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