From 9bda47f6d7056f9967b55d09e6961f2fa7a32d7a Mon Sep 17 00:00:00 2001 From: marvinosswald Date: Fri, 26 Jan 2024 14:14:33 +0000 Subject: [PATCH] Fix styling --- ...ilamentInputSelectAffixServiceProvider.php | 2 +- src/TextInputSelectAffix.php | 24 +++++++++++-------- tests/TestCase.php | 4 ++-- tests/TextInputSelectAffix.php | 2 +- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/FilamentInputSelectAffixServiceProvider.php b/src/FilamentInputSelectAffixServiceProvider.php index 1660e17..75fa38c 100644 --- a/src/FilamentInputSelectAffixServiceProvider.php +++ b/src/FilamentInputSelectAffixServiceProvider.php @@ -12,6 +12,6 @@ class FilamentInputSelectAffixServiceProvider extends PackageServiceProvider public function configurePackage(Package $package): void { $package->name(static::$name) - ->hasViews(); + ->hasViews(); } } diff --git a/src/TextInputSelectAffix.php b/src/TextInputSelectAffix.php index e92200d..692a96b 100644 --- a/src/TextInputSelectAffix.php +++ b/src/TextInputSelectAffix.php @@ -10,26 +10,31 @@ class TextInputSelectAffix extends TextInput { use HasComponents; + protected string $view = 'filament-input-select-affix::text-input-select-affix'; protected ?\Closure $selectComponentClosure = null; + protected ?Select $selectComponent = null; protected string $position = 'suffix'; - public function select(\Closure | Select $closure): TextInputSelectAffix + public function select(\Closure|Select $closure): TextInputSelectAffix { if ($closure instanceof Select) { - $this->selectComponentClosure = fn() => $closure; + $this->selectComponentClosure = fn () => $closure; + return $this; } $this->selectComponentClosure = $closure; + return $this; } public function position(string $position = 'suffix'): TextInputSelectAffix { $this->position = $position; + return $this; } @@ -59,7 +64,7 @@ public function dehydrateValidationRules(array &$rules): void } } - public function getPosition():string + public function getPosition(): string { return $this->position; } @@ -68,20 +73,19 @@ public function getSelectComponent(): ComponentContainer { $evaluated = $this->evaluate($this->selectComponentClosure); - if (!$evaluated instanceof Select) { - throw new \RuntimeException("Passed component must be of type Select"); + if (! $evaluated instanceof Select) { + throw new \RuntimeException('Passed component must be of type Select'); } $this->selectComponent = $evaluated->hiddenLabel() - ->extraAttributes(array_merge($evaluated->getExtraAttributes(),[ - 'style' => "border: none !important; background: transparent;--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);", + ->extraAttributes(array_merge($evaluated->getExtraAttributes(), [ + 'style' => 'border: none !important; background: transparent;--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);', ])); - $path = explode(".", $this->getStatePath()); + $path = explode('.', $this->getStatePath()); unset($path[count($path) - 1]); return ComponentContainer::make($this->getLivewire()) - ->statePath( implode(".", $path)) + ->statePath(implode('.', $path)) ->components([$this->selectComponent]); } - } diff --git a/tests/TestCase.php b/tests/TestCase.php index fac5f11..359f223 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -5,8 +5,8 @@ use Filament\FilamentServiceProvider; use Illuminate\Database\Eloquent\Factories\Factory; use Livewire\LivewireServiceProvider; -use Orchestra\Testbench\TestCase as Orchestra; use Marvinosswald\FilamentInputSelectAffix\FilamentInputSelectAffixServiceProvider; +use Orchestra\Testbench\TestCase as Orchestra; class TestCase extends Orchestra { @@ -15,7 +15,7 @@ protected function setUp(): void parent::setUp(); Factory::guessFactoryNamesUsing( - fn (string $modelName) => 'Marvinosswald\\FilamentInputSelectAffix\\Database\\Factories\\' . class_basename($modelName) . 'Factory' + fn (string $modelName) => 'Marvinosswald\\FilamentInputSelectAffix\\Database\\Factories\\'.class_basename($modelName).'Factory' ); } diff --git a/tests/TextInputSelectAffix.php b/tests/TextInputSelectAffix.php index 27e15eb..ccb0c67 100644 --- a/tests/TextInputSelectAffix.php +++ b/tests/TextInputSelectAffix.php @@ -21,7 +21,7 @@ $field = (new TextInputSelectAffix($name = Str::random())) ->container(ComponentContainer::make(Livewire::make())); - $field->select(Select::make("select")); + $field->select(Select::make('select')); expect($field) ->hasSelect()->toBeTrue();