@rowsncolumns/spreadsheet 10.2.76 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api/insert-options.d.ts +67 -0
- package/dist/cjs/api/insert-options.d.ts.map +1 -0
- package/dist/cjs/api/insert-options.js +104 -0
- package/dist/cjs/api/move-overwrite.d.ts +14 -0
- package/dist/cjs/api/move-overwrite.d.ts.map +1 -0
- package/dist/cjs/api/move-overwrite.js +29 -0
- package/dist/cjs/api/multi-selection.d.ts +59 -0
- package/dist/cjs/api/multi-selection.d.ts.map +1 -0
- package/dist/cjs/api/multi-selection.js +166 -0
- package/dist/cjs/atoms/index.d.ts +3 -0
- package/dist/cjs/atoms/index.d.ts.map +1 -1
- package/dist/cjs/atoms/index.js +3 -0
- package/dist/cjs/atoms/insert-cells-dialog.atom.d.ts +36 -0
- package/dist/cjs/atoms/insert-cells-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/insert-cells-dialog.atom.js +34 -0
- package/dist/cjs/atoms/insert-options.atom.d.ts +21 -0
- package/dist/cjs/atoms/insert-options.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/insert-options.atom.js +11 -0
- package/dist/cjs/atoms/move-overwrite-confirm.atom.d.ts +24 -0
- package/dist/cjs/atoms/move-overwrite-confirm.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/move-overwrite-confirm.atom.js +42 -0
- package/dist/cjs/atoms/sheet-context.atom.d.ts +2 -0
- package/dist/cjs/atoms/sheet-context.atom.d.ts.map +1 -1
- package/dist/cjs/atoms/sheet-context.atom.js +15 -2
- package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/cjs/components/canvas-grid/index.js +284 -63
- package/dist/cjs/components/canvas-grid/typings.d.ts +47 -5
- package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/cjs/components/cell-editor/formula-result-preview.d.ts +4 -1
- package/dist/cjs/components/cell-editor/formula-result-preview.d.ts.map +1 -1
- package/dist/cjs/components/cell-editor/formula-result-preview.js +2 -2
- package/dist/cjs/components/cell-editor/index.d.ts +7 -1
- package/dist/cjs/components/cell-editor/index.d.ts.map +1 -1
- package/dist/cjs/components/cell-editor/index.js +3 -3
- package/dist/cjs/components/cell-input/cell-input.d.ts +13 -0
- package/dist/cjs/components/cell-input/cell-input.d.ts.map +1 -1
- package/dist/cjs/components/cell-input/cell-input.js +8 -3
- package/dist/cjs/components/cell-input/formula-bar-cell-input.d.ts.map +1 -1
- package/dist/cjs/components/cell-input/formula-bar-cell-input.js +3 -1
- package/dist/cjs/components/context-menu/index.d.ts +16 -1
- package/dist/cjs/components/context-menu/index.d.ts.map +1 -1
- package/dist/cjs/components/context-menu/index.js +245 -24
- package/dist/cjs/components/floating-cell-editor/index.d.ts.map +1 -1
- package/dist/cjs/components/floating-cell-editor/index.js +13 -5
- package/dist/cjs/components/insert-cells-dialog/index.d.ts +35 -0
- package/dist/cjs/components/insert-cells-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/insert-cells-dialog/index.js +84 -0
- package/dist/cjs/components/insert-options-smart-tag/index.d.ts +25 -0
- package/dist/cjs/components/insert-options-smart-tag/index.d.ts.map +1 -0
- package/dist/cjs/components/insert-options-smart-tag/index.js +41 -0
- package/dist/cjs/components/move-overwrite-confirm-dialog/index.d.ts +8 -0
- package/dist/cjs/components/move-overwrite-confirm-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/move-overwrite-confirm-dialog/index.js +34 -0
- package/dist/cjs/components/selection/index.d.ts +1 -1
- package/dist/cjs/components/selection/index.d.ts.map +1 -1
- package/dist/cjs/components/selection/index.js +4 -2
- package/dist/cjs/components/selection/types.d.ts +8 -0
- package/dist/cjs/components/selection/types.d.ts.map +1 -1
- package/dist/cjs/config.d.ts +6 -0
- package/dist/cjs/config.d.ts.map +1 -1
- package/dist/cjs/config.js +7 -1
- package/dist/cjs/hooks/use-cell-renderer.d.ts +7 -1
- package/dist/cjs/hooks/use-cell-renderer.d.ts.map +1 -1
- package/dist/cjs/hooks/use-cell-renderer.js +8 -3
- package/dist/cjs/hooks/use-context-setter.d.ts.map +1 -1
- package/dist/cjs/hooks/use-context-setter.js +5 -1
- package/dist/cjs/hooks/use-copy-paste-cut.d.ts +5 -0
- package/dist/cjs/hooks/use-copy-paste-cut.d.ts.map +1 -1
- package/dist/cjs/hooks/use-copy-paste-cut.js +19 -0
- package/dist/cjs/hooks/use-editor-change.d.ts +4 -1
- package/dist/cjs/hooks/use-editor-change.d.ts.map +1 -1
- package/dist/cjs/hooks/use-editor-change.js +4 -3
- package/dist/cjs/hooks/use-editor-submit.d.ts +8 -1
- package/dist/cjs/hooks/use-editor-submit.d.ts.map +1 -1
- package/dist/cjs/hooks/use-editor-submit.js +9 -1
- package/dist/cjs/hooks/use-move-columns-rows.d.ts.map +1 -1
- package/dist/cjs/hooks/use-move-columns-rows.js +6 -0
- package/dist/cjs/hooks/use-selection-renderer.d.ts +9 -1
- package/dist/cjs/hooks/use-selection-renderer.d.ts.map +1 -1
- package/dist/cjs/hooks/use-selection-renderer.js +26 -2
- package/dist/cjs/hooks/use-selection.d.ts +13 -5
- package/dist/cjs/hooks/use-selection.d.ts.map +1 -1
- package/dist/cjs/hooks/use-selection.js +48 -6
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/cjs/types.d.ts +8 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/api/insert-options.d.ts +67 -0
- package/dist/esm/api/insert-options.d.ts.map +1 -0
- package/dist/esm/api/insert-options.js +91 -0
- package/dist/esm/api/move-overwrite.d.ts +14 -0
- package/dist/esm/api/move-overwrite.d.ts.map +1 -0
- package/dist/esm/api/move-overwrite.js +25 -0
- package/dist/esm/api/multi-selection.d.ts +59 -0
- package/dist/esm/api/multi-selection.d.ts.map +1 -0
- package/dist/esm/api/multi-selection.js +92 -0
- package/dist/esm/atoms/index.d.ts +3 -0
- package/dist/esm/atoms/index.d.ts.map +1 -1
- package/dist/esm/atoms/index.js +3 -0
- package/dist/esm/atoms/insert-cells-dialog.atom.d.ts +36 -0
- package/dist/esm/atoms/insert-cells-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/insert-cells-dialog.atom.js +25 -0
- package/dist/esm/atoms/insert-options.atom.d.ts +21 -0
- package/dist/esm/atoms/insert-options.atom.d.ts.map +1 -0
- package/dist/esm/atoms/insert-options.atom.js +5 -0
- package/dist/esm/atoms/move-overwrite-confirm.atom.d.ts +24 -0
- package/dist/esm/atoms/move-overwrite-confirm.atom.d.ts.map +1 -0
- package/dist/esm/atoms/move-overwrite-confirm.atom.js +29 -0
- package/dist/esm/atoms/sheet-context.atom.d.ts +2 -0
- package/dist/esm/atoms/sheet-context.atom.d.ts.map +1 -1
- package/dist/esm/atoms/sheet-context.atom.js +10 -0
- package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/esm/components/canvas-grid/index.js +236 -19
- package/dist/esm/components/canvas-grid/typings.d.ts +47 -5
- package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/esm/components/cell-editor/formula-result-preview.d.ts +4 -1
- package/dist/esm/components/cell-editor/formula-result-preview.d.ts.map +1 -1
- package/dist/esm/components/cell-editor/formula-result-preview.js +3 -3
- package/dist/esm/components/cell-editor/index.d.ts +7 -1
- package/dist/esm/components/cell-editor/index.d.ts.map +1 -1
- package/dist/esm/components/cell-editor/index.js +3 -3
- package/dist/esm/components/cell-input/cell-input.d.ts +13 -0
- package/dist/esm/components/cell-input/cell-input.d.ts.map +1 -1
- package/dist/esm/components/cell-input/cell-input.js +10 -5
- package/dist/esm/components/cell-input/formula-bar-cell-input.d.ts.map +1 -1
- package/dist/esm/components/cell-input/formula-bar-cell-input.js +3 -1
- package/dist/esm/components/context-menu/index.d.ts +16 -1
- package/dist/esm/components/context-menu/index.d.ts.map +1 -1
- package/dist/esm/components/context-menu/index.js +193 -16
- package/dist/esm/components/floating-cell-editor/index.d.ts.map +1 -1
- package/dist/esm/components/floating-cell-editor/index.js +12 -6
- package/dist/esm/components/insert-cells-dialog/index.d.ts +35 -0
- package/dist/esm/components/insert-cells-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/insert-cells-dialog/index.js +79 -0
- package/dist/esm/components/insert-options-smart-tag/index.d.ts +25 -0
- package/dist/esm/components/insert-options-smart-tag/index.d.ts.map +1 -0
- package/dist/esm/components/insert-options-smart-tag/index.js +35 -0
- package/dist/esm/components/move-overwrite-confirm-dialog/index.d.ts +8 -0
- package/dist/esm/components/move-overwrite-confirm-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/move-overwrite-confirm-dialog/index.js +30 -0
- package/dist/esm/components/selection/index.d.ts +1 -1
- package/dist/esm/components/selection/index.d.ts.map +1 -1
- package/dist/esm/components/selection/index.js +4 -2
- package/dist/esm/components/selection/types.d.ts +8 -0
- package/dist/esm/components/selection/types.d.ts.map +1 -1
- package/dist/esm/config.d.ts +6 -0
- package/dist/esm/config.d.ts.map +1 -1
- package/dist/esm/config.js +6 -0
- package/dist/esm/hooks/use-cell-renderer.d.ts +7 -1
- package/dist/esm/hooks/use-cell-renderer.d.ts.map +1 -1
- package/dist/esm/hooks/use-cell-renderer.js +9 -4
- package/dist/esm/hooks/use-context-setter.d.ts.map +1 -1
- package/dist/esm/hooks/use-context-setter.js +5 -1
- package/dist/esm/hooks/use-copy-paste-cut.d.ts +5 -0
- package/dist/esm/hooks/use-copy-paste-cut.d.ts.map +1 -1
- package/dist/esm/hooks/use-copy-paste-cut.js +19 -0
- package/dist/esm/hooks/use-editor-change.d.ts +4 -1
- package/dist/esm/hooks/use-editor-change.d.ts.map +1 -1
- package/dist/esm/hooks/use-editor-change.js +5 -4
- package/dist/esm/hooks/use-editor-submit.d.ts +8 -1
- package/dist/esm/hooks/use-editor-submit.d.ts.map +1 -1
- package/dist/esm/hooks/use-editor-submit.js +10 -2
- package/dist/esm/hooks/use-move-columns-rows.d.ts.map +1 -1
- package/dist/esm/hooks/use-move-columns-rows.js +6 -0
- package/dist/esm/hooks/use-selection-renderer.d.ts +9 -1
- package/dist/esm/hooks/use-selection-renderer.d.ts.map +1 -1
- package/dist/esm/hooks/use-selection-renderer.js +26 -2
- package/dist/esm/hooks/use-selection.d.ts +13 -5
- package/dist/esm/hooks/use-selection.d.ts.map +1 -1
- package/dist/esm/hooks/use-selection.js +39 -3
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +7 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types.d.ts +8 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/spreadsheet.min.css +1 -1
- package/package.json +8 -7
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { CellInterface, GridRange, SelectionArea } from "@rowsncolumns/grid";
|
|
2
|
+
import type { CellFormat } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* The paint-format call shape both engines accept from `onChangeFormatting`
|
|
5
|
+
* (`use-paint-format.ts` / rnc `change-formatting` with a `CellFormatOrGrid`):
|
|
6
|
+
* a row-major format grid tiled over the selections, `replace` clearing each
|
|
7
|
+
* target cell first.
|
|
8
|
+
*/
|
|
9
|
+
export type ChangeFormattingWithGrid = (sheetId: number, activeCell: CellInterface, selections: SelectionArea[], formats: (CellFormat | null)[][], options: {
|
|
10
|
+
replace: boolean;
|
|
11
|
+
}) => void;
|
|
12
|
+
export type InsertOptionsAxis = "row" | "column";
|
|
13
|
+
/**
|
|
14
|
+
* Excel's Insert Options smart tag choices after a row insert ("Format Same
|
|
15
|
+
* As Above" / "Format Same As Below" / "Clear Formatting") — for a column
|
|
16
|
+
* insert the first two read "Left" / "Right". `before` is the neighbour the
|
|
17
|
+
* insert already copied (above / left), `after` the neighbour on the other
|
|
18
|
+
* side (below / right).
|
|
19
|
+
*/
|
|
20
|
+
export type InsertFormatOption = "before" | "after" | "clear";
|
|
21
|
+
/** An inserted band: `count` rows (or columns) starting at `start`. */
|
|
22
|
+
export type InsertedBand = {
|
|
23
|
+
axis: InsertOptionsAxis;
|
|
24
|
+
start: number;
|
|
25
|
+
count: number;
|
|
26
|
+
};
|
|
27
|
+
/** Reads a cell's user-entered format; `null`/`undefined` for an unformatted cell. */
|
|
28
|
+
export type FormatReader = (rowIndex: number, columnIndex: number) => CellFormat | null | undefined;
|
|
29
|
+
export type InsertFormatPlan = {
|
|
30
|
+
/** The band cells the formats are written over (one area). */
|
|
31
|
+
selections: SelectionArea[];
|
|
32
|
+
/**
|
|
33
|
+
* Row-major format grid tiled over `selections` by `onChangeFormatting`'s
|
|
34
|
+
* paint-format path (`{ replace: true }`): one source row for a row band
|
|
35
|
+
* (tiles down), one source column for a column band (tiles right). `null`
|
|
36
|
+
* entries clear the target cell's format.
|
|
37
|
+
*/
|
|
38
|
+
formats: (CellFormat | null)[][];
|
|
39
|
+
};
|
|
40
|
+
/** The neighbour line an option copies from: `before` = above/left, `after` = below/right. */
|
|
41
|
+
export declare const neighbourIndexForOption: (band: InsertedBand, option: Exclude<InsertFormatOption, "clear">) => number;
|
|
42
|
+
/**
|
|
43
|
+
* The band as one grid area spanning the first `extent` cells across the
|
|
44
|
+
* other axis — `extent` bounds the write to the formatted part of the sheet
|
|
45
|
+
* instead of all 16,384 columns / 1,048,576 rows.
|
|
46
|
+
*/
|
|
47
|
+
export declare const insertedBandRange: (band: InsertedBand, extent: number) => GridRange;
|
|
48
|
+
/**
|
|
49
|
+
* What re-choosing an Insert Options entry writes: the neighbour line's
|
|
50
|
+
* per-cell formats tiled over the inserted band (`{ replace: true }` so the
|
|
51
|
+
* previous choice's formats do not linger), or `null` when the neighbour has
|
|
52
|
+
* no formats at all — the caller then clears the band instead. `limit` caps
|
|
53
|
+
* the scan across the other axis (the sheet's column / row count).
|
|
54
|
+
*/
|
|
55
|
+
export declare const formatsForInsertOption: (band: InsertedBand, option: Exclude<InsertFormatOption, "clear">, read: FormatReader, limit: number) => InsertFormatPlan | null;
|
|
56
|
+
/**
|
|
57
|
+
* The area "Clear Formatting" wipes: the formatted extent of the band itself
|
|
58
|
+
* (nothing to clear → `null`).
|
|
59
|
+
*/
|
|
60
|
+
export declare const clearRangeForInsertedBand: (band: InsertedBand, read: FormatReader, limit: number) => GridRange | null;
|
|
61
|
+
/**
|
|
62
|
+
* True when any cell of the band (within the first `limit` cells across the
|
|
63
|
+
* other axis) holds a user-entered value. A fresh insert is blank, so a value
|
|
64
|
+
* means the insert was refused or the user has since typed into it.
|
|
65
|
+
*/
|
|
66
|
+
export declare const insertedBandHasValues: (band: InsertedBand, hasValue: (rowIndex: number, columnIndex: number) => boolean, limit: number) => boolean;
|
|
67
|
+
//# sourceMappingURL=insert-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert-options.d.ts","sourceRoot":"","sources":["../../../api/insert-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAAG,CACrC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,aAAa,EACzB,UAAU,EAAE,aAAa,EAAE,EAC3B,OAAO,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,EAChC,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAC1B,IAAI,CAAC;AAEV,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;AAE9D,uEAAuE;AACvE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,sFAAsF;AACtF,MAAM,MAAM,YAAY,GAAG,CACzB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,KAChB,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;AAEnC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,8DAA8D;IAC9D,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,OAAO,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;CAClC,CAAC;AAwBF,8FAA8F;AAC9F,eAAO,MAAM,uBAAuB,GAClC,MAAM,YAAY,EAClB,QAAQ,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,WACuB,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,YAAY,EAClB,QAAQ,MAAM,KACb,SAaI,CAAC;AAER;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GACjC,MAAM,YAAY,EAClB,QAAQ,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,EAC5C,MAAM,YAAY,EAClB,OAAO,MAAM,KACZ,gBAAgB,GAAG,IAqBrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,GACpC,MAAM,YAAY,EAClB,MAAM,YAAY,EAClB,OAAO,MAAM,KACZ,SAAS,GAAG,IASd,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,MAAM,YAAY,EAClB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,EAC5D,OAAO,MAAM,YAWd,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.insertedBandHasValues = exports.clearRangeForInsertedBand = exports.formatsForInsertOption = exports.insertedBandRange = exports.neighbourIndexForOption = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var hasFormat = function (format) {
|
|
6
|
+
return !!format && Object.keys(format).length > 0;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Last formatted index along `axis` of the neighbour line `index` (a row when
|
|
10
|
+
* `axis` is `"row"`), scanning at most `limit` cells. `0` when the line holds
|
|
11
|
+
* no formats.
|
|
12
|
+
*/
|
|
13
|
+
var formattedExtent = function (read, axis, index, limit) {
|
|
14
|
+
var extent = 0;
|
|
15
|
+
for (var i = 1; i <= limit; i++) {
|
|
16
|
+
var format = axis === "row" ? read(index, i) : read(i, index);
|
|
17
|
+
if (hasFormat(format))
|
|
18
|
+
extent = i;
|
|
19
|
+
}
|
|
20
|
+
return extent;
|
|
21
|
+
};
|
|
22
|
+
/** The neighbour line an option copies from: `before` = above/left, `after` = below/right. */
|
|
23
|
+
var neighbourIndexForOption = function (band, option) { return (option === "before" ? band.start - 1 : band.start + band.count); };
|
|
24
|
+
exports.neighbourIndexForOption = neighbourIndexForOption;
|
|
25
|
+
/**
|
|
26
|
+
* The band as one grid area spanning the first `extent` cells across the
|
|
27
|
+
* other axis — `extent` bounds the write to the formatted part of the sheet
|
|
28
|
+
* instead of all 16,384 columns / 1,048,576 rows.
|
|
29
|
+
*/
|
|
30
|
+
var insertedBandRange = function (band, extent) {
|
|
31
|
+
return band.axis === "row"
|
|
32
|
+
? {
|
|
33
|
+
startRowIndex: band.start,
|
|
34
|
+
endRowIndex: band.start + band.count - 1,
|
|
35
|
+
startColumnIndex: 1,
|
|
36
|
+
endColumnIndex: Math.max(1, extent),
|
|
37
|
+
}
|
|
38
|
+
: {
|
|
39
|
+
startRowIndex: 1,
|
|
40
|
+
endRowIndex: Math.max(1, extent),
|
|
41
|
+
startColumnIndex: band.start,
|
|
42
|
+
endColumnIndex: band.start + band.count - 1,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
exports.insertedBandRange = insertedBandRange;
|
|
46
|
+
/**
|
|
47
|
+
* What re-choosing an Insert Options entry writes: the neighbour line's
|
|
48
|
+
* per-cell formats tiled over the inserted band (`{ replace: true }` so the
|
|
49
|
+
* previous choice's formats do not linger), or `null` when the neighbour has
|
|
50
|
+
* no formats at all — the caller then clears the band instead. `limit` caps
|
|
51
|
+
* the scan across the other axis (the sheet's column / row count).
|
|
52
|
+
*/
|
|
53
|
+
var formatsForInsertOption = function (band, option, read, limit) {
|
|
54
|
+
var neighbour = (0, exports.neighbourIndexForOption)(band, option);
|
|
55
|
+
if (neighbour < 1)
|
|
56
|
+
return null;
|
|
57
|
+
var sourceExtent = formattedExtent(read, band.axis, neighbour, limit);
|
|
58
|
+
// The band currently carries the formats of the earlier choice; the write
|
|
59
|
+
// must span those too so `replace` clears them.
|
|
60
|
+
var bandExtent = formattedExtent(read, band.axis, band.start, limit);
|
|
61
|
+
var extent = Math.max(sourceExtent, bandExtent);
|
|
62
|
+
if (extent === 0)
|
|
63
|
+
return null;
|
|
64
|
+
var line = [];
|
|
65
|
+
for (var i = 1; i <= extent; i++) {
|
|
66
|
+
var format = band.axis === "row" ? read(neighbour, i) : read(i, neighbour);
|
|
67
|
+
line.push(hasFormat(format) ? tslib_1.__assign({}, format) : null);
|
|
68
|
+
}
|
|
69
|
+
var formats = band.axis === "row" ? [line] : line.map(function (format) { return [format]; });
|
|
70
|
+
return {
|
|
71
|
+
selections: [{ range: (0, exports.insertedBandRange)(band, extent) }],
|
|
72
|
+
formats: formats,
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
exports.formatsForInsertOption = formatsForInsertOption;
|
|
76
|
+
/**
|
|
77
|
+
* The area "Clear Formatting" wipes: the formatted extent of the band itself
|
|
78
|
+
* (nothing to clear → `null`).
|
|
79
|
+
*/
|
|
80
|
+
var clearRangeForInsertedBand = function (band, read, limit) {
|
|
81
|
+
var extent = 0;
|
|
82
|
+
for (var k = 0; k < band.count; k++) {
|
|
83
|
+
extent = Math.max(extent, formattedExtent(read, band.axis, band.start + k, limit));
|
|
84
|
+
}
|
|
85
|
+
return extent === 0 ? null : (0, exports.insertedBandRange)(band, extent);
|
|
86
|
+
};
|
|
87
|
+
exports.clearRangeForInsertedBand = clearRangeForInsertedBand;
|
|
88
|
+
/**
|
|
89
|
+
* True when any cell of the band (within the first `limit` cells across the
|
|
90
|
+
* other axis) holds a user-entered value. A fresh insert is blank, so a value
|
|
91
|
+
* means the insert was refused or the user has since typed into it.
|
|
92
|
+
*/
|
|
93
|
+
var insertedBandHasValues = function (band, hasValue, limit) {
|
|
94
|
+
for (var k = 0; k < band.count; k++) {
|
|
95
|
+
var line = band.start + k;
|
|
96
|
+
for (var i = 1; i <= limit; i++) {
|
|
97
|
+
if (band.axis === "row" ? hasValue(line, i) : hasValue(i, line)) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
};
|
|
104
|
+
exports.insertedBandHasValues = insertedBandHasValues;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GridRange } from "@rowsncolumns/grid";
|
|
2
|
+
/** Excel's prompt before a plain drag-move overwrites non-empty destination cells. */
|
|
3
|
+
export declare const MOVE_OVERWRITE_PROMPT = "There's already data here. Do you want to replace it?";
|
|
4
|
+
/**
|
|
5
|
+
* Whether a plain (overwrite) drag-move from `from` to `to` needs Excel's
|
|
6
|
+
* "There's already data here. Do you want to replace it?" prompt: true when any
|
|
7
|
+
* destination cell OUTSIDE the source block holds a value. Cells the block itself
|
|
8
|
+
* currently occupies are never "data here" — they leave with the move — so an
|
|
9
|
+
* overlapping drag one cell over prompts only for the newly covered strip. An
|
|
10
|
+
* empty destination never prompts; Shift+drag (insert) and Ctrl+drag (copy) never
|
|
11
|
+
* reach this check.
|
|
12
|
+
*/
|
|
13
|
+
export declare const needsOverwritePrompt: (from: GridRange, to: GridRange, hasValue: (rowIndex: number, columnIndex: number) => boolean) => boolean;
|
|
14
|
+
//# sourceMappingURL=move-overwrite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-overwrite.d.ts","sourceRoot":"","sources":["../../../api/move-overwrite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,sFAAsF;AACtF,eAAO,MAAM,qBAAqB,0DACuB,CAAC;AAE1D;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAC/B,MAAM,SAAS,EACf,IAAI,SAAS,EACb,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,KAC3D,OAkBF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.needsOverwritePrompt = exports.MOVE_OVERWRITE_PROMPT = void 0;
|
|
4
|
+
/** Excel's prompt before a plain drag-move overwrites non-empty destination cells. */
|
|
5
|
+
exports.MOVE_OVERWRITE_PROMPT = "There's already data here. Do you want to replace it?";
|
|
6
|
+
/**
|
|
7
|
+
* Whether a plain (overwrite) drag-move from `from` to `to` needs Excel's
|
|
8
|
+
* "There's already data here. Do you want to replace it?" prompt: true when any
|
|
9
|
+
* destination cell OUTSIDE the source block holds a value. Cells the block itself
|
|
10
|
+
* currently occupies are never "data here" — they leave with the move — so an
|
|
11
|
+
* overlapping drag one cell over prompts only for the newly covered strip. An
|
|
12
|
+
* empty destination never prompts; Shift+drag (insert) and Ctrl+drag (copy) never
|
|
13
|
+
* reach this check.
|
|
14
|
+
*/
|
|
15
|
+
var needsOverwritePrompt = function (from, to, hasValue) {
|
|
16
|
+
for (var rowIndex = to.startRowIndex; rowIndex <= to.endRowIndex; rowIndex++) {
|
|
17
|
+
for (var columnIndex = to.startColumnIndex; columnIndex <= to.endColumnIndex; columnIndex++) {
|
|
18
|
+
var insideSource = rowIndex >= from.startRowIndex &&
|
|
19
|
+
rowIndex <= from.endRowIndex &&
|
|
20
|
+
columnIndex >= from.startColumnIndex &&
|
|
21
|
+
columnIndex <= from.endColumnIndex;
|
|
22
|
+
if (!insideSource && hasValue(rowIndex, columnIndex)) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
};
|
|
29
|
+
exports.needsOverwritePrompt = needsOverwritePrompt;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { GridRange, SelectionArea } from "@rowsncolumns/grid";
|
|
2
|
+
/**
|
|
3
|
+
* How Excel treats the areas of a multi-area (Ctrl-click) selection for the
|
|
4
|
+
* structural commands (rowsncolumns/spreadsheet#647 INS-08 / UI-07):
|
|
5
|
+
*
|
|
6
|
+
* - `single` — one area (or none): the normal Insert / Delete dialog path.
|
|
7
|
+
* - `all-rows` — every area is an entire-row band: insert / delete one block
|
|
8
|
+
* per area, sized to that area, applied bottom-up.
|
|
9
|
+
* - `all-columns` — every area is an entire-column band: same, per column band.
|
|
10
|
+
* - `mixed` — any partial area, or rows mixed with columns: Excel refuses
|
|
11
|
+
* with "That command cannot be used on multiple selections."
|
|
12
|
+
*/
|
|
13
|
+
export type MultiSelectionKind = "single" | "all-rows" | "all-columns" | "mixed";
|
|
14
|
+
export type WholeBandPredicates = {
|
|
15
|
+
isWholeRow(range: GridRange): boolean;
|
|
16
|
+
isWholeColumn(range: GridRange): boolean;
|
|
17
|
+
};
|
|
18
|
+
/** Entire-row test for a sheet `columnCount` wide (the grid's left bound is column 1). */
|
|
19
|
+
export declare const wholeRowPredicate: (columnCount: number, selectionLeftBound?: number) => (range: GridRange) => boolean;
|
|
20
|
+
/** Entire-column test for a sheet `rowCount` tall (the grid's top bound is row 1). */
|
|
21
|
+
export declare const wholeColumnPredicate: (rowCount: number, selectionTopBound?: number) => (range: GridRange) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Entire-row test when the sheet extent is unknown: the grid's row-header
|
|
24
|
+
* bookkeeping (`selectedRowHeadersIds`) already lists every row that belongs
|
|
25
|
+
* to a whole-row area, so an area is whole-row when its first and last rows
|
|
26
|
+
* are both listed.
|
|
27
|
+
*/
|
|
28
|
+
export declare const wholeRowPredicateFromHeaderIds: (rowHeaderIds: readonly number[]) => (range: GridRange) => boolean;
|
|
29
|
+
export declare const wholeColumnPredicateFromHeaderIds: (columnHeaderIds: readonly number[]) => (range: GridRange) => boolean;
|
|
30
|
+
export declare const classifyMultiSelection: (selections: readonly SelectionArea[], { isWholeRow, isWholeColumn }: WholeBandPredicates) => MultiSelectionKind;
|
|
31
|
+
export type IndexBand = {
|
|
32
|
+
start: number;
|
|
33
|
+
end: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The bands (start..end, inclusive) a per-area structural command acts on,
|
|
37
|
+
* deduplicated and ordered bottom-up / right-to-left so inserting one block
|
|
38
|
+
* per band never shifts a band that is still to be processed (INS-08).
|
|
39
|
+
*/
|
|
40
|
+
export declare const bandsForAreas: (selections: readonly SelectionArea[], axis: "row" | "column") => IndexBand[];
|
|
41
|
+
/**
|
|
42
|
+
* Groups header ids (e.g. `selectedRowHeadersIds`) into contiguous bands,
|
|
43
|
+
* bottom-up. Fallback for callers that only know which rows/columns are
|
|
44
|
+
* selected, not the areas they came from.
|
|
45
|
+
*/
|
|
46
|
+
export declare const bandsFromIndexes: (indexes: readonly number[]) => IndexBand[];
|
|
47
|
+
/** Sorted, de-duplicated row (or column) indexes covered by ALL areas. */
|
|
48
|
+
export declare const indexesForAreas: (selections: readonly SelectionArea[], axis: "row" | "column") => number[];
|
|
49
|
+
export type InsertCellsChoice = "shift-right" | "shift-down" | "entire-row" | "entire-column";
|
|
50
|
+
export type DeleteCellsChoice = "shift-left" | "shift-up" | "entire-row" | "entire-column";
|
|
51
|
+
/**
|
|
52
|
+
* Excel pre-selects the shift that moves the fewest neighbours: a selection
|
|
53
|
+
* taller than it is wide shifts cells right; a wider-than-tall or square one
|
|
54
|
+
* shifts cells down (UI-06).
|
|
55
|
+
*/
|
|
56
|
+
export declare const defaultInsertCellsChoice: (range: GridRange) => InsertCellsChoice;
|
|
57
|
+
/** Delete mirrors Insert: taller-than-wide → shift left, otherwise shift up. */
|
|
58
|
+
export declare const defaultDeleteCellsChoice: (range: GridRange) => DeleteCellsChoice;
|
|
59
|
+
//# sourceMappingURL=multi-selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-selection.d.ts","sourceRoot":"","sources":["../../../api/multi-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,UAAU,GAAG,aAAa,GAAG,OAAO,CAAC;AAEjF,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;IACtC,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;CAC1C,CAAC;AAEF,0FAA0F;AAC1F,eAAO,MAAM,iBAAiB,GAC3B,aAAa,MAAM,EAAE,2BAAsB,MAC3C,OAAO,SAAS,YAEoB,CAAC;AAExC,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,GAC9B,UAAU,MAAM,EAAE,0BAAqB,MACvC,OAAO,SAAS,YAC0D,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,GACxC,cAAc,SAAS,MAAM,EAAE,MAEtB,OAAO,SAAS,YAEzB,CAAC;AAEJ,eAAO,MAAM,iCAAiC,GAC3C,iBAAiB,SAAS,MAAM,EAAE,MAEzB,OAAO,SAAS,YAIzB,CAAC;AAEJ,eAAO,MAAM,sBAAsB,GACjC,YAAY,SAAS,aAAa,EAAE,EACpC,+BAA+B,mBAAmB,KACjD,kBAOF,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,YAAY,SAAS,aAAa,EAAE,EACpC,MAAM,KAAK,GAAG,QAAQ,KACrB,SAAS,EAcX,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,SAAS,MAAM,EAAE,KAAG,SAAS,EAYtE,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,eAAe,GAC1B,YAAY,SAAS,aAAa,EAAE,EACpC,MAAM,KAAK,GAAG,QAAQ,KACrB,MAAM,EAUR,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,eAAe,CAAC;AAEpB,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,eAAe,CAAC;AAMpB;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,SAAS,KAAG,iBACJ,CAAC;AAEzD,gFAAgF;AAChF,eAAO,MAAM,wBAAwB,GAAI,OAAO,SAAS,KAAG,iBACP,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultDeleteCellsChoice = exports.defaultInsertCellsChoice = exports.indexesForAreas = exports.bandsFromIndexes = exports.bandsForAreas = exports.classifyMultiSelection = exports.wholeColumnPredicateFromHeaderIds = exports.wholeRowPredicateFromHeaderIds = exports.wholeColumnPredicate = exports.wholeRowPredicate = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
/** Entire-row test for a sheet `columnCount` wide (the grid's left bound is column 1). */
|
|
6
|
+
var wholeRowPredicate = function (columnCount, selectionLeftBound) {
|
|
7
|
+
if (selectionLeftBound === void 0) { selectionLeftBound = 1; }
|
|
8
|
+
return function (range) {
|
|
9
|
+
return range.startColumnIndex <= selectionLeftBound &&
|
|
10
|
+
range.endColumnIndex >= columnCount;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
exports.wholeRowPredicate = wholeRowPredicate;
|
|
14
|
+
/** Entire-column test for a sheet `rowCount` tall (the grid's top bound is row 1). */
|
|
15
|
+
var wholeColumnPredicate = function (rowCount, selectionTopBound) {
|
|
16
|
+
if (selectionTopBound === void 0) { selectionTopBound = 1; }
|
|
17
|
+
return function (range) {
|
|
18
|
+
return range.startRowIndex <= selectionTopBound && range.endRowIndex >= rowCount;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
exports.wholeColumnPredicate = wholeColumnPredicate;
|
|
22
|
+
/**
|
|
23
|
+
* Entire-row test when the sheet extent is unknown: the grid's row-header
|
|
24
|
+
* bookkeeping (`selectedRowHeadersIds`) already lists every row that belongs
|
|
25
|
+
* to a whole-row area, so an area is whole-row when its first and last rows
|
|
26
|
+
* are both listed.
|
|
27
|
+
*/
|
|
28
|
+
var wholeRowPredicateFromHeaderIds = function (rowHeaderIds) {
|
|
29
|
+
var ids = new Set(rowHeaderIds);
|
|
30
|
+
return function (range) {
|
|
31
|
+
return ids.size > 0 && ids.has(range.startRowIndex) && ids.has(range.endRowIndex);
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
exports.wholeRowPredicateFromHeaderIds = wholeRowPredicateFromHeaderIds;
|
|
35
|
+
var wholeColumnPredicateFromHeaderIds = function (columnHeaderIds) {
|
|
36
|
+
var ids = new Set(columnHeaderIds);
|
|
37
|
+
return function (range) {
|
|
38
|
+
return ids.size > 0 &&
|
|
39
|
+
ids.has(range.startColumnIndex) &&
|
|
40
|
+
ids.has(range.endColumnIndex);
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
exports.wholeColumnPredicateFromHeaderIds = wholeColumnPredicateFromHeaderIds;
|
|
44
|
+
var classifyMultiSelection = function (selections, _a) {
|
|
45
|
+
var isWholeRow = _a.isWholeRow, isWholeColumn = _a.isWholeColumn;
|
|
46
|
+
if (selections.length <= 1)
|
|
47
|
+
return "single";
|
|
48
|
+
if (selections.every(function (_a) {
|
|
49
|
+
var range = _a.range;
|
|
50
|
+
return isWholeRow(range);
|
|
51
|
+
}))
|
|
52
|
+
return "all-rows";
|
|
53
|
+
if (selections.every(function (_a) {
|
|
54
|
+
var range = _a.range;
|
|
55
|
+
return isWholeColumn(range);
|
|
56
|
+
})) {
|
|
57
|
+
return "all-columns";
|
|
58
|
+
}
|
|
59
|
+
return "mixed";
|
|
60
|
+
};
|
|
61
|
+
exports.classifyMultiSelection = classifyMultiSelection;
|
|
62
|
+
/**
|
|
63
|
+
* The bands (start..end, inclusive) a per-area structural command acts on,
|
|
64
|
+
* deduplicated and ordered bottom-up / right-to-left so inserting one block
|
|
65
|
+
* per band never shifts a band that is still to be processed (INS-08).
|
|
66
|
+
*/
|
|
67
|
+
var bandsForAreas = function (selections, axis) {
|
|
68
|
+
var e_1, _a;
|
|
69
|
+
var seen = new Set();
|
|
70
|
+
var bands = [];
|
|
71
|
+
try {
|
|
72
|
+
for (var selections_1 = tslib_1.__values(selections), selections_1_1 = selections_1.next(); !selections_1_1.done; selections_1_1 = selections_1.next()) {
|
|
73
|
+
var range = selections_1_1.value.range;
|
|
74
|
+
var band = axis === "row"
|
|
75
|
+
? { start: range.startRowIndex, end: range.endRowIndex }
|
|
76
|
+
: { start: range.startColumnIndex, end: range.endColumnIndex };
|
|
77
|
+
var key = "".concat(band.start, ":").concat(band.end);
|
|
78
|
+
if (seen.has(key))
|
|
79
|
+
continue;
|
|
80
|
+
seen.add(key);
|
|
81
|
+
bands.push(band);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
85
|
+
finally {
|
|
86
|
+
try {
|
|
87
|
+
if (selections_1_1 && !selections_1_1.done && (_a = selections_1.return)) _a.call(selections_1);
|
|
88
|
+
}
|
|
89
|
+
finally { if (e_1) throw e_1.error; }
|
|
90
|
+
}
|
|
91
|
+
return bands.sort(function (a, b) { return b.start - a.start; });
|
|
92
|
+
};
|
|
93
|
+
exports.bandsForAreas = bandsForAreas;
|
|
94
|
+
/**
|
|
95
|
+
* Groups header ids (e.g. `selectedRowHeadersIds`) into contiguous bands,
|
|
96
|
+
* bottom-up. Fallback for callers that only know which rows/columns are
|
|
97
|
+
* selected, not the areas they came from.
|
|
98
|
+
*/
|
|
99
|
+
var bandsFromIndexes = function (indexes) {
|
|
100
|
+
var e_2, _a;
|
|
101
|
+
var sorted = Array.from(new Set(indexes)).sort(function (a, b) { return a - b; });
|
|
102
|
+
var bands = [];
|
|
103
|
+
try {
|
|
104
|
+
for (var sorted_1 = tslib_1.__values(sorted), sorted_1_1 = sorted_1.next(); !sorted_1_1.done; sorted_1_1 = sorted_1.next()) {
|
|
105
|
+
var index = sorted_1_1.value;
|
|
106
|
+
var last = bands[bands.length - 1];
|
|
107
|
+
if (last && index === last.end + 1) {
|
|
108
|
+
last.end = index;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
bands.push({ start: index, end: index });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
116
|
+
finally {
|
|
117
|
+
try {
|
|
118
|
+
if (sorted_1_1 && !sorted_1_1.done && (_a = sorted_1.return)) _a.call(sorted_1);
|
|
119
|
+
}
|
|
120
|
+
finally { if (e_2) throw e_2.error; }
|
|
121
|
+
}
|
|
122
|
+
return bands.sort(function (a, b) { return b.start - a.start; });
|
|
123
|
+
};
|
|
124
|
+
exports.bandsFromIndexes = bandsFromIndexes;
|
|
125
|
+
/** Sorted, de-duplicated row (or column) indexes covered by ALL areas. */
|
|
126
|
+
var indexesForAreas = function (selections, axis) {
|
|
127
|
+
var e_3, _a;
|
|
128
|
+
var indexes = new Set();
|
|
129
|
+
try {
|
|
130
|
+
for (var selections_2 = tslib_1.__values(selections), selections_2_1 = selections_2.next(); !selections_2_1.done; selections_2_1 = selections_2.next()) {
|
|
131
|
+
var range = selections_2_1.value.range;
|
|
132
|
+
var _b = tslib_1.__read(axis === "row"
|
|
133
|
+
? [range.startRowIndex, range.endRowIndex]
|
|
134
|
+
: [range.startColumnIndex, range.endColumnIndex], 2), start = _b[0], end = _b[1];
|
|
135
|
+
for (var index = start; index <= end; index++)
|
|
136
|
+
indexes.add(index);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
140
|
+
finally {
|
|
141
|
+
try {
|
|
142
|
+
if (selections_2_1 && !selections_2_1.done && (_a = selections_2.return)) _a.call(selections_2);
|
|
143
|
+
}
|
|
144
|
+
finally { if (e_3) throw e_3.error; }
|
|
145
|
+
}
|
|
146
|
+
return Array.from(indexes).sort(function (a, b) { return a - b; });
|
|
147
|
+
};
|
|
148
|
+
exports.indexesForAreas = indexesForAreas;
|
|
149
|
+
var isTallerThanWide = function (range) {
|
|
150
|
+
return range.endRowIndex - range.startRowIndex >
|
|
151
|
+
range.endColumnIndex - range.startColumnIndex;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Excel pre-selects the shift that moves the fewest neighbours: a selection
|
|
155
|
+
* taller than it is wide shifts cells right; a wider-than-tall or square one
|
|
156
|
+
* shifts cells down (UI-06).
|
|
157
|
+
*/
|
|
158
|
+
var defaultInsertCellsChoice = function (range) {
|
|
159
|
+
return isTallerThanWide(range) ? "shift-right" : "shift-down";
|
|
160
|
+
};
|
|
161
|
+
exports.defaultInsertCellsChoice = defaultInsertCellsChoice;
|
|
162
|
+
/** Delete mirrors Insert: taller-than-wide → shift left, otherwise shift up. */
|
|
163
|
+
var defaultDeleteCellsChoice = function (range) {
|
|
164
|
+
return isTallerThanWide(range) ? "shift-left" : "shift-up";
|
|
165
|
+
};
|
|
166
|
+
exports.defaultDeleteCellsChoice = defaultDeleteCellsChoice;
|
|
@@ -19,7 +19,10 @@ export * from "./validation-alert.atom";
|
|
|
19
19
|
export * from "./sort-dialog.atom";
|
|
20
20
|
export * from "./paste-special-dialog.atom";
|
|
21
21
|
export * from "./go-to-dialog.atom";
|
|
22
|
+
export * from "./move-overwrite-confirm.atom";
|
|
22
23
|
export * from "./evaluate-formula-dialog.atom";
|
|
23
24
|
export * from "./remove-duplicates-dialog.atom";
|
|
24
25
|
export * from "./watch-window.atom";
|
|
26
|
+
export * from "./insert-cells-dialog.atom";
|
|
27
|
+
export * from "./insert-options.atom";
|
|
25
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../atoms/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../atoms/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC"}
|
package/dist/cjs/atoms/index.js
CHANGED
|
@@ -24,6 +24,9 @@ tslib_1.__exportStar(require("./validation-alert.atom"), exports);
|
|
|
24
24
|
tslib_1.__exportStar(require("./sort-dialog.atom"), exports);
|
|
25
25
|
tslib_1.__exportStar(require("./paste-special-dialog.atom"), exports);
|
|
26
26
|
tslib_1.__exportStar(require("./go-to-dialog.atom"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./move-overwrite-confirm.atom"), exports);
|
|
27
28
|
tslib_1.__exportStar(require("./evaluate-formula-dialog.atom"), exports);
|
|
28
29
|
tslib_1.__exportStar(require("./remove-duplicates-dialog.atom"), exports);
|
|
29
30
|
tslib_1.__exportStar(require("./watch-window.atom"), exports);
|
|
31
|
+
tslib_1.__exportStar(require("./insert-cells-dialog.atom"), exports);
|
|
32
|
+
tslib_1.__exportStar(require("./insert-options.atom"), exports);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { DeleteCellsChoice, InsertCellsChoice } from "../api/multi-selection";
|
|
2
|
+
/**
|
|
3
|
+
* Open-state + payload for Excel's Insert / Delete cells dialog (right-click a
|
|
4
|
+
* cell → "Insert…" / "Delete…", `Ctrl` + `+` / `-` on a cell selection). The
|
|
5
|
+
* grid opens it with the shape-derived default; the host-mounted dialog routes
|
|
6
|
+
* the chosen entry back through `onApply`, and the opener dispatches the
|
|
7
|
+
* matching structural command (shift cells / entire row / entire column).
|
|
8
|
+
*/
|
|
9
|
+
export type InsertCellsDialogRequest = {
|
|
10
|
+
mode: "insert";
|
|
11
|
+
defaultChoice: InsertCellsChoice;
|
|
12
|
+
onApply: (choice: InsertCellsChoice) => void;
|
|
13
|
+
} | {
|
|
14
|
+
mode: "delete";
|
|
15
|
+
defaultChoice: DeleteCellsChoice;
|
|
16
|
+
onApply: (choice: DeleteCellsChoice) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare const insertCellsDialogAtom: import("jotai").PrimitiveAtom<InsertCellsDialogRequest | null> & {
|
|
19
|
+
init: InsertCellsDialogRequest | null;
|
|
20
|
+
};
|
|
21
|
+
export declare const useInsertCellsDialogState: () => [InsertCellsDialogRequest | null, (args_0: InsertCellsDialogRequest | ((prev: InsertCellsDialogRequest | null) => InsertCellsDialogRequest | null) | null) => void];
|
|
22
|
+
/**
|
|
23
|
+
* Number of mounted `InsertCellsDialogHost`s. The context menu only offers the
|
|
24
|
+
* dialog entry while a host is mounted; without one it keeps the direct
|
|
25
|
+
* submenu so a host that has not adopted the dialog never gets a dead item.
|
|
26
|
+
*/
|
|
27
|
+
export declare const insertCellsDialogHostCountAtom: import("jotai").PrimitiveAtom<number> & {
|
|
28
|
+
init: number;
|
|
29
|
+
};
|
|
30
|
+
/** True when at least one `InsertCellsDialogHost` is mounted. */
|
|
31
|
+
export declare const useIsInsertCellsDialogMounted: () => boolean;
|
|
32
|
+
/** Registers the calling component as a dialog host for its lifetime. */
|
|
33
|
+
export declare const useRegisterInsertCellsDialogHost: () => void;
|
|
34
|
+
/** Returns a function that opens the host-mounted Insert / Delete cells dialog. */
|
|
35
|
+
export declare const useOpenInsertCellsDialog: () => (request: InsertCellsDialogRequest) => void;
|
|
36
|
+
//# sourceMappingURL=insert-cells-dialog.atom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert-cells-dialog.atom.d.ts","sourceRoot":"","sources":["../../../atoms/insert-cells-dialog.atom.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAChC;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,aAAa,EAAE,iBAAiB,CAAC;IACjC,OAAO,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC9C,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,aAAa,EAAE,iBAAiB,CAAC;IACjC,OAAO,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEN,eAAO,MAAM,qBAAqB;;CAEjC,CAAC;AAEF,eAAO,MAAM,yBAAyB,2KAAuC,CAAC;AAE9E;;;;GAIG;AACH,eAAO,MAAM,8BAA8B;;CAAU,CAAC;AAEtD,iEAAiE;AACjE,eAAO,MAAM,6BAA6B,eACQ,CAAC;AAEnD,yEAAyE;AACzE,eAAO,MAAM,gCAAgC,YAM5C,CAAC;AAEF,mFAAmF;AACnF,eAAO,MAAM,wBAAwB,kBAGvB,wBAAwB,SAGrC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useOpenInsertCellsDialog = exports.useRegisterInsertCellsDialogHost = exports.useIsInsertCellsDialogMounted = exports.insertCellsDialogHostCountAtom = exports.useInsertCellsDialogState = exports.insertCellsDialogAtom = void 0;
|
|
4
|
+
var jotai_1 = require("jotai");
|
|
5
|
+
var react_1 = require("react");
|
|
6
|
+
exports.insertCellsDialogAtom = (0, jotai_1.atom)(null);
|
|
7
|
+
var useInsertCellsDialogState = function () { return (0, jotai_1.useAtom)(exports.insertCellsDialogAtom); };
|
|
8
|
+
exports.useInsertCellsDialogState = useInsertCellsDialogState;
|
|
9
|
+
/**
|
|
10
|
+
* Number of mounted `InsertCellsDialogHost`s. The context menu only offers the
|
|
11
|
+
* dialog entry while a host is mounted; without one it keeps the direct
|
|
12
|
+
* submenu so a host that has not adopted the dialog never gets a dead item.
|
|
13
|
+
*/
|
|
14
|
+
exports.insertCellsDialogHostCountAtom = (0, jotai_1.atom)(0);
|
|
15
|
+
/** True when at least one `InsertCellsDialogHost` is mounted. */
|
|
16
|
+
var useIsInsertCellsDialogMounted = function () {
|
|
17
|
+
return (0, jotai_1.useAtomValue)(exports.insertCellsDialogHostCountAtom) > 0;
|
|
18
|
+
};
|
|
19
|
+
exports.useIsInsertCellsDialogMounted = useIsInsertCellsDialogMounted;
|
|
20
|
+
/** Registers the calling component as a dialog host for its lifetime. */
|
|
21
|
+
var useRegisterInsertCellsDialogHost = function () {
|
|
22
|
+
var setCount = (0, jotai_1.useSetAtom)(exports.insertCellsDialogHostCountAtom);
|
|
23
|
+
(0, react_1.useEffect)(function () {
|
|
24
|
+
setCount(function (count) { return count + 1; });
|
|
25
|
+
return function () { return setCount(function (count) { return count - 1; }); };
|
|
26
|
+
}, [setCount]);
|
|
27
|
+
};
|
|
28
|
+
exports.useRegisterInsertCellsDialogHost = useRegisterInsertCellsDialogHost;
|
|
29
|
+
/** Returns a function that opens the host-mounted Insert / Delete cells dialog. */
|
|
30
|
+
var useOpenInsertCellsDialog = function () {
|
|
31
|
+
var setRequest = (0, jotai_1.useSetAtom)(exports.insertCellsDialogAtom);
|
|
32
|
+
return (0, react_1.useCallback)(function (request) { return setRequest(request); }, [setRequest]);
|
|
33
|
+
};
|
|
34
|
+
exports.useOpenInsertCellsDialog = useOpenInsertCellsDialog;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { InsertedBand, InsertFormatOption } from "../api/insert-options";
|
|
2
|
+
/**
|
|
3
|
+
* A just-inserted row / column band waiting for the user to (re)choose how it
|
|
4
|
+
* is formatted — Excel's Insert Options smart tag ("Format Same As Above /
|
|
5
|
+
* Below / Clear Formatting"; "Left / Right" for columns). The insert already
|
|
6
|
+
* applied `before` (the row above / column to the left); choosing another
|
|
7
|
+
* entry re-formats the band from the other neighbour, or clears it. Dropped
|
|
8
|
+
* on the next click elsewhere (a new active cell) or sheet switch.
|
|
9
|
+
*/
|
|
10
|
+
export type InsertOptionsRequest = InsertedBand & {
|
|
11
|
+
sheetId: number;
|
|
12
|
+
/** The entry currently applied to the band. */
|
|
13
|
+
option: InsertFormatOption;
|
|
14
|
+
};
|
|
15
|
+
export declare const insertOptionsAtom: import("jotai").PrimitiveAtom<InsertOptionsRequest | null> & {
|
|
16
|
+
init: InsertOptionsRequest | null;
|
|
17
|
+
};
|
|
18
|
+
export declare const useInsertOptionsState: () => [InsertOptionsRequest | null, (args_0: InsertOptionsRequest | ((prev: InsertOptionsRequest | null) => InsertOptionsRequest | null) | null) => void];
|
|
19
|
+
export declare const useInsertOptionsValue: () => InsertOptionsRequest | null;
|
|
20
|
+
export declare const useSetInsertOptions: () => (args_0: InsertOptionsRequest | ((prev: InsertOptionsRequest | null) => InsertOptionsRequest | null) | null) => void;
|
|
21
|
+
//# sourceMappingURL=insert-options.atom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert-options.atom.d.ts","sourceRoot":"","sources":["../../../atoms/insert-options.atom.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,MAAM,EAAE,kBAAkB,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;CAA0C,CAAC;AAEzE,eAAO,MAAM,qBAAqB,2JAAmC,CAAC;AACtE,eAAO,MAAM,qBAAqB,mCAAwC,CAAC;AAC3E,eAAO,MAAM,mBAAmB,4HAAsC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSetInsertOptions = exports.useInsertOptionsValue = exports.useInsertOptionsState = exports.insertOptionsAtom = void 0;
|
|
4
|
+
var jotai_1 = require("jotai");
|
|
5
|
+
exports.insertOptionsAtom = (0, jotai_1.atom)(null);
|
|
6
|
+
var useInsertOptionsState = function () { return (0, jotai_1.useAtom)(exports.insertOptionsAtom); };
|
|
7
|
+
exports.useInsertOptionsState = useInsertOptionsState;
|
|
8
|
+
var useInsertOptionsValue = function () { return (0, jotai_1.useAtomValue)(exports.insertOptionsAtom); };
|
|
9
|
+
exports.useInsertOptionsValue = useInsertOptionsValue;
|
|
10
|
+
var useSetInsertOptions = function () { return (0, jotai_1.useSetAtom)(exports.insertOptionsAtom); };
|
|
11
|
+
exports.useSetInsertOptions = useSetInsertOptions;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open-state + payload for the drag-move overwrite prompt (Excel: "There's
|
|
3
|
+
* already data here. Do you want to replace it?"). The grid raises it from the
|
|
4
|
+
* selection-border drop; the host-mounted dialog answers through `resolve`.
|
|
5
|
+
*/
|
|
6
|
+
export type MoveOverwriteConfirmRequest = {
|
|
7
|
+
message: string;
|
|
8
|
+
resolve: (replace: boolean) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const moveOverwriteConfirmAtom: import("jotai").PrimitiveAtom<MoveOverwriteConfirmRequest | null> & {
|
|
11
|
+
init: MoveOverwriteConfirmRequest | null;
|
|
12
|
+
};
|
|
13
|
+
export declare const useMoveOverwriteConfirmState: () => [MoveOverwriteConfirmRequest | null, (args_0: MoveOverwriteConfirmRequest | ((prev: MoveOverwriteConfirmRequest | null) => MoveOverwriteConfirmRequest | null) | null) => void];
|
|
14
|
+
/** Number of mounted `MoveOverwriteConfirmDialogHost`s. */
|
|
15
|
+
export declare const moveOverwriteConfirmHostCountAtom: import("jotai").PrimitiveAtom<number> & {
|
|
16
|
+
init: number;
|
|
17
|
+
};
|
|
18
|
+
/** True when a host has mounted the dialog; otherwise the grid falls back to `window.confirm`. */
|
|
19
|
+
export declare const useIsMoveOverwriteConfirmMounted: () => boolean;
|
|
20
|
+
/** Registers the calling component as a dialog host for its lifetime. */
|
|
21
|
+
export declare const useRegisterMoveOverwriteConfirmHost: () => void;
|
|
22
|
+
/** Returns a function that opens the host-mounted prompt and resolves with the user's answer. */
|
|
23
|
+
export declare const useOpenMoveOverwriteConfirm: () => (message: string) => Promise<boolean>;
|
|
24
|
+
//# sourceMappingURL=move-overwrite-confirm.atom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-overwrite-confirm.atom.d.ts","sourceRoot":"","sources":["../../../atoms/move-overwrite-confirm.atom.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;CAEpC,CAAC;AAEF,eAAO,MAAM,4BAA4B,uLACN,CAAC;AAEpC,2DAA2D;AAC3D,eAAO,MAAM,iCAAiC;;CAAU,CAAC;AAEzD,kGAAkG;AAClG,eAAO,MAAM,gCAAgC,eACQ,CAAC;AAEtD,yEAAyE;AACzE,eAAO,MAAM,mCAAmC,YAM/C,CAAC;AAEF,iGAAiG;AACjG,eAAO,MAAM,2BAA2B,kBAG1B,MAAM,qBAYnB,CAAC"}
|