@guiexpert/table 1.1.97 → 1.1.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/css/main.css +381 -27
- package/css/table-classes.css +33 -9
- package/css/table-clipboard.css +41 -0
- package/css/table-color-vars.css +56 -0
- package/css/table-fill-batch.css +9 -2
- package/css/table-master-detail.css +20 -0
- package/css/table-sheet-editing.css +149 -0
- package/css/table-spreadsheet.css +50 -0
- package/css/table-tree.css +23 -16
- package/index.cjs +54 -67
- package/index.d.ts +52 -0
- package/index.js +18968 -11475
- package/lib/table/action/action-id.type.d.ts +1 -1
- package/lib/table/action/shortcut.service.d.ts +9 -0
- package/lib/table/aria/aria-texts.d.ts +26 -0
- package/lib/table/aria/aria-texts.if.d.ts +196 -0
- package/lib/table/batch-edit/batch-edit-service.d.ts +22 -0
- package/lib/table/batch-edit/cell-change.if.d.ts +6 -2
- package/lib/table/batch-edit/pending-cell-changes.d.ts +7 -0
- package/lib/table/batch-edit/write-row-value.d.ts +14 -0
- package/lib/table/calc/column-values.d.ts +2 -0
- package/lib/table/clipboard/clipboard-html.d.ts +41 -0
- package/lib/table/clipboard/clipboard-keymap.d.ts +18 -0
- package/lib/table/clipboard/clipboard-options.d.ts +30 -0
- package/lib/table/clipboard/clipboard-options.if.d.ts +67 -0
- package/lib/table/clipboard/clipboard-service.d.ts +122 -0
- package/lib/table/clipboard/input-pipes.d.ts +59 -0
- package/lib/table/clipboard/paste-plan.d.ts +96 -0
- package/lib/table/clipboard/tsv.d.ts +31 -0
- package/lib/table/crud/crud-object-edit.d.ts +2 -0
- package/lib/table/crud/crud-object-view.d.ts +2 -0
- package/lib/table/crud/crud-table-model-factory.d.ts +2 -0
- package/lib/table/data/common/event/ge-edit-event.d.ts +46 -0
- package/lib/table/data/common/event/ge-row-drag-event.d.ts +2 -2
- package/lib/table/data/common/event/ge-undo-event.d.ts +29 -0
- package/lib/table/data/options/table-options.d.ts +34 -0
- package/lib/table/data/options/table-options.if.d.ts +116 -1
- package/lib/table/data/tablemodel/areamodel/abstract-area-model.d.ts +11 -2
- package/lib/table/data/tablemodel/areamodel/area-model-array-of-arrays.d.ts +14 -0
- package/lib/table/data/tablemodel/areamodel/area-model-object-array.d.ts +14 -0
- package/lib/table/data/tablemodel/areamodel/area-model.if.d.ts +11 -0
- package/lib/table/data/tablemodel/column/column-def.d.ts +13 -0
- package/lib/table/data/tablemodel/column/column-def.if.d.ts +36 -1
- package/lib/table/data/tablemodel/column/default-editable.d.ts +18 -0
- package/lib/table/ele-scope.d.ts +37 -0
- package/lib/table/event-adapter.d.ts +6 -0
- package/lib/table/event-listener-hub.d.ts +10 -0
- package/lib/table/event-listener.if.d.ts +16 -0
- package/lib/table/factory/pivot-factory.d.ts +1 -1
- package/lib/table/factory/row-group-factory.d.ts +1 -1
- package/lib/table/factory/table-factory.d.ts +14 -0
- package/lib/table/formula/formula-ast.if.d.ts +32 -2
- package/lib/table/formula/formula-error.d.ts +4 -2
- package/lib/table/formula/parser.d.ts +5 -2
- package/lib/table/formula/tokenizer.d.ts +5 -2
- package/lib/table/input-handler.d.ts +8 -0
- package/lib/table/master-detail/master-detail-service.d.ts +9 -0
- package/lib/table/render-scope.d.ts +40 -0
- package/lib/table/row-drag/row-drag-service.d.ts +3 -2
- package/lib/table/rtl/rtl-util.d.ts +126 -0
- package/lib/table/rtl/table-direction.type.d.ts +23 -0
- package/lib/table/selection/selection-service.d.ts +48 -0
- package/lib/table/service/convenience-dom.service.d.ts +49 -1
- package/lib/table/service/excel-export-options.if.d.ts +23 -0
- package/lib/table/service/excel-service.d.ts +12 -2
- package/lib/table/service/excel-service.if.d.ts +38 -1
- package/lib/table/sheet/cell-address.d.ts +100 -0
- package/lib/table/sheet/cell-formula-options.d.ts +27 -0
- package/lib/table/sheet/cell-formula-options.if.d.ts +27 -0
- package/lib/table/sheet/excel-formula.d.ts +20 -0
- package/lib/table/sheet/format-formula.d.ts +19 -0
- package/lib/table/sheet/sheet-cells.if.d.ts +17 -0
- package/lib/table/sheet/sheet-compiler.d.ts +47 -0
- package/lib/table/sheet/sheet-engine.d.ts +207 -0
- package/lib/table/sheet/sheet-function-info.d.ts +25 -0
- package/lib/table/sheet/sheet-functions.d.ts +27 -0
- package/lib/table/sheet/sheet-values.d.ts +154 -0
- package/lib/table/sheet/shift-formula.d.ts +71 -0
- package/lib/table/sheet/table-sheet.d.ts +214 -0
- package/lib/table/sheet-editing/cell-editor-service.d.ts +105 -0
- package/lib/table/sheet-editing/cell-editor.if.d.ts +110 -0
- package/lib/table/sheet-editing/editing-keymap.d.ts +17 -0
- package/lib/table/sheet-editing/editing-options.d.ts +34 -0
- package/lib/table/sheet-editing/editing-options.if.d.ts +49 -0
- package/lib/table/sheet-editing/editors/date-cell-editor.d.ts +23 -0
- package/lib/table/sheet-editing/editors/number-cell-editor.d.ts +18 -0
- package/lib/table/sheet-editing/editors/select-cell-editor.d.ts +36 -0
- package/lib/table/sheet-editing/editors/text-cell-editor.d.ts +35 -0
- package/lib/table/sheet-editing/formula-assist.d.ts +103 -0
- package/lib/table/sheet-editing/formula-text.d.ts +61 -0
- package/lib/table/sheet-editing/sheet-navigation.d.ts +26 -0
- package/lib/table/spreadsheet/area-model-sheet.d.ts +170 -0
- package/lib/table/spreadsheet/formula-bar.d.ts +53 -0
- package/lib/table/spreadsheet/spreadsheet-factory.d.ts +111 -0
- package/lib/table/spreadsheet/spreadsheet-options.if.d.ts +28 -0
- package/lib/table/spreadsheet/spreadsheet-preset.d.ts +37 -0
- package/lib/table/spreadsheet/structure-edit.d.ts +35 -0
- package/lib/table/table-api.d.ts +533 -4
- package/lib/table/table-scope.d.ts +299 -1
- package/lib/table/undo/cell-changes-undoable.d.ts +34 -0
- package/lib/table/undo/model-rows.d.ts +17 -0
- package/lib/table/undo/pending-changes-undoable.d.ts +35 -0
- package/lib/table/undo/undo-keymap.d.ts +17 -0
- package/lib/table/undo/undo-options.d.ts +26 -0
- package/lib/table/undo/undo-options.if.d.ts +30 -0
- package/lib/table/undo/undo-service.d.ts +103 -0
- package/lib/table/undo/undo-stack.d.ts +62 -0
- package/lib/table/undo/undoable.if.d.ts +36 -0
- package/package.json +1 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { TableScope } from '../table-scope.js';
|
|
2
|
+
import { TableSheet } from '../sheet/table-sheet.js';
|
|
3
|
+
import { CellEditMode } from './cell-editor.if.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The formula input of the cell editor (prompt 013 stage 6, `tableOptions.cellFormulas`): pointing (arrow keys, Shift
|
|
7
|
+
* + arrow keys, a click or a drag insert references while the caret stands at an insertion point), F4 (`$`), colored
|
|
8
|
+
* references in the text (a mirror behind the transparent text of the input) with frames around the referenced cells,
|
|
9
|
+
* function suggestions (an ARIA combobox with a listbox) and the argument hint (a tooltip). Created by the
|
|
10
|
+
* {@link CellEditorService} for a text field in a formula column.
|
|
11
|
+
*
|
|
12
|
+
* @category Internals
|
|
13
|
+
* @since 1.1.99
|
|
14
|
+
*/
|
|
15
|
+
export declare class FormulaAssist {
|
|
16
|
+
private readonly scope;
|
|
17
|
+
private readonly sheet;
|
|
18
|
+
private readonly input;
|
|
19
|
+
private readonly editedCell;
|
|
20
|
+
private readonly changed;
|
|
21
|
+
private readonly mirror;
|
|
22
|
+
private readonly list;
|
|
23
|
+
private readonly hint;
|
|
24
|
+
private frames;
|
|
25
|
+
private suggestions;
|
|
26
|
+
private active;
|
|
27
|
+
/** Escape closed the list: it stays closed until the text changes. */
|
|
28
|
+
private listClosed;
|
|
29
|
+
private pointer?;
|
|
30
|
+
private cellCache?;
|
|
31
|
+
private composing;
|
|
32
|
+
private drag?;
|
|
33
|
+
private readonly abort;
|
|
34
|
+
private readonly ids;
|
|
35
|
+
private readonly functions;
|
|
36
|
+
constructor(scope: TableScope, sheet: TableSheet, input: HTMLInputElement, container: HTMLDivElement, editedCell: () => [number, number], changed: () => void, idPrefix: string);
|
|
37
|
+
/**
|
|
38
|
+
* A key in the editor: the suggestion list, F4 and pointing. True if it was used (the caller stops it).
|
|
39
|
+
*
|
|
40
|
+
* @param {KeyboardEvent} evt - the key
|
|
41
|
+
* @param {CellEditMode} mode - "enter" (typing) or "edit" (F2: arrow keys move the caret)
|
|
42
|
+
* @returns {boolean} true if handled
|
|
43
|
+
*/
|
|
44
|
+
onKeyDown(evt: KeyboardEvent, mode: CellEditMode): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* A pointer press outside the editor: while pointing is possible, a body cell is inserted as reference (Shift: a
|
|
47
|
+
* range from the last pointed cell) and dragging spans a range. True if it was used – the click then neither
|
|
48
|
+
* commits nor moves the selection.
|
|
49
|
+
*
|
|
50
|
+
* @param {PointerEvent} evt - the press
|
|
51
|
+
* @returns {boolean} true if handled
|
|
52
|
+
*/
|
|
53
|
+
onPointerDown(evt: PointerEvent): boolean;
|
|
54
|
+
/** @returns {string[]} the ids of the suggestion list and the hint (owned by the edited cell, `aria-owns`) */
|
|
55
|
+
getOwnedIds(): string[];
|
|
56
|
+
/** Places the frames and the popups (after every render pass and on changes). */
|
|
57
|
+
update(): void;
|
|
58
|
+
/** Removes everything (the editor closes). */
|
|
59
|
+
destroy(): void;
|
|
60
|
+
private texts;
|
|
61
|
+
private onInput;
|
|
62
|
+
private caret;
|
|
63
|
+
private collapsed;
|
|
64
|
+
/** Pointing: right after an inserted reference, or (typing mode) at an insertion point. */
|
|
65
|
+
private canPoint;
|
|
66
|
+
/** The next cell in a direction: rows clamped, columns over shown data columns. */
|
|
67
|
+
private step;
|
|
68
|
+
/** The reference text of a pointed range: one cell or the bounding range (physical rows, data columns). */
|
|
69
|
+
private referenceText;
|
|
70
|
+
/** True if the display rows d1…d2 are exactly the physical rows p1…p2 (in any order). */
|
|
71
|
+
private isContiguous;
|
|
72
|
+
/** Inserts (or replaces the last pointed) reference at the caret. */
|
|
73
|
+
private point;
|
|
74
|
+
private startDrag;
|
|
75
|
+
/** F4: the next `$` form of the reference at (or right before) the caret. */
|
|
76
|
+
private toggleReferenceAtCaret;
|
|
77
|
+
private isListOpen;
|
|
78
|
+
/** Takes a suggestion: the typed name becomes `NAME(`. */
|
|
79
|
+
private accept;
|
|
80
|
+
/** The caret moved: list and hint follow (no new colors needed). */
|
|
81
|
+
private refreshCaret;
|
|
82
|
+
private refresh;
|
|
83
|
+
private syncScroll;
|
|
84
|
+
/** The colors of the references: by first occurrence, the same reference the same color. */
|
|
85
|
+
private colored;
|
|
86
|
+
private renderMirror;
|
|
87
|
+
/** One frame per referenced cell or range that is shown (a reference to a hidden row has none). */
|
|
88
|
+
private renderFrames;
|
|
89
|
+
/** The visible rectangle of a reference in host coordinates, `undefined` if nothing of it is shown. */
|
|
90
|
+
private frameRect;
|
|
91
|
+
/**
|
|
92
|
+
* The display rows and model columns of a reference's corners – cached while the text, the row count and the
|
|
93
|
+
* order stay (finding a display row may scan all rows of a sorted table; the frames are placed on every scroll).
|
|
94
|
+
*/
|
|
95
|
+
private frameCells;
|
|
96
|
+
/** The number of physical rows (a range beyond them ends at the last one). */
|
|
97
|
+
private sheetRows;
|
|
98
|
+
private firstDataColumn;
|
|
99
|
+
private lastDataColumn;
|
|
100
|
+
/** The suggestion list (a function name is typed) or the argument hint (inside a call). */
|
|
101
|
+
private renderPopups;
|
|
102
|
+
private renderList;
|
|
103
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** A reference in the formula text: position, text and the text without `$` in capitals (same reference = same color). */
|
|
2
|
+
export interface FormulaTextRefIf {
|
|
3
|
+
readonly start: number;
|
|
4
|
+
readonly end: number;
|
|
5
|
+
readonly text: string;
|
|
6
|
+
readonly key: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The references of a formula text (outside strings and `[field]`s), in order.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} text - the editor text (with `=`)
|
|
12
|
+
* @returns {FormulaTextRefIf[]} the references
|
|
13
|
+
*/
|
|
14
|
+
export declare function findReferences(text: string): FormulaTextRefIf[];
|
|
15
|
+
/**
|
|
16
|
+
* True if a reference may be inserted at the caret: the text is a formula and the caret follows `=`, `(`, `,`, `;` or
|
|
17
|
+
* an operator (spaces allowed) – not inside a string.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} text - the editor text
|
|
20
|
+
* @param {number} caret - the caret position
|
|
21
|
+
* @returns {boolean} whether pointing inserts here
|
|
22
|
+
*/
|
|
23
|
+
export declare function isInsertionPoint(text: string, caret: number): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* F4: the next `$` form of a reference – `A1` → `$A$1` → `A$1` → `$A1` → `A1`; a range changes both ends like its
|
|
26
|
+
* first one. Whole columns/rows toggle their one `$` part.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} ref - e.g. `"B2"`, `"$B$2:$B$4"`
|
|
29
|
+
* @returns {string} the next form
|
|
30
|
+
*/
|
|
31
|
+
export declare function toggleAbsolute(ref: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* The beginning of a function name the caret stands behind (`=SU|` → `"SU"`), `undefined` if there is none: it must
|
|
34
|
+
* start at an insertion point, contain letters and not be a reference already followed by `(`.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} text - the editor text
|
|
37
|
+
* @param {number} caret - the caret position
|
|
38
|
+
* @returns {{ start: number, prefix: string } | undefined} where the name starts and what was typed
|
|
39
|
+
*/
|
|
40
|
+
export declare function functionPrefixAt(text: string, caret: number): {
|
|
41
|
+
start: number;
|
|
42
|
+
prefix: string;
|
|
43
|
+
} | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The innermost function call the caret is in and the index of its argument (`=SUM(1,|` → `{ name: "SUM", argument: 1 }`).
|
|
46
|
+
*
|
|
47
|
+
* @param {string} text - the editor text
|
|
48
|
+
* @param {number} caret - the caret position
|
|
49
|
+
* @returns {{ name: string, argument: number } | undefined} the call
|
|
50
|
+
*/
|
|
51
|
+
export declare function callAt(text: string, caret: number): {
|
|
52
|
+
name: string;
|
|
53
|
+
argument: number;
|
|
54
|
+
} | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The arguments of a signature (`"SUM(number1, [number2], …)"` → `["number1", "[number2]", "…"]`).
|
|
57
|
+
*
|
|
58
|
+
* @param {string} signature - the signature
|
|
59
|
+
* @returns {string[]} the arguments
|
|
60
|
+
*/
|
|
61
|
+
export declare function signatureArguments(signature: string): string[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The target of Ctrl+arrow (⌘+arrow on macOS) in Excel-style editing – Excel's rule for jumping to the edge of the
|
|
3
|
+
* data: if the cell next to the start is empty, the next filled cell in that direction (or the last cell); if it is
|
|
4
|
+
* filled, the last filled cell of that block. Empty = `null`, `undefined` or `""` (not `0`, not `false`).
|
|
5
|
+
* DOM-free; hidden columns (`isShownColumn` → `false`) are skipped.
|
|
6
|
+
*
|
|
7
|
+
* @param {(row: number, column: number) => boolean} isEmpty - true for an empty cell
|
|
8
|
+
* @param {number} rowCount - rows (display order)
|
|
9
|
+
* @param {number} columnCount - columns (model indices)
|
|
10
|
+
* @param {number} row - start row
|
|
11
|
+
* @param {number} column - start column
|
|
12
|
+
* @param {number} dRow - -1, 0 or 1
|
|
13
|
+
* @param {number} dColumn - -1, 0 or 1
|
|
14
|
+
* @param {(column: number) => boolean} [isShownColumn] - false for a hidden column
|
|
15
|
+
* @returns {[number, number]} the target cell (the start if there is nothing to move to)
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const data = [[1], [2], [""], [""], [5]];
|
|
19
|
+
* const isEmpty = (r: number, c: number) => data[r][c] === "";
|
|
20
|
+
* findDataEdge(isEmpty, 5, 1, 0, 0, 1, 0); // [1, 0] – end of the block 1, 2
|
|
21
|
+
* findDataEdge(isEmpty, 5, 1, 1, 0, 1, 0); // [4, 0] – next filled cell
|
|
22
|
+
*
|
|
23
|
+
* @category Spreadsheet
|
|
24
|
+
* @since 1.1.99
|
|
25
|
+
*/
|
|
26
|
+
export declare function findDataEdge(isEmpty: (row: number, column: number) => boolean, rowCount: number, columnCount: number, row: number, column: number, dRow: number, dColumn: number, isShownColumn?: (column: number) => boolean): [number, number];
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { AbstractAreaModel } from '../data/tablemodel/areamodel/abstract-area-model.js';
|
|
2
|
+
import { AreaIdent } from '../data/tablemodel/area-ident.type.js';
|
|
3
|
+
import { ColumnDefIf } from '../data/tablemodel/column/column-def.if.js';
|
|
4
|
+
import { FilterFunction } from '../data/common/filter-function.js';
|
|
5
|
+
import { SortItem } from '../data/common/sort-item.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The body of a spreadsheet ({@link SpreadsheetFactory}): **sparse** – only rows with content exist (a sheet with a
|
|
9
|
+
* million empty rows costs nothing), row `n` = physical row `n` (cell formulas), sorting and filtering as a
|
|
10
|
+
* permutation (display → physical) only while they apply. Cells are stored by data column (`A` = 0); the model columns
|
|
11
|
+
* in front (row numbers) are left out with `columnOffset`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const body = new AreaModelSheet("body", [["Laptop", 1299], ["Mouse", 25]], 100, 26, 30, columnDefs, 1);
|
|
15
|
+
* body.getSheetData(); // [["Laptop", 1299], ["Mouse", 25]]
|
|
16
|
+
*
|
|
17
|
+
* @category Spreadsheet
|
|
18
|
+
* @since 1.1.99
|
|
19
|
+
*/
|
|
20
|
+
export declare class AreaModelSheet extends AbstractAreaModel<unknown[]> {
|
|
21
|
+
private rowCount;
|
|
22
|
+
private columnCount;
|
|
23
|
+
readonly columnOffset: number;
|
|
24
|
+
/** Increases with every structural change (rows/columns inserted or deleted, data replaced). */
|
|
25
|
+
version: number;
|
|
26
|
+
private rows;
|
|
27
|
+
private physicalOfArray;
|
|
28
|
+
private perm?;
|
|
29
|
+
private inverse?;
|
|
30
|
+
constructor(areaIdent: AreaIdent, data: unknown[][], rowCount: number, columnCount: number, defaultRowHeight: number, columnDefs?: ColumnDefIf[], columnOffset?: number);
|
|
31
|
+
/**
|
|
32
|
+
* Replaces all cells (sorting and filters end).
|
|
33
|
+
*
|
|
34
|
+
* @param {unknown[][]} data - rows × data columns
|
|
35
|
+
* @param {number} [rowCount] - at least the rows of `data`
|
|
36
|
+
* @param {number} [columnCount] - at least the longest row
|
|
37
|
+
*/
|
|
38
|
+
setSheetData(data: unknown[][], rowCount?: number, columnCount?: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* The cells as rows × columns, up to the last row and column with content (empty cells `""`) – e.g. to save them.
|
|
41
|
+
*
|
|
42
|
+
* @returns {unknown[][]} the data
|
|
43
|
+
*/
|
|
44
|
+
getSheetData(): unknown[][];
|
|
45
|
+
/** @returns {unknown} the input of a cell by physical row and data column (`undefined` if empty) */
|
|
46
|
+
getCell(row: number, col: number): unknown;
|
|
47
|
+
/**
|
|
48
|
+
* Writes the input of a cell by physical row and data column (the row is created on demand).
|
|
49
|
+
*
|
|
50
|
+
* @param {number} row - physical row
|
|
51
|
+
* @param {number} col - data column
|
|
52
|
+
* @param {unknown} value - the input
|
|
53
|
+
*/
|
|
54
|
+
setCell(row: number, col: number, value: unknown): void;
|
|
55
|
+
/** @returns {unknown[] | undefined} the row array of a physical row (`undefined` for an empty row) */
|
|
56
|
+
getRowArray(row: number): unknown[] | undefined;
|
|
57
|
+
/** Calls `fn` for every stored cell (the sparse rows only). */
|
|
58
|
+
forEachCell(fn: (row: number, col: number, value: unknown) => void): void;
|
|
59
|
+
/** @returns {number | undefined} the physical row of a row array of this model */
|
|
60
|
+
getPhysicalRowOfArray(row: unknown): number | undefined;
|
|
61
|
+
/** @returns {number} the number of data columns */
|
|
62
|
+
getSheetColumnCount(): number;
|
|
63
|
+
/**
|
|
64
|
+
* New column definitions (inserted or deleted columns).
|
|
65
|
+
*
|
|
66
|
+
* @param {ColumnDefIf[]} columnDefs - all columns of the table
|
|
67
|
+
*/
|
|
68
|
+
setColumnDefs(columnDefs: ColumnDefIf[]): void;
|
|
69
|
+
getRowCount(): number;
|
|
70
|
+
/** @returns {number} all rows, without sorting and filters */
|
|
71
|
+
getUnfilteredRowCount(): number;
|
|
72
|
+
/**
|
|
73
|
+
* The physical row (= row number − 1) of a display row – row numbers in `"original"` mode and cell formulas use it.
|
|
74
|
+
*
|
|
75
|
+
* @param {number} rowIndex - display index
|
|
76
|
+
* @returns {number} the physical row
|
|
77
|
+
*/
|
|
78
|
+
getPhysicalRowIndex(rowIndex: number): number;
|
|
79
|
+
/**
|
|
80
|
+
* The display row of a physical row, `-1` if a filter hides it.
|
|
81
|
+
*
|
|
82
|
+
* @param {number} physicalRow - the physical row
|
|
83
|
+
* @returns {number} the display index
|
|
84
|
+
*/
|
|
85
|
+
getDisplayRowIndex(physicalRow: number): number;
|
|
86
|
+
getValueAt(rowIndex: number, columnIndex: number): any;
|
|
87
|
+
/**
|
|
88
|
+
* The input of a cell – the formula text of a formula, otherwise the value (`""` for an empty cell).
|
|
89
|
+
*
|
|
90
|
+
* @param {number} rowIndex - display index
|
|
91
|
+
* @param {number} columnIndex - model column
|
|
92
|
+
* @returns {unknown} the input
|
|
93
|
+
*/
|
|
94
|
+
getInputValueAt(rowIndex: number, columnIndex: number): unknown;
|
|
95
|
+
getTextValueAt(rowIndex: number, columnIndex: number): string;
|
|
96
|
+
setValue(rowIndex: number, columnIndex: number, value: any): boolean;
|
|
97
|
+
/** The row array of a display row – `undefined` for an empty row (no object is created by reading). */
|
|
98
|
+
getRowByIndex(rowIndex: number): any;
|
|
99
|
+
getRowHeight(_rowIndex: number): number;
|
|
100
|
+
/** @returns {number | undefined} the constant row height */
|
|
101
|
+
getConstantRowHeight(): number | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* A sheet has no merged cells: the table skips the span scan (rows × columns calls on every init).
|
|
104
|
+
*
|
|
105
|
+
* @returns {number} 1
|
|
106
|
+
*/
|
|
107
|
+
getMaxColspan(): number;
|
|
108
|
+
/** @returns {number} 1 – no merged cells (see {@link getMaxColspan}) */
|
|
109
|
+
getMaxRowspan(): number;
|
|
110
|
+
/** A filter: the predicate gets the row as array of inputs (`[]` for an empty row). */
|
|
111
|
+
externalFilterChanged(predictFn: FilterFunction<any>): void;
|
|
112
|
+
/** Sorts the shown rows by the values of columns (empty cells last). */
|
|
113
|
+
doSort(sortItems: SortItem[]): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Inserts empty rows before a physical row (sorting and filters end).
|
|
116
|
+
*
|
|
117
|
+
* @param {number} at - physical row
|
|
118
|
+
* @param {number} count - rows
|
|
119
|
+
*/
|
|
120
|
+
insertRows(at: number, count: number): void;
|
|
121
|
+
/**
|
|
122
|
+
* Deletes rows (sorting and filters end).
|
|
123
|
+
*
|
|
124
|
+
* @param {number} at - first physical row
|
|
125
|
+
* @param {number} count - rows
|
|
126
|
+
* @returns {Array<[number, unknown[]]>} the deleted rows with content (offset from `at`, the row array) – for undo
|
|
127
|
+
*/
|
|
128
|
+
deleteRows(at: number, count: number): Array<[number, unknown[]]>;
|
|
129
|
+
/**
|
|
130
|
+
* Inserts rows again that {@link deleteRows} removed (undo): the same row arrays at their places.
|
|
131
|
+
*
|
|
132
|
+
* @param {number} at - first physical row
|
|
133
|
+
* @param {number} count - rows
|
|
134
|
+
* @param {Array<[number, unknown[]]>} removed - what `deleteRows` returned
|
|
135
|
+
*/
|
|
136
|
+
restoreRows(at: number, count: number, removed: ReadonlyArray<readonly [number, unknown[]]>): void;
|
|
137
|
+
/**
|
|
138
|
+
* Inserts empty data columns before a data column.
|
|
139
|
+
*
|
|
140
|
+
* @param {number} at - data column
|
|
141
|
+
* @param {number} count - columns
|
|
142
|
+
*/
|
|
143
|
+
insertColumns(at: number, count: number): void;
|
|
144
|
+
/**
|
|
145
|
+
* Deletes data columns.
|
|
146
|
+
*
|
|
147
|
+
* @param {number} at - first data column
|
|
148
|
+
* @param {number} count - columns
|
|
149
|
+
* @returns {Array<[unknown[], unknown[]]>} per row with content in the columns: the row array and its removed cells
|
|
150
|
+
*/
|
|
151
|
+
deleteColumns(at: number, count: number): Array<[unknown[], unknown[]]>;
|
|
152
|
+
/**
|
|
153
|
+
* Inserts columns again that {@link deleteColumns} removed (undo).
|
|
154
|
+
*
|
|
155
|
+
* @param {number} at - first data column
|
|
156
|
+
* @param {number} count - columns
|
|
157
|
+
* @param {Array<[unknown[], unknown[]]>} removed - what `deleteColumns` returned
|
|
158
|
+
*/
|
|
159
|
+
restoreColumns(at: number, count: number, removed: ReadonlyArray<readonly [unknown[], unknown[]]>): void;
|
|
160
|
+
/**
|
|
161
|
+
* The extent of the content in the current view: the last display row and model column with a value (the Excel
|
|
162
|
+
* export leaves out the empty rest). `[-1, -1]` for an empty sheet.
|
|
163
|
+
*
|
|
164
|
+
* @returns {[number, number]} last display row and last model column
|
|
165
|
+
*/
|
|
166
|
+
getContentExtent(): [number, number];
|
|
167
|
+
private valueOfPhysical;
|
|
168
|
+
private shiftRows;
|
|
169
|
+
private changed;
|
|
170
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { TableApi } from '../table-api.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Options of the {@link FormulaBar}.
|
|
5
|
+
*
|
|
6
|
+
* @category Spreadsheet
|
|
7
|
+
* @since 1.1.99
|
|
8
|
+
*/
|
|
9
|
+
export interface FormulaBarOptionsIf {
|
|
10
|
+
/** Show the address box (`B3`; typing `D10` or `B2:C5` + Enter goes there). Default `true`. */
|
|
11
|
+
addressBox: boolean;
|
|
12
|
+
/** The name of the input of the formula bar. Default `"Formula"`. */
|
|
13
|
+
ariaLabel: string;
|
|
14
|
+
/** The name of the address box. Default `"Cell address"`. */
|
|
15
|
+
addressAriaLabel: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The formula bar of a spreadsheet: an address box (`B3`) and the input of the active cell (the formula text, not
|
|
19
|
+
* its result). Typing there and Enter/Tab writes the cell (`TableApi.setCellInput`) and moves like the table, Escape
|
|
20
|
+
* restores it; while the cell editor is open the bar shows its text live. Plain DOM, no dependency – works with every
|
|
21
|
+
* wrapper (pass the `TableApi` of `tableReady`). Colors: `--ge-table-formula-bar-*`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const bar = new FormulaBar(document.querySelector<HTMLElement>(".formula-bar")!, tableApi);
|
|
25
|
+
* // later: bar.destroy();
|
|
26
|
+
*
|
|
27
|
+
* @category Spreadsheet
|
|
28
|
+
* @since 1.1.99
|
|
29
|
+
*/
|
|
30
|
+
export declare class FormulaBar {
|
|
31
|
+
private readonly api;
|
|
32
|
+
readonly element: HTMLDivElement;
|
|
33
|
+
readonly addressInput: HTMLInputElement;
|
|
34
|
+
readonly input: HTMLInputElement;
|
|
35
|
+
private readonly options;
|
|
36
|
+
private readonly unsubscribe;
|
|
37
|
+
private readonly abort;
|
|
38
|
+
/** The cell the input belongs to (fixed while typing in the bar). */
|
|
39
|
+
private cell?;
|
|
40
|
+
private original;
|
|
41
|
+
constructor(container: HTMLElement, api: TableApi, options?: Partial<FormulaBarOptionsIf>);
|
|
42
|
+
/** Removes the bar and its listeners. */
|
|
43
|
+
destroy(): void;
|
|
44
|
+
/** Shows the active cell: its address and input (not while typing in the bar). */
|
|
45
|
+
show(): void;
|
|
46
|
+
private onEditing;
|
|
47
|
+
private beginInput;
|
|
48
|
+
/** Writes the input (if changed); `false` keeps the bar's text otherwise. */
|
|
49
|
+
private endInput;
|
|
50
|
+
private onInputKey;
|
|
51
|
+
private onAddressKey;
|
|
52
|
+
private focusTable;
|
|
53
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { TableModel } from '../data/tablemodel/table-model.js';
|
|
2
|
+
import { TableModelIf } from '../data/tablemodel/table-model.if.js';
|
|
3
|
+
import { ColumnDefIf } from '../data/tablemodel/column/column-def.if.js';
|
|
4
|
+
import { AreaModelArrayOfArrays } from '../data/tablemodel/areamodel/area-model-array-of-arrays.js';
|
|
5
|
+
import { RowNumberColumnDef } from '../data/common/row-number-column-def.js';
|
|
6
|
+
import { TableOptionsIf } from '../data/options/table-options.if.js';
|
|
7
|
+
import { FormulaFunction } from '../formula/formula-options.if.js';
|
|
8
|
+
import { AreaModelSheet } from './area-model-sheet.js';
|
|
9
|
+
import { editInputPipe } from '../renderer/edit/edit-input-pipe.if.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The parameters of {@link SpreadsheetFactory.create}. All optional.
|
|
13
|
+
*
|
|
14
|
+
* @category Spreadsheet
|
|
15
|
+
* @since 1.1.99
|
|
16
|
+
*/
|
|
17
|
+
export interface SpreadsheetParamIf {
|
|
18
|
+
/** Rows × columns of inputs; formulas as `"=…"`. Default: empty. */
|
|
19
|
+
data: unknown[][];
|
|
20
|
+
/** Rows of the sheet. Default `max(data.length, 100)`. */
|
|
21
|
+
rowCount: number;
|
|
22
|
+
/** Columns of the sheet. Default `max(longest row, 26)` (A–Z). */
|
|
23
|
+
columnCount: number;
|
|
24
|
+
/** Width of a column in px. Default 100. */
|
|
25
|
+
columnWidth: number;
|
|
26
|
+
/** Height of a row in px. Default 30. */
|
|
27
|
+
rowHeight: number;
|
|
28
|
+
/** Row numbers in front (they count the rows of the sheet, also when sorted). Default `true`. */
|
|
29
|
+
rowNumbers: boolean;
|
|
30
|
+
/** Merged over the options of the factory (selection, focus, the spreadsheet preset). */
|
|
31
|
+
tableOptions: Partial<TableOptionsIf>;
|
|
32
|
+
/** Own functions of the cell formulas. */
|
|
33
|
+
functions: Record<string, FormulaFunction>;
|
|
34
|
+
/**
|
|
35
|
+
* The locale of typed and pasted values (`sheetInputPipe`): `"1,5"` is 1.5 in `"de-DE"`. Default: the browser's
|
|
36
|
+
* locale. Formulas always use `.` and English function names.
|
|
37
|
+
*/
|
|
38
|
+
locale: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The header of a spreadsheet: one row with the column letters `A, B, …` (`isColumnLetterRow(0)` – a click selects the
|
|
42
|
+
* column).
|
|
43
|
+
*
|
|
44
|
+
* @category Spreadsheet
|
|
45
|
+
* @since 1.1.99
|
|
46
|
+
*/
|
|
47
|
+
export declare class AreaModelSheetHeader extends AreaModelArrayOfArrays<string> {
|
|
48
|
+
/** The number of header rows with column letters (from the top). */
|
|
49
|
+
readonly columnLetterRows = 1;
|
|
50
|
+
/**
|
|
51
|
+
* @param {number} rowIndex - a header row
|
|
52
|
+
* @returns {boolean} true for the row of column letters
|
|
53
|
+
*/
|
|
54
|
+
isColumnLetterRow(rowIndex: number): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* New columns (insert/delete columns).
|
|
57
|
+
*
|
|
58
|
+
* @param {ColumnDefIf[]} columnDefs - all columns
|
|
59
|
+
*/
|
|
60
|
+
setColumns(columnDefs: ColumnDefIf[]): void;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The table model of a spreadsheet ({@link SpreadsheetFactory}): its data columns can be inserted and deleted
|
|
64
|
+
* (`TableApi.insertColumns`).
|
|
65
|
+
*
|
|
66
|
+
* @category Spreadsheet
|
|
67
|
+
* @since 1.1.99
|
|
68
|
+
*/
|
|
69
|
+
export declare class SpreadsheetTableModel extends TableModel {
|
|
70
|
+
readonly sheetBody: AreaModelSheet;
|
|
71
|
+
private readonly rowNumberColumn;
|
|
72
|
+
private readonly columnWidth;
|
|
73
|
+
private readonly inputPipe;
|
|
74
|
+
constructor(header: AreaModelSheetHeader, sheetBody: AreaModelSheet, rowNumberColumn: RowNumberColumnDef | undefined, columnDefs: ColumnDefIf[], rowHeight: number, columnWidth: number, inputPipe?: editInputPipe);
|
|
75
|
+
/**
|
|
76
|
+
* Sets the data columns: `A…` with the given widths (insert/delete columns keep the widths of the moved columns).
|
|
77
|
+
*
|
|
78
|
+
* @param {number} count - data columns
|
|
79
|
+
* @param {number[]} [widths] - width per data column in px (missing: the default width)
|
|
80
|
+
*/
|
|
81
|
+
setDataColumns(count: number, widths?: number[]): void;
|
|
82
|
+
/** @returns {number[]} the widths of the data columns in px */
|
|
83
|
+
getDataColumnWidths(): number[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Builds an empty (or filled) spreadsheet in one call: column letters, row numbers, a sparse body (a million rows cost
|
|
87
|
+
* only their filled cells) and the options of the spreadsheet preset – Excel-style editing, copy and paste, undo,
|
|
88
|
+
* cell formulas, the fill handle and a range selection with the active cell on A1.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* const { tableModel, tableOptions } = SpreadsheetFactory.create({
|
|
92
|
+
* data: [["Product", "Price", "Qty", "Total"], ["Laptop", 1299, 2, "=B2*C2"]],
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* @category Spreadsheet
|
|
96
|
+
* @since 1.1.99
|
|
97
|
+
*/
|
|
98
|
+
export declare class SpreadsheetFactory {
|
|
99
|
+
/**
|
|
100
|
+
* Model and options of a spreadsheet.
|
|
101
|
+
*
|
|
102
|
+
* @param {Partial<SpreadsheetParamIf>} [param] - data, size, row numbers, options
|
|
103
|
+
* @returns {{ tableModel: SpreadsheetTableModel, tableOptions: TableOptionsIf }} for the table or a wrapper
|
|
104
|
+
*/
|
|
105
|
+
static create(param?: Partial<SpreadsheetParamIf>): {
|
|
106
|
+
tableModel: SpreadsheetTableModel;
|
|
107
|
+
tableOptions: TableOptionsIf;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** @returns {boolean} true for the model of a {@link SpreadsheetFactory} sheet */
|
|
111
|
+
export declare function isSpreadsheetTableModel(model: TableModelIf): model is SpreadsheetTableModel;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EditingOptionsIf } from '../sheet-editing/editing-options.if.js';
|
|
2
|
+
import { ClipboardOptionsIf } from '../clipboard/clipboard-options.if.js';
|
|
3
|
+
import { UndoOptionsIf } from '../undo/undo-options.if.js';
|
|
4
|
+
import { CellFormulaOptionsIf } from '../sheet/cell-formula-options.if.js';
|
|
5
|
+
import { FillHandleOptionsIf } from '../fill/fill-handle-options.if.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The preset `tableOptions.spreadsheet` ({@link TableOptionsIf.spreadsheet}): which parts it switches on. Each part
|
|
9
|
+
* is `true` by default; `false` leaves it off, an object configures it. Options the table options set themselves win.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const tableOptions: TableOptionsIf = { ...new TableOptions(), spreadsheet: { cellFormulas: { columns: ["total"] } } };
|
|
13
|
+
*
|
|
14
|
+
* @category Spreadsheet
|
|
15
|
+
* @since 1.1.99
|
|
16
|
+
*/
|
|
17
|
+
export interface SpreadsheetOptionsIf {
|
|
18
|
+
/** Excel-style editing – the preset sets `defaultEditable: true` (columns without own `editable` are editable). */
|
|
19
|
+
editing: boolean | Partial<EditingOptionsIf>;
|
|
20
|
+
/** Copy, cut and paste. */
|
|
21
|
+
clipboard: boolean | Partial<ClipboardOptionsIf>;
|
|
22
|
+
/** Undo and redo. */
|
|
23
|
+
undo: boolean | Partial<UndoOptionsIf>;
|
|
24
|
+
/** Cell formulas (`=B2*C2`). */
|
|
25
|
+
cellFormulas: boolean | Partial<CellFormulaOptionsIf>;
|
|
26
|
+
/** The fill handle. */
|
|
27
|
+
fillHandle: boolean | Partial<FillHandleOptionsIf>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TableOptionsIf } from '../data/options/table-options.if.js';
|
|
2
|
+
import { SpreadsheetOptionsIf } from './spreadsheet-options.if.js';
|
|
3
|
+
|
|
4
|
+
type PresetKey = keyof SpreadsheetOptionsIf;
|
|
5
|
+
/**
|
|
6
|
+
* The value of one part of the preset `tableOptions.spreadsheet` for a table: the option itself if the options set it,
|
|
7
|
+
* otherwise the preset's part (`true` by default, `editing` with `defaultEditable: true`). Without the preset: the
|
|
8
|
+
* option. The options object is never changed (it may be shared by several tables or frozen).
|
|
9
|
+
*
|
|
10
|
+
* @param {TableOptionsIf} tableOptions - the options of a table
|
|
11
|
+
* @param {PresetKey} key - `editing`, `clipboard`, `undo`, `cellFormulas` or `fillHandle`
|
|
12
|
+
* @returns {unknown} the effective value
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* spreadsheetOption({ ...new TableOptions(), spreadsheet: true }, "undo"); // true
|
|
16
|
+
*
|
|
17
|
+
* @category Spreadsheet
|
|
18
|
+
* @since 1.1.99
|
|
19
|
+
*/
|
|
20
|
+
export declare function spreadsheetOption<K extends PresetKey>(tableOptions: TableOptionsIf | undefined, key: K): TableOptionsIf[K];
|
|
21
|
+
/**
|
|
22
|
+
* The options a table uses with the preset `tableOptions.spreadsheet`: a **copy** with every part of
|
|
23
|
+
* {@link SpreadsheetOptionsIf} the options don't set themselves (`editing`, `clipboard`, `undo`, `cellFormulas`,
|
|
24
|
+
* `fillHandle`). The table resolves the preset itself; use this to see the result.
|
|
25
|
+
*
|
|
26
|
+
* @param {TableOptionsIf} tableOptions - the options of a table
|
|
27
|
+
* @returns {TableOptionsIf} a copy (the same object without the preset)
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const options = applySpreadsheetPreset({ ...new TableOptions(), spreadsheet: true });
|
|
31
|
+
* options.undo; // true
|
|
32
|
+
*
|
|
33
|
+
* @category Spreadsheet
|
|
34
|
+
* @since 1.1.99
|
|
35
|
+
*/
|
|
36
|
+
export declare function applySpreadsheetPreset(tableOptions: TableOptionsIf): TableOptionsIf;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { TableScope } from '../table-scope.js';
|
|
2
|
+
import { CellChangeSource } from '../batch-edit/cell-change.if.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Rows or columns inserted or deleted at a **physical** position (row number − 1, column letter index).
|
|
6
|
+
*
|
|
7
|
+
* @category Spreadsheet
|
|
8
|
+
* @since 1.1.99
|
|
9
|
+
*/
|
|
10
|
+
export interface StructureEditIf {
|
|
11
|
+
readonly kind: "insertRows" | "deleteRows" | "insertColumns" | "deleteColumns";
|
|
12
|
+
readonly at: number;
|
|
13
|
+
readonly count: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Inserts or deletes rows or columns with adjusted cell formulas (`=SUM(D2:D4)` → `=SUM(D2:D5)` after inserting a row
|
|
17
|
+
* inside, a deleted reference → `#REF!`), as **one** undo step and one `onModelChanged` (source `"structure"`).
|
|
18
|
+
* Rows: a spreadsheet, object rows (new objects from `clipboard.createRow`, otherwise `{}`; the app's array changes
|
|
19
|
+
* **in place**) and arrays; columns: a spreadsheet only. Not while a batch edit collects changes. Sorting and filters
|
|
20
|
+
* stay (the view is built again); the active cell stays inside the table.
|
|
21
|
+
*
|
|
22
|
+
* @param {TableScope} scope - the table
|
|
23
|
+
* @param {StructureEditIf} edit - what to change
|
|
24
|
+
* @param {{ record?: boolean, rows?: unknown[], source?: CellChangeSource }} [opts] - `record: false` = no undo step;
|
|
25
|
+
* `rows`: the rows to insert (redo); `source` of the event
|
|
26
|
+
* @returns {boolean} true if changed
|
|
27
|
+
*
|
|
28
|
+
* @category Internals
|
|
29
|
+
* @since 1.1.99
|
|
30
|
+
*/
|
|
31
|
+
export declare function applyStructureEdit(scope: TableScope, edit: StructureEditIf, opts?: {
|
|
32
|
+
record?: boolean;
|
|
33
|
+
rows?: unknown[];
|
|
34
|
+
source?: CellChangeSource;
|
|
35
|
+
}): boolean;
|