Merge branch '3.x' into 3.1

This commit is contained in:
Dan Harrin
2023-11-25 23:44:43 +00:00
36 changed files with 252 additions and 174 deletions
+4 -2
View File
@@ -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
+4 -2
View File
@@ -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
@@ -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
@@ -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;
}
@@ -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);
}
@@ -1,3 +1,7 @@
@php
use Filament\Support\Enums\MaxWidth;
@endphp
<x-filament::grid
:default="$getColumns('default')"
:sm="$getColumns('sm')"
@@ -39,17 +43,17 @@
:twoXlStart="$formComponent->getColumnStart('2xl')"
@class([
match ($maxWidth = $formComponent->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,
},
])
+4 -3
View File
@@ -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);
@@ -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);
}
@@ -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;
@@ -1,3 +1,7 @@
@php
use Filament\Support\Enums\MaxWidth;
@endphp
<dl>
<x-filament::grid
:default="$getColumns('default')"
@@ -24,17 +28,17 @@
:twoXlStart="$infolistComponent->getColumnStart('2xl')"
@class([
match ($maxWidth = $infolistComponent->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,
},
])
@@ -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) {
@@ -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);
}
@@ -14,5 +14,7 @@ enum IconEntrySize
case ExtraLarge;
case TwoExtraLarge;
case ExtraExtraLarge;
}
+5 -3
View File
@@ -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;
}
```
+3 -2
View File
@@ -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);
}
```
@@ -1,4 +1,6 @@
@php
use Filament\Support\Enums\MaxWidth;
$navigation = filament()->getNavigation();
@endphp
@@ -44,21 +46,21 @@
<main
@class([
'fi-main mx-auto h-full w-full px-4 md:px-6 lg:px-8',
match ($maxContentWidth ??= (filament()->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,
},
])
@@ -1,3 +1,7 @@
@php
use Filament\Support\Enums\MaxWidth;
@endphp
<x-filament-panels::layout.base :livewire="$livewire">
@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',
},
])
+4 -3
View File
@@ -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<NavigationGroup> 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)),
);
}
}
+2 -1
View File
@@ -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();
}
@@ -1,35 +0,0 @@
<?php
namespace Filament\Listeners\Auth;
use Exception;
use Filament\Facades\Filament;
use Filament\Notifications\Auth\VerifyEmail;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification as BaseListener;
use Illuminate\Contracts\Auth\MustVerifyEmail;
class SendEmailVerificationNotification extends BaseListener
{
public function handle(Registered $event): void
{
if (! $event->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);
}
}
+27 -6
View File
@@ -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;
+2 -1
View File
@@ -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;
}
+3 -1
View File
@@ -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;
}
@@ -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;
}
+1 -1
View File
@@ -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()),
);
}
}
@@ -8,6 +8,10 @@
'width' => null,
])
@php
use Filament\Support\Enums\MaxWidth;
@endphp
<div
x-data="{
toggle: function (event) {
@@ -44,17 +48,17 @@
@class([
'fi-dropdown-panel absolute z-10 w-screen divide-y divide-gray-100 rounded-lg bg-white shadow-lg ring-1 ring-gray-950/5 transition dark:divide-white/5 dark:bg-gray-900 dark:ring-white/10',
match ($width) {
'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',
null => 'max-w-[14rem]',
default => $width,
},
@@ -1,5 +1,6 @@
@php
use Filament\Support\Enums\Alignment;
use Filament\Support\Enums\MaxWidth;
@endphp
@props([
@@ -159,18 +160,18 @@
'mx-auto rounded-xl' => ! ($slideOver || ($width === 'screen')),
'hidden' => ! $visible,
match ($width) {
'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',
'screen' => 'fixed inset-0',
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',
MaxWidth::Screen, 'screen' => 'fixed inset-0',
default => $width,
},
])
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace Filament\Support\Enums;
enum MaxWidth
{
case ExtraSmall;
case Small;
case Medium;
case Large;
case ExtraLarge;
case TwoExtraLarge;
case ThreeExtraLarge;
case FourExtraLarge;
case FiveExtraLarge;
case SixExtraLarge;
case SevenExtraLarge;
case Prose;
case Screen;
case ScreenSmall;
case ScreenMedium;
case ScreenLarge;
case ScreenExtraLarge;
case ScreenTwoExtraLarge;
case Full;
}
+1 -1
View File
@@ -44,7 +44,7 @@ In the function, `$state` is the value of the column, and `$record` can be used
## Customizing the size
The default icon size is `IconColumnSize::Large`, but you may customize the size to be either `IconColumnSize::ExtraSmall`, `IconColumnSize::Small`, `IconColumnSize::Medium`, `IconColumnSize::ExtraLarge` or `IconColumnSize::ExtraExtraLarge`:
The default icon size is `IconColumnSize::Large`, but you may customize the size to be either `IconColumnSize::ExtraSmall`, `IconColumnSize::Small`, `IconColumnSize::Medium`, `IconColumnSize::ExtraLarge` or `IconColumnSize::TwoExtraLarge`:
```php
use Filament\Tables\Columns\IconColumn;
@@ -31,7 +31,7 @@
IconColumnSize::Medium, 'md' => 'fi-ta-icon-item-size-md h-5 w-5',
IconColumnSize::Large, 'lg' => 'fi-ta-icon-item-size-lg h-6 w-6',
IconColumnSize::ExtraLarge, 'xl' => 'fi-ta-icon-item-size-xl h-7 w-7',
IconColumnSize::ExtraExtraLarge, '2xl' => 'fi-ta-icon-item-size-2xl h-8 w-8',
IconColumnSize::TwoExtraLarge, IconColumnSize::ExtraExtraLarge, '2xl' => 'fi-ta-icon-item-size-2xl h-8 w-8',
default => $size,
},
match ($color) {
@@ -6,6 +6,7 @@ use Closure;
use Filament\Actions\Concerns\CanCustomizeProcess;
use Filament\Forms\Components\Select;
use Filament\Forms\Form;
use Filament\Support\Enums\MaxWidth;
use Filament\Tables\Table;
use Illuminate\Database\Connection;
use Illuminate\Database\Eloquent\Builder;
@@ -52,7 +53,7 @@ class AssociateAction extends Action
$this->modalSubmitActionLabel(__('filament-actions::associate.single.modal.actions.associate.label'));
$this->modalWidth('lg');
$this->modalWidth(MaxWidth::Large);
$this->extraModalFooterActions(function (): array {
return $this->canAssociateAnother ? [
+2 -1
View File
@@ -6,6 +6,7 @@ use Closure;
use Filament\Actions\Concerns\CanCustomizeProcess;
use Filament\Forms\Components\Select;
use Filament\Forms\Form;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Services\RelationshipJoiner;
use Filament\Tables\Table;
use Illuminate\Database\Connection;
@@ -52,7 +53,7 @@ class AttachAction extends Action
$this->modalSubmitActionLabel(__('filament-actions::attach.single.modal.actions.attach.label'));
$this->modalWidth('lg');
$this->modalWidth(MaxWidth::Large);
$this->extraModalFooterActions(function (): array {
return $this->canAttachAnother() ? [
@@ -14,5 +14,7 @@ enum IconColumnSize
case ExtraLarge;
case TwoExtraLarge;
case ExtraExtraLarge;
}
@@ -5,6 +5,7 @@ namespace Filament\Tables\Table\Concerns;
use Closure;
use Filament\Forms\Form;
use Filament\Support\Enums\ActionSize;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Facades\FilamentIcon;
use Filament\Tables\Actions\Action;
@@ -17,7 +18,7 @@ trait CanToggleColumns
protected string | Closure | null $columnToggleFormMaxHeight = null;
protected string | Closure | null $columnToggleFormWidth = null;
protected MaxWidth | string | Closure | null $columnToggleFormWidth = null;
protected ?Closure $modifyToggleColumnsTriggerActionUsing = null;
@@ -45,7 +46,7 @@ trait CanToggleColumns
return $this;
}
public function columnToggleFormWidth(string | Closure | null $width): static
public function columnToggleFormWidth(MaxWidth | string | Closure | null $width): static
{
$this->columnToggleFormWidth = $width;
@@ -93,12 +94,12 @@ trait CanToggleColumns
return $this->evaluate($this->columnToggleFormMaxHeight);
}
public function getColumnToggleFormWidth(): ?string
public function getColumnToggleFormWidth(): MaxWidth | string | null
{
return $this->evaluate($this->columnToggleFormWidth) ?? match ($this->getColumnToggleFormColumns()) {
2 => '2xl',
3 => '4xl',
4 => '6xl',
2 => MaxWidth::TwoExtraLarge,
3 => MaxWidth::FourExtraLarge,
4 => MaxWidth::SixExtraLarge,
default => null,
};
}
@@ -5,6 +5,7 @@ namespace Filament\Tables\Table\Concerns;
use Closure;
use Filament\Forms\Form;
use Filament\Support\Enums\ActionSize;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Facades\FilamentIcon;
use Filament\Tables\Actions\Action;
use Filament\Tables\Enums\FiltersLayout;
@@ -24,7 +25,7 @@ trait HasFilters
protected string | Closure | null $filtersFormMaxHeight = null;
protected string | Closure | null $filtersFormWidth = null;
protected MaxWidth | string | Closure | null $filtersFormWidth = null;
protected FiltersLayout | Closure | null $filtersLayout = null;
@@ -87,7 +88,7 @@ trait HasFilters
return $this;
}
public function filtersFormWidth(string | Closure | null $width): static
public function filtersFormWidth(MaxWidth | string | Closure | null $width): static
{
$this->filtersFormWidth = $width;
@@ -188,12 +189,12 @@ trait HasFilters
return $this->evaluate($this->filtersFormMaxHeight);
}
public function getFiltersFormWidth(): ?string
public function getFiltersFormWidth(): MaxWidth | string | null
{
return $this->evaluate($this->filtersFormWidth) ?? match ($this->getFiltersFormColumns()) {
2 => '2xl',
3 => '4xl',
4 => '6xl',
2 => MaxWidth::TwoExtraLarge,
3 => MaxWidth::FourExtraLarge,
4 => MaxWidth::SixExtraLarge,
default => null,
};
}
+9 -7
View File
@@ -1,11 +1,11 @@
<?php
use Filament\Facades\Filament;
use Filament\Notifications\Auth\VerifyEmail;
use Filament\Pages\Auth\Register;
use Filament\Tests\Models\User;
use Filament\Tests\TestCase;
use Illuminate\Auth\Events\Registered;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Str;
use function Filament\Tests\livewire;
@@ -18,7 +18,7 @@ it('can render page', function () {
});
it('can register', function () {
Event::fake();
Notification::fake();
$this->assertGuest();
@@ -36,7 +36,7 @@ it('can register', function () {
->call('register')
->assertRedirect(Filament::getUrl());
Event::assertDispatched(Registered::class);
Notification::assertSentTimes(VerifyEmail::class, expectedCount: 1);
$this->assertAuthenticated();
@@ -47,6 +47,8 @@ it('can register', function () {
});
it('can register and redirect user to their intended URL', function () {
Notification::fake();
session()->put('url.intended', $intendedUrl = Str::random());
Filament::getCurrentPanel()->requiresEmailVerification(false);
@@ -65,7 +67,7 @@ it('can register and redirect user to their intended URL', function () {
});
it('can throttle registration attempts', function () {
Event::fake();
Notification::fake();
$this->assertGuest();
@@ -87,7 +89,7 @@ it('can throttle registration attempts', function () {
auth()->logout();
}
Event::assertDispatchedTimes(Registered::class, times: 2);
Notification::assertSentTimes(VerifyEmail::class, expectedCount: 2);
livewire(Register::class)
->fillForm([
@@ -100,7 +102,7 @@ it('can throttle registration attempts', function () {
->assertNotified()
->assertNoRedirect();
Event::assertDispatchedTimes(Registered::class, times: 2);
Notification::assertSentTimes(VerifyEmail::class, expectedCount: 2);
$this->assertGuest();
});