@carto/ps-react-ui 4.4.2 → 4.4.3

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.
Files changed (65) hide show
  1. package/dist/download-config-Dqu78h2a.js +57 -0
  2. package/dist/download-config-Dqu78h2a.js.map +1 -0
  3. package/dist/formatter-B9Bxn1k7.js +6 -0
  4. package/dist/formatter-B9Bxn1k7.js.map +1 -0
  5. package/dist/styles-Y8q7Jff3.js +118 -0
  6. package/dist/styles-Y8q7Jff3.js.map +1 -0
  7. package/dist/types/widgets/actions/brush-toggle/types.d.ts +8 -2
  8. package/dist/types/widgets/category/components/category-row-multi.d.ts +2 -1
  9. package/dist/types/widgets/category/components/category-row-single.d.ts +2 -1
  10. package/dist/types/widgets/category/types.d.ts +1 -0
  11. package/dist/types/widgets/echart/types.d.ts +2 -0
  12. package/dist/types/widgets/histogram/config.d.ts +15 -3
  13. package/dist/types/widgets/histogram/index.d.ts +2 -1
  14. package/dist/types/widgets/histogram/types.d.ts +6 -3
  15. package/dist/types/widgets/stores/types.d.ts +2 -0
  16. package/dist/types/widgets/utils/chart-config/index.d.ts +1 -1
  17. package/dist/types/widgets/utils/chart-config/option-builders.d.ts +13 -8
  18. package/dist/types/widgets/utils/formatter.d.ts +1 -0
  19. package/dist/types/widgets/utils/index.d.ts +1 -1
  20. package/dist/widgets/actions.js +455 -439
  21. package/dist/widgets/actions.js.map +1 -1
  22. package/dist/widgets/bar.js +52 -46
  23. package/dist/widgets/bar.js.map +1 -1
  24. package/dist/widgets/category.js +206 -197
  25. package/dist/widgets/category.js.map +1 -1
  26. package/dist/widgets/formula.js +1 -1
  27. package/dist/widgets/histogram.js +119 -79
  28. package/dist/widgets/histogram.js.map +1 -1
  29. package/dist/widgets/pie.js +110 -98
  30. package/dist/widgets/pie.js.map +1 -1
  31. package/dist/widgets/range.js +1 -1
  32. package/dist/widgets/scatterplot.js +49 -43
  33. package/dist/widgets/scatterplot.js.map +1 -1
  34. package/dist/widgets/spread.js +1 -1
  35. package/dist/widgets/timeseries.js +51 -45
  36. package/dist/widgets/timeseries.js.map +1 -1
  37. package/dist/widgets/toolbar-actions.js +101 -6693
  38. package/dist/widgets/toolbar-actions.js.map +1 -1
  39. package/dist/widgets/utils.js +16 -14
  40. package/dist/widgets/utils.js.map +1 -1
  41. package/package.json +5 -4
  42. package/src/widgets/README.md +3 -3
  43. package/src/widgets/actions/brush-toggle/brush-toggle.tsx +42 -47
  44. package/src/widgets/actions/brush-toggle/types.ts +8 -2
  45. package/src/widgets/bar/config.ts +22 -14
  46. package/src/widgets/category/category-ui.tsx +9 -1
  47. package/src/widgets/category/components/category-row-multi.tsx +6 -2
  48. package/src/widgets/category/components/category-row-single.tsx +5 -1
  49. package/src/widgets/category/types.ts +1 -0
  50. package/src/widgets/echart/types.ts +2 -0
  51. package/src/widgets/histogram/config.ts +101 -20
  52. package/src/widgets/histogram/index.ts +6 -1
  53. package/src/widgets/histogram/types.ts +9 -3
  54. package/src/widgets/pie/config.ts +17 -5
  55. package/src/widgets/scatterplot/config.ts +8 -3
  56. package/src/widgets/stores/types.ts +2 -0
  57. package/src/widgets/timeseries/config.ts +21 -13
  58. package/src/widgets/utils/chart-config/index.ts +1 -1
  59. package/src/widgets/utils/chart-config/option-builders.ts +22 -12
  60. package/src/widgets/utils/formatter.ts +2 -1
  61. package/src/widgets/utils/index.ts +1 -1
  62. package/dist/formatter-B1Xh8XDH.js +0 -5
  63. package/dist/formatter-B1Xh8XDH.js.map +0 -1
  64. package/dist/styles-C_8vOEep.js +0 -167
  65. package/dist/styles-C_8vOEep.js.map +0 -1
