@alaarab/ogrid-core 2.3.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 +1919 -108
- package/dist/types/constants/formulaBar.d.ts +60 -0
- package/dist/types/constants/index.d.ts +1 -0
- package/dist/types/formula/functions/financial.d.ts +2 -0
- package/dist/types/formula/functions/reference.d.ts +2 -0
- package/dist/types/formula/functions/statistical-extended.d.ts +2 -0
- package/dist/types/formula/types.d.ts +2 -0
- package/dist/types/index.d.ts +5 -2
- package/dist/types/types/dataGridTypes.d.ts +7 -0
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/utils/cellValue.d.ts +6 -0
- package/dist/types/utils/dataGridViewModel.d.ts +6 -0
- package/dist/types/utils/formulaBarHelpers.d.ts +40 -0
- package/dist/types/utils/index.d.ts +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formula bar and formula reference highlighting constants.
|
|
3
|
+
* Shared across React, Angular, Vue, and JS packages.
|
|
4
|
+
*/
|
|
5
|
+
/** Color palette for formula reference highlights (cycles 0–5). Uses CSS vars with fallbacks. */
|
|
6
|
+
export declare const FORMULA_REF_COLORS: readonly ["var(--ogrid-formula-ref-0, #4285f4)", "var(--ogrid-formula-ref-1, #ea4335)", "var(--ogrid-formula-ref-2, #34a853)", "var(--ogrid-formula-ref-3, #9334e6)", "var(--ogrid-formula-ref-4, #ff6d01)", "var(--ogrid-formula-ref-5, #46bdc6)"];
|
|
7
|
+
/** CSS text for the formula bar container (used by JS and Angular inline styles). */
|
|
8
|
+
export declare const FORMULA_BAR_CSS: {
|
|
9
|
+
readonly bar: "display:flex;align-items:center;border-bottom:1px solid var(--ogrid-border, #e0e0e0);background:var(--ogrid-bg, #fff);min-height:28px;font-size:13px;";
|
|
10
|
+
readonly nameBox: "font-family:monospace;font-size:12px;font-weight:500;padding:2px 8px;border-right:1px solid var(--ogrid-border, #e0e0e0);background:var(--ogrid-bg, #fff);color:var(--ogrid-fg, #242424);min-width:52px;text-align:center;line-height:24px;user-select:none;white-space:nowrap;";
|
|
11
|
+
readonly fxLabel: "padding:2px 8px;font-style:italic;font-weight:600;color:var(--ogrid-muted-fg, #888);user-select:none;border-right:1px solid var(--ogrid-border, #e0e0e0);line-height:24px;font-size:12px;";
|
|
12
|
+
readonly input: "flex:1;border:none;outline:none;padding:2px 8px;font-family:monospace;font-size:12px;line-height:24px;background:transparent;color:var(--ogrid-fg, #242424);min-width:0;";
|
|
13
|
+
};
|
|
14
|
+
/** Style objects for the formula bar — used by React and Vue (CSSProperties-compatible). */
|
|
15
|
+
export declare const FORMULA_BAR_STYLES: {
|
|
16
|
+
readonly bar: {
|
|
17
|
+
readonly display: "flex";
|
|
18
|
+
readonly alignItems: "center";
|
|
19
|
+
readonly borderBottom: "1px solid var(--ogrid-border, #e0e0e0)";
|
|
20
|
+
readonly background: "var(--ogrid-bg, #fff)";
|
|
21
|
+
readonly minHeight: "28px";
|
|
22
|
+
readonly fontSize: "13px";
|
|
23
|
+
};
|
|
24
|
+
readonly nameBox: {
|
|
25
|
+
readonly fontFamily: "monospace";
|
|
26
|
+
readonly fontSize: "12px";
|
|
27
|
+
readonly fontWeight: 500;
|
|
28
|
+
readonly padding: "2px 8px";
|
|
29
|
+
readonly borderRight: "1px solid var(--ogrid-border, #e0e0e0)";
|
|
30
|
+
readonly background: "var(--ogrid-bg, #fff)";
|
|
31
|
+
readonly color: "var(--ogrid-fg, #242424)";
|
|
32
|
+
readonly minWidth: "52px";
|
|
33
|
+
readonly textAlign: "center";
|
|
34
|
+
readonly lineHeight: "24px";
|
|
35
|
+
readonly userSelect: "none";
|
|
36
|
+
readonly whiteSpace: "nowrap";
|
|
37
|
+
};
|
|
38
|
+
readonly fxLabel: {
|
|
39
|
+
readonly padding: "2px 8px";
|
|
40
|
+
readonly fontStyle: "italic";
|
|
41
|
+
readonly fontWeight: 600;
|
|
42
|
+
readonly color: "var(--ogrid-muted-fg, #888)";
|
|
43
|
+
readonly userSelect: "none";
|
|
44
|
+
readonly borderRight: "1px solid var(--ogrid-border, #e0e0e0)";
|
|
45
|
+
readonly lineHeight: "24px";
|
|
46
|
+
readonly fontSize: "12px";
|
|
47
|
+
};
|
|
48
|
+
readonly input: {
|
|
49
|
+
readonly flex: 1;
|
|
50
|
+
readonly border: "none";
|
|
51
|
+
readonly outline: "none";
|
|
52
|
+
readonly padding: "2px 8px";
|
|
53
|
+
readonly fontFamily: "monospace";
|
|
54
|
+
readonly fontSize: "12px";
|
|
55
|
+
readonly lineHeight: "24px";
|
|
56
|
+
readonly background: "transparent";
|
|
57
|
+
readonly color: "var(--ogrid-fg, #242424)";
|
|
58
|
+
readonly minWidth: 0;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -2,3 +2,4 @@ export { CHECKBOX_COLUMN_WIDTH, ROW_NUMBER_COLUMN_WIDTH, DEFAULT_MIN_COLUMN_WIDT
|
|
|
2
2
|
export { DEFAULT_DEBOUNCE_MS, PEOPLE_SEARCH_DEBOUNCE_MS, SIDEBAR_TRANSITION_MS, } from './timing';
|
|
3
3
|
export { Z_INDEX } from './zIndex';
|
|
4
4
|
export type { ZIndexKey } from './zIndex';
|
|
5
|
+
export { FORMULA_REF_COLORS, FORMULA_BAR_CSS, FORMULA_BAR_STYLES } from './formulaBar';
|
|
@@ -80,6 +80,8 @@ export interface IFormulaContext {
|
|
|
80
80
|
getCellValue(address: ICellAddress): unknown;
|
|
81
81
|
getRangeValues(range: ICellRange): unknown[][];
|
|
82
82
|
now(): Date;
|
|
83
|
+
/** Optional: return the formula string for a cell, or undefined if not a formula cell. */
|
|
84
|
+
getCellFormula?(address: ICellAddress): string | undefined;
|
|
83
85
|
}
|
|
84
86
|
/** A registered formula function. */
|
|
85
87
|
export interface IFormulaFunction {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export type { ColumnFilterType, IDateFilterValue, IColumnFilterDef, IColumnMeta, IValueParserParams, IColumnDef, ICellValueChangedEvent, ICellEditorProps, CellEditorParams, IColumnGroupDef, HeaderCell, HeaderRow, IColumnDefinition, } from './types';
|
|
2
|
-
export type { RowId, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, RowSelectionMode, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, SideBarPanelId, ISideBarDef, IVirtualScrollConfig, IColumnReorderConfig, IOGridApi, } from './types';
|
|
2
|
+
export type { RowId, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, RowSelectionMode, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, SideBarPanelId, ISideBarDef, ISheetDef, IVirtualScrollConfig, IColumnReorderConfig, IOGridApi, } from './types';
|
|
3
3
|
export { toUserLike, isInSelectionRange, normalizeSelectionRange, } from './types';
|
|
4
4
|
export { escapeCsvValue, buildCsvHeader, buildCsvRows, exportToCsv, triggerCsvDownload, } from './utils';
|
|
5
5
|
export type { CsvColumn, FormulaExportOptions } from './utils';
|
|
6
|
-
export { getCellValue, isColumnEditable } from './utils';
|
|
6
|
+
export { getCellValue, isColumnEditable, createGridDataAccessor } from './utils';
|
|
7
7
|
export { flattenColumns, buildHeaderRows } from './utils';
|
|
8
8
|
export { isFilterConfig, getFilterField, mergeFilter, deriveFilterOptionsFromData, getMultiSelectFilterFields, } from './utils';
|
|
9
9
|
export { getStatusBarParts } from './utils';
|
|
@@ -43,9 +43,12 @@ export type { IFillFormulaOptions } from './utils';
|
|
|
43
43
|
export { UndoRedoStack } from './utils';
|
|
44
44
|
export { validateColumns, validateRowIds, validateVirtualScrollConfig } from './utils';
|
|
45
45
|
export { indexToColumnLetter, formatCellReference } from './utils';
|
|
46
|
+
export { extractFormulaReferences, processFormulaBarCommit, deriveFormulaBarText, handleFormulaBarKeyDown } from './utils';
|
|
47
|
+
export type { FormulaReference } from './utils';
|
|
46
48
|
export { CHECKBOX_COLUMN_WIDTH, ROW_NUMBER_COLUMN_WIDTH, DEFAULT_MIN_COLUMN_WIDTH, CELL_PADDING, GRID_BORDER_RADIUS, } from './constants';
|
|
47
49
|
export { DEFAULT_DEBOUNCE_MS, PEOPLE_SEARCH_DEBOUNCE_MS, SIDEBAR_TRANSITION_MS, } from './constants';
|
|
48
50
|
export { Z_INDEX } from './constants';
|
|
49
51
|
export type { ZIndexKey } from './constants';
|
|
52
|
+
export { FORMULA_REF_COLORS, FORMULA_BAR_CSS, FORMULA_BAR_STYLES } from './constants';
|
|
50
53
|
export { FormulaError, FormulaEngine, FormulaEvaluator, DependencyGraph, tokenize, parse, createBuiltInFunctions, columnLetterToIndex, parseCellRef, parseRange, formatAddress, toCellKey, fromCellKey, adjustFormulaReferences, toNumber, toString as formulaToString, toBoolean, flattenArgs, isFormulaError, REF_ERROR, DIV_ZERO_ERROR, VALUE_ERROR, NAME_ERROR, CIRC_ERROR, GENERAL_ERROR, NA_ERROR, } from './formula';
|
|
51
54
|
export type { ICellAddress, ICellRange, CellKey, FormulaErrorType, TokenType, Token, ASTNode, BinaryOp, IFormulaContext, IFormulaFunction, IEvaluator, IRecalcResult, IFormulaEngineConfig, IGridDataAccessor, INamedRange, IAuditEntry, IAuditTrail, } from './formula';
|
|
@@ -128,6 +128,13 @@ export interface ISideBarDef {
|
|
|
128
128
|
/** Position of the side bar (default: 'right'). */
|
|
129
129
|
position?: 'left' | 'right';
|
|
130
130
|
}
|
|
131
|
+
/** Definition for a sheet tab. */
|
|
132
|
+
export interface ISheetDef {
|
|
133
|
+
id: string;
|
|
134
|
+
name: string;
|
|
135
|
+
/** Optional tab color (CSS value). */
|
|
136
|
+
color?: string;
|
|
137
|
+
}
|
|
131
138
|
/** Configuration for virtual scrolling. */
|
|
132
139
|
export interface IVirtualScrollConfig {
|
|
133
140
|
/** Enable virtual scrolling (default: false). */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type { ColumnFilterType, IDateFilterValue, IColumnFilterDef, IColumnMeta, IValueParserParams, IColumnDef, ICellValueChangedEvent, ICellEditorProps, CellEditorParams, IColumnGroupDef, HeaderCell, HeaderRow, IColumnDefinition, } from './columnTypes';
|
|
2
|
-
export type { RowId, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, RowSelectionMode, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, SideBarPanelId, ISideBarDef, IVirtualScrollConfig, IColumnReorderConfig, IOGridApi, } from './dataGridTypes';
|
|
2
|
+
export type { RowId, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, RowSelectionMode, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, SideBarPanelId, ISideBarDef, ISheetDef, IVirtualScrollConfig, IColumnReorderConfig, IOGridApi, } from './dataGridTypes';
|
|
3
3
|
export { toUserLike, isInSelectionRange, normalizeSelectionRange, } from './dataGridTypes';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IColumnDef } from '../types/columnTypes';
|
|
2
|
+
import type { IGridDataAccessor } from '../formula/types';
|
|
2
3
|
/**
|
|
3
4
|
* Get the cell value for a row/column, using valueGetter when defined otherwise item[columnId].
|
|
4
5
|
*
|
|
@@ -14,3 +15,8 @@ export declare function getCellValue<T>(item: T, col: IColumnDef<T>): unknown;
|
|
|
14
15
|
* Handles both boolean and function-based `editable` definitions.
|
|
15
16
|
*/
|
|
16
17
|
export declare function isColumnEditable<T>(col: IColumnDef<T>, item: T): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Create an IGridDataAccessor from items and flat columns.
|
|
20
|
+
* Shared factory used by React, Angular, Vue, and JS formula engine integrations.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createGridDataAccessor<T>(items: T[], flatColumns: IColumnDef<T>[]): IGridDataAccessor;
|
|
@@ -75,6 +75,12 @@ export interface CellRenderDescriptorInput<T> {
|
|
|
75
75
|
onCellValueChanged?: unknown;
|
|
76
76
|
/** True while user is drag-selecting cells — hides fill handle during drag. */
|
|
77
77
|
isDragging?: boolean;
|
|
78
|
+
/** Get the formula engine's computed value for a cell (colIdx, rowIndex). */
|
|
79
|
+
getFormulaValue?: (col: number, row: number) => unknown;
|
|
80
|
+
/** Check if a cell has a formula at the given coordinate. */
|
|
81
|
+
hasFormula?: (col: number, row: number) => boolean;
|
|
82
|
+
/** Monotonic counter incremented on each formula recalculation — used for cache invalidation. */
|
|
83
|
+
formulaVersion?: number;
|
|
78
84
|
}
|
|
79
85
|
export interface CellRenderDescriptor {
|
|
80
86
|
mode: CellRenderMode;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formula bar helper utilities.
|
|
3
|
+
*
|
|
4
|
+
* Extracts cell/range references from a formula string for highlighting.
|
|
5
|
+
* Uses the formula tokenizer to parse CELL_REF and range tokens.
|
|
6
|
+
*/
|
|
7
|
+
/** A parsed reference from a formula — either a single cell or a range. */
|
|
8
|
+
export interface FormulaReference {
|
|
9
|
+
type: 'cell' | 'range';
|
|
10
|
+
col: number;
|
|
11
|
+
row: number;
|
|
12
|
+
endCol?: number;
|
|
13
|
+
endRow?: number;
|
|
14
|
+
/** Color palette index (cycles through 0-5). */
|
|
15
|
+
colorIndex: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Extract all cell and range references from a formula string.
|
|
19
|
+
* Each reference gets a cycling colorIndex for UI highlighting.
|
|
20
|
+
*
|
|
21
|
+
* @param formula - The formula string including the leading '='.
|
|
22
|
+
* @returns Array of references found in the formula.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Handle Enter/Escape key events in the formula bar input.
|
|
26
|
+
* Shared across React, Angular, Vue, and JS.
|
|
27
|
+
*/
|
|
28
|
+
export declare function handleFormulaBarKeyDown(key: string, preventDefault: () => void, onCommit: () => void, onCancel: () => void): void;
|
|
29
|
+
/**
|
|
30
|
+
* Process a formula bar commit: if the text starts with '=', set as formula;
|
|
31
|
+
* otherwise clear any existing formula and commit as a plain value.
|
|
32
|
+
*/
|
|
33
|
+
export declare function processFormulaBarCommit(text: string, col: number, row: number, setFormula: (col: number, row: number, formula: string | null) => void, onCellValueChanged?: (col: number, row: number, value: unknown) => void): void;
|
|
34
|
+
/**
|
|
35
|
+
* Derive the display text for a formula bar from the active cell.
|
|
36
|
+
* Returns the formula string (with '=' prefix) if the cell has a formula,
|
|
37
|
+
* otherwise the stringified raw value.
|
|
38
|
+
*/
|
|
39
|
+
export declare function deriveFormulaBarText(col: number | null, row: number | null, getFormula?: (col: number, row: number) => string | undefined, getRawValue?: (col: number, row: number) => unknown): string;
|
|
40
|
+
export declare function extractFormulaReferences(formula: string): FormulaReference[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { escapeCsvValue, buildCsvHeader, buildCsvRows, exportToCsv, triggerCsvDownload, } from './exportToCsv';
|
|
2
|
-
export { getCellValue, isColumnEditable } from './cellValue';
|
|
2
|
+
export { getCellValue, isColumnEditable, createGridDataAccessor } from './cellValue';
|
|
3
3
|
export { flattenColumns, buildHeaderRows } from './columnUtils';
|
|
4
4
|
export { isFilterConfig, getFilterField, mergeFilter, deriveFilterOptionsFromData, getMultiSelectFilterFields, } from './ogridHelpers';
|
|
5
5
|
export { getStatusBarParts } from './statusBarHelpers';
|
|
@@ -40,3 +40,5 @@ export type { IFillFormulaOptions } from './fillHelpers';
|
|
|
40
40
|
export { UndoRedoStack } from './undoRedoStack';
|
|
41
41
|
export { validateColumns, validateRowIds, validateVirtualScrollConfig } from './validation';
|
|
42
42
|
export { indexToColumnLetter, formatCellReference } from './cellReference';
|
|
43
|
+
export { extractFormulaReferences, processFormulaBarCommit, deriveFormulaBarText, handleFormulaBarKeyDown } from './formulaBarHelpers';
|
|
44
|
+
export type { FormulaReference } from './formulaBarHelpers';
|
package/package.json
CHANGED