@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/dist/react.js CHANGED
@@ -1,151 +1,144 @@
1
- var U = Object.defineProperty;
2
- var X = (e, t, s) => t in e ? U(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var A = (e, t, s) => X(e, typeof t != "symbol" ? t + "" : t, s);
4
- import { jsxs as Y, jsx as P } from "react/jsx-runtime";
5
- import { createContext as Z, useContext as ee, forwardRef as te, useRef as m, useState as W, useCallback as re, useMemo as T, useLayoutEffect as ne, useEffect as p, useImperativeHandle as se, useSyncExternalStore as H } from "react";
6
- import { MapController as oe, isStoreToken as le } from "@nika-js/onlymap";
7
- import { createPortal as G } from "react-dom";
8
- const J = Z(null);
9
- function K(e) {
10
- const t = ee(J);
11
- if (!t) throw new Error(`[onlymapjs] ${e} must be rendered inside <OmMap>.`);
12
- return t;
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 D(e, t) {
15
- if (e === t) return !0;
16
- const s = Object.keys(e ?? {}), r = Object.keys(t ?? {});
17
- return s.length !== r.length ? !1 : s.every((a) => e[a] === t[a]);
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 ie(e, t) {
20
- const { props: s, updateTriggers: r, ...a } = e, { props: u, updateTriggers: c, ...o } = t;
21
- return D(a, o) && D(s, u) && D(r, c);
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 ae {
24
- constructor(t) {
25
- A(this, "descriptors", /* @__PURE__ */ new Map());
26
- this.controller = t;
23
+ class ge {
24
+ constructor(e) {
25
+ B(this, "descriptors", /* @__PURE__ */ new Map());
26
+ this.controller = e;
27
27
  }
28
- upsert(t) {
29
- const s = this.descriptors.get(t.id);
30
- s && ie(s, t) || (this.descriptors.set(t.id, t), this.controller.setLayers([...this.descriptors.values()]));
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(t) {
33
- this.descriptors.delete(t) && this.controller.setLayers([...this.descriptors.values()]);
32
+ remove(e) {
33
+ this.descriptors.delete(e) && this.controller.setLayers([...this.descriptors.values()]);
34
34
  }
35
35
  }
36
- const q = ["top-left", "top-right", "bottom-left", "bottom-right"];
37
- function ce(e) {
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 ve = te(function(t, s) {
56
- const { center: r, zoom: a, pitch: u, bearing: c, basemap: o, basemapKey: l, attribution: d, headless: f, className: w, style: L, children: b } = t, h = m(null), [n, S] = W(null), [g, C] = W(null), [O, E] = W({
57
- "top-left": null,
58
- "top-right": null,
59
- "bottom-left": null,
60
- "bottom-right": null
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
- q.map((i) => [
47
+ $.map((i) => [
66
48
  i,
67
49
  (y) => {
68
- E((M) => M[i] === y ? M : { ...M, [i]: y });
50
+ k((M) => M[i] === y ? M : { ...M, [i]: y });
69
51
  }
70
52
  ])
71
53
  ),
72
54
  []
73
- ), k = m({ center: r, zoom: a, pitch: u, bearing: c });
74
- k.current = { center: r, zoom: a, pitch: u, bearing: c };
75
- const x = m(t.onReady);
76
- x.current = t.onReady;
77
- const v = m(t.onViewStateChange);
78
- v.current = t.onViewStateChange;
79
- const F = m(t.onRuntimeError);
80
- F.current = t.onRuntimeError;
81
- const $ = m(o);
82
- $.current = o;
83
- const z = m(void 0), Q = f ? JSON.stringify(f) : "";
84
- ne(() => {
85
- if (!h.current) return;
86
- const i = k.current;
87
- z.current = $.current;
88
- const y = new oe(h.current, {
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: $.current,
94
- basemapKey: l,
95
- attribution: d,
96
- headless: f ? f === !0 ? {} : f : void 0,
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 (_ = F.current) == null ? void 0 : _.call(F, I);
80
+ var q;
81
+ return (q = K.current) == null ? void 0 : q.call(K, I);
100
82
  }
101
83
  });
102
- S(y);
84
+ R(y);
103
85
  let M = !0;
104
86
  return y.ready.then(() => {
105
87
  var I;
106
- M && ((I = x.current) == null || I.call(x));
88
+ M && ((I = F.current) == null || I.call(F));
107
89
  }), () => {
108
- M = !1, S(null), y.destroy();
90
+ M = !1, R(null), y.destroy();
109
91
  };
110
- }, [Q]), p(() => {
111
- !n || z.current === o || (z.current = o, n.setBasemap(o ?? null));
112
- }, [n, o]), se(s, () => n, [n]), p(() => {
113
- if (!n) return;
114
- const i = { longitude: r == null ? void 0 : r[0], latitude: r == null ? void 0 : r[1], zoom: a, pitch: u, bearing: c };
115
- ue(n.getViewState(), i) && n.setView(i);
116
- }, [n, r == null ? void 0 : r[0], r == null ? void 0 : r[1], a, u, c]), p(() => {
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 (n)
119
- return (i = v.current) == null || i.call(v, n.getViewState()), n.getStore("viewport").subscribe(() => {
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 = v.current) == null ? void 0 : y.call(v, n.getViewState());
103
+ return (y = C.current) == null ? void 0 : y.call(C, s.getViewState());
122
104
  });
123
- }, [n]);
124
- const N = T(() => n ? new ae(n) : null, [n]), V = T(
125
- () => n && N && g ? { controller: n, layers: N, overlayPane: g, corners: O } : null,
126
- [n, N, g, O]
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__ */ Y("div", { className: w, style: { position: "relative", overflow: "hidden", ...L }, children: [
129
- /* @__PURE__ */ P("div", { ref: h, style: { position: "absolute", inset: 0 } }),
130
- /* @__PURE__ */ P(
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: R,
126
+ ref: j,
134
127
  style: { position: "absolute", top: 0, left: 0, zIndex: 10, pointerEvents: "none" }
135
128
  }
136
129
  ),
137
- q.map((i) => /* @__PURE__ */ P(
130
+ /* @__PURE__ */ w("div", { "data-om-widget-layer": "", style: X, children: $.map((i) => /* @__PURE__ */ w(
138
131
  "div",
139
132
  {
140
- "data-om-widget-corner": i,
141
- ref: j[i],
142
- style: ce(i)
133
+ "data-om-widget-slot": i,
134
+ ref: P[i],
135
+ style: he[i]
143
136
  },
144
137
  i
145
- )),
146
- V && /* @__PURE__ */ P(J.Provider, { value: V, children: b })
138
+ )) }),
139
+ H && /* @__PURE__ */ w(Q.Provider, { value: H, children: g })
147
140
  ] });
148
- }), fe = /* @__PURE__ */ new Set([
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 pe(e) {
169
- const { controller: t, layers: s } = K("OmLayer"), { id: r } = e, a = {};
170
- for (const [l, d] of Object.entries(e))
171
- !fe.has(l) && d !== void 0 && (a[l] = d);
172
- const u = {
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: e.type,
175
- data: e.data,
176
- label: e.label,
177
- color: e.color,
178
- filterField: e.filterField,
179
- filterRange: e.filterRange,
180
- filterSoftRange: e.filterSoftRange,
181
- filterCategoryField: e.filterCategoryField,
182
- filterCategories: e.filterCategories,
183
- source: e.source,
184
- key: e.streamKey,
185
- flush: e.flush,
186
- refresh: e.refresh,
187
- terrain: e.terrain,
188
- updateTriggers: e.updateTriggers,
189
- props: a
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
- p(() => {
192
- s.upsert(u);
193
- }), p(() => () => s.remove(r), [s, r]);
194
- const c = m(e.onClick);
195
- c.current = e.onClick;
196
- const o = m(e.onHover);
197
- return o.current = e.onHover, p(
198
- () => t.watchPicks((l) => {
199
- var d, f, w;
200
- if (l === null) {
201
- (d = o.current) == null || d.call(o, null);
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
- l.layerId === r && (l.type === "click" ? (f = c.current) == null || f.call(c, l) : (w = o.current) == null || w.call(o, l));
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
- [t, r]
199
+ [e, r]
207
200
  ), null;
208
201
  }
209
- function Se({ position: e = "top-left", className: t, style: s, children: r }) {
210
- const { corners: a } = K("OmWidget"), u = a[e];
211
- return u ? G(
212
- /* @__PURE__ */ P("div", { className: t, style: { pointerEvents: "auto", ...s }, children: r }),
213
- u
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 B(e, t) {
217
- return !t || (e == null ? void 0 : e.layerId) === t;
212
+ function G(t, e) {
213
+ return !e || (t == null ? void 0 : t.layerId) === e;
218
214
  }
219
- const de = {
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 Oe(e) {
231
- const { controller: t, overlayPane: s } = K("OmOverlay"), r = m(null), a = m(void 0), u = m(e);
232
- u.current = e;
233
- const c = T(() => {
234
- const b = t.getStore("selection");
235
- let h, n, S = null;
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: b.subscribe,
233
+ subscribe: h.subscribe,
238
234
  getSnapshot: () => {
239
- const g = b.getSnapshot(), { anchorFrom: C, layer: O } = u.current, E = `${C ?? ""}|${O ?? ""}`;
240
- return (g !== h || E !== n) && (h = g, n = E, C === "selection" && B(g, O) && (S = g)), S;
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
- }, [t]), o = H(
239
+ }, [e]), o = J(
244
240
  c.subscribe,
245
241
  c.getSnapshot,
246
242
  c.getSnapshot
247
243
  );
248
- p(
249
- () => t.registerOverlay((b, h) => {
250
- const n = r.current;
251
- if (!n) return;
252
- const { anchor: S, anchorFrom: g, layer: C, visible: O = !0, anchorOffset: E } = u.current;
253
- let R;
254
- if (g === "selection" ? (B(h, C) && (a.current = (h == null ? void 0 : h.coordinate) ?? void 0), R = a.current) : R = S, !O || !R || !b) {
255
- n.style.visibility = "hidden";
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 [j, k, x] = b.project([R[0], R[1], 0]);
259
- if (!(j >= 0 && j <= b.width && k >= 0 && k <= b.height) || x !== void 0 && x < 0) {
260
- n.style.visibility = "hidden";
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
- n.style.visibility = "visible", n.style.transform = `translate(${j}px, ${k}px) ${de[E ?? "bottom-center"]}`;
259
+ g.style.visibility = "visible", g.style.transform = `translate(${k}px, ${j}px) ${pe[T ?? "bottom-center"]}`;
264
260
  }),
265
- [t]
266
- ), p(() => {
267
- t.refreshOverlays();
261
+ [e]
262
+ ), E(() => {
263
+ e.refreshOverlays();
268
264
  });
269
- const { children: l, className: d, style: f, interactive: w = !0 } = e, L = typeof l == "function" ? l(o) : l;
270
- return G(
271
- /* @__PURE__ */ P(
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: d,
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: w ? "auto" : "none",
284
- ...f
279
+ pointerEvents: v ? "auto" : "none",
280
+ ...u
285
281
  },
286
282
  children: L
287
283
  }
288
284
  ),
289
- s
285
+ n
290
286
  );
291
287
  }
292
- function Re(e = []) {
293
- const { controller: t } = K("useOmMap"), s = e.join(" "), r = T(() => {
294
- const c = (s ? s.split(" ") : []).flatMap((l) => le(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>.`), []));
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: (l) => {
298
- const d = c.map((f) => f.subscribe(l));
293
+ subscribe: (a) => {
294
+ const f = c.map((u) => u.subscribe(a));
299
295
  return () => {
300
- for (const f of d) f();
296
+ for (const u of f) u();
301
297
  };
302
298
  },
303
299
  getSnapshot: () => {
304
- const l = c.map((d) => d.getSnapshot());
305
- return (!o || l.some((d, f) => d !== o[f])) && (o = l), 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
- }, [t, s]), a = H(r.subscribe, r.getSnapshot, r.getSnapshot);
309
- return T(() => t.buildCtx(), [t, a]);
304
+ }, [e, n]), l = J(r.subscribe, r.getSnapshot, r.getSnapshot);
305
+ return x(() => e.buildCtx(), [e, l]);
310
306
  }
311
307
  export {
312
- pe as OmLayer,
313
- ve as OmMap,
314
- Oe as OmOverlay,
315
- Se as OmWidget,
316
- Re as useOmMap
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
@@ -5,4 +5,4 @@
5
5
  * the build rootDir, and a `define` would need repeating across vite/vitest/
6
6
  * vite-node configs.
7
7
  */
8
- export declare const LIBRARY_VERSION = "0.4.0";
8
+ export declare const LIBRARY_VERSION = "0.4.2";
@@ -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;