@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.
Files changed (110) hide show
  1. package/README.md +12 -0
  2. package/css/main.css +381 -27
  3. package/css/table-classes.css +33 -9
  4. package/css/table-clipboard.css +41 -0
  5. package/css/table-color-vars.css +56 -0
  6. package/css/table-fill-batch.css +9 -2
  7. package/css/table-master-detail.css +20 -0
  8. package/css/table-sheet-editing.css +149 -0
  9. package/css/table-spreadsheet.css +50 -0
  10. package/css/table-tree.css +23 -16
  11. package/index.cjs +54 -67
  12. package/index.d.ts +52 -0
  13. package/index.js +18968 -11475
  14. package/lib/table/action/action-id.type.d.ts +1 -1
  15. package/lib/table/action/shortcut.service.d.ts +9 -0
  16. package/lib/table/aria/aria-texts.d.ts +26 -0
  17. package/lib/table/aria/aria-texts.if.d.ts +196 -0
  18. package/lib/table/batch-edit/batch-edit-service.d.ts +22 -0
  19. package/lib/table/batch-edit/cell-change.if.d.ts +6 -2
  20. package/lib/table/batch-edit/pending-cell-changes.d.ts +7 -0
  21. package/lib/table/batch-edit/write-row-value.d.ts +14 -0
  22. package/lib/table/calc/column-values.d.ts +2 -0
  23. package/lib/table/clipboard/clipboard-html.d.ts +41 -0
  24. package/lib/table/clipboard/clipboard-keymap.d.ts +18 -0
  25. package/lib/table/clipboard/clipboard-options.d.ts +30 -0
  26. package/lib/table/clipboard/clipboard-options.if.d.ts +67 -0
  27. package/lib/table/clipboard/clipboard-service.d.ts +122 -0
  28. package/lib/table/clipboard/input-pipes.d.ts +59 -0
  29. package/lib/table/clipboard/paste-plan.d.ts +96 -0
  30. package/lib/table/clipboard/tsv.d.ts +31 -0
  31. package/lib/table/crud/crud-object-edit.d.ts +2 -0
  32. package/lib/table/crud/crud-object-view.d.ts +2 -0
  33. package/lib/table/crud/crud-table-model-factory.d.ts +2 -0
  34. package/lib/table/data/common/event/ge-edit-event.d.ts +46 -0
  35. package/lib/table/data/common/event/ge-row-drag-event.d.ts +2 -2
  36. package/lib/table/data/common/event/ge-undo-event.d.ts +29 -0
  37. package/lib/table/data/options/table-options.d.ts +34 -0
  38. package/lib/table/data/options/table-options.if.d.ts +116 -1
  39. package/lib/table/data/tablemodel/areamodel/abstract-area-model.d.ts +11 -2
  40. package/lib/table/data/tablemodel/areamodel/area-model-array-of-arrays.d.ts +14 -0
  41. package/lib/table/data/tablemodel/areamodel/area-model-object-array.d.ts +14 -0
  42. package/lib/table/data/tablemodel/areamodel/area-model.if.d.ts +11 -0
  43. package/lib/table/data/tablemodel/column/column-def.d.ts +13 -0
  44. package/lib/table/data/tablemodel/column/column-def.if.d.ts +36 -1
  45. package/lib/table/data/tablemodel/column/default-editable.d.ts +18 -0
  46. package/lib/table/ele-scope.d.ts +37 -0
  47. package/lib/table/event-adapter.d.ts +6 -0
  48. package/lib/table/event-listener-hub.d.ts +10 -0
  49. package/lib/table/event-listener.if.d.ts +16 -0
  50. package/lib/table/factory/pivot-factory.d.ts +1 -1
  51. package/lib/table/factory/row-group-factory.d.ts +1 -1
  52. package/lib/table/factory/table-factory.d.ts +14 -0
  53. package/lib/table/formula/formula-ast.if.d.ts +32 -2
  54. package/lib/table/formula/formula-error.d.ts +4 -2
  55. package/lib/table/formula/parser.d.ts +5 -2
  56. package/lib/table/formula/tokenizer.d.ts +5 -2
  57. package/lib/table/input-handler.d.ts +8 -0
  58. package/lib/table/master-detail/master-detail-service.d.ts +9 -0
  59. package/lib/table/render-scope.d.ts +40 -0
  60. package/lib/table/row-drag/row-drag-service.d.ts +3 -2
  61. package/lib/table/rtl/rtl-util.d.ts +126 -0
  62. package/lib/table/rtl/table-direction.type.d.ts +23 -0
  63. package/lib/table/selection/selection-service.d.ts +48 -0
  64. package/lib/table/service/convenience-dom.service.d.ts +49 -1
  65. package/lib/table/service/excel-export-options.if.d.ts +23 -0
  66. package/lib/table/service/excel-service.d.ts +12 -2
  67. package/lib/table/service/excel-service.if.d.ts +38 -1
  68. package/lib/table/sheet/cell-address.d.ts +100 -0
  69. package/lib/table/sheet/cell-formula-options.d.ts +27 -0
  70. package/lib/table/sheet/cell-formula-options.if.d.ts +27 -0
  71. package/lib/table/sheet/excel-formula.d.ts +20 -0
  72. package/lib/table/sheet/format-formula.d.ts +19 -0
  73. package/lib/table/sheet/sheet-cells.if.d.ts +17 -0
  74. package/lib/table/sheet/sheet-compiler.d.ts +47 -0
  75. package/lib/table/sheet/sheet-engine.d.ts +207 -0
  76. package/lib/table/sheet/sheet-function-info.d.ts +25 -0
  77. package/lib/table/sheet/sheet-functions.d.ts +27 -0
  78. package/lib/table/sheet/sheet-values.d.ts +154 -0
  79. package/lib/table/sheet/shift-formula.d.ts +71 -0
  80. package/lib/table/sheet/table-sheet.d.ts +214 -0
  81. package/lib/table/sheet-editing/cell-editor-service.d.ts +105 -0
  82. package/lib/table/sheet-editing/cell-editor.if.d.ts +110 -0
  83. package/lib/table/sheet-editing/editing-keymap.d.ts +17 -0
  84. package/lib/table/sheet-editing/editing-options.d.ts +34 -0
  85. package/lib/table/sheet-editing/editing-options.if.d.ts +49 -0
  86. package/lib/table/sheet-editing/editors/date-cell-editor.d.ts +23 -0
  87. package/lib/table/sheet-editing/editors/number-cell-editor.d.ts +18 -0
  88. package/lib/table/sheet-editing/editors/select-cell-editor.d.ts +36 -0
  89. package/lib/table/sheet-editing/editors/text-cell-editor.d.ts +35 -0
  90. package/lib/table/sheet-editing/formula-assist.d.ts +103 -0
  91. package/lib/table/sheet-editing/formula-text.d.ts +61 -0
  92. package/lib/table/sheet-editing/sheet-navigation.d.ts +26 -0
  93. package/lib/table/spreadsheet/area-model-sheet.d.ts +170 -0
  94. package/lib/table/spreadsheet/formula-bar.d.ts +53 -0
  95. package/lib/table/spreadsheet/spreadsheet-factory.d.ts +111 -0
  96. package/lib/table/spreadsheet/spreadsheet-options.if.d.ts +28 -0
  97. package/lib/table/spreadsheet/spreadsheet-preset.d.ts +37 -0
  98. package/lib/table/spreadsheet/structure-edit.d.ts +35 -0
  99. package/lib/table/table-api.d.ts +533 -4
  100. package/lib/table/table-scope.d.ts +299 -1
  101. package/lib/table/undo/cell-changes-undoable.d.ts +34 -0
  102. package/lib/table/undo/model-rows.d.ts +17 -0
  103. package/lib/table/undo/pending-changes-undoable.d.ts +35 -0
  104. package/lib/table/undo/undo-keymap.d.ts +17 -0
  105. package/lib/table/undo/undo-options.d.ts +26 -0
  106. package/lib/table/undo/undo-options.if.d.ts +30 -0
  107. package/lib/table/undo/undo-service.d.ts +103 -0
  108. package/lib/table/undo/undo-stack.d.ts +62 -0
  109. package/lib/table/undo/undoable.if.d.ts +36 -0
  110. package/package.json +1 -1
