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