diff --git a/resources/views/components/table/td/bulk-actions.blade.php b/resources/views/components/table/td/bulk-actions.blade.php index 80cb3e5ff..f788a180c 100644 --- a/resources/views/components/table/td/bulk-actions.blade.php +++ b/resources/views/components/table/td/bulk-actions.blade.php @@ -12,16 +12,12 @@ 'inline-flex rounded-md shadow-sm' => $isTailwind, 'form-check' => $isBootstrap5, ])> - merge($bulkActionsTdCheckboxAttributes)->class([ - 'rounded border-gray-300 text-indigo-600 shadow-sm transition duration-150 ease-in-out focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-900 dark:text-white dark:border-gray-600 dark:hover:bg-gray-600 dark:focus:bg-gray-600' => ($isTailwind) && ($bulkActionsTdCheckboxAttributes['default'] ?? true), + 'border-gray-300 text-indigo-600 focus:border-indigo-300 focus:ring-indigo-200 dark:bg-gray-900 dark:text-white dark:border-gray-600 dark:hover:bg-gray-600 dark:focus:bg-gray-600' => ($isTailwind) && (($bulkActionsTdCheckboxAttributes['default'] ?? true) || ($bulkActionsTdCheckboxAttributes['default-colors'] ?? true)), + 'rounded shadow-sm transition duration-150 ease-in-out focus:ring focus:ring-opacity-50' => ($isTailwind) && (($bulkActionsTdCheckboxAttributes['default'] ?? true) || ($bulkActionsTdCheckboxAttributes['default-styling'] ?? true)), 'form-check-input' => ($isBootstrap5) && ($bulkActionsTdCheckboxAttributes['default'] ?? true), ])->except(['default','default-styling','default-colors']) }} diff --git a/resources/views/components/table/th/bulk-actions.blade.php b/resources/views/components/table/th/bulk-actions.blade.php index 90f9ba442..3edc95020 100644 --- a/resources/views/components/table/th/bulk-actions.blade.php +++ b/resources/views/components/table/th/bulk-actions.blade.php @@ -1,11 +1,11 @@ -@aware(['isTailwind', 'isBootstrap']) +@aware(['tableName','isTailwind', 'isBootstrap']) @php $customAttributes = $this->hasBulkActionsThAttributes ? $this->getBulkActionsThAttributes : $this->getAllThAttributes($this->getBulkActionsColumn())['customAttributes']; $bulkActionsThCheckboxAttributes = $this->getBulkActionsThCheckboxAttributes(); @endphp @if ($this->bulkActionsAreEnabled() && $this->hasBulkActions()) - +
true]; - protected array $bulkActionsTdCheckboxAttributes = ['default' => true]; + protected array $bulkActionsTdCheckboxAttributes = ['default' => true, 'default-colors' => false, 'default-styling' => false]; protected array $bulkActionsButtonAttributes = ['default-colors' => true, 'default-styling' => true]; diff --git a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php index adc3cea89..aad42b286 100644 --- a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php +++ b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php @@ -85,13 +85,25 @@ public function getBulkActionsTdAttributes(): array } /** - * Used to get attributes for the Bulk Actions TD + * Used to get attributes for the Bulk Actions TD Checkbox * * @return array */ public function getBulkActionsTdCheckboxAttributes(): array { - return $this->getCustomAttributes('bulkActionsTdCheckboxAttributes'); + $array = array_merge( + [ + 'x-cloak', + 'x-show' => '!currentlyReorderingStatus', + 'x-model' => 'selectedItems', + 'wire:loading.attr.delay' => 'disabled', + 'type' => 'checkbox', + ], + $this->getCustomAttributes('bulkActionsTdCheckboxAttributes') + ); + ksort($array); + + return $array; } diff --git a/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php b/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php index 019c13d22..3eb389975 100644 --- a/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php +++ b/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php @@ -78,7 +78,7 @@ public function test_can_set_bulk_actions_attributes_via_provider(string $setMet 'default' => $default, 'default-colors' => $defaultColors, 'default-styling' => $defaultStyling, - ], $this->basicTable->{$getMethod}()); + ], collect($this->basicTable->{$getMethod}())->only(['class', 'default', 'default-colors', 'default-styling'])->toArray()); $this->basicTable->{$setMethod}([ 'default' => $default, @@ -92,7 +92,7 @@ public function test_can_set_bulk_actions_attributes_via_provider(string $setMet 'default' => $default, 'default-colors' => ! $defaultColors, 'default-styling' => $defaultStyling, - ], $this->basicTable->{$getMethod}()); + ], collect($this->basicTable->{$getMethod}())->only(['class', 'default', 'default-colors', 'default-styling'])->toArray()); } #[DataProvider('bulkActionAttributesProvider')] @@ -107,7 +107,7 @@ public function test_can_get_bulk_actions_attributes_bag_via_provider(string $se $this->basicTable->{$setMethod}($data); - $this->assertSame($data, $this->basicTable->{$getMethod}()); + $this->assertSame($data, collect($this->basicTable->{$getMethod}())->only(['class', 'default', 'default-colors', 'default-styling'])->toArray()); $attributeBag = new ComponentAttributeBag($data); @@ -121,11 +121,26 @@ public function test_bulk_actions_td_attributes_returns_default_true_if_not_set( public function test_bulk_actions_td_checkbox_attributes_returns_default_true_if_not_set(): void { - $this->assertSame(['default' => true, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getBulkActionsTdCheckboxAttributes()); + $data = [ + 'x-cloak', + 'x-show' => '!currentlyReorderingStatus', + 'x-model' => 'selectedItems', + 'wire:loading.attr.delay' => 'disabled', + 'type' => 'checkbox', + 'default' => true, + 'default-colors' => false, + 'default-styling' => false, + ]; + ksort($data); + $returnedData = $this->basicTable->getBulkActionsTdCheckboxAttributes(); + ksort($returnedData); + + $this->assertSame($data, $returnedData); } public function test_bulk_actions_th_attributes_returns_default_true_if_not_set(): void { + $this->assertSame(['default' => true, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getBulkActionsThAttributes()); }