@carto/ps-react-ui 4.17.2 → 4.18.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/category-Ct2BzADB.js +753 -0
- package/dist/category-Ct2BzADB.js.map +1 -0
- package/dist/change-column-Bhcxmp-r.js +1148 -0
- package/dist/change-column-Bhcxmp-r.js.map +1 -0
- package/dist/echart-B10dhEaM.js +262 -0
- package/dist/echart-B10dhEaM.js.map +1 -0
- 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/dist/types/widgets-v2/actions/lock-selection/lock-selection.d.ts +15 -5
- package/dist/types/widgets-v2/category/components/category-legend.d.ts +18 -2
- package/dist/types/widgets-v2/category/components/category-row-stacked.d.ts +6 -1
- package/dist/types/widgets-v2/category/style.d.ts +8 -0
- package/dist/types/widgets-v2/echart/use-chart-selection.d.ts +10 -4
- package/dist/types/widgets-v2/histogram/index.d.ts +1 -1
- package/dist/types/widgets-v2/histogram/transforms.d.ts +11 -0
- package/dist/types/widgets-v2/histogram/types.d.ts +9 -0
- package/dist/types/widgets-v2/scatterplot/index.d.ts +1 -1
- package/dist/types/widgets-v2/scatterplot/transforms.d.ts +9 -0
- package/dist/types/widgets-v2/table/index.d.ts +1 -0
- package/dist/types/widgets-v2/table/transforms.d.ts +13 -0
- package/dist/types/widgets-v2/table/transforms.test.d.ts +1 -0
- package/dist/types/widgets-v2/timeseries/index.d.ts +1 -0
- package/dist/types/widgets-v2/timeseries/transforms.d.ts +10 -0
- package/dist/types/widgets-v2/timeseries/transforms.test.d.ts +1 -0
- package/dist/widgets-v2/actions.js +1 -1
- package/dist/widgets-v2/category.js +1 -1
- package/dist/widgets-v2/echart.js +1 -1
- package/dist/widgets-v2/echart.js.map +1 -1
- package/dist/widgets-v2/histogram.js +181 -158
- package/dist/widgets-v2/histogram.js.map +1 -1
- package/dist/widgets-v2/pie.js +155 -116
- package/dist/widgets-v2/pie.js.map +1 -1
- package/dist/widgets-v2/scatterplot.js +91 -85
- package/dist/widgets-v2/scatterplot.js.map +1 -1
- package/dist/widgets-v2/table.js +55 -45
- package/dist/widgets-v2/table.js.map +1 -1
- package/dist/widgets-v2/timeseries.js +96 -85
- package/dist/widgets-v2/timeseries.js.map +1 -1
- package/dist/widgets-v2.js +4 -4
- 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/src/widgets-v2/actions/lock-selection/lock-selection.test.tsx +62 -0
- package/src/widgets-v2/actions/lock-selection/lock-selection.tsx +45 -13
- package/src/widgets-v2/category/category-ui.test.tsx +55 -0
- package/src/widgets-v2/category/category-ui.tsx +65 -6
- package/src/widgets-v2/category/components/category-legend.test.tsx +53 -2
- package/src/widgets-v2/category/components/category-legend.tsx +55 -12
- package/src/widgets-v2/category/components/category-row-stacked.test.tsx +7 -3
- package/src/widgets-v2/category/components/category-row-stacked.tsx +8 -3
- package/src/widgets-v2/category/style.ts +10 -2
- package/src/widgets-v2/echart/echart-ui.test.tsx +25 -0
- package/src/widgets-v2/echart/echart-ui.tsx +20 -0
- package/src/widgets-v2/echart/use-chart-selection.test.tsx +3 -1
- package/src/widgets-v2/echart/use-chart-selection.ts +10 -4
- package/src/widgets-v2/histogram/index.ts +4 -1
- package/src/widgets-v2/histogram/options.test.ts +86 -0
- package/src/widgets-v2/histogram/options.ts +50 -0
- package/src/widgets-v2/histogram/transforms.test.ts +36 -1
- package/src/widgets-v2/histogram/transforms.ts +23 -0
- package/src/widgets-v2/histogram/types.ts +9 -0
- package/src/widgets-v2/pie/options.test.ts +262 -0
- package/src/widgets-v2/pie/options.ts +80 -5
- package/src/widgets-v2/scatterplot/index.ts +4 -1
- package/src/widgets-v2/scatterplot/transforms.test.ts +38 -1
- package/src/widgets-v2/scatterplot/transforms.ts +23 -0
- package/src/widgets-v2/table/index.ts +1 -0
- package/src/widgets-v2/table/transforms.test.ts +40 -0
- package/src/widgets-v2/table/transforms.ts +26 -0
- package/src/widgets-v2/timeseries/index.ts +1 -0
- package/src/widgets-v2/timeseries/transforms.test.ts +49 -0
- package/src/widgets-v2/timeseries/transforms.ts +31 -0
- package/dist/category-CGS_eHr4.js +0 -719
- package/dist/category-CGS_eHr4.js.map +0 -1
- package/dist/change-column-CiVAjOUB.js +0 -1143
- package/dist/change-column-CiVAjOUB.js.map +0 -1
- package/dist/echart-Bdvbfx9s.js +0 -250
- package/dist/echart-Bdvbfx9s.js.map +0 -1
- package/dist/legend-store-registry-Bo8U_qWM.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"echart-B10dhEaM.js","sources":["../src/widgets-v2/echart/edge-label-clamp.ts","../src/widgets-v2/echart/shared-resize-observer.ts","../src/widgets-v2/echart/style.ts","../src/widgets-v2/echart/echart-ui.tsx","../src/widgets-v2/echart/echart.tsx"],"sourcesContent":["import * as echarts from 'echarts'\nimport type { ECharts, EChartsOption } from 'echarts'\n\n/**\n * Render-time clamp that stops the first/last **category x-axis** labels from\n * clipping at the chart edges — *only when they actually overflow*.\n *\n * ECharts centers each category label on its tick; the first/last ticks sit at\n * the plot boundary, so a wide edge label spills past the chart and is cut off.\n * `grid.containLabel` does not contain this horizontal overflow and the v6\n * `outerBounds` shrink is unreliable, so we measure at render time and anchor\n * the overflowing edge label inward (`alignMinLabel: 'left'` /\n * `alignMaxLabel: 'right'`). Labels that fit stay centered.\n *\n * Lives in the generic bridge because the verdict needs the laid-out chart\n * (`convertToPixel`, `getWidth`); everything else is read from the `option`.\n * Auto-targets bar + histogram (category x-axis); pie's horizontal-bar fallback\n * (category *y*-axis), scatterplot (value) and timeseries (time) are skipped.\n */\n\nexport interface EdgeAlignment {\n alignMinLabel: 'left' | null\n alignMaxLabel: 'right' | null\n}\n\nexport const CENTERED: EdgeAlignment = {\n alignMinLabel: null,\n alignMaxLabel: null,\n}\n\n// Small cushion biasing toward anchoring when borderline: clipping is worse\n// than a hair of off-centering, and the measured width can differ slightly\n// from the final render (mainly when the web font isn't loaded yet at measure\n// time). Kept to 1px — a wider margin anchored labels that only just clear the\n// edge, and an anchored edge label can then be dropped by the axis\n// `hideOverlap`, leaving a gap. 1px guards measurement error without that.\nconst SAFETY_MARGIN_PX = 1\n\n/**\n * Pure overflow decision. Inputs are anchor-independent (tick centers and text\n * width don't depend on the label's current `text-anchor`), so feeding the\n * result back via `setOption` doesn't change them — the next pass yields the\n * same verdict, keeping the clamp loop-stable.\n */\nexport function decideEdgeAlignment(args: {\n firstLabel: string\n lastLabel: string\n font: string\n firstTickX: number\n lastTickX: number\n width: number\n}): EdgeAlignment {\n const halfFirst =\n echarts.format.getTextRect(args.firstLabel, args.font).width / 2\n const halfLast =\n echarts.format.getTextRect(args.lastLabel, args.font).width / 2\n return {\n alignMinLabel:\n halfFirst + SAFETY_MARGIN_PX > args.firstTickX ? 'left' : null,\n alignMaxLabel:\n halfLast + SAFETY_MARGIN_PX > args.width - args.lastTickX\n ? 'right'\n : null,\n }\n}\n\ninterface AxisLabel {\n formatter?: (value: string | number) => string | number\n fontSize?: number | string\n fontFamily?: string\n fontWeight?: number | string\n}\n\ninterface CategoryXAxis {\n type?: string\n axisLabel?: AxisLabel\n}\n\ninterface SeriesLike {\n encode?: { x?: string | number }\n datasetIndex?: number\n}\n\ntype Cell = string | number | null | undefined\n\nfunction firstOf<T>(value: T | T[] | undefined): T | undefined {\n if (Array.isArray(value)) return value[0]\n return value\n}\n\nfunction firstXAxis(option: EChartsOption): CategoryXAxis | undefined {\n const axis = firstOf(\n option.xAxis as CategoryXAxis | CategoryXAxis[] | undefined,\n )\n return axis && typeof axis === 'object' ? axis : undefined\n}\n\nfunction hasDataZoom(option: EChartsOption): boolean {\n const dz = option.dataZoom\n return Array.isArray(dz) ? dz.length > 0 : dz != null\n}\n\nfunction cellToText(value: Cell, fmt: AxisLabel['formatter']): string {\n if (typeof fmt === 'function') return String(fmt(value ?? ''))\n return value == null ? '' : String(value)\n}\n\n/**\n * Extracts the displayed first/last category strings and the label font from\n * the option, reading categories generically via `series[0].encode.x` into the\n * referenced dataset (`'name'` for bar, `0` for histogram). Returns `null` when\n * the option isn't a measurable category x-axis (fewer than 2 categories, no\n * dataset, etc.).\n */\nexport function resolveEdgeLabels(option: EChartsOption): {\n firstLabel: string\n lastLabel: string\n font: string\n count: number\n} | null {\n const xAxis = firstXAxis(option)\n if (!xAxis) return null\n if (xAxis.type !== 'category') return null\n\n const series0 = firstOf(\n option.series as SeriesLike | SeriesLike[] | undefined,\n )\n const encodeX = series0?.encode?.x\n if (encodeX == null) return null\n\n const datasetIndex = series0?.datasetIndex ?? 0\n const allDatasets = option.dataset as\n | { source?: unknown }\n | { source?: unknown }[]\n | undefined\n const dataset = Array.isArray(allDatasets)\n ? allDatasets[datasetIndex]\n : allDatasets\n const source = dataset?.source\n if (!Array.isArray(source) || source.length < 2) return null\n\n const rows = source as Record<string | number, Cell>[]\n const fmt = xAxis.axisLabel?.formatter\n const axisLabel = xAxis.axisLabel ?? {}\n const size =\n typeof axisLabel.fontSize === 'number'\n ? `${axisLabel.fontSize}px`\n : (axisLabel.fontSize ?? '12px')\n const family = axisLabel.fontFamily ?? 'sans-serif'\n const weight = axisLabel.fontWeight != null ? `${axisLabel.fontWeight} ` : ''\n\n return {\n firstLabel: cellToText(rows[0]?.[encodeX], fmt),\n lastLabel: cellToText(rows[rows.length - 1]?.[encodeX], fmt),\n font: `${weight}${size} ${family}`,\n count: source.length,\n }\n}\n\n/**\n * Measures the rendered chart and, when the edge labels would clip, applies\n * `alignMinLabel`/`alignMaxLabel` (or clears them) via an imperative merge\n * `setOption`. Returns the alignment now in effect so the caller can keep a\n * `prev` ref and skip redundant `setOption`s. Should be invoked from the\n * chart's `finished` event (layout is settled, so `convertToPixel` is valid).\n */\nexport function clampEdgeLabels(\n chart: ECharts,\n option: EChartsOption,\n prev: EdgeAlignment,\n): EdgeAlignment {\n const next = computeAlignment(chart, option)\n if (\n next.alignMinLabel === prev.alignMinLabel &&\n next.alignMaxLabel === prev.alignMaxLabel\n ) {\n return prev\n }\n chart.setOption({ xAxis: { axisLabel: { ...next } } } as EChartsOption, {\n lazyUpdate: true,\n })\n return next\n}\n\nfunction computeAlignment(\n chart: ECharts,\n option: EChartsOption,\n): EdgeAlignment {\n // Under dataZoom, convertToPixel on the absolute first/last index returns\n // off-plot pixels, so the overflow math is invalid — reset to centered.\n if (hasDataZoom(option)) return CENTERED\n\n const labels = resolveEdgeLabels(option)\n if (!labels) return CENTERED\n\n const firstTickX = chart.convertToPixel({ xAxisIndex: 0 }, 0)\n const lastTickX = chart.convertToPixel({ xAxisIndex: 0 }, labels.count - 1)\n const width = chart.getWidth()\n // Layout not measurable yet (defensive — `finished` normally fires after\n // layout). Fall back to centered; a later `finished` re-measures.\n if (\n typeof firstTickX !== 'number' ||\n typeof lastTickX !== 'number' ||\n !Number.isFinite(firstTickX) ||\n !Number.isFinite(lastTickX) ||\n !width\n ) {\n return CENTERED\n }\n\n return decideEdgeAlignment({\n firstLabel: labels.firstLabel,\n lastLabel: labels.lastLabel,\n font: labels.font,\n firstTickX,\n lastTickX,\n width,\n })\n}\n","type ResizeCallback = () => void\n\nconst callbacks = new Map<Element, ResizeCallback>()\nlet observer: ResizeObserver | null = null\n\n/**\n * Returns the singleton ResizeObserver, lazily constructing it on first use.\n * Returns `null` when `ResizeObserver` is not available in the global scope\n * (SSR, very old browsers, or tests that intentionally remove it).\n */\nfunction getObserver(): ResizeObserver | null {\n if (typeof ResizeObserver === 'undefined') return null\n observer ??= new ResizeObserver((entries) => {\n for (const entry of entries) {\n const callback = callbacks.get(entry.target)\n callback?.()\n }\n })\n return observer\n}\n\nconst NOOP_CLEANUP = (): void => undefined\n\nexport function observeResize(\n element: Element,\n callback: ResizeCallback,\n): () => void {\n const ro = getObserver()\n // Gracefully degrade when no ResizeObserver is available — consumers\n // still see one initial measure() pass via their own effect; we just\n // skip the subsequent resize-driven re-measures.\n if (!ro) return NOOP_CLEANUP\n callbacks.set(element, callback)\n ro.observe(element)\n return () => {\n callbacks.delete(element)\n if (observer) {\n observer.unobserve(element)\n // Disconnect the singleton once the last subscriber leaves so the\n // observer doesn't outlive its consumers in SSR teardown / micro-\n // frontend unmount scenarios. A subsequent observeResize() will\n // lazily re-create it via getObserver().\n if (callbacks.size === 0) {\n observer.disconnect()\n observer = null\n }\n }\n }\n}\n\n/** @internal — for tests only. */\nexport function __resetSharedResizeObserver(): void {\n if (observer) observer.disconnect()\n callbacks.clear()\n observer = null\n}\n","import type { SxProps, Theme } from '@mui/material'\n\nexport const styles = {\n root: {\n width: '100%',\n minHeight: 0,\n },\n} satisfies Record<string, SxProps<Theme>>\n","import { useEffect, useEffectEvent, useRef } from 'react'\nimport { Box, type SxProps, type Theme } from '@mui/material'\nimport * as echarts from 'echarts'\nimport {\n clampEdgeLabels,\n CENTERED,\n type EdgeAlignment,\n} from './edge-label-clamp'\nimport { observeResize } from './shared-resize-observer'\nimport { styles } from './style'\n\nexport const DEFAULT_INIT_OPTS = {\n renderer: 'svg',\n height: 304,\n} satisfies echarts.EChartsInitOpts\n\nexport type EchartsEventHandler = (event: unknown) => void\n\nexport interface EchartUIProps {\n option: echarts.EChartsOption\n /**\n * Keys to merge as arrays (replace by index) instead of by id. The middleware\n * memoizes this content-stably, so identical sets don't re-trigger setOption.\n */\n replaceMerge?: readonly string[]\n /**\n * Opaque ECharts event passthrough — handlers fire untransformed.\n *\n * **Must be referentially stable** (memoize it with `useMemo` /\n * `useCallback`, or hoist to module scope). The binding effect depends on\n * the `onEvents` object identity; an inline `{ click: handler }` literal\n * recreates the object on every render and causes every listener to be\n * detached and re-attached each commit.\n */\n onEvents?: Record<string, EchartsEventHandler>\n /**\n * Init options forwarded to echarts.init. Captured at mount only — to change\n * `renderer` or `height` after mount, unmount and remount the chart.\n * Defaults: `{ renderer: 'svg', height: 304 }`.\n */\n init?: echarts.EChartsInitOpts\n /**\n * Optional callback fired once after the ECharts instance is created\n * (`onInstance(chart)`) and once when it's about to be disposed\n * (`onInstance(null)`). Used by `Widget.Echart` to publish the live\n * instance to the per-widget registry so other actions (e.g.\n * `ZoomToggle`'s disable handler) can reach it without DOM lookups.\n * No need to memoize — the bridge wraps it in `useEffectEvent` so an\n * unstable reference does not re-init the chart.\n */\n onInstance?: (chart: echarts.ECharts | null) => void\n className?: string\n sx?: SxProps<Theme>\n}\n\nexport function EchartUI({\n option,\n replaceMerge,\n onEvents,\n init,\n onInstance,\n className,\n sx,\n}: EchartUIProps) {\n const containerRef = useRef<HTMLDivElement>(null)\n const chartRef = useRef<echarts.ECharts | null>(null)\n\n // Structural fingerprint of the last applied series / dataset arrays.\n // Used to decide whether the next `setOption` should *replace* those\n // components (when their shape changed) or *merge* them (when only\n // styling-level fields differ — e.g. a new `itemStyle.color` callback\n // from a selection update). Replacing wipes ECharts' per-series runtime\n // state (hover, animation cache, brush areas), so we want to do it only\n // when the structure actually moved.\n const seriesFingerprintRef = useRef<string | null>(null)\n const datasetFingerprintRef = useRef<string | null>(null)\n\n // Latest applied option (read by the `finished` clamp listener, which is\n // bound once and must see the current option) + the edge-label alignment\n // currently applied to the chart (so the clamp skips redundant setOptions).\n const optionRef = useRef<echarts.EChartsOption>(option)\n const edgeAlignRef = useRef<EdgeAlignment>(CENTERED)\n\n // Stable notify wrapper — always reads the latest `onInstance` prop\n // without forcing the init effect below to re-run when the parent\n // passes a fresh function reference. The init effect now only fires\n // when `init` actually changes (documented as mount-only anyway).\n const notifyInstance = useEffectEvent(\n (chart: echarts.ECharts | null): void => {\n onInstance?.(chart)\n },\n )\n\n // Init / dispose. `init` is captured once at mount.\n useEffect(() => {\n if (!containerRef.current) return undefined\n const chart = echarts.init(containerRef.current, null, {\n ...DEFAULT_INIT_OPTS,\n ...init,\n })\n chartRef.current = chart\n notifyInstance(chart)\n // Edge-label clamp: after each layout settles (option change OR resize both\n // end in a render → `finished`), measure the category x-axis edge labels\n // and anchor them inward only if they'd clip. `finished` (not rAF) so\n // `convertToPixel` sees the flushed `lazyUpdate` layout. Loop-safe: the\n // verdict is anchor-independent, so our own clamp setOption recomputes the\n // same result and the ref guard short-circuits.\n const onFinished = (): void => {\n edgeAlignRef.current = clampEdgeLabels(\n chart,\n optionRef.current,\n edgeAlignRef.current,\n )\n }\n chart.on('finished', onFinished)\n // Never let the legend end up with every item hidden — a user can click\n // series off one by one until the chart goes blank. `selected` on this\n // event is always the FULL name→boolean map (not just the clicked item),\n // so \"every value false\" reliably means \"nothing left visible\". Restore\n // all of them instead. `legendAllSelect` fires its own `legendselectall`\n // event, not `legendselectchanged`, so this can't re-trigger itself.\n // Always-on and independent of the consumer's `onEvents` — applies to\n // every ECharts widget in the library for free. A widget that disables\n // legend clicks entirely (e.g. Pie's `selectedMode: false`) never fires\n // `legendselectchanged`, so this is a no-op there.\n const onLegendSelectChanged = (params: unknown): void => {\n const { selected } = params as { selected?: Record<string, boolean> }\n if (!selected) return\n const names = Object.keys(selected)\n if (names.length > 0 && names.every((name) => !selected[name])) {\n chart.dispatchAction({ type: 'legendAllSelect' })\n }\n }\n chart.on('legendselectchanged', onLegendSelectChanged)\n return () => {\n chart.off('finished', onFinished)\n chart.off('legendselectchanged', onLegendSelectChanged)\n // Notify observers *before* disposal so any queued imperative\n // dispatches (e.g. ZoomToggle's `setOption` cleanup) see the\n // instance disappear before its DOM is torn down.\n notifyInstance(null)\n chart.dispose()\n chartRef.current = null\n }\n }, [init])\n\n // Apply option / replaceMerge changes via merge mode (no remount required).\n useEffect(() => {\n const seriesFp = computeSeriesFingerprint(option)\n const datasetFp = computeDatasetFingerprint(option)\n const augmented = new Set<string>(replaceMerge ?? [])\n if (seriesFp !== seriesFingerprintRef.current) augmented.add('series')\n if (datasetFp !== datasetFingerprintRef.current) augmented.add('dataset')\n seriesFingerprintRef.current = seriesFp\n datasetFingerprintRef.current = datasetFp\n // Expose the latest option to the `finished` clamp listener (bound once).\n optionRef.current = option\n chartRef.current?.setOption(option, {\n notMerge: false,\n lazyUpdate: true,\n replaceMerge: augmented.size > 0 ? Array.from(augmented) : undefined,\n })\n }, [option, replaceMerge])\n\n // Resize via shared singleton observer.\n useEffect(() => {\n const node = containerRef.current\n if (!node) return undefined\n return observeResize(node, () => {\n chartRef.current?.resize()\n })\n }, [])\n\n // Bind / unbind opaque event handlers.\n useEffect(() => {\n const chart = chartRef.current\n if (!chart || !onEvents) return undefined\n for (const [event, handler] of Object.entries(onEvents)) {\n chart.on(event, handler)\n }\n return () => {\n for (const [event, handler] of Object.entries(onEvents)) {\n chart.off(event, handler)\n }\n }\n }, [onEvents])\n\n return (\n <Box\n ref={containerRef}\n className={className}\n sx={{ ...styles.root, ...sx }}\n />\n )\n}\n\n/**\n * Cheap structural digest of the option's `series` array — covers the fields\n * that actually demand a `replaceMerge` (length, type, datasetIndex, name,\n * stack, encode). Excludes runtime-style fields like `itemStyle` (callbacks\n * have unstable identity but don't change structure).\n */\nfunction computeSeriesFingerprint(option: echarts.EChartsOption): string {\n const series = option.series\n if (!Array.isArray(series)) return series ? '1' : ''\n return series\n .map((s) => {\n if (s == null || typeof s !== 'object') return String(s)\n const o = s as Record<string, unknown>\n return [\n o.type,\n o.datasetIndex,\n o.name,\n o.stack,\n // `encode` is small; stringify is cheap and stable for plain objects.\n JSON.stringify(o.encode ?? null),\n ].join('|')\n })\n .join('||')\n}\n\n/**\n * Structural digest of the option's `dataset` array — count is the only\n * thing that needs `replaceMerge` here. Row-level changes are picked up by\n * ECharts' default merge.\n */\nfunction computeDatasetFingerprint(option: echarts.EChartsOption): string {\n const dataset = option.dataset\n if (!Array.isArray(dataset)) return dataset ? '1' : ''\n return String(dataset.length)\n}\n","import { useCallback, useMemo } from 'react'\nimport type * as echarts from 'echarts'\nimport {\n applyTransforms,\n setEchartInstance,\n useWidgetId,\n useWidgetShallow,\n type Transform,\n} from '../stores'\nimport { EchartUI, type EchartsEventHandler } from './echart-ui'\n\n/**\n * Default ECharts `replaceMerge` keys for every widget. `dataZoom` and\n * `brush` are omitted so ZoomToggle / BrushToggle's user-driven runtime\n * state (slider range, brushed areas in `multiple` mode) survives unrelated\n * re-renders. `series` and `dataset` are also omitted: EchartUI fingerprints\n * them per-render and adds them to `replaceMerge` only when their shape\n * actually changes, keeping ECharts' per-series runtime state alive when\n * only callback-style fields differ.\n *\n * Lives in this module (not the generic store) because it's an ECharts\n * concept. Module-private — callers should not need it.\n */\nconst DEFAULT_REPLACE_MERGE: readonly string[] = ['toolbox']\n\n/**\n * Reactive context passed to every {@link OptionFactory} call so the\n * factory can rebuild render-time pieces (axis label / tooltip formatters)\n * from the live store. Drives RelativeData / consumer-formatter changes\n * through to the chart without rebuilding the structural option.\n */\nexport interface OptionFactoryContext {\n formatter?: (value: number) => string\n labelFormatter?: (value: string | number) => string | number\n}\n\n/**\n * The per-widget option factory — a single callable that owns BOTH phases\n * of option construction:\n *\n * - **Structural phase** — when `option == null`, return the theme-aware\n * structural option (tooltip / legend / color palette / series\n * template, optionally merged with a consumer-supplied `optionsOverride`).\n * No data is read. `<Widget.Echart>` calls the factory with\n * `(undefined, undefined)` synchronously during render to derive the\n * structural base; `configTransforms` (Stack/Zoom/Brush) then mutate it\n * in the same render pass.\n * - **Merge phase** — when `option` is defined, fuse `data` into the\n * post-configTransforms option at fusion time. `<Widget.Echart>` calls\n * the factory with `(transformed, data, ctx)` on every render.\n *\n * The two phases share a closure (the factory creator captures `theme`,\n * `formatter`, `labelFormatter`, `seriesNames`, `selection`, `optionsOverride`,\n * …), so structural and merge agree on the same widget configuration.\n *\n * The third arg `ctx` carries the **live** store-side formatters at the\n * call site — distinct from the closure-time formatters because actions\n * like RelativeData can install a percent formatter on the store after\n * the factory was constructed. The merge phase reads from `ctx`; the\n * structural phase typically uses the closure-time values.\n */\nexport type OptionFactory = (\n option: echarts.EChartsOption | undefined,\n data: unknown,\n ctx?: OptionFactoryContext,\n) => echarts.EChartsOption\n\nexport interface EchartProps {\n /**\n * The per-widget {@link OptionFactory}. Required — `<Widget.Echart>`\n * derives the structural option from it (so configTransforms have a base\n * to mutate) and fuses `state.data` into the post-pipeline option at\n * render time. Wrap the factory creator in `useMemo` so its identity is\n * stable across renders.\n */\n optionFactory: OptionFactory\n onEvents?: Record<string, EchartsEventHandler>\n init?: echarts.EChartsInitOpts\n className?: string\n}\n\ninterface EchartSlice {\n data: unknown\n configTransforms: readonly Transform[]\n formatter?: (value: number) => string\n labelFormatter?: (value: string | number) => string | number\n}\n\nconst echartSelector = (s: {\n data: unknown\n configTransforms: readonly Transform[]\n formatter?: (value: number) => string\n labelFormatter?: (value: string | number) => string | number\n}): EchartSlice => ({\n data: s.data,\n configTransforms: s.configTransforms,\n formatter: s.formatter,\n labelFormatter: s.labelFormatter,\n})\n\n/**\n * Stateful Echart bridge — owns the entire ECharts coupling. The whole\n * option pipeline lives here, not in the store:\n *\n * 1. **Structural** — `optionFactory(undefined, undefined)` produces the\n * theme-aware base. Memoized on the factory identity, so the consumer's\n * `useMemo` ID gates the rebuild.\n * 2. **Transformed** — `applyTransforms(structural, configTransforms)`\n * applies any registered configTransforms (Stack/Zoom/Brush) over the\n * structural base. Memoized on `[structural, configTransforms]`.\n * 3. **`replaceMerge`** — derived from the enabled configTransforms'\n * `replaceMergeKeys`, deduped and sorted, seeded with\n * {@link DEFAULT_REPLACE_MERGE}. Memoized on `[configTransforms]` so\n * ECharts sees a stable array reference across non-transform changes.\n * 4. **Merge** — `optionFactory(transformed, data, ctx)` fuses post-\n * pipeline data into the option. Reactive `ctx` carries the live store\n * formatters so RelativeData's percent formatter flows through without\n * a structural rebuild.\n *\n * The `<Widget.Provider>` doesn't know about the factory at all: it stays\n * a renderer-agnostic shell. The `ProviderProps` surface has no ECharts\n * coupling, so non-Echart widgets don't transitively import the type.\n */\nexport function Echart({\n optionFactory,\n onEvents,\n init,\n className,\n}: EchartProps) {\n const id = useWidgetId()\n const slice = useWidgetShallow(id, echartSelector)\n\n // Publish the live ECharts instance to the per-id registry so actions\n // (e.g. `ZoomToggle`'s disable handler) can reach it imperatively. The\n // callback identity is stable across renders (only `id` is in deps), so\n // EchartUI's init effect doesn't see a fresh `onInstance` and re-init.\n const onInstance = useCallback(\n (chart: echarts.ECharts | null) => setEchartInstance(id, chart),\n [id],\n )\n\n // Destructure so React Compiler sees specific deps instead of inferring\n // the whole `slice` object. `useWidgetShallow` already shallow-compares\n // the slice, so per-field deps drive each memo exactly when its inputs\n // change.\n const {\n data: sliceData,\n configTransforms,\n formatter: sliceFormatter,\n labelFormatter: sliceLabelFormatter,\n } = slice\n\n const structural = useMemo(\n () => optionFactory(undefined, undefined),\n [optionFactory],\n )\n\n const transformed = useMemo(\n () =>\n applyTransforms(structural, configTransforms) as echarts.EChartsOption,\n [structural, configTransforms],\n )\n\n const replaceMerge = useMemo(() => {\n const keys = new Set<string>(DEFAULT_REPLACE_MERGE)\n for (const xf of configTransforms) {\n if (xf.enabled && xf.replaceMergeKeys?.length) {\n for (const k of xf.replaceMergeKeys) keys.add(k)\n }\n }\n return Array.from(keys).sort()\n }, [configTransforms])\n\n const option = useMemo(\n () =>\n optionFactory(transformed, sliceData, {\n formatter: sliceFormatter,\n labelFormatter: sliceLabelFormatter,\n }),\n [\n optionFactory,\n transformed,\n sliceData,\n sliceFormatter,\n sliceLabelFormatter,\n ],\n )\n\n return (\n <EchartUI\n option={option}\n replaceMerge={replaceMerge}\n onEvents={onEvents}\n init={init}\n onInstance={onInstance}\n className={className}\n />\n )\n}\n"],"names":["CENTERED","alignMinLabel","alignMaxLabel","SAFETY_MARGIN_PX","decideEdgeAlignment","args","halfFirst","echarts","format","getTextRect","firstLabel","font","width","halfLast","lastLabel","firstTickX","lastTickX","firstOf","value","Array","isArray","firstXAxis","option","axis","xAxis","undefined","hasDataZoom","dz","dataZoom","length","cellToText","fmt","String","resolveEdgeLabels","type","series0","series","encodeX","encode","x","datasetIndex","allDatasets","dataset","source","rows","axisLabel","formatter","size","fontSize","family","fontFamily","weight","fontWeight","count","clampEdgeLabels","chart","prev","next","computeAlignment","setOption","lazyUpdate","labels","convertToPixel","xAxisIndex","getWidth","Number","isFinite","callbacks","Map","observer","getObserver","ResizeObserver","entries","entry","callback","get","target","NOOP_CLEANUP","observeResize","element","ro","set","observe","delete","unobserve","disconnect","__resetSharedResizeObserver","clear","styles","root","minHeight","DEFAULT_INIT_OPTS","renderer","height","EchartUI","t0","$","_c","replaceMerge","onEvents","init","onInstance","className","sx","containerRef","useRef","chartRef","seriesFingerprintRef","datasetFingerprintRef","optionRef","edgeAlignRef","t1","notifyInstance","useEffectEvent","t2","current","chart_0","onFinished","on","onLegendSelectChanged","params","selected","names","Object","keys","every","name","dispatchAction","off","dispose","t3","useEffect","t4","t5","seriesFp","computeSeriesFingerprint","datasetFp","computeDatasetFingerprint","augmented","Set","add","notMerge","from","t6","t7","Symbol","for","node","resize","t8","t9","chart_1","event","handler","event_0","handler_0","t10","t11","Box","map","s","o","stack","JSON","stringify","join","DEFAULT_REPLACE_MERGE","echartSelector","data","configTransforms","labelFormatter","Echart","optionFactory","id","useWidgetId","slice","useWidgetShallow","setEchartInstance","sliceData","sliceFormatter","sliceLabelFormatter","structural","applyTransforms","transformed","xf","enabled","replaceMergeKeys","k","sort"],"mappings":";;;;;;;;AAyBO,MAAMA,IAA0B;AAAA,EACrCC,eAAe;AAAA,EACfC,eAAe;AACjB,GAQMC,IAAmB;AAQlB,SAASC,EAAoBC,GAOlB;AAChB,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,WACzBqI;AAAAA,IAAcT,gBACTU;AAAAA,EAAAA,CACjB,GAACpF,OAAA4E,GAAA5E,QAAAkF,GAAAlF,QAAAmF,GAAAnF,QAAAoF,GAAApF,QAAAuF,GAAAvF,QAAAqC,KAAAA,IAAArC,EAAA,EAAA;AALN,QAAA1E,IAEI+G;AAWH,MAAAU;AAAA,SAAA/C,UAAAM,KAAAN,EAAA,EAAA,MAAAI,KAAAJ,EAAA,EAAA,MAAAG,KAAAH,EAAA,EAAA,MAAAK,KAAAL,UAAA1E,KAAA0E,EAAA,EAAA,MAAAE,KAGC6C,sBAACjD,IAAA,EACSxE,QAAAA,GACM4E,cAAAA,GACJC,UAAAA,GACJC,MAAAA,GACMC,YAAAA,GACDC,WAAAA,GAAS,GACpBN,QAAAM,GAAAN,QAAAI,GAAAJ,QAAAG,GAAAH,QAAAK,GAAAL,QAAA1E,GAAA0E,QAAAE,GAAAF,QAAA+C,KAAAA,IAAA/C,EAAA,EAAA,GAPF+C;AAOE;"}
|
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
|