@gridsheet/react-core 0.12.14 → 0.13.0-alpha.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/README.md +4 -0
- package/dist/components/Cell.d.ts.map +1 -1
- package/dist/components/Cell.js +3 -3
- package/dist/components/Cell.js.map +1 -1
- package/dist/components/ContextMenu.d.ts.map +1 -1
- package/dist/components/ContextMenu.js +74 -29
- package/dist/components/ContextMenu.js.map +1 -1
- package/dist/components/Editor.d.ts.map +1 -1
- package/dist/components/Editor.js +32 -0
- package/dist/components/Editor.js.map +1 -1
- package/dist/components/GridSheet.js +2 -2
- package/dist/components/GridSheet.js.map +1 -1
- package/dist/components/HorizontalHeaderCell.d.ts +7 -0
- package/dist/components/HorizontalHeaderCell.d.ts.map +1 -0
- package/dist/components/{HeaderTopCell.js → HorizontalHeaderCell.js} +30 -6
- package/dist/components/HorizontalHeaderCell.js.map +1 -0
- package/dist/components/Resizer.d.ts.map +1 -1
- package/dist/components/Resizer.js +4 -3
- package/dist/components/Resizer.js.map +1 -1
- package/dist/components/Tabular.js +4 -4
- package/dist/components/Tabular.js.map +1 -1
- package/dist/components/VerticalHeaderCell.d.ts +7 -0
- package/dist/components/VerticalHeaderCell.d.ts.map +1 -0
- package/dist/components/{HeaderLeftCell.js → VerticalHeaderCell.js} +30 -6
- package/dist/components/VerticalHeaderCell.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/autofill.d.ts +1 -1
- package/dist/lib/autofill.d.ts.map +1 -1
- package/dist/lib/autofill.js +5 -3
- package/dist/lib/autofill.js.map +1 -1
- package/dist/lib/clipboard.d.ts +1 -1
- package/dist/lib/clipboard.d.ts.map +1 -1
- package/dist/lib/converters.d.ts +1 -1
- package/dist/lib/converters.d.ts.map +1 -1
- package/dist/lib/prevention.d.ts +24 -0
- package/dist/lib/prevention.d.ts.map +1 -0
- package/dist/lib/prevention.js +77 -0
- package/dist/lib/prevention.js.map +1 -0
- package/dist/lib/structs.d.ts +2 -2
- package/dist/lib/structs.d.ts.map +1 -1
- package/dist/lib/structs.js +4 -2
- package/dist/lib/structs.js.map +1 -1
- package/dist/lib/table.d.ts +24 -12
- package/dist/lib/table.d.ts.map +1 -1
- package/dist/lib/table.js +196 -104
- package/dist/lib/table.js.map +1 -1
- package/dist/lib/virtualization.d.ts +1 -1
- package/dist/lib/virtualization.d.ts.map +1 -1
- package/dist/store/actions.d.ts.map +1 -1
- package/dist/store/actions.js +46 -5
- package/dist/store/actions.js.map +1 -1
- package/dist/store/helpers.js +2 -2
- package/dist/styles/minified.d.ts +2 -2
- package/dist/styles/minified.d.ts.map +1 -1
- package/dist/styles/minified.js +2 -2
- package/dist/styles/minified.js.map +1 -1
- package/dist/types.d.ts +16 -15
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/components/HeaderLeftCell.d.ts +0 -7
- package/dist/components/HeaderLeftCell.d.ts.map +0 -1
- package/dist/components/HeaderLeftCell.js.map +0 -1
- package/dist/components/HeaderTopCell.d.ts +0 -7
- package/dist/components/HeaderTopCell.d.ts.map +0 -1
- package/dist/components/HeaderTopCell.js.map +0 -1
package/dist/lib/table.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Id, AreaType, CellsByIdType, CellsByAddressType, PointType, WriterType, Address, CellFilter, Labelers, MatrixType, CellType, Parsers, Renderers, HistoryType, StoreReflectionType, ShapeType } from "../types";
|
|
1
|
+
import { Id, AreaType, CellsByIdType, CellsByAddressType, PointType, WriterType, Address, CellFilter, Labelers, MatrixType, CellType, Parsers, Renderers, HistoryType, StoreReflectionType, ShapeType, OperatorType } from "../types";
|
|
2
2
|
import { FunctionMapping } from "../formula/functions/__base";
|
|
3
3
|
import { functions as functionsDefault } from "../formula/mapping";
|
|
4
4
|
declare type Props = {
|
|
@@ -26,7 +26,9 @@ declare type GetProps = {
|
|
|
26
26
|
declare type MoveProps = {
|
|
27
27
|
src: AreaType;
|
|
28
28
|
dst: AreaType;
|
|
29
|
+
operator?: OperatorType;
|
|
29
30
|
reflection?: StoreReflectionType;
|
|
31
|
+
historicize?: boolean;
|
|
30
32
|
};
|
|
31
33
|
declare type GetFlattenProps = GetProps & {
|
|
32
34
|
key?: keyof CellType;
|
|
@@ -104,7 +106,7 @@ export interface UserTable {
|
|
|
104
106
|
baseY: number;
|
|
105
107
|
reflection?: StoreReflectionType;
|
|
106
108
|
}): UserTable;
|
|
107
|
-
|
|
109
|
+
deleteRows(args: {
|
|
108
110
|
y: number;
|
|
109
111
|
numRows: number;
|
|
110
112
|
reflection?: StoreReflectionType;
|
|
@@ -124,7 +126,7 @@ export interface UserTable {
|
|
|
124
126
|
baseX: number;
|
|
125
127
|
reflection?: StoreReflectionType;
|
|
126
128
|
}): UserTable;
|
|
127
|
-
|
|
129
|
+
deleteCols(args: {
|
|
128
130
|
x: number;
|
|
129
131
|
numCols: number;
|
|
130
132
|
reflection?: StoreReflectionType;
|
|
@@ -202,45 +204,54 @@ export declare class Table implements UserTable {
|
|
|
202
204
|
private getIdMatrixFromArea;
|
|
203
205
|
private setChangedAt;
|
|
204
206
|
private copyCellLayout;
|
|
205
|
-
move({ src, dst, reflection, }: MoveProps): Table;
|
|
206
|
-
copy({ src, dst, reflection, }: MoveProps): Table;
|
|
207
|
+
move({ src, dst, historicize, operator, reflection, }: MoveProps): Table;
|
|
208
|
+
copy({ src, dst, operator, reflection, }: MoveProps): Table;
|
|
207
209
|
private _update;
|
|
208
|
-
update({ diff, partial, updateChangedAt, reflection, }: {
|
|
210
|
+
update({ diff, partial, updateChangedAt, historicize, operator, reflection, }: {
|
|
209
211
|
diff: CellsByAddressType;
|
|
210
212
|
partial?: boolean;
|
|
211
213
|
updateChangedAt?: boolean;
|
|
214
|
+
historicize?: boolean;
|
|
215
|
+
operator?: OperatorType;
|
|
212
216
|
reflection?: StoreReflectionType;
|
|
213
217
|
}): Table;
|
|
214
|
-
writeMatrix({ point, matrix, updateChangedAt, reflection, }: {
|
|
218
|
+
writeMatrix({ point, matrix, updateChangedAt, historicize, operator, reflection, }: {
|
|
215
219
|
point: PointType;
|
|
216
220
|
matrix: MatrixType<string>;
|
|
217
221
|
updateChangedAt?: boolean;
|
|
222
|
+
historicize?: boolean;
|
|
223
|
+
operator?: OperatorType;
|
|
218
224
|
reflection?: StoreReflectionType;
|
|
219
225
|
}): Table;
|
|
220
|
-
write({ point, value, updateChangedAt, reflection, }: {
|
|
226
|
+
write({ point, value, updateChangedAt, historicize, operator, reflection, }: {
|
|
221
227
|
point: PointType;
|
|
222
228
|
value: string;
|
|
223
229
|
updateChangedAt?: boolean;
|
|
230
|
+
historicize?: boolean;
|
|
231
|
+
operator?: OperatorType;
|
|
224
232
|
reflection?: StoreReflectionType;
|
|
225
233
|
}): Table;
|
|
226
|
-
addRowsAndUpdate({ y, numRows, baseY, diff, partial, updateChangedAt, reflection, }: {
|
|
234
|
+
addRowsAndUpdate({ y, numRows, baseY, diff, partial, updateChangedAt, operator, reflection, }: {
|
|
227
235
|
y: number;
|
|
228
236
|
numRows: number;
|
|
229
237
|
baseY: number;
|
|
230
238
|
diff: CellsByAddressType;
|
|
231
239
|
partial?: boolean;
|
|
232
240
|
updateChangedAt?: boolean;
|
|
241
|
+
operator?: OperatorType;
|
|
233
242
|
reflection?: StoreReflectionType;
|
|
234
243
|
}): Table;
|
|
235
|
-
addRows({ y, numRows, baseY, reflection, }: {
|
|
244
|
+
addRows({ y, numRows, baseY, operator, reflection, }: {
|
|
236
245
|
y: number;
|
|
237
246
|
numRows: number;
|
|
238
247
|
baseY: number;
|
|
248
|
+
operator?: OperatorType;
|
|
239
249
|
reflection?: StoreReflectionType;
|
|
240
250
|
}): Table;
|
|
241
|
-
|
|
251
|
+
deleteRows({ y, numRows, operator, reflection, }: {
|
|
242
252
|
y: number;
|
|
243
253
|
numRows: number;
|
|
254
|
+
operator?: OperatorType;
|
|
244
255
|
reflection?: StoreReflectionType;
|
|
245
256
|
}): Table;
|
|
246
257
|
addColsAndUpdate({ x, numCols, baseX, diff, partial, updateChangedAt, reflection, }: {
|
|
@@ -258,9 +269,10 @@ export declare class Table implements UserTable {
|
|
|
258
269
|
baseX: number;
|
|
259
270
|
reflection?: StoreReflectionType;
|
|
260
271
|
}): Table;
|
|
261
|
-
|
|
272
|
+
deleteCols({ x, numCols, operator, reflection, }: {
|
|
262
273
|
x: number;
|
|
263
274
|
numCols: number;
|
|
275
|
+
operator?: OperatorType;
|
|
264
276
|
reflection?: StoreReflectionType;
|
|
265
277
|
}): Table;
|
|
266
278
|
getHistories(): HistoryType[];
|
package/dist/lib/table.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/lib/table.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,EAAE,EAGF,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,OAAO,EACP,UAAU,EACV,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,OAAO,EACP,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,SAAS,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/lib/table.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,EAAE,EAGF,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,OAAO,EACP,UAAU,EACV,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,OAAO,EACP,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,SAAS,EACT,YAAY,EACb,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAQnE,aAAK,KAAK,GAAG;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAA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table.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.Table = void 0;
|
|
4
27
|
const core_1 = require("../parsers/core");
|
|
@@ -10,6 +33,7 @@ const evaluator_1 = require("../formula/evaluator");
|
|
|
10
33
|
const solver_1 = require("../formula/solver");
|
|
11
34
|
const constants_1 = require("../constants");
|
|
12
35
|
const helpers_1 = require("../store/helpers");
|
|
36
|
+
const prevention = __importStar(require("./prevention"));
|
|
13
37
|
const cellFilter = (cell) => true;
|
|
14
38
|
class Table {
|
|
15
39
|
constructor({ numRows = 0, numCols = 0, cells = {}, parsers = {}, renderers = {}, labelers = {}, useBigInt = false, historyLimit: historyLimit, minNumRows = 1, maxNumRows = -1, minNumCols = 1, maxNumCols = -1, headerWidth = -1, headerHeight = -1, functions = mapping_1.functions, }) {
|
|
@@ -53,8 +77,8 @@ class Table {
|
|
|
53
77
|
const range = (0, structs_1.expandRange)(address);
|
|
54
78
|
const data = cells[address];
|
|
55
79
|
range.forEach((address) => {
|
|
56
|
-
const origin =
|
|
57
|
-
cells[address] = Object.assign(Object.assign(Object.assign({}, origin), data), { style: Object.assign(Object.assign({}, origin === null || origin === void 0 ? void 0 : origin.style), data === null || data === void 0 ? void 0 : data.style) });
|
|
80
|
+
const origin = cells[address];
|
|
81
|
+
cells[address] = Object.assign(Object.assign(Object.assign({}, origin), data), { style: Object.assign(Object.assign({}, origin === null || origin === void 0 ? void 0 : origin.style), data === null || data === void 0 ? void 0 : data.style), prevention: ((origin === null || origin === void 0 ? void 0 : origin.prevention) || 0) | ((data === null || data === void 0 ? void 0 : data.prevention) || 0) });
|
|
58
82
|
});
|
|
59
83
|
});
|
|
60
84
|
const common = cells === null || cells === void 0 ? void 0 : cells['default'];
|
|
@@ -67,7 +91,7 @@ class Table {
|
|
|
67
91
|
const colId = (0, converters_1.x2c)(x);
|
|
68
92
|
const colDefault = cells === null || cells === void 0 ? void 0 : cells[colId];
|
|
69
93
|
const cell = cells === null || cells === void 0 ? void 0 : cells[address];
|
|
70
|
-
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) });
|
|
94
|
+
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), prevention: ((common === null || common === void 0 ? void 0 : common.prevention) || 0) | ((rowDefault === null || rowDefault === void 0 ? void 0 : rowDefault.prevention) || 0) | ((colDefault === null || colDefault === void 0 ? void 0 : colDefault.prevention) || 0) | ((cell === null || cell === void 0 ? void 0 : cell.prevention) || 0) });
|
|
71
95
|
stacked.value = (0, evaluator_1.convertFormulaAbsolute)({
|
|
72
96
|
value: stacked === null || stacked === void 0 ? void 0 : stacked.value,
|
|
73
97
|
table: this,
|
|
@@ -415,9 +439,9 @@ class Table {
|
|
|
415
439
|
}
|
|
416
440
|
}
|
|
417
441
|
cleanObsolete(history) {
|
|
418
|
-
if (history.operation === "
|
|
419
|
-
history.operation === "
|
|
420
|
-
history.
|
|
442
|
+
if (history.operation === "DELETE_ROWS" ||
|
|
443
|
+
history.operation === "DELETE_COLS") {
|
|
444
|
+
history.deleted.forEach((ids) => {
|
|
421
445
|
ids.forEach((id) => {
|
|
422
446
|
delete this.data[id];
|
|
423
447
|
});
|
|
@@ -427,7 +451,9 @@ class Table {
|
|
|
427
451
|
Object.keys(history.lostRows).forEach((address) => {
|
|
428
452
|
const idMatrix = history.lostRows[address];
|
|
429
453
|
idMatrix.map((ids) => ids.forEach((id) => {
|
|
430
|
-
|
|
454
|
+
if (id != null) {
|
|
455
|
+
delete this.data[id];
|
|
456
|
+
}
|
|
431
457
|
}));
|
|
432
458
|
});
|
|
433
459
|
}
|
|
@@ -462,9 +488,10 @@ class Table {
|
|
|
462
488
|
matrix.push(ids);
|
|
463
489
|
for (let x = left; x <= right; x++) {
|
|
464
490
|
const id = (_a = this.idMatrix[y]) === null || _a === void 0 ? void 0 : _a[x];
|
|
465
|
-
if (id) {
|
|
466
|
-
|
|
491
|
+
if (id == null) {
|
|
492
|
+
continue;
|
|
467
493
|
}
|
|
494
|
+
ids.push(id);
|
|
468
495
|
}
|
|
469
496
|
}
|
|
470
497
|
return matrix;
|
|
@@ -507,33 +534,45 @@ class Table {
|
|
|
507
534
|
}
|
|
508
535
|
return newCell;
|
|
509
536
|
}
|
|
510
|
-
move({ src, dst, reflection = {}, }) {
|
|
511
|
-
const
|
|
537
|
+
move({ src, dst, historicize = true, operator = "SYSTEM", reflection = {}, }) {
|
|
538
|
+
const matrixNew = this.getNewIdMatrix(src);
|
|
512
539
|
const matrixFrom = this.getIdMatrixFromArea(src);
|
|
513
540
|
const matrixTo = this.getIdMatrixFromArea(dst);
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
.forEach((cell) => this.setChangedAt(cell, changedAt));
|
|
541
|
+
(0, structs_1.putMatrix)(this.idMatrix, matrixNew, src, (_, id) => {
|
|
542
|
+
const cell = this.data[id];
|
|
543
|
+
if (operator === 'USER' && prevention.isPrevented(cell === null || cell === void 0 ? void 0 : cell.prevention, prevention.MoveFrom)) {
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
return true;
|
|
521
547
|
});
|
|
522
|
-
const lostRows = (0, structs_1.putMatrix)(this.idMatrix, matrixFrom, dst)
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
548
|
+
const lostRows = (0, structs_1.putMatrix)(this.idMatrix, matrixFrom, dst, (srcId, dstId) => {
|
|
549
|
+
const srcCell = this.data[srcId];
|
|
550
|
+
const dstCell = this.data[dstId];
|
|
551
|
+
if (operator === 'USER' && (prevention.isPrevented(srcCell === null || srcCell === void 0 ? void 0 : srcCell.prevention, prevention.MoveFrom) ||
|
|
552
|
+
prevention.isPrevented(dstCell === null || dstCell === void 0 ? void 0 : dstCell.prevention, prevention.MoveTo))) {
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
555
|
+
if (srcCell != null) {
|
|
556
|
+
this.setChangedAt(srcCell, new Date());
|
|
557
|
+
}
|
|
558
|
+
return true;
|
|
533
559
|
});
|
|
560
|
+
if (historicize) {
|
|
561
|
+
this.pushHistory({
|
|
562
|
+
applyed: true,
|
|
563
|
+
operation: "MOVE",
|
|
564
|
+
reflection,
|
|
565
|
+
src,
|
|
566
|
+
dst,
|
|
567
|
+
matrixFrom,
|
|
568
|
+
matrixTo,
|
|
569
|
+
matrixNew,
|
|
570
|
+
lostRows,
|
|
571
|
+
});
|
|
572
|
+
}
|
|
534
573
|
return this.shallowCopy({ copyCache: false });
|
|
535
574
|
}
|
|
536
|
-
copy({ src, dst, reflection = {}, }) {
|
|
575
|
+
copy({ src, dst, operator = "SYSTEM", reflection = {}, }) {
|
|
537
576
|
const { height: maxHeight, width: maxWidth } = (0, structs_1.areaShape)(Object.assign(Object.assign({}, src), { base: 1 }));
|
|
538
577
|
const { top: topFrom, left: leftFrom } = src;
|
|
539
578
|
const { top: topTo, left: leftTo, bottom: bottomTo, right: rightTo } = dst;
|
|
@@ -553,10 +592,10 @@ class Table {
|
|
|
553
592
|
const fromX = leftFrom + (j % maxWidth);
|
|
554
593
|
const slideY = toY - fromY;
|
|
555
594
|
const slideX = toX - fromX;
|
|
556
|
-
const cell = Object.assign({}, this.getByPoint({
|
|
595
|
+
const cell = Object.assign(Object.assign({}, this.getByPoint({
|
|
557
596
|
y: topFrom + (i % maxHeight),
|
|
558
597
|
x: leftFrom + (j % maxWidth),
|
|
559
|
-
}));
|
|
598
|
+
})), { prevention: 0 });
|
|
560
599
|
const value = (0, evaluator_1.convertFormulaAbsolute)({
|
|
561
600
|
value: cell === null || cell === void 0 ? void 0 : cell.value,
|
|
562
601
|
table: this,
|
|
@@ -567,16 +606,21 @@ class Table {
|
|
|
567
606
|
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 });
|
|
568
607
|
}
|
|
569
608
|
}
|
|
570
|
-
return this.update({
|
|
609
|
+
return this.update({
|
|
610
|
+
diff,
|
|
611
|
+
partial: false,
|
|
612
|
+
operator,
|
|
613
|
+
reflection,
|
|
614
|
+
});
|
|
571
615
|
}
|
|
572
|
-
_update({ diff, partial = true, updateChangedAt = true, }) {
|
|
616
|
+
_update({ diff, partial = true, updateChangedAt = true, ignoreFields = ['labeler', 'prevention'], operator = 'SYSTEM', }) {
|
|
573
617
|
const diffBefore = {};
|
|
574
618
|
const diffAfter = {};
|
|
575
619
|
const changedAt = new Date();
|
|
576
620
|
Object.keys(diff).forEach((address) => {
|
|
577
621
|
const cell = Object.assign({}, diff[address]);
|
|
578
|
-
if (
|
|
579
|
-
|
|
622
|
+
if (operator === 'USER' && prevention.isPrevented(cell === null || cell === void 0 ? void 0 : cell.prevention, prevention.Update)) {
|
|
623
|
+
return;
|
|
580
624
|
}
|
|
581
625
|
cell.value = (0, evaluator_1.convertFormulaAbsolute)({
|
|
582
626
|
value: cell.value,
|
|
@@ -584,11 +628,36 @@ class Table {
|
|
|
584
628
|
});
|
|
585
629
|
const point = (0, converters_1.a2p)(address);
|
|
586
630
|
const id = this.getId(point);
|
|
631
|
+
const current = this.data[id];
|
|
632
|
+
ignoreFields.forEach((key) => {
|
|
633
|
+
cell[key] = current === null || current === void 0 ? void 0 : current[key];
|
|
634
|
+
});
|
|
635
|
+
if (operator === 'USER' && prevention.isPrevented(current === null || current === void 0 ? void 0 : current.prevention, prevention.Write)) {
|
|
636
|
+
cell.value = current === null || current === void 0 ? void 0 : current.value;
|
|
637
|
+
}
|
|
638
|
+
if (operator === 'USER' && prevention.isPrevented(current === null || current === void 0 ? void 0 : current.prevention, prevention.Style)) {
|
|
639
|
+
cell.style = current === null || current === void 0 ? void 0 : current.style;
|
|
640
|
+
cell.justifyContent = current === null || current === void 0 ? void 0 : current.justifyContent;
|
|
641
|
+
cell.alignItems = current === null || current === void 0 ? void 0 : current.alignItems;
|
|
642
|
+
}
|
|
643
|
+
if (operator === 'USER' && prevention.isPrevented(current === null || current === void 0 ? void 0 : current.prevention, prevention.Resize)) {
|
|
644
|
+
cell.width = current === null || current === void 0 ? void 0 : current.width;
|
|
645
|
+
cell.height = current === null || current === void 0 ? void 0 : current.height;
|
|
646
|
+
}
|
|
647
|
+
if (operator === 'USER' && prevention.isPrevented(current === null || current === void 0 ? void 0 : current.prevention, prevention.SetRenderer)) {
|
|
648
|
+
cell.renderer = current === null || current === void 0 ? void 0 : current.renderer;
|
|
649
|
+
}
|
|
650
|
+
if (operator === 'USER' && prevention.isPrevented(current === null || current === void 0 ? void 0 : current.prevention, prevention.SetParser)) {
|
|
651
|
+
cell.parser = current === null || current === void 0 ? void 0 : current.parser;
|
|
652
|
+
}
|
|
653
|
+
if (updateChangedAt) {
|
|
654
|
+
this.setChangedAt(cell, changedAt);
|
|
655
|
+
}
|
|
587
656
|
// must not partial
|
|
588
657
|
diffBefore[id] = this.getByPoint(point);
|
|
589
658
|
diffAfter[id] = cell;
|
|
590
659
|
if (partial) {
|
|
591
|
-
this.data[id] = Object.assign(Object.assign({},
|
|
660
|
+
this.data[id] = Object.assign(Object.assign({}, current), cell);
|
|
592
661
|
}
|
|
593
662
|
else {
|
|
594
663
|
this.data[id] = cell;
|
|
@@ -600,23 +669,26 @@ class Table {
|
|
|
600
669
|
diffAfter,
|
|
601
670
|
};
|
|
602
671
|
}
|
|
603
|
-
update({ diff, partial = true, updateChangedAt = true, reflection = {}, }) {
|
|
672
|
+
update({ diff, partial = true, updateChangedAt = true, historicize = true, operator = "SYSTEM", reflection = {}, }) {
|
|
604
673
|
const { diffBefore, diffAfter } = this._update({
|
|
605
674
|
diff,
|
|
606
675
|
partial,
|
|
676
|
+
operator,
|
|
607
677
|
updateChangedAt,
|
|
608
678
|
});
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
679
|
+
if (historicize) {
|
|
680
|
+
this.pushHistory({
|
|
681
|
+
applyed: true,
|
|
682
|
+
operation: "UPDATE",
|
|
683
|
+
reflection,
|
|
684
|
+
diffBefore,
|
|
685
|
+
diffAfter,
|
|
686
|
+
partial,
|
|
687
|
+
});
|
|
688
|
+
}
|
|
617
689
|
return this.shallowCopy({ copyCache: true });
|
|
618
690
|
}
|
|
619
|
-
writeMatrix({ point, matrix, updateChangedAt = true, reflection = {}, }) {
|
|
691
|
+
writeMatrix({ point, matrix, updateChangedAt = true, historicize = true, operator = "SYSTEM", reflection = {}, }) {
|
|
620
692
|
const { y: baseY, x: baseX } = point;
|
|
621
693
|
const diff = {};
|
|
622
694
|
matrix.forEach((cols, i) => {
|
|
@@ -637,28 +709,32 @@ class Table {
|
|
|
637
709
|
diff,
|
|
638
710
|
partial: true,
|
|
639
711
|
updateChangedAt,
|
|
712
|
+
historicize,
|
|
713
|
+
operator,
|
|
640
714
|
reflection,
|
|
641
715
|
});
|
|
642
716
|
}
|
|
643
|
-
write({ point, value, updateChangedAt = true, reflection = {}, }) {
|
|
717
|
+
write({ point, value, updateChangedAt = true, historicize = true, operator = "SYSTEM", reflection = {}, }) {
|
|
644
718
|
return this.writeMatrix({
|
|
645
719
|
point,
|
|
646
720
|
matrix: [[value]],
|
|
647
721
|
updateChangedAt,
|
|
722
|
+
historicize,
|
|
723
|
+
operator,
|
|
648
724
|
reflection,
|
|
649
725
|
});
|
|
650
726
|
}
|
|
651
|
-
addRowsAndUpdate({ y, numRows, baseY, diff, partial, updateChangedAt, reflection = {}, }) {
|
|
727
|
+
addRowsAndUpdate({ y, numRows, baseY, diff, partial, updateChangedAt, operator = "SYSTEM", reflection = {}, }) {
|
|
652
728
|
const returned = this.addRows({
|
|
653
729
|
y,
|
|
654
730
|
numRows,
|
|
655
731
|
baseY,
|
|
656
732
|
reflection,
|
|
657
733
|
});
|
|
658
|
-
Object.assign(this.lastHistory, this._update({ diff, partial, updateChangedAt }), { partial });
|
|
734
|
+
Object.assign(this.lastHistory, this._update({ diff, partial, updateChangedAt, operator }), { partial });
|
|
659
735
|
return returned;
|
|
660
736
|
}
|
|
661
|
-
addRows({ y, numRows, baseY, reflection = {}, }) {
|
|
737
|
+
addRows({ y, numRows, baseY, operator = "SYSTEM", reflection = {}, }) {
|
|
662
738
|
if (this.maxNumRows !== -1 &&
|
|
663
739
|
this.getNumRows() + numRows > this.maxNumRows) {
|
|
664
740
|
console.error(`Rows are limited to ${this.maxNumRows}.`);
|
|
@@ -690,21 +766,33 @@ class Table {
|
|
|
690
766
|
});
|
|
691
767
|
return this.shallowCopy({ copyCache: false });
|
|
692
768
|
}
|
|
693
|
-
|
|
769
|
+
deleteRows({ y, numRows, operator = "SYSTEM", reflection = {}, }) {
|
|
694
770
|
if (this.minNumRows !== -1 &&
|
|
695
771
|
this.getNumRows() - numRows < this.minNumRows) {
|
|
696
772
|
console.error(`At least ${this.minNumRows} row(s) are required.`);
|
|
697
773
|
return this;
|
|
698
774
|
}
|
|
699
|
-
const
|
|
700
|
-
|
|
775
|
+
const ys = [];
|
|
776
|
+
for (let i = y; i < y + numRows; i++) {
|
|
777
|
+
const cell = this.getByPoint({ y: i, x: 0 });
|
|
778
|
+
if (operator === "USER" && prevention.isPrevented(cell === null || cell === void 0 ? void 0 : cell.prevention, prevention.DeleteRow)) {
|
|
779
|
+
console.warn(`Cannot delete row ${i}.`);
|
|
780
|
+
return this;
|
|
781
|
+
}
|
|
782
|
+
ys.unshift(i);
|
|
783
|
+
}
|
|
784
|
+
const deleted = [];
|
|
785
|
+
ys.forEach((y) => {
|
|
786
|
+
const row = this.idMatrix.splice(y, 1);
|
|
787
|
+
deleted.unshift(row[0]);
|
|
788
|
+
});
|
|
789
|
+
this.area.bottom -= ys.length;
|
|
701
790
|
this.pushHistory({
|
|
702
791
|
applyed: true,
|
|
703
|
-
operation: "
|
|
792
|
+
operation: "DELETE_ROWS",
|
|
704
793
|
reflection,
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
idMatrix: rows,
|
|
794
|
+
ys: ys.reverse(),
|
|
795
|
+
deleted,
|
|
708
796
|
});
|
|
709
797
|
return this.shallowCopy({ copyCache: false });
|
|
710
798
|
}
|
|
@@ -750,25 +838,37 @@ class Table {
|
|
|
750
838
|
});
|
|
751
839
|
return this.shallowCopy({ copyCache: false });
|
|
752
840
|
}
|
|
753
|
-
|
|
841
|
+
deleteCols({ x, numCols, operator = "SYSTEM", reflection = {}, }) {
|
|
754
842
|
if (this.minNumCols !== -1 &&
|
|
755
843
|
this.getNumCols() - numCols < this.minNumCols) {
|
|
756
844
|
console.error(`At least ${this.minNumCols} column(s) are required.`);
|
|
757
845
|
return this;
|
|
758
846
|
}
|
|
759
|
-
const
|
|
847
|
+
const xs = [];
|
|
848
|
+
for (let i = x; i < x + numCols; i++) {
|
|
849
|
+
const cell = this.getByPoint({ y: 0, x: i });
|
|
850
|
+
if (operator === "USER" && prevention.isPrevented(cell === null || cell === void 0 ? void 0 : cell.prevention, prevention.DeleteCol)) {
|
|
851
|
+
console.warn(`Cannot delete col ${i}.`);
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
xs.unshift(i);
|
|
855
|
+
}
|
|
856
|
+
const deleted = [];
|
|
760
857
|
this.idMatrix.forEach((row) => {
|
|
761
|
-
const
|
|
762
|
-
|
|
858
|
+
const deleting = [];
|
|
859
|
+
deleted.push(deleting);
|
|
860
|
+
// reverse and delete
|
|
861
|
+
xs.forEach((x) => {
|
|
862
|
+
deleting.unshift(...row.splice(x, 1));
|
|
863
|
+
});
|
|
763
864
|
});
|
|
764
|
-
this.area.right -=
|
|
865
|
+
this.area.right -= xs.length;
|
|
765
866
|
this.pushHistory({
|
|
766
867
|
applyed: true,
|
|
767
|
-
operation: "
|
|
868
|
+
operation: "DELETE_COLS",
|
|
768
869
|
reflection,
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
idMatrix: rows,
|
|
870
|
+
xs: xs.reverse(),
|
|
871
|
+
deleted,
|
|
772
872
|
});
|
|
773
873
|
return this.shallowCopy({ copyCache: false });
|
|
774
874
|
}
|
|
@@ -876,23 +976,27 @@ class Table {
|
|
|
876
976
|
this.area.right -= width;
|
|
877
977
|
break;
|
|
878
978
|
}
|
|
879
|
-
case "
|
|
880
|
-
const {
|
|
881
|
-
|
|
882
|
-
|
|
979
|
+
case "DELETE_ROWS": {
|
|
980
|
+
const { ys, deleted } = history;
|
|
981
|
+
ys.forEach((y, i) => {
|
|
982
|
+
this.idMatrix.splice(y, 0, deleted[i]);
|
|
983
|
+
});
|
|
984
|
+
this.area.bottom += ys.length;
|
|
883
985
|
break;
|
|
884
986
|
}
|
|
885
|
-
case "
|
|
886
|
-
const {
|
|
987
|
+
case "DELETE_COLS": {
|
|
988
|
+
const { xs, deleted } = history;
|
|
887
989
|
this.idMatrix.forEach((row, i) => {
|
|
888
|
-
|
|
990
|
+
for (let j = 0; j < xs.length; j++) {
|
|
991
|
+
row.splice(xs[j], 0, deleted[i][j]);
|
|
992
|
+
}
|
|
889
993
|
});
|
|
890
|
-
this.area.right +=
|
|
994
|
+
this.area.right += xs.length;
|
|
891
995
|
break;
|
|
892
996
|
}
|
|
893
997
|
case "MOVE": {
|
|
894
|
-
const {
|
|
895
|
-
const {
|
|
998
|
+
const { top: yFrom, left: xFrom } = history.src;
|
|
999
|
+
const { top: yTo, left: xTo } = history.dst;
|
|
896
1000
|
const { height: rows, width: cols } = (0, structs_1.matrixShape)({
|
|
897
1001
|
matrix: history.matrixFrom,
|
|
898
1002
|
base: -1,
|
|
@@ -950,39 +1054,27 @@ class Table {
|
|
|
950
1054
|
this.area.right += width;
|
|
951
1055
|
break;
|
|
952
1056
|
}
|
|
953
|
-
case "
|
|
954
|
-
const {
|
|
955
|
-
|
|
956
|
-
|
|
1057
|
+
case "DELETE_ROWS": {
|
|
1058
|
+
const { ys } = history;
|
|
1059
|
+
[...ys].reverse().forEach((y) => {
|
|
1060
|
+
this.idMatrix.splice(y, 1);
|
|
1061
|
+
});
|
|
1062
|
+
this.area.bottom -= ys.length;
|
|
957
1063
|
break;
|
|
958
1064
|
}
|
|
959
|
-
case "
|
|
960
|
-
const {
|
|
961
|
-
|
|
962
|
-
|
|
1065
|
+
case "DELETE_COLS": {
|
|
1066
|
+
const { xs } = history;
|
|
1067
|
+
[...xs].reverse().forEach((x) => {
|
|
1068
|
+
this.idMatrix.forEach((row) => {
|
|
1069
|
+
row.splice(x, 1);
|
|
1070
|
+
});
|
|
963
1071
|
});
|
|
964
|
-
this.area.right -=
|
|
1072
|
+
this.area.right -= xs.length;
|
|
965
1073
|
break;
|
|
966
1074
|
}
|
|
967
1075
|
case "MOVE": {
|
|
968
|
-
const {
|
|
969
|
-
|
|
970
|
-
const { height: rows, width: cols } = (0, structs_1.matrixShape)({
|
|
971
|
-
matrix: history.matrixFrom,
|
|
972
|
-
base: -1,
|
|
973
|
-
});
|
|
974
|
-
(0, structs_1.putMatrix)(this.idMatrix, history.matrixNew, {
|
|
975
|
-
top: yFrom,
|
|
976
|
-
left: xFrom,
|
|
977
|
-
bottom: yFrom + rows,
|
|
978
|
-
right: xFrom + cols,
|
|
979
|
-
});
|
|
980
|
-
(0, structs_1.putMatrix)(this.idMatrix, history.matrixFrom, {
|
|
981
|
-
top: yTo,
|
|
982
|
-
left: xTo,
|
|
983
|
-
bottom: yTo + rows,
|
|
984
|
-
right: xTo + cols,
|
|
985
|
-
});
|
|
1076
|
+
const { src, dst } = history;
|
|
1077
|
+
this.move({ src, dst, operator: "USER", historicize: false });
|
|
986
1078
|
}
|
|
987
1079
|
}
|
|
988
1080
|
return {
|