From 4009e9c78139b69daeb95c4ec41d992f7ee7c8f7 Mon Sep 17 00:00:00 2001 From: Ozan Kurt Date: Mon, 18 Nov 2024 09:20:55 +0100 Subject: [PATCH 01/29] Update Button.php --- src/Html/Button.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Html/Button.php b/src/Html/Button.php index 7a0c2fe..d65ad72 100755 --- a/src/Html/Button.php +++ b/src/Html/Button.php @@ -429,4 +429,32 @@ public function align(string $align = 'button-left'): static return $this; } + + /** + * Handle dynamic calls to the fluent instance or macroable methods. + * + * @param string $method + * @param array $parameters + * @return mixed + * + * @throws \BadMethodCallException + */ + public function __call($method, $parameters) + { + // Check if the method is a macro (Macroable functionality). + if (static::hasMacro($method)) { + $macro = static::$macros[$method]; + + if ($macro instanceof Closure) { + $macro = $macro->bindTo($this, static::class); + } + + return $macro(...$parameters); + } + + // Fallback to Fluent behavior if it's not a macro. + $this->attributes[$method] = count($parameters) > 0 ? reset($parameters) : true; + + return $this; + } } From f88790c76b5b16cbd3216fa2e80dbec849f40f05 Mon Sep 17 00:00:00 2001 From: yajra Date: Mon, 18 Nov 2024 08:56:55 +0000 Subject: [PATCH 02/29] fix: pint --- src/Html/Button.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Html/Button.php b/src/Html/Button.php index d65ad72..0d17b67 100755 --- a/src/Html/Button.php +++ b/src/Html/Button.php @@ -429,7 +429,7 @@ public function align(string $align = 'button-left'): static return $this; } - + /** * Handle dynamic calls to the fluent instance or macroable methods. * From 4a27ec92d9ccd163018b1d58459d099668a32c66 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 18 Nov 2024 17:39:10 +0800 Subject: [PATCH 03/29] chore: release v11.6.1 :rocket: --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa08be9..5033fe1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ ### UNRELEASED +### v11.6.1 (2024-11-18) + +- Fix Marcoable trait usage together with Fluent helper #227 +- fix: yajra/laravel-datatables#3190 +- ### v11.6.0 (2024-08-31) - feat: add macro in editor builder #225 From badd641c02a8dcf09a174cfc4e47934192a4ae42 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 18 Nov 2024 18:46:54 +0800 Subject: [PATCH 04/29] fix: checking of closure instance --- src/Html/Button.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Html/Button.php b/src/Html/Button.php index 0d17b67..9688572 100755 --- a/src/Html/Button.php +++ b/src/Html/Button.php @@ -2,6 +2,7 @@ namespace Yajra\DataTables\Html; +use Closure; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Support\Fluent; use Illuminate\Support\Traits\Macroable; From 7bdb2c7ca81ff99e3b1ae8e84a9d816fe30e5673 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 18 Nov 2024 18:49:52 +0800 Subject: [PATCH 05/29] chore: release v11.6.2 :rocket: --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5033fe1..1aa5dfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ ### UNRELEASED +### v11.6.2 (2024-11-18) + +- fix: checking of closure instance missing import #228 +- fix: yajra/laravel-datatables#3197 +- fix: #227 + ### v11.6.1 (2024-11-18) - Fix Marcoable trait usage together with Fluent helper #227 From 425070dacc722b8b1c49663c8c2951662706cfc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20N=C3=BCrnberger?= Date: Thu, 28 Nov 2024 08:03:03 +0100 Subject: [PATCH 06/29] clone the "working" fluent class from laravel --- src/Html/Button.php | 1 - src/Html/Column.php | 1 - src/Html/Editor/Editor.php | 2 +- src/Html/Editor/Fields/Field.php | 2 +- src/Html/Editor/FormOptions.php | 2 +- src/Html/Fluent.php | 238 +++++++++++++++++++++++++++++++ src/Html/Layout.php | 1 - src/Html/Parameters.php | 2 - src/Html/SearchPane.php | 1 - 9 files changed, 241 insertions(+), 9 deletions(-) create mode 100644 src/Html/Fluent.php diff --git a/src/Html/Button.php b/src/Html/Button.php index 9688572..e25892f 100755 --- a/src/Html/Button.php +++ b/src/Html/Button.php @@ -4,7 +4,6 @@ use Closure; use Illuminate\Contracts\Support\Arrayable; -use Illuminate\Support\Fluent; use Illuminate\Support\Traits\Macroable; class Button extends Fluent implements Arrayable diff --git a/src/Html/Column.php b/src/Html/Column.php index d57a304..eaaad7c 100644 --- a/src/Html/Column.php +++ b/src/Html/Column.php @@ -3,7 +3,6 @@ namespace Yajra\DataTables\Html; use Illuminate\Support\Arr; -use Illuminate\Support\Fluent; use Illuminate\Support\Str; use Yajra\DataTables\Html\Options\Plugins\SearchPanes; diff --git a/src/Html/Editor/Editor.php b/src/Html/Editor/Editor.php index 15d63fc..4e9b4b8 100644 --- a/src/Html/Editor/Editor.php +++ b/src/Html/Editor/Editor.php @@ -3,10 +3,10 @@ namespace Yajra\DataTables\Html\Editor; use Illuminate\Support\Arr; -use Illuminate\Support\Fluent; use Illuminate\Support\Str; use Illuminate\Support\Traits\Macroable; use Yajra\DataTables\Html\Editor\Fields\Field; +use Yajra\DataTables\Html\Fluent; use Yajra\DataTables\Html\HasAuthorizations; use Yajra\DataTables\Utilities\Helper; diff --git a/src/Html/Editor/Fields/Field.php b/src/Html/Editor/Fields/Field.php index 56f277f..f3c737a 100644 --- a/src/Html/Editor/Fields/Field.php +++ b/src/Html/Editor/Fields/Field.php @@ -6,9 +6,9 @@ use Illuminate\Contracts\Support\Arrayable; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Query\Builder as QueryBuilder; -use Illuminate\Support\Fluent; use Illuminate\Support\Str; use Illuminate\Support\Traits\Macroable; +use Yajra\DataTables\Html\Fluent; use Yajra\DataTables\Html\HasAuthorizations; /** diff --git a/src/Html/Editor/FormOptions.php b/src/Html/Editor/FormOptions.php index a849ff6..03c149c 100644 --- a/src/Html/Editor/FormOptions.php +++ b/src/Html/Editor/FormOptions.php @@ -2,7 +2,7 @@ namespace Yajra\DataTables\Html\Editor; -use Illuminate\Support\Fluent; +use Yajra\DataTables\Html\Fluent; /** * @see https://editor.datatables.net/reference/type/form-options diff --git a/src/Html/Fluent.php b/src/Html/Fluent.php new file mode 100644 index 0000000..83a68ac --- /dev/null +++ b/src/Html/Fluent.php @@ -0,0 +1,238 @@ + + * @implements \ArrayAccess + */ +class Fluent implements Arrayable, ArrayAccess, Jsonable, JsonSerializable +{ + /** + * All of the attributes set on the fluent instance. + * + * @var array + */ + protected $attributes = []; + + /** + * Create a new fluent instance. + * + * @param iterable $attributes + * @return void + */ + public function __construct($attributes = []) + { + foreach ($attributes as $key => $value) { + $this->attributes[$key] = $value; + } + } + + /** + * Get an attribute from the fluent instance using "dot" notation. + * + * @template TGetDefault + * + * @param TKey $key + * @param TGetDefault|(\Closure(): TGetDefault) $default + * @return TValue|TGetDefault + */ + public function get($key, $default = null) + { + return data_get($this->attributes, $key, $default); + } + + /** + * Get an attribute from the fluent instance. + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public function value($key, $default = null) + { + if (array_key_exists($key, $this->attributes)) { + return $this->attributes[$key]; + } + + return value($default); + } + + /** + * Get the value of the given key as a new Fluent instance. + * + * @param string $key + * @param mixed $default + * @return static + */ + public function scope($key, $default = null) + { + return new static( + (array) $this->get($key, $default) + ); + } + + /** + * Get the attributes from the fluent instance. + * + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * Convert the fluent instance to an array. + * + * @return array + */ + public function toArray() + { + return $this->attributes; + } + + /** + * Convert the fluent instance to a Collection. + * + * @param string|null $key + * @return \Illuminate\Support\Collection + */ + public function collect($key = null) + { + return new Collection($this->get($key)); + } + + /** + * Convert the object into something JSON serializable. + * + * @return array + */ + public function jsonSerialize(): array + { + return $this->toArray(); + } + + /** + * Convert the fluent instance to JSON. + * + * @param int $options + * @return string + */ + public function toJson($options = 0) + { + return json_encode($this->jsonSerialize(), $options); + } + + /** + * Determine if the given offset exists. + * + * @param TKey $offset + * @return bool + */ + public function offsetExists($offset): bool + { + return isset($this->attributes[$offset]); + } + + /** + * Get the value for a given offset. + * + * @param TKey $offset + * @return TValue|null + */ + public function offsetGet($offset): mixed + { + return $this->value($offset); + } + + /** + * Set the value at the given offset. + * + * @param TKey $offset + * @param TValue $value + * @return void + */ + public function offsetSet($offset, $value): void + { + $this->attributes[$offset] = $value; + } + + /** + * Unset the value at the given offset. + * + * @param TKey $offset + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->attributes[$offset]); + } + + /** + * Handle dynamic calls to the fluent instance to set attributes. + * + * @param TKey $method + * @param array{0: ?TValue} $parameters + * @return $this + */ + public function __call($method, $parameters) + { + $this->attributes[$method] = count($parameters) > 0 ? reset($parameters) : true; + + return $this; + } + + /** + * Dynamically retrieve the value of an attribute. + * + * @param TKey $key + * @return TValue|null + */ + public function __get($key) + { + return $this->value($key); + } + + /** + * Dynamically set the value of an attribute. + * + * @param TKey $key + * @param TValue $value + * @return void + */ + public function __set($key, $value) + { + $this->offsetSet($key, $value); + } + + /** + * Dynamically check if an attribute is set. + * + * @param TKey $key + * @return bool + */ + public function __isset($key) + { + return $this->offsetExists($key); + } + + /** + * Dynamically unset an attribute. + * + * @param TKey $key + * @return void + */ + public function __unset($key) + { + $this->offsetUnset($key); + } +} diff --git a/src/Html/Layout.php b/src/Html/Layout.php index ef4ca10..c3a952e 100644 --- a/src/Html/Layout.php +++ b/src/Html/Layout.php @@ -6,7 +6,6 @@ use Illuminate\Contracts\Support\Renderable; use Illuminate\Support\Facades\Blade; -use Illuminate\Support\Fluent; use Illuminate\Support\Traits\Macroable; use Illuminate\View\Component; use InvalidArgumentException; diff --git a/src/Html/Parameters.php b/src/Html/Parameters.php index 7b6b0c4..4d3faee 100644 --- a/src/Html/Parameters.php +++ b/src/Html/Parameters.php @@ -2,8 +2,6 @@ namespace Yajra\DataTables\Html; -use Illuminate\Support\Fluent; - class Parameters extends Fluent { /** diff --git a/src/Html/SearchPane.php b/src/Html/SearchPane.php index 0b82a30..da90b11 100644 --- a/src/Html/SearchPane.php +++ b/src/Html/SearchPane.php @@ -5,7 +5,6 @@ use Closure; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Database\Eloquent\Builder as EloquentBuilder; -use Illuminate\Support\Fluent; use Yajra\DataTables\Html\Editor\Fields\Options; class SearchPane extends Fluent From 41a045f6f15835e4010669af9d060c9f65a03e22 Mon Sep 17 00:00:00 2001 From: yajra Date: Fri, 29 Nov 2024 01:29:20 +0000 Subject: [PATCH 07/29] fix: pint --- src/Html/Fluent.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Html/Fluent.php b/src/Html/Fluent.php index 83a68ac..2ff5837 100644 --- a/src/Html/Fluent.php +++ b/src/Html/Fluent.php @@ -136,7 +136,6 @@ public function toJson($options = 0) * Determine if the given offset exists. * * @param TKey $offset - * @return bool */ public function offsetExists($offset): bool { @@ -159,7 +158,6 @@ public function offsetGet($offset): mixed * * @param TKey $offset * @param TValue $value - * @return void */ public function offsetSet($offset, $value): void { @@ -170,7 +168,6 @@ public function offsetSet($offset, $value): void * Unset the value at the given offset. * * @param TKey $offset - * @return void */ public function offsetUnset($offset): void { From 08ccb1115c029da46c43b2a0a9daa9e4591b559a Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 29 Nov 2024 09:31:05 +0800 Subject: [PATCH 08/29] chore: release v11.7.0 :rocket: --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aa5dfe..0dd1c3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ ### UNRELEASED +### v11.7.0 (2024-11-29) + +- feat: clone the "working" Fluent class from laravel #230 +- Fixes #229 +- Closes yajra/laravel-datatables#3201 +- Fix: #231 + ### v11.6.2 (2024-11-18) - fix: checking of closure instance missing import #228 From 32f8a6e24d6c8fd5ed1bc60989ec6786b297a335 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 9 Jan 2025 15:38:09 +0800 Subject: [PATCH 09/29] feat: add tags field support --- src/Html/Editor/Fields/Tags.php | 146 ++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 src/Html/Editor/Fields/Tags.php diff --git a/src/Html/Editor/Fields/Tags.php b/src/Html/Editor/Fields/Tags.php new file mode 100644 index 0000000..05dc8d9 --- /dev/null +++ b/src/Html/Editor/Fields/Tags.php @@ -0,0 +1,146 @@ +attributes['ajax'] = $url; + + return $this; + } + + /** + * @see https://editor.datatables.net/reference/field/tags#display + */ + public function display(string $display): static + { + $this->attributes['display'] = $display; + + return $this; + } + + /** + * @see https://editor.datatables.net/reference/field/tags#escapeLabelHtml + */ + public function escapeLabelHtml(bool $escape): static + { + $this->attributes['escapeLabelHtml'] = $escape; + + return $this; + } + + /** + * @param array { + * addButton?: string + * inputPlaceholder?: string + * noResults?: string + * title?: string + * placeholder?: string + * } $i18n + * @see https://editor.datatables.net/reference/field/tags#i18n + */ + public function i18n(array $i18n): static + { + $this->attributes['i18n'] = array_merge($this->attributes['i18n'] ?? [], $i18n); + + return $this; + } + + /** + * @see https://editor.datatables.net/reference/field/tags#i18n + */ + public function addButton(string $text): static + { + return $this->i18n(['addButton' => $text]); + } + + /** + * @see https://editor.datatables.net/reference/field/tags#i18n + */ + public function inputPlaceholder(string $text): static + { + return $this->i18n(['inputPlaceholder' => $text]); + } + + /** + * @see https://editor.datatables.net/reference/field/tags#i18n + */ + public function noResults(string $text): static + { + return $this->i18n(['noResults' => $text]); + } + + /** + * @see https://editor.datatables.net/reference/field/tags#i18n + */ + public function title(string $text): static + { + return $this->i18n(['title' => $text]); + } + + /** + * @see https://editor.datatables.net/reference/field/tags#i18n + */ + public function placeholder(string $text): static + { + return $this->i18n(['placeholder' => $text]); + } + + /** + * @see https://editor.datatables.net/reference/field/tags#limit + */ + public function limit(int $limit): static + { + $this->attributes['limit'] = $limit; + + return $this; + } + + /** + * @see https://editor.datatables.net/reference/field/tags#multiple + */ + public function multiple(bool $multiple = true): static + { + $this->attributes['multiple'] = $multiple; + + return $this; + } + + /** + * @see https://editor.datatables.net/reference/field/tags#options + */ + public function options(array|Arrayable $options): static + { + return parent::options($options); + } + + /** + * @see https://editor.datatables.net/reference/field/tags#separator + */ + public function separator(string $separator = ','): static + { + return parent::separator($separator); + } + + /** + * @see https://editor.datatables.net/reference/field/tags#unique + */ + public function unique(bool $unique = true): static + { + $this->attributes['unique'] = $unique; + + return $this; + } +} From 220f2d2c71f23a40cf553e83b6b87141b2a4ec08 Mon Sep 17 00:00:00 2001 From: yajra Date: Thu, 9 Jan 2025 07:43:13 +0000 Subject: [PATCH 10/29] fix: pint --- src/Html/Editor/Fields/Tags.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Html/Editor/Fields/Tags.php b/src/Html/Editor/Fields/Tags.php index 05dc8d9..b406def 100644 --- a/src/Html/Editor/Fields/Tags.php +++ b/src/Html/Editor/Fields/Tags.php @@ -49,6 +49,7 @@ public function escapeLabelHtml(bool $escape): static * title?: string * placeholder?: string * } $i18n + * * @see https://editor.datatables.net/reference/field/tags#i18n */ public function i18n(array $i18n): static From fde0ce44e18a615c746aab8164ede1329a1b26fb Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 9 Jan 2025 16:24:14 +0800 Subject: [PATCH 11/29] test: tags --- tests/Html/Editor/Fields/TagsTest.php | 131 ++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 tests/Html/Editor/Fields/TagsTest.php diff --git a/tests/Html/Editor/Fields/TagsTest.php b/tests/Html/Editor/Fields/TagsTest.php new file mode 100644 index 0000000..a087605 --- /dev/null +++ b/tests/Html/Editor/Fields/TagsTest.php @@ -0,0 +1,131 @@ +ajax('/tags'); + + $this->assertSame('/tags', $field->toArray()['ajax']); + } + + #[Test] + public function it_can_set_tags_display(): void + { + $field = new Tags; + $field->display('display'); + + $this->assertSame('display', $field->toArray()['display']); + } + + #[Test] + public function it_can_set_tags_escape_label_html(): void + { + $field = new Tags; + $field->escapeLabelHtml(true); + + $this->assertTrue($field->toArray()['escapeLabelHtml']); + } + + #[Test] + public function it_can_set_tags_i18n(): void + { + $field = new Tags; + $field->i18n([ + 'addButton' => 'Add', + 'inputPlaceholder' => 'Input', + 'noResults' => 'No Results', + 'title' => 'Title', + 'placeholder' => 'Placeholder', + ]); + + $this->assertSame('Add', $field->toArray()['i18n']['addButton']); + $this->assertSame('Input', $field->toArray()['i18n']['inputPlaceholder']); + $this->assertSame('No Results', $field->toArray()['i18n']['noResults']); + $this->assertSame('Title', $field->toArray()['i18n']['title']); + $this->assertSame('Placeholder', $field->toArray()['i18n']['placeholder']); + + $field->addButton('Add Button') + ->inputPlaceholder('Input Placeholder') + ->noResults('No Results X') + ->title('Title X') + ->placeholder('Placeholder X'); + + $this->assertSame('Add Button', $field->toArray()['i18n']['addButton']); + $this->assertSame('Input Placeholder', $field->toArray()['i18n']['inputPlaceholder']); + $this->assertSame('No Results X', $field->toArray()['i18n']['noResults']); + $this->assertSame('Title X', $field->toArray()['i18n']['title']); + $this->assertSame('Placeholder X', $field->toArray()['i18n']['placeholder']); + } + + #[Test] + public function it_can_set_tags_type(): void + { + $field = new Tags; + + $this->assertSame('tags', $field->toArray()['type']); + } + + #[Test] + public function it_can_set_tags_limit(): void + { + $field = new Tags; + $field->limit(2); + + $this->assertSame(2, $field->toArray()['limit']); + } + + #[Test] + public function it_can_set_tags_multiple(): void + { + $field = new Tags; + $field->multiple(); + + $this->assertTrue($field->toArray()['multiple']); + } + + #[Test] + public function it_can_set_tags_options(): void + { + $field = new Tags; + $field->options(['tag1', 'tag2']); + + $this->assertSame(['tag1', 'tag2'], $field->toArray()['options']); + + $field->options([ + ['value' => 'tag1', 'label' => 'Tag 1'], + ['value' => 'tag2', 'label' => 'Tag 2'], + ]); + + $this->assertSame([ + ['value' => 'tag1', 'label' => 'Tag 1'], + ['value' => 'tag2', 'label' => 'Tag 2'], + ], $field->toArray()['options']); + } + + #[Test] + public function it_can_set_tags_separator(): void + { + $field = new Tags; + $field->separator(','); + + $this->assertSame(',', $field->toArray()['separator']); + } + + #[Test] + public function it_can_set_tags_unique(): void + { + $field = new Tags; + $field->unique(); + + $this->assertTrue($field->toArray()['unique']); + } +} From 75fc79a90e5f50c3c7de55587e4cca5a04aa537d Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 9 Jan 2025 16:29:12 +0800 Subject: [PATCH 12/29] test: refactor --- tests/{ => Html/Builder}/BuilderOptionsLanguageTest.php | 3 ++- tests/{ => Html/Builder}/BuilderOptionsPluginsTest.php | 3 ++- tests/{ => Html/Builder}/BuilderOptionsTest.php | 3 ++- tests/{ => Html/Builder}/BuilderTest.php | 3 ++- tests/{ => Html/Builder}/LayoutTest.php | 3 ++- tests/{ => Html/Builder}/SearchPaneTest.php | 3 ++- tests/{ => Html/Column}/ColumnDefinitionTest.php | 3 ++- tests/{ => Html/Column}/ColumnTest.php | 3 ++- tests/{ => Html/Editor}/EditorFormOptionsTest.php | 3 ++- tests/{ => Html/Editor}/EditorTest.php | 3 ++- tests/{ => Html/Editor/Fields}/FieldOptionsTest.php | 3 ++- tests/{ => Html/Editor/Fields}/FieldTest.php | 3 ++- 12 files changed, 24 insertions(+), 12 deletions(-) rename tests/{ => Html/Builder}/BuilderOptionsLanguageTest.php (98%) rename tests/{ => Html/Builder}/BuilderOptionsPluginsTest.php (99%) rename tests/{ => Html/Builder}/BuilderOptionsTest.php (99%) rename tests/{ => Html/Builder}/BuilderTest.php (99%) rename tests/{ => Html/Builder}/LayoutTest.php (99%) rename tests/{ => Html/Builder}/SearchPaneTest.php (96%) rename tests/{ => Html/Column}/ColumnDefinitionTest.php (88%) rename tests/{ => Html/Column}/ColumnTest.php (98%) rename tests/{ => Html/Editor}/EditorFormOptionsTest.php (95%) rename tests/{ => Html/Editor}/EditorTest.php (98%) rename tests/{ => Html/Editor/Fields}/FieldOptionsTest.php (96%) rename tests/{ => Html/Editor/Fields}/FieldTest.php (99%) diff --git a/tests/BuilderOptionsLanguageTest.php b/tests/Html/Builder/BuilderOptionsLanguageTest.php similarity index 98% rename from tests/BuilderOptionsLanguageTest.php rename to tests/Html/Builder/BuilderOptionsLanguageTest.php index c65c45b..9567d16 100644 --- a/tests/BuilderOptionsLanguageTest.php +++ b/tests/Html/Builder/BuilderOptionsLanguageTest.php @@ -1,8 +1,9 @@ Date: Thu, 9 Jan 2025 16:31:53 +0800 Subject: [PATCH 13/29] test: search panes --- tests/Html/{Builder => Extensions}/SearchPaneTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename tests/Html/{Builder => Extensions}/SearchPaneTest.php (97%) diff --git a/tests/Html/Builder/SearchPaneTest.php b/tests/Html/Extensions/SearchPaneTest.php similarity index 97% rename from tests/Html/Builder/SearchPaneTest.php rename to tests/Html/Extensions/SearchPaneTest.php index 6fe60a0..48fd975 100644 --- a/tests/Html/Builder/SearchPaneTest.php +++ b/tests/Html/Extensions/SearchPaneTest.php @@ -1,6 +1,6 @@ Date: Thu, 9 Jan 2025 16:47:43 +0800 Subject: [PATCH 14/29] ci: fix static analysis --- phpstan.neon.dist | 7 +++---- src/Html/Editor/Fields/Tags.php | 12 +++--------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 08605d3..92b6e18 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -10,9 +10,8 @@ parameters: ignoreErrors: - '#Unsafe usage of new static\(\).#' + - identifier: missingType.generics + - identifier: missingType.iterableValue excludePaths: - - checkMissingIterableValueType: false - - checkGenericClassInNonGenericObjectType: false + - ./src/Html/Fluent.php diff --git a/src/Html/Editor/Fields/Tags.php b/src/Html/Editor/Fields/Tags.php index b406def..d9112d1 100644 --- a/src/Html/Editor/Fields/Tags.php +++ b/src/Html/Editor/Fields/Tags.php @@ -42,19 +42,13 @@ public function escapeLabelHtml(bool $escape): static } /** - * @param array { - * addButton?: string - * inputPlaceholder?: string - * noResults?: string - * title?: string - * placeholder?: string - * } $i18n - * * @see https://editor.datatables.net/reference/field/tags#i18n */ public function i18n(array $i18n): static { - $this->attributes['i18n'] = array_merge($this->attributes['i18n'] ?? [], $i18n); + $options = (array) $this->attributes['i18n']; + + $this->attributes['i18n'] = array_merge($options, $i18n); return $this; } From 0136e8e00ba1e476ced1ff0f84046e6ae5d09637 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 9 Jan 2025 22:08:31 +0800 Subject: [PATCH 15/29] fix: error when i18n is not set --- src/Html/Editor/Fields/Tags.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Html/Editor/Fields/Tags.php b/src/Html/Editor/Fields/Tags.php index d9112d1..2b910be 100644 --- a/src/Html/Editor/Fields/Tags.php +++ b/src/Html/Editor/Fields/Tags.php @@ -46,7 +46,9 @@ public function escapeLabelHtml(bool $escape): static */ public function i18n(array $i18n): static { - $options = (array) $this->attributes['i18n']; + $options = isset($this->attributes['i18n']) + ? (array) $this->attributes['i18n'] + : []; $this->attributes['i18n'] = array_merge($options, $i18n); From bf85ccba57fd468781b2df95bd3dcafee1e735cc Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 9 Jan 2025 22:14:23 +0800 Subject: [PATCH 16/29] test: set i18n prop directly --- tests/Html/Editor/Fields/TagsTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/Html/Editor/Fields/TagsTest.php b/tests/Html/Editor/Fields/TagsTest.php index a087605..da466e0 100644 --- a/tests/Html/Editor/Fields/TagsTest.php +++ b/tests/Html/Editor/Fields/TagsTest.php @@ -35,6 +35,14 @@ public function it_can_set_tags_escape_label_html(): void $this->assertTrue($field->toArray()['escapeLabelHtml']); } + #[Test] + public function it_can_set_tags_i18n_props_directly(): void + { + $field = new Tags; + $field->addButton('Add Tag'); + $this->assertSame('Add Tag', $field->toArray()['i18n']['addButton']); + } + #[Test] public function it_can_set_tags_i18n(): void { From f9936fe040ee74661569e3717a538bd405228919 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 9 Jan 2025 23:06:29 +0800 Subject: [PATCH 17/29] chore: release v11.8.0 :rocket: --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dd1c3b..3ed3d55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ ### UNRELEASED +### v11.8.0 (2025-01-09) + +- feat: add Editor 2.4.0 tags field support #232 +- ci: static analysis + ### v11.7.0 (2024-11-29) - feat: clone the "working" Fluent class from laravel #230 From 2798667055282bd663ccd88e6f9d8f95feac6307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alfaiate?= Date: Wed, 19 Feb 2025 09:07:09 +0700 Subject: [PATCH 18/29] fix: add missing exportRender property --- src/Html/Column.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Html/Column.php b/src/Html/Column.php index eaaad7c..bfaa34b 100644 --- a/src/Html/Column.php +++ b/src/Html/Column.php @@ -28,6 +28,7 @@ * @property string $contentPadding * @property string $createdCell * @property string $exportFormat + * @property callable $exportRender * * @see https://datatables.net/reference/option/#columns */ From 76cb7a423c84fa81cc5c6418cbb8c3c95d1a4f89 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 19 Feb 2025 10:11:43 +0800 Subject: [PATCH 19/29] chore: release v11.8.1 :rocket: --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ed3d55..6fbe015 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ ### UNRELEASED +### v11.8.1 (2025-02-19) + +- fix: add missing exportRender property #233 + ### v11.8.0 (2025-01-09) - feat: add Editor 2.4.0 tags field support #232 From 518a53c1ba84e096d656bf8b736973e686e83bc1 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 26 Feb 2025 11:18:50 +0800 Subject: [PATCH 20/29] feat: Laravel 12 support --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 3182b14..784ffcb 100644 --- a/composer.json +++ b/composer.json @@ -19,13 +19,13 @@ "require": { "php": "^8.2", "ext-json": "*", - "yajra/laravel-datatables-oracle": "^11.0" + "yajra/laravel-datatables-oracle": "^12.0" }, "require-dev": { - "larastan/larastan": "^2.9.1", - "orchestra/testbench": "^9", - "laravel/pint": "^1.14", - "rector/rector": "^1.0", + "larastan/larastan": "^3.1", + "orchestra/testbench": "^10", + "laravel/pint": "^1.21", + "rector/rector": "^2.0", "livewire/livewire": "^3.4" }, "suggest": { @@ -43,7 +43,7 @@ }, "extra": { "branch-alias": { - "dev-master": "11.0-dev" + "dev-master": "12.x-dev" }, "laravel": { "providers": [ From 919437a9522769d0b36675048682fbebabcc644b Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 26 Feb 2025 11:19:29 +0800 Subject: [PATCH 21/29] fix: static analysis --- phpstan.neon.dist | 7 +++++-- src/Html/Button.php | 6 ++++-- src/Html/Column.php | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 92b6e18..23d24cc 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -10,8 +10,11 @@ parameters: ignoreErrors: - '#Unsafe usage of new static\(\).#' - - identifier: missingType.generics - - identifier: missingType.iterableValue + - identifier: missingType.generics + - identifier: missingType.iterableValue + - identifier: binaryOp.invalid + - identifier: return.type + - identifier: argument.type excludePaths: - ./src/Html/Fluent.php diff --git a/src/Html/Button.php b/src/Html/Button.php index e25892f..0823962 100755 --- a/src/Html/Button.php +++ b/src/Html/Button.php @@ -271,10 +271,12 @@ public function addClass(string $class): static { if (! isset($this->attributes['className'])) { $this->attributes['className'] = $class; - } else { - $this->attributes['className'] .= " $class"; + + return $this; } + $this->attributes['className'] = $this->attributes['className']." $class"; + return $this; } diff --git a/src/Html/Column.php b/src/Html/Column.php index bfaa34b..fcebc04 100644 --- a/src/Html/Column.php +++ b/src/Html/Column.php @@ -503,7 +503,7 @@ public function parseRender(mixed $value): ?string return $value($parameters); } elseif ($this->isBuiltInRenderFunction($value)) { return $value; - } elseif (strlen((string) $value) < 256 && $view->exists($value)) { + } elseif (is_string($value) && strlen($value) < 256 && $view->exists($value)) { return $view->make($value)->with($parameters)->render(); } From 3e903bef48fd0adb26d5a935cef53af5759bfe86 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 26 Feb 2025 14:35:52 +0800 Subject: [PATCH 22/29] chore: release v12.0.0 :rocket: --- CHANGELOG.md | 67 ++-------------------------------------------------- 1 file changed, 2 insertions(+), 65 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fbe015..ed62ba6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,69 +4,6 @@ ### UNRELEASED -### v11.8.1 (2025-02-19) +### v12.0.0 (2025-02-26) -- fix: add missing exportRender property #233 - -### v11.8.0 (2025-01-09) - -- feat: add Editor 2.4.0 tags field support #232 -- ci: static analysis - -### v11.7.0 (2024-11-29) - -- feat: clone the "working" Fluent class from laravel #230 -- Fixes #229 -- Closes yajra/laravel-datatables#3201 -- Fix: #231 - -### v11.6.2 (2024-11-18) - -- fix: checking of closure instance missing import #228 -- fix: yajra/laravel-datatables#3197 -- fix: #227 - -### v11.6.1 (2024-11-18) - -- Fix Marcoable trait usage together with Fluent helper #227 -- fix: yajra/laravel-datatables#3190 -- -### v11.6.0 (2024-08-31) - -- feat: add macro in editor builder #225 - -### v11.5.1 (2024-08-31) - -- fix: unauthorized columns being displayed by builder #223 -- fix: #222 - -### v11.5.0 (2024-08-31) - -- feat: enable macro on Button builder #224 - -### v11.4.0 (2024-05-31) - -- feat: add className method to Editor Field #220 - -### v11.3.0 (2024-05-18) - -- feat: Allow passing view and livewire components to layout builder #219 - -### v11.2.1 (2024-04-29) - -- fix: multiple config option of select2 #218 - -### v11.2.0 (2024-04-24) - -- feat: load layout from view using selector #217 - -### v11.1.0 (2024-04-24) - -- feat: layout builder #216 -- https://datatables.net/reference/option/layout - -### v11.0.0 (2024-03-14) - -- Add support for Laravel 11.x -- Fix editor scope compatibility with Fluent class scope -- Rename Editor `scope` method to `formScope` +- feat: Laravel 12 support #234 From c535c6416d136b85229bfd4f5af4273a9ee88d36 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 26 Feb 2025 15:01:57 +0800 Subject: [PATCH 23/29] docs: Laravel 12 --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 From fbb82b72f36cf983c97e7e717c7c9a5d334240a5 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 1 Mar 2025 14:09:06 +0800 Subject: [PATCH 24/29] ci: workflows --- .github/workflows/continuous-integration.yml | 22 ++++++++---- .github/workflows/pint.yml | 21 ++++++++--- .github/workflows/static-analysis.yml | 37 ++++++-------------- 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 8ff98cc..f682722 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -1,23 +1,32 @@ -name: "Continuous Integration" +name: Continuous Integration on: push: + branches: + - master + - '*.x' pull_request: schedule: - cron: '0 0 * * *' jobs: - phpunit: - + tests: runs-on: ubuntu-latest + services: + oracle: + image: deepdiver/docker-oracle-xe-11g:2.0 + ports: + - 49160:22 + - 1521:1521 + 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 +36,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 +47,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 From 4bd6b36d1d34d9bab290f8b9e0a0c4a4e54d913d Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 1 Mar 2025 14:14:51 +0800 Subject: [PATCH 25/29] ci: rm service --- .github/workflows/continuous-integration.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index f682722..49f05ab 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -13,13 +13,6 @@ jobs: tests: runs-on: ubuntu-latest - services: - oracle: - image: deepdiver/docker-oracle-xe-11g:2.0 - ports: - - 49160:22 - - 1521:1521 - strategy: fail-fast: true matrix: From 8eda6e068e96dbd78525e1363fe87f0250e6ac66 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 31 Mar 2025 18:36:01 +0800 Subject: [PATCH 26/29] feat: select keyboard navigation and selection https://datatables.net/extensions/select/examples/initialisation/keys --- src/Html/Options/Plugins/Select.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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)) { From 68b8959b1c78bd2ba61275541e241c06a4810fbb Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 31 Mar 2025 18:42:50 +0800 Subject: [PATCH 27/29] chore: release v12.0.1 :rocket: --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed62ba6..9986ed0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ ### UNRELEASED +### v12.0.1 (2025-03-31) + +- feat: select keyboard navigation and selection #236 + ### v12.0.0 (2025-02-26) - feat: Laravel 12 support #234 From 4643244a6d176a87c434378b7235572a23439cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alfaiate?= Date: Thu, 24 Apr 2025 11:26:11 +0700 Subject: [PATCH 28/29] fix: use DOMContentLoaded --- src/resources/views/editor.blade.php | 2 +- src/resources/views/script.blade.php | 2 +- tests/Html/Builder/BuilderTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) 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()); } From 1f495cfd4561e0b4fb71ae73eb07fa6f3c7d0782 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 28 Apr 2025 16:07:05 +0800 Subject: [PATCH 29/29] chore: release v12.0.2 :rocket: --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9986ed0..04d08aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ ### 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