@@ -44,6 +44,12 @@ import { FillDirection } from './fill/fill-direction.type.js';
44
44
  import { FillMode } from './fill/fill-series.js';
45
45
  import { CellRange } from './data/common/cell-range.js';
46
46
  import { AriaTextsIf } from './aria/aria-texts.if.js';
47
+ import { EditingOptionsIf } from './sheet-editing/editing-options.if.js';
48
+ import { CellEditMode } from './sheet-editing/cell-editor.if.js';
49
+ import { ClipboardService } from './clipboard/clipboard-service.js';
50
+ import { UndoOptionsIf } from './undo/undo-options.if.js';
51
+ import { UndoService } from './undo/undo-service.js';
52
+ import { ShortcutActionIdMapping } from './action/shortcut-actionid-mapping.type.js';
47
53
 
48
54
  /**
49
55
  * Creates and runs one table in a host element – the core that every framework wrapper uses.
@@ -124,7 +130,26 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
124
130
  private firstDraggingRendering;
125
131
  /** Last comparator passed to `sort()`; re-applied after filtering. Cleared by a header sort. */
126
132
  private lastSortCompareFn?;
133
+ /** Excel-style editing (`tableOptions.editing`), `undefined` = off. @since 1.1.99 */
134
+ private readonly editingOptions?;
135
+ /** Listeners of {@link TableApi.subscribe}. @since 1.1.99 */
136
+ private readonly subscribers;
137
+ /** Copy, cut and paste (`tableOptions.clipboard`), `undefined` = off. @since 1.1.99 */
138
+ private readonly clipboardOptions?;
139
+ /** Copy, cut and paste: with the option keys and events, otherwise created for the API. @since 1.1.99 */
140
+ clipboardService?: ClipboardService;
141
+ /** Undo and redo (`tableOptions.undo`), `undefined` = off. @since 1.1.99 */
142
+ private readonly undoOptions?;
143
+ /** Undo and redo: records the changes of the write path (only with the option). @since 1.1.99 */
144
+ undoService?: UndoService;
145
+ /** The key event the {@link ShortcutService} is handling right now (`undefined` for `triggerAction`). @since 1.1.99 */
146
+ shortcutKeyEvent?: KeyboardEvent;
127
147
  constructor(hostElement: HTMLDivElement, tableModel: TableModelIf, domService: DomServiceIf, tableOptions: TableOptionsIf, eventListener: EventListenerIf, copyService?: CopyServiceIf, excelService?: ExcelServiceIf);
