From 6a14e7716e8161131b808a1a4cf6dd1447a02f32 Mon Sep 17 00:00:00 2001 From: francoism90 Date: Sun, 7 Jul 2024 23:47:25 +0200 Subject: [PATCH] wip --- src/Support/Html/HtmlExtended.php | 24 -------------- src/Support/Html/Mixins/BaseElementMixin.php | 16 +++++++--- src/Support/Html/Mixins/HtmlExtendedMixin.php | 31 +++++++++++++++++++ src/WireUseServiceProvider.php | 5 ++- 4 files changed, 44 insertions(+), 32 deletions(-) delete mode 100644 src/Support/Html/HtmlExtended.php create mode 100644 src/Support/Html/Mixins/HtmlExtendedMixin.php diff --git a/src/Support/Html/HtmlExtended.php b/src/Support/Html/HtmlExtended.php deleted file mode 100644 index 7414ef90..00000000 --- a/src/Support/Html/HtmlExtended.php +++ /dev/null @@ -1,24 +0,0 @@ -form = $value; - - return $this; - } - - public function icon(string $name, ?string $class = null, ?array $attributes = []): Div - { - return $this->div(svg($name, $class, $attributes)); - } -} diff --git a/src/Support/Html/Mixins/BaseElementMixin.php b/src/Support/Html/Mixins/BaseElementMixin.php index 9e685b07..79484c9e 100644 --- a/src/Support/Html/Mixins/BaseElementMixin.php +++ b/src/Support/Html/Mixins/BaseElementMixin.php @@ -9,7 +9,8 @@ class BaseElementMixin { public function wireKey(): mixed { - return function (?string $value = null) { + return function (?string $value = null): BaseElement + { /** @var BaseElement $this */ return $this->attribute('wire:key', $value); @@ -18,7 +19,8 @@ public function wireKey(): mixed public function wireIgnore(): mixed { - return function (?bool $self = false) { + return function (?bool $self = false): BaseElement + { /** @var BaseElement $this */ return $self @@ -29,7 +31,8 @@ public function wireIgnore(): mixed public function wireNavigate(): mixed { - return function () { + return function (): BaseElement + { /** @var BaseElement $this */ return $this->attribute('wire:navigate'); @@ -38,7 +41,8 @@ public function wireNavigate(): mixed public function wireSubmit(): mixed { - return function (?string $action = null) { + return function (?string $action = null): BaseElement + { /** @var BaseElement $this */ return $this->attribute('wire:submit', $action); @@ -47,8 +51,10 @@ public function wireSubmit(): mixed public function wireModel(): mixed { - return function (string $key, ?string $modifiers = null) { + return function (string $key, ?string $modifiers = null): BaseElement + { /** @var BaseElement $this */ + $directive = str('wire:model') ->when($modifiers, fn (Stringable $str) => $str->append(".{$modifiers}")) ->squish(); diff --git a/src/Support/Html/Mixins/HtmlExtendedMixin.php b/src/Support/Html/Mixins/HtmlExtendedMixin.php new file mode 100644 index 00000000..34e385d3 --- /dev/null +++ b/src/Support/Html/Mixins/HtmlExtendedMixin.php @@ -0,0 +1,31 @@ +form = $value; + + return $this; + }; + } + + public function icon(): mixed + { + return function (string $name, ?string $class = null, ?array $attributes = []): Div + { + /** @var Div $this */ + + return $this->div(svg($name, $class, $attributes)); + }; + } +} diff --git a/src/WireUseServiceProvider.php b/src/WireUseServiceProvider.php index 7801ef4d..6d40aea1 100644 --- a/src/WireUseServiceProvider.php +++ b/src/WireUseServiceProvider.php @@ -3,8 +3,8 @@ namespace Foxws\WireUse; use Foxws\WireUse\Support\Blade\Bladeable; -use Foxws\WireUse\Support\Html\HtmlExtended; use Foxws\WireUse\Support\Html\Mixins\BaseElementMixin; +use Foxws\WireUse\Support\Html\Mixins\HtmlExtendedMixin; use Foxws\WireUse\Support\Html\Mixins\LinkElementMixin; use Illuminate\Support\Facades\Blade; use Illuminate\View\ComponentAttributeBag; @@ -175,8 +175,7 @@ protected function registerLivewire(): static protected function registerHtml(): static { - $this->app->singleton(Html::class, HtmlExtended::class); - + Html::mixin(new HtmlExtendedMixin); BaseElement::mixin(new BaseElementMixin); A::mixin(new LinkElementMixin);