@gridsheet/react-core 0.12.3 → 0.12.4-rc.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/components/Cell.js +197 -181
- package/dist/components/Cell.js.map +1 -1
- package/dist/components/ContextMenu.js +211 -194
- package/dist/components/ContextMenu.js.map +1 -1
- package/dist/components/Editor.js +280 -263
- package/dist/components/Editor.js.map +1 -1
- package/dist/components/Emitter.js +41 -24
- package/dist/components/Emitter.js.map +1 -1
- package/dist/components/GridSheet.js +142 -105
- package/dist/components/GridSheet.js.map +1 -1
- package/dist/components/HeaderLeftCell.js +76 -60
- package/dist/components/HeaderLeftCell.js.map +1 -1
- package/dist/components/HeaderTopCell.js +77 -61
- package/dist/components/HeaderTopCell.js.map +1 -1
- package/dist/components/Resizer.js +91 -75
- package/dist/components/Resizer.js.map +1 -1
- package/dist/components/SearchBox.js +66 -49
- package/dist/components/SearchBox.js.map +1 -1
- package/dist/components/StoreInitializer.js +83 -66
- package/dist/components/StoreInitializer.js.map +1 -1
- package/dist/components/Tabular.js +98 -80
- package/dist/components/Tabular.js.map +1 -1
- package/dist/constants.js +33 -19
- package/dist/constants.js.map +1 -1
- package/dist/formula/evaluator.js +500 -474
- package/dist/formula/evaluator.js.map +1 -1
- package/dist/formula/functions/__base.js +27 -13
- package/dist/formula/functions/__base.js.map +1 -1
- package/dist/formula/functions/__utils.js +113 -95
- package/dist/formula/functions/__utils.js.map +1 -1
- package/dist/formula/functions/abs.js +31 -17
- package/dist/formula/functions/abs.js.map +1 -1
- package/dist/formula/functions/abs.spec.js +35 -23
- package/dist/formula/functions/abs.spec.js.map +1 -1
- package/dist/formula/functions/acos.js +38 -24
- package/dist/formula/functions/acos.js.map +1 -1
- package/dist/formula/functions/add.js +57 -43
- package/dist/formula/functions/add.js.map +1 -1
- package/dist/formula/functions/and.js +38 -24
- package/dist/formula/functions/and.js.map +1 -1
- package/dist/formula/functions/asin.js +38 -24
- package/dist/formula/functions/asin.js.map +1 -1
- package/dist/formula/functions/atan.js +36 -22
- package/dist/formula/functions/atan.js.map +1 -1
- package/dist/formula/functions/atan2.js +42 -28
- package/dist/formula/functions/atan2.js.map +1 -1
- package/dist/formula/functions/average.js +50 -36
- package/dist/formula/functions/average.js.map +1 -1
- package/dist/formula/functions/col.js +38 -24
- package/dist/formula/functions/col.js.map +1 -1
- package/dist/formula/functions/concat.js +37 -23
- package/dist/formula/functions/concat.js.map +1 -1
- package/dist/formula/functions/concatenate.js +35 -21
- package/dist/formula/functions/concatenate.js.map +1 -1
- package/dist/formula/functions/cos.js +36 -22
- package/dist/formula/functions/cos.js.map +1 -1
- package/dist/formula/functions/count.js +45 -31
- package/dist/formula/functions/count.js.map +1 -1
- package/dist/formula/functions/counta.js +45 -31
- package/dist/formula/functions/counta.js.map +1 -1
- package/dist/formula/functions/countif.js +40 -26
- package/dist/formula/functions/countif.js.map +1 -1
- package/dist/formula/functions/divide.js +42 -28
- package/dist/formula/functions/divide.js.map +1 -1
- package/dist/formula/functions/eq.js +35 -21
- package/dist/formula/functions/eq.js.map +1 -1
- package/dist/formula/functions/exp.js +38 -24
- package/dist/formula/functions/exp.js.map +1 -1
- package/dist/formula/functions/gt.js +37 -23
- package/dist/formula/functions/gt.js.map +1 -1
- package/dist/formula/functions/gte.js +37 -23
- package/dist/formula/functions/gte.js.map +1 -1
- package/dist/formula/functions/hlookup.js +77 -63
- package/dist/formula/functions/hlookup.js.map +1 -1
- package/dist/formula/functions/if.js +46 -32
- package/dist/formula/functions/if.js.map +1 -1
- package/dist/formula/functions/iferror.js +48 -34
- package/dist/formula/functions/iferror.js.map +1 -1
- package/dist/formula/functions/iferror.spec.js +63 -51
- package/dist/formula/functions/iferror.spec.js.map +1 -1
- package/dist/formula/functions/len.js +36 -22
- package/dist/formula/functions/len.js.map +1 -1
- package/dist/formula/functions/lenb.js +36 -22
- package/dist/formula/functions/lenb.js.map +1 -1
- package/dist/formula/functions/ln.js +38 -24
- package/dist/formula/functions/ln.js.map +1 -1
- package/dist/formula/functions/log.js +43 -29
- package/dist/formula/functions/log.js.map +1 -1
- package/dist/formula/functions/log10.js +38 -24
- package/dist/formula/functions/log10.js.map +1 -1
- package/dist/formula/functions/lt.js +37 -23
- package/dist/formula/functions/lt.js.map +1 -1
- package/dist/formula/functions/lte.js +37 -23
- package/dist/formula/functions/lte.js.map +1 -1
- package/dist/formula/functions/max.js +52 -38
- package/dist/formula/functions/max.js.map +1 -1
- package/dist/formula/functions/min.js +52 -38
- package/dist/formula/functions/min.js.map +1 -1
- package/dist/formula/functions/minus.js +57 -43
- package/dist/formula/functions/minus.js.map +1 -1
- package/dist/formula/functions/mod.js +40 -26
- package/dist/formula/functions/mod.js.map +1 -1
- package/dist/formula/functions/mod.spec.js +58 -46
- package/dist/formula/functions/mod.spec.js.map +1 -1
- package/dist/formula/functions/multiply.js +37 -23
- package/dist/formula/functions/multiply.js.map +1 -1
- package/dist/formula/functions/ne.js +35 -21
- package/dist/formula/functions/ne.js.map +1 -1
- package/dist/formula/functions/not.js +40 -26
- package/dist/formula/functions/not.js.map +1 -1
- package/dist/formula/functions/now.js +31 -17
- package/dist/formula/functions/now.js.map +1 -1
- package/dist/formula/functions/or.js +38 -24
- package/dist/formula/functions/or.js.map +1 -1
- package/dist/formula/functions/pi.js +29 -15
- package/dist/formula/functions/pi.js.map +1 -1
- package/dist/formula/functions/power.js +34 -20
- package/dist/formula/functions/power.js.map +1 -1
- package/dist/formula/functions/product.js +47 -33
- package/dist/formula/functions/product.js.map +1 -1
- package/dist/formula/functions/radians.js +36 -22
- package/dist/formula/functions/radians.js.map +1 -1
- package/dist/formula/functions/rand.js +29 -15
- package/dist/formula/functions/rand.js.map +1 -1
- package/dist/formula/functions/round.js +44 -30
- package/dist/formula/functions/round.js.map +1 -1
- package/dist/formula/functions/rounddown.js +44 -30
- package/dist/formula/functions/rounddown.js.map +1 -1
- package/dist/formula/functions/roundup.js +44 -30
- package/dist/formula/functions/roundup.js.map +1 -1
- package/dist/formula/functions/row.js +38 -24
- package/dist/formula/functions/row.js.map +1 -1
- package/dist/formula/functions/sin.js +36 -22
- package/dist/formula/functions/sin.js.map +1 -1
- package/dist/formula/functions/sqrt.js +38 -24
- package/dist/formula/functions/sqrt.js.map +1 -1
- package/dist/formula/functions/sum.js +52 -38
- package/dist/formula/functions/sum.js.map +1 -1
- package/dist/formula/functions/sum.spec.js +45 -33
- package/dist/formula/functions/sum.spec.js.map +1 -1
- package/dist/formula/functions/sumif.js +66 -52
- package/dist/formula/functions/sumif.js.map +1 -1
- package/dist/formula/functions/tan.js +36 -22
- package/dist/formula/functions/tan.js.map +1 -1
- package/dist/formula/functions/uminus.js +33 -19
- package/dist/formula/functions/uminus.js.map +1 -1
- package/dist/formula/functions/vlookup.js +77 -63
- package/dist/formula/functions/vlookup.js.map +1 -1
- package/dist/formula/mapping.js +126 -113
- package/dist/formula/mapping.js.map +1 -1
- package/dist/formula/solver.js +71 -56
- package/dist/formula/solver.js.map +1 -1
- package/dist/index.js +41 -10
- package/dist/index.js.map +1 -1
- package/dist/lib/autofill.js +344 -330
- package/dist/lib/autofill.js.map +1 -1
- package/dist/lib/clipboard.js +55 -41
- package/dist/lib/clipboard.js.map +1 -1
- package/dist/lib/converters.js +140 -119
- package/dist/lib/converters.js.map +1 -1
- package/dist/lib/structs.js +266 -228
- package/dist/lib/structs.js.map +1 -1
- package/dist/lib/table.js +915 -900
- package/dist/lib/table.js.map +1 -1
- package/dist/lib/time.js +69 -55
- package/dist/lib/time.js.map +1 -1
- package/dist/lib/virtualization.js +121 -104
- package/dist/lib/virtualization.js.map +1 -1
- package/dist/parsers/core.js +119 -105
- package/dist/parsers/core.js.map +1 -1
- package/dist/renderers/checkbox.js +24 -8
- package/dist/renderers/checkbox.js.map +1 -1
- package/dist/renderers/core.js +139 -125
- package/dist/renderers/core.js.map +1 -1
- package/dist/renderers/thousand_separator.js +25 -12
- package/dist/renderers/thousand_separator.js.map +1 -1
- package/dist/store/actions.js +495 -480
- package/dist/store/actions.js.map +1 -1
- package/dist/store/helpers.js +88 -72
- package/dist/store/helpers.js.map +1 -1
- package/dist/store/index.js +38 -2
- package/dist/store/index.js.map +1 -1
- package/dist/styles/embedder.js +27 -13
- package/dist/styles/embedder.js.map +1 -1
- package/dist/styles/minified.js +16 -3
- package/dist/styles/minified.js.map +1 -1
- package/dist/types.js +12 -1
- package/dist/utils.js +19 -5
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/lib/table.js
CHANGED
|
@@ -1,299 +1,251 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "../parsers/core", "../renderers/core", "./structs", "./converters", "../formula/mapping", "../formula/evaluator", "../formula/solver", "../constants", "../store/helpers"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ReadonlyTable = exports.Table = void 0;
|
|
13
|
+
const core_1 = require("../parsers/core");
|
|
14
|
+
const core_2 = require("../renderers/core");
|
|
15
|
+
const structs_1 = require("./structs");
|
|
16
|
+
const converters_1 = require("./converters");
|
|
17
|
+
const mapping_1 = require("../formula/mapping");
|
|
18
|
+
const evaluator_1 = require("../formula/evaluator");
|
|
19
|
+
const solver_1 = require("../formula/solver");
|
|
20
|
+
const constants_1 = require("../constants");
|
|
21
|
+
const helpers_1 = require("../store/helpers");
|
|
22
|
+
const cellFilter = (cell) => true;
|
|
23
|
+
class Table {
|
|
24
|
+
constructor({ numRows = 0, numCols = 0, cells = {}, parsers = {}, renderers = {}, labelers = {}, useBigInt = false, historyLimit: historyLimit = constants_1.HISTORY_LIMIT, minNumRows = 1, maxNumRows = -1, minNumCols = 1, maxNumCols = -1, headerWidth = -1, headerHeight = -1, functions = mapping_1.functions, }) {
|
|
25
|
+
this.totalWidth = 0;
|
|
26
|
+
this.totalHeight = 0;
|
|
27
|
+
this.headerWidth = 0;
|
|
28
|
+
this.headerHeight = 0;
|
|
29
|
+
this.functions = {};
|
|
30
|
+
this.head = useBigInt ? BigInt(0) : 0;
|
|
31
|
+
this.data = {};
|
|
32
|
+
this.area = { top: 0, left: 0, bottom: numRows, right: numCols };
|
|
33
|
+
this.parsers = parsers;
|
|
34
|
+
this.renderers = renderers;
|
|
35
|
+
this.labelers = labelers;
|
|
36
|
+
this.idMatrix = [];
|
|
37
|
+
this.histories = [];
|
|
38
|
+
this.historyIndex = -1;
|
|
39
|
+
this.addressesById = {};
|
|
40
|
+
this.historyLimit = historyLimit;
|
|
41
|
+
this.changedAt = new Date();
|
|
42
|
+
this.minNumRows = minNumRows;
|
|
43
|
+
this.maxNumRows = maxNumRows;
|
|
44
|
+
this.minNumCols = minNumCols;
|
|
45
|
+
this.maxNumCols = maxNumCols;
|
|
46
|
+
this.solvedCaches = {};
|
|
47
|
+
this.headerHeight = headerHeight;
|
|
48
|
+
this.headerWidth = headerWidth;
|
|
49
|
+
this.functions = functions;
|
|
50
|
+
const common = cells.default;
|
|
51
|
+
// make idMatrix beforehand
|
|
52
|
+
for (let y = 0; y < numRows + 1; y++) {
|
|
53
|
+
const ids = [];
|
|
54
|
+
this.idMatrix.push(ids);
|
|
55
|
+
for (let x = 0; x < numCols + 1; x++) {
|
|
56
|
+
const id = this.generateId();
|
|
57
|
+
ids.push(id);
|
|
58
|
+
const address = (0, converters_1.p2a)({ y, x });
|
|
59
|
+
this.addressesById[id] = address;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (let y = 0; y < numRows + 1; y++) {
|
|
63
|
+
const rowId = (0, converters_1.y2r)(y);
|
|
64
|
+
const rowDefault = cells[rowId];
|
|
65
|
+
for (let x = 0; x < numCols + 1; x++) {
|
|
66
|
+
const id = this.getId({ y, x });
|
|
67
|
+
const address = (0, converters_1.p2a)({ y, x });
|
|
68
|
+
const colId = (0, converters_1.x2c)(x);
|
|
69
|
+
const colDefault = cells[colId];
|
|
70
|
+
const cell = cells[address];
|
|
71
|
+
const stacked = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, common), rowDefault), colDefault), cell), { style: Object.assign(Object.assign(Object.assign(Object.assign({}, common === null || common === void 0 ? void 0 : common.style), rowDefault === null || rowDefault === void 0 ? void 0 : rowDefault.style), colDefault === null || colDefault === void 0 ? void 0 : colDefault.style), cell === null || cell === void 0 ? void 0 : cell.style) });
|
|
72
|
+
stacked.value = (0, evaluator_1.convertFormulaAbsolute)({
|
|
73
|
+
value: stacked === null || stacked === void 0 ? void 0 : stacked.value,
|
|
74
|
+
table: this,
|
|
75
|
+
});
|
|
76
|
+
if (y === 0) {
|
|
77
|
+
if (stacked.width == null) {
|
|
78
|
+
stacked.width = constants_1.DEFAULT_WIDTH;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (x === 0) {
|
|
82
|
+
if (stacked.height == null) {
|
|
83
|
+
stacked.height = constants_1.DEFAULT_HEIGHT;
|
|
84
|
+
}
|
|
67
85
|
}
|
|
86
|
+
else {
|
|
87
|
+
delete stacked.height;
|
|
88
|
+
delete stacked.width;
|
|
89
|
+
delete stacked.labeler;
|
|
90
|
+
}
|
|
91
|
+
this.data[id] = stacked;
|
|
68
92
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
93
|
+
}
|
|
94
|
+
this.setTotalSize();
|
|
95
|
+
}
|
|
96
|
+
generateId() {
|
|
97
|
+
return (this.head++).toString(36);
|
|
98
|
+
}
|
|
99
|
+
getRectSize({ top, left, bottom, right }) {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
let width = 0, height = 0;
|
|
102
|
+
for (let x = left || 1; x < right; x++) {
|
|
103
|
+
width += ((_a = this.getByPoint({ y: 0, x })) === null || _a === void 0 ? void 0 : _a.width) || constants_1.DEFAULT_WIDTH;
|
|
104
|
+
}
|
|
105
|
+
for (let y = top || 1; y < bottom; y++) {
|
|
106
|
+
height += ((_b = this.getByPoint({ y, x: 0 })) === null || _b === void 0 ? void 0 : _b.height) || constants_1.DEFAULT_HEIGHT;
|
|
107
|
+
}
|
|
108
|
+
return { width, height };
|
|
109
|
+
}
|
|
110
|
+
setTotalSize() {
|
|
111
|
+
const { bottom, right } = this.area;
|
|
112
|
+
const { width, height } = this.getRectSize({ top: 1, left: 1, bottom: bottom + 1, right: right + 1 });
|
|
113
|
+
this.totalWidth = width + this.headerWidth;
|
|
114
|
+
this.totalHeight = height + this.headerHeight;
|
|
115
|
+
}
|
|
116
|
+
shallowCopy({ copyCache = true } = {}) {
|
|
117
|
+
const copied = new Table({});
|
|
118
|
+
copied.changedAt = new Date();
|
|
119
|
+
copied.lastChangedAt = this.changedAt;
|
|
120
|
+
copied.head = this.head;
|
|
121
|
+
copied.idMatrix = this.idMatrix;
|
|
122
|
+
copied.data = this.data;
|
|
123
|
+
copied.area = this.area;
|
|
124
|
+
copied.parsers = this.parsers;
|
|
125
|
+
copied.renderers = this.renderers;
|
|
126
|
+
copied.labelers = this.labelers;
|
|
127
|
+
copied.functions = this.functions;
|
|
128
|
+
copied.histories = this.histories;
|
|
129
|
+
copied.historyLimit = this.historyLimit;
|
|
130
|
+
copied.historyIndex = this.historyIndex;
|
|
131
|
+
copied.minNumRows = this.minNumRows;
|
|
132
|
+
copied.maxNumRows = this.maxNumRows;
|
|
133
|
+
copied.minNumCols = this.minNumCols;
|
|
134
|
+
copied.maxNumCols = this.maxNumCols;
|
|
135
|
+
copied.headerHeight = this.headerHeight;
|
|
136
|
+
copied.headerWidth = this.headerWidth;
|
|
137
|
+
copied.setTotalSize();
|
|
138
|
+
if (copyCache) {
|
|
139
|
+
copied.addressesById = this.addressesById;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
// force reset
|
|
143
|
+
this.addressesById = {};
|
|
144
|
+
}
|
|
145
|
+
return copied;
|
|
146
|
+
}
|
|
147
|
+
getAddressById(id, slideY = 0, slideX = 0) {
|
|
148
|
+
const absCol = id.startsWith("$");
|
|
149
|
+
if (absCol) {
|
|
150
|
+
id = id.slice(1);
|
|
151
|
+
slideX = 0;
|
|
152
|
+
}
|
|
153
|
+
const absRow = id.endsWith("$");
|
|
154
|
+
if (absRow) {
|
|
155
|
+
id = id.slice(0, -1);
|
|
156
|
+
slideY = 0;
|
|
157
|
+
}
|
|
158
|
+
for (let y = 0; y < this.idMatrix.length; y++) {
|
|
159
|
+
const ids = this.idMatrix[y];
|
|
160
|
+
for (let x = 0; x < ids.length; x++) {
|
|
161
|
+
const existing = ids[x];
|
|
162
|
+
const address = (0, converters_1.p2a)({ y, x });
|
|
163
|
+
this.addressesById[existing] = address;
|
|
164
|
+
if (existing === id) {
|
|
165
|
+
const slidedAddress = (0, converters_1.p2a)({
|
|
166
|
+
y: y + slideY,
|
|
167
|
+
x: x + slideX,
|
|
168
|
+
});
|
|
169
|
+
return (0, converters_1.grantAddressAbsolute)(slidedAddress, absCol, absRow);
|
|
72
170
|
}
|
|
73
171
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
getAddressesByIds(ids) {
|
|
175
|
+
const addresses = {};
|
|
176
|
+
Object.keys(ids).forEach((id) => {
|
|
177
|
+
const cell = ids[id];
|
|
178
|
+
const address = this.getAddressById(id);
|
|
179
|
+
if (cell && address) {
|
|
180
|
+
addresses[address] = cell;
|
|
78
181
|
}
|
|
79
|
-
|
|
182
|
+
});
|
|
183
|
+
return addresses;
|
|
184
|
+
}
|
|
185
|
+
getPointById(id) {
|
|
186
|
+
const address = this.getAddressById(id);
|
|
187
|
+
if (address) {
|
|
188
|
+
return (0, converters_1.a2p)(address);
|
|
80
189
|
}
|
|
190
|
+
return { y: 0, x: 0 };
|
|
81
191
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
getRectSize({ top, left, bottom, right }) {
|
|
88
|
-
var _a, _b;
|
|
89
|
-
let width = 0, height = 0;
|
|
90
|
-
for (let x = left || 1; x < right; x++) {
|
|
91
|
-
width += ((_a = this.getByPoint({ y: 0, x })) === null || _a === void 0 ? void 0 : _a.width) || DEFAULT_WIDTH;
|
|
192
|
+
getId(point) {
|
|
193
|
+
var _a;
|
|
194
|
+
const { y, x } = point;
|
|
195
|
+
return (_a = this.idMatrix[y]) === null || _a === void 0 ? void 0 : _a[x];
|
|
92
196
|
}
|
|
93
|
-
|
|
94
|
-
|
|
197
|
+
getByPoint(point) {
|
|
198
|
+
var _a;
|
|
199
|
+
const { y, x } = point;
|
|
200
|
+
if (y === -1 || x === -1) {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
const id = (_a = this.idMatrix[y]) === null || _a === void 0 ? void 0 : _a[x];
|
|
204
|
+
if (id == null) {
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
const value = this.data[id];
|
|
208
|
+
return value;
|
|
95
209
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
setTotalSize() {
|
|
99
|
-
const { bottom, right } = this.area;
|
|
100
|
-
const { width, height } = this.getRectSize({ top: 1, left: 1, bottom: bottom + 1, right: right + 1 });
|
|
101
|
-
this.totalWidth = width + this.headerWidth;
|
|
102
|
-
this.totalHeight = height + this.headerHeight;
|
|
103
|
-
}
|
|
104
|
-
shallowCopy({ copyCache = true } = {}) {
|
|
105
|
-
const copied = new Table({});
|
|
106
|
-
copied.changedAt = new Date();
|
|
107
|
-
copied.lastChangedAt = this.changedAt;
|
|
108
|
-
copied.head = this.head;
|
|
109
|
-
copied.idMatrix = this.idMatrix;
|
|
110
|
-
copied.data = this.data;
|
|
111
|
-
copied.area = this.area;
|
|
112
|
-
copied.parsers = this.parsers;
|
|
113
|
-
copied.renderers = this.renderers;
|
|
114
|
-
copied.labelers = this.labelers;
|
|
115
|
-
copied.functions = this.functions;
|
|
116
|
-
copied.histories = this.histories;
|
|
117
|
-
copied.historyLimit = this.historyLimit;
|
|
118
|
-
copied.historyIndex = this.historyIndex;
|
|
119
|
-
copied.minNumRows = this.minNumRows;
|
|
120
|
-
copied.maxNumRows = this.maxNumRows;
|
|
121
|
-
copied.minNumCols = this.minNumCols;
|
|
122
|
-
copied.maxNumCols = this.maxNumCols;
|
|
123
|
-
copied.headerHeight = this.headerHeight;
|
|
124
|
-
copied.headerWidth = this.headerWidth;
|
|
125
|
-
copied.setTotalSize();
|
|
126
|
-
if (copyCache) {
|
|
127
|
-
copied.addressesById = this.addressesById;
|
|
210
|
+
getById(id) {
|
|
211
|
+
return this.data[id];
|
|
128
212
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
213
|
+
getNumRows(base = 0) {
|
|
214
|
+
const { top, left, bottom, right } = this.area;
|
|
215
|
+
return base + bottom - top;
|
|
132
216
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const absCol = id.startsWith("$");
|
|
137
|
-
if (absCol) {
|
|
138
|
-
id = id.slice(1);
|
|
139
|
-
slideX = 0;
|
|
140
|
-
}
|
|
141
|
-
const absRow = id.endsWith("$");
|
|
142
|
-
if (absRow) {
|
|
143
|
-
id = id.slice(0, -1);
|
|
144
|
-
slideY = 0;
|
|
145
|
-
}
|
|
146
|
-
for (let y = 0; y < this.idMatrix.length; y++) {
|
|
147
|
-
const ids = this.idMatrix[y];
|
|
148
|
-
for (let x = 0; x < ids.length; x++) {
|
|
149
|
-
const existing = ids[x];
|
|
150
|
-
const address = p2a({ y, x });
|
|
151
|
-
this.addressesById[existing] = address;
|
|
152
|
-
if (existing === id) {
|
|
153
|
-
const slidedAddress = p2a({
|
|
154
|
-
y: y + slideY,
|
|
155
|
-
x: x + slideX,
|
|
156
|
-
});
|
|
157
|
-
return grantAddressAbsolute(slidedAddress, absCol, absRow);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
217
|
+
getNumCols(base = 0) {
|
|
218
|
+
const { top, left, bottom, right } = this.area;
|
|
219
|
+
return base + right - left;
|
|
160
220
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const addresses = {};
|
|
164
|
-
Object.keys(ids).forEach((id) => {
|
|
165
|
-
const cell = ids[id];
|
|
166
|
-
const address = this.getAddressById(id);
|
|
167
|
-
if (cell && address) {
|
|
168
|
-
addresses[address] = cell;
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
return addresses;
|
|
172
|
-
}
|
|
173
|
-
getPointById(id) {
|
|
174
|
-
const address = this.getAddressById(id);
|
|
175
|
-
if (address) {
|
|
176
|
-
return a2p(address);
|
|
221
|
+
get top() {
|
|
222
|
+
return this.area.top;
|
|
177
223
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
getId(point) {
|
|
181
|
-
var _a;
|
|
182
|
-
const { y, x } = point;
|
|
183
|
-
return (_a = this.idMatrix[y]) === null || _a === void 0 ? void 0 : _a[x];
|
|
184
|
-
}
|
|
185
|
-
getByPoint(point) {
|
|
186
|
-
var _a;
|
|
187
|
-
const { y, x } = point;
|
|
188
|
-
if (y === -1 || x === -1) {
|
|
189
|
-
return undefined;
|
|
190
|
-
}
|
|
191
|
-
const id = (_a = this.idMatrix[y]) === null || _a === void 0 ? void 0 : _a[x];
|
|
192
|
-
if (id == null) {
|
|
193
|
-
return undefined;
|
|
194
|
-
}
|
|
195
|
-
const value = this.data[id];
|
|
196
|
-
return value;
|
|
197
|
-
}
|
|
198
|
-
getById(id) {
|
|
199
|
-
return this.data[id];
|
|
200
|
-
}
|
|
201
|
-
getNumRows(base = 0) {
|
|
202
|
-
const { top, left, bottom, right } = this.area;
|
|
203
|
-
return base + bottom - top;
|
|
204
|
-
}
|
|
205
|
-
getNumCols(base = 0) {
|
|
206
|
-
const { top, left, bottom, right } = this.area;
|
|
207
|
-
return base + right - left;
|
|
208
|
-
}
|
|
209
|
-
get top() {
|
|
210
|
-
return this.area.top;
|
|
211
|
-
}
|
|
212
|
-
get left() {
|
|
213
|
-
return this.area.left;
|
|
214
|
-
}
|
|
215
|
-
get bottom() {
|
|
216
|
-
return this.area.bottom;
|
|
217
|
-
}
|
|
218
|
-
get right() {
|
|
219
|
-
return this.area.right;
|
|
220
|
-
}
|
|
221
|
-
getMatrixFlatten({ area, key = "value", evaluates = true, raise = false, filter = cellFilter, } = {}) {
|
|
222
|
-
const { top, left, bottom, right } = area || {
|
|
223
|
-
top: 1,
|
|
224
|
-
left: 1,
|
|
225
|
-
bottom: this.area.bottom,
|
|
226
|
-
right: this.area.right,
|
|
227
|
-
};
|
|
228
|
-
const matrix = createMatrix(bottom - top + 1, right - left + 1);
|
|
229
|
-
for (let y = top; y <= bottom; y++) {
|
|
230
|
-
for (let x = left; x <= right; x++) {
|
|
231
|
-
const cell = this.getByPoint({ y, x }) || {};
|
|
232
|
-
if (!filter(cell)) {
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
matrix[y - top][x - left] = evaluates
|
|
236
|
-
? solveFormula({
|
|
237
|
-
value: cell[key],
|
|
238
|
-
table: this,
|
|
239
|
-
raise,
|
|
240
|
-
})
|
|
241
|
-
: cell[key];
|
|
242
|
-
}
|
|
224
|
+
get left() {
|
|
225
|
+
return this.area.left;
|
|
243
226
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
getObjectFlatten({ key = "value", evaluates = true, raise = false, filter = cellFilter, } = {}) {
|
|
247
|
-
const result = {};
|
|
248
|
-
const { top, left, bottom, right } = this.area;
|
|
249
|
-
for (let y = top; y <= bottom; y++) {
|
|
250
|
-
for (let x = left; x <= right; x++) {
|
|
251
|
-
const cell = this.getByPoint({ y: y - top, x: x - left });
|
|
252
|
-
if (cell != null && filter(cell)) {
|
|
253
|
-
result[p2a({ y, x })] = evaluates
|
|
254
|
-
? solveFormula({
|
|
255
|
-
value: cell[key],
|
|
256
|
-
table: this,
|
|
257
|
-
raise,
|
|
258
|
-
})
|
|
259
|
-
: cell[key];
|
|
260
|
-
}
|
|
261
|
-
}
|
|
227
|
+
get bottom() {
|
|
228
|
+
return this.area.bottom;
|
|
262
229
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
getRowsFlatten({ key = "value", evaluates = true, raise = false, filter = cellFilter, } = {}) {
|
|
266
|
-
const result = [];
|
|
267
|
-
const { top, left, bottom, right } = this.area;
|
|
268
|
-
for (let y = top; y <= bottom; y++) {
|
|
269
|
-
const row = {};
|
|
270
|
-
result.push(row);
|
|
271
|
-
for (let x = left; x <= right; x++) {
|
|
272
|
-
const cell = this.getByPoint({ y: y - top, x: x - left });
|
|
273
|
-
if (cell != null && filter(cell)) {
|
|
274
|
-
row[x2c(x) || y2r(y)] = evaluates
|
|
275
|
-
? solveFormula({
|
|
276
|
-
value: cell[key],
|
|
277
|
-
table: this,
|
|
278
|
-
raise,
|
|
279
|
-
})
|
|
280
|
-
: cell[key];
|
|
281
|
-
}
|
|
282
|
-
}
|
|
230
|
+
get right() {
|
|
231
|
+
return this.area.right;
|
|
283
232
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
233
|
+
getMatrixFlatten({ area, key = "value", evaluates = true, raise = false, filter = cellFilter, } = {}) {
|
|
234
|
+
const { top, left, bottom, right } = area || {
|
|
235
|
+
top: 1,
|
|
236
|
+
left: 1,
|
|
237
|
+
bottom: this.area.bottom,
|
|
238
|
+
right: this.area.right,
|
|
239
|
+
};
|
|
240
|
+
const matrix = (0, structs_1.createMatrix)(bottom - top + 1, right - left + 1);
|
|
292
241
|
for (let y = top; y <= bottom; y++) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
242
|
+
for (let x = left; x <= right; x++) {
|
|
243
|
+
const cell = this.getByPoint({ y, x }) || {};
|
|
244
|
+
if (!filter(cell)) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
matrix[y - top][x - left] = evaluates
|
|
248
|
+
? (0, solver_1.solveFormula)({
|
|
297
249
|
value: cell[key],
|
|
298
250
|
table: this,
|
|
299
251
|
raise,
|
|
@@ -301,689 +253,752 @@ export class Table {
|
|
|
301
253
|
: cell[key];
|
|
302
254
|
}
|
|
303
255
|
}
|
|
256
|
+
return matrix;
|
|
304
257
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
for (let y = top; y <= bottom; y++) {
|
|
316
|
-
for (let x = left; x <= right; x++) {
|
|
317
|
-
const cell = this.getByPoint({ y, x });
|
|
318
|
-
if (cell != null && filter(cell)) {
|
|
319
|
-
matrix[y - top][x - left] = Object.assign(Object.assign({}, cell), { value: evaluates
|
|
320
|
-
? solveFormula({
|
|
321
|
-
value: cell === null || cell === void 0 ? void 0 : cell.value,
|
|
258
|
+
getObjectFlatten({ key = "value", evaluates = true, raise = false, filter = cellFilter, } = {}) {
|
|
259
|
+
const result = {};
|
|
260
|
+
const { top, left, bottom, right } = this.area;
|
|
261
|
+
for (let y = top; y <= bottom; y++) {
|
|
262
|
+
for (let x = left; x <= right; x++) {
|
|
263
|
+
const cell = this.getByPoint({ y: y - top, x: x - left });
|
|
264
|
+
if (cell != null && filter(cell)) {
|
|
265
|
+
result[(0, converters_1.p2a)({ y, x })] = evaluates
|
|
266
|
+
? (0, solver_1.solveFormula)({
|
|
267
|
+
value: cell[key],
|
|
322
268
|
table: this,
|
|
323
269
|
raise,
|
|
324
270
|
})
|
|
325
|
-
: cell
|
|
271
|
+
: cell[key];
|
|
272
|
+
}
|
|
326
273
|
}
|
|
327
274
|
}
|
|
275
|
+
return result;
|
|
328
276
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
? solveFormula({
|
|
340
|
-
value: cell
|
|
277
|
+
getRowsFlatten({ key = "value", evaluates = true, raise = false, filter = cellFilter, } = {}) {
|
|
278
|
+
const result = [];
|
|
279
|
+
const { top, left, bottom, right } = this.area;
|
|
280
|
+
for (let y = top; y <= bottom; y++) {
|
|
281
|
+
const row = {};
|
|
282
|
+
result.push(row);
|
|
283
|
+
for (let x = left; x <= right; x++) {
|
|
284
|
+
const cell = this.getByPoint({ y: y - top, x: x - left });
|
|
285
|
+
if (cell != null && filter(cell)) {
|
|
286
|
+
row[(0, converters_1.x2c)(x) || (0, converters_1.y2r)(y)] = evaluates
|
|
287
|
+
? (0, solver_1.solveFormula)({
|
|
288
|
+
value: cell[key],
|
|
341
289
|
table: this,
|
|
342
290
|
raise,
|
|
343
291
|
})
|
|
344
|
-
: cell
|
|
292
|
+
: cell[key];
|
|
293
|
+
}
|
|
345
294
|
}
|
|
346
295
|
}
|
|
296
|
+
return result;
|
|
347
297
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
const result = [];
|
|
352
|
-
const { top, left, bottom, right } = this.area;
|
|
353
|
-
for (let y = top; y <= bottom; y++) {
|
|
354
|
-
const row = {};
|
|
355
|
-
result.push(row);
|
|
298
|
+
getColsFlatten({ key = "value", evaluates = true, raise = false, filter = cellFilter, } = {}) {
|
|
299
|
+
const result = [];
|
|
300
|
+
const { top, left, bottom, right } = this.area;
|
|
356
301
|
for (let x = left; x <= right; x++) {
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
302
|
+
const col = {};
|
|
303
|
+
result.push(col);
|
|
304
|
+
for (let y = top; y <= bottom; y++) {
|
|
305
|
+
const cell = this.getByPoint({ y: y - top, x: x - left });
|
|
306
|
+
if (cell != null && filter(cell)) {
|
|
307
|
+
col[(0, converters_1.y2r)(y) || (0, converters_1.x2c)(x)] = evaluates
|
|
308
|
+
? (0, solver_1.solveFormula)({
|
|
309
|
+
value: cell[key],
|
|
362
310
|
table: this,
|
|
363
311
|
raise,
|
|
364
312
|
})
|
|
365
|
-
: cell
|
|
313
|
+
: cell[key];
|
|
314
|
+
}
|
|
366
315
|
}
|
|
367
316
|
}
|
|
317
|
+
return result;
|
|
368
318
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
319
|
+
getMatrix({ area, evaluates = true, raise = false, filter = cellFilter, } = {}) {
|
|
320
|
+
const { top, left, bottom, right } = area || {
|
|
321
|
+
top: 1,
|
|
322
|
+
left: 1,
|
|
323
|
+
bottom: this.area.bottom,
|
|
324
|
+
right: this.area.right,
|
|
325
|
+
};
|
|
326
|
+
const matrix = (0, structs_1.createMatrix)(bottom - top + 1, right - left + 1);
|
|
377
327
|
for (let y = top; y <= bottom; y++) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
328
|
+
for (let x = left; x <= right; x++) {
|
|
329
|
+
const cell = this.getByPoint({ y, x });
|
|
330
|
+
if (cell != null && filter(cell)) {
|
|
331
|
+
matrix[y - top][x - left] = Object.assign(Object.assign({}, cell), { value: evaluates
|
|
332
|
+
? (0, solver_1.solveFormula)({
|
|
333
|
+
value: cell === null || cell === void 0 ? void 0 : cell.value,
|
|
334
|
+
table: this,
|
|
335
|
+
raise,
|
|
336
|
+
})
|
|
337
|
+
: cell === null || cell === void 0 ? void 0 : cell.value });
|
|
338
|
+
}
|
|
387
339
|
}
|
|
388
340
|
}
|
|
341
|
+
return matrix;
|
|
389
342
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
history.idMatrix.forEach((ids) => {
|
|
409
|
-
ids.forEach((id) => {
|
|
410
|
-
delete this.data[id];
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
if (history.operation === "MOVE") {
|
|
415
|
-
Object.keys(history.lostRows).forEach((address) => {
|
|
416
|
-
const idMatrix = history.lostRows[address];
|
|
417
|
-
idMatrix.map((ids) => ids.forEach((id) => {
|
|
418
|
-
delete this.data[id];
|
|
419
|
-
}));
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
cleanStrayed(history) {
|
|
424
|
-
if (history.operation === "ADD_ROWS" || history.operation === "ADD_COLS") {
|
|
425
|
-
history.idMatrix.forEach((ids) => {
|
|
426
|
-
ids.forEach((id) => {
|
|
427
|
-
delete this.data[id];
|
|
428
|
-
});
|
|
429
|
-
});
|
|
343
|
+
getObject({ evaluates = true, raise = false, filter = cellFilter, } = {}) {
|
|
344
|
+
const result = {};
|
|
345
|
+
const { top, left, bottom, right } = this.area;
|
|
346
|
+
for (let y = top; y <= bottom; y++) {
|
|
347
|
+
for (let x = left; x <= right; x++) {
|
|
348
|
+
const cell = this.getByPoint({ y: y - top, x: x - left });
|
|
349
|
+
if (cell != null && filter(cell)) {
|
|
350
|
+
result[(0, converters_1.p2a)({ y, x })] = Object.assign(Object.assign({}, cell), { value: evaluates
|
|
351
|
+
? (0, solver_1.solveFormula)({
|
|
352
|
+
value: cell === null || cell === void 0 ? void 0 : cell.value,
|
|
353
|
+
table: this,
|
|
354
|
+
raise,
|
|
355
|
+
})
|
|
356
|
+
: cell === null || cell === void 0 ? void 0 : cell.value });
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return result;
|
|
430
361
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
362
|
+
getRows({ evaluates = true, raise = false, filter = cellFilter, } = {}) {
|
|
363
|
+
const result = [];
|
|
364
|
+
const { top, left, bottom, right } = this.area;
|
|
365
|
+
for (let y = top; y <= bottom; y++) {
|
|
366
|
+
const row = {};
|
|
367
|
+
result.push(row);
|
|
368
|
+
for (let x = left; x <= right; x++) {
|
|
369
|
+
const cell = this.getByPoint({ y: y - top, x: x - left });
|
|
370
|
+
if (cell != null && filter(cell)) {
|
|
371
|
+
row[(0, converters_1.x2c)(x) || (0, converters_1.y2r)(y)] = Object.assign(Object.assign({}, cell), { value: evaluates
|
|
372
|
+
? (0, solver_1.solveFormula)({
|
|
373
|
+
value: cell === null || cell === void 0 ? void 0 : cell.value,
|
|
374
|
+
table: this,
|
|
375
|
+
raise,
|
|
376
|
+
})
|
|
377
|
+
: cell === null || cell === void 0 ? void 0 : cell.value });
|
|
378
|
+
}
|
|
379
|
+
}
|
|
440
380
|
}
|
|
381
|
+
return result;
|
|
441
382
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
var _a;
|
|
446
|
-
const matrix = [];
|
|
447
|
-
const { top, left, bottom, right } = area;
|
|
448
|
-
for (let y = top; y <= bottom; y++) {
|
|
449
|
-
const ids = [];
|
|
450
|
-
matrix.push(ids);
|
|
383
|
+
getCols({ evaluates = true, raise = false, filter = cellFilter, } = {}) {
|
|
384
|
+
const result = [];
|
|
385
|
+
const { top, left, bottom, right } = this.area;
|
|
451
386
|
for (let x = left; x <= right; x++) {
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
387
|
+
const col = {};
|
|
388
|
+
result.push(col);
|
|
389
|
+
for (let y = top; y <= bottom; y++) {
|
|
390
|
+
const cell = this.getByPoint({ y: y - top, x: x - left });
|
|
391
|
+
if (cell != null && filter(cell)) {
|
|
392
|
+
col[(0, converters_1.y2r)(y) || (0, converters_1.x2c)(x)] = Object.assign(Object.assign({}, cell), { value: evaluates
|
|
393
|
+
? (0, solver_1.solveFormula)({
|
|
394
|
+
value: cell === null || cell === void 0 ? void 0 : cell.value,
|
|
395
|
+
table: this,
|
|
396
|
+
raise,
|
|
397
|
+
})
|
|
398
|
+
: cell === null || cell === void 0 ? void 0 : cell.value });
|
|
399
|
+
}
|
|
455
400
|
}
|
|
456
401
|
}
|
|
402
|
+
return result;
|
|
457
403
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
const newCell = {};
|
|
472
|
-
if (cell.style != null) {
|
|
473
|
-
newCell.style = cell.style;
|
|
474
|
-
}
|
|
475
|
-
if (cell.justifyContent != null) {
|
|
476
|
-
newCell.justifyContent = cell.justifyContent;
|
|
404
|
+
pushHistory(history) {
|
|
405
|
+
const strayedHistories = this.histories.splice(this.historyIndex + 1, this.histories.length);
|
|
406
|
+
strayedHistories.forEach(this.cleanStrayed.bind(this));
|
|
407
|
+
this.histories.push(history);
|
|
408
|
+
this.lastHistory = history;
|
|
409
|
+
if (this.histories.length > this.historyLimit) {
|
|
410
|
+
const kickedOut = this.histories.splice(0, 1)[0];
|
|
411
|
+
this.cleanObsolete(kickedOut);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
this.historyIndex++;
|
|
415
|
+
}
|
|
477
416
|
}
|
|
478
|
-
|
|
479
|
-
|
|
417
|
+
cleanObsolete(history) {
|
|
418
|
+
if (history.operation === "REMOVE_ROWS" ||
|
|
419
|
+
history.operation === "REMOVE_COLS") {
|
|
420
|
+
history.idMatrix.forEach((ids) => {
|
|
421
|
+
ids.forEach((id) => {
|
|
422
|
+
delete this.data[id];
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
if (history.operation === "MOVE") {
|
|
427
|
+
Object.keys(history.lostRows).forEach((address) => {
|
|
428
|
+
const idMatrix = history.lostRows[address];
|
|
429
|
+
idMatrix.map((ids) => ids.forEach((id) => {
|
|
430
|
+
delete this.data[id];
|
|
431
|
+
}));
|
|
432
|
+
});
|
|
433
|
+
}
|
|
480
434
|
}
|
|
481
|
-
|
|
482
|
-
|
|
435
|
+
cleanStrayed(history) {
|
|
436
|
+
if (history.operation === "ADD_ROWS" || history.operation === "ADD_COLS") {
|
|
437
|
+
history.idMatrix.forEach((ids) => {
|
|
438
|
+
ids.forEach((id) => {
|
|
439
|
+
delete this.data[id];
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
}
|
|
483
443
|
}
|
|
484
|
-
|
|
485
|
-
|
|
444
|
+
getNewIdMatrix(area) {
|
|
445
|
+
const matrix = [];
|
|
446
|
+
const { top, left, bottom, right } = area;
|
|
447
|
+
for (let y = top; y <= bottom; y++) {
|
|
448
|
+
const ids = [];
|
|
449
|
+
matrix.push(ids);
|
|
450
|
+
for (let x = left; x <= right; x++) {
|
|
451
|
+
ids.push(this.generateId());
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return matrix;
|
|
486
455
|
}
|
|
487
|
-
|
|
488
|
-
|
|
456
|
+
getIdMatrixFromArea(area) {
|
|
457
|
+
var _a;
|
|
458
|
+
const matrix = [];
|
|
459
|
+
const { top, left, bottom, right } = area;
|
|
460
|
+
for (let y = top; y <= bottom; y++) {
|
|
461
|
+
const ids = [];
|
|
462
|
+
matrix.push(ids);
|
|
463
|
+
for (let x = left; x <= right; x++) {
|
|
464
|
+
const id = (_a = this.idMatrix[y]) === null || _a === void 0 ? void 0 : _a[x];
|
|
465
|
+
if (id) {
|
|
466
|
+
ids.push(id);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return matrix;
|
|
489
471
|
}
|
|
490
|
-
|
|
491
|
-
|
|
472
|
+
setChangedAt(cell, changedAt) {
|
|
473
|
+
if (cell == null) {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
cell.changedAt = changedAt || new Date();
|
|
477
|
+
return cell;
|
|
492
478
|
}
|
|
493
|
-
|
|
494
|
-
|
|
479
|
+
copyCellLayout(cell) {
|
|
480
|
+
if (cell == null) {
|
|
481
|
+
return undefined;
|
|
482
|
+
}
|
|
483
|
+
const newCell = {};
|
|
484
|
+
if (cell.style != null) {
|
|
485
|
+
newCell.style = cell.style;
|
|
486
|
+
}
|
|
487
|
+
if (cell.justifyContent != null) {
|
|
488
|
+
newCell.justifyContent = cell.justifyContent;
|
|
489
|
+
}
|
|
490
|
+
if (cell.alignItems != null) {
|
|
491
|
+
newCell.alignItems = cell.alignItems;
|
|
492
|
+
}
|
|
493
|
+
if (cell.renderer != null) {
|
|
494
|
+
newCell.renderer = cell.renderer;
|
|
495
|
+
}
|
|
496
|
+
if (cell.parser != null) {
|
|
497
|
+
newCell.parser = cell.parser;
|
|
498
|
+
}
|
|
499
|
+
if (cell.width != null) {
|
|
500
|
+
newCell.width = cell.width;
|
|
501
|
+
}
|
|
502
|
+
if (cell.height != null) {
|
|
503
|
+
newCell.height = cell.height;
|
|
504
|
+
}
|
|
505
|
+
if (cell.labeler != null) {
|
|
506
|
+
newCell.labeler = cell.labeler;
|
|
507
|
+
}
|
|
508
|
+
return newCell;
|
|
495
509
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
const toY = topTo + i;
|
|
531
|
-
if (toY > this.getNumRows()) {
|
|
532
|
-
continue;
|
|
533
|
-
}
|
|
534
|
-
for (let j = 0; j <= rightTo - leftTo; j++) {
|
|
535
|
-
const toX = leftTo + j;
|
|
536
|
-
if (toX > this.getNumCols()) {
|
|
510
|
+
move({ src, dst, reflection = {}, }) {
|
|
511
|
+
const changedAt = new Date();
|
|
512
|
+
const matrixFrom = this.getIdMatrixFromArea(src);
|
|
513
|
+
const matrixTo = this.getIdMatrixFromArea(dst);
|
|
514
|
+
const matrixNew = this.getNewIdMatrix(src);
|
|
515
|
+
(0, structs_1.putMatrix)(this.idMatrix, matrixNew, src);
|
|
516
|
+
matrixFrom.forEach((ids) => {
|
|
517
|
+
ids
|
|
518
|
+
.map(this.getById.bind(this))
|
|
519
|
+
.filter((c) => c)
|
|
520
|
+
.forEach((cell) => this.setChangedAt(cell, changedAt));
|
|
521
|
+
});
|
|
522
|
+
const lostRows = (0, structs_1.putMatrix)(this.idMatrix, matrixFrom, dst);
|
|
523
|
+
this.pushHistory({
|
|
524
|
+
operation: "MOVE",
|
|
525
|
+
reflection,
|
|
526
|
+
matrixFrom,
|
|
527
|
+
matrixTo,
|
|
528
|
+
matrixNew,
|
|
529
|
+
pointFrom: { y: src.top, x: src.left },
|
|
530
|
+
pointTo: { y: dst.top, x: dst.left },
|
|
531
|
+
lostRows,
|
|
532
|
+
});
|
|
533
|
+
return this.shallowCopy({ copyCache: false });
|
|
534
|
+
}
|
|
535
|
+
copy({ src, dst, reflection = {}, }) {
|
|
536
|
+
const { height: maxHeight, width: maxWidth } = (0, structs_1.areaShape)(Object.assign(Object.assign({}, src), { base: 1 }));
|
|
537
|
+
const { top: topFrom, left: leftFrom } = src;
|
|
538
|
+
const { top: topTo, left: leftTo, bottom: bottomTo, right: rightTo } = dst;
|
|
539
|
+
const diff = {};
|
|
540
|
+
const changedAt = new Date();
|
|
541
|
+
for (let i = 0; i <= bottomTo - topTo; i++) {
|
|
542
|
+
const toY = topTo + i;
|
|
543
|
+
if (toY > this.getNumRows()) {
|
|
537
544
|
continue;
|
|
538
545
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
546
|
+
for (let j = 0; j <= rightTo - leftTo; j++) {
|
|
547
|
+
const toX = leftTo + j;
|
|
548
|
+
if (toX > this.getNumCols()) {
|
|
549
|
+
continue;
|
|
550
|
+
}
|
|
551
|
+
const fromY = topFrom + (i % maxHeight);
|
|
552
|
+
const fromX = leftFrom + (j % maxWidth);
|
|
553
|
+
const slideY = toY - fromY;
|
|
554
|
+
const slideX = toX - fromX;
|
|
555
|
+
const cell = Object.assign({}, this.getByPoint({
|
|
556
|
+
y: topFrom + (i % maxHeight),
|
|
557
|
+
x: leftFrom + (j % maxWidth),
|
|
558
|
+
}));
|
|
559
|
+
const value = (0, evaluator_1.convertFormulaAbsolute)({
|
|
560
|
+
value: cell === null || cell === void 0 ? void 0 : cell.value,
|
|
561
|
+
table: this,
|
|
562
|
+
slideY,
|
|
563
|
+
slideX,
|
|
564
|
+
});
|
|
565
|
+
this.setChangedAt(cell, changedAt);
|
|
566
|
+
diff[(0, converters_1.p2a)({ y: toY, x: toX })] = Object.assign(Object.assign({}, cell), { style: Object.assign({}, cell === null || cell === void 0 ? void 0 : cell.style), value });
|
|
567
|
+
}
|
|
555
568
|
}
|
|
569
|
+
return this.update({ diff, partial: false, reflection });
|
|
556
570
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
+
_update({ diff, partial = true, updateChangedAt = true, }) {
|
|
572
|
+
const diffBefore = {};
|
|
573
|
+
const diffAfter = {};
|
|
574
|
+
const changedAt = new Date();
|
|
575
|
+
Object.keys(diff).forEach((address) => {
|
|
576
|
+
const cell = Object.assign({}, diff[address]);
|
|
577
|
+
if (updateChangedAt) {
|
|
578
|
+
this.setChangedAt(cell, changedAt);
|
|
579
|
+
}
|
|
580
|
+
cell.value = (0, evaluator_1.convertFormulaAbsolute)({
|
|
581
|
+
value: cell.value,
|
|
582
|
+
table: this,
|
|
583
|
+
});
|
|
584
|
+
const point = (0, converters_1.a2p)(address);
|
|
585
|
+
const id = this.getId(point);
|
|
586
|
+
// must not partial
|
|
587
|
+
diffBefore[id] = this.getByPoint(point);
|
|
588
|
+
diffAfter[id] = cell;
|
|
589
|
+
if (partial) {
|
|
590
|
+
this.data[id] = Object.assign(Object.assign({}, this.data[id]), cell);
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
this.data[id] = cell;
|
|
594
|
+
}
|
|
571
595
|
});
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
diffBefore,
|
|
600
|
-
diffAfter,
|
|
601
|
-
partial,
|
|
602
|
-
});
|
|
603
|
-
return this.shallowCopy({ copyCache: true });
|
|
604
|
-
}
|
|
605
|
-
writeMatrix({ point, matrix, updateChangedAt = true, reflection = {}, }) {
|
|
606
|
-
const { y: baseY, x: baseX } = point;
|
|
607
|
-
const diff = {};
|
|
608
|
-
matrix.forEach((cols, i) => {
|
|
609
|
-
const y = baseY + i;
|
|
610
|
-
if (y > this.bottom) {
|
|
611
|
-
return;
|
|
612
|
-
}
|
|
613
|
-
cols.forEach((value, j) => {
|
|
614
|
-
const x = baseX + j;
|
|
615
|
-
if (x > this.right) {
|
|
596
|
+
this.solvedCaches = {};
|
|
597
|
+
return {
|
|
598
|
+
diffBefore,
|
|
599
|
+
diffAfter,
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
update({ diff, partial = true, updateChangedAt = true, reflection = {}, }) {
|
|
603
|
+
const { diffBefore, diffAfter } = this._update({
|
|
604
|
+
diff,
|
|
605
|
+
partial,
|
|
606
|
+
updateChangedAt,
|
|
607
|
+
});
|
|
608
|
+
this.pushHistory({
|
|
609
|
+
operation: "UPDATE",
|
|
610
|
+
reflection,
|
|
611
|
+
diffBefore,
|
|
612
|
+
diffAfter,
|
|
613
|
+
partial,
|
|
614
|
+
});
|
|
615
|
+
return this.shallowCopy({ copyCache: true });
|
|
616
|
+
}
|
|
617
|
+
writeMatrix({ point, matrix, updateChangedAt = true, reflection = {}, }) {
|
|
618
|
+
const { y: baseY, x: baseX } = point;
|
|
619
|
+
const diff = {};
|
|
620
|
+
matrix.forEach((cols, i) => {
|
|
621
|
+
const y = baseY + i;
|
|
622
|
+
if (y > this.bottom) {
|
|
616
623
|
return;
|
|
617
624
|
}
|
|
618
|
-
|
|
619
|
-
|
|
625
|
+
cols.forEach((value, j) => {
|
|
626
|
+
const x = baseX + j;
|
|
627
|
+
if (x > this.right) {
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
const cell = this.parse({ y, x }, value);
|
|
631
|
+
diff[(0, converters_1.p2a)({ y, x })] = cell;
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
return this.update({
|
|
635
|
+
diff,
|
|
636
|
+
partial: true,
|
|
637
|
+
updateChangedAt,
|
|
638
|
+
reflection,
|
|
620
639
|
});
|
|
621
|
-
});
|
|
622
|
-
return this.update({
|
|
623
|
-
diff,
|
|
624
|
-
partial: true,
|
|
625
|
-
updateChangedAt,
|
|
626
|
-
reflection,
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
write({ point, value, updateChangedAt = true, reflection = {}, }) {
|
|
630
|
-
return this.writeMatrix({
|
|
631
|
-
point,
|
|
632
|
-
matrix: [[value]],
|
|
633
|
-
updateChangedAt,
|
|
634
|
-
reflection,
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
addRowsAndUpdate({ y, numRows, baseY, diff, partial, updateChangedAt, reflection = {}, }) {
|
|
638
|
-
const returned = this.addRows({
|
|
639
|
-
y,
|
|
640
|
-
numRows,
|
|
641
|
-
baseY,
|
|
642
|
-
reflection,
|
|
643
|
-
});
|
|
644
|
-
Object.assign(this.lastHistory, this._update({ diff, partial, updateChangedAt }), { partial });
|
|
645
|
-
return returned;
|
|
646
|
-
}
|
|
647
|
-
addRows({ y, numRows, baseY, reflection = {}, }) {
|
|
648
|
-
if (this.maxNumRows !== -1 &&
|
|
649
|
-
this.getNumRows() + numRows > this.maxNumRows) {
|
|
650
|
-
console.error(`Rows are limited to ${this.maxNumRows}.`);
|
|
651
|
-
return this;
|
|
652
640
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
row.push(id);
|
|
661
|
-
const cell = this.getByPoint({ y: baseY, x: j });
|
|
662
|
-
const copied = this.copyCellLayout(cell);
|
|
663
|
-
this.data[id] = Object.assign(Object.assign({}, copied), { changedAt });
|
|
664
|
-
}
|
|
665
|
-
rows.push(row);
|
|
666
|
-
}
|
|
667
|
-
this.idMatrix.splice(y, 0, ...rows);
|
|
668
|
-
this.area.bottom += numRows;
|
|
669
|
-
this.pushHistory({
|
|
670
|
-
operation: "ADD_ROWS",
|
|
671
|
-
reflection,
|
|
672
|
-
y,
|
|
673
|
-
idMatrix: rows,
|
|
674
|
-
});
|
|
675
|
-
return this.shallowCopy({ copyCache: false });
|
|
676
|
-
}
|
|
677
|
-
removeRows({ y, numRows, reflection = {}, }) {
|
|
678
|
-
if (this.minNumRows !== -1 &&
|
|
679
|
-
this.getNumRows() - numRows < this.minNumRows) {
|
|
680
|
-
console.error(`At least ${this.minNumRows} row(s) are required.`);
|
|
681
|
-
return this;
|
|
641
|
+
write({ point, value, updateChangedAt = true, reflection = {}, }) {
|
|
642
|
+
return this.writeMatrix({
|
|
643
|
+
point,
|
|
644
|
+
matrix: [[value]],
|
|
645
|
+
updateChangedAt,
|
|
646
|
+
reflection,
|
|
647
|
+
});
|
|
682
648
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
649
|
+
addRowsAndUpdate({ y, numRows, baseY, diff, partial, updateChangedAt, reflection = {}, }) {
|
|
650
|
+
const returned = this.addRows({
|
|
651
|
+
y,
|
|
652
|
+
numRows,
|
|
653
|
+
baseY,
|
|
654
|
+
reflection,
|
|
655
|
+
});
|
|
656
|
+
Object.assign(this.lastHistory, this._update({ diff, partial, updateChangedAt }), { partial });
|
|
657
|
+
return returned;
|
|
658
|
+
}
|
|
659
|
+
addRows({ y, numRows, baseY, reflection = {}, }) {
|
|
660
|
+
if (this.maxNumRows !== -1 &&
|
|
661
|
+
this.getNumRows() + numRows > this.maxNumRows) {
|
|
662
|
+
console.error(`Rows are limited to ${this.maxNumRows}.`);
|
|
663
|
+
return this;
|
|
664
|
+
}
|
|
665
|
+
const numCols = this.getNumCols(1);
|
|
666
|
+
const rows = [];
|
|
667
|
+
const changedAt = new Date();
|
|
668
|
+
for (let i = 0; i < numRows; i++) {
|
|
669
|
+
const row = [];
|
|
670
|
+
for (let j = 0; j < numCols; j++) {
|
|
671
|
+
const id = this.generateId();
|
|
672
|
+
row.push(id);
|
|
673
|
+
const cell = this.getByPoint({ y: baseY, x: j });
|
|
674
|
+
const copied = this.copyCellLayout(cell);
|
|
675
|
+
this.data[id] = Object.assign(Object.assign({}, copied), { changedAt });
|
|
676
|
+
}
|
|
677
|
+
rows.push(row);
|
|
678
|
+
}
|
|
679
|
+
this.idMatrix.splice(y, 0, ...rows);
|
|
680
|
+
this.area.bottom += numRows;
|
|
681
|
+
this.pushHistory({
|
|
682
|
+
operation: "ADD_ROWS",
|
|
683
|
+
reflection,
|
|
684
|
+
y,
|
|
685
|
+
idMatrix: rows,
|
|
686
|
+
});
|
|
687
|
+
return this.shallowCopy({ copyCache: false });
|
|
688
|
+
}
|
|
689
|
+
removeRows({ y, numRows, reflection = {}, }) {
|
|
690
|
+
if (this.minNumRows !== -1 &&
|
|
691
|
+
this.getNumRows() - numRows < this.minNumRows) {
|
|
692
|
+
console.error(`At least ${this.minNumRows} row(s) are required.`);
|
|
693
|
+
return this;
|
|
694
|
+
}
|
|
695
|
+
const rows = this.idMatrix.splice(y, numRows);
|
|
696
|
+
this.area.bottom -= numRows;
|
|
697
|
+
this.pushHistory({
|
|
698
|
+
operation: "REMOVE_ROWS",
|
|
699
|
+
reflection,
|
|
700
|
+
y,
|
|
701
|
+
idMatrix: rows,
|
|
702
|
+
});
|
|
703
|
+
return this.shallowCopy({ copyCache: false });
|
|
704
|
+
}
|
|
705
|
+
addColsAndUpdate({ x, numCols, baseX, diff, partial, updateChangedAt, reflection = {}, }) {
|
|
706
|
+
const returned = this.addCols({
|
|
707
|
+
x,
|
|
708
|
+
numCols,
|
|
709
|
+
baseX,
|
|
710
|
+
reflection,
|
|
711
|
+
});
|
|
712
|
+
Object.assign(this.lastHistory, this._update({ diff, partial, updateChangedAt }), { partial });
|
|
713
|
+
return returned;
|
|
714
|
+
}
|
|
715
|
+
addCols({ x, numCols, baseX, reflection = {}, }) {
|
|
716
|
+
if (this.maxNumCols !== -1 &&
|
|
717
|
+
this.getNumCols() + numCols > this.maxNumCols) {
|
|
718
|
+
console.error(`Columns are limited to ${this.maxNumCols}.`);
|
|
719
|
+
return this;
|
|
720
|
+
}
|
|
721
|
+
const numRows = this.getNumRows(1);
|
|
722
|
+
const rows = [];
|
|
723
|
+
const changedAt = new Date();
|
|
724
|
+
for (let i = 0; i < numRows; i++) {
|
|
725
|
+
const row = [];
|
|
726
|
+
for (let j = 0; j < numCols; j++) {
|
|
727
|
+
const id = this.generateId();
|
|
728
|
+
row.push(id);
|
|
729
|
+
const cell = this.getByPoint({ y: i, x: baseX });
|
|
730
|
+
const copied = this.copyCellLayout(cell);
|
|
731
|
+
this.idMatrix[i].splice(x, 0, id);
|
|
732
|
+
this.data[id] = Object.assign(Object.assign({}, copied), { changedAt });
|
|
733
|
+
}
|
|
734
|
+
rows.push(row);
|
|
735
|
+
}
|
|
736
|
+
this.area.right += numCols;
|
|
737
|
+
this.pushHistory({
|
|
738
|
+
operation: "ADD_COLS",
|
|
739
|
+
reflection,
|
|
740
|
+
x,
|
|
741
|
+
idMatrix: rows,
|
|
742
|
+
});
|
|
743
|
+
return this.shallowCopy({ copyCache: false });
|
|
744
|
+
}
|
|
745
|
+
removeCols({ x, numCols, reflection = {}, }) {
|
|
746
|
+
if (this.minNumCols !== -1 &&
|
|
747
|
+
this.getNumCols() - numCols < this.minNumCols) {
|
|
748
|
+
console.error(`At least ${this.minNumCols} column(s) are required.`);
|
|
749
|
+
return this;
|
|
750
|
+
}
|
|
751
|
+
const rows = [];
|
|
752
|
+
this.idMatrix.forEach((row) => {
|
|
753
|
+
const deleted = row.splice(x, numCols);
|
|
754
|
+
rows.push(deleted);
|
|
755
|
+
});
|
|
756
|
+
this.area.right -= numCols;
|
|
757
|
+
this.pushHistory({
|
|
758
|
+
operation: "REMOVE_COLS",
|
|
759
|
+
reflection,
|
|
760
|
+
x,
|
|
761
|
+
idMatrix: rows,
|
|
762
|
+
});
|
|
763
|
+
return this.shallowCopy({ copyCache: false });
|
|
708
764
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
const changedAt = new Date();
|
|
712
|
-
for (let i = 0; i < numRows; i++) {
|
|
713
|
-
const row = [];
|
|
714
|
-
for (let j = 0; j < numCols; j++) {
|
|
715
|
-
const id = this.generateId();
|
|
716
|
-
row.push(id);
|
|
717
|
-
const cell = this.getByPoint({ y: i, x: baseX });
|
|
718
|
-
const copied = this.copyCellLayout(cell);
|
|
719
|
-
this.idMatrix[i].splice(x, 0, id);
|
|
720
|
-
this.data[id] = Object.assign(Object.assign({}, copied), { changedAt });
|
|
721
|
-
}
|
|
722
|
-
rows.push(row);
|
|
723
|
-
}
|
|
724
|
-
this.area.right += numCols;
|
|
725
|
-
this.pushHistory({
|
|
726
|
-
operation: "ADD_COLS",
|
|
727
|
-
reflection,
|
|
728
|
-
x,
|
|
729
|
-
idMatrix: rows,
|
|
730
|
-
});
|
|
731
|
-
return this.shallowCopy({ copyCache: false });
|
|
732
|
-
}
|
|
733
|
-
removeCols({ x, numCols, reflection = {}, }) {
|
|
734
|
-
if (this.minNumCols !== -1 &&
|
|
735
|
-
this.getNumCols() - numCols < this.minNumCols) {
|
|
736
|
-
console.error(`At least ${this.minNumCols} column(s) are required.`);
|
|
737
|
-
return this;
|
|
765
|
+
getHistories() {
|
|
766
|
+
return [...this.histories];
|
|
738
767
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
const deleted = row.splice(x, numCols);
|
|
742
|
-
rows.push(deleted);
|
|
743
|
-
});
|
|
744
|
-
this.area.right -= numCols;
|
|
745
|
-
this.pushHistory({
|
|
746
|
-
operation: "REMOVE_COLS",
|
|
747
|
-
reflection,
|
|
748
|
-
x,
|
|
749
|
-
idMatrix: rows,
|
|
750
|
-
});
|
|
751
|
-
return this.shallowCopy({ copyCache: false });
|
|
752
|
-
}
|
|
753
|
-
getHistories() {
|
|
754
|
-
return [...this.histories];
|
|
755
|
-
}
|
|
756
|
-
getHistoryIndex() {
|
|
757
|
-
return this.historyIndex;
|
|
758
|
-
}
|
|
759
|
-
getHistorySize() {
|
|
760
|
-
return this.histories.length;
|
|
761
|
-
}
|
|
762
|
-
getHistoryLimit() {
|
|
763
|
-
return this.historyLimit;
|
|
764
|
-
}
|
|
765
|
-
setFunctions(additionalFunctions) {
|
|
766
|
-
this.functions = Object.assign(Object.assign({}, functionsDefault), additionalFunctions);
|
|
767
|
-
}
|
|
768
|
-
getArea() {
|
|
769
|
-
return Object.assign({}, this.area);
|
|
770
|
-
}
|
|
771
|
-
parse(point, value) {
|
|
772
|
-
const cell = this.getByPoint(point) || {};
|
|
773
|
-
const parser = this.parsers[cell.parser || ""] || defaultParser;
|
|
774
|
-
return parser.call(value, cell);
|
|
775
|
-
}
|
|
776
|
-
render(point, writer) {
|
|
777
|
-
const cell = this.getByPoint(point) || {};
|
|
778
|
-
const renderer = this.renderers[cell.renderer || ""] || defaultRenderer;
|
|
779
|
-
return renderer.call(this, point, writer);
|
|
780
|
-
}
|
|
781
|
-
stringify(point, value, evaluates = false) {
|
|
782
|
-
const cell = this.getByPoint(point);
|
|
783
|
-
const renderer = this.renderers[(cell === null || cell === void 0 ? void 0 : cell.renderer) || ""] || defaultRenderer;
|
|
784
|
-
const s = renderer.stringify(typeof value === "undefined" ? Object.assign({}, cell) : Object.assign(Object.assign({}, cell), { value }));
|
|
785
|
-
if (s[0] === "=") {
|
|
786
|
-
if (evaluates) {
|
|
787
|
-
return String(solveFormula({ value: s, table: this, raise: false }));
|
|
788
|
-
}
|
|
789
|
-
const lexer = new Lexer(s.substring(1));
|
|
790
|
-
lexer.tokenize();
|
|
791
|
-
return "=" + lexer.stringifyToRef(this);
|
|
792
|
-
}
|
|
793
|
-
return s;
|
|
794
|
-
}
|
|
795
|
-
trim(area) {
|
|
796
|
-
const copied = new Table({});
|
|
797
|
-
copied.area = area;
|
|
798
|
-
copied.idMatrix = this.idMatrix;
|
|
799
|
-
copied.data = this.data;
|
|
800
|
-
copied.parsers = this.parsers;
|
|
801
|
-
copied.renderers = this.renderers;
|
|
802
|
-
copied.labelers = this.labelers;
|
|
803
|
-
copied.functions = this.functions;
|
|
804
|
-
copied.addressesById = this.addressesById;
|
|
805
|
-
copied.solvedCaches = this.solvedCaches;
|
|
806
|
-
return copied;
|
|
807
|
-
}
|
|
808
|
-
getIdByAddress(address) {
|
|
809
|
-
const { y, x } = a2p(address);
|
|
810
|
-
const id = this.getId({ y: Math.abs(y), x: Math.abs(x) });
|
|
811
|
-
if (id) {
|
|
812
|
-
return `#${x < 0 ? "$" : ""}${id}${y < 0 ? "$" : ""}`;
|
|
768
|
+
getHistoryIndex() {
|
|
769
|
+
return this.historyIndex;
|
|
813
770
|
}
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
return;
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
771
|
+
getHistorySize() {
|
|
772
|
+
return this.histories.length;
|
|
773
|
+
}
|
|
774
|
+
getHistoryLimit() {
|
|
775
|
+
return this.historyLimit;
|
|
776
|
+
}
|
|
777
|
+
setFunctions(additionalFunctions) {
|
|
778
|
+
this.functions = Object.assign(Object.assign({}, mapping_1.functions), additionalFunctions);
|
|
779
|
+
}
|
|
780
|
+
getArea() {
|
|
781
|
+
return Object.assign({}, this.area);
|
|
782
|
+
}
|
|
783
|
+
parse(point, value) {
|
|
784
|
+
const cell = this.getByPoint(point) || {};
|
|
785
|
+
const parser = this.parsers[cell.parser || ""] || core_1.defaultParser;
|
|
786
|
+
return parser.call(value, cell);
|
|
787
|
+
}
|
|
788
|
+
render(point, writer) {
|
|
789
|
+
const cell = this.getByPoint(point) || {};
|
|
790
|
+
const renderer = this.renderers[cell.renderer || ""] || core_2.defaultRenderer;
|
|
791
|
+
return renderer.call(this, point, writer);
|
|
792
|
+
}
|
|
793
|
+
stringify(point, value, evaluates = false) {
|
|
794
|
+
const cell = this.getByPoint(point);
|
|
795
|
+
const renderer = this.renderers[(cell === null || cell === void 0 ? void 0 : cell.renderer) || ""] || core_2.defaultRenderer;
|
|
796
|
+
const s = renderer.stringify(typeof value === "undefined" ? Object.assign({}, cell) : Object.assign(Object.assign({}, cell), { value }));
|
|
797
|
+
if (s[0] === "=") {
|
|
798
|
+
if (evaluates) {
|
|
799
|
+
return String((0, solver_1.solveFormula)({ value: s, table: this, raise: false }));
|
|
838
800
|
}
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
801
|
+
const lexer = new evaluator_1.Lexer(s.substring(1));
|
|
802
|
+
lexer.tokenize();
|
|
803
|
+
return "=" + lexer.stringifyToRef(this);
|
|
804
|
+
}
|
|
805
|
+
return s;
|
|
806
|
+
}
|
|
807
|
+
trim(area) {
|
|
808
|
+
const copied = new Table({});
|
|
809
|
+
copied.area = area;
|
|
810
|
+
copied.idMatrix = this.idMatrix;
|
|
811
|
+
copied.data = this.data;
|
|
812
|
+
copied.parsers = this.parsers;
|
|
813
|
+
copied.renderers = this.renderers;
|
|
814
|
+
copied.labelers = this.labelers;
|
|
815
|
+
copied.functions = this.functions;
|
|
816
|
+
copied.addressesById = this.addressesById;
|
|
817
|
+
copied.solvedCaches = this.solvedCaches;
|
|
818
|
+
return copied;
|
|
819
|
+
}
|
|
820
|
+
getIdByAddress(address) {
|
|
821
|
+
const { y, x } = (0, converters_1.a2p)(address);
|
|
822
|
+
const id = this.getId({ y: Math.abs(y), x: Math.abs(x) });
|
|
823
|
+
if (id) {
|
|
824
|
+
return `#${x < 0 ? "$" : ""}${id}${y < 0 ? "$" : ""}`;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
applyDiff(diff, partial = true) {
|
|
828
|
+
if (!partial) {
|
|
829
|
+
Object.assign(this.data, diff);
|
|
830
|
+
return;
|
|
843
831
|
}
|
|
844
|
-
|
|
845
|
-
|
|
832
|
+
Object.keys(diff).map((id) => {
|
|
833
|
+
const cell = diff[id];
|
|
834
|
+
this.data[id] = Object.assign(Object.assign({}, this.getById(id)), cell);
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
undo() {
|
|
838
|
+
if (this.historyIndex < 0) {
|
|
839
|
+
return { history: null, newTable: this };
|
|
840
|
+
}
|
|
841
|
+
const history = this.histories[this.historyIndex--];
|
|
842
|
+
switch (history.operation) {
|
|
843
|
+
case "UPDATE":
|
|
844
|
+
// diffBefore is guaranteed as total of cell (not partial)
|
|
846
845
|
this.applyDiff(history.diffBefore, false);
|
|
846
|
+
break;
|
|
847
|
+
case "ADD_ROWS": {
|
|
848
|
+
if (history.diffBefore) {
|
|
849
|
+
this.applyDiff(history.diffBefore, false);
|
|
850
|
+
}
|
|
851
|
+
const { height } = (0, structs_1.matrixShape)({ matrix: history.idMatrix });
|
|
852
|
+
this.idMatrix.splice(history.y, height);
|
|
853
|
+
this.area.bottom -= height;
|
|
854
|
+
break;
|
|
855
|
+
}
|
|
856
|
+
case "ADD_COLS": {
|
|
857
|
+
if (history.diffBefore) {
|
|
858
|
+
this.applyDiff(history.diffBefore, false);
|
|
859
|
+
}
|
|
860
|
+
const { width } = (0, structs_1.matrixShape)({ matrix: history.idMatrix });
|
|
861
|
+
this.idMatrix.forEach((row) => {
|
|
862
|
+
row.splice(history.x, width);
|
|
863
|
+
});
|
|
864
|
+
this.area.right -= width;
|
|
865
|
+
break;
|
|
866
|
+
}
|
|
867
|
+
case "REMOVE_ROWS": {
|
|
868
|
+
const { height } = (0, structs_1.matrixShape)({ matrix: history.idMatrix });
|
|
869
|
+
this.idMatrix.splice(history.y, 0, ...history.idMatrix);
|
|
870
|
+
this.area.bottom += height;
|
|
871
|
+
break;
|
|
872
|
+
}
|
|
873
|
+
case "REMOVE_COLS": {
|
|
874
|
+
const { width } = (0, structs_1.matrixShape)({ matrix: history.idMatrix });
|
|
875
|
+
this.idMatrix.forEach((row, i) => {
|
|
876
|
+
row.splice(history.x, 0, ...history.idMatrix[i]);
|
|
877
|
+
});
|
|
878
|
+
this.area.right += width;
|
|
879
|
+
break;
|
|
880
|
+
}
|
|
881
|
+
case "MOVE": {
|
|
882
|
+
const { y: yFrom, x: xFrom } = history.pointFrom;
|
|
883
|
+
const { y: yTo, x: xTo } = history.pointTo;
|
|
884
|
+
const { height: rows, width: cols } = (0, structs_1.matrixShape)({
|
|
885
|
+
matrix: history.matrixFrom,
|
|
886
|
+
base: -1,
|
|
887
|
+
});
|
|
888
|
+
(0, structs_1.putMatrix)(this.idMatrix, history.matrixFrom, {
|
|
889
|
+
top: yFrom,
|
|
890
|
+
left: xFrom,
|
|
891
|
+
bottom: yFrom + rows,
|
|
892
|
+
right: xFrom + cols,
|
|
893
|
+
});
|
|
894
|
+
(0, structs_1.putMatrix)(this.idMatrix, history.matrixTo, {
|
|
895
|
+
top: yTo,
|
|
896
|
+
left: xTo,
|
|
897
|
+
bottom: yTo + rows,
|
|
898
|
+
right: xTo + cols,
|
|
899
|
+
});
|
|
900
|
+
break;
|
|
847
901
|
}
|
|
848
|
-
const { width } = matrixShape({ matrix: history.idMatrix });
|
|
849
|
-
this.idMatrix.forEach((row) => {
|
|
850
|
-
row.splice(history.x, width);
|
|
851
|
-
});
|
|
852
|
-
this.area.right -= width;
|
|
853
|
-
break;
|
|
854
|
-
}
|
|
855
|
-
case "REMOVE_ROWS": {
|
|
856
|
-
const { height } = matrixShape({ matrix: history.idMatrix });
|
|
857
|
-
this.idMatrix.splice(history.y, 0, ...history.idMatrix);
|
|
858
|
-
this.area.bottom += height;
|
|
859
|
-
break;
|
|
860
|
-
}
|
|
861
|
-
case "REMOVE_COLS": {
|
|
862
|
-
const { width } = matrixShape({ matrix: history.idMatrix });
|
|
863
|
-
this.idMatrix.forEach((row, i) => {
|
|
864
|
-
row.splice(history.x, 0, ...history.idMatrix[i]);
|
|
865
|
-
});
|
|
866
|
-
this.area.right += width;
|
|
867
|
-
break;
|
|
868
|
-
}
|
|
869
|
-
case "MOVE": {
|
|
870
|
-
const { y: yFrom, x: xFrom } = history.pointFrom;
|
|
871
|
-
const { y: yTo, x: xTo } = history.pointTo;
|
|
872
|
-
const { height: rows, width: cols } = matrixShape({
|
|
873
|
-
matrix: history.matrixFrom,
|
|
874
|
-
base: -1,
|
|
875
|
-
});
|
|
876
|
-
putMatrix(this.idMatrix, history.matrixFrom, {
|
|
877
|
-
top: yFrom,
|
|
878
|
-
left: xFrom,
|
|
879
|
-
bottom: yFrom + rows,
|
|
880
|
-
right: xFrom + cols,
|
|
881
|
-
});
|
|
882
|
-
putMatrix(this.idMatrix, history.matrixTo, {
|
|
883
|
-
top: yTo,
|
|
884
|
-
left: xTo,
|
|
885
|
-
bottom: yTo + rows,
|
|
886
|
-
right: xTo + cols,
|
|
887
|
-
});
|
|
888
|
-
break;
|
|
889
902
|
}
|
|
903
|
+
return {
|
|
904
|
+
history,
|
|
905
|
+
newTable: this.shallowCopy({
|
|
906
|
+
copyCache: !(0, helpers_1.shouldTracking)(history.operation),
|
|
907
|
+
}),
|
|
908
|
+
};
|
|
890
909
|
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
copyCache: !shouldTracking(history.operation),
|
|
895
|
-
}),
|
|
896
|
-
};
|
|
897
|
-
}
|
|
898
|
-
redo() {
|
|
899
|
-
if (this.historyIndex + 1 >= this.histories.length) {
|
|
900
|
-
return { history: null, newTable: this };
|
|
901
|
-
}
|
|
902
|
-
const history = this.histories[++this.historyIndex];
|
|
903
|
-
switch (history.operation) {
|
|
904
|
-
case "UPDATE":
|
|
905
|
-
this.applyDiff(history.diffAfter, history.partial);
|
|
906
|
-
break;
|
|
907
|
-
case "ADD_ROWS": {
|
|
908
|
-
if (history.diffAfter) {
|
|
909
|
-
this.applyDiff(history.diffAfter, history.partial);
|
|
910
|
-
}
|
|
911
|
-
const { height } = matrixShape({ matrix: history.idMatrix });
|
|
912
|
-
this.idMatrix.splice(history.y, 0, ...history.idMatrix);
|
|
913
|
-
this.area.bottom += height;
|
|
914
|
-
break;
|
|
910
|
+
redo() {
|
|
911
|
+
if (this.historyIndex + 1 >= this.histories.length) {
|
|
912
|
+
return { history: null, newTable: this };
|
|
915
913
|
}
|
|
916
|
-
|
|
917
|
-
|
|
914
|
+
const history = this.histories[++this.historyIndex];
|
|
915
|
+
switch (history.operation) {
|
|
916
|
+
case "UPDATE":
|
|
918
917
|
this.applyDiff(history.diffAfter, history.partial);
|
|
918
|
+
break;
|
|
919
|
+
case "ADD_ROWS": {
|
|
920
|
+
if (history.diffAfter) {
|
|
921
|
+
this.applyDiff(history.diffAfter, history.partial);
|
|
922
|
+
}
|
|
923
|
+
const { height } = (0, structs_1.matrixShape)({ matrix: history.idMatrix });
|
|
924
|
+
this.idMatrix.splice(history.y, 0, ...history.idMatrix);
|
|
925
|
+
this.area.bottom += height;
|
|
926
|
+
break;
|
|
927
|
+
}
|
|
928
|
+
case "ADD_COLS": {
|
|
929
|
+
if (history.diffAfter) {
|
|
930
|
+
this.applyDiff(history.diffAfter, history.partial);
|
|
931
|
+
}
|
|
932
|
+
const { width } = (0, structs_1.matrixShape)({ matrix: history.idMatrix });
|
|
933
|
+
this.idMatrix.map((row, i) => {
|
|
934
|
+
row.splice(history.x, 0, ...history.idMatrix[i]);
|
|
935
|
+
});
|
|
936
|
+
this.area.right += width;
|
|
937
|
+
break;
|
|
938
|
+
}
|
|
939
|
+
case "REMOVE_ROWS": {
|
|
940
|
+
const { height } = (0, structs_1.matrixShape)({ matrix: history.idMatrix });
|
|
941
|
+
this.idMatrix.splice(history.y, height);
|
|
942
|
+
this.area.bottom -= height;
|
|
943
|
+
break;
|
|
944
|
+
}
|
|
945
|
+
case "REMOVE_COLS": {
|
|
946
|
+
const { width } = (0, structs_1.matrixShape)({ matrix: history.idMatrix });
|
|
947
|
+
this.idMatrix.forEach((row) => {
|
|
948
|
+
row.splice(history.x, width);
|
|
949
|
+
});
|
|
950
|
+
this.area.right -= width;
|
|
951
|
+
break;
|
|
952
|
+
}
|
|
953
|
+
case "MOVE": {
|
|
954
|
+
const { y: yFrom, x: xFrom } = history.pointFrom;
|
|
955
|
+
const { y: yTo, x: xTo } = history.pointTo;
|
|
956
|
+
const { height: rows, width: cols } = (0, structs_1.matrixShape)({
|
|
957
|
+
matrix: history.matrixFrom,
|
|
958
|
+
base: -1,
|
|
959
|
+
});
|
|
960
|
+
(0, structs_1.putMatrix)(this.idMatrix, history.matrixNew, {
|
|
961
|
+
top: yFrom,
|
|
962
|
+
left: xFrom,
|
|
963
|
+
bottom: yFrom + rows,
|
|
964
|
+
right: xFrom + cols,
|
|
965
|
+
});
|
|
966
|
+
(0, structs_1.putMatrix)(this.idMatrix, history.matrixFrom, {
|
|
967
|
+
top: yTo,
|
|
968
|
+
left: xTo,
|
|
969
|
+
bottom: yTo + rows,
|
|
970
|
+
right: xTo + cols,
|
|
971
|
+
});
|
|
919
972
|
}
|
|
920
|
-
const { width } = matrixShape({ matrix: history.idMatrix });
|
|
921
|
-
this.idMatrix.map((row, i) => {
|
|
922
|
-
row.splice(history.x, 0, ...history.idMatrix[i]);
|
|
923
|
-
});
|
|
924
|
-
this.area.right += width;
|
|
925
|
-
break;
|
|
926
|
-
}
|
|
927
|
-
case "REMOVE_ROWS": {
|
|
928
|
-
const { height } = matrixShape({ matrix: history.idMatrix });
|
|
929
|
-
this.idMatrix.splice(history.y, height);
|
|
930
|
-
this.area.bottom -= height;
|
|
931
|
-
break;
|
|
932
|
-
}
|
|
933
|
-
case "REMOVE_COLS": {
|
|
934
|
-
const { width } = matrixShape({ matrix: history.idMatrix });
|
|
935
|
-
this.idMatrix.forEach((row) => {
|
|
936
|
-
row.splice(history.x, width);
|
|
937
|
-
});
|
|
938
|
-
this.area.right -= width;
|
|
939
|
-
break;
|
|
940
|
-
}
|
|
941
|
-
case "MOVE": {
|
|
942
|
-
const { y: yFrom, x: xFrom } = history.pointFrom;
|
|
943
|
-
const { y: yTo, x: xTo } = history.pointTo;
|
|
944
|
-
const { height: rows, width: cols } = matrixShape({
|
|
945
|
-
matrix: history.matrixFrom,
|
|
946
|
-
base: -1,
|
|
947
|
-
});
|
|
948
|
-
putMatrix(this.idMatrix, history.matrixNew, {
|
|
949
|
-
top: yFrom,
|
|
950
|
-
left: xFrom,
|
|
951
|
-
bottom: yFrom + rows,
|
|
952
|
-
right: xFrom + cols,
|
|
953
|
-
});
|
|
954
|
-
putMatrix(this.idMatrix, history.matrixFrom, {
|
|
955
|
-
top: yTo,
|
|
956
|
-
left: xTo,
|
|
957
|
-
bottom: yTo + rows,
|
|
958
|
-
right: xTo + cols,
|
|
959
|
-
});
|
|
960
973
|
}
|
|
974
|
+
return {
|
|
975
|
+
history,
|
|
976
|
+
newTable: this.shallowCopy({
|
|
977
|
+
copyCache: !(0, helpers_1.shouldTracking)(history.operation),
|
|
978
|
+
}),
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
getFunction(name) {
|
|
982
|
+
return this.functions[name];
|
|
983
|
+
}
|
|
984
|
+
getLabel(key, n) {
|
|
985
|
+
const labeler = this.labelers[key];
|
|
986
|
+
return labeler === null || labeler === void 0 ? void 0 : labeler(n);
|
|
987
|
+
}
|
|
988
|
+
getBase() {
|
|
989
|
+
return this;
|
|
990
|
+
}
|
|
991
|
+
getSolvedCache(key) {
|
|
992
|
+
return this.solvedCaches[key];
|
|
993
|
+
}
|
|
994
|
+
setSolvedCache(key, value) {
|
|
995
|
+
this.solvedCaches[key] = value;
|
|
961
996
|
}
|
|
962
|
-
return {
|
|
963
|
-
history,
|
|
964
|
-
newTable: this.shallowCopy({
|
|
965
|
-
copyCache: !shouldTracking(history.operation),
|
|
966
|
-
}),
|
|
967
|
-
};
|
|
968
|
-
}
|
|
969
|
-
getFunction(name) {
|
|
970
|
-
return this.functions[name];
|
|
971
|
-
}
|
|
972
|
-
getLabel(key, n) {
|
|
973
|
-
const labeler = this.labelers[key];
|
|
974
|
-
return labeler === null || labeler === void 0 ? void 0 : labeler(n);
|
|
975
|
-
}
|
|
976
|
-
getBase() {
|
|
977
|
-
return this;
|
|
978
|
-
}
|
|
979
|
-
getSolvedCache(key) {
|
|
980
|
-
return this.solvedCaches[key];
|
|
981
997
|
}
|
|
982
|
-
|
|
983
|
-
|
|
998
|
+
exports.Table = Table;
|
|
999
|
+
// just using as a type
|
|
1000
|
+
class ReadonlyTable extends Table {
|
|
984
1001
|
}
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
export class ReadonlyTable extends Table {
|
|
988
|
-
}
|
|
1002
|
+
exports.ReadonlyTable = ReadonlyTable;
|
|
1003
|
+
});
|
|
989
1004
|
//# sourceMappingURL=table.js.map
|