handsontable 12.3.3-next-e19badf-20230328 → 12.4.0-next-ddbea0c-20230512

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. package/3rdparty/walkontable/src/cell/coords.js +13 -16
  2. package/3rdparty/walkontable/src/cell/coords.mjs +13 -16
  3. package/3rdparty/walkontable/src/cell/range.js +25 -29
  4. package/3rdparty/walkontable/src/cell/range.mjs +24 -28
  5. package/3rdparty/walkontable/src/event.js +4 -0
  6. package/3rdparty/walkontable/src/event.mjs +4 -0
  7. package/3rdparty/walkontable/src/overlay/_base.js +6 -7
  8. package/3rdparty/walkontable/src/overlay/_base.mjs +6 -7
  9. package/3rdparty/walkontable/src/overlay/bottom.js +6 -7
  10. package/3rdparty/walkontable/src/overlay/bottom.mjs +6 -7
  11. package/3rdparty/walkontable/src/overlay/top.js +6 -7
  12. package/3rdparty/walkontable/src/overlay/top.mjs +6 -7
  13. package/3rdparty/walkontable/src/overlay/topInlineStartCorner.js +10 -12
  14. package/3rdparty/walkontable/src/overlay/topInlineStartCorner.mjs +10 -12
  15. package/3rdparty/walkontable/src/overlays.js +55 -64
  16. package/3rdparty/walkontable/src/overlays.mjs +55 -64
  17. package/3rdparty/walkontable/src/scroll.js +20 -23
  18. package/3rdparty/walkontable/src/scroll.mjs +20 -23
  19. package/3rdparty/walkontable/src/settings.js +13 -15
  20. package/3rdparty/walkontable/src/settings.mjs +13 -15
  21. package/3rdparty/walkontable/src/table.js +22 -26
  22. package/3rdparty/walkontable/src/table.mjs +22 -26
  23. package/CHANGELOG.md +14 -0
  24. package/base.js +2 -4
  25. package/base.mjs +2 -2
  26. package/core.js +23 -6
  27. package/core.mjs +23 -6
  28. package/dataMap/dataSource.js +5 -5
  29. package/dataMap/dataSource.mjs +5 -5
  30. package/dataMap/metaManager/metaSchema.js +9 -7
  31. package/dataMap/metaManager/metaSchema.mjs +9 -7
  32. package/dist/handsontable.css +2 -2
  33. package/dist/handsontable.full.css +2 -2
  34. package/dist/handsontable.full.js +5047 -4193
  35. package/dist/handsontable.full.min.css +2 -2
  36. package/dist/handsontable.full.min.js +86 -78
  37. package/dist/handsontable.js +4023 -3170
  38. package/dist/handsontable.min.css +2 -2
  39. package/dist/handsontable.min.js +11 -3
  40. package/dist/languages/all.js +133 -0
  41. package/dist/languages/ar-AR.js +7 -0
  42. package/dist/languages/cs-CZ.js +7 -0
  43. package/dist/languages/de-CH.js +7 -0
  44. package/dist/languages/de-DE.js +7 -0
  45. package/dist/languages/en-US.js +7 -0
  46. package/dist/languages/es-MX.js +7 -0
  47. package/dist/languages/fr-FR.js +7 -0
  48. package/dist/languages/it-IT.js +7 -0
  49. package/dist/languages/ja-JP.js +7 -0
  50. package/dist/languages/ko-KR.js +7 -0
  51. package/dist/languages/lv-LV.js +7 -0
  52. package/dist/languages/nb-NO.js +7 -0
  53. package/dist/languages/nl-NL.js +7 -0
  54. package/dist/languages/pl-PL.js +7 -0
  55. package/dist/languages/pt-BR.js +7 -0
  56. package/dist/languages/ru-RU.js +7 -0
  57. package/dist/languages/sr-SP.js +7 -0
  58. package/dist/languages/zh-CN.js +7 -0
  59. package/dist/languages/zh-TW.js +7 -0
  60. package/helpers/mixed.js +2 -2
  61. package/helpers/mixed.mjs +2 -2
  62. package/i18n/languages/ar-AR.js +7 -1
  63. package/i18n/languages/cs-CZ.js +7 -1
  64. package/i18n/languages/de-CH.js +7 -1
  65. package/i18n/languages/de-DE.js +7 -1
  66. package/i18n/languages/en-US.js +7 -1
  67. package/i18n/languages/es-MX.js +7 -1
  68. package/i18n/languages/fr-FR.js +7 -1
  69. package/i18n/languages/it-IT.js +7 -1
  70. package/i18n/languages/ja-JP.js +7 -1
  71. package/i18n/languages/ko-KR.js +7 -1
  72. package/i18n/languages/lv-LV.js +7 -1
  73. package/i18n/languages/nb-NO.js +7 -1
  74. package/i18n/languages/nl-NL.js +7 -1
  75. package/i18n/languages/pl-PL.js +7 -1
  76. package/i18n/languages/pt-BR.js +7 -1
  77. package/i18n/languages/ru-RU.js +7 -1
  78. package/i18n/languages/sr-SP.js +7 -1
  79. package/i18n/languages/zh-CN.js +7 -1
  80. package/i18n/languages/zh-TW.js +7 -1
  81. package/languages/all.js +133 -0
  82. package/languages/ar-AR.js +7 -0
  83. package/languages/cs-CZ.js +7 -0
  84. package/languages/de-CH.js +7 -0
  85. package/languages/de-DE.js +7 -0
  86. package/languages/en-US.js +7 -0
  87. package/languages/es-MX.js +7 -0
  88. package/languages/fr-FR.js +7 -0
  89. package/languages/index.js +133 -0
  90. package/languages/it-IT.js +7 -0
  91. package/languages/ja-JP.js +7 -0
  92. package/languages/ko-KR.js +7 -0
  93. package/languages/lv-LV.js +7 -0
  94. package/languages/nb-NO.js +7 -0
  95. package/languages/nl-NL.js +7 -0
  96. package/languages/pl-PL.js +7 -0
  97. package/languages/pt-BR.js +7 -0
  98. package/languages/ru-RU.js +7 -0
  99. package/languages/sr-SP.js +7 -0
  100. package/languages/zh-CN.js +7 -0
  101. package/languages/zh-TW.js +7 -0
  102. package/package.json +3 -2
  103. package/pluginHooks.js +16 -6
  104. package/pluginHooks.mjs +15 -3
  105. package/plugins/autoRowSize/autoRowSize.js +2 -2
  106. package/plugins/autoRowSize/autoRowSize.mjs +2 -2
  107. package/plugins/copyPaste/copyableRanges.js +25 -31
  108. package/plugins/copyPaste/copyableRanges.mjs +18 -24
  109. package/plugins/customBorders/customBorders.d.ts +2 -0
  110. package/plugins/filters/filters.js +5 -0
  111. package/plugins/filters/filters.mjs +5 -0
  112. package/plugins/formulas/engine/register.js +9 -0
  113. package/plugins/formulas/engine/register.mjs +13 -4
  114. package/plugins/formulas/engine/settings.js +18 -3
  115. package/plugins/formulas/engine/settings.mjs +16 -3
  116. package/plugins/formulas/formulas.js +274 -155
  117. package/plugins/formulas/formulas.mjs +274 -156
  118. package/plugins/formulas/indexSyncer/axisSyncer.js +379 -0
  119. package/plugins/formulas/indexSyncer/axisSyncer.mjs +374 -0
  120. package/plugins/formulas/indexSyncer/index.js +225 -0
  121. package/plugins/formulas/indexSyncer/index.mjs +219 -0
  122. package/plugins/formulas/utils.js +81 -0
  123. package/plugins/formulas/utils.mjs +74 -0
  124. package/plugins/manualRowMove/manualRowMove.js +26 -11
  125. package/plugins/manualRowMove/manualRowMove.mjs +27 -12
  126. package/plugins/nestedHeaders/stateManager/headersTree.js +23 -26
  127. package/plugins/nestedHeaders/stateManager/headersTree.mjs +20 -23
  128. package/plugins/nestedHeaders/stateManager/index.js +3 -3
  129. package/plugins/nestedHeaders/stateManager/matrixGenerator.js +1 -0
  130. package/plugins/nestedHeaders/stateManager/settingsNormalizer.js +1 -1
  131. package/plugins/nestedHeaders/utils/ghostTable.js +30 -35
  132. package/plugins/nestedHeaders/utils/ghostTable.mjs +30 -35
  133. package/plugins/registry.js +3 -1
  134. package/plugins/undoRedo/undoRedo.js +0 -1
  135. package/plugins/undoRedo/undoRedo.mjs +0 -1
  136. package/selection/highlight/visualSelection.js +5 -6
  137. package/selection/highlight/visualSelection.mjs +5 -6
  138. package/tableView.js +62 -72
  139. package/tableView.mjs +62 -72
  140. package/translations/changesObservable/observable.js +41 -46
  141. package/translations/changesObservable/observable.mjs +36 -41
  142. package/translations/changesObservable/observer.js +1 -1
  143. package/translations/indexMapper.js +21 -0
  144. package/translations/indexMapper.mjs +21 -0
  145. package/utils/dataStructures/tree.js +15 -18
  146. package/utils/dataStructures/tree.mjs +15 -18
  147. package/utils/parseTable.js +5 -1
  148. package/utils/parseTable.mjs +5 -1
