gp-grid-core 0.5.3 → 0.7.0
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/README.md +16 -1
- package/dist/index.d.ts +661 -203
- package/dist/index.js +179 -36
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -69,6 +69,81 @@ interface SlotState {
|
|
|
69
69
|
translateY: number;
|
|
70
70
|
}
|
|
71
71
|
//#endregion
|
|
72
|
+
//#region src/types/highlighting.d.ts
|
|
73
|
+
/**
|
|
74
|
+
* Minimal column info for highlighting context.
|
|
75
|
+
* Uses structural typing to avoid circular dependency with columns.ts.
|
|
76
|
+
*/
|
|
77
|
+
interface HighlightColumnInfo {
|
|
78
|
+
field: string;
|
|
79
|
+
colId?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Unified context for row, column, and cell highlighting.
|
|
83
|
+
*
|
|
84
|
+
* - Row context: `rowIndex` is set, `colIndex` is null
|
|
85
|
+
* - Column context: `colIndex` is set, `rowIndex` is null
|
|
86
|
+
* - Cell context: both `rowIndex` and `colIndex` are set
|
|
87
|
+
*/
|
|
88
|
+
interface HighlightContext<TData = Record<string, unknown>> {
|
|
89
|
+
/** Row index. Null for column-only context. */
|
|
90
|
+
rowIndex: number | null;
|
|
91
|
+
/** Column index. Null for row-only context. */
|
|
92
|
+
colIndex: number | null;
|
|
93
|
+
/** Column definition. Present for column and cell contexts. */
|
|
94
|
+
column?: HighlightColumnInfo;
|
|
95
|
+
/** Row data. Present for row and cell contexts. */
|
|
96
|
+
rowData?: TData;
|
|
97
|
+
/** Currently hovered cell position, null if not hovering */
|
|
98
|
+
hoverPosition: CellPosition | null;
|
|
99
|
+
/** Currently active (focused) cell position */
|
|
100
|
+
activeCell: CellPosition | null;
|
|
101
|
+
/** Current selection range */
|
|
102
|
+
selectionRange: CellRange | null;
|
|
103
|
+
/** Whether this row/column/cell is hovered (respects hoverScope) */
|
|
104
|
+
isHovered: boolean;
|
|
105
|
+
/** Whether this row/column contains or is the active cell */
|
|
106
|
+
isActive: boolean;
|
|
107
|
+
/** Whether this row/column/cell overlaps or is in the selection range */
|
|
108
|
+
isSelected: boolean;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Grid-level highlighting options.
|
|
112
|
+
* Hover tracking is automatically enabled when any highlighting callback is defined.
|
|
113
|
+
* Each callback type has its own natural interpretation of `isHovered`:
|
|
114
|
+
* - computeRowClasses: isHovered = mouse is on any cell in this row
|
|
115
|
+
* - computeColumnClasses: isHovered = mouse is on any cell in this column
|
|
116
|
+
* - computeCellClasses: isHovered = mouse is on this exact cell
|
|
117
|
+
*
|
|
118
|
+
* For a crosshair effect, implement both computeRowClasses and computeColumnClasses.
|
|
119
|
+
*/
|
|
120
|
+
interface HighlightingOptions<TData = Record<string, unknown>> {
|
|
121
|
+
/**
|
|
122
|
+
* Row-level class callback.
|
|
123
|
+
* Classes returned are applied to the row container element.
|
|
124
|
+
* Context has `rowIndex` set, `colIndex` is null.
|
|
125
|
+
* `isHovered` is true when the mouse is on any cell in this row.
|
|
126
|
+
* @returns Array of CSS class names
|
|
127
|
+
*/
|
|
128
|
+
computeRowClasses?: (context: HighlightContext<TData>) => string[];
|
|
129
|
+
/**
|
|
130
|
+
* Column-level class callback.
|
|
131
|
+
* Classes returned are applied to all cells in that column (not header).
|
|
132
|
+
* Context has `colIndex` set, `rowIndex` is null.
|
|
133
|
+
* `isHovered` is true when the mouse is on any cell in this column.
|
|
134
|
+
* @returns Array of CSS class names
|
|
135
|
+
*/
|
|
136
|
+
computeColumnClasses?: (context: HighlightContext<TData>) => string[];
|
|
137
|
+
/**
|
|
138
|
+
* Cell-level class callback.
|
|
139
|
+
* Classes returned are applied to individual cells for fine-grained control.
|
|
140
|
+
* Context has both `rowIndex` and `colIndex` set.
|
|
141
|
+
* `isHovered` is true only when the mouse is on this exact cell.
|
|
142
|
+
* @returns Array of CSS class names
|
|
143
|
+
*/
|
|
144
|
+
computeCellClasses?: (context: HighlightContext<TData>) => string[];
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
72
147
|
//#region src/types/columns.d.ts
|
|
73
148
|
/** Column definition */
|
|
74
149
|
interface ColumnDefinition {
|
|
@@ -82,10 +157,26 @@ interface ColumnDefinition {
|
|
|
82
157
|
sortable?: boolean;
|
|
83
158
|
/** Whether column is filterable. Default: true */
|
|
84
159
|
filterable?: boolean;
|
|
160
|
+
/** Whether column is hidden. Hidden columns are not rendered but still exist in the definition. Default: false */
|
|
161
|
+
hidden?: boolean;
|
|
85
162
|
/** Renderer key for adapter lookup, or inline renderer function */
|
|
86
163
|
cellRenderer?: string;
|
|
87
164
|
editRenderer?: string;
|
|
88
165
|
headerRenderer?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Per-column override for column-level highlighting.
|
|
168
|
+
* If defined, overrides grid-level computeColumnClasses for this column.
|
|
169
|
+
* Context has `colIndex` set, `rowIndex` is null.
|
|
170
|
+
* @returns Array of CSS class names to apply to all cells in this column
|
|
171
|
+
*/
|
|
172
|
+
computeColumnClasses?: (context: HighlightContext) => string[];
|
|
173
|
+
/**
|
|
174
|
+
* Per-column override for cell-level highlighting.
|
|
175
|
+
* If defined, overrides grid-level computeCellClasses for cells in this column.
|
|
176
|
+
* Context has both `rowIndex` and `colIndex` set.
|
|
177
|
+
* @returns Array of CSS class names to apply to individual cells
|
|
178
|
+
*/
|
|
179
|
+
computeCellClasses?: (context: HighlightContext) => string[];
|
|
89
180
|
}
|
|
90
181
|
//#endregion
|
|
91
182
|
//#region src/types/filters.d.ts
|
|
@@ -197,6 +288,11 @@ interface SetActiveCellInstruction {
|
|
|
197
288
|
type: "SET_ACTIVE_CELL";
|
|
198
289
|
position: CellPosition | null;
|
|
199
290
|
}
|
|
291
|
+
/** Set hover position instruction (for highlighting) */
|
|
292
|
+
interface SetHoverPositionInstruction {
|
|
293
|
+
type: "SET_HOVER_POSITION";
|
|
294
|
+
position: CellPosition | null;
|
|
295
|
+
}
|
|
200
296
|
/** Set selection range instruction */
|
|
201
297
|
interface SetSelectionRangeInstruction {
|
|
202
298
|
type: "SET_SELECTION_RANGE";
|
|
@@ -306,19 +402,20 @@ interface DataErrorInstruction {
|
|
|
306
402
|
/** Rows added instruction */
|
|
307
403
|
interface RowsAddedInstruction {
|
|
308
404
|
type: "ROWS_ADDED";
|
|
405
|
+
indices: number[];
|
|
309
406
|
count: number;
|
|
310
407
|
totalRows: number;
|
|
311
408
|
}
|
|
312
409
|
/** Rows removed instruction */
|
|
313
410
|
interface RowsRemovedInstruction {
|
|
314
411
|
type: "ROWS_REMOVED";
|
|
315
|
-
|
|
412
|
+
indices: number[];
|
|
316
413
|
totalRows: number;
|
|
317
414
|
}
|
|
318
415
|
/** Rows updated instruction */
|
|
319
416
|
interface RowsUpdatedInstruction {
|
|
320
417
|
type: "ROWS_UPDATED";
|
|
321
|
-
|
|
418
|
+
indices: number[];
|
|
322
419
|
}
|
|
323
420
|
/** Transaction processed instruction */
|
|
324
421
|
interface TransactionProcessedInstruction {
|
|
@@ -331,6 +428,7 @@ interface TransactionProcessedInstruction {
|
|
|
331
428
|
type GridInstruction = /** Slot lifecycle */
|
|
332
429
|
CreateSlotInstruction | DestroySlotInstruction | AssignSlotInstruction | MoveSlotInstruction
|
|
333
430
|
/** Selection */ | SetActiveCellInstruction | SetSelectionRangeInstruction | UpdateVisibleRangeInstruction
|
|
431
|
+
/** Highlighting */ | SetHoverPositionInstruction
|
|
334
432
|
/** Editing */ | StartEditInstruction | StopEditInstruction | CommitEditInstruction
|
|
335
433
|
/** Layout */ | SetContentSizeInstruction | UpdateHeaderInstruction
|
|
336
434
|
/** Filter popup */ | OpenFilterPopupInstruction | CloseFilterPopupInstruction
|
|
@@ -414,6 +512,8 @@ interface GridCoreOptions<TData = Row> {
|
|
|
414
512
|
transactionDebounceMs?: number;
|
|
415
513
|
/** Function to extract unique ID from row. Required for mutations. */
|
|
416
514
|
getRowId?: (row: TData) => RowId;
|
|
515
|
+
/** Row/column/cell highlighting configuration */
|
|
516
|
+
highlighting?: HighlightingOptions<TData>;
|
|
417
517
|
}
|
|
418
518
|
//#endregion
|
|
419
519
|
//#region src/types/input.d.ts
|
|
@@ -494,10 +594,16 @@ interface InputHandlerDeps {
|
|
|
494
594
|
getHeaderHeight: () => number;
|
|
495
595
|
/** Get row height */
|
|
496
596
|
getRowHeight: () => number;
|
|
497
|
-
/** Get column positions array */
|
|
597
|
+
/** Get column positions array (indexed by visible column) */
|
|
498
598
|
getColumnPositions: () => number[];
|
|
499
|
-
/** Get column count */
|
|
599
|
+
/** Get visible column count */
|
|
500
600
|
getColumnCount: () => number;
|
|
601
|
+
/**
|
|
602
|
+
* Convert visible column index to original column index.
|
|
603
|
+
* Used when columns can be hidden. Returns the original index for selection tracking.
|
|
604
|
+
* If not provided, visible index is used directly (no hidden columns).
|
|
605
|
+
*/
|
|
606
|
+
getOriginalColumnIndex?: (visibleIndex: number) => number;
|
|
501
607
|
}
|
|
502
608
|
/** Current drag state for UI rendering */
|
|
503
609
|
interface DragState {
|
|
@@ -514,6 +620,83 @@ interface DragState {
|
|
|
514
620
|
} | null;
|
|
515
621
|
}
|
|
516
622
|
//#endregion
|
|
623
|
+
//#region src/utils/positioning.d.ts
|
|
624
|
+
/**
|
|
625
|
+
* Calculate cumulative column positions (prefix sums)
|
|
626
|
+
* Returns an array where positions[i] is the left position of column i
|
|
627
|
+
* positions[columns.length] is the total width
|
|
628
|
+
*/
|
|
629
|
+
declare const calculateColumnPositions: (columns: ColumnDefinition[]) => number[];
|
|
630
|
+
/**
|
|
631
|
+
* Get total width from column positions
|
|
632
|
+
*/
|
|
633
|
+
declare const getTotalWidth: (columnPositions: number[]) => number;
|
|
634
|
+
/**
|
|
635
|
+
* Calculate scaled column positions when container is wider than total column widths.
|
|
636
|
+
* Columns expand proportionally based on their original width ratios.
|
|
637
|
+
*
|
|
638
|
+
* @param columns - Column definitions with original widths
|
|
639
|
+
* @param containerWidth - Available container width
|
|
640
|
+
* @returns Object with positions array and widths array
|
|
641
|
+
*/
|
|
642
|
+
declare const calculateScaledColumnPositions: (columns: ColumnDefinition[], containerWidth: number) => {
|
|
643
|
+
positions: number[];
|
|
644
|
+
widths: number[];
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* Find column index at a given X coordinate
|
|
648
|
+
*/
|
|
649
|
+
declare const findColumnAtX: (x: number, columnPositions: number[]) => number;
|
|
650
|
+
//#endregion
|
|
651
|
+
//#region src/utils/classNames.d.ts
|
|
652
|
+
/**
|
|
653
|
+
* Check if a cell is within the selection range
|
|
654
|
+
*/
|
|
655
|
+
declare const isCellSelected: (row: number, col: number, selectionRange: CellRange | null) => boolean;
|
|
656
|
+
/**
|
|
657
|
+
* Check if a cell is the active cell
|
|
658
|
+
*/
|
|
659
|
+
declare const isCellActive: (row: number, col: number, activeCell: CellPosition | null) => boolean;
|
|
660
|
+
/**
|
|
661
|
+
* Check if a row is within the visible range (not in overscan)
|
|
662
|
+
*/
|
|
663
|
+
declare const isRowVisible: (row: number, visibleRowRange: {
|
|
664
|
+
start: number;
|
|
665
|
+
end: number;
|
|
666
|
+
} | null) => boolean;
|
|
667
|
+
/**
|
|
668
|
+
* Check if a cell is being edited
|
|
669
|
+
*/
|
|
670
|
+
declare const isCellEditing: (row: number, col: number, editingCell: {
|
|
671
|
+
row: number;
|
|
672
|
+
col: number;
|
|
673
|
+
} | null) => boolean;
|
|
674
|
+
/**
|
|
675
|
+
* Check if a cell is in the fill preview range (vertical-only fill)
|
|
676
|
+
*/
|
|
677
|
+
declare const isCellInFillPreview: (row: number, col: number, isDraggingFill: boolean, fillSourceRange: CellRange | null, fillTarget: {
|
|
678
|
+
row: number;
|
|
679
|
+
col: number;
|
|
680
|
+
} | null) => boolean;
|
|
681
|
+
/**
|
|
682
|
+
* Build cell CSS classes based on state
|
|
683
|
+
*/
|
|
684
|
+
declare const buildCellClasses: (isActive: boolean, isSelected: boolean, isEditing: boolean, inFillPreview: boolean) => string;
|
|
685
|
+
/**
|
|
686
|
+
* Check if a row overlaps the selection range
|
|
687
|
+
*/
|
|
688
|
+
declare const isRowInSelectionRange: (rowIndex: number, range: CellRange | null) => boolean;
|
|
689
|
+
/**
|
|
690
|
+
* Check if a column overlaps the selection range
|
|
691
|
+
*/
|
|
692
|
+
declare const isColumnInSelectionRange: (colIndex: number, range: CellRange | null) => boolean;
|
|
693
|
+
//#endregion
|
|
694
|
+
//#region src/utils/event-emitter.d.ts
|
|
695
|
+
/**
|
|
696
|
+
* Batch instruction listener for efficient state updates
|
|
697
|
+
*/
|
|
698
|
+
type BatchInstructionListener$1 = (instructions: GridInstruction[]) => void;
|
|
699
|
+
//#endregion
|
|
517
700
|
//#region src/selection.d.ts
|
|
518
701
|
type Direction = "up" | "down" | "left" | "right";
|
|
519
702
|
interface SelectionManagerOptions {
|
|
@@ -529,10 +712,10 @@ interface SelectionManagerOptions {
|
|
|
529
712
|
declare class SelectionManager {
|
|
530
713
|
private state;
|
|
531
714
|
private options;
|
|
532
|
-
private
|
|
533
|
-
|
|
534
|
-
onInstruction(listener: InstructionListener): () => void;
|
|
715
|
+
private emitter;
|
|
716
|
+
onInstruction: (listener: InstructionListener) => () => void;
|
|
535
717
|
private emit;
|
|
718
|
+
constructor(options: SelectionManagerOptions);
|
|
536
719
|
getState(): SelectionState;
|
|
537
720
|
getActiveCell(): CellPosition | null;
|
|
538
721
|
getSelectionRange(): CellRange | null;
|
|
@@ -597,10 +780,10 @@ interface FillManagerOptions {
|
|
|
597
780
|
declare class FillManager {
|
|
598
781
|
private state;
|
|
599
782
|
private options;
|
|
600
|
-
private
|
|
601
|
-
|
|
602
|
-
onInstruction(listener: InstructionListener): () => void;
|
|
783
|
+
private emitter;
|
|
784
|
+
onInstruction: (listener: InstructionListener) => () => void;
|
|
603
785
|
private emit;
|
|
786
|
+
constructor(options: FillManagerOptions);
|
|
604
787
|
getState(): FillHandleState | null;
|
|
605
788
|
isActive(): boolean;
|
|
606
789
|
/**
|
|
@@ -657,6 +840,14 @@ declare class InputHandler<TData extends Row = Row> {
|
|
|
657
840
|
* Handle cell double click event (start editing)
|
|
658
841
|
*/
|
|
659
842
|
handleCellDoubleClick(rowIndex: number, colIndex: number): void;
|
|
843
|
+
/**
|
|
844
|
+
* Handle cell mouse enter event (for hover highlighting)
|
|
845
|
+
*/
|
|
846
|
+
handleCellMouseEnter(rowIndex: number, colIndex: number): void;
|
|
847
|
+
/**
|
|
848
|
+
* Handle cell mouse leave event (for hover highlighting)
|
|
849
|
+
*/
|
|
850
|
+
handleCellMouseLeave(): void;
|
|
660
851
|
/**
|
|
661
852
|
* Handle fill handle mouse down event
|
|
662
853
|
*/
|
|
@@ -692,16 +883,222 @@ declare class InputHandler<TData extends Row = Row> {
|
|
|
692
883
|
row: number;
|
|
693
884
|
col: number;
|
|
694
885
|
} | null, filterPopupOpen: boolean): KeyboardResult;
|
|
695
|
-
/**
|
|
696
|
-
* Find column index at a given X coordinate
|
|
697
|
-
*/
|
|
698
|
-
private findColumnAtX;
|
|
699
886
|
/**
|
|
700
887
|
* Calculate auto-scroll deltas based on mouse position
|
|
701
888
|
*/
|
|
702
889
|
private calculateAutoScroll;
|
|
703
890
|
}
|
|
704
891
|
//#endregion
|
|
892
|
+
//#region src/highlight-manager.d.ts
|
|
893
|
+
interface HighlightManagerOptions {
|
|
894
|
+
getActiveCell: () => CellPosition | null;
|
|
895
|
+
getSelectionRange: () => CellRange | null;
|
|
896
|
+
getColumn: (colIndex: number) => ColumnDefinition | undefined;
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Manages row/column/cell highlighting state and class computation.
|
|
900
|
+
* Emits SET_HOVER_POSITION instructions when hover position changes.
|
|
901
|
+
*/
|
|
902
|
+
declare class HighlightManager<TData = Record<string, unknown>> {
|
|
903
|
+
private options;
|
|
904
|
+
private highlightingOptions;
|
|
905
|
+
private hoverPosition;
|
|
906
|
+
private emitter;
|
|
907
|
+
onInstruction: (listener: InstructionListener) => () => void;
|
|
908
|
+
private emit;
|
|
909
|
+
private rowClassCache;
|
|
910
|
+
private columnClassCache;
|
|
911
|
+
private cellClassCache;
|
|
912
|
+
constructor(options: HighlightManagerOptions, highlightingOptions?: HighlightingOptions<TData>);
|
|
913
|
+
/**
|
|
914
|
+
* Check if highlighting is enabled (any callback defined).
|
|
915
|
+
* Hover tracking is automatically enabled when highlighting is enabled.
|
|
916
|
+
*/
|
|
917
|
+
isEnabled(): boolean;
|
|
918
|
+
/**
|
|
919
|
+
* Set the current hover position. Clears caches and emits instruction.
|
|
920
|
+
* Hover tracking is automatically enabled when any highlighting callback is defined.
|
|
921
|
+
*/
|
|
922
|
+
setHoverPosition(position: CellPosition | null): void;
|
|
923
|
+
/**
|
|
924
|
+
* Get the current hover position
|
|
925
|
+
*/
|
|
926
|
+
getHoverPosition(): CellPosition | null;
|
|
927
|
+
/**
|
|
928
|
+
* Called when selection changes. Clears all caches.
|
|
929
|
+
*/
|
|
930
|
+
onSelectionChange(): void;
|
|
931
|
+
/**
|
|
932
|
+
* Build context for row highlighting callback.
|
|
933
|
+
* Returns context with `rowIndex` set, `colIndex` is null.
|
|
934
|
+
* `isHovered` is true when the mouse is on any cell in this row.
|
|
935
|
+
*/
|
|
936
|
+
buildRowContext(rowIndex: number, rowData?: TData): HighlightContext<TData>;
|
|
937
|
+
/**
|
|
938
|
+
* Build context for column highlighting callback.
|
|
939
|
+
* Returns context with `colIndex` set, `rowIndex` is null.
|
|
940
|
+
* `isHovered` is true when the mouse is on any cell in this column.
|
|
941
|
+
*/
|
|
942
|
+
buildColumnContext(colIndex: number, column: ColumnDefinition): HighlightContext<TData>;
|
|
943
|
+
/**
|
|
944
|
+
* Build context for cell highlighting callback.
|
|
945
|
+
* Returns context with both `rowIndex` and `colIndex` set.
|
|
946
|
+
* `isHovered` is true only when the mouse is on this exact cell.
|
|
947
|
+
*/
|
|
948
|
+
buildCellContext(rowIndex: number, colIndex: number, column: ColumnDefinition, rowData?: TData): HighlightContext<TData>;
|
|
949
|
+
/**
|
|
950
|
+
* Compute row classes using cache and user callback
|
|
951
|
+
*/
|
|
952
|
+
computeRowClasses(rowIndex: number, rowData?: TData): string[];
|
|
953
|
+
/**
|
|
954
|
+
* Compute column classes using cache and user callback (or per-column override)
|
|
955
|
+
*/
|
|
956
|
+
computeColumnClasses(colIndex: number, column: ColumnDefinition): string[];
|
|
957
|
+
/**
|
|
958
|
+
* Compute cell classes using cache and user callback (or per-column override)
|
|
959
|
+
*/
|
|
960
|
+
computeCellClasses(rowIndex: number, colIndex: number, column: ColumnDefinition, rowData?: TData): string[];
|
|
961
|
+
/**
|
|
962
|
+
* Compute combined cell classes (column + cell classes flattened)
|
|
963
|
+
*/
|
|
964
|
+
computeCombinedCellClasses(rowIndex: number, colIndex: number, column: ColumnDefinition, rowData?: TData): string[];
|
|
965
|
+
/**
|
|
966
|
+
* Clear all caches
|
|
967
|
+
*/
|
|
968
|
+
clearAllCaches(): void;
|
|
969
|
+
/**
|
|
970
|
+
* Destroy the manager and release resources
|
|
971
|
+
*/
|
|
972
|
+
destroy(): void;
|
|
973
|
+
}
|
|
974
|
+
//#endregion
|
|
975
|
+
//#region src/sort-filter-manager.d.ts
|
|
976
|
+
interface SortFilterManagerOptions<TData> {
|
|
977
|
+
/** Get all columns */
|
|
978
|
+
getColumns: () => ColumnDefinition[];
|
|
979
|
+
/** Check if sorting is enabled globally */
|
|
980
|
+
isSortingEnabled: () => boolean;
|
|
981
|
+
/** Get cached rows for distinct value computation */
|
|
982
|
+
getCachedRows: () => Map<number, TData>;
|
|
983
|
+
/** Called when sort/filter changes to trigger data refresh */
|
|
984
|
+
onSortFilterChange: () => Promise<void>;
|
|
985
|
+
/** Called after data refresh to update UI */
|
|
986
|
+
onDataRefreshed: () => void;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Manages sorting and filtering state and operations.
|
|
990
|
+
*/
|
|
991
|
+
declare class SortFilterManager<TData = Record<string, unknown>> {
|
|
992
|
+
private options;
|
|
993
|
+
private emitter;
|
|
994
|
+
private sortModel;
|
|
995
|
+
private filterModel;
|
|
996
|
+
private openFilterColIndex;
|
|
997
|
+
onInstruction: (listener: InstructionListener) => () => void;
|
|
998
|
+
private emit;
|
|
999
|
+
constructor(options: SortFilterManagerOptions<TData>);
|
|
1000
|
+
setSort(colId: string, direction: SortDirection | null, addToExisting?: boolean): Promise<void>;
|
|
1001
|
+
getSortModel(): SortModel[];
|
|
1002
|
+
setFilter(colId: string, filter: ColumnFilterModel | string | null): Promise<void>;
|
|
1003
|
+
getFilterModel(): FilterModel;
|
|
1004
|
+
/**
|
|
1005
|
+
* Check if a column has an active filter
|
|
1006
|
+
*/
|
|
1007
|
+
hasActiveFilter(colId: string): boolean;
|
|
1008
|
+
/**
|
|
1009
|
+
* Check if a column is sortable
|
|
1010
|
+
*/
|
|
1011
|
+
isColumnSortable(colIndex: number): boolean;
|
|
1012
|
+
/**
|
|
1013
|
+
* Check if a column is filterable
|
|
1014
|
+
*/
|
|
1015
|
+
isColumnFilterable(colIndex: number): boolean;
|
|
1016
|
+
/**
|
|
1017
|
+
* Get distinct values for a column (for filter dropdowns)
|
|
1018
|
+
* For array-type columns (like tags), each unique array combination is returned.
|
|
1019
|
+
* Arrays are sorted internally for consistent comparison.
|
|
1020
|
+
* Limited to maxValues to avoid performance issues with large datasets.
|
|
1021
|
+
*/
|
|
1022
|
+
getDistinctValuesForColumn(colId: string, maxValues?: number): CellValue[];
|
|
1023
|
+
/**
|
|
1024
|
+
* Open filter popup for a column (toggles if already open for same column)
|
|
1025
|
+
*/
|
|
1026
|
+
openFilterPopup(colIndex: number, anchorRect: {
|
|
1027
|
+
top: number;
|
|
1028
|
+
left: number;
|
|
1029
|
+
width: number;
|
|
1030
|
+
height: number;
|
|
1031
|
+
}): void;
|
|
1032
|
+
/**
|
|
1033
|
+
* Close filter popup
|
|
1034
|
+
*/
|
|
1035
|
+
closeFilterPopup(): void;
|
|
1036
|
+
/**
|
|
1037
|
+
* Get sort info map for header rendering
|
|
1038
|
+
*/
|
|
1039
|
+
getSortInfoMap(): Map<string, {
|
|
1040
|
+
direction: SortDirection;
|
|
1041
|
+
index: number;
|
|
1042
|
+
}>;
|
|
1043
|
+
destroy(): void;
|
|
1044
|
+
}
|
|
1045
|
+
//#endregion
|
|
1046
|
+
//#region src/row-mutation-manager.d.ts
|
|
1047
|
+
interface RowMutationManagerOptions<TData> {
|
|
1048
|
+
/** Get the cached rows map */
|
|
1049
|
+
getCachedRows: () => Map<number, TData>;
|
|
1050
|
+
/** Set the cached rows map (for bulk operations) */
|
|
1051
|
+
setCachedRows: (rows: Map<number, TData>) => void;
|
|
1052
|
+
/** Get total row count */
|
|
1053
|
+
getTotalRows: () => number;
|
|
1054
|
+
/** Set total row count */
|
|
1055
|
+
setTotalRows: (count: number) => void;
|
|
1056
|
+
/** Update a single slot after row change */
|
|
1057
|
+
updateSlot: (rowIndex: number) => void;
|
|
1058
|
+
/** Refresh all slots after bulk changes */
|
|
1059
|
+
refreshAllSlots: () => void;
|
|
1060
|
+
/** Emit content size change */
|
|
1061
|
+
emitContentSize: () => void;
|
|
1062
|
+
/** Clear selection if it references invalid rows */
|
|
1063
|
+
clearSelectionIfInvalid: (maxValidRow: number) => void;
|
|
1064
|
+
}
|
|
1065
|
+
/**
|
|
1066
|
+
* Manages row CRUD operations and cache management.
|
|
1067
|
+
*/
|
|
1068
|
+
declare class RowMutationManager<TData extends Row = Row> {
|
|
1069
|
+
private options;
|
|
1070
|
+
private emitter;
|
|
1071
|
+
onInstruction: (listener: InstructionListener) => () => void;
|
|
1072
|
+
private emit;
|
|
1073
|
+
constructor(options: RowMutationManagerOptions<TData>);
|
|
1074
|
+
/**
|
|
1075
|
+
* Get a row by index.
|
|
1076
|
+
*/
|
|
1077
|
+
getRow(index: number): TData | undefined;
|
|
1078
|
+
/**
|
|
1079
|
+
* Add rows to the grid at the specified index.
|
|
1080
|
+
* If no index is provided, rows are added at the end.
|
|
1081
|
+
*/
|
|
1082
|
+
addRows(rows: TData[], index?: number): void;
|
|
1083
|
+
/**
|
|
1084
|
+
* Update existing rows with partial data.
|
|
1085
|
+
*/
|
|
1086
|
+
updateRows(updates: Array<{
|
|
1087
|
+
index: number;
|
|
1088
|
+
data: Partial<TData>;
|
|
1089
|
+
}>): void;
|
|
1090
|
+
/**
|
|
1091
|
+
* Delete rows at the specified indices.
|
|
1092
|
+
*/
|
|
1093
|
+
deleteRows(indices: number[]): void;
|
|
1094
|
+
/**
|
|
1095
|
+
* Set a complete row at the specified index.
|
|
1096
|
+
* Use this for complete row replacement. For partial updates, use updateRows.
|
|
1097
|
+
*/
|
|
1098
|
+
setRow(index: number, data: TData): void;
|
|
1099
|
+
destroy(): void;
|
|
1100
|
+
}
|
|
1101
|
+
//#endregion
|
|
705
1102
|
//#region src/grid-core.d.ts
|
|
706
1103
|
declare class GridCore<TData extends Row = Row> {
|
|
707
1104
|
private columns;
|
|
@@ -718,29 +1115,25 @@ declare class GridCore<TData extends Row = Row> {
|
|
|
718
1115
|
private totalRows;
|
|
719
1116
|
private currentPageIndex;
|
|
720
1117
|
private pageSize;
|
|
721
|
-
private sortModel;
|
|
722
|
-
private filterModel;
|
|
723
|
-
private openFilterColIndex;
|
|
724
1118
|
readonly selection: SelectionManager;
|
|
725
1119
|
readonly fill: FillManager;
|
|
726
1120
|
readonly input: InputHandler<TData>;
|
|
1121
|
+
readonly highlight: HighlightManager<TData> | null;
|
|
1122
|
+
readonly sortFilter: SortFilterManager<TData>;
|
|
1123
|
+
readonly rowMutation: RowMutationManager<TData>;
|
|
727
1124
|
private readonly slotPool;
|
|
728
1125
|
private readonly editManager;
|
|
729
1126
|
private columnPositions;
|
|
730
|
-
private
|
|
731
|
-
|
|
1127
|
+
private emitter;
|
|
1128
|
+
onInstruction: (listener: InstructionListener) => () => void;
|
|
1129
|
+
onBatchInstruction: (listener: BatchInstructionListener$1) => () => void;
|
|
1130
|
+
private emit;
|
|
1131
|
+
private emitBatch;
|
|
732
1132
|
private naturalContentHeight;
|
|
733
1133
|
private virtualContentHeight;
|
|
734
1134
|
private scrollRatio;
|
|
1135
|
+
private isDestroyed;
|
|
735
1136
|
constructor(options: GridCoreOptions<TData>);
|
|
736
|
-
onInstruction(listener: InstructionListener): () => void;
|
|
737
|
-
/**
|
|
738
|
-
* Subscribe to batched instructions for efficient React state updates.
|
|
739
|
-
* Batch listeners receive arrays of instructions instead of individual ones.
|
|
740
|
-
*/
|
|
741
|
-
onBatchInstruction(listener: BatchInstructionListener): () => void;
|
|
742
|
-
private emit;
|
|
743
|
-
private emitBatch;
|
|
744
1137
|
/**
|
|
745
1138
|
* Initialize the grid and load initial data.
|
|
746
1139
|
*/
|
|
@@ -754,37 +1147,16 @@ declare class GridCore<TData extends Row = Row> {
|
|
|
754
1147
|
private fetchAllData;
|
|
755
1148
|
setSort(colId: string, direction: SortDirection | null, addToExisting?: boolean): Promise<void>;
|
|
756
1149
|
setFilter(colId: string, filter: ColumnFilterModel | string | null): Promise<void>;
|
|
757
|
-
/**
|
|
758
|
-
* Check if a column has an active filter
|
|
759
|
-
*/
|
|
760
1150
|
hasActiveFilter(colId: string): boolean;
|
|
761
|
-
/**
|
|
762
|
-
* Check if a column is sortable
|
|
763
|
-
*/
|
|
764
1151
|
isColumnSortable(colIndex: number): boolean;
|
|
765
|
-
/**
|
|
766
|
-
* Check if a column is filterable
|
|
767
|
-
*/
|
|
768
1152
|
isColumnFilterable(colIndex: number): boolean;
|
|
769
|
-
/**
|
|
770
|
-
* Get distinct values for a column (for filter dropdowns)
|
|
771
|
-
* For array-type columns (like tags), each unique array combination is returned.
|
|
772
|
-
* Arrays are sorted internally for consistent comparison.
|
|
773
|
-
* Limited to MAX_DISTINCT_VALUES to avoid performance issues with large datasets.
|
|
774
|
-
*/
|
|
775
1153
|
getDistinctValuesForColumn(colId: string, maxValues?: number): CellValue[];
|
|
776
|
-
/**
|
|
777
|
-
* Open filter popup for a column (toggles if already open for same column)
|
|
778
|
-
*/
|
|
779
1154
|
openFilterPopup(colIndex: number, anchorRect: {
|
|
780
1155
|
top: number;
|
|
781
1156
|
left: number;
|
|
782
1157
|
width: number;
|
|
783
1158
|
height: number;
|
|
784
1159
|
}): void;
|
|
785
|
-
/**
|
|
786
|
-
* Close filter popup
|
|
787
|
-
*/
|
|
788
1160
|
closeFilterPopup(): void;
|
|
789
1161
|
getSortModel(): SortModel[];
|
|
790
1162
|
getFilterModel(): FilterModel;
|
|
@@ -795,8 +1167,6 @@ declare class GridCore<TData extends Row = Row> {
|
|
|
795
1167
|
getEditState(): EditState | null;
|
|
796
1168
|
getCellValue(row: number, col: number): CellValue;
|
|
797
1169
|
setCellValue(row: number, col: number, value: CellValue): void;
|
|
798
|
-
private getFieldValue;
|
|
799
|
-
private setFieldValue;
|
|
800
1170
|
private computeColumnPositions;
|
|
801
1171
|
private emitContentSize;
|
|
802
1172
|
private emitHeaders;
|
|
@@ -853,6 +1223,31 @@ declare class GridCore<TData extends Row = Row> {
|
|
|
853
1223
|
* Useful after in-place data modifications like fill operations.
|
|
854
1224
|
*/
|
|
855
1225
|
refreshSlotData(): void;
|
|
1226
|
+
/**
|
|
1227
|
+
* Add rows to the grid at the specified index.
|
|
1228
|
+
* If no index is provided, rows are added at the end.
|
|
1229
|
+
*/
|
|
1230
|
+
addRows(rows: TData[], index?: number): void;
|
|
1231
|
+
/**
|
|
1232
|
+
* Update existing rows with partial data.
|
|
1233
|
+
*/
|
|
1234
|
+
updateRows(updates: Array<{
|
|
1235
|
+
index: number;
|
|
1236
|
+
data: Partial<TData>;
|
|
1237
|
+
}>): void;
|
|
1238
|
+
/**
|
|
1239
|
+
* Delete rows at the specified indices.
|
|
1240
|
+
*/
|
|
1241
|
+
deleteRows(indices: number[]): void;
|
|
1242
|
+
/**
|
|
1243
|
+
* Get a row by index.
|
|
1244
|
+
*/
|
|
1245
|
+
getRow(index: number): TData | undefined;
|
|
1246
|
+
/**
|
|
1247
|
+
* Set a complete row at the specified index.
|
|
1248
|
+
* Use this for complete row replacement. For partial updates, use updateRows.
|
|
1249
|
+
*/
|
|
1250
|
+
setRow(index: number, data: TData): void;
|
|
856
1251
|
/**
|
|
857
1252
|
* Update the data source and refresh.
|
|
858
1253
|
*/
|
|
@@ -861,6 +1256,12 @@ declare class GridCore<TData extends Row = Row> {
|
|
|
861
1256
|
* Update columns and recompute layout.
|
|
862
1257
|
*/
|
|
863
1258
|
setColumns(columns: ColumnDefinition[]): void;
|
|
1259
|
+
/**
|
|
1260
|
+
* Destroy the grid core and release all references.
|
|
1261
|
+
* Call this before discarding the GridCore to ensure proper cleanup.
|
|
1262
|
+
* This method is idempotent - safe to call multiple times.
|
|
1263
|
+
*/
|
|
1264
|
+
destroy(): void;
|
|
864
1265
|
}
|
|
865
1266
|
//#endregion
|
|
866
1267
|
//#region src/slot-pool.d.ts
|
|
@@ -888,21 +1289,16 @@ interface SlotPoolManagerOptions {
|
|
|
888
1289
|
* Manages the slot pool for virtual scrolling.
|
|
889
1290
|
* Handles slot creation, recycling, positioning, and destruction.
|
|
890
1291
|
*/
|
|
891
|
-
/** Batch instruction listener for efficient React state updates */
|
|
892
|
-
type BatchInstructionListener$1 = (instructions: GridInstruction[]) => void;
|
|
893
1292
|
declare class SlotPoolManager {
|
|
894
1293
|
private state;
|
|
895
1294
|
private options;
|
|
896
|
-
private
|
|
897
|
-
private
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* Subscribe to batched instructions for efficient state updates.
|
|
902
|
-
*/
|
|
903
|
-
onBatchInstruction(listener: BatchInstructionListener$1): () => void;
|
|
1295
|
+
private emitter;
|
|
1296
|
+
private isDestroyed;
|
|
1297
|
+
onInstruction: (listener: InstructionListener) => () => void;
|
|
1298
|
+
onBatchInstruction: (listener: BatchInstructionListener$1) => () => void;
|
|
904
1299
|
private emit;
|
|
905
1300
|
private emitBatch;
|
|
1301
|
+
constructor(options: SlotPoolManagerOptions);
|
|
906
1302
|
/**
|
|
907
1303
|
* Get the slot ID for a given row index.
|
|
908
1304
|
*/
|
|
@@ -922,6 +1318,7 @@ declare class SlotPoolManager {
|
|
|
922
1318
|
destroyAllSlots(): void;
|
|
923
1319
|
/**
|
|
924
1320
|
* Clean up resources for garbage collection.
|
|
1321
|
+
* This method is idempotent - safe to call multiple times.
|
|
925
1322
|
*/
|
|
926
1323
|
destroy(): void;
|
|
927
1324
|
/**
|
|
@@ -957,10 +1354,10 @@ interface EditManagerOptions {
|
|
|
957
1354
|
declare class EditManager {
|
|
958
1355
|
private editState;
|
|
959
1356
|
private options;
|
|
960
|
-
private
|
|
961
|
-
|
|
962
|
-
onInstruction(listener: InstructionListener): () => void;
|
|
1357
|
+
private emitter;
|
|
1358
|
+
onInstruction: (listener: InstructionListener) => () => void;
|
|
963
1359
|
private emit;
|
|
1360
|
+
constructor(options: EditManagerOptions);
|
|
964
1361
|
/**
|
|
965
1362
|
* Get the current edit state.
|
|
966
1363
|
*/
|
|
@@ -998,12 +1395,206 @@ declare class EditManager {
|
|
|
998
1395
|
destroy(): void;
|
|
999
1396
|
}
|
|
1000
1397
|
//#endregion
|
|
1398
|
+
//#region src/sorting/parallel-sort-manager.d.ts
|
|
1399
|
+
interface ParallelSortOptions {
|
|
1400
|
+
/** Maximum number of workers (default: navigator.hardwareConcurrency || 4) */
|
|
1401
|
+
maxWorkers?: number;
|
|
1402
|
+
/** Threshold for parallel sorting (default: 400000) */
|
|
1403
|
+
parallelThreshold?: number;
|
|
1404
|
+
/** Minimum chunk size (default: 50000) */
|
|
1405
|
+
minChunkSize?: number;
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Manages parallel sorting operations using a worker pool.
|
|
1409
|
+
* Automatically decides between single-worker and parallel sorting based on data size.
|
|
1410
|
+
*/
|
|
1411
|
+
declare class ParallelSortManager {
|
|
1412
|
+
private pool;
|
|
1413
|
+
private parallelThreshold;
|
|
1414
|
+
private minChunkSize;
|
|
1415
|
+
private isTerminated;
|
|
1416
|
+
constructor(options?: ParallelSortOptions);
|
|
1417
|
+
/**
|
|
1418
|
+
* Check if the manager is available for use.
|
|
1419
|
+
*/
|
|
1420
|
+
isAvailable(): boolean;
|
|
1421
|
+
/**
|
|
1422
|
+
* Terminate all workers and clean up resources.
|
|
1423
|
+
*/
|
|
1424
|
+
terminate(): void;
|
|
1425
|
+
/**
|
|
1426
|
+
* Sort indices using values array.
|
|
1427
|
+
* Automatically uses parallel sorting for large datasets.
|
|
1428
|
+
*/
|
|
1429
|
+
sortIndices(values: number[], direction: SortDirection): Promise<Uint32Array>;
|
|
1430
|
+
/**
|
|
1431
|
+
* Sort string hashes with collision detection.
|
|
1432
|
+
* Automatically uses parallel sorting for large datasets.
|
|
1433
|
+
*/
|
|
1434
|
+
sortStringHashes(hashChunks: Float64Array[], direction: SortDirection, originalStrings: string[]): Promise<Uint32Array>;
|
|
1435
|
+
/**
|
|
1436
|
+
* Multi-column sort.
|
|
1437
|
+
* Automatically uses parallel sorting for large datasets.
|
|
1438
|
+
*/
|
|
1439
|
+
sortMultiColumn(columns: number[][], directions: SortDirection[]): Promise<Uint32Array>;
|
|
1440
|
+
private sortIndicesSingle;
|
|
1441
|
+
private sortStringHashesSingle;
|
|
1442
|
+
private sortMultiColumnSingle;
|
|
1443
|
+
private sortIndicesParallel;
|
|
1444
|
+
private sortStringHashesParallel;
|
|
1445
|
+
private sortMultiColumnParallel;
|
|
1446
|
+
/**
|
|
1447
|
+
* Split data into chunks for parallel processing.
|
|
1448
|
+
*/
|
|
1449
|
+
private splitIntoChunks;
|
|
1450
|
+
/**
|
|
1451
|
+
* Calculate chunk boundaries without copying data.
|
|
1452
|
+
*/
|
|
1453
|
+
private calculateChunkBoundaries;
|
|
1454
|
+
/**
|
|
1455
|
+
* Detect collisions at chunk boundaries for string sorting.
|
|
1456
|
+
*/
|
|
1457
|
+
private detectBoundaryCollisionsForStrings;
|
|
1458
|
+
/**
|
|
1459
|
+
* Resolve hash collisions using localeCompare.
|
|
1460
|
+
*/
|
|
1461
|
+
private resolveCollisions;
|
|
1462
|
+
}
|
|
1463
|
+
//#endregion
|
|
1464
|
+
//#region src/sorting/worker-pool.d.ts
|
|
1465
|
+
interface WorkerPoolOptions {
|
|
1466
|
+
/** Maximum number of workers (default: navigator.hardwareConcurrency ?? 4) */
|
|
1467
|
+
maxWorkers?: number;
|
|
1468
|
+
/** Whether to pre-warm workers on initialization */
|
|
1469
|
+
preWarm?: boolean;
|
|
1470
|
+
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Manages a pool of Web Workers for parallel task execution.
|
|
1473
|
+
* Workers are created lazily and reused across operations.
|
|
1474
|
+
*/
|
|
1475
|
+
declare class WorkerPool {
|
|
1476
|
+
private workerCode;
|
|
1477
|
+
private maxWorkers;
|
|
1478
|
+
private workers;
|
|
1479
|
+
private workerUrl;
|
|
1480
|
+
private nextRequestId;
|
|
1481
|
+
private isTerminated;
|
|
1482
|
+
constructor(workerCode: string, options?: WorkerPoolOptions);
|
|
1483
|
+
/**
|
|
1484
|
+
* Get the current pool size (number of active workers).
|
|
1485
|
+
*/
|
|
1486
|
+
getPoolSize(): number;
|
|
1487
|
+
/**
|
|
1488
|
+
* Get the maximum pool size.
|
|
1489
|
+
*/
|
|
1490
|
+
getMaxWorkers(): number;
|
|
1491
|
+
/**
|
|
1492
|
+
* Check if the pool is available for use.
|
|
1493
|
+
*/
|
|
1494
|
+
isAvailable(): boolean;
|
|
1495
|
+
/**
|
|
1496
|
+
* Execute a single task on an available worker.
|
|
1497
|
+
* Returns the worker's response.
|
|
1498
|
+
*/
|
|
1499
|
+
execute<TRequest extends {
|
|
1500
|
+
id?: number;
|
|
1501
|
+
}, TResponse>(request: TRequest, transferables?: Transferable[]): Promise<TResponse>;
|
|
1502
|
+
/**
|
|
1503
|
+
* Execute multiple tasks in parallel across available workers.
|
|
1504
|
+
* Each task is assigned to a different worker if possible.
|
|
1505
|
+
* Returns results in the same order as the input requests.
|
|
1506
|
+
*/
|
|
1507
|
+
executeParallel<TRequest extends {
|
|
1508
|
+
id?: number;
|
|
1509
|
+
}, TResponse>(tasks: Array<{
|
|
1510
|
+
request: TRequest;
|
|
1511
|
+
transferables?: Transferable[];
|
|
1512
|
+
}>): Promise<TResponse[]>;
|
|
1513
|
+
/**
|
|
1514
|
+
* Terminate all workers and clean up resources.
|
|
1515
|
+
*/
|
|
1516
|
+
terminate(): void;
|
|
1517
|
+
/**
|
|
1518
|
+
* Pre-warm workers by creating them ahead of time.
|
|
1519
|
+
*/
|
|
1520
|
+
private preWarmWorkers;
|
|
1521
|
+
/**
|
|
1522
|
+
* Ensure at least `count` workers exist in the pool.
|
|
1523
|
+
*/
|
|
1524
|
+
private ensureWorkers;
|
|
1525
|
+
/**
|
|
1526
|
+
* Get an available worker, creating one if needed.
|
|
1527
|
+
*/
|
|
1528
|
+
private getAvailableWorker;
|
|
1529
|
+
/**
|
|
1530
|
+
* Create a new worker and add it to the pool.
|
|
1531
|
+
*/
|
|
1532
|
+
private createWorker;
|
|
1533
|
+
/**
|
|
1534
|
+
* Respawn a failed worker.
|
|
1535
|
+
*/
|
|
1536
|
+
private respawnWorker;
|
|
1537
|
+
}
|
|
1538
|
+
//#endregion
|
|
1539
|
+
//#region src/sorting/k-way-merge.d.ts
|
|
1540
|
+
/**
|
|
1541
|
+
* Represents a sorted chunk with its values and offset in the original array.
|
|
1542
|
+
*/
|
|
1543
|
+
interface SortedChunk {
|
|
1544
|
+
/** Sorted indices (local to this chunk) */
|
|
1545
|
+
indices: Uint32Array;
|
|
1546
|
+
/** Values for comparison (in same order as indices) */
|
|
1547
|
+
values: Float64Array;
|
|
1548
|
+
/** Offset of this chunk in the original array */
|
|
1549
|
+
offset: number;
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* Represents a sorted chunk for multi-column sorting.
|
|
1553
|
+
*/
|
|
1554
|
+
interface MultiColumnSortedChunk {
|
|
1555
|
+
/** Sorted indices (local to this chunk) */
|
|
1556
|
+
indices: Uint32Array;
|
|
1557
|
+
/** Values for comparison - array of columns, each in same order as indices */
|
|
1558
|
+
columns: Float64Array[];
|
|
1559
|
+
/** Sort directions for each column (1 = asc, -1 = desc) */
|
|
1560
|
+
directions: Int8Array;
|
|
1561
|
+
/** Offset of this chunk in the original array */
|
|
1562
|
+
offset: number;
|
|
1563
|
+
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Merge multiple sorted chunks into a single sorted result.
|
|
1566
|
+
* Uses a min-heap for O(n log k) time complexity.
|
|
1567
|
+
*
|
|
1568
|
+
* @param chunks - Array of sorted chunks to merge
|
|
1569
|
+
* @param direction - Sort direction ('asc' or 'desc')
|
|
1570
|
+
* @returns Uint32Array of globally sorted indices
|
|
1571
|
+
*/
|
|
1572
|
+
declare function kWayMerge(chunks: SortedChunk[], direction: SortDirection): Uint32Array;
|
|
1573
|
+
/**
|
|
1574
|
+
* Merge multiple sorted chunks for multi-column sorting.
|
|
1575
|
+
*
|
|
1576
|
+
* @param chunks - Array of multi-column sorted chunks
|
|
1577
|
+
* @returns Uint32Array of globally sorted indices
|
|
1578
|
+
*/
|
|
1579
|
+
declare function kWayMergeMultiColumn(chunks: MultiColumnSortedChunk[]): Uint32Array;
|
|
1580
|
+
/**
|
|
1581
|
+
* Detect collision runs at chunk boundaries after merge.
|
|
1582
|
+
* This is used for string sorting where hashes may collide across chunks.
|
|
1583
|
+
*
|
|
1584
|
+
* @param chunks - Original sorted chunks with their hash values
|
|
1585
|
+
* @param _direction - Sort direction
|
|
1586
|
+
* @returns Array of boundary collision positions [start1, end1, start2, end2, ...]
|
|
1587
|
+
*/
|
|
1588
|
+
declare function detectBoundaryCollisions(chunks: SortedChunk[], _direction: SortDirection): Uint32Array;
|
|
1589
|
+
//#endregion
|
|
1001
1590
|
//#region src/data-source/client-data-source.d.ts
|
|
1002
1591
|
interface ClientDataSourceOptions<TData> {
|
|
1003
1592
|
/** Custom field accessor for nested properties */
|
|
1004
1593
|
getFieldValue?: (row: TData, field: string) => CellValue;
|
|
1005
1594
|
/** Use Web Worker for sorting large datasets (default: true) */
|
|
1006
1595
|
useWorker?: boolean;
|
|
1596
|
+
/** Options for parallel sorting (only used when useWorker is true) */
|
|
1597
|
+
parallelSort?: ParallelSortOptions | false;
|
|
1007
1598
|
}
|
|
1008
1599
|
/**
|
|
1009
1600
|
* Creates a client-side data source that holds all data in memory.
|
|
@@ -1380,73 +1971,6 @@ interface MutableClientDataSourceOptions<TData> {
|
|
|
1380
1971
|
*/
|
|
1381
1972
|
declare function createMutableClientDataSource<TData extends Row = Row>(data: TData[], options: MutableClientDataSourceOptions<TData>): MutableDataSource<TData>;
|
|
1382
1973
|
//#endregion
|
|
1383
|
-
//#region src/worker-manager.d.ts
|
|
1384
|
-
/**
|
|
1385
|
-
* Manages a Web Worker for sorting large datasets off the main thread.
|
|
1386
|
-
* Uses an inline worker (Blob URL) for maximum compatibility across bundlers.
|
|
1387
|
-
*/
|
|
1388
|
-
declare class SortWorkerManager {
|
|
1389
|
-
private worker;
|
|
1390
|
-
private workerUrl;
|
|
1391
|
-
private pendingRequests;
|
|
1392
|
-
private nextRequestId;
|
|
1393
|
-
private isTerminated;
|
|
1394
|
-
/**
|
|
1395
|
-
* Sort data using a Web Worker.
|
|
1396
|
-
* The worker is lazily initialized on first use.
|
|
1397
|
-
*/
|
|
1398
|
-
sortInWorker<T>(data: T[], sortModel: SortModel[]): Promise<T[]>;
|
|
1399
|
-
/**
|
|
1400
|
-
* Sort indices using a Web Worker with Transferable typed arrays.
|
|
1401
|
-
* This is much faster than sortInWorker for large datasets because
|
|
1402
|
-
* it avoids the serialization overhead of transferring full objects.
|
|
1403
|
-
*/
|
|
1404
|
-
sortIndices(values: number[], direction: SortDirection): Promise<Uint32Array>;
|
|
1405
|
-
/**
|
|
1406
|
-
* Sort by multiple columns using a Web Worker with Transferable typed arrays.
|
|
1407
|
-
* Each column's values are passed as a Float64Array, enabling fast multi-column sorting.
|
|
1408
|
-
* @param columns Array of column values (each as number[])
|
|
1409
|
-
* @param directions Array of directions for each column ("asc" or "desc")
|
|
1410
|
-
*/
|
|
1411
|
-
sortMultiColumn(columns: number[][], directions: SortDirection[]): Promise<Uint32Array>;
|
|
1412
|
-
/**
|
|
1413
|
-
* Sort string values using multiple hash chunks with collision detection.
|
|
1414
|
-
* Returns sorted indices and handles hash collisions using localeCompare fallback.
|
|
1415
|
-
* @param hashChunks Array of hash chunk arrays (one per chunk, each chunk as Float64Array)
|
|
1416
|
-
* @param direction Sort direction ("asc" or "desc")
|
|
1417
|
-
* @param originalStrings Original string values for collision fallback
|
|
1418
|
-
*/
|
|
1419
|
-
sortStringHashes(hashChunks: Float64Array[], direction: SortDirection, originalStrings: string[]): Promise<Uint32Array>;
|
|
1420
|
-
/**
|
|
1421
|
-
* Resolve hash collisions by re-sorting collision runs using localeCompare.
|
|
1422
|
-
* collisionRuns format: [start1, end1, start2, end2, ...] where each pair
|
|
1423
|
-
* defines a run of indices in the sorted array with identical hashes.
|
|
1424
|
-
*/
|
|
1425
|
-
private resolveCollisions;
|
|
1426
|
-
/**
|
|
1427
|
-
* Initialize the worker using an inline Blob URL.
|
|
1428
|
-
* This works without bundler-specific configuration.
|
|
1429
|
-
*/
|
|
1430
|
-
private initializeWorker;
|
|
1431
|
-
/**
|
|
1432
|
-
* Terminate the worker and clean up resources.
|
|
1433
|
-
*/
|
|
1434
|
-
terminate(): void;
|
|
1435
|
-
/**
|
|
1436
|
-
* Check if the worker is currently available.
|
|
1437
|
-
*/
|
|
1438
|
-
isAvailable(): boolean;
|
|
1439
|
-
}
|
|
1440
|
-
/**
|
|
1441
|
-
* Get a shared SortWorkerManager instance.
|
|
1442
|
-
* Useful when multiple data sources should share the same worker.
|
|
1443
|
-
*/
|
|
1444
|
-
declare function getSharedSortWorker(): SortWorkerManager;
|
|
1445
|
-
/**
|
|
1446
|
-
* Terminate the shared worker and release resources.
|
|
1447
|
-
*/
|
|
1448
|
-
declare function terminateSharedSortWorker(): void;
|
|
1449
|
-
//#endregion
|
|
1450
1974
|
//#region src/styles/variables.d.ts
|
|
1451
1975
|
declare const variablesStyles: string;
|
|
1452
1976
|
//#endregion
|
|
@@ -1480,79 +2004,11 @@ declare const gridStyles: string;
|
|
|
1480
2004
|
*/
|
|
1481
2005
|
declare function injectStyles(): void;
|
|
1482
2006
|
//#endregion
|
|
1483
|
-
//#region src/utils/positioning.d.ts
|
|
1484
|
-
/**
|
|
1485
|
-
* Calculate cumulative column positions (prefix sums)
|
|
1486
|
-
* Returns an array where positions[i] is the left position of column i
|
|
1487
|
-
* positions[columns.length] is the total width
|
|
1488
|
-
*/
|
|
1489
|
-
declare function calculateColumnPositions(columns: ColumnDefinition[]): number[];
|
|
1490
|
-
/**
|
|
1491
|
-
* Get total width from column positions
|
|
1492
|
-
*/
|
|
1493
|
-
declare function getTotalWidth(columnPositions: number[]): number;
|
|
1494
|
-
/**
|
|
1495
|
-
* Calculate scaled column positions when container is wider than total column widths.
|
|
1496
|
-
* Columns expand proportionally based on their original width ratios.
|
|
1497
|
-
*
|
|
1498
|
-
* @param columns - Column definitions with original widths
|
|
1499
|
-
* @param containerWidth - Available container width
|
|
1500
|
-
* @returns Object with positions array and widths array
|
|
1501
|
-
*/
|
|
1502
|
-
declare function calculateScaledColumnPositions(columns: ColumnDefinition[], containerWidth: number): {
|
|
1503
|
-
positions: number[];
|
|
1504
|
-
widths: number[];
|
|
1505
|
-
};
|
|
1506
|
-
/**
|
|
1507
|
-
* Find column index at a given X coordinate
|
|
1508
|
-
*/
|
|
1509
|
-
declare function findColumnAtX(x: number, columnPositions: number[]): number;
|
|
1510
|
-
//#endregion
|
|
1511
|
-
//#region src/utils/classNames.d.ts
|
|
1512
|
-
/**
|
|
1513
|
-
* Check if a cell is within the selection range
|
|
1514
|
-
*/
|
|
1515
|
-
declare function isCellSelected(row: number, col: number, selectionRange: CellRange | null): boolean;
|
|
1516
|
-
/**
|
|
1517
|
-
* Check if a cell is the active cell
|
|
1518
|
-
*/
|
|
1519
|
-
declare function isCellActive(row: number, col: number, activeCell: CellPosition | null): boolean;
|
|
1520
|
-
/**
|
|
1521
|
-
* Check if a row is within the visible range (not in overscan)
|
|
1522
|
-
*/
|
|
1523
|
-
declare function isRowVisible(row: number, visibleRowRange: {
|
|
1524
|
-
start: number;
|
|
1525
|
-
end: number;
|
|
1526
|
-
} | null): boolean;
|
|
1527
|
-
/**
|
|
1528
|
-
* Check if a cell is being edited
|
|
1529
|
-
*/
|
|
1530
|
-
declare function isCellEditing(row: number, col: number, editingCell: {
|
|
1531
|
-
row: number;
|
|
1532
|
-
col: number;
|
|
1533
|
-
} | null): boolean;
|
|
1534
|
-
/**
|
|
1535
|
-
* Check if a cell is in the fill preview range (vertical-only fill)
|
|
1536
|
-
*/
|
|
1537
|
-
declare function isCellInFillPreview(row: number, col: number, isDraggingFill: boolean, fillSourceRange: {
|
|
1538
|
-
startRow: number;
|
|
1539
|
-
startCol: number;
|
|
1540
|
-
endRow: number;
|
|
1541
|
-
endCol: number;
|
|
1542
|
-
} | null, fillTarget: {
|
|
1543
|
-
row: number;
|
|
1544
|
-
col: number;
|
|
1545
|
-
} | null): boolean;
|
|
1546
|
-
/**
|
|
1547
|
-
* Build cell CSS classes based on state
|
|
1548
|
-
*/
|
|
1549
|
-
declare function buildCellClasses(isActive: boolean, isSelected: boolean, isEditing: boolean, inFillPreview: boolean): string;
|
|
1550
|
-
//#endregion
|
|
1551
2007
|
//#region src/types/ui-state.d.ts
|
|
1552
|
-
interface SlotData {
|
|
2008
|
+
interface SlotData<TData = Row> {
|
|
1553
2009
|
slotId: string;
|
|
1554
2010
|
rowIndex: number;
|
|
1555
|
-
rowData:
|
|
2011
|
+
rowData: TData;
|
|
1556
2012
|
translateY: number;
|
|
1557
2013
|
}
|
|
1558
2014
|
interface HeaderData {
|
|
@@ -1576,8 +2032,8 @@ interface FilterPopupState {
|
|
|
1576
2032
|
distinctValues: CellValue[];
|
|
1577
2033
|
currentFilter?: ColumnFilterModel;
|
|
1578
2034
|
}
|
|
1579
|
-
interface GridState {
|
|
1580
|
-
slots: Map<string, SlotData
|
|
2035
|
+
interface GridState<TData = Row> {
|
|
2036
|
+
slots: Map<string, SlotData<TData>>;
|
|
1581
2037
|
activeCell: CellPosition | null;
|
|
1582
2038
|
selectionRange: CellRange | null;
|
|
1583
2039
|
editingCell: {
|
|
@@ -1599,6 +2055,8 @@ interface GridState {
|
|
|
1599
2055
|
start: number;
|
|
1600
2056
|
end: number;
|
|
1601
2057
|
} | null;
|
|
2058
|
+
/** Currently hovered cell position (for highlighting) */
|
|
2059
|
+
hoverPosition: CellPosition | null;
|
|
1602
2060
|
}
|
|
1603
2061
|
//#endregion
|
|
1604
|
-
export { type AssignSlotInstruction, type BatchInstructionListener, type CancelFillInstruction, type CellDataType, type CellPosition, type CellRange, type CellRendererParams, type CellValue, type CloseFilterPopupInstruction, type ColumnDefinition, type ColumnFilterModel, type CommitEditInstruction, type CommitFillInstruction, type ContainerBounds, type CreateSlotInstruction, type DataChangeListener, type DataErrorInstruction, type DataLoadedInstruction, type DataLoadingInstruction, type DataSource, type DataSourceRequest, type DataSourceResponse, type DateFilterCondition, type DateFilterOperator, type DestroySlotInstruction, type Direction, type DragMoveResult, type DragState, EditManager, type EditManagerOptions, type EditRendererParams, type EditState, type FillHandleState, FillManager, type FilterCombination, type FilterCondition, type FilterModel, type FilterPopupState, GridCore, type GridCoreOptions, type GridInstruction, type GridState, type HeaderData, type HeaderRendererParams, IndexedDataStore, type IndexedDataStoreOptions, InputHandler, type InputHandlerDeps, type InputResult, type InstructionListener, type KeyEventData, type KeyboardResult, type MoveSlotInstruction, type MutableClientDataSourceOptions, type MutableDataSource, type NumberFilterCondition, type NumberFilterOperator, type OpenFilterPopupInstruction, type PointerEventData, type Row, type RowId, type RowSortCache, type RowsAddedInstruction, type RowsRemovedInstruction, type RowsUpdatedInstruction, SelectionManager, type SelectionState, type SetActiveCellInstruction, type SetContentSizeInstruction, type SetSelectionRangeInstruction, type SlotData, type BatchInstructionListener$1 as SlotPoolBatchListener, SlotPoolManager, type SlotPoolManagerOptions, type SlotState, type SortDirection, type SortModel,
|
|
2062
|
+
export { type AssignSlotInstruction, type BatchInstructionListener, type CancelFillInstruction, type CellDataType, type CellPosition, type CellRange, type CellRendererParams, type CellValue, type CloseFilterPopupInstruction, type ColumnDefinition, type ColumnFilterModel, type CommitEditInstruction, type CommitFillInstruction, type ContainerBounds, type CreateSlotInstruction, type DataChangeListener, type DataErrorInstruction, type DataLoadedInstruction, type DataLoadingInstruction, type DataSource, type DataSourceRequest, type DataSourceResponse, type DateFilterCondition, type DateFilterOperator, type DestroySlotInstruction, type Direction, type DragMoveResult, type DragState, EditManager, type EditManagerOptions, type EditRendererParams, type EditState, type FillHandleState, FillManager, type FilterCombination, type FilterCondition, type FilterModel, type FilterPopupState, GridCore, type GridCoreOptions, type GridInstruction, type GridState, type HeaderData, type HeaderRendererParams, type HighlightContext, HighlightManager, type HighlightingOptions, IndexedDataStore, type IndexedDataStoreOptions, InputHandler, type InputHandlerDeps, type InputResult, type InstructionListener, type KeyEventData, type KeyboardResult, type MoveSlotInstruction, type MultiColumnSortedChunk, type MutableClientDataSourceOptions, type MutableDataSource, type NumberFilterCondition, type NumberFilterOperator, type OpenFilterPopupInstruction, ParallelSortManager, type ParallelSortOptions, type PointerEventData, type Row, type RowId, type RowSortCache, type RowsAddedInstruction, type RowsRemovedInstruction, type RowsUpdatedInstruction, SelectionManager, type SelectionState, type SetActiveCellInstruction, type SetContentSizeInstruction, type SetHoverPositionInstruction, type SetSelectionRangeInstruction, type SlotData, type BatchInstructionListener$1 as SlotPoolBatchListener, SlotPoolManager, type SlotPoolManagerOptions, type SlotState, type SortDirection, type SortModel, type SortedChunk, type StartEditInstruction, type StartFillInstruction, type StopEditInstruction, type TextFilterCondition, type TextFilterOperator, type Transaction, TransactionManager, type TransactionManagerOptions, type TransactionProcessedInstruction, type TransactionResult, type UpdateFillInstruction, type UpdateHeaderInstruction, WorkerPool, type WorkerPoolOptions, buildCellClasses, calculateColumnPositions, calculateScaledColumnPositions, cellStyles, compareValues, computeValueHash, containerStyles, createClientDataSource, createDataSourceFromArray, createMutableClientDataSource, createServerDataSource, detectBoundaryCollisions, evaluateColumnFilter, evaluateDateCondition, evaluateNumberCondition, evaluateTextCondition, filtersStyles, findColumnAtX, getFieldValue, getTotalWidth, gridStyles, headerStyles, injectStyles, isCellActive, isCellEditing, isCellInFillPreview, isCellSelected, isColumnInSelectionRange, isRowInSelectionRange, isRowVisible, isSameDay, kWayMerge, kWayMergeMultiColumn, rowPassesFilter, scrollbarStyles, setFieldValue, statesStyles, stringToSortableNumber, variablesStyles };
|