From c9ea6c0e38e9474347bf41859c41b109b31b62a9 Mon Sep 17 00:00:00 2001 From: Amir Maso'ud Mehrabian Date: Sat, 30 Nov 2024 13:44:52 +0330 Subject: [PATCH 01/15] Added neccessary files for Farsi translation --- resources/lang/json/fa.json | 72 ++++++++++++++++++++++++++++++++++ resources/lang/php/fa/core.php | 41 +++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 resources/lang/json/fa.json create mode 100644 resources/lang/php/fa/core.php diff --git a/resources/lang/json/fa.json b/resources/lang/json/fa.json new file mode 100644 index 000000000..7bcf32940 --- /dev/null +++ b/resources/lang/json/fa.json @@ -0,0 +1,72 @@ +{ + "livewire-tables::All": "همه", + "livewire-tables::All Columns": "تمام ستون‌ها", + "livewire-tables::Applied Filters": "فیلترهای اعمال‌شده", + "livewire-tables::Applied Sorting": "مرتب‌سازی اعمال‌شده", + "livewire-tables::Bulk Actions": "اقدامات گروهی", + "livewire-tables::Bulk Actions Confirm": "آیا مطمئن هستید؟", + "livewire-tables::Clear": "پاک کردن", + "livewire-tables::Columns": "ستون‌ها", + "livewire-tables::Debugging Values": "مقادیر اشکال‌زدایی", + "livewire-tables::Deselect All": "لغو انتخاب همه", + "livewire-tables::Done Reordering": "مرتب‌سازی تمام شد", + "livewire-tables::Filters": "فیلترها", + "livewire-tables::loading": "در حال بارگذاری", + "livewire-tables::max": "حداکثر", + "livewire-tables::min": "حداقل", + "livewire-tables::not_applicable": "نامعتبر", + "livewire-tables::No": "خیر", + "livewire-tables::No items found. Try to broaden your search.": "موردی یافت نشد. جستجوی خود را گسترش دهید.", + "livewire-tables::of": "از", + "livewire-tables::Remove filter option": "حذف گزینه فیلتر", + "livewire-tables::Remove sort option": "حذف گزینه مرتب‌سازی", + "livewire-tables::Reorder": "دوباره مرتب کنید", + "livewire-tables::results": "نتایج", + "livewire-tables::row": "ردیف", + "livewire-tables::rows": "ردیف‌ها", + "livewire-tables::rows, do you want to select all": "ردیف‌ها، آیا می‌خواهید همه را انتخاب کنید", + "livewire-tables::Search": "جستجو", + "livewire-tables::Select All": "انتخاب همه", + "livewire-tables::Select All On Page": "انتخاب همه در صفحه", + "livewire-tables::Showing": "در حال نمایش", + "livewire-tables::to": "تا", + "livewire-tables::Yes": "بله", + "livewire-tables::You are currently selecting all": "شما در حال حاضر همه را انتخاب کرده‌اید", + "livewire-tables::You are not connected to the internet.": "شما به اینترنت متصل نیستید.", + "livewire-tables::You have selected": "شما انتخاب کرده‌اید", + "All": "همه", + "All Columns": "تمام ستون‌ها", + "Applied Filters": "فیلترهای اعمال‌شده", + "Applied Sorting": "مرتب‌سازی اعمال‌شده", + "Bulk Actions": "اقدامات گروهی", + "Bulk Actions Confirm": "آیا مطمئن هستید؟", + "Clear": "پاک کردن", + "Columns": "ستون‌ها", + "Debugging Values": "مقادیر اشکال‌زدایی", + "Deselect All": "لغو انتخاب همه", + "Done Reordering": "مرتب‌سازی تمام شد", + "Filters": "فیلترها", + "loading": "در حال بارگذاری", + "max": "حداکثر", + "min": "حداقل", + "not_applicable": "نامعتبر", + "No": "خیر", + "No items found. Try to broaden your search.": "موردی یافت نشد. جستجوی خود را گسترش دهید.", + "of": "از", + "Remove filter option": "حذف گزینه فیلتر", + "Remove sort option": "حذف گزینه مرتب‌سازی", + "Reorder": "دوباره مرتب کنید", + "results": "نتایج", + "row": "ردیف", + "rows": "ردیف‌ها", + "rows, do you want to select all": "ردیف‌ها، آیا می‌خواهید همه را انتخاب کنید", + "Search": "جستجو", + "Select All": "انتخاب همه", + "Select All On Page": "انتخاب همه در صفحه", + "Showing": "در حال نمایش", + "to": "تا", + "Yes": "بله", + "You are currently selecting all": "شما در حال حاضر همه را انتخاب کرده‌اید", + "You are not connected to the internet.": "شما به اینترنت متصل نیستید.", + "You have selected": "شما انتخاب کرده‌اید" +} \ No newline at end of file diff --git a/resources/lang/php/fa/core.php b/resources/lang/php/fa/core.php new file mode 100644 index 000000000..dbf0f593f --- /dev/null +++ b/resources/lang/php/fa/core.php @@ -0,0 +1,41 @@ + 'همه', + 'All Columns' => 'تمام ستون‌ها', + 'Applied Filters' => 'فیلترهای اعمال‌شده', + 'Applied Sorting' => 'مرتب‌سازی اعمال‌شده', + 'Bulk Actions' => 'اقدامات گروهی', + 'Bulk Actions Confirm' => 'آیا مطمئن هستید؟', + 'cancel' => 'لغو', + 'Clear' => 'پاک کردن', + 'Columns' => 'ستون‌ها', + 'Debugging Values' => 'مقادیر اشکال‌زدایی', + 'Deselect All' => 'لغو انتخاب همه', + 'Done Reordering' => 'مرتب‌سازی تمام شد', + 'Filters' => 'فیلترها', + 'loading' => 'در حال بارگذاری', + 'max' => 'حداکثر', + 'min' => 'حداقل', + 'not_applicable' => 'نامعتبر', + 'No' => 'خیر', + 'No items found, try to broaden your search' => 'موردی یافت نشد، جستجوی خود را گسترش دهید', + 'of' => 'از', + 'Remove filter option' => 'حذف گزینه فیلتر', + 'Remove sort option' => 'حذف گزینه مرتب‌سازی', + 'Reorder' => 'دوباره مرتب کنید', + 'results' => 'نتایج', + 'row' => 'ردیف', + 'rows' => 'ردیف‌ها', + 'rows, do you want to select all' => 'ردیف‌ها، آیا می‌خواهید همه را انتخاب کنید', + 'save' => 'ذخیره', + 'Search' => 'جستجو', + 'Select All' => 'انتخاب همه', + 'Select All On Page' => 'انتخاب همه در صفحه', + 'Showing' => 'در حال نمایش', + 'to' => 'تا', + 'Yes' => 'بله', + 'You are currently selecting all' => 'شما در حال حاضر همه را انتخاب کرده‌اید', + 'You are not connected to the internet' => 'شما به اینترنت متصل نیستید', + 'You have selected' => 'شما انتخاب کرده‌اید', +]; \ No newline at end of file From 35a1d4cd3a4064ae74274496b915e33c19a83aa6 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 1 Dec 2024 06:10:15 +0000 Subject: [PATCH 02/15] Test Workflow Adjustments --- .github/workflows/discord-releases.yml | 2 +- .github/workflows/run-phpstan-pull.yml | 6 +++--- .github/workflows/run-phpstan.yml | 6 +++--- .github/workflows/run-tests-pcov-pull.yml | 22 +++++++++++----------- .github/workflows/run-tests-pull.yml | 8 ++++---- .github/workflows/run-tests.yml | 12 ++++++------ 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/discord-releases.yml b/.github/workflows/discord-releases.yml index 17e5ac816..236cea737 100644 --- a/.github/workflows/discord-releases.yml +++ b/.github/workflows/discord-releases.yml @@ -4,7 +4,7 @@ on: jobs: github-releases-to-discord: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/run-phpstan-pull.yml b/.github/workflows/run-phpstan-pull.yml index 9a288188b..7426e4a7a 100644 --- a/.github/workflows/run-phpstan-pull.yml +++ b/.github/workflows/run-phpstan-pull.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest] + os: [ubuntu-24.04] php: [8.3] laravel: [11] stability: [prefer-dist] @@ -20,7 +20,7 @@ jobs: name: PHPStan - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + extensions: dom, curl, libxml, mbstring, zip, pcntl, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, exif, iconv, fileinfo steps: - name: Checkout code @@ -47,7 +47,7 @@ jobs: php-version: ${{ matrix.php }} extensions: ${{ env.extensions }} coverage: pcov - tools: phpunit:9.5 + tools: phpunit:11.4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/run-phpstan.yml b/.github/workflows/run-phpstan.yml index 87180f167..5132a9479 100644 --- a/.github/workflows/run-phpstan.yml +++ b/.github/workflows/run-phpstan.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest] + os: [ubuntu-24.04] php: [8.3] laravel: [11] stability: [prefer-dist] @@ -23,7 +23,7 @@ jobs: name: PHPStan - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + extensions: dom, curl, libxml, mbstring, zip, pcntl, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, exif, iconv, fileinfo steps: - name: Checkout code @@ -50,7 +50,7 @@ jobs: php-version: ${{ matrix.php }} extensions: ${{ env.extensions }} coverage: pcov - tools: phpunit:9.5 + tools: phpunit:11.4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/run-tests-pcov-pull.yml b/.github/workflows/run-tests-pcov-pull.yml index 4457fb22a..0fa82ceb9 100644 --- a/.github/workflows/run-tests-pcov-pull.yml +++ b/.github/workflows/run-tests-pcov-pull.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest] + os: [ubuntu-24.04] php: [8.3] laravel: [11] stability: [prefer-dist] @@ -24,7 +24,7 @@ jobs: name: PCOV - ${{ matrix.os }} - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }}-withpcov - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pcov,pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pcov,pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, fileinfo steps: - name: Checkout code @@ -37,7 +37,14 @@ jobs: php-version: ${{ matrix.php }} extensions: ${{ env.extensions }} key: ${{ env.extensionKey }} - + + - name: Cache extensions + uses: actions/cache@v4 + with: + path: ${{ steps.extcache.outputs.dir }} + key: ${{ steps.extcache.outputs.key }} + restore-keys: ${{ steps.extcache.outputs.key }} + - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -49,13 +56,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Cache extensions - uses: actions/cache@v4 - with: - path: ${{ steps.extcache.outputs.dir }} - key: ${{ steps.extcache.outputs.key }} - restore-keys: ${{ steps.extcache.outputs.key }} - - name: Setup problem matchers for PHP run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" @@ -91,7 +91,7 @@ jobs: run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Unit Test Suite" --cache-directory=".phpunit.cache/code-coverage" --strict-coverage --coverage-clover ./coverage.xml - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: diff --git a/.github/workflows/run-tests-pull.yml b/.github/workflows/run-tests-pull.yml index 0de41ddb2..3d81e3b8c 100644 --- a/.github/workflows/run-tests-pull.yml +++ b/.github/workflows/run-tests-pull.yml @@ -14,14 +14,14 @@ jobs: max-parallel: 3 matrix: os: [ubuntu-latest] - php: [8.1, 8.2, 8.3] + php: [8.1, 8.2, 8.3, 8.4] laravel: [10.*] stability: [prefer-dist] name: PULL PHP-${{ matrix.php }} - Laravel-10 env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr + extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, fileinfo, :psr steps: - name: Checkout code @@ -95,14 +95,14 @@ jobs: max-parallel: 2 matrix: os: [ubuntu-latest] - php: [8.2, 8.3] + php: [8.2, 8.3, 8.4] laravel: [11.*] stability: [prefer-dist] name: PULL PHP-${{ matrix.php }} - Laravel-11 env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }}-L${{ matrix.laravel }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr + extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, fileinfo, :psr steps: - name: Checkout code diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ff452e572..05ff871b9 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -15,15 +15,15 @@ jobs: fail-fast: false max-parallel: 3 matrix: - os: [ubuntu-latest] - php: [8.1, 8.2, 8.3] + os: [ubuntu-24.04] + php: [8.1, 8.2, 8.3, 8.4] laravel: [10.*] stability: [prefer-dist] name: PHP-${{ matrix.php }} - Laravel-10 env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr + extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, fileinfo, :psr steps: - name: Checkout code @@ -96,15 +96,15 @@ jobs: fail-fast: false max-parallel: 2 matrix: - os: [ubuntu-latest] - php: [8.2, 8.3] + os: [ubuntu-24.04] + php: [8.2, 8.3, 8.4] laravel: [11.*] stability: [prefer-dist] name: PHP-${{ matrix.php }} - Laravel-11 env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr + extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, fileinfo, :psr steps: - name: Checkout code From 1b388e113222f7652cb1464c64911e5179f7e58e Mon Sep 17 00:00:00 2001 From: lrljoe Date: Sun, 1 Dec 2024 06:16:24 +0000 Subject: [PATCH 03/15] Fix styling --- resources/lang/php/fa/core.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lang/php/fa/core.php b/resources/lang/php/fa/core.php index dbf0f593f..bf880aaeb 100644 --- a/resources/lang/php/fa/core.php +++ b/resources/lang/php/fa/core.php @@ -38,4 +38,4 @@ 'You are currently selecting all' => 'شما در حال حاضر همه را انتخاب کرده‌اید', 'You are not connected to the internet' => 'شما به اینترنت متصل نیستید', 'You have selected' => 'شما انتخاب کرده‌اید', -]; \ No newline at end of file +]; From b09c351b5b0b4c524c684c3f0df4d5d35ff072af Mon Sep 17 00:00:00 2001 From: LRLJoe Date: Tue, 3 Dec 2024 23:08:22 +0000 Subject: [PATCH 04/15] Add initial commit with basic tests --- .../table/tr/bulk-actions.blade.php | 206 +++++++----------- .../BulkActionStylingConfiguration.php | 13 ++ src/Traits/Styling/HasBulkActionsStyling.php | 3 + .../Helpers/BulkActionStylingHelpers.php | 15 ++ .../BulkActionsStylingConfigurationTest.php | 1 + 5 files changed, 115 insertions(+), 123 deletions(-) diff --git a/resources/views/components/table/tr/bulk-actions.blade.php b/resources/views/components/table/tr/bulk-actions.blade.php index 11ecc95a8..4b85d49a6 100644 --- a/resources/views/components/table/tr/bulk-actions.blade.php +++ b/resources/views/components/table/tr/bulk-actions.blade.php @@ -1,4 +1,4 @@ -@aware([ 'tableName','isTailwind','isBootstrap']) +@aware([ 'tableName']) @if ($this->bulkActionsAreEnabled() && $this->hasBulkActions()) @php @@ -7,134 +7,94 @@ $simplePagination = $this->isPaginationMethod('simple'); @endphp - @if ($isTailwind) - - - - - - - - @elseif ($isBootstrap) - - - + + + + @endif diff --git a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php index 9c61f9eba..12b1d31d7 100644 --- a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php @@ -73,4 +73,17 @@ public function setBulkActionsThCheckboxAttributes(array $bulkActionsThCheckboxA return $this; } + + /** + * Used to set attributes for the Bulk Actions Row Buttons + * + */ + #[Computed] + public function setBulkActionsRowButtonAttributes(array $bulkActionsRowButtonAttributes): self + { + $this->setCustomAttributes('bulkActionsRowButtonAttributes', $bulkActionsRowButtonAttributes); + + return $this; + } + } diff --git a/src/Traits/Styling/HasBulkActionsStyling.php b/src/Traits/Styling/HasBulkActionsStyling.php index c1f1b1aca..34eb5ecf0 100644 --- a/src/Traits/Styling/HasBulkActionsStyling.php +++ b/src/Traits/Styling/HasBulkActionsStyling.php @@ -25,4 +25,7 @@ trait HasBulkActionsStyling protected array $bulkActionsMenuAttributes = ['default-colors' => true, 'default-styling' => true]; protected array $bulkActionsMenuItemAttributes = ['default-colors' => true, 'default-styling' => true]; + + protected array $bulkActionsRowButtonAttributes = ['default-colors' => true, 'default-styling' => true]; + } diff --git a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php index 6c100c345..f64099b25 100644 --- a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php +++ b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php @@ -3,6 +3,7 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; use Livewire\Attributes\Computed; +use Illuminate\View\ComponentAttributeBag; trait BulkActionStylingHelpers { @@ -93,4 +94,18 @@ public function getBulkActionsTdCheckboxAttributes(): array return $this->getCustomAttributes('bulkActionsTdCheckboxAttributes'); } + + /** + * Used to get attributes for the Bulk Actions Row Buttons + * + * @return array + */ + #[Computed] + public function getBulkActionsRowButtonAttributes(): array + { + return $this->getCustomAttributes('bulkActionsRowButtonAttributes', true); + + } + + } diff --git a/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php b/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php index fb321a1c4..019c13d22 100644 --- a/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php +++ b/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php @@ -32,6 +32,7 @@ public static function providesBulkActionMethodsToTest(): array 'BulkActionsThCheckboxAttributes', 'BulkActionsTdAttributes', 'BulkActionsTdCheckboxAttributes', + 'BulkActionsRowButtonAttributes', ]; } From c69c414e0349e60891e67aec45eeb29e9c49e2b8 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Tue, 3 Dec 2024 23:08:54 +0000 Subject: [PATCH 05/15] Fix styling --- .../Styling/Configuration/BulkActionStylingConfiguration.php | 2 -- src/Traits/Styling/HasBulkActionsStyling.php | 1 - src/Traits/Styling/Helpers/BulkActionStylingHelpers.php | 4 +--- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php index 12b1d31d7..96cd5353f 100644 --- a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php @@ -76,7 +76,6 @@ public function setBulkActionsThCheckboxAttributes(array $bulkActionsThCheckboxA /** * Used to set attributes for the Bulk Actions Row Buttons - * */ #[Computed] public function setBulkActionsRowButtonAttributes(array $bulkActionsRowButtonAttributes): self @@ -85,5 +84,4 @@ public function setBulkActionsRowButtonAttributes(array $bulkActionsRowButtonAtt return $this; } - } diff --git a/src/Traits/Styling/HasBulkActionsStyling.php b/src/Traits/Styling/HasBulkActionsStyling.php index 34eb5ecf0..07bf1f133 100644 --- a/src/Traits/Styling/HasBulkActionsStyling.php +++ b/src/Traits/Styling/HasBulkActionsStyling.php @@ -27,5 +27,4 @@ trait HasBulkActionsStyling protected array $bulkActionsMenuItemAttributes = ['default-colors' => true, 'default-styling' => true]; protected array $bulkActionsRowButtonAttributes = ['default-colors' => true, 'default-styling' => true]; - } diff --git a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php index f64099b25..1599d9917 100644 --- a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php +++ b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php @@ -2,8 +2,8 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; -use Livewire\Attributes\Computed; use Illuminate\View\ComponentAttributeBag; +use Livewire\Attributes\Computed; trait BulkActionStylingHelpers { @@ -106,6 +106,4 @@ public function getBulkActionsRowButtonAttributes(): array return $this->getCustomAttributes('bulkActionsRowButtonAttributes', true); } - - } From 0541611cd737e38ad14479ec2a19dbb7cef6a897 Mon Sep 17 00:00:00 2001 From: LRLJoe Date: Tue, 3 Dec 2024 23:16:59 +0000 Subject: [PATCH 06/15] Adjust for AttributeBag --- .../views/components/table/tr/bulk-actions.blade.php | 8 ++++---- .../Styling/Helpers/BulkActionStylingHelpers.php | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/resources/views/components/table/tr/bulk-actions.blade.php b/resources/views/components/table/tr/bulk-actions.blade.php index 4b85d49a6..e63d18df2 100644 --- a/resources/views/components/table/tr/bulk-actions.blade.php +++ b/resources/views/components/table/tr/bulk-actions.blade.php @@ -28,7 +28,7 @@ wire:loading.attr="disabled" type="button" {{ - $attributes->merge($this->getBulkActionsRowButtonAttributes)->class([ + $this->getBulkActionsRowButtonAttributesBag->class([ 'ml-1 underline text-sm leading-5 font-medium focus:outline-none focus:underline transition duration-150 ease-in-out' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true), 'text-blue-600 text-gray-700 focus:text-gray-800 dark:text-white dark:hover:text-gray-400' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-colors'] ?? true), 'btn btn-primary btn-sm' => $this->isBootstrap && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true) @@ -54,7 +54,7 @@ wire:loading.attr="disabled" type="button" {{ - $attributes->merge($this->getBulkActionsRowButtonAttributes)->class([ + $this->getBulkActionsRowButtonAttributesBag->class([ 'ml-1 underline text-sm leading-5 font-medium focus:outline-none focus:underline transition duration-150 ease-in-out' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true), 'text-blue-600 text-gray-700 focus:text-gray-800 dark:text-white dark:hover:text-gray-400' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-colors'] ?? true), 'btn btn-primary btn-sm' => $this->isBootstrap && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true) @@ -69,7 +69,7 @@ wire:loading.attr="disabled" type="button" {{ - $attributes->merge($this->getBulkActionsRowButtonAttributes)->class([ + $this->getBulkActionsRowButtonAttributesBag->class([ 'ml-1 underline text-sm leading-5 font-medium focus:outline-none focus:underline transition duration-150 ease-in-out' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true), 'text-blue-600 text-gray-700 focus:text-gray-800 dark:text-white dark:hover:text-gray-400' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-colors'] ?? true), 'btn btn-primary btn-sm' => $this->isBootstrap && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true) @@ -84,7 +84,7 @@ wire:loading.attr="disabled" type="button" {{ - $attributes->merge($this->getBulkActionsRowButtonAttributes)->class([ + $this->getBulkActionsRowButtonAttributesBag->class([ 'ml-1 underline text-sm leading-5 font-medium focus:outline-none focus:underline transition duration-150 ease-in-out' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true), 'text-blue-600 text-gray-700 focus:text-gray-800 dark:text-white dark:hover:text-gray-400' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-colors'] ?? true), 'btn btn-primary btn-sm' => $this->isBootstrap && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true) diff --git a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php index 1599d9917..7a513958d 100644 --- a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php +++ b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php @@ -2,8 +2,8 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; -use Illuminate\View\ComponentAttributeBag; use Livewire\Attributes\Computed; +use Illuminate\View\ComponentAttributeBag; trait BulkActionStylingHelpers { @@ -106,4 +106,12 @@ public function getBulkActionsRowButtonAttributes(): array return $this->getCustomAttributes('bulkActionsRowButtonAttributes', true); } + + #[Computed] + public function getBulkActionsRowButtonAttributesBag(): ComponentAttributeBag + { + return $this->getCustomAttributesBagFromArray($this->getBulkActionsRowButtonAttributes()); + } + + } From 639d37a9f79ea1b57db65a39910239030f4e210f Mon Sep 17 00:00:00 2001 From: lrljoe Date: Tue, 3 Dec 2024 23:17:27 +0000 Subject: [PATCH 07/15] Fix styling --- src/Traits/Styling/Helpers/BulkActionStylingHelpers.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php index 7a513958d..adc3cea89 100644 --- a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php +++ b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php @@ -2,8 +2,8 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; -use Livewire\Attributes\Computed; use Illuminate\View\ComponentAttributeBag; +use Livewire\Attributes\Computed; trait BulkActionStylingHelpers { @@ -112,6 +112,4 @@ public function getBulkActionsRowButtonAttributesBag(): ComponentAttributeBag { return $this->getCustomAttributesBagFromArray($this->getBulkActionsRowButtonAttributes()); } - - } From 5ad3f4991258c679307cae97d3b8048044ce2c9a Mon Sep 17 00:00:00 2001 From: LRLJoe Date: Tue, 3 Dec 2024 23:18:08 +0000 Subject: [PATCH 08/15] Remove Computed from Set --- .../Styling/Configuration/BulkActionStylingConfiguration.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php index 96cd5353f..6f74ed5a3 100644 --- a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php @@ -77,7 +77,6 @@ public function setBulkActionsThCheckboxAttributes(array $bulkActionsThCheckboxA /** * Used to set attributes for the Bulk Actions Row Buttons */ - #[Computed] public function setBulkActionsRowButtonAttributes(array $bulkActionsRowButtonAttributes): self { $this->setCustomAttributes('bulkActionsRowButtonAttributes', $bulkActionsRowButtonAttributes); From a931da990adf223cef1ef381a69bd43123f290d3 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 8 Dec 2024 00:50:35 +0000 Subject: [PATCH 09/15] Respect setDisplayPaginationDetailsDisabled for unpaginated tables (#2119) * Respect setDisplayPaginationDetailsDisabled for unpaginated tables * Fix styling --------- Co-authored-by: lrljoe --- .../views/components/pagination.blade.php | 129 ++++++------------ src/Traits/Helpers/PaginationHelpers.php | 2 + .../Traits/Visuals/PaginationVisualsTest.php | 6 +- 3 files changed, 45 insertions(+), 92 deletions(-) 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', From 9ef4587014e9601fbc078f2ec63d602fe746fe31 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 8 Dec 2024 02:57:40 +0000 Subject: [PATCH 10/15] Add setFilterSlidedownWrapperAttributes and setFilterSlidedownRowAttributes (#2120) * Add setFilterSlidedownRowAttributes and setFilterSlidedownWrapperAttributes * Fix styling --------- Co-authored-by: lrljoe --- docs/filters/available-component-methods.md | 273 +++++++++ docs/filters/available-filter-methods.md | 289 ++++++++++ docs/filters/available-methods.md | 520 +----------------- docs/filters/creating-filters.md | 2 +- docs/filters/introduction.md | 2 +- .../toolbar/items/filter-slidedown.blade.php | 48 +- .../FilterMenuStylingConfiguration.php | 20 + src/Traits/Styling/HasFilterMenuStyling.php | 4 + .../Helpers/FilterMenuStylingHelpers.php | 28 + .../Styling/FilterSlidedownStylingTest.php | 92 ++++ 10 files changed, 740 insertions(+), 538 deletions(-) create mode 100644 docs/filters/available-component-methods.md create mode 100644 docs/filters/available-filter-methods.md create mode 100644 tests/Unit/Traits/Styling/FilterSlidedownStylingTest.php diff --git a/docs/filters/available-component-methods.md b/docs/filters/available-component-methods.md new file mode 100644 index 000000000..9a463edbf --- /dev/null +++ b/docs/filters/available-component-methods.md @@ -0,0 +1,273 @@ +--- +title: Available Component Methods +weight: 5 +--- + +These are the available filters configuration methods on the component. These are "table-wide" methods. + +--- + +Filters are **enabled by default** but will only show up if you have at least one defined. + +## setFiltersStatus + +Enable/disable filters for the whole component. + +```php +public function configure(): void +{ + $this->setFiltersStatus(true); + $this->setFiltersStatus(false); +} +``` + +## setFiltersEnabled + +Enable filters for the component. + +```php +public function configure(): void +{ + // Shorthand for $this->setFiltersStatus(true) + $this->setFiltersEnabled(); +} +``` + +## setFiltersDisabled + +Disable filters for the component. + +```php +public function configure(): void +{ + // Shorthand for $this->setFiltersStatus(false) + $this->setFiltersDisabled(); +} +``` + +--- + +## setFiltersVisibilityStatus + +**Enabled by default**, show/hide the filters dropdown. + +```php +public function configure(): void +{ + $this->setFiltersVisibilityStatus(true); + $this->setFiltersVisibilityStatus(false); +} +``` + +## setFiltersVisibilityEnabled + +Show the filters dropdown for the component. + +```php +public function configure(): void +{ + // Shorthand for $this->setFiltersVisibilityStatus(true) + $this->setFiltersVisibilityEnabled(); +} +``` + +## setFiltersVisibilityDisabled + +Hide the filters dropdown for the component. + +```php +public function configure(): void +{ + // Shorthand for $this->setFiltersVisibilityStatus(false) + $this->setFiltersVisibilityDisabled(); +} +``` + +--- + +## setFilterPillsStatus + +**Enabled by default**, show/hide the filter pills. + +```php +public function configure(): void +{ + $this->setFilterPillsStatus(true); + $this->setFilterPillsStatus(false); +} +``` + +## setFilterPillsEnabled + +Show the filter pills for the component. + +```php +public function configure(): void +{ + // Shorthand for $this->setFilterPillsStatus(true) + $this->setFilterPillsEnabled(); +} +``` + +## setFilterPillsDisabled + +Hide the filter pills for the component. + +```php +public function configure(): void +{ + // Shorthand for $this->setFilterPillsStatus(false) + $this->setFilterPillsDisabled(); +} +``` + +--- + +## setFilterLayout + +Set the filter layout for the component. + +```php +public function configure(): void +{ + $this->setFilterLayout('slide-down'); +} +``` + +## setFilterLayoutPopover + +Set the filter layout to popover. + +```php +public function configure(): void +{ + $this->setFilterLayoutPopover(); +} +``` + +Set the filter layout to slide down. + +## setFilterLayoutSlideDown + +```php +public function configure(): void +{ + $this->setFilterLayoutSlideDown(); +} +``` + +## setFilterSlideDownDefaultStatusEnabled + +Set the filter slide down to visible by default + +```php +public function configure(): void +{ + // Shorthand for $this->setFilterSlideDownDefaultStatus(true) + $this->setFilterSlideDownDefaultStatusEnabled(); +} +``` + +## setFilterSlideDownDefaultStatusDisabled + +Set the filter slide down to collapsed by default + +```php +public function configure(): void +{ + // Shorthand for $this->setFilterSlideDownDefaultStatus(false) + $this->setFilterSlideDownDefaultStatusDisabled(); +} +``` + +## storeFiltersInSessionEnabled + +Optional behaviour - stores filter values in the session (specific to table - based on the table name) + +### Exercise Caution +If re-using the same Livewire Table Component multiple times in your site, with the same table name, this may cause clashes in filter values + +```php +public function configure(): void +{ + $this->storeFiltersInSessionEnabled(); +} +``` +## storeFiltersInSessionDisabled + +Default behaviour - does not store filters in the session + +```php +public function configure(): void +{ + $this->storeFiltersInSessionDisabled(); +} +``` + +## setFilterPopoverAttributes + +Allows for the customisation of the appearance of the Filter Popover Menu. + +Note the addition of a "default-width" boolean, allowing you to customise the width more smoothly without impacting other applied classes. + +You may also replace default colors by setting "default-colors" to false, or default styling by setting "default-styling" to false, and specifying replacement classes in the "class" property. + +You can also replace the default transition behaviours (Tailwind) by specifying replacement attributes in the array. + +```php +public function configure(): void +{ + $this->setFilterPopoverAttributes( + [ + 'class' => 'w-96', + 'default-width' => false, + 'default-colors' => true, + 'default-styling' => true, + 'x-transition:enter' => 'transition ease-out duration-100', + ] + ); +} +``` + +## setFilterSlidedownWrapperAttributes + +Allows for the customisation of the appearance of the Filter Slidedown Wrapper. + +You may also replace default colors by setting "default-colors" to false, or default styling by setting "default-styling" to false, and specifying replacement classes in the "class" property. + +You can also replace the default transition behaviours (Tailwind) by specifying replacement attributes in the array, for example to extend the duration of the transition effect from the default duration-100 to duration-1000: + +```php +public function configure(): void +{ + $this->setFilterSlidedownWrapperAttributes([ + 'x-transition:enter' => 'transition ease-out duration-1000', + 'class' => 'text-black', + 'default-colors' => true, + 'default-styling' => true, + ]); +} +``` + +## setFilterSlidedownRowAttributes + +Allows for the customisation of the appearance of the Filter Slidedown Row. Note that this uses a callback, which receives the "rowIndex" of the Slidedown Row + +You may replace default colors by setting "default-colors" to false, or default styling by setting "default-styling" to false, and specifying replacement classes in the "class" property. + +```php +public function configure(): void +{ + $this->setFilterSlidedownRowAttributes(fn($rowIndex) => $rowIndex % 2 === 0 ? + [ + 'class' => 'bg-red-500', + 'default-colors' => true, + 'default-styling' => true, + ] : [ + 'class' => 'bg-blue-500', + 'default-colors' => true, + 'default-styling' => true, + ] + ); +} +``` diff --git a/docs/filters/available-filter-methods.md b/docs/filters/available-filter-methods.md new file mode 100644 index 000000000..6e17a63b4 --- /dev/null +++ b/docs/filters/available-filter-methods.md @@ -0,0 +1,289 @@ +--- +title: Available Filter Methods +weight: 6 +--- + +The following methods are available on the filter object. These are "filter-specific" methods. + +---- + +## setFilterPillTitle + +By default, the filter pill title is the filter name, but you can make it whatever you want: + +```php +SelectFilter::make('Active') + ->setFilterPillTitle('User Status') +``` + +## setFilterPillValues + +If you have numeric, or generated keys as your filter option values, they probably don't look too nice in the filter pill. You can set the values to be displayed in the filter pill: + +```php +SelectFilter::make('Active') + ->setFilterPillTitle('User Status') + ->setFilterPillValues([ + '1' => 'Active', + '0' => 'Inactive', + ]) + ->options([ + '' => 'All', + '1' => 'Yes', + '0' => 'No', + ]) +``` + +Now instead of `Active: Yes` it will say `User Status: Active` + +## hiddenFromMenus + +Hide the filter from both the filter popover and the filter slide down. + +```php +SelectFilter::make('Active') + ->hiddenFromMenus() +``` + +## hiddenFromPills + +Hide the filter from the filter pills when applied. + +```php +SelectFilter::make('Active') + ->hiddenFromPills() +``` + +## hiddenFromFilterCount + +Hide the filter from the filter count when applied. + +```php +SelectFilter::make('Active') + ->hiddenFromFilterCount() +``` + +## hiddenFromAll + +Hide the filter from the menus, pills, and count. + +```php +SelectFilter::make('Active') + ->hiddenFromAll() +``` + +## notResetByClearButton + +By default the `clear` button will reset all filters to their defaults. You can prevent this on a specific filter by using this method. + +```php +SelectFilter::make('Active') + ->notResetByClearButton() +``` + +## setFilterSlidedownRow + +This method applies only when using the Slide Down approach to filter display. +By default the filters will be displayed in the order that they are listed in the filters() method. This method allows you to specify the row that the filter will be listed. When multiple filters are placed on the same row, and a mobile device is used, then the first filter listed will "win" that row. +You may use either a string or an integer to pass to this method, and it can be used in conjunction with setFilterSlidedownColspan + +```php +SelectFilter::make('Active') + ->setFilterSlidedownRow(1) +``` + +## setFilterSlidedownColspan + +This method applies only when using the Slide Down approach to filter display. +By default each filter will take up one column, with the number of columns determined by the size of the screen, this ranges from 1 on a mobile device, to a maximum of 5 on a large display. This method allows you to specify the number of columns that the filter should span. It will span the number of columns specified, up to the number of columns available (depending on screen size). +You may use either a string or an integer to pass to this method, and it can be used in conjunction with setFilterSlidedownRow + +```php +DateFilter::make('Date') + ->config([ + 'min' => '2020-01-01', + 'max' => '2021-12-31', + ]) + ->setFilterSlidedownColspan('2') +``` + +## setFilterPillBlade + +Set a blade file for use in displaying the filter values in the pills area. You can use this in conjunction with setFilterPillValues() to prettify your applied filter values display. You will receive two properties ($filter) containing the filter instance, and ($value) containing the filter value. + +```php +SelectFilter::make('Active') + ->setFilterPillBlade('path.to.blade') +``` + +Example blade: +```php +@aware(['component']) +@props(['filter']) + + + {{ $filter->getFilterPillTitle() }} - ({{ $filter->getFilterPillValue($value) }}) + + + +``` + +## setCustomFilterLabel + +Set a custom blade file for the filter's label. This will be used in both the Pop-Over and SlideDown filter displays, you should therefore ensure that you cater for the different filter layouts. + +```php +SelectFilter::make('Active') + ->setCustomFilterLabel('path.to.blade') +``` + +You will receive several properties to your blade, explained here: +- $filter (the filter instance) +- $filterLayout ('slide-down' or 'popover') +- $tableName (the table name) +- $isTailwind (bool - is theme Tailwind) +- $isBootstrap (bool - is theme Bootstrap 4 or Bootstrap 5) +- $isBootstrap4 (bool - is theme Bootstrap 4) +- $isBootstrap5 (bool - is theme Bootstrap 5) +- $customLabelAttributes (array -> any customLabel attributes set using setFilterLabelAttributes()) + +Example label blade: +```php +@props(['filter', 'filterLayout' => 'popover', 'tableName' => 'table', 'isTailwind' => false, 'isBootstrap' => false, 'isBootstrap4' => false, 'isBootstrap5' => false, 'customLabelAttributes' => []]) + + + +``` + +## setFilterLabelAttributes + +### Old Method (Still Supported) +Set custom attributes for a Filter Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts. + +By default, this replaces the default classes on the Filter Label wrapper, if you would like to keep them, set the default flag to true. + +```php +TextFilter::make('Name') + ->setFilterLabelAttributes( + [ + 'class' => 'text-xl', + 'default' => true, + ] + ), +``` + +### New Method (Recommended) +Set custom attributes for a Filter Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts. + +By default, this replaces the default classes on the Filter Label wrapper, if you would like to keep them, set the default flag to true. + +```php +TextFilter::make('Name') + ->setLabelAttributes( + [ + 'class' => 'text-xl', + 'default' => true, + ] + ), +``` + +## setCustomView +Use a fully custom view for a filter. This will utilise solely your view when rendering this filter. Note that the following methods will no longer apply to a filter using this: +- setCustomFilterLabel +- setFilterLabelAttributes + +```php +TextFilter::make('Name') + ->setCustomView('text-custom-view'), +``` + +## Config + +If the filter takes any config options, you can set them with the `config` method: + +```php + DateFilter::make('Date') + ->config([ + 'min' => '2020-01-01', + 'max' => '2021-12-31', + ]) +``` + +## Customising Wireable Behaviour + +For the following Filters, you may customise how the input is wire:model into the Table Component: + +- DateFilter (Defaults to Live) +- DateTimeFilter (Defaults to Live) +- MultiSelectDropdownFilter (Defaults to live.debounce.250ms) +- MultiSelectFilter (Defaults to live.debounce.250ms) +- NumberFilter (Defaults to Blur) +- SelectFilter (Defaults to Live) +- TextFilter (Defaults to Blur) + +You may override this using the following methods, on any of the above Filter types: + +### setWireBlur() +Forces the filter to use a wire:model.blur approach +```php + TextFilter::make('Name') + ->config([ + 'placeholder' => 'Search Name', + 'maxlength' => '25', + ]) + ->setWireBlur() +``` + +### setWireDefer() +Forces the filter to use a wire:model approach +```php + TextFilter::make('Name') + ->config([ + 'placeholder' => 'Search Name', + 'maxlength' => '25', + ]) + ->setWireDefer() +``` + +### setWireLive() +Forces the fitler to use a wire:model.live approach +```php + TextFilter::make('Name') + ->config([ + 'placeholder' => 'Search Name', + 'maxlength' => '25', + ]) + ->setWireLive() +``` + +### setWireDebounce(int $debounceDelay) +Allows you to pass a string to use a wire:model.live.debounce.Xms approach +```php + TextFilter::make('Name') + ->config([ + 'placeholder' => 'Search Name', + 'maxlength' => '25', + ]) + ->setWireDebounce(50) +``` diff --git a/docs/filters/available-methods.md b/docs/filters/available-methods.md index 820916003..2fd27f523 100644 --- a/docs/filters/available-methods.md +++ b/docs/filters/available-methods.md @@ -3,521 +3,7 @@ title: Available Methods weight: 4 --- -## Component Methods +The documentation has now been split into two sections to enhance clarity. -These are the available filters configuration methods on the component. - ---- - -Filters are **enabled by default** but will only show up if you have at least one defined. - -### setFiltersStatus - -Enable/disable filters for the whole component. - -```php -public function configure(): void -{ - $this->setFiltersStatus(true); - $this->setFiltersStatus(false); -} -``` - -### setFiltersEnabled - -Enable filters for the component. - -```php -public function configure(): void -{ - // Shorthand for $this->setFiltersStatus(true) - $this->setFiltersEnabled(); -} -``` - -### setFiltersDisabled - -Disable filters for the component. - -```php -public function configure(): void -{ - // Shorthand for $this->setFiltersStatus(false) - $this->setFiltersDisabled(); -} -``` - ---- - -### setFiltersVisibilityStatus - -**Enabled by default**, show/hide the filters dropdown. - -```php -public function configure(): void -{ - $this->setFiltersVisibilityStatus(true); - $this->setFiltersVisibilityStatus(false); -} -``` - -### setFiltersVisibilityEnabled - -Show the filters dropdown for the component. - -```php -public function configure(): void -{ - // Shorthand for $this->setFiltersVisibilityStatus(true) - $this->setFiltersVisibilityEnabled(); -} -``` - -### setFiltersVisibilityDisabled - -Hide the filters dropdown for the component. - -```php -public function configure(): void -{ - // Shorthand for $this->setFiltersVisibilityStatus(false) - $this->setFiltersVisibilityDisabled(); -} -``` - ---- - -### setFilterPillsStatus - -**Enabled by default**, show/hide the filter pills. - -```php -public function configure(): void -{ - $this->setFilterPillsStatus(true); - $this->setFilterPillsStatus(false); -} -``` - -### setFilterPillsEnabled - -Show the filter pills for the component. - -```php -public function configure(): void -{ - // Shorthand for $this->setFilterPillsStatus(true) - $this->setFilterPillsEnabled(); -} -``` - -### setFilterPillsDisabled - -Hide the filter pills for the component. - -```php -public function configure(): void -{ - // Shorthand for $this->setFilterPillsStatus(false) - $this->setFilterPillsDisabled(); -} -``` - ---- - -### setFilterLayout - -Set the filter layout for the component. - -```php -public function configure(): void -{ - $this->setFilterLayout('slide-down'); -} -``` - -### setFilterLayoutPopover - -Set the filter layout to popover. - -```php -public function configure(): void -{ - $this->setFilterLayoutPopover(); -} -``` - -Set the filter layout to slide down. - -### setFilterLayoutSlideDown - -```php -public function configure(): void -{ - $this->setFilterLayoutSlideDown(); -} -``` - -### setFilterSlideDownDefaultStatusEnabled - -Set the filter slide down to visible by default - -```php -public function configure(): void -{ - // Shorthand for $this->setFilterSlideDownDefaultStatus(true) - $this->setFilterSlideDownDefaultStatusEnabled(); -} -``` - -### setFilterSlideDownDefaultStatusDisabled - -Set the filter slide down to collapsed by default - -```php -public function configure(): void -{ - // Shorthand for $this->setFilterSlideDownDefaultStatus(false) - $this->setFilterSlideDownDefaultStatusDisabled(); -} -``` - -### storeFiltersInSessionEnabled - -Optional behaviour - stores filter values in the session (specific to table - based on the table name) - -#### Exercise Caution -If re-using the same Livewire Table Component multiple times in your site, with the same table name, this may cause clashes in filter values - -```php -public function configure(): void -{ - $this->storeFiltersInSessionEnabled(); -} -``` -### storeFiltersInSessionDisabled - -Default behaviour - does not store filters in the session - -```php -public function configure(): void -{ - $this->storeFiltersInSessionDisabled(); -} -``` - -### setFilterPopoverAttributes - -Allows for the customisation of the appearance of the Filter Popover Menu. - -Note the addition of a "default-width" boolean, allowing you to customise the width more smoothly without impacting other applied classes. - -You may also replace default colors by setting "default-colors" to false, or default styling by setting "default-styling" to false, and specifying replacement classes in the "class" property. - -You can also replace the default transition behaviours (Tailwind) by specifying replacement attributes in the array. - -```php -public function configure(): void -{ - $this->setFilterPopoverAttributes( - [ - 'class' => 'w-96', - 'default-width' => false, - 'default-colors' => true, - 'default-styling' => true, - 'x-transition:enter' => 'transition ease-out duration-100', - ] - ); -} -``` - ----- - -## Filter Methods - -The following methods are available on the filter object. - ----- - -### setFilterPillTitle - -By default, the filter pill title is the filter name, but you can make it whatever you want: - -```php -SelectFilter::make('Active') - ->setFilterPillTitle('User Status') -``` - -### setFilterPillValues - -If you have numeric, or generated keys as your filter option values, they probably don't look too nice in the filter pill. You can set the values to be displayed in the filter pill: - -```php -SelectFilter::make('Active') - ->setFilterPillTitle('User Status') - ->setFilterPillValues([ - '1' => 'Active', - '0' => 'Inactive', - ]) - ->options([ - '' => 'All', - '1' => 'Yes', - '0' => 'No', - ]) -``` - -Now instead of `Active: Yes` it will say `User Status: Active` - -### hiddenFromMenus - -Hide the filter from both the filter popover and the filter slide down. - -```php -SelectFilter::make('Active') - ->hiddenFromMenus() -``` - -### hiddenFromPills - -Hide the filter from the filter pills when applied. - -```php -SelectFilter::make('Active') - ->hiddenFromPills() -``` - -### hiddenFromFilterCount - -Hide the filter from the filter count when applied. - -```php -SelectFilter::make('Active') - ->hiddenFromFilterCount() -``` - -### hiddenFromAll - -Hide the filter from the menus, pills, and count. - -```php -SelectFilter::make('Active') - ->hiddenFromAll() -``` - -### notResetByClearButton - -By default the `clear` button will reset all filters to their defaults. You can prevent this on a specific filter by using this method. - -```php -SelectFilter::make('Active') - ->notResetByClearButton() -``` - -### setFilterSlidedownRow - -This method applies only when using the Slide Down approach to filter display. -By default the filters will be displayed in the order that they are listed in the filters() method. This method allows you to specify the row that the filter will be listed. When multiple filters are placed on the same row, and a mobile device is used, then the first filter listed will "win" that row. -You may use either a string or an integer to pass to this method, and it can be used in conjunction with setFilterSlidedownColspan - -```php -SelectFilter::make('Active') - ->setFilterSlidedownRow(1) -``` - -### setFilterSlidedownColspan - -This method applies only when using the Slide Down approach to filter display. -By default each filter will take up one column, with the number of columns determined by the size of the screen, this ranges from 1 on a mobile device, to a maximum of 5 on a large display. This method allows you to specify the number of columns that the filter should span. It will span the number of columns specified, up to the number of columns available (depending on screen size). -You may use either a string or an integer to pass to this method, and it can be used in conjunction with setFilterSlidedownRow - -```php -DateFilter::make('Date') - ->config([ - 'min' => '2020-01-01', - 'max' => '2021-12-31', - ]) - ->setFilterSlidedownColspan('2') -``` - -### setFilterPillBlade - -Set a blade file for use in displaying the filter values in the pills area. You can use this in conjunction with setFilterPillValues() to prettify your applied filter values display. You will receive two properties ($filter) containing the filter instance, and ($value) containing the filter value. - -```php -SelectFilter::make('Active') - ->setFilterPillBlade('path.to.blade') -``` - -Example blade: -```php -@aware(['component']) -@props(['filter']) - - - {{ $filter->getFilterPillTitle() }} - ({{ $filter->getFilterPillValue($value) }}) - - - -``` - -### setCustomFilterLabel - -Set a custom blade file for the filter's label. This will be used in both the Pop-Over and SlideDown filter displays, you should therefore ensure that you cater for the different filter layouts. - -```php -SelectFilter::make('Active') - ->setCustomFilterLabel('path.to.blade') -``` - -You will receive several properties to your blade, explained here: -- $filter (the filter instance) -- $filterLayout ('slide-down' or 'popover') -- $tableName (the table name) -- $isTailwind (bool - is theme Tailwind) -- $isBootstrap (bool - is theme Bootstrap 4 or Bootstrap 5) -- $isBootstrap4 (bool - is theme Bootstrap 4) -- $isBootstrap5 (bool - is theme Bootstrap 5) -- $customLabelAttributes (array -> any customLabel attributes set using setFilterLabelAttributes()) - -Example label blade: -```php -@props(['filter', 'filterLayout' => 'popover', 'tableName' => 'table', 'isTailwind' => false, 'isBootstrap' => false, 'isBootstrap4' => false, 'isBootstrap5' => false, 'customLabelAttributes' => []) - - - -``` - -### setFilterLabelAttributes - -#### Old Method (Still Supported) -Set custom attributes for a Filter Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts. - -By default, this replaces the default classes on the Filter Label wrapper, if you would like to keep them, set the default flag to true. - -```php -TextFilter::make('Name') - ->setFilterLabelAttributes( - [ - 'class' => 'text-xl', - 'default' => true, - ] - ), -``` - -#### New Method (Recommended) -Set custom attributes for a Filter Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts. - -By default, this replaces the default classes on the Filter Label wrapper, if you would like to keep them, set the default flag to true. - -```php -TextFilter::make('Name') - ->setLabelAttributes( - [ - 'class' => 'text-xl', - 'default' => true, - ] - ), -``` - -### setCustomView -Use a fully custom view for a filter. This will utilise solely your view when rendering this filter. Note that the following methods will no longer apply to a filter using this: -- setCustomFilterLabel -- setFilterLabelAttributes - -```php -TextFilter::make('Name') - ->setCustomView('text-custom-view'), -``` - -### Config - -If the filter takes any config options, you can set them with the `config` method: - -```php - DateFilter::make('Date') - ->config([ - 'min' => '2020-01-01', - 'max' => '2021-12-31', - ]) -``` - -### Customising Wireable Behaviour - -For the following Filters, you may customise how the input is wire:model into the Table Component: - -- DateFilter (Defaults to Live) -- DateTimeFilter (Defaults to Live) -- MultiSelectDropdownFilter (Defaults to live.debounce.250ms) -- MultiSelectFilter (Defaults to live.debounce.250ms) -- NumberFilter (Defaults to Blur) -- SelectFilter (Defaults to Live) -- TextFilter (Defaults to Blur) - -You may override this using the following methods, on any of the above Filter types: - -#### setWireBlur() -Forces the filter to use a wire:model.blur approach -```php - TextFilter::make('Name') - ->config([ - 'placeholder' => 'Search Name', - 'maxlength' => '25', - ]) - ->setWireBlur() -``` - -#### setWireDefer() -Forces the filter to use a wire:model approach -```php - TextFilter::make('Name') - ->config([ - 'placeholder' => 'Search Name', - 'maxlength' => '25', - ]) - ->setWireDefer() -``` - -#### setWireLive() -Forces the fitler to use a wire:model.live approach -```php - TextFilter::make('Name') - ->config([ - 'placeholder' => 'Search Name', - 'maxlength' => '25', - ]) - ->setWireLive() -``` - -#### setWireDebounce(int $debounceDelay) -Allows you to pass a string to use a wire:model.live.debounce.Xms approach -```php - TextFilter::make('Name') - ->config([ - 'placeholder' => 'Search Name', - 'maxlength' => '25', - ]) - ->setWireDebounce(50) -``` +Documentation for Available Component Methods is now: [Here](./available-component-methods) +Documentation for Available Filter Methods is now: [Here](./available-filter-methods) diff --git a/docs/filters/creating-filters.md b/docs/filters/creating-filters.md index e940c5952..e13e98563 100644 --- a/docs/filters/creating-filters.md +++ b/docs/filters/creating-filters.md @@ -3,7 +3,7 @@ title: Creating Filters weight: 2 --- -To create filters, you must implement the `filters()` method on your component. +To create filters, you must implement the `filters()` method on your component, which must return an array. ```php public function filters(): array diff --git a/docs/filters/introduction.md b/docs/filters/introduction.md index 11f0d9e76..b0888514b 100644 --- a/docs/filters/introduction.md +++ b/docs/filters/introduction.md @@ -3,7 +3,7 @@ title: Introduction weight: 1 --- -Filters are a good way to narrow down your data. Version 2 has two ways to interact with filters, either by a popover menu or a slide down area. +Filters are a good way to narrow down your data. Version 2 has two ways to interact with filters, either by a popover menu or a slide down area, which are configurable on a per-table basis. ## Popover Menu diff --git a/resources/views/components/tools/toolbar/items/filter-slidedown.blade.php b/resources/views/components/tools/toolbar/items/filter-slidedown.blade.php index be507404b..123e587ec 100644 --- a/resources/views/components/tools/toolbar/items/filter-slidedown.blade.php +++ b/resources/views/components/tools/toolbar/items/filter-slidedown.blade.php @@ -1,28 +1,38 @@ @aware([ 'tableName']) @props([]) -
$this->isBootstrap, - ]) - @if($this->isTailwind) - x-transition:enter="transition ease-out duration-100" - x-transition:enter-start="transform opacity-0" - x-transition:enter-end="transform opacity-100" - x-transition:leave="transition ease-in duration-75" - x-transition:leave-start="transform opacity-100" - x-transition:leave-end="transform opacity-0" - @endif +
merge($this->getFilterSlidedownWrapperAttributes) + ->merge($this->isTailwind ? [ + 'x-transition:enter' => 'transition ease-out duration-100', + 'x-transition:enter-start' => 'transform opacity-0', + 'x-transition:enter-end' => 'transform opacity-100', + 'x-transition:leave' => 'transition ease-in duration-75', + 'x-transition:leave-start' => 'transform opacity-100', + 'x-transition:leave-end' => 'transform opacity-0', + ] : []) + ->class([ + 'container' => $this->isBootstrap && ($this->getFilterSlidedownWrapperAttributes['default'] ?? true), + ]) + ->except(['default','default-colors','default-styling']) + }} + > - @foreach ($this->getFiltersByRow() as $filterRowIndex => $filterRow) -
$this->isBootstrap, - 'grid grid-cols-12 gap-6 px-4 md:p-0 mb-6' => $this->isTailwind, + @foreach ($this->getFiltersByRow() as $filterRowIndex => $filtersInRow) + @php($defaultAttributes = $this->getFilterSlidedownRowAttributes($filterRowIndex)) +
merge($defaultAttributes) + ->merge([ + 'row' => $filterRowIndex, + ]) + ->class([ + 'row col-12' => $this->isBootstrap && ($defaultAttributes['default-styling'] ?? true), + 'grid grid-cols-12 gap-6 px-4 py-2 mb-2' => $this->isTailwind && ($defaultAttributes['default-styling'] ?? true), ]) - row="{{ $filterRowIndex }}" + ->except(['default','default-colors','default-styling']) + }} > - @foreach ($filterRow as $filter) + @foreach ($filtersInRow as $filter)
diff --git a/src/Traits/Styling/Configuration/FilterMenuStylingConfiguration.php b/src/Traits/Styling/Configuration/FilterMenuStylingConfiguration.php index 92d8ba467..4a68532d5 100644 --- a/src/Traits/Styling/Configuration/FilterMenuStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/FilterMenuStylingConfiguration.php @@ -16,6 +16,26 @@ public function setFilterPopoverAttributes(array $filterPopoverAttributes): self return $this; } + /** + * Used to set attributes for the Filter Slidedown Wrapper + */ + public function setFilterSlidedownWrapperAttributes(array $filterSlidedownWrapperAttributes): self + { + $this->filterSlidedownWrapperAttributes = array_merge($this->filterSlidedownWrapperAttributes, $filterSlidedownWrapperAttributes); + + return $this; + } + + /** + * Set a list of attributes to override on the th sort button elements + */ + public function setFilterSlidedownRowAttributes(\Closure $callback): self + { + $this->filterSlidedownRowCallback = $callback; + + return $this; + } + public function setFilterLayout(string $type): self { if (! in_array($type, ['popover', 'slide-down'], true)) { diff --git a/src/Traits/Styling/HasFilterMenuStyling.php b/src/Traits/Styling/HasFilterMenuStyling.php index c534027e4..03a6737b4 100644 --- a/src/Traits/Styling/HasFilterMenuStyling.php +++ b/src/Traits/Styling/HasFilterMenuStyling.php @@ -18,4 +18,8 @@ trait HasFilterMenuStyling public bool $filterSlideDownDefaultVisible = false; protected array $filterPopoverAttributes = ['class' => '', 'default-width' => true, 'default-colors' => true, 'default-styling' => true]; + + protected array $filterSlidedownWrapperAttributes = ['class' => '', 'default-colors' => true, 'default-styling' => true]; + + protected ?\Closure $filterSlidedownRowCallback; } diff --git a/src/Traits/Styling/Helpers/FilterMenuStylingHelpers.php b/src/Traits/Styling/Helpers/FilterMenuStylingHelpers.php index d5ddf6d6c..9833809d6 100644 --- a/src/Traits/Styling/Helpers/FilterMenuStylingHelpers.php +++ b/src/Traits/Styling/Helpers/FilterMenuStylingHelpers.php @@ -20,6 +20,34 @@ public function getFilterPopoverAttributes(): array } + /** + * Used to get attributes for the Filter Slidedown Wrapper + * + * @return array + */ + #[Computed] + public function getFilterSlidedownWrapperAttributes(): array + { + return $this->filterSlidedownWrapperAttributes; + + } + + /** + * Used to get attributes for the Filter Slidedown Row + * + * @return array + */ + #[Computed] + public function getFilterSlidedownRowAttributes(string $rowIndex): array + { + + if (isset($this->filterSlidedownRowCallback)) { + return array_merge(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => (int) $rowIndex], call_user_func($this->filterSlidedownRowCallback, (int) $rowIndex)); + } + + return ['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => (int) $rowIndex]; + } + public function getFilterSlideDownDefaultStatus(): bool { return $this->filterSlideDownDefaultVisible; diff --git a/tests/Unit/Traits/Styling/FilterSlidedownStylingTest.php b/tests/Unit/Traits/Styling/FilterSlidedownStylingTest.php new file mode 100644 index 000000000..5ba1ac182 --- /dev/null +++ b/tests/Unit/Traits/Styling/FilterSlidedownStylingTest.php @@ -0,0 +1,92 @@ +assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getFilterSlidedownWrapperAttributes()); + } + + public function test_filter_slidedown_wrapper_attributes_can_be_changed(): void + { + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getFilterSlidedownWrapperAttributes()); + $this->basicTable->setFilterSlidedownWrapperAttributes([ + 'class' => 'text-blue-500', + 'default-colors' => true, + 'default-styling' => true, + 'x-transition:enter' => 'transition ease-out duration-1000', + ]); + + $this->assertSame(['class' => 'text-blue-500', 'default-colors' => true, 'default-styling' => true, 'x-transition:enter' => 'transition ease-out duration-1000'], $this->basicTable->getFilterSlidedownWrapperAttributes()); + + $this->basicTable->setFilterSlidedownWrapperAttributes([ + 'x-transition:enter-start' => 'transform opacity-0', + ]); + + $this->assertSame(['class' => 'text-blue-500', 'default-colors' => true, 'default-styling' => true, 'x-transition:enter' => 'transition ease-out duration-1000', 'x-transition:enter-start' => 'transform opacity-0'], $this->basicTable->getFilterSlidedownWrapperAttributes()); + + } + + public function test_filter_slidedown_row_attributes_returns_default_if_not_set(): void + { + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1)); + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes(2)); + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes('1')); + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes('2')); + } + + public function test_filter_slidedown_row_attributes_can_be_changed(): void + { + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1)); + + $this->basicTable->setFilterSlidedownRowAttributes(fn ($rowIndex) => $rowIndex % 2 === 0 ? + [ + 'class' => 'bg-red-500', + 'default-colors' => true, + 'default-styling' => true, + ] : [ + 'class' => 'bg-blue-500', + 'default-colors' => true, + 'default-styling' => true, + ] + ); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes(0)); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1)); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes(2)); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes(3)); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes('0')); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes('1')); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes('2')); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes('3')); + + } + + public function test_filter_slidedown_row_attributes_can_be_changed_and_sets_defaults(): void + { + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes(0)); + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1)); + + $this->basicTable->setFilterSlidedownRowAttributes(fn ($rowIndex) => $rowIndex % 2 === 0 ? + [ + 'class' => 'bg-red-500', + 'default-colors' => false, + ] : [ + 'class' => 'bg-blue-500', + 'default-styling' => false, + ] + ); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes(0)); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1)); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes(2)); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes(3)); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes('0')); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes('1')); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes('2')); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes('3')); + + } +} From 91d183e7d560e675a609cc6cf436546b4c9d3fcc Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 8 Dec 2024 03:11:15 +0000 Subject: [PATCH 11/15] Add missing LivewireComponentFilterTest and BooleanFilterTest (#2121) * Add missing LivewireComponentFilterTest and BooleanFilterTest * Fix styling --------- Co-authored-by: lrljoe --- .../Unit/Views/Filters/BooleanFilterTest.php | 17 +++++++ .../Filters/LivewireComponentFilterTest.php | 49 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 tests/Unit/Views/Filters/LivewireComponentFilterTest.php diff --git a/tests/Unit/Views/Filters/BooleanFilterTest.php b/tests/Unit/Views/Filters/BooleanFilterTest.php index 5e834a339..5fb5203e4 100644 --- a/tests/Unit/Views/Filters/BooleanFilterTest.php +++ b/tests/Unit/Views/Filters/BooleanFilterTest.php @@ -27,6 +27,18 @@ public function test_can_set_boolean_filter_to_integer(): void $this->assertTrue(self::$filterInstance->validate(1)); } + public function test_can_set_boolean_filter_to_valid_string(): void + { + $this->assertTrue(self::$filterInstance->validate('1')); + $this->assertFalse(self::$filterInstance->validate('0')); + } + + public function test_cannot_set_boolean_filter_to_valid_string(): void + { + $this->assertFalse(self::$filterInstance->validate('abc')); + $this->assertFalse(self::$filterInstance->validate('def')); + } + public function test_can_get_custom_filter_pills(): void { $filter = self::$filterInstance; @@ -74,6 +86,11 @@ public function test_can_get_if_boolean_filter_not_empty_string(): void $this->assertFalse(self::$filterInstance->isEmpty('0')); } + public function test_can_get_if_boolean_filter_not_empty_invalid_string(): void + { + $this->assertTrue(self::$filterInstance->isEmpty('abc')); + } + public function test_can_validate_null_boolean_filter_value(): void { $filter = self::$filterInstance; diff --git a/tests/Unit/Views/Filters/LivewireComponentFilterTest.php b/tests/Unit/Views/Filters/LivewireComponentFilterTest.php new file mode 100644 index 000000000..447e229b6 --- /dev/null +++ b/tests/Unit/Views/Filters/LivewireComponentFilterTest.php @@ -0,0 +1,49 @@ +assertFalse($filter->hasFilterCallback()); + + $filter = LivewireComponentFilter::make('Active') + ->filter(function (Builder $builder, int $value) { + return $builder->where('name', '=', $value); + }); + + $this->assertTrue($filter->hasFilterCallback()); + $this->assertIsCallable($filter->getFilterCallback()); + } + + public function test_can_set_livewire_component_filter_to_text(): void + { + $filter = LivewireComponentFilter::make('BreedID'); + $this->assertSame('test', $filter->validate('test')); + $this->assertSame('123', $filter->validate(123)); + + } + + public function test_can_get_if_livewire_component_filter_empty(): void + { + $filter = LivewireComponentFilter::make('Active'); + $this->assertTrue($filter->isEmpty(null)); + $this->assertTrue($filter->isEmpty('')); + $this->assertFalse($filter->isEmpty('123')); + $this->assertFalse($filter->isEmpty('test')); + $this->assertFalse($filter->isEmpty(1234)); + + } +} From d5b2dc87839f150b3e31333ef5610e8864c70675 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:29:32 +0000 Subject: [PATCH 12/15] Update ChangeLog --- CHANGELOG.md | 19 +++++++++++++++++++ CONTRIBUTORS.md | 5 +++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93bd62c02..3f3165858 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,25 @@ All notable changes to `laravel-livewire-tables` will be documented in this file +## [v3.5.8] - 2024-12-10 +### New Features +- Set bulk action row button attributes by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2117 +- Add setFilterSlidedownWrapperAttributes and setFilterSlidedownRowAttributes by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2120 + +### Bug Fixes +- Respect setDisplayPaginationDetailsDisabled for unpaginated tables by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2119 + +### Localisation +- Added neccessary files for Farsi translation by @AmirMehrabi in https://github.com/rappasoft/laravel-livewire-tables/pull/2100 + +### Testing +- Workflow Adjustments by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2108 +- Add extra Search Lazy Tests by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2107 +- Restore Missing Lazy Search Tests by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2106 +- Ignore WithEvents Coverage by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2105 +- Add missing tests for WithCustomisations by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2104 +- Add missing LivewireComponentFilterTest and BooleanFilterTest by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2121 + ## [v3.5.7] - 2024-12-01 ### New Features - IncrementColumn by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2096 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index df270ea9a..f4a2f3e2d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -12,12 +12,13 @@ | Chinese - Taiwan (TW) | None | | Danish (DA) | [jeppeolesen](https://github.com/jeppeolesen) | | Dutch (NL) | [siebsie23](https://github.com/siebsie23), [spekkie2002](https://github.com/spekkie2002), [Jerimu](https://github.com/Jerimu) | -| English (EN) | Core Team | +| English (EN) | Core Maintainers | +| Farsi (FA) | [AmirMehrabi](https://github.com/AmirMehrabi) | | Finnish (FI) | [devmikromike](https://github.com/devmikromike) | | French (FR) | [dgillier](https://github.com/dgillier), [khwadj](https://github.com/khwadj)| | German (DE) | [khwadj](https://github.com/khwadj) | | Indonesian (ID) | None | -| Italian (IT) | Core Team, [khwadj](https://github.com/khwadj) | +| Italian (IT) | Core Maintainers, [khwadj](https://github.com/khwadj) | | Malay (MS) | [wanadri](https://github.com/wanadri) | | Norwegian (NB) | [channor] (https://github.com/channor) | | Polish (PL) | [meavric](https://github.com/meavric) | From 1e55b7c3aa0bdd1e0353513bdd30c3e05562a591 Mon Sep 17 00:00:00 2001 From: Alex Bierhance Date: Tue, 10 Dec 2024 22:10:17 +0100 Subject: [PATCH 13/15] Update core.php (#2123) --- resources/lang/php/sv/core.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/lang/php/sv/core.php b/resources/lang/php/sv/core.php index 002c64dfe..b3630fe7c 100644 --- a/resources/lang/php/sv/core.php +++ b/resources/lang/php/sv/core.php @@ -2,13 +2,13 @@ return [ 'All' => 'Alla', - 'All Columns' => 'Alla Columner', + 'All Columns' => 'Alla Kolumner', 'Applied Filters' => 'Valda filter', 'Applied Sorting' => 'Vald sortering', 'Bulk Actions' => 'Bulk Modifiering', 'Bulk Actions Confirm' => 'Är du säker?', 'Clear' => 'Rensa', - 'Columns' => 'Columner', + 'Columns' => 'Kolumner', 'Debugging Values' => 'Debug Värden', 'Deselect All' => 'Avmarkera alla', 'Done Reordering' => 'Omordning klart', From 0dffa95474ee9fec1bd975ef6d790910e189e2fb Mon Sep 17 00:00:00 2001 From: Edwin van de Pol Date: Wed, 11 Dec 2024 02:02:20 +0100 Subject: [PATCH 14/15] Optimized imports (#2124) --- src/Commands/MakeCommand.php | 1 - src/Traits/ComponentUtilities.php | 1 - src/Traits/Configuration/ColumnConfiguration.php | 2 -- src/Traits/Configuration/FooterConfiguration.php | 6 ++++-- .../SecondaryHeaderConfiguration.php | 6 ++++-- .../TableAttributeConfiguration.php | 16 +++++++++------- src/Traits/HasAllTraits.php | 2 +- src/Traits/Helpers/FilterHelpers.php | 1 - .../FilterMenuStylingConfiguration.php | 3 ++- src/Traits/Styling/HasFilterMenuStyling.php | 3 ++- .../Helpers/LoadingPlaceholderStylingHelpers.php | 2 -- src/Traits/Styling/Search/HasSearchInput.php | 2 -- src/Traits/WithColumnSelect.php | 1 - src/Traits/WithColumns.php | 1 - src/Traits/WithFooter.php | 5 +++-- src/Traits/WithReordering.php | 1 - src/Traits/WithSecondaryHeader.php | 5 +++-- src/Traits/WithSorting.php | 1 - src/Traits/WithTableAttributes.php | 15 +++++++-------- src/Views/Action.php | 2 +- src/Views/Columns/ColorColumn.php | 3 ++- src/Views/Columns/IconColumn.php | 3 ++- src/Views/Columns/LinkColumn.php | 2 +- src/Views/Columns/ViewComponentColumn.php | 1 - src/Views/Columns/WireLinkColumn.php | 2 +- src/Views/Filters/DateRangeFilter.php | 2 +- .../Filters/LivewireComponentArrayFilter.php | 3 +-- src/Views/Filters/LivewireComponentFilter.php | 1 - src/Views/Filters/MultiSelectDropdownFilter.php | 2 +- src/Views/Filters/MultiSelectFilter.php | 2 +- src/Views/Filters/SelectFilter.php | 2 +- .../Traits/Columns/HasDefaultStringValue.php | 4 ---- src/Views/Traits/Columns/HasVisibility.php | 2 -- src/Views/Traits/Columns/IsCollapsible.php | 4 ---- src/Views/Traits/Columns/IsSearchable.php | 4 ---- src/Views/Traits/Columns/IsSelectable.php | 4 ---- src/Views/Traits/Columns/IsSortable.php | 2 -- .../AggregateColumnConfiguration.php | 2 +- .../Configuration/ArrayColumnConfiguration.php | 2 -- .../Configuration/BooleanColumnConfiguration.php | 2 -- .../Configuration/ColorColumnConfiguration.php | 4 ++-- .../Traits/Configuration/FilterConfiguration.php | 2 -- .../Configuration/IconColumnConfiguration.php | 4 +++- src/Views/Traits/Core/HasActionCallback.php | 3 --- src/Views/Traits/Core/HasAttributes.php | 1 - src/Views/Traits/Core/HasCallback.php | 1 - src/Views/Traits/Core/HasConfig.php | 3 +-- src/Views/Traits/Core/HasConfirmation.php | 3 --- src/Views/Traits/Core/HasFooter.php | 2 +- src/Views/Traits/Core/HasIcon.php | 1 - src/Views/Traits/Core/HasLocationCallback.php | 3 --- src/Views/Traits/Core/HasSecondaryHeader.php | 2 +- src/Views/Traits/Core/HasTheme.php | 2 +- src/Views/Traits/Core/HasTitleCallback.php | 3 --- src/Views/Traits/Core/HasVisibility.php | 3 --- src/Views/Traits/Core/HasWireActions.php | 2 -- src/Views/Traits/Filters/HasConfig.php | 4 ---- src/Views/Traits/Filters/HasCustomPosition.php | 2 -- src/Views/Traits/Filters/HasOptions.php | 4 ---- src/Views/Traits/Filters/HasVisibility.php | 1 - src/Views/Traits/Filters/IsArrayFilter.php | 4 ---- src/Views/Traits/Filters/IsNumericFilter.php | 4 ---- src/Views/Traits/Filters/IsStringFilter.php | 4 ---- .../Traits/Helpers/AggregateColumnHelpers.php | 1 - .../Traits/Helpers/BooleanColumnHelpers.php | 2 -- src/Views/Traits/Helpers/ColorColumnHelpers.php | 1 - src/Views/Traits/Helpers/ColumnHelpers.php | 1 - src/Views/Traits/Helpers/IconColumnHelpers.php | 1 - src/Views/Traits/IsColumn.php | 2 +- src/Views/Traits/IsExternalArrayFilter.php | 2 +- src/Views/Traits/IsFilter.php | 2 +- 71 files changed, 60 insertions(+), 139 deletions(-) diff --git a/src/Commands/MakeCommand.php b/src/Commands/MakeCommand.php index 97120c800..bf06570ae 100644 --- a/src/Commands/MakeCommand.php +++ b/src/Commands/MakeCommand.php @@ -5,7 +5,6 @@ use Illuminate\Console\Command; use Illuminate\Contracts\Console\PromptsForMissingInput; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Collection; use Illuminate\Support\Facades\File; use Illuminate\Support\Str; use Livewire\Features\SupportConsoleCommands\Commands\ComponentParser; diff --git a/src/Traits/ComponentUtilities.php b/src/Traits/ComponentUtilities.php index a8aa3832e..89607fe66 100644 --- a/src/Traits/ComponentUtilities.php +++ b/src/Traits/ComponentUtilities.php @@ -3,7 +3,6 @@ namespace Rappasoft\LaravelLivewireTables\Traits; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Support\Str; use Livewire\Attributes\Locked; use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; use Rappasoft\LaravelLivewireTables\Traits\Configuration\ComponentConfiguration; diff --git a/src/Traits/Configuration/ColumnConfiguration.php b/src/Traits/Configuration/ColumnConfiguration.php index 29bfadabd..57de0b9f4 100644 --- a/src/Traits/Configuration/ColumnConfiguration.php +++ b/src/Traits/Configuration/ColumnConfiguration.php @@ -2,8 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Configuration; -use Rappasoft\LaravelLivewireTables\Views\Column; - trait ColumnConfiguration { public function setPrependedColumns(array $prependedColumns): void diff --git a/src/Traits/Configuration/FooterConfiguration.php b/src/Traits/Configuration/FooterConfiguration.php index b84193312..2a32b6fa3 100644 --- a/src/Traits/Configuration/FooterConfiguration.php +++ b/src/Traits/Configuration/FooterConfiguration.php @@ -2,6 +2,8 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Configuration; +use Closure; + trait FooterConfiguration { public function setFooterStatus(bool $status): self @@ -46,14 +48,14 @@ public function setUseHeaderAsFooterDisabled(): self return $this; } - public function setFooterTrAttributes(\Closure $callback): self + public function setFooterTrAttributes(Closure $callback): self { $this->footerTrAttributesCallback = $callback; return $this; } - public function setFooterTdAttributes(\Closure $callback): self + public function setFooterTdAttributes(Closure $callback): self { $this->footerTdAttributesCallback = $callback; diff --git a/src/Traits/Configuration/SecondaryHeaderConfiguration.php b/src/Traits/Configuration/SecondaryHeaderConfiguration.php index 62acb5992..42ce2f574 100644 --- a/src/Traits/Configuration/SecondaryHeaderConfiguration.php +++ b/src/Traits/Configuration/SecondaryHeaderConfiguration.php @@ -2,6 +2,8 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Configuration; +use Closure; + trait SecondaryHeaderConfiguration { public function setSecondaryHeaderStatus(bool $status): self @@ -25,14 +27,14 @@ public function setSecondaryHeaderDisabled(): self return $this; } - public function setSecondaryHeaderTrAttributes(\Closure $callback): self + public function setSecondaryHeaderTrAttributes(Closure $callback): self { $this->secondaryHeaderTrAttributesCallback = $callback; return $this; } - public function setSecondaryHeaderTdAttributes(\Closure $callback): self + public function setSecondaryHeaderTdAttributes(Closure $callback): self { $this->secondaryHeaderTdAttributesCallback = $callback; diff --git a/src/Traits/Configuration/TableAttributeConfiguration.php b/src/Traits/Configuration/TableAttributeConfiguration.php index 2053d50d7..a675d3fc3 100644 --- a/src/Traits/Configuration/TableAttributeConfiguration.php +++ b/src/Traits/Configuration/TableAttributeConfiguration.php @@ -2,6 +2,8 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Configuration; +use Closure; + trait TableAttributeConfiguration { /** @@ -68,7 +70,7 @@ public function setTbodyAttributes(array $attributes = []): self /** * Set a list of attributes to override on the th elements */ - public function setThAttributes(\Closure $callback): self + public function setThAttributes(Closure $callback): self { $this->thAttributesCallback = $callback; @@ -78,7 +80,7 @@ public function setThAttributes(\Closure $callback): self /** * Set a list of attributes to override on the th sort button elements */ - public function setThSortButtonAttributes(\Closure $callback): self + public function setThSortButtonAttributes(Closure $callback): self { $this->thSortButtonAttributesCallback = $callback; @@ -88,7 +90,7 @@ public function setThSortButtonAttributes(\Closure $callback): self /** * Set a list of attributes to override on the th sort icon elements */ - public function setThSortIconAttributes(\Closure $callback): self + public function setThSortIconAttributes(Closure $callback): self { $this->thSortIconAttributesCallback = $callback; @@ -98,7 +100,7 @@ public function setThSortIconAttributes(\Closure $callback): self /** * Set a list of attributes to override on the td elements */ - public function setTrAttributes(\Closure $callback): self + public function setTrAttributes(Closure $callback): self { $this->trAttributesCallback = $callback; @@ -108,21 +110,21 @@ public function setTrAttributes(\Closure $callback): self /** * Set a list of attributes to override on the td elements */ - public function setTdAttributes(\Closure $callback): self + public function setTdAttributes(Closure $callback): self { $this->tdAttributesCallback = $callback; return $this; } - public function setTableRowUrl(\Closure $callback): self + public function setTableRowUrl(Closure $callback): self { $this->trUrlCallback = $callback; return $this; } - public function setTableRowUrlTarget(\Closure $callback): self + public function setTableRowUrlTarget(Closure $callback): self { $this->trUrlTargetCallback = $callback; diff --git a/src/Traits/HasAllTraits.php b/src/Traits/HasAllTraits.php index cc80420e0..ebbe7a815 100644 --- a/src/Traits/HasAllTraits.php +++ b/src/Traits/HasAllTraits.php @@ -2,7 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Traits; -use Rappasoft\LaravelLivewireTables\Traits\Core\{HasCustomAttributes,HasLocalisations}; +use Rappasoft\LaravelLivewireTables\Traits\Core\{HasCustomAttributes, HasLocalisations}; use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasTheme; trait HasAllTraits diff --git a/src/Traits/Helpers/FilterHelpers.php b/src/Traits/Helpers/FilterHelpers.php index 2ee7ed3db..a9265c6ec 100644 --- a/src/Traits/Helpers/FilterHelpers.php +++ b/src/Traits/Helpers/FilterHelpers.php @@ -2,7 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Helpers; -use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Livewire\Attributes\Computed; use Livewire\Attributes\On; diff --git a/src/Traits/Styling/Configuration/FilterMenuStylingConfiguration.php b/src/Traits/Styling/Configuration/FilterMenuStylingConfiguration.php index 4a68532d5..9a7a140b5 100644 --- a/src/Traits/Styling/Configuration/FilterMenuStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/FilterMenuStylingConfiguration.php @@ -2,6 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration; +use Closure; use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; trait FilterMenuStylingConfiguration @@ -29,7 +30,7 @@ public function setFilterSlidedownWrapperAttributes(array $filterSlidedownWrappe /** * Set a list of attributes to override on the th sort button elements */ - public function setFilterSlidedownRowAttributes(\Closure $callback): self + public function setFilterSlidedownRowAttributes(Closure $callback): self { $this->filterSlidedownRowCallback = $callback; diff --git a/src/Traits/Styling/HasFilterMenuStyling.php b/src/Traits/Styling/HasFilterMenuStyling.php index 03a6737b4..397409743 100644 --- a/src/Traits/Styling/HasFilterMenuStyling.php +++ b/src/Traits/Styling/HasFilterMenuStyling.php @@ -2,6 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Styling; +use Closure; use Livewire\Attributes\Locked; use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\FilterMenuStylingConfiguration; use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\FilterMenuStylingHelpers; @@ -21,5 +22,5 @@ trait HasFilterMenuStyling protected array $filterSlidedownWrapperAttributes = ['class' => '', 'default-colors' => true, 'default-styling' => true]; - protected ?\Closure $filterSlidedownRowCallback; + protected ?Closure $filterSlidedownRowCallback; } diff --git a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php index ef115641f..9cce416dd 100644 --- a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php +++ b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php @@ -2,8 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; -use Livewire\Attributes\Computed; - trait LoadingPlaceholderStylingHelpers { public function getLoadingPlaceholderAttributes(): array diff --git a/src/Traits/Styling/Search/HasSearchInput.php b/src/Traits/Styling/Search/HasSearchInput.php index f937f5ef5..f4134be65 100644 --- a/src/Traits/Styling/Search/HasSearchInput.php +++ b/src/Traits/Styling/Search/HasSearchInput.php @@ -2,8 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Search; -use Livewire\Attributes\Computed; - trait HasSearchInput { protected array $searchFieldAttributes = []; diff --git a/src/Traits/WithColumnSelect.php b/src/Traits/WithColumnSelect.php index 704d1bea5..d398967cc 100644 --- a/src/Traits/WithColumnSelect.php +++ b/src/Traits/WithColumnSelect.php @@ -6,7 +6,6 @@ use Rappasoft\LaravelLivewireTables\Events\ColumnsSelected; use Rappasoft\LaravelLivewireTables\Traits\Configuration\ColumnSelectConfiguration; use Rappasoft\LaravelLivewireTables\Traits\Helpers\ColumnSelectHelpers; -use Rappasoft\LaravelLivewireTables\Views\Column; trait WithColumnSelect { diff --git a/src/Traits/WithColumns.php b/src/Traits/WithColumns.php index 798ec205a..1e565ffe7 100644 --- a/src/Traits/WithColumns.php +++ b/src/Traits/WithColumns.php @@ -3,7 +3,6 @@ namespace Rappasoft\LaravelLivewireTables\Traits; use Illuminate\Support\Collection; -use Livewire\Attributes\Locked; use Rappasoft\LaravelLivewireTables\Exceptions\NoColumnsException; use Rappasoft\LaravelLivewireTables\Traits\Configuration\ColumnConfiguration; use Rappasoft\LaravelLivewireTables\Traits\Helpers\ColumnHelpers; diff --git a/src/Traits/WithFooter.php b/src/Traits/WithFooter.php index 8412d10fe..8f163dc93 100644 --- a/src/Traits/WithFooter.php +++ b/src/Traits/WithFooter.php @@ -2,6 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Traits; +use Closure; use Rappasoft\LaravelLivewireTables\Traits\Configuration\FooterConfiguration; use Rappasoft\LaravelLivewireTables\Traits\Helpers\FooterHelpers; @@ -16,9 +17,9 @@ trait WithFooter protected bool $columnsWithFooter = false; - protected ?\Closure $footerTrAttributesCallback; + protected ?Closure $footerTrAttributesCallback; - protected ?\Closure $footerTdAttributesCallback; + protected ?Closure $footerTdAttributesCallback; public function setupFooter(): void { diff --git a/src/Traits/WithReordering.php b/src/Traits/WithReordering.php index 2251fe2c4..006e7a715 100644 --- a/src/Traits/WithReordering.php +++ b/src/Traits/WithReordering.php @@ -2,7 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Traits; -use Livewire\Attributes\Locked; use Rappasoft\LaravelLivewireTables\Traits\Configuration\ReorderingConfiguration; use Rappasoft\LaravelLivewireTables\Traits\Helpers\ReorderingHelpers; diff --git a/src/Traits/WithSecondaryHeader.php b/src/Traits/WithSecondaryHeader.php index 30ab4a797..d3fe2f459 100644 --- a/src/Traits/WithSecondaryHeader.php +++ b/src/Traits/WithSecondaryHeader.php @@ -2,6 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Traits; +use Closure; use Rappasoft\LaravelLivewireTables\Traits\Configuration\SecondaryHeaderConfiguration; use Rappasoft\LaravelLivewireTables\Traits\Helpers\SecondaryHeaderHelpers; @@ -14,9 +15,9 @@ trait WithSecondaryHeader protected bool $columnsWithSecondaryHeader = false; - protected ?\Closure $secondaryHeaderTrAttributesCallback; + protected ?Closure $secondaryHeaderTrAttributesCallback; - protected ?\Closure $secondaryHeaderTdAttributesCallback; + protected ?Closure $secondaryHeaderTdAttributesCallback; public function bootedWithSecondaryHeader(): void { diff --git a/src/Traits/WithSorting.php b/src/Traits/WithSorting.php index 1ed30366e..67054e8a8 100644 --- a/src/Traits/WithSorting.php +++ b/src/Traits/WithSorting.php @@ -4,7 +4,6 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Collection; -use Livewire\Attributes\Locked; use Rappasoft\LaravelLivewireTables\Traits\Configuration\SortingConfiguration; use Rappasoft\LaravelLivewireTables\Traits\Core\QueryStrings\HasQueryStringForSort; use Rappasoft\LaravelLivewireTables\Traits\Helpers\SortingHelpers; diff --git a/src/Traits/WithTableAttributes.php b/src/Traits/WithTableAttributes.php index a0ce12c44..914783c83 100644 --- a/src/Traits/WithTableAttributes.php +++ b/src/Traits/WithTableAttributes.php @@ -3,7 +3,6 @@ namespace Rappasoft\LaravelLivewireTables\Traits; use Closure; -use Livewire\Attributes\On; use Rappasoft\LaravelLivewireTables\Traits\Configuration\TableAttributeConfiguration; use Rappasoft\LaravelLivewireTables\Traits\Helpers\TableAttributeHelpers; @@ -22,19 +21,19 @@ trait WithTableAttributes protected array $tbodyAttributes = []; - protected ?\Closure $thAttributesCallback; + protected ?Closure $thAttributesCallback; - protected ?\Closure $thSortButtonAttributesCallback; + protected ?Closure $thSortButtonAttributesCallback; - protected ?\Closure $thSortIconAttributesCallback; + protected ?Closure $thSortIconAttributesCallback; - protected ?\Closure $trAttributesCallback; + protected ?Closure $trAttributesCallback; - protected ?\Closure $tdAttributesCallback; + protected ?Closure $tdAttributesCallback; - protected ?\Closure $trUrlCallback; + protected ?Closure $trUrlCallback; - protected ?\Closure $trUrlTargetCallback; + protected ?Closure $trUrlTargetCallback; public bool $shouldBeDisplayed = true; } diff --git a/src/Views/Action.php b/src/Views/Action.php index 1c2975a30..6775a75c3 100644 --- a/src/Views/Action.php +++ b/src/Views/Action.php @@ -2,7 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Views; -use Illuminate\View\{Component,ComponentAttributeBag}; +use Illuminate\View\Component; use Rappasoft\LaravelLivewireTables\Traits\Core\HasLocalisations; use Rappasoft\LaravelLivewireTables\Views\Traits\Actions\{HasActionAttributes, HasRoute}; use Rappasoft\LaravelLivewireTables\Views\Traits\Columns\HasVisibility; diff --git a/src/Views/Columns/ColorColumn.php b/src/Views/Columns/ColorColumn.php index b5815d7d8..21e9100cd 100644 --- a/src/Views/Columns/ColorColumn.php +++ b/src/Views/Columns/ColorColumn.php @@ -2,6 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Views\Columns; +use Closure; use Illuminate\Database\Eloquent\Model; use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; use Rappasoft\LaravelLivewireTables\Views\Column; @@ -17,7 +18,7 @@ class ColorColumn extends Column ColorColumnHelpers; use HasDefaultStringValue; - public ?\Closure $colorCallback; + public ?Closure $colorCallback; protected string $view = 'livewire-tables::includes.columns.color'; diff --git a/src/Views/Columns/IconColumn.php b/src/Views/Columns/IconColumn.php index ec1238081..3dd264b2c 100644 --- a/src/Views/Columns/IconColumn.php +++ b/src/Views/Columns/IconColumn.php @@ -2,6 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Views\Columns; +use Closure; use Illuminate\Database\Eloquent\Model; use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; use Rappasoft\LaravelLivewireTables\Views\Column; @@ -15,7 +16,7 @@ class IconColumn extends Column use IconColumnConfiguration, IconColumnHelpers; - public ?\Closure $iconCallback; + public ?Closure $iconCallback; protected string $view = 'livewire-tables::includes.columns.icon'; diff --git a/src/Views/Columns/LinkColumn.php b/src/Views/Columns/LinkColumn.php index 9d0835935..0e58b646a 100644 --- a/src/Views/Columns/LinkColumn.php +++ b/src/Views/Columns/LinkColumn.php @@ -6,7 +6,7 @@ use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; use Rappasoft\LaravelLivewireTables\Views\Column; use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\LinkColumnConfiguration; -use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasLocationCallback,HasTitleCallback}; +use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasLocationCallback, HasTitleCallback}; use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\LinkColumnHelpers; class LinkColumn extends Column diff --git a/src/Views/Columns/ViewComponentColumn.php b/src/Views/Columns/ViewComponentColumn.php index b4f6d3a8c..17b012130 100644 --- a/src/Views/Columns/ViewComponentColumn.php +++ b/src/Views/Columns/ViewComponentColumn.php @@ -4,7 +4,6 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Support\HtmlString; -use Illuminate\View\ComponentAttributeBag; use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; use Rappasoft\LaravelLivewireTables\Views\Column; use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\ViewComponentColumnConfiguration; diff --git a/src/Views/Columns/WireLinkColumn.php b/src/Views/Columns/WireLinkColumn.php index 26adaf973..6d9ba9a0c 100644 --- a/src/Views/Columns/WireLinkColumn.php +++ b/src/Views/Columns/WireLinkColumn.php @@ -6,7 +6,7 @@ use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; use Rappasoft\LaravelLivewireTables\Views\Column; use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\WireLinkColumnConfiguration; -use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasActionCallback,HasConfirmation, HasTitleCallback}; +use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasActionCallback, HasConfirmation, HasTitleCallback}; use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\WireLinkColumnHelpers; class WireLinkColumn extends Column diff --git a/src/Views/Filters/DateRangeFilter.php b/src/Views/Filters/DateRangeFilter.php index 5884c10d6..4fe6fb67c 100644 --- a/src/Views/Filters/DateRangeFilter.php +++ b/src/Views/Filters/DateRangeFilter.php @@ -6,7 +6,7 @@ use Illuminate\Support\Facades\Validator; use Rappasoft\LaravelLivewireTables\Views\Filter; use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasWireables; -use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{HandlesDates, HasConfig,HasOptions}; +use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{HandlesDates, HasConfig, HasOptions}; class DateRangeFilter extends Filter { diff --git a/src/Views/Filters/LivewireComponentArrayFilter.php b/src/Views/Filters/LivewireComponentArrayFilter.php index ad995b3dc..f4505750c 100644 --- a/src/Views/Filters/LivewireComponentArrayFilter.php +++ b/src/Views/Filters/LivewireComponentArrayFilter.php @@ -2,10 +2,9 @@ namespace Rappasoft\LaravelLivewireTables\Views\Filters; -use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; use Rappasoft\LaravelLivewireTables\Views\Filter; use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasWireables; -use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{HasOptions,IsArrayFilter, IsLivewireComponentFilter}; +use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{HasOptions, IsArrayFilter, IsLivewireComponentFilter}; class LivewireComponentArrayFilter extends Filter { diff --git a/src/Views/Filters/LivewireComponentFilter.php b/src/Views/Filters/LivewireComponentFilter.php index 8605c2e99..82300635a 100644 --- a/src/Views/Filters/LivewireComponentFilter.php +++ b/src/Views/Filters/LivewireComponentFilter.php @@ -2,7 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Filters; -use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; use Rappasoft\LaravelLivewireTables\Views\Filter; use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasWireables; use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\IsLivewireComponentFilter; diff --git a/src/Views/Filters/MultiSelectDropdownFilter.php b/src/Views/Filters/MultiSelectDropdownFilter.php index be9be0a9f..5e8ed566f 100644 --- a/src/Views/Filters/MultiSelectDropdownFilter.php +++ b/src/Views/Filters/MultiSelectDropdownFilter.php @@ -5,7 +5,7 @@ use Illuminate\Support\Collection; use Rappasoft\LaravelLivewireTables\Views\Filter; use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasWireables; -use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{HasOptions,IsArrayFilter}; +use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{HasOptions, IsArrayFilter}; class MultiSelectDropdownFilter extends Filter { diff --git a/src/Views/Filters/MultiSelectFilter.php b/src/Views/Filters/MultiSelectFilter.php index 558bc0d70..c271354aa 100644 --- a/src/Views/Filters/MultiSelectFilter.php +++ b/src/Views/Filters/MultiSelectFilter.php @@ -4,7 +4,7 @@ use Rappasoft\LaravelLivewireTables\Views\Filter; use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasWireables; -use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{HasOptions,IsArrayFilter}; +use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{HasOptions, IsArrayFilter}; class MultiSelectFilter extends Filter { diff --git a/src/Views/Filters/SelectFilter.php b/src/Views/Filters/SelectFilter.php index 22c7022d3..dc564fd22 100644 --- a/src/Views/Filters/SelectFilter.php +++ b/src/Views/Filters/SelectFilter.php @@ -5,7 +5,7 @@ use Illuminate\Support\Collection; use Rappasoft\LaravelLivewireTables\Views\Filter; use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasWireables; -use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{HasOptions,IsStringFilter}; +use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{HasOptions, IsStringFilter}; class SelectFilter extends Filter { diff --git a/src/Views/Traits/Columns/HasDefaultStringValue.php b/src/Views/Traits/Columns/HasDefaultStringValue.php index fec0bf051..e40ffe054 100644 --- a/src/Views/Traits/Columns/HasDefaultStringValue.php +++ b/src/Views/Traits/Columns/HasDefaultStringValue.php @@ -2,10 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Columns; -use Closure; -use Illuminate\View\ComponentAttributeBag; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait HasDefaultStringValue { public string $defaultValue = ''; diff --git a/src/Views/Traits/Columns/HasVisibility.php b/src/Views/Traits/Columns/HasVisibility.php index 71217d7e8..b5397dd9c 100644 --- a/src/Views/Traits/Columns/HasVisibility.php +++ b/src/Views/Traits/Columns/HasVisibility.php @@ -2,8 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Columns; -use Rappasoft\LaravelLivewireTables\Views\Column; - trait HasVisibility { protected bool $hidden = false; diff --git a/src/Views/Traits/Columns/IsCollapsible.php b/src/Views/Traits/Columns/IsCollapsible.php index 143c48bea..2dc3439f2 100644 --- a/src/Views/Traits/Columns/IsCollapsible.php +++ b/src/Views/Traits/Columns/IsCollapsible.php @@ -2,10 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Columns; -use Closure; -use Illuminate\View\ComponentAttributeBag; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait IsCollapsible { protected bool $collapseOnMobile = false; diff --git a/src/Views/Traits/Columns/IsSearchable.php b/src/Views/Traits/Columns/IsSearchable.php index 33ebe2614..69801c16c 100644 --- a/src/Views/Traits/Columns/IsSearchable.php +++ b/src/Views/Traits/Columns/IsSearchable.php @@ -2,10 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Columns; -use Closure; -use Rappasoft\LaravelLivewireTables\DataTableComponent; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait IsSearchable { protected bool $searchable = false; diff --git a/src/Views/Traits/Columns/IsSelectable.php b/src/Views/Traits/Columns/IsSelectable.php index 9824fef9b..7b7d37067 100644 --- a/src/Views/Traits/Columns/IsSelectable.php +++ b/src/Views/Traits/Columns/IsSelectable.php @@ -2,10 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Columns; -use Closure; -use Rappasoft\LaravelLivewireTables\DataTableComponent; -use Rappasoft\LaravelLivewireTables\Views\Column; - trait IsSelectable { protected bool $selectable = true; diff --git a/src/Views/Traits/Columns/IsSortable.php b/src/Views/Traits/Columns/IsSortable.php index a95094124..2dfdf54d5 100644 --- a/src/Views/Traits/Columns/IsSortable.php +++ b/src/Views/Traits/Columns/IsSortable.php @@ -2,9 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Columns; -use Closure; use Rappasoft\LaravelLivewireTables\DataTableComponent; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; trait IsSortable { diff --git a/src/Views/Traits/Configuration/AggregateColumnConfiguration.php b/src/Views/Traits/Configuration/AggregateColumnConfiguration.php index 9e12611dd..729be2745 100644 --- a/src/Views/Traits/Configuration/AggregateColumnConfiguration.php +++ b/src/Views/Traits/Configuration/AggregateColumnConfiguration.php @@ -2,7 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Configuration; -use Illuminate\Database\Eloquent\{Builder, Model}; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Str; use Rappasoft\LaravelLivewireTables\Views\Column; diff --git a/src/Views/Traits/Configuration/ArrayColumnConfiguration.php b/src/Views/Traits/Configuration/ArrayColumnConfiguration.php index c0f7657b7..028b30aa7 100644 --- a/src/Views/Traits/Configuration/ArrayColumnConfiguration.php +++ b/src/Views/Traits/Configuration/ArrayColumnConfiguration.php @@ -2,8 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Configuration; -use Closure; - trait ArrayColumnConfiguration { public function separator(string $value): self diff --git a/src/Views/Traits/Configuration/BooleanColumnConfiguration.php b/src/Views/Traits/Configuration/BooleanColumnConfiguration.php index 68e98880a..68261622c 100644 --- a/src/Views/Traits/Configuration/BooleanColumnConfiguration.php +++ b/src/Views/Traits/Configuration/BooleanColumnConfiguration.php @@ -2,8 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Configuration; -use Closure; - trait BooleanColumnConfiguration { public function setSuccessValue(bool $value): self diff --git a/src/Views/Traits/Configuration/ColorColumnConfiguration.php b/src/Views/Traits/Configuration/ColorColumnConfiguration.php index 1e0671b6a..8821c4480 100644 --- a/src/Views/Traits/Configuration/ColorColumnConfiguration.php +++ b/src/Views/Traits/Configuration/ColorColumnConfiguration.php @@ -2,11 +2,11 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Configuration; -use Rappasoft\LaravelLivewireTables\Views\Traits\Columns; +use Closure; trait ColorColumnConfiguration { - public function color(\Closure $callback): self + public function color(Closure $callback): self { $this->colorCallback = $callback; diff --git a/src/Views/Traits/Configuration/FilterConfiguration.php b/src/Views/Traits/Configuration/FilterConfiguration.php index 88b769599..123dda5f0 100644 --- a/src/Views/Traits/Configuration/FilterConfiguration.php +++ b/src/Views/Traits/Configuration/FilterConfiguration.php @@ -2,8 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Configuration; -use Rappasoft\LaravelLivewireTables\Views\Filter; - trait FilterConfiguration { public function setFilterPillTitle(string $title): self diff --git a/src/Views/Traits/Configuration/IconColumnConfiguration.php b/src/Views/Traits/Configuration/IconColumnConfiguration.php index f52bc9e2e..f938dac4b 100644 --- a/src/Views/Traits/Configuration/IconColumnConfiguration.php +++ b/src/Views/Traits/Configuration/IconColumnConfiguration.php @@ -2,9 +2,11 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Configuration; +use Closure; + trait IconColumnConfiguration { - public function setIcon(\Closure $callback): self + public function setIcon(Closure $callback): self { $this->iconCallback = $callback; diff --git a/src/Views/Traits/Core/HasActionCallback.php b/src/Views/Traits/Core/HasActionCallback.php index 4ffc70146..aee47ed27 100644 --- a/src/Views/Traits/Core/HasActionCallback.php +++ b/src/Views/Traits/Core/HasActionCallback.php @@ -2,9 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Core; -use Closure; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait HasActionCallback { protected mixed $actionCallback = null; diff --git a/src/Views/Traits/Core/HasAttributes.php b/src/Views/Traits/Core/HasAttributes.php index 5ddd4653b..83a1a0388 100644 --- a/src/Views/Traits/Core/HasAttributes.php +++ b/src/Views/Traits/Core/HasAttributes.php @@ -5,7 +5,6 @@ use Closure; use Illuminate\Database\Eloquent\Model; use Illuminate\View\ComponentAttributeBag; -use Rappasoft\LaravelLivewireTables\Views\{Action, Column,Filter}; trait HasAttributes { diff --git a/src/Views/Traits/Core/HasCallback.php b/src/Views/Traits/Core/HasCallback.php index c022ca04a..ad4b20425 100644 --- a/src/Views/Traits/Core/HasCallback.php +++ b/src/Views/Traits/Core/HasCallback.php @@ -3,7 +3,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Core; use Closure; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; trait HasCallback { diff --git a/src/Views/Traits/Core/HasConfig.php b/src/Views/Traits/Core/HasConfig.php index 6c8a66676..902bab75f 100644 --- a/src/Views/Traits/Core/HasConfig.php +++ b/src/Views/Traits/Core/HasConfig.php @@ -2,8 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Core; -use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; +use Rappasoft\LaravelLivewireTables\Views\Filter; trait HasConfig { diff --git a/src/Views/Traits/Core/HasConfirmation.php b/src/Views/Traits/Core/HasConfirmation.php index 9a8597947..3b727cfb4 100644 --- a/src/Views/Traits/Core/HasConfirmation.php +++ b/src/Views/Traits/Core/HasConfirmation.php @@ -2,9 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Core; -use Closure; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait HasConfirmation { protected ?string $confirmMessage; diff --git a/src/Views/Traits/Core/HasFooter.php b/src/Views/Traits/Core/HasFooter.php index 54078f188..967cdbde0 100644 --- a/src/Views/Traits/Core/HasFooter.php +++ b/src/Views/Traits/Core/HasFooter.php @@ -4,7 +4,7 @@ use Illuminate\Support\HtmlString; use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; +use Rappasoft\LaravelLivewireTables\Views\Filter; trait HasFooter { diff --git a/src/Views/Traits/Core/HasIcon.php b/src/Views/Traits/Core/HasIcon.php index e8230c184..1e432b74d 100644 --- a/src/Views/Traits/Core/HasIcon.php +++ b/src/Views/Traits/Core/HasIcon.php @@ -3,7 +3,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Core; use Illuminate\View\ComponentAttributeBag; -use Livewire\Attributes\Computed; trait HasIcon { diff --git a/src/Views/Traits/Core/HasLocationCallback.php b/src/Views/Traits/Core/HasLocationCallback.php index e25fc2ce8..296d216ed 100644 --- a/src/Views/Traits/Core/HasLocationCallback.php +++ b/src/Views/Traits/Core/HasLocationCallback.php @@ -2,9 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Core; -use Closure; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait HasLocationCallback { protected mixed $locationCallback = null; diff --git a/src/Views/Traits/Core/HasSecondaryHeader.php b/src/Views/Traits/Core/HasSecondaryHeader.php index 666a9d312..3c47fb289 100644 --- a/src/Views/Traits/Core/HasSecondaryHeader.php +++ b/src/Views/Traits/Core/HasSecondaryHeader.php @@ -4,7 +4,7 @@ use Illuminate\Support\HtmlString; use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; +use Rappasoft\LaravelLivewireTables\Views\Filter; trait HasSecondaryHeader { diff --git a/src/Views/Traits/Core/HasTheme.php b/src/Views/Traits/Core/HasTheme.php index 5d229879a..d19253e9b 100644 --- a/src/Views/Traits/Core/HasTheme.php +++ b/src/Views/Traits/Core/HasTheme.php @@ -2,7 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Core; -use Livewire\Attributes\{Computed,Locked}; +use Livewire\Attributes\{Computed, Locked}; trait HasTheme { diff --git a/src/Views/Traits/Core/HasTitleCallback.php b/src/Views/Traits/Core/HasTitleCallback.php index ee096b9b1..113ccc144 100644 --- a/src/Views/Traits/Core/HasTitleCallback.php +++ b/src/Views/Traits/Core/HasTitleCallback.php @@ -2,9 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Core; -use Closure; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait HasTitleCallback { protected mixed $titleCallback = null; diff --git a/src/Views/Traits/Core/HasVisibility.php b/src/Views/Traits/Core/HasVisibility.php index 91b0ace58..7ec1d70e6 100644 --- a/src/Views/Traits/Core/HasVisibility.php +++ b/src/Views/Traits/Core/HasVisibility.php @@ -2,9 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Core; -use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait HasVisibility { protected bool $hiddenFromMenus = false; diff --git a/src/Views/Traits/Core/HasWireActions.php b/src/Views/Traits/Core/HasWireActions.php index 04d96a050..7c7942a4d 100644 --- a/src/Views/Traits/Core/HasWireActions.php +++ b/src/Views/Traits/Core/HasWireActions.php @@ -2,8 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Core; -use Illuminate\Database\Eloquent\Model; - trait HasWireActions { protected bool $shouldWireNavigate = false; diff --git a/src/Views/Traits/Filters/HasConfig.php b/src/Views/Traits/Filters/HasConfig.php index b14d59312..60755c155 100644 --- a/src/Views/Traits/Filters/HasConfig.php +++ b/src/Views/Traits/Filters/HasConfig.php @@ -2,10 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Filters; -use Closure; -use Illuminate\View\ComponentAttributeBag; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait HasConfig { public function config(array $config = []): self diff --git a/src/Views/Traits/Filters/HasCustomPosition.php b/src/Views/Traits/Filters/HasCustomPosition.php index b80b4bb2c..443baf749 100644 --- a/src/Views/Traits/Filters/HasCustomPosition.php +++ b/src/Views/Traits/Filters/HasCustomPosition.php @@ -2,8 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Filters; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait HasCustomPosition { public ?string $filterPosition = null; diff --git a/src/Views/Traits/Filters/HasOptions.php b/src/Views/Traits/Filters/HasOptions.php index a8e39a363..059c37b8c 100644 --- a/src/Views/Traits/Filters/HasOptions.php +++ b/src/Views/Traits/Filters/HasOptions.php @@ -2,10 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Filters; -use Closure; -use Illuminate\View\ComponentAttributeBag; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait HasOptions { public array $options = []; diff --git a/src/Views/Traits/Filters/HasVisibility.php b/src/Views/Traits/Filters/HasVisibility.php index b6d65fcff..13631c270 100644 --- a/src/Views/Traits/Filters/HasVisibility.php +++ b/src/Views/Traits/Filters/HasVisibility.php @@ -3,7 +3,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Filters; use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasVisibility as HasCoreVisibility; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; trait HasVisibility { diff --git a/src/Views/Traits/Filters/IsArrayFilter.php b/src/Views/Traits/Filters/IsArrayFilter.php index 5238d71d3..cf66f4804 100644 --- a/src/Views/Traits/Filters/IsArrayFilter.php +++ b/src/Views/Traits/Filters/IsArrayFilter.php @@ -2,10 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Filters; -use Closure; -use Illuminate\View\ComponentAttributeBag; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait IsArrayFilter { public string $pillsSeparator = ', '; diff --git a/src/Views/Traits/Filters/IsNumericFilter.php b/src/Views/Traits/Filters/IsNumericFilter.php index 602b8fa96..6ce4a6d28 100644 --- a/src/Views/Traits/Filters/IsNumericFilter.php +++ b/src/Views/Traits/Filters/IsNumericFilter.php @@ -2,10 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Filters; -use Closure; -use Illuminate\View\ComponentAttributeBag; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait IsNumericFilter { public function isEmpty(float|int|string|array|null $value): bool diff --git a/src/Views/Traits/Filters/IsStringFilter.php b/src/Views/Traits/Filters/IsStringFilter.php index 440dc26e1..2c505bad9 100644 --- a/src/Views/Traits/Filters/IsStringFilter.php +++ b/src/Views/Traits/Filters/IsStringFilter.php @@ -2,10 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Filters; -use Closure; -use Illuminate\View\ComponentAttributeBag; -use Rappasoft\LaravelLivewireTables\Views\{Column,Filter}; - trait IsStringFilter { public function isEmpty(?string $value): bool diff --git a/src/Views/Traits/Helpers/AggregateColumnHelpers.php b/src/Views/Traits/Helpers/AggregateColumnHelpers.php index 1748b8091..5ea2d7690 100644 --- a/src/Views/Traits/Helpers/AggregateColumnHelpers.php +++ b/src/Views/Traits/Helpers/AggregateColumnHelpers.php @@ -4,7 +4,6 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Support\HtmlString; -use Illuminate\View\ComponentAttributeBag; use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; trait AggregateColumnHelpers diff --git a/src/Views/Traits/Helpers/BooleanColumnHelpers.php b/src/Views/Traits/Helpers/BooleanColumnHelpers.php index ae8bd33fb..200505c1d 100644 --- a/src/Views/Traits/Helpers/BooleanColumnHelpers.php +++ b/src/Views/Traits/Helpers/BooleanColumnHelpers.php @@ -2,8 +2,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Helpers; -use Closure; - trait BooleanColumnHelpers { public function getSuccessValue(): bool diff --git a/src/Views/Traits/Helpers/ColorColumnHelpers.php b/src/Views/Traits/Helpers/ColorColumnHelpers.php index 3f46b9085..32296d13a 100644 --- a/src/Views/Traits/Helpers/ColorColumnHelpers.php +++ b/src/Views/Traits/Helpers/ColorColumnHelpers.php @@ -3,7 +3,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Helpers; use Illuminate\Database\Eloquent\Model; -use Illuminate\View\ComponentAttributeBag; trait ColorColumnHelpers { diff --git a/src/Views/Traits/Helpers/ColumnHelpers.php b/src/Views/Traits/Helpers/ColumnHelpers.php index 164de98da..3908f678b 100644 --- a/src/Views/Traits/Helpers/ColumnHelpers.php +++ b/src/Views/Traits/Helpers/ColumnHelpers.php @@ -9,7 +9,6 @@ use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; use Rappasoft\LaravelLivewireTables\Views\Column; use Rappasoft\LaravelLivewireTables\Views\Columns\LinkColumn; -use Rappasoft\LaravelLivewireTables\Views\Filter; trait ColumnHelpers { diff --git a/src/Views/Traits/Helpers/IconColumnHelpers.php b/src/Views/Traits/Helpers/IconColumnHelpers.php index ceb8f9439..0b9075ed8 100644 --- a/src/Views/Traits/Helpers/IconColumnHelpers.php +++ b/src/Views/Traits/Helpers/IconColumnHelpers.php @@ -3,7 +3,6 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits\Helpers; use Illuminate\Database\Eloquent\Model; -use Illuminate\View\ComponentAttributeBag; use Rappasoft\LaravelLivewireTables\Views\Traits\Columns\HasDefaultStringValue; trait IconColumnHelpers diff --git a/src/Views/Traits/IsColumn.php b/src/Views/Traits/IsColumn.php index d36b3e06d..31c873071 100644 --- a/src/Views/Traits/IsColumn.php +++ b/src/Views/Traits/IsColumn.php @@ -6,7 +6,7 @@ use Rappasoft\LaravelLivewireTables\Traits\Core\HasLocalisations; use Rappasoft\LaravelLivewireTables\Views\Traits\Columns\{HasColumnView, HasVisibility, IsCollapsible, IsSearchable, IsSelectable, IsSortable}; use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\ColumnConfiguration; -use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasAttributes,HasFooter,HasLabelAttributes,HasSecondaryHeader,HasTheme}; +use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasAttributes, HasFooter, HasLabelAttributes, HasSecondaryHeader, HasTheme}; use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\{ColumnHelpers,RelationshipHelpers}; trait IsColumn diff --git a/src/Views/Traits/IsExternalArrayFilter.php b/src/Views/Traits/IsExternalArrayFilter.php index 480d36e82..15feb3bf4 100644 --- a/src/Views/Traits/IsExternalArrayFilter.php +++ b/src/Views/Traits/IsExternalArrayFilter.php @@ -2,7 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Views\Traits; -use Livewire\Attributes\{Modelable,On,Renderless}; +use Livewire\Attributes\{Modelable, On, Renderless}; trait IsExternalArrayFilter { diff --git a/src/Views/Traits/IsFilter.php b/src/Views/Traits/IsFilter.php index 491b685e5..9e5a7b47b 100644 --- a/src/Views/Traits/IsFilter.php +++ b/src/Views/Traits/IsFilter.php @@ -4,7 +4,7 @@ use Rappasoft\LaravelLivewireTables\Traits\Core\HasLocalisations; use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\FilterConfiguration; -use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasConfig,HasLabelAttributes,HasView}; +use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasConfig, HasLabelAttributes, HasView}; use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{HasCustomPosition, HasVisibility}; use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\FilterHelpers; From d97455e096ae1b4e62abfab6105f73e1c65b4626 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Wed, 11 Dec 2024 01:07:55 +0000 Subject: [PATCH 15/15] Update ChangeLog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f3165858..be3d9db34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `laravel-livewire-tables` will be documented in this file +## [v3.5.9] - 2024-12-11 +### Tweaks +- Optimize Imports by @edwinvdpol in https://github.com/rappasoft/laravel-livewire-tables/pull/2124 + ## [v3.5.8] - 2024-12-10 ### New Features - Set bulk action row button attributes by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2117