@gp-grid/core 0.7.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.
@@ -0,0 +1,2067 @@
1
+ //#region src/types/basic.d.ts
2
+ /** Cell data type primitive types */
3
+ type CellDataType = "text" | "number" | "boolean" | "date" | "dateString" | "dateTime" | "dateTimeString" | "object";
4
+ /** Cell value type */
5
+ type CellValue = string | number | boolean | Date | object | null;
6
+ /** Row type */
7
+ type Row = unknown;
8
+ /** Row ID type for transaction operations */
9
+ type RowId = string | number;
10
+ /** Sort direction type */
11
+ type SortDirection = "asc" | "desc";
12
+ /** Sort model type */
13
+ type SortModel = {
14
+ colId: string;
15
+ direction: SortDirection;
16
+ };
17
+ /** Cell position */
18
+ interface CellPosition {
19
+ row: number;
20
+ col: number;
21
+ }
22
+ /** Cell range */
23
+ interface CellRange {
24
+ startRow: number;
25
+ startCol: number;
26
+ endRow: number;
27
+ endCol: number;
28
+ }
29
+ /** Selection state */
30
+ interface SelectionState {
31
+ /** Active cell position */
32
+ activeCell: CellPosition | null;
33
+ /** Selection range */
34
+ range: CellRange | null;
35
+ /** Anchor cell for shift-extend selection */
36
+ anchor: CellPosition | null;
37
+ /** Whether selection mode is active (ctrl held) */
38
+ selectionMode: boolean;
39
+ }
40
+ /** Edit state */
41
+ interface EditState {
42
+ /** Row index */
43
+ row: number;
44
+ /** Column index */
45
+ col: number;
46
+ /** Initial value */
47
+ initialValue: CellValue;
48
+ /** Current value */
49
+ currentValue: CellValue;
50
+ }
51
+ /** Fill handle state */
52
+ interface FillHandleState {
53
+ /** Source range */
54
+ sourceRange: CellRange;
55
+ /** Target row */
56
+ targetRow: number;
57
+ /** Target column */
58
+ targetCol: number;
59
+ }
60
+ /** The slot is the virtualized row, this represents the state of the slot */
61
+ interface SlotState {
62
+ /** Slot ID */
63
+ slotId: string;
64
+ /** Row index */
65
+ rowIndex: number;
66
+ /** Row data */
67
+ rowData: Row;
68
+ /** Translate Y position of the slot, we use translateY to optimize the rendering of the slots (Relies on the GP) */
69
+ translateY: number;
70
+ }
71
+ //#endregion
72
+ //#region src/types/highlighting.d.ts
73
+ /**
74
+ * Minimal column info for highlighting context.
75
+ * Uses structural typing to avoid circular dependency with columns.ts.
76
+ */
77
+ interface HighlightColumnInfo {
78
+ field: string;
79
+ colId?: string;
80
+ }
81
+ /**
82
+ * Unified context for row, column, and cell highlighting.
83
+ *
84
+ * - Row context: `rowIndex` is set, `colIndex` is null
85
+ * - Column context: `colIndex` is set, `rowIndex` is null
86
+ * - Cell context: both `rowIndex` and `colIndex` are set
87
+ */
88
+ interface HighlightContext<TData = Record<string, unknown>> {
89
+ /** Row index. Null for column-only context. */
90
+ rowIndex: number | null;
91
+ /** Column index. Null for row-only context. */
92
+ colIndex: number | null;
93
+ /** Column definition. Present for column and cell contexts. */
94
+ column?: HighlightColumnInfo;
95
+ /** Row data. Present for row and cell contexts. */
96
+ rowData?: TData;
97
+ /** Currently hovered cell position, null if not hovering */
98
+ hoverPosition: CellPosition | null;
99
+ /** Currently active (focused) cell position */
100
+ activeCell: CellPosition | null;
101
+ /** Current selection range */
102
+ selectionRange: CellRange | null;
103
+ /** Whether this row/column/cell is hovered (respects hoverScope) */
104
+ isHovered: boolean;
105
+ /** Whether this row/column contains or is the active cell */
106
+ isActive: boolean;
107
+ /** Whether this row/column/cell overlaps or is in the selection range */
108
+ isSelected: boolean;
109
+ }
110
+ /**
111
+ * Grid-level highlighting options.
112
+ * Hover tracking is automatically enabled when any highlighting callback is defined.
113
+ * Each callback type has its own natural interpretation of `isHovered`:
114
+ * - computeRowClasses: isHovered = mouse is on any cell in this row
115
+ * - computeColumnClasses: isHovered = mouse is on any cell in this column
116
+ * - computeCellClasses: isHovered = mouse is on this exact cell
117
+ *
118
+ * For a crosshair effect, implement both computeRowClasses and computeColumnClasses.
119
+ */
120
+ interface HighlightingOptions<TData = Record<string, unknown>> {
121
+ /**
122
+ * Row-level class callback.
123
+ * Classes returned are applied to the row container element.
124
+ * Context has `rowIndex` set, `colIndex` is null.
125
+ * `isHovered` is true when the mouse is on any cell in this row.
126
+ * @returns Array of CSS class names
127
+ */
128
+ computeRowClasses?: (context: HighlightContext<TData>) => string[];
129
+ /**
130
+ * Column-level class callback.
131
+ * Classes returned are applied to all cells in that column (not header).
132
+ * Context has `colIndex` set, `rowIndex` is null.
133
+ * `isHovered` is true when the mouse is on any cell in this column.
134
+ * @returns Array of CSS class names
135
+ */
136
+ computeColumnClasses?: (context: HighlightContext<TData>) => string[];
137
+ /**
138
+ * Cell-level class callback.
139
+ * Classes returned are applied to individual cells for fine-grained control.
140
+ * Context has both `rowIndex` and `colIndex` set.
141
+ * `isHovered` is true only when the mouse is on this exact cell.
142
+ * @returns Array of CSS class names
143
+ */
144
+ computeCellClasses?: (context: HighlightContext<TData>) => string[];
145
+ }
146
+ //#endregion
147
+ //#region src/types/columns.d.ts
148
+ /** Column definition */
149
+ interface ColumnDefinition {
150
+ field: string;
151
+ colId?: string;
152
+ cellDataType: CellDataType;
153
+ width: number;
154
+ headerName?: string;
155
+ editable?: boolean;
156
+ /** Whether column is sortable. Default: true when sortingEnabled */
157
+ sortable?: boolean;
158
+ /** Whether column is filterable. Default: true */
159
+ filterable?: boolean;
160
+ /** Whether column is hidden. Hidden columns are not rendered but still exist in the definition. Default: false */
161
+ hidden?: boolean;
162
+ /** Renderer key for adapter lookup, or inline renderer function */
163
+ cellRenderer?: string;
164
+ editRenderer?: string;
165
+ headerRenderer?: string;
166
+ /**
167
+ * Per-column override for column-level highlighting.
168
+ * If defined, overrides grid-level computeColumnClasses for this column.
169
+ * Context has `colIndex` set, `rowIndex` is null.
170
+ * @returns Array of CSS class names to apply to all cells in this column
171
+ */
172
+ computeColumnClasses?: (context: HighlightContext) => string[];
173
+ /**
174
+ * Per-column override for cell-level highlighting.
175
+ * If defined, overrides grid-level computeCellClasses for cells in this column.
176
+ * Context has both `rowIndex` and `colIndex` set.
177
+ * @returns Array of CSS class names to apply to individual cells
178
+ */
179
+ computeCellClasses?: (context: HighlightContext) => string[];
180
+ }
181
+ //#endregion
182
+ //#region src/types/filters.d.ts
183
+ /** Text filter operators */
184
+ type TextFilterOperator = "contains" | "notContains" | "equals" | "notEquals" | "startsWith" | "endsWith" | "blank" | "notBlank";
185
+ /** Number filter operators (symbols for display) */
186
+ type NumberFilterOperator = "=" | "!=" | ">" | "<" | ">=" | "<=" | "between" | "blank" | "notBlank";
187
+ /** Date filter operators */
188
+ type DateFilterOperator = "=" | "!=" | ">" | "<" | "between" | "blank" | "notBlank";
189
+ /** Filter combination mode */
190
+ type FilterCombination = "and" | "or";
191
+ /** Text filter condition */
192
+ interface TextFilterCondition {
193
+ type: "text";
194
+ operator: TextFilterOperator;
195
+ value?: string;
196
+ /** Selected distinct values for checkbox-style filtering */
197
+ selectedValues?: Set<string>;
198
+ /** Include blank values */
199
+ includeBlank?: boolean;
200
+ /** Operator connecting this condition to the next. Defaults to ColumnFilterModel.combination */
201
+ nextOperator?: FilterCombination;
202
+ }
203
+ /** Number filter condition */
204
+ interface NumberFilterCondition {
205
+ type: "number";
206
+ operator: NumberFilterOperator;
207
+ value?: number;
208
+ /** Second value for "between" operator */
209
+ valueTo?: number;
210
+ /** Operator connecting this condition to the next. Defaults to ColumnFilterModel.combination */
211
+ nextOperator?: FilterCombination;
212
+ }
213
+ /** Date filter condition */
214
+ interface DateFilterCondition {
215
+ type: "date";
216
+ operator: DateFilterOperator;
217
+ value?: Date | string;
218
+ /** Second value for "between" operator */
219
+ valueTo?: Date | string;
220
+ /** Operator connecting this condition to the next. Defaults to ColumnFilterModel.combination */
221
+ nextOperator?: FilterCombination;
222
+ }
223
+ /** Union of filter condition types */
224
+ type FilterCondition = TextFilterCondition | NumberFilterCondition | DateFilterCondition;
225
+ /** Column filter model with multiple conditions */
226
+ interface ColumnFilterModel {
227
+ conditions: FilterCondition[];
228
+ combination: FilterCombination;
229
+ }
230
+ /** Filter model type - maps column ID to filter */
231
+ type FilterModel = Record<string, ColumnFilterModel>;
232
+ //#endregion
233
+ //#region src/types/data-source.d.ts
234
+ /** Data source request */
235
+ interface DataSourceRequest {
236
+ /** Pagination */
237
+ pagination: {
238
+ /** Page index */
239
+ pageIndex: number;
240
+ /** Page size */
241
+ pageSize: number;
242
+ };
243
+ /** Sort */
244
+ sort?: SortModel[];
245
+ /** Filter */
246
+ filter?: FilterModel;
247
+ }
248
+ /** Data source response */
249
+ interface DataSourceResponse<TData = Row> {
250
+ /** Rows */
251
+ rows: TData[];
252
+ /** Total rows */
253
+ totalRows: number;
254
+ }
255
+ /** Data source interface */
256
+ interface DataSource<TData = Row> {
257
+ fetch(request: DataSourceRequest): Promise<DataSourceResponse<TData>>;
258
+ /** Optional cleanup method to release resources */
259
+ destroy?: () => void;
260
+ }
261
+ //#endregion
262
+ //#region src/types/instructions.d.ts
263
+ /** Create slot instruction */
264
+ interface CreateSlotInstruction {
265
+ type: "CREATE_SLOT";
266
+ slotId: string;
267
+ }
268
+ /** Destroy slot instruction */
269
+ interface DestroySlotInstruction {
270
+ type: "DESTROY_SLOT";
271
+ slotId: string;
272
+ }
273
+ /** Assign slot instruction */
274
+ interface AssignSlotInstruction {
275
+ type: "ASSIGN_SLOT";
276
+ slotId: string;
277
+ rowIndex: number;
278
+ rowData: Row;
279
+ }
280
+ /** Move slot instruction */
281
+ interface MoveSlotInstruction {
282
+ type: "MOVE_SLOT";
283
+ slotId: string;
284
+ translateY: number;
285
+ }
286
+ /** Set active cell instruction */
287
+ interface SetActiveCellInstruction {
288
+ type: "SET_ACTIVE_CELL";
289
+ position: CellPosition | null;
290
+ }
291
+ /** Set hover position instruction (for highlighting) */
292
+ interface SetHoverPositionInstruction {
293
+ type: "SET_HOVER_POSITION";
294
+ position: CellPosition | null;
295
+ }
296
+ /** Set selection range instruction */
297
+ interface SetSelectionRangeInstruction {
298
+ type: "SET_SELECTION_RANGE";
299
+ range: CellRange | null;
300
+ }
301
+ /** Update visible range instruction - emitted when selection moves outside visible viewport */
302
+ interface UpdateVisibleRangeInstruction {
303
+ type: "UPDATE_VISIBLE_RANGE";
304
+ start: number;
305
+ end: number;
306
+ }
307
+ /** Start edit instruction */
308
+ interface StartEditInstruction {
309
+ type: "START_EDIT";
310
+ row: number;
311
+ col: number;
312
+ initialValue: CellValue;
313
+ }
314
+ /** Stop edit instruction */
315
+ interface StopEditInstruction {
316
+ type: "STOP_EDIT";
317
+ }
318
+ /** Commit edit instruction */
319
+ interface CommitEditInstruction {
320
+ type: "COMMIT_EDIT";
321
+ row: number;
322
+ col: number;
323
+ value: CellValue;
324
+ }
325
+ /** Set content size instruction */
326
+ interface SetContentSizeInstruction {
327
+ type: "SET_CONTENT_SIZE";
328
+ width: number;
329
+ height: number;
330
+ viewportWidth: number;
331
+ }
332
+ /** Update header instruction */
333
+ interface UpdateHeaderInstruction {
334
+ type: "UPDATE_HEADER";
335
+ colIndex: number;
336
+ column: ColumnDefinition;
337
+ sortDirection?: SortDirection;
338
+ sortIndex?: number;
339
+ /** Whether column is sortable */
340
+ sortable: boolean;
341
+ /** Whether column is filterable */
342
+ filterable: boolean;
343
+ /** Whether column has an active filter */
344
+ hasFilter: boolean;
345
+ }
346
+ /** Open filter popup instruction */
347
+ interface OpenFilterPopupInstruction {
348
+ type: "OPEN_FILTER_POPUP";
349
+ colIndex: number;
350
+ column: ColumnDefinition;
351
+ anchorRect: {
352
+ top: number;
353
+ left: number;
354
+ width: number;
355
+ height: number;
356
+ };
357
+ distinctValues: CellValue[];
358
+ currentFilter?: ColumnFilterModel;
359
+ }
360
+ /** Close filter popup instruction */
361
+ interface CloseFilterPopupInstruction {
362
+ type: "CLOSE_FILTER_POPUP";
363
+ }
364
+ /** Start fill instruction */
365
+ interface StartFillInstruction {
366
+ type: "START_FILL";
367
+ sourceRange: CellRange;
368
+ }
369
+ /** Update fill instruction */
370
+ interface UpdateFillInstruction {
371
+ type: "UPDATE_FILL";
372
+ targetRow: number;
373
+ targetCol: number;
374
+ }
375
+ /** Commit fill instruction */
376
+ interface CommitFillInstruction {
377
+ type: "COMMIT_FILL";
378
+ filledCells: Array<{
379
+ row: number;
380
+ col: number;
381
+ value: CellValue;
382
+ }>;
383
+ }
384
+ /** Cancel fill instruction */
385
+ interface CancelFillInstruction {
386
+ type: "CANCEL_FILL";
387
+ }
388
+ /** Data loading instruction */
389
+ interface DataLoadingInstruction {
390
+ type: "DATA_LOADING";
391
+ }
392
+ /** Data loaded instruction */
393
+ interface DataLoadedInstruction {
394
+ type: "DATA_LOADED";
395
+ totalRows: number;
396
+ }
397
+ /** Data error instruction */
398
+ interface DataErrorInstruction {
399
+ type: "DATA_ERROR";
400
+ error: string;
401
+ }
402
+ /** Rows added instruction */
403
+ interface RowsAddedInstruction {
404
+ type: "ROWS_ADDED";
405
+ indices: number[];
406
+ count: number;
407
+ totalRows: number;
408
+ }
409
+ /** Rows removed instruction */
410
+ interface RowsRemovedInstruction {
411
+ type: "ROWS_REMOVED";
412
+ indices: number[];
413
+ totalRows: number;
414
+ }
415
+ /** Rows updated instruction */
416
+ interface RowsUpdatedInstruction {
417
+ type: "ROWS_UPDATED";
418
+ indices: number[];
419
+ }
420
+ /** Transaction processed instruction */
421
+ interface TransactionProcessedInstruction {
422
+ type: "TRANSACTION_PROCESSED";
423
+ added: number;
424
+ removed: number;
425
+ updated: number;
426
+ }
427
+ /** Union type of all instructions */
428
+ type GridInstruction = /** Slot lifecycle */
429
+ CreateSlotInstruction | DestroySlotInstruction | AssignSlotInstruction | MoveSlotInstruction
430
+ /** Selection */ | SetActiveCellInstruction | SetSelectionRangeInstruction | UpdateVisibleRangeInstruction
431
+ /** Highlighting */ | SetHoverPositionInstruction
432
+ /** Editing */ | StartEditInstruction | StopEditInstruction | CommitEditInstruction
433
+ /** Layout */ | SetContentSizeInstruction | UpdateHeaderInstruction
434
+ /** Filter popup */ | OpenFilterPopupInstruction | CloseFilterPopupInstruction
435
+ /** Fill handle */ | StartFillInstruction | UpdateFillInstruction | CommitFillInstruction | CancelFillInstruction
436
+ /** Data */ | DataLoadingInstruction | DataLoadedInstruction | DataErrorInstruction
437
+ /** Transactions */ | RowsAddedInstruction | RowsRemovedInstruction | RowsUpdatedInstruction | TransactionProcessedInstruction;
438
+ /** Instruction listener: Single instruction Listener that receives a single instruction, used by frameworks to update their state */
439
+ type InstructionListener = (instruction: GridInstruction) => void;
440
+ /** Batch instruction listener: Batch instruction Listener that receives an array of instructions, used by frameworks to update their state */
441
+ type BatchInstructionListener = (instructions: GridInstruction[]) => void;
442
+ //#endregion
443
+ //#region src/types/renderers.d.ts
444
+ /** Cell renderer params */
445
+ interface CellRendererParams<TData extends Row = Row> {
446
+ /** Cell value */
447
+ value: CellValue;
448
+ /** Row data */
449
+ rowData: TData;
450
+ /** Column definition */
451
+ column: ColumnDefinition;
452
+ /** Row index */
453
+ rowIndex: number;
454
+ /** Column index */
455
+ colIndex: number;
456
+ /** Is active cell */
457
+ isActive: boolean;
458
+ /** Is selected cell */
459
+ isSelected: boolean;
460
+ /** Is editing cell */
461
+ isEditing: boolean;
462
+ }
463
+ /** Edit renderer params */
464
+ interface EditRendererParams<TData extends Row = Row> extends CellRendererParams<TData> {
465
+ /** Initial value */
466
+ initialValue: CellValue;
467
+ /** On value change */
468
+ onValueChange: (newValue: CellValue) => void;
469
+ /** On commit */
470
+ onCommit: () => void;
471
+ /** On cancel */
472
+ onCancel: () => void;
473
+ }
474
+ /** Header renderer params */
475
+ interface HeaderRendererParams {
476
+ /** Column definition */
477
+ column: ColumnDefinition;
478
+ /** Column index */
479
+ colIndex: number;
480
+ /** Sort direction */
481
+ sortDirection?: SortDirection;
482
+ /** Sort index */
483
+ sortIndex?: number;
484
+ /** Whether column is sortable */
485
+ sortable: boolean;
486
+ /** Whether column is filterable */
487
+ filterable: boolean;
488
+ /** Whether column has an active filter */
489
+ hasFilter: boolean;
490
+ /** On sort */
491
+ onSort: (direction: SortDirection | null, addToExisting: boolean) => void;
492
+ /** On filter click */
493
+ onFilterClick: () => void;
494
+ }
495
+ //#endregion
496
+ //#region src/types/options.d.ts
497
+ /** Grid core options */
498
+ interface GridCoreOptions<TData = Row> {
499
+ /** Column definitions */
500
+ columns: ColumnDefinition[];
501
+ /** Data source */
502
+ dataSource: DataSource<TData>;
503
+ /** Row height */
504
+ rowHeight: number;
505
+ /** Header height: Default to row height */
506
+ headerHeight?: number;
507
+ /** Overscan: How many rows to render outside the viewport */
508
+ overscan?: number;
509
+ /** Enable/disable sorting globally. Default: true */
510
+ sortingEnabled?: boolean;
511
+ /** Debounce time for transactions in ms. Default 50. Set to 0 for sync. */
512
+ transactionDebounceMs?: number;
513
+ /** Function to extract unique ID from row. Required for mutations. */
514
+ getRowId?: (row: TData) => RowId;
515
+ /** Row/column/cell highlighting configuration */
516
+ highlighting?: HighlightingOptions<TData>;
517
+ }
518
+ //#endregion
519
+ //#region src/types/input.d.ts
520
+ /** Framework-agnostic pointer/mouse event data */
521
+ interface PointerEventData {
522
+ /** X coordinate relative to viewport */
523
+ clientX: number;
524
+ /** Y coordinate relative to viewport */
525
+ clientY: number;
526
+ /** Mouse button (0 = left, 1 = middle, 2 = right) */
527
+ button: number;
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
+ /** Framework-agnostic keyboard event data */
536
+ interface KeyEventData {
537
+ /** Key value (e.g., 'Enter', 'ArrowUp', 'a') */
538
+ key: string;
539
+ /** Whether Shift key is pressed */
540
+ shiftKey: boolean;
541
+ /** Whether Ctrl key is pressed */
542
+ ctrlKey: boolean;
543
+ /** Whether Meta/Command key is pressed */
544
+ metaKey: boolean;
545
+ }
546
+ /** Container bounds and scroll position */
547
+ interface ContainerBounds {
548
+ /** Top position relative to viewport */
549
+ top: number;
550
+ /** Left position relative to viewport */
551
+ left: number;
552
+ /** Container width */
553
+ width: number;
554
+ /** Container height */
555
+ height: number;
556
+ /** Current scroll top position */
557
+ scrollTop: number;
558
+ /** Current scroll left position */
559
+ scrollLeft: number;
560
+ }
561
+ /** Result from mouse/pointer input handlers */
562
+ interface InputResult {
563
+ /** Whether to call preventDefault() on the event */
564
+ preventDefault: boolean;
565
+ /** Whether to call stopPropagation() on the event */
566
+ stopPropagation: boolean;
567
+ /** Whether framework should focus the container element */
568
+ focusContainer?: boolean;
569
+ /** Type of drag operation to start (framework manages global listeners) */
570
+ startDrag?: "selection" | "fill";
571
+ }
572
+ /** Result from keyboard input handler */
573
+ interface KeyboardResult {
574
+ /** Whether to call preventDefault() on the event */
575
+ preventDefault: boolean;
576
+ /** Cell to scroll into view (if navigation occurred) */
577
+ scrollToCell?: CellPosition;
578
+ }
579
+ /** Result from drag move handler */
580
+ interface DragMoveResult {
581
+ /** Target row index */
582
+ targetRow: number;
583
+ /** Target column index */
584
+ targetCol: number;
585
+ /** Auto-scroll deltas (null if no auto-scroll needed) */
586
+ autoScroll: {
587
+ dx: number;
588
+ dy: number;
589
+ } | null;
590
+ }
591
+ /** Options for InputHandler constructor */
592
+ interface InputHandlerDeps {
593
+ /** Get header height */
594
+ getHeaderHeight: () => number;
595
+ /** Get row height */
596
+ getRowHeight: () => number;
597
+ /** Get column positions array (indexed by visible column) */
598
+ getColumnPositions: () => number[];
599
+ /** Get visible column count */
600
+ getColumnCount: () => number;
601
+ /**
602
+ * Convert visible column index to original column index.
603
+ * Used when columns can be hidden. Returns the original index for selection tracking.
604
+ * If not provided, visible index is used directly (no hidden columns).
605
+ */
606
+ getOriginalColumnIndex?: (visibleIndex: number) => number;
607
+ }
608
+ /** Current drag state for UI rendering */
609
+ interface DragState {
610
+ /** Whether any drag operation is active */
611
+ isDragging: boolean;
612
+ /** Type of active drag operation */
613
+ dragType: "selection" | "fill" | null;
614
+ /** Source range for fill operations */
615
+ fillSourceRange: CellRange | null;
616
+ /** Current fill target position */
617
+ fillTarget: {
618
+ row: number;
619
+ col: number;
620
+ } | null;
621
+ }
622
+ //#endregion
623
+ //#region src/utils/positioning.d.ts
624
+ /**
625
+ * Calculate cumulative column positions (prefix sums)
626
+ * Returns an array where positions[i] is the left position of column i
627
+ * positions[columns.length] is the total width
628
+ */
629
+ declare const calculateColumnPositions: (columns: ColumnDefinition[]) => number[];
630
+ /**
631
+ * Get total width from column positions
632
+ */
633
+ declare const getTotalWidth: (columnPositions: number[]) => number;
634
+ /**
635
+ * Calculate scaled column positions when container is wider than total column widths.
636
+ * Columns expand proportionally based on their original width ratios.
637
+ *
638
+ * @param columns - Column definitions with original widths
639
+ * @param containerWidth - Available container width
640
+ * @returns Object with positions array and widths array
641
+ */
642
+ declare const calculateScaledColumnPositions: (columns: ColumnDefinition[], containerWidth: number) => {
643
+ positions: number[];
644
+ widths: number[];
645
+ };
646
+ /**
647
+ * Find column index at a given X coordinate
648
+ */
649
+ declare const findColumnAtX: (x: number, columnPositions: number[]) => number;
650
+ //#endregion
651
+ //#region src/utils/classNames.d.ts
652
+ /**
653
+ * Check if a cell is within the selection range
654
+ */
655
+ declare const isCellSelected: (row: number, col: number, selectionRange: CellRange | null) => boolean;
656
+ /**
657
+ * Check if a cell is the active cell
658
+ */
659
+ declare const isCellActive: (row: number, col: number, activeCell: CellPosition | null) => boolean;
660
+ /**
661
+ * Check if a row is within the visible range (not in overscan)
662
+ */
663
+ declare const isRowVisible: (row: number, visibleRowRange: {
664
+ start: number;
665
+ end: number;
666
+ } | null) => boolean;
667
+ /**
668
+ * Check if a cell is being edited
669
+ */
670
+ declare const isCellEditing: (row: number, col: number, editingCell: {
671
+ row: number;
672
+ col: number;
673
+ } | null) => boolean;
674
+ /**
675
+ * Check if a cell is in the fill preview range (vertical-only fill)
676
+ */
677
+ declare const isCellInFillPreview: (row: number, col: number, isDraggingFill: boolean, fillSourceRange: CellRange | null, fillTarget: {
678
+ row: number;
679
+ col: number;
680
+ } | null) => boolean;
681
+ /**
682
+ * Build cell CSS classes based on state
683
+ */
684
+ declare const buildCellClasses: (isActive: boolean, isSelected: boolean, isEditing: boolean, inFillPreview: boolean) => string;
685
+ /**
686
+ * Check if a row overlaps the selection range
687
+ */
688
+ declare const isRowInSelectionRange: (rowIndex: number, range: CellRange | null) => boolean;
689
+ /**
690
+ * Check if a column overlaps the selection range
691
+ */
692
+ declare const isColumnInSelectionRange: (colIndex: number, range: CellRange | null) => boolean;
693
+ //#endregion
694
+ //#region src/utils/event-emitter.d.ts
695
+ /**
696
+ * Batch instruction listener for efficient state updates
697
+ */
698
+ type BatchInstructionListener$1 = (instructions: GridInstruction[]) => void;
699
+ //#endregion
700
+ //#region src/selection.d.ts
701
+ type Direction = "up" | "down" | "left" | "right";
702
+ interface SelectionManagerOptions {
703
+ getRowCount: () => number;
704
+ getColumnCount: () => number;
705
+ getCellValue: (row: number, col: number) => CellValue;
706
+ getRowData: (row: number) => Row | undefined;
707
+ getColumn: (col: number) => ColumnDefinition | undefined;
708
+ }
709
+ /**
710
+ * Manages Excel-style cell selection, keyboard navigation, and clipboard operations.
711
+ */
712
+ declare class SelectionManager {
713
+ private state;
714
+ private options;
715
+ private emitter;
716
+ onInstruction: (listener: InstructionListener) => () => void;
717
+ private emit;
718
+ constructor(options: SelectionManagerOptions);
719
+ getState(): SelectionState;
720
+ getActiveCell(): CellPosition | null;
721
+ getSelectionRange(): CellRange | null;
722
+ isSelected(row: number, col: number): boolean;
723
+ isActiveCell(row: number, col: number): boolean;
724
+ /**
725
+ * Start a selection at the given cell.
726
+ * @param cell - The cell to select
727
+ * @param opts.shift - Extend selection from anchor (range select)
728
+ * @param opts.ctrl - Toggle selection mode
729
+ */
730
+ startSelection(cell: CellPosition, opts?: {
731
+ shift?: boolean;
732
+ ctrl?: boolean;
733
+ }): void;
734
+ /**
735
+ * Move focus in a direction, optionally extending the selection.
736
+ */
737
+ moveFocus(direction: Direction, extend?: boolean): void;
738
+ /**
739
+ * Select all cells in the grid (Ctrl+A).
740
+ */
741
+ selectAll(): void;
742
+ /**
743
+ * Clear the current selection.
744
+ */
745
+ clearSelection(): void;
746
+ /**
747
+ * Set the active cell directly.
748
+ */
749
+ setActiveCell(row: number, col: number): void;
750
+ /**
751
+ * Set the selection range directly.
752
+ */
753
+ setSelectionRange(range: CellRange): void;
754
+ /**
755
+ * Get the data from the currently selected cells as a 2D array.
756
+ */
757
+ getSelectedData(): CellValue[][];
758
+ /**
759
+ * Copy the selected data to the clipboard (Ctrl+C).
760
+ */
761
+ copySelectionToClipboard(): Promise<void>;
762
+ /**
763
+ * Clean up resources for garbage collection.
764
+ */
765
+ destroy(): void;
766
+ private clampPosition;
767
+ }
768
+ //#endregion
769
+ //#region src/fill.d.ts
770
+ interface FillManagerOptions {
771
+ getRowCount: () => number;
772
+ getColumnCount: () => number;
773
+ getCellValue: (row: number, col: number) => CellValue;
774
+ getColumn: (col: number) => ColumnDefinition | undefined;
775
+ setCellValue: (row: number, col: number, value: CellValue) => void;
776
+ }
777
+ /**
778
+ * Manages fill handle operations including pattern detection and auto-fill.
779
+ */
780
+ declare class FillManager {
781
+ private state;
782
+ private options;
783
+ private emitter;
784
+ onInstruction: (listener: InstructionListener) => () => void;
785
+ private emit;
786
+ constructor(options: FillManagerOptions);
787
+ getState(): FillHandleState | null;
788
+ isActive(): boolean;
789
+ /**
790
+ * Start a fill drag operation from a source range.
791
+ */
792
+ startFillDrag(sourceRange: CellRange): void;
793
+ /**
794
+ * Update the fill drag target position.
795
+ */
796
+ updateFillDrag(targetRow: number, targetCol: number): void;
797
+ /**
798
+ * Commit the fill operation - apply pattern to target cells.
799
+ */
800
+ commitFillDrag(): void;
801
+ /**
802
+ * Cancel the fill operation.
803
+ */
804
+ cancelFillDrag(): void;
805
+ /**
806
+ * Clean up resources for garbage collection.
807
+ */
808
+ destroy(): void;
809
+ /**
810
+ * Calculate the values to fill based on source pattern.
811
+ */
812
+ private calculateFilledCells;
813
+ private getSourceColumnValues;
814
+ private detectPattern;
815
+ private applyPattern;
816
+ }
817
+ //#endregion
818
+ //#region src/input-handler.d.ts
819
+ declare class InputHandler<TData extends Row = Row> {
820
+ private core;
821
+ private deps;
822
+ private isDraggingSelection;
823
+ private isDraggingFill;
824
+ private fillSourceRange;
825
+ private fillTarget;
826
+ constructor(core: GridCore<TData>, deps: InputHandlerDeps);
827
+ /**
828
+ * Update dependencies (called when options change)
829
+ */
830
+ updateDeps(deps: Partial<InputHandlerDeps>): void;
831
+ /**
832
+ * Get current drag state for UI rendering
833
+ */
834
+ getDragState(): DragState;
835
+ /**
836
+ * Handle cell mouse down event
837
+ */
838
+ handleCellMouseDown(rowIndex: number, colIndex: number, event: PointerEventData): InputResult;
839
+ /**
840
+ * Handle cell double click event (start editing)
841
+ */
842
+ handleCellDoubleClick(rowIndex: number, colIndex: number): void;
843
+ /**
844
+ * Handle cell mouse enter event (for hover highlighting)
845
+ */
846
+ handleCellMouseEnter(rowIndex: number, colIndex: number): void;
847
+ /**
848
+ * Handle cell mouse leave event (for hover highlighting)
849
+ */
850
+ handleCellMouseLeave(): void;
851
+ /**
852
+ * Handle fill handle mouse down event
853
+ */
854
+ handleFillHandleMouseDown(activeCell: CellPosition | null, selectionRange: CellRange | null, _event: PointerEventData): InputResult;
855
+ /**
856
+ * Handle header click event (cycle sort direction)
857
+ */
858
+ handleHeaderClick(colId: string, addToExisting: boolean): void;
859
+ /**
860
+ * Start selection drag (called by framework after handleCellMouseDown returns startDrag: 'selection')
861
+ */
862
+ startSelectionDrag(): void;
863
+ /**
864
+ * Handle drag move event (selection or fill)
865
+ */
866
+ handleDragMove(event: PointerEventData, bounds: ContainerBounds): DragMoveResult | null;
867
+ /**
868
+ * Handle drag end event
869
+ */
870
+ handleDragEnd(): void;
871
+ /**
872
+ * Handle wheel event with dampening for large datasets
873
+ * Returns scroll deltas or null if no dampening needed
874
+ */
875
+ handleWheel(deltaY: number, deltaX: number, dampening: number): {
876
+ dy: number;
877
+ dx: number;
878
+ } | null;
879
+ /**
880
+ * Handle keyboard event
881
+ */
882
+ handleKeyDown(event: KeyEventData, activeCell: CellPosition | null, editingCell: {
883
+ row: number;
884
+ col: number;
885
+ } | null, filterPopupOpen: boolean): KeyboardResult;
886
+ /**
887
+ * Calculate auto-scroll deltas based on mouse position
888
+ */
889
+ private calculateAutoScroll;
890
+ }
891
+ //#endregion
892
+ //#region src/highlight-manager.d.ts
893
+ interface HighlightManagerOptions {
894
+ getActiveCell: () => CellPosition | null;
895
+ getSelectionRange: () => CellRange | null;
896
+ getColumn: (colIndex: number) => ColumnDefinition | undefined;
897
+ }
898
+ /**
899
+ * Manages row/column/cell highlighting state and class computation.
900
+ * Emits SET_HOVER_POSITION instructions when hover position changes.
901
+ */
902
+ declare class HighlightManager<TData = Record<string, unknown>> {
903
+ private options;
904
+ private highlightingOptions;
905
+ private hoverPosition;
906
+ private emitter;
907
+ onInstruction: (listener: InstructionListener) => () => void;
908
+ private emit;
909
+ private rowClassCache;
910
+ private columnClassCache;
911
+ private cellClassCache;
912
+ constructor(options: HighlightManagerOptions, highlightingOptions?: HighlightingOptions<TData>);
913
+ /**
914
+ * Check if highlighting is enabled (any callback defined).
915
+ * Hover tracking is automatically enabled when highlighting is enabled.
916
+ */
917
+ isEnabled(): boolean;
918
+ /**
919
+ * Update highlighting options. Clears all caches.
920
+ */
921
+ updateOptions(options: HighlightingOptions<TData>): void;
922
+ /**
923
+ * Set the current hover position. Clears caches and emits instruction.
924
+ * Hover tracking is automatically enabled when any highlighting callback is defined.
925
+ */
926
+ setHoverPosition(position: CellPosition | null): void;
927
+ /**
928
+ * Get the current hover position
929
+ */
930
+ getHoverPosition(): CellPosition | null;
931
+ /**
932
+ * Called when selection changes. Clears all caches.
933
+ */
934
+ onSelectionChange(): void;
935
+ /**
936
+ * Build context for row highlighting callback.
937
+ * Returns context with `rowIndex` set, `colIndex` is null.
938
+ * `isHovered` is true when the mouse is on any cell in this row.
939
+ */
940
+ buildRowContext(rowIndex: number, rowData?: TData): HighlightContext<TData>;
941
+ /**
942
+ * Build context for column highlighting callback.
943
+ * Returns context with `colIndex` set, `rowIndex` is null.
944
+ * `isHovered` is true when the mouse is on any cell in this column.
945
+ */
946
+ buildColumnContext(colIndex: number, column: ColumnDefinition): HighlightContext<TData>;
947
+ /**
948
+ * Build context for cell highlighting callback.
949
+ * Returns context with both `rowIndex` and `colIndex` set.
950
+ * `isHovered` is true only when the mouse is on this exact cell.
951
+ */
952
+ buildCellContext(rowIndex: number, colIndex: number, column: ColumnDefinition, rowData?: TData): HighlightContext<TData>;
953
+ /**
954
+ * Compute row classes using cache and user callback
955
+ */
956
+ computeRowClasses(rowIndex: number, rowData?: TData): string[];
957
+ /**
958
+ * Compute column classes using cache and user callback (or per-column override)
959
+ */
960
+ computeColumnClasses(colIndex: number, column: ColumnDefinition): string[];
961
+ /**
962
+ * Compute cell classes using cache and user callback (or per-column override)
963
+ */
964
+ computeCellClasses(rowIndex: number, colIndex: number, column: ColumnDefinition, rowData?: TData): string[];
965
+ /**
966
+ * Compute combined cell classes (column + cell classes flattened)
967
+ */
968
+ computeCombinedCellClasses(rowIndex: number, colIndex: number, column: ColumnDefinition, rowData?: TData): string[];
969
+ /**
970
+ * Clear all caches
971
+ */
972
+ clearAllCaches(): void;
973
+ /**
974
+ * Destroy the manager and release resources
975
+ */
976
+ destroy(): void;
977
+ }
978
+ //#endregion
979
+ //#region src/sort-filter-manager.d.ts
980
+ interface SortFilterManagerOptions<TData> {
981
+ /** Get all columns */
982
+ getColumns: () => ColumnDefinition[];
983
+ /** Check if sorting is enabled globally */
984
+ isSortingEnabled: () => boolean;
985
+ /** Get cached rows for distinct value computation */
986
+ getCachedRows: () => Map<number, TData>;
987
+ /** Called when sort/filter changes to trigger data refresh */
988
+ onSortFilterChange: () => Promise<void>;
989
+ /** Called after data refresh to update UI */
990
+ onDataRefreshed: () => void;
991
+ }
992
+ /**
993
+ * Manages sorting and filtering state and operations.
994
+ */
995
+ declare class SortFilterManager<TData = Record<string, unknown>> {
996
+ private options;
997
+ private emitter;
998
+ private sortModel;
999
+ private filterModel;
1000
+ private openFilterColIndex;
1001
+ onInstruction: (listener: InstructionListener) => () => void;
1002
+ private emit;
1003
+ constructor(options: SortFilterManagerOptions<TData>);
1004
+ setSort(colId: string, direction: SortDirection | null, addToExisting?: boolean): Promise<void>;
1005
+ getSortModel(): SortModel[];
1006
+ setFilter(colId: string, filter: ColumnFilterModel | string | null): Promise<void>;
1007
+ getFilterModel(): FilterModel;
1008
+ /**
1009
+ * Check if a column has an active filter
1010
+ */
1011
+ hasActiveFilter(colId: string): boolean;
1012
+ /**
1013
+ * Check if a column is sortable
1014
+ */
1015
+ isColumnSortable(colIndex: number): boolean;
1016
+ /**
1017
+ * Check if a column is filterable
1018
+ */
1019
+ isColumnFilterable(colIndex: number): boolean;
1020
+ /**
1021
+ * Get distinct values for a column (for filter dropdowns)
1022
+ * For array-type columns (like tags), each unique array combination is returned.
1023
+ * Arrays are sorted internally for consistent comparison.
1024
+ * Limited to maxValues to avoid performance issues with large datasets.
1025
+ */
1026
+ getDistinctValuesForColumn(colId: string, maxValues?: number): CellValue[];
1027
+ /**
1028
+ * Open filter popup for a column (toggles if already open for same column)
1029
+ */
1030
+ openFilterPopup(colIndex: number, anchorRect: {
1031
+ top: number;
1032
+ left: number;
1033
+ width: number;
1034
+ height: number;
1035
+ }): void;
1036
+ /**
1037
+ * Close filter popup
1038
+ */
1039
+ closeFilterPopup(): void;
1040
+ /**
1041
+ * Get sort info map for header rendering
1042
+ */
1043
+ getSortInfoMap(): Map<string, {
1044
+ direction: SortDirection;
1045
+ index: number;
1046
+ }>;
1047
+ destroy(): void;
1048
+ }
1049
+ //#endregion
1050
+ //#region src/row-mutation-manager.d.ts
1051
+ interface RowMutationManagerOptions<TData> {
1052
+ /** Get the cached rows map */
1053
+ getCachedRows: () => Map<number, TData>;
1054
+ /** Set the cached rows map (for bulk operations) */
1055
+ setCachedRows: (rows: Map<number, TData>) => void;
1056
+ /** Get total row count */
1057
+ getTotalRows: () => number;
1058
+ /** Set total row count */
1059
+ setTotalRows: (count: number) => void;
1060
+ /** Update a single slot after row change */
1061
+ updateSlot: (rowIndex: number) => void;
1062
+ /** Refresh all slots after bulk changes */
1063
+ refreshAllSlots: () => void;
1064
+ /** Emit content size change */
1065
+ emitContentSize: () => void;
1066
+ /** Clear selection if it references invalid rows */
1067
+ clearSelectionIfInvalid: (maxValidRow: number) => void;
1068
+ }
1069
+ /**
1070
+ * Manages row CRUD operations and cache management.
1071
+ */
1072
+ declare class RowMutationManager<TData extends Row = Row> {
1073
+ private options;
1074
+ private emitter;
1075
+ onInstruction: (listener: InstructionListener) => () => void;
1076
+ private emit;
1077
+ constructor(options: RowMutationManagerOptions<TData>);
1078
+ /**
1079
+ * Get a row by index.
1080
+ */
1081
+ getRow(index: number): TData | undefined;
1082
+ /**
1083
+ * Add rows to the grid at the specified index.
1084
+ * If no index is provided, rows are added at the end.
1085
+ */
1086
+ addRows(rows: TData[], index?: number): void;
1087
+ /**
1088
+ * Update existing rows with partial data.
1089
+ */
1090
+ updateRows(updates: Array<{
1091
+ index: number;
1092
+ data: Partial<TData>;
1093
+ }>): void;
1094
+ /**
1095
+ * Delete rows at the specified indices.
1096
+ */
1097
+ deleteRows(indices: number[]): void;
1098
+ /**
1099
+ * Set a complete row at the specified index.
1100
+ * Use this for complete row replacement. For partial updates, use updateRows.
1101
+ */
1102
+ setRow(index: number, data: TData): void;
1103
+ destroy(): void;
1104
+ }
1105
+ //#endregion
1106
+ //#region src/grid-core.d.ts
1107
+ declare class GridCore<TData extends Row = Row> {
1108
+ private columns;
1109
+ private dataSource;
1110
+ private rowHeight;
1111
+ private headerHeight;
1112
+ private overscan;
1113
+ private sortingEnabled;
1114
+ private scrollTop;
1115
+ private scrollLeft;
1116
+ private viewportWidth;
1117
+ private viewportHeight;
1118
+ private cachedRows;
1119
+ private totalRows;
1120
+ private currentPageIndex;
1121
+ private pageSize;
1122
+ readonly selection: SelectionManager;
1123
+ readonly fill: FillManager;
1124
+ readonly input: InputHandler<TData>;
1125
+ readonly highlight: HighlightManager<TData> | null;
1126
+ readonly sortFilter: SortFilterManager<TData>;
1127
+ readonly rowMutation: RowMutationManager<TData>;
1128
+ private readonly slotPool;
1129
+ private readonly editManager;
1130
+ private columnPositions;
1131
+ private emitter;
1132
+ onInstruction: (listener: InstructionListener) => () => void;
1133
+ onBatchInstruction: (listener: BatchInstructionListener$1) => () => void;
1134
+ private emit;
1135
+ private emitBatch;
1136
+ private naturalContentHeight;
1137
+ private virtualContentHeight;
1138
+ private scrollRatio;
1139
+ private isDestroyed;
1140
+ constructor(options: GridCoreOptions<TData>);
1141
+ /**
1142
+ * Initialize the grid and load initial data.
1143
+ */
1144
+ initialize(): Promise<void>;
1145
+ /**
1146
+ * Update viewport measurements and sync slots.
1147
+ * When scroll virtualization is active, maps the DOM scroll position to the actual row position.
1148
+ */
1149
+ setViewport(scrollTop: number, scrollLeft: number, width: number, height: number): void;
1150
+ private fetchData;
1151
+ private fetchAllData;
1152
+ setSort(colId: string, direction: SortDirection | null, addToExisting?: boolean): Promise<void>;
1153
+ setFilter(colId: string, filter: ColumnFilterModel | string | null): Promise<void>;
1154
+ hasActiveFilter(colId: string): boolean;
1155
+ isColumnSortable(colIndex: number): boolean;
1156
+ isColumnFilterable(colIndex: number): boolean;
1157
+ getDistinctValuesForColumn(colId: string, maxValues?: number): CellValue[];
1158
+ openFilterPopup(colIndex: number, anchorRect: {
1159
+ top: number;
1160
+ left: number;
1161
+ width: number;
1162
+ height: number;
1163
+ }): void;
1164
+ closeFilterPopup(): void;
1165
+ getSortModel(): SortModel[];
1166
+ getFilterModel(): FilterModel;
1167
+ startEdit(row: number, col: number): void;
1168
+ updateEditValue(value: CellValue): void;
1169
+ commitEdit(): void;
1170
+ cancelEdit(): void;
1171
+ getEditState(): EditState | null;
1172
+ getCellValue(row: number, col: number): CellValue;
1173
+ setCellValue(row: number, col: number, value: CellValue): void;
1174
+ private computeColumnPositions;
1175
+ private emitContentSize;
1176
+ private emitHeaders;
1177
+ getColumns(): ColumnDefinition[];
1178
+ getColumnPositions(): number[];
1179
+ getRowCount(): number;
1180
+ getRowHeight(): number;
1181
+ getHeaderHeight(): number;
1182
+ getTotalWidth(): number;
1183
+ getTotalHeight(): number;
1184
+ /**
1185
+ * Check if scroll scaling is active (large datasets exceeding browser scroll limits).
1186
+ * When scaling is active, scrollRatio < 1 and scroll positions are compressed.
1187
+ */
1188
+ isScalingActive(): boolean;
1189
+ /**
1190
+ * Get the natural (uncapped) content height.
1191
+ * Useful for debugging or displaying actual content size.
1192
+ */
1193
+ getNaturalHeight(): number;
1194
+ /**
1195
+ * Get the scroll ratio used for scroll virtualization.
1196
+ * Returns 1 when no virtualization is needed, < 1 when content exceeds browser limits.
1197
+ */
1198
+ getScrollRatio(): number;
1199
+ /**
1200
+ * Get the visible row range (excluding overscan).
1201
+ * Returns the first and last row indices that are actually visible in the viewport.
1202
+ * Includes partially visible rows to avoid false positives when clicking on edge rows.
1203
+ */
1204
+ getVisibleRowRange(): {
1205
+ start: number;
1206
+ end: number;
1207
+ };
1208
+ /**
1209
+ * Get the scroll position needed to bring a row into view.
1210
+ * Accounts for scroll scaling when active.
1211
+ */
1212
+ getScrollTopForRow(rowIndex: number): number;
1213
+ /**
1214
+ * Get the row index at a given viewport Y position.
1215
+ * Accounts for scroll scaling when active.
1216
+ * @param viewportY Y position in viewport (physical pixels below header, NOT including scroll)
1217
+ * @param virtualScrollTop Current scroll position from container.scrollTop (virtual/scaled)
1218
+ */
1219
+ getRowIndexAtDisplayY(viewportY: number, virtualScrollTop: number): number;
1220
+ getRowData(rowIndex: number): TData | undefined;
1221
+ /**
1222
+ * Refresh data from the data source.
1223
+ */
1224
+ refresh(): Promise<void>;
1225
+ /**
1226
+ * Refresh slot display without refetching data.
1227
+ * Useful after in-place data modifications like fill operations.
1228
+ */
1229
+ refreshSlotData(): void;
1230
+ /**
1231
+ * Add rows to the grid at the specified index.
1232
+ * If no index is provided, rows are added at the end.
1233
+ */
1234
+ addRows(rows: TData[], index?: number): void;
1235
+ /**
1236
+ * Update existing rows with partial data.
1237
+ */
1238
+ updateRows(updates: Array<{
1239
+ index: number;
1240
+ data: Partial<TData>;
1241
+ }>): void;
1242
+ /**
1243
+ * Delete rows at the specified indices.
1244
+ */
1245
+ deleteRows(indices: number[]): void;
1246
+ /**
1247
+ * Get a row by index.
1248
+ */
1249
+ getRow(index: number): TData | undefined;
1250
+ /**
1251
+ * Set a complete row at the specified index.
1252
+ * Use this for complete row replacement. For partial updates, use updateRows.
1253
+ */
1254
+ setRow(index: number, data: TData): void;
1255
+ /**
1256
+ * Update the data source and refresh.
1257
+ */
1258
+ setDataSource(dataSource: DataSource<TData>): Promise<void>;
1259
+ /**
1260
+ * Update columns and recompute layout.
1261
+ */
1262
+ setColumns(columns: ColumnDefinition[]): void;
1263
+ /**
1264
+ * Destroy the grid core and release all references.
1265
+ * Call this before discarding the GridCore to ensure proper cleanup.
1266
+ * This method is idempotent - safe to call multiple times.
1267
+ */
1268
+ destroy(): void;
1269
+ }
1270
+ //#endregion
1271
+ //#region src/slot-pool.d.ts
1272
+ interface SlotPoolManagerOptions {
1273
+ /** Get current row height */
1274
+ getRowHeight: () => number;
1275
+ /** Get current header height */
1276
+ getHeaderHeight: () => number;
1277
+ /** Get overscan count */
1278
+ getOverscan: () => number;
1279
+ /** Get current scroll top position (natural, not virtual) */
1280
+ getScrollTop: () => number;
1281
+ /** Get viewport height */
1282
+ getViewportHeight: () => number;
1283
+ /** Get total row count */
1284
+ getTotalRows: () => number;
1285
+ /** Get scroll ratio for virtualization (1 = no virtualization) */
1286
+ getScrollRatio: () => number;
1287
+ /** Get virtual content height */
1288
+ getVirtualContentHeight: () => number;
1289
+ /** Get row data by index */
1290
+ getRowData: (rowIndex: number) => Row | undefined;
1291
+ }
1292
+ /**
1293
+ * Manages the slot pool for virtual scrolling.
1294
+ * Handles slot creation, recycling, positioning, and destruction.
1295
+ */
1296
+ declare class SlotPoolManager {
1297
+ private state;
1298
+ private options;
1299
+ private emitter;
1300
+ private isDestroyed;
1301
+ onInstruction: (listener: InstructionListener) => () => void;
1302
+ onBatchInstruction: (listener: BatchInstructionListener$1) => () => void;
1303
+ private emit;
1304
+ private emitBatch;
1305
+ constructor(options: SlotPoolManagerOptions);
1306
+ /**
1307
+ * Get the slot ID for a given row index.
1308
+ */
1309
+ getSlotForRow(rowIndex: number): string | undefined;
1310
+ /**
1311
+ * Get all current slots.
1312
+ */
1313
+ getSlots(): Map<string, SlotState>;
1314
+ /**
1315
+ * Synchronize slots with current viewport position.
1316
+ * This implements the slot recycling strategy.
1317
+ */
1318
+ syncSlots(): void;
1319
+ /**
1320
+ * Destroy all slots.
1321
+ */
1322
+ destroyAllSlots(): void;
1323
+ /**
1324
+ * Clean up resources for garbage collection.
1325
+ * This method is idempotent - safe to call multiple times.
1326
+ */
1327
+ destroy(): void;
1328
+ /**
1329
+ * Refresh all slot data without changing which rows are displayed.
1330
+ * Used after filtering/sorting when data changes.
1331
+ */
1332
+ refreshAllSlots(): void;
1333
+ /**
1334
+ * Update a single slot's data.
1335
+ */
1336
+ updateSlot(rowIndex: number): void;
1337
+ /**
1338
+ * Calculate the translateY position for a row.
1339
+ * Handles scroll virtualization for very large datasets.
1340
+ */
1341
+ private getRowTranslateY;
1342
+ }
1343
+ //#endregion
1344
+ //#region src/edit-manager.d.ts
1345
+ interface EditManagerOptions {
1346
+ /** Get column definition by index */
1347
+ getColumn: (colIndex: number) => ColumnDefinition | undefined;
1348
+ /** Get cell value */
1349
+ getCellValue: (row: number, col: number) => CellValue;
1350
+ /** Set cell value */
1351
+ setCellValue: (row: number, col: number, value: CellValue) => void;
1352
+ /** Callback when edit is committed (to update slot display) */
1353
+ onCommit?: (row: number, col: number, value: CellValue) => void;
1354
+ }
1355
+ /**
1356
+ * Manages cell editing state and operations.
1357
+ */
1358
+ declare class EditManager {
1359
+ private editState;
1360
+ private options;
1361
+ private emitter;
1362
+ onInstruction: (listener: InstructionListener) => () => void;
1363
+ private emit;
1364
+ constructor(options: EditManagerOptions);
1365
+ /**
1366
+ * Get the current edit state.
1367
+ */
1368
+ getState(): EditState | null;
1369
+ /**
1370
+ * Check if currently editing.
1371
+ */
1372
+ isEditing(): boolean;
1373
+ /**
1374
+ * Check if a specific cell is being edited.
1375
+ */
1376
+ isEditingCell(row: number, col: number): boolean;
1377
+ /**
1378
+ * Start editing a cell.
1379
+ * Returns true if edit was started, false if cell is not editable.
1380
+ */
1381
+ startEdit(row: number, col: number): boolean;
1382
+ /**
1383
+ * Update the current edit value.
1384
+ */
1385
+ updateValue(value: CellValue): void;
1386
+ /**
1387
+ * Commit the current edit.
1388
+ * Saves the value and closes the editor.
1389
+ */
1390
+ commit(): void;
1391
+ /**
1392
+ * Cancel the current edit.
1393
+ * Discards changes and closes the editor.
1394
+ */
1395
+ cancel(): void;
1396
+ /**
1397
+ * Clean up resources for garbage collection.
1398
+ */
1399
+ destroy(): void;
1400
+ }
1401
+ //#endregion
1402
+ //#region src/sorting/parallel-sort-manager.d.ts
1403
+ interface ParallelSortOptions {
1404
+ /** Maximum number of workers (default: navigator.hardwareConcurrency || 4) */
1405
+ maxWorkers?: number;
1406
+ /** Threshold for parallel sorting (default: 400000) */
1407
+ parallelThreshold?: number;
1408
+ /** Minimum chunk size (default: 50000) */
1409
+ minChunkSize?: number;
1410
+ }
1411
+ /**
1412
+ * Manages parallel sorting operations using a worker pool.
1413
+ * Automatically decides between single-worker and parallel sorting based on data size.
1414
+ */
1415
+ declare class ParallelSortManager {
1416
+ private pool;
1417
+ private parallelThreshold;
1418
+ private minChunkSize;
1419
+ private isTerminated;
1420
+ constructor(options?: ParallelSortOptions);
1421
+ /**
1422
+ * Check if the manager is available for use.
1423
+ */
1424
+ isAvailable(): boolean;
1425
+ /**
1426
+ * Terminate all workers and clean up resources.
1427
+ */
1428
+ terminate(): void;
1429
+ /**
1430
+ * Sort indices using values array.
1431
+ * Automatically uses parallel sorting for large datasets.
1432
+ */
1433
+ sortIndices(values: number[], direction: SortDirection): Promise<Uint32Array>;
1434
+ /**
1435
+ * Sort string hashes with collision detection.
1436
+ * Automatically uses parallel sorting for large datasets.
1437
+ */
1438
+ sortStringHashes(hashChunks: Float64Array[], direction: SortDirection, originalStrings: string[]): Promise<Uint32Array>;
1439
+ /**
1440
+ * Multi-column sort.
1441
+ * Automatically uses parallel sorting for large datasets.
1442
+ */
1443
+ sortMultiColumn(columns: number[][], directions: SortDirection[]): Promise<Uint32Array>;
1444
+ private sortIndicesSingle;
1445
+ private sortStringHashesSingle;
1446
+ private sortMultiColumnSingle;
1447
+ private sortIndicesParallel;
1448
+ private sortStringHashesParallel;
1449
+ private sortMultiColumnParallel;
1450
+ /**
1451
+ * Split data into chunks for parallel processing.
1452
+ */
1453
+ private splitIntoChunks;
1454
+ /**
1455
+ * Calculate chunk boundaries without copying data.
1456
+ */
1457
+ private calculateChunkBoundaries;
1458
+ /**
1459
+ * Detect collisions at chunk boundaries for string sorting.
1460
+ */
1461
+ private detectBoundaryCollisionsForStrings;
1462
+ /**
1463
+ * Resolve hash collisions using localeCompare.
1464
+ */
1465
+ private resolveCollisions;
1466
+ }
1467
+ //#endregion
1468
+ //#region src/sorting/worker-pool.d.ts
1469
+ interface WorkerPoolOptions {
1470
+ /** Maximum number of workers (default: navigator.hardwareConcurrency ?? 4) */
1471
+ maxWorkers?: number;
1472
+ /** Whether to pre-warm workers on initialization */
1473
+ preWarm?: boolean;
1474
+ }
1475
+ /**
1476
+ * Manages a pool of Web Workers for parallel task execution.
1477
+ * Workers are created lazily and reused across operations.
1478
+ */
1479
+ declare class WorkerPool {
1480
+ private workerCode;
1481
+ private maxWorkers;
1482
+ private workers;
1483
+ private workerUrl;
1484
+ private nextRequestId;
1485
+ private isTerminated;
1486
+ constructor(workerCode: string, options?: WorkerPoolOptions);
1487
+ /**
1488
+ * Get the current pool size (number of active workers).
1489
+ */
1490
+ getPoolSize(): number;
1491
+ /**
1492
+ * Get the maximum pool size.
1493
+ */
1494
+ getMaxWorkers(): number;
1495
+ /**
1496
+ * Check if the pool is available for use.
1497
+ */
1498
+ isAvailable(): boolean;
1499
+ /**
1500
+ * Execute a single task on an available worker.
1501
+ * Returns the worker's response.
1502
+ */
1503
+ execute<TRequest extends {
1504
+ id?: number;
1505
+ }, TResponse>(request: TRequest, transferables?: Transferable[]): Promise<TResponse>;
1506
+ /**
1507
+ * Execute multiple tasks in parallel across available workers.
1508
+ * Each task is assigned to a different worker if possible.
1509
+ * Returns results in the same order as the input requests.
1510
+ */
1511
+ executeParallel<TRequest extends {
1512
+ id?: number;
1513
+ }, TResponse>(tasks: Array<{
1514
+ request: TRequest;
1515
+ transferables?: Transferable[];
1516
+ }>): Promise<TResponse[]>;
1517
+ /**
1518
+ * Terminate all workers and clean up resources.
1519
+ */
1520
+ terminate(): void;
1521
+ /**
1522
+ * Pre-warm workers by creating them ahead of time.
1523
+ */
1524
+ private preWarmWorkers;
1525
+ /**
1526
+ * Ensure at least `count` workers exist in the pool.
1527
+ */
1528
+ private ensureWorkers;
1529
+ /**
1530
+ * Get an available worker, creating one if needed.
1531
+ */
1532
+ private getAvailableWorker;
1533
+ /**
1534
+ * Create a new worker and add it to the pool.
1535
+ */
1536
+ private createWorker;
1537
+ /**
1538
+ * Respawn a failed worker.
1539
+ */
1540
+ private respawnWorker;
1541
+ }
1542
+ //#endregion
1543
+ //#region src/sorting/k-way-merge.d.ts
1544
+ /**
1545
+ * Represents a sorted chunk with its values and offset in the original array.
1546
+ */
1547
+ interface SortedChunk {
1548
+ /** Sorted indices (local to this chunk) */
1549
+ indices: Uint32Array;
1550
+ /** Values for comparison (in same order as indices) */
1551
+ values: Float64Array;
1552
+ /** Offset of this chunk in the original array */
1553
+ offset: number;
1554
+ }
1555
+ /**
1556
+ * Represents a sorted chunk for multi-column sorting.
1557
+ */
1558
+ interface MultiColumnSortedChunk {
1559
+ /** Sorted indices (local to this chunk) */
1560
+ indices: Uint32Array;
1561
+ /** Values for comparison - array of columns, each in same order as indices */
1562
+ columns: Float64Array[];
1563
+ /** Sort directions for each column (1 = asc, -1 = desc) */
1564
+ directions: Int8Array;
1565
+ /** Offset of this chunk in the original array */
1566
+ offset: number;
1567
+ }
1568
+ /**
1569
+ * Merge multiple sorted chunks into a single sorted result.
1570
+ * Uses a min-heap for O(n log k) time complexity.
1571
+ *
1572
+ * @param chunks - Array of sorted chunks to merge
1573
+ * @param direction - Sort direction ('asc' or 'desc')
1574
+ * @returns Uint32Array of globally sorted indices
1575
+ */
1576
+ declare function kWayMerge(chunks: SortedChunk[], direction: SortDirection): Uint32Array;
1577
+ /**
1578
+ * Merge multiple sorted chunks for multi-column sorting.
1579
+ *
1580
+ * @param chunks - Array of multi-column sorted chunks
1581
+ * @returns Uint32Array of globally sorted indices
1582
+ */
1583
+ declare function kWayMergeMultiColumn(chunks: MultiColumnSortedChunk[]): Uint32Array;
1584
+ /**
1585
+ * Detect collision runs at chunk boundaries after merge.
1586
+ * This is used for string sorting where hashes may collide across chunks.
1587
+ *
1588
+ * @param chunks - Original sorted chunks with their hash values
1589
+ * @param _direction - Sort direction
1590
+ * @returns Array of boundary collision positions [start1, end1, start2, end2, ...]
1591
+ */
1592
+ declare function detectBoundaryCollisions(chunks: SortedChunk[], _direction: SortDirection): Uint32Array;
1593
+ //#endregion
1594
+ //#region src/data-source/client-data-source.d.ts
1595
+ interface ClientDataSourceOptions<TData> {
1596
+ /** Custom field accessor for nested properties */
1597
+ getFieldValue?: (row: TData, field: string) => CellValue;
1598
+ /** Use Web Worker for sorting large datasets (default: true) */
1599
+ useWorker?: boolean;
1600
+ /** Options for parallel sorting (only used when useWorker is true) */
1601
+ parallelSort?: ParallelSortOptions | false;
1602
+ }
1603
+ /**
1604
+ * Creates a client-side data source that holds all data in memory.
1605
+ * Sorting and filtering are performed client-side.
1606
+ * For large datasets, sorting is automatically offloaded to a Web Worker.
1607
+ */
1608
+ declare function createClientDataSource<TData extends Row = Row>(data: TData[], options?: ClientDataSourceOptions<TData>): DataSource<TData>;
1609
+ /**
1610
+ * Convenience function to create a data source from an array.
1611
+ * This provides backwards compatibility with the old `rowData` prop.
1612
+ */
1613
+ declare function createDataSourceFromArray<TData extends Row = Row>(data: TData[]): DataSource<TData>;
1614
+ //#endregion
1615
+ //#region src/data-source/server-data-source.d.ts
1616
+ type ServerFetchFunction<TData> = (request: DataSourceRequest) => Promise<DataSourceResponse<TData>>;
1617
+ /**
1618
+ * Creates a server-side data source that delegates all operations to the server.
1619
+ * The fetch function receives sort/filter/pagination params to pass to the API.
1620
+ */
1621
+ declare function createServerDataSource<TData extends Row = Row>(fetchFn: ServerFetchFunction<TData>): DataSource<TData>;
1622
+ //#endregion
1623
+ //#region src/indexed-data-store/indexed-data-store.d.ts
1624
+ interface IndexedDataStoreOptions<TData> {
1625
+ /** Function to extract unique ID from row. Required for mutations. */
1626
+ getRowId: (row: TData) => RowId;
1627
+ /** Custom field accessor for nested properties */
1628
+ getFieldValue?: (row: TData, field: string) => CellValue;
1629
+ }
1630
+ /** Hash cache for a single row */
1631
+ interface RowSortCache {
1632
+ /** Map: sortModelHash -> computed hashes for that sort configuration */
1633
+ hashes: Map<string, number[]>;
1634
+ }
1635
+ /**
1636
+ * Efficient data structure for incremental operations on grid data.
1637
+ * Supports:
1638
+ * - O(1) lookup by row ID
1639
+ * - O(log n) binary insertion to maintain sort order
1640
+ * - Filter state caching with distinct values
1641
+ * - Hash caching for fast sorted comparisons
1642
+ */
1643
+ declare class IndexedDataStore<TData extends Row = Row> {
1644
+ private rows;
1645
+ private rowById;
1646
+ private sortedIndices;
1647
+ private sortModel;
1648
+ private sortModelHash;
1649
+ private filterModel;
1650
+ private filteredIndices;
1651
+ private distinctValues;
1652
+ private rowSortCache;
1653
+ private options;
1654
+ constructor(initialData: TData[] | undefined, options: IndexedDataStoreOptions<TData>);
1655
+ /**
1656
+ * Clear all data and internal caches.
1657
+ * Used for proper memory cleanup when the store is no longer needed.
1658
+ */
1659
+ clear(): void;
1660
+ /**
1661
+ * Replace all data (used for initial load or full refresh).
1662
+ */
1663
+ setData(data: TData[]): void;
1664
+ /**
1665
+ * Query data with sorting, filtering, and pagination.
1666
+ * Compatible with DataSource.fetch() interface.
1667
+ */
1668
+ query(request: DataSourceRequest): DataSourceResponse<TData>;
1669
+ /**
1670
+ * Get row by ID.
1671
+ */
1672
+ getRowById(id: RowId): TData | undefined;
1673
+ /**
1674
+ * Get row by index.
1675
+ */
1676
+ getRowByIndex(index: number): TData | undefined;
1677
+ /**
1678
+ * Get total row count (unfiltered).
1679
+ */
1680
+ getTotalRowCount(): number;
1681
+ /**
1682
+ * Get visible row count (after filtering).
1683
+ */
1684
+ getVisibleRowCount(): number;
1685
+ /**
1686
+ * Get distinct values for a field (for filter UI).
1687
+ */
1688
+ getDistinctValues(field: string): CellValue[];
1689
+ /**
1690
+ * Add rows to the store.
1691
+ * Rows are inserted at their correct sorted position.
1692
+ */
1693
+ addRows(rows: TData[]): void;
1694
+ /**
1695
+ * Add a single row.
1696
+ */
1697
+ private addRow;
1698
+ /**
1699
+ * Remove rows by ID.
1700
+ */
1701
+ removeRows(ids: RowId[]): void;
1702
+ /**
1703
+ * Remove a single row by index.
1704
+ */
1705
+ private removeRowByIndex;
1706
+ /**
1707
+ * Update indices after a row removal.
1708
+ */
1709
+ private reindexAfterRemoval;
1710
+ /**
1711
+ * Update a cell value.
1712
+ */
1713
+ updateCell(id: RowId, field: string, value: CellValue): void;
1714
+ /**
1715
+ * Update multiple fields on a row.
1716
+ */
1717
+ updateRow(id: RowId, data: Partial<TData>): void;
1718
+ /**
1719
+ * Set the sort model. Triggers full re-sort if model changed.
1720
+ */
1721
+ setSortModel(model: SortModel[]): void;
1722
+ /**
1723
+ * Get current sort model.
1724
+ */
1725
+ getSortModel(): SortModel[];
1726
+ /**
1727
+ * Set the filter model.
1728
+ */
1729
+ setFilterModel(model: FilterModel): void;
1730
+ /**
1731
+ * Get current filter model.
1732
+ */
1733
+ getFilterModel(): FilterModel;
1734
+ /**
1735
+ * Rebuild sorted indices (full re-sort).
1736
+ */
1737
+ private rebuildSortedIndices;
1738
+ /**
1739
+ * Rebuild hash cache for all rows.
1740
+ */
1741
+ private rebuildHashCache;
1742
+ /**
1743
+ * Compute and cache sort hashes for a row.
1744
+ */
1745
+ private computeRowHashes;
1746
+ /**
1747
+ * Compare two rows using cached hashes.
1748
+ */
1749
+ private compareRows;
1750
+ /**
1751
+ * Binary search for insertion position in sortedIndices.
1752
+ */
1753
+ private binarySearchInsertPosition;
1754
+ /**
1755
+ * Rebuild filtered indices.
1756
+ */
1757
+ private rebuildFilteredIndices;
1758
+ /**
1759
+ * Check if a row passes the current filter.
1760
+ */
1761
+ private rowPassesFilter;
1762
+ /**
1763
+ * Get visible indices (filtered + sorted).
1764
+ */
1765
+ private getVisibleIndices;
1766
+ /**
1767
+ * Rebuild distinct values cache for all fields.
1768
+ */
1769
+ private rebuildDistinctValues;
1770
+ /**
1771
+ * Update distinct values when a row is added or removed.
1772
+ */
1773
+ private updateDistinctValuesForRow;
1774
+ /**
1775
+ * Update distinct value for a specific field when cell value changes.
1776
+ */
1777
+ private updateDistinctValueForField;
1778
+ }
1779
+ //#endregion
1780
+ //#region src/indexed-data-store/field-helpers.d.ts
1781
+ /**
1782
+ * Default field value accessor supporting dot notation.
1783
+ * @example
1784
+ * getFieldValue({ user: { name: "John" } }, "user.name") // "John"
1785
+ */
1786
+ declare function getFieldValue<TData extends Row>(row: TData, field: string): CellValue;
1787
+ /**
1788
+ * Set field value supporting dot notation.
1789
+ * Creates nested objects if they don't exist.
1790
+ * @example
1791
+ * const obj = { user: {} };
1792
+ * setFieldValue(obj, "user.name", "John");
1793
+ * // obj is now { user: { name: "John" } }
1794
+ */
1795
+ declare function setFieldValue<TData extends Row>(row: TData, field: string, value: CellValue): void;
1796
+ //#endregion
1797
+ //#region src/indexed-data-store/sorting.d.ts
1798
+ /**
1799
+ * Convert a string to a sortable number using first 10 characters.
1800
+ * Uses base-36 encoding (a-z = 0-25, 0-9 = 26-35).
1801
+ */
1802
+ declare function stringToSortableNumber(str: string): number;
1803
+ /**
1804
+ * Compare two cell values for sorting.
1805
+ * Handles null/undefined, arrays, numbers, dates, and strings.
1806
+ */
1807
+ declare function compareValues(a: CellValue, b: CellValue): number;
1808
+ /**
1809
+ * Compute a sortable hash for a cell value.
1810
+ * Used for fast comparisons in sorted indices.
1811
+ */
1812
+ declare function computeValueHash(value: CellValue): number;
1813
+ //#endregion
1814
+ //#region src/filtering/index.d.ts
1815
+ /**
1816
+ * Check if two dates are on the same day.
1817
+ */
1818
+ declare function isSameDay(date1: Date, date2: Date): boolean;
1819
+ /**
1820
+ * Evaluate a text filter condition against a cell value.
1821
+ */
1822
+ declare function evaluateTextCondition(cellValue: CellValue, condition: TextFilterCondition): boolean;
1823
+ /**
1824
+ * Evaluate a number filter condition against a cell value.
1825
+ */
1826
+ declare function evaluateNumberCondition(cellValue: CellValue, condition: NumberFilterCondition): boolean;
1827
+ /**
1828
+ * Evaluate a date filter condition against a cell value.
1829
+ */
1830
+ declare function evaluateDateCondition(cellValue: CellValue, condition: DateFilterCondition): boolean;
1831
+ /**
1832
+ * Evaluate a column filter model against a cell value.
1833
+ * Uses left-to-right evaluation with per-condition operators.
1834
+ */
1835
+ declare function evaluateColumnFilter(cellValue: CellValue, filter: ColumnFilterModel): boolean;
1836
+ /**
1837
+ * Check if a row passes all filters in a filter model.
1838
+ */
1839
+ declare function rowPassesFilter<TData extends Row>(row: TData, filterModel: FilterModel, getFieldValue: (row: TData, field: string) => CellValue): boolean;
1840
+ //#endregion
1841
+ //#region src/transaction-manager.d.ts
1842
+ interface AddTransaction<TData> {
1843
+ type: "ADD";
1844
+ rows: TData[];
1845
+ }
1846
+ interface RemoveTransaction {
1847
+ type: "REMOVE";
1848
+ rowIds: RowId[];
1849
+ }
1850
+ interface UpdateCellTransaction {
1851
+ type: "UPDATE_CELL";
1852
+ rowId: RowId;
1853
+ field: string;
1854
+ value: CellValue;
1855
+ }
1856
+ interface UpdateRowTransaction<TData> {
1857
+ type: "UPDATE_ROW";
1858
+ rowId: RowId;
1859
+ data: Partial<TData>;
1860
+ }
1861
+ type Transaction<TData> = AddTransaction<TData> | RemoveTransaction | UpdateCellTransaction | UpdateRowTransaction<TData>;
1862
+ interface TransactionResult {
1863
+ added: number;
1864
+ removed: number;
1865
+ updated: number;
1866
+ }
1867
+ interface TransactionManagerOptions<TData extends Row> {
1868
+ /** Debounce time in milliseconds. Default 50. Set to 0 for sync. */
1869
+ debounceMs: number;
1870
+ /** The indexed data store to apply transactions to */
1871
+ store: IndexedDataStore<TData>;
1872
+ /** Callback when transactions are processed */
1873
+ onProcessed?: (result: TransactionResult) => void;
1874
+ }
1875
+ /**
1876
+ * Manages a queue of data mutations with debounced batch processing.
1877
+ * Supports ADD, REMOVE, UPDATE_CELL, and UPDATE_ROW operations.
1878
+ */
1879
+ declare class TransactionManager<TData extends Row = Row> {
1880
+ private queue;
1881
+ private debounceTimer;
1882
+ private pendingPromise;
1883
+ private options;
1884
+ constructor(options: TransactionManagerOptions<TData>);
1885
+ /**
1886
+ * Queue rows to be added.
1887
+ */
1888
+ add(rows: TData[]): void;
1889
+ /**
1890
+ * Queue rows to be removed by ID.
1891
+ */
1892
+ remove(rowIds: RowId[]): void;
1893
+ /**
1894
+ * Queue a cell update.
1895
+ */
1896
+ updateCell(rowId: RowId, field: string, value: CellValue): void;
1897
+ /**
1898
+ * Queue a row update (multiple fields).
1899
+ */
1900
+ updateRow(rowId: RowId, data: Partial<TData>): void;
1901
+ /**
1902
+ * Force immediate processing of queued transactions.
1903
+ * Returns a promise that resolves when processing is complete.
1904
+ */
1905
+ flush(): Promise<void>;
1906
+ /**
1907
+ * Check if there are pending transactions.
1908
+ */
1909
+ hasPending(): boolean;
1910
+ /**
1911
+ * Get count of pending transactions.
1912
+ */
1913
+ getPendingCount(): number;
1914
+ /**
1915
+ * Clear all pending transactions without processing.
1916
+ */
1917
+ clear(): void;
1918
+ /**
1919
+ * Schedule processing after throttle delay.
1920
+ * Uses throttle pattern: if a timer is already pending, new transactions
1921
+ * are added to the queue but don't reset the timer. This ensures updates
1922
+ * are processed even when they arrive faster than the throttle interval.
1923
+ */
1924
+ private scheduleProcessing;
1925
+ /**
1926
+ * Process all queued transactions.
1927
+ */
1928
+ private processQueue;
1929
+ }
1930
+ //#endregion
1931
+ //#region src/data-source/mutable-data-source.d.ts
1932
+ /** Callback for data change notifications */
1933
+ type DataChangeListener = (result: TransactionResult) => void;
1934
+ /**
1935
+ * Data source with mutation capabilities.
1936
+ * Extends DataSource with add, remove, and update operations.
1937
+ */
1938
+ interface MutableDataSource<TData = Row> extends DataSource<TData> {
1939
+ /** Add rows to the data source. Queued and processed after debounce. */
1940
+ addRows(rows: TData[]): void;
1941
+ /** Remove rows by ID. Queued and processed after debounce. */
1942
+ removeRows(ids: RowId[]): void;
1943
+ /** Update a cell value. Queued and processed after debounce. */
1944
+ updateCell(id: RowId, field: string, value: CellValue): void;
1945
+ /** Update multiple fields on a row. Queued and processed after debounce. */
1946
+ updateRow(id: RowId, data: Partial<TData>): void;
1947
+ /** Force immediate processing of queued transactions. */
1948
+ flushTransactions(): Promise<void>;
1949
+ /** Check if there are pending transactions. */
1950
+ hasPendingTransactions(): boolean;
1951
+ /** Get distinct values for a field (for filter UI). */
1952
+ getDistinctValues(field: string): CellValue[];
1953
+ /** Get a row by ID. */
1954
+ getRowById(id: RowId): TData | undefined;
1955
+ /** Get total row count. */
1956
+ getTotalRowCount(): number;
1957
+ /** Subscribe to data change notifications. Returns unsubscribe function. */
1958
+ subscribe(listener: DataChangeListener): () => void;
1959
+ /** Clear all data from the data source. */
1960
+ clear(): void;
1961
+ }
1962
+ interface MutableClientDataSourceOptions<TData> {
1963
+ /** Function to extract unique ID from row. Required. */
1964
+ getRowId: (row: TData) => RowId;
1965
+ /** Custom field accessor for nested properties. */
1966
+ getFieldValue?: (row: TData, field: string) => CellValue;
1967
+ /** Debounce time for transactions in ms. Default 50. Set to 0 for sync. */
1968
+ debounceMs?: number;
1969
+ /** Callback when transactions are processed. */
1970
+ onTransactionProcessed?: (result: TransactionResult) => void;
1971
+ }
1972
+ /**
1973
+ * Creates a mutable client-side data source with transaction support.
1974
+ * Uses IndexedDataStore for efficient incremental operations.
1975
+ */
1976
+ declare function createMutableClientDataSource<TData extends Row = Row>(data: TData[], options: MutableClientDataSourceOptions<TData>): MutableDataSource<TData>;
1977
+ //#endregion
1978
+ //#region src/styles/variables.d.ts
1979
+ declare const variablesStyles: string;
1980
+ //#endregion
1981
+ //#region src/styles/container.d.ts
1982
+ declare const containerStyles: string;
1983
+ //#endregion
1984
+ //#region src/styles/header.d.ts
1985
+ declare const headerStyles: string;
1986
+ //#endregion
1987
+ //#region src/styles/cells.d.ts
1988
+ declare const cellStyles: string;
1989
+ //#endregion
1990
+ //#region src/styles/states.d.ts
1991
+ declare const statesStyles: string;
1992
+ //#endregion
1993
+ //#region src/styles/scrollbar.d.ts
1994
+ declare const scrollbarStyles: string;
1995
+ //#endregion
1996
+ //#region src/styles/filters.d.ts
1997
+ declare const filtersStyles: string;
1998
+ //#endregion
1999
+ //#region src/styles/index.d.ts
2000
+ /**
2001
+ * Combined grid styles from all modules
2002
+ */
2003
+ declare const gridStyles: string;
2004
+ /**
2005
+ * Inject grid styles into the document head.
2006
+ * This is called automatically when the Grid component mounts.
2007
+ * Styles are only injected once, even if multiple Grid instances exist.
2008
+ */
2009
+ declare function injectStyles(): void;
2010
+ //#endregion
2011
+ //#region src/types/ui-state.d.ts
2012
+ interface SlotData<TData = Row> {
2013
+ slotId: string;
2014
+ rowIndex: number;
2015
+ rowData: TData;
2016
+ translateY: number;
2017
+ }
2018
+ interface HeaderData {
2019
+ column: ColumnDefinition;
2020
+ sortDirection?: SortDirection;
2021
+ sortIndex?: number;
2022
+ sortable: boolean;
2023
+ filterable: boolean;
2024
+ hasFilter: boolean;
2025
+ }
2026
+ interface FilterPopupState {
2027
+ isOpen: boolean;
2028
+ colIndex: number;
2029
+ column: ColumnDefinition | null;
2030
+ anchorRect: {
2031
+ top: number;
2032
+ left: number;
2033
+ width: number;
2034
+ height: number;
2035
+ } | null;
2036
+ distinctValues: CellValue[];
2037
+ currentFilter?: ColumnFilterModel;
2038
+ }
2039
+ interface GridState<TData = Row> {
2040
+ slots: Map<string, SlotData<TData>>;
2041
+ activeCell: CellPosition | null;
2042
+ selectionRange: CellRange | null;
2043
+ editingCell: {
2044
+ row: number;
2045
+ col: number;
2046
+ initialValue: CellValue;
2047
+ } | null;
2048
+ contentWidth: number;
2049
+ contentHeight: number;
2050
+ /** Viewport width (container's visible width) for column scaling */
2051
+ viewportWidth: number;
2052
+ headers: Map<number, HeaderData>;
2053
+ filterPopup: FilterPopupState | null;
2054
+ isLoading: boolean;
2055
+ error: string | null;
2056
+ totalRows: number;
2057
+ /** Visible row range (start inclusive, end inclusive). Used to prevent selection showing in overscan. */
2058
+ visibleRowRange: {
2059
+ start: number;
2060
+ end: number;
2061
+ } | null;
2062
+ /** Currently hovered cell position (for highlighting) */
2063
+ hoverPosition: CellPosition | null;
2064
+ }
2065
+ //#endregion
2066
+ export { type AssignSlotInstruction, type BatchInstructionListener, type CancelFillInstruction, type CellDataType, type CellPosition, type CellRange, type CellRendererParams, type CellValue, type CloseFilterPopupInstruction, type ColumnDefinition, type ColumnFilterModel, type CommitEditInstruction, type CommitFillInstruction, type ContainerBounds, type CreateSlotInstruction, type DataChangeListener, type DataErrorInstruction, type DataLoadedInstruction, type DataLoadingInstruction, type DataSource, type DataSourceRequest, type DataSourceResponse, type DateFilterCondition, type DateFilterOperator, type DestroySlotInstruction, type Direction, type DragMoveResult, type DragState, EditManager, type EditManagerOptions, type EditRendererParams, type EditState, type FillHandleState, FillManager, type FilterCombination, type FilterCondition, type FilterModel, type FilterPopupState, GridCore, type GridCoreOptions, type GridInstruction, type GridState, type HeaderData, type HeaderRendererParams, type HighlightContext, HighlightManager, type HighlightingOptions, IndexedDataStore, type IndexedDataStoreOptions, InputHandler, type InputHandlerDeps, type InputResult, type InstructionListener, type KeyEventData, type KeyboardResult, type MoveSlotInstruction, type MultiColumnSortedChunk, type MutableClientDataSourceOptions, type MutableDataSource, type NumberFilterCondition, type NumberFilterOperator, type OpenFilterPopupInstruction, ParallelSortManager, type ParallelSortOptions, type PointerEventData, type Row, type RowId, type RowSortCache, type RowsAddedInstruction, type RowsRemovedInstruction, type RowsUpdatedInstruction, SelectionManager, type SelectionState, type SetActiveCellInstruction, type SetContentSizeInstruction, type SetHoverPositionInstruction, type SetSelectionRangeInstruction, type SlotData, type BatchInstructionListener$1 as SlotPoolBatchListener, SlotPoolManager, type SlotPoolManagerOptions, type SlotState, type SortDirection, type SortModel, type SortedChunk, type StartEditInstruction, type StartFillInstruction, type StopEditInstruction, type TextFilterCondition, type TextFilterOperator, type Transaction, TransactionManager, type TransactionManagerOptions, type TransactionProcessedInstruction, type TransactionResult, type UpdateFillInstruction, type UpdateHeaderInstruction, WorkerPool, type WorkerPoolOptions, buildCellClasses, calculateColumnPositions, calculateScaledColumnPositions, cellStyles, compareValues, computeValueHash, containerStyles, createClientDataSource, createDataSourceFromArray, createMutableClientDataSource, createServerDataSource, detectBoundaryCollisions, evaluateColumnFilter, evaluateDateCondition, evaluateNumberCondition, evaluateTextCondition, filtersStyles, findColumnAtX, getFieldValue, getTotalWidth, gridStyles, headerStyles, injectStyles, isCellActive, isCellEditing, isCellInFillPreview, isCellSelected, isColumnInSelectionRange, isRowInSelectionRange, isRowVisible, isSameDay, kWayMerge, kWayMergeMultiColumn, rowPassesFilter, scrollbarStyles, setFieldValue, statesStyles, stringToSortableNumber, variablesStyles };
2067
+ //# sourceMappingURL=index.d.ts.map