@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.
Files changed (116) hide show
  1. package/dist/{download-config-Dqu78h2a.js → download-config-DemuQ3Jm.js} +9 -10
  2. package/dist/{download-config-Dqu78h2a.js.map → download-config-DemuQ3Jm.js.map} +1 -1
  3. package/dist/error-Cj8eUMrl.js +40 -0
  4. package/dist/error-Cj8eUMrl.js.map +1 -0
  5. package/dist/no-data-DkIt7Qt1.js +61 -0
  6. package/dist/no-data-DkIt7Qt1.js.map +1 -0
  7. package/dist/row-D4VOhcNI.js +34 -0
  8. package/dist/row-D4VOhcNI.js.map +1 -0
  9. package/dist/series-Bola3CmD.js +90 -0
  10. package/dist/series-Bola3CmD.js.map +1 -0
  11. package/dist/types/widgets/category/style.d.ts +1 -0
  12. package/dist/types/widgets/echart/shared-resize-observer.d.ts +12 -0
  13. package/dist/types/widgets/stores/index.d.ts +2 -1
  14. package/dist/types/widgets/stores/use-widget-selector.d.ts +35 -0
  15. package/dist/types/widgets/stores/widget-store-performance.test.d.ts +1 -0
  16. package/dist/types/widgets/stores/widget-store.d.ts +49 -27
  17. package/dist/types/widgets/table/types.d.ts +1 -1
  18. package/dist/use-widget-ref-BFazQvJK.js +22 -0
  19. package/dist/use-widget-ref-BFazQvJK.js.map +1 -0
  20. package/dist/use-widget-selector-DqRmWQ1K.js +12 -0
  21. package/dist/use-widget-selector-DqRmWQ1K.js.map +1 -0
  22. package/dist/widget-store-CIrb9RKP.js +263 -0
  23. package/dist/widget-store-CIrb9RKP.js.map +1 -0
  24. package/dist/widgets/actions.js +783 -817
  25. package/dist/widgets/actions.js.map +1 -1
  26. package/dist/widgets/bar.js +2 -2
  27. package/dist/widgets/category.js +259 -258
  28. package/dist/widgets/category.js.map +1 -1
  29. package/dist/widgets/echart.js +109 -99
  30. package/dist/widgets/echart.js.map +1 -1
  31. package/dist/widgets/error.js +1 -1
  32. package/dist/widgets/formula.js +71 -63
  33. package/dist/widgets/formula.js.map +1 -1
  34. package/dist/widgets/histogram.js +7 -8
  35. package/dist/widgets/histogram.js.map +1 -1
  36. package/dist/widgets/loader.js +53 -60
  37. package/dist/widgets/loader.js.map +1 -1
  38. package/dist/widgets/markdown.js +51 -50
  39. package/dist/widgets/markdown.js.map +1 -1
  40. package/dist/widgets/no-data.js +1 -1
  41. package/dist/widgets/pie.js +2 -2
  42. package/dist/widgets/range.js +146 -144
  43. package/dist/widgets/range.js.map +1 -1
  44. package/dist/widgets/scatterplot.js +2 -2
  45. package/dist/widgets/skeleton-loader.js +18 -17
  46. package/dist/widgets/skeleton-loader.js.map +1 -1
  47. package/dist/widgets/spread.js +110 -94
  48. package/dist/widgets/spread.js.map +1 -1
  49. package/dist/widgets/stores.js +5 -2
  50. package/dist/widgets/stores.js.map +1 -1
  51. package/dist/widgets/subheader.js +29 -29
  52. package/dist/widgets/subheader.js.map +1 -1
  53. package/dist/widgets/table.js +422 -436
  54. package/dist/widgets/table.js.map +1 -1
  55. package/dist/widgets/timeseries.js +2 -2
  56. package/dist/widgets/utils.js +1 -1
  57. package/dist/widgets/wrapper.js +156 -158
  58. package/dist/widgets/wrapper.js.map +1 -1
  59. package/dist/widgets.js +4 -4
  60. package/package.json +1 -1
  61. package/src/hooks/use-widget-ref.ts +3 -4
  62. package/src/widgets/actions/brush-toggle/brush-toggle.tsx +18 -32
  63. package/src/widgets/actions/change-column/change-column.tsx +15 -15
  64. package/src/widgets/actions/change-column/sortable-column-item.tsx +3 -1
  65. package/src/widgets/actions/download/download.tsx +4 -3
  66. package/src/widgets/actions/fullscreen/fullscreen.tsx +7 -11
  67. package/src/widgets/actions/lock-selection/lock-selection.tsx +12 -15
  68. package/src/widgets/actions/relative-data/relative-data.tsx +22 -26
  69. package/src/widgets/actions/searcher/searcher-toggle.tsx +11 -12
  70. package/src/widgets/actions/searcher/searcher.tsx +20 -21
  71. package/src/widgets/actions/stack-toggle/stack-toggle.tsx +15 -21
  72. package/src/widgets/actions/zoom-toggle/zoom-toggle.tsx +27 -43
  73. package/src/widgets/category/category-ui.tsx +30 -31
  74. package/src/widgets/category/style.ts +1 -0
  75. package/src/widgets/echart/echart-ui.test.tsx +20 -16
  76. package/src/widgets/echart/echart-ui.tsx +6 -12
  77. package/src/widgets/echart/echart.tsx +13 -27
  78. package/src/widgets/echart/shared-resize-observer.ts +45 -0
  79. package/src/widgets/error/error.tsx +7 -9
  80. package/src/widgets/formula/components/prefix.tsx +4 -6
  81. package/src/widgets/formula/components/row.tsx +4 -4
  82. package/src/widgets/formula/components/series.tsx +4 -6
  83. package/src/widgets/formula/components/suffix.tsx +4 -6
  84. package/src/widgets/formula/components/value.tsx +9 -16
  85. package/src/widgets/loader/loader.tsx +31 -44
  86. package/src/widgets/markdown/markdown.tsx +4 -7
  87. package/src/widgets/no-data/no-data.tsx +7 -10
  88. package/src/widgets/range/components/range-item.tsx +20 -18
  89. package/src/widgets/skeleton-loader/skeleton-loader.tsx +2 -5
  90. package/src/widgets/spread/components/max-value.tsx +14 -16
  91. package/src/widgets/spread/components/min-value.tsx +14 -16
  92. package/src/widgets/stores/index.ts +2 -1
  93. package/src/widgets/stores/use-widget-selector.ts +47 -0
  94. package/src/widgets/stores/widget-store-performance.test.ts +750 -0
  95. package/src/widgets/stores/widget-store.test.ts +81 -0
  96. package/src/widgets/stores/widget-store.ts +225 -44
  97. package/src/widgets/subheader/subheader.tsx +11 -3
  98. package/src/widgets/table/config.ts +0 -1
  99. package/src/widgets/table/hooks/use-pagination.ts +28 -52
  100. package/src/widgets/table/hooks/use-selection.ts +20 -24
  101. package/src/widgets/table/hooks/use-sort.ts +22 -39
  102. package/src/widgets/table/types.ts +1 -1
  103. package/src/widgets/wrapper/wrapper-ui.tsx +12 -13
  104. package/src/widgets/wrapper/wrapper.tsx +4 -6
  105. package/dist/error-CEkRPccv.js +0 -39
  106. package/dist/error-CEkRPccv.js.map +0 -1
  107. package/dist/no-data-hR3KcJ-_.js +0 -60
  108. package/dist/no-data-hR3KcJ-_.js.map +0 -1
  109. package/dist/row-DTCV0Ocm.js +0 -35
  110. package/dist/row-DTCV0Ocm.js.map +0 -1
  111. package/dist/series-CYNOu2Ju.js +0 -91
  112. package/dist/series-CYNOu2Ju.js.map +0 -1
  113. package/dist/use-widget-ref-wtFLDFCD.js +0 -25
  114. package/dist/use-widget-ref-wtFLDFCD.js.map +0 -1
  115. package/dist/widget-store-CzDt8oSK.js +0 -163
  116. package/dist/widget-store-CzDt8oSK.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useMemo } from 'react'
