@nika-js/onlymap 0.4.0 → 0.4.2
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 +2 -2
- package/dist/{LercDecode.es-CWLcQT4F.js → LercDecode.es-CtFZNCJy.js} +1 -1
- package/dist/{basemap-CZupn0P2.js → basemap-DfeKYdar.js} +1 -1
- package/dist/elements/om-map.d.ts +61 -0
- package/dist/elements/om-widget.d.ts +15 -0
- package/dist/html-data.d.ts +2 -2
- package/dist/{index-C8uDiJN4.js → index-BcbVw4b7.js} +1 -1
- package/dist/{index-SWWESFOk.js → index-CU-Ft1NI.js} +2 -2
- package/dist/{index-Vw-Top85.js → index-CeAQFyJG.js} +1 -1
- package/dist/{index-CC4aVelb.js → index-PfwJVVKI.js} +1 -1
- package/dist/{index-BoxZ3Mec.js → index-ULsb51al.js} +11032 -10715
- package/dist/index.d.ts +2 -0
- package/dist/{lerc-CSc9BX_F.js → lerc-DsrKzmOh.js} +2 -2
- package/dist/onlymap.standalone.js +15793 -15476
- package/dist/onlymapjs.js +57 -49
- package/dist/{raster-DDi9gXqf.js → raster-CXnE4ZJp.js} +2 -2
- package/dist/react/context.d.ts +5 -3
- package/dist/react/om-map.d.ts +4 -0
- package/dist/react/om-widget.d.ts +4 -1
- package/dist/react.js +192 -196
- package/dist/version.d.ts +1 -1
- package/dist/widget-layout.d.ts +62 -0
- package/dist/widget-registry.d.ts +20 -0
- package/llms.txt +2 -2
- package/onlymapjs.html-data.json +59 -2
- package/package.json +2 -1
- package/skills/onlymapjs/SKILL.md +3 -1
- package/skills/onlymapjs/references/react.md +2 -2
- package/skills/onlymapjs/references/syntax.md +4 -3
package/dist/react.js
CHANGED
|
@@ -1,151 +1,144 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsxs as
|
|
5
|
-
import { createContext as
|
|
6
|
-
import { MapController as
|
|
7
|
-
import { createPortal as
|
|
8
|
-
const
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
if (!
|
|
12
|
-
return
|
|
1
|
+
var Z = Object.defineProperty;
|
|
2
|
+
var ee = (t, e, n) => e in t ? Z(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var B = (t, e, n) => ee(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { jsxs as te, jsx as w } from "react/jsx-runtime";
|
|
5
|
+
import { createContext as re, useContext as ne, forwardRef as se, useRef as m, useState as V, useCallback as oe, useMemo as x, useLayoutEffect as ie, useEffect as E, useImperativeHandle as ae, useSyncExternalStore as J } from "react";
|
|
6
|
+
import { MANAGED_SLOTS as ce, slotContainerStyle as le, MapController as ue, parseWidgetStyle as de, resolveSlot as fe, isStoreToken as ye } from "@nika-js/onlymap";
|
|
7
|
+
import { createPortal as Y } from "react-dom";
|
|
8
|
+
const Q = re(null);
|
|
9
|
+
function z(t) {
|
|
10
|
+
const e = ne(Q);
|
|
11
|
+
if (!e) throw new Error(`[onlymapjs] ${t} must be rendered inside <OmMap>.`);
|
|
12
|
+
return e;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
17
|
-
return
|
|
14
|
+
function W(t, e) {
|
|
15
|
+
if (t === e) return !0;
|
|
16
|
+
const n = Object.keys(t ?? {}), r = Object.keys(e ?? {});
|
|
17
|
+
return n.length !== r.length ? !1 : n.every((l) => t[l] === e[l]);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
const { props:
|
|
21
|
-
return
|
|
19
|
+
function me(t, e) {
|
|
20
|
+
const { props: n, updateTriggers: r, ...l } = t, { props: d, updateTriggers: c, ...o } = e;
|
|
21
|
+
return W(l, o) && W(n, d) && W(r, c);
|
|
22
22
|
}
|
|
23
|
-
class
|
|
24
|
-
constructor(
|
|
25
|
-
|
|
26
|
-
this.controller =
|
|
23
|
+
class ge {
|
|
24
|
+
constructor(e) {
|
|
25
|
+
B(this, "descriptors", /* @__PURE__ */ new Map());
|
|
26
|
+
this.controller = e;
|
|
27
27
|
}
|
|
28
|
-
upsert(
|
|
29
|
-
const
|
|
30
|
-
|
|
28
|
+
upsert(e) {
|
|
29
|
+
const n = this.descriptors.get(e.id);
|
|
30
|
+
n && me(n, e) || (this.descriptors.set(e.id, e), this.controller.setLayers([...this.descriptors.values()]));
|
|
31
31
|
}
|
|
32
|
-
remove(
|
|
33
|
-
this.descriptors.delete(
|
|
32
|
+
remove(e) {
|
|
33
|
+
this.descriptors.delete(e) && this.controller.setLayers([...this.descriptors.values()]);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
function
|
|
38
|
-
return
|
|
39
|
-
position: "absolute",
|
|
40
|
-
[e.startsWith("top") ? "top" : "bottom"]: 10,
|
|
41
|
-
[e.endsWith("left") ? "left" : "right"]: 10,
|
|
42
|
-
display: "flex",
|
|
43
|
-
flexDirection: "column",
|
|
44
|
-
gap: 8,
|
|
45
|
-
alignItems: e.endsWith("left") ? "flex-start" : "flex-end",
|
|
46
|
-
zIndex: 20,
|
|
47
|
-
// The container never intercepts the map's pointer events; each
|
|
48
|
-
// <OmWidget> shell re-enables its own.
|
|
49
|
-
pointerEvents: "none"
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function ue(e, t) {
|
|
53
|
-
return Object.entries(t).some(([s, r]) => r !== void 0 && e[s] !== r);
|
|
36
|
+
const $ = ce, he = Object.fromEntries($.map((t) => [t, le(t)]));
|
|
37
|
+
function be(t, e) {
|
|
38
|
+
return Object.entries(e).some(([n, r]) => r !== void 0 && t[n] !== r);
|
|
54
39
|
}
|
|
55
|
-
const
|
|
56
|
-
const { center: r, zoom:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}), R = re((i) => {
|
|
62
|
-
C((y) => y === i ? y : i);
|
|
63
|
-
}, []), j = T(
|
|
40
|
+
const Ce = se(function(e, n) {
|
|
41
|
+
const { center: r, zoom: l, pitch: d, bearing: c, basemap: o, basemapKey: a, attribution: f, headless: u, widgetStyle: v, widgetsHidden: L, className: h, style: b, children: g } = e, p = m(null), [s, R] = V(null), [S, T] = V(null), [O, k] = V(
|
|
42
|
+
() => Object.fromEntries($.map((i) => [i, null]))
|
|
43
|
+
), j = oe((i) => {
|
|
44
|
+
T((y) => y === i ? y : i);
|
|
45
|
+
}, []), P = x(
|
|
64
46
|
() => Object.fromEntries(
|
|
65
|
-
|
|
47
|
+
$.map((i) => [
|
|
66
48
|
i,
|
|
67
49
|
(y) => {
|
|
68
|
-
|
|
50
|
+
k((M) => M[i] === y ? M : { ...M, [i]: y });
|
|
69
51
|
}
|
|
70
52
|
])
|
|
71
53
|
),
|
|
72
54
|
[]
|
|
73
|
-
),
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
if (!
|
|
86
|
-
const i =
|
|
87
|
-
|
|
88
|
-
const y = new
|
|
55
|
+
), _ = m({ center: r, zoom: l, pitch: d, bearing: c });
|
|
56
|
+
_.current = { center: r, zoom: l, pitch: d, bearing: c };
|
|
57
|
+
const F = m(e.onReady);
|
|
58
|
+
F.current = e.onReady;
|
|
59
|
+
const C = m(e.onViewStateChange);
|
|
60
|
+
C.current = e.onViewStateChange;
|
|
61
|
+
const K = m(e.onRuntimeError);
|
|
62
|
+
K.current = e.onRuntimeError;
|
|
63
|
+
const A = m(o);
|
|
64
|
+
A.current = o;
|
|
65
|
+
const D = m(void 0), U = u ? JSON.stringify(u) : "";
|
|
66
|
+
ie(() => {
|
|
67
|
+
if (!p.current) return;
|
|
68
|
+
const i = _.current;
|
|
69
|
+
D.current = A.current;
|
|
70
|
+
const y = new ue(p.current, {
|
|
89
71
|
center: i.center,
|
|
90
72
|
zoom: i.zoom,
|
|
91
73
|
pitch: i.pitch,
|
|
92
74
|
bearing: i.bearing,
|
|
93
|
-
basemap:
|
|
94
|
-
basemapKey:
|
|
95
|
-
attribution:
|
|
96
|
-
headless:
|
|
75
|
+
basemap: A.current,
|
|
76
|
+
basemapKey: a,
|
|
77
|
+
attribution: f,
|
|
78
|
+
headless: u ? u === !0 ? {} : u : void 0,
|
|
97
79
|
onRuntimeError: (I) => {
|
|
98
|
-
var
|
|
99
|
-
return (
|
|
80
|
+
var q;
|
|
81
|
+
return (q = K.current) == null ? void 0 : q.call(K, I);
|
|
100
82
|
}
|
|
101
83
|
});
|
|
102
|
-
|
|
84
|
+
R(y);
|
|
103
85
|
let M = !0;
|
|
104
86
|
return y.ready.then(() => {
|
|
105
87
|
var I;
|
|
106
|
-
M && ((I =
|
|
88
|
+
M && ((I = F.current) == null || I.call(F));
|
|
107
89
|
}), () => {
|
|
108
|
-
M = !1,
|
|
90
|
+
M = !1, R(null), y.destroy();
|
|
109
91
|
};
|
|
110
|
-
}, [
|
|
111
|
-
!
|
|
112
|
-
}, [
|
|
113
|
-
if (!
|
|
114
|
-
const i = { longitude: r == null ? void 0 : r[0], latitude: r == null ? void 0 : r[1], zoom:
|
|
115
|
-
|
|
116
|
-
}, [
|
|
92
|
+
}, [U]), E(() => {
|
|
93
|
+
!s || D.current === o || (D.current = o, s.setBasemap(o ?? null));
|
|
94
|
+
}, [s, o]), ae(n, () => s, [s]), E(() => {
|
|
95
|
+
if (!s) return;
|
|
96
|
+
const i = { longitude: r == null ? void 0 : r[0], latitude: r == null ? void 0 : r[1], zoom: l, pitch: d, bearing: c };
|
|
97
|
+
be(s.getViewState(), i) && s.setView(i);
|
|
98
|
+
}, [s, r == null ? void 0 : r[0], r == null ? void 0 : r[1], l, d, c]), E(() => {
|
|
117
99
|
var i;
|
|
118
|
-
if (
|
|
119
|
-
return (i =
|
|
100
|
+
if (s)
|
|
101
|
+
return (i = C.current) == null || i.call(C, s.getViewState()), s.getStore("viewport").subscribe(() => {
|
|
120
102
|
var y;
|
|
121
|
-
return (y =
|
|
103
|
+
return (y = C.current) == null ? void 0 : y.call(C, s.getViewState());
|
|
122
104
|
});
|
|
123
|
-
}, [
|
|
124
|
-
const
|
|
125
|
-
() =>
|
|
126
|
-
|
|
105
|
+
}, [s]);
|
|
106
|
+
const X = x(
|
|
107
|
+
() => ({
|
|
108
|
+
position: "absolute",
|
|
109
|
+
inset: 0,
|
|
110
|
+
zIndex: 20,
|
|
111
|
+
pointerEvents: "none",
|
|
112
|
+
opacity: "var(--om-widget-opacity, 1)",
|
|
113
|
+
...L ? { visibility: "hidden" } : void 0,
|
|
114
|
+
...v ? de(v).properties : void 0
|
|
115
|
+
}),
|
|
116
|
+
[v, L]
|
|
117
|
+
), N = x(() => s ? new ge(s) : null, [s]), H = x(
|
|
118
|
+
() => s && N && S ? { controller: s, layers: N, overlayPane: S, corners: O } : null,
|
|
119
|
+
[s, N, S, O]
|
|
127
120
|
);
|
|
128
|
-
return /* @__PURE__ */
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
-
/* @__PURE__ */
|
|
121
|
+
return /* @__PURE__ */ te("div", { className: h, style: { position: "relative", overflow: "hidden", ...b }, children: [
|
|
122
|
+
/* @__PURE__ */ w("div", { ref: p, style: { position: "absolute", inset: 0 } }),
|
|
123
|
+
/* @__PURE__ */ w(
|
|
131
124
|
"div",
|
|
132
125
|
{
|
|
133
|
-
ref:
|
|
126
|
+
ref: j,
|
|
134
127
|
style: { position: "absolute", top: 0, left: 0, zIndex: 10, pointerEvents: "none" }
|
|
135
128
|
}
|
|
136
129
|
),
|
|
137
|
-
|
|
130
|
+
/* @__PURE__ */ w("div", { "data-om-widget-layer": "", style: X, children: $.map((i) => /* @__PURE__ */ w(
|
|
138
131
|
"div",
|
|
139
132
|
{
|
|
140
|
-
"data-om-widget-
|
|
141
|
-
ref:
|
|
142
|
-
style:
|
|
133
|
+
"data-om-widget-slot": i,
|
|
134
|
+
ref: P[i],
|
|
135
|
+
style: he[i]
|
|
143
136
|
},
|
|
144
137
|
i
|
|
145
|
-
)),
|
|
146
|
-
|
|
138
|
+
)) }),
|
|
139
|
+
H && /* @__PURE__ */ w(Q.Provider, { value: H, children: g })
|
|
147
140
|
] });
|
|
148
|
-
}),
|
|
141
|
+
}), ve = /* @__PURE__ */ new Set([
|
|
149
142
|
"id",
|
|
150
143
|
"type",
|
|
151
144
|
"data",
|
|
@@ -165,58 +158,61 @@ const ve = te(function(t, s) {
|
|
|
165
158
|
"onClick",
|
|
166
159
|
"onHover"
|
|
167
160
|
]);
|
|
168
|
-
function
|
|
169
|
-
const { controller:
|
|
170
|
-
for (const [
|
|
171
|
-
!
|
|
172
|
-
const
|
|
161
|
+
function xe(t) {
|
|
162
|
+
const { controller: e, layers: n } = z("OmLayer"), { id: r } = t, l = {};
|
|
163
|
+
for (const [a, f] of Object.entries(t))
|
|
164
|
+
!ve.has(a) && f !== void 0 && (l[a] = f);
|
|
165
|
+
const d = {
|
|
173
166
|
id: r,
|
|
174
|
-
type:
|
|
175
|
-
data:
|
|
176
|
-
label:
|
|
177
|
-
color:
|
|
178
|
-
filterField:
|
|
179
|
-
filterRange:
|
|
180
|
-
filterSoftRange:
|
|
181
|
-
filterCategoryField:
|
|
182
|
-
filterCategories:
|
|
183
|
-
source:
|
|
184
|
-
key:
|
|
185
|
-
flush:
|
|
186
|
-
refresh:
|
|
187
|
-
terrain:
|
|
188
|
-
updateTriggers:
|
|
189
|
-
props:
|
|
167
|
+
type: t.type,
|
|
168
|
+
data: t.data,
|
|
169
|
+
label: t.label,
|
|
170
|
+
color: t.color,
|
|
171
|
+
filterField: t.filterField,
|
|
172
|
+
filterRange: t.filterRange,
|
|
173
|
+
filterSoftRange: t.filterSoftRange,
|
|
174
|
+
filterCategoryField: t.filterCategoryField,
|
|
175
|
+
filterCategories: t.filterCategories,
|
|
176
|
+
source: t.source,
|
|
177
|
+
key: t.streamKey,
|
|
178
|
+
flush: t.flush,
|
|
179
|
+
refresh: t.refresh,
|
|
180
|
+
terrain: t.terrain,
|
|
181
|
+
updateTriggers: t.updateTriggers,
|
|
182
|
+
props: l
|
|
190
183
|
};
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}),
|
|
194
|
-
const c = m(
|
|
195
|
-
c.current =
|
|
196
|
-
const o = m(
|
|
197
|
-
return o.current =
|
|
198
|
-
() =>
|
|
199
|
-
var
|
|
200
|
-
if (
|
|
201
|
-
(
|
|
184
|
+
E(() => {
|
|
185
|
+
n.upsert(d);
|
|
186
|
+
}), E(() => () => n.remove(r), [n, r]);
|
|
187
|
+
const c = m(t.onClick);
|
|
188
|
+
c.current = t.onClick;
|
|
189
|
+
const o = m(t.onHover);
|
|
190
|
+
return o.current = t.onHover, E(
|
|
191
|
+
() => e.watchPicks((a) => {
|
|
192
|
+
var f, u, v;
|
|
193
|
+
if (a === null) {
|
|
194
|
+
(f = o.current) == null || f.call(o, null);
|
|
202
195
|
return;
|
|
203
196
|
}
|
|
204
|
-
|
|
197
|
+
a.layerId === r && (a.type === "click" ? (u = c.current) == null || u.call(c, a) : (v = o.current) == null || v.call(o, a));
|
|
205
198
|
}),
|
|
206
|
-
[
|
|
199
|
+
[e, r]
|
|
207
200
|
), null;
|
|
208
201
|
}
|
|
209
|
-
function
|
|
210
|
-
const { corners:
|
|
211
|
-
|
|
212
|
-
/* @__PURE__ */
|
|
213
|
-
|
|
202
|
+
function Te({ position: t = "top-start", order: e, className: n, style: r, children: l }) {
|
|
203
|
+
const { corners: d } = z("OmWidget"), c = fe(t) ?? "top-start";
|
|
204
|
+
if (c === "manual")
|
|
205
|
+
return /* @__PURE__ */ w("div", { className: n, style: { pointerEvents: "auto", ...r }, children: l });
|
|
206
|
+
const o = d[c];
|
|
207
|
+
return o ? Y(
|
|
208
|
+
/* @__PURE__ */ w("div", { className: n, style: { pointerEvents: "auto", ...e !== void 0 ? { order: e } : void 0, ...r }, children: l }),
|
|
209
|
+
o
|
|
214
210
|
) : null;
|
|
215
211
|
}
|
|
216
|
-
function
|
|
217
|
-
return !
|
|
212
|
+
function G(t, e) {
|
|
213
|
+
return !e || (t == null ? void 0 : t.layerId) === e;
|
|
218
214
|
}
|
|
219
|
-
const
|
|
215
|
+
const pe = {
|
|
220
216
|
"top-left": "translate(0, 0)",
|
|
221
217
|
"top-center": "translate(-50%, 0)",
|
|
222
218
|
"top-right": "translate(-100%, 0)",
|
|
@@ -227,52 +223,52 @@ const de = {
|
|
|
227
223
|
"bottom-center": "translate(-50%, -100%)",
|
|
228
224
|
"bottom-right": "translate(-100%, -100%)"
|
|
229
225
|
};
|
|
230
|
-
function
|
|
231
|
-
const { controller:
|
|
232
|
-
|
|
233
|
-
const c =
|
|
234
|
-
const
|
|
235
|
-
let
|
|
226
|
+
function Me(t) {
|
|
227
|
+
const { controller: e, overlayPane: n } = z("OmOverlay"), r = m(null), l = m(void 0), d = m(t);
|
|
228
|
+
d.current = t;
|
|
229
|
+
const c = x(() => {
|
|
230
|
+
const h = e.getStore("selection");
|
|
231
|
+
let b, g, p = null;
|
|
236
232
|
return {
|
|
237
|
-
subscribe:
|
|
233
|
+
subscribe: h.subscribe,
|
|
238
234
|
getSnapshot: () => {
|
|
239
|
-
const
|
|
240
|
-
return (
|
|
235
|
+
const s = h.getSnapshot(), { anchorFrom: R, layer: S } = d.current, T = `${R ?? ""}|${S ?? ""}`;
|
|
236
|
+
return (s !== b || T !== g) && (b = s, g = T, R === "selection" && G(s, S) && (p = s)), p;
|
|
241
237
|
}
|
|
242
238
|
};
|
|
243
|
-
}, [
|
|
239
|
+
}, [e]), o = J(
|
|
244
240
|
c.subscribe,
|
|
245
241
|
c.getSnapshot,
|
|
246
242
|
c.getSnapshot
|
|
247
243
|
);
|
|
248
|
-
|
|
249
|
-
() =>
|
|
250
|
-
const
|
|
251
|
-
if (!
|
|
252
|
-
const { anchor:
|
|
253
|
-
let
|
|
254
|
-
if (
|
|
255
|
-
|
|
244
|
+
E(
|
|
245
|
+
() => e.registerOverlay((h, b) => {
|
|
246
|
+
const g = r.current;
|
|
247
|
+
if (!g) return;
|
|
248
|
+
const { anchor: p, anchorFrom: s, layer: R, visible: S = !0, anchorOffset: T } = d.current;
|
|
249
|
+
let O;
|
|
250
|
+
if (s === "selection" ? (G(b, R) && (l.current = (b == null ? void 0 : b.coordinate) ?? void 0), O = l.current) : O = p, !S || !O || !h) {
|
|
251
|
+
g.style.visibility = "hidden";
|
|
256
252
|
return;
|
|
257
253
|
}
|
|
258
|
-
const [
|
|
259
|
-
if (!(
|
|
260
|
-
|
|
254
|
+
const [k, j, P] = h.project([O[0], O[1], 0]);
|
|
255
|
+
if (!(k >= 0 && k <= h.width && j >= 0 && j <= h.height) || P !== void 0 && P < 0) {
|
|
256
|
+
g.style.visibility = "hidden";
|
|
261
257
|
return;
|
|
262
258
|
}
|
|
263
|
-
|
|
259
|
+
g.style.visibility = "visible", g.style.transform = `translate(${k}px, ${j}px) ${pe[T ?? "bottom-center"]}`;
|
|
264
260
|
}),
|
|
265
|
-
[
|
|
266
|
-
),
|
|
267
|
-
|
|
261
|
+
[e]
|
|
262
|
+
), E(() => {
|
|
263
|
+
e.refreshOverlays();
|
|
268
264
|
});
|
|
269
|
-
const { children:
|
|
270
|
-
return
|
|
271
|
-
/* @__PURE__ */
|
|
265
|
+
const { children: a, className: f, style: u, interactive: v = !0 } = t, L = typeof a == "function" ? a(o) : a;
|
|
266
|
+
return Y(
|
|
267
|
+
/* @__PURE__ */ w(
|
|
272
268
|
"div",
|
|
273
269
|
{
|
|
274
270
|
ref: r,
|
|
275
|
-
className:
|
|
271
|
+
className: f,
|
|
276
272
|
style: {
|
|
277
273
|
position: "absolute",
|
|
278
274
|
top: 0,
|
|
@@ -280,38 +276,38 @@ function Oe(e) {
|
|
|
280
276
|
visibility: "hidden",
|
|
281
277
|
// hidden until the first flush positions it — never flashes at the origin
|
|
282
278
|
willChange: "transform",
|
|
283
|
-
pointerEvents:
|
|
284
|
-
...
|
|
279
|
+
pointerEvents: v ? "auto" : "none",
|
|
280
|
+
...u
|
|
285
281
|
},
|
|
286
282
|
children: L
|
|
287
283
|
}
|
|
288
284
|
),
|
|
289
|
-
|
|
285
|
+
n
|
|
290
286
|
);
|
|
291
287
|
}
|
|
292
|
-
function
|
|
293
|
-
const { controller:
|
|
294
|
-
const c = (
|
|
288
|
+
function ke(t = []) {
|
|
289
|
+
const { controller: e } = z("useOmMap"), n = t.join(" "), r = x(() => {
|
|
290
|
+
const c = (n ? n.split(" ") : []).flatMap((a) => ye(a) ? [e.getStore(a)] : (console.warn(`[onlymapjs] useOmMap: "${a}" is not a watch token on the React front-end — expected viewport, selection, layers, or data:<layerId>.`), []));
|
|
295
291
|
let o;
|
|
296
292
|
return {
|
|
297
|
-
subscribe: (
|
|
298
|
-
const
|
|
293
|
+
subscribe: (a) => {
|
|
294
|
+
const f = c.map((u) => u.subscribe(a));
|
|
299
295
|
return () => {
|
|
300
|
-
for (const
|
|
296
|
+
for (const u of f) u();
|
|
301
297
|
};
|
|
302
298
|
},
|
|
303
299
|
getSnapshot: () => {
|
|
304
|
-
const
|
|
305
|
-
return (!o ||
|
|
300
|
+
const a = c.map((f) => f.getSnapshot());
|
|
301
|
+
return (!o || a.some((f, u) => f !== o[u])) && (o = a), o;
|
|
306
302
|
}
|
|
307
303
|
};
|
|
308
|
-
}, [
|
|
309
|
-
return
|
|
304
|
+
}, [e, n]), l = J(r.subscribe, r.getSnapshot, r.getSnapshot);
|
|
305
|
+
return x(() => e.buildCtx(), [e, l]);
|
|
310
306
|
}
|
|
311
307
|
export {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
308
|
+
xe as OmLayer,
|
|
309
|
+
Ce as OmMap,
|
|
310
|
+
Me as OmOverlay,
|
|
311
|
+
Te as OmWidget,
|
|
312
|
+
ke as useOmMap
|
|
317
313
|
};
|
package/dist/version.d.ts
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widget layout vocabulary (spec: "Widget Layout Manager") — the shared,
|
|
3
|
+
* framework-free half of the slot system: slot names, legacy-corner
|
|
4
|
+
* aliasing, per-slot flex layout parameters, and the `widget-style` token
|
|
5
|
+
* sugar parser. Both front-ends derive their containers from THIS table
|
|
6
|
+
* (the HTML lane as cssText, the React lane as CSSProperties) so the two
|
|
7
|
+
* lanes cannot drift on placement semantics.
|
|
8
|
+
*
|
|
9
|
+
* Names are LOGICAL and RTL-aware: `-start`/`-end` map to CSS
|
|
10
|
+
* `inset-inline-*` and flex alignment, so an RTL document mirrors the
|
|
11
|
+
* whole chrome without any per-widget work. Legacy corner names stay as
|
|
12
|
+
* aliases mapped logically (`top-left` → `top-start`), which means legacy
|
|
13
|
+
* manifests mirror correctly under RTL too — physical-corner fidelity is
|
|
14
|
+
* deliberately NOT preserved there.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MANAGED_SLOTS: readonly ["top-start", "top-center", "top-end", "center-start", "center-end", "bottom-start", "bottom-center", "bottom-end"];
|
|
17
|
+
export type ManagedSlot = (typeof MANAGED_SLOTS)[number];
|
|
18
|
+
/** A widget's resolved placement: a managed slot, or the author-styled manual tier. */
|
|
19
|
+
export type WidgetSlot = ManagedSlot | "manual";
|
|
20
|
+
/** Legacy 4-corner vocabulary (pre-0.4.1) — accepted forever, mapped LOGICALLY. */
|
|
21
|
+
export declare const LEGACY_POSITION_ALIASES: Readonly<Record<string, ManagedSlot>>;
|
|
22
|
+
/** Every accepted `position` value (validation + html-data). */
|
|
23
|
+
export declare const ALL_POSITION_VALUES: readonly string[];
|
|
24
|
+
/**
|
|
25
|
+
* `position` attribute/prop → slot. Absent/empty → the default `top-start`
|
|
26
|
+
* (today's `top-left` default, aliased). Unknown values → null; callers
|
|
27
|
+
* warn and fall back to the default (validation carries the loud version).
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveSlot(raw: string | null | undefined): WidgetSlot | null;
|
|
30
|
+
export interface SlotLayout {
|
|
31
|
+
/** Stack axis: edge-center slots run ALONG their edge (row); everything else stacks as a column. */
|
|
32
|
+
axis: "column" | "row";
|
|
33
|
+
block: "top" | "center" | "bottom";
|
|
34
|
+
inline: "start" | "center" | "end";
|
|
35
|
+
}
|
|
36
|
+
export declare function slotLayout(slot: ManagedSlot): SlotLayout;
|
|
37
|
+
/**
|
|
38
|
+
* The slot container's styles as a camelCase style object — ONE builder for
|
|
39
|
+
* both front-ends (the React lane spreads it as CSSProperties; the HTML
|
|
40
|
+
* lane serializes it to cssText), so the lanes cannot drift on placement.
|
|
41
|
+
* Insets/gaps read the layout tokens with the pre-0.4.1 constants as
|
|
42
|
+
* fallbacks (12px inset, 8px gap), so a single-widget legacy corner renders
|
|
43
|
+
* pixel-identically. Containers never intercept the map's pointer events;
|
|
44
|
+
* each widget re-enables its own.
|
|
45
|
+
*/
|
|
46
|
+
export declare function slotContainerStyle(slot: ManagedSlot): Record<string, string | number>;
|
|
47
|
+
/** The HTML lane's serialization of slotContainerStyle. */
|
|
48
|
+
export declare function slotContainerCssText(slot: ManagedSlot): string;
|
|
49
|
+
export declare const WIDGET_STYLE_KEY_NAMES: readonly string[];
|
|
50
|
+
export interface WidgetStyleParse {
|
|
51
|
+
/** Custom property → CSS value, ready for style.setProperty. */
|
|
52
|
+
properties: Record<string, string>;
|
|
53
|
+
/** Unparseable entries (unknown key / non-numeric value) — validation's loud half; the live path skips them. */
|
|
54
|
+
errors: string[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* `widget-style="gap:10 opacity:0.9 inset-x:16"` → custom properties — the
|
|
58
|
+
* no-CSS token surface for agents/authors. Space-separated `key:value`
|
|
59
|
+
* pairs; numbers get `px` except opacity. One parser serves the live path
|
|
60
|
+
* (om-map attr → host properties) and validation.
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseWidgetStyle(raw: string): WidgetStyleParse;
|
|
@@ -19,7 +19,27 @@ export interface WidgetHost {
|
|
|
19
19
|
export interface WidgetImpl {
|
|
20
20
|
/** Default watch tokens when the element has no `watch` attribute. */
|
|
21
21
|
watch?: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Compact button widget (spec: "Widget Layout Manager / Button
|
|
24
|
+
* clustering") — adjacent compact widgets in one slot auto-merge into a
|
|
25
|
+
* single visual control group (shared rounded container, dividers, one
|
|
26
|
+
* shadow). Per-widget opt-out: `cluster="false"`. Non-compact widgets
|
|
27
|
+
* (panels: legend, filter, search) never cluster.
|
|
28
|
+
*/
|
|
29
|
+
compact?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Never affected by hide-all (spec: "Widget Layout Manager / Hide-all") —
|
|
32
|
+
* `widgets-hidden` leaves this widget visible. Attribution declares it
|
|
33
|
+
* (license compliance) and so does the widgets-toggle button (it must
|
|
34
|
+
* stay clickable to un-hide). Third-party always-visible chrome sets it
|
|
35
|
+
* here rather than the core hardcoding a type list.
|
|
36
|
+
*/
|
|
37
|
+
neverHides?: boolean;
|
|
22
38
|
render(ctx: RuntimeContext, host: WidgetHost): void | Promise<void>;
|
|
23
39
|
}
|
|
40
|
+
/** Clusterable (spec: "Widget Layout Manager") — the type is compact AND the author didn't opt out. One predicate for the cluster pass AND the validation lint. */
|
|
41
|
+
export declare function isClusterableWidget(el: Element): boolean;
|
|
42
|
+
/** Exempt from hide-all — the type declares `neverHides` (attribution, widgets-toggle). */
|
|
43
|
+
export declare function widgetNeverHides(type: string | null): boolean;
|
|
24
44
|
export declare function registerWidget(name: string, impl: WidgetImpl): void;
|
|
25
45
|
export declare function getWidget(name: string): WidgetImpl | undefined;
|