diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 8ff98cc..49f05ab 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -1,23 +1,25 @@ -name: "Continuous Integration" +name: Continuous Integration on: push: + branches: + - master + - '*.x' pull_request: schedule: - cron: '0 0 * * *' jobs: - phpunit: - + tests: runs-on: ubuntu-latest strategy: fail-fast: true matrix: - php: [8.2, 8.3] + php: [8.2, 8.3, 8.4] stability: [prefer-stable] - name: PHP ${{ matrix.php }} - ${{ matrix.stability }} + name: PHP ${{ matrix.php }} - STABILITY ${{ matrix.stability }} steps: - name: Checkout code @@ -27,7 +29,6 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, memcached tools: composer:v2 coverage: none @@ -39,7 +40,7 @@ jobs: with: timeout_minutes: 5 max_attempts: 5 - command: COMPOSER_ROOT_VERSION=dev-master composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress + command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress - name: Execute tests run: vendor/bin/phpunit diff --git a/.github/workflows/pint.yml b/.github/workflows/pint.yml index f078347..c07577f 100644 --- a/.github/workflows/pint.yml +++ b/.github/workflows/pint.yml @@ -1,20 +1,33 @@ name: PHP Linting + on: pull_request: push: branches: - master + - '*.x' + jobs: - phplint: + pint: + name: Pint + runs-on: ubuntu-latest + + permissions: + contents: write + pull-requests: write + steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + - name: "laravel-pint" - uses: aglipanci/laravel-pint-action@2.0.0 + uses: aglipanci/laravel-pint-action@latest with: preset: laravel verboseMode: true + - uses: stefanzweifel/git-auto-commit-action@v5 with: - commit_message: "fix: pint" - + commit_message: "fix: pint :robot:" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 8e9365d..4dccad0 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -1,21 +1,12 @@ -name: "Static Analysis" +name: Static Analysis on: push: - paths: - - .github/workflows/static-analysis.yml - - composer.* - - phpstan.neon.dist - - src/** - - tests/** + branches: + - master + - '*.x' pull_request: - paths: - - .github/workflows/static-analysis.yml - - composer.* - - phpstan.neon.dist - - src/** - - tests/** schedule: - cron: '0 0 * * *' @@ -23,32 +14,26 @@ on: jobs: static-analysis-phpstan: - name: "Static Analysis with PHPStan" + name: Source Code runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - php: [8.2, 8.3] - stability: [prefer-stable] - steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php }} + php-version: 8.2 tools: composer:v2 coverage: none - name: Install dependencies - uses: nick-invision/retry@v1 + uses: nick-fields/retry@v3 with: timeout_minutes: 5 max_attempts: 5 - command: COMPOSER_ROOT_VERSION=dev-master composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress + command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - - name: "Run a static analysis with phpstan/phpstan" - run: "vendor/bin/phpstan --error-format=table" + - name: Run Static Analysis + run: vendor/bin/phpstan diff --git a/CHANGELOG.md b/CHANGELOG.md index ed62ba6..04d08aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ ### UNRELEASED +### v12.0.2 (2025-04-28) + +- fix: use DOMContentLoaded #237 +- fix: https://github.com/yajra/laravel-datatables-html/pull/235 + +### v12.0.1 (2025-03-31) + +- feat: select keyboard navigation and selection #236 + ### v12.0.0 (2025-02-26) - feat: Laravel 12 support #234 diff --git a/README.md b/README.md index a8ac86c..9103975 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Laravel DataTables Html Plugin -[![Laravel 11.x](https://img.shields.io/badge/Laravel-11.x-orange.svg)](http://laravel.com) +[![Laravel 12.x](https://img.shields.io/badge/Laravel-12.x-orange.svg)](http://laravel.com) [![Latest Stable Version](https://img.shields.io/packagist/v/yajra/laravel-datatables-html.svg)](https://packagist.org/packages/yajra/laravel-datatables-html) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yajra/laravel-datatables-html/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yajra/laravel-datatables-html/?branch=master) [![Total Downloads](https://img.shields.io/packagist/dt/yajra/laravel-datatables-html.svg)](https://packagist.org/packages/yajra/laravel-datatables-html) @@ -14,7 +14,7 @@ This package is a plugin of [Laravel DataTables](https://github.com/yajra/larave ## Requirements -- [Laravel 11.x](https://github.com/laravel/framework) +- [Laravel 12.x](https://github.com/laravel/framework) - [Laravel DataTables](https://github.com/yajra/laravel-datatables) ## Documentations @@ -29,10 +29,11 @@ This package is a plugin of [Laravel DataTables](https://github.com/yajra/larave | 9.x | 9.x | | 10.x | 10.x | | 11.x | 11.x | +| 12.x | 12.x | ## Quick Installation -`composer require yajra/laravel-datatables-html:^11` +`composer require yajra/laravel-datatables-html:^12` #### Setup scripts with ViteJS diff --git a/src/Html/Options/Plugins/Select.php b/src/Html/Options/Plugins/Select.php index 8cfc989..056d8e6 100644 --- a/src/Html/Options/Plugins/Select.php +++ b/src/Html/Options/Plugins/Select.php @@ -208,6 +208,18 @@ public function selectStyleMultiShift(): static return $this->select(['style' => Builder::SELECT_STYLE_MULTI_SHIFT]); } + /** + * Select keyboard navigation and selection. + * + * @return $this + * + * @see https://datatables.net/extensions/select/examples/initialisation/keys + */ + public function selectKeys(bool $enabled = true): static + { + return $this->select(['keys' => $enabled]); + } + public function getSelect(?string $key = null): mixed { if (is_null($key)) { diff --git a/src/resources/views/editor.blade.php b/src/resources/views/editor.blade.php index 70ab919..3f274d4 100644 --- a/src/resources/views/editor.blade.php +++ b/src/resources/views/editor.blade.php @@ -1,4 +1,4 @@ -$(function(){ +document.addEventListener("DOMContentLoaded", function(){ window.{{ config('datatables-html.namespace', 'LaravelDataTables') }} = window.{{ config('datatables-html.namespace', 'LaravelDataTables') }} || {}; $.ajaxSetup({headers: {'X-CSRF-TOKEN': '{{csrf_token()}}'}}); @foreach($editors as $editor) diff --git a/src/resources/views/script.blade.php b/src/resources/views/script.blade.php index b01ac74..4d3b205 100644 --- a/src/resources/views/script.blade.php +++ b/src/resources/views/script.blade.php @@ -1,4 +1,4 @@ -$(function(){window.{{ config('datatables-html.namespace', 'LaravelDataTables') }}=window.{{ config('datatables-html.namespace', 'LaravelDataTables') }}||{};window.{{ config('datatables-html.namespace', 'LaravelDataTables') }}["%1$s"]=$("#%1$s").DataTable(%2$s);}); +document.addEventListener("DOMContentLoaded",function(){window.{{ config('datatables-html.namespace', 'LaravelDataTables') }}=window.{{ config('datatables-html.namespace', 'LaravelDataTables') }}||{};window.{{ config('datatables-html.namespace', 'LaravelDataTables') }}["%1$s"]=$("#%1$s").DataTable(%2$s);}); @foreach ($scripts as $script) @include($script) @endforeach diff --git a/tests/Html/Builder/BuilderTest.php b/tests/Html/Builder/BuilderTest.php index b1c5818..1b61ef2 100644 --- a/tests/Html/Builder/BuilderTest.php +++ b/tests/Html/Builder/BuilderTest.php @@ -98,10 +98,10 @@ public function it_can_generate_table_html_and_scripts() $this->assertEquals($expected, $table); $script = $builder->scripts()->toHtml(); - $expected = ''; + $expected = ''; $this->assertEquals($expected, $script); - $expected = '$(function(){window.LaravelDataTables=window.LaravelDataTables||{};window.LaravelDataTables["foo-table"]=$("#foo-table").DataTable({"serverSide":true,"processing":true,"ajax":"","columns":[{"data":"foo","name":"foo","title":"Foo","orderable":true,"searchable":true},{"data":"baz","name":"baz","title":"Baz","orderable":true,"searchable":true}]});});'; + $expected = 'document.addEventListener("DOMContentLoaded",function(){window.LaravelDataTables=window.LaravelDataTables||{};window.LaravelDataTables["foo-table"]=$("#foo-table").DataTable({"serverSide":true,"processing":true,"ajax":"","columns":[{"data":"foo","name":"foo","title":"Foo","orderable":true,"searchable":true},{"data":"baz","name":"baz","title":"Baz","orderable":true,"searchable":true}]});});'; $this->assertEquals($expected, $builder->generateScripts()->toHtml()); }