@rowsncolumns/spreadsheet-state 28.0.75 → 28.0.76
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/anchored-objects.d.ts +66 -0
- package/dist/cjs/api/anchored-objects.d.ts.map +1 -0
- package/dist/cjs/api/anchored-objects.js +259 -0
- package/dist/cjs/api/dependency.d.ts +13 -2
- package/dist/cjs/api/dependency.d.ts.map +1 -1
- package/dist/cjs/api/dependency.js +11 -5
- package/dist/cjs/api/formula.d.ts +61 -4
- package/dist/cjs/api/formula.d.ts.map +1 -1
- package/dist/cjs/api/formula.js +250 -61
- package/dist/cjs/api/merges.d.ts +8 -0
- package/dist/cjs/api/merges.d.ts.map +1 -1
- package/dist/cjs/api/merges.js +64 -1
- package/dist/cjs/api/named-range-structural.d.ts +62 -0
- package/dist/cjs/api/named-range-structural.d.ts.map +1 -0
- package/dist/cjs/api/named-range-structural.js +197 -0
- package/dist/cjs/api/range-rule-helpers.d.ts +45 -1
- package/dist/cjs/api/range-rule-helpers.d.ts.map +1 -1
- package/dist/cjs/api/range-rule-helpers.js +159 -6
- package/dist/cjs/api/structural-formula-update.d.ts.map +1 -1
- package/dist/cjs/api/structural-formula-update.js +24 -6
- package/dist/cjs/api/structural-guards.d.ts +78 -0
- package/dist/cjs/api/structural-guards.d.ts.map +1 -0
- package/dist/cjs/api/structural-guards.js +202 -0
- package/dist/cjs/api/structural-table-refs.d.ts +94 -0
- package/dist/cjs/api/structural-table-refs.d.ts.map +1 -0
- package/dist/cjs/api/structural-table-refs.js +313 -0
- package/dist/cjs/constants.d.ts +25 -0
- package/dist/cjs/constants.d.ts.map +1 -0
- package/dist/cjs/constants.js +26 -0
- package/dist/cjs/hooks/use-calculation-worker.d.ts.map +1 -1
- package/dist/cjs/hooks/use-calculation-worker.js +64 -6
- package/dist/cjs/hooks/use-calculation.d.ts +7 -0
- package/dist/cjs/hooks/use-calculation.d.ts.map +1 -1
- package/dist/cjs/hooks/use-calculation.js +15 -0
- package/dist/cjs/hooks/use-on-calculation-success.d.ts +7 -0
- package/dist/cjs/hooks/use-on-calculation-success.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-calculation-success.js +7 -1
- package/dist/cjs/hooks/use-on-delete-cells-shift-left.d.ts +13 -3
- package/dist/cjs/hooks/use-on-delete-cells-shift-left.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-delete-cells-shift-left.js +27 -2
- package/dist/cjs/hooks/use-on-delete-cells-shift-up.d.ts +13 -3
- package/dist/cjs/hooks/use-on-delete-cells-shift-up.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-delete-cells-shift-up.js +27 -2
- package/dist/cjs/hooks/use-on-delete-column.d.ts +13 -4
- package/dist/cjs/hooks/use-on-delete-column.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-delete-column.js +14 -2
- package/dist/cjs/hooks/use-on-delete-row.d.ts +13 -4
- package/dist/cjs/hooks/use-on-delete-row.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-delete-row.js +14 -2
- package/dist/cjs/hooks/use-on-insert-cells-shift-down.d.ts +13 -3
- package/dist/cjs/hooks/use-on-insert-cells-shift-down.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-insert-cells-shift-down.js +27 -2
- package/dist/cjs/hooks/use-on-insert-cells-shift-right.d.ts +13 -3
- package/dist/cjs/hooks/use-on-insert-cells-shift-right.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-insert-cells-shift-right.js +27 -2
- package/dist/cjs/hooks/use-on-insert-column.d.ts +10 -3
- package/dist/cjs/hooks/use-on-insert-column.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-insert-column.js +33 -7
- package/dist/cjs/hooks/use-on-insert-row.d.ts +10 -3
- package/dist/cjs/hooks/use-on-insert-row.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-insert-row.js +32 -7
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts +2 -2
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/cjs/hooks/use-spreadsheet-state.js +61 -15
- package/dist/cjs/hooks/use-structured-reference.d.ts.map +1 -1
- package/dist/cjs/hooks/use-structured-reference.js +10 -6
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/interface/calculation-interface.d.ts +9 -0
- package/dist/cjs/interface/calculation-interface.d.ts.map +1 -1
- package/dist/cjs/interface/calculation-interface.js +31 -2
- package/dist/cjs/interface/delete-cells-shift-left.d.ts +8 -1
- package/dist/cjs/interface/delete-cells-shift-left.d.ts.map +1 -1
- package/dist/cjs/interface/delete-cells-shift-left.js +158 -80
- package/dist/cjs/interface/delete-cells-shift-up.d.ts +9 -1
- package/dist/cjs/interface/delete-cells-shift-up.d.ts.map +1 -1
- package/dist/cjs/interface/delete-cells-shift-up.js +155 -73
- package/dist/cjs/interface/delete-column.d.ts +1 -1
- package/dist/cjs/interface/delete-column.d.ts.map +1 -1
- package/dist/cjs/interface/delete-column.js +90 -31
- package/dist/cjs/interface/delete-row.d.ts +1 -1
- package/dist/cjs/interface/delete-row.d.ts.map +1 -1
- package/dist/cjs/interface/delete-row.js +85 -26
- package/dist/cjs/interface/insert-cells-shift-down.d.ts +10 -1
- package/dist/cjs/interface/insert-cells-shift-down.d.ts.map +1 -1
- package/dist/cjs/interface/insert-cells-shift-down.js +147 -52
- package/dist/cjs/interface/insert-cells-shift-right.d.ts +10 -1
- package/dist/cjs/interface/insert-cells-shift-right.d.ts.map +1 -1
- package/dist/cjs/interface/insert-cells-shift-right.js +154 -58
- package/dist/cjs/interface/insert-column.d.ts +1 -1
- package/dist/cjs/interface/insert-column.d.ts.map +1 -1
- package/dist/cjs/interface/insert-column.js +46 -8
- package/dist/cjs/interface/insert-row.d.ts +1 -1
- package/dist/cjs/interface/insert-row.d.ts.map +1 -1
- package/dist/cjs/interface/insert-row.js +47 -10
- package/dist/cjs/interface/spreadsheet-interface.d.ts.map +1 -1
- package/dist/cjs/interface/spreadsheet-interface.js +33 -0
- package/dist/cjs/sheet-cell.d.ts.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/api/anchored-objects.d.ts +66 -0
- package/dist/esm/api/anchored-objects.d.ts.map +1 -0
- package/dist/esm/api/anchored-objects.js +212 -0
- package/dist/esm/api/dependency.d.ts +13 -2
- package/dist/esm/api/dependency.d.ts.map +1 -1
- package/dist/esm/api/dependency.js +10 -4
- package/dist/esm/api/formula.d.ts +61 -4
- package/dist/esm/api/formula.d.ts.map +1 -1
- package/dist/esm/api/formula.js +238 -60
- package/dist/esm/api/merges.d.ts +8 -0
- package/dist/esm/api/merges.d.ts.map +1 -1
- package/dist/esm/api/merges.js +51 -0
- package/dist/esm/api/named-range-structural.d.ts +62 -0
- package/dist/esm/api/named-range-structural.d.ts.map +1 -0
- package/dist/esm/api/named-range-structural.js +176 -0
- package/dist/esm/api/range-rule-helpers.d.ts +45 -1
- package/dist/esm/api/range-rule-helpers.d.ts.map +1 -1
- package/dist/esm/api/range-rule-helpers.js +153 -1
- package/dist/esm/api/structural-formula-update.d.ts.map +1 -1
- package/dist/esm/api/structural-formula-update.js +24 -6
- package/dist/esm/api/structural-guards.d.ts +78 -0
- package/dist/esm/api/structural-guards.d.ts.map +1 -0
- package/dist/esm/api/structural-guards.js +186 -0
- package/dist/esm/api/structural-table-refs.d.ts +94 -0
- package/dist/esm/api/structural-table-refs.d.ts.map +1 -0
- package/dist/esm/api/structural-table-refs.js +219 -0
- package/dist/esm/constants.d.ts +25 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +26 -0
- package/dist/esm/hooks/use-calculation-worker.d.ts.map +1 -1
- package/dist/esm/hooks/use-calculation-worker.js +45 -0
- package/dist/esm/hooks/use-calculation.d.ts +7 -0
- package/dist/esm/hooks/use-calculation.d.ts.map +1 -1
- package/dist/esm/hooks/use-calculation.js +15 -0
- package/dist/esm/hooks/use-on-calculation-success.d.ts +7 -0
- package/dist/esm/hooks/use-on-calculation-success.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-calculation-success.js +7 -1
- package/dist/esm/hooks/use-on-delete-cells-shift-left.d.ts +13 -3
- package/dist/esm/hooks/use-on-delete-cells-shift-left.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-delete-cells-shift-left.js +26 -2
- package/dist/esm/hooks/use-on-delete-cells-shift-up.d.ts +13 -3
- package/dist/esm/hooks/use-on-delete-cells-shift-up.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-delete-cells-shift-up.js +26 -2
- package/dist/esm/hooks/use-on-delete-column.d.ts +13 -4
- package/dist/esm/hooks/use-on-delete-column.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-delete-column.js +14 -2
- package/dist/esm/hooks/use-on-delete-row.d.ts +13 -4
- package/dist/esm/hooks/use-on-delete-row.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-delete-row.js +14 -2
- package/dist/esm/hooks/use-on-insert-cells-shift-down.d.ts +13 -3
- package/dist/esm/hooks/use-on-insert-cells-shift-down.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-insert-cells-shift-down.js +26 -2
- package/dist/esm/hooks/use-on-insert-cells-shift-right.d.ts +13 -3
- package/dist/esm/hooks/use-on-insert-cells-shift-right.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-insert-cells-shift-right.js +26 -2
- package/dist/esm/hooks/use-on-insert-column.d.ts +10 -3
- package/dist/esm/hooks/use-on-insert-column.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-insert-column.js +33 -7
- package/dist/esm/hooks/use-on-insert-row.d.ts +10 -3
- package/dist/esm/hooks/use-on-insert-row.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-insert-row.js +32 -7
- package/dist/esm/hooks/use-spreadsheet-state.d.ts +2 -2
- package/dist/esm/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/esm/hooks/use-spreadsheet-state.js +61 -15
- package/dist/esm/hooks/use-structured-reference.d.ts.map +1 -1
- package/dist/esm/hooks/use-structured-reference.js +10 -6
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/interface/calculation-interface.d.ts +9 -0
- package/dist/esm/interface/calculation-interface.d.ts.map +1 -1
- package/dist/esm/interface/calculation-interface.js +33 -2
- package/dist/esm/interface/delete-cells-shift-left.d.ts +8 -1
- package/dist/esm/interface/delete-cells-shift-left.d.ts.map +1 -1
- package/dist/esm/interface/delete-cells-shift-left.js +135 -59
- package/dist/esm/interface/delete-cells-shift-up.d.ts +9 -1
- package/dist/esm/interface/delete-cells-shift-up.d.ts.map +1 -1
- package/dist/esm/interface/delete-cells-shift-up.js +133 -53
- package/dist/esm/interface/delete-column.d.ts +1 -1
- package/dist/esm/interface/delete-column.d.ts.map +1 -1
- package/dist/esm/interface/delete-column.js +80 -11
- package/dist/esm/interface/delete-row.d.ts +1 -1
- package/dist/esm/interface/delete-row.d.ts.map +1 -1
- package/dist/esm/interface/delete-row.js +81 -11
- package/dist/esm/interface/insert-cells-shift-down.d.ts +10 -1
- package/dist/esm/interface/insert-cells-shift-down.d.ts.map +1 -1
- package/dist/esm/interface/insert-cells-shift-down.js +116 -47
- package/dist/esm/interface/insert-cells-shift-right.d.ts +10 -1
- package/dist/esm/interface/insert-cells-shift-right.d.ts.map +1 -1
- package/dist/esm/interface/insert-cells-shift-right.js +120 -51
- package/dist/esm/interface/insert-column.d.ts +1 -1
- package/dist/esm/interface/insert-column.d.ts.map +1 -1
- package/dist/esm/interface/insert-column.js +46 -8
- package/dist/esm/interface/insert-row.d.ts +1 -1
- package/dist/esm/interface/insert-row.d.ts.map +1 -1
- package/dist/esm/interface/insert-row.js +47 -10
- package/dist/esm/interface/spreadsheet-interface.d.ts.map +1 -1
- package/dist/esm/interface/spreadsheet-interface.js +29 -0
- package/dist/esm/sheet-cell.d.ts.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +16 -16
|
@@ -18,8 +18,10 @@ export var useStructuredReference = function (_a) {
|
|
|
18
18
|
});
|
|
19
19
|
// Current row
|
|
20
20
|
var rowIndex = cell.row;
|
|
21
|
+
// Excel: a structured reference whose table no longer exists (the table
|
|
22
|
+
// was deleted, or every one of its rows) is `#REF!`, never `#NAME?`.
|
|
21
23
|
if (!table) {
|
|
22
|
-
throw new FormulaError("#
|
|
24
|
+
throw new FormulaError("#REF!", "Table could not be found");
|
|
23
25
|
}
|
|
24
26
|
// Special this row item
|
|
25
27
|
if (specialItem === "#This Row") {
|
|
@@ -33,12 +35,14 @@ export var useStructuredReference = function (_a) {
|
|
|
33
35
|
var _c = __read(columnNames !== null && columnNames !== void 0 ? columnNames : [], 2), from = _c[0], to = _c[1];
|
|
34
36
|
var startColIndex = getColumnIndexFromColumnName(table, from);
|
|
35
37
|
var endColIndex = getColumnIndexFromColumnName(table, to);
|
|
36
|
-
// Exit early, if column could not be found
|
|
38
|
+
// Exit early, if column could not be found. Excel: a reference to a
|
|
39
|
+
// column the table does not have — including the `#REF!` specifier a
|
|
40
|
+
// column delete writes (`Table1[@#REF!]`) — is `#REF!`.
|
|
37
41
|
if (!isNil(to) && isNil(endColIndex)) {
|
|
38
|
-
throw new FormulaError("#
|
|
42
|
+
throw new FormulaError("#REF!", "Column not found ".concat(to));
|
|
39
43
|
}
|
|
40
44
|
if (!isNil(from) && isNil(startColIndex)) {
|
|
41
|
-
throw new FormulaError("#
|
|
45
|
+
throw new FormulaError("#REF!", "Column not found ".concat(from));
|
|
42
46
|
}
|
|
43
47
|
var startColumnIndex = isNil(startColIndex)
|
|
44
48
|
? range.startColumnIndex
|
|
@@ -95,10 +99,10 @@ export var useStructuredReference = function (_a) {
|
|
|
95
99
|
}
|
|
96
100
|
// If column is not found, lets not select anything
|
|
97
101
|
if (from && isNil(startColIndex)) {
|
|
98
|
-
throw new FormulaError("#
|
|
102
|
+
throw new FormulaError("#REF!", "Column: ".concat(from, " could not be found"));
|
|
99
103
|
}
|
|
100
104
|
if (to && isNil(endColIndex)) {
|
|
101
|
-
throw new FormulaError("#
|
|
105
|
+
throw new FormulaError("#REF!", "Column: ".concat(to, " could not be found"));
|
|
102
106
|
}
|
|
103
107
|
// Check if thisrow is active and current cell is in bounds
|
|
104
108
|
if (thisRow &&
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -20,8 +20,11 @@ export * from "./helpers";
|
|
|
20
20
|
export * from "./api/fill";
|
|
21
21
|
export * from "./api/immer-utils";
|
|
22
22
|
export * from "./api/range";
|
|
23
|
+
export * from "./api/anchored-objects";
|
|
23
24
|
export * from "./atoms";
|
|
24
25
|
export * from "./api/formula";
|
|
26
|
+
export * from "./api/structural-guards";
|
|
27
|
+
export * from "./constants";
|
|
25
28
|
export * from "./types";
|
|
26
29
|
export * from "./commands";
|
|
27
30
|
export type { ClearType } from "./interface/delete-cells";
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,OAAO,EACL,yBAAyB,EACzB,cAAc,EACd,WAAW,EACX,SAAS,EACT,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,4BAA4B,EAC5B,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,KAAK,2BAA2B,GACjC,MAAM,qBAAqB,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,oCAAoC,CAAC;AACnD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oCAAoC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AClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -20,8 +20,11 @@ export * from "./helpers";
|
|
|
20
20
|
export * from "./api/fill";
|
|
21
21
|
export * from "./api/immer-utils";
|
|
22
22
|
export * from "./api/range";
|
|
23
|
+
export * from "./api/anchored-objects";
|
|
23
24
|
export * from "./atoms";
|
|
24
25
|
export * from "./api/formula";
|
|
26
|
+
export * from "./api/structural-guards";
|
|
27
|
+
export * from "./constants";
|
|
25
28
|
export * from "./types";
|
|
26
29
|
export * from "./commands";
|
|
27
30
|
// Register
|
|
@@ -60,6 +60,15 @@ export declare class CalculationInterface {
|
|
|
60
60
|
private ensureWorkerMetadata;
|
|
61
61
|
private isClientOnlyFormula;
|
|
62
62
|
private executeOperations;
|
|
63
|
+
/**
|
|
64
|
+
* Mirror a dynamic-array anchor's spill rectangle on the local graph (a
|
|
65
|
+
* matrix result registers it, a scalar clears it) so structural edits can
|
|
66
|
+
* find the projected cells of an anchor they delete — the same bookkeeping
|
|
67
|
+
* the React worker hook does in `handleArrayEvaluation`.
|
|
68
|
+
*/
|
|
69
|
+
private trackArrayResult;
|
|
70
|
+
/** The spill rectangle currently anchored at `position`, if it is a dynamic array. */
|
|
71
|
+
getArrayRange(position: CellCoordinate): CellCoordinateRange | undefined;
|
|
63
72
|
private createDefaultWorker;
|
|
64
73
|
private ensureWorker;
|
|
65
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculation-interface.d.ts","sourceRoot":"","sources":["../../../interface/calculation-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"calculation-interface.d.ts","sourceRoot":"","sources":["../../../interface/calculation-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAA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B;YAOhB,oBAAoB;IAelC,OAAO,CAAC,mBAAmB;YAcb,iBAAiB;IA2C/B;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAkBxB,sFAAsF;IACtF,aAAa,CAAC,QAAQ,EAAE,cAAc,GAAG,mBAAmB,GAAG,SAAS;IAIxE,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,YAAY;CAuDrB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
|
-
import { resolveSheetSpan } from "@rowsncolumns/utils";
|
|
1
|
+
import { __awaiter, __generator, __read, __spreadArray } from "tslib";
|
|
3
2
|
import { CalculationGraph, CalculationWorkerClient, createNamedRangeResolver, createStructuredReferenceResolver, enqueueCalculationOperations, mapOperationToGraphOperation, } from "@rowsncolumns/calculation-worker/server";
|
|
4
3
|
import { FormulaError } from "@rowsncolumns/fast-formula-parser";
|
|
4
|
+
import { resolveSheetSpan } from "@rowsncolumns/utils";
|
|
5
5
|
var isSerializedFormulaError = function (value) {
|
|
6
6
|
return Boolean(value &&
|
|
7
7
|
typeof value === "object" &&
|
|
@@ -344,6 +344,7 @@ var CalculationInterface = /** @class */ (function () {
|
|
|
344
344
|
case 2:
|
|
345
345
|
results = _a.sent();
|
|
346
346
|
expandedResults = results.flatMap(function (result) {
|
|
347
|
+
_this.trackArrayResult(result);
|
|
347
348
|
return expandWorkerResult(result);
|
|
348
349
|
});
|
|
349
350
|
if (expandedResults.length) {
|
|
@@ -354,6 +355,34 @@ var CalculationInterface = /** @class */ (function () {
|
|
|
354
355
|
});
|
|
355
356
|
});
|
|
356
357
|
};
|
|
358
|
+
/**
|
|
359
|
+
* Mirror a dynamic-array anchor's spill rectangle on the local graph (a
|
|
360
|
+
* matrix result registers it, a scalar clears it) so structural edits can
|
|
361
|
+
* find the projected cells of an anchor they delete — the same bookkeeping
|
|
362
|
+
* the React worker hook does in `handleArrayEvaluation`.
|
|
363
|
+
*/
|
|
364
|
+
CalculationInterface.prototype.trackArrayResult = function (result) {
|
|
365
|
+
if (!result.position)
|
|
366
|
+
return;
|
|
367
|
+
var position = result.position;
|
|
368
|
+
var matrix = normalizeMatrixValue(deserializeWorkerValue(result.value));
|
|
369
|
+
if (!matrix) {
|
|
370
|
+
this.graph.unregisterArrayFormula(position);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
var columns = Math.max.apply(Math, __spreadArray([1], __read(matrix.map(function (row) { return row.length; })), false));
|
|
374
|
+
this.graph.registerArrayFormula(position, {
|
|
375
|
+
sheetId: position.sheetId,
|
|
376
|
+
startRowIndex: position.rowIndex,
|
|
377
|
+
startColumnIndex: position.columnIndex,
|
|
378
|
+
endRowIndex: position.rowIndex + matrix.length - 1,
|
|
379
|
+
endColumnIndex: position.columnIndex + columns - 1,
|
|
380
|
+
});
|
|
381
|
+
};
|
|
382
|
+
/** The spill rectangle currently anchored at `position`, if it is a dynamic array. */
|
|
383
|
+
CalculationInterface.prototype.getArrayRange = function (position) {
|
|
384
|
+
return this.graph.getArrayRange(position);
|
|
385
|
+
};
|
|
357
386
|
CalculationInterface.prototype.createDefaultWorker = function () {
|
|
358
387
|
if (typeof require !== "function") {
|
|
359
388
|
throw new Error("createCalculationWorker must be provided outside of Node.js.");
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { CellInterface, SelectionArea } from "@rowsncolumns/common-types";
|
|
2
2
|
import type { CellData, SelectionAttributes, Sheet } from "@rowsncolumns/spreadsheet";
|
|
3
3
|
import type { UseOnDeleteCellsShiftLeftProps } from "../hooks/use-on-delete-cells-shift-left";
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Delete cells ▸ Shift cells left (SHF-04) — the horizontal twin of `deleteCellsShiftUp`: only the
|
|
6
|
+
* selection's rows move, the selected block is removed and every cell to its right slides left by
|
|
7
|
+
* the block's width. A reference to a deleted cell becomes `#REF!`; one to a cell that slid left
|
|
8
|
+
* follows it; a range entirely inside the block's rows that the block partially covers contracts.
|
|
9
|
+
* Refusals (torn merge/table/array) are decided by the hook before this runs.
|
|
10
|
+
*/
|
|
11
|
+
export declare const deleteCellsShiftLeft: <T extends CellData, S extends Sheet>({ rowCount, columnCount, locale, cellXfsRegistry, sharedStringRegistry, getActiveCell, getSelections, getDependents, getSheetName, createHistory, enqueueGraphOperation, enqueueCalculation, enqueueStructureChange, onChangeSheetData, onChangeSheets, onChangeTables, onChangeCitations, }: UseOnDeleteCellsShiftLeftProps<T, S>) => (sheetId: number, activeCell: CellInterface, selections: SelectionArea<SelectionAttributes>[]) => void;
|
|
5
12
|
//# sourceMappingURL=delete-cells-shift-left.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-cells-shift-left.d.ts","sourceRoot":"","sources":["../../../interface/delete-cells-shift-left.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,aAAa,EACd,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"delete-cells-shift-left.d.ts","sourceRoot":"","sources":["../../../interface/delete-cells-shift-left.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,aAAa,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,QAAQ,EACR,mBAAmB,EACnB,KAAK,EACN,MAAM,2BAA2B,CAAC;AAgBnC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAI9F;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,EAAE,8RAkBvE,8BAA8B,CAAC,CAAC,EAAE,CAAC,CAAC,MAEnC,SAAS,MAAM,EACf,YAAY,aAAa,EACzB,YAAY,aAAa,CAAC,mBAAmB,CAAC,EAAE,SAqRnD,CAAC"}
|
|
@@ -1,62 +1,91 @@
|
|
|
1
|
-
import { __read, __spreadArray, __values } from "tslib";
|
|
2
|
-
import { selectionFromActiveCell } from "@rowsncolumns/utils";
|
|
1
|
+
import { __assign, __read, __spreadArray, __values } from "tslib";
|
|
3
2
|
import { produceWithPatches } from "immer";
|
|
4
3
|
import { collectUniqueDependentsForRange, moveFormulaAtPosition, } from "../api/dependency";
|
|
5
|
-
import {
|
|
4
|
+
import { contractRangesInFormula } from "../api/formula";
|
|
5
|
+
import { createSheetDraft } from "../api/immer-utils";
|
|
6
|
+
import { shiftMergesInBand } from "../api/merges";
|
|
7
|
+
import { isRangeInsideBand, isRangeInsideBlock, resolveShiftSelection, shiftBand, } from "../api/structural-guards";
|
|
8
|
+
import { SheetCell } from "../sheet-cell";
|
|
9
|
+
/**
|
|
10
|
+
* Delete cells ▸ Shift cells left (SHF-04) — the horizontal twin of `deleteCellsShiftUp`: only the
|
|
11
|
+
* selection's rows move, the selected block is removed and every cell to its right slides left by
|
|
12
|
+
* the block's width. A reference to a deleted cell becomes `#REF!`; one to a cell that slid left
|
|
13
|
+
* follows it; a range entirely inside the block's rows that the block partially covers contracts.
|
|
14
|
+
* Refusals (torn merge/table/array) are decided by the hook before this runs.
|
|
15
|
+
*/
|
|
6
16
|
export var deleteCellsShiftLeft = function (_a) {
|
|
7
|
-
var rowCount = _a.rowCount, columnCount = _a.columnCount, locale = _a.locale, cellXfsRegistry = _a.cellXfsRegistry, sharedStringRegistry = _a.sharedStringRegistry, getActiveCell = _a.getActiveCell, getSelections = _a.getSelections, getDependents = _a.getDependents, createHistory = _a.createHistory, enqueueGraphOperation = _a.enqueueGraphOperation, enqueueCalculation = _a.enqueueCalculation, enqueueStructureChange = _a.enqueueStructureChange, onChangeSheetData = _a.onChangeSheetData, onChangeSheets = _a.onChangeSheets, onChangeCitations = _a.onChangeCitations;
|
|
17
|
+
var rowCount = _a.rowCount, columnCount = _a.columnCount, locale = _a.locale, cellXfsRegistry = _a.cellXfsRegistry, sharedStringRegistry = _a.sharedStringRegistry, getActiveCell = _a.getActiveCell, getSelections = _a.getSelections, getDependents = _a.getDependents, getSheetName = _a.getSheetName, createHistory = _a.createHistory, enqueueGraphOperation = _a.enqueueGraphOperation, enqueueCalculation = _a.enqueueCalculation, enqueueStructureChange = _a.enqueueStructureChange, onChangeSheetData = _a.onChangeSheetData, onChangeSheets = _a.onChangeSheets, onChangeTables = _a.onChangeTables, onChangeCitations = _a.onChangeCitations;
|
|
8
18
|
return function (sheetId, activeCell, selections) {
|
|
19
|
+
var _a;
|
|
9
20
|
var saveHistory = createHistory();
|
|
10
21
|
var recalcCells = new Map();
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
var
|
|
22
|
+
var selection = resolveShiftSelection(activeCell, selections);
|
|
23
|
+
var _b = selection.range, r1 = _b.startRowIndex, r2 = _b.endRowIndex, c1 = _b.startColumnIndex, c2 = _b.endColumnIndex;
|
|
24
|
+
var count = c2 - c1 + 1;
|
|
25
|
+
var band = shiftBand("left", selection.range);
|
|
26
|
+
var deletedRange = __assign({}, selection.range);
|
|
27
|
+
var sheetName = (_a = getSheetName === null || getSheetName === void 0 ? void 0 : getSheetName(sheetId)) !== null && _a !== void 0 ? _a : "";
|
|
17
28
|
enqueueStructureChange === null || enqueueStructureChange === void 0 ? void 0 : enqueueStructureChange({
|
|
18
29
|
kind: "delete-cells-shift-left",
|
|
19
30
|
sheetId: sheetId,
|
|
20
|
-
startRowIndex:
|
|
21
|
-
endRowIndex:
|
|
22
|
-
startColumnIndex:
|
|
23
|
-
endColumnIndex:
|
|
31
|
+
startRowIndex: r1,
|
|
32
|
+
endRowIndex: r2,
|
|
33
|
+
startColumnIndex: c1,
|
|
34
|
+
endColumnIndex: c2,
|
|
24
35
|
columnCount: columnCount,
|
|
25
36
|
});
|
|
26
|
-
// Update merges on sheet
|
|
37
|
+
// Update merges on sheet — merges wholly inside the deleted block go with it; merges wholly
|
|
38
|
+
// inside the shifted rows right of it ride left.
|
|
27
39
|
onChangeSheets === null || onChangeSheets === void 0 ? void 0 : onChangeSheets(function (prevSheets) {
|
|
28
40
|
var _a = __read(produceWithPatches(prevSheets, function (draft) {
|
|
29
41
|
var sheet = draft.find(function (s) { return s.sheetId === sheetId; });
|
|
30
42
|
if (sheet === null || sheet === void 0 ? void 0 : sheet.merges) {
|
|
31
|
-
|
|
32
|
-
sheet.merges = moveMergedCells(sheet.merges, "column-remove", columnIndex);
|
|
33
|
-
}
|
|
43
|
+
sheet.merges = shiftMergesInBand(sheet.merges, "column", c1, count, false, r1, r2);
|
|
34
44
|
}
|
|
35
45
|
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
36
46
|
saveHistory({ sheets: { patches: patches, inversePatches: inversePatches } });
|
|
37
47
|
return nextState;
|
|
38
48
|
});
|
|
49
|
+
// Tables: one wholly inside the deleted block is deleted with it; one wholly inside the
|
|
50
|
+
// shifted rows right of the block rides left. A partial cover was refused by the hook.
|
|
51
|
+
onChangeTables === null || onChangeTables === void 0 ? void 0 : onChangeTables(function (prevTables) {
|
|
52
|
+
var _a = __read(produceWithPatches(prevTables, function (draft) {
|
|
53
|
+
for (var idx = draft.length - 1; idx >= 0; idx--) {
|
|
54
|
+
var table = draft[idx];
|
|
55
|
+
if (table.sheetId !== sheetId)
|
|
56
|
+
continue;
|
|
57
|
+
if (isRangeInsideBlock(deletedRange, table.range)) {
|
|
58
|
+
draft.splice(idx, 1);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (isRangeInsideBand(table.range, band) &&
|
|
62
|
+
table.range.startColumnIndex > c2) {
|
|
63
|
+
table.range.startColumnIndex -= count;
|
|
64
|
+
table.range.endColumnIndex -= count;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
68
|
+
saveHistory({ tables: { patches: patches, inversePatches: inversePatches } });
|
|
69
|
+
return nextState;
|
|
70
|
+
});
|
|
39
71
|
// Update citations - delete if overlapping, shift back if after
|
|
40
72
|
onChangeCitations === null || onChangeCitations === void 0 ? void 0 : onChangeCitations(function (prevCitations) {
|
|
41
73
|
var _a = __read(produceWithPatches(prevCitations, function (draft) {
|
|
42
|
-
var deleteRowStart = selection.range.startRowIndex;
|
|
43
|
-
var deleteRowEnd = selection.range.endRowIndex;
|
|
44
|
-
var deleteColStart = selection.range.startColumnIndex;
|
|
45
|
-
var deleteColEnd = selection.range.endColumnIndex;
|
|
46
|
-
var shiftAmount = deleteColEnd - deleteColStart + 1;
|
|
47
74
|
for (var idx = draft.length - 1; idx >= 0; idx--) {
|
|
48
75
|
var citation = draft[idx];
|
|
49
76
|
if (citation.range.sheetId !== sheetId)
|
|
50
77
|
continue;
|
|
51
|
-
var rowsOverlap = !(citation.range.endRowIndex <
|
|
78
|
+
var rowsOverlap = !(citation.range.endRowIndex < r1 ||
|
|
79
|
+
citation.range.startRowIndex > r2);
|
|
52
80
|
if (rowsOverlap) {
|
|
53
|
-
var colsOverlap = !(citation.range.endColumnIndex <
|
|
81
|
+
var colsOverlap = !(citation.range.endColumnIndex < c1 ||
|
|
82
|
+
citation.range.startColumnIndex > c2);
|
|
54
83
|
if (colsOverlap) {
|
|
55
84
|
draft.splice(idx, 1);
|
|
56
85
|
}
|
|
57
|
-
else if (citation.range.startColumnIndex >
|
|
58
|
-
citation.range.startColumnIndex -=
|
|
59
|
-
citation.range.endColumnIndex -=
|
|
86
|
+
else if (citation.range.startColumnIndex > c2) {
|
|
87
|
+
citation.range.startColumnIndex -= count;
|
|
88
|
+
citation.range.endColumnIndex -= count;
|
|
60
89
|
}
|
|
61
90
|
}
|
|
62
91
|
}
|
|
@@ -68,79 +97,128 @@ export var deleteCellsShiftLeft = function (_a) {
|
|
|
68
97
|
onChangeSheetData === null || onChangeSheetData === void 0 ? void 0 : onChangeSheetData(function (prevSheetData) {
|
|
69
98
|
var _a = __read(produceWithPatches(prevSheetData, function (draft) {
|
|
70
99
|
var e_1, _a;
|
|
71
|
-
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
100
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
72
101
|
var movedKeys = new Set();
|
|
73
|
-
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
102
|
+
var totalColumns = Math.max(columnCount, c2 + 1);
|
|
103
|
+
for (var rowIndex = r1; rowIndex <= r2; rowIndex++) {
|
|
104
|
+
totalColumns = Math.max(totalColumns, (_e = (_d = (_c = (_b = draft[sheetId]) === null || _b === void 0 ? void 0 : _b[rowIndex]) === null || _c === void 0 ? void 0 : _c.values) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0);
|
|
105
|
+
}
|
|
106
|
+
// The cells that actually move: everything RIGHT of the deleted block in its rows.
|
|
107
|
+
var movingRange = {
|
|
108
|
+
startRowIndex: r1,
|
|
109
|
+
endRowIndex: r2,
|
|
110
|
+
startColumnIndex: c2 + 1,
|
|
111
|
+
endColumnIndex: totalColumns,
|
|
79
112
|
};
|
|
80
|
-
//
|
|
113
|
+
// Dependents of the deleted block AND of the moving cells, each processed once.
|
|
81
114
|
var dependents = collectUniqueDependentsForRange({
|
|
82
115
|
draft: draft,
|
|
83
116
|
sheetId: sheetId,
|
|
84
|
-
sourceRange:
|
|
117
|
+
sourceRange: {
|
|
118
|
+
startRowIndex: r1,
|
|
119
|
+
endRowIndex: r2,
|
|
120
|
+
startColumnIndex: c1,
|
|
121
|
+
endColumnIndex: totalColumns,
|
|
122
|
+
},
|
|
85
123
|
getDependents: getDependents,
|
|
86
124
|
});
|
|
125
|
+
var sheetCell = new SheetCell();
|
|
126
|
+
var contractAt = function (pos) {
|
|
127
|
+
var _a, _b;
|
|
128
|
+
if (pos.sheetId !== sheetId)
|
|
129
|
+
return;
|
|
130
|
+
var currentSheet = createSheetDraft(draft, sheetId, pos.rowIndex);
|
|
131
|
+
var cellData = (_b = (_a = currentSheet[pos.rowIndex]) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b[pos.columnIndex];
|
|
132
|
+
sheetCell.assign(sheetId, { rowIndex: pos.rowIndex, columnIndex: pos.columnIndex }, cellData, { locale: locale, cellXfsRegistry: cellXfsRegistry, sharedStringRegistry: sharedStringRegistry });
|
|
133
|
+
var formulaValue = sheetCell.formula;
|
|
134
|
+
if (!formulaValue)
|
|
135
|
+
return;
|
|
136
|
+
var contracted = contractRangesInFormula(formulaValue, c1, count, "column", sheetName, { bandSpan: { startIndex: r1, endIndex: r2 } });
|
|
137
|
+
if (!contracted || contracted === formulaValue)
|
|
138
|
+
return;
|
|
139
|
+
sheetCell.setFormulaValue(contracted, false);
|
|
140
|
+
currentSheet[pos.rowIndex].values[pos.columnIndex] =
|
|
141
|
+
sheetCell.getCellData();
|
|
142
|
+
};
|
|
143
|
+
var rebaseAt = function (pos) {
|
|
144
|
+
var insideBlock = pos.sheetId === sheetId &&
|
|
145
|
+
pos.rowIndex >= r1 &&
|
|
146
|
+
pos.rowIndex <= r2 &&
|
|
147
|
+
pos.columnIndex >= c1 &&
|
|
148
|
+
pos.columnIndex <= c2;
|
|
149
|
+
if (insideBlock)
|
|
150
|
+
return;
|
|
151
|
+
var moves = pos.sheetId === sheetId &&
|
|
152
|
+
pos.columnIndex > c2 &&
|
|
153
|
+
pos.rowIndex >= r1 &&
|
|
154
|
+
pos.rowIndex <= r2;
|
|
155
|
+
contractAt(pos);
|
|
156
|
+
moveFormulaAtPosition({
|
|
157
|
+
draft: draft,
|
|
158
|
+
position: pos,
|
|
159
|
+
activeSheetName: getSheetName === null || getSheetName === void 0 ? void 0 : getSheetName(pos.sheetId),
|
|
160
|
+
enqueueCalculation: enqueueCalculation,
|
|
161
|
+
enqueueGraphOperation: enqueueGraphOperation,
|
|
162
|
+
recalcCells: recalcCells,
|
|
163
|
+
movedKeys: movedKeys,
|
|
164
|
+
rowDelta: 0,
|
|
165
|
+
columnDelta: -count,
|
|
166
|
+
destinationPosition: {
|
|
167
|
+
rowIndex: pos.rowIndex,
|
|
168
|
+
columnIndex: moves ? pos.columnIndex - count : pos.columnIndex,
|
|
169
|
+
},
|
|
170
|
+
sourceRange: movingRange,
|
|
171
|
+
deletedRange: deletedRange,
|
|
172
|
+
locale: locale,
|
|
173
|
+
rowCount: rowCount,
|
|
174
|
+
columnCount: columnCount,
|
|
175
|
+
cellXfsRegistry: cellXfsRegistry,
|
|
176
|
+
sharedStringRegistry: sharedStringRegistry,
|
|
177
|
+
});
|
|
178
|
+
};
|
|
87
179
|
try {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
moveFormulaAtPosition({
|
|
92
|
-
draft: draft,
|
|
93
|
-
position: pos,
|
|
94
|
-
enqueueCalculation: enqueueCalculation,
|
|
95
|
-
enqueueGraphOperation: enqueueGraphOperation,
|
|
96
|
-
recalcCells: recalcCells,
|
|
97
|
-
movedKeys: movedKeys,
|
|
98
|
-
rowDelta: 0,
|
|
99
|
-
columnDelta: -count,
|
|
100
|
-
sourceRange: sourceRange,
|
|
101
|
-
locale: locale,
|
|
102
|
-
rowCount: rowCount,
|
|
103
|
-
columnCount: columnCount,
|
|
104
|
-
cellXfsRegistry: cellXfsRegistry,
|
|
105
|
-
sharedStringRegistry: sharedStringRegistry,
|
|
106
|
-
});
|
|
180
|
+
for (var _s = __values(dependents.values()), _t = _s.next(); !_t.done; _t = _s.next()) {
|
|
181
|
+
var pos = _t.value;
|
|
182
|
+
rebaseAt(pos);
|
|
107
183
|
}
|
|
108
184
|
}
|
|
109
185
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
110
186
|
finally {
|
|
111
187
|
try {
|
|
112
|
-
if (
|
|
188
|
+
if (_t && !_t.done && (_a = _s.return)) _a.call(_s);
|
|
113
189
|
}
|
|
114
190
|
finally { if (e_1) throw e_1.error; }
|
|
115
191
|
}
|
|
116
|
-
//
|
|
117
|
-
for (var rowIndex =
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
moveFormulaAtPosition({
|
|
122
|
-
draft: draft,
|
|
123
|
-
position: { sheetId: sheetId, rowIndex: rowIndex, columnIndex: columnIndex },
|
|
124
|
-
enqueueCalculation: enqueueCalculation,
|
|
125
|
-
enqueueGraphOperation: enqueueGraphOperation,
|
|
126
|
-
recalcCells: recalcCells,
|
|
127
|
-
movedKeys: movedKeys,
|
|
128
|
-
rowDelta: 0,
|
|
129
|
-
columnDelta: -count,
|
|
130
|
-
sourceRange: sourceRange,
|
|
192
|
+
// Formulas inside the deleted block leave the graph with their cells.
|
|
193
|
+
for (var rowIndex = r1; rowIndex <= r2; rowIndex++) {
|
|
194
|
+
for (var columnIndex = c1; columnIndex <= c2; columnIndex++) {
|
|
195
|
+
var cellData = (_h = (_g = (_f = draft[sheetId]) === null || _f === void 0 ? void 0 : _f[rowIndex]) === null || _g === void 0 ? void 0 : _g.values) === null || _h === void 0 ? void 0 : _h[columnIndex];
|
|
196
|
+
sheetCell.assign(sheetId, { rowIndex: rowIndex, columnIndex: columnIndex }, cellData, {
|
|
131
197
|
locale: locale,
|
|
132
|
-
rowCount: rowCount,
|
|
133
|
-
columnCount: columnCount,
|
|
134
|
-
cellXfsRegistry: cellXfsRegistry,
|
|
135
|
-
sharedStringRegistry: sharedStringRegistry,
|
|
136
198
|
});
|
|
199
|
+
if (!sheetCell.isFormula())
|
|
200
|
+
continue;
|
|
201
|
+
var enqueueOperation = sheetCell.ephemeral()
|
|
202
|
+
? enqueueCalculation
|
|
203
|
+
: enqueueGraphOperation;
|
|
204
|
+
enqueueOperation === null || enqueueOperation === void 0 ? void 0 : enqueueOperation({
|
|
205
|
+
type: "remove",
|
|
206
|
+
position: { sheetId: sheetId, rowIndex: rowIndex, columnIndex: columnIndex },
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// Re-base the moving formulas themselves
|
|
211
|
+
for (var rowIndex = r1; rowIndex <= r2; rowIndex++) {
|
|
212
|
+
var dataColumnCount = (_m = (_l = (_k = (_j = draft[sheetId]) === null || _j === void 0 ? void 0 : _j[rowIndex]) === null || _k === void 0 ? void 0 : _k.values) === null || _l === void 0 ? void 0 : _l.length) !== null && _m !== void 0 ? _m : 0;
|
|
213
|
+
for (var columnIndex = c2 + 1; columnIndex < dataColumnCount; columnIndex++) {
|
|
214
|
+
rebaseAt({ sheetId: sheetId, rowIndex: rowIndex, columnIndex: columnIndex });
|
|
137
215
|
}
|
|
138
216
|
}
|
|
139
217
|
// Finally delete the selected cells by splicing from right to left
|
|
140
|
-
for (var rowIndex =
|
|
141
|
-
for (var columnIndex =
|
|
142
|
-
if ((
|
|
143
|
-
(
|
|
218
|
+
for (var rowIndex = r1; rowIndex <= r2; rowIndex++) {
|
|
219
|
+
for (var columnIndex = c2; columnIndex >= c1; columnIndex--) {
|
|
220
|
+
if ((_p = (_o = draft[sheetId]) === null || _o === void 0 ? void 0 : _o[rowIndex]) === null || _p === void 0 ? void 0 : _p.values) {
|
|
221
|
+
(_r = (_q = draft[sheetId][rowIndex]) === null || _q === void 0 ? void 0 : _q.values) === null || _r === void 0 ? void 0 : _r.splice(columnIndex, 1);
|
|
144
222
|
}
|
|
145
223
|
}
|
|
146
224
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { CellInterface, SelectionArea } from "@rowsncolumns/common-types";
|
|
2
2
|
import type { CellData, SelectionAttributes, Sheet } from "@rowsncolumns/spreadsheet";
|
|
3
3
|
import type { UseOnDeleteCellsShiftUpProps } from "../hooks/use-on-delete-cells-shift-up";
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Delete cells ▸ Shift cells up (SHF-03, SHF-09). Only the selection's columns move: the selected
|
|
6
|
+
* block is removed and every cell below it slides up by the block's height. A reference to a
|
|
7
|
+
* deleted cell (or to a range the block covers entirely) becomes `#REF!` (SHF-09); a reference to a
|
|
8
|
+
* cell that slid up follows it (SHF-03); a range entirely inside the block's columns that the block
|
|
9
|
+
* partially covers contracts by the overlap. Refusals (torn merge/table/array) are decided by the
|
|
10
|
+
* hook via `getShiftCellsRefusal` before this runs.
|
|
11
|
+
*/
|
|
12
|
+
export declare const deleteCellsShiftUp: <T extends CellData, S extends Sheet>({ rowCount, columnCount, locale, cellXfsRegistry, sharedStringRegistry, getActiveCell, getSelections, getDependents, getSheetName, createHistory, enqueueGraphOperation, enqueueCalculation, enqueueStructureChange, onChangeSheetData, onChangeSheets, onChangeTables, onChangeCitations, }: UseOnDeleteCellsShiftUpProps<T, S>) => (sheetId: number, activeCell: CellInterface, selections: SelectionArea<SelectionAttributes>[]) => void;
|
|
5
13
|
//# sourceMappingURL=delete-cells-shift-up.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-cells-shift-up.d.ts","sourceRoot":"","sources":["../../../interface/delete-cells-shift-up.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,aAAa,EACd,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"delete-cells-shift-up.d.ts","sourceRoot":"","sources":["../../../interface/delete-cells-shift-up.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,aAAa,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,QAAQ,EACR,mBAAmB,EACnB,KAAK,EACN,MAAM,2BAA2B,CAAC;AAgBnC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAI1F;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,EAAE,8RAkBrE,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,MAEjC,SAAS,MAAM,EACf,YAAY,aAAa,EACzB,YAAY,aAAa,CAAC,mBAAmB,CAAC,EAAE,SAmQnD,CAAC"}
|