@gridsheet/react-core 0.12.4-rc.0 → 0.12.4
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.d.ts.map +1 -1
- package/dist/components/Cell.js +181 -190
- package/dist/components/Cell.js.map +1 -1
- package/dist/components/ContextMenu.js +198 -208
- package/dist/components/ContextMenu.js.map +1 -1
- package/dist/components/Editor.d.ts.map +1 -1
- package/dist/components/Editor.js +262 -275
- package/dist/components/Editor.js.map +1 -1
- package/dist/components/Emitter.js +29 -39
- package/dist/components/Emitter.js.map +1 -1
- package/dist/components/GridSheet.d.ts.map +1 -1
- package/dist/components/GridSheet.js +109 -119
- package/dist/components/GridSheet.js.map +1 -1
- package/dist/components/HeaderLeftCell.js +61 -72
- package/dist/components/HeaderLeftCell.js.map +1 -1
- package/dist/components/HeaderTopCell.js +62 -73
- package/dist/components/HeaderTopCell.js.map +1 -1
- package/dist/components/Resizer.d.ts.map +1 -1
- package/dist/components/Resizer.js +79 -87
- package/dist/components/Resizer.js.map +1 -1
- package/dist/components/SearchBox.d.ts.map +1 -1
- package/dist/components/SearchBox.js +54 -62
- package/dist/components/SearchBox.js.map +1 -1
- package/dist/components/StoreInitializer.js +71 -81
- package/dist/components/StoreInitializer.js.map +1 -1
- package/dist/components/Tabular.d.ts +2 -2
- package/dist/components/Tabular.d.ts.map +1 -1
- package/dist/components/Tabular.js +85 -95
- package/dist/components/Tabular.js.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +26 -33
- package/dist/constants.js.map +1 -1
- package/dist/formula/evaluator.d.ts +1 -1
- package/dist/formula/evaluator.js +490 -500
- package/dist/formula/evaluator.js.map +1 -1
- package/dist/formula/functions/__base.js +17 -27
- package/dist/formula/functions/__base.js.map +1 -1
- package/dist/formula/functions/__utils.js +103 -113
- package/dist/formula/functions/__utils.js.map +1 -1
- package/dist/formula/functions/abs.js +21 -31
- package/dist/formula/functions/abs.js.map +1 -1
- package/dist/formula/functions/abs.spec.js +25 -35
- package/dist/formula/functions/abs.spec.js.map +1 -1
- package/dist/formula/functions/acos.js +28 -38
- package/dist/formula/functions/acos.js.map +1 -1
- package/dist/formula/functions/add.js +47 -57
- package/dist/formula/functions/add.js.map +1 -1
- package/dist/formula/functions/and.js +28 -38
- package/dist/formula/functions/and.js.map +1 -1
- package/dist/formula/functions/asin.js +28 -38
- package/dist/formula/functions/asin.js.map +1 -1
- package/dist/formula/functions/atan.js +26 -36
- package/dist/formula/functions/atan.js.map +1 -1
- package/dist/formula/functions/atan2.js +32 -42
- package/dist/formula/functions/atan2.js.map +1 -1
- package/dist/formula/functions/average.js +40 -50
- package/dist/formula/functions/average.js.map +1 -1
- package/dist/formula/functions/col.js +28 -38
- package/dist/formula/functions/col.js.map +1 -1
- package/dist/formula/functions/concat.js +27 -37
- package/dist/formula/functions/concat.js.map +1 -1
- package/dist/formula/functions/concatenate.js +25 -35
- package/dist/formula/functions/concatenate.js.map +1 -1
- package/dist/formula/functions/cos.js +26 -36
- package/dist/formula/functions/cos.js.map +1 -1
- package/dist/formula/functions/count.js +35 -45
- package/dist/formula/functions/count.js.map +1 -1
- package/dist/formula/functions/counta.js +35 -45
- package/dist/formula/functions/counta.js.map +1 -1
- package/dist/formula/functions/countif.js +30 -40
- package/dist/formula/functions/countif.js.map +1 -1
- package/dist/formula/functions/divide.js +32 -42
- package/dist/formula/functions/divide.js.map +1 -1
- package/dist/formula/functions/eq.js +25 -35
- package/dist/formula/functions/eq.js.map +1 -1
- package/dist/formula/functions/exp.js +28 -38
- package/dist/formula/functions/exp.js.map +1 -1
- package/dist/formula/functions/gt.js +27 -37
- package/dist/formula/functions/gt.js.map +1 -1
- package/dist/formula/functions/gte.js +27 -37
- package/dist/formula/functions/gte.js.map +1 -1
- package/dist/formula/functions/hlookup.js +67 -77
- package/dist/formula/functions/hlookup.js.map +1 -1
- package/dist/formula/functions/if.js +36 -46
- package/dist/formula/functions/if.js.map +1 -1
- package/dist/formula/functions/iferror.js +38 -48
- package/dist/formula/functions/iferror.js.map +1 -1
- package/dist/formula/functions/iferror.spec.js +53 -63
- package/dist/formula/functions/iferror.spec.js.map +1 -1
- package/dist/formula/functions/len.js +26 -36
- package/dist/formula/functions/len.js.map +1 -1
- package/dist/formula/functions/lenb.js +26 -36
- package/dist/formula/functions/lenb.js.map +1 -1
- package/dist/formula/functions/ln.js +28 -38
- package/dist/formula/functions/ln.js.map +1 -1
- package/dist/formula/functions/log.js +33 -43
- package/dist/formula/functions/log.js.map +1 -1
- package/dist/formula/functions/log10.js +28 -38
- package/dist/formula/functions/log10.js.map +1 -1
- package/dist/formula/functions/lt.js +27 -37
- package/dist/formula/functions/lt.js.map +1 -1
- package/dist/formula/functions/lte.js +27 -37
- package/dist/formula/functions/lte.js.map +1 -1
- package/dist/formula/functions/max.js +42 -52
- package/dist/formula/functions/max.js.map +1 -1
- package/dist/formula/functions/min.js +42 -52
- package/dist/formula/functions/min.js.map +1 -1
- package/dist/formula/functions/minus.js +47 -57
- package/dist/formula/functions/minus.js.map +1 -1
- package/dist/formula/functions/mod.js +30 -40
- package/dist/formula/functions/mod.js.map +1 -1
- package/dist/formula/functions/mod.spec.js +47 -57
- package/dist/formula/functions/mod.spec.js.map +1 -1
- package/dist/formula/functions/multiply.js +27 -37
- package/dist/formula/functions/multiply.js.map +1 -1
- package/dist/formula/functions/ne.js +25 -35
- package/dist/formula/functions/ne.js.map +1 -1
- package/dist/formula/functions/not.js +30 -40
- package/dist/formula/functions/not.js.map +1 -1
- package/dist/formula/functions/now.js +21 -31
- package/dist/formula/functions/now.js.map +1 -1
- package/dist/formula/functions/or.js +28 -38
- package/dist/formula/functions/or.js.map +1 -1
- package/dist/formula/functions/pi.js +19 -29
- package/dist/formula/functions/pi.js.map +1 -1
- package/dist/formula/functions/power.js +24 -34
- package/dist/formula/functions/power.js.map +1 -1
- package/dist/formula/functions/product.js +37 -47
- package/dist/formula/functions/product.js.map +1 -1
- package/dist/formula/functions/radians.js +26 -36
- package/dist/formula/functions/radians.js.map +1 -1
- package/dist/formula/functions/rand.js +19 -29
- package/dist/formula/functions/rand.js.map +1 -1
- package/dist/formula/functions/round.js +34 -44
- package/dist/formula/functions/round.js.map +1 -1
- package/dist/formula/functions/rounddown.js +34 -44
- package/dist/formula/functions/rounddown.js.map +1 -1
- package/dist/formula/functions/roundup.js +34 -44
- package/dist/formula/functions/roundup.js.map +1 -1
- package/dist/formula/functions/row.js +28 -38
- package/dist/formula/functions/row.js.map +1 -1
- package/dist/formula/functions/sin.js +26 -36
- package/dist/formula/functions/sin.js.map +1 -1
- package/dist/formula/functions/sqrt.js +28 -38
- package/dist/formula/functions/sqrt.js.map +1 -1
- package/dist/formula/functions/sum.js +42 -52
- package/dist/formula/functions/sum.js.map +1 -1
- package/dist/formula/functions/sum.spec.js +35 -45
- package/dist/formula/functions/sum.spec.js.map +1 -1
- package/dist/formula/functions/sumif.js +56 -66
- package/dist/formula/functions/sumif.js.map +1 -1
- package/dist/formula/functions/tan.js +26 -36
- package/dist/formula/functions/tan.js.map +1 -1
- package/dist/formula/functions/uminus.js +23 -33
- package/dist/formula/functions/uminus.js.map +1 -1
- package/dist/formula/functions/vlookup.js +67 -77
- package/dist/formula/functions/vlookup.js.map +1 -1
- package/dist/formula/mapping.js +116 -126
- package/dist/formula/mapping.js.map +1 -1
- package/dist/formula/solver.js +61 -71
- package/dist/formula/solver.js.map +1 -1
- package/dist/index.js +31 -41
- package/dist/index.js.map +1 -1
- package/dist/lib/autofill.js +334 -344
- package/dist/lib/autofill.js.map +1 -1
- package/dist/lib/clipboard.js +45 -55
- package/dist/lib/clipboard.js.map +1 -1
- package/dist/lib/converters.js +130 -140
- package/dist/lib/converters.js.map +1 -1
- package/dist/lib/hooks.d.ts +1 -0
- package/dist/lib/hooks.d.ts.map +1 -0
- package/dist/lib/hooks.js +2 -0
- package/dist/lib/hooks.js.map +1 -0
- package/dist/lib/structs.js +254 -264
- package/dist/lib/structs.js.map +1 -1
- package/dist/lib/table.d.ts +1 -3
- package/dist/lib/table.d.ts.map +1 -1
- package/dist/lib/table.js +897 -911
- package/dist/lib/table.js.map +1 -1
- package/dist/lib/time.d.ts.map +1 -1
- package/dist/lib/time.js +59 -69
- package/dist/lib/time.js.map +1 -1
- package/dist/lib/virtualization.d.ts +3 -12
- package/dist/lib/virtualization.d.ts.map +1 -1
- package/dist/lib/virtualization.js +116 -120
- package/dist/lib/virtualization.js.map +1 -1
- package/dist/parsers/core.js +109 -119
- package/dist/parsers/core.js.map +1 -1
- package/dist/renderers/checkbox.js +11 -21
- package/dist/renderers/checkbox.js.map +1 -1
- package/dist/renderers/core.d.ts +1 -1
- package/dist/renderers/core.d.ts.map +1 -1
- package/dist/renderers/core.js +129 -139
- package/dist/renderers/core.js.map +1 -1
- package/dist/renderers/thousand_separator.js +15 -25
- package/dist/renderers/thousand_separator.js.map +1 -1
- package/dist/store/actions.js +485 -495
- package/dist/store/actions.js.map +1 -1
- package/dist/store/helpers.js +78 -88
- package/dist/store/helpers.js.map +1 -1
- package/dist/store/index.js +5 -15
- package/dist/store/index.js.map +1 -1
- package/dist/styles/embedder.js +17 -27
- package/dist/styles/embedder.js.map +1 -1
- package/dist/styles/minified.js +6 -16
- package/dist/styles/minified.js.map +1 -1
- package/dist/types.d.ts +10 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -12
- package/dist/utils.js +9 -19
- package/dist/utils.js.map +1 -1
- package/package.json +9 -2
package/dist/lib/autofill.js
CHANGED
|
@@ -1,403 +1,393 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Autofill = void 0;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
5
|
+
const structs_1 = require("./structs");
|
|
6
|
+
const converters_1 = require("./converters");
|
|
7
|
+
const evaluator_1 = require("../formula/evaluator");
|
|
8
|
+
const time_1 = require("./time");
|
|
9
|
+
const BORDER_AUTOFILL_DRAGGING = "dashed 1px #000000";
|
|
10
|
+
const DirectionMapping = {
|
|
11
|
+
left: ["horizontal", -1],
|
|
12
|
+
right: ["horizontal", 1],
|
|
13
|
+
up: ["vertical", -1],
|
|
14
|
+
down: ["vertical", 1],
|
|
15
|
+
};
|
|
16
|
+
class Autofill {
|
|
17
|
+
constructor(store, draggingTo) {
|
|
18
|
+
const { table, choosing, selectingZone } = store;
|
|
19
|
+
this.src = (0, structs_1.complementSelectingArea)((0, structs_1.zoneToArea)(selectingZone), choosing);
|
|
20
|
+
this.direction = this.suggestDirection(draggingTo);
|
|
21
|
+
this.dst = this.getDestinationArea(draggingTo);
|
|
22
|
+
this.table = table;
|
|
5
23
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
left: ["horizontal", -1],
|
|
21
|
-
right: ["horizontal", 1],
|
|
22
|
-
up: ["vertical", -1],
|
|
23
|
-
down: ["vertical", 1],
|
|
24
|
-
};
|
|
25
|
-
class Autofill {
|
|
26
|
-
constructor(store, draggingTo) {
|
|
27
|
-
const { table, choosing, selectingZone } = store;
|
|
28
|
-
this.src = (0, structs_1.complementSelectingArea)((0, structs_1.zoneToArea)(selectingZone), choosing);
|
|
29
|
-
this.direction = this.suggestDirection(draggingTo);
|
|
30
|
-
this.dst = this.getDestinationArea(draggingTo);
|
|
31
|
-
this.table = table;
|
|
32
|
-
}
|
|
33
|
-
get applied() {
|
|
34
|
-
const [orientation, sign] = DirectionMapping[this.direction];
|
|
35
|
-
const matrix = this.table.getMatrix({ area: this.src, evaluates: false });
|
|
36
|
-
const srcShape = (0, structs_1.areaShape)(Object.assign(Object.assign({}, this.src), { base: 1 }));
|
|
37
|
-
const dstShape = (0, structs_1.areaShape)(Object.assign(Object.assign({}, this.dst), { base: 1 }));
|
|
38
|
-
const diff = {};
|
|
39
|
-
if (orientation === "horizontal") {
|
|
40
|
-
for (let i = 0; i < dstShape.height; i++) {
|
|
41
|
-
const patterns = this.getChangePatterns(matrix[i]);
|
|
42
|
-
for (let j = 0; j < dstShape.width; j++) {
|
|
43
|
-
const baseCell = matrix[i % srcShape.height][j % srcShape.width];
|
|
44
|
-
const x = sign > 0 ? this.dst.left + j : this.dst.right - j;
|
|
45
|
-
const px = sign > 0 ? j % srcShape.width : (srcShape.width - 1 - (j % srcShape.width)) % srcShape.width;
|
|
46
|
-
diff[(0, converters_1.p2a)({ y: this.dst.top + i, x })] = Object.assign(Object.assign({}, baseCell), { value: patterns[px].next().value });
|
|
47
|
-
}
|
|
24
|
+
get applied() {
|
|
25
|
+
const [orientation, sign] = DirectionMapping[this.direction];
|
|
26
|
+
const matrix = this.table.getMatrix({ area: this.src, evaluates: false });
|
|
27
|
+
const srcShape = (0, structs_1.areaShape)(Object.assign(Object.assign({}, this.src), { base: 1 }));
|
|
28
|
+
const dstShape = (0, structs_1.areaShape)(Object.assign(Object.assign({}, this.dst), { base: 1 }));
|
|
29
|
+
const diff = {};
|
|
30
|
+
if (orientation === "horizontal") {
|
|
31
|
+
for (let i = 0; i < dstShape.height; i++) {
|
|
32
|
+
const patterns = this.getChangePatterns(matrix[i]);
|
|
33
|
+
for (let j = 0; j < dstShape.width; j++) {
|
|
34
|
+
const baseCell = matrix[i % srcShape.height][j % srcShape.width];
|
|
35
|
+
const x = sign > 0 ? this.dst.left + j : this.dst.right - j;
|
|
36
|
+
const px = sign > 0 ? j % srcShape.width : (srcShape.width - 1 - (j % srcShape.width)) % srcShape.width;
|
|
37
|
+
diff[(0, converters_1.p2a)({ y: this.dst.top + i, x })] = Object.assign(Object.assign({}, baseCell), { value: patterns[px].next().value });
|
|
48
38
|
}
|
|
49
39
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
for (let i = 0; i < dstShape.width; i++) {
|
|
43
|
+
const patterns = this.getChangePatterns(matrix.map((row) => row[i]));
|
|
44
|
+
for (let j = 0; j < dstShape.height; j++) {
|
|
45
|
+
const baseCell = matrix[i % srcShape.height][j % srcShape.width];
|
|
46
|
+
const y = sign > 0 ? this.dst.top + j : this.dst.bottom - j;
|
|
47
|
+
const py = sign > 0 ? j % srcShape.height : (srcShape.height - 1 - (j % srcShape.height)) % srcShape.height;
|
|
48
|
+
diff[(0, converters_1.p2a)({ y, x: this.dst.left + i })] = Object.assign(Object.assign({}, baseCell), { value: patterns[py].next().value });
|
|
59
49
|
}
|
|
60
50
|
}
|
|
61
|
-
const table = this.table.update({
|
|
62
|
-
diff,
|
|
63
|
-
reflection: {
|
|
64
|
-
selectingZone: (0, structs_1.areaToZone)(this.src),
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
return table;
|
|
68
51
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
52
|
+
const table = this.table.update({
|
|
53
|
+
diff,
|
|
54
|
+
reflection: {
|
|
55
|
+
selectingZone: (0, structs_1.areaToZone)(this.src),
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return table;
|
|
59
|
+
}
|
|
60
|
+
get wholeArea() {
|
|
61
|
+
return (0, structs_1.concatAreas)(this.src, this.dst);
|
|
62
|
+
}
|
|
63
|
+
getCellStyle(target) {
|
|
64
|
+
const { x, y } = target;
|
|
65
|
+
const style = {};
|
|
66
|
+
const { top, left, bottom, right } = this.src;
|
|
67
|
+
switch (this.direction) {
|
|
68
|
+
case "left": {
|
|
69
|
+
if (this.dst.left <= x && x <= this.dst.right) {
|
|
70
|
+
if (top === y) {
|
|
71
|
+
style.borderTop = BORDER_AUTOFILL_DRAGGING;
|
|
85
72
|
}
|
|
86
|
-
if (
|
|
87
|
-
style.
|
|
73
|
+
if (bottom === y - 1) {
|
|
74
|
+
style.borderTop = BORDER_AUTOFILL_DRAGGING;
|
|
88
75
|
}
|
|
89
|
-
break;
|
|
90
76
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
77
|
+
if (this.dst.left === x && top <= y && y <= bottom) {
|
|
78
|
+
style.borderLeft = BORDER_AUTOFILL_DRAGGING;
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case "right": {
|
|
83
|
+
if (this.dst.left <= x && x <= this.dst.right) {
|
|
84
|
+
if (top === y) {
|
|
85
|
+
style.borderTop = BORDER_AUTOFILL_DRAGGING;
|
|
99
86
|
}
|
|
100
|
-
if (
|
|
101
|
-
style.
|
|
87
|
+
if (bottom === y - 1) {
|
|
88
|
+
style.borderTop = BORDER_AUTOFILL_DRAGGING;
|
|
102
89
|
}
|
|
103
|
-
break;
|
|
104
90
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
91
|
+
if (this.dst.right === x - 1 && top <= y && y <= bottom) {
|
|
92
|
+
style.borderLeft = BORDER_AUTOFILL_DRAGGING;
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case "up": {
|
|
97
|
+
if (this.dst.top <= y && y <= this.dst.bottom) {
|
|
98
|
+
if (left === x) {
|
|
99
|
+
style.borderLeft = BORDER_AUTOFILL_DRAGGING;
|
|
113
100
|
}
|
|
114
|
-
if (
|
|
115
|
-
style.
|
|
101
|
+
if (right === x - 1) {
|
|
102
|
+
style.borderLeft = BORDER_AUTOFILL_DRAGGING;
|
|
116
103
|
}
|
|
117
|
-
break;
|
|
118
104
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
105
|
+
if (this.dst.top === y && left <= x && x <= right) {
|
|
106
|
+
style.borderTop = BORDER_AUTOFILL_DRAGGING;
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
case "down": {
|
|
111
|
+
if (this.dst.top <= y && y <= this.dst.bottom) {
|
|
112
|
+
if (left === x) {
|
|
113
|
+
style.borderLeft = BORDER_AUTOFILL_DRAGGING;
|
|
127
114
|
}
|
|
128
|
-
if (
|
|
129
|
-
style.
|
|
115
|
+
if (right === x - 1) {
|
|
116
|
+
style.borderLeft = BORDER_AUTOFILL_DRAGGING;
|
|
130
117
|
}
|
|
131
|
-
break;
|
|
132
118
|
}
|
|
119
|
+
if (this.dst.bottom === y - 1 && left <= x && x <= right) {
|
|
120
|
+
style.borderTop = BORDER_AUTOFILL_DRAGGING;
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
133
123
|
}
|
|
134
|
-
return style;
|
|
135
124
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
125
|
+
return style;
|
|
126
|
+
}
|
|
127
|
+
getDestinationArea(autofillDraggingTo) {
|
|
128
|
+
const { x, y } = autofillDraggingTo;
|
|
129
|
+
const { top, left, bottom, right } = this.src;
|
|
130
|
+
switch (this.direction) {
|
|
131
|
+
case "left":
|
|
132
|
+
return { top, bottom, left: x, right: left - 1 };
|
|
133
|
+
case "right":
|
|
134
|
+
return { top, bottom, left: right + 1, right: x };
|
|
135
|
+
case "up":
|
|
136
|
+
return { left, right, top: y, bottom: top - 1 };
|
|
137
|
+
case "down":
|
|
138
|
+
return { left, right, top: bottom + 1, bottom: y };
|
|
150
139
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return vertical < 0 ? "up" : "down";
|
|
172
|
-
}
|
|
173
|
-
if (horizontal !== 0) {
|
|
140
|
+
return this.src;
|
|
141
|
+
}
|
|
142
|
+
suggestDirection(draggingTo) {
|
|
143
|
+
const { top, left, bottom, right } = this.src;
|
|
144
|
+
let horizontal = 0, vertical = 0;
|
|
145
|
+
if (draggingTo.x < left) {
|
|
146
|
+
horizontal = draggingTo.x - left;
|
|
147
|
+
}
|
|
148
|
+
else if (draggingTo.x > right) {
|
|
149
|
+
horizontal = draggingTo.x - right;
|
|
150
|
+
}
|
|
151
|
+
if (draggingTo.y < top) {
|
|
152
|
+
vertical = draggingTo.y - top;
|
|
153
|
+
}
|
|
154
|
+
else if (draggingTo.y > bottom) {
|
|
155
|
+
vertical = draggingTo.y - bottom;
|
|
156
|
+
}
|
|
157
|
+
// diagonal
|
|
158
|
+
if (Math.abs(horizontal) > 0 && Math.abs(vertical) > 0) {
|
|
159
|
+
if (Math.abs(horizontal) > Math.abs(vertical)) {
|
|
174
160
|
return horizontal < 0 ? "left" : "right";
|
|
175
161
|
}
|
|
176
|
-
|
|
177
|
-
return vertical < 0 ? "up" : "down";
|
|
178
|
-
}
|
|
179
|
-
return "down";
|
|
162
|
+
return vertical < 0 ? "up" : "down";
|
|
180
163
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
164
|
+
if (horizontal !== 0) {
|
|
165
|
+
return horizontal < 0 ? "left" : "right";
|
|
166
|
+
}
|
|
167
|
+
if (vertical !== 0) {
|
|
168
|
+
return vertical < 0 ? "up" : "down";
|
|
169
|
+
}
|
|
170
|
+
return "down";
|
|
171
|
+
}
|
|
172
|
+
;
|
|
173
|
+
getChangePatterns(cells) {
|
|
174
|
+
const result = [];
|
|
175
|
+
const groups = groupByType(cells);
|
|
176
|
+
const [orientation, sign] = DirectionMapping[this.direction];
|
|
177
|
+
groups.forEach((group) => {
|
|
178
|
+
const lastValue = sign > 0 ? group.last : group.first;
|
|
179
|
+
switch (group.kind) {
|
|
180
|
+
case "other": {
|
|
181
|
+
result.push(pass(group.first));
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
case "formula": {
|
|
185
|
+
const value = group.first;
|
|
186
|
+
const table = this.table;
|
|
187
|
+
function* generateFormula() {
|
|
188
|
+
let slide = 0;
|
|
189
|
+
const skip = cells.length * sign;
|
|
190
|
+
while (true) {
|
|
191
|
+
slide += skip;
|
|
192
|
+
yield (0, evaluator_1.convertFormulaAbsolute)({
|
|
193
|
+
value,
|
|
194
|
+
table,
|
|
195
|
+
slideY: orientation === "vertical" ? slide : 0,
|
|
196
|
+
slideX: orientation === "horizontal" ? slide : 0,
|
|
197
|
+
});
|
|
208
198
|
}
|
|
209
|
-
|
|
199
|
+
}
|
|
200
|
+
result.push(generateFormula());
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
case "number": {
|
|
204
|
+
if (!group.equidistant) {
|
|
205
|
+
result.push(pass(group.first), ...group.nexts.map((v) => pass(v)));
|
|
210
206
|
return;
|
|
211
207
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
208
|
+
function* generateNumber() {
|
|
209
|
+
let value = lastValue;
|
|
210
|
+
const skip = group.numericDelta * sign;
|
|
211
|
+
while (true) {
|
|
212
|
+
value += skip;
|
|
213
|
+
yield value;
|
|
216
214
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
215
|
+
}
|
|
216
|
+
const g = generateNumber();
|
|
217
|
+
result.push(g, ...group.nexts.map(() => g));
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
case "date": {
|
|
221
|
+
const next = (d) => {
|
|
222
|
+
return sign > 0 ? group.timeDelta.add(d) : group.timeDelta.sub(d);
|
|
223
|
+
};
|
|
224
|
+
if (!group.equidistant) {
|
|
225
|
+
result.push(pass(group.first), ...group.nexts.map((v) => pass(v)));
|
|
227
226
|
return;
|
|
228
227
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
result.push(pass(group.first), ...group.nexts.map((v) => pass(v)));
|
|
235
|
-
return;
|
|
228
|
+
function* generateDate() {
|
|
229
|
+
let value = lastValue;
|
|
230
|
+
while (true) {
|
|
231
|
+
value = next(value);
|
|
232
|
+
yield new Date(value);
|
|
236
233
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
result.push(g, ...group.nexts.map(() => g));
|
|
234
|
+
}
|
|
235
|
+
const g = generateDate();
|
|
236
|
+
result.push(g, ...group.nexts.map(() => g));
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
case "string+number": {
|
|
240
|
+
if (!group.equidistant) {
|
|
241
|
+
result.push(pass(group.first), ...group.nexts.map((v) => pass(v)));
|
|
246
242
|
return;
|
|
247
243
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
let value = lastNumber;
|
|
257
|
-
const skip = group.numericDelta * sign;
|
|
258
|
-
while (true) {
|
|
259
|
-
value += skip;
|
|
260
|
-
yield `${prefix}${Math.abs(value)}`;
|
|
261
|
-
}
|
|
244
|
+
function* generateStringNumber() {
|
|
245
|
+
const { prefix } = extractStringNumber(group.first);
|
|
246
|
+
const { number: lastNumber } = extractStringNumber(lastValue);
|
|
247
|
+
let value = lastNumber;
|
|
248
|
+
const skip = group.numericDelta * sign;
|
|
249
|
+
while (true) {
|
|
250
|
+
value += skip;
|
|
251
|
+
yield `${prefix}${Math.abs(value)}`;
|
|
262
252
|
}
|
|
263
|
-
const g = generateStringNumber();
|
|
264
|
-
result.push(g, ...group.nexts.map(() => g));
|
|
265
|
-
return;
|
|
266
253
|
}
|
|
254
|
+
const g = generateStringNumber();
|
|
255
|
+
result.push(g, ...group.nexts.map(() => g));
|
|
256
|
+
return;
|
|
267
257
|
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
return result;
|
|
271
261
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
262
|
+
}
|
|
263
|
+
exports.Autofill = Autofill;
|
|
264
|
+
function* pass(value) {
|
|
265
|
+
while (true) {
|
|
266
|
+
yield value;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const StringNumberPattern = new RegExp('(.+?)(\\d+)$');
|
|
270
|
+
const extractStringNumber = (value) => {
|
|
271
|
+
const match = value.match(StringNumberPattern);
|
|
272
|
+
if (match) {
|
|
273
|
+
const [, prefix, n] = match;
|
|
274
|
+
return { prefix, number: Number(n) };
|
|
277
275
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
276
|
+
return { prefix: "", number: 0 };
|
|
277
|
+
};
|
|
278
|
+
class TypedGroup {
|
|
279
|
+
constructor(value) {
|
|
280
|
+
this.timeDelta = time_1.TimeDelta.create();
|
|
281
|
+
this.numericDelta = 0;
|
|
282
|
+
this.equidistant = true;
|
|
283
|
+
this.first = value;
|
|
284
|
+
this.nexts = [];
|
|
285
|
+
this.kind = this.discriminate(value);
|
|
286
|
+
}
|
|
287
|
+
discriminate(value) {
|
|
288
|
+
let kind = value instanceof Date ? "date" : typeof value;
|
|
289
|
+
if (kind === "number" || kind === "date") {
|
|
290
|
+
return kind;
|
|
284
291
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
class TypedGroup {
|
|
288
|
-
constructor(value) {
|
|
289
|
-
this.timeDelta = time_1.TimeDelta.create();
|
|
290
|
-
this.numericDelta = 0;
|
|
291
|
-
this.equidistant = true;
|
|
292
|
-
this.first = value;
|
|
293
|
-
this.nexts = [];
|
|
294
|
-
this.kind = this.discriminate(value);
|
|
292
|
+
if (kind === "string" && value[0] === "=") {
|
|
293
|
+
return "formula";
|
|
295
294
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
if (kind === "number" || kind === "date") {
|
|
299
|
-
return kind;
|
|
300
|
-
}
|
|
301
|
-
if (kind === "string" && value[0] === "=") {
|
|
302
|
-
return "formula";
|
|
303
|
-
}
|
|
304
|
-
else if (kind === "string" && value.match(StringNumberPattern)) {
|
|
305
|
-
return "string+number";
|
|
306
|
-
}
|
|
307
|
-
return "other";
|
|
295
|
+
else if (kind === "string" && value.match(StringNumberPattern)) {
|
|
296
|
+
return "string+number";
|
|
308
297
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
return this.
|
|
298
|
+
return "other";
|
|
299
|
+
}
|
|
300
|
+
get last() {
|
|
301
|
+
if (this.nexts.length === 0) {
|
|
302
|
+
return this.first;
|
|
314
303
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
switch (kind) {
|
|
322
|
-
case "date": {
|
|
323
|
-
this.timeDelta = new time_1.TimeDelta(value, this.first);
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
case "number": {
|
|
327
|
-
this.numericDelta = value - this.first;
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
330
|
-
case "string+number": {
|
|
331
|
-
const { prefix: prefix1, number: number1 } = extractStringNumber(this.first);
|
|
332
|
-
const { prefix: prefix2, number: number2 } = extractStringNumber(value);
|
|
333
|
-
if (prefix1 === prefix2) {
|
|
334
|
-
this.numericDelta = number2 - number1;
|
|
335
|
-
}
|
|
336
|
-
break;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
this.nexts.push(value);
|
|
304
|
+
return this.nexts[this.nexts.length - 1];
|
|
305
|
+
}
|
|
306
|
+
add(value) {
|
|
307
|
+
const kind = this.discriminate(value);
|
|
308
|
+
if (this.kind !== kind || kind === "other" || kind === "formula") {
|
|
309
|
+
return new TypedGroup(value);
|
|
341
310
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
return [];
|
|
345
|
-
}
|
|
346
|
-
const news = [];
|
|
347
|
-
let lastGroup = this;
|
|
348
|
-
switch (this.kind) {
|
|
311
|
+
if (this.nexts.length === 0) {
|
|
312
|
+
switch (kind) {
|
|
349
313
|
case "date": {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return [];
|
|
314
|
+
this.timeDelta = new time_1.TimeDelta(value, this.first);
|
|
315
|
+
break;
|
|
353
316
|
}
|
|
354
317
|
case "number": {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
return [];
|
|
318
|
+
this.numericDelta = value - this.first;
|
|
319
|
+
break;
|
|
358
320
|
}
|
|
359
321
|
case "string+number": {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
if (basePrefix !== prefix) {
|
|
365
|
-
const nexts = this.nexts.splice(i, this.nexts.length);
|
|
366
|
-
lastGroup = new TypedGroup(nexts.splice(0, 1)[0]);
|
|
367
|
-
nexts.forEach(lastGroup.add.bind(lastGroup));
|
|
368
|
-
news.push(lastGroup, ...lastGroup.subdivide());
|
|
369
|
-
break;
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
const { number: firstNumber } = extractStringNumber(lastGroup.first);
|
|
373
|
-
if (number !== firstNumber + (i + 1) * lastGroup.numericDelta) {
|
|
374
|
-
lastGroup.equidistant = false;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
322
|
+
const { prefix: prefix1, number: number1 } = extractStringNumber(this.first);
|
|
323
|
+
const { prefix: prefix2, number: number2 } = extractStringNumber(value);
|
|
324
|
+
if (prefix1 === prefix2) {
|
|
325
|
+
this.numericDelta = number2 - number1;
|
|
377
326
|
}
|
|
378
327
|
break;
|
|
379
328
|
}
|
|
380
329
|
}
|
|
381
|
-
return news;
|
|
382
330
|
}
|
|
331
|
+
this.nexts.push(value);
|
|
383
332
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
333
|
+
subdivide() {
|
|
334
|
+
if (this.nexts.length === 0) {
|
|
335
|
+
return [];
|
|
336
|
+
}
|
|
337
|
+
const news = [];
|
|
338
|
+
let lastGroup = this;
|
|
339
|
+
switch (this.kind) {
|
|
340
|
+
case "date": {
|
|
341
|
+
const eq = this.nexts.every((v, i) => i === 0 || (0, date_fns_1.isEqual)(v, this.timeDelta.add(this.nexts[i - 1])));
|
|
342
|
+
this.equidistant = eq;
|
|
343
|
+
return [];
|
|
344
|
+
}
|
|
345
|
+
case "number": {
|
|
346
|
+
const eq = this.nexts.every((v, i) => i === 0 || v === this.first + this.numericDelta * (i + 1));
|
|
347
|
+
this.equidistant = eq;
|
|
348
|
+
return [];
|
|
349
|
+
}
|
|
350
|
+
case "string+number": {
|
|
351
|
+
let { prefix: basePrefix, number: baseNumber } = extractStringNumber(this.first);
|
|
352
|
+
for (let i = 0; i < lastGroup.nexts.length; i++) {
|
|
353
|
+
const next = lastGroup.nexts[i];
|
|
354
|
+
const { prefix, number } = extractStringNumber(next);
|
|
355
|
+
if (basePrefix !== prefix) {
|
|
356
|
+
const nexts = this.nexts.splice(i, this.nexts.length);
|
|
357
|
+
lastGroup = new TypedGroup(nexts.splice(0, 1)[0]);
|
|
358
|
+
nexts.forEach(lastGroup.add.bind(lastGroup));
|
|
359
|
+
news.push(lastGroup, ...lastGroup.subdivide());
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
const { number: firstNumber } = extractStringNumber(lastGroup.first);
|
|
364
|
+
if (number !== firstNumber + (i + 1) * lastGroup.numericDelta) {
|
|
365
|
+
lastGroup.equidistant = false;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
break;
|
|
394
370
|
}
|
|
395
371
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
372
|
+
return news;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function groupByType(cells) {
|
|
376
|
+
var _a, _b;
|
|
377
|
+
let group = new TypedGroup((_a = cells[0]) === null || _a === void 0 ? void 0 : _a.value);
|
|
378
|
+
const groups = [group];
|
|
379
|
+
for (let i = 1; i < cells.length; i++) {
|
|
380
|
+
const value = (_b = cells[i]) === null || _b === void 0 ? void 0 : _b.value;
|
|
381
|
+
const nextGroup = group.add(value);
|
|
382
|
+
if (nextGroup) {
|
|
383
|
+
groups.push(nextGroup);
|
|
384
|
+
group = nextGroup;
|
|
399
385
|
}
|
|
400
|
-
return groups;
|
|
401
386
|
}
|
|
402
|
-
|
|
387
|
+
for (let i = groups.length - 1; i >= 0; i--) {
|
|
388
|
+
const group = groups[i];
|
|
389
|
+
groups.splice(i + 1, 0, ...group.subdivide());
|
|
390
|
+
}
|
|
391
|
+
return groups;
|
|
392
|
+
}
|
|
403
393
|
//# sourceMappingURL=autofill.js.map
|