@carto/ps-react-ui 4.12.2 → 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.
- package/dist/components.js +706 -658
- package/dist/components.js.map +1 -1
- package/dist/legend/stores.js +20 -0
- package/dist/legend/stores.js.map +1 -0
- package/dist/legend.js +1536 -0
- package/dist/legend.js.map +1 -0
- package/dist/selectors-DwHj6mE2.js +388 -0
- package/dist/selectors-DwHj6mE2.js.map +1 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/responsive-drawer/responsive-drawer.d.ts +35 -3
- package/dist/types/legend/components/contexts.d.ts +20 -0
- package/dist/types/legend/components/icons.d.ts +12 -0
- package/dist/types/legend/components/index.d.ts +26 -0
- package/dist/types/legend/components/legend-actions/legend-actions.d.ts +24 -0
- package/dist/types/legend/components/legend-actions/styles.d.ts +7 -0
- package/dist/types/legend/components/legend-category/legend-category-ui.d.ts +13 -0
- package/dist/types/legend/components/legend-category/styles.d.ts +52 -0
- package/dist/types/legend/components/legend-config-select/legend-config-select.d.ts +14 -0
- package/dist/types/legend/components/legend-config-select/styles.d.ts +44 -0
- package/dist/types/legend/components/legend-group/legend-group.d.ts +21 -0
- package/dist/types/legend/components/legend-group/styles.d.ts +63 -0
- package/dist/types/legend/components/legend-icon/legend-icon-ui.d.ts +10 -0
- package/dist/types/legend/components/legend-icon/styles.d.ts +52 -0
- package/dist/types/legend/components/legend-item/legend-item-ui.d.ts +14 -0
- package/dist/types/legend/components/legend-item/legend-item.d.ts +10 -0
- package/dist/types/legend/components/legend-item/styles.d.ts +7 -0
- package/dist/types/legend/components/legend-opacity/legend-opacity.d.ts +32 -0
- package/dist/types/legend/components/legend-opacity/styles.d.ts +23 -0
- package/dist/types/legend/components/legend-proportion/legend-proportion-ui.d.ts +16 -0
- package/dist/types/legend/components/legend-proportion/styles.d.ts +37 -0
- package/dist/types/legend/components/legend-ramp/legend-ramp-ui.d.ts +20 -0
- package/dist/types/legend/components/legend-ramp/styles.d.ts +53 -0
- package/dist/types/legend/components/legend-row/legend-row.d.ts +23 -0
- package/dist/types/legend/components/legend-row/styles.d.ts +77 -0
- package/dist/types/legend/components/legend-row-menu/legend-row-menu.d.ts +18 -0
- package/dist/types/legend/components/legend-row-menu/legend-zoom-to.d.ts +15 -0
- package/dist/types/legend/components/legend-swatch/legend-swatch.d.ts +26 -0
- package/dist/types/legend/components/legend-visibility-toggle/legend-visibility-toggle.d.ts +35 -0
- package/dist/types/legend/index.d.ts +88 -0
- package/dist/types/legend/provider/index.d.ts +6 -0
- package/dist/types/legend/provider/labels.d.ts +27 -0
- package/dist/types/legend/provider/legend-config-context.d.ts +7 -0
- package/dist/types/legend/provider/legend-provider.d.ts +38 -0
- package/dist/types/legend/stores/index.d.ts +5 -0
- package/dist/types/legend/stores/legend-context.d.ts +4 -0
- package/dist/types/legend/stores/legend-store-registry.d.ts +39 -0
- package/dist/types/legend/stores/legend-store.test.d.ts +1 -0
- package/dist/types/legend/stores/selectors.d.ts +33 -0
- package/dist/types/legend/stores/types.d.ts +275 -0
- package/package.json +11 -3
- package/src/components/geolocation-controls/geolocation-controls.test.tsx +15 -0
- package/src/components/geolocation-controls/geolocation-controls.tsx +19 -3
- package/src/components/index.ts +2 -0
- package/src/components/responsive-drawer/responsive-drawer.test.tsx +129 -25
- package/src/components/responsive-drawer/responsive-drawer.tsx +149 -16
- package/src/legend/components/contexts.ts +32 -0
- package/src/legend/components/icons.tsx +22 -0
- package/src/legend/components/index.ts +39 -0
- package/src/legend/components/legend-actions/legend-actions.tsx +57 -0
- package/src/legend/components/legend-actions/styles.ts +9 -0
- package/src/legend/components/legend-category/legend-category-ui.tsx +91 -0
- package/src/legend/components/legend-category/styles.ts +61 -0
- package/src/legend/components/legend-config-select/legend-config-select.tsx +96 -0
- package/src/legend/components/legend-config-select/styles.ts +48 -0
- package/src/legend/components/legend-group/legend-group.test.tsx +115 -0
- package/src/legend/components/legend-group/legend-group.tsx +88 -0
- package/src/legend/components/legend-group/styles.ts +82 -0
- package/src/legend/components/legend-icon/legend-icon-ui.tsx +56 -0
- package/src/legend/components/legend-icon/styles.ts +56 -0
- package/src/legend/components/legend-item/legend-item-ui.test.tsx +362 -0
- package/src/legend/components/legend-item/legend-item-ui.tsx +43 -0
- package/src/legend/components/legend-item/legend-item.tsx +34 -0
- package/src/legend/components/legend-item/styles.ts +11 -0
- package/src/legend/components/legend-opacity/legend-opacity.tsx +179 -0
- package/src/legend/components/legend-opacity/styles.ts +28 -0
- package/src/legend/components/legend-proportion/legend-proportion-ui.tsx +122 -0
- package/src/legend/components/legend-proportion/styles.ts +43 -0
- package/src/legend/components/legend-ramp/legend-ramp-ui.tsx +159 -0
- package/src/legend/components/legend-ramp/styles.ts +62 -0
- package/src/legend/components/legend-row/legend-row.test.tsx +498 -0
- package/src/legend/components/legend-row/legend-row.tsx +129 -0
- package/src/legend/components/legend-row/styles.ts +111 -0
- package/src/legend/components/legend-row-menu/legend-row-menu.tsx +68 -0
- package/src/legend/components/legend-row-menu/legend-zoom-to.tsx +35 -0
- package/src/legend/components/legend-swatch/legend-swatch.test.tsx +109 -0
- package/src/legend/components/legend-swatch/legend-swatch.tsx +237 -0
- package/src/legend/components/legend-visibility-toggle/legend-visibility-toggle.tsx +127 -0
- package/src/legend/index.ts +121 -0
- package/src/legend/provider/index.ts +6 -0
- package/src/legend/provider/labels.ts +59 -0
- package/src/legend/provider/legend-config-context.ts +15 -0
- package/src/legend/provider/legend-provider.tsx +102 -0
- package/src/legend/stores/index.ts +46 -0
- package/src/legend/stores/legend-context.ts +17 -0
- package/src/legend/stores/legend-store-registry.ts +639 -0
- package/src/legend/stores/legend-store.test.ts +457 -0
- package/src/legend/stores/selectors.ts +65 -0
- package/src/legend/stores/types.ts +347 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import type { StoreApi } from 'zustand'
|
|
3
|
+
|
|
4
|
+
/** Floating panel anchor position. */
|
|
5
|
+
export type LegendPosition =
|
|
6
|
+
| 'top-left'
|
|
7
|
+
| 'top-right'
|
|
8
|
+
| 'bottom-left'
|
|
9
|
+
| 'bottom-right'
|
|
10
|
+
|
|
11
|
+
// ─── Legend variables (discriminated union) ────────────────────────────────
|
|
12
|
+
// The typed payload that drives each item renderer. Keyed by `type` so a
|
|
13
|
+
// single `LegendItemUI` can switch and the future adapter has one clear
|
|
14
|
+
// target to map `layer.legend.variables` into.
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Layout direction of a category/icon legend's items. `'horizontal'` flows
|
|
18
|
+
* the swatch+label pairs left-to-right, wrapping onto multiple rows.
|
|
19
|
+
*/
|
|
20
|
+
export type LegendOrientation = 'vertical' | 'horizontal'
|
|
21
|
+
|
|
22
|
+
/** Swatch shape for a category legend. */
|
|
23
|
+
export type LegendSwatchShape = 'square' | 'circle' | 'line'
|
|
24
|
+
|
|
25
|
+
/** Fill pattern for a filled square/circle swatch (`isStrokeColor: false`). */
|
|
26
|
+
export type LegendFillPattern =
|
|
27
|
+
| 'solid'
|
|
28
|
+
| 'horizontal'
|
|
29
|
+
| 'vertical'
|
|
30
|
+
| 'diagonal'
|
|
31
|
+
| 'diagonal-alt'
|
|
32
|
+
| 'cross'
|
|
33
|
+
| 'dots'
|
|
34
|
+
| 'grid'
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Border style for a stroked square/circle swatch (`isStrokeColor: true`), or
|
|
38
|
+
* the line style for `shape: 'line'`. `corners` applies to squares only;
|
|
39
|
+
* `dash-dot` applies to lines only — inapplicable values degrade gracefully.
|
|
40
|
+
*/
|
|
41
|
+
export type LegendStrokeStyle =
|
|
42
|
+
| 'solid'
|
|
43
|
+
| 'dashed'
|
|
44
|
+
| 'dotted'
|
|
45
|
+
| 'dash-dot'
|
|
46
|
+
| 'corners'
|
|
47
|
+
|
|
48
|
+
export interface LegendCategoryItem {
|
|
49
|
+
label: string
|
|
50
|
+
/** Fill or stroke color (see `isStrokeColor`). */
|
|
51
|
+
color: string
|
|
52
|
+
/**
|
|
53
|
+
* Optional value shown alongside the label — a pre-formatted node, so the
|
|
54
|
+
* consumer controls the formatting (e.g. `'12%'`, `'1.2K'`, or any element).
|
|
55
|
+
*/
|
|
56
|
+
value?: ReactNode
|
|
57
|
+
/** Optional marker diameter/length in px (the "Small/Medium/Large/XL" sizes). */
|
|
58
|
+
size?: number
|
|
59
|
+
/** Override the variable-level swatch shape for this item. */
|
|
60
|
+
shape?: LegendSwatchShape
|
|
61
|
+
/** Override the variable-level fill pattern for this item (mix patterns in one list). */
|
|
62
|
+
fillPattern?: LegendFillPattern
|
|
63
|
+
/** Override the variable-level border/line style for this item. */
|
|
64
|
+
strokeStyle?: LegendStrokeStyle
|
|
65
|
+
/** Override the variable-level fill-vs-outline mode for this item. */
|
|
66
|
+
isStrokeColor?: boolean
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface LegendCategoryVariable {
|
|
70
|
+
type: 'category'
|
|
71
|
+
items: LegendCategoryItem[]
|
|
72
|
+
/** Default swatch shape for all items (each item may override). Default `'circle'`. */
|
|
73
|
+
shape?: LegendSwatchShape
|
|
74
|
+
/**
|
|
75
|
+
* Default fill-vs-outline mode (each item may override). When true, `color`
|
|
76
|
+
* paints the marker border/outline instead of its fill.
|
|
77
|
+
*/
|
|
78
|
+
isStrokeColor?: boolean
|
|
79
|
+
/**
|
|
80
|
+
* Default fill pattern when filled (each item may override — mix patterns
|
|
81
|
+
* in one list). Default `'solid'`.
|
|
82
|
+
*/
|
|
83
|
+
fillPattern?: LegendFillPattern
|
|
84
|
+
/**
|
|
85
|
+
* Default border style when stroked, or line style for `shape: 'line'`
|
|
86
|
+
* (each item may override). Default `'solid'`.
|
|
87
|
+
*/
|
|
88
|
+
strokeStyle?: LegendStrokeStyle
|
|
89
|
+
/** Item layout direction. Default `'vertical'`. */
|
|
90
|
+
orientation?: LegendOrientation
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface LegendRampStop {
|
|
94
|
+
label: string
|
|
95
|
+
value: number
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface LegendRampVariable {
|
|
99
|
+
type: 'ramp'
|
|
100
|
+
/** Ordered low→high colors (hex / rgb / css). */
|
|
101
|
+
colors: string[]
|
|
102
|
+
/**
|
|
103
|
+
* Ordered low→high stops. Discrete ramps **require `colors.length + 1`**
|
|
104
|
+
* stops — the boundaries between color steps, including both outer edges —
|
|
105
|
+
* and each label is centered on its boundary line (keep labels short, e.g.
|
|
106
|
+
* `20K`; there is no collision handling). A discrete ramp with any other
|
|
107
|
+
* stop count is incoherent and renders an inline error instead of the bar.
|
|
108
|
+
* Continuous ramps show only the first/last endpoints.
|
|
109
|
+
*/
|
|
110
|
+
stops: LegendRampStop[]
|
|
111
|
+
/** Continuous gradient bar vs. discrete color steps. */
|
|
112
|
+
isContinuous: boolean
|
|
113
|
+
/**
|
|
114
|
+
* Average value, marked as a dashed vertical line on the bar (tooltip shows
|
|
115
|
+
* the formatted value). Positioned linearly between the first and last stop
|
|
116
|
+
* `value`s; out-of-range averages clamp to the bar's edge.
|
|
117
|
+
*/
|
|
118
|
+
avg?: number
|
|
119
|
+
/**
|
|
120
|
+
* Formats `avg` for its tooltip. Default `String(avg)` — pass e.g.
|
|
121
|
+
* `(v) => formatNumber(v, 'es-ES')` or `(v) => `${v}%``. Use a stable
|
|
122
|
+
* reference (same contract as the other variable fields).
|
|
123
|
+
*/
|
|
124
|
+
formatValue?: (value: number) => ReactNode
|
|
125
|
+
/** Attribute the color is based on (shown as "Color based on"). */
|
|
126
|
+
attribute?: string
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface LegendProportionVariable {
|
|
130
|
+
type: 'proportion'
|
|
131
|
+
min: number
|
|
132
|
+
max: number
|
|
133
|
+
/**
|
|
134
|
+
* Explicit value breaks to label (order-insensitive — the renderer sorts
|
|
135
|
+
* descending and caps at the **4 largest**). When omitted (or fewer than 2
|
|
136
|
+
* entries), breaks are evenly spaced between `min` and `max` over `steps`.
|
|
137
|
+
*/
|
|
138
|
+
stops?: number[]
|
|
139
|
+
/**
|
|
140
|
+
* Number of nested circles and derived value breaks, clamped to **2–4**.
|
|
141
|
+
* Defaults to 4. Ignored when explicit `stops` are provided (their count,
|
|
142
|
+
* capped at 4, wins). Circles and labels always match 1:1. Edge case: when
|
|
143
|
+
* `min === max` the renderer collapses to a **single** circle/break (the
|
|
144
|
+
* shared value), regardless of `steps`.
|
|
145
|
+
*/
|
|
146
|
+
steps?: number
|
|
147
|
+
/**
|
|
148
|
+
* Formats each derived break (MAX / middle / MIN). Default `String(value)`
|
|
149
|
+
* — pass e.g. `(v) => formatNumber(v, 'es-ES')`. Use a stable reference
|
|
150
|
+
* (same contract as the other variable fields).
|
|
151
|
+
*/
|
|
152
|
+
formatValue?: (value: number) => ReactNode
|
|
153
|
+
/** Attribute the size is based on (shown as "Radius range by"). */
|
|
154
|
+
attribute?: string
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface LegendIconItem {
|
|
158
|
+
label: string
|
|
159
|
+
/** Icon URL (data URI or external). */
|
|
160
|
+
icon: string
|
|
161
|
+
/**
|
|
162
|
+
* Optional value shown alongside the label — a pre-formatted node, so the
|
|
163
|
+
* consumer controls the formatting (e.g. `'12%'`, `'1.2K'`, or any element).
|
|
164
|
+
*/
|
|
165
|
+
value?: ReactNode
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface LegendIconVariable {
|
|
169
|
+
type: 'icon'
|
|
170
|
+
items: LegendIconItem[]
|
|
171
|
+
/** Item layout direction. Default `'vertical'`. */
|
|
172
|
+
orientation?: LegendOrientation
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export type LegendVariable =
|
|
176
|
+
| LegendCategoryVariable
|
|
177
|
+
| LegendRampVariable
|
|
178
|
+
| LegendProportionVariable
|
|
179
|
+
| LegendIconVariable
|
|
180
|
+
|
|
181
|
+
// ─── Store entities ─────────────────────────────────────────────────────────
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* One section of a layer's configuration select. The select's menu lists each
|
|
185
|
+
* section under its `title` (omitted when the layer has a single section);
|
|
186
|
+
* every section keeps its own highlighted `active` option. The closed field
|
|
187
|
+
* displays the first section's `active`.
|
|
188
|
+
*/
|
|
189
|
+
export interface LegendConfigSection {
|
|
190
|
+
id: string
|
|
191
|
+
/** Section heading in the menu (e.g. "Global"). Hidden for a single section. */
|
|
192
|
+
title?: string
|
|
193
|
+
options: string[]
|
|
194
|
+
/** The section's currently-selected option. */
|
|
195
|
+
active: string
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** A layer row in the legend. Holds both static definition and interactive state. */
|
|
199
|
+
export interface LegendLayer {
|
|
200
|
+
id: string
|
|
201
|
+
name: string
|
|
202
|
+
/** Secondary line (e.g. "Zoom level 1 – 12"). */
|
|
203
|
+
subtitle?: string
|
|
204
|
+
visible: boolean
|
|
205
|
+
/** 0–1. */
|
|
206
|
+
opacity: number
|
|
207
|
+
collapsed: boolean
|
|
208
|
+
/**
|
|
209
|
+
* @internal Collapsed state snapshotted when the layer was hidden — restored
|
|
210
|
+
* on show so a manual collapse/expand persists across visibility toggles.
|
|
211
|
+
* Managed by `setVisibility`/`setCollapsed`; do not set from outside.
|
|
212
|
+
*/
|
|
213
|
+
collapsedBeforeHide?: boolean
|
|
214
|
+
/** Sort order among siblings (lower = first). */
|
|
215
|
+
order: number
|
|
216
|
+
/** Owning group id, if the layer belongs to a group. */
|
|
217
|
+
groupId?: string
|
|
218
|
+
/** Show the opacity header action (slider + input popover) for this layer. */
|
|
219
|
+
opacityControl?: boolean
|
|
220
|
+
/**
|
|
221
|
+
* Configuration-select sections. When absent (or empty), the row renders no
|
|
222
|
+
* select. User-picked `active`s survive Provider re-syncs as long as the
|
|
223
|
+
* section id still exists and the pick is still among its `options`.
|
|
224
|
+
*/
|
|
225
|
+
sections?: LegendConfigSection[]
|
|
226
|
+
/** Footer helper note — one per layer, shown after all variables. */
|
|
227
|
+
helperText?: ReactNode
|
|
228
|
+
/**
|
|
229
|
+
* Ordered item renderers, stacked top-to-bottom in the row body (a layer
|
|
230
|
+
* can mix e.g. two category lists and a proportion). Pass a stable array
|
|
231
|
+
* reference — `_sync` compares it by reference, like the other prop-driven
|
|
232
|
+
* fields.
|
|
233
|
+
*/
|
|
234
|
+
variables: LegendVariable[]
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* A group of layer rows. A group has no stored visibility of its own — it is
|
|
239
|
+
* derived from its member layers (see `selectGroupVisibility`): all visible →
|
|
240
|
+
* `'visible'`, none visible → `'hidden'`, otherwise `'mixed'`.
|
|
241
|
+
*/
|
|
242
|
+
export interface LegendGroup {
|
|
243
|
+
id: string
|
|
244
|
+
label: string
|
|
245
|
+
collapsed: boolean
|
|
246
|
+
/**
|
|
247
|
+
* @internal Collapsed state snapshotted when the group was hidden via
|
|
248
|
+
* `setGroupVisibility` — restored on show. Managed by the setters.
|
|
249
|
+
*/
|
|
250
|
+
collapsedBeforeHide?: boolean
|
|
251
|
+
order: number
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ─── Provider input shapes ──────────────────────────────────────────────────
|
|
255
|
+
// Interactive fields are optional on input; the store seeds defaults and
|
|
256
|
+
// preserves user interaction across re-syncs.
|
|
257
|
+
|
|
258
|
+
/** @experimental This API is new and may change in a future release. */
|
|
259
|
+
export interface LegendLayerInput extends Omit<
|
|
260
|
+
LegendLayer,
|
|
261
|
+
'visible' | 'opacity' | 'collapsed' | 'collapsedBeforeHide' | 'order'
|
|
262
|
+
> {
|
|
263
|
+
visible?: boolean
|
|
264
|
+
opacity?: number
|
|
265
|
+
collapsed?: boolean
|
|
266
|
+
order?: number
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** @experimental This API is new and may change in a future release. */
|
|
270
|
+
export interface LegendGroupInput extends Omit<
|
|
271
|
+
LegendGroup,
|
|
272
|
+
'collapsed' | 'collapsedBeforeHide' | 'order'
|
|
273
|
+
> {
|
|
274
|
+
collapsed?: boolean
|
|
275
|
+
order?: number
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// ─── Store shape ──────────────────────────────────────────────────────────────
|
|
279
|
+
|
|
280
|
+
export interface LegendState {
|
|
281
|
+
layers: Record<string, LegendLayer>
|
|
282
|
+
groups: Record<string, LegendGroup>
|
|
283
|
+
|
|
284
|
+
// Layer setters — the "set layer values" feature that replaces react-maps
|
|
285
|
+
// `useLegend`. All mutations go through these.
|
|
286
|
+
setVisibility: (id: string, visible: boolean) => void
|
|
287
|
+
setOpacity: (id: string, opacity: number) => void
|
|
288
|
+
setCollapsed: (id: string, collapsed: boolean) => void
|
|
289
|
+
/**
|
|
290
|
+
* Pick a section's active option in the layer's configuration select.
|
|
291
|
+
* No-op for unknown layers/sections or when `value` is not one of the
|
|
292
|
+
* section's `options`.
|
|
293
|
+
*/
|
|
294
|
+
setSectionValue: (id: string, sectionId: string, value: string) => void
|
|
295
|
+
|
|
296
|
+
// Group setters
|
|
297
|
+
/**
|
|
298
|
+
* Show/hide **all member layers** of a group (the group itself has no stored
|
|
299
|
+
* visibility — it is derived from its members). Each member keeps its own
|
|
300
|
+
* collapse snapshot; the group additionally collapses when hiding and
|
|
301
|
+
* restores its pre-hide collapse state when showing. No-op when the group
|
|
302
|
+
* is already at the target state or has no members.
|
|
303
|
+
*/
|
|
304
|
+
setGroupVisibility: (id: string, visible: boolean) => void
|
|
305
|
+
setGroupCollapsed: (id: string, collapsed: boolean) => void
|
|
306
|
+
|
|
307
|
+
// Imperative add/remove/update — an alternative to the Provider's bulk
|
|
308
|
+
// `layers`/`groups` props. To use these, keep those props stable (pass the
|
|
309
|
+
// initial set once, or `[]`) so the Provider's `_sync` doesn't overwrite
|
|
310
|
+
// imperative changes on a later prop change.
|
|
311
|
+
/**
|
|
312
|
+
* Add a layer, or update it if `input.id` already exists. Interactive state
|
|
313
|
+
* (visible/opacity/collapsed/order and section actives) is preserved unless
|
|
314
|
+
* the input explicitly overrides it; new layers append to the end of their
|
|
315
|
+
* sibling bucket. No-op when an existing layer is unchanged.
|
|
316
|
+
*/
|
|
317
|
+
setLegendLayer: (input: LegendLayerInput) => void
|
|
318
|
+
/**
|
|
319
|
+
* Remove a layer and densely re-number the remaining siblings. No-op for an
|
|
320
|
+
* unknown id.
|
|
321
|
+
*/
|
|
322
|
+
removeLegendLayer: (id: string) => void
|
|
323
|
+
/**
|
|
324
|
+
* Add a group, or update it if `input.id` already exists (collapse/order
|
|
325
|
+
* preserved on update). No-op when unchanged.
|
|
326
|
+
*/
|
|
327
|
+
setLegendGroup: (input: LegendGroupInput) => void
|
|
328
|
+
/**
|
|
329
|
+
* Remove a group; its member layers are **un-grouped** (their `groupId` is
|
|
330
|
+
* cleared) so they survive as ungrouped rows rather than vanish. No-op for an
|
|
331
|
+
* unknown id.
|
|
332
|
+
*/
|
|
333
|
+
removeLegendGroup: (id: string) => void
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* @internal Provider prop-sync. Adds new entities, updates static fields of
|
|
337
|
+
* known ones (preserving their interactive state), and removes vanished ones.
|
|
338
|
+
*/
|
|
339
|
+
_sync: (layers: LegendLayerInput[], groups: LegendGroupInput[]) => void
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export type LegendStoreApi = StoreApi<LegendState>
|
|
343
|
+
|
|
344
|
+
export interface LegendInit {
|
|
345
|
+
layers?: LegendLayerInput[]
|
|
346
|
+
groups?: LegendGroupInput[]
|
|
347
|
+
}
|