@gp-grid/core 0.8.3 → 0.9.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 +1194 -887
- package/dist/index.js +136 -8
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -159,6 +159,59 @@ interface HighlightingOptions<TData = Record<string, unknown>> {
|
|
|
159
159
|
computeCellClasses?: (context: HighlightContext<TData>) => string[];
|
|
160
160
|
}
|
|
161
161
|
//#endregion
|
|
162
|
+
//#region src/types/renderers.d.ts
|
|
163
|
+
/** Cell renderer params */
|
|
164
|
+
interface CellRendererParams<TData extends Row = Row> {
|
|
165
|
+
/** Cell value */
|
|
166
|
+
value: CellValue;
|
|
167
|
+
/** Row data */
|
|
168
|
+
rowData: TData;
|
|
169
|
+
/** Column definition */
|
|
170
|
+
column: ColumnDefinition;
|
|
171
|
+
/** Row index */
|
|
172
|
+
rowIndex: number;
|
|
173
|
+
/** Column index */
|
|
174
|
+
colIndex: number;
|
|
175
|
+
/** Is active cell */
|
|
176
|
+
isActive: boolean;
|
|
177
|
+
/** Is selected cell */
|
|
178
|
+
isSelected: boolean;
|
|
179
|
+
/** Is editing cell */
|
|
180
|
+
isEditing: boolean;
|
|
181
|
+
}
|
|
182
|
+
/** Edit renderer params */
|
|
183
|
+
interface EditRendererParams<TData extends Row = Row> extends CellRendererParams<TData> {
|
|
184
|
+
/** Initial value */
|
|
185
|
+
initialValue: CellValue;
|
|
186
|
+
/** On value change */
|
|
187
|
+
onValueChange: (newValue: CellValue) => void;
|
|
188
|
+
/** On commit */
|
|
189
|
+
onCommit: () => void;
|
|
190
|
+
/** On cancel */
|
|
191
|
+
onCancel: () => void;
|
|
192
|
+
}
|
|
193
|
+
/** Header renderer params */
|
|
194
|
+
interface HeaderRendererParams {
|
|
195
|
+
/** Column definition */
|
|
196
|
+
column: ColumnDefinition;
|
|
197
|
+
/** Column index */
|
|
198
|
+
colIndex: number;
|
|
199
|
+
/** Sort direction */
|
|
200
|
+
sortDirection?: SortDirection;
|
|
201
|
+
/** Sort index */
|
|
202
|
+
sortIndex?: number;
|
|
203
|
+
/** Whether column is sortable */
|
|
204
|
+
sortable: boolean;
|
|
205
|
+
/** Whether column is filterable */
|
|
206
|
+
filterable: boolean;
|
|
207
|
+
/** Whether column has an active filter */
|
|
208
|
+
hasFilter: boolean;
|
|
209
|
+
/** On sort */
|
|
210
|
+
onSort: (direction: SortDirection | null, addToExisting: boolean) => void;
|
|
211
|
+
/** On filter click */
|
|
212
|
+
onFilterClick: () => void;
|
|
213
|
+
}
|
|
214
|
+
//#endregion
|
|
162
215
|
//#region src/types/columns.d.ts
|
|
163
216
|
/** Column definition */
|
|
164
217
|
interface ColumnDefinition {
|
|
@@ -174,10 +227,20 @@ interface ColumnDefinition {
|
|
|
174
227
|
filterable?: boolean;
|
|
175
228
|
/** Whether column is hidden. Hidden columns are not rendered but still exist in the definition. Default: false */
|
|
176
229
|
hidden?: boolean;
|
|
230
|
+
/** Whether column is resizable by dragging the header edge. Default: true */
|
|
231
|
+
resizable?: boolean;
|
|
232
|
+
/** Minimum width in pixels when resizing. Default: 50 */
|
|
233
|
+
minWidth?: number;
|
|
234
|
+
/** Maximum width in pixels when resizing. Default: undefined (no limit) */
|
|
235
|
+
maxWidth?: number;
|
|
236
|
+
/** Whether column can be moved/reordered by dragging the header. Default: true */
|
|
237
|
+
movable?: boolean;
|
|
238
|
+
/** Whether this column acts as a drag handle for row dragging. Default: false */
|
|
239
|
+
rowDrag?: boolean;
|
|
177
240
|
/** Renderer key for adapter lookup, or inline renderer function */
|
|
178
|
-
cellRenderer?: string;
|
|
179
|
-
editRenderer?: string;
|
|
180
|
-
headerRenderer?: string;
|
|
241
|
+
cellRenderer?: string | ((params: CellRendererParams) => unknown);
|
|
242
|
+
editRenderer?: string | ((params: EditRendererParams) => unknown);
|
|
243
|
+
headerRenderer?: string | ((params: HeaderRendererParams) => unknown);
|
|
181
244
|
/**
|
|
182
245
|
* Per-column override for column-level highlighting.
|
|
183
246
|
* If defined, overrides grid-level computeColumnClasses for this column.
|
|
@@ -362,10 +425,6 @@ interface UpdateHeaderInstruction {
|
|
|
362
425
|
column: ColumnDefinition;
|
|
363
426
|
sortDirection?: SortDirection;
|
|
364
427
|
sortIndex?: number;
|
|
365
|
-
/** Whether column is sortable */
|
|
366
|
-
sortable: boolean;
|
|
367
|
-
/** Whether column is filterable */
|
|
368
|
-
filterable: boolean;
|
|
369
428
|
/** Whether column has an active filter */
|
|
370
429
|
hasFilter: boolean;
|
|
371
430
|
}
|
|
@@ -450,65 +509,83 @@ interface TransactionProcessedInstruction {
|
|
|
450
509
|
removed: number;
|
|
451
510
|
updated: number;
|
|
452
511
|
}
|
|
453
|
-
/**
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
/** Cell renderer params */
|
|
462
|
-
interface CellRendererParams<TData extends Row = Row> {
|
|
463
|
-
/** Cell value */
|
|
464
|
-
value: CellValue;
|
|
465
|
-
/** Row data */
|
|
466
|
-
rowData: TData;
|
|
467
|
-
/** Column definition */
|
|
468
|
-
column: ColumnDefinition;
|
|
469
|
-
/** Row index */
|
|
470
|
-
rowIndex: number;
|
|
471
|
-
/** Column index */
|
|
512
|
+
/** Columns changed (after resize, reorder, etc.) */
|
|
513
|
+
interface ColumnsChangedInstruction {
|
|
514
|
+
type: "COLUMNS_CHANGED";
|
|
515
|
+
columns: ColumnDefinition[];
|
|
516
|
+
}
|
|
517
|
+
/** Column resize started */
|
|
518
|
+
interface StartColumnResizeInstruction {
|
|
519
|
+
type: "START_COLUMN_RESIZE";
|
|
472
520
|
colIndex: number;
|
|
473
|
-
|
|
474
|
-
isActive: boolean;
|
|
475
|
-
/** Is selected cell */
|
|
476
|
-
isSelected: boolean;
|
|
477
|
-
/** Is editing cell */
|
|
478
|
-
isEditing: boolean;
|
|
521
|
+
initialWidth: number;
|
|
479
522
|
}
|
|
480
|
-
/**
|
|
481
|
-
interface
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
onValueChange: (newValue: CellValue) => void;
|
|
486
|
-
/** On commit */
|
|
487
|
-
onCommit: () => void;
|
|
488
|
-
/** On cancel */
|
|
489
|
-
onCancel: () => void;
|
|
523
|
+
/** Column resize in progress */
|
|
524
|
+
interface UpdateColumnResizeInstruction {
|
|
525
|
+
type: "UPDATE_COLUMN_RESIZE";
|
|
526
|
+
colIndex: number;
|
|
527
|
+
currentWidth: number;
|
|
490
528
|
}
|
|
491
|
-
/**
|
|
492
|
-
interface
|
|
493
|
-
|
|
494
|
-
column: ColumnDefinition;
|
|
495
|
-
/** Column index */
|
|
529
|
+
/** Column resize committed */
|
|
530
|
+
interface CommitColumnResizeInstruction {
|
|
531
|
+
type: "COMMIT_COLUMN_RESIZE";
|
|
496
532
|
colIndex: number;
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
533
|
+
newWidth: number;
|
|
534
|
+
}
|
|
535
|
+
/** Column resize cancelled */
|
|
536
|
+
interface CancelColumnResizeInstruction {
|
|
537
|
+
type: "CANCEL_COLUMN_RESIZE";
|
|
538
|
+
}
|
|
539
|
+
/** Column move started */
|
|
540
|
+
interface StartColumnMoveInstruction {
|
|
541
|
+
type: "START_COLUMN_MOVE";
|
|
542
|
+
sourceColIndex: number;
|
|
543
|
+
}
|
|
544
|
+
/** Column move position updated */
|
|
545
|
+
interface UpdateColumnMoveInstruction {
|
|
546
|
+
type: "UPDATE_COLUMN_MOVE";
|
|
547
|
+
currentX: number;
|
|
548
|
+
currentY: number;
|
|
549
|
+
dropTargetIndex: number | null;
|
|
550
|
+
}
|
|
551
|
+
/** Column move committed */
|
|
552
|
+
interface CommitColumnMoveInstruction {
|
|
553
|
+
type: "COMMIT_COLUMN_MOVE";
|
|
554
|
+
sourceColIndex: number;
|
|
555
|
+
targetColIndex: number;
|
|
556
|
+
}
|
|
557
|
+
/** Column move cancelled */
|
|
558
|
+
interface CancelColumnMoveInstruction {
|
|
559
|
+
type: "CANCEL_COLUMN_MOVE";
|
|
560
|
+
}
|
|
561
|
+
/** Row drag started */
|
|
562
|
+
interface StartRowDragInstruction {
|
|
563
|
+
type: "START_ROW_DRAG";
|
|
564
|
+
sourceRowIndex: number;
|
|
565
|
+
}
|
|
566
|
+
/** Row drag position updated */
|
|
567
|
+
interface UpdateRowDragInstruction {
|
|
568
|
+
type: "UPDATE_ROW_DRAG";
|
|
569
|
+
currentX: number;
|
|
570
|
+
currentY: number;
|
|
571
|
+
dropTargetIndex: number | null;
|
|
572
|
+
}
|
|
573
|
+
/** Row drag committed */
|
|
574
|
+
interface CommitRowDragInstruction {
|
|
575
|
+
type: "COMMIT_ROW_DRAG";
|
|
576
|
+
sourceRowIndex: number;
|
|
577
|
+
targetRowIndex: number;
|
|
578
|
+
}
|
|
579
|
+
/** Row drag cancelled */
|
|
580
|
+
interface CancelRowDragInstruction {
|
|
581
|
+
type: "CANCEL_ROW_DRAG";
|
|
511
582
|
}
|
|
583
|
+
/** Union type of all instructions */
|
|
584
|
+
type GridInstruction = /** Slot lifecycle */CreateSlotInstruction | DestroySlotInstruction | AssignSlotInstruction | MoveSlotInstruction /** Selection */ | SetActiveCellInstruction | SetSelectionRangeInstruction | UpdateVisibleRangeInstruction /** Highlighting */ | SetHoverPositionInstruction /** Editing */ | StartEditInstruction | StopEditInstruction | CommitEditInstruction /** Layout */ | SetContentSizeInstruction | UpdateHeaderInstruction /** Filter popup */ | OpenFilterPopupInstruction | CloseFilterPopupInstruction /** Fill handle */ | StartFillInstruction | UpdateFillInstruction | CommitFillInstruction | CancelFillInstruction /** Data */ | DataLoadingInstruction | DataLoadedInstruction | DataErrorInstruction /** Transactions */ | RowsAddedInstruction | RowsRemovedInstruction | RowsUpdatedInstruction | TransactionProcessedInstruction /** Column changes */ | ColumnsChangedInstruction /** Column resize */ | StartColumnResizeInstruction | UpdateColumnResizeInstruction | CommitColumnResizeInstruction | CancelColumnResizeInstruction /** Column move */ | StartColumnMoveInstruction | UpdateColumnMoveInstruction | CommitColumnMoveInstruction | CancelColumnMoveInstruction /** Row drag */ | StartRowDragInstruction | UpdateRowDragInstruction | CommitRowDragInstruction | CancelRowDragInstruction;
|
|
585
|
+
/** Instruction listener: Single instruction Listener that receives a single instruction, used by frameworks to update their state */
|
|
586
|
+
type InstructionListener = (instruction: GridInstruction) => void;
|
|
587
|
+
/** Batch instruction listener: Batch instruction Listener that receives an array of instructions, used by frameworks to update their state */
|
|
588
|
+
type BatchInstructionListener = (instructions: GridInstruction[]) => void;
|
|
512
589
|
//#endregion
|
|
513
590
|
//#region src/types/options.d.ts
|
|
514
591
|
/** Grid core options */
|
|
@@ -533,6 +610,14 @@ interface GridCoreOptions<TData = Row> {
|
|
|
533
610
|
highlighting?: HighlightingOptions<TData>;
|
|
534
611
|
/** Called when a cell value is changed via editing or fill drag. Requires getRowId. */
|
|
535
612
|
onCellValueChanged?: (event: CellValueChangedEvent<TData>) => void;
|
|
613
|
+
/** Whether clicking and dragging any cell in a row drags the entire row instead of starting selection. Default: false */
|
|
614
|
+
rowDragEntireRow?: boolean;
|
|
615
|
+
/** Called when a row is dropped after dragging. Consumer is responsible for data reordering. */
|
|
616
|
+
onRowDragEnd?: (sourceIndex: number, targetIndex: number) => void;
|
|
617
|
+
/** Called when a column is resized. */
|
|
618
|
+
onColumnResized?: (colIndex: number, newWidth: number) => void;
|
|
619
|
+
/** Called when a column is moved/reordered. */
|
|
620
|
+
onColumnMoved?: (fromIndex: number, toIndex: number) => void;
|
|
536
621
|
}
|
|
537
622
|
//#endregion
|
|
538
623
|
//#region src/types/input.d.ts
|
|
@@ -586,7 +671,7 @@ interface InputResult {
|
|
|
586
671
|
/** Whether framework should focus the container element */
|
|
587
672
|
focusContainer?: boolean;
|
|
588
673
|
/** Type of drag operation to start (framework manages global listeners) */
|
|
589
|
-
startDrag?: "selection" | "fill";
|
|
674
|
+
startDrag?: "selection" | "fill" | "column-resize" | "column-move" | "row-drag";
|
|
590
675
|
}
|
|
591
676
|
/** Result from keyboard input handler */
|
|
592
677
|
interface KeyboardResult {
|
|
@@ -623,13 +708,39 @@ interface InputHandlerDeps {
|
|
|
623
708
|
* If not provided, visible index is used directly (no hidden columns).
|
|
624
709
|
*/
|
|
625
710
|
getOriginalColumnIndex?: (visibleIndex: number) => number;
|
|
711
|
+
/** Get column widths array (indexed by visible column) */
|
|
712
|
+
getColumnWidths?: () => number[];
|
|
713
|
+
}
|
|
714
|
+
/** Column resize drag state */
|
|
715
|
+
interface ColumnResizeDragState {
|
|
716
|
+
colIndex: number;
|
|
717
|
+
initialWidth: number;
|
|
718
|
+
currentWidth: number;
|
|
719
|
+
}
|
|
720
|
+
/** Column move drag state */
|
|
721
|
+
interface ColumnMoveDragState {
|
|
722
|
+
sourceColIndex: number;
|
|
723
|
+
currentX: number;
|
|
724
|
+
currentY: number;
|
|
725
|
+
dropTargetIndex: number | null;
|
|
726
|
+
ghostWidth: number;
|
|
727
|
+
ghostHeight: number;
|
|
728
|
+
}
|
|
729
|
+
/** Row drag state */
|
|
730
|
+
interface RowDragState {
|
|
731
|
+
sourceRowIndex: number;
|
|
732
|
+
currentX: number;
|
|
733
|
+
currentY: number;
|
|
734
|
+
dropTargetIndex: number | null;
|
|
735
|
+
/** Pre-computed translateY for the drop indicator inside the rows wrapper */
|
|
736
|
+
dropIndicatorY: number;
|
|
626
737
|
}
|
|
627
738
|
/** Current drag state for UI rendering */
|
|
628
739
|
interface DragState {
|
|
629
740
|
/** Whether any drag operation is active */
|
|
630
741
|
isDragging: boolean;
|
|
631
742
|
/** Type of active drag operation */
|
|
632
|
-
dragType: "selection" | "fill" | null;
|
|
743
|
+
dragType: "selection" | "fill" | "column-resize" | "column-move" | "row-drag" | null;
|
|
633
744
|
/** Source range for fill operations */
|
|
634
745
|
fillSourceRange: CellRange | null;
|
|
635
746
|
/** Current fill target position */
|
|
@@ -637,85 +748,14 @@ interface DragState {
|
|
|
637
748
|
row: number;
|
|
638
749
|
col: number;
|
|
639
750
|
} | null;
|
|
751
|
+
/** Column resize state (when dragType is "column-resize") */
|
|
752
|
+
columnResize: ColumnResizeDragState | null;
|
|
753
|
+
/** Column move state (when dragType is "column-move") */
|
|
754
|
+
columnMove: ColumnMoveDragState | null;
|
|
755
|
+
/** Row drag state (when dragType is "row-drag") */
|
|
756
|
+
rowDrag: RowDragState | null;
|
|
640
757
|
}
|
|
641
758
|
//#endregion
|
|
642
|
-
//#region src/utils/positioning.d.ts
|
|
643
|
-
/**
|
|
644
|
-
* Calculate cumulative column positions (prefix sums)
|
|
645
|
-
* Returns an array where positions[i] is the left position of column i
|
|
646
|
-
* positions[columns.length] is the total width
|
|
647
|
-
*/
|
|
648
|
-
declare const calculateColumnPositions: (columns: ColumnDefinition[]) => number[];
|
|
649
|
-
/**
|
|
650
|
-
* Get total width from column positions
|
|
651
|
-
*/
|
|
652
|
-
declare const getTotalWidth: (columnPositions: number[]) => number;
|
|
653
|
-
/**
|
|
654
|
-
* Calculate scaled column positions when container is wider than total column widths.
|
|
655
|
-
* Columns expand proportionally based on their original width ratios.
|
|
656
|
-
*
|
|
657
|
-
* @param columns - Column definitions with original widths
|
|
658
|
-
* @param containerWidth - Available container width
|
|
659
|
-
* @returns Object with positions array and widths array
|
|
660
|
-
*/
|
|
661
|
-
declare const calculateScaledColumnPositions: (columns: ColumnDefinition[], containerWidth: number) => {
|
|
662
|
-
positions: number[];
|
|
663
|
-
widths: number[];
|
|
664
|
-
};
|
|
665
|
-
/**
|
|
666
|
-
* Find column index at a given X coordinate
|
|
667
|
-
*/
|
|
668
|
-
declare const findColumnAtX: (x: number, columnPositions: number[]) => number;
|
|
669
|
-
//#endregion
|
|
670
|
-
//#region src/utils/classNames.d.ts
|
|
671
|
-
/**
|
|
672
|
-
* Check if a cell is within the selection range
|
|
673
|
-
*/
|
|
674
|
-
declare const isCellSelected: (row: number, col: number, selectionRange: CellRange | null) => boolean;
|
|
675
|
-
/**
|
|
676
|
-
* Check if a cell is the active cell
|
|
677
|
-
*/
|
|
678
|
-
declare const isCellActive: (row: number, col: number, activeCell: CellPosition | null) => boolean;
|
|
679
|
-
/**
|
|
680
|
-
* Check if a row is within the visible range (not in overscan)
|
|
681
|
-
*/
|
|
682
|
-
declare const isRowVisible: (row: number, visibleRowRange: {
|
|
683
|
-
start: number;
|
|
684
|
-
end: number;
|
|
685
|
-
} | null) => boolean;
|
|
686
|
-
/**
|
|
687
|
-
* Check if a cell is being edited
|
|
688
|
-
*/
|
|
689
|
-
declare const isCellEditing: (row: number, col: number, editingCell: {
|
|
690
|
-
row: number;
|
|
691
|
-
col: number;
|
|
692
|
-
} | null) => boolean;
|
|
693
|
-
/**
|
|
694
|
-
* Check if a cell is in the fill preview range (vertical-only fill)
|
|
695
|
-
*/
|
|
696
|
-
declare const isCellInFillPreview: (row: number, col: number, isDraggingFill: boolean, fillSourceRange: CellRange | null, fillTarget: {
|
|
697
|
-
row: number;
|
|
698
|
-
col: number;
|
|
699
|
-
} | null) => boolean;
|
|
700
|
-
/**
|
|
701
|
-
* Build cell CSS classes based on state
|
|
702
|
-
*/
|
|
703
|
-
declare const buildCellClasses: (isActive: boolean, isSelected: boolean, isEditing: boolean, inFillPreview: boolean) => string;
|
|
704
|
-
/**
|
|
705
|
-
* Check if a row overlaps the selection range
|
|
706
|
-
*/
|
|
707
|
-
declare const isRowInSelectionRange: (rowIndex: number, range: CellRange | null) => boolean;
|
|
708
|
-
/**
|
|
709
|
-
* Check if a column overlaps the selection range
|
|
710
|
-
*/
|
|
711
|
-
declare const isColumnInSelectionRange: (colIndex: number, range: CellRange | null) => boolean;
|
|
712
|
-
//#endregion
|
|
713
|
-
//#region src/utils/event-emitter.d.ts
|
|
714
|
-
/**
|
|
715
|
-
* Batch instruction listener for efficient state updates
|
|
716
|
-
*/
|
|
717
|
-
type BatchInstructionListener$1 = (instructions: GridInstruction[]) => void;
|
|
718
|
-
//#endregion
|
|
719
759
|
//#region src/selection.d.ts
|
|
720
760
|
type Direction = "up" | "down" | "left" | "right";
|
|
721
761
|
interface SelectionManagerOptions {
|
|
@@ -842,6 +882,30 @@ declare class InputHandler<TData extends Row = Row> {
|
|
|
842
882
|
private isDraggingFill;
|
|
843
883
|
private fillSourceRange;
|
|
844
884
|
private fillTarget;
|
|
885
|
+
private isDraggingColumnResize;
|
|
886
|
+
private resizeColIndex;
|
|
887
|
+
private resizeStartX;
|
|
888
|
+
private resizeInitialWidth;
|
|
889
|
+
private resizeCurrentWidth;
|
|
890
|
+
private isDraggingColumnMove;
|
|
891
|
+
private moveSourceColIndex;
|
|
892
|
+
private moveStartX;
|
|
893
|
+
private moveStartY;
|
|
894
|
+
private moveThresholdMet;
|
|
895
|
+
private moveShiftKey;
|
|
896
|
+
private moveGhostWidth;
|
|
897
|
+
private moveGhostHeight;
|
|
898
|
+
private moveCurrentX;
|
|
899
|
+
private moveCurrentY;
|
|
900
|
+
private moveDropTargetIndex;
|
|
901
|
+
private isDraggingRow;
|
|
902
|
+
private rowDragSourceIndex;
|
|
903
|
+
private rowDragStartX;
|
|
904
|
+
private rowDragStartY;
|
|
905
|
+
private rowDragThresholdMet;
|
|
906
|
+
private rowDragCurrentX;
|
|
907
|
+
private rowDragCurrentY;
|
|
908
|
+
private rowDragDropTargetIndex;
|
|
845
909
|
constructor(core: GridCore<TData>, deps: InputHandlerDeps);
|
|
846
910
|
/**
|
|
847
911
|
* Update dependencies (called when options change)
|
|
@@ -875,12 +939,22 @@ declare class InputHandler<TData extends Row = Row> {
|
|
|
875
939
|
* Handle header click event (cycle sort direction)
|
|
876
940
|
*/
|
|
877
941
|
handleHeaderClick(colId: string, addToExisting: boolean): void;
|
|
942
|
+
/**
|
|
943
|
+
* Handle mousedown on the resize handle of a header cell.
|
|
944
|
+
* Returns InputResult with startDrag: "column-resize".
|
|
945
|
+
*/
|
|
946
|
+
handleHeaderResizeMouseDown(colIndex: number, colWidth: number, event: PointerEventData): InputResult;
|
|
947
|
+
/**
|
|
948
|
+
* Handle mousedown on a header cell for potential column move.
|
|
949
|
+
* Uses a drag threshold to distinguish click (sort) vs drag (move).
|
|
950
|
+
*/
|
|
951
|
+
handleHeaderMouseDown(colIndex: number, colWidth: number, colHeight: number, event: PointerEventData): InputResult;
|
|
878
952
|
/**
|
|
879
953
|
* Start selection drag (called by framework after handleCellMouseDown returns startDrag: 'selection')
|
|
880
954
|
*/
|
|
881
955
|
startSelectionDrag(): void;
|
|
882
956
|
/**
|
|
883
|
-
* Handle drag move event (selection or
|
|
957
|
+
* Handle drag move event (selection, fill, column-resize, column-move, or row-drag)
|
|
884
958
|
*/
|
|
885
959
|
handleDragMove(event: PointerEventData, bounds: ContainerBounds): DragMoveResult | null;
|
|
886
960
|
/**
|
|
@@ -908,7 +982,7 @@ declare class InputHandler<TData extends Row = Row> {
|
|
|
908
982
|
private calculateAutoScroll;
|
|
909
983
|
}
|
|
910
984
|
//#endregion
|
|
911
|
-
//#region src/highlight-manager.d.ts
|
|
985
|
+
//#region src/managers/highlight-manager.d.ts
|
|
912
986
|
interface HighlightManagerOptions {
|
|
913
987
|
getActiveCell: () => CellPosition | null;
|
|
914
988
|
getSelectionRange: () => CellRange | null;
|
|
@@ -995,121 +1069,50 @@ declare class HighlightManager<TData = Record<string, unknown>> {
|
|
|
995
1069
|
destroy(): void;
|
|
996
1070
|
}
|
|
997
1071
|
//#endregion
|
|
998
|
-
//#region src/
|
|
999
|
-
interface
|
|
1000
|
-
/** Get
|
|
1001
|
-
getColumns: () => ColumnDefinition[];
|
|
1002
|
-
/** Check if sorting is enabled globally */
|
|
1003
|
-
isSortingEnabled: () => boolean;
|
|
1004
|
-
/** Get cached rows for distinct value computation */
|
|
1072
|
+
//#region src/managers/row-mutation-manager.d.ts
|
|
1073
|
+
interface RowMutationManagerOptions<TData> {
|
|
1074
|
+
/** Get the cached rows map */
|
|
1005
1075
|
getCachedRows: () => Map<number, TData>;
|
|
1006
|
-
/**
|
|
1007
|
-
|
|
1008
|
-
/**
|
|
1009
|
-
|
|
1076
|
+
/** Set the cached rows map (for bulk operations) */
|
|
1077
|
+
setCachedRows: (rows: Map<number, TData>) => void;
|
|
1078
|
+
/** Get total row count */
|
|
1079
|
+
getTotalRows: () => number;
|
|
1080
|
+
/** Set total row count */
|
|
1081
|
+
setTotalRows: (count: number) => void;
|
|
1082
|
+
/** Update a single slot after row change */
|
|
1083
|
+
updateSlot: (rowIndex: number) => void;
|
|
1084
|
+
/** Refresh all slots after bulk changes */
|
|
1085
|
+
refreshAllSlots: () => void;
|
|
1086
|
+
/** Emit content size change */
|
|
1087
|
+
emitContentSize: () => void;
|
|
1088
|
+
/** Clear selection if it references invalid rows */
|
|
1089
|
+
clearSelectionIfInvalid: (maxValidRow: number) => void;
|
|
1010
1090
|
}
|
|
1011
1091
|
/**
|
|
1012
|
-
* Manages
|
|
1092
|
+
* Manages row CRUD operations and cache management.
|
|
1013
1093
|
*/
|
|
1014
|
-
declare class
|
|
1094
|
+
declare class RowMutationManager<TData extends Row = Row> {
|
|
1015
1095
|
private options;
|
|
1016
1096
|
private emitter;
|
|
1017
|
-
private sortModel;
|
|
1018
|
-
private filterModel;
|
|
1019
|
-
private openFilterColIndex;
|
|
1020
1097
|
onInstruction: (listener: InstructionListener) => () => void;
|
|
1021
1098
|
private emit;
|
|
1022
|
-
constructor(options:
|
|
1023
|
-
setSort(colId: string, direction: SortDirection | null, addToExisting?: boolean): Promise<void>;
|
|
1024
|
-
getSortModel(): SortModel[];
|
|
1025
|
-
setFilter(colId: string, filter: ColumnFilterModel | string | null): Promise<void>;
|
|
1026
|
-
getFilterModel(): FilterModel;
|
|
1099
|
+
constructor(options: RowMutationManagerOptions<TData>);
|
|
1027
1100
|
/**
|
|
1028
|
-
*
|
|
1101
|
+
* Get a row by index.
|
|
1029
1102
|
*/
|
|
1030
|
-
|
|
1103
|
+
getRow(index: number): TData | undefined;
|
|
1031
1104
|
/**
|
|
1032
|
-
*
|
|
1105
|
+
* Add rows to the grid at the specified index.
|
|
1106
|
+
* If no index is provided, rows are added at the end.
|
|
1033
1107
|
*/
|
|
1034
|
-
|
|
1108
|
+
addRows(rows: TData[], index?: number): void;
|
|
1035
1109
|
/**
|
|
1036
|
-
*
|
|
1110
|
+
* Update existing rows with partial data.
|
|
1037
1111
|
*/
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
* Arrays are sorted internally for consistent comparison.
|
|
1043
|
-
* Limited to maxValues to avoid performance issues with large datasets.
|
|
1044
|
-
*/
|
|
1045
|
-
getDistinctValuesForColumn(colId: string, maxValues?: number): CellValue[];
|
|
1046
|
-
/**
|
|
1047
|
-
* Open filter popup for a column (toggles if already open for same column)
|
|
1048
|
-
*/
|
|
1049
|
-
openFilterPopup(colIndex: number, anchorRect: {
|
|
1050
|
-
top: number;
|
|
1051
|
-
left: number;
|
|
1052
|
-
width: number;
|
|
1053
|
-
height: number;
|
|
1054
|
-
}): void;
|
|
1055
|
-
/**
|
|
1056
|
-
* Close filter popup
|
|
1057
|
-
*/
|
|
1058
|
-
closeFilterPopup(): void;
|
|
1059
|
-
/**
|
|
1060
|
-
* Get sort info map for header rendering
|
|
1061
|
-
*/
|
|
1062
|
-
getSortInfoMap(): Map<string, {
|
|
1063
|
-
direction: SortDirection;
|
|
1064
|
-
index: number;
|
|
1065
|
-
}>;
|
|
1066
|
-
destroy(): void;
|
|
1067
|
-
}
|
|
1068
|
-
//#endregion
|
|
1069
|
-
//#region src/row-mutation-manager.d.ts
|
|
1070
|
-
interface RowMutationManagerOptions<TData> {
|
|
1071
|
-
/** Get the cached rows map */
|
|
1072
|
-
getCachedRows: () => Map<number, TData>;
|
|
1073
|
-
/** Set the cached rows map (for bulk operations) */
|
|
1074
|
-
setCachedRows: (rows: Map<number, TData>) => void;
|
|
1075
|
-
/** Get total row count */
|
|
1076
|
-
getTotalRows: () => number;
|
|
1077
|
-
/** Set total row count */
|
|
1078
|
-
setTotalRows: (count: number) => void;
|
|
1079
|
-
/** Update a single slot after row change */
|
|
1080
|
-
updateSlot: (rowIndex: number) => void;
|
|
1081
|
-
/** Refresh all slots after bulk changes */
|
|
1082
|
-
refreshAllSlots: () => void;
|
|
1083
|
-
/** Emit content size change */
|
|
1084
|
-
emitContentSize: () => void;
|
|
1085
|
-
/** Clear selection if it references invalid rows */
|
|
1086
|
-
clearSelectionIfInvalid: (maxValidRow: number) => void;
|
|
1087
|
-
}
|
|
1088
|
-
/**
|
|
1089
|
-
* Manages row CRUD operations and cache management.
|
|
1090
|
-
*/
|
|
1091
|
-
declare class RowMutationManager<TData extends Row = Row> {
|
|
1092
|
-
private options;
|
|
1093
|
-
private emitter;
|
|
1094
|
-
onInstruction: (listener: InstructionListener) => () => void;
|
|
1095
|
-
private emit;
|
|
1096
|
-
constructor(options: RowMutationManagerOptions<TData>);
|
|
1097
|
-
/**
|
|
1098
|
-
* Get a row by index.
|
|
1099
|
-
*/
|
|
1100
|
-
getRow(index: number): TData | undefined;
|
|
1101
|
-
/**
|
|
1102
|
-
* Add rows to the grid at the specified index.
|
|
1103
|
-
* If no index is provided, rows are added at the end.
|
|
1104
|
-
*/
|
|
1105
|
-
addRows(rows: TData[], index?: number): void;
|
|
1106
|
-
/**
|
|
1107
|
-
* Update existing rows with partial data.
|
|
1108
|
-
*/
|
|
1109
|
-
updateRows(updates: Array<{
|
|
1110
|
-
index: number;
|
|
1111
|
-
data: Partial<TData>;
|
|
1112
|
-
}>): void;
|
|
1112
|
+
updateRows(updates: Array<{
|
|
1113
|
+
index: number;
|
|
1114
|
+
data: Partial<TData>;
|
|
1115
|
+
}>): void;
|
|
1113
1116
|
/**
|
|
1114
1117
|
* Delete rows at the specified indices.
|
|
1115
1118
|
*/
|
|
@@ -1122,88 +1125,29 @@ declare class RowMutationManager<TData extends Row = Row> {
|
|
|
1122
1125
|
destroy(): void;
|
|
1123
1126
|
}
|
|
1124
1127
|
//#endregion
|
|
1125
|
-
//#region src/
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
private onCellValueChanged?;
|
|
1135
|
-
private scrollTop;
|
|
1136
|
-
private scrollLeft;
|
|
1137
|
-
private viewportWidth;
|
|
1138
|
-
private viewportHeight;
|
|
1139
|
-
private cachedRows;
|
|
1140
|
-
private totalRows;
|
|
1141
|
-
private currentPageIndex;
|
|
1142
|
-
private pageSize;
|
|
1143
|
-
readonly selection: SelectionManager;
|
|
1144
|
-
readonly fill: FillManager;
|
|
1145
|
-
readonly input: InputHandler<TData>;
|
|
1146
|
-
readonly highlight: HighlightManager<TData> | null;
|
|
1147
|
-
readonly sortFilter: SortFilterManager<TData>;
|
|
1148
|
-
readonly rowMutation: RowMutationManager<TData>;
|
|
1149
|
-
private readonly slotPool;
|
|
1150
|
-
private readonly editManager;
|
|
1151
|
-
private columnPositions;
|
|
1152
|
-
private emitter;
|
|
1153
|
-
onInstruction: (listener: InstructionListener) => () => void;
|
|
1154
|
-
onBatchInstruction: (listener: BatchInstructionListener$1) => () => void;
|
|
1155
|
-
private emit;
|
|
1156
|
-
private emitBatch;
|
|
1128
|
+
//#region src/managers/scroll-virtualization-manager.d.ts
|
|
1129
|
+
interface ScrollVirtualizationManagerOptions {
|
|
1130
|
+
getRowHeight: () => number;
|
|
1131
|
+
getHeaderHeight: () => number;
|
|
1132
|
+
getTotalRows: () => number;
|
|
1133
|
+
getScrollTop: () => number;
|
|
1134
|
+
getViewportHeight: () => number;
|
|
1135
|
+
}
|
|
1136
|
+
declare class ScrollVirtualizationManager {
|
|
1157
1137
|
private naturalContentHeight;
|
|
1158
1138
|
private virtualContentHeight;
|
|
1159
1139
|
private scrollRatio;
|
|
1160
|
-
private
|
|
1161
|
-
|
|
1162
|
-
constructor(options: GridCoreOptions<TData>);
|
|
1163
|
-
/**
|
|
1164
|
-
* Initialize the grid and load initial data.
|
|
1165
|
-
*/
|
|
1166
|
-
initialize(): Promise<void>;
|
|
1140
|
+
private readonly options;
|
|
1141
|
+
constructor(options: ScrollVirtualizationManagerOptions);
|
|
1167
1142
|
/**
|
|
1168
|
-
* Update
|
|
1169
|
-
*
|
|
1143
|
+
* Update scroll virtualization state based on current row count.
|
|
1144
|
+
* Should be called whenever totalRows changes.
|
|
1170
1145
|
*/
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
hasActiveFilter(colId: string): boolean;
|
|
1177
|
-
isColumnSortable(colIndex: number): boolean;
|
|
1178
|
-
isColumnFilterable(colIndex: number): boolean;
|
|
1179
|
-
getDistinctValuesForColumn(colId: string, maxValues?: number): CellValue[];
|
|
1180
|
-
openFilterPopup(colIndex: number, anchorRect: {
|
|
1181
|
-
top: number;
|
|
1182
|
-
left: number;
|
|
1183
|
-
width: number;
|
|
1184
|
-
height: number;
|
|
1185
|
-
}): void;
|
|
1186
|
-
closeFilterPopup(): void;
|
|
1187
|
-
getSortModel(): SortModel[];
|
|
1188
|
-
getFilterModel(): FilterModel;
|
|
1189
|
-
startEdit(row: number, col: number): void;
|
|
1190
|
-
updateEditValue(value: CellValue): void;
|
|
1191
|
-
commitEdit(): void;
|
|
1192
|
-
cancelEdit(): void;
|
|
1193
|
-
getEditState(): EditState | null;
|
|
1194
|
-
getCellValue(row: number, col: number): CellValue;
|
|
1195
|
-
setCellValue(row: number, col: number, value: CellValue): void;
|
|
1196
|
-
private clearSelectionIfInvalid;
|
|
1197
|
-
private computeColumnPositions;
|
|
1198
|
-
private emitContentSize;
|
|
1199
|
-
private emitHeaders;
|
|
1200
|
-
getColumns(): ColumnDefinition[];
|
|
1201
|
-
getColumnPositions(): number[];
|
|
1202
|
-
getRowCount(): number;
|
|
1203
|
-
getRowHeight(): number;
|
|
1204
|
-
getHeaderHeight(): number;
|
|
1205
|
-
getTotalWidth(): number;
|
|
1206
|
-
getTotalHeight(): number;
|
|
1146
|
+
updateContentSize(): {
|
|
1147
|
+
naturalHeight: number;
|
|
1148
|
+
virtualHeight: number;
|
|
1149
|
+
scrollRatio: number;
|
|
1150
|
+
};
|
|
1207
1151
|
/**
|
|
1208
1152
|
* Check if scroll scaling is active (large datasets exceeding browser scroll limits).
|
|
1209
1153
|
* When scaling is active, scrollRatio < 1 and scroll positions are compressed.
|
|
@@ -1214,6 +1158,10 @@ declare class GridCore<TData extends Row = Row> {
|
|
|
1214
1158
|
* Useful for debugging or displaying actual content size.
|
|
1215
1159
|
*/
|
|
1216
1160
|
getNaturalHeight(): number;
|
|
1161
|
+
/**
|
|
1162
|
+
* Get the virtual (capped) content height for DOM use.
|
|
1163
|
+
*/
|
|
1164
|
+
getVirtualHeight(): number;
|
|
1217
1165
|
/**
|
|
1218
1166
|
* Get the scroll ratio used for scroll virtualization.
|
|
1219
1167
|
* Returns 1 when no virtualization is needed, < 1 when content exceeds browser limits.
|
|
@@ -1240,742 +1188,1146 @@ declare class GridCore<TData extends Row = Row> {
|
|
|
1240
1188
|
* @param virtualScrollTop Current scroll position from container.scrollTop (virtual/scaled)
|
|
1241
1189
|
*/
|
|
1242
1190
|
getRowIndexAtDisplayY(viewportY: number, virtualScrollTop: number): number;
|
|
1243
|
-
getRowData(rowIndex: number): TData | undefined;
|
|
1244
|
-
/**
|
|
1245
|
-
* Refresh data from the data source.
|
|
1246
|
-
*/
|
|
1247
|
-
refresh(): Promise<void>;
|
|
1248
|
-
/**
|
|
1249
|
-
* Fast-path refresh for transaction-based mutations.
|
|
1250
|
-
* Only re-fetches the visible window instead of all rows.
|
|
1251
|
-
* Use this when data was mutated via MutableDataSource transactions.
|
|
1252
|
-
*/
|
|
1253
|
-
refreshFromTransaction(): Promise<void>;
|
|
1254
|
-
/**
|
|
1255
|
-
* Refresh slot display without refetching data.
|
|
1256
|
-
* Useful after in-place data modifications like fill operations.
|
|
1257
|
-
*/
|
|
1258
|
-
refreshSlotData(): void;
|
|
1259
1191
|
/**
|
|
1260
|
-
*
|
|
1261
|
-
*
|
|
1192
|
+
* Get the virtual content height for external use
|
|
1193
|
+
* @internal
|
|
1262
1194
|
*/
|
|
1263
|
-
|
|
1195
|
+
getVirtualContentHeight(): number;
|
|
1196
|
+
}
|
|
1197
|
+
//#endregion
|
|
1198
|
+
//#region src/managers/sort-filter-manager.d.ts
|
|
1199
|
+
interface SortFilterManagerOptions<TData> {
|
|
1200
|
+
/** Get all columns */
|
|
1201
|
+
getColumns: () => ColumnDefinition[];
|
|
1202
|
+
/** Check if sorting is enabled globally */
|
|
1203
|
+
isSortingEnabled: () => boolean;
|
|
1204
|
+
/** Get cached rows for distinct value computation */
|
|
1205
|
+
getCachedRows: () => Map<number, TData>;
|
|
1206
|
+
/** Called when sort/filter changes to trigger data refresh */
|
|
1207
|
+
onSortFilterChange: () => Promise<void>;
|
|
1208
|
+
/** Called after data refresh to update UI */
|
|
1209
|
+
onDataRefreshed: () => void;
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Manages sorting and filtering state and operations.
|
|
1213
|
+
*/
|
|
1214
|
+
declare class SortFilterManager<TData = Record<string, unknown>> {
|
|
1215
|
+
private options;
|
|
1216
|
+
private emitter;
|
|
1217
|
+
private sortModel;
|
|
1218
|
+
private filterModel;
|
|
1219
|
+
private openFilterColIndex;
|
|
1220
|
+
onInstruction: (listener: InstructionListener) => () => void;
|
|
1221
|
+
private emit;
|
|
1222
|
+
constructor(options: SortFilterManagerOptions<TData>);
|
|
1223
|
+
setSort(colId: string, direction: SortDirection | null, addToExisting?: boolean): Promise<void>;
|
|
1224
|
+
getSortModel(): SortModel[];
|
|
1225
|
+
setFilter(colId: string, filter: ColumnFilterModel | string | null): Promise<void>;
|
|
1226
|
+
getFilterModel(): FilterModel;
|
|
1264
1227
|
/**
|
|
1265
|
-
*
|
|
1228
|
+
* Check if a column has an active filter
|
|
1266
1229
|
*/
|
|
1267
|
-
|
|
1268
|
-
index: number;
|
|
1269
|
-
data: Partial<TData>;
|
|
1270
|
-
}>): void;
|
|
1230
|
+
hasActiveFilter(colId: string): boolean;
|
|
1271
1231
|
/**
|
|
1272
|
-
*
|
|
1232
|
+
* Check if a column is sortable
|
|
1273
1233
|
*/
|
|
1274
|
-
|
|
1234
|
+
isColumnSortable(colIndex: number): boolean;
|
|
1275
1235
|
/**
|
|
1276
|
-
*
|
|
1236
|
+
* Check if a column is filterable
|
|
1277
1237
|
*/
|
|
1278
|
-
|
|
1238
|
+
isColumnFilterable(colIndex: number): boolean;
|
|
1279
1239
|
/**
|
|
1280
|
-
*
|
|
1281
|
-
*
|
|
1240
|
+
* Get distinct values for a column (for filter dropdowns)
|
|
1241
|
+
* For array-type columns (like tags), each unique array combination is returned.
|
|
1242
|
+
* Arrays are sorted internally for consistent comparison.
|
|
1243
|
+
* Limited to maxValues to avoid performance issues with large datasets.
|
|
1282
1244
|
*/
|
|
1283
|
-
|
|
1245
|
+
getDistinctValuesForColumn(colId: string, maxValues?: number): CellValue[];
|
|
1284
1246
|
/**
|
|
1285
|
-
*
|
|
1286
|
-
* Preserves grid state (sort, filter, scroll position).
|
|
1287
|
-
* Cancels any active edit and clamps selection to valid range.
|
|
1247
|
+
* Open filter popup for a column (toggles if already open for same column)
|
|
1288
1248
|
*/
|
|
1289
|
-
|
|
1249
|
+
openFilterPopup(colIndex: number, anchorRect: {
|
|
1250
|
+
top: number;
|
|
1251
|
+
left: number;
|
|
1252
|
+
width: number;
|
|
1253
|
+
height: number;
|
|
1254
|
+
}): void;
|
|
1290
1255
|
/**
|
|
1291
|
-
*
|
|
1256
|
+
* Close filter popup
|
|
1292
1257
|
*/
|
|
1293
|
-
|
|
1258
|
+
closeFilterPopup(): void;
|
|
1294
1259
|
/**
|
|
1295
|
-
*
|
|
1296
|
-
* Call this before discarding the GridCore to ensure proper cleanup.
|
|
1297
|
-
* This method is idempotent - safe to call multiple times.
|
|
1260
|
+
* Get sort info map for header rendering
|
|
1298
1261
|
*/
|
|
1262
|
+
getSortInfoMap(): Map<string, {
|
|
1263
|
+
direction: SortDirection;
|
|
1264
|
+
index: number;
|
|
1265
|
+
}>;
|
|
1299
1266
|
destroy(): void;
|
|
1300
1267
|
}
|
|
1301
1268
|
//#endregion
|
|
1302
|
-
//#region src/
|
|
1303
|
-
interface
|
|
1304
|
-
/**
|
|
1305
|
-
|
|
1306
|
-
/**
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
getViewportHeight: () => number;
|
|
1314
|
-
/** Get total row count */
|
|
1315
|
-
getTotalRows: () => number;
|
|
1316
|
-
/** Get scroll ratio for virtualization (1 = no virtualization) */
|
|
1317
|
-
getScrollRatio: () => number;
|
|
1318
|
-
/** Get virtual content height */
|
|
1319
|
-
getVirtualContentHeight: () => number;
|
|
1320
|
-
/** Get row data by index */
|
|
1321
|
-
getRowData: (rowIndex: number) => Row | undefined;
|
|
1269
|
+
//#region src/indexed-data-store/indexed-data-store.d.ts
|
|
1270
|
+
interface IndexedDataStoreOptions<TData> {
|
|
1271
|
+
/** Function to extract unique ID from row. Required for mutations. */
|
|
1272
|
+
getRowId: (row: TData) => RowId;
|
|
1273
|
+
/** Custom field accessor for nested properties */
|
|
1274
|
+
getFieldValue?: (row: TData, field: string) => CellValue;
|
|
1275
|
+
}
|
|
1276
|
+
/** Hash cache for a single row */
|
|
1277
|
+
interface RowSortCache {
|
|
1278
|
+
/** Map: sortModelHash -> computed hashes for that sort configuration */
|
|
1279
|
+
hashes: Map<string, number[]>;
|
|
1322
1280
|
}
|
|
1323
1281
|
/**
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1282
|
+
* Efficient data structure for incremental operations on grid data.
|
|
1283
|
+
* Supports:
|
|
1284
|
+
* - O(1) lookup by row ID
|
|
1285
|
+
* - O(log n) binary insertion to maintain sort order
|
|
1286
|
+
* - Filter state caching with distinct values
|
|
1287
|
+
* - Hash caching for fast sorted comparisons
|
|
1326
1288
|
*/
|
|
1327
|
-
declare class
|
|
1328
|
-
private
|
|
1289
|
+
declare class IndexedDataStore<TData extends Row = Row> {
|
|
1290
|
+
private rows;
|
|
1291
|
+
private rowById;
|
|
1292
|
+
private sortedIndices;
|
|
1293
|
+
private sortModel;
|
|
1294
|
+
private sortModelHash;
|
|
1295
|
+
private filterModel;
|
|
1296
|
+
private filteredIndices;
|
|
1297
|
+
private distinctValues;
|
|
1298
|
+
private rowSortCache;
|
|
1329
1299
|
private options;
|
|
1330
|
-
|
|
1331
|
-
private isDestroyed;
|
|
1332
|
-
onInstruction: (listener: InstructionListener) => () => void;
|
|
1333
|
-
onBatchInstruction: (listener: BatchInstructionListener$1) => () => void;
|
|
1334
|
-
private emit;
|
|
1335
|
-
private emitBatch;
|
|
1336
|
-
constructor(options: SlotPoolManagerOptions);
|
|
1300
|
+
constructor(initialData: TData[] | undefined, options: IndexedDataStoreOptions<TData>);
|
|
1337
1301
|
/**
|
|
1338
|
-
*
|
|
1302
|
+
* Clear all data and internal caches.
|
|
1303
|
+
* Used for proper memory cleanup when the store is no longer needed.
|
|
1339
1304
|
*/
|
|
1340
|
-
|
|
1305
|
+
clear(): void;
|
|
1341
1306
|
/**
|
|
1342
|
-
*
|
|
1307
|
+
* Replace all data (used for initial load or full refresh).
|
|
1343
1308
|
*/
|
|
1344
|
-
|
|
1309
|
+
setData(data: TData[]): void;
|
|
1345
1310
|
/**
|
|
1346
|
-
*
|
|
1347
|
-
*
|
|
1311
|
+
* Query data with sorting, filtering, and pagination.
|
|
1312
|
+
* Compatible with DataSource.fetch() interface.
|
|
1348
1313
|
*/
|
|
1349
|
-
|
|
1314
|
+
query(request: DataSourceRequest): DataSourceResponse<TData>;
|
|
1350
1315
|
/**
|
|
1351
|
-
*
|
|
1316
|
+
* Get row by ID.
|
|
1352
1317
|
*/
|
|
1353
|
-
|
|
1318
|
+
getRowById(id: RowId): TData | undefined;
|
|
1354
1319
|
/**
|
|
1355
|
-
*
|
|
1356
|
-
* This method is idempotent - safe to call multiple times.
|
|
1320
|
+
* Get row by index.
|
|
1357
1321
|
*/
|
|
1358
|
-
|
|
1322
|
+
getRowByIndex(index: number): TData | undefined;
|
|
1359
1323
|
/**
|
|
1360
|
-
*
|
|
1361
|
-
* Used after filtering/sorting when data changes.
|
|
1324
|
+
* Get total row count (unfiltered).
|
|
1362
1325
|
*/
|
|
1363
|
-
|
|
1326
|
+
getTotalRowCount(): number;
|
|
1364
1327
|
/**
|
|
1365
|
-
*
|
|
1328
|
+
* Get all rows as a new array.
|
|
1329
|
+
* Used for direct data access when bypassing store's query system.
|
|
1366
1330
|
*/
|
|
1367
|
-
|
|
1331
|
+
getAllRows(): TData[];
|
|
1368
1332
|
/**
|
|
1369
|
-
*
|
|
1370
|
-
*
|
|
1371
|
-
*
|
|
1372
|
-
* When virtualization is active (scrollRatio < 1), we use viewport-relative
|
|
1373
|
-
* positioning to keep translateY values small. This prevents browser rendering
|
|
1374
|
-
* issues that occur at extreme pixel values (millions of pixels).
|
|
1375
|
-
*
|
|
1376
|
-
* Note: The header is rendered outside the content sizer, so row positions
|
|
1377
|
-
* start at 0 (not headerHeight) within the rows container.
|
|
1333
|
+
* Move a row from one position to another in the raw data array.
|
|
1334
|
+
* This reorders the underlying data; when no sort is active, the new order
|
|
1335
|
+
* is reflected immediately on the next fetch.
|
|
1378
1336
|
*/
|
|
1379
|
-
|
|
1337
|
+
moveRow(fromIndex: number, toIndex: number): void;
|
|
1380
1338
|
/**
|
|
1381
|
-
* Get
|
|
1382
|
-
* When virtualization is active, this positions the wrapper so rows
|
|
1383
|
-
* with small translateY values appear at the correct scroll position.
|
|
1339
|
+
* Get visible row count (after filtering).
|
|
1384
1340
|
*/
|
|
1385
|
-
|
|
1386
|
-
}
|
|
1387
|
-
//#endregion
|
|
1388
|
-
//#region src/edit-manager.d.ts
|
|
1389
|
-
interface EditManagerOptions {
|
|
1390
|
-
/** Get column definition by index */
|
|
1391
|
-
getColumn: (colIndex: number) => ColumnDefinition | undefined;
|
|
1392
|
-
/** Get cell value */
|
|
1393
|
-
getCellValue: (row: number, col: number) => CellValue;
|
|
1394
|
-
/** Set cell value */
|
|
1395
|
-
setCellValue: (row: number, col: number, value: CellValue) => void;
|
|
1396
|
-
/** Callback when edit is committed (to update slot display) */
|
|
1397
|
-
onCommit?: (row: number, col: number, value: CellValue) => void;
|
|
1398
|
-
}
|
|
1399
|
-
/**
|
|
1400
|
-
* Manages cell editing state and operations.
|
|
1401
|
-
*/
|
|
1402
|
-
declare class EditManager {
|
|
1403
|
-
private editState;
|
|
1404
|
-
private options;
|
|
1405
|
-
private emitter;
|
|
1406
|
-
onInstruction: (listener: InstructionListener) => () => void;
|
|
1407
|
-
private emit;
|
|
1408
|
-
constructor(options: EditManagerOptions);
|
|
1341
|
+
getVisibleRowCount(): number;
|
|
1409
1342
|
/**
|
|
1410
|
-
* Get
|
|
1343
|
+
* Get distinct values for a field (for filter UI).
|
|
1411
1344
|
*/
|
|
1412
|
-
|
|
1345
|
+
getDistinctValues(field: string): CellValue[];
|
|
1413
1346
|
/**
|
|
1414
|
-
*
|
|
1347
|
+
* Add rows to the store.
|
|
1348
|
+
* Rows are inserted at their correct sorted position.
|
|
1415
1349
|
*/
|
|
1416
|
-
|
|
1350
|
+
addRows(rows: TData[]): void;
|
|
1417
1351
|
/**
|
|
1418
|
-
*
|
|
1352
|
+
* Add a single row.
|
|
1419
1353
|
*/
|
|
1420
|
-
|
|
1354
|
+
private addRow;
|
|
1421
1355
|
/**
|
|
1422
|
-
*
|
|
1423
|
-
* Returns true if edit was started, false if cell is not editable.
|
|
1356
|
+
* Remove rows by ID.
|
|
1424
1357
|
*/
|
|
1425
|
-
|
|
1358
|
+
removeRows(ids: RowId[]): void;
|
|
1426
1359
|
/**
|
|
1427
|
-
*
|
|
1360
|
+
* Remove a single row by index.
|
|
1428
1361
|
*/
|
|
1429
|
-
|
|
1362
|
+
private removeRowByIndex;
|
|
1430
1363
|
/**
|
|
1431
|
-
*
|
|
1432
|
-
* Saves the value and closes the editor.
|
|
1364
|
+
* Update indices after a row removal.
|
|
1433
1365
|
*/
|
|
1434
|
-
|
|
1366
|
+
private reindexAfterRemoval;
|
|
1435
1367
|
/**
|
|
1436
|
-
*
|
|
1437
|
-
* Discards changes and closes the editor.
|
|
1368
|
+
* Update a cell value.
|
|
1438
1369
|
*/
|
|
1439
|
-
|
|
1370
|
+
updateCell(id: RowId, field: string, value: CellValue): void;
|
|
1440
1371
|
/**
|
|
1441
|
-
*
|
|
1372
|
+
* Update multiple fields on a row.
|
|
1442
1373
|
*/
|
|
1443
|
-
|
|
1444
|
-
}
|
|
1445
|
-
//#endregion
|
|
1446
|
-
//#region src/sorting/parallel-sort-manager.d.ts
|
|
1447
|
-
interface ParallelSortOptions {
|
|
1448
|
-
/** Maximum number of workers (default: navigator.hardwareConcurrency || 4) */
|
|
1449
|
-
maxWorkers?: number;
|
|
1450
|
-
/** Threshold for parallel sorting (default: 400000) */
|
|
1451
|
-
parallelThreshold?: number;
|
|
1452
|
-
/** Minimum chunk size (default: 50000) */
|
|
1453
|
-
minChunkSize?: number;
|
|
1454
|
-
}
|
|
1455
|
-
/**
|
|
1456
|
-
* Manages parallel sorting operations using a worker pool.
|
|
1457
|
-
* Automatically decides between single-worker and parallel sorting based on data size.
|
|
1458
|
-
*/
|
|
1459
|
-
declare class ParallelSortManager {
|
|
1460
|
-
private pool;
|
|
1461
|
-
private parallelThreshold;
|
|
1462
|
-
private minChunkSize;
|
|
1463
|
-
private isTerminated;
|
|
1464
|
-
constructor(options?: ParallelSortOptions);
|
|
1374
|
+
updateRow(id: RowId, data: Partial<TData>): void;
|
|
1465
1375
|
/**
|
|
1466
|
-
*
|
|
1376
|
+
* Set the sort model. Triggers full re-sort if model changed.
|
|
1467
1377
|
*/
|
|
1468
|
-
|
|
1378
|
+
setSortModel(model: SortModel[]): void;
|
|
1469
1379
|
/**
|
|
1470
|
-
*
|
|
1380
|
+
* Get current sort model.
|
|
1471
1381
|
*/
|
|
1472
|
-
|
|
1382
|
+
getSortModel(): SortModel[];
|
|
1473
1383
|
/**
|
|
1474
|
-
*
|
|
1475
|
-
* Automatically uses parallel sorting for large datasets.
|
|
1384
|
+
* Set the filter model.
|
|
1476
1385
|
*/
|
|
1477
|
-
|
|
1386
|
+
setFilterModel(model: FilterModel): void;
|
|
1478
1387
|
/**
|
|
1479
|
-
*
|
|
1480
|
-
* Automatically uses parallel sorting for large datasets.
|
|
1388
|
+
* Get current filter model.
|
|
1481
1389
|
*/
|
|
1482
|
-
|
|
1390
|
+
getFilterModel(): FilterModel;
|
|
1483
1391
|
/**
|
|
1484
|
-
*
|
|
1485
|
-
* Automatically uses parallel sorting for large datasets.
|
|
1392
|
+
* Rebuild sorted indices (full re-sort).
|
|
1486
1393
|
*/
|
|
1487
|
-
|
|
1488
|
-
private sortIndicesSingle;
|
|
1489
|
-
private sortStringHashesSingle;
|
|
1490
|
-
private sortMultiColumnSingle;
|
|
1491
|
-
private sortIndicesParallel;
|
|
1492
|
-
private sortStringHashesParallel;
|
|
1493
|
-
private sortMultiColumnParallel;
|
|
1394
|
+
private rebuildSortedIndices;
|
|
1494
1395
|
/**
|
|
1495
|
-
*
|
|
1396
|
+
* Rebuild hash cache for all rows.
|
|
1496
1397
|
*/
|
|
1497
|
-
private
|
|
1398
|
+
private rebuildHashCache;
|
|
1498
1399
|
/**
|
|
1499
|
-
*
|
|
1400
|
+
* Compute and cache sort hashes for a row.
|
|
1500
1401
|
*/
|
|
1501
|
-
private
|
|
1402
|
+
private computeRowHashes;
|
|
1502
1403
|
/**
|
|
1503
|
-
*
|
|
1404
|
+
* Compare two rows using cached hashes.
|
|
1504
1405
|
*/
|
|
1505
|
-
private
|
|
1406
|
+
private compareRows;
|
|
1506
1407
|
/**
|
|
1507
|
-
*
|
|
1408
|
+
* Binary search for insertion position in sortedIndices.
|
|
1508
1409
|
*/
|
|
1509
|
-
private
|
|
1510
|
-
}
|
|
1511
|
-
//#endregion
|
|
1512
|
-
//#region src/sorting/worker-pool.d.ts
|
|
1513
|
-
interface WorkerPoolOptions {
|
|
1514
|
-
/** Maximum number of workers (default: navigator.hardwareConcurrency ?? 4) */
|
|
1515
|
-
maxWorkers?: number;
|
|
1516
|
-
/** Whether to pre-warm workers on initialization */
|
|
1517
|
-
preWarm?: boolean;
|
|
1518
|
-
}
|
|
1519
|
-
/**
|
|
1520
|
-
* Manages a pool of Web Workers for parallel task execution.
|
|
1521
|
-
* Workers are created lazily and reused across operations.
|
|
1522
|
-
*/
|
|
1523
|
-
declare class WorkerPool {
|
|
1524
|
-
private workerCode;
|
|
1525
|
-
private maxWorkers;
|
|
1526
|
-
private workers;
|
|
1527
|
-
private workerUrl;
|
|
1528
|
-
private nextRequestId;
|
|
1529
|
-
private isTerminated;
|
|
1530
|
-
constructor(workerCode: string, options?: WorkerPoolOptions);
|
|
1410
|
+
private binarySearchInsertPosition;
|
|
1531
1411
|
/**
|
|
1532
|
-
*
|
|
1412
|
+
* Rebuild filtered indices.
|
|
1533
1413
|
*/
|
|
1534
|
-
|
|
1414
|
+
private rebuildFilteredIndices;
|
|
1535
1415
|
/**
|
|
1536
|
-
*
|
|
1537
|
-
*/
|
|
1538
|
-
getMaxWorkers(): number;
|
|
1539
|
-
/**
|
|
1540
|
-
* Check if the pool is available for use.
|
|
1541
|
-
*/
|
|
1542
|
-
isAvailable(): boolean;
|
|
1543
|
-
/**
|
|
1544
|
-
* Execute a single task on an available worker.
|
|
1545
|
-
* Returns the worker's response.
|
|
1546
|
-
*/
|
|
1547
|
-
execute<TRequest extends {
|
|
1548
|
-
id?: number;
|
|
1549
|
-
}, TResponse>(request: TRequest, transferables?: Transferable[]): Promise<TResponse>;
|
|
1550
|
-
/**
|
|
1551
|
-
* Execute multiple tasks in parallel across available workers.
|
|
1552
|
-
* Each task is assigned to a different worker if possible.
|
|
1553
|
-
* Returns results in the same order as the input requests.
|
|
1554
|
-
*/
|
|
1555
|
-
executeParallel<TRequest extends {
|
|
1556
|
-
id?: number;
|
|
1557
|
-
}, TResponse>(tasks: Array<{
|
|
1558
|
-
request: TRequest;
|
|
1559
|
-
transferables?: Transferable[];
|
|
1560
|
-
}>): Promise<TResponse[]>;
|
|
1561
|
-
/**
|
|
1562
|
-
* Terminate all workers and clean up resources.
|
|
1563
|
-
*/
|
|
1564
|
-
terminate(): void;
|
|
1565
|
-
/**
|
|
1566
|
-
* Pre-warm workers by creating them ahead of time.
|
|
1416
|
+
* Check if a row passes the current filter.
|
|
1567
1417
|
*/
|
|
1568
|
-
private
|
|
1418
|
+
private rowPassesFilter;
|
|
1569
1419
|
/**
|
|
1570
|
-
*
|
|
1420
|
+
* Get visible indices (filtered + sorted).
|
|
1571
1421
|
*/
|
|
1572
|
-
private
|
|
1422
|
+
private getVisibleIndices;
|
|
1573
1423
|
/**
|
|
1574
|
-
*
|
|
1424
|
+
* Rebuild distinct values cache for all fields.
|
|
1575
1425
|
*/
|
|
1576
|
-
private
|
|
1426
|
+
private rebuildDistinctValues;
|
|
1577
1427
|
/**
|
|
1578
|
-
*
|
|
1428
|
+
* Update distinct values when a row is added or removed.
|
|
1579
1429
|
*/
|
|
1580
|
-
private
|
|
1430
|
+
private updateDistinctValuesForRow;
|
|
1581
1431
|
/**
|
|
1582
|
-
*
|
|
1432
|
+
* Update distinct value for a specific field when cell value changes.
|
|
1583
1433
|
*/
|
|
1584
|
-
private
|
|
1434
|
+
private updateDistinctValueForField;
|
|
1585
1435
|
}
|
|
1586
1436
|
//#endregion
|
|
1587
|
-
//#region src/
|
|
1437
|
+
//#region src/indexed-data-store/field-helpers.d.ts
|
|
1588
1438
|
/**
|
|
1589
|
-
*
|
|
1439
|
+
* Default field value accessor supporting dot notation.
|
|
1440
|
+
* @example
|
|
1441
|
+
* getFieldValue({ user: { name: "John" } }, "user.name") // "John"
|
|
1590
1442
|
*/
|
|
1591
|
-
|
|
1592
|
-
/** Sorted indices (local to this chunk) */
|
|
1593
|
-
indices: Uint32Array;
|
|
1594
|
-
/** Values for comparison (in same order as indices) */
|
|
1595
|
-
values: Float64Array;
|
|
1596
|
-
/** Offset of this chunk in the original array */
|
|
1597
|
-
offset: number;
|
|
1598
|
-
}
|
|
1443
|
+
declare function getFieldValue<TData extends Row>(row: TData, field: string): CellValue;
|
|
1599
1444
|
/**
|
|
1600
|
-
*
|
|
1445
|
+
* Set field value supporting dot notation.
|
|
1446
|
+
* Creates nested objects if they don't exist.
|
|
1447
|
+
* @example
|
|
1448
|
+
* const obj = { user: {} };
|
|
1449
|
+
* setFieldValue(obj, "user.name", "John");
|
|
1450
|
+
* // obj is now { user: { name: "John" } }
|
|
1601
1451
|
*/
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
/** Values for comparison - array of columns, each in same order as indices */
|
|
1606
|
-
columns: Float64Array[];
|
|
1607
|
-
/** Sort directions for each column (1 = asc, -1 = desc) */
|
|
1608
|
-
directions: Int8Array;
|
|
1609
|
-
/** Offset of this chunk in the original array */
|
|
1610
|
-
offset: number;
|
|
1611
|
-
}
|
|
1452
|
+
declare function setFieldValue<TData extends Row>(row: TData, field: string, value: CellValue): void;
|
|
1453
|
+
//#endregion
|
|
1454
|
+
//#region src/indexed-data-store/sorting.d.ts
|
|
1612
1455
|
/**
|
|
1613
|
-
*
|
|
1614
|
-
* Uses
|
|
1615
|
-
*
|
|
1616
|
-
* @param chunks - Array of sorted chunks to merge
|
|
1617
|
-
* @param direction - Sort direction ('asc' or 'desc')
|
|
1618
|
-
* @returns Uint32Array of globally sorted indices
|
|
1456
|
+
* Convert a string to a sortable number using first 10 characters.
|
|
1457
|
+
* Uses base-36 encoding (a-z = 0-25, 0-9 = 26-35).
|
|
1619
1458
|
*/
|
|
1620
|
-
declare function
|
|
1459
|
+
declare function stringToSortableNumber(str: string): number;
|
|
1621
1460
|
/**
|
|
1622
|
-
*
|
|
1623
|
-
*
|
|
1624
|
-
* @param chunks - Array of multi-column sorted chunks
|
|
1625
|
-
* @returns Uint32Array of globally sorted indices
|
|
1461
|
+
* Compare two cell values for sorting.
|
|
1462
|
+
* Handles null/undefined, arrays, numbers, dates, and strings.
|
|
1626
1463
|
*/
|
|
1627
|
-
declare function
|
|
1464
|
+
declare function compareValues(a: CellValue, b: CellValue): number;
|
|
1628
1465
|
/**
|
|
1629
|
-
*
|
|
1630
|
-
*
|
|
1631
|
-
*
|
|
1632
|
-
* @param chunks - Original sorted chunks with their hash values
|
|
1633
|
-
* @param _direction - Sort direction
|
|
1634
|
-
* @returns Array of boundary collision positions [start1, end1, start2, end2, ...]
|
|
1466
|
+
* Compute a sortable hash for a cell value.
|
|
1467
|
+
* Used for fast comparisons in sorted indices.
|
|
1635
1468
|
*/
|
|
1636
|
-
declare function
|
|
1469
|
+
declare function computeValueHash(value: CellValue): number;
|
|
1637
1470
|
//#endregion
|
|
1638
|
-
//#region src/
|
|
1639
|
-
interface ClientDataSourceOptions<TData> {
|
|
1640
|
-
/** Custom field accessor for nested properties */
|
|
1641
|
-
getFieldValue?: (row: TData, field: string) => CellValue;
|
|
1642
|
-
/** Use Web Worker for sorting large datasets (default: true) */
|
|
1643
|
-
useWorker?: boolean;
|
|
1644
|
-
/** Options for parallel sorting (only used when useWorker is true) */
|
|
1645
|
-
parallelSort?: ParallelSortOptions | false;
|
|
1646
|
-
}
|
|
1471
|
+
//#region src/filtering/index.d.ts
|
|
1647
1472
|
/**
|
|
1648
|
-
*
|
|
1649
|
-
* Sorting and filtering are performed client-side.
|
|
1650
|
-
* For large datasets, sorting is automatically offloaded to a Web Worker.
|
|
1473
|
+
* Check if two dates are on the same day.
|
|
1651
1474
|
*/
|
|
1652
|
-
declare function
|
|
1475
|
+
declare function isSameDay(date1: Date, date2: Date): boolean;
|
|
1653
1476
|
/**
|
|
1654
|
-
*
|
|
1655
|
-
* This provides backwards compatibility with the old `rowData` prop.
|
|
1477
|
+
* Evaluate a text filter condition against a cell value.
|
|
1656
1478
|
*/
|
|
1657
|
-
declare function
|
|
1658
|
-
//#endregion
|
|
1659
|
-
//#region src/data-source/server-data-source.d.ts
|
|
1660
|
-
type ServerFetchFunction<TData> = (request: DataSourceRequest) => Promise<DataSourceResponse<TData>>;
|
|
1479
|
+
declare function evaluateTextCondition(cellValue: CellValue, condition: TextFilterCondition): boolean;
|
|
1661
1480
|
/**
|
|
1662
|
-
*
|
|
1663
|
-
* The fetch function receives sort/filter/pagination params to pass to the API.
|
|
1481
|
+
* Evaluate a number filter condition against a cell value.
|
|
1664
1482
|
*/
|
|
1665
|
-
declare function
|
|
1483
|
+
declare function evaluateNumberCondition(cellValue: CellValue, condition: NumberFilterCondition): boolean;
|
|
1484
|
+
/**
|
|
1485
|
+
* Evaluate a date filter condition against a cell value.
|
|
1486
|
+
*/
|
|
1487
|
+
declare function evaluateDateCondition(cellValue: CellValue, condition: DateFilterCondition): boolean;
|
|
1488
|
+
/**
|
|
1489
|
+
* Evaluate a column filter model against a cell value.
|
|
1490
|
+
* Uses left-to-right evaluation with per-condition operators.
|
|
1491
|
+
*/
|
|
1492
|
+
declare function evaluateColumnFilter(cellValue: CellValue, filter: ColumnFilterModel): boolean;
|
|
1493
|
+
/**
|
|
1494
|
+
* Check if a row passes all filters in a filter model.
|
|
1495
|
+
*/
|
|
1496
|
+
declare function rowPassesFilter<TData extends Row>(row: TData, filterModel: FilterModel, getFieldValue: (row: TData, field: string) => CellValue): boolean;
|
|
1666
1497
|
//#endregion
|
|
1667
|
-
//#region src/
|
|
1668
|
-
interface
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
/** Custom field accessor for nested properties */
|
|
1672
|
-
getFieldValue?: (row: TData, field: string) => CellValue;
|
|
1498
|
+
//#region src/managers/transaction-manager.d.ts
|
|
1499
|
+
interface AddTransaction<TData> {
|
|
1500
|
+
type: "ADD";
|
|
1501
|
+
rows: TData[];
|
|
1673
1502
|
}
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1503
|
+
interface RemoveTransaction {
|
|
1504
|
+
type: "REMOVE";
|
|
1505
|
+
rowIds: RowId[];
|
|
1506
|
+
}
|
|
1507
|
+
interface UpdateCellTransaction {
|
|
1508
|
+
type: "UPDATE_CELL";
|
|
1509
|
+
rowId: RowId;
|
|
1510
|
+
field: string;
|
|
1511
|
+
value: CellValue;
|
|
1512
|
+
}
|
|
1513
|
+
interface UpdateRowTransaction<TData> {
|
|
1514
|
+
type: "UPDATE_ROW";
|
|
1515
|
+
rowId: RowId;
|
|
1516
|
+
data: Partial<TData>;
|
|
1517
|
+
}
|
|
1518
|
+
type Transaction<TData> = AddTransaction<TData> | RemoveTransaction | UpdateCellTransaction | UpdateRowTransaction<TData>;
|
|
1519
|
+
interface TransactionResult {
|
|
1520
|
+
added: number;
|
|
1521
|
+
removed: number;
|
|
1522
|
+
updated: number;
|
|
1523
|
+
}
|
|
1524
|
+
interface TransactionManagerOptions<TData extends Row> {
|
|
1525
|
+
/** Debounce time in milliseconds. Default 50. Set to 0 for sync. */
|
|
1526
|
+
debounceMs: number;
|
|
1527
|
+
/** The indexed data store to apply transactions to */
|
|
1528
|
+
store: IndexedDataStore<TData>;
|
|
1529
|
+
/** Callback when transactions are processed */
|
|
1530
|
+
onProcessed?: (result: TransactionResult) => void;
|
|
1678
1531
|
}
|
|
1679
1532
|
/**
|
|
1680
|
-
*
|
|
1681
|
-
* Supports
|
|
1682
|
-
* - O(1) lookup by row ID
|
|
1683
|
-
* - O(log n) binary insertion to maintain sort order
|
|
1684
|
-
* - Filter state caching with distinct values
|
|
1685
|
-
* - Hash caching for fast sorted comparisons
|
|
1533
|
+
* Manages a queue of data mutations with debounced batch processing.
|
|
1534
|
+
* Supports ADD, REMOVE, UPDATE_CELL, and UPDATE_ROW operations.
|
|
1686
1535
|
*/
|
|
1687
|
-
declare class
|
|
1688
|
-
private
|
|
1689
|
-
private
|
|
1690
|
-
private
|
|
1691
|
-
private sortModel;
|
|
1692
|
-
private sortModelHash;
|
|
1693
|
-
private filterModel;
|
|
1694
|
-
private filteredIndices;
|
|
1695
|
-
private distinctValues;
|
|
1696
|
-
private rowSortCache;
|
|
1536
|
+
declare class TransactionManager<TData extends Row = Row> {
|
|
1537
|
+
private queue;
|
|
1538
|
+
private debounceTimer;
|
|
1539
|
+
private pendingPromise;
|
|
1697
1540
|
private options;
|
|
1698
|
-
constructor(
|
|
1541
|
+
constructor(options: TransactionManagerOptions<TData>);
|
|
1699
1542
|
/**
|
|
1700
|
-
*
|
|
1701
|
-
* Used for proper memory cleanup when the store is no longer needed.
|
|
1543
|
+
* Queue rows to be added.
|
|
1702
1544
|
*/
|
|
1703
|
-
|
|
1545
|
+
add(rows: TData[]): void;
|
|
1704
1546
|
/**
|
|
1705
|
-
*
|
|
1547
|
+
* Queue rows to be removed by ID.
|
|
1706
1548
|
*/
|
|
1707
|
-
|
|
1549
|
+
remove(rowIds: RowId[]): void;
|
|
1708
1550
|
/**
|
|
1709
|
-
*
|
|
1710
|
-
* Compatible with DataSource.fetch() interface.
|
|
1551
|
+
* Queue a cell update.
|
|
1711
1552
|
*/
|
|
1712
|
-
|
|
1553
|
+
updateCell(rowId: RowId, field: string, value: CellValue): void;
|
|
1713
1554
|
/**
|
|
1714
|
-
*
|
|
1555
|
+
* Queue a row update (multiple fields).
|
|
1715
1556
|
*/
|
|
1716
|
-
|
|
1557
|
+
updateRow(rowId: RowId, data: Partial<TData>): void;
|
|
1717
1558
|
/**
|
|
1718
|
-
*
|
|
1559
|
+
* Force immediate processing of queued transactions.
|
|
1560
|
+
* Returns a promise that resolves when processing is complete.
|
|
1719
1561
|
*/
|
|
1720
|
-
|
|
1562
|
+
flush(): Promise<void>;
|
|
1721
1563
|
/**
|
|
1722
|
-
*
|
|
1564
|
+
* Check if there are pending transactions.
|
|
1723
1565
|
*/
|
|
1724
|
-
|
|
1566
|
+
hasPending(): boolean;
|
|
1725
1567
|
/**
|
|
1726
|
-
* Get
|
|
1727
|
-
* Used for direct data access when bypassing store's query system.
|
|
1568
|
+
* Get count of pending transactions.
|
|
1728
1569
|
*/
|
|
1729
|
-
|
|
1570
|
+
getPendingCount(): number;
|
|
1730
1571
|
/**
|
|
1731
|
-
*
|
|
1572
|
+
* Clear all pending transactions without processing.
|
|
1732
1573
|
*/
|
|
1733
|
-
|
|
1574
|
+
clear(): void;
|
|
1734
1575
|
/**
|
|
1735
|
-
*
|
|
1576
|
+
* Schedule processing after throttle delay.
|
|
1577
|
+
* Uses throttle pattern: if a timer is already pending, new transactions
|
|
1578
|
+
* are added to the queue but don't reset the timer. This ensures updates
|
|
1579
|
+
* are processed even when they arrive faster than the throttle interval.
|
|
1736
1580
|
*/
|
|
1737
|
-
|
|
1581
|
+
private scheduleProcessing;
|
|
1738
1582
|
/**
|
|
1739
|
-
*
|
|
1740
|
-
* Rows are inserted at their correct sorted position.
|
|
1583
|
+
* Process all queued transactions.
|
|
1741
1584
|
*/
|
|
1742
|
-
|
|
1585
|
+
private processQueue;
|
|
1586
|
+
}
|
|
1587
|
+
//#endregion
|
|
1588
|
+
//#region src/grid-core.d.ts
|
|
1589
|
+
declare class GridCore<TData extends Row = Row> {
|
|
1590
|
+
private columns;
|
|
1591
|
+
private dataSource;
|
|
1592
|
+
private rowHeight;
|
|
1593
|
+
private headerHeight;
|
|
1594
|
+
private overscan;
|
|
1595
|
+
private sortingEnabled;
|
|
1596
|
+
private getRowId?;
|
|
1597
|
+
private onCellValueChanged?;
|
|
1598
|
+
private rowDragEntireRow;
|
|
1599
|
+
private onRowDragEnd?;
|
|
1600
|
+
private onColumnResized?;
|
|
1601
|
+
private onColumnMoved?;
|
|
1602
|
+
private scrollTop;
|
|
1603
|
+
private scrollLeft;
|
|
1604
|
+
private viewportWidth;
|
|
1605
|
+
private viewportHeight;
|
|
1606
|
+
private currentPageIndex;
|
|
1607
|
+
private pageSize;
|
|
1608
|
+
private cachedRows;
|
|
1609
|
+
private totalRows;
|
|
1610
|
+
readonly selection: SelectionManager;
|
|
1611
|
+
readonly fill: FillManager;
|
|
1612
|
+
readonly input: InputHandler<TData>;
|
|
1613
|
+
readonly highlight: HighlightManager<TData> | null;
|
|
1614
|
+
readonly sortFilter: SortFilterManager<TData>;
|
|
1615
|
+
readonly rowMutation: RowMutationManager<TData>;
|
|
1616
|
+
private readonly slotPool;
|
|
1617
|
+
private readonly editManager;
|
|
1618
|
+
private columnPositions;
|
|
1619
|
+
private batchListeners;
|
|
1620
|
+
private instructionBuffer;
|
|
1621
|
+
private readonly scrollVirtualization;
|
|
1622
|
+
private isDestroyed;
|
|
1623
|
+
private _isDataLoading;
|
|
1624
|
+
constructor(options: GridCoreOptions<TData>);
|
|
1743
1625
|
/**
|
|
1744
|
-
*
|
|
1626
|
+
* Subscribe to batched instructions for efficient React/Vue state updates.
|
|
1627
|
+
* Batch listeners receive arrays of instructions instead of individual ones.
|
|
1745
1628
|
*/
|
|
1746
|
-
|
|
1629
|
+
onBatchInstruction(listener: BatchInstructionListener): () => void;
|
|
1747
1630
|
/**
|
|
1748
|
-
*
|
|
1631
|
+
* Start buffering instructions. All emit/emitBatch calls will accumulate
|
|
1632
|
+
* into an internal buffer until flushBatch() is called.
|
|
1749
1633
|
*/
|
|
1750
|
-
|
|
1634
|
+
private startBatch;
|
|
1751
1635
|
/**
|
|
1752
|
-
*
|
|
1636
|
+
* Flush buffered instructions to listeners as a single batch, then
|
|
1637
|
+
* stop buffering.
|
|
1753
1638
|
*/
|
|
1754
|
-
private
|
|
1639
|
+
private flushBatch;
|
|
1640
|
+
private emit;
|
|
1641
|
+
private emitBatch;
|
|
1755
1642
|
/**
|
|
1756
|
-
*
|
|
1643
|
+
* Initialize the grid and load initial data.
|
|
1757
1644
|
*/
|
|
1758
|
-
|
|
1645
|
+
initialize(): Promise<void>;
|
|
1759
1646
|
/**
|
|
1760
|
-
* Update
|
|
1647
|
+
* Update viewport measurements and sync slots.
|
|
1648
|
+
* When scroll virtualization is active, maps the DOM scroll position to the actual row position.
|
|
1761
1649
|
*/
|
|
1762
|
-
|
|
1650
|
+
setViewport(scrollTop: number, scrollLeft: number, width: number, height: number): void;
|
|
1651
|
+
private fetchData;
|
|
1652
|
+
setSort(colId: string, direction: SortDirection | null, addToExisting?: boolean): Promise<void>;
|
|
1653
|
+
setFilter(colId: string, filter: ColumnFilterModel | string | null): Promise<void>;
|
|
1654
|
+
hasActiveFilter(colId: string): boolean;
|
|
1655
|
+
getDistinctValuesForColumn(colId: string, maxValues?: number): CellValue[];
|
|
1656
|
+
openFilterPopup(colIndex: number, anchorRect: {
|
|
1657
|
+
top: number;
|
|
1658
|
+
left: number;
|
|
1659
|
+
width: number;
|
|
1660
|
+
height: number;
|
|
1661
|
+
}): void;
|
|
1662
|
+
closeFilterPopup(): void;
|
|
1663
|
+
getSortModel(): SortModel[];
|
|
1664
|
+
getFilterModel(): FilterModel;
|
|
1665
|
+
startEdit(row: number, col: number): void;
|
|
1666
|
+
updateEditValue(value: CellValue): void;
|
|
1667
|
+
commitEdit(): void;
|
|
1668
|
+
cancelEdit(): void;
|
|
1669
|
+
getEditState(): EditState | null;
|
|
1670
|
+
getCellValue(row: number, col: number): CellValue;
|
|
1671
|
+
setCellValue(row: number, col: number, value: CellValue): void;
|
|
1672
|
+
private clearSelectionIfInvalid;
|
|
1673
|
+
private computeColumnPositions;
|
|
1674
|
+
private emitContentSize;
|
|
1675
|
+
private emitHeaders;
|
|
1763
1676
|
/**
|
|
1764
|
-
*
|
|
1677
|
+
* Set the width of a column and recompute layout.
|
|
1765
1678
|
*/
|
|
1766
|
-
|
|
1679
|
+
setColumnWidth(colIndex: number, width: number): void;
|
|
1767
1680
|
/**
|
|
1768
|
-
*
|
|
1681
|
+
* Move a column from one index to another and recompute layout.
|
|
1769
1682
|
*/
|
|
1770
|
-
|
|
1683
|
+
moveColumn(fromIndex: number, toIndex: number): void;
|
|
1771
1684
|
/**
|
|
1772
|
-
*
|
|
1685
|
+
* Commit a row drag operation. Reorders data if the data source supports it,
|
|
1686
|
+
* then invokes the onRowDragEnd callback.
|
|
1687
|
+
*
|
|
1688
|
+
* Optimized: instead of a full refresh (fetchData + rebuild all slots), we
|
|
1689
|
+
* update the cachedRows map in-place to mirror the splice the data source
|
|
1690
|
+
* performed, then only update the affected slots.
|
|
1773
1691
|
*/
|
|
1774
|
-
|
|
1692
|
+
commitRowDrag(sourceIndex: number, targetIndex: number): void;
|
|
1775
1693
|
/**
|
|
1776
|
-
*
|
|
1694
|
+
* Whether the entire row is draggable.
|
|
1777
1695
|
*/
|
|
1778
|
-
|
|
1696
|
+
isRowDragEntireRow(): boolean;
|
|
1697
|
+
getColumns(): ColumnDefinition[];
|
|
1698
|
+
getColumnPositions(): number[];
|
|
1699
|
+
getRowCount(): number;
|
|
1700
|
+
getRowHeight(): number;
|
|
1701
|
+
getHeaderHeight(): number;
|
|
1702
|
+
getTotalWidth(): number;
|
|
1703
|
+
getTotalHeight(): number;
|
|
1704
|
+
isScalingActive(): boolean;
|
|
1705
|
+
getNaturalHeight(): number;
|
|
1706
|
+
getScrollRatio(): number;
|
|
1707
|
+
getVisibleRowRange(): {
|
|
1708
|
+
start: number;
|
|
1709
|
+
end: number;
|
|
1710
|
+
};
|
|
1711
|
+
getScrollTopForRow(rowIndex: number): number;
|
|
1712
|
+
getRowIndexAtDisplayY(viewportY: number, virtualScrollTop: number): number;
|
|
1779
1713
|
/**
|
|
1780
|
-
* Get
|
|
1714
|
+
* Get the translateY position for a row inside the rows wrapper.
|
|
1715
|
+
* Accounts for scroll virtualization (compressed coordinates).
|
|
1781
1716
|
*/
|
|
1782
|
-
|
|
1717
|
+
getRowTranslateY(rowIndex: number): number;
|
|
1718
|
+
getRowData(rowIndex: number): TData | undefined;
|
|
1783
1719
|
/**
|
|
1784
|
-
*
|
|
1720
|
+
* Refresh data from the data source.
|
|
1785
1721
|
*/
|
|
1786
|
-
|
|
1722
|
+
refresh(): Promise<void>;
|
|
1787
1723
|
/**
|
|
1788
|
-
*
|
|
1724
|
+
* Fast-path refresh for transaction-based mutations.
|
|
1725
|
+
* Only re-fetches the visible window instead of all rows.
|
|
1726
|
+
* Use this when data was mutated via MutableDataSource transactions.
|
|
1789
1727
|
*/
|
|
1790
|
-
|
|
1728
|
+
refreshFromTransaction(): Promise<void>;
|
|
1791
1729
|
/**
|
|
1792
|
-
*
|
|
1730
|
+
* Refresh slot display without refetching data.
|
|
1731
|
+
* Useful after in-place data modifications like fill operations.
|
|
1793
1732
|
*/
|
|
1794
|
-
|
|
1733
|
+
refreshSlotData(): void;
|
|
1795
1734
|
/**
|
|
1796
|
-
*
|
|
1735
|
+
* Add rows to the grid at the specified index.
|
|
1736
|
+
* If no index is provided, rows are added at the end.
|
|
1797
1737
|
*/
|
|
1798
|
-
|
|
1738
|
+
addRows(rows: TData[], index?: number): void;
|
|
1799
1739
|
/**
|
|
1800
|
-
*
|
|
1740
|
+
* Update existing rows with partial data.
|
|
1801
1741
|
*/
|
|
1802
|
-
|
|
1742
|
+
updateRows(updates: Array<{
|
|
1743
|
+
index: number;
|
|
1744
|
+
data: Partial<TData>;
|
|
1745
|
+
}>): void;
|
|
1803
1746
|
/**
|
|
1804
|
-
*
|
|
1747
|
+
* Delete rows at the specified indices.
|
|
1805
1748
|
*/
|
|
1806
|
-
|
|
1749
|
+
deleteRows(indices: number[]): void;
|
|
1807
1750
|
/**
|
|
1808
|
-
*
|
|
1751
|
+
* Get a row by index.
|
|
1809
1752
|
*/
|
|
1810
|
-
|
|
1753
|
+
getRow(index: number): TData | undefined;
|
|
1811
1754
|
/**
|
|
1812
|
-
*
|
|
1755
|
+
* Set a complete row at the specified index.
|
|
1756
|
+
* Use this for complete row replacement. For partial updates, use updateRows.
|
|
1813
1757
|
*/
|
|
1814
|
-
|
|
1758
|
+
setRow(index: number, data: TData): void;
|
|
1815
1759
|
/**
|
|
1816
|
-
*
|
|
1760
|
+
* Update the data source and refresh.
|
|
1761
|
+
* Preserves grid state (sort, filter, scroll position).
|
|
1762
|
+
* Cancels any active edit and clamps selection to valid range.
|
|
1817
1763
|
*/
|
|
1818
|
-
|
|
1764
|
+
setDataSource(dataSource: DataSource<TData>): Promise<void>;
|
|
1819
1765
|
/**
|
|
1820
|
-
* Update
|
|
1766
|
+
* Update columns and recompute layout.
|
|
1821
1767
|
*/
|
|
1822
|
-
|
|
1768
|
+
setColumns(columns: ColumnDefinition[]): void;
|
|
1823
1769
|
/**
|
|
1824
|
-
*
|
|
1770
|
+
* Destroy the grid core and release all references.
|
|
1771
|
+
* Call this before discarding the GridCore to ensure proper cleanup.
|
|
1772
|
+
* This method is idempotent - safe to call multiple times.
|
|
1825
1773
|
*/
|
|
1826
|
-
|
|
1774
|
+
destroy(): void;
|
|
1827
1775
|
}
|
|
1828
1776
|
//#endregion
|
|
1829
|
-
//#region src/
|
|
1777
|
+
//#region src/utils/positioning.d.ts
|
|
1830
1778
|
/**
|
|
1831
|
-
*
|
|
1832
|
-
*
|
|
1833
|
-
*
|
|
1779
|
+
* Calculate cumulative column positions (prefix sums)
|
|
1780
|
+
* Returns an array where positions[i] is the left position of column i
|
|
1781
|
+
* positions[columns.length] is the total width
|
|
1834
1782
|
*/
|
|
1835
|
-
declare
|
|
1783
|
+
declare const calculateColumnPositions: (columns: ColumnDefinition[]) => number[];
|
|
1836
1784
|
/**
|
|
1837
|
-
*
|
|
1838
|
-
* Creates nested objects if they don't exist.
|
|
1839
|
-
* @example
|
|
1840
|
-
* const obj = { user: {} };
|
|
1841
|
-
* setFieldValue(obj, "user.name", "John");
|
|
1842
|
-
* // obj is now { user: { name: "John" } }
|
|
1785
|
+
* Get total width from column positions
|
|
1843
1786
|
*/
|
|
1844
|
-
declare
|
|
1845
|
-
//#endregion
|
|
1846
|
-
//#region src/indexed-data-store/sorting.d.ts
|
|
1787
|
+
declare const getTotalWidth: (columnPositions: number[]) => number;
|
|
1847
1788
|
/**
|
|
1848
|
-
*
|
|
1849
|
-
*
|
|
1789
|
+
* Calculate scaled column positions when container is wider than total column widths.
|
|
1790
|
+
* Columns expand proportionally based on their original width ratios.
|
|
1791
|
+
*
|
|
1792
|
+
* @param columns - Column definitions with original widths
|
|
1793
|
+
* @param containerWidth - Available container width
|
|
1794
|
+
* @returns Object with positions array and widths array
|
|
1850
1795
|
*/
|
|
1851
|
-
declare
|
|
1796
|
+
declare const calculateScaledColumnPositions: (columns: ColumnDefinition[], containerWidth: number) => {
|
|
1797
|
+
positions: number[];
|
|
1798
|
+
widths: number[];
|
|
1799
|
+
};
|
|
1852
1800
|
/**
|
|
1853
|
-
*
|
|
1854
|
-
* Handles null/undefined, arrays, numbers, dates, and strings.
|
|
1801
|
+
* Find column index at a given X coordinate
|
|
1855
1802
|
*/
|
|
1856
|
-
declare
|
|
1803
|
+
declare const findColumnAtX: (x: number, columnPositions: number[]) => number;
|
|
1804
|
+
//#endregion
|
|
1805
|
+
//#region src/utils/classNames.d.ts
|
|
1857
1806
|
/**
|
|
1858
|
-
*
|
|
1859
|
-
* Used for fast comparisons in sorted indices.
|
|
1807
|
+
* Check if a cell is within the selection range
|
|
1860
1808
|
*/
|
|
1861
|
-
declare
|
|
1862
|
-
//#endregion
|
|
1863
|
-
//#region src/filtering/index.d.ts
|
|
1809
|
+
declare const isCellSelected: (row: number, col: number, selectionRange: CellRange | null) => boolean;
|
|
1864
1810
|
/**
|
|
1865
|
-
* Check if
|
|
1811
|
+
* Check if a cell is the active cell
|
|
1866
1812
|
*/
|
|
1867
|
-
declare
|
|
1813
|
+
declare const isCellActive: (row: number, col: number, activeCell: CellPosition | null) => boolean;
|
|
1868
1814
|
/**
|
|
1869
|
-
*
|
|
1815
|
+
* Check if a row is within the visible range (not in overscan)
|
|
1870
1816
|
*/
|
|
1871
|
-
declare
|
|
1817
|
+
declare const isRowVisible: (row: number, visibleRowRange: {
|
|
1818
|
+
start: number;
|
|
1819
|
+
end: number;
|
|
1820
|
+
} | null) => boolean;
|
|
1872
1821
|
/**
|
|
1873
|
-
*
|
|
1822
|
+
* Check if a cell is being edited
|
|
1874
1823
|
*/
|
|
1875
|
-
declare
|
|
1824
|
+
declare const isCellEditing: (row: number, col: number, editingCell: {
|
|
1825
|
+
row: number;
|
|
1826
|
+
col: number;
|
|
1827
|
+
} | null) => boolean;
|
|
1876
1828
|
/**
|
|
1877
|
-
*
|
|
1829
|
+
* Check if a cell is in the fill preview range (vertical-only fill)
|
|
1878
1830
|
*/
|
|
1879
|
-
declare
|
|
1831
|
+
declare const isCellInFillPreview: (row: number, col: number, isDraggingFill: boolean, fillSourceRange: CellRange | null, fillTarget: {
|
|
1832
|
+
row: number;
|
|
1833
|
+
col: number;
|
|
1834
|
+
} | null) => boolean;
|
|
1880
1835
|
/**
|
|
1881
|
-
*
|
|
1882
|
-
* Uses left-to-right evaluation with per-condition operators.
|
|
1836
|
+
* Build cell CSS classes based on state
|
|
1883
1837
|
*/
|
|
1884
|
-
declare
|
|
1838
|
+
declare const buildCellClasses: (isActive: boolean, isSelected: boolean, isEditing: boolean, inFillPreview: boolean) => string;
|
|
1885
1839
|
/**
|
|
1886
|
-
* Check if a row
|
|
1840
|
+
* Check if a row overlaps the selection range
|
|
1887
1841
|
*/
|
|
1888
|
-
declare
|
|
1842
|
+
declare const isRowInSelectionRange: (rowIndex: number, range: CellRange | null) => boolean;
|
|
1843
|
+
/**
|
|
1844
|
+
* Check if a column overlaps the selection range
|
|
1845
|
+
*/
|
|
1846
|
+
declare const isColumnInSelectionRange: (colIndex: number, range: CellRange | null) => boolean;
|
|
1889
1847
|
//#endregion
|
|
1890
|
-
//#region src/
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1848
|
+
//#region src/utils/event-emitter.d.ts
|
|
1849
|
+
/**
|
|
1850
|
+
* Batch instruction listener for efficient state updates
|
|
1851
|
+
*/
|
|
1852
|
+
type BatchInstructionListener$1 = (instructions: GridInstruction[]) => void;
|
|
1853
|
+
//#endregion
|
|
1854
|
+
//#region src/types/ui-state.d.ts
|
|
1855
|
+
interface SlotData<TData = Row> {
|
|
1856
|
+
slotId: string;
|
|
1857
|
+
rowIndex: number;
|
|
1858
|
+
rowData: TData;
|
|
1859
|
+
translateY: number;
|
|
1894
1860
|
}
|
|
1895
|
-
interface
|
|
1896
|
-
|
|
1897
|
-
|
|
1861
|
+
interface HeaderData {
|
|
1862
|
+
column: ColumnDefinition;
|
|
1863
|
+
sortDirection?: SortDirection;
|
|
1864
|
+
sortIndex?: number;
|
|
1865
|
+
hasFilter: boolean;
|
|
1898
1866
|
}
|
|
1899
|
-
interface
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1867
|
+
interface FilterPopupState {
|
|
1868
|
+
isOpen: boolean;
|
|
1869
|
+
colIndex: number;
|
|
1870
|
+
column: ColumnDefinition | null;
|
|
1871
|
+
anchorRect: {
|
|
1872
|
+
top: number;
|
|
1873
|
+
left: number;
|
|
1874
|
+
width: number;
|
|
1875
|
+
height: number;
|
|
1876
|
+
} | null;
|
|
1877
|
+
distinctValues: CellValue[];
|
|
1878
|
+
currentFilter?: ColumnFilterModel;
|
|
1904
1879
|
}
|
|
1905
|
-
interface
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
data: Partial<TData>;
|
|
1880
|
+
interface InitialStateArgs {
|
|
1881
|
+
initialWidth?: number;
|
|
1882
|
+
initialHeight?: number;
|
|
1909
1883
|
}
|
|
1910
|
-
|
|
1911
|
-
interface
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1884
|
+
declare const createInitialState: <TData = Row>(args?: InitialStateArgs) => GridState<TData>;
|
|
1885
|
+
interface GridState<TData = Row> {
|
|
1886
|
+
slots: Map<string, SlotData<TData>>;
|
|
1887
|
+
activeCell: CellPosition | null;
|
|
1888
|
+
selectionRange: CellRange | null;
|
|
1889
|
+
editingCell: {
|
|
1890
|
+
row: number;
|
|
1891
|
+
col: number;
|
|
1892
|
+
initialValue: CellValue;
|
|
1893
|
+
} | null;
|
|
1894
|
+
contentWidth: number;
|
|
1895
|
+
contentHeight: number;
|
|
1896
|
+
/** Viewport width (container's visible width) for column scaling */
|
|
1897
|
+
viewportWidth: number;
|
|
1898
|
+
/** Viewport height (container's visible height) for loader positioning */
|
|
1899
|
+
viewportHeight: number;
|
|
1900
|
+
/** Y offset for rows wrapper when virtualization is active (keeps row translateY values small) */
|
|
1901
|
+
rowsWrapperOffset: number;
|
|
1902
|
+
headers: Map<number, HeaderData>;
|
|
1903
|
+
filterPopup: FilterPopupState | null;
|
|
1904
|
+
isLoading: boolean;
|
|
1905
|
+
error: string | null;
|
|
1906
|
+
totalRows: number;
|
|
1907
|
+
/** Visible row range (start inclusive, end inclusive). Used to prevent selection showing in overscan. */
|
|
1908
|
+
visibleRowRange: {
|
|
1909
|
+
start: number;
|
|
1910
|
+
end: number;
|
|
1911
|
+
} | null;
|
|
1912
|
+
/** Currently hovered cell position (for highlighting) */
|
|
1913
|
+
hoverPosition: CellPosition | null;
|
|
1914
|
+
/** Columns updated by core (after resize/reorder). Null means use props. */
|
|
1915
|
+
columns: ColumnDefinition[] | null;
|
|
1916
|
+
}
|
|
1917
|
+
//#endregion
|
|
1918
|
+
//#region src/utils/scroll-helpers.d.ts
|
|
1919
|
+
/**
|
|
1920
|
+
* Find the slot for a given row index
|
|
1921
|
+
*/
|
|
1922
|
+
declare const findSlotForRow: (slots: Map<string, SlotData>, rowIndex: number) => SlotData | null;
|
|
1923
|
+
/**
|
|
1924
|
+
* Scroll a cell into view if needed.
|
|
1925
|
+
*
|
|
1926
|
+
* The header is rendered outside the scroll container (flex column layout),
|
|
1927
|
+
* so all coordinates are relative to the body scroll container.
|
|
1928
|
+
*
|
|
1929
|
+
* When scroll virtualization is active, slot.translateY is relative to the
|
|
1930
|
+
* first visible row, and the rows wrapper is offset by rowsWrapperOffset.
|
|
1931
|
+
* The actual DOM position of a row is: rowsWrapperOffset + slot.translateY.
|
|
1932
|
+
*/
|
|
1933
|
+
declare const scrollCellIntoView: (core: {
|
|
1934
|
+
getScrollTopForRow(row: number): number;
|
|
1935
|
+
}, container: HTMLDivElement, row: number, rowHeight: number, slots: Map<string, SlotData>, rowsWrapperOffset?: number) => void;
|
|
1936
|
+
//#endregion
|
|
1937
|
+
//#region src/utils/fill-helpers.d.ts
|
|
1938
|
+
interface VisibleColumnInfo {
|
|
1939
|
+
column: ColumnDefinition;
|
|
1940
|
+
originalIndex: number;
|
|
1941
|
+
}
|
|
1942
|
+
interface FillHandlePosition {
|
|
1943
|
+
top: number;
|
|
1944
|
+
left: number;
|
|
1945
|
+
}
|
|
1946
|
+
interface CalculateFillHandlePositionParams {
|
|
1947
|
+
activeCell: CellPosition | null;
|
|
1948
|
+
selectionRange: CellRange | null;
|
|
1949
|
+
slots: Map<string, SlotData>;
|
|
1950
|
+
columns: ColumnDefinition[];
|
|
1951
|
+
visibleColumnsWithIndices: VisibleColumnInfo[];
|
|
1952
|
+
columnPositions: number[];
|
|
1953
|
+
columnWidths: number[];
|
|
1954
|
+
rowHeight: number;
|
|
1955
|
+
}
|
|
1956
|
+
/**
|
|
1957
|
+
* Calculate the fill handle position (bottom-right corner of active cell or selection).
|
|
1958
|
+
* Returns null if no cell is active, columns are not editable, or the target is not visible.
|
|
1959
|
+
*/
|
|
1960
|
+
declare const calculateFillHandlePosition: (params: CalculateFillHandlePositionParams) => FillHandlePosition | null;
|
|
1961
|
+
//#endregion
|
|
1962
|
+
//#region src/slot-pool.d.ts
|
|
1963
|
+
interface SlotPoolManagerOptions {
|
|
1964
|
+
/** Get current row height */
|
|
1965
|
+
getRowHeight: () => number;
|
|
1966
|
+
/** Get current header height */
|
|
1967
|
+
getHeaderHeight: () => number;
|
|
1968
|
+
/** Get overscan count */
|
|
1969
|
+
getOverscan: () => number;
|
|
1970
|
+
/** Get current scroll top position (natural, not virtual) */
|
|
1971
|
+
getScrollTop: () => number;
|
|
1972
|
+
/** Get viewport height */
|
|
1973
|
+
getViewportHeight: () => number;
|
|
1974
|
+
/** Get total row count */
|
|
1975
|
+
getTotalRows: () => number;
|
|
1976
|
+
/** Get scroll ratio for virtualization (1 = no virtualization) */
|
|
1977
|
+
getScrollRatio: () => number;
|
|
1978
|
+
/** Get virtual content height */
|
|
1979
|
+
getVirtualContentHeight: () => number;
|
|
1980
|
+
/** Get row data by index */
|
|
1981
|
+
getRowData: (rowIndex: number) => Row | undefined;
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Manages the slot pool for virtual scrolling.
|
|
1985
|
+
* Handles slot creation, recycling, positioning, and destruction.
|
|
1986
|
+
*/
|
|
1987
|
+
declare class SlotPoolManager {
|
|
1988
|
+
private state;
|
|
1989
|
+
private options;
|
|
1990
|
+
private emitter;
|
|
1991
|
+
private isDestroyed;
|
|
1992
|
+
onInstruction: (listener: InstructionListener) => () => void;
|
|
1993
|
+
onBatchInstruction: (listener: BatchInstructionListener$1) => () => void;
|
|
1994
|
+
private emit;
|
|
1995
|
+
private emitBatch;
|
|
1996
|
+
constructor(options: SlotPoolManagerOptions);
|
|
1997
|
+
/**
|
|
1998
|
+
* Get the slot ID for a given row index.
|
|
1999
|
+
*/
|
|
2000
|
+
getSlotForRow(rowIndex: number): string | undefined;
|
|
2001
|
+
/**
|
|
2002
|
+
* Get all current slots.
|
|
2003
|
+
*/
|
|
2004
|
+
getSlots(): Map<string, SlotState>;
|
|
2005
|
+
/**
|
|
2006
|
+
* Synchronize slots with current viewport position.
|
|
2007
|
+
* This implements the slot recycling strategy.
|
|
2008
|
+
*/
|
|
2009
|
+
syncSlots(): void;
|
|
2010
|
+
/**
|
|
2011
|
+
* Destroy all slots.
|
|
2012
|
+
*/
|
|
2013
|
+
destroyAllSlots(): void;
|
|
2014
|
+
/**
|
|
2015
|
+
* Clean up resources for garbage collection.
|
|
2016
|
+
* This method is idempotent - safe to call multiple times.
|
|
2017
|
+
*/
|
|
2018
|
+
destroy(): void;
|
|
2019
|
+
/**
|
|
2020
|
+
* Refresh all slot data without changing which rows are displayed.
|
|
2021
|
+
* Used after filtering/sorting when data changes.
|
|
2022
|
+
*/
|
|
2023
|
+
refreshAllSlots(): void;
|
|
2024
|
+
/**
|
|
2025
|
+
* Update a single slot's data.
|
|
2026
|
+
*/
|
|
2027
|
+
updateSlot(rowIndex: number): void;
|
|
2028
|
+
/**
|
|
2029
|
+
* Calculate the translateY position for a row.
|
|
2030
|
+
* Handles scroll virtualization for very large datasets.
|
|
2031
|
+
*
|
|
2032
|
+
* When virtualization is active (scrollRatio < 1), we use viewport-relative
|
|
2033
|
+
* positioning to keep translateY values small. This prevents browser rendering
|
|
2034
|
+
* issues that occur at extreme pixel values (millions of pixels).
|
|
2035
|
+
*
|
|
2036
|
+
* Note: The header is rendered outside the content sizer, so row positions
|
|
2037
|
+
* start at 0 (not headerHeight) within the rows container.
|
|
2038
|
+
*/
|
|
2039
|
+
private getRowTranslateY;
|
|
2040
|
+
/**
|
|
2041
|
+
* Get the translateY position for a row inside the rows wrapper.
|
|
2042
|
+
* Public accessor for use by input handler (e.g., drop indicator positioning).
|
|
2043
|
+
*/
|
|
2044
|
+
getRowTranslateYForIndex(rowIndex: number): number;
|
|
2045
|
+
/**
|
|
2046
|
+
* Get the Y offset for the rows wrapper container.
|
|
2047
|
+
* When virtualization is active, this positions the wrapper so rows
|
|
2048
|
+
* with small translateY values appear at the correct scroll position.
|
|
2049
|
+
*/
|
|
2050
|
+
getRowsWrapperOffset(): number;
|
|
2051
|
+
}
|
|
2052
|
+
//#endregion
|
|
2053
|
+
//#region src/edit-manager.d.ts
|
|
2054
|
+
interface EditManagerOptions {
|
|
2055
|
+
/** Get column definition by index */
|
|
2056
|
+
getColumn: (colIndex: number) => ColumnDefinition | undefined;
|
|
2057
|
+
/** Get cell value */
|
|
2058
|
+
getCellValue: (row: number, col: number) => CellValue;
|
|
2059
|
+
/** Set cell value */
|
|
2060
|
+
setCellValue: (row: number, col: number, value: CellValue) => void;
|
|
2061
|
+
/** Callback when edit is committed (to update slot display) */
|
|
2062
|
+
onCommit?: (row: number, col: number, value: CellValue) => void;
|
|
2063
|
+
}
|
|
2064
|
+
/**
|
|
2065
|
+
* Manages cell editing state and operations.
|
|
2066
|
+
*/
|
|
2067
|
+
declare class EditManager {
|
|
2068
|
+
private editState;
|
|
2069
|
+
private options;
|
|
2070
|
+
private emitter;
|
|
2071
|
+
onInstruction: (listener: InstructionListener) => () => void;
|
|
2072
|
+
private emit;
|
|
2073
|
+
constructor(options: EditManagerOptions);
|
|
2074
|
+
/**
|
|
2075
|
+
* Get the current edit state.
|
|
2076
|
+
*/
|
|
2077
|
+
getState(): EditState | null;
|
|
2078
|
+
/**
|
|
2079
|
+
* Check if currently editing.
|
|
2080
|
+
*/
|
|
2081
|
+
isEditing(): boolean;
|
|
2082
|
+
/**
|
|
2083
|
+
* Check if a specific cell is being edited.
|
|
2084
|
+
*/
|
|
2085
|
+
isEditingCell(row: number, col: number): boolean;
|
|
2086
|
+
/**
|
|
2087
|
+
* Start editing a cell.
|
|
2088
|
+
* Returns true if edit was started, false if cell is not editable.
|
|
2089
|
+
*/
|
|
2090
|
+
startEdit(row: number, col: number): boolean;
|
|
2091
|
+
/**
|
|
2092
|
+
* Update the current edit value.
|
|
2093
|
+
*/
|
|
2094
|
+
updateValue(value: CellValue): void;
|
|
2095
|
+
/**
|
|
2096
|
+
* Commit the current edit.
|
|
2097
|
+
* Saves the value and closes the editor.
|
|
2098
|
+
*/
|
|
2099
|
+
commit(): void;
|
|
2100
|
+
/**
|
|
2101
|
+
* Cancel the current edit.
|
|
2102
|
+
* Discards changes and closes the editor.
|
|
2103
|
+
*/
|
|
2104
|
+
cancel(): void;
|
|
2105
|
+
/**
|
|
2106
|
+
* Clean up resources for garbage collection.
|
|
2107
|
+
*/
|
|
2108
|
+
destroy(): void;
|
|
2109
|
+
}
|
|
2110
|
+
//#endregion
|
|
2111
|
+
//#region src/sorting/parallel-sort-manager.d.ts
|
|
2112
|
+
interface ParallelSortOptions {
|
|
2113
|
+
/** Maximum number of workers (default: navigator.hardwareConcurrency || 4) */
|
|
2114
|
+
maxWorkers?: number;
|
|
2115
|
+
/** Threshold for parallel sorting (default: 400000) */
|
|
2116
|
+
parallelThreshold?: number;
|
|
2117
|
+
/** Minimum chunk size (default: 50000) */
|
|
2118
|
+
minChunkSize?: number;
|
|
2119
|
+
}
|
|
2120
|
+
/**
|
|
2121
|
+
* Manages parallel sorting operations using a worker pool.
|
|
2122
|
+
* Automatically decides between single-worker and parallel sorting based on data size.
|
|
2123
|
+
*/
|
|
2124
|
+
declare class ParallelSortManager {
|
|
2125
|
+
private pool;
|
|
2126
|
+
private parallelThreshold;
|
|
2127
|
+
private minChunkSize;
|
|
2128
|
+
private isTerminated;
|
|
2129
|
+
constructor(options?: ParallelSortOptions);
|
|
2130
|
+
/**
|
|
2131
|
+
* Check if the manager is available for use.
|
|
2132
|
+
*/
|
|
2133
|
+
isAvailable(): boolean;
|
|
2134
|
+
/**
|
|
2135
|
+
* Terminate all workers and clean up resources.
|
|
2136
|
+
*/
|
|
2137
|
+
terminate(): void;
|
|
2138
|
+
/**
|
|
2139
|
+
* Sort indices using values array.
|
|
2140
|
+
* Automatically uses parallel sorting for large datasets.
|
|
2141
|
+
*/
|
|
2142
|
+
sortIndices(values: number[], direction: SortDirection): Promise<Uint32Array>;
|
|
2143
|
+
/**
|
|
2144
|
+
* Sort string hashes with collision detection.
|
|
2145
|
+
* Automatically uses parallel sorting for large datasets.
|
|
2146
|
+
*/
|
|
2147
|
+
sortStringHashes(hashChunks: Float64Array[], direction: SortDirection, originalStrings: string[]): Promise<Uint32Array>;
|
|
2148
|
+
/**
|
|
2149
|
+
* Multi-column sort.
|
|
2150
|
+
* Automatically uses parallel sorting for large datasets.
|
|
2151
|
+
*/
|
|
2152
|
+
sortMultiColumn(columns: number[][], directions: SortDirection[]): Promise<Uint32Array>;
|
|
2153
|
+
private sortIndicesSingle;
|
|
2154
|
+
private sortStringHashesSingle;
|
|
2155
|
+
private sortMultiColumnSingle;
|
|
2156
|
+
private sortIndicesParallel;
|
|
2157
|
+
private sortStringHashesParallel;
|
|
2158
|
+
private sortMultiColumnParallel;
|
|
2159
|
+
/**
|
|
2160
|
+
* Split data into chunks for parallel processing.
|
|
2161
|
+
*/
|
|
2162
|
+
private splitIntoChunks;
|
|
2163
|
+
/**
|
|
2164
|
+
* Calculate chunk boundaries without copying data.
|
|
2165
|
+
*/
|
|
2166
|
+
private calculateChunkBoundaries;
|
|
2167
|
+
/**
|
|
2168
|
+
* Detect collisions at chunk boundaries for string sorting.
|
|
2169
|
+
*/
|
|
2170
|
+
private detectBoundaryCollisionsForStrings;
|
|
2171
|
+
/**
|
|
2172
|
+
* Resolve hash collisions using localeCompare.
|
|
2173
|
+
*/
|
|
2174
|
+
private resolveCollisions;
|
|
1915
2175
|
}
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
/**
|
|
1920
|
-
|
|
1921
|
-
/**
|
|
1922
|
-
|
|
2176
|
+
//#endregion
|
|
2177
|
+
//#region src/sorting/worker-pool.d.ts
|
|
2178
|
+
interface WorkerPoolOptions {
|
|
2179
|
+
/** Maximum number of workers (default: navigator.hardwareConcurrency ?? 4) */
|
|
2180
|
+
maxWorkers?: number;
|
|
2181
|
+
/** Whether to pre-warm workers on initialization */
|
|
2182
|
+
preWarm?: boolean;
|
|
1923
2183
|
}
|
|
1924
2184
|
/**
|
|
1925
|
-
* Manages a
|
|
1926
|
-
*
|
|
2185
|
+
* Manages a pool of Web Workers for parallel task execution.
|
|
2186
|
+
* Workers are created lazily and reused across operations.
|
|
1927
2187
|
*/
|
|
1928
|
-
declare class
|
|
1929
|
-
private
|
|
1930
|
-
private
|
|
1931
|
-
private
|
|
1932
|
-
private
|
|
1933
|
-
|
|
2188
|
+
declare class WorkerPool {
|
|
2189
|
+
private workerCode;
|
|
2190
|
+
private maxWorkers;
|
|
2191
|
+
private workers;
|
|
2192
|
+
private workerUrl;
|
|
2193
|
+
private nextRequestId;
|
|
2194
|
+
private isTerminated;
|
|
2195
|
+
constructor(workerCode: string, options?: WorkerPoolOptions);
|
|
1934
2196
|
/**
|
|
1935
|
-
*
|
|
2197
|
+
* Get the current pool size (number of active workers).
|
|
1936
2198
|
*/
|
|
1937
|
-
|
|
2199
|
+
getPoolSize(): number;
|
|
1938
2200
|
/**
|
|
1939
|
-
*
|
|
2201
|
+
* Get the maximum pool size.
|
|
1940
2202
|
*/
|
|
1941
|
-
|
|
2203
|
+
getMaxWorkers(): number;
|
|
1942
2204
|
/**
|
|
1943
|
-
*
|
|
2205
|
+
* Check if the pool is available for use.
|
|
1944
2206
|
*/
|
|
1945
|
-
|
|
2207
|
+
isAvailable(): boolean;
|
|
1946
2208
|
/**
|
|
1947
|
-
*
|
|
2209
|
+
* Execute a single task on an available worker.
|
|
2210
|
+
* Returns the worker's response.
|
|
1948
2211
|
*/
|
|
1949
|
-
|
|
2212
|
+
execute<TRequest extends {
|
|
2213
|
+
id?: number;
|
|
2214
|
+
}, TResponse>(request: TRequest, transferables?: Transferable[]): Promise<TResponse>;
|
|
1950
2215
|
/**
|
|
1951
|
-
*
|
|
1952
|
-
*
|
|
2216
|
+
* Execute multiple tasks in parallel across available workers.
|
|
2217
|
+
* Each task is assigned to a different worker if possible.
|
|
2218
|
+
* Returns results in the same order as the input requests.
|
|
1953
2219
|
*/
|
|
1954
|
-
|
|
2220
|
+
executeParallel<TRequest extends {
|
|
2221
|
+
id?: number;
|
|
2222
|
+
}, TResponse>(tasks: Array<{
|
|
2223
|
+
request: TRequest;
|
|
2224
|
+
transferables?: Transferable[];
|
|
2225
|
+
}>): Promise<TResponse[]>;
|
|
1955
2226
|
/**
|
|
1956
|
-
*
|
|
2227
|
+
* Terminate all workers and clean up resources.
|
|
1957
2228
|
*/
|
|
1958
|
-
|
|
2229
|
+
terminate(): void;
|
|
1959
2230
|
/**
|
|
1960
|
-
*
|
|
2231
|
+
* Pre-warm workers by creating them ahead of time.
|
|
1961
2232
|
*/
|
|
1962
|
-
|
|
2233
|
+
private preWarmWorkers;
|
|
1963
2234
|
/**
|
|
1964
|
-
*
|
|
2235
|
+
* Ensure at least `count` workers exist in the pool.
|
|
1965
2236
|
*/
|
|
1966
|
-
|
|
2237
|
+
private ensureWorkers;
|
|
1967
2238
|
/**
|
|
1968
|
-
*
|
|
1969
|
-
* Uses throttle pattern: if a timer is already pending, new transactions
|
|
1970
|
-
* are added to the queue but don't reset the timer. This ensures updates
|
|
1971
|
-
* are processed even when they arrive faster than the throttle interval.
|
|
2239
|
+
* Get an available worker, creating one if needed.
|
|
1972
2240
|
*/
|
|
1973
|
-
private
|
|
2241
|
+
private getAvailableWorker;
|
|
1974
2242
|
/**
|
|
1975
|
-
*
|
|
2243
|
+
* Create a new worker and add it to the pool.
|
|
1976
2244
|
*/
|
|
1977
|
-
private
|
|
2245
|
+
private createWorker;
|
|
2246
|
+
/**
|
|
2247
|
+
* Respawn a failed worker.
|
|
2248
|
+
*/
|
|
2249
|
+
private respawnWorker;
|
|
2250
|
+
}
|
|
2251
|
+
//#endregion
|
|
2252
|
+
//#region src/sorting/k-way-merge.d.ts
|
|
2253
|
+
/**
|
|
2254
|
+
* Represents a sorted chunk with its values and offset in the original array.
|
|
2255
|
+
*/
|
|
2256
|
+
interface SortedChunk {
|
|
2257
|
+
/** Sorted indices (local to this chunk) */
|
|
2258
|
+
indices: Uint32Array;
|
|
2259
|
+
/** Values for comparison (in same order as indices) */
|
|
2260
|
+
values: Float64Array;
|
|
2261
|
+
/** Offset of this chunk in the original array */
|
|
2262
|
+
offset: number;
|
|
2263
|
+
}
|
|
2264
|
+
/**
|
|
2265
|
+
* Represents a sorted chunk for multi-column sorting.
|
|
2266
|
+
*/
|
|
2267
|
+
interface MultiColumnSortedChunk {
|
|
2268
|
+
/** Sorted indices (local to this chunk) */
|
|
2269
|
+
indices: Uint32Array;
|
|
2270
|
+
/** Values for comparison - array of columns, each in same order as indices */
|
|
2271
|
+
columns: Float64Array[];
|
|
2272
|
+
/** Sort directions for each column (1 = asc, -1 = desc) */
|
|
2273
|
+
directions: Int8Array;
|
|
2274
|
+
/** Offset of this chunk in the original array */
|
|
2275
|
+
offset: number;
|
|
2276
|
+
}
|
|
2277
|
+
/**
|
|
2278
|
+
* Merge multiple sorted chunks into a single sorted result.
|
|
2279
|
+
* Uses a min-heap for O(n log k) time complexity.
|
|
2280
|
+
*
|
|
2281
|
+
* @param chunks - Array of sorted chunks to merge
|
|
2282
|
+
* @param direction - Sort direction ('asc' or 'desc')
|
|
2283
|
+
* @returns Uint32Array of globally sorted indices
|
|
2284
|
+
*/
|
|
2285
|
+
declare function kWayMerge(chunks: SortedChunk[], direction: SortDirection): Uint32Array;
|
|
2286
|
+
/**
|
|
2287
|
+
* Merge multiple sorted chunks for multi-column sorting.
|
|
2288
|
+
*
|
|
2289
|
+
* @param chunks - Array of multi-column sorted chunks
|
|
2290
|
+
* @returns Uint32Array of globally sorted indices
|
|
2291
|
+
*/
|
|
2292
|
+
declare function kWayMergeMultiColumn(chunks: MultiColumnSortedChunk[]): Uint32Array;
|
|
2293
|
+
/**
|
|
2294
|
+
* Detect collision runs at chunk boundaries after merge.
|
|
2295
|
+
* This is used for string sorting where hashes may collide across chunks.
|
|
2296
|
+
*
|
|
2297
|
+
* @param chunks - Original sorted chunks with their hash values
|
|
2298
|
+
* @param _direction - Sort direction
|
|
2299
|
+
* @returns Array of boundary collision positions [start1, end1, start2, end2, ...]
|
|
2300
|
+
*/
|
|
2301
|
+
declare function detectBoundaryCollisions(chunks: SortedChunk[], _direction: SortDirection): Uint32Array;
|
|
2302
|
+
//#endregion
|
|
2303
|
+
//#region src/data-source/client-data-source.d.ts
|
|
2304
|
+
interface ClientDataSourceOptions<TData> {
|
|
2305
|
+
/** Custom field accessor for nested properties */
|
|
2306
|
+
getFieldValue?: (row: TData, field: string) => CellValue;
|
|
2307
|
+
/** Use Web Worker for sorting large datasets (default: true) */
|
|
2308
|
+
useWorker?: boolean;
|
|
2309
|
+
/** Options for parallel sorting (only used when useWorker is true) */
|
|
2310
|
+
parallelSort?: ParallelSortOptions | false;
|
|
1978
2311
|
}
|
|
2312
|
+
/**
|
|
2313
|
+
* Creates a client-side data source that holds all data in memory.
|
|
2314
|
+
* Sorting and filtering are performed client-side.
|
|
2315
|
+
* For large datasets, sorting is automatically offloaded to a Web Worker.
|
|
2316
|
+
*/
|
|
2317
|
+
declare function createClientDataSource<TData extends Row = Row>(data: TData[], options?: ClientDataSourceOptions<TData>): DataSource<TData>;
|
|
2318
|
+
/**
|
|
2319
|
+
* Convenience function to create a data source from an array.
|
|
2320
|
+
* This provides backwards compatibility with the old `rowData` prop.
|
|
2321
|
+
*/
|
|
2322
|
+
declare function createDataSourceFromArray<TData extends Row = Row>(data: TData[]): DataSource<TData>;
|
|
2323
|
+
//#endregion
|
|
2324
|
+
//#region src/data-source/server-data-source.d.ts
|
|
2325
|
+
type ServerFetchFunction<TData> = (request: DataSourceRequest) => Promise<DataSourceResponse<TData>>;
|
|
2326
|
+
/**
|
|
2327
|
+
* Creates a server-side data source that delegates all operations to the server.
|
|
2328
|
+
* The fetch function receives sort/filter/pagination params to pass to the API.
|
|
2329
|
+
*/
|
|
2330
|
+
declare function createServerDataSource<TData extends Row = Row>(fetchFn: ServerFetchFunction<TData>): DataSource<TData>;
|
|
1979
2331
|
//#endregion
|
|
1980
2332
|
//#region src/data-source/mutable-data-source.d.ts
|
|
1981
2333
|
/** Callback for data change notifications */
|
|
@@ -2007,6 +2359,8 @@ interface MutableDataSource<TData = Row> extends DataSource<TData> {
|
|
|
2007
2359
|
subscribe(listener: DataChangeListener): () => void;
|
|
2008
2360
|
/** Clear all data from the data source. */
|
|
2009
2361
|
clear(): void;
|
|
2362
|
+
/** Move a row from one display position to another. */
|
|
2363
|
+
moveRow(fromIndex: number, toIndex: number): void;
|
|
2010
2364
|
}
|
|
2011
2365
|
interface MutableClientDataSourceOptions<TData> {
|
|
2012
2366
|
/** Function to extract unique ID from row. Required. */
|
|
@@ -2050,6 +2404,9 @@ declare const scrollbarStyles: string;
|
|
|
2050
2404
|
//#region src/styles/filters.d.ts
|
|
2051
2405
|
declare const filtersStyles: string;
|
|
2052
2406
|
//#endregion
|
|
2407
|
+
//#region src/styles/row-drag.d.ts
|
|
2408
|
+
declare const rowDragStyles: string;
|
|
2409
|
+
//#endregion
|
|
2053
2410
|
//#region src/styles/index.d.ts
|
|
2054
2411
|
/**
|
|
2055
2412
|
* Combined grid styles from all modules
|
|
@@ -2062,63 +2419,13 @@ declare const gridStyles: string;
|
|
|
2062
2419
|
*/
|
|
2063
2420
|
declare function injectStyles(): void;
|
|
2064
2421
|
//#endregion
|
|
2065
|
-
//#region src/
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
column: ColumnDefinition;
|
|
2074
|
-
sortDirection?: SortDirection;
|
|
2075
|
-
sortIndex?: number;
|
|
2076
|
-
sortable: boolean;
|
|
2077
|
-
filterable: boolean;
|
|
2078
|
-
hasFilter: boolean;
|
|
2079
|
-
}
|
|
2080
|
-
interface FilterPopupState {
|
|
2081
|
-
isOpen: boolean;
|
|
2082
|
-
colIndex: number;
|
|
2083
|
-
column: ColumnDefinition | null;
|
|
2084
|
-
anchorRect: {
|
|
2085
|
-
top: number;
|
|
2086
|
-
left: number;
|
|
2087
|
-
width: number;
|
|
2088
|
-
height: number;
|
|
2089
|
-
} | null;
|
|
2090
|
-
distinctValues: CellValue[];
|
|
2091
|
-
currentFilter?: ColumnFilterModel;
|
|
2092
|
-
}
|
|
2093
|
-
interface GridState<TData = Row> {
|
|
2094
|
-
slots: Map<string, SlotData<TData>>;
|
|
2095
|
-
activeCell: CellPosition | null;
|
|
2096
|
-
selectionRange: CellRange | null;
|
|
2097
|
-
editingCell: {
|
|
2098
|
-
row: number;
|
|
2099
|
-
col: number;
|
|
2100
|
-
initialValue: CellValue;
|
|
2101
|
-
} | null;
|
|
2102
|
-
contentWidth: number;
|
|
2103
|
-
contentHeight: number;
|
|
2104
|
-
/** Viewport width (container's visible width) for column scaling */
|
|
2105
|
-
viewportWidth: number;
|
|
2106
|
-
/** Viewport height (container's visible height) for loader positioning */
|
|
2107
|
-
viewportHeight: number;
|
|
2108
|
-
/** Y offset for rows wrapper when virtualization is active (keeps row translateY values small) */
|
|
2109
|
-
rowsWrapperOffset: number;
|
|
2110
|
-
headers: Map<number, HeaderData>;
|
|
2111
|
-
filterPopup: FilterPopupState | null;
|
|
2112
|
-
isLoading: boolean;
|
|
2113
|
-
error: string | null;
|
|
2114
|
-
totalRows: number;
|
|
2115
|
-
/** Visible row range (start inclusive, end inclusive). Used to prevent selection showing in overscan. */
|
|
2116
|
-
visibleRowRange: {
|
|
2117
|
-
start: number;
|
|
2118
|
-
end: number;
|
|
2119
|
-
} | null;
|
|
2120
|
-
/** Currently hovered cell position (for highlighting) */
|
|
2121
|
-
hoverPosition: CellPosition | null;
|
|
2122
|
-
}
|
|
2422
|
+
//#region src/state-reducer.d.ts
|
|
2423
|
+
/**
|
|
2424
|
+
* Apply a single instruction to mutable slot/header Maps and return
|
|
2425
|
+
* other state changes as a partial object.
|
|
2426
|
+
*
|
|
2427
|
+
* Returns `null` when only the Maps were mutated (no primitive field changes).
|
|
2428
|
+
*/
|
|
2429
|
+
declare const applyInstruction: <TData = Row>(instruction: GridInstruction, slots: Map<string, SlotData<TData>>, headers: Map<number, HeaderData>) => Partial<GridState<TData>> | null;
|
|
2123
2430
|
//#endregion
|
|
2124
|
-
export { type AssignSlotInstruction, type BatchInstructionListener, type CancelFillInstruction, type CellDataType, type CellPosition, type CellRange, type CellRendererParams, type CellValue, type CellValueChangedEvent, 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 };
|
|
2431
|
+
export { type AssignSlotInstruction, type BatchInstructionListener, type CalculateFillHandlePositionParams, type CancelColumnMoveInstruction, type CancelColumnResizeInstruction, type CancelFillInstruction, type CancelRowDragInstruction, type CellDataType, type CellPosition, type CellRange, type CellRendererParams, type CellValue, type CellValueChangedEvent, type CloseFilterPopupInstruction, type ColumnDefinition, type ColumnFilterModel, type ColumnMoveDragState, type ColumnResizeDragState, type ColumnsChangedInstruction, type CommitColumnMoveInstruction, type CommitColumnResizeInstruction, type CommitEditInstruction, type CommitFillInstruction, type CommitRowDragInstruction, 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 FillHandlePosition, 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, type InitialStateArgs, 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 RowDragState, type RowId, RowMutationManager, type RowMutationManagerOptions, type RowSortCache, type RowsAddedInstruction, type RowsRemovedInstruction, type RowsUpdatedInstruction, ScrollVirtualizationManager, type ScrollVirtualizationManagerOptions, 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, SortFilterManager, type SortFilterManagerOptions, type SortModel, type SortedChunk, type StartColumnMoveInstruction, type StartColumnResizeInstruction, type StartEditInstruction, type StartFillInstruction, type StartRowDragInstruction, type StopEditInstruction, type TextFilterCondition, type TextFilterOperator, type Transaction, TransactionManager, type TransactionManagerOptions, type TransactionProcessedInstruction, type TransactionResult, type UpdateColumnMoveInstruction, type UpdateColumnResizeInstruction, type UpdateFillInstruction, type UpdateHeaderInstruction, type UpdateRowDragInstruction, type VisibleColumnInfo, WorkerPool, type WorkerPoolOptions, applyInstruction, buildCellClasses, calculateColumnPositions, calculateFillHandlePosition, calculateScaledColumnPositions, cellStyles, compareValues, computeValueHash, containerStyles, createClientDataSource, createDataSourceFromArray, createInitialState, createMutableClientDataSource, createServerDataSource, detectBoundaryCollisions, evaluateColumnFilter, evaluateDateCondition, evaluateNumberCondition, evaluateTextCondition, filtersStyles, findColumnAtX, findSlotForRow, getFieldValue, getTotalWidth, gridStyles, headerStyles, injectStyles, isCellActive, isCellEditing, isCellInFillPreview, isCellSelected, isColumnInSelectionRange, isRowInSelectionRange, isRowVisible, isSameDay, kWayMerge, kWayMergeMultiColumn, rowDragStyles, rowPassesFilter, scrollCellIntoView, scrollbarStyles, setFieldValue, statesStyles, stringToSortableNumber, variablesStyles };
|