handsontable 14.1.0 → 14.2.0-next-4873a35-20240228

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. package/3rdparty/walkontable/src/core/_base.js +12 -0
  2. package/3rdparty/walkontable/src/core/_base.mjs +12 -0
  3. package/3rdparty/walkontable/src/scroll.js +131 -98
  4. package/3rdparty/walkontable/src/scroll.mjs +133 -100
  5. package/3rdparty/walkontable/src/selection/border/border.js +3 -3
  6. package/3rdparty/walkontable/src/selection/border/border.mjs +3 -3
  7. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.js +26 -0
  8. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.mjs +26 -0
  9. package/3rdparty/walkontable/src/table/mixin/calculatedRows.js +26 -0
  10. package/3rdparty/walkontable/src/table/mixin/calculatedRows.mjs +26 -0
  11. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.js +20 -0
  12. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.mjs +20 -0
  13. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.js +20 -0
  14. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.mjs +20 -0
  15. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.js +20 -0
  16. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.mjs +20 -0
  17. package/3rdparty/walkontable/src/table.js +2 -0
  18. package/3rdparty/walkontable/src/table.mjs +2 -0
  19. package/3rdparty/walkontable/src/viewport.js +9 -0
  20. package/3rdparty/walkontable/src/viewport.mjs +10 -1
  21. package/CHANGELOG.md +38 -0
  22. package/base.js +2 -2
  23. package/base.mjs +2 -2
  24. package/core/index.js +6 -0
  25. package/core/index.mjs +2 -1
  26. package/core/viewportScroll/index.js +65 -0
  27. package/core/viewportScroll/index.mjs +61 -0
  28. package/core/viewportScroll/scrollStrategies/columnHeaderScroll.js +20 -0
  29. package/core/viewportScroll/scrollStrategies/columnHeaderScroll.mjs +16 -0
  30. package/core/viewportScroll/scrollStrategies/cornerHeaderScroll.js +14 -0
  31. package/core/viewportScroll/scrollStrategies/cornerHeaderScroll.mjs +10 -0
  32. package/core/viewportScroll/scrollStrategies/multipleScroll.js +15 -0
  33. package/core/viewportScroll/scrollStrategies/multipleScroll.mjs +11 -0
  34. package/core/viewportScroll/scrollStrategies/noncontiguousScroll.js +15 -0
  35. package/core/viewportScroll/scrollStrategies/noncontiguousScroll.mjs +11 -0
  36. package/core/viewportScroll/scrollStrategies/rowHeaderScroll.js +20 -0
  37. package/core/viewportScroll/scrollStrategies/rowHeaderScroll.mjs +16 -0
  38. package/core/viewportScroll/scrollStrategies/singleScroll.js +46 -0
  39. package/core/viewportScroll/scrollStrategies/singleScroll.mjs +42 -0
  40. package/core.d.ts +1 -1
  41. package/core.js +11 -52
  42. package/core.mjs +12 -53
  43. package/dataMap/metaManager/index.js +1 -1
  44. package/dataMap/metaManager/index.mjs +1 -1
  45. package/dataMap/metaManager/metaLayers/cellMeta.js +6 -1
  46. package/dataMap/metaManager/metaLayers/cellMeta.mjs +6 -1
  47. package/dataMap/metaManager/metaSchema.js +36 -12
  48. package/dataMap/metaManager/metaSchema.mjs +36 -12
  49. package/dist/handsontable.css +2 -2
  50. package/dist/handsontable.full.css +2 -2
  51. package/dist/handsontable.full.js +2996 -1928
  52. package/dist/handsontable.full.min.css +2 -2
  53. package/dist/handsontable.full.min.js +42 -42
  54. package/dist/handsontable.js +2998 -1930
  55. package/dist/handsontable.min.css +2 -2
  56. package/dist/handsontable.min.js +25 -25
  57. package/dist/languages/all.js +130 -25
  58. package/dist/languages/all.min.js +1 -1
  59. package/dist/languages/hr-HR.js +167 -0
  60. package/dist/languages/hr-HR.min.js +1 -0
  61. package/editorManager.js +15 -4
  62. package/editorManager.mjs +15 -4
  63. package/editors/autocompleteEditor/autocompleteEditor.js +2 -2
  64. package/editors/autocompleteEditor/autocompleteEditor.mjs +2 -2
  65. package/editors/baseEditor/baseEditor.js +1 -1
  66. package/editors/baseEditor/baseEditor.mjs +1 -1
  67. package/editors/checkboxEditor/checkboxEditor.js +5 -4
  68. package/editors/checkboxEditor/checkboxEditor.mjs +5 -4
  69. package/editors/dateEditor/dateEditor.js +1 -1
  70. package/editors/dateEditor/dateEditor.mjs +1 -1
  71. package/editors/dropdownEditor/dropdownEditor.js +1 -1
  72. package/editors/dropdownEditor/dropdownEditor.mjs +1 -1
  73. package/editors/handsontableEditor/handsontableEditor.js +1 -1
  74. package/editors/handsontableEditor/handsontableEditor.mjs +1 -1
  75. package/editors/selectEditor/selectEditor.js +1 -1
  76. package/editors/selectEditor/selectEditor.mjs +1 -1
  77. package/editors/textEditor/textEditor.js +1 -2
  78. package/editors/textEditor/textEditor.mjs +1 -2
  79. package/editors/timeEditor/timeEditor.js +1 -1
  80. package/editors/timeEditor/timeEditor.mjs +1 -1
  81. package/helpers/mixed.js +2 -2
  82. package/helpers/mixed.mjs +2 -2
  83. package/helpers/moves.js +86 -0
  84. package/helpers/moves.mjs +82 -0
  85. package/i18n/languages/hr-HR.js +96 -0
  86. package/i18n/languages/hr-HR.mjs +90 -0
  87. package/i18n/languages/index.js +2 -0
  88. package/i18n/languages/index.mjs +2 -1
  89. package/languages/all.js +130 -25
  90. package/languages/hr-HR.js +167 -0
  91. package/languages/hr-HR.mjs +92 -0
  92. package/languages/index.js +130 -25
  93. package/languages/index.mjs +2 -1
  94. package/package.json +11 -1
  95. package/pluginHooks.d.ts +4 -2
  96. package/pluginHooks.js +33 -3
  97. package/pluginHooks.mjs +33 -3
  98. package/plugins/autoColumnSize/autoColumnSize.js +6 -1
  99. package/plugins/autoColumnSize/autoColumnSize.mjs +6 -1
  100. package/plugins/autoRowSize/autoRowSize.js +5 -0
  101. package/plugins/autoRowSize/autoRowSize.mjs +5 -0
  102. package/plugins/autofill/autofill.js +3 -2
  103. package/plugins/autofill/autofill.mjs +3 -2
  104. package/plugins/dropdownMenu/dropdownMenu.js +58 -4
  105. package/plugins/dropdownMenu/dropdownMenu.mjs +58 -4
  106. package/plugins/filters/component/value.js +51 -5
  107. package/plugins/filters/component/value.mjs +51 -5
  108. package/plugins/filters/utils.js +1 -1
  109. package/plugins/filters/utils.mjs +1 -1
  110. package/plugins/formulas/formulas.js +10 -1
  111. package/plugins/formulas/formulas.mjs +10 -1
  112. package/plugins/formulas/indexSyncer/axisSyncer.js +3 -75
  113. package/plugins/formulas/indexSyncer/axisSyncer.mjs +3 -75
  114. package/plugins/manualColumnResize/manualColumnResize.js +3 -0
  115. package/plugins/manualColumnResize/manualColumnResize.mjs +3 -0
  116. package/plugins/mergeCells/cellsCollection.js +1 -1
  117. package/plugins/mergeCells/cellsCollection.mjs +1 -1
  118. package/plugins/mergeCells/mergeCells.js +30 -0
  119. package/plugins/mergeCells/mergeCells.mjs +30 -0
  120. package/plugins/undoRedo/undoRedo.js +61 -14
  121. package/plugins/undoRedo/undoRedo.mjs +61 -14
  122. package/renderers/autocompleteRenderer/autocompleteRenderer.js +1 -1
  123. package/renderers/autocompleteRenderer/autocompleteRenderer.mjs +1 -1
  124. package/renderers/baseRenderer/baseRenderer.js +1 -1
  125. package/renderers/baseRenderer/baseRenderer.mjs +1 -1
  126. package/renderers/checkboxRenderer/checkboxRenderer.js +36 -8
  127. package/renderers/checkboxRenderer/checkboxRenderer.mjs +36 -8
  128. package/renderers/dateRenderer/dateRenderer.js +1 -1
  129. package/renderers/dateRenderer/dateRenderer.mjs +1 -1
  130. package/renderers/dropdownRenderer/dropdownRenderer.js +1 -1
  131. package/renderers/dropdownRenderer/dropdownRenderer.mjs +1 -1
  132. package/renderers/handsontableRenderer/handsontableRenderer.js +1 -1
  133. package/renderers/handsontableRenderer/handsontableRenderer.mjs +1 -1
  134. package/renderers/htmlRenderer/htmlRenderer.js +1 -1
  135. package/renderers/htmlRenderer/htmlRenderer.mjs +1 -1
  136. package/renderers/numericRenderer/index.js +2 -1
  137. package/renderers/numericRenderer/index.mjs +1 -1
  138. package/renderers/numericRenderer/numericRenderer.js +28 -13
  139. package/renderers/numericRenderer/numericRenderer.mjs +27 -13
  140. package/renderers/passwordRenderer/passwordRenderer.js +1 -1
  141. package/renderers/passwordRenderer/passwordRenderer.mjs +1 -1
  142. package/renderers/selectRenderer/selectRenderer.js +1 -1
  143. package/renderers/selectRenderer/selectRenderer.mjs +1 -1
  144. package/renderers/textRenderer/textRenderer.js +1 -1
  145. package/renderers/textRenderer/textRenderer.mjs +1 -1
  146. package/renderers/timeRenderer/timeRenderer.js +1 -1
  147. package/renderers/timeRenderer/timeRenderer.mjs +1 -1
  148. package/selection/mouseEventHandler.js +4 -0
  149. package/selection/mouseEventHandler.mjs +4 -0
  150. package/selection/selection.js +64 -5
  151. package/selection/selection.mjs +64 -5
  152. package/shortcuts/recorder.js +27 -8
  153. package/shortcuts/recorder.mjs +27 -8
  154. package/tableView.js +86 -5
  155. package/tableView.mjs +87 -6
  156. package/utils/autoResize.js +0 -1
  157. package/utils/autoResize.mjs +0 -1
  158. package/utils/ghostTable.js +6 -6
  159. package/utils/ghostTable.mjs +6 -6
  160. package/utils/parseTable.js +9 -1
  161. package/utils/parseTable.mjs +9 -1
