Skip to content

Commit 83df220

Browse files
committed
Merge branch 'v4' into v5
# Conflicts: # composer.json
2 parents e6ed8a3 + d52e380 commit 83df220

File tree

10 files changed

+33
-12
lines changed

10 files changed

+33
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
composer.lock
55
phpunit.xml
66
.phpunit.result.cache
7+
/.output.txt

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"pestphp/pest": "^4.0",
4242
"pestphp/pest-plugin-laravel": "^4.0",
4343
"orchestra/testbench": "^8.0|^9.0|^10.0",
44-
"nonsapiens/realaddressfactory": "^2.0",
44+
"nonsapiens/realaddressfactory": "^3.0",
4545
"timacdonald/log-fake": "^2.0",
4646
"laravel/pint": "^1.6"
4747
},

resources/views/fields/filament-google-widget-map.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
<input x-ref="pacinput" type="text" placeholder="Search Box" />
1717
@endif
1818

19-
<div
19+
<div
20+
id="map-{{ $getMapId() }}"
2021
x-ref="map"
2122
class="w-full"
2223
style="

resources/views/widgets/filament-google-maps-widget.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class="-my-2"
5555
@endif
5656
>
5757
<div
58+
id="map-{{ $this->getMapId() }}"
5859
x-ref="map"
5960
class="w-full"
6061
style="

src/Concerns/InteractsWithMaps.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Cheesegrits\FilamentGoogleMaps\Fields\Geocomplete;
66
use Cheesegrits\FilamentGoogleMaps\Fields\Map;
7+
use Filament\Schemas\Components\Component;
78

89
trait InteractsWithMaps
910
{
@@ -27,7 +28,11 @@ public function reverseGeocodeUpdated($container, string $statePath, array $resu
2728
return true;
2829
}
2930

30-
foreach ($component->getChildComponentContainers() as $childComponentContainer) {
31+
if (! $component instanceof Component) {
32+
return false;
33+
}
34+
35+
foreach ($component->getChildSchemas() as $childComponentContainer) {
3136
if ($childComponentContainer->isHidden()) {
3237
continue;
3338
}
@@ -61,7 +66,11 @@ public function placeUpdated($container, string $statePath, array $results): boo
6166
return true;
6267
}
6368

64-
foreach ($component->getChildComponentContainers() as $childComponentContainer) {
69+
if (! $component instanceof Component) {
70+
return false;
71+
}
72+
73+
foreach ($component->getChildSchemas() as $childComponentContainer) {
6574
if ($childComponentContainer->isHidden()) {
6675
continue;
6776
}

src/Fields/Geocomplete.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function getUpdateLatLngFields(): array
131131
$fields = $this->getModel()::getLatLngAttributes();
132132

133133
foreach ($fields as $fieldKey => $field) {
134-
$fieldId = FieldHelper::getFieldId($field, $this);
134+
$fieldId = FieldHelper::getFieldStatePath($field, $this);
135135

136136
if ($fieldId) {
137137
$statePaths[$fieldKey] = $fieldId;
@@ -247,7 +247,7 @@ public function getReverseGeocode(): array
247247
$statePaths = [];
248248

249249
foreach ($fields as $field => $format) {
250-
$fieldId = FieldHelper::getFieldId($field, $this);
250+
$fieldId = FieldHelper::getFieldStatePath($field, $this);
251251

252252
if ($fieldId) {
253253
$statePaths[$fieldId] = $format;

src/Fields/Map.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public function getReverseGeocode(): array
274274
$statePaths = [];
275275

276276
foreach ($fields as $field => $format) {
277-
$fieldId = FieldHelper::getFieldId($field, $this);
277+
$fieldId = FieldHelper::getFieldStatePath($field, $this);
278278

279279
if ($fieldId) {
280280
$statePaths[$fieldId] = $format;
@@ -380,7 +380,7 @@ public function getDrawingField(): ?string
380380
$drawingField = $this->evaluate($this->drawingField);
381381

382382
if ($drawingField) {
383-
return FieldHelper::getFieldId($drawingField, $this);
383+
return FieldHelper::getFieldStatePath($drawingField, $this);
384384
}
385385

386386
return null;
@@ -507,7 +507,7 @@ public function getGeoJsonField(): ?string
507507
$jsonField = $this->evaluate($this->geoJsonField);
508508

509509
if ($jsonField) {
510-
return FieldHelper::getFieldId($jsonField, $this);
510+
return FieldHelper::getFieldStatePath($jsonField, $this);
511511
}
512512

513513
return null;
@@ -709,7 +709,7 @@ public function getAutocompleteId(): ?string
709709
$autoCompleteField = $this->getAutocomplete();
710710

711711
if (! blank($autoCompleteField)) {
712-
return FieldHelper::getFieldId($autoCompleteField, $this);
712+
return FieldHelper::getFieldStatePath($autoCompleteField, $this);
713713
}
714714

715715
return null;

src/Fields/WidgetMap.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class WidgetMap extends Field
3737

3838
protected Closure|Action|null $markerAction = null;
3939

40+
protected static ?string $mapId = null;
41+
4042
/**
4143
* Main field config variables
4244
*/
@@ -301,4 +303,11 @@ public function getState(): mixed
301303
}
302304
}
303305
}
306+
307+
public function getMapId(): ?string
308+
{
309+
$mapId = static::$mapId ?? str(get_called_class())->afterLast('\\')->studly()->toString();
310+
311+
return preg_replace('/[^a-zA-Z0-9_]/', '', $mapId);
312+
}
304313
}

src/Helpers/FieldHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static function getFlatFields($topComponent): array
3030
return $flatFields;
3131
}
3232

33-
public static function getFieldId(string $field, Component $component): ?string
33+
public static function getFieldStatePath(string $field, Component $component): ?string
3434
{
3535
$topComponent = self::getTopComponent($component);
3636
$flatFields = static::getFlatFields($topComponent);

src/Infolists/MapEntry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function getDrawingField(): ?string
9494
$drawingField = $this->evaluate($this->drawingField);
9595

9696
if ($drawingField) {
97-
return FieldHelper::getFieldId($drawingField, $this);
97+
return FieldHelper::getFieldStatePath($drawingField, $this);
9898
}
9999

100100
return null;

0 commit comments

Comments
 (0)