@sanity/google-maps-input 2.30.2-shopify.2 → 3.0.0-v3-studio.0
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 +68 -2
- package/lib/cjs/index.js +902 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/esm/index.js +892 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/types/index.d.ts +43 -0
- package/lib/types/index.d.ts.map +1 -0
- package/package.json +71 -19
- package/src/@types/css.d.ts +4 -0
- package/src/diff/GeopointArrayDiff.tsx +84 -0
- package/src/diff/GeopointFieldDiff.styles.tsx +20 -0
- package/src/diff/GeopointFieldDiff.tsx +95 -0
- package/src/diff/GeopointMove.tsx +48 -0
- package/src/diff/resolver.ts +21 -0
- package/src/global-workaround.ts +11 -0
- package/src/index.tsx +52 -0
- package/src/input/GeopointInput.styles.tsx +12 -0
- package/src/input/GeopointInput.tsx +176 -0
- package/src/input/GeopointSelect.tsx +78 -0
- package/src/loader/GoogleMapsLoadProxy.tsx +51 -0
- package/src/loader/LoadError.tsx +44 -0
- package/src/loader/loadGoogleMapsApi.ts +97 -0
- package/src/map/Arrow.tsx +76 -0
- package/src/map/Map.styles.tsx +10 -0
- package/src/map/Map.tsx +125 -0
- package/src/map/Marker.tsx +130 -0
- package/src/map/SearchInput.styles.tsx +8 -0
- package/src/map/SearchInput.tsx +56 -0
- package/src/map/util.ts +14 -0
- package/src/types.ts +19 -0
- package/.depcheckignore.json +0 -3
- package/config.dist.json +0 -9
- package/dist/dts/diff/GeopointArrayDiff.d.ts +0 -5
- package/dist/dts/diff/GeopointArrayDiff.d.ts.map +0 -1
- package/dist/dts/diff/GeopointFieldDiff.d.ts +0 -5
- package/dist/dts/diff/GeopointFieldDiff.d.ts.map +0 -1
- package/dist/dts/diff/GeopointFieldDiff.styles.d.ts +0 -2
- package/dist/dts/diff/GeopointFieldDiff.styles.d.ts.map +0 -1
- package/dist/dts/diff/GeopointMove.d.ts +0 -13
- package/dist/dts/diff/GeopointMove.d.ts.map +0 -1
- package/dist/dts/diff/resolver.d.ts +0 -4
- package/dist/dts/diff/resolver.d.ts.map +0 -1
- package/dist/dts/input/GeopointInput.d.ts +0 -40
- package/dist/dts/input/GeopointInput.d.ts.map +0 -1
- package/dist/dts/input/GeopointInput.styles.d.ts +0 -3
- package/dist/dts/input/GeopointInput.styles.d.ts.map +0 -1
- package/dist/dts/input/GeopointSelect.d.ts +0 -28
- package/dist/dts/input/GeopointSelect.d.ts.map +0 -1
- package/dist/dts/loader/GoogleMapsLoadProxy.d.ts +0 -14
- package/dist/dts/loader/GoogleMapsLoadProxy.d.ts.map +0 -1
- package/dist/dts/loader/LoadError.d.ts +0 -10
- package/dist/dts/loader/LoadError.d.ts.map +0 -1
- package/dist/dts/loader/loadGoogleMapsApi.d.ts +0 -18
- package/dist/dts/loader/loadGoogleMapsApi.d.ts.map +0 -1
- package/dist/dts/map/Arrow.d.ts +0 -29
- package/dist/dts/map/Arrow.d.ts.map +0 -1
- package/dist/dts/map/Map.d.ts +0 -37
- package/dist/dts/map/Map.d.ts.map +0 -1
- package/dist/dts/map/Map.styles.d.ts +0 -2
- package/dist/dts/map/Map.styles.d.ts.map +0 -1
- package/dist/dts/map/Marker.d.ts +0 -36
- package/dist/dts/map/Marker.d.ts.map +0 -1
- package/dist/dts/map/SearchInput.d.ts +0 -16
- package/dist/dts/map/SearchInput.d.ts.map +0 -1
- package/dist/dts/map/SearchInput.styles.d.ts +0 -2
- package/dist/dts/map/SearchInput.styles.d.ts.map +0 -1
- package/dist/dts/map/util.d.ts +0 -4
- package/dist/dts/map/util.d.ts.map +0 -1
- package/dist/dts/types.d.ts +0 -14
- package/dist/dts/types.d.ts.map +0 -1
- package/lib/@types/css.d.js +0 -1
- package/lib/diff/GeopointArrayDiff.js +0 -82
- package/lib/diff/GeopointFieldDiff.js +0 -97
- package/lib/diff/GeopointFieldDiff.styles.js +0 -18
- package/lib/diff/GeopointMove.js +0 -55
- package/lib/diff/resolver.js +0 -27
- package/lib/input/GeopointInput.js +0 -194
- package/lib/input/GeopointInput.styles.js +0 -22
- package/lib/input/GeopointSelect.js +0 -103
- package/lib/loader/GoogleMapsLoadProxy.js +0 -70
- package/lib/loader/LoadError.js +0 -43
- package/lib/loader/loadGoogleMapsApi.js +0 -81
- package/lib/map/Arrow.js +0 -97
- package/lib/map/Map.js +0 -147
- package/lib/map/Map.styles.js +0 -18
- package/lib/map/Marker.js +0 -156
- package/lib/map/SearchInput.js +0 -77
- package/lib/map/SearchInput.styles.js +0 -18
- package/lib/map/util.js +0 -14
- package/lib/types.js +0 -5
- package/sanity.json +0 -18
- package/tsconfig.json +0 -20
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,892 @@
|
|
|
1
|
+
import {jsx as $7XdDa$jsx, jsxs as $7XdDa$jsxs, Fragment as $7XdDa$Fragment} from "react/jsx-runtime";
|
|
2
|
+
import $7XdDa$react, {createRef as $7XdDa$createRef, PureComponent as $7XdDa$PureComponent, useRef as $7XdDa$useRef} from "react";
|
|
3
|
+
import {createPlugin as $7XdDa$createPlugin} from "sanity";
|
|
4
|
+
import {uniqueId as $7XdDa$uniqueId} from "lodash";
|
|
5
|
+
import {Box as $7XdDa$Box, Grid as $7XdDa$Grid, Button as $7XdDa$Button, Dialog as $7XdDa$Dialog, Card as $7XdDa$Card, Text as $7XdDa$Text, Code as $7XdDa$Code, TextInput as $7XdDa$TextInput} from "@sanity/ui";
|
|
6
|
+
import {EditIcon as $7XdDa$EditIcon, TrashIcon as $7XdDa$TrashIcon} from "@sanity/icons";
|
|
7
|
+
import {ChangeIndicatorCompareValueProvider as $7XdDa$ChangeIndicatorCompareValueProvider, ChangeIndicator as $7XdDa$ChangeIndicator, useUserColor as $7XdDa$useUserColor, getAnnotationAtPath as $7XdDa$getAnnotationAtPath, DiffTooltip as $7XdDa$DiffTooltip} from "sanity/_unstable";
|
|
8
|
+
import {setIfMissing as $7XdDa$setIfMissing, set as $7XdDa$set, unset as $7XdDa$unset} from "sanity/form";
|
|
9
|
+
import {BehaviorSubject as $7XdDa$BehaviorSubject} from "rxjs";
|
|
10
|
+
import $7XdDa$styledcomponents from "styled-components";
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const $f3e4d9113981c5e8$var$callbackName = "___sanity_googleMapsApiCallback";
|
|
26
|
+
const $f3e4d9113981c5e8$var$authFailureCallbackName = "gm_authFailure";
|
|
27
|
+
const $f3e4d9113981c5e8$var$locale = typeof window !== "undefined" && window.navigator.language || "en";
|
|
28
|
+
let $f3e4d9113981c5e8$var$subject;
|
|
29
|
+
function $f3e4d9113981c5e8$export$616f2ff2d07a5991(config) {
|
|
30
|
+
const selectedLocale = config.defaultLocale || $f3e4d9113981c5e8$var$locale || "en-US";
|
|
31
|
+
if ($f3e4d9113981c5e8$var$subject) return $f3e4d9113981c5e8$var$subject;
|
|
32
|
+
$f3e4d9113981c5e8$var$subject = new (0, $7XdDa$BehaviorSubject)({
|
|
33
|
+
loadState: "loading"
|
|
34
|
+
});
|
|
35
|
+
window[$f3e4d9113981c5e8$var$authFailureCallbackName] = ()=>{
|
|
36
|
+
delete window[$f3e4d9113981c5e8$var$authFailureCallbackName];
|
|
37
|
+
$f3e4d9113981c5e8$var$subject.next({
|
|
38
|
+
loadState: "authError"
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
window[$f3e4d9113981c5e8$var$callbackName] = ()=>{
|
|
42
|
+
delete window[$f3e4d9113981c5e8$var$callbackName];
|
|
43
|
+
$f3e4d9113981c5e8$var$subject.next({
|
|
44
|
+
loadState: "loaded",
|
|
45
|
+
api: window.google.maps
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
const script = document.createElement("script");
|
|
49
|
+
script.onerror = (event, source, lineno, colno, error)=>$f3e4d9113981c5e8$var$subject.next({
|
|
50
|
+
loadState: "loadError",
|
|
51
|
+
error: $f3e4d9113981c5e8$var$coeerceError(event, error)
|
|
52
|
+
});
|
|
53
|
+
script.src = `https://maps.googleapis.com/maps/api/js?key=${config.apiKey}&libraries=places&callback=${$f3e4d9113981c5e8$var$callbackName}&language=${selectedLocale}`;
|
|
54
|
+
document.getElementsByTagName("head")[0].appendChild(script);
|
|
55
|
+
return $f3e4d9113981c5e8$var$subject;
|
|
56
|
+
}
|
|
57
|
+
function $f3e4d9113981c5e8$var$coeerceError(event, error) {
|
|
58
|
+
if (error) return error;
|
|
59
|
+
if (typeof event === "string") return new Error(event);
|
|
60
|
+
return new Error($f3e4d9113981c5e8$var$isErrorEvent(event) ? event.message : "Failed to load Google Maps API");
|
|
61
|
+
}
|
|
62
|
+
function $f3e4d9113981c5e8$var$isErrorEvent(event) {
|
|
63
|
+
if (typeof event !== "object" || event === null) return false;
|
|
64
|
+
if (!("message" in event)) return false;
|
|
65
|
+
return typeof event.message === "string";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
function $720eceaeeca17272$export$58a097931cd8d64d(props) {
|
|
73
|
+
return /*#__PURE__*/ (0, $7XdDa$jsxs)((0, $7XdDa$Card), {
|
|
74
|
+
tone: "critical",
|
|
75
|
+
radius: 1,
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Box), {
|
|
78
|
+
as: "header",
|
|
79
|
+
paddingX: 4,
|
|
80
|
+
paddingTop: 4,
|
|
81
|
+
paddingBottom: 1,
|
|
82
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Text), {
|
|
83
|
+
as: "h2",
|
|
84
|
+
weight: "bold",
|
|
85
|
+
children: "Google Maps failed to load"
|
|
86
|
+
})
|
|
87
|
+
}),
|
|
88
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Box), {
|
|
89
|
+
paddingX: 4,
|
|
90
|
+
paddingTop: 4,
|
|
91
|
+
paddingBottom: 1,
|
|
92
|
+
children: props.isAuthError ? /*#__PURE__*/ (0, $7XdDa$jsx)($720eceaeeca17272$var$AuthError, {}) : /*#__PURE__*/ (0, $7XdDa$jsxs)((0, $7XdDa$Fragment), {
|
|
93
|
+
children: [
|
|
94
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Text), {
|
|
95
|
+
as: "h3",
|
|
96
|
+
children: "Error details:"
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("pre", {
|
|
99
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Code), {
|
|
100
|
+
size: 1,
|
|
101
|
+
children: "error" in props && props.error?.message
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function $720eceaeeca17272$var$AuthError() {
|
|
111
|
+
return /*#__PURE__*/ (0, $7XdDa$jsxs)((0, $7XdDa$Text), {
|
|
112
|
+
children: [
|
|
113
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("p", {
|
|
114
|
+
children: "The error appears to be related to authentication"
|
|
115
|
+
}),
|
|
116
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("p", {
|
|
117
|
+
children: "Common causes include:"
|
|
118
|
+
}),
|
|
119
|
+
/*#__PURE__*/ (0, $7XdDa$jsxs)("ul", {
|
|
120
|
+
children: [
|
|
121
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("li", {
|
|
122
|
+
children: "Incorrect API key"
|
|
123
|
+
}),
|
|
124
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("li", {
|
|
125
|
+
children: "Referer not allowed"
|
|
126
|
+
}),
|
|
127
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("li", {
|
|
128
|
+
children: "Missing authentication scope"
|
|
129
|
+
})
|
|
130
|
+
]
|
|
131
|
+
}),
|
|
132
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("p", {
|
|
133
|
+
children: "Check the browser developer tools for more information."
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class $004c8002f57d3835$export$a628545bcf173896 extends (0, $7XdDa$react).Component {
|
|
141
|
+
constructor(props){
|
|
142
|
+
super(props);
|
|
143
|
+
this.state = {
|
|
144
|
+
loadState: "loading"
|
|
145
|
+
};
|
|
146
|
+
let sync = true;
|
|
147
|
+
this.loadSubscription = (0, $f3e4d9113981c5e8$export$616f2ff2d07a5991)(props.config).subscribe((loadState)=>{
|
|
148
|
+
if (sync) this.state = loadState;
|
|
149
|
+
else this.setState(loadState);
|
|
150
|
+
});
|
|
151
|
+
sync = false;
|
|
152
|
+
}
|
|
153
|
+
componentWillUnmount() {
|
|
154
|
+
if (this.loadSubscription) this.loadSubscription.unsubscribe();
|
|
155
|
+
}
|
|
156
|
+
render() {
|
|
157
|
+
switch(this.state.loadState){
|
|
158
|
+
case "loadError":
|
|
159
|
+
return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $720eceaeeca17272$export$58a097931cd8d64d), {
|
|
160
|
+
error: this.state.error,
|
|
161
|
+
isAuthError: false
|
|
162
|
+
});
|
|
163
|
+
case "authError":
|
|
164
|
+
return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $720eceaeeca17272$export$58a097931cd8d64d), {
|
|
165
|
+
isAuthError: true
|
|
166
|
+
});
|
|
167
|
+
case "loading":
|
|
168
|
+
return /*#__PURE__*/ (0, $7XdDa$jsx)("div", {
|
|
169
|
+
children: "Loading Google Maps API"
|
|
170
|
+
});
|
|
171
|
+
case "loaded":
|
|
172
|
+
return this.props.children(this.state.api) || null;
|
|
173
|
+
default:
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
const $efbce5eedf9afa01$export$be3daefb18c346ac = (0, $7XdDa$styledcomponents).div`
|
|
187
|
+
position: absolute;
|
|
188
|
+
right: 10px;
|
|
189
|
+
top: 10px;
|
|
190
|
+
width: 220px;
|
|
191
|
+
`;
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class $73e82a3e42e8fc6c$export$55d7609a8f1eccd2 extends $7XdDa$PureComponent {
|
|
195
|
+
searchInputRef = /*#__PURE__*/ $7XdDa$createRef();
|
|
196
|
+
handleChange = ()=>{
|
|
197
|
+
if (!this.autoComplete) return;
|
|
198
|
+
this.props.onChange(this.autoComplete.getPlace());
|
|
199
|
+
if (this.searchInputRef.current) this.searchInputRef.current.value = "";
|
|
200
|
+
};
|
|
201
|
+
componentDidMount() {
|
|
202
|
+
const input = this.searchInputRef.current;
|
|
203
|
+
if (!input) return;
|
|
204
|
+
const { api: api , map: map } = this.props;
|
|
205
|
+
const { Circle: Circle , places: places , event: event } = api;
|
|
206
|
+
const searchBounds = new Circle({
|
|
207
|
+
center: map.getCenter(),
|
|
208
|
+
radius: 100
|
|
209
|
+
}).getBounds();
|
|
210
|
+
this.autoComplete = new places.Autocomplete(input, {
|
|
211
|
+
bounds: searchBounds,
|
|
212
|
+
types: []
|
|
213
|
+
});
|
|
214
|
+
event.addListener(this.autoComplete, "place_changed", this.handleChange);
|
|
215
|
+
}
|
|
216
|
+
render() {
|
|
217
|
+
return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $efbce5eedf9afa01$export$be3daefb18c346ac), {
|
|
218
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$TextInput), {
|
|
219
|
+
name: "place",
|
|
220
|
+
ref: this.searchInputRef,
|
|
221
|
+
placeholder: "Search for place or address",
|
|
222
|
+
padding: 4
|
|
223
|
+
})
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
function $0bf72f17fd0ef0c4$export$ad553d4d3a617f20(latLng1, latLng2) {
|
|
232
|
+
const lat1 = typeof latLng1.lat === "function" ? latLng1.lat() : latLng1.lat;
|
|
233
|
+
const lng1 = typeof latLng1.lng === "function" ? latLng1.lng() : latLng1.lng;
|
|
234
|
+
const lat2 = typeof latLng2.lat === "function" ? latLng2.lat() : latLng2.lat;
|
|
235
|
+
const lng2 = typeof latLng2.lng === "function" ? latLng2.lng() : latLng2.lng;
|
|
236
|
+
return lat1 === lat2 && lng1 === lng2;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
const $ad6b04c75b364834$export$23f3dfd47374502b = (0, $7XdDa$styledcomponents).div`
|
|
242
|
+
position: absolute;
|
|
243
|
+
top: 0;
|
|
244
|
+
left: 0;
|
|
245
|
+
height: 100%;
|
|
246
|
+
width: 100%;
|
|
247
|
+
box-sizing: border-box;
|
|
248
|
+
`;
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
class $238e2fa3d9e85b5f$export$4ad1bae46276c5ce extends (0, $7XdDa$react).PureComponent {
|
|
252
|
+
static defaultProps = {
|
|
253
|
+
defaultZoom: 8,
|
|
254
|
+
scrollWheel: true
|
|
255
|
+
};
|
|
256
|
+
state = {
|
|
257
|
+
map: undefined
|
|
258
|
+
};
|
|
259
|
+
mapRef = /*#__PURE__*/ (0, $7XdDa$react).createRef();
|
|
260
|
+
mapEl = null;
|
|
261
|
+
componentDidMount() {
|
|
262
|
+
this.attachClickHandler();
|
|
263
|
+
}
|
|
264
|
+
attachClickHandler = ()=>{
|
|
265
|
+
const map = this.state.map;
|
|
266
|
+
if (!map) return;
|
|
267
|
+
const { api: api , onClick: onClick } = this.props;
|
|
268
|
+
const { event: event } = api;
|
|
269
|
+
if (this.clickHandler) this.clickHandler.remove();
|
|
270
|
+
if (onClick) this.clickHandler = event.addListener(map, "click", onClick);
|
|
271
|
+
};
|
|
272
|
+
componentDidUpdate(prevProps) {
|
|
273
|
+
const map = this.state.map;
|
|
274
|
+
if (!map) return;
|
|
275
|
+
const { onClick: onClick , location: location , bounds: bounds } = this.props;
|
|
276
|
+
if (prevProps.onClick !== onClick) this.attachClickHandler();
|
|
277
|
+
if (!(0, $0bf72f17fd0ef0c4$export$ad553d4d3a617f20)(prevProps.location, location)) map.panTo(this.getCenter());
|
|
278
|
+
if (bounds && (!prevProps.bounds || !bounds.equals(prevProps.bounds))) map.fitBounds(bounds);
|
|
279
|
+
}
|
|
280
|
+
componentWillUnmount() {
|
|
281
|
+
if (this.clickHandler) this.clickHandler.remove();
|
|
282
|
+
}
|
|
283
|
+
getCenter() {
|
|
284
|
+
const { location: location , api: api } = this.props;
|
|
285
|
+
return new api.LatLng(location.lat, location.lng);
|
|
286
|
+
}
|
|
287
|
+
constructMap(el) {
|
|
288
|
+
const { defaultZoom: defaultZoom , api: api , mapTypeControl: mapTypeControl , controlSize: controlSize , bounds: bounds , scrollWheel: scrollWheel } = this.props;
|
|
289
|
+
const map = new api.Map(el, {
|
|
290
|
+
zoom: defaultZoom,
|
|
291
|
+
center: this.getCenter(),
|
|
292
|
+
scrollwheel: scrollWheel,
|
|
293
|
+
streetViewControl: false,
|
|
294
|
+
mapTypeControl: mapTypeControl,
|
|
295
|
+
controlSize: controlSize
|
|
296
|
+
});
|
|
297
|
+
if (bounds) map.fitBounds(bounds);
|
|
298
|
+
return map;
|
|
299
|
+
}
|
|
300
|
+
setMapElement = (element)=>{
|
|
301
|
+
if (element && element !== this.mapEl) {
|
|
302
|
+
const map = this.constructMap(element);
|
|
303
|
+
this.setState({
|
|
304
|
+
map: map
|
|
305
|
+
}, this.attachClickHandler);
|
|
306
|
+
}
|
|
307
|
+
this.mapEl = element;
|
|
308
|
+
};
|
|
309
|
+
render() {
|
|
310
|
+
const { children: children } = this.props;
|
|
311
|
+
const { map: map } = this.state;
|
|
312
|
+
return /*#__PURE__*/ (0, $7XdDa$jsxs)((0, $7XdDa$Fragment), {
|
|
313
|
+
children: [
|
|
314
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)((0, $ad6b04c75b364834$export$23f3dfd47374502b), {
|
|
315
|
+
ref: this.setMapElement
|
|
316
|
+
}),
|
|
317
|
+
children && map ? children(map) : null
|
|
318
|
+
]
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
const $b7b6f34a212b17da$var$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";
|
|
327
|
+
class $b7b6f34a212b17da$export$e98856a975cab58e extends $7XdDa$PureComponent {
|
|
328
|
+
eventHandlers = {};
|
|
329
|
+
componentDidMount() {
|
|
330
|
+
const { position: position , api: api , map: map , onMove: onMove , zIndex: zIndex , opacity: opacity , label: label , markerRef: markerRef , color: color } = this.props;
|
|
331
|
+
const { Marker: GMarker } = api;
|
|
332
|
+
let icon;
|
|
333
|
+
if (color) icon = {
|
|
334
|
+
path: $b7b6f34a212b17da$var$markerPath,
|
|
335
|
+
fillOpacity: 1,
|
|
336
|
+
fillColor: color.background,
|
|
337
|
+
strokeColor: color.border,
|
|
338
|
+
strokeWeight: 2,
|
|
339
|
+
anchor: new api.Point(10, 35),
|
|
340
|
+
labelOrigin: new api.Point(10, 11)
|
|
341
|
+
};
|
|
342
|
+
this.marker = new GMarker({
|
|
343
|
+
draggable: Boolean(onMove),
|
|
344
|
+
position: position,
|
|
345
|
+
map: map,
|
|
346
|
+
zIndex: zIndex,
|
|
347
|
+
opacity: opacity,
|
|
348
|
+
label: label,
|
|
349
|
+
icon: icon
|
|
350
|
+
});
|
|
351
|
+
if (markerRef) markerRef.current = this.marker;
|
|
352
|
+
this.attachMoveHandler();
|
|
353
|
+
this.attachClickHandler();
|
|
354
|
+
}
|
|
355
|
+
componentDidUpdate(prevProps) {
|
|
356
|
+
if (!this.marker) return;
|
|
357
|
+
const { position: position , onMove: onMove , label: label , zIndex: zIndex , opacity: opacity , map: map } = this.props;
|
|
358
|
+
if (prevProps.onMove !== onMove) this.attachMoveHandler();
|
|
359
|
+
if (!(0, $0bf72f17fd0ef0c4$export$ad553d4d3a617f20)(prevProps.position, position)) this.marker.setPosition(position);
|
|
360
|
+
if (prevProps.label !== label) this.marker.setLabel(label || null);
|
|
361
|
+
if (prevProps.zIndex !== zIndex) this.marker.setZIndex(zIndex || null);
|
|
362
|
+
if (prevProps.opacity !== opacity) this.marker.setOpacity(opacity || null);
|
|
363
|
+
if (prevProps.map !== map) this.marker.setMap(map);
|
|
364
|
+
}
|
|
365
|
+
componentWillUnmount() {
|
|
366
|
+
if (this.eventHandlers.move) this.eventHandlers.move.remove();
|
|
367
|
+
if (this.marker) this.marker.setMap(null);
|
|
368
|
+
}
|
|
369
|
+
attachMoveHandler() {
|
|
370
|
+
const { api: api , onMove: onMove } = this.props;
|
|
371
|
+
if (this.eventHandlers.move) this.eventHandlers.move.remove();
|
|
372
|
+
if (this.marker && onMove) this.eventHandlers.move = api.event.addListener(this.marker, "dragend", onMove);
|
|
373
|
+
}
|
|
374
|
+
attachClickHandler() {
|
|
375
|
+
const { api: api , onClick: onClick } = this.props;
|
|
376
|
+
if (this.eventHandlers.click) this.eventHandlers.click.remove();
|
|
377
|
+
if (this.marker && onClick) this.eventHandlers.click = api.event.addListener(this.marker, "click", onClick);
|
|
378
|
+
}
|
|
379
|
+
// eslint-disable-next-line class-methods-use-this
|
|
380
|
+
render() {
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
const $154571ab11e62bfc$var$fallbackLatLng = {
|
|
387
|
+
lat: 40.7058254,
|
|
388
|
+
lng: -74.1180863
|
|
389
|
+
};
|
|
390
|
+
class $154571ab11e62bfc$export$9a2476e65b6b92a7 extends (0, $7XdDa$react).PureComponent {
|
|
391
|
+
static defaultProps = {
|
|
392
|
+
defaultZoom: 8,
|
|
393
|
+
defaultLocation: {
|
|
394
|
+
lng: 10.74609,
|
|
395
|
+
lat: 59.91273
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
mapRef = /*#__PURE__*/ (0, $7XdDa$react).createRef();
|
|
399
|
+
getCenter() {
|
|
400
|
+
const { value: value = {} , defaultLocation: defaultLocation = {} } = this.props;
|
|
401
|
+
const point = {
|
|
402
|
+
...$154571ab11e62bfc$var$fallbackLatLng,
|
|
403
|
+
...defaultLocation,
|
|
404
|
+
...value
|
|
405
|
+
};
|
|
406
|
+
return point;
|
|
407
|
+
}
|
|
408
|
+
handlePlaceChanged = (place)=>{
|
|
409
|
+
if (!place.geometry?.location) return;
|
|
410
|
+
this.setValue(place.geometry.location);
|
|
411
|
+
};
|
|
412
|
+
handleMarkerDragEnd = (event)=>{
|
|
413
|
+
if (event.latLng) this.setValue(event.latLng);
|
|
414
|
+
};
|
|
415
|
+
handleMapClick = (event)=>{
|
|
416
|
+
if (event.latLng) this.setValue(event.latLng);
|
|
417
|
+
};
|
|
418
|
+
setValue(geoPoint) {
|
|
419
|
+
if (this.props.onChange) this.props.onChange(geoPoint);
|
|
420
|
+
}
|
|
421
|
+
render() {
|
|
422
|
+
const { api: api , defaultZoom: defaultZoom , value: value , onChange: onChange } = this.props;
|
|
423
|
+
return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $238e2fa3d9e85b5f$export$4ad1bae46276c5ce), {
|
|
424
|
+
api: api,
|
|
425
|
+
location: this.getCenter(),
|
|
426
|
+
onClick: this.handleMapClick,
|
|
427
|
+
defaultZoom: defaultZoom,
|
|
428
|
+
children: (map)=>/*#__PURE__*/ (0, $7XdDa$jsxs)((0, $7XdDa$Fragment), {
|
|
429
|
+
children: [
|
|
430
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)((0, $73e82a3e42e8fc6c$export$55d7609a8f1eccd2), {
|
|
431
|
+
api: api,
|
|
432
|
+
map: map,
|
|
433
|
+
onChange: this.handlePlaceChanged
|
|
434
|
+
}),
|
|
435
|
+
value && /*#__PURE__*/ (0, $7XdDa$jsx)((0, $b7b6f34a212b17da$export$e98856a975cab58e), {
|
|
436
|
+
api: api,
|
|
437
|
+
map: map,
|
|
438
|
+
position: value,
|
|
439
|
+
onMove: onChange ? this.handleMarkerDragEnd : undefined
|
|
440
|
+
})
|
|
441
|
+
]
|
|
442
|
+
})
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
const $8e8668abdcaeab13$export$1c4ad7c095d42d37 = (0, $7XdDa$styledcomponents).img`
|
|
450
|
+
width: 100%;
|
|
451
|
+
height: auto;
|
|
452
|
+
vertical-align: top;
|
|
453
|
+
`;
|
|
454
|
+
const $8e8668abdcaeab13$export$ffa61c425f593078 = (0, $7XdDa$styledcomponents).div`
|
|
455
|
+
height: 40rem;
|
|
456
|
+
width: 50rem;
|
|
457
|
+
`;
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
let $df916f7ad083efd6$var$config;
|
|
461
|
+
function $df916f7ad083efd6$export$ee3fba7cd2f8c355() {
|
|
462
|
+
return $df916f7ad083efd6$var$config;
|
|
463
|
+
}
|
|
464
|
+
function $df916f7ad083efd6$export$a9c6c3563e9053d(newConfig) {
|
|
465
|
+
$df916f7ad083efd6$var$config = newConfig;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
const $aae6ff17d8424da8$var$getStaticImageUrl = (value, apiKey)=>{
|
|
470
|
+
const loc = `${value.lat},${value.lng}`;
|
|
471
|
+
const params = {
|
|
472
|
+
key: apiKey,
|
|
473
|
+
center: loc,
|
|
474
|
+
markers: loc,
|
|
475
|
+
zoom: 13,
|
|
476
|
+
scale: 2,
|
|
477
|
+
size: "640x300"
|
|
478
|
+
};
|
|
479
|
+
const qs = Object.keys(params).reduce((res, param)=>{
|
|
480
|
+
return res.concat(`${param}=${encodeURIComponent(params[param])}`);
|
|
481
|
+
}, []);
|
|
482
|
+
return `https://maps.googleapis.com/maps/api/staticmap?${qs.join("&")}`;
|
|
483
|
+
};
|
|
484
|
+
class $aae6ff17d8424da8$var$GeopointInput extends (0, $7XdDa$react).PureComponent {
|
|
485
|
+
_geopointInputId = (0, $7XdDa$uniqueId)("GeopointInput");
|
|
486
|
+
constructor(props){
|
|
487
|
+
super(props);
|
|
488
|
+
this.state = {
|
|
489
|
+
modalOpen: false
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
setEditButton = (el)=>{
|
|
493
|
+
this.editButton = el;
|
|
494
|
+
};
|
|
495
|
+
focus() {
|
|
496
|
+
if (this.editButton) this.editButton.focus();
|
|
497
|
+
}
|
|
498
|
+
handleToggleModal = ()=>{
|
|
499
|
+
this.setState((prevState)=>({
|
|
500
|
+
modalOpen: !prevState.modalOpen
|
|
501
|
+
}));
|
|
502
|
+
};
|
|
503
|
+
handleCloseModal = ()=>{
|
|
504
|
+
this.setState({
|
|
505
|
+
modalOpen: false
|
|
506
|
+
});
|
|
507
|
+
};
|
|
508
|
+
handleChange = (latLng)=>{
|
|
509
|
+
const { schemaType: schemaType , onChange: onChange } = this.props;
|
|
510
|
+
onChange([
|
|
511
|
+
(0, $7XdDa$setIfMissing)({
|
|
512
|
+
_type: schemaType.name
|
|
513
|
+
}),
|
|
514
|
+
(0, $7XdDa$set)(latLng.lat(), [
|
|
515
|
+
"lat"
|
|
516
|
+
]),
|
|
517
|
+
(0, $7XdDa$set)(latLng.lng(), [
|
|
518
|
+
"lng"
|
|
519
|
+
]),
|
|
520
|
+
]);
|
|
521
|
+
};
|
|
522
|
+
handleClear = ()=>{
|
|
523
|
+
const { onChange: onChange } = this.props;
|
|
524
|
+
onChange((0, $7XdDa$unset)());
|
|
525
|
+
};
|
|
526
|
+
render() {
|
|
527
|
+
const { value: value , readOnly: readOnly , compareValue: compareValue , geoConfig: config } = this.props;
|
|
528
|
+
const { modalOpen: modalOpen } = this.state;
|
|
529
|
+
if (!config || !config.apiKey) return /*#__PURE__*/ (0, $7XdDa$jsxs)("div", {
|
|
530
|
+
children: [
|
|
531
|
+
/*#__PURE__*/ (0, $7XdDa$jsxs)("p", {
|
|
532
|
+
children: [
|
|
533
|
+
"The ",
|
|
534
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("a", {
|
|
535
|
+
href: "https://sanity.io/docs/schema-types/geopoint-type",
|
|
536
|
+
children: "Geopoint type"
|
|
537
|
+
}),
|
|
538
|
+
" needs a Google Maps API key with access to:"
|
|
539
|
+
]
|
|
540
|
+
}),
|
|
541
|
+
/*#__PURE__*/ (0, $7XdDa$jsxs)("ul", {
|
|
542
|
+
children: [
|
|
543
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("li", {
|
|
544
|
+
children: "Google Maps JavaScript API"
|
|
545
|
+
}),
|
|
546
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("li", {
|
|
547
|
+
children: "Google Places API Web Service"
|
|
548
|
+
}),
|
|
549
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("li", {
|
|
550
|
+
children: "Google Static Maps API"
|
|
551
|
+
})
|
|
552
|
+
]
|
|
553
|
+
}),
|
|
554
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("p", {
|
|
555
|
+
children: "Please enter the API key with access to these services in your googleMapsInput plugin config."
|
|
556
|
+
})
|
|
557
|
+
]
|
|
558
|
+
});
|
|
559
|
+
return /*#__PURE__*/ (0, $7XdDa$jsxs)((0, $7XdDa$Fragment), {
|
|
560
|
+
children: [
|
|
561
|
+
value && /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$ChangeIndicatorCompareValueProvider), {
|
|
562
|
+
value: value,
|
|
563
|
+
compareValue: compareValue,
|
|
564
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$ChangeIndicator), {
|
|
565
|
+
compareDeep: true,
|
|
566
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)((0, $8e8668abdcaeab13$export$1c4ad7c095d42d37), {
|
|
567
|
+
src: $aae6ff17d8424da8$var$getStaticImageUrl(value, config.apiKey),
|
|
568
|
+
alt: "Map location"
|
|
569
|
+
})
|
|
570
|
+
})
|
|
571
|
+
}),
|
|
572
|
+
!readOnly && /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Box), {
|
|
573
|
+
marginTop: 4,
|
|
574
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsxs)((0, $7XdDa$Grid), {
|
|
575
|
+
columns: 2,
|
|
576
|
+
gap: 2,
|
|
577
|
+
children: [
|
|
578
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Button), {
|
|
579
|
+
mode: "ghost",
|
|
580
|
+
icon: value && (0, $7XdDa$EditIcon),
|
|
581
|
+
padding: 3,
|
|
582
|
+
ref: this.setEditButton,
|
|
583
|
+
text: value ? "Edit" : "Set location",
|
|
584
|
+
onClick: this.handleToggleModal
|
|
585
|
+
}),
|
|
586
|
+
value && /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Button), {
|
|
587
|
+
tone: "critical",
|
|
588
|
+
icon: (0, $7XdDa$TrashIcon),
|
|
589
|
+
padding: 3,
|
|
590
|
+
mode: "ghost",
|
|
591
|
+
text: "Remove",
|
|
592
|
+
onClick: this.handleClear
|
|
593
|
+
})
|
|
594
|
+
]
|
|
595
|
+
})
|
|
596
|
+
}),
|
|
597
|
+
modalOpen && /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Dialog), {
|
|
598
|
+
id: `${this._geopointInputId}_dialog`,
|
|
599
|
+
onClose: this.handleCloseModal,
|
|
600
|
+
header: "Place the marker on the map",
|
|
601
|
+
width: 1,
|
|
602
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)((0, $8e8668abdcaeab13$export$ffa61c425f593078), {
|
|
603
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)((0, $004c8002f57d3835$export$a628545bcf173896), {
|
|
604
|
+
config: (0, $df916f7ad083efd6$export$ee3fba7cd2f8c355)(),
|
|
605
|
+
children: (api)=>/*#__PURE__*/ (0, $7XdDa$jsx)((0, $154571ab11e62bfc$export$9a2476e65b6b92a7), {
|
|
606
|
+
api: api,
|
|
607
|
+
value: value || undefined,
|
|
608
|
+
onChange: readOnly ? undefined : this.handleChange,
|
|
609
|
+
defaultLocation: config.defaultLocation,
|
|
610
|
+
defaultZoom: config.defaultZoom
|
|
611
|
+
})
|
|
612
|
+
})
|
|
613
|
+
})
|
|
614
|
+
})
|
|
615
|
+
]
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
var $aae6ff17d8424da8$export$2e2bcd8739ae039 = $aae6ff17d8424da8$var$GeopointInput;
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
class $d97751f0fd202e1b$export$21b07c8f274aebd5 extends $7XdDa$PureComponent {
|
|
634
|
+
eventHandlers = {};
|
|
635
|
+
componentDidMount() {
|
|
636
|
+
const { from: from , to: to , api: api , map: map , zIndex: zIndex , onClick: onClick , color: color , arrowRef: arrowRef } = this.props;
|
|
637
|
+
const lineSymbol = {
|
|
638
|
+
path: api.SymbolPath.FORWARD_OPEN_ARROW
|
|
639
|
+
};
|
|
640
|
+
this.line = new api.Polyline({
|
|
641
|
+
map: map,
|
|
642
|
+
zIndex: zIndex,
|
|
643
|
+
path: [
|
|
644
|
+
from,
|
|
645
|
+
to
|
|
646
|
+
],
|
|
647
|
+
icons: [
|
|
648
|
+
{
|
|
649
|
+
icon: lineSymbol,
|
|
650
|
+
offset: "50%"
|
|
651
|
+
}
|
|
652
|
+
],
|
|
653
|
+
strokeOpacity: 0.55,
|
|
654
|
+
strokeColor: color ? color.text : "black"
|
|
655
|
+
});
|
|
656
|
+
if (onClick) this.eventHandlers.click = api.event.addListener(this.line, "click", onClick);
|
|
657
|
+
if (arrowRef) arrowRef.current = this.line;
|
|
658
|
+
}
|
|
659
|
+
componentDidUpdate(prevProps) {
|
|
660
|
+
if (!this.line) return;
|
|
661
|
+
const { from: from , to: to , map: map } = this.props;
|
|
662
|
+
if (!(0, $0bf72f17fd0ef0c4$export$ad553d4d3a617f20)(prevProps.from, from) || !(0, $0bf72f17fd0ef0c4$export$ad553d4d3a617f20)(prevProps.to, to)) this.line.setPath([
|
|
663
|
+
from,
|
|
664
|
+
to
|
|
665
|
+
]);
|
|
666
|
+
if (prevProps.map !== map) this.line.setMap(map);
|
|
667
|
+
}
|
|
668
|
+
componentWillUnmount() {
|
|
669
|
+
if (this.line) this.line.setMap(null);
|
|
670
|
+
if (this.eventHandlers.click) this.eventHandlers.click.remove();
|
|
671
|
+
}
|
|
672
|
+
// eslint-disable-next-line class-methods-use-this
|
|
673
|
+
render() {
|
|
674
|
+
return null;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
function $d0ad603c81d3eea8$export$f432217b31ec4a77({ diff: diff , api: api , map: map , label: label }) {
|
|
680
|
+
const { fromValue: from , toValue: to } = diff;
|
|
681
|
+
const annotation = diff.isChanged ? diff.annotation : undefined;
|
|
682
|
+
const userColor = (0, $7XdDa$useUserColor)(annotation ? annotation.author : null) || undefined;
|
|
683
|
+
const fromRef = $7XdDa$useRef();
|
|
684
|
+
const toRef = $7XdDa$useRef();
|
|
685
|
+
return /*#__PURE__*/ (0, $7XdDa$jsxs)((0, $7XdDa$Fragment), {
|
|
686
|
+
children: [
|
|
687
|
+
from && /*#__PURE__*/ (0, $7XdDa$jsx)((0, $b7b6f34a212b17da$export$e98856a975cab58e), {
|
|
688
|
+
api: api,
|
|
689
|
+
map: map,
|
|
690
|
+
position: from,
|
|
691
|
+
zIndex: 0,
|
|
692
|
+
opacity: 0.55,
|
|
693
|
+
markerRef: fromRef,
|
|
694
|
+
color: userColor
|
|
695
|
+
}),
|
|
696
|
+
from && to && /*#__PURE__*/ (0, $7XdDa$jsx)((0, $d97751f0fd202e1b$export$21b07c8f274aebd5), {
|
|
697
|
+
api: api,
|
|
698
|
+
map: map,
|
|
699
|
+
from: from,
|
|
700
|
+
to: to,
|
|
701
|
+
zIndex: 1,
|
|
702
|
+
color: userColor
|
|
703
|
+
}),
|
|
704
|
+
to && /*#__PURE__*/ (0, $7XdDa$jsx)((0, $b7b6f34a212b17da$export$e98856a975cab58e), {
|
|
705
|
+
api: api,
|
|
706
|
+
map: map,
|
|
707
|
+
position: to,
|
|
708
|
+
zIndex: 2,
|
|
709
|
+
markerRef: toRef,
|
|
710
|
+
label: label,
|
|
711
|
+
color: userColor
|
|
712
|
+
})
|
|
713
|
+
]
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
const $9aeb4640a3d1c536$export$35b4f62b8f8d707c = (0, $7XdDa$styledcomponents).div`
|
|
720
|
+
position: relative;
|
|
721
|
+
min-height: 200px;
|
|
722
|
+
|
|
723
|
+
&:empty {
|
|
724
|
+
background-color: var(--card-skeleton-color-from);
|
|
725
|
+
display: table;
|
|
726
|
+
width: 100%;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
&:empty:after {
|
|
730
|
+
content: 'Missing/invalid data';
|
|
731
|
+
display: table-cell;
|
|
732
|
+
vertical-align: middle;
|
|
733
|
+
text-align: center;
|
|
734
|
+
position: relative;
|
|
735
|
+
}
|
|
736
|
+
`;
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
const $0b61abf3d6e295b1$export$2d0695678527b4cc = ({ diff: diff , schemaType: schemaType })=>{
|
|
741
|
+
return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $9aeb4640a3d1c536$export$35b4f62b8f8d707c), {
|
|
742
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)((0, $004c8002f57d3835$export$a628545bcf173896), {
|
|
743
|
+
config: (0, $df916f7ad083efd6$export$ee3fba7cd2f8c355)(),
|
|
744
|
+
children: (api)=>/*#__PURE__*/ (0, $7XdDa$jsx)($0b61abf3d6e295b1$var$GeopointDiff, {
|
|
745
|
+
api: api,
|
|
746
|
+
diff: diff,
|
|
747
|
+
schemaType: schemaType
|
|
748
|
+
})
|
|
749
|
+
})
|
|
750
|
+
});
|
|
751
|
+
};
|
|
752
|
+
function $0b61abf3d6e295b1$var$GeopointDiff({ api: api , diff: diff }) {
|
|
753
|
+
const fromValue = (diff.fromValue || []).filter($0b61abf3d6e295b1$var$hasCoordinates);
|
|
754
|
+
const toValue = (diff.toValue || []).filter($0b61abf3d6e295b1$var$hasCoordinates);
|
|
755
|
+
if (fromValue.length === 0 && toValue.length === 0) return null;
|
|
756
|
+
const bounds = $0b61abf3d6e295b1$var$getBounds(fromValue, toValue, api);
|
|
757
|
+
return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $238e2fa3d9e85b5f$export$4ad1bae46276c5ce), {
|
|
758
|
+
api: api,
|
|
759
|
+
location: bounds.getCenter().toJSON(),
|
|
760
|
+
mapTypeControl: false,
|
|
761
|
+
controlSize: 20,
|
|
762
|
+
bounds: bounds,
|
|
763
|
+
children: (map)=>/*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Fragment), {
|
|
764
|
+
children: diff.items.map(({ toIndex: toIndex , diff: pointDiff })=>{
|
|
765
|
+
if (!$0b61abf3d6e295b1$var$isChangeDiff(pointDiff)) return null;
|
|
766
|
+
return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $d0ad603c81d3eea8$export$f432217b31ec4a77), {
|
|
767
|
+
api: api,
|
|
768
|
+
map: map,
|
|
769
|
+
diff: pointDiff,
|
|
770
|
+
label: `${toIndex}`
|
|
771
|
+
}, toIndex);
|
|
772
|
+
})
|
|
773
|
+
})
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
function $0b61abf3d6e295b1$var$isChangeDiff(diff) {
|
|
777
|
+
return diff.action !== "unchanged" && diff.type === "object";
|
|
778
|
+
}
|
|
779
|
+
function $0b61abf3d6e295b1$var$hasCoordinates(point) {
|
|
780
|
+
return typeof point.lat === "number" && typeof point.lng === "number";
|
|
781
|
+
}
|
|
782
|
+
function $0b61abf3d6e295b1$var$getBounds(fromValue, toValue, api) {
|
|
783
|
+
const bounds = new api.LatLngBounds();
|
|
784
|
+
const points = [
|
|
785
|
+
...fromValue || [],
|
|
786
|
+
...toValue || []
|
|
787
|
+
];
|
|
788
|
+
points.forEach((point)=>bounds.extend(point));
|
|
789
|
+
return bounds;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
const $f98f019473805f47$export$6b7bf6aeccd8ac3f = ({ diff: diff , schemaType: schemaType })=>{
|
|
802
|
+
return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $9aeb4640a3d1c536$export$35b4f62b8f8d707c), {
|
|
803
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)((0, $004c8002f57d3835$export$a628545bcf173896), {
|
|
804
|
+
config: (0, $df916f7ad083efd6$export$ee3fba7cd2f8c355)(),
|
|
805
|
+
children: (api)=>/*#__PURE__*/ (0, $7XdDa$jsx)($f98f019473805f47$var$GeopointDiff, {
|
|
806
|
+
api: api,
|
|
807
|
+
diff: diff,
|
|
808
|
+
schemaType: schemaType
|
|
809
|
+
})
|
|
810
|
+
})
|
|
811
|
+
});
|
|
812
|
+
};
|
|
813
|
+
function $f98f019473805f47$var$GeopointDiff({ api: api , diff: diff }) {
|
|
814
|
+
const { fromValue: fromValue , toValue: toValue } = diff;
|
|
815
|
+
const annotation = (0, $7XdDa$getAnnotationAtPath)(diff, [
|
|
816
|
+
"lat"
|
|
817
|
+
]) || (0, $7XdDa$getAnnotationAtPath)(diff, [
|
|
818
|
+
"lng"
|
|
819
|
+
]) || (0, $7XdDa$getAnnotationAtPath)(diff, []);
|
|
820
|
+
const center = $f98f019473805f47$var$getCenter(diff, api);
|
|
821
|
+
const bounds = fromValue && toValue ? $f98f019473805f47$var$getBounds(fromValue, toValue, api) : undefined;
|
|
822
|
+
return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$DiffTooltip), {
|
|
823
|
+
annotations: annotation ? [
|
|
824
|
+
annotation
|
|
825
|
+
] : [],
|
|
826
|
+
description: $f98f019473805f47$var$getAction(diff),
|
|
827
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)("div", {
|
|
828
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)((0, $238e2fa3d9e85b5f$export$4ad1bae46276c5ce), {
|
|
829
|
+
api: api,
|
|
830
|
+
location: center,
|
|
831
|
+
mapTypeControl: false,
|
|
832
|
+
controlSize: 20,
|
|
833
|
+
bounds: bounds,
|
|
834
|
+
scrollWheel: false,
|
|
835
|
+
children: (map)=>/*#__PURE__*/ (0, $7XdDa$jsx)((0, $d0ad603c81d3eea8$export$f432217b31ec4a77), {
|
|
836
|
+
api: api,
|
|
837
|
+
map: map,
|
|
838
|
+
diff: diff
|
|
839
|
+
})
|
|
840
|
+
})
|
|
841
|
+
})
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
function $f98f019473805f47$var$getBounds(fromValue, toValue, api) {
|
|
845
|
+
return new api.LatLngBounds().extend(fromValue).extend(toValue);
|
|
846
|
+
}
|
|
847
|
+
function $f98f019473805f47$var$getCenter(diff, api) {
|
|
848
|
+
const { fromValue: fromValue , toValue: toValue } = diff;
|
|
849
|
+
if (fromValue && toValue) return $f98f019473805f47$var$getBounds(fromValue, toValue, api).getCenter().toJSON();
|
|
850
|
+
if (fromValue) return fromValue;
|
|
851
|
+
if (toValue) return toValue;
|
|
852
|
+
throw new Error("Neither a from or a to value present");
|
|
853
|
+
}
|
|
854
|
+
function $f98f019473805f47$var$getAction(diff) {
|
|
855
|
+
const { fromValue: fromValue , toValue: toValue } = diff;
|
|
856
|
+
if (fromValue && toValue) return "Moved";
|
|
857
|
+
else if (fromValue) return "Removed";
|
|
858
|
+
else if (toValue) return "Added";
|
|
859
|
+
return "Unchanged";
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
const $357f50a17451fe9f$export$626ae7d0cf8f9143 = (0, $7XdDa$createPlugin)((config)=>{
|
|
864
|
+
(0, $df916f7ad083efd6$export$a9c6c3563e9053d)(config);
|
|
865
|
+
return {
|
|
866
|
+
name: "google-maps-input",
|
|
867
|
+
form: {
|
|
868
|
+
renderInput: (props)=>{
|
|
869
|
+
if ($357f50a17451fe9f$var$isGeopoint(props.schemaType)) {
|
|
870
|
+
const castedProps = props;
|
|
871
|
+
return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $aae6ff17d8424da8$export$2e2bcd8739ae039), {
|
|
872
|
+
...castedProps,
|
|
873
|
+
geoConfig: config
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
return undefined;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
});
|
|
881
|
+
function $357f50a17451fe9f$var$isGeopoint(schemaType) {
|
|
882
|
+
return $357f50a17451fe9f$var$isType("geopoint", schemaType);
|
|
883
|
+
}
|
|
884
|
+
function $357f50a17451fe9f$var$isType(name, schema) {
|
|
885
|
+
if (schema?.name === name) return true;
|
|
886
|
+
else if (!schema?.name) return false;
|
|
887
|
+
return $357f50a17451fe9f$var$isType(name, schema?.type);
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
export {$357f50a17451fe9f$export$626ae7d0cf8f9143 as googleMapsInput, $0b61abf3d6e295b1$export$2d0695678527b4cc as GeopointArrayDiff, $f98f019473805f47$export$6b7bf6aeccd8ac3f as GeopointFieldDiff, $aae6ff17d8424da8$export$2e2bcd8739ae039 as GeopointInput};
|
|
892
|
+
//# sourceMappingURL=index.js.map
|