Phase 0: Fundament für Inhaus
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7197eaebf2
commit
9c0f8de791
15771 changed files with 1564103 additions and 5 deletions
18
vendor/filament/support/src/ArrayRecord.php
vendored
Normal file
18
vendor/filament/support/src/ArrayRecord.php
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support;
|
||||
|
||||
class ArrayRecord
|
||||
{
|
||||
protected static string $keyName = '__key';
|
||||
|
||||
public static function keyName(string $keyName): void
|
||||
{
|
||||
static::$keyName = $keyName;
|
||||
}
|
||||
|
||||
public static function getKeyName(): string
|
||||
{
|
||||
return static::$keyName;
|
||||
}
|
||||
}
|
||||
23
vendor/filament/support/src/Assets/AlpineComponent.php
vendored
Normal file
23
vendor/filament/support/src/Assets/AlpineComponent.php
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Assets;
|
||||
|
||||
class AlpineComponent extends Asset
|
||||
{
|
||||
public function getPublicPath(): string
|
||||
{
|
||||
return public_path($this->getRelativePublicPath());
|
||||
}
|
||||
|
||||
public function getRelativePublicPath(): string
|
||||
{
|
||||
$path = config('filament.assets_path', '');
|
||||
|
||||
return ltrim("{$path}/js/{$this->getPackage()}/components/{$this->getId()}.js", '/');
|
||||
}
|
||||
|
||||
public function getSrc(): string
|
||||
{
|
||||
return asset($this->getRelativePublicPath()) . '?v=' . $this->getVersion();
|
||||
}
|
||||
}
|
||||
92
vendor/filament/support/src/Assets/Asset.php
vendored
Normal file
92
vendor/filament/support/src/Assets/Asset.php
vendored
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Assets;
|
||||
|
||||
use Composer\InstalledVersions;
|
||||
use Filament\Support\Facades\FilamentAsset;
|
||||
use Throwable;
|
||||
|
||||
abstract class Asset
|
||||
{
|
||||
protected string $id;
|
||||
|
||||
protected ?string $path = null;
|
||||
|
||||
protected bool $isLoadedOnRequest = false;
|
||||
|
||||
protected ?string $package = null;
|
||||
|
||||
final public function __construct(string $id, ?string $path = null)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
public static function make(string $id, ?string $path = null): static
|
||||
{
|
||||
return app(static::class, ['id' => $id, 'path' => $path]);
|
||||
}
|
||||
|
||||
public function loadedOnRequest(bool $condition = true): static
|
||||
{
|
||||
$this->isLoadedOnRequest = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function package(?string $package): static
|
||||
{
|
||||
$this->package = $package;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPackage(): ?string
|
||||
{
|
||||
return $this->package;
|
||||
}
|
||||
|
||||
public function getPath(): ?string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function isRemote(): bool
|
||||
{
|
||||
return str($this->getPath())->startsWith(['http://', 'https://', '//']);
|
||||
}
|
||||
|
||||
public function getVersion(): string
|
||||
{
|
||||
$package = $this->getPackage();
|
||||
|
||||
if (blank($package)) {
|
||||
return InstalledVersions::getVersion('filament/support');
|
||||
}
|
||||
|
||||
if (
|
||||
($package === 'app') &&
|
||||
filled($appVersion = FilamentAsset::getAppVersion())
|
||||
) {
|
||||
return $appVersion;
|
||||
}
|
||||
|
||||
try {
|
||||
return InstalledVersions::getVersion($package);
|
||||
} catch (Throwable $exception) {
|
||||
return InstalledVersions::getVersion('filament/support');
|
||||
}
|
||||
}
|
||||
|
||||
public function isLoadedOnRequest(): bool
|
||||
{
|
||||
return $this->isLoadedOnRequest;
|
||||
}
|
||||
|
||||
abstract public function getPublicPath(): string;
|
||||
}
|
||||
353
vendor/filament/support/src/Assets/AssetManager.php
vendored
Normal file
353
vendor/filament/support/src/Assets/AssetManager.php
vendored
Normal file
|
|
@ -0,0 +1,353 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Assets;
|
||||
|
||||
use Filament\Support\Colors\ColorManager;
|
||||
use Filament\Support\Facades\FilamentColor;
|
||||
use Illuminate\Support\Arr;
|
||||
use LogicException;
|
||||
|
||||
class AssetManager
|
||||
{
|
||||
/**
|
||||
* @var array<string, array<AlpineComponent>>
|
||||
*/
|
||||
protected array $alpineComponents = [];
|
||||
|
||||
/**
|
||||
* @var array<string, array<string, mixed>>
|
||||
*/
|
||||
protected array $cssVariables = [];
|
||||
|
||||
/**
|
||||
* @var array<string, array<string, mixed>>
|
||||
*/
|
||||
protected array $scriptData = [];
|
||||
|
||||
/**
|
||||
* @var array<string, array<Js>>
|
||||
*/
|
||||
protected array $scripts = [];
|
||||
|
||||
/**
|
||||
* @var array<string, array<Css>>
|
||||
*/
|
||||
protected array $styles = [];
|
||||
|
||||
/**
|
||||
* @var array<string, array<Font>>
|
||||
*/
|
||||
protected array $fonts = [];
|
||||
|
||||
/**
|
||||
* @var array<string, Theme>
|
||||
*/
|
||||
protected array $themes = [];
|
||||
|
||||
protected ?string $appVersion = null;
|
||||
|
||||
public function appVersion(?string $version): void
|
||||
{
|
||||
$this->appVersion = $version;
|
||||
}
|
||||
|
||||
public function getAppVersion(): ?string
|
||||
{
|
||||
return $this->appVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<Asset> $assets
|
||||
*/
|
||||
public function register(array $assets, string $package = 'app'): void
|
||||
{
|
||||
foreach ($assets as $asset) {
|
||||
$asset->package($package);
|
||||
|
||||
match (true) { /** @phpstan-ignore expr.resultUnused */
|
||||
$asset instanceof Theme => $this->themes[$asset->getId()] = $asset,
|
||||
$asset instanceof AlpineComponent => $this->alpineComponents[$package][] = $asset,
|
||||
$asset instanceof Css => $this->styles[$package][] = $asset,
|
||||
$asset instanceof Font => $this->fonts[$package][] = $asset,
|
||||
$asset instanceof Js => $this->scripts[$package][] = $asset,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $variables
|
||||
*/
|
||||
public function registerCssVariables(array $variables, ?string $package = null): void
|
||||
{
|
||||
$this->cssVariables[$package] = [
|
||||
...($this->cssVariables[$package] ?? []),
|
||||
...$variables,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public function registerScriptData(array $data, ?string $package = null): void
|
||||
{
|
||||
$this->scriptData[$package] = [
|
||||
...($this->scriptData[$package] ?? []),
|
||||
...$data,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string> | null $packages
|
||||
* @return array<AlpineComponent>
|
||||
*/
|
||||
public function getAlpineComponents(?array $packages = null): array
|
||||
{
|
||||
/** @var array<AlpineComponent> $assets */
|
||||
$assets = $this->getAssets($this->alpineComponents, $packages);
|
||||
|
||||
return $assets;
|
||||
}
|
||||
|
||||
public function getAlpineComponentSrc(string $id, string $package = 'app'): string
|
||||
{
|
||||
/** @var array<AlpineComponent> $components */
|
||||
$components = $this->getAlpineComponents([$package]);
|
||||
|
||||
foreach ($components as $component) {
|
||||
if ($component->getId() !== $id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $component->getSrc();
|
||||
}
|
||||
|
||||
throw new LogicException("Alpine component with ID [{$id}] not found for package [{$package}].");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string> | null $packages
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getScriptData(?array $packages = null): array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
foreach ($this->scriptData as $package => $packageData) {
|
||||
if (
|
||||
($packages !== null) &&
|
||||
filled($package) &&
|
||||
(! in_array($package, $packages))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = [
|
||||
...$data,
|
||||
...$packageData,
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getScriptSrc(string $id, string $package = 'app'): string
|
||||
{
|
||||
/** @var array<Js> $scripts */
|
||||
$scripts = $this->getScripts([$package]);
|
||||
|
||||
foreach ($scripts as $script) {
|
||||
if ($script->getId() !== $id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $script->getSrc();
|
||||
}
|
||||
|
||||
throw new LogicException("Script with ID [{$id}] not found for package [{$package}].");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string> | null $packages
|
||||
* @return array<Js>
|
||||
*/
|
||||
public function getScripts(?array $packages = null, bool $withCore = true): array
|
||||
{
|
||||
/** @var array<Js> $assets */
|
||||
$assets = $this->getAssets($this->scripts, $packages);
|
||||
|
||||
if (! $withCore) {
|
||||
$assets = array_filter(
|
||||
$assets,
|
||||
fn (Js $asset): bool => ! $asset->isCore(),
|
||||
);
|
||||
}
|
||||
|
||||
return $assets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string> | null $packages
|
||||
*/
|
||||
public function renderScripts(?array $packages = null, bool $withCore = false): string
|
||||
{
|
||||
/** @var array<Js> $assets */
|
||||
$assets = $this->getScripts($packages, $withCore);
|
||||
|
||||
if ($withCore) {
|
||||
usort(
|
||||
$assets,
|
||||
fn (Js $asset): int => $asset->isCore() ? 1 : -1,
|
||||
);
|
||||
}
|
||||
|
||||
return view('filament::assets', [
|
||||
'assets' => $assets,
|
||||
'data' => $this->getScriptData($packages),
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string> | null $packages
|
||||
* @return array<Font>
|
||||
*/
|
||||
public function getFonts(?array $packages = null): array
|
||||
{
|
||||
/** @var array<Font> $assets */
|
||||
$assets = $this->getAssets($this->fonts, $packages);
|
||||
|
||||
return $assets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string> | null $packages
|
||||
* @return array<Css>
|
||||
*/
|
||||
public function getStyles(?array $packages = null): array
|
||||
{
|
||||
/** @var array<Css> $assets */
|
||||
$assets = $this->getAssets($this->styles, $packages);
|
||||
|
||||
return $assets;
|
||||
}
|
||||
|
||||
public function getStyleHref(string $id, string $package = 'app'): string
|
||||
{
|
||||
/** @var array<Css> $styles */
|
||||
$styles = $this->getStyles([$package]);
|
||||
|
||||
foreach ($styles as $style) {
|
||||
if ($style->getId() !== $id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $style->getHref();
|
||||
}
|
||||
|
||||
throw new LogicException("Stylesheet with ID [{$id}] not found for package [{$package}].");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string> | null $packages
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getCssVariables(?array $packages = null): array
|
||||
{
|
||||
$variables = [];
|
||||
|
||||
foreach ($this->cssVariables as $package => $packageVariables) {
|
||||
if (
|
||||
($packages !== null) &&
|
||||
filled($package) &&
|
||||
(! in_array($package, $packages))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$variables = [
|
||||
...$variables,
|
||||
...$packageVariables,
|
||||
];
|
||||
}
|
||||
|
||||
return $variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string> | null $packages
|
||||
*/
|
||||
public function renderStyles(?array $packages = null): string
|
||||
{
|
||||
$cssVariables = $this->getCssVariables($packages);
|
||||
$customColors = [];
|
||||
|
||||
$defaultColorNames = array_keys(ColorManager::DEFAULT_COLORS);
|
||||
|
||||
foreach (FilamentColor::getColors() as $name => $palette) {
|
||||
foreach (array_keys($palette) as $shade) {
|
||||
$cssVariables["{$name}-{$shade}"] = $this->resolveColorShadeFromPalette($palette, $shade);
|
||||
}
|
||||
|
||||
if (! in_array($name, $defaultColorNames)) {
|
||||
$customColors[$name] = array_keys($palette);
|
||||
}
|
||||
}
|
||||
|
||||
return view('filament::assets', [
|
||||
'assets' => [
|
||||
...$this->getStyles($packages),
|
||||
...array_map(
|
||||
fn (Font $font): Css => $font->getStyle(),
|
||||
$this->getFonts($packages),
|
||||
),
|
||||
],
|
||||
'cssVariables' => $cssVariables,
|
||||
'customColors' => $customColors,
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int | string, string | int> $palette
|
||||
*/
|
||||
protected function resolveColorShadeFromPalette(array $palette, string | int $shade): string
|
||||
{
|
||||
$color = $palette[$shade];
|
||||
|
||||
while (! str_starts_with($color, 'oklch(')) {
|
||||
if ($color === 0) {
|
||||
return 'oklch(1 0 0)';
|
||||
}
|
||||
|
||||
$color = $palette[$color];
|
||||
}
|
||||
|
||||
return $color;
|
||||
}
|
||||
|
||||
public function getTheme(?string $id): ?Theme
|
||||
{
|
||||
return $this->getThemes()[$id] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, Theme>
|
||||
*/
|
||||
public function getThemes(): array
|
||||
{
|
||||
return $this->themes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, array<Asset>> $assets
|
||||
* @param array<string> | null $packages
|
||||
* @return array<Asset>
|
||||
*/
|
||||
protected function getAssets(array $assets, ?array $packages = null): array
|
||||
{
|
||||
if ($packages !== null) {
|
||||
$assets = Arr::only($assets, $packages);
|
||||
}
|
||||
|
||||
return Arr::flatten($assets);
|
||||
}
|
||||
}
|
||||
70
vendor/filament/support/src/Assets/Css.php
vendored
Normal file
70
vendor/filament/support/src/Assets/Css.php
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Assets;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class Css extends Asset
|
||||
{
|
||||
protected string | Htmlable | Closure | null $html = null;
|
||||
|
||||
protected ?string $relativePublicPath = null;
|
||||
|
||||
public function html(string | Htmlable | Closure | null $html): static
|
||||
{
|
||||
$this->html = $html;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function relativePublicPath(?string $relativePublicPath): static
|
||||
{
|
||||
$this->relativePublicPath = $relativePublicPath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHref(): string
|
||||
{
|
||||
if ($this->isRemote()) {
|
||||
return $this->getPath();
|
||||
}
|
||||
|
||||
return asset($this->getRelativePublicPath()) . '?v=' . $this->getVersion();
|
||||
}
|
||||
|
||||
public function getHtml(): Htmlable
|
||||
{
|
||||
$html = value($this->html);
|
||||
|
||||
if (str($html)->contains('<link')) {
|
||||
return $html instanceof Htmlable ? $html : new HtmlString($html);
|
||||
}
|
||||
|
||||
$html ??= $this->getHref();
|
||||
|
||||
return new HtmlString("<link
|
||||
href=\"{$html}\"
|
||||
rel=\"stylesheet\"
|
||||
data-navigate-track
|
||||
/>");
|
||||
}
|
||||
|
||||
public function getRelativePublicPath(): string
|
||||
{
|
||||
if (filled($this->relativePublicPath)) {
|
||||
return $this->relativePublicPath;
|
||||
}
|
||||
|
||||
$path = config('filament.assets_path', '');
|
||||
|
||||
return ltrim("{$path}/css/{$this->getPackage()}/{$this->getId()}.css", '/');
|
||||
}
|
||||
|
||||
public function getPublicPath(): string
|
||||
{
|
||||
return public_path($this->getRelativePublicPath());
|
||||
}
|
||||
}
|
||||
24
vendor/filament/support/src/Assets/Font.php
vendored
Normal file
24
vendor/filament/support/src/Assets/Font.php
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Assets;
|
||||
|
||||
class Font extends Asset
|
||||
{
|
||||
public function getStyle(): Css
|
||||
{
|
||||
return Css::make($this->getId(), path: $this->getPath() . DIRECTORY_SEPARATOR . 'index.css')
|
||||
->relativePublicPath($this->getRelativePublicPath() . DIRECTORY_SEPARATOR . 'index.css');
|
||||
}
|
||||
|
||||
public function getRelativePublicPath(): string
|
||||
{
|
||||
$path = config('filament.assets_path', '');
|
||||
|
||||
return ltrim("{$path}/fonts/{$this->getPackage()}/{$this->getId()}", '/');
|
||||
}
|
||||
|
||||
public function getPublicPath(): string
|
||||
{
|
||||
return public_path($this->getRelativePublicPath());
|
||||
}
|
||||
}
|
||||
182
vendor/filament/support/src/Assets/Js.php
vendored
Normal file
182
vendor/filament/support/src/Assets/Js.php
vendored
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Assets;
|
||||
|
||||
use Filament\Support\Facades\FilamentView;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class Js extends Asset
|
||||
{
|
||||
protected bool $isAsync = false;
|
||||
|
||||
protected bool $isDeferred = false;
|
||||
|
||||
protected bool $isCore = false;
|
||||
|
||||
protected bool $isNavigateOnce = true;
|
||||
|
||||
protected bool $isModule = false;
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected array $extraAttributes = [];
|
||||
|
||||
protected string | Htmlable | null $html = null;
|
||||
|
||||
public function async(bool $condition = true): static
|
||||
{
|
||||
$this->isAsync = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function defer(bool $condition = true): static
|
||||
{
|
||||
$this->isDeferred = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function core(bool $condition = true): static
|
||||
{
|
||||
$this->isCore = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function navigateOnce(bool $condition = true): static
|
||||
{
|
||||
$this->isNavigateOnce = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function module(bool $condition = true): static
|
||||
{
|
||||
$this->isModule = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function html(string | Htmlable | null $html): static
|
||||
{
|
||||
$this->html = $html;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isAsync(): bool
|
||||
{
|
||||
return $this->isAsync;
|
||||
}
|
||||
|
||||
public function isDeferred(): bool
|
||||
{
|
||||
return $this->isDeferred;
|
||||
}
|
||||
|
||||
public function isCore(): bool
|
||||
{
|
||||
return $this->isCore;
|
||||
}
|
||||
|
||||
public function isNavigateOnce(): bool
|
||||
{
|
||||
return $this->isNavigateOnce;
|
||||
}
|
||||
|
||||
public function isModule(): bool
|
||||
{
|
||||
return $this->isModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $attributes
|
||||
*/
|
||||
public function extraAttributes(array $attributes): static
|
||||
{
|
||||
// Security: Attribute values are not escaped when rendered. Never
|
||||
// pass unsanitized user input as attribute names or values.
|
||||
|
||||
$this->extraAttributes = $attributes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHtml(): Htmlable
|
||||
{
|
||||
$html = $this->html;
|
||||
|
||||
if (str($html)->contains('<script')) {
|
||||
return $html instanceof Htmlable ? $html : new HtmlString($html);
|
||||
}
|
||||
|
||||
$html ??= $this->getSrc();
|
||||
|
||||
$async = $this->isAsync() ? 'async' : '';
|
||||
$defer = $this->isDeferred() ? 'defer' : '';
|
||||
$module = $this->isModule() ? 'type="module"' : '';
|
||||
$extraAttributesHtml = $this->getExtraAttributesHtml();
|
||||
|
||||
$hasSpaMode = FilamentView::hasSpaMode();
|
||||
|
||||
$navigateOnce = ($hasSpaMode && $this->isNavigateOnce()) ? 'data-navigate-once' : '';
|
||||
$navigateTrack = $hasSpaMode ? 'data-navigate-track' : '';
|
||||
|
||||
return new HtmlString(
|
||||
"
|
||||
<script
|
||||
src=\"{$html}\"
|
||||
{$async}
|
||||
{$defer}
|
||||
{$module}
|
||||
{$extraAttributesHtml}
|
||||
{$navigateOnce}
|
||||
{$navigateTrack}
|
||||
></script>
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getExtraAttributes(): array
|
||||
{
|
||||
return $this->extraAttributes;
|
||||
}
|
||||
|
||||
public function getExtraAttributesHtml(): string
|
||||
{
|
||||
$attributes = '';
|
||||
|
||||
foreach ($this->getExtraAttributes() as $key => $value) {
|
||||
$attributes .= " {$key}=\"{$value}\"";
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
public function getSrc(): string
|
||||
{
|
||||
if ($this->isRemote()) {
|
||||
return $this->getPath();
|
||||
}
|
||||
|
||||
return asset($this->getRelativePublicPath()) . '?v=' . $this->getVersion();
|
||||
}
|
||||
|
||||
public function getRelativePublicPath(): string
|
||||
{
|
||||
$path = config('filament.assets_path', '');
|
||||
|
||||
return ltrim("{$path}/js/{$this->getPackage()}/{$this->getId()}.js", '/');
|
||||
}
|
||||
|
||||
public function getPublicPath(): string
|
||||
{
|
||||
return public_path($this->getRelativePublicPath());
|
||||
}
|
||||
}
|
||||
5
vendor/filament/support/src/Assets/Theme.php
vendored
Normal file
5
vendor/filament/support/src/Assets/Theme.php
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Assets;
|
||||
|
||||
class Theme extends Css {}
|
||||
66
vendor/filament/support/src/Authorization/DenyResponse.php
vendored
Normal file
66
vendor/filament/support/src/Authorization/DenyResponse.php
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Authorization;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
class DenyResponse extends Response
|
||||
{
|
||||
protected ?string $key = null;
|
||||
|
||||
protected ?Closure $getMessageUsing = null;
|
||||
|
||||
public static function make(string $key, string | Closure $message): Response
|
||||
{
|
||||
$static = static::deny(is_string($message) ? $message : null);
|
||||
|
||||
if ($static instanceof DenyResponse) {
|
||||
$static->key($key);
|
||||
|
||||
if ($message instanceof Closure) {
|
||||
$static->getMessageUsing($message);
|
||||
}
|
||||
}
|
||||
|
||||
return $static;
|
||||
}
|
||||
|
||||
public function key(?string $key): static
|
||||
{
|
||||
$this->key = $key;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getKey(): ?string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function getMessageUsing(?Closure $callback): static
|
||||
{
|
||||
$this->getMessageUsing = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function message(int $count = 1, int $total = 1): ?string
|
||||
{
|
||||
if ($this->getMessageUsing) {
|
||||
return app()->call($this->getMessageUsing, [
|
||||
'count' => $count,
|
||||
'failureCount' => $count,
|
||||
'isAll' => $count === $total,
|
||||
'total' => $total,
|
||||
'totalCount' => $total,
|
||||
])
|
||||
?? parent::message()
|
||||
?? (($count === 1) && ($total === 1)
|
||||
? null
|
||||
: $this->message());
|
||||
}
|
||||
|
||||
return parent::message();
|
||||
}
|
||||
}
|
||||
39
vendor/filament/support/src/ChunkIterator.php
vendored
Normal file
39
vendor/filament/support/src/ChunkIterator.php
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support;
|
||||
|
||||
use Generator;
|
||||
use Iterator;
|
||||
|
||||
class ChunkIterator
|
||||
{
|
||||
public function __construct(
|
||||
protected Iterator $iterator,
|
||||
protected int $chunkSize,
|
||||
) {}
|
||||
|
||||
public function get(): Generator
|
||||
{
|
||||
$this->iterator->rewind();
|
||||
|
||||
$chunk = [];
|
||||
|
||||
for ($i = 0; $this->iterator->valid(); $i++) {
|
||||
$chunk[] = $this->iterator->current();
|
||||
|
||||
$this->iterator->next();
|
||||
|
||||
if (count($chunk) !== $this->chunkSize) {
|
||||
continue;
|
||||
}
|
||||
|
||||
yield $chunk;
|
||||
|
||||
$chunk = [];
|
||||
}
|
||||
|
||||
if (count($chunk)) {
|
||||
yield $chunk;
|
||||
}
|
||||
}
|
||||
}
|
||||
48
vendor/filament/support/src/CliManager.php
vendored
Normal file
48
vendor/filament/support/src/CliManager.php
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support;
|
||||
|
||||
class CliManager
|
||||
{
|
||||
/**
|
||||
* @var array<string, array{path: string, viewNamespace: ?string}>
|
||||
*/
|
||||
protected array $componentLocations = [];
|
||||
|
||||
/**
|
||||
* @var array<string, array{path: string, viewNamespace: ?string}>
|
||||
*/
|
||||
protected array $livewireComponentLocations = [];
|
||||
|
||||
public function registerComponentLocation(string $path, string $namespace, ?string $viewNamespace): void
|
||||
{
|
||||
$this->componentLocations[$namespace] = [
|
||||
'path' => $path,
|
||||
'viewNamespace' => $viewNamespace,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array{path: string, viewNamespace: ?string}>
|
||||
*/
|
||||
public function getComponentLocations(): array
|
||||
{
|
||||
return $this->componentLocations;
|
||||
}
|
||||
|
||||
public function registerLivewireComponentLocation(string $path, string $namespace, ?string $viewNamespace): void
|
||||
{
|
||||
$this->livewireComponentLocations[$namespace] = [
|
||||
'path' => $path,
|
||||
'viewNamespace' => $viewNamespace,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array{path: string, viewNamespace: ?string}>
|
||||
*/
|
||||
public function getLivewireComponentLocations(): array
|
||||
{
|
||||
return $this->livewireComponentLocations;
|
||||
}
|
||||
}
|
||||
732
vendor/filament/support/src/Colors/Color.php
vendored
Normal file
732
vendor/filament/support/src/Colors/Color.php
vendored
Normal file
|
|
@ -0,0 +1,732 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Colors;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Color
|
||||
{
|
||||
/**
|
||||
* WCAG 2.1 minimum contrast ratio for normal-size text at conformance level AA
|
||||
* (success criterion 1.4.3 Contrast (Minimum)).
|
||||
*
|
||||
* @ref https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html
|
||||
*/
|
||||
public const WCAG_AA_TEXT = 4.5;
|
||||
|
||||
/**
|
||||
* WCAG 2.1 minimum contrast ratio for large-scale text at conformance level AA
|
||||
* (success criterion 1.4.3 Contrast (Minimum)).
|
||||
*
|
||||
* @ref https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html
|
||||
*/
|
||||
public const WCAG_AA_LARGE_TEXT = 3.0;
|
||||
|
||||
/**
|
||||
* WCAG 2.1 contrast ratio for user interface components and graphical objects
|
||||
* (success criterion 1.4.11 Non-text Contrast). Defined only at conformance level AA.
|
||||
*
|
||||
* @ref https://www.w3.org/WAI/WCAG21/Understanding/non-text-contrast.html
|
||||
*/
|
||||
public const WCAG_AA_NON_TEXT = 3.0;
|
||||
|
||||
/**
|
||||
* WCAG 2.1 enhanced contrast ratio for normal-size text at conformance level AAA
|
||||
* (success criterion 1.4.6 Contrast (Enhanced)).
|
||||
*
|
||||
* @ref https://www.w3.org/WAI/WCAG21/Understanding/contrast-enhanced.html
|
||||
*/
|
||||
public const WCAG_AAA_TEXT = 7.0;
|
||||
|
||||
/**
|
||||
* WCAG 2.1 enhanced contrast ratio for large-scale text at conformance level AAA
|
||||
* (success criterion 1.4.6 Contrast (Enhanced)).
|
||||
*
|
||||
* @ref https://www.w3.org/WAI/WCAG21/Understanding/contrast-enhanced.html
|
||||
*/
|
||||
public const WCAG_AAA_LARGE_TEXT = 4.5;
|
||||
|
||||
public const Slate = [
|
||||
50 => 'oklch(0.984 0.003 247.858)',
|
||||
100 => 'oklch(0.968 0.007 247.896)',
|
||||
200 => 'oklch(0.929 0.013 255.508)',
|
||||
300 => 'oklch(0.869 0.022 252.894)',
|
||||
400 => 'oklch(0.704 0.04 256.788)',
|
||||
500 => 'oklch(0.554 0.046 257.417)',
|
||||
600 => 'oklch(0.446 0.043 257.281)',
|
||||
700 => 'oklch(0.372 0.044 257.287)',
|
||||
800 => 'oklch(0.279 0.041 260.031)',
|
||||
900 => 'oklch(0.208 0.042 265.755)',
|
||||
950 => 'oklch(0.129 0.042 264.695)',
|
||||
];
|
||||
|
||||
public const Gray = [
|
||||
50 => 'oklch(0.985 0.002 247.839)',
|
||||
100 => 'oklch(0.967 0.003 264.542)',
|
||||
200 => 'oklch(0.928 0.006 264.531)',
|
||||
300 => 'oklch(0.872 0.01 258.338)',
|
||||
400 => 'oklch(0.707 0.022 261.325)',
|
||||
500 => 'oklch(0.551 0.027 264.364)',
|
||||
600 => 'oklch(0.446 0.03 256.802)',
|
||||
700 => 'oklch(0.373 0.034 259.733)',
|
||||
800 => 'oklch(0.278 0.033 256.848)',
|
||||
900 => 'oklch(0.21 0.034 264.665)',
|
||||
950 => 'oklch(0.13 0.028 261.692)',
|
||||
];
|
||||
|
||||
public const Zinc = [
|
||||
50 => 'oklch(0.985 0 0)',
|
||||
100 => 'oklch(0.967 0.001 286.375)',
|
||||
200 => 'oklch(0.92 0.004 286.32)',
|
||||
300 => 'oklch(0.871 0.006 286.286)',
|
||||
400 => 'oklch(0.705 0.015 286.067)',
|
||||
500 => 'oklch(0.552 0.016 285.938)',
|
||||
600 => 'oklch(0.442 0.017 285.786)',
|
||||
700 => 'oklch(0.37 0.013 285.805)',
|
||||
800 => 'oklch(0.274 0.006 286.033)',
|
||||
900 => 'oklch(0.21 0.006 285.885)',
|
||||
950 => 'oklch(0.141 0.005 285.823)',
|
||||
];
|
||||
|
||||
public const Neutral = [
|
||||
50 => 'oklch(0.985 0 0)',
|
||||
100 => 'oklch(0.97 0 0)',
|
||||
200 => 'oklch(0.922 0 0)',
|
||||
300 => 'oklch(0.87 0 0)',
|
||||
400 => 'oklch(0.708 0 0)',
|
||||
500 => 'oklch(0.556 0 0)',
|
||||
600 => 'oklch(0.439 0 0)',
|
||||
700 => 'oklch(0.371 0 0)',
|
||||
800 => 'oklch(0.269 0 0)',
|
||||
900 => 'oklch(0.205 0 0)',
|
||||
950 => 'oklch(0.145 0 0)',
|
||||
];
|
||||
|
||||
public const Stone = [
|
||||
50 => 'oklch(0.985 0.001 106.423)',
|
||||
100 => 'oklch(0.97 0.001 106.424)',
|
||||
200 => 'oklch(0.923 0.003 48.717)',
|
||||
300 => 'oklch(0.869 0.005 56.366)',
|
||||
400 => 'oklch(0.709 0.01 56.259)',
|
||||
500 => 'oklch(0.553 0.013 58.071)',
|
||||
600 => 'oklch(0.444 0.011 73.639)',
|
||||
700 => 'oklch(0.374 0.01 67.558)',
|
||||
800 => 'oklch(0.268 0.007 34.298)',
|
||||
900 => 'oklch(0.216 0.006 56.043)',
|
||||
950 => 'oklch(0.147 0.004 49.25)',
|
||||
];
|
||||
|
||||
public const Mauve = [
|
||||
50 => 'oklch(0.985 0 0)',
|
||||
100 => 'oklch(0.96 0.003 325.6)',
|
||||
200 => 'oklch(0.922 0.005 325.62)',
|
||||
300 => 'oklch(0.865 0.012 325.68)',
|
||||
400 => 'oklch(0.711 0.019 323.02)',
|
||||
500 => 'oklch(0.542 0.034 322.5)',
|
||||
600 => 'oklch(0.435 0.029 321.78)',
|
||||
700 => 'oklch(0.364 0.029 323.89)',
|
||||
800 => 'oklch(0.263 0.024 320.12)',
|
||||
900 => 'oklch(0.212 0.019 322.12)',
|
||||
950 => 'oklch(0.145 0.008 326)',
|
||||
];
|
||||
|
||||
public const Olive = [
|
||||
50 => 'oklch(0.988 0.003 106.5)',
|
||||
100 => 'oklch(0.966 0.005 106.5)',
|
||||
200 => 'oklch(0.93 0.007 106.5)',
|
||||
300 => 'oklch(0.88 0.011 106.6)',
|
||||
400 => 'oklch(0.737 0.021 106.9)',
|
||||
500 => 'oklch(0.58 0.031 107.3)',
|
||||
600 => 'oklch(0.466 0.025 107.3)',
|
||||
700 => 'oklch(0.394 0.023 107.4)',
|
||||
800 => 'oklch(0.286 0.016 107.4)',
|
||||
900 => 'oklch(0.228 0.013 107.4)',
|
||||
950 => 'oklch(0.153 0.006 107.1)',
|
||||
];
|
||||
|
||||
public const Mist = [
|
||||
50 => 'oklch(0.987 0.002 197.1)',
|
||||
100 => 'oklch(0.963 0.002 197.1)',
|
||||
200 => 'oklch(0.925 0.005 214.3)',
|
||||
300 => 'oklch(0.872 0.007 219.6)',
|
||||
400 => 'oklch(0.723 0.014 214.4)',
|
||||
500 => 'oklch(0.56 0.021 213.5)',
|
||||
600 => 'oklch(0.45 0.017 213.2)',
|
||||
700 => 'oklch(0.378 0.015 216)',
|
||||
800 => 'oklch(0.275 0.011 216.9)',
|
||||
900 => 'oklch(0.218 0.008 223.9)',
|
||||
950 => 'oklch(0.148 0.004 228.8)',
|
||||
];
|
||||
|
||||
public const Taupe = [
|
||||
50 => 'oklch(0.986 0.002 67.8)',
|
||||
100 => 'oklch(0.96 0.002 17.2)',
|
||||
200 => 'oklch(0.922 0.005 34.3)',
|
||||
300 => 'oklch(0.868 0.007 39.5)',
|
||||
400 => 'oklch(0.714 0.014 41.2)',
|
||||
500 => 'oklch(0.547 0.021 43.1)',
|
||||
600 => 'oklch(0.438 0.017 39.3)',
|
||||
700 => 'oklch(0.367 0.016 35.7)',
|
||||
800 => 'oklch(0.268 0.011 36.5)',
|
||||
900 => 'oklch(0.214 0.009 43.1)',
|
||||
950 => 'oklch(0.147 0.004 49.3)',
|
||||
];
|
||||
|
||||
public const Red = [
|
||||
50 => 'oklch(0.971 0.013 17.38)',
|
||||
100 => 'oklch(0.936 0.032 17.717)',
|
||||
200 => 'oklch(0.885 0.062 18.334)',
|
||||
300 => 'oklch(0.808 0.114 19.571)',
|
||||
400 => 'oklch(0.704 0.191 22.216)',
|
||||
500 => 'oklch(0.637 0.237 25.331)',
|
||||
600 => 'oklch(0.577 0.245 27.325)',
|
||||
700 => 'oklch(0.505 0.213 27.518)',
|
||||
800 => 'oklch(0.444 0.177 26.899)',
|
||||
900 => 'oklch(0.396 0.141 25.723)',
|
||||
950 => 'oklch(0.258 0.092 26.042)',
|
||||
];
|
||||
|
||||
public const Orange = [
|
||||
50 => 'oklch(0.98 0.016 73.684)',
|
||||
100 => 'oklch(0.954 0.038 75.164)',
|
||||
200 => 'oklch(0.901 0.076 70.697)',
|
||||
300 => 'oklch(0.837 0.128 66.29)',
|
||||
400 => 'oklch(0.75 0.183 55.934)',
|
||||
500 => 'oklch(0.705 0.213 47.604)',
|
||||
600 => 'oklch(0.646 0.222 41.116)',
|
||||
700 => 'oklch(0.553 0.195 38.402)',
|
||||
800 => 'oklch(0.47 0.157 37.304)',
|
||||
900 => 'oklch(0.408 0.123 38.172)',
|
||||
950 => 'oklch(0.266 0.079 36.259)',
|
||||
];
|
||||
|
||||
public const Amber = [
|
||||
50 => 'oklch(0.987 0.022 95.277)',
|
||||
100 => 'oklch(0.962 0.059 95.617)',
|
||||
200 => 'oklch(0.924 0.12 95.746)',
|
||||
300 => 'oklch(0.879 0.169 91.605)',
|
||||
400 => 'oklch(0.828 0.189 84.429)',
|
||||
500 => 'oklch(0.769 0.188 70.08)',
|
||||
600 => 'oklch(0.666 0.179 58.318)',
|
||||
700 => 'oklch(0.555 0.163 48.998)',
|
||||
800 => 'oklch(0.473 0.137 46.201)',
|
||||
900 => 'oklch(0.414 0.112 45.904)',
|
||||
950 => 'oklch(0.279 0.077 45.635)',
|
||||
];
|
||||
|
||||
public const Yellow = [
|
||||
50 => 'oklch(0.987 0.026 102.212)',
|
||||
100 => 'oklch(0.973 0.071 103.193)',
|
||||
200 => 'oklch(0.945 0.129 101.54)',
|
||||
300 => 'oklch(0.905 0.182 98.111)',
|
||||
400 => 'oklch(0.852 0.199 91.936)',
|
||||
500 => 'oklch(0.795 0.184 86.047)',
|
||||
600 => 'oklch(0.681 0.162 75.834)',
|
||||
700 => 'oklch(0.554 0.135 66.442)',
|
||||
800 => 'oklch(0.476 0.114 61.907)',
|
||||
900 => 'oklch(0.421 0.095 57.708)',
|
||||
950 => 'oklch(0.286 0.066 53.813)',
|
||||
];
|
||||
|
||||
public const Lime = [
|
||||
50 => 'oklch(0.986 0.031 120.757)',
|
||||
100 => 'oklch(0.967 0.067 122.328)',
|
||||
200 => 'oklch(0.938 0.127 124.321)',
|
||||
300 => 'oklch(0.897 0.196 126.665)',
|
||||
400 => 'oklch(0.841 0.238 128.85)',
|
||||
500 => 'oklch(0.768 0.233 130.85)',
|
||||
600 => 'oklch(0.648 0.2 131.684)',
|
||||
700 => 'oklch(0.532 0.157 131.589)',
|
||||
800 => 'oklch(0.453 0.124 130.933)',
|
||||
900 => 'oklch(0.405 0.101 131.063)',
|
||||
950 => 'oklch(0.274 0.072 132.109)',
|
||||
];
|
||||
|
||||
public const Green = [
|
||||
50 => 'oklch(0.982 0.018 155.826)',
|
||||
100 => 'oklch(0.962 0.044 156.743)',
|
||||
200 => 'oklch(0.925 0.084 155.995)',
|
||||
300 => 'oklch(0.871 0.15 154.449)',
|
||||
400 => 'oklch(0.792 0.209 151.711)',
|
||||
500 => 'oklch(0.723 0.219 149.579)',
|
||||
600 => 'oklch(0.627 0.194 149.214)',
|
||||
700 => 'oklch(0.527 0.154 150.069)',
|
||||
800 => 'oklch(0.448 0.119 151.328)',
|
||||
900 => 'oklch(0.393 0.095 152.535)',
|
||||
950 => 'oklch(0.266 0.065 152.934)',
|
||||
];
|
||||
|
||||
public const Emerald = [
|
||||
50 => 'oklch(0.979 0.021 166.113)',
|
||||
100 => 'oklch(0.95 0.052 163.051)',
|
||||
200 => 'oklch(0.905 0.093 164.15)',
|
||||
300 => 'oklch(0.845 0.143 164.978)',
|
||||
400 => 'oklch(0.765 0.177 163.223)',
|
||||
500 => 'oklch(0.696 0.17 162.48)',
|
||||
600 => 'oklch(0.596 0.145 163.225)',
|
||||
700 => 'oklch(0.508 0.118 165.612)',
|
||||
800 => 'oklch(0.432 0.095 166.913)',
|
||||
900 => 'oklch(0.378 0.077 168.94)',
|
||||
950 => 'oklch(0.262 0.051 172.552)',
|
||||
];
|
||||
|
||||
public const Teal = [
|
||||
50 => 'oklch(0.984 0.014 180.72)',
|
||||
100 => 'oklch(0.953 0.051 180.801)',
|
||||
200 => 'oklch(0.91 0.096 180.426)',
|
||||
300 => 'oklch(0.855 0.138 181.071)',
|
||||
400 => 'oklch(0.777 0.152 181.912)',
|
||||
500 => 'oklch(0.704 0.14 182.503)',
|
||||
600 => 'oklch(0.6 0.118 184.704)',
|
||||
700 => 'oklch(0.511 0.096 186.391)',
|
||||
800 => 'oklch(0.437 0.078 188.216)',
|
||||
900 => 'oklch(0.386 0.063 188.416)',
|
||||
950 => 'oklch(0.277 0.046 192.524)',
|
||||
];
|
||||
|
||||
public const Cyan = [
|
||||
50 => 'oklch(0.984 0.019 200.873)',
|
||||
100 => 'oklch(0.956 0.045 203.388)',
|
||||
200 => 'oklch(0.917 0.08 205.041)',
|
||||
300 => 'oklch(0.865 0.127 207.078)',
|
||||
400 => 'oklch(0.789 0.154 211.53)',
|
||||
500 => 'oklch(0.715 0.143 215.221)',
|
||||
600 => 'oklch(0.609 0.126 221.723)',
|
||||
700 => 'oklch(0.52 0.105 223.128)',
|
||||
800 => 'oklch(0.45 0.085 224.283)',
|
||||
900 => 'oklch(0.398 0.07 227.392)',
|
||||
950 => 'oklch(0.302 0.056 229.695)',
|
||||
];
|
||||
|
||||
public const Sky = [
|
||||
50 => 'oklch(0.977 0.013 236.62)',
|
||||
100 => 'oklch(0.951 0.026 236.824)',
|
||||
200 => 'oklch(0.901 0.058 230.902)',
|
||||
300 => 'oklch(0.828 0.111 230.318)',
|
||||
400 => 'oklch(0.746 0.16 232.661)',
|
||||
500 => 'oklch(0.685 0.169 237.323)',
|
||||
600 => 'oklch(0.588 0.158 241.966)',
|
||||
700 => 'oklch(0.5 0.134 242.749)',
|
||||
800 => 'oklch(0.443 0.11 240.79)',
|
||||
900 => 'oklch(0.391 0.09 240.876)',
|
||||
950 => 'oklch(0.293 0.066 243.157)',
|
||||
];
|
||||
|
||||
public const Blue = [
|
||||
50 => 'oklch(0.97 0.014 254.604)',
|
||||
100 => 'oklch(0.932 0.032 255.585)',
|
||||
200 => 'oklch(0.882 0.059 254.128)',
|
||||
300 => 'oklch(0.809 0.105 251.813)',
|
||||
400 => 'oklch(0.707 0.165 254.624)',
|
||||
500 => 'oklch(0.623 0.214 259.815)',
|
||||
600 => 'oklch(0.546 0.245 262.881)',
|
||||
700 => 'oklch(0.488 0.243 264.376)',
|
||||
800 => 'oklch(0.424 0.199 265.638)',
|
||||
900 => 'oklch(0.379 0.146 265.522)',
|
||||
950 => 'oklch(0.282 0.091 267.935)',
|
||||
];
|
||||
|
||||
public const Indigo = [
|
||||
50 => 'oklch(0.962 0.018 272.314)',
|
||||
100 => 'oklch(0.93 0.034 272.788)',
|
||||
200 => 'oklch(0.87 0.065 274.039)',
|
||||
300 => 'oklch(0.785 0.115 274.713)',
|
||||
400 => 'oklch(0.673 0.182 276.935)',
|
||||
500 => 'oklch(0.585 0.233 277.117)',
|
||||
600 => 'oklch(0.511 0.262 276.966)',
|
||||
700 => 'oklch(0.457 0.24 277.023)',
|
||||
800 => 'oklch(0.398 0.195 277.366)',
|
||||
900 => 'oklch(0.359 0.144 278.697)',
|
||||
950 => 'oklch(0.257 0.09 281.288)',
|
||||
];
|
||||
|
||||
public const Violet = [
|
||||
50 => 'oklch(0.969 0.016 293.756)',
|
||||
100 => 'oklch(0.943 0.029 294.588)',
|
||||
200 => 'oklch(0.894 0.057 293.283)',
|
||||
300 => 'oklch(0.811 0.111 293.571)',
|
||||
400 => 'oklch(0.702 0.183 293.541)',
|
||||
500 => 'oklch(0.606 0.25 292.717)',
|
||||
600 => 'oklch(0.541 0.281 293.009)',
|
||||
700 => 'oklch(0.491 0.27 292.581)',
|
||||
800 => 'oklch(0.432 0.232 292.759)',
|
||||
900 => 'oklch(0.38 0.189 293.745)',
|
||||
950 => 'oklch(0.283 0.141 291.089)',
|
||||
];
|
||||
|
||||
public const Purple = [
|
||||
50 => 'oklch(0.977 0.014 308.299)',
|
||||
100 => 'oklch(0.946 0.033 307.174)',
|
||||
200 => 'oklch(0.902 0.063 306.703)',
|
||||
300 => 'oklch(0.827 0.119 306.383)',
|
||||
400 => 'oklch(0.714 0.203 305.504)',
|
||||
500 => 'oklch(0.627 0.265 303.9)',
|
||||
600 => 'oklch(0.558 0.288 302.321)',
|
||||
700 => 'oklch(0.496 0.265 301.924)',
|
||||
800 => 'oklch(0.438 0.218 303.724)',
|
||||
900 => 'oklch(0.381 0.176 304.987)',
|
||||
950 => 'oklch(0.291 0.149 302.717)',
|
||||
];
|
||||
|
||||
public const Fuchsia = [
|
||||
50 => 'oklch(0.977 0.017 320.058)',
|
||||
100 => 'oklch(0.952 0.037 318.852)',
|
||||
200 => 'oklch(0.903 0.076 319.62)',
|
||||
300 => 'oklch(0.833 0.145 321.434)',
|
||||
400 => 'oklch(0.74 0.238 322.16)',
|
||||
500 => 'oklch(0.667 0.295 322.15)',
|
||||
600 => 'oklch(0.591 0.293 322.896)',
|
||||
700 => 'oklch(0.518 0.253 323.949)',
|
||||
800 => 'oklch(0.452 0.211 324.591)',
|
||||
900 => 'oklch(0.401 0.17 325.612)',
|
||||
950 => 'oklch(0.293 0.136 325.661)',
|
||||
];
|
||||
|
||||
public const Pink = [
|
||||
50 => 'oklch(0.971 0.014 343.198)',
|
||||
100 => 'oklch(0.948 0.028 342.258)',
|
||||
200 => 'oklch(0.899 0.061 343.231)',
|
||||
300 => 'oklch(0.823 0.12 346.018)',
|
||||
400 => 'oklch(0.718 0.202 349.761)',
|
||||
500 => 'oklch(0.656 0.241 354.308)',
|
||||
600 => 'oklch(0.592 0.249 0.584)',
|
||||
700 => 'oklch(0.525 0.223 3.958)',
|
||||
800 => 'oklch(0.459 0.187 3.815)',
|
||||
900 => 'oklch(0.408 0.153 2.432)',
|
||||
950 => 'oklch(0.284 0.109 3.907)',
|
||||
];
|
||||
|
||||
public const Rose = [
|
||||
50 => 'oklch(0.969 0.015 12.422)',
|
||||
100 => 'oklch(0.941 0.03 12.58)',
|
||||
200 => 'oklch(0.892 0.058 10.001)',
|
||||
300 => 'oklch(0.81 0.117 11.638)',
|
||||
400 => 'oklch(0.712 0.194 13.428)',
|
||||
500 => 'oklch(0.645 0.246 16.439)',
|
||||
600 => 'oklch(0.586 0.253 17.585)',
|
||||
700 => 'oklch(0.514 0.222 16.935)',
|
||||
800 => 'oklch(0.455 0.188 13.697)',
|
||||
900 => 'oklch(0.41 0.159 10.272)',
|
||||
950 => 'oklch(0.271 0.105 12.094)',
|
||||
];
|
||||
|
||||
public static function convertToOklch(string $color): string
|
||||
{
|
||||
if (str_starts_with($color, 'oklch(')) {
|
||||
return $color;
|
||||
}
|
||||
|
||||
$color = str_replace(' ', '', $color);
|
||||
|
||||
if (str_starts_with($color, '#')) {
|
||||
[$red, $green, $blue] = sscanf($color, '#%02x%02x%02x');
|
||||
} elseif (str_starts_with($color, 'rgb(')) {
|
||||
[$red, $green, $blue] = sscanf($color, 'rgb(%d,%d,%d)');
|
||||
} else {
|
||||
[$red, $green, $blue] = sscanf($color, '%d,%d,%d');
|
||||
}
|
||||
|
||||
// Normalize RGB values to between 0 and 1
|
||||
$red /= 255;
|
||||
$green /= 255;
|
||||
$blue /= 255;
|
||||
|
||||
// Linearize RGB values
|
||||
$red = $red <= 0.04045 ? $red / 12.92 : pow(($red + 0.055) / 1.055, 2.4);
|
||||
$green = $green <= 0.04045 ? $green / 12.92 : pow(($green + 0.055) / 1.055, 2.4);
|
||||
$blue = $blue <= 0.04045 ? $blue / 12.92 : pow(($blue + 0.055) / 1.055, 2.4);
|
||||
|
||||
// Convert to linear light values
|
||||
$long = 0.4122214708 * $red + 0.5363325363 * $green + 0.0514459929 * $blue;
|
||||
$medium = 0.2119034982 * $red + 0.6806995451 * $green + 0.1073969566 * $blue;
|
||||
$short = 0.0883024619 * $red + 0.2817188376 * $green + 0.6299787005 * $blue;
|
||||
|
||||
// Apply the OKLab transformation
|
||||
$longCubeRoot = pow($long, 1 / 3);
|
||||
$mediumCubeRoot = pow($medium, 1 / 3);
|
||||
$shortCubeRoot = pow($short, 1 / 3);
|
||||
|
||||
$lightness = 0.2104542553 * $longCubeRoot + 0.793617785 * $mediumCubeRoot - 0.0040720468 * $shortCubeRoot;
|
||||
|
||||
$colorOpponentA = 1.9779984951 * $longCubeRoot - 2.428592205 * $mediumCubeRoot + 0.4505937099 * $shortCubeRoot;
|
||||
$colorOpponentB = 0.0259040371 * $longCubeRoot + 0.7827717662 * $mediumCubeRoot - 0.808675766 * $shortCubeRoot;
|
||||
|
||||
$chroma = sqrt($colorOpponentA * $colorOpponentA + $colorOpponentB * $colorOpponentB);
|
||||
$hue = atan2($colorOpponentB, $colorOpponentA); // In radians
|
||||
|
||||
// Convert hue to degrees and ensure it's between 0 and 360
|
||||
$hue = rad2deg($hue);
|
||||
|
||||
if ($hue < 0) {
|
||||
$hue += 360;
|
||||
}
|
||||
|
||||
return 'oklch(' . round($lightness, 3) . ' ' . round($chroma, 3) . ' ' . round($hue, 3) . ')';
|
||||
}
|
||||
|
||||
public static function convertToRgb(string $color): string
|
||||
{
|
||||
if (str_starts_with($color, 'rgb(')) {
|
||||
return $color;
|
||||
}
|
||||
|
||||
if (str_starts_with($color, '#')) {
|
||||
[$red, $green, $blue] = sscanf($color, '#%02x%02x%02x');
|
||||
|
||||
return "rgb({$red}, {$green}, {$blue})";
|
||||
}
|
||||
|
||||
if (! str_starts_with($color, 'oklch(')) {
|
||||
return "rgb({$color})";
|
||||
}
|
||||
|
||||
// Parse the OKLCH values
|
||||
[$lightness, $chroma, $hue] = sscanf($color, 'oklch(%f %f %f)');
|
||||
|
||||
// Convert hue to radians
|
||||
$hue = deg2rad($hue ?? 0);
|
||||
|
||||
// Convert chroma to linear RGB
|
||||
$colorOpponentA = $chroma * cos($hue);
|
||||
$colorOpponentB = $chroma * sin($hue);
|
||||
|
||||
$long = $lightness + 0.3963377774 * $colorOpponentA + 0.2158037573 * $colorOpponentB;
|
||||
$medium = $lightness - 0.1055613458 * $colorOpponentA - 0.0638541728 * $colorOpponentB;
|
||||
$short = $lightness - 0.0894841775 * $colorOpponentA - 1.2914855480 * $colorOpponentB;
|
||||
|
||||
$long = pow($long, 3);
|
||||
$medium = pow($medium, 3);
|
||||
$short = pow($short, 3);
|
||||
|
||||
$red = 4.0767416621 * $long - 3.3077115913 * $medium + 0.2309699292 * $short;
|
||||
$green = -1.2684380046 * $long + 2.6097574011 * $medium - 0.3413193965 * $short;
|
||||
$blue = -0.0041960863 * $long - 0.7034186147 * $medium + 1.7076147010 * $short;
|
||||
|
||||
// Convert linear RGB to sRGB
|
||||
$red = $red <= 0.0031308 ? 12.92 * $red : 1.055 * pow($red, 1 / 2.4) - 0.055;
|
||||
$green = $green <= 0.0031308 ? 12.92 * $green : 1.055 * pow($green, 1 / 2.4) - 0.055;
|
||||
$blue = $blue <= 0.0031308 ? 12.92 * $blue : 1.055 * pow($blue, 1 / 2.4) - 0.055;
|
||||
|
||||
// Convert to range between 0 and 255
|
||||
$red = round($red * 255);
|
||||
$green = round($green * 255);
|
||||
$blue = round($blue * 255);
|
||||
|
||||
// Ensure values are in range between 0 and 255
|
||||
$red = max(0, min(255, $red));
|
||||
$green = max(0, min(255, $green));
|
||||
$blue = max(0, min(255, $blue));
|
||||
|
||||
return "rgb({$red}, {$green}, {$blue})";
|
||||
}
|
||||
|
||||
public static function convertToHex(string $color): string
|
||||
{
|
||||
if (str_starts_with($color, '#')) {
|
||||
return Str::lower($color);
|
||||
}
|
||||
|
||||
$color = static::convertToRgb($color);
|
||||
|
||||
[$red, $green, $blue] = sscanf($color, 'rgb(%d, %d, %d)');
|
||||
|
||||
return sprintf('#%02x%02x%02x', $red, $green, $blue);
|
||||
}
|
||||
|
||||
public static function calculateContrastRatio(string $color1, string $color2): float
|
||||
{
|
||||
$color1 = str_replace(' ', '', static::convertToRgb($color1));
|
||||
$color2 = str_replace(' ', '', static::convertToRgb($color2));
|
||||
|
||||
[$red1, $green1, $blue1] = sscanf($color1, 'rgb(%d,%d,%d)');
|
||||
[$red2, $green2, $blue2] = sscanf($color2, 'rgb(%d,%d,%d)');
|
||||
|
||||
$luminosity1 = 0.2126 * pow($red1 / 255, 2.2) +
|
||||
0.7152 * pow($green1 / 255, 2.2) +
|
||||
0.0722 * pow($blue1 / 255, 2.2);
|
||||
|
||||
$luminosity2 = 0.2126 * pow($red2 / 255, 2.2) +
|
||||
0.7152 * pow($green2 / 255, 2.2) +
|
||||
0.0722 * pow($blue2 / 255, 2.2);
|
||||
|
||||
$lighter = max($luminosity1, $luminosity2);
|
||||
$darker = min($luminosity1, $luminosity2);
|
||||
|
||||
return ($lighter + 0.05) / ($darker + 0.05);
|
||||
}
|
||||
|
||||
public static function isTextContrastRatioAccessible(string $color1, string $color2): bool
|
||||
{
|
||||
return static::calculateContrastRatio($color1, $color2) >= static::WCAG_AA_TEXT;
|
||||
}
|
||||
|
||||
public static function isNonTextContrastRatioAccessible(string $color1, string $color2): bool
|
||||
{
|
||||
return static::calculateContrastRatio($color1, $color2) >= static::WCAG_AA_NON_TEXT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the first shade in `$palette` whose color has at least `$minRatio` contrast against
|
||||
* `$surface`. Iterates from the lightest shade to the darkest by default, or darkest-first if
|
||||
* `$shouldStartFromDarkest` is `true`. Shades outside `[$minShade, $maxShade]` are skipped. Returns `null`
|
||||
* if no shade satisfies the constraints.
|
||||
*
|
||||
* @param array<int, string> $palette
|
||||
*/
|
||||
public static function findShade(
|
||||
array $palette,
|
||||
string $surface,
|
||||
float $minRatio = self::WCAG_AA_TEXT,
|
||||
?int $maxShade = null,
|
||||
?int $minShade = null,
|
||||
bool $shouldStartFromDarkest = false,
|
||||
): ?int {
|
||||
$shouldStartFromDarkest ? krsort($palette) : ksort($palette);
|
||||
|
||||
foreach ($palette as $shade => $value) {
|
||||
if (($maxShade !== null) && ($shade > $maxShade)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (($minShade !== null) && ($shade < $minShade)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (static::calculateContrastRatio($surface, $value) >= $minRatio) {
|
||||
return $shade;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function generateV3Palette(string $color): array
|
||||
{
|
||||
$color = str_replace(' ', '', static::convertToRgb($color));
|
||||
[$baseRed, $baseGreen, $baseBlue] = sscanf($color, 'rgb(%d,%d,%d)');
|
||||
|
||||
$colors = [];
|
||||
|
||||
$intensityMap = [
|
||||
50 => 0.95,
|
||||
100 => 0.9,
|
||||
200 => 0.75,
|
||||
300 => 0.6,
|
||||
400 => 0.3,
|
||||
500 => 1.0,
|
||||
600 => 0.9,
|
||||
700 => 0.75,
|
||||
800 => 0.6,
|
||||
900 => 0.49,
|
||||
950 => 0.3,
|
||||
];
|
||||
|
||||
foreach ($intensityMap as $shade => $intensity) {
|
||||
if ($shade < 500) {
|
||||
$red = ((255 - $baseRed) * $intensity) + $baseRed;
|
||||
$green = ((255 - $baseGreen) * $intensity) + $baseGreen;
|
||||
$blue = ((255 - $baseBlue) * $intensity) + $baseBlue;
|
||||
} else {
|
||||
$red = $baseRed * $intensity;
|
||||
$green = $baseGreen * $intensity;
|
||||
$blue = $baseBlue * $intensity;
|
||||
}
|
||||
|
||||
$colors[$shade] = static::convertToOklch(sprintf('%s, %s, %s', round($red), round($green), round($blue)));
|
||||
}
|
||||
|
||||
return $colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function hex(string $color): array
|
||||
{
|
||||
return static::generatePalette($color);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function rgb(string $color): array
|
||||
{
|
||||
return static::generatePalette($color);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function generatePalette(string $color): array
|
||||
{
|
||||
$color = static::convertToOklch($color);
|
||||
|
||||
[, $chroma, $hue] = sscanf($color, 'oklch(%f %f %f)');
|
||||
|
||||
$isAchromatic = $chroma < 0.03;
|
||||
|
||||
return array_map(
|
||||
fn (array $constants): string => "oklch({$constants[0]} " . ($isAchromatic ? '0' : $constants[1]) . " {$hue})",
|
||||
[
|
||||
50 => [0.97717647058824, 0.01395454545455],
|
||||
100 => [0.95035294117647, 0.03272727272727],
|
||||
200 => [0.90547058823529, 0.06318181818182],
|
||||
300 => [0.84047058823529, 0.10604545454546],
|
||||
400 => [0.75352941176471, 0.15027272727273],
|
||||
500 => [0.68270588235294, 0.17009090909091],
|
||||
600 => [0.59782352941176, 0.16913636363636],
|
||||
700 => [0.51494117647059, 0.14940909090909],
|
||||
800 => [0.44611764705882, 0.12331818181818],
|
||||
900 => [0.39458823529412, 0.09963636363636],
|
||||
950 => [0.27788235294118, 0.07136363636364],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
public static function all(): array
|
||||
{
|
||||
return [
|
||||
'slate' => static::Slate,
|
||||
'gray' => static::Gray,
|
||||
'zinc' => static::Zinc,
|
||||
'neutral' => static::Neutral,
|
||||
'stone' => static::Stone,
|
||||
'mauve' => static::Mauve,
|
||||
'olive' => static::Olive,
|
||||
'mist' => static::Mist,
|
||||
'taupe' => static::Taupe,
|
||||
'red' => static::Red,
|
||||
'orange' => static::Orange,
|
||||
'amber' => static::Amber,
|
||||
'yellow' => static::Yellow,
|
||||
'lime' => static::Lime,
|
||||
'green' => static::Green,
|
||||
'emerald' => static::Emerald,
|
||||
'teal' => static::Teal,
|
||||
'cyan' => static::Cyan,
|
||||
'sky' => static::Sky,
|
||||
'blue' => static::Blue,
|
||||
'indigo' => static::Indigo,
|
||||
'violet' => static::Violet,
|
||||
'purple' => static::Purple,
|
||||
'fuchsia' => static::Fuchsia,
|
||||
'pink' => static::Pink,
|
||||
'rose' => static::Rose,
|
||||
];
|
||||
}
|
||||
|
||||
public static function isLight(string $color): bool
|
||||
{
|
||||
$color = static::convertToOklch($color);
|
||||
|
||||
[$lightness] = sscanf($color, 'oklch(%f %f %f)');
|
||||
|
||||
return $lightness >= 0.65;
|
||||
}
|
||||
}
|
||||
240
vendor/filament/support/src/Colors/ColorManager.php
vendored
Normal file
240
vendor/filament/support/src/Colors/ColorManager.php
vendored
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Colors;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Concerns\EvaluatesClosures;
|
||||
use Filament\Support\View\Components\Contracts\HasColor;
|
||||
use Filament\Support\View\Components\Contracts\HasDefaultGrayColor;
|
||||
use Illuminate\Support\Str;
|
||||
use LogicException;
|
||||
|
||||
class ColorManager
|
||||
{
|
||||
use EvaluatesClosures;
|
||||
|
||||
const DEFAULT_COLORS = [
|
||||
'danger' => Color::Red,
|
||||
'gray' => Color::Zinc,
|
||||
'info' => Color::Blue,
|
||||
'primary' => Color::Amber,
|
||||
'success' => Color::Green,
|
||||
'warning' => Color::Amber,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array<array<string, array<int, string> | string> | Closure>
|
||||
*/
|
||||
protected array $colors = [];
|
||||
|
||||
/**
|
||||
* @var array<string, array<int, string>>
|
||||
*/
|
||||
protected array $cachedColors;
|
||||
|
||||
/**
|
||||
* @var array<class-string<HasColor>, array<string, array<string>>>
|
||||
*/
|
||||
protected array $componentClasses = [];
|
||||
|
||||
/**
|
||||
* @var array<class-string<HasColor>, array<string, array<string>>>
|
||||
*/
|
||||
protected array $componentCustomStyles = [];
|
||||
|
||||
/**
|
||||
* @var array<string,array<int>>
|
||||
*/
|
||||
protected array $overridingShades = [];
|
||||
|
||||
/**
|
||||
* @var array<string,array<int>>
|
||||
*/
|
||||
protected array $addedShades = [];
|
||||
|
||||
/**
|
||||
* @var array<string,array<int>>
|
||||
*/
|
||||
protected array $removedShades = [];
|
||||
|
||||
/**
|
||||
* @param array<string, array<int, string> | string> | Closure $colors
|
||||
*/
|
||||
public function register(array | Closure $colors): static
|
||||
{
|
||||
$this->colors[] = $colors;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
public function getColors(): array
|
||||
{
|
||||
if (isset($this->cachedColors)) {
|
||||
return $this->cachedColors;
|
||||
}
|
||||
|
||||
array_unshift($this->colors, static::DEFAULT_COLORS);
|
||||
|
||||
foreach ($this->colors as $colors) {
|
||||
$colors = $this->evaluate($colors);
|
||||
|
||||
foreach ($colors as $name => $color) {
|
||||
if (is_string($color)) {
|
||||
$color = Color::generatePalette($color);
|
||||
} else {
|
||||
$color = array_map(
|
||||
fn (string | int $color): string | int => is_string($color) ? Color::convertToOklch($color) : $color,
|
||||
$color,
|
||||
);
|
||||
}
|
||||
|
||||
$this->cachedColors[$name] = $color;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->cachedColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?array<int, string>
|
||||
*/
|
||||
public function getColor(string $color): ?array
|
||||
{
|
||||
return $this->getColors()[$color] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<HasColor> | HasColor $component
|
||||
* @return array<string>
|
||||
*/
|
||||
public function getComponentClasses(string | HasColor $component, ?string $color): array
|
||||
{
|
||||
if (blank($color)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$componentKey = is_string($component) ? $component : serialize($component);
|
||||
|
||||
if (isset($this->componentClasses[$componentKey][$color])) {
|
||||
return $this->componentClasses[$componentKey][$color];
|
||||
}
|
||||
|
||||
$component = is_string($component) ? app($component) : $component;
|
||||
|
||||
if (($color === 'gray') && ($component instanceof HasDefaultGrayColor)) {
|
||||
return $this->componentClasses[$componentKey][$color] = [];
|
||||
}
|
||||
|
||||
$classes = ['fi-color', 'fi-color-' . (string) preg_replace('/[^a-zA-Z0-9_-]/', '', $color)];
|
||||
|
||||
$resolvedColor = $this->getColor($color);
|
||||
|
||||
if (! $resolvedColor) {
|
||||
return $this->componentClasses[$componentKey][$color] = $classes;
|
||||
}
|
||||
|
||||
$map = $component->getColorMap($resolvedColor);
|
||||
|
||||
return $this->componentClasses[$componentKey][$color] = [
|
||||
...$classes,
|
||||
...array_map(
|
||||
fn (string $shade, string $key): string => match ($key) {
|
||||
'bg' => "fi-bg-color-{$shade}",
|
||||
'dark:bg' => "dark:fi-bg-color-{$shade}",
|
||||
'dark:hover:bg' => "dark:hover:fi-bg-color-{$shade}",
|
||||
'dark:hover:text' => "dark:hover:fi-text-color-{$shade}",
|
||||
'dark:text' => "dark:fi-text-color-{$shade}",
|
||||
'hover:bg' => "hover:fi-bg-color-{$shade}",
|
||||
'hover:text' => "hover:fi-text-color-{$shade}",
|
||||
'text' => "fi-text-color-{$shade}",
|
||||
default => throw new LogicException("Invalid color mapping key [{$key}]."),
|
||||
},
|
||||
array_values($map),
|
||||
array_keys($map),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<HasColor> | HasColor $component
|
||||
* @param array<string> $color
|
||||
* @return array<string>
|
||||
*/
|
||||
public function getComponentCustomStyles(string | HasColor $component, array $color): array
|
||||
{
|
||||
$componentKey = is_string($component) ? $component : serialize($component);
|
||||
$colorKey = serialize($color);
|
||||
|
||||
if (isset($this->componentCustomStyles[$componentKey][$colorKey])) {
|
||||
return $this->componentCustomStyles[$componentKey][$colorKey];
|
||||
}
|
||||
|
||||
$component = is_string($component) ? app($component) : $component;
|
||||
|
||||
$map = $component->getColorMap($color);
|
||||
|
||||
return $this->componentCustomStyles[$componentKey][$colorKey] = [
|
||||
...array_map(
|
||||
fn (string $color, string $shade): string => '--color-' . preg_replace('/[^a-zA-Z0-9_-]/', '', $shade) . ': ' . (Str::sanitizeCssColor($color) ?? ''),
|
||||
array_values($color),
|
||||
array_keys($color),
|
||||
),
|
||||
...array_map(
|
||||
fn (string $shade, string $key): string => '--' . str_replace(':', '-', $key) . ': ' . ($shade ? 'var(--color-' . preg_replace('/[^a-zA-Z0-9_-]/', '', $shade) . ')' : 'oklch(1 0 0)'),
|
||||
array_values($map),
|
||||
array_keys($map),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int> $shades
|
||||
*/
|
||||
public function overrideShades(string $alias, array $shades): void
|
||||
{
|
||||
$this->overridingShades[$alias] = $shades;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int> | null
|
||||
*/
|
||||
public function getOverridingShades(string $alias): ?array
|
||||
{
|
||||
return $this->overridingShades[$alias] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int> $shades
|
||||
*/
|
||||
public function addShades(string $alias, array $shades): void
|
||||
{
|
||||
$this->addedShades[$alias] = $shades;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int> | null
|
||||
*/
|
||||
public function getAddedShades(string $alias): ?array
|
||||
{
|
||||
return $this->addedShades[$alias] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int> $shades
|
||||
*/
|
||||
public function removeShades(string $alias, array $shades): void
|
||||
{
|
||||
$this->removedShades[$alias] = $shades;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int> | null
|
||||
*/
|
||||
public function getRemovedShades(string $alias): ?array
|
||||
{
|
||||
return $this->removedShades[$alias] ?? null;
|
||||
}
|
||||
}
|
||||
21
vendor/filament/support/src/Commands/AboutCommand.php
vendored
Normal file
21
vendor/filament/support/src/Commands/AboutCommand.php
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
|
||||
#[AsCommand(name: 'filament:about')]
|
||||
class AboutCommand extends Command
|
||||
{
|
||||
protected $description = 'Display basic information about Filament packages that are installed';
|
||||
|
||||
protected $name = 'filament:about';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->call('about', [
|
||||
'--only' => 'filament',
|
||||
]);
|
||||
}
|
||||
}
|
||||
91
vendor/filament/support/src/Commands/AssetsCommand.php
vendored
Normal file
91
vendor/filament/support/src/Commands/AssetsCommand.php
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands;
|
||||
|
||||
use Filament\Support\Commands\Concerns\CanManipulateFiles;
|
||||
use Filament\Support\Facades\FilamentAsset;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
|
||||
#[AsCommand(name: 'filament:assets')]
|
||||
class AssetsCommand extends Command
|
||||
{
|
||||
use CanManipulateFiles;
|
||||
|
||||
protected $description = 'Set up Filament assets';
|
||||
|
||||
protected $name = 'filament:assets';
|
||||
|
||||
/** @var array<string> */
|
||||
protected array $publishedAssets = [];
|
||||
|
||||
public function handle(Filesystem $filesystem): int
|
||||
{
|
||||
foreach (FilamentAsset::getAlpineComponents() as $asset) {
|
||||
if ($asset->isRemote()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->copyAsset($asset->getPath(), $asset->getPublicPath());
|
||||
}
|
||||
|
||||
foreach (FilamentAsset::getFonts() as $asset) {
|
||||
$assetPublicPath = $asset->getPublicPath();
|
||||
|
||||
foreach ($filesystem->allFiles($asset->getPath()) as $file) {
|
||||
if ($file->getExtension() === 'js') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->copyAsset($file->getPathname(), $assetPublicPath . DIRECTORY_SEPARATOR . $file->getFilename());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (FilamentAsset::getScripts() as $asset) {
|
||||
if ($asset->isRemote()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->copyAsset($asset->getPath(), $asset->getPublicPath());
|
||||
}
|
||||
|
||||
foreach (FilamentAsset::getStyles() as $asset) {
|
||||
if ($asset->isRemote()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->copyAsset($asset->getPath(), $asset->getPublicPath());
|
||||
}
|
||||
|
||||
foreach (FilamentAsset::getThemes() as $asset) {
|
||||
if ($asset->isRemote()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->copyAsset($asset->getPath(), $asset->getPublicPath());
|
||||
}
|
||||
|
||||
$this->components->bulletList($this->publishedAssets);
|
||||
|
||||
$this->components->info('Successfully published assets!');
|
||||
|
||||
return static::SUCCESS;
|
||||
}
|
||||
|
||||
protected function copyAsset(string $from, string $to): void
|
||||
{
|
||||
$filesystem = app(Filesystem::class);
|
||||
|
||||
[$from, $to] = str_replace('/', DIRECTORY_SEPARATOR, [$from, $to]);
|
||||
|
||||
$filesystem->ensureDirectoryExists(
|
||||
(string) str($to)
|
||||
->beforeLast(DIRECTORY_SEPARATOR),
|
||||
);
|
||||
|
||||
$filesystem->replace($to, $filesystem->get($from));
|
||||
|
||||
$this->publishedAssets[] = $to;
|
||||
}
|
||||
}
|
||||
179
vendor/filament/support/src/Commands/CheckTranslationsCommand.php
vendored
Normal file
179
vendor/filament/support/src/Commands/CheckTranslationsCommand.php
vendored
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands;
|
||||
|
||||
use Composer\InstalledVersions;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Console\PromptsForMissingInput;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Exception\InvalidOptionException;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Finder\SplFileInfo;
|
||||
|
||||
use function Laravel\Prompts\info;
|
||||
use function Laravel\Prompts\table;
|
||||
use function Laravel\Prompts\warning;
|
||||
|
||||
#[AsCommand(name: 'filament:check-translations')]
|
||||
class CheckTranslationsCommand extends Command implements PromptsForMissingInput
|
||||
{
|
||||
protected $description = 'Check for missing and removed translations';
|
||||
|
||||
protected $name = 'filament:check-translations';
|
||||
|
||||
/**
|
||||
* @return array<InputArgument>
|
||||
*/
|
||||
protected function getArguments(): array
|
||||
{
|
||||
return [
|
||||
new InputArgument(
|
||||
name: 'locales',
|
||||
mode: InputArgument::IS_ARRAY,
|
||||
description: 'The locales to check',
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<InputOption>
|
||||
*/
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
new InputOption(
|
||||
name: 'source',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_REQUIRED,
|
||||
description: 'The directory containing the translations to check - either \'vendor\' or \'app\'',
|
||||
default: 'vendor',
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$this->scan('filament');
|
||||
$this->scan('actions');
|
||||
$this->scan('forms');
|
||||
$this->scan('infolists');
|
||||
$this->scan('notifications');
|
||||
$this->scan('query-builder');
|
||||
$this->scan('schemas');
|
||||
$this->scan('spark-billing-provider');
|
||||
$this->scan('spatie-laravel-google-fonts-plugin');
|
||||
$this->scan('spatie-laravel-media-library-plugin');
|
||||
$this->scan('spatie-laravel-settings-plugin');
|
||||
$this->scan('spatie-laravel-tags-plugin');
|
||||
$this->scan('support');
|
||||
$this->scan('tables');
|
||||
$this->scan('widgets');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
protected function scan(string $package): void
|
||||
{
|
||||
$localeRootDirectory = match ($source = $this->option('source')) {
|
||||
'app' => lang_path("vendor/{$package}"),
|
||||
'vendor' => InstalledVersions::isInstalled("filament/{$package}")
|
||||
? InstalledVersions::getInstallPath("filament/{$package}") . '/resources/lang'
|
||||
: null,
|
||||
default => throw new InvalidOptionException("{$source} is not a valid translation source. Must be `vendor` or `app`.")
|
||||
};
|
||||
|
||||
$filesystem = app(Filesystem::class);
|
||||
|
||||
if (($localeRootDirectory === null) || (! $filesystem->exists($localeRootDirectory))) {
|
||||
return;
|
||||
}
|
||||
|
||||
collect($filesystem->directories($localeRootDirectory))
|
||||
->mapWithKeys(static fn (string $directory): array => [$directory => (string) str($directory)->afterLast(DIRECTORY_SEPARATOR)])
|
||||
->when(
|
||||
$locales = $this->argument('locales'),
|
||||
fn (Collection $availableLocales): Collection => $availableLocales->filter(fn (string $locale): bool => in_array($locale, $locales))
|
||||
)
|
||||
->each(function (string $locale, string $localeDir) use ($filesystem, $localeRootDirectory, $package): void {
|
||||
$files = $filesystem->allFiles($localeDir);
|
||||
$baseFiles = $filesystem->allFiles(implode(DIRECTORY_SEPARATOR, [$localeRootDirectory, 'en']));
|
||||
|
||||
$localeFiles = collect($files)->map(fn ($file) => (string) str($file->getPathname())->after(DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR));
|
||||
$englishFiles = collect($baseFiles)->map(fn ($file) => (string) str($file->getPathname())->after(DIRECTORY_SEPARATOR . 'en' . DIRECTORY_SEPARATOR));
|
||||
$missingFiles = $englishFiles->diff($localeFiles);
|
||||
$removedFiles = $localeFiles->diff($englishFiles);
|
||||
$path = implode(DIRECTORY_SEPARATOR, [$localeRootDirectory, $locale]);
|
||||
|
||||
if ($missingFiles->count() > 0 && $removedFiles->count() > 0) {
|
||||
warning("[!] Package filament/{$package} has {$missingFiles->count()} missing translation " . Str::plural('file', $missingFiles->count()) . " and {$removedFiles->count()} removed translation " . Str::plural('file', $missingFiles->count()) . ' for ' . locale_get_display_name($locale, 'en') . ".\n");
|
||||
} elseif ($missingFiles->count() > 0) {
|
||||
warning("[!] Package filament/{$package} has {$missingFiles->count()} missing translation " . Str::plural('file', $missingFiles->count()) . ' for ' . locale_get_display_name($locale, 'en') . ".\n");
|
||||
} elseif ($removedFiles->count() > 0) {
|
||||
warning("[!] Package filament/{$package} has {$removedFiles->count()} removed translation " . Str::plural('file', $removedFiles->count()) . ' for ' . locale_get_display_name($locale, 'en') . ".\n");
|
||||
}
|
||||
|
||||
if ($missingFiles->count() > 0 || $removedFiles->count() > 0) {
|
||||
table(
|
||||
[$path, ''],
|
||||
array_merge(
|
||||
array_map(fn (string $file): array => [$file, 'Missing'], $missingFiles->toArray()),
|
||||
array_map(fn (string $file): array => [$file, 'Removed'], $removedFiles->toArray()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
collect($files)
|
||||
->reject(function ($file) use ($localeRootDirectory) {
|
||||
return ! file_exists(implode(DIRECTORY_SEPARATOR, [$localeRootDirectory, 'en', $file->getRelativePathname()]));
|
||||
})
|
||||
->mapWithKeys(function (SplFileInfo $file) use ($localeDir, $localeRootDirectory) {
|
||||
$expectedKeys = require implode(DIRECTORY_SEPARATOR, [$localeRootDirectory, 'en', $file->getRelativePathname()]);
|
||||
$actualKeys = require $file->getPathname();
|
||||
|
||||
return [
|
||||
(string) str($file->getPathname())->after("{$localeDir}/") => [
|
||||
'missing' => array_keys(array_diff_key(
|
||||
Arr::dot($expectedKeys),
|
||||
Arr::dot($actualKeys)
|
||||
)),
|
||||
'removed' => array_keys(array_diff_key(
|
||||
Arr::dot($actualKeys),
|
||||
Arr::dot($expectedKeys)
|
||||
)),
|
||||
],
|
||||
];
|
||||
})
|
||||
->tap(function (Collection $files) use ($locale, $package): void {
|
||||
$missingKeysCount = $files->sum(fn ($file): int => count($file['missing']));
|
||||
$removedKeysCount = $files->sum(fn ($file): int => count($file['removed']));
|
||||
|
||||
$locale = locale_get_display_name($locale, 'en');
|
||||
|
||||
if ((! $missingKeysCount) && (! $removedKeysCount)) {
|
||||
info("[✓] Package filament/{$package} has no missing or removed translation keys for {$locale}!\n");
|
||||
} elseif ($missingKeysCount && $removedKeysCount) {
|
||||
warning("[!] Package filament/{$package} has {$missingKeysCount} missing translation " . Str::plural('key', $missingKeysCount) . " and {$removedKeysCount} removed translation " . Str::plural('key', $removedKeysCount) . " for {$locale}.\n");
|
||||
} elseif ($missingKeysCount) {
|
||||
warning("[!] Package filament/{$package} has {$missingKeysCount} missing translation " . Str::plural('key', $missingKeysCount) . " for {$locale}.\n");
|
||||
} else {
|
||||
warning("[!] Package filament/{$package} has {$removedKeysCount} removed translation " . Str::plural('key', $removedKeysCount) . " for {$locale}.\n");
|
||||
}
|
||||
})
|
||||
->filter(static fn ($keys): bool => count($keys['missing']) || count($keys['removed']))
|
||||
->each(function ($keys, string $file): void {
|
||||
table(
|
||||
[$file, ''],
|
||||
[
|
||||
...array_map(fn (string $key): array => [$key, 'Missing'], $keys['missing']),
|
||||
...array_map(fn (string $key): array => [$key, 'Removed'], $keys['removed']),
|
||||
],
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
63
vendor/filament/support/src/Commands/Concerns/CanAskForComponentLocation.php
vendored
Normal file
63
vendor/filament/support/src/Commands/Concerns/CanAskForComponentLocation.php
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Support\Facades\FilamentCli;
|
||||
|
||||
use function Laravel\Prompts\select;
|
||||
|
||||
trait CanAskForComponentLocation
|
||||
{
|
||||
/**
|
||||
* @return array{
|
||||
* 0: string,
|
||||
* 1: string,
|
||||
* 2: ?string,
|
||||
* }
|
||||
*/
|
||||
protected function askForComponentLocation(string $path, string $question = 'Where would you like to create the component?'): array
|
||||
{
|
||||
$pathNamespace = (string) str($path)->replace('/', '\\');
|
||||
|
||||
$locations = FilamentCli::getComponentLocations();
|
||||
|
||||
if (blank($locations)) {
|
||||
return [
|
||||
app()->getNamespace() . "Filament\\{$pathNamespace}",
|
||||
app_path('Filament' . DIRECTORY_SEPARATOR . $path),
|
||||
'',
|
||||
];
|
||||
}
|
||||
|
||||
$options = [
|
||||
'' => app()->getNamespace() . "Filament\\{$pathNamespace}",
|
||||
...array_map(
|
||||
fn (string $namespace): string => "{$namespace}\\{$pathNamespace}",
|
||||
array_combine(
|
||||
array_keys($locations),
|
||||
array_keys($locations),
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
$namespace = select(
|
||||
label: $question,
|
||||
options: $options,
|
||||
default: $this->input->isInteractive() ? null : '',
|
||||
);
|
||||
|
||||
if (blank($namespace)) {
|
||||
return [
|
||||
app()->getNamespace() . "Filament\\{$pathNamespace}",
|
||||
app_path('Filament' . DIRECTORY_SEPARATOR . $path),
|
||||
'',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
"{$namespace}\\{$pathNamespace}",
|
||||
$locations[$namespace]['path'] . '/' . $path,
|
||||
$locations[$namespace]['viewNamespace'] ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
58
vendor/filament/support/src/Commands/Concerns/CanAskForLivewireComponentLocation.php
vendored
Normal file
58
vendor/filament/support/src/Commands/Concerns/CanAskForLivewireComponentLocation.php
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Support\Facades\FilamentCli;
|
||||
|
||||
use function Laravel\Prompts\select;
|
||||
|
||||
trait CanAskForLivewireComponentLocation
|
||||
{
|
||||
/**
|
||||
* @return array{
|
||||
* 0: string,
|
||||
* 1: string,
|
||||
* 2: ?string,
|
||||
* }
|
||||
*/
|
||||
protected function askForLivewireComponentLocation(string $question = 'Where would you like to create the Livewire component?'): array
|
||||
{
|
||||
$locations = FilamentCli::getLivewireComponentLocations();
|
||||
|
||||
if (blank($locations)) {
|
||||
return [
|
||||
app()->getNamespace() . 'Livewire',
|
||||
app_path('Livewire'),
|
||||
'',
|
||||
];
|
||||
}
|
||||
|
||||
$options = [
|
||||
'' => app()->getNamespace() . 'Livewire',
|
||||
...array_combine(
|
||||
array_keys($locations),
|
||||
array_keys($locations),
|
||||
),
|
||||
];
|
||||
|
||||
$namespace = select(
|
||||
label: $question,
|
||||
options: $options,
|
||||
default: $this->input->isInteractive() ? null : '',
|
||||
);
|
||||
|
||||
if (blank($namespace)) {
|
||||
return [
|
||||
app()->getNamespace() . 'Livewire',
|
||||
app_path('Livewire'),
|
||||
'',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
$namespace,
|
||||
$locations[$namespace]['path'],
|
||||
$locations[$namespace]['viewNamespace'] ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
42
vendor/filament/support/src/Commands/Concerns/CanAskForRelatedModel.php
vendored
Normal file
42
vendor/filament/support/src/Commands/Concerns/CanAskForRelatedModel.php
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use function Filament\Support\discover_app_classes;
|
||||
use function Laravel\Prompts\info;
|
||||
use function Laravel\Prompts\suggest;
|
||||
|
||||
trait CanAskForRelatedModel
|
||||
{
|
||||
/**
|
||||
* @return ?class-string
|
||||
*/
|
||||
protected function askForRelatedModel(string $relationship): ?string
|
||||
{
|
||||
$modelFqns = discover_app_classes(parentClass: Model::class);
|
||||
|
||||
$modelFqns = array_combine(
|
||||
$modelFqns,
|
||||
$modelFqns,
|
||||
);
|
||||
|
||||
info("Filament couldn't automatically find the related model for the [{$relationship}] relationship.");
|
||||
|
||||
return suggest(
|
||||
label: 'What is the related model?',
|
||||
options: function (?string $search) use ($modelFqns): array {
|
||||
if (blank($search)) {
|
||||
return $modelFqns;
|
||||
}
|
||||
|
||||
$search = str($search)->trim()->replace(['\\', '/'], '');
|
||||
|
||||
return array_filter($modelFqns, fn (string $modelFqn): bool => str($modelFqn)->replace(['\\', '/'], '')->contains($search, ignoreCase: true));
|
||||
},
|
||||
placeholder: app()->getNamespace() . 'Models\\User',
|
||||
hint: 'Please provide the fully-qualified class name.',
|
||||
);
|
||||
}
|
||||
}
|
||||
42
vendor/filament/support/src/Commands/Concerns/CanAskForRelatedResource.php
vendored
Normal file
42
vendor/filament/support/src/Commands/Concerns/CanAskForRelatedResource.php
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use function Laravel\Prompts\confirm;
|
||||
use function Laravel\Prompts\info;
|
||||
|
||||
trait CanAskForRelatedResource
|
||||
{
|
||||
/**
|
||||
* @return ?class-string
|
||||
*/
|
||||
protected function askForRelatedResource(): ?string
|
||||
{
|
||||
info('Linking to an existing resource will open the resource\'s pages instead of modals when links are clicked. It will also inherit the resource\'s configuration.');
|
||||
|
||||
if (! confirm(
|
||||
label: 'Do you want to link this to an existing resource?',
|
||||
default: false,
|
||||
)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$clusterFqn = $this->askForCluster(
|
||||
initialQuestion: 'Is the resource in a cluster?',
|
||||
question: 'Which cluster is the resource in?',
|
||||
);
|
||||
|
||||
if (filled($clusterFqn)) {
|
||||
[$resourcesNamespace] = $this->getClusterResourcesLocation($clusterFqn);
|
||||
} else {
|
||||
[$resourcesNamespace] = $this->getResourcesLocation(
|
||||
question: 'Which namespace would you like to search for resources in?',
|
||||
);
|
||||
}
|
||||
|
||||
return $this->askForResource(
|
||||
question: 'Which resource do you want to use?',
|
||||
resourcesNamespace: $resourcesNamespace,
|
||||
);
|
||||
}
|
||||
}
|
||||
125
vendor/filament/support/src/Commands/Concerns/CanAskForResource.php
vendored
Normal file
125
vendor/filament/support/src/Commands/Concerns/CanAskForResource.php
vendored
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Resources\Resource;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
use function Laravel\Prompts\search;
|
||||
use function Laravel\Prompts\text;
|
||||
|
||||
trait CanAskForResource
|
||||
{
|
||||
/**
|
||||
* @return class-string
|
||||
*/
|
||||
protected function askForResource(string $question, ?string $initialResource = null, ?string $resourcesNamespace = null): string
|
||||
{
|
||||
$resourcesNamespace ??= $this->resourcesNamespace;
|
||||
|
||||
if (is_string($initialResource)) {
|
||||
$initialResource = (string) str($initialResource)
|
||||
->trim('/')
|
||||
->trim('\\')
|
||||
->trim(' ')
|
||||
->replace('/', '\\');
|
||||
|
||||
if (class_exists($initialResource)) {
|
||||
return $initialResource;
|
||||
}
|
||||
|
||||
$resourceNamespace = (string) str($initialResource)
|
||||
->beforeLast('Resource')
|
||||
->pluralStudly()
|
||||
->replace('/', '\\')
|
||||
->prepend("{$resourcesNamespace}\\");
|
||||
|
||||
$resourceBasename = (string) str($initialResource)
|
||||
->classBasename()
|
||||
->beforeLast('Resource')
|
||||
->singular()
|
||||
->append('Resource');
|
||||
|
||||
if (class_exists("{$resourceNamespace}\\{$resourceBasename}")) {
|
||||
return "{$resourceNamespace}\\{$resourceBasename}";
|
||||
}
|
||||
|
||||
$resourceNamespace = (string) str($resourceNamespace)
|
||||
->beforeLast('\\');
|
||||
|
||||
if (class_exists("{$resourceNamespace}\\{$resourceBasename}")) {
|
||||
return "{$resourceNamespace}\\{$resourceBasename}";
|
||||
}
|
||||
}
|
||||
|
||||
$resourceFqns = array_filter(
|
||||
array_values($this->panel->getResources()),
|
||||
fn (string $resource): bool => str($resource)->startsWith("{$resourcesNamespace}\\"),
|
||||
);
|
||||
|
||||
if (! $resourceFqns) {
|
||||
return (string) str(text(
|
||||
label: "No resources were found within [{$resourcesNamespace}]. {$question}",
|
||||
placeholder: app()->getNamespace() . 'Filament\\Resources\\Posts\\PostResource',
|
||||
required: true,
|
||||
validate: function (string $value): ?string {
|
||||
$value = (string) str($value)
|
||||
->trim('/')
|
||||
->trim('\\')
|
||||
->trim(' ')
|
||||
->replace('/', '\\');
|
||||
|
||||
return match (true) {
|
||||
! class_exists($value) => 'The resource class doesn\'t exist, please use the fully-qualified class name.',
|
||||
! is_subclass_of($value, Resource::class) => 'The resource class or one of its parents must extend [' . Resource::class . '].',
|
||||
default => null,
|
||||
};
|
||||
},
|
||||
hint: 'Please provide the fully-qualified class name of the resource.',
|
||||
))
|
||||
->trim('/')
|
||||
->trim('\\')
|
||||
->trim(' ')
|
||||
->replace('/', '\\');
|
||||
}
|
||||
|
||||
return search(
|
||||
label: $question,
|
||||
options: function (?string $search) use ($resourceFqns, $resourcesNamespace): array {
|
||||
$search = str($search)->trim()->replace(['\\', '/'], '');
|
||||
|
||||
return collect($resourceFqns)
|
||||
->when(
|
||||
filled($search = (string) str($search)->trim()->replace(['\\', '/'], '')),
|
||||
fn (Collection $resourceFqns) => $resourceFqns->filter(fn (string $fqn): bool => str($fqn)->replace(['\\', '/'], '')->contains($search, ignoreCase: true)),
|
||||
)
|
||||
->mapWithKeys(function (string $fqn) use ($resourcesNamespace): array {
|
||||
$label = (string) str($fqn)->after("{$resourcesNamespace}\\");
|
||||
|
||||
if (str($label)->contains('\\')) {
|
||||
$finalSegment = (string) str($label)->afterLast('\\');
|
||||
|
||||
$penultimateSegment = (string) str($label)->beforeLast('\\');
|
||||
|
||||
if (str($penultimateSegment)->contains('\\')) {
|
||||
$penultimateSegment = (string) str($penultimateSegment)->afterLast('\\');
|
||||
}
|
||||
|
||||
if (str($finalSegment)->endsWith('Resource') && ($finalSegment !== 'Resource')) {
|
||||
$expectedPenultimateSegment = (string) str($finalSegment)
|
||||
->beforeLast('Resource')
|
||||
->pluralStudly();
|
||||
}
|
||||
|
||||
if ($penultimateSegment === ($expectedPenultimateSegment ?? null)) {
|
||||
$label = (string) str($label)->beforeLast('\\');
|
||||
}
|
||||
}
|
||||
|
||||
return [$fqn => $label];
|
||||
})
|
||||
->all();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
43
vendor/filament/support/src/Commands/Concerns/CanAskForSchema.php
vendored
Normal file
43
vendor/filament/support/src/Commands/Concerns/CanAskForSchema.php
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use function Filament\Support\discover_app_classes;
|
||||
use function Laravel\Prompts\confirm;
|
||||
use function Laravel\Prompts\suggest;
|
||||
|
||||
trait CanAskForSchema
|
||||
{
|
||||
/**
|
||||
* @return ?class-string
|
||||
*/
|
||||
protected function askForSchema(string $intialQuestion, string $question, string $questionPlaceholder): ?string
|
||||
{
|
||||
if (! confirm(
|
||||
label: $intialQuestion,
|
||||
default: false,
|
||||
)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$schemaFqns = array_filter(
|
||||
discover_app_classes(),
|
||||
fn (string $schemaFqn): bool => method_exists($schemaFqn, 'configure'),
|
||||
);
|
||||
|
||||
return suggest(
|
||||
label: $question,
|
||||
options: function (?string $search) use ($schemaFqns): array {
|
||||
if (blank($search)) {
|
||||
return $schemaFqns;
|
||||
}
|
||||
|
||||
$search = str($search)->trim()->replace(['\\', '/'], '');
|
||||
|
||||
return array_filter($schemaFqns, fn (string $schemaFqn): bool => str($schemaFqn)->replace(['\\', '/'], '')->contains($search, ignoreCase: true));
|
||||
},
|
||||
placeholder: $questionPlaceholder,
|
||||
hint: 'Please provide the fully-qualified class name.',
|
||||
);
|
||||
}
|
||||
}
|
||||
111
vendor/filament/support/src/Commands/Concerns/CanAskForViewLocation.php
vendored
Normal file
111
vendor/filament/support/src/Commands/Concerns/CanAskForViewLocation.php
vendored
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\View\FileViewFinder;
|
||||
|
||||
use function Filament\Support\get_composer_vendor_directory;
|
||||
use function Filament\Support\is_path_within_directory;
|
||||
use function Filament\Support\is_path_within_vendor_directory;
|
||||
use function Laravel\Prompts\select;
|
||||
|
||||
trait CanAskForViewLocation
|
||||
{
|
||||
/**
|
||||
* @return array{
|
||||
* 0: string,
|
||||
* 1: string,
|
||||
* }
|
||||
*/
|
||||
protected function askForViewLocation(string $view, string $question = 'Where would you like to create the Blade view?', ?string $defaultNamespace = null): array
|
||||
{
|
||||
$viewFactory = app(Factory::class);
|
||||
|
||||
$paths = [];
|
||||
|
||||
/** @var array<string> $viewPaths */
|
||||
$viewPaths = config('view.paths') ?? [];
|
||||
$defaultViewPath = Arr::first($viewPaths);
|
||||
$publishedVendorViewPath = resource_path('views/vendor');
|
||||
|
||||
if (
|
||||
($defaultViewPath !== null) &&
|
||||
is_path_within_directory($defaultViewPath, base_path()) &&
|
||||
(! is_path_within_directory($defaultViewPath, get_composer_vendor_directory())) &&
|
||||
(
|
||||
(! is_path_within_vendor_directory($defaultViewPath, base_path())) ||
|
||||
is_path_within_directory($defaultViewPath, $publishedVendorViewPath)
|
||||
)
|
||||
) {
|
||||
$paths[''] = $defaultViewPath;
|
||||
}
|
||||
|
||||
/** @var FileViewFinder $viewFinder */
|
||||
$viewFinder = $viewFactory->getFinder();
|
||||
|
||||
foreach ($viewFinder->getHints() as $namespace => $hintPaths) {
|
||||
foreach ($hintPaths as $path) {
|
||||
if (! is_path_within_directory($path, base_path())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_path_within_directory($path, get_composer_vendor_directory())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_path_within_vendor_directory($path, base_path()) && (! is_path_within_directory($path, $publishedVendorViewPath))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($path === resource_path('views/vendor/livewire')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (filled($paths[''] ?? null) && str($path)->startsWith($paths[''])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$paths[$namespace] = $path;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$options = array_map(
|
||||
fn (string $path): string => (string) str($path)->after(base_path()),
|
||||
$paths,
|
||||
);
|
||||
|
||||
$namespace = ($defaultNamespace !== null) && array_key_exists($defaultNamespace, $paths)
|
||||
? $defaultNamespace
|
||||
: (count($options) > 1
|
||||
? select(
|
||||
label: $question,
|
||||
options: $options,
|
||||
default: $this->input->isInteractive() ? null : array_key_first($options),
|
||||
)
|
||||
: array_key_first($options));
|
||||
|
||||
if (blank($namespace)) {
|
||||
return [
|
||||
$view,
|
||||
resource_path(
|
||||
(string) str($view)
|
||||
->replace('.', '/')
|
||||
->prepend('views/')
|
||||
->append('.blade.php'),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
"{$namespace}::{$view}",
|
||||
(string) str($view)
|
||||
->replace('.', '/')
|
||||
->prepend("{$paths[$namespace]}/")
|
||||
->append('.blade.php'),
|
||||
];
|
||||
}
|
||||
}
|
||||
13
vendor/filament/support/src/Commands/Concerns/CanCachePanelComponents.php
vendored
Normal file
13
vendor/filament/support/src/Commands/Concerns/CanCachePanelComponents.php
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Commands\CacheComponentsCommand;
|
||||
|
||||
trait CanCachePanelComponents
|
||||
{
|
||||
protected function canCachePanelComponents(): bool
|
||||
{
|
||||
return class_exists(CacheComponentsCommand::class);
|
||||
}
|
||||
}
|
||||
89
vendor/filament/support/src/Commands/Concerns/CanGeneratePanels.php
vendored
Normal file
89
vendor/filament/support/src/Commands/Concerns/CanGeneratePanels.php
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Commands\FileGenerators\PanelProviderClassGenerator;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Commands\Exceptions\FailureCommandOutput;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use function Laravel\Prompts\text;
|
||||
|
||||
trait CanGeneratePanels
|
||||
{
|
||||
use CanManipulateFiles;
|
||||
|
||||
public function generatePanel(?string $id = null, string $defaultId = '', string $placeholderId = '', bool $isForced = false): void
|
||||
{
|
||||
$id = Str::lcfirst($id ?? text(
|
||||
label: 'What is the panel\'s ID?',
|
||||
placeholder: $placeholderId,
|
||||
default: $defaultId,
|
||||
required: true,
|
||||
validate: fn (string $value) => match (true) {
|
||||
preg_match('/^[a-zA-Z].*/', $value) !== false => null,
|
||||
default => 'The ID must start with a letter, and not a number or special character.',
|
||||
},
|
||||
hint: 'It must be unique to any others you have, and is used to reference the panel in your code.',
|
||||
));
|
||||
|
||||
$basename = (string) str($id)
|
||||
->studly()
|
||||
->append('PanelProvider');
|
||||
|
||||
$path = app_path(
|
||||
(string) str($basename)
|
||||
->prepend('Providers/Filament/')
|
||||
->replace('\\', '/')
|
||||
->append('.php'),
|
||||
);
|
||||
|
||||
if (! $isForced && $this->checkForCollision([$path])) {
|
||||
throw new FailureCommandOutput;
|
||||
}
|
||||
|
||||
$fqn = app()->getNamespace() . "Providers\\Filament\\{$basename}";
|
||||
|
||||
if (empty(Filament::getPanels())) {
|
||||
$this->writeFile($path, app(PanelProviderClassGenerator::class, [
|
||||
'fqn' => $fqn,
|
||||
'id' => $id,
|
||||
'isDefault' => true,
|
||||
]));
|
||||
} else {
|
||||
$this->writeFile($path, app(PanelProviderClassGenerator::class, [
|
||||
'fqn' => $fqn,
|
||||
'id' => $id,
|
||||
]));
|
||||
}
|
||||
|
||||
$hasBootstrapProvidersFile = file_exists($bootstrapProvidersPath = App::getBootstrapProvidersPath());
|
||||
|
||||
if ($hasBootstrapProvidersFile) {
|
||||
ServiceProvider::addProviderToBootstrapFile(
|
||||
$fqn,
|
||||
$bootstrapProvidersPath,
|
||||
);
|
||||
} else {
|
||||
$appConfig = file_get_contents(config_path('app.php'));
|
||||
|
||||
if (! Str::contains($appConfig, "{$fqn}::class")) {
|
||||
file_put_contents(config_path('app.php'), str_replace(
|
||||
app()->getNamespace() . 'Providers\\RouteServiceProvider::class,',
|
||||
"{$fqn}::class," . PHP_EOL . ' ' . app()->getNamespace() . 'Providers\\RouteServiceProvider::class,',
|
||||
$appConfig,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$this->components->info("Filament panel [{$path}] created successfully.");
|
||||
|
||||
if ($hasBootstrapProvidersFile) {
|
||||
$this->components->warn("We've attempted to register the {$basename} in your [bootstrap/providers.php] file. If you get an error while trying to access your panel then this process has probably failed. You can manually register the service provider by adding it to the array.");
|
||||
} else {
|
||||
$this->components->warn("We've attempted to register the {$basename} in your [config/app.php] file as a service provider. If you get an error while trying to access your panel then this process has probably failed. You can manually register the service provider by adding it to the [providers] array.");
|
||||
}
|
||||
}
|
||||
}
|
||||
17
vendor/filament/support/src/Commands/Concerns/CanIndentStrings.php
vendored
Normal file
17
vendor/filament/support/src/Commands/Concerns/CanIndentStrings.php
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
trait CanIndentStrings /** @phpstan-ignore trait.unused */
|
||||
{
|
||||
protected function indentString(string $string, int $level = 1): string
|
||||
{
|
||||
return implode(
|
||||
PHP_EOL,
|
||||
array_map(
|
||||
fn (string $line) => ($line !== '') ? (str_repeat(' ', $level) . "{$line}") : '',
|
||||
explode(PHP_EOL, $string),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
212
vendor/filament/support/src/Commands/Concerns/CanManipulateFiles.php
vendored
Normal file
212
vendor/filament/support/src/Commands/Concerns/CanManipulateFiles.php
vendored
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Support\Commands\FileGenerators\Contracts\FileGenerator;
|
||||
use Filament\Support\Commands\FileGenerators\Contracts\HasSkippedColumns;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Arr;
|
||||
use ReflectionClass;
|
||||
|
||||
use function Laravel\Prompts\confirm;
|
||||
|
||||
trait CanManipulateFiles
|
||||
{
|
||||
/**
|
||||
* Columns already reported to the user as skipped, to avoid warning about the same column more than once per command.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected array $reportedSkippedColumns = [];
|
||||
|
||||
/**
|
||||
* @param string | array<string> $paths
|
||||
*/
|
||||
protected function checkForCollision(string | array $paths): bool
|
||||
{
|
||||
foreach (Arr::wrap($paths) as $path) {
|
||||
if (! $this->fileExists($path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
(! app()->runningUnitTests()) &&
|
||||
(! confirm(basename($path) . ' already exists, do you want to overwrite it?'))
|
||||
) {
|
||||
$this->components->error("{$path} already exists, aborting.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unlink($path);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $replacements
|
||||
*/
|
||||
protected function copyStubToApp(string $stub, string $targetPath, array $replacements = []): void
|
||||
{
|
||||
$filesystem = app(Filesystem::class);
|
||||
|
||||
if (! $this->fileExists($stubPath = base_path("stubs/filament/{$stub}.stub"))) {
|
||||
$stubPath = $this->getDefaultStubPath() . "/{$stub}.stub";
|
||||
}
|
||||
|
||||
$stub = str($filesystem->get($stubPath));
|
||||
|
||||
foreach ($replacements as $key => $replacement) {
|
||||
$stub = $stub->replace("{{ {$key} }}", $replacement);
|
||||
}
|
||||
|
||||
$stub = (string) $stub;
|
||||
|
||||
$this->writeFile($targetPath, $stub);
|
||||
}
|
||||
|
||||
protected function fileExists(string $path): bool
|
||||
{
|
||||
$filesystem = app(Filesystem::class);
|
||||
|
||||
return $filesystem->exists($path);
|
||||
}
|
||||
|
||||
protected function escapeCssString(string $value): string
|
||||
{
|
||||
return (string) preg_replace_callback(
|
||||
'/[\x00-\x1F\x7F]/',
|
||||
static fn (array $matches): string => '\\' . dechex(ord($matches[0])) . ' ',
|
||||
str_replace(['\\', "'"], ['\\\\', "\\'"], $value),
|
||||
);
|
||||
}
|
||||
|
||||
protected function getRelativePath(string $path, string $from): string
|
||||
{
|
||||
$path = $this->normalizePath($path);
|
||||
$from = $this->normalizePath($from);
|
||||
$pathSegments = explode('/', ltrim($path, '/'));
|
||||
$fromSegments = explode('/', ltrim($from, '/'));
|
||||
$isPathOnWindowsDrive = preg_match('/^[a-z]:\//i', $path) === 1;
|
||||
$isFromOnWindowsDrive = preg_match('/^[a-z]:\//i', $from) === 1;
|
||||
$isPathOnNetworkShare = str_starts_with($path, '//');
|
||||
$isFromOnNetworkShare = str_starts_with($from, '//');
|
||||
|
||||
if (
|
||||
($isPathOnWindowsDrive || $isFromOnWindowsDrive) &&
|
||||
(
|
||||
! ($isPathOnWindowsDrive && $isFromOnWindowsDrive) ||
|
||||
(strcasecmp($pathSegments[0], $fromSegments[0]) !== 0)
|
||||
)
|
||||
) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
if (
|
||||
($isPathOnNetworkShare || $isFromOnNetworkShare) &&
|
||||
(
|
||||
! ($isPathOnNetworkShare && $isFromOnNetworkShare) ||
|
||||
(strcasecmp($pathSegments[0], $fromSegments[0]) !== 0) ||
|
||||
(strcasecmp($pathSegments[1], $fromSegments[1]) !== 0)
|
||||
)
|
||||
) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
if (str_starts_with($path, '/') !== str_starts_with($from, '/')) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
$isCaseInsensitive = $isPathOnWindowsDrive || $isPathOnNetworkShare;
|
||||
|
||||
while (
|
||||
filled($pathSegments) &&
|
||||
filled($fromSegments) &&
|
||||
($isCaseInsensitive
|
||||
? (strcasecmp($pathSegments[0], $fromSegments[0]) === 0)
|
||||
: ($pathSegments[0] === $fromSegments[0]))
|
||||
) {
|
||||
array_shift($pathSegments);
|
||||
array_shift($fromSegments);
|
||||
}
|
||||
|
||||
return str_repeat('../', count($fromSegments)) . implode('/', $pathSegments);
|
||||
}
|
||||
|
||||
protected function normalizePath(string $path): string
|
||||
{
|
||||
$isNetworkPath = str_starts_with($path, '\\\\') || str_starts_with($path, '//');
|
||||
$isAbsolute = str_starts_with($path, '/') || str_starts_with($path, '\\');
|
||||
$normalizedSegments = [];
|
||||
|
||||
foreach (explode('/', str_replace('\\', '/', $path)) as $segment) {
|
||||
if (($segment === '') || ($segment === '.')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (($segment === '..') && filled($normalizedSegments) && (array_last($normalizedSegments) !== '..')) {
|
||||
array_pop($normalizedSegments);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$normalizedSegments[] = $segment;
|
||||
}
|
||||
|
||||
return ($isNetworkPath ? '//' : ($isAbsolute ? '/' : '')) . implode('/', $normalizedSegments);
|
||||
}
|
||||
|
||||
protected function writeFile(string $path, string | FileGenerator $contents): void
|
||||
{
|
||||
$filesystem = app(Filesystem::class);
|
||||
|
||||
$filesystem->ensureDirectoryExists(
|
||||
pathinfo($path, PATHINFO_DIRNAME),
|
||||
);
|
||||
|
||||
if ($contents instanceof FileGenerator) {
|
||||
$filesystem->put($path, $contents->generate());
|
||||
|
||||
if ($contents instanceof HasSkippedColumns) {
|
||||
$this->reportSkippedColumns($contents->getSkippedColumns());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$filesystem->put($path, $contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $skippedColumns Column names, keyed by name with their database type as the value.
|
||||
*/
|
||||
protected function reportSkippedColumns(array $skippedColumns): void
|
||||
{
|
||||
$newlySkippedColumns = array_diff_key($skippedColumns, $this->reportedSkippedColumns);
|
||||
|
||||
if (empty($newlySkippedColumns)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->reportedSkippedColumns = [
|
||||
...$this->reportedSkippedColumns,
|
||||
...$newlySkippedColumns,
|
||||
];
|
||||
|
||||
$columnsList = collect($newlySkippedColumns)
|
||||
->map(fn (string $type, string $name): string => "{$name} ({$type})")
|
||||
->join(', ');
|
||||
|
||||
$this->components->warn("Binary columns were skipped, as they cannot be displayed in the browser: {$columnsList}. Add them to your model's `\$hidden` property to prevent errors.");
|
||||
}
|
||||
|
||||
protected function getDefaultStubPath(): string
|
||||
{
|
||||
$reflectionClass = new ReflectionClass($this);
|
||||
|
||||
return (string) str($reflectionClass->getFileName())
|
||||
->beforeLast('Commands')
|
||||
->append('../stubs');
|
||||
}
|
||||
}
|
||||
27
vendor/filament/support/src/Commands/Concerns/CanOpenUrlInBrowser.php
vendored
Normal file
27
vendor/filament/support/src/Commands/Concerns/CanOpenUrlInBrowser.php
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
trait CanOpenUrlInBrowser
|
||||
{
|
||||
public function openUrlInBrowser(string $url): void
|
||||
{
|
||||
$result = -1;
|
||||
|
||||
if (PHP_OS_FAMILY === 'Darwin') {
|
||||
exec('open "' . $url . '"', result_code: $result);
|
||||
}
|
||||
if (PHP_OS_FAMILY === 'Linux') {
|
||||
exec('xdg-open "' . $url . '"', result_code: $result);
|
||||
}
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
exec('start "" "' . $url . '"', result_code: $result);
|
||||
}
|
||||
|
||||
if ($result !== 0) {
|
||||
$this->components->error('An error occurred while trying to open the page in your browser.');
|
||||
$this->output->writeln(' <comment>Please open the following URL in your browser:</>');
|
||||
$this->output->writeln(' <href="' . $url . '">' . $url . '</>');
|
||||
}
|
||||
}
|
||||
}
|
||||
287
vendor/filament/support/src/Commands/Concerns/CanReadModelSchemas.php
vendored
Normal file
287
vendor/filament/support/src/Commands/Concerns/CanReadModelSchemas.php
vendored
Normal file
|
|
@ -0,0 +1,287 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
|
||||
trait CanReadModelSchemas
|
||||
{
|
||||
/**
|
||||
* @return class-string<Model>|null
|
||||
*/
|
||||
protected function parseModel(string $model): ?string
|
||||
{
|
||||
if (! class_exists($model)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Model> $model
|
||||
*/
|
||||
protected function getModelSchema(string $model): Builder
|
||||
{
|
||||
return app($model)
|
||||
->getConnection()
|
||||
->getSchemaBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Model> $model
|
||||
*/
|
||||
protected function getModelTable(string $model): string
|
||||
{
|
||||
return app($model)->getTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Model> $model
|
||||
*/
|
||||
protected function guessBelongsToRelationshipName(string $column, string $model): ?string
|
||||
{
|
||||
/** @var Model $modelInstance */
|
||||
$modelInstance = app($model);
|
||||
$modelInstanceReflection = new ReflectionClass($modelInstance);
|
||||
$guessedRelationshipName = str($column)->beforeLast('_id');
|
||||
$hasRelationship = $modelInstanceReflection->hasMethod($guessedRelationshipName);
|
||||
|
||||
if (! $hasRelationship) {
|
||||
$guessedRelationshipName = $guessedRelationshipName->camel();
|
||||
$hasRelationship = $modelInstanceReflection->hasMethod($guessedRelationshipName);
|
||||
}
|
||||
|
||||
if (! $hasRelationship) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$type = $modelInstanceReflection->getMethod($guessedRelationshipName)->getReturnType();
|
||||
|
||||
if (
|
||||
(! $type) ||
|
||||
(! method_exists($type, 'getName')) ||
|
||||
($type->getName() !== BelongsTo::class)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
} catch (ReflectionException $exception) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $guessedRelationshipName;
|
||||
}
|
||||
|
||||
protected function guessBelongsToRelationshipTableName(string $column): ?string
|
||||
{
|
||||
$tableName = str($column)->beforeLast('_id');
|
||||
|
||||
if (Schema::hasTable(Str::plural($tableName))) {
|
||||
return Str::plural($tableName);
|
||||
}
|
||||
|
||||
if (! Schema::hasTable($tableName)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Model> $model
|
||||
*/
|
||||
protected function guessBelongsToRelationshipTitleColumnName(string $column, string $model): string
|
||||
{
|
||||
$schema = $this->getModelSchema($model);
|
||||
$table = $this->getModelTable($model);
|
||||
|
||||
$columns = collect($schema->getColumnListing($table));
|
||||
|
||||
if ($columns->contains('name')) {
|
||||
return 'name';
|
||||
}
|
||||
|
||||
if ($columns->contains('title')) {
|
||||
return 'title';
|
||||
}
|
||||
|
||||
return collect($schema->getIndexes($table))
|
||||
->firstWhere('primary')['columns'][0] ?? 'id';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $column
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function parseColumnType(array $column): array
|
||||
{
|
||||
$type = match ($column['type']) {
|
||||
'tinyint(1)', 'bit' => 'boolean',
|
||||
'varchar(max)', 'nvarchar(max)' => 'text',
|
||||
default => null,
|
||||
};
|
||||
|
||||
$type ??= match ($column['type_name']) {
|
||||
'boolean', 'bool' => 'boolean',
|
||||
'char', 'bpchar', 'nchar' => 'char',
|
||||
'varchar', 'nvarchar' => 'string',
|
||||
'integer', 'int', 'int4', 'tinyint', 'smallint', 'int2', 'mediumint', 'bigint', 'int8' => 'integer',
|
||||
'decimal', 'numeric' => 'decimal',
|
||||
'float', 'real', 'float4' => 'float',
|
||||
'double', 'float8' => 'double',
|
||||
'money', 'smallmoney' => 'money',
|
||||
'date' => 'date',
|
||||
'time', 'timetz' => 'time',
|
||||
'datetime', 'datetime2', 'smalldatetime', 'datetimeoffset' => 'datetime',
|
||||
'timestamp', 'timestamptz' => 'timestamp',
|
||||
'text', 'tinytext', 'longtext', 'mediumtext', 'ntext' => 'text',
|
||||
'json', 'jsonb' => 'json',
|
||||
'binary', 'varbinary', 'blob', 'tinyblob', 'mediumblob', 'longblob', 'bytea' => 'binary',
|
||||
'geometry', 'geography', 'point', 'linestring', 'polygon', 'multipoint', 'multilinestring', 'multipolygon', 'geometrycollection', 'geomcollection' => 'binary',
|
||||
default => $column['type_name'],
|
||||
};
|
||||
|
||||
$values = str_contains($column['type'], '(')
|
||||
? str_getcsv(Str::between($column['type'], '(', ')'), enclosure: "'", escape: '\\')
|
||||
: null;
|
||||
|
||||
$values = is_null($values) ? [] : match ($type) {
|
||||
'string', 'char', 'binary', 'bit' => ['length' => (int) $values[0]],
|
||||
'enum' => ['values' => array_map(fn (string $value): string => trim($value, '\''), $values)],
|
||||
default => [],
|
||||
};
|
||||
|
||||
return array_merge(['name' => $type], array_filter($values));
|
||||
}
|
||||
|
||||
/**
|
||||
* Columns skipped while reading the model schema, keyed by column name with their database type as the value.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected array $skippedColumns = [];
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $type
|
||||
*/
|
||||
protected function canGenerateSchemaComponentForColumnType(array $type): bool
|
||||
{
|
||||
// Binary and spatial columns (`blob`, `geometry`, `point`, etc.) hold data that
|
||||
// is not valid UTF-8, so it cannot be serialized to JavaScript for a schema component.
|
||||
return $type['name'] !== 'binary';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Model> $model
|
||||
* @param array<string, mixed> $column
|
||||
*/
|
||||
protected function recordSkippedColumn(string $model, array $column): void
|
||||
{
|
||||
// A column that is already `$hidden` is excluded from the model's array representation, so it cannot cause errors and does not need a warning.
|
||||
if (in_array($column['name'], app($model)->getHidden(), strict: true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->skippedColumns[$column['name']] = $column['type_name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getSkippedColumns(): array
|
||||
{
|
||||
return $this->skippedColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $column
|
||||
* @param class-string<Model> $model
|
||||
*/
|
||||
protected function parseDefaultExpression(array $column, string $model): mixed
|
||||
{
|
||||
$default = $column['default'];
|
||||
|
||||
if (blank($default)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$driver = app($model)->getConnection()->getDriverName();
|
||||
|
||||
if (in_array($driver, ['mysql', 'mariadb'])) {
|
||||
if ($default === 'NULL'
|
||||
|| preg_match("/^\(.*\)$/", $default) === 1
|
||||
|| str_ends_with($default, '()')
|
||||
|| str_starts_with(strtolower($default), 'current_timestamp')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (preg_match("/^'(.*)'$/", $default, $matches) === 1) {
|
||||
return str_replace("''", "'", $matches[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($driver === 'pgsql') {
|
||||
if (str_starts_with($default, 'NULL::')) {
|
||||
$default = null;
|
||||
}
|
||||
|
||||
if (preg_match("/^['(](.*)[')]::/", $default, $matches) === 1) {
|
||||
return str_replace("''", "'", $matches[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($driver === 'sqlsrv') {
|
||||
while (preg_match('/^\((.*)\)$/', $default, $matches)) {
|
||||
$default = $matches[1];
|
||||
}
|
||||
|
||||
if ($default === 'NULL'
|
||||
|| str_ends_with($default, '()')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (preg_match('/^\'(.*)\'$/', $default, $matches) === 1) {
|
||||
return str_replace("''", "'", $matches[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($driver === 'sqlite') {
|
||||
if ($default === 'NULL'
|
||||
|| str_starts_with(strtolower($default), 'current_timestamp')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (preg_match('/^\'(.*)\'$/s', $default, $matches) === 1) {
|
||||
return str_replace("''", "'", $matches[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
public function getRecordTitleAttribute(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Model> $model
|
||||
* @return array<string>
|
||||
*/
|
||||
protected function getEnumCasts(string $model): array
|
||||
{
|
||||
$casts = app($model)->getCasts();
|
||||
|
||||
return array_filter(
|
||||
$casts,
|
||||
fn (mixed $cast): bool => is_string($cast) ? enum_exists($cast) : false,
|
||||
);
|
||||
}
|
||||
}
|
||||
175
vendor/filament/support/src/Commands/Concerns/HasCluster.php
vendored
Normal file
175
vendor/filament/support/src/Commands/Concerns/HasCluster.php
vendored
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Clusters\Cluster;
|
||||
use ReflectionClass;
|
||||
|
||||
use function Laravel\Prompts\confirm;
|
||||
use function Laravel\Prompts\search;
|
||||
use function Laravel\Prompts\text;
|
||||
|
||||
trait HasCluster
|
||||
{
|
||||
/**
|
||||
* @var ?class-string<Cluster>
|
||||
*/
|
||||
protected ?string $clusterFqn = null;
|
||||
|
||||
protected function configureClusterFqn(string $initialQuestion, string $question): void
|
||||
{
|
||||
$this->clusterFqn = $this->askForCluster($initialQuestion, $question, $this->option('cluster'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?class-string<Cluster>
|
||||
*/
|
||||
protected function askForCluster(string $initialQuestion, string $question, ?string $initialValue = null): ?string
|
||||
{
|
||||
$clusterFqns = array_values($this->panel->getClusters());
|
||||
|
||||
if (
|
||||
blank($initialValue) &&
|
||||
(empty($clusterFqns) || (! confirm(
|
||||
label: $initialQuestion,
|
||||
default: false,
|
||||
)))
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (is_string($initialValue)) {
|
||||
$cluster = (string) str($initialValue)
|
||||
->trim('/')
|
||||
->trim('\\')
|
||||
->trim(' ')
|
||||
->replace('/', '\\');
|
||||
|
||||
if (! class_exists($cluster)) {
|
||||
$this->components->warn('The cluster class provided does not exist.');
|
||||
} elseif (! is_subclass_of($cluster, Cluster::class)) {
|
||||
$this->components->warn('The cluster class or one of its parents must extend [' . Cluster::class . '].');
|
||||
} else {
|
||||
return $cluster;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($clusterFqns)) {
|
||||
$clusterFqn = (string) str(text(
|
||||
label: "No clusters were found within the [{$this->panel->getId()}] panel. {$question}",
|
||||
placeholder: app()->getNamespace() . 'Filament\\Clusters\\Blog',
|
||||
required: true,
|
||||
validate: function (string $value): ?string {
|
||||
$value = (string) str($value)
|
||||
->trim('/')
|
||||
->trim('\\')
|
||||
->trim(' ')
|
||||
->replace('/', '\\');
|
||||
|
||||
if (
|
||||
(! class_exists($value)) &&
|
||||
class_exists("{$value}\\" . class_basename($value) . 'Cluster')
|
||||
) {
|
||||
$value = "{$value}\\" . class_basename($value) . 'Cluster';
|
||||
}
|
||||
|
||||
return match (true) {
|
||||
! class_exists($value) => 'The cluster class doesn\'t exist, please use the fully-qualified class name.',
|
||||
! is_subclass_of($value, Cluster::class) => 'The cluster class or one of its parents must extend [' . Cluster::class . '].',
|
||||
default => null,
|
||||
};
|
||||
},
|
||||
hint: 'Please provide the fully-qualified class name of the cluster.',
|
||||
))
|
||||
->trim('/')
|
||||
->trim('\\')
|
||||
->trim(' ')
|
||||
->replace('/', '\\');
|
||||
|
||||
if (
|
||||
(! class_exists($clusterFqn)) &&
|
||||
class_exists("{$clusterFqn}\\" . class_basename($clusterFqn) . 'Cluster')
|
||||
) {
|
||||
return "{$clusterFqn}\\" . class_basename($clusterFqn) . 'Cluster';
|
||||
}
|
||||
|
||||
return $clusterFqn;
|
||||
}
|
||||
|
||||
return search(
|
||||
label: $question,
|
||||
options: function (?string $search) use ($clusterFqns): array {
|
||||
if (blank($search)) {
|
||||
return $clusterFqns;
|
||||
}
|
||||
|
||||
$search = str($search)->trim()->replace(['\\', '/'], '');
|
||||
|
||||
return collect($clusterFqns)
|
||||
->filter(fn (string $fqn): bool => str($fqn)->replace(['\\', '/'], '')->contains($search, ignoreCase: true))
|
||||
->mapWithKeys(function (string $fqn): array {
|
||||
$basenameBeforeCluster = (string) str($fqn)
|
||||
->classBasename()
|
||||
->beforeLast('Cluster');
|
||||
|
||||
$namespacePartBeforeBasename = (string) str($fqn)
|
||||
->beforeLast('\\')
|
||||
->classBasename();
|
||||
|
||||
if ($basenameBeforeCluster === $namespacePartBeforeBasename) {
|
||||
return [$fqn => (string) str($fqn)->beforeLast('\\')];
|
||||
}
|
||||
|
||||
return [$fqn => $fqn];
|
||||
})
|
||||
->all();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
protected function configureClusterResourcesLocation(): void
|
||||
{
|
||||
[
|
||||
$this->resourcesNamespace, /** @phpstan-ignore-line */
|
||||
$this->resourcesDirectory, /** @phpstan-ignore-line */
|
||||
] = $this->getClusterResourcesLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?class-string<Cluster> $clusterFqn
|
||||
* @return array{
|
||||
* 0: string,
|
||||
* 1: string
|
||||
* }
|
||||
*/
|
||||
public function getClusterResourcesLocation(?string $clusterFqn = null): array
|
||||
{
|
||||
$clusterFqn ??= $this->clusterFqn;
|
||||
|
||||
$clusterBasenameBeforeCluster = (string) str($clusterFqn)
|
||||
->classBasename()
|
||||
->beforeLast('Cluster');
|
||||
|
||||
$clusterNamespacePartBeforeBasename = (string) str($clusterFqn)
|
||||
->beforeLast('\\')
|
||||
->classBasename();
|
||||
|
||||
if ($clusterBasenameBeforeCluster === $clusterNamespacePartBeforeBasename) {
|
||||
return [
|
||||
(string) str($clusterFqn)
|
||||
->beforeLast('\\')
|
||||
->append('\\Resources'),
|
||||
(string) str((new ReflectionClass($clusterFqn))->getFileName())
|
||||
->beforeLast(DIRECTORY_SEPARATOR)
|
||||
->append('/Resources'),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
"{$clusterFqn}\\Resources",
|
||||
(string) str((new ReflectionClass($clusterFqn))->getFileName())
|
||||
->beforeLast('.')
|
||||
->append('/Resources'),
|
||||
];
|
||||
}
|
||||
}
|
||||
35
vendor/filament/support/src/Commands/Concerns/HasClusterPagesLocation.php
vendored
Normal file
35
vendor/filament/support/src/Commands/Concerns/HasClusterPagesLocation.php
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use ReflectionClass;
|
||||
|
||||
trait HasClusterPagesLocation
|
||||
{
|
||||
protected function configureClusterPagesLocation(): void
|
||||
{
|
||||
$clusterBasenameBeforeCluster = (string) str($this->clusterFqn)
|
||||
->classBasename()
|
||||
->beforeLast('Cluster');
|
||||
|
||||
$clusterNamespacePartBeforeBasename = (string) str($this->clusterFqn)
|
||||
->beforeLast('\\')
|
||||
->classBasename();
|
||||
|
||||
if ($clusterBasenameBeforeCluster === $clusterNamespacePartBeforeBasename) {
|
||||
$this->pagesNamespace = (string) str($this->clusterFqn)
|
||||
->beforeLast('\\')
|
||||
->append('\\Pages');
|
||||
$this->pagesDirectory = (string) str((new ReflectionClass($this->clusterFqn))->getFileName())
|
||||
->beforeLast(DIRECTORY_SEPARATOR)
|
||||
->append('/Pages');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->pagesNamespace = "{$this->clusterFqn}\\Pages";
|
||||
$this->pagesDirectory = (string) str((new ReflectionClass($this->clusterFqn))->getFileName())
|
||||
->beforeLast('.')
|
||||
->append('/Pages');
|
||||
}
|
||||
}
|
||||
63
vendor/filament/support/src/Commands/Concerns/HasPanel.php
vendored
Normal file
63
vendor/filament/support/src/Commands/Concerns/HasPanel.php
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Exceptions\NoDefaultPanelSetException;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Panel;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use function Laravel\Prompts\confirm;
|
||||
use function Laravel\Prompts\select;
|
||||
|
||||
trait HasPanel
|
||||
{
|
||||
protected ?Panel $panel;
|
||||
|
||||
protected function configurePanel(string $question, ?string $initialQuestion = null): void
|
||||
{
|
||||
if (! class_exists(Panel::class)) {
|
||||
$this->panel = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$panelName = ($this->hasArgument('panel') ? $this->argument('panel') : null) ?? $this->option('panel'); /** @phpstan-ignore-line */
|
||||
$this->panel = filled($panelName) ? Filament::getPanel($panelName, isStrict: false) : null;
|
||||
|
||||
if ($this->panel) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (filled($initialQuestion) && (! confirm(label: $initialQuestion))) {
|
||||
$this->panel = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$panels = Filament::getPanels();
|
||||
|
||||
if (count($panels) > 1) {
|
||||
try {
|
||||
$defaultPanelId = Filament::getDefaultPanel()->getId();
|
||||
} catch (NoDefaultPanelSetException) {
|
||||
$defaultPanelId = null;
|
||||
}
|
||||
|
||||
/** @var Panel $panel */
|
||||
$panel = $panels[select(
|
||||
label: $question,
|
||||
options: array_map(
|
||||
fn (Panel $panel): string => $panel->getId(),
|
||||
$panels,
|
||||
),
|
||||
default: $defaultPanelId,
|
||||
)];
|
||||
} else {
|
||||
/** @var Panel $panel */
|
||||
$panel = Arr::first($panels);
|
||||
}
|
||||
|
||||
$this->panel = $panel;
|
||||
}
|
||||
}
|
||||
81
vendor/filament/support/src/Commands/Concerns/HasResourcesLocation.php
vendored
Normal file
81
vendor/filament/support/src/Commands/Concerns/HasResourcesLocation.php
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use function Filament\Support\is_path_within_vendor_directory;
|
||||
use function Laravel\Prompts\search;
|
||||
|
||||
trait HasResourcesLocation
|
||||
{
|
||||
protected string $resourcesNamespace;
|
||||
|
||||
protected string $resourcesDirectory;
|
||||
|
||||
protected function configureResourcesLocation(string $question): void
|
||||
{
|
||||
if (filled($this->clusterFqn)) {
|
||||
return;
|
||||
}
|
||||
|
||||
[
|
||||
$this->resourcesNamespace,
|
||||
$this->resourcesDirectory,
|
||||
] = $this->getResourcesLocation($question);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* 0: string,
|
||||
* 1: string,
|
||||
* }
|
||||
*/
|
||||
public function getResourcesLocation(string $question): array
|
||||
{
|
||||
$directories = $this->panel->getResourceDirectories();
|
||||
$namespaces = $this->panel->getResourceNamespaces();
|
||||
|
||||
foreach ($directories as $index => $directory) {
|
||||
if (is_path_within_vendor_directory($directory, base_path())) {
|
||||
unset($directories[$index]);
|
||||
unset($namespaces[$index]);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($namespaces) < 2) {
|
||||
return [
|
||||
(Arr::first($namespaces) ?? app()->getNamespace() . 'Filament\\Resources'),
|
||||
(Arr::first($directories) ?? app_path('Filament/Resources/')),
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->option('resource-namespace')) {
|
||||
return [
|
||||
(string) $this->option('resource-namespace'),
|
||||
$directories[array_search($this->option('resource-namespace'), $namespaces)],
|
||||
];
|
||||
}
|
||||
|
||||
$keyedNamespaces = array_combine(
|
||||
$namespaces,
|
||||
$namespaces,
|
||||
);
|
||||
|
||||
return [
|
||||
$namespace = search(
|
||||
label: $question,
|
||||
options: function (?string $search) use ($keyedNamespaces): array {
|
||||
if (blank($search)) {
|
||||
return $keyedNamespaces;
|
||||
}
|
||||
|
||||
$search = str($search)->trim()->replace(['\\', '/'], '');
|
||||
|
||||
return array_filter($keyedNamespaces, fn (string $namespace): bool => str($namespace)->replace(['\\', '/'], '')->contains($search, ignoreCase: true));
|
||||
},
|
||||
),
|
||||
$directories[array_search($namespace, $namespaces)],
|
||||
];
|
||||
}
|
||||
}
|
||||
7
vendor/filament/support/src/Commands/Exceptions/FailureCommandOutput.php
vendored
Normal file
7
vendor/filament/support/src/Commands/Exceptions/FailureCommandOutput.php
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class FailureCommandOutput extends Exception {}
|
||||
7
vendor/filament/support/src/Commands/Exceptions/SuccessCommandOutput.php
vendored
Normal file
7
vendor/filament/support/src/Commands/Exceptions/SuccessCommandOutput.php
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class SuccessCommandOutput extends Exception {}
|
||||
143
vendor/filament/support/src/Commands/FileGenerators/ClassGenerator.php
vendored
Normal file
143
vendor/filament/support/src/Commands/FileGenerators/ClassGenerator.php
vendored
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\FileGenerators;
|
||||
|
||||
use Filament\Support\Commands\FileGenerators\Concerns\CanCheckFileGenerationFlags;
|
||||
use Filament\Support\Commands\FileGenerators\Contracts\FileGenerator;
|
||||
use Nette\PhpGenerator\ClassType;
|
||||
use Nette\PhpGenerator\PhpFile;
|
||||
use Nette\PhpGenerator\PhpNamespace;
|
||||
use Nette\PhpGenerator\Printer;
|
||||
use Nette\PhpGenerator\PsrPrinter;
|
||||
|
||||
abstract class ClassGenerator implements FileGenerator
|
||||
{
|
||||
use CanCheckFileGenerationFlags;
|
||||
|
||||
protected PhpNamespace $namespace;
|
||||
|
||||
public function getFile(): PhpFile
|
||||
{
|
||||
$file = (new PhpFile);
|
||||
$this->configureFile($file);
|
||||
|
||||
$this->namespace = $file->addNamespace($this->getNamespace());
|
||||
$this->useImportsInNamespace($this->namespace, $this->getImports());
|
||||
$this->configureNamespace($this->namespace);
|
||||
|
||||
$class = $this->namespace->addClass($this->getBasename());
|
||||
|
||||
if (filled($extends = $this->getExtends())) {
|
||||
$class->setExtends($extends);
|
||||
}
|
||||
|
||||
foreach ($this->getImplements() as $implement) {
|
||||
$class->addImplement($implement);
|
||||
}
|
||||
|
||||
$this->addTraitsToClass($class);
|
||||
$this->addPropertiesToClass($class);
|
||||
$this->addMethodsToClass($class);
|
||||
$this->configureClass($class);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
protected function configureFile(PhpFile $file): void {}
|
||||
|
||||
protected function configureNamespace(PhpNamespace $namespace): void {}
|
||||
|
||||
protected function configureClass(ClassType $class): void {}
|
||||
|
||||
protected function addTraitsToClass(ClassType $class): void {}
|
||||
|
||||
protected function addPropertiesToClass(ClassType $class): void {}
|
||||
|
||||
protected function addMethodsToClass(ClassType $class): void {}
|
||||
|
||||
/**
|
||||
* @return ?class-string
|
||||
*/
|
||||
public function getExtends(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string>
|
||||
*/
|
||||
public function getImplements(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string $name
|
||||
*/
|
||||
public function simplifyFqn(string $name): string
|
||||
{
|
||||
return $this->namespace->simplifyName($name);
|
||||
}
|
||||
|
||||
abstract public function getBasename(): string;
|
||||
|
||||
abstract public function getNamespace(): string;
|
||||
|
||||
protected function extractNamespace(string $fqn): string
|
||||
{
|
||||
return (string) str($fqn)->beforeLast('\\');
|
||||
}
|
||||
|
||||
public function hasPartialImports(): bool
|
||||
{
|
||||
return $this->hasFileGenerationFlag(FileGenerationFlag::PARTIAL_IMPORTS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string> $imports
|
||||
*/
|
||||
protected function useImportsInNamespace(PhpNamespace $namespace, array $imports): void
|
||||
{
|
||||
foreach ($imports as $key => $import) {
|
||||
if (is_string($key)) {
|
||||
$namespace->addUse($key, alias: $import);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$namespace->addUse($import);
|
||||
}
|
||||
}
|
||||
|
||||
protected function importUnlessPartial(string $class): void
|
||||
{
|
||||
if ($this->hasPartialImports()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->namespace->addUse($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
public function getImports(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getPrinter(): Printer
|
||||
{
|
||||
$printer = new PsrPrinter;
|
||||
$printer->linesBetweenProperties = 1;
|
||||
|
||||
return $printer;
|
||||
}
|
||||
|
||||
protected function configurePrinter(Printer $printer): void {}
|
||||
|
||||
public function generate(): string
|
||||
{
|
||||
return $this->getPrinter()->printFile($this->getFile());
|
||||
}
|
||||
}
|
||||
11
vendor/filament/support/src/Commands/FileGenerators/Concerns/CanCheckFileGenerationFlags.php
vendored
Normal file
11
vendor/filament/support/src/Commands/FileGenerators/Concerns/CanCheckFileGenerationFlags.php
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\FileGenerators\Concerns;
|
||||
|
||||
trait CanCheckFileGenerationFlags
|
||||
{
|
||||
protected function hasFileGenerationFlag(string $flag): bool
|
||||
{
|
||||
return in_array($flag, config('filament.file_generation.flags') ?? []);
|
||||
}
|
||||
}
|
||||
19
vendor/filament/support/src/Commands/FileGenerators/Concerns/CanGenerateViewProperty.php
vendored
Normal file
19
vendor/filament/support/src/Commands/FileGenerators/Concerns/CanGenerateViewProperty.php
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\FileGenerators\Concerns;
|
||||
|
||||
use Nette\PhpGenerator\ClassType;
|
||||
use Nette\PhpGenerator\Property;
|
||||
|
||||
trait CanGenerateViewProperty
|
||||
{
|
||||
protected function addViewPropertyToClass(ClassType $class): void
|
||||
{
|
||||
$property = $class->addProperty('view', $this->getView())
|
||||
->setProtected()
|
||||
->setType('string');
|
||||
$this->configureViewProperty($property);
|
||||
}
|
||||
|
||||
protected function configureViewProperty(Property $property): void {}
|
||||
}
|
||||
8
vendor/filament/support/src/Commands/FileGenerators/Contracts/FileGenerator.php
vendored
Normal file
8
vendor/filament/support/src/Commands/FileGenerators/Contracts/FileGenerator.php
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\FileGenerators\Contracts;
|
||||
|
||||
interface FileGenerator
|
||||
{
|
||||
public function generate(): string;
|
||||
}
|
||||
11
vendor/filament/support/src/Commands/FileGenerators/Contracts/HasSkippedColumns.php
vendored
Normal file
11
vendor/filament/support/src/Commands/FileGenerators/Contracts/HasSkippedColumns.php
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\FileGenerators\Contracts;
|
||||
|
||||
interface HasSkippedColumns
|
||||
{
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getSkippedColumns(): array;
|
||||
}
|
||||
16
vendor/filament/support/src/Commands/FileGenerators/FileGenerationFlag.php
vendored
Normal file
16
vendor/filament/support/src/Commands/FileGenerators/FileGenerationFlag.php
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands\FileGenerators;
|
||||
|
||||
class FileGenerationFlag
|
||||
{
|
||||
const EMBEDDED_PANEL_RESOURCE_SCHEMAS = 'embedded_panel_resource_schemas';
|
||||
|
||||
const EMBEDDED_PANEL_RESOURCE_TABLES = 'embedded_panel_resource_tables';
|
||||
|
||||
const PANEL_CLUSTER_CLASSES_OUTSIDE_DIRECTORIES = 'panel_cluster_classes_outside_directories';
|
||||
|
||||
const PANEL_RESOURCE_CLASSES_OUTSIDE_DIRECTORIES = 'panel_resource_classes_outside_directories';
|
||||
|
||||
const PARTIAL_IMPORTS = 'partial_imports';
|
||||
}
|
||||
306
vendor/filament/support/src/Commands/InstallCommand.php
vendored
Normal file
306
vendor/filament/support/src/Commands/InstallCommand.php
vendored
Normal file
|
|
@ -0,0 +1,306 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands;
|
||||
|
||||
use Composer\InstalledVersions;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Commands\Concerns\CanGeneratePanels;
|
||||
use Filament\Support\Commands\Concerns\CanManipulateFiles;
|
||||
use Filament\Support\Commands\Concerns\CanOpenUrlInBrowser;
|
||||
use Filament\Support\Commands\Exceptions\FailureCommandOutput;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
use function Laravel\Prompts\confirm;
|
||||
|
||||
#[AsCommand(name: 'filament:install', aliases: [
|
||||
'install:filament',
|
||||
])]
|
||||
class InstallCommand extends Command
|
||||
{
|
||||
use CanGeneratePanels;
|
||||
use CanManipulateFiles;
|
||||
use CanOpenUrlInBrowser;
|
||||
|
||||
protected $description = 'Install Filament';
|
||||
|
||||
protected $name = 'filament:install';
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $aliases = [
|
||||
'install:filament',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array<InputOption>
|
||||
*/
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
new InputOption(
|
||||
name: 'panels',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_NONE,
|
||||
description: 'Install the panel builder and create the first panel',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'scaffold',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_NONE,
|
||||
description: 'Install the Filament packages for use outside of panels, in your Blade or Livewire application',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'notifications',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_NONE,
|
||||
description: 'Install the Filament flash notifications into the scaffolded layout file',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'force',
|
||||
shortcut: 'F',
|
||||
mode: InputOption::VALUE_NONE,
|
||||
description: 'Overwrite the contents of the files if they already exist',
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
public function __invoke(): int
|
||||
{
|
||||
try {
|
||||
$this->installAdminPanel();
|
||||
$this->installScaffolding();
|
||||
$this->installUpgradeCommand();
|
||||
$this->ignorePublishedAssets();
|
||||
} catch (FailureCommandOutput) {
|
||||
return static::FAILURE;
|
||||
}
|
||||
|
||||
$this->call(UpgradeCommand::class);
|
||||
|
||||
$this->askToStar();
|
||||
|
||||
return static::SUCCESS;
|
||||
}
|
||||
|
||||
protected function installAdminPanel(): void
|
||||
{
|
||||
if (! $this->option('panels')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! class_exists(PanelProvider::class)) {
|
||||
$this->components->error('Please require [filament/filament] before attempting to install the Panel Builder.');
|
||||
|
||||
throw new FailureCommandOutput;
|
||||
}
|
||||
|
||||
$this->generatePanel(defaultId: 'admin', isForced: $this->option('force'));
|
||||
}
|
||||
|
||||
protected function installScaffolding(): void
|
||||
{
|
||||
if (! $this->option('scaffold')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$filesystem = app(Filesystem::class);
|
||||
$filesystem->copyDirectory(__DIR__ . '/../../stubs/scaffolding', base_path());
|
||||
|
||||
$hasNotifications = false;
|
||||
|
||||
if (
|
||||
InstalledVersions::isInstalled('filament/notifications') &&
|
||||
($this->option('notifications') || confirm(
|
||||
label: 'Do you want to send flash notifications using Filament?',
|
||||
default: true,
|
||||
))
|
||||
) {
|
||||
$layout = $filesystem->get(resource_path('views/layouts/app.blade.php'));
|
||||
$layout = (string) str($layout)
|
||||
->replace('{{ $slot }}', '{{ $slot }}' . PHP_EOL . PHP_EOL . ' @livewire(\'notifications\')');
|
||||
$filesystem->put(resource_path('views/layouts/app.blade.php'), $layout);
|
||||
|
||||
$hasNotifications = true;
|
||||
}
|
||||
|
||||
$cssDirectory = resource_path('css');
|
||||
$packagesCssImports = collect([
|
||||
'support',
|
||||
'actions',
|
||||
'forms',
|
||||
'infolists',
|
||||
...($hasNotifications ? ['notifications'] : []),
|
||||
'schemas',
|
||||
'tables',
|
||||
'widgets',
|
||||
])
|
||||
->filter(fn (string $package): bool => InstalledVersions::isInstalled("filament/{$package}"))
|
||||
->map(function (string $package) use ($cssDirectory): string {
|
||||
$packageCssPath = $this->getRelativePath(
|
||||
(string) InstalledVersions::getInstallPath("filament/{$package}") . '/resources/css/index.css',
|
||||
$cssDirectory,
|
||||
);
|
||||
|
||||
return "@import '{$this->escapeCssString($packageCssPath)}';";
|
||||
})
|
||||
->implode(PHP_EOL);
|
||||
|
||||
$paginationViewsPath = $this->escapeCssString(
|
||||
$this->getRelativePath(
|
||||
(string) InstalledVersions::getInstallPath('laravel/framework') . '/src/Illuminate/Pagination/resources/views',
|
||||
$cssDirectory,
|
||||
),
|
||||
);
|
||||
|
||||
$css = $filesystem->get(resource_path('css/app.css'));
|
||||
$css = (string) str($css)
|
||||
->replace('{{ filamentCssImports }}', $packagesCssImports)
|
||||
->replace('{{ laravelPaginationViewsPath }}', $paginationViewsPath);
|
||||
$filesystem->put(resource_path('css/app.css'), $css);
|
||||
|
||||
$this->components->info('Scaffolding installed successfully.');
|
||||
|
||||
$this->components->info('Please run `npm run build` to compile your new assets.');
|
||||
}
|
||||
|
||||
protected function installUpgradeCommand(): void
|
||||
{
|
||||
$path = base_path('composer.json');
|
||||
|
||||
if (! file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$configuration = json_decode(file_get_contents($path), associative: true);
|
||||
|
||||
if (! is_array($configuration)) {
|
||||
$this->components->warn('Could not update [composer.json] because it could not be parsed as JSON. Please add "@php artisan filament:upgrade" to the "post-autoload-dump" scripts manually.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$command = '@php artisan filament:upgrade';
|
||||
|
||||
if (in_array($command, $configuration['scripts']['post-autoload-dump'] ?? [])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$configuration['scripts']['post-autoload-dump'] ??= [];
|
||||
$configuration['scripts']['post-autoload-dump'][] = $command;
|
||||
|
||||
file_put_contents(
|
||||
$path,
|
||||
(string) str(json_encode($configuration, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES))
|
||||
->append(PHP_EOL)
|
||||
->replace(
|
||||
search: " \"keywords\": [\n \"laravel\",\n \"framework\"\n ],",
|
||||
replace: ' "keywords": ["laravel", "framework"],',
|
||||
)
|
||||
->replace(
|
||||
search: " \"keywords\": [\n \"framework\",\n \"laravel\"\n ],",
|
||||
replace: ' "keywords": ["framework", "laravel"],',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
protected function ignorePublishedAssets(): void
|
||||
{
|
||||
$path = base_path('.gitignore');
|
||||
|
||||
if (! file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$contents = file_get_contents($path);
|
||||
|
||||
preg_match('/\r\n|\n|\r/', $contents, $lineEndingMatches);
|
||||
|
||||
$lineEnding = $lineEndingMatches[0] ?? PHP_EOL;
|
||||
|
||||
$lines = preg_split('/\r\n|\n|\r/', $contents);
|
||||
|
||||
$existingRules = collect($lines)
|
||||
->map(fn (string $rule): string => trim(rtrim($rule), '/'))
|
||||
->all();
|
||||
|
||||
$assetsPath = trim((string) config('filament.assets_path'), '/');
|
||||
|
||||
$newRules = collect(['css', 'fonts', 'js'])
|
||||
->map(fn (string $directory): string => collect(['public', $assetsPath, $directory, 'filament'])
|
||||
->filter()
|
||||
->implode('/'))
|
||||
->reject(fn (string $rule): bool => in_array($rule, $existingRules))
|
||||
->all();
|
||||
|
||||
if (blank($newRules)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($newRules as $newRule) {
|
||||
$previousRule = null;
|
||||
$previousRuleIndex = null;
|
||||
|
||||
foreach ($lines as $lineIndex => $line) {
|
||||
$rule = trim(rtrim($line), '/');
|
||||
|
||||
if (
|
||||
(! str_starts_with($rule, 'public/')) ||
|
||||
(strcmp($rule, $newRule) >= 0) ||
|
||||
(($previousRule !== null) && (strcmp($rule, $previousRule) <= 0))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$previousRule = $rule;
|
||||
$previousRuleIndex = $lineIndex;
|
||||
}
|
||||
|
||||
if ($previousRuleIndex !== null) {
|
||||
array_splice($lines, $previousRuleIndex + 1, 0, ["/{$newRule}"]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
while (($lines !== []) && (end($lines) === '')) {
|
||||
array_pop($lines);
|
||||
}
|
||||
|
||||
if ($lines !== []) {
|
||||
$lines[] = '';
|
||||
}
|
||||
|
||||
$lines[] = "/{$newRule}";
|
||||
}
|
||||
|
||||
if (end($lines) !== '') {
|
||||
$lines[] = '';
|
||||
}
|
||||
|
||||
file_put_contents(
|
||||
$path,
|
||||
implode($lineEnding, $lines),
|
||||
);
|
||||
|
||||
$this->components->info('Added the published Filament assets to [.gitignore].');
|
||||
}
|
||||
|
||||
protected function askToStar(): void
|
||||
{
|
||||
if ($this->option('no-interaction')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! confirm(
|
||||
label: 'All done! Would you like to show some love by starring the Filament repo on GitHub?',
|
||||
default: true,
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->openUrlInBrowser('https://github.com/filamentphp/filament');
|
||||
}
|
||||
}
|
||||
42
vendor/filament/support/src/Commands/MakeIssueCommand.php
vendored
Normal file
42
vendor/filament/support/src/Commands/MakeIssueCommand.php
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands;
|
||||
|
||||
use Composer\InstalledVersions;
|
||||
use Filament\Support\Commands\Concerns\CanOpenUrlInBrowser;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
|
||||
#[AsCommand(name: 'make:filament-issue', aliases: [
|
||||
'filament:issue',
|
||||
'filament:make-issue',
|
||||
])]
|
||||
class MakeIssueCommand extends Command
|
||||
{
|
||||
use CanOpenUrlInBrowser;
|
||||
|
||||
protected $description = 'Generates a link to the Filament issue page and pre-fills the version numbers.';
|
||||
|
||||
protected $name = 'make:filament-issue';
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $aliases = [
|
||||
'filament:issue',
|
||||
'filament:make-issue',
|
||||
];
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$url = 'https://github.com/filamentphp/filament/issues/new?' . http_build_query([
|
||||
'template' => 'bug_report.yml',
|
||||
'package-version' => InstalledVersions::getPrettyVersion('filament/support'),
|
||||
'laravel-version' => InstalledVersions::getPrettyVersion('laravel/framework'),
|
||||
'livewire-version' => InstalledVersions::getPrettyVersion('livewire/livewire'),
|
||||
'php-version' => PHP_VERSION,
|
||||
]);
|
||||
|
||||
$this->openUrlInBrowser($url);
|
||||
}
|
||||
}
|
||||
43
vendor/filament/support/src/Commands/OptimizeClearCommand.php
vendored
Normal file
43
vendor/filament/support/src/Commands/OptimizeClearCommand.php
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Commands\Concerns\CanCachePanelComponents;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
|
||||
#[AsCommand(name: 'filament:optimize-clear')]
|
||||
class OptimizeClearCommand extends Command
|
||||
{
|
||||
use CanCachePanelComponents;
|
||||
|
||||
protected $description = 'Remove the cached components and Blade icons';
|
||||
|
||||
protected $name = 'filament:optimize-clear';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$this->components->info('Clearing cached components and Blade icons.');
|
||||
|
||||
$tasks = collect();
|
||||
|
||||
if ($this->canCachePanelComponents()) {
|
||||
$tasks->put(
|
||||
'Clearing cached components',
|
||||
fn (): bool => $this->callSilent('filament:clear-cached-components') === static::SUCCESS,
|
||||
);
|
||||
}
|
||||
|
||||
$tasks->put(
|
||||
'Clearing cached Blade icons',
|
||||
fn (): bool => $this->callSilent('icons:clear') === static::SUCCESS,
|
||||
);
|
||||
|
||||
$tasks->each(fn (Closure $task, string $description) => $this->components->task($description, $task));
|
||||
|
||||
$this->newLine();
|
||||
|
||||
return static::SUCCESS;
|
||||
}
|
||||
}
|
||||
40
vendor/filament/support/src/Commands/OptimizeCommand.php
vendored
Normal file
40
vendor/filament/support/src/Commands/OptimizeCommand.php
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Commands\Concerns\CanCachePanelComponents;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
|
||||
#[AsCommand(name: 'filament:optimize')]
|
||||
class OptimizeCommand extends Command
|
||||
{
|
||||
use CanCachePanelComponents;
|
||||
|
||||
protected $description = 'Cache components and Blade icons to increase performance';
|
||||
|
||||
protected $name = 'filament:optimize';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$this->components->info('Caching components and Blade icons.');
|
||||
|
||||
$tasks = collect();
|
||||
|
||||
if ($this->canCachePanelComponents()) {
|
||||
$tasks->put(
|
||||
'Caching components',
|
||||
fn (): bool => $this->callSilent('filament:cache-components') === static::SUCCESS
|
||||
);
|
||||
}
|
||||
|
||||
$tasks->put('Caching Blade icons', fn (): bool => $this->callSilent('icons:cache') === static::SUCCESS);
|
||||
|
||||
$tasks->each(fn (Closure $task, string $description) => $this->components->task($description, $task));
|
||||
|
||||
$this->newLine();
|
||||
|
||||
return static::SUCCESS;
|
||||
}
|
||||
}
|
||||
33
vendor/filament/support/src/Commands/UpgradeCommand.php
vendored
Normal file
33
vendor/filament/support/src/Commands/UpgradeCommand.php
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Commands;
|
||||
|
||||
use Filament\Support\Events\FilamentUpgraded;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
|
||||
#[AsCommand(name: 'filament:upgrade')]
|
||||
class UpgradeCommand extends Command
|
||||
{
|
||||
protected $description = 'Upgrade Filament to the latest version';
|
||||
|
||||
protected $name = 'filament:upgrade';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
foreach ([
|
||||
AssetsCommand::class,
|
||||
'config:clear',
|
||||
'route:clear',
|
||||
'view:clear',
|
||||
] as $command) {
|
||||
$this->call($command);
|
||||
}
|
||||
|
||||
FilamentUpgraded::dispatch();
|
||||
|
||||
$this->components->info('Successfully upgraded!');
|
||||
|
||||
return static::SUCCESS;
|
||||
}
|
||||
}
|
||||
8
vendor/filament/support/src/Components/Attributes/ExposedLivewireMethod.php
vendored
Normal file
8
vendor/filament/support/src/Components/Attributes/ExposedLivewireMethod.php
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Components\Attributes;
|
||||
|
||||
use Attribute;
|
||||
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class ExposedLivewireMethod {}
|
||||
18
vendor/filament/support/src/Components/Component.php
vendored
Normal file
18
vendor/filament/support/src/Components/Component.php
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Components;
|
||||
|
||||
use Filament\Support\Concerns\Configurable;
|
||||
use Filament\Support\Concerns\EvaluatesClosures;
|
||||
use Filament\Support\Concerns\Macroable;
|
||||
use Illuminate\Support\Traits\Conditionable;
|
||||
use Illuminate\Support\Traits\Tappable;
|
||||
|
||||
abstract class Component
|
||||
{
|
||||
use Conditionable;
|
||||
use Configurable;
|
||||
use EvaluatesClosures;
|
||||
use Macroable;
|
||||
use Tappable;
|
||||
}
|
||||
176
vendor/filament/support/src/Components/ComponentManager.php
vendored
Normal file
176
vendor/filament/support/src/Components/ComponentManager.php
vendored
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Components;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Components\Contracts\ScopedComponentManager;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use ReflectionNamedType;
|
||||
|
||||
class ComponentManager implements ScopedComponentManager
|
||||
{
|
||||
/**
|
||||
* @var array<class-string, array<Closure>>
|
||||
*/
|
||||
protected array $configurations = [];
|
||||
|
||||
/**
|
||||
* @var array<class-string, array<Closure>>
|
||||
*/
|
||||
protected array $importantConfigurations = [];
|
||||
|
||||
/**
|
||||
* @var array<string, array<string>>
|
||||
*/
|
||||
protected array $methodCache = [];
|
||||
|
||||
/**
|
||||
* @var array<class-string, array<class-string>>
|
||||
*/
|
||||
protected array $configureClassHierarchyCache = [];
|
||||
|
||||
/**
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected array $setUpMethodClassCache = [];
|
||||
|
||||
final public function __construct() {}
|
||||
|
||||
public static function resolve(): ScopedComponentManager
|
||||
{
|
||||
if (app()->resolved(ScopedComponentManager::class)) {
|
||||
return static::resolveScoped();
|
||||
}
|
||||
|
||||
app()->singletonIf(
|
||||
ComponentManager::class,
|
||||
fn () => new ComponentManager,
|
||||
);
|
||||
|
||||
return app(ComponentManager::class);
|
||||
}
|
||||
|
||||
public static function resolveScoped(): ScopedComponentManager
|
||||
{
|
||||
return app(ScopedComponentManager::class);
|
||||
}
|
||||
|
||||
public function clone(): static
|
||||
{
|
||||
return clone $this;
|
||||
}
|
||||
|
||||
public function configureUsing(string $component, Closure $modifyUsing, ?Closure $during = null, bool $isImportant = false): mixed
|
||||
{
|
||||
if ($isImportant) {
|
||||
$this->importantConfigurations[$component] ??= [];
|
||||
$this->importantConfigurations[$component][] = $modifyUsing;
|
||||
} else {
|
||||
$this->configurations[$component] ??= [];
|
||||
$this->configurations[$component][] = $modifyUsing;
|
||||
}
|
||||
|
||||
if (! $during) {
|
||||
$configurationKey = $isImportant ?
|
||||
array_key_last($this->importantConfigurations[$component]) :
|
||||
array_key_last($this->configurations[$component]);
|
||||
|
||||
return function () use ($component, $configurationKey, $isImportant): void {
|
||||
if ($isImportant) {
|
||||
unset($this->importantConfigurations[$component][$configurationKey]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unset($this->configurations[$component][$configurationKey]);
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
return $during();
|
||||
} finally {
|
||||
if ($isImportant) {
|
||||
array_pop($this->importantConfigurations[$component]);
|
||||
} else {
|
||||
array_pop($this->configurations[$component]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function configure(Component $component, Closure $setUp): void
|
||||
{
|
||||
$componentClass = $component::class;
|
||||
|
||||
$classesToConfigure = $this->configureClassHierarchyCache[$componentClass]
|
||||
??= [...array_reverse(class_parents($component)), $componentClass];
|
||||
|
||||
$setUpMethodClass = $this->setUpMethodClassCache[$componentClass]
|
||||
??= (new ReflectionMethod($component, 'setUp'))->getDeclaringClass()->getName();
|
||||
|
||||
foreach ($classesToConfigure as $classToConfigure) {
|
||||
if ($classToConfigure === $setUpMethodClass) {
|
||||
$setUp();
|
||||
}
|
||||
|
||||
if (array_key_exists($classToConfigure, $this->configurations)) {
|
||||
foreach ($this->configurations[$classToConfigure] as $configure) {
|
||||
$configure($component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($classesToConfigure as $classToConfigure) {
|
||||
if (array_key_exists($classToConfigure, $this->importantConfigurations)) {
|
||||
foreach ($this->importantConfigurations[$classToConfigure] as $configure) {
|
||||
$configure($component);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, Closure>
|
||||
*/
|
||||
public function extractPublicMethods(Component $component): array
|
||||
{
|
||||
if (! isset($this->methodCache[$component::class])) {
|
||||
$reflection = new ReflectionClass($component);
|
||||
|
||||
$this->methodCache[$component::class] = [];
|
||||
|
||||
// The `static`-return filter only applies to first-party Filament
|
||||
// classes, since their fluent setters are never called from any
|
||||
// Blade view we ship. Third-party subclasses might legitimately
|
||||
// call their own setters from a published view, so we leave their
|
||||
// method lists untouched.
|
||||
$shouldSkipFluentSetters = str_starts_with($component::class, 'Filament\\');
|
||||
|
||||
foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
|
||||
$name = $method->getName();
|
||||
|
||||
if (str_starts_with($name, '__')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($shouldSkipFluentSetters) {
|
||||
$returnType = $method->getReturnType();
|
||||
|
||||
if ($returnType instanceof ReflectionNamedType && $returnType->getName() === 'static') {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->methodCache[$component::class][] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ($this->methodCache[$component::class] as $method) {
|
||||
$values[$method] = $component->$method(...);
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
8
vendor/filament/support/src/Components/Contracts/HasEmbeddedView.php
vendored
Normal file
8
vendor/filament/support/src/Components/Contracts/HasEmbeddedView.php
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Components\Contracts;
|
||||
|
||||
interface HasEmbeddedView
|
||||
{
|
||||
public function toEmbeddedHtml(): string;
|
||||
}
|
||||
18
vendor/filament/support/src/Components/Contracts/ScopedComponentManager.php
vendored
Normal file
18
vendor/filament/support/src/Components/Contracts/ScopedComponentManager.php
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Components\Contracts;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Components\Component;
|
||||
|
||||
interface ScopedComponentManager
|
||||
{
|
||||
public function configureUsing(string $component, Closure $modifyUsing, ?Closure $during = null, bool $isImportant = false): mixed;
|
||||
|
||||
public function configure(Component $component, Closure $setUp): void;
|
||||
|
||||
/**
|
||||
* @return array<string, Closure>
|
||||
*/
|
||||
public function extractPublicMethods(Component $component): array;
|
||||
}
|
||||
234
vendor/filament/support/src/Components/ViewComponent.php
vendored
Normal file
234
vendor/filament/support/src/Components/ViewComponent.php
vendored
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Components;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Components\Contracts\HasEmbeddedView;
|
||||
use Filament\Support\View\ComponentAttributeBag as FilamentComponentAttributeBag;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\View\FileViewFinder;
|
||||
use LogicException;
|
||||
|
||||
abstract class ViewComponent extends Component implements Htmlable
|
||||
{
|
||||
protected string $view;
|
||||
|
||||
/**
|
||||
* @var view-string | Closure | null
|
||||
*/
|
||||
protected string | Closure | null $defaultView = null;
|
||||
|
||||
/**
|
||||
* @var array<array<string, mixed> | Closure>
|
||||
*/
|
||||
protected array $viewData = [];
|
||||
|
||||
protected string $viewIdentifier;
|
||||
|
||||
/**
|
||||
* @var array<view-string, View>
|
||||
*/
|
||||
protected array $viewInstances = [];
|
||||
|
||||
protected ?string $publishedViewOverrideCheckPath = null;
|
||||
|
||||
/**
|
||||
* @var array<string, bool>
|
||||
*/
|
||||
private static array $hasPublishedEmbeddedViewOverrideCache = [];
|
||||
|
||||
/**
|
||||
* @param view-string | null $view
|
||||
* @param array<string, mixed> | Closure $viewData
|
||||
*/
|
||||
public function view(?string $view, array | Closure $viewData = []): static
|
||||
{
|
||||
if ($view === null) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->view = $view;
|
||||
|
||||
if (filled($viewData)) {
|
||||
$this->viewData($viewData);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param view-string | Closure | null $view
|
||||
*/
|
||||
public function defaultView(string | Closure | null $view): static
|
||||
{
|
||||
$this->defaultView = $view;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, Closure>
|
||||
*/
|
||||
protected function extractPublicMethods(): array
|
||||
{
|
||||
return ComponentManager::resolve()->extractPublicMethods($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> | Closure $data
|
||||
*/
|
||||
public function viewData(array | Closure $data): static
|
||||
{
|
||||
$this->viewData[] = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return view-string
|
||||
*/
|
||||
public function getView(): string
|
||||
{
|
||||
if (isset($this->view)) {
|
||||
return $this->view;
|
||||
}
|
||||
|
||||
if (filled($defaultView = $this->getDefaultView())) {
|
||||
return $defaultView;
|
||||
}
|
||||
|
||||
throw new LogicException('Class [' . static::class . '] extends [' . ViewComponent::class . '] but does not have a [$view] property defined.');
|
||||
}
|
||||
|
||||
public function hasView(): bool
|
||||
{
|
||||
return isset($this->view) || $this->getDefaultView();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return view-string | null
|
||||
*/
|
||||
public function getDefaultView(): ?string
|
||||
{
|
||||
return $this->evaluate($this->defaultView);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getViewData(): array
|
||||
{
|
||||
return Arr::mapWithKeys(
|
||||
$this->viewData,
|
||||
fn (mixed $data): array => $this->evaluate($data) ?? [],
|
||||
);
|
||||
}
|
||||
|
||||
public function toHtml(): string
|
||||
{
|
||||
if ((! ($this instanceof HasEmbeddedView)) || $this->hasView()) {
|
||||
return $this->render()->render();
|
||||
}
|
||||
|
||||
$publishedViewOverrideCheckPath = $this->getPublishedViewOverrideCheckPath();
|
||||
|
||||
if (filled($publishedViewOverrideCheckPath) && static::hasPublishedEmbeddedViewOverride($publishedViewOverrideCheckPath)) {
|
||||
static::registerPublishedEmbeddedViewOverrideNamespace($publishedViewOverrideCheckPath);
|
||||
|
||||
return $this->renderView($publishedViewOverrideCheckPath)->render();
|
||||
}
|
||||
|
||||
return $this->toEmbeddedHtml();
|
||||
}
|
||||
|
||||
public function getPublishedViewOverrideCheckPath(): ?string
|
||||
{
|
||||
return $this->publishedViewOverrideCheckPath;
|
||||
}
|
||||
|
||||
public static function hasPublishedEmbeddedViewOverride(string $view): bool
|
||||
{
|
||||
return self::$hasPublishedEmbeddedViewOverrideCache[$view] ??= self::checkForPublishedEmbeddedViewOverride($view);
|
||||
}
|
||||
|
||||
protected static function checkForPublishedEmbeddedViewOverride(string $view): bool
|
||||
{
|
||||
if (! str_contains($view, '::')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
[$namespace, $name] = explode('::', $view, 2);
|
||||
|
||||
return file_exists(resource_path('views/vendor/' . $namespace . '/' . str_replace('.', '/', $name) . '.blade.php'));
|
||||
}
|
||||
|
||||
protected static function registerPublishedEmbeddedViewOverrideNamespace(string $view): void
|
||||
{
|
||||
if (! str_contains($view, '::')) {
|
||||
return;
|
||||
}
|
||||
|
||||
[$namespace] = explode('::', $view, 2);
|
||||
|
||||
$factory = app('view');
|
||||
|
||||
$overridePath = resource_path('views/vendor/' . $namespace);
|
||||
|
||||
// Laravel only registers the published override path as a namespace hint if the
|
||||
// directory already exists when the `view` factory is first resolved. Livewire 4
|
||||
// resolves the factory early during boot, so an override published afterwards is
|
||||
// never picked up. Registering the location here keeps overrides working regardless
|
||||
// of when the `view` factory was resolved.
|
||||
$finder = $factory->getFinder();
|
||||
|
||||
if ($finder instanceof FileViewFinder && in_array($overridePath, $finder->getHints()[$namespace] ?? [], true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$factory->prependNamespace($namespace, $overridePath);
|
||||
}
|
||||
|
||||
public function toHtmlString(): ?HtmlString
|
||||
{
|
||||
$html = $this->toHtml();
|
||||
|
||||
if (blank($html)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new HtmlString($html);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getExtraViewData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return $this->renderView($this->getView());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param view-string $view
|
||||
*/
|
||||
protected function renderView(string $view): View
|
||||
{
|
||||
$this->viewInstances[$view] ??= view($view, [
|
||||
...$this->extractPublicMethods(),
|
||||
...(isset($this->viewIdentifier) ? [$this->viewIdentifier => $this] : []),
|
||||
]);
|
||||
|
||||
return $this->viewInstances[$view]->with([
|
||||
'attributes' => new FilamentComponentAttributeBag,
|
||||
...$this->getExtraViewData(),
|
||||
...$this->getViewData(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
179
vendor/filament/support/src/Concerns/CanAggregateRelatedModels.php
vendored
Normal file
179
vendor/filament/support/src/Concerns/CanAggregateRelatedModels.php
vendored
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Database\Query\Expression;
|
||||
|
||||
trait CanAggregateRelatedModels
|
||||
{
|
||||
protected string | Expression | Closure | null $columnToAvg = null;
|
||||
|
||||
/**
|
||||
* @var string | array<int | string, string | Closure> | Closure | null
|
||||
*/
|
||||
protected string | array | Closure | null $relationshipToAvg = null;
|
||||
|
||||
/**
|
||||
* @var string | array<int | string, string | Closure> | Closure | null
|
||||
*/
|
||||
protected string | array | Closure | null $relationshipsToCount = null;
|
||||
|
||||
/**
|
||||
* @var string | array<int | string, string | Closure> | Closure | null
|
||||
*/
|
||||
protected string | array | Closure | null $relationshipsToExistenceCheck = null;
|
||||
|
||||
protected string | Expression | Closure | null $columnToMax = null;
|
||||
|
||||
/**
|
||||
* @var string | array<int | string, string | Closure> | Closure | null
|
||||
*/
|
||||
protected string | array | Closure | null $relationshipToMax = null;
|
||||
|
||||
protected string | Expression | Closure | null $columnToMin = null;
|
||||
|
||||
/**
|
||||
* @var string | array<int | string, string | Closure> | Closure | null
|
||||
*/
|
||||
protected string | array | Closure | null $relationshipToMin = null;
|
||||
|
||||
protected string | Expression | Closure | null $columnToSum = null;
|
||||
|
||||
/**
|
||||
* @var string | array<int | string, string | Closure> | Closure | null
|
||||
*/
|
||||
protected string | array | Closure | null $relationshipToSum = null;
|
||||
|
||||
/**
|
||||
* @param string | array<int | string, string | Closure> | Closure | null $relationship
|
||||
*/
|
||||
public function avg(string | array | Closure | null $relationship, string | Expression | Closure | null $column): static
|
||||
{
|
||||
$this->columnToAvg = $column;
|
||||
$this->relationshipToAvg = $relationship;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string | array<int | string, string | Closure> | Closure | null $relationships
|
||||
*/
|
||||
public function counts(string | array | Closure | null $relationships): static
|
||||
{
|
||||
$this->relationshipsToCount = $relationships;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string | array<int | string, string | Closure> | Closure | null $relationships
|
||||
*/
|
||||
public function exists(string | array | Closure | null $relationships): static
|
||||
{
|
||||
$this->relationshipsToExistenceCheck = $relationships;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string | array<int | string, string | Closure> | Closure | null $relationship
|
||||
*/
|
||||
public function max(string | array | Closure | null $relationship, string | Expression | Closure | null $column): static
|
||||
{
|
||||
$this->columnToMax = $column;
|
||||
$this->relationshipToMax = $relationship;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string | array<int | string, string | Closure> | Closure | null $relationship
|
||||
*/
|
||||
public function min(string | array | Closure | null $relationship, string | Expression | Closure | null $column): static
|
||||
{
|
||||
$this->columnToMin = $column;
|
||||
$this->relationshipToMin = $relationship;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string | array<int | string, string | Closure> | Closure | null $relationship
|
||||
*/
|
||||
public function sum(string | array | Closure | null $relationship, string | Expression | Closure | null $column): static
|
||||
{
|
||||
$this->columnToSum = $column;
|
||||
$this->relationshipToSum = $relationship;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getColumnToAvg(): string | Expression | null
|
||||
{
|
||||
return $this->evaluate($this->columnToAvg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string | array<int | string, string | Closure> | null
|
||||
*/
|
||||
public function getRelationshipToAvg(): string | array | null
|
||||
{
|
||||
return $this->evaluate($this->relationshipToAvg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string | array<int | string, string | Closure> | null
|
||||
*/
|
||||
public function getRelationshipsToCount(): string | array | null
|
||||
{
|
||||
return $this->evaluate($this->relationshipsToCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string | array<int | string, string | Closure> | null
|
||||
*/
|
||||
public function getRelationshipsToExistenceCheck(): string | array | null
|
||||
{
|
||||
return $this->evaluate($this->relationshipsToExistenceCheck);
|
||||
}
|
||||
|
||||
public function getColumnToMax(): string | Expression | null
|
||||
{
|
||||
return $this->evaluate($this->columnToMax);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string | array<int | string, string | Closure> | null
|
||||
*/
|
||||
public function getRelationshipToMax(): string | array | null
|
||||
{
|
||||
return $this->evaluate($this->relationshipToMax);
|
||||
}
|
||||
|
||||
public function getColumnToMin(): string | Expression | null
|
||||
{
|
||||
return $this->evaluate($this->columnToMin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string | array<int | string, string | Closure> | null
|
||||
*/
|
||||
public function getRelationshipToMin(): string | array | null
|
||||
{
|
||||
return $this->evaluate($this->relationshipToMin);
|
||||
}
|
||||
|
||||
public function getColumnToSum(): string | Expression | null
|
||||
{
|
||||
return $this->evaluate($this->columnToSum);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string | array<int | string, string | Closure> | null
|
||||
*/
|
||||
public function getRelationshipToSum(): string | array | null
|
||||
{
|
||||
return $this->evaluate($this->relationshipToSum);
|
||||
}
|
||||
}
|
||||
24
vendor/filament/support/src/Concerns/CanBeContained.php
vendored
Normal file
24
vendor/filament/support/src/Concerns/CanBeContained.php
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait CanBeContained
|
||||
{
|
||||
protected bool | Closure $isContained = true;
|
||||
|
||||
protected bool $isContainedCache;
|
||||
|
||||
public function contained(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->isContained = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isContained(): bool
|
||||
{
|
||||
return $this->isContainedCache ??= (bool) $this->evaluate($this->isContained);
|
||||
}
|
||||
}
|
||||
77
vendor/filament/support/src/Concerns/CanBeCopied.php
vendored
Normal file
77
vendor/filament/support/src/Concerns/CanBeCopied.php
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait CanBeCopied
|
||||
{
|
||||
protected bool | Closure $isCopyable = false;
|
||||
|
||||
protected string | Closure | null $copyableState = null;
|
||||
|
||||
protected string | Closure | null $copyMessage = null;
|
||||
|
||||
protected int | Closure | null $copyMessageDuration = null;
|
||||
|
||||
public function copyable(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->isCopyable = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function copyableState(string | Closure | null $state): static
|
||||
{
|
||||
$this->copyableState = $state;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function copyMessage(string | Closure | null $message): static
|
||||
{
|
||||
$this->copyMessage = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function copyMessageDuration(int | Closure | null $duration): static
|
||||
{
|
||||
$this->copyMessageDuration = $duration;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isCopyable(mixed $state): bool
|
||||
{
|
||||
return (bool) $this->evaluate($this->isCopyable, [
|
||||
'state' => $state,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getCopyableState(mixed $state): ?string
|
||||
{
|
||||
return $this->evaluate($this->copyableState, [
|
||||
'state' => $state,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getCopyMessage(mixed $state): string
|
||||
{
|
||||
return $this->evaluate($this->copyMessage, [
|
||||
'state' => $state,
|
||||
]) ?? __('filament::components/copyable.messages.copied');
|
||||
}
|
||||
|
||||
public function getCopyMessageDuration(mixed $state): int
|
||||
{
|
||||
return $this->evaluate($this->copyMessageDuration, [
|
||||
'state' => $state,
|
||||
]) ?? 2000;
|
||||
}
|
||||
|
||||
public function hasCopyable(): bool
|
||||
{
|
||||
return $this->isCopyable !== false;
|
||||
}
|
||||
}
|
||||
43
vendor/filament/support/src/Concerns/CanBeLazy.php
vendored
Normal file
43
vendor/filament/support/src/Concerns/CanBeLazy.php
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
trait CanBeLazy
|
||||
{
|
||||
protected static bool $isLazy = true;
|
||||
|
||||
protected ?string $placeholderHeight = null;
|
||||
|
||||
public static function isLazy(): bool
|
||||
{
|
||||
return static::$isLazy;
|
||||
}
|
||||
|
||||
public function placeholder(): View
|
||||
{
|
||||
return view(
|
||||
'filament::components.loading-section',
|
||||
[
|
||||
'height' => $this->getPlaceholderHeight(),
|
||||
...$this->getPlaceholderData(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getPlaceholderData(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public function getPlaceholderHeight(): ?string
|
||||
{
|
||||
return $this->placeholderHeight;
|
||||
}
|
||||
}
|
||||
25
vendor/filament/support/src/Concerns/CanCallHooks.php
vendored
Normal file
25
vendor/filament/support/src/Concerns/CanCallHooks.php
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
trait CanCallHooks
|
||||
{
|
||||
protected function callHook(string $hook): void
|
||||
{
|
||||
if (method_exists($this, $hook)) {
|
||||
$this->{$hook}();
|
||||
}
|
||||
|
||||
$calledTraitHooks = [];
|
||||
|
||||
foreach (class_uses_recursive($this) as $trait) {
|
||||
$method = $hook . class_basename($trait);
|
||||
|
||||
if (method_exists($this, $method) && (! in_array($method, $calledTraitHooks, strict: true))) {
|
||||
$this->{$method}();
|
||||
|
||||
$calledTraitHooks[] = $method;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
55
vendor/filament/support/src/Concerns/CanConfigureCommonMark.php
vendored
Normal file
55
vendor/filament/support/src/Concerns/CanConfigureCommonMark.php
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use League\CommonMark\Extension\ExtensionInterface;
|
||||
|
||||
trait CanConfigureCommonMark
|
||||
{
|
||||
/**
|
||||
* @var array<string, mixed> | Closure | null
|
||||
*/
|
||||
protected array | Closure | null $commonMarkOptions = null;
|
||||
|
||||
/**
|
||||
* @var array<array-key, ExtensionInterface> | Closure | null
|
||||
*/
|
||||
protected array | Closure | null $commonMarkExtensions = null;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> | Closure | null $commonMarkOptions
|
||||
*/
|
||||
public function commonMarkOptions(array | Closure | null $commonMarkOptions): static
|
||||
{
|
||||
$this->commonMarkOptions = $commonMarkOptions;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getCommonMarkOptions(): array
|
||||
{
|
||||
return $this->evaluate($this->commonMarkOptions) ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<array-key, ExtensionInterface> | Closure | null $commonMarkExtensions
|
||||
*/
|
||||
public function commonMarkExtensions(array | Closure | null $commonMarkExtensions): static
|
||||
{
|
||||
$this->commonMarkExtensions = $commonMarkExtensions;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array-key, ExtensionInterface>
|
||||
*/
|
||||
public function getCommonMarkExtensions(): array
|
||||
{
|
||||
return $this->evaluate($this->commonMarkExtensions) ?? [];
|
||||
}
|
||||
}
|
||||
22
vendor/filament/support/src/Concerns/CanGrow.php
vendored
Normal file
22
vendor/filament/support/src/Concerns/CanGrow.php
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait CanGrow
|
||||
{
|
||||
protected bool | Closure | null $canGrow = null;
|
||||
|
||||
public function grow(bool | Closure | null $condition = true): static
|
||||
{
|
||||
$this->canGrow = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function canGrow(bool $default = true): bool
|
||||
{
|
||||
return (bool) ($this->evaluate($this->canGrow) ?? $default);
|
||||
}
|
||||
}
|
||||
90
vendor/filament/support/src/Concerns/CanOrderColumns.php
vendored
Normal file
90
vendor/filament/support/src/Concerns/CanOrderColumns.php
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait CanOrderColumns
|
||||
{
|
||||
/**
|
||||
* @var array<string | int, int | Closure | null> | null
|
||||
*/
|
||||
protected ?array $columnOrder = null;
|
||||
|
||||
/**
|
||||
* @param array<string, int | Closure | null> | int | Closure | null $order
|
||||
*/
|
||||
public function columnOrder(array | int | Closure | null $order): static
|
||||
{
|
||||
if ($order instanceof Closure) {
|
||||
$this->columnOrder[] = $order;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (! is_array($order)) {
|
||||
$order = [
|
||||
'lg' => $order,
|
||||
];
|
||||
}
|
||||
|
||||
$this->columnOrder = [
|
||||
...($this->columnOrder ?? []),
|
||||
...$order,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, ?int> | int | null
|
||||
*/
|
||||
public function getColumnOrder(int | string | null $breakpoint = null): array | int | null
|
||||
{
|
||||
$order = $this->columnOrder ?? [
|
||||
'default' => null,
|
||||
'sm' => null,
|
||||
'md' => null,
|
||||
'lg' => null,
|
||||
'xl' => null,
|
||||
'2xl' => null,
|
||||
];
|
||||
|
||||
foreach ($this->columnOrder ?? [] as $columnOrderBreakpoint => $columnOrder) {
|
||||
$columnOrder = $this->evaluate($columnOrder);
|
||||
|
||||
if (is_array($columnOrder)) {
|
||||
$order = [
|
||||
...$order,
|
||||
...$columnOrder,
|
||||
];
|
||||
|
||||
unset($order[$columnOrderBreakpoint]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blank($columnOrderBreakpoint)) {
|
||||
unset($order[$columnOrderBreakpoint]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_string($columnOrderBreakpoint)) {
|
||||
$order['default'] = $columnOrder;
|
||||
|
||||
unset($order[$columnOrderBreakpoint]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$order[$columnOrderBreakpoint] = $columnOrder;
|
||||
}
|
||||
|
||||
if ($breakpoint !== null) {
|
||||
return $this->evaluate($order[$breakpoint] ?? null);
|
||||
}
|
||||
|
||||
return $order;
|
||||
}
|
||||
}
|
||||
180
vendor/filament/support/src/Concerns/CanSpanColumns.php
vendored
Normal file
180
vendor/filament/support/src/Concerns/CanSpanColumns.php
vendored
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait CanSpanColumns
|
||||
{
|
||||
/**
|
||||
* @var array<string | int, int | string | Closure | null> | null
|
||||
*/
|
||||
protected ?array $columnSpan = null;
|
||||
|
||||
/**
|
||||
* @var array<string | int, int | string | Closure | null> | null
|
||||
*/
|
||||
protected ?array $columnStart = null;
|
||||
|
||||
/**
|
||||
* @param array<string, int | string | Closure | null> | int | string | Closure | null $span
|
||||
*/
|
||||
public function columnSpan(array | int | string | Closure | null $span): static
|
||||
{
|
||||
if ($span instanceof Closure) {
|
||||
$this->columnSpan[] = $span;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (! is_array($span)) {
|
||||
$span = [
|
||||
'default' => 1,
|
||||
'lg' => $span,
|
||||
];
|
||||
}
|
||||
|
||||
$this->columnSpan = [
|
||||
...($this->columnSpan ?? []),
|
||||
...$span,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function columnSpanFull(): static
|
||||
{
|
||||
$this->columnSpan(['default' => 'full']);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, int | string | Closure | null> | int | string | Closure | null $start
|
||||
*/
|
||||
public function columnStart(array | int | string | Closure | null $start): static
|
||||
{
|
||||
if ($start instanceof Closure) {
|
||||
$this->columnStart[] = $start;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (! is_array($start)) {
|
||||
$start = [
|
||||
'lg' => $start,
|
||||
];
|
||||
}
|
||||
|
||||
$this->columnStart = [
|
||||
...($this->columnStart ?? []),
|
||||
...$start,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, int | string | null> | int | string | null
|
||||
*/
|
||||
public function getColumnSpan(int | string | null $breakpoint = null): array | int | string | null
|
||||
{
|
||||
$span = $this->columnSpan ?? [
|
||||
'default' => 1,
|
||||
'sm' => null,
|
||||
'md' => null,
|
||||
'lg' => null,
|
||||
'xl' => null,
|
||||
'2xl' => null,
|
||||
];
|
||||
|
||||
foreach ($this->columnSpan ?? [] as $columnSpanBreakpoint => $columnSpan) {
|
||||
$columnSpan = $this->evaluate($columnSpan);
|
||||
|
||||
if (is_array($columnSpan)) {
|
||||
$span = [
|
||||
...$span,
|
||||
...$columnSpan,
|
||||
];
|
||||
|
||||
unset($span[$columnSpanBreakpoint]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blank($columnSpanBreakpoint)) {
|
||||
unset($span[$columnSpanBreakpoint]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_string($columnSpanBreakpoint)) {
|
||||
$span['default'] = $columnSpan;
|
||||
|
||||
unset($span[$columnSpanBreakpoint]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$span[$columnSpanBreakpoint] = $columnSpan;
|
||||
}
|
||||
|
||||
if ($breakpoint !== null) {
|
||||
return $this->evaluate($span[$breakpoint] ?? null);
|
||||
}
|
||||
|
||||
return $span;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, int | string | null> | int | string | null
|
||||
*/
|
||||
public function getColumnStart(int | string | null $breakpoint = null): array | int | string | null
|
||||
{
|
||||
$start = $this->columnStart ?? [
|
||||
'default' => null,
|
||||
'sm' => null,
|
||||
'md' => null,
|
||||
'lg' => null,
|
||||
'xl' => null,
|
||||
'2xl' => null,
|
||||
];
|
||||
|
||||
foreach ($this->columnStart ?? [] as $columnStartBreakpoint => $columnStart) {
|
||||
$columnStart = $this->evaluate($columnStart);
|
||||
|
||||
if (is_array($columnStart)) {
|
||||
$start = [
|
||||
...$start,
|
||||
...$columnStart,
|
||||
];
|
||||
|
||||
unset($start[$columnStartBreakpoint]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blank($columnStartBreakpoint)) {
|
||||
unset($start[$columnStartBreakpoint]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_string($columnStartBreakpoint)) {
|
||||
$start['default'] = $columnStart;
|
||||
|
||||
unset($start[$columnStartBreakpoint]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$start[$columnStartBreakpoint] = $columnStart;
|
||||
}
|
||||
|
||||
if ($breakpoint !== null) {
|
||||
return $this->evaluate($start[$breakpoint] ?? null);
|
||||
}
|
||||
|
||||
return $start;
|
||||
}
|
||||
}
|
||||
32
vendor/filament/support/src/Concerns/CanWrap.php
vendored
Normal file
32
vendor/filament/support/src/Concerns/CanWrap.php
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait CanWrap
|
||||
{
|
||||
protected bool | Closure | null $canWrap = null;
|
||||
|
||||
public function wrap(bool | Closure | null $condition = true): static
|
||||
{
|
||||
$this->canWrap = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function canWrap(): bool
|
||||
{
|
||||
return (bool) ($this->evaluate($this->canWrap) ?? $this->canWrapByDefault());
|
||||
}
|
||||
|
||||
public function canWrapByDefault(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function hasWrap(): bool
|
||||
{
|
||||
return $this->canWrap !== null || $this->canWrapByDefault();
|
||||
}
|
||||
}
|
||||
22
vendor/filament/support/src/Concerns/CanWrapHeader.php
vendored
Normal file
22
vendor/filament/support/src/Concerns/CanWrapHeader.php
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait CanWrapHeader
|
||||
{
|
||||
protected bool | Closure $canHeaderWrap = false;
|
||||
|
||||
public function wrapHeader(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->canHeaderWrap = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function canHeaderWrap(): bool
|
||||
{
|
||||
return (bool) $this->evaluate($this->canHeaderWrap);
|
||||
}
|
||||
}
|
||||
31
vendor/filament/support/src/Concerns/Configurable.php
vendored
Normal file
31
vendor/filament/support/src/Concerns/Configurable.php
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Components\ComponentManager;
|
||||
|
||||
trait Configurable
|
||||
{
|
||||
public static function configureUsing(Closure $modifyUsing, ?Closure $during = null, bool $isImportant = false): mixed
|
||||
{
|
||||
return ComponentManager::resolve()->configureUsing(
|
||||
static::class,
|
||||
$modifyUsing,
|
||||
$during,
|
||||
$isImportant,
|
||||
);
|
||||
}
|
||||
|
||||
public function configure(): static
|
||||
{
|
||||
ComponentManager::resolve()->configure(
|
||||
$this,
|
||||
$this->setUp(...),
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function setUp(): void {}
|
||||
}
|
||||
166
vendor/filament/support/src/Concerns/EvaluatesClosures.php
vendored
Normal file
166
vendor/filament/support/src/Concerns/EvaluatesClosures.php
vendored
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use ReflectionFunction;
|
||||
use ReflectionNamedType;
|
||||
use ReflectionParameter;
|
||||
|
||||
trait EvaluatesClosures
|
||||
{
|
||||
protected string $evaluationIdentifier;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @param T | callable(): T $value
|
||||
* @param array<string, mixed> $namedInjections
|
||||
* @param array<string, mixed> $typedInjections
|
||||
* @return T
|
||||
*/
|
||||
public function evaluate(mixed $value, array $namedInjections = [], array $typedInjections = []): mixed
|
||||
{
|
||||
if (! $value instanceof Closure) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$dependencies = [];
|
||||
|
||||
foreach ((new ReflectionFunction($value))->getParameters() as $parameter) {
|
||||
$dependencies[] = $this->resolveClosureDependencyForEvaluation($parameter, $namedInjections, $typedInjections);
|
||||
}
|
||||
|
||||
return $value(...$dependencies);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $namedInjections
|
||||
* @param array<string, mixed> $typedInjections
|
||||
*/
|
||||
protected function resolveClosureDependencyForEvaluation(ReflectionParameter $parameter, array $namedInjections, array $typedInjections): mixed
|
||||
{
|
||||
$parameterName = $parameter->getName();
|
||||
|
||||
if (array_key_exists($parameterName, $namedInjections)) {
|
||||
return value($namedInjections[$parameterName]);
|
||||
}
|
||||
|
||||
$typedParameterClassName = $this->getTypedReflectionParameterClassName($parameter);
|
||||
|
||||
if (filled($typedParameterClassName) && array_key_exists($typedParameterClassName, $typedInjections)) {
|
||||
return value($typedInjections[$typedParameterClassName]);
|
||||
}
|
||||
|
||||
// Dependencies are wrapped in an array to differentiate between null and no value.
|
||||
$defaultWrappedDependencyByName = $this->resolveDefaultClosureDependencyForEvaluationByName($parameterName);
|
||||
|
||||
if (count($defaultWrappedDependencyByName)) {
|
||||
// Unwrap the dependency if it was resolved.
|
||||
return $defaultWrappedDependencyByName[0];
|
||||
}
|
||||
|
||||
if (filled($typedParameterClassName)) {
|
||||
// Dependencies are wrapped in an array to differentiate between null and no value.
|
||||
$defaultWrappedDependencyByType = $this->resolveDefaultClosureDependencyForEvaluationByType($typedParameterClassName);
|
||||
|
||||
if (count($defaultWrappedDependencyByType)) {
|
||||
// Unwrap the dependency if it was resolved.
|
||||
return $defaultWrappedDependencyByType[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
(
|
||||
isset($this->evaluationIdentifier) &&
|
||||
($parameterName === $this->evaluationIdentifier)
|
||||
) ||
|
||||
(is_string($typedParameterClassName) && is_a($this, $typedParameterClassName))
|
||||
) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (
|
||||
filled($typedParameterClassName)
|
||||
&& (! is_subclass_of($typedParameterClassName, Model::class) || app()->bound($typedParameterClassName))
|
||||
) {
|
||||
return app()->make($typedParameterClassName);
|
||||
}
|
||||
|
||||
if ($parameter->isDefaultValueAvailable()) {
|
||||
return $parameter->getDefaultValue();
|
||||
}
|
||||
|
||||
if ($parameter->isOptional() || $parameter->allowsNull()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$staticClass = static::class;
|
||||
|
||||
throw new BindingResolutionException("An attempt was made to evaluate a closure for [{$staticClass}], but [\${$parameterName}] was unresolvable.");
|
||||
}
|
||||
|
||||
protected function evaluationValueIsFunctionAndHasParameter(mixed $value, string $parameterName): bool
|
||||
{
|
||||
if (! $value instanceof Closure) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ((new ReflectionFunction($value))->getParameters() as $parameter) {
|
||||
if ($parameter->getName() === $parameterName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<mixed>
|
||||
*/
|
||||
protected function resolveDefaultClosureDependencyForEvaluationByName(string $parameterName): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<mixed>
|
||||
*/
|
||||
protected function resolveDefaultClosureDependencyForEvaluationByType(string $parameterType): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function getTypedReflectionParameterClassName(ReflectionParameter $parameter): ?string
|
||||
{
|
||||
$type = $parameter->getType();
|
||||
|
||||
if (! $type instanceof ReflectionNamedType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($type->isBuiltin()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$name = $type->getName();
|
||||
|
||||
$class = $parameter->getDeclaringClass();
|
||||
|
||||
if (is_null($class)) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
if ($name === 'self') {
|
||||
return $class->getName();
|
||||
}
|
||||
|
||||
if ($name === 'parent' && ($parent = $class->getParentClass())) {
|
||||
return $parent->getName();
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
69
vendor/filament/support/src/Concerns/HasAlignment.php
vendored
Normal file
69
vendor/filament/support/src/Concerns/HasAlignment.php
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Enums\Alignment;
|
||||
|
||||
trait HasAlignment
|
||||
{
|
||||
protected Alignment | string | Closure | null $alignment = null;
|
||||
|
||||
public function alignment(Alignment | string | Closure | null $alignment): static
|
||||
{
|
||||
$this->alignment = $alignment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function alignStart(bool | Closure $condition = true): static
|
||||
{
|
||||
return $this->alignment(fn (): ?Alignment => $this->evaluate($condition) ? Alignment::Start : null);
|
||||
}
|
||||
|
||||
public function alignCenter(bool | Closure $condition = true): static
|
||||
{
|
||||
return $this->alignment(fn (): ?Alignment => $this->evaluate($condition) ? Alignment::Center : null);
|
||||
}
|
||||
|
||||
public function alignEnd(bool | Closure $condition = true): static
|
||||
{
|
||||
return $this->alignment(fn (): ?Alignment => $this->evaluate($condition) ? Alignment::End : null);
|
||||
}
|
||||
|
||||
public function alignJustify(bool | Closure $condition = true): static
|
||||
{
|
||||
return $this->alignment(fn (): ?Alignment => $this->evaluate($condition) ? Alignment::Justify : null);
|
||||
}
|
||||
|
||||
public function alignBetween(bool | Closure $condition = true): static
|
||||
{
|
||||
return $this->alignment(fn (): ?Alignment => $this->evaluate($condition) ? Alignment::Between : null);
|
||||
}
|
||||
|
||||
public function alignLeft(bool | Closure $condition = true): static
|
||||
{
|
||||
return $this->alignment(fn (): ?Alignment => $this->evaluate($condition) ? Alignment::Left : null);
|
||||
}
|
||||
|
||||
public function alignRight(bool | Closure $condition = true): static
|
||||
{
|
||||
return $this->alignment(fn (): ?Alignment => $this->evaluate($condition) ? Alignment::Right : null);
|
||||
}
|
||||
|
||||
public function getAlignment(): Alignment | string | null
|
||||
{
|
||||
$alignment = $this->evaluate($this->alignment);
|
||||
|
||||
if (! is_string($alignment)) {
|
||||
return $alignment;
|
||||
}
|
||||
|
||||
return Alignment::tryFrom($alignment) ?? $alignment;
|
||||
}
|
||||
|
||||
public function hasDynamicAlignment(): bool
|
||||
{
|
||||
return $this->alignment instanceof Closure;
|
||||
}
|
||||
}
|
||||
72
vendor/filament/support/src/Concerns/HasBadge.php
vendored
Normal file
72
vendor/filament/support/src/Concerns/HasBadge.php
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait HasBadge
|
||||
{
|
||||
protected string | Closure | null $badge = null;
|
||||
|
||||
/**
|
||||
* @var string | array<string> | Closure | null
|
||||
*/
|
||||
protected string | array | Closure | null $badgeColor = null;
|
||||
|
||||
public function badge(string | int | float | Closure | null $badge): static
|
||||
{
|
||||
if (is_int($badge) || is_float($badge)) {
|
||||
$badge = (string) $badge;
|
||||
}
|
||||
|
||||
$this->badge = $badge;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use `badge()` instead.
|
||||
*/
|
||||
public function indicator(string | int | float | Closure | null $indicator): static
|
||||
{
|
||||
return $this->badge($indicator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string | array<string> | Closure | null $color
|
||||
*/
|
||||
public function badgeColor(string | array | Closure | null $color): static
|
||||
{
|
||||
$this->badgeColor = $color;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use `badgeColor()` instead.
|
||||
*/
|
||||
public function indicatorColor(string | Closure | null $color): static
|
||||
{
|
||||
return $this->badgeColor($color);
|
||||
}
|
||||
|
||||
public function getBadge(): ?string
|
||||
{
|
||||
return $this->evaluate($this->badge);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string | array<string> | null
|
||||
*/
|
||||
public function getBadgeColor(?string $badge = null): string | array | null
|
||||
{
|
||||
return $this->evaluate($this->badgeColor, [
|
||||
'badge' => $badge,
|
||||
]);
|
||||
}
|
||||
|
||||
public function hasBadge(): bool
|
||||
{
|
||||
return $this->badge !== null;
|
||||
}
|
||||
}
|
||||
25
vendor/filament/support/src/Concerns/HasBadgeTooltip.php
vendored
Normal file
25
vendor/filament/support/src/Concerns/HasBadgeTooltip.php
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
trait HasBadgeTooltip
|
||||
{
|
||||
protected string | Htmlable | Closure | null $badgeTooltip = null;
|
||||
|
||||
public function badgeTooltip(string | Htmlable | Closure | null $tooltip): static
|
||||
{
|
||||
$this->badgeTooltip = $tooltip;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBadgeTooltip(?string $badge = null): string | Htmlable | null
|
||||
{
|
||||
return $this->evaluate($this->badgeTooltip, [
|
||||
'badge' => $badge,
|
||||
]);
|
||||
}
|
||||
}
|
||||
605
vendor/filament/support/src/Concerns/HasCellState.php
vendored
Normal file
605
vendor/filament/support/src/Concerns/HasCellState.php
vendored
Normal file
|
|
@ -0,0 +1,605 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Forms\Components\RichEditor\Models\Contracts\HasRichContent;
|
||||
use Filament\Support\ArrayRecord;
|
||||
use Filament\Tables\Columns\Column;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Stringable;
|
||||
use LogicException;
|
||||
use Znck\Eloquent\Relations\BelongsToThrough;
|
||||
|
||||
trait HasCellState
|
||||
{
|
||||
protected mixed $defaultState = null;
|
||||
|
||||
protected mixed $getStateUsing = null;
|
||||
|
||||
protected string | Closure | null $separator = null;
|
||||
|
||||
protected bool | Closure $isDistinctList = false;
|
||||
|
||||
protected ?string $inverseRelationshipName = null;
|
||||
|
||||
/**
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
protected array $cachedState = [];
|
||||
|
||||
protected ?bool $hasMultipleRelationshipCache = null;
|
||||
|
||||
protected ?Relation $relationshipCache = null;
|
||||
|
||||
protected ?bool $hasRelationshipCache = null;
|
||||
|
||||
protected ?string $relationshipNameCache = null;
|
||||
|
||||
protected ?string $fullAttributeNameCache = null;
|
||||
|
||||
protected ?string $attributeNameCache = null;
|
||||
|
||||
protected ?bool $hasNestedMorphToRelationshipCache = null;
|
||||
|
||||
public function inverseRelationship(?string $name): static
|
||||
{
|
||||
$this->inverseRelationshipName = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function distinctList(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->isDistinctList = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStateUsing(mixed $callback): static
|
||||
{
|
||||
$this->getStateUsing = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function state(mixed $state): static
|
||||
{
|
||||
$this->getStateUsing($state);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function default(mixed $state): static
|
||||
{
|
||||
$this->defaultState = $state;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isDistinctList(): bool
|
||||
{
|
||||
return (bool) $this->evaluate($this->isDistinctList);
|
||||
}
|
||||
|
||||
public function getDefaultState(): mixed
|
||||
{
|
||||
return $this->evaluate($this->defaultState);
|
||||
}
|
||||
|
||||
public function getState(): mixed
|
||||
{
|
||||
return $this->cacheState(function (): mixed {
|
||||
$state = ($this->getStateUsing !== null) ?
|
||||
$this->evaluate($this->getStateUsing) :
|
||||
$this->getStateFromRecord();
|
||||
|
||||
if (is_string($state) && ($separator = $this->getSeparator())) {
|
||||
$state = explode($separator, $state);
|
||||
$state = (count($state) === 1 && blank($state[0])) ?
|
||||
[] :
|
||||
$state;
|
||||
}
|
||||
|
||||
if (blank($state)) {
|
||||
$state = $this->getDefaultState();
|
||||
}
|
||||
|
||||
return $state;
|
||||
});
|
||||
}
|
||||
|
||||
public function getStateFromRecord(): mixed
|
||||
{
|
||||
$record = $this->getRecord();
|
||||
|
||||
if ($record instanceof Model) {
|
||||
$relationship = $this->getRelationship($record);
|
||||
|
||||
if ($relationship) {
|
||||
$relationshipAttribute = $this->getFullAttributeName($record);
|
||||
|
||||
$state = collect($this->getRelationshipResults($record))
|
||||
->reduce(
|
||||
function (Collection $carry, Model $record) use ($relationshipAttribute): Collection {
|
||||
if (
|
||||
($record instanceof HasRichContent) &&
|
||||
$record->hasRichContentAttribute($relationshipAttribute)
|
||||
) {
|
||||
$state = $record->getRichContentAttribute($relationshipAttribute);
|
||||
} else {
|
||||
$state = data_get($record, $relationshipAttribute);
|
||||
}
|
||||
|
||||
if (blank($state)) {
|
||||
return $carry;
|
||||
}
|
||||
|
||||
return $carry->push($state);
|
||||
},
|
||||
initial: collect(),
|
||||
)
|
||||
->when($this->isDistinctList(), fn (Collection $state) => $state->unique())
|
||||
->values();
|
||||
|
||||
if (! $state->count()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (($state->count() < 2) && (! $this->hasMultipleRelationship($record))) {
|
||||
return $state->first();
|
||||
}
|
||||
|
||||
return $state->all();
|
||||
}
|
||||
}
|
||||
|
||||
$name = $this->getName();
|
||||
|
||||
if (
|
||||
($record instanceof HasRichContent) &&
|
||||
$record->hasRichContentAttribute($name)
|
||||
) {
|
||||
$state = $record->getRichContentAttribute($name);
|
||||
} else {
|
||||
$state = data_get($record, $name);
|
||||
}
|
||||
|
||||
return $state;
|
||||
}
|
||||
|
||||
public function clearCachedState(): void
|
||||
{
|
||||
$this->cachedState = [];
|
||||
}
|
||||
|
||||
public function separator(string | Closure | null $separator = ','): static
|
||||
{
|
||||
$this->separator = $separator;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSeparator(): ?string
|
||||
{
|
||||
return $this->evaluate($this->separator);
|
||||
}
|
||||
|
||||
public function hasRelationship(Model $record): bool
|
||||
{
|
||||
if (isset($this->hasRelationshipCache)) {
|
||||
return $this->hasRelationshipCache;
|
||||
}
|
||||
|
||||
$name = $this->getName();
|
||||
|
||||
if (! str($name)->contains('.')) {
|
||||
return $this->hasRelationshipCache = false;
|
||||
}
|
||||
|
||||
if ($record->hasAttribute((string) str($name)->before('.'))) {
|
||||
return $this->hasRelationshipCache = false;
|
||||
}
|
||||
|
||||
return $this->hasRelationshipCache = $record->isRelation((string) str($name)->before('.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use `hasRelationship()` instead.
|
||||
*/
|
||||
public function queriesRelationships(Model $record): bool
|
||||
{
|
||||
return $this->hasRelationship($record);
|
||||
}
|
||||
|
||||
public function getRelationship(Model $record, ?string $relationshipName = null): ?Relation
|
||||
{
|
||||
$hasNestedMorphToRelationship = $this->hasNestedMorphToRelationship($record);
|
||||
|
||||
if ($this->relationshipCache && (! $hasNestedMorphToRelationship)) {
|
||||
return $this->relationshipCache;
|
||||
}
|
||||
|
||||
if (isset($relationshipName)) {
|
||||
$nameParts = explode('.', $relationshipName);
|
||||
} else {
|
||||
$name = $this->getName();
|
||||
|
||||
if (! str($name)->contains('.')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$nameParts = explode('.', $name);
|
||||
array_pop($nameParts);
|
||||
}
|
||||
|
||||
$relationship = null;
|
||||
|
||||
foreach ($nameParts as $namePart) {
|
||||
if ($record->hasAttribute($namePart)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (! $record->isRelation($namePart)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$relationship = $record->{$namePart}();
|
||||
$record = $relationship->getRelated();
|
||||
}
|
||||
|
||||
if ($hasNestedMorphToRelationship) {
|
||||
return $relationship;
|
||||
}
|
||||
|
||||
return $this->relationshipCache = $relationship;
|
||||
}
|
||||
|
||||
public function hasMultipleRelationship(Model $record): bool
|
||||
{
|
||||
$hasNestedMorphToRelationship = $this->hasNestedMorphToRelationship($record);
|
||||
|
||||
if (isset($this->hasMultipleRelationshipCache) && (! $hasNestedMorphToRelationship)) {
|
||||
return $this->hasMultipleRelationshipCache;
|
||||
}
|
||||
|
||||
$hasMultipleRelationship = false;
|
||||
|
||||
$relationships = explode('.', $this->getRelationshipName($record));
|
||||
|
||||
while (count($relationships)) {
|
||||
$currentRelationshipName = array_shift($relationships);
|
||||
|
||||
$currentRelationshipValue = $record->getRelationValue($currentRelationshipName);
|
||||
|
||||
if ($currentRelationshipValue instanceof Collection) {
|
||||
$hasMultipleRelationship = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (! $currentRelationshipValue instanceof Model) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (! count($relationships)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$record = $currentRelationshipValue;
|
||||
}
|
||||
|
||||
if ($hasNestedMorphToRelationship) {
|
||||
return $hasMultipleRelationship;
|
||||
}
|
||||
|
||||
return $this->hasMultipleRelationshipCache = $hasMultipleRelationship;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string> | null $relationships
|
||||
* @return array<Model>
|
||||
*/
|
||||
public function getRelationshipResults(Model $record, ?array $relationships = null): array
|
||||
{
|
||||
$results = [];
|
||||
|
||||
$relationships ??= explode('.', $this->getRelationshipName($record));
|
||||
|
||||
while (count($relationships)) {
|
||||
$currentRelationshipName = array_shift($relationships);
|
||||
|
||||
$currentRelationshipValue = $record->getRelationValue($currentRelationshipName);
|
||||
|
||||
if ($currentRelationshipValue instanceof Collection) {
|
||||
if (! count($relationships)) {
|
||||
$results = [
|
||||
...$results,
|
||||
...$currentRelationshipValue->all(),
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($currentRelationshipValue as $valueRecord) {
|
||||
$results = [
|
||||
...$results,
|
||||
...$this->getRelationshipResults(
|
||||
$valueRecord,
|
||||
$relationships,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (! $currentRelationshipValue instanceof Model) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (! count($relationships)) {
|
||||
$results[] = $currentRelationshipValue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$record = $currentRelationshipValue;
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getAttributeName(Model $record): string
|
||||
{
|
||||
$hasNestedMorphToRelationship = $this->hasNestedMorphToRelationship($record);
|
||||
|
||||
if (($this->attributeNameCache !== null) && (! $hasNestedMorphToRelationship)) {
|
||||
return $this->attributeNameCache;
|
||||
}
|
||||
|
||||
$name = $this->getName();
|
||||
|
||||
if (! str($name)->contains('.')) {
|
||||
return $this->attributeNameCache = $name;
|
||||
}
|
||||
|
||||
$nameParts = explode('.', $name);
|
||||
$lastPart = array_pop($nameParts);
|
||||
|
||||
foreach ($nameParts as $namePart) {
|
||||
if ($record->hasAttribute($namePart)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (! $record->isRelation($namePart)) {
|
||||
break;
|
||||
}
|
||||
|
||||
array_shift($nameParts);
|
||||
$record = $record->{$namePart}()->getRelated();
|
||||
}
|
||||
|
||||
$attributeName = Arr::first([...$nameParts, $lastPart]);
|
||||
|
||||
if ($hasNestedMorphToRelationship) {
|
||||
return $attributeName;
|
||||
}
|
||||
|
||||
return $this->attributeNameCache = $attributeName;
|
||||
}
|
||||
|
||||
public function getFullAttributeName(Model $record): string
|
||||
{
|
||||
$hasNestedMorphToRelationship = $this->hasNestedMorphToRelationship($record);
|
||||
|
||||
if (($this->fullAttributeNameCache !== null) && (! $hasNestedMorphToRelationship)) {
|
||||
return $this->fullAttributeNameCache;
|
||||
}
|
||||
|
||||
$name = $this->getName();
|
||||
|
||||
if (! str($name)->contains('.')) {
|
||||
return $this->fullAttributeNameCache = $name;
|
||||
}
|
||||
|
||||
$nameParts = explode('.', $name);
|
||||
$lastPart = array_pop($nameParts);
|
||||
|
||||
foreach ($nameParts as $namePart) {
|
||||
if ($record->hasAttribute($namePart)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (! $record->isRelation($namePart)) {
|
||||
break;
|
||||
}
|
||||
|
||||
array_shift($nameParts);
|
||||
$record = $record->{$namePart}()->getRelated();
|
||||
}
|
||||
|
||||
$fullAttributeName = implode('.', [...$nameParts, $lastPart]);
|
||||
|
||||
if ($hasNestedMorphToRelationship) {
|
||||
return $fullAttributeName;
|
||||
}
|
||||
|
||||
return $this->fullAttributeNameCache = $fullAttributeName;
|
||||
}
|
||||
|
||||
public function getInverseRelationshipName(Model $record): string
|
||||
{
|
||||
if (filled($this->inverseRelationshipName)) {
|
||||
return $this->inverseRelationshipName;
|
||||
}
|
||||
|
||||
$nameParts = explode('.', $this->getName());
|
||||
array_pop($nameParts);
|
||||
|
||||
$inverseRelationshipParts = [];
|
||||
|
||||
foreach ($nameParts as $namePart) {
|
||||
if ($record->hasAttribute($namePart)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (! $record->isRelation($namePart)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$relationship = $record->{$namePart}();
|
||||
$record = $relationship->getRelated();
|
||||
|
||||
$inverseNestedRelationshipName = (string) str(class_basename($relationship->getParent()::class))
|
||||
->when(
|
||||
($relationship instanceof BelongsTo ||
|
||||
$relationship instanceof BelongsToMany ||
|
||||
$relationship instanceof BelongsToThrough),
|
||||
fn (Stringable $name) => $name->plural(),
|
||||
)
|
||||
->camel();
|
||||
|
||||
if ($record->hasAttribute($inverseNestedRelationshipName) || (! $record->isRelation($inverseNestedRelationshipName))) {
|
||||
// The conventional relationship doesn't exist, but we can
|
||||
// attempt to use the original relationship name instead.
|
||||
|
||||
if ($record->hasAttribute($namePart) || (! $record->isRelation($namePart))) {
|
||||
$recordClass = $record::class;
|
||||
|
||||
throw new LogicException("When trying to guess the inverse relationship for column [{$this->getName()}], relationship [{$inverseNestedRelationshipName}] was not found on model [{$recordClass}]. Please define a custom [inverseRelationship()] for this column.");
|
||||
}
|
||||
|
||||
$inverseNestedRelationshipName = $namePart;
|
||||
}
|
||||
|
||||
array_unshift($inverseRelationshipParts, $inverseNestedRelationshipName);
|
||||
}
|
||||
|
||||
return $this->inverseRelationshipName = implode('.', $inverseRelationshipParts);
|
||||
}
|
||||
|
||||
public function getRelationshipName(Model $record): ?string
|
||||
{
|
||||
$hasNestedMorphToRelationship = $this->hasNestedMorphToRelationship($record);
|
||||
|
||||
if (($this->relationshipNameCache !== null) && (! $hasNestedMorphToRelationship)) {
|
||||
return $this->relationshipNameCache;
|
||||
}
|
||||
|
||||
$name = $this->getName();
|
||||
|
||||
if (! str($name)->contains('.')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$nameParts = explode('.', $name);
|
||||
array_pop($nameParts);
|
||||
|
||||
$relationshipParts = [];
|
||||
|
||||
foreach ($nameParts as $namePart) {
|
||||
if ($record->hasAttribute($namePart)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (! $record->isRelation($namePart)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$relationshipParts[] = $namePart;
|
||||
$record = $record->{$namePart}()->getRelated();
|
||||
}
|
||||
|
||||
$relationshipName = implode('.', $relationshipParts);
|
||||
|
||||
if ($hasNestedMorphToRelationship) {
|
||||
return $relationshipName;
|
||||
}
|
||||
|
||||
return $this->relationshipNameCache = $relationshipName;
|
||||
}
|
||||
|
||||
/**
|
||||
* When the name of a cell traverses a `MorphTo` relationship and then continues deeper,
|
||||
* the remainder of the path resolves against the concrete related model of each record,
|
||||
* which may differ between records and is unknown while the query is being built. In
|
||||
* that case, the relationship and attribute names cannot be cached across records and
|
||||
* must be resolved fresh for each one.
|
||||
*/
|
||||
public function hasNestedMorphToRelationship(Model $record): bool
|
||||
{
|
||||
if (isset($this->hasNestedMorphToRelationshipCache)) {
|
||||
return $this->hasNestedMorphToRelationshipCache;
|
||||
}
|
||||
|
||||
$name = $this->getName();
|
||||
|
||||
if (! str($name)->contains('.')) {
|
||||
return $this->hasNestedMorphToRelationshipCache = false;
|
||||
}
|
||||
|
||||
$nameParts = explode('.', $name);
|
||||
array_pop($nameParts);
|
||||
|
||||
$lastNamePartIndex = count($nameParts) - 1;
|
||||
|
||||
foreach ($nameParts as $namePartIndex => $namePart) {
|
||||
if ($record->hasAttribute($namePart)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (! $record->isRelation($namePart)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$relationship = $record->{$namePart}();
|
||||
|
||||
if ($relationship instanceof MorphTo) {
|
||||
return $this->hasNestedMorphToRelationshipCache = ($namePartIndex < $lastNamePartIndex);
|
||||
}
|
||||
|
||||
$record = $relationship->getRelated();
|
||||
}
|
||||
|
||||
return $this->hasNestedMorphToRelationshipCache = false;
|
||||
}
|
||||
|
||||
protected function cacheState(Closure $state): mixed
|
||||
{
|
||||
$record = $this->getRecord();
|
||||
|
||||
if (! $record) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this instanceof Column) {
|
||||
$recordKey = $this->getLivewire()->getTableRecordKey($record);
|
||||
} elseif (is_array($record)) { /** @phpstan-ignore function.impossibleType */
|
||||
$recordKey = (string) ($record[ArrayRecord::getKeyName()] ?? null); /** @phpstan-ignore nullCoalesce.offset */
|
||||
} else {
|
||||
$recordKey = (string) $record->getKey();
|
||||
}
|
||||
|
||||
if (blank($recordKey)) {
|
||||
return $state();
|
||||
}
|
||||
|
||||
if (array_key_exists($recordKey, $this->cachedState)) {
|
||||
return $this->cachedState[$recordKey];
|
||||
}
|
||||
|
||||
return $this->cachedState[$recordKey] = $state();
|
||||
}
|
||||
|
||||
public function getGetStateUsingCallback(): mixed
|
||||
{
|
||||
return $this->getStateUsing;
|
||||
}
|
||||
}
|
||||
51
vendor/filament/support/src/Concerns/HasColor.php
vendored
Normal file
51
vendor/filament/support/src/Concerns/HasColor.php
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait HasColor
|
||||
{
|
||||
/**
|
||||
* @var string | array<string> | Closure | null
|
||||
*/
|
||||
protected string | array | Closure | null $color = null;
|
||||
|
||||
/**
|
||||
* @var string | array<string> | Closure | null
|
||||
*/
|
||||
protected string | array | Closure | null $defaultColor = null;
|
||||
|
||||
/**
|
||||
* @param string | array<string> | Closure | null $color
|
||||
*/
|
||||
public function color(string | array | Closure | null $color): static
|
||||
{
|
||||
$this->color = $color;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string | array<string> | Closure | null $color
|
||||
*/
|
||||
public function defaultColor(string | array | Closure | null $color): static
|
||||
{
|
||||
$this->defaultColor = $color;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string | array<string> | null
|
||||
*/
|
||||
public function getColor(): string | array | null
|
||||
{
|
||||
return $this->evaluate($this->color) ?? $this->evaluate($this->defaultColor);
|
||||
}
|
||||
|
||||
public function hasColor(): bool
|
||||
{
|
||||
return $this->color !== null || $this->defaultColor !== null;
|
||||
}
|
||||
}
|
||||
120
vendor/filament/support/src/Concerns/HasDefaultDataFormattingSettings.php
vendored
Normal file
120
vendor/filament/support/src/Concerns/HasDefaultDataFormattingSettings.php
vendored
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait HasDefaultDataFormattingSettings
|
||||
{
|
||||
protected string | Closure $defaultCurrency = 'usd';
|
||||
|
||||
protected string | Closure $defaultDateDisplayFormat = 'M j, Y';
|
||||
|
||||
protected string | Closure $defaultIsoDateDisplayFormat = 'L';
|
||||
|
||||
protected string | Closure $defaultDateTimeDisplayFormat = 'M j, Y H:i:s';
|
||||
|
||||
protected string | Closure $defaultIsoDateTimeDisplayFormat = 'LLL';
|
||||
|
||||
protected string | Closure | null $defaultNumberLocale = null;
|
||||
|
||||
protected string | Closure $defaultTimeDisplayFormat = 'H:i:s';
|
||||
|
||||
protected string | Closure $defaultIsoTimeDisplayFormat = 'LT';
|
||||
|
||||
public function defaultDateDisplayFormat(string | Closure $format): static
|
||||
{
|
||||
$this->defaultDateDisplayFormat = $format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function defaultDateTimeDisplayFormat(string | Closure $format): static
|
||||
{
|
||||
$this->defaultDateTimeDisplayFormat = $format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function defaultTimeDisplayFormat(string | Closure $format): static
|
||||
{
|
||||
$this->defaultTimeDisplayFormat = $format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function defaultIsoDateDisplayFormat(string | Closure $format): static
|
||||
{
|
||||
$this->defaultIsoDateDisplayFormat = $format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function defaultIsoDateTimeDisplayFormat(string | Closure $format): static
|
||||
{
|
||||
$this->defaultIsoDateTimeDisplayFormat = $format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function defaultIsoTimeDisplayFormat(string | Closure $format): static
|
||||
{
|
||||
$this->defaultIsoTimeDisplayFormat = $format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function defaultNumberLocale(string | Closure | null $locale): static
|
||||
{
|
||||
$this->defaultNumberLocale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function defaultCurrency(string | Closure $currency): static
|
||||
{
|
||||
$this->defaultCurrency = $currency;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDefaultDateDisplayFormat(): string
|
||||
{
|
||||
return $this->evaluate($this->defaultDateDisplayFormat);
|
||||
}
|
||||
|
||||
public function getDefaultDateTimeDisplayFormat(): string
|
||||
{
|
||||
return $this->evaluate($this->defaultDateTimeDisplayFormat);
|
||||
}
|
||||
|
||||
public function getDefaultTimeDisplayFormat(): string
|
||||
{
|
||||
return $this->evaluate($this->defaultTimeDisplayFormat);
|
||||
}
|
||||
|
||||
public function getDefaultIsoDateDisplayFormat(): string
|
||||
{
|
||||
return $this->evaluate($this->defaultIsoDateDisplayFormat);
|
||||
}
|
||||
|
||||
public function getDefaultIsoDateTimeDisplayFormat(): string
|
||||
{
|
||||
return $this->evaluate($this->defaultIsoDateTimeDisplayFormat);
|
||||
}
|
||||
|
||||
public function getDefaultIsoTimeDisplayFormat(): string
|
||||
{
|
||||
return $this->evaluate($this->defaultIsoTimeDisplayFormat);
|
||||
}
|
||||
|
||||
public function getDefaultNumberLocale(): ?string
|
||||
{
|
||||
return $this->evaluate($this->defaultNumberLocale);
|
||||
}
|
||||
|
||||
public function getDefaultCurrency(): string
|
||||
{
|
||||
return $this->evaluate($this->defaultCurrency);
|
||||
}
|
||||
}
|
||||
55
vendor/filament/support/src/Concerns/HasExtraAlpineAttributes.php
vendored
Normal file
55
vendor/filament/support/src/Concerns/HasExtraAlpineAttributes.php
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\View\ComponentAttributeBag as FilamentComponentAttributeBag;
|
||||
use Illuminate\View\ComponentAttributeBag;
|
||||
|
||||
trait HasExtraAlpineAttributes
|
||||
{
|
||||
/**
|
||||
* @var array<array<mixed> | Closure>
|
||||
*/
|
||||
protected array $extraAlpineAttributes = [];
|
||||
|
||||
/**
|
||||
* @param array<mixed> | Closure $attributes
|
||||
*/
|
||||
public function extraAlpineAttributes(array | Closure $attributes, bool $merge = false): static
|
||||
{
|
||||
// Security: Attribute values are not escaped when rendered. Never
|
||||
// pass unsanitized user input as attribute names or values.
|
||||
|
||||
if ($merge) {
|
||||
if (($attributes instanceof Closure) && in_array($attributes, $this->extraAlpineAttributes, strict: true)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->extraAlpineAttributes[] = $attributes;
|
||||
} else {
|
||||
$this->extraAlpineAttributes = [$attributes];
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public function getExtraAlpineAttributes(): array
|
||||
{
|
||||
$temporaryAttributeBag = new FilamentComponentAttributeBag;
|
||||
|
||||
foreach ($this->extraAlpineAttributes as $extraAlpineAttributes) {
|
||||
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraAlpineAttributes), escape: false);
|
||||
}
|
||||
|
||||
return $temporaryAttributeBag->getAttributes();
|
||||
}
|
||||
|
||||
public function getExtraAlpineAttributeBag(): ComponentAttributeBag
|
||||
{
|
||||
return new FilamentComponentAttributeBag($this->getExtraAlpineAttributes());
|
||||
}
|
||||
}
|
||||
60
vendor/filament/support/src/Concerns/HasExtraAttributes.php
vendored
Normal file
60
vendor/filament/support/src/Concerns/HasExtraAttributes.php
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\View\ComponentAttributeBag as FilamentComponentAttributeBag;
|
||||
use Illuminate\View\ComponentAttributeBag;
|
||||
|
||||
trait HasExtraAttributes
|
||||
{
|
||||
/**
|
||||
* @var array<array<mixed> | Closure>
|
||||
*/
|
||||
protected array $extraAttributes = [];
|
||||
|
||||
/**
|
||||
* @param array<mixed> | Closure $attributes
|
||||
*/
|
||||
public function extraAttributes(array | Closure $attributes, bool $merge = false): static
|
||||
{
|
||||
// Security: Attribute values are not escaped when rendered. Never
|
||||
// pass unsanitized user input as attribute names or values.
|
||||
|
||||
if ($merge) {
|
||||
if (($attributes instanceof Closure) && in_array($attributes, $this->extraAttributes, strict: true)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->extraAttributes[] = $attributes;
|
||||
} else {
|
||||
$this->extraAttributes = [$attributes];
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public function getExtraAttributes(): array
|
||||
{
|
||||
$temporaryAttributeBag = new FilamentComponentAttributeBag;
|
||||
|
||||
foreach ($this->extraAttributes as $extraAttributes) {
|
||||
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraAttributes), escape: false);
|
||||
}
|
||||
|
||||
return $temporaryAttributeBag->getAttributes();
|
||||
}
|
||||
|
||||
public function getExtraAttributeBag(): ComponentAttributeBag
|
||||
{
|
||||
return new FilamentComponentAttributeBag($this->getExtraAttributes());
|
||||
}
|
||||
|
||||
public function hasExtraAttributes(): bool
|
||||
{
|
||||
return ! empty($this->extraAttributes);
|
||||
}
|
||||
}
|
||||
36
vendor/filament/support/src/Concerns/HasFontFamily.php
vendored
Normal file
36
vendor/filament/support/src/Concerns/HasFontFamily.php
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Enums\FontFamily;
|
||||
|
||||
trait HasFontFamily
|
||||
{
|
||||
protected FontFamily | string | Closure | null $fontFamily = null;
|
||||
|
||||
public function fontFamily(FontFamily | string | Closure | null $family): static
|
||||
{
|
||||
$this->fontFamily = $family;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFontFamily(mixed $state = null): FontFamily | string | null
|
||||
{
|
||||
$family = $this->evaluate($this->fontFamily, [
|
||||
'state' => $state,
|
||||
]);
|
||||
|
||||
if (is_string($family)) {
|
||||
$family = FontFamily::tryFrom($family) ?? $family;
|
||||
}
|
||||
|
||||
return $family;
|
||||
}
|
||||
|
||||
public function hasFontFamily(): bool
|
||||
{
|
||||
return $this->fontFamily !== null;
|
||||
}
|
||||
}
|
||||
22
vendor/filament/support/src/Concerns/HasFromBreakpoint.php
vendored
Normal file
22
vendor/filament/support/src/Concerns/HasFromBreakpoint.php
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait HasFromBreakpoint
|
||||
{
|
||||
protected string | Closure | null $fromBreakpoint = null;
|
||||
|
||||
public function from(string | Closure | null $breakpoint): static
|
||||
{
|
||||
$this->fromBreakpoint = $breakpoint;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFromBreakpoint(): ?string
|
||||
{
|
||||
return $this->evaluate($this->fromBreakpoint);
|
||||
}
|
||||
}
|
||||
46
vendor/filament/support/src/Concerns/HasIcon.php
vendored
Normal file
46
vendor/filament/support/src/Concerns/HasIcon.php
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use BackedEnum;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
trait HasIcon
|
||||
{
|
||||
protected string | BackedEnum | Htmlable | Closure | false | null $icon = null;
|
||||
|
||||
public function icon(string | BackedEnum | Htmlable | Closure | null $icon): static
|
||||
{
|
||||
// Security: Icon strings are escaped when rendered as URLs, but
|
||||
// invalid icon names from user input will cause rendering errors.
|
||||
// Validate against a known allowlist if user-controlled.
|
||||
|
||||
$this->icon = filled($icon) ? $icon : false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIcon(string | BackedEnum | Htmlable | null $default = null): string | BackedEnum | Htmlable | null
|
||||
{
|
||||
$icon = $this->evaluate($this->icon);
|
||||
|
||||
// https://github.com/filamentphp/filament/pull/13512
|
||||
if ($icon instanceof Renderable) {
|
||||
return new HtmlString($icon->render());
|
||||
}
|
||||
|
||||
if ($icon === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $icon ?? $default;
|
||||
}
|
||||
|
||||
public function hasIcon(): bool
|
||||
{
|
||||
return $this->icon !== null && $this->icon !== false;
|
||||
}
|
||||
}
|
||||
36
vendor/filament/support/src/Concerns/HasIconColor.php
vendored
Normal file
36
vendor/filament/support/src/Concerns/HasIconColor.php
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait HasIconColor
|
||||
{
|
||||
/**
|
||||
* @var string | array<string> | Closure | null
|
||||
*/
|
||||
protected string | array | Closure | null $iconColor = null;
|
||||
|
||||
/**
|
||||
* @param string | array<string> | Closure | null $color
|
||||
*/
|
||||
public function iconColor(string | array | Closure | null $color): static
|
||||
{
|
||||
$this->iconColor = $color;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string | array<string> | null
|
||||
*/
|
||||
public function getIconColor(): string | array | null
|
||||
{
|
||||
return $this->evaluate($this->iconColor);
|
||||
}
|
||||
|
||||
public function hasIconColor(): bool
|
||||
{
|
||||
return $this->iconColor !== null;
|
||||
}
|
||||
}
|
||||
38
vendor/filament/support/src/Concerns/HasIconPosition.php
vendored
Normal file
38
vendor/filament/support/src/Concerns/HasIconPosition.php
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Enums\IconPosition;
|
||||
|
||||
trait HasIconPosition
|
||||
{
|
||||
protected IconPosition | string | Closure | null $iconPosition = null;
|
||||
|
||||
public function iconPosition(IconPosition | string | Closure | null $position): static
|
||||
{
|
||||
$this->iconPosition = $position;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIconPosition(): IconPosition
|
||||
{
|
||||
$position = $this->evaluate($this->iconPosition);
|
||||
|
||||
if ($position instanceof IconPosition) {
|
||||
return $position;
|
||||
}
|
||||
|
||||
if (blank($position)) {
|
||||
return IconPosition::Before;
|
||||
}
|
||||
|
||||
return IconPosition::tryFrom($position) ?? IconPosition::Before;
|
||||
}
|
||||
|
||||
public function hasIconPosition(): bool
|
||||
{
|
||||
return $this->iconPosition !== null;
|
||||
}
|
||||
}
|
||||
28
vendor/filament/support/src/Concerns/HasIconSize.php
vendored
Normal file
28
vendor/filament/support/src/Concerns/HasIconSize.php
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Enums\IconSize;
|
||||
|
||||
trait HasIconSize
|
||||
{
|
||||
protected IconSize | string | Closure | null $iconSize = null;
|
||||
|
||||
public function iconSize(IconSize | string | Closure | null $size): static
|
||||
{
|
||||
$this->iconSize = $size;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIconSize(): IconSize | string | null
|
||||
{
|
||||
return $this->evaluate($this->iconSize);
|
||||
}
|
||||
|
||||
public function hasIconSize(): bool
|
||||
{
|
||||
return $this->iconSize !== null;
|
||||
}
|
||||
}
|
||||
27
vendor/filament/support/src/Concerns/HasLineClamp.php
vendored
Normal file
27
vendor/filament/support/src/Concerns/HasLineClamp.php
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait HasLineClamp
|
||||
{
|
||||
protected int | Closure | null $lineClamp = null;
|
||||
|
||||
public function lineClamp(int | Closure | null $lineClamp): static
|
||||
{
|
||||
$this->lineClamp = $lineClamp;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLineClamp(): ?int
|
||||
{
|
||||
return $this->evaluate($this->lineClamp);
|
||||
}
|
||||
|
||||
public function hasLineClamp(): bool
|
||||
{
|
||||
return $this->lineClamp !== null;
|
||||
}
|
||||
}
|
||||
23
vendor/filament/support/src/Concerns/HasPlaceholder.php
vendored
Normal file
23
vendor/filament/support/src/Concerns/HasPlaceholder.php
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
trait HasPlaceholder
|
||||
{
|
||||
protected string | Htmlable | Closure | null $placeholder = null;
|
||||
|
||||
public function placeholder(string | Htmlable | Closure | null $placeholder): static
|
||||
{
|
||||
$this->placeholder = $placeholder;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPlaceholder(): string | Htmlable | null
|
||||
{
|
||||
return $this->evaluate($this->placeholder);
|
||||
}
|
||||
}
|
||||
22
vendor/filament/support/src/Concerns/HasReorderAnimationDuration.php
vendored
Normal file
22
vendor/filament/support/src/Concerns/HasReorderAnimationDuration.php
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait HasReorderAnimationDuration
|
||||
{
|
||||
protected int | Closure $reorderAnimationDuration = 300;
|
||||
|
||||
public function reorderAnimationDuration(int | Closure $animation): static
|
||||
{
|
||||
$this->reorderAnimationDuration = $animation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getReorderAnimationDuration(): int
|
||||
{
|
||||
return $this->evaluate($this->reorderAnimationDuration);
|
||||
}
|
||||
}
|
||||
28
vendor/filament/support/src/Concerns/HasTooltip.php
vendored
Normal file
28
vendor/filament/support/src/Concerns/HasTooltip.php
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
trait HasTooltip
|
||||
{
|
||||
protected string | Htmlable | Closure | null $tooltip = null;
|
||||
|
||||
public function tooltip(string | Htmlable | Closure | null $tooltip): static
|
||||
{
|
||||
$this->tooltip = $tooltip;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTooltip(): string | Htmlable | null
|
||||
{
|
||||
return $this->evaluate($this->tooltip);
|
||||
}
|
||||
|
||||
public function hasTooltip(): bool
|
||||
{
|
||||
return $this->tooltip !== null;
|
||||
}
|
||||
}
|
||||
49
vendor/filament/support/src/Concerns/HasVerticalAlignment.php
vendored
Normal file
49
vendor/filament/support/src/Concerns/HasVerticalAlignment.php
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Enums\VerticalAlignment;
|
||||
|
||||
trait HasVerticalAlignment
|
||||
{
|
||||
protected VerticalAlignment | string | Closure | null $verticalAlignment = null;
|
||||
|
||||
public function verticalAlignment(VerticalAlignment | string | Closure | null $alignment): static
|
||||
{
|
||||
$this->verticalAlignment = $alignment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function verticallyAlignStart(bool | Closure $condition = true): static
|
||||
{
|
||||
return $this->verticalAlignment(fn (): ?VerticalAlignment => $this->evaluate($condition) ? VerticalAlignment::Start : null);
|
||||
}
|
||||
|
||||
public function verticallyAlignCenter(bool | Closure $condition = true): static
|
||||
{
|
||||
return $this->verticalAlignment(fn (): ?VerticalAlignment => $this->evaluate($condition) ? VerticalAlignment::Center : null);
|
||||
}
|
||||
|
||||
public function verticallyAlignEnd(bool | Closure $condition = true): static
|
||||
{
|
||||
return $this->verticalAlignment(fn (): ?VerticalAlignment => $this->evaluate($condition) ? VerticalAlignment::End : null);
|
||||
}
|
||||
|
||||
public function getVerticalAlignment(): VerticalAlignment | string | null
|
||||
{
|
||||
$alignment = $this->evaluate($this->verticalAlignment);
|
||||
|
||||
if (! is_string($alignment)) {
|
||||
return $alignment;
|
||||
}
|
||||
|
||||
return VerticalAlignment::tryFrom($alignment) ?? $alignment;
|
||||
}
|
||||
|
||||
public function hasDynamicVerticalAlignment(): bool
|
||||
{
|
||||
return $this->verticalAlignment instanceof Closure;
|
||||
}
|
||||
}
|
||||
36
vendor/filament/support/src/Concerns/HasWeight.php
vendored
Normal file
36
vendor/filament/support/src/Concerns/HasWeight.php
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
|
||||
trait HasWeight
|
||||
{
|
||||
protected FontWeight | string | Closure | null $weight = null;
|
||||
|
||||
public function weight(FontWeight | string | Closure | null $weight): static
|
||||
{
|
||||
$this->weight = $weight;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWeight(mixed $state = null): FontWeight | string | null
|
||||
{
|
||||
$weight = $this->evaluate($this->weight, [
|
||||
'state' => $state,
|
||||
]);
|
||||
|
||||
if (! is_string($weight)) {
|
||||
return $weight;
|
||||
}
|
||||
|
||||
return FontWeight::tryFrom($weight) ?? $weight;
|
||||
}
|
||||
|
||||
public function hasWeight(): bool
|
||||
{
|
||||
return $this->weight !== null;
|
||||
}
|
||||
}
|
||||
28
vendor/filament/support/src/Concerns/HasWidth.php
vendored
Normal file
28
vendor/filament/support/src/Concerns/HasWidth.php
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
||||
trait HasWidth
|
||||
{
|
||||
protected int | string | Closure | null $width = null;
|
||||
|
||||
public function width(int | string | Closure | null $width): static
|
||||
{
|
||||
$this->width = $width;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWidth(): ?string
|
||||
{
|
||||
$width = $this->evaluate($this->width);
|
||||
|
||||
if (is_int($width)) {
|
||||
$width = "{$width}px";
|
||||
}
|
||||
|
||||
return $width;
|
||||
}
|
||||
}
|
||||
111
vendor/filament/support/src/Concerns/Macroable.php
vendored
Normal file
111
vendor/filament/support/src/Concerns/Macroable.php
vendored
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Concerns;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Closure;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
|
||||
trait Macroable
|
||||
{
|
||||
/**
|
||||
* @var array<string, array<class-string, Closure>>
|
||||
*/
|
||||
protected static array $macros = [];
|
||||
|
||||
public static function macro(string $name, callable $macro): void
|
||||
{
|
||||
static::$macros[$name][static::class] = $macro;
|
||||
}
|
||||
|
||||
public static function mixin(object $mixin, bool $replace = true): void
|
||||
{
|
||||
$methods = (new ReflectionClass($mixin))->getMethods(
|
||||
ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED,
|
||||
);
|
||||
|
||||
foreach ($methods as $method) {
|
||||
if ($replace || (! isset(static::$macros[$method->name][static::class]))) {
|
||||
static::macro($method->name, $method->invoke($mixin));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function flushMacros(): void
|
||||
{
|
||||
static::$macros = [];
|
||||
}
|
||||
|
||||
public static function hasMacro(string $name): bool
|
||||
{
|
||||
return (bool) static::getMacro($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<array-key> $parameters
|
||||
*/
|
||||
public static function __callStatic(string $method, array $parameters): mixed
|
||||
{
|
||||
$macro = static::getMacro($method);
|
||||
|
||||
if ($macro === null) {
|
||||
throw new BadMethodCallException(sprintf(
|
||||
'Method %s::%s does not exist.',
|
||||
static::class,
|
||||
$method,
|
||||
));
|
||||
}
|
||||
|
||||
if ($macro instanceof Closure) {
|
||||
$macro = $macro->bindTo(null, static::class);
|
||||
}
|
||||
|
||||
return $macro(...$parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<array-key> $parameters
|
||||
*/
|
||||
public function __call(string $method, array $parameters): mixed
|
||||
{
|
||||
$macro = static::getMacro($method);
|
||||
|
||||
if ($macro === null) {
|
||||
throw new BadMethodCallException(sprintf(
|
||||
'Method %s::%s does not exist.',
|
||||
static::class,
|
||||
$method,
|
||||
));
|
||||
}
|
||||
|
||||
if ($macro instanceof Closure) {
|
||||
$macro = $macro->bindTo($this, static::class);
|
||||
}
|
||||
|
||||
return $macro(...$parameters);
|
||||
}
|
||||
|
||||
protected static function getMacro(string $method): ?callable
|
||||
{
|
||||
$macros = static::$macros[$method] ?? [];
|
||||
|
||||
if (! count($macros)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (array_key_exists(static::class, $macros)) {
|
||||
return $macros[static::class];
|
||||
}
|
||||
|
||||
foreach (class_parents(static::class) as $parent) {
|
||||
if (! array_key_exists($parent, $macros)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $macros[$parent];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
10
vendor/filament/support/src/Contracts/Collapsible.php
vendored
Normal file
10
vendor/filament/support/src/Contracts/Collapsible.php
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Contracts;
|
||||
|
||||
interface Collapsible
|
||||
{
|
||||
public function isCollapsible(): bool;
|
||||
|
||||
public function isCollapsed(): bool;
|
||||
}
|
||||
11
vendor/filament/support/src/Contracts/HasColor.php
vendored
Normal file
11
vendor/filament/support/src/Contracts/HasColor.php
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Contracts;
|
||||
|
||||
interface HasColor
|
||||
{
|
||||
/**
|
||||
* @return string | array<string> | null
|
||||
*/
|
||||
public function getColor(): string | array | null;
|
||||
}
|
||||
10
vendor/filament/support/src/Contracts/HasDescription.php
vendored
Normal file
10
vendor/filament/support/src/Contracts/HasDescription.php
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Contracts;
|
||||
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
interface HasDescription
|
||||
{
|
||||
public function getDescription(): string | Htmlable | null;
|
||||
}
|
||||
11
vendor/filament/support/src/Contracts/HasIcon.php
vendored
Normal file
11
vendor/filament/support/src/Contracts/HasIcon.php
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Contracts;
|
||||
|
||||
use BackedEnum;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
interface HasIcon
|
||||
{
|
||||
public function getIcon(): string | BackedEnum | Htmlable | null;
|
||||
}
|
||||
10
vendor/filament/support/src/Contracts/HasLabel.php
vendored
Normal file
10
vendor/filament/support/src/Contracts/HasLabel.php
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Contracts;
|
||||
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
interface HasLabel
|
||||
{
|
||||
public function getLabel(): string | Htmlable | null;
|
||||
}
|
||||
10
vendor/filament/support/src/Contracts/LoadingIndicator.php
vendored
Normal file
10
vendor/filament/support/src/Contracts/LoadingIndicator.php
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Contracts;
|
||||
|
||||
use Illuminate\View\ComponentAttributeBag;
|
||||
|
||||
interface LoadingIndicator
|
||||
{
|
||||
public function toHtml(ComponentAttributeBag $attributes): string;
|
||||
}
|
||||
10
vendor/filament/support/src/Contracts/ScalableIcon.php
vendored
Normal file
10
vendor/filament/support/src/Contracts/ScalableIcon.php
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Contracts;
|
||||
|
||||
use Filament\Support\Enums\IconSize;
|
||||
|
||||
interface ScalableIcon
|
||||
{
|
||||
public function getIconForSize(IconSize $size): string;
|
||||
}
|
||||
42
vendor/filament/support/src/Contracts/TranslatableContentDriver.php
vendored
Normal file
42
vendor/filament/support/src/Contracts/TranslatableContentDriver.php
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Contracts;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
interface TranslatableContentDriver
|
||||
{
|
||||
public function __construct(string $activeLocale);
|
||||
|
||||
/**
|
||||
* @param class-string<Model> $model
|
||||
*/
|
||||
public function isAttributeTranslatable(string $model, string $attribute): bool;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getRecordAttributesToArray(Model $record): array;
|
||||
|
||||
/**
|
||||
* @param class-string<Model> $model
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public function makeRecord(string $model, array $data): Model;
|
||||
|
||||
public function setRecordLocale(Model $record): Model;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public function updateRecord(Model $record, array $data): Model;
|
||||
|
||||
/**
|
||||
* @template TModel of Model
|
||||
*
|
||||
* @param Builder<TModel> $query
|
||||
* @return Builder<TModel>
|
||||
*/
|
||||
public function applySearchConstraintToQuery(Builder $query, string $column, string $search, string $whereClause, ?bool $isSearchForcedCaseInsensitive = null): Builder;
|
||||
}
|
||||
20
vendor/filament/support/src/Enums/Alignment.php
vendored
Normal file
20
vendor/filament/support/src/Enums/Alignment.php
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Enums;
|
||||
|
||||
enum Alignment: string
|
||||
{
|
||||
case Start = 'start';
|
||||
|
||||
case Left = 'left';
|
||||
|
||||
case Center = 'center';
|
||||
|
||||
case End = 'end';
|
||||
|
||||
case Right = 'right';
|
||||
|
||||
case Justify = 'justify';
|
||||
|
||||
case Between = 'between';
|
||||
}
|
||||
8
vendor/filament/support/src/Enums/ArgumentValue.php
vendored
Normal file
8
vendor/filament/support/src/Enums/ArgumentValue.php
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Enums;
|
||||
|
||||
enum ArgumentValue
|
||||
{
|
||||
case Default;
|
||||
}
|
||||
12
vendor/filament/support/src/Enums/FontFamily.php
vendored
Normal file
12
vendor/filament/support/src/Enums/FontFamily.php
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Enums;
|
||||
|
||||
enum FontFamily: string
|
||||
{
|
||||
case Sans = 'sans';
|
||||
|
||||
case Serif = 'serif';
|
||||
|
||||
case Mono = 'mono';
|
||||
}
|
||||
24
vendor/filament/support/src/Enums/FontWeight.php
vendored
Normal file
24
vendor/filament/support/src/Enums/FontWeight.php
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Enums;
|
||||
|
||||
enum FontWeight: string
|
||||
{
|
||||
case Thin = 'thin';
|
||||
|
||||
case ExtraLight = 'extralight';
|
||||
|
||||
case Light = 'light';
|
||||
|
||||
case Normal = 'normal';
|
||||
|
||||
case Medium = 'medium';
|
||||
|
||||
case SemiBold = 'semibold';
|
||||
|
||||
case Bold = 'bold';
|
||||
|
||||
case ExtraBold = 'extrabold';
|
||||
|
||||
case Black = 'black';
|
||||
}
|
||||
10
vendor/filament/support/src/Enums/GridDirection.php
vendored
Normal file
10
vendor/filament/support/src/Enums/GridDirection.php
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Filament\Support\Enums;
|
||||
|
||||
enum GridDirection: string
|
||||
{
|
||||
case Row = 'row';
|
||||
|
||||
case Column = 'column';
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue