@alaarab/ogrid-react 2.2.0 → 2.4.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/dist/esm/index.js +6064 -104
- package/dist/types/components/ColumnChooserContent.d.ts +53 -0
- package/dist/types/components/ColumnHeaderFilterRenderers.d.ts +15 -1
- package/dist/types/components/FormulaBar.d.ts +25 -0
- package/dist/types/components/FormulaRefOverlay.d.ts +19 -0
- package/dist/types/components/OGridLayout.d.ts +4 -0
- package/dist/types/components/PaginationControlsBase.d.ts +71 -0
- package/dist/types/components/SheetTabs.d.ts +14 -0
- package/dist/types/hooks/index.d.ts +5 -1
- package/dist/types/hooks/useClipboard.d.ts +10 -0
- package/dist/types/hooks/useColumnHeaderMenuState.d.ts +23 -0
- package/dist/types/hooks/useDataGridEditing.d.ts +8 -0
- package/dist/types/hooks/useDataGridInteraction.d.ts +10 -0
- package/dist/types/hooks/useDataGridTableOrchestration.d.ts +2 -0
- package/dist/types/hooks/useFillHandle.d.ts +3 -0
- package/dist/types/hooks/useFormulaBar.d.ts +43 -0
- package/dist/types/hooks/useFormulaEngine.d.ts +52 -0
- package/dist/types/hooks/useOGrid.d.ts +4 -0
- package/dist/types/index.d.ts +15 -5
- package/dist/types/types/dataGridTypes.d.ts +57 -2
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/utils/dataGridViewModel.d.ts +2 -1
- package/dist/types/utils/index.d.ts +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared inner content for ColumnChooser dropdowns across all React UI packages.
|
|
3
|
+
* Each UI package provides its own popover/dropdown wrapper and CheckboxItem slot.
|
|
4
|
+
* Optional Header, OptionsListContainer, OptionItemContainer, and Actions slots
|
|
5
|
+
* allow framework-specific wrappers (e.g. MUI Box/Typography) for Material.
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import type { IColumnDefinition } from '../types/columnTypes';
|
|
9
|
+
export interface IColumnChooserCheckboxItemProps {
|
|
10
|
+
columnId: string;
|
|
11
|
+
columnName: string;
|
|
12
|
+
checked: boolean;
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
onChange: (checked: boolean) => void;
|
|
15
|
+
}
|
|
16
|
+
export interface IColumnChooserActionsProps {
|
|
17
|
+
onClearAll: () => void;
|
|
18
|
+
onSelectAll: () => void;
|
|
19
|
+
}
|
|
20
|
+
export interface IColumnChooserHeaderProps {
|
|
21
|
+
visibleCount: number;
|
|
22
|
+
totalCount: number;
|
|
23
|
+
}
|
|
24
|
+
export interface ColumnChooserContentClassNames {
|
|
25
|
+
header?: string;
|
|
26
|
+
optionsList?: string;
|
|
27
|
+
optionItem?: string;
|
|
28
|
+
actions?: string;
|
|
29
|
+
clearButton?: string;
|
|
30
|
+
selectAllButton?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ColumnChooserContentProps {
|
|
33
|
+
columns: IColumnDefinition[];
|
|
34
|
+
visibleColumns: Set<string>;
|
|
35
|
+
visibleCount: number;
|
|
36
|
+
totalCount: number;
|
|
37
|
+
handleSelectAll: () => void;
|
|
38
|
+
handleClearAll: () => void;
|
|
39
|
+
/** Curried handler: (columnId) => (checked: boolean) => void */
|
|
40
|
+
handleCheckboxChange: (columnId: string) => (checked: boolean) => void;
|
|
41
|
+
CheckboxItem: React.ComponentType<IColumnChooserCheckboxItemProps>;
|
|
42
|
+
classNames?: ColumnChooserContentClassNames;
|
|
43
|
+
Header?: React.ComponentType<IColumnChooserHeaderProps>;
|
|
44
|
+
OptionsListContainer?: React.ComponentType<{
|
|
45
|
+
children: React.ReactNode;
|
|
46
|
+
}>;
|
|
47
|
+
OptionItemContainer?: React.ComponentType<{
|
|
48
|
+
columnId: string;
|
|
49
|
+
children: React.ReactNode;
|
|
50
|
+
}>;
|
|
51
|
+
Actions?: React.ComponentType<IColumnChooserActionsProps>;
|
|
52
|
+
}
|
|
53
|
+
export declare const ColumnChooserContent: React.FC<ColumnChooserContentProps>;
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* to the correct renderer based on filterType, eliminating the duplicated if/switch chain
|
|
7
7
|
* that was previously in each UI package's ColumnHeaderFilter component.
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
9
|
+
import * as React from 'react';
|
|
10
10
|
import type { ColumnFilterType } from '../types/columnTypes';
|
|
11
11
|
import type { UserLike } from '../types/dataGridTypes';
|
|
12
12
|
import type { UseColumnHeaderFilterStateResult } from '../hooks/useColumnHeaderFilterState';
|
|
13
|
+
import { type DateFilterClassNames } from './ColumnHeaderFilterContent';
|
|
13
14
|
/**
|
|
14
15
|
* Framework-specific renderers for each filter type.
|
|
15
16
|
* Each UI package maps its own sub-filter components to these slots.
|
|
@@ -69,3 +70,16 @@ export interface DateRendererProps {
|
|
|
69
70
|
* @returns The rendered filter content, or null for unsupported filter types
|
|
70
71
|
*/
|
|
71
72
|
export declare function renderFilterContent(filterType: ColumnFilterType, state: UseColumnHeaderFilterStateResult, options: string[], isLoadingOptions: boolean, selectedUser: UserLike | undefined, renderers: FilterContentRenderers): React.ReactNode;
|
|
73
|
+
/**
|
|
74
|
+
* Factory that creates the standard FilterContentRenderers for packages that use
|
|
75
|
+
* the default prop-passthrough pattern (Radix, Material). Fluent keeps its own
|
|
76
|
+
* memoized renderers because it adds extra event-propagation handlers.
|
|
77
|
+
*
|
|
78
|
+
* @param components - The framework-specific sub-filter popover components
|
|
79
|
+
* @param dateClassNames - Optional CSS class names for the date filter buttons (used by packages with CSS modules)
|
|
80
|
+
*/
|
|
81
|
+
export declare function createBaseFilterRenderers(components: {
|
|
82
|
+
MultiSelectFilterPopover: React.ComponentType<MultiSelectRendererProps>;
|
|
83
|
+
TextFilterPopover: React.ComponentType<TextRendererProps>;
|
|
84
|
+
PeopleFilterPopover: React.ComponentType<PeopleRendererProps>;
|
|
85
|
+
}, dateClassNames?: DateFilterClassNames): FilterContentRenderers;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FormulaBar — Headless Excel-style formula bar component.
|
|
3
|
+
*
|
|
4
|
+
* Layout: [Name Box] [fx] [Formula Input]
|
|
5
|
+
*
|
|
6
|
+
* Uses --ogrid-* CSS variables for theming.
|
|
7
|
+
*/
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
export interface FormulaBarProps {
|
|
10
|
+
/** Active cell reference (e.g. "A1"). */
|
|
11
|
+
cellRef: string | null;
|
|
12
|
+
/** Text displayed/edited in the formula input. */
|
|
13
|
+
formulaText: string;
|
|
14
|
+
/** Whether the input is in editing mode. */
|
|
15
|
+
isEditing: boolean;
|
|
16
|
+
/** Called when the user changes the input text. */
|
|
17
|
+
onInputChange: (text: string) => void;
|
|
18
|
+
/** Commit the formula bar value. */
|
|
19
|
+
onCommit: () => void;
|
|
20
|
+
/** Cancel editing. */
|
|
21
|
+
onCancel: () => void;
|
|
22
|
+
/** Start editing the formula bar. */
|
|
23
|
+
startEditing: () => void;
|
|
24
|
+
}
|
|
25
|
+
export declare function FormulaBar({ cellRef, formulaText, isEditing, onInputChange, onCommit, onCancel, startEditing, }: FormulaBarProps): React.ReactElement;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FormulaRefOverlay — Renders colored border overlays on cells referenced by
|
|
3
|
+
* the active formula, like Excel's reference highlighting.
|
|
4
|
+
*
|
|
5
|
+
* Uses the same container measurement pattern as MarchingAntsOverlay.
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { type FormulaReference } from '@alaarab/ogrid-core';
|
|
9
|
+
export interface FormulaRefOverlayProps {
|
|
10
|
+
/** Ref to the positioned container that wraps the table. */
|
|
11
|
+
containerRef: React.RefObject<HTMLElement | null>;
|
|
12
|
+
/** References to highlight. */
|
|
13
|
+
references: FormulaReference[];
|
|
14
|
+
/** Column offset (1 when checkbox/row-number columns are present). */
|
|
15
|
+
colOffset: number;
|
|
16
|
+
}
|
|
17
|
+
declare function FormulaRefOverlayInner({ containerRef, references, colOffset, }: FormulaRefOverlayProps): React.ReactElement | null;
|
|
18
|
+
export declare const FormulaRefOverlay: React.MemoExoticComponent<typeof FormulaRefOverlayInner>;
|
|
19
|
+
export {};
|
|
@@ -25,6 +25,10 @@ export interface OGridLayoutProps {
|
|
|
25
25
|
sideBar?: SideBarProps | null;
|
|
26
26
|
/** When true, render a fullscreen toggle button in the toolbar. */
|
|
27
27
|
fullScreen?: boolean;
|
|
28
|
+
/** Formula bar element (rendered between toolbar and grid). */
|
|
29
|
+
formulaBar?: React.ReactNode;
|
|
30
|
+
/** Sheet tabs element (rendered between grid and footer). */
|
|
31
|
+
sheetTabs?: React.ReactNode;
|
|
28
32
|
}
|
|
29
33
|
/**
|
|
30
34
|
* Renders OGrid layout as a unified bordered container:
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared base component for PaginationControls across all React UI packages.
|
|
3
|
+
* Handles hook call, null guard, vm destructure, and renders the full layout structure.
|
|
4
|
+
* Each UI package provides slots for framework-specific interactive elements.
|
|
5
|
+
*/
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import type { IPaginationControlsProps } from './PaginationControlsProps';
|
|
8
|
+
export interface INavButtonSlotProps {
|
|
9
|
+
variant: 'first' | 'prev' | 'next' | 'last';
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
'aria-label': string;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface IPageButtonSlotProps {
|
|
16
|
+
onClick: () => void;
|
|
17
|
+
active: boolean;
|
|
18
|
+
'aria-label': string;
|
|
19
|
+
'aria-current'?: 'page';
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface IPageSizeSelectSlotProps {
|
|
24
|
+
value: number;
|
|
25
|
+
options: readonly number[];
|
|
26
|
+
onChange: (value: number) => void;
|
|
27
|
+
'aria-label': string;
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface IOuterContainerSlotProps {
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
className?: string;
|
|
33
|
+
role: string;
|
|
34
|
+
'aria-label': string;
|
|
35
|
+
}
|
|
36
|
+
export interface IPaginationControlsSlots {
|
|
37
|
+
NavButton: React.ComponentType<INavButtonSlotProps>;
|
|
38
|
+
PageButton: React.ComponentType<IPageButtonSlotProps>;
|
|
39
|
+
PageSizeSelect: React.ComponentType<IPageSizeSelectSlotProps>;
|
|
40
|
+
OuterContainer?: React.ComponentType<IOuterContainerSlotProps>;
|
|
41
|
+
InfoText?: React.ComponentType<{
|
|
42
|
+
children: React.ReactNode;
|
|
43
|
+
}>;
|
|
44
|
+
NavButtonsContainer?: React.ComponentType<{
|
|
45
|
+
children: React.ReactNode;
|
|
46
|
+
className?: string;
|
|
47
|
+
}>;
|
|
48
|
+
PageSizeContainer?: React.ComponentType<{
|
|
49
|
+
children: React.ReactNode;
|
|
50
|
+
className?: string;
|
|
51
|
+
}>;
|
|
52
|
+
PageSizeLabel?: React.ComponentType<Record<string, never>>;
|
|
53
|
+
Ellipsis?: React.ComponentType<Record<string, never>>;
|
|
54
|
+
}
|
|
55
|
+
export interface PaginationControlsBaseClassNames {
|
|
56
|
+
pagination?: string;
|
|
57
|
+
paginationInfo?: string;
|
|
58
|
+
paginationControls?: string;
|
|
59
|
+
pageNumbers?: string;
|
|
60
|
+
ellipsis?: string;
|
|
61
|
+
navBtn?: string;
|
|
62
|
+
pageBtn?: string;
|
|
63
|
+
pageSizeSelector?: string;
|
|
64
|
+
pageSizeLabel?: string;
|
|
65
|
+
pageSizeSelect?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface PaginationControlsBaseProps extends IPaginationControlsProps {
|
|
68
|
+
slots: IPaginationControlsSlots;
|
|
69
|
+
classNames?: PaginationControlsBaseClassNames;
|
|
70
|
+
}
|
|
71
|
+
export declare const PaginationControlsBase: React.FC<PaginationControlsBaseProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SheetTabs — Excel-style sheet tab bar at the bottom of the grid.
|
|
3
|
+
*
|
|
4
|
+
* Layout: [+] [Sheet1] [Sheet2] [Sheet3]
|
|
5
|
+
*/
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import type { ISheetDef } from '@alaarab/ogrid-core';
|
|
8
|
+
export interface SheetTabsProps {
|
|
9
|
+
sheets: ISheetDef[];
|
|
10
|
+
activeSheet: string;
|
|
11
|
+
onSheetChange: (sheetId: string) => void;
|
|
12
|
+
onSheetAdd?: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function SheetTabs({ sheets, activeSheet, onSheetChange, onSheetAdd, }: SheetTabsProps): React.ReactElement;
|
|
@@ -57,7 +57,7 @@ export { useColumnResize } from './useColumnResize';
|
|
|
57
57
|
export type { UseColumnResizeParams, UseColumnResizeResult, } from './useColumnResize';
|
|
58
58
|
export { useColumnPinning } from './useColumnPinning';
|
|
59
59
|
export type { UseColumnPinningParams, UseColumnPinningResult, } from './useColumnPinning';
|
|
60
|
-
export { useColumnHeaderMenuState } from './useColumnHeaderMenuState';
|
|
60
|
+
export { useColumnHeaderMenuState, getColumnHeaderMenuProps } from './useColumnHeaderMenuState';
|
|
61
61
|
export type { UseColumnHeaderMenuStateParams, UseColumnHeaderMenuStateResult, } from './useColumnHeaderMenuState';
|
|
62
62
|
export { useRichSelectState } from './useRichSelectState';
|
|
63
63
|
export type { UseRichSelectStateParams, UseRichSelectStateResult } from './useRichSelectState';
|
|
@@ -81,3 +81,7 @@ 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';
|
|
86
|
+
export { useFormulaBar } from './useFormulaBar';
|
|
87
|
+
export type { UseFormulaBarParams, UseFormulaBarResult } from './useFormulaBar';
|
|
@@ -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;
|
|
@@ -41,3 +41,26 @@ export interface UseColumnHeaderMenuStateResult {
|
|
|
41
41
|
* Tracks which column's menu is open, anchor element, and action handlers.
|
|
42
42
|
*/
|
|
43
43
|
export declare function useColumnHeaderMenuState(params: UseColumnHeaderMenuStateParams): UseColumnHeaderMenuStateResult;
|
|
44
|
+
/**
|
|
45
|
+
* Maps a UseColumnHeaderMenuStateResult to the flat ColumnHeaderMenuProps shape.
|
|
46
|
+
* Eliminates the 18-prop spread that each DataGridTable package repeats.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getColumnHeaderMenuProps(headerMenu: UseColumnHeaderMenuStateResult): {
|
|
49
|
+
isOpen: boolean;
|
|
50
|
+
anchorElement: HTMLElement | null;
|
|
51
|
+
onClose: () => void;
|
|
52
|
+
onPinLeft: () => void;
|
|
53
|
+
onPinRight: () => void;
|
|
54
|
+
onUnpin: () => void;
|
|
55
|
+
onSortAsc: () => void;
|
|
56
|
+
onSortDesc: () => void;
|
|
57
|
+
onClearSort: () => void;
|
|
58
|
+
onAutosizeThis: () => void;
|
|
59
|
+
onAutosizeAll: () => void;
|
|
60
|
+
canPinLeft: boolean;
|
|
61
|
+
canPinRight: boolean;
|
|
62
|
+
canUnpin: boolean;
|
|
63
|
+
currentSort: "asc" | "desc" | null;
|
|
64
|
+
isSortable: boolean;
|
|
65
|
+
isResizable: boolean;
|
|
66
|
+
};
|
|
@@ -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;
|
|
@@ -61,6 +61,8 @@ export interface UseDataGridTableOrchestrationResult<T> {
|
|
|
61
61
|
headerRows: HeaderRow<T>[];
|
|
62
62
|
allowOverflowX: boolean;
|
|
63
63
|
fitToContent: boolean;
|
|
64
|
+
showColumnLetters: boolean;
|
|
65
|
+
showNameBox: boolean;
|
|
64
66
|
editCallbacks: {
|
|
65
67
|
commitCellEdit: DataGridEditingState<T>['commitCellEdit'];
|
|
66
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,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useFormulaBar — React hook for formula bar state.
|
|
3
|
+
*
|
|
4
|
+
* Manages the formula bar text, editing mode, and reference extraction.
|
|
5
|
+
*/
|
|
6
|
+
import { type FormulaReference } from '@alaarab/ogrid-core';
|
|
7
|
+
export interface UseFormulaBarParams {
|
|
8
|
+
/** Active cell column index (0-based). */
|
|
9
|
+
activeCol: number | null;
|
|
10
|
+
/** Active cell row index (0-based). */
|
|
11
|
+
activeRow: number | null;
|
|
12
|
+
/** Active cell reference string (e.g. "A1"). */
|
|
13
|
+
activeCellRef: string | null;
|
|
14
|
+
/** Get formula string for a cell. */
|
|
15
|
+
getFormula?: (col: number, row: number) => string | undefined;
|
|
16
|
+
/** Get raw display value for a cell. */
|
|
17
|
+
getRawValue?: (col: number, row: number) => unknown;
|
|
18
|
+
/** Set formula for a cell. */
|
|
19
|
+
setFormula?: (col: number, row: number, formula: string | null) => void;
|
|
20
|
+
/** Commit a non-formula value change. */
|
|
21
|
+
onCellValueChanged?: (col: number, row: number, value: unknown) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface UseFormulaBarResult {
|
|
24
|
+
/** Cell reference string (e.g. "A1"). */
|
|
25
|
+
cellRef: string | null;
|
|
26
|
+
/** Text shown in the formula bar input. */
|
|
27
|
+
formulaText: string;
|
|
28
|
+
/** Whether the formula bar input is being edited. */
|
|
29
|
+
isEditing: boolean;
|
|
30
|
+
/** Update the formula bar input text. */
|
|
31
|
+
onInputChange: (text: string) => void;
|
|
32
|
+
/** Commit the current edit. */
|
|
33
|
+
onCommit: () => void;
|
|
34
|
+
/** Cancel the current edit. */
|
|
35
|
+
onCancel: () => void;
|
|
36
|
+
/** Start editing the formula bar. */
|
|
37
|
+
startEditing: () => void;
|
|
38
|
+
/** References extracted from the current formula text (for highlighting). */
|
|
39
|
+
referencedCells: FormulaReference[];
|
|
40
|
+
/** Whether the formula bar is actively being edited (for click-to-insert-ref guards). */
|
|
41
|
+
isFormulaBarEditing: React.MutableRefObject<boolean>;
|
|
42
|
+
}
|
|
43
|
+
export declare function useFormulaBar(params: UseFormulaBarParams): UseFormulaBarResult;
|
|
@@ -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;
|
|
@@ -32,6 +32,10 @@ export interface UseOGridLayout {
|
|
|
32
32
|
};
|
|
33
33
|
sideBarProps: SideBarProps | null;
|
|
34
34
|
fullScreen?: boolean;
|
|
35
|
+
/** Formula bar element (rendered between toolbar and grid when formulas are enabled). */
|
|
36
|
+
formulaBar?: React.ReactNode;
|
|
37
|
+
/** Sheet tabs element (rendered between grid and footer when sheetDefs are provided). */
|
|
38
|
+
sheetTabs?: React.ReactNode;
|
|
35
39
|
}
|
|
36
40
|
/** Filter state. */
|
|
37
41
|
export interface UseOGridFilters {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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
|
-
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';
|
|
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, ISheetDef, } 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, useFormulaBar, getColumnHeaderMenuProps, } 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, UseFormulaBarParams, UseFormulaBarResult, } 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';
|
|
@@ -14,10 +14,20 @@ export { GridContextMenu } from './components/GridContextMenu';
|
|
|
14
14
|
export type { GridContextMenuProps, GridContextMenuClassNames } from './components/GridContextMenu';
|
|
15
15
|
export { MarchingAntsOverlay } from './components/MarchingAntsOverlay';
|
|
16
16
|
export type { MarchingAntsOverlayProps } from './components/MarchingAntsOverlay';
|
|
17
|
+
export { FormulaBar } from './components/FormulaBar';
|
|
18
|
+
export type { FormulaBarProps } from './components/FormulaBar';
|
|
19
|
+
export { FormulaRefOverlay } from './components/FormulaRefOverlay';
|
|
20
|
+
export type { FormulaRefOverlayProps } from './components/FormulaRefOverlay';
|
|
21
|
+
export { SheetTabs } from './components/SheetTabs';
|
|
22
|
+
export type { SheetTabsProps } from './components/SheetTabs';
|
|
17
23
|
export { SideBar } from './components/SideBar';
|
|
18
24
|
export type { SideBarProps, SideBarFilterColumn } from './components/SideBar';
|
|
19
25
|
export { BaseColumnHeaderMenu } from './components/BaseColumnHeaderMenu';
|
|
20
26
|
export type { BaseColumnHeaderMenuProps, ColumnHeaderMenuClassNames } from './components/BaseColumnHeaderMenu';
|
|
27
|
+
export { PaginationControlsBase } from './components/PaginationControlsBase';
|
|
28
|
+
export type { PaginationControlsBaseProps, PaginationControlsBaseClassNames, IPaginationControlsSlots, INavButtonSlotProps, IPageButtonSlotProps, IPageSizeSelectSlotProps, IOuterContainerSlotProps, } from './components/PaginationControlsBase';
|
|
29
|
+
export { ColumnChooserContent } from './components/ColumnChooserContent';
|
|
30
|
+
export type { ColumnChooserContentProps, ColumnChooserContentClassNames, IColumnChooserCheckboxItemProps, IColumnChooserActionsProps, IColumnChooserHeaderProps, } from './components/ColumnChooserContent';
|
|
21
31
|
export { createOGrid } from './components/createOGrid';
|
|
22
32
|
export type { CreateOGridComponents, GridRowProps, InlineCellEditorProps } from './components/createOGrid';
|
|
23
33
|
export { CellErrorBoundary } from './components/CellErrorBoundary';
|
|
@@ -32,9 +42,9 @@ export { BaseDropIndicator } from './components/BaseDropIndicator';
|
|
|
32
42
|
export type { BaseDropIndicatorProps } from './components/BaseDropIndicator';
|
|
33
43
|
export { DateFilterContent, getColumnHeaderFilterStateParams, getDateFilterContentProps, } from './components/ColumnHeaderFilterContent';
|
|
34
44
|
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, partitionColumnsForVirtualization, areGridRowPropsEqual, findCtrlArrowTarget, computeTabNavigation, rangesEqual, clampSelectionToBounds, computeAutoScrollSpeed, formatCellValueForTsv, formatSelectionAsTsv, parseTsvClipboard, UndoRedoStack, } from './utils';
|
|
45
|
+
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
46
|
export type { CsvColumn, StatusBarPart, StatusBarPartsInput, GridContextMenuItem, GridContextMenuHandlerProps, PaginationViewModel, HeaderFilterConfigInput, HeaderFilterConfig, CellRenderDescriptorInput, CellRenderDescriptor, CellRenderMode, CellInteractionHandlers, ParseValueResult, AggregationResult, GridRowComparatorProps, IColumnHeaderMenuItem, ColumnHeaderMenuInput, ColumnHeaderMenuHandlers, } from './utils';
|
|
37
|
-
export { renderFilterContent } from './components/ColumnHeaderFilterRenderers';
|
|
47
|
+
export { renderFilterContent, createBaseFilterRenderers } from './components/ColumnHeaderFilterRenderers';
|
|
38
48
|
export type { FilterContentRenderers, MultiSelectRendererProps, TextRendererProps, PeopleRendererProps, DateRendererProps, } from './components/ColumnHeaderFilterRenderers';
|
|
39
49
|
export type { IColumnChooserProps } from './components/ColumnChooserProps';
|
|
40
50
|
export type { IPaginationControlsProps } from './components/PaginationControlsProps';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { IColumnDef, IColumnGroupDef, ICellValueChangedEvent } from './columnTypes';
|
|
3
|
-
|
|
3
|
+
import type { IFormulaFunction, IRecalcResult, IGridDataAccessor, IAuditEntry, IAuditTrail } from '@alaarab/ogrid-core';
|
|
4
|
+
export type { RowId, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, RowSelectionMode, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, SideBarPanelId, ISideBarDef, ISheetDef, IVirtualScrollConfig, IColumnReorderConfig, IOGridApi, } from '@alaarab/ogrid-core';
|
|
4
5
|
export { toUserLike, isInSelectionRange, normalizeSelectionRange } from '@alaarab/ogrid-core';
|
|
5
|
-
import type { RowId, UserLike, IFilters, FilterValue, RowSelectionMode, IRowSelectionChangeEvent, IStatusBarProps, IDataSource, ISideBarDef, IVirtualScrollConfig } from '@alaarab/ogrid-core';
|
|
6
|
+
import type { RowId, UserLike, IFilters, FilterValue, RowSelectionMode, IRowSelectionChangeEvent, IStatusBarProps, IDataSource, ISideBarDef, ISheetDef, IVirtualScrollConfig } from '@alaarab/ogrid-core';
|
|
6
7
|
/** Base props shared by both client-side and server-side OGrid modes. */
|
|
7
8
|
interface IOGridBaseProps<T> {
|
|
8
9
|
columns: (IColumnDef<T> | IColumnGroupDef<T>)[];
|
|
@@ -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;
|
|
@@ -94,6 +97,30 @@ interface IOGridBaseProps<T> {
|
|
|
94
97
|
onError?: (error: unknown) => void;
|
|
95
98
|
/** Called when a cell renderer or custom editor throws an error. */
|
|
96
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>;
|
|
116
|
+
/** Sheet definitions for bottom tab bar. When set, renders Excel-style sheet tabs. */
|
|
117
|
+
sheetDefs?: ISheetDef[];
|
|
118
|
+
/** Currently active sheet id. */
|
|
119
|
+
activeSheet?: string;
|
|
120
|
+
/** Called when the user switches sheets. */
|
|
121
|
+
onSheetChange?: (sheetId: string) => void;
|
|
122
|
+
/** Called when the user clicks the add-sheet button. */
|
|
123
|
+
onSheetAdd?: () => void;
|
|
97
124
|
'aria-label'?: string;
|
|
98
125
|
'aria-labelledby'?: string;
|
|
99
126
|
}
|
|
@@ -152,6 +179,12 @@ export interface IOGridDataGridProps<T> {
|
|
|
152
179
|
onSelectionChange?: (event: IRowSelectionChangeEvent<T>) => void;
|
|
153
180
|
/** Show Excel-style row numbers column. */
|
|
154
181
|
showRowNumbers?: boolean;
|
|
182
|
+
/** Show Excel-style column letter headers (A, B, C...) above the header row. */
|
|
183
|
+
showColumnLetters?: boolean;
|
|
184
|
+
/** Show a name box displaying the active cell reference (e.g. "A1"). */
|
|
185
|
+
showNameBox?: boolean;
|
|
186
|
+
/** Callback when the active cell changes. Used by the name box to display the current cell reference. */
|
|
187
|
+
onActiveCellChange?: (ref: string | null) => void;
|
|
155
188
|
/** Current page number (1-based) for row number calculation. */
|
|
156
189
|
currentPage?: number;
|
|
157
190
|
/** Page size for row number calculation. */
|
|
@@ -185,4 +218,26 @@ export interface IOGridDataGridProps<T> {
|
|
|
185
218
|
'aria-labelledby'?: string;
|
|
186
219
|
/** Custom keydown handler. Called before grid's built-in handling. Call event.preventDefault() to suppress grid default. */
|
|
187
220
|
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
221
|
+
/** Enable formula support. When true, cell values starting with '=' are treated as formulas. */
|
|
222
|
+
formulas?: boolean;
|
|
223
|
+
/** Get the formula engine's computed value for a cell, or undefined if no formula. */
|
|
224
|
+
getFormulaValue?: (col: number, row: number) => unknown;
|
|
225
|
+
/** Check if a cell has a formula. */
|
|
226
|
+
hasFormula?: (col: number, row: number) => boolean;
|
|
227
|
+
/** Get the formula string for a cell. */
|
|
228
|
+
getFormula?: (col: number, row: number) => string | undefined;
|
|
229
|
+
/** Set a formula for a cell (called from edit commit when value starts with '='). */
|
|
230
|
+
setFormula?: (col: number, row: number, formula: string | null) => void;
|
|
231
|
+
/** Notify the formula engine that a non-formula cell changed. */
|
|
232
|
+
onFormulaCellChanged?: (col: number, row: number) => void;
|
|
233
|
+
/** Get all cells that a cell depends on (deep, transitive). */
|
|
234
|
+
getPrecedents?: (col: number, row: number) => IAuditEntry[];
|
|
235
|
+
/** Get all cells that depend on a cell (deep, transitive). */
|
|
236
|
+
getDependents?: (col: number, row: number) => IAuditEntry[];
|
|
237
|
+
/** Get full audit trail for a cell. */
|
|
238
|
+
getAuditTrail?: (col: number, row: number) => IAuditTrail | null;
|
|
239
|
+
/** Monotonic counter incremented on each formula recalculation — used for cache invalidation. */
|
|
240
|
+
formulaVersion?: number;
|
|
241
|
+
/** Cell references to highlight (from active formula in formula bar). */
|
|
242
|
+
formulaReferences?: import('@alaarab/ogrid-core').FormulaReference[];
|
|
188
243
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type { ColumnFilterType, IColumnFilterDef, IColumnMeta, IColumnDef, IColumnGroupDef, IColumnDefinition, ICellValueChangedEvent, ICellEditorProps, CellEditorParams, IValueParserParams, IDateFilterValue, HeaderCell, HeaderRow, } from './columnTypes';
|
|
2
|
-
export type { RowId, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, IOGridApi, IOGridProps, IOGridClientProps, IOGridServerProps, IOGridDataGridProps, RowSelectionMode, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, SideBarPanelId, ISideBarDef, IVirtualScrollConfig, IColumnReorderConfig, } from './dataGridTypes';
|
|
2
|
+
export type { RowId, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, IOGridApi, IOGridProps, IOGridClientProps, IOGridServerProps, IOGridDataGridProps, RowSelectionMode, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, SideBarPanelId, ISideBarDef, IVirtualScrollConfig, IColumnReorderConfig, ISheetDef, } from './dataGridTypes';
|
|
3
3
|
export { toUserLike, isInSelectionRange, normalizeSelectionRange } from './dataGridTypes';
|
|
@@ -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
|
};
|