@carto/ps-react-ui 4.12.1 → 4.13.0

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.
Files changed (104) hide show
  1. package/dist/components.js +706 -658
  2. package/dist/components.js.map +1 -1
  3. package/dist/legend/stores.js +20 -0
  4. package/dist/legend/stores.js.map +1 -0
  5. package/dist/legend.js +1536 -0
  6. package/dist/legend.js.map +1 -0
  7. package/dist/selectors-DwHj6mE2.js +388 -0
  8. package/dist/selectors-DwHj6mE2.js.map +1 -0
  9. package/dist/types/components/index.d.ts +1 -0
  10. package/dist/types/components/responsive-drawer/responsive-drawer.d.ts +35 -3
  11. package/dist/types/legend/components/contexts.d.ts +20 -0
  12. package/dist/types/legend/components/icons.d.ts +12 -0
  13. package/dist/types/legend/components/index.d.ts +26 -0
  14. package/dist/types/legend/components/legend-actions/legend-actions.d.ts +24 -0
  15. package/dist/types/legend/components/legend-actions/styles.d.ts +7 -0
  16. package/dist/types/legend/components/legend-category/legend-category-ui.d.ts +13 -0
  17. package/dist/types/legend/components/legend-category/styles.d.ts +52 -0
  18. package/dist/types/legend/components/legend-config-select/legend-config-select.d.ts +14 -0
  19. package/dist/types/legend/components/legend-config-select/styles.d.ts +44 -0
  20. package/dist/types/legend/components/legend-group/legend-group.d.ts +21 -0
  21. package/dist/types/legend/components/legend-group/styles.d.ts +63 -0
  22. package/dist/types/legend/components/legend-icon/legend-icon-ui.d.ts +10 -0
  23. package/dist/types/legend/components/legend-icon/styles.d.ts +52 -0
  24. package/dist/types/legend/components/legend-item/legend-item-ui.d.ts +14 -0
  25. package/dist/types/legend/components/legend-item/legend-item.d.ts +10 -0
  26. package/dist/types/legend/components/legend-item/styles.d.ts +7 -0
  27. package/dist/types/legend/components/legend-opacity/legend-opacity.d.ts +32 -0
  28. package/dist/types/legend/components/legend-opacity/styles.d.ts +23 -0
  29. package/dist/types/legend/components/legend-proportion/legend-proportion-ui.d.ts +16 -0
  30. package/dist/types/legend/components/legend-proportion/styles.d.ts +37 -0
  31. package/dist/types/legend/components/legend-ramp/legend-ramp-ui.d.ts +20 -0
  32. package/dist/types/legend/components/legend-ramp/styles.d.ts +53 -0
  33. package/dist/types/legend/components/legend-row/legend-row.d.ts +23 -0
  34. package/dist/types/legend/components/legend-row/styles.d.ts +77 -0
  35. package/dist/types/legend/components/legend-row-menu/legend-row-menu.d.ts +18 -0
  36. package/dist/types/legend/components/legend-row-menu/legend-zoom-to.d.ts +15 -0
  37. package/dist/types/legend/components/legend-swatch/legend-swatch.d.ts +26 -0
  38. package/dist/types/legend/components/legend-visibility-toggle/legend-visibility-toggle.d.ts +35 -0
  39. package/dist/types/legend/index.d.ts +88 -0
  40. package/dist/types/legend/provider/index.d.ts +6 -0
  41. package/dist/types/legend/provider/labels.d.ts +27 -0
  42. package/dist/types/legend/provider/legend-config-context.d.ts +7 -0
  43. package/dist/types/legend/provider/legend-provider.d.ts +38 -0
  44. package/dist/types/legend/stores/index.d.ts +5 -0
  45. package/dist/types/legend/stores/legend-context.d.ts +4 -0
  46. package/dist/types/legend/stores/legend-store-registry.d.ts +39 -0
  47. package/dist/types/legend/stores/legend-store.test.d.ts +1 -0
  48. package/dist/types/legend/stores/selectors.d.ts +33 -0
  49. package/dist/types/legend/stores/types.d.ts +275 -0
  50. package/dist/widgets-v2/bar.js +7 -3
  51. package/dist/widgets-v2/bar.js.map +1 -1
  52. package/dist/widgets-v2/histogram.js +9 -4
  53. package/dist/widgets-v2/histogram.js.map +1 -1
  54. package/package.json +11 -3
  55. package/src/components/geolocation-controls/geolocation-controls.test.tsx +15 -0
  56. package/src/components/geolocation-controls/geolocation-controls.tsx +19 -3
  57. package/src/components/index.ts +2 -0
  58. package/src/components/responsive-drawer/responsive-drawer.test.tsx +129 -25
  59. package/src/components/responsive-drawer/responsive-drawer.tsx +149 -16
  60. package/src/legend/components/contexts.ts +32 -0
  61. package/src/legend/components/icons.tsx +22 -0
  62. package/src/legend/components/index.ts +39 -0
  63. package/src/legend/components/legend-actions/legend-actions.tsx +57 -0
  64. package/src/legend/components/legend-actions/styles.ts +9 -0
  65. package/src/legend/components/legend-category/legend-category-ui.tsx +91 -0
  66. package/src/legend/components/legend-category/styles.ts +61 -0
  67. package/src/legend/components/legend-config-select/legend-config-select.tsx +96 -0
  68. package/src/legend/components/legend-config-select/styles.ts +48 -0
  69. package/src/legend/components/legend-group/legend-group.test.tsx +115 -0
  70. package/src/legend/components/legend-group/legend-group.tsx +88 -0
  71. package/src/legend/components/legend-group/styles.ts +82 -0
  72. package/src/legend/components/legend-icon/legend-icon-ui.tsx +56 -0
  73. package/src/legend/components/legend-icon/styles.ts +56 -0
  74. package/src/legend/components/legend-item/legend-item-ui.test.tsx +362 -0
  75. package/src/legend/components/legend-item/legend-item-ui.tsx +43 -0
  76. package/src/legend/components/legend-item/legend-item.tsx +34 -0
  77. package/src/legend/components/legend-item/styles.ts +11 -0
  78. package/src/legend/components/legend-opacity/legend-opacity.tsx +179 -0
  79. package/src/legend/components/legend-opacity/styles.ts +28 -0
  80. package/src/legend/components/legend-proportion/legend-proportion-ui.tsx +122 -0
  81. package/src/legend/components/legend-proportion/styles.ts +43 -0
  82. package/src/legend/components/legend-ramp/legend-ramp-ui.tsx +159 -0
  83. package/src/legend/components/legend-ramp/styles.ts +62 -0
  84. package/src/legend/components/legend-row/legend-row.test.tsx +498 -0
  85. package/src/legend/components/legend-row/legend-row.tsx +129 -0
  86. package/src/legend/components/legend-row/styles.ts +111 -0
  87. package/src/legend/components/legend-row-menu/legend-row-menu.tsx +68 -0
  88. package/src/legend/components/legend-row-menu/legend-zoom-to.tsx +35 -0
  89. package/src/legend/components/legend-swatch/legend-swatch.test.tsx +109 -0
  90. package/src/legend/components/legend-swatch/legend-swatch.tsx +237 -0
  91. package/src/legend/components/legend-visibility-toggle/legend-visibility-toggle.tsx +127 -0
  92. package/src/legend/index.ts +121 -0
  93. package/src/legend/provider/index.ts +6 -0
  94. package/src/legend/provider/labels.ts +59 -0
  95. package/src/legend/provider/legend-config-context.ts +15 -0
  96. package/src/legend/provider/legend-provider.tsx +102 -0
  97. package/src/legend/stores/index.ts +46 -0
  98. package/src/legend/stores/legend-context.ts +17 -0
  99. package/src/legend/stores/legend-store-registry.ts +639 -0
  100. package/src/legend/stores/legend-store.test.ts +457 -0
  101. package/src/legend/stores/selectors.ts +65 -0
  102. package/src/legend/stores/types.ts +347 -0
  103. package/src/widgets-v2/bar/options.ts +4 -0
  104. package/src/widgets-v2/histogram/options.ts +5 -0