148
+ /**
149
+ * The options of a nested table (master/detail `ctx.createTable()`): as given; without an own `direction` in a
150
+ * right-to-left table an object that reads everything else from the given options (prototype) and adds `"rtl"`.
151
+ */
152
+ private nestedTableOptions;
128
153
  /** Time of the last Tab key press on the page (the host is focused right after it). */
129
154
  private lastTabKeyTime;
130
155
  /**
@@ -154,6 +179,154 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
154
179
  * @return {boolean} - Returns true if the action was triggered successfully, false otherwise.
155
180
  */
156
181
  onActionTriggered(actionId: ActionId): boolean;
182
+ /**
183
+ * The options of Excel-style editing ({@link TableOptionsIf.editing}), `undefined` if it is off.
184
+ *
185
+ * @returns {EditingOptionsIf | undefined} complete options
186
+ * @since 1.1.99
187
+ */
188
+ getEditingOptions(): EditingOptionsIf | undefined;
189
+ /**
190
+ * Shortcut layers of switched-on features, applied over the system mapping (see {@link ShortcutService}).
191
+ *
192
+ * @param {boolean} mac - macOS keys
193
+ * @returns {ShortcutActionIdMapping[]} the layers (none without Excel-style editing)
194
+ * @since 1.1.99
195
+ */
196
+ getShortcutLayers(mac: boolean): ShortcutActionIdMapping[];
197
+ /**
198
+ * Adds a listener next to the one given to the constructor (see {@link TableApi.subscribe}).
199
+ *
200
+ * @param {Partial<EventListenerIf>} listener - the events of interest
201
+ * @returns {() => void} removes the listener again
202
+ * @since 1.1.99
203
+ */
204
+ subscribe(listener: Partial<EventListenerIf>): () => void;
205
+ /**
206
+ * Opens the cell editor of a body cell: the editor above the cell (Excel-style editing) or – for columns with an
207
+ * own `getEditRenderer`, and without `tableOptions.editing` – the editor inside the cell.
208
+ *
209
+ * @param {number} rowIndex - display row index
210
+ * @param {number} columnIndex - model column index
211
+ * @param {CellEditMode} [mode="edit"] - "edit" (F2, Enter, double click) or "enter" (typing)
212
+ * @param {"all" | "end"} [textSelection] - select the text or put the caret at the end (default: the option)
213
+ * @returns {boolean} true if an editor is open
214
+ * @since 1.1.99
215
+ */
216
+ startEditing(rowIndex: number, columnIndex: number, mode?: CellEditMode, textSelection?: 'all' | 'end'): boolean;
217
+ /** True if a new editor may open now: no header focus, no blocking overlay, no running drag or fill. @since 1.1.99 */
218
+ canStartEditing(): boolean;
219
+ /**
220
+ * The value a body cell shows: a pending value of a batch edit, otherwise the model value – with cell formulas the
221
+ * input ({@link getCellInput}: the formula text for the editor).
222
+ *
223
+ * @param {number} rowIndex - display row index
224
+ * @param {number} columnIndex - model column index
225
+ * @returns {unknown} the value
226
+ * @since 1.1.99
227
+ */
228
+ getShownCellValue(rowIndex: number, columnIndex: number): unknown;
229
+ /** The body cell with the keyboard focus, `undefined` if there is none (or the header has the focus). @since 1.1.99 */
230
+ getActiveBodyCell(): [number, number] | undefined;
231
+ /**
232
+ * Builds the view again after rows or columns were inserted or deleted (filter and sorting applied again, new
233
+ * columns measured).
234
+ *
235
+ * @param {boolean} columns - true: the columns changed
236
+ * @since 1.1.99
237
+ */
238
+ refreshAfterStructureChange(columns: boolean): void;
239
+ /**
240
+ * The next shown column in a direction (hidden columns skipped; the same column at the edge).
241
+ *
242
+ * @param {number} columnIndex - model column index
243
+ * @param {number} direction - 1 or -1
244
+ * @returns {number} the column
245
+ * @since 1.1.99
246
+ */
247
+ nextShownColumn(columnIndex: number, direction: number): number;
248
+ /**
249
+ * True if there is a shown column (no row number column) next to `columnIndex` in that direction – Tab uses it:
250
+ * in the last column it leaves the table.
251
+ *
252
+ * @param {number} columnIndex - model column index
253
+ * @param {number} direction - 1 or -1
254
+ * @returns {boolean} true if Tab can move
255
+ * @since 1.1.99
256
+ */
257
+ hasShownColumnBeside(columnIndex: number, direction: number): boolean;
258
+ /**
259
+ * Moves the keyboard focus from a cell by rows/columns (Excel-style editing: Enter, Tab and arrow keys after
260
+ * committing); the selection follows with `collapseSelectionOnNavigate`.
261
+ *
262
+ * @param {number} rowIndex - start row
263
+ * @param {number} columnIndex - start column
264
+ * @param {number} dRow - rows
265
+ * @param {number} dColumn - columns (hidden columns are skipped)
266
+ * @returns {boolean} true if a focus model exists
267
+ * @since 1.1.99
268
+ */
269
+ moveActiveCell(rowIndex: number, columnIndex: number, dRow: number, dColumn: number): boolean;
270
+ /**
271
+ * The selected body cells (shown columns, inside the table) – `undefined` if there are more than `maxCells`.
272
+ *
273
+ * @param {number} maxCells - upper limit
274
+ * @returns {Array<[number, number]> | undefined} row and column per cell; none without selection
275
+ * @since 1.1.99
276
+ */
277
+ getSelectedBodyCells(maxCells: number): Array<[number, number]> | undefined;
278
+ /**
279
+ * The body cells of the selection (or of `given` ranges): clamped to the table, shown columns without row number
280
+ * column, each cell once – `undefined` if there are more than `maxCells` (checked before the cells are visited).
281
+ */
282
+ private collectSelectedBodyCells;
283
+ /**
284
+ * Clears body cells (Delete in Excel-style editing): editable cells get `ColumnDef.emptyValue` (default
285
+ * `EditingOptionsIf.emptyValue`, `""`), cells that are already empty are left alone; **one** `onModelChanged` with
286
+ * the source `"clear"`. Without `ranges`: the selected cells, or the focused cell.
287
+ *
288
+ * @param {CellRange[]} [ranges] - body ranges (display indices)
289
+ * @returns {number} the number of cleared cells; `-1` if more than `maxClearCells`
290
+ * @since 1.1.99
291
+ */
292
+ clearCells(ranges?: CellRange[]): number;
293
+ /**
294
+ * Writes the value of the editor above the cell (Excel-style editing): into one cell, or – Ctrl/⌘+Enter – into
295
+ * several; batch edit: marks it. Used by {@link CellEditorService}.
296
+ *
297
+ * @param {Array<[number, number]>} cells - display row and model column per cell
298
+ * @param {unknown} value - the editor value (it runs through `editInputPipe` and `validate`)
299
+ * @param {boolean} deferRepaint - repaint after the current mouse click
300
+ * @returns {{ written: number, invalid: number, message?: string }} what happened
301
+ * @since 1.1.99
302
+ */
303
+ commitCellEditor(cells: Array<[number, number]>, value: unknown, deferRepaint: boolean): {
304
+ written: number;
305
+ invalid: number;
306
+ message?: string;
307
+ };
308
+ /**
309
+ * Space on a cell with a `true`/`false` value (Excel-style editing): writes the opposite value.
310
+ *
311
+ * @param {number} rowIndex - display row index
312
+ * @param {number} columnIndex - model column index
313
+ * @since 1.1.99
314
+ */
315
+ toggleBooleanCell(rowIndex: number, columnIndex: number): void;
316
+ /** The texts of Excel-style editing (own functions of `tableOptions.ariaTexts`, otherwise English). @since 1.1.99 */
317
+ getSheetTexts(): Required<Pick<AriaTextsIf, 'editingStarted' | 'readOnlyCell' | 'cellsCleared' | 'clearTooLarge' | 'rangeSelected' | 'rowSelected' | 'columnSelected' | 'gridEditingHint' | 'cellsPasted' | 'pasteTooLarge' | 'copyTooLarge' | 'cutMarked' | 'copiedLastRangeOnly'>>;
318
+ /** The keys of Excel-style editing that are ActionIds (Tab, Shift+arrows, Ctrl+arrows, Delete …). */
319
+ private onSheetAction;
320
+ /** The moving corner of the selected range (Shift+arrows), the active cell if there is none. */
321
+ private getSelectionExtent;
322
+ /** The first shown column that is no row number column. */
323
+ private getFirstShownDataColumnIndex;
324
+ /** Ctrl+arrow: Excel's edge of the data block from a cell (shown columns, no row number column). */
325
+ private dataEdge;
326
+ /** Shift+arrows: the range from the anchor to `(row, column)`, scrolled into view and announced. */
327
+ private extendSelectionTo;
328
+ /** Shift+Space / Ctrl+Space: the rows (columns) of the last range or of the active cell. */
329
+ private selectWholeRowsOrColumns;
157
330
  /**
158
331
  * The event listener of this table (the one given to the constructor, or an empty {@link EventAdapter}).
159
332
  *
@@ -222,6 +395,8 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
222
395
  getHeaderFocus(): [number, number] | undefined;
223
396
  /** Moves the body focus to a cell, scrolls it into view and repaints (also leaves the header). */
