@nika-js/onlymap 0.7.3 → 0.7.5
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 +13 -0
- package/README.md +3 -1
- package/bin/onlymapjs.mjs +236 -0
- package/dist/{LercDecode.es-DEucX1sB.js → LercDecode.es-DYwn8YTS.js} +1 -1
- package/dist/{basemap-CmEvmtwF.js → basemap-CtEc5BCi.js} +1 -1
- package/dist/elements/om-map.d.ts +8 -0
- package/dist/{geoparquet-DL58Htx5.js → geoparquet-RBC0ZJNm.js} +1 -1
- package/dist/{index-ec-8juRl.js → index-Bwu1DFHP.js} +1 -1
- package/dist/{index-CNili_G3.js → index-CJ0pib8I.js} +2 -2
- package/dist/{index-NkRgxbAW.js → index-CiGUw6GD.js} +1 -1
- package/dist/{index-BRdaiH3a.js → index-DkimKgOm.js} +3321 -3295
- package/dist/{index-DrTKLcxB.js → index-HrEJtZoQ.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{lerc-BPTGJlrt.js → lerc-BIQMg0FV.js} +2 -2
- package/dist/onlymap.standalone.js +3786 -3760
- package/dist/onlymapjs.css +1 -1
- package/dist/onlymapjs.js +89 -87
- package/dist/{raster-lkF1eUo1.js → raster-Dsugvobw.js} +3 -3
- package/dist/{raster-pipeline-B4N48UQX.js → raster-pipeline-rqJJRCEo.js} +1 -1
- package/dist/react/context.d.ts +2 -0
- package/dist/react.js +244 -236
- package/dist/version.d.ts +1 -1
- package/dist/widget-layout.d.ts +21 -0
- package/dist/{zarr-B-l3yHWb.js → zarr-CRysSFhD.js} +2 -2
- package/llms.txt +5 -3
- package/package.json +1 -1
- package/skills/onlymapjs/SKILL.md +3 -2
- package/skills/onlymapjs/references/syntax.md +5 -3
package/dist/react.js
CHANGED
|
@@ -1,167 +1,172 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsxs as ee, jsx as
|
|
5
|
-
import { createContext as
|
|
6
|
-
import { MANAGED_SLOTS as
|
|
7
|
-
import { createPortal as
|
|
8
|
-
const
|
|
9
|
-
function Y(
|
|
10
|
-
const e =
|
|
11
|
-
if (!e) throw new Error(`[onlymapjs] ${
|
|
1
|
+
var Le = Object.defineProperty;
|
|
2
|
+
var _e = (r, e, s) => e in r ? Le(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
|
|
3
|
+
var ue = (r, e, s) => _e(r, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
+
import { jsxs as ee, jsx as C } from "react/jsx-runtime";
|
|
5
|
+
import { createContext as $e, useContext as je, forwardRef as De, useRef as b, useState as k, useId as ge, useCallback as te, useMemo as $, useLayoutEffect as fe, useEffect as E, useImperativeHandle as Ae, useSyncExternalStore as ye } from "react";
|
|
6
|
+
import { MANAGED_SLOTS as ze, slotContainerStyle as Be, FOLD_SIDES as K, MapController as Ie, parseWidgetStyle as Ke, foldToggleSlot as We, foldToggleStyle as He, foldPanelStyle as Ne, foldDrawerStyle as Ve, resolveFoldBreakpointPx as qe, shouldFoldAtWidth as Je, effectiveFoldBreakpointPx as Ye, DEFAULT_FOLD_BREAKPOINT_PX as Ge, bottomEndLiftPx as Xe, FOLD_BOTTOM_CLEARANCE_PX as Ze, resolveSlot as Ue, foldSideForSlot as Qe, isStoreToken as et } from "@nika-js/onlymap";
|
|
7
|
+
import { createPortal as be } from "react-dom";
|
|
8
|
+
const he = $e(null);
|
|
9
|
+
function Y(r) {
|
|
10
|
+
const e = je(he);
|
|
11
|
+
if (!e) throw new Error(`[onlymapjs] ${r} must be rendered inside <OmMap>.`);
|
|
12
12
|
return e;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
if (
|
|
16
|
-
const s = Object.keys(
|
|
17
|
-
return s.length !== o.length ? !1 : s.every((i) =>
|
|
14
|
+
function re(r, e) {
|
|
15
|
+
if (r === e) return !0;
|
|
16
|
+
const s = Object.keys(r ?? {}), o = Object.keys(e ?? {});
|
|
17
|
+
return s.length !== o.length ? !1 : s.every((i) => r[i] === e[i]);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
const { props: s, updateTriggers: o, ...i } =
|
|
21
|
-
return
|
|
19
|
+
function tt(r, e) {
|
|
20
|
+
const { props: s, updateTriggers: o, ...i } = r, { props: g, updateTriggers: u, ...d } = e;
|
|
21
|
+
return re(i, d) && re(s, g) && re(o, u);
|
|
22
22
|
}
|
|
23
|
-
class
|
|
23
|
+
class rt {
|
|
24
24
|
constructor(e) {
|
|
25
|
-
|
|
25
|
+
ue(this, "descriptors", /* @__PURE__ */ new Map());
|
|
26
26
|
this.controller = e;
|
|
27
27
|
}
|
|
28
28
|
upsert(e) {
|
|
29
29
|
const s = this.descriptors.get(e.id);
|
|
30
|
-
s &&
|
|
30
|
+
s && tt(s, e) || (this.descriptors.set(e.id, e), this.controller.setLayers([...this.descriptors.values()]));
|
|
31
31
|
}
|
|
32
32
|
remove(e) {
|
|
33
33
|
this.descriptors.delete(e) && this.controller.setLayers([...this.descriptors.values()]);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const J =
|
|
37
|
-
function
|
|
38
|
-
const e =
|
|
36
|
+
const J = ze, nt = Object.fromEntries(J.map((r) => [r, Be(r)])), me = { display: "flex", pointerEvents: "none", order: 2147483647 }, ot = Object.fromEntries(K.map((r) => [r, null]));
|
|
37
|
+
function st(r) {
|
|
38
|
+
const e = r.querySelector(
|
|
39
39
|
'button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])'
|
|
40
40
|
);
|
|
41
|
-
e ? e.focus() : (
|
|
41
|
+
e ? e.focus() : (r.tabIndex = -1, r.focus());
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
return Object.entries(e).some(([s, o]) => o !== void 0 &&
|
|
43
|
+
function it(r, e) {
|
|
44
|
+
return Object.entries(e).some(([s, o]) => o !== void 0 && r[s] !== o);
|
|
45
45
|
}
|
|
46
|
-
const
|
|
47
|
-
const { center: o, zoom: i, pitch:
|
|
48
|
-
() => Object.fromEntries(J.map((
|
|
49
|
-
), [
|
|
50
|
-
() => Object.fromEntries(K.map((
|
|
51
|
-
), [
|
|
46
|
+
const gt = De(function(e, s) {
|
|
47
|
+
const { center: o, zoom: i, pitch: g, bearing: u, basemap: d, basemapKey: y, attribution: h, headless: f, widgetStyle: T, widgetsHidden: v, widgetsFold: m = !0, className: S, style: O, children: w } = e, P = b(null), M = b(null), [c, j] = k(null), [L, G] = k(null), [F, z] = k(
|
|
48
|
+
() => Object.fromEntries(J.map((t) => [t, null]))
|
|
49
|
+
), [x, W] = k(!1), [B, Se] = k({ lift: 0, shift: 0 }), [ne, Oe] = k(ot), [we, Re] = k(
|
|
50
|
+
() => Object.fromEntries(K.map((t) => [t, 0]))
|
|
51
|
+
), [Ee, X] = k(null), oe = `om-react-fold-${ge().replaceAll(":", "")}`, Pe = b(new Map(K.map((t) => [t, /* @__PURE__ */ new Set()]))), Fe = b(/* @__PURE__ */ new Map()), [se, xe] = k(() => /* @__PURE__ */ new Set()), ie = f ? JSON.stringify(f) : "", H = b({
|
|
52
52
|
badge: null,
|
|
53
53
|
attribution: null
|
|
54
|
-
}),
|
|
55
|
-
G((n) => n ===
|
|
56
|
-
}, []),
|
|
54
|
+
}), Ce = te((t) => {
|
|
55
|
+
G((n) => n === t ? n : t);
|
|
56
|
+
}, []), Te = $(
|
|
57
57
|
() => Object.fromEntries(
|
|
58
|
-
J.map((
|
|
59
|
-
|
|
58
|
+
J.map((t) => [
|
|
59
|
+
t,
|
|
60
60
|
(n) => {
|
|
61
|
-
|
|
61
|
+
z((a) => a[t] === n ? a : { ...a, [t]: n });
|
|
62
62
|
}
|
|
63
63
|
])
|
|
64
64
|
),
|
|
65
65
|
[]
|
|
66
|
-
),
|
|
66
|
+
), ke = $(
|
|
67
67
|
() => Object.fromEntries(
|
|
68
|
-
K.map((
|
|
69
|
-
|
|
68
|
+
K.map((t) => [
|
|
69
|
+
t,
|
|
70
70
|
(n) => {
|
|
71
|
-
|
|
71
|
+
Oe((a) => a[t] === n ? a : { ...a, [t]: n });
|
|
72
72
|
}
|
|
73
73
|
])
|
|
74
74
|
),
|
|
75
75
|
[]
|
|
76
|
-
),
|
|
77
|
-
const
|
|
78
|
-
a ?
|
|
76
|
+
), ae = te((t, n, a) => {
|
|
77
|
+
const l = Pe.current.get(t), p = l.size;
|
|
78
|
+
a ? l.add(n) : l.delete(n), l.size !== p && Re((R) => ({ ...R, [t]: l.size }));
|
|
79
|
+
}, []), le = te((t, n, a) => {
|
|
80
|
+
const l = Fe.current;
|
|
81
|
+
a ? l.set(n, t) : l.delete(n);
|
|
82
|
+
const p = new Set(l.values());
|
|
83
|
+
xe((R) => R.size === p.size && [...p].every((_) => R.has(_)) ? R : p);
|
|
79
84
|
}, []);
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
if (!
|
|
83
|
-
let n, a =
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
|
|
85
|
+
fe(() => {
|
|
86
|
+
const t = P.current;
|
|
87
|
+
if (!t) return;
|
|
88
|
+
let n, a = Ge;
|
|
89
|
+
const l = (R) => {
|
|
90
|
+
const _ = getComputedStyle(t).getPropertyValue("--om-widget-fold-breakpoint").trim();
|
|
91
|
+
_ !== n && (n = _, a = qe(_, t)), W((I) => m && Je(R, Ye(a, se), I));
|
|
87
92
|
};
|
|
88
|
-
if (
|
|
89
|
-
const
|
|
90
|
-
return
|
|
91
|
-
}, [
|
|
92
|
-
(!
|
|
93
|
-
}, [
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const V =
|
|
93
|
+
if (l(t.getBoundingClientRect().width || (f ? f === !0 ? 800 : f.width ?? 800 : 0)), typeof ResizeObserver > "u") return;
|
|
94
|
+
const p = new ResizeObserver(([R]) => l(R.contentRect.width));
|
|
95
|
+
return p.observe(t), () => p.disconnect();
|
|
96
|
+
}, [m, ie, se]), E(() => {
|
|
97
|
+
(!x || v) && X(null);
|
|
98
|
+
}, [x, v]);
|
|
99
|
+
const ce = b({ center: o, zoom: i, pitch: g, bearing: u });
|
|
100
|
+
ce.current = { center: o, zoom: i, pitch: g, bearing: u };
|
|
101
|
+
const N = b(e.onReady);
|
|
102
|
+
N.current = e.onReady;
|
|
103
|
+
const D = b(e.onViewStateChange);
|
|
104
|
+
D.current = e.onViewStateChange;
|
|
105
|
+
const V = b(e.onRuntimeError);
|
|
101
106
|
V.current = e.onRuntimeError;
|
|
102
|
-
const Z =
|
|
103
|
-
Z.current =
|
|
104
|
-
const U =
|
|
105
|
-
|
|
106
|
-
if (!
|
|
107
|
-
const
|
|
107
|
+
const Z = b(d);
|
|
108
|
+
Z.current = d;
|
|
109
|
+
const U = b(void 0);
|
|
110
|
+
fe(() => {
|
|
111
|
+
if (!M.current) return;
|
|
112
|
+
const t = ce.current;
|
|
108
113
|
U.current = Z.current;
|
|
109
|
-
const n = new
|
|
110
|
-
center:
|
|
111
|
-
zoom:
|
|
112
|
-
pitch:
|
|
113
|
-
bearing:
|
|
114
|
+
const n = new Ie(M.current, {
|
|
115
|
+
center: t.center,
|
|
116
|
+
zoom: t.zoom,
|
|
117
|
+
pitch: t.pitch,
|
|
118
|
+
bearing: t.bearing,
|
|
114
119
|
basemap: Z.current,
|
|
115
|
-
basemapKey:
|
|
116
|
-
attribution:
|
|
120
|
+
basemapKey: y,
|
|
121
|
+
attribution: h,
|
|
117
122
|
headless: f ? f === !0 ? {} : f : void 0,
|
|
118
123
|
chromeHosts: {
|
|
119
|
-
badge:
|
|
120
|
-
attribution:
|
|
124
|
+
badge: H.current.badge ?? void 0,
|
|
125
|
+
attribution: H.current.attribution ?? void 0
|
|
121
126
|
},
|
|
122
|
-
onRuntimeError: (
|
|
123
|
-
var
|
|
124
|
-
return (
|
|
127
|
+
onRuntimeError: (l) => {
|
|
128
|
+
var p;
|
|
129
|
+
return (p = V.current) == null ? void 0 : p.call(V, l);
|
|
125
130
|
}
|
|
126
131
|
});
|
|
127
|
-
|
|
132
|
+
j(n);
|
|
128
133
|
let a = !0;
|
|
129
134
|
return n.ready.then(() => {
|
|
130
|
-
var
|
|
131
|
-
a && ((
|
|
135
|
+
var l;
|
|
136
|
+
a && ((l = N.current) == null || l.call(N));
|
|
132
137
|
}), () => {
|
|
133
|
-
a = !1,
|
|
138
|
+
a = !1, j(null), n.destroy();
|
|
134
139
|
};
|
|
135
|
-
}, [
|
|
136
|
-
!
|
|
137
|
-
}, [
|
|
138
|
-
if (!
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
}, [
|
|
142
|
-
var
|
|
143
|
-
if (
|
|
144
|
-
return (
|
|
140
|
+
}, [ie]), E(() => {
|
|
141
|
+
!c || U.current === d || (U.current = d, c.setBasemap(d ?? null));
|
|
142
|
+
}, [c, d]), Ae(s, () => c, [c]), E(() => {
|
|
143
|
+
if (!c) return;
|
|
144
|
+
const t = { longitude: o == null ? void 0 : o[0], latitude: o == null ? void 0 : o[1], zoom: i, pitch: g, bearing: u };
|
|
145
|
+
it(c.getViewState(), t) && c.setView(t);
|
|
146
|
+
}, [c, o == null ? void 0 : o[0], o == null ? void 0 : o[1], i, g, u]), E(() => {
|
|
147
|
+
var t;
|
|
148
|
+
if (c)
|
|
149
|
+
return (t = D.current) == null || t.call(D, c.getViewState()), c.getStore("viewport").subscribe(() => {
|
|
145
150
|
var n;
|
|
146
|
-
return (n =
|
|
151
|
+
return (n = D.current) == null ? void 0 : n.call(D, c.getViewState());
|
|
147
152
|
});
|
|
148
|
-
}, [
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
if (!
|
|
153
|
+
}, [c]);
|
|
154
|
+
const A = F["bottom-start"], q = F["bottom-end"];
|
|
155
|
+
E(() => {
|
|
156
|
+
const t = P.current;
|
|
157
|
+
if (!t || !q || typeof ResizeObserver > "u") return;
|
|
153
158
|
const n = () => {
|
|
154
|
-
const
|
|
155
|
-
(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
),
|
|
160
|
-
|
|
159
|
+
const l = parseFloat(getComputedStyle(t).getPropertyValue("--om-widget-gap-y")) || 8, p = q.getBoundingClientRect(), R = Xe(
|
|
160
|
+
(A == null ? void 0 : A.getBoundingClientRect()) ?? null,
|
|
161
|
+
p,
|
|
162
|
+
x ? Ze : 0,
|
|
163
|
+
l
|
|
164
|
+
), _ = R + Math.ceil(p.height) + l;
|
|
165
|
+
Se((I) => I.lift === R && I.shift === _ ? I : { lift: R, shift: _ });
|
|
161
166
|
}, a = new ResizeObserver(n);
|
|
162
|
-
return a.observe(
|
|
163
|
-
}, [
|
|
164
|
-
const
|
|
167
|
+
return a.observe(t), a.observe(q), A && a.observe(A), n(), () => a.disconnect();
|
|
168
|
+
}, [A, q, x]);
|
|
169
|
+
const Me = $(
|
|
165
170
|
() => ({
|
|
166
171
|
position: "absolute",
|
|
167
172
|
inset: 0,
|
|
@@ -171,74 +176,74 @@ const dt = Me(function(e, s) {
|
|
|
171
176
|
// Measured clearance for the floating bottom drawer toggle — the
|
|
172
177
|
// drawer root reads it through foldDrawerStyle's max() (same wiring
|
|
173
178
|
// as the HTML lane's widget layer).
|
|
174
|
-
"--om-fold-bottom-shift": `${
|
|
175
|
-
...
|
|
179
|
+
"--om-fold-bottom-shift": `${B.shift}px`,
|
|
180
|
+
...T ? Ke(T).properties : void 0
|
|
176
181
|
}),
|
|
177
|
-
[
|
|
178
|
-
), Q =
|
|
179
|
-
() =>
|
|
180
|
-
[
|
|
182
|
+
[T, B.shift]
|
|
183
|
+
), Q = $(() => c ? new rt(c) : null, [c]), de = $(
|
|
184
|
+
() => c && Q && L ? { controller: c, layers: Q, overlayPane: L, corners: F, widgetsHidden: !!v, widgetsFolded: x, foldPanels: ne, registerFoldedWidget: ae, registerSlotWidget: le } : null,
|
|
185
|
+
[c, Q, L, F, v, x, ne, ae, le]
|
|
181
186
|
);
|
|
182
|
-
return /* @__PURE__ */ ee("div", { ref:
|
|
183
|
-
/* @__PURE__ */
|
|
184
|
-
/* @__PURE__ */
|
|
187
|
+
return /* @__PURE__ */ ee("div", { ref: P, className: S, style: { position: "relative", overflow: "hidden", ...O }, children: [
|
|
188
|
+
/* @__PURE__ */ C("div", { ref: M, style: { position: "absolute", inset: 0 } }),
|
|
189
|
+
/* @__PURE__ */ C(
|
|
185
190
|
"div",
|
|
186
191
|
{
|
|
187
|
-
ref:
|
|
192
|
+
ref: Ce,
|
|
188
193
|
style: { position: "absolute", top: 0, left: 0, zIndex: 10, pointerEvents: "none" }
|
|
189
194
|
}
|
|
190
195
|
),
|
|
191
|
-
/* @__PURE__ */
|
|
196
|
+
/* @__PURE__ */ C("div", { "data-om-widget-layer": "", style: Me, children: J.map((t) => /* @__PURE__ */ ee(
|
|
192
197
|
"div",
|
|
193
198
|
{
|
|
194
|
-
"data-om-widget-slot":
|
|
195
|
-
ref:
|
|
199
|
+
"data-om-widget-slot": t,
|
|
200
|
+
ref: Te[t],
|
|
196
201
|
style: {
|
|
197
|
-
...
|
|
198
|
-
...
|
|
202
|
+
...nt[t],
|
|
203
|
+
...B.lift > 0 && t === "bottom-end" ? { bottom: `calc(var(--om-widget-inset-y, 12px) + ${B.lift}px)` } : void 0
|
|
199
204
|
},
|
|
200
205
|
children: [
|
|
201
|
-
|
|
202
|
-
const a =
|
|
206
|
+
x && K.filter((n) => We(n) === t && we[n] > 0).map((n) => {
|
|
207
|
+
const a = Ee === n;
|
|
203
208
|
return /* @__PURE__ */ ee(
|
|
204
209
|
"div",
|
|
205
210
|
{
|
|
206
211
|
"data-om-fold-drawer": n,
|
|
207
|
-
style: { ...
|
|
208
|
-
onKeyDown: (
|
|
209
|
-
var
|
|
210
|
-
|
|
212
|
+
style: { ...Ve(n), display: v ? "none" : "flex" },
|
|
213
|
+
onKeyDown: (l) => {
|
|
214
|
+
var p;
|
|
215
|
+
l.key !== "Escape" || !a || (X(null), (p = l.currentTarget.querySelector("[data-om-fold-toggle]")) == null || p.focus(), l.preventDefault(), l.stopPropagation());
|
|
211
216
|
},
|
|
212
217
|
children: [
|
|
213
|
-
/* @__PURE__ */
|
|
218
|
+
/* @__PURE__ */ C(
|
|
214
219
|
"button",
|
|
215
220
|
{
|
|
216
221
|
type: "button",
|
|
217
222
|
"data-om-fold-toggle": n,
|
|
218
223
|
"aria-expanded": a,
|
|
219
|
-
"aria-controls": `${
|
|
224
|
+
"aria-controls": `${oe}-${n}`,
|
|
220
225
|
"aria-label": `${a ? "Close" : "Open"} ${n} map controls`,
|
|
221
|
-
style:
|
|
226
|
+
style: He(),
|
|
222
227
|
onClick: () => {
|
|
223
228
|
X(a ? null : n), a || requestAnimationFrame(() => {
|
|
224
|
-
var
|
|
225
|
-
const
|
|
226
|
-
|
|
229
|
+
var p;
|
|
230
|
+
const l = (p = P.current) == null ? void 0 : p.querySelector(`[data-om-fold-panel="${n}"]`);
|
|
231
|
+
l && st(l);
|
|
227
232
|
});
|
|
228
233
|
},
|
|
229
234
|
children: "⋯"
|
|
230
235
|
}
|
|
231
236
|
),
|
|
232
|
-
/* @__PURE__ */
|
|
237
|
+
/* @__PURE__ */ C(
|
|
233
238
|
"div",
|
|
234
239
|
{
|
|
235
|
-
id: `${
|
|
236
|
-
ref:
|
|
240
|
+
id: `${oe}-${n}`,
|
|
241
|
+
ref: ke[n],
|
|
237
242
|
"data-om-fold-panel": n,
|
|
238
243
|
role: "region",
|
|
239
244
|
"aria-label": `${n} map controls`,
|
|
240
245
|
hidden: !a,
|
|
241
|
-
style: { ...
|
|
246
|
+
style: { ...Ne(n), display: a ? "flex" : "none" }
|
|
242
247
|
}
|
|
243
248
|
)
|
|
244
249
|
]
|
|
@@ -246,33 +251,33 @@ const dt = Me(function(e, s) {
|
|
|
246
251
|
`fold-${n}`
|
|
247
252
|
);
|
|
248
253
|
}),
|
|
249
|
-
|
|
254
|
+
t === "bottom-start" && /* @__PURE__ */ C(
|
|
250
255
|
"div",
|
|
251
256
|
{
|
|
252
257
|
"data-om-mandated-chrome": "badge",
|
|
253
258
|
ref: (n) => {
|
|
254
|
-
|
|
259
|
+
H.current.badge = n;
|
|
255
260
|
},
|
|
256
|
-
style:
|
|
261
|
+
style: me
|
|
257
262
|
}
|
|
258
263
|
),
|
|
259
|
-
|
|
264
|
+
t === "bottom-end" && /* @__PURE__ */ C(
|
|
260
265
|
"div",
|
|
261
266
|
{
|
|
262
267
|
"data-om-mandated-chrome": "attribution",
|
|
263
268
|
ref: (n) => {
|
|
264
|
-
|
|
269
|
+
H.current.attribution = n;
|
|
265
270
|
},
|
|
266
|
-
style:
|
|
271
|
+
style: me
|
|
267
272
|
}
|
|
268
273
|
)
|
|
269
274
|
]
|
|
270
275
|
},
|
|
271
|
-
|
|
276
|
+
t
|
|
272
277
|
)) }),
|
|
273
|
-
|
|
278
|
+
de && /* @__PURE__ */ C(he.Provider, { value: de, children: w })
|
|
274
279
|
] });
|
|
275
|
-
}),
|
|
280
|
+
}), ve = {
|
|
276
281
|
id: "id",
|
|
277
282
|
type: "type",
|
|
278
283
|
data: "data",
|
|
@@ -298,67 +303,70 @@ const dt = Me(function(e, s) {
|
|
|
298
303
|
terrain: "terrain",
|
|
299
304
|
visibleZoomRange: "visibleZoomRange",
|
|
300
305
|
updateTriggers: "updateTriggers"
|
|
301
|
-
},
|
|
302
|
-
function
|
|
306
|
+
}, at = /* @__PURE__ */ new Set([...Object.keys(ve), "onClick", "onHover"]);
|
|
307
|
+
function lt(r) {
|
|
303
308
|
const e = {};
|
|
304
|
-
for (const [o, i] of Object.entries(
|
|
305
|
-
!
|
|
309
|
+
for (const [o, i] of Object.entries(r))
|
|
310
|
+
!at.has(o) && i !== void 0 && (e[o] = i);
|
|
306
311
|
const s = {};
|
|
307
|
-
for (const [o, i] of Object.entries(
|
|
308
|
-
s[i] =
|
|
312
|
+
for (const [o, i] of Object.entries(ve))
|
|
313
|
+
s[i] = r[o];
|
|
309
314
|
return Object.keys(e).length > 0 && (s.props = e), s;
|
|
310
315
|
}
|
|
311
|
-
function
|
|
312
|
-
const { controller: e, layers: s } = Y("OmLayer"), { id: o } =
|
|
313
|
-
|
|
316
|
+
function yt(r) {
|
|
317
|
+
const { controller: e, layers: s } = Y("OmLayer"), { id: o } = r, i = lt(r);
|
|
318
|
+
E(() => {
|
|
314
319
|
s.upsert(i);
|
|
315
|
-
}),
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
const u =
|
|
319
|
-
return u.current =
|
|
320
|
-
() => e.watchPicks((
|
|
321
|
-
var
|
|
322
|
-
if (
|
|
323
|
-
(
|
|
320
|
+
}), E(() => () => s.remove(o), [s, o]);
|
|
321
|
+
const g = b(r.onClick);
|
|
322
|
+
g.current = r.onClick;
|
|
323
|
+
const u = b(r.onHover);
|
|
324
|
+
return u.current = r.onHover, E(
|
|
325
|
+
() => e.watchPicks((d) => {
|
|
326
|
+
var y, h, f;
|
|
327
|
+
if (d === null) {
|
|
328
|
+
(y = u.current) == null || y.call(u, null);
|
|
324
329
|
return;
|
|
325
330
|
}
|
|
326
|
-
|
|
331
|
+
d.layerId === o && (d.type === "click" ? (h = g.current) == null || h.call(g, d) : (f = u.current) == null || f.call(u, d));
|
|
327
332
|
}),
|
|
328
333
|
[e, o]
|
|
329
334
|
), null;
|
|
330
335
|
}
|
|
331
|
-
function
|
|
332
|
-
const { corners: u, widgetsHidden:
|
|
333
|
-
if (
|
|
334
|
-
if (
|
|
335
|
-
return f(
|
|
336
|
-
}, [
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
/* @__PURE__ */
|
|
336
|
+
function bt({ position: r = "top-start", order: e, fold: s, className: o, style: i, children: g }) {
|
|
337
|
+
const { corners: u, widgetsHidden: d, widgetsFolded: y, foldPanels: h, registerFoldedWidget: f, registerSlotWidget: T } = Y("OmWidget"), v = ge(), m = Ue(r) ?? "top-start", S = y && m !== "manual" && s !== "never", O = m === "manual" ? null : Qe(m);
|
|
338
|
+
if (E(() => {
|
|
339
|
+
if (O)
|
|
340
|
+
return f(O, v, S), () => f(O, v, !1);
|
|
341
|
+
}, [O, v, S, f]), E(() => {
|
|
342
|
+
if (m !== "manual")
|
|
343
|
+
return T(m, v, !0), () => T(m, v, !1);
|
|
344
|
+
}, [m, v, T]), m === "manual")
|
|
345
|
+
return /* @__PURE__ */ C("div", { className: o, style: { pointerEvents: "auto", ...i }, children: g });
|
|
346
|
+
const w = S && O ? h[O] : u[m];
|
|
347
|
+
return w ? be(
|
|
348
|
+
/* @__PURE__ */ C(
|
|
341
349
|
"div",
|
|
342
350
|
{
|
|
343
351
|
"data-om-react-widget": "",
|
|
344
|
-
"data-om-fold-origin-slot":
|
|
352
|
+
"data-om-fold-origin-slot": S ? m : void 0,
|
|
345
353
|
className: o,
|
|
346
354
|
style: {
|
|
347
355
|
...e !== void 0 ? { order: e } : void 0,
|
|
348
356
|
...i,
|
|
349
|
-
pointerEvents:
|
|
350
|
-
visibility:
|
|
357
|
+
pointerEvents: d ? "none" : (i == null ? void 0 : i.pointerEvents) ?? "auto",
|
|
358
|
+
visibility: d ? "hidden" : i == null ? void 0 : i.visibility
|
|
351
359
|
},
|
|
352
|
-
children:
|
|
360
|
+
children: g
|
|
353
361
|
}
|
|
354
362
|
),
|
|
355
|
-
|
|
363
|
+
w
|
|
356
364
|
) : null;
|
|
357
365
|
}
|
|
358
|
-
function
|
|
359
|
-
return e && (
|
|
366
|
+
function pe(r, e, s, o) {
|
|
367
|
+
return e && (r == null ? void 0 : r.layerId) !== e ? !1 : !s || (r ? r.type : o) === s;
|
|
360
368
|
}
|
|
361
|
-
const
|
|
369
|
+
const ct = {
|
|
362
370
|
"top-left": "translate(0, 0)",
|
|
363
371
|
"top-center": "translate(-50%, 0)",
|
|
364
372
|
"top-right": "translate(-100%, 0)",
|
|
@@ -369,52 +377,52 @@ const ot = {
|
|
|
369
377
|
"bottom-center": "translate(-50%, -100%)",
|
|
370
378
|
"bottom-right": "translate(-100%, -100%)"
|
|
371
379
|
};
|
|
372
|
-
function
|
|
373
|
-
const { controller: e, overlayPane: s } = Y("OmOverlay"), o =
|
|
374
|
-
|
|
375
|
-
const u =
|
|
376
|
-
const
|
|
377
|
-
let
|
|
380
|
+
function ht(r) {
|
|
381
|
+
const { controller: e, overlayPane: s } = Y("OmOverlay"), o = b(null), i = b(void 0), g = b(r);
|
|
382
|
+
g.current = r;
|
|
383
|
+
const u = $(() => {
|
|
384
|
+
const m = e.getStore("selection");
|
|
385
|
+
let S, O, w = null;
|
|
378
386
|
return {
|
|
379
|
-
subscribe:
|
|
387
|
+
subscribe: m.subscribe,
|
|
380
388
|
getSnapshot: () => {
|
|
381
|
-
const
|
|
382
|
-
return (
|
|
389
|
+
const P = m.getSnapshot(), { anchorFrom: M, layer: c, selectionType: j } = g.current, L = `${M ?? ""}|${c ?? ""}|${j ?? ""}`;
|
|
390
|
+
return (P !== S || L !== O) && (S = P, O = L, M === "selection" && pe(P, c, j, e.getLastPickType()) && (w = P)), w;
|
|
383
391
|
}
|
|
384
392
|
};
|
|
385
|
-
}, [e]),
|
|
393
|
+
}, [e]), d = ye(
|
|
386
394
|
u.subscribe,
|
|
387
395
|
u.getSnapshot,
|
|
388
396
|
u.getSnapshot
|
|
389
397
|
);
|
|
390
|
-
|
|
391
|
-
() => e.registerOverlay((
|
|
392
|
-
const
|
|
393
|
-
if (!
|
|
394
|
-
const { anchor:
|
|
395
|
-
let
|
|
396
|
-
if (
|
|
397
|
-
|
|
398
|
+
E(
|
|
399
|
+
() => e.registerOverlay((m, S, O) => {
|
|
400
|
+
const w = o.current;
|
|
401
|
+
if (!w) return;
|
|
402
|
+
const { anchor: P, anchorFrom: M, layer: c, selectionType: j, visible: L = !0, anchorOffset: G } = g.current;
|
|
403
|
+
let F;
|
|
404
|
+
if (M === "selection" ? (pe(S, c, j, O) && (i.current = (S == null ? void 0 : S.coordinate) ?? void 0), F = i.current) : F = P, !L || !F || !m) {
|
|
405
|
+
w.style.visibility = "hidden";
|
|
398
406
|
return;
|
|
399
407
|
}
|
|
400
|
-
const [
|
|
401
|
-
if (!(
|
|
402
|
-
|
|
408
|
+
const [z, x, W] = m.project([F[0], F[1], F[2] ?? 0]);
|
|
409
|
+
if (!(z >= 0 && z <= m.width && x >= 0 && x <= m.height) || W !== void 0 && W < 0) {
|
|
410
|
+
w.style.visibility = "hidden";
|
|
403
411
|
return;
|
|
404
412
|
}
|
|
405
|
-
|
|
413
|
+
w.style.visibility = "visible", w.style.transform = `translate(${z}px, ${x}px) ${ct[G ?? "bottom-center"]}`;
|
|
406
414
|
}),
|
|
407
415
|
[e]
|
|
408
|
-
),
|
|
416
|
+
), E(() => {
|
|
409
417
|
e.refreshOverlays();
|
|
410
418
|
});
|
|
411
|
-
const { children:
|
|
412
|
-
return
|
|
413
|
-
/* @__PURE__ */
|
|
419
|
+
const { children: y, className: h, style: f, interactive: T = !0 } = r, v = typeof y == "function" ? y(d) : y;
|
|
420
|
+
return be(
|
|
421
|
+
/* @__PURE__ */ C(
|
|
414
422
|
"div",
|
|
415
423
|
{
|
|
416
424
|
ref: o,
|
|
417
|
-
className:
|
|
425
|
+
className: h,
|
|
418
426
|
style: {
|
|
419
427
|
position: "absolute",
|
|
420
428
|
top: 0,
|
|
@@ -422,38 +430,38 @@ function mt(t) {
|
|
|
422
430
|
visibility: "hidden",
|
|
423
431
|
// hidden until the first flush positions it — never flashes at the origin
|
|
424
432
|
willChange: "transform",
|
|
425
|
-
pointerEvents:
|
|
433
|
+
pointerEvents: T ? "auto" : "none",
|
|
426
434
|
...f
|
|
427
435
|
},
|
|
428
|
-
children:
|
|
436
|
+
children: v
|
|
429
437
|
}
|
|
430
438
|
),
|
|
431
439
|
s
|
|
432
440
|
);
|
|
433
441
|
}
|
|
434
|
-
function
|
|
435
|
-
const { controller: e } = Y("useOmMap"), s =
|
|
436
|
-
const u = (s ? s.split(" ") : []).flatMap((
|
|
437
|
-
let
|
|
442
|
+
function vt(r = []) {
|
|
443
|
+
const { controller: e } = Y("useOmMap"), s = r.join(" "), o = $(() => {
|
|
444
|
+
const u = (s ? s.split(" ") : []).flatMap((y) => et(y) ? [e.getStore(y)] : (console.warn(`[onlymapjs] useOmMap: "${y}" is not a watch token on the React front-end — expected viewport, selection, layers, or data:<layerId>.`), []));
|
|
445
|
+
let d;
|
|
438
446
|
return {
|
|
439
|
-
subscribe: (
|
|
440
|
-
const
|
|
447
|
+
subscribe: (y) => {
|
|
448
|
+
const h = u.map((f) => f.subscribe(y));
|
|
441
449
|
return () => {
|
|
442
|
-
for (const f of
|
|
450
|
+
for (const f of h) f();
|
|
443
451
|
};
|
|
444
452
|
},
|
|
445
453
|
getSnapshot: () => {
|
|
446
|
-
const
|
|
447
|
-
return (!
|
|
454
|
+
const y = u.map((h) => h.getSnapshot());
|
|
455
|
+
return (!d || y.some((h, f) => h !== d[f])) && (d = y), d;
|
|
448
456
|
}
|
|
449
457
|
};
|
|
450
|
-
}, [e, s]), i =
|
|
451
|
-
return
|
|
458
|
+
}, [e, s]), i = ye(o.subscribe, o.getSnapshot, o.getSnapshot);
|
|
459
|
+
return $(() => e.buildCtx(), [e, i]);
|
|
452
460
|
}
|
|
453
461
|
export {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
462
|
+
yt as OmLayer,
|
|
463
|
+
gt as OmMap,
|
|
464
|
+
ht as OmOverlay,
|
|
465
|
+
bt as OmWidget,
|
|
466
|
+
vt as useOmMap
|
|
459
467
|
};
|