@object-ui/plugin-map 17.3.0 → 17.6.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/CHANGELOG.md +490 -0
- package/README.md +144 -243
- package/dist/ObjectMap.d.ts +18 -3
- package/dist/ObjectMap.d.ts.map +1 -1
- package/dist/camera.d.ts +102 -0
- package/dist/camera.d.ts.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +271 -204
- package/dist/index.umd.cjs +1 -1
- package/package.json +12 -11
package/dist/index.js
CHANGED
|
@@ -1,24 +1,44 @@
|
|
|
1
1
|
import { useCallback as e, useEffect as t, useMemo as n, useRef as r, useState as i } from "react";
|
|
2
|
-
import { ComponentRegistry as a, buildExpandFields as o,
|
|
3
|
-
import { useNavigationOverlay as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
2
|
+
import { ComponentRegistry as a, buildExpandFields as o, convertSortToQueryParams as s, extractRecords as c, getRecordDisplayName as ee } from "@object-ui/core";
|
|
3
|
+
import { ElementDataSourceGate as l, useNavigationOverlay as te, useSchemaContext as u } from "@object-ui/react";
|
|
4
|
+
import { ObjectMapConfigSchema as d } from "@object-ui/types/zod";
|
|
5
|
+
import { NavigationOverlay as ne, cn as f, useIsMobile as re } from "@object-ui/components";
|
|
6
|
+
import ie, { Marker as p, NavigationControl as ae, Popup as oe } from "react-map-gl/maplibre";
|
|
7
7
|
import "maplibre-gl/dist/maplibre-gl.css";
|
|
8
|
-
import { jsx as
|
|
9
|
-
//#region src/ObjectMap.tsx
|
|
10
|
-
var h = u.object({
|
|
11
|
-
latitudeField: u.string().optional(),
|
|
12
|
-
longitudeField: u.string().optional(),
|
|
13
|
-
locationField: u.string().optional(),
|
|
14
|
-
titleField: u.string().optional(),
|
|
15
|
-
descriptionField: u.string().optional(),
|
|
16
|
-
zoom: u.number().optional(),
|
|
17
|
-
center: u.tuple([u.number(), u.number()]).optional(),
|
|
18
|
-
style: u.string().optional()
|
|
19
|
-
}), ae = "https://demotiles.maplibre.org/style.json";
|
|
8
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
20
9
|
function g(e) {
|
|
21
|
-
return e
|
|
10
|
+
return e >= -180 && e < 180 ? e : ((e + 180) % 360 + 360) % 360 - 180;
|
|
11
|
+
}
|
|
12
|
+
var _ = (e) => Math.min(85, Math.max(-85, e));
|
|
13
|
+
function se(e) {
|
|
14
|
+
if (e.length === 0) return null;
|
|
15
|
+
let t = e.map(([e]) => g(e)).sort((e, t) => e - t), n = e.map(([, e]) => _(e)), r = t.length, i = t[0] + 360 - t[r - 1], a = 0;
|
|
16
|
+
for (let e = 1; e < r; e++) {
|
|
17
|
+
let n = t[e] - t[e - 1];
|
|
18
|
+
n > i && (i = n, a = e);
|
|
19
|
+
}
|
|
20
|
+
let o = t[a], s = t[(a + r - 1) % r], c = a === 0 ? s : s + 360;
|
|
21
|
+
return [[o, Math.min(...n)], [c, Math.max(...n)]];
|
|
22
|
+
}
|
|
23
|
+
function ce(e) {
|
|
24
|
+
let [[t, n], [r, i]] = e;
|
|
25
|
+
return {
|
|
26
|
+
longitude: g((t + r) / 2),
|
|
27
|
+
latitude: (n + i) / 2
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/ObjectMap.tsx
|
|
32
|
+
var le = "https://demotiles.maplibre.org/style.json", v = Object.keys(d.shape).filter((e) => e !== "style");
|
|
33
|
+
function ue(e) {
|
|
34
|
+
if (e.data) {
|
|
35
|
+
let t = e.data;
|
|
36
|
+
return Array.isArray(t) ? {
|
|
37
|
+
provider: "value",
|
|
38
|
+
items: t
|
|
39
|
+
} : e.data;
|
|
40
|
+
}
|
|
41
|
+
return e.staticData ? {
|
|
22
42
|
provider: "value",
|
|
23
43
|
items: e.staticData
|
|
24
44
|
} : e.objectName ? {
|
|
@@ -26,47 +46,65 @@ function g(e) {
|
|
|
26
46
|
object: e.objectName
|
|
27
47
|
} : null;
|
|
28
48
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
49
|
+
var y = () => globalThis.process?.env?.NODE_ENV !== "production", b = /* @__PURE__ */ new Set();
|
|
50
|
+
function x(e) {
|
|
51
|
+
if (!y()) return;
|
|
52
|
+
let t = e.filter;
|
|
53
|
+
if (!t || typeof t != "object" || Array.isArray(t) || !Object.prototype.hasOwnProperty.call(t, "map")) return;
|
|
54
|
+
let n = t.map;
|
|
55
|
+
if (!n || typeof n != "object") return;
|
|
56
|
+
let r;
|
|
57
|
+
try {
|
|
58
|
+
r = `${e.type ?? "map"}::${e.objectName ?? ""}::${JSON.stringify(n)}`;
|
|
59
|
+
} catch {
|
|
60
|
+
r = `${e.type ?? "map"}::${e.objectName ?? ""}::<unserializable>`;
|
|
36
61
|
}
|
|
62
|
+
b.has(r) || (b.add(r), console.warn("[ObjectMap] `filter.map` is no longer read as map configuration, so this map is rendering with the DEFAULT field names (`latitude` / `longitude` / `name`). `filter` is the query filter; the map config belongs under the declared `map` input — move it to `schema.map` (`{ type: 'object-map', map: { latitudeField, longitudeField, titleField } }`). The old spelling was never documented and could not survive a `dataSource` binding, whose merged filter is an `and` node with no `map` key at all (objectstack#7121). If `map` is genuinely a field you are filtering on, ignore this — the filter itself is passed through untouched. objectui#4034."));
|
|
63
|
+
}
|
|
64
|
+
var S = /* @__PURE__ */ new Set();
|
|
65
|
+
function C(e) {
|
|
66
|
+
if (!y()) return;
|
|
67
|
+
let t = e.style;
|
|
68
|
+
if (typeof t != "string" || t === "") return;
|
|
69
|
+
let n = `${e.type ?? "map"}::${e.objectName ?? ""}::${t}`;
|
|
70
|
+
S.has(n) || (S.add(n), console.warn(`[ObjectMap] A top-level \`style\` is NOT read as a map style, so this map is rendering with the DEFAULT public demo tiles and \`${t}\` was dropped. \`style\` is the base schema's INLINE CSS key (a record of CSS properties), which every node may carry; the map style is \`mapStyle\` — named that way precisely to avoid this collision. Write \`mapStyle: '${t}'\` at the top level, or \`map: { style: '${t}' }\` in the declared config block. On a view, note that \`options.map\` is FLATTENED into the top level, so its \`style\` lands here as this same top-level key — spell it \`map: { mapStyle }\` there. objectui#5017.`));
|
|
37
71
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (
|
|
72
|
+
var w = /* @__PURE__ */ new Set();
|
|
73
|
+
function T(e) {
|
|
74
|
+
if (!y()) return;
|
|
75
|
+
let t = v.filter((t) => e[t] !== void 0);
|
|
76
|
+
if (t.length === 0) return;
|
|
77
|
+
let n = `${e.type ?? "map"}::${e.objectName ?? ""}::${t.join(",")}`;
|
|
78
|
+
w.has(n) || (w.add(n), console.warn(`[ObjectMap] The \`map\` block configures this map, so these top-level keys are IGNORED: ${t.map((e) => `\`${e}\``).join(", ")}. The \`map\` block is the authoring shape; the flat top-level spelling is the internal form ObjectView/ListView produce when they flatten \`options.map\`, and what the author wrote outranks it. Move anything you still need into \`map\`, or drop the \`map\` block. objectui#5018.`));
|
|
79
|
+
}
|
|
80
|
+
function de(e) {
|
|
81
|
+
x(e), C(e);
|
|
82
|
+
let t = e.mapStyle || e.map?.style, n = e.map ?? null;
|
|
83
|
+
if (n) {
|
|
84
|
+
let r = d.safeParse(n);
|
|
85
|
+
return r.success || console.warn("[ObjectMap] Invalid map configuration:", r.error.format()), T(e), {
|
|
86
|
+
...n,
|
|
87
|
+
style: n.style || t
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return e.locationField || e.latitudeField ? {
|
|
41
91
|
locationField: e.locationField,
|
|
42
92
|
latitudeField: e.latitudeField,
|
|
43
93
|
longitudeField: e.longitudeField,
|
|
44
|
-
titleField: e.titleField
|
|
94
|
+
titleField: e.titleField,
|
|
45
95
|
descriptionField: e.descriptionField,
|
|
46
96
|
zoom: e.zoom,
|
|
47
97
|
center: e.center,
|
|
48
98
|
style: t
|
|
49
|
-
}
|
|
50
|
-
let n = null;
|
|
51
|
-
if (e.filter && typeof e.filter == "object" && "map" in e.filter ? n = e.filter.map : e.map && (n = e.map), n) {
|
|
52
|
-
let e = h.safeParse(n);
|
|
53
|
-
return e.success || console.warn("[ObjectMap] Invalid map configuration:", e.error.format()), {
|
|
54
|
-
...n,
|
|
55
|
-
style: n.style || t
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
99
|
+
} : {
|
|
59
100
|
latitudeField: "latitude",
|
|
60
101
|
longitudeField: "longitude",
|
|
61
102
|
locationField: "location",
|
|
62
|
-
titleField: "name",
|
|
63
103
|
descriptionField: "description",
|
|
64
|
-
zoom: 10,
|
|
65
|
-
center: [0, 0],
|
|
66
104
|
style: t
|
|
67
105
|
};
|
|
68
106
|
}
|
|
69
|
-
function
|
|
107
|
+
function fe(e, t) {
|
|
70
108
|
if (t.latitudeField && t.longitudeField) {
|
|
71
109
|
let n = e[t.latitudeField], r = e[t.longitudeField];
|
|
72
110
|
if (typeof n == "number" && typeof r == "number") return [n, r];
|
|
@@ -88,7 +126,7 @@ function v(e, t) {
|
|
|
88
126
|
}
|
|
89
127
|
return null;
|
|
90
128
|
}
|
|
91
|
-
function
|
|
129
|
+
function pe(e, t, n = 50) {
|
|
92
130
|
if (e.length <= 1 || t >= 15) return e.map((e) => ({
|
|
93
131
|
id: e.id,
|
|
94
132
|
coordinates: e.coordinates,
|
|
@@ -119,102 +157,96 @@ function se(e, t, n = 50) {
|
|
|
119
157
|
}
|
|
120
158
|
}), a;
|
|
121
159
|
}
|
|
122
|
-
var
|
|
123
|
-
let [
|
|
124
|
-
|
|
125
|
-
}, []),
|
|
160
|
+
var E = ({ schema: a, dataSource: l, className: u, data: d, onMarkerClick: g, onRowClick: _, onEdit: v, onDelete: y, enableClustering: b, clusterRadius: x = 50 }) => {
|
|
161
|
+
let [S, C] = i([]), [w, T] = i(!0), [E, D] = i(null), [O, me] = i(null), [he, k] = i(null), [A, ge] = i(""), j = re(), M = r(null), [N, _e] = i(null), [P, F] = i(null), [I, L] = i(!1), [R, ve] = i(null), ye = e((e) => {
|
|
162
|
+
ve(e?.error?.message || "Failed to load the map style/tiles.");
|
|
163
|
+
}, []), be = e(() => {
|
|
126
164
|
if (typeof navigator > "u" || !navigator.geolocation) {
|
|
127
|
-
|
|
165
|
+
F("Geolocation is not available in this browser.");
|
|
128
166
|
return;
|
|
129
167
|
}
|
|
130
|
-
|
|
168
|
+
L(!0), F(null), navigator.geolocation.getCurrentPosition((e) => {
|
|
131
169
|
let { longitude: t, latitude: n } = e.coords;
|
|
132
|
-
|
|
170
|
+
_e({
|
|
133
171
|
lng: t,
|
|
134
172
|
lat: n
|
|
135
|
-
}),
|
|
173
|
+
}), L(!1);
|
|
136
174
|
try {
|
|
137
|
-
|
|
175
|
+
M.current?.flyTo({
|
|
138
176
|
center: [t, n],
|
|
139
177
|
zoom: 12,
|
|
140
178
|
duration: 800
|
|
141
179
|
});
|
|
142
180
|
} catch {}
|
|
143
181
|
}, (e) => {
|
|
144
|
-
|
|
182
|
+
L(!1), F(e.message || "Unable to retrieve location.");
|
|
145
183
|
}, {
|
|
146
184
|
enableHighAccuracy: !1,
|
|
147
185
|
timeout: 8e3,
|
|
148
186
|
maximumAge: 6e4
|
|
149
187
|
});
|
|
150
|
-
}, []),
|
|
188
|
+
}, []), z = ue(a), B = n(() => z, [JSON.stringify(z)]), V = n(() => de(a), [a]), H = B?.provider === "value";
|
|
151
189
|
t(() => {
|
|
152
190
|
(async () => {
|
|
153
191
|
try {
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
E(e), D(!1);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (a.data) {
|
|
162
|
-
let e = a.data;
|
|
163
|
-
if (Array.isArray(e)) {
|
|
164
|
-
E(e), D(!1);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
192
|
+
if (T(!0), Array.isArray(d)) {
|
|
193
|
+
C(d), T(!1);
|
|
194
|
+
return;
|
|
167
195
|
}
|
|
168
|
-
if (
|
|
169
|
-
|
|
196
|
+
if (H && B?.provider === "value") {
|
|
197
|
+
C(B.items), T(!1);
|
|
170
198
|
return;
|
|
171
199
|
}
|
|
172
|
-
if (!
|
|
173
|
-
if (
|
|
174
|
-
let e =
|
|
200
|
+
if (!l || typeof l.find != "function") throw Error("DataSource required for object/api providers");
|
|
201
|
+
if (B?.provider === "object") {
|
|
202
|
+
let e = B.object, t = o(O?.fields), n = await l.find(e, {
|
|
175
203
|
$filter: a.filter,
|
|
176
|
-
$orderby:
|
|
204
|
+
$orderby: s(a.sort),
|
|
177
205
|
...t.length > 0 ? { $expand: t } : {}
|
|
178
|
-
}), r =
|
|
179
|
-
|
|
180
|
-
} else
|
|
181
|
-
|
|
206
|
+
}), r = c(n);
|
|
207
|
+
C(r);
|
|
208
|
+
} else B?.provider === "api" && (console.warn("API provider not yet implemented for ObjectMap"), C([]));
|
|
209
|
+
T(!1);
|
|
182
210
|
} catch (e) {
|
|
183
|
-
|
|
211
|
+
D(e), T(!1);
|
|
184
212
|
}
|
|
185
213
|
})();
|
|
186
214
|
}, [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
215
|
+
d,
|
|
216
|
+
B,
|
|
217
|
+
l,
|
|
218
|
+
H,
|
|
190
219
|
a.filter,
|
|
191
220
|
a.sort,
|
|
192
|
-
|
|
221
|
+
O
|
|
193
222
|
]), t(() => {
|
|
194
|
-
!
|
|
223
|
+
!H && l && (async () => {
|
|
195
224
|
try {
|
|
196
|
-
if (!
|
|
197
|
-
let e =
|
|
225
|
+
if (!l) return;
|
|
226
|
+
let e = B?.provider === "object" ? B.object : a.objectName;
|
|
198
227
|
if (!e) return;
|
|
199
|
-
let t = await
|
|
200
|
-
|
|
228
|
+
let t = await l.getObjectSchema(e);
|
|
229
|
+
me(t);
|
|
201
230
|
} catch (e) {
|
|
202
231
|
console.error("Failed to fetch object schema:", e);
|
|
203
232
|
}
|
|
204
233
|
})();
|
|
205
234
|
}, [
|
|
206
235
|
a.objectName,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
236
|
+
l,
|
|
237
|
+
H,
|
|
238
|
+
B
|
|
210
239
|
]);
|
|
211
|
-
let { markers:
|
|
240
|
+
let { markers: U, invalidCount: W } = n(() => {
|
|
212
241
|
let e = 0;
|
|
213
242
|
return {
|
|
214
|
-
markers:
|
|
215
|
-
let r =
|
|
243
|
+
markers: S.map((t, n) => {
|
|
244
|
+
let r = fe(t, V);
|
|
216
245
|
if (!r) return e++, null;
|
|
217
|
-
let i =
|
|
246
|
+
let i = ee(O, t, {
|
|
247
|
+
titleField: V.titleField,
|
|
248
|
+
fallback: "Marker"
|
|
249
|
+
}), a = V.descriptionField ? t[V.descriptionField] : void 0, [o, s] = r;
|
|
218
250
|
return !isFinite(o) || !isFinite(s) || o < -90 || o > 90 || s < -180 || s > 180 ? (e++, null) : {
|
|
219
251
|
id: t.id || t._id || `marker-${n}`,
|
|
220
252
|
title: i,
|
|
@@ -225,146 +257,167 @@ var y = ({ schema: a, dataSource: c, className: u, onMarkerClick: h, onRowClick:
|
|
|
225
257
|
}).filter((e) => e !== null),
|
|
226
258
|
invalidCount: e
|
|
227
259
|
};
|
|
228
|
-
}, [
|
|
260
|
+
}, [
|
|
261
|
+
S,
|
|
262
|
+
V,
|
|
263
|
+
O
|
|
264
|
+
]), G = n(() => U.find((e) => e.id === he), [U, he]), [K, xe] = i(V.zoom || 3), Se = e((e) => {
|
|
265
|
+
try {
|
|
266
|
+
let t = e?.target?.getZoom?.();
|
|
267
|
+
typeof t == "number" && Number.isFinite(t) && xe(Math.round(t));
|
|
268
|
+
} catch {}
|
|
269
|
+
}, []), q = te({
|
|
229
270
|
navigation: a.navigation,
|
|
230
271
|
objectName: a.objectName,
|
|
231
|
-
onRowClick:
|
|
232
|
-
}),
|
|
233
|
-
if (!
|
|
234
|
-
let e =
|
|
235
|
-
return
|
|
236
|
-
}, [
|
|
272
|
+
onRowClick: _
|
|
273
|
+
}), J = n(() => {
|
|
274
|
+
if (!A.trim()) return U;
|
|
275
|
+
let e = A.toLowerCase();
|
|
276
|
+
return U.filter((t) => t.title?.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e));
|
|
277
|
+
}, [U, A]), Ce = n(() => b ?? (a.enableClustering || J.length > 100) ? pe(J, K, x) : J.map((e) => ({
|
|
237
278
|
id: e.id,
|
|
238
279
|
coordinates: e.coordinates,
|
|
239
280
|
markers: [e],
|
|
240
281
|
isCluster: !1
|
|
241
282
|
})), [
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
283
|
+
J,
|
|
284
|
+
K,
|
|
285
|
+
b,
|
|
286
|
+
x,
|
|
246
287
|
a
|
|
247
|
-
]),
|
|
248
|
-
if (
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
288
|
+
]), Y = n(() => se(J.map((e) => e.coordinates)), [J]), X = typeof V.center?.[0] == "number" ? V.center[0] : void 0, Z = typeof V.center?.[1] == "number" ? V.center[1] : void 0, Q = typeof V.zoom == "number" ? V.zoom : void 0, $ = X !== void 0 || Z !== void 0 || Q !== void 0, we = n(() => {
|
|
289
|
+
if (Y && !$) return {
|
|
290
|
+
bounds: Y,
|
|
291
|
+
fitBoundsOptions: {
|
|
292
|
+
padding: 48,
|
|
293
|
+
maxZoom: 12
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
let e = Y ? ce(Y) : {
|
|
297
|
+
longitude: 0,
|
|
298
|
+
latitude: 0
|
|
252
299
|
};
|
|
253
|
-
let e = $.map((e) => e.coordinates[0]), t = $.map((e) => e.coordinates[1]), n = Math.min(...e), r = Math.max(...e), i = Math.min(...t), a = Math.max(...t);
|
|
254
300
|
return {
|
|
255
|
-
longitude:
|
|
256
|
-
latitude:
|
|
257
|
-
zoom:
|
|
301
|
+
longitude: Z ?? e.longitude,
|
|
302
|
+
latitude: X ?? e.latitude,
|
|
303
|
+
zoom: Q ?? (Y ? 3 : 2)
|
|
258
304
|
};
|
|
259
|
-
}, [
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
305
|
+
}, [
|
|
306
|
+
Y,
|
|
307
|
+
$,
|
|
308
|
+
Z,
|
|
309
|
+
X,
|
|
310
|
+
Q
|
|
311
|
+
]);
|
|
312
|
+
return w ? /* @__PURE__ */ m("div", {
|
|
313
|
+
className: f("min-w-0 overflow-hidden", u),
|
|
314
|
+
children: /* @__PURE__ */ m("div", {
|
|
263
315
|
className: "flex items-center justify-center h-96 bg-muted rounded-lg border",
|
|
264
|
-
children: /* @__PURE__ */
|
|
316
|
+
children: /* @__PURE__ */ m("div", {
|
|
265
317
|
className: "text-muted-foreground",
|
|
266
318
|
children: "Loading map..."
|
|
267
319
|
})
|
|
268
320
|
})
|
|
269
|
-
}) :
|
|
270
|
-
className:
|
|
271
|
-
children: /* @__PURE__ */
|
|
321
|
+
}) : E ? /* @__PURE__ */ m("div", {
|
|
322
|
+
className: f("min-w-0 overflow-hidden", u),
|
|
323
|
+
children: /* @__PURE__ */ m("div", {
|
|
272
324
|
className: "flex items-center justify-center h-96 bg-muted rounded-lg border",
|
|
273
|
-
children: /* @__PURE__ */
|
|
325
|
+
children: /* @__PURE__ */ h("div", {
|
|
274
326
|
className: "text-destructive",
|
|
275
|
-
children: ["Error: ",
|
|
327
|
+
children: ["Error: ", E.message]
|
|
276
328
|
})
|
|
277
329
|
})
|
|
278
|
-
}) : /* @__PURE__ */
|
|
279
|
-
className:
|
|
330
|
+
}) : /* @__PURE__ */ h("div", {
|
|
331
|
+
className: f("min-w-0 overflow-hidden", u),
|
|
280
332
|
children: [
|
|
281
|
-
|
|
333
|
+
W > 0 && /* @__PURE__ */ m("div", {
|
|
282
334
|
className: "mb-2 p-2 text-sm text-yellow-800 bg-yellow-50 border border-yellow-200 rounded",
|
|
283
|
-
children: `${
|
|
335
|
+
children: `${W} record${W === 1 ? "" : "s"} with missing or invalid coordinates excluded from the map.`
|
|
284
336
|
}),
|
|
285
|
-
|
|
337
|
+
U.length > 0 && /* @__PURE__ */ m("div", {
|
|
286
338
|
className: "mb-2",
|
|
287
|
-
children: /* @__PURE__ */
|
|
339
|
+
children: /* @__PURE__ */ m("input", {
|
|
288
340
|
type: "text",
|
|
289
|
-
value:
|
|
290
|
-
onChange: (e) =>
|
|
341
|
+
value: A,
|
|
342
|
+
onChange: (e) => ge(e.target.value),
|
|
291
343
|
placeholder: "Search locations…",
|
|
292
344
|
className: "w-full px-3 py-2 text-sm border rounded-md bg-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
|
|
293
345
|
})
|
|
294
346
|
}),
|
|
295
|
-
/* @__PURE__ */
|
|
347
|
+
/* @__PURE__ */ h("div", {
|
|
296
348
|
className: "relative border rounded-lg overflow-hidden bg-muted h-[300px] sm:h-[400px] md:h-[500px] lg:h-[600px] w-full",
|
|
297
349
|
children: [
|
|
298
|
-
/* @__PURE__ */
|
|
350
|
+
/* @__PURE__ */ h(ie, {
|
|
299
351
|
ref: (e) => {
|
|
300
|
-
|
|
352
|
+
M.current = e;
|
|
301
353
|
},
|
|
302
|
-
initialViewState:
|
|
354
|
+
initialViewState: we,
|
|
303
355
|
style: {
|
|
304
356
|
width: "100%",
|
|
305
357
|
height: "100%"
|
|
306
358
|
},
|
|
307
|
-
mapStyle:
|
|
359
|
+
mapStyle: V.style || le,
|
|
308
360
|
touchZoomRotate: !0,
|
|
309
361
|
dragRotate: !0,
|
|
310
362
|
touchPitch: !0,
|
|
311
|
-
|
|
312
|
-
|
|
363
|
+
onLoad: Se,
|
|
364
|
+
onZoom: (e) => xe(Math.round(e.viewState.zoom)),
|
|
365
|
+
onError: ye,
|
|
313
366
|
children: [
|
|
314
|
-
|
|
367
|
+
R && /* @__PURE__ */ h("div", {
|
|
315
368
|
role: "alert",
|
|
316
369
|
className: "absolute inset-x-0 top-0 z-20 p-2 text-sm text-center text-amber-900 bg-amber-50 border-b border-amber-200",
|
|
317
370
|
children: [
|
|
318
371
|
"Map failed to load (",
|
|
319
|
-
|
|
372
|
+
R,
|
|
320
373
|
"). Markers below are still listed in the search box;",
|
|
321
374
|
" ",
|
|
322
|
-
|
|
375
|
+
V.style ? "check the configured map style URL." : "configure a custom map style for production use."
|
|
323
376
|
]
|
|
324
377
|
}),
|
|
325
|
-
/* @__PURE__ */
|
|
378
|
+
/* @__PURE__ */ m(ae, {
|
|
326
379
|
position: "top-right",
|
|
327
380
|
showCompass: !0,
|
|
328
381
|
showZoom: !0
|
|
329
382
|
}),
|
|
330
|
-
/* @__PURE__ */
|
|
383
|
+
/* @__PURE__ */ m("button", {
|
|
331
384
|
type: "button",
|
|
332
|
-
onClick:
|
|
333
|
-
disabled:
|
|
385
|
+
onClick: be,
|
|
386
|
+
disabled: I,
|
|
334
387
|
className: "absolute top-2 left-2 z-10 inline-flex items-center justify-center size-9 rounded-md bg-background/95 border shadow-sm hover:bg-background disabled:opacity-50",
|
|
335
388
|
"aria-label": "Show my location",
|
|
336
389
|
"data-testid": "map-geolocate",
|
|
337
|
-
children: /* @__PURE__ */
|
|
390
|
+
children: /* @__PURE__ */ m("span", {
|
|
338
391
|
"aria-hidden": "true",
|
|
339
|
-
children:
|
|
392
|
+
children: I ? "⏳" : "🧭"
|
|
340
393
|
})
|
|
341
394
|
}),
|
|
342
|
-
|
|
343
|
-
longitude:
|
|
344
|
-
latitude:
|
|
395
|
+
N && /* @__PURE__ */ m(p, {
|
|
396
|
+
longitude: N.lng,
|
|
397
|
+
latitude: N.lat,
|
|
345
398
|
anchor: "center",
|
|
346
|
-
children: /* @__PURE__ */
|
|
399
|
+
children: /* @__PURE__ */ m("div", {
|
|
347
400
|
className: "size-3 rounded-full bg-blue-500 ring-4 ring-blue-500/30 shadow",
|
|
348
401
|
"aria-label": "Your location",
|
|
349
402
|
"data-testid": "map-user-location"
|
|
350
403
|
})
|
|
351
404
|
}),
|
|
352
|
-
|
|
405
|
+
Ce.map((e) => e.isCluster ? /* @__PURE__ */ m(p, {
|
|
353
406
|
longitude: e.coordinates[0],
|
|
354
407
|
latitude: e.coordinates[1],
|
|
355
408
|
anchor: "center",
|
|
356
409
|
onClick: (t) => {
|
|
357
410
|
t.originalEvent.stopPropagation();
|
|
358
411
|
try {
|
|
359
|
-
let t = Math.min(20, Math.max(
|
|
360
|
-
|
|
412
|
+
let t = Math.min(20, Math.max(K + 2, 8));
|
|
413
|
+
M.current?.flyTo({
|
|
361
414
|
center: [e.coordinates[0], e.coordinates[1]],
|
|
362
415
|
zoom: t,
|
|
363
416
|
duration: 600
|
|
364
417
|
});
|
|
365
418
|
} catch {}
|
|
366
419
|
},
|
|
367
|
-
children: /* @__PURE__ */
|
|
420
|
+
children: /* @__PURE__ */ m("div", {
|
|
368
421
|
className: "flex items-center justify-center rounded-full bg-primary text-primary-foreground font-bold text-xs cursor-pointer hover:scale-110 transition-transform shadow-md",
|
|
369
422
|
style: {
|
|
370
423
|
width: Math.min(48, 24 + e.markers.length * 2),
|
|
@@ -374,46 +427,48 @@ var y = ({ schema: a, dataSource: c, className: u, onMarkerClick: h, onRowClick:
|
|
|
374
427
|
"data-testid": "map-cluster",
|
|
375
428
|
children: e.markers.length
|
|
376
429
|
})
|
|
377
|
-
}, e.id) : /* @__PURE__ */ p
|
|
430
|
+
}, e.id) : /* @__PURE__ */ m(p, {
|
|
378
431
|
longitude: e.coordinates[0],
|
|
379
432
|
latitude: e.coordinates[1],
|
|
380
433
|
anchor: "bottom",
|
|
381
434
|
onClick: (t) => {
|
|
382
435
|
t.originalEvent.stopPropagation();
|
|
383
436
|
let n = e.markers[0];
|
|
384
|
-
|
|
437
|
+
k(n.id), q.handleClick(n.data), g?.(n.data);
|
|
385
438
|
},
|
|
386
|
-
children: /* @__PURE__ */
|
|
439
|
+
children: /* @__PURE__ */ m("div", {
|
|
387
440
|
className: "text-2xl cursor-pointer hover:scale-110 transition-transform",
|
|
388
441
|
children: "📍"
|
|
389
442
|
})
|
|
390
443
|
}, e.id)),
|
|
391
|
-
|
|
392
|
-
longitude:
|
|
393
|
-
latitude:
|
|
444
|
+
G && !j && /* @__PURE__ */ m(oe, {
|
|
445
|
+
longitude: G.coordinates[0],
|
|
446
|
+
latitude: G.coordinates[1],
|
|
394
447
|
anchor: "top",
|
|
395
|
-
onClose: () =>
|
|
448
|
+
onClose: () => k(null),
|
|
396
449
|
closeOnClick: !1,
|
|
397
|
-
children: /* @__PURE__ */
|
|
450
|
+
children: /* @__PURE__ */ h("div", {
|
|
398
451
|
className: "p-2 min-w-[150px] sm:min-w-[200px]",
|
|
399
452
|
children: [
|
|
400
|
-
/* @__PURE__ */
|
|
453
|
+
/* @__PURE__ */ m("h3", {
|
|
401
454
|
className: "font-bold text-sm mb-1",
|
|
402
|
-
children:
|
|
455
|
+
children: G.title
|
|
403
456
|
}),
|
|
404
|
-
|
|
457
|
+
G.description && /* @__PURE__ */ m("p", {
|
|
405
458
|
className: "text-xs text-muted-foreground",
|
|
406
|
-
children:
|
|
459
|
+
children: G.description
|
|
407
460
|
}),
|
|
408
|
-
/* @__PURE__ */
|
|
461
|
+
/* @__PURE__ */ h("div", {
|
|
409
462
|
className: "mt-2 text-xs flex gap-2",
|
|
410
|
-
children: [
|
|
463
|
+
children: [v && /* @__PURE__ */ m("button", {
|
|
464
|
+
type: "button",
|
|
411
465
|
className: "text-blue-500 hover:underline",
|
|
412
|
-
onClick: () =>
|
|
466
|
+
onClick: () => v(G.data),
|
|
413
467
|
children: "Edit"
|
|
414
|
-
}),
|
|
468
|
+
}), y && /* @__PURE__ */ m("button", {
|
|
469
|
+
type: "button",
|
|
415
470
|
className: "text-red-500 hover:underline",
|
|
416
|
-
onClick: () =>
|
|
471
|
+
onClick: () => y(G.data),
|
|
417
472
|
children: "Delete"
|
|
418
473
|
})]
|
|
419
474
|
})
|
|
@@ -422,67 +477,69 @@ var y = ({ schema: a, dataSource: c, className: u, onMarkerClick: h, onRowClick:
|
|
|
422
477
|
})
|
|
423
478
|
]
|
|
424
479
|
}),
|
|
425
|
-
|
|
480
|
+
G && j && /* @__PURE__ */ h("div", {
|
|
426
481
|
className: "absolute inset-x-0 bottom-0 z-30 bg-background border-t shadow-lg rounded-t-2xl p-4 pb-[max(env(safe-area-inset-bottom),1rem)]",
|
|
427
482
|
role: "dialog",
|
|
428
483
|
"aria-label": "Location details",
|
|
429
484
|
"data-testid": "map-mobile-record-sheet",
|
|
430
485
|
children: [
|
|
431
|
-
/* @__PURE__ */
|
|
486
|
+
/* @__PURE__ */ m("div", {
|
|
432
487
|
className: "mx-auto mb-2 h-1 w-10 rounded-full bg-muted",
|
|
433
488
|
"aria-hidden": "true"
|
|
434
489
|
}),
|
|
435
|
-
/* @__PURE__ */
|
|
490
|
+
/* @__PURE__ */ h("div", {
|
|
436
491
|
className: "flex items-start justify-between gap-3",
|
|
437
|
-
children: [/* @__PURE__ */
|
|
492
|
+
children: [/* @__PURE__ */ h("div", {
|
|
438
493
|
className: "min-w-0 flex-1",
|
|
439
|
-
children: [/* @__PURE__ */
|
|
494
|
+
children: [/* @__PURE__ */ m("h3", {
|
|
440
495
|
className: "text-sm font-semibold truncate",
|
|
441
|
-
children:
|
|
442
|
-
}),
|
|
496
|
+
children: G.title
|
|
497
|
+
}), G.description && /* @__PURE__ */ m("p", {
|
|
443
498
|
className: "mt-1 text-xs text-muted-foreground line-clamp-3",
|
|
444
|
-
children:
|
|
499
|
+
children: G.description
|
|
445
500
|
})]
|
|
446
|
-
}), /* @__PURE__ */
|
|
501
|
+
}), /* @__PURE__ */ m("button", {
|
|
447
502
|
type: "button",
|
|
448
|
-
onClick: () =>
|
|
503
|
+
onClick: () => k(null),
|
|
449
504
|
className: "text-muted-foreground hover:text-foreground text-lg leading-none px-2",
|
|
450
505
|
"aria-label": "Close details",
|
|
451
506
|
"data-testid": "map-mobile-record-close",
|
|
452
507
|
children: "×"
|
|
453
508
|
})]
|
|
454
509
|
}),
|
|
455
|
-
/* @__PURE__ */
|
|
510
|
+
/* @__PURE__ */ h("div", {
|
|
456
511
|
className: "mt-3 flex flex-wrap gap-2 text-xs",
|
|
457
|
-
children: [
|
|
512
|
+
children: [v && /* @__PURE__ */ m("button", {
|
|
513
|
+
type: "button",
|
|
458
514
|
className: "px-3 py-1.5 rounded-md border bg-card hover:bg-accent",
|
|
459
|
-
onClick: () =>
|
|
515
|
+
onClick: () => v(G.data),
|
|
460
516
|
children: "Edit"
|
|
461
|
-
}),
|
|
517
|
+
}), y && /* @__PURE__ */ m("button", {
|
|
518
|
+
type: "button",
|
|
462
519
|
className: "px-3 py-1.5 rounded-md border border-destructive/30 text-destructive hover:bg-destructive/10",
|
|
463
|
-
onClick: () =>
|
|
520
|
+
onClick: () => y(G.data),
|
|
464
521
|
children: "Delete"
|
|
465
522
|
})]
|
|
466
523
|
})
|
|
467
524
|
]
|
|
468
525
|
}),
|
|
469
|
-
|
|
526
|
+
P && /* @__PURE__ */ m("div", {
|
|
470
527
|
className: "absolute top-2 left-14 right-2 z-10 text-xs px-3 py-1.5 rounded-md bg-destructive/10 text-destructive border border-destructive/30",
|
|
471
|
-
children:
|
|
528
|
+
children: P
|
|
472
529
|
})
|
|
473
530
|
]
|
|
474
531
|
}),
|
|
475
|
-
|
|
476
|
-
...
|
|
532
|
+
q.isOverlay && /* @__PURE__ */ m(ne, {
|
|
533
|
+
...q,
|
|
477
534
|
title: "Location Details",
|
|
478
|
-
children: (e) => /* @__PURE__ */
|
|
535
|
+
children: (e) => /* @__PURE__ */ m("div", {
|
|
479
536
|
className: "space-y-3",
|
|
480
|
-
children: Object.entries(e).map(([e, t]) => /* @__PURE__ */
|
|
537
|
+
children: Object.entries(e).map(([e, t]) => /* @__PURE__ */ h("div", {
|
|
481
538
|
className: "flex flex-col",
|
|
482
|
-
children: [/* @__PURE__ */
|
|
539
|
+
children: [/* @__PURE__ */ m("span", {
|
|
483
540
|
className: "text-xs font-medium text-muted-foreground uppercase tracking-wide",
|
|
484
541
|
children: e.replace(/_/g, " ")
|
|
485
|
-
}), /* @__PURE__ */
|
|
542
|
+
}), /* @__PURE__ */ m("span", {
|
|
486
543
|
className: "text-sm",
|
|
487
544
|
children: String(t ?? "—")
|
|
488
545
|
})]
|
|
@@ -491,15 +548,25 @@ var y = ({ schema: a, dataSource: c, className: u, onMarkerClick: h, onRowClick:
|
|
|
491
548
|
})
|
|
492
549
|
]
|
|
493
550
|
});
|
|
494
|
-
},
|
|
495
|
-
|
|
496
|
-
|
|
551
|
+
}, D = {
|
|
552
|
+
filter: !0,
|
|
553
|
+
sort: !0
|
|
554
|
+
}, O = ({ schema: e, ...t }) => {
|
|
555
|
+
let { dataSource: n } = u() || {};
|
|
556
|
+
return /* @__PURE__ */ m(l, {
|
|
497
557
|
schema: e,
|
|
558
|
+
mapping: D,
|
|
498
559
|
dataSource: n,
|
|
499
|
-
|
|
560
|
+
testId: "object-map",
|
|
561
|
+
errorTitle: "This map’s data source could not be resolved",
|
|
562
|
+
children: (e) => /* @__PURE__ */ m(E, {
|
|
563
|
+
schema: e,
|
|
564
|
+
dataSource: n,
|
|
565
|
+
...t
|
|
566
|
+
})
|
|
500
567
|
});
|
|
501
568
|
};
|
|
502
|
-
|
|
569
|
+
a.register("object-map", O, {
|
|
503
570
|
namespace: "plugin-map",
|
|
504
571
|
label: "Object Map",
|
|
505
572
|
category: "view",
|
|
@@ -514,7 +581,7 @@ console.log("Registering object-map..."), a.register("object-map", b, {
|
|
|
514
581
|
label: "Map Config",
|
|
515
582
|
description: "latitudeField, longitudeField, titleField"
|
|
516
583
|
}]
|
|
517
|
-
}), a.register("map",
|
|
584
|
+
}), a.register("map", O, {
|
|
518
585
|
namespace: "view",
|
|
519
586
|
label: "Map View",
|
|
520
587
|
category: "view",
|
|
@@ -531,4 +598,4 @@ console.log("Registering object-map..."), a.register("object-map", b, {
|
|
|
531
598
|
}]
|
|
532
599
|
});
|
|
533
600
|
//#endregion
|
|
534
|
-
export {
|
|
601
|
+
export { E as ObjectMap, O as ObjectMapRenderer };
|