@gridsheet/react-core 0.12.3 → 0.12.4-rc.0

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