@carto/ps-react-ui 4.4.3 → 4.5.1
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-Dqu78h2a.js → download-config-DemuQ3Jm.js} +9 -10
- package/dist/{download-config-Dqu78h2a.js.map → download-config-DemuQ3Jm.js.map} +1 -1
- package/dist/error-Cj8eUMrl.js +40 -0
- package/dist/error-Cj8eUMrl.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/types/widgets/category/style.d.ts +1 -0
- package/dist/types/widgets/echart/shared-resize-observer.d.ts +12 -0
- package/dist/types/widgets/stores/index.d.ts +2 -1
- 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/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 +783 -817
- package/dist/widgets/actions.js.map +1 -1
- package/dist/widgets/bar.js +2 -2
- package/dist/widgets/category.js +259 -258
- 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 +7 -8
- 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 +2 -2
- package/dist/widgets/range.js +146 -144
- package/dist/widgets/range.js.map +1 -1
- package/dist/widgets/scatterplot.js +2 -2
- 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/subheader.js +29 -29
- package/dist/widgets/subheader.js.map +1 -1
- package/dist/widgets/table.js +422 -436
- package/dist/widgets/table.js.map +1 -1
- package/dist/widgets/timeseries.js +2 -2
- package/dist/widgets/utils.js +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 +1 -1
- package/src/hooks/use-widget-ref.ts +3 -4
- package/src/widgets/actions/brush-toggle/brush-toggle.tsx +18 -32
- 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/category/category-ui.tsx +30 -31
- package/src/widgets/category/style.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/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/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/range/components/range-item.tsx +20 -18
- 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/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/subheader/subheader.tsx +11 -3
- 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/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/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/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
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react/compiler-runtime";
|
|
3
3
|
import "@mui/material";
|
|
4
|
-
import "./widget-store-
|
|
5
|
-
import "@mui/icons-material";
|
|
4
|
+
import "./widget-store-CIrb9RKP.js";
|
|
6
5
|
import "zustand/shallow";
|
|
6
|
+
import "@mui/icons-material";
|
|
7
7
|
import "react";
|
|
8
|
-
import "react-markdown";
|
|
9
8
|
import { d as n, a as s } from "./exports-Cr43OCul.js";
|
|
10
9
|
import "./lasso-tool-BYbxrJ-7.js";
|
|
11
10
|
import "./cjs-D4KH3azB.js";
|
|
12
11
|
import "@dnd-kit/core";
|
|
13
12
|
import "@dnd-kit/sortable";
|
|
14
13
|
import "@dnd-kit/utilities";
|
|
15
|
-
function
|
|
14
|
+
function E(r) {
|
|
16
15
|
const o = [];
|
|
17
16
|
if (r.length > 0 && (r[0]?.length ?? 0) > 0) {
|
|
18
17
|
const i = r?.[0]?.[0] ?? {}, t = Object.keys(i);
|
|
@@ -25,7 +24,7 @@ function T(r) {
|
|
|
25
24
|
});
|
|
26
25
|
}), o;
|
|
27
26
|
}
|
|
28
|
-
function
|
|
27
|
+
function T(r) {
|
|
29
28
|
const o = [];
|
|
30
29
|
return o.push(["x", "y"]), r.forEach((i) => {
|
|
31
30
|
i.forEach((t) => {
|
|
@@ -33,7 +32,7 @@ function b(r) {
|
|
|
33
32
|
});
|
|
34
33
|
}), o;
|
|
35
34
|
}
|
|
36
|
-
function
|
|
35
|
+
function b(r) {
|
|
37
36
|
return function({
|
|
38
37
|
refUI: o
|
|
39
38
|
}) {
|
|
@@ -50,8 +49,8 @@ function j(r) {
|
|
|
50
49
|
};
|
|
51
50
|
}
|
|
52
51
|
export {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
b as c,
|
|
53
|
+
E as f,
|
|
54
|
+
T as s
|
|
56
55
|
};
|
|
57
|
-
//# sourceMappingURL=download-config-
|
|
56
|
+
//# sourceMappingURL=download-config-DemuQ3Jm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download-config-
|
|
1
|
+
{"version":3,"file":"download-config-DemuQ3Jm.js","sources":["../src/widgets/utils/chart-config/csv-modifiers.ts","../src/widgets/utils/chart-config/download-config.ts"],"sourcesContent":["/**\n * Shared CSV export modifiers for chart widgets\n */\n\n/**\n * Flattens object array data into CSV-ready rows.\n * Used by bar, pie, histogram, and timeseries widgets.\n *\n * @param data - Array of series, where each series is an array of data objects\n * @returns CSV rows with headers and values\n */\nexport function flattenObjectArrayToCSV<T extends Record<string, unknown>>(\n data: T[][],\n): string[][] {\n const rows: string[][] = []\n\n // Add headers from first data point if available\n if (data.length > 0 && (data[0]?.length ?? 0) > 0) {\n const firstDataPoint = data?.[0]?.[0] ?? {}\n const headers = Object.keys(firstDataPoint)\n rows.push(headers)\n }\n\n // Add data rows from all series\n data.forEach((series) => {\n series.forEach((dataPoint) => {\n const values = Object.values(dataPoint).map((v) => String(v))\n rows.push(values)\n })\n })\n\n return rows\n}\n\n/**\n * Creates CSV rows for scatterplot data.\n * Scatterplot uses array format [x, y] instead of objects.\n *\n * @param data - Array of series, where each series is an array of [x, y] tuples\n * @returns CSV rows with ['x', 'y'] headers\n */\nexport function scatterplotDataToCSV(data: number[][][]): string[][] {\n const rows: string[][] = []\n\n // Add headers\n rows.push(['x', 'y'])\n\n // Add data rows from all series\n data.forEach((series) => {\n series.forEach((dataPoint) => {\n rows.push([String(dataPoint[0]), String(dataPoint[1])])\n })\n })\n\n return rows\n}\n","import { downloadToCSV, downloadToPNG, type DownloadItem } from '../../actions'\nimport type { ConfigProps } from '../../loader/types'\n\nexport function createChartDownloadConfig<TData>(\n csvModifier: (data: TData) => string[][],\n) {\n return function ({ refUI }: ConfigProps): DownloadItem<TData>[] {\n return [\n {\n ...downloadToPNG,\n modifier: () => downloadToPNG.modifier(refUI),\n },\n {\n ...downloadToCSV,\n modifier: async (data) => {\n const rows = csvModifier(data)\n return downloadToCSV.modifier(rows)\n },\n },\n ]\n }\n}\n"],"names":["flattenObjectArrayToCSV","data","rows","length","firstDataPoint","headers","Object","keys","push","forEach","series","dataPoint","values","map","v","String","scatterplotDataToCSV","createChartDownloadConfig","csvModifier","refUI","downloadToPNG","modifier","downloadToCSV"],"mappings":";;;;;;;;;;;;;AAWO,SAASA,EACdC,GACY;AACZ,QAAMC,IAAmB,CAAA;AAGzB,MAAID,EAAKE,SAAS,MAAMF,EAAK,CAAC,GAAGE,UAAU,KAAK,GAAG;AACjD,UAAMC,IAAiBH,IAAO,CAAC,IAAI,CAAC,KAAK,CAAA,GACnCI,IAAUC,OAAOC,KAAKH,CAAc;AAC1CF,IAAAA,EAAKM,KAAKH,CAAO;AAAA,EACnB;AAGAJ,SAAAA,EAAKQ,QAASC,CAAAA,MAAW;AACvBA,IAAAA,EAAOD,QAASE,CAAAA,MAAc;AAC5B,YAAMC,IAASN,OAAOM,OAAOD,CAAS,EAAEE,IAAKC,CAAAA,MAAMC,OAAOD,CAAC,CAAC;AAC5DZ,MAAAA,EAAKM,KAAKI,CAAM;AAAA,IAClB,CAAC;AAAA,EACH,CAAC,GAEMV;AACT;AASO,SAASc,EAAqBf,GAAgC;AACnE,QAAMC,IAAmB,CAAA;AAGzBA,SAAAA,EAAKM,KAAK,CAAC,KAAK,GAAG,CAAC,GAGpBP,EAAKQ,QAASC,CAAAA,MAAW;AACvBA,IAAAA,EAAOD,QAASE,CAAAA,MAAc;AAC5BT,MAAAA,EAAKM,KAAK,CAACO,OAAOJ,EAAU,CAAC,CAAC,GAAGI,OAAOJ,EAAU,CAAC,CAAC,CAAC,CAAC;AAAA,IACxD,CAAC;AAAA,EACH,CAAC,GAEMT;AACT;ACpDO,SAASe,EACdC,GACA;AACA,SAAO,SAAU;AAAA,IAAEC,OAAAA;AAAAA,EAAAA,GAA6C;AAC9D,WAAO,CACL;AAAA,MACE,GAAGC;AAAAA,MACHC,UAAUA,MAAMD,EAAcC,SAASF,CAAK;AAAA,IAAA,GAE9C;AAAA,MACE,GAAGG;AAAAA,MACHD,UAAU,OAAOpB,MAAS;AACxB,cAAMC,IAAOgB,EAAYjB,CAAI;AAC7B,eAAOqB,EAAcD,SAASnB,CAAI;AAAA,MACpC;AAAA,IAAA,CACD;AAAA,EAEL;AACF;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as m, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { c as h } from "react/compiler-runtime";
|
|
3
|
+
import { AlertTitle as p, Alert as x } from "@mui/material";
|
|
4
|
+
import { u as A } from "./use-widget-selector-DqRmWQ1K.js";
|
|
5
|
+
function E(t) {
|
|
6
|
+
const r = h(5), {
|
|
7
|
+
id: l,
|
|
8
|
+
children: c,
|
|
9
|
+
title: d,
|
|
10
|
+
description: g
|
|
11
|
+
} = t, {
|
|
12
|
+
isLoading: a,
|
|
13
|
+
isFetching: f,
|
|
14
|
+
error: o
|
|
15
|
+
} = A(l, F);
|
|
16
|
+
if (a || f)
|
|
17
|
+
return c;
|
|
18
|
+
if (o) {
|
|
19
|
+
const n = d ?? o.title ?? "Error", s = g ?? o.message ?? "An error occurred while loading the widget. Please try again.";
|
|
20
|
+
let e;
|
|
21
|
+
r[0] !== n ? (e = /* @__PURE__ */ m(p, { children: n }), r[0] = n, r[1] = e) : e = r[1];
|
|
22
|
+
let i;
|
|
23
|
+
return r[2] !== s || r[3] !== e ? (i = /* @__PURE__ */ u(x, { severity: "error", children: [
|
|
24
|
+
e,
|
|
25
|
+
s
|
|
26
|
+
] }), r[2] = s, r[3] = e, r[4] = i) : i = r[4], i;
|
|
27
|
+
}
|
|
28
|
+
return c;
|
|
29
|
+
}
|
|
30
|
+
function F(t) {
|
|
31
|
+
return {
|
|
32
|
+
isLoading: t?.isLoading,
|
|
33
|
+
isFetching: t?.isFetching,
|
|
34
|
+
error: t?.error
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
E as W
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=error-Cj8eUMrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-Cj8eUMrl.js","sources":["../src/widgets/error/error.tsx"],"sourcesContent":["import { Alert, AlertTitle } from '@mui/material'\nimport { useWidgetSelector } from '../stores/use-widget-selector'\nimport type { WidgetErrorProps } from './types'\n\n/**\n * Displays an error alert when a widget encounters an error during data loading. Reads error state from the widget store and hides errors during loading/fetching to prevent flashing.\n *\n * @example\n * ```tsx\n * <WidgetError id=\"my-widget\">\n * <WidgetContent />\n * </WidgetError>\n * ```\n */\nexport function WidgetError({\n id,\n children,\n title: titleProp,\n description,\n}: WidgetErrorProps) {\n // Single consolidated subscription instead of 3 separate ones.\n const { isLoading, isFetching, error } = useWidgetSelector(id, (w) => ({\n isLoading: w?.isLoading,\n isFetching: w?.isFetching,\n error: w?.error,\n }))\n\n // Don't show error during loading/fetching states\n if (isLoading || isFetching) {\n return children\n }\n\n // Show error UI if error exists\n if (error) {\n const errorTitle = titleProp ?? error.title ?? 'Error'\n const errorMessage =\n description ??\n error.message ??\n 'An error occurred while loading the widget. Please try again.'\n\n return (\n <Alert severity='error'>\n <AlertTitle>{errorTitle}</AlertTitle>\n {errorMessage}\n </Alert>\n )\n }\n\n // No error, render children\n return children\n}\n"],"names":["WidgetError","t0","$","_c","id","children","title","titleProp","description","isLoading","isFetching","error","useWidgetSelector","_temp","errorTitle","errorMessage","message","t1","AlertTitle","t2","jsxs","Alert","w"],"mappings":";;;;AAcO,SAAAA,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAAqB;AAAA,IAAAC,IAAAA;AAAAA,IAAAC,UAAAA;AAAAA,IAAAC,OAAAC;AAAAA,IAAAC,aAAAA;AAAAA,EAAAA,IAAAP,GAO1B;AAAA,IAAAQ,WAAAA;AAAAA,IAAAC,YAAAA;AAAAA,IAAAC,OAAAA;AAAAA,EAAAA,IAAyCC,EAAkBR,GAAIS,CAI7D;AAGF,MAAIJ,KAAAC;AAAuB,WAClBL;AAIT,MAAIM,GAAK;AACP,UAAAG,IAAmBP,KAAaI,EAAKL,SAAlB,SACnBS,IACEP,KACAG,EAAKK,WADL;AAE+D,QAAAC;AAAA,IAAAf,SAAAY,KAI7DG,sBAACC,kBAAuB,GAAahB,OAAAY,GAAAZ,OAAAe,KAAAA,IAAAf,EAAA,CAAA;AAAA,QAAAiB;AAAA,WAAAjB,EAAA,CAAA,MAAAa,KAAAb,SAAAe,KADvCE,IAAA,gBAAAC,EAACC,GAAA,EAAe,UAAA,SACdJ,UAAAA;AAAAA,MAAAA;AAAAA,MACCF;AAAAA,IAAAA,GACH,GAAQb,OAAAa,GAAAb,OAAAe,GAAAf,OAAAiB,KAAAA,IAAAjB,EAAA,CAAA,GAHRiB;AAAAA,EAGQ;AAEX,SAGMd;AAAQ;AAnCV,SAAAQ,EAAAS,GAAA;AAAA,SAOkE;AAAA,IAAAb,WAC1Da,GAACb;AAAAA,IAAWC,YACXY,GAACZ;AAAAA,IAAYC,OAClBW,GAACX;AAAAA,EAAAA;AACT;"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as f, jsxs as x } from "react/jsx-runtime";
|
|
2
|
+
import { c as v } from "react/compiler-runtime";
|
|
3
|
+
import { Typography as p, Box as b } from "@mui/material";
|
|
4
|
+
import { u as j } from "./use-widget-selector-DqRmWQ1K.js";
|
|
5
|
+
const A = {
|
|
6
|
+
root: {
|
|
7
|
+
display: "flex",
|
|
8
|
+
flexDirection: "column",
|
|
9
|
+
gap: 1,
|
|
10
|
+
// 8px
|
|
11
|
+
paddingTop: 1,
|
|
12
|
+
// 8px
|
|
13
|
+
paddingBottom: 2,
|
|
14
|
+
// 16px
|
|
15
|
+
paddingX: 2,
|
|
16
|
+
// 16px
|
|
17
|
+
width: "100%",
|
|
18
|
+
minHeight: "100%"
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function B(e) {
|
|
22
|
+
const t = v(7), {
|
|
23
|
+
id: u,
|
|
24
|
+
children: a,
|
|
25
|
+
title: l,
|
|
26
|
+
description: c,
|
|
27
|
+
isEmpty: d
|
|
28
|
+
} = e, n = l === void 0 ? "No data available" : l, s = c === 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" : c, y = d === void 0 ? E : d, {
|
|
29
|
+
isLoading: g,
|
|
30
|
+
isFetching: m,
|
|
31
|
+
data: h
|
|
32
|
+
} = j(u, T);
|
|
33
|
+
if (g || m)
|
|
34
|
+
return a;
|
|
35
|
+
if (y(h)) {
|
|
36
|
+
let r;
|
|
37
|
+
t[0] !== n ? (r = /* @__PURE__ */ f(p, { variant: "body2", color: "text.primary", children: n }), t[0] = n, t[1] = r) : r = t[1];
|
|
38
|
+
let i;
|
|
39
|
+
t[2] !== s ? (i = /* @__PURE__ */ f(p, { variant: "caption", color: "text.secondary", children: s }), t[2] = s, t[3] = i) : i = t[3];
|
|
40
|
+
let o;
|
|
41
|
+
return t[4] !== r || t[5] !== i ? (o = /* @__PURE__ */ x(b, { sx: A.root, children: [
|
|
42
|
+
r,
|
|
43
|
+
i
|
|
44
|
+
] }), t[4] = r, t[5] = i, t[6] = o) : o = t[6], o;
|
|
45
|
+
}
|
|
46
|
+
return a;
|
|
47
|
+
}
|
|
48
|
+
function T(e) {
|
|
49
|
+
return {
|
|
50
|
+
isLoading: e?.isLoading,
|
|
51
|
+
isFetching: e?.isFetching,
|
|
52
|
+
data: e?.data
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function E(e) {
|
|
56
|
+
return e == null ? !0 : Array.isArray(e) ? !!(e.length === 0 || e.every((t) => Array.isArray(t) && t.length === 0)) : typeof e == "object" ? Object.keys(e).length === 0 : !1;
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
B as W
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=no-data-DkIt7Qt1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-data-DkIt7Qt1.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 { useWidgetSelector } from '../stores/use-widget-selector'\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 // Single consolidated subscription instead of 3 separate ones.\n const { isLoading, isFetching, data } = useWidgetSelector(id, (w) => ({\n isLoading: w?.isLoading,\n isFetching: w?.isFetching,\n data: w?.data,\n }))\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","isLoading","isFetching","data","useWidgetSelector","_temp","t4","Typography","t5","t6","Box","w","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;ACqBO,SAAAC,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAAsB;AAAA,IAAAC,IAAAA;AAAAA,IAAAC,UAAAA;AAAAA,IAAAC,OAAAC;AAAAA,IAAAC,aAAAC;AAAAA,IAAAC,SAAAC;AAAAA,EAAAA,IAAAV,GAG3BK,IAA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/D,OAAOX,KAAS,WACXc,OAAOC,KAAKf,CAAI,EAAEW,WAAW,IAI/B;AACT;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as a } 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 l } from "./use-widget-selector-DqRmWQ1K.js";
|
|
5
|
+
const s = {
|
|
6
|
+
item: {
|
|
7
|
+
'&[data-disabled="true"]': {
|
|
8
|
+
color: (t) => t.palette.text.disabled
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
row: {
|
|
12
|
+
display: "flex",
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
gap: (t) => t.spacing(1),
|
|
15
|
+
"& + &": {
|
|
16
|
+
marginTop: (t) => t.spacing(1)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function h(t) {
|
|
21
|
+
const e = n(3), o = l(t.id, d);
|
|
22
|
+
let i;
|
|
23
|
+
return e[0] !== o || e[1] !== t ? (i = o?.map((m, r) => /* @__PURE__ */ a(c, { sx: s.row, children: typeof t.children == "function" ? t.children({
|
|
24
|
+
index: r
|
|
25
|
+
}) : t.children }, `row-${r}`)), e[0] = o, e[1] = t, e[2] = i) : i = e[2], i;
|
|
26
|
+
}
|
|
27
|
+
function d(t) {
|
|
28
|
+
return t?.data;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
h as R,
|
|
32
|
+
s
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=row-D4VOhcNI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-D4VOhcNI.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 { useWidgetSelector } from '../../stores/use-widget-selector'\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 = useWidgetSelector(\n props.id,\n (w) => (w as FormulaWidgetState | undefined)?.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","data","useWidgetSelector","id","_temp","t0","map","_","index","jsx","Box","children","w"],"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;ACdO,SAAAE,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GACLC,IAAaC,EACXJ,EAAKK,IACLC,CACF;AAAC,MAAAC;AAAA,SAAAN,EAAA,CAAA,MAAAE,KAAAF,SAAAD,KAEMO,IAAAJ,GAAIK,IAAM,CAAAC,GAAAC,MAEb,gBAAAC,EAACC,GAAA,EAAQ,IAAA1B,EAAMO,KACZ,UAAA,OAAOO,EAAKa,YAAc,aACvBb,EAAKa,SAAU;AAAA,IAAAH,OAAAA;AAAAA,EAAAA,CACF,IAAbV,EAAKa,YAHe,OAAOH,CAAK,EAItC,CAEH,GAACT,OAAAE,GAAAF,OAAAD,GAAAC,OAAAM,KAAAA,IAAAN,EAAA,CAAA,GARKM;AAQL;AAdG,SAAAD,EAAAQ,GAAA;AAAA,SAGKA,GAA0CX;AAAA;"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { c as h } from "react/compiler-runtime";
|
|
3
|
+
import { u as p } from "./use-widget-selector-DqRmWQ1K.js";
|
|
4
|
+
import { Typography as g, Avatar as b } from "@mui/material";
|
|
5
|
+
import { s as P } from "./row-D4VOhcNI.js";
|
|
6
|
+
function y(t) {
|
|
7
|
+
const e = h(4);
|
|
8
|
+
let l;
|
|
9
|
+
return e[0] !== t.TypographyProps || e[1] !== t.children || e[2] !== t.disabled ? (l = /* @__PURE__ */ m(g, { sx: P.item, variant: "h5", fontWeight: "medium", "data-disabled": t.disabled, color: "default", ...t.TypographyProps, children: t.children }), e[0] = t.TypographyProps, e[1] = t.children, e[2] = t.disabled, e[3] = l) : l = e[3], l;
|
|
10
|
+
}
|
|
11
|
+
function A(t) {
|
|
12
|
+
const e = h(9);
|
|
13
|
+
let l, r, n;
|
|
14
|
+
e[0] !== t ? ({
|
|
15
|
+
id: l,
|
|
16
|
+
index: n,
|
|
17
|
+
...r
|
|
18
|
+
} = t, e[0] = t, e[1] = l, e[2] = r, e[3] = n) : (l = e[1], r = e[2], n = e[3]);
|
|
19
|
+
const f = n === void 0 ? 0 : n;
|
|
20
|
+
let a;
|
|
21
|
+
e[4] !== f ? (a = (s) => s?.data?.[f]?.prefix, e[4] = f, e[5] = a) : a = e[5];
|
|
22
|
+
const o = p(l, a);
|
|
23
|
+
if (!o)
|
|
24
|
+
return null;
|
|
25
|
+
let i;
|
|
26
|
+
return e[6] !== o || e[7] !== r ? (i = /* @__PURE__ */ m(y, { ...r, children: o }), e[6] = o, e[7] = r, e[8] = i) : i = e[8], i;
|
|
27
|
+
}
|
|
28
|
+
function C(t) {
|
|
29
|
+
const e = h(10);
|
|
30
|
+
let l, r, n;
|
|
31
|
+
e[0] !== t ? ({
|
|
32
|
+
id: l,
|
|
33
|
+
index: n,
|
|
34
|
+
...r
|
|
35
|
+
} = t, e[0] = t, e[1] = l, e[2] = r, e[3] = n) : (l = e[1], r = e[2], n = e[3]);
|
|
36
|
+
const f = n === void 0 ? 0 : n;
|
|
37
|
+
let a;
|
|
38
|
+
e[4] !== f ? (a = (c) => c?.data?.[f]?.suffix, e[4] = f, e[5] = a) : a = e[5];
|
|
39
|
+
const o = p(l, a);
|
|
40
|
+
if (!o)
|
|
41
|
+
return null;
|
|
42
|
+
let i;
|
|
43
|
+
e[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (i = {
|
|
44
|
+
color: S
|
|
45
|
+
}, e[6] = i) : i = e[6];
|
|
46
|
+
let s;
|
|
47
|
+
return e[7] !== r || e[8] !== o ? (s = /* @__PURE__ */ m(y, { TypographyProps: i, ...r, children: o }), e[7] = r, e[8] = o, e[9] = s) : s = e[9], s;
|
|
48
|
+
}
|
|
49
|
+
function S(t) {
|
|
50
|
+
return t.palette.text.secondary;
|
|
51
|
+
}
|
|
52
|
+
function I(t) {
|
|
53
|
+
const e = h(12), {
|
|
54
|
+
id: l,
|
|
55
|
+
index: r
|
|
56
|
+
} = t, n = r === void 0 ? 0 : r;
|
|
57
|
+
let f;
|
|
58
|
+
e[0] !== n ? (f = (x) => x?.series?.[n], e[0] = n, e[1] = f) : f = e[1];
|
|
59
|
+
const a = p(l, f);
|
|
60
|
+
if (!a)
|
|
61
|
+
return null;
|
|
62
|
+
const {
|
|
63
|
+
name: o,
|
|
64
|
+
color: i
|
|
65
|
+
} = a;
|
|
66
|
+
let s;
|
|
67
|
+
e[2] !== i ? (s = i && {
|
|
68
|
+
color: (x) => x.palette.getContrastText(i)
|
|
69
|
+
}, e[2] = i, e[3] = s) : s = e[3];
|
|
70
|
+
let c;
|
|
71
|
+
e[4] !== i || e[5] !== s ? (c = {
|
|
72
|
+
bgcolor: i,
|
|
73
|
+
width: 32,
|
|
74
|
+
height: 32,
|
|
75
|
+
fontSize: "0.875rem",
|
|
76
|
+
fontWeight: "medium",
|
|
77
|
+
...s
|
|
78
|
+
}, e[4] = i, e[5] = s, e[6] = c) : c = e[6];
|
|
79
|
+
let d;
|
|
80
|
+
e[7] !== o ? (d = o.charAt(0).toUpperCase(), e[7] = o, e[8] = d) : d = e[8];
|
|
81
|
+
let u;
|
|
82
|
+
return e[9] !== c || e[10] !== d ? (u = /* @__PURE__ */ m(b, { sx: c, children: d }), e[9] = c, e[10] = d, e[11] = u) : u = e[11], u;
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
y as I,
|
|
86
|
+
A as P,
|
|
87
|
+
I as S,
|
|
88
|
+
C as a
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=series-Bola3CmD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"series-Bola3CmD.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 { Item } from './item'\nimport { useWidgetSelector } from '../../stores/use-widget-selector'\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 = useWidgetSelector(\n id,\n (w) => (w as FormulaWidgetState | undefined)?.data?.[index]?.prefix,\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 { Item } from './item'\nimport type { Theme } from '@mui/material'\nimport { useWidgetSelector } from '../../stores/use-widget-selector'\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 = useWidgetSelector(\n id,\n (w) => (w as FormulaWidgetState | undefined)?.data?.[index]?.suffix,\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 { useWidgetSelector } from '../../stores/use-widget-selector'\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 = useWidgetSelector(\n id,\n (w) => (w as FormulaWidgetState | undefined)?.series?.[index],\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","w","data","prefix","useWidgetSelector","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","to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AbT6C;AAaS;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared ResizeObserver singleton for all ECharts instances.
|
|
3
|
+
*
|
|
4
|
+
* Instead of creating 100+ individual ResizeObserver instances (one per chart),
|
|
5
|
+
* this module provides a single shared observer that efficiently handles resize
|
|
6
|
+
* callbacks for all registered elements.
|
|
7
|
+
*/
|
|
8
|
+
type ResizeCallback = () => void;
|
|
9
|
+
export declare function observeResize(element: Element, callback: ResizeCallback): () => void;
|
|
10
|
+
/** Reset the shared observer (for testing only). */
|
|
11
|
+
export declare function resetSharedResizeObserver(): void;
|
|
12
|
+
export {};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { useWidgetStore } from './widget-store';
|
|
1
|
+
export { useWidgetStore, widgetStoreActions } from './widget-store';
|
|
2
|
+
export { useWidgetSelector } from './use-widget-selector';
|
|
2
3
|
export type { BaseWidgetState, ToolType, WidgetsStoreProps, WidgetState, WidgetStore, WidgetStoreActions, WidgetStoreState, } from './types';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { WidgetState } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Scoped selector hook for reading a single widget's state from the store.
|
|
4
|
+
*
|
|
5
|
+
* Consolidates multiple `useWidgetStore(useShallow(...))` calls into a single
|
|
6
|
+
* subscription per component. The selector receives only this widget's state
|
|
7
|
+
* (or undefined if not yet registered), and uses shallow comparison to avoid
|
|
8
|
+
* re-renders when unrelated properties change.
|
|
9
|
+
*
|
|
10
|
+
* @param widgetId - The widget ID to subscribe to.
|
|
11
|
+
* @param selector - A function that extracts the needed properties from the widget state.
|
|
12
|
+
* Must be a stable reference (inline arrow is fine due to useCallback wrapping).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* // Before: 4 separate subscriptions
|
|
17
|
+
* const title = useWidgetStore(useShallow((s) => s.getWidget(id)?.title))
|
|
18
|
+
* const collapsed = useWidgetStore(useShallow((s) => s.getWidget(id)?.collapsed))
|
|
19
|
+
* const disabled = useWidgetStore(useShallow((s) => s.getWidget(id)?.disabled))
|
|
20
|
+
* const isFetching = useWidgetStore(useShallow((s) => s.getWidget(id)?.isFetching))
|
|
21
|
+
*
|
|
22
|
+
* // After: 1 subscription
|
|
23
|
+
* const { title, collapsed, disabled, isFetching } = useWidgetSelector(id, (w) => ({
|
|
24
|
+
* title: w?.title, collapsed: w?.collapsed, disabled: w?.disabled, isFetching: w?.isFetching,
|
|
25
|
+
* }))
|
|
26
|
+
*
|
|
27
|
+
* // With extra dependencies (e.g., index prop):
|
|
28
|
+
* const value = useWidgetSelector(
|
|
29
|
+
* id,
|
|
30
|
+
* (w) => (w as MyState | undefined)?.data?.[index]?.value,
|
|
31
|
+
* [index],
|
|
32
|
+
* )
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function useWidgetSelector<T>(widgetId: string, selector: (widget: WidgetState | undefined) => T): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,39 +1,61 @@
|
|
|
1
|
-
import { WidgetStore } from './types';
|
|
1
|
+
import { WidgetStore, WidgetStoreActions } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Zustand store for managing widget state across the application.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Provides centralized state management for all widget UI components, including
|
|
6
|
+
* data/config transformation pipelines via registered tools.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
+
* **Performance optimizations:**
|
|
9
|
+
* - `registerTool` skips the store update when structural properties (order, enabled,
|
|
10
|
+
* type, disables) haven't changed — only `fn` and `config` are updated via direct
|
|
11
|
+
* mutation, avoiding a new `registeredTools` array reference and WidgetLoader
|
|
12
|
+
* pipeline cascades.
|
|
13
|
+
* - `setToolEnabled` skips the store update when the enabled state is already the
|
|
14
|
+
* requested value.
|
|
15
|
+
* - `executeToolPipeline` / `executeConfigPipeline` skip the final `set()` when
|
|
16
|
+
* the transformed data/config is referentially identical to what's already in the store.
|
|
17
|
+
* - Both pipelines support cancellation — newer executions for the same widget
|
|
18
|
+
* automatically cancel in-progress ones.
|
|
19
|
+
*
|
|
20
|
+
* @example Reading widget state (prefer useWidgetSelector for performance)
|
|
8
21
|
* ```tsx
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* useEffect(() => {
|
|
18
|
-
* setWidget({
|
|
19
|
-
* id: 'my-widget',
|
|
20
|
-
* type: 'formula',
|
|
21
|
-
* title: 'Total Sales',
|
|
22
|
-
* isLoading: false,
|
|
23
|
-
* visible: true,
|
|
24
|
-
* data: { value: 1000, prefix: '$' }
|
|
25
|
-
* })
|
|
26
|
-
* }, [setWidget])
|
|
27
|
-
*
|
|
28
|
-
* return <div>{widget?.data?.value}</div>
|
|
22
|
+
* import { useWidgetSelector } from '@carto/ps-react-ui/widgets'
|
|
23
|
+
*
|
|
24
|
+
* function MyWidget({ id }: { id: string }) {
|
|
25
|
+
* const { title, data } = useWidgetSelector(id, (w) => ({
|
|
26
|
+
* title: w?.title,
|
|
27
|
+
* data: w?.data,
|
|
28
|
+
* }))
|
|
29
|
+
* return <div>{title}: {JSON.stringify(data)}</div>
|
|
29
30
|
* }
|
|
30
31
|
* ```
|
|
31
32
|
*
|
|
32
|
-
* @example
|
|
33
|
+
* @example Writing widget state
|
|
33
34
|
* ```tsx
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* const
|
|
35
|
+
* import { widgetStoreActions } from '@carto/ps-react-ui/widgets'
|
|
36
|
+
*
|
|
37
|
+
* const { setWidget } = widgetStoreActions
|
|
38
|
+
* setWidget('my-widget', { type: 'formula', isLoading: false, data: { value: 1000 } })
|
|
37
39
|
* ```
|
|
38
40
|
*/
|
|
39
41
|
export declare const useWidgetStore: import('node_modules/zustand/esm/react.mjs').UseBoundStore<import('node_modules/zustand/esm/vanilla.mjs').StoreApi<WidgetStore>>;
|
|
42
|
+
/**
|
|
43
|
+
* Stable references to store actions, accessible without creating a subscription.
|
|
44
|
+
*
|
|
45
|
+
* Use this instead of `useWidgetStore((state) => state.setWidget)` to avoid
|
|
46
|
+
* unnecessary subscriber evaluations. Actions are stable functions that never
|
|
47
|
+
* change, so subscribing to them wastes cycles on every store update.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* import { widgetStoreActions } from '@carto/ps-react-ui/widgets'
|
|
52
|
+
*
|
|
53
|
+
* const { setWidget, registerTool } = widgetStoreActions
|
|
54
|
+
*
|
|
55
|
+
* useEffect(() => {
|
|
56
|
+
* registerTool(id, { id: 'my-tool', order: 10, enabled: true, fn: (d) => d })
|
|
57
|
+
* return () => widgetStoreActions.unregisterTool(id, 'my-tool')
|
|
58
|
+
* }, [id])
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare const widgetStoreActions: WidgetStoreActions;
|
|
@@ -75,7 +75,7 @@ export interface TableWidgetConfig {
|
|
|
75
75
|
/** Enable row selection with checkboxes */
|
|
76
76
|
selectable?: boolean;
|
|
77
77
|
/** Currently selected row IDs */
|
|
78
|
-
selected
|
|
78
|
+
selected?: (string | number)[];
|
|
79
79
|
/** Pagination and sort mode: local (client-side) or remote (server-side) */
|
|
80
80
|
mode: Mode;
|
|
81
81
|
/** Pagination configuration */
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { c as l } from "react/compiler-runtime";
|
|
2
|
+
import { useRef as c, useEffect as i } from "react";
|
|
3
|
+
import { w as m } from "./widget-store-CIrb9RKP.js";
|
|
4
|
+
function R(t) {
|
|
5
|
+
const e = l(4), n = c(null), s = c(null);
|
|
6
|
+
let o, r;
|
|
7
|
+
e[0] !== t ? (o = () => {
|
|
8
|
+
n.current && m.setWidget(t, {
|
|
9
|
+
refUI: n,
|
|
10
|
+
instance: s
|
|
11
|
+
});
|
|
12
|
+
}, r = [t], e[0] = t, e[1] = o, e[2] = r) : (o = e[1], r = e[2]), i(o, r);
|
|
13
|
+
let f;
|
|
14
|
+
return e[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (f = {
|
|
15
|
+
ref: n,
|
|
16
|
+
instance: s
|
|
17
|
+
}, e[3] = f) : f = e[3], f;
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
R as u
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=use-widget-ref-BFazQvJK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-widget-ref-BFazQvJK.js","sources":["../src/hooks/use-widget-ref.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport { widgetStoreActions } 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\n useEffect(() => {\n if (ref.current) {\n widgetStoreActions.setWidget(widgetId, { refUI: ref, instance: instance })\n }\n }, [widgetId])\n\n return { ref, instance }\n}\n"],"names":["useWidgetRef","widgetId","$","_c","ref","useRef","instance","t0","t1","current","widgetStoreActions","setWidget","refUI","useEffect","t2","Symbol","for"],"mappings":";;;AAmBO,SAAAA,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAGLC,IAAYC,EAAiB,IAAI,GACjCC,IAAiBD,EAA+B,IAAI;AAAC,MAAAE,GAAAC;AAAA,EAAAN,SAAAD,KAE3CM,IAAAA,MAAA;AACR,IAAIH,EAAGK,WACLC,EAAkBC,UAAWV,GAAU;AAAA,MAAAW,OAASR;AAAAA,MAAGE,UAAAA;AAAAA,IAAAA,CAAsB;AAAA,EAC1E,GACAE,IAAA,CAACP,CAAQ,GAACC,OAAAD,GAAAC,OAAAK,GAAAL,OAAAM,MAAAD,IAAAL,EAAA,CAAA,GAAAM,IAAAN,EAAA,CAAA,IAJbW,EAAUN,GAIPC,CAAU;AAAC,MAAAM;AAAA,SAAAZ,EAAA,CAAA,MAAAa,uBAAAC,IAAA,2BAAA,KAEPF,IAAA;AAAA,IAAAV,KAAAA;AAAAA,IAAAE,UAAAA;AAAAA,EAAAA,GAAiBJ,OAAAY,KAAAA,IAAAZ,EAAA,CAAA,GAAjBY;AAAiB;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { c as i } from "react/compiler-runtime";
|
|
2
|
+
import { u as m } from "./widget-store-CIrb9RKP.js";
|
|
3
|
+
import { useShallow as s } from "zustand/shallow";
|
|
4
|
+
function a(r, e) {
|
|
5
|
+
const o = i(3);
|
|
6
|
+
let t;
|
|
7
|
+
return o[0] !== e || o[1] !== r ? (t = (u) => e(u.widgets[r]), o[0] = e, o[1] = r, o[2] = t) : t = o[2], m(s(t));
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
a as u
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=use-widget-selector-DqRmWQ1K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-widget-selector-DqRmWQ1K.js","sources":["../src/widgets/stores/use-widget-selector.ts"],"sourcesContent":["import { useWidgetStore } from './widget-store'\nimport type { WidgetState } from './types'\nimport { useShallow } from 'zustand/shallow'\n\n/**\n * Scoped selector hook for reading a single widget's state from the store.\n *\n * Consolidates multiple `useWidgetStore(useShallow(...))` calls into a single\n * subscription per component. The selector receives only this widget's state\n * (or undefined if not yet registered), and uses shallow comparison to avoid\n * re-renders when unrelated properties change.\n *\n * @param widgetId - The widget ID to subscribe to.\n * @param selector - A function that extracts the needed properties from the widget state.\n * Must be a stable reference (inline arrow is fine due to useCallback wrapping).\n *\n * @example\n * ```tsx\n * // Before: 4 separate subscriptions\n * const title = useWidgetStore(useShallow((s) => s.getWidget(id)?.title))\n * const collapsed = useWidgetStore(useShallow((s) => s.getWidget(id)?.collapsed))\n * const disabled = useWidgetStore(useShallow((s) => s.getWidget(id)?.disabled))\n * const isFetching = useWidgetStore(useShallow((s) => s.getWidget(id)?.isFetching))\n *\n * // After: 1 subscription\n * const { title, collapsed, disabled, isFetching } = useWidgetSelector(id, (w) => ({\n * title: w?.title, collapsed: w?.collapsed, disabled: w?.disabled, isFetching: w?.isFetching,\n * }))\n *\n * // With extra dependencies (e.g., index prop):\n * const value = useWidgetSelector(\n * id,\n * (w) => (w as MyState | undefined)?.data?.[index]?.value,\n * [index],\n * )\n * ```\n */\nexport function useWidgetSelector<T>(\n widgetId: string,\n selector: (widget: WidgetState | undefined) => T,\n): T {\n return useWidgetStore(\n useShallow((state: { widgets: Record<string, WidgetState> }) =>\n selector(state.widgets[widgetId]),\n ),\n )\n}\n"],"names":["useWidgetSelector","widgetId","selector","$","_c","t0","state","widgets","useWidgetStore","useShallow"],"mappings":";;;AAqCO,SAAAA,EAAAC,GAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA;AAAA,MAAAC;AAAA,SAAAF,EAAA,CAAA,MAAAD,KAAAC,SAAAF,KAKQI,IAAAC,CAAAA,MACTJ,EAASI,EAAKC,QAASN,CAAQ,CAAC,GAACE,OAAAD,GAAAC,OAAAF,GAAAE,OAAAE,KAAAA,IAAAF,EAAA,CAAA,GAF9BK,EACLC,EAAWJ,CAEX,CACF;AAAC;"}
|