From 2dc33d3d723cd97f002b32b7c8d32d82fdd673ea Mon Sep 17 00:00:00 2001 From: Nick Potts Date: Tue, 17 Jun 2025 17:18:50 +0800 Subject: [PATCH] update to v4 --- composer.json | 3 +- src/Forms/Components/GoogleAutocomplete.php | 32 +++++++++++---------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index 76c5570..56bbb69 100644 --- a/composer.json +++ b/composer.json @@ -23,11 +23,12 @@ "require": { "php": "^8.2", "spatie/laravel-package-tools": "^1.16", - "filament/filament": "^3.0-stable", + "filament/filament": "^4.0", "illuminate/contracts": "^10.0||^11.0||^12.0", "skagarwal/google-places-api": "^3.0" }, "require-dev": { + "filament/upgrade": "^4.0", "larastan/larastan": "^2.9|^3.0", "laravel/pint": "^1.14", "nunomaduro/collision": "^8.1.1||^7.10.0", diff --git a/src/Forms/Components/GoogleAutocomplete.php b/src/Forms/Components/GoogleAutocomplete.php index ac22d92..1c5a347 100644 --- a/src/Forms/Components/GoogleAutocomplete.php +++ b/src/Forms/Components/GoogleAutocomplete.php @@ -3,10 +3,12 @@ namespace Tapp\FilamentGoogleAutocomplete\Forms\Components; use Closure; -use Filament\Forms; -use Filament\Forms\Components\Component; -use Filament\Forms\Components\Concerns; -use Filament\Forms\Set; +use Filament\Schemas\Components\Component; +use Filament\Forms\Components\Select; +use Filament\Schemas\Components\Concerns; +use Filament\Schemas\Components\Utilities\Set; +use Filament\Schemas\Components\Grid; +use Filament\Forms\Components\TextInput; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Blade; use Illuminate\Support\HtmlString; @@ -25,7 +27,7 @@ class GoogleAutocomplete extends Component /** * @var view-string */ - protected string $view = 'filament-forms::components.group'; + protected string $view = 'filament-schemas::components.grid'; protected bool|Closure $isRequired = false; @@ -66,7 +68,7 @@ public function getChildComponents(): array { $components = []; - $components[] = Forms\Components\Select::make($this->getAutocompleteName()) + $components[] = Select::make($this->getAutocompleteName()) ->label($this->getAutocompleteLabel()) ->native(false) ->dehydrated(false) @@ -133,7 +135,7 @@ function (Component $component) { $allComponents = array_merge($components, $addressData); return [ - Forms\Components\Grid::make($this->getAddressFieldsColumns()) + Grid::make($this->getAddressFieldsColumns()) ->schema( $allComponents ), @@ -176,7 +178,7 @@ protected function getPlaceAutocompleteResult($result) return []; } - public function withFields(null|array|string|\Closure $fields): static + public function withFields(null|array|string|Closure $fields): static { $this->withFields = $fields; @@ -187,16 +189,16 @@ public function getWithFields(): ?array { if (empty($this->withFields)) { return [ - Forms\Components\TextInput::make('address') + TextInput::make('address') ->extraInputAttributes([ 'data-google-field' => '{street_number} {route}, {sublocality_level_1}', ]), - Forms\Components\TextInput::make('city') + TextInput::make('city') ->extraInputAttributes([ 'data-google-field' => 'locality', ]), - Forms\Components\TextInput::make('country'), - Forms\Components\TextInput::make('zip') + TextInput::make('country'), + TextInput::make('zip') ->extraInputAttributes([ 'data-google-field' => 'postal_code', ]), @@ -206,7 +208,7 @@ public function getWithFields(): ?array return $this->evaluate($this->withFields); } - public function autocompleteFieldColumnSpan(string|\Closure $autocompleteFieldColumnSpan = 'full'): static + public function autocompleteFieldColumnSpan(string|Closure $autocompleteFieldColumnSpan = 'full'): static { $this->autocompleteFieldColumnSpan = $autocompleteFieldColumnSpan; @@ -220,7 +222,7 @@ public function getAutocompleteFieldColumnSpan(): ?string return $this->evaluate($this->autocompleteFieldColumnSpan); } - public function addressFieldsColumns(null|array|string|\Closure $addressFieldsColumns): static + public function addressFieldsColumns(null|array|string|Closure $addressFieldsColumns): static { $this->addressFieldsColumns = $addressFieldsColumns; @@ -239,7 +241,7 @@ public function getAddressFieldsColumns(): ?array return $this->evaluate($this->addressFieldsColumns); } - public function autocompleteSearchDebounce(int|\Closure $autocompleteSearchDebounce = 2000): static + public function autocompleteSearchDebounce(int|Closure $autocompleteSearchDebounce = 2000): static { $this->autocompleteSearchDebounce = $autocompleteSearchDebounce;