@@ -4,6 +4,7 @@ exports.__esModule = true;
4
4
  require("core-js/modules/es.array.push.js");
5
5
  require("core-js/modules/es.error.cause.js");
6
6
  var _string = require("../../../helpers/string");
7
+ var _moves = require("../../../helpers/moves");
7
8
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
8
9
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
10
  function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
@@ -176,79 +177,6 @@ class AxisSyncer {
176
177
  _classPrivateFieldSet(this, _finalIndex, this.getHfIndexFromVisualIndex(visualFinalIndex));
177
178
  }
178
179
 
179
- /**
180
- * Gets first position where to move element (respecting the fact that some element will be sooner or later
181
- * taken out of the dataset in order to move them).
182
- *
183
- * @param {Array<number>} movedHfIndexes Sequence of moved HF indexes for certain axis.
184
- * @param {number} finalHfIndex Final HF place where to move rows.
185
- * @returns {number} HF's index informing where to move the first element.
186
- * @private
187
- */
188
- getMoveLine(movedHfIndexes, finalHfIndex) {
189
- const numberOfElements = _classPrivateFieldGet(this, _indexMapper).getNumberOfIndexes();
190
- const notMovedElements = Array.from(Array(numberOfElements).keys()).filter(index => movedHfIndexes.includes(index) === false);
191
- if (finalHfIndex === 0) {
192
- var _notMovedElements$fin;
193
- return (_notMovedElements$fin = notMovedElements[finalHfIndex]) !== null && _notMovedElements$fin !== void 0 ? _notMovedElements$fin : 0; // Moving before the first dataset's element.
194
- }
195
- return notMovedElements[finalHfIndex - 1] + 1; // Moving before another element.
196
- }
197
-
198
- /**
199
- * Gets initially calculated HF's move positions.
200
- *
201
- * @private
202
- * @param {Array<number>} movedHfIndexes Sequence of moved HF indexes for certain axis.
203
- * @param {number} finalHfIndex Final HF place where to move rows.
204
- * @returns {Array<{from: number, to: number}>} Initially calculated HF's move positions.
205
- */
206
- getInitiallyCalculatedMoves(movedHfIndexes, finalHfIndex) {
207
- let moveLine = this.getMoveLine(movedHfIndexes, finalHfIndex);
208
- const moves = [];
209
- movedHfIndexes.forEach(movedHfIndex => {
210
- const move = {
211
- from: movedHfIndex,
212
- to: moveLine
213
- };
214
- moves.forEach(previouslyMovedIndex => {
215
- const isMovingFromEndToStart = previouslyMovedIndex.from > previouslyMovedIndex.to;
216
- const isMovingElementBefore = previouslyMovedIndex.to <= move.from;
217
- const isMovingAfterElement = previouslyMovedIndex.from > move.from;
218
- if (isMovingAfterElement && isMovingElementBefore && isMovingFromEndToStart) {
219
- move.from += 1;
220
- }
221
- });
222
-
223
- // Moved element from right to left (or bottom to top).
224
- if (move.from >= moveLine) {
225
- moveLine += 1;
226
- }
227
- moves.push(move);
228
- });
229
- return moves;
230
- }
231
-
232
- /**
233
- * Gets finally calculated HF's move positions (after adjusting).
234
- *
235
- * @private
236
- * @param {Array<{from: number, to: number}>} moves Initially calculated HF's move positions.
237
- * @returns {Array<{from: number, to: number}>} Finally calculated HF's move positions (after adjusting).
238
- */
239
- adjustedCalculatedMoves(moves) {
240
- moves.forEach((move, index) => {
241
- const nextMoved = moves.slice(index + 1);
242
- nextMoved.forEach(nextMovedIndex => {
243
- const isMovingFromStartToEnd = nextMovedIndex.from < nextMovedIndex.to;
244
- if (nextMovedIndex.from > move.from && isMovingFromStartToEnd) {
245
- nextMovedIndex.from -= 1;
246
- }
247
- });
248
- });
249
- return moves;
250
- }
251
-
252
180
  /**
253
181
  * Calculating where to move HF elements and performing already calculated moves.
254
182
  *
@@ -262,7 +190,7 @@ class AxisSyncer {
262
190
  if (movePossible === false || orderChanged === false) {
263
191
  return;
264
192
  }
265
- const calculatedMoves = this.adjustedCalculatedMoves(this.getInitiallyCalculatedMoves(_classPrivateFieldGet(this, _movedIndexes), _classPrivateFieldGet(this, _finalIndex)));
193
+ const calculatedMoves = (0, _moves.getMoves)(_classPrivateFieldGet(this, _movedIndexes), _classPrivateFieldGet(this, _finalIndex), _classPrivateFieldGet(this, _indexMapper).getNumberOfIndexes());
266
194
  if (_classPrivateFieldGet(this, _indexSyncer).getSheetId() === null) {
267
195
  _classPrivateFieldGet(this, _indexSyncer).getPostponeAction(() => this.syncMoves(calculatedMoves));
268
196
  } else {
@@ -282,7 +210,7 @@ class AxisSyncer {
282
210
  return;
283
211
  }
284
212
  const newSequence = _classPrivateFieldGet(this, _indexMapper).getIndexesSequence();
285
- if (source === 'update') {
213
+ if (source === 'update' && newSequence.length > 0) {
286
214
  const relativeTransformation = _classPrivateFieldGet(this, _indexesSequence).map(index => newSequence.indexOf(index));
287
215
  const sheetDimensions = _classPrivateFieldGet(this, _indexSyncer).getEngine().getSheetDimensions(_classPrivateFieldGet(this, _indexSyncer).getSheetId());
288
216
  let sizeForAxis;
@@ -8,6 +8,7 @@ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _
8
8
  function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
9
9
  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; } }
10
10
  import { toUpperCaseFirst } from "../../../helpers/string.mjs";
11
+ import { getMoves } from "../../../helpers/moves.mjs";
11
12
  /**
12
13
  * @private
13
14
  * @class IndexSyncer
@@ -173,79 +174,6 @@ class AxisSyncer {
173
174
  _classPrivateFieldSet(this, _finalIndex, this.getHfIndexFromVisualIndex(visualFinalIndex));
174
175
  }
175
176
 
176
- /**
177
- * Gets first position where to move element (respecting the fact that some element will be sooner or later
178
- * taken out of the dataset in order to move them).
179
- *
180
- * @param {Array<number>} movedHfIndexes Sequence of moved HF indexes for certain axis.
181
- * @param {number} finalHfIndex Final HF place where to move rows.
182
- * @returns {number} HF's index informing where to move the first element.
183
- * @private
184
- */
185
- getMoveLine(movedHfIndexes, finalHfIndex) {
186
- const numberOfElements = _classPrivateFieldGet(this, _indexMapper).getNumberOfIndexes();
187
- const notMovedElements = Array.from(Array(numberOfElements).keys()).filter(index => movedHfIndexes.includes(index) === false);
188
- if (finalHfIndex === 0) {
189
- var _notMovedElements$fin;
190
- return (_notMovedElements$fin = notMovedElements[finalHfIndex]) !== null && _notMovedElements$fin !== void 0 ? _notMovedElements$fin : 0; // Moving before the first dataset's element.
191
- }
192
- return notMovedElements[finalHfIndex - 1] + 1; // Moving before another element.
193
- }
194
-
195
- /**
196
- * Gets initially calculated HF's move positions.
197
- *
198
- * @private
199
- * @param {Array<number>} movedHfIndexes Sequence of moved HF indexes for certain axis.
200
- * @param {number} finalHfIndex Final HF place where to move rows.
201
- * @returns {Array<{from: number, to: number}>} Initially calculated HF's move positions.
202
- */
203
- getInitiallyCalculatedMoves(movedHfIndexes, finalHfIndex) {
204
- let moveLine = this.getMoveLine(movedHfIndexes, finalHfIndex);
205
- const moves = [];
206
- movedHfIndexes.forEach(movedHfIndex => {
207
- const move = {
208
- from: movedHfIndex,
209
- to: moveLine
210
- };
211
- moves.forEach(previouslyMovedIndex => {
212
- const isMovingFromEndToStart = previouslyMovedIndex.from > previouslyMovedIndex.to;
213
- const isMovingElementBefore = previouslyMovedIndex.to <= move.from;
214
- const isMovingAfterElement = previouslyMovedIndex.from > move.from;
215
- if (isMovingAfterElement && isMovingElementBefore && isMovingFromEndToStart) {
216
- move.from += 1;
217
- }
218
- });
219
-
220
- // Moved element from right to left (or bottom to top).
221
- if (move.from >= moveLine) {
222
- moveLine += 1;
223
- }
224
- moves.push(move);
225
- });
226
- return moves;
227
- }
228
-
229
- /**
230
- * Gets finally calculated HF's move positions (after adjusting).
231
- *
232
- * @private
233
- * @param {Array<{from: number, to: number}>} moves Initially calculated HF's move positions.
234
- * @returns {Array<{from: number, to: number}>} Finally calculated HF's move positions (after adjusting).
235
- */
236
- adjustedCalculatedMoves(moves) {
237
- moves.forEach((move, index) => {
238
- const nextMoved = moves.slice(index + 1);
239
- nextMoved.forEach(nextMovedIndex => {
240
- const isMovingFromStartToEnd = nextMovedIndex.from < nextMovedIndex.to;
241
- if (nextMovedIndex.from > move.from && isMovingFromStartToEnd) {
242
- nextMovedIndex.from -= 1;
243
- }
244
- });
245
- });
246
- return moves;
247
- }
248
-
249
177
  /**
250
178
  * Calculating where to move HF elements and performing already calculated moves.
251
179
  *
@@ -259,7 +187,7 @@ class AxisSyncer {
259
187
  if (movePossible === false || orderChanged === false) {
260
188
  return;
261
189
  }
262
- const calculatedMoves = this.adjustedCalculatedMoves(this.getInitiallyCalculatedMoves(_classPrivateFieldGet(this, _movedIndexes), _classPrivateFieldGet(this, _finalIndex)));
190
+ const calculatedMoves = getMoves(_classPrivateFieldGet(this, _movedIndexes), _classPrivateFieldGet(this, _finalIndex), _classPrivateFieldGet(this, _indexMapper).getNumberOfIndexes());
263
191
  if (_classPrivateFieldGet(this, _indexSyncer).getSheetId() === null) {
264
192
  _classPrivateFieldGet(this, _indexSyncer).getPostponeAction(() => this.syncMoves(calculatedMoves));
265
193
  } else {
@@ -279,7 +207,7 @@ class AxisSyncer {
279
207
  return;
280
208
  }
281
209
  const newSequence = _classPrivateFieldGet(this, _indexMapper).getIndexesSequence();
282
- if (source === 'update') {
210
+ if (source === 'update' && newSequence.length > 0) {
283
211
  const relativeTransformation = _classPrivateFieldGet(this, _indexesSequence).map(index => newSequence.indexOf(index));
284
212
  const sheetDimensions = _classPrivateFieldGet(this, _indexSyncer).getEngine().getSheetDimensions(_classPrivateFieldGet(this, _indexSyncer).getSheetId());
285
213
  let sizeForAxis;
@@ -609,6 +609,9 @@ function _onMouseOver2(event) {
609
609
  }
610
610
  }
611
611
  function _onMouseDown2(event) {
612
+ if (event.target.parentNode !== this.hot.rootElement) {
613
+ return;
614
+ }
612
615
  if ((0, _element.hasClass)(event.target, 'manualColumnResizer')) {
613
616
  this.setupHandlePosition(_classPrivateFieldGet(this, _currentTH));
614
617
  this.setupGuidePosition();
@@ -603,6 +603,9 @@ function _onMouseOver2(event) {
603
603
  }
604
604
  }
605
605
  function _onMouseDown2(event) {
606
+ if (event.target.parentNode !== this.hot.rootElement) {
607
+ return;
608
+ }
606
609
  if (hasClass(event.target, 'manualColumnResizer')) {
607
610
  this.setupHandlePosition(_classPrivateFieldGet(this, _currentTH));
608
611
  this.setupGuidePosition();
@@ -77,7 +77,7 @@ class MergedCellsCollection {
77
77
  }
78
78
 
79
79
  /**
80
- * Get a merged cell containing the provided range.
80
+ * Get the first-found merged cell containing the provided range.
81
81
  *
82
82
  * @param {CellRange|object} range The range to search merged cells for.
83
83
  * @returns {MergedCellCoords|boolean}
@@ -73,7 +73,7 @@ class MergedCellsCollection {
73
73
  }
74
74
 
75
75
  /**
76
- * Get a merged cell containing the provided range.
76
+ * Get the first-found merged cell containing the provided range.
77
77
  *
78
78
  * @param {CellRange|object} range The range to search merged cells for.
79
79
  * @returns {MergedCellCoords|boolean}
@@ -98,9 +98,20 @@ var _onBeforeDrawAreaBorders = /*#__PURE__*/new WeakSet();
98
98
  var _onAfterModifyTransformStart = /*#__PURE__*/new WeakSet();
