diff --git a/resources/views/components/pagination.blade.php b/resources/views/components/pagination.blade.php index 4a9ffca95..feab347e2 100644 --- a/resources/views/components/pagination.blade.php +++ b/resources/views/components/pagination.blade.php @@ -1,19 +1,16 @@ -@aware(['isTailwind','isBootstrap','isBootstrap4','isBootstrap5']) - @includeWhen( $this->hasConfigurableAreaFor('before-pagination'), $this->getConfigurableAreaFor('before-pagination'), $this->getParametersForConfigurableArea('before-pagination') ) -@if ($this->isTailwind) -
getPaginationWrapperAttributesBag() }}> - @if ($this->paginationVisibilityIsEnabled()) +
getPaginationWrapperAttributesBag() }}> + @if ($this->paginationVisibilityIsEnabled()) + @if ($this->isTailwind)
- @if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1) + @if ($this->paginationIsEnabled && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1 && $this->showPaginationDetails)

- @if($this->showPaginationDetails()) {{ __($this->getLocalisationPath.'Showing') }} {{ $this->getRows->firstItem() }} {{ __($this->getLocalisationPath.'to') }} @@ -21,44 +18,43 @@ {{ __($this->getLocalisationPath.'of') }} {{ __($this->getLocalisationPath.'results') }} - @endif

- @elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('simple')) + @elseif ($this->paginationIsEnabled && $this->isPaginationMethod('simple') && $this->showPaginationDetails)

- @if($this->showPaginationDetails()) - {{ __($this->getLocalisationPath.'Showing') }} - {{ $this->getRows->firstItem() }} - {{ __($this->getLocalisationPath.'to') }} - {{ $this->getRows->lastItem() }} - @endif + {{ __($this->getLocalisationPath.'Showing') }} + {{ $this->getRows->firstItem() }} + {{ __($this->getLocalisationPath.'to') }} + {{ $this->getRows->lastItem() }}

- @elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('cursor')) + @elseif ($this->paginationIsEnabled && $this->isPaginationMethod('cursor')) @else -

- {{ __($this->getLocalisationPath.'Showing') }} - {{ $this->getRows->count() }} - {{ __($this->getLocalisationPath.'results') }} -

+ @if($this->showPaginationDetails) +

+ {{ __($this->getLocalisationPath.'Showing') }} + {{ $this->getRows->count() }} + {{ __($this->getLocalisationPath.'results') }} +

