@carto/ps-react-ui 5.0.0-widgets.13 → 5.0.0-widgets.14
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/styles-CCZnY17y.js +117 -0
- package/dist/styles-CCZnY17y.js.map +1 -0
- package/dist/types/widgets/_shared/chart-config/index.d.ts +1 -1
- package/dist/types/widgets/_shared/chart-config/option-builders.d.ts +51 -0
- package/dist/types/widgets/echart/types.d.ts +1 -0
- package/dist/types/widgets/stores/types.d.ts +4 -0
- package/dist/widgets/actions.js +551 -528
- package/dist/widgets/actions.js.map +1 -1
- package/dist/widgets/bar.js +84 -89
- package/dist/widgets/bar.js.map +1 -1
- package/dist/widgets/histogram.js +106 -96
- package/dist/widgets/histogram.js.map +1 -1
- package/dist/widgets/pie.js +81 -68
- package/dist/widgets/pie.js.map +1 -1
- package/dist/widgets/scatterplot.js +104 -94
- package/dist/widgets/scatterplot.js.map +1 -1
- package/dist/widgets/timeseries.js +77 -65
- package/dist/widgets/timeseries.js.map +1 -1
- package/package.json +1 -1
- package/dist/styles-dOu_pRNb.js +0 -77
- package/dist/styles-dOu_pRNb.js.map +0 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
function m(t) {
|
|
2
|
+
const e = [];
|
|
3
|
+
if (t.length > 0 && (t[0]?.length ?? 0) > 0) {
|
|
4
|
+
const n = t?.[0]?.[0] ?? {}, i = Object.keys(n);
|
|
5
|
+
e.push(i);
|
|
6
|
+
}
|
|
7
|
+
return t.forEach((n) => {
|
|
8
|
+
n.forEach((i) => {
|
|
9
|
+
const o = Object.values(i).map((r) => String(r));
|
|
10
|
+
e.push(o);
|
|
11
|
+
});
|
|
12
|
+
}), e;
|
|
13
|
+
}
|
|
14
|
+
function y(t) {
|
|
15
|
+
const e = [];
|
|
16
|
+
return e.push(["x", "y"]), t.forEach((n) => {
|
|
17
|
+
n.forEach((i) => {
|
|
18
|
+
e.push([String(i[0]), String(i[1])]);
|
|
19
|
+
});
|
|
20
|
+
}), e;
|
|
21
|
+
}
|
|
22
|
+
function F(t) {
|
|
23
|
+
return {
|
|
24
|
+
show: t,
|
|
25
|
+
icon: "circle",
|
|
26
|
+
left: 0,
|
|
27
|
+
bottom: 0,
|
|
28
|
+
orient: "horizontal",
|
|
29
|
+
type: "scroll"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function v(t, e) {
|
|
33
|
+
return {
|
|
34
|
+
...!t && {
|
|
35
|
+
bottom: parseInt(e.spacing(3))
|
|
36
|
+
},
|
|
37
|
+
...t && {
|
|
38
|
+
bottom: parseInt(e.spacing(7))
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function x(t) {
|
|
43
|
+
return function(e, n, i, o, r) {
|
|
44
|
+
const l = {
|
|
45
|
+
top: parseInt(t.spacing(0.5))
|
|
46
|
+
};
|
|
47
|
+
return r.contentSize[0] < r.viewSize[0] - e[0] ? l.left = e[0] : l.right = r.viewSize[0] - e[0], l;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function u(t) {
|
|
51
|
+
if (t)
|
|
52
|
+
return (e) => t(e);
|
|
53
|
+
}
|
|
54
|
+
function b(t, e) {
|
|
55
|
+
let n = u(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 d(t) {
|
|
66
|
+
return (e) => {
|
|
67
|
+
const n = Array.isArray(e) ? e : [e], i = (s, a) => `<div style="margin: 0px 0 0;line-height:1;">${s ? `<div style="font-size:11px;color:#FFFFFF;font-weight:400;line-height:1; margin-bottom: 10px">${s}</div>` : ""}<div style="margin: 0;line-height:1;">${a}</div><div style="clear:both"></div></div>`, o = n.map((s) => {
|
|
68
|
+
const {
|
|
69
|
+
name: a,
|
|
70
|
+
seriesName: c,
|
|
71
|
+
marker: f,
|
|
72
|
+
value: h
|
|
73
|
+
} = t(s, n);
|
|
74
|
+
return {
|
|
75
|
+
name: a,
|
|
76
|
+
seriesName: c,
|
|
77
|
+
marker: f,
|
|
78
|
+
value: h
|
|
79
|
+
};
|
|
80
|
+
}), r = o[0]?.name ?? "", p = r || n.length > 1 ? "margin: 10px 0 0;line-height:1;" : "margin: 0;line-height:1;", g = o.map(({
|
|
81
|
+
seriesName: s,
|
|
82
|
+
marker: a,
|
|
83
|
+
value: c
|
|
84
|
+
}) => `<div style="${p}"><div style="margin: 0px 0 0;line-height:1;">${a}${s ? `<span style="font-size:11px;color:#FFFFFF;font-weight:400;margin-left:2px;margin-right:10px">${s}</span>` : ""}<span style="float:right;margin-left:10px;font-size:11px;color:#FFFFFF;font-weight:900">${c}</span></div></div>`);
|
|
85
|
+
return i(r, 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
|
+
x as a,
|
|
109
|
+
b,
|
|
110
|
+
d as c,
|
|
111
|
+
v as d,
|
|
112
|
+
F as e,
|
|
113
|
+
m as f,
|
|
114
|
+
w as g,
|
|
115
|
+
y as s
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=styles-CCZnY17y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles-CCZnY17y.js","sources":["../src/widgets/_shared/chart-config/csv-modifiers.ts","../src/widgets/_shared/chart-config/option-builders.ts","../src/widgets/_shared/skeleton/styles.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 type { Theme } from '@mui/material'\nimport type { LegendComponentOption } from 'echarts'\nimport type {\n CallbackDataParams,\n TopLevelFormatterParams,\n} from 'node_modules/echarts/types/dist/shared'\n\n/**\n * Shared EChart configuration builders for chart widgets\n */\n\n/**\n * Builds standard legend configuration for chart widgets\n *\n * @param hasLegend - Whether to show the legend\n * @returns Legend configuration object\n */\nexport function buildLegendConfig(hasLegend: boolean): LegendComponentOption {\n return {\n show: hasLegend,\n icon: 'circle' as const,\n left: 0,\n bottom: 0,\n orient: 'horizontal',\n type: 'scroll',\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 formatter to xAxis configuration\n * Only applies to single axis objects (not arrays) with type 'value'\n *\n * @param xAxis - Existing xAxis configuration\n * @param formatter - Optional formatter function from widget config\n * @returns Updated xAxis configuration or undefined if no changes needed\n */\nexport function applyXAxisFormatter(\n xAxis: unknown,\n formatter?: (value: number) => string,\n) {\n let axisFormatter = createAxisLabelFormatter(formatter)\n\n const xAxisIsObject = xAxis && !Array.isArray(xAxis)\n const xAxisTyped = xAxis as { type?: string; axisLabel?: unknown }\n\n if (!xAxisIsObject || xAxisTyped.type !== 'value') {\n axisFormatter = undefined\n }\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":["flattenObjectArrayToCSV","data","rows","length","firstDataPoint","headers","Object","keys","push","forEach","series","dataPoint","values","map","v","String","scatterplotDataToCSV","buildLegendConfig","hasLegend","show","icon","left","bottom","orient","type","buildGridConfig","theme","parseInt","spacing","createTooltipPositioner","point","_params","_dom","_rect","size","position","top","contentSize","viewSize","right","createAxisLabelFormatter","formatter","value","applyYAxisFormatter","yAxis","axisFormatter","yAxisIsObject","Array","isArray","yAxisTyped","undefined","axisLabel","createTooltipFormatter","callback","params","items","tooltip","name","item","seriesName","marker","marginStyle","formattedValues","join","baseSkeletonStyles","graph","container","display","alignItems","justifyContent","flexDirection","gap","height"],"mappings":"AAWO,SAASA,EACdC,GACY;AACZ,QAAMC,IAAmB,CAAA;AAGzB,MAAID,EAAKE,SAAS,MAAMF,EAAK,CAAC,GAAGE,UAAU,KAAK,GAAG;AACjD,UAAMC,IAAiBH,IAAO,C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AAO7C,EAAO,CAAC,GAAG6C,QAAQ,IAG1BI,IADaJ,KAAQF,EAAMpD,SAAS,IAEtC,oCACA,4BAEE2D,IAAkBlD,EAAOC,IAC7B,CAAC;AAAA,MAAE8C,YAAAA;AAAAA,MAAYC,QAAAA;AAAAA,MAAQlB,OAAAA;AAAAA,IAAAA,MACrB,eAAemB,CAAW,iDAAiDD,CAAM,GAAGD,IAAa,gGAAgGA,CAAU,YAAY,EAAE,2FAA2FjB,CAAK,qBAC7T;AAEA,WAAOc,EAAQC,GAAMK,EAAgBC,KAAK,EAAE,CAAC;AAAA,EAC/C;AACF;ACrMO,MAAMC,IAAqB;AAAA,EAChCC,OAAO;AAAA;AAAA;AAAA;AAAA,IAILC,WAAW;AAAA,MACTC,SAAS;AAAA,MACTC,YAAY;AAAA,MACZC,gBAAgB;AAAA,MAChBC,eAAe;AAAA,MACfC,KAAKA,CAAC;AAAA,QAAE3C,SAAAA;AAAAA,MAAAA,MAAqBA,EAAQ,CAAC;AAAA,MACtC4C,QAAQA,CAAC;AAAA,QAAE5C,SAAAA;AAAAA,MAAAA,MAAqBA,EAAQ,EAAE;AAAA,IAAA;AAAA,EAC5C;AAEJ;"}
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
export { createChartWidgetConfig } from './config-factory';
|
|
5
5
|
export type { ChartWidgetBaseConfig, CreateChartWidgetConfigParams, } from './config-factory';
|
|
6
6
|
export { flattenObjectArrayToCSV, scatterplotDataToCSV } from './csv-modifiers';
|
|
7
|
-
export { buildLegendConfig, buildGridConfig, createTooltipPositioner, } from './option-builders';
|
|
7
|
+
export { buildLegendConfig, buildGridConfig, createTooltipPositioner, createAxisLabelFormatter, createTooltipFormatter, applyXAxisFormatter, applyYAxisFormatter, } from './option-builders';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Theme } from '@mui/material';
|
|
2
2
|
import { LegendComponentOption } from 'echarts';
|
|
3
|
+
import { CallbackDataParams, TopLevelFormatterParams } from '../../../../node_modules/echarts/types/dist/shared';
|
|
3
4
|
/**
|
|
4
5
|
* Shared EChart configuration builders for chart widgets
|
|
5
6
|
*/
|
|
@@ -32,3 +33,53 @@ export declare function createTooltipPositioner(theme: Theme): (point: [number,
|
|
|
32
33
|
contentSize: [number, number];
|
|
33
34
|
viewSize: [number, number];
|
|
34
35
|
}) => Record<string, number>;
|
|
36
|
+
/**
|
|
37
|
+
* Creates an axis label formatter for ECharts
|
|
38
|
+
* Used to format numeric axis labels with a widget formatter
|
|
39
|
+
*
|
|
40
|
+
* @param formatter - Optional formatter function from widget config
|
|
41
|
+
* @returns Axis label formatter function or undefined
|
|
42
|
+
*/
|
|
43
|
+
export declare function createAxisLabelFormatter(formatter?: (value: number) => string): ((value: number) => string) | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Applies formatter to xAxis configuration
|
|
46
|
+
* Only applies to single axis objects (not arrays) with type 'value'
|
|
47
|
+
*
|
|
48
|
+
* @param xAxis - Existing xAxis configuration
|
|
49
|
+
* @param formatter - Optional formatter function from widget config
|
|
50
|
+
* @returns Updated xAxis configuration or undefined if no changes needed
|
|
51
|
+
*/
|
|
52
|
+
export declare function applyXAxisFormatter(xAxis: unknown, formatter?: (value: number) => string): {
|
|
53
|
+
axisLabel: {
|
|
54
|
+
formatter: ((value: number) => string) | undefined;
|
|
55
|
+
};
|
|
56
|
+
type?: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Applies formatter to yAxis configuration
|
|
60
|
+
* Only applies to single axis objects (not arrays) with type 'value'
|
|
61
|
+
*
|
|
62
|
+
* @param yAxis - Existing yAxis configuration
|
|
63
|
+
* @param formatter - Optional formatter function from widget config
|
|
64
|
+
* @returns Updated yAxis configuration or undefined if no changes needed
|
|
65
|
+
*/
|
|
66
|
+
export declare function applyYAxisFormatter(yAxis: unknown, formatter?: (value: number) => string): {
|
|
67
|
+
axisLabel: {
|
|
68
|
+
formatter: ((value: number) => string) | undefined;
|
|
69
|
+
};
|
|
70
|
+
type?: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Creates a tooltip formatter for ECharts
|
|
74
|
+
* Formats numeric values in tooltip using widget formatter
|
|
75
|
+
* Handles both axis trigger (array) and item trigger (object) modes
|
|
76
|
+
*
|
|
77
|
+
* @param formatter - Optional formatter function from widget config
|
|
78
|
+
* @returns Tooltip formatter function or undefined
|
|
79
|
+
*/
|
|
80
|
+
export declare function createTooltipFormatter(callback: (item: CallbackDataParams, items: CallbackDataParams[]) => {
|
|
81
|
+
name: string;
|
|
82
|
+
seriesName: string;
|
|
83
|
+
marker: string;
|
|
84
|
+
value: string | number;
|
|
85
|
+
}): (params: TopLevelFormatterParams) => string;
|
|
@@ -21,6 +21,10 @@ export interface WidgetsStoreProps {
|
|
|
21
21
|
refUI?: RefObject<HTMLElement | null>;
|
|
22
22
|
/** Registered tools for the widget's transformation pipeline */
|
|
23
23
|
registeredTools?: ToolRegistration[];
|
|
24
|
+
/** Formatter function for widget values */
|
|
25
|
+
formatter?: (value: number) => string;
|
|
26
|
+
/** Locale for number formatting (e.g., 'en-US', 'es-ES', 'fr-FR') */
|
|
27
|
+
locale?: string;
|
|
24
28
|
}
|
|
25
29
|
/**
|
|
26
30
|
* Tool transformation function type
|