@carto/ps-react-ui 6.0.0 → 6.1.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-BWlS5tpP.js +1150 -0
- package/dist/actions-BWlS5tpP.js.map +1 -0
- package/dist/category-alzjKzvQ.js +839 -0
- package/dist/category-alzjKzvQ.js.map +1 -0
- package/dist/{download-Vlzn2jzb.js → download-B4sykOFm.js} +94 -83
- package/dist/download-B4sykOFm.js.map +1 -0
- package/dist/{echart-DjcbtKgi.js → echart-CV8F50gn.js} +6 -5
- package/dist/echart-CV8F50gn.js.map +1 -0
- package/dist/{formula-CdHWtepq.js → formula-DJS-JLpk.js} +10 -16
- package/dist/{formula-CdHWtepq.js.map → formula-DJS-JLpk.js.map} +1 -1
- package/dist/legend.js +34 -21
- package/dist/legend.js.map +1 -1
- package/dist/{markdown-CY-67NRE.js → markdown-Bn2nKCbn.js} +12 -18
- package/dist/{markdown-CY-67NRE.js.map → markdown-Bn2nKCbn.js.map} +1 -1
- package/dist/{range-DHQSsl2_.js → range-BpU2zBmq.js} +2 -2
- package/dist/{range-DHQSsl2_.js.map → range-BpU2zBmq.js.map} +1 -1
- package/dist/{spread-DuM5oTI1.js → spread-CQwFIwuz.js} +10 -16
- package/dist/{spread-DuM5oTI1.js.map → spread-CQwFIwuz.js.map} +1 -1
- package/dist/{stores-B8CHbgw-.js → stores-DcBOZlU3.js} +30 -24
- package/dist/stores-DcBOZlU3.js.map +1 -0
- package/dist/{table-BE4uO9pp.js → table-DEdW_fDj.js} +7 -13
- package/dist/{table-BE4uO9pp.js.map → table-DEdW_fDj.js.map} +1 -1
- package/dist/types/legend/stores/types.d.ts +4 -2
- package/dist/types/widgets/actions/download/csv-item.d.ts +3 -3
- package/dist/types/widgets/actions/download/index.d.ts +2 -1
- package/dist/types/widgets/actions/download/png-item.d.ts +2 -2
- package/dist/types/widgets/actions/download/types.d.ts +12 -1
- package/dist/types/widgets/actions/download/widget-download.d.ts +26 -0
- package/dist/types/widgets/actions/fullscreen/fullscreen.d.ts +20 -13
- package/dist/types/widgets/actions/index.d.ts +1 -1
- package/dist/types/widgets/actions/searcher/filter.d.ts +3 -2
- package/dist/types/widgets/actions/searcher/searcher-toggle.d.ts +3 -0
- package/dist/types/widgets/bar/download.d.ts +6 -20
- package/dist/types/widgets/category/category-ui.d.ts +9 -1
- package/dist/types/widgets/category/download.d.ts +5 -10
- package/dist/types/widgets/category/helpers.d.ts +10 -0
- package/dist/types/widgets/echart/style.d.ts +1 -0
- package/dist/types/widgets/formula/download.d.ts +5 -15
- package/dist/types/widgets/histogram/download.d.ts +3 -8
- package/dist/types/widgets/index.d.ts +1 -1
- package/dist/types/widgets/markdown/download.d.ts +5 -11
- package/dist/types/widgets/pie/download.d.ts +3 -8
- package/dist/types/widgets/scatterplot/download.d.ts +6 -11
- package/dist/types/widgets/spread/download.d.ts +6 -12
- package/dist/types/widgets/stores/index.d.ts +1 -1
- package/dist/types/widgets/stores/widget-store-registry.d.ts +14 -0
- package/dist/types/widgets/table/download.d.ts +7 -13
- package/dist/types/widgets/timeseries/download.d.ts +7 -12
- package/dist/types/widgets/toolbox/toolbox.d.ts +1 -1
- package/dist/{utils-BStJWhZN.js → utils-C-eWwOhE.js} +2 -2
- package/dist/{utils-BStJWhZN.js.map → utils-C-eWwOhE.js.map} +1 -1
- package/dist/widgets/actions.js +4 -4
- package/dist/widgets/bar.js +11 -17
- package/dist/widgets/bar.js.map +1 -1
- package/dist/widgets/category.js +1 -1
- package/dist/widgets/echart.js +1 -1
- package/dist/widgets/formula.js +1 -1
- package/dist/widgets/histogram.js +14 -20
- package/dist/widgets/histogram.js.map +1 -1
- package/dist/widgets/markdown.js +1 -1
- package/dist/widgets/pie.js +13 -19
- package/dist/widgets/pie.js.map +1 -1
- package/dist/widgets/range.js +1 -1
- package/dist/widgets/scatterplot.js +13 -19
- package/dist/widgets/scatterplot.js.map +1 -1
- package/dist/widgets/spread.js +1 -1
- package/dist/widgets/stores.js +2 -2
- package/dist/widgets/table.js +1 -1
- package/dist/widgets/timeseries.js +16 -22
- package/dist/widgets/timeseries.js.map +1 -1
- package/dist/widgets/utils.js +1 -1
- package/dist/widgets.js +274 -333
- package/dist/widgets.js.map +1 -1
- package/dist/{zoom-toggle-D_VuA01l.js → zoom-toggle-MmLjMTEw.js} +2 -2
- package/dist/{zoom-toggle-D_VuA01l.js.map → zoom-toggle-MmLjMTEw.js.map} +1 -1
- package/package.json +1 -1
- package/src/legend/components/legend-item/legend-item-ui.test.tsx +22 -1
- package/src/legend/components/legend-ramp/legend-ramp-ui.tsx +22 -6
- package/src/legend/stores/types.ts +4 -2
- package/src/widgets/actions/download/csv-item.test.tsx +3 -3
- package/src/widgets/actions/download/csv-item.tsx +6 -6
- package/src/widgets/actions/download/download.tsx +5 -3
- package/src/widgets/actions/download/index.ts +2 -1
- package/src/widgets/actions/download/png-item.test.tsx +5 -3
- package/src/widgets/actions/download/png-item.tsx +4 -4
- package/src/widgets/actions/download/types.ts +15 -1
- package/src/widgets/actions/download/widget-download.test.ts +30 -0
- package/src/widgets/actions/download/widget-download.ts +41 -0
- package/src/widgets/actions/fullscreen/fullscreen-store.test.tsx +155 -0
- package/src/widgets/actions/fullscreen/fullscreen.test.tsx +39 -41
- package/src/widgets/actions/fullscreen/fullscreen.tsx +198 -96
- package/src/widgets/actions/index.ts +3 -0
- package/src/widgets/actions/searcher/filter.test.ts +28 -0
- package/src/widgets/actions/searcher/filter.ts +22 -4
- package/src/widgets/actions/searcher/searcher-toggle.tsx +16 -8
- package/src/widgets/actions/searcher/searcher.test.tsx +22 -0
- package/src/widgets/actions/searcher/searcher.tsx +17 -7
- package/src/widgets/bar/download.test.tsx +5 -3
- package/src/widgets/bar/download.tsx +11 -35
- package/src/widgets/category/category-ui.tsx +26 -14
- package/src/widgets/category/category.tsx +37 -2
- package/src/widgets/category/components/category-legend.tsx +1 -2
- package/src/widgets/category/download.test.ts +4 -2
- package/src/widgets/category/download.ts +14 -27
- package/src/widgets/category/helpers.test.ts +17 -0
- package/src/widgets/category/helpers.ts +16 -0
- package/src/widgets/echart/style.ts +6 -0
- package/src/widgets/formula/download.test.tsx +3 -1
- package/src/widgets/formula/download.tsx +10 -30
- package/src/widgets/histogram/download.test.ts +6 -4
- package/src/widgets/histogram/download.ts +13 -26
- package/src/widgets/index.ts +1 -0
- package/src/widgets/markdown/download.test.ts +2 -2
- package/src/widgets/markdown/download.tsx +11 -26
- package/src/widgets/pie/download.test.ts +7 -3
- package/src/widgets/pie/download.ts +12 -25
- package/src/widgets/scatterplot/download.test.ts +4 -2
- package/src/widgets/scatterplot/download.ts +15 -28
- package/src/widgets/spread/download.test.ts +3 -1
- package/src/widgets/spread/download.ts +13 -27
- package/src/widgets/stores/index.ts +2 -0
- package/src/widgets/stores/widget-store-registry.test.ts +25 -0
- package/src/widgets/stores/widget-store-registry.ts +22 -0
- package/src/widgets/table/download.test.ts +5 -3
- package/src/widgets/table/download.ts +15 -29
- package/src/widgets/timeseries/download.test.ts +6 -4
- package/src/widgets/timeseries/download.ts +16 -29
- package/src/widgets/toolbox/toolbox.tsx +1 -1
- package/dist/actions-KsX1xdDM.js +0 -1024
- package/dist/actions-KsX1xdDM.js.map +0 -1
- package/dist/category-CsdDqDzo.js +0 -833
- package/dist/category-CsdDqDzo.js.map +0 -1
- package/dist/download-Vlzn2jzb.js.map +0 -1
- package/dist/echart-DjcbtKgi.js.map +0 -1
- package/dist/stores-B8CHbgw-.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download-B4sykOFm.js","names":["Icon = DownloadIcon","{\n items,\n labels,\n icon: Icon = DownloadIcon,\n iconProps,\n onError,\n}: DownloadProps","{ ...DEFAULT_DOWNLOAD_LABELS, ...labels }","(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 }","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 }, [])","() => setAnchorEl(null)","useCallback(() => setAnchorEl(null), [])","(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({ id })\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 }","{ url, filename, revoke }","e","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({ id })\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, id, isDownloading, onError],\n )","isDownloading ? (\n <CircularProgress size={18} color='inherit' />\n ) : (\n <Icon fontSize='small' {...iconProps} />\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>","triggerActive ? 'active' : undefined","anchorEl ? 'true' : undefined","isDownloading || undefined","error ? 'true' : undefined","isDownloading || items.length === 0","<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 vertical: 'bottom',\n horizontal: 'right',\n }","{\n vertical: 'top',\n horizontal: 'right',\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 ))","(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 )","item","<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>","Boolean(anchorEl)","<>\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 </>","<ImageOutlined {...props} />","<ArticleOutlined {...props} />","<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 />","<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>"],"sources":["../src/widgets/actions/download/exports.ts","../src/widgets/actions/download/labels.ts","../src/widgets/actions/download/download.tsx","../src/widgets/actions/download/icons.tsx","../src/widgets/actions/download/constants.ts","../src/widgets/actions/download/png-item.tsx","../src/widgets/actions/download/csv-item.tsx","../src/widgets/actions/download/widget-download.ts"],"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] 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, useContext, 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 { WidgetContext } from '../../stores'\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 id = useContext(WidgetContext)\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({ id })\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, id, 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 { DownloadContext, 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/stores`.\n */\n getCaptureEl: (ctx: DownloadContext) => 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 (ctx) => {\n const el = args.getCaptureEl(ctx)\n if (!el) {\n throw new Error('[widgets] 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 { DownloadContext, 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: (ctx: DownloadContext) => 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: (ctx: DownloadContext) => 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: (ctx) => {\n if (args.getCsv) {\n const csv = args.getCsv(ctx)\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(ctx))\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n }\n}\n","import { buildPngDownloadItem } from './png-item'\nimport type { DownloadContext, DownloadItem } from './types'\n\n/** Arguments every per-widget `create*DownloadConfig` shares. */\nexport interface WidgetDownloadArgs<T> {\n /** Base filename (without extension). */\n filename: string\n /**\n * Reads the data to export at click time. `ctx.id` is the store the menu\n * was opened from — the fullscreen dialog's own while it's open. See\n * `widgetStoreData` in `widgets/stores`.\n */\n getData: (ctx: DownloadContext) => T\n /**\n * Reads the element the PNG item rasterises. When given, a PNG item is\n * prepended to the menu. See `widgetCaptureEl` in `widgets/stores`.\n */\n getCaptureEl?: (ctx: DownloadContext) => HTMLElement | null\n /** PNG `pixelRatio` (default 2). */\n pngPixelRatio?: number\n /** PNG `backgroundColor` (default transparent). */\n pngBackgroundColor?: string | null\n}\n\n/**\n * `items`, with a PNG item in front when `args.getCaptureEl` is given — the\n * order every widget's download menu uses.\n */\nexport function withPngItem(\n args: Omit<WidgetDownloadArgs<unknown>, 'getData'>,\n ...items: DownloadItem[]\n): DownloadItem[] {\n if (!args.getCaptureEl) return items\n const png = buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n })\n return [png, ...items]\n}\n"],"mappings":";;;;;;;;;;AAgBA,IAAM,IAAqB;AAE3B,SAAgB,EAAY,GAA+C;CACzE,IAAM,KAAU,MAA0B;EACxC,IAAI,KAAQ,MAAM,OAAO;EACzB,IAAI,IACF,OAAO,KAAS,WACZ,IACA,OAAO,KAAS,YAAY,OAAO,KAAS,YAC1C,OAAO,CAAI,IACX,KAAK,UAAU,CAAI;EAG3B,OAFI,EAAmB,KAAK,CAAK,MAAG,IAAQ,IAAI,MAC5C,WAAW,KAAK,CAAK,IAAU,IAAI,EAAM,QAAQ,MAAM,MAAI,EAAE,KAC1D;CACT;CACA,OAAO,EAAK,KAAK,MAAQ,EAAI,IAAI,CAAM,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI;AAC/D;AAEA,SAAgB,EACd,GACgB;CAChB,IAAM,IAAM,EAAY,CAAI,GACtB,IAAO,IAAI,KAAK,CAAC,CAAG,GAAG,EAAE,MAAM,0BAA0B,CAAC,GAC1D,IAAM,IAAI,gBAAgB,CAAI;CACpC,OAAO;EAAE;EAAK,cAAc,IAAI,gBAAgB,CAAG;CAAE;AACvD;AAMA,IAAM,IAAwB,uBACxB,IAAsB;AAE5B,SAAgB,EAAiB,GAAsB;CACrD,QACG,KAAQ,GAAA,CACN,QAAQ,GAAuB,GAAG,CAAC,CACnC,MAAM,GAAG,CAAmB,KAAK;AAExC;AAOA,SAAgB,EAAoB,GAG3B;CACP,IAAM,EAAE,QAAK,gBAAa,G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L,KAAK,EAAO;IACZ,UAAU,GAAG,EAAK,SAAS;IAC3B,QAAQ,EAAO;GACjB;EACF;CACF;AACF;;;ACRA,SAAgB,EACd,GACc;CACd,OAAO;EACL,IAAI,EAAkB;EACtB,OAAO,EAAK,SAAS;EACrB,MAAM,kBAAC,GAAD,EAAS,UAAS,QAAS,CAAA;EACjC,UAAU,MAAQ;GAChB,IAAI,EAAK,QAAQ;IACf,IAAM,IAAM,EAAK,OAAO,CAAG,GACrB,IAAO,IAAI,KAAK,CAAC,CAAG,GAAG,EAAE,MAAM,0BAA0B,CAAC,GAC1D,IAAM,IAAI,gBAAgB,CAAI;IACpC,OAAO,QAAQ,QAAQ;KACrB;KACA,UAAU,GAAG,EAAK,SAAS;KAC3B,cAAc,IAAI,gBAAgB,CAAG;IACvC,CAAC;GACH;GACA,IAAM,IAAS,EAAc,EAAK,QAAQ,CAAG,CAAC;GAC9C,OAAO,QAAQ,QAAQ;IACrB,KAAK,EAAO;IACZ,UAAU,GAAG,EAAK,SAAS;IAC3B,QAAQ,EAAO;GACjB,CAAC;EACH;CACF;AACF;;;AC1CA,SAAgB,EACd,GACA,GAAG,GACa;CAQhB,OAPK,EAAK,eAOH,CANK,EAAqB;EAC/B,UAAU,EAAK;EACf,cAAc,EAAK;EACnB,YAAY,EAAK;EACjB,iBAAiB,EAAK;CACxB,CACQ,GAAK,GAAG,CAAK,IAPU;AAQjC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as e, D as t,
|
|
1
|
+
import { C as e, D as t, k as n, v as r } from "./stores-DcBOZlU3.js";
|
|
2
2
|
import { c as i } from "react/compiler-runtime";
|
|
3
3
|
import { useEffect as a, useEffectEvent as o, useRef as s } from "react";
|
|
4
4
|
import { Box as c } from "@mui/material";
|
|
@@ -86,7 +86,8 @@ function E() {
|
|
|
86
86
|
var D = { root: {
|
|
87
87
|
width: "100%",
|
|
88
88
|
flex: 1,
|
|
89
|
-
minHeight: 304
|
|
89
|
+
minHeight: 304,
|
|
90
|
+
isolation: "isolate"
|
|
90
91
|
} }, O = { renderer: "svg" };
|
|
91
92
|
function k(e) {
|
|
92
93
|
let t = i(21), { option: n, replaceMerge: r, onEvents: f, init: p, onInstance: m, className: h, sx: g } = e, _ = s(null), v = s(null), b = s(null), x = s(null), S = s(n), C = s(d), w;
|
|
@@ -182,12 +183,12 @@ var M = ["toolbox"], N = (e) => ({
|
|
|
182
183
|
labelFormatter: e.labelFormatter
|
|
183
184
|
});
|
|
184
185
|
function P(a) {
|
|
185
|
-
let o = i(23), { optionFactory: s, onEvents: c, init: u, className: d, sx: f } = a, p =
|
|
186
|
+
let o = i(23), { optionFactory: s, onEvents: c, init: u, className: d, sx: f } = a, p = t(), m = e(p, N), h;
|
|
186
187
|
o[0] === p ? h = o[1] : (h = (e) => r(p, e), o[0] = p, o[1] = h);
|
|
187
188
|
let g = h, { data: _, configTransforms: v, formatter: y, labelFormatter: b } = m, x;
|
|
188
189
|
o[2] === s ? x = o[3] : (x = s(void 0, void 0), o[2] = s, o[3] = x);
|
|
189
190
|
let S = x, C;
|
|
190
|
-
o[4] !== v || o[5] !== S ? (C =
|
|
191
|
+
o[4] !== v || o[5] !== S ? (C = n(S, v), o[4] = v, o[5] = S, o[6] = C) : C = o[6];
|
|
191
192
|
let w = C, T;
|
|
192
193
|
if (o[7] !== v) {
|
|
193
194
|
let e = new Set(M);
|
|
@@ -246,4 +247,4 @@ function F(e) {
|
|
|
246
247
|
//#endregion
|
|
247
248
|
export { E as a, k as i, P as n, T as o, O as r, F as t };
|
|
248
249
|
|
|
249
|
-
//# sourceMappingURL=echart-
|
|
250
|
+
//# sourceMappingURL=echart-CV8F50gn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"echart-CV8F50gn.js","names":["{\n option,\n replaceMerge,\n onEvents,\n init,\n onInstance,\n className,\n sx,\n}: EchartUIProps","(chart: echarts.ECharts | null): void => {\n onInstance?.(chart)\n }","() => {\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 }","chart","[init]","() => {\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 const node = containerRef.current\n if (!node) return undefined\n return observeResize(node, () => {\n chartRef.current?.resize()\n })\n }","[]","() => {\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]","event","handler","{ ...styles.root, ...sx }","<Box\n ref={containerRef}\n className={className}\n sx={{ ...styles.root, ...sx }}\n />","{\n optionFactory,\n onEvents,\n init,\n className,\n sx,\n}: EchartProps","(chart: echarts.ECharts | null) => setEchartInstance(id, chart)","useCallback(\n (chart: echarts.ECharts | null) => setEchartInstance(id, chart),\n [id],\n )","optionFactory(undefined, undefined)","useMemo(\n () => optionFactory(undefined, undefined),\n [optionFactory],\n )","applyTransforms(structural, configTransforms)","Array.from(keys).sort()","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])","optionFactory(transformed, sliceData, {\n formatter: sliceFormatter,\n labelFormatter: sliceLabelFormatter,\n })","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 )","<EchartUI\n option={option}\n replaceMerge={replaceMerge}\n onEvents={onEvents}\n init={init}\n onInstance={onInstance}\n className={className}\n sx={sx}\n />","{\n selection,\n onSelectionChange,\n keyFromClick,\n keysFromBrush,\n}: UseChartSelectionOptions<K>","(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 }","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 )","[]","(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 }","params","event","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 if (!onSelectionChange) return\n onSelectionChange(keysFromBrush(latestBrushedRef.current))\n }","useCallback(() => {\n if (!onSelectionChange) return\n onSelectionChange(keysFromBrush(latestBrushedRef.current))\n }, [onSelectionChange, keysFromBrush])","{\n click: handleClick,\n brushSelected: handleBrushSelected,\n brushEnd: handleBrushEnd,\n }","useMemo<Record<string, EchartsEventHandler>>(\n () => ({\n click: handleClick,\n brushSelected: handleBrushSelected,\n brushEnd: handleBrushEnd,\n }),\n [handleClick, handleBrushSelected, handleBrushEnd],\n )","{ onEvents, selection: wiringSelection }"],"sources":["../src/widgets/echart/edge-label-clamp.ts","../src/widgets/echart/shared-resize-observer.ts","../src/widgets/echart/style.ts","../src/widgets/echart/echart-ui.tsx","../src/widgets/echart/echart.tsx","../src/widgets/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 } | { source?: unknown }[] | 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 // ECharts puts its tooltip inside this box at `z-index: 9999999`. With\n // no stacking context of its own, that number competes page-wide and\n // beats MUI's modal and popover layers, so a tooltip left showing\n // paints over any dialog or menu opened above the chart. Isolating\n // keeps the tooltip above its own chart only.\n isolation: 'isolate',\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 )\n\n return { onEvents, selection: wiringSelection }\n}\n"],"mappings":";;;;;;;AAyBA,IAAa,IAA0B;CACrC,eAAe;CACf,eAAe;AACjB,GAQM,IAAmB;AAQzB,SAAgB,EAAoB,GAOlB;CAChB,IAAM,IACJ,EAAQ,OAAO,YAAY,EAAK,YAAY,EAAK,IAAI,CAAC,CAAC,QAAQ,GAC3D,IACJ,EAAQ,OAAO,YAAY,EAAK,WAAW,EAAK,IAAI,CAAC,CAAC,QAAQ;CAChE,OAAO;EACL,eACE,IAAY,IAAmB,EAAK,aAAa,SAAS;EAC5D,eACE,IAAW,IAAmB,EAAK,QAAQ,EAAK,YAC5C,UACA;CACR;AACF;AAqBA,SAAS,EAAW,GAA2C;CAE7D,OADI,MAAM,QAAQ,CAAK,IAAU,EAAM,KAChC;AAC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
|
|
2
|
-
import { C as t,
|
|
3
|
-
import { n as r, t as i } from "./download-
|
|
4
|
-
import { t as a } from "./utils-
|
|
2
|
+
import { C as t, D as n } from "./stores-DcBOZlU3.js";
|
|
3
|
+
import { n as r, t as i } from "./download-B4sykOFm.js";
|
|
4
|
+
import { t as a } from "./utils-C-eWwOhE.js";
|
|
5
5
|
import { c as o } from "react/compiler-runtime";
|
|
6
6
|
import { Avatar as s, Box as c, Chip as l, Skeleton as u, Typography as d } from "@mui/material";
|
|
7
7
|
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
@@ -247,16 +247,10 @@ function A(e, t) {
|
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region src/widgets/formula/download.tsx
|
|
249
249
|
function j(e) {
|
|
250
|
-
|
|
251
|
-
return e.getCaptureEl && t.push(r({
|
|
250
|
+
return i(e, r({
|
|
252
251
|
filename: e.filename,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
backgroundColor: e.pngBackgroundColor
|
|
256
|
-
})), t.push(i({
|
|
257
|
-
filename: e.filename,
|
|
258
|
-
getRows: () => {
|
|
259
|
-
let t = e.getData(), n = [[
|
|
252
|
+
getRows: (t) => {
|
|
253
|
+
let n = e.getData(t), r = [[
|
|
260
254
|
"series",
|
|
261
255
|
"prefix",
|
|
262
256
|
"value",
|
|
@@ -264,7 +258,7 @@ function j(e) {
|
|
|
264
258
|
"note",
|
|
265
259
|
"delta"
|
|
266
260
|
]];
|
|
267
|
-
for (let e of
|
|
261
|
+
for (let e of n) r.push([
|
|
268
262
|
e.series?.name ?? "",
|
|
269
263
|
e.prefix ?? "",
|
|
270
264
|
e.value,
|
|
@@ -272,11 +266,11 @@ function j(e) {
|
|
|
272
266
|
e.note ?? "",
|
|
273
267
|
e.delta?.value ?? ""
|
|
274
268
|
]);
|
|
275
|
-
return
|
|
269
|
+
return r;
|
|
276
270
|
}
|
|
277
|
-
}))
|
|
271
|
+
}));
|
|
278
272
|
}
|
|
279
273
|
//#endregion
|
|
280
274
|
export { C as a, b as c, g as d, w as i, y as l, k as n, S as o, D as r, x as s, j as t, v as u };
|
|
281
275
|
|
|
282
|
-
//# sourceMappingURL=formula-
|
|
276
|
+
//# sourceMappingURL=formula-DJS-JLpk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formula-CdHWtepq.js","names":["{\n value,\n label,\n severity,\n format,\n ChipProps: chipProps,\n}: DeltaProps","label ?? (format ? format(value) : defaultPercentFormatter.format(value))","{ fontWeight: 600 }","<Chip\n size='small'\n color={SEVERITY_TO_COLOR[resolvedSeverity]}\n label={text}\n sx={{ fontWeight: 600 }}\n {...chipProps}\n />","SEVERITY_TO_COLOR[resolvedSeverity]","{ children, TypographyProps }: NoteProps","mergeSx(\n {\n color: 'text.secondary',\n m: 0,\n },\n TypographyProps?.sx,\n )","sx","<Typography\n variant='caption'\n component='p'\n {...TypographyProps}\n sx={mergeSx(\n {\n color: 'text.secondary',\n m: 0,\n },\n TypographyProps?.sx,\n )}\n >\n {children}\n </Typography>","{ children, TypographyProps }: PrefixProps","{ fontWeight: 600, color: 'text.secondary', lineHeight: 1 }","<Typography\n variant='h5'\n component='span'\n sx={{ fontWeight: 600, color: 'text.secondary', lineHeight: 1 }}\n {...TypographyProps}\n >\n {children}\n </Typography>","{\n name,\n color,\n size = 24,\n AvatarProps: avatarProps,\n}: SeriesProps","size = 24","name.charAt(0).toUpperCase()","color\n ? (theme: Theme) =>\n theme.palette.getContrastText(\n resolveThemeColor(theme, color) ?? color,\n )\n : 'text.primary'","{\n width: size,\n height: size,\n fontSize: size * 0.5,\n fontWeight: 600,\n bgcolor: color ?? 'action.disabledBackground',\n // `getContrastText` needs a concrete colour, so the palette path is\n // resolved here even though `bgcolor` above takes it as it comes.\n color: color\n ? (theme: Theme) =>\n theme.palette.getContrastText(\n resolveThemeColor(theme, color) ?? color,\n )\n : 'text.primary',\n }","size * 0.5","color ?? 'action.disabledBackground'","<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 // `getContrastText` needs a concrete colour, so the palette path is\n // resolved here even though `bgcolor` above takes it as it comes.\n color: color\n ? (theme: Theme) =>\n theme.palette.getContrastText(\n resolveThemeColor(theme, color) ?? color,\n )\n : 'text.primary',\n }}\n {...avatarProps}\n >\n {letter}\n </Avatar>","{ children, TypographyProps }: SuffixProps","{ fontWeight: 600, color: 'text.secondary', lineHeight: 1 }","<Typography\n variant='h5'\n component='span'\n sx={{ fontWeight: 600, color: 'text.secondary', lineHeight: 1 }}\n {...TypographyProps}\n >\n {children}\n </Typography>","{ children, color, TypographyProps }: ValueProps","{\n fontWeight: 600,\n color: color ?? 'text.primary',\n lineHeight: 1,\n }","color ?? 'text.primary'","<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>","{ items, formatter, ref }: FormulaUIProps","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 ))","(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 )","<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>","<FormulaUI items={slice.data} formatter={slice.formatter} />","data","formatter","{ count = 1 }: FormulaSkeletonProps","count = 1","<Box sx={styles.root}>\n {Array.from({ length: count }).map((_, i) => (\n <Skeleton key={`row-${i}`} variant='rectangular' sx={styles.block} />\n ))}\n </Box>","(_, i) => (\n <Skeleton key={`row-${i}`} variant='rectangular' sx={styles.block} />\n )"],"sources":["../src/widgets/formula/delta.tsx","../src/widgets/formula/note.tsx","../src/widgets/formula/prefix.tsx","../src/widgets/formula/series.tsx","../src/widgets/formula/suffix.tsx","../src/widgets/formula/value.tsx","../src/widgets/formula/style.ts","../src/widgets/formula/formula-ui.tsx","../src/widgets/formula/formula.tsx","../src/widgets/formula/skeleton.tsx","../src/widgets/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'\nimport { mergeSx } from '../../components/lasso-tool/styles'\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 {...TypographyProps}\n sx={mergeSx(\n {\n color: 'text.secondary',\n m: 0,\n },\n TypographyProps?.sx,\n )}\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'\nimport type { PaletteColor } from '../../components/types'\nimport { resolveThemeColor } from '../utils'\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?: PaletteColor\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 // `getContrastText` needs a concrete colour, so the palette path is\n // resolved here even though `bgcolor` above takes it as it comes.\n color: color\n ? (theme: Theme) =>\n theme.palette.getContrastText(\n resolveThemeColor(theme, color) ?? color,\n )\n : 'text.primary',\n }}\n {...avatarProps}\n >\n {letter}\n </Avatar>\n )\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'\nimport type { PaletteColor } from '../../components/types'\n\nexport interface ValueProps {\n children: ReactNode\n /** Override the default `text.primary` color — useful for sparkline tints. */\n color?: PaletteColor\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,IAAM,IAA0B,IAAI,KAAK,aAAa,KAAA,GAAW;CAC/D,OAAO;CACP,aAAa;CACb,uBAAuB;AACzB,CAAC,GAEK,IAA+D;CACnE,UAAU;CACV,UAAU;CACV,SAAS;AACX;AAOA,SAAgB,EAAA,GAMD;eANO,EACpB,UACA,UACA,aACA,WACA,WAAW,MALSA,GAOd,IAAmB,KAAY,EAAc,CAAK,GAEtDC;CAAU,AAAA,EAAA,OAAA,KAAA,EAAA,OAAV,KAAA,EAAA,OAA0B,KAA1B,IAAA,MAAU,IAAS,EAAO,CAAK,IAAI,EAAwB,OAAO,CAAK,IAA7D,EAAA,KAAA,GAAV,EAAA,KAAA,GAA0B,EAAA,KAAA;CAD5B,IAAM,IACJA,GAIS,IAAA,EAAkB,IAErBC;qDAAE,IAAA,EAAA,YAAY,IAAI;CAJxBC,IAAAA;CAD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AAA,OAAA,gBADxB,IAAA,kBAAC,GAAD;EAAK,IAAI,EAAO;EACb,UAAA,MAAM,KAAK,EAAE,QAAQ,EAAM,CAAC,CAAC,CAAC,IAAIC,CAElC;CACE,CAAA,GAHmB,EAAA,KAAA,cADxBD;AAMJ;AALyC,SAAA,EAAC,GAAG,GAAA;CACrC,OAAA,kBAAC,GAAD;EAA2B,SAAQ;EAAc,IAAI,EAAO;CAAQ,GAArD,OAAO,GAA8C;;;;ACG5E,SAAgB,EACd,GACgB;CAChB,IAAM,IAAwB,CAAC;CAiC/B,OAhCI,EAAK,gBACP,EAAM,KACJ,EAAqB;EACnB,UAAU,EAAK;EACf,cAAc,EAAK;EACnB,YAAY,EAAK;EACjB,iBAAiB,EAAK;CACxB,CAAC,CACH,GAEF,EAAM,KACJ,EAAqB;EACnB,UAAU,EAAK;EACf,eAAe;GACb,IAAM,IAAO,EAAK,QAAQ,GACpB,IAAoB,CACxB;IAAC;IAAU;IAAU;IAAS;IAAU;IAAQ;GAAO,CACzD;GACA,KAAK,IAAM,KAAK,GACd,EAAK,KAAK;IACR,EAAE,QAAQ,QAAQ;IAClB,EAAE,UAAU;IACZ,EAAE;IACF,EAAE,UAAU;IACZ,EAAE,QAAQ;IACV,EAAE,OAAO,SAAS;GACpB,CAAC;GAEH,OAAO;EACT;CACF,CAAC,CACH,GACO;AACT"}
|
|
1
|
+
{"version":3,"file":"formula-DJS-JLpk.js","names":["{\n value,\n label,\n severity,\n format,\n ChipProps: chipProps,\n}: DeltaProps","label ?? (format ? format(value) : defaultPercentFormatter.format(value))","{ fontWeight: 600 }","<Chip\n size='small'\n color={SEVERITY_TO_COLOR[resolvedSeverity]}\n label={text}\n sx={{ fontWeight: 600 }}\n {...chipProps}\n />","SEVERITY_TO_COLOR[resolvedSeverity]","{ children, TypographyProps }: NoteProps","mergeSx(\n {\n color: 'text.secondary',\n m: 0,\n },\n TypographyProps?.sx,\n )","sx","<Typography\n variant='caption'\n component='p'\n {...TypographyProps}\n sx={mergeSx(\n {\n color: 'text.secondary',\n m: 0,\n },\n TypographyProps?.sx,\n )}\n >\n {children}\n </Typography>","{ children, TypographyProps }: PrefixProps","{ fontWeight: 600, color: 'text.secondary', lineHeight: 1 }","<Typography\n variant='h5'\n component='span'\n sx={{ fontWeight: 600, color: 'text.secondary', lineHeight: 1 }}\n {...TypographyProps}\n >\n {children}\n </Typography>","{\n name,\n color,\n size = 24,\n AvatarProps: avatarProps,\n}: SeriesProps","size = 24","name.charAt(0).toUpperCase()","color\n ? (theme: Theme) =>\n theme.palette.getContrastText(\n resolveThemeColor(theme, color) ?? color,\n )\n : 'text.primary'","{\n width: size,\n height: size,\n fontSize: size * 0.5,\n fontWeight: 600,\n bgcolor: color ?? 'action.disabledBackground',\n // `getContrastText` needs a concrete colour, so the palette path is\n // resolved here even though `bgcolor` above takes it as it comes.\n color: color\n ? (theme: Theme) =>\n theme.palette.getContrastText(\n resolveThemeColor(theme, color) ?? color,\n )\n : 'text.primary',\n }","size * 0.5","color ?? 'action.disabledBackground'","<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 // `getContrastText` needs a concrete colour, so the palette path is\n // resolved here even though `bgcolor` above takes it as it comes.\n color: color\n ? (theme: Theme) =>\n theme.palette.getContrastText(\n resolveThemeColor(theme, color) ?? color,\n )\n : 'text.primary',\n }}\n {...avatarProps}\n >\n {letter}\n </Avatar>","{ children, TypographyProps }: SuffixProps","{ fontWeight: 600, color: 'text.secondary', lineHeight: 1 }","<Typography\n variant='h5'\n component='span'\n sx={{ fontWeight: 600, color: 'text.secondary', lineHeight: 1 }}\n {...TypographyProps}\n >\n {children}\n </Typography>","{ children, color, TypographyProps }: ValueProps","{\n fontWeight: 600,\n color: color ?? 'text.primary',\n lineHeight: 1,\n }","color ?? 'text.primary'","<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>","{ items, formatter, ref }: FormulaUIProps","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 ))","(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 )","<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>","<FormulaUI items={slice.data} formatter={slice.formatter} />","data","formatter","{ count = 1 }: FormulaSkeletonProps","count = 1","<Box sx={styles.root}>\n {Array.from({ length: count }).map((_, i) => (\n <Skeleton key={`row-${i}`} variant='rectangular' sx={styles.block} />\n ))}\n </Box>","(_, i) => (\n <Skeleton key={`row-${i}`} variant='rectangular' sx={styles.block} />\n )"],"sources":["../src/widgets/formula/delta.tsx","../src/widgets/formula/note.tsx","../src/widgets/formula/prefix.tsx","../src/widgets/formula/series.tsx","../src/widgets/formula/suffix.tsx","../src/widgets/formula/value.tsx","../src/widgets/formula/style.ts","../src/widgets/formula/formula-ui.tsx","../src/widgets/formula/formula.tsx","../src/widgets/formula/skeleton.tsx","../src/widgets/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'\nimport { mergeSx } from '../../components/lasso-tool/styles'\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 {...TypographyProps}\n sx={mergeSx(\n {\n color: 'text.secondary',\n m: 0,\n },\n TypographyProps?.sx,\n )}\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'\nimport type { PaletteColor } from '../../components/types'\nimport { resolveThemeColor } from '../utils'\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?: PaletteColor\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 // `getContrastText` needs a concrete colour, so the palette path is\n // resolved here even though `bgcolor` above takes it as it comes.\n color: color\n ? (theme: Theme) =>\n theme.palette.getContrastText(\n resolveThemeColor(theme, color) ?? color,\n )\n : 'text.primary',\n }}\n {...avatarProps}\n >\n {letter}\n </Avatar>\n )\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'\nimport type { PaletteColor } from '../../components/types'\n\nexport interface ValueProps {\n children: ReactNode\n /** Override the default `text.primary` color — useful for sparkline tints. */\n color?: PaletteColor\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 withPngItem,\n type DownloadItem,\n type WidgetDownloadArgs,\n} from '../actions/download'\nimport type { FormulaWidgetData } from './types'\n\nexport type FormulaDownloadConfigArgs = WidgetDownloadArgs<FormulaWidgetData>\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`). When\n * `getCaptureEl` is given, prepends a PNG item that rasterises the captured\n * element via `html2canvas`.\n */\nexport function createFormulaDownloadConfig(\n args: FormulaDownloadConfigArgs,\n): DownloadItem[] {\n return withPngItem(\n args,\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: (ctx) => {\n const data = args.getData(ctx)\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}\n"],"mappings":";;;;;;;;AAkBA,IAAM,IAA0B,IAAI,KAAK,aAAa,KAAA,GAAW;CAC/D,OAAO;CACP,aAAa;CACb,uBAAuB;AACzB,CAAC,GAEK,IAA+D;CACnE,UAAU;CAC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t) {
|
|
1874
|
-
let n = y(
|
|
1874
|
+
let n = y(42), { data: r, labels: i } = t, a = i === void 0 ? ye : i, { colors: o, stops: s, isContinuous: c, attribute: l, formatValue: u } = r, d = u === void 0 ? String : u, f;
|
|
1875
1875
|
n[0] === r ? f = n[1] : (f = Bt(r), n[0] = r, n[1] = f);
|
|
1876
1876
|
let p = f, m = s[0], h = s[s.length - 1], g;
|
|
1877
1877
|
n[2] === o ? g = n[3] : (g = o.join(", "), n[2] = o, n[3] = g);
|
|
1878
1878
|
let _ = `linear-gradient(90deg, ${g})`, v = !c && s.length === o.length + 1, b = !c && !v, x;
|
|
1879
|
-
n[4]
|
|
1879
|
+
if (n[4] !== s) {
|
|
1880
|
+
let e = (e) => s[e].label || String(s[e].value);
|
|
1881
|
+
x = (t) => `${e(t)} – ${e(t + 1)}`, n[4] = s, n[5] = x;
|
|
1882
|
+
} else x = n[5];
|
|
1880
1883
|
let S = x, C;
|
|
1881
1884
|
n[6] !== l || n[7] !== a ? (C = l && /* @__PURE__ */ U(k, {
|
|
1882
1885
|
sx: Q.attribute,
|
|
@@ -1910,7 +1913,7 @@ function Vt(t) {
|
|
|
1910
1913
|
}), n[12] = w, n[13] = r, n[14] = i) : i = n[14], i;
|
|
1911
1914
|
}
|
|
1912
1915
|
let T;
|
|
1913
|
-
n[15] !== o || n[16] !==
|
|
1916
|
+
n[15] !== o || n[16] !== d || n[17] !== _ || n[18] !== c || n[19] !== a || n[20] !== S || n[21] !== s ? (T = c ? /* @__PURE__ */ H(k, {
|
|
1914
1917
|
role: "img",
|
|
1915
1918
|
"aria-label": a.colorGradient,
|
|
1916
1919
|
sx: {
|
|
@@ -1918,21 +1921,31 @@ function Vt(t) {
|
|
|
1918
1921
|
height: "100%",
|
|
1919
1922
|
background: _
|
|
1920
1923
|
}
|
|
1921
|
-
}) : o.map((
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
}
|
|
1928
|
-
|
|
1924
|
+
}) : o.map((t, n) => /* @__PURE__ */ H(e, {
|
|
1925
|
+
title: /* @__PURE__ */ U(V, { children: [
|
|
1926
|
+
d(s[n].value),
|
|
1927
|
+
" –",
|
|
1928
|
+
" ",
|
|
1929
|
+
d(s[n + 1].value)
|
|
1930
|
+
] }),
|
|
1931
|
+
placement: "top",
|
|
1932
|
+
arrow: !0,
|
|
1933
|
+
children: /* @__PURE__ */ H(k, {
|
|
1934
|
+
role: "img",
|
|
1935
|
+
"aria-label": S(n),
|
|
1936
|
+
sx: {
|
|
1937
|
+
...Q.step,
|
|
1938
|
+
backgroundColor: t
|
|
1939
|
+
}
|
|
1940
|
+
})
|
|
1941
|
+
}, n)), n[15] = o, n[16] = d, n[17] = _, n[18] = c, n[19] = a, n[20] = S, n[21] = s, n[22] = T) : T = n[22];
|
|
1929
1942
|
let E;
|
|
1930
|
-
n[
|
|
1943
|
+
n[23] === T ? E = n[24] : (E = /* @__PURE__ */ H(k, {
|
|
1931
1944
|
sx: Q.bar,
|
|
1932
1945
|
children: T
|
|
1933
|
-
}), n[
|
|
1946
|
+
}), n[23] = T, n[24] = E);
|
|
1934
1947
|
let D;
|
|
1935
|
-
n[
|
|
1948
|
+
n[25] !== p || n[26] !== r.avg || n[27] !== d ? (D = p != null && r.avg != null && /* @__PURE__ */ H(e, {
|
|
1936
1949
|
title: d(r.avg),
|
|
1937
1950
|
placement: "top",
|
|
1938
1951
|
arrow: !0,
|
|
@@ -1940,14 +1953,14 @@ function Vt(t) {
|
|
|
1940
1953
|
sx: Q.avgLine,
|
|
1941
1954
|
style: { left: `${p}%` }
|
|
1942
1955
|
})
|
|
1943
|
-
}), n[
|
|
1956
|
+
}), n[25] = p, n[26] = r.avg, n[27] = d, n[28] = D) : D = n[28];
|
|
1944
1957
|
let O;
|
|
1945
|
-
n[
|
|
1958
|
+
n[29] !== E || n[30] !== D ? (O = /* @__PURE__ */ U(k, {
|
|
1946
1959
|
sx: Q.barWrap,
|
|
1947
1960
|
children: [E, D]
|
|
1948
|
-
}), n[
|
|
1961
|
+
}), n[29] = E, n[30] = D, n[31] = O) : O = n[31];
|
|
1949
1962
|
let A;
|
|
1950
|
-
n[
|
|
1963
|
+
n[32] !== o.length || n[33] !== m?.label || n[34] !== v || n[35] !== h?.label || n[36] !== s ? (A = v ? /* @__PURE__ */ H(k, {
|
|
1951
1964
|
sx: Q.boundaryLabels,
|
|
1952
1965
|
children: s.map((e, t) => {
|
|
1953
1966
|
let n = t === s.length - 1, r = t === 0 ? void 0 : n ? "translateX(-100%)" : "translateX(-50%)";
|
|
@@ -1972,16 +1985,16 @@ function Vt(t) {
|
|
|
1972
1985
|
sx: { color: "text.secondary" },
|
|
1973
1986
|
children: h?.label
|
|
1974
1987
|
})]
|
|
1975
|
-
}), n[
|
|
1988
|
+
}), n[32] = o.length, n[33] = m?.label, n[34] = v, n[35] = h?.label, n[36] = s, n[37] = A) : A = n[37];
|
|
1976
1989
|
let j;
|
|
1977
|
-
return n[
|
|
1990
|
+
return n[38] !== w || n[39] !== O || n[40] !== A ? (j = /* @__PURE__ */ U(k, {
|
|
1978
1991
|
sx: Q.container,
|
|
1979
1992
|
children: [
|
|
1980
1993
|
w,
|
|
1981
1994
|
O,
|
|
1982
1995
|
A
|
|
1983
1996
|
]
|
|
1984
|
-
}), n[
|
|
1997
|
+
}), n[38] = w, n[39] = O, n[40] = A, n[41] = j) : j = n[41], j;
|
|
1985
1998
|
}
|
|
1986
1999
|
//#endregion
|
|
1987
2000
|
//#region src/legend/components/legend-proportion/styles.ts
|