@sanity/google-maps-input 5.0.2 → 6.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.
- package/README.md +17 -35
- package/dist/index.d.ts +17 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +443 -860
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -1,319 +1,275 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react/compiler-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { DiffFromTo, setIfMissing, set, unset, ChangeIndicator, definePlugin } from "sanity";
|
|
4
|
+
import { ImageIcon, WarningOutlineIcon, ErrorOutlineIcon, EditIcon, TrashIcon } from "@sanity/icons";
|
|
5
|
+
import { Flex, Text, Card, Box, Stack, Code, Spinner, Button, Grid, Dialog, Label, TextInput } from "@sanity/ui";
|
|
6
|
+
import { createContext, useState, use, useId, useRef, useEffect } from "react";
|
|
7
|
+
import { createStaticMapsUrl, useApiLoadingStatus, APILoadingStatus, useMapsLibrary, useMap, Map, MapControl, ControlPosition, AdvancedMarker, StaticMap, APIProvider, Circle } from "@vis.gl/react-google-maps";
|
|
7
8
|
import { styled } from "styled-components";
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
return
|
|
9
|
+
const DEFAULT_WIDTH = 640, DEFAULT_HEIGHT = 300, METERS_PER_DEGREE = 111e3, MIN_LATITUDE_COSINE = 0.01, CIRCLE_OUTLINE = "0x4285F4", CIRCLE_FILL = "0x4285F480";
|
|
10
|
+
function lngMetersPerDegree(lat) {
|
|
11
|
+
return METERS_PER_DEGREE * Math.max(Math.cos(lat * Math.PI / 180), MIN_LATITUDE_COSINE);
|
|
12
|
+
}
|
|
13
|
+
function getGeopointStaticMapUrl(value, apiKey, {
|
|
14
|
+
width = DEFAULT_WIDTH,
|
|
15
|
+
height = DEFAULT_HEIGHT
|
|
16
|
+
} = {}) {
|
|
17
|
+
const center = {
|
|
18
|
+
lat: value.lat,
|
|
19
|
+
lng: value.lng
|
|
20
|
+
};
|
|
21
|
+
return createStaticMapsUrl({
|
|
22
|
+
apiKey,
|
|
23
|
+
width,
|
|
24
|
+
height,
|
|
25
|
+
scale: 2,
|
|
26
|
+
zoom: 13,
|
|
27
|
+
center,
|
|
28
|
+
markers: [{
|
|
29
|
+
location: center
|
|
30
|
+
}]
|
|
31
|
+
});
|
|
11
32
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
33
|
+
function generateCirclePoints(lat, lng, radius) {
|
|
34
|
+
const points = [], latRatio = radius / METERS_PER_DEGREE, lngRatio = radius / lngMetersPerDegree(lat);
|
|
35
|
+
for (let i = 0; i <= 64; i++) {
|
|
36
|
+
const angle = i / 64 * 2 * Math.PI;
|
|
37
|
+
points.push({
|
|
38
|
+
lat: lat + latRatio * Math.cos(angle),
|
|
39
|
+
lng: lng + lngRatio * Math.sin(angle)
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return points;
|
|
14
43
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
44
|
+
const BOUNDS_PADDING = 1.15;
|
|
45
|
+
function getCircleBounds(lat, lng, radius) {
|
|
46
|
+
const padded = radius * BOUNDS_PADDING, latDelta = padded / METERS_PER_DEGREE, lngDelta = padded / lngMetersPerDegree(lat);
|
|
47
|
+
return [{
|
|
48
|
+
lat: lat + latDelta,
|
|
49
|
+
lng
|
|
50
|
+
}, {
|
|
51
|
+
lat: lat - latDelta,
|
|
52
|
+
lng
|
|
53
|
+
}, {
|
|
54
|
+
lat,
|
|
55
|
+
lng: lng + lngDelta
|
|
56
|
+
}, {
|
|
57
|
+
lat,
|
|
58
|
+
lng: lng - lngDelta
|
|
59
|
+
}];
|
|
60
|
+
}
|
|
61
|
+
function getGeopointRadiusStaticMapUrl(value, apiKey, {
|
|
62
|
+
width = DEFAULT_WIDTH,
|
|
63
|
+
height = DEFAULT_HEIGHT
|
|
64
|
+
} = {}) {
|
|
65
|
+
return value.radius ? createStaticMapsUrl({
|
|
66
|
+
apiKey,
|
|
67
|
+
width,
|
|
68
|
+
height,
|
|
69
|
+
scale: 2,
|
|
70
|
+
markers: [{
|
|
71
|
+
location: {
|
|
72
|
+
lat: value.lat,
|
|
73
|
+
lng: value.lng
|
|
74
|
+
}
|
|
75
|
+
}],
|
|
76
|
+
paths: [{
|
|
77
|
+
coordinates: generateCirclePoints(value.lat, value.lng, value.radius),
|
|
78
|
+
color: CIRCLE_OUTLINE,
|
|
79
|
+
weight: 2,
|
|
80
|
+
fillcolor: CIRCLE_FILL
|
|
81
|
+
}],
|
|
82
|
+
visible: getCircleBounds(value.lat, value.lng, value.radius)
|
|
83
|
+
}) : getGeopointStaticMapUrl(value, apiKey, {
|
|
84
|
+
width,
|
|
85
|
+
height
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const GoogleMapsInputContext = createContext(null);
|
|
89
|
+
GoogleMapsInputContext.displayName = "GoogleMapsInputContext";
|
|
90
|
+
const MapDiffImage = styled.div.withConfig({
|
|
91
|
+
displayName: "MapDiffImage",
|
|
92
|
+
componentId: "sc-1uvj7r6-0"
|
|
93
|
+
})`& img{display:block;width:100%;height:auto;object-fit:contain;vertical-align:top;}`, MapDiffPlaceholder = styled.div.withConfig({
|
|
94
|
+
displayName: "MapDiffPlaceholder",
|
|
95
|
+
componentId: "sc-1uvj7r6-1"
|
|
96
|
+
})`width:100%;min-height:80px;display:flex;align-items:center;justify-content:center;`;
|
|
97
|
+
function hasRadius(value) {
|
|
98
|
+
return typeof value.radius == "number";
|
|
99
|
+
}
|
|
100
|
+
function StaticMapDiffPreview(t0) {
|
|
101
|
+
const $ = c(7), {
|
|
102
|
+
value
|
|
103
|
+
} = t0, [failed, setFailed] = useState(!1), apiKey = use(GoogleMapsInputContext)?.apiKey;
|
|
104
|
+
if (!value || typeof value.lat != "number" || typeof value.lng != "number" || !apiKey)
|
|
105
|
+
return null;
|
|
106
|
+
if (failed) {
|
|
107
|
+
let t12;
|
|
108
|
+
return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t12 = /* @__PURE__ */ jsx(MapDiffPlaceholder, { children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 2, justify: "center", padding: 3, children: [
|
|
109
|
+
/* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: /* @__PURE__ */ jsx(ImageIcon, {}) }),
|
|
110
|
+
/* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: "Map preview unavailable" })
|
|
111
|
+
] }) }), $[0] = t12) : t12 = $[0], t12;
|
|
112
|
+
}
|
|
19
113
|
let t1;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
114
|
+
$[1] !== apiKey || $[2] !== value ? (t1 = hasRadius(value) ? getGeopointRadiusStaticMapUrl(value, apiKey, {
|
|
115
|
+
width: 500,
|
|
116
|
+
height: 280
|
|
117
|
+
}) : getGeopointStaticMapUrl(value, apiKey, {
|
|
118
|
+
width: 500,
|
|
119
|
+
height: 280
|
|
120
|
+
}), $[1] = apiKey, $[2] = value, $[3] = t1) : t1 = $[3];
|
|
121
|
+
const url = t1;
|
|
122
|
+
let t2;
|
|
123
|
+
$[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = () => setFailed(!0), $[4] = t2) : t2 = $[4];
|
|
124
|
+
let t3;
|
|
125
|
+
return $[5] !== url ? (t3 = /* @__PURE__ */ jsx(MapDiffImage, { children: /* @__PURE__ */ jsx("img", { alt: "", src: url, onError: t2, height: 280, width: 500 }) }), $[5] = url, $[6] = t3) : t3 = $[6], t3;
|
|
27
126
|
}
|
|
28
|
-
function
|
|
127
|
+
function GeopointDiff(t0) {
|
|
128
|
+
const $ = c(3), {
|
|
129
|
+
diff,
|
|
130
|
+
schemaType
|
|
131
|
+
} = t0;
|
|
132
|
+
let t1;
|
|
133
|
+
return $[0] !== diff || $[1] !== schemaType ? (t1 = /* @__PURE__ */ jsx(DiffFromTo, { diff, schemaType, previewComponent: StaticMapDiffPreview, layout: "grid" }), $[0] = diff, $[1] = schemaType, $[2] = t1) : t1 = $[2], t1;
|
|
134
|
+
}
|
|
135
|
+
const GET_API_KEY_URL = "https://developers.google.com/maps/documentation/javascript/get-api-key", DEMO_KEY_URL = "https://developers.google.com/maps/documentation/javascript/demo-key", REQUIRED_APIS = ["Google Maps JavaScript API", "Google Static Maps API", "Google Places API (New)"];
|
|
136
|
+
function RequiredApis() {
|
|
29
137
|
const $ = c(1);
|
|
30
138
|
let t0;
|
|
31
|
-
return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */
|
|
32
|
-
/* @__PURE__ */ jsx("p", { children: "The error appears to be related to authentication" }),
|
|
33
|
-
/* @__PURE__ */ jsx("p", { children: "Common causes include:" }),
|
|
34
|
-
/* @__PURE__ */ jsxs("ul", { children: [
|
|
35
|
-
/* @__PURE__ */ jsx("li", { children: "Incorrect API key" }),
|
|
36
|
-
/* @__PURE__ */ jsx("li", { children: "Referer not allowed" }),
|
|
37
|
-
/* @__PURE__ */ jsx("li", { children: "Missing authentication scope" })
|
|
38
|
-
] }),
|
|
39
|
-
/* @__PURE__ */ jsx("p", { children: "Check the browser developer tools for more information." })
|
|
40
|
-
] }), $[0] = t0) : t0 = $[0], t0;
|
|
139
|
+
return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(Box, { paddingLeft: 3, children: /* @__PURE__ */ jsx(Stack, { as: "ul", gap: 2, children: REQUIRED_APIS.map(_temp$2) }) }), $[0] = t0) : t0 = $[0], t0;
|
|
41
140
|
}
|
|
42
|
-
|
|
43
|
-
|
|
141
|
+
function _temp$2(api) {
|
|
142
|
+
return /* @__PURE__ */ jsx(Text, { as: "li", size: 1, muted: !0, children: api }, api);
|
|
44
143
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
144
|
+
function MessageCard(t0) {
|
|
145
|
+
const $ = c(13), {
|
|
146
|
+
tone,
|
|
147
|
+
icon,
|
|
148
|
+
title,
|
|
149
|
+
children
|
|
150
|
+
} = t0;
|
|
151
|
+
let t1;
|
|
152
|
+
$[0] !== icon ? (t1 = /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Text, { size: 3, children: icon }) }), $[0] = icon, $[1] = t1) : t1 = $[1];
|
|
153
|
+
let t2;
|
|
154
|
+
$[2] !== title ? (t2 = /* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children: title }), $[2] = title, $[3] = t2) : t2 = $[3];
|
|
155
|
+
let t3;
|
|
156
|
+
$[4] !== children || $[5] !== t2 ? (t3 = /* @__PURE__ */ jsxs(Stack, { flex: 1, gap: 4, children: [
|
|
157
|
+
t2,
|
|
158
|
+
children
|
|
159
|
+
] }), $[4] = children, $[5] = t2, $[6] = t3) : t3 = $[6];
|
|
160
|
+
let t4;
|
|
161
|
+
$[7] !== t1 || $[8] !== t3 ? (t4 = /* @__PURE__ */ jsxs(Flex, { gap: 3, children: [
|
|
162
|
+
t1,
|
|
163
|
+
t3
|
|
164
|
+
] }), $[7] = t1, $[8] = t3, $[9] = t4) : t4 = $[9];
|
|
165
|
+
let t5;
|
|
166
|
+
return $[10] !== t4 || $[11] !== tone ? (t5 = /* @__PURE__ */ jsx(Card, { padding: 4, radius: 2, tone, border: !0, children: t4 }), $[10] = t4, $[11] = tone, $[12] = t5) : t5 = $[12], t5;
|
|
66
167
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
168
|
+
function MissingApiKeyCard(t0) {
|
|
169
|
+
const $ = c(10), {
|
|
170
|
+
typeTitle
|
|
171
|
+
} = t0;
|
|
172
|
+
let t1;
|
|
173
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ jsx(WarningOutlineIcon, {}), $[0] = t1) : t1 = $[0];
|
|
174
|
+
let t2;
|
|
175
|
+
$[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx("code", { children: "googleMapsInput" }), $[1] = t2) : t2 = $[1];
|
|
176
|
+
let t3;
|
|
177
|
+
$[2] !== typeTitle ? (t3 = /* @__PURE__ */ jsxs(Text, { size: 1, muted: !0, children: [
|
|
178
|
+
"The ",
|
|
179
|
+
typeTitle,
|
|
180
|
+
" field uses Google Maps and needs an API key. Add one to the",
|
|
181
|
+
" ",
|
|
182
|
+
t2,
|
|
183
|
+
" plugin configuration:"
|
|
184
|
+
] }), $[2] = typeTitle, $[3] = t3) : t3 = $[3];
|
|
185
|
+
let t4;
|
|
186
|
+
$[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = /* @__PURE__ */ jsx(Card, { padding: 3, radius: 2, tone: "transparent", border: !0, overflow: "auto", children: /* @__PURE__ */ jsx(Code, { size: 1, children: "googleMapsInput({apiKey: 'your-api-key'})" }) }), $[4] = t4) : t4 = $[4];
|
|
187
|
+
let t5;
|
|
188
|
+
$[5] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t5 = /* @__PURE__ */ jsxs(Stack, { gap: 3, children: [
|
|
189
|
+
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "The key needs these APIs enabled:" }),
|
|
190
|
+
/* @__PURE__ */ jsx(RequiredApis, {})
|
|
191
|
+
] }), $[5] = t5) : t5 = $[5];
|
|
192
|
+
let t6;
|
|
193
|
+
$[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t6 = /* @__PURE__ */ jsx("a", { href: GET_API_KEY_URL, target: "_blank", rel: "noopener noreferrer", children: "Get an API key" }), $[6] = t6) : t6 = $[6];
|
|
194
|
+
let t7;
|
|
195
|
+
$[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t7 = /* @__PURE__ */ jsxs(Text, { size: 1, muted: !0, children: [
|
|
196
|
+
t6,
|
|
197
|
+
" \xB7 ",
|
|
198
|
+
/* @__PURE__ */ jsx("a", { href: DEMO_KEY_URL, target: "_blank", rel: "noopener noreferrer", children: "use a demo key to test" })
|
|
199
|
+
] }), $[7] = t7) : t7 = $[7];
|
|
200
|
+
let t8;
|
|
201
|
+
return $[8] !== t3 ? (t8 = /* @__PURE__ */ jsxs(MessageCard, { tone: "caution", icon: t1, title: "Google Maps API key required", children: [
|
|
202
|
+
t3,
|
|
203
|
+
t4,
|
|
204
|
+
t5,
|
|
205
|
+
t7
|
|
206
|
+
] }), $[8] = t3, $[9] = t8) : t8 = $[9], t8;
|
|
69
207
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const $ = c(5), locale = config2.defaultLocale || browserLocale;
|
|
208
|
+
function InvalidApiKeyCard() {
|
|
209
|
+
const $ = c(2);
|
|
73
210
|
let t0;
|
|
74
|
-
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
typeof window > "u" || loadGoogleMapsApi({
|
|
81
|
-
locale,
|
|
82
|
-
apiKey: config2.apiKey
|
|
83
|
-
}).then((api) => setState({
|
|
84
|
-
type: "loaded",
|
|
85
|
-
api
|
|
86
|
-
}), (err) => setState({
|
|
87
|
-
type: "error",
|
|
88
|
-
error: {
|
|
89
|
-
type: err instanceof AuthError ? "authError" : "loadError",
|
|
90
|
-
message: err.message
|
|
91
|
-
}
|
|
92
|
-
}));
|
|
93
|
-
}, t2 = [locale, config2.apiKey], $[1] = config2.apiKey, $[2] = locale, $[3] = t1, $[4] = t2) : (t1 = $[3], t2 = $[4]), useEffect(t1, t2), state;
|
|
211
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(ErrorOutlineIcon, {}), $[0] = t0) : t0 = $[0];
|
|
212
|
+
let t1;
|
|
213
|
+
return $[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ jsxs(MessageCard, { tone: "critical", icon: t0, title: "Map preview couldn\u2019t load", children: [
|
|
214
|
+
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "The Google Maps API key was rejected. Check that it is a valid key \u2014 not a demo or placeholder key \u2014 that it is not restricted in a way that blocks this Studio\u2019s URL, and that it has these APIs enabled:" }),
|
|
215
|
+
/* @__PURE__ */ jsx(RequiredApis, {})
|
|
216
|
+
] }), $[1] = t1) : t1 = $[1], t1;
|
|
94
217
|
}
|
|
95
|
-
function
|
|
96
|
-
const $ = c(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
case "loading": {
|
|
104
|
-
let t0;
|
|
105
|
-
return $[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("div", { children: "Loading Google Maps API" }), $[3] = t0) : t0 = $[3], t0;
|
|
106
|
-
}
|
|
107
|
-
case "loaded": {
|
|
108
|
-
let t0;
|
|
109
|
-
return $[4] !== loadState.api || $[5] !== props.children ? (t0 = props.children(loadState.api), $[4] = loadState.api, $[5] = props.children, $[6] = t0) : t0 = $[6], t0;
|
|
110
|
-
}
|
|
111
|
-
default:
|
|
112
|
-
return null;
|
|
218
|
+
function MapApiGate(t0) {
|
|
219
|
+
const $ = c(4), {
|
|
220
|
+
children
|
|
221
|
+
} = t0, status = useApiLoadingStatus();
|
|
222
|
+
if (status === APILoadingStatus.AUTH_FAILURE || status === APILoadingStatus.FAILED) {
|
|
223
|
+
let t12;
|
|
224
|
+
return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t12 = /* @__PURE__ */ jsx(InvalidApiKeyCard, {}), $[0] = t12) : t12 = $[0], t12;
|
|
113
225
|
}
|
|
226
|
+
if (status !== APILoadingStatus.LOADED) {
|
|
227
|
+
let t12;
|
|
228
|
+
return $[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t12 = /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", height: "fill", padding: 4, children: /* @__PURE__ */ jsx(Spinner, { muted: !0 }) }), $[1] = t12) : t12 = $[1], t12;
|
|
229
|
+
}
|
|
230
|
+
let t1;
|
|
231
|
+
return $[2] !== children ? (t1 = /* @__PURE__ */ jsx(Fragment, { children }), $[2] = children, $[3] = t1) : t1 = $[3], t1;
|
|
114
232
|
}
|
|
115
|
-
|
|
116
|
-
|
|
233
|
+
function getValidLatLng(value) {
|
|
234
|
+
const lat = value?.lat, lng = value?.lng;
|
|
235
|
+
return typeof lat == "number" && Number.isFinite(lat) && typeof lng == "number" && Number.isFinite(lng) ? {
|
|
236
|
+
lat,
|
|
237
|
+
lng
|
|
238
|
+
} : null;
|
|
239
|
+
}
|
|
240
|
+
const StaticMapContainer = styled.div.withConfig({
|
|
241
|
+
displayName: "StaticMapContainer",
|
|
117
242
|
componentId: "sc-10h92ni-0"
|
|
118
|
-
})`width:100%;height:auto;vertical-align:top
|
|
243
|
+
})`cursor:pointer;& img{width:100%;height:auto;display:block;vertical-align:top;}`, DialogInnerContainer = styled.div.withConfig({
|
|
119
244
|
displayName: "DialogInnerContainer",
|
|
120
245
|
componentId: "sc-10h92ni-1"
|
|
121
|
-
})`height:40rem;`,
|
|
122
|
-
displayName: "
|
|
123
|
-
componentId: "sc-
|
|
124
|
-
})`
|
|
125
|
-
function
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
};
|
|
134
|
-
state = {
|
|
135
|
-
map: void 0
|
|
136
|
-
};
|
|
137
|
-
mapRef = createRef();
|
|
138
|
-
mapEl = null;
|
|
139
|
-
componentDidMount() {
|
|
140
|
-
this.attachClickHandler();
|
|
141
|
-
}
|
|
142
|
-
attachClickHandler = () => {
|
|
143
|
-
const map = this.state.map;
|
|
144
|
-
if (!map)
|
|
145
|
-
return;
|
|
146
|
-
const {
|
|
147
|
-
api,
|
|
148
|
-
onClick
|
|
149
|
-
} = this.props, {
|
|
150
|
-
event
|
|
151
|
-
} = api;
|
|
152
|
-
this.clickHandler && this.clickHandler.remove(), onClick && (this.clickHandler = event.addListener(map, "click", onClick));
|
|
153
|
-
};
|
|
154
|
-
componentDidUpdate(prevProps) {
|
|
155
|
-
const map = this.state.map;
|
|
156
|
-
if (!map)
|
|
157
|
-
return;
|
|
158
|
-
const {
|
|
159
|
-
onClick,
|
|
160
|
-
location,
|
|
161
|
-
bounds
|
|
162
|
-
} = 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 {
|
|
170
|
-
location,
|
|
171
|
-
api
|
|
172
|
-
} = this.props;
|
|
173
|
-
return new api.LatLng(location.lat, location.lng);
|
|
174
|
-
}
|
|
175
|
-
constructMap(el) {
|
|
246
|
+
})`height:40rem;`, MAP_ID = "DEMO_MAP_ID", SearchInputContainer = styled.div.withConfig({
|
|
247
|
+
displayName: "SearchInputContainer",
|
|
248
|
+
componentId: "sc-n3m9ut-0"
|
|
249
|
+
})`margin:10px;width:240px;& gmp-place-autocomplete{width:100%;}`;
|
|
250
|
+
function SearchInput(t0) {
|
|
251
|
+
const $ = c(3), {
|
|
252
|
+
onSelect
|
|
253
|
+
} = t0, places = useMapsLibrary("places"), map = useMap();
|
|
254
|
+
if (!places)
|
|
255
|
+
return null;
|
|
256
|
+
let t1;
|
|
257
|
+
return $[0] !== map || $[1] !== onSelect ? (t1 = /* @__PURE__ */ jsx(SearchInputContainer, { children: /* @__PURE__ */ jsx("gmp-place-autocomplete", { "ongmp-select": async (t2) => {
|
|
176
258
|
const {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
bounds,
|
|
182
|
-
scrollWheel
|
|
183
|
-
} = this.props, map = new api.Map(el, {
|
|
184
|
-
zoom: defaultZoom,
|
|
185
|
-
center: this.getCenter(),
|
|
186
|
-
scrollwheel: scrollWheel,
|
|
187
|
-
streetViewControl: !1,
|
|
188
|
-
mapTypeControl,
|
|
189
|
-
controlSize
|
|
259
|
+
placePrediction
|
|
260
|
+
} = t2, place = placePrediction.toPlace();
|
|
261
|
+
await place.fetchFields({
|
|
262
|
+
fields: ["location"]
|
|
190
263
|
});
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
setMapElement = (element) => {
|
|
194
|
-
if (element && element !== this.mapEl) {
|
|
195
|
-
const map = this.constructMap(element);
|
|
196
|
-
this.setState({
|
|
197
|
-
map
|
|
198
|
-
}, this.attachClickHandler);
|
|
199
|
-
}
|
|
200
|
-
this.mapEl = element;
|
|
201
|
-
};
|
|
202
|
-
render() {
|
|
203
|
-
const {
|
|
204
|
-
children
|
|
205
|
-
} = this.props, {
|
|
206
|
-
map
|
|
207
|
-
} = this.state;
|
|
208
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
209
|
-
/* @__PURE__ */ jsx(MapContainer, { ref: this.setMapElement }),
|
|
210
|
-
children && map ? children(map) : null
|
|
211
|
-
] });
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
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";
|
|
215
|
-
class Marker extends PureComponent {
|
|
216
|
-
eventHandlers = {};
|
|
217
|
-
componentDidMount() {
|
|
218
|
-
const {
|
|
219
|
-
position,
|
|
220
|
-
api,
|
|
221
|
-
map,
|
|
222
|
-
onMove,
|
|
223
|
-
zIndex,
|
|
224
|
-
opacity,
|
|
225
|
-
label,
|
|
226
|
-
markerRef,
|
|
227
|
-
color
|
|
228
|
-
} = this.props, {
|
|
229
|
-
Marker: GMarker
|
|
230
|
-
} = api;
|
|
231
|
-
let icon;
|
|
232
|
-
color && (icon = {
|
|
233
|
-
path: markerPath,
|
|
234
|
-
fillOpacity: 1,
|
|
235
|
-
fillColor: color.background,
|
|
236
|
-
strokeColor: color.border,
|
|
237
|
-
strokeWeight: 2,
|
|
238
|
-
anchor: new api.Point(10, 35),
|
|
239
|
-
labelOrigin: new api.Point(10, 11)
|
|
240
|
-
}), this.marker = new GMarker({
|
|
241
|
-
draggable: !!onMove,
|
|
242
|
-
position,
|
|
243
|
-
map,
|
|
244
|
-
zIndex,
|
|
245
|
-
opacity,
|
|
246
|
-
label,
|
|
247
|
-
icon
|
|
248
|
-
}), markerRef && (markerRef.current = this.marker), this.attachMoveHandler(), this.attachClickHandler();
|
|
249
|
-
}
|
|
250
|
-
componentDidUpdate(prevProps) {
|
|
251
|
-
if (!this.marker)
|
|
252
|
-
return;
|
|
253
|
-
const {
|
|
254
|
-
position,
|
|
255
|
-
onMove,
|
|
256
|
-
label,
|
|
257
|
-
zIndex,
|
|
258
|
-
opacity,
|
|
259
|
-
map
|
|
260
|
-
} = this.props;
|
|
261
|
-
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);
|
|
262
|
-
}
|
|
263
|
-
componentWillUnmount() {
|
|
264
|
-
this.eventHandlers.move && this.eventHandlers.move.remove(), this.marker && this.marker.setMap(null);
|
|
265
|
-
}
|
|
266
|
-
attachMoveHandler() {
|
|
267
|
-
const {
|
|
268
|
-
api,
|
|
269
|
-
onMove
|
|
270
|
-
} = this.props;
|
|
271
|
-
this.eventHandlers.move && this.eventHandlers.move.remove(), this.marker && onMove && (this.eventHandlers.move = api.event.addListener(this.marker, "dragend", onMove));
|
|
272
|
-
}
|
|
273
|
-
attachClickHandler() {
|
|
274
|
-
const {
|
|
275
|
-
api,
|
|
276
|
-
onClick
|
|
277
|
-
} = this.props;
|
|
278
|
-
this.eventHandlers.click && this.eventHandlers.click.remove(), this.marker && onClick && (this.eventHandlers.click = api.event.addListener(this.marker, "click", onClick));
|
|
279
|
-
}
|
|
280
|
-
render() {
|
|
281
|
-
return null;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
const WrapperContainer = styled.div.withConfig({
|
|
285
|
-
displayName: "WrapperContainer",
|
|
286
|
-
componentId: "sc-n3m9ut-0"
|
|
287
|
-
})`position:absolute;right:10px;top:10px;width:220px;`;
|
|
288
|
-
class SearchInput extends PureComponent {
|
|
289
|
-
searchInputRef = createRef();
|
|
290
|
-
handleChange = () => {
|
|
291
|
-
this.autoComplete && (this.props.onChange(this.autoComplete.getPlace()), this.searchInputRef.current && (this.searchInputRef.current.value = ""));
|
|
292
|
-
};
|
|
293
|
-
componentDidMount() {
|
|
294
|
-
const input = this.searchInputRef.current;
|
|
295
|
-
if (!input)
|
|
264
|
+
const location = place.location;
|
|
265
|
+
if (!location)
|
|
296
266
|
return;
|
|
297
|
-
const {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
event
|
|
304
|
-
} = api, searchBounds = new Circle({
|
|
305
|
-
center: map.getCenter(),
|
|
306
|
-
radius: 100
|
|
307
|
-
}).getBounds();
|
|
308
|
-
this.autoComplete = new places.Autocomplete(input, {
|
|
309
|
-
bounds: searchBounds,
|
|
310
|
-
types: []
|
|
311
|
-
// return all kinds of places
|
|
312
|
-
}), event.addListener(this.autoComplete, "place_changed", this.handleChange);
|
|
313
|
-
}
|
|
314
|
-
render() {
|
|
315
|
-
return /* @__PURE__ */ jsx(WrapperContainer, { children: /* @__PURE__ */ jsx(TextInput, { name: "place", ref: this.searchInputRef, placeholder: "Search for place or address", padding: 4 }) });
|
|
316
|
-
}
|
|
267
|
+
const latLng = {
|
|
268
|
+
lat: location.lat(),
|
|
269
|
+
lng: location.lng()
|
|
270
|
+
};
|
|
271
|
+
onSelect(latLng), map?.panTo(latLng);
|
|
272
|
+
} }) }), $[0] = map, $[1] = onSelect, $[2] = t1) : t1 = $[2], t1;
|
|
317
273
|
}
|
|
318
274
|
const fallbackLatLng$1 = {
|
|
319
275
|
lat: 40.7058254,
|
|
@@ -321,67 +277,81 @@ const fallbackLatLng$1 = {
|
|
|
321
277
|
}, defaultMapLocation$1 = {
|
|
322
278
|
lng: 10.74609,
|
|
323
279
|
lat: 59.91273
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
280
|
+
};
|
|
281
|
+
function GeopointSelect(t0) {
|
|
282
|
+
const $ = c(24), {
|
|
327
283
|
value,
|
|
328
284
|
onChange,
|
|
329
285
|
defaultLocation: t1,
|
|
330
286
|
defaultZoom: t2
|
|
331
287
|
} = t0, defaultLocation = t1 === void 0 ? defaultMapLocation$1 : t1, defaultZoom = t2 === void 0 ? 8 : t2;
|
|
332
288
|
let t3;
|
|
333
|
-
$[0] !==
|
|
289
|
+
$[0] !== value ? (t3 = getValidLatLng(value), $[0] = value, $[1] = t3) : t3 = $[1];
|
|
290
|
+
const position = t3;
|
|
291
|
+
let t4;
|
|
292
|
+
$[2] !== defaultLocation || $[3] !== position ? (t4 = {
|
|
334
293
|
...fallbackLatLng$1,
|
|
335
294
|
...defaultLocation,
|
|
336
|
-
...
|
|
337
|
-
}
|
|
338
|
-
const
|
|
339
|
-
let t4;
|
|
340
|
-
$[3] !== onChange ? (t4 = (geoPoint) => {
|
|
341
|
-
onChange && onChange(geoPoint);
|
|
342
|
-
}, $[3] = onChange, $[4] = t4) : t4 = $[4];
|
|
343
|
-
const setValue = t4;
|
|
295
|
+
...position
|
|
296
|
+
}, $[2] = defaultLocation, $[3] = position, $[4] = t4) : t4 = $[4];
|
|
297
|
+
const center = t4;
|
|
344
298
|
let t5;
|
|
345
|
-
$[5] !==
|
|
346
|
-
|
|
347
|
-
}, $[5] =
|
|
348
|
-
const
|
|
299
|
+
$[5] !== onChange ? (t5 = (event) => {
|
|
300
|
+
event.detail.latLng && onChange && onChange(event.detail.latLng);
|
|
301
|
+
}, $[5] = onChange, $[6] = t5) : t5 = $[6];
|
|
302
|
+
const handleMapClick = t5;
|
|
349
303
|
let t6;
|
|
350
|
-
$[7] !==
|
|
351
|
-
|
|
352
|
-
|
|
304
|
+
$[7] !== onChange ? (t6 = (event_0) => {
|
|
305
|
+
event_0.latLng && onChange && onChange({
|
|
306
|
+
lat: event_0.latLng.lat(),
|
|
307
|
+
lng: event_0.latLng.lng()
|
|
308
|
+
});
|
|
309
|
+
}, $[7] = onChange, $[8] = t6) : t6 = $[8];
|
|
353
310
|
const handleMarkerDragEnd = t6;
|
|
354
311
|
let t7;
|
|
355
|
-
$[9] !==
|
|
356
|
-
|
|
357
|
-
}, $[9] =
|
|
358
|
-
const
|
|
312
|
+
$[9] !== onChange ? (t7 = (location) => {
|
|
313
|
+
onChange?.(location);
|
|
314
|
+
}, $[9] = onChange, $[10] = t7) : t7 = $[10];
|
|
315
|
+
const handleSelect = t7;
|
|
359
316
|
let t8;
|
|
360
|
-
$[11]
|
|
317
|
+
$[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t8 = {
|
|
318
|
+
width: "100%",
|
|
319
|
+
height: "100%"
|
|
320
|
+
}, $[11] = t8) : t8 = $[11];
|
|
361
321
|
let t9;
|
|
362
|
-
$[
|
|
363
|
-
/* @__PURE__ */ jsx(SearchInput, { api, map, onChange: handlePlaceChanged }),
|
|
364
|
-
value && /* @__PURE__ */ jsx(Marker, { api, map, position: value, onMove: onChange ? handleMarkerDragEnd : void 0 })
|
|
365
|
-
] }), $[13] = api, $[14] = handleMarkerDragEnd, $[15] = handlePlaceChanged, $[16] = onChange, $[17] = value, $[18] = t9) : t9 = $[18];
|
|
322
|
+
$[12] !== handleSelect ? (t9 = /* @__PURE__ */ jsx(MapControl, { position: ControlPosition.TOP_RIGHT, children: /* @__PURE__ */ jsx(SearchInput, { onSelect: handleSelect }) }), $[12] = handleSelect, $[13] = t9) : t9 = $[13];
|
|
366
323
|
let t10;
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
324
|
+
$[14] !== handleMarkerDragEnd || $[15] !== onChange || $[16] !== position ? (t10 = position && /* @__PURE__ */ jsx(AdvancedMarker, { position, draggable: !!onChange, onDragEnd: handleMarkerDragEnd }), $[14] = handleMarkerDragEnd, $[15] = onChange, $[16] = position, $[17] = t10) : t10 = $[17];
|
|
325
|
+
let t11;
|
|
326
|
+
return $[18] !== center || $[19] !== defaultZoom || $[20] !== handleMapClick || $[21] !== t10 || $[22] !== t9 ? (t11 = /* @__PURE__ */ jsxs(Map, { mapId: MAP_ID, defaultCenter: center, defaultZoom, onClick: handleMapClick, gestureHandling: "greedy", streetViewControl: !1, mapTypeControl: !1, style: t8, children: [
|
|
327
|
+
t9,
|
|
328
|
+
t10
|
|
329
|
+
] }), $[18] = center, $[19] = defaultZoom, $[20] = handleMapClick, $[21] = t10, $[22] = t9, $[23] = t11) : t11 = $[23], t11;
|
|
330
|
+
}
|
|
331
|
+
function StaticMapPreview(t0) {
|
|
332
|
+
const $ = c(8), {
|
|
333
|
+
url,
|
|
334
|
+
onClick,
|
|
335
|
+
onDoubleClick
|
|
336
|
+
} = t0, [failed, setFailed] = useState(!1);
|
|
337
|
+
if (failed) {
|
|
338
|
+
let t12;
|
|
339
|
+
return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t12 = /* @__PURE__ */ jsx(InvalidApiKeyCard, {}), $[0] = t12) : t12 = $[0], t12;
|
|
340
|
+
}
|
|
341
|
+
let t1;
|
|
342
|
+
$[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = () => setFailed(!0), $[1] = t1) : t1 = $[1];
|
|
343
|
+
let t2;
|
|
344
|
+
$[2] !== url ? (t2 = /* @__PURE__ */ jsx(StaticMap, { url }), $[2] = url, $[3] = t2) : t2 = $[3];
|
|
345
|
+
let t3;
|
|
346
|
+
return $[4] !== onClick || $[5] !== onDoubleClick || $[6] !== t2 ? (t3 = /* @__PURE__ */ jsx(StaticMapContainer, { onClick, onDoubleClick, onErrorCapture: t1, children: t2 }), $[4] = onClick, $[5] = onDoubleClick, $[6] = t2, $[7] = t3) : t3 = $[7], t3;
|
|
347
|
+
}
|
|
348
|
+
const EMPTY_PATH$1 = [];
|
|
379
349
|
function GeopointInput(props) {
|
|
380
|
-
const $ = c(
|
|
350
|
+
const $ = c(54), {
|
|
381
351
|
changed,
|
|
382
352
|
elementProps,
|
|
383
353
|
focused,
|
|
384
|
-
geoConfig:
|
|
354
|
+
geoConfig: config,
|
|
385
355
|
onChange,
|
|
386
356
|
onPathFocus,
|
|
387
357
|
path,
|
|
@@ -410,7 +380,7 @@ function GeopointInput(props) {
|
|
|
410
380
|
$[5] !== onChange || $[6] !== schemaTypeName ? (t3 = (latLng) => {
|
|
411
381
|
onChange([setIfMissing({
|
|
412
382
|
_type: schemaTypeName
|
|
413
|
-
}), set(latLng.lat
|
|
383
|
+
}), set(latLng.lat, ["lat"]), set(latLng.lng, ["lng"])]);
|
|
414
384
|
}, $[5] = onChange, $[6] = schemaTypeName, $[7] = t3) : t3 = $[7];
|
|
415
385
|
const handleChange = t3;
|
|
416
386
|
let t4;
|
|
@@ -421,42 +391,33 @@ function GeopointInput(props) {
|
|
|
421
391
|
let t5, t6;
|
|
422
392
|
if ($[10] !== modalOpen || $[11] !== onPathFocus ? (t5 = () => {
|
|
423
393
|
modalOpen && onPathFocus(EMPTY_PATH$1);
|
|
424
|
-
}, t6 = [modalOpen, onPathFocus], $[10] = modalOpen, $[11] = onPathFocus, $[12] = t5, $[13] = t6) : (t5 = $[12], t6 = $[13]), useEffect(t5, t6), !
|
|
394
|
+
}, t6 = [modalOpen, onPathFocus], $[10] = modalOpen, $[11] = onPathFocus, $[12] = t5, $[13] = t6) : (t5 = $[12], t6 = $[13]), useEffect(t5, t6), !config || !config.apiKey) {
|
|
425
395
|
let t72;
|
|
426
|
-
return $[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t72 = /* @__PURE__ */
|
|
427
|
-
/* @__PURE__ */ jsxs("p", { children: [
|
|
428
|
-
"The ",
|
|
429
|
-
/* @__PURE__ */ jsx("a", { href: "https://sanity.io/docs/schema-types/geopoint-type", children: "Geopoint type" }),
|
|
430
|
-
" needs a Google Maps API key with access to:"
|
|
431
|
-
] }),
|
|
432
|
-
/* @__PURE__ */ jsxs("ul", { children: [
|
|
433
|
-
/* @__PURE__ */ jsx("li", { children: "Google Maps JavaScript API" }),
|
|
434
|
-
/* @__PURE__ */ jsx("li", { children: "Google Places API Web Service" }),
|
|
435
|
-
/* @__PURE__ */ jsx("li", { children: "Google Static Maps API" })
|
|
436
|
-
] }),
|
|
437
|
-
/* @__PURE__ */ jsx("p", { children: "Please enter the API key with access to these services in your googleMapsInput plugin config." })
|
|
438
|
-
] }), $[14] = t72) : t72 = $[14], t72;
|
|
396
|
+
return $[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t72 = /* @__PURE__ */ jsx(MissingApiKeyCard, { typeTitle: "Geopoint" }), $[14] = t72) : t72 = $[14], t72;
|
|
439
397
|
}
|
|
440
|
-
let t7;
|
|
441
|
-
$[15] !==
|
|
442
|
-
const
|
|
443
|
-
let
|
|
444
|
-
$[
|
|
398
|
+
let position, t7;
|
|
399
|
+
$[15] !== config || $[16] !== value ? (position = getValidLatLng(value), t7 = position ? getGeopointStaticMapUrl(position, config.apiKey) : null, $[15] = config, $[16] = value, $[17] = position, $[18] = t7) : (position = $[17], t7 = $[18]);
|
|
400
|
+
const staticImageUrl = t7;
|
|
401
|
+
let t8;
|
|
402
|
+
$[19] !== changed || $[20] !== focused || $[21] !== handleFocusButton || $[22] !== path || $[23] !== staticImageUrl ? (t8 = staticImageUrl && /* @__PURE__ */ jsx(ChangeIndicator, { path, isChanged: changed, hasFocus: !!focused, children: /* @__PURE__ */ jsx(StaticMapPreview, { url: staticImageUrl, onClick: handleFocusButton, onDoubleClick: handleToggleModal }) }), $[19] = changed, $[20] = focused, $[21] = handleFocusButton, $[22] = path, $[23] = staticImageUrl, $[24] = t8) : t8 = $[24];
|
|
403
|
+
const t9 = position ? 2 : 1, t10 = position ? EditIcon : void 0, t11 = position ? "Edit" : "Set location";
|
|
445
404
|
let t12;
|
|
446
|
-
$[
|
|
405
|
+
$[25] !== ariaDescribedBy || $[26] !== handleFocus || $[27] !== id || $[28] !== inputRef || $[29] !== readOnly || $[30] !== t10 || $[31] !== t11 ? (t12 = /* @__PURE__ */ jsx(Button, { "aria-describedby": ariaDescribedBy, disabled: readOnly, icon: t10, id, mode: "ghost", onClick: handleToggleModal, onFocus: handleFocus, padding: 3, ref: inputRef, text: t11 }), $[25] = ariaDescribedBy, $[26] = handleFocus, $[27] = id, $[28] = inputRef, $[29] = readOnly, $[30] = t10, $[31] = t11, $[32] = t12) : t12 = $[32];
|
|
447
406
|
let t13;
|
|
448
|
-
$[
|
|
449
|
-
t11,
|
|
450
|
-
t12
|
|
451
|
-
] }) }), $[34] = t11, $[35] = t12, $[36] = t8, $[37] = t13) : t13 = $[37];
|
|
407
|
+
$[33] !== handleClear || $[34] !== position || $[35] !== readOnly ? (t13 = position && /* @__PURE__ */ jsx(Button, { disabled: readOnly, icon: TrashIcon, mode: "ghost", onClick: handleClear, padding: 3, text: "Remove", tone: "critical" }), $[33] = handleClear, $[34] = position, $[35] = readOnly, $[36] = t13) : t13 = $[36];
|
|
452
408
|
let t14;
|
|
453
|
-
$[
|
|
409
|
+
$[37] !== t12 || $[38] !== t13 || $[39] !== t9 ? (t14 = /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Grid, { gridTemplateColumns: t9, gap: 3, children: [
|
|
410
|
+
t12,
|
|
411
|
+
t13
|
|
412
|
+
] }) }), $[37] = t12, $[38] = t13, $[39] = t9, $[40] = t14) : t14 = $[40];
|
|
454
413
|
let t15;
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
414
|
+
$[41] !== config || $[42] !== dialogId || $[43] !== handleBlur || $[44] !== handleChange || $[45] !== handleCloseModal || $[46] !== modalOpen || $[47] !== readOnly || $[48] !== value ? (t15 = modalOpen && /* @__PURE__ */ jsx(Dialog, { header: "Place the marker on the map", id: `${dialogId}_dialog`, onBlur: handleBlur, onClose: handleCloseModal, ref: dialogRef, width: 1, children: /* @__PURE__ */ jsx(DialogInnerContainer, { children: /* @__PURE__ */ jsx(APIProvider, { apiKey: config.apiKey, children: /* @__PURE__ */ jsx(MapApiGate, { children: /* @__PURE__ */ jsx(GeopointSelect, { value: value || void 0, onChange: readOnly ? void 0 : handleChange, defaultLocation: config.defaultLocation, defaultZoom: config.defaultZoom }) }) }) }) }), $[41] = config, $[42] = dialogId, $[43] = handleBlur, $[44] = handleChange, $[45] = handleCloseModal, $[46] = modalOpen, $[47] = readOnly, $[48] = value, $[49] = t15) : t15 = $[49];
|
|
415
|
+
let t16;
|
|
416
|
+
return $[50] !== t14 || $[51] !== t15 || $[52] !== t8 ? (t16 = /* @__PURE__ */ jsxs(Stack, { gap: 3, children: [
|
|
417
|
+
t8,
|
|
418
|
+
t14,
|
|
419
|
+
t15
|
|
420
|
+
] }), $[50] = t14, $[51] = t15, $[52] = t8, $[53] = t16) : t16 = $[53], t16;
|
|
460
421
|
}
|
|
461
422
|
function _temp$1(currentState) {
|
|
462
423
|
return !currentState;
|
|
@@ -467,147 +428,87 @@ const fallbackLatLng = {
|
|
|
467
428
|
}, defaultMapLocation = {
|
|
468
429
|
lng: 10.74609,
|
|
469
430
|
lat: 59.91273
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
marker,
|
|
474
|
-
circleRef,
|
|
475
|
-
isMarkerDragging
|
|
476
|
-
} = t0;
|
|
477
|
-
let t1;
|
|
478
|
-
$[0] !== api.event || $[1] !== isMarkerDragging || $[2] !== marker ? (t1 = () => {
|
|
479
|
-
const handleDrag = () => {
|
|
480
|
-
isMarkerDragging.current = !0;
|
|
481
|
-
}, handleDragEnd = () => {
|
|
482
|
-
isMarkerDragging.current = !1;
|
|
483
|
-
}, dragListener = api.event.addListener(marker, "drag", handleDrag), dragEndListener = api.event.addListener(marker, "dragend", handleDragEnd);
|
|
484
|
-
return () => {
|
|
485
|
-
api.event.removeListener(dragListener), api.event.removeListener(dragEndListener);
|
|
486
|
-
};
|
|
487
|
-
}, $[0] = api.event, $[1] = isMarkerDragging, $[2] = marker, $[3] = t1) : t1 = $[3];
|
|
488
|
-
let t2;
|
|
489
|
-
return $[4] !== api || $[5] !== circleRef || $[6] !== isMarkerDragging || $[7] !== marker ? (t2 = [api, marker, circleRef, isMarkerDragging], $[4] = api, $[5] = circleRef, $[6] = isMarkerDragging, $[7] = marker, $[8] = t2) : t2 = $[8], useEffect(t1, t2), null;
|
|
490
|
-
}, GeopointRadiusSelect = (t0) => {
|
|
491
|
-
const $ = c(35), {
|
|
492
|
-
api,
|
|
431
|
+
};
|
|
432
|
+
function GeopointRadiusSelect(t0) {
|
|
433
|
+
const $ = c(38), {
|
|
493
434
|
value,
|
|
494
435
|
onChange,
|
|
495
436
|
defaultLocation: t1,
|
|
496
437
|
defaultRadiusZoom: t2,
|
|
497
438
|
defaultRadius: t3
|
|
498
|
-
} = t0, defaultLocation = t1 === void 0 ? defaultMapLocation : t1, defaultRadiusZoom = t2 === void 0 ? 12 : t2, defaultRadius = t3 === void 0 ? 1e3 : t3
|
|
439
|
+
} = t0, defaultLocation = t1 === void 0 ? defaultMapLocation : t1, defaultRadiusZoom = t2 === void 0 ? 12 : t2, defaultRadius = t3 === void 0 ? 1e3 : t3;
|
|
499
440
|
let t4;
|
|
500
|
-
$[0] !==
|
|
441
|
+
$[0] !== value ? (t4 = getValidLatLng(value), $[0] = value, $[1] = t4) : t4 = $[1];
|
|
442
|
+
const position = t4;
|
|
443
|
+
let t5;
|
|
444
|
+
$[2] !== defaultLocation || $[3] !== position ? (t5 = {
|
|
501
445
|
...fallbackLatLng,
|
|
502
446
|
...defaultLocation,
|
|
503
|
-
...
|
|
504
|
-
}
|
|
505
|
-
const
|
|
506
|
-
let t5;
|
|
507
|
-
$[3] !== onChange ? (t5 = (geoPoint, radius) => {
|
|
508
|
-
if (onChange) {
|
|
509
|
-
const roundedRadius = radius ? Math.round(radius) : void 0;
|
|
510
|
-
onChange(geoPoint, roundedRadius);
|
|
511
|
-
}
|
|
512
|
-
}, $[3] = onChange, $[4] = t5) : t5 = $[4];
|
|
513
|
-
const setValue = t5;
|
|
447
|
+
...position
|
|
448
|
+
}, $[2] = defaultLocation, $[3] = position, $[4] = t5) : t5 = $[4];
|
|
449
|
+
const center = t5, currentRadius = value?.radius ?? defaultRadius;
|
|
514
450
|
let t6;
|
|
515
|
-
$[5] !==
|
|
516
|
-
|
|
517
|
-
}, $[5] =
|
|
518
|
-
const
|
|
451
|
+
$[5] !== onChange ? (t6 = (latLng, radius) => {
|
|
452
|
+
onChange?.(latLng, radius == null ? void 0 : Math.round(radius));
|
|
453
|
+
}, $[5] = onChange, $[6] = t6) : t6 = $[6];
|
|
454
|
+
const setValue = t6;
|
|
519
455
|
let t7;
|
|
520
|
-
$[
|
|
521
|
-
event.latLng &&
|
|
522
|
-
}, $[
|
|
523
|
-
const
|
|
456
|
+
$[7] !== currentRadius || $[8] !== setValue ? (t7 = (event) => {
|
|
457
|
+
event.detail.latLng && setValue(event.detail.latLng, currentRadius);
|
|
458
|
+
}, $[7] = currentRadius, $[8] = setValue, $[9] = t7) : t7 = $[9];
|
|
459
|
+
const handleMapClick = t7;
|
|
524
460
|
let t8;
|
|
525
|
-
$[
|
|
526
|
-
event_0.latLng && setValue(
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
$[
|
|
531
|
-
|
|
461
|
+
$[10] !== currentRadius || $[11] !== setValue ? (t8 = (event_0) => {
|
|
462
|
+
event_0.latLng && setValue({
|
|
463
|
+
lat: event_0.latLng.lat(),
|
|
464
|
+
lng: event_0.latLng.lng()
|
|
465
|
+
}, currentRadius);
|
|
466
|
+
}, $[10] = currentRadius, $[11] = setValue, $[12] = t8) : t8 = $[12];
|
|
467
|
+
const handleMarkerDragEnd = t8;
|
|
468
|
+
let t9;
|
|
469
|
+
$[13] !== currentRadius || $[14] !== setValue ? (t9 = (location) => setValue(location, currentRadius), $[13] = currentRadius, $[14] = setValue, $[15] = t9) : t9 = $[15];
|
|
470
|
+
const handleSelect = t9;
|
|
471
|
+
let t10;
|
|
472
|
+
$[16] !== setValue || $[17] !== value ? (t10 = (radius_0) => {
|
|
473
|
+
value && setValue({
|
|
532
474
|
lat: value.lat,
|
|
533
475
|
lng: value.lng
|
|
534
|
-
}
|
|
535
|
-
},
|
|
476
|
+
}, radius_0);
|
|
477
|
+
}, $[16] = setValue, $[17] = value, $[18] = t10) : t10 = $[18];
|
|
478
|
+
const handleCircleRadiusChanged = t10;
|
|
536
479
|
let t11;
|
|
537
|
-
$[
|
|
480
|
+
$[19] !== currentRadius || $[20] !== setValue ? (t11 = (event_1) => {
|
|
481
|
+
event_1.latLng && setValue({
|
|
482
|
+
lat: event_1.latLng.lat(),
|
|
483
|
+
lng: event_1.latLng.lng()
|
|
484
|
+
}, currentRadius);
|
|
485
|
+
}, $[19] = currentRadius, $[20] = setValue, $[21] = t11) : t11 = $[21];
|
|
486
|
+
const handleCircleDragEnd = t11;
|
|
538
487
|
let t12;
|
|
539
|
-
$[22]
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
lng: value.lng
|
|
544
|
-
},
|
|
545
|
-
radius: value.radius,
|
|
546
|
-
fillColor: "#4285F4",
|
|
547
|
-
fillOpacity: 0.2,
|
|
548
|
-
strokeColor: "#4285F4",
|
|
549
|
-
strokeOpacity: 0.8,
|
|
550
|
-
strokeWeight: 2,
|
|
551
|
-
editable: !0
|
|
552
|
-
}), circleRef.current.addListener("center_changed", () => {
|
|
553
|
-
if (circleRef.current && markerRef.current && !isMarkerDragging.current) {
|
|
554
|
-
const circleCenter = circleRef.current.getCenter();
|
|
555
|
-
circleCenter && markerRef.current.setPosition(circleCenter);
|
|
556
|
-
}
|
|
557
|
-
}), circleRef.current.addListener("radius_changed", () => {
|
|
558
|
-
if (circleRef.current) {
|
|
559
|
-
const center = circleRef.current.getCenter(), radius_0 = circleRef.current.getRadius();
|
|
560
|
-
center && setValue(center, Math.round(radius_0));
|
|
561
|
-
}
|
|
562
|
-
}), circleRef.current.addListener("dragend", () => {
|
|
563
|
-
if (circleRef.current) {
|
|
564
|
-
const center_0 = circleRef.current.getCenter(), radius_1 = circleRef.current.getRadius();
|
|
565
|
-
center_0 && setValue(center_0, Math.round(radius_1));
|
|
566
|
-
}
|
|
567
|
-
})), /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
568
|
-
/* @__PURE__ */ jsx(SearchInput, { api, map, onChange: handlePlaceChanged }),
|
|
569
|
-
value && /* @__PURE__ */ jsx(Marker, { api, map, position: value, onMove: onChange ? handleMarkerDragEnd : void 0, markerRef }),
|
|
570
|
-
value && markerRef.current && /* @__PURE__ */ jsx(MarkerDragSync, { api, marker: markerRef.current, circleRef, isMarkerDragging })
|
|
571
|
-
] })), $[22] = api, $[23] = handleMarkerDragEnd, $[24] = handlePlaceChanged, $[25] = onChange, $[26] = setValue, $[27] = value, $[28] = t12) : t12 = $[28];
|
|
488
|
+
$[22] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t12 = {
|
|
489
|
+
width: "100%",
|
|
490
|
+
height: "100%"
|
|
491
|
+
}, $[22] = t12) : t12 = $[22];
|
|
572
492
|
let t13;
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
let zoom = 13;
|
|
587
|
-
if (value.radius) {
|
|
588
|
-
const scale = (value.radius + value.radius / 2) / 500, calculatedZoom = 16 - Math.log(scale) / Math.log(2);
|
|
589
|
-
zoom = Math.max(8, Math.min(16, Math.round(calculatedZoom - 0.4)));
|
|
590
|
-
}
|
|
591
|
-
const qs = new URLSearchParams({
|
|
592
|
-
key: apiKey,
|
|
593
|
-
center: loc,
|
|
594
|
-
markers: loc,
|
|
595
|
-
zoom: zoom.toString(),
|
|
596
|
-
scale: "2",
|
|
597
|
-
size: "640x300"
|
|
598
|
-
});
|
|
599
|
-
if (value.radius) {
|
|
600
|
-
const path = generateCirclePoints(value.lat, value.lng, value.radius).map((p) => `${p.lat},${p.lng}`).join("|");
|
|
601
|
-
qs.append("path", `fillcolor:0x4285F480|color:0x4285F4|weight:2|${path}`);
|
|
602
|
-
}
|
|
603
|
-
return `https://maps.googleapis.com/maps/api/staticmap?${qs.toString()}`;
|
|
604
|
-
};
|
|
493
|
+
$[23] !== handleSelect ? (t13 = /* @__PURE__ */ jsx(MapControl, { position: ControlPosition.TOP_RIGHT, children: /* @__PURE__ */ jsx(SearchInput, { onSelect: handleSelect }) }), $[23] = handleSelect, $[24] = t13) : t13 = $[24];
|
|
494
|
+
let t14;
|
|
495
|
+
$[25] !== currentRadius || $[26] !== handleCircleDragEnd || $[27] !== handleCircleRadiusChanged || $[28] !== handleMarkerDragEnd || $[29] !== onChange || $[30] !== position ? (t14 = position && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
496
|
+
/* @__PURE__ */ jsx(AdvancedMarker, { position, draggable: !!onChange, onDragEnd: handleMarkerDragEnd }),
|
|
497
|
+
/* @__PURE__ */ jsx(Circle, { center: position, radius: currentRadius, editable: !!onChange, draggable: !!onChange, fillColor: "#4285F4", fillOpacity: 0.2, strokeColor: "#4285F4", strokeOpacity: 0.8, strokeWeight: 2, onRadiusChanged: handleCircleRadiusChanged, onDragEnd: handleCircleDragEnd })
|
|
498
|
+
] }), $[25] = currentRadius, $[26] = handleCircleDragEnd, $[27] = handleCircleRadiusChanged, $[28] = handleMarkerDragEnd, $[29] = onChange, $[30] = position, $[31] = t14) : t14 = $[31];
|
|
499
|
+
let t15;
|
|
500
|
+
return $[32] !== center || $[33] !== defaultRadiusZoom || $[34] !== handleMapClick || $[35] !== t13 || $[36] !== t14 ? (t15 = /* @__PURE__ */ jsxs(Map, { mapId: MAP_ID, defaultCenter: center, defaultZoom: defaultRadiusZoom, onClick: handleMapClick, gestureHandling: "greedy", streetViewControl: !1, mapTypeControl: !1, style: t12, children: [
|
|
501
|
+
t13,
|
|
502
|
+
t14
|
|
503
|
+
] }), $[32] = center, $[33] = defaultRadiusZoom, $[34] = handleMapClick, $[35] = t13, $[36] = t14, $[37] = t15) : t15 = $[37], t15;
|
|
504
|
+
}
|
|
505
|
+
const EMPTY_PATH = [];
|
|
605
506
|
function GeopointRadiusInput(props) {
|
|
606
|
-
const $ = c(
|
|
507
|
+
const $ = c(73), {
|
|
607
508
|
changed,
|
|
608
509
|
elementProps,
|
|
609
510
|
focused,
|
|
610
|
-
geoConfig:
|
|
511
|
+
geoConfig: config,
|
|
611
512
|
onChange,
|
|
612
513
|
onPathFocus,
|
|
613
514
|
path,
|
|
@@ -633,12 +534,12 @@ function GeopointRadiusInput(props) {
|
|
|
633
534
|
$[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = () => setModalOpen(_temp), $[4] = t2) : t2 = $[4];
|
|
634
535
|
const handleToggleModal = t2;
|
|
635
536
|
let t3;
|
|
636
|
-
$[5] !==
|
|
637
|
-
const currentRadius = radius ?? value?.radius ??
|
|
537
|
+
$[5] !== config.defaultRadius || $[6] !== onChange || $[7] !== schemaTypeName || $[8] !== value?.radius ? (t3 = (latLng, radius) => {
|
|
538
|
+
const currentRadius = radius ?? value?.radius ?? config.defaultRadius ?? 1e3;
|
|
638
539
|
onChange([setIfMissing({
|
|
639
540
|
_type: schemaTypeName
|
|
640
|
-
}), set(latLng.lat
|
|
641
|
-
}, $[5] =
|
|
541
|
+
}), set(latLng.lat, ["lat"]), set(latLng.lng, ["lng"]), set(currentRadius, ["radius"])]);
|
|
542
|
+
}, $[5] = config.defaultRadius, $[6] = onChange, $[7] = schemaTypeName, $[8] = value?.radius, $[9] = t3) : t3 = $[9];
|
|
642
543
|
const handleChange = t3;
|
|
643
544
|
let t4;
|
|
644
545
|
$[10] !== onChange || $[11] !== value ? (t4 = (event) => {
|
|
@@ -653,389 +554,73 @@ function GeopointRadiusInput(props) {
|
|
|
653
554
|
let t6, t7;
|
|
654
555
|
if ($[15] !== modalOpen || $[16] !== onPathFocus ? (t6 = () => {
|
|
655
556
|
modalOpen && onPathFocus(EMPTY_PATH);
|
|
656
|
-
}, t7 = [modalOpen, onPathFocus], $[15] = modalOpen, $[16] = onPathFocus, $[17] = t6, $[18] = t7) : (t6 = $[17], t7 = $[18]), useEffect(t6, t7), !
|
|
557
|
+
}, t7 = [modalOpen, onPathFocus], $[15] = modalOpen, $[16] = onPathFocus, $[17] = t6, $[18] = t7) : (t6 = $[17], t7 = $[18]), useEffect(t6, t7), !config || !config.apiKey) {
|
|
657
558
|
let t82;
|
|
658
|
-
return $[19] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t82 = /* @__PURE__ */
|
|
659
|
-
/* @__PURE__ */ jsxs("p", { children: [
|
|
660
|
-
"The ",
|
|
661
|
-
/* @__PURE__ */ jsx("a", { href: "https://sanity.io/docs/schema-types/geopoint-type", children: "Geopoint Radius type" }),
|
|
662
|
-
" ",
|
|
663
|
-
"needs a Google Maps API key with access to:"
|
|
664
|
-
] }),
|
|
665
|
-
/* @__PURE__ */ jsxs("ul", { children: [
|
|
666
|
-
/* @__PURE__ */ jsx("li", { children: "Google Maps JavaScript API" }),
|
|
667
|
-
/* @__PURE__ */ jsx("li", { children: "Google Places API Web Service" }),
|
|
668
|
-
/* @__PURE__ */ jsx("li", { children: "Google Static Maps API" })
|
|
669
|
-
] }),
|
|
670
|
-
/* @__PURE__ */ jsx("p", { children: "Please enter the API key with access to these services in your googleMapsInput plugin config." })
|
|
671
|
-
] }), $[19] = t82) : t82 = $[19], t82;
|
|
559
|
+
return $[19] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t82 = /* @__PURE__ */ jsx(MissingApiKeyCard, { typeTitle: "Geopoint Radius" }), $[19] = t82) : t82 = $[19], t82;
|
|
672
560
|
}
|
|
673
|
-
let t8;
|
|
674
|
-
$[20] !==
|
|
561
|
+
let position, radius_0, t8;
|
|
562
|
+
if ($[20] !== config.apiKey || $[21] !== config.defaultRadius || $[22] !== value) {
|
|
563
|
+
position = getValidLatLng(value);
|
|
564
|
+
let t92;
|
|
565
|
+
$[26] !== config.defaultRadius || $[27] !== value?.radius ? (t92 = Math.round(value?.radius || config.defaultRadius || 1e3), $[26] = config.defaultRadius, $[27] = value?.radius, $[28] = t92) : t92 = $[28], radius_0 = t92, t8 = position ? getGeopointRadiusStaticMapUrl({
|
|
566
|
+
lat: position.lat,
|
|
567
|
+
lng: position.lng,
|
|
568
|
+
radius: value?.radius ?? 0
|
|
569
|
+
}, config.apiKey) : null, $[20] = config.apiKey, $[21] = config.defaultRadius, $[22] = value, $[23] = position, $[24] = radius_0, $[25] = t8;
|
|
570
|
+
} else
|
|
571
|
+
position = $[23], radius_0 = $[24], t8 = $[25];
|
|
572
|
+
const staticImageUrl = t8;
|
|
675
573
|
let t9;
|
|
676
|
-
$[
|
|
574
|
+
$[29] !== changed || $[30] !== focused || $[31] !== handleFocusButton || $[32] !== path || $[33] !== staticImageUrl ? (t9 = staticImageUrl && /* @__PURE__ */ jsx(ChangeIndicator, { path, isChanged: changed, hasFocus: !!focused, children: /* @__PURE__ */ jsx(StaticMapPreview, { url: staticImageUrl, onClick: handleFocusButton, onDoubleClick: handleToggleModal }) }), $[29] = changed, $[30] = focused, $[31] = handleFocusButton, $[32] = path, $[33] = staticImageUrl, $[34] = t9) : t9 = $[34];
|
|
575
|
+
let t10;
|
|
576
|
+
$[35] !== handleRadiusChange || $[36] !== position || $[37] !== radius_0 || $[38] !== readOnly ? (t10 = position && /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
|
|
677
577
|
/* @__PURE__ */ jsx(Label, { children: "Radius (meters)" }),
|
|
678
|
-
/* @__PURE__ */ jsx(TextInput, { type: "number", value:
|
|
679
|
-
] }), $[
|
|
680
|
-
const
|
|
681
|
-
let t13;
|
|
682
|
-
$[32] !== ariaDescribedBy || $[33] !== handleFocus || $[34] !== id || $[35] !== inputRef || $[36] !== readOnly || $[37] !== t11 || $[38] !== t12 ? (t13 = /* @__PURE__ */ jsx(Button, { "aria-describedby": ariaDescribedBy, disabled: readOnly, icon: t11, id, mode: "ghost", onClick: handleToggleModal, onFocus: handleFocus, padding: 3, ref: inputRef, text: t12 }), $[32] = ariaDescribedBy, $[33] = handleFocus, $[34] = id, $[35] = inputRef, $[36] = readOnly, $[37] = t11, $[38] = t12, $[39] = t13) : t13 = $[39];
|
|
578
|
+
/* @__PURE__ */ jsx(TextInput, { type: "number", value: radius_0, onChange: handleRadiusChange, disabled: readOnly, min: 1, max: 5e4, step: 1 })
|
|
579
|
+
] }), $[35] = handleRadiusChange, $[36] = position, $[37] = radius_0, $[38] = readOnly, $[39] = t10) : t10 = $[39];
|
|
580
|
+
const t11 = position ? 2 : 1, t12 = position ? EditIcon : void 0, t13 = position ? "Edit" : "Set location and radius";
|
|
683
581
|
let t14;
|
|
684
|
-
$[40] !==
|
|
582
|
+
$[40] !== ariaDescribedBy || $[41] !== handleFocus || $[42] !== id || $[43] !== inputRef || $[44] !== readOnly || $[45] !== t12 || $[46] !== t13 ? (t14 = /* @__PURE__ */ jsx(Button, { "aria-describedby": ariaDescribedBy, disabled: readOnly, icon: t12, id, mode: "ghost", onClick: handleToggleModal, onFocus: handleFocus, padding: 3, ref: inputRef, text: t13 }), $[40] = ariaDescribedBy, $[41] = handleFocus, $[42] = id, $[43] = inputRef, $[44] = readOnly, $[45] = t12, $[46] = t13, $[47] = t14) : t14 = $[47];
|
|
685
583
|
let t15;
|
|
686
|
-
$[
|
|
687
|
-
t13,
|
|
688
|
-
t14
|
|
689
|
-
] }) }), $[44] = t10, $[45] = t13, $[46] = t14, $[47] = t15) : t15 = $[47];
|
|
584
|
+
$[48] !== handleClear || $[49] !== position || $[50] !== readOnly ? (t15 = position && /* @__PURE__ */ jsx(Button, { disabled: readOnly, icon: TrashIcon, mode: "ghost", onClick: handleClear, padding: 3, text: "Remove", tone: "critical" }), $[48] = handleClear, $[49] = position, $[50] = readOnly, $[51] = t15) : t15 = $[51];
|
|
690
585
|
let t16;
|
|
691
|
-
$[
|
|
586
|
+
$[52] !== t11 || $[53] !== t14 || $[54] !== t15 ? (t16 = /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Grid, { gridTemplateColumns: t11, gap: 3, children: [
|
|
587
|
+
t14,
|
|
588
|
+
t15
|
|
589
|
+
] }) }), $[52] = t11, $[53] = t14, $[54] = t15, $[55] = t16) : t16 = $[55];
|
|
692
590
|
let t17;
|
|
693
|
-
|
|
694
|
-
|
|
591
|
+
$[56] !== config.apiKey || $[57] !== config.defaultLocation || $[58] !== config.defaultRadius || $[59] !== config.defaultRadiusZoom || $[60] !== dialogId || $[61] !== handleBlur || $[62] !== handleChange || $[63] !== handleCloseModal || $[64] !== modalOpen || $[65] !== readOnly || $[66] !== value ? (t17 = modalOpen && /* @__PURE__ */ jsx(Dialog, { header: "Place the marker and set radius on the map", id: `${dialogId}_dialog`, onBlur: handleBlur, onClose: handleCloseModal, ref: dialogRef, width: 1, children: /* @__PURE__ */ jsx(DialogInnerContainer, { children: /* @__PURE__ */ jsx(APIProvider, { apiKey: config.apiKey, children: /* @__PURE__ */ jsx(MapApiGate, { children: /* @__PURE__ */ jsx(GeopointRadiusSelect, { value: value || void 0, onChange: readOnly ? void 0 : handleChange, defaultLocation: config.defaultLocation, defaultRadiusZoom: config.defaultRadiusZoom, defaultRadius: config.defaultRadius }) }) }) }) }), $[56] = config.apiKey, $[57] = config.defaultLocation, $[58] = config.defaultRadius, $[59] = config.defaultRadiusZoom, $[60] = dialogId, $[61] = handleBlur, $[62] = handleChange, $[63] = handleCloseModal, $[64] = modalOpen, $[65] = readOnly, $[66] = value, $[67] = t17) : t17 = $[67];
|
|
592
|
+
let t18;
|
|
593
|
+
return $[68] !== t10 || $[69] !== t16 || $[70] !== t17 || $[71] !== t9 ? (t18 = /* @__PURE__ */ jsxs(Stack, { gap: 3, children: [
|
|
695
594
|
t9,
|
|
696
|
-
|
|
697
|
-
t16
|
|
698
|
-
|
|
595
|
+
t10,
|
|
596
|
+
t16,
|
|
597
|
+
t17
|
|
598
|
+
] }), $[68] = t10, $[69] = t16, $[70] = t17, $[71] = t9, $[72] = t18) : t18 = $[72], t18;
|
|
699
599
|
}
|
|
700
600
|
function _temp(currentState) {
|
|
701
601
|
return !currentState;
|
|
702
602
|
}
|
|
703
|
-
const
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
from,
|
|
712
|
-
to,
|
|
713
|
-
api,
|
|
714
|
-
map,
|
|
715
|
-
zIndex,
|
|
716
|
-
onClick,
|
|
717
|
-
color,
|
|
718
|
-
arrowRef
|
|
719
|
-
} = this.props, lineSymbol = {
|
|
720
|
-
path: api.SymbolPath.FORWARD_OPEN_ARROW
|
|
721
|
-
};
|
|
722
|
-
this.line = new api.Polyline({
|
|
723
|
-
map,
|
|
724
|
-
zIndex,
|
|
725
|
-
path: [from, to],
|
|
726
|
-
icons: [{
|
|
727
|
-
icon: lineSymbol,
|
|
728
|
-
offset: "50%"
|
|
729
|
-
}],
|
|
730
|
-
strokeOpacity: 0.55,
|
|
731
|
-
strokeColor: color ? color.text : "black"
|
|
732
|
-
}), onClick && (this.eventHandlers.click = api.event.addListener(this.line, "click", onClick)), arrowRef && (arrowRef.current = this.line);
|
|
733
|
-
}
|
|
734
|
-
componentDidUpdate(prevProps) {
|
|
735
|
-
if (!this.line)
|
|
736
|
-
return;
|
|
737
|
-
const {
|
|
738
|
-
from,
|
|
739
|
-
to,
|
|
740
|
-
map
|
|
741
|
-
} = this.props;
|
|
742
|
-
(!latLngAreEqual(prevProps.from, from) || !latLngAreEqual(prevProps.to, to)) && this.line.setPath([from, to]), prevProps.map !== map && this.line.setMap(map);
|
|
743
|
-
}
|
|
744
|
-
componentWillUnmount() {
|
|
745
|
-
this.line && this.line.setMap(null), this.eventHandlers.click && this.eventHandlers.click.remove();
|
|
746
|
-
}
|
|
747
|
-
render() {
|
|
748
|
-
return null;
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
function GeopointMove(t0) {
|
|
752
|
-
const $ = c(21), {
|
|
753
|
-
diff,
|
|
754
|
-
api,
|
|
755
|
-
map,
|
|
756
|
-
label
|
|
757
|
-
} = t0, {
|
|
758
|
-
fromValue: from,
|
|
759
|
-
toValue: to
|
|
760
|
-
} = diff, annotation = diff.isChanged ? diff.annotation : void 0, userColor = useUserColor(annotation ? annotation.author : null) || void 0, fromRef = useRef(void 0), toRef = useRef(void 0);
|
|
761
|
-
let t1;
|
|
762
|
-
$[0] !== api || $[1] !== from || $[2] !== map || $[3] !== userColor ? (t1 = from && /* @__PURE__ */ jsx(Marker, { api, map, position: from, zIndex: 0, opacity: 0.55, markerRef: fromRef, color: userColor }), $[0] = api, $[1] = from, $[2] = map, $[3] = userColor, $[4] = t1) : t1 = $[4];
|
|
763
|
-
let t2;
|
|
764
|
-
$[5] !== api || $[6] !== from || $[7] !== map || $[8] !== to || $[9] !== userColor ? (t2 = from && to && /* @__PURE__ */ jsx(Arrow, { api, map, from, to, zIndex: 1, color: userColor }), $[5] = api, $[6] = from, $[7] = map, $[8] = to, $[9] = userColor, $[10] = t2) : t2 = $[10];
|
|
765
|
-
let t3;
|
|
766
|
-
$[11] !== api || $[12] !== label || $[13] !== map || $[14] !== to || $[15] !== userColor ? (t3 = to && /* @__PURE__ */ jsx(Marker, { api, map, position: to, zIndex: 2, markerRef: toRef, label, color: userColor }), $[11] = api, $[12] = label, $[13] = map, $[14] = to, $[15] = userColor, $[16] = t3) : t3 = $[16];
|
|
767
|
-
let t4;
|
|
768
|
-
return $[17] !== t1 || $[18] !== t2 || $[19] !== t3 ? (t4 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
769
|
-
t1,
|
|
770
|
-
t2,
|
|
771
|
-
t3
|
|
772
|
-
] }), $[17] = t1, $[18] = t2, $[19] = t3, $[20] = t4) : t4 = $[20], t4;
|
|
773
|
-
}
|
|
774
|
-
const GeopointArrayDiff = (t0) => {
|
|
775
|
-
const $ = c(4), {
|
|
776
|
-
diff,
|
|
777
|
-
schemaType
|
|
778
|
-
} = t0;
|
|
779
|
-
let t1;
|
|
780
|
-
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = getGeoConfig(), $[0] = t1) : t1 = $[0];
|
|
781
|
-
let t2;
|
|
782
|
-
return $[1] !== diff || $[2] !== schemaType ? (t2 = /* @__PURE__ */ jsx(RootContainer, { children: /* @__PURE__ */ jsx(GoogleMapsLoadProxy, { config: t1, children: (api) => /* @__PURE__ */ jsx(GeopointDiff$1, { api, diff, schemaType }) }) }), $[1] = diff, $[2] = schemaType, $[3] = t2) : t2 = $[3], t2;
|
|
783
|
-
};
|
|
784
|
-
function GeopointDiff$1(t0) {
|
|
785
|
-
const $ = c(17), {
|
|
786
|
-
api,
|
|
787
|
-
diff
|
|
788
|
-
} = t0;
|
|
789
|
-
let T0, bounds, t1, t2, t3;
|
|
790
|
-
if ($[0] !== api || $[1] !== diff.fromValue || $[2] !== diff.toValue) {
|
|
791
|
-
t3 = /* @__PURE__ */ Symbol.for("react.early_return_sentinel");
|
|
792
|
-
bb0: {
|
|
793
|
-
const fromValue = (diff.fromValue || []).filter(hasCoordinates), toValue = (diff.toValue || []).filter(hasCoordinates);
|
|
794
|
-
if (fromValue.length === 0 && toValue.length === 0) {
|
|
795
|
-
t3 = null;
|
|
796
|
-
break bb0;
|
|
603
|
+
const googleMapsInput = definePlugin((config) => ({
|
|
604
|
+
name: "google-maps-input",
|
|
605
|
+
studio: {
|
|
606
|
+
components: {
|
|
607
|
+
// Make the config (API key) available to diff components, which are
|
|
608
|
+
// resolved outside of the form and so can't receive it as a prop.
|
|
609
|
+
activeToolLayout: function(props) {
|
|
610
|
+
return /* @__PURE__ */ jsx(GoogleMapsInputContext, { value: config, children: props.renderDefault(props) });
|
|
797
611
|
}
|
|
798
|
-
bounds = getBounds$2(fromValue, toValue, api), T0 = GoogleMap, t1 = api, t2 = bounds.getCenter().toJSON();
|
|
799
612
|
}
|
|
800
|
-
|
|
801
|
-
} else
|
|
802
|
-
T0 = $[3], bounds = $[4], t1 = $[5], t2 = $[6], t3 = $[7];
|
|
803
|
-
if (t3 !== /* @__PURE__ */ Symbol.for("react.early_return_sentinel"))
|
|
804
|
-
return t3;
|
|
805
|
-
let t4;
|
|
806
|
-
$[8] !== api || $[9] !== diff.items ? (t4 = (map) => /* @__PURE__ */ jsx(Fragment, { children: diff.items.map((t52) => {
|
|
807
|
-
const {
|
|
808
|
-
toIndex,
|
|
809
|
-
diff: pointDiff
|
|
810
|
-
} = t52;
|
|
811
|
-
return isChangeDiff(pointDiff) ? /* @__PURE__ */ jsx(GeopointMove, { api, map, diff: pointDiff, label: `${toIndex}` }, toIndex) : null;
|
|
812
|
-
}) }), $[8] = api, $[9] = diff.items, $[10] = t4) : t4 = $[10];
|
|
813
|
-
let t5;
|
|
814
|
-
return $[11] !== T0 || $[12] !== bounds || $[13] !== t1 || $[14] !== t2 || $[15] !== t4 ? (t5 = /* @__PURE__ */ jsx(T0, { api: t1, location: t2, mapTypeControl: !1, controlSize: 20, bounds, children: t4 }), $[11] = T0, $[12] = bounds, $[13] = t1, $[14] = t2, $[15] = t4, $[16] = t5) : t5 = $[16], t5;
|
|
815
|
-
}
|
|
816
|
-
function isChangeDiff(diff) {
|
|
817
|
-
return diff.action !== "unchanged" && diff.type === "object";
|
|
818
|
-
}
|
|
819
|
-
function hasCoordinates(point) {
|
|
820
|
-
return typeof point.lat == "number" && typeof point.lng == "number";
|
|
821
|
-
}
|
|
822
|
-
function getBounds$2(fromValue, toValue, api) {
|
|
823
|
-
const bounds = new api.LatLngBounds();
|
|
824
|
-
return [...fromValue || [], ...toValue || []].forEach((point) => bounds.extend(point)), bounds;
|
|
825
|
-
}
|
|
826
|
-
const GeopointFieldDiff = (t0) => {
|
|
827
|
-
const $ = c(4), {
|
|
828
|
-
diff,
|
|
829
|
-
schemaType
|
|
830
|
-
} = t0;
|
|
831
|
-
let t1;
|
|
832
|
-
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = getGeoConfig(), $[0] = t1) : t1 = $[0];
|
|
833
|
-
let t2;
|
|
834
|
-
return $[1] !== diff || $[2] !== schemaType ? (t2 = /* @__PURE__ */ jsx(RootContainer, { children: /* @__PURE__ */ jsx(GoogleMapsLoadProxy, { config: t1, children: (api) => /* @__PURE__ */ jsx(GeopointDiff, { api, diff, schemaType }) }) }), $[1] = diff, $[2] = schemaType, $[3] = t2) : t2 = $[3], t2;
|
|
835
|
-
};
|
|
836
|
-
function GeopointDiff(t0) {
|
|
837
|
-
const $ = c(25), {
|
|
838
|
-
api,
|
|
839
|
-
diff
|
|
840
|
-
} = t0, {
|
|
841
|
-
fromValue,
|
|
842
|
-
toValue
|
|
843
|
-
} = diff;
|
|
844
|
-
let t1;
|
|
845
|
-
$[0] !== diff ? (t1 = getAnnotationAtPath(diff, ["lat"]) || getAnnotationAtPath(diff, ["lng"]) || getAnnotationAtPath(diff, []), $[0] = diff, $[1] = t1) : t1 = $[1];
|
|
846
|
-
const annotation = t1;
|
|
847
|
-
let t2;
|
|
848
|
-
$[2] !== api || $[3] !== diff ? (t2 = getCenter$1(diff, api), $[2] = api, $[3] = diff, $[4] = t2) : t2 = $[4];
|
|
849
|
-
const center = t2;
|
|
850
|
-
let t3;
|
|
851
|
-
$[5] !== api || $[6] !== fromValue || $[7] !== toValue ? (t3 = fromValue && toValue ? getBounds$1(fromValue, toValue, api) : void 0, $[5] = api, $[6] = fromValue, $[7] = toValue, $[8] = t3) : t3 = $[8];
|
|
852
|
-
const bounds = t3;
|
|
853
|
-
let t4;
|
|
854
|
-
$[9] !== annotation ? (t4 = annotation ? [annotation] : [], $[9] = annotation, $[10] = t4) : t4 = $[10];
|
|
855
|
-
let t5;
|
|
856
|
-
$[11] !== diff ? (t5 = getAction$1(diff), $[11] = diff, $[12] = t5) : t5 = $[12];
|
|
857
|
-
let t6;
|
|
858
|
-
$[13] !== api || $[14] !== diff ? (t6 = (map) => /* @__PURE__ */ jsx(GeopointMove, { api, map, diff }), $[13] = api, $[14] = diff, $[15] = t6) : t6 = $[15];
|
|
859
|
-
let t7;
|
|
860
|
-
$[16] !== api || $[17] !== bounds || $[18] !== center || $[19] !== t6 ? (t7 = /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(GoogleMap, { api, location: center, mapTypeControl: !1, controlSize: 20, bounds, scrollWheel: !1, children: t6 }) }), $[16] = api, $[17] = bounds, $[18] = center, $[19] = t6, $[20] = t7) : t7 = $[20];
|
|
861
|
-
let t8;
|
|
862
|
-
return $[21] !== t4 || $[22] !== t5 || $[23] !== t7 ? (t8 = /* @__PURE__ */ jsx(DiffTooltip, { annotations: t4, description: t5, children: t7 }), $[21] = t4, $[22] = t5, $[23] = t7, $[24] = t8) : t8 = $[24], t8;
|
|
863
|
-
}
|
|
864
|
-
function getBounds$1(fromValue, toValue, api) {
|
|
865
|
-
return new api.LatLngBounds().extend(fromValue).extend(toValue);
|
|
866
|
-
}
|
|
867
|
-
function getCenter$1(diff, api) {
|
|
868
|
-
const {
|
|
869
|
-
fromValue,
|
|
870
|
-
toValue
|
|
871
|
-
} = diff;
|
|
872
|
-
if (fromValue && toValue)
|
|
873
|
-
return getBounds$1(fromValue, toValue, api).getCenter().toJSON();
|
|
874
|
-
if (fromValue)
|
|
875
|
-
return fromValue;
|
|
876
|
-
if (toValue)
|
|
877
|
-
return toValue;
|
|
878
|
-
throw new Error("Neither a from or a to value present");
|
|
879
|
-
}
|
|
880
|
-
function getAction$1(diff) {
|
|
881
|
-
const {
|
|
882
|
-
fromValue,
|
|
883
|
-
toValue
|
|
884
|
-
} = diff;
|
|
885
|
-
return fromValue && toValue ? "Moved" : fromValue ? "Removed" : toValue ? "Added" : "Unchanged";
|
|
886
|
-
}
|
|
887
|
-
function GeopointRadiusMove(t0) {
|
|
888
|
-
const $ = c(33), {
|
|
889
|
-
diff,
|
|
890
|
-
api,
|
|
891
|
-
map,
|
|
892
|
-
label
|
|
893
|
-
} = t0, {
|
|
894
|
-
fromValue: from,
|
|
895
|
-
toValue: to
|
|
896
|
-
} = diff, annotation = diff.isChanged ? diff.annotation : void 0, userColor = useUserColor(annotation ? annotation.author : null) || void 0, fromRef = useRef(void 0), toRef = useRef(void 0), fromCircleRef = useRef(void 0), toCircleRef = useRef(void 0);
|
|
897
|
-
let t1;
|
|
898
|
-
$[0] !== api || $[1] !== from || $[2] !== map || $[3] !== to || $[4] !== userColor?.background ? (t1 = () => {
|
|
899
|
-
const color = userColor?.background || "#4285F4";
|
|
900
|
-
return from && from.radius && (fromCircleRef.current = new api.Circle({
|
|
901
|
-
map,
|
|
902
|
-
center: {
|
|
903
|
-
lat: from.lat,
|
|
904
|
-
lng: from.lng
|
|
905
|
-
},
|
|
906
|
-
radius: from.radius,
|
|
907
|
-
fillColor: color,
|
|
908
|
-
fillOpacity: 0.1,
|
|
909
|
-
strokeColor: color,
|
|
910
|
-
strokeOpacity: 0.3,
|
|
911
|
-
strokeWeight: 1,
|
|
912
|
-
zIndex: 0
|
|
913
|
-
})), to && to.radius && (toCircleRef.current = new api.Circle({
|
|
914
|
-
map,
|
|
915
|
-
center: {
|
|
916
|
-
lat: to.lat,
|
|
917
|
-
lng: to.lng
|
|
918
|
-
},
|
|
919
|
-
radius: to.radius,
|
|
920
|
-
fillColor: color,
|
|
921
|
-
fillOpacity: 0.2,
|
|
922
|
-
strokeColor: color,
|
|
923
|
-
strokeOpacity: 0.8,
|
|
924
|
-
strokeWeight: 2,
|
|
925
|
-
zIndex: 2
|
|
926
|
-
})), () => {
|
|
927
|
-
fromCircleRef.current && fromCircleRef.current.setMap(null), toCircleRef.current && toCircleRef.current.setMap(null);
|
|
928
|
-
};
|
|
929
|
-
}, $[0] = api, $[1] = from, $[2] = map, $[3] = to, $[4] = userColor?.background, $[5] = t1) : t1 = $[5];
|
|
930
|
-
let t2;
|
|
931
|
-
$[6] !== api || $[7] !== from || $[8] !== map || $[9] !== to || $[10] !== userColor ? (t2 = [api, map, from, to, userColor], $[6] = api, $[7] = from, $[8] = map, $[9] = to, $[10] = userColor, $[11] = t2) : t2 = $[11], useEffect(t1, t2);
|
|
932
|
-
let t3;
|
|
933
|
-
$[12] !== api || $[13] !== from || $[14] !== map || $[15] !== userColor ? (t3 = from && /* @__PURE__ */ jsx(Marker, { api, map, position: from, zIndex: 0, opacity: 0.55, markerRef: fromRef, color: userColor }), $[12] = api, $[13] = from, $[14] = map, $[15] = userColor, $[16] = t3) : t3 = $[16];
|
|
934
|
-
let t4;
|
|
935
|
-
$[17] !== api || $[18] !== from || $[19] !== map || $[20] !== to || $[21] !== userColor ? (t4 = from && to && /* @__PURE__ */ jsx(Arrow, { api, map, from, to, zIndex: 1, color: userColor }), $[17] = api, $[18] = from, $[19] = map, $[20] = to, $[21] = userColor, $[22] = t4) : t4 = $[22];
|
|
936
|
-
let t5;
|
|
937
|
-
$[23] !== api || $[24] !== label || $[25] !== map || $[26] !== to || $[27] !== userColor ? (t5 = to && /* @__PURE__ */ jsx(Marker, { api, map, position: to, zIndex: 2, markerRef: toRef, label, color: userColor }), $[23] = api, $[24] = label, $[25] = map, $[26] = to, $[27] = userColor, $[28] = t5) : t5 = $[28];
|
|
938
|
-
let t6;
|
|
939
|
-
return $[29] !== t3 || $[30] !== t4 || $[31] !== t5 ? (t6 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
940
|
-
t3,
|
|
941
|
-
t4,
|
|
942
|
-
t5
|
|
943
|
-
] }), $[29] = t3, $[30] = t4, $[31] = t5, $[32] = t6) : t6 = $[32], t6;
|
|
944
|
-
}
|
|
945
|
-
const GeopointRadiusFieldDiff = (t0) => {
|
|
946
|
-
const $ = c(4), {
|
|
947
|
-
diff,
|
|
948
|
-
schemaType
|
|
949
|
-
} = t0;
|
|
950
|
-
let t1;
|
|
951
|
-
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = getGeoConfig(), $[0] = t1) : t1 = $[0];
|
|
952
|
-
let t2;
|
|
953
|
-
return $[1] !== diff || $[2] !== schemaType ? (t2 = /* @__PURE__ */ jsx(RootContainer, { children: /* @__PURE__ */ jsx(GoogleMapsLoadProxy, { config: t1, children: (api) => /* @__PURE__ */ jsx(GeopointRadiusDiff, { api, diff, schemaType }) }) }), $[1] = diff, $[2] = schemaType, $[3] = t2) : t2 = $[3], t2;
|
|
954
|
-
};
|
|
955
|
-
function GeopointRadiusDiff(t0) {
|
|
956
|
-
const $ = c(25), {
|
|
957
|
-
api,
|
|
958
|
-
diff
|
|
959
|
-
} = t0, {
|
|
960
|
-
fromValue,
|
|
961
|
-
toValue
|
|
962
|
-
} = diff;
|
|
963
|
-
let t1;
|
|
964
|
-
$[0] !== diff ? (t1 = getAnnotationAtPath(diff, ["lat"]) || getAnnotationAtPath(diff, ["lng"]) || getAnnotationAtPath(diff, ["radius"]) || getAnnotationAtPath(diff, []), $[0] = diff, $[1] = t1) : t1 = $[1];
|
|
965
|
-
const annotation = t1;
|
|
966
|
-
let t2;
|
|
967
|
-
$[2] !== api || $[3] !== diff ? (t2 = getCenter(diff, api), $[2] = api, $[3] = diff, $[4] = t2) : t2 = $[4];
|
|
968
|
-
const center = t2;
|
|
969
|
-
let t3;
|
|
970
|
-
$[5] !== api || $[6] !== fromValue || $[7] !== toValue ? (t3 = fromValue && toValue ? getBounds(fromValue, toValue, api) : void 0, $[5] = api, $[6] = fromValue, $[7] = toValue, $[8] = t3) : t3 = $[8];
|
|
971
|
-
const bounds = t3;
|
|
972
|
-
let t4;
|
|
973
|
-
$[9] !== annotation ? (t4 = annotation ? [annotation] : [], $[9] = annotation, $[10] = t4) : t4 = $[10];
|
|
974
|
-
let t5;
|
|
975
|
-
$[11] !== diff ? (t5 = getAction(diff), $[11] = diff, $[12] = t5) : t5 = $[12];
|
|
976
|
-
let t6;
|
|
977
|
-
$[13] !== api || $[14] !== diff ? (t6 = (map) => /* @__PURE__ */ jsx(GeopointRadiusMove, { api, map, diff }), $[13] = api, $[14] = diff, $[15] = t6) : t6 = $[15];
|
|
978
|
-
let t7;
|
|
979
|
-
$[16] !== api || $[17] !== bounds || $[18] !== center || $[19] !== t6 ? (t7 = /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(GoogleMap, { api, location: center, mapTypeControl: !1, controlSize: 20, bounds, scrollWheel: !1, children: t6 }) }), $[16] = api, $[17] = bounds, $[18] = center, $[19] = t6, $[20] = t7) : t7 = $[20];
|
|
980
|
-
let t8;
|
|
981
|
-
return $[21] !== t4 || $[22] !== t5 || $[23] !== t7 ? (t8 = /* @__PURE__ */ jsx(DiffTooltip, { annotations: t4, description: t5, children: t7 }), $[21] = t4, $[22] = t5, $[23] = t7, $[24] = t8) : t8 = $[24], t8;
|
|
982
|
-
}
|
|
983
|
-
function getBounds(fromValue, toValue, api) {
|
|
984
|
-
const bounds = new api.LatLngBounds().extend(fromValue).extend(toValue), fromRadius = fromValue.radius || 0, toRadius = toValue.radius || 0, maxRadius = Math.max(fromRadius, toRadius);
|
|
985
|
-
if (maxRadius > 0) {
|
|
986
|
-
const radiusInDegrees = maxRadius / 111e3;
|
|
987
|
-
bounds.extend({
|
|
988
|
-
lat: fromValue.lat + radiusInDegrees,
|
|
989
|
-
lng: fromValue.lng + radiusInDegrees
|
|
990
|
-
}), bounds.extend({
|
|
991
|
-
lat: fromValue.lat - radiusInDegrees,
|
|
992
|
-
lng: fromValue.lng - radiusInDegrees
|
|
993
|
-
}), bounds.extend({
|
|
994
|
-
lat: toValue.lat + radiusInDegrees,
|
|
995
|
-
lng: toValue.lng + radiusInDegrees
|
|
996
|
-
}), bounds.extend({
|
|
997
|
-
lat: toValue.lat - radiusInDegrees,
|
|
998
|
-
lng: toValue.lng - radiusInDegrees
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
return bounds;
|
|
1002
|
-
}
|
|
1003
|
-
function getCenter(diff, api) {
|
|
1004
|
-
const {
|
|
1005
|
-
fromValue,
|
|
1006
|
-
toValue
|
|
1007
|
-
} = diff;
|
|
1008
|
-
if (fromValue && toValue)
|
|
1009
|
-
return getBounds(fromValue, toValue, api).getCenter().toJSON();
|
|
1010
|
-
if (fromValue)
|
|
1011
|
-
return fromValue;
|
|
1012
|
-
if (toValue)
|
|
1013
|
-
return toValue;
|
|
1014
|
-
throw new Error("Neither a from or a to value present");
|
|
1015
|
-
}
|
|
1016
|
-
function getAction(diff) {
|
|
1017
|
-
const {
|
|
1018
|
-
fromValue,
|
|
1019
|
-
toValue
|
|
1020
|
-
} = diff;
|
|
1021
|
-
if (fromValue && toValue) {
|
|
1022
|
-
const latChanged = fromValue.lat !== toValue.lat || fromValue.lng !== toValue.lng, radiusChanged = fromValue.radius !== toValue.radius;
|
|
1023
|
-
return latChanged && radiusChanged ? "Moved and radius changed" : latChanged ? "Moved" : radiusChanged ? "Radius changed" : "Unchanged";
|
|
1024
|
-
} else {
|
|
1025
|
-
if (fromValue)
|
|
1026
|
-
return "Removed";
|
|
1027
|
-
if (toValue)
|
|
1028
|
-
return "Added";
|
|
1029
|
-
}
|
|
1030
|
-
return "Unchanged";
|
|
1031
|
-
}
|
|
1032
|
-
const googleMapsInput = definePlugin((config2) => (setGeoConfig(config2), {
|
|
1033
|
-
name: "google-maps-input",
|
|
613
|
+
},
|
|
1034
614
|
schema: {
|
|
1035
615
|
types: [{
|
|
1036
616
|
name: "geopointRadius",
|
|
1037
617
|
title: "Geopoint with Radius",
|
|
1038
618
|
type: "object",
|
|
619
|
+
// Only attach the map diff when there's a key to render it with;
|
|
620
|
+
// otherwise fall back to the default per-field (lat/lng/radius) diff.
|
|
621
|
+
components: config.apiKey ? {
|
|
622
|
+
diff: GeopointDiff
|
|
623
|
+
} : void 0,
|
|
1039
624
|
fields: [{
|
|
1040
625
|
name: "lat",
|
|
1041
626
|
title: "Latitude",
|
|
@@ -1068,7 +653,7 @@ const googleMapsInput = definePlugin((config2) => (setGeoConfig(config2), {
|
|
|
1068
653
|
radius
|
|
1069
654
|
}) {
|
|
1070
655
|
return {
|
|
1071
|
-
title: `${lat.toFixed(6)}, ${lng.toFixed(6)}
|
|
656
|
+
title: typeof lat == "number" && typeof lng == "number" ? `${lat.toFixed(6)}, ${lng.toFixed(6)}` : "No location set",
|
|
1072
657
|
subtitle: radius ? `Radius: ${radius}m` : "No radius set"
|
|
1073
658
|
};
|
|
1074
659
|
}
|
|
@@ -1078,7 +663,7 @@ const googleMapsInput = definePlugin((config2) => (setGeoConfig(config2), {
|
|
|
1078
663
|
form: {
|
|
1079
664
|
components: {
|
|
1080
665
|
input(props) {
|
|
1081
|
-
return isGeopoint(props.schemaType) ? /* @__PURE__ */ jsx(GeopointInput, { ...props, geoConfig:
|
|
666
|
+
return isGeopoint(props.schemaType) ? /* @__PURE__ */ jsx(GeopointInput, { ...props, geoConfig: config }) : isGeopointRadius(props.schemaType) ? /* @__PURE__ */ jsx(GeopointRadiusInput, { ...props, geoConfig: config }) : props.renderDefault(props);
|
|
1082
667
|
}
|
|
1083
668
|
}
|
|
1084
669
|
}
|
|
@@ -1093,10 +678,8 @@ function isType(name, schema) {
|
|
|
1093
678
|
return schema?.name === name ? !0 : schema?.name ? isType(name, schema?.type) : !1;
|
|
1094
679
|
}
|
|
1095
680
|
export {
|
|
1096
|
-
|
|
1097
|
-
GeopointFieldDiff,
|
|
681
|
+
GeopointDiff,
|
|
1098
682
|
GeopointInput,
|
|
1099
|
-
GeopointRadiusFieldDiff,
|
|
1100
683
|
GeopointRadiusInput,
|
|
1101
684
|
googleMapsInput
|
|
1102
685
|
};
|