@carto/ps-react-ui 4.11.2 → 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/types/widgets-v2/wrapper/style.d.ts +5 -12
- 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 +247 -243
- package/dist/widgets-v2.js.map +1 -1
- package/package.json +3 -3
- 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/src/widgets-v2/wrapper/style.ts +13 -18
- package/src/widgets-v2/wrapper/widget-wrapper.test.tsx +66 -0
- package/src/widgets-v2/wrapper/widget-wrapper.tsx +7 -4
- 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":"scatterplot.js","sources":["../../src/widgets-v2/scatterplot/options.ts","../../src/widgets-v2/scatterplot/skeleton.tsx","../../src/widgets-v2/scatterplot/download.ts","../../src/widgets-v2/scatterplot/transforms.ts"],"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 type {\n ScatterplotEChartsOption,\n ScatterplotOptionFactoryInput,\n ScatterplotOptionsInput,\n ScatterplotWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a scatterplot widget — both\n * axes `type: 'value'` (not category, unlike Bar/Histogram), grid, tooltip\n * triggered per-item rather than per-axis. Intentionally data-agnostic: no\n * series, no dataset, no `legend.show` (those depend on data and are added\n * by {@link createScatterplotOptionFactory}).\n *\n * Styling parity with v1: dark themed tooltip via `createTooltipFormatter`\n * + `createTooltipPositioner`, `buildGridConfig`-based grid, polished\n * axisLine/Tick/splitLine, `overlineDelicate` axis labels, structural\n * legend wired via `buildLegendConfig` (toggled by the merger), and the\n * CARTO `qualitative.bold + secondary` palette — same pattern bar /\n * histogram / pie already use. {@link createScatterplotOptionFactory}\n * wraps this builder in its structural-phase branch.\n */\nexport function scatterplotOptions({\n theme,\n xFormatter,\n yFormatter,\n}: ScatterplotOptionsInput): ScatterplotEChartsOption {\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 `bottom` when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n // Per-point trigger — different from Bar's 'axis' trigger because\n // points don't share an x-coordinate.\n trigger: 'item',\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 position: createTooltipPositioner(theme),\n formatter: buildScatterTooltipFormatter(xFormatter, yFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false, labelFormatter: undefined }),\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: 'value',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n color: theme.palette.black?.[60],\n margin: parseInt(theme.spacing(1)),\n hideOverlap: true,\n showMinLabel: true,\n showMaxLabel: true,\n ...(xFormatter && { formatter: xFormatter }),\n },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n },\n yAxis: {\n type: 'value',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n color: theme.palette.black?.[60],\n margin: parseInt(theme.spacing(1)),\n hideOverlap: true,\n showMinLabel: true,\n showMaxLabel: true,\n ...(yFormatter && { formatter: yFormatter }),\n },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n },\n } as ScatterplotEChartsOption\n}\n\n/**\n * Returns the scatterplot widget's {@link OptionFactory} — one closure\n * that owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link scatterplotOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`ScatterplotWidgetData`) into the option via the dataset API. Each\n * series's `[x, y]` tuples land in `dataset[i].source` as 2-column\n * rows; the series uses positional encoding (`encode: { x: 0, y: 1 }`)\n * and `type: 'scatter'`. niceMin/niceMax are computed over both axes\n * so the chart frames data on rounded extents and numeric jitters\n * don't shift gridlines per render. Reactive `ctx.formatter` (driven\n * by RelativeData) re-derives the y-axis label and tooltip at fusion\n * time; `xFormatter` stays baked at structural-build time (relative\n * is a values-axis concept; x is coordinate-space).\n *\n * When `ZoomToggle` installs a `dataZoom` slider, grid bottom is\n * extended and the slider is positioned above the legend row (if any) —\n * same layout dance bar / histogram / timeseries do.\n */\nexport function createScatterplotOptionFactory(\n options: ScatterplotOptionFactoryInput,\n): OptionFactory {\n const { theme, xFormatter, yFormatter, optionsOverride } = options\n const series = options.series\n const symbolSize = options.symbolSize ?? 8\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0 ? new Set<string>(selection) : null\n return (option, data, ctx) => {\n if (option == null) {\n const structural = scatterplotOptions({ theme, xFormatter, yFormatter })\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 ScatterplotWidgetData) : []\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 baseXAxis =\n typeof option.xAxis === 'object' && !Array.isArray(option.xAxis)\n ? option.xAxis\n : {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n\n const reactiveFormatter = ctx?.formatter\n\n const { niceMinX, niceMaxX, niceMinY, niceMaxY } =\n computeScatterBounds(seriesArr)\n\n // Dim non-selected points via `series.itemStyle.color`. The selection\n // key is `${seriesIndex}:${dataIndex}`; we read those off the params\n // ECharts hands to the callback per-data.\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 items would stay dimmed forever after an external clear.\n // Keeping the key always-present means a plain setOption merge swaps\n // the callback in place, no `replaceMerge` and no entry-animation\n // flash on selection on/off.\n const makeDimColor =\n (seriesIdx: number) => (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n const key = `${seriesIdx}:${params.dataIndex}`\n return selectionSet.has(key)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`,\n // reserve grid space and lift any x-slider above the legend (if\n // present). Scatter supports 2D zoom via `axes: ['x', 'y']` — in\n // that case there's also a vertical y-slider on the right edge, so\n // we reserve `grid.right` separately. Inside-only dataZoom entries\n // (no `type: 'slider'`) take no grid space.\n const dataZoomLayout = layoutDataZoomForScatter(option.dataZoom, hasLegend)\n const hasXSlider = dataZoomLayout?.hasXSlider ?? false\n const hasYSlider = dataZoomLayout?.hasYSlider ?? false\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = hasXSlider\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n const fallbackRight =\n typeof baseGrid.right === 'number' ? baseGrid.right : 8\n const gridRight = hasYSlider\n ? fallbackRight + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : fallbackRight\n\n return {\n ...option,\n // ECharts dataset.source wants a mutable [number, number][] shape; we\n // hold readonly tuples internally, so cast at the boundary.\n dataset: seriesArr.map((s) => ({ source: s as unknown as number[][] })),\n series: seriesArr.map((_, i) => {\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n type: 'scatter' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 0, y: 1 },\n symbolSize,\n emphasis: { focus: 'series' },\n itemStyle: { color: makeDimColor(i) },\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom, right: gridRight },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout.entries } : {}),\n xAxis: {\n ...baseXAxis,\n min: niceMinX,\n max: niceMaxX,\n } as EChartsOption['xAxis'],\n yAxis: {\n ...baseYAxis,\n min: niceMinY,\n max: niceMaxY,\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n // Re-derive the y-axis formatter at fusion time so RelativeData's\n // percent formatter (written to `state.formatter`) flows through\n // without rebuilding the structural option. Falls back to the\n // structural `yFormatter` already baked in `baseYAxis.axisLabel`\n // (which `String(value)` if neither is set).\n ...(reactiveFormatter ? { formatter: reactiveFormatter } : {}),\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n // Rebuild the tooltip formatter so the live y-axis formatter is\n // applied to the y-coordinate in the (x, y) label. xFormatter is\n // structural — relative is a values-axis concept, so xFormatter\n // doesn't change under RelativeData.\n formatter: buildReactiveScatterTooltipFormatter(\n (baseTooltip as { formatter?: unknown }).formatter,\n reactiveFormatter,\n xFormatter,\n ),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Lay out the `dataZoom` array for the scatter chart:\n * - Detect whether any horizontal (x-axis) slider is present — if so\n * lift it above the legend row when a legend is shown.\n * - Detect whether any vertical (y-axis) slider is present — the\n * caller reserves `grid.right` so the slider doesn't overlap the\n * plot area.\n *\n * Returns `null` when there's no `dataZoom` so callers can skip the\n * layout adjustment entirely. An entry is considered an \"x-slider\" if\n * it has `xAxisIndex` set (or no axis index — defaults to x in ECharts).\n * A \"y-slider\" has `yAxisIndex` set.\n */\nfunction layoutDataZoomForScatter(\n dataZoom: unknown,\n hasLegend: boolean,\n): { entries: unknown[]; hasXSlider: boolean; hasYSlider: boolean } | null {\n if (!Array.isArray(dataZoom) || dataZoom.length === 0) return null\n let hasXSlider = false\n let hasYSlider = false\n const entries = dataZoom.map((entry: unknown) => {\n if (entry == null || typeof entry !== 'object') return entry\n const dz = entry as {\n type?: string\n xAxisIndex?: unknown\n yAxisIndex?: unknown\n bottom?: number\n }\n if (dz.type !== 'slider') return dz\n const targetsY = dz.yAxisIndex !== undefined\n if (targetsY) {\n hasYSlider = true\n return dz\n }\n // Either explicit x or defaulted (ECharts defaults sliders to xAxis\n // when no axis index is provided).\n hasXSlider = true\n if (hasLegend) {\n return { ...dz, bottom: ZOOM_LAYOUT.sliderBottomWithLegend }\n }\n return dz\n })\n return { entries, hasXSlider, hasYSlider }\n}\n\n/**\n * If a reactive (store-driven) y formatter is provided, re-build the\n * scatter tooltip formatter using it. Otherwise, return the structural\n * formatter unchanged so the original `xFormatter` / `yFormatter`\n * baked into `scatterplotOptions` still applies. The structural\n * formatter has stable identity per `scatterplotOptions` call, so this\n * path doesn't churn ECharts on every render.\n */\nfunction buildReactiveScatterTooltipFormatter(\n structuralFormatter: unknown,\n reactiveYFormatter: ((value: number) => string) | undefined,\n xFormatter: ((value: number) => string) | undefined,\n) {\n if (!reactiveYFormatter) return structuralFormatter\n return createTooltipFormatter((item) => {\n const value = item.value as readonly [number, number] | undefined\n const x = value?.[0]\n const y = value?.[1]\n const formattedX =\n typeof x === 'number' ? (xFormatter ? xFormatter(x) : String(x)) : ''\n const formattedY =\n typeof y === 'number' ? reactiveYFormatter(y) : String(y ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: `(${formattedX}, ${formattedY})`,\n seriesName,\n marker,\n value: '',\n }\n })\n}\n\nfunction buildScatterTooltipFormatter(\n xFormatter: ((value: number) => string) | undefined,\n yFormatter: ((value: number) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const value = item.value as readonly [number, number] | undefined\n const x = value?.[0]\n const y = value?.[1]\n const formattedX =\n typeof x === 'number' ? (xFormatter ? xFormatter(x) : String(x)) : ''\n const formattedY =\n typeof y === 'number' ? (yFormatter ? yFormatter(y) : String(y)) : ''\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: `(${formattedX}, ${formattedY})`,\n seriesName,\n marker,\n value: '',\n }\n })\n}\n\nfunction computeScatterBounds(seriesArr: ScatterplotWidgetData): {\n niceMinX: number\n niceMaxX: number\n niceMinY: number\n niceMaxY: number\n} {\n let minX = Infinity\n let maxX = -Infinity\n let minY = Infinity\n let maxY = -Infinity\n for (const series of seriesArr) {\n for (const point of series) {\n const x = point?.[0]\n const y = point?.[1]\n if (typeof x === 'number' && Number.isFinite(x)) {\n if (x < minX) minX = x\n if (x > maxX) maxX = x\n }\n if (typeof y === 'number' && Number.isFinite(y)) {\n if (y < minY) minY = y\n if (y > maxY) maxY = y\n }\n }\n }\n // Mirror bar's `computeNiceBounds`: clamp min to 0 when data is\n // non-negative (gridline reads cleanly from zero), apply `niceNum` to\n // negative mins, and floor max=0 to 1 so the chart always has range.\n // Scatter can have free coordinates so we apply this per-axis.\n const niceMaxX = Number.isFinite(maxX) ? (maxX <= 0 ? 1 : niceNum(maxX)) : 1\n const niceMaxY = Number.isFinite(maxY) ? (maxY <= 0 ? 1 : niceNum(maxY)) : 1\n const niceMinX = Number.isFinite(minX) ? (minX < 0 ? niceNum(minX) : 0) : 0\n const niceMinY = Number.isFinite(minY) ? (minY < 0 ? niceNum(minY) : 0) : 0\n return { niceMinX, niceMaxX, niceMinY, niceMaxY }\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, 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 position: 'relative',\n flex: '1 1 auto',\n width: '100%',\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\n// `sx` callback that needs runtime args — extracted at module scope so the\n// `styles` object can satisfy `Record<string, SxProps<Theme>>` cleanly\n// (function `sx`-with-args isn't assignable to plain `SxProps<Theme>`).\nconst dotSx = (top: string, left: string, size: number): SxProps<Theme> => ({\n position: 'absolute',\n top,\n left,\n width: size,\n height: size,\n borderRadius: '50%',\n})\n\nexport interface ScatterplotSkeletonProps {\n /** Number of dots to render. */\n count?: number\n}\n\n/**\n * Loading state for the Scatterplot widget. Mirrors a scatter chart's\n * silhouette — a deterministic spread of small circular dots in the plot\n * area plus a legend stub — so the skeleton reads as \"a scatter chart\"\n * rather than a generic list. Matches bar/histogram/pie skeleton structure\n * (grid stub + legend stub in a flex column).\n */\nexport function ScatterplotSkeleton({ count = 24 }: ScatterplotSkeletonProps) {\n // Deterministic pseudo-scatter positions so the skeleton doesn't flicker.\n const dots = Array.from({ length: count }, (_, i) => {\n const top = 10 + ((i * 37) % 80)\n const left = 5 + ((i * 53) % 90)\n const size = 8 + ((i * 7) % 6)\n return { top: `${top}%`, left: `${left}%`, size }\n })\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\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 buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { ScatterplotWidgetData } from './types'\n\n/**\n * Download menu items for the Scatterplot widget. Always includes a CSV\n * item with `series, x, y` columns (one row per point). When\n * `getCaptureEl` is supplied, prepends a PNG item that rasterises the\n * captured element via `html2canvas`.\n */\nexport function createScatterplotDownloadConfig(args: {\n filename: string\n getData: () => ScatterplotWidgetData\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 id: 'csv',\n label: 'Download as CSV',\n resolve: () => {\n const data = args.getData()\n const rows: unknown[][] = [['series', 'x', 'y']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const [x, y] of series) {\n rows.push([seriesName, x, y])\n }\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","/**\n * Scatterplot-specific `RelativeData` transform. Scatter data is\n * `[number, number][]` — each series is a list of `[x, y]` tuples.\n * Relative is a values-axis concept, so this rewrites `y` to its\n * share of the series's total `y` (0–100) and leaves `x` raw — x is\n * coordinate space, not part of the cohort total.\n *\n * Pass to `<Widget.RelativeData transform={toRelativeScatterplotData} />`.\n *\n * The denominator is the sum of |y| across the series so mixed-sign\n * y values produce sane signed shares-of-magnitude. A series whose\n * total y-magnitude is zero (all-zero or empty input) is returned\n * unchanged so a stalled or empty data set doesn't show misleading 0%\n * values. Inputs whose shape isn't `[number, number][]` fall through\n * untouched.\n */\nexport const toRelativeScatterplotData = (input: unknown): unknown => {\n if (!Array.isArray(input)) return input\n return input.map((series: unknown): unknown => {\n if (!isXyTupleArray(series)) return series\n const total = series.reduce((acc, [, y]) => acc + Math.abs(y), 0)\n if (total <= 0) return series\n return series.map(([x, y]) => [x, (y / total) * 100] as [number, number])\n })\n}\n\nfunction isXyTupleArray(v: unknown): v is [number, number][] {\n if (!Array.isArray(v)) return false\n return v.every(\n (item) =>\n Array.isArray(item) &&\n item.length === 2 &&\n typeof item[0] === 'number' &&\n Number.isFinite(item[0]) &&\n typeof item[1] === 'number' &&\n Number.isFinite(item[1]),\n )\n}\n"],"names":["scatterplotOptions","theme","xFormatter","yFormatter","grid","left","parseInt","spacing","top","right","buildGridConfig","containLabel","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","textStyle","color","common","white","fontSize","fontFamily","typography","caption","position","createTooltipPositioner","formatter","buildScatterTooltipFormatter","legend","buildLegendConfig","hasLegend","labelFormatter","undefined","axisPointer","lineStyle","secondary","main","Object","values","qualitative","bold","xAxis","type","axisLine","show","axisTick","axisLabel","overlineDelicate","black","margin","hideOverlap","showMinLabel","showMaxLabel","splitLine","divider","yAxis","createScatterplotOptionFactory","options","optionsOverride","series","symbolSize","selection","selectionSet","length","Set","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","baseLegend","baseGrid","baseTooltip","baseXAxis","baseYAxis","reactiveFormatter","niceMinX","niceMaxX","niceMinY","niceMaxY","computeScatterBounds","makeDimColor","seriesIdx","params","base","key","dataIndex","has","echarts","modifyAlpha","dataZoomLayout","layoutDataZoomForScatter","dataZoom","hasXSlider","hasYSlider","fallbackBottom","bottom","baseBottom","gridBottom","ZOOM_LAYOUT","sliderHeight","sliderGap","fallbackRight","gridRight","map","s","source","_","i","overrideColor","resolveThemeColor","datasetIndex","name","encode","x","y","emphasis","focus","itemStyle","entries","min","max","buildReactiveScatterTooltipFormatter","entry","dz","yAxisIndex","sliderBottomWithLegend","structuralFormatter","reactiveYFormatter","createTooltipFormatter","item","value","formattedX","String","formattedY","marker","seriesName","minX","Infinity","maxX","minY","maxY","point","Number","isFinite","niceNum","styles","container","display","alignItems","justifyContent","flexDirection","gap","height","flex","width","legendItem","dotSx","size","borderRadius","ScatterplotSkeleton","t0","$","_c","count","t1","T0","T1","t2","t3","t4","dots","from","_temp","Box","_temp2","t5","jsx","t6","Symbol","for","_temp3","t7","i_1","jsxs","Skeleton","d","i_0","createScatterplotDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","id","label","resolve","getData","rows","seriesNames","handle","downloadToCSV","Promise","url","revoke","toRelativeScatterplotData","input","isXyTupleArray","total","reduce","acc","Math","abs","v","every"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,SAASA,GAAmB;AAAA,EACjCC,OAAAA;AAAAA,EACAC,YAAAA;AAAAA,EACAC,YAAAA;AACuB,GAA6B;AACpD,SAAO;AAAA,IACLC,MAAM;AAAA,MACJC,MAAMC,SAASL,EAAMM,QAAQ,CAAC,CAAC;AAAA,MAC/BC,KAAKF,SAASL,EAAMM,QAAQ,CAAC,CAAC;AAAA,MAC9BE,OAAOH,SAASL,EAAMM,QAAQ,CAAC,CAAC;AAAA;AAAA,MAEhC,GAAGG,EAAgB,IAAOT,CAAK;AAAA,MAC/BU,cAAc;AAAA,IAAA;AAAA,IAEhBC,SAAS;AAAA;AAAA;AAAA,MAGPC,SAAS;AAAA,MACTC,iBAAiBb,EAAMc,QAAQC,KAAK,GAAG;AAAA,MACvCC,aAAa;AAA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AACT;ACrCO,MAAMmB,KAA4BA,CAACC,MACnC/I,MAAMC,QAAQ8I,CAAK,IACjBA,EAAM1G,IAAI,CAACjD,MAA6B;AAC7C,MAAI,CAAC4J,GAAe5J,CAAM,EAAG,QAAOA;AACpC,QAAM6J,IAAQ7J,EAAO8J,OAAO,CAACC,GAAK,CAAA,EAAGnG,CAAC,MAAMmG,IAAMC,KAAKC,IAAIrG,CAAC,GAAG,CAAC;AAChE,SAAIiG,KAAS,IAAU7J,IAChBA,EAAOiD,IAAI,CAAC,CAACU,GAAGC,CAAC,MAAM,CAACD,GAAIC,IAAIiG,IAAS,GAAG,CAAqB;AAC1E,CAAC,IANiCF;AASpC,SAASC,GAAeM,GAAqC;AAC3D,SAAKtJ,MAAMC,QAAQqJ,CAAC,IACbA,EAAEC,MACNxF,CAAAA,MACC/D,MAAMC,QAAQ8D,CAAI,KAClBA,EAAKvE,WAAW,KAChB,OAAOuE,EAAK,CAAC,KAAM,YACnBa,OAAOC,SAASd,EAAK,CAAC,CAAC,KACvB,OAAOA,EAAK,CAAC,KAAM,YACnBa,OAAOC,SAASd,EAAK,CAAC,CAAC,CAC3B,IAT8B;AAUhC;"}
|
|
1
|
+
{"version":3,"file":"scatterplot.js","sources":["../../src/widgets-v2/scatterplot/options.ts","../../src/widgets-v2/scatterplot/skeleton.tsx","../../src/widgets-v2/scatterplot/download.ts","../../src/widgets-v2/scatterplot/transforms.ts"],"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 type {\n ScatterplotEChartsOption,\n ScatterplotOptionFactoryInput,\n ScatterplotOptionsInput,\n ScatterplotWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a scatterplot widget — both\n * axes `type: 'value'` (not category, unlike Bar/Histogram), grid, tooltip\n * triggered per-item rather than per-axis. Intentionally data-agnostic: no\n * series, no dataset, no `legend.show` (those depend on data and are added\n * by {@link createScatterplotOptionFactory}).\n *\n * Styling parity with v1: dark themed tooltip via `createTooltipFormatter`\n * + `createTooltipPositioner`, `buildGridConfig`-based grid, polished\n * axisLine/Tick/splitLine, `overlineDelicate` axis labels, structural\n * legend wired via `buildLegendConfig` (toggled by the merger), and the\n * CARTO `qualitative.bold + secondary` palette — same pattern bar /\n * histogram / pie already use. {@link createScatterplotOptionFactory}\n * wraps this builder in its structural-phase branch.\n */\nexport function scatterplotOptions({\n theme,\n xFormatter,\n yFormatter,\n}: ScatterplotOptionsInput): ScatterplotEChartsOption {\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 `bottom` when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n // Per-point trigger — different from Bar's 'axis' trigger because\n // points don't share an x-coordinate.\n trigger: 'item',\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 position: createTooltipPositioner(theme),\n formatter: buildScatterTooltipFormatter(xFormatter, yFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false, labelFormatter: undefined }),\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: 'value',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n color: theme.palette.black?.[60],\n margin: parseInt(theme.spacing(1)),\n hideOverlap: true,\n showMinLabel: true,\n showMaxLabel: true,\n ...(xFormatter && { formatter: xFormatter }),\n },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n },\n yAxis: {\n type: 'value',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n color: theme.palette.black?.[60],\n margin: parseInt(theme.spacing(1)),\n hideOverlap: true,\n showMinLabel: true,\n showMaxLabel: true,\n ...(yFormatter && { formatter: yFormatter }),\n },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n },\n } as ScatterplotEChartsOption\n}\n\n/**\n * Returns the scatterplot widget's {@link OptionFactory} — one closure\n * that owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link scatterplotOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`ScatterplotWidgetData`) into the option via the dataset API. Each\n * series's `[x, y]` tuples land in `dataset[i].source` as 2-column\n * rows; the series uses positional encoding (`encode: { x: 0, y: 1 }`)\n * and `type: 'scatter'`. niceMin/niceMax are computed over both axes\n * so the chart frames data on rounded extents and numeric jitters\n * don't shift gridlines per render. Reactive `ctx.formatter` (driven\n * by RelativeData) re-derives the y-axis label and tooltip at fusion\n * time; `xFormatter` stays baked at structural-build time (relative\n * is a values-axis concept; x is coordinate-space).\n *\n * When `ZoomToggle` installs a `dataZoom` slider, grid bottom is\n * extended and the slider is positioned above the legend row (if any) —\n * same layout dance bar / histogram / timeseries do.\n */\nexport function createScatterplotOptionFactory(\n options: ScatterplotOptionFactoryInput,\n): OptionFactory {\n const { theme, xFormatter, yFormatter, optionsOverride } = options\n const series = options.series\n const symbolSize = options.symbolSize ?? 8\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0 ? new Set<string>(selection) : null\n return (option, data, ctx) => {\n if (option == null) {\n const structural = scatterplotOptions({ theme, xFormatter, yFormatter })\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 ScatterplotWidgetData) : []\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 baseXAxis =\n typeof option.xAxis === 'object' && !Array.isArray(option.xAxis)\n ? option.xAxis\n : {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n\n const reactiveFormatter = ctx?.formatter\n\n const { niceMinX, niceMaxX, niceMinY, niceMaxY } =\n computeScatterBounds(seriesArr)\n\n // Dim non-selected points via `series.itemStyle.color`. The selection\n // key is `${seriesIndex}:${dataIndex}`; we read those off the params\n // ECharts hands to the callback per-data.\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 items would stay dimmed forever after an external clear.\n // Keeping the key always-present means a plain setOption merge swaps\n // the callback in place, no `replaceMerge` and no entry-animation\n // flash on selection on/off.\n const makeDimColor =\n (seriesIdx: number) => (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n const key = `${seriesIdx}:${params.dataIndex}`\n return selectionSet.has(key)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`,\n // reserve grid space and lift any x-slider above the legend (if\n // present). Scatter supports 2D zoom via `axes: ['x', 'y']` — in\n // that case there's also a vertical y-slider on the right edge, so\n // we reserve `grid.right` separately. Inside-only dataZoom entries\n // (no `type: 'slider'`) take no grid space.\n const dataZoomLayout = layoutDataZoomForScatter(option.dataZoom, hasLegend)\n const hasXSlider = dataZoomLayout?.hasXSlider ?? false\n const hasYSlider = dataZoomLayout?.hasYSlider ?? false\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = hasXSlider\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n const fallbackRight =\n typeof baseGrid.right === 'number' ? baseGrid.right : 8\n const gridRight = hasYSlider\n ? fallbackRight + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : fallbackRight\n\n return {\n ...option,\n // ECharts dataset.source wants a mutable [number, number][] shape; we\n // hold readonly tuples internally, so cast at the boundary.\n dataset: seriesArr.map((s) => ({ source: s as unknown as number[][] })),\n series: seriesArr.map((_, i) => {\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n type: 'scatter' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 0, y: 1 },\n symbolSize,\n emphasis: { focus: 'series' },\n itemStyle: { color: makeDimColor(i) },\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom, right: gridRight },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout.entries } : {}),\n xAxis: {\n ...baseXAxis,\n min: niceMinX,\n max: niceMaxX,\n } as EChartsOption['xAxis'],\n yAxis: {\n ...baseYAxis,\n min: niceMinY,\n max: niceMaxY,\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n // Re-derive the y-axis formatter at fusion time so RelativeData's\n // percent formatter (written to `state.formatter`) flows through\n // without rebuilding the structural option. Falls back to the\n // structural `yFormatter` already baked in `baseYAxis.axisLabel`\n // (which `String(value)` if neither is set).\n ...(reactiveFormatter ? { formatter: reactiveFormatter } : {}),\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n // Rebuild the tooltip formatter so the live y-axis formatter is\n // applied to the y-coordinate in the (x, y) label. xFormatter is\n // structural — relative is a values-axis concept, so xFormatter\n // doesn't change under RelativeData.\n formatter: buildReactiveScatterTooltipFormatter(\n (baseTooltip as { formatter?: unknown }).formatter,\n reactiveFormatter,\n xFormatter,\n ),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Lay out the `dataZoom` array for the scatter chart:\n * - Detect whether any horizontal (x-axis) slider is present — if so\n * lift it above the legend row when a legend is shown.\n * - Detect whether any vertical (y-axis) slider is present — the\n * caller reserves `grid.right` so the slider doesn't overlap the\n * plot area.\n *\n * Returns `null` when there's no `dataZoom` so callers can skip the\n * layout adjustment entirely. An entry is considered an \"x-slider\" if\n * it has `xAxisIndex` set (or no axis index — defaults to x in ECharts).\n * A \"y-slider\" has `yAxisIndex` set.\n */\nfunction layoutDataZoomForScatter(\n dataZoom: unknown,\n hasLegend: boolean,\n): { entries: unknown[]; hasXSlider: boolean; hasYSlider: boolean } | null {\n if (!Array.isArray(dataZoom) || dataZoom.length === 0) return null\n let hasXSlider = false\n let hasYSlider = false\n const entries = dataZoom.map((entry: unknown) => {\n if (entry == null || typeof entry !== 'object') return entry\n const dz = entry as {\n type?: string\n xAxisIndex?: unknown\n yAxisIndex?: unknown\n bottom?: number\n }\n if (dz.type !== 'slider') return dz\n const targetsY = dz.yAxisIndex !== undefined\n if (targetsY) {\n hasYSlider = true\n return dz\n }\n // Either explicit x or defaulted (ECharts defaults sliders to xAxis\n // when no axis index is provided).\n hasXSlider = true\n if (hasLegend) {\n return { ...dz, bottom: ZOOM_LAYOUT.sliderBottomWithLegend }\n }\n return dz\n })\n return { entries, hasXSlider, hasYSlider }\n}\n\n/**\n * If a reactive (store-driven) y formatter is provided, re-build the\n * scatter tooltip formatter using it. Otherwise, return the structural\n * formatter unchanged so the original `xFormatter` / `yFormatter`\n * baked into `scatterplotOptions` still applies. The structural\n * formatter has stable identity per `scatterplotOptions` call, so this\n * path doesn't churn ECharts on every render.\n */\nfunction buildReactiveScatterTooltipFormatter(\n structuralFormatter: unknown,\n reactiveYFormatter: ((value: number) => string) | undefined,\n xFormatter: ((value: number) => string) | undefined,\n) {\n if (!reactiveYFormatter) return structuralFormatter\n return createTooltipFormatter((item) => {\n const value = item.value as readonly [number, number] | undefined\n const x = value?.[0]\n const y = value?.[1]\n const formattedX =\n typeof x === 'number' ? (xFormatter ? xFormatter(x) : String(x)) : ''\n const formattedY =\n typeof y === 'number' ? reactiveYFormatter(y) : String(y ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: `(${formattedX}, ${formattedY})`,\n seriesName,\n marker,\n value: '',\n }\n })\n}\n\nfunction buildScatterTooltipFormatter(\n xFormatter: ((value: number) => string) | undefined,\n yFormatter: ((value: number) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const value = item.value as readonly [number, number] | undefined\n const x = value?.[0]\n const y = value?.[1]\n const formattedX =\n typeof x === 'number' ? (xFormatter ? xFormatter(x) : String(x)) : ''\n const formattedY =\n typeof y === 'number' ? (yFormatter ? yFormatter(y) : String(y)) : ''\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: `(${formattedX}, ${formattedY})`,\n seriesName,\n marker,\n value: '',\n }\n })\n}\n\nfunction computeScatterBounds(seriesArr: ScatterplotWidgetData): {\n niceMinX: number\n niceMaxX: number\n niceMinY: number\n niceMaxY: number\n} {\n let minX = Infinity\n let maxX = -Infinity\n let minY = Infinity\n let maxY = -Infinity\n for (const series of seriesArr) {\n for (const point of series) {\n const x = point?.[0]\n const y = point?.[1]\n if (typeof x === 'number' && Number.isFinite(x)) {\n if (x < minX) minX = x\n if (x > maxX) maxX = x\n }\n if (typeof y === 'number' && Number.isFinite(y)) {\n if (y < minY) minY = y\n if (y > maxY) maxY = y\n }\n }\n }\n // Mirror bar's `computeNiceBounds`: clamp min to 0 when data is\n // non-negative (gridline reads cleanly from zero), apply `niceNum` to\n // negative mins, and floor max=0 to 1 so the chart always has range.\n // Scatter can have free coordinates so we apply this per-axis.\n const niceMaxX = Number.isFinite(maxX) ? (maxX <= 0 ? 1 : niceNum(maxX)) : 1\n const niceMaxY = Number.isFinite(maxY) ? (maxY <= 0 ? 1 : niceNum(maxY)) : 1\n const niceMinX = Number.isFinite(minX) ? (minX < 0 ? niceNum(minX) : 0) : 0\n const niceMinY = Number.isFinite(minY) ? (minY < 0 ? niceNum(minY) : 0) : 0\n return { niceMinX, niceMaxX, niceMinY, niceMaxY }\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, 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 position: 'relative',\n flex: '1 1 auto',\n width: '100%',\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\n// `sx` callback that needs runtime args — extracted at module scope so the\n// `styles` object can satisfy `Record<string, SxProps<Theme>>` cleanly\n// (function `sx`-with-args isn't assignable to plain `SxProps<Theme>`).\nconst dotSx = (top: string, left: string, size: number): SxProps<Theme> => ({\n position: 'absolute',\n top,\n left,\n width: size,\n height: size,\n borderRadius: '50%',\n})\n\nexport interface ScatterplotSkeletonProps {\n /** Number of dots to render. */\n count?: number\n}\n\n/**\n * Loading state for the Scatterplot widget. Mirrors a scatter chart's\n * silhouette — a deterministic spread of small circular dots in the plot\n * area plus a legend stub — so the skeleton reads as \"a scatter chart\"\n * rather than a generic list. Matches bar/histogram/pie skeleton structure\n * (grid stub + legend stub in a flex column).\n */\nexport function ScatterplotSkeleton({ count = 24 }: ScatterplotSkeletonProps) {\n // Deterministic pseudo-scatter positions so the skeleton doesn't flicker.\n const dots = Array.from({ length: count }, (_, i) => {\n const top = 10 + ((i * 37) % 80)\n const left = 5 + ((i * 53) % 90)\n const size = 8 + ((i * 7) % 6)\n return { top: `${top}%`, left: `${left}%`, size }\n })\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\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 { ScatterplotWidgetData } from './types'\n\n/**\n * Download menu items for the Scatterplot widget. Always includes a CSV\n * item with `series, x, y` columns (one row per point). When\n * `getCaptureEl` is supplied, prepends a PNG item that rasterises the\n * captured element via `html2canvas`.\n */\nexport function createScatterplotDownloadConfig(args: {\n filename: string\n getData: () => ScatterplotWidgetData\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', 'x', 'y']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const [x, y] of series) {\n rows.push([seriesName, x, y])\n }\n }\n return rows\n },\n }),\n )\n return items\n}\n","/**\n * Scatterplot-specific `RelativeData` transform. Scatter data is\n * `[number, number][]` — each series is a list of `[x, y]` tuples.\n * Relative is a values-axis concept, so this rewrites `y` to its\n * share of the series's total `y` (0–100) and leaves `x` raw — x is\n * coordinate space, not part of the cohort total.\n *\n * Pass to `<Widget.RelativeData transform={toRelativeScatterplotData} />`.\n *\n * The denominator is the sum of |y| across the series so mixed-sign\n * y values produce sane signed shares-of-magnitude. A series whose\n * total y-magnitude is zero (all-zero or empty input) is returned\n * unchanged so a stalled or empty data set doesn't show misleading 0%\n * values. Inputs whose shape isn't `[number, number][]` fall through\n * untouched.\n */\nexport const toRelativeScatterplotData = (input: unknown): unknown => {\n if (!Array.isArray(input)) return input\n return input.map((series: unknown): unknown => {\n if (!isXyTupleArray(series)) return series\n const total = series.reduce((acc, [, y]) => acc + Math.abs(y), 0)\n if (total <= 0) return series\n return series.map(([x, y]) => [x, (y / total) * 100] as [number, number])\n })\n}\n\nfunction isXyTupleArray(v: unknown): v is [number, number][] {\n if (!Array.isArray(v)) return false\n return v.every(\n (item) =>\n Array.isArray(item) &&\n item.length === 2 &&\n typeof item[0] === 'number' &&\n Number.isFinite(item[0]) &&\n typeof item[1] === 'number' &&\n Number.isFinite(item[1]),\n )\n}\n"],"names":["scatterplotOptions","theme","xFormatter","yFormatter","grid","left","parseInt","spacing","top","right","buildGridConfig","containLabel","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","textStyle","color","common","white","fontSize","fontFamily","typography","caption","position","createTooltipPositioner","formatter","buildScatterTooltipFormatter","legend","buildLegendConfig","hasLegend","labelFormatter","undefined","axisPointer","lineStyle","secondary","main","Object","values","qualitative","bold","xAxis","type","axisLine","show","axisTick","axisLabel","overlineDelicate","black","margin","hideOverlap","showMinLabel","showMaxLabel","splitLine","divider","yAxis","createScatterplotOptionFactory","options","optionsOverride","series","symbolSize","selection","selectionSet","length","Set","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","baseLegend","baseGrid","baseTooltip","baseXAxis","baseYAxis","reactiveFormatter","niceMinX","niceMaxX","niceMinY","niceMaxY","computeScatterBounds","makeDimColor","seriesIdx","params","base","key","dataIndex","has","echarts","modifyAlpha","dataZoomLayout","layoutDataZoomForScatter","dataZoom","hasXSlider","hasYSlider","fallbackBottom","bottom","baseBottom","gridBottom","ZOOM_LAYOUT","sliderHeight","sliderGap","fallbackRight","gridRight","map","s","source","_","i","overrideColor","resolveThemeColor","datasetIndex","name","encode","x","y","emphasis","focus","itemStyle","entries","min","max","buildReactiveScatterTooltipFormatter","entry","dz","yAxisIndex","sliderBottomWithLegend","structuralFormatter","reactiveYFormatter","createTooltipFormatter","item","value","formattedX","String","formattedY","marker","seriesName","minX","Infinity","maxX","minY","maxY","point","Number","isFinite","niceNum","styles","container","display","alignItems","justifyContent","flexDirection","gap","height","flex","width","legendItem","dotSx","size","borderRadius","ScatterplotSkeleton","t0","$","_c","count","t1","T0","T1","t2","t3","t4","dots","from","_temp","Box","_temp2","t5","jsx","t6","Symbol","for","_temp3","t7","i_1","jsxs","Skeleton","d","i_0","createScatterplotDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","buildCsvDownloadItem","getRows","getData","rows","seriesNames","toRelativeScatterplotData","input","isXyTupleArray","total","reduce","acc","Math","abs","v","every"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,SAASA,GAAmB;AAAA,EACjCC,OAAAA;AAAAA,EACAC,YAAAA;AAAAA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,EAAKyD,WAAW;AACxC,cAAMiB,IAAaqD,EAAKa,cAAc9F,CAAC,KAAK,UAAUA,IAAI,CAAC;AAC3D,mBAAW,CAACM,GAAGC,CAAC,KAAK5D;AACnBkJ,UAAAA,EAAKT,KAAK,CAACxD,GAAYtB,GAAGC,CAAC,CAAC;AAAA,MAEhC;AACA,aAAOsF;AAAAA,IACT;AAAA,EAAA,CACD,CACH,GACOX;AACT;ACjCO,MAAMa,KAA4BA,CAACC,MACnCzI,MAAMC,QAAQwI,CAAK,IACjBA,EAAMpG,IAAI,CAACjD,MAA6B;AAC7C,MAAI,CAACsJ,GAAetJ,CAAM,EAAG,QAAOA;AACpC,QAAMuJ,IAAQvJ,EAAOwJ,OAAO,CAACC,GAAK,CAAA,EAAG7F,CAAC,MAAM6F,IAAMC,KAAKC,IAAI/F,CAAC,GAAG,CAAC;AAChE,SAAI2F,KAAS,IAAUvJ,IAChBA,EAAOiD,IAAI,CAAC,CAACU,GAAGC,CAAC,MAAM,CAACD,GAAIC,IAAI2F,IAAS,GAAG,CAAqB;AAC1E,CAAC,IANiCF;AASpC,SAASC,GAAeM,GAAqC;AAC3D,SAAKhJ,MAAMC,QAAQ+I,CAAC,IACbA,EAAEC,MACNlF,CAAAA,MACC/D,MAAMC,QAAQ8D,CAAI,KAClBA,EAAKvE,WAAW,KAChB,OAAOuE,EAAK,CAAC,KAAM,YACnBa,OAAOC,SAASd,EAAK,CAAC,CAAC,KACvB,OAAOA,EAAK,CAAC,KAAM,YACnBa,OAAOC,SAASd,EAAK,CAAC,CAAC,CAC3B,IAT8B;AAUhC;"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { c as
|
|
4
|
-
import { Box as p, Skeleton as
|
|
1
|
+
import { S as R, a as B, b as P } from "../spread-DYNpzgh_.js";
|
|
2
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
3
|
+
import { c as m } from "react/compiler-runtime";
|
|
4
|
+
import { Box as p, Skeleton as l } 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 s } from "../png-item-9dNbB37T.js";
|
|
12
|
+
import { b as f } from "../csv-item-hH_Gt7ur.js";
|
|
13
|
+
const a = {
|
|
13
14
|
root: {
|
|
14
15
|
display: "flex",
|
|
15
16
|
flexDirection: "column",
|
|
@@ -26,46 +27,40 @@ const l = {
|
|
|
26
27
|
height: 32
|
|
27
28
|
}
|
|
28
29
|
};
|
|
29
|
-
function
|
|
30
|
-
const e =
|
|
31
|
-
count:
|
|
32
|
-
} =
|
|
33
|
-
let
|
|
34
|
-
return e[0] !== r ? (
|
|
30
|
+
function D(t) {
|
|
31
|
+
const e = m(2), {
|
|
32
|
+
count: n
|
|
33
|
+
} = t, r = n === void 0 ? 1 : n;
|
|
34
|
+
let o;
|
|
35
|
+
return e[0] !== r ? (o = /* @__PURE__ */ i(p, { sx: a.root, children: Array.from({
|
|
35
36
|
length: r
|
|
36
|
-
}).map(
|
|
37
|
+
}).map(c) }), e[0] = r, e[1] = o) : o = e[1], o;
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
-
return /* @__PURE__ */
|
|
39
|
+
function c(t, e) {
|
|
40
|
+
return /* @__PURE__ */ i(p, { sx: a.row, children: /* @__PURE__ */ i(l, { variant: "rectangular", sx: a.block }) }, `row-${e}`);
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
+
function I(t) {
|
|
42
43
|
const e = [];
|
|
43
|
-
return
|
|
44
|
-
filename:
|
|
45
|
-
getCaptureEl:
|
|
46
|
-
pixelRatio:
|
|
47
|
-
backgroundColor:
|
|
48
|
-
})), e.push({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const t = c(r);
|
|
56
|
-
return Promise.resolve({
|
|
57
|
-
url: t.url,
|
|
58
|
-
filename: `${o.filename}.csv`,
|
|
59
|
-
revoke: t.revoke
|
|
60
|
-
});
|
|
44
|
+
return t.getCaptureEl && e.push(s({
|
|
45
|
+
filename: t.filename,
|
|
46
|
+
getCaptureEl: t.getCaptureEl,
|
|
47
|
+
pixelRatio: t.pngPixelRatio,
|
|
48
|
+
backgroundColor: t.pngBackgroundColor
|
|
49
|
+
})), e.push(f({
|
|
50
|
+
filename: t.filename,
|
|
51
|
+
getRows: () => {
|
|
52
|
+
const n = t.getData(), r = [["series", "prefix", "min", "max", "suffix", "note"]];
|
|
53
|
+
for (const o of n)
|
|
54
|
+
r.push([o.series?.name ?? "", o.prefix ?? "", o.min, o.max, o.suffix ?? "", o.note ?? ""]);
|
|
55
|
+
return r;
|
|
61
56
|
}
|
|
62
|
-
}), e;
|
|
57
|
+
})), e;
|
|
63
58
|
}
|
|
64
59
|
export {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
R as Separator,
|
|
61
|
+
B as Spread,
|
|
62
|
+
D as SpreadSkeleton,
|
|
63
|
+
P as SpreadUI,
|
|
64
|
+
I as createSpreadDownloadConfig
|
|
70
65
|
};
|
|
71
66
|
//# sourceMappingURL=spread.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spread.js","sources":["../../src/widgets-v2/spread/skeleton.tsx","../../src/widgets-v2/spread/download.ts"],"sourcesContent":["import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n py: 1,\n },\n row: {\n display: 'flex',\n alignItems: 'center',\n gap: 1.5,\n },\n block: { width: 200, height: 32 },\n} satisfies Record<string, SxProps<Theme>>\n\nexport interface SpreadSkeletonProps {\n count?: number\n}\n\n/**\n * Loading placeholder for the Spread widget. Renders `count` rows, each\n * sized for the `min — max` pair so the layout doesn't jump once data\n * resolves. Mirrors the row-per-item structure of {@link SpreadUI}.\n */\nexport function SpreadSkeleton({ count = 1 }: SpreadSkeletonProps) {\n return (\n <Box sx={styles.root}>\n {Array.from({ length: count }).map((_, i) => (\n <Box key={`row-${i}`} sx={styles.row}>\n <Skeleton variant='rectangular' sx={styles.block} />\n </Box>\n ))}\n </Box>\n )\n}\n","import {\n
|
|
1
|
+
{"version":3,"file":"spread.js","sources":["../../src/widgets-v2/spread/skeleton.tsx","../../src/widgets-v2/spread/download.ts"],"sourcesContent":["import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n py: 1,\n },\n row: {\n display: 'flex',\n alignItems: 'center',\n gap: 1.5,\n },\n block: { width: 200, height: 32 },\n} satisfies Record<string, SxProps<Theme>>\n\nexport interface SpreadSkeletonProps {\n count?: number\n}\n\n/**\n * Loading placeholder for the Spread widget. Renders `count` rows, each\n * sized for the `min — max` pair so the layout doesn't jump once data\n * resolves. Mirrors the row-per-item structure of {@link SpreadUI}.\n */\nexport function SpreadSkeleton({ count = 1 }: SpreadSkeletonProps) {\n return (\n <Box sx={styles.root}>\n {Array.from({ length: count }).map((_, i) => (\n <Box key={`row-${i}`} sx={styles.row}>\n <Skeleton variant='rectangular' sx={styles.block} />\n </Box>\n ))}\n </Box>\n )\n}\n","import {\n buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadItem,\n} from '../actions/download'\nimport type { SpreadWidgetData } from './types'\n\n/**\n * Download menu items for the Spread widget. Always includes a CSV item\n * with `series, prefix, min, max, suffix, note` columns (one row per\n * entry). When `getCaptureEl` is supplied, prepends a PNG item that\n * rasterises the captured element via `html2canvas`.\n */\nexport function createSpreadDownloadConfig(args: {\n filename: string\n getData: () => SpreadWidgetData\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push(\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: () => {\n const data = args.getData()\n const rows: unknown[][] = [\n ['series', 'prefix', 'min', 'max', 'suffix', 'note'],\n ]\n for (const item of data) {\n rows.push([\n item.series?.name ?? '',\n item.prefix ?? '',\n item.min,\n item.max,\n item.suffix ?? '',\n item.note ?? '',\n ])\n }\n return rows\n },\n }),\n )\n return items\n}\n"],"names":["styles","root","display","flexDirection","gap","py","row","alignItems","block","width","height","SpreadSkeleton","t0","$","_c","count","t1","undefined","t2","Box","Array","from","length","map","_temp","_","i","jsx","Skeleton","createSpreadDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","backgroundColor","pngBackgroundColor","buildCsvDownloadItem","getRows","data","getData","rows","item","series","name","prefix","min","max","suffix","note"],"mappings":";;;;;;;;;;;;AAGA,MAAMA,IAAS;AAAA,EACbC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,KAAK;AAAA,IACLC,IAAI;AAAA,EAAA;AAAA,EAENC,KAAK;AAAA,IACHJ,SAAS;AAAA,IACTK,YAAY;AAAA,IACZH,KAAK;AAAA,EAAA;AAAA,EAEPI,OAAO;AAAA,IAAEC,OAAO;AAAA,IAAKC,QAAQ;AAAA,EAAA;AAC/B;AAWO,SAAAC,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAAwB;AAAA,IAAAC,OAAAC;AAAAA,EAAAA,IAAAJ,GAAEG,IAAAC,MAAAC,SAAA,IAAAD;AAAS,MAAAE;AAAA,SAAAL,SAAAE,KAEtCG,sBAACC,GAAA,EAAQ,IAAAnB,EAAMC,MACZmB,gBAAKC,KAAM;AAAA,IAAAC,QAAUP;AAAAA,EAAAA,CAAO,EAACQ,IAAKC,CAIlC,GACH,GAAMX,OAAAE,GAAAF,OAAAK,KAAAA,IAAAL,EAAA,CAAA,GANNK;AAMM;AARH,SAAAM,EAAAC,GAAAC,GAAA;AAAA,SAIC,gBAAAC,EAACR,GAAA,EAAyB,IAAAnB,EAAMM,KAC9B,UAAA,gBAAAqB,EAACC,GAAA,EAAiB,SAAA,eAAkB,IAAA5B,EAAMQ,MAAAA,CAAM,EAAA,GADxC,OAAOkB,CAAC,EAElB;AAAM;ACpBP,SAASG,EAA2BC,GAMxB;AACjB,QAAMC,IAAwB,CAAA;AAC9B,SAAID,EAAKE,gBACPD,EAAME,KACJC,EAAqB;AAAA,IACnBC,UAAUL,EAAKK;AAAAA,IACfH,cAAcF,EAAKE;AAAAA,IACnBI,YAAYN,EAAKO;AAAAA,IACjBC,iBAAiBR,EAAKS;AAAAA,EAAAA,CACvB,CACH,GAEFR,EAAME,KACJO,EAAqB;AAAA,IACnBL,UAAUL,EAAKK;AAAAA,IACfM,SAASA,MAAM;AACb,YAAMC,IAAOZ,EAAKa,QAAAA,GACZC,IAAoB,CACxB,CAAC,UAAU,UAAU,OAAO,OAAO,UAAU,MAAM,CAAC;AAEtD,iBAAWC,KAAQH;AACjBE,QAAAA,EAAKX,KAAK,CACRY,EAAKC,QAAQC,QAAQ,IACrBF,EAAKG,UAAU,IACfH,EAAKI,KACLJ,EAAKK,KACLL,EAAKM,UAAU,IACfN,EAAKO,QAAQ,EAAE,CAChB;AAEH,aAAOR;AAAAA,IACT;AAAA,EAAA,CACD,CACH,GACOb;AACT;"}
|
package/dist/widgets-v2/table.js
CHANGED
|
@@ -1,77 +1,68 @@
|
|
|
1
|
-
import { s
|
|
2
|
-
import { D as
|
|
3
|
-
import { jsx as
|
|
4
|
-
import { c as
|
|
5
|
-
import { TableHead as w, TableRow as
|
|
1
|
+
import { s, t as g } from "../table-B3ZWWhJt.js";
|
|
2
|
+
import { D as q, a as J, b as K, T as M, c as Q, d as W, e as X, p as Y, r as ee, f as te } from "../table-B3ZWWhJt.js";
|
|
3
|
+
import { jsx as a, jsxs as _ } from "react/jsx-runtime";
|
|
4
|
+
import { c as E } from "react/compiler-runtime";
|
|
5
|
+
import { TableHead as w, TableRow as h, TableBody as x, TableCell as u, Skeleton as b, Box as A, Table as C } 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
11
|
import "html2canvas";
|
|
12
|
-
import { b as
|
|
12
|
+
import { b as v } from "../png-item-9dNbB37T.js";
|
|
13
|
+
import { b as D } from "../csv-item-hH_Gt7ur.js";
|
|
13
14
|
function V(t) {
|
|
14
|
-
const e =
|
|
15
|
-
rows:
|
|
16
|
-
columns:
|
|
17
|
-
size:
|
|
18
|
-
} = t,
|
|
19
|
-
let
|
|
20
|
-
e[0] !==
|
|
21
|
-
length:
|
|
22
|
-
}).map(
|
|
23
|
-
let
|
|
24
|
-
e[2] !==
|
|
25
|
-
length:
|
|
26
|
-
}), e[2] =
|
|
15
|
+
const e = E(11), {
|
|
16
|
+
rows: d,
|
|
17
|
+
columns: f,
|
|
18
|
+
size: m
|
|
19
|
+
} = t, c = d === void 0 ? 5 : d, r = f === void 0 ? 4 : f;
|
|
20
|
+
let l;
|
|
21
|
+
e[0] !== r ? (l = /* @__PURE__ */ a(w, { children: /* @__PURE__ */ a(h, { children: Array.from({
|
|
22
|
+
length: r
|
|
23
|
+
}).map(L) }) }), e[0] = r, e[1] = l) : l = e[1];
|
|
24
|
+
let o;
|
|
25
|
+
e[2] !== c ? (o = Array.from({
|
|
26
|
+
length: c
|
|
27
|
+
}), e[2] = c, e[3] = o) : o = e[3];
|
|
27
28
|
let i;
|
|
28
|
-
e[4] !==
|
|
29
|
-
length:
|
|
30
|
-
}).map((
|
|
31
|
-
let
|
|
32
|
-
return e[7] !==
|
|
33
|
-
|
|
29
|
+
e[4] !== r || e[5] !== o ? (i = /* @__PURE__ */ a(x, { children: o.map((B, p) => /* @__PURE__ */ a(h, { sx: s.row, children: Array.from({
|
|
30
|
+
length: r
|
|
31
|
+
}).map((k, T) => /* @__PURE__ */ a(u, { children: /* @__PURE__ */ a(b, { variant: "text", width: "70%", height: 20 }) }, `cell-${p}-${T}`)) }, `row-${p}`)) }), e[4] = r, e[5] = o, e[6] = i) : i = e[6];
|
|
32
|
+
let n;
|
|
33
|
+
return e[7] !== m || e[8] !== l || e[9] !== i ? (n = /* @__PURE__ */ a(A, { sx: s.container, "aria-label": "Table skeleton", children: /* @__PURE__ */ _(C, { size: m, sx: s.table, stickyHeader: !0, children: [
|
|
34
|
+
l,
|
|
34
35
|
i
|
|
35
|
-
] }) }), e[7] =
|
|
36
|
+
] }) }), e[7] = m, e[8] = l, e[9] = i, e[10] = n) : n = e[10], n;
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
-
return /* @__PURE__ */
|
|
38
|
+
function L(t, e) {
|
|
39
|
+
return /* @__PURE__ */ a(u, { sx: s.headerCell, children: /* @__PURE__ */ a(b, { variant: "text", width: "80%", height: 24 }) }, `head-${e}`);
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
+
function Z(t) {
|
|
41
42
|
const e = [];
|
|
42
|
-
return t.getCaptureEl && e.push(
|
|
43
|
+
return t.getCaptureEl && e.push(v({
|
|
43
44
|
filename: t.filename,
|
|
44
45
|
getCaptureEl: t.getCaptureEl,
|
|
45
46
|
pixelRatio: t.pngPixelRatio,
|
|
46
47
|
backgroundColor: t.pngBackgroundColor
|
|
47
|
-
})), e.push({
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const n = g(t.getData(), t.columns), c = new Blob([n], {
|
|
52
|
-
type: "text/csv;charset=utf-8;"
|
|
53
|
-
}), l = URL.createObjectURL(c);
|
|
54
|
-
return Promise.resolve({
|
|
55
|
-
url: l,
|
|
56
|
-
filename: `${t.filename}.csv`,
|
|
57
|
-
revoke: () => URL.revokeObjectURL(l)
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}), e;
|
|
48
|
+
})), e.push(D({
|
|
49
|
+
filename: t.filename,
|
|
50
|
+
getCsv: () => g(t.getData(), t.columns)
|
|
51
|
+
})), e;
|
|
61
52
|
}
|
|
62
53
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
54
|
+
q as DEFAULT_TABLE_LABELS,
|
|
55
|
+
J as DEFAULT_TABLE_PAGE_SIZE,
|
|
56
|
+
K as DEFAULT_TABLE_PAGE_SIZE_OPTIONS,
|
|
57
|
+
M as Table,
|
|
67
58
|
V as TableSkeleton,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
59
|
+
Q as TableUI,
|
|
60
|
+
W as compareValues,
|
|
61
|
+
Z as createTableDownloadConfig,
|
|
62
|
+
X as deriveVisibleRows,
|
|
63
|
+
Y as paginateRows,
|
|
64
|
+
ee as resolveColumns,
|
|
65
|
+
te as sortRows,
|
|
75
66
|
g as tableDataToCsv
|
|
76
67
|
};
|
|
77
68
|
//# sourceMappingURL=table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","sources":["../../src/widgets-v2/table/skeleton.tsx","../../src/widgets-v2/table/download.ts"],"sourcesContent":["import {\n Box,\n Skeleton,\n Table as MuiTable,\n TableBody,\n TableCell,\n TableHead,\n TableRow as MuiTableRow,\n type TableProps as MuiTableProps,\n} from '@mui/material'\nimport { styles } from './style'\n\nexport interface TableSkeletonProps {\n /** Number of body rows to render. Defaults to `5` (matches v1). */\n rows?: number\n /** Number of columns to render. Defaults to `4` (matches v1). */\n columns?: number\n /**\n * Forwarded to MUI's `<Table size>` so the loading layout matches the\n * size you'll render in {@link TableUI}. Leave `undefined` (the\n * default) to use MUI's own default density.\n */\n size?: MuiTableProps['size']\n}\n\n/**\n * Loading placeholder for the Table widget. Renders the same MUI table\n * primitives that {@link TableUI} uses so the loading layout (column\n * widths, header band, row density) doesn't shift when data resolves.\n *\n * Mirrors the v1 widget's `<TableSkeleton>` structure with v2's themed\n * `styles.headerCell`.\n */\nexport function TableSkeleton({\n rows = 5,\n columns = 4,\n size,\n}: TableSkeletonProps) {\n return (\n <Box sx={styles.container} aria-label='Table skeleton'>\n <MuiTable size={size} sx={styles.table} stickyHeader>\n <TableHead>\n <MuiTableRow>\n {Array.from({ length: columns }).map((_, c) => (\n <TableCell key={`head-${c}`} sx={styles.headerCell}>\n <Skeleton variant='text' width='80%' height={24} />\n </TableCell>\n ))}\n </MuiTableRow>\n </TableHead>\n <TableBody>\n {Array.from({ length: rows }).map((_, r) => (\n <MuiTableRow key={`row-${r}`} sx={styles.row}>\n {Array.from({ length: columns }).map((__, c) => (\n <TableCell key={`cell-${r}-${c}`}>\n <Skeleton variant='text' width='70%' height={20} />\n </TableCell>\n ))}\n </MuiTableRow>\n ))}\n </TableBody>\n </MuiTable>\n </Box>\n )\n}\n","import {
|
|
1
|
+
{"version":3,"file":"table.js","sources":["../../src/widgets-v2/table/skeleton.tsx","../../src/widgets-v2/table/download.ts"],"sourcesContent":["import {\n Box,\n Skeleton,\n Table as MuiTable,\n TableBody,\n TableCell,\n TableHead,\n TableRow as MuiTableRow,\n type TableProps as MuiTableProps,\n} from '@mui/material'\nimport { styles } from './style'\n\nexport interface TableSkeletonProps {\n /** Number of body rows to render. Defaults to `5` (matches v1). */\n rows?: number\n /** Number of columns to render. Defaults to `4` (matches v1). */\n columns?: number\n /**\n * Forwarded to MUI's `<Table size>` so the loading layout matches the\n * size you'll render in {@link TableUI}. Leave `undefined` (the\n * default) to use MUI's own default density.\n */\n size?: MuiTableProps['size']\n}\n\n/**\n * Loading placeholder for the Table widget. Renders the same MUI table\n * primitives that {@link TableUI} uses so the loading layout (column\n * widths, header band, row density) doesn't shift when data resolves.\n *\n * Mirrors the v1 widget's `<TableSkeleton>` structure with v2's themed\n * `styles.headerCell`.\n */\nexport function TableSkeleton({\n rows = 5,\n columns = 4,\n size,\n}: TableSkeletonProps) {\n return (\n <Box sx={styles.container} aria-label='Table skeleton'>\n <MuiTable size={size} sx={styles.table} stickyHeader>\n <TableHead>\n <MuiTableRow>\n {Array.from({ length: columns }).map((_, c) => (\n <TableCell key={`head-${c}`} sx={styles.headerCell}>\n <Skeleton variant='text' width='80%' height={24} />\n </TableCell>\n ))}\n </MuiTableRow>\n </TableHead>\n <TableBody>\n {Array.from({ length: rows }).map((_, r) => (\n <MuiTableRow key={`row-${r}`} sx={styles.row}>\n {Array.from({ length: columns }).map((__, c) => (\n <TableCell key={`cell-${r}-${c}`}>\n <Skeleton variant='text' width='70%' height={20} />\n </TableCell>\n ))}\n </MuiTableRow>\n ))}\n </TableBody>\n </MuiTable>\n </Box>\n )\n}\n","import {\n buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadItem,\n} from '../actions/download'\nimport { tableDataToCsv } from './helpers'\nimport type { TableColumn, TableWidgetData } from './types'\n\n/**\n * Download menu items for the Table widget. Always includes a CSV item\n * that pulls the latest data from the widget store via `getData()` (so\n * locked / sorted / filtered state is honored); headers come from\n * `column.label`, cells from `row[column.id]`. When `getCaptureEl` is\n * supplied, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createTableDownloadConfig(opts: {\n filename: string\n getData: () => TableWidgetData\n columns: readonly TableColumn[]\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (opts.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: opts.filename,\n getCaptureEl: opts.getCaptureEl,\n pixelRatio: opts.pngPixelRatio,\n backgroundColor: opts.pngBackgroundColor,\n }),\n )\n }\n items.push(\n buildCsvDownloadItem({\n filename: opts.filename,\n getCsv: () => tableDataToCsv(opts.getData(), opts.columns),\n }),\n )\n return items\n}\n"],"names":["TableSkeleton","t0","$","_c","rows","t1","columns","t2","size","undefined","t3","jsx","TableHead","MuiTableRow","Array","from","length","map","_temp","t4","t5","TableBody","__0","r","styles","row","__","c_0","TableCell","Skeleton","c","t6","Box","container","jsxs","MuiTable","table","_","headerCell","createTableDownloadConfig","opts","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","backgroundColor","pngBackgroundColor","buildCsvDownloadItem","getCsv","tableDataToCsv","getData"],"mappings":";;;;;;;;;;;;;AAiCO,SAAAA,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA,GAAuB;AAAA,IAAAC,MAAAC;AAAAA,IAAAC,SAAAC;AAAAA,IAAAC,MAAAA;AAAAA,EAAAA,IAAAP,GAC5BG,IAAAC,MAAAI,SAAA,IAAAJ,GACAC,IAAAC,MAAAE,SAAA,IAAAF;AAAW,MAAAG;AAAA,EAAAR,SAAAI,KAMLI,IAAA,gBAAAC,EAACC,GAAA,EACC,UAAA,gBAAAD,EAACE,GAAA,EACEC,gBAAKC,KAAM;AAAA,IAAAC,QAAUV;AAAAA,EAAAA,CAAS,EAACW,IAAKC,CAIpC,GACH,EAAA,CACF,GAAYhB,OAAAI,GAAAJ,OAAAQ,KAAAA,IAAAR,EAAA,CAAA;AAAA,MAAAiB;AAAA,EAAAjB,SAAAE,KAETe,IAAAL,MAAKC,KAAM;AAAA,IAAAC,QAAUZ;AAAAA,EAAAA,CAAM,GAACF,OAAAE,GAAAF,OAAAiB,KAAAA,IAAAjB,EAAA,CAAA;AAAA,MAAAkB;AAAA,EAAAlB,EAAA,CAAA,MAAAI,KAAAJ,SAAAiB,KAD/BC,IAAA,gBAAAT,EAACU,GAAA,EACEF,UAAAA,EAA4BF,IAAK,CAAAK,GAAAC,MAChC,gBAAAZ,EAACE,GAAA,EA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