@guiexpert/table 1.1.98 → 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 +9 -0
- package/css/main.css +296 -0
- package/css/table-clipboard.css +41 -0
- package/css/table-color-vars.css +56 -0
- package/css/table-sheet-editing.css +149 -0
- package/css/table-spreadsheet.css +50 -0
- package/index.cjs +46 -59
- package/index.d.ts +46 -0
- package/index.js +18934 -11624
- 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/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 +28 -0
- package/lib/table/data/options/table-options.if.d.ts +99 -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/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/selection/selection-service.d.ts +48 -0
- package/lib/table/service/excel-export-options.if.d.ts +6 -0
- package/lib/table/service/excel-service.d.ts +4 -0
- package/lib/table/service/excel-service.if.d.ts +35 -0
- 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 +511 -2
- package/lib/table/table-scope.d.ts +294 -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,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;
|
package/lib/table/table-api.d.ts
CHANGED
|
@@ -19,10 +19,14 @@ import { FormulaOptionsIf } from './formula/formula-options.if.js';
|
|
|
19
19
|
import { FormulaError } from './formula/formula-error.js';
|
|
20
20
|
import { RowDropTargetIf } from './row-drag/row-drop-target.if.js';
|
|
21
21
|
import { CellChangeIf, CellChangeSource } from './batch-edit/cell-change.if.js';
|
|
22
|
+
import { GeUndoEvent } from './data/common/event/ge-undo-event.js';
|
|
22
23
|
import { CellValueChangeIf } from './batch-edit/cell-value-change.if.js';
|
|
23
24
|
import { FillDirection } from './fill/fill-direction.type.js';
|
|
24
25
|
import { FillMode } from './fill/fill-series.js';
|
|
25
26
|
import { CellRange } from './data/common/cell-range.js';
|
|
27
|
+
import { EventListenerIf } from './event-listener.if.js';
|
|
28
|
+
import { ExcelExportOptionsIf } from './service/excel-export-options.if.js';
|
|
29
|
+
import { SheetEngine } from './sheet/sheet-engine.js';
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
32
|
* The public API of one table – everything you do with a table after it has been created:
|
|
@@ -839,8 +843,19 @@ export declare class TableApi {
|
|
|
839
843
|
* @example
|
|
840
844
|
* // Download table data with custom filename only
|
|
841
845
|
* tableApi.downloadExcel('quarterly-data.xlsx');
|
|
846
|
+
*
|
|
847
|
+
* @example
|
|
848
|
+
* // cell formulas as Excel formulas (since 1.1.99, tableOptions.cellFormulas)
|
|
849
|
+
* tableApi.downloadExcel('budget.xlsx', '', { cellFormulas: true });
|
|
850
|
+
*/
|
|
851
|
+
downloadExcel(fileName?: string, author?: string, exportOptions?: Partial<ExcelExportOptionsIf>): Promise<void>;
|
|
852
|
+
/**
|
|
853
|
+
* Where the data of a sheet start in the Excel file (rows above, columns in front) – `undefined` with a warning if
|
|
854
|
+
* the export is not the sheet: no cell formulas, a filter, sorting, a hidden data column or no formula support.
|
|
842
855
|
*/
|
|
843
|
-
|
|
856
|
+
private getExcelFormulaOffset;
|
|
857
|
+
/** A body cell with a cell formula as Excel formula cell (`undefined` for other cells). */
|
|
858
|
+
private getExcelFormulaCell;
|
|
844
859
|
/** The value of a cell for the Excel export – the shown number in a row number column (body; footer empty). */
|
|
845
860
|
private getExportValue;
|
|
846
861
|
/**
|
|
@@ -1502,6 +1517,8 @@ export declare class TableApi {
|
|
|
1502
1517
|
*
|
|
1503
1518
|
* @param {CellValueChangeIf[]} changes - display row index, column (index or property) and value per cell
|
|
1504
1519
|
* @param {CellChangeSource} [source="api"] - reported in {@link GeModelChangeEvent.source}
|
|
1520
|
+
* @param {{ undoable?: boolean }} [opts] - `undoable`: record the change for undo ({@link TableOptionsIf.undo}) – default:
|
|
1521
|
+
* `UndoOptionsIf.recordApiChanges` for `"api"`, recorded for the other sources (since 1.1.99)
|
|
1505
1522
|
* @returns {CellChangeIf[]} the written (batch edit: newly pending) cells
|
|
1506
1523
|
*
|
|
1507
1524
|
* @example
|
|
@@ -1517,7 +1534,9 @@ export declare class TableApi {
|
|
|
1517
1534
|
*
|
|
1518
1535
|
* @since 1.1.96
|
|
1519
1536
|
*/
|
|
1520
|
-
applyCellChanges(changes: CellValueChangeIf[], source?: CellChangeSource
|
|
1537
|
+
applyCellChanges(changes: CellValueChangeIf[], source?: CellChangeSource, opts?: {
|
|
1538
|
+
undoable?: boolean;
|
|
1539
|
+
}): CellChangeIf[];
|
|
1521
1540
|
/**
|
|
1522
1541
|
* Fills cells next to a range – what dragging the fill handle does ({@link TableOptionsIf.fillHandle} is not
|
|
1523
1542
|
* needed for this call): continues series (1, 2 → 3, 4; dates; `Item 1` → `Item 2`) or copies, writes with
|
|
@@ -1558,6 +1577,496 @@ export declare class TableApi {
|
|
|
1558
1577
|
* @since 1.1.96
|
|
1559
1578
|
*/
|
|
1560
1579
|
cancelFill(): void;
|
|
1580
|
+
/**
|
|
1581
|
+
* Adds an event listener next to the one the table was created with – e.g. for a toolbar or an own formula bar
|
|
1582
|
+
* that lives outside the component that created the table. Every `on…` method you give is called after the main
|
|
1583
|
+
* listener's; a listener that throws is logged and does not stop the others.
|
|
1584
|
+
*
|
|
1585
|
+
* @param {Partial<EventListenerIf>} listener - the events of interest
|
|
1586
|
+
* @returns {() => void} call it to remove the listener (the table also removes all on `destroy()`)
|
|
1587
|
+
*
|
|
1588
|
+
* @example
|
|
1589
|
+
* const unsubscribe = tableApi.subscribe({
|
|
1590
|
+
* onEditingChanged: (evt: GeEditEvent) => { hint.textContent = evt.type === "input" ? evt.input ?? "" : ""; },
|
|
1591
|
+
* onModelChanged: (evt: GeModelChangeEvent) => console.log(`${evt.changes?.length ?? 0} cells changed`),
|
|
1592
|
+
* });
|
|
1593
|
+
* // later
|
|
1594
|
+
* unsubscribe();
|
|
1595
|
+
*
|
|
1596
|
+
* @since 1.1.99
|
|
1597
|
+
*/
|
|
1598
|
+
subscribe(listener: Partial<EventListenerIf>): () => void;
|
|
1599
|
+
/**
|
|
1600
|
+
* Opens the cell editor of a body cell – like F2 (caret at the end) or, with `typedText`, like typing that text.
|
|
1601
|
+
* With Excel-style editing ({@link TableOptionsIf.editing}) the editor sits above the cell; otherwise (or for
|
|
1602
|
+
* columns with an own `getEditRenderer`) it is rendered into the cell.
|
|
1603
|
+
*
|
|
1604
|
+
* @param {number} rowIndex - display row index of the body
|
|
1605
|
+
* @param {number | string} column - model column index or property
|
|
1606
|
+
* @param {string} [typedText] - starts in "enter" mode with this text (it replaces the content)
|
|
1607
|
+
* @returns {boolean} true if an editor is open (`false` for a cell that cannot be edited)
|
|
1608
|
+
*
|
|
1609
|
+
* @example
|
|
1610
|
+
* tableApi.startEditing(0, "price"); // edit the price of the first row
|
|
1611
|
+
* tableApi.startEditing(4, "name", "Ad"); // as if "Ad" had been typed
|
|
1612
|
+
*
|
|
1613
|
+
* @since 1.1.99
|
|
1614
|
+
*/
|
|
1615
|
+
startEditing(rowIndex: number, column: number | string, typedText?: string): boolean;
|
|
1616
|
+
/**
|
|
1617
|
+
* Closes an open cell editor: commits its input (like Enter without moving) or, with `cancel`, discards it (like
|
|
1618
|
+
* Escape).
|
|
1619
|
+
*
|
|
1620
|
+
* @param {boolean} [cancel=false] - discard the input
|
|
1621
|
+
* @returns {boolean} true if no editor is open afterwards (an invalid input keeps the editor open)
|
|
1622
|
+
*
|
|
1623
|
+
* @example
|
|
1624
|
+
* saveButton.addEventListener("click", () => {
|
|
1625
|
+
* tableApi.stopEditing(); // the value being typed belongs to the data that is saved
|
|
1626
|
+
* });
|
|
1627
|
+
*
|
|
1628
|
+
* @since 1.1.99
|
|
1629
|
+
*/
|
|
1630
|
+
stopEditing(cancel?: boolean): boolean;
|
|
1631
|
+
/**
|
|
1632
|
+
* True while a cell editor is open.
|
|
1633
|
+
*
|
|
1634
|
+
* @returns {boolean} true while editing
|
|
1635
|
+
*
|
|
1636
|
+
* @example
|
|
1637
|
+
* if (!tableApi.isEditing()) {
|
|
1638
|
+
* tableApi.updateCells([], true); // live data: don't repaint under the user's input
|
|
1639
|
+
* }
|
|
1640
|
+
*
|
|
1641
|
+
* @since 1.1.99
|
|
1642
|
+
*/
|
|
1643
|
+
isEditing(): boolean;
|
|
1644
|
+
/**
|
|
1645
|
+
* The cell whose editor is open.
|
|
1646
|
+
*
|
|
1647
|
+
* @returns {[number, number] | undefined} display row and model column, `undefined` without editor
|
|
1648
|
+
*
|
|
1649
|
+
* @example
|
|
1650
|
+
* const cell = tableApi.getEditingCell();
|
|
1651
|
+
* if (cell) console.log(`editing row ${cell[0]}, column ${cell[1]}`);
|
|
1652
|
+
*
|
|
1653
|
+
* @since 1.1.99
|
|
1654
|
+
*/
|
|
1655
|
+
getEditingCell(): [number, number] | undefined;
|
|
1656
|
+
/**
|
|
1657
|
+
* Clears body cells like Delete in Excel-style editing: editable cells get their empty value
|
|
1658
|
+
* ({@link ColumnDefIf.emptyValue}, default `""`), **one** `onModelChanged` with the source `"clear"` (batch edit:
|
|
1659
|
+
* marked). Works without {@link TableOptionsIf.editing} too.
|
|
1660
|
+
*
|
|
1661
|
+
* @param {CellRange[]} [ranges] - body ranges; default: the selected cells, or the focused cell
|
|
1662
|
+
* @returns {number} the number of cleared cells, `-1` if there were too many (`EditingOptionsIf.maxClearCells`)
|
|
1663
|
+
*
|
|
1664
|
+
* @example
|
|
1665
|
+
* tableApi.clearCells([new CellRange(0, 2, 9, 2)]); // rows 0–9 of column 2
|
|
1666
|
+
*
|
|
1667
|
+
* @since 1.1.99
|
|
1668
|
+
*/
|
|
1669
|
+
clearCells(ranges?: CellRange[]): number;
|
|
1670
|
+
/**
|
|
1671
|
+
* Copies the selected cells (the last selected range, everything after Ctrl/⌘+A, otherwise the focused cell) with
|
|
1672
|
+
* the asynchronous clipboard API – for an own button or menu. Tab-separated text with Excel's quoting plus an HTML
|
|
1673
|
+
* table (`ClipboardOptionsIf.html`); pasting it into this table pastes the values. The browser may ask for
|
|
1674
|
+
* permission; Ctrl/⌘+C needs none ({@link TableOptionsIf.clipboard}). Works without the option (defaults).
|
|
1675
|
+
*
|
|
1676
|
+
* @returns {Promise<void>} resolves when the clipboard was written
|
|
1677
|
+
*
|
|
1678
|
+
* @example
|
|
1679
|
+
* copyButton.addEventListener("click", () => tableApi.copySelection());
|
|
1680
|
+
*
|
|
1681
|
+
* @since 1.1.99
|
|
1682
|
+
*/
|
|
1683
|
+
copySelection(): Promise<void>;
|
|
1684
|
+
/**
|
|
1685
|
+
* Like {@link copySelection}, and the cells are marked (dashed frame): the next paste of this content moves them –
|
|
1686
|
+
* the cut cells are emptied in the same change (`source: "cut"`). Escape or another change removes the mark.
|
|
1687
|
+
*
|
|
1688
|
+
* @returns {Promise<void>} resolves when the clipboard was written
|
|
1689
|
+
*
|
|
1690
|
+
* @example
|
|
1691
|
+
* cutButton.addEventListener("click", () => tableApi.cutSelection());
|
|
1692
|
+
*
|
|
1693
|
+
* @since 1.1.99
|
|
1694
|
+
*/
|
|
1695
|
+
cutSelection(): Promise<void>;
|
|
1696
|
+
/**
|
|
1697
|
+
* Pastes tab-separated text like Ctrl/⌘+V – without clipboard permissions: from `target` (once), otherwise from the
|
|
1698
|
+
* selection (tiled over a selected range that is an integer multiple, one value into every selected cell) or the
|
|
1699
|
+
* focused cell. Hidden columns are skipped, read-only cells left out, the rest is cut off at the last column;
|
|
1700
|
+
* **one** `onModelChanged` with `source: "paste"` (batch edit: marked). Works without {@link TableOptionsIf.clipboard}.
|
|
1701
|
+
*
|
|
1702
|
+
* @param {string} text - rows separated by line breaks, cells by tabs (quoted cells like Excel)
|
|
1703
|
+
* @param {[number, number] | undefined} [target] - display row and model column of the first cell
|
|
1704
|
+
* @returns {CellChangeIf[]} the written (batch edit: newly pending) cells
|
|
1705
|
+
*
|
|
1706
|
+
* @example
|
|
1707
|
+
* tableApi.pasteText("a\tb\n1\t2", [0, 1]); // A 2×2 block from row 0, column 1
|
|
1708
|
+
*
|
|
1709
|
+
* @since 1.1.99
|
|
1710
|
+
*/
|
|
1711
|
+
pasteText(text: string, target?: [number, number]): CellChangeIf[];
|
|
1712
|
+
/**
|
|
1713
|
+
* The selected cells as tab-separated text, exactly as Ctrl/⌘+C copies them (Excel's quoting, `copyHeaders`,
|
|
1714
|
+
* `copyValue`). `""` without cells or with more than `CopyService.maxCopyCells`.
|
|
1715
|
+
*
|
|
1716
|
+
* @returns {string} the text
|
|
1717
|
+
*
|
|
1718
|
+
* @example
|
|
1719
|
+
* console.log(tableApi.getSelectionAsText()); // "a\tb\n1\t2"
|
|
1720
|
+
*
|
|
1721
|
+
* @since 1.1.99
|
|
1722
|
+
*/
|
|
1723
|
+
getSelectionAsText(): string;
|
|
1724
|
+
/**
|
|
1725
|
+
* Removes the mark of cut cells (like Escape): the next paste copies instead of moving.
|
|
1726
|
+
*
|
|
1727
|
+
* @example
|
|
1728
|
+
* tableApi.cancelCut();
|
|
1729
|
+
*
|
|
1730
|
+
* @since 1.1.99
|
|
1731
|
+
*/
|
|
1732
|
+
cancelCut(): void;
|
|
1733
|
+
/**
|
|
1734
|
+
* Undoes the last change like Ctrl/⌘+Z ({@link TableOptionsIf.undo}): the old values are written back
|
|
1735
|
+
* (`onModelChanged` with source `"undo"`), the cells are selected and scrolled into view. Not while the cell editor
|
|
1736
|
+
* is open (it has its own text undo).
|
|
1737
|
+
*
|
|
1738
|
+
* @returns {boolean} true if a step was undone; false without the option or with nothing to undo
|
|
1739
|
+
*
|
|
1740
|
+
* @example
|
|
1741
|
+
* undoButton.addEventListener("click", () => tableApi.undo());
|
|
1742
|
+
*
|
|
1743
|
+
* @since 1.1.99
|
|
1744
|
+
*/
|
|
1745
|
+
undo(): boolean;
|
|
1746
|
+
/**
|
|
1747
|
+
* Redoes the last undone change like Ctrl+Y / Ctrl/⌘+Shift+Z (source `"redo"`).
|
|
1748
|
+
*
|
|
1749
|
+
* @returns {boolean} true if a step was redone
|
|
1750
|
+
*
|
|
1751
|
+
* @example
|
|
1752
|
+
* redoButton.addEventListener("click", () => tableApi.redo());
|
|
1753
|
+
*
|
|
1754
|
+
* @since 1.1.99
|
|
1755
|
+
*/
|
|
1756
|
+
redo(): boolean;
|
|
1757
|
+
/**
|
|
1758
|
+
* True if there is a change to undo – for buttons (or listen to `onUndoStackChanged`).
|
|
1759
|
+
*
|
|
1760
|
+
* @returns {boolean} true if {@link undo} would undo something
|
|
1761
|
+
*
|
|
1762
|
+
* @example
|
|
1763
|
+
* undoButton.disabled = !tableApi.canUndo();
|
|
1764
|
+
*
|
|
1765
|
+
* @since 1.1.99
|
|
1766
|
+
*/
|
|
1767
|
+
canUndo(): boolean;
|
|
1768
|
+
/**
|
|
1769
|
+
* True if there is an undone change to redo.
|
|
1770
|
+
*
|
|
1771
|
+
* @returns {boolean} true if {@link redo} would redo something
|
|
1772
|
+
*
|
|
1773
|
+
* @example
|
|
1774
|
+
* redoButton.disabled = !tableApi.canRedo();
|
|
1775
|
+
*
|
|
1776
|
+
* @since 1.1.99
|
|
1777
|
+
*/
|
|
1778
|
+
canRedo(): boolean;
|
|
1779
|
+
/**
|
|
1780
|
+
* Empties the undo history (e.g. after saving or loading new data).
|
|
1781
|
+
*
|
|
1782
|
+
* @example
|
|
1783
|
+
* await save(rows);
|
|
1784
|
+
* tableApi.clearUndoHistory();
|
|
1785
|
+
*
|
|
1786
|
+
* @since 1.1.99
|
|
1787
|
+
*/
|
|
1788
|
+
clearUndoHistory(): void;
|
|
1789
|
+
/**
|
|
1790
|
+
* The state of the undo history (what `onUndoStackChanged` reports).
|
|
1791
|
+
*
|
|
1792
|
+
* @returns {GeUndoEvent | undefined} can undo/redo, labels, size; `undefined` without the option
|
|
1793
|
+
*
|
|
1794
|
+
* @example
|
|
1795
|
+
* const state = tableApi.getUndoState();
|
|
1796
|
+
* undoButton.title = state?.undoLabel ? `Undo ${state.undoLabel}` : "Undo";
|
|
1797
|
+
*
|
|
1798
|
+
* @since 1.1.99
|
|
1799
|
+
*/
|
|
1800
|
+
getUndoState(): GeUndoEvent | undefined;
|
|
1801
|
+
/**
|
|
1802
|
+
* Records all changes `fn` makes (several {@link applyCellChanges} calls, a fill and a paste …) as **one** undo step.
|
|
1803
|
+
* Without the option `fn` just runs.
|
|
1804
|
+
*
|
|
1805
|
+
* @param {string} label - the label of the step ("Undo Import")
|
|
1806
|
+
* @param {() => T} fn - the changes
|
|
1807
|
+
* @returns {T} what `fn` returns
|
|
1808
|
+
*
|
|
1809
|
+
* @example
|
|
1810
|
+
* tableApi.batchUndoable("Import", () => {
|
|
1811
|
+
* tableApi.applyCellChanges(firstChanges, "api", { undoable: true });
|
|
1812
|
+
* tableApi.applyCellChanges(secondChanges, "api", { undoable: true });
|
|
1813
|
+
* });
|
|
1814
|
+
*
|
|
1815
|
+
* @since 1.1.99
|
|
1816
|
+
*/
|
|
1817
|
+
batchUndoable<T>(label: string, fn: () => T): T;
|
|
1818
|
+
/**
|
|
1819
|
+
* True if the table calculates cell formulas ({@link TableOptionsIf.cellFormulas}, flat body).
|
|
1820
|
+
*
|
|
1821
|
+
* @returns {boolean} whether cell formulas are on
|
|
1822
|
+
*
|
|
1823
|
+
* @example
|
|
1824
|
+
* const showAddresses = tableApi.hasCellFormulas();
|
|
1825
|
+
*
|
|
1826
|
+
* @since 1.1.99
|
|
1827
|
+
*/
|
|
1828
|
+
hasCellFormulas(): boolean;
|
|
1829
|
+
/**
|
|
1830
|
+
* The address of a body cell in cell formulas: `"B3"` = second data column, third row of `getAllRows()` (the
|
|
1831
|
+
* physical row – sorting and filtering don't change it). `undefined` without cell formulas or for a row number or
|
|
1832
|
+
* checkbox column.
|
|
1833
|
+
*
|
|
1834
|
+
* @param {number} rowIndex - display row
|
|
1835
|
+
* @param {number | string} column - model column index or property
|
|
1836
|
+
* @returns {string | undefined} the address
|
|
1837
|
+
*
|
|
1838
|
+
* @example
|
|
1839
|
+
* tableApi.getCellAddress(1, "total"); // "D2" – the second row of getAllRows()
|
|
1840
|
+
*
|
|
1841
|
+
* @since 1.1.99
|
|
1842
|
+
*/
|
|
1843
|
+
getCellAddress(rowIndex: number, column: number | string): string | undefined;
|
|
1844
|
+
/**
|
|
1845
|
+
* The body cell of an address (`"B3"`, `"$B$3"`): display row (`-1` if a filter hides it) and model column;
|
|
1846
|
+
* `undefined` without cell formulas or for an address outside the data.
|
|
1847
|
+
*
|
|
1848
|
+
* @param {string} address - the address
|
|
1849
|
+
* @returns {[number, number] | undefined} display row and model column
|
|
1850
|
+
*
|
|
1851
|
+
* @example
|
|
1852
|
+
* const cell = tableApi.getCellByAddress("D5");
|
|
1853
|
+
* if (cell && cell[0] >= 0) tableApi.scrollToIndex(cell[1], cell[0]);
|
|
1854
|
+
*
|
|
1855
|
+
* @since 1.1.99
|
|
1856
|
+
*/
|
|
1857
|
+
getCellByAddress(address: string): [number, number] | undefined;
|
|
1858
|
+
/**
|
|
1859
|
+
* The input of a body cell – what was typed: the formula text of a cell formula (`"=B2*C2"`), otherwise the value.
|
|
1860
|
+
*
|
|
1861
|
+
* @param {number} rowIndex - display row
|
|
1862
|
+
* @param {number | string} column - model column index or property
|
|
1863
|
+
* @returns {unknown} the input
|
|
1864
|
+
*
|
|
1865
|
+
* @example
|
|
1866
|
+
* tableApi.getCellInput(1, "total"); // "=B2*C2"
|
|
1867
|
+
*
|
|
1868
|
+
* @since 1.1.99
|
|
1869
|
+
*/
|
|
1870
|
+
getCellInput(rowIndex: number, column: number | string): unknown;
|
|
1871
|
+
/**
|
|
1872
|
+
* The value of a body cell – the result of a cell formula (`2598`), otherwise the value (= `getValueAt`).
|
|
1873
|
+
*
|
|
1874
|
+
* @param {number} rowIndex - display row
|
|
1875
|
+
* @param {number | string} column - model column index or property
|
|
1876
|
+
* @returns {unknown} the value
|
|
1877
|
+
*
|
|
1878
|
+
* @example
|
|
1879
|
+
* tableApi.getCellValue(1, "total"); // 2598
|
|
1880
|
+
*
|
|
1881
|
+
* @since 1.1.99
|
|
1882
|
+
*/
|
|
1883
|
+
getCellValue(rowIndex: number, column: number | string): unknown;
|
|
1884
|
+
/**
|
|
1885
|
+
* Writes the input of a body cell (a value or a formula `"=B2*C2"`) like the editor: one {@link applyCellChanges}.
|
|
1886
|
+
*
|
|
1887
|
+
* @param {number} rowIndex - display row
|
|
1888
|
+
* @param {number | string} column - model column index or property
|
|
1889
|
+
* @param {unknown} input - the input
|
|
1890
|
+
* @returns {boolean} true if written (or marked in a batch edit)
|
|
1891
|
+
*
|
|
1892
|
+
* @example
|
|
1893
|
+
* tableApi.setCellInput(4, "total", "=SUM(D2:D4)");
|
|
1894
|
+
*
|
|
1895
|
+
* @since 1.1.99
|
|
1896
|
+
*/
|
|
1897
|
+
setCellInput(rowIndex: number, column: number | string, input: unknown): boolean;
|
|
1898
|
+
/**
|
|
1899
|
+
* Calculates a formula once against the sheet (not stored), e.g. for a preview: `"=SUM(D2:D4)"`.
|
|
1900
|
+
* `undefined` without cell formulas.
|
|
1901
|
+
*
|
|
1902
|
+
* @param {string} source - the formula (the `=` is optional)
|
|
1903
|
+
* @returns {unknown} the result (a {@link FormulaError} for an error)
|
|
1904
|
+
*
|
|
1905
|
+
* @example
|
|
1906
|
+
* tableApi.evaluateFormula("=SUM(D2:D4)"); // 3895
|
|
1907
|
+
*
|
|
1908
|
+
* @since 1.1.99
|
|
1909
|
+
*/
|
|
1910
|
+
evaluateFormula(source: string): unknown;
|
|
1911
|
+
/**
|
|
1912
|
+
* The value of a cell by its address – also of a row a filter hides. `undefined` without cell formulas.
|
|
1913
|
+
*
|
|
1914
|
+
* @param {string} address - e.g. `"D5"`
|
|
1915
|
+
* @returns {unknown} the value
|
|
1916
|
+
*
|
|
1917
|
+
* @example
|
|
1918
|
+
* tableApi.getSheetValue("D5"); // 3895
|
|
1919
|
+
*
|
|
1920
|
+
* @since 1.1.99
|
|
1921
|
+
*/
|
|
1922
|
+
getSheetValue(address: string): unknown;
|
|
1923
|
+
/**
|
|
1924
|
+
* Calculates all cell formulas again – after the app changed the data without the table ({@link updateCells},
|
|
1925
|
+
* {@link applyCellChanges} and the editor recalculate by themselves; {@link repaint} does not). Also renews
|
|
1926
|
+
* `TODAY()`, `NOW()` and `RAND()`.
|
|
1927
|
+
*
|
|
1928
|
+
* @example
|
|
1929
|
+
* rows[3].price = 30; // changed outside the table
|
|
1930
|
+
* tableApi.recalculate();
|
|
1931
|
+
*
|
|
1932
|
+
* @since 1.1.99
|
|
1933
|
+
*/
|
|
1934
|
+
recalculate(): void;
|
|
1935
|
+
/**
|
|
1936
|
+
* The cells and ranges a cell formula reads, as addresses.
|
|
1937
|
+
*
|
|
1938
|
+
* @param {number} rowIndex - display row
|
|
1939
|
+
* @param {number | string} column - model column index or property
|
|
1940
|
+
* @returns {string[]} e.g. `["B2", "C2"]` (empty for a value cell or without cell formulas)
|
|
1941
|
+
*
|
|
1942
|
+
* @example
|
|
1943
|
+
* tableApi.getPrecedents(1, "total"); // ["B2", "C2"]
|
|
1944
|
+
*
|
|
1945
|
+
* @since 1.1.99
|
|
1946
|
+
*/
|
|
1947
|
+
getPrecedents(rowIndex: number, column: number | string): string[];
|
|
1948
|
+
/**
|
|
1949
|
+
* The cells whose formulas read a cell directly (display row, model column; rows a filter hides are left out).
|
|
1950
|
+
*
|
|
1951
|
+
* @param {number} rowIndex - display row
|
|
1952
|
+
* @param {number | string} column - model column index or property
|
|
1953
|
+
* @returns {Array<[number, number]>} the dependent cells
|
|
1954
|
+
*
|
|
1955
|
+
* @example
|
|
1956
|
+
* tableApi.getDependents(1, "price"); // [[1, 3]] – D2 reads B2
|
|
1957
|
+
*
|
|
1958
|
+
* @since 1.1.99
|
|
1959
|
+
*/
|
|
1960
|
+
getDependents(rowIndex: number, column: number | string): Array<[number, number]>;
|
|
1961
|
+
/**
|
|
1962
|
+
* The formula engine of the cell formulas (`undefined` without them) – physical rows, data columns.
|
|
1963
|
+
*
|
|
1964
|
+
* @returns {SheetEngine | undefined} the engine
|
|
1965
|
+
*
|
|
1966
|
+
* @example
|
|
1967
|
+
* tableApi.getSheetEngine()?.getFormulaCount(); // 4
|
|
1968
|
+
*
|
|
1969
|
+
* @since 1.1.99
|
|
1970
|
+
*/
|
|
1971
|
+
getSheetEngine(): SheetEngine | undefined;
|
|
1972
|
+
/**
|
|
1973
|
+
* The active body cell (the focused cell), `undefined` if there is none or the header has the focus.
|
|
1974
|
+
*
|
|
1975
|
+
* @returns {[number, number] | undefined} display row and model column
|
|
1976
|
+
*
|
|
1977
|
+
* @example
|
|
1978
|
+
* const cell = tableApi.getActiveCell();
|
|
1979
|
+
* if (cell) console.log(tableApi.getCellAddress(cell[0], cell[1])); // "B3"
|
|
1980
|
+
*
|
|
1981
|
+
* @since 1.1.99
|
|
1982
|
+
*/
|
|
1983
|
+
getActiveCell(): [number, number] | undefined;
|
|
1984
|
+
/**
|
|
1985
|
+
* Goes to a cell or range of the sheet by its address (cell formulas): `"D10"` makes it the active cell, `"B2:C5"`
|
|
1986
|
+
* selects the range (its first cell becomes active); the view scrolls to it. `false` for an invalid address, one
|
|
1987
|
+
* outside the data or a row a filter hides.
|
|
1988
|
+
*
|
|
1989
|
+
* @param {string} address - e.g. `"D10"`, `"$B$2:C5"`
|
|
1990
|
+
* @returns {boolean} true if it went there
|
|
1991
|
+
*
|
|
1992
|
+
* @example
|
|
1993
|
+
* tableApi.goToAddress("B2:C5");
|
|
1994
|
+
*
|
|
1995
|
+
* @since 1.1.99
|
|
1996
|
+
*/
|
|
1997
|
+
goToAddress(address: string): boolean;
|
|
1998
|
+
/**
|
|
1999
|
+
* Inserts empty rows before a row of the sheet (`at` = row number − 1, the physical row: also when sorted or
|
|
2000
|
+
* filtered) and adjusts the cell formulas (`=SUM(D2:D4)` grows when rows are inserted inside). One undo step, one
|
|
2001
|
+
* `onModelChanged` (source `"structure"`). Works for a spreadsheet ({@link SpreadsheetFactory}), object rows (new
|
|
2002
|
+
* objects from `clipboard.createRow`, otherwise `{}` – the app's array changes in place) and arrays.
|
|
2003
|
+
*
|
|
2004
|
+
* @param {number} at - the physical row the new rows come before (row count = append)
|
|
2005
|
+
* @param {number} [count=1] - rows
|
|
2006
|
+
* @returns {boolean} true if inserted
|
|
2007
|
+
*
|
|
2008
|
+
* @example
|
|
2009
|
+
* tableApi.insertRows(4, 2); // two empty rows before row 5
|
|
2010
|
+
*
|
|
2011
|
+
* @since 1.1.99
|
|
2012
|
+
*/
|
|
2013
|
+
insertRows(at: number, count?: number): boolean;
|
|
2014
|
+
/**
|
|
2015
|
+
* Deletes rows of the sheet (`at` = row number − 1) and adjusts the cell formulas (a deleted reference becomes
|
|
2016
|
+
* `#REF!`). One undo step.
|
|
2017
|
+
*
|
|
2018
|
+
* @param {number} at - the first physical row
|
|
2019
|
+
* @param {number} [count=1] - rows
|
|
2020
|
+
* @returns {boolean} true if deleted
|
|
2021
|
+
*
|
|
2022
|
+
* @example
|
|
2023
|
+
* tableApi.deleteRows(2); // row 3
|
|
2024
|
+
*
|
|
2025
|
+
* @since 1.1.99
|
|
2026
|
+
*/
|
|
2027
|
+
deleteRows(at: number, count?: number): boolean;
|
|
2028
|
+
/**
|
|
2029
|
+
* Inserts empty columns before a column of a spreadsheet ({@link SpreadsheetFactory}; `at` = letter index, A = 0)
|
|
2030
|
+
* and adjusts the cell formulas. One undo step.
|
|
2031
|
+
*
|
|
2032
|
+
* @param {number} at - the data column the new columns come before
|
|
2033
|
+
* @param {number} [count=1] - columns
|
|
2034
|
+
* @returns {boolean} true if inserted (`false` for other models)
|
|
2035
|
+
*
|
|
2036
|
+
* @example
|
|
2037
|
+
* tableApi.insertColumns(1); // a new column B
|
|
2038
|
+
*
|
|
2039
|
+
* @since 1.1.99
|
|
2040
|
+
*/
|
|
2041
|
+
insertColumns(at: number, count?: number): boolean;
|
|
2042
|
+
/**
|
|
2043
|
+
* Deletes columns of a spreadsheet (`at` = letter index, A = 0) and adjusts the cell formulas. One undo step.
|
|
2044
|
+
*
|
|
2045
|
+
* @param {number} at - the first data column
|
|
2046
|
+
* @param {number} [count=1] - columns
|
|
2047
|
+
* @returns {boolean} true if deleted (`false` for other models)
|
|
2048
|
+
*
|
|
2049
|
+
* @example
|
|
2050
|
+
* tableApi.deleteColumns(2); // column C
|
|
2051
|
+
*
|
|
2052
|
+
* @since 1.1.99
|
|
2053
|
+
*/
|
|
2054
|
+
deleteColumns(at: number, count?: number): boolean;
|
|
2055
|
+
/**
|
|
2056
|
+
* The inputs of a spreadsheet ({@link SpreadsheetFactory}) as rows × columns – formulas as text, up to the last
|
|
2057
|
+
* filled row and column (empty cells `""`). Save them; `SpreadsheetFactory.create({ data })` loads them again.
|
|
2058
|
+
* `undefined` for other models (their data are the app's rows).
|
|
2059
|
+
*
|
|
2060
|
+
* @returns {unknown[][] | undefined} the data
|
|
2061
|
+
*
|
|
2062
|
+
* @example
|
|
2063
|
+
* localStorage.setItem("sheet", JSON.stringify(tableApi.getSheetData()));
|
|
2064
|
+
*
|
|
2065
|
+
* @since 1.1.99
|
|
2066
|
+
*/
|
|
2067
|
+
getSheetData(): unknown[][] | undefined;
|
|
2068
|
+
/** A column index or property → index (`-1` if unknown). */
|
|
2069
|
+
private toColumnIndex;
|
|
1561
2070
|
/**
|
|
1562
2071
|
* Expands or collapses the detail row of a master row (master/detail, {@link TableOptionsIf.masterDetail}). The
|
|
1563
2072
|
* content is created when the detail row becomes visible; collapsing destroys it. Reports
|