react-open-source-grid 1.5.0 → 1.5.2
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/assets/components/AccessibilityDemo.d.ts +8 -0
- package/dist/assets/components/ApiReferencePage.d.ts +2 -0
- package/dist/assets/components/BenchmarkDemo.d.ts +2 -0
- package/dist/assets/components/CellRenderersDemo.d.ts +16 -0
- package/dist/assets/components/CodeBlock.d.ts +10 -0
- package/dist/assets/components/ColumnFiltersDemo.d.ts +5 -0
- package/dist/assets/components/CompleteApiReferencePage.d.ts +2 -0
- package/dist/assets/components/ContextMenuDemo.d.ts +12 -0
- package/dist/assets/components/DataGrid/ARCHITECTURE.md.d.ts +288 -0
- package/dist/assets/components/DataGrid/AdvancedFilterBuilder.d.ts +12 -0
- package/dist/assets/components/DataGrid/CellRenderers.d.ts +64 -0
- package/dist/assets/components/DataGrid/ColumnChooser.d.ts +12 -0
- package/dist/assets/components/DataGrid/ColumnFilters.d.ts +16 -0
- package/dist/assets/components/DataGrid/ContextMenu.d.ts +10 -0
- package/dist/assets/components/DataGrid/DataGrid.d.ts +22 -0
- package/dist/assets/components/DataGrid/DensityToggle.d.ts +23 -0
- package/dist/assets/components/DataGrid/DragHandle.d.ts +7 -0
- package/dist/assets/components/DataGrid/DraggableRow.d.ts +14 -0
- package/dist/assets/components/DataGrid/ExportMenu.d.ts +12 -0
- package/dist/assets/components/DataGrid/FacetedSearch.d.ts +29 -0
- package/dist/assets/components/DataGrid/FilteredSearchBar.d.ts +36 -0
- package/dist/assets/components/DataGrid/FocusTrap.d.ts +12 -0
- package/dist/assets/components/DataGrid/GridApiDemo.d.ts +6 -0
- package/dist/assets/components/DataGrid/GridBody.d.ts +42 -0
- package/dist/assets/components/DataGrid/GridFooter.d.ts +18 -0
- package/dist/assets/components/DataGrid/GridHeader.d.ts +18 -0
- package/dist/assets/components/DataGrid/GridPagination.d.ts +10 -0
- package/dist/assets/components/DataGrid/GroupByPanel.d.ts +9 -0
- package/dist/assets/components/DataGrid/GroupRow.d.ts +31 -0
- package/dist/assets/components/DataGrid/InfiniteScrollDataGrid.d.ts +39 -0
- package/dist/assets/components/DataGrid/LayoutPresetsManager.d.ts +11 -0
- package/dist/assets/components/DataGrid/MarketDataEngine.d.ts +165 -0
- package/dist/assets/components/DataGrid/MarketDataGrid.d.ts +33 -0
- package/dist/assets/components/DataGrid/MarketDataGridUtils.d.ts +13 -0
- package/dist/assets/components/DataGrid/ScreenReaderAnnouncer.d.ts +8 -0
- package/dist/assets/components/DataGrid/ServerSideDataSource.d.ts +136 -0
- package/dist/assets/components/DataGrid/ThemeSelector.d.ts +12 -0
- package/dist/assets/components/DataGrid/Tooltip.d.ts +15 -0
- package/dist/assets/components/DataGrid/TreeRow.d.ts +31 -0
- package/dist/assets/components/DataGrid/VirtualScroller.d.ts +35 -0
- package/dist/assets/components/DataGrid/WebSocketMockFeed.d.ts +121 -0
- package/dist/assets/components/DataGrid/aggregationUtils.d.ts +25 -0
- package/dist/assets/components/DataGrid/contextMenuUtils.d.ts +36 -0
- package/dist/assets/components/DataGrid/demos/TooltipDemo.d.ts +1 -0
- package/dist/assets/components/DataGrid/densityModes.d.ts +42 -0
- package/dist/assets/components/DataGrid/dragRowUtils.d.ts +98 -0
- package/dist/assets/components/DataGrid/exportUtils.d.ts +30 -0
- package/dist/assets/components/DataGrid/filterUtils.d.ts +17 -0
- package/dist/assets/components/DataGrid/gridApi.d.ts +142 -0
- package/dist/assets/components/DataGrid/gridApi.types.d.ts +348 -0
- package/dist/assets/components/DataGrid/gridReducer.d.ts +4 -0
- package/dist/assets/components/DataGrid/groupingUtils.d.ts +17 -0
- package/dist/assets/components/DataGrid/index.d.ts +41 -0
- package/dist/assets/components/DataGrid/layoutPersistence.d.ts +95 -0
- package/dist/assets/components/DataGrid/themes.d.ts +113 -0
- package/dist/assets/components/DataGrid/treeDataUtils.d.ts +97 -0
- package/dist/assets/components/DataGrid/types.d.ts +536 -0
- package/dist/assets/components/DataGrid/useContextMenu.d.ts +31 -0
- package/dist/assets/components/DataGrid/useDensityMode.d.ts +36 -0
- package/dist/assets/components/DataGrid/useFocusTrap.d.ts +14 -0
- package/dist/assets/components/DataGrid/useMarketData.d.ts +57 -0
- package/dist/assets/components/DataGrid/useScreenReaderAnnouncements.d.ts +23 -0
- package/dist/assets/components/DataGrid/useTooltip.d.ts +21 -0
- package/dist/assets/components/DemoGridPage.d.ts +2 -0
- package/dist/assets/components/DensityModeDemo.d.ts +12 -0
- package/dist/assets/components/FacetedSearchDemo.d.ts +8 -0
- package/dist/assets/components/FeatureGallery.d.ts +2 -0
- package/dist/assets/components/FilteredSearchDemo.d.ts +7 -0
- package/dist/assets/components/GridApiDemoPage.d.ts +2 -0
- package/dist/assets/components/HomePage.d.ts +1 -0
- package/dist/assets/components/InfiniteScrollDemo.d.ts +13 -0
- package/dist/assets/components/LayoutPersistenceDemo.d.ts +2 -0
- package/dist/assets/components/LiveMarketDemo.d.ts +18 -0
- package/dist/assets/components/MarketDataExamples.d.ts +42 -0
- package/dist/assets/components/RowDraggingDemo.d.ts +3 -0
- package/dist/assets/components/RowPinningDemo.d.ts +12 -0
- package/dist/assets/components/ThemesDemo.d.ts +17 -0
- package/dist/assets/components/TooltipDemo.d.ts +1 -0
- package/dist/assets/components/TreeDataDemo.d.ts +3 -0
- package/dist/assets/components/VirtualScrollDemo.d.ts +13 -0
- package/dist/assets/{index-BCK5Ko4P.js → index-bQ7aqGuU.js} +2 -2
- package/dist/assets/index.js +1 -1
- package/dist/assets/{layoutPersistence-BHB0W18y.js → layoutPersistence-B2lMGbE7.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +17 -4
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { Row, TreeNode, TreeConfig, ExpandedNodes } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Tree Data Utilities
|
|
4
|
+
*
|
|
5
|
+
* Utilities for managing hierarchical/tree data structures in the DataGrid.
|
|
6
|
+
* Useful for org charts, file explorers, product categories, etc.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Type guard to check if a row is a tree node
|
|
10
|
+
*/
|
|
11
|
+
export declare const isTreeNode: (row: Row | TreeNode) => row is TreeNode;
|
|
12
|
+
/**
|
|
13
|
+
* Build tree structure from flat data
|
|
14
|
+
* Converts a flat array of rows with parent-child relationships into a hierarchical tree structure.
|
|
15
|
+
*
|
|
16
|
+
* @param rows - Flat array of rows
|
|
17
|
+
* @param config - Tree configuration specifying id, parentId, and children fields
|
|
18
|
+
* @returns Array of root-level tree nodes
|
|
19
|
+
*/
|
|
20
|
+
export declare const buildTreeFromFlat: (rows: Row[], config: TreeConfig) => TreeNode[];
|
|
21
|
+
/**
|
|
22
|
+
* Flatten tree structure for rendering
|
|
23
|
+
* Converts a hierarchical tree structure into a flat array respecting expand/collapse state.
|
|
24
|
+
*
|
|
25
|
+
* @param nodes - Array of tree nodes (can be root or any level)
|
|
26
|
+
* @param expandedNodes - Map of node IDs to their expanded state
|
|
27
|
+
* @param config - Tree configuration
|
|
28
|
+
* @returns Flat array of visible tree nodes
|
|
29
|
+
*/
|
|
30
|
+
export declare const flattenTree: (nodes: TreeNode[], expandedNodes: ExpandedNodes, config: TreeConfig) => TreeNode[];
|
|
31
|
+
/**
|
|
32
|
+
* Toggle expand/collapse state of a tree node
|
|
33
|
+
*
|
|
34
|
+
* @param nodeId - ID of the node to toggle
|
|
35
|
+
* @param expandedNodes - Current expanded state map
|
|
36
|
+
* @returns Updated expanded state map
|
|
37
|
+
*/
|
|
38
|
+
export declare const toggleNodeExpansion: (nodeId: string | number, expandedNodes: ExpandedNodes) => ExpandedNodes;
|
|
39
|
+
/**
|
|
40
|
+
* Expand all nodes in the tree
|
|
41
|
+
*
|
|
42
|
+
* @param nodes - Array of tree nodes
|
|
43
|
+
* @param config - Tree configuration
|
|
44
|
+
* @returns Expanded state map with all nodes set to expanded
|
|
45
|
+
*/
|
|
46
|
+
export declare const expandAllNodes: (nodes: TreeNode[], config: TreeConfig) => ExpandedNodes;
|
|
47
|
+
/**
|
|
48
|
+
* Collapse all nodes in the tree
|
|
49
|
+
*
|
|
50
|
+
* @param nodes - Array of tree nodes
|
|
51
|
+
* @param config - Tree configuration
|
|
52
|
+
* @returns Expanded state map with all nodes set to collapsed
|
|
53
|
+
*/
|
|
54
|
+
export declare const collapseAllNodes: (nodes: TreeNode[], config: TreeConfig) => ExpandedNodes;
|
|
55
|
+
/**
|
|
56
|
+
* Get all descendant node IDs of a given node
|
|
57
|
+
*
|
|
58
|
+
* @param node - The tree node
|
|
59
|
+
* @param config - Tree configuration
|
|
60
|
+
* @returns Array of all descendant node IDs
|
|
61
|
+
*/
|
|
62
|
+
export declare const getDescendantIds: (node: TreeNode, config: TreeConfig) => (string | number)[];
|
|
63
|
+
/**
|
|
64
|
+
* Get the path from root to a specific node
|
|
65
|
+
*
|
|
66
|
+
* @param nodeId - ID of the target node
|
|
67
|
+
* @param nodes - Array of root tree nodes
|
|
68
|
+
* @param config - Tree configuration
|
|
69
|
+
* @returns Array of node IDs representing the path, or null if not found
|
|
70
|
+
*/
|
|
71
|
+
export declare const getNodePath: (nodeId: string | number, nodes: TreeNode[], config: TreeConfig) => (string | number)[] | null;
|
|
72
|
+
/**
|
|
73
|
+
* Get the maximum depth of the tree
|
|
74
|
+
*
|
|
75
|
+
* @param nodes - Array of tree nodes
|
|
76
|
+
* @param config - Tree configuration
|
|
77
|
+
* @returns Maximum depth (levels) of the tree
|
|
78
|
+
*/
|
|
79
|
+
export declare const getTreeDepth: (nodes: TreeNode[], config: TreeConfig) => number;
|
|
80
|
+
/**
|
|
81
|
+
* Count total number of nodes in the tree
|
|
82
|
+
*
|
|
83
|
+
* @param nodes - Array of tree nodes
|
|
84
|
+
* @param config - Tree configuration
|
|
85
|
+
* @returns Total count of nodes
|
|
86
|
+
*/
|
|
87
|
+
export declare const countTreeNodes: (nodes: TreeNode[], config: TreeConfig) => number;
|
|
88
|
+
/**
|
|
89
|
+
* Filter tree nodes by a predicate function
|
|
90
|
+
* Returns a new tree structure containing only matching nodes and their ancestors
|
|
91
|
+
*
|
|
92
|
+
* @param nodes - Array of tree nodes
|
|
93
|
+
* @param predicate - Function to test each node
|
|
94
|
+
* @param config - Tree configuration
|
|
95
|
+
* @returns Filtered tree structure
|
|
96
|
+
*/
|
|
97
|
+
export declare const filterTree: (nodes: TreeNode[], predicate: (node: TreeNode) => boolean, config: TreeConfig) => TreeNode[];
|
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ThemeName } from './themes';
|
|
3
|
+
import type { DensityMode } from './densityModes';
|
|
4
|
+
import type { GridApi } from './gridApi.types';
|
|
5
|
+
export type FilterType = 'text' | 'number' | 'date' | 'set' | 'multi';
|
|
6
|
+
export interface Column {
|
|
7
|
+
field: string;
|
|
8
|
+
headerName: string;
|
|
9
|
+
width?: number;
|
|
10
|
+
editable?: boolean;
|
|
11
|
+
sortable?: boolean;
|
|
12
|
+
filterable?: boolean;
|
|
13
|
+
pinnable?: boolean;
|
|
14
|
+
filterType?: FilterType;
|
|
15
|
+
renderCell?: (row: Row) => React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
export interface Row {
|
|
18
|
+
id: string | number;
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}
|
|
21
|
+
export interface TreeNode extends Row {
|
|
22
|
+
isTreeNode: true;
|
|
23
|
+
nodeId: string | number;
|
|
24
|
+
parentId: string | number | null;
|
|
25
|
+
level: number;
|
|
26
|
+
hasChildren: boolean;
|
|
27
|
+
isExpanded: boolean;
|
|
28
|
+
children?: TreeNode[];
|
|
29
|
+
}
|
|
30
|
+
export interface TreeConfig {
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
idField?: string;
|
|
33
|
+
parentIdField?: string;
|
|
34
|
+
childrenField?: string;
|
|
35
|
+
indentSize?: number;
|
|
36
|
+
showExpandIcon?: boolean;
|
|
37
|
+
showConnectors?: boolean;
|
|
38
|
+
lazyLoad?: boolean;
|
|
39
|
+
onNodeExpand?: (node: TreeNode) => void | Promise<TreeNode[]>;
|
|
40
|
+
onNodeCollapse?: (node: TreeNode) => void;
|
|
41
|
+
}
|
|
42
|
+
export interface ExpandedNodes {
|
|
43
|
+
[nodeKey: string]: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface SortConfig {
|
|
46
|
+
field: string;
|
|
47
|
+
direction: 'asc' | 'desc' | null;
|
|
48
|
+
}
|
|
49
|
+
export interface FilterValue {
|
|
50
|
+
type?: string;
|
|
51
|
+
value?: any;
|
|
52
|
+
value2?: any;
|
|
53
|
+
values?: any[];
|
|
54
|
+
}
|
|
55
|
+
export interface FilterCondition {
|
|
56
|
+
type: string;
|
|
57
|
+
value?: any;
|
|
58
|
+
value2?: any;
|
|
59
|
+
values?: any[];
|
|
60
|
+
}
|
|
61
|
+
export interface AdvancedFilterValue {
|
|
62
|
+
operator: 'AND' | 'OR';
|
|
63
|
+
conditions: FilterCondition[];
|
|
64
|
+
}
|
|
65
|
+
export interface FilterConfig {
|
|
66
|
+
[field: string]: FilterValue | AdvancedFilterValue | null;
|
|
67
|
+
}
|
|
68
|
+
export interface SelectionState {
|
|
69
|
+
selectedRows: Set<string | number>;
|
|
70
|
+
lastSelectedIndex: number | null;
|
|
71
|
+
}
|
|
72
|
+
export interface EditState {
|
|
73
|
+
rowId: string | number | null;
|
|
74
|
+
field: string | null;
|
|
75
|
+
value: any;
|
|
76
|
+
}
|
|
77
|
+
export interface FocusState {
|
|
78
|
+
rowIndex: number;
|
|
79
|
+
columnIndex: number;
|
|
80
|
+
}
|
|
81
|
+
export type AggregateFunction = 'count' | 'sum' | 'avg' | 'min' | 'max' | 'total';
|
|
82
|
+
export interface GroupConfig {
|
|
83
|
+
field: string;
|
|
84
|
+
aggregates?: {
|
|
85
|
+
field: string;
|
|
86
|
+
function: AggregateFunction;
|
|
87
|
+
}[];
|
|
88
|
+
}
|
|
89
|
+
export interface AggregateConfig {
|
|
90
|
+
field: string;
|
|
91
|
+
function: AggregateFunction;
|
|
92
|
+
label?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface FooterConfig {
|
|
95
|
+
show: boolean;
|
|
96
|
+
aggregates?: AggregateConfig[];
|
|
97
|
+
showGroupFooters?: boolean;
|
|
98
|
+
}
|
|
99
|
+
export interface GroupedRow {
|
|
100
|
+
isGroup: true;
|
|
101
|
+
groupKey: string;
|
|
102
|
+
groupValue: any;
|
|
103
|
+
field: string;
|
|
104
|
+
level: number;
|
|
105
|
+
children: (Row | GroupedRow)[];
|
|
106
|
+
isExpanded: boolean;
|
|
107
|
+
aggregates?: {
|
|
108
|
+
[key: string]: any;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export interface ExpandedGroups {
|
|
112
|
+
[groupKey: string]: boolean;
|
|
113
|
+
}
|
|
114
|
+
export interface GridState {
|
|
115
|
+
columns: Column[];
|
|
116
|
+
sortConfig: SortConfig;
|
|
117
|
+
filterConfig: FilterConfig;
|
|
118
|
+
currentPage: number;
|
|
119
|
+
pageSize: number;
|
|
120
|
+
selection: SelectionState;
|
|
121
|
+
editState: EditState;
|
|
122
|
+
focusState: FocusState | null;
|
|
123
|
+
columnOrder: string[];
|
|
124
|
+
columnWidths: {
|
|
125
|
+
[field: string]: number;
|
|
126
|
+
};
|
|
127
|
+
groupBy: string[];
|
|
128
|
+
expandedGroups: ExpandedGroups;
|
|
129
|
+
pinnedColumnsLeft: string[];
|
|
130
|
+
pinnedColumnsRight: string[];
|
|
131
|
+
hiddenColumns: string[];
|
|
132
|
+
expandedNodes: ExpandedNodes;
|
|
133
|
+
dragState: DragState;
|
|
134
|
+
pinnedRowsTop: (string | number)[];
|
|
135
|
+
pinnedRowsBottom: (string | number)[];
|
|
136
|
+
}
|
|
137
|
+
export type GridAction = {
|
|
138
|
+
type: 'SET_SORT';
|
|
139
|
+
payload: SortConfig;
|
|
140
|
+
} | {
|
|
141
|
+
type: 'SET_FILTER';
|
|
142
|
+
payload: {
|
|
143
|
+
field: string;
|
|
144
|
+
value: FilterValue | AdvancedFilterValue | null;
|
|
145
|
+
};
|
|
146
|
+
} | {
|
|
147
|
+
type: 'CLEAR_FILTERS';
|
|
148
|
+
} | {
|
|
149
|
+
type: 'SET_PAGE';
|
|
150
|
+
payload: number;
|
|
151
|
+
} | {
|
|
152
|
+
type: 'SET_PAGE_SIZE';
|
|
153
|
+
payload: number;
|
|
154
|
+
} | {
|
|
155
|
+
type: 'TOGGLE_ROW_SELECTION';
|
|
156
|
+
payload: {
|
|
157
|
+
rowId: string | number;
|
|
158
|
+
isMulti: boolean;
|
|
159
|
+
};
|
|
160
|
+
} | {
|
|
161
|
+
type: 'SELECT_RANGE';
|
|
162
|
+
payload: {
|
|
163
|
+
startIndex: number;
|
|
164
|
+
endIndex: number;
|
|
165
|
+
rowIds: (string | number)[];
|
|
166
|
+
};
|
|
167
|
+
} | {
|
|
168
|
+
type: 'CLEAR_SELECTION';
|
|
169
|
+
} | {
|
|
170
|
+
type: 'START_EDIT';
|
|
171
|
+
payload: {
|
|
172
|
+
rowId: string | number;
|
|
173
|
+
field: string;
|
|
174
|
+
value: any;
|
|
175
|
+
};
|
|
176
|
+
} | {
|
|
177
|
+
type: 'END_EDIT';
|
|
178
|
+
} | {
|
|
179
|
+
type: 'SET_FOCUS';
|
|
180
|
+
payload: FocusState | null;
|
|
181
|
+
} | {
|
|
182
|
+
type: 'REORDER_COLUMNS';
|
|
183
|
+
payload: {
|
|
184
|
+
fromIndex: number;
|
|
185
|
+
toIndex: number;
|
|
186
|
+
};
|
|
187
|
+
} | {
|
|
188
|
+
type: 'RESIZE_COLUMN';
|
|
189
|
+
payload: {
|
|
190
|
+
field: string;
|
|
191
|
+
width: number;
|
|
192
|
+
};
|
|
193
|
+
} | {
|
|
194
|
+
type: 'RESET_COLUMNS';
|
|
195
|
+
payload: Column[];
|
|
196
|
+
} | {
|
|
197
|
+
type: 'ADD_GROUP';
|
|
198
|
+
payload: string;
|
|
199
|
+
} | {
|
|
200
|
+
type: 'REMOVE_GROUP';
|
|
201
|
+
payload: string;
|
|
202
|
+
} | {
|
|
203
|
+
type: 'REORDER_GROUPS';
|
|
204
|
+
payload: {
|
|
205
|
+
fromIndex: number;
|
|
206
|
+
toIndex: number;
|
|
207
|
+
};
|
|
208
|
+
} | {
|
|
209
|
+
type: 'TOGGLE_GROUP';
|
|
210
|
+
payload: string;
|
|
211
|
+
} | {
|
|
212
|
+
type: 'CLEAR_GROUPS';
|
|
213
|
+
} | {
|
|
214
|
+
type: 'PIN_COLUMN';
|
|
215
|
+
payload: {
|
|
216
|
+
field: string;
|
|
217
|
+
side: 'left' | 'right';
|
|
218
|
+
};
|
|
219
|
+
} | {
|
|
220
|
+
type: 'UNPIN_COLUMN';
|
|
221
|
+
payload: string;
|
|
222
|
+
} | {
|
|
223
|
+
type: 'TOGGLE_COLUMN_VISIBILITY';
|
|
224
|
+
payload: string;
|
|
225
|
+
} | {
|
|
226
|
+
type: 'SET_COLUMN_VISIBILITY';
|
|
227
|
+
payload: {
|
|
228
|
+
field: string;
|
|
229
|
+
visible: boolean;
|
|
230
|
+
};
|
|
231
|
+
} | {
|
|
232
|
+
type: 'RESET_COLUMN_LAYOUT';
|
|
233
|
+
} | {
|
|
234
|
+
type: 'LOAD_LAYOUT_PRESET';
|
|
235
|
+
payload: LayoutPreset['layout'];
|
|
236
|
+
} | {
|
|
237
|
+
type: 'APPLY_LAYOUT';
|
|
238
|
+
payload: Partial<LayoutPreset['layout']>;
|
|
239
|
+
} | {
|
|
240
|
+
type: 'TOGGLE_TREE_NODE';
|
|
241
|
+
payload: string | number;
|
|
242
|
+
} | {
|
|
243
|
+
type: 'EXPAND_ALL_NODES';
|
|
244
|
+
} | {
|
|
245
|
+
type: 'COLLAPSE_ALL_NODES';
|
|
246
|
+
} | {
|
|
247
|
+
type: 'SET_EXPANDED_NODES';
|
|
248
|
+
payload: ExpandedNodes;
|
|
249
|
+
} | {
|
|
250
|
+
type: 'SET_DRAG_STATE';
|
|
251
|
+
payload: DragState;
|
|
252
|
+
} | {
|
|
253
|
+
type: 'START_DRAG';
|
|
254
|
+
payload: {
|
|
255
|
+
rowId: string | number;
|
|
256
|
+
rowIndex: number;
|
|
257
|
+
};
|
|
258
|
+
} | {
|
|
259
|
+
type: 'END_DRAG';
|
|
260
|
+
} | {
|
|
261
|
+
type: 'PIN_ROW_TOP';
|
|
262
|
+
payload: string | number;
|
|
263
|
+
} | {
|
|
264
|
+
type: 'PIN_ROW_BOTTOM';
|
|
265
|
+
payload: string | number;
|
|
266
|
+
} | {
|
|
267
|
+
type: 'UNPIN_ROW';
|
|
268
|
+
payload: string | number;
|
|
269
|
+
} | {
|
|
270
|
+
type: 'SET_ROW_DATA';
|
|
271
|
+
payload: Row[];
|
|
272
|
+
} | {
|
|
273
|
+
type: 'SET_COLUMN_DEFS';
|
|
274
|
+
payload: Column[];
|
|
275
|
+
} | {
|
|
276
|
+
type: 'SORT_COLUMN';
|
|
277
|
+
payload: string;
|
|
278
|
+
} | {
|
|
279
|
+
type: 'SET_SORT_MODEL';
|
|
280
|
+
payload: SortConfig[];
|
|
281
|
+
} | {
|
|
282
|
+
type: 'CLEAR_ALL_FILTERS';
|
|
283
|
+
} | {
|
|
284
|
+
type: 'CLEAR_ALL_SORTING';
|
|
285
|
+
} | {
|
|
286
|
+
type: 'SELECT_ROW';
|
|
287
|
+
payload: {
|
|
288
|
+
rowId: string | number;
|
|
289
|
+
ctrlKey: boolean;
|
|
290
|
+
};
|
|
291
|
+
} | {
|
|
292
|
+
type: 'DESELECT_ROW';
|
|
293
|
+
payload: string | number;
|
|
294
|
+
} | {
|
|
295
|
+
type: 'SELECT_ALL_ROWS';
|
|
296
|
+
} | {
|
|
297
|
+
type: 'DESELECT_ALL_ROWS';
|
|
298
|
+
} | {
|
|
299
|
+
type: 'CLEAR_FOCUS';
|
|
300
|
+
} | {
|
|
301
|
+
type: 'START_EDITING';
|
|
302
|
+
payload: {
|
|
303
|
+
rowId: string | number;
|
|
304
|
+
field: string;
|
|
305
|
+
value: any;
|
|
306
|
+
};
|
|
307
|
+
} | {
|
|
308
|
+
type: 'CANCEL_EDITING';
|
|
309
|
+
} | {
|
|
310
|
+
type: 'SAVE_EDIT';
|
|
311
|
+
} | {
|
|
312
|
+
type: 'REFRESH_CELLS';
|
|
313
|
+
payload?: unknown;
|
|
314
|
+
} | {
|
|
315
|
+
type: 'REFRESH_HEADER';
|
|
316
|
+
} | {
|
|
317
|
+
type: 'REDRAW_ROWS';
|
|
318
|
+
payload?: unknown;
|
|
319
|
+
} | {
|
|
320
|
+
type: 'SHOW_OVERLAY';
|
|
321
|
+
payload: 'loading' | 'noRows';
|
|
322
|
+
} | {
|
|
323
|
+
type: 'HIDE_OVERLAY';
|
|
324
|
+
} | {
|
|
325
|
+
type: 'SET_GROUP_BY';
|
|
326
|
+
payload: string[];
|
|
327
|
+
} | {
|
|
328
|
+
type: 'RECALCULATE_LAYOUT';
|
|
329
|
+
} | {
|
|
330
|
+
type: 'RESET_COLUMN_STATE';
|
|
331
|
+
};
|
|
332
|
+
export interface VirtualScrollConfig {
|
|
333
|
+
enabled: boolean;
|
|
334
|
+
rowHeight?: number | ((index: number, row: Row | GroupedRow) => number);
|
|
335
|
+
containerHeight?: number;
|
|
336
|
+
overscanCount?: number;
|
|
337
|
+
enableColumnVirtualization?: boolean;
|
|
338
|
+
columnOverscan?: number;
|
|
339
|
+
}
|
|
340
|
+
export interface LayoutPreset {
|
|
341
|
+
id: string;
|
|
342
|
+
name: string;
|
|
343
|
+
description?: string;
|
|
344
|
+
createdAt: number;
|
|
345
|
+
updatedAt: number;
|
|
346
|
+
layout: {
|
|
347
|
+
columnOrder: string[];
|
|
348
|
+
columnWidths: {
|
|
349
|
+
[field: string]: number;
|
|
350
|
+
};
|
|
351
|
+
pinnedColumnsLeft: string[];
|
|
352
|
+
pinnedColumnsRight: string[];
|
|
353
|
+
hiddenColumns: string[];
|
|
354
|
+
sortConfig: SortConfig;
|
|
355
|
+
filterConfig: FilterConfig;
|
|
356
|
+
pageSize: number;
|
|
357
|
+
groupBy?: string[];
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
export type StorageStrategy = 'localStorage' | 'server' | 'userProfile';
|
|
361
|
+
export interface StorageAdapter {
|
|
362
|
+
save(key: string, preset: LayoutPreset): Promise<void>;
|
|
363
|
+
load(key: string, presetId?: string): Promise<LayoutPreset | LayoutPreset[] | null>;
|
|
364
|
+
delete(key: string, presetId: string): Promise<void>;
|
|
365
|
+
list(key: string): Promise<LayoutPreset[]>;
|
|
366
|
+
}
|
|
367
|
+
export interface ServerConfig {
|
|
368
|
+
baseUrl: string;
|
|
369
|
+
headers?: Record<string, string>;
|
|
370
|
+
saveEndpoint?: string;
|
|
371
|
+
loadEndpoint?: string;
|
|
372
|
+
deleteEndpoint?: string;
|
|
373
|
+
listEndpoint?: string;
|
|
374
|
+
}
|
|
375
|
+
export interface UserProfileConfig {
|
|
376
|
+
userId: string;
|
|
377
|
+
profileKey?: string;
|
|
378
|
+
adapter?: StorageAdapter;
|
|
379
|
+
}
|
|
380
|
+
export interface PersistenceConfig {
|
|
381
|
+
enabled: boolean;
|
|
382
|
+
storageKey: string;
|
|
383
|
+
strategy?: StorageStrategy;
|
|
384
|
+
autoSave?: boolean;
|
|
385
|
+
autoSaveDelay?: number;
|
|
386
|
+
autoLoad?: boolean;
|
|
387
|
+
serverConfig?: ServerConfig;
|
|
388
|
+
userProfileConfig?: UserProfileConfig;
|
|
389
|
+
customAdapter?: StorageAdapter;
|
|
390
|
+
}
|
|
391
|
+
export interface RowPinConfig {
|
|
392
|
+
enabled: boolean;
|
|
393
|
+
showPinButton?: boolean;
|
|
394
|
+
maxPinnedTop?: number;
|
|
395
|
+
maxPinnedBottom?: number;
|
|
396
|
+
onPinChange?: (pinnedTop: (string | number)[], pinnedBottom: (string | number)[]) => void;
|
|
397
|
+
}
|
|
398
|
+
export interface DragRowConfig {
|
|
399
|
+
enabled: boolean;
|
|
400
|
+
showDragHandle?: boolean;
|
|
401
|
+
allowCrossGroup?: boolean;
|
|
402
|
+
allowExternalDrop?: boolean;
|
|
403
|
+
dragHandlePosition?: 'left' | 'right';
|
|
404
|
+
onDragStart?: (row: Row, rowIndex: number) => void;
|
|
405
|
+
onDragEnd?: () => void;
|
|
406
|
+
onRowDrop?: (sourceIndex: number, targetIndex: number, row: Row) => void;
|
|
407
|
+
onRowMove?: (sourceIndex: number, targetIndex: number) => void;
|
|
408
|
+
onExternalDrop?: (data: any, targetIndex: number) => void;
|
|
409
|
+
}
|
|
410
|
+
export interface DragState {
|
|
411
|
+
isDragging: boolean;
|
|
412
|
+
draggedRowId: string | number | null;
|
|
413
|
+
draggedRowIndex: number | null;
|
|
414
|
+
dropTargetIndex: number | null;
|
|
415
|
+
dropPosition: 'before' | 'after' | null;
|
|
416
|
+
}
|
|
417
|
+
export interface MarketDataConfig {
|
|
418
|
+
enabled: boolean;
|
|
419
|
+
flashDuration?: number;
|
|
420
|
+
enableFlash?: boolean;
|
|
421
|
+
enableLiveSorting?: boolean;
|
|
422
|
+
enableRankingMovement?: boolean;
|
|
423
|
+
batchInterval?: number;
|
|
424
|
+
maxUpdatesPerFrame?: number;
|
|
425
|
+
cpuThreshold?: number;
|
|
426
|
+
densityMode?: boolean;
|
|
427
|
+
}
|
|
428
|
+
export interface CellUpdate {
|
|
429
|
+
rowId: string | number;
|
|
430
|
+
field: string;
|
|
431
|
+
oldValue: any;
|
|
432
|
+
newValue: any;
|
|
433
|
+
timestamp: number;
|
|
434
|
+
}
|
|
435
|
+
export interface FlashAnimation {
|
|
436
|
+
cellKey: string;
|
|
437
|
+
direction: 'up' | 'down';
|
|
438
|
+
startTime: number;
|
|
439
|
+
duration: number;
|
|
440
|
+
}
|
|
441
|
+
export interface ContextMenuItem {
|
|
442
|
+
id?: string;
|
|
443
|
+
label: string;
|
|
444
|
+
icon?: React.ReactNode;
|
|
445
|
+
onClick?: () => void;
|
|
446
|
+
disabled?: boolean;
|
|
447
|
+
danger?: boolean;
|
|
448
|
+
type?: 'item' | 'separator';
|
|
449
|
+
shortcut?: string;
|
|
450
|
+
submenu?: ContextMenuItem[];
|
|
451
|
+
}
|
|
452
|
+
export interface ContextMenuConfig {
|
|
453
|
+
enabled?: boolean;
|
|
454
|
+
showCopy?: boolean;
|
|
455
|
+
showExport?: boolean;
|
|
456
|
+
showColumnOptions?: boolean;
|
|
457
|
+
showFilterByValue?: boolean;
|
|
458
|
+
customItems?: ContextMenuItem[];
|
|
459
|
+
onBeforeShow?: (event: ContextMenuEvent) => ContextMenuItem[] | null;
|
|
460
|
+
}
|
|
461
|
+
export interface ContextMenuEvent {
|
|
462
|
+
type: 'cell' | 'header' | 'row';
|
|
463
|
+
row?: Row;
|
|
464
|
+
column?: Column;
|
|
465
|
+
rowIndex?: number;
|
|
466
|
+
columnIndex?: number;
|
|
467
|
+
event: React.MouseEvent;
|
|
468
|
+
}
|
|
469
|
+
export interface ContextMenuProps {
|
|
470
|
+
x: number;
|
|
471
|
+
y: number;
|
|
472
|
+
items: ContextMenuItem[];
|
|
473
|
+
onClose: () => void;
|
|
474
|
+
}
|
|
475
|
+
export interface ContextMenuState {
|
|
476
|
+
isOpen: boolean;
|
|
477
|
+
x: number;
|
|
478
|
+
y: number;
|
|
479
|
+
items: ContextMenuItem[];
|
|
480
|
+
contextType: 'cell' | 'header' | 'row' | null;
|
|
481
|
+
targetRow?: Row;
|
|
482
|
+
targetColumn?: Column;
|
|
483
|
+
targetRowIndex?: number;
|
|
484
|
+
targetColumnIndex?: number;
|
|
485
|
+
}
|
|
486
|
+
export type TooltipPlacement = 'top' | 'bottom' | 'left' | 'right' | 'auto';
|
|
487
|
+
export interface TooltipContent {
|
|
488
|
+
title?: string;
|
|
489
|
+
content: React.ReactNode;
|
|
490
|
+
}
|
|
491
|
+
export interface TooltipConfig {
|
|
492
|
+
enabled?: boolean;
|
|
493
|
+
showDelay?: number;
|
|
494
|
+
hideDelay?: number;
|
|
495
|
+
placement?: TooltipPlacement;
|
|
496
|
+
offset?: number;
|
|
497
|
+
maxWidth?: number;
|
|
498
|
+
showCellTooltips?: boolean;
|
|
499
|
+
showRowTooltips?: boolean;
|
|
500
|
+
getCellTooltip?: (row: Row, column: Column, value: any) => TooltipContent | string | null;
|
|
501
|
+
getRowTooltip?: (row: Row, rowIndex: number) => TooltipContent | string | null;
|
|
502
|
+
}
|
|
503
|
+
export interface TooltipState {
|
|
504
|
+
isVisible: boolean;
|
|
505
|
+
x: number;
|
|
506
|
+
y: number;
|
|
507
|
+
placement: TooltipPlacement;
|
|
508
|
+
content: TooltipContent | null;
|
|
509
|
+
targetRect: DOMRect | null;
|
|
510
|
+
}
|
|
511
|
+
export interface DataGridProps {
|
|
512
|
+
columns: Column[];
|
|
513
|
+
rows: Row[];
|
|
514
|
+
pageSize?: number;
|
|
515
|
+
showColumnPinning?: boolean;
|
|
516
|
+
footerConfig?: FooterConfig;
|
|
517
|
+
virtualScrollConfig?: VirtualScrollConfig;
|
|
518
|
+
persistenceConfig?: PersistenceConfig;
|
|
519
|
+
treeConfig?: TreeConfig;
|
|
520
|
+
dragRowConfig?: DragRowConfig;
|
|
521
|
+
rowPinConfig?: RowPinConfig;
|
|
522
|
+
marketDataConfig?: MarketDataConfig;
|
|
523
|
+
contextMenuConfig?: ContextMenuConfig;
|
|
524
|
+
tooltipConfig?: TooltipConfig;
|
|
525
|
+
tableId?: string;
|
|
526
|
+
theme?: ThemeName;
|
|
527
|
+
densityMode?: DensityMode;
|
|
528
|
+
showDensityToggle?: boolean;
|
|
529
|
+
onDensityChange?: (mode: DensityMode) => void;
|
|
530
|
+
onRowClick?: (row: Row) => void;
|
|
531
|
+
onCellEdit?: (rowIndex: number, field: string, value: any) => void;
|
|
532
|
+
onSelectionChange?: (selectedIds: (string | number)[]) => void;
|
|
533
|
+
onLayoutChange?: (layout: LayoutPreset['layout']) => void;
|
|
534
|
+
onRowReorder?: (rows: Row[]) => void;
|
|
535
|
+
onGridReady?: (api: GridApi) => void;
|
|
536
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ContextMenuState, ContextMenuConfig, ContextMenuEvent, Column, Row, FilterValue } from './types';
|
|
2
|
+
interface UseContextMenuProps {
|
|
3
|
+
config?: ContextMenuConfig;
|
|
4
|
+
columns: Column[];
|
|
5
|
+
rows: Row[];
|
|
6
|
+
selectedRows: Set<string | number>;
|
|
7
|
+
onPinColumn?: (field: string, side: 'left' | 'right') => void;
|
|
8
|
+
onUnpinColumn?: (field: string) => void;
|
|
9
|
+
onToggleColumnVisibility?: (field: string) => void;
|
|
10
|
+
onResizeColumn?: (field: string, width: number) => void;
|
|
11
|
+
onAutoSizeAllColumns?: (widths: {
|
|
12
|
+
[field: string]: number;
|
|
13
|
+
}) => void;
|
|
14
|
+
onSetFilter?: (field: string, value: FilterValue | null) => void;
|
|
15
|
+
onPinRowTop?: (rowId: string | number) => void;
|
|
16
|
+
onPinRowBottom?: (rowId: string | number) => void;
|
|
17
|
+
onUnpinRow?: (rowId: string | number) => void;
|
|
18
|
+
pinnedColumnsLeft?: string[];
|
|
19
|
+
pinnedColumnsRight?: string[];
|
|
20
|
+
pinnedRowsTop?: (string | number)[];
|
|
21
|
+
pinnedRowsBottom?: (string | number)[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Hook to manage context menu state and actions
|
|
25
|
+
*/
|
|
26
|
+
export declare const useContextMenu: ({ config, columns, rows, selectedRows, onPinColumn, onUnpinColumn, onToggleColumnVisibility, onResizeColumn, onAutoSizeAllColumns, onSetFilter, onPinRowTop, onPinRowBottom, onUnpinRow, pinnedColumnsLeft, pinnedColumnsRight, pinnedRowsTop, pinnedRowsBottom, }: UseContextMenuProps) => {
|
|
27
|
+
contextMenu: ContextMenuState;
|
|
28
|
+
handleContextMenu: (event: ContextMenuEvent) => void;
|
|
29
|
+
closeContextMenu: () => void;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { DensityMode } from './densityModes';
|
|
2
|
+
import { getDensityConfig } from './densityModes';
|
|
3
|
+
export interface UseDensityModeOptions {
|
|
4
|
+
initialMode?: DensityMode;
|
|
5
|
+
persist?: boolean;
|
|
6
|
+
persistenceKey?: string;
|
|
7
|
+
onChange?: (mode: DensityMode) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface UseDensityModeReturn {
|
|
10
|
+
densityMode: DensityMode;
|
|
11
|
+
setDensityMode: (mode: DensityMode) => void;
|
|
12
|
+
densityConfig: ReturnType<typeof getDensityConfig>;
|
|
13
|
+
densityStyles: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* useDensityMode Hook
|
|
17
|
+
*
|
|
18
|
+
* Manages density mode state and provides CSS variables for styling.
|
|
19
|
+
* Supports persistence to localStorage.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* const { densityMode, setDensityMode, densityStyles } = useDensityMode({
|
|
24
|
+
* initialMode: 'normal',
|
|
25
|
+
* persist: true
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* return (
|
|
29
|
+
* <div style={densityStyles}>
|
|
30
|
+
* <DensityToggle value={densityMode} onChange={setDensityMode} />
|
|
31
|
+
* <DataGrid ... />
|
|
32
|
+
* </div>
|
|
33
|
+
* );
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function useDensityMode(options?: UseDensityModeOptions): UseDensityModeReturn;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useFocusTrap Hook
|
|
3
|
+
*
|
|
4
|
+
* Traps focus within a container element (useful for modals, dialogs, and popups).
|
|
5
|
+
* Ensures keyboard navigation stays within the trapped area for accessibility.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
export declare const useFocusTrap: (options?: {
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
initialFocus?: "first" | "last" | HTMLElement | null;
|
|
11
|
+
returnFocus?: boolean;
|
|
12
|
+
escapeDeactivates?: boolean;
|
|
13
|
+
onEscape?: () => void;
|
|
14
|
+
}) => React.RefObject<HTMLElement | null>;
|