@carto/ps-react-ui 4.16.0 → 4.17.1
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-CVYzhR1-.js → legend-store-registry-Bo8U_qWM.js} +136 -132
- package/dist/legend-store-registry-Bo8U_qWM.js.map +1 -0
- package/dist/legend.js +400 -397
- package/dist/legend.js.map +1 -1
- package/dist/types/legend/stores/types.d.ts +8 -0
- package/package.json +3 -3
- package/src/legend/components/legend-group/legend-group.test.tsx +25 -0
- package/src/legend/components/legend-group/legend-group.tsx +4 -7
- package/src/legend/components/legend-opacity/styles.ts +1 -1
- package/src/legend/components/legend-sortable/legend-sortable.tsx +5 -5
- package/src/legend/stores/legend-store-registry.ts +22 -2
- package/src/legend/stores/legend-store.test.ts +52 -0
- package/src/legend/stores/types.ts +8 -0
- package/dist/legend-store-registry-CVYzhR1-.js.map +0 -1
|
@@ -198,6 +198,14 @@ export interface LegendLayer {
|
|
|
198
198
|
export interface LegendGroup {
|
|
199
199
|
id: string;
|
|
200
200
|
label: string;
|
|
201
|
+
/**
|
|
202
|
+
* Optional header icon. Rendered only when provided — no icon shows by
|
|
203
|
+
* default. A same-type element with shallow-equal props is treated as
|
|
204
|
+
* unchanged across re-syncs even when re-created inline (e.g.
|
|
205
|
+
* `icon={<MyIcon />}`); a deeply nested custom node should be memoized if
|
|
206
|
+
* you want to avoid unnecessary syncs.
|
|
207
|
+
*/
|
|
208
|
+
icon?: ReactNode;
|
|
201
209
|
collapsed: boolean;
|
|
202
210
|
/**
|
|
203
211
|
* @internal Collapsed state snapshotted when the group was hidden via
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carto/ps-react-ui",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.1",
|
|
4
4
|
"description": "CARTO's Professional Service React Material library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devDependencies": {
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"react-dom": "19.2.4",
|
|
18
18
|
"react-markdown": "10.1.0",
|
|
19
19
|
"zustand": "5.0.12",
|
|
20
|
-
"@carto/ps-
|
|
21
|
-
"@carto/ps-
|
|
20
|
+
"@carto/ps-utils": "2.1.0",
|
|
21
|
+
"@carto/ps-common-types": "1.0.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@carto/meridian-ds": "^2.0.0",
|
|
@@ -125,6 +125,31 @@ describe('<LegendGroup> composition', () => {
|
|
|
125
125
|
fireEvent.click(header)
|
|
126
126
|
expect(getLegendStore('g-hide').getState().groups.g1!.collapsed).toBe(false)
|
|
127
127
|
})
|
|
128
|
+
|
|
129
|
+
it('renders no icon when the group has no icon configured', () => {
|
|
130
|
+
renderGroup('g-icon-none')
|
|
131
|
+
expect(screen.queryByTestId('LayersOutlinedIcon')).toBeNull()
|
|
132
|
+
expect(screen.queryByTestId('my-icon')).toBeNull()
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('renders the custom icon when provided', () => {
|
|
136
|
+
render(
|
|
137
|
+
<LegendProvider
|
|
138
|
+
id='g-icon-custom'
|
|
139
|
+
layers={layers}
|
|
140
|
+
groups={[
|
|
141
|
+
{
|
|
142
|
+
id: 'g1',
|
|
143
|
+
label: 'Demographics',
|
|
144
|
+
icon: <span data-testid='my-icon' />,
|
|
145
|
+
},
|
|
146
|
+
]}
|
|
147
|
+
>
|
|
148
|
+
<LegendGroup groupId='g1' />
|
|
149
|
+
</LegendProvider>,
|
|
150
|
+
)
|
|
151
|
+
expect(screen.getByTestId('my-icon')).toBeTruthy()
|
|
152
|
+
})
|
|
128
153
|
})
|
|
129
154
|
|
|
130
155
|
describe('<LegendGroupMenu> + built-in items', () => {
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
2
|
import { Box, Collapse, Typography } from '@mui/material'
|
|
3
|
-
import {
|
|
4
|
-
LayersOutlined as GroupIcon,
|
|
5
|
-
ExpandMore as ExpandMoreIcon,
|
|
6
|
-
} from '@mui/icons-material'
|
|
3
|
+
import { ExpandMore as ExpandMoreIcon } from '@mui/icons-material'
|
|
7
4
|
import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'
|
|
8
5
|
import { SmartTooltip } from '../../../components/smart-tooltip/smart-tooltip'
|
|
9
6
|
import {
|
|
@@ -76,9 +73,9 @@ export function LegendGroup({ groupId, children }: LegendGroupProps) {
|
|
|
76
73
|
onClick={toggle}
|
|
77
74
|
onKeyDown={accordionKeyDown(toggle)}
|
|
78
75
|
>
|
|
79
|
-
|
|
80
|
-
<
|
|
81
|
-
|
|
76
|
+
{group.icon != null && (
|
|
77
|
+
<Box sx={styles.groupIcon}>{group.icon}</Box>
|
|
78
|
+
)}
|
|
82
79
|
|
|
83
80
|
<SmartTooltip title={group.label} dependencies={[group.label]}>
|
|
84
81
|
{({ ref }) => (
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
} from '@dnd-kit/core'
|
|
15
15
|
import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'
|
|
16
16
|
import { Box, Typography } from '@mui/material'
|
|
17
|
-
import { LayersOutlined as GroupIcon } from '@mui/icons-material'
|
|
18
17
|
import {
|
|
19
18
|
getLegendStore,
|
|
20
19
|
selectLayersByGroup,
|
|
@@ -172,15 +171,16 @@ function OverlayCard({ activeId }: { activeId: string }) {
|
|
|
172
171
|
: s.layers[parsed.id]?.name
|
|
173
172
|
: undefined,
|
|
174
173
|
)
|
|
174
|
+
const groupIcon = useLegendStore(id, (s) =>
|
|
175
|
+
parsed?.kind === 'group' ? s.groups[parsed.id]?.icon : undefined,
|
|
176
|
+
)
|
|
175
177
|
|
|
176
178
|
if (!parsed || label === undefined) return null
|
|
177
179
|
|
|
178
180
|
return (
|
|
179
181
|
<Box sx={styles.overlay}>
|
|
180
|
-
{parsed.kind === 'group' && (
|
|
181
|
-
<Box sx={styles.overlayIcon}>
|
|
182
|
-
<GroupIcon fontSize='small' />
|
|
183
|
-
</Box>
|
|
182
|
+
{parsed.kind === 'group' && groupIcon != null && (
|
|
183
|
+
<Box sx={styles.overlayIcon}>{groupIcon}</Box>
|
|
184
184
|
)}
|
|
185
185
|
<Typography
|
|
186
186
|
variant='button'
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isValidElement } from 'react'
|
|
1
2
|
import { useStore, type StoreApi } from 'zustand'
|
|
2
3
|
import { createStore } from 'zustand/vanilla'
|
|
3
4
|
import { devtools } from 'zustand/middleware'
|
|
@@ -161,11 +162,30 @@ function mergeSections(
|
|
|
161
162
|
return sameAsPrev ? prev : merged
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
/**
|
|
165
|
+
/**
|
|
166
|
+
* Same-type, same-key React elements with shallow-equal props count as
|
|
167
|
+
* equal, so a ReactNode field (e.g. `LegendGroup.icon`) re-created inline on
|
|
168
|
+
* every render (`icon={<MyIcon />}`) doesn't look "changed" on every sync. A
|
|
169
|
+
* different `key` is treated as a real change, same as a different type.
|
|
170
|
+
*/
|
|
171
|
+
function reactElementEqual(a: unknown, b: unknown): boolean {
|
|
172
|
+
if (!isValidElement(a) || !isValidElement(b)) return false
|
|
173
|
+
if (a.type !== b.type || a.key !== b.key) return false
|
|
174
|
+
return shallowEqualEntity(
|
|
175
|
+
a.props as Record<string, unknown>,
|
|
176
|
+
b.props as Record<string, unknown>,
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Shallow equality over the union of both objects' keys — `Object.is` per
|
|
182
|
+
* value, except React elements, which fall back to {@link reactElementEqual}.
|
|
183
|
+
*/
|
|
165
184
|
function shallowEqualEntity<T extends object>(a: T, b: T): boolean {
|
|
166
185
|
const keys = new Set([...Object.keys(a), ...Object.keys(b)]) as Set<keyof T>
|
|
167
186
|
for (const key of keys) {
|
|
168
|
-
if (
|
|
187
|
+
if (Object.is(a[key], b[key])) continue
|
|
188
|
+
if (!reactElementEqual(a[key], b[key])) return false
|
|
169
189
|
}
|
|
170
190
|
return true
|
|
171
191
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createElement } from 'react'
|
|
1
2
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
2
3
|
import {
|
|
3
4
|
createLegendStore,
|
|
@@ -324,6 +325,57 @@ describe('legend store', () => {
|
|
|
324
325
|
expect(store.getState().groups.g1!.collapsed).toBe(true) // persisted
|
|
325
326
|
})
|
|
326
327
|
|
|
328
|
+
it('_sync treats a re-created group icon of the same type/props as unchanged', () => {
|
|
329
|
+
const store = createLegendStore('s', {
|
|
330
|
+
layers,
|
|
331
|
+
groups: [
|
|
332
|
+
{ id: 'g1', label: 'One', icon: createElement('span', null, 'icon') },
|
|
333
|
+
],
|
|
334
|
+
})
|
|
335
|
+
const before = store.getState().groups
|
|
336
|
+
|
|
337
|
+
// New element instance each call (as a consumer re-rendering inline
|
|
338
|
+
// would produce), but same type and shallow-equal props.
|
|
339
|
+
store
|
|
340
|
+
.getState()
|
|
341
|
+
._sync(layers, [
|
|
342
|
+
{ id: 'g1', label: 'One', icon: createElement('span', null, 'icon') },
|
|
343
|
+
])
|
|
344
|
+
|
|
345
|
+
expect(store.getState().groups).toBe(before) // no sync at all
|
|
346
|
+
})
|
|
347
|
+
|
|
348
|
+
it('_sync detects a real icon change (different type/props)', () => {
|
|
349
|
+
const store = createLegendStore('s', {
|
|
350
|
+
layers,
|
|
351
|
+
groups: [
|
|
352
|
+
{ id: 'g1', label: 'One', icon: createElement('span', null, 'icon') },
|
|
353
|
+
],
|
|
354
|
+
})
|
|
355
|
+
|
|
356
|
+
const newIcon = createElement('div', null, 'icon')
|
|
357
|
+
store.getState()._sync(layers, [{ id: 'g1', label: 'One', icon: newIcon }])
|
|
358
|
+
|
|
359
|
+
expect(store.getState().groups.g1!.icon).toBe(newIcon)
|
|
360
|
+
})
|
|
361
|
+
|
|
362
|
+
it('_sync detects a same-type/same-props icon with a different key as changed', () => {
|
|
363
|
+
const store = createLegendStore('s', {
|
|
364
|
+
groups: [
|
|
365
|
+
{
|
|
366
|
+
id: 'g1',
|
|
367
|
+
label: 'One',
|
|
368
|
+
icon: createElement('span', { key: 'a' }, 'icon'),
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
const newIcon = createElement('span', { key: 'b' }, 'icon')
|
|
374
|
+
store.getState()._sync([], [{ id: 'g1', label: 'One', icon: newIcon }])
|
|
375
|
+
|
|
376
|
+
expect(store.getState().groups.g1!.icon).toBe(newIcon)
|
|
377
|
+
})
|
|
378
|
+
|
|
327
379
|
it('_sync preserves the collapse snapshot of a hidden layer', () => {
|
|
328
380
|
const store = createLegendStore('s', { layers })
|
|
329
381
|
store.getState().setCollapsed('a', true) // manual collapse
|
|
@@ -242,6 +242,14 @@ export interface LegendLayer {
|
|
|
242
242
|
export interface LegendGroup {
|
|
243
243
|
id: string
|
|
244
244
|
label: string
|
|
245
|
+
/**
|
|
246
|
+
* Optional header icon. Rendered only when provided — no icon shows by
|
|
247
|
+
* default. A same-type element with shallow-equal props is treated as
|
|
248
|
+
* unchanged across re-syncs even when re-created inline (e.g.
|
|
249
|
+
* `icon={<MyIcon />}`); a deeply nested custom node should be memoized if
|
|
250
|
+
* you want to avoid unnecessary syncs.
|
|
251
|
+
*/
|
|
252
|
+
icon?: ReactNode
|
|
245
253
|
collapsed: boolean
|
|
246
254
|
/**
|
|
247
255
|
* @internal Collapsed state snapshotted when the group was hidden via
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legend-store-registry-CVYzhR1-.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 { 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/** 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 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","shallowEqualEntity","key","is","normalizeOrders","entries","bucketOf","buckets","entry","get","mergeLayerEntity","input","fallbackOrder","opacity","mergeGroupEntity","syncState","layerInputs","groupInputs","layerEntries","groupEntries","layersChanged","groupsChanged","rebuildRecord","changed","out","before","upsertLayerState","siblingCount","removeLayerState","upsertGroupState","count","removeGroupState","nextGroups","members","nextLayers","member","createLegendStore","init","seeded","createStore","devtools","setVisibility","lid","s","setOpacity","setCollapsed","setSectionValue","sectionId","value","x","moveLayer","setGroupVisibility","gid","some","groupPatch","setGroupCollapsed","hidden","moveGroup","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"],"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,GAAmC;AACrE,SAAOC,OAAOC,OAAOF,EAAMO,MAAM,EAAEH,KAAKT,CAAO;AACjD;AAQO,SAASgB,GAAyBX,GAA6B;AACpE,QAAMG,IAASF,OAAOC,OAAOF,EAAMG,MA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