@@ -0,0 +1,374 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ import "core-js/modules/es.array.map.js";
3
+ import "core-js/modules/es.array.index-of.js";
4
+ import "core-js/modules/es.object.to-string.js";
5
+ import "core-js/modules/web.dom-collections.for-each.js";
6
+ import "core-js/modules/es.array.filter.js";
7
+ import "core-js/modules/es.array.from.js";
8
+ import "core-js/modules/es.string.iterator.js";
9
+ import "core-js/modules/es.array.iterator.js";
10
+ import "core-js/modules/web.dom-collections.iterator.js";
11
+ import "core-js/modules/es.array.includes.js";
12
+ import "core-js/modules/es.string.includes.js";
13
+ import "core-js/modules/es.array.slice.js";
14
+ import "core-js/modules/es.weak-map.js";
15
+ import "core-js/modules/es.symbol.to-primitive.js";
16
+ import "core-js/modules/es.date.to-primitive.js";
17
+ import "core-js/modules/es.symbol.js";
18
+ import "core-js/modules/es.symbol.description.js";
19
+ import "core-js/modules/es.number.constructor.js";
20
+ import "core-js/modules/es.symbol.iterator.js";
21
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
23
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
24
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
25
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
26
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
27
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
28
+ function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
29
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
30
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
31
+ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
32
+ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
33
+ import { toUpperCaseFirst } from "../../../helpers/string.mjs";
34
+ /**
35
+ * @private
36
+ * @class IndexSyncer
37
+ * @description
38
+ *
39
+ * Indexes synchronizer responsible for providing logic for particular axis. It respects an idea to represent trimmed
40
+ * elements in HF's engine to perform formulas calculations on them. It also provides method for translation from visual
41
+ * row/column indexes to HF's row/column indexes.
42
+ */
43
+ var _axis = /*#__PURE__*/new WeakMap();
44
+ var _indexMapper = /*#__PURE__*/new WeakMap();
45
+ var _indexSyncer = /*#__PURE__*/new WeakMap();
46
+ var _indexesSequence = /*#__PURE__*/new WeakMap();
47
+ var _movedIndexes = /*#__PURE__*/new WeakMap();
48
+ var _finalIndex = /*#__PURE__*/new WeakMap();
49
+ var _removedIndexes = /*#__PURE__*/new WeakMap();
50
+ var AxisSyncer = /*#__PURE__*/function () {
51
+ function AxisSyncer(axis, indexMapper, indexSyncer) {
52
+ _classCallCheck(this, AxisSyncer);
53
+ /**
54
+ * The axis for which the actions are performed.
55
+ *
56
+ * @private
57
+ * @type {'row'|'column'}
58
+ */
59
+ _classPrivateFieldInitSpec(this, _axis, {
60
+ writable: true,
61
+ value: void 0
62
+ });
63
+ /**
64
+ * Reference to index mapper.
65
+ *
66
+ * @private
67
+ * @type {IndexMapper}
68
+ */
69
+ _classPrivateFieldInitSpec(this, _indexMapper, {
70
+ writable: true,
71
+ value: void 0
72
+ });
73
+ /**
74
+ * The index synchronizer for both axis (is storing some more general information).
75
+ *
76
+ * @private
77
+ * @type {IndexSyncer}
78
+ */
79
+ _classPrivateFieldInitSpec(this, _indexSyncer, {
80
+ writable: true,
81
+ value: void 0
82
+ });
83
+ /**
84
+ * Sequence of physical indexes stored for watching changes and calculating some transformations.
85
+ *
86
+ * @private
87
+ * @type {Array<number>}
88
+ */
89
+ _classPrivateFieldInitSpec(this, _indexesSequence, {
90
+ writable: true,
91
+ value: []
92
+ });
93
+ /**
94
+ * List of moved HF indexes, stored before performing move on HOT to calculate transformation needed on HF's engine.
95
+ *
96
+ * @private
97
+ * @type {Array<number>}
98
+ */
99
+ _classPrivateFieldInitSpec(this, _movedIndexes, {
100
+ writable: true,
101
+ value: []
102
+ });
103
+ /**
104
+ * Final HF's place where to move indexes, stored before performing move on HOT to calculate transformation needed on HF's engine.
105
+ *
106
+ * @private
107
+ * @type {number|undefined}
108
+ */
109
+ _classPrivateFieldInitSpec(this, _finalIndex, {
110
+ writable: true,
111
+ value: void 0
112
+ });
113
+ /**
114
+ * List of removed HF indexes, stored before performing removal on HOT to calculate transformation needed on HF's engine.
115
+ *
116
+ * @private
117
+ * @type {Array<number>}
118
+ */
119
+ _classPrivateFieldInitSpec(this, _removedIndexes, {
120
+ writable: true,
121
+ value: []
122
+ });
123
+ _classPrivateFieldSet(this, _axis, axis);
124
+ _classPrivateFieldSet(this, _indexMapper, indexMapper);
125
+ _classPrivateFieldSet(this, _indexSyncer, indexSyncer);
126
+ }
127
+
128
+ /**
129
+ * Sets removed HF indexes (it should be done right before performing move on HOT).
130
+ *
131
+ * @param {Array<number>} removedIndexes List of removed physical indexes.
132
+ * @returns {Array<number>} List of removed visual indexes.
133
+ */
134
+ _createClass(AxisSyncer, [{
135
+ key: "setRemovedHfIndexes",
136
+ value: function setRemovedHfIndexes(removedIndexes) {
137
+ var _this = this;
138
+ _classPrivateFieldSet(this, _removedIndexes, removedIndexes.map(function (physicalIndex) {
139
+ var visualIndex = _classPrivateFieldGet(_this, _indexMapper).getVisualFromPhysicalIndex(physicalIndex);
140
+ return _this.getHfIndexFromVisualIndex(visualIndex);
141
+ }));
142
+ return _classPrivateFieldGet(this, _removedIndexes);
143
+ }
144
+
145
+ /**
146
+ * Gets removed HF indexes (right before performing removal on HOT).
147
+ *
148
+ * @returns {Array<number>} List of removed HF indexes.
149
+ */
150
+ }, {
151
+ key: "getRemovedHfIndexes",
152
+ value: function getRemovedHfIndexes() {
153
+ return _classPrivateFieldGet(this, _removedIndexes);
154
+ }
155
+
156
+ /**
157
+ * Gets corresponding HyperFormula index for particular visual index. It's respecting the idea that HF's engine
158
+ * is fed also with trimmed indexes (business requirements for formula result calculation also for trimmed elements).
159
+ *
160
+ * @param {number} visualIndex Visual index.
161
+ * @returns {number}
162
+ */
163
+ }, {
164
+ key: "getHfIndexFromVisualIndex",
165
+ value: function getHfIndexFromVisualIndex(visualIndex) {
166
+ var indexesSequence = _classPrivateFieldGet(this, _indexMapper).getIndexesSequence();
167
+ var notTrimmedIndexes = _classPrivateFieldGet(this, _indexMapper).getNotTrimmedIndexes();
168
+ return indexesSequence.indexOf(notTrimmedIndexes[visualIndex]);
169
+ }
170
+
171
+ /**
172
+ * Synchronizes moves done on HOT to HF engine (based on previously calculated positions).
173
+ *
174
+ * @private
175
+ * @param {Array<{from: number, to: number}>} moves Calculated HF's move positions.
176
+ */
177
+ }, {
178
+ key: "syncMoves",
179
+ value: function syncMoves(moves) {
180
+ var _this2 = this;
181
+ var NUMBER_OF_MOVED_INDEXES = 1;
182
+ var SYNC_MOVE_METHOD_NAME = "move".concat(toUpperCaseFirst(_classPrivateFieldGet(this, _axis)), "s");
183
+ _classPrivateFieldGet(this, _indexSyncer).getEngine().batch(function () {
184
+ moves.forEach(function (move) {
185
+ var moveToTheSamePosition = move.from !== move.to;
186
+ // Moving from left to right (or top to bottom) to a line (drop index) right after already moved element.
187
+ var anotherMoveWithoutEffect = move.from + 1 !== move.to;
188
+ if (moveToTheSamePosition && anotherMoveWithoutEffect) {
189
+ _classPrivateFieldGet(_this2, _indexSyncer).getEngine()[SYNC_MOVE_METHOD_NAME](_classPrivateFieldGet(_this2, _indexSyncer).getSheetId(), move.from, NUMBER_OF_MOVED_INDEXES, move.to);
190
+ }
191
+ });
192
+ });
193
+ }
194
+
195
+ /**
196
+ * Stores information about performed HOT moves for purpose of calculating where to move HF elements.
197
+ *
198
+ * @param {Array<number>} movedVisualIndexes Sequence of moved visual indexes for certain axis.
199
+ * @param {number} visualFinalIndex Final visual place where to move HOT indexes.
200
+ * @param {boolean} movePossible Indicates if it's possible to move HOT indexes to the desired position.
201
+ */
202
+ }, {
203
+ key: "storeMovesInformation",
204
+ value: function storeMovesInformation(movedVisualIndexes, visualFinalIndex, movePossible) {
205
+ var _this3 = this;
206
+ if (movePossible === false) {
207
+ return;
208
+ }
209
+ _classPrivateFieldSet(this, _movedIndexes, movedVisualIndexes.map(function (index) {
210
+ return _this3.getHfIndexFromVisualIndex(index);
211
+ }));
212
+ _classPrivateFieldSet(this, _finalIndex, this.getHfIndexFromVisualIndex(visualFinalIndex));
213
+ }
214
+
215
+ /**
216
+ * Gets first position where to move element (respecting the fact that some element will be sooner or later
217
+ * taken out of the dataset in order to move them).
218
+ *
219
+ * @param {Array<number>} movedHfIndexes Sequence of moved HF indexes for certain axis.
220
+ * @param {number} finalHfIndex Final HF place where to move rows.
221
+ * @returns {number} HF's index informing where to move the first element.
222
+ * @private
223
+ */
224
+ }, {
225
+ key: "getMoveLine",
226
+ value: function getMoveLine(movedHfIndexes, finalHfIndex) {
227
+ var numberOfElements = _classPrivateFieldGet(this, _indexMapper).getNumberOfIndexes();
228
+ var notMovedElements = Array.from(Array(numberOfElements).keys()).filter(function (index) {
229
+ return movedHfIndexes.includes(index) === false;
230
+ });
231
+ if (finalHfIndex === 0) {
232
+ var _notMovedElements$fin;
233
+ return (_notMovedElements$fin = notMovedElements[finalHfIndex]) !== null && _notMovedElements$fin !== void 0 ? _notMovedElements$fin : 0; // Moving before the first dataset's element.
234
+ }
235
+
236
+ return notMovedElements[finalHfIndex - 1] + 1; // Moving before another element.
237
+ }
238
+
239
+ /**
240
+ * Gets initially calculated HF's move positions.
241
+ *
242
+ * @private
243
+ * @param {Array<number>} movedHfIndexes Sequence of moved HF indexes for certain axis.
244
+ * @param {number} finalHfIndex Final HF place where to move rows.
245
+ * @returns {Array<{from: number, to: number}>} Initially calculated HF's move positions.
246
+ */
247
+ }, {
248
+ key: "getInitiallyCalculatedMoves",
249
+ value: function getInitiallyCalculatedMoves(movedHfIndexes, finalHfIndex) {
250
+ var moveLine = this.getMoveLine(movedHfIndexes, finalHfIndex);
251
+ var moves = [];
252
+ movedHfIndexes.forEach(function (movedHfIndex) {
253
+ var move = {
254
+ from: movedHfIndex,
255
+ to: moveLine
256
+ };
257
+ moves.forEach(function (previouslyMovedIndex) {
258
+ var isMovingFromEndToStart = previouslyMovedIndex.from > previouslyMovedIndex.to;
259
+ var isMovingElementBefore = previouslyMovedIndex.to <= move.from;
260
+ var isMovingAfterElement = previouslyMovedIndex.from > move.from;
261
+ if (isMovingAfterElement && isMovingElementBefore && isMovingFromEndToStart) {
262
+ move.from += 1;
263
+ }
264
+ });
265
+
266
+ // Moved element from right to left (or bottom to top).
267
+ if (move.from >= moveLine) {
268
+ moveLine += 1;
269
+ }
270
+ moves.push(move);
271
+ });
272
+ return moves;
273
+ }
274
+
275
+ /**
276
+ * Gets finally calculated HF's move positions (after adjusting).
277
+ *
278
+ * @private
279
+ * @param {Array<{from: number, to: number}>} moves Initially calculated HF's move positions.
280
+ * @returns {Array<{from: number, to: number}>} Finally calculated HF's move positions (after adjusting).
281
+ */
282
+ }, {
283
+ key: "adjustedCalculatedMoves",
284
+ value: function adjustedCalculatedMoves(moves) {
285
+ moves.forEach(function (move, index) {
286
+ var nextMoved = moves.slice(index + 1);
287
+ nextMoved.forEach(function (nextMovedIndex) {
288
+ var isMovingFromStartToEnd = nextMovedIndex.from < nextMovedIndex.to;
289
+ if (nextMovedIndex.from > move.from && isMovingFromStartToEnd) {
290
+ nextMovedIndex.from -= 1;
291
+ }
292
+ });
293
+ });
294
+ return moves;
295
+ }
296
+
297
+ /**
298
+ * Calculating where to move HF elements and performing already calculated moves.
299
+ *
300
+ * @param {boolean} movePossible Indicates if it was possible to move HOT indexes to the desired position.
301
+ * @param {boolean} orderChanged Indicates if order of HOT indexes was changed by move.
302
+ */
303
+ }, {
304
+ key: "calculateAndSyncMoves",
305
+ value: function calculateAndSyncMoves(movePossible, orderChanged) {
306
+ var _this4 = this;
307
+ if (_classPrivateFieldGet(this, _indexSyncer).isPerformingUndoRedo()) {
308
+ return;
309
+ }
310
+ if (movePossible === false || orderChanged === false) {
311
+ return;
312
+ }
313
+ var calculatedMoves = this.adjustedCalculatedMoves(this.getInitiallyCalculatedMoves(_classPrivateFieldGet(this, _movedIndexes), _classPrivateFieldGet(this, _finalIndex)));
314
+ if (_classPrivateFieldGet(this, _indexSyncer).getSheetId() === null) {
315
+ _classPrivateFieldGet(this, _indexSyncer).getPostponeAction(function () {
316
+ return _this4.syncMoves(calculatedMoves);
317
+ });
318
+ } else {
319
+ this.syncMoves(calculatedMoves);
320
+ }
321
+ }
322
+
323
+ /**
324
+ * Gets callback for hook triggered after performing change of indexes order.
325
+ *
326
+ * @returns {Function}
327
+ */
328
+ }, {
329
+ key: "getIndexesChangeSyncMethod",
330
+ value: function getIndexesChangeSyncMethod() {
331
+ var _this5 = this;
332
+ var SYNC_ORDER_CHANGE_METHOD_NAME = "set".concat(toUpperCaseFirst(_classPrivateFieldGet(this, _axis)), "Order");
333
+ return function (source) {
334
+ if (_classPrivateFieldGet(_this5, _indexSyncer).isPerformingUndoRedo()) {
335
+ return;
336
+ }
337
+ var newSequence = _classPrivateFieldGet(_this5, _indexMapper).getIndexesSequence();
338
+ if (source === 'update') {
339
+ var relativeTransformation = _classPrivateFieldGet(_this5, _indexesSequence).map(function (index) {
340
+ return newSequence.indexOf(index);
341
+ });
342
+ var sheetDimensions = _classPrivateFieldGet(_this5, _indexSyncer).getEngine().getSheetDimensions(_classPrivateFieldGet(_this5, _indexSyncer).getSheetId());
343
+ var sizeForAxis;
344
+ if (_classPrivateFieldGet(_this5, _axis) === 'row') {
345
+ sizeForAxis = sheetDimensions.height;
346
+ } else {
347
+ sizeForAxis = sheetDimensions.width;
348
+ }
349
+ var numberOfReorganisedIndexes = relativeTransformation.length;
350
+
351
+ // Sheet dimension can be changed by HF's engine for purpose of calculating values. It extends dependency
352
+ // graph to calculate values outside of a defined dataset. This part of code could be removed after resolving
353
+ // feature request from HF issue board (handsontable/hyperformula#1179).
354
+ for (var i = numberOfReorganisedIndexes; i < sizeForAxis; i += 1) {
355
+ relativeTransformation.push(i);
356
+ }
357
+ _classPrivateFieldGet(_this5, _indexSyncer).getEngine()[SYNC_ORDER_CHANGE_METHOD_NAME](_classPrivateFieldGet(_this5, _indexSyncer).getSheetId(), relativeTransformation);
358
+ }
359
+ _classPrivateFieldSet(_this5, _indexesSequence, newSequence);
360
+ };
361
+ }
362
+
363
+ /**
364
+ * Initialize the AxisSyncer.
365
+ */
366
+ }, {
367
+ key: "init",
368
+ value: function init() {
369
+ _classPrivateFieldSet(this, _indexesSequence, _classPrivateFieldGet(this, _indexMapper).getIndexesSequence());
370
+ }
371
+ }]);
372
+ return AxisSyncer;
373
+ }();
374
+ export default AxisSyncer;
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.symbol.to-primitive.js");
4
+ require("core-js/modules/es.date.to-primitive.js");
5
+ require("core-js/modules/es.symbol.js");
6
+ require("core-js/modules/es.symbol.description.js");
7
+ require("core-js/modules/es.number.constructor.js");
8
+ require("core-js/modules/es.symbol.iterator.js");
9
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
10
+ exports.__esModule = true;
11
+ exports.default = void 0;
12
+ require("core-js/modules/es.array.iterator.js");
13
+ require("core-js/modules/es.object.to-string.js");
14
+ require("core-js/modules/es.string.iterator.js");
15
+ require("core-js/modules/es.weak-map.js");
16
+ require("core-js/modules/web.dom-collections.iterator.js");
17
+ var _axisSyncer = _interopRequireDefault(require("./axisSyncer"));
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
21
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
22
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
23
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
24
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
25
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
26
+ function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
27
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
28
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
29
+ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
30
+ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
31
+ /**
32
+ * @private
33
+ * @class IndexSyncer
34
+ * @description
35
+ *
36
+ * Indexes synchronizer responsible for providing logic for syncing actions done on indexes for HOT to actions performed
37
+ * on HF's.
38
+ *
39
+ */
40
+ var _rowIndexSyncer = /*#__PURE__*/new WeakMap();
41
+ var _columnIndexSyncer = /*#__PURE__*/new WeakMap();
42
+ var _postponeAction = /*#__PURE__*/new WeakMap();
43
+ var _isPerformingUndo = /*#__PURE__*/new WeakMap();
44
+ var _isPerformingRedo = /*#__PURE__*/new WeakMap();
45
+ var _engine = /*#__PURE__*/new WeakMap();
46
+ var _sheetId = /*#__PURE__*/new WeakMap();
47
+ var IndexSyncer = /*#__PURE__*/function () {
48
+ function IndexSyncer(rowIndexMapper, columnIndexMapper, postponeAction) {
49
+ _classCallCheck(this, IndexSyncer);
50
+ /**
51
+ * Indexes synchronizer for the axis of the rows.
52
+ *
53
+ * @private
54
+ * @type {AxisSyncer}
55
+ */
56
+ _classPrivateFieldInitSpec(this, _rowIndexSyncer, {
57
+ writable: true,
58
+ value: void 0
59
+ });
60
+ /**
61
+ * Indexes synchronizer for the axis of the columns.
62
+ *
63
+ * @private
64
+ * @type {AxisSyncer}
65
+ */
66
+ _classPrivateFieldInitSpec(this, _columnIndexSyncer, {
67
+ writable: true,
68
+ value: void 0
69
+ });
70
+ /**
71
+ * Method which will postpone execution of some action (needed when synchronization endpoint isn't setup yet).
72
+ *
73
+ * @private
74
+ * @type {Function}
75
+ */
76
+ _classPrivateFieldInitSpec(this, _postponeAction, {
77
+ writable: true,
78
+ value: void 0
79
+ });
80
+ /**
81
+ * Flag informing whether undo is already performed (we don't perform synchronization in such case).
82
+ *
83
+ * @private
84
+ * @type {boolean}
85
+ */
86
+ _classPrivateFieldInitSpec(this, _isPerformingUndo, {
87
+ writable: true,
88
+ value: false
89
+ });
90
+ /**
91
+ * Flag informing whether redo is already performed (we don't perform synchronization in such case).
92
+ *
93
+ * @private
94
+ * @type {boolean}
95
+ */
96
+ _classPrivateFieldInitSpec(this, _isPerformingRedo, {
97
+ writable: true,
98
+ value: false
99
+ });
100
+ /**
101
+ * The HF's engine instance which will be synced.
102
+ *
103
+ * @private
104
+ * @type {HyperFormula|null}
105
+ */
106
+ _classPrivateFieldInitSpec(this, _engine, {
107
+ writable: true,
108
+ value: null
109
+ });
110
+ /**
111
+ * HyperFormula's sheet name.
112
+ *
113
+ * @private
114
+ * @type {string|null}
115
+ */
116
+ _classPrivateFieldInitSpec(this, _sheetId, {
117
+ writable: true,
118
+ value: null
119
+ });
120
+ _classPrivateFieldSet(this, _rowIndexSyncer, new _axisSyncer.default('row', rowIndexMapper, this));
121
+ _classPrivateFieldSet(this, _columnIndexSyncer, new _axisSyncer.default('column', columnIndexMapper, this));
122
+ _classPrivateFieldSet(this, _postponeAction, postponeAction);
123
+ }
124
+
125
+ /**
126
+ * Gets index synchronizer for a particular axis.
127
+ *
128
+ * @param {'row'|'column'} indexType Type of indexes.
129
+ * @returns {AxisSyncer}
130
+ */
131
+ _createClass(IndexSyncer, [{
132
+ key: "getForAxis",
133
+ value: function getForAxis(indexType) {
134
+ if (indexType === 'row') {
135
+ return _classPrivateFieldGet(this, _rowIndexSyncer);
136
+ }
137
+ return _classPrivateFieldGet(this, _columnIndexSyncer);
138
+ }
139
+
140
+ /**
141
+ * Sets flag informing whether an undo action is already performed (we don't execute synchronization in such case).
142
+ *
143
+ * @param {boolean} flagValue Boolean value for the flag.
144
+ */
145
+ }, {
146
+ key: "setPerformUndo",
147
+ value: function setPerformUndo(flagValue) {
148
+ _classPrivateFieldSet(this, _isPerformingUndo, flagValue);
149
+ }
150
+
151
+ /**
152
+ * Sets flag informing whether a redo action is already performed (we don't execute synchronization in such case).
153
+ *
154
+ * @param {boolean} flagValue Boolean value for the flag.
155
+ */
156
+ }, {
157
+ key: "setPerformRedo",
158
+ value: function setPerformRedo(flagValue) {
159
+ _classPrivateFieldSet(this, _isPerformingRedo, flagValue);
160
+ }
161
+
162
+ /**
163
+ * Gets information whether redo or undo action is already performed (we don't execute synchronization in such case).
164
+ *
165
+ * @private
166
+ * @returns {boolean}
167
+ */
168
+ }, {
169
+ key: "isPerformingUndoRedo",
170
+ value: function isPerformingUndoRedo() {
171
+ return _classPrivateFieldGet(this, _isPerformingUndo) || _classPrivateFieldGet(this, _isPerformingRedo);
172
+ }
173
+
174
+ /**
175
+ * Gets HyperFormula's sheet id.
176
+ *
177
+ * @returns {string|null}
178
+ */
179
+ }, {
180
+ key: "getSheetId",
181
+ value: function getSheetId() {
182
+ return _classPrivateFieldGet(this, _sheetId);
183
+ }
184
+
185
+ /**
186
+ * Gets engine instance that will be used for handled instance of Handsontable.
187
+ *
188
+ * @type {HyperFormula|null}
189
+ */
190
+ }, {
191
+ key: "getEngine",
192
+ value: function getEngine() {
193
+ return _classPrivateFieldGet(this, _engine);
194
+ }
195
+
196
+ /**
197
+ * Gets method which will postpone execution of some action (needed when synchronization endpoint isn't setup yet).
198
+ *
199
+ * @returns {Function}
200
+ */
201
+ }, {
202
+ key: "getPostponeAction",
203
+ value: function getPostponeAction() {
204
+ return _classPrivateFieldGet(this, _postponeAction);
205
+ }
206
+
207
+ /**
208
+ * Setups a synchronization endpoint.
209
+ *
210
+ * @param {HyperFormula|null} engine The HF's engine instance which will be synced.
211
+ * @param {string|null} sheetId HyperFormula's sheet name.
212
+ */
213
+ }, {
214
+ key: "setupSyncEndpoint",
215
+ value: function setupSyncEndpoint(engine, sheetId) {
216
+ _classPrivateFieldSet(this, _engine, engine);
217
+ _classPrivateFieldSet(this, _sheetId, sheetId);
218
+ _classPrivateFieldGet(this, _rowIndexSyncer).init();
219
+ _classPrivateFieldGet(this, _columnIndexSyncer).init();
220
+ }
221
+ }]);
222
+ return IndexSyncer;
223
+ }();
224
+ var _default = IndexSyncer;
225
+ exports.default = _default;