@carto/ps-react-ui 5.0.0-widgets.1 → 5.0.0-widgets.11

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 (115) hide show
  1. package/dist/error-B2IJ9d2h.js +38 -0
  2. package/dist/error-B2IJ9d2h.js.map +1 -0
  3. package/dist/no-data-C54XJt13.js +61 -0
  4. package/dist/no-data-C54XJt13.js.map +1 -0
  5. package/dist/note-Clng2ej6.js +124 -0
  6. package/dist/note-Clng2ej6.js.map +1 -0
  7. package/dist/{row-C_m1ovHv.js → row-DrHwXNvF.js} +2 -2
  8. package/dist/{row-C_m1ovHv.js.map → row-DrHwXNvF.js.map} +1 -1
  9. package/dist/{series-6xp-KQ0S.js → series-Do02NQUF.js} +3 -3
  10. package/dist/{series-6xp-KQ0S.js.map → series-Do02NQUF.js.map} +1 -1
  11. package/dist/types/components/basemaps/group-wrapper.d.ts +1 -1
  12. package/dist/types/widgets/actions/lock-selection/types.d.ts +0 -2
  13. package/dist/types/widgets/actions/searcher/searcher.d.ts +1 -1
  14. package/dist/types/widgets/actions/searcher/types.d.ts +2 -0
  15. package/dist/types/widgets/bar/config.d.ts +1 -1
  16. package/dist/types/widgets/bar/types.d.ts +1 -1
  17. package/dist/types/widgets/category/config.d.ts +2 -1
  18. package/dist/types/widgets/category/style.d.ts +0 -1
  19. package/dist/types/widgets/category/types.d.ts +1 -0
  20. package/dist/types/widgets/echart/types.d.ts +1 -0
  21. package/dist/types/widgets/error/error.d.ts +2 -0
  22. package/dist/types/widgets/error/index.d.ts +2 -0
  23. package/dist/types/widgets/error/types.d.ts +12 -0
  24. package/dist/types/widgets/formula/config.d.ts +1 -1
  25. package/dist/types/widgets/histogram/config.d.ts +1 -1
  26. package/dist/types/widgets/histogram/types.d.ts +1 -1
  27. package/dist/types/widgets/index.d.ts +6 -0
  28. package/dist/types/widgets/loader/index.d.ts +3 -0
  29. package/dist/types/widgets/loader/loader.d.ts +2 -0
  30. package/dist/types/widgets/{root → loader}/types.d.ts +1 -1
  31. package/dist/types/widgets/loader/utils.d.ts +1 -0
  32. package/dist/types/widgets/markdown/types.d.ts +1 -1
  33. package/dist/types/widgets/no-data/index.d.ts +2 -0
  34. package/dist/types/widgets/no-data/no-data.d.ts +35 -0
  35. package/dist/types/widgets/no-data/style.d.ts +6 -0
  36. package/dist/types/widgets/no-data/types.d.ts +67 -0
  37. package/dist/types/widgets/note/index.d.ts +2 -2
  38. package/dist/types/widgets/note/note.d.ts +2 -2
  39. package/dist/types/widgets/note/types.d.ts +1 -1
  40. package/dist/types/widgets/pie/config.d.ts +1 -1
  41. package/dist/types/widgets/pie/types.d.ts +1 -1
  42. package/dist/types/widgets/scatterplot/config.d.ts +1 -1
  43. package/dist/types/widgets/scatterplot/types.d.ts +1 -1
  44. package/dist/types/widgets/selection-summary/index.d.ts +2 -2
  45. package/dist/types/widgets/selection-summary/selection-summary.d.ts +2 -2
  46. package/dist/types/widgets/selection-summary/types.d.ts +1 -1
  47. package/dist/types/widgets/skeleton-loader/skeleton-loader.d.ts +1 -1
  48. package/dist/types/widgets/spread/config.d.ts +1 -1
  49. package/dist/types/widgets/stores/types.d.ts +4 -76
  50. package/dist/types/widgets/stores/widget-store.d.ts +1 -1
  51. package/dist/types/widgets/subheader/index.d.ts +2 -2
  52. package/dist/types/widgets/subheader/subheader.d.ts +2 -2
  53. package/dist/types/widgets/subheader/types.d.ts +1 -1
  54. package/dist/types/widgets/table/config.d.ts +8 -2
  55. package/dist/types/widgets/table/hooks/index.d.ts +2 -2
  56. package/dist/types/widgets/table/hooks/use-pagination.d.ts +4 -16
  57. package/dist/types/widgets/table/hooks/use-selection.d.ts +3 -5
  58. package/dist/types/widgets/table/hooks/use-sort.d.ts +7 -14
  59. package/dist/types/widgets/table/index.d.ts +2 -2
  60. package/dist/types/widgets/table/table-ui.d.ts +3 -3
  61. package/dist/types/widgets/table/types.d.ts +14 -19
  62. package/dist/types/widgets/timeseries/config.d.ts +1 -1
  63. package/dist/types/widgets/timeseries/types.d.ts +1 -1
  64. package/dist/widget-store-CB6Trp_0.js +131 -0
  65. package/dist/widget-store-CB6Trp_0.js.map +1 -0
  66. package/dist/widgets/actions.js +602 -596
  67. package/dist/widgets/actions.js.map +1 -1
  68. package/dist/widgets/bar.js +8 -7
  69. package/dist/widgets/bar.js.map +1 -1
  70. package/dist/widgets/category.js +238 -272
  71. package/dist/widgets/category.js.map +1 -1
  72. package/dist/widgets/echart.js +1 -1
  73. package/dist/widgets/error.js +5 -0
  74. package/dist/widgets/error.js.map +1 -0
  75. package/dist/widgets/formula.js +19 -18
  76. package/dist/widgets/formula.js.map +1 -1
  77. package/dist/widgets/histogram.js +54 -53
  78. package/dist/widgets/histogram.js.map +1 -1
  79. package/dist/widgets/loader.js +57 -0
  80. package/dist/widgets/loader.js.map +1 -0
  81. package/dist/widgets/markdown.js +1 -1
  82. package/dist/widgets/no-data.js +5 -0
  83. package/dist/widgets/no-data.js.map +1 -0
  84. package/dist/widgets/note.js +2 -121
  85. package/dist/widgets/note.js.map +1 -1
  86. package/dist/widgets/pie.js +8 -7
  87. package/dist/widgets/pie.js.map +1 -1
  88. package/dist/widgets/range.js +2 -2
  89. package/dist/widgets/scatterplot.js +8 -7
  90. package/dist/widgets/scatterplot.js.map +1 -1
  91. package/dist/widgets/selection-summary.js +3 -3
  92. package/dist/widgets/selection-summary.js.map +1 -1
  93. package/dist/widgets/skeleton-loader.js +1 -1
  94. package/dist/widgets/spread.js +20 -19
  95. package/dist/widgets/spread.js.map +1 -1
  96. package/dist/widgets/stores.js +1 -1
  97. package/dist/widgets/subheader.js +6 -6
  98. package/dist/widgets/subheader.js.map +1 -1
  99. package/dist/widgets/table.js +562 -570
  100. package/dist/widgets/table.js.map +1 -1
  101. package/dist/widgets/timeseries.js +8 -7
  102. package/dist/widgets/timeseries.js.map +1 -1
  103. package/dist/widgets/wrapper.js +1 -1
  104. package/dist/widgets/wrapper.js.map +1 -1
  105. package/dist/widgets.js +8 -2
  106. package/dist/widgets.js.map +1 -1
  107. package/package.json +12 -4
  108. package/dist/types/widgets/root/index.d.ts +0 -3
  109. package/dist/types/widgets/root/root.d.ts +0 -2
  110. package/dist/types/widgets/root/style.d.ts +0 -8
  111. package/dist/types/widgets/root/utils.d.ts +0 -1
  112. package/dist/widget-store-DNyVElxd.js +0 -190
  113. package/dist/widget-store-DNyVElxd.js.map +0 -1
  114. package/dist/widgets/root.js +0 -68
  115. package/dist/widgets/root.js.map +0 -1
