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