@carto/ps-react-ui 4.3.6 → 4.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.js +123 -123
- package/dist/components.js.map +1 -1
- package/dist/error-CEkRPccv.js +39 -0
- package/dist/error-CEkRPccv.js.map +1 -0
- package/dist/{lasso-tool-BctzdzBu.js → lasso-tool-jl4YK02H.js} +19 -19
- package/dist/lasso-tool-jl4YK02H.js.map +1 -0
- package/dist/no-data-hR3KcJ-_.js +60 -0
- package/dist/no-data-hR3KcJ-_.js.map +1 -0
- package/dist/{row-D3uVFImu.js → row-BKmVAUN5.js} +2 -2
- package/dist/{row-D3uVFImu.js.map → row-BKmVAUN5.js.map} +1 -1
- package/dist/{series-BAImrSBo.js → series-D1pynfeh.js} +3 -3
- package/dist/{series-BAImrSBo.js.map → series-D1pynfeh.js.map} +1 -1
- package/dist/{styles-CCZnY17y.js → styles-DrPyd0y5.js} +28 -22
- package/dist/styles-DrPyd0y5.js.map +1 -0
- package/dist/types/components/lasso-tool/types.d.ts +1 -1
- package/dist/types/widgets/_shared/chart-config/index.d.ts +1 -1
- package/dist/types/widgets/_shared/chart-config/option-builders.d.ts +7 -0
- package/dist/types/widgets/_shared/chart-config/option-builders.test.d.ts +1 -0
- package/dist/types/widgets/actions/change-column/change-column.d.ts +4 -0
- package/dist/types/widgets/actions/fullscreen/fullscreen.d.ts +1 -1
- package/dist/types/widgets/actions/fullscreen/types.d.ts +2 -1
- package/dist/types/widgets/actions/index.d.ts +1 -1
- package/dist/types/widgets/actions/lock-selection/types.d.ts +7 -7
- package/dist/types/widgets/actions/relative-data/types.d.ts +1 -1
- package/dist/types/widgets/echart/types.d.ts +0 -4
- package/dist/types/widgets/echart/utils.d.ts +2 -1
- package/dist/types/widgets/error/error.d.ts +1 -1
- package/dist/types/widgets/error/types.d.ts +8 -0
- package/dist/types/widgets/loader/loader.d.ts +1 -1
- package/dist/types/widgets/loader/types.d.ts +1 -1
- package/dist/types/widgets/stores/types.d.ts +1 -1
- package/dist/{use-widget-ref-B8x4sHIj.js → use-widget-ref-P-2i0MJG.js} +2 -2
- package/dist/{use-widget-ref-B8x4sHIj.js.map → use-widget-ref-P-2i0MJG.js.map} +1 -1
- package/dist/{utils-D3-eQyDR.js → utils-idmvq0Oa.js} +17 -16
- package/dist/utils-idmvq0Oa.js.map +1 -0
- package/dist/{widget-store-Dn0Bnc4h.js → widget-store-CzDt8oSK.js} +31 -46
- package/dist/widget-store-CzDt8oSK.js.map +1 -0
- package/dist/widgets/actions.js +714 -697
- package/dist/widgets/actions.js.map +1 -1
- package/dist/widgets/bar.js +67 -63
- package/dist/widgets/bar.js.map +1 -1
- package/dist/widgets/category.js +250 -241
- package/dist/widgets/category.js.map +1 -1
- package/dist/widgets/echart.js +93 -100
- package/dist/widgets/echart.js.map +1 -1
- package/dist/widgets/error.js +1 -1
- package/dist/widgets/formula.js +64 -72
- package/dist/widgets/formula.js.map +1 -1
- package/dist/widgets/histogram.js +75 -73
- package/dist/widgets/histogram.js.map +1 -1
- package/dist/widgets/loader.js +58 -49
- package/dist/widgets/loader.js.map +1 -1
- package/dist/widgets/markdown.js +2 -2
- package/dist/widgets/no-data.js +1 -1
- package/dist/widgets/pie.js +4 -4
- package/dist/widgets/range.js +97 -105
- package/dist/widgets/range.js.map +1 -1
- package/dist/widgets/scatterplot.js +8 -8
- package/dist/widgets/skeleton-loader.js +1 -1
- package/dist/widgets/spread.js +84 -100
- package/dist/widgets/spread.js.map +1 -1
- package/dist/widgets/stores.js +1 -1
- package/dist/widgets/table.js +493 -485
- package/dist/widgets/table.js.map +1 -1
- package/dist/widgets/timeseries.js +4 -4
- package/dist/widgets/wrapper.js +156 -156
- package/dist/widgets/wrapper.js.map +1 -1
- package/dist/widgets.js +4 -4
- package/package.json +1 -1
- package/src/components/lasso-tool/lasso-tool-inline.tsx +19 -17
- package/src/components/lasso-tool/lasso-tool.tsx +22 -20
- package/src/components/lasso-tool/types.ts +4 -3
- package/src/widgets/_shared/chart-config/index.ts +1 -0
- package/src/widgets/_shared/chart-config/option-builders.test.ts +40 -0
- package/src/widgets/_shared/chart-config/option-builders.ts +12 -0
- package/src/widgets/actions/change-column/change-column.test.tsx +129 -2
- package/src/widgets/actions/change-column/change-column.tsx +79 -2
- package/src/widgets/actions/fullscreen/fullscreen.tsx +8 -8
- package/src/widgets/actions/fullscreen/types.ts +6 -1
- package/src/widgets/actions/index.ts +4 -1
- package/src/widgets/actions/lock-selection/lock-selection.test.tsx +28 -30
- package/src/widgets/actions/lock-selection/types.ts +8 -8
- package/src/widgets/actions/relative-data/relative-data.test.tsx +13 -13
- package/src/widgets/actions/relative-data/types.ts +1 -1
- package/src/widgets/actions/stack-toggle/stack-toggle.test.tsx +19 -9
- package/src/widgets/actions/zoom-toggle/zoom-toggle.tsx +113 -95
- package/src/widgets/bar/config.ts +37 -28
- package/src/widgets/category/category-ui.tsx +25 -22
- package/src/widgets/echart/echart-ui.test.tsx +3 -18
- package/src/widgets/echart/echart-ui.tsx +4 -22
- package/src/widgets/echart/echart.test.tsx +9 -25
- package/src/widgets/echart/echart.tsx +36 -29
- package/src/widgets/echart/types.ts +0 -4
- package/src/widgets/echart/utils.ts +3 -1
- package/src/widgets/error/error.tsx +17 -14
- package/src/widgets/error/types.ts +10 -0
- package/src/widgets/formula/components/value.tsx +13 -13
- package/src/widgets/histogram/config.ts +36 -29
- package/src/widgets/loader/loader.tsx +28 -25
- package/src/widgets/loader/types.ts +3 -1
- package/src/widgets/no-data/no-data.tsx +8 -11
- package/src/widgets/range/components/range-item.tsx +9 -13
- package/src/widgets/spread/components/max-value.tsx +13 -13
- package/src/widgets/spread/components/min-value.tsx +13 -13
- package/src/widgets/stores/types.ts +1 -4
- package/src/widgets/stores/widget-store.ts +1 -27
- package/src/widgets/table/hooks/use-pagination.ts +44 -35
- package/src/widgets/table/hooks/use-sort.ts +25 -23
- package/src/widgets/wrapper/wrapper-ui.tsx +16 -17
- package/dist/error-piB8FwYO.js +0 -38
- package/dist/error-piB8FwYO.js.map +0 -1
- package/dist/lasso-tool-BctzdzBu.js.map +0 -1
- package/dist/no-data-jdlbMef0.js +0 -61
- package/dist/no-data-jdlbMef0.js.map +0 -1
- package/dist/styles-CCZnY17y.js.map +0 -1
- package/dist/utils-D3-eQyDR.js.map +0 -1
- package/dist/widget-store-Dn0Bnc4h.js.map +0 -1
|
@@ -12,7 +12,7 @@ export type { StackToggleProps, StackToggleState } from './stack-toggle/types';
|
|
|
12
12
|
export { Searcher, SEARCHER_TOOL_ID } from './searcher/searcher';
|
|
13
13
|
export { SearcherToggle } from './searcher/searcher-toggle';
|
|
14
14
|
export type { SearcherToggleProps, SearcherProps, SearcherFilterFn, SearcherState, } from './searcher/types';
|
|
15
|
-
export { ChangeColumn } from './change-column/change-column';
|
|
15
|
+
export { ChangeColumn, CHANGE_COLUMN_TOOL_ID, } from './change-column/change-column';
|
|
16
16
|
export type { ChangeColumnProps } from './change-column/types';
|
|
17
17
|
export { LockSelection, LOCK_SELECTION_TOOL_ID, } from './lock-selection/lock-selection';
|
|
18
18
|
export type { LockSelectionProps, LockSelectionState, } from './lock-selection/types';
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { IconButtonProps } from '@mui/material';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { BaseWidgetState } from '../../stores/types';
|
|
4
|
-
/**
|
|
5
|
-
* Lock selection specific state properties.
|
|
6
|
-
*/
|
|
7
|
-
export interface LockSelectionStateProps {
|
|
8
|
-
/** Whether the selection is currently locked */
|
|
9
|
-
isLocked?: boolean;
|
|
10
|
-
}
|
|
11
4
|
/**
|
|
12
5
|
* Widget state extension for lock selection functionality.
|
|
13
6
|
* Extends the base widget state with lock-specific properties.
|
|
@@ -34,3 +27,10 @@ export interface LockSelectionProps {
|
|
|
34
27
|
/** Custom icon to display */
|
|
35
28
|
Icon?: ReactNode;
|
|
36
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Lock selection specific state properties.
|
|
32
|
+
*/
|
|
33
|
+
export interface LockSelectionStateProps {
|
|
34
|
+
/** Whether the selection is currently locked */
|
|
35
|
+
isLocked?: boolean;
|
|
36
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IconButtonProps } from '@mui/material';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { BaseWidgetState } from '
|
|
3
|
+
import { BaseWidgetState } from '../../../widgets/stores';
|
|
4
4
|
export interface RelativeDataProps {
|
|
5
5
|
/** Widget ID to update data in the widget store */
|
|
6
6
|
id: string;
|
|
@@ -4,13 +4,11 @@ import { Ref } from 'react';
|
|
|
4
4
|
import { theme as CartoTheme } from '@carto/meridian-ds/theme';
|
|
5
5
|
import type * as echarts from 'echarts';
|
|
6
6
|
export type EchartOptionsProps = EChartsOption;
|
|
7
|
-
export type EchartReplaceMerge = string[];
|
|
8
7
|
export interface EchartUIProps {
|
|
9
8
|
id: string;
|
|
10
9
|
option: EchartOptionsProps;
|
|
11
10
|
className?: string;
|
|
12
11
|
init?: echarts.EChartsInitOpts;
|
|
13
|
-
replaceMerge?: EchartReplaceMerge;
|
|
14
12
|
style?: React.CSSProperties;
|
|
15
13
|
ref?: Ref<echarts.ECharts>;
|
|
16
14
|
onEvents?: Record<string, Parameters<echarts.ECharts['on']>[2]>;
|
|
@@ -23,7 +21,6 @@ export type EchartWidgetState = BaseWidgetState<{
|
|
|
23
21
|
option: EchartUIProps['option'];
|
|
24
22
|
onEvents?: EchartUIProps['onEvents'];
|
|
25
23
|
init?: EchartUIProps['init'];
|
|
26
|
-
replaceMerge?: EchartReplaceMerge;
|
|
27
24
|
}>;
|
|
28
25
|
export interface EchartWidgetOptionProps<D> {
|
|
29
26
|
data?: D;
|
|
@@ -34,5 +31,4 @@ export interface EchartWidgetProps {
|
|
|
34
31
|
type: string;
|
|
35
32
|
option: EchartUIProps['option'];
|
|
36
33
|
onEvents?: EchartUIProps['onEvents'];
|
|
37
|
-
replaceMerge?: EchartReplaceMerge;
|
|
38
34
|
}
|
|
@@ -4,12 +4,13 @@ export declare function mergeEchartWidgetConfig<T extends EchartOptionsProps>(..
|
|
|
4
4
|
export declare function getEChartZoomConfig(zoom: boolean, { start, end }?: {
|
|
5
5
|
start: number;
|
|
6
6
|
end: number;
|
|
7
|
-
}, { inside, xSlider, ySlider, showSliders, xAxisLabelFormatter, }?: {
|
|
7
|
+
}, { inside, xSlider, ySlider, showSliders, xAxisLabelFormatter, bottomOffset, }?: {
|
|
8
8
|
inside?: boolean;
|
|
9
9
|
xSlider?: boolean;
|
|
10
10
|
ySlider?: boolean;
|
|
11
11
|
showSliders?: boolean;
|
|
12
12
|
xAxisLabelFormatter?: (value: number) => string;
|
|
13
|
+
bottomOffset?: number;
|
|
13
14
|
}, theme?: Theme): {
|
|
14
15
|
dataZoom: ({
|
|
15
16
|
throttle: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { WidgetErrorProps } from './types';
|
|
2
|
-
export declare function WidgetError({ id, children }: WidgetErrorProps): string | number | bigint | boolean | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
2
|
+
export declare function WidgetError({ id, children, title: titleProp, description, }: WidgetErrorProps): string | number | bigint | boolean | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { WidgetLoaderProps } from './types';
|
|
2
|
-
export declare function WidgetLoader<T extends
|
|
2
|
+
export declare function WidgetLoader<T extends object = Record<string, unknown>>(props: WidgetLoaderProps<T>): import('react').ReactNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { WidgetsStoreProps, WidgetState } from '../stores/types';
|
|
3
|
-
export interface WidgetLoaderProps<T extends
|
|
3
|
+
export interface WidgetLoaderProps<T extends object = Record<string, unknown>> extends WidgetsStoreProps {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
config?: T;
|
|
6
6
|
}
|
|
@@ -172,7 +172,7 @@ export interface WidgetStoreActions {
|
|
|
172
172
|
* @param widgetId - Widget ID
|
|
173
173
|
* @param baseConfig - Base config to transform
|
|
174
174
|
*/
|
|
175
|
-
executeConfigPipeline: (widgetId: string, baseConfig:
|
|
175
|
+
executeConfigPipeline: (widgetId: string, baseConfig: object) => Promise<void>;
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
178
|
* Complete widget store interface
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as u } from "react/compiler-runtime";
|
|
2
2
|
import { useRef as n, useEffect as c } from "react";
|
|
3
|
-
import { u as i } from "./widget-store-
|
|
3
|
+
import { u as i } from "./widget-store-CzDt8oSK.js";
|
|
4
4
|
function a(t) {
|
|
5
5
|
const e = u(4), s = n(null), r = i(m);
|
|
6
6
|
let f, o;
|
|
@@ -16,4 +16,4 @@ function m(t) {
|
|
|
16
16
|
export {
|
|
17
17
|
a as u
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=use-widget-ref-
|
|
19
|
+
//# sourceMappingURL=use-widget-ref-P-2i0MJG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-widget-ref-
|
|
1
|
+
{"version":3,"file":"use-widget-ref-P-2i0MJG.js","sources":["../src/hooks/use-widget-ref.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport { useWidgetStore } from '../widgets/stores/widget-store'\n\n/**\n * Custom hook for registering a DOM element ref with the widget store.\n * This allows other parts of the application to access the widget's DOM element.\n *\n * @param widgetId - The widget ID to register the ref under\n * @returns A ref object to attach to the DOM element\n *\n * @example\n * ```tsx\n * function MyWidget({ id }: { id: string }) {\n * const ref = useWidgetRef<HTMLDivElement>(id)\n *\n * return <div ref={ref}>Widget content</div>\n * }\n * ```\n */\nexport function useWidgetRef<T extends HTMLElement = HTMLElement>(\n widgetId: string,\n) {\n const ref = useRef<T | null>(null)\n const setWidget = useWidgetStore((store) => store.setWidget)\n\n useEffect(() => {\n if (ref.current) {\n setWidget(widgetId, { refUI: ref })\n }\n }, [widgetId, setWidget])\n\n return ref\n}\n"],"names":["useWidgetRef","widgetId","$","_c","ref","useRef","setWidget","useWidgetStore","_temp","t0","t1","current","refUI","useEffect","store"],"mappings":";;;AAmBO,SAAAA,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAGLC,IAAYC,EAAiB,IAAI,GACjCC,IAAkBC,EAAeC,CAA0B;AAAC,MAAAC,GAAAC;AAAA,SAAAR,EAAA,CAAA,MAAAI,KAAAJ,SAAAD,KAElDQ,IAAAA,MAAA;AACR,IAAIL,EAAGO,WACLL,EAAUL,GAAU;AAAA,MAAAW,OAASR;AAAAA,IAAAA,CAAK;AAAA,EACnC,GACAM,IAAA,CAACT,GAAUK,CAAS,GAACJ,OAAAI,GAAAJ,OAAAD,GAAAC,OAAAO,GAAAP,OAAAQ,MAAAD,IAAAP,EAAA,CAAA,GAAAQ,IAAAR,EAAA,CAAA,IAJxBW,EAAUJ,GAIPC,CAAqB,GAEjBN;AAAG;AAZL,SAAAI,EAAAM,GAAA;AAAA,SAIuCA,EAAKR;AAAU;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as n } from "./cjs-D4KH3azB.js";
|
|
2
|
-
const
|
|
3
|
-
function
|
|
2
|
+
const y = "stacked";
|
|
3
|
+
function h(...e) {
|
|
4
4
|
return n(e[0] ?? {}, e[1] ?? {}, {
|
|
5
5
|
customMerge: (i) => {
|
|
6
6
|
if (i === "color")
|
|
@@ -13,7 +13,7 @@ function S(...e) {
|
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function p(e, {
|
|
17
17
|
start: i,
|
|
18
18
|
end: I
|
|
19
19
|
} = {
|
|
@@ -24,9 +24,10 @@ function h(e, {
|
|
|
24
24
|
xSlider: g = !0,
|
|
25
25
|
ySlider: t = !1,
|
|
26
26
|
showSliders: r = !0,
|
|
27
|
-
xAxisLabelFormatter: l
|
|
27
|
+
xAxisLabelFormatter: l,
|
|
28
|
+
bottomOffset: c = 0
|
|
28
29
|
} = {}, o) {
|
|
29
|
-
const d = o ?
|
|
30
|
+
const d = o ? m(o) : {};
|
|
30
31
|
return {
|
|
31
32
|
dataZoom: [a && {
|
|
32
33
|
throttle: 0,
|
|
@@ -49,7 +50,7 @@ function h(e, {
|
|
|
49
50
|
throttle: 0,
|
|
50
51
|
type: "slider",
|
|
51
52
|
xAxisIndex: [0],
|
|
52
|
-
bottom:
|
|
53
|
+
bottom: c,
|
|
53
54
|
height: parseInt(o?.spacing?.(4) ?? "32"),
|
|
54
55
|
show: e && r,
|
|
55
56
|
zoomLock: !e,
|
|
@@ -77,10 +78,10 @@ function h(e, {
|
|
|
77
78
|
moveHandleSize: 8,
|
|
78
79
|
handleSize: "100%",
|
|
79
80
|
handleIcon: "image://data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzYiIGhlaWdodD0iOSIgdmlld0JveD0iMCAwIDM2IDkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjAuNSIgeT0iMC41IiB3aWR0aD0iOCIgaGVpZ2h0PSIxOCIgcng9IjQiIHRyYW5zZm9ybT0icm90YXRlKC05MCAwLjUgMC41KSIgZmlsbD0id2hpdGUiIHN0cm9rZT0iIzM1OEJFNyIvPgo8cmVjdCB3aWR0aD0iMyIgaGVpZ2h0PSIyIiByeD0iMSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDEzIDYpIiBmaWxsPSIjMzU4QkU3Ii8+CjxyZWN0IHdpZHRoPSIzIiBoZWlnaHQ9IjIiIHJ4PSIxIiB0cmFuc2Zvcm09InJvdGF0ZSgtOTAgMTcgNikiIGZpbGw9IiMzNThCRTciLz4KPHJlY3Qgd2lkdGg9IjMiIGhlaWdodD0iMiIgcng9IjEiIHRyYW5zZm9ybT0icm90YXRlKC05MCAyMSA2KSIgZmlsbD0iIzM1OEJFNyIvPgo8L3N2Zz4="
|
|
80
|
-
}].filter((
|
|
81
|
+
}].filter((s) => !!s)
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
|
-
function
|
|
84
|
+
function m(e) {
|
|
84
85
|
return {
|
|
85
86
|
fillerColor: "rgba(53, 139, 231, 0.25)",
|
|
86
87
|
borderColor: "rgba(53, 139, 231, 0.3)",
|
|
@@ -121,7 +122,7 @@ function y(e) {
|
|
|
121
122
|
}
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
|
-
function
|
|
125
|
+
function b(e) {
|
|
125
126
|
return e ? {
|
|
126
127
|
brush: {
|
|
127
128
|
brushType: "rect",
|
|
@@ -129,16 +130,16 @@ function p(e) {
|
|
|
129
130
|
}
|
|
130
131
|
} : {};
|
|
131
132
|
}
|
|
132
|
-
function
|
|
133
|
+
function M(e, i = y) {
|
|
133
134
|
return {
|
|
134
135
|
stack: e ? i : void 0
|
|
135
136
|
};
|
|
136
137
|
}
|
|
137
138
|
export {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
y as D,
|
|
140
|
+
M as a,
|
|
141
|
+
p as b,
|
|
142
|
+
b as g,
|
|
143
|
+
h as m
|
|
143
144
|
};
|
|
144
|
-
//# sourceMappingURL=utils-
|
|
145
|
+
//# sourceMappingURL=utils-idmvq0Oa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-idmvq0Oa.js","sources":["../src/widgets/echart/const.ts","../src/widgets/echart/utils.ts"],"sourcesContent":["export const DEFAULT_STACK_GROUP = 'stacked'\n","import deepmerge from 'deepmerge'\nimport type { EchartOptionsProps } from './types'\nimport type { Theme } from '@mui/material'\nimport { DEFAULT_STACK_GROUP } from './const'\n\nexport function mergeEchartWidgetConfig<T extends EchartOptionsProps>(\n ...options: [T | undefined, T | undefined]\n): T {\n return deepmerge(options[0] ?? {}, options[1] ?? {}, {\n customMerge: (key) => {\n if (key === 'color') {\n return (_, b: T['color']) => b\n }\n if (key === 'series') {\n return (a: T['series'][], b: T['series'][]) => {\n if (!a.length) return a // If there is no series in a, return a as is\n\n const mergedSeries = b?.map((bItem, index) => {\n const aItem = a?.[index] ?? {}\n return deepmerge(aItem, bItem as object)\n })\n return mergedSeries\n }\n }\n },\n }) as T\n}\n\nexport function getEChartZoomConfig(\n zoom: boolean,\n { start, end }: { start: number; end: number } = { start: 0, end: 100 },\n {\n inside = true,\n xSlider = true,\n ySlider = false,\n showSliders = true,\n xAxisLabelFormatter,\n bottomOffset = 0,\n } = {} as {\n inside?: boolean\n xSlider?: boolean\n ySlider?: boolean\n showSliders?: boolean\n xAxisLabelFormatter?: (value: number) => string\n bottomOffset?: number\n },\n theme?: Theme,\n) {\n const sliderStyles = theme ? getEChartZoomSliderStyles(theme) : {}\n\n return {\n dataZoom: [\n inside && {\n throttle: 0,\n type: 'inside',\n xAxisIndex: xSlider ? [0] : [],\n yAxisIndex: ySlider ? [0] : [],\n show: zoom,\n zoomLock: !zoom,\n start,\n end,\n },\n inside &&\n ySlider && {\n throttle: 0,\n type: 'inside',\n show: zoom,\n zoomLock: !zoom,\n start,\n end,\n orientation: 'vertical',\n },\n xSlider && {\n throttle: 0,\n type: 'slider',\n xAxisIndex: [0],\n bottom: bottomOffset,\n height: parseInt(theme?.spacing?.(4) ?? '32'),\n show: zoom && showSliders,\n zoomLock: !zoom,\n start,\n end,\n labelFormatter: xAxisLabelFormatter,\n showDetail: false,\n ...sliderStyles,\n brushSelect: false,\n moveHandleSize: 8,\n handleSize: '100%',\n handleIcon:\n 'image://data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOSIgaGVpZ2h0PSIzNiIgdmlld0JveD0iMCAwIDkgMzYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjAuNSIgeT0iLTAuNSIgd2lkdGg9IjgiIGhlaWdodD0iMTgiIHJ4PSI0IiB0cmFuc2Zvcm09Im1hdHJpeCgxIDAgMCAtMSAwIDI3KSIgZmlsbD0id2hpdGUiIHN0cm9rZT0iIzM1OEJFNyIvPgo8cmVjdCB3aWR0aD0iMyIgaGVpZ2h0PSIyIiByeD0iMSIgdHJhbnNmb3JtPSJtYXRyaXgoMSAwIDAgLTEgMyAyMykiIGZpbGw9IiMzNThCRTciLz4KPHJlY3Qgd2lkdGg9IjMiIGhlaWdodD0iMiIgcng9IjEiIHRyYW5zZm9ybT0ibWF0cml4KDEgMCAwIC0xIDMgMTkpIiBmaWxsPSIjMzU4QkU3Ii8+CjxyZWN0IHdpZHRoPSIzIiBoZWlnaHQ9IjIiIHJ4PSIxIiB0cmFuc2Zvcm09Im1hdHJpeCgxIDAgMCAtMSAzIDE1KSIgZmlsbD0iIzM1OEJFNyIvPgo8L3N2Zz4=',\n },\n ySlider && {\n throttle: 0,\n type: 'slider',\n left: parseInt(theme?.spacing?.(6) ?? '48'),\n width: parseInt(theme?.spacing?.(4) ?? '32'),\n yAxisIndex: [0],\n show: zoom && showSliders,\n zoomLock: !zoom,\n start,\n end,\n ...sliderStyles,\n brushSelect: false,\n moveHandleSize: 8,\n handleSize: '100%',\n handleIcon:\n 'image://data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzYiIGhlaWdodD0iOSIgdmlld0JveD0iMCAwIDM2IDkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjAuNSIgeT0iMC41IiB3aWR0aD0iOCIgaGVpZ2h0PSIxOCIgcng9IjQiIHRyYW5zZm9ybT0icm90YXRlKC05MCAwLjUgMC41KSIgZmlsbD0id2hpdGUiIHN0cm9rZT0iIzM1OEJFNyIvPgo8cmVjdCB3aWR0aD0iMyIgaGVpZ2h0PSIyIiByeD0iMSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDEzIDYpIiBmaWxsPSIjMzU4QkU3Ii8+CjxyZWN0IHdpZHRoPSIzIiBoZWlnaHQ9IjIiIHJ4PSIxIiB0cmFuc2Zvcm09InJvdGF0ZSgtOTAgMTcgNikiIGZpbGw9IiMzNThCRTciLz4KPHJlY3Qgd2lkdGg9IjMiIGhlaWdodD0iMiIgcng9IjEiIHRyYW5zZm9ybT0icm90YXRlKC05MCAyMSA2KSIgZmlsbD0iIzM1OEJFNyIvPgo8L3N2Zz4=',\n },\n ].filter((d) => !!d),\n }\n}\n\nfunction getEChartZoomSliderStyles(theme: Theme) {\n return {\n fillerColor: 'rgba(53, 139, 231, 0.25)',\n borderColor: 'rgba(53, 139, 231, 0.3)',\n borderWidth: 0.5,\n backgroundColor: 'transparent',\n borderRadius: 4,\n dataBackground: {\n lineStyle: {\n opacity: 0,\n },\n areaStyle: {\n opacity: 1,\n color: theme.palette.secondary.main,\n },\n },\n selectedDataBackground: {\n lineStyle: {\n opacity: 0,\n },\n areaStyle: {\n opacity: 1,\n color: theme.palette.secondary.main,\n },\n },\n handleStyle: {\n color: theme.palette.common.white,\n borderColor: 'rgba(3, 111, 226, 0.08)',\n borderWidth: 1,\n shadowBlur: 3,\n shadowColor: 'rgba(0, 0, 0, 0.1)',\n shadowOffsetX: 0,\n shadowOffsetY: 1,\n },\n textStyle: {\n color: theme.palette.black[60],\n fontSize: parseInt(theme.typography.overlineDelicate.fontSize as string),\n fontFamily: theme.typography.overlineDelicate.fontFamily,\n },\n } as const\n}\n\nexport function getEChartBrushConfig(brush: boolean) {\n return brush\n ? {\n brush: {\n brushType: 'rect',\n brushMode: 'single',\n },\n }\n : {}\n}\n\nexport function getEChartStackConfig(\n stack: boolean,\n stackGroup: string = DEFAULT_STACK_GROUP,\n) {\n return { stack: stack ? stackGroup : undefined }\n}\n"],"names":["DEFAULT_STACK_GROUP","mergeEchartWidgetConfig","options","deepmerge","customMerge","key","_","b","a","length","map","bItem","index","aItem","getEChartZoomConfig","zoom","start","end","inside","xSlider","ySlider","showSliders","xAxisLabelFormatter","bottomOffset","theme","sliderStyles","getEChartZoomSliderStyles","dataZoom","throttle","type","xAxisIndex","yAxisIndex","show","zoomLock","orientation","bottom","height","parseInt","spacing","labelFormatter","showDetail","brushSelect","moveHandleSize","handleSize","handleIcon","left","width","filter","d","fillerColor","borderColor","borderWidth","backgroundColor","borderRadius","dataBackground","lineStyle","opacity","areaStyle","color","palette","secondary","main","selectedDataBackground","handleStyle","common","white","shadowBlur","shadowColor","shadowOffsetX","shadowOffsetY","textStyle","black","fontSize","typography","overlineDelicate","fontFamily","getEChartBrushConfig","brush","brushType","brushMode","getEChartStackConfig","stack","stackGroup","undefined"],"mappings":";AAAO,MAAMA,IAAsB;ACK5B,SAASC,KACXC,GACA;AACH,SAAOC,EAAUD,EAAQ,CAAC,KAAK,CAAA,GAAIA,EAAQ,CAAC,KAAK,IAAI;AAAA,IACnDE,aAAcC,CAAAA,MAAQ;AACpB,UAAIA,MAAQ;AACV,eAAO,CAACC,GAAGC,MAAkBA;AAE/B,UAAIF,MAAQ;AACV,eAAO,CAACG,GAAkBD,MACnBC,EAAEC,SAEcF,GAAGG,IAAI,CAACC,GAAOC,MAAU;AAC5C,gBAAMC,IAAQL,IAAII,CAAK,KAAK,CAAA;AAC5B,iBAAOT,EAAUU,GAAOF,CAAe;AAAA,QACzC,CAAC,IALqBH;AAAAA,IAS5B;AAAA,EAAA,CACD;AACH;AAEO,SAASM,EACdC,GACA;AAAA,EAAEC,OAAAA;AAAAA,EAAOC,KAAAA;AAAoC,IAAI;AAAA,EAAED,OAAO;AAAA,EAAGC,KAAK;AAAI,GACtE;AAAA,EACEC,QAAAA,IAAS;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AqBC,GAAgB;AACnD,SAAOA,IACH;AAAA,IACEA,OAAO;AAAA,MACLC,WAAW;AAAA,MACXC,WAAW;AAAA,IAAA;AAAA,EACb,IAEF,CAAA;AACN;AAEO,SAASC,EACdC,GACAC,IAAqBlF,GACrB;AACA,SAAO;AAAA,IAAEiF,OAAOA,IAAQC,IAAaC;AAAAA,EAAAA;AACvC;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { create as
|
|
2
|
-
const
|
|
1
|
+
import { create as T } from "zustand";
|
|
2
|
+
const f = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), p = T()((l, u) => ({
|
|
3
3
|
// State
|
|
4
4
|
widgets: {},
|
|
5
5
|
// Actions
|
|
@@ -27,16 +27,16 @@ const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p = a()((l,
|
|
|
27
27
|
clearWidgets: () => l({
|
|
28
28
|
widgets: {}
|
|
29
29
|
}),
|
|
30
|
-
getWidget: (e) =>
|
|
30
|
+
getWidget: (e) => u().widgets[e],
|
|
31
31
|
registerTool: (e, i) => l((t) => {
|
|
32
|
-
const s = t.widgets[e] ?? {},
|
|
32
|
+
const s = t.widgets[e] ?? {}, c = (s.registeredTools ?? []).filter((d) => d.id !== i.id);
|
|
33
33
|
return {
|
|
34
34
|
widgets: {
|
|
35
35
|
...t.widgets,
|
|
36
36
|
[e]: {
|
|
37
37
|
...s,
|
|
38
38
|
id: e,
|
|
39
|
-
registeredTools: [...
|
|
39
|
+
registeredTools: [...c, i]
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
};
|
|
@@ -44,13 +44,13 @@ const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p = a()((l,
|
|
|
44
44
|
unregisterTool: (e, i) => l((t) => {
|
|
45
45
|
const s = t.widgets[e];
|
|
46
46
|
if (!s) return t;
|
|
47
|
-
const
|
|
47
|
+
const c = (s.registeredTools ?? []).filter((d) => d.id !== i);
|
|
48
48
|
return {
|
|
49
49
|
widgets: {
|
|
50
50
|
...t.widgets,
|
|
51
51
|
[e]: {
|
|
52
52
|
...s,
|
|
53
|
-
registeredTools:
|
|
53
|
+
registeredTools: c
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
};
|
|
@@ -58,7 +58,7 @@ const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p = a()((l,
|
|
|
58
58
|
updateToolConfig: (e, i, t) => l((s) => {
|
|
59
59
|
const n = s.widgets[e];
|
|
60
60
|
if (!n) return s;
|
|
61
|
-
const
|
|
61
|
+
const d = (n.registeredTools ?? []).map((r) => r.id === i ? {
|
|
62
62
|
...r,
|
|
63
63
|
config: {
|
|
64
64
|
...r.config,
|
|
@@ -70,7 +70,7 @@ const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p = a()((l,
|
|
|
70
70
|
...s.widgets,
|
|
71
71
|
[e]: {
|
|
72
72
|
...n,
|
|
73
|
-
registeredTools:
|
|
73
|
+
registeredTools: d
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
};
|
|
@@ -78,7 +78,7 @@ const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p = a()((l,
|
|
|
78
78
|
setToolEnabled: (e, i, t) => l((s) => {
|
|
79
79
|
const n = s.widgets[e];
|
|
80
80
|
if (!n) return s;
|
|
81
|
-
const
|
|
81
|
+
const d = (n.registeredTools ?? []).map((r) => r.id === i ? {
|
|
82
82
|
...r,
|
|
83
83
|
enabled: t
|
|
84
84
|
} : r);
|
|
@@ -87,23 +87,23 @@ const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p = a()((l,
|
|
|
87
87
|
...s.widgets,
|
|
88
88
|
[e]: {
|
|
89
89
|
...n,
|
|
90
|
-
registeredTools:
|
|
90
|
+
registeredTools: d
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
}),
|
|
95
95
|
executeToolPipeline: async (e, i) => {
|
|
96
|
-
const t =
|
|
96
|
+
const t = u().widgets[e];
|
|
97
97
|
if (!t) return;
|
|
98
|
-
const s = (
|
|
99
|
-
|
|
100
|
-
const n = t,
|
|
98
|
+
const s = (f.get(e) ?? 0) + 1;
|
|
99
|
+
f.set(e, s);
|
|
100
|
+
const n = t, c = /* @__PURE__ */ new Set();
|
|
101
101
|
for (const o of n.registeredTools ?? [])
|
|
102
|
-
o.enabled && o.disables && o.disables.forEach((g) =>
|
|
103
|
-
const
|
|
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
104
|
let r = i;
|
|
105
|
-
for (const o of
|
|
106
|
-
if (
|
|
105
|
+
for (const o of d) {
|
|
106
|
+
if (f.get(e) !== s)
|
|
107
107
|
return;
|
|
108
108
|
try {
|
|
109
109
|
r = await o.fn(r, o.config);
|
|
@@ -122,38 +122,23 @@ const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p = a()((l,
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
} : o;
|
|
125
|
-
}),
|
|
125
|
+
}), f.get(e) === s && f.delete(e);
|
|
126
126
|
},
|
|
127
127
|
executeConfigPipeline: async (e, i) => {
|
|
128
|
-
const t =
|
|
128
|
+
const t = u().widgets[e];
|
|
129
129
|
if (!t) return;
|
|
130
|
-
const s = (
|
|
131
|
-
|
|
130
|
+
const s = (a.get(e) ?? 0) + 1;
|
|
131
|
+
a.set(e, s);
|
|
132
132
|
const n = /* @__PURE__ */ new Set();
|
|
133
133
|
for (const r of t.registeredTools ?? [])
|
|
134
134
|
r.enabled && r.disables && r.disables.forEach((o) => n.add(o));
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return o ? {
|
|
140
|
-
widgets: {
|
|
141
|
-
...r.widgets,
|
|
142
|
-
[e]: {
|
|
143
|
-
...o,
|
|
144
|
-
...i
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
} : r;
|
|
148
|
-
}), f.get(e) === s && f.delete(e);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
let c = i;
|
|
152
|
-
for (const r of d) {
|
|
153
|
-
if (f.get(e) !== s)
|
|
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)
|
|
154
139
|
return;
|
|
155
140
|
try {
|
|
156
|
-
|
|
141
|
+
d = await r.fn(d, r.config);
|
|
157
142
|
} catch (o) {
|
|
158
143
|
console.error(`Config tool ${r.id} failed for widget ${e}:`, o);
|
|
159
144
|
}
|
|
@@ -165,14 +150,14 @@ const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p = a()((l,
|
|
|
165
150
|
...r.widgets,
|
|
166
151
|
[e]: {
|
|
167
152
|
...o,
|
|
168
|
-
...
|
|
153
|
+
...d
|
|
169
154
|
}
|
|
170
155
|
}
|
|
171
156
|
} : r;
|
|
172
|
-
}),
|
|
157
|
+
}), a.get(e) === s && a.delete(e);
|
|
173
158
|
}
|
|
174
159
|
}));
|
|
175
160
|
export {
|
|
176
161
|
p as u
|
|
177
162
|
};
|
|
178
|
-
//# sourceMappingURL=widget-store-
|
|
163
|
+
//# sourceMappingURL=widget-store-CzDt8oSK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,MACF;AAAA,IACF;AAAA,EAEJ,CAAC;AAAA,EAEHI,cAAeJ,CAAAA,MACbJ,EAAKM,CAAAA,MAAU;AACb,UAAMJ,IAAU;AAAA,MAAE,GAAGI,EAAMJ;AAAAA,IAAAA;AAE3B,kBAAOA,EAAQE,CAAE,GAEV;AAAA,MAAEF,SAAAA;AAAAA,IAAAA;AAAAA,EACX,CAAC;AAAA,EAEHO,cAAcA,MACZT,EAAI;AAAA,IACFE,SAAS,CAAA;AAAA,EAAC,CACX;AAAA,EAEHQ,WAAW,CAAwBN,MAC1BH,EAAAA,EA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