diff --git a/CHANGELOG.md b/CHANGELOG.md index d137430cf..d9fdfd24c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,15 @@ All notable changes to `laravel-livewire-tables` will be documented in this file -## [v3.2.0] - 2023-01-04 +## [v3.2.1] - 2024-02-24 +### Bug Fixes +- Fix collapsing columns not respecting view point collapse points by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1665 + +### Tweaks +- Migrate "updated" Search and FilterComponents calls to WithSearch and WithFilters by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1666 +- Allow nullable search/filter values by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1666 + +## [v3.2.0] - 2024-01-04 ### Tweaks - Migration to new Core Traits, and de-duplication of code by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1623 diff --git a/resources/views/components/table/td.blade.php b/resources/views/components/table/td.blade.php index 7275217a2..1ae7e41d6 100644 --- a/resources/views/components/table/td.blade.php +++ b/resources/views/components/table/td.blade.php @@ -15,12 +15,12 @@ $attributes->merge($customAttributes) ->class(['px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $component->isTailwind() && ($customAttributes['default'] ?? true)]) ->class(['hidden' => $component->isTailwind() && $column && $column->shouldCollapseAlways()]) - ->class(['hidden sm:table-cell' => $component->isTailwind() && $column && $column->shouldCollapseOnMobile()]) - ->class(['hidden md:table-cell' => $component->isTailwind() && $column && $column->shouldCollapseOnTablet()]) + ->class(['hidden md:table-cell' => $component->isTailwind() && $column && $column->shouldCollapseOnMobile()]) + ->class(['hidden lg:table-cell' => $component->isTailwind() && $column && $column->shouldCollapseOnTablet()]) ->class(['' => $component->isBootstrap() && ($customAttributes['default'] ?? true)]) ->class(['d-none' => $component->isBootstrap() && $column && $column->shouldCollapseAlways()]) - ->class(['d-none d-sm-table-cell' => $component->isBootstrap() && $column && $column->shouldCollapseOnMobile()]) - ->class(['d-none d-md-table-cell' => $component->isBootstrap() && $column && $column->shouldCollapseOnTablet()]) + ->class(['d-none d-md-table-cell' => $component->isBootstrap() && $column && $column->shouldCollapseOnMobile()]) + ->class(['d-none d-lg-table-cell' => $component->isBootstrap() && $column && $column->shouldCollapseOnTablet()]) ->style(['cursor:pointer' => $component->isBootstrap()]) ->except('default') }} diff --git a/resources/views/components/table/td/plain.blade.php b/resources/views/components/table/td/plain.blade.php index 1135cf0f5..f59391b4c 100644 --- a/resources/views/components/table/td/plain.blade.php +++ b/resources/views/components/table/td/plain.blade.php @@ -6,8 +6,8 @@ ->merge($customAttributes) ->class(['px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $customAttributes['default'] ?? true]) ->class(['hidden' => $column && $column->shouldCollapseAlways()]) - ->class(['hidden sm:table-cell' => $column && $column->shouldCollapseOnMobile()]) - ->class(['hidden md:table-cell' => $column && $column->shouldCollapseOnTablet()]) + ->class(['hidden md:table-cell' => $column && $column->shouldCollapseOnMobile()]) + ->class(['hidden lg:table-cell' => $column && $column->shouldCollapseOnTablet()]) ->except('default') }} @if($hideUntilReorder) x-show="reorderDisplayColumn" @endif > {{ $slot }} @@ -17,8 +17,8 @@ ->merge($customAttributes) ->class(['' => $customAttributes['default'] ?? true]) ->class(['d-none' => $column && $column->shouldCollapseAlways()]) - ->class(['d-none d-sm-table-cell' => $column && $column->shouldCollapseOnMobile()]) - ->class(['d-none d-md-table-cell' => $column && $column->shouldCollapseOnTablet()]) + ->class(['d-none d-md-table-cell' => $column && $column->shouldCollapseOnMobile()]) + ->class(['d-none d-lg-table-cell' => $column && $column->shouldCollapseOnTablet()]) ->except('default') }}> {{ $slot }} diff --git a/resources/views/datatable.blade.php b/resources/views/datatable.blade.php index fafbb676c..73d8cf071 100644 --- a/resources/views/datatable.blade.php +++ b/resources/views/datatable.blade.php @@ -14,8 +14,12 @@ - - + @if($this->getCurrentlyReorderingStatus()) + + @endif + @if($this->bulkActionsAreEnabled() && $this->hasBulkActions()) + + @endif @foreach($columns as $index => $column) diff --git a/src/LaravelLivewireTablesServiceProvider.php b/src/LaravelLivewireTablesServiceProvider.php index 7990aed9a..a7dd0587b 100644 --- a/src/LaravelLivewireTablesServiceProvider.php +++ b/src/LaravelLivewireTablesServiceProvider.php @@ -14,7 +14,7 @@ class LaravelLivewireTablesServiceProvider extends ServiceProvider public function boot(): void { - AboutCommand::add('Rappasoft Laravel Livewire Tables', fn () => ['Version' => '3.0.0']); + AboutCommand::add('Rappasoft Laravel Livewire Tables', fn () => ['Version' => '3.2.1']); $this->mergeConfigFrom( __DIR__.'/../config/livewire-tables.php', 'livewire-tables' diff --git a/src/Traits/ComponentUtilities.php b/src/Traits/ComponentUtilities.php index cce891e8f..1e421e0b6 100644 --- a/src/Traits/ComponentUtilities.php +++ b/src/Traits/ComponentUtilities.php @@ -87,40 +87,6 @@ protected function generateDataTableFingerprint(): string return base_convert($crc32, 10, 36); } - /** - * Keep track of any properties on the custom query string key for this specific table - */ - public function updated(string $name, string|array $value): void - { - if ($name === 'search') { - $this->resetComputedPage(); - - // Clear bulk actions on search - $this->clearSelected(); - $this->setSelectAllDisabled(); - - if ($value === '') { - $this->clearSearch(); - } - } - - if (Str::contains($name, 'filterComponents')) { - $this->resetComputedPage(); - - // Clear bulk actions on filter - $this->clearSelected(); - $this->setSelectAllDisabled(); - - // Clear filters on empty value - $filterName = Str::after($name, 'filterComponents.'); - $filter = $this->getFilterByKey($filterName); - - if ($filter && $filter->isEmpty($value)) { - $this->resetFilter($filterName); - } - } - } - /** * 1. After the sorting method is hit we need to tell the table to go back into reordering mode */ diff --git a/src/Traits/Helpers/TableAttributeHelpers.php b/src/Traits/Helpers/TableAttributeHelpers.php index 25a970628..3da2da12e 100644 --- a/src/Traits/Helpers/TableAttributeHelpers.php +++ b/src/Traits/Helpers/TableAttributeHelpers.php @@ -16,7 +16,7 @@ public function getComponentWrapperAttributes(): array } /** - * @return array + * @return array */ public function getTableWrapperAttributes(): array { @@ -24,7 +24,7 @@ public function getTableWrapperAttributes(): array } /** - * @return array + * @return array */ public function getTableAttributes(): array { @@ -32,7 +32,7 @@ public function getTableAttributes(): array } /** - * @return array + * @return array */ public function getTheadAttributes(): array { @@ -40,7 +40,7 @@ public function getTheadAttributes(): array } /** - * @return array + * @return array */ public function getTbodyAttributes(): array { @@ -48,7 +48,7 @@ public function getTbodyAttributes(): array } /** - * @return array + * @return array */ public function getThAttributes(Column $column): array { @@ -56,7 +56,7 @@ public function getThAttributes(Column $column): array } /** - * @return array + * @return array */ public function getThSortButtonAttributes(Column $column): array { diff --git a/src/Traits/WithFilters.php b/src/Traits/WithFilters.php index 3ffde9006..ec6c7aac2 100644 --- a/src/Traits/WithFilters.php +++ b/src/Traits/WithFilters.php @@ -68,4 +68,20 @@ public function applyFilters(): Builder return $this->getBuilder(); } + + public function updatedFilterComponents(string|array|null $value, string $filterName): void + { + $this->resetComputedPage(); + + // Clear bulk actions on filter + $this->clearSelected(); + $this->setSelectAllDisabled(); + + // Clear filters on empty value + $filter = $this->getFilterByKey($filterName); + + if ($filter && $filter->isEmpty($value)) { + $this->resetFilter($filterName); + } + } } diff --git a/src/Traits/WithSearch.php b/src/Traits/WithSearch.php index 49d9bb805..0ef402573 100644 --- a/src/Traits/WithSearch.php +++ b/src/Traits/WithSearch.php @@ -65,4 +65,17 @@ public function applySearch(): Builder return $this->getBuilder(); } + + public function updatedSearch(string|array|null $value): void + { + $this->resetComputedPage(); + + // Clear bulk actions on search + $this->clearSelected(); + $this->setSelectAllDisabled(); + + if (is_null($value) || $value === '') { + $this->clearSearch(); + } + } }