From 2a9ef43286fce48820d75ec0283986e6c8496060 Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Sun, 14 May 2023 23:27:48 +0330 Subject: [PATCH 01/19] Adds the possibility of having '0' as prefix for text-inputs. --- packages/forms/resources/views/components/text-input.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/forms/resources/views/components/text-input.blade.php b/packages/forms/resources/views/components/text-input.blade.php index 8b7679ef7d..1fe87e96b6 100644 --- a/packages/forms/resources/views/components/text-input.blade.php +++ b/packages/forms/resources/views/components/text-input.blade.php @@ -30,7 +30,7 @@ @endif - @if ($label = $getPrefixLabel()) + @if (filled($label = $getPrefixLabel()) && ($getPrefixLabel() !== false)) {{ $label }} From ff7e33e184ba189153d79760408e4a4f9a1efc2b Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Sun, 14 May 2023 23:29:15 +0330 Subject: [PATCH 02/19] Adds the possibility of having '0' as postfix for text-inputs. --- packages/forms/resources/views/components/text-input.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/forms/resources/views/components/text-input.blade.php b/packages/forms/resources/views/components/text-input.blade.php index 1fe87e96b6..7ffbe28b76 100644 --- a/packages/forms/resources/views/components/text-input.blade.php +++ b/packages/forms/resources/views/components/text-input.blade.php @@ -83,7 +83,7 @@ /> - @if ($label = $getSuffixLabel()) + @if (filled($label = $getSuffixLabel()) && ($getSuffixLabel() !== false))) {{ $label }} From eaf2e629df7b7442264da8478cd1ddd7ca20a508 Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Sun, 14 May 2023 23:32:50 +0330 Subject: [PATCH 03/19] Adds the possibility of having '0' as prefix for select-inputs. --- packages/forms/resources/views/components/select.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/forms/resources/views/components/select.blade.php b/packages/forms/resources/views/components/select.blade.php index 62b8400f77..b1745d7e35 100644 --- a/packages/forms/resources/views/components/select.blade.php +++ b/packages/forms/resources/views/components/select.blade.php @@ -29,7 +29,7 @@ @endif - @if ($label = $getPrefixLabel()) + @if (filled($label = $getPrefixLabel()) && ($getPrefixLabel() !== false)) {{ $label }} From 5bb4b3f80c259a4858fc7059279e2d199d4b7a2f Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Sun, 14 May 2023 23:34:38 +0330 Subject: [PATCH 04/19] Adds the possibility of having '0' as postfix for select-inputs. --- packages/forms/resources/views/components/select.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/forms/resources/views/components/select.blade.php b/packages/forms/resources/views/components/select.blade.php index b1745d7e35..b22a7ab811 100644 --- a/packages/forms/resources/views/components/select.blade.php +++ b/packages/forms/resources/views/components/select.blade.php @@ -126,7 +126,7 @@ @endif - @if ($label = $getSuffixLabel()) + @if (filled($label = $getSuffixLabel()) && ($getSuffixLabel() !== false)) {{ $label }} From b6b72a59e2652bf9ed01e3e259ab75ae99a25395 Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Sun, 14 May 2023 23:37:40 +0330 Subject: [PATCH 05/19] Adds the possibility of having '0' as prefix for color-picker inputs. --- .../forms/resources/views/components/color-picker.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/forms/resources/views/components/color-picker.blade.php b/packages/forms/resources/views/components/color-picker.blade.php index c9690451c6..cc3def0d4a 100644 --- a/packages/forms/resources/views/components/color-picker.blade.php +++ b/packages/forms/resources/views/components/color-picker.blade.php @@ -29,7 +29,7 @@ @endif - @if ($label = $getPrefixLabel()) + @if (filled($label = $getPrefixLabel()) && ($getPrefixLabel() !== false)) {{ $label }} From 758d3628ee8fe259fe5c4aeb33871b2b09b0914e Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Sun, 14 May 2023 23:38:25 +0330 Subject: [PATCH 06/19] Adds the possibility of having '0' as postfix for color-picker inputs. --- .../forms/resources/views/components/color-picker.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/forms/resources/views/components/color-picker.blade.php b/packages/forms/resources/views/components/color-picker.blade.php index cc3def0d4a..84a9a01f15 100644 --- a/packages/forms/resources/views/components/color-picker.blade.php +++ b/packages/forms/resources/views/components/color-picker.blade.php @@ -102,7 +102,7 @@ - @if ($label = $getSuffixLabel()) + @if (filled($label = $getSuffixLabel()) && ($getSuffixLabel() !== false)) {{ $label }} From b635c57a43e2d36733a21f9971d7aacf51e587ad Mon Sep 17 00:00:00 2001 From: Julio Motol Date: Tue, 16 May 2023 15:30:02 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=F0=9F=93=8C=20Allow=20`spatie/laravel-se?= =?UTF-8?q?ttings:^3.0`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julio Motol --- packages/spatie-laravel-settings-plugin/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/spatie-laravel-settings-plugin/composer.json b/packages/spatie-laravel-settings-plugin/composer.json index 9973acbbd0..b0e1463a33 100644 --- a/packages/spatie-laravel-settings-plugin/composer.json +++ b/packages/spatie-laravel-settings-plugin/composer.json @@ -13,7 +13,7 @@ "illuminate/console": "^8.6|^9.0|^10.0", "illuminate/filesystem": "^8.6|^9.0|^10.0", "illuminate/support": "^8.6|^9.0|^10.0", - "spatie/laravel-settings": "^2.2" + "spatie/laravel-settings": "^2.2|^3.0" }, "autoload": { "psr-4": { From 7421ef1f4a85f3b251a525dea669f793b2cb5645 Mon Sep 17 00:00:00 2001 From: Zep Fietje Date: Tue, 16 May 2023 12:15:24 +0200 Subject: [PATCH 08/19] Support ascii validation rule --- packages/forms/src/Components/Concerns/CanBeValidated.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/forms/src/Components/Concerns/CanBeValidated.php b/packages/forms/src/Components/Concerns/CanBeValidated.php index b07bc75744..aa135902e2 100644 --- a/packages/forms/src/Components/Concerns/CanBeValidated.php +++ b/packages/forms/src/Components/Concerns/CanBeValidated.php @@ -50,6 +50,13 @@ trait CanBeValidated return $this; } + public function ascii(bool | Closure $condition = true): static + { + $this->rule('ascii', $condition); + + return $this; + } + public function confirmed(bool | Closure $condition = true): static { $this->rule('confirmed', $condition); From 6f2665f88ba343fae48c16d1a768bc21b93ef2dd Mon Sep 17 00:00:00 2001 From: Zep Fietje Date: Tue, 16 May 2023 17:26:52 +0200 Subject: [PATCH 09/19] Document --- packages/forms/docs/05-validation.md | 84 +++++++++++++++------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/packages/forms/docs/05-validation.md b/packages/forms/docs/05-validation.md index be1af1f4e0..12e9ffdd28 100644 --- a/packages/forms/docs/05-validation.md +++ b/packages/forms/docs/05-validation.md @@ -14,7 +14,7 @@ Filament includes several [dedicated validation methods](#available-rules), but ### Active URL -The field must have a valid A or AAAA record according to the `dns_get_record()` PHP function. [See the Laravel documentation](https://laravel.com/docs/validation#rule-active-url) +The field must have a valid A or AAAA record according to the `dns_get_record()` PHP function. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-active-url) ```php Field::make('name')->activeUrl() @@ -22,7 +22,7 @@ Field::make('name')->activeUrl() ### After (date) -The field value must be a value after a given date. [See the Laravel documentation](https://laravel.com/docs/validation#rule-after) +The field value must be a value after a given date. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-after) ```php Field::make('startDate')->after('tomorrow') @@ -37,7 +37,7 @@ Field::make('endDate')->after('startDate') ### After or equal to (date) -The field value must be a date after or equal to the given date. [See the Laravel documentation](https://laravel.com/docs/validation#rule-after-or-equal) +The field value must be a date after or equal to the given date. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-after-or-equal) ```php Field::make('startDate')->afterOrEqual('tomorrow') @@ -52,7 +52,7 @@ Field::make('endDate')->afterOrEqual('startDate') ### Alpha -The field must be entirely alphabetic characters. [See the Laravel documentation](https://laravel.com/docs/validation#rule-alpha) +The field must be entirely alphabetic characters. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-alpha) ```php Field::make('name')->alpha() @@ -60,7 +60,7 @@ Field::make('name')->alpha() ### Alpha Dash -The field may have alpha-numeric characters, as well as dashes and underscores. [See the Laravel documentation](https://laravel.com/docs/validation#rule-alpha-dash) +The field may have alpha-numeric characters, as well as dashes and underscores. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-alpha-dash) ```php Field::make('name')->alphaDash() @@ -68,15 +68,19 @@ Field::make('name')->alphaDash() ### Alpha Numeric -The field must be entirely alpha-numeric characters. [See the Laravel documentation](https://laravel.com/docs/validation#rule-alpha-num) +The field must be entirely alpha-numeric characters. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-alpha-num) ```php Field::make('name')->alphaNum() ``` +### ASCII + +The field must be entirely 7-bit ASCII characters. [See the Laravel documentation.](https://laravel.com/docs/10.x/validation#rule-ascii) + ### Before (date) -The field value must be a date before a given date. [See the Laravel documentation](https://laravel.com/docs/validation#rule-before) +The field value must be a date before a given date. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-before) ```php Field::make('startDate')->before('first day of next month') @@ -91,7 +95,7 @@ Field::make('endDate') ### Before or equal to (date) -The field value must be a date before or equal to the given date. [See the Laravel documentation](https://laravel.com/docs/validation#rule-before-or-equal) +The field value must be a date before or equal to the given date. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-before-or-equal) ```php Field::make('startDate')->beforeOrEqual('end of this month') @@ -106,7 +110,7 @@ Field::make('endDate') ### Confirmed -The field must have a matching field of `{field}_confirmation`. [See the Laravel documentation](https://laravel.com/docs/validation#rule-confirmed) +The field must have a matching field of `{field}_confirmation`. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-confirmed) ```php Field::make('password')->confirmed() @@ -115,7 +119,7 @@ Field::make('password_confirmation') ### Different -The field value must be different to another. [See the Laravel documentation](https://laravel.com/docs/validation#rule-different) +The field value must be different to another. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-different) ```php Field::make('backupEmail')->different('email') @@ -123,7 +127,7 @@ Field::make('backupEmail')->different('email') ### Doesnt Start With -The field must not start with one of the given values. [See the Laravel documentation](https://laravel.com/docs/validation#rule-doesnt-start-with) +The field must not start with one of the given values. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-doesnt-start-with) ```php Field::make('name')->doesntStartWith(['admin']) @@ -131,7 +135,7 @@ Field::make('name')->doesntStartWith(['admin']) ### Doesnt End With -The field must not end with one of the given values. [See the Laravel documentation](https://laravel.com/docs/validation#rule-doesnt-end-with) +The field must not end with one of the given values. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-doesnt-end-with) ```php Field::make('name')->doesntEndWith(['admin']) @@ -139,7 +143,7 @@ Field::make('name')->doesntEndWith(['admin']) ### Ends With -The field must end with one of the given values. [See the Laravel documentation](https://laravel.com/docs/validation#rule-ends-with) +The field must end with one of the given values. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-ends-with) ```php Field::make('name')->endsWith(['bot']) @@ -147,7 +151,7 @@ Field::make('name')->endsWith(['bot']) ### Enum -The field must contain a valid enum value. [See the Laravel documentation](https://laravel.com/docs/validation#rule-enum) +The field must contain a valid enum value. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-enum) ```php Field::make('status')->enum(MyStatus::class) @@ -155,7 +159,7 @@ Field::make('status')->enum(MyStatus::class) ### Exists -The field value must exist in the database. [See the Laravel documentation](https://laravel.com/docs/validation#rule-exists). +The field value must exist in the database. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-exists). ```php Field::make('invitation')->exists() @@ -188,7 +192,7 @@ Field::make('invitation') ### Filled -The field must not be empty when it is present. [See the Laravel documentation](https://laravel.com/docs/validation#rule-filled) +The field must not be empty when it is present. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-filled) ```php Field::make('name')->filled() @@ -196,7 +200,7 @@ Field::make('name')->filled() ### Greater than -The field value must be greater than another. [See the Laravel documentation](https://laravel.com/docs/validation#rule-gt) +The field value must be greater than another. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-gt) ```php Field::make('newNumber')->gt('oldNumber') @@ -204,14 +208,14 @@ Field::make('newNumber')->gt('oldNumber') ### Greater than or equal to -The field value must be greater than or equal to another. [See the Laravel documentation](https://laravel.com/docs/validation#rule-gte) +The field value must be greater than or equal to another. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-gte) ```php Field::make('newNumber')->gte('oldNumber') ``` ### In -The field must be included in the given list of values. [See the Laravel documentation](https://laravel.com/docs/validation#rule-in) +The field must be included in the given list of values. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-in) ```php Field::make('status')->in(['pending', 'completed']) @@ -219,7 +223,7 @@ Field::make('status')->in(['pending', 'completed']) ### Ip Address -The field must be an IP address. [See the Laravel documentation](https://laravel.com/docs/validation#rule-ip) +The field must be an IP address. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-ip) ```php Field::make('ip_address')->ip() @@ -229,7 +233,7 @@ Field::make('ip_address')->ipv6() ### JSON -The field must be a valid JSON string. [See the Laravel documentation](https://laravel.com/docs/validation#rule-json) +The field must be a valid JSON string. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-json) ```php Field::make('ip_address')->json() @@ -237,7 +241,7 @@ Field::make('ip_address')->json() ### Less than -The field value must be less than another. [See the Laravel documentation](https://laravel.com/docs/validation#rule-lt) +The field value must be less than another. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-lt) ```php Field::make('newNumber')->lt('oldNumber') @@ -245,7 +249,7 @@ Field::make('newNumber')->lt('oldNumber') ### Less than or equal to -The field value must be less than or equal to another. [See the Laravel documentation](https://laravel.com/docs/validation#rule-lte) +The field value must be less than or equal to another. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-lte) ```php Field::make('newNumber')->lte('oldNumber') @@ -253,7 +257,7 @@ Field::make('newNumber')->lte('oldNumber') ### Mac Address -The field must be a MAC address. [See the Laravel documentation](https://laravel.com/docs/validation#rule-mac) +The field must be a MAC address. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-mac) ```php Field::make('mac_address')->macAddress() @@ -261,7 +265,7 @@ Field::make('mac_address')->macAddress() ### Multiple Of -The field must be a multiple of value. [See the Laravel documentation](https://laravel.com/docs/validation#multiple-of) +The field must be a multiple of value. [See the Laravel documentation.](https://laravel.com/docs/validation#multiple-of) ```php Field::make('number')->multipleOf(2) @@ -269,7 +273,7 @@ Field::make('number')->multipleOf(2) ### Not In -The field must not be included in the given list of values. [See the Laravel documentation](https://laravel.com/docs/validation#rule-not-in) +The field must not be included in the given list of values. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-not-in) ```php Field::make('status')->notIn(['cancelled', 'rejected']) @@ -277,7 +281,7 @@ Field::make('status')->notIn(['cancelled', 'rejected']) ### Not Regex -The field must not match the given regular expression. [See the Laravel documentation](https://laravel.com/docs/validation#rule-not-regex) +The field must not match the given regular expression. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-not-regex) ```php Field::make('email')->notRegex('/^.+$/i') @@ -285,7 +289,7 @@ Field::make('email')->notRegex('/^.+$/i') ### Nullable -The field value can be empty. This rule is applied by default if the `required` rule is not present. [See the Laravel documentation](https://laravel.com/docs/validation#rule-nullable) +The field value can be empty. This rule is applied by default if the `required` rule is not present. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-nullable) ```php Field::make('name')->nullable() @@ -293,7 +297,7 @@ Field::make('name')->nullable() ### Prohibited -The field value must be empty. [See the Laravel documentation](https://laravel.com/docs/validation#rule-prohibited) +The field value must be empty. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-prohibited) ```php Field::make('name')->prohibited() @@ -301,7 +305,7 @@ Field::make('name')->prohibited() ### Required -The field value must not be empty. [See the Laravel documentation](https://laravel.com/docs/validation#rule-required) +The field value must not be empty. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-required) ```php Field::make('name')->required() @@ -309,7 +313,7 @@ Field::make('name')->required() ### Required With -The field value must not be empty _only if_ any of the other specified fields are not empty. [See the Laravel documentation](https://laravel.com/docs/validation#rule-required-with) +The field value must not be empty _only if_ any of the other specified fields are not empty. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-required-with) ```php Field::make('name')->requiredWith('field,another_field') @@ -317,7 +321,7 @@ Field::make('name')->requiredWith('field,another_field') ### Required With All -The field value must not be empty _only if_ all of the other specified fields are not empty. [See the Laravel documentation](https://laravel.com/docs/validation#rule-required-with-all) +The field value must not be empty _only if_ all of the other specified fields are not empty. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-required-with-all) ```php Field::make('name')->requiredWithAll('field,another_field') @@ -325,7 +329,7 @@ Field::make('name')->requiredWithAll('field,another_field') ### Required Without -The field value must not be empty _only when_ any of the other specified fields are empty. [See the Laravel documentation](https://laravel.com/docs/validation#rule-required-without) +The field value must not be empty _only when_ any of the other specified fields are empty. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-required-without) ```php Field::make('name')->requiredWithout('field,another_field') @@ -333,7 +337,7 @@ Field::make('name')->requiredWithout('field,another_field') ### Required Without All -The field value must not be empty _only when_ all of the other specified fields are empty. [See the Laravel documentation](https://laravel.com/docs/validation#rule-required-without-all) +The field value must not be empty _only when_ all of the other specified fields are empty. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-required-without-all) ```php Field::make('name')->requiredWithoutAll('field,another_field') @@ -341,7 +345,7 @@ Field::make('name')->requiredWithoutAll('field,another_field') ### Regex -The field must match the given regular expression. [See the Laravel documentation](https://laravel.com/docs/validation#rule-regex) +The field must match the given regular expression. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-regex) ```php Field::make('email')->regex('/^.+@.+$/i') @@ -349,7 +353,7 @@ Field::make('email')->regex('/^.+@.+$/i') ### Same -The field value must be the same as another. [See the Laravel documentation](https://laravel.com/docs/validation#rule-same) +The field value must be the same as another. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-same) ```php Field::make('password')->same('passwordConfirmation') @@ -357,7 +361,7 @@ Field::make('password')->same('passwordConfirmation') ### Starts With -The field must start with one of the given values. [See the Laravel documentation](https://laravel.com/docs/validation#rule-starts-with) +The field must start with one of the given values. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-starts-with) ```php Field::make('name')->startsWith(['a']) @@ -365,14 +369,14 @@ Field::make('name')->startsWith(['a']) ### String -The field must be a string. [See the Laravel documentation](https://laravel.com/docs/validation#rule-string) +The field must be a string. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-string) ```php Field::make('name')->string() ``` ### Unique -The field value must not exist in the database. [See the Laravel documentation](https://laravel.com/docs/validation#rule-unique) +The field value must not exist in the database. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-unique) ```php Field::make('email')->unique() @@ -417,7 +421,7 @@ Field::make('email') ### UUID -The field must be a valid RFC 4122 (version 1, 3, 4, or 5) universally unique identifier (UUID). [See the Laravel documentation](https://laravel.com/docs/validation#rule-uuid) +The field must be a valid RFC 4122 (version 1, 3, 4, or 5) universally unique identifier (UUID). [See the Laravel documentation.](https://laravel.com/docs/validation#rule-uuid) ```php Field::make('identifer')->uuid() From 4f54647969d6498431f263e3e377a8c319791e89 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Tue, 16 May 2023 20:42:57 +0100 Subject: [PATCH 10/19] Update group.blade.php --- packages/actions/resources/views/components/group.blade.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/actions/resources/views/components/group.blade.php b/packages/actions/resources/views/components/group.blade.php index 7ab24bc033..ffeb31b54a 100644 --- a/packages/actions/resources/views/components/group.blade.php +++ b/packages/actions/resources/views/components/group.blade.php @@ -2,6 +2,7 @@ 'actions' => [], 'button' => false, 'color' => null, + 'divided' => false, 'dropdownPlacement' => null, 'dynamicComponent' => null, 'group' => null, @@ -20,6 +21,7 @@ @php $group = \Filament\Actions\ActionGroup::make($actions) ->color($color) + ->divided($divided) ->dropdownPlacement($dropdownPlacement) ->icon($icon) ->indicator($indicator) From 08c2c2e942723eab70e4e14b869143846872d42d Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Tue, 16 May 2023 21:28:13 +0100 Subject: [PATCH 11/19] Action group docs --- packages/actions/docs/02-overview.md | 16 +++- packages/actions/docs/03-trigger-button.md | 11 +++ packages/actions/docs/05-grouping-actions.md | 89 +++++++++++++++++++ ...ding-an-action-to-a-livewire-component.md} | 8 +- .../01-create.md | 0 .../02-edit.md | 0 .../03-view.md | 0 .../04-delete.md | 0 .../05-replicate.md | 0 .../06-force-delete.md | 0 .../07-restore.md | 0 packages/tables/docs/04-filters.md | 6 +- 12 files changed, 122 insertions(+), 8 deletions(-) create mode 100644 packages/actions/docs/05-grouping-actions.md rename packages/actions/docs/{05-adding-an-action-to-a-livewire-component.md => 06-adding-an-action-to-a-livewire-component.md} (90%) rename packages/actions/docs/{06-prebuilt-actions => 07-prebuilt-actions}/01-create.md (100%) rename packages/actions/docs/{06-prebuilt-actions => 07-prebuilt-actions}/02-edit.md (100%) rename packages/actions/docs/{06-prebuilt-actions => 07-prebuilt-actions}/03-view.md (100%) rename packages/actions/docs/{06-prebuilt-actions => 07-prebuilt-actions}/04-delete.md (100%) rename packages/actions/docs/{06-prebuilt-actions => 07-prebuilt-actions}/05-replicate.md (100%) rename packages/actions/docs/{06-prebuilt-actions => 07-prebuilt-actions}/06-force-delete.md (100%) rename packages/actions/docs/{06-prebuilt-actions => 07-prebuilt-actions}/07-restore.md (100%) diff --git a/packages/actions/docs/02-overview.md b/packages/actions/docs/02-overview.md index c6bc792b84..5995334400 100644 --- a/packages/actions/docs/02-overview.md +++ b/packages/actions/docs/02-overview.md @@ -106,4 +106,18 @@ Filament includes several prebuilt actions that you can add to your app. Their a - [Delete](prebuilt-actions/delete) - [Replicate](prebuilt-actions/replicate) - [Force-delete](prebuilt-actions/force-delete) -- [Restore](prebuilt-actions/restore) \ No newline at end of file +- [Restore](prebuilt-actions/restore) + +## Grouping actions + +You may group actions together into a dropdown menu by using an `ActionGroup` object. Groups may contain many actions, or other groups: + +```php +ActionGroup::make([ + Action::make('view'), + Action::make('edit'), + Action::make('delete'), +]) +``` + +To learn about how to group actions, see the [Grouping actions](grouping-actions) page. diff --git a/packages/actions/docs/03-trigger-button.md b/packages/actions/docs/03-trigger-button.md index 5a5f21b608..71abc88021 100644 --- a/packages/actions/docs/03-trigger-button.md +++ b/packages/actions/docs/03-trigger-button.md @@ -41,6 +41,17 @@ Action::make('edit') +### Using an icon button on mobile devices only + +You may want to use a button style with a label on desktop, but remove the label on mobile. This will transform it into an icon button. You can do this with the `labeledFrom()` method, passing in the responsive [breakpoint](https://tailwindcss.com/docs/responsive-design#overview) at which you want the label to be added to the button: + +```php +Action::make('edit') + ->icon('heroicon-o-pencil-square') + ->button() + ->labeledFrom('md') +``` + ## Setting a label By default, the label of the trigger button is generated from its name. You may customize this using the `label()` method: diff --git a/packages/actions/docs/05-grouping-actions.md b/packages/actions/docs/05-grouping-actions.md new file mode 100644 index 0000000000..5055baf897 --- /dev/null +++ b/packages/actions/docs/05-grouping-actions.md @@ -0,0 +1,89 @@ +--- +title: Grouping actions +--- + +## Overview + +You may group actions together into a dropdown menu by using an `ActionGroup` object. Groups may contain many actions, or other groups: + +```php +ActionGroup::make([ + Action::make('view'), + Action::make('edit'), + Action::make('delete'), +]) +``` + +This page is about customizing the look of the group's trigger button and dropdown. + +## Customizing the group trigger style + +The button which opens the dropdown may be customized in the same way as a normal action. [All of the methods available for trigger buttons](trigger-button) may be used to customize the group trigger button: + +```php +ActionGroup::make([ + // Array of actions +]) + ->label('More actions') + ->icon('heroicon-m-ellipsis-vertical') + ->size('sm') + ->color('primary') + ->button() +``` + +## Setting the placement of the dropdown + +The dropdown may be positioned relative to the trigger button by using the `placement()` method: + +```php +ActionGroup::make([ + // Array of actions +]) + ->placement('bottom-start') +``` + +## Adding dividers between actions + +You may add dividers between each action in the dropdown by using the `divided()` method: + +```php +ActionGroup::make([ + // Array of actions +]) + ->divided() +``` + +If you'd like to group multiple actions together within one division, you may nest another `ActionGroup` within the main `ActionGroup`, and disable the dropdown on the nested group using `dropdown(false)`: + +```php +ActionGroup::make([ + // Array of individually divided actions + ActionGroup::make([ + // Array of actions within one division + ])->dropdown(false), + // Array of individually divided actions +]) + ->divided() +``` + +## Setting the width of the dropdown + +The dropdown may be set to a width by using the `width()` method. Options correspond to [Tailwind's max-width scale](https://tailwindcss.com/docs/max-width). The options are `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`, `5xl`, `6xl` and `7xl`: + +```php +ActionGroup::make([ + // Array of actions +]) + ->width('xs') +``` + +## Controlling the maximum height of the dropdown + +The dropdown content can have a maximum height using the `maxHeight()` method, so that it scrolls. You can pass a [CSS length](https://developer.mozilla.org/en-US/docs/Web/CSS/length): + +```php +ActionGroup::make([ + // Array of actions +]) + ->maxHeight('400px') +``` diff --git a/packages/actions/docs/05-adding-an-action-to-a-livewire-component.md b/packages/actions/docs/06-adding-an-action-to-a-livewire-component.md similarity index 90% rename from packages/actions/docs/05-adding-an-action-to-a-livewire-component.md rename to packages/actions/docs/06-adding-an-action-to-a-livewire-component.md index 9a60090fd4..79a03ef357 100644 --- a/packages/actions/docs/05-adding-an-action-to-a-livewire-component.md +++ b/packages/actions/docs/06-adding-an-action-to-a-livewire-component.md @@ -93,9 +93,9 @@ public function deleteAction(): Action } ``` -## Grouping actions +## Grouping actions in a Livewire view -You may group actions together into a dropdown menu by using the `` Blade component, passing in the `actions` array as an attribute: +You may [group actions together into a dropdown menu](grouping-actions) by using the `` Blade component, passing in the `actions` array as an attribute: ```blade
@@ -109,7 +109,7 @@ You may group actions together into a dropdown menu by using the ` ``` -You can also pass in a `label`, `icon`, `color`, `size`, `tooltip`, and `dropdown-placement` to the group, as attributes: +You can also pass in any attributes to customize the appearance of the trigger button and dropdown: ```blade
@@ -129,4 +129,4 @@ You can also pass in a `label`, `icon`, `color`, `size`, `tooltip`, and `dropdow
-``` \ No newline at end of file +``` diff --git a/packages/actions/docs/06-prebuilt-actions/01-create.md b/packages/actions/docs/07-prebuilt-actions/01-create.md similarity index 100% rename from packages/actions/docs/06-prebuilt-actions/01-create.md rename to packages/actions/docs/07-prebuilt-actions/01-create.md diff --git a/packages/actions/docs/06-prebuilt-actions/02-edit.md b/packages/actions/docs/07-prebuilt-actions/02-edit.md similarity index 100% rename from packages/actions/docs/06-prebuilt-actions/02-edit.md rename to packages/actions/docs/07-prebuilt-actions/02-edit.md diff --git a/packages/actions/docs/06-prebuilt-actions/03-view.md b/packages/actions/docs/07-prebuilt-actions/03-view.md similarity index 100% rename from packages/actions/docs/06-prebuilt-actions/03-view.md rename to packages/actions/docs/07-prebuilt-actions/03-view.md diff --git a/packages/actions/docs/06-prebuilt-actions/04-delete.md b/packages/actions/docs/07-prebuilt-actions/04-delete.md similarity index 100% rename from packages/actions/docs/06-prebuilt-actions/04-delete.md rename to packages/actions/docs/07-prebuilt-actions/04-delete.md diff --git a/packages/actions/docs/06-prebuilt-actions/05-replicate.md b/packages/actions/docs/07-prebuilt-actions/05-replicate.md similarity index 100% rename from packages/actions/docs/06-prebuilt-actions/05-replicate.md rename to packages/actions/docs/07-prebuilt-actions/05-replicate.md diff --git a/packages/actions/docs/06-prebuilt-actions/06-force-delete.md b/packages/actions/docs/07-prebuilt-actions/06-force-delete.md similarity index 100% rename from packages/actions/docs/06-prebuilt-actions/06-force-delete.md rename to packages/actions/docs/07-prebuilt-actions/06-force-delete.md diff --git a/packages/actions/docs/06-prebuilt-actions/07-restore.md b/packages/actions/docs/07-prebuilt-actions/07-restore.md similarity index 100% rename from packages/actions/docs/06-prebuilt-actions/07-restore.md rename to packages/actions/docs/07-prebuilt-actions/07-restore.md diff --git a/packages/tables/docs/04-filters.md b/packages/tables/docs/04-filters.md index e7441cd076..67c1f5e468 100644 --- a/packages/tables/docs/04-filters.md +++ b/packages/tables/docs/04-filters.md @@ -358,9 +358,9 @@ public function table(Table $table): Table } ``` -## Controlling the max height of the filters dropdown +## Controlling the maximum height of the filters dropdown -To add a max height to the filters dropdown content, so that they scroll, you may use the `filtersFormMaxHeight()` method, passing a [CSS length](https://developer.mozilla.org/en-US/docs/Web/CSS/length): +To add a maximum height to the filters dropdown content, so that they scroll, you may use the `filtersFormMaxHeight()` method, passing a [CSS length](https://developer.mozilla.org/en-US/docs/Web/CSS/length): ```php use Filament\Tables\Table; @@ -479,4 +479,4 @@ public function table(Table $table): Table ->label('Filter'), ); } -``` \ No newline at end of file +``` From 69f2d0be1e179420478fdf4f140701b1825d92df Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Tue, 16 May 2023 21:32:42 +0100 Subject: [PATCH 12/19] Update 05-actions.md --- packages/tables/docs/05-actions.md | 49 +++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/packages/tables/docs/05-actions.md b/packages/tables/docs/05-actions.md index b16a72c236..62b106b04b 100644 --- a/packages/tables/docs/05-actions.md +++ b/packages/tables/docs/05-actions.md @@ -106,6 +106,53 @@ BulkAction::make('delete') The function allows you to access the current table `$records` that are selected. It is an Eloquent collection of models. +### Grouping bulk actions + +You may use a `BulkActionGroup` object to [group multiple bulk actions together](../actions/grouping-actions) in a dropdown. Any bulk actions that remain outside of the `BulkActionGroup` will be rendered next to the dropdown's trigger button: + +```php +use Filament\Tables\Actions\BulkAction; +use Filament\Tables\Actions\BulkActionGroup; +use Filament\Tables\Table; + +public function table(Table $table): Table +{ + return $table + ->bulkActions([ + BulkActionGroup::make([ + BulkAction::make('delete') + ->requiresConfirmation() + ->action(fn (Collection $records) => $records->each->delete()), + BulkAction::make('forceDelete') + ->requiresConfirmation() + ->action(fn (Collection $records) => $records->each->forceDelete()), + ]), + BulkAction::make('export')->action(fn (Collection $records) => ...), + ]); +} +``` + +Alternatively, if all of your bulk actions are grouped, you can use the shorthand `groupedBulkActions()` method: + +```php +use Filament\Tables\Actions\BulkAction; +use Filament\Tables\Actions\BulkActionGroup; +use Filament\Tables\Table; + +public function table(Table $table): Table +{ + return $table + ->groupedBulkActions([ + BulkAction::make('delete') + ->requiresConfirmation() + ->action(fn (Collection $records) => $records->each->delete()), + BulkAction::make('forceDelete') + ->requiresConfirmation() + ->action(fn (Collection $records) => $records->each->forceDelete()), + ]); +} +``` + ### Deselecting records once a bulk action has finished You may deselect the records after a bulk action has been executed using the `deselectRecordsAfterCompletion()` method: @@ -281,4 +328,4 @@ use Filament\Tables\Actions\ActionGroup; ActionGroup::make([ // ... ])->tooltip('More actions'); -``` \ No newline at end of file +``` From 6220730177a168247b2bd16b0163ec358b479d91 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Tue, 16 May 2023 21:43:03 +0100 Subject: [PATCH 13/19] Add infolist to Livewire docs --- ...8-adding-a-form-to-a-livewire-component.md | 2 +- ...ing-an-infolist-to-a-livewire-component.md | 95 +++++++++++++++++++ ...-adding-a-table-to-a-livewire-component.md | 2 +- 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 packages/infolists/docs/05-adding-an-infolist-to-a-livewire-component.md diff --git a/packages/forms/docs/08-adding-a-form-to-a-livewire-component.md b/packages/forms/docs/08-adding-a-form-to-a-livewire-component.md index aacfd27923..6fa9214f1c 100644 --- a/packages/forms/docs/08-adding-a-form-to-a-livewire-component.md +++ b/packages/forms/docs/08-adding-a-form-to-a-livewire-component.md @@ -25,7 +25,7 @@ use Illuminate\Support\Facades\Route; Route::get('posts/create', CreatePost::class); ``` -### Adding the form +## Adding the form There are 5 main tasks when adding a form to a Livewire component class. Each one is essential: diff --git a/packages/infolists/docs/05-adding-an-infolist-to-a-livewire-component.md b/packages/infolists/docs/05-adding-an-infolist-to-a-livewire-component.md new file mode 100644 index 0000000000..05891078cc --- /dev/null +++ b/packages/infolists/docs/05-adding-an-infolist-to-a-livewire-component.md @@ -0,0 +1,95 @@ +--- +title: Adding an infolist to a Livewire component +--- + +## Setting up the Livewire component + +First, generate a new Livewire component: + +```bash +php artisan make:livewire ViewProduct +``` + +Then, render your Livewire component on the page: + +```blade +@livewire('view-product') +``` + +Alternatively, you can use a full-page Livewire component: + +```php +use App\Http\Livewire\ViewProduct; +use Illuminate\Support\Facades\Route; + +Route::get('products/{product}', ViewProduct::class); +``` + +## Adding the infolist + +Next, add a method to the Livewire component which accepts an `$infolist` object, modifies it, and returns it: + +```php +use Filament\Infolists\Infolist; + +public function productInfolist(Infolist $infolist): Infolist +{ + return $infolist + ->record($this->product) + ->schema([ + // ... + ]); +} +``` + +Finally, render the infolist in the Livewire component's view: + +```blade +{{ $this->productInfolist }} +``` + +## Passing data to the infolist + +You can pass data to the infolist in two ways: + +Either pass an Eloquent model instance to the `record()` method of the infolist, to automatically map all the model attributes and relationships to the entries in the infolist's schema: + +```php +use Filament\Infolists\Components\TextEntry; +use Filament\Infolists\Infolist; + +public function productInfolist(Infolist $infolist): Infolist +{ + return $infolist + ->record($this->product) + ->schema([ + TextEntry::make('name'), + TextEntry::make('category.name'), + // ... + ]); +} +``` + +Alternatively, you can pass an array of data to the `state()` method of the infolist, to manually map the data to the entries in the infolist's schema: + +```php +use Filament\Infolists\Components\TextEntry; +use Filament\Infolists\Infolist; + +public function productInfolist(Infolist $infolist): Infolist +{ + return $infolist + ->state([ + 'name' => 'MacBook Pro', + 'category' => [ + 'name' => 'Laptops', + ], + // ... + ]) + ->schema([ + TextEntry::make('name'), + TextEntry::make('category.name'), + // ... + ]); +} +``` diff --git a/packages/tables/docs/11-adding-a-table-to-a-livewire-component.md b/packages/tables/docs/11-adding-a-table-to-a-livewire-component.md index beb7d975a7..c850a2c839 100644 --- a/packages/tables/docs/11-adding-a-table-to-a-livewire-component.md +++ b/packages/tables/docs/11-adding-a-table-to-a-livewire-component.md @@ -25,7 +25,7 @@ use Illuminate\Support\Facades\Route; Route::get('products', ListProducts::class); ``` -### Adding the table +## Adding the table There are 3 tasks when adding a table to a Livewire component class: From a5f0590d806f2b75d929b1c13ac99dfa7c5d5140 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Tue, 16 May 2023 21:59:52 +0100 Subject: [PATCH 14/19] Update 05-validation.md --- packages/forms/docs/05-validation.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/forms/docs/05-validation.md b/packages/forms/docs/05-validation.md index 12e9ffdd28..7580eba810 100644 --- a/packages/forms/docs/05-validation.md +++ b/packages/forms/docs/05-validation.md @@ -78,6 +78,10 @@ Field::make('name')->alphaNum() The field must be entirely 7-bit ASCII characters. [See the Laravel documentation.](https://laravel.com/docs/10.x/validation#rule-ascii) +```php +Field::make('name')->ascii() +``` + ### Before (date) The field value must be a date before a given date. [See the Laravel documentation.](https://laravel.com/docs/validation#rule-before) From 8ea7e96a1ed68f763a8f46c52696f38d816b5f3a Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Tue, 16 May 2023 22:23:19 +0100 Subject: [PATCH 15/19] wip --- .../forms/resources/views/components/color-picker.blade.php | 4 ++-- packages/forms/resources/views/components/select.blade.php | 4 ++-- .../forms/resources/views/components/text-input.blade.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/forms/resources/views/components/color-picker.blade.php b/packages/forms/resources/views/components/color-picker.blade.php index 84a9a01f15..c5cb368d4e 100644 --- a/packages/forms/resources/views/components/color-picker.blade.php +++ b/packages/forms/resources/views/components/color-picker.blade.php @@ -29,7 +29,7 @@ @endif - @if (filled($label = $getPrefixLabel()) && ($getPrefixLabel() !== false)) + @if (filled($label = $getPrefixLabel())) {{ $label }} @@ -102,7 +102,7 @@
- @if (filled($label = $getSuffixLabel()) && ($getSuffixLabel() !== false)) + @if (filled($label = $getSuffixLabel())) {{ $label }} diff --git a/packages/forms/resources/views/components/select.blade.php b/packages/forms/resources/views/components/select.blade.php index b22a7ab811..8c775557ee 100644 --- a/packages/forms/resources/views/components/select.blade.php +++ b/packages/forms/resources/views/components/select.blade.php @@ -29,7 +29,7 @@ @endif - @if (filled($label = $getPrefixLabel()) && ($getPrefixLabel() !== false)) + @if (filled($label = $getPrefixLabel())) {{ $label }} @@ -126,7 +126,7 @@ @endif - @if (filled($label = $getSuffixLabel()) && ($getSuffixLabel() !== false)) + @if (filled($label = $getSuffixLabel())) {{ $label }} diff --git a/packages/forms/resources/views/components/text-input.blade.php b/packages/forms/resources/views/components/text-input.blade.php index 7ffbe28b76..186aa928c3 100644 --- a/packages/forms/resources/views/components/text-input.blade.php +++ b/packages/forms/resources/views/components/text-input.blade.php @@ -30,7 +30,7 @@ @endif - @if (filled($label = $getPrefixLabel()) && ($getPrefixLabel() !== false)) + @if (filled($label = $getPrefixLabel())) {{ $label }} @@ -83,7 +83,7 @@ /> - @if (filled($label = $getSuffixLabel()) && ($getSuffixLabel() !== false))) + @if (filled($label = $getSuffixLabel())) {{ $label }} From c7cc2be47a286bd51e9173343f6b9bac70a611ba Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Tue, 16 May 2023 22:25:38 +0100 Subject: [PATCH 16/19] wip --- packages/forms/resources/views/components/affixes.blade.php | 4 ++-- packages/forms/src/Components/Concerns/HasAffixes.php | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/forms/resources/views/components/affixes.blade.php b/packages/forms/resources/views/components/affixes.blade.php index a459cf0e35..75cf0146ba 100644 --- a/packages/forms/resources/views/components/affixes.blade.php +++ b/packages/forms/resources/views/components/affixes.blade.php @@ -53,7 +53,7 @@ @endif - @if ($prefix) + @if (filled($prefix)) - @if ($suffix) + @if (filled($suffix)) evaluate($this->prefixLabel); } - public function getPostfixLabel(): ?string - { - return $this->getSuffixLabel(); - } - public function getSuffixLabel(): ?string { return $this->evaluate($this->suffixLabel); From 615d35648bf2758c3579f8537a6c4672fdd8da32 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Tue, 16 May 2023 22:30:10 +0100 Subject: [PATCH 17/19] dropdown item key bindings --- .../views/components/button.blade.php | 3 ++ .../components/dropdown/list/item.blade.php | 36 +++++++++++++------ .../views/components/icon-button.blade.php | 12 +++---- .../resources/views/components/link.blade.php | 6 ++-- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/packages/support/resources/views/components/button.blade.php b/packages/support/resources/views/components/button.blade.php index 05a994ae03..5673ddd0a7 100644 --- a/packages/support/resources/views/components/button.blade.php +++ b/packages/support/resources/views/components/button.blade.php @@ -164,6 +164,9 @@ @if ($tag === 'button') @elseif ($tag === 'a') map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding))->implode('.') }} @endif @if ($tooltip) x-tooltip.raw="{{ $tooltip }}" @endif - @if ($keyBindings || $tooltip) - x-data="{}" - @endif {{ $attributes ->merge([ diff --git a/packages/support/resources/views/components/link.blade.php b/packages/support/resources/views/components/link.blade.php index 3830aae213..954a911bcc 100644 --- a/packages/support/resources/views/components/link.blade.php +++ b/packages/support/resources/views/components/link.blade.php @@ -115,15 +115,15 @@ @elseif ($tag === 'button')