diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f8fe64b6..553622c32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ All notable changes to `laravel-livewire-tables` will be documented in this file +## [v3.4.22] - 2024-09-29 +### Bug Fixes +- Fix Loading Placeholder Bug - Breaking Table by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1969 + +### New Features +- Add setPaginationWrapperAttributes by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1978 +- Add configurable areas - before-wrapper and after-wrapper by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1977 +- Add ToolsAttributes and ToolbarAttributes by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1982 + +### Docs +- Add getTitle reference for setTdAttributes/setTrAttributes by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1976 +- Add setToolsAttributes and setToolBarAttributes docs by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1984 +- Add docs for the ColumnSelect lifecycle hooks by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1983 + ## [v3.4.21] - 2024-09-25 ### Bug Fixes - Remove persist from getFilterGenericData by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1966 diff --git a/docs/column-types/livewire_component_column.md b/docs/column-types/livewire_component_column.md index 9b1851299..6a6af2eea 100644 --- a/docs/column-types/livewire_component_column.md +++ b/docs/column-types/livewire_component_column.md @@ -10,7 +10,6 @@ This is **not recommended** as due to the nature of Livewire, it becomes ineffic ## component ``` LivewireComponentColumn::make('Action') - ->title(fn($row) => 'Edit') ->component('PathToLivewireComponent'), ``` @@ -29,4 +28,4 @@ Please also see the following for other available methods:
  • Footer
  • - \ No newline at end of file + diff --git a/docs/columns/styling.md b/docs/columns/styling.md index f7db2a4bd..7862c9566 100644 --- a/docs/columns/styling.md +++ b/docs/columns/styling.md @@ -45,6 +45,11 @@ Below is a copy of the relevant sections from [datatable styling](../datatable/s Set a list of attributes to override on the th elements. +If your Column does not have a field (e.g. a label column), then you may use the following, which will utilise the first parameter in Column::make() +```php + $column->getTitle() +``` + ```php public function configure(): void { @@ -204,6 +209,11 @@ public function configure(): void Set a list of attributes to override on the td elements. For example, changing the background color between red/green based on whether the "total" field is over or under 1000. +If your Column does not have a field (e.g. a label column), then you may use the following, which will utilise the first parameter in Column::make() +```php + $column->getTitle() +``` + ```php public function configure(): void { diff --git a/docs/datatable/configurable-areas.md b/docs/datatable/configurable-areas.md index bb9d78a5b..4661be63b 100644 --- a/docs/datatable/configurable-areas.md +++ b/docs/datatable/configurable-areas.md @@ -26,6 +26,7 @@ You can use the `setConfigurableAreas` method to set multiple areas that you wan public function configure(): void { $this->setConfigurableAreas([ + 'before-wrapper' => 'path.to.my.view', 'before-tools' => 'path.to.my.view', 'toolbar-left-start' => 'path.to.my.view', 'toolbar-left-end' => 'path.to.my.view', @@ -35,6 +36,7 @@ public function configure(): void 'after-toolbar' => 'path.to.my.view', 'before-pagination' => 'path.to.my.view', 'after-pagination' => 'path.to.my.view', + 'after-wrapper' => 'path.to.my.view', ]); } ``` diff --git a/docs/datatable/styling.md b/docs/datatable/styling.md index b460371bf..9353ad00e 100644 --- a/docs/datatable/styling.md +++ b/docs/datatable/styling.md @@ -150,6 +150,11 @@ public function configure(): void Set a list of attributes to override on the th elements. +If your Column does not have a field (e.g. a label column), then you may use the following, which will utilise the first parameter in Column::make() +```php + $column->getTitle() +``` + ```php public function configure(): void { @@ -311,6 +316,11 @@ public function configure(): void Set a list of attributes to override on the td elements +If your Column does not have a field (e.g. a label column), then you may use the following, which will utilise the first parameter in Column::make() +```php + $column->getTitle() +``` + ```php public function configure(): void { diff --git a/docs/misc/lifecycle-hooks.md b/docs/misc/lifecycle-hooks.md index 1e05569a9..f56ce1f9a 100644 --- a/docs/misc/lifecycle-hooks.md +++ b/docs/misc/lifecycle-hooks.md @@ -19,6 +19,12 @@ This is called prior to setting up the available Columns via the columns() metho ## columnsSet This is called immediately after the Columns are set up +## configuringColumnSelect +This is called immediately prior to setting up Column Select + +## configuredColumnSelect +This is called immediately after setting up Column Select + ## rowsRetrieved This is called immediately after the query is executed, and is passed the result from the executed query. diff --git a/docs/misc/tools.md b/docs/misc/tools.md index 7904caa0c..0d9dbc390 100644 --- a/docs/misc/tools.md +++ b/docs/misc/tools.md @@ -56,4 +56,28 @@ Disables the Toolbar, which contains the Reorder, Filters, Search, Column Select { $this->setToolBarDisabled(); } -``` \ No newline at end of file +``` + +### setToolsAttributes +Allows setting of attributes for the parent element in the tools blade + +By default, this replaces the default classes on the tools blade, if you would like to keep them, set the default-colors/default-styling flags to true as appropriate + +```php + public function configure(): void + { + $this->setToolsAttributes(['class' => ' bg-green-500', 'default-colors' => false, 'default-styling' => true]); + } +``` + +### setToolBarAttributes +Allows setting of attributes for the parent element in the toolbar blade. + +By default, this replaces the default classes on the toolbar blade, if you would like to keep them, set the default-colors/default-styling flags to true as appropriate + +```php + public function configure(): void + { + $this->setToolBarAttributes(['class' => ' bg-red-500', 'default-colors' => false, 'default-styling' => true]); + } +``` diff --git a/docs/pagination/available-methods.md b/docs/pagination/available-methods.md index 638e58a4b..eae078132 100644 --- a/docs/pagination/available-methods.md +++ b/docs/pagination/available-methods.md @@ -296,3 +296,14 @@ public function configure(): void $this->setShouldRetrieveTotalItemCountDisabled(); } ``` + +## setPaginationWrapperAttributes + +Used to set attributes for the "div" that wraps the pagination section + +```php +public function configure(): void +{ + $this->setPaginationWrapperAttributes(['class' => 'text-lg']); +} +``` diff --git a/resources/views/components/includes/loading.blade.php b/resources/views/components/includes/loading.blade.php index c07d9cb19..f22096321 100644 --- a/resources/views/components/includes/loading.blade.php +++ b/resources/views/components/includes/loading.blade.php @@ -9,15 +9,15 @@ @include($this->getLoadingPlaceHolderBlade(), ['colCount' => $colCount]) @else - merge($customAttributes['loader-wrapper']) - ->class(['w-full text-center h-screen place-items-center align-middle' => $isTailwind && ($customAttributes['loader-wrapper']['default'] ?? true)]) - ->class(['w-100 text-center h-100 align-items-center' => $isBootstrap && ($customAttributes['loader-wrapper']['default'] ?? true)]); + ->class(['hidden w-full text-center h-screen place-items-center align-middle' => $isTailwind && ($customAttributes['loader-wrapper']['default'] ?? true)]) + ->class(['d-none w-100 text-center h-100 align-items-center' => $isBootstrap && ($customAttributes['loader-wrapper']['default'] ?? true)]); }} wire:loading.class.remove="hidden d-none" > - +
    hasConfigurableAreaFor('before-pagination')) - @include($this->getConfigurableAreaFor('before-pagination'), $this->getParametersForConfigurableArea('before-pagination')) -@endif +@includeWhen( + $this->hasConfigurableAreaFor('before-pagination'), + $this->getConfigurableAreaFor('before-pagination'), + $this->getParametersForConfigurableArea('before-pagination') +) @if ($this->isTailwind) -
    +
    getPaginationWrapperAttributesBag() }}> @if ($this->paginationVisibilityIsEnabled())
    @@ -47,7 +49,7 @@ @endif
    @elseif ($this->isBootstrap4) -
    +
    getPaginationWrapperAttributesBag() }}> @if ($this->paginationVisibilityIsEnabled()) @if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
    @@ -100,7 +102,7 @@ @endif
    @elseif ($this->isBootstrap5) -
    +
    getPaginationWrapperAttributesBag() }} > @if ($this->paginationVisibilityIsEnabled()) @if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
    @@ -152,6 +154,8 @@
    @endif -@if ($this->hasConfigurableAreaFor('after-pagination')) - @include($this->getConfigurableAreaFor('after-pagination'), $this->getParametersForConfigurableArea('after-pagination')) -@endif \ No newline at end of file +@includeWhen( + $this->hasConfigurableAreaFor('after-pagination'), + $this->getConfigurableAreaFor('after-pagination'), + $this->getParametersForConfigurableArea('after-pagination') +) diff --git a/resources/views/components/table/tr.blade.php b/resources/views/components/table/tr.blade.php index 4a3f84ece..40ccde560 100644 --- a/resources/views/components/table/tr.blade.php +++ b/resources/views/components/table/tr.blade.php @@ -12,9 +12,9 @@ x-on:dragover.prevent.throttle.500ms="currentlyReorderingStatus && dragOverEvent(event)" x-on:dragleave.prevent.throttle.500ms="currentlyReorderingStatus && dragLeaveEvent(event)" @if($this->hasDisplayLoadingPlaceholder()) - wire:loading.remove + wire:loading.class.add="hidden d-none" @else - wire:loading.class.delay="opacity-50 dark:bg-gray-900 dark:opacity-60" + wire:loading.class.delay="opacity-50 dark:bg-gray-900 dark:opacity-60" @endif id="{{ $tableName }}-row-{{ $row->{$primaryKey} }}" :draggable="currentlyReorderingStatus" diff --git a/resources/views/components/tools.blade.php b/resources/views/components/tools.blade.php index 4a5dfa7b8..bdb31a745 100644 --- a/resources/views/components/tools.blade.php +++ b/resources/views/components/tools.blade.php @@ -1,8 +1,12 @@ @aware(['component','isTailwind','isBootstrap']) +@php($toolsAttributes = $this->getToolsAttributesBag()) -
    $isTailwind, - 'd-flex flex-column ' => ($isBootstrap), -])> +
    merge() + ->class(['flex-col' => $isTailwind && ($toolsAttributes['default-styling'] ?? true)]) + ->class(['d-flex flex-column' => $isBootstrap && ($toolsAttributes['default-styling'] ?? true)]) + ->except(['default','default-styling','default-colors']) + }} +> {{ $slot }}
    diff --git a/resources/views/components/tools/toolbar.blade.php b/resources/views/components/tools/toolbar.blade.php index 8a3c8901b..65e8c086b 100644 --- a/resources/views/components/tools/toolbar.blade.php +++ b/resources/views/components/tools/toolbar.blade.php @@ -1,10 +1,14 @@ @aware(['component', 'tableName','isTailwind','isBootstrap']) @props([]) +@php($toolBarAttributes = $this->getToolBarAttributesBag()) -
    $this->isBootstrap, - 'md:flex md:justify-between mb-4 px-4 md:p-0' => $this->isTailwind, - ]) +
    merge() + ->class(['md:flex md:justify-between mb-4 px-4 md:p-0' => $isTailwind && ($toolBarAttributes['default-styling'] ?? true)]) + ->class(['d-md-flex justify-content-between mb-3' => $isBootstrap && ($toolBarAttributes['default-styling'] ?? true)]) + ->except(['default','default-styling','default-colors']) + }} >
    $this->isBootstrap, @@ -52,9 +56,7 @@ 'md:flex md:items-center space-y-4 md:space-y-0 md:space-x-2' => $this->isTailwind, ]) > - @if ($this->hasConfigurableAreaFor('toolbar-right-start')) - @include($this->getConfigurableAreaFor('toolbar-right-start'), $this->getParametersForConfigurableArea('toolbar-right-start')) - @endif + @includeWhen($this->hasConfigurableAreaFor('toolbar-right-start'), $this->getConfigurableAreaFor('toolbar-right-start'), $this->getParametersForConfigurableArea('toolbar-right-start')) @if($this->hasActions && $this->showActionsInToolbar && $this->getActionsPosition == 'right') @@ -72,9 +74,7 @@ @endif - @if ($this->hasConfigurableAreaFor('toolbar-right-end')) - @include($this->getConfigurableAreaFor('toolbar-right-end'), $this->getParametersForConfigurableArea('toolbar-right-end')) - @endif + @includeWhen($this->hasConfigurableAreaFor('toolbar-right-end'), $this->getConfigurableAreaFor('toolbar-right-end'), $this->getParametersForConfigurableArea('toolbar-right-end'))
    @if ( diff --git a/resources/views/datatable.blade.php b/resources/views/datatable.blade.php index f534f7f49..e92119d9b 100644 --- a/resources/views/datatable.blade.php +++ b/resources/views/datatable.blade.php @@ -7,15 +7,24 @@ @php($isBootstrap5 = $this->isBootstrap5)
    getTopLevelAttributes() }}> + + @includeWhen( + $this->hasConfigurableAreaFor('before-wrapper'), + $this->getConfigurableAreaFor('before-wrapper'), + $this->getParametersForConfigurableArea('before-wrapper') + ) + @if($this->hasActions && !$this->showActionsInToolbar) @endif - @if ($this->hasConfigurableAreaFor('before-tools')) - @include($this->getConfigurableAreaFor('before-tools'), $this->getParametersForConfigurableArea('before-tools')) - @endif + @includeWhen( + $this->hasConfigurableAreaFor('before-tools'), + $this->getConfigurableAreaFor('before-tools'), + $this->getParametersForConfigurableArea('before-tools') + ) @if($this->shouldShowTools) @@ -26,11 +35,21 @@ @endif - @includeWhen($this->hasConfigurableAreaFor('before-toolbar'), $this->getConfigurableAreaFor('before-toolbar'), $this->getParametersForConfigurableArea('before-toolbar')) + @includeWhen( + $this->hasConfigurableAreaFor('before-toolbar'), + $this->getConfigurableAreaFor('before-toolbar'), + $this->getParametersForConfigurableArea('before-toolbar') + ) + @if($this->shouldShowToolBar) @endif - @includeWhen($this->hasConfigurableAreaFor('after-toolbar'), $this->getConfigurableAreaFor('after-toolbar'), $this->getParametersForConfigurableArea('after-toolbar')) + + @includeWhen( + $this->hasConfigurableAreaFor('after-toolbar'), + $this->getConfigurableAreaFor('after-toolbar'), + $this->getParametersForConfigurableArea('after-toolbar') + ) @endif @@ -110,4 +129,11 @@ @includeIf($customView) + + @includeWhen( + $this->hasConfigurableAreaFor('after-wrapper'), + $this->getConfigurableAreaFor('after-wrapper'), + $this->getParametersForConfigurableArea('after-wrapper') + ) +
    diff --git a/src/Traits/Configuration/PaginationConfiguration.php b/src/Traits/Configuration/PaginationConfiguration.php index a8877653a..35c618e0c 100644 --- a/src/Traits/Configuration/PaginationConfiguration.php +++ b/src/Traits/Configuration/PaginationConfiguration.php @@ -177,4 +177,11 @@ public function setShouldRetrieveTotalItemCountDisabled(): self return $this; } + + public function setPaginationWrapperAttributes(array $paginationWrapperAttributes): self + { + $this->paginationWrapperAttributes = array_merge(['class' => ''], $paginationWrapperAttributes); + + return $this; + } } diff --git a/src/Traits/Core/HasCustomAttributes.php b/src/Traits/Core/HasCustomAttributes.php index 99afeb4c4..cbc3bcd85 100644 --- a/src/Traits/Core/HasCustomAttributes.php +++ b/src/Traits/Core/HasCustomAttributes.php @@ -46,4 +46,9 @@ public function setCustomAttributes(string $propertyName, array $customAttribute return $this; } + + public function getCustomAttributesBagFromArray(array $attributesArray): ComponentAttributeBag + { + return new ComponentAttributeBag($attributesArray); + } } diff --git a/src/Traits/Helpers/PaginationHelpers.php b/src/Traits/Helpers/PaginationHelpers.php index 717af7c12..9654b3a72 100644 --- a/src/Traits/Helpers/PaginationHelpers.php +++ b/src/Traits/Helpers/PaginationHelpers.php @@ -2,6 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Helpers; +use Illuminate\View\ComponentAttributeBag; use Livewire\Attributes\Computed; trait PaginationHelpers @@ -155,4 +156,15 @@ public function getShouldRetrieveTotalItemCount(): bool { return $this->shouldRetrieveTotalItemCount; } + + public function getPaginationWrapperAttributes(): array + { + return $this->paginationWrapperAttributes ?? ['class' => '']; + } + + #[Computed] + public function getPaginationWrapperAttributesBag(): ComponentAttributeBag + { + return new ComponentAttributeBag($this->getPaginationWrapperAttributes()); + } } diff --git a/src/Traits/Styling/Configuration/ToolsStylingConfiguration.php b/src/Traits/Styling/Configuration/ToolsStylingConfiguration.php new file mode 100644 index 000000000..9b2ca17f4 --- /dev/null +++ b/src/Traits/Styling/Configuration/ToolsStylingConfiguration.php @@ -0,0 +1,20 @@ +setCustomAttributes(propertyName: 'toolsAttributes', customAttributes: $toolsAttributes); + + return $this; + } + + public function setToolBarAttributes(array $toolBarAttributes = []): self + { + $this->setCustomAttributes(propertyName: 'toolBarAttributes', customAttributes: $toolBarAttributes); + + return $this; + } +} diff --git a/src/Traits/Styling/HasToolsStyling.php b/src/Traits/Styling/HasToolsStyling.php new file mode 100644 index 000000000..a56123311 --- /dev/null +++ b/src/Traits/Styling/HasToolsStyling.php @@ -0,0 +1,16 @@ + '', 'default-colors' => true, 'default-styling' => true]; + + protected array $toolBarAttributes = ['class' => '', 'default-colors' => true, 'default-styling' => true]; +} diff --git a/src/Traits/Styling/Helpers/ToolsStylingHelpers.php b/src/Traits/Styling/Helpers/ToolsStylingHelpers.php new file mode 100644 index 000000000..95aa8684f --- /dev/null +++ b/src/Traits/Styling/Helpers/ToolsStylingHelpers.php @@ -0,0 +1,32 @@ +getCustomAttributes(propertyName: 'toolsAttributes', default: false, classicMode: false); + } + + #[Computed] + public function getToolsAttributesBag(): ComponentAttributeBag + { + return $this->getCustomAttributesBagFromArray($this->getToolsAttributes()); + } + + protected function getToolBarAttributes(): array + { + return $this->getCustomAttributes(propertyName: 'toolBarAttributes', default: false, classicMode: false); + } + + #[Computed] + public function getToolBarAttributesBag(): ComponentAttributeBag + { + return $this->getCustomAttributesBagFromArray($this->getToolBarAttributes()); + + } +} diff --git a/src/Traits/WithPagination.php b/src/Traits/WithPagination.php index c8c56a3c9..8e6a44aa0 100644 --- a/src/Traits/WithPagination.php +++ b/src/Traits/WithPagination.php @@ -52,6 +52,9 @@ trait WithPagination protected bool $shouldRetrieveTotalItemCount = true; + // Used In Frontend + protected array $paginationWrapperAttributes = ['class' => '']; + public function mountWithPagination(): void { $sessionPerPage = session()->get($this->getPerPagePaginationSessionKey(), $this->getPerPageAccepted()[0] ?? 10); diff --git a/src/Traits/WithTools.php b/src/Traits/WithTools.php index 31d91a57a..8ede2e382 100644 --- a/src/Traits/WithTools.php +++ b/src/Traits/WithTools.php @@ -4,11 +4,13 @@ use Rappasoft\LaravelLivewireTables\Traits\Configuration\ToolsConfiguration; use Rappasoft\LaravelLivewireTables\Traits\Helpers\ToolsHelpers; +use Rappasoft\LaravelLivewireTables\Traits\Styling\HasToolsStyling; trait WithTools { use ToolsConfiguration, - ToolsHelpers; + ToolsHelpers, + HasToolsStyling; protected bool $toolsStatus = true; diff --git a/tests/Traits/Helpers/PaginationHelpersTest.php b/tests/Traits/Helpers/PaginationHelpersTest.php index d3744c326..067c0e208 100644 --- a/tests/Traits/Helpers/PaginationHelpersTest.php +++ b/tests/Traits/Helpers/PaginationHelpersTest.php @@ -173,4 +173,33 @@ public function test_can_toggle_total_item_count_retrieval_via_status(): void $this->assertTrue($this->basicTable->getShouldRetrieveTotalItemCount()); } + + public function test_can_get_pagination_wrapper_attributes(): void + { + + $this->assertSame(['class' => ''], $this->basicTable->getPaginationWrapperAttributes()); + + $this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg']); + + $this->assertSame(['class' => 'text-lg'], $this->basicTable->getPaginationWrapperAttributes()); + + $this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg', 'testval' => '456']); + + $this->assertSame(['class' => 'text-lg', 'testval' => '456'], $this->basicTable->getPaginationWrapperAttributes()); + + } + + public function test_can_get_pagination_wrapper_attributes_bag(): void + { + $this->assertSame((new \Illuminate\View\ComponentAttributeBag(['class' => '']))->getAttributes(), $this->basicTable->getPaginationWrapperAttributesBag()->getAttributes()); + + $this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg']); + + $this->assertSame((new \Illuminate\View\ComponentAttributeBag(['class' => 'text-lg']))->getAttributes(), $this->basicTable->getPaginationWrapperAttributesBag()->getAttributes()); + + $this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg', 'testval' => '123']); + + $this->assertSame((new \Illuminate\View\ComponentAttributeBag(['class' => 'text-lg', 'testval' => '123']))->getAttributes(), $this->basicTable->getPaginationWrapperAttributesBag()->getAttributes()); + + } } diff --git a/tests/Traits/Helpers/ToolsStylingHelpersTest.php b/tests/Traits/Helpers/ToolsStylingHelpersTest.php new file mode 100644 index 000000000..560385a89 --- /dev/null +++ b/tests/Traits/Helpers/ToolsStylingHelpersTest.php @@ -0,0 +1,67 @@ +assertTrue($this->basicTable->hasCustomAttributes('toolsAttributes')); + } + + public function test_can_get_tools_attributes_initial_values(): void + { + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getToolsAttributesBag()->getAttributes()); + } + + public function test_can_change_tools_attributes_initial_values(): void + { + $this->basicTable->setToolsAttributes(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true]); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getToolsAttributesBag()->getAttributes()); + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getToolBarAttributesBag()->getAttributes()); + } + + public function test_can_change_tools_attributes_initial_values_no_defaults(): void + { + $this->basicTable->setToolsAttributes(['class' => 'bg-amber-500']); + $this->assertSame(['class' => 'bg-amber-500', 'default-colors' => false, 'default-styling' => false], $this->basicTable->getToolsAttributesBag()->getAttributes()); + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getToolBarAttributesBag()->getAttributes()); + + } + + public function test_can_get_toolbar_attributes_initial_status(): void + { + $this->assertTrue($this->basicTable->hasCustomAttributes('toolBarAttributes')); + } + + public function test_can_get_toolbar_attributes_initial_values(): void + { + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getToolBarAttributesBag()->getAttributes()); + } + + public function test_can_change_toolbar_attributes_initial_values(): void + { + $this->basicTable->setToolBarAttributes(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true]); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getToolBarAttributesBag()->getAttributes()); + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getToolsAttributesBag()->getAttributes()); + + } + + public function test_can_change_toolbar_attributes_initial_values_no_defaults(): void + { + $this->basicTable->setToolBarAttributes(['class' => 'bg-green-500']); + $this->assertSame(['class' => 'bg-green-500', 'default-colors' => false, 'default-styling' => false], $this->basicTable->getToolBarAttributesBag()->getAttributes()); + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getToolsAttributesBag()->getAttributes()); + } + + public function test_can_change_tools_and_toolbar_attributes_initial_values_no_defaults(): void + { + $this->basicTable->setToolsAttributes(['class' => 'bg-amber-500'])->setToolBarAttributes(['class' => 'bg-green-500']); + + $this->assertSame(['class' => 'bg-amber-500', 'default-colors' => false, 'default-styling' => false], $this->basicTable->getToolsAttributesBag()->getAttributes()); + + $this->assertSame(['class' => 'bg-green-500', 'default-colors' => false, 'default-styling' => false], $this->basicTable->getToolBarAttributesBag()->getAttributes()); + } +} diff --git a/tests/Traits/Visuals/LoadingPlaceholderVisualsTest.php b/tests/Traits/Visuals/LoadingPlaceholderVisualsTest.php index 0f64aa5bf..5d93e3432 100644 --- a/tests/Traits/Visuals/LoadingPlaceholderVisualsTest.php +++ b/tests/Traits/Visuals/LoadingPlaceholderVisualsTest.php @@ -12,7 +12,7 @@ public function test_can_see_placeholder_section(): void { Livewire::test(PetsTableLoadingPlaceholder::class) ->call('setPerPageAccepted', [1, 5, 10]) - ->assertSeeHtml('tr wire:key="table-loader" class="hidden d-none"') + ->assertSeeHtml('tr wire:key="table-loader') ->call('setPerPage', 5); } @@ -21,7 +21,7 @@ public function test_can_see_placeholder_custom_text(): void Livewire::test(PetsTableLoadingPlaceholder::class) ->call('setPerPageAccepted', [1, 5, 10]) ->assertSeeHtmlInOrder([ - '