Skip to content

update to v4 #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
32 changes: 17 additions & 15 deletions src/Forms/Components/GoogleAutocomplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
),
Expand Down Expand Up @@ -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;

Expand All @@ -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',
]),
Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand Down