@gp-grid/react 0.7.4 → 0.8.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/dist/index.d.ts CHANGED
@@ -1,1302 +1,24 @@
1
1
  import React$1 from "react";
2
+ import { CellDataType, CellPosition, CellRange, CellRendererParams, CellRendererParams as CellRendererParams$1, CellValue, CellValue as CellValue$1, CellValueChangedEvent, CellValueChangedEvent as CellValueChangedEvent$1, ColumnDefinition, ColumnDefinition as ColumnDefinition$1, ColumnFilterModel, DataSource, DataSource as DataSource$1, DataSourceRequest, DataSourceResponse, EditRendererParams, EditRendererParams as EditRendererParams$1, FilterCondition, FilterModel, GridCore, GridCore as GridCore$1, GridInstruction, HeaderRendererParams, HeaderRendererParams as HeaderRendererParams$1, HighlightingOptions, MutableDataSource, MutableDataSource as MutableDataSource$1, ParallelSortOptions, Row, Row as Row$1, RowId, RowId as RowId$1, SortDirection, SortModel, createClientDataSource, createDataSourceFromArray, createMutableClientDataSource, createServerDataSource } from "@gp-grid/core";
2
3
 
3
- //#region ../core/src/types/basic.d.ts
4
- /** Cell data type primitive types */
5
- type CellDataType = "text" | "number" | "boolean" | "date" | "dateString" | "dateTime" | "dateTimeString" | "object";
6
- /** Cell value type */
7
- type CellValue = string | number | boolean | Date | object | null;
8
- /** Row type */
9
- type Row = unknown;
10
- /** Row ID type for transaction operations */
11
- type RowId = string | number;
12
- /** Sort direction type */
13
- type SortDirection = "asc" | "desc";
14
- /** Sort model type */
15
- type SortModel = {
16
- colId: string;
17
- direction: SortDirection;
18
- };
19
- /** Cell position */
20
- interface CellPosition {
21
- row: number;
22
- col: number;
23
- }
24
- /** Cell range */
25
- interface CellRange {
26
- startRow: number;
27
- startCol: number;
28
- endRow: number;
29
- endCol: number;
30
- }
31
- /** Selection state */
32
- interface SelectionState {
33
- /** Active cell position */
34
- activeCell: CellPosition | null;
35
- /** Selection range */
36
- range: CellRange | null;
37
- /** Anchor cell for shift-extend selection */
38
- anchor: CellPosition | null;
39
- /** Whether selection mode is active (ctrl held) */
40
- selectionMode: boolean;
41
- }
42
- /** Edit state */
43
- interface EditState {
44
- /** Row index */
45
- row: number;
46
- /** Column index */
47
- col: number;
48
- /** Initial value */
49
- initialValue: CellValue;
50
- /** Current value */
51
- currentValue: CellValue;
52
- }
53
- /** Fill handle state */
54
- interface FillHandleState {
55
- /** Source range */
56
- sourceRange: CellRange;
57
- /** Target row */
58
- targetRow: number;
59
- /** Target column */
60
- targetCol: number;
61
- }
62
- //#endregion
63
- //#region ../core/src/types/highlighting.d.ts
64
- /**
65
- * Minimal column info for highlighting context.
66
- * Uses structural typing to avoid circular dependency with columns.ts.
67
- */
68
- interface HighlightColumnInfo {
69
- field: string;
70
- colId?: string;
71
- }
72
- /**
73
- * Unified context for row, column, and cell highlighting.
74
- *
75
- * - Row context: `rowIndex` is set, `colIndex` is null
76
- * - Column context: `colIndex` is set, `rowIndex` is null
77
- * - Cell context: both `rowIndex` and `colIndex` are set
78
- */
79
- interface HighlightContext<TData = Record<string, unknown>> {
80
- /** Row index. Null for column-only context. */
81
- rowIndex: number | null;
82
- /** Column index. Null for row-only context. */
83
- colIndex: number | null;
84
- /** Column definition. Present for column and cell contexts. */
85
- column?: HighlightColumnInfo;
86
- /** Row data. Present for row and cell contexts. */
87
- rowData?: TData;
88
- /** Currently hovered cell position, null if not hovering */
89
- hoverPosition: CellPosition | null;
90
- /** Currently active (focused) cell position */
91
- activeCell: CellPosition | null;
92
- /** Current selection range */
93
- selectionRange: CellRange | null;
94
- /** Whether this row/column/cell is hovered (respects hoverScope) */
95
- isHovered: boolean;
96
- /** Whether this row/column contains or is the active cell */
97
- isActive: boolean;
98
- /** Whether this row/column/cell overlaps or is in the selection range */
99
- isSelected: boolean;
100
- }
101
- /**
102
- * Grid-level highlighting options.
103
- * Hover tracking is automatically enabled when any highlighting callback is defined.
104
- * Each callback type has its own natural interpretation of `isHovered`:
105
- * - computeRowClasses: isHovered = mouse is on any cell in this row
106
- * - computeColumnClasses: isHovered = mouse is on any cell in this column
107
- * - computeCellClasses: isHovered = mouse is on this exact cell
108
- *
109
- * For a crosshair effect, implement both computeRowClasses and computeColumnClasses.
110
- */
111
- interface HighlightingOptions<TData = Record<string, unknown>> {
112
- /**
113
- * Row-level class callback.
114
- * Classes returned are applied to the row container element.
115
- * Context has `rowIndex` set, `colIndex` is null.
116
- * `isHovered` is true when the mouse is on any cell in this row.
117
- * @returns Array of CSS class names
118
- */
119
- computeRowClasses?: (context: HighlightContext<TData>) => string[];
120
- /**
121
- * Column-level class callback.
122
- * Classes returned are applied to all cells in that column (not header).
123
- * Context has `colIndex` set, `rowIndex` is null.
124
- * `isHovered` is true when the mouse is on any cell in this column.
125
- * @returns Array of CSS class names
126
- */
127
- computeColumnClasses?: (context: HighlightContext<TData>) => string[];
128
- /**
129
- * Cell-level class callback.
130
- * Classes returned are applied to individual cells for fine-grained control.
131
- * Context has both `rowIndex` and `colIndex` set.
132
- * `isHovered` is true only when the mouse is on this exact cell.
133
- * @returns Array of CSS class names
134
- */
135
- computeCellClasses?: (context: HighlightContext<TData>) => string[];
136
- }
137
- //#endregion
138
- //#region ../core/src/types/columns.d.ts
139
- /** Column definition */
140
- interface ColumnDefinition {
141
- field: string;
142
- colId?: string;
143
- cellDataType: CellDataType;
144
- width: number;
145
- headerName?: string;
146
- editable?: boolean;
147
- /** Whether column is sortable. Default: true when sortingEnabled */
148
- sortable?: boolean;
149
- /** Whether column is filterable. Default: true */
150
- filterable?: boolean;
151
- /** Whether column is hidden. Hidden columns are not rendered but still exist in the definition. Default: false */
152
- hidden?: boolean;
153
- /** Renderer key for adapter lookup, or inline renderer function */
154
- cellRenderer?: string;
155
- editRenderer?: string;
156
- headerRenderer?: string;
157
- /**
158
- * Per-column override for column-level highlighting.
159
- * If defined, overrides grid-level computeColumnClasses for this column.
160
- * Context has `colIndex` set, `rowIndex` is null.
161
- * @returns Array of CSS class names to apply to all cells in this column
162
- */
163
- computeColumnClasses?: (context: HighlightContext) => string[];
164
- /**
165
- * Per-column override for cell-level highlighting.
166
- * If defined, overrides grid-level computeCellClasses for cells in this column.
167
- * Context has both `rowIndex` and `colIndex` set.
168
- * @returns Array of CSS class names to apply to individual cells
169
- */
170
- computeCellClasses?: (context: HighlightContext) => string[];
171
- }
172
- //#endregion
173
- //#region ../core/src/types/filters.d.ts
174
- /** Text filter operators */
175
- type TextFilterOperator = "contains" | "notContains" | "equals" | "notEquals" | "startsWith" | "endsWith" | "blank" | "notBlank";
176
- /** Number filter operators (symbols for display) */
177
- type NumberFilterOperator = "=" | "!=" | ">" | "<" | ">=" | "<=" | "between" | "blank" | "notBlank";
178
- /** Date filter operators */
179
- type DateFilterOperator = "=" | "!=" | ">" | "<" | "between" | "blank" | "notBlank";
180
- /** Filter combination mode */
181
- type FilterCombination = "and" | "or";
182
- /** Text filter condition */
183
- interface TextFilterCondition {
184
- type: "text";
185
- operator: TextFilterOperator;
186
- value?: string;
187
- /** Selected distinct values for checkbox-style filtering */
188
- selectedValues?: Set<string>;
189
- /** Include blank values */
190
- includeBlank?: boolean;
191
- /** Operator connecting this condition to the next. Defaults to ColumnFilterModel.combination */
192
- nextOperator?: FilterCombination;
193
- }
194
- /** Number filter condition */
195
- interface NumberFilterCondition {
196
- type: "number";
197
- operator: NumberFilterOperator;
198
- value?: number;
199
- /** Second value for "between" operator */
200
- valueTo?: number;
201
- /** Operator connecting this condition to the next. Defaults to ColumnFilterModel.combination */
202
- nextOperator?: FilterCombination;
203
- }
204
- /** Date filter condition */
205
- interface DateFilterCondition {
206
- type: "date";
207
- operator: DateFilterOperator;
208
- value?: Date | string;
209
- /** Second value for "between" operator */
210
- valueTo?: Date | string;
211
- /** Operator connecting this condition to the next. Defaults to ColumnFilterModel.combination */
212
- nextOperator?: FilterCombination;
213
- }
214
- /** Union of filter condition types */
215
- type FilterCondition = TextFilterCondition | NumberFilterCondition | DateFilterCondition;
216
- /** Column filter model with multiple conditions */
217
- interface ColumnFilterModel {
218
- conditions: FilterCondition[];
219
- combination: FilterCombination;
220
- }
221
- /** Filter model type - maps column ID to filter */
222
- type FilterModel = Record<string, ColumnFilterModel>;
223
- //#endregion
224
- //#region ../core/src/types/data-source.d.ts
225
- /** Data source request */
226
- interface DataSourceRequest {
227
- /** Pagination */
228
- pagination: {
229
- /** Page index */
230
- pageIndex: number;
231
- /** Page size */
232
- pageSize: number;
233
- };
234
- /** Sort */
235
- sort?: SortModel[];
236
- /** Filter */
237
- filter?: FilterModel;
238
- }
239
- /** Data source response */
240
- interface DataSourceResponse<TData = Row> {
241
- /** Rows */
242
- rows: TData[];
243
- /** Total rows */
244
- totalRows: number;
245
- }
246
- /** Data source interface */
247
- interface DataSource<TData = Row> {
248
- fetch(request: DataSourceRequest): Promise<DataSourceResponse<TData>>;
249
- /** Optional cleanup method to release resources */
250
- destroy?: () => void;
251
- }
252
- //#endregion
253
- //#region ../core/src/types/instructions.d.ts
254
- /** Create slot instruction */
255
- interface CreateSlotInstruction {
256
- type: "CREATE_SLOT";
257
- slotId: string;
258
- }
259
- /** Destroy slot instruction */
260
- interface DestroySlotInstruction {
261
- type: "DESTROY_SLOT";
262
- slotId: string;
263
- }
264
- /** Assign slot instruction */
265
- interface AssignSlotInstruction {
266
- type: "ASSIGN_SLOT";
267
- slotId: string;
268
- rowIndex: number;
269
- rowData: Row;
270
- }
271
- /** Move slot instruction */
272
- interface MoveSlotInstruction {
273
- type: "MOVE_SLOT";
274
- slotId: string;
275
- translateY: number;
276
- }
277
- /** Set active cell instruction */
278
- interface SetActiveCellInstruction {
279
- type: "SET_ACTIVE_CELL";
280
- position: CellPosition | null;
281
- }
282
- /** Set hover position instruction (for highlighting) */
283
- interface SetHoverPositionInstruction {
284
- type: "SET_HOVER_POSITION";
285
- position: CellPosition | null;
286
- }
287
- /** Set selection range instruction */
288
- interface SetSelectionRangeInstruction {
289
- type: "SET_SELECTION_RANGE";
290
- range: CellRange | null;
291
- }
292
- /** Update visible range instruction - emitted when selection moves outside visible viewport */
293
- interface UpdateVisibleRangeInstruction {
294
- type: "UPDATE_VISIBLE_RANGE";
295
- start: number;
296
- end: number;
297
- }
298
- /** Start edit instruction */
299
- interface StartEditInstruction {
300
- type: "START_EDIT";
301
- row: number;
302
- col: number;
303
- initialValue: CellValue;
304
- }
305
- /** Stop edit instruction */
306
- interface StopEditInstruction {
307
- type: "STOP_EDIT";
308
- }
309
- /** Commit edit instruction */
310
- interface CommitEditInstruction {
311
- type: "COMMIT_EDIT";
312
- row: number;
313
- col: number;
314
- value: CellValue;
315
- }
316
- /** Set content size instruction */
317
- interface SetContentSizeInstruction {
318
- type: "SET_CONTENT_SIZE";
319
- width: number;
320
- height: number;
321
- viewportWidth: number;
322
- }
323
- /** Update header instruction */
324
- interface UpdateHeaderInstruction {
325
- type: "UPDATE_HEADER";
326
- colIndex: number;
327
- column: ColumnDefinition;
328
- sortDirection?: SortDirection;
329
- sortIndex?: number;
330
- /** Whether column is sortable */
331
- sortable: boolean;
332
- /** Whether column is filterable */
333
- filterable: boolean;
334
- /** Whether column has an active filter */
335
- hasFilter: boolean;
336
- }
337
- /** Open filter popup instruction */
338
- interface OpenFilterPopupInstruction {
339
- type: "OPEN_FILTER_POPUP";
340
- colIndex: number;
341
- column: ColumnDefinition;
342
- anchorRect: {
343
- top: number;
344
- left: number;
345
- width: number;
346
- height: number;
347
- };
348
- distinctValues: CellValue[];
349
- currentFilter?: ColumnFilterModel;
350
- }
351
- /** Close filter popup instruction */
352
- interface CloseFilterPopupInstruction {
353
- type: "CLOSE_FILTER_POPUP";
354
- }
355
- /** Start fill instruction */
356
- interface StartFillInstruction {
357
- type: "START_FILL";
358
- sourceRange: CellRange;
359
- }
360
- /** Update fill instruction */
361
- interface UpdateFillInstruction {
362
- type: "UPDATE_FILL";
363
- targetRow: number;
364
- targetCol: number;
365
- }
366
- /** Commit fill instruction */
367
- interface CommitFillInstruction {
368
- type: "COMMIT_FILL";
369
- filledCells: Array<{
370
- row: number;
371
- col: number;
372
- value: CellValue;
373
- }>;
374
- }
375
- /** Cancel fill instruction */
376
- interface CancelFillInstruction {
377
- type: "CANCEL_FILL";
378
- }
379
- /** Data loading instruction */
380
- interface DataLoadingInstruction {
381
- type: "DATA_LOADING";
382
- }
383
- /** Data loaded instruction */
384
- interface DataLoadedInstruction {
385
- type: "DATA_LOADED";
386
- totalRows: number;
387
- }
388
- /** Data error instruction */
389
- interface DataErrorInstruction {
390
- type: "DATA_ERROR";
391
- error: string;
392
- }
393
- /** Rows added instruction */
394
- interface RowsAddedInstruction {
395
- type: "ROWS_ADDED";
396
- indices: number[];
397
- count: number;
398
- totalRows: number;
399
- }
400
- /** Rows removed instruction */
401
- interface RowsRemovedInstruction {
402
- type: "ROWS_REMOVED";
403
- indices: number[];
404
- totalRows: number;
405
- }
406
- /** Rows updated instruction */
407
- interface RowsUpdatedInstruction {
408
- type: "ROWS_UPDATED";
409
- indices: number[];
410
- }
411
- /** Transaction processed instruction */
412
- interface TransactionProcessedInstruction {
413
- type: "TRANSACTION_PROCESSED";
414
- added: number;
415
- removed: number;
416
- updated: number;
417
- }
418
- /** Union type of all instructions */
419
- type GridInstruction = /** Slot lifecycle */
420
- CreateSlotInstruction | DestroySlotInstruction | AssignSlotInstruction | MoveSlotInstruction
421
- /** Selection */ | SetActiveCellInstruction | SetSelectionRangeInstruction | UpdateVisibleRangeInstruction
422
- /** Highlighting */ | SetHoverPositionInstruction
423
- /** Editing */ | StartEditInstruction | StopEditInstruction | CommitEditInstruction
424
- /** Layout */ | SetContentSizeInstruction | UpdateHeaderInstruction
425
- /** Filter popup */ | OpenFilterPopupInstruction | CloseFilterPopupInstruction
426
- /** Fill handle */ | StartFillInstruction | UpdateFillInstruction | CommitFillInstruction | CancelFillInstruction
427
- /** Data */ | DataLoadingInstruction | DataLoadedInstruction | DataErrorInstruction
428
- /** Transactions */ | RowsAddedInstruction | RowsRemovedInstruction | RowsUpdatedInstruction | TransactionProcessedInstruction;
429
- /** Instruction listener: Single instruction Listener that receives a single instruction, used by frameworks to update their state */
430
- type InstructionListener = (instruction: GridInstruction) => void;
431
- //#endregion
432
- //#region ../core/src/types/renderers.d.ts
433
- /** Cell renderer params */
434
- interface CellRendererParams<TData extends Row = Row> {
435
- /** Cell value */
436
- value: CellValue;
437
- /** Row data */
438
- rowData: TData;
439
- /** Column definition */
440
- column: ColumnDefinition;
441
- /** Row index */
442
- rowIndex: number;
443
- /** Column index */
444
- colIndex: number;
445
- /** Is active cell */
446
- isActive: boolean;
447
- /** Is selected cell */
448
- isSelected: boolean;
449
- /** Is editing cell */
450
- isEditing: boolean;
451
- }
452
- /** Edit renderer params */
453
- interface EditRendererParams<TData extends Row = Row> extends CellRendererParams<TData> {
454
- /** Initial value */
455
- initialValue: CellValue;
456
- /** On value change */
457
- onValueChange: (newValue: CellValue) => void;
458
- /** On commit */
459
- onCommit: () => void;
460
- /** On cancel */
461
- onCancel: () => void;
462
- }
463
- /** Header renderer params */
464
- interface HeaderRendererParams {
465
- /** Column definition */
466
- column: ColumnDefinition;
467
- /** Column index */
468
- colIndex: number;
469
- /** Sort direction */
470
- sortDirection?: SortDirection;
471
- /** Sort index */
472
- sortIndex?: number;
473
- /** Whether column is sortable */
474
- sortable: boolean;
475
- /** Whether column is filterable */
476
- filterable: boolean;
477
- /** Whether column has an active filter */
478
- hasFilter: boolean;
479
- /** On sort */
480
- onSort: (direction: SortDirection | null, addToExisting: boolean) => void;
481
- /** On filter click */
482
- onFilterClick: () => void;
483
- }
484
- //#endregion
485
- //#region ../core/src/types/options.d.ts
486
- /** Grid core options */
487
- interface GridCoreOptions<TData = Row> {
488
- /** Column definitions */
489
- columns: ColumnDefinition[];
490
- /** Data source */
491
- dataSource: DataSource<TData>;
492
- /** Row height */
493
- rowHeight: number;
494
- /** Header height: Default to row height */
495
- headerHeight?: number;
496
- /** Overscan: How many rows to render outside the viewport */
497
- overscan?: number;
498
- /** Enable/disable sorting globally. Default: true */
499
- sortingEnabled?: boolean;
500
- /** Debounce time for transactions in ms. Default 50. Set to 0 for sync. */
501
- transactionDebounceMs?: number;
502
- /** Function to extract unique ID from row. Required for mutations. */
503
- getRowId?: (row: TData) => RowId;
504
- /** Row/column/cell highlighting configuration */
505
- highlighting?: HighlightingOptions<TData>;
506
- }
507
- //#endregion
508
- //#region ../core/src/types/input.d.ts
509
- /** Framework-agnostic pointer/mouse event data */
510
- interface PointerEventData {
511
- /** X coordinate relative to viewport */
512
- clientX: number;
513
- /** Y coordinate relative to viewport */
514
- clientY: number;
515
- /** Mouse button (0 = left, 1 = middle, 2 = right) */
516
- button: number;
517
- /** Whether Shift key is pressed */
518
- shiftKey: boolean;
519
- /** Whether Ctrl key is pressed */
520
- ctrlKey: boolean;
521
- /** Whether Meta/Command key is pressed */
522
- metaKey: boolean;
523
- }
524
- /** Framework-agnostic keyboard event data */
525
- interface KeyEventData {
526
- /** Key value (e.g., 'Enter', 'ArrowUp', 'a') */
527
- key: string;
528
- /** Whether Shift key is pressed */
529
- shiftKey: boolean;
530
- /** Whether Ctrl key is pressed */
531
- ctrlKey: boolean;
532
- /** Whether Meta/Command key is pressed */
533
- metaKey: boolean;
534
- }
535
- /** Container bounds and scroll position */
536
- interface ContainerBounds {
537
- /** Top position relative to viewport */
538
- top: number;
539
- /** Left position relative to viewport */
540
- left: number;
541
- /** Container width */
542
- width: number;
543
- /** Container height */
544
- height: number;
545
- /** Current scroll top position */
546
- scrollTop: number;
547
- /** Current scroll left position */
548
- scrollLeft: number;
549
- }
550
- /** Result from mouse/pointer input handlers */
551
- interface InputResult {
552
- /** Whether to call preventDefault() on the event */
553
- preventDefault: boolean;
554
- /** Whether to call stopPropagation() on the event */
555
- stopPropagation: boolean;
556
- /** Whether framework should focus the container element */
557
- focusContainer?: boolean;
558
- /** Type of drag operation to start (framework manages global listeners) */
559
- startDrag?: "selection" | "fill";
560
- }
561
- /** Result from keyboard input handler */
562
- interface KeyboardResult {
563
- /** Whether to call preventDefault() on the event */
564
- preventDefault: boolean;
565
- /** Cell to scroll into view (if navigation occurred) */
566
- scrollToCell?: CellPosition;
567
- }
568
- /** Result from drag move handler */
569
- interface DragMoveResult {
570
- /** Target row index */
571
- targetRow: number;
572
- /** Target column index */
573
- targetCol: number;
574
- /** Auto-scroll deltas (null if no auto-scroll needed) */
575
- autoScroll: {
576
- dx: number;
577
- dy: number;
578
- } | null;
579
- }
580
- /** Options for InputHandler constructor */
581
- interface InputHandlerDeps {
582
- /** Get header height */
583
- getHeaderHeight: () => number;
584
- /** Get row height */
585
- getRowHeight: () => number;
586
- /** Get column positions array (indexed by visible column) */
587
- getColumnPositions: () => number[];
588
- /** Get visible column count */
589
- getColumnCount: () => number;
590
- /**
591
- * Convert visible column index to original column index.
592
- * Used when columns can be hidden. Returns the original index for selection tracking.
593
- * If not provided, visible index is used directly (no hidden columns).
594
- */
595
- getOriginalColumnIndex?: (visibleIndex: number) => number;
596
- }
597
- /** Current drag state for UI rendering */
598
- interface DragState {
599
- /** Whether any drag operation is active */
600
- isDragging: boolean;
601
- /** Type of active drag operation */
602
- dragType: "selection" | "fill" | null;
603
- /** Source range for fill operations */
604
- fillSourceRange: CellRange | null;
605
- /** Current fill target position */
606
- fillTarget: {
607
- row: number;
608
- col: number;
609
- } | null;
610
- }
611
- //#endregion
612
- //#region ../core/src/utils/event-emitter.d.ts
613
- /**
614
- * Batch instruction listener for efficient state updates
615
- */
616
- type BatchInstructionListener = (instructions: GridInstruction[]) => void;
617
- //#endregion
618
- //#region ../core/src/selection.d.ts
619
- type Direction = "up" | "down" | "left" | "right";
620
- interface SelectionManagerOptions {
621
- getRowCount: () => number;
622
- getColumnCount: () => number;
623
- getCellValue: (row: number, col: number) => CellValue;
624
- getRowData: (row: number) => Row | undefined;
625
- getColumn: (col: number) => ColumnDefinition | undefined;
626
- }
627
- /**
628
- * Manages Excel-style cell selection, keyboard navigation, and clipboard operations.
629
- */
630
- declare class SelectionManager {
631
- private state;
632
- private options;
633
- private emitter;
634
- onInstruction: (listener: InstructionListener) => () => void;
635
- private emit;
636
- constructor(options: SelectionManagerOptions);
637
- getState(): SelectionState;
638
- getActiveCell(): CellPosition | null;
639
- getSelectionRange(): CellRange | null;
640
- isSelected(row: number, col: number): boolean;
641
- isActiveCell(row: number, col: number): boolean;
642
- /**
643
- * Start a selection at the given cell.
644
- * @param cell - The cell to select
645
- * @param opts.shift - Extend selection from anchor (range select)
646
- * @param opts.ctrl - Toggle selection mode
647
- */
648
- startSelection(cell: CellPosition, opts?: {
649
- shift?: boolean;
650
- ctrl?: boolean;
651
- }): void;
652
- /**
653
- * Move focus in a direction, optionally extending the selection.
654
- */
655
- moveFocus(direction: Direction, extend?: boolean): void;
656
- /**
657
- * Select all cells in the grid (Ctrl+A).
658
- */
659
- selectAll(): void;
660
- /**
661
- * Clear the current selection.
662
- */
663
- clearSelection(): void;
664
- /**
665
- * Set the active cell directly.
666
- */
667
- setActiveCell(row: number, col: number): void;
668
- /**
669
- * Set the selection range directly.
670
- */
671
- setSelectionRange(range: CellRange): void;
672
- /**
673
- * Get the data from the currently selected cells as a 2D array.
674
- */
675
- getSelectedData(): CellValue[][];
676
- /**
677
- * Copy the selected data to the clipboard (Ctrl+C).
678
- */
679
- copySelectionToClipboard(): Promise<void>;
680
- /**
681
- * Clean up resources for garbage collection.
682
- */
683
- destroy(): void;
684
- private clampPosition;
685
- }
686
- //#endregion
687
- //#region ../core/src/fill.d.ts
688
- interface FillManagerOptions {
689
- getRowCount: () => number;
690
- getColumnCount: () => number;
691
- getCellValue: (row: number, col: number) => CellValue;
692
- getColumn: (col: number) => ColumnDefinition | undefined;
693
- setCellValue: (row: number, col: number, value: CellValue) => void;
694
- }
695
- /**
696
- * Manages fill handle operations including pattern detection and auto-fill.
697
- */
698
- declare class FillManager {
699
- private state;
700
- private options;
701
- private emitter;
702
- onInstruction: (listener: InstructionListener) => () => void;
703
- private emit;
704
- constructor(options: FillManagerOptions);
705
- getState(): FillHandleState | null;
706
- isActive(): boolean;
707
- /**
708
- * Start a fill drag operation from a source range.
709
- */
710
- startFillDrag(sourceRange: CellRange): void;
711
- /**
712
- * Update the fill drag target position.
713
- */
714
- updateFillDrag(targetRow: number, targetCol: number): void;
715
- /**
716
- * Commit the fill operation - apply pattern to target cells.
717
- */
718
- commitFillDrag(): void;
719
- /**
720
- * Cancel the fill operation.
721
- */
722
- cancelFillDrag(): void;
723
- /**
724
- * Clean up resources for garbage collection.
725
- */
726
- destroy(): void;
727
- /**
728
- * Calculate the values to fill based on source pattern.
729
- */
730
- private calculateFilledCells;
731
- private getSourceColumnValues;
732
- private detectPattern;
733
- private applyPattern;
734
- }
735
- //#endregion
736
- //#region ../core/src/input-handler.d.ts
737
- declare class InputHandler<TData extends Row = Row> {
738
- private core;
739
- private deps;
740
- private isDraggingSelection;
741
- private isDraggingFill;
742
- private fillSourceRange;
743
- private fillTarget;
744
- constructor(core: GridCore<TData>, deps: InputHandlerDeps);
745
- /**
746
- * Update dependencies (called when options change)
747
- */
748
- updateDeps(deps: Partial<InputHandlerDeps>): void;
749
- /**
750
- * Get current drag state for UI rendering
751
- */
752
- getDragState(): DragState;
753
- /**
754
- * Handle cell mouse down event
755
- */
756
- handleCellMouseDown(rowIndex: number, colIndex: number, event: PointerEventData): InputResult;
757
- /**
758
- * Handle cell double click event (start editing)
759
- */
760
- handleCellDoubleClick(rowIndex: number, colIndex: number): void;
761
- /**
762
- * Handle cell mouse enter event (for hover highlighting)
763
- */
764
- handleCellMouseEnter(rowIndex: number, colIndex: number): void;
765
- /**
766
- * Handle cell mouse leave event (for hover highlighting)
767
- */
768
- handleCellMouseLeave(): void;
769
- /**
770
- * Handle fill handle mouse down event
771
- */
772
- handleFillHandleMouseDown(activeCell: CellPosition | null, selectionRange: CellRange | null, _event: PointerEventData): InputResult;
773
- /**
774
- * Handle header click event (cycle sort direction)
775
- */
776
- handleHeaderClick(colId: string, addToExisting: boolean): void;
777
- /**
778
- * Start selection drag (called by framework after handleCellMouseDown returns startDrag: 'selection')
779
- */
780
- startSelectionDrag(): void;
781
- /**
782
- * Handle drag move event (selection or fill)
783
- */
784
- handleDragMove(event: PointerEventData, bounds: ContainerBounds): DragMoveResult | null;
785
- /**
786
- * Handle drag end event
787
- */
788
- handleDragEnd(): void;
789
- /**
790
- * Handle wheel event with dampening for large datasets
791
- * Returns scroll deltas or null if no dampening needed
792
- */
793
- handleWheel(deltaY: number, deltaX: number, dampening: number): {
794
- dy: number;
795
- dx: number;
796
- } | null;
797
- /**
798
- * Handle keyboard event
799
- */
800
- handleKeyDown(event: KeyEventData, activeCell: CellPosition | null, editingCell: {
801
- row: number;
802
- col: number;
803
- } | null, filterPopupOpen: boolean): KeyboardResult;
804
- /**
805
- * Calculate auto-scroll deltas based on mouse position
806
- */
807
- private calculateAutoScroll;
808
- }
809
- //#endregion
810
- //#region ../core/src/highlight-manager.d.ts
811
- interface HighlightManagerOptions {
812
- getActiveCell: () => CellPosition | null;
813
- getSelectionRange: () => CellRange | null;
814
- getColumn: (colIndex: number) => ColumnDefinition | undefined;
815
- }
816
- /**
817
- * Manages row/column/cell highlighting state and class computation.
818
- * Emits SET_HOVER_POSITION instructions when hover position changes.
819
- */
820
- declare class HighlightManager<TData = Record<string, unknown>> {
821
- private options;
822
- private highlightingOptions;
823
- private hoverPosition;
824
- private emitter;
825
- onInstruction: (listener: InstructionListener) => () => void;
826
- private emit;
827
- private rowClassCache;
828
- private columnClassCache;
829
- private cellClassCache;
830
- constructor(options: HighlightManagerOptions, highlightingOptions?: HighlightingOptions<TData>);
831
- /**
832
- * Check if highlighting is enabled (any callback defined).
833
- * Hover tracking is automatically enabled when highlighting is enabled.
834
- */
835
- isEnabled(): boolean;
836
- /**
837
- * Update highlighting options. Clears all caches.
838
- */
839
- updateOptions(options: HighlightingOptions<TData>): void;
840
- /**
841
- * Set the current hover position. Clears caches and emits instruction.
842
- * Hover tracking is automatically enabled when any highlighting callback is defined.
843
- */
844
- setHoverPosition(position: CellPosition | null): void;
845
- /**
846
- * Get the current hover position
847
- */
848
- getHoverPosition(): CellPosition | null;
849
- /**
850
- * Called when selection changes. Clears all caches.
851
- */
852
- onSelectionChange(): void;
853
- /**
854
- * Build context for row highlighting callback.
855
- * Returns context with `rowIndex` set, `colIndex` is null.
856
- * `isHovered` is true when the mouse is on any cell in this row.
857
- */
858
- buildRowContext(rowIndex: number, rowData?: TData): HighlightContext<TData>;
859
- /**
860
- * Build context for column highlighting callback.
861
- * Returns context with `colIndex` set, `rowIndex` is null.
862
- * `isHovered` is true when the mouse is on any cell in this column.
863
- */
864
- buildColumnContext(colIndex: number, column: ColumnDefinition): HighlightContext<TData>;
865
- /**
866
- * Build context for cell highlighting callback.
867
- * Returns context with both `rowIndex` and `colIndex` set.
868
- * `isHovered` is true only when the mouse is on this exact cell.
869
- */
870
- buildCellContext(rowIndex: number, colIndex: number, column: ColumnDefinition, rowData?: TData): HighlightContext<TData>;
871
- /**
872
- * Compute row classes using cache and user callback
873
- */
874
- computeRowClasses(rowIndex: number, rowData?: TData): string[];
875
- /**
876
- * Compute column classes using cache and user callback (or per-column override)
877
- */
878
- computeColumnClasses(colIndex: number, column: ColumnDefinition): string[];
879
- /**
880
- * Compute cell classes using cache and user callback (or per-column override)
881
- */
882
- computeCellClasses(rowIndex: number, colIndex: number, column: ColumnDefinition, rowData?: TData): string[];
883
- /**
884
- * Compute combined cell classes (column + cell classes flattened)
885
- */
886
- computeCombinedCellClasses(rowIndex: number, colIndex: number, column: ColumnDefinition, rowData?: TData): string[];
887
- /**
888
- * Clear all caches
889
- */
890
- clearAllCaches(): void;
891
- /**
892
- * Destroy the manager and release resources
893
- */
894
- destroy(): void;
895
- }
896
- //#endregion
897
- //#region ../core/src/sort-filter-manager.d.ts
898
- interface SortFilterManagerOptions<TData> {
899
- /** Get all columns */
900
- getColumns: () => ColumnDefinition[];
901
- /** Check if sorting is enabled globally */
902
- isSortingEnabled: () => boolean;
903
- /** Get cached rows for distinct value computation */
904
- getCachedRows: () => Map<number, TData>;
905
- /** Called when sort/filter changes to trigger data refresh */
906
- onSortFilterChange: () => Promise<void>;
907
- /** Called after data refresh to update UI */
908
- onDataRefreshed: () => void;
909
- }
910
- /**
911
- * Manages sorting and filtering state and operations.
912
- */
913
- declare class SortFilterManager<TData = Record<string, unknown>> {
914
- private options;
915
- private emitter;
916
- private sortModel;
917
- private filterModel;
918
- private openFilterColIndex;
919
- onInstruction: (listener: InstructionListener) => () => void;
920
- private emit;
921
- constructor(options: SortFilterManagerOptions<TData>);
922
- setSort(colId: string, direction: SortDirection | null, addToExisting?: boolean): Promise<void>;
923
- getSortModel(): SortModel[];
924
- setFilter(colId: string, filter: ColumnFilterModel | string | null): Promise<void>;
925
- getFilterModel(): FilterModel;
926
- /**
927
- * Check if a column has an active filter
928
- */
929
- hasActiveFilter(colId: string): boolean;
930
- /**
931
- * Check if a column is sortable
932
- */
933
- isColumnSortable(colIndex: number): boolean;
934
- /**
935
- * Check if a column is filterable
936
- */
937
- isColumnFilterable(colIndex: number): boolean;
938
- /**
939
- * Get distinct values for a column (for filter dropdowns)
940
- * For array-type columns (like tags), each unique array combination is returned.
941
- * Arrays are sorted internally for consistent comparison.
942
- * Limited to maxValues to avoid performance issues with large datasets.
943
- */
944
- getDistinctValuesForColumn(colId: string, maxValues?: number): CellValue[];
945
- /**
946
- * Open filter popup for a column (toggles if already open for same column)
947
- */
948
- openFilterPopup(colIndex: number, anchorRect: {
949
- top: number;
950
- left: number;
951
- width: number;
952
- height: number;
953
- }): void;
954
- /**
955
- * Close filter popup
956
- */
957
- closeFilterPopup(): void;
958
- /**
959
- * Get sort info map for header rendering
960
- */
961
- getSortInfoMap(): Map<string, {
962
- direction: SortDirection;
963
- index: number;
964
- }>;
965
- destroy(): void;
966
- }
967
- //#endregion
968
- //#region ../core/src/row-mutation-manager.d.ts
969
- interface RowMutationManagerOptions<TData> {
970
- /** Get the cached rows map */
971
- getCachedRows: () => Map<number, TData>;
972
- /** Set the cached rows map (for bulk operations) */
973
- setCachedRows: (rows: Map<number, TData>) => void;
974
- /** Get total row count */
975
- getTotalRows: () => number;
976
- /** Set total row count */
977
- setTotalRows: (count: number) => void;
978
- /** Update a single slot after row change */
979
- updateSlot: (rowIndex: number) => void;
980
- /** Refresh all slots after bulk changes */
981
- refreshAllSlots: () => void;
982
- /** Emit content size change */
983
- emitContentSize: () => void;
984
- /** Clear selection if it references invalid rows */
985
- clearSelectionIfInvalid: (maxValidRow: number) => void;
986
- }
987
- /**
988
- * Manages row CRUD operations and cache management.
989
- */
990
- declare class RowMutationManager<TData extends Row = Row> {
991
- private options;
992
- private emitter;
993
- onInstruction: (listener: InstructionListener) => () => void;
994
- private emit;
995
- constructor(options: RowMutationManagerOptions<TData>);
996
- /**
997
- * Get a row by index.
998
- */
999
- getRow(index: number): TData | undefined;
1000
- /**
1001
- * Add rows to the grid at the specified index.
1002
- * If no index is provided, rows are added at the end.
1003
- */
1004
- addRows(rows: TData[], index?: number): void;
1005
- /**
1006
- * Update existing rows with partial data.
1007
- */
1008
- updateRows(updates: Array<{
1009
- index: number;
1010
- data: Partial<TData>;
1011
- }>): void;
1012
- /**
1013
- * Delete rows at the specified indices.
1014
- */
1015
- deleteRows(indices: number[]): void;
1016
- /**
1017
- * Set a complete row at the specified index.
1018
- * Use this for complete row replacement. For partial updates, use updateRows.
1019
- */
1020
- setRow(index: number, data: TData): void;
1021
- destroy(): void;
1022
- }
1023
- //#endregion
1024
- //#region ../core/src/grid-core.d.ts
1025
- declare class GridCore<TData extends Row = Row> {
1026
- private columns;
1027
- private dataSource;
1028
- private rowHeight;
1029
- private headerHeight;
1030
- private overscan;
1031
- private sortingEnabled;
1032
- private scrollTop;
1033
- private scrollLeft;
1034
- private viewportWidth;
1035
- private viewportHeight;
1036
- private cachedRows;
1037
- private totalRows;
1038
- private currentPageIndex;
1039
- private pageSize;
1040
- readonly selection: SelectionManager;
1041
- readonly fill: FillManager;
1042
- readonly input: InputHandler<TData>;
1043
- readonly highlight: HighlightManager<TData> | null;
1044
- readonly sortFilter: SortFilterManager<TData>;
1045
- readonly rowMutation: RowMutationManager<TData>;
1046
- private readonly slotPool;
1047
- private readonly editManager;
1048
- private columnPositions;
1049
- private emitter;
1050
- onInstruction: (listener: InstructionListener) => () => void;
1051
- onBatchInstruction: (listener: BatchInstructionListener) => () => void;
1052
- private emit;
1053
- private emitBatch;
1054
- private naturalContentHeight;
1055
- private virtualContentHeight;
1056
- private scrollRatio;
1057
- private isDestroyed;
1058
- constructor(options: GridCoreOptions<TData>);
1059
- /**
1060
- * Initialize the grid and load initial data.
1061
- */
1062
- initialize(): Promise<void>;
1063
- /**
1064
- * Update viewport measurements and sync slots.
1065
- * When scroll virtualization is active, maps the DOM scroll position to the actual row position.
1066
- */
1067
- setViewport(scrollTop: number, scrollLeft: number, width: number, height: number): void;
1068
- private fetchData;
1069
- private fetchAllData;
1070
- setSort(colId: string, direction: SortDirection | null, addToExisting?: boolean): Promise<void>;
1071
- setFilter(colId: string, filter: ColumnFilterModel | string | null): Promise<void>;
1072
- hasActiveFilter(colId: string): boolean;
1073
- isColumnSortable(colIndex: number): boolean;
1074
- isColumnFilterable(colIndex: number): boolean;
1075
- getDistinctValuesForColumn(colId: string, maxValues?: number): CellValue[];
1076
- openFilterPopup(colIndex: number, anchorRect: {
1077
- top: number;
1078
- left: number;
1079
- width: number;
1080
- height: number;
1081
- }): void;
1082
- closeFilterPopup(): void;
1083
- getSortModel(): SortModel[];
1084
- getFilterModel(): FilterModel;
1085
- startEdit(row: number, col: number): void;
1086
- updateEditValue(value: CellValue): void;
1087
- commitEdit(): void;
1088
- cancelEdit(): void;
1089
- getEditState(): EditState | null;
1090
- getCellValue(row: number, col: number): CellValue;
1091
- setCellValue(row: number, col: number, value: CellValue): void;
1092
- private computeColumnPositions;
1093
- private emitContentSize;
1094
- private emitHeaders;
1095
- getColumns(): ColumnDefinition[];
1096
- getColumnPositions(): number[];
1097
- getRowCount(): number;
1098
- getRowHeight(): number;
1099
- getHeaderHeight(): number;
1100
- getTotalWidth(): number;
1101
- getTotalHeight(): number;
1102
- /**
1103
- * Check if scroll scaling is active (large datasets exceeding browser scroll limits).
1104
- * When scaling is active, scrollRatio < 1 and scroll positions are compressed.
1105
- */
1106
- isScalingActive(): boolean;
1107
- /**
1108
- * Get the natural (uncapped) content height.
1109
- * Useful for debugging or displaying actual content size.
1110
- */
1111
- getNaturalHeight(): number;
1112
- /**
1113
- * Get the scroll ratio used for scroll virtualization.
1114
- * Returns 1 when no virtualization is needed, < 1 when content exceeds browser limits.
1115
- */
1116
- getScrollRatio(): number;
1117
- /**
1118
- * Get the visible row range (excluding overscan).
1119
- * Returns the first and last row indices that are actually visible in the viewport.
1120
- * Includes partially visible rows to avoid false positives when clicking on edge rows.
1121
- */
1122
- getVisibleRowRange(): {
1123
- start: number;
1124
- end: number;
1125
- };
1126
- /**
1127
- * Get the scroll position needed to bring a row into view.
1128
- * Accounts for scroll scaling when active.
1129
- */
1130
- getScrollTopForRow(rowIndex: number): number;
1131
- /**
1132
- * Get the row index at a given viewport Y position.
1133
- * Accounts for scroll scaling when active.
1134
- * @param viewportY Y position in viewport (physical pixels below header, NOT including scroll)
1135
- * @param virtualScrollTop Current scroll position from container.scrollTop (virtual/scaled)
1136
- */
1137
- getRowIndexAtDisplayY(viewportY: number, virtualScrollTop: number): number;
1138
- getRowData(rowIndex: number): TData | undefined;
1139
- /**
1140
- * Refresh data from the data source.
1141
- */
1142
- refresh(): Promise<void>;
1143
- /**
1144
- * Refresh slot display without refetching data.
1145
- * Useful after in-place data modifications like fill operations.
1146
- */
1147
- refreshSlotData(): void;
1148
- /**
1149
- * Add rows to the grid at the specified index.
1150
- * If no index is provided, rows are added at the end.
1151
- */
1152
- addRows(rows: TData[], index?: number): void;
1153
- /**
1154
- * Update existing rows with partial data.
1155
- */
1156
- updateRows(updates: Array<{
1157
- index: number;
1158
- data: Partial<TData>;
1159
- }>): void;
1160
- /**
1161
- * Delete rows at the specified indices.
1162
- */
1163
- deleteRows(indices: number[]): void;
1164
- /**
1165
- * Get a row by index.
1166
- */
1167
- getRow(index: number): TData | undefined;
1168
- /**
1169
- * Set a complete row at the specified index.
1170
- * Use this for complete row replacement. For partial updates, use updateRows.
1171
- */
1172
- setRow(index: number, data: TData): void;
1173
- /**
1174
- * Update the data source and refresh.
1175
- */
1176
- setDataSource(dataSource: DataSource<TData>): Promise<void>;
1177
- /**
1178
- * Update columns and recompute layout.
1179
- */
1180
- setColumns(columns: ColumnDefinition[]): void;
1181
- /**
1182
- * Destroy the grid core and release all references.
1183
- * Call this before discarding the GridCore to ensure proper cleanup.
1184
- * This method is idempotent - safe to call multiple times.
1185
- */
1186
- destroy(): void;
1187
- }
1188
- //#endregion
1189
- //#region ../core/src/sorting/parallel-sort-manager.d.ts
1190
- interface ParallelSortOptions {
1191
- /** Maximum number of workers (default: navigator.hardwareConcurrency || 4) */
1192
- maxWorkers?: number;
1193
- /** Threshold for parallel sorting (default: 400000) */
1194
- parallelThreshold?: number;
1195
- /** Minimum chunk size (default: 50000) */
1196
- minChunkSize?: number;
1197
- }
1198
- //#endregion
1199
- //#region ../core/src/data-source/client-data-source.d.ts
1200
- interface ClientDataSourceOptions<TData> {
1201
- /** Custom field accessor for nested properties */
1202
- getFieldValue?: (row: TData, field: string) => CellValue;
1203
- /** Use Web Worker for sorting large datasets (default: true) */
1204
- useWorker?: boolean;
1205
- /** Options for parallel sorting (only used when useWorker is true) */
1206
- parallelSort?: ParallelSortOptions | false;
1207
- }
1208
- /**
1209
- * Creates a client-side data source that holds all data in memory.
1210
- * Sorting and filtering are performed client-side.
1211
- * For large datasets, sorting is automatically offloaded to a Web Worker.
1212
- */
1213
- declare function createClientDataSource<TData extends Row = Row>(data: TData[], options?: ClientDataSourceOptions<TData>): DataSource<TData>;
1214
- /**
1215
- * Convenience function to create a data source from an array.
1216
- * This provides backwards compatibility with the old `rowData` prop.
1217
- */
1218
- declare function createDataSourceFromArray<TData extends Row = Row>(data: TData[]): DataSource<TData>;
1219
- //#endregion
1220
- //#region ../core/src/data-source/server-data-source.d.ts
1221
- type ServerFetchFunction<TData> = (request: DataSourceRequest) => Promise<DataSourceResponse<TData>>;
1222
- /**
1223
- * Creates a server-side data source that delegates all operations to the server.
1224
- * The fetch function receives sort/filter/pagination params to pass to the API.
1225
- */
1226
- declare function createServerDataSource<TData extends Row = Row>(fetchFn: ServerFetchFunction<TData>): DataSource<TData>;
1227
- //#endregion
1228
- //#region ../core/src/transaction-manager.d.ts
1229
- interface TransactionResult {
1230
- added: number;
1231
- removed: number;
1232
- updated: number;
1233
- }
1234
- //#endregion
1235
- //#region ../core/src/data-source/mutable-data-source.d.ts
1236
- /** Callback for data change notifications */
1237
- type DataChangeListener = (result: TransactionResult) => void;
1238
- /**
1239
- * Data source with mutation capabilities.
1240
- * Extends DataSource with add, remove, and update operations.
1241
- */
1242
- interface MutableDataSource<TData = Row> extends DataSource<TData> {
1243
- /** Add rows to the data source. Queued and processed after debounce. */
1244
- addRows(rows: TData[]): void;
1245
- /** Remove rows by ID. Queued and processed after debounce. */
1246
- removeRows(ids: RowId[]): void;
1247
- /** Update a cell value. Queued and processed after debounce. */
1248
- updateCell(id: RowId, field: string, value: CellValue): void;
1249
- /** Update multiple fields on a row. Queued and processed after debounce. */
1250
- updateRow(id: RowId, data: Partial<TData>): void;
1251
- /** Force immediate processing of queued transactions. */
1252
- flushTransactions(): Promise<void>;
1253
- /** Check if there are pending transactions. */
1254
- hasPendingTransactions(): boolean;
1255
- /** Get distinct values for a field (for filter UI). */
1256
- getDistinctValues(field: string): CellValue[];
1257
- /** Get a row by ID. */
1258
- getRowById(id: RowId): TData | undefined;
1259
- /** Get total row count. */
1260
- getTotalRowCount(): number;
1261
- /** Subscribe to data change notifications. Returns unsubscribe function. */
1262
- subscribe(listener: DataChangeListener): () => void;
1263
- /** Clear all data from the data source. */
1264
- clear(): void;
1265
- }
1266
- interface MutableClientDataSourceOptions<TData> {
1267
- /** Function to extract unique ID from row. Required. */
1268
- getRowId: (row: TData) => RowId;
1269
- /** Custom field accessor for nested properties. */
1270
- getFieldValue?: (row: TData, field: string) => CellValue;
1271
- /** Debounce time for transactions in ms. Default 50. Set to 0 for sync. */
1272
- debounceMs?: number;
1273
- /** Callback when transactions are processed. */
1274
- onTransactionProcessed?: (result: TransactionResult) => void;
1275
- }
1276
- /**
1277
- * Creates a mutable client-side data source with transaction support.
1278
- * Uses IndexedDataStore for efficient incremental operations.
1279
- */
1280
- declare function createMutableClientDataSource<TData extends Row = Row>(data: TData[], options: MutableClientDataSourceOptions<TData>): MutableDataSource<TData>;
1281
- //#endregion
1282
4
  //#region src/types.d.ts