99
99
  var _onAfterDrawSelection = /*#__PURE__*/new WeakSet();
100
100
  var _onBeforeRemoveCellClassNames = /*#__PURE__*/new WeakSet();
101
+ var _onBeforeBeginEditing = /*#__PURE__*/new WeakSet();
101
102
  class MergeCells extends _base.BasePlugin {
102
103
  constructor() {
103
104
  super(...arguments);
105
+ /**
106
+ * Allows to prevent opening the editor while more than one merged cell is selected.
107
+ *
108
+ * @param {number} row Visual row index of the edited cell.
109
+ * @param {number} column Visual column index of the edited cell.
110
+ * @param {string | null} initialValue The initial editor value.
111
+ * @param {MouseEvent | KeyboardEvent} event The event which was responsible for opening the editor.
112
+ * @returns {boolean | undefined}
113
+ */
114
+ _classPrivateMethodInitSpec(this, _onBeforeBeginEditing);
104
115
  /**
105
116
  * `beforeRemoveCellClassNames` hook callback. Used to remove additional class name from all cells in the table.
106
117
  *
@@ -459,6 +470,12 @@ class MergeCells extends _base.BasePlugin {
459
470
  }
460
471
  return _classPrivateMethodGet(_this, _onBeforeRemoveCellClassNames, _onBeforeRemoveCellClassNames2).call(_this, ...args);
461
472
  });
473
+ this.addHook('beforeBeginEditing', function () {
474
+ for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
475
+ args[_key24] = arguments[_key24];
476
+ }
477
+ return _classPrivateMethodGet(_this, _onBeforeBeginEditing, _onBeforeBeginEditing2).call(_this, ...args);
478
+ });
462
479
  this.addHook('beforeUndoStackChange', (action, source) => {
463
480
  if (source === 'MergeCells') {
464
481
  return false;
@@ -1290,4 +1307,17 @@ function _onAfterDrawSelection2(currentRow, currentColumn, cornersOfSelection, l
1290
1307
  }
1291
1308
  function _onBeforeRemoveCellClassNames2() {
1292
1309
  return this.selectionCalculations.getSelectedMergedCellClassNameToRemove();
1310
+ }
1311
+ function _onBeforeBeginEditing2(row, column, initialValue, event) {
1312
+ if (!(event instanceof MouseEvent)) {
1313
+ return;
1314
+ }
1315
+ const selection = this.hot.getSelectedRangeLast();
1316
+ const mergeCell = this.mergedCellsCollection.getByRange(selection);
1317
+ if (!mergeCell) {
1318
+ return;
1319
+ }
1320
+ const from = this.hot._createCellCoords(mergeCell.row, mergeCell.col);
1321
+ const to = this.hot._createCellCoords(mergeCell.row + mergeCell.rowspan - 1, mergeCell.col + mergeCell.colspan - 1);
1322
+ return this.hot.selection.getLayerLevel() === 0 && selection.isEqual(this.hot._createCellRange(from, from, to));
1293
1323
  }
@@ -94,9 +94,20 @@ var _onBeforeDrawAreaBorders = /*#__PURE__*/new WeakSet();
94
94
  var _onAfterModifyTransformStart = /*#__PURE__*/new WeakSet();
95
95
  var _onAfterDrawSelection = /*#__PURE__*/new WeakSet();
96
96
  var _onBeforeRemoveCellClassNames = /*#__PURE__*/new WeakSet();
97
+ var _onBeforeBeginEditing = /*#__PURE__*/new WeakSet();
97
98
  export class MergeCells extends BasePlugin {
98
99
  constructor() {
99
100
  super(...arguments);
101
+ /**
102
+ * Allows to prevent opening the editor while more than one merged cell is selected.
103
+ *
104
+ * @param {number} row Visual row index of the edited cell.
105
+ * @param {number} column Visual column index of the edited cell.
106
+ * @param {string | null} initialValue The initial editor value.
107
+ * @param {MouseEvent | KeyboardEvent} event The event which was responsible for opening the editor.
108
+ * @returns {boolean | undefined}
109
+ */
110
+ _classPrivateMethodInitSpec(this, _onBeforeBeginEditing);
100
111
  /**
101
112
  * `beforeRemoveCellClassNames` hook callback. Used to remove additional class name from all cells in the table.
102
113
  *
@@ -455,6 +466,12 @@ export class MergeCells extends BasePlugin {
455
466
  }
456
467
  return _classPrivateMethodGet(_this, _onBeforeRemoveCellClassNames, _onBeforeRemoveCellClassNames2).call(_this, ...args);
457
468
  });
469
+ this.addHook('beforeBeginEditing', function () {
470
+ for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
471
+ args[_key24] = arguments[_key24];
472
+ }
473
+ return _classPrivateMethodGet(_this, _onBeforeBeginEditing, _onBeforeBeginEditing2).call(_this, ...args);
474
+ });
458
475
  this.addHook('beforeUndoStackChange', (action, source) => {
459
476
  if (source === 'MergeCells') {
460
477
  return false;
@@ -1285,4 +1302,17 @@ function _onAfterDrawSelection2(currentRow, currentColumn, cornersOfSelection, l
1285
1302
  }
1286
1303
  function _onBeforeRemoveCellClassNames2() {
1287
1304
  return this.selectionCalculations.getSelectedMergedCellClassNameToRemove();
1305
+ }
1306
+ function _onBeforeBeginEditing2(row, column, initialValue, event) {
1307
+ if (!(event instanceof MouseEvent)) {
1308
+ return;
1309
+ }
1310
+ const selection = this.hot.getSelectedRangeLast();
1311
+ const mergeCell = this.mergedCellsCollection.getByRange(selection);
1312
+ if (!mergeCell) {
1313
+ return;
1314
+ }
1315
+ const from = this.hot._createCellCoords(mergeCell.row, mergeCell.col);
1316
+ const to = this.hot._createCellCoords(mergeCell.row + mergeCell.rowspan - 1, mergeCell.col + mergeCell.colspan - 1);
1317
+ return this.hot.selection.getLayerLevel() === 0 && selection.isEqual(this.hot._createCellRange(from, from, to));
1288
1318
  }
@@ -8,6 +8,7 @@ var _array = require("../../helpers/array");
8
8
  var _number = require("../../helpers/number");
9
9
  var _object = require("../../helpers/object");
10
10
  var _utils = require("../contextMenu/utils");
11
+ var _moves = require("../../helpers/moves");
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
13
  const SHORTCUTS_GROUP = 'undoRedo';
13
14
  const PLUGIN_KEY = exports.PLUGIN_KEY = 'undoRedo';
@@ -132,6 +133,12 @@ function UndoRedo(instance) {
132
133
  }
133
134
  plugin.done(() => new UndoRedo.RowMoveAction(rows, finalIndex));
134
135
  });
136
+ instance.addHook('beforeColumnMove', (columns, finalIndex) => {
137
+ if (columns === false) {
138
+ return;
139
+ }
140
+ plugin.done(() => new UndoRedo.ColumnMoveAction(columns, finalIndex));
141
+ });
135
142
  instance.addHook('beforeMergeCells', (cellRange, auto) => {
136
143
  if (auto) {
137
144
  return;
@@ -714,24 +721,24 @@ UndoRedo.UnmergeCellsAction = UnmergeCellsAction;
714
721
  */
715
722
  UndoRedo.RowMoveAction = function (rows, finalIndex) {
716
723
  this.rows = rows.slice();
717
- this.finalIndex = finalIndex;
724
+ this.finalRowIndex = finalIndex;
718
725
  this.actionType = 'row_move';
719
726
  };
720
727
  (0, _object.inherit)(UndoRedo.RowMoveAction, UndoRedo.Action);
721
728
  UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
722
729
  const manualRowMove = instance.getPlugin('manualRowMove');
723
- const copyOfRows = [].concat(this.rows);
724
- const rowsMovedUp = copyOfRows.filter(a => a > this.finalIndex);
725
- const rowsMovedDown = copyOfRows.filter(a => a <= this.finalIndex);
726
- const allMovedRows = rowsMovedUp.sort((a, b) => b - a).concat(rowsMovedDown.sort((a, b) => a - b));
727
730
  instance.addHookOnce('afterViewRender', undoneCallback);
728
-
729
- // Moving rows from those with higher indexes to those with lower indexes when action was performed from bottom to top
730
- // Moving rows from those with lower indexes to those with higher indexes when action was performed from top to bottom
731
- for (let i = 0; i < allMovedRows.length; i += 1) {
732
- const newPhysicalRow = instance.toVisualRow(allMovedRows[i]);
733
- manualRowMove.moveRow(newPhysicalRow, allMovedRows[i]);
734
- }
731
+ const rowMoves = (0, _moves.getMoves)(this.rows, this.finalRowIndex, instance.rowIndexMapper.getNumberOfIndexes());
732
+ rowMoves.reverse().forEach(_ref4 => {
733
+ let {
734
+ from,
735
+ to
736
+ } = _ref4;
737
+ if (from < to) {
738
+ to -= 1;
739
+ }
740
+ manualRowMove.moveRow(to, from);
741
+ });
735
742
  instance.render();
736
743
  instance.deselectCell();
737
744
  instance.selectRows(this.rows[0], this.rows[0] + this.rows.length - 1);
@@ -739,10 +746,50 @@ UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
739
746
  UndoRedo.RowMoveAction.prototype.redo = function (instance, redoneCallback) {
740
747
  const manualRowMove = instance.getPlugin('manualRowMove');
741
748
  instance.addHookOnce('afterViewRender', redoneCallback);
742
- manualRowMove.moveRows(this.rows.slice(), this.finalIndex);
749
+ manualRowMove.moveRows(this.rows.slice(), this.finalRowIndex);
750
+ instance.render();
751
+ instance.deselectCell();
752
+ instance.selectRows(this.finalRowIndex, this.finalRowIndex + this.rows.length - 1);
753
+ };
754
+
755
+ /**
756
+ * ManualColumnMove action.
757
+ *
758
+ * @private
759
+ * @param {number[]} columns An array with moved columns.
760
+ * @param {number} finalIndex The destination index.
761
+ */
762
+ UndoRedo.ColumnMoveAction = function (columns, finalIndex) {
763
+ this.columns = columns.slice();
764
+ this.finalColumnIndex = finalIndex;
765
+ this.actionType = 'col_move';
766
+ };
767
+ (0, _object.inherit)(UndoRedo.ColumnMoveAction, UndoRedo.Action);
768
+ UndoRedo.ColumnMoveAction.prototype.undo = function (instance, undoneCallback) {
769
+ const manualColumnMove = instance.getPlugin('manualColumnMove');
770
+ instance.addHookOnce('afterViewRender', undoneCallback);
771
+ const columnMoves = (0, _moves.getMoves)(this.columns, this.finalColumnIndex, instance.columnIndexMapper.getNumberOfIndexes());
772
+ columnMoves.reverse().forEach(_ref5 => {
773
+ let {
774
+ from,
775
+ to
776
+ } = _ref5;
777
+ if (from < to) {
778
+ to -= 1;
779
+ }
780
+ manualColumnMove.moveColumn(to, from);
781
+ });
782
+ instance.render();
783
+ instance.deselectCell();
784
+ instance.selectColumns(this.columns[0], this.columns[0] + this.columns.length - 1);
785
+ };
786
+ UndoRedo.ColumnMoveAction.prototype.redo = function (instance, redoneCallback) {
787
+ const manualColumnMove = instance.getPlugin('manualColumnMove');
788
+ instance.addHookOnce('afterViewRender', redoneCallback);
789
+ manualColumnMove.moveColumns(this.columns.slice(), this.finalColumnIndex);
743
790
  instance.render();
744
791
  instance.deselectCell();
745
- instance.selectRows(this.finalIndex, this.finalIndex + this.rows.length - 1);
792
+ instance.selectColumns(this.finalColumnIndex, this.finalColumnIndex + this.columns.length - 1);
746
793
  };
747
794
 
748
795
  /**
@@ -5,6 +5,7 @@ import { arrayMap, arrayEach } from "../../helpers/array.mjs";
5
5
  import { rangeEach } from "../../helpers/number.mjs";
6
6
  import { inherit, deepClone } from "../../helpers/object.mjs";
7
7
  import { align } from "../contextMenu/utils.mjs";
8
+ import { getMoves } from "../../helpers/moves.mjs";
8
9
  const SHORTCUTS_GROUP = 'undoRedo';
9
10
  export const PLUGIN_KEY = 'undoRedo';
10
11
 
@@ -128,6 +129,12 @@ function UndoRedo(instance) {
128
129
  }
129
130
  plugin.done(() => new UndoRedo.RowMoveAction(rows, finalIndex));
130
131
  });
132
+ instance.addHook('beforeColumnMove', (columns, finalIndex) => {
133
+ if (columns === false) {
134
+ return;
135
+ }
136
+ plugin.done(() => new UndoRedo.ColumnMoveAction(columns, finalIndex));
137
+ });
131
138
  instance.addHook('beforeMergeCells', (cellRange, auto) => {
132
139
  if (auto) {
133
140
  return;
@@ -710,24 +717,24 @@ UndoRedo.UnmergeCellsAction = UnmergeCellsAction;
710
717
  */
711
718
  UndoRedo.RowMoveAction = function (rows, finalIndex) {
712
719
  this.rows = rows.slice();
713
- this.finalIndex = finalIndex;
720
+ this.finalRowIndex = finalIndex;
714
721
  this.actionType = 'row_move';
715
722
  };
716
723
  inherit(UndoRedo.RowMoveAction, UndoRedo.Action);
717
724
  UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
718
725
  const manualRowMove = instance.getPlugin('manualRowMove');
719
- const copyOfRows = [].concat(this.rows);
720
- const rowsMovedUp = copyOfRows.filter(a => a > this.finalIndex);
721
- const rowsMovedDown = copyOfRows.filter(a => a <= this.finalIndex);
722
- const allMovedRows = rowsMovedUp.sort((a, b) => b - a).concat(rowsMovedDown.sort((a, b) => a - b));
723
726
  instance.addHookOnce('afterViewRender', undoneCallback);
724
-
725
- // Moving rows from those with higher indexes to those with lower indexes when action was performed from bottom to top
726
- // Moving rows from those with lower indexes to those with higher indexes when action was performed from top to bottom
727
- for (let i = 0; i < allMovedRows.length; i += 1) {
728
- const newPhysicalRow = instance.toVisualRow(allMovedRows[i]);
729
- manualRowMove.moveRow(newPhysicalRow, allMovedRows[i]);
730
- }
727
+ const rowMoves = getMoves(this.rows, this.finalRowIndex, instance.rowIndexMapper.getNumberOfIndexes());
728
+ rowMoves.reverse().forEach(_ref4 => {
729
+ let {
730
+ from,
731
+ to
732
+ } = _ref4;
733
+ if (from < to) {
734
+ to -= 1;
735
+ }
736
+ manualRowMove.moveRow(to, from);
737
+ });
731
738
  instance.render();
732
739
  instance.deselectCell();
733
740
  instance.selectRows(this.rows[0], this.rows[0] + this.rows.length - 1);
@@ -735,10 +742,50 @@ UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
735
742
  UndoRedo.RowMoveAction.prototype.redo = function (instance, redoneCallback) {
736
743
  const manualRowMove = instance.getPlugin('manualRowMove');
737
744
  instance.addHookOnce('afterViewRender', redoneCallback);
738
- manualRowMove.moveRows(this.rows.slice(), this.finalIndex);
745
+ manualRowMove.moveRows(this.rows.slice(), this.finalRowIndex);
746
+ instance.render();
747
+ instance.deselectCell();
748
+ instance.selectRows(this.finalRowIndex, this.finalRowIndex + this.rows.length - 1);
749
+ };
750
+
751
+ /**
752
+ * ManualColumnMove action.
753
+ *
754
+ * @private
755
+ * @param {number[]} columns An array with moved columns.
756
+ * @param {number} finalIndex The destination index.
757
+ */
758
+ UndoRedo.ColumnMoveAction = function (columns, finalIndex) {
759
+ this.columns = columns.slice();
760
+ this.finalColumnIndex = finalIndex;
761
+ this.actionType = 'col_move';
762
+ };
763
+ inherit(UndoRedo.ColumnMoveAction, UndoRedo.Action);
764
+ UndoRedo.ColumnMoveAction.prototype.undo = function (instance, undoneCallback) {
765
+ const manualColumnMove = instance.getPlugin('manualColumnMove');
766
+ instance.addHookOnce('afterViewRender', undoneCallback);
767
+ const columnMoves = getMoves(this.columns, this.finalColumnIndex, instance.columnIndexMapper.getNumberOfIndexes());
768
+ columnMoves.reverse().forEach(_ref5 => {
769
+ let {
770
+ from,
771
+ to
772
+ } = _ref5;
773
+ if (from < to) {
774
+ to -= 1;
775
+ }
776
+ manualColumnMove.moveColumn(to, from);
777
+ });
778
+ instance.render();
779
+ instance.deselectCell();
780
+ instance.selectColumns(this.columns[0], this.columns[0] + this.columns.length - 1);
781
+ };
782
+ UndoRedo.ColumnMoveAction.prototype.redo = function (instance, redoneCallback) {
783
+ const manualColumnMove = instance.getPlugin('manualColumnMove');
784
+ instance.addHookOnce('afterViewRender', redoneCallback);
785
+ manualColumnMove.moveColumns(this.columns.slice(), this.finalColumnIndex);
739
786
  instance.render();
740
787
  instance.deselectCell();
741
- instance.selectRows(this.finalIndex, this.finalIndex + this.rows.length - 1);
788
+ instance.selectColumns(this.finalColumnIndex, this.finalColumnIndex + this.columns.length - 1);
742
789
  };
743
790
 
744
791
  /**
@@ -20,7 +20,7 @@ const RENDERER_TYPE = exports.RENDERER_TYPE = 'autocomplete';
20
20
  * @param {number} col The visual column index.
21
21
  * @param {number|string} prop The column property (passed when datasource is an array of objects).
22
22
  * @param {*} value The rendered value.
23
- * @param {object} cellProperties The cell meta object ({@see Core#getCellMeta}).
23
+ * @param {object} cellProperties The cell meta object (see {@link Core#getCellMeta}).
24
24
  */
25
25
  function autocompleteRenderer(hotInstance, TD, row, col, prop, value, cellProperties) {
26
26
  const {
@@ -15,7 +15,7 @@ export const RENDERER_TYPE = 'autocomplete';
15
15
  * @param {number} col The visual column index.
16
16
  * @param {number|string} prop The column property (passed when datasource is an array of objects).
17
17
  * @param {*} value The rendered value.
18
- * @param {object} cellProperties The cell meta object ({@see Core#getCellMeta}).
18
+ * @param {object} cellProperties The cell meta object (see {@link Core#getCellMeta}).
19
19
  */
20
20
  export function autocompleteRenderer(hotInstance, TD, row, col, prop, value, cellProperties) {
21
21
  const {
@@ -18,7 +18,7 @@ const RENDERER_TYPE = exports.RENDERER_TYPE = 'base';
18
18
  * @param {number} col The visual column index.
19
19
  * @param {number|string} prop The column property (passed when datasource is an array of objects).
20
20
  * @param {*} value The rendered value.
21
- * @param {object} cellProperties The cell meta object ({@see Core#getCellMeta}).
21
+ * @param {object} cellProperties The cell meta object (see {@link Core#getCellMeta}).
22
22
  */
23
23
  function baseRenderer(hotInstance, TD, row, col, prop, value, cellProperties) {
24
24
  const ariaEnabled = cellProperties.ariaTags;
@@ -13,7 +13,7 @@ export const RENDERER_TYPE = 'base';
13
13
  * @param {number} col The visual column index.
14
14
  * @param {number|string} prop The column property (passed when datasource is an array of objects).
15
15
  * @param {*} value The rendered value.
16
- * @param {object} cellProperties The cell meta object ({@see Core#getCellMeta}).
16
+ * @param {object} cellProperties The cell meta object (see {@link Core#getCellMeta}).
17
17
  */
18
18
  export function baseRenderer(hotInstance, TD, row, col, prop, value, cellProperties) {
19
19
  const ariaEnabled = cellProperties.ariaTags;