@carto/ps-react-ui 4.3.5 → 4.3.7
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/components.js +123 -123
- package/dist/components.js.map +1 -1
- package/dist/error-CEkRPccv.js +39 -0
- package/dist/error-CEkRPccv.js.map +1 -0
- package/dist/{lasso-tool-wFqOD6wk.js → lasso-tool-jl4YK02H.js} +184 -159
- package/dist/lasso-tool-jl4YK02H.js.map +1 -0
- package/dist/no-data-hR3KcJ-_.js +60 -0
- package/dist/no-data-hR3KcJ-_.js.map +1 -0
- package/dist/{row-DrHwXNvF.js → row-BKmVAUN5.js} +2 -2
- package/dist/{row-DrHwXNvF.js.map → row-BKmVAUN5.js.map} +1 -1
- package/dist/{series-D3Pc-kYX.js → series-D1pynfeh.js} +3 -3
- package/dist/{series-D3Pc-kYX.js.map → series-D1pynfeh.js.map} +1 -1
- package/dist/{styles-CCZnY17y.js → styles-DrPyd0y5.js} +28 -22
- package/dist/styles-DrPyd0y5.js.map +1 -0
- package/dist/types/components/lasso-tool/types.d.ts +1 -1
- package/dist/types/widgets/_shared/chart-config/index.d.ts +1 -1
- package/dist/types/widgets/_shared/chart-config/option-builders.d.ts +7 -0
- package/dist/types/widgets/_shared/chart-config/option-builders.test.d.ts +1 -0
- package/dist/types/widgets/actions/index.d.ts +4 -4
- package/dist/types/widgets/actions/lock-selection/types.d.ts +0 -13
- package/dist/types/widgets/actions/relative-data/types.d.ts +0 -4
- package/dist/types/widgets/actions/searcher/types.d.ts +0 -2
- package/dist/types/widgets/actions/stack-toggle/stack-toggle.d.ts +3 -2
- package/dist/types/widgets/actions/stack-toggle/types.d.ts +0 -4
- package/dist/types/widgets/actions/zoom-toggle/zoom-toggle.d.ts +4 -0
- package/dist/types/widgets/echart/types.d.ts +0 -4
- package/dist/types/widgets/echart/utils.d.ts +2 -1
- package/dist/types/widgets/error/error.d.ts +1 -1
- package/dist/types/widgets/error/types.d.ts +8 -0
- package/dist/types/widgets/loader/loader.d.ts +1 -1
- package/dist/types/widgets/loader/types.d.ts +1 -1
- package/dist/types/widgets/stores/index.d.ts +1 -1
- package/dist/types/widgets/stores/types.d.ts +15 -0
- package/dist/{use-widget-ref-B0aNCANx.js → use-widget-ref-P-2i0MJG.js} +2 -2
- package/dist/{use-widget-ref-B0aNCANx.js.map → use-widget-ref-P-2i0MJG.js.map} +1 -1
- package/dist/{utils-D3-eQyDR.js → utils-idmvq0Oa.js} +17 -16
- package/dist/utils-idmvq0Oa.js.map +1 -0
- package/dist/widget-store-CzDt8oSK.js +163 -0
- package/dist/widget-store-CzDt8oSK.js.map +1 -0
- package/dist/widgets/actions.js +714 -659
- package/dist/widgets/actions.js.map +1 -1
- package/dist/widgets/bar.js +67 -63
- package/dist/widgets/bar.js.map +1 -1
- package/dist/widgets/category.js +250 -241
- package/dist/widgets/category.js.map +1 -1
- package/dist/widgets/echart.js +93 -100
- package/dist/widgets/echart.js.map +1 -1
- package/dist/widgets/error.js +1 -1
- package/dist/widgets/formula.js +64 -72
- package/dist/widgets/formula.js.map +1 -1
- package/dist/widgets/histogram.js +75 -73
- package/dist/widgets/histogram.js.map +1 -1
- package/dist/widgets/loader.js +41 -40
- package/dist/widgets/loader.js.map +1 -1
- package/dist/widgets/markdown.js +2 -2
- package/dist/widgets/no-data.js +1 -1
- package/dist/widgets/pie.js +4 -4
- package/dist/widgets/range.js +97 -105
- package/dist/widgets/range.js.map +1 -1
- package/dist/widgets/scatterplot.js +8 -8
- package/dist/widgets/skeleton-loader.js +1 -1
- package/dist/widgets/spread.js +84 -100
- package/dist/widgets/spread.js.map +1 -1
- package/dist/widgets/stores.js +1 -1
- package/dist/widgets/table.js +493 -485
- package/dist/widgets/table.js.map +1 -1
- package/dist/widgets/timeseries.js +4 -4
- package/dist/widgets/wrapper.js +156 -156
- package/dist/widgets/wrapper.js.map +1 -1
- package/dist/widgets.js +4 -4
- package/package.json +3 -3
- package/src/components/lasso-tool/lasso-tool-inline.tsx +19 -17
- package/src/components/lasso-tool/lasso-tool.tsx +27 -22
- package/src/components/lasso-tool/types.ts +4 -3
- package/src/widgets/_shared/chart-config/index.ts +1 -0
- package/src/widgets/_shared/chart-config/option-builders.test.ts +40 -0
- package/src/widgets/_shared/chart-config/option-builders.ts +12 -0
- package/src/widgets/actions/fullscreen/fullscreen.tsx +5 -8
- package/src/widgets/actions/index.ts +4 -7
- package/src/widgets/actions/lock-selection/lock-selection.test.tsx +28 -30
- package/src/widgets/actions/lock-selection/lock-selection.tsx +25 -26
- package/src/widgets/actions/lock-selection/types.ts +0 -17
- package/src/widgets/actions/relative-data/relative-data.test.tsx +13 -13
- package/src/widgets/actions/relative-data/relative-data.tsx +18 -21
- package/src/widgets/actions/relative-data/types.ts +0 -7
- package/src/widgets/actions/searcher/searcher.tsx +40 -22
- package/src/widgets/actions/searcher/types.ts +0 -2
- package/src/widgets/actions/stack-toggle/stack-toggle.test.tsx +160 -16
- package/src/widgets/actions/stack-toggle/stack-toggle.tsx +79 -78
- package/src/widgets/actions/stack-toggle/types.ts +0 -8
- package/src/widgets/actions/zoom-toggle/zoom-toggle.tsx +137 -87
- package/src/widgets/bar/config.ts +37 -28
- package/src/widgets/category/category-ui.tsx +25 -22
- package/src/widgets/echart/echart-ui.test.tsx +3 -18
- package/src/widgets/echart/echart-ui.tsx +4 -22
- package/src/widgets/echart/echart.test.tsx +9 -25
- package/src/widgets/echart/echart.tsx +36 -29
- package/src/widgets/echart/types.ts +0 -4
- package/src/widgets/echart/utils.ts +3 -1
- package/src/widgets/error/error.tsx +17 -14
- package/src/widgets/error/types.ts +10 -0
- package/src/widgets/formula/components/value.tsx +13 -13
- package/src/widgets/histogram/config.ts +36 -29
- package/src/widgets/loader/loader.tsx +20 -8
- package/src/widgets/loader/types.ts +3 -1
- package/src/widgets/no-data/no-data.tsx +8 -11
- package/src/widgets/range/components/range-item.tsx +9 -13
- package/src/widgets/spread/components/max-value.tsx +13 -13
- package/src/widgets/spread/components/min-value.tsx +13 -13
- package/src/widgets/stores/index.ts +1 -0
- package/src/widgets/stores/types.ts +17 -0
- package/src/widgets/stores/widget-store.test.ts +141 -0
- package/src/widgets/stores/widget-store.ts +73 -2
- package/src/widgets/table/hooks/use-pagination.ts +44 -35
- package/src/widgets/table/hooks/use-sort.ts +25 -23
- package/src/widgets/wrapper/wrapper-ui.tsx +16 -17
- package/dist/error-B2IJ9d2h.js +0 -38
- package/dist/error-B2IJ9d2h.js.map +0 -1
- package/dist/lasso-tool-wFqOD6wk.js.map +0 -1
- package/dist/no-data-C54XJt13.js +0 -61
- package/dist/no-data-C54XJt13.js.map +0 -1
- package/dist/styles-CCZnY17y.js.map +0 -1
- package/dist/utils-D3-eQyDR.js.map +0 -1
- package/dist/widget-store-CB6Trp_0.js +0 -131
- package/dist/widget-store-CB6Trp_0.js.map +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as h, jsxs as A } from "react/jsx-runtime";
|
|
2
|
+
import { c as T } from "react/compiler-runtime";
|
|
3
|
+
import { Typography as x, Box as E } from "@mui/material";
|
|
4
|
+
import { useShallow as c } from "zustand/shallow";
|
|
5
|
+
import { u as p } from "./widget-store-CzDt8oSK.js";
|
|
6
|
+
const W = {
|
|
7
|
+
root: {
|
|
8
|
+
display: "flex",
|
|
9
|
+
flexDirection: "column",
|
|
10
|
+
gap: 1,
|
|
11
|
+
// 8px
|
|
12
|
+
paddingTop: 1,
|
|
13
|
+
// 8px
|
|
14
|
+
paddingBottom: 2,
|
|
15
|
+
// 16px
|
|
16
|
+
paddingX: 2,
|
|
17
|
+
// 16px
|
|
18
|
+
width: "100%",
|
|
19
|
+
minHeight: "100%"
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function S(r) {
|
|
23
|
+
const t = T(13), {
|
|
24
|
+
id: i,
|
|
25
|
+
children: u,
|
|
26
|
+
title: y,
|
|
27
|
+
description: g,
|
|
28
|
+
isEmpty: m
|
|
29
|
+
} = r, f = y === void 0 ? "No data available" : y, d = g === void 0 ? "There are no results for the combination of filters applied to your data. Try tweaking your filters, or zoom and pan the map to adjust filters" : g, v = m === void 0 ? k : m;
|
|
30
|
+
let n;
|
|
31
|
+
t[0] !== i ? (n = (e) => e.widgets[i]?.isLoading, t[0] = i, t[1] = n) : n = t[1];
|
|
32
|
+
const w = p(c(n));
|
|
33
|
+
let s;
|
|
34
|
+
t[2] !== i ? (s = (e) => e.widgets[i]?.isFetching, t[2] = i, t[3] = s) : s = t[3];
|
|
35
|
+
const b = p(c(s));
|
|
36
|
+
let l;
|
|
37
|
+
t[4] !== i ? (l = (e) => e.widgets[i]?.data, t[4] = i, t[5] = l) : l = t[5];
|
|
38
|
+
const j = p(c(l));
|
|
39
|
+
if (w || b)
|
|
40
|
+
return u;
|
|
41
|
+
if (v(j)) {
|
|
42
|
+
let e;
|
|
43
|
+
t[6] !== f ? (e = /* @__PURE__ */ h(x, { variant: "body2", color: "text.primary", children: f }), t[6] = f, t[7] = e) : e = t[7];
|
|
44
|
+
let o;
|
|
45
|
+
t[8] !== d ? (o = /* @__PURE__ */ h(x, { variant: "caption", color: "text.secondary", children: d }), t[8] = d, t[9] = o) : o = t[9];
|
|
46
|
+
let a;
|
|
47
|
+
return t[10] !== e || t[11] !== o ? (a = /* @__PURE__ */ A(E, { sx: W.root, children: [
|
|
48
|
+
e,
|
|
49
|
+
o
|
|
50
|
+
] }), t[10] = e, t[11] = o, t[12] = a) : a = t[12], a;
|
|
51
|
+
}
|
|
52
|
+
return u;
|
|
53
|
+
}
|
|
54
|
+
function k(r) {
|
|
55
|
+
return r == null ? !0 : Array.isArray(r) ? !!(r.length === 0 || r.every((t) => Array.isArray(t) && t.length === 0)) : typeof r == "object" ? Object.keys(r).length === 0 : !1;
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
S as W
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=no-data-hR3KcJ-_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-data-hR3KcJ-_.js","sources":["../src/widgets/no-data/style.ts","../src/widgets/no-data/no-data.tsx"],"sourcesContent":["import type { SxProps, Theme } from '@mui/material'\n\n/**\n * Styles for NoData component matching Figma design specifications\n * Design reference: node 5781-11028\n */\nexport const styles: Record<string, SxProps<Theme>> = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 1, // 8px\n paddingTop: 1, // 8px\n paddingBottom: 2, // 16px\n paddingX: 2, // 16px\n width: '100%',\n minHeight: '100%',\n },\n}\n","import { Box, Typography } from '@mui/material'\nimport { useShallow } from 'zustand/shallow'\nimport { useWidgetStore } from '../stores/widget-store'\nimport type { WidgetNoDataProps } from './types'\nimport { styles } from './style'\n\n/**\n * NoData wrapper component that displays empty state UI when widget has no data\n *\n * Integrates with widget store to check loading/fetching state and data availability.\n * Works in conjunction with SkeletonLoader for complete loading/empty state handling.\n *\n * @example Basic usage\n * ```tsx\n * <NoData id=\"my-widget\">\n * <WidgetContent id=\"my-widget\" />\n * </NoData>\n * ```\n *\n * @example With SkeletonLoader\n * ```tsx\n * <SkeletonLoader id=\"my-widget\" Skeleton={MySkeleton}>\n * <NoData id=\"my-widget\">\n * <WidgetContent id=\"my-widget\" />\n * </NoData>\n * </SkeletonLoader>\n * ```\n *\n * @example With custom messages\n * ```tsx\n * <NoData\n * id=\"my-widget\"\n * title=\"No results found\"\n * description=\"Try adjusting your filters\"\n * >\n * <WidgetContent id=\"my-widget\" />\n * </NoData>\n * ```\n */\nexport function WidgetNoData({\n id,\n children,\n title = 'No data available',\n description = 'There are no results for the combination of filters applied to your data. Try tweaking your filters, or zoom and pan the map to adjust filters',\n isEmpty = defaultIsEmpty,\n}: WidgetNoDataProps) {\n // Subscribe to widget store with selective subscription for optimal performance\n const isLoading = useWidgetStore(\n useShallow((state) => state.widgets[id]?.isLoading),\n )\n const isFetching = useWidgetStore(\n useShallow((state) => state.widgets[id]?.isFetching),\n )\n const data = useWidgetStore(useShallow((state) => state.widgets[id]?.data))\n\n // If loading or fetching, show children\n // SkeletonLoader handles loading state, this allows proper composition\n if (isLoading || isFetching) {\n return children\n }\n\n // Check if data is empty\n if (isEmpty(data)) {\n return (\n <Box sx={styles.root}>\n <Typography variant='body2' color='text.primary'>\n {title}\n </Typography>\n <Typography variant='caption' color='text.secondary'>\n {description}\n </Typography>\n </Box>\n )\n }\n\n // Data exists, render children\n return children\n}\n\n/**\n * Default function to determine if data is empty\n * Handles various data structures commonly used in widgets\n */\nfunction defaultIsEmpty(data: unknown): boolean {\n // Null or undefined\n if (data == null) {\n return true\n }\n\n // Arrays (most common case)\n if (Array.isArray(data)) {\n // Empty array\n if (data.length === 0) {\n return true\n }\n\n // Array of arrays (CategoryWidget pattern: [[],[]])\n // Check if all inner arrays are empty\n if (data.every((item) => Array.isArray(item) && item.length === 0)) {\n return true\n }\n\n return false\n }\n\n // Objects\n if (typeof data === 'object') {\n return Object.keys(data).length === 0\n }\n\n // Primitives (numbers, strings, booleans) are considered valid data\n return false\n}\n"],"names":["styles","root","display","flexDirection","gap","paddingTop","paddingBottom","paddingX","width","minHeight","WidgetNoData","t0","$","_c","id","children","title","t1","description","t2","isEmpty","t3","undefined","defaultIsEmpty","t4","state","widgets","isLoading","useWidgetStore","useShallow","t5","state_0","isFetching","t6","state_1","data","t7","Typography","t8","t9","Box","Array","isArray","length","every","item","Object","keys"],"mappings":";;;;;AAMO,MAAMA,IAAyC;AAAA,EACpDC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,KAAK;AAAA;AAAA,IACLC,YAAY;AAAA;AAAA,IACZC,eAAe;AAAA;AAAA,IACfC,UAAU;AAAA;AAAA,IACVC,OAAO;AAAA,IACPC,WAAW;AAAA,EAAA;AAEf;ACsBO,SAAAC,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA,GAAsB;AAAA,IAAAC,IAAAA;AAAAA,IAAAC,UAAAA;AAAAA,IAAAC,OAAAC;AAAAA,IAAAC,aAAAC;AAAAA,IAAAC,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C,EAAMC,MACbmC,UAAAA;AAAAA,MAAAA;AAAAA,MAGAE;AAAAA,IAAAA,GAGF,GAAM1B,QAAAwB,GAAAxB,QAAA0B,GAAA1B,QAAA2B,KAAAA,IAAA3B,EAAA,EAAA,GAPN2B;AAAAA,EAOM;AAET,SAGMxB;AAAQ;AAOjB,SAASQ,EAAeY,GAAwB;AAE9C,SAAIA,KAAQ,OACH,KAILM,MAAMC,QAAQP,CAAI,IAEhBA,GAAAA,EAAKQ,WAAW,KAMhBR,EAAKS,MAAOC,CAAAA,MAASJ,MAAMC,QAAQG,CAAI,KAAKA,EAAKF,WAAW,CAAC,KAQ/D,OAAOR,KAAS,WACXW,OAAOC,KAAKZ,CAAI,EAAEQ,WAAW,IAI/B;AACT;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as d } from "react/jsx-runtime";
|
|
2
2
|
import { c as n } from "react/compiler-runtime";
|
|
3
3
|
import { Box as c } from "@mui/material";
|
|
4
|
-
import { u as m } from "./widget-store-
|
|
4
|
+
import { u as m } from "./widget-store-CzDt8oSK.js";
|
|
5
5
|
import { useShallow as s } from "zustand/shallow";
|
|
6
6
|
const f = {
|
|
7
7
|
item: {
|
|
@@ -32,4 +32,4 @@ export {
|
|
|
32
32
|
y as R,
|
|
33
33
|
f as s
|
|
34
34
|
};
|
|
35
|
-
//# sourceMappingURL=row-
|
|
35
|
+
//# sourceMappingURL=row-BKmVAUN5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-
|
|
1
|
+
{"version":3,"file":"row-BKmVAUN5.js","sources":["../src/widgets/formula/style.ts","../src/widgets/formula/components/row.tsx"],"sourcesContent":["import type { SxProps, Theme } from '@mui/material'\n\nexport const styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: (theme: Theme) => theme.spacing(2),\n },\n item: {\n '&[data-disabled=\"true\"]': {\n color: (theme: Theme) => theme.palette.text.disabled,\n },\n },\n row: {\n display: 'flex',\n alignItems: 'center',\n gap: (theme: Theme) => theme.spacing(1),\n\n '& + &': {\n marginTop: (theme: Theme) => theme.spacing(1),\n },\n },\n} satisfies Record<string, SxProps<Theme>>\n","import { Box } from '@mui/material'\nimport { styles } from '../style'\nimport type { FormulaWidgetState, RowProps } from '../types'\nimport { useWidgetStore } from '../../stores/widget-store'\nimport { useShallow } from 'zustand/shallow'\n\nexport function Row(props: RowProps) {\n const data = useWidgetStore(\n useShallow((state) => state.getWidget<FormulaWidgetState>(props.id)?.data),\n )\n\n return data?.map((_, index) => {\n return (\n <Box sx={styles.row} key={index}>\n {typeof props.children === 'function'\n ? props.children({ index })\n : props.children}\n </Box>\n )\n })\n}\n"],"names":["styles","item","color","theme","palette","text","disabled","row","display","alignItems","gap","spacing","marginTop","Row","props","$","_c","t0","id","state","getWidget","data","useWidgetStore","useShallow","t1","map","_","index","jsx","Box","children"],"mappings":";;;;;AAEO,MAAMA,IAAS;AAAA,EAMpBC,MAAM;AAAA,IACJ,2BAA2B;AAAA,MACzBC,OAAOA,CAACC,MAAiBA,EAAMC,QAAQC,KAAKC;AAAAA,IAAAA;AAAAA,EAC9C;AAAA,EAEFC,KAAK;AAAA,IACHC,SAAS;AAAA,IACTC,YAAY;AAAA,IACZC,KAAKA,CAACP,MAAiBA,EAAMQ,QAAQ,CAAC;AAAA,IAEtC,SAAS;AAAA,MACPC,WAAWA,CAACT,MAAiBA,EAAMQ,QAAQ,CAAC;AAAA,IAAA;AAAA,EAC9C;AAEJ;AChBO,SAAAE,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA;AAAA,MAAAC;AAAA,EAAAF,EAAA,CAAA,MAAAD,EAAAI,MAEQD,IAAAE,CAAAA,MAAWA,EAAKC,UAA+BN,EAAKI,EAAS,GAACG,MAAAN,EAAA,CAAA,IAAAD,EAAAI,IAAAH,OAAAE,KAAAA,IAAAF,EAAA,CAAA;AAD3E,QAAAM,IAAaC,EACXC,EAAWN,CAA8D,CAC3E;AAAC,MAAAO;AAAA,SAAAT,EAAA,CAAA,MAAAM,KAAAN,SAAAD,KAEMU,IAAAH,GAAII,IAAM,CAAAC,GAAAC,MAEb,gBAAAC,EAACC,GAAA,EAAQ,IAAA7B,EAAMO,KACZ,UAAA,OAAOO,EAAKgB,YAAc,aACvBhB,EAAKgB,SAAU;AAAA,IAAAH,OAAAA;AAAAA,EAAAA,CACF,IAAbb,EAAKgB,SAAAA,GAHeH,CAI1B,CAEH,GAACZ,OAAAM,GAAAN,OAAAD,GAAAC,OAAAS,KAAAA,IAAAT,EAAA,CAAA,GARKS;AAQL;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
2
|
import { c as h } from "react/compiler-runtime";
|
|
3
|
-
import { u as g } from "./widget-store-
|
|
3
|
+
import { u as g } from "./widget-store-CzDt8oSK.js";
|
|
4
4
|
import { useShallow as p } from "zustand/shallow";
|
|
5
5
|
import { Typography as S, Avatar as b } from "@mui/material";
|
|
6
|
-
import { s as P } from "./row-
|
|
6
|
+
import { s as P } from "./row-BKmVAUN5.js";
|
|
7
7
|
function y(i) {
|
|
8
8
|
const e = h(4);
|
|
9
9
|
let t;
|
|
@@ -88,4 +88,4 @@ export {
|
|
|
88
88
|
j as S,
|
|
89
89
|
I as a
|
|
90
90
|
};
|
|
91
|
-
//# sourceMappingURL=series-
|
|
91
|
+
//# sourceMappingURL=series-D1pynfeh.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"series-
|
|
1
|
+
{"version":3,"file":"series-D1pynfeh.js","sources":["../src/widgets/formula/components/item.tsx","../src/widgets/formula/components/prefix.tsx","../src/widgets/formula/components/suffix.tsx","../src/widgets/formula/components/series.tsx"],"sourcesContent":["import { Typography } from '@mui/material'\nimport type { ItemProps } from '../types'\nimport { styles } from '../style'\n\nexport function Item(props: ItemProps) {\n return (\n <Typography\n sx={styles.item}\n variant='h5'\n fontWeight='medium'\n data-disabled={props.disabled}\n color='default'\n {...props.TypographyProps}\n >\n {props.children}\n </Typography>\n )\n}\n","import { type FormulaWidgetState, type ValueProps } from '../types'\nimport { useWidgetStore } from '../../stores/widget-store'\nimport { Item } from './item'\nimport { useShallow } from 'zustand/shallow'\n\nexport function Prefix({ id, index = 0, ...props }: ValueProps) {\n const prefix = useWidgetStore(\n useShallow(\n (state) => state.getWidget<FormulaWidgetState>(id)?.data?.[index]?.prefix,\n ),\n )\n\n if (!prefix) {\n return null\n }\n\n return <Item {...props}>{prefix}</Item>\n}\n","import { type FormulaWidgetState, type ValueProps } from '../types'\nimport { useWidgetStore } from '../../stores/widget-store'\nimport { Item } from './item'\nimport type { Theme } from '@mui/material'\nimport { useShallow } from 'zustand/shallow'\n\nexport function Suffix({ id, index = 0, ...props }: ValueProps) {\n const suffix = useWidgetStore(\n useShallow(\n (state) => state.getWidget<FormulaWidgetState>(id)?.data?.[index]?.suffix,\n ),\n )\n\n if (!suffix) {\n return null\n }\n\n return (\n <Item\n TypographyProps={{\n color: (theme: Theme) => theme.palette.text.secondary,\n }}\n {...props}\n >\n {suffix}\n </Item>\n )\n}\n","import { Avatar } from '@mui/material'\nimport type { FormulaWidgetState, ValueProps } from '../types'\nimport { useWidgetStore } from '../../stores/widget-store'\nimport { useShallow } from 'zustand/shallow'\n\nexport function Series({ id, index = 0 }: Pick<ValueProps, 'id' | 'index'>) {\n const serie = useWidgetStore(\n useShallow(\n (state) => state.getWidget<FormulaWidgetState>(id)?.series?.[index],\n ),\n )\n if (!serie) {\n return null\n }\n\n const { name, color } = serie\n\n return (\n <Avatar\n sx={{\n bgcolor: color,\n width: 32,\n height: 32,\n fontSize: '0.875rem',\n fontWeight: 'medium',\n ...(color && {\n color: (theme) => theme.palette.getContrastText(color),\n }),\n }}\n >\n {name.charAt(0).toUpperCase()}\n </Avatar>\n )\n}\n"],"names":["Item","props","$","_c","t0","TypographyProps","children","disabled","Typography","styles","item","Prefix","id","t1","index","undefined","t2","state","getWidget","data","prefix","useWidgetStore","useShallow","t3","jsx","Suffix","suffix","Symbol","for","color","_temp","t4","theme","palette","text","secondary","Series","series","serie","name","getContrastText","bgcolor","width","height","fontSize","fontWeight","t5","charAt","toUpperCase","t6","Avatar"],"mappings":";;;;;;AAIO,SAAAA,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA;AAAA,MAAAC;AAAA,SAAAF,EAAA,CAAA,MAAAD,EAAAI,mBAAAH,EAAA,CAAA,MAAAD,EAAAK,YAAAJ,EAAA,CAAA,MAAAD,EAAAM,YAEHH,sBAACI,GAAA,EACK,IAAAC,EAAMC,MACF,SAAA,MACG,YAAA,UACI,iBAAAT,EAAKM,UACd,OAAA,WAAS,GACXN,EAAKI,iBAERJ,YAAKK,UACR,GAAaJ,EAAA,CAAA,IAAAD,EAAAI,iBAAAH,EAAA,CAAA,IAAAD,EAAAK,UAAAJ,EAAA,CAAA,IAAAD,EAAAM,UAAAL,OAAAE,KAAAA,IAAAF,EAAA,CAAA,GATbE;AASa;ACVV,SAAAO,EAAAP,GAAA;AAAA,QAAAF,IAAAC,EAAA,EAAA;AAAA,MAAAS,GAAAX,GAAAY;AAAA,EAAAX,SAAAE,KAAgB;AAAA,IAAAQ,IAAAA;AAAAA,IAAAE,OAAAD;AAAAA,IAAA,GAAAZ;AAAAA,EAAAA,IAAAG,GAAuCF,OAAAE,GAAAF,OAAAU,GAAAV,OAAAD,GAAAC,OAAAW,MAAAD,IAAAV,EAAA,CAAA,GAAAD,IAAAC,EAAA,CAAA,GAAAW,IAAAX,EAAA,CAAA;AAAjC,QAAAY,IAAAD,MAAAE,SAAA,IAAAF;AAAS,MAAAG;AAAA,EAAAd,EAAA,CAAA,MAAAU,KAAAV,SAAAY,KAGhCE,IAAAC,OAAWA,EAAKC,UAA+BN,CAAQ,GAACO,OAAGL,CAAK,GAASM,QAAAlB,OAAAU,GAAAV,OAAAY,GAAAZ,OAAAc,KAAAA,IAAAd,EAAA,CAAA;AAF7E,QAAAkB,IAAeC,EACbC,EACEN,CACF,C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AqC,GAAArC,OAAA4C,KAAAA,IAAA5C,EAAA,CAAA;AAAA,MAAA+C;AAAA,SAAA/C,EAAA,EAAA,MAAA6B,KAAA7B,UAAA4C,KAZ/BG,IAAA,gBAAAzB,EAAC0B,GAAA,EACK,IAAAnB,GAWHe,UAAAA,GACH,GAAS5C,QAAA6B,GAAA7B,QAAA4C,GAAA5C,QAAA+C,KAAAA,IAAA/C,EAAA,EAAA,GAbT+C;AAaS;"}
|
|
@@ -20,6 +20,11 @@ function y(t) {
|
|
|
20
20
|
}), e;
|
|
21
21
|
}
|
|
22
22
|
function F(t) {
|
|
23
|
+
if (t <= 0) return 0;
|
|
24
|
+
const e = Math.pow(10, Math.floor(Math.log10(t)));
|
|
25
|
+
return Math.ceil(t / e) * e;
|
|
26
|
+
}
|
|
27
|
+
function b(t) {
|
|
23
28
|
return {
|
|
24
29
|
show: t,
|
|
25
30
|
icon: "circle",
|
|
@@ -29,7 +34,7 @@ function F(t) {
|
|
|
29
34
|
type: "scroll"
|
|
30
35
|
};
|
|
31
36
|
}
|
|
32
|
-
function
|
|
37
|
+
function x(t, e) {
|
|
33
38
|
return {
|
|
34
39
|
...!t && {
|
|
35
40
|
bottom: parseInt(e.spacing(3))
|
|
@@ -39,19 +44,19 @@ function v(t, e) {
|
|
|
39
44
|
}
|
|
40
45
|
};
|
|
41
46
|
}
|
|
42
|
-
function
|
|
47
|
+
function d(t) {
|
|
43
48
|
return function(e, n, i, o, r) {
|
|
44
|
-
const
|
|
49
|
+
const c = {
|
|
45
50
|
top: parseInt(t.spacing(0.5))
|
|
46
51
|
};
|
|
47
|
-
return r.contentSize[0] < r.viewSize[0] - e[0] ?
|
|
52
|
+
return r.contentSize[0] < r.viewSize[0] - e[0] ? c.left = e[0] : c.right = r.viewSize[0] - e[0], c;
|
|
48
53
|
};
|
|
49
54
|
}
|
|
50
55
|
function u(t) {
|
|
51
56
|
if (t)
|
|
52
57
|
return (e) => t(e);
|
|
53
58
|
}
|
|
54
|
-
function
|
|
59
|
+
function v(t, e) {
|
|
55
60
|
let n = u(e);
|
|
56
61
|
const i = t && !Array.isArray(t), o = t;
|
|
57
62
|
return (!i || o.type !== "value") && (n = void 0), {
|
|
@@ -62,30 +67,30 @@ function b(t, e) {
|
|
|
62
67
|
}
|
|
63
68
|
};
|
|
64
69
|
}
|
|
65
|
-
function
|
|
70
|
+
function w(t) {
|
|
66
71
|
return (e) => {
|
|
67
72
|
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
73
|
const {
|
|
69
74
|
name: a,
|
|
70
|
-
seriesName:
|
|
71
|
-
marker:
|
|
75
|
+
seriesName: l,
|
|
76
|
+
marker: g,
|
|
72
77
|
value: h
|
|
73
78
|
} = t(s, n);
|
|
74
79
|
return {
|
|
75
80
|
name: a,
|
|
76
|
-
seriesName:
|
|
77
|
-
marker:
|
|
81
|
+
seriesName: l,
|
|
82
|
+
marker: g,
|
|
78
83
|
value: h
|
|
79
84
|
};
|
|
80
|
-
}), r = o[0]?.name ?? "", p = r || n.length > 1 ? "margin: 10px 0 0;line-height:1;" : "margin: 0;line-height:1;",
|
|
85
|
+
}), r = o[0]?.name ?? "", p = r || n.length > 1 ? "margin: 10px 0 0;line-height:1;" : "margin: 0;line-height:1;", f = o.map(({
|
|
81
86
|
seriesName: s,
|
|
82
87
|
marker: a,
|
|
83
|
-
value:
|
|
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">${
|
|
85
|
-
return i(r,
|
|
88
|
+
value: l
|
|
89
|
+
}) => `<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">${l}</span></div></div>`);
|
|
90
|
+
return i(r, f.join(""));
|
|
86
91
|
};
|
|
87
92
|
}
|
|
88
|
-
const
|
|
93
|
+
const S = {
|
|
89
94
|
graph: {
|
|
90
95
|
/**
|
|
91
96
|
* Common container style for chart widget skeletons
|
|
@@ -105,13 +110,14 @@ const w = {
|
|
|
105
110
|
}
|
|
106
111
|
};
|
|
107
112
|
export {
|
|
108
|
-
|
|
109
|
-
b,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
d as a,
|
|
114
|
+
x as b,
|
|
115
|
+
w as c,
|
|
116
|
+
b as d,
|
|
117
|
+
S as e,
|
|
113
118
|
m as f,
|
|
114
|
-
|
|
119
|
+
v as g,
|
|
120
|
+
F as n,
|
|
115
121
|
y as s
|
|
116
122
|
};
|
|
117
|
-
//# sourceMappingURL=styles-
|
|
123
|
+
//# sourceMappingURL=styles-DrPyd0y5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles-DrPyd0y5.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 * 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\n */\nexport function niceNum(value: number): number {\n if (value <= 0) return 0\n const base = Math.pow(10, Math.floor(Math.log10(value)))\n return Math.ceil(value / base) * base\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","niceNum","value","base","Math","pow","floor","log10","ceil","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","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,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,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EAAM3D,SAAS,IAEtC,oCACA,4BAEEkE,IAAkBzD,EAAOC,IAC7B,CAAC;AAAA,MAAEqD,YAAAA;AAAAA,MAAYC,QAAAA;AAAAA,MAAQjD,OAAAA;AAAAA,IAAAA,MACrB,eAAekD,CAAW,iDAAiDD,CAAM,GAAGD,IAAa,gGAAgGA,CAAU,YAAY,EAAE,2FAA2FhD,CAAK,qBAC7T;AAEA,WAAO6C,EAAQC,GAAMK,EAAgBC,KAAK,EAAE,CAAC;AAAA,EAC/C;AACF;ACjNO,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,QAAE1C,SAAAA;AAAAA,MAAAA,MAAqBA,EAAQ,CAAC;AAAA,MACtC2C,QAAQA,CAAC;AAAA,QAAE3C,SAAAA;AAAAA,MAAAA,MAAqBA,EAAQ,EAAE;AAAA,IAAA;AAAA,EAC5C;AAEJ;"}
|
|
@@ -9,7 +9,7 @@ export interface LassoToolsData {
|
|
|
9
9
|
interface LassoToolsComponentBaseProps<M extends string = LassoToolsMode> {
|
|
10
10
|
enabled: boolean;
|
|
11
11
|
modes: Partial<LassoToolsModes<M>>;
|
|
12
|
-
modesMapping: LassoToolsModesMapping<M
|
|
12
|
+
modesMapping: Partial<LassoToolsModesMapping<M>>;
|
|
13
13
|
values: LassoToolsData[];
|
|
14
14
|
labels?: {
|
|
15
15
|
action?: {
|
|
@@ -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, createAxisLabelFormatter, createTooltipFormatter, applyXAxisFormatter, applyYAxisFormatter, } from './option-builders';
|
|
7
|
+
export { buildLegendConfig, buildGridConfig, createTooltipPositioner, createAxisLabelFormatter, createTooltipFormatter, applyXAxisFormatter, applyYAxisFormatter, niceNum, } from './option-builders';
|
|
@@ -4,6 +4,13 @@ import { CallbackDataParams, TopLevelFormatterParams } from '../../../../node_mo
|
|
|
4
4
|
/**
|
|
5
5
|
* Shared EChart configuration builders for chart widgets
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Rounds a value up to the nearest "nice" number.
|
|
9
|
+
* A nice number is a multiple of 10^floor(log10(value)).
|
|
10
|
+
*
|
|
11
|
+
* Examples: 547 → 600, 200 → 200, 1200 → 2000, 18 → 20, 5 → 5
|
|
12
|
+
*/
|
|
13
|
+
export declare function niceNum(value: number): number;
|
|
7
14
|
/**
|
|
8
15
|
* Builds standard legend configuration for chart widgets
|
|
9
16
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,14 +5,14 @@ export type { DownloadItem, DownloadProps } from './download/types';
|
|
|
5
5
|
export { downloadToCSV, downloadToPNG } from './download/exports';
|
|
6
6
|
export { RelativeData, RELATIVE_DATA_TOOL_ID, } from './relative-data/relative-data';
|
|
7
7
|
export type { RelativeDataProps } from './relative-data/types';
|
|
8
|
-
export { ZoomToggle } from './zoom-toggle/zoom-toggle';
|
|
8
|
+
export { ZoomToggle, ZOOM_TOGGLE_TOOL_ID } from './zoom-toggle/zoom-toggle';
|
|
9
9
|
export type { ZoomToggleProps, ZoomState, ZoomConfig, } from './zoom-toggle/types';
|
|
10
|
-
export { StackToggle } from './stack-toggle/stack-toggle';
|
|
11
|
-
export type { StackToggleProps
|
|
10
|
+
export { StackToggle, STACK_TOGGLE_TOOL_ID } from './stack-toggle/stack-toggle';
|
|
11
|
+
export type { StackToggleProps } from './stack-toggle/types';
|
|
12
12
|
export { Searcher, SEARCHER_TOOL_ID } from './searcher/searcher';
|
|
13
13
|
export { SearcherToggle } from './searcher/searcher-toggle';
|
|
14
14
|
export type { SearcherToggleProps, SearcherProps, SearcherFilterFn, SearcherState, } from './searcher/types';
|
|
15
15
|
export { ChangeColumn } from './change-column/change-column';
|
|
16
16
|
export type { ChangeColumnProps } from './change-column/types';
|
|
17
17
|
export { LockSelection, LOCK_SELECTION_TOOL_ID, } from './lock-selection/lock-selection';
|
|
18
|
-
export type { LockSelectionProps
|
|
18
|
+
export type { LockSelectionProps } from './lock-selection/types';
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
import { IconButtonProps } from '@mui/material';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { BaseWidgetState } from '../../stores/types';
|
|
4
|
-
/**
|
|
5
|
-
* Lock selection specific state properties.
|
|
6
|
-
*/
|
|
7
|
-
export interface LockSelectionStateProps {
|
|
8
|
-
/** Whether the selection is currently locked */
|
|
9
|
-
isLocked?: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Widget state extension for lock selection functionality.
|
|
13
|
-
* Extends the base widget state with lock-specific properties.
|
|
14
|
-
*/
|
|
15
|
-
export type LockSelectionState<T = object> = BaseWidgetState<T & LockSelectionStateProps>;
|
|
16
3
|
export interface LockSelectionProps {
|
|
17
4
|
/** Widget ID to store lock selection state */
|
|
18
5
|
id: string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IconButtonProps } from '@mui/material';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { BaseWidgetState } from '../../stores/types';
|
|
4
3
|
export interface RelativeDataProps {
|
|
5
4
|
/** Widget ID to update data in the widget store */
|
|
6
5
|
id: string;
|
|
@@ -22,6 +21,3 @@ export interface RelativeDataProps {
|
|
|
22
21
|
/** Custom icon to display */
|
|
23
22
|
Icon?: ReactNode;
|
|
24
23
|
}
|
|
25
|
-
export type RelativeDataState<T = unknown> = BaseWidgetState<T & {
|
|
26
|
-
isRelative?: boolean;
|
|
27
|
-
}>;
|
|
@@ -14,8 +14,6 @@ export type SearcherFilterFn = (data: EchartWidgetData, searchText: string) => P
|
|
|
14
14
|
export interface SearcherStateProps {
|
|
15
15
|
/** Whether search is currently enabled */
|
|
16
16
|
isSearchEnabled?: boolean;
|
|
17
|
-
/** Current search text */
|
|
18
|
-
searchText?: string;
|
|
19
17
|
}
|
|
20
18
|
/**
|
|
21
19
|
* Widget state extension for searcher functionality.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { StackToggleProps } from './types';
|
|
2
|
+
export declare const STACK_TOGGLE_TOOL_ID = "stack-toggle";
|
|
2
3
|
/**
|
|
3
4
|
* Widget action to toggle stacking behavior in ECharts bar and histogram widgets.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* Registers as a config pipeline tool so that stack configuration is automatically
|
|
7
|
+
* re-applied when the base config is updated (e.g., by WidgetLoader).
|
|
7
8
|
*
|
|
8
9
|
* @example
|
|
9
10
|
* ```tsx
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IconButtonProps } from '@mui/material';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { BaseWidgetState } from '../../stores/types';
|
|
4
3
|
export interface StackToggleProps {
|
|
5
4
|
/** Widget ID to update stack configuration in the widget store */
|
|
6
5
|
id: string;
|
|
@@ -20,6 +19,3 @@ export interface StackToggleProps {
|
|
|
20
19
|
/** Custom icon to display */
|
|
21
20
|
Icon?: ReactNode;
|
|
22
21
|
}
|
|
23
|
-
export type StackToggleState<T = unknown> = BaseWidgetState<T & {
|
|
24
|
-
isStacked?: boolean;
|
|
25
|
-
}>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { ZoomToggleProps } from './types';
|
|
2
|
+
export declare const ZOOM_TOGGLE_TOOL_ID = "zoom-toggle";
|
|
2
3
|
/**
|
|
3
4
|
* Widget action to toggle EChart zoom functionality.
|
|
4
5
|
*
|
|
6
|
+
* Registers as a config pipeline tool so that zoom configuration is automatically
|
|
7
|
+
* re-applied when the base config is updated (e.g., by WidgetLoader).
|
|
8
|
+
*
|
|
5
9
|
* When zoom is active, displays an inline reset button to disable zoom.
|
|
6
10
|
* Only intended for use in fullscreen ToolbarActions for bar and histogram widgets.
|
|
7
11
|
*
|
|
@@ -4,13 +4,11 @@ import { Ref } from 'react';
|
|
|
4
4
|
import { theme as CartoTheme } from '@carto/meridian-ds/theme';
|
|
5
5
|
import type * as echarts from 'echarts';
|
|
6
6
|
export type EchartOptionsProps = EChartsOption;
|
|
7
|
-
export type EchartReplaceMerge = string[];
|
|
8
7
|
export interface EchartUIProps {
|
|
9
8
|
id: string;
|
|
10
9
|
option: EchartOptionsProps;
|
|
11
10
|
className?: string;
|
|
12
11
|
init?: echarts.EChartsInitOpts;
|
|
13
|
-
replaceMerge?: EchartReplaceMerge;
|
|
14
12
|
style?: React.CSSProperties;
|
|
15
13
|
ref?: Ref<echarts.ECharts>;
|
|
16
14
|
onEvents?: Record<string, Parameters<echarts.ECharts['on']>[2]>;
|
|
@@ -23,7 +21,6 @@ export type EchartWidgetState = BaseWidgetState<{
|
|
|
23
21
|
option: EchartUIProps['option'];
|
|
24
22
|
onEvents?: EchartUIProps['onEvents'];
|
|
25
23
|
init?: EchartUIProps['init'];
|
|
26
|
-
replaceMerge?: EchartReplaceMerge;
|
|
27
24
|
}>;
|
|
28
25
|
export interface EchartWidgetOptionProps<D> {
|
|
29
26
|
data?: D;
|
|
@@ -34,5 +31,4 @@ export interface EchartWidgetProps {
|
|
|
34
31
|
type: string;
|
|
35
32
|
option: EchartUIProps['option'];
|
|
36
33
|
onEvents?: EchartUIProps['onEvents'];
|
|
37
|
-
replaceMerge?: EchartReplaceMerge;
|
|
38
34
|
}
|
|
@@ -4,12 +4,13 @@ export declare function mergeEchartWidgetConfig<T extends EchartOptionsProps>(..
|
|
|
4
4
|
export declare function getEChartZoomConfig(zoom: boolean, { start, end }?: {
|
|
5
5
|
start: number;
|
|
6
6
|
end: number;
|
|
7
|
-
}, { inside, xSlider, ySlider, showSliders, xAxisLabelFormatter, }?: {
|
|
7
|
+
}, { inside, xSlider, ySlider, showSliders, xAxisLabelFormatter, bottomOffset, }?: {
|
|
8
8
|
inside?: boolean;
|
|
9
9
|
xSlider?: boolean;
|
|
10
10
|
ySlider?: boolean;
|
|
11
11
|
showSliders?: boolean;
|
|
12
12
|
xAxisLabelFormatter?: (value: number) => string;
|
|
13
|
+
bottomOffset?: number;
|
|
13
14
|
}, theme?: Theme): {
|
|
14
15
|
dataZoom: ({
|
|
15
16
|
throttle: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { WidgetErrorProps } from './types';
|
|
2
|
-
export declare function WidgetError({ id, children }: WidgetErrorProps): string | number | bigint | boolean | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
2
|
+
export declare function WidgetError({ id, children, title: titleProp, description, }: WidgetErrorProps): string | number | bigint | boolean | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { WidgetLoaderProps } from './types';
|
|
2
|
-
export declare function WidgetLoader<T
|
|
2
|
+
export declare function WidgetLoader<T extends object = Record<string, unknown>>(props: WidgetLoaderProps<T>): import('react').ReactNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { WidgetsStoreProps, WidgetState } from '../stores/types';
|
|
3
|
-
export interface WidgetLoaderProps<T
|
|
3
|
+
export interface WidgetLoaderProps<T extends object = Record<string, unknown>> extends WidgetsStoreProps {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
config?: T;
|
|
6
6
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { useWidgetStore } from './widget-store';
|
|
2
|
-
export type { BaseWidgetState, WidgetsStoreProps, WidgetState, WidgetStore, WidgetStoreActions, WidgetStoreState, } from './types';
|
|
2
|
+
export type { BaseWidgetState, ToolType, WidgetsStoreProps, WidgetState, WidgetStore, WidgetStoreActions, WidgetStoreState, } from './types';
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Tool type determines which pipeline a tool participates in.
|
|
4
|
+
* - 'data': transforms widget data (default)
|
|
5
|
+
* - 'config': transforms widget config/option
|
|
6
|
+
*/
|
|
7
|
+
export type ToolType = 'data' | 'config';
|
|
2
8
|
export interface WidgetsStoreProps {
|
|
3
9
|
/** Unique identifier for the widget */
|
|
4
10
|
id: string;
|
|
@@ -70,6 +76,8 @@ export interface ToolRegistration {
|
|
|
70
76
|
fn: ToolTransformFunction;
|
|
71
77
|
/** Whether tool is currently enabled */
|
|
72
78
|
enabled: boolean;
|
|
79
|
+
/** 'data' (default) transforms data, 'config' transforms widget config/option */
|
|
80
|
+
type?: ToolType;
|
|
73
81
|
/** Tool-specific configuration */
|
|
74
82
|
config?: Record<string, unknown>;
|
|
75
83
|
/**
|
|
@@ -158,6 +166,13 @@ export interface WidgetStoreActions {
|
|
|
158
166
|
* @param sourceData - Original data to transform
|
|
159
167
|
*/
|
|
160
168
|
executeToolPipeline: (widgetId: string, sourceData: unknown) => Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Execute the config transformation pipeline
|
|
171
|
+
* Applies config-type tools to the base config, then sets the result on the widget
|
|
172
|
+
* @param widgetId - Widget ID
|
|
173
|
+
* @param baseConfig - Base config to transform
|
|
174
|
+
*/
|
|
175
|
+
executeConfigPipeline: (widgetId: string, baseConfig: object) => Promise<void>;
|
|
161
176
|
}
|
|
162
177
|
/**
|
|
163
178
|
* Complete widget store interface
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as u } from "react/compiler-runtime";
|
|
2
2
|
import { useRef as n, useEffect as c } from "react";
|
|
3
|
-
import { u as i } from "./widget-store-
|
|
3
|
+
import { u as i } from "./widget-store-CzDt8oSK.js";
|
|
4
4
|
function a(t) {
|
|
5
5
|
const e = u(4), s = n(null), r = i(m);
|
|
6
6
|
let f, o;
|
|
@@ -16,4 +16,4 @@ function m(t) {
|
|
|
16
16
|
export {
|
|
17
17
|
a as u
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=use-widget-ref-
|
|
19
|
+
//# sourceMappingURL=use-widget-ref-P-2i0MJG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-widget-ref-
|
|
1
|
+
{"version":3,"file":"use-widget-ref-P-2i0MJG.js","sources":["../src/hooks/use-widget-ref.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport { useWidgetStore } from '../widgets/stores/widget-store'\n\n/**\n * Custom hook for registering a DOM element ref with the widget store.\n * This allows other parts of the application to access the widget's DOM element.\n *\n * @param widgetId - The widget ID to register the ref under\n * @returns A ref object to attach to the DOM element\n *\n * @example\n * ```tsx\n * function MyWidget({ id }: { id: string }) {\n * const ref = useWidgetRef<HTMLDivElement>(id)\n *\n * return <div ref={ref}>Widget content</div>\n * }\n * ```\n */\nexport function useWidgetRef<T extends HTMLElement = HTMLElement>(\n widgetId: string,\n) {\n const ref = useRef<T | null>(null)\n const setWidget = useWidgetStore((store) => store.setWidget)\n\n useEffect(() => {\n if (ref.current) {\n setWidget(widgetId, { refUI: ref })\n }\n }, [widgetId, setWidget])\n\n return ref\n}\n"],"names":["useWidgetRef","widgetId","$","_c","ref","useRef","setWidget","useWidgetStore","_temp","t0","t1","current","refUI","useEffect","store"],"mappings":";;;AAmBO,SAAAA,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAGLC,IAAYC,EAAiB,IAAI,GACjCC,IAAkBC,EAAeC,CAA0B;AAAC,MAAAC,GAAAC;AAAA,SAAAR,EAAA,CAAA,MAAAI,KAAAJ,SAAAD,KAElDQ,IAAAA,MAAA;AACR,IAAIL,EAAGO,WACLL,EAAUL,GAAU;AAAA,MAAAW,OAASR;AAAAA,IAAAA,CAAK;AAAA,EACnC,GACAM,IAAA,CAACT,GAAUK,CAAS,GAACJ,OAAAI,GAAAJ,OAAAD,GAAAC,OAAAO,GAAAP,OAAAQ,MAAAD,IAAAP,EAAA,CAAA,GAAAQ,IAAAR,EAAA,CAAA,IAJxBW,EAAUJ,GAIPC,CAAqB,GAEjBN;AAAG;AAZL,SAAAI,EAAAM,GAAA;AAAA,SAIuCA,EAAKR;AAAU;"}
|