@carto/ps-react-ui 4.22.0 → 4.23.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/actions-D7LB9DvT.js +1161 -0
- package/dist/actions-D7LB9DvT.js.map +1 -0
- package/dist/category-Ca5XDx0N.js +839 -0
- package/dist/category-Ca5XDx0N.js.map +1 -0
- package/dist/{download-C7he8mSh.js → download--wRRnf19.js} +81 -80
- package/dist/download--wRRnf19.js.map +1 -0
- package/dist/{echart-BnJYXH7H.js → echart-CgOQw9XB.js} +3 -2
- package/dist/echart-CgOQw9XB.js.map +1 -0
- package/dist/{formula-Cqj84ZGX.js → formula-DRuMIVo8.js} +6 -6
- package/dist/formula-DRuMIVo8.js.map +1 -0
- package/dist/{markdown-CV_KP-at.js → markdown-C3OX9jyy.js} +6 -6
- package/dist/markdown-C3OX9jyy.js.map +1 -0
- package/dist/{spread-C8T12Nfh.js → spread-BT07rCJw.js} +7 -7
- package/dist/spread-BT07rCJw.js.map +1 -0
- package/dist/{table-CNQijNNB.js → table-CRG9eOs9.js} +3 -3
- package/dist/table-CRG9eOs9.js.map +1 -0
- package/dist/types/widgets-v2/actions/download/csv-item.d.ts +3 -3
- package/dist/types/widgets-v2/actions/download/index.d.ts +1 -1
- package/dist/types/widgets-v2/actions/download/png-item.d.ts +2 -2
- package/dist/types/widgets-v2/actions/download/types.d.ts +12 -1
- package/dist/types/widgets-v2/actions/fullscreen/fullscreen.d.ts +20 -13
- package/dist/types/widgets-v2/actions/index.d.ts +1 -1
- package/dist/types/widgets-v2/bar/download.d.ts +3 -3
- package/dist/types/widgets-v2/category/category-ui.d.ts +9 -1
- package/dist/types/widgets-v2/category/download.d.ts +3 -3
- package/dist/types/widgets-v2/echart/style.d.ts +1 -0
- package/dist/types/widgets-v2/formula/download.d.ts +3 -3
- package/dist/types/widgets-v2/histogram/download.d.ts +3 -3
- package/dist/types/widgets-v2/index.d.ts +1 -1
- package/dist/types/widgets-v2/markdown/download.d.ts +3 -3
- package/dist/types/widgets-v2/pie/download.d.ts +3 -3
- package/dist/types/widgets-v2/scatterplot/download.d.ts +3 -3
- package/dist/types/widgets-v2/spread/download.d.ts +3 -3
- package/dist/types/widgets-v2/table/download.d.ts +3 -3
- package/dist/types/widgets-v2/timeseries/download.d.ts +3 -3
- package/dist/types/widgets-v2/toolbox/toolbox.d.ts +1 -1
- package/dist/widgets-v2/actions.js +2 -2
- package/dist/widgets-v2/bar.js +7 -7
- package/dist/widgets-v2/bar.js.map +1 -1
- package/dist/widgets-v2/category.js +1 -1
- package/dist/widgets-v2/echart.js +1 -1
- package/dist/widgets-v2/formula.js +1 -1
- package/dist/widgets-v2/histogram.js +10 -10
- package/dist/widgets-v2/histogram.js.map +1 -1
- package/dist/widgets-v2/markdown.js +1 -1
- package/dist/widgets-v2/pie.js +10 -10
- package/dist/widgets-v2/pie.js.map +1 -1
- package/dist/widgets-v2/scatterplot.js +9 -9
- package/dist/widgets-v2/scatterplot.js.map +1 -1
- package/dist/widgets-v2/spread.js +1 -1
- package/dist/widgets-v2/table.js +1 -1
- package/dist/widgets-v2/timeseries.js +12 -12
- package/dist/widgets-v2/timeseries.js.map +1 -1
- package/dist/widgets-v2.js +274 -333
- package/dist/widgets-v2.js.map +1 -1
- package/package.json +3 -3
- package/src/widgets-v2/actions/download/csv-item.test.tsx +3 -3
- package/src/widgets-v2/actions/download/csv-item.tsx +6 -6
- package/src/widgets-v2/actions/download/download.tsx +5 -3
- package/src/widgets-v2/actions/download/index.ts +1 -1
- package/src/widgets-v2/actions/download/png-item.test.tsx +5 -3
- package/src/widgets-v2/actions/download/png-item.tsx +4 -4
- package/src/widgets-v2/actions/download/types.ts +15 -1
- package/src/widgets-v2/actions/fullscreen/fullscreen-store.test.tsx +155 -0
- package/src/widgets-v2/actions/fullscreen/fullscreen.test.tsx +39 -41
- package/src/widgets-v2/actions/fullscreen/fullscreen.tsx +211 -96
- package/src/widgets-v2/actions/index.ts +1 -0
- package/src/widgets-v2/actions/searcher/searcher.tsx +17 -2
- package/src/widgets-v2/bar/download.test.tsx +5 -3
- package/src/widgets-v2/bar/download.tsx +5 -4
- package/src/widgets-v2/category/category-ui.tsx +20 -9
- package/src/widgets-v2/category/category.tsx +37 -2
- package/src/widgets-v2/category/download.test.ts +4 -2
- package/src/widgets-v2/category/download.ts +5 -4
- package/src/widgets-v2/echart/style.ts +6 -0
- package/src/widgets-v2/formula/download.test.tsx +3 -1
- package/src/widgets-v2/formula/download.tsx +5 -4
- package/src/widgets-v2/histogram/download.test.ts +6 -4
- package/src/widgets-v2/histogram/download.ts +5 -4
- package/src/widgets-v2/index.ts +1 -0
- package/src/widgets-v2/markdown/download.test.ts +2 -2
- package/src/widgets-v2/markdown/download.tsx +5 -4
- package/src/widgets-v2/pie/download.test.ts +7 -3
- package/src/widgets-v2/pie/download.ts +5 -4
- package/src/widgets-v2/scatterplot/download.test.ts +4 -2
- package/src/widgets-v2/scatterplot/download.ts +5 -4
- package/src/widgets-v2/spread/download.test.ts +3 -1
- package/src/widgets-v2/spread/download.ts +5 -4
- package/src/widgets-v2/table/download.test.ts +5 -3
- package/src/widgets-v2/table/download.ts +4 -3
- package/src/widgets-v2/timeseries/download.test.ts +6 -4
- package/src/widgets-v2/timeseries/download.ts +5 -4
- package/src/widgets-v2/toolbox/toolbox.tsx +1 -1
- package/dist/actions-iN1jwyxA.js +0 -1024
- package/dist/actions-iN1jwyxA.js.map +0 -1
- package/dist/category-DZt6yiST.js +0 -826
- package/dist/category-DZt6yiST.js.map +0 -1
- package/dist/download-C7he8mSh.js.map +0 -1
- package/dist/echart-BnJYXH7H.js.map +0 -1
- package/dist/formula-Cqj84ZGX.js.map +0 -1
- package/dist/markdown-CV_KP-at.js.map +0 -1
- package/dist/spread-C8T12Nfh.js.map +0 -1
- package/dist/table-CNQijNNB.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"category-DZt6yiST.js","names":["SxProps","Theme","CategorySize","bar","Record","small","position","height","bgcolor","borderRadius","overflow","transition","medium","barFill","inset","stackedSegment","top","bottom","styles","root","display","flexDirection","width","list","gap","py","listScroll","pr","rowSingle","cursor","userSelect","filter","outline","outlineColor","outlineOffset","rowHeader","justifyContent","alignItems","rowMulti","name","whiteSpace","textOverflow","color","fontWeight","multiName","value","fontVariantNumeric","minWidth","textAlign","multiBarRow","multiBarContainer","flex","rowStacked","stackedHeader","stackedTotal","stackedBreakdown","flexWrap","columnGap","rowGap","stackedBreakdownItem","legend","pt","mt","borderTop","theme","palette","divider","legendItem","legendItemHidden","opacity","legendDot","legendLabel","textTransform","otherRow","px","otherLabelButton","ml","otherLabel","otherCount","Box","CategorySize","styles","CategoryBarProps","value","maxValue","color","size","CategoryBar","t0","$","_c","t1","undefined","pct","t2","bar","t3","barFill","t4","t5","width","backgroundColor","t6","t7","KeyboardEvent","Box","Typography","CategoryBar","CategoryKey","CategorySize","styles","CategoryRowSingleProps","name","displayName","value","maxValue","color","formatter","n","selected","onToggle","size","CategoryRowSingle","t0","$","_c","t1","e","key","preventDefault","handleKey","t2","t3","t4","t5","t6","t7","rowHeader","t8","t9","rowSingle","KeyboardEvent","Box","Typography","CategoryBar","CategoryKey","CategorySize","styles","CategoryRowMultiProps","name","displayName","values","colors","maxValue","formatter","n","selected","onToggle","size","CategoryRowMulti","t0","$","_c","t1","e","key","preventDefault","handleKey","t2","t3","t4","multiName","t5","t6","v","i","multiBarRow","multiBarContainer","value","map","rowMulti","Box","CategorySize","styles","CategoryBarStackedProps","values","colors","maxValue","size","CategoryBarStacked","t0","$","_c","t1","undefined","offsets","acc","v","push","t2","bar","t3","t4","v_0","i","leftPct","pct","stackedSegment","left","width","backgroundColor","map","KeyboardEvent","Box","Typography","CategoryBarStacked","CategoryKey","CategorySize","styles","CategoryRowStackedProps","name","displayName","values","colors","seriesNames","formatter","n","selected","onToggle","size","CategoryRowStacked","t0","$","_c","t1","e","key","preventDefault","handleKey","T0","T1","T2","t10","t11","t12","t2","t3","t4","t5","t6","t7","t8","t9","total","reduce","_temp","rowStacked","stackedHeader","t13","multiName","stackedTotal","t14","t15","t16","t17","v","i","stackedBreakdownItem","map","stackedBreakdown","t18","a","b","KeyboardEvent","Box","Typography","Tooltip","styles","CategoryRowOtherProps","hiddenCount","otherLabel","otherCountLabel","onShowAll","showAllLabel","CategoryRowOther","t0","$","_c","t1","t2","t3","undefined","t4","replace","String","countText","t5","otherCount","count","t6","t7","otherRow","e","key","preventDefault","handleKey","Symbol","for","otherLabelButton","t8","t9","t10","Box","Typography","CategorySeriesConfig","styles","CategoryLegendProps","series","colorAt","index","hiddenSeries","ReadonlySet","onToggle","NO_HIDDEN_SERIES","Set","CategoryLegend","t0","$","_c","t1","undefined","length","t2","t3","s","i","hidden","has","name","e","key","preventDefault","legendItemHidden","legendItem","legendDot","backgroundColor","color","legendLabel","map","legend","useCallback","useMemo","useRef","useState","Box","useTheme","CategoryRowSingle","CategoryRowMulti","CategoryRowStacked","CategoryRowOther","CategoryLegend","CategoryKey","CategoryLabels","CategorySeriesConfig","CategorySize","CategoryWidgetData","styles","DEFAULT_MAX_ITEMS","ROW_HEIGHT_PX","Record","small","medium","SCROLL_VIEWPORT_FALLBACK_ROWS","CategoryUIProps","data","selection","onSelectionChange","next","formatter","value","labelFormatter","series","maxItems","labels","onShowAll","maxOverride","size","stacked","GroupedRow","name","values","rowColors","generateGroupedData","length","seriesCount","Math","max","grouped","Map","order","s","item","row","get","Array","fill","undefined","set","push","color","map","k","CategoryUI","t0","$","_c","t1","t2","t3","theme","fmt","_temp","hasSelection","t4","t5","Set","selectionSet","t6","cur","includes","filter","n_0","n","toggle","t7","palette","secondary","main","t8","Object","qualitative","bold","t9","paletteColors","t10","seriesIndex","rowColor","seriesColor","colorAt","dimColor","action","disabled","t11","t12","bb0","m","v","maxValue","scrollMode","measuredRef","naturalHeight","setNaturalHeight","t13","node","current","h","clientHeight","listRefCallback","hiddenSeries","setHiddenSeries","_temp2","t14","JSON","stringify","_temp3","seriesKey","prevSeriesKey","setPrevSeriesKey","t15","index","prev","next_0","has","delete","add","toggleSeries","t16","Number","isFinite","hasCap","T0","T1","hasLegend","hiddenCount","t17","t18","t19","t20","t21","visible","slice","isMulti","visibleIdx","from","_temp4","i_0","i","scrollMaxHeight","root","list","listScroll","maxHeight","overflowY","row_0","selected","dimmed","displayName","i_1","String","i_2","i_3","i_4","i_5","i_6","t22","other","otherCount","showAll","t23","t24","i_7","t25","_","useMemo","useWidgetId","useWidgetShallow","WidgetState","CategoryUI","CategoryKey","CategoryLabels","CategorySeriesConfig","CategorySize","CategoryWidgetData","CategorySlice","data","rawData","formatter","value","labelFormatter","categorySelector","s","undefined","maxFromCategoryData","d","m","series","item","CategoryProps","selection","onSelectionChange","next","maxItems","labels","onShowAll","maxOverride","size","stacked","Category","t0","$","_c","id","slice","naturalMax","effectiveMaxOverride","t1","Box","Skeleton","SxProps","Theme","CategorySize","styles","root","display","flexDirection","gap","py","row","rowHeader","justifyContent","alignItems","name","height","width","value","Record","BAR_HEIGHT","small","medium","WIDTH_PATTERNS","CategorySkeletonProps","rows","size","CategorySkeleton","t0","$","_c","t1","t2","undefined","t3","Array","from","length","t4","map","_","i","buildCsvDownloadItem","buildPngDownloadItem","DownloadItem","CategoryWidgetData","createCategoryDownloadConfig","args","filename","getData","seriesNames","getCaptureEl","HTMLElement","pngPixelRatio","pngBackgroundColor","items","push","pixelRatio","backgroundColor","getRows","data","rows","i","series","entries","seriesName","item","name","value"],"sources":["../src/widgets-v2/category/style.ts","../src/widgets-v2/category/components/category-bar.tsx","../src/widgets-v2/category/components/category-row-single.tsx","../src/widgets-v2/category/components/category-row-multi.tsx","../src/widgets-v2/category/components/category-bar-stacked.tsx","../src/widgets-v2/category/components/category-row-stacked.tsx","../src/widgets-v2/category/components/category-row-other.tsx","../src/widgets-v2/category/components/category-legend.tsx","../src/widgets-v2/category/category-ui.tsx","../src/widgets-v2/category/category.tsx","../src/widgets-v2/category/skeleton.tsx","../src/widgets-v2/category/download.ts"],"sourcesContent":["import type { SxProps, Theme } from '@mui/material'\nimport type { CategorySize } from './types'\n\n// Size-keyed bar styles — scoped strictly to the bar primitive\n// (track + fill height & corner radius). `small` preserves the\n// historical look (4px-tall pill); `medium` renders a 12px-tall track\n// with a 2px corner radius. Every other token (gap, padding, hover,\n// transitions, label/value typography) is size-invariant.\nconst bar: Record<CategorySize, SxProps<Theme>> = {\n small: {\n position: 'relative',\n height: 4,\n bgcolor: 'action.hover',\n borderRadius: 1,\n overflow: 'hidden',\n transition: 'background-color 150ms ease',\n },\n medium: {\n position: 'relative',\n height: 12,\n bgcolor: 'action.hover',\n borderRadius: 0.25,\n overflow: 'hidden',\n transition: 'background-color 150ms ease',\n },\n}\n\nconst barFill: Record<CategorySize, SxProps<Theme>> = {\n small: {\n position: 'absolute',\n inset: '0 auto 0 0',\n borderRadius: 1,\n transition:\n 'width 300ms ease-in-out, background-color 150ms ease, filter 150ms ease',\n },\n medium: {\n position: 'absolute',\n inset: '0 auto 0 0',\n borderRadius: 0.25,\n transition:\n 'width 300ms ease-in-out, background-color 150ms ease, filter 150ms ease',\n },\n}\n\n// Square-cornered segment for the stacked bar. Adjacent segments meet\n// cleanly; the parent `bar[size]` track clips the outer ends via its\n// own borderRadius + overflow:hidden, so the stacked bar still has the\n// same rounded silhouette as a single `CategoryBar`.\nconst stackedSegment: Record<CategorySize, SxProps<Theme>> = {\n small: {\n position: 'absolute',\n top: 0,\n bottom: 0,\n transition:\n 'left 300ms ease-in-out, width 300ms ease-in-out, background-color 150ms ease, filter 150ms ease',\n },\n medium: {\n position: 'absolute',\n top: 0,\n bottom: 0,\n transition:\n 'left 300ms ease-in-out, width 300ms ease-in-out, background-color 150ms ease, filter 150ms ease',\n },\n}\n\nexport const styles = {\n // ── Top-level container ────────────────────────────────────────────\n root: {\n display: 'flex',\n flexDirection: 'column',\n position: 'relative',\n width: '100%',\n },\n // Flat list of category rows. Holds both single + multi rows.\n list: {\n display: 'flex',\n flexDirection: 'column',\n gap: 1,\n py: 0.5,\n },\n // Layered on `list` only in scroll mode (`maxItems === 0`): right padding\n // so the bars + right-aligned values clear the scrollbar. Right side only\n // — the left edge stays at 0 so content stays aligned with the capped\n // view. `overflowY` + the dynamic `maxHeight` remain on the inline style.\n listScroll: {\n pr: 1,\n },\n\n // ── Single-series row ─────────────────────────────────────────────\n // v1 layout: label + value share a top flex row (justify-between); the\n // bar fills the row width below. Mirrors `rowMulti` for visual\n // consistency.\n rowSingle: {\n display: 'flex',\n flexDirection: 'column',\n gap: 0.5,\n // py: 0.5,\n // px: 0.5,\n cursor: 'pointer',\n userSelect: 'none',\n transition: 'background-color 80ms ease',\n // Hovering anywhere in the row also brightens the bar fill, matching\n // what the bar got from `bar:hover` before. `data-bar-fill` is set\n // on `barFill` by <CategoryBar>; descendant selector reaches it\n // through `bar` in single rows and through `multiBarRow > bar` in\n // multi rows.\n '&:hover [data-bar-fill=\"true\"]': {\n filter: 'brightness(1.2)',\n },\n '&:focus-visible': {\n outline: '2px solid',\n outlineColor: 'primary.main',\n outlineOffset: -2,\n },\n },\n // Top row of `rowSingle`: label on the left, value on the right.\n rowHeader: {\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n gap: 1,\n },\n // ── Multi-series row ──────────────────────────────────────────────\n // Flex column: label fills the top row; bar+value pairs stack below.\n // Bars get full track width — better legibility for N>=2 series than a\n // shared grid would give.\n rowMulti: {\n display: 'flex',\n flexDirection: 'column',\n gap: 0.5,\n // py: 0.5,\n // px: 0.5,\n cursor: 'pointer',\n userSelect: 'none',\n transition: 'background-color 80ms ease',\n // Row-hover brightens every bar fill inside the multi-row.\n '&:hover [data-bar-fill=\"true\"]': {\n filter: 'brightness(1.2)',\n },\n '&:focus-visible': {\n outline: '2px solid',\n outlineColor: 'primary.main',\n outlineOffset: -2,\n },\n },\n // ── Row labels / values ───────────────────────────────────────────\n // Matches v1: name uses medium-weight body2 in primary text color,\n // value uses regular body2 in secondary text color. Same font size,\n // visual hierarchy via weight + color.\n name: {\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n color: 'text.primary',\n fontWeight: 'medium',\n },\n multiName: {\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n color: 'text.primary',\n fontWeight: 'medium',\n },\n value: {\n color: 'text.secondary',\n fontVariantNumeric: 'tabular-nums',\n // Right-align + minWidth keeps `rowMulti`'s per-bar value column\n // tidy (where the bar grows on the left and the number sits at a\n // fixed right edge). `rowSingle` uses `rowHeader`'s flex\n // justify-between to push the value to the trailing edge, so the\n // minWidth here is also harmless in that context.\n minWidth: 48,\n textAlign: 'right',\n },\n\n // ── Bar (track + fill) ────────────────────────────────────────────\n // Size-keyed maps live above the `styles` object; `<CategoryBar>` picks\n // the variant via its `size` prop. Hover brightening still fires from\n // the parent row (`&:hover [data-bar-fill]`), so it works regardless\n // of which size variant the bar uses.\n bar,\n barFill,\n stackedSegment,\n\n // ── Multi-series internals ────────────────────────────────────────\n // One [bar | value] flex row per series, inside `rowMulti`'s column.\n multiBarRow: {\n display: 'flex',\n alignItems: 'center',\n gap: 1,\n },\n multiBarContainer: {\n flex: 1,\n },\n\n // ── Stacked-mode row ──────────────────────────────────────────────\n // Mirror `rowMulti`'s outer shape (click target + hover brightening +\n // focus ring) but stack three children vertically: header line, bar,\n // breakdown line.\n rowStacked: {\n display: 'flex',\n flexDirection: 'column',\n gap: 0.5,\n cursor: 'pointer',\n userSelect: 'none',\n transition: 'background-color 80ms ease',\n '&:hover [data-bar-fill=\"true\"]': {\n filter: 'brightness(1.2)',\n },\n '&:focus-visible': {\n outline: '2px solid',\n outlineColor: 'primary.main',\n outlineOffset: -2,\n },\n },\n stackedHeader: {\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n gap: 1,\n },\n // Right-aligned total in the header. Tabular-nums keeps totals lined\n // up vertically across rows; minWidth reuses the per-series-value\n // column width so the right edge sits at the same spot as `rowMulti`'s\n // value column when both modes co-exist in the same widget card.\n stackedTotal: {\n color: 'text.primary',\n fontWeight: 'medium',\n fontVariantNumeric: 'tabular-nums',\n minWidth: 48,\n textAlign: 'right',\n },\n // Flex row of \"{seriesName}: {value}\" pairs. Wraps gracefully when\n // series names are long or there are many series.\n stackedBreakdown: {\n display: 'flex',\n flexWrap: 'wrap',\n columnGap: 2,\n rowGap: 0.25,\n },\n stackedBreakdownItem: {\n color: 'text.secondary',\n fontVariantNumeric: 'tabular-nums',\n },\n\n // ── Legend (sticky bottom) ────────────────────────────────────────\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: 2,\n flexWrap: 'wrap',\n pt: 2,\n mt: 2,\n position: 'sticky',\n bottom: 0,\n bgcolor: 'background.paper',\n borderTop: (theme: Theme) => `1px solid ${theme.palette.divider}`,\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: 1,\n cursor: 'pointer',\n },\n legendItemHidden: {\n display: 'flex',\n alignItems: 'center',\n gap: 1,\n cursor: 'pointer',\n opacity: 0.5,\n },\n legendDot: {\n width: 14,\n height: 14,\n borderRadius: '50%',\n },\n legendLabel: {\n color: 'text.secondary',\n textTransform: 'uppercase',\n fontWeight: 'medium',\n },\n\n // ── \"Other\" overflow row ──────────────────────────────────────────\n // Left-aligned `Others <count>` — the label sits next to a muted count\n // (no parentheses). Only the label is the click target when interactive;\n // the count is always static text beside it.\n otherRow: {\n display: 'flex',\n alignItems: 'center',\n gap: 1,\n py: 0.5,\n px: 0.5,\n },\n // Interactive affordances layered onto the \"Others\" label only (cursor,\n // hover tint, focus ring). A negative LEFT margin + matching padding keep\n // the hover pill breathing without shifting the label's text edge (it\n // stays aligned with the category rows above). No right margin, so the\n // row `gap` is preserved between the pill and the count.\n otherLabelButton: {\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: 1,\n px: 0.5,\n ml: -0.5,\n transition: 'background-color 80ms ease',\n '&:hover': {\n bgcolor: 'action.hover',\n },\n '&:focus-visible': {\n outline: '2px solid',\n outlineColor: 'primary.main',\n outlineOffset: 2,\n },\n },\n otherLabel: {\n color: 'text.primary',\n fontWeight: 'medium',\n },\n otherCount: {\n color: 'text.secondary',\n fontVariantNumeric: 'tabular-nums',\n },\n // `bar` / `barFill` are size-keyed (`Record<CategorySize, SxProps>`);\n // every other entry is a single `SxProps<Theme>`. The mixed shape means\n // we can't apply the file-wide `satisfies Record<string, SxProps<Theme>>`\n // constraint that the other widget style files use — consumers of\n // individual tokens still get full type-checking at the call site via\n // the typed `Box`/`Typography` `sx` prop.\n}\n","import { Box } from '@mui/material'\nimport type { CategorySize } from '../types'\nimport { styles } from '../style'\n\nexport interface CategoryBarProps {\n /** Numeric value driving the fill width. */\n value: number\n /** Denominator for the percentage fill. `0` → empty bar (no division by zero). */\n maxValue: number\n /** Fill color. Honors any CSS color or MUI theme token. */\n color: string\n /**\n * Visual density. `'small'` (default) keeps the historical 4px pill;\n * `'medium'` renders a 12px-tall track with a 2px corner radius. Only\n * the bar track + fill change — every other token in the parent row is\n * size-invariant.\n */\n size?: CategorySize\n}\n\n/**\n * Single horizontal bar (track + proportional fill). Pure presentation.\n * Selection / dimming live at the row level; this component is unaware of\n * both — bars stay vivid regardless of selection state (per the v2\n * \"row-bg + row-dim, never muted bar\" rule).\n */\nexport function CategoryBar({\n value,\n maxValue,\n color,\n size = 'small',\n}: CategoryBarProps) {\n const pct = maxValue > 0 ? (value / maxValue) * 100 : 0\n // Width + color rendered as inline `style` (not `sx`) to avoid\n // generating a new emotion class for every distinct value/color pair\n // — also makes the rendered DOM testable without computed-style math.\n return (\n <Box sx={styles.bar[size]} data-size={size}>\n <Box\n sx={styles.barFill[size]}\n style={{ width: `${pct}%`, backgroundColor: color }}\n // Tag the fill so an ancestor row's `:hover` selector can target\n // it (`&:hover [data-bar-fill]`) — the brightening affordance now\n // fires from anywhere in the row, not only the bar track.\n data-bar-fill='true'\n />\n </Box>\n )\n}\n","import type { KeyboardEvent } from 'react'\nimport { Box, Typography } from '@mui/material'\nimport { CategoryBar } from './category-bar'\nimport type { CategoryKey, CategorySize } from '../types'\nimport { styles } from '../style'\n\nexport interface CategoryRowSingleProps {\n /** Raw category key — what gets emitted to `onToggle` regardless of formatter. */\n name: CategoryKey\n /** Display label (post-`labelFormatter`). Falls back to `name` when omitted. */\n displayName?: string | number\n value: number\n maxValue: number\n color: string\n formatter: (n: number) => string\n selected: boolean\n onToggle: (name: CategoryKey) => void\n /** Bar visual density. Forwarded to {@link CategoryBar}. */\n size?: CategorySize\n}\n\n/**\n * Single-series category row: `[label] [bar] [value]` grid. Click /\n * Enter / Space toggles `name` in/out of the selection set via\n * `onToggle`. Selection key is always the raw `name` — `displayName` is\n * presentation only.\n *\n * Visual selection / dim signal lives ENTIRELY in the bar color\n * (`color` prop) — computed upstream by `CategoryUI` (real palette\n * color when selected or no-selection; `theme.palette.action.disabled`\n * when a selection exists and this row isn't in it). The row itself\n * has no bg tint, no opacity rule.\n */\nexport function CategoryRowSingle({\n name,\n displayName,\n value,\n maxValue,\n color,\n formatter,\n selected,\n onToggle,\n size,\n}: CategoryRowSingleProps) {\n const handleKey = (e: KeyboardEvent<HTMLDivElement>): void => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onToggle(name)\n }\n }\n return (\n <Box\n role='button'\n aria-pressed={selected}\n tabIndex={0}\n onClick={() => onToggle(name)}\n onKeyDown={handleKey}\n sx={styles.rowSingle}\n >\n <Box sx={styles.rowHeader}>\n <Typography variant='body2' sx={styles.name}>\n {displayName ?? name}\n </Typography>\n <Typography variant='body2' sx={styles.value}>\n {formatter(value)}\n </Typography>\n </Box>\n <CategoryBar\n value={value}\n maxValue={maxValue}\n color={color}\n size={size}\n />\n </Box>\n )\n}\n","import type { KeyboardEvent } from 'react'\nimport { Box, Typography } from '@mui/material'\nimport { CategoryBar } from './category-bar'\nimport type { CategoryKey, CategorySize } from '../types'\nimport { styles } from '../style'\n\nexport interface CategoryRowMultiProps {\n /** Raw category key — what gets emitted to `onToggle`. */\n name: CategoryKey\n /** Display label (post-`labelFormatter`). Falls back to `name`. */\n displayName?: string | number\n /** One value per series. `0` is rendered as an empty bar (track only). */\n values: readonly number[]\n /** One color per series (palette + per-series overrides resolved upstream). */\n colors: readonly string[]\n /** Shared max across all series + rows (or `maxOverride`). */\n maxValue: number\n formatter: (n: number) => string\n selected: boolean\n onToggle: (name: CategoryKey) => void\n /** Bar visual density. Forwarded to every {@link CategoryBar} in the row. */\n size?: CategorySize\n}\n\n/**\n * Multi-series category row: label spans the top; bar+value pairs stack\n * vertically below, one per series. Each bar uses the full row width\n * track (no shared grid) for legibility at N>=2 series. Click anywhere\n * in the row (label OR any bar/value) toggles selection by `name`.\n *\n * Visual selection / dim signal lives ENTIRELY in the bar colors\n * (`colors` prop) — every series in a dimmed row receives\n * `theme.palette.action.disabled`; selected / unselected-no-selection\n * rows receive their real palette colors. Computed upstream by\n * `CategoryUI`. The row itself has no bg tint, no opacity rule.\n */\nexport function CategoryRowMulti({\n name,\n displayName,\n values,\n colors,\n maxValue,\n formatter,\n selected,\n onToggle,\n size,\n}: CategoryRowMultiProps) {\n const handleKey = (e: KeyboardEvent<HTMLDivElement>): void => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onToggle(name)\n }\n }\n return (\n <Box\n role='button'\n aria-pressed={selected}\n tabIndex={0}\n onClick={() => onToggle(name)}\n onKeyDown={handleKey}\n sx={styles.rowMulti}\n >\n <Typography variant='body2' sx={styles.multiName}>\n {displayName ?? name}\n </Typography>\n {values.map((v, i) => (\n // Multi-bar rows iterate per series — the bar belongs to series `i`,\n // and the row is keyed on the parent's `name`, so a composite of\n // `name` + the series index is stable across reorders.\n <Box key={`${name}-series-${i}`} sx={styles.multiBarRow}>\n <Box sx={styles.multiBarContainer}>\n <CategoryBar\n value={v}\n maxValue={maxValue}\n color={colors[i] ?? ''}\n size={size}\n />\n </Box>\n <Typography variant='body2' sx={styles.value}>\n {formatter(v)}\n </Typography>\n </Box>\n ))}\n </Box>\n )\n}\n","import { Box } from '@mui/material'\nimport type { CategorySize } from '../types'\nimport { styles } from '../style'\n\nexport interface CategoryBarStackedProps {\n /** One value per series. Zero values render no segment (visually + in the DOM). */\n values: readonly number[]\n /** One color per series. Resolved upstream by `CategoryUI.colorAt`. */\n colors: readonly string[]\n /**\n * Shared denominator across all rows + series (or `maxOverride`). Same\n * value `CategoryBar` uses — segments scale identically to single-bar rows\n * so cross-row comparison is preserved.\n */\n maxValue: number\n /** Visual density. Forwarded to the track styling; segments inherit height. */\n size?: CategorySize\n}\n\n/**\n * Stacked horizontal bar: one rounded track containing N square segments\n * placed side-by-side. Each segment's width is `value_i / maxValue * 100%`\n * and its left offset is the cumulative sum of preceding values. Square\n * interior edges + the parent track's `overflow: hidden` + rounded radius\n * mean the outer ends of the stacked bar match a single `CategoryBar` while\n * interior segment boundaries meet cleanly.\n *\n * Pure presentation — selection / dimming is resolved upstream by the row\n * via the `colors` prop. Each segment carries `data-bar-fill='true'` so the\n * existing row-hover brightening selector still fires on every segment.\n */\nexport function CategoryBarStacked({\n values,\n colors,\n maxValue,\n size = 'small',\n}: CategoryBarStackedProps) {\n // Cumulative offsets pre-computed up front so the render map function\n // stays pure (no mutable closure variable — keeps the React Compiler\n // immutability check happy).\n const offsets: number[] = []\n {\n let acc = 0\n for (const v of values) {\n offsets.push(acc)\n acc += v\n }\n }\n return (\n <Box sx={styles.bar[size]} data-size={size}>\n {values.map((v, i) => {\n if (v <= 0) return null\n const leftPct = maxValue > 0 ? (offsets[i]! / maxValue) * 100 : 0\n const pct = maxValue > 0 ? (v / maxValue) * 100 : 0\n return (\n <Box\n // Segments are keyed by per-series colour (the only stable\n // distinguishing field on this side) plus the segment index for\n // when callers reuse palette colours across series.\n key={`seg-${colors[i] ?? 'none'}-${i}`}\n sx={styles.stackedSegment[size]}\n style={{\n left: `${leftPct}%`,\n width: `${pct}%`,\n backgroundColor: colors[i] ?? '',\n }}\n data-bar-fill='true'\n />\n )\n })}\n </Box>\n )\n}\n","import type { KeyboardEvent } from 'react'\nimport { Box, Typography } from '@mui/material'\nimport { CategoryBarStacked } from './category-bar-stacked'\nimport type { CategoryKey, CategorySize } from '../types'\nimport { styles } from '../style'\n\nexport interface CategoryRowStackedProps {\n /** Raw category key — what gets emitted to `onToggle`. */\n name: CategoryKey\n /** Display label (post-`labelFormatter`). Falls back to `name`. */\n displayName?: string | number\n /** One value per series. Zero values still appear in the breakdown row. */\n values: readonly number[]\n /** One color per series (palette + per-series overrides resolved upstream). */\n colors: readonly string[]\n /**\n * Series names for the breakdown row, one per visible series, already\n * resolved by the caller (unnamed series fall back to `Series N` using\n * their ORIGINAL series index — this component has no notion of which\n * series were hidden, so it must not recompute a positional fallback).\n */\n seriesNames: readonly string[]\n formatter: (n: number) => string\n selected: boolean\n onToggle: (name: CategoryKey) => void\n /** Bar visual density. Forwarded to the inner {@link CategoryBarStacked}. */\n size?: CategorySize\n}\n\n/**\n * Stacked-mode category row: label + total share a header line; a single\n * segmented bar sits below; an inline breakdown lists each series with its\n * formatted value. Click anywhere in the row toggles selection by `name`.\n *\n * Per-row normalization: the stacked bar always fills 100% of the track,\n * with each segment sized as `value_i / sum(values)`. This is intentionally\n * different from `CategoryRowMulti` (which scales bars against the global\n * `maxValue` for cross-row comparison) — in stacked mode the comparable\n * axis is the proportion of each series within the row, not the row's\n * total relative to other rows. The total numeric value is still shown in\n * the header so the per-row magnitude isn't lost.\n *\n * Visual selection / dim signal lives entirely in the segment colors\n * (`colors` prop) — every series in a dimmed row receives\n * `theme.palette.action.disabled`. The bar visually collapses to a single\n * grey shape when dimmed, but the breakdown text stays at full color so the\n * per-series values remain legible.\n */\nexport function CategoryRowStacked({\n name,\n displayName,\n values,\n colors,\n seriesNames,\n formatter,\n selected,\n onToggle,\n size,\n}: CategoryRowStackedProps) {\n const handleKey = (e: KeyboardEvent<HTMLDivElement>): void => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onToggle(name)\n }\n }\n const total = values.reduce((a, b) => a + b, 0)\n return (\n <Box\n role='button'\n aria-pressed={selected}\n tabIndex={0}\n onClick={() => onToggle(name)}\n onKeyDown={handleKey}\n sx={styles.rowStacked}\n >\n <Box sx={styles.stackedHeader}>\n <Typography variant='body2' sx={styles.multiName}>\n {displayName ?? name}\n </Typography>\n <Typography variant='body2' sx={styles.stackedTotal}>\n {formatter(total)}\n </Typography>\n </Box>\n <CategoryBarStacked\n values={values}\n colors={colors}\n maxValue={total}\n size={size}\n />\n <Box sx={styles.stackedBreakdown}>\n {values.map((v, i) => (\n // Series name is the stable identity for the breakdown line.\n <Typography\n key={`breakdown-${seriesNames[i]}`}\n variant='body2'\n sx={styles.stackedBreakdownItem}\n >\n {`${seriesNames[i]}: ${formatter(v)}`}\n </Typography>\n ))}\n </Box>\n </Box>\n )\n}\n","import type { KeyboardEvent } from 'react'\nimport { Box, Typography } from '@mui/material'\nimport { Tooltip } from '../../../components'\nimport { styles } from '../style'\n\nexport interface CategoryRowOtherProps {\n hiddenCount: number\n /** Label for the overflow row. Defaults to `'Others'`. */\n otherLabel?: string\n /** Count text with `{count}` placeholder. Defaults to `'{count}'`. */\n otherCountLabel?: string\n /**\n * When provided, the row becomes a button: clicking it (or Enter/Space)\n * fires `onShowAll`, expanding the widget to reveal every category. When\n * omitted the row renders as a static, non-interactive summary.\n */\n onShowAll?: () => void\n /** Tooltip shown over the button form. Defaults to `'Show all'`. */\n showAllLabel?: string\n}\n\n/**\n * Overflow summary row rendered after the last visible category row when\n * `data.length > maxItems`. Shows `Others <count>` (count muted, no\n * parentheses).\n *\n * When `onShowAll` is supplied the row is an interactive button — clicking\n * it (or Enter/Space) expands the widget to show all categories, mirroring\n * the Searcher's full-list view. Without `onShowAll` it stays a static,\n * non-interactive summary (backward-compatible default).\n */\nexport function CategoryRowOther({\n hiddenCount,\n otherLabel = 'Others',\n otherCountLabel = '{count}',\n onShowAll,\n showAllLabel = 'Show all',\n}: CategoryRowOtherProps) {\n const countText = otherCountLabel.replace('{count}', String(hiddenCount))\n\n const count = (\n <Typography variant='body2' sx={styles.otherCount}>\n {countText}\n </Typography>\n )\n\n if (!onShowAll) {\n return (\n <Box sx={styles.otherRow}>\n <Typography variant='body2' sx={styles.otherLabel}>\n {otherLabel}\n </Typography>\n {count}\n </Box>\n )\n }\n\n const handleKey = (e: KeyboardEvent<HTMLSpanElement>): void => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onShowAll()\n }\n }\n\n // Only the label is the click target; the count stays static beside it.\n return (\n <Box sx={styles.otherRow}>\n <Tooltip title={showAllLabel}>\n <Typography\n variant='body2'\n component='span'\n role='button'\n tabIndex={0}\n onClick={onShowAll}\n onKeyDown={handleKey}\n sx={{ ...styles.otherLabel, ...styles.otherLabelButton }}\n >\n {otherLabel}\n </Typography>\n </Tooltip>\n {count}\n </Box>\n )\n}\n","import { Box, Typography } from '@mui/material'\nimport type { CategorySeriesConfig } from '../types'\nimport { styles } from '../style'\n\nexport interface CategoryLegendProps {\n /** Series metadata. Empty array → renders nothing. */\n series: readonly CategorySeriesConfig[]\n /**\n * Per-series colour resolver. Receives the series index and returns the\n * palette colour (or `undefined` to fall back to the MUI default). The\n * legend derives its dot colour from this on the fly — the caller does\n * NOT pre-compute a `colors` array (avoids passing two views of the\n * same source).\n */\n colorAt: (index: number) => string | undefined\n /**\n * Series indices currently hidden from the chart. Renders dimmed.\n * Optional — defaults to none hidden. Added after this component's first\n * release; kept optional (not required) so it stays a non-breaking\n * addition for any direct consumer of `CategoryLegend` (a public\n * subpath export) that predates the hide feature.\n */\n hiddenSeries?: ReadonlySet<number>\n /**\n * Fires with the series index when its legend item is clicked. Optional\n * — omitting it renders a legend with no hide affordance (same\n * reasoning as `hiddenSeries`).\n */\n onToggle?: (index: number) => void\n}\n\nconst NO_HIDDEN_SERIES: ReadonlySet<number> = new Set()\n\n/**\n * Sticky color legend rendered below a multi-series Category list.\n * Per-series `color` overrides the matching `colorAt(i)` result. Clicking an\n * item toggles that series' visibility in the rows above (mirrors ECharts'\n * native legend click-to-hide).\n */\nexport function CategoryLegend({\n series,\n colorAt,\n hiddenSeries = NO_HIDDEN_SERIES,\n onToggle,\n}: CategoryLegendProps) {\n if (series.length === 0) return null\n return (\n <Box sx={styles.legend}>\n {series.map((s, i) => {\n const hidden = hiddenSeries.has(i)\n return (\n <Box\n key={s.name}\n // `checkbox`/`aria-checked`, not `button`/`aria-pressed` — this\n // toggles a persistent visibility state (closer to a checkbox)\n // AND keeps it out of `getByRole('button')` queries that count\n // category ROWS throughout this widget's test suite.\n role='checkbox'\n aria-checked={!hidden}\n tabIndex={0}\n onClick={() => onToggle?.(i)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onToggle?.(i)\n }\n }}\n sx={hidden ? styles.legendItemHidden : styles.legendItem}\n >\n <Box\n sx={styles.legendDot}\n style={{ backgroundColor: s.color ?? colorAt(i) }}\n />\n <Typography variant='caption' sx={styles.legendLabel}>\n {s.name}\n </Typography>\n </Box>\n )\n })}\n </Box>\n )\n}\n","import { useCallback, useMemo, useRef, useState } from 'react'\nimport { Box, useTheme } from '@mui/material'\nimport { CategoryRowSingle } from './components/category-row-single'\nimport { CategoryRowMulti } from './components/category-row-multi'\nimport { CategoryRowStacked } from './components/category-row-stacked'\nimport { CategoryRowOther } from './components/category-row-other'\nimport { CategoryLegend } from './components/category-legend'\nimport type {\n CategoryKey,\n CategoryLabels,\n CategorySeriesConfig,\n CategorySize,\n CategoryWidgetData,\n} from './types'\nimport { styles } from './style'\n\nconst DEFAULT_MAX_ITEMS = 20\n\n// Fallback viewport height used in scroll mode ONLY when no natural\n// measurement is available yet — i.e., the consumer mounts directly into\n// `maxItems === 0` (e.g., SearcherToggle pre-enabled), so the list has\n// never rendered in capped form for us to measure.\n//\n// small: label(~20) + gap(4) + bar(4) + list-gap(8) ≈ 36\n// medium: label(~20) + gap(4) + bar(12) + list-gap(8) ≈ 44\nconst ROW_HEIGHT_PX: Record<CategorySize, number> = { small: 36, medium: 44 }\nconst SCROLL_VIEWPORT_FALLBACK_ROWS = 8\n\nexport interface CategoryUIProps {\n data: CategoryWidgetData\n /** Currently-selected category names (destination-owned). */\n selection?: readonly CategoryKey[]\n /** Fires with the next selection set when a row is clicked. */\n onSelectionChange?: (next: readonly CategoryKey[]) => void\n /** Number formatter applied to each row's value. */\n formatter?: (value: number) => string\n /**\n * Display-only transform for category names. Selection callbacks always\n * receive the raw `item.name` regardless of this formatter.\n */\n labelFormatter?: (value: string | number) => string | number\n /**\n * Per-series metadata. Enables the legend (for multi-series) and\n * overrides palette colors per series index. Length need not match\n * `data.length`; mismatches degrade gracefully (extras ignored, gaps\n * fall back to palette).\n */\n series?: readonly CategorySeriesConfig[]\n /**\n * Caps the number of visible category rows.\n *\n * - `undefined` (omitted) — caps at {@link DEFAULT_MAX_ITEMS} (20).\n * Surplus rows fold into a single \"Others <count>\" footer row.\n * `undefined` cannot mean \"no cap\" because it's consumed by the\n * default-parameter syntax — pass `null` instead.\n * - positive finite N — same as the default but with a custom cap.\n * - `0` — **no cap WITH scroll**: every row renders inside a\n * fixed-height viewport that scrolls internally. The viewport's\n * max-height is the list's natural `clientHeight` measured on the\n * first render where the list was NOT in scroll mode (i.e., the\n * capped view) — frozen for the component's lifetime. If the\n * consumer mounts directly into scroll mode and we never see a\n * capped render, the viewport falls back to `8 × ROW_HEIGHT_PX`.\n * Composers flip into this mode while the user is searching\n * (`maxItems = searcherOpen ? 0 : userMaxItems`) so the widget\n * card height stays stable.\n * - `null` / `Infinity` / negative — **no cap, no scroll**: render\n * every row; the list grows with content. Matches v1's \"undefined\"\n * behavior. Use `null` as the canonical explicit form.\n */\n maxItems?: number | null\n /** Labels for the \"Other\" overflow row. `{count}` placeholder is replaced. */\n labels?: CategoryLabels\n /**\n * When provided, the \"Other\" overflow row becomes a button — clicking it\n * fires `onShowAll`, which a composer typically wires to expand the widget\n * (drop the row cap) so every category becomes reachable. When omitted the\n * overflow row stays a static summary.\n */\n onShowAll?: () => void\n /** Manual override for the bar-width denominator. */\n maxOverride?: number\n /**\n * Visual density of the bar primitive. `'small'` (default) keeps the\n * historical 4px-tall pill; `'medium'` switches to a 12px-tall track\n * with a 2px corner radius. Only the bar track + fill change.\n */\n size?: CategorySize\n /**\n * Multi-series stacked mode. When `true` and `data.length > 1`, each\n * category renders as a single segmented bar (one segment per series)\n * with a `formatter(sum)` total in the header and a per-series\n * breakdown line below. Composers typically thread this from\n * `useTransformEnabled(id, 'stack-toggle')`.\n *\n * No-op for single-series data — same convention as the legend.\n */\n stacked?: boolean\n}\n\ninterface GroupedRow {\n name: CategoryKey\n values: number[]\n /** Per-series per-row color override (first non-undefined wins). */\n rowColors: (string | undefined)[]\n}\n\n/**\n * Group items by `name` across series so each unique name produces one\n * row containing N values (zero-filled where a series has no entry for\n * that name). First-seen order across series is preserved.\n *\n * Ported from v1\n * (`packages/react-ui/src/widgets/category/category-ui.tsx:137-166`)\n * with readonly typing + per-row color capture.\n */\nfunction generateGroupedData(data: CategoryWidgetData): GroupedRow[] {\n if (!data || data.length === 0) return []\n const seriesCount = Math.max(data.length, 1)\n const grouped = new Map<CategoryKey, GroupedRow>()\n const order: CategoryKey[] = []\n for (let s = 0; s < data.length; s++) {\n const series = data[s] ?? []\n for (const item of series) {\n let row = grouped.get(item.name)\n if (!row) {\n row = {\n name: item.name,\n values: new Array<number>(seriesCount).fill(0),\n rowColors: new Array<string | undefined>(seriesCount).fill(undefined),\n }\n grouped.set(item.name, row)\n order.push(item.name)\n }\n row.values[s] = item.value\n row.rowColors[s] = item.color\n }\n }\n return order.map((k) => grouped.get(k)!)\n}\n\n/**\n * Pure presentational component for the Category widget. Renders\n * single-series rows (`data.length === 1`) as a compact grid or\n * multi-series rows (`data.length > 1`) as stacked-bar groups, capped at\n * `maxItems` with an overflow summary, and an optional sticky color\n * legend when `series` metadata is supplied.\n *\n * Selection is destination-owned: clicking a row fires\n * `onSelectionChange(next)` with the toggled set; the consumer keeps the\n * list in their own store. `aria-pressed` + Enter/Space keyboard\n * activation give full a11y parity with the mouse path.\n *\n * Returns `null` when there's nothing to render — `Widget.State` is the\n * empty-state authority in the canonical compositor.\n */\nexport function CategoryUI({\n data,\n selection,\n onSelectionChange,\n formatter,\n labelFormatter,\n series,\n maxItems = DEFAULT_MAX_ITEMS,\n labels,\n onShowAll,\n maxOverride,\n size = 'small',\n stacked = false,\n}: CategoryUIProps) {\n const theme = useTheme()\n const fmt = formatter ?? ((n: number) => String(n))\n\n const hasSelection = !!selection && selection.length > 0\n const selectionSet = useMemo(\n () => new Set<CategoryKey>(selection ?? []),\n [selection],\n )\n\n const toggle = useCallback(\n (name: CategoryKey) => {\n if (!onSelectionChange) return\n const cur = selection ?? []\n const next = cur.includes(name)\n ? cur.filter((n) => n !== name)\n : [...cur, name]\n onSelectionChange(next)\n },\n [onSelectionChange, selection],\n )\n\n // Palette: same convention as Bar/Pie/Histogram/Scatterplot/Timeseries v2.\n const paletteColors = useMemo<readonly string[]>(\n () => [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n [theme],\n )\n\n const colorAt = useCallback(\n (seriesIndex: number, rowColor?: string): string => {\n if (rowColor) return rowColor\n const seriesColor = series?.[seriesIndex]?.color\n if (seriesColor) return seriesColor\n return (\n paletteColors[seriesIndex % paletteColors.length] ??\n theme.palette.secondary.main\n )\n },\n [series, paletteColors, theme],\n )\n\n // Dim color for non-selected rows when a selection exists. Swapped in\n // at the bar-fill level only — text + track stay at their real colors.\n // Theme-driven so it survives palette swaps.\n const dimColor = theme.palette.action.disabled\n\n const grouped = useMemo(() => generateGroupedData(data), [data])\n\n const maxValue = useMemo(() => {\n if (typeof maxOverride === 'number' && maxOverride > 0) return maxOverride\n let m = 0\n for (const row of grouped) {\n for (const v of row.values) if (v > m) m = v\n }\n return m\n }, [grouped, maxOverride])\n\n // Three modes:\n // * positive finite N (default `DEFAULT_MAX_ITEMS = 20` when prop\n // omitted): cap at N rows; surplus folds into \"Others <count>\".\n // * `0`: no cap WITH scroll — every row renders, the list locks to a\n // fixed viewport and scrolls internally. Composers use this to\n // bypass pagination while the user is searching:\n // `maxItems = searcherOpen ? 0 : userMaxItems`\n // * `null` / `Infinity` / negative: no cap, no scroll — every row\n // renders and the list grows with content. `null` is the canonical\n // explicit form (`undefined` is consumed by the default param above).\n const scrollMode = maxItems === 0\n\n // Natural-height measurement. In scroll mode (`maxItems === 0`,\n // set by the composer when the SearcherToggle is open) every row\n // renders inside a scrollable viewport. The viewport's max-height\n // must match the pre-overflow content area — i.e., whatever the\n // list was rendering BEFORE the composer dropped the cap.\n //\n // We measure the list's `clientHeight` exactly once, the first time\n // it attaches while NOT in scroll mode (otherwise we'd capture the\n // wrong layout). Once set, `naturalHeight` is the lock anchor\n // forever — matches v1's frozen-at-mount semantics, just with a\n // real DOM measurement instead of a hard-coded constant.\n //\n // Implemented via a callback ref instead of `useLayoutEffect` so\n // setState fires during commit, not inside an effect — satisfies\n // the `react-hooks/set-state-in-effect` rule. React invokes\n // callback refs on attach (and re-invokes them when the callback\n // identity changes, which it does when `scrollMode` flips), so\n // toggling the searcher off after a scroll-mode mount triggers the\n // first measurement at that point.\n //\n // Fallback: if the consumer never lands a non-scroll render\n // (e.g., searcher pre-enabled and never closed), `naturalHeight`\n // stays `null` → viewport falls back to `8 × ROW_HEIGHT_PX`.\n const measuredRef = useRef(false)\n const [naturalHeight, setNaturalHeight] = useState<number | null>(null)\n const listRefCallback = useCallback(\n (node: HTMLDivElement | null) => {\n if (!node) return\n if (measuredRef.current) return\n if (scrollMode) return\n const h = node.clientHeight\n if (h > 0) {\n measuredRef.current = true\n setNaturalHeight(h)\n }\n },\n [scrollMode],\n )\n\n // Which series are hidden via a legend click. Local UI-only state — not\n // synced to `selection`/`onSelectionChange` (that's row-level filter\n // selection, unrelated). Never allowed to reach \"every series hidden\":\n // toggling the last visible one instead resets to \"all visible\" rather\n // than leaving the widget blank.\n const [hiddenSeries, setHiddenSeries] = useState<ReadonlySet<number>>(\n () => new Set(),\n )\n // A reload with a different series breakdown invalidates hidden indices —\n // index 2 may now point at an entirely different series. Reset rather\n // than keep hiding whatever now occupies a stale index. Adjusted directly\n // during render (React's documented \"adjusting state when a prop changes\"\n // pattern) instead of in a `useEffect`, which would commit the stale\n // hidden-set for one extra frame before the effect fires. Compared by a\n // content-derived key, not the raw `series` reference — an inline\n // `series={[...]}` literal (no useMemo) gets a new reference on every\n // unrelated parent re-render, which would otherwise reset hiddenSeries\n // right after the user hides one.\n const seriesKey = JSON.stringify(series?.map((s) => s.name) ?? [])\n const [prevSeriesKey, setPrevSeriesKey] = useState(seriesKey)\n if (seriesKey !== prevSeriesKey) {\n setPrevSeriesKey(seriesKey)\n setHiddenSeries(new Set())\n }\n // Real number of data series — NOT `series?.length`, which is legend\n // metadata and may legitimately be shorter than the actual series count\n // (unnamed trailing series fall back to `Series N`). Using the metadata\n // length here would trip the \"never fully hidden\" guard early whenever\n // `series` is shorter than `data`.\n const seriesCount = Math.max(data.length, 1)\n const toggleSeries = useCallback(\n (index: number) => {\n setHiddenSeries((prev) => {\n const next = new Set(prev)\n if (next.has(index)) next.delete(index)\n else next.add(index)\n return next.size >= seriesCount ? new Set() : next\n })\n },\n [seriesCount],\n )\n\n if (grouped.length === 0) return null\n\n const hasCap =\n typeof maxItems === 'number' && Number.isFinite(maxItems) && maxItems > 0\n const visible = hasCap ? grouped.slice(0, maxItems) : grouped\n const hiddenCount = hasCap ? grouped.length - visible.length : 0\n\n const isMulti = data.length > 1\n const hasLegend = isMulti && !!series && series.length > 0\n // Invariant across every row in this render — only depends on\n // `hiddenSeries`/`seriesCount`, not on any particular row's data — so\n // it's computed once here instead of per row inside the render loop.\n const visibleIdx = Array.from({ length: seriesCount }, (_, i) => i).filter(\n (i) => !hiddenSeries.has(i),\n )\n\n // Fallback viewport height matches the documented \"8 × ROW_HEIGHT_PX\"\n // (see the constants at the top of the file). Earlier code multiplied\n // this by `seriesCount`, making a 3-series widget render 3× the\n // intended viewport on the first frame before `naturalHeight` was\n // measured — a visible layout jump.\n const scrollMaxHeight = scrollMode\n ? (naturalHeight ?? ROW_HEIGHT_PX[size] * SCROLL_VIEWPORT_FALLBACK_ROWS)\n : undefined\n\n return (\n <Box sx={styles.root}>\n <Box\n ref={listRefCallback}\n sx={scrollMode ? { ...styles.list, ...styles.listScroll } : styles.list}\n style={\n scrollMaxHeight !== undefined\n ? { maxHeight: scrollMaxHeight, overflowY: 'auto' }\n : undefined\n }\n >\n {visible.map((row) => {\n const selected = selectionSet.has(row.name)\n const dimmed = hasSelection && !selected\n const displayName = labelFormatter\n ? labelFormatter(row.name)\n : undefined\n // When the row is dimmed, every series' bar fill is replaced\n // with `dimColor`. Text + track are untouched. This is the\n // ONLY visual difference between selected and non-selected\n // rows — no row-level opacity, no `rowSelected` bg tint.\n const fill = (i: number): string =>\n dimmed ? dimColor : colorAt(i, row.rowColors[i])\n // Series hidden via the legend are dropped before reaching the\n // row components — they render whatever arrays they're given\n // with no notion of \"hidden\" themselves. `visibleIdx` is hoisted\n // above this loop (same for every row).\n if (isMulti) {\n if (stacked) {\n // Stacked-mode branch: one segmented bar per row. Toggling\n // `stacked` after the natural-height measurement does NOT\n // re-trigger measurement (see the `naturalHeight` comment\n // above) — accepted trade-off: stacked rows have a slightly\n // different height, so the scroll viewport may show extra\n // whitespace after the toggle. Visual only, not functional.\n // Stacked rows are per-row normalized — they don't take\n // the global `maxValue`. Each row's bar fills 100% of the\n // track and the segments split it by `value_i / sum`. The\n // numeric total in the header preserves the per-row\n // magnitude information.\n return (\n <CategoryRowStacked\n key={String(row.name)}\n name={row.name}\n displayName={displayName}\n values={visibleIdx.map((i) => row.values[i]!)}\n colors={visibleIdx.map((i) => fill(i))}\n seriesNames={visibleIdx.map(\n (i) => series?.[i]?.name ?? `Series ${i + 1}`,\n )}\n formatter={fmt}\n selected={selected}\n onToggle={toggle}\n size={size}\n />\n )\n }\n return (\n <CategoryRowMulti\n key={String(row.name)}\n name={row.name}\n displayName={displayName}\n values={visibleIdx.map((i) => row.values[i]!)}\n colors={visibleIdx.map((i) => fill(i))}\n maxValue={maxValue}\n formatter={fmt}\n selected={selected}\n onToggle={toggle}\n size={size}\n />\n )\n }\n return (\n <CategoryRowSingle\n key={String(row.name)}\n name={row.name}\n displayName={displayName}\n value={row.values[0] ?? 0}\n maxValue={maxValue}\n color={fill(0)}\n formatter={fmt}\n selected={selected}\n onToggle={toggle}\n size={size}\n />\n )\n })}\n {hiddenCount > 0 && (\n <CategoryRowOther\n hiddenCount={hiddenCount}\n otherLabel={labels?.other}\n otherCountLabel={labels?.otherCount}\n showAllLabel={labels?.showAll}\n onShowAll={onShowAll}\n />\n )}\n </Box>\n {hasLegend && series && (\n <CategoryLegend\n series={series}\n colorAt={(i) => colorAt(i)}\n hiddenSeries={hiddenSeries}\n onToggle={toggleSeries}\n />\n )}\n </Box>\n )\n}\n","import { useMemo } from 'react'\nimport { useWidgetId, useWidgetShallow, type WidgetState } from '../stores'\nimport { CategoryUI } from './category-ui'\nimport type {\n CategoryKey,\n CategoryLabels,\n CategorySeriesConfig,\n CategorySize,\n CategoryWidgetData,\n} from './types'\n\ninterface CategorySlice {\n data: CategoryWidgetData\n rawData: CategoryWidgetData | undefined\n formatter?: (value: number) => string\n labelFormatter?: (value: string | number) => string | number\n}\n\nconst categorySelector = (s: WidgetState): CategorySlice => ({\n data: (s.data ?? []) as CategoryWidgetData,\n rawData: (s.rawData ?? undefined) as CategoryWidgetData | undefined,\n formatter: s.formatter,\n labelFormatter: s.labelFormatter,\n})\n\nfunction maxFromCategoryData(d: CategoryWidgetData | undefined): number {\n if (!d) return 0\n let m = 0\n for (const series of d) {\n for (const item of series) if (item.value > m) m = item.value\n }\n return m\n}\n\nexport interface CategoryProps {\n /** Currently-selected category names. Destination-owned. */\n selection?: readonly CategoryKey[]\n /** Fires when a row is clicked. Consumer updates the destination's store. */\n onSelectionChange?: (next: readonly CategoryKey[]) => void\n /** Per-series metadata. Enables the legend + overrides palette per index. */\n series?: readonly CategorySeriesConfig[]\n /**\n * Cap visible rows; overflow folds into an \"Others <count>\" row. Default 20\n * (when omitted). Pass `0` to swap the cap for a scrollable viewport\n * (composers use this when the user opens the SearcherToggle —\n * `maxItems = searcherOpen ? 0 : userMaxItems`). Pass `null` to disable\n * the cap entirely without adding a scroll viewport.\n */\n maxItems?: number | null\n /** Labels for the \"Other\" overflow row. */\n labels?: CategoryLabels\n /**\n * When provided, the \"Other\" overflow row becomes a button that fires this\n * callback. Composers wire it to expand the widget (e.g. flip the\n * `show-all` flag) so every category is shown. Forwarded to\n * {@link CategoryUI}.\n */\n onShowAll?: () => void\n /**\n * Manual override for the bar-width denominator. When omitted, the\n * bridge auto-fills from the widget store's `rawData` so bar widths\n * stay coherent across data transforms (e.g., the Searcher filtering\n * rows in and out — bars don't rescale just because the larger rows\n * got hidden). Pass an explicit number to fix the denominator\n * regardless of the data.\n */\n maxOverride?: number\n /**\n * Visual density of the bar primitive. `'small'` (default) keeps the\n * historical 4px-tall pill; `'medium'` switches to a 12px-tall track\n * with a 2px corner radius. Forwarded as-is to {@link CategoryUI}.\n */\n size?: CategorySize\n /**\n * Multi-series stacked mode. Forwarded as-is to {@link CategoryUI}.\n * Composers typically wire this from\n * `useTransformEnabled(id, 'stack-toggle')`. No-op for single-series.\n */\n stacked?: boolean\n}\n\n/**\n * Stateful Category bridge — reads `data`, `formatter`, and\n * `labelFormatter` (post-pipeline) from the per-widget store and\n * forwards them to the pure {@link CategoryUI}. `selection` and\n * `onSelectionChange` follow the destination-owned principle: the\n * consumer keeps the list in their own store and passes it through.\n */\nexport function Category({\n selection,\n onSelectionChange,\n series,\n maxItems,\n labels,\n onShowAll,\n maxOverride,\n size,\n stacked,\n}: CategoryProps) {\n const id = useWidgetId()\n const slice = useWidgetShallow(id, categorySelector)\n // Auto-fill `maxOverride` from `rawData` so bar widths stay coherent\n // across data transforms (e.g., the Searcher filtering rows in/out).\n // Consumer's explicit value always wins; we only fill when omitted\n // AND `rawData` has at least one positive value (CategoryUI's\n // `maxOverride > 0` guard would reject 0 anyway, but skipping is\n // cleaner — it lets the live fallback path handle the empty case).\n const naturalMax = useMemo(\n () => maxFromCategoryData(slice.rawData),\n [slice.rawData],\n )\n const effectiveMaxOverride =\n maxOverride ?? (naturalMax > 0 ? naturalMax : undefined)\n return (\n <CategoryUI\n data={slice.data}\n formatter={slice.formatter}\n labelFormatter={slice.labelFormatter}\n selection={selection}\n onSelectionChange={onSelectionChange}\n series={series}\n maxItems={maxItems}\n labels={labels}\n onShowAll={onShowAll}\n maxOverride={effectiveMaxOverride}\n size={size}\n stacked={stacked}\n />\n )\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\nimport type { CategorySize } from './types'\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 1,\n py: 0.5,\n },\n // Mirror the real row layout: label + value on top, bar below.\n row: {\n display: 'flex',\n flexDirection: 'column',\n gap: 0.5,\n },\n rowHeader: {\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n gap: 1,\n },\n // Small fixed-width shimmer pills — matches the visual density of the\n // real label / value cells without claiming the full row width.\n name: { height: 14, width: 80 },\n value: { height: 14, width: 48 },\n} satisfies Record<string, SxProps<Theme>>\n\n// Bar shimmer height matches the live bar track for each size variant so\n// the skeleton doesn't visibly resize the row on data settle.\nconst BAR_HEIGHT: Record<CategorySize, number> = {\n small: 4,\n medium: 12,\n}\n\n// Varied widths give the bar shimmer a more realistic, less uniform feel.\n// Cycles when `rows > WIDTH_PATTERNS.length`.\nconst WIDTH_PATTERNS = ['95%', '80%', '55%', '75%', '60%']\n\nexport interface CategorySkeletonProps {\n rows?: number\n /**\n * Visual density. Mirrors the live widget's `size` prop so the loading\n * shimmer's bar height matches what's about to render — no row jump\n * on data settle.\n */\n size?: CategorySize\n}\n\nexport function CategorySkeleton({\n rows = 5,\n size = 'small',\n}: CategorySkeletonProps) {\n return (\n <Box sx={styles.root}>\n {Array.from({ length: rows }).map((_, i) => (\n <Box key={`row-${i}`} sx={styles.row}>\n <Box sx={styles.rowHeader}>\n <Skeleton variant='rectangular' sx={styles.name} />\n <Skeleton variant='rectangular' sx={styles.value} />\n </Box>\n <Skeleton\n variant='rectangular'\n sx={{\n height: BAR_HEIGHT[size],\n width: WIDTH_PATTERNS[i % WIDTH_PATTERNS.length],\n }}\n />\n </Box>\n ))}\n </Box>\n )\n}\n","import {\n buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadItem,\n} from '../actions/download'\nimport type { CategoryWidgetData } from './types'\n\n/**\n * Download menu items for the Category widget. Always includes a CSV item\n * with `series, name, value` columns (one row per item). When\n * `getCaptureEl` is supplied, prepends a PNG item that rasterises the\n * captured element via `html2canvas`.\n */\nexport function createCategoryDownloadConfig(args: {\n filename: string\n getData: () => CategoryWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push(\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: () => {\n const data = args.getData()\n const rows: unknown[][] = [['series', 'name', 'value']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const item of series) {\n rows.push([seriesName, item.name, item.value])\n }\n }\n return rows\n },\n }),\n )\n return items\n}\n"],"mappings":";;;;;;;;AAiEA,IAAakB,IAAS;CAEpBC,MAAM;EACJC,SAAS;EACTC,eAAe;EACff,UAAU;EACVgB,OAAO;CACT;CAEAC,MAAM;EACJH,SAAS;EACTC,eAAe;EACfG,KAAK;EACLC,IAAI;CACN;CAKAC,YAAY,EACVC,IAAI,EACN;CAMAC,WAAW;EACTR,SAAS;EACTC,eAAe;EACfG,KAAK;EAG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,gBACPI,EAAMC,KACJb,EAAqB;EACnBK,UAAUD,EAAKC;EACfG,cAAcJ,EAAKI;EACnBM,YAAYV,EAAKM;EACjBK,iBAAiBX,EAAKO;CACxB,CAAC,CACH,GAEFC,EAAMC,KACJd,EAAqB;EACnBM,UAAUD,EAAKC;EACfW,eAAe;GACb,IAAMC,IAAOb,EAAKE,QAAQ,GACpBY,IAAoB,CAAC;IAAC;IAAU;IAAQ;GAAO,CAAC;GACtD,KAAK,IAAM,CAACC,GAAGC,MAAWH,EAAKI,QAAQ,GAAG;IACxC,IAAMC,IAAalB,EAAKG,cAAcY,MAAM,UAAUA,IAAI;IAC1D,KAAK,IAAMI,KAAQH,GACjBF,EAAKL,KAAK;KAACS;KAAYC,EAAKC;KAAMD,EAAKE;IAAK,CAAC;GAEjD;GACA,OAAOP;EACT;CACF,CAAC,CACH,GACON;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"download-C7he8mSh.js","names":["html2canvas","DownloadHandle","url","revoke","CSV_FORMULA_PREFIX","toCsvString","rows","escape","cell","value","String","JSON","stringify","test","replace","map","row","join","downloadToCSV","csv","blob","Blob","type","URL","createObjectURL","revokeObjectURL","UNSAFE_FILENAME_CHARS","MAX_FILENAME_LENGTH","sanitizeFilename","name","slice","triggerLinkDownload","args","filename","a","document","createElement","href","download","style","display","body","appendChild","click","remove","DownloadDOMToPNGOptions","element","HTMLElement","pixelRatio","backgroundColor","downloadDOMToPNG","opts","Promise","canvas","scale","useCORS","logging","resolve","reject","toBlob","Error","DownloadLabels","trigger","loading","error","DEFAULT_DOWNLOAD_LABELS","useCallback","useState","ComponentType","CircularProgress","IconButton","ListItemIcon","ListItemText","Menu","MenuItem","SvgIconProps","FileDownload","DownloadIcon","Tooltip","triggerLinkDownload","DownloadItem","DEFAULT_DOWNLOAD_LABELS","DownloadLabels","DownloadProps","items","labels","Partial","icon","iconProps","onError","err","Error","Download","t0","$","_c","t1","Icon","undefined","t2","_labels","anchorEl","setAnchorEl","isDownloading","setIsDownloading","error","setError","t3","Symbol","for","e","currentTarget","open","t4","close","t5","item","disabled","resolve","then","t6","url","filename","revoke","setTimeout","catch","e_0","String","finally","onSelect","triggerLabel","loading","trigger","triggerActive","Boolean","t7","t8","t9","length","t10","t11","t12","t13","t14","t15","t16","vertical","horizontal","t17","t18","item_0","id","color","label","map","t19","SvgIcon","SvgIconProps","ArticleOutlined","ImageOutlined","PNGIcon","props","$","_c","t0","MarkdownIcon","CSVIcon","Symbol","for","t1","DOWNLOAD_ITEM_IDS","png","csv","markdown","const","DownloadItemId","DOWNLOAD_ITEM_IDS","downloadDOMToPNG","PNGIcon","DownloadItem","BuildPngDownloadItemArgs","filename","getCaptureEl","HTMLElement","pixelRatio","backgroundColor","label","buildPngDownloadItem","args","id","png","icon","resolve","el","Error","handle","element","url","revoke","DOWNLOAD_ITEM_IDS","downloadToCSV","CSVIcon","DownloadItem","BuildCsvDownloadItemBase","filename","label","BuildCsvDownloadItemArgs","getRows","getCsv","buildCsvDownloadItem","args","id","csv","icon","resolve","blob","Blob","type","url","URL","createObjectURL","Promise","revoke","revokeObjectURL","handle"],"sources":["../src/widgets-v2/actions/download/exports.ts","../src/widgets-v2/actions/download/labels.ts","../src/widgets-v2/actions/download/download.tsx","../src/widgets-v2/actions/download/icons.tsx","../src/widgets-v2/actions/download/constants.ts","../src/widgets-v2/actions/download/png-item.tsx","../src/widgets-v2/actions/download/csv-item.tsx"],"sourcesContent":["/**\n * Pure download helpers — no React, no DOM lifecycle outside the link click.\n * Component layer in {@link ./download.tsx} orchestrates these.\n */\n\nimport html2canvas from 'html2canvas'\n\nexport interface DownloadHandle {\n url: string\n revoke: () => void\n}\n\n// Leading characters that Excel / Sheets / Numbers interpret as a formula\n// when the CSV is opened. Prefixing the cell with a single quote forces the\n// spreadsheet app to render it as plain text. Tab and CR are included\n// because some tooling strips leading whitespace before formula evaluation.\nconst CSV_FORMULA_PREFIX = /^[=+\\-@\\t\\r]/\n\nexport function toCsvString(rows: readonly (readonly unknown[])[]): string {\n const escape = (cell: unknown): string => {\n if (cell == null) return ''\n let value =\n typeof cell === 'string'\n ? cell\n : typeof cell === 'number' || typeof cell === 'boolean'\n ? String(cell)\n : JSON.stringify(cell)\n if (CSV_FORMULA_PREFIX.test(value)) value = `'${value}`\n if (/[\",\\n\\r]/.test(value)) return `\"${value.replace(/\"/g, '\"\"')}\"`\n return value\n }\n return rows.map((row) => row.map(escape).join(',')).join('\\n')\n}\n\nexport function downloadToCSV(\n rows: readonly (readonly unknown[])[],\n): DownloadHandle {\n const csv = toCsvString(rows)\n const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' })\n const url = URL.createObjectURL(blob)\n return { url, revoke: () => URL.revokeObjectURL(url) }\n}\n\n// Path separators, NUL, and ASCII control chars. Filenames containing these\n// can confuse the browser download stack and historically enabled\n// Content-Disposition-style trickery.\n// eslint-disable-next-line no-control-regex\nconst UNSAFE_FILENAME_CHARS = /[\\\\/\\x00-\\x1f\\x7f]/g\nconst MAX_FILENAME_LENGTH = 200\n\nexport function sanitizeFilename(name: string): string {\n return (\n (name ?? '')\n .replace(UNSAFE_FILENAME_CHARS, '_')\n .slice(0, MAX_FILENAME_LENGTH) || 'download'\n )\n}\n\n/**\n * Triggers a browser download for the given URL by synthesizing an anchor,\n * clicking it, and removing it. Pure DOM — no React. The filename is run\n * through {@link sanitizeFilename} before being assigned to `a.download`.\n */\nexport function triggerLinkDownload(args: {\n url: string\n filename: string\n}): void {\n const { url, filename } = args\n const a = document.createElement('a')\n a.href = url\n a.download = sanitizeFilename(filename)\n a.style.display = 'none'\n document.body.appendChild(a)\n a.click()\n a.remove()\n}\n\nexport interface DownloadDOMToPNGOptions {\n element: HTMLElement\n /** html2canvas `scale`. Default 2 — crisp on hi-DPI displays. */\n pixelRatio?: number\n /**\n * html2canvas `backgroundColor`. Default `null` (transparent) so the PNG\n * inherits whatever surface it lands on when the user pastes it.\n */\n backgroundColor?: string | null\n}\n\n/**\n * Rasterise an HTMLElement to PNG via `html2canvas` and wrap the result in\n * a `DownloadHandle`. The caller is responsible for calling `handle.revoke`\n * after the link click is dispatched. Used by per-widget download configs\n * to power the PNG menu item.\n */\nexport async function downloadDOMToPNG(\n opts: DownloadDOMToPNGOptions,\n): Promise<DownloadHandle> {\n const { element, pixelRatio = 2, backgroundColor = null } = opts\n const canvas = await html2canvas(element, {\n scale: pixelRatio,\n backgroundColor,\n useCORS: true,\n logging: false,\n })\n return new Promise<DownloadHandle>((resolve, reject) => {\n canvas.toBlob((blob) => {\n if (!blob) {\n reject(new Error('[widgets-v2] toBlob() returned null'))\n return\n }\n const url = URL.createObjectURL(blob)\n resolve({ url, revoke: () => URL.revokeObjectURL(url) })\n }, 'image/png')\n })\n}\n","export interface DownloadLabels {\n trigger: string\n /** Tooltip / aria-label shown on the trigger while a download is in flight. */\n loading: string\n /**\n * Tooltip / aria-label shown on the trigger after a download failed. Cleared\n * the next time the menu opens.\n */\n error: string\n}\n\nexport const DEFAULT_DOWNLOAD_LABELS: DownloadLabels = {\n trigger: 'Download',\n loading: 'Downloading…',\n error: 'Download failed',\n}\n","import { useCallback, useState, type ComponentType } from 'react'\nimport {\n CircularProgress,\n IconButton,\n ListItemIcon,\n ListItemText,\n Menu,\n MenuItem,\n type SvgIconProps,\n} from '@mui/material'\nimport { FileDownload as DownloadIcon } from '@mui/icons-material'\nimport { Tooltip } from '../../../components'\nimport { triggerLinkDownload } from './exports'\nimport type { DownloadItem } from './types'\nimport { DEFAULT_DOWNLOAD_LABELS, type DownloadLabels } from './labels'\n\nexport interface DownloadProps {\n items: readonly DownloadItem[]\n labels?: Partial<DownloadLabels>\n icon?: ComponentType<SvgIconProps>\n iconProps?: SvgIconProps\n /**\n * Fires when an item's `resolve()` rejects (or any step in the click-through\n * path throws). The error is normalised to a real `Error` first. Surface\n * to your telemetry / toast layer here; the trigger already shows a visual\n * error indicator independently.\n */\n onError?: (err: Error) => void\n}\n\nexport function Download({\n items,\n labels,\n icon: Icon = DownloadIcon,\n iconProps,\n onError,\n}: DownloadProps) {\n const _labels = { ...DEFAULT_DOWNLOAD_LABELS, ...labels }\n const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)\n const [isDownloading, setIsDownloading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const open = useCallback((e: React.MouseEvent<HTMLButtonElement>) => {\n // Clear any prior error when the user re-engages the menu — the next\n // attempt is a fresh interaction, not a continuation of the failed one.\n setError(null)\n setAnchorEl(e.currentTarget)\n }, [])\n const close = useCallback(() => setAnchorEl(null), [])\n\n const onSelect = useCallback(\n (item: DownloadItem) => {\n // Single-flight: ignore re-entry while a download is already in flight.\n // The trigger is `disabled` and the menu is closed during that window,\n // so this guard mostly defends against future call sites that bypass\n // the menu (e.g. keyboard shortcuts).\n if (item.disabled || isDownloading) return\n close()\n setIsDownloading(true)\n setError(null)\n item\n .resolve()\n .then(({ url, filename, revoke }) => {\n // `item.filename` overrides what `resolve()` returns — lets consumers\n // template the filename with widget metadata declaratively.\n triggerLinkDownload({ url, filename: item.filename ?? filename })\n // Defer revoke past the current task so Safari / Firefox-on-slow-disk\n // can dispatch the download before the blob URL is invalidated.\n // Synchronous revoke here can silently cancel the download.\n if (revoke) setTimeout(revoke, 0)\n })\n .catch((err: unknown) => {\n const e = err instanceof Error ? err : new Error(String(err))\n setError(e)\n onError?.(e)\n })\n .finally(() => {\n setIsDownloading(false)\n })\n },\n [close, isDownloading, onError],\n )\n\n const triggerLabel = isDownloading\n ? _labels.loading\n : error\n ? _labels.error\n : _labels.trigger\n const triggerActive = Boolean(anchorEl) || isDownloading\n\n return (\n <>\n <Tooltip title={triggerLabel}>\n <IconButton\n size='small'\n aria-label={triggerLabel}\n aria-haspopup='true'\n aria-expanded={anchorEl ? 'true' : undefined}\n aria-busy={isDownloading || undefined}\n data-error={error ? 'true' : undefined}\n disabled={isDownloading || items.length === 0}\n onClick={open}\n className={triggerActive ? 'active' : undefined}\n >\n {isDownloading ? (\n <CircularProgress size={18} color='inherit' />\n ) : (\n <Icon fontSize='small' {...iconProps} />\n )}\n </IconButton>\n </Tooltip>\n <Menu\n anchorEl={anchorEl}\n open={Boolean(anchorEl)}\n onClose={close}\n variant='menu'\n elevation={8}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'right',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'right',\n }}\n >\n {items.map((item) => (\n <MenuItem\n key={item.id}\n disabled={item.disabled}\n onClick={() => void onSelect(item)}\n >\n {item.icon && (\n <ListItemIcon sx={{ color: 'text.primary' }}>\n {item.icon}\n </ListItemIcon>\n )}\n <ListItemText>{item.label}</ListItemText>\n </MenuItem>\n ))}\n </Menu>\n </>\n )\n}\n","import { SvgIcon, type SvgIconProps } from '@mui/material'\nimport { ArticleOutlined, ImageOutlined } from '@mui/icons-material'\n\n/**\n * Generic \"image\" glyph used for the PNG download item. Wraps MUI's\n * `ImageOutlined` so callers can swap it via the per-widget download\n * config's `icon` override without pulling MUI directly.\n */\nexport function PNGIcon(props: SvgIconProps) {\n return <ImageOutlined {...props} />\n}\n\n/**\n * Generic \"document\" glyph used for the Markdown download item. Wraps MUI's\n * `ArticleOutlined`, mirroring {@link PNGIcon}, so the Markdown menu item\n * carries an icon consistent with the other download formats.\n */\nexport function MarkdownIcon(props: SvgIconProps) {\n return <ArticleOutlined {...props} />\n}\n\n/**\n * \"CSV\" rectangle with the letters spelled inside — matches v1 visual and is\n * easier to recognise in a download menu than a generic table glyph.\n */\nexport function CSVIcon(props: SvgIconProps) {\n return (\n <SvgIcon viewBox='0 0 18 18' {...props}>\n <path\n fill='currentColor'\n d='M4.313 11.25h2.25v-1.125H4.688v-2.25h1.875V6.75h-2.25a.726.726 0 0 0-.535.216.726.726 0 0 0-.216.534v3c0 .213.072.39.216.534a.726.726 0 0 0 .534.216Zm2.925 0h2.25c.212 0 .39-.072.534-.216a.726.726 0 0 0 .216-.534V9.375a.931.931 0 0 0-.216-.59.658.658 0 0 0-.534-.273H8.363v-.637h1.875V6.75h-2.25a.726.726 0 0 0-.535.216.726.726 0 0 0-.216.534v1.125c0 .213.072.403.216.572a.675.675 0 0 0 .534.253h1.126v.675H7.238v1.125Zm4.95 0h1.124l1.313-4.5H13.5l-.75 2.588L12 6.75h-1.125l1.313 4.5ZM3 15c-.413 0-.766-.147-1.06-.44a1.445 1.445 0 0 1-.44-1.06v-9c0-.412.147-.766.44-1.06C2.235 3.148 2.588 3 3 3h12c.412 0 .766.147 1.06.44.293.294.44.648.44 1.06v9c0 .412-.147.766-.44 1.06-.294.293-.647.44-1.06.44H3Zm0-1.5h12v-9H3v9Z'\n />\n </SvgIcon>\n )\n}\n","/**\n * Canonical `DownloadItem.id`s for the built-in download formats. Centralised\n * so the per-format builders — and anything that keys off the id (menu logic,\n * tests) — reference one source of truth instead of re-typing string literals.\n * The Markdown format keeps the short `'md'` id to match its `.md` extension.\n */\nexport const DOWNLOAD_ITEM_IDS = {\n png: 'png',\n csv: 'csv',\n markdown: 'md',\n} as const\n\nexport type DownloadItemId =\n (typeof DOWNLOAD_ITEM_IDS)[keyof typeof DOWNLOAD_ITEM_IDS]\n","import { DOWNLOAD_ITEM_IDS } from './constants'\nimport { downloadDOMToPNG } from './exports'\nimport { PNGIcon } from './icons'\nimport type { DownloadItem } from './types'\n\nexport interface BuildPngDownloadItemArgs {\n /** Base filename (without extension). The item appends `.png`. */\n filename: string\n /**\n * Reads the capture element to rasterise. Called at click time so the\n * download config doesn't capture a stale reference. Wire it to\n * `() => getCaptureEl(id)` from `widgets-v2/stores`.\n */\n getCaptureEl: () => HTMLElement | null\n /** html2canvas `scale`. Default 2. */\n pixelRatio?: number\n /** html2canvas `backgroundColor`. Default transparent (`null`). */\n backgroundColor?: string | null\n /** Override the menu label. Default `'PNG'`. */\n label?: string\n}\n\n/**\n * Builds the standard PNG `DownloadItem` used by every per-widget download\n * config. Centralised so the menu label, icon, error message, and filename\n * suffix stay consistent across widgets without each `create*DownloadConfig`\n * re-deriving the same shape.\n */\nexport function buildPngDownloadItem(\n args: BuildPngDownloadItemArgs,\n): DownloadItem {\n return {\n id: DOWNLOAD_ITEM_IDS.png,\n label: args.label ?? 'PNG',\n icon: <PNGIcon fontSize='small' />,\n resolve: async () => {\n const el = args.getCaptureEl()\n if (!el) {\n throw new Error('[widgets-v2] No PNG capture element available')\n }\n const handle = await downloadDOMToPNG({\n element: el,\n pixelRatio: args.pixelRatio,\n backgroundColor: args.backgroundColor,\n })\n return {\n url: handle.url,\n filename: `${args.filename}.png`,\n revoke: handle.revoke,\n }\n },\n }\n}\n","import { DOWNLOAD_ITEM_IDS } from './constants'\nimport { downloadToCSV } from './exports'\nimport { CSVIcon } from './icons'\nimport type { DownloadItem } from './types'\n\ninterface BuildCsvDownloadItemBase {\n /** Base filename (without extension). The item appends `.csv`. */\n filename: string\n /** Override the menu label. Default `'CSV'`. */\n label?: string\n}\n\n/**\n * Args for {@link buildCsvDownloadItem}. A discriminated union: a caller must\n * supply exactly one content source — `getRows` (rows serialised through the\n * shared `toCsvString`) or `getCsv` (a pre-built CSV string). The `?: never`\n * arms make passing both — or neither — a compile-time error.\n */\nexport type BuildCsvDownloadItemArgs =\n | (BuildCsvDownloadItemBase & {\n /**\n * Builds the CSV rows at click time. Used by most widgets — rows are run\n * through `toCsvString` so escaping (incl. the spreadsheet\n * formula-injection guard) stays consistent across widgets.\n */\n getRows: () => readonly (readonly unknown[])[]\n getCsv?: never\n })\n | (BuildCsvDownloadItemBase & {\n /**\n * Returns a pre-built CSV string at click time. Escape hatch for widgets\n * (e.g. Table) that already serialise their own CSV with bespoke\n * header/cell handling.\n */\n getCsv: () => string\n getRows?: never\n })\n\n/**\n * Builds the standard CSV `DownloadItem` used by every per-widget download\n * config. Centralised so the menu label, icon, and `.csv` filename suffix stay\n * consistent across widgets — mirrors {@link buildPngDownloadItem} so neither\n * format can drift again.\n */\nexport function buildCsvDownloadItem(\n args: BuildCsvDownloadItemArgs,\n): DownloadItem {\n return {\n id: DOWNLOAD_ITEM_IDS.csv,\n label: args.label ?? 'CSV',\n icon: <CSVIcon fontSize='small' />,\n resolve: () => {\n if (args.getCsv) {\n const csv = args.getCsv()\n const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' })\n const url = URL.createObjectURL(blob)\n return Promise.resolve({\n url,\n filename: `${args.filename}.csv`,\n revoke: () => URL.revokeObjectURL(url),\n })\n }\n const handle = downloadToCSV(args.getRows())\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;AAgBA,IAAMI,IAAqB;AAE3B,SAAgBC,EAAYC,GAA+C;CACzE,IAAMC,KAAUC,MAA0B;EACxC,IAAIA,KAAQ,MAAM,OAAO;EACzB,IAAIC,IACF,OAAOD,KAAS,WACZA,IACA,OAAOA,KAAS,YAAY,OAAOA,KAAS,YAC1CE,OAAOF,CAAI,IACXG,KAAKC,UAAUJ,CAAI;EAG3B,OAFIJ,EAAmBS,KAAKJ,CAAK,MAAGA,IAAQ,IAAIA,MAC5C,WAAWI,KAAKJ,CAAK,IAAU,IAAIA,EAAMK,QAAQ,MAAM,MAAI,EAAC,KACzDL;CACT;CACA,OAAOH,EAAKS,KAAKC,MAAQA,EAAID,IAAIR,CAAM,CAAC,CAACU,KAAK,GAAG,CAAC,CAAC,CAACA,KAAK,IAAI;AAC/D;AAEA,SAAgBC,EACdZ,GACgB;CAChB,IAAMa,IAAMd,EAAYC,CAAI,GACtBc,IAAO,IAAIC,KAAK,CAACF,CAAG,GAAG,EAAEG,MAAM,0BAA0B,CAAC,GAC1DpB,IAAMqB,IAAIC,gBAAgBJ,CAAI;CACpC,OAAO;EAAElB;EAAKC,cAAcoB,IAAIE,gBAAgBvB,CAAG;CAAE;AACvD;AAMA,IAAMwB,IAAwB,uBACxBC,IAAsB;AAE5B,SAAgBC,EAAiBC,GAAsB;CACrD,QACGA,KAAQ,GAAA,CACNf,QAAQY,GAAuB,GAAG,CAAC,CACnCI,MAAM,GAAGH,CAAmB,K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S;EACrBK,MAAM,kBAAC,GAAD,EAAS,UAAS,QAAO,CAAA;EAC/BC,SAAS,YAAY;GACnB,IAAMC,IAAKL,EAAKN,aAAa;GAC7B,IAAI,CAACW,GACH,MAAUC,MAAM,+CAA+C;GAEjE,IAAMC,IAAS,MAAMlB,EAAiB;IACpCmB,SAASH;IACTT,YAAYI,EAAKJ;IACjBC,iBAAiBG,EAAKH;GACxB,CAAC;GACD,OAAO;IACLY,KAAKF,EAAOE;IACZhB,UAAU,GAAGO,EAAKP,SAAQ;IAC1BiB,QAAQH,EAAOG;GACjB;EACF;CACF;AACF;;;ACRA,SAAgBW,EACdC,GACc;CACd,OAAO;EACLC,IAAIZ,EAAkBa;EACtBP,OAAOK,EAAKL,SAAS;EACrBQ,MAAM,kBAAC,GAAD,EAAS,UAAS,QAAO,CAAA;EAC/BC,eAAe;GACb,IAAIJ,EAAKF,QAAQ;IACf,IAAMI,IAAMF,EAAKF,OAAO,GAClBO,IAAO,IAAIC,KAAK,CAACJ,CAAG,GAAG,EAAEK,MAAM,0BAA0B,CAAC,GAC1DC,IAAMC,IAAIC,gBAAgBL,CAAI;IACpC,OAAOM,QAAQP,QAAQ;KACrBI;KACAd,UAAU,GAAGM,EAAKN,SAAQ;KAC1BkB,cAAcH,IAAII,gBAAgBL,CAAG;IACvC,CAAC;GACH;GACA,IAAMM,IAASxB,EAAcU,EAAKH,QAAQ,CAAC;GAC3C,OAAOc,QAAQP,QAAQ;IACrBI,KAAKM,EAAON;IACZd,UAAU,GAAGM,EAAKN,SAAQ;IAC1BkB,QAAQE,EAAOF;GACjB,CAAC;EACH;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"echart-BnJYXH7H.js","names":["echarts","ECharts","EChartsOption","EdgeAlignment","alignMinLabel","alignMaxLabel","CENTERED","SAFETY_MARGIN_PX","decideEdgeAlignment","args","firstLabel","lastLabel","font","firstTickX","lastTickX","width","halfFirst","format","getTextRect","halfLast","AxisLabel","formatter","value","fontSize","fontFamily","fontWeight","CategoryXAxis","type","axisLabel","SeriesLike","encode","x","datasetIndex","Cell","firstOf","T","Array","isArray","firstXAxis","option","axis","xAxis","undefined","hasDataZoom","dz","dataZoom","length","cellToText","fmt","String","resolveEdgeLabels","count","series0","series","encodeX","allDatasets","dataset","source","rows","Record","size","family","weight","clampEdgeLabels","chart","prev","next","computeAlignment","setOption","lazyUpdate","labels","convertToPixel","xAxisIndex","getWidth","Number","isFinite","ResizeCallback","callbacks","Map","Element","observer","ResizeObserver","getObserver","entries","entry","callback","get","target","NOOP_CLEANUP","undefined","observeResize","element","ro","set","observe","delete","unobserve","size","disconnect","__resetSharedResizeObserver","clear","SxProps","Theme","styles","root","width","flex","minHeight","Record","useEffect","useEffectEvent","useRef","Box","SxProps","Theme","echarts","clampEdgeLabels","CENTERED","EdgeAlignment","observeResize","styles","DEFAULT_INIT_OPTS","renderer","EChartsInitOpts","EchartsEventHandler","event","EchartUIProps","option","EChartsOption","replaceMerge","onEvents","Record","init","onInstance","chart","ECharts","className","sx","EchartUI","t0","$","_c","containerRef","chartRef","seriesFingerprintRef","datasetFingerprintRef","optionRef","edgeAlignRef","t1","notifyInstance","t2","current","chart_0","onFinished","on","onLegendSelectChanged","params","selected","names","Object","keys","length","every","name","dispatchAction","type","off","dispose","t3","t4","t5","seriesFp","computeSeriesFingerprint","datasetFp","computeDatasetFingerprint","augmented","Set","add","setOption","notMerge","lazyUpdate","size","Array","from","undefined","t6","t7","Symbol","for","node","resize","t8","t9","chart_1","handler","entries","event_0","handler_0","t10","root","t11","series","isArray","map","s","String","o","datasetIndex","stack","JSON","stringify","encode","join","dataset","useCallback","useMemo","SxProps","Theme","echarts","applyTransforms","setEchartInstance","useWidgetId","useWidgetShallow","Transform","EchartUI","EchartsEventHandler","DEFAULT_REPLACE_MERGE","OptionFactoryContext","formatter","value","labelFormatter","OptionFactory","option","EChartsOption","data","ctx","EchartProps","optionFactory","onEvents","Record","init","EChartsInitOpts","className","sx","EchartSlice","configTransforms","echartSelector","s","Echart","t0","$","_c","id","slice","t1","chart","onInstance","sliceData","sliceFormatter","sliceLabelFormatter","t2","undefined","structural","t3","transformed","t4","keys","Set","xf","enabled","replaceMergeKeys","length","k","add","Array","from","sort","replaceMerge","t5","t6","useCallback","useMemo","useRef","CallbackDataParams","EchartsEventHandler","SelectionKey","UseChartSelectionOptions","selection","K","onSelectionChange","next","keyFromClick","params","keysFromBrush","selected","seriesIndex","dataIndex","ChartSelectionWiring","onEvents","Record","useChartSelection","t0","$","_c","t1","event","key","current","idx","indexOf","slice","handleClick","t2","Symbol","for","latestBrushedRef","t3","event_0","params_0","batch","handleBrushSelected","t4","handleBrushEnd","t5","click","brushSelected","brushEnd","wiringSelection","length","t6"],"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","../src/widgets-v2/echart/use-chart-selection.ts"],"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 // `flex: 1` lets the chart fill a parent that has a definite height —\n // the fullscreen dialog. Inline it has none (Widget.Content is an\n // auto-height flex column), so flex-basis resolves to the content box,\n // which is empty until ECharts measures it: at `min-height: 0` the\n // container is 0px tall, ECharts draws nothing and the widget renders\n // blank. 304 is not a new magic number — it's the height `init.height`\n // used to pin, kept so cards look exactly as before. Override per widget\n // with `<Widget.Echart sx={{ minHeight }} />`.\n flex: 1,\n minHeight: 304,\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\n// No `height`: a numeric height here is stored in zrender's init opts, and\n// every later `resize()` resolves back to it — the chart would stay that tall\n// inside a fullscreen dialog. Height comes from the container instead\n// (`styles.root`'s `min-height` inline, `flex: 1` when the parent has one).\nexport const DEFAULT_INIT_OPTS = {\n renderer: 'svg',\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 is container-driven, so prefer\n * `sx={{ minHeight }}` over pinning `height` here.\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 { SxProps, Theme } from '@mui/material'\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 * Styles for the chart container — this is where its height comes from.\n * `min-height` defaults to the card height (304px) and `flex: 1` lets the\n * chart fill a taller parent; override either here, e.g.\n * `sx={{ minHeight: 400 }}` for a taller card.\n */\n sx?: SxProps<Theme>\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 sx,\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 sx={sx}\n />\n )\n}\n","import { useCallback, useMemo, useRef } from 'react'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport type { EchartsEventHandler } from './echart-ui'\n\nexport type SelectionKey = string | number\n\nexport interface UseChartSelectionOptions<K extends SelectionKey> {\n /**\n * Controlled selection. `undefined`/`null`/an explicit `[]` all mean \"no\n * selection interaction\" — every current merger already treats an empty\n * selection as \"nothing excluded,\" so this hook collapses all three to\n * `null` rather than promising per-merger `[]` semantics it doesn't\n * implement.\n */\n selection?: readonly K[]\n /** Receives the next selection. When omitted the wiring is a no-op. */\n onSelectionChange?: (next: readonly K[]) => void\n /**\n * Pull a selection key out of an ECharts `click` event. Return `null` to\n * skip (e.g. a click on empty plot area). For Bar/Pie/Timeseries this is\n * usually `(p) => p.name`; for Histogram/Scatterplot it's the dataIndex.\n */\n keyFromClick: (params: CallbackDataParams) => K | null\n /**\n * Map a `brushSelected` payload's `selected[*]` entries (each carrying a\n * `seriesIndex` + `dataIndex[]`) into the full set of selection keys for\n * the brushed area. Called once per brush event.\n */\n keysFromBrush: (\n selected: readonly { seriesIndex: number; dataIndex: number[] }[],\n ) => K[]\n}\n\nexport interface ChartSelectionWiring<K extends SelectionKey> {\n /**\n * Pass straight to `<Widget.Echart onEvents={…}>`. Wires `click` and\n * `brushSelected` so the user's interactions reach `onSelectionChange`.\n */\n onEvents: Record<string, EchartsEventHandler>\n /**\n * The current selection — `null` for \"no selection interaction\"\n * (`undefined`/`null`/an explicit `[]`), or a non-empty array meaning\n * \"render only these as fully opaque, dim the rest\".\n */\n selection: readonly K[] | null\n}\n\n/**\n * Translate ECharts' click + brush events into a consumer-owned selection\n * with the expected dashboard semantics:\n *\n * - **Click toggles** — clicking an item adds it to the selection if\n * absent, removes it if present.\n * - **Brush replaces** — finishing a brush stroke overwrites the selection\n * with whatever the brush covered (drag-to-empty clears).\n *\n * Wire the returned `onEvents` into `<Widget.Echart>` and feed\n * `wiring.selection` to the widget's option factory so the merger can dim\n * non-selected rows at fusion time.\n */\nexport function useChartSelection<K extends SelectionKey>({\n selection,\n onSelectionChange,\n keyFromClick,\n keysFromBrush,\n}: UseChartSelectionOptions<K>): ChartSelectionWiring<K> {\n const handleClick = useCallback(\n (event: unknown) => {\n if (!onSelectionChange) return\n const params = event as CallbackDataParams\n const key = keyFromClick(params)\n if (key == null) return\n const current = selection ?? []\n const idx = current.indexOf(key)\n const next =\n idx === -1\n ? [...current, key]\n : [...current.slice(0, idx), ...current.slice(idx + 1)]\n onSelectionChange(next)\n },\n [selection, onSelectionChange, keyFromClick],\n )\n\n // ECharts fires `brushSelected` on every pointer-move while the user is\n // drawing a brush, but we only want to push to `onSelectionChange` once\n // the gesture ends. Cache the latest `brushSelected` payload here, then\n // commit on `brushEnd`.\n const latestBrushedRef = useRef<\n readonly { seriesIndex: number; dataIndex: number[] }[]\n >([])\n\n const handleBrushSelected = useCallback((event: unknown) => {\n const params = event as {\n batch?: {\n selected?: { seriesIndex: number; dataIndex: number[] }[]\n }[]\n }\n latestBrushedRef.current = params.batch?.[0]?.selected ?? []\n }, [])\n\n const handleBrushEnd = useCallback(() => {\n if (!onSelectionChange) return\n onSelectionChange(keysFromBrush(latestBrushedRef.current))\n }, [onSelectionChange, keysFromBrush])\n\n const onEvents = useMemo<Record<string, EchartsEventHandler>>(\n () => ({\n click: handleClick,\n brushSelected: handleBrushSelected,\n brushEnd: handleBrushEnd,\n }),\n [handleClick, handleBrushSelected, handleBrushEnd],\n )\n\n const wiringSelection = useMemo(\n () => (selection && selection.length > 0 ? selection : null),\n [selection],\n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B,KAAAA,IAAAnB,EAAA;CAHD,IAAAoB,IAAuBD,GAGeE;CAAA,AAAArB,EAAA,OAAAoB,KAAApB,EAAA,QAAAS,KAG7BY,IAAA;EAAAC,OACEb;EAAWc,eACHL;EAAmBM,UACxBJ;CACZ,GAACpB,EAAA,KAAAoB,GAAApB,EAAA,MAAAS,GAAAT,EAAA,MAAAqB,KAAAA,IAAArB,EAAA;CALH,IAAAJ,IACSyB,GAQTI,IACSxC,KAAaA,EAASyC,SAAU,IAAhCzC,IAAA,MAER0C;CAE8C,OAF9C3B,EAAA,QAAAJ,KAAAI,EAAA,QAAAyB,KAEME,IAAA;EAAA/B;EAAAX,WAAuBwC;CAAgB,GAACzB,EAAA,MAAAJ,GAAAI,EAAA,MAAAyB,GAAAzB,EAAA,MAAA2B,KAAAA,IAAA3B,EAAA,KAAxC2B;AAAwC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formula-Cqj84ZGX.js","names":["Chip","ChipProps","DeltaSeverity","DeltaProps","value","label","severity","format","defaultPercentFormatter","Intl","NumberFormat","undefined","style","signDisplay","maximumFractionDigits","SEVERITY_TO_COLOR","Record","positive","negative","neutral","Delta","t0","$","_c","chipProps","resolvedSeverity","inferSeverity","t1","text","t2","t3","Symbol","for","fontWeight","t4","Typography","TypographyProps","ReactNode","NoteProps","children","Note","t0","$","_c","t1","Symbol","for","m","t2","Typography","TypographyProps","ReactNode","PrefixProps","children","Prefix","t0","$","_c","t1","Symbol","for","fontWeight","color","lineHeight","t2","Avatar","AvatarProps","Theme","SeriesProps","name","color","size","Series","t0","$","_c","t1","avatarProps","undefined","t2","charAt","toUpperCase","letter","t3","t4","t5","theme","palette","getContrastText","toCssColor","t6","width","height","fontSize","fontWeight","bgcolor","t7","value","includes","parts","split","cur","p","Record","Typography","TypographyProps","ReactNode","SuffixProps","children","Suffix","t0","$","_c","t1","Symbol","for","fontWeight","color","lineHeight","t2","Typography","TypographyProps","ReactNode","ValueProps","children","color","Value","t0","$","_c","t1","t2","fontWeight","lineHeight","t3","SxProps","Theme","styles","root","display","flexDirection","gap","alignItems","row","body","flex","minWidth","valueRow","delta","alignSelf","flexShrink","Record","Box","Ref","FormulaDataItem","Delta","Note","Prefix","Series","Suffix","Value","styles","FormulaUIProps","items","formatter","value","ref","HTMLDivElement","FormulaUI","t0","$","_c","t1","t2","item","i","series","name","prefix","suffix","row","color","body","valueRow","String","note","delta","label","severity","map","root","useWidgetId","useWidgetShallow","FormulaUI","FormulaWidgetData","FormulaSlice","data","formatter","value","EMPTY_DATA","Object","freeze","formulaSelector","s","Formula","$","_c","id","slice","t0","Box","Skeleton","SxProps","Theme","styles","root","display","gap","alignItems","minHeight","py","block","width","height","Record","FormulaSkeletonProps","count","FormulaSkeleton","t0","$","_c","t1","undefined","t2","Array","from","length","map","_temp","_","i","buildCsvDownloadItem","buildPngDownloadItem","DownloadItem","FormulaWidgetData","FormulaDownloadConfigArgs","filename","getData","getCaptureEl","HTMLElement","pngPixelRatio","pngBackgroundColor","createFormulaDownloadConfig","args","items","push","pixelRatio","backgroundColor","getRows","data","rows","d","series","name","prefix","value","suffix","note","delta"],"sources":["../src/widgets-v2/formula/delta.tsx","../src/widgets-v2/formula/note.tsx","../src/widgets-v2/formula/prefix.tsx","../src/widgets-v2/formula/series.tsx","../src/widgets-v2/formula/suffix.tsx","../src/widgets-v2/formula/value.tsx","../src/widgets-v2/formula/style.ts","../src/widgets-v2/formula/formula-ui.tsx","../src/widgets-v2/formula/formula.tsx","../src/widgets-v2/formula/skeleton.tsx","../src/widgets-v2/formula/download.tsx"],"sourcesContent":["import { Chip, type ChipProps } from '@mui/material'\nimport type { DeltaSeverity } from './types'\n\nexport interface DeltaProps {\n /** Numeric magnitude. Used for the default percent label and severity inference. */\n value: number\n /** Pre-formatted label override; skips the default percent formatter. */\n label?: string\n /**\n * Visual treatment. When omitted it's derived from the sign of `value`:\n * `>0 → 'positive'`, `<0 → 'negative'`, `=0 → 'neutral'`.\n */\n severity?: DeltaSeverity\n /** Override the default `Intl.NumberFormat({style:'percent'})` formatter. */\n format?: (value: number) => string\n ChipProps?: ChipProps\n}\n\nconst defaultPercentFormatter = new Intl.NumberFormat(undefined, {\n style: 'percent',\n signDisplay: 'always',\n maximumFractionDigits: 1,\n})\n\nconst SEVERITY_TO_COLOR: Record<DeltaSeverity, ChipProps['color']> = {\n positive: 'success',\n negative: 'error',\n neutral: 'default',\n}\n\n/**\n * Comparative delta rendered as a small filled chip. Colour is driven by\n * `severity` (or the sign of `value`); content is `label`, the result of\n * `format(value)`, or the default percent format.\n */\nexport function Delta({\n value,\n label,\n severity,\n format,\n ChipProps: chipProps,\n}: DeltaProps) {\n const resolvedSeverity = severity ?? inferSeverity(value)\n const text =\n label ?? (format ? format(value) : defaultPercentFormatter.format(value))\n return (\n <Chip\n size='small'\n color={SEVERITY_TO_COLOR[resolvedSeverity]}\n label={text}\n sx={{ fontWeight: 600 }}\n {...chipProps}\n />\n )\n}\n\nfunction inferSeverity(value: number): DeltaSeverity {\n if (value > 0) return 'positive'\n if (value < 0) return 'negative'\n return 'neutral'\n}\n","import { Typography, type TypographyProps } from '@mui/material'\nimport type { ReactNode } from 'react'\n\nexport interface NoteProps {\n children: ReactNode\n TypographyProps?: TypographyProps\n}\n\n/**\n * Small subdued caption rendered below a Formula value. Use for short\n * descriptive text (e.g. \"Last 7 days\", \"Excludes refunds\").\n */\nexport function Note({ children, TypographyProps }: NoteProps) {\n return (\n <Typography\n variant='caption'\n component='p'\n color='text.secondary'\n sx={{ m: 0 }}\n {...TypographyProps}\n >\n {children}\n </Typography>\n )\n}\n","import { Typography, type TypographyProps } from '@mui/material'\nimport type { ReactNode } from 'react'\n\nexport interface PrefixProps {\n children: ReactNode\n TypographyProps?: TypographyProps\n}\n\n/**\n * Prefix slot for a Formula KPI — large, bold, muted (`text.secondary`).\n * Composable building block for custom formula layouts; the canonical\n * {@link FormulaUI} renders one of these per item when `prefix` is set.\n */\nexport function Prefix({ children, TypographyProps }: PrefixProps) {\n return (\n <Typography\n variant='h5'\n component='span'\n sx={{ fontWeight: 600, color: 'text.secondary', lineHeight: 1 }}\n {...TypographyProps}\n >\n {children}\n </Typography>\n )\n}\n","import { Avatar, type AvatarProps, type Theme } from '@mui/material'\n\nexport interface SeriesProps {\n /** Used for the avatar's first-letter glyph and as accessible label. */\n name: string\n /** Avatar background colour (any MUI palette path or CSS colour). */\n color?: string\n /** Diameter in px. Default `24`. */\n size?: number\n AvatarProps?: AvatarProps\n}\n\n/**\n * Series indicator — circular avatar showing the first letter of `name`.\n * Background colour is `color` (consumer-supplied) or a neutral disabled\n * colour, with text colour computed for contrast against it.\n */\nexport function Series({\n name,\n color,\n size = 24,\n AvatarProps: avatarProps,\n}: SeriesProps) {\n const letter = name.charAt(0).toUpperCase()\n return (\n <Avatar\n aria-label={name}\n sx={{\n width: size,\n height: size,\n fontSize: size * 0.5,\n fontWeight: 600,\n bgcolor: color ?? 'action.disabledBackground',\n color: color\n ? (theme: Theme) =>\n theme.palette.getContrastText(toCssColor(theme, color))\n : 'text.primary',\n }}\n {...avatarProps}\n >\n {letter}\n </Avatar>\n )\n}\n\n/**\n * Resolve a palette path (e.g. `\"primary.main\"`) to a hex/rgb string so that\n * `getContrastText` — which doesn't accept dotted paths — produces a sensible\n * text colour. Non-palette strings (raw `#hex`, `rgb(...)`) pass through.\n */\nfunction toCssColor(theme: Theme, value: string): string {\n if (!value.includes('.')) return value\n const parts = value.split('.')\n let cur: unknown = theme.palette\n for (const p of parts) {\n if (\n cur &&\n typeof cur === 'object' &&\n p in (cur as Record<string, unknown>)\n ) {\n cur = (cur as Record<string, unknown>)[p]\n } else {\n return value\n }\n }\n return typeof cur === 'string' ? cur : value\n}\n","import { Typography, type TypographyProps } from '@mui/material'\nimport type { ReactNode } from 'react'\n\nexport interface SuffixProps {\n children: ReactNode\n TypographyProps?: TypographyProps\n}\n\n/**\n * Suffix slot for a Formula KPI — large, bold, muted (`text.secondary`).\n * Composable building block for custom formula layouts; the canonical\n * {@link FormulaUI} renders one of these per item when `suffix` is set.\n */\nexport function Suffix({ children, TypographyProps }: SuffixProps) {\n return (\n <Typography\n variant='h5'\n component='span'\n sx={{ fontWeight: 600, color: 'text.secondary', lineHeight: 1 }}\n {...TypographyProps}\n >\n {children}\n </Typography>\n )\n}\n","import { Typography, type TypographyProps } from '@mui/material'\nimport type { ReactNode } from 'react'\n\nexport interface ValueProps {\n children: ReactNode\n /** Override the default `text.primary` color — useful for sparkline tints. */\n color?: string\n TypographyProps?: TypographyProps\n}\n\n/**\n * Value slot for a Formula KPI — large, bold, primary text color. Composable\n * building block for custom formula layouts; the canonical {@link FormulaUI}\n * renders one of these per item.\n */\nexport function Value({ children, color, TypographyProps }: ValueProps) {\n return (\n <Typography\n variant='h5'\n component='span'\n sx={{\n fontWeight: 600,\n color: color ?? 'text.primary',\n lineHeight: 1,\n }}\n {...TypographyProps}\n >\n {children}\n </Typography>\n )\n}\n","import type { SxProps, Theme } from '@mui/material'\n\nexport const styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n alignItems: 'stretch',\n },\n row: {\n display: 'flex',\n alignItems: 'flex-start',\n gap: 1.5,\n },\n body: {\n flex: 1,\n minWidth: 0,\n display: 'flex',\n flexDirection: 'column',\n gap: 0.25,\n },\n valueRow: {\n display: 'inline-flex',\n alignItems: 'baseline',\n gap: 0.25,\n },\n delta: {\n alignSelf: 'center',\n flexShrink: 0,\n },\n} satisfies Record<string, SxProps<Theme>>\n","import { Box } from '@mui/material'\nimport type { Ref } from 'react'\nimport type { FormulaDataItem } from './types'\nimport { Delta } from './delta'\nimport { Note } from './note'\nimport { Prefix } from './prefix'\nimport { Series } from './series'\nimport { Suffix } from './suffix'\nimport { Value } from './value'\nimport { styles } from './style'\n\nexport interface FormulaUIProps {\n items: readonly FormulaDataItem[]\n /** Number formatter — applied to each item's `value`. */\n formatter?: (value: number) => string\n /** Forwarded to the root `<Box>` so consumers can capture the DOM (PNG export). */\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * Pure presentational component for the Formula widget. Each item renders as\n * a row containing (in order): optional `Series` avatar, a body with\n * `[prefix] value [suffix]` plus optional `Note`, and an optional `Delta`\n * chip pushed to the right edge.\n *\n * For fully custom layouts, compose {@link Series}, {@link Prefix},\n * {@link Value}, {@link Suffix}, {@link Note}, and {@link Delta} directly\n * instead of passing `items`.\n */\nexport function FormulaUI({ items, formatter, ref }: FormulaUIProps) {\n return (\n <Box ref={ref} sx={styles.root}>\n {items.map((item, i) => (\n // Series name is the closest stable id; fall back to the literal\n // value (numeric KPIs rarely repeat with the same prefix/suffix).\n <Box\n key={`formula-${item.series?.name ?? `${item.prefix ?? ''}${item.value}${item.suffix ?? ''}`}-${i}`}\n sx={styles.row}\n >\n {item.series ? (\n <Series name={item.series.name} color={item.series.color} />\n ) : null}\n <Box sx={styles.body}>\n <Box sx={styles.valueRow}>\n {item.prefix ? <Prefix>{item.prefix}</Prefix> : null}\n <Value color={item.color}>\n {formatter ? formatter(item.value) : String(item.value)}\n </Value>\n {item.suffix ? <Suffix>{item.suffix}</Suffix> : null}\n </Box>\n {item.note ? <Note>{item.note}</Note> : null}\n </Box>\n {item.delta ? (\n <Box sx={styles.delta}>\n <Delta\n value={item.delta.value}\n label={item.delta.label}\n severity={item.delta.severity}\n />\n </Box>\n ) : null}\n </Box>\n ))}\n </Box>\n )\n}\n","import { useWidgetId, useWidgetShallow } from '../stores'\nimport { FormulaUI } from './formula-ui'\nimport type { FormulaWidgetData } from './types'\n\ninterface FormulaSlice {\n data: FormulaWidgetData\n formatter?: (value: number) => string\n}\n\n// Stable empty-data sentinel — keeps the slice's `data` reference stable\n// when the underlying store value is null/undefined so the shallow-equality\n// gate in `useWidgetShallow` doesn't re-render every commit.\nconst EMPTY_DATA: FormulaWidgetData = Object.freeze([]) as FormulaWidgetData\n\nconst formulaSelector = (s: {\n data: unknown\n formatter?: (value: number) => string\n}): FormulaSlice => ({\n data: (s.data ?? EMPTY_DATA) as FormulaWidgetData,\n formatter: s.formatter,\n})\n\n/**\n * Stateful Formula bridge — reads `data` (post-pipeline) and `formatter` from\n * the per-widget store and forwards them to the pure {@link FormulaUI}. Sits\n * inside `<Widget.Provider>`. Demonstrates that the composition shell\n * (Provider, Wrapper, State) doesn't care whether the rendered child is\n * ECharts (Bar) or a custom DOM tree (Formula).\n */\nexport function Formula() {\n const id = useWidgetId()\n const slice = useWidgetShallow(id, formulaSelector)\n return <FormulaUI items={slice.data} formatter={slice.formatter} />\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n root: {\n display: 'flex',\n gap: 3,\n alignItems: 'baseline',\n minHeight: 64,\n py: 1,\n },\n block: { width: 120, height: 36 },\n} satisfies Record<string, SxProps<Theme>>\n\nexport interface FormulaSkeletonProps {\n count?: number\n}\n\nexport function FormulaSkeleton({ count = 1 }: FormulaSkeletonProps) {\n return (\n <Box sx={styles.root}>\n {Array.from({ length: count }).map((_, i) => (\n <Skeleton key={`row-${i}`} variant='rectangular' sx={styles.block} />\n ))}\n </Box>\n )\n}\n","import {\n buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadItem,\n} from '../actions/download'\nimport type { FormulaWidgetData } from './types'\n\nexport interface FormulaDownloadConfigArgs {\n filename: string\n getData: () => FormulaWidgetData\n /**\n * Optional getter for the widget's capture element (registered by\n * `Widget.State`). When provided, a PNG item is prepended.\n */\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}\n\n/**\n * Builds download items for the Formula widget. Always includes a CSV item\n * with one row per KPI (`prefix`, `value`, `suffix`, `note`, `delta`).\n * When `getCaptureEl` is supplied, prepends a PNG item that rasterises the\n * captured element via `html2canvas`.\n */\nexport function createFormulaDownloadConfig(\n args: FormulaDownloadConfigArgs,\n): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push(\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: () => {\n const data = args.getData()\n const rows: unknown[][] = [\n ['series', 'prefix', 'value', 'suffix', 'note', 'delta'],\n ]\n for (const d of data) {\n rows.push([\n d.series?.name ?? '',\n d.prefix ?? '',\n d.value,\n d.suffix ?? '',\n d.note ?? '',\n d.delta?.value ?? '',\n ])\n }\n return rows\n },\n }),\n )\n return items\n}\n"],"mappings":";;;;;;AAkBA,IAAMQ,IAA0B,IAAIC,KAAKC,aAAaC,KAAAA,GAAW;CAC/DC,OAAO;CACPC,aAAa;CACbC,uBAAuB;AACzB,CAAC,GAEKC,IAA+D;CACnEE,UAAU;CACVC,UAAU;CACVC,SAAS;AACX;AAOA,SAAOC,EAAAC,GAAA;CAAA,IAAAC,IAAAC,EAAA,CAAA,GAAe,EAAAnB,UAAAC,UAAAC,aAAAC,WAAAN,WAAAuB,MAAAH,GAOpBI,IAAyBnB,KAAYoB,EAActB,CAAK,GAACuB;CAAA,AAAAL,EAAA,OAAAf,KAAAe,EAAA,OAAAjB,KAAAiB,EAAA,OAAAlB,KAEvDuB,IAAAtB,MAAUE,IAASA,EAAOH,CAA6C,IAApCI,EAAuBD,OAAQH,CAAK,IAAEkB,EAAA,KAAAf,GAAAe,EAAA,KAAAjB,GAAAiB,EAAA,KAAAlB,GAAAkB,EAAA,KAAAK,KAAAA,IAAAL,EAAA;CAD3E,IAAAM,IACED,GAISE,IAAAd,EAAkBU,IAAiBK;CAAA,AAAAR,EAAA,OAAAS,OAAAC,IAAA,2BAAA,KAEtCF,IAAA,EAAAG,YAAc,IAAI,GAACX,EAAA,KAAAQ,KAAAA,IAAAR,EAAA;CAAA,IAAAY;CAEvB,OAFuBZ,EAAA,OAAAE,KAAAF,EAAA,OAAAO,KAAAP,EAAA,OAAAM,KAJzBM,IAAA,kBAAC,GAAD;EACO,MAAA;EACE,OAAAL;EACAD,O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C,QAAQ;IAClBF,EAAEG,UAAU;IACZH,EAAEI;IACFJ,EAAEK,UAAU;IACZL,EAAEM,QAAQ;IACVN,EAAEO,OAAOH,SAAS;GAAE,CACrB;GAEH,OAAOL;EACT;CACF,CAAC,CACH,GACON;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-CV_KP-at.js","names":["SxProps","Theme","styles","root","color","bgcolor","px","borderRadius","fontFamily","fontSize","p","overflowX","borderLeft","borderColor","pl","ml","fontStyle","my","border","borderTop","borderCollapse","width","py","textAlign","paragraph","heading","mt","mb","fontWeight","Record","Box","Typography","TypographyProps","Components","MarkdownContent","styles","MarkdownUIProps","content","components","h1","props","mdHeading","h2","h3","h4","h5","h6","p","children","paragraph","React","ReactNode","variant","heading","MarkdownUI","t0","$","_c","t1","root","useWidgetId","useWidget","MarkdownUI","MarkdownWidgetData","Markdown","$","_c","id","content","_temp","t0","s","data","Box","Skeleton","SxProps","Theme","styles","root","display","flexDirection","gap","py","line","width","height","const","MarkdownSkeletonProps","lines","MarkdownSkeleton","t0","$","_c","t1","undefined","t2","widths","Array","from","length","map","_","i","DOWNLOAD_ITEM_IDS","MarkdownIcon","buildPngDownloadItem","toCsvString","triggerLinkDownload","DownloadItem","MarkdownWidgetData","createMarkdownDownloadConfig","args","filename","getData","getCaptureEl","HTMLElement","pngPixelRatio","pngBackgroundColor","items","push","pixelRatio","backgroundColor","id","markdown","label","icon","resolve","data","blob","Blob","content","type","url","URL","createObjectURL","Promise","revoke","revokeObjectURL"],"sources":["../src/widgets-v2/markdown/style.ts","../src/widgets-v2/markdown/markdown-ui.tsx","../src/widgets-v2/markdown/markdown.tsx","../src/widgets-v2/markdown/skeleton.tsx","../src/widgets-v2/markdown/download.tsx"],"sourcesContent":["import type { SxProps, Theme } from '@mui/material'\n\nexport const styles = {\n root: {\n color: 'text.primary',\n '& a': { color: 'primary.main' },\n '& code': {\n bgcolor: 'action.hover',\n px: 0.5,\n borderRadius: 0.5,\n fontFamily: 'monospace',\n fontSize: '0.875em',\n },\n '& pre': {\n bgcolor: 'action.hover',\n p: 1.5,\n borderRadius: 1,\n overflowX: 'auto',\n },\n '& blockquote': {\n borderLeft: '3px solid',\n borderColor: 'divider',\n pl: 1.5,\n ml: 0,\n color: 'text.secondary',\n fontStyle: 'italic',\n },\n '& ul, & ol': { pl: 3, my: 1 },\n '& li': { my: 0.25 },\n '& hr': {\n border: 'none',\n borderTop: '1px solid',\n borderColor: 'divider',\n my: 1.5,\n },\n '& table': { borderCollapse: 'collapse', width: '100%' },\n '& th, & td': {\n border: '1px solid',\n borderColor: 'divider',\n px: 1,\n py: 0.5,\n textAlign: 'left',\n },\n },\n paragraph: {\n my: 1,\n },\n heading: {\n mt: 2,\n mb: 1,\n fontWeight: 600,\n },\n} satisfies Record<string, SxProps<Theme>>\n","import { Box, Typography, type TypographyProps } from '@mui/material'\nimport type { Components } from 'react-markdown'\nimport { MarkdownContent } from './markdown-content'\nimport { styles } from './style'\n\nexport interface MarkdownUIProps {\n content: string\n}\n\n/** MUI-styled element mapping for `react-markdown`. */\nconst components: Components = {\n h1: (props) => mdHeading(props, 'h4'),\n h2: (props) => mdHeading(props, 'h5'),\n h3: (props) => mdHeading(props, 'h6'),\n h4: (props) => mdHeading(props, 'subtitle1'),\n h5: (props) => mdHeading(props, 'subtitle2'),\n h6: (props) => mdHeading(props, 'subtitle2'),\n p: ({ children }) => (\n <Typography variant='body2' component='p' sx={styles.paragraph}>\n {children}\n </Typography>\n ),\n}\n\nfunction mdHeading(\n props: { children?: React.ReactNode },\n variant: TypographyProps['variant'],\n) {\n return (\n <Typography variant={variant} component='div' sx={styles.heading}>\n {props.children}\n </Typography>\n )\n}\n\n/**\n * Pure presentational component for the Markdown widget. Delegates the\n * `react-markdown` engine to {@link MarkdownContent} and supplies a\n * document-style MUI element mapping (body2 paragraphs, real heading\n * typography). Opts INTO raw HTML and inline images — the Markdown widget is\n * the one slot in the library where authors can ship rich content. Caption\n * slots like `Note` keep the conservative defaults.\n */\nexport function MarkdownUI({ content }: MarkdownUIProps) {\n return (\n <Box sx={styles.root}>\n <MarkdownContent\n content={content}\n components={components}\n allowHtml\n allowImages\n />\n </Box>\n )\n}\n","import { useWidgetId, useWidget } from '../stores'\nimport { MarkdownUI } from './markdown-ui'\nimport type { MarkdownWidgetData } from './types'\n\n/**\n * Stateful Markdown bridge — reads `data.content` (post-pipeline) from the\n * per-widget store and forwards it to the pure {@link MarkdownUI}. Sits\n * inside `<Widget.Provider>`.\n */\nexport function Markdown() {\n const id = useWidgetId()\n const content = useWidget(id, (s) => {\n const data = s.data as MarkdownWidgetData | undefined\n return data?.content ?? ''\n })\n return <MarkdownUI content={content} />\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 1,\n py: 1,\n },\n line: (width: string): SxProps<Theme> => ({ width, height: 18 }),\n} as const\n\nexport interface MarkdownSkeletonProps {\n lines?: number\n}\n\nexport function MarkdownSkeleton({ lines = 5 }: MarkdownSkeletonProps) {\n // Vary widths to mimic prose.\n const widths = ['100%', '95%', '90%', '85%', '70%']\n return (\n <Box sx={styles.root}>\n {Array.from({ length: lines }).map((_, i) => (\n <Skeleton\n key={`line-${i}`}\n variant='rectangular'\n sx={styles.line(widths[i % widths.length] ?? '85%')}\n />\n ))}\n </Box>\n )\n}\n","import {\n DOWNLOAD_ITEM_IDS,\n MarkdownIcon,\n buildPngDownloadItem,\n toCsvString,\n triggerLinkDownload,\n type DownloadItem,\n} from '../actions/download'\nimport type { MarkdownWidgetData } from './types'\n\n/**\n * Download menu items for the Markdown widget. Always includes a `.md`\n * item that saves the markdown source verbatim. When `getCaptureEl` is\n * supplied, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createMarkdownDownloadConfig(args: {\n filename: string\n getData: () => MarkdownWidgetData\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: DOWNLOAD_ITEM_IDS.markdown,\n label: 'Markdown',\n icon: <MarkdownIcon fontSize='small' />,\n resolve: () => {\n const data = args.getData()\n const blob = new Blob([data.content ?? ''], {\n type: 'text/markdown;charset=utf-8;',\n })\n const url = URL.createObjectURL(blob)\n return Promise.resolve({\n url,\n filename: `${args.filename}.md`,\n revoke: () => URL.revokeObjectURL(url),\n })\n },\n })\n return items\n}\n\n// Re-export pure helpers consumers may want when building a custom Download item.\nexport { toCsvString, triggerLinkDownload }\n"],"mappings":";;;;;;;AAEA,IAAaE,IAAS;CACpBC,MAAM;EACJC,OAAO;EACP,OAAO,EAAEA,OAAO,eAAe;EAC/B,UAAU;GACRC,SAAS;GACTC,IAAI;GACJC,cAAc;GACdC,YAAY;GACZC,UAAU;EACZ;EACA,SAAS;GACPJ,SAAS;GACTK,GAAG;GACHH,cAAc;GACdI,WAAW;EACb;EACA,gBAAgB;GACdC,YAAY;GACZC,aAAa;GACbC,IAAI;GACJC,IAAI;GACJX,OAAO;GACPY,WAAW;EACb;EACA,cAAc;GAAEF,IAAI;GAAGG,IAAI;EAAE;EAC7B,QAAQ,EAAEA,IAAI,IAAK;EACnB,QAAQ;GACNC,QAAQ;GACRC,WAAW;GACXN,aAAa;GACbI,IAAI;EACN;EACA,WAAW;GAAEG,gBAAgB;GAAYC,OAAO;EAAO;EACvD,cAAc;GACZH,QAAQ;GACRL,aAAa;GACbP,IAAI;GACJgB,IAAI;GACJC,WAAW;EACb;CACF;CACAC,WAAW,EACTP,IAAI,EACN;CACAQ,SAAS;EACPC,IAAI;EACJC,IAAI;EACJC,YAAY;CACd;AACF,GC1CMU,IAAyB;CAC7BC,KAAKC,MAA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AcH,IAAII,gBAAgBL,CAAG;GACvC,CAAC;EACH;CACF,CAAC,GACMd;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spread-C8T12Nfh.js","names":["Value","Separator","$","_c","t0","Symbol","for","Box","Ref","Note","Prefix","Series","Suffix","Value","styles","Separator","SpreadDataItem","SpreadUIProps","items","formatter","value","ref","HTMLDivElement","SpreadUI","t0","$","_c","fmt","_temp","t1","t2","item","i","series","name","min","max","row","color","body","valueRow","prefix","suffix","note","map","root","n","String","useWidgetId","useWidgetShallow","SpreadUI","SpreadWidgetData","SpreadSlice","data","formatter","value","EMPTY_DATA","Object","freeze","spreadSelector","s","Spread","$","_c","id","slice","t0","Box","Skeleton","SxProps","Theme","styles","root","display","flexDirection","gap","py","row","alignItems","block","width","height","Record","SpreadSkeletonProps","count","SpreadSkeleton","t0","$","_c","t1","undefined","t2","Array","from","length","map","_temp","_","i","buildCsvDownloadItem","buildPngDownloadItem","DownloadItem","SpreadWidgetData","createSpreadDownloadConfig","args","filename","getData","getCaptureEl","HTMLElement","pngPixelRatio","pngBackgroundColor","items","push","pixelRatio","backgroundColor","getRows","data","rows","item","series","name","prefix","min","max","suffix","note","SpreadVariant","GetSpreadBandOptions","value","spread","variant","getSpreadBand","min","max","offset","width","Math","abs"],"sources":["../src/widgets-v2/spread/separator.tsx","../src/widgets-v2/spread/spread-ui.tsx","../src/widgets-v2/spread/spread.tsx","../src/widgets-v2/spread/skeleton.tsx","../src/widgets-v2/spread/download.ts","../src/widgets-v2/spread/band.ts"],"sourcesContent":["import { Value } from '../formula'\n\n/**\n * Em-dash separator placed between a Spread row's `min` and `max` values.\n * Built from the Formula {@link Value} primitive so typography (h5/600,\n * baseline alignment) matches the numbers around it. Renders with\n * `text.secondary` so it visually recedes between the two bounds.\n */\nexport function Separator() {\n return <Value color='inherit'>-</Value>\n}\n","import { Box } from '@mui/material'\nimport type { Ref } from 'react'\nimport { Note, Prefix, Series, Suffix, Value } from '../formula'\nimport { styles } from '../formula/style'\nimport { Separator } from './separator'\nimport type { SpreadDataItem } from './types'\n\nexport interface SpreadUIProps {\n items: readonly SpreadDataItem[]\n /** Number formatter — applied to each item's `min` and `max`. */\n formatter?: (value: number) => string\n /** Forwarded to the root `<Box>` so consumers can capture the DOM (PNG export). */\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * Pure presentational component for the Spread widget. Each item renders as\n * a row containing (in order): optional `Series` avatar, a body with\n * `[prefix] min — max [suffix]` plus optional `Note`. Reuses the Formula\n * primitives ({@link Series}, {@link Prefix}, {@link Value}, {@link Suffix},\n * {@link Note}) and the Formula row styles so Spread and Formula stay\n * visually aligned when used together.\n */\nexport function SpreadUI({ items, formatter, ref }: SpreadUIProps) {\n const fmt = formatter ?? ((n: number) => String(n))\n return (\n <Box ref={ref} sx={styles.root}>\n {items.map((item, i) => (\n // Composite of series name + min/max bounds for stability across\n // reorders; falls back to the index when bounds happen to collide.\n <Box\n key={`spread-${item.series?.name ?? ''}-${item.min}-${item.max}-${i}`}\n sx={styles.row}\n >\n {item.series ? (\n <Series name={item.series.name} color={item.series.color} />\n ) : null}\n <Box sx={styles.body}>\n <Box sx={styles.valueRow}>\n {item.prefix ? <Prefix>{item.prefix}</Prefix> : null}\n <Value color={item.color}>{fmt(item.min)}</Value>\n <Separator />\n <Value color={item.color}>{fmt(item.max)}</Value>\n {item.suffix ? <Suffix>{item.suffix}</Suffix> : null}\n </Box>\n {item.note ? <Note>{item.note}</Note> : null}\n </Box>\n </Box>\n ))}\n </Box>\n )\n}\n","import { useWidgetId, useWidgetShallow } from '../stores'\nimport { SpreadUI } from './spread-ui'\nimport type { SpreadWidgetData } from './types'\n\ninterface SpreadSlice {\n data: SpreadWidgetData\n formatter?: (value: number) => string\n}\n\n// Stable empty-data sentinel — keeps the slice's `data` reference stable\n// when the underlying store value is null/undefined so the shallow-equality\n// gate in `useWidgetShallow` doesn't re-render every commit.\nconst EMPTY_DATA: SpreadWidgetData = Object.freeze([]) as SpreadWidgetData\n\nconst spreadSelector = (s: {\n data: unknown\n formatter?: (value: number) => string\n}): SpreadSlice => ({\n data: (s.data ?? EMPTY_DATA) as SpreadWidgetData,\n formatter: s.formatter,\n})\n\n/**\n * Stateful Spread bridge — reads `data` (post-pipeline) and `formatter` from\n * the per-widget store and forwards them to the pure {@link SpreadUI}.\n */\nexport function Spread() {\n const id = useWidgetId()\n const slice = useWidgetShallow(id, spreadSelector)\n return <SpreadUI items={slice.data} formatter={slice.formatter} />\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n py: 1,\n },\n row: {\n display: 'flex',\n alignItems: 'center',\n gap: 1.5,\n },\n block: { width: 200, height: 32 },\n} satisfies Record<string, SxProps<Theme>>\n\nexport interface SpreadSkeletonProps {\n count?: number\n}\n\n/**\n * Loading placeholder for the Spread widget. Renders `count` rows, each\n * sized for the `min — max` pair so the layout doesn't jump once data\n * resolves. Mirrors the row-per-item structure of {@link SpreadUI}.\n */\nexport function SpreadSkeleton({ count = 1 }: SpreadSkeletonProps) {\n return (\n <Box sx={styles.root}>\n {Array.from({ length: count }).map((_, i) => (\n <Box key={`row-${i}`} sx={styles.row}>\n <Skeleton variant='rectangular' sx={styles.block} />\n </Box>\n ))}\n </Box>\n )\n}\n","import {\n buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadItem,\n} from '../actions/download'\nimport type { SpreadWidgetData } from './types'\n\n/**\n * Download menu items for the Spread widget. Always includes a CSV item\n * with `series, prefix, min, max, suffix, note` columns (one row per\n * entry). When `getCaptureEl` is supplied, prepends a PNG item that\n * rasterises the captured element via `html2canvas`.\n */\nexport function createSpreadDownloadConfig(args: {\n filename: string\n getData: () => SpreadWidgetData\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push(\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: () => {\n const data = args.getData()\n const rows: unknown[][] = [\n ['series', 'prefix', 'min', 'max', 'suffix', 'note'],\n ]\n for (const item of data) {\n rows.push([\n item.series?.name ?? '',\n item.prefix ?? '',\n item.min,\n item.max,\n item.suffix ?? '',\n item.note ?? '',\n ])\n }\n return rows\n },\n }),\n )\n return items\n}\n","/**\n * How a `spread` amount is applied to a centre value.\n *\n * - `percentage` — `spread` is a whole-number percentage of the centre\n * value, so `5` means +/-5%.\n * - `absolute` — `spread` is a raw offset in the value's own units.\n */\nexport type SpreadVariant = 'percentage' | 'absolute'\n\nexport interface GetSpreadBandOptions {\n /** The centre value the band is drawn around. */\n value: number\n /** Half-width of the band, read according to `variant`. */\n spread: number\n /** Defaults to `percentage`. */\n variant?: SpreadVariant\n}\n\n/**\n * Derives the `min` / `max` band around a centre value, for feeding a\n * {@link SpreadDataItem} from a single aggregated number (a prediction, a\n * target) plus a tolerance — rather than from a real column range.\n *\n * `spread` is read as a percentage by default, which is what a tolerance\n * almost always is: an absolute offset is meaningless without knowing the\n * value's magnitude, and gets visually lost on large values (+/-5 on a\n * prediction of 204,113 renders as a range indistinguishable from a single\n * number).\n *\n * @example\n * getSpreadBand({ value: 1000, spread: 5 })\n * // -> { min: 950, max: 1050 }\n * getSpreadBand({ value: 1000, spread: 5, variant: 'absolute' })\n * // -> { min: 995, max: 1005 }\n */\nexport function getSpreadBand({\n value,\n spread,\n variant = 'percentage',\n}: GetSpreadBandOptions): { min: number; max: number } {\n const offset = variant === 'absolute' ? spread : (spread / 100) * value\n // Keep `min <= max`: a percentage of a negative centre value (or a negative\n // `spread`) yields a negative offset, which would invert the band.\n const width = Math.abs(offset)\n\n return { min: value - width, max: value + width }\n}\n"],"mappings":";;;;;;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