From 67a57edd82c2cf1761c396ca08bf92930022a69d Mon Sep 17 00:00:00 2001 From: Ash Monsh Date: Mon, 15 Jan 2024 02:52:59 +0300 Subject: [PATCH 1/3] better field type selector --- composer.json | 3 +- composer.lock | 122 +++++++++++++----- .../views/filament/fields/types.blade.php | 15 +++ .../pages/browse-entry.blade.php | 6 +- .../pages/show-entry.blade.php | 8 +- .../themes/zeus/bolt/show-entry.blade.php | 6 +- src/Concerns/Schemata.php | 48 +++++-- src/Fields/Classes/CheckboxList.php | 10 ++ src/Fields/Classes/ColorPicker.php | 5 + src/Fields/Classes/DatePicker.php | 5 + src/Fields/Classes/DateTimePicker.php | 5 + src/Fields/Classes/FileUpload.php | 5 + src/Fields/Classes/Paragraph.php | 5 + src/Fields/Classes/Radio.php | 5 + src/Fields/Classes/RichEditor.php | 5 + src/Fields/Classes/Select.php | 5 + src/Fields/Classes/TextInput.php | 5 + src/Fields/Classes/Textarea.php | 5 + src/Fields/Classes/TimePicker.php | 5 + src/Fields/Classes/Toggle.php | 5 + src/Fields/FieldsContract.php | 12 ++ 21 files changed, 245 insertions(+), 45 deletions(-) create mode 100644 resources/views/filament/fields/types.blade.php diff --git a/composer.json b/composer.json index ab0873e9..50b20d6d 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,8 @@ "flowframe/laravel-trend": "^0.1.5", "guava/filament-icon-picker": "^2.0", "lara-zeus/accordion": "^1.0", - "lara-zeus/core": "^3.0" + "lara-zeus/core": "^3.0", + "ryangjchandler/blade-tabler-icons": "^2.2" }, "require-dev": { "laravel/pint": "^1.0", diff --git a/composer.lock b/composer.lock index c1ede7d9..7f5a4a75 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": "071fb01058129c4f15c0ce410df361d3", + "content-hash": "dcc558221642dafa9e472c54973d8a64", "packages": [ { "name": "alperenersoy/filament-export", @@ -1554,16 +1554,16 @@ }, { "name": "filament/actions", - "version": "v3.1.45", + "version": "v3.1.47", "source": { "type": "git", "url": "https://github.com/filamentphp/actions.git", - "reference": "8da79e0c098a64551e9ac37727c90b25235e57d2" + "reference": "70c85922297818e290710f23168740c319c378f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/actions/zipball/8da79e0c098a64551e9ac37727c90b25235e57d2", - "reference": "8da79e0c098a64551e9ac37727c90b25235e57d2", + "url": "https://api.github.com/repos/filamentphp/actions/zipball/70c85922297818e290710f23168740c319c378f5", + "reference": "70c85922297818e290710f23168740c319c378f5", "shasum": "" }, "require": { @@ -1601,20 +1601,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-01-11T12:33:06+00:00" + "time": "2024-01-12T12:31:49+00:00" }, { "name": "filament/filament", - "version": "v3.1.45", + "version": "v3.1.47", "source": { "type": "git", "url": "https://github.com/filamentphp/panels.git", - "reference": "ae1f2a035321002dbbe83cb0f8f4b6e9c1076f34" + "reference": "075adb3ca819e730679744445e2d6508bb726e3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/panels/zipball/ae1f2a035321002dbbe83cb0f8f4b6e9c1076f34", - "reference": "ae1f2a035321002dbbe83cb0f8f4b6e9c1076f34", + "url": "https://api.github.com/repos/filamentphp/panels/zipball/075adb3ca819e730679744445e2d6508bb726e3d", + "reference": "075adb3ca819e730679744445e2d6508bb726e3d", "shasum": "" }, "require": { @@ -1666,20 +1666,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-01-11T12:33:11+00:00" + "time": "2024-01-12T11:54:25+00:00" }, { "name": "filament/forms", - "version": "v3.1.45", + "version": "v3.1.47", "source": { "type": "git", "url": "https://github.com/filamentphp/forms.git", - "reference": "22f0e4d3a38b32f30381397325c152211ab94a03" + "reference": "27e9a869c06253ce7b3cd1db252fdceb5621d0c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/forms/zipball/22f0e4d3a38b32f30381397325c152211ab94a03", - "reference": "22f0e4d3a38b32f30381397325c152211ab94a03", + "url": "https://api.github.com/repos/filamentphp/forms/zipball/27e9a869c06253ce7b3cd1db252fdceb5621d0c6", + "reference": "27e9a869c06253ce7b3cd1db252fdceb5621d0c6", "shasum": "" }, "require": { @@ -1722,20 +1722,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-01-11T12:33:00+00:00" + "time": "2024-01-12T11:54:20+00:00" }, { "name": "filament/infolists", - "version": "v3.1.45", + "version": "v3.1.47", "source": { "type": "git", "url": "https://github.com/filamentphp/infolists.git", - "reference": "2515985792f32c68984ad2ea6b974b7342829e29" + "reference": "bc0735e0a4efd73af6dd8e2d9f773bdafaf98ab6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/infolists/zipball/2515985792f32c68984ad2ea6b974b7342829e29", - "reference": "2515985792f32c68984ad2ea6b974b7342829e29", + "url": "https://api.github.com/repos/filamentphp/infolists/zipball/bc0735e0a4efd73af6dd8e2d9f773bdafaf98ab6", + "reference": "bc0735e0a4efd73af6dd8e2d9f773bdafaf98ab6", "shasum": "" }, "require": { @@ -1773,11 +1773,11 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-01-08T12:59:23+00:00" + "time": "2024-01-12T11:54:23+00:00" }, { "name": "filament/notifications", - "version": "v3.1.45", + "version": "v3.1.47", "source": { "type": "git", "url": "https://github.com/filamentphp/notifications.git", @@ -1829,7 +1829,7 @@ }, { "name": "filament/spatie-laravel-translatable-plugin", - "version": "v3.1.45", + "version": "v3.1.47", "source": { "type": "git", "url": "https://github.com/filamentphp/spatie-laravel-translatable-plugin.git", @@ -1874,16 +1874,16 @@ }, { "name": "filament/support", - "version": "v3.1.45", + "version": "v3.1.47", "source": { "type": "git", "url": "https://github.com/filamentphp/support.git", - "reference": "954fdfb81f6f59dadef8c94ddebd667d8ea1ac17" + "reference": "7122e56e5831a6423d7e028c3a2d08255aba08e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/support/zipball/954fdfb81f6f59dadef8c94ddebd667d8ea1ac17", - "reference": "954fdfb81f6f59dadef8c94ddebd667d8ea1ac17", + "url": "https://api.github.com/repos/filamentphp/support/zipball/7122e56e5831a6423d7e028c3a2d08255aba08e9", + "reference": "7122e56e5831a6423d7e028c3a2d08255aba08e9", "shasum": "" }, "require": { @@ -1927,11 +1927,11 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-01-11T16:43:44+00:00" + "time": "2024-01-12T11:54:33+00:00" }, { "name": "filament/tables", - "version": "v3.1.45", + "version": "v3.1.47", "source": { "type": "git", "url": "https://github.com/filamentphp/tables.git", @@ -1984,7 +1984,7 @@ }, { "name": "filament/widgets", - "version": "v3.1.45", + "version": "v3.1.47", "source": { "type": "git", "url": "https://github.com/filamentphp/widgets.git", @@ -5097,6 +5097,68 @@ ], "time": "2023-02-14T16:54:54+00:00" }, + { + "name": "ryangjchandler/blade-tabler-icons", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/ryangjchandler/blade-tabler-icons.git", + "reference": "0bb9dfff74ff38a1374b2d4f0ce1cb0585ea96ee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ryangjchandler/blade-tabler-icons/zipball/0bb9dfff74ff38a1374b2d4f0ce1cb0585ea96ee", + "reference": "0bb9dfff74ff38a1374b2d4f0ce1cb0585ea96ee", + "shasum": "" + }, + "require": { + "blade-ui-kit/blade-icons": "^1.5", + "illuminate/support": "^10.0", + "php": "^8.1" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.14", + "orchestra/testbench": "^8.0", + "phpunit/phpunit": "^9.5.10" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "RyanChandler\\TablerIcons\\BladeTablerIconsServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "RyanChandler\\TablerIcons\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ryan Chandler", + "email": "support@ryangjchandler.co.uk", + "homepage": "https://ryangjchandler.co.uk", + "role": "Developer" + } + ], + "description": "A package to easily make use of Tabler icons in your Laravel Blade views.", + "homepage": "https://github.com/ryangjchandler/blade-tabler-icons", + "keywords": [ + "blade", + "laravel", + "tabler" + ], + "support": { + "issues": "https://github.com/ryangjchandler/blade-tabler-icons/issues", + "source": "https://github.com/ryangjchandler/blade-tabler-icons/tree/v2.2.0" + }, + "time": "2024-01-07T23:33:22+00:00" + }, { "name": "sabberworm/php-css-parser", "version": "8.4.0", diff --git a/resources/views/filament/fields/types.blade.php b/resources/views/filament/fields/types.blade.php new file mode 100644 index 00000000..51b056e3 --- /dev/null +++ b/resources/views/filament/fields/types.blade.php @@ -0,0 +1,15 @@ +
+ @svg($field['icon'],'text-primary-500 w-5 h-5') + + + {{ $field['title'] }} + {{--{{ $field['description'] }}--}} + + + @svg('heroicon-o-information-circle','mx-2 w-4 h-4 text-gray-400') + + +
\ No newline at end of file diff --git a/resources/views/filament/resources/response-resource/pages/browse-entry.blade.php b/resources/views/filament/resources/response-resource/pages/browse-entry.blade.php index 6021c134..6f3bd392 100644 --- a/resources/views/filament/resources/response-resource/pages/browse-entry.blade.php +++ b/resources/views/filament/resources/response-resource/pages/browse-entry.blade.php @@ -57,7 +57,11 @@ class="rounded-full"
{{ __('status') }} @php $getStatues = $getRecord->statusDetails() @endphp - + @svg($getStatues['icon'],'w-4 h-4 inline') {{ $getStatues['label'] }} diff --git a/resources/views/filament/resources/response-resource/pages/show-entry.blade.php b/resources/views/filament/resources/response-resource/pages/show-entry.blade.php index 32b6d46b..d76bec69 100644 --- a/resources/views/filament/resources/response-resource/pages/show-entry.blade.php +++ b/resources/views/filament/resources/response-resource/pages/show-entry.blade.php @@ -55,7 +55,11 @@ class="rounded-full"
{{ __('status') }} @php $getStatues = $response->statusDetails() @endphp - + @svg($getStatues['icon'],'w-4 h-4 inline') {{ $getStatues['label'] }} @@ -69,4 +73,4 @@ class="rounded-full"
- \ No newline at end of file + diff --git a/resources/views/themes/zeus/bolt/show-entry.blade.php b/resources/views/themes/zeus/bolt/show-entry.blade.php index bb50f2c1..a033a0f5 100644 --- a/resources/views/themes/zeus/bolt/show-entry.blade.php +++ b/resources/views/themes/zeus/bolt/show-entry.blade.php @@ -62,7 +62,11 @@
{{ __('status') }} @php $getStatues = $response->statusDetails() @endphp - + @svg($getStatues['icon'],'w-4 h-4 inline') {{ $getStatues['label'] }} diff --git a/src/Concerns/Schemata.php b/src/Concerns/Schemata.php index 3cf602f3..01485e28 100644 --- a/src/Concerns/Schemata.php +++ b/src/Concerns/Schemata.php @@ -21,6 +21,7 @@ use Filament\Forms\Get; use Filament\Forms\Set; use Guava\FilamentIconPicker\Forms\IconPicker; +use Illuminate\Support\HtmlString; use Illuminate\Support\Str; use LaraZeus\Accordion\Forms\Accordion; use LaraZeus\Accordion\Forms\Accordions; @@ -39,7 +40,7 @@ protected static function getVisibleFields(array $sections, array $arguments): a $sections['fields'] = collect($sections['fields']) ->reject(function ($item, $key) use ($arguments) { return $key === $arguments['item'] || - ! ( + !( isset($item['options']['dataSource']) || $item['type'] === '\LaraZeus\Bolt\Fields\Classes\Toggle' ); @@ -65,7 +66,7 @@ protected static function sectionOptionsFormSchema(array $formOptions, array $al ->icon('iconpark-viewgriddetail-o') ->schema([ Select::make('columns') - ->options(fn (): array => array_combine(range(1, 12), range(1, 12))) + ->options(fn(): array => array_combine(range(1, 12), range(1, 12))) ->required() ->default(1) ->hint(__('fields per row')) @@ -116,7 +117,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') @@ -124,7 +125,7 @@ public static function getMainFormSchema(): array ->color('warning') ->tooltip('more section options') ->icon('heroicon-m-cog') - ->fillForm(fn ( + ->fillForm(fn( array $arguments, Repeater $component ) => $component->getItemState($arguments['item'])) @@ -143,7 +144,7 @@ public static function getMainFormSchema(): array $component->state($state); }), ]) - ->itemLabel(fn (array $state): ?string => $state['name'] ?? null) + ->itemLabel(fn(array $state): ?string => $state['name'] ?? null) ->columnSpan(2), ]; } @@ -255,7 +256,7 @@ public static function getTabsSchema(): array }), TextInput::make('slug')->required()->maxLength(255)->label(__('slug')), ]) - ->getOptionLabelFromRecordUsing(fn (Category $record) => "{$record->name}"), + ->getOptionLabelFromRecordUsing(fn(Category $record) => "{$record->name}"), Grid::make() ->columns(2) ->schema([ @@ -352,7 +353,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, @@ -360,7 +361,7 @@ public static function getSectionsSchema(): array '2xl' => 3, ]) ->label('') - ->itemLabel(fn (array $state): ?string => $state['name'] ?? null) + ->itemLabel(fn(array $state): ?string => $state['name'] ?? null) ->addActionLabel(__('Add field')) ->extraItemActions([ Action::make('fields options') @@ -370,7 +371,7 @@ public static function getSectionsSchema(): array ->icon('heroicon-m-cog') ->modalIcon('heroicon-m-cog') ->modalDescription(__('advanced fields settings')) - ->fillForm(fn ( + ->fillForm(fn( $state, array $arguments, Repeater $component @@ -411,6 +412,14 @@ public static function getSectionsSchema(): array ]; } + public static function getCleanOptionString(array $field): string + { + return + view('zeus::filament.fields.types') + ->with('field', $field) + ->render(); + } + public static function getFieldsSchema(): array { return [ @@ -423,7 +432,26 @@ public static function getFieldsSchema(): array ->label(__('Field Name')), Select::make('type') ->required() - ->options(Bolt::availableFields()->pluck('title', 'class')) + ->searchable() + ->preload() + //->options(Bolt::availableFields()->pluck('title', 'class')) + + /*->getSearchResultsUsing(function (string $search) { + $users = Bolt::availableFields()->where('title', 'like', "%{$search}%"); + + return $users->mapWithKeys(function ($user) { + return [$user->getKey() => static::getCleanOptionString($user)]; + })->toArray(); + })*/ + ->allowHtml() + ->extraAttributes(['class'=>'field-type']) + ->options(function (): array { + return Bolt::availableFields() + ->mapWithKeys(function ($user) { + return [$user['class'] => static::getCleanOptionString($user)]; + }) + ->toArray(); + }) ->live() ->default('\LaraZeus\Bolt\Fields\Classes\TextInput') ->label(__('Field Type')), diff --git a/src/Fields/Classes/CheckboxList.php b/src/Fields/Classes/CheckboxList.php index 4444ba70..d0cb4f79 100644 --- a/src/Fields/Classes/CheckboxList.php +++ b/src/Fields/Classes/CheckboxList.php @@ -19,6 +19,16 @@ public function title(): string return __('Checkbox List'); } + public function icon(): string + { + return 'tabler-list-check'; + } + + public function description(): string + { + return __('checkbox items from data source'); + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/ColorPicker.php b/src/Fields/Classes/ColorPicker.php index 694e03e7..7c0ffac4 100644 --- a/src/Fields/Classes/ColorPicker.php +++ b/src/Fields/Classes/ColorPicker.php @@ -19,6 +19,11 @@ public function title(): string return __('Color Picker'); } + public function icon(): string + { + return 'tabler-color-picker'; + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/DatePicker.php b/src/Fields/Classes/DatePicker.php index 09590c15..b93cf3bb 100644 --- a/src/Fields/Classes/DatePicker.php +++ b/src/Fields/Classes/DatePicker.php @@ -17,6 +17,11 @@ public function title(): string return __('Date Picker'); } + public function icon(): string + { + return 'tabler-calendar'; + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/DateTimePicker.php b/src/Fields/Classes/DateTimePicker.php index 90f77d58..8204f763 100644 --- a/src/Fields/Classes/DateTimePicker.php +++ b/src/Fields/Classes/DateTimePicker.php @@ -17,6 +17,11 @@ public function title(): string return __('Date Time Picker'); } + public function icon(): string + { + return 'tabler-calendar-time'; + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/FileUpload.php b/src/Fields/Classes/FileUpload.php index 5c7c9e65..3bdf931a 100644 --- a/src/Fields/Classes/FileUpload.php +++ b/src/Fields/Classes/FileUpload.php @@ -21,6 +21,11 @@ public function title(): string return __('File Upload'); } + public function icon(): string + { + return 'tabler-cloud-upload'; + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/Paragraph.php b/src/Fields/Classes/Paragraph.php index 65a63c54..36cfe9db 100644 --- a/src/Fields/Classes/Paragraph.php +++ b/src/Fields/Classes/Paragraph.php @@ -18,6 +18,11 @@ public function title(): string return __('Paragraph'); } + public function icon(): string + { + return 'tabler-text-recognition'; + } + public static function getOptions(): array { return [ diff --git a/src/Fields/Classes/Radio.php b/src/Fields/Classes/Radio.php index 1d177541..a644e508 100644 --- a/src/Fields/Classes/Radio.php +++ b/src/Fields/Classes/Radio.php @@ -21,6 +21,11 @@ public function title(): string return __('Radio'); } + public function icon(): string + { + return 'tabler-circle-check'; + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/RichEditor.php b/src/Fields/Classes/RichEditor.php index 7427e31d..f4a89ffe 100644 --- a/src/Fields/Classes/RichEditor.php +++ b/src/Fields/Classes/RichEditor.php @@ -17,6 +17,11 @@ public function title(): string return __('Rich Editor'); } + public function icon(): string + { + return 'tabler-cursor-text'; + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/Select.php b/src/Fields/Classes/Select.php index 81dd306d..7cbf4636 100644 --- a/src/Fields/Classes/Select.php +++ b/src/Fields/Classes/Select.php @@ -21,6 +21,11 @@ public function title(): string return __('Select Menu'); } + public function icon(): string + { + return 'tabler-selector'; + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/TextInput.php b/src/Fields/Classes/TextInput.php index 542ab1fb..5d61abee 100644 --- a/src/Fields/Classes/TextInput.php +++ b/src/Fields/Classes/TextInput.php @@ -24,6 +24,11 @@ public function title(): string return __('Text Input'); } + public function icon(): string + { + return 'tabler-input-search'; + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/Textarea.php b/src/Fields/Classes/Textarea.php index 3d6cd998..563dea99 100644 --- a/src/Fields/Classes/Textarea.php +++ b/src/Fields/Classes/Textarea.php @@ -20,6 +20,11 @@ public function title(): string return __('Textarea'); } + public function icon(): string + { + return 'tabler-text-size'; + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/TimePicker.php b/src/Fields/Classes/TimePicker.php index ef9062e3..57732b87 100644 --- a/src/Fields/Classes/TimePicker.php +++ b/src/Fields/Classes/TimePicker.php @@ -17,6 +17,11 @@ public function title(): string return __('Time Picker'); } + public function icon(): string + { + return 'tabler-clock-hour-8'; + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/Toggle.php b/src/Fields/Classes/Toggle.php index db6b74bd..5e68f81e 100644 --- a/src/Fields/Classes/Toggle.php +++ b/src/Fields/Classes/Toggle.php @@ -20,6 +20,11 @@ public function title(): string return __('Toggle'); } + public function icon(): string + { + return 'tabler-toggle-left'; + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/FieldsContract.php b/src/Fields/FieldsContract.php index 90e49dda..c937d7ec 100644 --- a/src/Fields/FieldsContract.php +++ b/src/Fields/FieldsContract.php @@ -42,6 +42,8 @@ public function toArray(): array 'code' => class_basename($this), 'sort' => $this->sort, 'title' => $this->title(), + 'description' => $this->description(), + 'icon' => $this->icon(), ]; } @@ -50,6 +52,16 @@ public function title(): string return __(class_basename($this)); } + public function description(): string + { + return __('field text for all the text you need'); + } + + public function icon(): string + { + return 'iconpark-aligntextcenter-o'; + } + public function hasOptions(): bool { return method_exists(get_called_class(), 'getOptions'); From 33496fc5f64892fd2af5ed1ae81a2ac4afb0bfcd Mon Sep 17 00:00:00 2001 From: Ash Monsh Date: Mon, 15 Jan 2024 03:05:30 +0300 Subject: [PATCH 2/3] add desc for all feilds --- src/Fields/Classes/ColorPicker.php | 5 +++++ src/Fields/Classes/DatePicker.php | 5 +++++ src/Fields/Classes/DateTimePicker.php | 5 +++++ src/Fields/Classes/FileUpload.php | 5 +++++ src/Fields/Classes/Paragraph.php | 5 +++++ src/Fields/Classes/Radio.php | 5 +++++ src/Fields/Classes/RichEditor.php | 5 +++++ src/Fields/Classes/Select.php | 5 +++++ src/Fields/Classes/TextInput.php | 5 +++++ src/Fields/Classes/Textarea.php | 5 +++++ src/Fields/Classes/TimePicker.php | 5 +++++ src/Fields/Classes/Toggle.php | 5 +++++ 12 files changed, 60 insertions(+) diff --git a/src/Fields/Classes/ColorPicker.php b/src/Fields/Classes/ColorPicker.php index 7c0ffac4..2c4f659a 100644 --- a/src/Fields/Classes/ColorPicker.php +++ b/src/Fields/Classes/ColorPicker.php @@ -24,6 +24,11 @@ public function icon(): string return 'tabler-color-picker'; } + public function description(): string + { + return __('pick a color with rgb, rgba or hsl'); + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/DatePicker.php b/src/Fields/Classes/DatePicker.php index b93cf3bb..110c3ecf 100644 --- a/src/Fields/Classes/DatePicker.php +++ b/src/Fields/Classes/DatePicker.php @@ -22,6 +22,11 @@ public function icon(): string return 'tabler-calendar'; } + public function description(): string + { + return __('full date picker'); + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/DateTimePicker.php b/src/Fields/Classes/DateTimePicker.php index 8204f763..bf596011 100644 --- a/src/Fields/Classes/DateTimePicker.php +++ b/src/Fields/Classes/DateTimePicker.php @@ -22,6 +22,11 @@ public function icon(): string return 'tabler-calendar-time'; } + public function description(): string + { + return __('full date and time picker'); + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/FileUpload.php b/src/Fields/Classes/FileUpload.php index 3bdf931a..bfa94359 100644 --- a/src/Fields/Classes/FileUpload.php +++ b/src/Fields/Classes/FileUpload.php @@ -26,6 +26,11 @@ public function icon(): string return 'tabler-cloud-upload'; } + public function description(): string + { + return __('single or multiple file uploader'); + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/Paragraph.php b/src/Fields/Classes/Paragraph.php index 36cfe9db..23014737 100644 --- a/src/Fields/Classes/Paragraph.php +++ b/src/Fields/Classes/Paragraph.php @@ -23,6 +23,11 @@ public function icon(): string return 'tabler-text-recognition'; } + public function description(): string + { + return __('display a paragraph in your form'); + } + public static function getOptions(): array { return [ diff --git a/src/Fields/Classes/Radio.php b/src/Fields/Classes/Radio.php index a644e508..8965078b 100644 --- a/src/Fields/Classes/Radio.php +++ b/src/Fields/Classes/Radio.php @@ -26,6 +26,11 @@ public function icon(): string return 'tabler-circle-check'; } + public function description(): string + { + return __('single choice from a datasource'); + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/RichEditor.php b/src/Fields/Classes/RichEditor.php index f4a89ffe..4980cd55 100644 --- a/src/Fields/Classes/RichEditor.php +++ b/src/Fields/Classes/RichEditor.php @@ -22,6 +22,11 @@ public function icon(): string return 'tabler-cursor-text'; } + public function description(): string + { + return __('Text editor with styling'); + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/Select.php b/src/Fields/Classes/Select.php index 7cbf4636..68dfb841 100644 --- a/src/Fields/Classes/Select.php +++ b/src/Fields/Classes/Select.php @@ -26,6 +26,11 @@ public function icon(): string return 'tabler-selector'; } + public function description(): string + { + return __('select single or multiple items from a dropdown list'); + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/TextInput.php b/src/Fields/Classes/TextInput.php index 5d61abee..b30c30ff 100644 --- a/src/Fields/Classes/TextInput.php +++ b/src/Fields/Classes/TextInput.php @@ -29,6 +29,11 @@ public function icon(): string return 'tabler-input-search'; } + public function description(): string + { + return __('text input'); + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/Textarea.php b/src/Fields/Classes/Textarea.php index 563dea99..59199eb0 100644 --- a/src/Fields/Classes/Textarea.php +++ b/src/Fields/Classes/Textarea.php @@ -25,6 +25,11 @@ public function icon(): string return 'tabler-text-size'; } + public function description(): string + { + return __('multi line textarea'); + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/TimePicker.php b/src/Fields/Classes/TimePicker.php index 57732b87..e7dd5d50 100644 --- a/src/Fields/Classes/TimePicker.php +++ b/src/Fields/Classes/TimePicker.php @@ -22,6 +22,11 @@ public function icon(): string return 'tabler-clock-hour-8'; } + public function description(): string + { + return __('time picker'); + } + public static function getOptions(?array $sections = null): array { return [ diff --git a/src/Fields/Classes/Toggle.php b/src/Fields/Classes/Toggle.php index 5e68f81e..626a677a 100644 --- a/src/Fields/Classes/Toggle.php +++ b/src/Fields/Classes/Toggle.php @@ -25,6 +25,11 @@ public function icon(): string return 'tabler-toggle-left'; } + public function description(): string + { + return __('toggle'); + } + public static function getOptions(?array $sections = null): array { return [ From bf714c196be81dd8c9284107107777c85927ecb7 Mon Sep 17 00:00:00 2001 From: atmonshi Date: Mon, 15 Jan 2024 00:05:54 +0000 Subject: [PATCH 3/3] Fix styling --- src/Concerns/Schemata.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Concerns/Schemata.php b/src/Concerns/Schemata.php index 01485e28..03dfbf2d 100644 --- a/src/Concerns/Schemata.php +++ b/src/Concerns/Schemata.php @@ -21,7 +21,6 @@ use Filament\Forms\Get; use Filament\Forms\Set; use Guava\FilamentIconPicker\Forms\IconPicker; -use Illuminate\Support\HtmlString; use Illuminate\Support\Str; use LaraZeus\Accordion\Forms\Accordion; use LaraZeus\Accordion\Forms\Accordions; @@ -40,7 +39,7 @@ protected static function getVisibleFields(array $sections, array $arguments): a $sections['fields'] = collect($sections['fields']) ->reject(function ($item, $key) use ($arguments) { return $key === $arguments['item'] || - !( + ! ( isset($item['options']['dataSource']) || $item['type'] === '\LaraZeus\Bolt\Fields\Classes\Toggle' ); @@ -66,7 +65,7 @@ protected static function sectionOptionsFormSchema(array $formOptions, array $al ->icon('iconpark-viewgriddetail-o') ->schema([ Select::make('columns') - ->options(fn(): array => array_combine(range(1, 12), range(1, 12))) + ->options(fn (): array => array_combine(range(1, 12), range(1, 12))) ->required() ->default(1) ->hint(__('fields per row')) @@ -125,7 +124,7 @@ public static function getMainFormSchema(): array ->color('warning') ->tooltip('more section options') ->icon('heroicon-m-cog') - ->fillForm(fn( + ->fillForm(fn ( array $arguments, Repeater $component ) => $component->getItemState($arguments['item'])) @@ -144,7 +143,7 @@ public static function getMainFormSchema(): array $component->state($state); }), ]) - ->itemLabel(fn(array $state): ?string => $state['name'] ?? null) + ->itemLabel(fn (array $state): ?string => $state['name'] ?? null) ->columnSpan(2), ]; } @@ -256,7 +255,7 @@ public static function getTabsSchema(): array }), TextInput::make('slug')->required()->maxLength(255)->label(__('slug')), ]) - ->getOptionLabelFromRecordUsing(fn(Category $record) => "{$record->name}"), + ->getOptionLabelFromRecordUsing(fn (Category $record) => "{$record->name}"), Grid::make() ->columns(2) ->schema([ @@ -361,7 +360,7 @@ public static function getSectionsSchema(): array '2xl' => 3, ]) ->label('') - ->itemLabel(fn(array $state): ?string => $state['name'] ?? null) + ->itemLabel(fn (array $state): ?string => $state['name'] ?? null) ->addActionLabel(__('Add field')) ->extraItemActions([ Action::make('fields options') @@ -371,7 +370,7 @@ public static function getSectionsSchema(): array ->icon('heroicon-m-cog') ->modalIcon('heroicon-m-cog') ->modalDescription(__('advanced fields settings')) - ->fillForm(fn( + ->fillForm(fn ( $state, array $arguments, Repeater $component @@ -443,8 +442,8 @@ public static function getFieldsSchema(): array return [$user->getKey() => static::getCleanOptionString($user)]; })->toArray(); })*/ - ->allowHtml() - ->extraAttributes(['class'=>'field-type']) + ->allowHtml() + ->extraAttributes(['class' => 'field-type']) ->options(function (): array { return Bolt::availableFields() ->mapWithKeys(function ($user) {