From 47bf72383efb73c2330ab7adc4a2ce5aa699167f Mon Sep 17 00:00:00 2001 From: Ash Monsh Date: Mon, 8 Jan 2024 16:25:24 +0300 Subject: [PATCH 1/3] Update composer.lock --- composer.lock | 84 +++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/composer.lock b/composer.lock index 9fe2128e..603fac8c 100644 --- a/composer.lock +++ b/composer.lock @@ -1554,7 +1554,7 @@ }, { "name": "filament/actions", - "version": "v3.1.35", + "version": "v3.1.36", "source": { "type": "git", "url": "https://github.com/filamentphp/actions.git", @@ -1605,16 +1605,16 @@ }, { "name": "filament/filament", - "version": "v3.1.35", + "version": "v3.1.36", "source": { "type": "git", "url": "https://github.com/filamentphp/panels.git", - "reference": "4c6f1e1efdd3be5582af249055b893a09123777e" + "reference": "04a7b41e1ac425a931b5ea5672fd394e2d80aa74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/panels/zipball/4c6f1e1efdd3be5582af249055b893a09123777e", - "reference": "4c6f1e1efdd3be5582af249055b893a09123777e", + "url": "https://api.github.com/repos/filamentphp/panels/zipball/04a7b41e1ac425a931b5ea5672fd394e2d80aa74", + "reference": "04a7b41e1ac425a931b5ea5672fd394e2d80aa74", "shasum": "" }, "require": { @@ -1666,20 +1666,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-01-04T12:28:40+00:00" + "time": "2024-01-08T12:59:20+00:00" }, { "name": "filament/forms", - "version": "v3.1.35", + "version": "v3.1.36", "source": { "type": "git", "url": "https://github.com/filamentphp/forms.git", - "reference": "23526fc23555d55d3fb3b9965efeba2ac04d6bbf" + "reference": "dd9a44cff7bf647fff4faea3de4bd2166243a138" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/forms/zipball/23526fc23555d55d3fb3b9965efeba2ac04d6bbf", - "reference": "23526fc23555d55d3fb3b9965efeba2ac04d6bbf", + "url": "https://api.github.com/repos/filamentphp/forms/zipball/dd9a44cff7bf647fff4faea3de4bd2166243a138", + "reference": "dd9a44cff7bf647fff4faea3de4bd2166243a138", "shasum": "" }, "require": { @@ -1722,20 +1722,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-01-04T12:28:34+00:00" + "time": "2024-01-08T12:59:14+00:00" }, { "name": "filament/infolists", - "version": "v3.1.35", + "version": "v3.1.36", "source": { "type": "git", "url": "https://github.com/filamentphp/infolists.git", - "reference": "5bc1bfb47d34efd0ee7b3cee43d18996f99d9999" + "reference": "2515985792f32c68984ad2ea6b974b7342829e29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/infolists/zipball/5bc1bfb47d34efd0ee7b3cee43d18996f99d9999", - "reference": "5bc1bfb47d34efd0ee7b3cee43d18996f99d9999", + "url": "https://api.github.com/repos/filamentphp/infolists/zipball/2515985792f32c68984ad2ea6b974b7342829e29", + "reference": "2515985792f32c68984ad2ea6b974b7342829e29", "shasum": "" }, "require": { @@ -1773,11 +1773,11 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-01-02T23:07:20+00:00" + "time": "2024-01-08T12:59:23+00:00" }, { "name": "filament/notifications", - "version": "v3.1.35", + "version": "v3.1.36", "source": { "type": "git", "url": "https://github.com/filamentphp/notifications.git", @@ -1829,7 +1829,7 @@ }, { "name": "filament/spatie-laravel-translatable-plugin", - "version": "v3.1.35", + "version": "v3.1.36", "source": { "type": "git", "url": "https://github.com/filamentphp/spatie-laravel-translatable-plugin.git", @@ -1874,16 +1874,16 @@ }, { "name": "filament/support", - "version": "v3.1.35", + "version": "v3.1.36", "source": { "type": "git", "url": "https://github.com/filamentphp/support.git", - "reference": "bb580e362e66ae8071d8386e13841c1dc1a252b4" + "reference": "332308fdd61b67c8d8e7864029d8f6a85b99d49a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/support/zipball/bb580e362e66ae8071d8386e13841c1dc1a252b4", - "reference": "bb580e362e66ae8071d8386e13841c1dc1a252b4", + "url": "https://api.github.com/repos/filamentphp/support/zipball/332308fdd61b67c8d8e7864029d8f6a85b99d49a", + "reference": "332308fdd61b67c8d8e7864029d8f6a85b99d49a", "shasum": "" }, "require": { @@ -1927,20 +1927,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-01-04T12:29:08+00:00" + "time": "2024-01-08T12:59:20+00:00" }, { "name": "filament/tables", - "version": "v3.1.35", + "version": "v3.1.36", "source": { "type": "git", "url": "https://github.com/filamentphp/tables.git", - "reference": "ba00ac1bf300756a4b240decf8c82d550ff2d024" + "reference": "9efcf3f0b8395b376bb8eace47f11ed0830f8c09" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/tables/zipball/ba00ac1bf300756a4b240decf8c82d550ff2d024", - "reference": "ba00ac1bf300756a4b240decf8c82d550ff2d024", + "url": "https://api.github.com/repos/filamentphp/tables/zipball/9efcf3f0b8395b376bb8eace47f11ed0830f8c09", + "reference": "9efcf3f0b8395b376bb8eace47f11ed0830f8c09", "shasum": "" }, "require": { @@ -1980,11 +1980,11 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-01-04T12:29:06+00:00" + "time": "2024-01-08T12:59:16+00:00" }, { "name": "filament/widgets", - "version": "v3.1.35", + "version": "v3.1.36", "source": { "type": "git", "url": "https://github.com/filamentphp/widgets.git", @@ -4181,23 +4181,23 @@ }, { "name": "phenx/php-font-lib", - "version": "0.5.4", + "version": "0.5.5", "source": { "type": "git", "url": "https://github.com/dompdf/php-font-lib.git", - "reference": "dd448ad1ce34c63d09baccd05415e361300c35b4" + "reference": "671df0f3516252011aa94f9e8e3b3b66199339f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/dd448ad1ce34c63d09baccd05415e361300c35b4", - "reference": "dd448ad1ce34c63d09baccd05415e361300c35b4", + "url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/671df0f3516252011aa94f9e8e3b3b66199339f8", + "reference": "671df0f3516252011aa94f9e8e3b3b66199339f8", "shasum": "" }, "require": { "ext-mbstring": "*" }, "require-dev": { - "symfony/phpunit-bridge": "^3 || ^4 || ^5" + "symfony/phpunit-bridge": "^3 || ^4 || ^5 || ^6" }, "type": "library", "autoload": { @@ -4207,7 +4207,7 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0" + "LGPL-2.1-or-later" ], "authors": [ { @@ -4219,9 +4219,9 @@ "homepage": "https://github.com/PhenX/php-font-lib", "support": { "issues": "https://github.com/dompdf/php-font-lib/issues", - "source": "https://github.com/dompdf/php-font-lib/tree/0.5.4" + "source": "https://github.com/dompdf/php-font-lib/tree/0.5.5" }, - "time": "2021-12-17T19:44:54+00:00" + "time": "2024-01-07T18:13:29+00:00" }, { "name": "phenx/php-svg-lib", @@ -11002,16 +11002,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.54", + "version": "1.10.55", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "3e25f279dada0adc14ffd7bad09af2e2fc3523bb" + "reference": "9a88f9d18ddf4cf54c922fbeac16c4cb164c5949" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/3e25f279dada0adc14ffd7bad09af2e2fc3523bb", - "reference": "3e25f279dada0adc14ffd7bad09af2e2fc3523bb", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9a88f9d18ddf4cf54c922fbeac16c4cb164c5949", + "reference": "9a88f9d18ddf4cf54c922fbeac16c4cb164c5949", "shasum": "" }, "require": { @@ -11060,7 +11060,7 @@ "type": "tidelift" } ], - "time": "2024-01-05T15:50:47+00:00" + "time": "2024-01-08T12:32:40+00:00" }, { "name": "phpunit/php-code-coverage", From d2f72924747d0e17ae91a313d79fdaa2d392d356 Mon Sep 17 00:00:00 2001 From: Ash Monsh Date: Mon, 8 Jan 2024 18:56:57 +0300 Subject: [PATCH 2/3] update all fields classes --- composer.json | 3 +- composer.lock | 86 ++++++++++++++- src/Concerns/HasHiddenOptions.php | 1 + src/Concerns/HasOptions.php | 35 +++--- src/Concerns/Schemata.php | 11 +- src/Fields/Classes/CheckboxList.php | 2 +- src/Fields/Classes/ColorPicker.php | 2 +- src/Fields/Classes/DatePicker.php | 2 +- src/Fields/Classes/DateTimePicker.php | 11 ++ src/Fields/Classes/FileUpload.php | 2 +- src/Fields/Classes/Radio.php | 2 +- src/Fields/Classes/RichEditor.php | 2 +- src/Fields/Classes/Select.php | 2 +- src/Fields/Classes/TextInput.php | 151 ++++++++++++++++++-------- src/Fields/Classes/Textarea.php | 2 +- src/Fields/Classes/TimePicker.php | 2 +- src/Fields/Classes/Toggle.php | 30 ++++- src/Fields/FieldsContract.php | 10 +- 18 files changed, 272 insertions(+), 84 deletions(-) diff --git a/composer.json b/composer.json index 529bab7c..ab0873e9 100644 --- a/composer.json +++ b/composer.json @@ -31,8 +31,9 @@ "php": "^8.1", "alperenersoy/filament-export": "dev-fix-there", "codeat3/blade-clarity-icons": "^1.7", - "guava/filament-icon-picker": "^2.0", "flowframe/laravel-trend": "^0.1.5", + "guava/filament-icon-picker": "^2.0", + "lara-zeus/accordion": "^1.0", "lara-zeus/core": "^3.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 603fac8c..4a37e264 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b61d0fb103846cd7ce174d0b45e4f046", + "content-hash": "d129f56fbbd7e588ed7ef053d0decec6", "packages": [ { "name": "alperenersoy/filament-export", @@ -2439,6 +2439,90 @@ }, "time": "2023-12-07T10:44:41+00:00" }, + { + "name": "lara-zeus/accordion", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/lara-zeus/accordion.git", + "reference": "206caace18bc09ddd63f19ec439b823ef8282a33" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/lara-zeus/accordion/zipball/206caace18bc09ddd63f19ec439b823ef8282a33", + "reference": "206caace18bc09ddd63f19ec439b823ef8282a33", + "shasum": "" + }, + "require": { + "filament/filament": "^3.0", + "php": "^8.1", + "spatie/laravel-package-tools": "^1.16" + }, + "require-dev": { + "laravel/pint": "^1.0", + "nunomaduro/collision": "^7.0", + "nunomaduro/larastan": "^2.0.1", + "nunomaduro/phpinsights": "^2.8", + "orchestra/testbench": "^8.0", + "phpstan/extension-installer": "^1.1" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "LaraZeus\\Accordion\\AccordionServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "LaraZeus\\Accordion\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "php coder", + "email": "info@larazeus.com", + "role": "Owner" + } + ], + "description": "Zeus Accordion is filamentphp layout component to group components", + "homepage": "https://larazeus.com/accordion", + "keywords": [ + "accordion", + "code", + "coulmn", + "design", + "field", + "filamentphp", + "generator", + "input", + "lara-zeus", + "laravel", + "tippy", + "tooltip", + "ui" + ], + "support": { + "issues": "https://github.com/lara-zeus/accordion/issues", + "source": "https://github.com/lara-zeus/accordion" + }, + "funding": [ + { + "url": "https://www.buymeacoffee.com/larazeus", + "type": "custom" + }, + { + "url": "https://github.com/atmonshi", + "type": "github" + } + ], + "time": "2024-01-07T23:21:38+00:00" + }, { "name": "lara-zeus/core", "version": "v3.0.15", diff --git a/src/Concerns/HasHiddenOptions.php b/src/Concerns/HasHiddenOptions.php index f3ec82ad..1c014493 100644 --- a/src/Concerns/HasHiddenOptions.php +++ b/src/Concerns/HasHiddenOptions.php @@ -37,6 +37,7 @@ public static function hiddenHintOptions(): array Hidden::make('options.hint.text'), Hidden::make('options.hint.icon'), Hidden::make('options.hint.color'), + Hidden::make('options.hint.icon-tooltip'), ]; } diff --git a/src/Concerns/HasOptions.php b/src/Concerns/HasOptions.php index 4b733ce2..ce2d025e 100644 --- a/src/Concerns/HasOptions.php +++ b/src/Concerns/HasOptions.php @@ -11,43 +11,45 @@ use Filament\Forms\Get; use Filament\Forms\Set; use Guava\FilamentIconPicker\Forms\IconPicker; +use LaraZeus\Accordion\Forms\Accordion; use LaraZeus\Bolt\BoltPlugin; use LaraZeus\Bolt\Facades\Bolt; use LaraZeus\Bolt\Fields\FieldsContract; trait HasOptions { - public static function visibility(string $type = 'field', ?array $getFields = null): Grid + public static function visibility(?array $getFields = []): Accordion { - $fieldsList = []; if (filled($getFields)) { - $fieldsList = collect($getFields) + $getFields = collect($getFields) ->pluck('fields') ->mapWithKeys(function (array $item) { return $item; }); } - return Grid::make() + return Accordion::make('visibility-options') + ->label('Conditional Visibility') + ->icon('iconpark-eyes') ->schema([ Toggle::make('options.visibility.active') ->live() - ->label(__('Conditional Visibility')), + ->label(__('Enable Conditional Visibility')), Select::make('options.visibility.fieldID') ->label(__('show when the field:')) ->live() ->visible(fn (Get $get): bool => ! empty($get('options.visibility.active'))) ->required(fn (Get $get): bool => ! empty($get('options.visibility.active'))) - ->options(optional($fieldsList)->pluck('name', 'id')), + ->options(optional($getFields)->pluck('name', 'id')), Select::make('options.visibility.values') ->label(__('has the value:')) ->live() ->required(fn (Get $get): bool => ! empty($get('options.visibility.fieldID'))) ->visible(fn (Get $get): bool => ! empty($get('options.visibility.fieldID'))) - ->options(function (Get $get) use ($fieldsList) { - $getRelated = $fieldsList->where('id', $get('options.visibility.fieldID'))->first(); + ->options(function (Get $get) use ($getFields) { + $getRelated = $getFields->where('id', $get('options.visibility.fieldID'))->first(); if ($get('options.visibility.fieldID') === null) { return []; @@ -66,8 +68,7 @@ public static function visibility(string $type = 'field', ?array $getFields = nu return FieldsContract::getFieldCollectionItemsList($getRelated); }), - ]) - ->columns(1); + ]); } public static function required(): Grid @@ -79,12 +80,18 @@ public static function required(): Grid ->columns(1); } - public static function hintOptions(): Grid + public static function hintOptions(): Accordion { - return Grid::make() + return Accordion::make('hint-options') + ->columns() + ->label('Hint Options') + ->icon('heroicon-o-light-bulb') ->schema([ TextInput::make('options.hint.text') ->label(__('Hint Text')), + TextInput::make('options.hint.icon-tooltip') + ->label(__('Hint Icon tooltip')), + ColorPicker::make('options.hint.color')->label(__('Hint Color')), IconPicker::make('options.hint.icon') ->columns([ 'default' => 1, @@ -92,9 +99,7 @@ public static function hintOptions(): Grid '2xl' => 5, ]) ->label(__('Hint Icon')), - ColorPicker::make('options.hint.color')->label(__('Hint Color')), - ]) - ->columns(1); + ]); } public static function columnSpanFull(): Grid diff --git a/src/Concerns/Schemata.php b/src/Concerns/Schemata.php index 0f77b26d..a2839382 100644 --- a/src/Concerns/Schemata.php +++ b/src/Concerns/Schemata.php @@ -22,6 +22,7 @@ use Filament\Forms\Set; use Guava\FilamentIconPicker\Forms\IconPicker; use Illuminate\Support\Str; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\BoltPlugin; use LaraZeus\Bolt\Facades\Bolt; use LaraZeus\Bolt\Models\Category; @@ -53,7 +54,7 @@ public static function getMainFormSchema(): array ->addActionLabel(__('Add Section')) ->cloneable() ->collapsible() - ->collapsed(fn (string $operation) => $operation === 'edit') + //->collapsed(fn (string $operation) => $operation === 'edit') ->minItems(1) ->extraItemActions([ Action::make('options') @@ -93,7 +94,7 @@ public static function getMainFormSchema(): array Toggle::make('compact') ->visible($formOptions['show-as'] === 'page') ->label(__('compact section')), - self::visibility('section', $get('sections')), + self::visibility($get('sections')), ]; }) ->action(function (array $data, array $arguments, Repeater $component): void { @@ -326,7 +327,7 @@ public static function getSectionsSchema(): array ->cloneable() ->minItems(1) ->collapsible() - ->collapsed(fn (string $operation) => $operation === 'edit') + //->collapsed(fn (string $operation) => $operation === 'edit') ->grid([ 'default' => 1, 'md' => 2, @@ -337,11 +338,13 @@ public static function getSectionsSchema(): array ->itemLabel(fn (array $state): ?string => $state['name'] ?? null) ->addActionLabel(__('Add field')) ->extraItemActions([ - Action::make('options') + Action::make('fields options') ->slideOver() ->color('warning') ->tooltip('more section options') ->icon('heroicon-m-cog') + ->modalIcon('heroicon-m-cog') + ->modalDescription(__('advanced fields settings')) ->fillForm(fn ( $state, array $arguments, diff --git a/src/Fields/Classes/CheckboxList.php b/src/Fields/Classes/CheckboxList.php index a27a8607..f489c3ba 100644 --- a/src/Fields/Classes/CheckboxList.php +++ b/src/Fields/Classes/CheckboxList.php @@ -25,7 +25,7 @@ public static function getOptions(?array $sections = null): array self::hintOptions(), self::required(), self::columnSpanFull(), - self::visibility('field', $sections), + self::visibility($sections), ]; } diff --git a/src/Fields/Classes/ColorPicker.php b/src/Fields/Classes/ColorPicker.php index 693a82a7..462ef116 100644 --- a/src/Fields/Classes/ColorPicker.php +++ b/src/Fields/Classes/ColorPicker.php @@ -31,7 +31,7 @@ public static function getOptions(?array $sections = null): array self::hintOptions(), self::required(), self::columnSpanFull(), - self::visibility('field', $sections), + self::visibility($sections), ]; } diff --git a/src/Fields/Classes/DatePicker.php b/src/Fields/Classes/DatePicker.php index 2bba4c9d..43baa9a1 100644 --- a/src/Fields/Classes/DatePicker.php +++ b/src/Fields/Classes/DatePicker.php @@ -22,7 +22,7 @@ public static function getOptions(?array $sections = null): array self::hintOptions(), self::required(), self::columnSpanFull(), - self::visibility('field', $sections), + self::visibility($sections), ]; } diff --git a/src/Fields/Classes/DateTimePicker.php b/src/Fields/Classes/DateTimePicker.php index 9ba70cb3..6fe8d7f0 100644 --- a/src/Fields/Classes/DateTimePicker.php +++ b/src/Fields/Classes/DateTimePicker.php @@ -15,6 +15,17 @@ public function title(): string return __('Date Time Picker'); } + public static function getOptions(): array + { + return [ + self::htmlID(), + self::hintOptions(), + self::required(), + self::columnSpanFull(), + self::visibility(), + ]; + } + public static function getOptionsHidden(): array { return [ diff --git a/src/Fields/Classes/FileUpload.php b/src/Fields/Classes/FileUpload.php index ffeadc97..71daf559 100644 --- a/src/Fields/Classes/FileUpload.php +++ b/src/Fields/Classes/FileUpload.php @@ -27,7 +27,7 @@ public static function getOptions(?array $sections = null): array self::hintOptions(), self::required(), self::columnSpanFull(), - self::visibility('field', $sections), + self::visibility($sections), ]; } diff --git a/src/Fields/Classes/Radio.php b/src/Fields/Classes/Radio.php index ac07b2b8..4b9b4e1e 100644 --- a/src/Fields/Classes/Radio.php +++ b/src/Fields/Classes/Radio.php @@ -28,7 +28,7 @@ public static function getOptions(?array $sections = null): array Toggle::make('options.is_inline')->label(__('Is inline')), self::required(), self::columnSpanFull(), - self::visibility('field', $sections), + self::visibility($sections), ]; } diff --git a/src/Fields/Classes/RichEditor.php b/src/Fields/Classes/RichEditor.php index f12bf446..4a6dadea 100644 --- a/src/Fields/Classes/RichEditor.php +++ b/src/Fields/Classes/RichEditor.php @@ -22,7 +22,7 @@ public static function getOptions(?array $sections = null): array self::hintOptions(), self::required(), self::columnSpanFull(), - self::visibility('field', $sections), + self::visibility($sections), ]; } diff --git a/src/Fields/Classes/Select.php b/src/Fields/Classes/Select.php index 0e14b477..5712ffb6 100644 --- a/src/Fields/Classes/Select.php +++ b/src/Fields/Classes/Select.php @@ -28,7 +28,7 @@ public static function getOptions(?array $sections = null): array Toggle::make('options.allow_multiple')->label(__('Allow Multiple')), self::required(), self::columnSpanFull(), - self::visibility('field', $sections), + self::visibility($sections), ]; } diff --git a/src/Fields/Classes/TextInput.php b/src/Fields/Classes/TextInput.php index 0ab5b30e..43c7f5b2 100644 --- a/src/Fields/Classes/TextInput.php +++ b/src/Fields/Classes/TextInput.php @@ -2,10 +2,15 @@ namespace LaraZeus\Bolt\Fields\Classes; +use Filament\Forms\Components\ColorPicker; use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput as TextInputAlias; use Filament\Forms\Get; +use Filament\Support\Colors\Color; +use Guava\FilamentIconPicker\Forms\IconPicker; +use LaraZeus\Accordion\Forms\Accordion; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\Fields\FieldsContract; class TextInput extends FieldsContract @@ -22,47 +27,83 @@ public function title(): string public static function getOptions(?array $sections = null): array { return [ - Select::make('options.dateType') - ->label(__('Data type')) - ->required() - ->options([ - 'string' => __('text'), - 'email' => __('email'), - 'numeric' => __('numeric'), - 'password' => __('password'), - 'tel' => __('tel'), - 'url' => __('url'), - 'activeUrl' => __('active url'), - 'alpha' => __('alpha'), - 'alphaDash' => __('alpha dash'), - 'alphaNum' => __('alpha num'), - 'ip' => __('ip'), - 'ipv4' => __('ip v4'), - 'ipv6' => __('ip v6'), - 'macAddress' => __('mac address'), - ]) - ->default('string') - ->live(), - - TextInputAlias::make('options.prefix') - ->label(__('prefix')), - - TextInputAlias::make('options.suffix') - ->label(__('suffix')), - - TextInputAlias::make('options.minValue') - ->visible(fn (Get $get): bool => $get('options.dateType') === 'numeric') - ->label(__('min value')), - - TextInputAlias::make('options.maxValue') - ->visible(fn (Get $get): bool => $get('options.dateType') === 'numeric') - ->label(__('max value')), - - self::htmlID(), - self::hintOptions(), - self::required(), - self::columnSpanFull(), - self::visibility('field', $sections), + Accordions::make('options') + ->accordions([ + Accordion::make('validation-options') + ->label(__('Validation Options')) + ->icon('iconpark-checkcorrect-o') + ->columns() + ->schema([ + Select::make('options.dateType') + ->label(__('Data type')) + ->required() + ->options([ + 'string' => __('text'), + 'email' => __('email'), + 'numeric' => __('numeric'), + 'password' => __('password'), + 'tel' => __('tel'), + 'url' => __('url'), + 'activeUrl' => __('active url'), + 'alpha' => __('alpha'), + 'alphaDash' => __('alpha dash'), + 'alphaNum' => __('alpha num'), + 'ip' => __('ip'), + 'ipv4' => __('ip v4'), + 'ipv6' => __('ip v6'), + 'macAddress' => __('mac address'), + ]) + ->default('string') + ->columnSpanFull() + ->live(), + + TextInputAlias::make('options.minValue') + ->visible(fn(Get $get): bool => $get('options.dateType') === 'numeric') + ->label(__('min value')), + + TextInputAlias::make('options.maxValue') + ->visible(fn(Get $get): bool => $get('options.dateType') === 'numeric') + ->label(__('max value')), + + self::required(), + ]), + + Accordion::make('visual-options') + ->label(__('Visual Options')) + ->columns() + ->icon('iconpark-viewgriddetail-o') + ->schema([ + TextInputAlias::make('options.prefix') + ->label(__('prefix')), + TextInputAlias::make('options.suffix') + ->label(__('suffix')), + + IconPicker::make('options.prefix-icon') + ->columns([ + 'default' => 1, + 'lg' => 3, + '2xl' => 5, + ]) + ->label(__('Prefix Icon')), + IconPicker::make('options.suffix-icon') + ->columns([ + 'default' => 1, + 'lg' => 3, + '2xl' => 5, + ]) + ->label(__('Suffix Icon')), + + ColorPicker::make('options.prefix-icon-color') + ->label(__('Prefix Icon Color')), + ColorPicker::make('options.suffix-icon-color') + ->label(__('Suffix Icon Color')), + + self::columnSpanFull(), + self::htmlID(), + ]), + self::hintOptions(), + self::visibility($sections), + ]), ]; } @@ -74,11 +115,19 @@ public static function getOptionsHidden(): array self::hiddenHintOptions(), self::hiddenRequired(), self::hiddenColumnSpanFull(), + Hidden::make('options.dateType'), - Hidden::make('options.prefix'), - Hidden::make('options.suffix'), + Hidden::make('options.minValue'), Hidden::make('options.maxValue'), + + Hidden::make('options.suffix'), + Hidden::make('options.suffix-icon'), + Hidden::make('options.suffix-icon-color'), + + Hidden::make('options.prefix'), + Hidden::make('options.prefix-icon'), + Hidden::make('options.prefix-icon-color'), ]; } @@ -87,10 +136,24 @@ public function appendFilamentComponentsOptions($component, $zeusField) { parent::appendFilamentComponentsOptions($component, $zeusField); - if (! empty($zeusField['options']['dateType'])) { + if (!empty($zeusField['options']['dateType'])) { call_user_func([$component, $zeusField['options']['dateType']]); } + if (isset($zeusField->options['prefix']) && $zeusField->options['prefix'] !== null) { + $component = $component + ->prefixIcon($zeusField->options['prefix-icon'] ?? null) + ->prefixIconColor(Color::hex($zeusField->options['prefix-icon-color'] ?? '#000000')) + ->prefix($zeusField->options['prefix']); + } + + if (isset($zeusField->options['suffix']) && $zeusField->options['suffix'] !== null) { + $component = $component + ->suffixIcon($zeusField->options['suffix-icon'] ?? null) + ->suffixIconColor(Color::hex($zeusField->options['suffix-icon-color'] ?? '#000000')) + ->suffix($zeusField->options['suffix']); + } + return $component; } } diff --git a/src/Fields/Classes/Textarea.php b/src/Fields/Classes/Textarea.php index b3722dbb..b788233f 100644 --- a/src/Fields/Classes/Textarea.php +++ b/src/Fields/Classes/Textarea.php @@ -37,7 +37,7 @@ public static function getOptions(?array $sections = null): array self::hintOptions(), self::required(), self::columnSpanFull(), - self::visibility('field', $sections), + self::visibility($sections), ]; } diff --git a/src/Fields/Classes/TimePicker.php b/src/Fields/Classes/TimePicker.php index d63022f4..593e8ba4 100644 --- a/src/Fields/Classes/TimePicker.php +++ b/src/Fields/Classes/TimePicker.php @@ -22,7 +22,7 @@ public static function getOptions(?array $sections = null): array self::hintOptions(), self::required(), self::columnSpanFull(), - self::visibility('field', $sections), + self::visibility($sections), ]; } diff --git a/src/Fields/Classes/Toggle.php b/src/Fields/Classes/Toggle.php index 1769adeb..3f00ad23 100644 --- a/src/Fields/Classes/Toggle.php +++ b/src/Fields/Classes/Toggle.php @@ -2,6 +2,8 @@ namespace LaraZeus\Bolt\Fields\Classes; +use Filament\Forms\Components\Hidden; +use Guava\FilamentIconPicker\Forms\IconPicker; use LaraZeus\Bolt\Fields\FieldsContract; class Toggle extends FieldsContract @@ -22,7 +24,23 @@ public static function getOptions(?array $sections = null): array self::hintOptions(), self::required(), self::columnSpanFull(), - self::visibility('field', $sections), + self::visibility($sections), + + IconPicker::make('options.on-icon') + ->columns([ + 'default' => 1, + 'lg' => 3, + '2xl' => 5, + ]) + ->label(__('On Icon')), + + IconPicker::make('options.off-icon') + ->columns([ + 'default' => 1, + 'lg' => 3, + '2xl' => 5, + ]) + ->label(__('Off Icon')), ]; } @@ -34,6 +52,8 @@ public static function getOptionsHidden(): array self::hiddenHintOptions(), self::hiddenRequired(), self::hiddenColumnSpanFull(), + Hidden::make('options.on-icon'), + Hidden::make('options.off-icon'), ]; } @@ -42,6 +62,14 @@ public function appendFilamentComponentsOptions($component, $zeusField) { parent::appendFilamentComponentsOptions($component, $zeusField); + if (optional($zeusField->options)['on-icon']) { + $component = $component->onIcon($zeusField->options['on-icon']); + } + + if (optional($zeusField->options)['off-icon']) { + $component = $component->offIcon($zeusField->options['off-icon']); + } + return $component->live(); } } diff --git a/src/Fields/FieldsContract.php b/src/Fields/FieldsContract.php index 118d6bb4..aa66d045 100644 --- a/src/Fields/FieldsContract.php +++ b/src/Fields/FieldsContract.php @@ -74,14 +74,6 @@ public function appendFilamentComponentsOptions($component, $zeusField) ->id($htmlId) ->helperText($zeusField->description); - if (isset($zeusField->options['prefix']) && $zeusField->options['prefix'] !== null) { - $component = $component->prefix($zeusField->options['prefix']); - } - - if (isset($zeusField->options['suffix']) && $zeusField->options['suffix'] !== null) { - $component = $component->suffix($zeusField->options['suffix']); - } - if (optional($zeusField->options)['is_required']) { $component = $component->required(); } @@ -99,7 +91,7 @@ public function appendFilamentComponentsOptions($component, $zeusField) $component = $component->hint($zeusField->options['hint']['text']); } if (optional($zeusField->options)['hint']['icon']) { - $component = $component->hintIcon($zeusField->options['hint']['icon'], tooltip: $zeusField->options['hint']['text']); + $component = $component->hintIcon($zeusField->options['hint']['icon'], tooltip: $zeusField->options['hint']['icon-tooltip'] ?? $zeusField->options['hint']['text']); } if (optional($zeusField->options)['hint']['color']) { $component = $component->hintColor(fn () => Color::hex($zeusField->options['hint']['color'])); From 93deb9fddfd5b7bea10a7b7d6761eae0f5b38fbf Mon Sep 17 00:00:00 2001 From: Ash Monsh Date: Mon, 8 Jan 2024 21:20:49 +0300 Subject: [PATCH 3/3] update fields options --- src/Concerns/HasHiddenOptions.php | 76 ++------------------------- src/Concerns/Schemata.php | 6 ++- src/Fields/Classes/CheckboxList.php | 20 +++++-- src/Fields/Classes/ColorPicker.php | 32 +++++++---- src/Fields/Classes/DatePicker.php | 20 +++++-- src/Fields/Classes/DateTimePicker.php | 22 +++++--- src/Fields/Classes/FileUpload.php | 22 +++++--- src/Fields/Classes/Paragraph.php | 15 +++++- src/Fields/Classes/Radio.php | 22 +++++--- src/Fields/Classes/RichEditor.php | 20 +++++-- src/Fields/Classes/Select.php | 22 ++++++-- src/Fields/Classes/TextInput.php | 6 +-- src/Fields/Classes/Textarea.php | 37 ++++++++----- src/Fields/Classes/TimePicker.php | 20 +++++-- src/Fields/Classes/Toggle.php | 54 ++++++++++++------- src/Fields/FieldsContract.php | 5 ++ tests/FormsTest.php | 1 + 17 files changed, 233 insertions(+), 167 deletions(-) diff --git a/src/Concerns/HasHiddenOptions.php b/src/Concerns/HasHiddenOptions.php index 1c014493..6ca7348b 100644 --- a/src/Concerns/HasHiddenOptions.php +++ b/src/Concerns/HasHiddenOptions.php @@ -2,16 +2,7 @@ namespace LaraZeus\Bolt\Concerns; -use Filament\Forms\Components\Grid; use Filament\Forms\Components\Hidden; -use Filament\Forms\Components\Repeater; -use Filament\Forms\Components\Select; -use Filament\Forms\Components\TextInput; -use Filament\Forms\Components\Toggle; -use Filament\Forms\Get; -use Filament\Forms\Set; -use LaraZeus\Bolt\BoltPlugin; -use LaraZeus\Bolt\Facades\Bolt; trait HasHiddenOptions { @@ -50,70 +41,9 @@ public static function hiddenColumnSpanFull(): array public static function hiddenDataSource(): array { - $dataSources = BoltPlugin::getModel('Collection')::get() - ->mapWithKeys(function ($item, $key) { - return [ - $key => [ - 'title' => $item['name'], - 'class' => $item['id'], - ], - ]; - }) - ->merge( - Bolt::availableDataSource() - ->mapWithKeys(function ($item, $key) { - return [ - $key => [ - 'title' => $item['title'], - 'class' => $item['class'], - ], - ]; - }) - ) - ->pluck('title', 'class'); - - return Grid::make() - ->schema([ - Select::make('options.dataSource') - ->required() - ->createOptionForm([ - TextInput::make('name') - ->live(onBlur: true) - ->label(__('Collections Name'))->required()->maxLength(255)->columnSpan(2), - Repeater::make('values') - ->grid([ - 'default' => 1, - 'md' => 2, - 'lg' => 3, - ]) - ->label(__('Collections Values')) - ->columnSpan(2) - ->columns(1) - ->schema([ - TextInput::make('itemValue') - ->live(onBlur: true) - ->afterStateUpdated(function (Set $set, Get $get, string $operation) { - $set('itemKey', $get('itemValue')); - }) - ->required()->label(__('Value'))->hint(__('what the user will see')), - TextInput::make('itemKey') - ->live(onBlur: true) - ->required()->label(__('Key'))->hint(__('what store in the form')), - Toggle::make('itemIsDefault')->label(__('selected by default')), - ]), - ]) - ->createOptionUsing(function (array $data) { - $collectionModel = BoltPlugin::getModel('Collection'); - $collection = new $collectionModel; - $collection->fill($data); - $collection->save(); - - return $collection->id; - }) - ->options($dataSources) - ->label(__('Data Source')), - ]) - ->columns(1); + return [ + Hidden::make('options.dataSource'), + ]; } public static function hiddenHtmlID(): array diff --git a/src/Concerns/Schemata.php b/src/Concerns/Schemata.php index a2839382..bad01d50 100644 --- a/src/Concerns/Schemata.php +++ b/src/Concerns/Schemata.php @@ -22,7 +22,6 @@ use Filament\Forms\Set; use Guava\FilamentIconPicker\Forms\IconPicker; use Illuminate\Support\Str; -use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\BoltPlugin; use LaraZeus\Bolt\Facades\Bolt; use LaraZeus\Bolt\Models\Category; @@ -89,9 +88,11 @@ public static function getMainFormSchema(): array ]) ->label(__('Section icon')), Toggle::make('aside') + ->default(false) ->visible($formOptions['show-as'] === 'page') ->label(__('show as aside')), Toggle::make('compact') + ->default(false) ->visible($formOptions['show-as'] === 'page') ->label(__('compact section')), self::visibility($get('sections')), @@ -341,7 +342,7 @@ public static function getSectionsSchema(): array Action::make('fields options') ->slideOver() ->color('warning') - ->tooltip('more section options') + ->tooltip('more field options') ->icon('heroicon-m-cog') ->modalIcon('heroicon-m-cog') ->modalDescription(__('advanced fields settings')) @@ -413,6 +414,7 @@ public static function getFieldsSchema(): array if (class_exists($class)) { $newClass = (new $class); if ($newClass->hasOptions()) { + // @phpstan-ignore-next-line return collect($newClass->getOptionsHidden())->flatten()->toArray(); } } diff --git a/src/Fields/Classes/CheckboxList.php b/src/Fields/Classes/CheckboxList.php index f489c3ba..54ada6e2 100644 --- a/src/Fields/Classes/CheckboxList.php +++ b/src/Fields/Classes/CheckboxList.php @@ -2,6 +2,8 @@ namespace LaraZeus\Bolt\Fields\Classes; +use LaraZeus\Accordion\Forms\Accordion; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\Fields\FieldsContract; use LaraZeus\Bolt\Models\Field; use LaraZeus\Bolt\Models\FieldResponse; @@ -21,11 +23,19 @@ public static function getOptions(?array $sections = null): array { return [ self::dataSource(), - self::htmlID(), - self::hintOptions(), - self::required(), - self::columnSpanFull(), - self::visibility($sections), + Accordions::make('check-list-options') + ->accordions([ + Accordion::make('general-options') + ->label(__('General Options')) + ->icon('iconpark-checklist-o') + ->schema([ + self::required(), + self::columnSpanFull(), + self::htmlID(), + ]), + self::hintOptions(), + self::visibility($sections), + ]), ]; } diff --git a/src/Fields/Classes/ColorPicker.php b/src/Fields/Classes/ColorPicker.php index 462ef116..03a5b219 100644 --- a/src/Fields/Classes/ColorPicker.php +++ b/src/Fields/Classes/ColorPicker.php @@ -4,6 +4,8 @@ use Filament\Forms\Components\ColorPicker as ColorPickerAlias; use Filament\Forms\Components\Hidden; +use LaraZeus\Accordion\Forms\Accordion; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\Fields\FieldsContract; class ColorPicker extends FieldsContract @@ -20,18 +22,26 @@ public function title(): string public static function getOptions(?array $sections = null): array { return [ - \Filament\Forms\Components\Select::make('options.colorType') - ->label(__('Color Type')) - ->options([ - 'hsl' => 'hsl', - 'rgb' => 'rgb', - 'rgba' => 'rgba', + Accordions::make('check-list-options') + ->accordions([ + Accordion::make('general-options') + ->label(__('General Options')) + ->icon('iconpark-checklist-o') + ->schema([ + \Filament\Forms\Components\Select::make('options.colorType') + ->label(__('Color Type')) + ->options([ + 'hsl' => 'hsl', + 'rgb' => 'rgb', + 'rgba' => 'rgba', + ]), + self::required(), + self::columnSpanFull(), + self::htmlID(), + ]), + self::hintOptions(), + self::visibility($sections), ]), - self::htmlID(), - self::hintOptions(), - self::required(), - self::columnSpanFull(), - self::visibility($sections), ]; } diff --git a/src/Fields/Classes/DatePicker.php b/src/Fields/Classes/DatePicker.php index 43baa9a1..09590c15 100644 --- a/src/Fields/Classes/DatePicker.php +++ b/src/Fields/Classes/DatePicker.php @@ -2,6 +2,8 @@ namespace LaraZeus\Bolt\Fields\Classes; +use LaraZeus\Accordion\Forms\Accordion; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\Fields\FieldsContract; class DatePicker extends FieldsContract @@ -18,11 +20,19 @@ public function title(): string public static function getOptions(?array $sections = null): array { return [ - self::htmlID(), - self::hintOptions(), - self::required(), - self::columnSpanFull(), - self::visibility($sections), + Accordions::make('check-list-options') + ->accordions([ + Accordion::make('general-options') + ->label(__('General Options')) + ->icon('iconpark-checklist-o') + ->schema([ + self::required(), + self::columnSpanFull(), + self::htmlID(), + ]), + self::hintOptions(), + self::visibility($sections), + ]), ]; } diff --git a/src/Fields/Classes/DateTimePicker.php b/src/Fields/Classes/DateTimePicker.php index 6fe8d7f0..90f77d58 100644 --- a/src/Fields/Classes/DateTimePicker.php +++ b/src/Fields/Classes/DateTimePicker.php @@ -2,6 +2,8 @@ namespace LaraZeus\Bolt\Fields\Classes; +use LaraZeus\Accordion\Forms\Accordion; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\Fields\FieldsContract; class DateTimePicker extends FieldsContract @@ -15,14 +17,22 @@ public function title(): string return __('Date Time Picker'); } - public static function getOptions(): array + public static function getOptions(?array $sections = null): array { return [ - self::htmlID(), - self::hintOptions(), - self::required(), - self::columnSpanFull(), - self::visibility(), + Accordions::make('check-list-options') + ->accordions([ + Accordion::make('general-options') + ->label(__('General Options')) + ->icon('iconpark-checklist-o') + ->schema([ + self::required(), + self::columnSpanFull(), + self::htmlID(), + ]), + self::hintOptions(), + self::visibility($sections), + ]), ]; } diff --git a/src/Fields/Classes/FileUpload.php b/src/Fields/Classes/FileUpload.php index 71daf559..9594aa6f 100644 --- a/src/Fields/Classes/FileUpload.php +++ b/src/Fields/Classes/FileUpload.php @@ -3,6 +3,8 @@ namespace LaraZeus\Bolt\Fields\Classes; use Filament\Forms\Components\Hidden; +use LaraZeus\Accordion\Forms\Accordion; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\Facades\Bolt; use LaraZeus\Bolt\Fields\FieldsContract; use LaraZeus\Bolt\Models\Field; @@ -22,12 +24,20 @@ public function title(): string public static function getOptions(?array $sections = null): array { return [ - \Filament\Forms\Components\Toggle::make('options.allow_multiple')->label(__('Allow Multiple')), - self::htmlID(), - self::hintOptions(), - self::required(), - self::columnSpanFull(), - self::visibility($sections), + Accordions::make('check-list-options') + ->accordions([ + Accordion::make('general-options') + ->label(__('General Options')) + ->icon('iconpark-checklist-o') + ->schema([ + \Filament\Forms\Components\Toggle::make('options.allow_multiple')->label(__('Allow Multiple')), + self::required(), + self::columnSpanFull(), + self::htmlID(), + ]), + self::hintOptions(), + self::visibility($sections), + ]), ]; } diff --git a/src/Fields/Classes/Paragraph.php b/src/Fields/Classes/Paragraph.php index 4b02750c..65a63c54 100644 --- a/src/Fields/Classes/Paragraph.php +++ b/src/Fields/Classes/Paragraph.php @@ -3,6 +3,8 @@ namespace LaraZeus\Bolt\Fields\Classes; use Filament\Forms\Components\Placeholder; +use LaraZeus\Accordion\Forms\Accordion; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\Fields\FieldsContract; class Paragraph extends FieldsContract @@ -19,8 +21,17 @@ public function title(): string public static function getOptions(): array { return [ - self::hintOptions(), - self::columnSpanFull(), + Accordions::make('check-list-options') + ->accordions([ + Accordion::make('general-options') + ->label(__('General Options')) + ->icon('iconpark-checklist-o') + ->schema([ + self::columnSpanFull(), + self::hintOptions(), + ]), + + ]), ]; } diff --git a/src/Fields/Classes/Radio.php b/src/Fields/Classes/Radio.php index 4b9b4e1e..2c49bf35 100644 --- a/src/Fields/Classes/Radio.php +++ b/src/Fields/Classes/Radio.php @@ -4,6 +4,8 @@ use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Toggle; +use LaraZeus\Accordion\Forms\Accordion; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\Fields\FieldsContract; use LaraZeus\Bolt\Models\Field; use LaraZeus\Bolt\Models\FieldResponse; @@ -23,12 +25,20 @@ public static function getOptions(?array $sections = null): array { return [ self::dataSource(), - self::htmlID(), - self::hintOptions(), - Toggle::make('options.is_inline')->label(__('Is inline')), - self::required(), - self::columnSpanFull(), - self::visibility($sections), + Accordions::make('check-list-options') + ->accordions([ + Accordion::make('general-options') + ->label(__('General Options')) + ->icon('iconpark-checklist-o') + ->schema([ + self::required(), + Toggle::make('options.is_inline')->label(__('Is inline')), + self::columnSpanFull(), + self::htmlID(), + ]), + self::hintOptions(), + self::visibility($sections), + ]), ]; } diff --git a/src/Fields/Classes/RichEditor.php b/src/Fields/Classes/RichEditor.php index 4a6dadea..7427e31d 100644 --- a/src/Fields/Classes/RichEditor.php +++ b/src/Fields/Classes/RichEditor.php @@ -2,6 +2,8 @@ namespace LaraZeus\Bolt\Fields\Classes; +use LaraZeus\Accordion\Forms\Accordion; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\Fields\FieldsContract; class RichEditor extends FieldsContract @@ -18,11 +20,19 @@ public function title(): string public static function getOptions(?array $sections = null): array { return [ - self::htmlID(), - self::hintOptions(), - self::required(), - self::columnSpanFull(), - self::visibility($sections), + Accordions::make('check-list-options') + ->accordions([ + Accordion::make('general-options') + ->label(__('General Options')) + ->icon('iconpark-checklist-o') + ->schema([ + self::required(), + self::columnSpanFull(), + self::htmlID(), + ]), + self::hintOptions(), + self::visibility($sections), + ]), ]; } diff --git a/src/Fields/Classes/Select.php b/src/Fields/Classes/Select.php index 5712ffb6..bacc9d94 100644 --- a/src/Fields/Classes/Select.php +++ b/src/Fields/Classes/Select.php @@ -4,6 +4,8 @@ use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Toggle; +use LaraZeus\Accordion\Forms\Accordion; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\Fields\FieldsContract; use LaraZeus\Bolt\Models\Field; use LaraZeus\Bolt\Models\FieldResponse; @@ -23,12 +25,22 @@ public static function getOptions(?array $sections = null): array { return [ self::dataSource(), - self::htmlID(), - self::hintOptions(), Toggle::make('options.allow_multiple')->label(__('Allow Multiple')), - self::required(), - self::columnSpanFull(), - self::visibility($sections), + Accordions::make('options') + ->activeAccordion(1) + ->accordions([ + Accordion::make('general-options') + ->label(__('General Options')) + ->icon('iconpark-checklist-o') + ->columns() + ->schema([ + self::required(), + self::columnSpanFull(), + self::htmlID(), + ]), + self::hintOptions(), + self::visibility($sections), + ]), ]; } diff --git a/src/Fields/Classes/TextInput.php b/src/Fields/Classes/TextInput.php index 43c7f5b2..c2774556 100644 --- a/src/Fields/Classes/TextInput.php +++ b/src/Fields/Classes/TextInput.php @@ -58,11 +58,11 @@ public static function getOptions(?array $sections = null): array ->live(), TextInputAlias::make('options.minValue') - ->visible(fn(Get $get): bool => $get('options.dateType') === 'numeric') + ->visible(fn (Get $get): bool => $get('options.dateType') === 'numeric') ->label(__('min value')), TextInputAlias::make('options.maxValue') - ->visible(fn(Get $get): bool => $get('options.dateType') === 'numeric') + ->visible(fn (Get $get): bool => $get('options.dateType') === 'numeric') ->label(__('max value')), self::required(), @@ -136,7 +136,7 @@ public function appendFilamentComponentsOptions($component, $zeusField) { parent::appendFilamentComponentsOptions($component, $zeusField); - if (!empty($zeusField['options']['dateType'])) { + if (! empty($zeusField['options']['dateType'])) { call_user_func([$component, $zeusField['options']['dateType']]); } diff --git a/src/Fields/Classes/Textarea.php b/src/Fields/Classes/Textarea.php index b788233f..ae78ad01 100644 --- a/src/Fields/Classes/Textarea.php +++ b/src/Fields/Classes/Textarea.php @@ -5,6 +5,8 @@ use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Textarea as TextareaAlias; use Filament\Forms\Components\TextInput; +use LaraZeus\Accordion\Forms\Accordion; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\Fields\FieldsContract; class Textarea extends FieldsContract @@ -21,23 +23,32 @@ public function title(): string public static function getOptions(?array $sections = null): array { return [ - TextInput::make('options.rows') - ->label(__('rows')), + Accordions::make('check-list-options') + ->columns() + ->accordions([ + Accordion::make('general-options') + ->label(__('General Options')) + ->icon('iconpark-checklist-o') + ->schema([ + TextInput::make('options.rows') + ->label(__('rows')), - TextInput::make('options.cols') - ->label(__('cols')), + TextInput::make('options.cols') + ->label(__('cols')), - TextInput::make('options.minLength') - ->label(__('min length')), + TextInput::make('options.minLength') + ->label(__('min length')), - TextInput::make('options.maxLength') - ->label(__('max length')), + TextInput::make('options.maxLength') + ->label(__('max length')), - self::htmlID(), - self::hintOptions(), - self::required(), - self::columnSpanFull(), - self::visibility($sections), + self::required(), + self::columnSpanFull(), + self::htmlID(), + ]), + self::hintOptions(), + self::visibility($sections), + ]), ]; } diff --git a/src/Fields/Classes/TimePicker.php b/src/Fields/Classes/TimePicker.php index 593e8ba4..ef9062e3 100644 --- a/src/Fields/Classes/TimePicker.php +++ b/src/Fields/Classes/TimePicker.php @@ -2,6 +2,8 @@ namespace LaraZeus\Bolt\Fields\Classes; +use LaraZeus\Accordion\Forms\Accordion; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\Fields\FieldsContract; class TimePicker extends FieldsContract @@ -18,11 +20,19 @@ public function title(): string public static function getOptions(?array $sections = null): array { return [ - self::htmlID(), - self::hintOptions(), - self::required(), - self::columnSpanFull(), - self::visibility($sections), + Accordions::make('check-list-options') + ->accordions([ + Accordion::make('general-options') + ->label(__('General Options')) + ->icon('iconpark-checklist-o') + ->schema([ + self::required(), + self::columnSpanFull(), + self::htmlID(), + ]), + self::hintOptions(), + self::visibility($sections), + ]), ]; } diff --git a/src/Fields/Classes/Toggle.php b/src/Fields/Classes/Toggle.php index 3f00ad23..e0b9b47d 100644 --- a/src/Fields/Classes/Toggle.php +++ b/src/Fields/Classes/Toggle.php @@ -2,8 +2,11 @@ namespace LaraZeus\Bolt\Fields\Classes; +use Filament\Forms\Components\Grid; use Filament\Forms\Components\Hidden; use Guava\FilamentIconPicker\Forms\IconPicker; +use LaraZeus\Accordion\Forms\Accordion; +use LaraZeus\Accordion\Forms\Accordions; use LaraZeus\Bolt\Fields\FieldsContract; class Toggle extends FieldsContract @@ -20,27 +23,38 @@ public function title(): string public static function getOptions(?array $sections = null): array { return [ - self::htmlID(), - self::hintOptions(), - self::required(), - self::columnSpanFull(), - self::visibility($sections), + Accordions::make('check-list-options') + ->accordions([ + Accordion::make('general-options') + ->label(__('General Options')) + ->icon('iconpark-checklist-o') + ->schema([ + Grid::make() + ->columns() + ->schema([ + IconPicker::make('options.on-icon') + ->columns([ + 'default' => 1, + 'lg' => 3, + '2xl' => 5, + ]) + ->label(__('On Icon')), - IconPicker::make('options.on-icon') - ->columns([ - 'default' => 1, - 'lg' => 3, - '2xl' => 5, - ]) - ->label(__('On Icon')), - - IconPicker::make('options.off-icon') - ->columns([ - 'default' => 1, - 'lg' => 3, - '2xl' => 5, - ]) - ->label(__('Off Icon')), + IconPicker::make('options.off-icon') + ->columns([ + 'default' => 1, + 'lg' => 3, + '2xl' => 5, + ]) + ->label(__('Off Icon')), + ]), + self::required(), + self::columnSpanFull(), + self::htmlID(), + ]), + self::hintOptions(), + self::visibility($sections), + ]), ]; } diff --git a/src/Fields/FieldsContract.php b/src/Fields/FieldsContract.php index aa66d045..ebc1f3de 100644 --- a/src/Fields/FieldsContract.php +++ b/src/Fields/FieldsContract.php @@ -163,6 +163,11 @@ public static function getFieldCollectionItemsList(Field | FieldPreset | array $ $getCollection = collect(); + //@phpstan-ignore-next-line + if (optional($zeusField->options)['dataSource'] === null) { + return $getCollection; + } + //@phpstan-ignore-next-line if ($zeusField instanceof FieldPreset && is_string($zeusField->options)) { //@phpstan-ignore-next-line diff --git a/tests/FormsTest.php b/tests/FormsTest.php index d61c7da3..61407703 100644 --- a/tests/FormsTest.php +++ b/tests/FormsTest.php @@ -244,6 +244,7 @@ 'name' => 'sdf', 'columns' => 2, 'aside' => 0, + 'compact' => 0, 'fields' => [ [ 'name' => 'sdf',