@alaarab/ogrid-react 2.1.15 → 2.3.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.
@@ -81,3 +81,5 @@ export { useDataGridTableOrchestration } from './useDataGridTableOrchestration';
81
81
  export type { UseDataGridTableOrchestrationParams, UseDataGridTableOrchestrationResult, } from './useDataGridTableOrchestration';
82
82
  export { useColumnMeta } from './useColumnMeta';
83
83
  export type { UseColumnMetaParams, ColumnMetaResult } from './useColumnMeta';
84
+ export { useFormulaEngine } from './useFormulaEngine';
85
+ export type { UseFormulaEngineParams, UseFormulaEngineResult } from './useFormulaEngine';
@@ -9,6 +9,16 @@ export interface UseClipboardParams<T> {
9
9
  onCellValueChanged: ((event: ICellValueChangedEvent<T>) => void) | undefined;
10
10
  beginBatch?: () => void;
11
11
  endBatch?: () => void;
12
+ /** When true, enables formula-aware copy/paste. */
13
+ formulas?: boolean;
14
+ /** Flat (unfiltered) column list used to map visible col to flat col index. */
15
+ flatColumns?: IColumnDef<T>[];
16
+ /** Returns the formula string for a flat column + row, or undefined if none. */
17
+ getFormula?: (col: number, row: number) => string | undefined;
18
+ /** Returns true if a flat column + row has a formula. */
19
+ hasFormula?: (col: number, row: number) => boolean;
20
+ /** Sets or clears a formula for a flat column + row. */
21
+ setFormula?: (col: number, row: number, formula: string | null) => void;
12
22
  }
13
23
  export interface UseClipboardResult {
14
24
  handleCopy: () => void;
@@ -31,6 +31,14 @@ export interface UseDataGridEditingParams<T> {
31
31
  endCol: number;
32
32
  } | null) => void;
33
33
  colOffset: number;
34
+ /** Formula integration: set a formula for a cell coordinate. */
35
+ setFormula?: (col: number, row: number, formula: string | null) => void;
36
+ /** Formula integration: notify a non-formula cell changed. */
37
+ onFormulaCellChanged?: (col: number, row: number) => void;
38
+ /** Whether formula support is enabled. */
39
+ formulas?: boolean;
40
+ /** All flat columns (for mapping columnId → column index). */
41
+ flatColumns?: IColumnDef<T>[];
34
42
  }
