@carto/ps-react-ui 4.5.0 → 4.6.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 → download-config-C3I0jWIL.js} +2 -2
- package/dist/{download-config-DemuQ3Jm.js.map → download-config-C3I0jWIL.js.map} +1 -1
- package/dist/{row-D4VOhcNI.js → row-DZSP99LW.js} +2 -2
- package/dist/{row-D4VOhcNI.js.map → row-DZSP99LW.js.map} +1 -1
- package/dist/{series-Bola3CmD.js → series-DLNHDWs0.js} +3 -3
- package/dist/{series-Bola3CmD.js.map → series-DLNHDWs0.js.map} +1 -1
- package/dist/types/hooks/index.d.ts +0 -1
- package/dist/types/widgets/actions/brush-toggle/brush-toggle.d.ts +3 -0
- package/dist/types/widgets/actions/index.d.ts +4 -4
- package/dist/types/widgets/actions/lock-selection/types.d.ts +2 -0
- package/dist/types/widgets/actions/relative-data/relative-data.d.ts +7 -2
- package/dist/types/widgets/actions/relative-data/types.d.ts +2 -0
- package/dist/types/widgets/actions/zoom-toggle/zoom-toggle.d.ts +4 -0
- package/dist/types/widgets/category/index.d.ts +10 -2
- package/dist/types/widgets/category/style.d.ts +1 -0
- package/dist/types/widgets/no-data/no-data.d.ts +3 -2
- package/dist/types/widgets/no-data/types.d.ts +5 -1
- package/dist/types/widgets/stores/index.d.ts +1 -1
- package/dist/types/widgets/stores/types.d.ts +10 -10
- package/dist/types/widgets/stores/widget-store.d.ts +2 -3
- package/dist/types/widgets/table/index.d.ts +6 -2
- package/dist/{use-widget-ref-BFazQvJK.js → use-widget-ref-Ddr_SlJJ.js} +2 -2
- package/dist/{use-widget-ref-BFazQvJK.js.map → use-widget-ref-Ddr_SlJJ.js.map} +1 -1
- package/dist/{use-widget-selector-DqRmWQ1K.js → use-widget-selector-DFl2hW0R.js} +2 -2
- package/dist/{use-widget-selector-DqRmWQ1K.js.map → use-widget-selector-DFl2hW0R.js.map} +1 -1
- package/dist/{widget-store-CIrb9RKP.js → widget-store-Bw5zRUGg.js} +93 -95
- package/dist/widget-store-Bw5zRUGg.js.map +1 -0
- package/dist/widgets/actions.js +770 -755
- package/dist/widgets/actions.js.map +1 -1
- package/dist/widgets/bar.js +2 -2
- package/dist/widgets/category.js +187 -183
- package/dist/widgets/category.js.map +1 -1
- package/dist/widgets/echart.js +2 -2
- package/dist/widgets/error.js +37 -2
- package/dist/widgets/error.js.map +1 -1
- package/dist/widgets/formula.js +5 -5
- package/dist/widgets/histogram.js +1 -1
- package/dist/widgets/loader.js +1 -1
- package/dist/widgets/markdown.js +2 -2
- package/dist/widgets/no-data.js +58 -2
- package/dist/widgets/no-data.js.map +1 -1
- package/dist/widgets/note.js +121 -2
- package/dist/widgets/note.js.map +1 -1
- package/dist/widgets/pie.js +2 -2
- package/dist/widgets/range.js +3 -3
- package/dist/widgets/scatterplot.js +2 -2
- package/dist/widgets/skeleton-loader.js +1 -1
- package/dist/widgets/spread.js +5 -5
- package/dist/widgets/stores.js +2 -2
- package/dist/widgets/subheader.js +29 -29
- package/dist/widgets/subheader.js.map +1 -1
- package/dist/widgets/table.js +3 -3
- package/dist/widgets/timeseries.js +2 -2
- package/dist/widgets/utils.js +1 -1
- package/dist/widgets/wrapper.js +2 -2
- package/package.json +1 -5
- package/src/hooks/index.ts +0 -1
- package/src/widgets/actions/brush-toggle/brush-toggle.tsx +18 -22
- package/src/widgets/actions/change-column/change-column.test.tsx +1 -1
- package/src/widgets/actions/download/download.test.tsx +1 -1
- package/src/widgets/actions/index.ts +11 -2
- package/src/widgets/actions/lock-selection/lock-selection.test.tsx +14 -0
- package/src/widgets/actions/lock-selection/lock-selection.tsx +18 -11
- package/src/widgets/actions/lock-selection/types.ts +2 -0
- package/src/widgets/actions/relative-data/relative-data.test.tsx +211 -20
- package/src/widgets/actions/relative-data/relative-data.tsx +65 -34
- package/src/widgets/actions/relative-data/types.ts +2 -0
- package/src/widgets/actions/searcher/searcher.tsx +28 -30
- package/src/widgets/actions/stack-toggle/stack-toggle.tsx +11 -2
- package/src/widgets/actions/zoom-toggle/zoom-toggle.tsx +53 -45
- package/src/widgets/category/category-ui.tsx +7 -6
- package/src/widgets/category/index.ts +13 -14
- package/src/widgets/category/style.ts +1 -0
- package/src/widgets/no-data/no-data.test.tsx +90 -40
- package/src/widgets/no-data/no-data.tsx +7 -5
- package/src/widgets/no-data/types.ts +5 -1
- package/src/widgets/stores/index.ts +2 -0
- package/src/widgets/stores/types.ts +10 -18
- package/src/widgets/stores/widget-store.test.ts +132 -13
- package/src/widgets/stores/widget-store.ts +29 -35
- package/src/widgets/subheader/subheader.tsx +11 -3
- package/src/widgets/table/index.ts +6 -4
- package/dist/error-Cj8eUMrl.js +0 -40
- package/dist/error-Cj8eUMrl.js.map +0 -1
- package/dist/no-data-DkIt7Qt1.js +0 -61
- package/dist/no-data-DkIt7Qt1.js.map +0 -1
- package/dist/note-t51drNe0.js +0 -124
- package/dist/note-t51drNe0.js.map +0 -1
- package/dist/types/hooks/use-debounce.d.ts +0 -19
- package/dist/types/widgets/category/components/index.d.ts +0 -10
- package/dist/types/widgets/index.d.ts +0 -9
- package/dist/types/widgets/table/hooks/index.d.ts +0 -6
- package/dist/widget-store-CIrb9RKP.js.map +0 -1
- package/dist/widgets.js +0 -13
- package/dist/widgets.js.map +0 -1
- package/src/hooks/use-debounce.ts +0 -55
- package/src/widgets/category/components/index.ts +0 -14
- package/src/widgets/index.ts +0 -25
- package/src/widgets/table/hooks/index.ts +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react/compiler-runtime";
|
|
3
3
|
import "@mui/material";
|
|
4
|
-
import "./widget-store-
|
|
4
|
+
import "./widget-store-Bw5zRUGg.js";
|
|
5
5
|
import "zustand/shallow";
|
|
6
6
|
import "@mui/icons-material";
|
|
7
7
|
import "react";
|
|
@@ -53,4 +53,4 @@ export {
|
|
|
53
53
|
E as f,
|
|
54
54
|
T as s
|
|
55
55
|
};
|
|
56
|
-
//# sourceMappingURL=download-config-
|
|
56
|
+
//# sourceMappingURL=download-config-C3I0jWIL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download-config-
|
|
1
|
+
{"version":3,"file":"download-config-C3I0jWIL.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;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import { c as n } from "react/compiler-runtime";
|
|
3
3
|
import { Box as c } from "@mui/material";
|
|
4
|
-
import { u as l } from "./use-widget-selector-
|
|
4
|
+
import { u as l } from "./use-widget-selector-DFl2hW0R.js";
|
|
5
5
|
const s = {
|
|
6
6
|
item: {
|
|
7
7
|
'&[data-disabled="true"]': {
|
|
@@ -31,4 +31,4 @@ export {
|
|
|
31
31
|
h as R,
|
|
32
32
|
s
|
|
33
33
|
};
|
|
34
|
-
//# sourceMappingURL=row-
|
|
34
|
+
//# sourceMappingURL=row-DZSP99LW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-
|
|
1
|
+
{"version":3,"file":"row-DZSP99LW.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;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
2
|
import { c as h } from "react/compiler-runtime";
|
|
3
|
-
import { u as p } from "./use-widget-selector-
|
|
3
|
+
import { u as p } from "./use-widget-selector-DFl2hW0R.js";
|
|
4
4
|
import { Typography as g, Avatar as b } from "@mui/material";
|
|
5
|
-
import { s as P } from "./row-
|
|
5
|
+
import { s as P } from "./row-DZSP99LW.js";
|
|
6
6
|
function y(t) {
|
|
7
7
|
const e = h(4);
|
|
8
8
|
let l;
|
|
@@ -87,4 +87,4 @@ export {
|
|
|
87
87
|
I as S,
|
|
88
88
|
C as a
|
|
89
89
|
};
|
|
90
|
-
//# sourceMappingURL=series-
|
|
90
|
+
//# sourceMappingURL=series-DLNHDWs0.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"series-
|
|
1
|
+
{"version":3,"file":"series-DLNHDWs0.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","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;ACXV,SAAAO,EAAAP,GAAA;AAAA,QAAAF,IAAAC,EAAA,CAAA;AAAA,MAAAS,GAAAX,GAAAY;AAAA,EAAAX,SAAAE,KAAgB;AAAA,IAAAQ,IAAAA;AAAAA,IAAAE,OAAAD;AAAAA,IAAA,GAAAZ;AAAAA,EAAAA,IAAAG,GAAuCF,OAAAE,GAAAF,OAAAU,GAAAV,OAAAD,GAAAC,OAAAW,MAAAD,IAAAV,EAAA,CAAA,GAAAD,IAAAC,EAAA,CAAA,GAAAW,IAAAX,EAAA,CAAA;AAAjC,QAAAY,IAAAD,MAAAE,SAAA,IAAAF;AAAS,MAAAG;AAAA,EAAAd,SAAAY,KAGlCE,IAAAC,CAAAA,MAAQA,GAA0CC,OAAGJ,CAAK,GAASK,QAAAjB,OAAAY,GAAAZ,OAAAc,KAAAA,IAAAd,EAAA,CAAA;AAFrE,QAAAiB,IAAeC,EACbR,GACAI,CACF;AAEA,MAAI,CAACG;AAAM,WACF;AACR,MAAAE;AAAA,SAAAnB,EAAA,CAAA,MAAAiB,KAAAjB,SAAAD,KAEMoB,IAAA,gBAAAC,EAACtB,GAAA,EAAI,GAAKC,GAAQkB,UAAAA,GAAO,GAAOjB,OAAAiB,GAAAjB,OAAAD,GAAAC,OAAAmB,KAAAA,IAAAnB,EAAA,CAAA,GAAhCmB;AAAgC;ACTlC,SAAAE,EAAAnB,GAAA;AAAA,QAAAF,IAAAC,EAAA,EAAA;AAAA,MAAAS,GAAAX,GAAAY;AAAA,EAAAX,SAAAE,KAAgB;AAAA,IAAAQ,IAAAA;AAAAA,IAAAE,OAAAD;AAAAA,IAAA,GAAAZ;AAAAA,EAAAA,IAAAG,GAAuCF,OAAAE,GAAAF,OAAAU,GAAAV,OAAAD,GAAAC,OAAAW,MAAAD,IAAAV,EAAA,CAAA,GAAAD,IAAAC,EAAA,CAAA,GAAAW,IAAAX,EAAA,CAAA;AAAjC,QAAAY,IAAAD,MAAAE,SAAA,IAAAF;AAAS,MAAAG;AAAA,EAAAd,SAAAY,KAGlCE,IAAAC,CAAAA,MAAQA,GAA0CC,OAAGJ,CAAK,GAASU,QAAAtB,OAAAY,GAAAZ,OAAAc,KAAAA,IAAAd,EAAA,CAAA;AAFrE,QAAAsB,IAAeJ,EACbR,GACAI,CACF;AAEA,MAAI,CAACQ;AAAM,WACF;AACR,MAAAH;AAAA,EAAAnB,EAAA,CAAA,MAAAuB,uBAAAC,IAAA,2BAAA,KAIoBL,IAAA;AAAA,IAAAM,OACRC;AAAAA,EAAAA,GACR1B,OAAAmB,KAAAA,IAAAnB,EAAA,CAAA;AAAA,MAAA2B;AAAA,SAAA3B,EAAA,CAAA,MAAAD,KAAAC,SAAAsB,KAHHK,sBAAC7B,GAAA,EACkB,iBAAAqB,GAEhB,GACGpB,GAEHuB,UAAAA,GACH,GAAOtB,OAAAD,GAAAC,OAAAsB,GAAAtB,OAAA2B,KAAAA,IAAA3B,EAAA,CAAA,GAPP2B;AAOO;AAlBJ,SAAAD,EAAAE,GAAA;AAAA,SAa0BA,EAAKC,QAAQC,KAAKC;AAAU;ACdtD,SAAAC,EAAA9B,GAAA;AAAA,QAAAF,IAAAC,EAAA,EAAA,GAAgB;AAAA,IAAAS,IAAAA;AAAAA,IAAAE,OAAAD;AAAAA,EAAAA,IAAAT,GAAMU,IAAAD,MAAAE,SAAA,IAAAF;AAAS,MAAAG;AAAA,EAAAd,SAAAY,KAGlCE,IAAAC,CAAAA,MAAQA,GAA4CkB,SAAGrB,CAAK,GAACZ,OAAAY,GAAAZ,OAAAc,KAAAA,IAAAd,EAAA,CAAA;AAF/D,QAAAkC,IAAchB,EACZR,GACAI,CACF;AACA,MAAI,CAACoB;AAAK,WACD;AAGT,QAAA;AAAA,IAAAC,MAAAA;AAAAA,IAAAV,OAAAA;AAAAA,EAAAA,IAAwBS;AAAK,MAAAf;AAAA,EAAAnB,SAAAyB,KAUnBN,IAAAM,KAAA;AAAA,IAAAA,OACKG,CAAAA,MAAWA,EAAKC,QAAQO,gBAAiBX,CAAK;AAAA,EAAA,GACtDzB,OAAAyB,GAAAzB,OAAAmB,KAAAA,IAAAnB,EAAA,CAAA;AAAA,MAAA2B;AAAA,EAAA3B,EAAA,CAAA,MAAAyB,KAAAzB,SAAAmB,KARCQ,IAAA;AAAA,IAAAU,SACOZ;AAAAA,IAAKa,OACP;AAAA,IAAEC,QACD;AAAA,IAAEC,UACA;AAAA,IAAUC,YACR;AAAA,IAAQ,GAChBtB;AAAAA,EAAAA,GAGLnB,OAAAyB,GAAAzB,OAAAmB,GAAAnB,OAAA2B,KAAAA,IAAA3B,EAAA,CAAA;AAAA,MAAA0C;AAAA,EAAA1C,SAAAmC,KAEAO,IAAAP,EAAIQ,OAAQ,CAAC,EAACC,YAAAA,GAAc5C,OAAAmC,GAAAnC,OAAA0C,KAAAA,IAAA1C,EAAA,CAAA;AAAA,MAAA6C;AAAA,SAAA7C,EAAA,CAAA,MAAA2B,KAAA3B,UAAA0C,KAZ/BG,IAAA,gBAAAzB,EAAC0B,GAAA,EACK,IAAAnB,GAWHe,UAAAA,GACH,GAAS1C,OAAA2B,GAAA3B,QAAA0C,GAAA1C,QAAA6C,KAAAA,IAAA7C,EAAA,EAAA,GAbT6C;AAaS;"}
|
|
@@ -6,6 +6,9 @@ export declare const BRUSH_TOGGLE_TOOL_ID = "brush-toggle";
|
|
|
6
6
|
* Registers as a config pipeline tool so that brush configuration is automatically
|
|
7
7
|
* re-applied when the base config is updated (e.g., by WidgetLoader).
|
|
8
8
|
*
|
|
9
|
+
* Brush state is stored in the widget store root, and the tool derives its
|
|
10
|
+
* `enabled` flag from the store. This keeps state accessible across component instances.
|
|
11
|
+
*
|
|
9
12
|
* When brush is active, users can drag across bars to select a range.
|
|
10
13
|
* Selection clearing is handled via the chart's brush interactions/toolbox configuration.
|
|
11
14
|
* Only intended for use in fullscreen ToolbarActions for bar and histogram widgets.
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export { FullScreen } from './fullscreen/fullscreen';
|
|
2
|
-
export type { FullScreenState, FullScreenConfig } from './fullscreen/types';
|
|
2
|
+
export type { FullScreenState, FullScreenConfig, FullScreenProps, } from './fullscreen/types';
|
|
3
3
|
export { Download } from './download/download';
|
|
4
4
|
export type { DownloadItem, DownloadProps } from './download/types';
|
|
5
5
|
export { downloadToCSV, downloadToPNG } from './download/exports';
|
|
6
6
|
export { RelativeData, RELATIVE_DATA_TOOL_ID, RELATIVE_DATA_CONFIG_TOOL_ID, } from './relative-data/relative-data';
|
|
7
|
-
export type { RelativeDataProps } from './relative-data/types';
|
|
7
|
+
export type { RelativeDataProps, RelativeDataState, } from './relative-data/types';
|
|
8
8
|
export { ZoomToggle, ZOOM_TOGGLE_TOOL_ID } from './zoom-toggle/zoom-toggle';
|
|
9
9
|
export type { ZoomToggleProps, ZoomState, ZoomConfig, } from './zoom-toggle/types';
|
|
10
10
|
export { StackToggle, STACK_TOGGLE_TOOL_ID } from './stack-toggle/stack-toggle';
|
|
11
11
|
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
|
-
export type { SearcherToggleProps, SearcherProps, SearcherFilterFn, SearcherState, } from './searcher/types';
|
|
14
|
+
export type { SearcherToggleProps, SearcherProps, SearcherFilterFn, SearcherState, SearcherStateProps, } from './searcher/types';
|
|
15
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
|
-
export type { LockSelectionProps, LockSelectionState, } from './lock-selection/types';
|
|
18
|
+
export type { LockSelectionProps, LockSelectionState, LockSelectionStateProps, } from './lock-selection/types';
|
|
19
19
|
export { BrushToggle, BRUSH_TOGGLE_TOOL_ID } from './brush-toggle/brush-toggle';
|
|
20
20
|
export type { BrushToggleProps, BrushState, BrushConfig, BrushSelectedItems, } from './brush-toggle/types';
|
|
@@ -4,8 +4,13 @@ export declare const RELATIVE_DATA_CONFIG_TOOL_ID = "relative-data-config";
|
|
|
4
4
|
/**
|
|
5
5
|
* Widget action to toggle between relative (percentage) and absolute data display.
|
|
6
6
|
*
|
|
7
|
-
* Registers
|
|
8
|
-
*
|
|
7
|
+
* Registers two transformation tools in the widget pipeline when mounted:
|
|
8
|
+
* - A data tool that converts values to percentages (enabled/disabled via store)
|
|
9
|
+
* - A config tool that is **always enabled** and reads `isRelative` from the store
|
|
10
|
+
* to decide whether to apply the percentage formatter or restore the original one.
|
|
11
|
+
* The config tool must always participate because the original formatter may have
|
|
12
|
+
* been set via `setWidget` (not in the base config), so disabling the tool would
|
|
13
|
+
* leave the percentage formatter stuck on the widget.
|
|
9
14
|
*
|
|
10
15
|
* @example
|
|
11
16
|
* ```tsx
|
|
@@ -6,6 +6,10 @@ export declare const ZOOM_TOGGLE_TOOL_ID = "zoom-toggle";
|
|
|
6
6
|
* Registers as a config pipeline tool so that zoom configuration is automatically
|
|
7
7
|
* re-applied when the base config is updated (e.g., by WidgetLoader).
|
|
8
8
|
*
|
|
9
|
+
* Zoom state (enabled, range) is stored in the widget store root, and the tool
|
|
10
|
+
* derives its `enabled` flag from the store. This keeps state accessible across
|
|
11
|
+
* component instances.
|
|
12
|
+
*
|
|
9
13
|
* When zoom is active, displays an inline reset button to disable zoom.
|
|
10
14
|
* Only intended for use in fullscreen ToolbarActions for bar and histogram widgets.
|
|
11
15
|
*
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
export { CategoryUI } from './category-ui';
|
|
2
2
|
export { CategorySkeleton } from './skeleton';
|
|
3
3
|
export { categoryConfig, categoryDownloadConfig } from './config';
|
|
4
|
-
export { CategoryBar
|
|
5
|
-
export type { CategoryBarProps
|
|
4
|
+
export { CategoryBar } from './components/category-bar';
|
|
5
|
+
export type { CategoryBarProps } from './components/category-bar';
|
|
6
|
+
export { CategoryRowSingle } from './components/category-row-single';
|
|
7
|
+
export type { CategoryRowSingleProps } from './components/category-row-single';
|
|
8
|
+
export { CategoryRowMulti } from './components/category-row-multi';
|
|
9
|
+
export type { CategoryRowMultiProps } from './components/category-row-multi';
|
|
10
|
+
export { CategoryRowOther } from './components/category-row-other';
|
|
11
|
+
export type { CategoryRowOtherProps } from './components/category-row-other';
|
|
12
|
+
export { CategoryLegend } from './components/category-legend';
|
|
13
|
+
export type { CategoryLegendProps } from './components/category-legend';
|
|
6
14
|
export type { CategoryUIProps, CategoryWidgetData, CategoryWidgetState, CategoryWidgetConfig, CategoryDownloadConfig, CategoryDataItem, CategorySeriesConfig, CategoryLabels, } from './types';
|
|
@@ -2,8 +2,9 @@ import { WidgetNoDataProps } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* NoData wrapper component that displays empty state UI when widget has no data
|
|
4
4
|
*
|
|
5
|
-
* Integrates with widget store to check loading/fetching state and data availability.
|
|
6
|
-
*
|
|
5
|
+
* Integrates with widget store to check loading/fetching state and source data availability.
|
|
6
|
+
* Uses `sourceData` (pre-pipeline data) instead of `data` (post-pipeline) to distinguish
|
|
7
|
+
* "API returned nothing" from "pipeline tools filtered everything out".
|
|
7
8
|
*
|
|
8
9
|
* @example Basic usage
|
|
9
10
|
* ```tsx
|
|
@@ -54,7 +54,11 @@ export interface WidgetNoDataProps {
|
|
|
54
54
|
*/
|
|
55
55
|
description?: string;
|
|
56
56
|
/**
|
|
57
|
-
* Optional custom function to determine if data is empty
|
|
57
|
+
* Optional custom function to determine if source data is empty.
|
|
58
|
+
* Receives `sourceData` (pre-pipeline data from the API), not `data`
|
|
59
|
+
* (post-pipeline). This allows distinguishing "API returned nothing"
|
|
60
|
+
* from "pipeline tools filtered everything out".
|
|
61
|
+
*
|
|
58
62
|
* If not provided, uses default isEmpty logic that handles:
|
|
59
63
|
* - null/undefined → empty
|
|
60
64
|
* - [] (empty array) → empty
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { useWidgetStore, widgetStoreActions } from './widget-store';
|
|
2
2
|
export { useWidgetSelector } from './use-widget-selector';
|
|
3
|
-
export type { BaseWidgetState, ToolType, WidgetsStoreProps, WidgetState, WidgetStore, WidgetStoreActions, WidgetStoreState, } from './types';
|
|
3
|
+
export type { BaseWidgetState, ToolRegistration, ToolTransformFunction, ToolType, WidgetsStoreProps, WidgetState, WidgetStore, WidgetStoreActions, WidgetStoreState, } from './types';
|
|
@@ -12,6 +12,10 @@ export interface WidgetsStoreProps {
|
|
|
12
12
|
type: string;
|
|
13
13
|
/** Widget data - flexible to accommodate different widget types */
|
|
14
14
|
data: unknown;
|
|
15
|
+
/** Original pre-pipeline data. Used by NoData to distinguish
|
|
16
|
+
* "no data from API" from "pipeline tools filtered everything out".
|
|
17
|
+
* Set automatically by executeToolPipeline — not a component prop. */
|
|
18
|
+
sourceData?: unknown;
|
|
15
19
|
/** Loading state */
|
|
16
20
|
isLoading: boolean;
|
|
17
21
|
/** Fetching state (e.g., for async data) */
|
|
@@ -38,7 +42,7 @@ export interface WidgetsStoreProps {
|
|
|
38
42
|
* Tool transformation function type
|
|
39
43
|
* Can be synchronous or asynchronous to support remote operations
|
|
40
44
|
*/
|
|
41
|
-
export type ToolTransformFunction = (data: unknown
|
|
45
|
+
export type ToolTransformFunction = (data: unknown) => unknown;
|
|
42
46
|
/**
|
|
43
47
|
* Tool registration for widget pipeline
|
|
44
48
|
*
|
|
@@ -80,8 +84,6 @@ export interface ToolRegistration {
|
|
|
80
84
|
enabled: boolean;
|
|
81
85
|
/** 'data' (default) transforms data, 'config' transforms widget config/option */
|
|
82
86
|
type?: ToolType;
|
|
83
|
-
/** Tool-specific configuration */
|
|
84
|
-
config?: Record<string, unknown>;
|
|
85
87
|
/**
|
|
86
88
|
* Array of tool IDs to disable when this tool is active.
|
|
87
89
|
* During pipeline execution, if this tool is enabled, any tools listed
|
|
@@ -147,13 +149,6 @@ export interface WidgetStoreActions {
|
|
|
147
149
|
* @param toolId - Tool ID to remove
|
|
148
150
|
*/
|
|
149
151
|
unregisterTool: (widgetId: string, toolId: string) => void;
|
|
150
|
-
/**
|
|
151
|
-
* Update tool configuration
|
|
152
|
-
* @param widgetId - Widget ID
|
|
153
|
-
* @param toolId - Tool ID
|
|
154
|
-
* @param config - New configuration to merge
|
|
155
|
-
*/
|
|
156
|
-
updateToolConfig: (widgetId: string, toolId: string, config: Record<string, unknown>) => void;
|
|
157
152
|
/**
|
|
158
153
|
* Set tool enabled state
|
|
159
154
|
* @param widgetId - Widget ID
|
|
@@ -161,6 +156,11 @@ export interface WidgetStoreActions {
|
|
|
161
156
|
* @param enabled - Whether tool should be enabled
|
|
162
157
|
*/
|
|
163
158
|
setToolEnabled: (widgetId: string, toolId: string, enabled: boolean) => void;
|
|
159
|
+
/**
|
|
160
|
+
* Trigger pipeline re-execution by bumping the registeredTools reference.
|
|
161
|
+
* @param widgetId - Widget ID
|
|
162
|
+
*/
|
|
163
|
+
triggerToolPipeline: (widgetId: string) => void;
|
|
164
164
|
/**
|
|
165
165
|
* Execute the tool transformation pipeline
|
|
166
166
|
* Supports both synchronous and asynchronous tools
|
|
@@ -7,9 +7,8 @@ import { WidgetStore, WidgetStoreActions } from './types';
|
|
|
7
7
|
*
|
|
8
8
|
* **Performance optimizations:**
|
|
9
9
|
* - `registerTool` skips the store update when structural properties (order, enabled,
|
|
10
|
-
* type, disables) haven't changed — only `fn`
|
|
11
|
-
*
|
|
12
|
-
* pipeline cascades.
|
|
10
|
+
* type, disables) haven't changed — only `fn` is updated via direct mutation,
|
|
11
|
+
* avoiding a new `registeredTools` array reference and WidgetLoader pipeline cascades.
|
|
13
12
|
* - `setToolEnabled` skips the store update when the enabled state is already the
|
|
14
13
|
* requested value.
|
|
15
14
|
* - `executeToolPipeline` / `executeConfigPipeline` skip the final `set()` when
|
|
@@ -3,11 +3,15 @@ export { Row } from './components/row';
|
|
|
3
3
|
export { Pagination } from './components/pagination';
|
|
4
4
|
export { PaginationActions } from './components/pagination-actions';
|
|
5
5
|
export { Table } from './table-ui';
|
|
6
|
-
export { usePagination
|
|
6
|
+
export { usePagination } from './hooks/use-pagination';
|
|
7
|
+
export { useSort } from './hooks/use-sort';
|
|
8
|
+
export { useSelection } from './hooks/use-selection';
|
|
7
9
|
export { tableConfig, tableDownloadConfig } from './config';
|
|
8
10
|
export { TableSkeleton } from './skeleton';
|
|
9
11
|
export { sanitizeTableRow, sanitizeTableData } from './serializer';
|
|
10
12
|
export { getCellValue, compareValues, sortData, paginateData } from './helpers';
|
|
11
13
|
export { styles as tableStyles } from './style';
|
|
12
14
|
export type { TableUIProps, TableColumn, TableRow, TableWidgetData, TablePaginationState, SortDirection, SortState, Mode, TableWidgetConfig, TableWidgetState, TableDownloadConfig, TableProps, CellHeaderProps, RowProps, PaginationProps, PaginationActionsProps, } from './types';
|
|
13
|
-
export type { UsePaginationResult
|
|
15
|
+
export type { UsePaginationResult } from './hooks/use-pagination';
|
|
16
|
+
export type { UseSortResult } from './hooks/use-sort';
|
|
17
|
+
export type { UseSelectionOptions, UseSelectionResult, } from './hooks/use-selection';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as l } from "react/compiler-runtime";
|
|
2
2
|
import { useRef as c, useEffect as i } from "react";
|
|
3
|
-
import { w as m } from "./widget-store-
|
|
3
|
+
import { w as m } from "./widget-store-Bw5zRUGg.js";
|
|
4
4
|
function R(t) {
|
|
5
5
|
const e = l(4), n = c(null), s = c(null);
|
|
6
6
|
let o, r;
|
|
@@ -19,4 +19,4 @@ function R(t) {
|
|
|
19
19
|
export {
|
|
20
20
|
R as u
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=use-widget-ref-
|
|
22
|
+
//# sourceMappingURL=use-widget-ref-Ddr_SlJJ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-widget-ref-
|
|
1
|
+
{"version":3,"file":"use-widget-ref-Ddr_SlJJ.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;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as i } from "react/compiler-runtime";
|
|
2
|
-
import { u as m } from "./widget-store-
|
|
2
|
+
import { u as m } from "./widget-store-Bw5zRUGg.js";
|
|
3
3
|
import { useShallow as s } from "zustand/shallow";
|
|
4
4
|
function a(r, e) {
|
|
5
5
|
const o = i(3);
|
|
@@ -9,4 +9,4 @@ function a(r, e) {
|
|
|
9
9
|
export {
|
|
10
10
|
a as u
|
|
11
11
|
};
|
|
12
|
-
//# sourceMappingURL=use-widget-selector-
|
|
12
|
+
//# sourceMappingURL=use-widget-selector-DFl2hW0R.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-widget-selector-
|
|
1
|
+
{"version":3,"file":"use-widget-selector-DFl2hW0R.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;"}
|