@@ -0,0 +1,57 @@
1
+ import "react/jsx-runtime";
2
+ import "react/compiler-runtime";
3
+ import "@mui/material";
4
+ import "./widget-store-CzDt8oSK.js";
5
+ import "@mui/icons-material";
6
+ import "zustand/shallow";
7
+ import "react";
8
+ import "react-markdown";
9
+ import { d as n, a as s } from "./exports-Cr43OCul.js";
10
+ import "./lasso-tool-BYbxrJ-7.js";
11
+ import "./cjs-D4KH3azB.js";
12
+ import "@dnd-kit/core";
13
+ import "@dnd-kit/sortable";
14
+ import "@dnd-kit/utilities";
15
+ function T(r) {
16
+ const o = [];
17
+ if (r.length > 0 && (r[0]?.length ?? 0) > 0) {
18
+ const i = r?.[0]?.[0] ?? {}, t = Object.keys(i);
19
+ o.push(t);
20
+ }
21
+ return r.forEach((i) => {
22
+ i.forEach((t) => {
23
+ const e = Object.values(t).map((c) => String(c));
24
+ o.push(e);
25
+ });
26
+ }), o;
27
+ }
28
+ function b(r) {
29
+ const o = [];
30
+ return o.push(["x", "y"]), r.forEach((i) => {
31
+ i.forEach((t) => {
32
+ o.push([String(t[0]), String(t[1])]);
33
+ });
34
+ }), o;
35
+ }
36
+ function j(r) {
37
+ return function({
38
+ refUI: o
39
+ }) {
40
+ return [{
41
+ ...n,
42
+ modifier: () => n.modifier(o)
43
+ }, {
44
+ ...s,
45
+ modifier: async (i) => {
46
+ const t = r(i);
47
+ return s.modifier(t);
48
+ }
49
+ }];
50
+ };
51
+ }
52
+ export {
53
+ j as c,
54
+ T as f,
55
+ b as s
56
+ };
57
+ //# sourceMappingURL=download-config-Dqu78h2a.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download-config-Dqu78h2a.js","sources":["../src/widgets/utils/chart-config/csv-modifiers.ts","../src/widgets/utils/chart-config/download-config.ts"],"sourcesContent":["/**\n * Shared CSV export modifiers for chart widgets\n */\n\n/**\n * Flattens object array data into CSV-ready rows.\n * Used by bar, pie, histogram, and timeseries widgets.\n *\n * @param data - Array of series, where each series is an array of data objects\n * @returns CSV rows with headers and values\n */\nexport function flattenObjectArrayToCSV<T extends Record<string, unknown>>(\n data: T[][],\n): string[][] {\n const rows: string[][] = []\n\n // Add headers from first data point if available\n if (data.length > 0 && (data[0]?.length ?? 0) > 0) {\n const firstDataPoint = data?.[0]?.[0] ?? {}\n const headers = Object.keys(firstDataPoint)\n rows.push(headers)\n }\n\n // Add data rows from all series\n data.forEach((series) => {\n series.forEach((dataPoint) => {\n const values = Object.values(dataPoint).map((v) => String(v))\n rows.push(values)\n })\n })\n\n return rows\n}\n\n/**\n * Creates CSV rows for scatterplot data.\n * Scatterplot uses array format [x, y] instead of objects.\n *\n * @param data - Array of series, where each series is an array of [x, y] tuples\n * @returns CSV rows with ['x', 'y'] headers\n */\nexport function scatterplotDataToCSV(data: number[][][]): string[][] {\n const rows: string[][] = []\n\n // Add headers\n rows.push(['x', 'y'])\n\n // Add data rows from all series\n data.forEach((series) => {\n series.forEach((dataPoint) => {\n rows.push([String(dataPoint[0]), String(dataPoint[1])])\n })\n })\n\n return rows\n}\n","import { downloadToCSV, downloadToPNG, type DownloadItem } from '../../actions'\nimport type { ConfigProps } from '../../loader/types'\n\nexport function createChartDownloadConfig<TData>(\n csvModifier: (data: TData) => string[][],\n) {\n return function ({ refUI }: ConfigProps): DownloadItem<TData>[] {\n return [\n {\n ...downloadToPNG,\n modifier: () => downloadToPNG.modifier(refUI),\n },\n {\n ...downloadToCSV,\n modifier: async (data) => {\n const rows = csvModifier(data)\n return downloadToCSV.modifier(rows)\n },\n },\n ]\n }\n}\n"],"names":["flattenObjectArrayToCSV","data","rows","length","firstDataPoint","headers","Object","keys","push","forEach","series","dataPoint","values","map","v","String","scatterplotDataToCSV","createChartDownloadConfig","csvModifier","refUI","downloadToPNG","modifier","downloadToCSV"],"mappings":";;;;;;;;;;;;;;AAWO,SAASA,EACdC,GACY;AACZ,QAAMC,IAAmB,CAAA;AAGzB,MAAID,EAAKE,SAAS,MAAMF,EAAK,CAAC,GAAGE,UAAU,KAAK,GAAG;AACjD,UAAMC,IAAiBH,IAAO,CAAC,IAAI,CAAC,KAAK,CAAA,GACnCI,IAAUC,OAAOC,KAAKH,CAAc;AAC1CF,IAAAA,EAAKM,KAAKH,CAAO;AAAA,EACnB;AAGAJ,SAAAA,EAAKQ,QAASC,CAAAA,MAAW;AACvBA,IAAAA,EAAOD,QAASE,CAAAA,MAAc;AAC5B,YAAMC,IAASN,OAAOM,OAAOD,CAAS,EAAEE,IAAKC,CAAAA,MAAMC,OAAOD,CAAC,CAAC;AAC5DZ,MAAAA,EAAKM,KAAKI,CAAM;AAAA,IAClB,CAAC;AAAA,EACH,CAAC,GAEMV;AACT;AASO,SAASc,EAAqBf,GAAgC;AACnE,QAAMC,IAAmB,CAAA;AAGzBA,SAAAA,EAAKM,KAAK,CAAC,KAAK,GAAG,CAAC,GAGpBP,EAAKQ,QAASC,CAAAA,MAAW;AACvBA,IAAAA,EAAOD,QAASE,CAAAA,MAAc;AAC5BT,MAAAA,EAAKM,KAAK,CAACO,OAAOJ,EAAU,CAAC,CAAC,GAAGI,OAAOJ,EAAU,CAAC,CAAC,CAAC,CAAC;AAAA,IACxD,CAAC;AAAA,EACH,CAAC,GAEMT;AACT;ACpDO,SAASe,EACdC,GACA;AACA,SAAO,SAAU;AAAA,IAAEC,OAAAA;AAAAA,EAAAA,GAA6C;AAC9D,WAAO,CACL;AAAA,MACE,GAAGC;AAAAA,MACHC,UAAUA,MAAMD,EAAcC,SAASF,CAAK;AAAA,IAAA,GAE9C;AAAA,MACE,GAAGG;AAAAA,MACHD,UAAU,OAAOpB,MAAS;AACxB,cAAMC,IAAOgB,EAAYjB,CAAI;AAC7B,eAAOqB,EAAcD,SAASnB,CAAI;AAAA,MACpC;AAAA,IAAA,CACD;AAAA,EAEL;AACF;"}
@@ -0,0 +1,6 @@
1
+ const a = (t) => String(t), e = (t) => t;
2
+ export {
3
+ e as a,
4
+ a as d
5
+ };
6
+ //# sourceMappingURL=formatter-B9Bxn1k7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter-B9Bxn1k7.js","sources":["../src/widgets/utils/formatter.ts"],"sourcesContent":["export const defaultFormatter = (value: number) => String(value)\nexport const defaultLabelFormatter = (value: string | number) => value\n"],"names":["defaultFormatter","value","String","defaultLabelFormatter"],"mappings":"AAAO,MAAMA,IAAmBA,CAACC,MAAkBC,OAAOD,CAAK,GAClDE,IAAwBA,CAACF,MAA2BA;"}
@@ -0,0 +1,118 @@
1
+ function u(t) {
2
+ if (t === 0) return 0;
3
+ const e = Math.abs(t), n = Math.pow(10, Math.floor(Math.log10(e))), i = Math.ceil(e / n) * n;
4
+ return t < 0 ? -i : i;
5
+ }
6
+ function d({
7
+ hasLegend: t,
8
+ labelFormatter: e
9
+ }) {
10
+ return {
11
+ show: t,
12
+ icon: "circle",
13
+ left: 0,
14
+ bottom: 0,
15
+ orient: "horizontal",
16
+ type: "scroll",
17
+ ...e && {
18
+ formatter: (n) => String(e(n))
19
+ }
20
+ };
21
+ }
22
+ function x(t, e) {
23
+ return {
24
+ ...!t && {
25
+ bottom: parseInt(e.spacing(3))
26
+ },
27
+ ...t && {
28
+ bottom: parseInt(e.spacing(7))
29
+ }
30
+ };
31
+ }
32
+ function y(t) {
33
+ return function(e, n, i, o, a) {
34
+ const l = {
35
+ top: parseInt(t.spacing(0.5))
36
+ };
37
+ return a.contentSize[0] < a.viewSize[0] - e[0] ? l.left = e[0] : l.right = a.viewSize[0] - e[0], l;
38
+ };
39
+ }
40
+ function m(t) {
41
+ if (t)
42
+ return (e) => t(e);
43
+ }
44
+ function b(t, e) {
45
+ const n = t && !Array.isArray(t), i = t, o = e && n ? (a) => String(e(a)) : void 0;
46
+ return {
47
+ ...i,
48
+ axisLabel: {
49
+ ...typeof i.axisLabel == "object" && i.axisLabel ? i.axisLabel : {},
50
+ formatter: o
51
+ }
52
+ };
53
+ }
54
+ function F(t, e) {
55
+ let n = m(e);
56
+ const i = t && !Array.isArray(t), o = t;
57
+ return (!i || o.type !== "value") && (n = void 0), {
58
+ ...o,
59
+ axisLabel: {
60
+ ...typeof o.axisLabel == "object" && o.axisLabel ? o.axisLabel : {},
61
+ formatter: n
62
+ }
63
+ };
64
+ }
65
+ function v(t) {
66
+ return (e) => {
67
+ const n = Array.isArray(e) ? e : [e], i = (r, s) => `<div style="margin: 0px 0 0;line-height:1;">${r ? `<div style="font-size:11px;color:#FFFFFF;font-weight:400;line-height:1; margin-bottom: 10px">${r}</div>` : ""}<div style="margin: 0;line-height:1;">${s}</div><div style="clear:both"></div></div>`, o = n.map((r) => {
68
+ const {
69
+ name: s,
70
+ seriesName: c,
71
+ marker: f,
72
+ value: h
73
+ } = t(r, n);
74
+ return {
75
+ name: s,
76
+ seriesName: c,
77
+ marker: f,
78
+ value: h
79
+ };
80
+ }), a = o[0]?.name ?? "", p = a || n.length > 1 ? "margin: 10px 0 0;line-height:1;" : "margin: 0;line-height:1;", g = o.map(({
81
+ seriesName: r,
82
+ marker: s,
83
+ value: c
84
+ }) => `<div style="${p}"><div style="margin: 0px 0 0;line-height:1;">${s}${r ? `<span style="font-size:11px;color:#FFFFFF;font-weight:400;margin-left:2px;margin-right:10px">${r}</span>` : ""}<span style="float:right;margin-left:10px;font-size:11px;color:#FFFFFF;font-weight:900">${c}</span></div></div>`);
85
+ return i(a, g.join(""));
86
+ };
87
+ }
88
+ const w = {
89
+ graph: {
90
+ /**
91
+ * Common container style for chart widget skeletons
92
+ */
93
+ container: {
94
+ display: "flex",
95
+ alignItems: "center",
96
+ justifyContent: "space-between",
97
+ flexDirection: "column",
98
+ gap: ({
99
+ spacing: t
100
+ }) => t(1),
101
+ height: ({
102
+ spacing: t
103
+ }) => t(38)
104
+ }
105
+ }
106
+ };
107
+ export {
108
+ b as a,
109
+ F as b,
110
+ w as c,
111
+ x as d,
112
+ d as e,
113
+ m as f,
114
+ v as g,
115
+ y as h,
116
+ u as n
117
+ };
118
+ //# sourceMappingURL=styles-Y8q7Jff3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles-Y8q7Jff3.js","sources":["../src/widgets/utils/chart-config/option-builders.ts","../src/widgets/utils/skeleton/styles.ts"],"sourcesContent":["import type { Theme } from '@mui/material'\nimport type { LegendComponentOption } from 'echarts'\nimport type {\n CallbackDataParams,\n TopLevelFormatterParams,\n} from 'echarts/types/dist/shared'\n\n/**\n * Shared EChart configuration builders for chart widgets\n */\n\n/**\n * Rounds a value up to the nearest \"nice\" number.\n * A nice number is a multiple of 10^floor(log10(value)).\n *\n * Examples: 547 → 600, 200 → 200, 1200 → 2000, 18 → 20, 5 → 5, -547 → -500\n */\nexport function niceNum(value: number): number {\n if (value === 0) return 0\n const absValue = Math.abs(value)\n const base = Math.pow(10, Math.floor(Math.log10(absValue)))\n const rounded = Math.ceil(absValue / base) * base\n return value < 0 ? -rounded : rounded\n}\n\n/**\n * Builds standard legend configuration for chart widgets\n *\n * @param params - Legend configuration parameters\n * @param params.hasLegend - Whether to show the legend\n * @param params.labelFormatter - Optional formatter for legend item names\n * @returns Legend configuration object\n */\nexport function buildLegendConfig({\n hasLegend,\n labelFormatter,\n}: {\n hasLegend: boolean\n labelFormatter?: (value: string | number) => string | number\n}): LegendComponentOption {\n return {\n show: hasLegend,\n icon: 'circle' as const,\n left: 0,\n bottom: 0,\n orient: 'horizontal',\n type: 'scroll',\n ...(labelFormatter && {\n formatter: (name: string) => String(labelFormatter(name)),\n }),\n }\n}\n\n/**\n * Builds standard grid configuration with legend-aware spacing\n *\n * @param hasLegend - Whether the chart has a legend\n * @param theme - MUI theme for spacing\n * @param additionalConfig - Additional grid configuration to merge\n * @returns Grid configuration object\n */\nexport function buildGridConfig(hasLegend: boolean, theme: Theme) {\n return {\n ...(!hasLegend && { bottom: parseInt(theme.spacing(3)) }),\n ...(hasLegend && { bottom: parseInt(theme.spacing(7)) }),\n }\n}\n\n/**\n * Creates a tooltip position calculator that handles overflow\n * Used by bar, histogram, and scatterplot widgets\n *\n * @param theme - MUI theme for spacing\n * @returns Tooltip position function\n */\nexport function createTooltipPositioner(theme: Theme) {\n return function (\n point: [number, number],\n _params: unknown,\n _dom: unknown,\n _rect: unknown,\n size: { contentSize: [number, number]; viewSize: [number, number] },\n ) {\n const position = { top: parseInt(theme.spacing(0.5)) } as Record<\n string,\n number\n >\n\n // Position tooltip left or right based on available space\n if (size.contentSize[0] < size.viewSize[0] - point[0]) {\n position.left = point[0]\n } else {\n position.right = size.viewSize[0] - point[0]\n }\n\n return position\n }\n}\n\n/**\n * Creates an axis label formatter for ECharts\n * Used to format numeric axis labels with a widget formatter\n *\n * @param formatter - Optional formatter function from widget config\n * @returns Axis label formatter function or undefined\n */\nexport function createAxisLabelFormatter(\n formatter?: (value: number) => string,\n) {\n if (!formatter) return undefined\n return (value: number) => formatter(value)\n}\n\n/**\n * Applies labelFormatter to xAxis configuration\n * Applies to any xAxis regardless of axis type (category, value, etc.)\n *\n * @param xAxis - Existing xAxis configuration\n * @param labelFormatter - Optional labelFormatter function from widget config\n * @returns Updated xAxis configuration\n */\nexport function applyXAxisFormatter(\n xAxis: unknown,\n formatter?: (value: string | number) => string | number,\n) {\n const xAxisIsObject = xAxis && !Array.isArray(xAxis)\n const xAxisTyped = xAxis as { type?: string; axisLabel?: unknown }\n\n const axisFormatter =\n formatter && xAxisIsObject\n ? (value: string | number) => String(formatter(value))\n : undefined\n\n return {\n ...xAxisTyped,\n axisLabel: {\n ...(typeof xAxisTyped.axisLabel === 'object' && xAxisTyped.axisLabel\n ? xAxisTyped.axisLabel\n : {}),\n formatter: axisFormatter,\n },\n }\n}\n\n/**\n * Applies formatter to yAxis configuration\n * Only applies to single axis objects (not arrays) with type 'value'\n *\n * @param yAxis - Existing yAxis configuration\n * @param formatter - Optional formatter function from widget config\n * @returns Updated yAxis configuration or undefined if no changes needed\n */\nexport function applyYAxisFormatter(\n yAxis: unknown,\n formatter?: (value: number) => string,\n) {\n let axisFormatter = createAxisLabelFormatter(formatter)\n\n const yAxisIsObject = yAxis && !Array.isArray(yAxis)\n const yAxisTyped = yAxis as { type?: string; axisLabel?: unknown }\n\n if (!yAxisIsObject || yAxisTyped.type !== 'value') {\n axisFormatter = undefined\n }\n\n return {\n ...yAxisTyped,\n axisLabel: {\n ...(typeof yAxisTyped.axisLabel === 'object' && yAxisTyped.axisLabel\n ? yAxisTyped.axisLabel\n : {}),\n formatter: axisFormatter,\n },\n }\n}\n\n/**\n * Creates a tooltip formatter for ECharts\n * Formats numeric values in tooltip using widget formatter\n * Handles both axis trigger (array) and item trigger (object) modes\n *\n * @param formatter - Optional formatter function from widget config\n * @returns Tooltip formatter function or undefined\n */\nexport function createTooltipFormatter(\n callback: (\n item: CallbackDataParams,\n items: CallbackDataParams[],\n ) => {\n name: string\n seriesName: string\n marker: string\n value: string | number\n },\n) {\n return (params: TopLevelFormatterParams) => {\n // Handle both array (axis trigger) and object (item trigger)\n const items = Array.isArray(params) ? params : [params]\n\n const tooltip = (name: string, callback: string) =>\n `<div style=\"margin: 0px 0 0;line-height:1;\">${name ? `<div style=\"font-size:11px;color:#FFFFFF;font-weight:400;line-height:1; margin-bottom: 10px\">${name}</div>` : ''}<div style=\"margin: 0;line-height:1;\">${callback}</div><div style=\"clear:both\"></div></div>`\n\n const values = items.map((item) => {\n const { name, seriesName, marker, value } = callback(item, items)\n return {\n name,\n seriesName,\n marker,\n value,\n }\n })\n\n const name = values[0]?.name ?? ''\n // Show margin if name exists or there are multiple items\n const showMargin = name || items.length > 1\n const marginStyle = showMargin\n ? 'margin: 10px 0 0;line-height:1;'\n : 'margin: 0;line-height:1;'\n\n const formattedValues = values.map(\n ({ seriesName, marker, value }) =>\n `<div style=\"${marginStyle}\"><div style=\"margin: 0px 0 0;line-height:1;\">${marker}${seriesName ? `<span style=\"font-size:11px;color:#FFFFFF;font-weight:400;margin-left:2px;margin-right:10px\">${seriesName}</span>` : ''}<span style=\"float:right;margin-left:10px;font-size:11px;color:#FFFFFF;font-weight:900\">${value}</span></div></div>`,\n )\n\n return tooltip(name, formattedValues.join(''))\n }\n}\n","import type { Theme } from '@mui/material'\n\n/**\n * Base skeleton styles shared across all chart widgets\n */\nexport const baseSkeletonStyles = {\n graph: {\n /**\n * Common container style for chart widget skeletons\n */\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }: Theme) => spacing(1),\n height: ({ spacing }: Theme) => spacing(38),\n },\n },\n} as const\n"],"names":["niceNum","value","absValue","Math","abs","base","pow","floor","log10","rounded","ceil","buildLegendConfig","hasLegend","labelFormatter","show","icon","left","bottom","orient","type","formatter","name","String","buildGridConfig","theme","parseInt","spacing","createTooltipPositioner","point","_params","_dom","_rect","size","position","top","contentSize","viewSize","right","createAxisLabelFormatter","applyXAxisFormatter","xAxis","xAxisIsObject","Array","isArray","xAxisTyped","axisFormatter","undefined","axisLabel","applyYAxisFormatter","yAxis","yAxisIsObject","yAxisTyped","createTooltipFormatter","callback","params","items","tooltip","values","map","item","seriesName","marker","marginStyle","length","formattedValues","join","baseSkeletonStyles","graph","container","display","alignItems","justifyContent","flexDirection","gap","height"],"mappings":"AAiBO,SAASA,EAAQC,GAAuB;AAC7C,MAAIA,MAAU,EAAG,QAAO;AACxB,QAAMC,IAAWC,KAAKC,IAAIH,CAAK,GACzBI,IAAOF,KAAKG,IAAI,IAAIH,KAAKI,MAAMJ,KAAKK,MAAMN,CAAQ,CAAC,CAAC,GACpDO,IAAUN,KAAKO,KAAKR,IAAWG,CAAI,IAAIA;AAC7C,SAAOJ,IAAQ,IAAI,CAACQ,IAAUA;AAChC;AAUO,SAASE,EAAkB;AAAA,EAChCC,WAAAA;AAAAA,EACAC,gBAAAA;AAIF,GAA0B;AACxB,SAAO;AAAA,IACLC,MAAMF;AAAAA,IACNG,MAAM;AAAA,IACNC,MAAM;AAAA,IACNC,QAAQ;AAAA,IACRC,QAAQ;AAAA,IACRC,MAAM;AAAA,IACN,GAAIN,KAAkB;AAAA,MACpBO,WAAWA,CAACC,MAAiBC,OAAOT,EAAeQ,CAAI,CAAC;AAAA,IAAA;AAAA,EAC1D;AAEJ;AAUO,SAASE,EAAgBX,GAAoBY,GAAc;AAChE,SAAO;AAAA,IACL,GAAI,CAACZ,KAAa;AAAA,MAAEK,QAAQQ,SAASD,EAAME,QAAQ,CAAC,CAAC;AAAA,IAAA;AAAA,IACrD,GAAId,KAAa;AAAA,MAAEK,QAAQQ,SAASD,EAAME,QAAQ,CAAC,CAAC;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AA,IAAA;AAAA,EAC5C;AAEJ;"}
@@ -2,9 +2,15 @@ import { IconButtonProps } from '@mui/material';
2
2
  import { ReactNode } from 'react';
