diff --git a/.github/workflows/pint.yml b/.github/workflows/pint.yml
index 356103132..c533df969 100644
--- a/.github/workflows/pint.yml
+++ b/.github/workflows/pint.yml
@@ -26,7 +26,7 @@ jobs:
- name: Fix PHP code style issues
uses: aglipanci/laravel-pint-action@latest
- - name: Commit changes
+ - name: Commit styling changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Fix styling
diff --git a/.github/workflows/run-phpstan-pull.yml b/.github/workflows/run-phpstan-pull.yml
new file mode 100644
index 000000000..9f8b7a5d7
--- /dev/null
+++ b/.github/workflows/run-phpstan-pull.yml
@@ -0,0 +1,89 @@
+name: run-phpstan-pull
+
+on:
+ pull_request:
+ branches:
+ - 'master'
+ - 'development'
+
+jobs:
+ test:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: true
+ matrix:
+ os: [ubuntu-latest]
+ php: [8.3]
+ laravel: [11]
+ stability: [prefer-dist]
+
+ 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
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Setup cache environment
+ id: extcache
+ uses: shivammathur/cache-extensions@v1
+ with:
+ 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:
+ php-version: ${{ matrix.php }}
+ extensions: ${{ env.extensions }}
+ coverage: pcov
+ tools: phpunit:9.5
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Setup problem matchers for PHP
+ run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
+
+ - name: Get composer cache directory
+ id: composer-cache
+ run: |
+ echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
+
+ - uses: actions/cache@v4
+ with:
+ path: ${{ steps.composer-cache.outputs.dir }}
+ key: phpstan-${{ matrix.os }}-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
+ restore-keys: phpstan-${{ matrix.os }}-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-
+
+ - name: Add token
+ run: |
+ composer config github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Install dependencies
+ if: steps.composer-cache.outputs.cache-hit != 'true'
+ run: composer require "laravel/framework:${{ matrix.laravel }}.*" --no-interaction --no-update
+
+ - name: Update dependencies
+ if: steps.composer-cache.outputs.cache-hit != 'true'
+ run: composer update --${{ matrix.stability }} --no-interaction
+
+ - name: Install PHPStan
+ run: composer require larastan/larastan:^2.0 --no-interaction
+
+ - uses: actions/cache@v4
+ with:
+ path: ./build/phpstan
+ key: phpstan-${{ matrix.os }}-P${{ matrix.php }}-L${{ matrix.laravel }}
+
+ - name: Run PHPStan Tests
+ run: ./vendor/bin/phpstan analyse
\ No newline at end of file
diff --git a/.github/workflows/run-phpstan.yml b/.github/workflows/run-phpstan.yml
index 3701660df..742eb28a7 100644
--- a/.github/workflows/run-phpstan.yml
+++ b/.github/workflows/run-phpstan.yml
@@ -1,10 +1,6 @@
name: run-phpstan
on:
- pull_request:
- branches:
- - 'master'
- - 'development'
push:
branches:
- '*' # matches every branch that doesn't contain a '/'
@@ -26,7 +22,7 @@ jobs:
name: PHPStan - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
env:
- extensionKey: phpextensions
+ 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
steps:
@@ -69,8 +65,8 @@ jobs:
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
- key: ${{ runner.os }}-PHPStan-P${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
- restore-keys: ${{ runner.os }}-PHPStan-P${{ matrix.php }}-L${{ matrix.laravel }}-composer-
+ key: phpstan-${{ matrix.os }}-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
+ restore-keys: phpstan-${{ matrix.os }}-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-
- name: Add token
run: |
@@ -87,5 +83,10 @@ jobs:
- name: Install PHPStan
run: composer require larastan/larastan:^2.0 --dev --no-interaction
+ - uses: actions/cache@v4
+ with:
+ path: ./build/phpstan
+ key: phpstan-${{ matrix.os }}-P${{ matrix.php }}-L${{ matrix.laravel }}
+
- name: Run PHPStan Tests
- run: ./vendor/bin/phpstan analyse
+ run: ./vendor/bin/phpstan analyse
\ No newline at end of file
diff --git a/.github/workflows/run-tests-pcov-pull.yml b/.github/workflows/run-tests-pcov-pull.yml
index fffe0618f..785b3c173 100644
--- a/.github/workflows/run-tests-pcov-pull.yml
+++ b/.github/workflows/run-tests-pcov-pull.yml
@@ -26,6 +26,14 @@ jobs:
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pcov,pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
steps:
+ - name: Wait for tests to finish
+ uses: lewagon/wait-on-check-action@v1.3.4
+ with:
+ ref: ${{ github.ref }}
+ running-workflow-name: 'Run Tests Pull'
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
+ wait-interval: 20
+
- name: Checkout code
uses: actions/checkout@v4
@@ -66,8 +74,8 @@ jobs:
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
- key: ${{ runner.os }}-PCOV-PULL-PHP${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
- restore-keys: ${{ runner.os }}-PCOV-PULL-PHP${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-
+ key: ${{ matrix.os }}-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
+ restore-keys: ${{ matrix.os }}-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-
- name: Add token
run: |
@@ -85,7 +93,7 @@ jobs:
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run Unit Tests
- run: php ./vendor/bin/paratest --cache-directory=".phpunit.cache/code-coverage" --strict-coverage --coverage-clover ./coverage.xml
+ run: php ./vendor/bin/phpunit --cache-directory=".phpunit.cache/code-coverage" --strict-coverage --coverage-clover ./coverage.xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
diff --git a/.github/workflows/run-tests-pull.yml b/.github/workflows/run-tests-pull.yml
index 80c625554..8b0fdd2c4 100644
--- a/.github/workflows/run-tests-pull.yml
+++ b/.github/workflows/run-tests-pull.yml
@@ -1,4 +1,4 @@
-name: run-tests-pull
+name: Run Tests Pull
on:
pull_request:
@@ -20,8 +20,8 @@ jobs:
name: PULL PHP-${{ matrix.php }} - Laravel-10
env:
- extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }}-L${{ matrix.laravel }}
- extensions: dom, curl, libxml, mbstring, zip, pcntl, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr
+ 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
steps:
- name: Checkout code
@@ -39,8 +39,8 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.extcache.outputs.dir }}
- key: ${{ runner.os }}-${{ steps.extcache.outputs.key }}
- restore-keys: ${{ runner.os }}-${{ steps.extcache.outputs.key }}
+ key: ${{ matrix.os }}-${{ steps.extcache.outputs.key }}
+ restore-keys: ${{ matrix.os }}-${{ steps.extcache.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
@@ -64,8 +64,8 @@ jobs:
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
- key: ${{ runner.os }}-STDPUSH-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
- restore-keys: ${{ runner.os }}-STDPUSH-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-
+ key: ${{ matrix.os }}-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
+ restore-keys: ${{ matrix.os }}-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-
- name: Add token
run: |
@@ -100,7 +100,7 @@ jobs:
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, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr
+ extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr
steps:
- name: Checkout code
@@ -118,8 +118,8 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.extcache.outputs.dir }}
- key: ${{ runner.os }}-${{ steps.extcache.outputs.key }}
- restore-keys: ${{ runner.os }}-${{ steps.extcache.outputs.key }}
+ key: ${{ matrix.os }}-${{ steps.extcache.outputs.key }}
+ restore-keys: ${{ matrix.os }}-${{ steps.extcache.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
@@ -143,8 +143,8 @@ jobs:
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
- key: ${{ runner.os }}-STDPUSH-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
- restore-keys: ${{ runner.os }}-STDPUSH-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-
+ key: ${{ matrix.os }}-P${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
+ restore-keys: ${{ matrix.os }}-P${{ matrix.php }}-L${{ matrix.laravel }}-composer-
- name: Add token
run: |
@@ -162,4 +162,4 @@ jobs:
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run Unit Tests
- run: php ./vendor/bin/paratest --no-coverage
+ run: php ./vendor/bin/phpunit --no-coverage
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml
index bcb0d7031..8078c1ddb 100644
--- a/.github/workflows/run-tests.yml
+++ b/.github/workflows/run-tests.yml
@@ -1,4 +1,4 @@
-name: run-tests
+name: Run Standard Tests
on:
push:
@@ -22,8 +22,8 @@ jobs:
name: PHP-${{ matrix.php }} - Laravel-10
env:
- extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }}-L${{ matrix.laravel }}
- extensions: dom, curl, libxml, mbstring, zip, pcntl, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr
+ 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
steps:
- name: Checkout code
@@ -41,8 +41,8 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.extcache.outputs.dir }}
- key: ${{ runner.os }}-${{ steps.extcache.outputs.key }}
- restore-keys: ${{ runner.os }}-${{ steps.extcache.outputs.key }}
+ key: ${{ matrix.os }}-${{ steps.extcache.outputs.key }}
+ restore-keys: ${{ matrix.os }}-${{ steps.extcache.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
@@ -66,8 +66,8 @@ jobs:
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
- key: ${{ runner.os }}-STDPUSH-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
- restore-keys: ${{ runner.os }}-STDPUSH-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-
+ key: ${{ matrix.os }}-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
+ restore-keys: ${{ matrix.os }}-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-
- name: Add token
run: |
@@ -101,8 +101,8 @@ jobs:
name: PHP-${{ matrix.php }} - Laravel-11
env:
- extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }}-L${{ matrix.laravel }}
- extensions: dom, curl, libxml, mbstring, zip, pcntl, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr
+ 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
steps:
- name: Checkout code
@@ -120,8 +120,8 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.extcache.outputs.dir }}
- key: ${{ runner.os }}-${{ steps.extcache.outputs.key }}
- restore-keys: ${{ runner.os }}-${{ steps.extcache.outputs.key }}
+ key: ${{ matrix.os }}-${{ steps.extcache.outputs.key }}
+ restore-keys: ${{ matrix.os }}-${{ steps.extcache.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
@@ -145,8 +145,8 @@ jobs:
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
- key: ${{ runner.os }}-STDPUSH-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
- restore-keys: ${{ runner.os }}-STDPUSH-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-
+ key: ${{ matrix.os }}-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
+ restore-keys: ${{ matrix.os }}-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-
- name: Add token
run: |
@@ -164,4 +164,4 @@ jobs:
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run Unit Tests
- run: php ./vendor/bin/paratest --no-coverage
+ run: php ./vendor/bin/phpunit --no-coverage
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 553622c32..02c0cab4f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,28 @@
All notable changes to `laravel-livewire-tables` will be documented in this file
+## [v3.5.0] - 2024-11-06
+
+### Bug Fixes
+- Issue in multiple places where there is incorrect brackets in conjunction with coalescing operator (??) by @mrl22 in https://github.com/rappasoft/laravel-livewire-tables/pull/2021
+- Add Value to BooleanColumn custom view by @lrjoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2010
+- Add config option to bypass setting User on Events. by @me-julian in https://github.com/rappasoft/laravel-livewire-tables/pull/2006
+- Livewire column doesn't have title() method by @ChrisThompsonTLDR in https://github.com/rappasoft/laravel-livewire-tables/pull/2002
+- Loading Placeholder Adjustments by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1987
+
+### New Features
+- Add Sort in QueryString by @lrjoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2018
+- Add Search in QueryString by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2017
+- Add Filter in QueryString by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2011
+- BETA: Livewire Custom Filter (Array) by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2025
+
+### Localisation
+- Adds Swedish translations by @Aiiion in https://github.com/rappasoft/laravel-livewire-tables/pull/2027
+- Fix missing i18n keys for FR, IT, EN, DE by @khwadj in https://github.com/rappasoft/laravel-livewire-tables/pull/1993
+- Add lang Norwegian and Albanian by @channor in https://github.com/rappasoft/laravel-livewire-tables/pull/1988
+
+
+
## [v3.4.22] - 2024-09-29
### Bug Fixes
- Fix Loading Placeholder Bug - Breaking Table by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1969
diff --git a/config/livewire-tables.php b/config/livewire-tables.php
index 4cc3dccab..7c2e20983 100644
--- a/config/livewire-tables.php
+++ b/config/livewire-tables.php
@@ -114,4 +114,14 @@
'defaultConfig' => [],
],
+ /**
+ * Configuration options for Events
+ */
+ 'events' => [
+ /**
+ * Enable or disable passing the user from Laravel's Auth service to events
+ */
+ 'enableUserForEvent' => true,
+ ],
+
];
diff --git a/docs/column-types/livewire_component_column.md b/docs/column-types/livewire_component_column.md
index 9b1851299..6a6af2eea 100644
--- a/docs/column-types/livewire_component_column.md
+++ b/docs/column-types/livewire_component_column.md
@@ -10,7 +10,6 @@ This is **not recommended** as due to the nature of Livewire, it becomes ineffic
## component
```
LivewireComponentColumn::make('Action')
- ->title(fn($row) => 'Edit')
->component('PathToLivewireComponent'),
```
@@ -29,4 +28,4 @@ Please also see the following for other available methods:
Footer
-
\ No newline at end of file
+
diff --git a/docs/datatable/available-methods.md b/docs/datatable/available-methods.md
index 13d4091b3..3cf5c303c 100644
--- a/docs/datatable/available-methods.md
+++ b/docs/datatable/available-methods.md
@@ -76,43 +76,7 @@ public function configure(): void
## Query String
-The query string is **enabled by default**, but if you ever needed to toggle it you can use the following methods:
-
-### setQueryStringStatus
-
-Enable/disable the query string.
-
-```php
-public function configure(): void
-{
- $this->setQueryStringStatus(true);
- $this->setQueryStringStatus(false);
-}
-```
-
-### setQueryStringEnabled
-
-Enable the query string.
-
-```php
-public function configure(): void
-{
- // Shorthand for $this->setQueryStringStatus(true)
- $this->setQueryStringEnabled();
-}
-```
-
-### setQueryStringDisabled
-
-Disable the query string.
-
-```php
-public function configure(): void
-{
- // Shorthand for $this->setQueryStringStatus(false)
- $this->setQueryStringDisabled();
-}
-```
+The documentation for Query String now lives: [here](./query-string)
## Relationships
diff --git a/docs/datatable/events.md b/docs/datatable/events.md
index 2a64763a7..dc81a5695 100644
--- a/docs/datatable/events.md
+++ b/docs/datatable/events.md
@@ -55,6 +55,8 @@ There are several events, all in the Rappasoft\LaravelLivewireTables\Events name
| FilterApplied | Applied when a Filter is applied (not when removed) | The Table Name ($tableName), Filter Key ($key), Filter Value ($value), Logged In User ($user) |
| SearchApplied | Applied when a Search is applied (not when removed) | The Table Name ($tableName), Search Term ($value), Logged In User ($user) |
+Passing the user with an event is optional and [can be disabled in the config](../start/configuration.md#bypassing-laravels-auth-service).
+
By default, the Tables will dispatch an event when the Selected Columns is changed, you may customise this behaviour:
#### enableAllEvents
diff --git a/docs/datatable/query-string.md b/docs/datatable/query-string.md
new file mode 100644
index 000000000..c830ef15a
--- /dev/null
+++ b/docs/datatable/query-string.md
@@ -0,0 +1,207 @@
+---
+title: Query String
+weight: 5
+---
+
+The query string is **enabled by default**, but if you ever needed to toggle it you can use the following methods:
+
+## Global
+### setQueryStringStatus
+
+Enable/disable the query string.
+
+```php
+public function configure(): void
+{
+ $this->setQueryStringStatus(true);
+ $this->setQueryStringStatus(false);
+}
+```
+
+### setQueryStringEnabled
+
+Enable the query string.
+
+```php
+public function configure(): void
+{
+ // Shorthand for $this->setQueryStringStatus(true)
+ $this->setQueryStringEnabled();
+}
+```
+
+### setQueryStringDisabled
+
+Disable the query string.
+
+```php
+public function configure(): void
+{
+ // Shorthand for $this->setQueryStringStatus(false)
+ $this->setQueryStringDisabled();
+}
+```
+
+### setQueryStringAlias
+
+Change the Alias in the URL, otherwise defaults to "$tablename"
+
+```php
+public function configure(): void
+{
+ $this->setQueryStringAlias('table1');
+}
+```
+
+## Filters
+
+The filter query string is **enabled by default**, but if you ever needed to toggle it you can use the following methods:
+
+### setQueryStringStatusForFilter
+
+Enable/disable the query string for the filters
+
+```php
+public function configure(): void
+{
+ $this->setQueryStringStatusForFilter(true);
+ $this->setQueryStringStatusForFilter(false);
+}
+```
+
+### setQueryStringForFilterEnabled
+
+Enable the query string for the filters
+
+```php
+public function configure(): void
+{
+ // Shorthand for $this->setQueryStringStatusForFilter(true)
+ $this->setQueryStringForFilterEnabled();
+}
+```
+
+### setQueryStringForFilterDisabled
+
+Disable the query string for the filters
+
+```php
+public function configure(): void
+{
+ // Shorthand for $this->setQueryStringStatusForFilter(false)
+ $this->setQueryStringForFilterDisabled();
+}
+```
+
+### setQueryStringAliasForFilter
+
+Change the Alias in the URL for the filter, otherwise defaults to "$tablename-filters"
+
+```php
+public function configure(): void
+{
+ $this->setQueryStringAliasForFilter('filtervalues');
+}
+```
+
+## Search
+
+The search query string is **enabled by default**, but if you ever needed to toggle it you can use the following methods:
+
+### setQueryStringStatusForSearch
+
+Enable/disable the query string for search
+
+```php
+public function configure(): void
+{
+ $this->setQueryStringStatusForSearch(true);
+ $this->setQueryStringStatusForSearch(false);
+}
+```
+
+### setQueryStringForSearchEnabled
+
+Enable the query string for search
+
+```php
+public function configure(): void
+{
+ // Shorthand for $this->setQueryStringStatusForSearch(true)
+ $this->setQueryStringForSearchEnabled();
+}
+```
+
+### setQueryStringForSearchDisabled
+
+Disable the query string for search
+
+```php
+public function configure(): void
+{
+ // Shorthand for $this->setQueryStringStatusForSearch(false)
+ $this->setQueryStringForSearchDisabled();
+}
+```
+
+### setQueryStringAliasForSearch
+
+Change the Alias in the URL for the search, otherwise defaults to "$tablename-search"
+
+```php
+public function configure(): void
+{
+ $this->setQueryStringAliasForSearch('search');
+}
+```
+
+## Sorts
+
+The sorts query string is **enabled by default**, but if you ever needed to toggle it you can use the following methods:
+
+### setQueryStringStatusForSort
+
+Enable/disable the query string for sort
+
+```php
+public function configure(): void
+{
+ $this->setQueryStringStatusForSort(true);
+ $this->setQueryStringStatusForSort(false);
+}
+```
+
+### setQueryStringForSortEnabled
+
+Enable the query string for sort
+
+```php
+public function configure(): void
+{
+ // Shorthand for $this->setQueryStringStatusForSort(true)
+ $this->setQueryStringForSortEnabled();
+}
+```
+
+### setQueryStringForSortDisabled
+
+Disable the query string for sort
+
+```php
+public function configure(): void
+{
+ // Shorthand for $this->setQueryStringStatusForSort(false)
+ $this->setQueryStringForSortDisabled();
+}
+```
+
+### setQueryStringAliasForSort
+
+Change the Alias in the URL for the sorts, otherwise defaults to "$tablename-sorts"
+
+```php
+public function configure(): void
+{
+ $this->setQueryStringAliasForSort('sorts');
+}
+```
\ No newline at end of file
diff --git a/docs/datatable/styling.md b/docs/datatable/styling.md
index 9353ad00e..937a6df94 100644
--- a/docs/datatable/styling.md
+++ b/docs/datatable/styling.md
@@ -1,6 +1,6 @@
---
title: Styling
-weight: 5
+weight: 6
---
The package offers significant opportunities to customise the look & feel of the core table, as well as other elements (which are documented in the relevant sections).
diff --git a/docs/misc/loading-placeholder.md b/docs/misc/loading-placeholder.md
index 20ca7f9b5..67c4977ac 100644
--- a/docs/misc/loading-placeholder.md
+++ b/docs/misc/loading-placeholder.md
@@ -47,7 +47,9 @@ You may use this method to set custom text for the placeholder:
$this->setLoadingPlaceholderContent('Text To Display');
}
```
-### setLoadingPlaceHolderWrapperAttributes
+### setLoadingPlaceHolderWrapperAttributes (Deprecated)
+
+This is replaced by setLoadingPlaceHolderRowAttributes, but remains functional.
This method allows you to customise the attributes for the <tr> element used as a Placeholder when the table is loading. Similar to other setAttribute methods, this accepts a range of attributes, and a boolean "default", which will enable/disable the default attributes.
@@ -62,6 +64,22 @@ This method allows you to customise the attributes for the <tr> element us
```
+### setLoadingPlaceHolderRowAttributes
+
+Replaces setLoadingPlaceHolderWrapperAttributes
+This method allows you to customise the attributes for the <tr> element used as a Placeholder when the table is loading. Similar to other setAttribute methods, this accepts a range of attributes, and a boolean "default", which will enable/disable the default attributes.
+
+```php
+ public function configure(): void
+ {
+ $this->setLoadingPlaceHolderRowAttributes([
+ 'class' => 'text-bold',
+ 'default' => false,
+ ]);
+ }
+
+```
+
### setLoadingPlaceHolderIconAttributes
This method allows you to customise the attributes for the <div> element that is used solely for the PlaceholderIcon. Similar to other setAttribute methods, this accepts a range of attributes, and a boolean "default", which will enable/disable the default attributes.
diff --git a/docs/start/configuration.md b/docs/start/configuration.md
index 3e264c578..01725843f 100644
--- a/docs/start/configuration.md
+++ b/docs/start/configuration.md
@@ -81,3 +81,22 @@ You must also make sure you have this Alpine style available globally. Note that
[x-cloak] { display: none !important; }
```
+
+## Bypassing Laravel's Auth Service
+
+By default, all [events](../datatable/events#dispatched) will retrieve any currently authenticated user from Laravel's [Auth service](https://laravel.com/docs/authentication) and pass it along with the event.
+
+If your project doesn't include the Illuminate/Auth package, or you otherwise want to prevent this, you can set the `enableUserForEvent` config option to false.
+
+```php
+// config/livewire-tables.php
+return [
+ // ...
+ 'events' => [
+ /**
+ * Enable or disable passing the user from Laravel's Auth service to events
+ */
+ 'enableUserForEvent' => false,
+ ],
+];
+```
diff --git a/resources/lang/de.json b/resources/lang/de.json
index 2ddfa94cc..6ef76e8bf 100644
--- a/resources/lang/de.json
+++ b/resources/lang/de.json
@@ -5,6 +5,7 @@
"livewire-tables::Applied Sorting": "Angewendete Sortierung",
"livewire-tables::Bulk Actions": "Aktionen",
"livewire-tables::Clear": "Zurücksetzen",
+ "livewire-tables::Bulk Actions Confirm": "Bist du sicher?",
"livewire-tables::Columns": "Spalten",
"livewire-tables::Debugging Values": "Werte debuggen",
"livewire-tables::Deselect All": "Alle abwählen",
@@ -23,6 +24,7 @@
"livewire-tables::rows, do you want to select all": "Zeilen, sollen alle ausgewählt werden",
"livewire-tables::Search": "Suche",
"livewire-tables::Select All": "Alle auswählen",
+ "livewire-tables::Select All On Page": "Alle auf der Seite auswählen",
"livewire-tables::Showing": "Anzeigen",
"livewire-tables::to": "nach",
"livewire-tables::Yes": "Ja",
@@ -34,6 +36,7 @@
"Applied Filters": "Angewendete Filter",
"Applied Sorting": "Angewendete Sortierung",
"Bulk Actions": "Aktionen",
+ "Bulk Actions Confirm": "Bist du sicher?",
"Clear": "Zurücksetzen",
"Columns": "Spalten",
"Debugging Values": "Werte debuggen",
@@ -53,6 +56,7 @@
"rows, do you want to select all": "Zeilen, sollen alle ausgewählt werden",
"Search": "Suche",
"Select All": "Alle auswählen",
+ "Select All On Page": "Alle auf der Seite auswählen",
"Showing": "Anzeigen",
"to": "nach",
"Yes": "Ja",
diff --git a/resources/lang/en.json b/resources/lang/en.json
index dcf30f145..1579cbbe2 100644
--- a/resources/lang/en.json
+++ b/resources/lang/en.json
@@ -11,6 +11,7 @@
"livewire-tables::Deselect All": "Deselect All",
"livewire-tables::Done Reordering": "Done Reordering",
"livewire-tables::Filters": "Filters",
+ "livewire-tables::loading": "Loading",
"livewire-tables::max": "Max",
"livewire-tables::min": "Min",
"livewire-tables::not_applicable": "N/A",
@@ -45,6 +46,7 @@
"Deselect All": "Deselect All",
"Done Reordering": "Done Reordering",
"Filters": "Filters",
+ "loading": "Loading",
"max": "Max",
"min": "Min",
"not_applicable": "N/A",
diff --git a/resources/lang/es.json b/resources/lang/es.json
index b03b2e25f..8654e82ca 100644
--- a/resources/lang/es.json
+++ b/resources/lang/es.json
@@ -4,6 +4,7 @@
"livewire-tables::Applied Filters": "Filtros Aplicados",
"livewire-tables::Applied Sorting": "Ordenamiento Aplicado",
"livewire-tables::Bulk Actions": "Acciones Masivas",
+ "livewire-tables::Bulk Actions Confirm": "Está seguro?",
"livewire-tables::Clear": "Borrar",
"livewire-tables::Columns": "Columnas",
"livewire-tables::Debugging Values": "Valores de depuración",
@@ -35,6 +36,7 @@
"Applied Filters": "Filtros Aplicados",
"Applied Sorting": "Ordenamiento Aplicado",
"Bulk Actions": "Acciones Masivas",
+ "Bulk Actions Confirm": "Está seguro?",
"Clear": "Borrar",
"Columns": "Columnas",
"Debugging Values": "Valores de depuración",
diff --git a/resources/lang/fr.json b/resources/lang/fr.json
index 89323dc4a..9cb399d08 100644
--- a/resources/lang/fr.json
+++ b/resources/lang/fr.json
@@ -4,6 +4,7 @@
"livewire-tables::Applied Filters": "Filtres appliqués",
"livewire-tables::Applied Sorting": "Tris appliqués",
"livewire-tables::Bulk Actions": "Actions en masse",
+ "livewire-tables::Bulk Actions Confirm": "Êtes-vous sûr ?",
"livewire-tables::Clear": "Effacer",
"livewire-tables::Columns": "Colonnes",
"livewire-tables::Debugging Values": "Valeurs de débogage",
@@ -23,7 +24,8 @@
"livewire-tables::rows, do you want to select all": "lignes, voulez-vous tout sélectionner ?",
"livewire-tables::Search": "Rechercher",
"livewire-tables::Select All": "Tout sélectionner",
- "livewire-tables::Showing": "Montrant",
+ "livewire-tables::Select All On Page": "Tout sélectionner sur la page",
+ "livewire-tables::Showing": "Résultats",
"livewire-tables::to": "à",
"livewire-tables::Yes": "Oui",
"livewire-tables::You are currently selecting all": "Vous êtes en train de sélectionner ",
@@ -34,6 +36,7 @@
"Applied Filters": "Filtres appliqués",
"Applied Sorting": "Tris appliqués",
"Bulk Actions": "Actions en masse",
+ "Bulk Actions Confirm": "Êtes-vous sûr ?",
"Clear": "Effacer",
"Columns": "Colonnes",
"Debugging Values": "Valeurs de débogage",
@@ -53,7 +56,8 @@
"rows, do you want to select all": "lignes, voulez-vous tout sélectionner ?",
"Search": "Rechercher",
"Select All": "Tout sélectionner",
- "Showing": "Montrant",
+ "Select All On Page": "Tout sélectionner sur la page",
+ "Showing": "Résultats",
"to": "à",
"Yes": "Oui",
"You are currently selecting all": "Vous êtes en train de sélectionner ",
diff --git a/resources/lang/it.json b/resources/lang/it.json
index a1c50fb21..ceaffa5fc 100644
--- a/resources/lang/it.json
+++ b/resources/lang/it.json
@@ -4,6 +4,7 @@
"livewire-tables::Applied Filters": "Filtri Applicati",
"livewire-tables::Applied Sorting": "Ordinamento Applicato",
"livewire-tables::Bulk Actions": "Azioni di Gruppo",
+ "livewire-tables::Bulk Actions Confirm": "Sei sicuro?",
"livewire-tables::Clear": "Pulisci",
"livewire-tables::Columns": "Colonne",
"livewire-tables::Debugging Values": "Valori di debug",
@@ -22,7 +23,8 @@
"livewire-tables::rows": "righe",
"livewire-tables::rows, do you want to select all": "righe, vuoi selezionarle tutte",
"livewire-tables::Search": "Cerca",
- "livewire-tables::Select All": "Seleziona Tutto",
+ "livewire-tables::Select All": "Seleziona tutto",
+ "livewire-tables::Select All On Page": "Seleziona tutto sulla pagina",
"livewire-tables::Showing": "Visualizzati",
"livewire-tables::to": "a",
"livewire-tables::Yes": "SÌ",
@@ -34,6 +36,7 @@
"Applied Filters": "Filtri Applicati",
"Applied Sorting": "Ordinamento Applicato",
"Bulk Actions": "Azioni di Gruppo",
+ "Bulk Actions Confirm": "Sei sicuro?",
"Clear": "Pulisci",
"Columns": "Colonne",
"Debugging Values": "Valori di debug",
@@ -52,7 +55,8 @@
"rows": "righe",
"rows, do you want to select all": "righe, vuoi selezionarle tutte",
"Search": "Cerca",
- "Select All": "Seleziona Tutto",
+ "Select All": "Seleziona tutto",
+ "Select All On Page": "Seleziona tutto sulla pagina",
"Showing": "Visualizzati",
"to": "a",
"Yes": "SÌ",
diff --git a/resources/lang/nb.json b/resources/lang/nb.json
new file mode 100644
index 000000000..b7bb83929
--- /dev/null
+++ b/resources/lang/nb.json
@@ -0,0 +1,70 @@
+{
+ "livewire-tables::All": "Alle",
+ "livewire-tables::All Columns": "Alle kolonner",
+ "livewire-tables::Applied Filters": "Anvendte filtre",
+ "livewire-tables::Applied Sorting": "Anvendt sortering",
+ "livewire-tables::Bulk Actions": "Massehandlinger",
+ "livewire-tables::Bulk Actions Confirm": "Er du sikker?",
+ "livewire-tables::Clear": "Tøm",
+ "livewire-tables::Columns": "Kolonner",
+ "livewire-tables::Debugging Values": "Debugger Verdier",
+ "livewire-tables::Deselect All": "Opphev alle",
+ "livewire-tables::Done Reordering": "Ferdig med omorganisering",
+ "livewire-tables::Filters": "Filtre",
+ "livewire-tables::max": "Maks",
+ "livewire-tables::min": "Min",
+ "livewire-tables::not_applicable": "I/T",
+ "livewire-tables::No": "Nei",
+ "livewire-tables::No items found. Try to broaden your search.": "Ingen elementer funnet. Prøv å utvide søket.",
+ "livewire-tables::of": "av",
+ "livewire-tables::Remove filter option": "Fjern filtervalg",
+ "livewire-tables::Remove sort option": "Fjern sorteringsvalg",
+ "livewire-tables::Reorder": "Omorganiser",
+ "livewire-tables::results": "resultater",
+ "livewire-tables::row": "rad",
+ "livewire-tables::rows": "rader",
+ "livewire-tables::rows, do you want to select all": "rader, vil du velge alle",
+ "livewire-tables::Search": "Søk",
+ "livewire-tables::Select All": "Velg alle",
+ "livewire-tables::Select All On Page": "Velg alle på siden",
+ "livewire-tables::Showing": "Viser",
+ "livewire-tables::to": "til",
+ "livewire-tables::Yes": "Ja",
+ "livewire-tables::You are currently selecting all": "Du velger for øyeblikket alle",
+ "livewire-tables::You are not connected to the internet.": "Du er ikke tilkoblet internett.",
+ "livewire-tables::You have selected": "Du har valgt",
+ "All": "Alle",
+ "All Columns": "Alle kolonner",
+ "Applied Filters": "Anvendte filtre",
+ "Applied Sorting": "Anvendt sortering",
+ "Bulk Actions": "Massehandlinger",
+ "Bulk Actions Confirm": "Er du sikker?",
+ "Clear": "Tøm",
+ "Columns": "Kolonner",
+ "Debugging Values": "Debugger verdier",
+ "Deselect All": "Opphev valg for alle",
+ "Done Reordering": "Ferdig med omorganisering",
+ "Filters": "Filtre",
+ "max": "Maks",
+ "min": "Min",
+ "not_applicable": "I/T",
+ "No": "Nei",
+ "No items found. Try to broaden your search.": "Ingen elementer funnet. Prøv å utvide søket.",
+ "of": "av",
+ "Remove filter option": "Fjern filtervalg",
+ "Remove sort option": "Fjern sorteringsvalg",
+ "Reorder": "Omorganiser",
+ "results": "resultater",
+ "row": "rad",
+ "rows": "rader",
+ "rows, do you want to select all": "rader, vil du velge alle",
+ "Search": "Søk",
+ "Select All": "Velg alle",
+ "Select All On Page": "Velg alle på siden",
+ "Showing": "Viser",
+ "to": "til",
+ "Yes": "Ja",
+ "You are currently selecting all": "Du velger for øyeblikket alle",
+ "You are not connected to the internet.": "Du er ikke tilkoblet internett.",
+ "You have selected": "Du har valgt"
+}
diff --git a/resources/lang/sq.json b/resources/lang/sq.json
new file mode 100644
index 000000000..1784fa2cc
--- /dev/null
+++ b/resources/lang/sq.json
@@ -0,0 +1,70 @@
+{
+ "livewire-tables::All": "Të gjitha",
+ "livewire-tables::All Columns": "Të gjitha kolonat",
+ "livewire-tables::Applied Filters": "Filtrat e aplikuara",
+ "livewire-tables::Applied Sorting": "Renditja e aplikuar",
+ "livewire-tables::Bulk Actions": "Veprime në masë",
+ "livewire-tables::Bulk Actions Confirm": "A jeni i sigurt?",
+ "livewire-tables::Clear": "Pastro",
+ "livewire-tables::Columns": "Kolonat",
+ "livewire-tables::Debugging Values": "Vlerat e korrigjimit",
+ "livewire-tables::Deselect All": "Heq të gjitha",
+ "livewire-tables::Done Reordering": "Përfundoi riorganizimi",
+ "livewire-tables::Filters": "Filtrat",
+ "livewire-tables::max": "Maksimumi",
+ "livewire-tables::min": "Minimumi",
+ "livewire-tables::not_applicable": "N/A",
+ "livewire-tables::No": "Jo",
+ "livewire-tables::No items found. Try to broaden your search.": "Nuk u gjetën artikuj. Provoni të zgjeroni kërkimin tuaj.",
+ "livewire-tables::of": "nga",
+ "livewire-tables::Remove filter option": "Hiq opsionin e filtrit",
+ "livewire-tables::Remove sort option": "Hiq opsionin e renditjes",
+ "livewire-tables::Reorder": "Riorganizo",
+ "livewire-tables::results": "rezultate",
+ "livewire-tables::row": "rreshti",
+ "livewire-tables::rows": "rreshtat",
+ "livewire-tables::rows, do you want to select all": "rreshtat, dëshironi të zgjidhni të gjitha",
+ "livewire-tables::Search": "Kërko",
+ "livewire-tables::Select All": "Zgjidh të gjitha",
+ "livewire-tables::Select All On Page": "Zgjidh të gjitha në faqe",
+ "livewire-tables::Showing": "Duke treguar",
+ "livewire-tables::to": "te",
+ "livewire-tables::Yes": "Po",
+ "livewire-tables::You are currently selecting all": "Po zgjedhni të gjitha aktualisht",
+ "livewire-tables::You are not connected to the internet.": "Nuk jeni të lidhur me internetin.",
+ "livewire-tables::You have selected": "Keni zgjedhur",
+ "All": "Të gjitha",
+ "All Columns": "Të gjitha kolonat",
+ "Applied Filters": "Filtrat e aplikuara",
+ "Applied Sorting": "Renditja e aplikuar",
+ "Bulk Actions": "Veprime në masë",
+ "Bulk Actions Confirm": "A jeni i sigurt?",
+ "Clear": "Pastro",
+ "Columns": "Kolonat",
+ "Debugging Values": "Vlerat e korrigjimit",
+ "Deselect All": "Heq të gjitha",
+ "Done Reordering": "Përfundoi riorganizimi",
+ "Filters": "Filtrat",
+ "max": "Maksimumi",
+ "min": "Minimumi",
+ "not_applicable": "N/A",
+ "No": "Jo",
+ "No items found. Try to broaden your search.": "Nuk u gjetën artikuj. Provoni të zgjeroni kërkimin tuaj.",
+ "of": "nga",
+ "Remove filter option": "Hiq opsionin e filtrit",
+ "Remove sort option": "Hiq opsionin e renditjes",
+ "Reorder": "Riorganizo",
+ "results": "rezultate",
+ "row": "rreshti",
+ "rows": "rreshtat",
+ "rows, do you want to select all": "rreshtat, dëshironi të zgjidhni të gjitha",
+ "Search": "Kërko",
+ "Select All": "Zgjidh të gjitha",
+ "Select All On Page": "Zgjidh të gjitha në faqe",
+ "Showing": "Duke treguar",
+ "to": "te",
+ "Yes": "Po",
+ "You are currently selecting all": "Po zgjedhni të gjitha aktualisht",
+ "You are not connected to the internet.": "Nuk jeni të lidhur me internetin.",
+ "You have selected": "Keni zgjedhur"
+}
diff --git a/resources/lang/sv.json b/resources/lang/sv.json
new file mode 100644
index 000000000..4bfd4cbfb
--- /dev/null
+++ b/resources/lang/sv.json
@@ -0,0 +1,36 @@
+{
+ "livewire-tables::All": "Alla",
+ "livewire-tables::All Columns": "Alla Columner",
+ "livewire-tables::Applied Filters": "Valda filter",
+ "livewire-tables::Applied Sorting": "Vald sortering",
+ "livewire-tables::Bulk Actions": "Bulk Modifiering",
+ "livewire-tables::Bulk Actions Confirm": "Är du säker?",
+ "livewire-tables::Clear": "Rensa",
+ "livewire-tables::Columns": "Columner",
+ "livewire-tables::Debugging Values": "Debug Värden",
+ "livewire-tables::Deselect All": "Avmarkera alla",
+ "livewire-tables::Done Reordering": "Omordning klart",
+ "livewire-tables::Filters": "Filter",
+ "livewire-tables::max": "Max",
+ "livewire-tables::min": "Min",
+ "livewire-tables::not_applicable": "N/A",
+ "livewire-tables::No": "Nej",
+ "livewire-tables::No items found. Try to broaden your search.": "Inga föremål hittades. Försök vidga din sökning.",
+ "livewire-tables::of": "av",
+ "livewire-tables::Remove filter option": "Rensa valt filter",
+ "livewire-tables::Remove sort option": "Rensa vald sortering",
+ "livewire-tables::Reorder": "Omordna",
+ "livewire-tables::results": "resultat",
+ "livewire-tables::row": "rad",
+ "livewire-tables::rows": "rader",
+ "livewire-tables::rows, do you want to select all": "rader, vill du markera alla",
+ "livewire-tables::Search": "Sök",
+ "livewire-tables::Select All": "Markera alla",
+ "livewire-tables::Select All On Page": "Markera alla på sidan",
+ "livewire-tables::Showing": "Visar",
+ "livewire-tables::to": "till",
+ "livewire-tables::Yes": "Ja",
+ "livewire-tables::You are currently selecting all": "Du markerar för närvarande alla",
+ "livewire-tables::You are not connected to the internet.": "Du är inte uppkopplad till internet.",
+ "livewire-tables::You have selected": "Du har markerat"
+}
diff --git a/resources/views/components/includes/loading.blade.php b/resources/views/components/includes/loading.blade.php
index f22096321..b8c988e88 100644
--- a/resources/views/components/includes/loading.blade.php
+++ b/resources/views/components/includes/loading.blade.php
@@ -1,35 +1,37 @@
-@aware(['isTailwind', 'isBootstrap', 'tableName', 'component'])
+@aware(['tableName'])
@props(['colCount' => 1])
@php
-$customAttributes['loader-wrapper'] = $this->getLoadingPlaceHolderWrapperAttributes();
-$customAttributes['loader-icon'] = $this->getLoadingPlaceHolderIconAttributes();
+$loaderRow = $this->getLoadingPlaceHolderRowAttributes();
+$loaderCell = $this->getLoadingPlaceHolderCellAttributes();
+$loaderIcon = $this->getLoadingPlaceHolderIconAttributes();
@endphp
-@if($this->hasLoadingPlaceholderBlade())
- @include($this->getLoadingPlaceHolderBlade(), ['colCount' => $colCount])
-@else
- merge($customAttributes['loader-wrapper'])
- ->class(['hidden w-full text-center h-screen place-items-center align-middle' => $isTailwind && ($customAttributes['loader-wrapper']['default'] ?? true)])
- ->class(['d-none w-100 text-center h-100 align-items-center' => $isBootstrap && ($customAttributes['loader-wrapper']['default'] ?? true)]);
- }}
- wire:loading.class.remove="hidden d-none"
- >
-
+ merge($loaderRow)
+ ->class(['hidden w-full text-center place-items-center align-middle' => $this->isTailwind && ($loaderRow['default'] ?? true)])
+ ->class(['d-none w-100 text-center align-items-center' => $this->isBootstrap && ($loaderRow['default'] ?? true)])
+ ->except(['default','default-styling','default-colors'])
+}}>
+ merge($loaderCell)
+ ->class(['py-4' => $this->isTailwind && ($loaderCell['default'] ?? true)])
+ ->class(['py-4' => $this->isBootstrap && ($loaderCell['default'] ?? true)])
+ ->except(['default','default-styling','default-colors', 'colspan','wire:key'])
+ }}>
+ @if($this->hasLoadingPlaceholderBlade())
+ @include($this->getLoadingPlaceHolderBlade(), ['colCount' => $colCount])
+ @else
-
merge($customAttributes['loader-icon'])
- ->class(['lds-hourglass' => $isTailwind && ($customAttributes['loader-icon']['default'] ?? true)])
- ->class(['lds-hourglass' => $isBootstrap && ($customAttributes['loader-icon']['default'] ?? true)])
+
merge($loaderIcon)
+ ->class(['lds-hourglass' => $this->isTailwind && ($loaderIcon['default'] ?? true)])
+ ->class(['lds-hourglass' => $this->isBootstrap && ($loaderIcon['default'] ?? true)])
->except(['default','default-styling','default-colors']);
- }}
- >
-
{{ $this->getLoadingPlaceholderContent() }}
+ }}>
+
{!! $this->getLoadingPlaceholderContent() !!}
-
-
+ @endif
+
+
-@endif
diff --git a/resources/views/components/table/th.blade.php b/resources/views/components/table/th.blade.php
index b12366dc7..3afee536c 100644
--- a/resources/views/components/table/th.blade.php
+++ b/resources/views/components/table/th.blade.php
@@ -20,8 +20,8 @@
@if ($isTailwind)
merge($customThAttributes)
- ->class(['text-gray-500 dark:bg-gray-800 dark:text-gray-400' => ($customThAttributes['default-colors'] ?? true || $customThAttributes['default'] ?? true)])
- ->class(['px-6 py-3 text-left text-xs font-medium whitespace-nowrap uppercase tracking-wider' => ($customThAttributes['default-styling'] ?? true || $customThAttributes['default'] ?? true)])
+ ->class(['text-gray-500 dark:bg-gray-800 dark:text-gray-400' => (($customThAttributes['default-colors'] ?? true) || ($customThAttributes['default'] ?? true))])
+ ->class(['px-6 py-3 text-left text-xs font-medium whitespace-nowrap uppercase tracking-wider' => (($customThAttributes['default-styling'] ?? true) || ($customThAttributes['default'] ?? true))])
->class(['hidden' => $column->shouldCollapseAlways()])
->class(['hidden md:table-cell' => $column->shouldCollapseOnMobile()])
->class(['hidden lg:table-cell' => $column->shouldCollapseOnTablet()])
@@ -35,8 +35,8 @@
merge($customSortButtonAttributes)
- ->class(['text-gray-500 dark:text-gray-400' => ($customSortButtonAttributes['default-colors'] ?? true || $customSortButtonAttributes['default'] ?? true)])
- ->class(['flex items-center space-x-1 text-left text-xs leading-4 font-medium uppercase tracking-wider group focus:outline-none' => ($customSortButtonAttributes['default-styling'] ?? true || $customSortButtonAttributes['default'] ?? true)])
+ ->class(['text-gray-500 dark:text-gray-400' => (($customSortButtonAttributes['default-colors'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
+ ->class(['flex items-center space-x-1 text-left text-xs leading-4 font-medium uppercase tracking-wider group focus:outline-none' => (($customSortButtonAttributes['default-styling'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
->except(['default', 'default-colors', 'default-styling', 'wire:key'])
}}
>
@@ -71,7 +71,7 @@ class="d-flex align-items-center laravel-livewire-tables-cursor"
wire:click="sortBy('{{ $column->getColumnSortKey() }}')"
{{
$attributes->merge($customSortButtonAttributes)
- ->class(['' => ($customSortButtonAttributes['default-styling'] ?? true || $customSortButtonAttributes['default'] ?? true)])
+ ->class(['' => (($customSortButtonAttributes['default-styling'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
->except(['default', 'default-colors', 'default-styling', 'wire:key'])
}}
>
@@ -79,7 +79,7 @@ class="d-flex align-items-center laravel-livewire-tables-cursor"
merge($customSortButtonAttributes)
- ->class(['' => ($customSortButtonAttributes['default-colors'] ?? true || $customSortButtonAttributes['default'] ?? true)])
+ ->class(['' => (($customSortButtonAttributes['default-colors'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
->except(['default', 'default-colors', 'default-styling', 'wire:key'])
}}
/>
diff --git a/resources/views/components/table/th/plain.blade.php b/resources/views/components/table/th/plain.blade.php
index 4f5837f34..3a0a56d36 100644
--- a/resources/views/components/table/th/plain.blade.php
+++ b/resources/views/components/table/th/plain.blade.php
@@ -4,8 +4,8 @@
merge($customAttributes)->class([
- 'table-cell px-3 py-2 md:px-6 md:py-3 text-center md:text-left bg-gray-50 dark:bg-gray-800 laravel-livewire-tables-reorderingMinimised' => ($isTailwind) && ($customAttributes['default-colors'] ?? true || $customAttributes['default'] ?? true),
- 'laravel-livewire-tables-reorderingMinimised' => ($isBootstrap) && ($customAttributes['default-colors'] ?? true || $customAttributes['default'] ?? true),
+ 'table-cell px-3 py-2 md:px-6 md:py-3 text-center md:text-left bg-gray-50 dark:bg-gray-800 laravel-livewire-tables-reorderingMinimised' => ($isTailwind) && (($customAttributes['default-colors'] ?? true) || ($customAttributes['default'] ?? true)),
+ 'laravel-livewire-tables-reorderingMinimised' => ($isBootstrap) && (($customAttributes['default-colors'] ?? true) || ($customAttributes['default'] ?? true)),
])
}}
@if($hideUntilReorder) :class="!reorderDisplayColumn && 'w-0 p-0 hidden'" @endif
diff --git a/resources/views/components/table/th/reorder.blade.php b/resources/views/components/table/th/reorder.blade.php
index 5ba02d959..e4fe7cecb 100644
--- a/resources/views/components/table/th/reorder.blade.php
+++ b/resources/views/components/table/th/reorder.blade.php
@@ -6,8 +6,8 @@
merge($customThAttributes)
- ->class(['text-gray-500 dark:bg-gray-800 dark:text-gray-400' => ($customThAttributes['default-colors'] ?? true || $customThAttributes['default'] ?? true)])
- ->class(['table-cell px-6 py-3 text-left text-xs font-medium whitespace-nowrap uppercase tracking-wider' => ($customThAttributes['default-styling'] ?? true || $customThAttributes['default'] ?? true)])
+ ->class(['text-gray-500 dark:bg-gray-800 dark:text-gray-400' => (($customThAttributes['default-colors'] ?? true) || ($customThAttributes['default'] ?? true))])
+ ->class(['table-cell px-6 py-3 text-left text-xs font-medium whitespace-nowrap uppercase tracking-wider' => (($customThAttributes['default-styling'] ?? true) || ($customThAttributes['default'] ?? true))])
->class(['laravel-livewire-tables-reorderingMinimised' => ($isBootstrap) && ($customThAttributes['default'] ?? true)])
}}
>
diff --git a/resources/views/components/tools/filters/livewire-component-array-filter.blade.php b/resources/views/components/tools/filters/livewire-component-array-filter.blade.php
new file mode 100644
index 000000000..237d062fa
--- /dev/null
+++ b/resources/views/components/tools/filters/livewire-component-array-filter.blade.php
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/resources/views/components/tools/filters/livewire-component-filter.blade.php b/resources/views/components/tools/filters/livewire-component-filter.blade.php
index 89b407133..a430faf9f 100644
--- a/resources/views/components/tools/filters/livewire-component-filter.blade.php
+++ b/resources/views/components/tools/filters/livewire-component-filter.blade.php
@@ -1,5 +1,4 @@
-
-
+
diff --git a/resources/views/components/tools/toolbar/items/search-field.blade.php b/resources/views/components/tools/toolbar/items/search-field.blade.php
index 755cbab29..6bc8bb9c5 100644
--- a/resources/views/components/tools/toolbar/items/search-field.blade.php
+++ b/resources/views/components/tools/toolbar/items/search-field.blade.php
@@ -12,10 +12,10 @@
{{
$attributes->merge($this->getSearchFieldAttributes())
->class([
- 'block w-full rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 rounded-none rounded-l-md focus:ring-0 focus:border-gray-300' => $this->isTailwind && $this->hasSearch() && ($this->getSearchFieldAttributes()['default'] ?? true || $this->getSearchFieldAttributes()['default-styling'] ?? true),
- 'block w-full rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 rounded-md focus:ring focus:ring-opacity-50' => $this->isTailwind && !$this->hasSearch() && ($this->getSearchFieldAttributes()['default'] ?? true || $this->getSearchFieldAttributes()['default-styling'] ?? true),
- 'border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-gray-300' => $this->isTailwind && $this->hasSearch() && ($this->getSearchFieldAttributes()['default'] ?? true || $this->getSearchFieldAttributes()['default-colors'] ?? true),
- 'border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-indigo-300 focus:ring-indigo-200' => $this->isTailwind && !$this->hasSearch() && ($this->getSearchFieldAttributes()['default'] ?? true || $this->getSearchFieldAttributes()['default-colors'] ?? true),
+ 'block w-full rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 rounded-none rounded-l-md focus:ring-0 focus:border-gray-300' => $this->isTailwind && $this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-styling'] ?? true)),
+ 'block w-full rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 rounded-md focus:ring focus:ring-opacity-50' => $this->isTailwind && !$this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-styling'] ?? true)),
+ 'border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-gray-300' => $this->isTailwind && $this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-colors'] ?? true)),
+ 'border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-indigo-300 focus:ring-indigo-200' => $this->isTailwind && !$this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-colors'] ?? true)),
'form-control' => $this->isBootstrap && $this->getSearchFieldAttributes()['default'] ?? true,
])
diff --git a/src/Events/LaravelLivewireTablesEvent.php b/src/Events/LaravelLivewireTablesEvent.php
index 89026ead2..b1a034367 100644
--- a/src/Events/LaravelLivewireTablesEvent.php
+++ b/src/Events/LaravelLivewireTablesEvent.php
@@ -42,7 +42,7 @@ public function setTableForEvent(string $tableName): self
public function setUserForEvent(): self
{
- if (auth()->user()) {
+ if (config('livewire-tables.events.enableUserForEvent', true) && auth()->user()) {
$this->user = auth()->user();
}
diff --git a/src/Traits/ComponentUtilities.php b/src/Traits/ComponentUtilities.php
index 8cf7bad19..de24d0e72 100644
--- a/src/Traits/ComponentUtilities.php
+++ b/src/Traits/ComponentUtilities.php
@@ -48,6 +48,8 @@ trait ComponentUtilities
protected bool $useComputedProperties = true;
+ protected bool $hasRunConfigure = false;
+
/**
* Set any configuration options
*/
@@ -71,16 +73,7 @@ public function mountComponentUtilities(): void
*/
public function bootedComponentUtilities(): void
{
- // Fire Lifecycle Hooks for configuring
- $this->callHook('configuring');
- $this->callTraitHook('configuring');
-
- // Call the configure() method
- $this->configure();
-
- // Fire Lifecycle Hooks for configured
- $this->callHook('configured');
- $this->callTraitHook('configured');
+ $this->runCoreConfiguration();
// Make sure a primary key is set
if (! $this->hasPrimaryKey()) {
@@ -89,6 +82,25 @@ public function bootedComponentUtilities(): void
}
+ protected function runCoreConfiguration(): void
+ {
+ if (! $this->hasRunConfigure) {
+ // Fire Lifecycle Hooks for configuring
+ $this->callHook('configuring');
+ $this->callTraitHook('configuring');
+
+ // Call the configure() method
+ $this->configure();
+
+ // Fire Lifecycle Hooks for configured
+ $this->callHook('configured');
+ $this->callTraitHook('configured');
+
+ $this->hasRunConfigure = true;
+
+ }
+ }
+
/**
* Returns a unique id for the table, used as an alias to identify one table from another session and query string to prevent conflicts
*/
diff --git a/src/Traits/Configuration/LoadingPlaceholderConfiguration.php b/src/Traits/Configuration/LoadingPlaceholderConfiguration.php
index a88bcccda..1c7f7b988 100644
--- a/src/Traits/Configuration/LoadingPlaceholderConfiguration.php
+++ b/src/Traits/Configuration/LoadingPlaceholderConfiguration.php
@@ -32,27 +32,6 @@ public function setLoadingPlaceholderContent(string $content): self
return $this;
}
- public function setLoadingPlaceHolderAttributes(array $attributes): self
- {
- $this->loadingPlaceHolderAttributes = $attributes;
-
- return $this;
- }
-
- public function setLoadingPlaceHolderIconAttributes(array $attributes): self
- {
- $this->loadingPlaceHolderIconAttributes = $attributes;
-
- return $this;
- }
-
- public function setLoadingPlaceHolderWrapperAttributes(array $attributes): self
- {
- $this->loadingPlaceHolderWrapperAttributes = $attributes;
-
- return $this;
- }
-
public function setLoadingPlaceholderBlade(string $customBlade): self
{
$this->loadingPlaceholderBlade = $customBlade;
diff --git a/src/Traits/Configuration/QueryStringConfiguration.php b/src/Traits/Configuration/QueryStringConfiguration.php
index 771c640c2..fb0dedfad 100644
--- a/src/Traits/Configuration/QueryStringConfiguration.php
+++ b/src/Traits/Configuration/QueryStringConfiguration.php
@@ -14,7 +14,7 @@ public function setQueryStringAlias(string $queryStringAlias): self
public function setupQueryStringStatus(): void
{
if (! $this->hasQueryStringStatus()) {
- $this->configure();
+ $this->runCoreConfiguration();
if (! $this->hasQueryStringStatus()) {
$this->setQueryStringEnabled();
}
diff --git a/src/Traits/Core/QueryStrings/HasQueryString.php b/src/Traits/Core/QueryStrings/HasQueryString.php
new file mode 100644
index 000000000..7c1f567b6
--- /dev/null
+++ b/src/Traits/Core/QueryStrings/HasQueryString.php
@@ -0,0 +1,59 @@
+ [],
+ 'filter' => [],
+ 'search' => [],
+ 'sorts' => [],
+ ];
+
+ protected function getQueryStringConfig(string $type): array
+ {
+ return array_merge(['status' => null, 'alias' => null], ($this->queryStringConfig[$type] ?? []));
+ }
+
+ protected function hasQueryStringConfigStatus(string $type): bool
+ {
+ return isset($this->getQueryStringConfig($type)['status']);
+ }
+
+ protected function getQueryStringConfigStatus(string $type): bool
+ {
+ return $this->getQueryStringConfig($type)['status'] ?? $this->getQueryStringStatus();
+ }
+
+ protected function hasQueryStringConfigAlias(string $type): bool
+ {
+ return isset($this->getQueryStringConfig($type)['alias']);
+ }
+
+ protected function getQueryStringConfigAlias(string $type): string
+ {
+ return $this->getQueryStringConfig($type)['alias'] ?? $this->getQueryStringAlias().'-'.$type;
+ }
+
+ protected function setQueryStringConfig(string $type, array $config): self
+ {
+ $this->queryStringConfig[$type] = array_merge($this->getQueryStringConfig($type), $config);
+
+ return $this;
+ }
+
+ protected function setQueryStringConfigStatus(string $type, bool $status): self
+ {
+ return $this->setQueryStringConfig($type, ['status' => $status]);
+
+ }
+
+ protected function setQueryStringConfigAlias(string $type, string $alias): self
+ {
+ return $this->setQueryStringConfig($type, ['alias' => $alias]);
+ }
+}
diff --git a/src/Traits/Core/QueryStrings/HasQueryStringForFilter.php b/src/Traits/Core/QueryStrings/HasQueryStringForFilter.php
new file mode 100644
index 000000000..add0a331f
--- /dev/null
+++ b/src/Traits/Core/QueryStrings/HasQueryStringForFilter.php
@@ -0,0 +1,84 @@
+queryStringForFilterIsEnabled()) ?
+ [
+ 'appliedFilters' => ['except' => null, 'history' => false, 'keep' => false, 'as' => $this->getQueryStringAliasForFilter()],
+ 'filterComponents' => ['except' => null, 'history' => false, 'keep' => false, 'as' => $this->getQueryStringAliasForFilter()],
+ ] : [];
+ }
+
+ protected function setupQueryStringStatusForFilter(): void
+ {
+ if (! $this->hasQueryStringStatusForFilter()) {
+ $this->setQueryStringForFilterEnabled();
+ }
+ }
+
+ public function hasQueryStringStatusForFilter(): bool
+ {
+ return isset($this->queryStringStatusForFilter);
+ }
+
+ public function getQueryStringStatusForFilter(): bool
+ {
+ return $this->queryStringStatusForFilter ?? true;
+ }
+
+ public function queryStringForFilterIsEnabled(): bool
+ {
+ $this->setupQueryStringStatusForFilter();
+
+ return $this->getQueryStringStatusForFilter() && $this->filtersAreEnabled();
+ }
+
+ public function setQueryStringStatusForFilter(bool $status): self
+ {
+ $this->queryStringStatusForFilter = $status;
+
+ return $this;
+ }
+
+ public function setQueryStringForFilterEnabled(): self
+ {
+ $this->setQueryStringStatusForFilter(true);
+
+ return $this;
+ }
+
+ public function setQueryStringForFilterDisabled(): self
+ {
+ $this->setQueryStringStatusForFilter(false);
+
+ return $this;
+ }
+
+ public function hasQueryStringAliasForFilter(): bool
+ {
+ return isset($this->queryStringAliasForFilter);
+ }
+
+ public function getQueryStringAliasForFilter(): string
+ {
+ return $this->queryStringAliasForFilter ?? $this->getQueryStringAlias().'-filters';
+ }
+
+ public function setQueryStringAliasForFilter(string $alias): self
+ {
+ $this->queryStringAliasForFilter = $alias;
+
+ return $this;
+ }
+}
diff --git a/src/Traits/Core/QueryStrings/HasQueryStringForSearch.php b/src/Traits/Core/QueryStrings/HasQueryStringForSearch.php
new file mode 100644
index 000000000..c987e4ccc
--- /dev/null
+++ b/src/Traits/Core/QueryStrings/HasQueryStringForSearch.php
@@ -0,0 +1,66 @@
+queryStringForSearchEnabled() && $this->searchIsEnabled()) ? ['search' => ['except' => null, 'history' => false, 'keep' => false, 'as' => $this->getQueryStringAliasForSearch()]] : [];
+
+ }
+
+ protected function setupQueryStringStatusForSearch(): void
+ {
+ if (! $this->hasQueryStringStatusForSearch()) {
+ $this->setQueryStringForSearchEnabled();
+ }
+ }
+
+ public function hasQueryStringStatusForSearch(): bool
+ {
+ return $this->hasQueryStringConfigStatus('search');
+ }
+
+ public function getQueryStringStatusForSearch(): bool
+ {
+ return $this->getQueryStringConfigStatus('search');
+ }
+
+ public function queryStringForSearchEnabled(): bool
+ {
+ $this->setupQueryStringStatusForSearch();
+
+ return $this->getQueryStringStatusForSearch() && $this->searchIsEnabled();
+ }
+
+ public function setQueryStringStatusForSearch(bool $status): self
+ {
+ return $this->setQueryStringConfigStatus('search', $status);
+ }
+
+ public function setQueryStringForSearchEnabled(): self
+ {
+ return $this->setQueryStringStatusForSearch(true);
+ }
+
+ public function setQueryStringForSearchDisabled(): self
+ {
+ return $this->setQueryStringStatusForSearch(false);
+ }
+
+ public function hasQueryStringAliasForSearch(): bool
+ {
+ return $this->hasQueryStringConfigAlias('search');
+ }
+
+ public function getQueryStringAliasForSearch(): string
+ {
+ return $this->getQueryStringConfigAlias('search');
+ }
+
+ public function setQueryStringAliasForSearch(string $alias): self
+ {
+ return $this->setQueryStringConfigAlias('search', $alias);
+ }
+}
diff --git a/src/Traits/Core/QueryStrings/HasQueryStringForSort.php b/src/Traits/Core/QueryStrings/HasQueryStringForSort.php
new file mode 100644
index 000000000..cbdad07af
--- /dev/null
+++ b/src/Traits/Core/QueryStrings/HasQueryStringForSort.php
@@ -0,0 +1,66 @@
+queryStringForSortEnabled() && $this->sortingIsEnabled()) ? ['sorts' => ['except' => null, 'history' => false, 'keep' => false, 'as' => $this->getQueryStringAliasForSort()]] : [];
+
+ }
+
+ protected function setupQueryStringStatusForSort(): void
+ {
+ if (! $this->hasQueryStringStatusForSort()) {
+ $this->setQueryStringForSortEnabled();
+ }
+ }
+
+ public function hasQueryStringStatusForSort(): bool
+ {
+ return $this->hasQueryStringConfigStatus('sorts');
+ }
+
+ public function getQueryStringStatusForSort(): bool
+ {
+ return $this->getQueryStringConfigStatus('sorts');
+ }
+
+ public function queryStringForSortEnabled(): bool
+ {
+ $this->setupQueryStringStatusForSort();
+
+ return $this->getQueryStringStatusForSort() && $this->sortingIsEnabled();
+ }
+
+ public function setQueryStringStatusForSort(bool $status): self
+ {
+ return $this->setQueryStringConfigStatus('sorts', $status);
+ }
+
+ public function setQueryStringForSortEnabled(): self
+ {
+ return $this->setQueryStringStatusForSort(true);
+ }
+
+ public function setQueryStringForSortDisabled(): self
+ {
+ return $this->setQueryStringStatusForSort(false);
+ }
+
+ public function hasQueryStringAliasForSort(): bool
+ {
+ return $this->hasQueryStringConfigAlias('sorts');
+ }
+
+ public function getQueryStringAliasForSort(): string
+ {
+ return $this->getQueryStringConfigAlias('sorts');
+ }
+
+ public function setQueryStringAliasForSort(string $alias): self
+ {
+ return $this->setQueryStringConfigAlias('sorts', $alias);
+ }
+}
diff --git a/src/Traits/HasAllTraits.php b/src/Traits/HasAllTraits.php
index 70ddd3eb5..b8da012d7 100644
--- a/src/Traits/HasAllTraits.php
+++ b/src/Traits/HasAllTraits.php
@@ -14,6 +14,7 @@ trait HasAllTraits
use ComponentUtilities,
WithActions,
WithData,
+ WithQueryString,
WithColumns,
WithSorting,
WithSearch,
@@ -28,7 +29,6 @@ trait HasAllTraits
WithEvents,
WithFilters,
WithFooter,
- WithQueryString,
WithRefresh,
WithReordering,
WithSecondaryHeader,
diff --git a/src/Traits/Helpers/FilterHelpers.php b/src/Traits/Helpers/FilterHelpers.php
index 056500190..d9bfddf51 100644
--- a/src/Traits/Helpers/FilterHelpers.php
+++ b/src/Traits/Helpers/FilterHelpers.php
@@ -345,4 +345,14 @@ public function showFilterPillsSection(): bool
{
return $this->filtersAreEnabled() && $this->filterPillsAreEnabled() && $this->hasAppliedVisibleFiltersForPills();
}
+
+ #[On('livewireArrayFilterUpdateValues')]
+ public function updateLivewireArrayFilterValues(string $filterKey, string $tableName, array $values): void
+ {
+ if ($this->tableName == $tableName) {
+ $filter = $this->getFilterByKey($filterKey);
+ $filter->options($values);
+ }
+
+ }
}
diff --git a/src/Traits/Helpers/LoadingPlaceholderHelpers.php b/src/Traits/Helpers/LoadingPlaceholderHelpers.php
index 4a5a9e7e7..cd43c583f 100644
--- a/src/Traits/Helpers/LoadingPlaceholderHelpers.php
+++ b/src/Traits/Helpers/LoadingPlaceholderHelpers.php
@@ -16,23 +16,7 @@ public function getDisplayLoadingPlaceholder(): bool
public function getLoadingPlaceholderContent(): string
{
- return $this->loadingPlaceholderContent ?? __('livewire-tables:loading');
- }
-
- public function getLoadingPlaceholderAttributes(): array
- {
- return count($this->loadingPlaceHolderAttributes) ? $this->loadingPlaceHolderAttributes : ['default' => true];
-
- }
-
- public function getLoadingPlaceHolderIconAttributes(): array
- {
- return count($this->loadingPlaceHolderIconAttributes) ? $this->loadingPlaceHolderIconAttributes : ['default' => true];
- }
-
- public function getLoadingPlaceHolderWrapperAttributes(): array
- {
- return count($this->loadingPlaceHolderWrapperAttributes) ? $this->loadingPlaceHolderWrapperAttributes : ['default' => true];
+ return $this->loadingPlaceholderContent ?? __('livewire-tables::loading');
}
public function hasLoadingPlaceholderBlade(): bool
diff --git a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php
new file mode 100644
index 000000000..c07780bdc
--- /dev/null
+++ b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php
@@ -0,0 +1,34 @@
+setCustomAttributes('loadingPlaceHolderAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderAttributes', default: false, classicMode: true), ...$attributes]);
+
+ return $this;
+ }
+
+ public function setLoadingPlaceHolderIconAttributes(array $attributes): self
+ {
+ $this->setCustomAttributes('loadingPlaceHolderIconAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderIconAttributes', default: false, classicMode: true), ...$attributes]);
+
+ return $this;
+ }
+
+ public function setLoadingPlaceHolderRowAttributes(array $attributes): self
+ {
+ $this->setCustomAttributes('loadingPlaceHolderRowAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: false, classicMode: true), ...$attributes]);
+
+ return $this;
+ }
+
+ public function setLoadingPlaceHolderWrapperAttributes(array $attributes): self
+ {
+ $this->setCustomAttributes('loadingPlaceHolderRowAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: false, classicMode: true), ...$attributes]);
+
+ return $this;
+ }
+}
diff --git a/src/Traits/Styling/HasLoadingPlaceholderStyling.php b/src/Traits/Styling/HasLoadingPlaceholderStyling.php
new file mode 100644
index 000000000..1dbb2b80d
--- /dev/null
+++ b/src/Traits/Styling/HasLoadingPlaceholderStyling.php
@@ -0,0 +1,22 @@
+ '', 'default' => true];
+}
diff --git a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php
new file mode 100644
index 000000000..ef115641f
--- /dev/null
+++ b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php
@@ -0,0 +1,36 @@
+getCustomAttributes(propertyName: 'loadingPlaceHolderAttributes', default: true, classicMode: true);
+
+ }
+
+ public function getLoadingPlaceHolderIconAttributes(): array
+ {
+ return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderIconAttributes', default: true, classicMode: true);
+
+ }
+
+ public function getLoadingPlaceHolderWrapperAttributes(): array
+ {
+ return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: true, classicMode: true);
+ }
+
+ public function getLoadingPlaceHolderRowAttributes(): array
+ {
+ return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: true, classicMode: true);
+ }
+
+ public function getLoadingPlaceHolderCellAttributes(): array
+ {
+ return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderCellAttributes', default: true, classicMode: true);
+
+ }
+}
diff --git a/src/Traits/WithFilters.php b/src/Traits/WithFilters.php
index 3c2ff58c5..e9469ea44 100644
--- a/src/Traits/WithFilters.php
+++ b/src/Traits/WithFilters.php
@@ -7,12 +7,14 @@
use Livewire\Attributes\Locked;
use Rappasoft\LaravelLivewireTables\Events\FilterApplied;
use Rappasoft\LaravelLivewireTables\Traits\Configuration\FilterConfiguration;
+use Rappasoft\LaravelLivewireTables\Traits\Core\QueryStrings\HasQueryStringForFilter;
use Rappasoft\LaravelLivewireTables\Traits\Helpers\FilterHelpers;
trait WithFilters
{
use FilterConfiguration,
FilterHelpers;
+ use HasQueryStringForFilter;
#[Locked]
public bool $filtersStatus = true;
@@ -47,18 +49,6 @@ public function filters(): array
return [];
}
- protected function queryStringWithFilters(): array
- {
- if ($this->queryStringIsEnabled() && $this->filtersAreEnabled()) {
- return [
- 'appliedFilters' => ['except' => null, 'history' => false, 'keep' => false, 'as' => $this->getQueryStringAlias().'-filters'],
- 'filterComponents' => ['except' => null, 'history' => false, 'keep' => false, 'as' => $this->getQueryStringAlias().'-filters'],
- ];
- }
-
- return [];
- }
-
public function applyFilters(): Builder
{
if ($this->filtersAreEnabled() && $this->hasFilters() && $this->hasAppliedFiltersWithValues()) {
diff --git a/src/Traits/WithLoadingPlaceholder.php b/src/Traits/WithLoadingPlaceholder.php
index 47c3a3072..130b6d51b 100644
--- a/src/Traits/WithLoadingPlaceholder.php
+++ b/src/Traits/WithLoadingPlaceholder.php
@@ -4,21 +4,17 @@
use Rappasoft\LaravelLivewireTables\Traits\Configuration\LoadingPlaceholderConfiguration;
use Rappasoft\LaravelLivewireTables\Traits\Helpers\LoadingPlaceholderHelpers;
+use Rappasoft\LaravelLivewireTables\Traits\Styling\HasLoadingPlaceholderStyling;
trait WithLoadingPlaceholder
{
use LoadingPlaceholderConfiguration,
- LoadingPlaceholderHelpers;
+ LoadingPlaceholderHelpers,
+ HasLoadingPlaceholderStyling;
protected bool $displayLoadingPlaceholder = false;
protected string $loadingPlaceholderContent = 'Loading';
protected ?string $loadingPlaceholderBlade = null;
-
- protected array $loadingPlaceHolderAttributes = [];
-
- protected array $loadingPlaceHolderIconAttributes = [];
-
- protected array $loadingPlaceHolderWrapperAttributes = [];
}
diff --git a/src/Traits/WithQueryString.php b/src/Traits/WithQueryString.php
index ccc11d5e9..56dee3699 100644
--- a/src/Traits/WithQueryString.php
+++ b/src/Traits/WithQueryString.php
@@ -4,12 +4,14 @@
use Livewire\Attributes\Locked;
use Rappasoft\LaravelLivewireTables\Traits\Configuration\QueryStringConfiguration;
+use Rappasoft\LaravelLivewireTables\Traits\Core\QueryStrings\HasQueryString;
use Rappasoft\LaravelLivewireTables\Traits\Helpers\QueryStringHelpers;
trait WithQueryString
{
use QueryStringConfiguration,
QueryStringHelpers;
+ use HasQueryString;
#[Locked]
public ?bool $queryStringStatus;
diff --git a/src/Traits/WithSearch.php b/src/Traits/WithSearch.php
index 0d86e1397..ddfe98553 100644
--- a/src/Traits/WithSearch.php
+++ b/src/Traits/WithSearch.php
@@ -6,12 +6,14 @@
use Livewire\Attributes\Locked;
use Rappasoft\LaravelLivewireTables\Events\SearchApplied;
use Rappasoft\LaravelLivewireTables\Traits\Configuration\SearchConfiguration;
+use Rappasoft\LaravelLivewireTables\Traits\Core\QueryStrings\HasQueryStringForSearch;
use Rappasoft\LaravelLivewireTables\Traits\Helpers\SearchHelpers;
trait WithSearch
{
use SearchConfiguration,
SearchHelpers;
+ use HasQueryStringForSearch;
public string $search = '';
@@ -38,17 +40,6 @@ trait WithSearch
protected bool $trimSearchString = false;
- protected function queryStringWithSearch(): array
- {
- if ($this->queryStringIsEnabled() && $this->searchIsEnabled()) {
- return [
- 'search' => ['except' => null, 'history' => false, 'keep' => false, 'as' => $this->getQueryStringAlias().'-search'],
- ];
- }
-
- return [];
- }
-
// TODO
public function applySearch(): Builder
{
diff --git a/src/Traits/WithSorting.php b/src/Traits/WithSorting.php
index 78c8e9a73..1ed30366e 100644
--- a/src/Traits/WithSorting.php
+++ b/src/Traits/WithSorting.php
@@ -6,12 +6,14 @@
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;
trait WithSorting
{
use SortingConfiguration,
SortingHelpers;
+ use HasQueryStringForSort;
public array $sorts = [];
@@ -31,17 +33,6 @@ trait WithSorting
public string $defaultSortingLabelDesc = 'Z-A';
- public function queryStringWithSorting(): array
- {
- if ($this->queryStringIsEnabled() && $this->sortingIsEnabled()) {
- return [
- 'sorts' => ['except' => null, 'history' => false, 'keep' => false, 'as' => $this->getQueryStringAlias().'-sorts'],
- ];
- }
-
- return [];
- }
-
public function sortBy(string $columnSelectName): ?string
{
diff --git a/src/Views/Columns/BooleanColumn.php b/src/Views/Columns/BooleanColumn.php
index 38dcf7216..30716b0e3 100644
--- a/src/Views/Columns/BooleanColumn.php
+++ b/src/Views/Columns/BooleanColumn.php
@@ -45,6 +45,7 @@ public function getContents(Model $row): null|string|\Illuminate\Support\HtmlStr
->withIsBootstrap($this->isBootstrap())
->withSuccessValue($this->getSuccessValue())
->withType($this->getType())
+ ->withValue($value)
->withStatus($this->hasCallback() ? call_user_func($this->getCallback(), $value, $row) : (bool) $value === true);
}
}
diff --git a/src/Views/Filters/LivewireComponentArrayFilter.php b/src/Views/Filters/LivewireComponentArrayFilter.php
new file mode 100644
index 000000000..ad995b3dc
--- /dev/null
+++ b/src/Views/Filters/LivewireComponentArrayFilter.php
@@ -0,0 +1,58 @@
+filterDefaultValue ?? null;
+ }
+
+ public function getFilterPillValue($value): array|string|bool|null
+ {
+ $values = [];
+ foreach ($value as $key => $item) {
+
+ $found = $this->getCustomFilterPillValue($item) ?? ($this->options[$item] ?? $item);
+ if ($found) {
+ $values[] = $found;
+ }
+ }
+
+ return $values;
+ }
+
+ public function getKeys(): array
+ {
+ return array_keys($this->options ?? []);
+ }
+}
diff --git a/src/Views/Filters/LivewireComponentFilter.php b/src/Views/Filters/LivewireComponentFilter.php
index cfcf29e8c..8605c2e99 100644
--- a/src/Views/Filters/LivewireComponentFilter.php
+++ b/src/Views/Filters/LivewireComponentFilter.php
@@ -5,17 +5,17 @@
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Filter;
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasWireables;
+use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\IsLivewireComponentFilter;
class LivewireComponentFilter extends Filter
{
use HasWireables;
+ use IsLivewireComponentFilter;
public string $wireMethod = 'blur';
protected string $view = 'livewire-tables::components.tools.filters.livewire-component-filter';
- public string $livewireComponent = '';
-
public function validate(string $value): string|bool
{
return $value;
@@ -33,38 +33,4 @@ public function getFilterDefaultValue(): ?string
{
return $this->filterDefaultValue ?? null;
}
-
- public function setLivewireComponent(string $livewireComponent): self
- {
-
- $class = '\\'.config('livewire.class_namespace').'\\'.collect(str($livewireComponent)->explode('.'))->map(fn ($segment) => (string) str($segment)->studly())->join('\\');
-
- if (! class_exists($class)) {
- throw new DataTableConfigurationException('You must specify a valid path to your Livewire Component Filter.');
- }
-
- if (! is_subclass_of($class, \Livewire\Component::class)) {
- throw new DataTableConfigurationException('Your Livewire Component Filter MUST Extend Livewire\Component.');
- }
-
- $this->livewireComponent = $livewireComponent;
-
- return $this;
- }
-
- public function getLivewireComponent(): string
- {
- return $this->livewireComponent ?? '';
- }
-
- public function render(): string|\Illuminate\Contracts\Foundation\Application|\Illuminate\View\View|\Illuminate\View\Factory
- {
- if ($this->livewireComponent == '') {
- throw new DataTableConfigurationException('You must specify a valid path to your Livewire Component Filter.');
- }
-
- return view($this->getViewPath(), $this->getFilterDisplayData())->with([
- 'livewireComponent' => $this->livewireComponent,
- ]);
- }
}
diff --git a/src/Views/Traits/Filters/HasOptions.php b/src/Views/Traits/Filters/HasOptions.php
index 3447fe660..a8e39a363 100644
--- a/src/Views/Traits/Filters/HasOptions.php
+++ b/src/Views/Traits/Filters/HasOptions.php
@@ -33,7 +33,7 @@ public function options(array $options = []): self
public function getOptions(): array
{
- return $this->options ?? $this->options = config($this->optionsPath, []);
+ return $this->options ?? $this->options = (property_exists($this, 'optionsPath') ? config($this->optionsPath, []) : []);
}
public function getKeys(): array
diff --git a/src/Views/Traits/Filters/IsLivewireComponentFilter.php b/src/Views/Traits/Filters/IsLivewireComponentFilter.php
new file mode 100644
index 000000000..fbcf83d0a
--- /dev/null
+++ b/src/Views/Traits/Filters/IsLivewireComponentFilter.php
@@ -0,0 +1,44 @@
+explode('.'))->map(fn ($segment) => (string) str($segment)->studly())->join('\\');
+
+ if (! class_exists($class)) {
+ throw new DataTableConfigurationException('You must specify a valid path to your Livewire Component Filter.');
+ }
+
+ if (! is_subclass_of($class, \Livewire\Component::class)) {
+ throw new DataTableConfigurationException('Your Livewire Component Filter MUST Extend Livewire\Component.');
+ }
+
+ $this->livewireComponent = $livewireComponent;
+
+ return $this;
+ }
+
+ public function getLivewireComponent(): string
+ {
+ return $this->livewireComponent ?? '';
+ }
+
+ public function render(): string|\Illuminate\Contracts\Foundation\Application|\Illuminate\View\View|\Illuminate\View\Factory
+ {
+ if ($this->livewireComponent == '') {
+ throw new DataTableConfigurationException('You must specify a valid path to your Livewire Component Filter.');
+ }
+
+ return view($this->getViewPath(), $this->getFilterDisplayData())->with([
+ 'livewireComponent' => $this->livewireComponent,
+ ]);
+ }
+}
diff --git a/src/Views/Traits/IsExternalArrayFilter.php b/src/Views/Traits/IsExternalArrayFilter.php
new file mode 100644
index 000000000..480d36e82
--- /dev/null
+++ b/src/Views/Traits/IsExternalArrayFilter.php
@@ -0,0 +1,73 @@
+tableName && $filterKey == $this->filterKey && $this->selectedItems != $value) {
+ $this->selectedItems = $value;
+ $this->needsUpdating = false;
+
+ }
+ }
+
+ protected function clearFilter() {}
+
+ #[Renderless]
+ public function updatedSelectedItems(string $value): void
+ {
+ if (! $this->needsUpdating) {
+ $this->needsUpdating = true;
+
+ }
+ }
+
+ #[Renderless]
+ protected function sendUpdateDispatch(array $returnValues): void
+ {
+ if ($this->needsUpdating) {
+ if (! empty($returnValues)) {
+ $this->value = array_keys($returnValues);
+ } else {
+ $this->value = [];
+ }
+ $this->dispatch('livewireArrayFilterUpdateValues', tableName: $this->tableName, filterKey: $this->filterKey, values: $returnValues)->to($this->tableComponent);
+
+ }
+ }
+
+ #[Renderless]
+ public function renderingIsExternalArrayFilter(): void
+ {
+ $returnValues = [];
+
+ if ($this->needsUpdating == true && ! empty($this->selectedItems)) {
+ foreach ($this->selectedItems as $selectedItem) {
+ $returnValues[$selectedItem] = $this->selectOptions[$selectedItem] ?? 'Unknown';
+ }
+ $this->sendUpdateDispatch($returnValues);
+ }
+ }
+}
diff --git a/tests/Events/ColumnsSelectedTest.php b/tests/Events/ColumnsSelectedTest.php
index 197b1450f..bf32df5a6 100644
--- a/tests/Events/ColumnsSelectedTest.php
+++ b/tests/Events/ColumnsSelectedTest.php
@@ -80,4 +80,24 @@ public function test_an_event_is_emitted_when_a_column_selection_are_updated_and
return $event->columns == [] && $event->user->id == '1234' && $event->tableName == $this->basicTable->getTableName();
});
}
+
+ public function test_user_not_set_on_event_when_a_column_selection_is_updated_and_user_for_event_disabled()
+ {
+ Event::fake();
+
+ config()->set('livewire-tables.events.enableUserForEvent', false);
+
+ $user = new \Illuminate\Foundation\Auth\User;
+ $user->id = '1234';
+ $user->name = 'Bob';
+ $this->actingAs($user);
+
+ $this->basicTable->selectAllColumns();
+
+ Event::assertDispatched(ColumnsSelected::class, function ($event) {
+ $this->assertFalse(isset($event->user), 'User set on Event when config is set to disable this behavior');
+
+ return true;
+ });
+ }
}
diff --git a/tests/Events/FilterAppliedTest.php b/tests/Events/FilterAppliedTest.php
index ef59c5719..612530494 100644
--- a/tests/Events/FilterAppliedTest.php
+++ b/tests/Events/FilterAppliedTest.php
@@ -61,4 +61,24 @@ public function test_an_event_is_emitted_when_a_filter_is_applied_with_values_an
return $event->value == 'test value' && $event->user->id == '1234' && $event->key = 'pet_name_filter' && $event->tableName == $this->basicTable->getTableName();
});
}
+
+ public function test_user_not_set_on_event_when_a_filter_is_applied_and_user_for_event_disabled()
+ {
+ Event::fake();
+
+ config()->set('livewire-tables.events.enableUserForEvent', false);
+
+ $user = new \Illuminate\Foundation\Auth\User;
+ $user->id = '1234';
+ $user->name = 'Bob';
+ $this->actingAs($user);
+
+ $this->basicTable->enableFilterAppliedEvent()->setFilter('pet_name_filter', 'test value');
+
+ Event::assertDispatched(FilterApplied::class, function ($event) {
+ $this->assertFalse(isset($event->user), 'User set on Event when config is set to disable this behavior');
+
+ return true;
+ });
+ }
}
diff --git a/tests/Events/SearchAppliedTest.php b/tests/Events/SearchAppliedTest.php
index d7abc2bc7..d76af688e 100644
--- a/tests/Events/SearchAppliedTest.php
+++ b/tests/Events/SearchAppliedTest.php
@@ -71,4 +71,24 @@ public function test_an_event_is_emitted_when_a_search_is_applied_and_event_enab
return $event->value == 'test search value' && $event->user->id == '1234' && $event->tableName == $this->basicTable->getTableName();
});
}
+
+ public function test_user_not_set_on_event_when_a_search_is_applied_and_user_for_event_disabled()
+ {
+ Event::fake();
+
+ config()->set('livewire-tables.events.enableUserForEvent', false);
+
+ $user = new \Illuminate\Foundation\Auth\User;
+ $user->id = '1234';
+ $user->name = 'Bob';
+ $this->actingAs($user);
+
+ $this->basicTable->enableSearchAppliedEvent()->setSearch('test')->applySearch();
+
+ Event::assertDispatched(SearchApplied::class, function ($event) {
+ $this->assertFalse(isset($event->user), 'User set on Event when config is set to disable this behavior');
+
+ return true;
+ });
+ }
}
diff --git a/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php b/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php
index 1206f1608..28a3b97ad 100644
--- a/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php
+++ b/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php
@@ -48,11 +48,19 @@ public function test_can_set_loading_placeholder_attributes(): void
{
$this->basicTable->setLoadingPlaceholderEnabled();
- $this->assertSame(['default' => true], $this->basicTable->getLoadingPlaceHolderAttributes());
+ $this->assertSame(['default' => true, 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderAttributes());
$this->basicTable->setLoadingPlaceHolderAttributes(['class' => 'test12345']);
- $this->assertSame(['class' => 'test12345'], $this->basicTable->getLoadingPlaceHolderAttributes());
+ $this->assertSame(['class' => 'test12345', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderAttributes());
+
+ $this->basicTable->setLoadingPlaceHolderAttributes(['class' => 'test12345', 'default' => true, 'default-colors' => true, 'default-styling' => true]);
+
+ $this->assertSame(['class' => 'test12345', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderAttributes());
+
+ $this->basicTable->setLoadingPlaceHolderAttributes(['class' => 'test12345', 'default' => false, 'default-colors' => false, 'default-styling' => true]);
+
+ $this->assertSame(['class' => 'test12345', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderAttributes());
}
@@ -60,11 +68,19 @@ public function test_can_set_loading_placeholder_icon_attributes(): void
{
$this->basicTable->setLoadingPlaceholderEnabled();
- $this->assertSame(['default' => true], $this->basicTable->getLoadingPlaceHolderIconAttributes());
+ $this->assertSame(['default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderIconAttributes());
$this->basicTable->setLoadingPlaceHolderIconAttributes(['class' => 'test123']);
- $this->assertSame(['class' => 'test123'], $this->basicTable->getLoadingPlaceHolderIconAttributes());
+ $this->assertSame(['class' => 'test123', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderIconAttributes());
+
+ $this->basicTable->setLoadingPlaceHolderIconAttributes(['class' => 'test123', 'default' => true, 'default-colors' => true, 'default-styling' => true]);
+
+ $this->assertSame(['class' => 'test123', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderIconAttributes());
+
+ $this->basicTable->setLoadingPlaceHolderIconAttributes(['class' => 'test123', 'default' => false, 'default-colors' => false, 'default-styling' => true]);
+
+ $this->assertSame(['class' => 'test123', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderIconAttributes());
}
@@ -72,11 +88,47 @@ public function test_can_set_loading_placeholder_wrapper_attributes(): void
{
$this->basicTable->setLoadingPlaceholderEnabled();
- $this->assertSame(['default' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
+ $this->assertSame(['default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
+ $this->assertSame(['default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes());
$this->basicTable->setLoadingPlaceHolderWrapperAttributes(['class' => 'test1234567-wrapper']);
- $this->assertSame(['class' => 'test1234567-wrapper'], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
+ $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
+ $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderRowAttributes());
+
+ $this->basicTable->setLoadingPlaceHolderWrapperAttributes(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true]);
+
+ $this->assertSame(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
+ $this->assertSame(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes());
+
+ $this->basicTable->setLoadingPlaceHolderWrapperAttributes(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true]);
+
+ $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
+ $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes());
+
+ }
+
+ public function test_can_set_loading_placeholder_row_attributes(): void
+ {
+ $this->basicTable->setLoadingPlaceholderEnabled();
+
+ $this->assertSame(['default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes());
+
+ $this->basicTable->setLoadingPlaceHolderRowAttributes(['class' => 'test1234567-wrapper']);
+
+ $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderRowAttributes());
+ $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
+
+ $this->basicTable->setLoadingPlaceHolderRowAttributes(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true]);
+
+ $this->assertSame(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes());
+ $this->assertSame(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
+
+ $this->basicTable->setLoadingPlaceHolderRowAttributes(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true]);
+
+ $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes());
+ $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
+
}
public function test_can_set_loading_placeholder_custom_blade(): void
diff --git a/tests/Traits/Core/QueryStrings/QueryStringForFiltersTest.php b/tests/Traits/Core/QueryStrings/QueryStringForFiltersTest.php
new file mode 100644
index 000000000..6ee41bccb
--- /dev/null
+++ b/tests/Traits/Core/QueryStrings/QueryStringForFiltersTest.php
@@ -0,0 +1,110 @@
+setDataTableFingerprint('test');
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame(true, $mock->getQueryStringStatusForFilter());
+ }
+
+ public function test_can_disable_filter_query_string_status(): void
+ {
+ $mock = new class extends PetsTable
+ {
+ public ?array $testAttributesArray;
+
+ public function configure(): void
+ {
+ $this->setDataTableFingerprint('test');
+ $this->setQueryStringForFilterDisabled();
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame(false, $mock->getQueryStringStatusForFilter());
+ }
+
+ public function test_can_enable_filter_query_string_status(): void
+ {
+ $mock = new class extends PetsTable
+ {
+ public ?array $testAttributesArray;
+
+ public function configure(): void
+ {
+ $this->setDataTableFingerprint('test');
+ $this->setQueryStringForFilterDisabled();
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame(false, $mock->getQueryStringStatusForFilter());
+ $mock->setQueryStringForFilterEnabled();
+ $this->assertSame(true, $mock->getQueryStringStatusForFilter());
+
+ }
+
+ public function test_can_get_default_filter_query_string_alias(): void
+ {
+ $mock = new class extends PetsTable
+ {
+ public ?array $testAttributesArray;
+
+ public function configure(): void
+ {
+ $this->setDataTableFingerprint('test');
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame('table-filters', $mock->getQueryStringAliasForFilter());
+
+ }
+
+ public function test_can_change_default_filter_query_string_alias(): void
+ {
+ $mock = new class extends PetsTable
+ {
+ public ?array $testAttributesArray;
+
+ public function configure(): void
+ {
+ $this->setDataTableFingerprint('test');
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame('table-filters', $mock->getQueryStringAliasForFilter());
+ $mock->setQueryStringAliasForFilter('pet-filters');
+ $this->assertSame('pet-filters', $mock->getQueryStringAliasForFilter());
+ $this->assertTrue($mock->hasQueryStringAliasForFilter());
+ }
+}
diff --git a/tests/Traits/Core/QueryStrings/QueryStringForSearchTest.php b/tests/Traits/Core/QueryStrings/QueryStringForSearchTest.php
new file mode 100644
index 000000000..6fb3c5a71
--- /dev/null
+++ b/tests/Traits/Core/QueryStrings/QueryStringForSearchTest.php
@@ -0,0 +1,110 @@
+setDataTableFingerprint('test');
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame(true, $mock->getQueryStringStatusForSearch());
+ }
+
+ public function test_can_disable_search_query_string_status(): void
+ {
+ $mock = new class extends PetsTable
+ {
+ public ?array $testAttributesArray;
+
+ public function configure(): void
+ {
+ $this->setDataTableFingerprint('test');
+ $this->setQueryStringForSearchDisabled();
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame(false, $mock->getQueryStringStatusForSearch());
+ }
+
+ public function test_can_enable_search_query_string_status(): void
+ {
+ $mock = new class extends PetsTable
+ {
+ public ?array $testAttributesArray;
+
+ public function configure(): void
+ {
+ $this->setDataTableFingerprint('test');
+ $this->setQueryStringForSearchDisabled();
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame(false, $mock->getQueryStringStatusForSearch());
+ $mock->setQueryStringForSearchEnabled();
+ $this->assertSame(true, $mock->getQueryStringStatusForSearch());
+
+ }
+
+ public function test_can_get_default_search_query_string_alias(): void
+ {
+ $mock = new class extends PetsTable
+ {
+ public ?array $testAttributesArray;
+
+ public function configure(): void
+ {
+ $this->setDataTableFingerprint('test');
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame('table-search', $mock->getQueryStringAliasForSearch());
+ }
+
+ public function test_can_change_default_search_query_string_alias(): void
+ {
+ $mock = new class extends PetsTable
+ {
+ public ?array $testAttributesArray;
+
+ public function configure(): void
+ {
+ $this->setDataTableFingerprint('test');
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertFalse($mock->hasQueryStringAliasForSearch());
+ $this->assertSame('table-search', $mock->getQueryStringAliasForSearch());
+ $mock->setQueryStringAliasForSearch('pet-search');
+ $this->assertSame('pet-search', $mock->getQueryStringAliasForSearch());
+ $this->assertTrue($mock->hasQueryStringAliasForSearch());
+ }
+}
diff --git a/tests/Traits/Core/QueryStrings/QueryStringForSortTest.php b/tests/Traits/Core/QueryStrings/QueryStringForSortTest.php
new file mode 100644
index 000000000..7db6d3eb9
--- /dev/null
+++ b/tests/Traits/Core/QueryStrings/QueryStringForSortTest.php
@@ -0,0 +1,110 @@
+setDataTableFingerprint('test');
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame(true, $mock->getQueryStringStatusForSort());
+ }
+
+ public function test_can_disable_sort_query_string_status(): void
+ {
+ $mock = new class extends PetsTable
+ {
+ public ?array $testAttributesArray;
+
+ public function configure(): void
+ {
+ $this->setDataTableFingerprint('test');
+ $this->setQueryStringForSortDisabled();
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame(false, $mock->getQueryStringStatusForSort());
+ }
+
+ public function test_can_enable_sort_query_string_status(): void
+ {
+ $mock = new class extends PetsTable
+ {
+ public ?array $testAttributesArray;
+
+ public function configure(): void
+ {
+ $this->setDataTableFingerprint('test');
+ $this->setQueryStringForSortDisabled();
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame(false, $mock->getQueryStringStatusForSort());
+ $mock->setQueryStringForSortEnabled();
+ $this->assertSame(true, $mock->getQueryStringStatusForSort());
+
+ }
+
+ public function test_can_get_default_sort_query_string_alias(): void
+ {
+ $mock = new class extends PetsTable
+ {
+ public ?array $testAttributesArray;
+
+ public function configure(): void
+ {
+ $this->setDataTableFingerprint('test');
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame('table-sorts', $mock->getQueryStringAliasForSort());
+
+ }
+
+ public function test_can_change_default_sort_query_string_alias(): void
+ {
+ $mock = new class extends PetsTable
+ {
+ public ?array $testAttributesArray;
+
+ public function configure(): void
+ {
+ $this->setDataTableFingerprint('test');
+ }
+ };
+
+ $mock->configure();
+ $mock->boot();
+
+ $this->assertSame('table-sorts', $mock->getQueryStringAliasForSort());
+ $mock->setQueryStringAliasForSort('pet-sorts');
+ $this->assertSame('pet-sorts', $mock->getQueryStringAliasForSort());
+ $this->assertTrue($mock->hasQueryStringAliasForSort());
+ }
+}
diff --git a/tests/Traits/Helpers/ToolsHelpersTest.php b/tests/Traits/Helpers/ToolsHelpersTest.php
index 07533cbbc..9f2601462 100644
--- a/tests/Traits/Helpers/ToolsHelpersTest.php
+++ b/tests/Traits/Helpers/ToolsHelpersTest.php
@@ -16,6 +16,11 @@ public function test_can_get_toolbar_status(): void
$this->assertFalse($this->basicTable->getToolBarStatus());
$this->assertTrue($this->basicTable->getToolsStatus());
+ $this->basicTable->setToolBarEnabled();
+
+ $this->assertTrue($this->basicTable->getToolBarStatus());
+ $this->assertTrue($this->basicTable->getToolsStatus());
+
}
public function test_can_get_tools_status(): void
@@ -27,6 +32,12 @@ public function test_can_get_tools_status(): void
$this->assertFalse($this->basicTable->getToolsStatus());
$this->assertTrue($this->basicTable->getToolBarStatus());
+
+ $this->basicTable->setToolsEnabled();
+
+ $this->assertTrue($this->basicTable->getToolsStatus());
+ $this->assertTrue($this->basicTable->getToolBarStatus());
+
}
public function test_can_get_tools_should_display(): void
diff --git a/tests/Traits/Visuals/SearchVisualsTest.php b/tests/Traits/Visuals/SearchVisualsTest.php
index 1891bfd16..c025e1185 100644
--- a/tests/Traits/Visuals/SearchVisualsTest.php
+++ b/tests/Traits/Visuals/SearchVisualsTest.php
@@ -76,4 +76,50 @@ public function test_search_live_filter_is_applied(): void
->call('setSearchLive')
->assertSeeHtml('wire:model.live="search"');
}
+
+ public function test_search_via_query_string_functions(): void
+ {
+ Livewire::withQueryParams(['table-search' => 'Cartman'])
+ ->test(PetsTable::class)
+ ->assertSee('Cartman')
+ ->assertDontSee('Chico');
+
+ Livewire::withQueryParams(['table-search' => 'Chico'])
+ ->test(PetsTable::class)
+ ->assertSee('Chico')
+ ->assertDontSee('Cartman');
+
+ $mock = new class extends PetsTable
+ {
+ public ?array $testAttributesArray;
+
+ public function configure(): void
+ {
+ $this->setPrimaryKey('id');
+ $this->setDataTableFingerprint('test');
+ $this->setQueryStringAliasForSearch('pet-search');
+ }
+ };
+
+ Livewire::withQueryParams(['table-search' => 'Chico'])
+ ->test($mock)
+ ->assertSee('Chico')
+ ->assertSee('Cartman');
+
+ Livewire::withQueryParams(['pet-search' => 'Chico'])
+ ->test($mock)
+ ->assertSee('Chico')
+ ->assertDontSee('Cartman');
+
+ Livewire::withQueryParams(['pet-search' => null])
+ ->test($mock)
+ ->assertSee('Chico')
+ ->assertSee('Cartman');
+
+ Livewire::withQueryParams([])
+ ->test($mock)
+ ->assertSee('Chico')
+ ->assertSee('Cartman');
+
+ }
}
diff --git a/tests/Views/Columns/BooleanColumnTest.php b/tests/Views/Columns/BooleanColumnTest.php
index 6280af52c..726b6cfda 100644
--- a/tests/Views/Columns/BooleanColumnTest.php
+++ b/tests/Views/Columns/BooleanColumnTest.php
@@ -104,6 +104,19 @@ public function test_can_set_toggleable_with_confirm_message(): void
$this->assertTrue($column->hasConfirmMessage());
$this->assertSame('Are you sure?', $column->getConfirmMessage());
+ }
+
+ public function test_can_get_value(): void
+ {
+ $column = BooleanColumn::make('Name')->getContents(Pet::find(1));
+ $this->assertSame($column['value'], 'Cartman');
+ }
+
+ public function test_can_get_is_tailwind(): void
+ {
+ $column = BooleanColumn::make('Name')->getContents(Pet::find(1));
+ $this->assertSame($column['isTailwind'], true);
+ $this->assertSame($column['isBootstrap'], false);
}
}