@carto/ps-react-ui 4.17.2 → 4.17.3
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/legend/stores.js +1 -1
- package/dist/{legend-store-registry-Bo8U_qWM.js → legend-store-registry-p1tSwJXH.js} +151 -147
- package/dist/legend-store-registry-p1tSwJXH.js.map +1 -0
- package/dist/legend.js +473 -415
- package/dist/legend.js.map +1 -1
- package/dist/types/legend/components/legend-actions/legend-actions.d.ts +2 -2
- package/dist/types/legend/components/legend-group/styles.d.ts +31 -20
- package/dist/types/legend/components/legend-row/styles.d.ts +24 -4
- package/dist/types/legend/components/legend-sortable/styles.d.ts +4 -3
- package/package.json +3 -3
- package/src/legend/components/legend-actions/legend-actions.tsx +2 -2
- package/src/legend/components/legend-group/styles.ts +59 -36
- package/src/legend/components/legend-row/legend-row.tsx +10 -7
- package/src/legend/components/legend-row/styles.ts +41 -10
- package/src/legend/components/legend-sortable/styles.ts +13 -4
- package/src/legend/stores/legend-store-registry.ts +28 -4
- package/src/legend/stores/legend-store.test.ts +23 -0
- package/dist/legend-store-registry-Bo8U_qWM.js.map +0 -1
package/dist/legend/stores.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as r, c as a, a as t, d as l, g as o, h as d, r as L, s as g, b as n, e as c, f as u, i, j as p, k as S, l as y, m as G, u as b, n as h, o as C, p as f } from "../legend-store-registry-
|
|
1
|
+
import { L as r, c as a, a as t, d as l, g as o, h as d, r as L, s as g, b as n, e as c, f as u, i, j as p, k as S, l as y, m as G, u as b, n as h, o as C, p as f } from "../legend-store-registry-p1tSwJXH.js";
|
|
2
2
|
export {
|
|
3
3
|
r as LegendContext,
|
|
4
4
|
a as clearAllLegendStores,
|
|
@@ -29,17 +29,17 @@ function ne(e) {
|
|
|
29
29
|
return Object.keys(e.groups).length > 0;
|
|
30
30
|
}
|
|
31
31
|
function le(e) {
|
|
32
|
-
const r = (o) => O(e, o).filter((
|
|
32
|
+
const r = (o) => O(e, o).filter((t) => t.visible), n = [];
|
|
33
33
|
for (const o of E(e)) {
|
|
34
|
-
const
|
|
35
|
-
|
|
34
|
+
const t = r(o.id);
|
|
35
|
+
t.length > 0 && n.push({
|
|
36
36
|
group: o,
|
|
37
|
-
layers:
|
|
37
|
+
layers: t
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
const
|
|
41
|
-
return
|
|
42
|
-
layers:
|
|
40
|
+
const s = r(void 0);
|
|
41
|
+
return s.length > 0 && n.push({
|
|
42
|
+
layers: s
|
|
43
43
|
}), n;
|
|
44
44
|
}
|
|
45
45
|
function ce(e, r) {
|
|
@@ -49,12 +49,12 @@ function ce(e, r) {
|
|
|
49
49
|
!!n.helperText : !1;
|
|
50
50
|
}
|
|
51
51
|
function ue(e, r) {
|
|
52
|
-
let n = !1,
|
|
52
|
+
let n = !1, s = !1;
|
|
53
53
|
for (const o of O(e, r))
|
|
54
|
-
o.visible ? n = !0 :
|
|
55
|
-
return n &&
|
|
54
|
+
o.visible ? n = !0 : s = !0;
|
|
55
|
+
return n && s ? "mixed" : s ? "hidden" : "visible";
|
|
56
56
|
}
|
|
57
|
-
const p = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(),
|
|
57
|
+
const p = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Set(), H = () => {
|
|
58
58
|
try {
|
|
59
59
|
return !1;
|
|
60
60
|
} catch {
|
|
@@ -86,37 +86,37 @@ function R(e, r) {
|
|
|
86
86
|
collapsedBeforeHide: r
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
89
|
+
function I(e, r, n) {
|
|
90
|
+
const s = e.findIndex((i) => i.id === r);
|
|
91
|
+
if (s === -1) return null;
|
|
92
92
|
const o = Math.max(0, Math.min(e.length - 1, n));
|
|
93
|
-
if (o ===
|
|
94
|
-
const
|
|
95
|
-
|
|
93
|
+
if (o === s) return null;
|
|
94
|
+
const t = [...e], [l] = t.splice(s, 1);
|
|
95
|
+
t.splice(o, 0, l);
|
|
96
96
|
const c = /* @__PURE__ */ new Map();
|
|
97
|
-
return
|
|
98
|
-
i.order !==
|
|
97
|
+
return t.forEach((i, d) => {
|
|
98
|
+
i.order !== d && c.set(i.id, d);
|
|
99
99
|
}), c.size > 0 ? c : null;
|
|
100
100
|
}
|
|
101
101
|
function h(e, r, n) {
|
|
102
|
-
const
|
|
103
|
-
return
|
|
102
|
+
const s = e.layers[r];
|
|
103
|
+
return s ? {
|
|
104
104
|
layers: {
|
|
105
105
|
...e.layers,
|
|
106
106
|
[r]: {
|
|
107
|
-
...
|
|
107
|
+
...s,
|
|
108
108
|
...n
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
} : {};
|
|
112
112
|
}
|
|
113
113
|
function T(e, r, n) {
|
|
114
|
-
const
|
|
115
|
-
return
|
|
114
|
+
const s = e.groups[r];
|
|
115
|
+
return s ? {
|
|
116
116
|
groups: {
|
|
117
117
|
...e.groups,
|
|
118
118
|
[r]: {
|
|
119
|
-
...
|
|
119
|
+
...s,
|
|
120
120
|
...n
|
|
121
121
|
}
|
|
122
122
|
}
|
|
@@ -125,36 +125,36 @@ function T(e, r, n) {
|
|
|
125
125
|
function U(e, r) {
|
|
126
126
|
if (!r || !e || e === r) return r;
|
|
127
127
|
const n = r.map((o) => {
|
|
128
|
-
const
|
|
129
|
-
return
|
|
128
|
+
const t = e.find((l) => l.id === o.id);
|
|
129
|
+
return t && t.active !== o.active && o.options.includes(t.active) ? {
|
|
130
130
|
...o,
|
|
131
|
-
active:
|
|
131
|
+
active: t.active
|
|
132
132
|
} : o;
|
|
133
133
|
});
|
|
134
|
-
return e.length === n.length && n.every((o,
|
|
135
|
-
const l = e[
|
|
134
|
+
return e.length === n.length && n.every((o, t) => {
|
|
135
|
+
const l = e[t];
|
|
136
136
|
return l.id === o.id && l.title === o.title && l.options === o.options && l.active === o.active;
|
|
137
137
|
}) ? e : n;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function W(e, r) {
|
|
140
140
|
return !j(e) || !j(r) || e.type !== r.type || e.key !== r.key ? !1 : v(e.props, r.props);
|
|
141
141
|
}
|
|
142
142
|
function v(e, r) {
|
|
143
143
|
const n = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(r)]);
|
|
144
|
-
for (const
|
|
145
|
-
if (!Object.is(e[
|
|
144
|
+
for (const s of n)
|
|
145
|
+
if (!Object.is(e[s], r[s]) && !W(e[s], r[s]))
|
|
146
146
|
return !1;
|
|
147
147
|
return !0;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function L(e, r) {
|
|
150
150
|
const n = /* @__PURE__ */ new Map();
|
|
151
|
-
for (const
|
|
152
|
-
const o = r(
|
|
153
|
-
|
|
151
|
+
for (const s of e) {
|
|
152
|
+
const o = r(s.merged), t = n.get(o);
|
|
153
|
+
t ? t.push(s) : n.set(o, [s]);
|
|
154
154
|
}
|
|
155
|
-
for (const
|
|
156
|
-
|
|
157
|
-
o.merged.order =
|
|
155
|
+
for (const s of n.values())
|
|
156
|
+
s.sort((o, t) => o.merged.order - t.merged.order || o.index - t.index).forEach((o, t) => {
|
|
157
|
+
o.merged.order = t;
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
function V(e, r, n) {
|
|
@@ -168,118 +168,122 @@ function V(e, r, n) {
|
|
|
168
168
|
order: e?.order ?? r.order ?? n
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
-
function M(e, r, n) {
|
|
171
|
+
function M(e, r, n, s) {
|
|
172
172
|
return {
|
|
173
173
|
...r,
|
|
174
|
-
collapsed: e?.collapsed ?? r.collapsed ?? !
|
|
174
|
+
collapsed: e?.collapsed ?? r.collapsed ?? !s,
|
|
175
175
|
collapsedBeforeHide: e?.collapsedBeforeHide,
|
|
176
176
|
order: e?.order ?? r.order ?? n
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
|
-
function
|
|
180
|
-
const
|
|
179
|
+
function k(e, r, n) {
|
|
180
|
+
const s = r.map((u, a) => ({
|
|
181
181
|
index: a,
|
|
182
182
|
merged: V(e.layers[u.id], u, a)
|
|
183
183
|
}));
|
|
184
|
-
|
|
185
|
-
const o =
|
|
184
|
+
L(s, (u) => u.groupId);
|
|
185
|
+
const o = new Set(s.filter(({
|
|
186
|
+
merged: u
|
|
187
|
+
}) => u.visible && u.groupId != null).map(({
|
|
188
|
+
merged: u
|
|
189
|
+
}) => u.groupId)), t = n.map((u, a) => ({
|
|
186
190
|
index: a,
|
|
187
|
-
merged: M(e.groups[u.id], u, a)
|
|
191
|
+
merged: M(e.groups[u.id], u, a, o.has(u.id))
|
|
188
192
|
}));
|
|
189
|
-
|
|
193
|
+
L(t, () => {
|
|
190
194
|
});
|
|
191
|
-
let
|
|
192
|
-
const
|
|
195
|
+
let l = s.length !== Object.keys(e.layers).length;
|
|
196
|
+
const c = {};
|
|
193
197
|
for (const {
|
|
194
198
|
merged: u
|
|
195
|
-
} of
|
|
199
|
+
} of s) {
|
|
196
200
|
const a = e.layers[u.id];
|
|
197
|
-
a && v(a, u) ?
|
|
201
|
+
a && v(a, u) ? c[u.id] = a : (c[u.id] = u, l = !0);
|
|
198
202
|
}
|
|
199
|
-
let
|
|
200
|
-
const
|
|
203
|
+
let i = t.length !== Object.keys(e.groups).length;
|
|
204
|
+
const d = {};
|
|
201
205
|
for (const {
|
|
202
206
|
merged: u
|
|
203
|
-
} of
|
|
207
|
+
} of t) {
|
|
204
208
|
const a = e.groups[u.id];
|
|
205
|
-
a && v(a, u) ?
|
|
209
|
+
a && v(a, u) ? d[u.id] = a : (d[u.id] = u, i = !0);
|
|
206
210
|
}
|
|
207
|
-
return !
|
|
208
|
-
layers:
|
|
209
|
-
groups:
|
|
211
|
+
return !l && !i ? {} : {
|
|
212
|
+
layers: l ? c : e.layers,
|
|
213
|
+
groups: i ? d : e.groups
|
|
210
214
|
};
|
|
211
215
|
}
|
|
212
216
|
function m(e, r, n) {
|
|
213
|
-
const
|
|
217
|
+
const s = Object.values(r).map((l, c) => ({
|
|
214
218
|
index: c,
|
|
215
219
|
merged: {
|
|
216
220
|
...l
|
|
217
221
|
}
|
|
218
222
|
}));
|
|
219
|
-
|
|
220
|
-
let o =
|
|
221
|
-
const
|
|
223
|
+
L(s, n);
|
|
224
|
+
let o = s.length !== Object.keys(e).length;
|
|
225
|
+
const t = {};
|
|
222
226
|
for (const {
|
|
223
227
|
merged: l
|
|
224
|
-
} of
|
|
228
|
+
} of s) {
|
|
225
229
|
const c = e[l.id];
|
|
226
|
-
c && v(c, l) ?
|
|
230
|
+
c && v(c, l) ? t[l.id] = c : (t[l.id] = l, o = !0);
|
|
227
231
|
}
|
|
228
|
-
return o ?
|
|
232
|
+
return o ? t : null;
|
|
229
233
|
}
|
|
230
|
-
function
|
|
231
|
-
const n = Object.values(e.layers).filter((
|
|
234
|
+
function F(e, r) {
|
|
235
|
+
const n = Object.values(e.layers).filter((t) => t.groupId === r.groupId && t.id !== r.id).length, s = V(e.layers[r.id], r, n), o = m(e.layers, {
|
|
232
236
|
...e.layers,
|
|
233
|
-
[r.id]:
|
|
234
|
-
}, (
|
|
237
|
+
[r.id]: s
|
|
238
|
+
}, (t) => t.groupId);
|
|
235
239
|
return o ? {
|
|
236
240
|
layers: o
|
|
237
241
|
} : {};
|
|
238
242
|
}
|
|
239
|
-
function
|
|
243
|
+
function J(e, r) {
|
|
240
244
|
if (!e.layers[r]) return {};
|
|
241
245
|
const n = {
|
|
242
246
|
...e.layers
|
|
243
247
|
};
|
|
244
248
|
delete n[r];
|
|
245
|
-
const
|
|
246
|
-
return
|
|
247
|
-
layers:
|
|
249
|
+
const s = m(e.layers, n, (o) => o.groupId);
|
|
250
|
+
return s ? {
|
|
251
|
+
layers: s
|
|
248
252
|
} : {};
|
|
249
253
|
}
|
|
250
|
-
function
|
|
251
|
-
const n = Object.values(e.groups).filter((
|
|
254
|
+
function K(e, r) {
|
|
255
|
+
const n = Object.values(e.groups).filter((l) => l.id !== r.id).length, s = Object.values(e.layers).some((l) => l.groupId === r.id && l.visible), o = M(e.groups[r.id], r, n, s), t = m(e.groups, {
|
|
252
256
|
...e.groups,
|
|
253
|
-
[r.id]:
|
|
257
|
+
[r.id]: o
|
|
254
258
|
}, () => {
|
|
255
259
|
});
|
|
256
|
-
return
|
|
257
|
-
groups:
|
|
260
|
+
return t ? {
|
|
261
|
+
groups: t
|
|
258
262
|
} : {};
|
|
259
263
|
}
|
|
260
|
-
function
|
|
264
|
+
function N(e, r) {
|
|
261
265
|
if (!e.groups[r]) return {};
|
|
262
266
|
const n = {
|
|
263
267
|
...e.groups
|
|
264
268
|
};
|
|
265
269
|
delete n[r];
|
|
266
|
-
const
|
|
270
|
+
const s = m(e.groups, n, () => {
|
|
267
271
|
}), o = Object.values(e.layers).filter((c) => c.groupId === r);
|
|
268
|
-
if (o.length === 0) return
|
|
269
|
-
groups:
|
|
272
|
+
if (o.length === 0) return s ? {
|
|
273
|
+
groups: s
|
|
270
274
|
} : {};
|
|
271
|
-
const
|
|
275
|
+
const t = {
|
|
272
276
|
...e.layers
|
|
273
277
|
};
|
|
274
278
|
for (const c of o)
|
|
275
|
-
|
|
279
|
+
t[c.id] = {
|
|
276
280
|
...c,
|
|
277
281
|
groupId: void 0
|
|
278
282
|
};
|
|
279
|
-
const l = m(e.layers,
|
|
283
|
+
const l = m(e.layers, t, (c) => c.groupId);
|
|
280
284
|
return {
|
|
281
|
-
...
|
|
282
|
-
groups:
|
|
285
|
+
...s ? {
|
|
286
|
+
groups: s
|
|
283
287
|
} : {},
|
|
284
288
|
...l ? {
|
|
285
289
|
layers: l
|
|
@@ -287,79 +291,79 @@ function Q(e, r) {
|
|
|
287
291
|
};
|
|
288
292
|
}
|
|
289
293
|
function ie(e, r = {}) {
|
|
290
|
-
const n =
|
|
294
|
+
const n = k({
|
|
291
295
|
layers: {},
|
|
292
296
|
groups: {}
|
|
293
297
|
}, r.layers ?? [], r.groups ?? []);
|
|
294
|
-
return $()(q((
|
|
298
|
+
return $()(q((s) => ({
|
|
295
299
|
layers: n.layers ?? {},
|
|
296
300
|
groups: n.groups ?? {},
|
|
297
|
-
setVisibility: (o,
|
|
298
|
-
const c = l.layers[o], i = c && w(c,
|
|
301
|
+
setVisibility: (o, t) => s((l) => {
|
|
302
|
+
const c = l.layers[o], i = c && w(c, t);
|
|
299
303
|
return i ? h(l, o, i) : {};
|
|
300
304
|
}, !1, "setVisibility"),
|
|
301
|
-
setOpacity: (o,
|
|
302
|
-
opacity: _(
|
|
305
|
+
setOpacity: (o, t) => s((l) => h(l, o, {
|
|
306
|
+
opacity: _(t)
|
|
303
307
|
}), !1, "setOpacity"),
|
|
304
|
-
setCollapsed: (o,
|
|
308
|
+
setCollapsed: (o, t) => s((l) => {
|
|
305
309
|
const c = l.layers[o];
|
|
306
|
-
return c ? h(l, o, R(c,
|
|
310
|
+
return c ? h(l, o, R(c, t)) : {};
|
|
307
311
|
}, !1, "setCollapsed"),
|
|
308
|
-
setSectionValue: (o,
|
|
309
|
-
const i = c.layers[o],
|
|
310
|
-
if (!i?.sections || !
|
|
312
|
+
setSectionValue: (o, t, l) => s((c) => {
|
|
313
|
+
const i = c.layers[o], d = i?.sections?.find((a) => a.id === t);
|
|
314
|
+
if (!i?.sections || !d || d.active === l || !d.options.includes(l))
|
|
311
315
|
return {};
|
|
312
|
-
const
|
|
313
|
-
...
|
|
316
|
+
const u = i.sections.map((a) => a.id === t ? {
|
|
317
|
+
...a,
|
|
314
318
|
active: l
|
|
315
|
-
} :
|
|
319
|
+
} : a);
|
|
316
320
|
return h(c, o, {
|
|
317
|
-
sections:
|
|
321
|
+
sections: u
|
|
318
322
|
});
|
|
319
323
|
}, !1, "setSectionValue"),
|
|
320
|
-
moveLayer: (o,
|
|
324
|
+
moveLayer: (o, t) => s((l) => {
|
|
321
325
|
const c = l.layers[o];
|
|
322
326
|
if (!c) return {};
|
|
323
|
-
const i = O(l, c.groupId),
|
|
324
|
-
if (!
|
|
325
|
-
const
|
|
327
|
+
const i = O(l, c.groupId), d = I(i, o, t);
|
|
328
|
+
if (!d) return {};
|
|
329
|
+
const u = {
|
|
326
330
|
...l.layers
|
|
327
331
|
};
|
|
328
|
-
for (const [
|
|
329
|
-
a
|
|
330
|
-
...a
|
|
332
|
+
for (const [a, g] of d)
|
|
333
|
+
u[a] = {
|
|
334
|
+
...u[a],
|
|
331
335
|
order: g
|
|
332
336
|
};
|
|
333
337
|
return {
|
|
334
|
-
layers:
|
|
338
|
+
layers: u
|
|
335
339
|
};
|
|
336
340
|
}, !1, "moveLayer"),
|
|
337
|
-
setGroupVisibility: (o,
|
|
341
|
+
setGroupVisibility: (o, t) => s((l) => {
|
|
338
342
|
const c = l.groups[o];
|
|
339
343
|
if (!c) return {};
|
|
340
|
-
const i = Object.values(l.layers).filter((f) => f.groupId === o),
|
|
341
|
-
if (i.length === 0 || !
|
|
342
|
-
const
|
|
344
|
+
const i = Object.values(l.layers).filter((f) => f.groupId === o), d = i.some((f) => f.visible);
|
|
345
|
+
if (i.length === 0 || !t && !d) return {};
|
|
346
|
+
const u = {
|
|
343
347
|
...l.layers
|
|
344
348
|
};
|
|
345
|
-
let
|
|
349
|
+
let a = !1;
|
|
346
350
|
for (const f of i) {
|
|
347
|
-
const G = w(f,
|
|
348
|
-
G && (
|
|
351
|
+
const G = w(f, t);
|
|
352
|
+
G && (u[f.id] = {
|
|
349
353
|
...f,
|
|
350
354
|
...G
|
|
351
|
-
},
|
|
355
|
+
}, a = !0);
|
|
352
356
|
}
|
|
353
|
-
if (!
|
|
357
|
+
if (!a) return {};
|
|
354
358
|
let g = null;
|
|
355
|
-
return !
|
|
359
|
+
return !t && d ? g = {
|
|
356
360
|
collapsed: !0,
|
|
357
361
|
collapsedBeforeHide: c.collapsed
|
|
358
|
-
} :
|
|
362
|
+
} : t && !d && (g = {
|
|
359
363
|
collapsed: c.collapsedBeforeHide ?? !1,
|
|
360
364
|
collapsedBeforeHide: void 0
|
|
361
365
|
}), {
|
|
362
|
-
layers:
|
|
366
|
+
layers: u,
|
|
363
367
|
...g ? {
|
|
364
368
|
groups: {
|
|
365
369
|
...l.groups,
|
|
@@ -371,37 +375,37 @@ function ie(e, r = {}) {
|
|
|
371
375
|
} : {}
|
|
372
376
|
};
|
|
373
377
|
}, !1, "setGroupVisibility"),
|
|
374
|
-
setGroupCollapsed: (o,
|
|
378
|
+
setGroupCollapsed: (o, t) => s((l) => {
|
|
375
379
|
if (!l.groups[o]) return {};
|
|
376
|
-
const i = Object.values(l.layers).filter((
|
|
377
|
-
return T(l, o,
|
|
378
|
-
collapsed:
|
|
379
|
-
collapsedBeforeHide:
|
|
380
|
+
const i = Object.values(l.layers).filter((u) => u.groupId === o), d = i.length > 0 && i.every((u) => !u.visible);
|
|
381
|
+
return T(l, o, d ? {
|
|
382
|
+
collapsed: t,
|
|
383
|
+
collapsedBeforeHide: t
|
|
380
384
|
} : {
|
|
381
|
-
collapsed:
|
|
385
|
+
collapsed: t
|
|
382
386
|
});
|
|
383
387
|
}, !1, "setGroupCollapsed"),
|
|
384
|
-
moveGroup: (o,
|
|
388
|
+
moveGroup: (o, t) => s((l) => {
|
|
385
389
|
if (!l.groups[o]) return {};
|
|
386
|
-
const c =
|
|
390
|
+
const c = I(E(l), o, t);
|
|
387
391
|
if (!c) return {};
|
|
388
392
|
const i = {
|
|
389
393
|
...l.groups
|
|
390
394
|
};
|
|
391
|
-
for (const [
|
|
392
|
-
i[
|
|
393
|
-
...i[
|
|
394
|
-
order:
|
|
395
|
+
for (const [d, u] of c)
|
|
396
|
+
i[d] = {
|
|
397
|
+
...i[d],
|
|
398
|
+
order: u
|
|
395
399
|
};
|
|
396
400
|
return {
|
|
397
401
|
groups: i
|
|
398
402
|
};
|
|
399
403
|
}, !1, "moveGroup"),
|
|
400
|
-
setLegendLayer: (o) =>
|
|
401
|
-
removeLegendLayer: (o) =>
|
|
402
|
-
setLegendGroup: (o) =>
|
|
403
|
-
removeLegendGroup: (o) =>
|
|
404
|
-
_sync: (o,
|
|
404
|
+
setLegendLayer: (o) => s((t) => F(t, o), !1, "setLegendLayer"),
|
|
405
|
+
removeLegendLayer: (o) => s((t) => J(t, o), !1, "removeLegendLayer"),
|
|
406
|
+
setLegendGroup: (o) => s((t) => K(t, o), !1, "setLegendGroup"),
|
|
407
|
+
removeLegendGroup: (o) => s((t) => N(t, o), !1, "removeLegendGroup"),
|
|
408
|
+
_sync: (o, t) => s((l) => k(l, o, t), !1, "_sync")
|
|
405
409
|
}), {
|
|
406
410
|
name: `legend-${e}`,
|
|
407
411
|
enabled: H()
|
|
@@ -419,7 +423,7 @@ function de(e) {
|
|
|
419
423
|
p.delete(e);
|
|
420
424
|
}
|
|
421
425
|
function fe() {
|
|
422
|
-
p.clear(), y.clear(),
|
|
426
|
+
p.clear(), y.clear(), b.clear();
|
|
423
427
|
}
|
|
424
428
|
function pe(e, r) {
|
|
425
429
|
p.set(e, r);
|
|
@@ -427,7 +431,7 @@ function pe(e, r) {
|
|
|
427
431
|
function ge(e, r) {
|
|
428
432
|
p.set(e, r);
|
|
429
433
|
const n = (y.get(e) ?? 0) + 1;
|
|
430
|
-
y.set(e, n), n > 1 && H() && !
|
|
434
|
+
y.set(e, n), n > 1 && H() && !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));
|
|
431
435
|
}
|
|
432
436
|
function ye(e, r) {
|
|
433
437
|
const n = (y.get(e) ?? 1) - 1;
|
|
@@ -435,13 +439,13 @@ function ye(e, r) {
|
|
|
435
439
|
}
|
|
436
440
|
function me(e, r) {
|
|
437
441
|
const n = B(2);
|
|
438
|
-
let
|
|
439
|
-
return n[0] !== e ? (
|
|
442
|
+
let s;
|
|
443
|
+
return n[0] !== e ? (s = x(e), n[0] = e, n[1] = s) : s = n[1], C(s, r);
|
|
440
444
|
}
|
|
441
445
|
function he(e, r) {
|
|
442
446
|
const n = B(2);
|
|
443
|
-
let
|
|
444
|
-
return n[0] !== e ? (
|
|
447
|
+
let s;
|
|
448
|
+
return n[0] !== e ? (s = x(e), n[0] = e, n[1] = s) : s = n[1], C(s, D(r));
|
|
445
449
|
}
|
|
446
450
|
export {
|
|
447
451
|
z as L,
|
|
@@ -465,4 +469,4 @@ export {
|
|
|
465
469
|
te as s,
|
|
466
470
|
ye as u
|
|
467
471
|
};
|
|
468
|
-
//# sourceMappingURL=legend-store-registry-
|
|
472
|
+
//# sourceMappingURL=legend-store-registry-p1tSwJXH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legend-store-registry-p1tSwJXH.js","sources":["../src/legend/stores/legend-context.ts","../src/legend/stores/selectors.ts","../src/legend/stores/legend-store-registry.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 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 * `true` when every group is collapsed (`false` with no groups) — drives the\n * \"Collapse all groups\" / \"Expand all groups\" menu label flip.\n *\n * @experimental This API is new and may change in a future release.\n */\nexport function selectAllGroupsCollapsed(state: LegendState): boolean {\n const groups = Object.values(state.groups)\n return groups.length > 0 && groups.every((g) => g.collapsed)\n}\n\n/**\n * Whether the legend has groups — gates panel-level group actions.\n *\n * @experimental This API is new and may change in a future release.\n */\nexport function selectHasGroups(state: LegendState): boolean {\n return Object.keys(state.groups).length > 0\n}\n\n/**\n * Visible layers grouped for the enabled-layers menu.\n *\n * @experimental This API is new and may change in a future release.\n */\nexport function selectVisibleLayersGrouped(\n state: LegendState,\n): { group?: LegendGroup; layers: LegendLayer[] }[] {\n const visible = (groupId: string | undefined) =>\n selectLayersByGroup(state, groupId).filter((l) => l.visible)\n const sections: { group?: LegendGroup; layers: LegendLayer[] }[] = []\n for (const group of selectOrderedGroups(state)) {\n const layers = visible(group.id)\n if (layers.length > 0) sections.push({ group, layers })\n }\n const ungrouped = visible(undefined)\n if (ungrouped.length > 0) sections.push({ layers: ungrouped })\n return sections\n}\n\n/**\n * Whether a layer has any collapsible body — something the row's `Collapse`\n * can actually fold. A layer with no variables, sections, or helper note\n * renders an empty body, so there is nothing to collapse. Gates the row's\n * title-area collapse affordance (chevron + click).\n *\n * @experimental This API is new and may change in a future release.\n */\nexport function selectLayerCollapsible(\n state: LegendState,\n layerId: string,\n): boolean {\n const layer = state.layers[layerId]\n if (!layer) return false\n return (\n layer.variables.length > 0 ||\n (layer.sections?.length ?? 0) > 0 ||\n // Truthiness matches the render condition — an empty-string note renders\n // no footer, so it must not enable the collapse affordance.\n Boolean(layer.helperText)\n )\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 selectLayersByGroup(state, groupId)) {\n if (layer.visible) anyVisible = true\n else anyHidden = true\n }\n if (anyVisible && anyHidden) return 'mixed'\n return anyHidden ? 'hidden' : 'visible'\n}\n","import { isValidElement } from 'react'\nimport { 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'\nimport { selectLayersByGroup, selectOrderedGroups } from './selectors'\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\n/**\n * Reorder one entity within its **ordered** bucket: splice it out, insert at\n * the clamped index, and return the dense `order` rewrites (only the entries\n * whose order actually changes). `null` when the position doesn't change or\n * the id isn't in the bucket. Powers `moveLayer` / `moveGroup`.\n */\nfunction movePatch<T extends { id: string; order: number }>(\n bucket: T[],\n id: string,\n toIndex: number,\n): Map<string, number> | null {\n const fromIndex = bucket.findIndex((e) => e.id === id)\n if (fromIndex === -1) return null\n const clamped = Math.max(0, Math.min(bucket.length - 1, toIndex))\n if (clamped === fromIndex) return null\n const next = [...bucket]\n const [moved] = next.splice(fromIndex, 1)\n next.splice(clamped, 0, moved!)\n const orders = new Map<string, number>()\n next.forEach((entity, index) => {\n if (entity.order !== index) orders.set(entity.id, index)\n })\n return orders.size > 0 ? orders : null\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/**\n * Same-type, same-key React elements with shallow-equal props count as\n * equal, so a ReactNode field (e.g. `LegendGroup.icon`) re-created inline on\n * every render (`icon={<MyIcon />}`) doesn't look \"changed\" on every sync. A\n * different `key` is treated as a real change, same as a different type.\n */\nfunction reactElementEqual(a: unknown, b: unknown): boolean {\n if (!isValidElement(a) || !isValidElement(b)) return false\n if (a.type !== b.type || a.key !== b.key) return false\n return shallowEqualEntity(\n a.props as Record<string, unknown>,\n b.props as Record<string, unknown>,\n )\n}\n\n/**\n * Shallow equality over the union of both objects' keys — `Object.is` per\n * value, except React elements, which fall back to {@link reactElementEqual}.\n */\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])) continue\n if (!reactElementEqual(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/**\n * Group counterpart of {@link mergeLayerEntity}. A group with no `prev`\n * state (first sync) defaults collapsed when none of its member layers is\n * visible yet — `hasVisibleLayer` is ignored once the group exists so a\n * user's manual expand/collapse always sticks.\n */\nfunction mergeGroupEntity(\n prev: LegendGroup | undefined,\n input: LegendGroupInput,\n fallbackOrder: number,\n hasVisibleLayer: boolean,\n): LegendGroup {\n return {\n ...input,\n collapsed: prev?.collapsed ?? input.collapsed ?? !hasVisibleLayer,\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 groupsWithVisibleLayer = new Set(\n layerEntries\n .filter(({ merged }) => merged.visible && merged.groupId != null)\n .map(({ merged }) => merged.groupId!),\n )\n const groupEntries = groupInputs.map((input, index) => ({\n index,\n merged: mergeGroupEntity(\n state.groups[input.id],\n input,\n index,\n groupsWithVisibleLayer.has(input.id),\n ),\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 hasVisibleLayer = Object.values(state.layers).some(\n (l) => l.groupId === input.id && l.visible,\n )\n const merged = mergeGroupEntity(\n state.groups[input.id],\n input,\n count,\n hasVisibleLayer,\n )\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 moveLayer: (lid, toIndex) =>\n set(\n (s) => {\n const layer = s.layers[lid]\n if (!layer) return {}\n const bucket = selectLayersByGroup(s, layer.groupId)\n const orders = movePatch(bucket, lid, toIndex)\n if (!orders) return {}\n const layers = { ...s.layers }\n for (const [id, order] of orders) {\n layers[id] = { ...layers[id]!, order }\n }\n return { layers }\n },\n false,\n 'moveLayer',\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 moveGroup: (gid, toIndex) =>\n set(\n (s) => {\n if (!s.groups[gid]) return {}\n const orders = movePatch(selectOrderedGroups(s), gid, toIndex)\n if (!orders) return {}\n const groups = { ...s.groups }\n for (const [id, order] of orders) {\n groups[id] = { ...groups[id]!, order }\n }\n return { groups }\n },\n false,\n 'moveGroup',\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"],"names":["LegendContext","createContext","useLegendId","id","useContext","Error","byOrder","a","b","order","selectOrderedGroups","state","Object","values","groups","sort","selectLayersByGroup","groupId","layers","filter","l","selectOrderedLayers","selectAllGroupsCollapsed","length","every","g","collapsed","selectHasGroups","keys","selectVisibleLayersGrouped","visible","sections","group","push","ungrouped","undefined","selectLayerCollapsible","layerId","layer","variables","Boolean","helperText","selectGroupVisibility","anyVisible","anyHidden","legendStores","Map","legendMountCounts","warnedDuplicates","Set","isDev","import","clamp01","n","Math","min","max","visibilityPatch","entity","collapsedBeforeHide","collapsePatch","movePatch","bucket","toIndex","fromIndex","findIndex","e","clamped","next","moved","splice","orders","forEach","index","set","size","updateLayer","patch","updateGroup","mergeSections","prev","merged","map","section","prevSection","find","p","active","options","includes","m","i","title","reactElementEqual","isValidElement","type","key","shallowEqualEntity","props","is","normalizeOrders","entries","bucketOf","buckets","entry","get","mergeLayerEntity","input","fallbackOrder","opacity","mergeGroupEntity","hasVisibleLayer","syncState","layerInputs","groupInputs","layerEntries","groupsWithVisibleLayer","groupEntries","has","layersChanged","groupsChanged","rebuildRecord","changed","out","before","upsertLayerState","siblingCount","removeLayerState","upsertGroupState","count","some","removeGroupState","nextGroups","members","nextLayers","member","createLegendStore","init","seeded","createStore","devtools","setVisibility","lid","s","setOpacity","setCollapsed","setSectionValue","sectionId","value","x","moveLayer","setGroupVisibility","gid","groupPatch","setGroupCollapsed","hidden","moveGroup","setLegendLayer","removeLegendLayer","setLegendGroup","removeLegendGroup","_sync","name","enabled","getLegendStore","store","hasLegendStore","deleteLegendStore","delete","clearAllLegendStores","clear","setLegendStoreEntry","registerLegendStore","console","warn","add","unregisterLegendStore","keepAlive","useLegendStore","selector","$","_c","t0","useStore","useLegendShallow","useShallow"],"mappings":";;;;;;AAGO,MAAMA,IAAgBC,EAA6B,IAAI;AAGvD,SAAAC,KAAA;AACL,QAAAC,IAAWC,EAAWJ,CAAa;AACnC,MAAIG,KAAM;AACR,UAAM,IAAIE,MACR,0LAGF;AACD,SACMF;AAAE;ACbX,MAAMG,IAAU,CAA8BC,GAAMC,MAClDD,EAAEE,QAAQD,EAAEC;AAOP,SAASC,EAAoBC,GAAmC;AACrE,SAAOC,OAAOC,OAAOF,EAAMG,MAAM,EAAEC,KAAKT,CAAO;AACjD;AAQO,SAASU,EACdL,GACAM,GACe;AACf,SAAOL,OAAOC,OAAOF,EAAMO,MAAM,EAC9BC,OAAQC,CAAAA,MAAMA,EAAEH,YAAYA,CAAO,EACnCF,KAAKT,CAAO;AACjB;AAOO,SAASe,GAAoBV,GA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