@carto/ps-react-ui 4.11.3 → 4.12.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/chat.js +962 -733
- package/dist/chat.js.map +1 -1
- package/dist/csv-item-hH_Gt7ur.js +32 -0
- package/dist/csv-item-hH_Gt7ur.js.map +1 -0
- package/dist/png-item-9dNbB37T.js +57 -0
- package/dist/png-item-9dNbB37T.js.map +1 -0
- package/dist/table-B3ZWWhJt.js +383 -0
- package/dist/table-B3ZWWhJt.js.map +1 -0
- package/dist/types/chat/containers/chat-footer.d.ts +1 -1
- package/dist/types/chat/containers/styles.d.ts +79 -12
- package/dist/types/chat/index.d.ts +1 -1
- package/dist/types/chat/types.d.ts +21 -0
- package/dist/types/chat/use-typewriter.d.ts +5 -3
- package/dist/types/widgets-v2/actions/download/constants.d.ts +12 -0
- package/dist/types/widgets-v2/actions/download/csv-item.d.ts +38 -0
- package/dist/types/widgets-v2/actions/download/icons.d.ts +6 -0
- package/dist/types/widgets-v2/actions/download/index.d.ts +3 -1
- package/dist/types/widgets-v2/actions/index.d.ts +1 -1
- package/dist/widgets-v2/actions.js +40 -36
- package/dist/widgets-v2/actions.js.map +1 -1
- package/dist/widgets-v2/bar.js +77 -84
- package/dist/widgets-v2/bar.js.map +1 -1
- package/dist/widgets-v2/category.js +50 -55
- package/dist/widgets-v2/category.js.map +1 -1
- package/dist/widgets-v2/formula.js +37 -43
- package/dist/widgets-v2/formula.js.map +1 -1
- package/dist/widgets-v2/histogram.js +138 -144
- package/dist/widgets-v2/histogram.js.map +1 -1
- package/dist/widgets-v2/markdown.js +18 -17
- package/dist/widgets-v2/markdown.js.map +1 -1
- package/dist/widgets-v2/pie.js +67 -73
- package/dist/widgets-v2/pie.js.map +1 -1
- package/dist/widgets-v2/scatterplot.js +75 -81
- package/dist/widgets-v2/scatterplot.js.map +1 -1
- package/dist/widgets-v2/spread.js +36 -41
- package/dist/widgets-v2/spread.js.map +1 -1
- package/dist/widgets-v2/table.js +46 -55
- package/dist/widgets-v2/table.js.map +1 -1
- package/dist/widgets-v2/timeseries.js +81 -87
- package/dist/widgets-v2/timeseries.js.map +1 -1
- package/dist/widgets-v2.js +1 -1
- package/package.json +1 -1
- package/src/chat/bubbles/styles.ts +5 -1
- package/src/chat/containers/chat-content.tsx +4 -1
- package/src/chat/containers/chat-footer.test.tsx +59 -0
- package/src/chat/containers/chat-footer.tsx +124 -36
- package/src/chat/containers/styles.ts +107 -16
- package/src/chat/feedback/styles.ts +11 -4
- package/src/chat/index.ts +1 -0
- package/src/chat/types.ts +22 -0
- package/src/chat/use-typewriter.ts +32 -24
- package/src/widgets-v2/actions/download/constants.ts +14 -0
- package/src/widgets-v2/actions/download/csv-item.test.tsx +77 -0
- package/src/widgets-v2/actions/download/csv-item.tsx +71 -0
- package/src/widgets-v2/actions/download/icons.tsx +10 -1
- package/src/widgets-v2/actions/download/index.ts +3 -1
- package/src/widgets-v2/actions/download/png-item.tsx +2 -1
- package/src/widgets-v2/actions/index.ts +5 -0
- package/src/widgets-v2/bar/download.tsx +16 -22
- package/src/widgets-v2/category/download.test.ts +9 -0
- package/src/widgets-v2/category/download.ts +16 -20
- package/src/widgets-v2/formula/download.tsx +23 -29
- package/src/widgets-v2/histogram/download.ts +22 -26
- package/src/widgets-v2/markdown/{download.ts → download.tsx} +5 -2
- package/src/widgets-v2/pie/download.ts +16 -20
- package/src/widgets-v2/scatterplot/download.ts +16 -20
- package/src/widgets-v2/spread/download.ts +23 -27
- package/src/widgets-v2/table/download.test.ts +10 -0
- package/src/widgets-v2/table/download.ts +11 -15
- package/src/widgets-v2/table/helpers.test.ts +19 -0
- package/src/widgets-v2/table/helpers.ts +7 -12
- package/src/widgets-v2/timeseries/download.ts +36 -40
- package/dist/png-item-BE9uEqlD.js +0 -45
- package/dist/png-item-BE9uEqlD.js.map +0 -1
- package/dist/table-C9IMbTr0.js +0 -385
- package/dist/table-C9IMbTr0.js.map +0 -1
- package/dist/types/chat/feedback/styles.d.ts +0 -211
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar.js","sources":["../../src/widgets-v2/bar/options.ts","../../src/widgets-v2/bar/skeleton.tsx","../../src/widgets-v2/bar/download.tsx"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n BarEChartsOption,\n BarOptionFactoryInput,\n BarOptionsInput,\n BarWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a bar widget — axes, grid,\n * tooltip styling, themed legend. Intentionally data-agnostic: no series,\n * no dataset, no `legend.show` (those depend on data and are added by the\n * option factory's merge phase). This separation is what lets data-side\n * pipeline transforms (Searcher, RelativeData) drive the rendered chart —\n * the merge happens at render time inside the Echart bridge.\n *\n * Styling matches the v1 `barConfig` look-and-feel: minimal axes (only\n * min/max y-labels rendered inside the plot via `niceNum`), themed tooltip,\n * scroll legend, and CARTO color palette. The y-axis min/max + label\n * formatter and the tooltip formatter are wired here for the no-data case;\n * {@link createBarOptionFactory} re-derives them at fusion time so reactive\n * formatter changes (RelativeData) and stack templates (StackToggle) flow\n * through to the chart.\n */\nexport function barOptions({\n theme,\n formatter,\n labelFormatter,\n}: BarOptionsInput): BarEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildBarTooltipFormatter(formatter, labelFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false, labelFormatter }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n hideOverlap: true,\n ...(labelFormatter && {\n formatter: (v: string | number) => String(labelFormatter(v)),\n }),\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as BarEChartsOption\n}\n\n/**\n * Returns the bar widget's {@link OptionFactory} — a single closure that\n * handles BOTH option-construction phases:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link barOptions}, optionally merging the\n * consumer-supplied `optionsOverride` on top. Called once by Provider\n * to seed `rawOptions` in the store; configTransforms (StackToggle /\n * ZoomToggle / BrushToggle) then mutate it via the pipeline middleware.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`BarWidgetData`) into the option via the dataset API: one dataset\n * per series, each series referencing its dataset by index, encoded\n * by `name` (x) and `value` (y). Spreads any series-template fields\n * already on the incoming option (e.g. `{ stack: 'total' }` from\n * `addStack`) into every emitted series so configTransforms compose\n * end-to-end. Reactive `ctx.formatter` / `ctx.labelFormatter` drive\n * the y-axis min/max-only label and the tooltip formatter at fusion\n * time so RelativeData's percent formatter flows through without a\n * structural rebuild.\n *\n * Stable identity when the inputs don't change (consumers should wrap the\n * call in `useMemo` keyed on the same inputs).\n */\nexport function createBarOptionFactory(\n options: BarOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride } = options\n const series = options.series\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0\n ? new Set<string | number>(selection)\n : null\n return (option, data, ctx) => {\n // Structural phase: Provider seeds rawOptions with this branch. No data\n // is read; we just emit the theme-aware base (optionally with override).\n if (option == null) {\n const structural = barOptions({ theme, formatter, labelFormatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr = Array.isArray(data) ? (data as BarWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n const hasLegend = seriesArr.length > 1\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n\n // Reactive (live store) formatters from ctx — distinct from the\n // closure-time `formatter` / `labelFormatter` captured for the\n // structural-build branch above. RelativeData can install a percent\n // formatter on the store after the factory was constructed; the merge\n // phase reads `ctx` to pick that up.\n const liveFormatter = ctx?.formatter\n const liveLabelFormatter = ctx?.labelFormatter\n\n // Closure shared between the yAxis min/max callbacks and the label\n // formatter, so only the rounded extents are labelled (matches v1).\n // Delegating the extent to ECharts (rather than precomputing scalars\n // from the raw data) is what keeps stacked bars inside the plot: when\n // StackToggle marks the series, ECharts feeds the *post-stack* extent\n // to these callbacks, so `niceNum` rounds the stacked total instead of\n // a single series.\n let niceMin = 0\n let niceMax = 1\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push the\n // slider above the legend (if any) and reserve room in the grid below.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // When a selection is active, dim non-selected bars by routing the\n // resolved palette color through `modifyAlpha`. Per-row `itemStyle` on\n // dataset object-rows is silently ignored when `series.encode` is in\n // play — the callback approach is the standard ECharts pattern for\n // per-data styling derived from a dataset.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and bars would stay dimmed forever after an external clear. Always\n // emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n // Per-series `color` override: ECharts sets `params.color` from\n // `series[i].color` when resolving styles, so the dim callback\n // above keeps working — it just dims the user's colour rather\n // than the palette default.\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'bar' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 'name', y: 'value' },\n barMaxWidth: 100,\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: {\n ...baseGrid,\n bottom: gridBottom,\n },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildBarTooltipFormatter(liveFormatter, liveLabelFormatter),\n },\n } as EChartsOption\n }\n}\n\nfunction buildBarTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as { name?: string | number; value?: number }\n const raw = row?.value\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : (item.name ?? '')\n return { name: String(name), seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton, type SxProps, type Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n display: 'flex',\n justifyContent: 'space-between',\n flex: '1 1 auto',\n alignItems: 'flex-end',\n width: '100%',\n },\n bar: {\n flex: 1,\n maxWidth: ({ spacing }) => spacing(12),\n '& + &': {\n marginLeft: ({ spacing }) => spacing(1),\n },\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nconst BAR_HEIGHTS = ['20%', '40%', '60%', '20%', '80%'] as const\n\n/**\n * Loading state for the Bar widget. Mirrors a bar chart's silhouette — five\n * vertical bars at staggered heights anchored to the bottom, plus a legend\n * stub — so the skeleton reads as \"a bar chart\" rather than a generic list.\n */\nexport function BarSkeleton() {\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n CSVIcon,\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { BarWidgetData } from './types'\n\nexport interface BarDownloadConfigArgs {\n filename: string\n getData: () => BarWidgetData\n /**\n * Optional getter for the widget's capture element (registered by\n * `Widget.State` on its success path). When provided, a PNG item is\n * prepended to the returned list. Wire it to\n * `() => getCaptureEl(id)`.\n */\n getCaptureEl?: () => HTMLElement | null\n /** PNG `pixelRatio` (default 2). */\n pngPixelRatio?: number\n /** PNG `backgroundColor` (default transparent). */\n pngBackgroundColor?: string | null\n}\n\n/**\n * Builds download items for the Bar widget. Always includes a CSV item\n * with one `name,value` block per series, separated by an empty row when\n * there are multiple. When `getCaptureEl` is supplied, also prepends a PNG\n * item that rasterises the captured element via `html2canvas`.\n */\nexport function createBarDownloadConfig(\n args: BarDownloadConfigArgs,\n): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'CSV',\n icon: <CSVIcon fontSize='small' />,\n resolve: () => {\n const data = args.getData()\n const rows: unknown[][] = []\n for (const [i, series] of data.entries()) {\n if (i > 0) rows.push([])\n rows.push(['name', 'value'])\n for (const d of series) rows.push([d.name, d.value])\n }\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n"],"names":["barOptions","theme","formatter","labelFormatter","niceMin","niceMax","grid","left","parseInt","spacing","top","right","buildGridConfig","containLabel","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","textStyle","color","common","white","fontSize","fontFamily","typography","caption","axisPointer","type","position","createTooltipPositioner","buildBarTooltipFormatter","legend","buildLegendConfig","hasLegend","lineStyle","secondary","main","Object","values","qualitative","bold","xAxis","axisLine","show","axisTick","axisLabel","margin","hideOverlap","v","String","yAxis","min","extent","niceNum","max","splitLine","black","divider","overlineDelicate","showMaxLabel","showMinLabel","verticalAlign","inside","value","createBarOptionFactory","options","optionsOverride","series","selection","selectionSet","length","Set","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","baseLegend","baseGrid","baseTooltip","baseYAxis","seriesTemplates","broadcastTemplate","liveFormatter","liveLabelFormatter","dataZoomLayout","positionDataZoomForLegend","dataZoom","fallbackBottom","bottom","baseBottom","gridBottom","ZOOM_LAYOUT","sliderHeight","sliderGap","dimItemStyle","params","base","name","has","echarts","modifyAlpha","map","s","source","_","i","template","overrideColor","resolveThemeColor","datasetIndex","encode","x","y","barMaxWidth","emphasis","focus","itemStyle","createTooltipFormatter","item","raw","formattedValue","marker","seriesName","styles","container","display","alignItems","justifyContent","flexDirection","gap","height","flex","width","bar","maxWidth","marginLeft","legendItem","BAR_HEIGHTS","BarSkeleton","$","_c","t0","Symbol","for","jsx","Box","_temp","t1","_temp2","i_0","jsxs","Skeleton","createBarDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","id","label","icon","CSVIcon","resolve","getData","rows","entries","d","handle","downloadToCSV","Promise","url","revoke"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,SAASA,EAAW;AAAA,EACzBC,OAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,gBAAAA;AACe,GAAqB;AAGpC,MAAIC,IAAU,GACVC,IAAU;AAEd,SAAO;AAAA,IACLC,MAAM;AAAA,MACJC,MAAMC,SAASP,EAAMQ,QAAQ,CAAC,CAAC;AAAA,MAC/BC,KAAKF,SAASP,EAAMQ,QAAQ,CAAC,CAAC;AAAA,MAC9BE,OAAOH,SAASP,EAAMQ,QAAQ,CAAC,CAAC;AAAA;AAAA,MAEhC,GAAGG,EAAgB,IAAOX,CAAK;AAAA,MAC/BY,cAAc;AAAA,IAAA;AAAA,IAEhBC,S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AA,CAAO;AAAA,IAC/BC,SAASA,MAAM;AACb,YAAMlG,IAAOqF,EAAKc,QAAAA,GACZC,IAAoB,CAAA;AAC1B,iBAAW,CAAC/D,GAAG3C,CAAM,KAAKM,EAAKqG,WAAW;AACxC,QAAIhE,IAAI,KAAG+D,EAAKZ,KAAK,CAAA,CAAE,GACvBY,EAAKZ,KAAK,CAAC,QAAQ,OAAO,CAAC;AAC3B,mBAAWc,KAAK5G,EAAQ0G,CAAAA,EAAKZ,KAAK,CAACc,EAAEzE,MAAMyE,EAAEhH,KAAK,CAAC;AAAA,MACrD;AACA,YAAMiH,IAASC,EAAcJ,CAAI;AACjC,aAAOK,QAAQP,QAAQ;AAAA,QACrBQ,KAAKH,EAAOG;AAAAA,QACZhB,UAAU,GAAGL,EAAKK,QAAQ;AAAA,QAC1BiB,QAAQJ,EAAOI;AAAAA,MAAAA,CAChB;AAAA,IACH;AAAA,EAAA,CACD,GACMrB;AACT;"}
|
|
1
|
+
{"version":3,"file":"bar.js","sources":["../../src/widgets-v2/bar/options.ts","../../src/widgets-v2/bar/skeleton.tsx","../../src/widgets-v2/bar/download.tsx"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n BarEChartsOption,\n BarOptionFactoryInput,\n BarOptionsInput,\n BarWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a bar widget — axes, grid,\n * tooltip styling, themed legend. Intentionally data-agnostic: no series,\n * no dataset, no `legend.show` (those depend on data and are added by the\n * option factory's merge phase). This separation is what lets data-side\n * pipeline transforms (Searcher, RelativeData) drive the rendered chart —\n * the merge happens at render time inside the Echart bridge.\n *\n * Styling matches the v1 `barConfig` look-and-feel: minimal axes (only\n * min/max y-labels rendered inside the plot via `niceNum`), themed tooltip,\n * scroll legend, and CARTO color palette. The y-axis min/max + label\n * formatter and the tooltip formatter are wired here for the no-data case;\n * {@link createBarOptionFactory} re-derives them at fusion time so reactive\n * formatter changes (RelativeData) and stack templates (StackToggle) flow\n * through to the chart.\n */\nexport function barOptions({\n theme,\n formatter,\n labelFormatter,\n}: BarOptionsInput): BarEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildBarTooltipFormatter(formatter, labelFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false, labelFormatter }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n hideOverlap: true,\n ...(labelFormatter && {\n formatter: (v: string | number) => String(labelFormatter(v)),\n }),\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as BarEChartsOption\n}\n\n/**\n * Returns the bar widget's {@link OptionFactory} — a single closure that\n * handles BOTH option-construction phases:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link barOptions}, optionally merging the\n * consumer-supplied `optionsOverride` on top. Called once by Provider\n * to seed `rawOptions` in the store; configTransforms (StackToggle /\n * ZoomToggle / BrushToggle) then mutate it via the pipeline middleware.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`BarWidgetData`) into the option via the dataset API: one dataset\n * per series, each series referencing its dataset by index, encoded\n * by `name` (x) and `value` (y). Spreads any series-template fields\n * already on the incoming option (e.g. `{ stack: 'total' }` from\n * `addStack`) into every emitted series so configTransforms compose\n * end-to-end. Reactive `ctx.formatter` / `ctx.labelFormatter` drive\n * the y-axis min/max-only label and the tooltip formatter at fusion\n * time so RelativeData's percent formatter flows through without a\n * structural rebuild.\n *\n * Stable identity when the inputs don't change (consumers should wrap the\n * call in `useMemo` keyed on the same inputs).\n */\nexport function createBarOptionFactory(\n options: BarOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride } = options\n const series = options.series\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0\n ? new Set<string | number>(selection)\n : null\n return (option, data, ctx) => {\n // Structural phase: Provider seeds rawOptions with this branch. No data\n // is read; we just emit the theme-aware base (optionally with override).\n if (option == null) {\n const structural = barOptions({ theme, formatter, labelFormatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr = Array.isArray(data) ? (data as BarWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n const hasLegend = seriesArr.length > 1\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n\n // Reactive (live store) formatters from ctx — distinct from the\n // closure-time `formatter` / `labelFormatter` captured for the\n // structural-build branch above. RelativeData can install a percent\n // formatter on the store after the factory was constructed; the merge\n // phase reads `ctx` to pick that up.\n const liveFormatter = ctx?.formatter\n const liveLabelFormatter = ctx?.labelFormatter\n\n // Closure shared between the yAxis min/max callbacks and the label\n // formatter, so only the rounded extents are labelled (matches v1).\n // Delegating the extent to ECharts (rather than precomputing scalars\n // from the raw data) is what keeps stacked bars inside the plot: when\n // StackToggle marks the series, ECharts feeds the *post-stack* extent\n // to these callbacks, so `niceNum` rounds the stacked total instead of\n // a single series.\n let niceMin = 0\n let niceMax = 1\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push the\n // slider above the legend (if any) and reserve room in the grid below.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // When a selection is active, dim non-selected bars by routing the\n // resolved palette color through `modifyAlpha`. Per-row `itemStyle` on\n // dataset object-rows is silently ignored when `series.encode` is in\n // play — the callback approach is the standard ECharts pattern for\n // per-data styling derived from a dataset.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and bars would stay dimmed forever after an external clear. Always\n // emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n // Per-series `color` override: ECharts sets `params.color` from\n // `series[i].color` when resolving styles, so the dim callback\n // above keeps working — it just dims the user's colour rather\n // than the palette default.\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'bar' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 'name', y: 'value' },\n barMaxWidth: 100,\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: {\n ...baseGrid,\n bottom: gridBottom,\n },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildBarTooltipFormatter(liveFormatter, liveLabelFormatter),\n },\n } as EChartsOption\n }\n}\n\nfunction buildBarTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as { name?: string | number; value?: number }\n const raw = row?.value\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : (item.name ?? '')\n return { name: String(name), seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton, type SxProps, type Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n display: 'flex',\n justifyContent: 'space-between',\n flex: '1 1 auto',\n alignItems: 'flex-end',\n width: '100%',\n },\n bar: {\n flex: 1,\n maxWidth: ({ spacing }) => spacing(12),\n '& + &': {\n marginLeft: ({ spacing }) => spacing(1),\n },\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nconst BAR_HEIGHTS = ['20%', '40%', '60%', '20%', '80%'] as const\n\n/**\n * Loading state for the Bar widget. Mirrors a bar chart's silhouette — five\n * vertical bars at staggered heights anchored to the bottom, plus a legend\n * stub — so the skeleton reads as \"a bar chart\" rather than a generic list.\n */\nexport function BarSkeleton() {\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadItem,\n} from '../actions/download'\nimport type { BarWidgetData } from './types'\n\nexport interface BarDownloadConfigArgs {\n filename: string\n getData: () => BarWidgetData\n /**\n * Optional getter for the widget's capture element (registered by\n * `Widget.State` on its success path). When provided, a PNG item is\n * prepended to the returned list. Wire it to\n * `() => getCaptureEl(id)`.\n */\n getCaptureEl?: () => HTMLElement | null\n /** PNG `pixelRatio` (default 2). */\n pngPixelRatio?: number\n /** PNG `backgroundColor` (default transparent). */\n pngBackgroundColor?: string | null\n}\n\n/**\n * Builds download items for the Bar widget. Always includes a CSV item\n * with one `name,value` block per series, separated by an empty row when\n * there are multiple. When `getCaptureEl` is supplied, also prepends a PNG\n * item that rasterises the captured element via `html2canvas`.\n */\nexport function createBarDownloadConfig(\n args: BarDownloadConfigArgs,\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 for (const [i, series] of data.entries()) {\n if (i > 0) rows.push([])\n rows.push(['name', 'value'])\n for (const d of series) rows.push([d.name, d.value])\n }\n return rows\n },\n }),\n )\n return items\n}\n"],"names":["barOptions","theme","formatter","labelFormatter","niceMin","niceMax","grid","left","parseInt","spacing","top","right","buildGridConfig","containLabel","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","textStyle","color","common","white","fontSize","fontFamily","typography","caption","axisPointer","type","position","createTooltipPositioner","buildBarTooltipFormatter","legend","buildLegendConfig","hasLegend","lineStyle","secondary","main","Object","values","qualitative","bold","xAxis","axisLine","show","axisTick","axisLabel","margin","hideOverlap","v","String","yAxis","min","extent","niceNum","max","splitLine","black","divider","overlineDelicate","showMaxLabel","showMinLabel","verticalAlign","inside","value","createBarOptionFactory","options","optionsOverride","series","selection","selectionSet","length","Set","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","baseLegend","baseGrid","baseTooltip","baseYAxis","seriesTemplates","broadcastTemplate","liveFormatter","liveLabelFormatter","dataZoomLayout","positionDataZoomForLegend","dataZoom","fallbackBottom","bottom","baseBottom","gridBottom","ZOOM_LAYOUT","sliderHeight","sliderGap","dimItemStyle","params","base","name","has","echarts","modifyAlpha","map","s","source","_","i","template","overrideColor","resolveThemeColor","datasetIndex","encode","x","y","barMaxWidth","emphasis","focus","itemStyle","createTooltipFormatter","item","raw","formattedValue","marker","seriesName","styles","container","display","alignItems","justifyContent","flexDirection","gap","height","flex","width","bar","maxWidth","marginLeft","legendItem","BAR_HEIGHTS","BarSkeleton","$","_c","t0","Symbol","for","jsx","Box","_temp","t1","_temp2","i_0","jsxs","Skeleton","createBarDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","buildCsvDownloadItem","getRows","getData","rows","entries","d"],"mappings":";;;;;;;;;;;;;;;;;;;;;;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KACF,SAAA,eACAH,QAAAA,EAAAA,GAHH,OAAOzB,CAAC,EAGC;AACd;AC1BL,SAAS+C,GACdC,GACgB;AAChB,QAAMC,IAAwB,CAAA;AAC9B,SAAID,EAAKE,gBACPD,EAAME,KACJC,EAAqB;AAAA,IACnBC,UAAUL,EAAKK;AAAAA,IACfH,cAAcF,EAAKE;AAAAA,IACnBI,YAAYN,EAAKO;AAAAA,IACjBxJ,iBAAiBiJ,EAAKQ;AAAAA,EAAAA,CACvB,CACH,GAEFP,EAAME,KACJM,EAAqB;AAAA,IACnBJ,UAAUL,EAAKK;AAAAA,IACfK,SAASA,MAAM;AACb,YAAM/F,IAAOqF,EAAKW,QAAAA,GACZC,IAAoB,CAAA;AAC1B,iBAAW,CAAC5D,GAAG3C,CAAM,KAAKM,EAAKkG,WAAW;AACxC,QAAI7D,IAAI,KAAG4D,EAAKT,KAAK,CAAA,CAAE,GACvBS,EAAKT,KAAK,CAAC,QAAQ,OAAO,CAAC;AAC3B,mBAAWW,KAAKzG,EAAQuG,CAAAA,EAAKT,KAAK,CAACW,EAAEtE,MAAMsE,EAAE7G,KAAK,CAAC;AAAA,MACrD;AACA,aAAO2G;AAAAA,IACT;AAAA,EAAA,CACD,CACH,GACOX;AACT;"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { jsx as m, jsxs as
|
|
3
|
-
import { c as
|
|
4
|
-
import { Box as
|
|
1
|
+
import { C as N, a as P, b as $, c as z, d as G, e as L, f as M } from "../category-Dnd2_j0x.js";
|
|
2
|
+
import { jsx as m, jsxs as g } from "react/jsx-runtime";
|
|
3
|
+
import { c as d } from "react/compiler-runtime";
|
|
4
|
+
import { Box as c, Skeleton as p } from "@mui/material";
|
|
5
5
|
import "react";
|
|
6
6
|
import "@mui/icons-material";
|
|
7
7
|
import "../lasso-tool-CDFj4zKY.js";
|
|
8
8
|
import "../cjs-D4KH3azB.js";
|
|
9
9
|
import "@carto/ps-utils";
|
|
10
|
-
import
|
|
11
|
-
import { b as
|
|
12
|
-
|
|
10
|
+
import "html2canvas";
|
|
11
|
+
import { b as w } from "../png-item-9dNbB37T.js";
|
|
12
|
+
import { b as h } from "../csv-item-hH_Gt7ur.js";
|
|
13
|
+
const s = {
|
|
13
14
|
root: {
|
|
14
15
|
display: "flex",
|
|
15
16
|
flexDirection: "column",
|
|
@@ -41,63 +42,57 @@ const i = {
|
|
|
41
42
|
}, x = {
|
|
42
43
|
small: 4,
|
|
43
44
|
medium: 12
|
|
44
|
-
},
|
|
45
|
-
function T(
|
|
46
|
-
const e =
|
|
45
|
+
}, u = ["95%", "80%", "55%", "75%", "60%"];
|
|
46
|
+
function T(t) {
|
|
47
|
+
const e = d(5), {
|
|
47
48
|
rows: l,
|
|
48
|
-
size:
|
|
49
|
-
} =
|
|
50
|
-
let
|
|
51
|
-
e[0] !==
|
|
52
|
-
length:
|
|
53
|
-
}), e[0] =
|
|
54
|
-
let
|
|
55
|
-
return e[2] !==
|
|
56
|
-
/* @__PURE__ */
|
|
57
|
-
/* @__PURE__ */ m(
|
|
58
|
-
/* @__PURE__ */ m(
|
|
49
|
+
size: i
|
|
50
|
+
} = t, a = l === void 0 ? 5 : l, n = i === void 0 ? "small" : i;
|
|
51
|
+
let o;
|
|
52
|
+
e[0] !== a ? (o = Array.from({
|
|
53
|
+
length: a
|
|
54
|
+
}), e[0] = a, e[1] = o) : o = e[1];
|
|
55
|
+
let r;
|
|
56
|
+
return e[2] !== n || e[3] !== o ? (r = /* @__PURE__ */ m(c, { sx: s.root, children: o.map((C, f) => /* @__PURE__ */ g(c, { sx: s.row, children: [
|
|
57
|
+
/* @__PURE__ */ g(c, { sx: s.rowHeader, children: [
|
|
58
|
+
/* @__PURE__ */ m(p, { variant: "rectangular", sx: s.name }),
|
|
59
|
+
/* @__PURE__ */ m(p, { variant: "rectangular", sx: s.value })
|
|
59
60
|
] }),
|
|
60
|
-
/* @__PURE__ */ m(
|
|
61
|
-
height: x[
|
|
62
|
-
width:
|
|
61
|
+
/* @__PURE__ */ m(p, { variant: "rectangular", sx: {
|
|
62
|
+
height: x[n],
|
|
63
|
+
width: u[f % u.length]
|
|
63
64
|
} })
|
|
64
|
-
] }, `row-${
|
|
65
|
+
] }, `row-${f}`)) }), e[2] = n, e[3] = o, e[4] = r) : r = e[4], r;
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
+
function _(t) {
|
|
67
68
|
const e = [];
|
|
68
|
-
return
|
|
69
|
-
filename:
|
|
70
|
-
getCaptureEl:
|
|
71
|
-
pixelRatio:
|
|
72
|
-
backgroundColor:
|
|
73
|
-
})), e.push({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
s.push([n, c.name, c.value]);
|
|
69
|
+
return t.getCaptureEl && e.push(w({
|
|
70
|
+
filename: t.filename,
|
|
71
|
+
getCaptureEl: t.getCaptureEl,
|
|
72
|
+
pixelRatio: t.pngPixelRatio,
|
|
73
|
+
backgroundColor: t.pngBackgroundColor
|
|
74
|
+
})), e.push(h({
|
|
75
|
+
filename: t.filename,
|
|
76
|
+
getRows: () => {
|
|
77
|
+
const l = t.getData(), i = [["series", "name", "value"]];
|
|
78
|
+
for (const [a, n] of l.entries()) {
|
|
79
|
+
const o = t.seriesNames?.[a] ?? `series_${a + 1}`;
|
|
80
|
+
for (const r of n)
|
|
81
|
+
i.push([o, r.name, r.value]);
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
return Promise.resolve({
|
|
85
|
-
url: r.url,
|
|
86
|
-
filename: `${o.filename}.csv`,
|
|
87
|
-
revoke: r.revoke
|
|
88
|
-
});
|
|
83
|
+
return i;
|
|
89
84
|
}
|
|
90
|
-
}), e;
|
|
85
|
+
})), e;
|
|
91
86
|
}
|
|
92
87
|
export {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
88
|
+
N as Category,
|
|
89
|
+
P as CategoryBar,
|
|
90
|
+
$ as CategoryLegend,
|
|
91
|
+
z as CategoryRowMulti,
|
|
92
|
+
G as CategoryRowOther,
|
|
93
|
+
L as CategoryRowSingle,
|
|
99
94
|
T as CategorySkeleton,
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
M as CategoryUI,
|
|
96
|
+
_ as createCategoryDownloadConfig
|
|
102
97
|
};
|
|
103
98
|
//# sourceMappingURL=category.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category.js","sources":["../../src/widgets-v2/category/skeleton.tsx","../../src/widgets-v2/category/download.ts"],"sourcesContent":["import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\nimport type { CategorySize } from './types'\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 1,\n py: 0.5,\n },\n // Mirror the real row layout: label + value on top, bar below.\n row: {\n display: 'flex',\n flexDirection: 'column',\n gap: 0.5,\n },\n rowHeader: {\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n gap: 1,\n },\n // Small fixed-width shimmer pills — matches the visual density of the\n // real label / value cells without claiming the full row width.\n name: { height: 14, width: 80 },\n value: { height: 14, width: 48 },\n} satisfies Record<string, SxProps<Theme>>\n\n// Bar shimmer height matches the live bar track for each size variant so\n// the skeleton doesn't visibly resize the row on data settle.\nconst BAR_HEIGHT: Record<CategorySize, number> = {\n small: 4,\n medium: 12,\n}\n\n// Varied widths give the bar shimmer a more realistic, less uniform feel.\n// Cycles when `rows > WIDTH_PATTERNS.length`.\nconst WIDTH_PATTERNS = ['95%', '80%', '55%', '75%', '60%']\n\nexport interface CategorySkeletonProps {\n rows?: number\n /**\n * Visual density. Mirrors the live widget's `size` prop so the loading\n * shimmer's bar height matches what's about to render — no row jump\n * on data settle.\n */\n size?: CategorySize\n}\n\nexport function CategorySkeleton({\n rows = 5,\n size = 'small',\n}: CategorySkeletonProps) {\n return (\n <Box sx={styles.root}>\n {Array.from({ length: rows }).map((_, i) => (\n <Box key={`row-${i}`} sx={styles.row}>\n <Box sx={styles.rowHeader}>\n <Skeleton variant='rectangular' sx={styles.name} />\n <Skeleton variant='rectangular' sx={styles.value} />\n </Box>\n <Skeleton\n variant='rectangular'\n sx={{\n height: BAR_HEIGHT[size],\n width: WIDTH_PATTERNS[i % WIDTH_PATTERNS.length],\n }}\n />\n </Box>\n ))}\n </Box>\n )\n}\n","import {\n
|
|
1
|
+
{"version":3,"file":"category.js","sources":["../../src/widgets-v2/category/skeleton.tsx","../../src/widgets-v2/category/download.ts"],"sourcesContent":["import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\nimport type { CategorySize } from './types'\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 1,\n py: 0.5,\n },\n // Mirror the real row layout: label + value on top, bar below.\n row: {\n display: 'flex',\n flexDirection: 'column',\n gap: 0.5,\n },\n rowHeader: {\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n gap: 1,\n },\n // Small fixed-width shimmer pills — matches the visual density of the\n // real label / value cells without claiming the full row width.\n name: { height: 14, width: 80 },\n value: { height: 14, width: 48 },\n} satisfies Record<string, SxProps<Theme>>\n\n// Bar shimmer height matches the live bar track for each size variant so\n// the skeleton doesn't visibly resize the row on data settle.\nconst BAR_HEIGHT: Record<CategorySize, number> = {\n small: 4,\n medium: 12,\n}\n\n// Varied widths give the bar shimmer a more realistic, less uniform feel.\n// Cycles when `rows > WIDTH_PATTERNS.length`.\nconst WIDTH_PATTERNS = ['95%', '80%', '55%', '75%', '60%']\n\nexport interface CategorySkeletonProps {\n rows?: number\n /**\n * Visual density. Mirrors the live widget's `size` prop so the loading\n * shimmer's bar height matches what's about to render — no row jump\n * on data settle.\n */\n size?: CategorySize\n}\n\nexport function CategorySkeleton({\n rows = 5,\n size = 'small',\n}: CategorySkeletonProps) {\n return (\n <Box sx={styles.root}>\n {Array.from({ length: rows }).map((_, i) => (\n <Box key={`row-${i}`} sx={styles.row}>\n <Box sx={styles.rowHeader}>\n <Skeleton variant='rectangular' sx={styles.name} />\n <Skeleton variant='rectangular' sx={styles.value} />\n </Box>\n <Skeleton\n variant='rectangular'\n sx={{\n height: BAR_HEIGHT[size],\n width: WIDTH_PATTERNS[i % WIDTH_PATTERNS.length],\n }}\n />\n </Box>\n ))}\n </Box>\n )\n}\n","import {\n buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadItem,\n} from '../actions/download'\nimport type { CategoryWidgetData } from './types'\n\n/**\n * Download menu items for the Category widget. Always includes a CSV item\n * with `series, name, value` columns (one row per item). When\n * `getCaptureEl` is supplied, prepends a PNG item that rasterises the\n * captured element via `html2canvas`.\n */\nexport function createCategoryDownloadConfig(args: {\n filename: string\n getData: () => CategoryWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push(\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: () => {\n const data = args.getData()\n const rows: unknown[][] = [['series', 'name', 'value']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const item of series) {\n rows.push([seriesName, item.name, item.value])\n }\n }\n return rows\n },\n }),\n )\n return items\n}\n"],"names":["styles","root","display","flexDirection","gap","py","row","rowHeader","justifyContent","alignItems","name","height","width","value","BAR_HEIGHT","small","medium","WIDTH_PATTERNS","CategorySkeleton","t0","$","_c","rows","t1","size","t2","undefined","t3","Array","from","length","t4","Box","map","_","i","jsxs","jsx","Skeleton","createCategoryDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","backgroundColor","pngBackgroundColor","buildCsvDownloadItem","getRows","data","getData","series","entries","seriesName","seriesNames","item"],"mappings":";;;;;;;;;;;;AAIA,MAAMA,IAAS;AAAA,EACbC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,KAAK;AAAA,IACLC,IAAI;AAAA,EAAA;AAAA;AAAA,EAGNC,KAAK;AAAA,IACHJ,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,KAAK;AAAA,EAAA;AAAA,EAEPG,WAAW;AAAA,IACTL,SAAS;AAAA,IACTM,gBAAgB;AAAA,IAChBC,YAAY;AAAA,IACZL,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA,EAIPM,MAAM;AAAA,IAAEC,QAAQ;AAAA,IAAIC,OAAO;AAAA,EAAA;AAAA,EAC3BC,OAAO;AAAA,IAAEF,QAAQ;AAAA,IAAIC,OAAO;AAAA,EAAA;AAC9B,GAIME,IAA2C;AAAA,EAC/CC,OAAO;AAAA,EACPC,QAAQ;AACV,GAIMC,IAAiB,CAAC,OAAO,OAAO,OAAO,OAAO,KAAK;AAYlD,SAAAC,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAA0B;AAAA,IAAAC,MAAAC;AAAAA,IAAAC,MAAAC;AAAAA,EAAAA,IAAAN,GAC/BG,IAAAC,MAAAG,SAAA,IAAAH,GACAC,IAAAC,MAAAC,SAAA,UAAAD;AAAc,MAAAE;AAAA,EAAAP,SAAAE,KAITK,IAAAC,MAAKC,KAAM;AAAA,IAAAC,QAAUR;AAAAA,EAAAA,CAAM,GAACF,OAAAE,GAAAF,OAAAO,KAAAA,IAAAP,EAAA,CAAA;AAAA,MAAAW;AAAA,SAAAX,EAAA,CAAA,MAAAI,KAAAJ,SAAAO,KAD/BI,sBAACC,GAAA,EAAQ,IAAAhC,EAAMC,MACZ0B,UAAAA,EAA4BM,IAAK,CAAAC,GAAAC,MAChC,gBAAAC,EAACJ,GAAA,EAAyB,IAAAhC,EAA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GACOmB;AACT;"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { D as
|
|
2
|
-
import { N, P as
|
|
1
|
+
import { D as P, F as E, a as R } from "../formula-DuC0NQLH.js";
|
|
2
|
+
import { N, P as V, S as _, a as $, V as j } from "../style-DVnT6HC1.js";
|
|
3
3
|
import { jsx as i } from "react/jsx-runtime";
|
|
4
|
-
import { c as
|
|
5
|
-
import { Box as m, Skeleton as
|
|
4
|
+
import { c as l } from "react/compiler-runtime";
|
|
5
|
+
import { Box as m, Skeleton as s } from "@mui/material";
|
|
6
6
|
import "react";
|
|
7
7
|
import "@mui/icons-material";
|
|
8
8
|
import "../lasso-tool-CDFj4zKY.js";
|
|
9
9
|
import "../cjs-D4KH3azB.js";
|
|
10
10
|
import "@carto/ps-utils";
|
|
11
|
-
import
|
|
12
|
-
import { b as
|
|
13
|
-
|
|
11
|
+
import "html2canvas";
|
|
12
|
+
import { b as u } from "../png-item-9dNbB37T.js";
|
|
13
|
+
import { b as f } from "../csv-item-hH_Gt7ur.js";
|
|
14
|
+
const n = {
|
|
14
15
|
root: {
|
|
15
16
|
display: "flex",
|
|
16
17
|
gap: 3,
|
|
@@ -23,52 +24,45 @@ const l = {
|
|
|
23
24
|
height: 36
|
|
24
25
|
}
|
|
25
26
|
};
|
|
26
|
-
function F(
|
|
27
|
-
const e =
|
|
28
|
-
count:
|
|
29
|
-
} =
|
|
30
|
-
let
|
|
31
|
-
return e[0] !== r ? (
|
|
27
|
+
function F(t) {
|
|
28
|
+
const e = l(2), {
|
|
29
|
+
count: a
|
|
30
|
+
} = t, r = a === void 0 ? 1 : a;
|
|
31
|
+
let o;
|
|
32
|
+
return e[0] !== r ? (o = /* @__PURE__ */ i(m, { sx: n.root, children: Array.from({
|
|
32
33
|
length: r
|
|
33
|
-
}).map(
|
|
34
|
+
}).map(p) }), e[0] = r, e[1] = o) : o = e[1], o;
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
-
return /* @__PURE__ */ i(
|
|
36
|
+
function p(t, e) {
|
|
37
|
+
return /* @__PURE__ */ i(s, { variant: "rectangular", sx: n.block }, `row-${e}`);
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function S(t) {
|
|
39
40
|
const e = [];
|
|
40
|
-
return
|
|
41
|
-
filename:
|
|
42
|
-
getCaptureEl:
|
|
43
|
-
pixelRatio:
|
|
44
|
-
backgroundColor:
|
|
45
|
-
})), e.push({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
r.push([a.series?.name ?? "", a.prefix ?? "", a.value, a.suffix ?? "", a.note ?? "", a.delta?.value ?? ""]);
|
|
53
|
-
const t = f(r);
|
|
54
|
-
return Promise.resolve({
|
|
55
|
-
url: t.url,
|
|
56
|
-
filename: `${o.filename}.csv`,
|
|
57
|
-
revoke: t.revoke
|
|
58
|
-
});
|
|
41
|
+
return t.getCaptureEl && e.push(u({
|
|
42
|
+
filename: t.filename,
|
|
43
|
+
getCaptureEl: t.getCaptureEl,
|
|
44
|
+
pixelRatio: t.pngPixelRatio,
|
|
45
|
+
backgroundColor: t.pngBackgroundColor
|
|
46
|
+
})), e.push(f({
|
|
47
|
+
filename: t.filename,
|
|
48
|
+
getRows: () => {
|
|
49
|
+
const a = t.getData(), r = [["series", "prefix", "value", "suffix", "note", "delta"]];
|
|
50
|
+
for (const o of a)
|
|
51
|
+
r.push([o.series?.name ?? "", o.prefix ?? "", o.value, o.suffix ?? "", o.note ?? "", o.delta?.value ?? ""]);
|
|
52
|
+
return r;
|
|
59
53
|
}
|
|
60
|
-
}), e;
|
|
54
|
+
})), e;
|
|
61
55
|
}
|
|
62
56
|
export {
|
|
63
|
-
|
|
57
|
+
P as Delta,
|
|
64
58
|
E as Formula,
|
|
65
59
|
F as FormulaSkeleton,
|
|
66
|
-
|
|
60
|
+
R as FormulaUI,
|
|
67
61
|
N as Note,
|
|
68
|
-
|
|
62
|
+
V as Prefix,
|
|
69
63
|
_ as Series,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
$ as Suffix,
|
|
65
|
+
j as Value,
|
|
66
|
+
S as createFormulaDownloadConfig
|
|
73
67
|
};
|
|
74
68
|
//# sourceMappingURL=formula.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formula.js","sources":["../../src/widgets-v2/formula/skeleton.tsx","../../src/widgets-v2/formula/download.tsx"],"sourcesContent":["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
|
|
1
|
+
{"version":3,"file":"formula.js","sources":["../../src/widgets-v2/formula/skeleton.tsx","../../src/widgets-v2/formula/download.tsx"],"sourcesContent":["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"],"names":["styles","root","display","gap","alignItems","minHeight","py","block","width","height","FormulaSkeleton","t0","$","_c","count","t1","undefined","t2","Box","Array","from","length","map","_temp","_","i","jsx","Skeleton","createFormulaDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","backgroundColor","pngBackgroundColor","buildCsvDownloadItem","getRows","data","getData","rows","d","series","name","prefix","value","suffix","note","delta"],"mappings":";;;;;;;;;;;;;AAGA,MAAMA,IAAS;AAAA,EACbC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,KAAK;AAAA,IACLC,YAAY;AAAA,IACZC,WAAW;AAAA,IACXC,IAAI;AAAA,EAAA;AAAA,EAENC,OAAO;AAAA,IAAEC,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