35
43
  export interface UseDataGridEditingResult<T> {
36
44
  editing: DataGridEditingState<T>;
@@ -47,6 +47,16 @@ export interface UseDataGridInteractionParams<T> {
47
47
  wrapperRef: RefObject<HTMLDivElement | null>;
48
48
  /** Custom keydown handler — called before grid default. preventDefault() suppresses grid handling. */
49
49
  onKeyDown?: (event: React.KeyboardEvent) => void;
50
+ /** When true, enables formula-aware clipboard and fill handle. */
51
+ formulas?: boolean;
52
+ /** Flat column list for formula coordinate mapping. */
53
+ flatColumns?: IColumnDef<T>[];
54
+ /** Returns the formula string for a flat column + row. */
55
+ getFormula?: (col: number, row: number) => string | undefined;
56
+ /** Returns true if a flat column + row has a formula. */
57
+ hasFormula?: (col: number, row: number) => boolean;
58
+ /** Sets or clears a formula for a flat column + row. */
59
+ setFormula?: (col: number, row: number, formula: string | null) => void;
50
60
  }
51
61
  export interface UseDataGridInteractionResult<T> {
52
62
  interaction: DataGridCellInteractionState;
@@ -4,6 +4,7 @@ import type { DataGridLayoutState, DataGridRowSelectionState, DataGridEditingSta
4
4
  import type { UseColumnResizeResult } from './useColumnResize';
5
5
  import type { UseColumnReorderResult } from './useColumnReorder';
6
6
  import type { UseVirtualScrollResult } from './useVirtualScroll';
7
+ import type { IVisibleColumnRange } from '@alaarab/ogrid-core';
7
8
  import type { HeaderFilterConfigInput, CellRenderDescriptorInput } from '../utils';
8
9
  import type { IStatusBarProps, RowId, HeaderRow } from '../types';
9
10
  import { CellDescriptorCache } from '@alaarab/ogrid-core';
@@ -32,6 +33,10 @@ export interface UseDataGridTableOrchestrationResult<T> {
32
33
  virtualScrollEnabled: boolean;
33
34
  virtualRowHeight: number;
34
35
  visibleRange: UseVirtualScrollResult['visibleRange'];
36
+ /** Visible column range for horizontal virtualization (null when disabled). */
37
+ columnRange: IVisibleColumnRange | null;
38
+ /** Callback for horizontal scroll events (column virtualization). */
39
+ onHorizontalScroll?: (scrollLeft: number) => void;
35
40
  items: T[];
36
41
  columns: IOGridDataGridProps<T>['columns'];
37
42
  getRowId: IOGridDataGridProps<T>['getRowId'];
@@ -56,6 +61,8 @@ export interface UseDataGridTableOrchestrationResult<T> {
56
61
  headerRows: HeaderRow<T>[];
57
62
  allowOverflowX: boolean;
58
63
  fitToContent: boolean;
64
+ showColumnLetters: boolean;
65
+ showNameBox: boolean;
59
66
  editCallbacks: {
60
67
  commitCellEdit: DataGridEditingState<T>['commitCellEdit'];
61
68
  setEditingCell: DataGridEditingState<T>['setEditingCell'];
@@ -1,6 +1,7 @@
1
1
  import type { RefObject } from 'react';
2
2
  import type { ISelectionRange, IActiveCell } from '../types';
3
3
  import type { IColumnDef, ICellValueChangedEvent } from '../types/columnTypes';
4
+ import type { IFillFormulaOptions } from '../utils';
4
5
  export interface UseFillHandleParams<T> {
5
6
  items: T[];
6
7
  visibleCols: IColumnDef<T>[];
@@ -13,6 +14,8 @@ export interface UseFillHandleParams<T> {
13
14
  wrapperRef: RefObject<HTMLDivElement | null>;
14
15
  beginBatch?: () => void;
15
16
  endBatch?: () => void;
17
+ /** Optional formula-aware fill options. When provided, cells with formulas adjust references during fill. */
18
+ formulaOptions?: IFillFormulaOptions<T>;
16
19
  }
17
20
  export interface UseFillHandleResult {
18
21
  fillDrag: {
@@ -0,0 +1,52 @@
1
+ /**
2
+ * useFormulaEngine — React hook for integrating the formula engine with the grid.
3
+ *
4
+ * Lazily creates a FormulaEngine instance when `formulas` prop is true.
5
+ * Provides accessor bridge between grid data and formula coordinates.
6
+ * Tree-shakeable: if `formulas` is false, no formula code is loaded.
7
+ */
8
+ import { type IGridDataAccessor, type IFormulaFunction, type IRecalcResult, type IAuditEntry, type IAuditTrail } from '@alaarab/ogrid-core';
9
+ import type { IColumnDef } from '@alaarab/ogrid-core';
10
+ export interface UseFormulaEngineParams<T> {
11
+ /** Enable formula support. */
12
+ formulas?: boolean;
13
+ /** Grid data items. */
14
+ items: T[];
15
+ /** Flat leaf columns (for mapping column index ↔ columnId). */
16
+ flatColumns: IColumnDef<T>[];
17
+ /** Initial formulas to load. */
18
+ initialFormulas?: Array<{
19
+ col: number;
20
+ row: number;
21
+ formula: string;
22
+ }>;
23
+ /** Called when recalculation produces cascading updates. */
24
+ onFormulaRecalc?: (result: IRecalcResult) => void;
25
+ /** Custom formula functions. */
26
+ formulaFunctions?: Record<string, IFormulaFunction>;
27
+ /** Named ranges: name → cell/range reference string. */
28
+ namedRanges?: Record<string, string>;
29
+ /** Sheet accessors for cross-sheet references. */
30
+ sheets?: Record<string, IGridDataAccessor>;
31
+ }
32
+ export interface UseFormulaEngineResult {
33
+ /** Get the formula engine's computed value for a cell coordinate. */
34
+ getFormulaValue: (col: number, row: number) => unknown;
35
+ /** Check if a cell has a formula. */
36
+ hasFormula: (col: number, row: number) => boolean;
37
+ /** Get the formula string for a cell. */
38
+ getFormula: (col: number, row: number) => string | undefined;
39
+ /** Set or clear a formula for a cell. Triggers recalculation. */
40
+ setFormula: (col: number, row: number, formula: string | null) => void;
41
+ /** Notify the engine that a non-formula cell value changed. Triggers dependent recalc. */
42
+ onCellChanged: (col: number, row: number) => void;
43
+ /** Get all cells that a cell depends on (deep, transitive). */
44
+ getPrecedents: (col: number, row: number) => IAuditEntry[];
45
+ /** Get all cells that depend on a cell (deep, transitive). */
46
+ getDependents: (col: number, row: number) => IAuditEntry[];
47
+ /** Get full audit trail for a cell. */
48
+ getAuditTrail: (col: number, row: number) => IAuditTrail | null;
49
+ /** Whether formula support is active. */
50
+ enabled: boolean;
51
+ }
52
+ export declare function useFormulaEngine<T>(params: UseFormulaEngineParams<T>): UseFormulaEngineResult;
@@ -14,6 +14,8 @@ export interface UseOGridDataFetchingParams<T> {
14
14
  pageSize: number;
15
15
  onError?: (err: unknown) => void;
16
16
  onFirstDataRendered?: () => void;
17
+ /** Worker sort mode: true=always, 'auto'=when data > 5000 rows, false=sync. */
18
+ workerSort?: boolean | 'auto';
17
19
  }
18
20
  export interface UseOGridDataFetchingState<T> {
19
21
  displayItems: T[];
@@ -1,6 +1,6 @@
1
1
  import type { Virtualizer } from '@tanstack/react-virtual';
2
2
  import type { RefObject } from 'react';
3
- import type { IVisibleRange } from '@alaarab/ogrid-core';
3
+ import type { IVisibleRange, IVisibleColumnRange } from '@alaarab/ogrid-core';
4
4
  export type { IVirtualScrollConfig } from '@alaarab/ogrid-core';
5
5
  export interface UseVirtualScrollParams {
6
6
  /** Total number of rows in the data set. */
@@ -18,6 +18,12 @@ export interface UseVirtualScrollParams {
18
18
  threshold?: number;
19
19
  /** Ref to the scrollable container element. */
20
20
  containerRef: RefObject<HTMLElement | null>;
21
+ /** Enable column virtualization (only render visible columns). */
22
+ columnVirtualization?: boolean;
23
+ /** Column widths for horizontal virtualization (unpinned columns only). */
24
+ columnWidths?: number[];
25
+ /** Column overscan count. Default: 2. */
26
+ columnOverscan?: number;
21
27
  }
22
28
  export interface UseVirtualScrollResult {
23
29
  /** The TanStack virtualizer instance (null when disabled). */
@@ -28,11 +34,15 @@ export interface UseVirtualScrollResult {
28
34
  visibleRange: IVisibleRange;
29
35
  /** Scroll to a specific row index. */
30
36
  scrollToIndex: (index: number) => void;
37
+ /** Visible column range for horizontal virtualization (null when column virtualization disabled). */
38
+ columnRange: IVisibleColumnRange | null;
39
+ /** Callback to attach to scroll container's onScroll for horizontal tracking. */
40
+ onHorizontalScroll?: (scrollLeft: number) => void;
31
41
  }
32
42
  /**
33
- * Wraps TanStack Virtual for row virtualization.
43
+ * Wraps TanStack Virtual for row virtualization, with optional column virtualization.
34
44
  * When disabled or when totalRows < threshold, returns a pass-through (all rows visible).
35
- * @param params - Total rows, row height, enabled flag, overscan, threshold, and container ref.
36
- * @returns Virtualizer instance, total height, visible range, and scrollToIndex helper.
45
+ * @param params - Total rows, row height, enabled flag, overscan, threshold, container ref, and column virtualization params.
46
+ * @returns Virtualizer instance, total height, visible range, scrollToIndex, columnRange, and onHorizontalScroll.
37
47
  */
38
48
  export declare function useVirtualScroll(params: UseVirtualScrollParams): UseVirtualScrollResult;
@@ -1,8 +1,8 @@
1
1
  export { CHECKBOX_COLUMN_WIDTH, ROW_NUMBER_COLUMN_WIDTH, DEFAULT_MIN_COLUMN_WIDTH, CELL_PADDING, GRID_BORDER_RADIUS, } from '@alaarab/ogrid-core';
2
2
  export type { ColumnFilterType, IColumnFilterDef, IColumnMeta, IColumnDef, IColumnGroupDef, IColumnDefinition, ICellValueChangedEvent, ICellEditorProps, CellEditorParams, IValueParserParams, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, IOGridApi, IOGridProps, IOGridDataGridProps, RowSelectionMode, RowId, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, HeaderCell, HeaderRow, SideBarPanelId, ISideBarDef, IDateFilterValue, IVirtualScrollConfig, IColumnReorderConfig, } from './types';
3
3
  export { toUserLike, isInSelectionRange, normalizeSelectionRange } from './types';
4
- export { useFilterOptions, useOGrid, useActiveCell, useCellEditing, useContextMenu, useCellSelection, useClipboard, useRowSelection, useKeyboardNavigation, useUndoRedo, useDebounce, useFillHandle, useDataGridState, useColumnHeaderFilterState, useTextFilterState, useMultiSelectFilterState, usePeopleFilterState, useDateFilterState, useColumnChooserState, useInlineCellEditorState, useColumnResize, useRichSelectState, useSelectState, useSideBarState, useTableLayout, useColumnReorder, useVirtualScroll, useListVirtualizer, useLatestRef, usePaginationControls, useDataGridTableOrchestration, useColumnMeta, } from './hooks';
5
- export type { UseFilterOptionsResult, UseOGridResult, UseOGridPagination, UseOGridColumnChooser, UseOGridLayout, UseOGridFilters, ColumnChooserPlacement, UseActiveCellResult, UseCellEditingResult, EditingCell, UseContextMenuResult, ContextMenuPosition, UseCellSelectionResult, UseCellSelectionParams, UseClipboardResult, UseClipboardParams, UseRowSelectionResult, UseRowSelectionParams, UseKeyboardNavigationResult, UseKeyboardNavigationParams, UseUndoRedoResult, UseUndoRedoParams, UseFillHandleResult, UseFillHandleParams, UseDataGridStateParams, UseDataGridStateResult, DataGridLayoutState, DataGridRowSelectionState, DataGridEditingState, DataGridCellInteractionState, DataGridContextMenuState, DataGridViewModelState, DataGridPinningState, UseColumnHeaderFilterStateParams, UseColumnHeaderFilterStateResult, UseTextFilterStateParams, UseTextFilterStateResult, UseMultiSelectFilterStateParams, UseMultiSelectFilterStateResult, UsePeopleFilterStateParams, UsePeopleFilterStateResult, UseDateFilterStateParams, UseDateFilterStateResult, UseColumnChooserStateParams, UseColumnChooserStateResult, UseInlineCellEditorStateParams, UseInlineCellEditorStateResult, InlineCellEditorType, UseColumnResizeParams, UseColumnResizeResult, UseRichSelectStateParams, UseRichSelectStateResult, UseSelectStateParams, UseSelectStateResult, UseSideBarStateParams, UseSideBarStateResult, UseTableLayoutParams, UseTableLayoutResult, UseColumnReorderParams, UseColumnReorderResult, UseVirtualScrollParams, UseVirtualScrollResult, UsePaginationControlsProps, UsePaginationControlsResult, UseDataGridTableOrchestrationParams, UseDataGridTableOrchestrationResult, UseColumnMetaParams, ColumnMetaResult, } from './hooks';
4
+ export { useFilterOptions, useOGrid, useActiveCell, useCellEditing, useContextMenu, useCellSelection, useClipboard, useRowSelection, useKeyboardNavigation, useUndoRedo, useDebounce, useFillHandle, useDataGridState, useColumnHeaderFilterState, useTextFilterState, useMultiSelectFilterState, usePeopleFilterState, useDateFilterState, useColumnChooserState, useInlineCellEditorState, useColumnResize, useRichSelectState, useSelectState, useSideBarState, useTableLayout, useColumnReorder, useVirtualScroll, useListVirtualizer, useLatestRef, usePaginationControls, useDataGridTableOrchestration, useColumnMeta, useFormulaEngine, } from './hooks';
5
+ export type { UseFilterOptionsResult, UseOGridResult, UseOGridPagination, UseOGridColumnChooser, UseOGridLayout, UseOGridFilters, ColumnChooserPlacement, UseActiveCellResult, UseCellEditingResult, EditingCell, UseContextMenuResult, ContextMenuPosition, UseCellSelectionResult, UseCellSelectionParams, UseClipboardResult, UseClipboardParams, UseRowSelectionResult, UseRowSelectionParams, UseKeyboardNavigationResult, UseKeyboardNavigationParams, UseUndoRedoResult, UseUndoRedoParams, UseFillHandleResult, UseFillHandleParams, UseDataGridStateParams, UseDataGridStateResult, DataGridLayoutState, DataGridRowSelectionState, DataGridEditingState, DataGridCellInteractionState, DataGridContextMenuState, DataGridViewModelState, DataGridPinningState, UseColumnHeaderFilterStateParams, UseColumnHeaderFilterStateResult, UseTextFilterStateParams, UseTextFilterStateResult, UseMultiSelectFilterStateParams, UseMultiSelectFilterStateResult, UsePeopleFilterStateParams, UsePeopleFilterStateResult, UseDateFilterStateParams, UseDateFilterStateResult, UseColumnChooserStateParams, UseColumnChooserStateResult, UseInlineCellEditorStateParams, UseInlineCellEditorStateResult, InlineCellEditorType, UseColumnResizeParams, UseColumnResizeResult, UseRichSelectStateParams, UseRichSelectStateResult, UseSelectStateParams, UseSelectStateResult, UseSideBarStateParams, UseSideBarStateResult, UseTableLayoutParams, UseTableLayoutResult, UseColumnReorderParams, UseColumnReorderResult, UseVirtualScrollParams, UseVirtualScrollResult, UsePaginationControlsProps, UsePaginationControlsResult, UseDataGridTableOrchestrationParams, UseDataGridTableOrchestrationResult, UseColumnMetaParams, ColumnMetaResult, UseFormulaEngineParams, UseFormulaEngineResult, } from './hooks';
6
6
  export { GRID_ROOT_STYLE, CURSOR_CELL_STYLE, POPOVER_ANCHOR_STYLE, PREVENT_DEFAULT, NOOP, STOP_PROPAGATION, } from './constants/domHelpers';
7
7
  export { OGridLayout } from './components/OGridLayout';
8
8
  export type { OGridLayoutProps } from './components/OGridLayout';
@@ -32,7 +32,7 @@ export { BaseDropIndicator } from './components/BaseDropIndicator';
32
32
  export type { BaseDropIndicatorProps } from './components/BaseDropIndicator';
33
33
  export { DateFilterContent, getColumnHeaderFilterStateParams, getDateFilterContentProps, } from './components/ColumnHeaderFilterContent';
34
34
  export type { IColumnHeaderFilterProps, DateFilterContentProps, DateFilterClassNames, } from './components/ColumnHeaderFilterContent';
35
- export { escapeCsvValue, buildCsvHeader, buildCsvRows, exportToCsv, triggerCsvDownload, getCellValue, flattenColumns, buildHeaderRows, getFilterField, mergeFilter, deriveFilterOptionsFromData, getMultiSelectFilterFields, getStatusBarParts, getDataGridStatusBarConfig, GRID_CONTEXT_MENU_ITEMS, COLUMN_HEADER_MENU_ITEMS, getContextMenuHandlers, getColumnHeaderMenuItems, formatShortcut, getPaginationViewModel, PAGE_SIZE_OPTIONS, MAX_PAGE_BUTTONS, getHeaderFilterConfig, getCellRenderDescriptor, CellDescriptorCache, isRowInRange, resolveCellDisplayContent, resolveCellStyle, buildInlineEditorProps, buildPopoverEditorProps, getCellInteractionProps, parseValue, numberParser, currencyParser, dateParser, emailParser, booleanParser, computeAggregations, processClientSideData, areGridRowPropsEqual, findCtrlArrowTarget, computeTabNavigation, rangesEqual, clampSelectionToBounds, computeAutoScrollSpeed, formatCellValueForTsv, formatSelectionAsTsv, parseTsvClipboard, UndoRedoStack, } from './utils';
35
+ export { escapeCsvValue, buildCsvHeader, buildCsvRows, exportToCsv, triggerCsvDownload, getCellValue, flattenColumns, buildHeaderRows, getFilterField, mergeFilter, deriveFilterOptionsFromData, getMultiSelectFilterFields, getStatusBarParts, getDataGridStatusBarConfig, GRID_CONTEXT_MENU_ITEMS, COLUMN_HEADER_MENU_ITEMS, getContextMenuHandlers, getColumnHeaderMenuItems, formatShortcut, getPaginationViewModel, PAGE_SIZE_OPTIONS, MAX_PAGE_BUTTONS, getHeaderFilterConfig, getCellRenderDescriptor, CellDescriptorCache, isRowInRange, resolveCellDisplayContent, resolveCellStyle, buildInlineEditorProps, buildPopoverEditorProps, getCellInteractionProps, parseValue, numberParser, currencyParser, dateParser, emailParser, booleanParser, computeAggregations, processClientSideData, partitionColumnsForVirtualization, areGridRowPropsEqual, findCtrlArrowTarget, computeTabNavigation, rangesEqual, clampSelectionToBounds, computeAutoScrollSpeed, formatCellValueForTsv, formatSelectionAsTsv, parseTsvClipboard, UndoRedoStack, indexToColumnLetter, formatCellReference, } from './utils';
36
36
  export type { CsvColumn, StatusBarPart, StatusBarPartsInput, GridContextMenuItem, GridContextMenuHandlerProps, PaginationViewModel, HeaderFilterConfigInput, HeaderFilterConfig, CellRenderDescriptorInput, CellRenderDescriptor, CellRenderMode, CellInteractionHandlers, ParseValueResult, AggregationResult, GridRowComparatorProps, IColumnHeaderMenuItem, ColumnHeaderMenuInput, ColumnHeaderMenuHandlers, } from './utils';
37
37
  export { renderFilterContent } from './components/ColumnHeaderFilterRenderers';
38
38
  export type { FilterContentRenderers, MultiSelectRendererProps, TextRendererProps, PeopleRendererProps, DateRendererProps, } from './components/ColumnHeaderFilterRenderers';
@@ -1,5 +1,6 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { IColumnDef, IColumnGroupDef, ICellValueChangedEvent } from './columnTypes';
3
+ import type { IFormulaFunction, IRecalcResult, IGridDataAccessor, IAuditEntry, IAuditTrail } from '@alaarab/ogrid-core';
3
4
  export type { RowId, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, RowSelectionMode, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, SideBarPanelId, ISideBarDef, IVirtualScrollConfig, IColumnReorderConfig, IOGridApi, } from '@alaarab/ogrid-core';
4
5
  export { toUserLike, isInSelectionRange, normalizeSelectionRange } from '@alaarab/ogrid-core';
5
6
  import type { RowId, UserLike, IFilters, FilterValue, RowSelectionMode, IRowSelectionChangeEvent, IStatusBarProps, IDataSource, ISideBarDef, IVirtualScrollConfig } from '@alaarab/ogrid-core';
@@ -43,6 +44,8 @@ interface IOGridBaseProps<T> {
43
44
  onSelectionChange?: (event: IRowSelectionChangeEvent<T>) => void;
44
45
  /** Show Excel-style row numbers column at the start of the grid (1, 2, 3...). Default: false. */
45
46
  showRowNumbers?: boolean;
47
+ /** Enable Excel-style cell references: column letter headers (A, B, C...), row number gutter, and a name box showing the active cell (e.g. "A1"). Implies showRowNumbers. */
48
+ cellReferences?: boolean;
46
49
  statusBar?: boolean | IStatusBarProps;
47
50
  defaultPageSize?: number;
48
51
  defaultSortBy?: string;
@@ -80,12 +83,36 @@ interface IOGridBaseProps<T> {
80
83
  rowHeight?: number;
81
84
  /** Cell spacing/density preset. Controls cell padding throughout the grid. Default: 'normal'. */
82
85
  density?: 'compact' | 'normal' | 'comfortable';
86
+ /**
87
+ * Offload sorting to a Web Worker to avoid blocking the main thread.
88
+ * - `true`: always use worker sort
89
+ * - `'auto'`: use worker sort when data.length > 5000
90
+ * - `false` (default): use synchronous sort
91
+ * Columns with custom `compare` functions fall back to synchronous sort.
92
+ */
93
+ workerSort?: boolean | 'auto';
83
94
  /** Fires once when the grid first renders with data (useful for restoring column state). */
84
95
  onFirstDataRendered?: () => void;
85
96
  /** Called when server-side fetchPage fails. */
86
97
  onError?: (error: unknown) => void;
87
98
  /** Called when a cell renderer or custom editor throws an error. */
88
99
  onCellError?: (error: Error, errorInfo: React.ErrorInfo) => void;
100
+ /** Enable Excel-like formula support. When true, cells starting with '=' are treated as formulas. Default: false. */
101
+ formulas?: boolean;
102
+ /** Initial formulas to load when the formula engine initializes. */
103
+ initialFormulas?: Array<{
104
+ col: number;
105
+ row: number;
106
+ formula: string;
107
+ }>;
108
+ /** Called when formula recalculation produces updated cell values (e.g. cascade from an edited cell). */
109
+ onFormulaRecalc?: (result: IRecalcResult) => void;
110
+ /** Custom formula functions to register with the formula engine (e.g. { MYFUNC: { minArgs: 1, maxArgs: 1, evaluate: ... } }). */
111
+ formulaFunctions?: Record<string, IFormulaFunction>;
112
+ /** Named ranges for the formula engine: name → cell/range ref string (e.g. { Revenue: 'A1:A10' }). */
113
+ namedRanges?: Record<string, string>;
114
+ /** Sheet accessors for cross-sheet formula references (e.g. { Sheet2: accessor }). */
115
+ sheets?: Record<string, IGridDataAccessor>;
89
116
  'aria-label'?: string;
90
117
  'aria-labelledby'?: string;
91
118
  }
@@ -144,6 +171,12 @@ export interface IOGridDataGridProps<T> {
144
171
  onSelectionChange?: (event: IRowSelectionChangeEvent<T>) => void;
145
172
  /** Show Excel-style row numbers column. */
146
173
  showRowNumbers?: boolean;
174
+ /** Show Excel-style column letter headers (A, B, C...) above the header row. */
175
+ showColumnLetters?: boolean;
176
+ /** Show a name box displaying the active cell reference (e.g. "A1"). */
177
+ showNameBox?: boolean;
178
+ /** Callback when the active cell changes. Used by the name box to display the current cell reference. */
179
+ onActiveCellChange?: (ref: string | null) => void;
147
180
  /** Current page number (1-based) for row number calculation. */
148
181
  currentPage?: number;
149
182
  /** Page size for row number calculation. */
@@ -177,4 +210,22 @@ export interface IOGridDataGridProps<T> {
177
210
  'aria-labelledby'?: string;
178
211
  /** Custom keydown handler. Called before grid's built-in handling. Call event.preventDefault() to suppress grid default. */
179
212
  onKeyDown?: (event: React.KeyboardEvent) => void;
213
+ /** Enable formula support. When true, cell values starting with '=' are treated as formulas. */
214
+ formulas?: boolean;
215
+ /** Get the formula engine's computed value for a cell, or undefined if no formula. */
216
+ getFormulaValue?: (col: number, row: number) => unknown;
217
+ /** Check if a cell has a formula. */
218
+ hasFormula?: (col: number, row: number) => boolean;
219
+ /** Get the formula string for a cell. */
220
+ getFormula?: (col: number, row: number) => string | undefined;
221
+ /** Set a formula for a cell (called from edit commit when value starts with '='). */
222
+ setFormula?: (col: number, row: number, formula: string | null) => void;
223
+ /** Notify the formula engine that a non-formula cell changed. */
224
+ onFormulaCellChanged?: (col: number, row: number) => void;
225
+ /** Get all cells that a cell depends on (deep, transitive). */
226
+ getPrecedents?: (col: number, row: number) => IAuditEntry[];
227
+ /** Get all cells that depend on a cell (deep, transitive). */
228
+ getDependents?: (col: number, row: number) => IAuditEntry[];
229
+ /** Get full audit trail for a cell. */
230
+ getAuditTrail?: (col: number, row: number) => IAuditTrail | null;
180
231
  }
@@ -19,7 +19,7 @@ export declare function resolveCellDisplayContent<T>(col: IColumnDef<T>, item: T
19
19
  * Resolves the cellStyle from a column def.
20
20
  * Returns React.CSSProperties for JSX compatibility.
21
21
  */
22
- export declare function resolveCellStyle<T>(col: IColumnDef<T>, item: T): React.CSSProperties | undefined;
22
+ export declare function resolveCellStyle<T>(col: IColumnDef<T>, item: T, displayValue?: unknown): React.CSSProperties | undefined;
23
23
  /**
24
24
  * Builds props for InlineCellEditor with React-specific IColumnDef.
25
25
  */
@@ -63,6 +63,7 @@ export declare function getCellInteractionProps(descriptor: CellRenderDescriptor
63
63
  onClick: () => void;
64
64
  onContextMenu: (e: React.MouseEvent) => void;
65
65
  'data-in-range'?: "true" | undefined;
66
+ 'data-active-cell'?: "true" | undefined;
66
67
  'data-row-index': number;
67
68
  'data-col-index': number;
68
69
  };
@@ -1,5 +1,5 @@
1
- export { escapeCsvValue, buildCsvHeader, buildCsvRows, exportToCsv, triggerCsvDownload, getCellValue, flattenColumns, buildHeaderRows, getFilterField, mergeFilter, deriveFilterOptionsFromData, getMultiSelectFilterFields, getStatusBarParts, getDataGridStatusBarConfig, getPaginationViewModel, PAGE_SIZE_OPTIONS, MAX_PAGE_BUTTONS, GRID_CONTEXT_MENU_ITEMS, COLUMN_HEADER_MENU_ITEMS, getContextMenuHandlers, getColumnHeaderMenuItems, formatShortcut, parseValue, numberParser, currencyParser, dateParser, emailParser, booleanParser, computeAggregations, processClientSideData, computeNextSortState, measureColumnContentWidth, AUTOSIZE_EXTRA_PX, AUTOSIZE_MAX_PX, findCtrlArrowTarget, computeTabNavigation, rangesEqual, clampSelectionToBounds, computeAutoScrollSpeed, formatCellValueForTsv, formatSelectionAsTsv, parseTsvClipboard, applyPastedValues, applyCutClear, applyFillValues, computeArrowNavigation, applyCellDeletion, applyRangeRowSelection, computeRowSelectionState, UndoRedoStack, buildCellIndex, } from '@alaarab/ogrid-core';
2
- export type { CsvColumn, StatusBarPart, StatusBarPartsInput, GridContextMenuItem, GridContextMenuHandlerProps, PaginationViewModel, ParseValueResult, AggregationResult, IColumnHeaderMenuItem, ColumnHeaderMenuInput, ColumnHeaderMenuHandlers, ArrowNavigationContext, ArrowNavigationResult, } from '@alaarab/ogrid-core';
1
+ export { escapeCsvValue, buildCsvHeader, buildCsvRows, exportToCsv, triggerCsvDownload, getCellValue, flattenColumns, buildHeaderRows, getFilterField, mergeFilter, deriveFilterOptionsFromData, getMultiSelectFilterFields, getStatusBarParts, getDataGridStatusBarConfig, getPaginationViewModel, PAGE_SIZE_OPTIONS, MAX_PAGE_BUTTONS, GRID_CONTEXT_MENU_ITEMS, COLUMN_HEADER_MENU_ITEMS, getContextMenuHandlers, getColumnHeaderMenuItems, formatShortcut, parseValue, numberParser, currencyParser, dateParser, emailParser, booleanParser, computeAggregations, processClientSideData, partitionColumnsForVirtualization, computeNextSortState, measureColumnContentWidth, AUTOSIZE_EXTRA_PX, AUTOSIZE_MAX_PX, findCtrlArrowTarget, computeTabNavigation, rangesEqual, clampSelectionToBounds, computeAutoScrollSpeed, formatCellValueForTsv, formatSelectionAsTsv, parseTsvClipboard, applyPastedValues, applyCutClear, applyFillValues, computeArrowNavigation, applyCellDeletion, applyRangeRowSelection, computeRowSelectionState, UndoRedoStack, buildCellIndex, indexToColumnLetter, formatCellReference, getScrollTopForRow, } from '@alaarab/ogrid-core';
2
+ export type { CsvColumn, StatusBarPart, StatusBarPartsInput, GridContextMenuItem, GridContextMenuHandlerProps, PaginationViewModel, ParseValueResult, AggregationResult, IColumnHeaderMenuItem, ColumnHeaderMenuInput, ColumnHeaderMenuHandlers, ArrowNavigationContext, ArrowNavigationResult, IFillFormulaOptions, } from '@alaarab/ogrid-core';
3
3
  export { getHeaderFilterConfig, getCellRenderDescriptor, resolveCellDisplayContent, resolveCellStyle, buildInlineEditorProps, buildPopoverEditorProps, getCellInteractionProps, } from './dataGridViewModel';
4
4
  export { CellDescriptorCache } from '@alaarab/ogrid-core';
5
5
  export type { HeaderFilterConfigInput, HeaderFilterConfig, CellRenderDescriptorInput, CellRenderDescriptor, CellRenderMode, CellInteractionHandlers, } from './dataGridViewModel';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alaarab/ogrid-react",
3
- "version": "2.1.15",
3
+ "version": "2.3.0",
4
4
  "description": "OGrid React – React hooks, headless components, and utilities for OGrid data grids.",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -39,7 +39,7 @@
39
39
  "node": ">=18"
40
40
  },
41
41
  "dependencies": {
42
- "@alaarab/ogrid-core": "2.1.15",
42
+ "@alaarab/ogrid-core": "2.3.0",
43
43
  "@tanstack/react-virtual": "^3.0.0"
44
44
  },
45
45
  "peerDependencies": {