1283
5
  /** Ref handle exposed by the Grid component */
1284
- interface GridRef<TData extends Row = Row> {
6
+ interface GridRef<TData extends Row$1 = Row$1> {
1285
7
  /** Access to the underlying GridCore instance */
1286
- core: GridCore<TData> | null;
8
+ core: GridCore$1<TData> | null;
1287
9
  }
1288
10
  /** React cell renderer: A function that renders a cell */
1289
- type ReactCellRenderer = (params: CellRendererParams) => React.ReactNode;
11
+ type ReactCellRenderer = (params: CellRendererParams$1) => React.ReactNode;
1290
12
  /** React edit renderer: A function that renders the cell while in edit mode */
1291
- type ReactEditRenderer = (params: EditRendererParams) => React.ReactNode;
13
+ type ReactEditRenderer = (params: EditRendererParams$1) => React.ReactNode;
1292
14
  /** React header renderer: A function that renders a header cell */
1293
- type ReactHeaderRenderer = (params: HeaderRendererParams) => React.ReactNode;
15
+ type ReactHeaderRenderer = (params: HeaderRendererParams$1) => React.ReactNode;
1294
16
  /** Grid component props */
1295
- interface GridProps<TData extends Row = Row> {
17
+ interface GridProps<TData extends Row$1 = Row$1> {
1296
18
  /** Column definitions */
1297
- columns: ColumnDefinition[];
19
+ columns: ColumnDefinition$1[];
1298
20
  /** Data source for the grid */
1299
- dataSource?: DataSource<TData>;
21
+ dataSource?: DataSource$1<TData>;
1300
22
  /** Legacy: Raw row data (will be wrapped in a client data source) */
1301
23
  rowData?: TData[];
1302
24
  /** Row height in pixels */
@@ -1331,6 +53,14 @@ interface GridProps<TData extends Row = Row> {
1331
53
  gridRef?: React.MutableRefObject<GridRef<TData> | null>;
1332
54
  /** Row/column/cell highlighting configuration */
1333
55
  highlighting?: HighlightingOptions<TData>;
56
+ /** Function to extract unique ID from row. Required when onCellValueChanged is provided. */
57
+ getRowId?: (row: TData) => RowId$1;
58
+ /** Called when a cell value is changed via editing or fill drag. Requires getRowId. */
59
+ onCellValueChanged?: (event: CellValueChangedEvent$1<TData>) => void;
60
+ /** Custom loading component to render instead of default spinner */
61
+ loadingComponent?: React.ComponentType<{
62
+ isLoading: boolean;
63
+ }>;
1334
64
  }
1335
65
  //#endregion
1336
66
  //#region src/Grid.d.ts
@@ -1339,6 +69,54 @@ interface GridProps<TData extends Row = Row> {
1339
69
  * @param props - Grid component props
1340
70
  * @returns Grid React component
1341
71
  */
1342
- declare function Grid<TData extends Row = Row>(props: GridProps<TData>): React$1.ReactNode;
72
+ declare function Grid<TData extends Row$1 = Row$1>(props: GridProps<TData>): React$1.ReactNode;
73
+ //#endregion
74
+ //#region src/useGridData.d.ts
75
+ interface UseGridDataOptions<TData> {
76
+ /** Function to extract a unique ID from each row. Required. */
77
+ getRowId: (row: TData) => RowId$1;
78
+ /** Debounce time for batching transactions in ms. Default 50. */
79
+ debounceMs?: number;
80
+ /** Use Web Worker for sorting large datasets (default: true) */
81
+ useWorker?: boolean;
82
+ /** Options for parallel sorting (only used when useWorker is true) */
83
+ parallelSort?: ParallelSortOptions | false;
84
+ }
85
+ interface UseGridDataResult<TData> {
86
+ /** The data source to pass to <Grid dataSource={...} />. */
87
+ dataSource: MutableDataSource$1<TData>;
88
+ /** Update a single row by ID with partial data. */
89
+ updateRow: (id: RowId$1, data: Partial<TData>) => void;
90
+ /** Add rows to the data source. */
91
+ addRows: (rows: TData[]) => void;
92
+ /** Remove rows by ID. */
93
+ removeRows: (ids: RowId$1[]) => void;
94
+ /** Update a single cell value. */
95
+ updateCell: (id: RowId$1, field: string, value: CellValue$1) => void;
96
+ /** Clear all data from the data source. */
97
+ clear: () => void;
98
+ /** Get a row by its ID. */
99
+ getRowById: (id: RowId$1) => TData | undefined;
100
+ /** Get the current total row count. */
101
+ getTotalRowCount: () => number;
102
+ /** Force immediate processing of queued transactions. */
103
+ flushTransactions: () => Promise<void>;
104
+ }
105
+ /**
106
+ * React hook for efficient grid data mutations.
107
+ *
108
+ * Wraps `createMutableClientDataSource` to provide a simple API for
109
+ * updating grid data without triggering full pipeline rebuilds.
110
+ *
111
+ * @example
112
+ * ```tsx
113
+ * const { dataSource, updateRow, addRows } = useGridData(initialData, {
114
+ * getRowId: (row) => row.id,
115
+ * });
116
+ *
117
+ * return <Grid dataSource={dataSource} columns={columns} rowHeight={36} />;
118
+ * ```
119
+ */
120
+ declare const useGridData: <TData extends Row$1 = Row$1>(initialData: TData[], options: UseGridDataOptions<TData>) => UseGridDataResult<TData>;
1343
121
  //#endregion
1344
- export { type CellDataType, type CellPosition, type CellRange, type CellRendererParams, type CellValue, type ColumnDefinition, type ColumnFilterModel, type DataSource, type DataSourceRequest, type DataSourceResponse, type EditRendererParams, type FilterCondition, type FilterModel, Grid, GridCore, type GridInstruction, type GridProps, type GridRef, type HeaderRendererParams, type MutableDataSource, type ReactCellRenderer, type ReactEditRenderer, type ReactHeaderRenderer, type Row, type SortDirection, type SortModel, createClientDataSource, createDataSourceFromArray, createMutableClientDataSource, createServerDataSource };
122
+ export { type CellDataType, type CellPosition, type CellRange, type CellRendererParams, type CellValue, type CellValueChangedEvent, type ColumnDefinition, type ColumnFilterModel, type DataSource, type DataSourceRequest, type DataSourceResponse, type EditRendererParams, type FilterCondition, type FilterModel, Grid, GridCore, type GridInstruction, type GridProps, type GridRef, type HeaderRendererParams, type MutableDataSource, type ReactCellRenderer, type ReactEditRenderer, type ReactHeaderRenderer, type Row, type RowId, type SortDirection, type SortModel, type UseGridDataOptions, type UseGridDataResult, createClientDataSource, createDataSourceFromArray, createMutableClientDataSource, createServerDataSource, useGridData };