3
3
  import { BaseWidgetState } from '../../stores/types';
4
4
  /**
5
- * Represents a single item selected by the brush
5
+ * Brush selection result emitted by BrushToggle.
6
+ * Contains raw indices so consumers can resolve data according to their widget type.
6
7
  */
7
- export type BrushSelectedItems = (string | number)[];
8
+ export interface BrushSelectedItems {
9
+ /** Data indices of the selected items in the dataset */
10
+ dataIndex: number[];
11
+ /** Series index from the brush event (defaults to 0) */
12
+ seriesIndex: number;
13
+ }
8
14
  /**
9
15
  * State stored in widget store for brush functionality
10
16
  */
@@ -5,10 +5,11 @@ export interface CategoryRowMultiProps {
5
5
  maxValue: number;
6
6
  colors: string[];
7
7
  formatter: NonNullable<CategoryWidgetConfig['formatter']>;
8
+ labelFormatter?: CategoryWidgetConfig['labelFormatter'];
8
9
  onClick?: CategoryWidgetConfig['onRowClick'];
9
10
  selected?: boolean;
10
11
  }
11
12
  /**
12
13
  * Renders a multi-series category row with a label and multiple color-coded bars stacked vertically.
13
14
  */
14
- export declare function CategoryRowMulti({ name, values, maxValue, colors, formatter, onClick, selected, }: CategoryRowMultiProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function CategoryRowMulti({ name, values, maxValue, colors, formatter, labelFormatter, onClick, selected, }: CategoryRowMultiProps): import("react/jsx-runtime").JSX.Element;
@@ -5,10 +5,11 @@ export interface CategoryRowSingleProps {
5
5
  maxValue: number;
6
6
  color: string;
7
7
  formatter: NonNullable<CategoryWidgetConfig['formatter']>;
8
+ labelFormatter?: CategoryWidgetConfig['labelFormatter'];
8
9
  onClick?: CategoryWidgetConfig['onRowClick'];
9
10
  selected?: boolean;
10
11
  }
11
12
  /**
12
13
  * Renders a single-series category row with a label, formatted value, and proportional bar.
13
14
  */
14
- export declare function CategoryRowSingle({ name, value, maxValue, color, formatter, onClick, selected, }: CategoryRowSingleProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function CategoryRowSingle({ name, value, maxValue, color, formatter, labelFormatter, onClick, selected, }: CategoryRowSingleProps): import("react/jsx-runtime").JSX.Element;
@@ -22,6 +22,7 @@ export type CategoryWidgetState = BaseWidgetState<WrapperState<CategoryWidgetCon
22
22
  }>;
23
23
  export interface CategoryWidgetConfig {
24
24
  formatter?: (value: number) => string;
25
+ labelFormatter?: (value: string | number) => string | number;
25
26
  series?: CategorySeriesConfig[];
26
27
  maxItems?: number;
27
28
  labels?: CategoryLabels;
@@ -27,10 +27,12 @@ export interface EchartWidgetOptionProps<D> {
27
27
  data?: D;
28
28
  theme: typeof CartoTheme;
29
29
  formatter?: (value: number) => string;
30
+ labelFormatter?: (value: string | number) => string | number;
30
31
  }
31
32
  export interface EchartWidgetProps {
32
33
  type: string;
33
34
  option: EchartUIProps['option'];
34
35
  onEvents?: EchartUIProps['onEvents'];
35
36
  formatter?: (value: number) => string;
37
+ labelFormatter?: (value: string | number) => string | number;
36
38
  }
@@ -1,9 +1,21 @@
1
1
  import { HistogramConfig, HistogramWidgetConfig } from './types';
2
- export declare const histogramDownloadConfig: ({ refUI }: import('../loader').ConfigProps) => import('../actions').DownloadItem<import('../echart').EchartWidgetData>[];
2
+ import { DownloadItem } from '../actions';
3
+ import { ConfigProps } from '../loader/types';
4
+ export interface HistogramDownloadConfigProps extends ConfigProps {
5
+ ticks: number[];
6
+ labelFormatter?: (value: string | number) => string | number;
7
+ }
8
+ export declare function histogramDataToCSV(data: number[][], ticks: number[], labelFormatter?: (value: string | number) => string | number): string[][];
9
+ export declare function histogramDownloadConfig({ refUI, ticks, labelFormatter, }: HistogramDownloadConfigProps): DownloadItem<number[][]>[];
3
10
  /**
4
- * Generates ECharts configuration for distribution histogram widgets with adjacent bars (minimal gap) and axis formatting styled with the CARTO theme.
11
+ * Generates ECharts configuration for distribution histogram widgets with
12
+ * adjacent bars (minimal gap) and axis formatting styled with the CARTO theme.
5
13
  *
6
- * @param props - Histogram configuration including bin data and theme.
14
+ * Accepts raw `number[][]` data and `ticks` boundaries. The ticks and
15
+ * `labelFormatter` are used to create the x-axis category labels; the raw
16
+ * numeric data is embedded directly in each series.
17
+ *
18
+ * @param props - Histogram configuration including raw data, ticks, and theme.
7
19
  * @returns Widget config with ECharts option object.
8
20
  */
9
21
  export declare function histogramConfig(props: HistogramConfig): HistogramWidgetConfig;
@@ -1,3 +1,4 @@
1
1
  export type { HistogramConfig, HistogramWidgetConfig, HistogramWidgetData, HistogramWidgetState, } from './types';
2
- export { histogramConfig, histogramDownloadConfig } from './config';
2
+ export type { HistogramDownloadConfigProps } from './config';
3
+ export { histogramConfig, histogramDataToCSV, histogramDownloadConfig, } from './config';
3
4
  export { HistogramSkeleton } from './skeleton';
@@ -1,9 +1,12 @@
1
- import { EchartWidgetData, EchartWidgetState } from '../echart';
1
+ import { EchartWidgetState } from '../echart';
2
2
  import { EchartWidgetOptionProps, EchartWidgetProps } from '../echart/types';
3
3
  import { ConfigProps } from '../loader';
4
- export type HistogramWidgetData = EchartWidgetData;
4
+ export type HistogramWidgetData = number[][];
5
5
  export type HistogramWidgetState = EchartWidgetState;
6
6
  export type HistogramWidgetConfig = EchartWidgetProps & {
7
7
  type: 'histogram';
8
8
  };
9
- export type HistogramConfig = ConfigProps & EchartWidgetOptionProps<HistogramWidgetData>;
9
+ export type HistogramConfig = ConfigProps & Pick<EchartWidgetOptionProps<unknown>, 'theme' | 'formatter' | 'labelFormatter'> & {
10
+ data?: number[][];
11
+ ticks: number[];
12
+ };
@@ -29,6 +29,8 @@ export interface WidgetsStoreProps {
29
29
  registeredTools?: ToolRegistration[];
30
30
  /** Formatter function for widget values */
31
31
  formatter?: (value: number) => string;
32
+ /** Formatter function for widget label/category values */
33
+ labelFormatter?: (value: string | number) => string | number;
32
34
  /** Locale for number formatting (e.g., 'en-US', 'es-ES', 'fr-FR') */
33
35
  locale?: string;
34
36
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Shared utilities for chart widget configuration
3
3
  */
4
- export { defaultFormatter } from '../formatter';
4
+ export { defaultFormatter, defaultLabelFormatter } from '../formatter';
5
5
  export { createChartWidgetConfig } from './config-factory';
6
6
  export type { ChartWidgetBaseConfig, CreateChartWidgetConfigParams, } from './config-factory';
7
7
  export { flattenObjectArrayToCSV, scatterplotDataToCSV } from './csv-modifiers';
@@ -14,10 +14,15 @@ export declare function niceNum(value: number): number;
14
14
  /**
15
15
  * Builds standard legend configuration for chart widgets
16
16
  *
17
- * @param hasLegend - Whether to show the legend
17
+ * @param params - Legend configuration parameters
18
+ * @param params.hasLegend - Whether to show the legend
19
+ * @param params.labelFormatter - Optional formatter for legend item names
18
20
  * @returns Legend configuration object
19
21
  */
20
- export declare function buildLegendConfig(hasLegend: boolean): LegendComponentOption;
22
+ export declare function buildLegendConfig({ hasLegend, labelFormatter, }: {
23
+ hasLegend: boolean;
24
+ labelFormatter?: (value: string | number) => string | number;
25
+ }): LegendComponentOption;
21
26
  /**
22
27
  * Builds standard grid configuration with legend-aware spacing
23
28
  *
@@ -49,16 +54,16 @@ export declare function createTooltipPositioner(theme: Theme): (point: [number,
49
54
  */
50
55
  export declare function createAxisLabelFormatter(formatter?: (value: number) => string): ((value: number) => string) | undefined;
51
56
  /**
52
- * Applies formatter to xAxis configuration
53
- * Only applies to single axis objects (not arrays) with type 'value'
57
+ * Applies labelFormatter to xAxis configuration
58
+ * Applies to any xAxis regardless of axis type (category, value, etc.)
54
59
  *
55
60
  * @param xAxis - Existing xAxis configuration
56
- * @param formatter - Optional formatter function from widget config
57
- * @returns Updated xAxis configuration or undefined if no changes needed
61
+ * @param labelFormatter - Optional labelFormatter function from widget config
62
+ * @returns Updated xAxis configuration
58
63
  */
59
- export declare function applyXAxisFormatter(xAxis: unknown, formatter?: (value: number) => string): {
64
+ export declare function applyXAxisFormatter(xAxis: unknown, formatter?: (value: string | number) => string | number): {
60
65
  axisLabel: {
61
- formatter: ((value: number) => string) | undefined;
66
+ formatter: ((value: string | number) => string) | undefined;
62
67
  };
63
68
  type?: string;
64
69
  };
@@ -1 +1,2 @@
1
1
  export declare const defaultFormatter: (value: number) => string;
2
+ export declare const defaultLabelFormatter: (value: string | number) => string | number;
@@ -1,4 +1,4 @@
1
- export { defaultFormatter } from './formatter';
1
+ export { defaultFormatter, defaultLabelFormatter } from './formatter';
2
2
  export { createChartWidgetConfig } from './chart-config';
3
3
  export type { ChartWidgetBaseConfig, CreateChartWidgetConfigParams, } from './chart-config';
4
4
  export { flattenObjectArrayToCSV, scatterplotDataToCSV } from './chart-config';