+ @endif @endif
- @if ($this->paginationIsEnabled()) + @if ($this->paginationIsEnabled) {{ $this->getRows->links('livewire-tables::specific.tailwind.'.(!$this->isPaginationMethod('standard') ? 'simple-' : '').'pagination') }} @endif
- @endif -
-@elseif ($this->isBootstrap4) -
getPaginationWrapperAttributesBag() }}> - @if ($this->paginationVisibilityIsEnabled()) - @if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1) + @else + @if ($this->paginationIsEnabled && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
{{ $this->getRows->links('livewire-tables::specific.bootstrap-4.pagination') }}
-
- @if($this->showPaginationDetails()) +
$this->isBootstrap4, + "text-md-end" => $this->isBootstrap5, + ])> + @if($this->showPaginationDetails) {{ __($this->getLocalisationPath.'Showing') }} {{ $this->getRows->count() ? $this->getRows->firstItem() : 0 }} {{ __($this->getLocalisationPath.'to') }} @@ -69,14 +65,18 @@ @endif
- @elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('simple')) + @elseif ($this->paginationIsEnabled && $this->isPaginationMethod('simple'))
{{ $this->getRows->links('livewire-tables::specific.bootstrap-4.simple-pagination') }}
-
- @if($this->showPaginationDetails()) +
$this->isBootstrap4, + "text-md-end" => $this->isBootstrap5, + ])> + @if($this->showPaginationDetails) {{ __($this->getLocalisationPath.'Showing') }} {{ $this->getRows->count() ? $this->getRows->firstItem() : 0 }} {{ __($this->getLocalisationPath.'to') }} @@ -84,7 +84,7 @@ @endif
- @elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('cursor')) + @elseif ($this->paginationIsEnabled && $this->isPaginationMethod('cursor'))
{{ $this->getRows->links('livewire-tables::specific.bootstrap-4.simple-pagination') }} @@ -93,66 +93,17 @@ @else
- {{ __($this->getLocalisationPath.'Showing') }} - {{ $this->getRows->count() }} - {{ __($this->getLocalisationPath.'results') }} -
-
- @endif - @endif -
-@elseif ($this->isBootstrap5) -
getPaginationWrapperAttributesBag() }} > - @if ($this->paginationVisibilityIsEnabled()) - @if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1) -
-
- {{ $this->getRows->links('livewire-tables::specific.bootstrap-4.pagination') }} -
-
- @if($this->showPaginationDetails()) - {{ __($this->getLocalisationPath.'Showing') }} - {{ $this->getRows->count() ? $this->getRows->firstItem() : 0 }} - {{ __($this->getLocalisationPath.'to') }} - {{ $this->getRows->count() ? $this->getRows->lastItem() : 0 }} - {{ __($this->getLocalisationPath.'of') }} - - {{ __($this->getLocalisationPath.'results') }} - @endif -
-
- @elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('simple')) -
-
- {{ $this->getRows->links('livewire-tables::specific.bootstrap-4.simple-pagination') }} -
-
- @if($this->showPaginationDetails()) - {{ __($this->getLocalisationPath.'Showing') }} - {{ $this->getRows->count() ? $this->getRows->firstItem() : 0 }} - {{ __($this->getLocalisationPath.'to') }} - {{ $this->getRows->count() ? $this->getRows->lastItem() : 0 }} + @if($this->showPaginationDetails) + {{ __($this->getLocalisationPath.'Showing') }} + {{ $this->getRows->count() }} + {{ __($this->getLocalisationPath.'results') }} @endif
- @elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('cursor')) -
-
- {{ $this->getRows->links('livewire-tables::specific.bootstrap-4.simple-pagination') }} -
-
- @else -
-
- {{ __($this->getLocalisationPath.'Showing') }} - {{ $this->getRows->count() }} - {{ __($this->getLocalisationPath.'results') }} -
-
@endif @endif -
-@endif + @endif +
@includeWhen( $this->hasConfigurableAreaFor('after-pagination'), diff --git a/src/Traits/Helpers/PaginationHelpers.php b/src/Traits/Helpers/PaginationHelpers.php index b97666ca3..07ee59f59 100644 --- a/src/Traits/Helpers/PaginationHelpers.php +++ b/src/Traits/Helpers/PaginationHelpers.php @@ -27,6 +27,7 @@ public function getPaginationTheme(): string return $this->paginationTheme; } + #[Computed] public function paginationIsEnabled(): bool { return $this->getPaginationStatus() === true; @@ -118,6 +119,7 @@ public function getPerPageDisplayedItemCount(): int return $this->paginationCurrentCount; } + #[Computed] public function showPaginationDetails(): bool { return $this->shouldShowPaginationDetails === true; diff --git a/tests/Unit/Traits/Visuals/PaginationVisualsTest.php b/tests/Unit/Traits/Visuals/PaginationVisualsTest.php index 8e0134f61..1d4226e78 100644 --- a/tests/Unit/Traits/Visuals/PaginationVisualsTest.php +++ b/tests/Unit/Traits/Visuals/PaginationVisualsTest.php @@ -186,7 +186,7 @@ public function test_detailed_pagination_is_displayed_standard_bs4(): void Livewire::test(PetsTable::class) ->call('setTheme', 'bootstrap-4') ->call('enableDetailedPagination', 'standard') - ->assertSeeHtmlInOrder(['
', + ->assertSeeHtmlInOrder(['
', 'Showing', '1', 'to', @@ -231,7 +231,7 @@ public function test_detailed_pagination_is_displayed_standard_bs5(): void Livewire::test(PetsTable::class) ->call('setTheme', 'bootstrap-5') ->call('enableDetailedPagination', 'standard') - ->assertSeeHtmlInOrder(['
', + ->assertSeeHtmlInOrder(['
', 'Showing', '1', 'to', @@ -244,7 +244,7 @@ public function test_detailed_pagination_is_displayed_simple_bs5(): void Livewire::test(PetsTable::class) ->call('setTheme', 'bootstrap-5') ->call('enableDetailedPagination', 'simple') - ->assertSeeHtmlInOrder(['
', + ->assertSeeHtmlInOrder(['
', 'Showing', '1', 'to',