@sanity/google-maps-input 4.2.1 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/LICENSE +1 -1
  2. package/assets/google-maps-input.png +0 -0
  3. package/assets/google-maps-radius-input.png +0 -0
  4. package/dist/index.d.ts +54 -84
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +736 -652
  7. package/dist/index.js.map +1 -1
  8. package/package.json +36 -80
  9. package/dist/index.cjs +0 -1014
  10. package/dist/index.cjs.map +0 -1
  11. package/dist/index.d.cts +0 -85
  12. package/sanity.json +0 -8
  13. package/src/diff/GeopointArrayDiff.tsx +0 -86
  14. package/src/diff/GeopointFieldDiff.styles.tsx +0 -20
  15. package/src/diff/GeopointFieldDiff.tsx +0 -97
  16. package/src/diff/GeopointMove.tsx +0 -48
  17. package/src/diff/GeopointRadiusFieldDiff.tsx +0 -136
  18. package/src/diff/GeopointRadiusMove.tsx +0 -92
  19. package/src/diff/resolver.ts +0 -26
  20. package/src/global-workaround.ts +0 -11
  21. package/src/index.ts +0 -20
  22. package/src/input/GeopointInput.styles.tsx +0 -11
  23. package/src/input/GeopointInput.tsx +0 -179
  24. package/src/input/GeopointRadiusInput.tsx +0 -258
  25. package/src/input/GeopointRadiusSelect.tsx +0 -193
  26. package/src/input/GeopointSelect.tsx +0 -79
  27. package/src/loader/GoogleMapsLoadProxy.tsx +0 -62
  28. package/src/loader/LoadError.tsx +0 -43
  29. package/src/loader/loadGoogleMapsApi.ts +0 -77
  30. package/src/map/Arrow.tsx +0 -76
  31. package/src/map/Map.styles.tsx +0 -10
  32. package/src/map/Map.tsx +0 -125
  33. package/src/map/Marker.tsx +0 -130
  34. package/src/map/SearchInput.styles.tsx +0 -8
  35. package/src/map/SearchInput.tsx +0 -56
  36. package/src/map/util.ts +0 -14
  37. package/src/plugin.tsx +0 -92
  38. package/src/types.ts +0 -46
  39. package/v2-incompatible.js +0 -10