224
397
  private setFocusCell;
398
+ /** Excel-style editing: the keyboard moved the active cell – it becomes the selection and the anchor. */
399
+ private afterActiveCellMoved;
225
400
  private getFirstShownColumnIndex;
226
401
  private getLastShownColumnIndex;
227
402
  /** Home, End, Ctrl+Home, Ctrl+End, Page Up/Down and Enter in the body; `undefined` = not such an action. */
@@ -268,7 +443,9 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
268
443
  * @returns {CellChangeIf[]} the written (or, in a batch edit, newly pending) cells
269
444
  * @since 1.1.96
270
445
  */
271
- applyCellChanges(changes: CellValueChangeIf[], source?: CellChangeSource): CellChangeIf[];
446
+ applyCellChanges(changes: CellValueChangeIf[], source?: CellChangeSource, opts?: {
447
+ undoable?: boolean;
448
+ }): CellChangeIf[];
272
449
  /**
273
450
  * Writes cell values directly (no batch edit) – used by {@link applyCellChanges} and the batch commit.
274
451
  *
@@ -288,6 +465,122 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
288
465
  skipValidation?: boolean;
289
466
  }): CellChangeIf[];
290
467
  private writeCellsInternal;
468
+ /**
469
+ * Writes pasted cells (copy, cut and paste): like {@link applyCellChanges} – not editable cells skipped, `validate`,
470
+ * batch edit marks – with **one** `onModelChanged`; `raw` = values copied inside the table (no `editInputPipe`).
471
+ *
472
+ * @param {CellValueChangeIf[]} changes - target cells (and emptied cut cells)
473
+ * @param {CellChangeSource} source - `"paste"` or `"cut"`
474
+ * @param {boolean} raw - true: without `editInputPipe`
475
+ * @returns {CellChangeIf[]} the written (batch edit: newly pending) cells
476
+ * @since 1.1.99
477
+ */
478
+ writePastedCells(changes: CellValueChangeIf[], source: CellChangeSource, raw: boolean): CellChangeIf[];
479
+ /**
480
+ * Selects a body range (after pasting): its first cell becomes the active cell and the anchor.
481
+ *
482
+ * @param {CellRange} range - display rows, model columns
483
+ * @since 1.1.99
484
+ */
485
+ selectBodyRange(range: CellRange): void;
486
+ /**
487
+ * The message of the column's `validate` for a value that would be pasted, `undefined` if it is valid.
488
+ *
489
+ * @param {number} rowIndex - display row
490
+ * @param {number} columnIndex - model column
491
+ * @param {unknown} value - the value
492
+ * @param {boolean} raw - true: without `editInputPipe`
493
+ * @returns {string | undefined} the message
494
+ * @since 1.1.99
495
+ */
496
+ checkPastedValue(rowIndex: number, columnIndex: number, value: unknown, raw: boolean): string | undefined;
497
+ /**
498
+ * The input of a body cell – what was typed: the formula text of a cell formula (`"=B2*C2"`), otherwise the value
499
+ * ({@link AreaModelIf.getInputValueAt}). Editor, undo and the batch edit use it.
500
+ *
501
+ * @param {number} rowIndex - display row
502
+ * @param {number} columnIndex - model column
503
+ * @returns {unknown} the input
504
+ * @since 1.1.99
505
+ */
506
+ getCellInput(rowIndex: number, columnIndex: number): unknown;
507
+ /**
508
+ * The value of a body cell to choose an editor or convert pasted text by: the result of a formula cell (a number
509
+ * stays a number when overwritten), otherwise {@link getShownCellValue}.
510
+ *
511
+ * @param {number} rowIndex - display row
512
+ * @param {number} columnIndex - model column
513
+ * @returns {unknown} the value
514
+ * @since 1.1.99
515
+ */
516
+ getTypedCellValue(rowIndex: number, columnIndex: number): unknown;
517
+ /**
518
+ * The announcement of a stored formula with a syntax error (`AriaTextsIf.formulaError`).
519
+ *
520
+ * @param {string} message - the parser's message
521
+ * @returns {string} the text
522
+ * @since 1.1.99
523
+ */
524
+ getFormulaErrorText(message: string): string;
525
+ /** A syntax error of a formula refuses it only with `rejectInvalidFormulas` (otherwise it is stored: `#ERROR!`). */
526
+ private checkFormulaSyntax;
527
+ /**
528
+ * Resolves a formula copied inside the table for a target cell: its relative references move (Excel); a target
529
+ * without formulas gets the copied value. A cut formula moves unchanged.
530
+ *
531
+ * @param {unknown} value - a pasted value (maybe a {@link CopiedFormula})
532
+ * @param {number} rowIndex - display row of the target
533
+ * @param {number} columnIndex - model column of the target
534
+ * @param {boolean} cut - true: the formula moves (cut and paste)
535
+ * @returns {unknown} the value to write
536
+ * @since 1.1.99
537
+ */
538
+ resolvePastedValue(value: unknown, rowIndex: number, columnIndex: number, cut: boolean): unknown;
539
+ /**
540
+ * The value of a cell for a copy inside the table: a formula cell gives a {@link CopiedFormula}.
541
+ *
542
+ * @param {number} rowIndex - display row
543
+ * @param {number} columnIndex - model column
544
+ * @returns {unknown} the value
545
+ * @since 1.1.99
546
+ */
547
+ getCopyValue(rowIndex: number, columnIndex: number): unknown;
548
+ /** True while a batch edit collects changes. @since 1.1.99 */
549
+ isBatchEditActive(): boolean;
550
+ /** The options of undo and redo ({@link TableOptionsIf.undo}), `undefined` if it is off. @since 1.1.99 */
551
+ getUndoOptions(): UndoOptionsIf | undefined;
552
+ /**
553
+ * Writes the values of an undo or redo: without `editInputPipe` (the values were piped already) and validation, only
554
+ * editable cells; cells of hidden rows (`hidden`, written into their objects already) in the same event; no new
555
+ * step.
556
+ *
557
+ * @param {{ rowIndex: number, columnIndex: number, value: unknown }[]} cells - shown cells
558
+ * @param {CellChangeIf[]} hidden - cells of rows a filter hides
559
+ * @param {"undo" | "redo"} source - reported in the event
560
+ * @returns {CellChangeIf[]} the written cells (including `hidden`)
561
+ * @since 1.1.99
562
+ */
563
+ writeUndoCells(cells: {
564
+ rowIndex: number;
565
+ columnIndex: number;
566
+ value: unknown;
567
+ }[], hidden: CellChangeIf[], source: 'undo' | 'redo'): CellChangeIf[];
568
+ /** The texts of undo and redo (own functions of `tableOptions.ariaTexts`, otherwise English). @since 1.1.99 */
569
+ getUndoTexts(): Required<Pick<AriaTextsIf, 'undone' | 'redone' | 'nothingToUndo' | 'nothingToRedo' | 'undoSkipped' | 'undoHistoryCleared'>>;
570
+ /** True while an overlay blocks the table ("Loading…"). @since 1.1.99 */
571
+ isOverlayBlocking(): boolean;
572
+ /** Rows were added at the end of the body (pasting with `pasteAddsRows`): derived values are recomputed. @since 1.1.99 */
573
+ rowsAppended(): void;
574
+ /** True for a tree, a row grouping or a pivot table in the body (rows cannot simply be appended). @since 1.1.99 */
575
+ isRowGroupingOrTree(): boolean;
576
+ /**
577
+ * The clipboard service for the API ({@link TableApi.pasteText}, {@link TableApi.getSelectionAsText}): the one of
578
+ * the option, otherwise one with the defaults that does not listen to keys or events.
579
+ *
580
+ * @returns {ClipboardService} the service
581
+ * @since 1.1.99
582
+ */
583
+ getClipboardService(): ClipboardService;
291
584
  /** Marks values as pending (batch edit): pipe, validation, then the batch edit service. */