2
2
  import type { TableRow, TableWidgetState } from '../types'
3
- import { useWidgetStore } from '../../stores/widget-store'
4
- import { useShallow } from 'zustand/shallow'
3
+ import { widgetStoreActions } from '../../stores/widget-store'
4
+ import { useWidgetSelector } from '../../stores/use-widget-selector'
5
5
 
6
6
  export interface UseSelectionOptions {
7
7
  /** Callback when selection changes */
@@ -48,14 +48,10 @@ export function useSelection(
48
48
  ): UseSelectionResult {
49
49
  const { onSelectionChange } = options ?? {}
50
50
 
51
- // Get store actions and state
52
- const setWidget = useWidgetStore((state) => state.setWidget)
53
- const getWidget = useWidgetStore((state) => state.getWidget)
54
- const selected = useWidgetStore(
55
- useShallow((state) => {
56
- const widget = state.widgets[widgetId] as TableWidgetState | undefined
57
- return widget?.selected
58
- }),
51
+ // Get store state
52
+ const selected = useWidgetSelector(
53
+ widgetId,
54
+ (w) => (w as TableWidgetState | undefined)?.selected,
59
55
  )
60
56
 
61
57
  // Use store values with fallback to empty array
@@ -91,14 +87,14 @@ export function useSelection(
91
87
  // Toggle selection of a single row
92
88
  const toggleRow = useCallback(
93
89
  (id: string | number) => {
94
- const widget = getWidget<TableWidgetState>(widgetId)
90
+ const widget = widgetStoreActions.getWidget<TableWidgetState>(widgetId)
95
91
  const currentSelected = widget?.selected ?? []
96
92
 
97
93
  const newSelected = currentSelected.includes(id)
98
94
  ? currentSelected.filter((s) => s !== id)
99
95
  : [...currentSelected, id]
100
96
 
101
- setWidget<TableWidgetState>(widgetId, {
97
+ widgetStoreActions.setWidget<TableWidgetState>(widgetId, {
102
98
  selected: newSelected,
103
99
  })
104
100
 
@@ -106,13 +102,13 @@ export function useSelection(
106
102
  onSelectionChange(newSelected)
107
103
  }
108
104
  },
109
- [getWidget, setWidget, widgetId, onSelectionChange],
105
+ [widgetId, onSelectionChange],
110
106
  )
111
107
 
112
108
  // Toggle selection of all provided rows
113
109
  const toggleAll = useCallback(
114
110
  (rows: TableRow[]) => {
115
- const widget = getWidget<TableWidgetState>(widgetId)
111
+ const widget = widgetStoreActions.getWidget<TableWidgetState>(widgetId)
116
112
  const currentSelected = widget?.selected ?? []
117
113
 
118
114
  const rowIds = rows.map((row) => row.id)
@@ -122,7 +118,7 @@ export function useSelection(
122
118
  ? currentSelected.filter((id) => !rowIds.includes(id))
123
119
  : [...new Set([...currentSelected, ...rowIds])]
124
120
 
125
- setWidget<TableWidgetState>(widgetId, {
121
+ widgetStoreActions.setWidget<TableWidgetState>(widgetId, {
126
122
  selected: newSelected,
127
123
  })
128
124
 
@@ -130,18 +126,18 @@ export function useSelection(
130
126
  onSelectionChange(newSelected)
131
127
  }
132
128
  },
133
- [getWidget, setWidget, widgetId, onSelectionChange],
129
+ [widgetId, onSelectionChange],
134
130
  )
135
131
 
136
132
  // Select specific rows
137
133
  const selectRows = useCallback(
138
134
  (ids: (string | number)[]) => {
139
- const widget = getWidget<TableWidgetState>(widgetId)
135
+ const widget = widgetStoreActions.getWidget<TableWidgetState>(widgetId)
140
136
  const currentSelected = widget?.selected ?? []
141
137
 
142
138
  const newSelected = [...new Set([...currentSelected, ...ids])]
143
139
 
144
- setWidget<TableWidgetState>(widgetId, {
140
+ widgetStoreActions.setWidget<TableWidgetState>(widgetId, {
145
141
  selected: newSelected,
146
142
  })
147
143
 
@@ -149,18 +145,18 @@ export function useSelection(
149
145
  onSelectionChange(newSelected)
150
146
  }
151
147
  },
152
- [getWidget, setWidget, widgetId, onSelectionChange],
148
+ [widgetId, onSelectionChange],
153
149
  )
154
150
 
155
151
  // Deselect specific rows
156
152
  const deselectRows = useCallback(
157
153
  (ids: (string | number)[]) => {
158
- const widget = getWidget<TableWidgetState>(widgetId)
154
+ const widget = widgetStoreActions.getWidget<TableWidgetState>(widgetId)
159
155
  const currentSelected = widget?.selected ?? []
160
156
 
161
157
  const newSelected = currentSelected.filter((id) => !ids.includes(id))
162
158
 
163
- setWidget<TableWidgetState>(widgetId, {
159
+ widgetStoreActions.setWidget<TableWidgetState>(widgetId, {
164
160
  selected: newSelected,
165
161
  })
166
162
 
@@ -168,21 +164,21 @@ export function useSelection(
168
164
  onSelectionChange(newSelected)
169
165
  }
170
166
  },
171
- [getWidget, setWidget, widgetId, onSelectionChange],
167
+ [widgetId, onSelectionChange],
172
168
  )
173
169
 
174
170
  // Clear all selections
175
171
  const clearSelection = useCallback(() => {
176
172
  const newSelected: (string | number)[] = []
177
173
 
178
- setWidget<TableWidgetState>(widgetId, {
174
+ widgetStoreActions.setWidget<TableWidgetState>(widgetId, {
179
175
  selected: newSelected,
180
176
  })
181
177
 
182
178
  if (onSelectionChange) {
183
179
  onSelectionChange(newSelected)
184
180
  }
185
- }, [setWidget, widgetId, onSelectionChange])
181
+ }, [widgetId, onSelectionChange])
186
182
 
187
183
  return {
188
184
  selectedIds,
@@ -6,8 +6,8 @@ import type {
6
6
  TableWidgetState,
7
7
  } from '../types'
8
8
  import { sortData } from '../helpers'
9
- import { useWidgetStore } from '../../stores/widget-store'
10
- import { useShallow } from 'zustand/shallow'
9
+ import { widgetStoreActions } from '../../stores/widget-store'
10
+ import { useWidgetSelector } from '../../stores/use-widget-selector'
11
11
  import { DEFAULT_COLUMN_ID, DEFAULT_DIRECTION } from '../config'
12
12
 
13
13
  export interface UseSortResult<T> extends SortState {
@@ -43,42 +43,25 @@ export function useSort<T extends TableRow>(
43
43
  widgetId: string,
44
44
  data: T[],
45
45
  ): UseSortResult<T> {
46
- // Get store actions and state
47
- const setWidget = useWidgetStore((state) => state.setWidget)
48
- const getWidget = useWidgetStore((state) => state.getWidget)
49
- const sortEnabled = useWidgetStore(
50
- useShallow(
51
- (state) =>
52
- !!(state.widgets[widgetId] as TableWidgetState | undefined)?.sort,
53
- ),
54
- )
55
- const columnId = useWidgetStore(
56
- useShallow(
57
- (state) =>
58
- (state.widgets[widgetId] as TableWidgetState | undefined)?.sort
59
- ?.columnId ?? DEFAULT_COLUMN_ID,
60
- ),
61
- )
62
- const direction = useWidgetStore(
63
- useShallow(
64
- (state) =>
65
- (state.widgets[widgetId] as TableWidgetState | undefined)?.sort
66
- ?.direction ?? DEFAULT_DIRECTION,
67
- ),
68
- )
69
-
70
- const mode = useWidgetStore(
71
- useShallow((state) => {
72
- const widget = state.widgets[widgetId] as TableWidgetState | undefined
73
- return widget?.mode
74
- }),
46
+ // Get store state
47
+ const { sortEnabled, columnId, direction, mode } = useWidgetSelector(
48
+ widgetId,
49
+ (w) => {
50
+ const widget = w as TableWidgetState | undefined
51
+ return {
52
+ sortEnabled: !!widget?.sort,
53
+ columnId: widget?.sort?.columnId ?? DEFAULT_COLUMN_ID,
54
+ direction: widget?.sort?.direction ?? DEFAULT_DIRECTION,
55
+ mode: widget?.mode,
56
+ }
57
+ },
75
58
  )
76
59
 
77
60
  // Toggle sort on a column
78
61
  const toggleSort = useCallback(
79
62
  (toggleColumnId: string) => {
80
63
  // Read current state directly from store to avoid stale closures
81
- const widget = getWidget<TableWidgetState>(widgetId)
64
+ const widget = widgetStoreActions.getWidget<TableWidgetState>(widgetId)
82
65
  const currentColumnId = widget?.sort?.columnId ?? DEFAULT_COLUMN_ID
83
66
  const currentDirection = widget?.sort?.direction ?? DEFAULT_DIRECTION
84
67
 
@@ -89,42 +72,42 @@ export function useSort<T extends TableRow>(
89
72
  newDirection = currentDirection === 'asc' ? 'desc' : 'asc'
90
73
  }
91
74
 
92
- setWidget<TableWidgetState>(widgetId, {
75
+ widgetStoreActions.setWidget<TableWidgetState>(widgetId, {
93
76
  sort: {
94
77
  columnId: toggleColumnId,
95
78
  direction: newDirection,
96
79
  },
97
80
  })
98
81
  },
99
- [getWidget, setWidget, widgetId],
82
+ [widgetId],
100
83
  )
101
84
 
102
85
  // Set sort state directly
103
86
  const setSort = useCallback(
104
87
  (newColumnId: string | null, newDirection: SortDirection) => {
105
- setWidget<TableWidgetState>(widgetId, {
88
+ widgetStoreActions.setWidget<TableWidgetState>(widgetId, {
106
89
  sort: {
107
90
  columnId: newColumnId,
108
91
  direction: newDirection,
109
92
  },
110
93
  })
111
94
  },
112
- [setWidget, widgetId],
95
+ [widgetId],
113
96
  )
114
97
 
115
98
  // Clear sort
116
99
  const clearSort = useCallback(() => {
117
- const widget = getWidget<TableWidgetState>(widgetId)
100
+ const widget = widgetStoreActions.getWidget<TableWidgetState>(widgetId)
118
101
  if (!widget?.sort) return
119
102
 
120
- setWidget<TableWidgetState>(widgetId, {
103
+ widgetStoreActions.setWidget<TableWidgetState>(widgetId, {
121
104
  sort: {
122
105
  ...widget.sort,
123
106
  columnId: null,
124
107
  direction: 'asc',
125
108
  },
126
109
  })
127
- }, [setWidget, getWidget, widgetId])
110
+ }, [widgetId])
128
111
 
129
112
  // Sorted data for local mode
130
113
  const sortedData = useMemo(() => {
@@ -84,7 +84,7 @@ export interface TableWidgetConfig {
84
84
  /** Enable row selection with checkboxes */
85
85
  selectable?: boolean
86
86
  /** Currently selected row IDs */
87
- selected: (string | number)[]
87
+ selected?: (string | number)[]
88
88
  /** Pagination and sort mode: local (client-side) or remote (server-side) */
89
89
  mode: Mode
90
90
  /** Pagination configuration */
@@ -9,8 +9,7 @@ import { Title } from './components/title'
9
9
  import type { WrapperState, WrapperUIProps } from './types'
10
10
  import { Options } from './components/options'
11
11
  import { Actions } from './components/actions'
12
- import { useWidgetStore } from '../stores/widget-store'
13
- import { useShallow } from 'zustand/shallow'
12
+ import { useWidgetSelector } from '../stores/use-widget-selector'
14
13
 
15
14
  const EMPTY_ACTIONS: NonNullable<WrapperUIProps['actions']> = []
16
15
  const EMPTY_OPTIONS: NonNullable<WrapperUIProps['options']> = []
@@ -38,17 +37,17 @@ export function WrapperUI({
38
37
  options = EMPTY_OPTIONS,
39
38
  onChangeCollapsed,
40
39
  }: WrapperUIProps) {
41
- const title = useWidgetStore(
42
- useShallow((state) => state.getWidget<WrapperState>(id)?.title),
43
- )
44
- const collapsed = useWidgetStore(
45
- useShallow((state) => state.getWidget<WrapperState>(id)?.collapsed),
46
- )
47
- const disabled = useWidgetStore(
48
- useShallow((state) => state.getWidget<WrapperState>(id)?.disabled),
49
- )
50
- const isFetching = useWidgetStore(
51
- useShallow((state) => state.getWidget<WrapperState>(id)?.isFetching),
40
+ // Single consolidated subscription instead of 4 separate ones.
41
+ const { title, collapsed, disabled, isFetching } = useWidgetSelector(
42
+ id,
43
+ (w) => {
44
+ return {
45
+ title: (w as WrapperState | undefined)?.title,
46
+ collapsed: (w as WrapperState | undefined)?.collapsed,
47
+ disabled: (w as WrapperState | undefined)?.disabled,
48
+ isFetching: w?.isFetching,
49
+ }
50
+ },
52
51
  )
53
52
 
54
53
  return (
@@ -1,6 +1,6 @@
1
1
  import type { WrapperProps, WrapperState } from './types'
2
2
  import { WrapperUI } from './wrapper-ui'
3
- import { useWidgetStore } from '../stores/widget-store'
3
+ import { widgetStoreActions } from '../stores/widget-store'
4
4
  import { useLayoutEffect } from 'react'
5
5
 
6
6
  /**
@@ -29,22 +29,20 @@ export function WidgetWrapper({
29
29
  children,
30
30
  onChangeCollapsed,
31
31
  }: WrapperProps) {
32
- const setWidget = useWidgetStore((state) => state.setWidget)
33
-
34
32
  useLayoutEffect(() => {
35
- setWidget<WrapperState>(id, {
33
+ widgetStoreActions.setWidget<WrapperState>(id, {
36
34
  collapsed: defaultCollapsed,
37
35
  disabled,
38
36
  title,
39
37
  })
40
- }, [defaultCollapsed, disabled, title, id, setWidget])
38
+ }, [defaultCollapsed, disabled, title, id])
41
39
 
42
40
  const handleChangeCollapsed = (
43
41
  event: React.SyntheticEvent<Element, Event>,
44
42
  expanded: boolean,
45
43
  ) => {
46
44
  onChangeCollapsed?.(event, expanded)
47
- setWidget<WrapperState>(id, { collapsed: !expanded })
45
+ widgetStoreActions.setWidget<WrapperState>(id, { collapsed: !expanded })
48
46
  }
49
47
 
50
48
  return (
@@ -1,39 +0,0 @@
1
- import { jsx as x, jsxs as A } from "react/jsx-runtime";
2
- import { c as W } from "react/compiler-runtime";
3
- import { AlertTitle as j, Alert as y } from "@mui/material";
4
- import { u as g } from "./widget-store-CzDt8oSK.js";
5
- import { useShallow as f } from "zustand/shallow";
6
- function T(m) {
7
- const e = W(11), {
8
- id: r,
9
- children: a,
10
- title: h,
11
- description: p
12
- } = m;
13
- let o;
14
- e[0] !== r ? (o = (t) => t.widgets[r]?.isLoading, e[0] = r, e[1] = o) : o = e[1];
15
- const u = g(f(o));
16
- let s;
17
- e[2] !== r ? (s = (t) => t.widgets[r]?.isFetching, e[2] = r, e[3] = s) : s = e[3];
18
- const w = g(f(s));
19
- let l;
20
- e[4] !== r ? (l = (t) => t.widgets[r]?.error, e[4] = r, e[5] = l) : l = e[5];
21
- const c = g(f(l));
22
- if (u || w)
23
- return a;
24
- if (c) {
25
- const t = h ?? c.title ?? "Error", d = p ?? c.message ?? "An error occurred while loading the widget. Please try again.";
26
- let i;
27
- e[6] !== t ? (i = /* @__PURE__ */ x(j, { children: t }), e[6] = t, e[7] = i) : i = e[7];
28
- let n;
29
- return e[8] !== d || e[9] !== i ? (n = /* @__PURE__ */ A(y, { severity: "error", children: [
30
- i,
31
- d
32
- ] }), e[8] = d, e[9] = i, e[10] = n) : n = e[10], n;
33
- }
34
- return a;
35
- }
36
- export {
37
- T as W
38
- };
39
- //# sourceMappingURL=error-CEkRPccv.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-CEkRPccv.js","sources":["../src/widgets/error/error.tsx"],"sourcesContent":["import { Alert, AlertTitle } from '@mui/material'\nimport { useWidgetStore } from '../stores/widget-store'\nimport { useShallow } from 'zustand/shallow'\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 const isLoading = useWidgetStore(\n useShallow((state) => state.widgets[id]?.isLoading),\n )\n const isFetching = useWidgetStore(\n useShallow((state) => state.widgets[id]?.isFetching),\n )\n const error = useWidgetStore(useShallow((state) => state.widgets[id]?.error))\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","t1","state","widgets","isLoading","useWidgetStore","useShallow","t2","state_0","isFetching","t3","state_1","error","errorTitle","errorMessage","message","t4","AlertTitle","t5","jsxs","Alert"],"mappings":";;;;;AAeO,SAAAA,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA,GAAqB;AAAA,IAAAC,IAAAA;AAAAA,IAAAC,UAAAA;AAAAA,IAAAC,OAAAC;AAAAA,IAAAC,aAAAA;AAAAA,EAAAA,IAAAP;AAKT,MAAAQ;AAAA,EAAAP,SAAAE,KAEJK,IAAAC,CAAAA,MAAWA,EAAKC,QAASP,CAAE,GAAYQ,WAAAV,OAAAE,GAAAF,OAAAO,KAAAA,IAAAP,EAAA,CAAA;AADpD,QAAAU,IAAkBC,EAChBC,EAAWL,CAAuC,CACpD;AAAC,MAAAM;AAAA,EAAAb,SAAAE,KAEYW,IAAAC,CAAAA,MAAWN,EAAKC,QAASP,CAAE,GAAaa,YAAAf,OAAAE,GAAAF,OAAAa,KAAAA,IAAAb,EAAA,CAAA;AADrD,QAAAe,IAAmBJ,EACjBC,EAAWC,CAAwC,CACrD;AAAC,MAAAG;AAAA,EAAAhB,SAAAE,KACuCc,IAAAC,CAAAA,MAAWT,EAAKC,QAASP,CAAE,GAAQgB,OAAAlB,OAAAE,GAAAF,OAAAgB,KAAAA,IAAAhB,EAAA,CAAA;AAA3E,QAAAkB,IAAcP,EAAeC,EAAWI,CAAmC,CAAC;AAG5E,MAAIN,KAAAK;AAAuB,WAClBZ;AAIT,MAAIe,GAAK;AACP,UAAAC,IAAmBd,KAAaa,EAAKd,SAAlB,SACnBgB,IACEd,KACAY,EAAKG,WADL;AAE+D,QAAAC;AAAA,IAAAtB,SAAAmB,KAI7DG,sBAACC,kBAAuB,GAAavB,OAAAmB,GAAAnB,OAAAsB,KAAAA,IAAAtB,EAAA,CAAA;AAAA,QAAAwB;AAAA,WAAAxB,EAAA,CAAA,MAAAoB,KAAApB,SAAAsB,KADvCE,IAAA,gBAAAC,EAACC,GAAA,EAAe,UAAA,SACdJ,UAAAA;AAAAA,MAAAA;AAAAA,MACCF;AAAAA,IAAAA,GACH,GAAQpB,OAAAoB,GAAApB,OAAAsB,GAAAtB,QAAAwB,KAAAA,IAAAxB,EAAA,EAAA,GAHRwB;AAAAA,EAGQ;AAEX,SAGMrB;AAAQ;"}
@@ -1,60 +0,0 @@
1
- import { jsx as h, jsxs as A } from "react/jsx-runtime";
2
- import { c as T } from "react/compiler-runtime";
3
- import { Typography as x, Box as E } from "@mui/material";
4
- import { useShallow as c } from "zustand/shallow";
5
- import { u as p } from "./widget-store-CzDt8oSK.js";
6
- const W = {
7
- root: {
8
- display: "flex",
9
- flexDirection: "column",
10
- gap: 1,
11
- // 8px
12
- paddingTop: 1,
13
- // 8px
14
- paddingBottom: 2,
15
- // 16px
16
- paddingX: 2,
17
- // 16px
18
- width: "100%",
19
- minHeight: "100%"
20
- }
21
- };
22
- function S(r) {
23
- const t = T(13), {
24
- id: i,
25
- children: u,
26
- title: y,
27
- description: g,
28
- isEmpty: m
29
- } = r, f = y === void 0 ? "No data available" : y, d = g === void 0 ? "There are no results for the combination of filters applied to your data. Try tweaking your filters, or zoom and pan the map to adjust filters" : g, v = m === void 0 ? k : m;
30
- let n;
31
- t[0] !== i ? (n = (e) => e.widgets[i]?.isLoading, t[0] = i, t[1] = n) : n = t[1];
32
- const w = p(c(n));
33
- let s;
34
- t[2] !== i ? (s = (e) => e.widgets[i]?.isFetching, t[2] = i, t[3] = s) : s = t[3];
35
- const b = p(c(s));
36
- let l;
37
- t[4] !== i ? (l = (e) => e.widgets[i]?.data, t[4] = i, t[5] = l) : l = t[5];
38
- const j = p(c(l));
39
- if (w || b)
40
- return u;
41
- if (v(j)) {
42
- let e;
43
- t[6] !== f ? (e = /* @__PURE__ */ h(x, { variant: "body2", color: "text.primary", children: f }), t[6] = f, t[7] = e) : e = t[7];
44
- let o;
45
- t[8] !== d ? (o = /* @__PURE__ */ h(x, { variant: "caption", color: "text.secondary", children: d }), t[8] = d, t[9] = o) : o = t[9];
46
- let a;
47
- return t[10] !== e || t[11] !== o ? (a = /* @__PURE__ */ A(E, { sx: W.root, children: [
48
- e,
49
- o
50
- ] }), t[10] = e, t[11] = o, t[12] = a) : a = t[12], a;
51
- }
52
- return u;
53
- }
54
- function k(r) {
55
- return r == null ? !0 : Array.isArray(r) ? !!(r.length === 0 || r.every((t) => Array.isArray(t) && t.length === 0)) : typeof r == "object" ? Object.keys(r).length === 0 : !1;
56
- }
57
- export {
58
- S as W
59
- };
60
- //# sourceMappingURL=no-data-hR3KcJ-_.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"no-data-hR3KcJ-_.js","sources":["../src/widgets/no-data/style.ts","../src/widgets/no-data/no-data.tsx"],"sourcesContent":["import type { SxProps, Theme } from '@mui/material'\n\n/**\n * Styles for NoData component matching Figma design specifications\n * Design reference: node 5781-11028\n */\nexport const styles: Record<string, SxProps<Theme>> = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 1, // 8px\n paddingTop: 1, // 8px\n paddingBottom: 2, // 16px\n paddingX: 2, // 16px\n width: '100%',\n minHeight: '100%',\n },\n}\n","import { Box, Typography } from '@mui/material'\nimport { useShallow } from 'zustand/shallow'\nimport { useWidgetStore } from '../stores/widget-store'\nimport type { WidgetNoDataProps } from './types'\nimport { styles } from './style'\n\n/**\n * NoData wrapper component that displays empty state UI when widget has no data\n *\n * Integrates with widget store to check loading/fetching state and data availability.\n * Works in conjunction with SkeletonLoader for complete loading/empty state handling.\n *\n * @example Basic usage\n * ```tsx\n * <NoData id=\"my-widget\">\n * <WidgetContent id=\"my-widget\" />\n * </NoData>\n * ```\n *\n * @example With SkeletonLoader\n * ```tsx\n * <SkeletonLoader id=\"my-widget\" Skeleton={MySkeleton}>\n * <NoData id=\"my-widget\">\n * <WidgetContent id=\"my-widget\" />\n * </NoData>\n * </SkeletonLoader>\n * ```\n *\n * @example With custom messages\n * ```tsx\n * <NoData\n * id=\"my-widget\"\n * title=\"No results found\"\n * description=\"Try adjusting your filters\"\n * >\n * <WidgetContent id=\"my-widget\" />\n * </NoData>\n * ```\n */\nexport function WidgetNoData({\n id,\n children,\n title = 'No data available',\n description = 'There are no results for the combination of filters applied to your data. Try tweaking your filters, or zoom and pan the map to adjust filters',\n isEmpty = defaultIsEmpty,\n}: WidgetNoDataProps) {\n // Subscribe to widget store with selective subscription for optimal performance\n const isLoading = useWidgetStore(\n useShallow((state) => state.widgets[id]?.isLoading),\n )\n const isFetching = useWidgetStore(\n useShallow((state) => state.widgets[id]?.isFetching),\n )\n const data = useWidgetStore(useShallow((state) => state.widgets[id]?.data))\n\n // If loading or fetching, show children\n // SkeletonLoader handles loading state, this allows proper composition\n if (isLoading || isFetching) {\n return children\n }\n\n // Check if data is empty\n if (isEmpty(data)) {\n return (\n <Box sx={styles.root}>\n <Typography variant='body2' color='text.primary'>\n {title}\n </Typography>\n <Typography variant='caption' color='text.secondary'>\n {description}\n </Typography>\n </Box>\n )\n }\n\n // Data exists, render children\n return children\n}\n\n/**\n * Default function to determine if data is empty\n * Handles various data structures commonly used in widgets\n */\nfunction defaultIsEmpty(data: unknown): boolean {\n // Null or undefined\n if (data == null) {\n return true\n }\n\n // Arrays (most common case)\n if (Array.isArray(data)) {\n // Empty array\n if (data.length === 0) {\n return true\n }\n\n // Array of arrays (CategoryWidget pattern: [[],[]])\n // Check if all inner arrays are empty\n if (data.every((item) => Array.isArray(item) && item.length === 0)) {\n return true\n }\n\n return false\n }\n\n // Objects\n if (typeof data === 'object') {\n return Object.keys(data).length === 0\n }\n\n // Primitives (numbers, strings, booleans) are considered valid data\n return false\n}\n"],"names":["styles","root","display","flexDirection","gap","paddingTop","paddingBottom","paddingX","width","minHeight","WidgetNoData","t0","$","_c","id","children","title","t1","description","t2","isEmpty","t3","undefined","defaultIsEmpty","t4","state","widgets","isLoading","useWidgetStore","useShallow","t5","state_0","isFetching","t6","state_1","data","t7","Typography","t8","t9","Box","Array","isArray","length","every","item","Object","keys"],"mappings":";;;;;AAMO,MAAMA,IAAyC;AAAA,EACpDC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,KAAK;AAAA;AAAA,IACLC,YAAY;AAAA;AAAA,IACZC,eAAe;AAAA;AAAA,IACfC,UAAU;AAAA;AAAA,IACVC,OAAO;AAAA,IACPC,WAAW;AAAA,EAAA;AAEf;ACsBO,SAAAC,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA,GAAsB;AAAA,IAAAC,IAAAA;AAAAA,IAAAC,UAAAA;AAAAA,IAAAC,OAAAC;AAAAA,IAAAC,aAAAC;AAAAA,IAAAC,SAAAC;AAAAA,EAAAA,IAAAV,GAG3BK,IAAAC,MAAAK,SAAA,sBAAAL,GACAC,IAAAC,MAAAG,SAAA,mJAAAH,GACAC,IAAAC,MAAAC,SAAAC,IAAAF;AAAwB,MAAAG;AAAA,EA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;AAAAA,EAOM;AAET,SAGMxB;AAAQ;AAOjB,SAASQ,EAAeY,GAAwB;AAE9C,SAAIA,KAAQ,OACH,KAILM,MAAMC,QAAQP,CAAI,IAEhBA,GAAAA,EAAKQ,WAAW,KAMhBR,EAAKS,MAAOC,CAAAA,MAASJ,MAAMC,QAAQG,CAAI,KAAKA,EAAKF,WAAW,CAAC,KAQ/D,OAAOR,KAAS,WACXW,OAAOC,KAAKZ,CAAI,EAAEQ,WAAW,IAI/B;AACT;"}
@@ -1,35 +0,0 @@
1
- import { jsx as d } from "react/jsx-runtime";
2
- import { c as n } from "react/compiler-runtime";
3
- import { Box as c } from "@mui/material";
4
- import { u as m } from "./widget-store-CzDt8oSK.js";
5
- import { useShallow as s } from "zustand/shallow";
6
- const f = {
7
- item: {
8
- '&[data-disabled="true"]': {
9
- color: (t) => t.palette.text.disabled
10
- }
11
- },
12
- row: {
13
- display: "flex",
14
- alignItems: "center",
15
- gap: (t) => t.spacing(1),
16
- "& + &": {
17
- marginTop: (t) => t.spacing(1)
18
- }
19
- }
20
- };
21
- function y(t) {
22
- const e = n(5);
23
- let i;
24
- e[0] !== t.id ? (i = (l) => l.getWidget(t.id)?.data, e[0] = t.id, e[1] = i) : i = e[1];
25
- const o = m(s(i));
26
- let a;
27
- return e[2] !== o || e[3] !== t ? (a = o?.map((l, r) => /* @__PURE__ */ d(c, { sx: f.row, children: typeof t.children == "function" ? t.children({
28
- index: r
29
- }) : t.children }, `row-${r}`)), e[2] = o, e[3] = t, e[4] = a) : a = e[4], a;
30
- }
31
- export {
32
- y as R,
33
- f as s
34
- };
35
- //# sourceMappingURL=row-DTCV0Ocm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"row-DTCV0Ocm.js","sources":["../src/widgets/formula/style.ts","../src/widgets/formula/components/row.tsx"],"sourcesContent":["import type { SxProps, Theme } from '@mui/material'\n\nexport const styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: (theme: Theme) => theme.spacing(2),\n },\n item: {\n '&[data-disabled=\"true\"]': {\n color: (theme: Theme) => theme.palette.text.disabled,\n },\n },\n row: {\n display: 'flex',\n alignItems: 'center',\n gap: (theme: Theme) => theme.spacing(1),\n\n '& + &': {\n marginTop: (theme: Theme) => theme.spacing(1),\n },\n },\n} satisfies Record<string, SxProps<Theme>>\n","import { Box } from '@mui/material'\nimport { styles } from '../style'\nimport type { FormulaWidgetState, RowProps } from '../types'\nimport { useWidgetStore } from '../../stores/widget-store'\nimport { useShallow } from 'zustand/shallow'\n\n/**\n * Iterates over the widget's data items and renders a row for each one using render props.\n */\nexport function Row(props: RowProps) {\n const data = useWidgetStore(\n useShallow((state) => state.getWidget<FormulaWidgetState>(props.id)?.data),\n )\n\n return data?.map((_, index) => {\n return (\n <Box sx={styles.row} key={`row-${index}`}>\n {typeof props.children === 'function'\n ? props.children({ index })\n : props.children}\n </Box>\n )\n })\n}\n"],"names":["styles","item","color","theme","palette","text","disabled","row","display","alignItems","gap","spacing","marginTop","Row","props","$","_c","t0","id","state","getWidget","data","useWidgetStore","useShallow","t1","map","_","index","jsx","Box","children"],"mappings":";;;;;AAEO,MAAMA,IAAS;AAAA,EAMpBC,MAAM;AAAA,IACJ,2BAA2B;AAAA,MACzBC,OAAOA,CAACC,MAAiBA,EAAMC,QAAQC,KAAKC;AAAAA,IAAAA;AAAAA,EAC9C;AAAA,EAEFC,KAAK;AAAA,IACHC,SAAS;AAAA,IACTC,YAAY;AAAA,IACZC,KAAKA,CAACP,MAAiBA,EAAMQ,QAAQ,CAAC;AAAA,IAEtC,SAAS;AAAA,MACPC,WAAWA,CAACT,MAAiBA,EAAMQ,QAAQ,CAAC;AAAA,IAAA;AAAA,EAC9C;AAEJ;ACbO,SAAAE,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA;AAAA,MAAAC;AAAA,EAAAF,EAAA,CAAA,MAAAD,EAAAI,MAEQD,IAAAE,CAAAA,MAAWA,EAAKC,UAA+BN,EAAKI,EAAS,GAACG,MAAAN,EAAA,CAAA,IAAAD,EAAAI,IAAAH,OAAAE,KAAAA,IAAAF,EAAA,CAAA;AAD3E,QAAAM,IAAaC,EACXC,EAAWN,CAA8D,CAC3E;AAAC,MAAAO;AAAA,SAAAT,EAAA,CAAA,MAAAM,KAAAN,SAAAD,KAEMU,IAAAH,GAAII,IAAM,CAAAC,GAAAC,MAEb,gBAAAC,EAACC,GAAA,EAAQ,IAAA7B,EAAMO,KACZ,UAAA,OAAOO,EAAKgB,YAAc,aACvBhB,EAAKgB,SAAU;AAAA,IAAAH,OAAAA;AAAAA,EAAAA,CACF,IAAbb,EAAKgB,YAHe,OAAOH,CAAK,EAItC,CAEH,GAACZ,OAAAM,GAAAN,OAAAD,GAAAC,OAAAS,KAAAA,IAAAT,EAAA,CAAA,GARKS;AAQL;"}
@@ -1,91 +0,0 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import { c as h } from "react/compiler-runtime";
3
- import { u as g } from "./widget-store-CzDt8oSK.js";
4
- import { useShallow as p } from "zustand/shallow";
5
- import { Typography as S, Avatar as b } from "@mui/material";
6
- import { s as P } from "./row-DTCV0Ocm.js";
7
- function y(i) {
8
- const e = h(4);
9
- let t;
10
- return e[0] !== i.TypographyProps || e[1] !== i.children || e[2] !== i.disabled ? (t = /* @__PURE__ */ m(S, { sx: P.item, variant: "h5", fontWeight: "medium", "data-disabled": i.disabled, color: "default", ...i.TypographyProps, children: i.children }), e[0] = i.TypographyProps, e[1] = i.children, e[2] = i.disabled, e[3] = t) : t = e[3], t;
11
- }
12
- function C(i) {
13
- const e = h(10);
14
- let t, r, o;
15
- e[0] !== i ? ({
16
- id: t,
17
- index: o,
18
- ...r
19
- } = i, e[0] = i, e[1] = t, e[2] = r, e[3] = o) : (t = e[1], r = e[2], o = e[3]);
20
- const f = o === void 0 ? 0 : o;
21
- let d;
22
- e[4] !== t || e[5] !== f ? (d = (s) => s.getWidget(t)?.data?.[f]?.prefix, e[4] = t, e[5] = f, e[6] = d) : d = e[6];
23
- const n = g(p(d));
24
- if (!n)
25
- return null;
26
- let l;
27
- return e[7] !== n || e[8] !== r ? (l = /* @__PURE__ */ m(y, { ...r, children: n }), e[7] = n, e[8] = r, e[9] = l) : l = e[9], l;
28
- }
29
- function I(i) {
30
- const e = h(11);
31
- let t, r, o;
32
- e[0] !== i ? ({
33
- id: t,
34
- index: o,
35
- ...r
36
- } = i, e[0] = i, e[1] = t, e[2] = r, e[3] = o) : (t = e[1], r = e[2], o = e[3]);
37
- const f = o === void 0 ? 0 : o;
38
- let d;
39
- e[4] !== t || e[5] !== f ? (d = (a) => a.getWidget(t)?.data?.[f]?.suffix, e[4] = t, e[5] = f, e[6] = d) : d = e[6];
40
- const n = g(p(d));
41
- if (!n)
42
- return null;
43
- let l;
44
- e[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (l = {
45
- color: T
46
- }, e[7] = l) : l = e[7];
47
- let s;
48
- return e[8] !== r || e[9] !== n ? (s = /* @__PURE__ */ m(y, { TypographyProps: l, ...r, children: n }), e[8] = r, e[9] = n, e[10] = s) : s = e[10], s;
49
- }
50
- function T(i) {
51
- return i.palette.text.secondary;
52
- }
53
- function j(i) {
54
- const e = h(13), {
55
- id: t,
56
- index: r
57
- } = i, o = r === void 0 ? 0 : r;
58
- let f;
59
- e[0] !== t || e[1] !== o ? (f = (x) => x.getWidget(t)?.series?.[o], e[0] = t, e[1] = o, e[2] = f) : f = e[2];
60
- const d = g(p(f));
61
- if (!d)
62
- return null;
63
- const {
64
- name: n,
65
- color: l
66
- } = d;
67
- let s;
68
- e[3] !== l ? (s = l && {
69
- color: (x) => x.palette.getContrastText(l)
70
- }, e[3] = l, e[4] = s) : s = e[4];
71
- let a;
72
- e[5] !== l || e[6] !== s ? (a = {
73
- bgcolor: l,
74
- width: 32,
75
- height: 32,
76
- fontSize: "0.875rem",
77
- fontWeight: "medium",
78
- ...s
79
- }, e[5] = l, e[6] = s, e[7] = a) : a = e[7];
80
- let c;
81
- e[8] !== n ? (c = n.charAt(0).toUpperCase(), e[8] = n, e[9] = c) : c = e[9];
82
- let u;
83
- return e[10] !== a || e[11] !== c ? (u = /* @__PURE__ */ m(b, { sx: a, children: c }), e[10] = a, e[11] = c, e[12] = u) : u = e[12], u;
84
- }
85
- export {
86
- y as I,
87
- C as P,
88
- j as S,
89
- I as a
90
- };
91
- //# sourceMappingURL=series-CYNOu2Ju.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"series-CYNOu2Ju.js","sources":["../src/widgets/formula/components/item.tsx","../src/widgets/formula/components/prefix.tsx","../src/widgets/formula/components/suffix.tsx","../src/widgets/formula/components/series.tsx"],"sourcesContent":["import { Typography } from '@mui/material'\nimport type { ItemProps } from '../types'\nimport { styles } from '../style'\n\n/**\n * Base typography wrapper used by formula sub-components (Value, Prefix, Suffix) to render styled text.\n */\nexport function Item(props: ItemProps) {\n return (\n <Typography\n sx={styles.item}\n variant='h5'\n fontWeight='medium'\n data-disabled={props.disabled}\n color='default'\n {...props.TypographyProps}\n >\n {props.children}\n </Typography>\n )\n}\n","import { type FormulaWidgetState, type ValueProps } from '../types'\nimport { useWidgetStore } from '../../stores/widget-store'\nimport { Item } from './item'\nimport { useShallow } from 'zustand/shallow'\n\n/**\n * Renders the prefix content (e.g., currency symbol) before a formula value, if defined in the data item.\n */\nexport function Prefix({ id, index = 0, ...props }: ValueProps) {\n const prefix = useWidgetStore(\n useShallow(\n (state) => state.getWidget<FormulaWidgetState>(id)?.data?.[index]?.prefix,\n ),\n )\n\n if (!prefix) {\n return null\n }\n\n return <Item {...props}>{prefix}</Item>\n}\n","import { type FormulaWidgetState, type ValueProps } from '../types'\nimport { useWidgetStore } from '../../stores/widget-store'\nimport { Item } from './item'\nimport type { Theme } from '@mui/material'\nimport { useShallow } from 'zustand/shallow'\n\n/**\n * Renders the suffix content (e.g., unit label) after a formula value, if defined in the data item.\n */\nexport function Suffix({ id, index = 0, ...props }: ValueProps) {\n const suffix = useWidgetStore(\n useShallow(\n (state) => state.getWidget<FormulaWidgetState>(id)?.data?.[index]?.suffix,\n ),\n )\n\n if (!suffix) {\n return null\n }\n\n return (\n <Item\n TypographyProps={{\n color: (theme: Theme) => theme.palette.text.secondary,\n }}\n {...props}\n >\n {suffix}\n </Item>\n )\n}\n","import { Avatar } from '@mui/material'\nimport type { FormulaWidgetState, ValueProps } from '../types'\nimport { useWidgetStore } from '../../stores/widget-store'\nimport { useShallow } from 'zustand/shallow'\n\n/**\n * Renders a colored avatar badge showing the first letter of the series name for multi-value formula widgets.\n */\nexport function Series({ id, index = 0 }: Pick<ValueProps, 'id' | 'index'>) {\n const serie = useWidgetStore(\n useShallow(\n (state) => state.getWidget<FormulaWidgetState>(id)?.series?.[index],\n ),\n )\n if (!serie) {\n return null\n }\n\n const { name, color } = serie\n\n return (\n <Avatar\n sx={{\n bgcolor: color,\n width: 32,\n height: 32,\n fontSize: '0.875rem',\n fontWeight: 'medium',\n ...(color && {\n color: (theme) => theme.palette.getContrastText(color),\n }),\n }}\n >\n {name.charAt(0).toUpperCase()}\n </Avatar>\n )\n}\n"],"names":["Item","props","$","_c","t0","TypographyProps","children","disabled","Typography","styles","item","Prefix","id","t1","index","undefined","t2","state","getWidget","data","prefix","useWidgetStore","useShallow","t3","jsx","Suffix","suffix","Symbol","for","color","_temp","t4","theme","palette","text","secondary","Series","series","serie","name","getContrastText","bgcolor","width","height","fontSize","fontWeight","t5","charAt","toUpperCase","t6","Avatar"],"mappings":";;;;;;AAOO,SAAAA,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA;AAAA,MAAAC;AAAA,SAAAF,EAAA,CAAA,MAAAD,EAAAI,mBAAAH,EAAA,CAAA,MAAAD,EAAAK,YAAAJ,EAAA,CAAA,MAAAD,EAAAM,YAEHH,sBAACI,GAAA,EACK,IAAAC,EAAMC,MACF,SAAA,MACG,YAAA,UACI,iBAAAT,EAAKM,UACd,OAAA,WAAS,GACXN,EAAKI,iBAERJ,YAAKK,UACR,GAAaJ,EAAA,CAAA,I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AAc,KAAAA,IAAAd,EAAA,CAAA;AAFvE,QAAAoC,IAAcjB,EACZC,EACEN,CACF,CACF;AACA,MAAI,CAACsB;AAAK,WACD;AAGT,QAAA;AAAA,IAAAC,MAAAA;AAAAA,IAAAV,OAAAA;AAAAA,EAAAA,IAAwBS;AAAK,MAAAf;AAAA,EAAArB,SAAA2B,KAUnBN,IAAAM,KAAA;AAAA,IAAAA,OACKG,CAAAA,MAAWA,EAAKC,QAAQO,gBAAiBX,CAAK;AAAA,EAAA,GACtD3B,OAAA2B,GAAA3B,OAAAqB,KAAAA,IAAArB,EAAA,CAAA;AAAA,MAAA6B;AAAA,EAAA7B,EAAA,CAAA,MAAA2B,KAAA3B,SAAAqB,KARCQ,IAAA;AAAA,IAAAU,SACOZ;AAAAA,IAAKa,OACP;AAAA,IAAEC,QACD;AAAA,IAAEC,UACA;AAAA,IAAUC,YACR;AAAA,IAAQ,GAChBtB;AAAAA,EAAAA,GAGLrB,OAAA2B,GAAA3B,OAAAqB,GAAArB,OAAA6B,KAAAA,IAAA7B,EAAA,CAAA;AAAA,MAAA4C;AAAA,EAAA5C,SAAAqC,KAEAO,IAAAP,EAAIQ,OAAQ,CAAC,EAACC,YAAAA,GAAc9C,OAAAqC,GAAArC,OAAA4C,KAAAA,IAAA5C,EAAA,CAAA;AAAA,MAAA+C;AAAA,SAAA/C,EAAA,EAAA,MAAA6B,KAAA7B,UAAA4C,KAZ/BG,IAAA,gBAAAzB,EAAC0B,GAAA,EACK,IAAAnB,GAWHe,UAAAA,GACH,GAAS5C,QAAA6B,GAAA7B,QAAA4C,GAAA5C,QAAA+C,KAAAA,IAAA/C,EAAA,EAAA,GAbT+C;AAaS;"}
@@ -1,25 +0,0 @@
1
- import { c as i } from "react/compiler-runtime";
2
- import { useRef as u, useEffect as l } from "react";
3
- import { u as m } from "./widget-store-CzDt8oSK.js";
4
- function R(t) {
5
- const e = i(5), f = u(null), c = u(null), r = m(a);
6
- let n, o;
7
- e[0] !== r || e[1] !== t ? (n = () => {
8
- f.current && r(t, {
9
- refUI: f,
10
- instance: c
11
- });
12
- }, o = [t, r], e[0] = r, e[1] = t, e[2] = n, e[3] = o) : (n = e[2], o = e[3]), l(n, o);
13
- let s;
14
- return e[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (s = {
15
- ref: f,
16
- instance: c
17
- }, e[4] = s) : s = e[4], s;
18
- }
19
- function a(t) {
20
- return t.setWidget;
21
- }
22
- export {
23
- R as u
24
- };
25
- //# sourceMappingURL=use-widget-ref-wtFLDFCD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-widget-ref-wtFLDFCD.js","sources":["../src/hooks/use-widget-ref.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport { useWidgetStore } from '../widgets/stores/widget-store'\n\n/**\n * Registers a DOM element ref and an ECharts instance ref with the widget store.\n * This allows other parts of the application (e.g., screenshot export) to access the widget's DOM element.\n *\n * @param widgetId - The widget ID to register the refs under.\n * @returns An object with `ref` (DOM element) and `instance` (ECharts instance) refs.\n *\n * @example\n * ```tsx\n * function MyWidget({ id }: { id: string }) {\n * const { ref } = useWidgetRef<HTMLDivElement>(id)\n *\n * return <div ref={ref}>Widget content</div>\n * }\n * ```\n */\nexport function useWidgetRef<T extends HTMLElement = HTMLElement>(\n widgetId: string,\n) {\n const ref = useRef<T | null>(null)\n const instance = useRef<echarts.ECharts | null>(null)\n const setWidget = useWidgetStore((store) => store.setWidget)\n\n useEffect(() => {\n if (ref.current) {\n setWidget(widgetId, { refUI: ref, instance: instance })\n }\n }, [widgetId, setWidget])\n\n return { ref, instance }\n}\n"],"names":["useWidgetRef","widgetId","$","_c","ref","useRef","instance","setWidget","useWidgetStore","_temp","t0","t1","current","refUI","useEffect","t2","Symbol","for","store"],"mappings":";;;AAmBO,SAAAA,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAGLC,IAAYC,EAAiB,IAAI,GACjCC,IAAiBD,EAA+B,IAAI,GACpDE,IAAkBC,EAAeC,CAA0B;AAAC,MAAAC,GAAAC;AAAA,EAAAT,EAAA,CAAA,MAAAK,KAAAL,SAAAD,KAElDS,IAAAA,MAAA;AACR,IAAIN,EAAGQ,WACLL,EAAUN,GAAU;AAAA,MAAAY,OAAST;AAAAA,MAAGE,UAAAA;AAAAA,IAAAA,CAAsB;AAAA,EACvD,GACAK,IAAA,CAACV,GAAUM,CAAS,GAACL,OAAAK,GAAAL,OAAAD,GAAAC,OAAAQ,GAAAR,OAAAS,MAAAD,IAAAR,EAAA,CAAA,GAAAS,IAAAT,EAAA,CAAA,IAJxBY,EAAUJ,GAIPC,CAAqB;AAAC,MAAAI;AAAA,SAAAb,EAAA,CAAA,MAAAc,uBAAAC,IAAA,2BAAA,KAElBF,IAAA;AAAA,IAAAX,KAAAA;AAAAA,IAAAE,UAAAA;AAAAA,EAAAA,GAAiBJ,OAAAa,KAAAA,IAAAb,EAAA,CAAA,GAAjBa;AAAiB;AAbnB,SAAAN,EAAAS,GAAA;AAAA,SAKuCA,EAAKX;AAAU;"}