package/dist/index.cjs DELETED
@@ -1,1014 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var jsxRuntime = require("react/jsx-runtime"), react = require("react"), ui = require("@sanity/ui"), icons = require("@sanity/icons"), sanity = require("sanity"), styledComponents = require("styled-components");
4
- const callbackName = "___sanity_googleMapsApiCallback", authFailureCallbackName = "gm_authFailure";
5
- let AuthError$1 = class extends Error {
6
- };
7
- function _loadGoogleMapsApi(config2) {
8
- return new Promise((resolve, reject) => {
9
- window[authFailureCallbackName] = () => {
10
- reject(new AuthError$1("Authentication error when loading Google Maps API."));
11
- }, window[callbackName] = () => {
12
- resolve(window.google.maps);
13
- };
14
- const script = document.createElement("script");
15
- script.onerror = (event, source, lineno, colno, error) => reject(new Error(coeerceError(event, error))), script.src = `https://maps.googleapis.com/maps/api/js?key=${config2.apiKey}&libraries=places&callback=${callbackName}&language=${config2.locale}`, document.getElementsByTagName("head")[0].appendChild(script);
16
- }).finally(() => {
17
- delete window[callbackName], delete window[authFailureCallbackName];
18
- });
19
- }
20
- let memo = null;
21
- function loadGoogleMapsApi(config2) {
22
- return memo || (memo = _loadGoogleMapsApi(config2), memo.catch(() => {
23
- memo = null;
24
- }), memo);
25
- }
26
- function coeerceError(event, error) {
27
- return error ? error.message : typeof event == "string" ? event : isErrorEvent(event) ? event.message : "Failed to load Google Maps API";
28
- }
29
- function isErrorEvent(event) {
30
- return typeof event != "object" || event === null || !("message" in event) ? !1 : typeof event.message == "string";
31
- }
32
- function LoadError(props) {
33
- return /* @__PURE__ */ jsxRuntime.jsxs(ui.Card, { tone: "critical", radius: 1, children: [
34
- /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { as: "header", paddingX: 4, paddingTop: 4, paddingBottom: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "h2", weight: "bold", children: "Google Maps failed to load" }) }),
35
- /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingX: 4, paddingTop: 4, paddingBottom: 1, children: props.isAuthError ? /* @__PURE__ */ jsxRuntime.jsx(AuthError2, {}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
36
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "h3", children: "Error details:" }),
37
- /* @__PURE__ */ jsxRuntime.jsx("pre", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Code, { size: 1, children: "error" in props && props.error?.message }) })
38
- ] }) })
39
- ] });
40
- }
41
- function AuthError2() {
42
- return /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { children: [
43
- /* @__PURE__ */ jsxRuntime.jsx("p", { children: "The error appears to be related to authentication" }),
44
- /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Common causes include:" }),
45
- /* @__PURE__ */ jsxRuntime.jsxs("ul", { children: [
46
- /* @__PURE__ */ jsxRuntime.jsx("li", { children: "Incorrect API key" }),
47
- /* @__PURE__ */ jsxRuntime.jsx("li", { children: "Referer not allowed" }),
48
- /* @__PURE__ */ jsxRuntime.jsx("li", { children: "Missing authentication scope" })
49
- ] }),
50
- /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Check the browser developer tools for more information." })
51
- ] });
52
- }
53
- const browserLocale = typeof window < "u" && window.navigator.language || "en";
54
- function useLoadGoogleMapsApi(config2) {
55
- const locale = config2.defaultLocale || browserLocale, [state, setState] = react.useState({ type: "loading" });
56
- return react.useEffect(() => {
57
- typeof window > "u" || loadGoogleMapsApi({ locale, apiKey: config2.apiKey }).then(
58
- (api) => setState({ type: "loaded", api }),
59
- (err) => setState({
60
- type: "error",
61
- error: { type: err instanceof AuthError$1 ? "authError" : "loadError", message: err.message }
62
- })
63
- );
64
- }, [locale, config2.apiKey]), state;
65
- }
66
- function GoogleMapsLoadProxy(props) {
67
- const loadState = useLoadGoogleMapsApi(props.config);
68
- switch (loadState.type) {
69
- case "error":
70
- return /* @__PURE__ */ jsxRuntime.jsx(LoadError, { error: loadState.error, isAuthError: loadState.error.type === "authError" });
71
- case "loading":
72
- return /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Loading Google Maps API" });
73
- case "loaded":
74
- return props.children(loadState.api);
75
- default:
76
- return null;
77
- }
78
- }
79
- let config;
80
- function getGeoConfig() {
81
- return config;
82
- }
83
- function setGeoConfig(newConfig) {
84
- config = newConfig;
85
- }
86
- const PreviewImage = styledComponents.styled.img`
87
- width: 100%;
88
- height: auto;
89
- vertical-align: top;
90
- `, DialogInnerContainer = styledComponents.styled.div`
91
- height: 40rem;
92
- `, WrapperContainer = styledComponents.styled.div`
93
- position: absolute;
94
- right: 10px;
95
- top: 10px;
96
- width: 220px;
97
- `;
98
- class SearchInput extends react.PureComponent {
99
- searchInputRef = react.createRef();
100
- autoComplete;
101
- handleChange = () => {
102
- this.autoComplete && (this.props.onChange(this.autoComplete.getPlace()), this.searchInputRef.current && (this.searchInputRef.current.value = ""));
103
- };
104
- componentDidMount() {
105
- const input = this.searchInputRef.current;
106
- if (!input)
107
- return;
108
- const { api, map } = this.props, { Circle, places, event } = api, searchBounds = new Circle({ center: map.getCenter(), radius: 100 }).getBounds();
109
- this.autoComplete = new places.Autocomplete(input, {
110
- bounds: searchBounds,
111
- types: []
112
- // return all kinds of places
113
- }), event.addListener(this.autoComplete, "place_changed", this.handleChange);
114
- }
115
- render() {
116
- return /* @__PURE__ */ jsxRuntime.jsx(WrapperContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(
117
- ui.TextInput,
118
- {
119
- name: "place",
120
- ref: this.searchInputRef,
121
- placeholder: "Search for place or address",
122
- padding: 4
123
- }
124
- ) });
125
- }
126
- }
127
- function latLngAreEqual(latLng1, latLng2) {
128
- const lat1 = typeof latLng1.lat == "function" ? latLng1.lat() : latLng1.lat, lng1 = typeof latLng1.lng == "function" ? latLng1.lng() : latLng1.lng, lat2 = typeof latLng2.lat == "function" ? latLng2.lat() : latLng2.lat, lng2 = typeof latLng2.lng == "function" ? latLng2.lng() : latLng2.lng;
129
- return lat1 === lat2 && lng1 === lng2;
130
- }
131
- const MapContainer = styledComponents.styled.div`
132
- position: absolute;
133
- top: 0;
134
- left: 0;
135
- height: 100%;
136
- width: 100%;
137
- box-sizing: border-box;
138
- `;
139
- class GoogleMap extends react.PureComponent {
140
- static defaultProps = {
141
- defaultZoom: 8,
142
- scrollWheel: !0
143
- };
144
- state = { map: void 0 };
145
- clickHandler;
146
- mapRef = react.createRef();
147
- mapEl = null;
148
- componentDidMount() {
149
- this.attachClickHandler();
150
- }
151
- attachClickHandler = () => {
152
- const map = this.state.map;
153
- if (!map)
154
- return;
155
- const { api, onClick } = this.props, { event } = api;
156
- this.clickHandler && this.clickHandler.remove(), onClick && (this.clickHandler = event.addListener(map, "click", onClick));
157
- };
158
- componentDidUpdate(prevProps) {
159
- const map = this.state.map;
160
- if (!map)
161
- return;
162
- const { onClick, location, bounds } = this.props;
163
- prevProps.onClick !== onClick && this.attachClickHandler(), latLngAreEqual(prevProps.location, location) || map.panTo(this.getCenter()), bounds && (!prevProps.bounds || !bounds.equals(prevProps.bounds)) && map.fitBounds(bounds);
164
- }
165
- componentWillUnmount() {
166
- this.clickHandler && this.clickHandler.remove();
167
- }
168
- getCenter() {
169
- const { location, api } = this.props;
170
- return new api.LatLng(location.lat, location.lng);
171
- }
172
- constructMap(el) {
173
- const { defaultZoom, api, mapTypeControl, controlSize, bounds, scrollWheel } = this.props, map = new api.Map(el, {
174
- zoom: defaultZoom,
175
- center: this.getCenter(),
176
- scrollwheel: scrollWheel,
177
- streetViewControl: !1,
178
- mapTypeControl,
179
- controlSize
180
- });
181
- return bounds && map.fitBounds(bounds), map;
182
- }
183
- setMapElement = (element) => {
184
- if (element && element !== this.mapEl) {
185
- const map = this.constructMap(element);
186
- this.setState({ map }, this.attachClickHandler);
187
- }
188
- this.mapEl = element;
189
- };
190
- render() {
191
- const { children } = this.props, { map } = this.state;
192
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
193
- /* @__PURE__ */ jsxRuntime.jsx(MapContainer, { ref: this.setMapElement }),
194
- children && map ? children(map) : null
195
- ] });
196
- }
197
- }
198
- const markerPath = "M 3.052 3.7 C 1.56 5.293 0.626 7.612 0.663 9.793 C 0.738 14.352 2.793 16.077 6.078 22.351 C 7.263 25.111 8.497 28.032 9.672 32.871 C 9.835 33.584 9.994 34.246 10.069 34.305 C 10.143 34.362 10.301 33.697 10.465 32.983 C 11.639 28.145 12.875 25.226 14.059 22.466 C 17.344 16.192 19.398 14.466 19.474 9.908 C 19.511 7.727 18.574 5.405 17.083 3.814 C 15.379 1.994 12.809 0.649 10.069 0.593 C 7.328 0.536 4.756 1.882 3.052 3.7 Z";
199
- class Marker extends react.PureComponent {
200
- marker;
201
- eventHandlers = {};
202
- componentDidMount() {
203
- const { position, api, map, onMove, zIndex, opacity, label, markerRef, color } = this.props, { Marker: GMarker } = api;
204
- let icon;
205
- color && (icon = {
206
- path: markerPath,
207
- fillOpacity: 1,
208
- fillColor: color.background,
209
- strokeColor: color.border,
210
- strokeWeight: 2,
211
- anchor: new api.Point(10, 35),
212
- labelOrigin: new api.Point(10, 11)
213
- }), this.marker = new GMarker({
214
- draggable: !!onMove,
215
- position,
216
- map,
217
- zIndex,
218
- opacity,
219
- label,
220
- icon
221
- }), markerRef && (markerRef.current = this.marker), this.attachMoveHandler(), this.attachClickHandler();
222
- }
223
- componentDidUpdate(prevProps) {
224
- if (!this.marker)
225
- return;
226
- const { position, onMove, label, zIndex, opacity, map } = this.props;
227
- prevProps.onMove !== onMove && this.attachMoveHandler(), latLngAreEqual(prevProps.position, position) || this.marker.setPosition(position), prevProps.label !== label && this.marker.setLabel(label || null), prevProps.zIndex !== zIndex && this.marker.setZIndex(zIndex || null), prevProps.opacity !== opacity && this.marker.setOpacity(opacity || null), prevProps.map !== map && this.marker.setMap(map);
228
- }
229
- componentWillUnmount() {
230
- this.eventHandlers.move && this.eventHandlers.move.remove(), this.marker && this.marker.setMap(null);
231
- }
232
- attachMoveHandler() {
233
- const { api, onMove } = this.props;
234
- this.eventHandlers.move && this.eventHandlers.move.remove(), this.marker && onMove && (this.eventHandlers.move = api.event.addListener(this.marker, "dragend", onMove));
235
- }
236
- attachClickHandler() {
237
- const { api, onClick } = this.props;
238
- this.eventHandlers.click && this.eventHandlers.click.remove(), this.marker && onClick && (this.eventHandlers.click = api.event.addListener(this.marker, "click", onClick));
239
- }
240
- // eslint-disable-next-line class-methods-use-this
241
- render() {
242
- return null;
243
- }
244
- }
245
- const fallbackLatLng$1 = { lat: 40.7058254, lng: -74.1180863 }, GeopointSelect = ({
246
- api,
247
- value,
248
- onChange,
249
- defaultLocation = { lng: 10.74609, lat: 59.91273 },
250
- defaultZoom = 8
251
- }) => {
252
- const getCenter2 = react.useCallback(() => ({ ...fallbackLatLng$1, ...defaultLocation, ...value }), [value, defaultLocation]), setValue = react.useCallback(
253
- (geoPoint) => {
254
- onChange && onChange(geoPoint);
255
- },
256
- [onChange]
257
- ), handlePlaceChanged = react.useCallback(
258
- (place) => {
259
- place.geometry?.location && setValue(place.geometry.location);
260
- },
261
- [setValue]
262
- ), handleMarkerDragEnd = react.useCallback(
263
- (event) => {
264
- event.latLng && setValue(event.latLng);
265
- },
266
- [setValue]
267
- ), handleMapClick = react.useCallback(
268
- (event) => {
269
- event.latLng && setValue(event.latLng);
270
- },
271
- [setValue]
272
- );
273
- return /* @__PURE__ */ jsxRuntime.jsx(GoogleMap, { api, location: getCenter2(), onClick: handleMapClick, defaultZoom, children: (map) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
274
- /* @__PURE__ */ jsxRuntime.jsx(SearchInput, { api, map, onChange: handlePlaceChanged }),
275
- value && /* @__PURE__ */ jsxRuntime.jsx(
276
- Marker,
277
- {
278
- api,
279
- map,
280
- position: value,
281
- onMove: onChange ? handleMarkerDragEnd : void 0
282
- }
283
- )
284
- ] }) });
285
- }, EMPTY_PATH$1 = [], getStaticImageUrl$1 = (value, apiKey) => {
286
- const loc = `${value.lat},${value.lng}`;
287
- return `https://maps.googleapis.com/maps/api/staticmap?${new URLSearchParams({
288
- key: apiKey,
289
- center: loc,
290
- markers: loc,
291
- zoom: "13",
292
- scale: "2",
293
- size: "640x300"
294
- }).toString()}`;
295
- };
296
- function GeopointInput(props) {
297
- const {
298
- changed,
299
- elementProps,
300
- focused,
301
- geoConfig: config2,
302
- onChange,
303
- onPathFocus,
304
- path,
305
- readOnly,
306
- schemaType,
307
- value
308
- } = props, {
309
- id,
310
- ref: inputRef,
311
- onBlur: handleBlur,
312
- onFocus: handleFocus,
313
- "aria-describedby": ariaDescribedBy
314
- } = elementProps, schemaTypeName = schemaType.name, dialogId = react.useId(), dialogRef = react.useRef(null), handleFocusButton = react.useCallback(() => inputRef?.current?.focus(), [inputRef]), [modalOpen, setModalOpen] = react.useState(!1), handleCloseModal = react.useCallback(() => {
315
- dialogRef.current && dialogRef.current.blur(), setModalOpen(!1), handleFocusButton();
316
- }, [setModalOpen, handleFocusButton]), handleToggleModal = react.useCallback(
317
- () => setModalOpen((currentState) => !currentState),
318
- [setModalOpen]
319
- ), handleChange = react.useCallback(
320
- (latLng) => {
321
- onChange([
322
- sanity.setIfMissing({ _type: schemaTypeName }),
323
- sanity.set(latLng.lat(), ["lat"]),
324
- sanity.set(latLng.lng(), ["lng"])
325
- ]);
326
- },
327
- [schemaTypeName, onChange]
328
- ), handleClear = react.useCallback(() => {
329
- onChange(sanity.unset());
330
- }, [onChange]);
331
- return react.useEffect(() => {
332
- modalOpen && onPathFocus(EMPTY_PATH$1);
333
- }, [modalOpen, onPathFocus]), !config2 || !config2.apiKey ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
334
- /* @__PURE__ */ jsxRuntime.jsxs("p", { children: [
335
- "The ",
336
- /* @__PURE__ */ jsxRuntime.jsx("a", { href: "https://sanity.io/docs/schema-types/geopoint-type", children: "Geopoint type" }),
337
- " needs a Google Maps API key with access to:"
338
- ] }),
339
- /* @__PURE__ */ jsxRuntime.jsxs("ul", { children: [
340
- /* @__PURE__ */ jsxRuntime.jsx("li", { children: "Google Maps JavaScript API" }),
341
- /* @__PURE__ */ jsxRuntime.jsx("li", { children: "Google Places API Web Service" }),
342
- /* @__PURE__ */ jsxRuntime.jsx("li", { children: "Google Static Maps API" })
343
- ] }),
344
- /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Please enter the API key with access to these services in your googleMapsInput plugin config." })
345
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
346
- value && /* @__PURE__ */ jsxRuntime.jsx(sanity.ChangeIndicator, { path, isChanged: changed, hasFocus: !!focused, children: /* @__PURE__ */ jsxRuntime.jsx(
347
- PreviewImage,
348
- {
349
- src: getStaticImageUrl$1(value, config2.apiKey),
350
- alt: "Map location",
351
- onClick: handleFocusButton,
352
- onDoubleClick: handleToggleModal
353
- }
354
- ) }),
355
- /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Grid, { columns: value ? 2 : 1, gap: 3, children: [
356
- /* @__PURE__ */ jsxRuntime.jsx(
357
- ui.Button,
358
- {
359
- "aria-describedby": ariaDescribedBy,
360
- disabled: readOnly,
361
- icon: value && icons.EditIcon,
362
- id,
363
- mode: "ghost",
364
- onClick: handleToggleModal,
365
- onFocus: handleFocus,
366
- padding: 3,
367
- ref: inputRef,
368
- text: value ? "Edit" : "Set location"
369
- }
370
- ),
371
- value && /* @__PURE__ */ jsxRuntime.jsx(
372
- ui.Button,
373
- {
374
- disabled: readOnly,
375
- icon: icons.TrashIcon,
376
- mode: "ghost",
377
- onClick: handleClear,
378
- padding: 3,
379
- text: "Remove",
380
- tone: "critical"
381
- }
382
- )
383
- ] }) }),
384
- modalOpen && /* @__PURE__ */ jsxRuntime.jsx(
385
- ui.Dialog,
386
- {
387
- header: "Place the marker on the map",
388
- id: `${dialogId}_dialog`,
389
- onBlur: handleBlur,
390
- onClose: handleCloseModal,
391
- ref: dialogRef,
392
- width: 1,
393
- children: /* @__PURE__ */ jsxRuntime.jsx(DialogInnerContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(GoogleMapsLoadProxy, { config: getGeoConfig(), children: (api) => /* @__PURE__ */ jsxRuntime.jsx(
394
- GeopointSelect,
395
- {
396
- api,
397
- value: value || void 0,
398
- onChange: readOnly ? void 0 : handleChange,
399
- defaultLocation: config2.defaultLocation,
400
- defaultZoom: config2.defaultZoom
401
- }
402
- ) }) })
403
- }
404
- )
405
- ] });
406
- }
407
- const fallbackLatLng = { lat: 40.7058254, lng: -74.1180863 }, MarkerDragSync = ({ api, marker, circleRef, isMarkerDragging }) => (react.useEffect(() => {
408
- const handleDrag = () => {
409
- isMarkerDragging.current = !0;
410
- }, handleDragEnd = () => {
411
- isMarkerDragging.current = !1;
412
- }, dragListener = api.event.addListener(marker, "drag", handleDrag), dragEndListener = api.event.addListener(marker, "dragend", handleDragEnd);
413
- return () => {
414
- api.event.removeListener(dragListener), api.event.removeListener(dragEndListener);
415
- };
416
- }, [api, marker, circleRef, isMarkerDragging]), null), GeopointRadiusSelect = ({
417
- api,
418
- value,
419
- onChange,
420
- defaultLocation = { lng: 10.74609, lat: 59.91273 },
421
- defaultRadiusZoom = 12,
422
- defaultRadius = 1e3
423
- }) => {
424
- const circleRef = react.useRef(null), markerRef = react.useRef(void 0), isMarkerDragging = react.useRef(!1), getCenter2 = react.useCallback(() => ({ ...fallbackLatLng, ...defaultLocation, ...value }), [value, defaultLocation]), setValue = react.useCallback(
425
- (geoPoint, radius) => {
426
- if (onChange) {
427
- const roundedRadius = radius ? Math.round(radius) : void 0;
428
- onChange(geoPoint, roundedRadius);
429
- }
430
- },
431
- [onChange]
432
- ), handlePlaceChanged = react.useCallback(
433
- (place) => {
434
- place.geometry?.location && setValue(place.geometry.location, value?.radius || defaultRadius);
435
- },
436
- [setValue, value?.radius, defaultRadius]
437
- ), handleMarkerDragEnd = react.useCallback(
438
- (event) => {
439
- event.latLng && (circleRef.current && circleRef.current.setCenter(event.latLng), setValue(event.latLng, value?.radius || defaultRadius));
440
- },
441
- [setValue, value?.radius, defaultRadius]
442
- ), handleMapClick = react.useCallback(
443
- (event) => {
444
- event.latLng && setValue(event.latLng, value?.radius || defaultRadius);
445
- },
446
- [setValue, value?.radius, defaultRadius]
447
- );
448
- return react.useEffect(() => {
449
- value && circleRef.current && (circleRef.current.setCenter({ lat: value.lat, lng: value.lng }), circleRef.current.setRadius(value.radius));
450
- }, [value]), /* @__PURE__ */ jsxRuntime.jsx(
451
- GoogleMap,
452
- {
453
- api,
454
- location: getCenter2(),
455
- onClick: handleMapClick,
456
- defaultZoom: defaultRadiusZoom,
457
- children: (map) => (value && !circleRef.current && (circleRef.current = new api.Circle({
458
- map,
459
- center: { lat: value.lat, lng: value.lng },
460
- radius: value.radius,
461
- fillColor: "#4285F4",
462
- fillOpacity: 0.2,
463
- strokeColor: "#4285F4",
464
- strokeOpacity: 0.8,
465
- strokeWeight: 2,
466
- editable: !0
467
- }), circleRef.current.addListener("center_changed", () => {
468
- if (circleRef.current && markerRef.current && !isMarkerDragging.current) {
469
- const circleCenter = circleRef.current.getCenter();
470
- circleCenter && markerRef.current.setPosition(circleCenter);
471
- }
472
- }), circleRef.current.addListener("radius_changed", () => {
473
- if (circleRef.current) {
474
- const center = circleRef.current.getCenter(), radius = circleRef.current.getRadius();
475
- center && setValue(center, Math.round(radius));
476
- }
477
- }), circleRef.current.addListener("dragend", () => {
478
- if (circleRef.current) {
479
- const center = circleRef.current.getCenter(), radius = circleRef.current.getRadius();
480
- center && setValue(center, Math.round(radius));
481
- }
482
- })), /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
483
- /* @__PURE__ */ jsxRuntime.jsx(SearchInput, { api, map, onChange: handlePlaceChanged }),
484
- value && /* @__PURE__ */ jsxRuntime.jsx(
485
- Marker,
486
- {
487
- api,
488
- map,
489
- position: value,
490
- onMove: onChange ? handleMarkerDragEnd : void 0,
491
- markerRef
492
- }
493
- ),
494
- value && markerRef.current && /* @__PURE__ */ jsxRuntime.jsx(
495
- MarkerDragSync,
496
- {
497
- api,
498
- marker: markerRef.current,
499
- circleRef,
500
- isMarkerDragging
501
- }
502
- )
503
- ] }))
504
- }
505
- );
506
- }, EMPTY_PATH = [], generateCirclePoints = (lat, lng, radius) => {
507
- const points = [];
508
- for (let i = 0; i <= 32; i++) {
509
- const angle = i / 32 * 2 * Math.PI, latOffset = radius / 111e3 * Math.cos(angle), lngOffset = radius / (111e3 * Math.cos(lat * Math.PI / 180)) * Math.sin(angle);
510
- points.push({
511
- lat: lat + latOffset,
512
- lng: lng + lngOffset
513
- });
514
- }
515
- return points;
516
- }, getStaticImageUrl = (value, apiKey) => {
517
- const loc = `${value.lat},${value.lng}`;
518
- let zoom = 13;
519
- if (value.radius) {
520
- const scale = (value.radius + value.radius / 2) / 500, calculatedZoom = 16 - Math.log(scale) / Math.log(2);
521
- zoom = Math.max(8, Math.min(16, Math.round(calculatedZoom - 0.4)));
522
- }
523
- const qs = new URLSearchParams({
524
- key: apiKey,
525
- center: loc,
526
- markers: loc,
527
- zoom: zoom.toString(),
528
- scale: "2",
529
- size: "640x300"
530
- });
531
- if (value.radius) {
532
- const path = generateCirclePoints(value.lat, value.lng, value.radius).map((p) => `${p.lat},${p.lng}`).join("|");
533
- qs.append("path", `fillcolor:0x4285F480|color:0x4285F4|weight:2|${path}`);
534
- }
535
- return `https://maps.googleapis.com/maps/api/staticmap?${qs.toString()}`;
536
- };
537
- function GeopointRadiusInput(props) {
538
- const {
539
- changed,
540
- elementProps,
541
- focused,
542
- geoConfig: config2,
543
- onChange,
544
- onPathFocus,
545
- path,
546
- readOnly,
547
- schemaType,
548
- value
549
- } = props, {
550
- id,
551
- ref: inputRef,
552
- onBlur: handleBlur,
553
- onFocus: handleFocus,
554
- "aria-describedby": ariaDescribedBy
555
- } = elementProps, schemaTypeName = schemaType.name, dialogId = react.useId(), dialogRef = react.useRef(null), handleFocusButton = react.useCallback(() => inputRef?.current?.focus(), [inputRef]), [modalOpen, setModalOpen] = react.useState(!1), handleCloseModal = react.useCallback(() => {
556
- dialogRef.current && dialogRef.current.blur(), setModalOpen(!1), handleFocusButton();
557
- }, [setModalOpen, handleFocusButton]), handleToggleModal = react.useCallback(
558
- () => setModalOpen((currentState) => !currentState),
559
- [setModalOpen]
560
- ), handleChange = react.useCallback(
561
- (latLng, radius) => {
562
- const currentRadius = radius ?? value?.radius ?? config2.defaultRadius ?? 1e3;
563
- onChange([
564
- sanity.setIfMissing({ _type: schemaTypeName }),
565
- sanity.set(latLng.lat(), ["lat"]),
566
- sanity.set(latLng.lng(), ["lng"]),
567
- sanity.set(currentRadius, ["radius"])
568
- ]);
569
- },
570
- [schemaTypeName, onChange, value?.radius, config2.defaultRadius]
571
- ), handleRadiusChange = react.useCallback(
572
- (event) => {
573
- value && onChange([sanity.set(Math.round(Number(event.currentTarget.value)), ["radius"])]);
574
- },
575
- [onChange, value]
576
- ), handleClear = react.useCallback(() => {
577
- onChange(sanity.unset());
578
- }, [onChange]);
579
- return react.useEffect(() => {
580
- modalOpen && onPathFocus(EMPTY_PATH);
581
- }, [modalOpen, onPathFocus]), !config2 || !config2.apiKey ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
582
- /* @__PURE__ */ jsxRuntime.jsxs("p", { children: [
583
- "The ",
584
- /* @__PURE__ */ jsxRuntime.jsx("a", { href: "https://sanity.io/docs/schema-types/geopoint-type", children: "Geopoint Radius type" }),
585
- " ",
586
- "needs a Google Maps API key with access to:"
587
- ] }),
588
- /* @__PURE__ */ jsxRuntime.jsxs("ul", { children: [
589
- /* @__PURE__ */ jsxRuntime.jsx("li", { children: "Google Maps JavaScript API" }),
590
- /* @__PURE__ */ jsxRuntime.jsx("li", { children: "Google Places API Web Service" }),
591
- /* @__PURE__ */ jsxRuntime.jsx("li", { children: "Google Static Maps API" })
592
- ] }),
593
- /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Please enter the API key with access to these services in your googleMapsInput plugin config." })
594
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
595
- value && /* @__PURE__ */ jsxRuntime.jsx(sanity.ChangeIndicator, { path, isChanged: changed, hasFocus: !!focused, children: /* @__PURE__ */ jsxRuntime.jsx(
596
- PreviewImage,
597
- {
598
- src: getStaticImageUrl(value, config2.apiKey),
599
- alt: "Map location with radius",
600
- onClick: handleFocusButton,
601
- onDoubleClick: handleToggleModal
602
- }
603
- ) }),
604
- value && /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
605
- /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: "Radius (meters)" }),
606
- /* @__PURE__ */ jsxRuntime.jsx(
607
- ui.TextInput,
608
- {
609
- type: "number",
610
- value: Math.round(value.radius || config2.defaultRadius || 1e3),
611
- onChange: handleRadiusChange,
612
- disabled: readOnly,
613
- min: 1,
614
- max: 5e4,
615
- step: 1
616
- }
617
- )
618
- ] }),
619
- /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Grid, { columns: value ? 2 : 1, gap: 3, children: [
620
- /* @__PURE__ */ jsxRuntime.jsx(
621
- ui.Button,
622
- {
623
- "aria-describedby": ariaDescribedBy,
624
- disabled: readOnly,
625
- icon: value && icons.EditIcon,
626
- id,
627
- mode: "ghost",
628
- onClick: handleToggleModal,
629
- onFocus: handleFocus,
630
- padding: 3,
631
- ref: inputRef,
632
- text: value ? "Edit" : "Set location and radius"
633
- }
634
- ),
635
- value && /* @__PURE__ */ jsxRuntime.jsx(
636
- ui.Button,
637
- {
638
- disabled: readOnly,
639
- icon: icons.TrashIcon,
640
- mode: "ghost",
641
- onClick: handleClear,
642
- padding: 3,
643
- text: "Remove",
644
- tone: "critical"
645
- }
646
- )
647
- ] }) }),
648
- modalOpen && /* @__PURE__ */ jsxRuntime.jsx(
649
- ui.Dialog,
650
- {
651
- header: "Place the marker and set radius on the map",
652
- id: `${dialogId}_dialog`,
653
- onBlur: handleBlur,
654
- onClose: handleCloseModal,
655
- ref: dialogRef,
656
- width: 1,
657
- children: /* @__PURE__ */ jsxRuntime.jsx(DialogInnerContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(GoogleMapsLoadProxy, { config: getGeoConfig(), children: (api) => /* @__PURE__ */ jsxRuntime.jsx(
658
- GeopointRadiusSelect,
659
- {
660
- api,
661
- value: value || void 0,
662
- onChange: readOnly ? void 0 : handleChange,
663
- defaultLocation: config2.defaultLocation,
664
- defaultRadiusZoom: config2.defaultRadiusZoom,
665
- defaultRadius: config2.defaultRadius
666
- }
667
- ) }) })
668
- }
669
- )
670
- ] });
671
- }
672
- class Arrow extends react.PureComponent {
673
- line;
674
- eventHandlers = {};
675
- componentDidMount() {
676
- const { from, to, api, map, zIndex, onClick, color, arrowRef } = this.props, lineSymbol = {
677
- path: api.SymbolPath.FORWARD_OPEN_ARROW
678
- };
679
- this.line = new api.Polyline({
680
- map,
681
- zIndex,
682
- path: [from, to],
683
- icons: [{ icon: lineSymbol, offset: "50%" }],
684
- strokeOpacity: 0.55,
685
- strokeColor: color ? color.text : "black"
686
- }), onClick && (this.eventHandlers.click = api.event.addListener(this.line, "click", onClick)), arrowRef && (arrowRef.current = this.line);
687
- }
688
- componentDidUpdate(prevProps) {
689
- if (!this.line)
690
- return;
691
- const { from, to, map } = this.props;
692
- (!latLngAreEqual(prevProps.from, from) || !latLngAreEqual(prevProps.to, to)) && this.line.setPath([from, to]), prevProps.map !== map && this.line.setMap(map);
693
- }
694
- componentWillUnmount() {
695
- this.line && this.line.setMap(null), this.eventHandlers.click && this.eventHandlers.click.remove();
696
- }
697
- // eslint-disable-next-line class-methods-use-this
698
- render() {
699
- return null;
700
- }
701
- }
702
- function GeopointMove({ diff, api, map, label }) {
703
- const { fromValue: from, toValue: to } = diff, annotation = diff.isChanged ? diff.annotation : void 0, userColor = sanity.useUserColor(annotation ? annotation.author : null) || void 0, fromRef = react.useRef(void 0), toRef = react.useRef(void 0);
704
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
705
- from && /* @__PURE__ */ jsxRuntime.jsx(
706
- Marker,
707
- {
708
- api,
709
- map,
710
- position: from,
711
- zIndex: 0,
712
- opacity: 0.55,
713
- markerRef: fromRef,
714
- color: userColor
715
- }
716
- ),
717
- from && to && /* @__PURE__ */ jsxRuntime.jsx(Arrow, { api, map, from, to, zIndex: 1, color: userColor }),
718
- to && /* @__PURE__ */ jsxRuntime.jsx(
719
- Marker,
720
- {
721
- api,
722
- map,
723
- position: to,
724
- zIndex: 2,
725
- markerRef: toRef,
726
- label,
727
- color: userColor
728
- }
729
- )
730
- ] });
731
- }
732
- const RootContainer = styledComponents.styled.div`
733
- position: relative;
734
- min-height: 200px;
735
-
736
- &:empty {
737
- background-color: var(--card-skeleton-color-from);
738
- display: table;
739
- width: 100%;
740
- }
741
-
742
- &:empty:after {
743
- content: 'Missing/invalid data';
744
- display: table-cell;
745
- vertical-align: middle;
746
- text-align: center;
747
- position: relative;
748
- }
749
- `, GeopointArrayDiff = ({
750
- diff,
751
- schemaType
752
- }) => /* @__PURE__ */ jsxRuntime.jsx(RootContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(GoogleMapsLoadProxy, { config: getGeoConfig(), children: (api) => /* @__PURE__ */ jsxRuntime.jsx(GeopointDiff$1, { api, diff, schemaType }) }) });
753
- function GeopointDiff$1({ api, diff }) {
754
- const fromValue = (diff.fromValue || []).filter(hasCoordinates), toValue = (diff.toValue || []).filter(hasCoordinates);
755
- if (fromValue.length === 0 && toValue.length === 0)
756
- return null;
757
- const bounds = getBounds$2(fromValue, toValue, api);
758
- return /* @__PURE__ */ jsxRuntime.jsx(
759
- GoogleMap,
760
- {
761
- api,
762
- location: bounds.getCenter().toJSON(),
763
- mapTypeControl: !1,
764
- controlSize: 20,
765
- bounds,
766
- children: (map) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: diff.items.map(({ toIndex, diff: pointDiff }) => isChangeDiff(pointDiff) ? /* @__PURE__ */ jsxRuntime.jsx(
767
- GeopointMove,
768
- {
769
- api,
770
- map,
771
- diff: pointDiff,
772
- label: `${toIndex}`
773
- },
774
- toIndex
775
- ) : null) })
776
- }
777
- );
778
- }
779
- function isChangeDiff(diff) {
780
- return diff.action !== "unchanged" && diff.type === "object";
781
- }
782
- function hasCoordinates(point) {
783
- return typeof point.lat == "number" && typeof point.lng == "number";
784
- }
785
- function getBounds$2(fromValue, toValue, api) {
786
- const bounds = new api.LatLngBounds();
787
- return [...fromValue || [], ...toValue || []].forEach((point) => bounds.extend(point)), bounds;
788
- }
789
- const GeopointFieldDiff = ({
790
- diff,
791
- schemaType
792
- }) => /* @__PURE__ */ jsxRuntime.jsx(RootContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(GoogleMapsLoadProxy, { config: getGeoConfig(), children: (api) => /* @__PURE__ */ jsxRuntime.jsx(GeopointDiff, { api, diff, schemaType }) }) });
793
- function GeopointDiff({ api, diff }) {
794
- const { fromValue, toValue } = diff, annotation = sanity.getAnnotationAtPath(diff, ["lat"]) || sanity.getAnnotationAtPath(diff, ["lng"]) || sanity.getAnnotationAtPath(diff, []), center = getCenter$1(diff, api), bounds = fromValue && toValue ? getBounds$1(fromValue, toValue, api) : void 0;
795
- return /* @__PURE__ */ jsxRuntime.jsx(sanity.DiffTooltip, { annotations: annotation ? [annotation] : [], description: getAction$1(diff), children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
796
- GoogleMap,
797
- {
798
- api,
799
- location: center,
800
- mapTypeControl: !1,
801
- controlSize: 20,
802
- bounds,
803
- scrollWheel: !1,
804
- children: (map) => /* @__PURE__ */ jsxRuntime.jsx(GeopointMove, { api, map, diff })
805
- }
806
- ) }) });
807
- }
808
- function getBounds$1(fromValue, toValue, api) {
809
- return new api.LatLngBounds().extend(fromValue).extend(toValue);
810
- }
811
- function getCenter$1(diff, api) {
812
- const { fromValue, toValue } = diff;
813
- if (fromValue && toValue)
814
- return getBounds$1(fromValue, toValue, api).getCenter().toJSON();
815
- if (fromValue)
816
- return fromValue;
817
- if (toValue)
818
- return toValue;
819
- throw new Error("Neither a from or a to value present");
820
- }
821
- function getAction$1(diff) {
822
- const { fromValue, toValue } = diff;
823
- return fromValue && toValue ? "Moved" : fromValue ? "Removed" : toValue ? "Added" : "Unchanged";
824
- }
825
- function GeopointRadiusMove({ diff, api, map, label }) {
826
- const { fromValue: from, toValue: to } = diff, annotation = diff.isChanged ? diff.annotation : void 0, userColor = sanity.useUserColor(annotation ? annotation.author : null) || void 0, fromRef = react.useRef(void 0), toRef = react.useRef(void 0), fromCircleRef = react.useRef(void 0), toCircleRef = react.useRef(void 0);
827
- return react.useEffect(() => {
828
- const color = userColor?.background || "#4285F4";
829
- return from && from.radius && (fromCircleRef.current = new api.Circle({
830
- map,
831
- center: { lat: from.lat, lng: from.lng },
832
- radius: from.radius,
833
- fillColor: color,
834
- fillOpacity: 0.1,
835
- strokeColor: color,
836
- strokeOpacity: 0.3,
837
- strokeWeight: 1,
838
- zIndex: 0
839
- })), to && to.radius && (toCircleRef.current = new api.Circle({
840
- map,
841
- center: { lat: to.lat, lng: to.lng },
842
- radius: to.radius,
843
- fillColor: color,
844
- fillOpacity: 0.2,
845
- strokeColor: color,
846
- strokeOpacity: 0.8,
847
- strokeWeight: 2,
848
- zIndex: 2
849
- })), () => {
850
- fromCircleRef.current && fromCircleRef.current.setMap(null), toCircleRef.current && toCircleRef.current.setMap(null);
851
- };
852
- }, [api, map, from, to, userColor]), /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
853
- from && /* @__PURE__ */ jsxRuntime.jsx(
854
- Marker,
855
- {
856
- api,
857
- map,
858
- position: from,
859
- zIndex: 0,
860
- opacity: 0.55,
861
- markerRef: fromRef,
862
- color: userColor
863
- }
864
- ),
865
- from && to && /* @__PURE__ */ jsxRuntime.jsx(Arrow, { api, map, from, to, zIndex: 1, color: userColor }),
866
- to && /* @__PURE__ */ jsxRuntime.jsx(
867
- Marker,
868
- {
869
- api,
870
- map,
871
- position: to,
872
- zIndex: 2,
873
- markerRef: toRef,
874
- label,
875
- color: userColor
876
- }
877
- )
878
- ] });
879
- }
880
- const GeopointRadiusFieldDiff = ({
881
- diff,
882
- schemaType
883
- }) => /* @__PURE__ */ jsxRuntime.jsx(RootContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(GoogleMapsLoadProxy, { config: getGeoConfig(), children: (api) => /* @__PURE__ */ jsxRuntime.jsx(GeopointRadiusDiff, { api, diff, schemaType }) }) });
884
- function GeopointRadiusDiff({ api, diff }) {
885
- const { fromValue, toValue } = diff, annotation = sanity.getAnnotationAtPath(diff, ["lat"]) || sanity.getAnnotationAtPath(diff, ["lng"]) || sanity.getAnnotationAtPath(diff, ["radius"]) || sanity.getAnnotationAtPath(diff, []), center = getCenter(diff, api), bounds = fromValue && toValue ? getBounds(fromValue, toValue, api) : void 0;
886
- return /* @__PURE__ */ jsxRuntime.jsx(sanity.DiffTooltip, { annotations: annotation ? [annotation] : [], description: getAction(diff), children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
887
- GoogleMap,
888
- {
889
- api,
890
- location: center,
891
- mapTypeControl: !1,
892
- controlSize: 20,
893
- bounds,
894
- scrollWheel: !1,
895
- children: (map) => /* @__PURE__ */ jsxRuntime.jsx(GeopointRadiusMove, { api, map, diff })
896
- }
897
- ) }) });
898
- }
899
- function getBounds(fromValue, toValue, api) {
900
- const bounds = new api.LatLngBounds().extend(fromValue).extend(toValue), fromRadius = fromValue.radius || 0, toRadius = toValue.radius || 0, maxRadius = Math.max(fromRadius, toRadius);
901
- if (maxRadius > 0) {
902
- const radiusInDegrees = maxRadius / 111e3;
903
- bounds.extend({
904
- lat: fromValue.lat + radiusInDegrees,
905
- lng: fromValue.lng + radiusInDegrees
906
- }), bounds.extend({
907
- lat: fromValue.lat - radiusInDegrees,
908
- lng: fromValue.lng - radiusInDegrees
909
- }), bounds.extend({
910
- lat: toValue.lat + radiusInDegrees,
911
- lng: toValue.lng + radiusInDegrees
912
- }), bounds.extend({
913
- lat: toValue.lat - radiusInDegrees,
914
- lng: toValue.lng - radiusInDegrees
915
- });
916
- }
917
- return bounds;
918
- }
919
- function getCenter(diff, api) {
920
- const { fromValue, toValue } = diff;
921
- if (fromValue && toValue)
922
- return getBounds(fromValue, toValue, api).getCenter().toJSON();
923
- if (fromValue)
924
- return fromValue;
925
- if (toValue)
926
- return toValue;
927
- throw new Error("Neither a from or a to value present");
928
- }
929
- function getAction(diff) {
930
- const { fromValue, toValue } = diff;
931
- if (fromValue && toValue) {
932
- const latChanged = fromValue.lat !== toValue.lat || fromValue.lng !== toValue.lng, radiusChanged = fromValue.radius !== toValue.radius;
933
- return latChanged && radiusChanged ? "Moved and radius changed" : latChanged ? "Moved" : radiusChanged ? "Radius changed" : "Unchanged";
934
- } else {
935
- if (fromValue)
936
- return "Removed";
937
- if (toValue)
938
- return "Added";
939
- }
940
- return "Unchanged";
941
- }
942
- const googleMapsInput = sanity.definePlugin((config2) => (setGeoConfig(config2), {
943
- name: "google-maps-input",
944
- schema: {
945
- types: [
946
- {
947
- name: "geopointRadius",
948
- title: "Geopoint with Radius",
949
- type: "object",
950
- fields: [
951
- {
952
- name: "lat",
953
- title: "Latitude",
954
- type: "number",
955
- validation: (Rule) => Rule.required().min(-90).max(90)
956
- },
957
- {
958
- name: "lng",
959
- title: "Longitude",
960
- type: "number",
961
- validation: (Rule) => Rule.required().min(-180).max(180)
962
- },
963
- {
964
- name: "alt",
965
- title: "Altitude",
966
- type: "number"
967
- },
968
- {
969
- name: "radius",
970
- title: "Radius (meters)",
971
- type: "number",
972
- validation: (Rule) => Rule.required().min(1).max(5e4)
973
- }
974
- ],
975
- preview: {
976
- select: {
977
- lat: "lat",
978
- lng: "lng",
979
- radius: "radius"
980
- },
981
- prepare({ lat, lng, radius }) {
982
- return {
983
- title: `${lat.toFixed(6)}, ${lng.toFixed(6)}`,
984
- subtitle: radius ? `Radius: ${radius}m` : "No radius set"
985
- };
986
- }
987
- }
988
- }
989
- ]
990
- },
991
- form: {
992
- components: {
993
- input(props) {
994
- return isGeopoint(props.schemaType) ? /* @__PURE__ */ jsxRuntime.jsx(GeopointInput, { ...props, geoConfig: config2 }) : isGeopointRadius(props.schemaType) ? /* @__PURE__ */ jsxRuntime.jsx(GeopointRadiusInput, { ...props, geoConfig: config2 }) : props.renderDefault(props);
995
- }
996
- }
997
- }
998
- }));
999
- function isGeopoint(schemaType) {
1000
- return isType("geopoint", schemaType);
1001
- }
1002
- function isGeopointRadius(schemaType) {
1003
- return isType("geopointRadius", schemaType);
1004
- }
1005
- function isType(name, schema) {
1006
- return schema?.name === name ? !0 : schema?.name ? isType(name, schema?.type) : !1;
1007
- }
1008
- exports.GeopointArrayDiff = GeopointArrayDiff;
1009
- exports.GeopointFieldDiff = GeopointFieldDiff;
1010
- exports.GeopointInput = GeopointInput;
1011
- exports.GeopointRadiusFieldDiff = GeopointRadiusFieldDiff;
1012
- exports.GeopointRadiusInput = GeopointRadiusInput;
1013
- exports.googleMapsInput = googleMapsInput;
1014
- //# sourceMappingURL=index.cjs.map