Integrate component actions

This commit is contained in:
Dan Harrin
2024-03-25 10:23:21 +00:00
parent 7d8ea110d7
commit 42dfd33ad5
54 changed files with 166 additions and 234 deletions
@@ -2,7 +2,7 @@
namespace App\Livewire\Forms;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\CheckboxList;
@@ -2,8 +2,8 @@
namespace App\Livewire\Forms;
use Filament\Forms\Components\Actions;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Components\Actions;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\Fieldset;
use Filament\Forms\Components\Grid;
+46 -6
View File
@@ -2,18 +2,28 @@
namespace Filament\Actions;
use Exception;
use Filament\Components\Actions\ActionContainer;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Js;
class Action extends MountableAction implements Contracts\Groupable, Contracts\HasRecord
{
use Concerns\BelongsToComponent;
use Concerns\CanSubmitForm;
use Concerns\HasMountableArguments;
use Concerns\InteractsWithRecord;
public function getLivewireCallMountedActionName(): string
{
return 'callMountedAction';
return $this->getComponent() ?
'callMountedFormComponentAction' :
'callMountedAction';
}
public function getLivewire(): object
{
return $this->getComponent()?->getLivewire() ?? parent::getLivewire();
}
public function getLivewireClickHandler(): ?string
@@ -37,7 +47,21 @@ class Action extends MountableAction implements Contracts\Groupable, Contracts\H
$argumentsParameter .= Js::from($arguments);
}
return "mountAction('{$this->getName()}'{$argumentsParameter})";
$component = $this->getComponent();
if (! $component) {
return "mountAction('{$this->getName()}'{$argumentsParameter})";
}
$componentKey = $component->getKey();
if (blank($componentKey)) {
$componentClass = $this->getComponent()::class;
throw new Exception("The component [{$componentClass}] must have a [key()] set in order to use actions. This [key()] must be a unique identifier for the component.");
}
return "mountFormComponentAction('{$componentKey}', '{$this->getName()}'{$argumentsParameter})";
}
/**
@@ -46,8 +70,13 @@ class Action extends MountableAction implements Contracts\Groupable, Contracts\H
protected function resolveDefaultClosureDependencyForEvaluationByName(string $parameterName): array
{
return match ($parameterName) {
'model' => [$this->getModel()],
'record' => [$this->getRecord()],
'component' => [$this->getComponent()],
'context', 'operation' => [$this->getComponent()->getContainer()->getOperation()],
'get' => [$this->getComponent()->makeGetUtility()],
'model' => [$this->getModel() ?? $this->getComponent()?->getModel()],
'record' => [$this->getRecord() ?? $this->getComponent()?->getRecord()],
'set' => [$this->getComponent()->makeSetUtility()],
'state' => [$this->getComponent()->getState()],
default => parent::resolveDefaultClosureDependencyForEvaluationByName($parameterName),
};
}
@@ -57,7 +86,7 @@ class Action extends MountableAction implements Contracts\Groupable, Contracts\H
*/
protected function resolveDefaultClosureDependencyForEvaluationByType(string $parameterType): array
{
$record = $this->getRecord();
$record = $this->getRecord() ?? $this->getComponent()?->getRecord();
if (! $record) {
return parent::resolveDefaultClosureDependencyForEvaluationByType($parameterType);
@@ -85,6 +114,17 @@ class Action extends MountableAction implements Contracts\Groupable, Contracts\H
public function getInfolistName(): string
{
return 'mountedActionInfolist';
return $this->getComponent() ?
'mountedFormComponentActionInfolist' :
'mountedActionInfolist';
}
public function toFormComponent(): ActionContainer
{
$component = ActionContainer::make($this);
$this->component($component);
return $component;
}
}
@@ -0,0 +1,23 @@
<?php
namespace Filament\Actions\Concerns;
use Filament\Components\Component;
use Filament\Forms\Contracts\HasForms;
trait BelongsToComponent
{
protected ?Component $component = null;
public function component(?Component $component = null): static
{
$this->component = $component;
return $this;
}
public function getComponent(): ?Component
{
return $this->component;
}
}
+1 -2
View File
@@ -624,8 +624,7 @@ This field uses action objects for easy customization of buttons within it. You
Here is an example of how you might customize an action:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Select;
use Filament\Actions\Action;use Filament\Forms\Components\Select;
Select::make('author_id')
->relationship(name: 'author', titleAttribute: 'name')
@@ -309,8 +309,7 @@ This field uses action objects for easy customization of buttons within it. You
Here is an example of how you might customize an action:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\CheckboxList;
use Filament\Actions\Action;use Filament\Forms\Components\CheckboxList;
CheckboxList::make('technologies')
->options([
+3 -8
View File
@@ -581,8 +581,7 @@ This field uses action objects for easy customization of buttons within it. You
Here is an example of how you might customize an action:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Repeater;
use Filament\Actions\Action;use Filament\Forms\Components\Repeater;
Repeater::make('members')
->schema([
@@ -598,8 +597,7 @@ Repeater::make('members')
You can confirm actions with a modal by using the `requiresConfirmation()` method on the action object. You may use any [modal customization method](../../actions/modals) to change its content and behaviour:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Repeater;
use Filament\Actions\Action;use Filament\Forms\Components\Repeater;
Repeater::make('members')
->schema([
@@ -617,10 +615,7 @@ Repeater::make('members')
You may add new [action buttons](../actions) to the header of each repeater item by passing `Action` objects into `extraItemActions()`:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Facades\Mail;
use Filament\Actions\Action;use Filament\Forms\Components\Repeater;use Filament\Forms\Components\TextInput;use Illuminate\Support\Facades\Mail;
Repeater::make('members')
->schema([
+3 -8
View File
@@ -373,8 +373,7 @@ This field uses action objects for easy customization of buttons within it. You
Here is an example of how you might customize an action:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Builder;
use Filament\Actions\Action;use Filament\Forms\Components\Builder;
Builder::make('content')
->blocks([
@@ -390,8 +389,7 @@ Builder::make('content')
You can confirm actions with a modal by using the `requiresConfirmation()` method on the action object. You may use any [modal customization method](../../actions/modals) to change its content and behaviour:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Builder;
use Filament\Actions\Action;use Filament\Forms\Components\Builder;
Builder::make('content')
->blocks([
@@ -409,10 +407,7 @@ Builder::make('content')
You may add new [action buttons](../actions) to the header of each builder item by passing `Action` objects into `extraItemActions()`:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Facades\Mail;
use Filament\Actions\Action;use Filament\Forms\Components\Builder;use Filament\Forms\Components\TextInput;use Illuminate\Support\Facades\Mail;
Builder::make('content')
->blocks([
@@ -165,8 +165,7 @@ This field uses action objects for easy customization of buttons within it. You
Here is an example of how you might customize an action:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\KeyValue;
use Filament\Actions\Action;use Filament\Forms\Components\KeyValue;
KeyValue::make('meta')
->deleteAction(
+1 -2
View File
@@ -213,8 +213,7 @@ This component uses action objects for easy customization of buttons within it.
Here is an example of how you might customize an action:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Wizard;
use Filament\Actions\Action;use Filament\Forms\Components\Wizard;
Wizard::make([
// ...
+3 -7
View File
@@ -41,8 +41,7 @@ Sections can have actions in their [header](#adding-actions-to-the-sections-head
You may add [actions](../actions) to the section's header using the `headerActions()` method:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Section;
use Filament\Actions\Action;use Filament\Forms\Components\Section;
Section::make('Rate limiting')
->headerActions([
@@ -65,8 +64,7 @@ Section::make('Rate limiting')
In addition to [header actions](#adding-an-icon-to-the-sections-header), you may add [actions](../actions) to the section's footer using the `footerActions()` method:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Section;
use Filament\Actions\Action;use Filament\Forms\Components\Section;
Section::make('Rate limiting')
->schema([
@@ -89,9 +87,7 @@ Section::make('Rate limiting')
Footer actions are aligned to the inline start by default. You may customize the alignment using the `footerActionsAlignment()` method:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Section;
use Filament\Support\Enums\Alignment;
use Filament\Actions\Action;use Filament\Forms\Components\Section;use Filament\Support\Enums\Alignment;
Section::make('Rate limiting')
->schema([
+11 -19
View File
@@ -12,8 +12,7 @@ Filament's forms can use [Actions](../actions). They are buttons that can be add
Action objects inside a form component are instances of `Filament/Forms/Components/Actions/Action`. You must pass a unique name to the action's `make()` method, which is used to identify it amongst others internally within Filament. You can [customize the trigger button](../actions/trigger-button) of an action, and even [open a modal](../actions/modals) with little effort:
```php
use App\Actions\ResetStars;
use Filament\Forms\Components\Actions\Action;
use App\Actions\ResetStars;use Filament\Actions\Action;
Action::make('resetStars')
->icon('heroicon-m-x-mark')
@@ -36,7 +35,7 @@ Certain fields support "affix actions", which are buttons that can be placed bef
To define an affix action, you can pass it to either `prefixAction()` or `suffixAction()`:
```php
use Filament\Components\Utilities\Set;use Filament\Forms\Components\Actions\Action;use Filament\Forms\Components\TextInput;
use Filament\Actions\Action;use Filament\Components\Utilities\Set;use Filament\Forms\Components\TextInput;
TextInput::make('cost')
->prefix('€')
@@ -59,8 +58,7 @@ Notice `$set` and `$state` injected into the `action()` function in this example
You may pass multiple affix actions to a field by passing them in an array to either `prefixActions()` or `suffixActions()`. Either method can be used, or both at once, Filament will render all the registered actions in order:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Actions\Action;use Filament\Forms\Components\TextInput;
TextInput::make('cost')
->prefix('€')
@@ -80,7 +78,7 @@ TextInput::make('cost')
All fields support "hint actions", which are rendered aside the field's [hint](fields/getting-started#adding-a-hint-next-to-the-label). To add a hint action to a field, you may pass it to `hintAction()`:
```php
use Filament\Components\Utilities\Set;use Filament\Forms\Components\Actions\Action;use Filament\Forms\Components\TextInput;
use Filament\Actions\Action;use Filament\Components\Utilities\Set;use Filament\Forms\Components\TextInput;
TextInput::make('cost')
->prefix('€')
@@ -103,8 +101,7 @@ Notice `$set` and `$state` injected into the `action()` function in this example
You may pass multiple hint actions to a field by passing them in an array to `hintActions()`. Filament will render all the registered actions in order:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Actions\Action;use Filament\Forms\Components\TextInput;
TextInput::make('cost')
->prefix('€')
@@ -120,7 +117,7 @@ TextInput::make('cost')
If you wish to render an action within a custom form component, `ViewField` object, or `View` component object, you may do so using the `registerActions()` method:
```php
use Filament\Components\Utilities\Set;use Filament\Forms\Components\Actions\Action;use Filament\Forms\Components\ViewField;
use Filament\Actions\Action;use Filament\Components\Utilities\Set;use Filament\Forms\Components\ViewField;
ViewField::make('rating')
->view('filament.forms.components.range-slider')
@@ -150,10 +147,7 @@ Now, to render the action in the view of the custom component, you need to call
You may use an `Actions` component to render a set of actions anywhere in the form, avoiding the need to register them to any particular component:
```php
use App\Actions\Star;
use App\Actions\ResetStars;
use Filament\Forms\Components\Actions;
use Filament\Forms\Components\Actions\Action;
use App\Actions\ResetStars;use App\Actions\Star;use Filament\Actions\Action;use Filament\Components\Actions;
Actions::make([
Action::make('star')
@@ -179,7 +173,7 @@ Actions::make([
You can stretch the independent form actions to consume the full width of the form using `fullWidth()`:
```php
use Filament\Forms\Components\Actions;
use Filament\Components\Actions;
Actions::make([
// ...
@@ -193,8 +187,7 @@ Actions::make([
Independent form actions are aligned to the start of the component by default. You may change this by passing `Alignment::Center` or `Alignment::End` to `alignment()`:
```php
use Filament\Forms\Components\Actions;
use Filament\Support\Enums\Alignment;
use Filament\Components\Actions;use Filament\Support\Enums\Alignment;
Actions::make([
// ...
@@ -208,8 +201,7 @@ Actions::make([
Independent form actions are vertically aligned to the start of the component by default. You may change this by passing `Alignment::Center` or `Alignment::End` to `verticalAlignment()`:
```php
use Filament\Forms\Components\Actions;
use Filament\Support\Enums\VerticalAlignment;
use Filament\Components\Actions;use Filament\Support\Enums\VerticalAlignment;
Actions::make([
// ...
@@ -223,7 +215,7 @@ Actions::make([
If an action is attached to a form component, the `action()` function is able to [inject utilities](advanced#form-component-utility-injection) directly from that form component. For instance, you can inject [`$set`](advanced#injecting-a-function-to-set-the-state-of-another-field) and [`$state`](advanced#injecting-the-current-state-of-a-field):
```php
use Filament\Components\Utilities\Set;use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;use Filament\Components\Utilities\Set;
Action::make('copyCostToPrice')
->icon('heroicon-m-clipboard')
@@ -1,5 +1,5 @@
@php
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
$containers = $getChildComponentContainers();
$blockPickerBlocks = $getBlockPickerBlocks();
@@ -43,7 +43,7 @@
$hintActions = array_filter(
$hintActions ?? [],
fn (\Filament\Forms\Components\Actions\Action $hintAction): bool => $hintAction->isVisible(),
fn (\Filament\Actions\Action $hintAction): bool => $hintAction->isVisible(),
);
$hasError = filled($statePath) && ($errors->has($statePath) || ($hasNestedRecursiveValidationRules && $errors->has("{$statePath}.*")));
@@ -1,5 +1,5 @@
@php
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
$containers = $getChildComponentContainers();
@@ -1,101 +0,0 @@
<?php
namespace Filament\Forms\Components\Actions;
use Exception;
use Filament\Actions\Concerns\HasMountableArguments;
use Filament\Actions\MountableAction;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Js;
class Action extends MountableAction
{
use Concerns\BelongsToComponent;
use HasMountableArguments;
public function getLivewireCallMountedActionName(): string
{
return 'callMountedFormComponentAction';
}
public function getLivewireClickHandler(): ?string
{
if (! $this->isLivewireClickHandlerEnabled()) {
return null;
}
if (is_string($this->action)) {
return $this->action;
}
if ($event = $this->getLivewireEventClickHandler()) {
return $event;
}
$argumentsParameter = '';
if (count($arguments = $this->getArguments())) {
$argumentsParameter .= ', ';
$argumentsParameter .= Js::from($arguments);
$argumentsParameter .= '';
}
$componentKey = $this->getComponent()->getKey();
if (blank($componentKey)) {
$componentClass = $this->getComponent()::class;
throw new Exception("The form component [{$componentClass}] must have a [key()] set in order to use actions. This [key()] must be a unique identifier for the component.");
}
return "mountFormComponentAction('{$componentKey}', '{$this->getName()}'{$argumentsParameter})";
}
public function toFormComponent(): ActionContainer
{
$component = ActionContainer::make($this);
$this->component($component);
return $component;
}
/**
* @return array<mixed>
*/
protected function resolveDefaultClosureDependencyForEvaluationByName(string $parameterName): array
{
return match ($parameterName) {
'component' => [$this->getComponent()],
'context', 'operation' => [$this->getComponent()->getContainer()->getOperation()],
'get' => [$this->getComponent()->getGetCallback()],
'model' => [$this->getComponent()->getModel()],
'record' => [$this->getComponent()->getRecord()],
'set' => [$this->getComponent()->getSetCallback()],
'state' => [$this->getComponent()->getState()],
default => parent::resolveDefaultClosureDependencyForEvaluationByName($parameterName),
};
}
/**
* @return array<mixed>
*/
protected function resolveDefaultClosureDependencyForEvaluationByType(string $parameterType): array
{
$record = $this->getComponent()->getRecord();
if (! $record) {
return parent::resolveDefaultClosureDependencyForEvaluationByType($parameterType);
}
return match ($parameterType) {
Model::class, $record::class => [$record],
default => parent::resolveDefaultClosureDependencyForEvaluationByType($parameterType),
};
}
public function getInfolistName(): string
{
return 'mountedFormComponentActionInfolist';
}
}
@@ -1,28 +0,0 @@
<?php
namespace Filament\Forms\Components\Actions\Concerns;
use Filament\Components\Component;
use Filament\Forms\Contracts\HasForms;
trait BelongsToComponent
{
protected Component $component;
public function component(Component $component): static
{
$this->component = $component;
return $this;
}
public function getComponent(): Component
{
return $this->component;
}
public function getLivewire(): HasForms
{
return $this->getComponent()->getLivewire();
}
}
+1 -1
View File
@@ -3,8 +3,8 @@
namespace Filament\Forms\Components;
use Closure;
use Filament\Actions\Action;
use Filament\ComponentContainer;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Builder\Block;
use Filament\Support\Concerns\HasReorderAnimationDuration;
use Filament\Support\Enums\ActionSize;
@@ -3,7 +3,7 @@
namespace Filament\Forms\Components;
use Closure;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Support\Enums\ActionSize;
use Filament\Support\Services\RelationshipJoiner;
use Illuminate\Contracts\Support\Htmlable;
@@ -3,7 +3,7 @@
namespace Filament\Forms\Components\Concerns;
use Closure;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Support\Enums\ActionSize;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Arr;
@@ -3,7 +3,7 @@
namespace Filament\Forms\Components\Concerns;
use Closure;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Support\Enums\ActionSize;
use Illuminate\Support\Arr;
@@ -3,7 +3,7 @@
namespace Filament\Forms\Components\Concerns;
use Closure;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Support\Concerns\HasFooterActionsAlignment;
use Illuminate\Support\Arr;
@@ -3,7 +3,7 @@
namespace Filament\Forms\Components\Concerns;
use Closure;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Illuminate\Support\Arr;
trait HasHeaderActions
@@ -3,7 +3,7 @@
namespace Filament\Forms\Components\Concerns;
use Closure;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Support\Enums\ActionSize;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Arr;
@@ -2,7 +2,7 @@
namespace Filament\Forms\Components\Contracts;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
interface HasAffixActions
{
@@ -2,7 +2,7 @@
namespace Filament\Forms\Components\Contracts;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
interface HasExtraItemActions
{
@@ -2,7 +2,7 @@
namespace Filament\Forms\Components\Contracts;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
interface HasFooterActions
{
@@ -2,7 +2,7 @@
namespace Filament\Forms\Components\Contracts;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
interface HasHeaderActions
{
@@ -2,7 +2,7 @@
namespace Filament\Forms\Components\Contracts;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
interface HasHintActions
{
+1 -1
View File
@@ -3,7 +3,7 @@
namespace Filament\Forms\Components;
use Closure;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Support\Concerns\HasExtraAlpineAttributes;
use Filament\Support\Concerns\HasReorderAnimationDuration;
use Filament\Support\Enums\ActionSize;
+1 -1
View File
@@ -3,8 +3,8 @@
namespace Filament\Forms\Components;
use Closure;
use Filament\Actions\Action;
use Filament\ComponentContainer;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Contracts\HasForms;
use Filament\Support\Concerns\HasReorderAnimationDuration;
use Filament\Support\Enums\ActionSize;
+1 -1
View File
@@ -4,9 +4,9 @@ namespace Filament\Forms\Components;
use Closure;
use Exception;
use Filament\Actions\Action;
use Filament\ComponentContainer;
use Filament\Components\Component;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Form;
use Filament\Support\Concerns\HasExtraAlpineAttributes;
use Filament\Support\Facades\FilamentIcon;
@@ -2,7 +2,7 @@
namespace Filament\Forms\Components\TextInput\Actions;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Support\Facades\FilamentIcon;
class HidePasswordAction extends Action
@@ -2,7 +2,7 @@
namespace Filament\Forms\Components\TextInput\Actions;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Support\Facades\FilamentIcon;
class ShowPasswordAction extends Action
+1 -1
View File
@@ -3,8 +3,8 @@
namespace Filament\Forms\Components;
use Closure;
use Filament\Actions\Action;
use Filament\Components\Component;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Wizard\Step;
use Filament\Support\Concerns;
use Filament\Support\Enums\IconPosition;
@@ -2,9 +2,9 @@
namespace Filament\Forms\Concerns;
use Filament\Actions\Action;
use Filament\ComponentContainer;
use Filament\Components\Component;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Form;
use Filament\Support\Exceptions\Cancel;
use Filament\Support\Exceptions\Halt;
@@ -183,10 +183,7 @@ Alternatively, if you're editing records in a modal action, check out the [Actio
You may want to allow the user to save a part of the form independently of the rest of the form. One way to do this is with a [section action in the header or footer](../../forms/layout/section#adding-actions-to-the-sections-header-or-footer). From the `action()` method, you can call `saveFormComponentOnly()`, passing in the `Section` component that you want to save:
```php
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Section;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord;
use Filament\Actions\Action;use Filament\Forms\Components\Section;use Filament\Notifications\Notification;use Filament\Resources\Pages\EditRecord;
Section::make('Rate limiting')
->schema([
+1 -1
View File
@@ -29,7 +29,7 @@ class ComponentContainer extends ViewComponent
use Components\Concerns\HasStateBindingModifiers;
use HasExtraAttributes;
protected string $view = 'filament::component-container';
protected string $view = 'filament-schema::component-container';
protected string $evaluationIdentifier = 'container';
@@ -1,10 +1,9 @@
<?php
namespace Filament\Forms\Components;
namespace Filament\Components;
use Closure;
use Filament\Components\Component;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Support\Concerns\HasAlignment;
use Filament\Support\Concerns\HasVerticalAlignment;
@@ -13,7 +12,7 @@ class Actions extends Component
use HasAlignment;
use HasVerticalAlignment;
protected string $view = 'filament-forms::components.actions';
protected string $view = 'filament-schema::components.actions';
protected bool | Closure $isFullWidth = false;
@@ -1,12 +1,13 @@
<?php
namespace Filament\Forms\Components\Actions;
namespace Filament\Components\Actions;
use Filament\Actions\Action;
use Filament\Components\Component;
class ActionContainer extends Component
{
protected string $view = 'filament-forms::components.actions.action-container';
protected string $view = 'filament-schema::components.actions.action-container';
protected Action $action;
@@ -63,11 +63,11 @@ class Component extends ViewComponent
{
return match ($parameterName) {
'context', 'operation' => [$this->getContainer()->getOperation()],
'get' => [$this->getGetCallback()],
'get' => [$this->makeGetUtility()],
'livewire' => [$this->getLivewire()],
'model' => [$this->getModel()],
'record' => [$this->getRecord()],
'set' => [$this->getSetCallback()],
'set' => [$this->makeSetUtility()],
'state' => [$this->getState()],
default => parent::resolveDefaultClosureDependencyForEvaluationByName($parameterName),
};
@@ -3,7 +3,7 @@
namespace Filament\Components\Concerns;
use Closure;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Forms\Components\Contracts\HasAffixActions;
use Filament\Forms\Components\Contracts\HasExtraItemActions;
use Filament\Forms\Components\Contracts\HasFooterActions;
@@ -455,16 +455,32 @@ trait HasState
return ! $this->isDehydratedWhenHidden();
}
public function getGetCallback(): Get
public function makeGetUtility(): Get
{
return new Get($this);
}
public function getSetCallback(): Set
public function makeSetUtility(): Set
{
return new Set($this);
}
/**
* @deprecated Use `makeGetUtility()` instead.
*/
public function getGetCallback(): Get
{
return $this->makeGetUtility();
}
/**
* @deprecated Use `makeSetUtility()` instead.
*/
public function getSetCallback(): Set
{
return $this->makeSetUtility();
}
public function generateRelativeStatePath(string | Component $path, bool $isAbsolute = false): string
{
if ($path instanceof Component) {
@@ -13,7 +13,7 @@ class SchemaServiceProvider extends PackageServiceProvider
public function configurePackage(Package $package): void
{
$package
->name('filament')
->name('filament-schema')
->hasCommands($this->getCommands())
->hasTranslations()
->hasViews();
@@ -3,8 +3,8 @@
namespace Filament\Testing;
use Closure;
use Filament\Actions\Action;
use Filament\ComponentContainer;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Contracts\HasForms;
use Illuminate\Support\Arr;
use Illuminate\Testing\Assert;
@@ -20,12 +20,12 @@
@php
$prefixActions = array_filter(
$prefixActions,
fn (\Filament\Forms\Components\Actions\Action $prefixAction): bool => $prefixAction->isVisible(),
fn (\Filament\Actions\Action $prefixAction): bool => $prefixAction->isVisible(),
);
$suffixActions = array_filter(
$suffixActions,
fn (\Filament\Forms\Components\Actions\Action $suffixAction): bool => $suffixAction->isVisible(),
fn (\Filament\Actions\Action $suffixAction): bool => $suffixAction->isVisible(),
);
$hasPrefix = count($prefixActions) || $prefixIcon || filled($prefix);
@@ -2,6 +2,8 @@
namespace Filament\Tables\Actions;
use Filament\Actions\Action;
/**
* @deprecated Use `\Filament\Tables\Actions\Action` instead, with the `button()` method.
* @see Action
@@ -2,6 +2,8 @@
namespace Filament\Tables\Actions;
use Filament\Actions\Action;
/**
* @deprecated Use `\Filament\Tables\Actions\Action` instead, with the `iconButton()` method.
* @see Action
@@ -3,9 +3,9 @@
namespace Filament\Tables\Filters\QueryBuilder\Forms\Components;
use Exception;
use Filament\Actions\Action;
use Filament\ComponentContainer;
use Filament\Components\Component;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Repeater;
use Filament\Tables\Filters\QueryBuilder\Concerns\HasConstraints;
+8 -1
View File
@@ -93,13 +93,20 @@ return static function (RectorConfig $rectorConfig): void {
'Filament\\Forms\\Components\\Concerns\\HasMeta' => 'Filament\\Components\\Concerns\\HasMeta',
'Filament\\Forms\\Components\\Concerns\\HasState' => 'Filament\\Components\\Concerns\\HasState',
'Filament\\Forms\\Components\\Concerns\\ListensToEvents' => 'Filament\\Components\\Concerns\\ListensToEvents',
'Filament\\Forms\\Components\\Actions\\Concerns\\BelongsToComponent' => 'Filament\\Actions\\Concerns\\BelongsToComponent',
'Filament\\Forms\\Components\\Actions' => 'Filament\\Components\\Actions',
'Filament\\Forms\\Components\\Actions\\Action' => 'Filament\\Actions\\Action',
'Filament\\Forms\\Components\\Actions\\ActionContainer' => 'Filament\\Components\\Actions\\ActionContainer',
'Filament\\Forms\\Components\\Actions\\ActionContainer' => 'Filament\\Components\\Actions\\ActionContainer',
],
);
$rectorConfig->ruleWithConfiguration(
RenameStringRector::class,
[
'filament-forms::component-container' => 'filament::component-container',
'filament-forms::component-container' => 'filament-schema::component-container',
'filament-forms::components.actions' => 'filament-schema::components.actions',
'filament-forms::components.actions.action-container' => 'filament-schema::components.actions.action-container',
],
);
};
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Tests\Forms\Fixtures\Actions;
use Filament\Tests\TestCase;
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Filament\Tests\Forms\Fixtures;
use Filament\Forms\Components\Actions\Action;
use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;