@@ -0,0 +1,388 @@
1
+ import { createContext as E, useContext as V } from "react";
2
+ import { c as G } from "react/compiler-runtime";
3
+ import { useStore as k } from "zustand";
4
+ import { createStore as P } from "zustand/vanilla";
5
+ import { devtools as M } from "zustand/middleware";
6
+ import { useShallow as x } from "zustand/react/shallow";
7
+ const $ = E(null);
8
+ function X() {
9
+ const e = V($);
10
+ if (e == null)
11
+ throw new Error("useLegendId() must be called inside <Legend.Provider>. If you are calling from outside the Provider tree, use the hooks (useLegendStore, useLegendShallow) directly with an explicit id.");
12
+ return e;
13
+ }
14
+ const g = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Set(), B = () => {
15
+ try {
16
+ return !1;
17
+ } catch {
18
+ return !1;
19
+ }
20
+ }, A = (e) => Math.min(1, Math.max(0, e));
21
+ function j(e, r) {
22
+ return e.visible === r ? null : r ? (
23
+ // Showing: restore the pre-hide collapsed state (default expand).
24
+ {
25
+ visible: r,
26
+ collapsed: e.collapsedBeforeHide ?? !1,
27
+ collapsedBeforeHide: void 0
28
+ }
29
+ ) : (
30
+ // Hiding: snapshot, then collapse.
31
+ {
32
+ visible: r,
33
+ collapsed: !0,
34
+ collapsedBeforeHide: e.collapsed
35
+ }
36
+ );
37
+ }
38
+ function D(e, r) {
39
+ return e.visible ? {
40
+ collapsed: r
41
+ } : {
42
+ collapsed: r,
43
+ collapsedBeforeHide: r
44
+ };
45
+ }
46
+ function h(e, r, n) {
47
+ const s = e.layers[r];
48
+ return s ? {
49
+ layers: {
50
+ ...e.layers,
51
+ [r]: {
52
+ ...s,
53
+ ...n
54
+ }
55
+ }
56
+ } : {};
57
+ }
58
+ function q(e, r, n) {
59
+ const s = e.groups[r];
60
+ return s ? {
61
+ groups: {
62
+ ...e.groups,
63
+ [r]: {
64
+ ...s,
65
+ ...n
66
+ }
67
+ }
68
+ } : {};
69
+ }
70
+ function _(e, r) {
71
+ if (!r || !e || e === r) return r;
72
+ const n = r.map((o) => {
73
+ const t = e.find((l) => l.id === o.id);
74
+ return t && t.active !== o.active && o.options.includes(t.active) ? {
75
+ ...o,
76
+ active: t.active
77
+ } : o;
78
+ });
79
+ return e.length === n.length && n.every((o, t) => {
80
+ const l = e[t];
81
+ return l.id === o.id && l.title === o.title && l.options === o.options && l.active === o.active;
82
+ }) ? e : n;
83
+ }
84
+ function L(e, r) {
85
+ const n = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(r)]);
86
+ for (const s of n)
87
+ if (!Object.is(e[s], r[s])) return !1;
88
+ return !0;
89
+ }
90
+ function v(e, r) {
91
+ const n = /* @__PURE__ */ new Map();
92
+ for (const s of e) {
93
+ const o = r(s.merged), t = n.get(o);
94
+ t ? t.push(s) : n.set(o, [s]);
95
+ }
96
+ for (const s of n.values())
97
+ s.sort((o, t) => o.merged.order - t.merged.order || o.index - t.index).forEach((o, t) => {
98
+ o.merged.order = t;
99
+ });
100
+ }
101
+ function I(e, r, n) {
102
+ return {
103
+ ...r,
104
+ visible: e?.visible ?? r.visible ?? !0,
105
+ opacity: e?.opacity ?? r.opacity ?? 1,
106
+ collapsed: e?.collapsed ?? r.collapsed ?? !1,
107
+ collapsedBeforeHide: e?.collapsedBeforeHide,
108
+ sections: _(e?.sections, r.sections),
109
+ order: e?.order ?? r.order ?? n
110
+ };
111
+ }
112
+ function H(e, r, n) {
113
+ return {
114
+ ...r,
115
+ collapsed: e?.collapsed ?? r.collapsed ?? !1,
116
+ collapsedBeforeHide: e?.collapsedBeforeHide,
117
+ order: e?.order ?? r.order ?? n
118
+ };
119
+ }
120
+ function w(e, r, n) {
121
+ const s = r.map((u, a) => ({
122
+ index: a,
123
+ merged: I(e.layers[u.id], u, a)
124
+ }));
125
+ v(s, (u) => u.groupId);
126
+ const o = n.map((u, a) => ({
127
+ index: a,
128
+ merged: H(e.groups[u.id], u, a)
129
+ }));
130
+ v(o, () => {
131
+ });
132
+ let t = s.length !== Object.keys(e.layers).length;
133
+ const l = {};
134
+ for (const {
135
+ merged: u
136
+ } of s) {
137
+ const a = e.layers[u.id];
138
+ a && L(a, u) ? l[u.id] = a : (l[u.id] = u, t = !0);
139
+ }
140
+ let c = o.length !== Object.keys(e.groups).length;
141
+ const i = {};
142
+ for (const {
143
+ merged: u
144
+ } of o) {
145
+ const a = e.groups[u.id];
146
+ a && L(a, u) ? i[u.id] = a : (i[u.id] = u, c = !0);
147
+ }
148
+ return !t && !c ? {} : {
149
+ layers: t ? l : e.layers,
150
+ groups: c ? i : e.groups
151
+ };
152
+ }
153
+ function y(e, r, n) {
154
+ const s = Object.values(r).map((l, c) => ({
155
+ index: c,
156
+ merged: {
157
+ ...l
158
+ }
159
+ }));
160
+ v(s, n);
161
+ let o = s.length !== Object.keys(e).length;
162
+ const t = {};
163
+ for (const {
164
+ merged: l
165
+ } of s) {
166
+ const c = e[l.id];
167
+ c && L(c, l) ? t[l.id] = c : (t[l.id] = l, o = !0);
168
+ }
169
+ return o ? t : null;
170
+ }
171
+ function z(e, r) {
172
+ const n = Object.values(e.layers).filter((t) => t.groupId === r.groupId && t.id !== r.id).length, s = I(e.layers[r.id], r, n), o = y(e.layers, {
173
+ ...e.layers,
174
+ [r.id]: s
175
+ }, (t) => t.groupId);
176
+ return o ? {
177
+ layers: o
178
+ } : {};
179
+ }
180
+ function R(e, r) {
181
+ if (!e.layers[r]) return {};
182
+ const n = {
183
+ ...e.layers
184
+ };
185
+ delete n[r];
186
+ const s = y(e.layers, n, (o) => o.groupId);
187
+ return s ? {
188
+ layers: s
189
+ } : {};
190
+ }
191
+ function U(e, r) {
192
+ const n = Object.values(e.groups).filter((t) => t.id !== r.id).length, s = H(e.groups[r.id], r, n), o = y(e.groups, {
193
+ ...e.groups,
194
+ [r.id]: s
195
+ }, () => {
196
+ });
197
+ return o ? {
198
+ groups: o
199
+ } : {};
200
+ }
201
+ function F(e, r) {
202
+ if (!e.groups[r]) return {};
203
+ const n = {
204
+ ...e.groups
205
+ };
206
+ delete n[r];
207
+ const s = y(e.groups, n, () => {
208
+ }), o = Object.values(e.layers).filter((c) => c.groupId === r);
209
+ if (o.length === 0) return s ? {
210
+ groups: s
211
+ } : {};
212
+ const t = {
213
+ ...e.layers
214
+ };
215
+ for (const c of o)
216
+ t[c.id] = {
217
+ ...c,
218
+ groupId: void 0
219
+ };
220
+ const l = y(e.layers, t, (c) => c.groupId);
221
+ return {
222
+ ...s ? {
223
+ groups: s
224
+ } : {},
225
+ ...l ? {
226
+ layers: l
227
+ } : {}
228
+ };
229
+ }
230
+ function Y(e, r = {}) {
231
+ const n = w({
232
+ layers: {},
233
+ groups: {}
234
+ }, r.layers ?? [], r.groups ?? []);
235
+ return P()(M((s) => ({
236
+ layers: n.layers ?? {},
237
+ groups: n.groups ?? {},
238
+ setVisibility: (o, t) => s((l) => {
239
+ const c = l.layers[o], i = c && j(c, t);
240
+ return i ? h(l, o, i) : {};
241
+ }, !1, "setVisibility"),
242
+ setOpacity: (o, t) => s((l) => h(l, o, {
243
+ opacity: A(t)
244
+ }), !1, "setOpacity"),
245
+ setCollapsed: (o, t) => s((l) => {
246
+ const c = l.layers[o];
247
+ return c ? h(l, o, D(c, t)) : {};
248
+ }, !1, "setCollapsed"),
249
+ setSectionValue: (o, t, l) => s((c) => {
250
+ const i = c.layers[o], u = i?.sections?.find((d) => d.id === t);
251
+ if (!i?.sections || !u || u.active === l || !u.options.includes(l))
252
+ return {};
253
+ const a = i.sections.map((d) => d.id === t ? {
254
+ ...d,
255
+ active: l
256
+ } : d);
257
+ return h(c, o, {
258
+ sections: a
259
+ });
260
+ }, !1, "setSectionValue"),
261
+ setGroupVisibility: (o, t) => s((l) => {
262
+ const c = l.groups[o];
263
+ if (!c) return {};
264
+ const i = Object.values(l.layers).filter((f) => f.groupId === o), u = i.some((f) => f.visible);
265
+ if (i.length === 0 || !t && !u) return {};
266
+ const a = {
267
+ ...l.layers
268
+ };
269
+ let d = !1;
270
+ for (const f of i) {
271
+ const O = j(f, t);
272
+ O && (a[f.id] = {
273
+ ...f,
274
+ ...O
275
+ }, d = !0);
276
+ }
277
+ if (!d) return {};
278
+ let m = null;
279
+ return !t && u ? m = {
280
+ collapsed: !0,
281
+ collapsedBeforeHide: c.collapsed
282
+ } : t && !u && (m = {
283
+ collapsed: c.collapsedBeforeHide ?? !1,
284
+ collapsedBeforeHide: void 0
285
+ }), {
286
+ layers: a,
287
+ ...m ? {
288
+ groups: {
289
+ ...l.groups,
290
+ [o]: {
291
+ ...c,
292
+ ...m
293
+ }
294
+ }
295
+ } : {}
296
+ };
297
+ }, !1, "setGroupVisibility"),
298
+ setGroupCollapsed: (o, t) => s((l) => {
299
+ if (!l.groups[o]) return {};
300
+ const i = Object.values(l.layers).filter((a) => a.groupId === o), u = i.length > 0 && i.every((a) => !a.visible);
301
+ return q(l, o, u ? {
302
+ collapsed: t,
303
+ collapsedBeforeHide: t
304
+ } : {
305
+ collapsed: t
306
+ });
307
+ }, !1, "setGroupCollapsed"),
308
+ setLegendLayer: (o) => s((t) => z(t, o), !1, "setLegendLayer"),
309
+ removeLegendLayer: (o) => s((t) => R(t, o), !1, "removeLegendLayer"),
310
+ setLegendGroup: (o) => s((t) => U(t, o), !1, "setLegendGroup"),
311
+ removeLegendGroup: (o) => s((t) => F(t, o), !1, "removeLegendGroup"),
312
+ _sync: (o, t) => s((l) => w(l, o, t), !1, "_sync")
313
+ }), {
314
+ name: `legend-${e}`,
315
+ enabled: B()
316
+ }));
317
+ }
318
+ function C(e) {
319
+ const r = g.get(e);
320
+ if (!r) throw new Error(`[legend] Legend store "${e}" not found.`);
321
+ return r;
322
+ }
323
+ function Z(e) {
324
+ return g.has(e);
325
+ }
326
+ function ee(e) {
327
+ g.delete(e);
328
+ }
329
+ function re() {
330
+ g.clear(), p.clear(), b.clear();
331
+ }
332
+ function oe(e, r) {
333
+ g.set(e, r);
334
+ }
335
+ function se(e, r) {
336
+ g.set(e, r);
337
+ const n = (p.get(e) ?? 0) + 1;
338
+ p.set(e, n), n > 1 && B() && !b.has(e) && (console.warn(`[legend] Duplicate <Legend.Provider id="${e}"> detected. Multiple providers sharing an id will race on prop sync. Use unique ids per legend panel.`), b.add(e));
339
+ }
340
+ function te(e, r) {
341
+ const n = (p.get(e) ?? 1) - 1;
342
+ n <= 0 ? (p.delete(e), r.keepAlive || g.delete(e)) : p.set(e, n);
343
+ }
344
+ function ne(e, r) {
345
+ const n = G(2);
346
+ let s;
347
+ return n[0] !== e ? (s = C(e), n[0] = e, n[1] = s) : s = n[1], k(s, r);
348
+ }
349
+ function le(e, r) {
350
+ const n = G(2);
351
+ let s;
352
+ return n[0] !== e ? (s = C(e), n[0] = e, n[1] = s) : s = n[1], k(s, x(r));
353
+ }
354
+ const S = (e, r) => e.order - r.order;
355
+ function ce(e) {
356
+ return Object.values(e.groups).sort(S);
357
+ }
358
+ function ue(e, r) {
359
+ return Object.values(e.layers).filter((n) => n.groupId === r).sort(S);
360
+ }
361
+ function ae(e) {
362
+ return Object.values(e.layers).sort(S);
363
+ }
364
+ function ie(e, r) {
365
+ let n = !1, s = !1;
366
+ for (const o of Object.values(e.layers))
367
+ o.groupId === r && (o.visible ? n = !0 : s = !0);
368
+ return n && s ? "mixed" : s ? "hidden" : "visible";
369
+ }
370
+ export {
371
+ $ as L,
372
+ Y as a,
373
+ ue as b,
374
+ re as c,
375
+ ee as d,
376
+ ce as e,
377
+ ae as f,
378
+ C as g,
379
+ Z as h,
380
+ oe as i,
381
+ X as j,
382
+ le as k,
383
+ ne as l,
384
+ se as r,
385
+ ie as s,
386
+ te as u
387
+ };
388
+ //# sourceMappingURL=selectors-DwHj6mE2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors-DwHj6mE2.js","sources":["../src/legend/stores/legend-context.ts","../src/legend/stores/legend-store-registry.ts","../src/legend/stores/selectors.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\n\n/** @experimental This API is new and may change in a future release. */\nexport const LegendContext = createContext<string | null>(null)\n\n/** @experimental This API is new and may change in a future release. */\nexport function useLegendId(): string {\n const id = useContext(LegendContext)\n if (id == null) {\n throw new Error(\n 'useLegendId() must be called inside <Legend.Provider>. ' +\n 'If you are calling from outside the Provider tree, use the hooks ' +\n '(useLegendStore, useLegendShallow) directly with an explicit id.',\n )\n }\n return id\n}\n","import { useStore, type StoreApi } from 'zustand'\nimport { createStore } from 'zustand/vanilla'\nimport { devtools } from 'zustand/middleware'\nimport { useShallow } from 'zustand/react/shallow'\nimport type {\n LegendConfigSection,\n LegendGroup,\n LegendGroupInput,\n LegendInit,\n LegendLayer,\n LegendLayerInput,\n LegendState,\n LegendStoreApi,\n} from './types'\n\n// Per-panel legend store registry. One store per `<Legend.Provider id>`.\n// Mirrors the widgets-v2 registry pattern (keyed Map + refcounted mounts),\n// without the chart-pipeline machinery.\nconst legendStores = new Map<string, LegendStoreApi>()\nconst legendMountCounts = new Map<string, number>()\nconst warnedDuplicates = new Set<string>()\n\nconst isDev = (): boolean => {\n try {\n return Boolean(\n (import.meta as unknown as { env?: { DEV?: boolean } }).env?.DEV,\n )\n } catch {\n return false\n }\n}\n\nconst clamp01 = (n: number): number => Math.min(1, Math.max(0, n))\n\n// ─── Pure state helpers ─────────────────────────────────────────────────────\n\n/**\n * Visibility↔collapse coupling. Hiding snapshots the current collapsed state\n * and collapses; showing restores the snapshot (manual choices persist) and\n * defaults to expanded. Idempotent: returns `null` when `visible` is already\n * the requested value, so a double-hide can't overwrite the real snapshot.\n */\nfunction visibilityPatch(\n entity: {\n visible: boolean\n collapsed: boolean\n collapsedBeforeHide?: boolean\n },\n visible: boolean,\n): {\n visible: boolean\n collapsed: boolean\n collapsedBeforeHide: boolean | undefined\n} | null {\n if (entity.visible === visible) return null\n return visible\n ? // Showing: restore the pre-hide collapsed state (default expand).\n {\n visible,\n collapsed: entity.collapsedBeforeHide ?? false,\n collapsedBeforeHide: undefined,\n }\n : // Hiding: snapshot, then collapse.\n {\n visible,\n collapsed: true,\n collapsedBeforeHide: entity.collapsed,\n }\n}\n\n/**\n * Manual collapse. While hidden, the snapshot follows the manual choice so\n * the next show keeps it.\n */\nfunction collapsePatch(\n entity: { visible: boolean },\n collapsed: boolean,\n): { collapsed: boolean; collapsedBeforeHide?: boolean } {\n return entity.visible\n ? { collapsed }\n : { collapsed, collapsedBeforeHide: collapsed }\n}\n\nfunction updateLayer(\n state: LegendState,\n id: string,\n patch: Partial<LegendLayer>,\n): Partial<LegendState> {\n const layer = state.layers[id]\n if (!layer) return {}\n return { layers: { ...state.layers, [id]: { ...layer, ...patch } } }\n}\n\nfunction updateGroup(\n state: LegendState,\n id: string,\n patch: Partial<LegendGroup>,\n): Partial<LegendState> {\n const group = state.groups[id]\n if (!group) return {}\n return { groups: { ...state.groups, [id]: { ...group, ...patch } } }\n}\n\n/**\n * Merge incoming config-select sections while preserving the user's picked\n * `active` for any section id that still exists and whose pick is still among\n * the new `options` (the structure — ids, titles, options, order — always\n * follows the props). Returns the previous array when the merge lands on the\n * same content, so unchanged syncs keep entity identity (bail-out).\n */\nfunction mergeSections(\n prev: LegendConfigSection[] | undefined,\n next: LegendConfigSection[] | undefined,\n): LegendConfigSection[] | undefined {\n if (!next || !prev || prev === next) return next\n const merged = next.map((section) => {\n const prevSection = prev.find((p) => p.id === section.id)\n return prevSection &&\n prevSection.active !== section.active &&\n section.options.includes(prevSection.active)\n ? { ...section, active: prevSection.active }\n : section\n })\n const sameAsPrev =\n prev.length === merged.length &&\n merged.every((m, i) => {\n const p = prev[i]!\n return (\n p.id === m.id &&\n p.title === m.title &&\n p.options === m.options &&\n p.active === m.active\n )\n })\n return sameAsPrev ? prev : merged\n}\n\n/** Shallow equality over the union of both objects' keys (`Object.is` per value). */\nfunction shallowEqualEntity<T extends object>(a: T, b: T): boolean {\n const keys = new Set([...Object.keys(a), ...Object.keys(b)]) as Set<keyof T>\n for (const key of keys) {\n if (!Object.is(a[key], b[key])) return false\n }\n return true\n}\n\n/**\n * Reassign `order` to dense indexes `0..n-1` within each sibling bucket,\n * sorted by current order with ties broken by input position. This is the\n * only boundary where external (possibly duplicated) orders enter, so the\n * stored orders stay dense and unique within each bucket.\n */\nfunction normalizeOrders<T extends { order: number }>(\n entries: { merged: T; index: number }[],\n bucketOf: (e: T) => string | undefined,\n): void {\n const buckets = new Map<string | undefined, { merged: T; index: number }[]>()\n for (const entry of entries) {\n const key = bucketOf(entry.merged)\n const bucket = buckets.get(key)\n if (bucket) bucket.push(entry)\n else buckets.set(key, [entry])\n }\n for (const bucket of buckets.values()) {\n bucket\n .sort((a, b) => a.merged.order - b.merged.order || a.index - b.index)\n .forEach((entry, i) => {\n entry.merged.order = i\n })\n }\n}\n\n/**\n * Seed/merge one layer: static fields follow the input; interactive state\n * (`visible`/`opacity`/`collapsed`/`order`/`collapsedBeforeHide` + section\n * actives) sticks to the store entry when present. Shared by `_sync` (per\n * entry) and the imperative `setLegendLayer`.\n */\nfunction mergeLayerEntity(\n prev: LegendLayer | undefined,\n input: LegendLayerInput,\n fallbackOrder: number,\n): LegendLayer {\n return {\n ...input,\n visible: prev?.visible ?? input.visible ?? true,\n opacity: prev?.opacity ?? input.opacity ?? 1,\n collapsed: prev?.collapsed ?? input.collapsed ?? false,\n collapsedBeforeHide: prev?.collapsedBeforeHide,\n sections: mergeSections(prev?.sections, input.sections),\n order: prev?.order ?? input.order ?? fallbackOrder,\n } as LegendLayer\n}\n\n/** Group counterpart of {@link mergeLayerEntity}. */\nfunction mergeGroupEntity(\n prev: LegendGroup | undefined,\n input: LegendGroupInput,\n fallbackOrder: number,\n): LegendGroup {\n return {\n ...input,\n collapsed: prev?.collapsed ?? input.collapsed ?? false,\n collapsedBeforeHide: prev?.collapsedBeforeHide,\n order: prev?.order ?? input.order ?? fallbackOrder,\n } as LegendGroup\n}\n\n/**\n * Merge incoming definitions while preserving interactive state of known\n * entities: static fields (name, subtitle, variables, attributes, …) follow\n * the props; `visible`/`opacity`/`collapsed`/`order` stick to what's in the\n * store. New entities are seeded; vanished ones are dropped. Sibling orders\n * are normalized to dense indexes.\n *\n * Unchanged entities keep their previous object identity (`variables`\n * compared by reference), and when nothing changed at all the sync is a\n * no-op (`{}`), so stable consumer props never produce a state update.\n */\nfunction syncState(\n state: LegendState,\n layerInputs: LegendLayerInput[],\n groupInputs: LegendGroupInput[],\n): Partial<LegendState> {\n const layerEntries = layerInputs.map((input, index) => ({\n index,\n merged: mergeLayerEntity(state.layers[input.id], input, index),\n }))\n normalizeOrders(layerEntries, (l) => l.groupId)\n\n const groupEntries = groupInputs.map((input, index) => ({\n index,\n merged: mergeGroupEntity(state.groups[input.id], input, index),\n }))\n normalizeOrders(groupEntries, () => undefined)\n\n // Reference preservation: reuse the previous entity object when nothing\n // about it changed, so subscribers see stable identities.\n let layersChanged = layerEntries.length !== Object.keys(state.layers).length\n const layers: Record<string, LegendLayer> = {}\n for (const { merged } of layerEntries) {\n const prev = state.layers[merged.id]\n if (prev && shallowEqualEntity(prev, merged)) {\n layers[merged.id] = prev\n } else {\n layers[merged.id] = merged\n layersChanged = true\n }\n }\n\n let groupsChanged = groupEntries.length !== Object.keys(state.groups).length\n const groups: Record<string, LegendGroup> = {}\n for (const { merged } of groupEntries) {\n const prev = state.groups[merged.id]\n if (prev && shallowEqualEntity(prev, merged)) {\n groups[merged.id] = prev\n } else {\n groups[merged.id] = merged\n groupsChanged = true\n }\n }\n\n if (!layersChanged && !groupsChanged) return {}\n return {\n layers: layersChanged ? layers : state.layers,\n groups: groupsChanged ? groups : state.groups,\n }\n}\n\n/**\n * Rebuild a layer/group record from a candidate map, normalizing dense order\n * per bucket and preserving the previous object identity for entries that are\n * unchanged. Returns `null` when nothing changed (so callers can bail with\n * `{}`).\n */\nfunction rebuildRecord<\n T extends { id: string; order: number; groupId?: string },\n>(\n prev: Record<string, T>,\n next: Record<string, T>,\n bucketOf: (e: T) => string | undefined,\n): Record<string, T> | null {\n const entries = Object.values(next).map((e, index) => ({\n index,\n merged: { ...e },\n }))\n normalizeOrders(entries, bucketOf)\n let changed = entries.length !== Object.keys(prev).length\n const out: Record<string, T> = {}\n for (const { merged } of entries) {\n const before = prev[merged.id]\n if (before && shallowEqualEntity(before, merged)) {\n out[merged.id] = before\n } else {\n out[merged.id] = merged\n changed = true\n }\n }\n return changed ? out : null\n}\n\n/** Add or update a single layer (imperative `setLegendLayer`). */\nfunction upsertLayerState(\n state: LegendState,\n input: LegendLayerInput,\n): Partial<LegendState> {\n const siblingCount = Object.values(state.layers).filter(\n (l) => l.groupId === input.groupId && l.id !== input.id,\n ).length\n const merged = mergeLayerEntity(state.layers[input.id], input, siblingCount)\n const layers = rebuildRecord(\n state.layers,\n { ...state.layers, [input.id]: merged },\n (l) => l.groupId,\n )\n return layers ? { layers } : {}\n}\n\n/** Remove a single layer, re-densifying its sibling orders. */\nfunction removeLayerState(\n state: LegendState,\n id: string,\n): Partial<LegendState> {\n if (!state.layers[id]) return {}\n const next = { ...state.layers }\n delete next[id]\n const layers = rebuildRecord(state.layers, next, (l) => l.groupId)\n return layers ? { layers } : {}\n}\n\n/** Add or update a single group (imperative `setLegendGroup`). */\nfunction upsertGroupState(\n state: LegendState,\n input: LegendGroupInput,\n): Partial<LegendState> {\n const count = Object.values(state.groups).filter(\n (g) => g.id !== input.id,\n ).length\n const merged = mergeGroupEntity(state.groups[input.id], input, count)\n const groups = rebuildRecord(\n state.groups,\n { ...state.groups, [input.id]: merged },\n () => undefined,\n )\n return groups ? { groups } : {}\n}\n\n/**\n * Remove a group; its member layers are un-grouped (`groupId` cleared) so they\n * survive as ungrouped rows. Re-densifies both group and layer orders.\n */\nfunction removeGroupState(\n state: LegendState,\n id: string,\n): Partial<LegendState> {\n if (!state.groups[id]) return {}\n const nextGroups = { ...state.groups }\n delete nextGroups[id]\n const groups = rebuildRecord(state.groups, nextGroups, () => undefined)\n\n const members = Object.values(state.layers).filter((l) => l.groupId === id)\n if (members.length === 0) return groups ? { groups } : {}\n\n const nextLayers = { ...state.layers }\n for (const member of members) {\n nextLayers[member.id] = { ...member, groupId: undefined }\n }\n const layers = rebuildRecord(state.layers, nextLayers, (l) => l.groupId)\n return {\n ...(groups ? { groups } : {}),\n ...(layers ? { layers } : {}),\n }\n}\n\n// ─── Store factory ────────────────────────────────────────────────────────────\n\n/**\n * @internal — used by Provider; not part of the public API.\n *\n * @experimental This API is new and may change in a future release.\n */\nexport function createLegendStore(\n id: string,\n init: LegendInit = {},\n): LegendStoreApi {\n // Seed through the same merge/normalize path as `_sync`, so a later sync\n // with identical input is a guaranteed no-op (stable identities).\n const seeded = syncState(\n { layers: {}, groups: {} } as LegendState,\n init.layers ?? [],\n init.groups ?? [],\n )\n\n return createStore<LegendState>()(\n devtools(\n (set) => ({\n layers: seeded.layers ?? {},\n groups: seeded.groups ?? {},\n\n setVisibility: (lid, visible) =>\n set(\n (s) => {\n const layer = s.layers[lid]\n const patch = layer && visibilityPatch(layer, visible)\n return patch ? updateLayer(s, lid, patch) : {}\n },\n false,\n 'setVisibility',\n ),\n setOpacity: (lid, opacity) =>\n set(\n (s) => updateLayer(s, lid, { opacity: clamp01(opacity) }),\n false,\n 'setOpacity',\n ),\n setCollapsed: (lid, collapsed) =>\n set(\n (s) => {\n const layer = s.layers[lid]\n return layer\n ? updateLayer(s, lid, collapsePatch(layer, collapsed))\n : {}\n },\n false,\n 'setCollapsed',\n ),\n setSectionValue: (lid, sectionId, value) =>\n set(\n (s) => {\n const layer = s.layers[lid]\n const section = layer?.sections?.find((x) => x.id === sectionId)\n if (\n !layer?.sections ||\n !section ||\n section.active === value ||\n !section.options.includes(value)\n ) {\n return {}\n }\n const sections = layer.sections.map((x) =>\n x.id === sectionId ? { ...x, active: value } : x,\n )\n return updateLayer(s, lid, { sections })\n },\n false,\n 'setSectionValue',\n ),\n\n setGroupVisibility: (gid, visible) =>\n set(\n (s) => {\n const group = s.groups[gid]\n if (!group) return {}\n const members = Object.values(s.layers).filter(\n (l) => l.groupId === gid,\n )\n const anyVisible = members.some((l) => l.visible)\n // Idempotence on the derived state: hide needs a visible member,\n // show needs a fully-hidden group (mixed acts in both directions\n // except show-from-mixed still shows the hidden remainder).\n if (members.length === 0 || (!visible && !anyVisible)) return {}\n\n // Cascade: each member runs the standard visibility↔collapse\n // coupling, so per-layer collapse snapshots survive a group\n // hide/show; members already at the target are untouched.\n const layers = { ...s.layers }\n let layersChanged = false\n for (const member of members) {\n const patch = visibilityPatch(member, visible)\n if (patch) {\n layers[member.id] = { ...member, ...patch }\n layersChanged = true\n }\n }\n if (!layersChanged) return {}\n\n // Group-level collapse coupling, only on real derived\n // transitions: any-visible→hidden snapshots + collapses;\n // hidden→visible restores the snapshot.\n let groupPatch: Partial<LegendGroup> | null = null\n if (!visible && anyVisible) {\n groupPatch = {\n collapsed: true,\n collapsedBeforeHide: group.collapsed,\n }\n } else if (visible && !anyVisible) {\n groupPatch = {\n collapsed: group.collapsedBeforeHide ?? false,\n collapsedBeforeHide: undefined,\n }\n }\n return {\n layers,\n ...(groupPatch\n ? {\n groups: {\n ...s.groups,\n [gid]: { ...group, ...groupPatch },\n },\n }\n : {}),\n }\n },\n false,\n 'setGroupVisibility',\n ),\n setGroupCollapsed: (gid, collapsed) =>\n set(\n (s) => {\n const group = s.groups[gid]\n if (!group) return {}\n // Group visibility is derived from members; while the group is\n // hidden the snapshot follows the manual choice (layer parity).\n const members = Object.values(s.layers).filter(\n (l) => l.groupId === gid,\n )\n const hidden =\n members.length > 0 && members.every((l) => !l.visible)\n return updateGroup(\n s,\n gid,\n hidden\n ? { collapsed, collapsedBeforeHide: collapsed }\n : { collapsed },\n )\n },\n false,\n 'setGroupCollapsed',\n ),\n\n setLegendLayer: (input) =>\n set((s) => upsertLayerState(s, input), false, 'setLegendLayer'),\n removeLegendLayer: (lid) =>\n set((s) => removeLayerState(s, lid), false, 'removeLegendLayer'),\n setLegendGroup: (input) =>\n set((s) => upsertGroupState(s, input), false, 'setLegendGroup'),\n removeLegendGroup: (gid) =>\n set((s) => removeGroupState(s, gid), false, 'removeLegendGroup'),\n\n _sync: (layerInputs, groupInputs) =>\n set((s) => syncState(s, layerInputs, groupInputs), false, '_sync'),\n }),\n { name: `legend-${id}`, enabled: isDev() },\n ),\n )\n}\n\n// ─── Registry ───────────────────────────────────────────────────────────────\n\n/** @experimental This API is new and may change in a future release. */\nexport function getLegendStore(id: string): LegendStoreApi {\n const store = legendStores.get(id)\n if (!store) throw new Error(`[legend] Legend store \"${id}\" not found.`)\n return store\n}\n\n/** @experimental This API is new and may change in a future release. */\nexport function hasLegendStore(id: string): boolean {\n return legendStores.has(id)\n}\n\n/** @experimental This API is new and may change in a future release. */\nexport function deleteLegendStore(id: string): void {\n legendStores.delete(id)\n}\n\n/** @experimental This API is new and may change in a future release. */\nexport function clearAllLegendStores(): void {\n legendStores.clear()\n legendMountCounts.clear()\n warnedDuplicates.clear()\n}\n\n/**\n * @internal — used by Provider's lazy init so children can resolve the store first render.\n *\n * @experimental This API is new and may change in a future release.\n */\nexport function setLegendStoreEntry(id: string, store: LegendStoreApi): void {\n legendStores.set(id, store)\n}\n\n/**\n * @internal — registers a Provider mount and warns on duplicate ids in dev.\n *\n * @experimental This API is new and may change in a future release.\n */\nexport function registerLegendStore(id: string, store: LegendStoreApi): void {\n legendStores.set(id, store)\n const count = (legendMountCounts.get(id) ?? 0) + 1\n legendMountCounts.set(id, count)\n if (count > 1 && isDev() && !warnedDuplicates.has(id)) {\n // eslint-disable-next-line no-console\n console.warn(\n `[legend] Duplicate <Legend.Provider id=\"${id}\"> detected. ` +\n `Multiple providers sharing an id will race on prop sync. ` +\n `Use unique ids per legend panel.`,\n )\n warnedDuplicates.add(id)\n }\n}\n\n/**\n * @internal — Provider unmount counterpart; removes the entry on last unmount.\n *\n * @experimental This API is new and may change in a future release.\n */\nexport function unregisterLegendStore(\n id: string,\n options: { keepAlive: boolean },\n): void {\n const count = (legendMountCounts.get(id) ?? 1) - 1\n if (count <= 0) {\n legendMountCounts.delete(id)\n if (!options.keepAlive) legendStores.delete(id)\n } else {\n legendMountCounts.set(id, count)\n }\n}\n\n// ─── Hooks ────────────────────────────────────────────────────────────────────\n\n/** @experimental This API is new and may change in a future release. */\nexport function useLegendStore<T>(\n id: string,\n selector: (state: LegendState) => T,\n): T {\n const store = getLegendStore(id) as unknown as StoreApi<LegendState>\n return useStore(store, selector)\n}\n\n/** @experimental This API is new and may change in a future release. */\nexport function useLegendShallow<T>(\n id: string,\n selector: (state: LegendState) => T,\n): T {\n const store = getLegendStore(id) as unknown as StoreApi<LegendState>\n return useStore(store, useShallow(selector))\n}\n","import type { LegendGroup, LegendLayer, LegendState } from './types'\n\nconst byOrder = <T extends { order: number }>(a: T, b: T): number =>\n a.order - b.order\n\n/**\n * Groups sorted by `order`.\n *\n * @experimental This API is new and may change in a future release.\n */\nexport function selectOrderedGroups(state: LegendState): LegendGroup[] {\n return Object.values(state.groups).sort(byOrder)\n}\n\n/**\n * Layers belonging to `groupId` (pass `undefined` for ungrouped, top-level\n * layers), sorted by `order`.\n *\n * @experimental This API is new and may change in a future release.\n */\nexport function selectLayersByGroup(\n state: LegendState,\n groupId: string | undefined,\n): LegendLayer[] {\n return Object.values(state.layers)\n .filter((l) => l.groupId === groupId)\n .sort(byOrder)\n}\n\n/**\n * All layers sorted by `order`, regardless of group.\n *\n * @experimental This API is new and may change in a future release.\n */\nexport function selectOrderedLayers(state: LegendState): LegendLayer[] {\n return Object.values(state.layers).sort(byOrder)\n}\n\n/**\n * Tri-state visibility — derived for groups from their member layers, and the\n * state contract of a controlled `Legend.VisibilityToggle` for any custom\n * element kind.\n */\nexport type LegendVisibility = 'visible' | 'hidden' | 'mixed'\n\n/**\n * Tri-state group visibility: `'visible'` when every member layer is visible\n * (also for empty groups), `'hidden'` when none is, `'mixed'` otherwise.\n *\n * @experimental This API is new and may change in a future release.\n */\nexport function selectGroupVisibility(\n state: LegendState,\n groupId: string,\n): LegendVisibility {\n let anyVisible = false\n let anyHidden = false\n for (const layer of Object.values(state.layers)) {\n if (layer.groupId !== groupId) continue\n if (layer.visible) anyVisible = true\n else anyHidden = true\n }\n if (anyVisible && anyHidden) return 'mixed'\n return anyHidden ? 'hidden' : 'visible'\n}\n"],"names":["LegendContext","createContext","useLegendId","id","useContext","Error","legendStores","Map","legendMountCounts","warnedDuplicates","Set","isDev","import","clamp01","n","Math","min","max","visibilityPatch","entity","visible","collapsed","collapsedBeforeHide","undefined","collapsePatch","updateLayer","state","patch","layer","layers","updateGroup","group","groups","mergeSections","prev","next","merged","map","section","prevSection","find","p","active","options","includes","length","every","m","i","title","shallowEqualEntity","a","b","keys","Object","key","is","normalizeOrders","entries","bucketOf","buckets","entry","bucket","get","push","set","values","sort","order","index","forEach","mergeLayerEntity","input","fallbackOrder","opacity","sections","mergeGroupEntity","syncState","layerInputs","groupInputs","layerEntries","l","groupId","groupEntries","layersChanged","groupsChanged","rebuildRecord","e","changed","out","before","upsertLayerState","siblingCount","filter","removeLayerState","upsertGroupState","count","g","removeGroupState","nextGroups","members","nextLayers","member","createLegendStore","init","seeded","createStore","devtools","setVisibility","lid","s","setOpacity","setCollapsed","setSectionValue","sectionId","value","x","setGroupVisibility","gid","anyVisible","some","groupPatch","setGroupCollapsed","hidden","setLegendLayer","removeLegendLayer","setLegendGroup","removeLegendGroup","_sync","name","enabled","getLegendStore","store","hasLegendStore","has","deleteLegendStore","delete","clearAllLegendStores","clear","setLegendStoreEntry","registerLegendStore","console","warn","add","unregisterLegendStore","keepAlive","useLegendStore","selector","$","_c","t0","useStore","useLegendShallow","useShallow","byOrder","selectOrderedGroups","selectLayersByGroup","selectOrderedLayers","selectGroupVisibility","anyHidden"],"mappings":";;;;;;AAGO,MAAMA,IAAgBC,EAA6B,IAA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ClB,MAAIqC,IAAa,IACbwC,IAAY;AAChB,aAAWnI,KAAS0B,OAAOY,OAAOxC,EAAMG,MAAM;AAC5C,IAAID,EAAMsD,YAAYA,MAClBtD,EAAMR,UAASmG,IAAa,KAC3BwC,IAAY;AAEnB,SAAIxC,KAAcwC,IAAkB,UAC7BA,IAAY,WAAW;AAChC;"}
@@ -18,5 +18,6 @@ export { BasemapsUI } from './basemaps/basemaps';
18
18
  export type { BasemapsUIProps } from './basemaps/types';
