@carto/ps-react-ui 4.4.2 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/download-config-DemuQ3Jm.js +56 -0
- package/dist/download-config-DemuQ3Jm.js.map +1 -0
- package/dist/error-Cj8eUMrl.js +40 -0
- package/dist/error-Cj8eUMrl.js.map +1 -0
- package/dist/formatter-B9Bxn1k7.js +6 -0
- package/dist/formatter-B9Bxn1k7.js.map +1 -0
- package/dist/no-data-DkIt7Qt1.js +61 -0
- package/dist/no-data-DkIt7Qt1.js.map +1 -0
- package/dist/row-D4VOhcNI.js +34 -0
- package/dist/row-D4VOhcNI.js.map +1 -0
- package/dist/series-Bola3CmD.js +90 -0
- package/dist/series-Bola3CmD.js.map +1 -0
- package/dist/styles-Y8q7Jff3.js +118 -0
- package/dist/styles-Y8q7Jff3.js.map +1 -0
- package/dist/types/widgets/actions/brush-toggle/types.d.ts +8 -2
- package/dist/types/widgets/category/components/category-row-multi.d.ts +2 -1
- package/dist/types/widgets/category/components/category-row-single.d.ts +2 -1
- package/dist/types/widgets/category/types.d.ts +1 -0
- package/dist/types/widgets/echart/shared-resize-observer.d.ts +12 -0
- package/dist/types/widgets/echart/types.d.ts +2 -0
- package/dist/types/widgets/histogram/config.d.ts +15 -3
- package/dist/types/widgets/histogram/index.d.ts +2 -1
- package/dist/types/widgets/histogram/types.d.ts +6 -3
- package/dist/types/widgets/stores/index.d.ts +2 -1
- package/dist/types/widgets/stores/types.d.ts +2 -0
- package/dist/types/widgets/stores/use-widget-selector.d.ts +35 -0
- package/dist/types/widgets/stores/widget-store-performance.test.d.ts +1 -0
- package/dist/types/widgets/stores/widget-store.d.ts +49 -27
- package/dist/types/widgets/table/types.d.ts +1 -1
- package/dist/types/widgets/utils/chart-config/index.d.ts +1 -1
- package/dist/types/widgets/utils/chart-config/option-builders.d.ts +13 -8
- package/dist/types/widgets/utils/formatter.d.ts +1 -0
- package/dist/types/widgets/utils/index.d.ts +1 -1
- package/dist/use-widget-ref-BFazQvJK.js +22 -0
- package/dist/use-widget-ref-BFazQvJK.js.map +1 -0
- package/dist/use-widget-selector-DqRmWQ1K.js +12 -0
- package/dist/use-widget-selector-DqRmWQ1K.js.map +1 -0
- package/dist/widget-store-CIrb9RKP.js +263 -0
- package/dist/widget-store-CIrb9RKP.js.map +1 -0
- package/dist/widgets/actions.js +799 -817
- package/dist/widgets/actions.js.map +1 -1
- package/dist/widgets/bar.js +53 -47
- package/dist/widgets/bar.js.map +1 -1
- package/dist/widgets/category.js +261 -255
- package/dist/widgets/category.js.map +1 -1
- package/dist/widgets/echart.js +109 -99
- package/dist/widgets/echart.js.map +1 -1
- package/dist/widgets/error.js +1 -1
- package/dist/widgets/formula.js +71 -63
- package/dist/widgets/formula.js.map +1 -1
- package/dist/widgets/histogram.js +119 -80
- package/dist/widgets/histogram.js.map +1 -1
- package/dist/widgets/loader.js +53 -60
- package/dist/widgets/loader.js.map +1 -1
- package/dist/widgets/markdown.js +51 -50
- package/dist/widgets/markdown.js.map +1 -1
- package/dist/widgets/no-data.js +1 -1
- package/dist/widgets/pie.js +111 -99
- package/dist/widgets/pie.js.map +1 -1
- package/dist/widgets/range.js +146 -144
- package/dist/widgets/range.js.map +1 -1
- package/dist/widgets/scatterplot.js +50 -44
- package/dist/widgets/scatterplot.js.map +1 -1
- package/dist/widgets/skeleton-loader.js +18 -17
- package/dist/widgets/skeleton-loader.js.map +1 -1
- package/dist/widgets/spread.js +110 -94
- package/dist/widgets/spread.js.map +1 -1
- package/dist/widgets/stores.js +5 -2
- package/dist/widgets/stores.js.map +1 -1
- package/dist/widgets/table.js +422 -436
- package/dist/widgets/table.js.map +1 -1
- package/dist/widgets/timeseries.js +52 -46
- package/dist/widgets/timeseries.js.map +1 -1
- package/dist/widgets/toolbar-actions.js +101 -6693
- package/dist/widgets/toolbar-actions.js.map +1 -1
- package/dist/widgets/utils.js +16 -14
- package/dist/widgets/utils.js.map +1 -1
- package/dist/widgets/wrapper.js +156 -158
- package/dist/widgets/wrapper.js.map +1 -1
- package/dist/widgets.js +4 -4
- package/package.json +5 -4
- package/src/hooks/use-widget-ref.ts +3 -4
- package/src/widgets/README.md +3 -3
- package/src/widgets/actions/brush-toggle/brush-toggle.tsx +60 -79
- package/src/widgets/actions/brush-toggle/types.ts +8 -2
- package/src/widgets/actions/change-column/change-column.tsx +15 -15
- package/src/widgets/actions/change-column/sortable-column-item.tsx +3 -1
- package/src/widgets/actions/download/download.tsx +4 -3
- package/src/widgets/actions/fullscreen/fullscreen.tsx +7 -11
- package/src/widgets/actions/lock-selection/lock-selection.tsx +12 -15
- package/src/widgets/actions/relative-data/relative-data.tsx +22 -26
- package/src/widgets/actions/searcher/searcher-toggle.tsx +11 -12
- package/src/widgets/actions/searcher/searcher.tsx +20 -21
- package/src/widgets/actions/stack-toggle/stack-toggle.tsx +15 -21
- package/src/widgets/actions/zoom-toggle/zoom-toggle.tsx +27 -43
- package/src/widgets/bar/config.ts +22 -14
- package/src/widgets/category/category-ui.tsx +31 -27
- package/src/widgets/category/components/category-row-multi.tsx +6 -2
- package/src/widgets/category/components/category-row-single.tsx +5 -1
- package/src/widgets/category/types.ts +1 -0
- package/src/widgets/echart/echart-ui.test.tsx +20 -16
- package/src/widgets/echart/echart-ui.tsx +6 -12
- package/src/widgets/echart/echart.tsx +13 -27
- package/src/widgets/echart/shared-resize-observer.ts +45 -0
- package/src/widgets/echart/types.ts +2 -0
- package/src/widgets/error/error.tsx +7 -9
- package/src/widgets/formula/components/prefix.tsx +4 -6
- package/src/widgets/formula/components/row.tsx +4 -4
- package/src/widgets/formula/components/series.tsx +4 -6
- package/src/widgets/formula/components/suffix.tsx +4 -6
- package/src/widgets/formula/components/value.tsx +9 -16
- package/src/widgets/histogram/config.ts +101 -20
- package/src/widgets/histogram/index.ts +6 -1
- package/src/widgets/histogram/types.ts +9 -3
- package/src/widgets/loader/loader.tsx +31 -44
- package/src/widgets/markdown/markdown.tsx +4 -7
- package/src/widgets/no-data/no-data.tsx +7 -10
- package/src/widgets/pie/config.ts +17 -5
- package/src/widgets/range/components/range-item.tsx +20 -18
- package/src/widgets/scatterplot/config.ts +8 -3
- package/src/widgets/skeleton-loader/skeleton-loader.tsx +2 -5
- package/src/widgets/spread/components/max-value.tsx +14 -16
- package/src/widgets/spread/components/min-value.tsx +14 -16
- package/src/widgets/stores/index.ts +2 -1
- package/src/widgets/stores/types.ts +2 -0
- package/src/widgets/stores/use-widget-selector.ts +47 -0
- package/src/widgets/stores/widget-store-performance.test.ts +750 -0
- package/src/widgets/stores/widget-store.test.ts +81 -0
- package/src/widgets/stores/widget-store.ts +225 -44
- package/src/widgets/table/config.ts +0 -1
- package/src/widgets/table/hooks/use-pagination.ts +28 -52
- package/src/widgets/table/hooks/use-selection.ts +20 -24
- package/src/widgets/table/hooks/use-sort.ts +22 -39
- package/src/widgets/table/types.ts +1 -1
- package/src/widgets/timeseries/config.ts +21 -13
- package/src/widgets/utils/chart-config/index.ts +1 -1
- package/src/widgets/utils/chart-config/option-builders.ts +22 -12
- package/src/widgets/utils/formatter.ts +2 -1
- package/src/widgets/utils/index.ts +1 -1
- package/src/widgets/wrapper/wrapper-ui.tsx +12 -13
- package/src/widgets/wrapper/wrapper.tsx +4 -6
- package/dist/error-CEkRPccv.js +0 -39
- package/dist/error-CEkRPccv.js.map +0 -1
- package/dist/formatter-B1Xh8XDH.js +0 -5
- package/dist/formatter-B1Xh8XDH.js.map +0 -1
- package/dist/no-data-hR3KcJ-_.js +0 -60
- package/dist/no-data-hR3KcJ-_.js.map +0 -1
- package/dist/row-DTCV0Ocm.js +0 -35
- package/dist/row-DTCV0Ocm.js.map +0 -1
- package/dist/series-CYNOu2Ju.js +0 -91
- package/dist/series-CYNOu2Ju.js.map +0 -1
- package/dist/styles-C_8vOEep.js +0 -167
- package/dist/styles-C_8vOEep.js.map +0 -1
- package/dist/use-widget-ref-wtFLDFCD.js +0 -25
- package/dist/use-widget-ref-wtFLDFCD.js.map +0 -1
- package/dist/widget-store-CzDt8oSK.js +0 -163
- package/dist/widget-store-CzDt8oSK.js.map +0 -1
package/dist/row-DTCV0Ocm.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
-
import { c as n } from "react/compiler-runtime";
|
|
3
|
-
import { Box as c } from "@mui/material";
|
|
4
|
-
import { u as m } from "./widget-store-CzDt8oSK.js";
|
|
5
|
-
import { useShallow as s } from "zustand/shallow";
|
|
6
|
-
const f = {
|
|
7
|
-
item: {
|
|
8
|
-
'&[data-disabled="true"]': {
|
|
9
|
-
color: (t) => t.palette.text.disabled
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
row: {
|
|
13
|
-
display: "flex",
|
|
14
|
-
alignItems: "center",
|
|
15
|
-
gap: (t) => t.spacing(1),
|
|
16
|
-
"& + &": {
|
|
17
|
-
marginTop: (t) => t.spacing(1)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
function y(t) {
|
|
22
|
-
const e = n(5);
|
|
23
|
-
let i;
|
|
24
|
-
e[0] !== t.id ? (i = (l) => l.getWidget(t.id)?.data, e[0] = t.id, e[1] = i) : i = e[1];
|
|
25
|
-
const o = m(s(i));
|
|
26
|
-
let a;
|
|
27
|
-
return e[2] !== o || e[3] !== t ? (a = o?.map((l, r) => /* @__PURE__ */ d(c, { sx: f.row, children: typeof t.children == "function" ? t.children({
|
|
28
|
-
index: r
|
|
29
|
-
}) : t.children }, `row-${r}`)), e[2] = o, e[3] = t, e[4] = a) : a = e[4], a;
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
y as R,
|
|
33
|
-
f as s
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=row-DTCV0Ocm.js.map
|
package/dist/row-DTCV0Ocm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"row-DTCV0Ocm.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\n/**\n * Iterates over the widget's data items and renders a row for each one using render props.\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={`row-${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;ACbO,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,YAHe,OAAOH,CAAK,EAItC,CAEH,GAACZ,OAAAM,GAAAN,OAAAD,GAAAC,OAAAS,KAAAA,IAAAT,EAAA,CAAA,GARKS;AAQL;"}
|
package/dist/series-CYNOu2Ju.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import { c as h } from "react/compiler-runtime";
|
|
3
|
-
import { u as g } from "./widget-store-CzDt8oSK.js";
|
|
4
|
-
import { useShallow as p } from "zustand/shallow";
|
|
5
|
-
import { Typography as S, Avatar as b } from "@mui/material";
|
|
6
|
-
import { s as P } from "./row-DTCV0Ocm.js";
|
|
7
|
-
function y(i) {
|
|
8
|
-
const e = h(4);
|
|
9
|
-
let t;
|
|
10
|
-
return e[0] !== i.TypographyProps || e[1] !== i.children || e[2] !== i.disabled ? (t = /* @__PURE__ */ m(S, { sx: P.item, variant: "h5", fontWeight: "medium", "data-disabled": i.disabled, color: "default", ...i.TypographyProps, children: i.children }), e[0] = i.TypographyProps, e[1] = i.children, e[2] = i.disabled, e[3] = t) : t = e[3], t;
|
|
11
|
-
}
|
|
12
|
-
function C(i) {
|
|
13
|
-
const e = h(10);
|
|
14
|
-
let t, r, o;
|
|
15
|
-
e[0] !== i ? ({
|
|
16
|
-
id: t,
|
|
17
|
-
index: o,
|
|
18
|
-
...r
|
|
19
|
-
} = i, e[0] = i, e[1] = t, e[2] = r, e[3] = o) : (t = e[1], r = e[2], o = e[3]);
|
|
20
|
-
const f = o === void 0 ? 0 : o;
|
|
21
|
-
let d;
|
|
22
|
-
e[4] !== t || e[5] !== f ? (d = (s) => s.getWidget(t)?.data?.[f]?.prefix, e[4] = t, e[5] = f, e[6] = d) : d = e[6];
|
|
23
|
-
const n = g(p(d));
|
|
24
|
-
if (!n)
|
|
25
|
-
return null;
|
|
26
|
-
let l;
|
|
27
|
-
return e[7] !== n || e[8] !== r ? (l = /* @__PURE__ */ m(y, { ...r, children: n }), e[7] = n, e[8] = r, e[9] = l) : l = e[9], l;
|
|
28
|
-
}
|
|
29
|
-
function I(i) {
|
|
30
|
-
const e = h(11);
|
|
31
|
-
let t, r, o;
|
|
32
|
-
e[0] !== i ? ({
|
|
33
|
-
id: t,
|
|
34
|
-
index: o,
|
|
35
|
-
...r
|
|
36
|
-
} = i, e[0] = i, e[1] = t, e[2] = r, e[3] = o) : (t = e[1], r = e[2], o = e[3]);
|
|
37
|
-
const f = o === void 0 ? 0 : o;
|
|
38
|
-
let d;
|
|
39
|
-
e[4] !== t || e[5] !== f ? (d = (a) => a.getWidget(t)?.data?.[f]?.suffix, e[4] = t, e[5] = f, e[6] = d) : d = e[6];
|
|
40
|
-
const n = g(p(d));
|
|
41
|
-
if (!n)
|
|
42
|
-
return null;
|
|
43
|
-
let l;
|
|
44
|
-
e[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (l = {
|
|
45
|
-
color: T
|
|
46
|
-
}, e[7] = l) : l = e[7];
|
|
47
|
-
let s;
|
|
48
|
-
return e[8] !== r || e[9] !== n ? (s = /* @__PURE__ */ m(y, { TypographyProps: l, ...r, children: n }), e[8] = r, e[9] = n, e[10] = s) : s = e[10], s;
|
|
49
|
-
}
|
|
50
|
-
function T(i) {
|
|
51
|
-
return i.palette.text.secondary;
|
|
52
|
-
}
|
|
53
|
-
function j(i) {
|
|
54
|
-
const e = h(13), {
|
|
55
|
-
id: t,
|
|
56
|
-
index: r
|
|
57
|
-
} = i, o = r === void 0 ? 0 : r;
|
|
58
|
-
let f;
|
|
59
|
-
e[0] !== t || e[1] !== o ? (f = (x) => x.getWidget(t)?.series?.[o], e[0] = t, e[1] = o, e[2] = f) : f = e[2];
|
|
60
|
-
const d = g(p(f));
|
|
61
|
-
if (!d)
|
|
62
|
-
return null;
|
|
63
|
-
const {
|
|
64
|
-
name: n,
|
|
65
|
-
color: l
|
|
66
|
-
} = d;
|
|
67
|
-
let s;
|
|
68
|
-
e[3] !== l ? (s = l && {
|
|
69
|
-
color: (x) => x.palette.getContrastText(l)
|
|
70
|
-
}, e[3] = l, e[4] = s) : s = e[4];
|
|
71
|
-
let a;
|
|
72
|
-
e[5] !== l || e[6] !== s ? (a = {
|
|
73
|
-
bgcolor: l,
|
|
74
|
-
width: 32,
|
|
75
|
-
height: 32,
|
|
76
|
-
fontSize: "0.875rem",
|
|
77
|
-
fontWeight: "medium",
|
|
78
|
-
...s
|
|
79
|
-
}, e[5] = l, e[6] = s, e[7] = a) : a = e[7];
|
|
80
|
-
let c;
|
|
81
|
-
e[8] !== n ? (c = n.charAt(0).toUpperCase(), e[8] = n, e[9] = c) : c = e[9];
|
|
82
|
-
let u;
|
|
83
|
-
return e[10] !== a || e[11] !== c ? (u = /* @__PURE__ */ m(b, { sx: a, children: c }), e[10] = a, e[11] = c, e[12] = u) : u = e[12], u;
|
|
84
|
-
}
|
|
85
|
-
export {
|
|
86
|
-
y as I,
|
|
87
|
-
C as P,
|
|
88
|
-
j as S,
|
|
89
|
-
I as a
|
|
90
|
-
};
|
|
91
|
-
//# sourceMappingURL=series-CYNOu2Ju.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"series-CYNOu2Ju.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\n/**\n * Base typography wrapper used by formula sub-components (Value, Prefix, Suffix) to render styled text.\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\n/**\n * Renders the prefix content (e.g., currency symbol) before a formula value, if defined in the data item.\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\n/**\n * Renders the suffix content (e.g., unit label) after a formula value, if defined in the data item.\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\n/**\n * Renders a colored avatar badge showing the first letter of the series name for multi-value formula widgets.\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":";;;;;;AAOO,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,IAA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AAQO,gBAAiBX,CAAK;AAAA,EAAA,GACtD3B,OAAA2B,GAAA3B,OAAAqB,KAAAA,IAAArB,EAAA,CAAA;AAAA,MAAA6B;AAAA,EAAA7B,EAAA,CAAA,MAAA2B,KAAA3B,SAAAqB,KARCQ,IAAA;AAAA,IAAAU,SACOZ;AAAAA,IAAKa,OACP;AAAA,IAAEC,QACD;AAAA,IAAEC,UACA;AAAA,IAAUC,YACR;AAAA,IAAQ,GAChBtB;AAAAA,EAAAA,GAGLrB,OAAA2B,GAAA3B,OAAAqB,GAAArB,OAAA6B,KAAAA,IAAA7B,EAAA,CAAA;AAAA,MAAA4C;AAAA,EAAA5C,SAAAqC,KAEAO,IAAAP,EAAIQ,OAAQ,CAAC,EAACC,YAAAA,GAAc9C,OAAAqC,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;"}
|
package/dist/styles-C_8vOEep.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
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 p, a as f } 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 I(t) {
|
|
16
|
-
const e = [];
|
|
17
|
-
if (t.length > 0 && (t[0]?.length ?? 0) > 0) {
|
|
18
|
-
const o = t?.[0]?.[0] ?? {}, i = Object.keys(o);
|
|
19
|
-
e.push(i);
|
|
20
|
-
}
|
|
21
|
-
return t.forEach((o) => {
|
|
22
|
-
o.forEach((i) => {
|
|
23
|
-
const r = Object.values(i).map((n) => String(n));
|
|
24
|
-
e.push(r);
|
|
25
|
-
});
|
|
26
|
-
}), e;
|
|
27
|
-
}
|
|
28
|
-
function z(t) {
|
|
29
|
-
const e = [];
|
|
30
|
-
return e.push(["x", "y"]), t.forEach((o) => {
|
|
31
|
-
o.forEach((i) => {
|
|
32
|
-
e.push([String(i[0]), String(i[1])]);
|
|
33
|
-
});
|
|
34
|
-
}), e;
|
|
35
|
-
}
|
|
36
|
-
function O(t) {
|
|
37
|
-
if (t === 0) return 0;
|
|
38
|
-
const e = Math.abs(t), o = Math.pow(10, Math.floor(Math.log10(e))), i = Math.ceil(e / o) * o;
|
|
39
|
-
return t < 0 ? -i : i;
|
|
40
|
-
}
|
|
41
|
-
function V(t) {
|
|
42
|
-
return {
|
|
43
|
-
show: t,
|
|
44
|
-
icon: "circle",
|
|
45
|
-
left: 0,
|
|
46
|
-
bottom: 0,
|
|
47
|
-
orient: "horizontal",
|
|
48
|
-
type: "scroll"
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function D(t, e) {
|
|
52
|
-
return {
|
|
53
|
-
...!t && {
|
|
54
|
-
bottom: parseInt(e.spacing(3))
|
|
55
|
-
},
|
|
56
|
-
...t && {
|
|
57
|
-
bottom: parseInt(e.spacing(7))
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function E(t) {
|
|
62
|
-
return function(e, o, i, r, n) {
|
|
63
|
-
const c = {
|
|
64
|
-
top: parseInt(t.spacing(0.5))
|
|
65
|
-
};
|
|
66
|
-
return n.contentSize[0] < n.viewSize[0] - e[0] ? c.left = e[0] : c.right = n.viewSize[0] - e[0], c;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function m(t) {
|
|
70
|
-
if (t)
|
|
71
|
-
return (e) => t(e);
|
|
72
|
-
}
|
|
73
|
-
function k(t, e) {
|
|
74
|
-
let o = m(e);
|
|
75
|
-
const i = t && !Array.isArray(t), r = t;
|
|
76
|
-
return (!i || r.type !== "value") && (o = void 0), {
|
|
77
|
-
...r,
|
|
78
|
-
axisLabel: {
|
|
79
|
-
...typeof r.axisLabel == "object" && r.axisLabel ? r.axisLabel : {},
|
|
80
|
-
formatter: o
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function _(t, e) {
|
|
85
|
-
let o = m(e);
|
|
86
|
-
const i = t && !Array.isArray(t), r = t;
|
|
87
|
-
return (!i || r.type !== "value") && (o = void 0), {
|
|
88
|
-
...r,
|
|
89
|
-
axisLabel: {
|
|
90
|
-
...typeof r.axisLabel == "object" && r.axisLabel ? r.axisLabel : {},
|
|
91
|
-
formatter: o
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function G(t) {
|
|
96
|
-
return (e) => {
|
|
97
|
-
const o = Array.isArray(e) ? e : [e], i = (a, s) => `<div style="margin: 0px 0 0;line-height:1;">${a ? `<div style="font-size:11px;color:#FFFFFF;font-weight:400;line-height:1; margin-bottom: 10px">${a}</div>` : ""}<div style="margin: 0;line-height:1;">${s}</div><div style="clear:both"></div></div>`, r = o.map((a) => {
|
|
98
|
-
const {
|
|
99
|
-
name: s,
|
|
100
|
-
seriesName: l,
|
|
101
|
-
marker: g,
|
|
102
|
-
value: d
|
|
103
|
-
} = t(a, o);
|
|
104
|
-
return {
|
|
105
|
-
name: s,
|
|
106
|
-
seriesName: l,
|
|
107
|
-
marker: g,
|
|
108
|
-
value: d
|
|
109
|
-
};
|
|
110
|
-
}), n = r[0]?.name ?? "", u = n || o.length > 1 ? "margin: 10px 0 0;line-height:1;" : "margin: 0;line-height:1;", h = r.map(({
|
|
111
|
-
seriesName: a,
|
|
112
|
-
marker: s,
|
|
113
|
-
value: l
|
|
114
|
-
}) => `<div style="${u}"><div style="margin: 0px 0 0;line-height:1;">${s}${a ? `<span style="font-size:11px;color:#FFFFFF;font-weight:400;margin-left:2px;margin-right:10px">${a}</span>` : ""}<span style="float:right;margin-left:10px;font-size:11px;color:#FFFFFF;font-weight:900">${l}</span></div></div>`);
|
|
115
|
-
return i(n, h.join(""));
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
function N(t) {
|
|
119
|
-
return function({
|
|
120
|
-
refUI: e
|
|
121
|
-
}) {
|
|
122
|
-
return [{
|
|
123
|
-
...p,
|
|
124
|
-
modifier: () => p.modifier(e)
|
|
125
|
-
}, {
|
|
126
|
-
...f,
|
|
127
|
-
modifier: async (o) => {
|
|
128
|
-
const i = t(o);
|
|
129
|
-
return f.modifier(i);
|
|
130
|
-
}
|
|
131
|
-
}];
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
const P = {
|
|
135
|
-
graph: {
|
|
136
|
-
/**
|
|
137
|
-
* Common container style for chart widget skeletons
|
|
138
|
-
*/
|
|
139
|
-
container: {
|
|
140
|
-
display: "flex",
|
|
141
|
-
alignItems: "center",
|
|
142
|
-
justifyContent: "space-between",
|
|
143
|
-
flexDirection: "column",
|
|
144
|
-
gap: ({
|
|
145
|
-
spacing: t
|
|
146
|
-
}) => t(1),
|
|
147
|
-
height: ({
|
|
148
|
-
spacing: t
|
|
149
|
-
}) => t(38)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
export {
|
|
154
|
-
k as a,
|
|
155
|
-
_ as b,
|
|
156
|
-
P as c,
|
|
157
|
-
D as d,
|
|
158
|
-
V as e,
|
|
159
|
-
m as f,
|
|
160
|
-
N as g,
|
|
161
|
-
G as h,
|
|
162
|
-
E as i,
|
|
163
|
-
I as j,
|
|
164
|
-
O as n,
|
|
165
|
-
z as s
|
|
166
|
-
};
|
|
167
|
-
//# sourceMappingURL=styles-C_8vOEep.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles-C_8vOEep.js","sources":["../src/widgets/utils/chart-config/csv-modifiers.ts","../src/widgets/utils/chart-config/option-builders.ts","../src/widgets/utils/chart-config/download-config.ts","../src/widgets/utils/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 '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 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 { 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","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","absValue","Math","abs","base","pow","floor","log10","rounded","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","applyXAxisFormatter","xAxis","axisFormatter","xAxisIsObject","Array","isArray","xAxisTyped","undefined","axisLabel","applyYAxisFormatter","yAxis","yAxisIsObject","yAxisTyped","createTooltipFormatter","callback","params","items","tooltip","name","item","seriesName","marker","marginStyle","formattedValues","join","createChartDownloadConfig","csvModifier","refUI","downloadToPNG","modifier","downloadToCSV","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,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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C;AAAA,QAAErD,SAAAA;AAAAA,MAAAA,MAAqBA,EAAQ,EAAE;AAAA,IAAA;AAAA,EAC5C;AAEJ;"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { c as i } from "react/compiler-runtime";
|
|
2
|
-
import { useRef as u, useEffect as l } from "react";
|
|
3
|
-
import { u as m } from "./widget-store-CzDt8oSK.js";
|
|
4
|
-
function R(t) {
|
|
5
|
-
const e = i(5), f = u(null), c = u(null), r = m(a);
|
|
6
|
-
let n, o;
|
|
7
|
-
e[0] !== r || e[1] !== t ? (n = () => {
|
|
8
|
-
f.current && r(t, {
|
|
9
|
-
refUI: f,
|
|
10
|
-
instance: c
|
|
11
|
-
});
|
|
12
|
-
}, o = [t, r], e[0] = r, e[1] = t, e[2] = n, e[3] = o) : (n = e[2], o = e[3]), l(n, o);
|
|
13
|
-
let s;
|
|
14
|
-
return e[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (s = {
|
|
15
|
-
ref: f,
|
|
16
|
-
instance: c
|
|
17
|
-
}, e[4] = s) : s = e[4], s;
|
|
18
|
-
}
|
|
19
|
-
function a(t) {
|
|
20
|
-
return t.setWidget;
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
R as u
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=use-widget-ref-wtFLDFCD.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-widget-ref-wtFLDFCD.js","sources":["../src/hooks/use-widget-ref.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport { useWidgetStore } from '../widgets/stores/widget-store'\n\n/**\n * Registers a DOM element ref and an ECharts instance ref with the widget store.\n * This allows other parts of the application (e.g., screenshot export) to access the widget's DOM element.\n *\n * @param widgetId - The widget ID to register the refs under.\n * @returns An object with `ref` (DOM element) and `instance` (ECharts instance) refs.\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 instance = useRef<echarts.ECharts | null>(null)\n const setWidget = useWidgetStore((store) => store.setWidget)\n\n useEffect(() => {\n if (ref.current) {\n setWidget(widgetId, { refUI: ref, instance: instance })\n }\n }, [widgetId, setWidget])\n\n return { ref, instance }\n}\n"],"names":["useWidgetRef","widgetId","$","_c","ref","useRef","instance","setWidget","useWidgetStore","_temp","t0","t1","current","refUI","useEffect","t2","Symbol","for","store"],"mappings":";;;AAmBO,SAAAA,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAGLC,IAAYC,EAAiB,IAAI,GACjCC,IAAiBD,EAA+B,IAAI,GACpDE,IAAkBC,EAAeC,CAA0B;AAAC,MAAAC,GAAAC;AAAA,EAAAT,EAAA,CAAA,MAAAK,KAAAL,SAAAD,KAElDS,IAAAA,MAAA;AACR,IAAIN,EAAGQ,WACLL,EAAUN,GAAU;AAAA,MAAAY,OAAST;AAAAA,MAAGE,UAAAA;AAAAA,IAAAA,CAAsB;AAAA,EACvD,GACAK,IAAA,CAACV,GAAUM,CAAS,GAACL,OAAAK,GAAAL,OAAAD,GAAAC,OAAAQ,GAAAR,OAAAS,MAAAD,IAAAR,EAAA,CAAA,GAAAS,IAAAT,EAAA,CAAA,IAJxBY,EAAUJ,GAIPC,CAAqB;AAAC,MAAAI;AAAA,SAAAb,EAAA,CAAA,MAAAc,uBAAAC,IAAA,2BAAA,KAElBF,IAAA;AAAA,IAAAX,KAAAA;AAAAA,IAAAE,UAAAA;AAAAA,EAAAA,GAAiBJ,OAAAa,KAAAA,IAAAb,EAAA,CAAA,GAAjBa;AAAiB;AAbnB,SAAAN,EAAAS,GAAA;AAAA,SAKuCA,EAAKX;AAAU;"}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { create as T } from "zustand";
|
|
2
|
-
const f = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), p = T()((l, u) => ({
|
|
3
|
-
// State
|
|
4
|
-
widgets: {},
|
|
5
|
-
// Actions
|
|
6
|
-
setWidget: (e, i) => l((t) => {
|
|
7
|
-
const s = t.widgets[e] ?? {};
|
|
8
|
-
return {
|
|
9
|
-
widgets: {
|
|
10
|
-
...t.widgets,
|
|
11
|
-
[e]: {
|
|
12
|
-
...s,
|
|
13
|
-
...i,
|
|
14
|
-
id: e
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}),
|
|
19
|
-
removeWidget: (e) => l((i) => {
|
|
20
|
-
const t = {
|
|
21
|
-
...i.widgets
|
|
22
|
-
};
|
|
23
|
-
return delete t[e], {
|
|
24
|
-
widgets: t
|
|
25
|
-
};
|
|
26
|
-
}),
|
|
27
|
-
clearWidgets: () => l({
|
|
28
|
-
widgets: {}
|
|
29
|
-
}),
|
|
30
|
-
getWidget: (e) => u().widgets[e],
|
|
31
|
-
registerTool: (e, i) => l((t) => {
|
|
32
|
-
const s = t.widgets[e] ?? {}, c = (s.registeredTools ?? []).filter((d) => d.id !== i.id);
|
|
33
|
-
return {
|
|
34
|
-
widgets: {
|
|
35
|
-
...t.widgets,
|
|
36
|
-
[e]: {
|
|
37
|
-
...s,
|
|
38
|
-
id: e,
|
|
39
|
-
registeredTools: [...c, i]
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}),
|
|
44
|
-
unregisterTool: (e, i) => l((t) => {
|
|
45
|
-
const s = t.widgets[e];
|
|
46
|
-
if (!s) return t;
|
|
47
|
-
const c = (s.registeredTools ?? []).filter((d) => d.id !== i);
|
|
48
|
-
return {
|
|
49
|
-
widgets: {
|
|
50
|
-
...t.widgets,
|
|
51
|
-
[e]: {
|
|
52
|
-
...s,
|
|
53
|
-
registeredTools: c
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}),
|
|
58
|
-
updateToolConfig: (e, i, t) => l((s) => {
|
|
59
|
-
const n = s.widgets[e];
|
|
60
|
-
if (!n) return s;
|
|
61
|
-
const d = (n.registeredTools ?? []).map((r) => r.id === i ? {
|
|
62
|
-
...r,
|
|
63
|
-
config: {
|
|
64
|
-
...r.config,
|
|
65
|
-
...t
|
|
66
|
-
}
|
|
67
|
-
} : r);
|
|
68
|
-
return {
|
|
69
|
-
widgets: {
|
|
70
|
-
...s.widgets,
|
|
71
|
-
[e]: {
|
|
72
|
-
...n,
|
|
73
|
-
registeredTools: d
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}),
|
|
78
|
-
setToolEnabled: (e, i, t) => l((s) => {
|
|
79
|
-
const n = s.widgets[e];
|
|
80
|
-
if (!n) return s;
|
|
81
|
-
const d = (n.registeredTools ?? []).map((r) => r.id === i ? {
|
|
82
|
-
...r,
|
|
83
|
-
enabled: t
|
|
84
|
-
} : r);
|
|
85
|
-
return {
|
|
86
|
-
widgets: {
|
|
87
|
-
...s.widgets,
|
|
88
|
-
[e]: {
|
|
89
|
-
...n,
|
|
90
|
-
registeredTools: d
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}),
|
|
95
|
-
executeToolPipeline: async (e, i) => {
|
|
96
|
-
const t = u().widgets[e];
|
|
97
|
-
if (!t) return;
|
|
98
|
-
const s = (f.get(e) ?? 0) + 1;
|
|
99
|
-
f.set(e, s);
|
|
100
|
-
const n = t, c = /* @__PURE__ */ new Set();
|
|
101
|
-
for (const o of n.registeredTools ?? [])
|
|
102
|
-
o.enabled && o.disables && o.disables.forEach((g) => c.add(g));
|
|
103
|
-
const d = [...n.registeredTools ?? []].filter((o) => (o.type ?? "data") === "data" && o.enabled && !c.has(o.id)).sort((o, g) => o.order - g.order);
|
|
104
|
-
let r = i;
|
|
105
|
-
for (const o of d) {
|
|
106
|
-
if (f.get(e) !== s)
|
|
107
|
-
return;
|
|
108
|
-
try {
|
|
109
|
-
r = await o.fn(r, o.config);
|
|
110
|
-
} catch (g) {
|
|
111
|
-
console.error(`Tool ${o.id} failed for widget ${e}:`, g);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
l((o) => {
|
|
115
|
-
const g = o.widgets[e];
|
|
116
|
-
return g ? {
|
|
117
|
-
widgets: {
|
|
118
|
-
...o.widgets,
|
|
119
|
-
[e]: {
|
|
120
|
-
...g,
|
|
121
|
-
data: r
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
} : o;
|
|
125
|
-
}), f.get(e) === s && f.delete(e);
|
|
126
|
-
},
|
|
127
|
-
executeConfigPipeline: async (e, i) => {
|
|
128
|
-
const t = u().widgets[e];
|
|
129
|
-
if (!t) return;
|
|
130
|
-
const s = (a.get(e) ?? 0) + 1;
|
|
131
|
-
a.set(e, s);
|
|
132
|
-
const n = /* @__PURE__ */ new Set();
|
|
133
|
-
for (const r of t.registeredTools ?? [])
|
|
134
|
-
r.enabled && r.disables && r.disables.forEach((o) => n.add(o));
|
|
135
|
-
const c = [...t.registeredTools ?? []].filter((r) => r.type === "config" && r.enabled && !n.has(r.id)).sort((r, o) => r.order - o.order);
|
|
136
|
-
let d = i;
|
|
137
|
-
for (const r of c) {
|
|
138
|
-
if (a.get(e) !== s)
|
|
139
|
-
return;
|
|
140
|
-
try {
|
|
141
|
-
d = await r.fn(d, r.config);
|
|
142
|
-
} catch (o) {
|
|
143
|
-
console.error(`Config tool ${r.id} failed for widget ${e}:`, o);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
l((r) => {
|
|
147
|
-
const o = r.widgets[e];
|
|
148
|
-
return o ? {
|
|
149
|
-
widgets: {
|
|
150
|
-
...r.widgets,
|
|
151
|
-
[e]: {
|
|
152
|
-
...o,
|
|
153
|
-
...d
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
} : r;
|
|
157
|
-
}), a.get(e) === s && a.delete(e);
|
|
158
|
-
}
|
|
159
|
-
}));
|
|
160
|
-
export {
|
|
161
|
-
p as u
|
|
162
|
-
};
|
|
163
|
-
//# sourceMappingURL=widget-store-CzDt8oSK.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"widget-store-CzDt8oSK.js","sources":["../src/widgets/stores/widget-store.ts"],"sourcesContent":["import { create } from 'zustand'\nimport type { WidgetState, WidgetStore, ToolRegistration } from './types'\n\n// Track active pipeline executions for cancellation\nconst activePipelines = new Map<string, number>()\nconst activeConfigPipelines = new Map<string, number>()\n\n/**\n * Zustand store for managing widget state across the application.\n *\n * This store provides centralized state management for all widget UI components\n *\n * @example\n * ```tsx\n * // Import the store\n * import { useWidgetStore } from '@carto/ps-react-ui/widgets'\n *\n * // Use in a component\n * function MyWidget() {\n * const setWidget = useWidgetStore((state) => state.setWidget)\n * const widget = useWidgetStore((state) => state.widgets['my-widget'])\n *\n * useEffect(() => {\n * setWidget({\n * id: 'my-widget',\n * type: 'formula',\n * title: 'Total Sales',\n * isLoading: false,\n * visible: true,\n * data: { value: 1000, prefix: '$' }\n * })\n * }, [setWidget])\n *\n * return <div>{widget?.data?.value}</div>\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Get widgets by type\n * const getWidgetsByType = useWidgetStore((state) => state.getWidgetsByType)\n * const formulaWidgets = getWidgetsByType('formula')\n * ```\n */\nexport const useWidgetStore = create<WidgetStore>()((set, get) => ({\n // State\n widgets: {},\n\n // Actions\n setWidget: (id, widget) =>\n set((state) => {\n const current =\n state.widgets[id] ?? ({} as WidgetStore['widgets'][string])\n return {\n widgets: {\n ...state.widgets,\n [id]: {\n ...current,\n ...widget,\n id,\n },\n },\n }\n }),\n\n removeWidget: (id) =>\n set((state) => {\n const widgets = { ...state.widgets }\n\n delete widgets[id]\n\n return { widgets }\n }),\n\n clearWidgets: () =>\n set({\n widgets: {},\n }),\n\n getWidget: <T extends WidgetState>(id: string) => {\n return get().widgets[id] as T | undefined\n },\n\n registerTool: (widgetId: string, tool: ToolRegistration) =>\n set((state) => {\n const current = state.widgets[widgetId] ?? ({} as WidgetState)\n const registeredTools = current.registeredTools ?? []\n\n // Remove existing tool with same id if present\n const filteredTools = registeredTools.filter(\n (t: ToolRegistration) => t.id !== tool.id,\n )\n\n return {\n widgets: {\n ...state.widgets,\n [widgetId]: {\n ...current,\n id: widgetId,\n registeredTools: [...filteredTools, tool],\n },\n },\n }\n }),\n\n unregisterTool: (widgetId: string, toolId: string) =>\n set((state) => {\n const current = state.widgets[widgetId]\n if (!current) return state\n\n const registeredTools = current.registeredTools ?? []\n const filteredTools = registeredTools.filter(\n (t: ToolRegistration) => t.id !== toolId,\n )\n\n return {\n widgets: {\n ...state.widgets,\n [widgetId]: {\n ...current,\n registeredTools: filteredTools,\n },\n },\n }\n }),\n\n updateToolConfig: (\n widgetId: string,\n toolId: string,\n config: Record<string, unknown>,\n ) =>\n set((state) => {\n const current = state.widgets[widgetId]\n if (!current) return state\n\n const registeredTools = current.registeredTools ?? []\n const updatedTools = registeredTools.map((tool: ToolRegistration) =>\n tool.id === toolId\n ? {\n ...tool,\n config: { ...tool.config, ...config },\n }\n : tool,\n )\n\n return {\n widgets: {\n ...state.widgets,\n [widgetId]: {\n ...current,\n registeredTools: updatedTools,\n },\n },\n }\n }),\n\n setToolEnabled: (widgetId: string, toolId: string, enabled: boolean) =>\n set((state) => {\n const current = state.widgets[widgetId]\n if (!current) return state\n\n const registeredTools = current.registeredTools ?? []\n const updatedTools = registeredTools.map((tool: ToolRegistration) =>\n tool.id === toolId ? { ...tool, enabled } : tool,\n )\n\n return {\n widgets: {\n ...state.widgets,\n [widgetId]: {\n ...current,\n registeredTools: updatedTools,\n },\n },\n }\n }),\n\n executeToolPipeline: async (widgetId: string, sourceData: unknown) => {\n const widget = get().widgets[widgetId]\n if (!widget) return\n\n // Cancel any in-progress pipeline for this widget\n const currentExecution = (activePipelines.get(widgetId) ?? 0) + 1\n activePipelines.set(widgetId, currentExecution)\n\n const widgetWithTools = widget\n\n // Build set of tool IDs that should be disabled\n const disabledToolIds = new Set<string>()\n for (const tool of widgetWithTools.registeredTools ?? []) {\n if (tool.enabled && tool.disables) {\n tool.disables.forEach((id) => disabledToolIds.add(id))\n }\n }\n\n // Sort tools by order and filter enabled data-only tools, excluding disabled tools\n const sortedTools = [...(widgetWithTools.registeredTools ?? [])]\n .filter(\n (tool) =>\n (tool.type ?? 'data') === 'data' &&\n tool.enabled &&\n !disabledToolIds.has(tool.id),\n )\n .sort((a, b) => a.order - b.order)\n\n // Execute pipeline - handle both sync and async tools\n let transformedData = sourceData\n for (const tool of sortedTools) {\n // Check if this execution was cancelled\n if (activePipelines.get(widgetId) !== currentExecution) {\n return\n }\n\n try {\n // Call tool function (may return Promise or direct value)\n transformedData = await tool.fn(transformedData, tool.config)\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(`Tool ${tool.id} failed for widget ${widgetId}:`, error)\n // Continue with current data to prevent one tool from breaking all\n }\n }\n\n // Single store update with final transformed data\n set((state) => {\n const currentWidget = state.widgets[widgetId]\n if (!currentWidget) return state\n\n return {\n widgets: {\n ...state.widgets,\n [widgetId]: {\n ...currentWidget,\n data: transformedData,\n },\n },\n }\n })\n\n // Clean up tracking\n if (activePipelines.get(widgetId) === currentExecution) {\n activePipelines.delete(widgetId)\n }\n },\n\n executeConfigPipeline: async (widgetId: string, baseConfig: object) => {\n const widget = get().widgets[widgetId]\n if (!widget) return\n\n // Cancel any in-progress config pipeline for this widget\n const currentExecution = (activeConfigPipelines.get(widgetId) ?? 0) + 1\n activeConfigPipelines.set(widgetId, currentExecution)\n\n // Build set of tool IDs that should be disabled (cross-type disabling works)\n const disabledToolIds = new Set<string>()\n for (const tool of widget.registeredTools ?? []) {\n if (tool.enabled && tool.disables) {\n tool.disables.forEach((id) => disabledToolIds.add(id))\n }\n }\n\n // Filter to config tools only, sort by order\n const sortedTools = [...(widget.registeredTools ?? [])]\n .filter(\n (tool) =>\n tool.type === 'config' &&\n tool.enabled &&\n !disabledToolIds.has(tool.id),\n )\n .sort((a, b) => a.order - b.order)\n\n // Chain config tools\n let transformedConfig: unknown = baseConfig\n for (const tool of sortedTools) {\n if (activeConfigPipelines.get(widgetId) !== currentExecution) {\n return\n }\n\n try {\n transformedConfig = await tool.fn(transformedConfig, tool.config)\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\n `Config tool ${tool.id} failed for widget ${widgetId}:`,\n error,\n )\n }\n }\n\n // Set the transformed config into the widget\n set((state) => {\n const currentWidget = state.widgets[widgetId]\n if (!currentWidget) return state\n\n return {\n widgets: {\n ...state.widgets,\n [widgetId]: {\n ...currentWidget,\n ...(transformedConfig as Record<string, unknown>),\n },\n },\n }\n })\n\n if (activeConfigPipelines.get(widgetId) === currentExecution) {\n activeConfigPipelines.delete(widgetId)\n }\n },\n}))\n"],"names":["activePipelines","Map","activeConfigPipelines","useWidgetStore","create","set","get","widgets","setWidget","id","widget","state","current","removeWidget","clearWidgets","getWidget","registerTool","widgetId","tool","filteredTools","registeredTools","filter","t","unregisterTool","toolId","updateToolConfig","config","updatedTools","map","setToolEnabled","enabled","executeToolPipeline","sourceData","currentExecution","widgetWithTools","disabledToolIds","Set","disables","forEach","add","sortedTools","type","has","sort","a","b","order","transformedData","fn","error","console","currentWidget","data","delete","executeConfigPipeline","baseConfig","transformedConfig"],"mappings":";AAIA,MAAMA,wBAAsBC,IAAAA,GACtBC,wBAA4BD,IAAAA,GAuCrBE,IAAiBC,EAAAA,EAAsB,CAACC,GAAKC,OAAS;AAAA;AAAA,EAEjEC,SAAS,CAAA;AAAA;AAAA,EAGTC,WAAWA,CAACC,GAAIC,MACdL,EAAKM,CAAAA,MAAU;AACb,UAAMC,IACJD,EAAMJ,QAAQE,CAAE,KAAM,CAAA;AACxB,WAAO;AAAA,MACLF,SAAS;AAAA,QACP,GAAGI,EAAMJ;AAAAA,QACT,CAACE,CAAE,GAAG;AAAA,UACJ,GAAGG;AAAAA,UACH,GAAGF;AAAAA,UACHD,IAAAA;AAAAA,QAAAA;AAAAA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