@gp-grid/core 0.7.2 → 0.8.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 CHANGED
@@ -1,4 +1,4 @@
1
- # gp-grid-core 🏁 🏎️
1
+ # @gp-grid/core 🏁 🏎️
2
2
 
3
3
  <div align="center">
4
4
  <a href="https://www.gp-grid.io">
@@ -31,12 +31,12 @@ A framework-agnostic TypeScript library for building high-performance data grids
31
31
 
32
32
  ## Available implementations
33
33
 
34
- - [**gp-grid-react**](https://www.npmjs.com/package/gp-grid-react) | Official
35
- - [**gp-grid-vue**](https://www.npmjs.com/package/gp-grid-vue) | Official
34
+ - [**@gp-grid/react**](https://www.npmjs.com/package/@gp-grid/react) | Official
35
+ - [**@gp-grid/vue**](https://www.npmjs.com/package/@gp-grid/vue) | Official
36
36
 
37
37
  ## Philosophy
38
38
 
39
- **gp-grid-core** is built on three core principles:
39
+ **@gp-grid/core** is built on three core principles:
40
40
 
41
41
  ### 1. Slot-Based Virtual Scrolling
42
42
 
@@ -66,7 +66,7 @@ Data fetching is abstracted through a `DataSource` interface, supporting both:
66
66
  npm/pnpm/yarn
67
67
 
68
68
  ```bash
69
- pnpm add gp-grid-core
69
+ pnpm add @gp-grid/core
70
70
  ```
71
71
 
72
72
  ## Architecture Overview
@@ -81,7 +81,7 @@ The main orchestrator class that manages:
81
81
  - Sort and filter state
82
82
 
83
83
  ```typescript
84
- import { GridCore, createClientDataSource } from "gp-grid-core";
84
+ import { GridCore, createClientDataSource } from "@gp-grid/core";
85
85
 
86
86
  const dataSource = createClientDataSource(myData);
87
87
 
@@ -150,7 +150,7 @@ The core emits these instruction types:
150
150
  For datasets that can be loaded entirely in memory. Sorting and filtering are performed client-side.
151
151
 
152
152
  ```typescript
153
- import { createClientDataSource } from "gp-grid-core";
153
+ import { createClientDataSource } from "@gp-grid/core";
154
154
 
155
155
  interface Person {
156
156
  id: number;
@@ -191,7 +191,7 @@ import {
191
191
  createServerDataSource,
192
192
  DataSourceRequest,
193
193
  DataSourceResponse,
194
- } from "gp-grid-core";
194
+ } from "@gp-grid/core";
195
195
 
196
196
  interface Person {
197
197
  id: number;
@@ -310,7 +310,7 @@ interface HeaderRendererParams {
310
310
 
311
311
  ## Creating a Framework Adapter
312
312
 
313
- To integrate gp-grid-core with any UI framework:
313
+ To integrate @gp-grid/core with any UI framework:
314
314
 
315
315
  1. **Subscribe to instructions** using `onBatchInstruction()`
316
316
  2. **Maintain UI state** by processing instructions
@@ -320,7 +320,7 @@ To integrate gp-grid-core with any UI framework:
320
320
  ### Example: Minimal Adapter Pattern
321
321
 
322
322
  ```typescript
323
- import { GridCore, GridInstruction } from "gp-grid-core";
323
+ import { GridCore, GridInstruction } from "@gp-grid/core";
324
324
 
325
325
  class MyGridAdapter {
326
326
  private core: GridCore;
package/dist/index.d.ts CHANGED
@@ -57,6 +57,21 @@ interface FillHandleState {
57
57
  /** Target column */
58
58
  targetCol: number;
59
59
  }
60
+ /** Event emitted when a cell value is changed via editing or fill drag */
61
+ interface CellValueChangedEvent<TData = Row> {
62
+ /** Stable row ID (from getRowId) */
63
+ rowId: RowId;
64
+ /** Column index */
65
+ colIndex: number;
66
+ /** Column field name */
67
+ field: string;
68
+ /** Previous cell value */
69
+ oldValue: CellValue;
70
+ /** New cell value */
71
+ newValue: CellValue;
72
+ /** The full row data object */
73
+ rowData: TData;
74
+ }
60
75
  /** The slot is the virtualized row, this represents the state of the slot */
61
76
  interface SlotState {
62
77
  /** Slot ID */
@@ -514,6 +529,8 @@ interface GridCoreOptions<TData = Row> {
514
529
  getRowId?: (row: TData) => RowId;
515
530
  /** Row/column/cell highlighting configuration */
516
531
  highlighting?: HighlightingOptions<TData>;
532
+ /** Called when a cell value is changed via editing or fill drag. Requires getRowId. */
533
+ onCellValueChanged?: (event: CellValueChangedEvent<TData>) => void;
517
534
  }
518
535
  //#endregion
519
536
  //#region src/types/input.d.ts
@@ -1111,6 +1128,8 @@ declare class GridCore<TData extends Row = Row> {
1111
1128
  private headerHeight;
1112
1129
  private overscan;
1113
1130
  private sortingEnabled;
1131
+ private getRowId?;
1132
+ private onCellValueChanged?;
1114
1133
  private scrollTop;
1115
1134
  private scrollLeft;
1116
1135
  private viewportWidth;
@@ -1137,6 +1156,7 @@ declare class GridCore<TData extends Row = Row> {
1137
1156
  private virtualContentHeight;
1138
1157
  private scrollRatio;
1139
1158
  private isDestroyed;
1159
+ private _isDataLoading;
1140
1160
  constructor(options: GridCoreOptions<TData>);
1141
1161
  /**
1142
1162
  * Initialize the grid and load initial data.
@@ -1171,6 +1191,7 @@ declare class GridCore<TData extends Row = Row> {
1171
1191
  getEditState(): EditState | null;
1172
1192
  getCellValue(row: number, col: number): CellValue;
1173
1193
  setCellValue(row: number, col: number, value: CellValue): void;
1194
+ private clearSelectionIfInvalid;
1174
1195
  private computeColumnPositions;
1175
1196
  private emitContentSize;
1176
1197
  private emitHeaders;
@@ -1222,6 +1243,12 @@ declare class GridCore<TData extends Row = Row> {
1222
1243
  * Refresh data from the data source.
1223
1244
  */
1224
1245
  refresh(): Promise<void>;
1246
+ /**
1247
+ * Fast-path refresh for transaction-based mutations.
1248
+ * Only re-fetches the visible window instead of all rows.
1249
+ * Use this when data was mutated via MutableDataSource transactions.
1250
+ */
1251
+ refreshFromTransaction(): Promise<void>;
1225
1252
  /**
1226
1253
  * Refresh slot display without refetching data.
1227
1254
  * Useful after in-place data modifications like fill operations.
@@ -1254,6 +1281,8 @@ declare class GridCore<TData extends Row = Row> {
1254
1281
  setRow(index: number, data: TData): void;
1255
1282
  /**
1256
1283
  * Update the data source and refresh.
1284
+ * Preserves grid state (sort, filter, scroll position).
1285
+ * Cancels any active edit and clamps selection to valid range.
1257
1286
  */
1258
1287
  setDataSource(dataSource: DataSource<TData>): Promise<void>;
1259
1288
  /**
@@ -1678,6 +1707,11 @@ declare class IndexedDataStore<TData extends Row = Row> {
1678
1707
  * Get total row count (unfiltered).
1679
1708
  */
1680
1709
  getTotalRowCount(): number;
1710
+ /**
1711
+ * Get all rows as a new array.
1712
+ * Used for direct data access when bypassing store's query system.
1713
+ */
1714
+ getAllRows(): TData[];
1681
1715
  /**
1682
1716
  * Get visible row count (after filtering).
1683
1717
  */
@@ -1968,10 +2002,15 @@ interface MutableClientDataSourceOptions<TData> {
1968
2002
  debounceMs?: number;
1969
2003
  /** Callback when transactions are processed. */
1970
2004
  onTransactionProcessed?: (result: TransactionResult) => void;
2005
+ /** Use Web Worker for sorting large datasets (default: true) */
2006
+ useWorker?: boolean;
2007
+ /** Options for parallel sorting (only used when useWorker is true) */
2008
+ parallelSort?: ParallelSortOptions | false;
1971
2009
  }
1972
2010
  /**
1973
2011
  * Creates a mutable client-side data source with transaction support.
1974
2012
  * Uses IndexedDataStore for efficient incremental operations.
2013
+ * For large datasets, sorting is automatically offloaded to a Web Worker.
1975
2014
  */
1976
2015
  declare function createMutableClientDataSource<TData extends Row = Row>(data: TData[], options: MutableClientDataSourceOptions<TData>): MutableDataSource<TData>;
1977
2016
  //#endregion
@@ -2063,5 +2102,4 @@ interface GridState<TData = Row> {
2063
2102
  hoverPosition: CellPosition | null;
2064
2103
  }
2065
2104
  //#endregion
2066
- export { type AssignSlotInstruction, type BatchInstructionListener, type CancelFillInstruction, type CellDataType, type CellPosition, type CellRange, type CellRendererParams, type CellValue, type CloseFilterPopupInstruction, type ColumnDefinition, type ColumnFilterModel, type CommitEditInstruction, type CommitFillInstruction, type ContainerBounds, type CreateSlotInstruction, type DataChangeListener, type DataErrorInstruction, type DataLoadedInstruction, type DataLoadingInstruction, type DataSource, type DataSourceRequest, type DataSourceResponse, type DateFilterCondition, type DateFilterOperator, type DestroySlotInstruction, type Direction, type DragMoveResult, type DragState, EditManager, type EditManagerOptions, type EditRendererParams, type EditState, type FillHandleState, FillManager, type FilterCombination, type FilterCondition, type FilterModel, type FilterPopupState, GridCore, type GridCoreOptions, type GridInstruction, type GridState, type HeaderData, type HeaderRendererParams, type HighlightContext, HighlightManager, type HighlightingOptions, IndexedDataStore, type IndexedDataStoreOptions, InputHandler, type InputHandlerDeps, type InputResult, type InstructionListener, type KeyEventData, type KeyboardResult, type MoveSlotInstruction, type MultiColumnSortedChunk, type MutableClientDataSourceOptions, type MutableDataSource, type NumberFilterCondition, type NumberFilterOperator, type OpenFilterPopupInstruction, ParallelSortManager, type ParallelSortOptions, type PointerEventData, type Row, type RowId, type RowSortCache, type RowsAddedInstruction, type RowsRemovedInstruction, type RowsUpdatedInstruction, SelectionManager, type SelectionState, type SetActiveCellInstruction, type SetContentSizeInstruction, type SetHoverPositionInstruction, type SetSelectionRangeInstruction, type SlotData, type BatchInstructionListener$1 as SlotPoolBatchListener, SlotPoolManager, type SlotPoolManagerOptions, type SlotState, type SortDirection, type SortModel, type SortedChunk, type StartEditInstruction, type StartFillInstruction, type StopEditInstruction, type TextFilterCondition, type TextFilterOperator, type Transaction, TransactionManager, type TransactionManagerOptions, type TransactionProcessedInstruction, type TransactionResult, type UpdateFillInstruction, type UpdateHeaderInstruction, WorkerPool, type WorkerPoolOptions, buildCellClasses, calculateColumnPositions, calculateScaledColumnPositions, cellStyles, compareValues, computeValueHash, containerStyles, createClientDataSource, createDataSourceFromArray, createMutableClientDataSource, createServerDataSource, detectBoundaryCollisions, evaluateColumnFilter, evaluateDateCondition, evaluateNumberCondition, evaluateTextCondition, filtersStyles, findColumnAtX, getFieldValue, getTotalWidth, gridStyles, headerStyles, injectStyles, isCellActive, isCellEditing, isCellInFillPreview, isCellSelected, isColumnInSelectionRange, isRowInSelectionRange, isRowVisible, isSameDay, kWayMerge, kWayMergeMultiColumn, rowPassesFilter, scrollbarStyles, setFieldValue, statesStyles, stringToSortableNumber, variablesStyles };
2067
- //# sourceMappingURL=index.d.ts.map
2105
+ 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 };