diff --git a/packages/actions/docs/04-modals.md b/packages/actions/docs/04-modals.md index ccba9c312e..2161d957f3 100644 --- a/packages/actions/docs/04-modals.md +++ b/packages/actions/docs/04-modals.md @@ -323,9 +323,11 @@ Action::make('updateAuthor') ## Changing the modal width -You can change the width of the modal by using the `modalWidth()` method. Options correspond to [Tailwind's max-width scale](https://tailwindcss.com/docs/max-width). The options are `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`, `5xl`, `6xl`, `7xl`, and `screen`: +You can change the width of the modal by using the `modalWidth()` method. Options correspond to [Tailwind's max-width scale](https://tailwindcss.com/docs/max-width). The options are `ExtraSmall`, `Small`, `Medium`, `Large`, `ExtraLarge`, `TwoExtraLarge`, `ThreeExtraLarge`, `FourExtraLarge`, `FiveExtraLarge`, `SixExtraLarge`, `SevenExtraLarge`, and `Screen`: ```php +use Filament\Support\Enums\MaxWidth; + Action::make('updateAuthor') ->form([ // ... @@ -333,7 +335,7 @@ Action::make('updateAuthor') ->action(function (array $data): void { // ... }) - ->modalWidth('5xl') + ->modalWidth(MaxWidth::FiveExtraLarge) ``` ## Conditionally hiding the modal diff --git a/packages/actions/docs/05-grouping-actions.md b/packages/actions/docs/05-grouping-actions.md index 3f1c7b6d6b..62c9180dca 100644 --- a/packages/actions/docs/05-grouping-actions.md +++ b/packages/actions/docs/05-grouping-actions.md @@ -70,13 +70,15 @@ The `dropdown(false)` method puts the actions inside the parent dropdown, instea ## Setting the width of the dropdown -The dropdown may be set to a width by using the `dropdownWidth()` method. Options correspond to [Tailwind's max-width scale](https://tailwindcss.com/docs/max-width). The options are `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`, `5xl`, `6xl` and `7xl`: +The dropdown may be set to a width by using the `dropdownWidth()` method. Options correspond to [Tailwind's max-width scale](https://tailwindcss.com/docs/max-width). The options are `ExtraSmall`, `Small`, `Medium`, `Large`, `ExtraLarge`, `TwoExtraLarge`, `ThreeExtraLarge`, `FourExtraLarge`, `FiveExtraLarge`, `SixExtraLarge` and `SevenExtraLarge`: ```php +use Filament\Support\Enums\MaxWidth; + ActionGroup::make([ // Array of actions ]) - ->dropdownWidth('xs') + ->dropdownWidth(MaxWidth::ExtraSmall) ``` ## Controlling the maximum height of the dropdown diff --git a/packages/actions/src/Concerns/CanOpenModal.php b/packages/actions/src/Concerns/CanOpenModal.php index 19885bcb1e..ec2dd59894 100644 --- a/packages/actions/src/Concerns/CanOpenModal.php +++ b/packages/actions/src/Concerns/CanOpenModal.php @@ -7,6 +7,7 @@ use Filament\Actions\Contracts\HasRecord; use Filament\Actions\MountableAction; use Filament\Actions\StaticAction; use Filament\Support\Enums\Alignment; +use Filament\Support\Enums\MaxWidth; use Filament\Support\View\Components\Modal; use Illuminate\Contracts\Support\Htmlable; use Illuminate\Contracts\View\View; @@ -69,7 +70,7 @@ trait CanOpenModal protected string | Htmlable | Closure | null $modalDescription = null; - protected string | Closure | null $modalWidth = null; + protected MaxWidth | string | Closure | null $modalWidth = null; protected bool | Closure | null $isModalHidden = false; @@ -289,7 +290,7 @@ trait CanOpenModal return $this; } - public function modalWidth(string | Closure | null $width = null): static + public function modalWidth(MaxWidth | string | Closure | null $width = null): static { $this->modalWidth = $width; @@ -484,7 +485,7 @@ trait CanOpenModal public function getModalAlignment(): Alignment | string { - return $this->evaluate($this->modalAlignment) ?? (in_array($this->getModalWidth(), ['xs', 'sm']) ? Alignment::Center : Alignment::Start); + return $this->evaluate($this->modalAlignment) ?? (in_array($this->getModalWidth(), [MaxWidth::ExtraSmall, MaxWidth::Small, 'xs', 'sm'])) ? Alignment::Center : Alignment::Start; } public function getModalSubmitActionLabel(): string @@ -522,9 +523,9 @@ trait CanOpenModal return $this->evaluate($this->modalDescription); } - public function getModalWidth(): string + public function getModalWidth(): MaxWidth | string { - return $this->evaluate($this->modalWidth) ?? '4xl'; + return $this->evaluate($this->modalWidth) ?? MaxWidth::FourExtraLarge; } public function isModalFooterSticky(): bool diff --git a/packages/actions/src/Concerns/CanRequireConfirmation.php b/packages/actions/src/Concerns/CanRequireConfirmation.php index de1f5f710f..09775ee029 100644 --- a/packages/actions/src/Concerns/CanRequireConfirmation.php +++ b/packages/actions/src/Concerns/CanRequireConfirmation.php @@ -5,6 +5,7 @@ namespace Filament\Actions\Concerns; use Closure; use Filament\Actions\MountableAction; use Filament\Support\Enums\Alignment; +use Filament\Support\Enums\MaxWidth; use Filament\Support\Facades\FilamentIcon; trait CanRequireConfirmation @@ -16,7 +17,7 @@ trait CanRequireConfirmation $this->modalIcon(fn (MountableAction $action): ?string => $action->evaluate($condition) ? (FilamentIcon::resolve('actions::modal.confirmation') ?? 'heroicon-o-exclamation-triangle') : null); $this->modalDescription(fn (MountableAction $action): ?string => $action->evaluate($condition) ? __('filament-actions::modal.confirmation') : null); $this->modalSubmitActionLabel(fn (MountableAction $action): ?string => $action->evaluate($condition) ? __('filament-actions::modal.actions.confirm.label') : null); - $this->modalWidth(fn (MountableAction $action): ?string => $action->evaluate($condition) ? 'md' : null); + $this->modalWidth(fn (MountableAction $action): ?MaxWidth => $action->evaluate($condition) ? MaxWidth::Medium : null); return $this; } diff --git a/packages/actions/src/Concerns/HasDropdown.php b/packages/actions/src/Concerns/HasDropdown.php index ba0d9f4883..c421f2c3b8 100644 --- a/packages/actions/src/Concerns/HasDropdown.php +++ b/packages/actions/src/Concerns/HasDropdown.php @@ -3,6 +3,7 @@ namespace Filament\Actions\Concerns; use Closure; +use Filament\Support\Enums\MaxWidth; trait HasDropdown { @@ -12,7 +13,7 @@ trait HasDropdown protected string | Closure | null $dropdownMaxHeight = null; - protected string | Closure | null $dropdownWidth = null; + protected MaxWidth | string | Closure | null $dropdownWidth = null; public function dropdown(bool | Closure $condition = true): static { @@ -35,7 +36,7 @@ trait HasDropdown return $this; } - public function dropdownWidth(string | Closure | null $width): static + public function dropdownWidth(MaxWidth | string | Closure | null $width): static { $this->dropdownWidth = $width; @@ -52,7 +53,7 @@ trait HasDropdown return $this->evaluate($this->dropdownMaxHeight); } - public function getDropdownWidth(): ?string + public function getDropdownWidth(): MaxWidth | string | null { return $this->evaluate($this->dropdownWidth); } diff --git a/packages/forms/resources/views/component-container.blade.php b/packages/forms/resources/views/component-container.blade.php index 97e8d45500..416fa2b7e6 100644 --- a/packages/forms/resources/views/component-container.blade.php +++ b/packages/forms/resources/views/component-container.blade.php @@ -1,3 +1,7 @@ +@php + use Filament\Support\Enums\MaxWidth; +@endphp + getMaxWidth()) { - 'xs' => 'max-w-xs', - 'sm' => 'max-w-sm', - 'md' => 'max-w-md', - 'lg' => 'max-w-lg', - 'xl' => 'max-w-xl', - '2xl' => 'max-w-2xl', - '3xl' => 'max-w-3xl', - '4xl' => 'max-w-4xl', - '5xl' => 'max-w-5xl', - '6xl' => 'max-w-6xl', - '7xl' => 'max-w-7xl', + MaxWidth::ExtraSmall, 'xs' => 'max-w-xs', + MaxWidth::Small, 'sm' => 'max-w-sm', + MaxWidth::Medium, 'md' => 'max-w-md', + MaxWidth::Large, 'lg' => 'max-w-lg', + MaxWidth::ExtraLarge, 'xl' => 'max-w-xl', + MaxWidth::TwoExtraLarge, '2xl' => 'max-w-2xl', + MaxWidth::ThreeExtraLarge, '3xl' => 'max-w-3xl', + MaxWidth::FourExtraLarge, '4xl' => 'max-w-4xl', + MaxWidth::FiveExtraLarge, '5xl' => 'max-w-5xl', + MaxWidth::SixExtraLarge, '6xl' => 'max-w-6xl', + MaxWidth::SevenExtraLarge, '7xl' => 'max-w-7xl', default => $maxWidth, }, ]) diff --git a/packages/forms/src/Components/Builder.php b/packages/forms/src/Components/Builder.php index 3adbdea3f5..1f9ea9010e 100644 --- a/packages/forms/src/Components/Builder.php +++ b/packages/forms/src/Components/Builder.php @@ -7,6 +7,7 @@ use Filament\Forms\ComponentContainer; use Filament\Forms\Components\Actions\Action; use Filament\Forms\Components\Builder\Block; use Filament\Support\Enums\ActionSize; +use Filament\Support\Enums\MaxWidth; use Filament\Support\Facades\FilamentIcon; use Illuminate\Support\Arr; use Illuminate\Support\Str; @@ -76,7 +77,7 @@ class Builder extends Field implements Contracts\CanConcealComponents, Contracts */ protected ?array $blockPickerColumns = []; - protected string | Closure | null $blockPickerWidth = null; + protected MaxWidth | string | Closure | null $blockPickerWidth = null; protected function setUp(): void { @@ -871,14 +872,14 @@ class Builder extends Field implements Contracts\CanConcealComponents, Contracts return $columns; } - public function blockPickerWidth(string | Closure | null $width): static + public function blockPickerWidth(MaxWidth | string | Closure | null $width): static { $this->blockPickerWidth = $width; return $this; } - public function getBlockPickerWidth(): ?string + public function getBlockPickerWidth(): MaxWidth | string | null { $width = $this->evaluate($this->blockPickerWidth); diff --git a/packages/forms/src/Components/Concerns/HasMaxWidth.php b/packages/forms/src/Components/Concerns/HasMaxWidth.php index a9e72f5f2e..8154608c4e 100644 --- a/packages/forms/src/Components/Concerns/HasMaxWidth.php +++ b/packages/forms/src/Components/Concerns/HasMaxWidth.php @@ -3,19 +3,20 @@ namespace Filament\Forms\Components\Concerns; use Closure; +use Filament\Support\Enums\MaxWidth; trait HasMaxWidth { - protected string | Closure | null $maxWidth = null; + protected MaxWidth | string | Closure | null $maxWidth = null; - public function maxWidth(string | Closure | null $width): static + public function maxWidth(MaxWidth | string | Closure | null $width): static { $this->maxWidth = $width; return $this; } - public function getMaxWidth(): ?string + public function getMaxWidth(): MaxWidth | string | null { return $this->evaluate($this->maxWidth); } diff --git a/packages/infolists/docs/03-entries/03-icon.md b/packages/infolists/docs/03-entries/03-icon.md index 1ed65ace1e..a62fddef0d 100644 --- a/packages/infolists/docs/03-entries/03-icon.md +++ b/packages/infolists/docs/03-entries/03-icon.md @@ -44,7 +44,7 @@ In the function, `$state` is the value of the entry, and `$record` can be used t ## Customizing the size -The default icon size is `IconEntrySize::Large`, but you may customize the size to be either `IconEntrySize::ExtraSmall`, `IconEntrySize::Small`, `IconEntrySize::Medium`, `IconEntrySize::ExtraLarge` or `IconEntrySize::ExtraExtraLarge`: +The default icon size is `IconEntrySize::Large`, but you may customize the size to be either `IconEntrySize::ExtraSmall`, `IconEntrySize::Small`, `IconEntrySize::Medium`, `IconEntrySize::ExtraLarge` or `IconEntrySize::TwoExtraLarge`: ```php use Filament\Infolists\Components\IconEntry; diff --git a/packages/infolists/resources/views/component-container.blade.php b/packages/infolists/resources/views/component-container.blade.php index 251475af32..60ea850bf8 100644 --- a/packages/infolists/resources/views/component-container.blade.php +++ b/packages/infolists/resources/views/component-container.blade.php @@ -1,3 +1,7 @@ +@php + use Filament\Support\Enums\MaxWidth; +@endphp +
getMaxWidth()) { - 'xs' => 'max-w-xs', - 'sm' => 'max-w-sm', - 'md' => 'max-w-md', - 'lg' => 'max-w-lg', - 'xl' => 'max-w-xl', - '2xl' => 'max-w-2xl', - '3xl' => 'max-w-3xl', - '4xl' => 'max-w-4xl', - '5xl' => 'max-w-5xl', - '6xl' => 'max-w-6xl', - '7xl' => 'max-w-7xl', + MaxWidth::ExtraSmall, 'xs' => 'max-w-xs', + MaxWidth::Small, 'sm' => 'max-w-sm', + MaxWidth::Medium, 'md' => 'max-w-md', + MaxWidth::Large, 'lg' => 'max-w-lg', + MaxWidth::ExtraLarge, 'xl' => 'max-w-xl', + MaxWidth::TwoExtraLarge, '2xl' => 'max-w-2xl', + MaxWidth::ThreeExtraLarge, '3xl' => 'max-w-3xl', + MaxWidth::FourExtraLarge, '4xl' => 'max-w-4xl', + MaxWidth::FiveExtraLarge, '5xl' => 'max-w-5xl', + MaxWidth::SixExtraLarge, '6xl' => 'max-w-6xl', + MaxWidth::SevenExtraLarge, '7xl' => 'max-w-7xl', default => $maxWidth, }, ]) diff --git a/packages/infolists/resources/views/components/icon-entry.blade.php b/packages/infolists/resources/views/components/icon-entry.blade.php index 9628a495c6..f5a06a6cb0 100644 --- a/packages/infolists/resources/views/components/icon-entry.blade.php +++ b/packages/infolists/resources/views/components/icon-entry.blade.php @@ -30,7 +30,7 @@ IconEntrySize::Medium, 'md' => 'fi-in-icon-item-size-md h-5 w-5', IconEntrySize::Large, 'lg' => 'fi-in-icon-item-size-lg h-6 w-6', IconEntrySize::ExtraLarge, 'xl' => 'fi-in-icon-item-size-xl h-7 w-7', - IconEntrySize::ExtraExtraLarge, '2xl' => 'fi-in-icon-item-size-2xl h-8 w-8', + IconEntrySize::TwoExtraLarge, IconEntrySize::ExtraExtraLarge, '2xl' => 'fi-in-icon-item-size-2xl h-8 w-8', default => $size, }, match ($color) { diff --git a/packages/infolists/src/Components/Concerns/HasMaxWidth.php b/packages/infolists/src/Components/Concerns/HasMaxWidth.php index fc2cf32bdf..04396bf086 100644 --- a/packages/infolists/src/Components/Concerns/HasMaxWidth.php +++ b/packages/infolists/src/Components/Concerns/HasMaxWidth.php @@ -3,19 +3,20 @@ namespace Filament\Infolists\Components\Concerns; use Closure; +use Filament\Support\Enums\MaxWidth; trait HasMaxWidth { - protected string | Closure | null $maxWidth = null; + protected MaxWidth | string | Closure | null $maxWidth = null; - public function maxWidth(string | Closure | null $width): static + public function maxWidth(MaxWidth | string | Closure | null $width): static { $this->maxWidth = $width; return $this; } - public function getMaxWidth(): ?string + public function getMaxWidth(): MaxWidth | string | null { return $this->evaluate($this->maxWidth); } diff --git a/packages/infolists/src/Components/IconEntry/IconEntrySize.php b/packages/infolists/src/Components/IconEntry/IconEntrySize.php index 2d0ab724b3..2f84f4687c 100644 --- a/packages/infolists/src/Components/IconEntry/IconEntrySize.php +++ b/packages/infolists/src/Components/IconEntry/IconEntrySize.php @@ -14,5 +14,7 @@ enum IconEntrySize case ExtraLarge; + case TwoExtraLarge; + case ExtraExtraLarge; } diff --git a/packages/panels/docs/04-pages.md b/packages/panels/docs/04-pages.md index 8dffb41895..4ad0192c29 100644 --- a/packages/panels/docs/04-pages.md +++ b/packages/panels/docs/04-pages.md @@ -296,12 +296,14 @@ This example assumes you have a Blade view at `resources/views/filament/settings ## Customizing the maximum content width -By default, Filament will restrict the width of the content on the page, so it doesn't become too wide on large screens. To change this, you may override the `getMaxContentWidth()` method. Options correspond to [Tailwind's max-width scale](https://tailwindcss.com/docs/max-width). The options are `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`, `5xl`, `6xl`, `7xl`, `prose`, `screen-sm`, `screen-md`, `screen-lg`, `screen-xl`, `screen-2xl` and `full`. The default is `7xl`: +By default, Filament will restrict the width of the content on the page, so it doesn't become too wide on large screens. To change this, you may override the `getMaxContentWidth()` method. Options correspond to [Tailwind's max-width scale](https://tailwindcss.com/docs/max-width). The options are `ExtraSmall`, `Small`, `Medium`, `Large`, `ExtraLarge`, `TwoExtraLarge`, `ThreeExtraLarge`, `FourExtraLarge`, `FiveExtraLarge`, `SixExtraLarge`, `SevenExtraLarge`, `Prose`, `ScreenSmall`, `ScreenMedium`, `ScreenLarge`, `ScreenExtraLarge`, `ScreenTwoExtraLarge` and `Full`. The default is `SevenExtraLarge`: ```php -public function getMaxContentWidth(): ?string +use Filament\Support\Enums\MaxWidth; + +public function getMaxContentWidth(): MaxWidth { - return 'full'; + return MaxWidth::Full; } ``` diff --git a/packages/panels/docs/09-configuration.md b/packages/panels/docs/09-configuration.md index edc3ba581c..55437ecd60 100644 --- a/packages/panels/docs/09-configuration.md +++ b/packages/panels/docs/09-configuration.md @@ -100,16 +100,17 @@ public function panel(Panel $panel): Panel ## Customizing the maximum content width -By default, Filament will restrict the width of the content on a page, so it doesn't become too wide on large screens. To change this, you may use the `maxContentWidth()` method. Options correspond to [Tailwind's max-width scale](https://tailwindcss.com/docs/max-width). The options are `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`, `5xl`, `6xl`, `7xl`, `prose`, `screen-sm`, `screen-md`, `screen-lg`, `screen-xl`, `screen-2xl` and `full`. The default is `7xl`: +By default, Filament will restrict the width of the content on a page, so it doesn't become too wide on large screens. To change this, you may use the `maxContentWidth()` method. Options correspond to [Tailwind's max-width scale](https://tailwindcss.com/docs/max-width). The options are `ExtraSmall`, `Small`, `Medium`, `Large`, `ExtraLarge`, `TwoExtraLarge`, `ThreeExtraLarge`, `FourExtraLarge`, `FiveExtraLarge`, `SixExtraLarge`, `SevenExtraLarge`, `Prose`, `ScreenSmall`, `ScreenMedium`, `ScreenLarge`, `ScreenExtraLarge`, `ScreenTwoExtraLarge` and `Full`. The default is `SevenExtraLarge`: ```php use Filament\Panel; +use Filament\Support\Enums\MaxWidth; public function panel(Panel $panel): Panel { return $panel // ... - ->maxContentWidth('full'); + ->maxContentWidth(MaxWidth::Full); } ``` diff --git a/packages/panels/resources/views/components/layout/index.blade.php b/packages/panels/resources/views/components/layout/index.blade.php index 7ccf178632..da5fe43b07 100644 --- a/packages/panels/resources/views/components/layout/index.blade.php +++ b/packages/panels/resources/views/components/layout/index.blade.php @@ -1,4 +1,6 @@ @php + use Filament\Support\Enums\MaxWidth; + $navigation = filament()->getNavigation(); @endphp @@ -44,21 +46,21 @@
getMaxContentWidth() ?? '7xl')) { - 'xl' => 'max-w-xl', - '2xl' => 'max-w-2xl', - '3xl' => 'max-w-3xl', - '4xl' => 'max-w-4xl', - '5xl' => 'max-w-5xl', - '6xl' => 'max-w-6xl', - '7xl' => 'max-w-7xl', - 'prose' => 'max-w-prose', - 'screen-sm' => 'max-w-screen-sm', - 'screen-md' => 'max-w-screen-md', - 'screen-lg' => 'max-w-screen-lg', - 'screen-xl' => 'max-w-screen-xl', - 'screen-2xl' => 'max-w-screen-2xl', - 'full' => 'max-w-full', + match ($maxContentWidth ??= (filament()->getMaxContentWidth() ?? MaxWidth::SevenExtraLarge)) { + MaxWidth::ExtraLarge, 'xl' => 'max-w-xl', + MaxWidth::TwoExtraLarge, '2xl' => 'max-w-2xl', + MaxWidth::ThreeExtraLarge, '3xl' => 'max-w-3xl', + MaxWidth::FourExtraLarge, '4xl' => 'max-w-4xl', + MaxWidth::FiveExtraLarge, '5xl' => 'max-w-5xl', + MaxWidth::SixExtraLarge, '6xl' => 'max-w-6xl', + MaxWidth::SevenExtraLarge, '7xl' => 'max-w-7xl', + MaxWidth::Prose, 'prose' => 'max-w-prose', + MaxWidth::ScreenSmall, 'screen-sm' => 'max-w-screen-sm', + MaxWidth::ScreenMedium, 'screen-md' => 'max-w-screen-md', + MaxWidth::ScreenLarge, 'screen-lg' => 'max-w-screen-lg', + MaxWidth::ScreenExtraLarge, 'screen-xl' => 'max-w-screen-xl', + MaxWidth::ScreenTwoExtraLarge, 'screen-2xl' => 'max-w-screen-2xl', + MaxWidth::Full, 'full' => 'max-w-full', default => $maxContentWidth, }, ]) diff --git a/packages/panels/resources/views/components/layout/simple.blade.php b/packages/panels/resources/views/components/layout/simple.blade.php index 379955f327..0caa3060a9 100644 --- a/packages/panels/resources/views/components/layout/simple.blade.php +++ b/packages/panels/resources/views/components/layout/simple.blade.php @@ -1,3 +1,7 @@ +@php + use Filament\Support\Enums\MaxWidth; +@endphp + @props([ 'after' => null, @@ -25,17 +29,16 @@ @class([ 'fi-simple-main my-16 w-full bg-white px-6 py-12 shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10 sm:rounded-xl sm:px-12', match ($maxWidth ?? null) { - 'xs' => 'sm:max-w-xs', - 'sm' => 'sm:max-w-sm', - 'md' => 'sm:max-w-md', - 'lg' => 'sm:max-w-lg', - 'xl' => 'sm:max-w-xl', - '2xl' => 'sm:max-w-2xl', - '3xl' => 'sm:max-w-3xl', - '4xl' => 'sm:max-w-4xl', - '5xl' => 'sm:max-w-5xl', - '6xl' => 'sm:max-w-6xl', - '7xl' => 'sm:max-w-7xl', + MaxWidth::ExtraSmall, 'xs' => 'sm:max-w-xs', + MaxWidth::Small, 'sm' => 'sm:max-w-sm', + MaxWidth::Medium, 'md' => 'sm:max-w-md', + MaxWidth::ExtraLarge, 'xl' => 'sm:max-w-xl', + MaxWidth::TwoExtraLarge, '2xl' => 'sm:max-w-2xl', + MaxWidth::ThreeExtraLarge, '3xl' => 'sm:max-w-3xl', + MaxWidth::FourExtraLarge, '4xl' => 'sm:max-w-4xl', + MaxWidth::FiveExtraLarge, '5xl' => 'sm:max-w-5xl', + MaxWidth::SixExtraLarge, '6xl' => 'sm:max-w-6xl', + MaxWidth::SevenExtraLarge, '7xl' => 'sm:max-w-7xl', default => 'sm:max-w-lg', }, ]) diff --git a/packages/panels/src/Facades/Filament.php b/packages/panels/src/Facades/Filament.php index ac8eb9f941..9c68de8aa8 100644 --- a/packages/panels/src/Facades/Filament.php +++ b/packages/panels/src/Facades/Filament.php @@ -13,6 +13,7 @@ use Filament\Navigation\NavigationGroup; use Filament\Navigation\NavigationItem; use Filament\Panel; use Filament\Support\Assets\Theme; +use Filament\Support\Enums\MaxWidth; use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Contracts\Auth\CanResetPassword; use Illuminate\Contracts\Auth\MustVerifyEmail; @@ -48,7 +49,7 @@ use Illuminate\Support\Facades\Facade; * @method static string | null getHomeUrl() * @method static string | null getLoginUrl(array $parameters = []) * @method static string getLogoutUrl(array $parameters = []) - * @method static string | null getMaxContentWidth() + * @method static MaxWidth | string | null getMaxContentWidth() * @method static string | null getModelResource(string | Model $model) * @method static string getNameForDefaultAvatar(Model | Authenticatable $user) * @method static array getNavigation() @@ -120,11 +121,11 @@ class Filament extends Facade return 'filament'; } - public static function registerPanel(Panel $panel): void + public static function registerPanel(Panel | Closure $panel): void { static::getFacadeApplication()->resolving( static::getFacadeAccessor(), - fn (FilamentManager $filamentManager) => $filamentManager->registerPanel($panel), + fn (FilamentManager $filamentManager) => $filamentManager->registerPanel(value($panel)), ); } } diff --git a/packages/panels/src/FilamentManager.php b/packages/panels/src/FilamentManager.php index 4510d91904..d1e332ed6c 100644 --- a/packages/panels/src/FilamentManager.php +++ b/packages/panels/src/FilamentManager.php @@ -17,6 +17,7 @@ use Filament\Navigation\MenuItem; use Filament\Navigation\NavigationGroup; use Filament\Navigation\NavigationItem; use Filament\Support\Assets\Theme; +use Filament\Support\Enums\MaxWidth; use Filament\Support\Facades\FilamentAsset; use Filament\Support\Facades\FilamentView; use Filament\Widgets\Widget; @@ -203,7 +204,7 @@ class FilamentManager return $this->getCurrentPanel()->getLogoutUrl($parameters); } - public function getMaxContentWidth(): ?string + public function getMaxContentWidth(): MaxWidth | string | null { return $this->getCurrentPanel()->getMaxContentWidth(); } diff --git a/packages/panels/src/Listeners/Auth/SendEmailVerificationNotification.php b/packages/panels/src/Listeners/Auth/SendEmailVerificationNotification.php deleted file mode 100644 index 2851cc4a4a..0000000000 --- a/packages/panels/src/Listeners/Auth/SendEmailVerificationNotification.php +++ /dev/null @@ -1,35 +0,0 @@ -user instanceof MustVerifyEmail) { - return; - } - - if ($event->user->hasVerifiedEmail()) { - return; - } - - if (! method_exists($event->user, 'notify')) { - $userClass = $event->user::class; - - throw new Exception("Model [{$userClass}] does not have a [notify()] method."); - } - - $notification = new VerifyEmail(); - $notification->url = Filament::getVerifyEmailUrl($event->user); - - $event->user->notify($notification); - } -} diff --git a/packages/panels/src/Pages/Auth/Register.php b/packages/panels/src/Pages/Auth/Register.php index 107693489b..0929a2cbb9 100644 --- a/packages/panels/src/Pages/Auth/Register.php +++ b/packages/panels/src/Pages/Auth/Register.php @@ -4,6 +4,7 @@ namespace Filament\Pages\Auth; use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException; use DanHarrin\LivewireRateLimiting\WithRateLimiting; +use Exception; use Filament\Actions\Action; use Filament\Actions\ActionGroup; use Filament\Facades\Filament; @@ -11,13 +12,15 @@ use Filament\Forms\Components\Component; use Filament\Forms\Components\TextInput; use Filament\Forms\Form; use Filament\Http\Responses\Auth\Contracts\RegistrationResponse; +use Filament\Notifications\Auth\VerifyEmail; use Filament\Notifications\Notification; use Filament\Pages\Concerns\InteractsWithFormActions; use Filament\Pages\SimplePage; use Illuminate\Auth\EloquentUserProvider; -use Illuminate\Auth\Events\Registered; use Illuminate\Auth\SessionGuard; +use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Contracts\Support\Htmlable; +use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Hash; use Illuminate\Validation\Rules\Password; @@ -74,11 +77,7 @@ class Register extends SimplePage $user = $this->getUserModel()::create($data); - app()->bind( - \Illuminate\Auth\Listeners\SendEmailVerificationNotification::class, - \Filament\Listeners\Auth\SendEmailVerificationNotification::class, - ); - event(new Registered($user)); + $this->sendEmailVerificationNotification($user); Filament::auth()->login($user); @@ -87,6 +86,28 @@ class Register extends SimplePage return app(RegistrationResponse::class); } + protected function sendEmailVerificationNotification(Model $user): void + { + if (! $user instanceof MustVerifyEmail) { + return; + } + + if ($user->hasVerifiedEmail()) { + return; + } + + if (! method_exists($user, 'notify')) { + $userClass = $user::class; + + throw new Exception("Model [{$userClass}] does not have a [notify()] method."); + } + + $notification = new VerifyEmail(); + $notification->url = Filament::getVerifyEmailUrl($user); + + $user->notify($notification); + } + public function form(Form $form): Form { return $form; diff --git a/packages/panels/src/Pages/BasePage.php b/packages/panels/src/Pages/BasePage.php index 3fa1bc65d0..b35bbeb7dc 100644 --- a/packages/panels/src/Pages/BasePage.php +++ b/packages/panels/src/Pages/BasePage.php @@ -10,6 +10,7 @@ use Filament\Forms\Contracts\HasForms; use Filament\Infolists\Concerns\InteractsWithInfolists; use Filament\Infolists\Contracts\HasInfolists; use Filament\Support\Enums\Alignment; +use Filament\Support\Enums\MaxWidth; use Filament\Support\Exceptions\Halt; use Illuminate\Contracts\Support\Htmlable; use Illuminate\Contracts\View\View; @@ -70,7 +71,7 @@ abstract class BasePage extends Component implements HasActions, HasForms, HasIn ->title(); } - public function getMaxContentWidth(): ?string + public function getMaxContentWidth(): MaxWidth | string | null { return $this->maxContentWidth; } diff --git a/packages/panels/src/Pages/SimplePage.php b/packages/panels/src/Pages/SimplePage.php index 4dc0aa8793..35ea4891a8 100644 --- a/packages/panels/src/Pages/SimplePage.php +++ b/packages/panels/src/Pages/SimplePage.php @@ -2,6 +2,8 @@ namespace Filament\Pages; +use Filament\Support\Enums\MaxWidth; + abstract class SimplePage extends BasePage { protected static string $layout = 'filament-panels::components.layout.simple'; @@ -15,7 +17,7 @@ abstract class SimplePage extends BasePage ]; } - public function getMaxWidth(): ?string + public function getMaxWidth(): MaxWidth | string | null { return $this->maxWidth; } diff --git a/packages/panels/src/Panel/Concerns/HasMaxContentWidth.php b/packages/panels/src/Panel/Concerns/HasMaxContentWidth.php index b83195dce2..1530f77d17 100644 --- a/packages/panels/src/Panel/Concerns/HasMaxContentWidth.php +++ b/packages/panels/src/Panel/Concerns/HasMaxContentWidth.php @@ -2,18 +2,20 @@ namespace Filament\Panel\Concerns; +use Filament\Support\Enums\MaxWidth; + trait HasMaxContentWidth { - protected ?string $maxContentWidth = null; + protected MaxWidth | string | null $maxContentWidth = null; - public function maxContentWidth(?string $maxContentWidth): static + public function maxContentWidth(MaxWidth | string | null $maxContentWidth): static { $this->maxContentWidth = $maxContentWidth; return $this; } - public function getMaxContentWidth(): ?string + public function getMaxContentWidth(): MaxWidth | string | null { return $this->maxContentWidth; } diff --git a/packages/panels/src/PanelProvider.php b/packages/panels/src/PanelProvider.php index 802c59a1bf..d66ab20a6b 100644 --- a/packages/panels/src/PanelProvider.php +++ b/packages/panels/src/PanelProvider.php @@ -12,7 +12,7 @@ abstract class PanelProvider extends ServiceProvider public function register(): void { Filament::registerPanel( - $this->panel(Panel::make()), + fn (): Panel => $this->panel(Panel::make()), ); } } diff --git a/packages/support/resources/views/components/dropdown/index.blade.php b/packages/support/resources/views/components/dropdown/index.blade.php index 5fa180e8cf..f7fdf8ea85 100644 --- a/packages/support/resources/views/components/dropdown/index.blade.php +++ b/packages/support/resources/views/components/dropdown/index.blade.php @@ -8,6 +8,10 @@ 'width' => null, ]) +@php + use Filament\Support\Enums\MaxWidth; +@endphp +