diff --git a/src/Traits/Configuration/PaginationConfiguration.php b/src/Traits/Configuration/PaginationConfiguration.php index 02fde2557..7d185c246 100644 --- a/src/Traits/Configuration/PaginationConfiguration.php +++ b/src/Traits/Configuration/PaginationConfiguration.php @@ -163,5 +163,4 @@ public function setShouldRetrieveTotalItemCountDisabled(): self return $this; } - } diff --git a/src/Traits/Helpers/PaginationHelpers.php b/src/Traits/Helpers/PaginationHelpers.php index 61a98c9f5..0240481ab 100644 --- a/src/Traits/Helpers/PaginationHelpers.php +++ b/src/Traits/Helpers/PaginationHelpers.php @@ -139,12 +139,9 @@ private function getPerPagePaginationSessionKey(): string return $this->tableName.'-perPage'; } - #[Computed] public function getShouldRetrieveTotalItemCount(): bool { return $this->shouldRetrieveTotalItemCount; } - - } diff --git a/src/Traits/Styling/Configuration/PaginationStylingConfiguration.php b/src/Traits/Styling/Configuration/PaginationStylingConfiguration.php index 0a503041e..2e1ea03ea 100644 --- a/src/Traits/Styling/Configuration/PaginationStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/PaginationStylingConfiguration.php @@ -1,43 +1,41 @@ -customPaginationBlade = $customPaginationBlade; - - return $this; - } - - public function setPaginationTheme(string $theme): self - { - $this->paginationTheme = $theme; - - return $this; - } - - public function setPaginationWrapperAttributes(array $paginationWrapperAttributes = []): self - { - $this->setCustomAttributes(propertyName: 'paginationWrapperAttributes', customAttributes: array_merge($this->getPaginationWrapperAttributes(), $paginationWrapperAttributes)); - - return $this; - } - - public function setPerPageFieldAttributes(array $perPageFieldAttributes = []): self - { - $this->setCustomAttributes(propertyName: 'perPageFieldAttributes', customAttributes: array_merge($this->getPerPageFieldAttributes(), $perPageFieldAttributes)); - - return $this; - } - - public function setPerPageWrapperAttributes(array $perPageWrapperAttributes = []): self - { - $this->setCustomAttributes(propertyName: 'perPageWrapperAttributes', customAttributes: array_merge($this->getPerPageWrapperAttributes(), $perPageWrapperAttributes)); - - return $this; - } - - -} \ No newline at end of file +customPaginationBlade = $customPaginationBlade; + + return $this; + } + + public function setPaginationTheme(string $theme): self + { + $this->paginationTheme = $theme; + + return $this; + } + + public function setPaginationWrapperAttributes(array $paginationWrapperAttributes = []): self + { + $this->setCustomAttributes(propertyName: 'paginationWrapperAttributes', customAttributes: array_merge($this->getPaginationWrapperAttributes(), $paginationWrapperAttributes)); + + return $this; + } + + public function setPerPageFieldAttributes(array $perPageFieldAttributes = []): self + { + $this->setCustomAttributes(propertyName: 'perPageFieldAttributes', customAttributes: array_merge($this->getPerPageFieldAttributes(), $perPageFieldAttributes)); + + return $this; + } + + public function setPerPageWrapperAttributes(array $perPageWrapperAttributes = []): self + { + $this->setCustomAttributes(propertyName: 'perPageWrapperAttributes', customAttributes: array_merge($this->getPerPageWrapperAttributes(), $perPageWrapperAttributes)); + + return $this; + } +} diff --git a/src/Traits/Styling/HasPaginationStyling.php b/src/Traits/Styling/HasPaginationStyling.php index 1d7682315..a65c816bb 100644 --- a/src/Traits/Styling/HasPaginationStyling.php +++ b/src/Traits/Styling/HasPaginationStyling.php @@ -1,29 +1,29 @@ - '', 'default-colors' => true, 'default-styling' => true]; - - // Used In Frontend - protected array $perPageWrapperAttributes = ['class' => '', 'default-colors' => true, 'default-styling' => true]; - - // Used In Frontend - protected array $paginationWrapperAttributes = ['class' => '']; - - // Used In Frontend - protected ?string $customPaginationBlade; -} + '', 'default-colors' => true, 'default-styling' => true]; + + // Used In Frontend + protected array $perPageWrapperAttributes = ['class' => '', 'default-colors' => true, 'default-styling' => true]; + + // Used In Frontend + protected array $paginationWrapperAttributes = ['class' => '']; + + // Used In Frontend + protected ?string $customPaginationBlade; +} diff --git a/src/Traits/Styling/Helpers/PaginationStylingHelpers.php b/src/Traits/Styling/Helpers/PaginationStylingHelpers.php index e33398303..b957750d3 100644 --- a/src/Traits/Styling/Helpers/PaginationStylingHelpers.php +++ b/src/Traits/Styling/Helpers/PaginationStylingHelpers.php @@ -1,67 +1,65 @@ -paginationTheme; - } - - #[Computed] - public function getPaginationWrapperAttributes(): array - { - return $this->getCustomAttributes(propertyName: 'paginationWrapperAttributes', default: false, classicMode: true); - } - - #[Computed] - public function getPaginationWrapperAttributesBag(): ComponentAttributeBag - { - return $this->getCustomAttributesBagFromArray($this->getPaginationWrapperAttributes()); - } - - - #[Computed] - public function getPerPageFieldAttributes(): array - { - return $this->getCustomAttributes(propertyName: 'perPageFieldAttributes', default: false, classicMode: false); - - } - - #[Computed] - public function getPerPageFieldAttributesBag(): ComponentAttributeBag - { - return new ComponentAttributeBag($this->getPerPageFieldAttributes()); - } - - #[Computed] - public function getPerPageWrapperAttributes(): array - { - return $this->getCustomAttributes(propertyName: 'perPageWrapperAttributes', default: false, classicMode: false); - - } - - #[Computed] - public function getPerPageWrapperAttributesBag(): ComponentAttributeBag - { - return new ComponentAttributeBag($this->getPerPageWrapperAttributes()); - } - - #[Computed] - public function hasCustomPaginationBlade(): bool - { - return (isset($this->customPaginationBlade) && $this->customPaginationBlade !== null); - } - - #[Computed] - public function getCustomPaginationBlade(): string - { - return $this->customPaginationBlade ?? ''; - } - -} \ No newline at end of file +paginationTheme; + } + + #[Computed] + public function getPaginationWrapperAttributes(): array + { + return $this->getCustomAttributes(propertyName: 'paginationWrapperAttributes', default: false, classicMode: true); + } + + #[Computed] + public function getPaginationWrapperAttributesBag(): ComponentAttributeBag + { + return $this->getCustomAttributesBagFromArray($this->getPaginationWrapperAttributes()); + } + + #[Computed] + public function getPerPageFieldAttributes(): array + { + return $this->getCustomAttributes(propertyName: 'perPageFieldAttributes', default: false, classicMode: false); + + } + + #[Computed] + public function getPerPageFieldAttributesBag(): ComponentAttributeBag + { + return new ComponentAttributeBag($this->getPerPageFieldAttributes()); + } + + #[Computed] + public function getPerPageWrapperAttributes(): array + { + return $this->getCustomAttributes(propertyName: 'perPageWrapperAttributes', default: false, classicMode: false); + + } + + #[Computed] + public function getPerPageWrapperAttributesBag(): ComponentAttributeBag + { + return new ComponentAttributeBag($this->getPerPageWrapperAttributes()); + } + + #[Computed] + public function hasCustomPaginationBlade(): bool + { + return isset($this->customPaginationBlade) && $this->customPaginationBlade !== null; + } + + #[Computed] + public function getCustomPaginationBlade(): string + { + return $this->customPaginationBlade ?? ''; + } +} diff --git a/src/Traits/WithPagination.php b/src/Traits/WithPagination.php index a5e28886e..b2c7b7b3d 100644 --- a/src/Traits/WithPagination.php +++ b/src/Traits/WithPagination.php @@ -49,7 +49,6 @@ trait WithPagination protected bool $shouldRetrieveTotalItemCount = true; - public function mountWithPagination(): void { $sessionPerPage = session()->get($this->getPerPagePaginationSessionKey(), $this->getPerPageAccepted()[0] ?? 10); diff --git a/tests/Traits/Helpers/PaginationHelpersTest.php b/tests/Traits/Helpers/PaginationHelpersTest.php index f4f5576b9..b33a2384f 100644 --- a/tests/Traits/Helpers/PaginationHelpersTest.php +++ b/tests/Traits/Helpers/PaginationHelpersTest.php @@ -120,7 +120,6 @@ public function test_can_disable_detailed_pagination(): void } - public function test_can_toggle_total_item_count_retrieval(): void { @@ -150,5 +149,4 @@ public function test_can_toggle_total_item_count_retrieval_via_status(): void $this->assertTrue($this->basicTable->getShouldRetrieveTotalItemCount()); } - } diff --git a/tests/Traits/Styling/PaginationStylingTest.php b/tests/Traits/Styling/PaginationStylingTest.php index e50eb81b7..d8a32e925 100644 --- a/tests/Traits/Styling/PaginationStylingTest.php +++ b/tests/Traits/Styling/PaginationStylingTest.php @@ -1,152 +1,146 @@ -assertSame('tailwind', $this->basicTable->getPaginationTheme()); - - $this->basicTable->setPaginationTheme('bootstrap'); - - $this->assertSame('bootstrap', $this->basicTable->getPaginationTheme()); - } - - public function test_can_get_per_page_field_attributes(): void - { - $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getPerPageFieldAttributes()); - - $this->basicTable->setPerPageFieldAttributes( - [ - 'class' => 'bg-blue-500 dark:bg-red-500', - 'default-colors' => true, - ] - ); - - $this->assertSame(['class' => 'bg-blue-500 dark:bg-red-500', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getPerPageFieldAttributes()); - - $this->basicTable->setPerPageFieldAttributes( - [ - 'default-styling' => false, - ] - ); - - $this->assertSame(['class' => 'bg-blue-500 dark:bg-red-500', 'default-colors' => true, 'default-styling' => false], $this->basicTable->getPerPageFieldAttributes()); - } - - public function test_can_get_per_page_wrapper_attributes(): void - { - - $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getPerPageWrapperAttributes()); - - $this->basicTable->setPerPageWrapperAttributes( - [ - 'class' => 'bg-blue-500 dark:bg-red-500', - 'default-colors' => true, - ] - ); - - $this->assertSame(['class' => 'bg-blue-500 dark:bg-red-500', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getPerPageWrapperAttributes()); - - $this->basicTable->setPerPageWrapperAttributes( - [ - 'default-styling' => false, - ] - ); - - $this->assertSame(['class' => 'bg-blue-500 dark:bg-red-500', 'default-colors' => true, 'default-styling' => false], $this->basicTable->getPerPageWrapperAttributes()); - } - - - public function test_can_get_pagination_wrapper_attributes(): void - { - - $this->assertSame(['class' => '', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getPaginationWrapperAttributes()); - - $this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg']); - - $this->assertSame(['class' => 'text-lg', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getPaginationWrapperAttributes()); - - $this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg', 'testval' => '456']); - - $this->assertSame(['class' => 'text-lg', 'default' => false, 'default-colors' => false, 'default-styling' => false, 'testval' => '456'], $this->basicTable->getPaginationWrapperAttributes()); - - } - - public function test_can_get_pagination_wrapper_attributes_bag(): void - { - $this->assertSame((new ComponentAttributeBag(['class' => '', 'default' => false, 'default-colors' => false, 'default-styling' => false]))->getAttributes(), $this->basicTable->getPaginationWrapperAttributesBag()->getAttributes()); - - $this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg']); - - $this->assertSame((new ComponentAttributeBag(['class' => 'text-lg', 'default' => false, 'default-colors' => false, 'default-styling' => false]))->getAttributes(), $this->basicTable->getPaginationWrapperAttributesBag()->getAttributes()); - - $this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg', 'testval' => '123']); - - $this->assertSame((new ComponentAttributeBag(['class' => 'text-lg', 'default' => false, 'default-colors' => false, 'default-styling' => false, 'testval' => '123']))->getAttributes(), $this->basicTable->getPaginationWrapperAttributesBag()->getAttributes()); - - } - - public function test_pagination_wrapper_merges_classes_in_frontend(): void - { - - Livewire::test(new class extends PetsTable - { - public function configure(): void - { - $this->setPrimaryKey('id') - ->setPaginationWrapperAttributes(['class' => 'pagiclass text-lg', 'testval' => '592', 'default' => true, 'default-colors' => true, 'default-styling' => true]); - } - }) - ->assertSeeHtml('