@xcelsior/ui-spreadsheets 1.0.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.
- package/.storybook/main.ts +27 -0
- package/.storybook/preview.tsx +28 -0
- package/.turbo/turbo-build.log +22 -0
- package/CHANGELOG.md +9 -0
- package/biome.json +3 -0
- package/dist/index.d.mts +687 -0
- package/dist/index.d.ts +687 -0
- package/dist/index.js +3459 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3417 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +51 -0
- package/postcss.config.js +5 -0
- package/src/components/ColorPickerPopover.tsx +73 -0
- package/src/components/ColumnHeaderActions.tsx +139 -0
- package/src/components/CommentModals.tsx +137 -0
- package/src/components/KeyboardShortcutsModal.tsx +119 -0
- package/src/components/RowIndexColumnHeader.tsx +70 -0
- package/src/components/Spreadsheet.stories.tsx +1146 -0
- package/src/components/Spreadsheet.tsx +1005 -0
- package/src/components/SpreadsheetCell.tsx +341 -0
- package/src/components/SpreadsheetFilterDropdown.tsx +341 -0
- package/src/components/SpreadsheetHeader.tsx +111 -0
- package/src/components/SpreadsheetSettingsModal.tsx +555 -0
- package/src/components/SpreadsheetToolbar.tsx +346 -0
- package/src/hooks/index.ts +40 -0
- package/src/hooks/useSpreadsheetComments.ts +132 -0
- package/src/hooks/useSpreadsheetFiltering.ts +379 -0
- package/src/hooks/useSpreadsheetHighlighting.ts +201 -0
- package/src/hooks/useSpreadsheetKeyboardShortcuts.ts +149 -0
- package/src/hooks/useSpreadsheetPinning.ts +203 -0
- package/src/hooks/useSpreadsheetUndoRedo.ts +167 -0
- package/src/index.ts +31 -0
- package/src/types.ts +612 -0
- package/src/utils.ts +16 -0
- package/tsconfig.json +30 -0
- package/tsup.config.ts +12 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,687 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React$1 from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Column definition for the spreadsheet
|
|
6
|
+
*/
|
|
7
|
+
interface SpreadsheetColumn<T = any> {
|
|
8
|
+
/** Unique identifier for the column */
|
|
9
|
+
id: string;
|
|
10
|
+
/** Display label for the column header */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Width of the column in pixels */
|
|
13
|
+
width?: number;
|
|
14
|
+
/** Minimum width of the column in pixels */
|
|
15
|
+
minWidth?: number;
|
|
16
|
+
/** Text alignment */
|
|
17
|
+
align?: 'left' | 'center' | 'right';
|
|
18
|
+
/** Whether the column is sortable */
|
|
19
|
+
sortable?: boolean;
|
|
20
|
+
/** Whether the column is filterable */
|
|
21
|
+
filterable?: boolean;
|
|
22
|
+
/** Whether the column is editable */
|
|
23
|
+
editable?: boolean;
|
|
24
|
+
/** Whether the column can be pinned */
|
|
25
|
+
pinnable?: boolean;
|
|
26
|
+
/** Type of data in the column (for filtering/formatting) */
|
|
27
|
+
type?: 'text' | 'number' | 'date' | 'select' | 'boolean';
|
|
28
|
+
/** Options for select type columns */
|
|
29
|
+
options?: string[];
|
|
30
|
+
/** Custom render function for cell content */
|
|
31
|
+
render?: (value: any, row: T, rowIndex: number) => React$1.ReactNode;
|
|
32
|
+
/** Custom cell value getter */
|
|
33
|
+
getValue?: (row: T) => any;
|
|
34
|
+
/** Group this column belongs to */
|
|
35
|
+
group?: string;
|
|
36
|
+
/** Whether this column is frozen/sticky */
|
|
37
|
+
frozen?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Column group definition
|
|
41
|
+
*/
|
|
42
|
+
interface SpreadsheetColumnGroup {
|
|
43
|
+
/** Unique identifier for the group */
|
|
44
|
+
id: string;
|
|
45
|
+
/** Display label for the group header */
|
|
46
|
+
label: string;
|
|
47
|
+
/** Column IDs in this group */
|
|
48
|
+
columns: string[];
|
|
49
|
+
/** Whether the group is collapsible */
|
|
50
|
+
collapsible?: boolean;
|
|
51
|
+
/** Background color for the group header */
|
|
52
|
+
headerColor?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Sort configuration
|
|
56
|
+
*/
|
|
57
|
+
interface SpreadsheetSortConfig {
|
|
58
|
+
/** Column ID to sort by */
|
|
59
|
+
columnId: string;
|
|
60
|
+
/** Sort direction */
|
|
61
|
+
direction: 'asc' | 'desc';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Text filter operator types for Excel-like filtering
|
|
65
|
+
*/
|
|
66
|
+
type TextFilterOperator = 'contains' | 'notContains' | 'equals' | 'notEquals' | 'startsWith' | 'endsWith' | 'isEmpty' | 'isNotEmpty';
|
|
67
|
+
/**
|
|
68
|
+
* Number filter operator types for Excel-like filtering
|
|
69
|
+
*/
|
|
70
|
+
type NumberFilterOperator = 'equals' | 'notEquals' | 'greaterThan' | 'greaterThanOrEqual' | 'lessThan' | 'lessThanOrEqual' | 'between' | 'isEmpty' | 'isNotEmpty';
|
|
71
|
+
/**
|
|
72
|
+
* Date filter operator types for Excel-like filtering
|
|
73
|
+
*/
|
|
74
|
+
type DateFilterOperator = 'equals' | 'notEquals' | 'before' | 'after' | 'between' | 'today' | 'yesterday' | 'thisWeek' | 'lastWeek' | 'thisMonth' | 'lastMonth' | 'thisYear' | 'isEmpty' | 'isNotEmpty';
|
|
75
|
+
/**
|
|
76
|
+
* Text filter condition
|
|
77
|
+
*/
|
|
78
|
+
interface TextFilterCondition {
|
|
79
|
+
operator: TextFilterOperator;
|
|
80
|
+
value?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Number filter condition
|
|
84
|
+
*/
|
|
85
|
+
interface NumberFilterCondition {
|
|
86
|
+
operator: NumberFilterOperator;
|
|
87
|
+
value?: number;
|
|
88
|
+
valueTo?: number;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Date filter condition
|
|
92
|
+
*/
|
|
93
|
+
interface DateFilterCondition {
|
|
94
|
+
operator: DateFilterOperator;
|
|
95
|
+
value?: string;
|
|
96
|
+
valueTo?: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Filter configuration for a single column
|
|
100
|
+
*/
|
|
101
|
+
interface SpreadsheetColumnFilter {
|
|
102
|
+
/** Text search filter (legacy, still supported) */
|
|
103
|
+
text?: string;
|
|
104
|
+
/** Minimum value for range filtering (legacy, still supported) */
|
|
105
|
+
min?: string | number;
|
|
106
|
+
/** Maximum value for range filtering (legacy, still supported) */
|
|
107
|
+
max?: string | number;
|
|
108
|
+
/** Selected values for multi-select filtering */
|
|
109
|
+
selectedValues?: string[];
|
|
110
|
+
/** Text filter condition for advanced filtering */
|
|
111
|
+
textCondition?: TextFilterCondition;
|
|
112
|
+
/** Number filter condition for advanced filtering */
|
|
113
|
+
numberCondition?: NumberFilterCondition;
|
|
114
|
+
/** Date filter condition for advanced filtering */
|
|
115
|
+
dateCondition?: DateFilterCondition;
|
|
116
|
+
/** Include blank/empty values */
|
|
117
|
+
includeBlanks?: boolean;
|
|
118
|
+
/** Exclude blank/empty values */
|
|
119
|
+
excludeBlanks?: boolean;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Cell position identifier
|
|
123
|
+
*/
|
|
124
|
+
interface CellPosition {
|
|
125
|
+
/** Row ID or index */
|
|
126
|
+
rowId: string | number;
|
|
127
|
+
/** Column ID */
|
|
128
|
+
columnId: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Cell highlight configuration
|
|
132
|
+
*/
|
|
133
|
+
interface CellHighlight {
|
|
134
|
+
/** Row ID (optional for column highlights) */
|
|
135
|
+
rowId?: string | number;
|
|
136
|
+
/** Column ID (optional for row highlights) */
|
|
137
|
+
columnId?: string;
|
|
138
|
+
/** Highlight color */
|
|
139
|
+
color: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Cell comment
|
|
143
|
+
*/
|
|
144
|
+
interface CellComment {
|
|
145
|
+
/** Unique ID */
|
|
146
|
+
id: string;
|
|
147
|
+
/** Row ID */
|
|
148
|
+
rowId: string | number;
|
|
149
|
+
/** Column ID (optional for row comments) */
|
|
150
|
+
columnId?: string;
|
|
151
|
+
/** Comment text */
|
|
152
|
+
text: string;
|
|
153
|
+
/** Author name */
|
|
154
|
+
author?: string;
|
|
155
|
+
/** Timestamp */
|
|
156
|
+
timestamp: Date;
|
|
157
|
+
/** Whether the comment is resolved */
|
|
158
|
+
resolved?: boolean;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Selection state
|
|
162
|
+
*/
|
|
163
|
+
interface SelectionState {
|
|
164
|
+
/** Selected row IDs */
|
|
165
|
+
selectedRows: Set<string | number>;
|
|
166
|
+
/** Focused cell position */
|
|
167
|
+
focusedCell: CellPosition | null;
|
|
168
|
+
/** Last selected row (for shift-click range selection) */
|
|
169
|
+
lastSelectedRow: string | number | null;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Pagination state
|
|
173
|
+
*/
|
|
174
|
+
interface PaginationState {
|
|
175
|
+
/** Current page (1-indexed) */
|
|
176
|
+
currentPage: number;
|
|
177
|
+
/** Number of rows per page */
|
|
178
|
+
pageSize: number;
|
|
179
|
+
/** Total number of rows */
|
|
180
|
+
totalRows: number;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Spreadsheet state
|
|
184
|
+
*/
|
|
185
|
+
interface SpreadsheetState<T = any> {
|
|
186
|
+
/** All data rows */
|
|
187
|
+
data: T[];
|
|
188
|
+
/** Column definitions */
|
|
189
|
+
columns: SpreadsheetColumn<T>[];
|
|
190
|
+
/** Column groups */
|
|
191
|
+
columnGroups?: SpreadsheetColumnGroup[];
|
|
192
|
+
/** Current sort configuration */
|
|
193
|
+
sortConfig: SpreadsheetSortConfig | null;
|
|
194
|
+
/** Column filters */
|
|
195
|
+
filters: Record<string, SpreadsheetColumnFilter>;
|
|
196
|
+
/** Selection state */
|
|
197
|
+
selection: SelectionState;
|
|
198
|
+
/** Pagination state */
|
|
199
|
+
pagination: PaginationState;
|
|
200
|
+
/** Collapsed column groups */
|
|
201
|
+
collapsedGroups: Set<string>;
|
|
202
|
+
/** Pinned columns */
|
|
203
|
+
pinnedColumns: Map<string, 'left' | 'right'>;
|
|
204
|
+
/** Cell highlights */
|
|
205
|
+
highlights: CellHighlight[];
|
|
206
|
+
/** Cell comments */
|
|
207
|
+
comments: CellComment[];
|
|
208
|
+
/** Zoom level (percentage) */
|
|
209
|
+
zoom: number;
|
|
210
|
+
/** Whether there are unsaved changes */
|
|
211
|
+
hasUnsavedChanges: boolean;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Row action configuration
|
|
215
|
+
*/
|
|
216
|
+
interface RowAction<T = any> {
|
|
217
|
+
/** Unique identifier */
|
|
218
|
+
id: string;
|
|
219
|
+
/** Icon component */
|
|
220
|
+
icon: React$1.ReactNode;
|
|
221
|
+
/** Tooltip text */
|
|
222
|
+
tooltip: string;
|
|
223
|
+
/** Callback when action is clicked */
|
|
224
|
+
onClick: (row: T, rowId: string | number) => void;
|
|
225
|
+
/** Whether the action is visible */
|
|
226
|
+
visible?: (row: T) => boolean;
|
|
227
|
+
/** Custom className */
|
|
228
|
+
className?: string;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Props for the main Spreadsheet component
|
|
232
|
+
*/
|
|
233
|
+
interface SpreadsheetProps<T = any> {
|
|
234
|
+
/** Data rows */
|
|
235
|
+
data: T[];
|
|
236
|
+
/** Column definitions */
|
|
237
|
+
columns: SpreadsheetColumn<T>[];
|
|
238
|
+
/** Column groups */
|
|
239
|
+
columnGroups?: SpreadsheetColumnGroup[];
|
|
240
|
+
/** Unique key accessor for each row */
|
|
241
|
+
getRowId: (row: T) => string | number;
|
|
242
|
+
/** Callback when a cell value is edited */
|
|
243
|
+
onCellEdit?: (rowId: string | number, columnId: string, newValue: any) => void;
|
|
244
|
+
/** Callback when selection changes */
|
|
245
|
+
onSelectionChange?: (selectedRows: (string | number)[]) => void;
|
|
246
|
+
/** Callback when sort changes */
|
|
247
|
+
onSortChange?: (sortConfig: SpreadsheetSortConfig | null) => void;
|
|
248
|
+
/** Callback when filters change */
|
|
249
|
+
onFilterChange?: (filters: Record<string, SpreadsheetColumnFilter>) => void;
|
|
250
|
+
/** Callback for row click */
|
|
251
|
+
onRowClick?: (row: T, rowIndex: number) => void;
|
|
252
|
+
/** Callback for row double click */
|
|
253
|
+
onRowDoubleClick?: (row: T, rowIndex: number) => void;
|
|
254
|
+
/** Callback when a row is cloned/duplicated */
|
|
255
|
+
onRowClone?: (row: T, rowId: string | number) => void;
|
|
256
|
+
/** Callback when a row comment is added */
|
|
257
|
+
onAddRowComment?: (rowId: string | number, comment: string) => void;
|
|
258
|
+
/** Callback when row highlight is toggled */
|
|
259
|
+
onRowHighlight?: (rowId: string | number, color: string | null) => void;
|
|
260
|
+
/** Whether to show the toolbar */
|
|
261
|
+
showToolbar?: boolean;
|
|
262
|
+
/** Whether to show pagination */
|
|
263
|
+
showPagination?: boolean;
|
|
264
|
+
/** Whether to show row index column (#) */
|
|
265
|
+
showRowIndex?: boolean;
|
|
266
|
+
/** Whether to enable row selection */
|
|
267
|
+
enableRowSelection?: boolean;
|
|
268
|
+
/** Whether to enable cell editing */
|
|
269
|
+
enableCellEditing?: boolean;
|
|
270
|
+
/** Whether to enable cell comments */
|
|
271
|
+
enableComments?: boolean;
|
|
272
|
+
/** Whether to enable cell highlighting */
|
|
273
|
+
enableHighlighting?: boolean;
|
|
274
|
+
/** Whether to enable undo/redo */
|
|
275
|
+
enableUndoRedo?: boolean;
|
|
276
|
+
/** Initial page size */
|
|
277
|
+
defaultPageSize?: number;
|
|
278
|
+
/** Available page size options */
|
|
279
|
+
pageSizeOptions?: number[];
|
|
280
|
+
/** Initial zoom level */
|
|
281
|
+
defaultZoom?: number;
|
|
282
|
+
/** Whether to auto-save changes */
|
|
283
|
+
autoSave?: boolean;
|
|
284
|
+
/** Whether to use compact mode (smaller cells) */
|
|
285
|
+
compactMode?: boolean;
|
|
286
|
+
/** Loading state */
|
|
287
|
+
isLoading?: boolean;
|
|
288
|
+
/** Custom className */
|
|
289
|
+
className?: string;
|
|
290
|
+
/** Empty state message */
|
|
291
|
+
emptyMessage?: string;
|
|
292
|
+
/** Row highlights (externally controlled) */
|
|
293
|
+
rowHighlights?: CellHighlight[];
|
|
294
|
+
/** Row comments (externally controlled) */
|
|
295
|
+
rowComments?: CellComment[];
|
|
296
|
+
/** Custom row actions to display in the index column */
|
|
297
|
+
rowActions?: RowAction<T>[];
|
|
298
|
+
/**
|
|
299
|
+
* Enable server-side mode for filtering, sorting, and pagination.
|
|
300
|
+
* When enabled, the component will NOT perform client-side filtering, sorting, or pagination.
|
|
301
|
+
* Instead, it expects the `data` prop to already be filtered, sorted, and paginated by the server.
|
|
302
|
+
* @default false
|
|
303
|
+
*/
|
|
304
|
+
serverSide?: boolean;
|
|
305
|
+
/**
|
|
306
|
+
* Total number of items (required when serverSide is true).
|
|
307
|
+
* Used to calculate pagination correctly when data is paginated server-side.
|
|
308
|
+
*/
|
|
309
|
+
totalItems?: number;
|
|
310
|
+
/**
|
|
311
|
+
* Controlled current page (1-indexed). Use with serverSide mode for controlled pagination.
|
|
312
|
+
* When provided, the component becomes controlled for pagination.
|
|
313
|
+
*/
|
|
314
|
+
currentPage?: number;
|
|
315
|
+
/**
|
|
316
|
+
* Controlled page size. Use with serverSide mode for controlled pagination.
|
|
317
|
+
* When provided along with currentPage, pagination becomes fully controlled.
|
|
318
|
+
*/
|
|
319
|
+
pageSize?: number;
|
|
320
|
+
/**
|
|
321
|
+
* Callback when page changes. Required for serverSide pagination to work.
|
|
322
|
+
* Called with (page: number, pageSize: number) when the user changes pages or page size.
|
|
323
|
+
*/
|
|
324
|
+
onPageChange?: (page: number, pageSize: number) => void;
|
|
325
|
+
/**
|
|
326
|
+
* Controlled sort configuration. Use with serverSide mode for controlled sorting.
|
|
327
|
+
* When provided, sorting becomes controlled by the parent component.
|
|
328
|
+
*/
|
|
329
|
+
sortConfig?: SpreadsheetSortConfig | null;
|
|
330
|
+
/**
|
|
331
|
+
* Controlled filters. Use with serverSide mode for controlled filtering.
|
|
332
|
+
* When provided, filtering becomes controlled by the parent component.
|
|
333
|
+
*/
|
|
334
|
+
filters?: Record<string, SpreadsheetColumnFilter>;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Props for SpreadsheetCell component
|
|
338
|
+
*/
|
|
339
|
+
interface SpreadsheetCellProps {
|
|
340
|
+
/** Cell value */
|
|
341
|
+
value: any;
|
|
342
|
+
/** Column definition */
|
|
343
|
+
column: SpreadsheetColumn;
|
|
344
|
+
/** Row data */
|
|
345
|
+
row: any;
|
|
346
|
+
/** Row index */
|
|
347
|
+
rowIndex: number;
|
|
348
|
+
/** Row ID */
|
|
349
|
+
rowId: string | number;
|
|
350
|
+
/** Whether the cell is editable */
|
|
351
|
+
isEditable?: boolean;
|
|
352
|
+
/** Whether the cell is currently being edited */
|
|
353
|
+
isEditing?: boolean;
|
|
354
|
+
/** Whether the cell is focused */
|
|
355
|
+
isFocused?: boolean;
|
|
356
|
+
/** Whether the row is selected */
|
|
357
|
+
isRowSelected?: boolean;
|
|
358
|
+
/** Whether the row is hovered */
|
|
359
|
+
isRowHovered?: boolean;
|
|
360
|
+
/** Highlight color */
|
|
361
|
+
highlightColor?: string;
|
|
362
|
+
/** Whether the cell has comments */
|
|
363
|
+
hasComments?: boolean;
|
|
364
|
+
/** Number of unresolved comments */
|
|
365
|
+
unresolvedCommentCount?: number;
|
|
366
|
+
/** Whether the cell was recently copied */
|
|
367
|
+
isCopied?: boolean;
|
|
368
|
+
/** Compact mode */
|
|
369
|
+
compactMode?: boolean;
|
|
370
|
+
/** Whether the column is pinned */
|
|
371
|
+
isPinned?: boolean;
|
|
372
|
+
/** Pin side */
|
|
373
|
+
pinSide?: 'left' | 'right';
|
|
374
|
+
/** Left offset for sticky positioning */
|
|
375
|
+
leftOffset?: number;
|
|
376
|
+
/** Right offset for sticky positioning */
|
|
377
|
+
rightOffset?: number;
|
|
378
|
+
/** Callback when cell is clicked */
|
|
379
|
+
onClick?: (event: React$1.MouseEvent) => void;
|
|
380
|
+
/** Callback when cell value changes */
|
|
381
|
+
onChange?: (newValue: any) => void;
|
|
382
|
+
/** Callback when editing is confirmed */
|
|
383
|
+
onConfirm?: () => void;
|
|
384
|
+
/** Callback when editing is cancelled */
|
|
385
|
+
onCancel?: () => void;
|
|
386
|
+
/** Callback to copy value down */
|
|
387
|
+
onCopyDown?: () => void;
|
|
388
|
+
/** Callback to copy to selected rows */
|
|
389
|
+
onCopyToSelected?: () => void;
|
|
390
|
+
/** Callback to add highlight */
|
|
391
|
+
onHighlight?: () => void;
|
|
392
|
+
/** Callback to add comment */
|
|
393
|
+
onAddComment?: () => void;
|
|
394
|
+
/** Callback to view comments */
|
|
395
|
+
onViewComments?: () => void;
|
|
396
|
+
/** Whether there are selected rows (for showing copy to selected button) */
|
|
397
|
+
hasSelectedRows?: boolean;
|
|
398
|
+
/** Custom className */
|
|
399
|
+
className?: string;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Props for SpreadsheetHeader component
|
|
403
|
+
*/
|
|
404
|
+
interface SpreadsheetHeaderProps {
|
|
405
|
+
/** Column definition */
|
|
406
|
+
column: SpreadsheetColumn;
|
|
407
|
+
/** Current sort configuration */
|
|
408
|
+
sortConfig: SpreadsheetSortConfig | null;
|
|
409
|
+
/** Whether the column has active filters */
|
|
410
|
+
hasActiveFilter?: boolean;
|
|
411
|
+
/** Whether the column is pinned */
|
|
412
|
+
isPinned?: boolean;
|
|
413
|
+
/** Pin side */
|
|
414
|
+
pinSide?: 'left' | 'right';
|
|
415
|
+
/** Left offset for sticky positioning */
|
|
416
|
+
leftOffset?: number;
|
|
417
|
+
/** Right offset for sticky positioning */
|
|
418
|
+
rightOffset?: number;
|
|
419
|
+
/** Highlight color */
|
|
420
|
+
highlightColor?: string;
|
|
421
|
+
/** Compact mode */
|
|
422
|
+
compactMode?: boolean;
|
|
423
|
+
/** Callback when column header is clicked (sorting) */
|
|
424
|
+
onClick?: () => void;
|
|
425
|
+
/** Callback to toggle filter dropdown */
|
|
426
|
+
onFilterClick?: () => void;
|
|
427
|
+
/** Callback to toggle pin */
|
|
428
|
+
onPinClick?: () => void;
|
|
429
|
+
/** Callback to highlight column */
|
|
430
|
+
onHighlightClick?: () => void;
|
|
431
|
+
/** Custom className */
|
|
432
|
+
className?: string;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Props for SpreadsheetFilterDropdown component
|
|
436
|
+
*/
|
|
437
|
+
interface SpreadsheetFilterDropdownProps {
|
|
438
|
+
/** Column definition */
|
|
439
|
+
column: SpreadsheetColumn;
|
|
440
|
+
/** Current filter value */
|
|
441
|
+
filter?: SpreadsheetColumnFilter;
|
|
442
|
+
/** All unique values in the column (for select filter) - optional, not currently used */
|
|
443
|
+
uniqueValues?: string[];
|
|
444
|
+
/** Callback when filter changes */
|
|
445
|
+
onFilterChange: (filter: SpreadsheetColumnFilter | undefined) => void;
|
|
446
|
+
/** Callback to close dropdown */
|
|
447
|
+
onClose: () => void;
|
|
448
|
+
/** Custom className */
|
|
449
|
+
className?: string;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Props for SpreadsheetToolbar component
|
|
453
|
+
*/
|
|
454
|
+
interface SpreadsheetToolbarProps {
|
|
455
|
+
/** Current zoom level */
|
|
456
|
+
zoom: number;
|
|
457
|
+
/** Whether undo is available */
|
|
458
|
+
canUndo: boolean;
|
|
459
|
+
/** Whether redo is available */
|
|
460
|
+
canRedo: boolean;
|
|
461
|
+
/** Number of undo actions available */
|
|
462
|
+
undoCount?: number;
|
|
463
|
+
/** Number of redo actions available */
|
|
464
|
+
redoCount?: number;
|
|
465
|
+
/** Number of selected rows */
|
|
466
|
+
selectedRowCount: number;
|
|
467
|
+
/** Whether there are unsaved changes */
|
|
468
|
+
hasUnsavedChanges: boolean;
|
|
469
|
+
/** Save status */
|
|
470
|
+
saveStatus: 'saved' | 'saving' | 'unsaved' | 'error';
|
|
471
|
+
/** Whether auto-save is enabled */
|
|
472
|
+
autoSave: boolean;
|
|
473
|
+
/** Summary data to display */
|
|
474
|
+
summary?: {
|
|
475
|
+
label: string;
|
|
476
|
+
value: string | number;
|
|
477
|
+
variant?: 'success' | 'danger' | 'warning' | 'info';
|
|
478
|
+
};
|
|
479
|
+
/** Callback for zoom in */
|
|
480
|
+
onZoomIn: () => void;
|
|
481
|
+
/** Callback for zoom out */
|
|
482
|
+
onZoomOut: () => void;
|
|
483
|
+
/** Callback for zoom reset */
|
|
484
|
+
onZoomReset: () => void;
|
|
485
|
+
/** Callback for undo */
|
|
486
|
+
onUndo: () => void;
|
|
487
|
+
/** Callback for redo */
|
|
488
|
+
onRedo: () => void;
|
|
489
|
+
/** Callback for clear selection */
|
|
490
|
+
onClearSelection: () => void;
|
|
491
|
+
/** Callback for manual save */
|
|
492
|
+
onSave?: () => void;
|
|
493
|
+
/** Callback for export */
|
|
494
|
+
onExport?: () => void;
|
|
495
|
+
/** Callback for settings */
|
|
496
|
+
onSettings?: () => void;
|
|
497
|
+
/** Callback for keyboard shortcuts */
|
|
498
|
+
onShowShortcuts?: () => void;
|
|
499
|
+
/** Whether there are active filters */
|
|
500
|
+
hasActiveFilters?: boolean;
|
|
501
|
+
/** Callback to clear all filters */
|
|
502
|
+
onClearFilters?: () => void;
|
|
503
|
+
/** Custom className */
|
|
504
|
+
className?: string;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Props for SpreadsheetColumnGroupHeader component
|
|
508
|
+
*/
|
|
509
|
+
interface SpreadsheetColumnGroupHeaderProps {
|
|
510
|
+
/** Group definition */
|
|
511
|
+
group: SpreadsheetColumnGroup;
|
|
512
|
+
/** Number of visible columns in the group */
|
|
513
|
+
colSpan: number;
|
|
514
|
+
/** Whether the group is collapsed */
|
|
515
|
+
isCollapsed: boolean;
|
|
516
|
+
/** Callback to toggle collapse */
|
|
517
|
+
onToggleCollapse: () => void;
|
|
518
|
+
/** Custom className */
|
|
519
|
+
className?: string;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Spreadsheet component - A feature-rich data grid with Excel-like functionality.
|
|
524
|
+
*
|
|
525
|
+
* Features:
|
|
526
|
+
* - Sortable columns
|
|
527
|
+
* - Filterable columns (text search, multi-select, range)
|
|
528
|
+
* - Inline cell editing
|
|
529
|
+
* - Row selection (single, multi, range)
|
|
530
|
+
* - Column pinning
|
|
531
|
+
* - Column grouping with collapse
|
|
532
|
+
* - Pagination
|
|
533
|
+
* - Zoom controls
|
|
534
|
+
* - Undo/Redo
|
|
535
|
+
* - Cell highlighting
|
|
536
|
+
* - Keyboard navigation
|
|
537
|
+
*
|
|
538
|
+
* @example
|
|
539
|
+
* ```tsx
|
|
540
|
+
* const columns = [
|
|
541
|
+
* { id: 'name', label: 'Name', sortable: true, filterable: true },
|
|
542
|
+
* { id: 'email', label: 'Email', editable: true },
|
|
543
|
+
* { id: 'status', label: 'Status', type: 'select', options: ['Active', 'Inactive'] },
|
|
544
|
+
* ];
|
|
545
|
+
*
|
|
546
|
+
* <Spreadsheet
|
|
547
|
+
* data={users}
|
|
548
|
+
* columns={columns}
|
|
549
|
+
* getRowId={(row) => row.id}
|
|
550
|
+
* onCellEdit={(rowId, columnId, value) => handleEdit(rowId, columnId, value)}
|
|
551
|
+
* showToolbar
|
|
552
|
+
* showPagination
|
|
553
|
+
* enableRowSelection
|
|
554
|
+
* />
|
|
555
|
+
* ```
|
|
556
|
+
*/
|
|
557
|
+
declare function Spreadsheet<T extends Record<string, any>>({ data, columns, columnGroups, getRowId, onCellEdit, onSelectionChange, onSortChange, onFilterChange, onRowClick, onRowDoubleClick, onRowClone, onAddRowComment, onRowHighlight, showToolbar, showPagination, showRowIndex, enableRowSelection, enableCellEditing, enableComments, enableHighlighting, enableUndoRedo, defaultPageSize, pageSizeOptions, defaultZoom, autoSave, compactMode, isLoading, className, emptyMessage, rowHighlights: externalRowHighlights, rowComments: externalRowComments, rowActions, serverSide, totalItems, currentPage: controlledCurrentPage, pageSize: controlledPageSize, onPageChange, sortConfig: controlledSortConfig, filters: controlledFilters, }: SpreadsheetProps<T>): react_jsx_runtime.JSX.Element;
|
|
558
|
+
declare namespace Spreadsheet {
|
|
559
|
+
var displayName: string;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* SpreadsheetCell component - A single cell in the spreadsheet table.
|
|
564
|
+
* Supports static display, inline editing, and various cell interactions.
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* ```tsx
|
|
568
|
+
* <SpreadsheetCell
|
|
569
|
+
* value="John Doe"
|
|
570
|
+
* column={{ id: 'name', label: 'Name', editable: true }}
|
|
571
|
+
* row={rowData}
|
|
572
|
+
* rowIndex={0}
|
|
573
|
+
* rowId="1"
|
|
574
|
+
* isEditable={true}
|
|
575
|
+
* onClick={handleClick}
|
|
576
|
+
* onChange={handleChange}
|
|
577
|
+
* />
|
|
578
|
+
* ```
|
|
579
|
+
*/
|
|
580
|
+
declare const SpreadsheetCell: React$1.FC<SpreadsheetCellProps>;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* SpreadsheetHeader component - A column header cell with sorting, filtering, and pinning capabilities.
|
|
584
|
+
*
|
|
585
|
+
* @example
|
|
586
|
+
* ```tsx
|
|
587
|
+
* <SpreadsheetHeader
|
|
588
|
+
* column={{ id: 'name', label: 'Name', sortable: true }}
|
|
589
|
+
* sortConfig={{ columnId: 'name', direction: 'asc' }}
|
|
590
|
+
* onClick={() => handleSort('name')}
|
|
591
|
+
* onFilterClick={() => setActiveFilter('name')}
|
|
592
|
+
* />
|
|
593
|
+
* ```
|
|
594
|
+
*/
|
|
595
|
+
declare const SpreadsheetHeader: React$1.FC<SpreadsheetHeaderProps & {
|
|
596
|
+
children?: React$1.ReactNode;
|
|
597
|
+
}>;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* SpreadsheetFilterDropdown component - Condition-based filter dropdown for columns.
|
|
601
|
+
* Supports text conditions, number conditions, and date conditions.
|
|
602
|
+
*/
|
|
603
|
+
declare const SpreadsheetFilterDropdown: React$1.FC<SpreadsheetFilterDropdownProps>;
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* SpreadsheetToolbar component - Top toolbar with zoom controls, undo/redo, filters, and actions.
|
|
607
|
+
*
|
|
608
|
+
* @example
|
|
609
|
+
* ```tsx
|
|
610
|
+
* <SpreadsheetToolbar
|
|
611
|
+
* zoom={100}
|
|
612
|
+
* canUndo={true}
|
|
613
|
+
* canRedo={false}
|
|
614
|
+
* selectedRowCount={3}
|
|
615
|
+
* showFilters={false}
|
|
616
|
+
* hasUnsavedChanges={false}
|
|
617
|
+
* saveStatus="saved"
|
|
618
|
+
* autoSave={true}
|
|
619
|
+
* onZoomIn={() => setZoom(zoom + 10)}
|
|
620
|
+
* onZoomOut={() => setZoom(zoom - 10)}
|
|
621
|
+
* onZoomReset={() => setZoom(100)}
|
|
622
|
+
* onUndo={handleUndo}
|
|
623
|
+
* onRedo={handleRedo}
|
|
624
|
+
* onToggleFilters={() => setShowFilters(!showFilters)}
|
|
625
|
+
* onClearSelection={() => setSelectedRows(new Set())}
|
|
626
|
+
* />
|
|
627
|
+
* ```
|
|
628
|
+
*/
|
|
629
|
+
declare const SpreadsheetToolbar: React$1.FC<SpreadsheetToolbarProps>;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Settings configuration for the Spreadsheet
|
|
633
|
+
*/
|
|
634
|
+
interface SpreadsheetSettings {
|
|
635
|
+
/** Default pinned column IDs */
|
|
636
|
+
defaultPinnedColumns: string[];
|
|
637
|
+
/** Default sort configuration */
|
|
638
|
+
defaultSort: SpreadsheetSortConfig | null;
|
|
639
|
+
/** Default page size */
|
|
640
|
+
defaultPageSize: number;
|
|
641
|
+
/** Default zoom level */
|
|
642
|
+
defaultZoom: number;
|
|
643
|
+
/** Whether auto-save is enabled */
|
|
644
|
+
autoSave: boolean;
|
|
645
|
+
/** Whether compact view is enabled */
|
|
646
|
+
compactView: boolean;
|
|
647
|
+
/** Whether to show row index column */
|
|
648
|
+
showRowIndex?: boolean;
|
|
649
|
+
/** Whether row index column is pinned */
|
|
650
|
+
pinRowIndex?: boolean;
|
|
651
|
+
/** Row index column highlight color */
|
|
652
|
+
rowIndexHighlightColor?: string;
|
|
653
|
+
}
|
|
654
|
+
interface SpreadsheetSettingsModalProps {
|
|
655
|
+
/** Whether the modal is open */
|
|
656
|
+
isOpen: boolean;
|
|
657
|
+
/** Callback to close the modal */
|
|
658
|
+
onClose: () => void;
|
|
659
|
+
/** Current settings */
|
|
660
|
+
settings: SpreadsheetSettings;
|
|
661
|
+
/** Callback to save settings */
|
|
662
|
+
onSave: (settings: SpreadsheetSettings) => void;
|
|
663
|
+
/** Available columns for pinning/sorting */
|
|
664
|
+
columns: SpreadsheetColumn[];
|
|
665
|
+
/** Title for the modal */
|
|
666
|
+
title?: string;
|
|
667
|
+
/** Available page size options */
|
|
668
|
+
pageSizeOptions?: number[];
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* SpreadsheetSettingsModal - A generic settings modal for configuring spreadsheet options.
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* ```tsx
|
|
675
|
+
* <SpreadsheetSettingsModal
|
|
676
|
+
* isOpen={showSettings}
|
|
677
|
+
* onClose={() => setShowSettings(false)}
|
|
678
|
+
* settings={currentSettings}
|
|
679
|
+
* onSave={(newSettings) => setSettings(newSettings)}
|
|
680
|
+
* columns={columns}
|
|
681
|
+
* title="Spreadsheet Settings"
|
|
682
|
+
* />
|
|
683
|
+
* ```
|
|
684
|
+
*/
|
|
685
|
+
declare const SpreadsheetSettingsModal: React.FC<SpreadsheetSettingsModalProps>;
|
|
686
|
+
|
|
687
|
+
export { type CellComment, type CellHighlight, type CellPosition, type PaginationState, type RowAction, type SelectionState, Spreadsheet, SpreadsheetCell, type SpreadsheetCellProps, type SpreadsheetColumn, type SpreadsheetColumnFilter, type SpreadsheetColumnGroup, type SpreadsheetColumnGroupHeaderProps, SpreadsheetFilterDropdown, type SpreadsheetFilterDropdownProps, SpreadsheetHeader, type SpreadsheetHeaderProps, type SpreadsheetProps, type SpreadsheetSettings, SpreadsheetSettingsModal, type SpreadsheetSortConfig, type SpreadsheetState, SpreadsheetToolbar, type SpreadsheetToolbarProps };
|