292
585
  private markPending;
293
586
  /**
@@ -321,6 +614,11 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
321
614
  * @since 1.1.96
322
615
  */
323
616
  fillRange(source: CellRange, direction: FillDirection, count: number, mode?: FillMode, selectAfter?: CellRange): number;
617
+ /**
618
+ * Cell formulas (since 1.1.99): a filled cell whose source cell (the source repeats) holds a formula gets the formula
619
+ * with moved references (Excel: `=B2*C2` → `=B3*C3`, `$B$1` stays) instead of a series value.
620
+ */
621
+ private moveFilledFormulas;
324
622
  /** The last selected range, clamped to the body (`undefined` without one). */
325
623
  getFillSourceRange(): CellRange | undefined;
326
624
  private normalizeRange;
@@ -0,0 +1,34 @@
1
+ import { TableScope } from '../table-scope.js';
2
+ import { CellChangeIf, CellChangeSource } from '../batch-edit/cell-change.if.js';
3
+ import { UndoableIf, UndoResultIf } from './undoable.if.js';
4
+
5
+ /**
6
+ * A step of written cells (an edit, a fill, a paste …): undo writes the old values back, redo the new ones. The cells
7
+ * are found by row **object** and property – sorting and filtering in between don't matter; a row a filter hides is
8
+ * written directly into its object (reported in the same event), a row that left the model is skipped. A cell that
9
+ * no longer has the expected value is skipped (`onConflict: "skip"`) or overwritten.
10
+ *
11
+ * @category Spreadsheet
12
+ * @since 1.1.99
13
+ */
14
+ export declare class CellChangesUndoable implements UndoableIf {
15
+ readonly label: string;
16
+ readonly source: CellChangeSource;
17
+ private readonly entries;
18
+ /**
19
+ * @param {string} label - for buttons and announcements
20
+ * @param {CellChangeSource} source - what started the step
21
+ * @param {CellChangeIf[]} changes - the written cells (`GeModelChangeEvent.changes`)
22
+ */
23
+ constructor(label: string, source: CellChangeSource, changes: CellChangeIf[]);
24
+ get cellCount(): number;
25
+ /**
26
+ * Adds cells written by the same user action (an `onModelChanged` handler that derives values) to this step.
27
+ *
28
+ * @param {CellChangeIf[]} changes - the written cells
29
+ */
30
+ append(changes: CellChangeIf[]): void;
31
+ undo(scope: TableScope): UndoResultIf;
32
+ redo(scope: TableScope): UndoResultIf;
33
+ private apply;
34
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The rows array of a body model (object array: `getAllRows`, row grouping: `getSourceRows`, array of arrays: `arr`,
3
+ * tree: its root rows) – another array means `setRows` replaced the data.
4
+ *
5
+ * @param {unknown} body - the body area model
6
+ * @returns {unknown[] | undefined} the array, `undefined` for models that can't tell
7
+ * @internal
8
+ */
9
+ export declare function rowsArrayOf(body: unknown): unknown[] | undefined;
10
+ /**
11
+ * All row objects of a body model, also filtered and collapsed ones (tree: the data of every node).
12
+ *
13
+ * @param {unknown} body - the body area model
14
+ * @returns {Set<unknown> | null} the rows, `null` for models that can't tell
15
+ * @internal
16
+ */
17
+ export declare function allRowObjectsOf(body: unknown): Set<unknown> | null;
@@ -0,0 +1,35 @@
1
+ import { TableScope } from '../table-scope.js';
2
+ import { CellChangeSource } from '../batch-edit/cell-change.if.js';
3
+ import { PendingCellIf } from '../batch-edit/pending-cell-changes.js';
4
+ import { UndoableIf, UndoResultIf } from './undoable.if.js';
5
+
6
+ /** One cell of a batch edit step: its pending entry before and after (none = not pending). */
7
+ export interface PendingSnapshotIf {
8
+ rowKey: unknown;
9
+ property: string;
10
+ before?: PendingCellIf;
11
+ after?: PendingCellIf;
12
+ }
13
+ /**
14
+ * A step of a batch edit (values marked, not written): undo restores the pending state before the step, redo the one
15
+ * after it. A cell whose pending value changed since then is skipped (`onConflict: "skip"`). Commit and cancel of the
16
+ * batch edit empty the history.
17
+ *
18
+ * @category Spreadsheet
19
+ * @since 1.1.99
20
+ */
21
+ export declare class PendingChangesUndoable implements UndoableIf {
22
+ readonly label: string;
23
+ readonly source: CellChangeSource;
24
+ private readonly cells;
25
+ /**
26
+ * @param {string} label - for buttons and announcements
27
+ * @param {CellChangeSource} source - what started the step
28
+ * @param {PendingSnapshotIf[]} cells - the pending entries before and after
29
+ */
30
+ constructor(label: string, source: CellChangeSource, cells: PendingSnapshotIf[]);
31
+ get cellCount(): number;
32
+ undo(scope: TableScope): UndoResultIf;
33
+ redo(scope: TableScope): UndoResultIf;
34
+ private apply;
35
+ }
@@ -0,0 +1,17 @@
1
+ import { ShortcutActionIdMapping } from '../action/shortcut-actionid-mapping.type.js';
2
+
3
+ /**
4
+ * The keys of undo and redo ({@link TableOptionsIf.undo}) – a layer over the system mapping that the table only uses
5
+ * with the option; `tableOptions.shortcutActionIdMapping` still overrides it. In an open editor the keys belong to
6
+ * the editor (the browser's text undo).
7
+ *
8
+ * @param {boolean} mac - macOS keys (⌘+Z, ⌘+Shift+Z)
9
+ * @returns {ShortcutActionIdMapping} the layer
10
+ *
11
+ * @example
12
+ * undoShortcutLayer(false)["ctrl+y"]; // "REDO"
13
+ *
14
+ * @category Spreadsheet
15
+ * @since 1.1.99
16
+ */
17
+ export declare function undoShortcutLayer(mac: boolean): ShortcutActionIdMapping;
@@ -0,0 +1,26 @@
1
+ import { UndoOptionsIf } from './undo-options.if.js';
2
+
3
+ /**
4
+ * The defaults of {@link UndoOptionsIf} (undo and redo, {@link TableOptionsIf.undo}).
5
+ *
6
+ * @example
7
+ * const options = UndoOptions.create({ maxSteps: 20 });
8
+ * options?.onConflict; // "skip"
9
+ *
10
+ * @category Spreadsheet
11
+ * @since 1.1.99
12
+ */
13
+ export declare class UndoOptions implements UndoOptionsIf {
14
+ maxSteps: number;
15
+ maxCells: number;
16
+ onConflict: "skip" | "overwrite";
17
+ recordApiChanges: boolean;
18
+ /**
19
+ * The options of {@link TableOptionsIf.undo}: `undefined`/`false` = off, `true` = the defaults, an object = the
20
+ * defaults overridden by its values (`undefined` keeps the default).
21
+ *
22
+ * @param {boolean | Partial<UndoOptionsIf>} [option] - `tableOptions.undo`
23
+ * @returns {UndoOptionsIf | undefined} complete options, `undefined` if undo is off
24
+ */
25
+ static create(option?: boolean | Partial<UndoOptionsIf>): UndoOptionsIf | undefined;
26
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Undo and redo ({@link TableOptionsIf.undo}). `undo: true` uses the defaults of {@link UndoOptions}; an object
3
+ * overrides single values.
4
+ *
5
+ * @example
6
+ * const tableOptions: TableOptionsIf = {
7
+ * ...new TableOptions(),
8
+ * editing: true,
9
+ * undo: { maxSteps: 50, onConflict: "overwrite" },
10
+ * };
11
+ *
12
+ * @category Spreadsheet
13
+ * @since 1.1.99
14
+ */
15
+ export interface UndoOptionsIf {
16
+ /** Steps kept; the oldest is dropped. Default `100`. */
17
+ maxSteps: number;
18
+ /**
19
+ * Cells kept over all steps (the oldest steps are dropped). A single change with more cells empties the history
20
+ * and is announced – it cannot be undone. Default `1_000_000`.
21
+ */
22
+ maxCells: number;
23
+ /**
24
+ * A cell changed by something else since the step (live data, `updateCells`): `"skip"` leaves it and announces it
25
+ * (default, safe), `"overwrite"` writes anyway.
26
+ */
27
+ onConflict: "skip" | "overwrite";
28
+ /** Record `api.applyCellChanges(…)` with source `"api"` too. Default `false` (per call: `{ undoable: true }`). */
29
+ recordApiChanges: boolean;
30
+ }
@@ -0,0 +1,103 @@
1
+ import { TableScope } from '../table-scope.js';
2
+ import { UndoOptionsIf } from './undo-options.if.js';
3
+ import { UndoableIf } from './undoable.if.js';
4
+ import { CellChangeIf, CellChangeSource } from '../batch-edit/cell-change.if.js';
5
+ import { PendingSnapshotIf } from './pending-changes-undoable.js';
6
+ import { GeUndoEvent } from '../data/common/event/ge-undo-event.js';
7
+
8
+ /**
9
+ * Undo and redo ({@link TableOptionsIf.undo}, `tableScope.undoService`, only with the option): records every change
10
+ * that goes through the table's one write path (editor, fill handle, paste, cut, Delete; `api.applyCellChanges` only
11
+ * with `recordApiChanges` or `{ undoable: true }`) as one step, and marked values of a batch edit. Not recorded:
12
+ * `updateCells`, `setRows` (the history is emptied when the rows array is replaced), sorting, filter, row drag.
13
+ *
14
+ * @category Internals
15
+ * @since 1.1.99
16
+ */
17
+ export declare class UndoService {
18
+ private readonly tableScope;
19
+ readonly options: UndoOptionsIf;
20
+ private readonly stack;
21
+ private group?;
22
+ /** An undo or redo is running: its writes (also of event handlers) are not recorded. */
23
+ private running;
24
+ /** The step whose `onModelChanged` is being reported: writes of handlers are added to it. */
25
+ private folding?;
26
+ private foldDepth;
27
+ /** The rows array when the first step was recorded – another array (`setRows`) empties the history. */
28
+ private rowsRef?;
29
+ /**
30
+ * @param {TableScope} tableScope - the table
31
+ * @param {UndoOptionsIf} options - complete options
32
+ */
33
+ constructor(tableScope: TableScope, options: UndoOptionsIf);
34
+ /**
35
+ * Records an own step (e.g. inserting rows) – not while an undo or redo runs.
36
+ *
37
+ * @param {UndoableIf} step - the step
38
+ * @since 1.1.99
39
+ */
40
+ addStep(step: UndoableIf): void;
41
+ /**
42
+ * Records written cells as a step (called by the table's write path).
43
+ *
44
+ * @param {CellChangeIf[]} changes - the written cells
45
+ * @param {CellChangeSource} source - what wrote them
46
+ * @param {boolean} [undoable] - `api.applyCellChanges(…, { undoable })`: overrides `recordApiChanges`
47
+ */
48
+ record(changes: CellChangeIf[], source: CellChangeSource, undoable?: boolean): void;
49
+ /** The step recorded last (for {@link beginFold}). */
50
+ private lastRecorded?;
51
+ /**
52
+ * The table reports the write that was just recorded (`onModelChanged`): writes of handlers until {@link endFold}
53
+ * belong to the same step.
54
+ */
55
+ beginFold(): void;
56
+ /** End of {@link beginFold}. */
57
+ endFold(): void;
58
+ /**
59
+ * Records marked values of a batch edit as a step (called by the table).
60
+ *
61
+ * @param {PendingSnapshotIf[]} cells - pending entries before and after
62
+ * @param {CellChangeSource} source - what marked them
63
+ * @param {boolean} [undoable] - as in {@link record}
64
+ */
65
+ recordPending(cells: PendingSnapshotIf[], source: CellChangeSource, undoable?: boolean): void;
66
+ /**
67
+ * Records everything `fn` changes as one step (see {@link TableApi.batchUndoable}).
68
+ *
69
+ * @param {string} label - the label of the step
70
+ * @param {() => T} fn - the changes
71
+ * @returns {T} what `fn` returns
72
+ */
73
+ batch<T>(label: string, fn: () => T): T;
74
+ /**
75
+ * Undoes the last step: writes the old values back (source `"undo"`), selects the cells, announces it.
76
+ *
77
+ * @returns {boolean} true if a step was undone
78
+ */
79
+ undo(): boolean;
80
+ /**
81
+ * Redoes the last undone step (source `"redo"`).
82
+ *
83
+ * @returns {boolean} true if a step was redone
84
+ */
85
+ redo(): boolean;
86
+ /** @returns {boolean} true if there is a step to undo */
87
+ canUndo(): boolean;
88
+ /** @returns {boolean} true if there is a step to redo */
89
+ canRedo(): boolean;
90
+ /** @returns {GeUndoEvent} the state of the history (for buttons) */
91
+ getState(): GeUndoEvent;
92
+ /** Empties the history (batch commit/cancel, {@link TableApi.clearUndoHistory}). */
93
+ clear(silent?: boolean): void;
94
+ private add;
95
+ private run;
96
+ /**
97
+ * `setRows` (or `api.addRows`/`removeRows`, which build a new array) replaced the rows array: the steps point to rows
98
+ * that may be gone – the history is emptied (silently when asked by a getter; the next change reports it).
99
+ */
100
+ private checkRows;
101
+ private currentRows;
102
+ private fire;
103
+ }