19
19
  export { Tooltip, setTooltipEnterDelay } from './tooltip/tooltip';
20
20
  export { SmartTooltip } from './smart-tooltip/smart-tooltip';
21
+ export { ResponsiveDrawer } from './responsive-drawer/responsive-drawer';
21
22
  export type { CopyButtonProps } from './copy-button/types';
22
23
  export { CopyButton } from './copy-button/copy-button';
@@ -1,12 +1,44 @@
1
- import { PopoverProps } from '@mui/material';
1
+ import { PopoverOrigin, PopoverProps } from '@mui/material';
2
2
  import { ReactNode } from 'react';
3
+ type ResponsiveDrawerPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
4
+ /** Placement of the panel relative to its anchor (desktop popover only). */
5
+ export type ResponsiveDrawerPlacement = 'side' | 'overlay';
6
+ /**
7
+ * Resolve the Popover anchor/transform origins for a given corner + placement.
8
+ *
9
+ * `transformOrigin` (the panel corner that pins to the anchor point) is the same
10
+ * for both placements: the panel's own corner matching `position`. `anchorOrigin`
11
+ * (the point on the anchor the panel pins to) differs:
12
+ * - `'side'` flips horizontally → the panel opens beside the trigger.
13
+ * - `'overlay'` uses the same corner → the panel sits **on top of** the anchor
14
+ * (e.g. a trigger that's hidden while the panel is open), pinned corner-to-corner.
15
+ */
16
+ export declare function resolveOrigins(position: ResponsiveDrawerPosition, placement: ResponsiveDrawerPlacement): {
17
+ anchorOrigin: PopoverOrigin;
18
+ transformOrigin: PopoverOrigin;
19
+ };
3
20
  export declare function ResponsiveDrawer<T extends {
4
21
  collapsed: boolean;
5
22
  onChangeCollapsed: (collapsed: boolean) => void;
6
- position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
23
+ position: ResponsiveDrawerPosition;
7
24
  slotProps?: PopoverProps['slotProps'];
8
- }>({ ref, children, collapsed, isMobile, position, sx, slotProps, onChangeCollapsed, }: Required<Pick<T, 'collapsed' | 'onChangeCollapsed' | 'position'>> & Pick<PopoverProps, 'slotProps' | 'sx'> & {
25
+ }>({ ref, children, collapsed, isMobile, position, sx, slotProps, onChangeCollapsed, modal, placement, }: Required<Pick<T, 'collapsed' | 'onChangeCollapsed' | 'position'>> & Pick<PopoverProps, 'slotProps' | 'sx'> & {
9
26
  ref: HTMLElement | null;
10
27
  isMobile: boolean;
11
28
  children: ReactNode;
29
+ /**
30
+ * When `false`, the desktop popover is **non-modal**: no backdrop, clicks
31
+ * pass through to the content behind it (e.g. a map stays interactive), no
32
+ * focus trap, and neither backdrop-click nor Escape closes it (close it via
33
+ * `onChangeCollapsed`). Defaults to `true` (standard dismissable popover).
34
+ * Desktop-only — the mobile drawer is unaffected.
35
+ */
36
+ modal?: boolean;
37
+ /**
38
+ * Desktop popover placement relative to the anchor: `'side'` (default) opens
39
+ * beside the trigger; `'overlay'` pins corner-to-corner, sitting on top of
40
+ * the anchor (e.g. a trigger hidden while the panel is open). Desktop-only.
41
+ */
42
+ placement?: ResponsiveDrawerPlacement;
12
43
  }): import("react/jsx-runtime").JSX.Element;
44
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Per-row composition context provided by `Legend.Row`. Actions placed inside
3
+ * the row resolve their target layer from here instead of taking a `layerId`
4
+ * prop, and the opacity compound shares its popover state through it (the
5
+ * popover anchors to the row's sticky header element to span its full width).
6
+ */
7
+ export interface LegendRowContextValue {
8
+ layerId: string;
9
+ /** The row's sticky header element — anchor for `Legend.Opacity.Popover`. */
10
+ headerEl: HTMLElement | null;
11
+ opacityOpen: boolean;
12
+ setOpacityOpen: (open: boolean) => void;
13
+ }
14
+ export declare const LegendRowContext: import('react').Context<LegendRowContextValue | null>;
15
+ /** Nearest `Legend.Row` composition context, or `null` outside a row. */
16
+ export declare function useLegendRow(): LegendRowContextValue | null;
17
+ /** Per-group composition context provided by `Legend.Group` (the group id). */
18
+ export declare const LegendGroupContext: import('react').Context<string | null>;
19
+ /** Nearest `Legend.Group` id, or `null` outside a group. */
20
+ export declare function useLegendGroupId(): string | null;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Indeterminate visibility — an outlined eye with an internal slash, shown on
3
+ * a group whose member layers are partially hidden ("mixed" state). Path data
4
+ * exported from the Figma source (`MUI_visibility_indeterminate`, CARTO PS Lib
5
+ * Documentation node 5877-16982); the glyph is centered at (184, 24) in the
6
+ * header frame and drawn on a 18px grid (75% of the 24px box), so it is
7
+ * re-centered into the standard viewBox and scaled by 4/3 — the resulting
8
+ * 22×15-unit eye matches the MUI `Visibility*` icons exactly.
9
+ */
10
+ export declare const VisibilityIndeterminateIcon: import('../../../node_modules/@mui/material/OverridableComponent').OverridableComponent<import('node_modules/@mui/material').SvgIconTypeMap<{}, "svg">> & {
11
+ muiName: string;
12
+ };
@@ -0,0 +1,26 @@
1
+ export { LegendGroup } from './legend-group/legend-group';
2
+ export type { LegendGroupProps } from './legend-group/legend-group';
3
+ export { LegendRow } from './legend-row/legend-row';
4
+ export type { LegendRowProps } from './legend-row/legend-row';
5
+ export { LegendActions } from './legend-actions/legend-actions';
6
+ export type { LegendActionsProps } from './legend-actions/legend-actions';
7
+ export { LegendRowContext, LegendGroupContext, useLegendRow, useLegendGroupId, } from './contexts';
8
+ export type { LegendRowContextValue } from './contexts';
9
+ export { LegendVisibilityToggle } from './legend-visibility-toggle/legend-visibility-toggle';
10
+ export { LegendRowMenu } from './legend-row-menu/legend-row-menu';
11
+ export { LegendZoomTo } from './legend-row-menu/legend-zoom-to';
12
+ export { LegendOpacity } from './legend-opacity/legend-opacity';
13
+ export { LegendConfigSelect } from './legend-config-select/legend-config-select';
14
+ export { LegendItem } from './legend-item/legend-item';
15
+ export { LegendItemUI } from './legend-item/legend-item-ui';
16
+ export type { LegendItemUIProps } from './legend-item/legend-item-ui';
17
+ export { LegendSwatch, DEFAULT_SWATCH_SIZE, } from './legend-swatch/legend-swatch';
18
+ export type { LegendSwatchProps } from './legend-swatch/legend-swatch';
19
+ export { LegendCategoryUI } from './legend-category/legend-category-ui';
20
+ export type { LegendCategoryUIProps } from './legend-category/legend-category-ui';
21
+ export { LegendRampUI } from './legend-ramp/legend-ramp-ui';
22
+ export type { LegendRampUIProps } from './legend-ramp/legend-ramp-ui';
23
+ export { LegendProportionUI } from './legend-proportion/legend-proportion-ui';
24
+ export type { LegendProportionUIProps } from './legend-proportion/legend-proportion-ui';
25
+ export { LegendIconUI } from './legend-icon/legend-icon-ui';
26
+ export type { LegendIconUIProps } from './legend-icon/legend-icon-ui';
@@ -0,0 +1,24 @@
1
+ import { ReactNode } from 'react';
2
+ export interface LegendActionsProps {
3
+ children?: ReactNode;
4
+ }
5
+ /**
6
+ * Header actions slot for `Legend.Row` / `Legend.Group` (widgets-v2 `Actions`
7
+ * parity): the wrapper partitions its children by component identity and
8
+ * renders this slot inside the header, next to the collapse chevron, wrapped
9
+ * in the hover-fade group (`PsLegend-rowFade` in rows, `PsLegend-groupFade`
10
+ * in group headers — resolved from the nearest context).
11
+ *
12
+ * @experimental This API is new and may change in a future release.
13
+ */
14
+ export declare function LegendActions({ children }: LegendActionsProps): import("react/jsx-runtime").JSX.Element;
15
+ /**
16
+ * Splits a wrapper's children by component identity: `<Legend.Actions>`
17
+ * elements belong in the header, everything else in the collapsible body.
18
+ * Identity comparison works because consumers import the slot from the same
19
+ * module (same pattern as widgets-v2 `Wrapper`).
20
+ */
21
+ export declare function partitionLegendChildren(children: ReactNode): {
22
+ actions: ReactNode[];
23
+ body: ReactNode[];
24
+ };
@@ -0,0 +1,7 @@
1
+ export declare const styles: {
2
+ fadeGroup: {
3
+ display: "flex";
4
+ alignItems: "center";
5
+ gap: number;
6
+ };
7
+ };
@@ -0,0 +1,13 @@
1
+ import { LegendCategoryVariable } from '../../stores';
2
+ export interface LegendCategoryUIProps {
3
+ data: LegendCategoryVariable;
4
+ }
5
+ /**
6
+ * Categorical legend — a list of swatches with labels (and optional trailing
7
+ * values, compact-formatted). The variable-level shape / fill pattern /
8
+ * stroke style / `isStrokeColor` act as defaults; each item may override any
9
+ * of them, so one list can mix patterns (or shapes) across entries.
10
+ *
11
+ * @experimental This API is new and may change in a future release.
12
+ */
13
+ export declare function LegendCategoryUI({ data }: LegendCategoryUIProps): import("react/jsx-runtime").JSX.Element;