@@ -0,0 +1,67 @@
1
+ import { ReactNode } from 'react';
2
+ import { WidgetState } from '../stores/types';
3
+ /**
4
+ * Props for the WidgetNoData wrapper component
5
+ *
6
+ * @example Basic usage
7
+ * ```tsx
8
+ * <WidgetNoData id="my-widget">
9
+ * <WidgetContent id="my-widget" />
10
+ * </WidgetNoData>
11
+ * ```
12
+ *
13
+ * @example With custom messages
14
+ * ```tsx
15
+ * <WidgetNoData
16
+ * id="my-widget"
17
+ * title="No results found"
18
+ * description="Try adjusting your filters"
19
+ * >
20
+ * <WidgetContent id="my-widget" />
21
+ * </WidgetNoData>
22
+ * ```
23
+ *
24
+ * @example With custom isEmpty logic
25
+ * ```tsx
26
+ * <WidgetNoData
27
+ * id="my-widget"
28
+ * isEmpty={(data) => {
29
+ * const d = data as CustomData
30
+ * return !d?.items?.length
31
+ * }}
32
+ * >
33
+ * <WidgetContent id="my-widget" />
34
+ * </WidgetNoData>
35
+ * ```
36
+ */
37
+ export interface WidgetNoDataProps {
38
+ /**
39
+ * Widget ID to fetch state from store
40
+ */
41
+ id: WidgetState['id'];
42
+ /**
43
+ * Children to render when data is available
44
+ */
45
+ children: ReactNode;
46
+ /**
47
+ * Optional custom title for empty state
48
+ * @default "No data available"
49
+ */
50
+ title?: string;
51
+ /**
52
+ * Optional custom description for empty state
53
+ * @default "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"
54
+ */
55
+ description?: string;
56
+ /**
57
+ * Optional custom function to determine if data is empty
58
+ * If not provided, uses default isEmpty logic that handles:
59
+ * - null/undefined → empty
60
+ * - [] (empty array) → empty
61
+ * - [[]] (nested empty arrays) → empty
62
+ * - {} (empty object) → empty
63
+ * - Primitives → not empty
64
+ * - Arrays/objects with content → not empty
65
+ */
66
+ isEmpty?: (data: unknown) => boolean;
67
+ }
@@ -1,2 +1,2 @@
1
- export { Note } from './note';
2
- export type { NoteProps } from './types';
1
+ export { WidgetNote } from './note';
2
+ export type { WidgetNoteProps } from './types';
@@ -1,2 +1,2 @@
1
- import { NoteProps } from './types';
2
- export declare function Note({ children, labels }: NoteProps): import("react/jsx-runtime").JSX.Element | null;
1
+ import { WidgetNoteProps } from './types';
2
+ export declare function WidgetNote({ children, labels, }: WidgetNoteProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,5 +1,5 @@
1
1
  import { MarkdownComponentProps } from '../markdown';
2
- export interface NoteProps {
2
+ export interface WidgetNoteProps {
3
3
  children: MarkdownComponentProps['children'];
4
4
  labels?: {
5
5
  showMore?: string;
@@ -1,5 +1,5 @@
1
1
  import { PieConfig, PieWidgetConfig, PieWidgetData } from './types';
2
2
  import { DownloadItem } from '../actions';
3
- import { ConfigProps } from '../root/types';
3
+ import { ConfigProps } from '../loader/types';
4
4
  export declare function pieDownloadConfig({ refUI, }: ConfigProps): DownloadItem<PieWidgetData>[];
5
5
  export declare function pieConfig(props: PieConfig): PieWidgetConfig;
@@ -1,6 +1,6 @@
1
1
  import { EchartWidgetData, EchartWidgetState } from '../echart';
2
2
  import { EchartWidgetOptionProps, EchartWidgetProps } from '../echart/types';
3
- import { ConfigProps } from '../root';
3
+ import { ConfigProps } from '../loader';
4
4
  export type PieWidgetData = EchartWidgetData;
5
5
  export type PieWidgetState = EchartWidgetState;
6
6
  export type PieWidgetConfig = EchartWidgetProps & {
@@ -1,5 +1,5 @@
1
1
  import { ScatterplotConfig, ScatterplotWidgetConfig, ScatterplotWidgetData } from './types';
2
2
  import { DownloadItem } from '../actions';
3
- import { ConfigProps } from '../root/types';
3
+ import { ConfigProps } from '../loader/types';
4
4
  export declare function scatterplotDownloadConfig({ refUI, }: ConfigProps): DownloadItem<ScatterplotWidgetData>[];
5
5
  export declare function scatterplotConfig(props: ScatterplotConfig): ScatterplotWidgetConfig;
@@ -1,6 +1,6 @@
1
1
  import { EchartWidgetState } from '../echart';
2
2
  import { EchartWidgetOptionProps, EchartWidgetProps } from '../echart/types';
3
- import { ConfigProps } from '../root';
3
+ import { ConfigProps } from '../loader';
4
4
  export type ScatterplotWidgetData = [number, number][][];
5
5
  export type ScatterplotWidgetState = EchartWidgetState;
6
6
  export type ScatterplotWidgetConfig = EchartWidgetProps & {
@@ -1,2 +1,2 @@
1
- export { SelectionSummary } from './selection-summary';
2
- export type { SelectedProps, SelectionSummaryLabels } from './types';
1
+ export { WidgetSelectionSummary } from './selection-summary';
2
+ export type { WidgetSelectionSummaryProps, SelectionSummaryLabels, } from './types';
@@ -1,2 +1,2 @@
1
- import { SelectedProps } from './types';
2
- export declare function SelectionSummary({ selections, onClear, labels, }: SelectedProps): import("react/jsx-runtime").JSX.Element;
1
+ import { WidgetSelectionSummaryProps } from './types';
2
+ export declare function WidgetSelectionSummary({ selections, onClear, labels, }: WidgetSelectionSummaryProps): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- export interface SelectedProps {
1
+ export interface WidgetSelectionSummaryProps {
2
2
  selections: number;
3
3
  onClear?: () => void;
4
4
  labels?: Partial<SelectionSummaryLabels>;
@@ -1,2 +1,2 @@
1
1
  import { SkeletonLoaderProps } from './types';
2
- export declare function SkeletonLoader({ id, children, Skeleton, }: SkeletonLoaderProps): 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 SkeletonLoader({ id, children, Skeleton, }: SkeletonLoaderProps): string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | 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> | null | undefined;
@@ -1,5 +1,5 @@
1
1
  import { DownloadItem } from '../actions';
2
- import { ConfigProps } from '../root/types';
2
+ import { ConfigProps } from '../loader/types';
3
3
  import { SpreadWidgetConfig, SpreadWidgetData } from './types';
4
4
  import { SeriesConfig } from '../formula/types';
5
5
  export interface SpreadConfigProps {
@@ -1,55 +1,4 @@
1
1
  import { RefObject } from 'react';
2
- /**
3
- * Sort direction for table columns
4
- */
5
- export type StoreSortDirection = 'asc' | 'desc';
6
- /**
7
- * Pagination mode for tables
8
- */
9
- export type StorePaginationMode = 'local' | 'remote';
10
- /**
11
- * Sort mode for tables
12
- */
13
- export type StoreSortMode = 'local' | 'remote';
14
- /**
15
- * Table pagination state stored in widget store
16
- */
17
- export interface TablePaginationStoreState {
18
- /** Current page (0-indexed) */
19
- page: number;
20
- /** Rows per page */
21
- rowsPerPage: number;
22
- /** Available rows per page options */
23
- rowsPerPageOptions: number[];
24
- /** Pagination mode: local or remote */
25
- mode: StorePaginationMode;
26
- }
27
- /**
28
- * Table sort state stored in widget store
29
- */
30
- export interface TableSortStoreState {
31
- /** Column ID being sorted */
32
- columnId: string | null;
33
- /** Sort direction */
34
- direction: StoreSortDirection;
35
- /** Sort mode: local or remote */
36
- mode: StoreSortMode;
37
- }
38
- /**
39
- * Table selection state stored in widget store
40
- */
41
- export interface TableSelectionStoreState {
42
- /** Set of selected row IDs */
43
- selectedIds: Set<string | number>;
44
- }
45
- /**
46
- * Combined table state for widget store
47
- */
48
- export interface TableStoreState {
49
- pagination?: TablePaginationStoreState;
50
- sort?: TableSortStoreState;
51
- selection?: TableSelectionStoreState;
52
- }
53
2
  export interface WidgetsStoreProps {
54
3
  /** Unique identifier for the widget */
55
4
  id: string;
@@ -62,7 +11,10 @@ export interface WidgetsStoreProps {
62
11
  /** Fetching state (e.g., for async data) */
63
12
  isFetching: boolean;
64
13
  /** Error message if any */
65
- error?: string;
14
+ error?: {
15
+ title?: string;
16
+ message?: string;
17
+ };
66
18
  /** Whether widget is visible */
67
19
  visible?: boolean;
68
20
  /** Reference to the widget ui instance */
@@ -169,30 +121,6 @@ export interface WidgetStoreActions {
169
121
  * @returns Widget state or undefined if not found
170
122
  */
171
123
  getWidget: <T extends WidgetState = WidgetState>(id: WidgetState['id']) => T | undefined;
172
- /**
173
- * Set table pagination state for a widget
174
- * @param id - Widget ID
175
- * @param pagination - Partial pagination state to merge
176
- */
177
- setTablePagination: (id: WidgetState['id'], pagination: Partial<TablePaginationStoreState>) => void;
178
- /**
179
- * Set table sort state for a widget
180
- * @param id - Widget ID
181
- * @param sort - Partial sort state to merge
182
- */
183
- setTableSort: (id: WidgetState['id'], sort: Partial<TableSortStoreState>) => void;
184
- /**
185
- * Set table selection state for a widget
186
- * @param id - Widget ID
187
- * @param selection - Partial selection state to merge
188
- */
189
- setTableSelection: (id: WidgetState['id'], selection: Partial<TableSelectionStoreState>) => void;
190
- /**
191
- * Get table state for a widget
192
- * @param id - Widget ID
193
- * @returns Table state or undefined if not found
194
- */
195
- getTableState: (id: WidgetState['id']) => TableStoreState | undefined;
196
124
  /**
197
125
  * Register a tool with the widget's transformation pipeline
198
126
  * @param widgetId - Widget ID
@@ -36,4 +36,4 @@ import { WidgetStore } from './types';
36
36
  * const formulaWidgets = getWidgetsByType('formula')
37
37
  * ```
38
38
  */
39
- export declare const useWidgetStore: import('zustand').UseBoundStore<import('zustand').StoreApi<WidgetStore>>;
39
+ export declare const useWidgetStore: import('node_modules/zustand/esm/react.mjs').UseBoundStore<import('node_modules/zustand/esm/vanilla.mjs').StoreApi<WidgetStore>>;
@@ -1,2 +1,2 @@
1
- export { Subheader } from './subheader';
2
- export type { SubheaderComponentProps } from './types';
1
+ export { WidgetSubHeader } from './subheader';
2
+ export type { WidgetSubHeaderProps } from './types';
@@ -1,2 +1,2 @@
1
- import { SubheaderComponentProps } from './types';
2
- export declare function Subheader({ slotLeft, slotRight, sx, }: SubheaderComponentProps): import("react/jsx-runtime").JSX.Element;
1
+ import { WidgetSubHeaderProps } from './types';
2
+ export declare function WidgetSubHeader({ slotLeft, slotRight, sx, }: WidgetSubHeaderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { SxProps, Theme } from '@mui/material';
2
2
  import { ReactNode } from 'react';
3
- export interface SubheaderComponentProps {
3
+ export interface WidgetSubHeaderProps {
4
4
  /** Content for the left slot */
5
5
  slotLeft?: ReactNode;
6
6
  /** Content for the right slot*/
@@ -1,5 +1,11 @@
1
- import { ConfigProps } from '../root/types';
2
- import { TableDownloadConfig, TableWidgetConfig, TableColumn } from './types';
1
+ import { ConfigProps } from '../loader/types';
2
+ import { TableDownloadConfig, TableWidgetConfig, TableColumn, Mode, SortDirection } from './types';
3
+ export declare const DEFAULT_MODE: Mode;
4
+ export declare const DEFAULT_PAGE = 0;
5
+ export declare const DEFAULT_ROWS_PER_PAGE = 10;
6
+ export declare const DEFAULT_ROWS_PER_PAGE_OPTIONS: number[];
7
+ export declare const DEFAULT_COLUMN_ID: null;
8
+ export declare const DEFAULT_DIRECTION: SortDirection;
3
9
  /**
4
10
  * Default table download configuration
5
11
  * Supports PNG export (screenshot) and CSV export (data)
@@ -1,6 +1,6 @@
1
1
  export { usePagination } from './use-pagination';
2
2
  export { useSort } from './use-sort';
3
3
  export { useSelection } from './use-selection';
4
- export type { UsePaginationOptions, UsePaginationResult, } from './use-pagination';
5
- export type { UseSortOptions, UseSortResult } from './use-sort';
4
+ export type { UsePaginationResult } from './use-pagination';
5
+ export type { UseSortResult } from './use-sort';
6
6
  export type { UseSelectionOptions, UseSelectionResult } from './use-selection';
@@ -1,19 +1,7 @@
1
- import { TableRow, PaginationMode } from '../types';
2
- export interface UsePaginationOptions {
3
- /** Pagination mode: local or remote */
4
- mode: PaginationMode;
5
- /** Initial page (0-indexed) */
6
- initialPage?: number;
7
- /** Initial rows per page */
8
- initialRowsPerPage?: number;
9
- /** Available rows per page options */
10
- rowsPerPageOptions?: number[];
11
- /** Total rows (for remote pagination) */
12
- total?: number;
13
- /** Callback when page changes (for remote pagination) */
14
- onPageChange?: (page: number, rowsPerPage: number) => void;
15
- }
1
+ import { TableRow } from '../types';
16
2
  export interface UsePaginationResult<T> {
3
+ /** Whether pagination is enabled */
4
+ paginationEnabled: boolean;
17
5
  /** Current page (0-indexed) */
18
6
  page: number;
19
7
  /** Rows per page */
@@ -42,4 +30,4 @@ export interface UsePaginationResult<T> {
42
30
  * Supports both local (client-side) and remote (server-side) pagination
43
31
  * State is persisted in the widget store for the given widgetId
44
32
  */
45
- export declare function usePagination<T extends TableRow>(widgetId: string, data: T[], options: UsePaginationOptions): UsePaginationResult<T>;
33
+ export declare function usePagination<T extends TableRow>(widgetId: string, data: T[]): UsePaginationResult<T>;
@@ -1,13 +1,11 @@
1
1
  import { TableRow } from '../types';
2
2
  export interface UseSelectionOptions {
3
- /** Initial selected IDs */
4
- initialSelectedIds?: Set<string | number>;
5
3
  /** Callback when selection changes */
6
- onSelectionChange?: (selectedIds: Set<string | number>) => void;
4
+ onSelectionChange?: (selectedIds: (string | number)[]) => void;
7
5
  }
8
6
  export interface UseSelectionResult {
9
- /** Set of selected row IDs */
10
- selectedIds: Set<string | number>;
7
+ /** Array of selected row IDs */
8
+ selectedIds: (string | number)[];
11
9
  /** Check if a row is selected */
12
10
  isSelected: (id: string | number) => boolean;
13
11
  /** Check if all provided rows are selected */
@@ -1,17 +1,10 @@
1
- import { TableRow, SortMode, SortDirection, SortState } from '../types';
2
- export interface UseSortOptions {
3
- /** Sort mode: local or remote */
4
- mode: SortMode;
5
- /** Initial sort column ID */
6
- initialColumnId?: string | null;
7
- /** Initial sort direction */
8
- initialDirection?: SortDirection;
9
- /** Callback when sort changes (for remote sorting) */
10
- onSortChange?: (columnId: string, direction: SortDirection) => void;
11
- }
12
- export interface UseSortResult<T> {
1
+ import { TableRow, SortDirection, SortState } from '../types';
2
+ export interface UseSortResult<T> extends SortState {
3
+ /** Whether sorting is enabled */
4
+ sortEnabled: boolean;
13
5
  /** Current sort state */
14
- sortState: SortState;
6
+ columnId: string | null;
7
+ direction: SortDirection;
15
8
  /** Sorted data (for local mode) */
16
9
  sortedData: T[];
17
10
  /** Toggle sort on a column */
@@ -26,4 +19,4 @@ export interface UseSortResult<T> {
26
19
  * Supports both local (client-side) and remote (server-side) sorting
27
20
  * State is persisted in the widget store for the given widgetId
28
21
  */
29
- export declare function useSort<T extends TableRow>(widgetId: string, data: T[], options: UseSortOptions): UseSortResult<T>;
22
+ export declare function useSort<T extends TableRow>(widgetId: string, data: T[]): UseSortResult<T>;
@@ -9,5 +9,5 @@ export { TableSkeleton } from './skeleton';
9
9
  export { sanitizeTableRow, sanitizeTableData } from './serializer';
10
10
  export { getCellValue, compareValues, sortData, paginateData } from './helpers';
11
11
  export { styles as tableStyles } from './style';
12
- export type { TableUIProps, TableColumn, TableRow, TableWidgetData, TablePaginationState, SortDirection, SortState, PaginationMode, SortMode, TableWidgetConfig, TableWidgetState, TableDownloadConfig, TableProps, CellHeaderProps, RowProps, PaginationProps, PaginationActionsProps, } from './types';
13
- export type { UsePaginationOptions, UsePaginationResult, UseSortOptions, UseSortResult, UseSelectionOptions, UseSelectionResult, } from './hooks';
12
+ export type { TableUIProps, TableColumn, TableRow, TableWidgetData, TablePaginationState, SortDirection, SortState, Mode, TableWidgetConfig, TableWidgetState, TableDownloadConfig, TableProps, CellHeaderProps, RowProps, PaginationProps, PaginationActionsProps, } from './types';
13
+ export type { UsePaginationResult, UseSortResult, UseSelectionOptions, UseSelectionResult, } from './hooks';
@@ -14,13 +14,13 @@ export interface TableComponentProps extends MuiTableProps {
14
14
  */
15
15
  declare function Table({ children, ref, stickyHeader, ...props }: TableComponentProps): import("react/jsx-runtime").JSX.Element;
16
16
  declare namespace Table {
17
- var Head: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").TableHeadTypeMap<{}, "thead">>;
17
+ var Head: import("node_modules/@mui/material/OverridableComponent").OverridableComponent<import("node_modules/@mui/material").TableHeadTypeMap<{}, "thead">>;
18
18
  var CellHeader: typeof import(".").CellHeader;
19
- var Body: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").TableBodyTypeMap<{}, "tbody">>;
19
+ var Body: import("node_modules/@mui/material/OverridableComponent").OverridableComponent<import("node_modules/@mui/material").TableBodyTypeMap<{}, "tbody">>;
20
20
  var Row: typeof import(".").Row;
21
21
  var Cell: typeof TableCell;
22
22
  var Container: typeof TableContainer;
23
- var Paper: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").PaperTypeMap<{}, "div">>;
23
+ var Paper: import("node_modules/@mui/material/OverridableComponent").OverridableComponent<import("node_modules/@mui/material").PaperTypeMap<{}, "div">>;
24
24
  var Pagination: typeof import(".").Pagination;
25
25
  var PaginationActions: typeof import(".").PaginationActions;
26
26
  }
@@ -63,13 +63,9 @@ export interface SortState {
63
63
  direction: SortDirection;
64
64
  }
65
65
  /**
66
- * Pagination mode
66
+ * Pagination and sort mode
67
67
  */
68
- export type PaginationMode = 'local' | 'remote';
69
- /**
70
- * Sort mode
71
- */
72
- export type SortMode = 'local' | 'remote';
68
+ export type Mode = 'local' | 'remote';
73
69
  /**
74
70
  * Table widget configuration
75
71
  */
@@ -78,45 +74,44 @@ export interface TableWidgetConfig {
78
74
  columns?: TableColumn[];
79
75
  /** Enable row selection with checkboxes */
80
76
  selectable?: boolean;
77
+ /** Currently selected row IDs */
78
+ selected: (string | number)[];
79
+ /** Pagination and sort mode: local (client-side) or remote (server-side) */
80
+ mode: Mode;
81
81
  /** Pagination configuration */
82
82
  pagination?: {
83
- /** Pagination mode: local (client-side) or remote (server-side) */
84
- mode: PaginationMode;
83
+ /** Current page (0-indexed) */
84
+ page?: number;
85
85
  /** Available rows per page options */
86
86
  rowsPerPageOptions?: number[];
87
87
  /** Default rows per page */
88
- defaultRowsPerPage?: number;
88
+ rowsPerPage?: number;
89
89
  /** Total rows for remote pagination */
90
90
  total?: number;
91
91
  };
92
92
  /** Sort configuration */
93
93
  sort?: {
94
- /** Sort mode: local (client-side) or remote (server-side) */
95
- mode: SortMode;
96
94
  /** Default sort column */
97
- defaultColumnId?: string;
95
+ columnId: string | null;
98
96
  /** Default sort direction */
99
- defaultDirection?: SortDirection;
97
+ direction?: SortDirection;
100
98
  };
101
99
  /** Callback when a row is clicked */
102
100
  onRowClick?: (row: TableRow) => void;
103
101
  /** Callback when hovering over a row (null when leaving table) */
104
102
  onRowHover?: (row: TableRow | null) => void;
105
103
  /** Callback when selection changes */
106
- onSelectionChange?: (selectedIds: Set<string | number>) => void;
104
+ onSelectionChange?: (selected: (string | number)[]) => void;
107
105
  /** Callback when page changes (for remote pagination) */
108
106
  onPageChange?: (page: number, rowsPerPage: number) => void;
109
107
  /** Callback when sort changes (for remote sorting) */
110
108
  onSortChange?: (columnId: string, direction: SortDirection) => void;
111
109
  }
112
110
  /**
113
- * Table widget state
111
+ * Table widget state - includes both configuration and runtime state
114
112
  */
115
- export type TableWidgetState = BaseWidgetState<WrapperState<TableWidgetConfig> & {
113
+ export type TableWidgetState = BaseWidgetState<WrapperState<TableWidgetConfig & {}> & {
116
114
  data: TableWidgetData;
117
- paginationState?: TablePaginationState;
118
- sortState?: SortState;
119
- selectedIds?: Set<string | number>;
120
115
  }>;
121
116
  /**
122
117
  * Table download configuration
@@ -1,5 +1,5 @@
1
1
  import { TimeseriesConfig, TimeseriesWidgetConfig, TimeseriesWidgetData } from './types';
2
2
  import { DownloadItem } from '../actions';
3
- import { ConfigProps } from '../root/types';
3
+ import { ConfigProps } from '../loader/types';
4
4
  export declare function timeseriesDownloadConfig({ refUI, }: ConfigProps): DownloadItem<TimeseriesWidgetData>[];
5
5
  export declare function timeseriesConfig(props: TimeseriesConfig): TimeseriesWidgetConfig;
@@ -1,6 +1,6 @@
1
1
  import { EchartWidgetData, EchartWidgetState } from '../echart';
2
2
  import { EchartWidgetOptionProps, EchartWidgetProps } from '../echart/types';
3
- import { ConfigProps } from '../root';
3
+ import { ConfigProps } from '../loader';
4
4
  export type TimeseriesWidgetData = EchartWidgetData;
5
5
  export type TimeseriesWidgetState = EchartWidgetState;
6
6
  export type TimeseriesWidgetConfig = EchartWidgetProps & {
@@ -0,0 +1,131 @@
1
+ import { create as f } from "zustand";
2
+ const T = /* @__PURE__ */ new Map(), w = f()((g, u) => ({
3
+ // State
4
+ widgets: {},
5
+ // Actions
6
+ setWidget: (e, t) => g((o) => {
7
+ const r = o.widgets[e] ?? {};
8
+ return {
9
+ widgets: {
10
+ ...o.widgets,
11
+ [e]: {
12
+ ...r,
13
+ ...t,
14
+ id: e
15
+ }
16
+ }
17
+ };
18
+ }),
19
+ removeWidget: (e) => g((t) => {
20
+ const o = {
21
+ ...t.widgets
22
+ };
23
+ return delete o[e], {
24
+ widgets: o
25
+ };
26
+ }),
27
+ clearWidgets: () => g({
28
+ widgets: {}
29
+ }),
30
+ getWidget: (e) => u().widgets[e],
31
+ registerTool: (e, t) => g((o) => {
32
+ const r = o.widgets[e] ?? {}, l = (r.registeredTools ?? []).filter((d) => d.id !== t.id);
33
+ return {
34
+ widgets: {
35
+ ...o.widgets,
36
+ [e]: {
37
+ ...r,
38
+ id: e,
39
+ registeredTools: [...l, t]
40
+ }
41
+ }
42
+ };
43
+ }),
44
+ unregisterTool: (e, t) => g((o) => {
45
+ const r = o.widgets[e];
46
+ if (!r) return o;
47
+ const l = (r.registeredTools ?? []).filter((d) => d.id !== t);
48
+ return {
49
+ widgets: {
50
+ ...o.widgets,
51
+ [e]: {
52
+ ...r,
53
+ registeredTools: l
54
+ }
55
+ }
56
+ };
57
+ }),
58
+ updateToolConfig: (e, t, o) => g((r) => {
59
+ const i = r.widgets[e];
60
+ if (!i) return r;
61
+ const d = (i.registeredTools ?? []).map((n) => n.id === t ? {
62
+ ...n,
63
+ config: {
64
+ ...n.config,
65
+ ...o
66
+ }
67
+ } : n);
68
+ return {
69
+ widgets: {
70
+ ...r.widgets,
71
+ [e]: {
72
+ ...i,
73
+ registeredTools: d
74
+ }
75
+ }
76
+ };
77
+ }),
78
+ setToolEnabled: (e, t, o) => g((r) => {
79
+ const i = r.widgets[e];
80
+ if (!i) return r;
81
+ const d = (i.registeredTools ?? []).map((n) => n.id === t ? {
82
+ ...n,
83
+ enabled: o
84
+ } : n);
85
+ return {
86
+ widgets: {
87
+ ...r.widgets,
88
+ [e]: {
89
+ ...i,
90
+ registeredTools: d
91
+ }
92
+ }
93
+ };
94
+ }),
95
+ executeToolPipeline: async (e, t) => {
96
+ const o = u().widgets[e];
97
+ if (!o) return;
98
+ const r = (T.get(e) ?? 0) + 1;
99
+ T.set(e, r);
100
+ const i = o, l = /* @__PURE__ */ new Set();
101
+ for (const s of i.registeredTools ?? [])
102
+ s.enabled && s.disables && s.disables.forEach((c) => l.add(c));
103
+ const d = [...i.registeredTools ?? []].filter((s) => s.enabled && !l.has(s.id)).sort((s, c) => s.order - c.order);
104
+ let n = t;
105
+ for (const s of d) {
106
+ if (T.get(e) !== r)
107
+ return;
108
+ try {
109
+ n = await s.fn(n, s.config);
110
+ } catch (c) {
111
+ console.error(`Tool ${s.id} failed for widget ${e}:`, c);
112
+ }
113
+ }
114
+ g((s) => {
115
+ const c = s.widgets[e];
116
+ return c ? {
117
+ widgets: {
118
+ ...s.widgets,
119
+ [e]: {
120
+ ...c,
121
+ data: n
122
+ }
123
+ }
124
+ } : s;
125
+ }), T.get(e) === r && T.delete(e);
126
+ }
127
+ }));
128
+ export {
129
+ w as u
130
+ };
131
+ //# sourceMappingURL=widget-store-CB6Trp_0.js.map