handsontable 15.0.1-next-ab94a4c-20250207 → 15.1.0-next-dfdf994-20250206

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 (170) hide show
  1. package/3rdparty/walkontable/src/index.js +2 -0
  2. package/3rdparty/walkontable/src/index.mjs +2 -1
  3. package/3rdparty/walkontable/src/overlays.js +2 -39
  4. package/3rdparty/walkontable/src/overlays.mjs +2 -39
  5. package/3rdparty/walkontable/src/renderer/_base.js +3 -4
  6. package/3rdparty/walkontable/src/renderer/_base.mjs +2 -2
  7. package/3rdparty/walkontable/src/renderer/cells.js +7 -11
  8. package/3rdparty/walkontable/src/renderer/cells.mjs +6 -9
  9. package/3rdparty/walkontable/src/renderer/colGroup.js +6 -7
  10. package/3rdparty/walkontable/src/renderer/colGroup.mjs +5 -5
  11. package/3rdparty/walkontable/src/renderer/columnHeaders.js +4 -5
  12. package/3rdparty/walkontable/src/renderer/columnHeaders.mjs +3 -3
  13. package/3rdparty/walkontable/src/renderer/index.js +18 -19
  14. package/3rdparty/walkontable/src/renderer/index.mjs +6 -6
  15. package/3rdparty/walkontable/src/renderer/rowHeaders.js +6 -7
  16. package/3rdparty/walkontable/src/renderer/rowHeaders.mjs +5 -5
  17. package/3rdparty/walkontable/src/renderer/rows.js +23 -11
  18. package/3rdparty/walkontable/src/renderer/rows.mjs +23 -10
  19. package/3rdparty/walkontable/src/renderer/table.js +1 -1
  20. package/3rdparty/walkontable/src/renderer/table.mjs +1 -1
  21. package/3rdparty/walkontable/src/selection/border/border.js +10 -2
  22. package/3rdparty/walkontable/src/selection/border/border.mjs +10 -2
  23. package/3rdparty/walkontable/src/utils/nodesPool.js +21 -6
  24. package/3rdparty/walkontable/src/utils/nodesPool.mjs +21 -6
  25. package/3rdparty/walkontable/src/utils/orderView/index.js +4 -5
  26. package/3rdparty/walkontable/src/utils/orderView/index.mjs +2 -2
  27. package/3rdparty/walkontable/src/utils/orderView/sharedView.js +3 -4
  28. package/3rdparty/walkontable/src/utils/orderView/sharedView.mjs +2 -2
  29. package/3rdparty/walkontable/src/utils/orderView/view.js +60 -76
  30. package/3rdparty/walkontable/src/utils/orderView/view.mjs +59 -74
  31. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.js +138 -0
  32. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.mjs +135 -0
  33. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.js +72 -0
  34. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.mjs +68 -0
  35. package/3rdparty/walkontable/src/utils/orderView/viewSize.js +1 -1
  36. package/3rdparty/walkontable/src/utils/orderView/viewSize.mjs +1 -1
  37. package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.js +4 -5
  38. package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.mjs +3 -3
  39. package/CHANGELOG.md +51 -2
  40. package/README.md +3 -3
  41. package/base.js +2 -2
  42. package/base.mjs +2 -2
  43. package/cellTypes/dropdownType/dropdownType.js +4 -2
  44. package/cellTypes/dropdownType/dropdownType.mjs +4 -2
  45. package/core.js +39 -38
  46. package/core.mjs +36 -35
  47. package/dataMap/dataMap.js +8 -0
  48. package/dataMap/dataMap.mjs +8 -0
  49. package/dataMap/dataSource.js +4 -0
  50. package/dataMap/dataSource.mjs +4 -0
  51. package/dataMap/metaManager/lazyFactoryMap.js +8 -5
  52. package/dataMap/metaManager/lazyFactoryMap.mjs +8 -5
  53. package/dataMap/metaManager/metaSchema.js +24 -9
  54. package/dataMap/metaManager/metaSchema.mjs +24 -9
  55. package/dist/handsontable.css +6 -2
  56. package/dist/handsontable.full.css +6 -2
  57. package/dist/handsontable.full.js +8026 -6927
  58. package/dist/handsontable.full.min.css +3 -3
  59. package/dist/handsontable.full.min.js +530 -528
  60. package/dist/handsontable.js +3833 -2914
  61. package/dist/handsontable.min.css +3 -3
  62. package/dist/handsontable.min.js +35 -33
  63. package/editors/autocompleteEditor/autocompleteEditor.js +1 -3
  64. package/editors/autocompleteEditor/autocompleteEditor.mjs +1 -3
  65. package/editors/dateEditor/dateEditor.js +4 -0
  66. package/editors/dateEditor/dateEditor.mjs +4 -0
  67. package/editors/dropdownEditor/dropdownEditor.js +3 -16
  68. package/editors/dropdownEditor/dropdownEditor.mjs +3 -16
  69. package/editors/handsontableEditor/handsontableEditor.js +4 -4
  70. package/editors/handsontableEditor/handsontableEditor.mjs +4 -4
  71. package/focusManager.js +1 -1
  72. package/focusManager.mjs +1 -1
  73. package/helpers/dom/element.d.ts +0 -1
  74. package/helpers/mixed.js +2 -2
  75. package/helpers/mixed.mjs +2 -2
  76. package/helpers/object.js +4 -0
  77. package/helpers/object.mjs +4 -0
  78. package/package.json +2 -2
  79. package/plugins/base/base.js +0 -7
  80. package/plugins/base/base.mjs +0 -7
  81. package/plugins/comments/comments.js +12 -3
  82. package/plugins/comments/comments.mjs +12 -3
  83. package/plugins/contextMenu/contextMenu.js +2 -7
  84. package/plugins/contextMenu/contextMenu.mjs +2 -7
  85. package/plugins/contextMenu/menu/menu.js +2 -2
  86. package/plugins/contextMenu/menu/menu.mjs +2 -2
  87. package/plugins/contextMenu/predefinedItems/clearColumn.js +15 -4
  88. package/plugins/contextMenu/predefinedItems/clearColumn.mjs +15 -4
  89. package/plugins/copyPaste/copyPaste.js +6 -12
  90. package/plugins/copyPaste/copyPaste.mjs +6 -12
  91. package/plugins/filters/conditionCollection.js +8 -7
  92. package/plugins/filters/conditionCollection.mjs +8 -7
  93. package/plugins/filters/filters.js +26 -16
  94. package/plugins/filters/filters.mjs +26 -16
  95. package/plugins/filters/utils.js +7 -24
  96. package/plugins/filters/utils.mjs +7 -24
  97. package/plugins/hiddenColumns/hiddenColumns.js +1 -3
  98. package/plugins/hiddenColumns/hiddenColumns.mjs +1 -3
  99. package/plugins/hiddenRows/hiddenRows.js +1 -3
  100. package/plugins/hiddenRows/hiddenRows.mjs +1 -3
  101. package/plugins/manualRowMove/manualRowMove.js +1 -1
  102. package/plugins/manualRowMove/manualRowMove.mjs +1 -1
  103. package/plugins/mergeCells/calculations/autofill.js +60 -44
  104. package/plugins/mergeCells/calculations/autofill.mjs +60 -44
  105. package/plugins/mergeCells/cellsCollection.js +25 -8
  106. package/plugins/mergeCells/cellsCollection.mjs +25 -8
  107. package/plugins/mergeCells/mergeCells.js +15 -16
  108. package/plugins/mergeCells/mergeCells.mjs +15 -16
  109. package/plugins/nestedHeaders/nestedHeaders.js +6 -1
  110. package/plugins/nestedHeaders/nestedHeaders.mjs +6 -1
  111. package/plugins/nestedHeaders/stateManager/index.js +1 -2
  112. package/plugins/nestedHeaders/stateManager/index.mjs +1 -2
  113. package/plugins/nestedHeaders/utils/ghostTable.js +4 -0
  114. package/plugins/nestedHeaders/utils/ghostTable.mjs +4 -0
  115. package/plugins/nestedRows/utils/rowMoveController.js +1 -6
  116. package/plugins/nestedRows/utils/rowMoveController.mjs +1 -6
  117. package/plugins/undoRedo/actions/_base.js +19 -0
  118. package/plugins/undoRedo/actions/_base.mjs +15 -0
  119. package/plugins/undoRedo/actions/cellAlignment.js +85 -0
  120. package/plugins/undoRedo/actions/cellAlignment.mjs +81 -0
  121. package/plugins/undoRedo/actions/columnMove.js +84 -0
  122. package/plugins/undoRedo/actions/columnMove.mjs +80 -0
  123. package/plugins/undoRedo/actions/columnSort.js +73 -0
  124. package/plugins/undoRedo/actions/columnSort.mjs +69 -0
  125. package/plugins/undoRedo/actions/createColumn.js +60 -0
  126. package/plugins/undoRedo/actions/createColumn.mjs +56 -0
  127. package/plugins/undoRedo/actions/createRow.js +65 -0
  128. package/plugins/undoRedo/actions/createRow.mjs +61 -0
  129. package/plugins/undoRedo/actions/dataChange.js +123 -0
  130. package/plugins/undoRedo/actions/dataChange.mjs +119 -0
  131. package/plugins/undoRedo/actions/filters.js +66 -0
  132. package/plugins/undoRedo/actions/filters.mjs +62 -0
  133. package/plugins/undoRedo/actions/index.js +27 -0
  134. package/plugins/undoRedo/actions/index.mjs +23 -0
  135. package/plugins/undoRedo/actions/mergeCells.js +63 -0
  136. package/plugins/undoRedo/actions/mergeCells.mjs +59 -0
  137. package/plugins/undoRedo/actions/removeColumn.js +176 -0
  138. package/plugins/undoRedo/actions/removeColumn.mjs +172 -0
  139. package/plugins/undoRedo/actions/removeRow.js +119 -0
  140. package/plugins/undoRedo/actions/removeRow.mjs +115 -0
  141. package/plugins/undoRedo/actions/rowMove.js +84 -0
  142. package/plugins/undoRedo/actions/rowMove.mjs +80 -0
  143. package/plugins/undoRedo/actions/unmergeCells.js +56 -0
  144. package/plugins/undoRedo/actions/unmergeCells.mjs +52 -0
  145. package/plugins/undoRedo/index.js +3 -4
  146. package/plugins/undoRedo/index.mjs +1 -2
  147. package/plugins/undoRedo/undoRedo.js +277 -879
  148. package/plugins/undoRedo/undoRedo.mjs +277 -880
  149. package/plugins/undoRedo/utils.js +37 -0
  150. package/plugins/undoRedo/utils.mjs +33 -0
  151. package/renderers/checkboxRenderer/checkboxRenderer.js +8 -1
  152. package/renderers/checkboxRenderer/checkboxRenderer.mjs +8 -1
  153. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +1 -0
  154. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +1 -0
  155. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +2 -1
  156. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +2 -1
  157. package/styles/handsontable.css +75 -103
  158. package/styles/handsontable.min.css +3 -3
  159. package/styles/ht-theme-horizon.css +2 -2
  160. package/styles/ht-theme-horizon.min.css +2 -2
  161. package/styles/ht-theme-main.css +2 -2
  162. package/styles/ht-theme-main.min.css +2 -2
  163. package/tableView.js +17 -1
  164. package/tableView.mjs +17 -1
  165. package/utils/autoResize.js +1 -1
  166. package/utils/autoResize.mjs +1 -1
  167. package/utils/parseTable.js +1 -1
  168. package/utils/parseTable.mjs +1 -1
  169. package/validators/dateValidator/dateValidator.js +1 -1
  170. package/validators/dateValidator/dateValidator.mjs +1 -1
@@ -2,6 +2,8 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  require("core-js/modules/es.error.cause.js");
5
+ require("core-js/modules/esnext.iterator.constructor.js");
6
+ require("core-js/modules/esnext.iterator.every.js");
5
7
  var _object = require("../../../helpers/object");
6
8
  var _array = require("../../../helpers/array");
7
9
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -38,35 +40,20 @@ class AutofillCalculations {
38
40
  this.mergedCellsCollection = this.plugin.mergedCellsCollection;
39
41
  }
40
42
 
41
- /**
42
- * Correct the provided selection area, so it's not selecting only a part of a merged cell.
43
- *
44
- * @param {Array} selectionArea The selection to correct.
45
- */
46
- correctSelectionAreaSize(selectionArea) {
47
- if (selectionArea[0] === selectionArea[2] && selectionArea[1] === selectionArea[3]) {
48
- const mergedCell = this.mergedCellsCollection.get(selectionArea[0], selectionArea[1]);
49
- if (mergedCell) {
50
- selectionArea[2] = selectionArea[0] + mergedCell.rowspan - 1;
51
- selectionArea[3] = selectionArea[1] + mergedCell.colspan - 1;
52
- }
53
- }
54
- }
55
-
56
43
  /**
57
44
  * Get the direction of the autofill process.
58
45
  *
59
- * @param {Array} selectionArea The selection area.
60
- * @param {Array} finalArea The final area (base + drag).
46
+ * @param {Array} baseArea The selection area.
47
+ * @param {Array} fullArea The final area (base + drag).
61
48
  * @returns {string} `up`, `down`, `left` or `right`.
62
49
  */
63
- getDirection(selectionArea, finalArea) {
50
+ getDirection(baseArea, fullArea) {
64
51
  let direction = null;
65
- if (finalArea[0] === selectionArea[0] && finalArea[1] === selectionArea[1] && finalArea[3] === selectionArea[3]) {
52
+ if (fullArea[0] === baseArea[0] && fullArea[1] === baseArea[1] && fullArea[3] === baseArea[3]) {
66
53
  direction = 'down';
67
- } else if (finalArea[2] === selectionArea[2] && finalArea[1] === selectionArea[1] && finalArea[3] === selectionArea[3]) {
54
+ } else if (fullArea[2] === baseArea[2] && fullArea[1] === baseArea[1] && fullArea[3] === baseArea[3]) {
68
55
  direction = 'up';
69
- } else if (finalArea[1] === selectionArea[1] && finalArea[2] === selectionArea[2]) {
56
+ } else if (fullArea[1] === baseArea[1] && fullArea[2] === baseArea[2]) {
70
57
  direction = 'right';
71
58
  } else {
72
59
  direction = 'left';
@@ -78,20 +65,20 @@ class AutofillCalculations {
78
65
  * Snap the drag area to the farthest merged cell, so it won't clip any of the merged cells.
79
66
  *
80
67
  * @param {Array} baseArea The base selected area.
81
- * @param {Array} dragArea The drag area.
68
+ * @param {Array} fullArea The drag area.
82
69
  * @param {string} dragDirection The autofill drag direction.
83
70
  * @param {Array} foundMergedCells MergeCellCoords found in the base selection area.
84
71
  * @returns {Array} The new drag area.
85
72
  */
86
- snapDragArea(baseArea, dragArea, dragDirection, foundMergedCells) {
87
- const newDragArea = dragArea.slice(0);
88
- const fillSize = this.getAutofillSize(baseArea, dragArea, dragDirection);
73
+ snapDragArea(baseArea, fullArea, dragDirection, foundMergedCells) {
74
+ const newDragArea = fullArea.slice(0);
75
+ const fillSize = this.getAutofillSize(baseArea, fullArea, dragDirection);
89
76
  const [baseAreaStartRow, baseAreaStartColumn, baseAreaEndRow, baseAreaEndColumn] = baseArea;
90
77
  const verticalDirection = ['up', 'down'].indexOf(dragDirection) > -1;
91
78
  const fullCycle = verticalDirection ? baseAreaEndRow - baseAreaStartRow + 1 : baseAreaEndColumn - baseAreaStartColumn + 1;
92
79
  const fulls = Math.floor(fillSize / fullCycle) * fullCycle;
93
80
  const partials = fillSize - fulls;
94
- const farthestCollection = this.getFarthestCollection(baseArea, dragArea, dragDirection, foundMergedCells);
81
+ const farthestCollection = this.getFarthestCollection(baseArea, fullArea, dragDirection, foundMergedCells);
95
82
  if (farthestCollection) {
96
83
  if (dragDirection === 'down') {
97
84
  const fill = farthestCollection.row + farthestCollection.rowspan - baseAreaStartRow - partials;
@@ -156,13 +143,13 @@ class AutofillCalculations {
156
143
  *
157
144
  * @private
158
145
  * @param {Array} baseArea The base selection area.
159
- * @param {Array} dragArea The drag area (containing the base area).
146
+ * @param {Array} fullArea The drag area (containing the base area).
160
147
  * @param {string} direction The drag direction.
161
148
  * @returns {number|null} The "length" (height or width, depending on the direction) of the drag.
162
149
  */
163
- getAutofillSize(baseArea, dragArea, direction) {
150
+ getAutofillSize(baseArea, fullArea, direction) {
164
151
  const [baseAreaStartRow, baseAreaStartColumn, baseAreaEndRow, baseAreaEndColumn] = baseArea;
165
- const [dragAreaStartRow, dragAreaStartColumn, dragAreaEndRow, dragAreaEndColumn] = dragArea;
152
+ const [dragAreaStartRow, dragAreaStartColumn, dragAreaEndRow, dragAreaEndColumn] = fullArea;
166
153
  switch (direction) {
167
154
  case 'up':
168
155
  return baseAreaStartRow - dragAreaStartRow;
@@ -182,22 +169,30 @@ class AutofillCalculations {
182
169
  *
183
170
  * @private
184
171
  * @param {Array} baseArea The base selection area.
185
- * @param {Array} dragArea The base selection area extended by the drag area.
172
+ * @param {Array} fullArea The base selection area extended by the drag area.
186
173
  * @param {string} direction Drag direction.
187
174
  * @returns {Array|null} Array representing the drag area coordinates.
188
175
  */
189
- getDragArea(baseArea, dragArea, direction) {
176
+ getDragArea(baseArea, fullArea, direction) {
190
177
  const [baseAreaStartRow, baseAreaStartColumn, baseAreaEndRow, baseAreaEndColumn] = baseArea;
191
- const [dragAreaStartRow, dragAreaStartColumn, dragAreaEndRow, dragAreaEndColumn] = dragArea;
178
+ const [fullAreaStartRow, fullAreaStartColumn, fullAreaEndRow, fullAreaEndColumn] = fullArea;
192
179
  switch (direction) {
193
180
  case 'up':
194
- return [dragAreaStartRow, dragAreaStartColumn, baseAreaStartRow - 1, baseAreaEndColumn];
181
+ return [fullAreaStartRow, fullAreaStartColumn, baseAreaStartRow - 1, baseAreaEndColumn];
195
182
  case 'down':
196
- return [baseAreaEndRow + 1, baseAreaStartColumn, dragAreaEndRow, baseAreaEndColumn];
183
+ {
184
+ const mergedCell = this.mergedCellsCollection.get(fullAreaEndRow, baseAreaEndColumn);
185
+ const rowShift = mergedCell ? mergedCell.rowspan - 1 : 0;
186
+ return [baseAreaEndRow + 1, baseAreaStartColumn, fullAreaEndRow + rowShift, baseAreaEndColumn];
187
+ }
197
188
  case 'left':
198
- return [dragAreaStartRow, dragAreaStartColumn, baseAreaEndRow, baseAreaStartColumn - 1];
189
+ return [fullAreaStartRow, fullAreaStartColumn, baseAreaEndRow, baseAreaStartColumn - 1];
199
190
  case 'right':
200
- return [baseAreaStartRow, baseAreaEndColumn + 1, dragAreaEndRow, dragAreaEndColumn];
191
+ {
192
+ const mergedCell = this.mergedCellsCollection.get(fullAreaEndRow, baseAreaEndColumn);
193
+ const columnShift = mergedCell ? mergedCell.colspan - 1 : 0;
194
+ return [baseAreaStartRow, baseAreaEndColumn + columnShift, fullAreaEndRow, fullAreaEndColumn];
195
+ }
201
196
  default:
202
197
  return null;
203
198
  }
@@ -208,17 +203,17 @@ class AutofillCalculations {
208
203
  *
209
204
  * @private
210
205
  * @param {Array} baseArea The base selection area.
211
- * @param {Array} dragArea The drag area (containing the base area).
206
+ * @param {Array} fullArea The drag area (containing the base area).
212
207
  * @param {string} direction The drag direction.
213
208
  * @param {Array} mergedCellArray Array of the merged cells found in the base area.
214
209
  * @returns {MergedCellCoords|null}
215
210
  */
216
- getFarthestCollection(baseArea, dragArea, direction, mergedCellArray) {
211
+ getFarthestCollection(baseArea, fullArea, direction, mergedCellArray) {
217
212
  const [baseAreaStartRow, baseAreaStartColumn, baseAreaEndRow, baseAreaEndColumn] = baseArea;
218
213
  const verticalDirection = ['up', 'down'].indexOf(direction) > -1;
219
214
  const baseEnd = verticalDirection ? baseAreaEndRow : baseAreaEndColumn;
220
215
  const baseStart = verticalDirection ? baseAreaStartRow : baseAreaStartColumn;
221
- const fillSize = this.getAutofillSize(baseArea, dragArea, direction);
216
+ const fillSize = this.getAutofillSize(baseArea, fullArea, direction);
222
217
  const fullCycle = verticalDirection ? baseAreaEndRow - baseAreaStartRow + 1 : baseAreaEndColumn - baseAreaStartColumn + 1;
223
218
  const fulls = Math.floor(fillSize / fullCycle) * fullCycle;
224
219
  const partials = fillSize - fulls;
@@ -293,7 +288,7 @@ class AutofillCalculations {
293
288
  rowspan: current.rowspan,
294
289
  col: current.col,
295
290
  colspan: current.colspan
296
- });
291
+ }, true);
297
292
  break;
298
293
  case 'down':
299
294
  this.plugin.mergedCellsCollection.add({
@@ -301,7 +296,7 @@ class AutofillCalculations {
301
296
  rowspan: current.rowspan,
302
297
  col: current.col,
303
298
  colspan: current.colspan
304
- });
299
+ }, true);
305
300
  break;
306
301
  case 'left':
307
302
  this.plugin.mergedCellsCollection.add({
@@ -309,7 +304,7 @@ class AutofillCalculations {
309
304
  rowspan: current.rowspan,
310
305
  col: current.col - fillOffset,
311
306
  colspan: current.colspan
312
- });
307
+ }, true);
313
308
  break;
314
309
  case 'right':
315
310
  this.plugin.mergedCellsCollection.add({
@@ -317,7 +312,7 @@ class AutofillCalculations {
317
312
  rowspan: current.rowspan,
318
313
  col: current.col + fillOffset,
319
314
  colspan: current.colspan
320
- });
315
+ }, true);
321
316
  break;
322
317
  default:
323
318
  }
@@ -392,7 +387,28 @@ class AutofillCalculations {
392
387
  const topLeft = this.plugin.hot._createCellCoords(dragAreaStartRow, dragAreaStartColumn);
393
388
  const bottomRight = this.plugin.hot._createCellCoords(dragAreaEndRow, dragAreaEndColumn);
394
389
  const dragRange = this.plugin.hot._createCellRange(topLeft, topLeft, bottomRight);
395
- return this.mergedCellsCollection.getWithinRange(dragRange, true).length > 0;
390
+ const mergedCellsWithPartials = this.mergedCellsCollection.getWithinRange(dragRange, true);
391
+ if (mergedCellsWithPartials.length === 0) {
392
+ return false;
393
+ }
394
+ const mergedCellsWithoutPartials = this.mergedCellsCollection.getWithinRange(dragRange, false);
395
+ if (mergedCellsWithoutPartials.length === 0) {
396
+ return true;
397
+ }
398
+ if (direction === 'up' || direction === 'down') {
399
+ return !mergedCellsWithoutPartials.every(_ref => {
400
+ let {
401
+ colspan
402
+ } = _ref;
403
+ return colspan === dragRange.getWidth();
404
+ });
405
+ }
406
+ return !mergedCellsWithoutPartials.every(_ref2 => {
407
+ let {
408
+ rowspan
409
+ } = _ref2;
410
+ return rowspan === dragRange.getHeight();
411
+ });
396
412
  }
397
413
  }
398
414
  var _default = exports.default = AutofillCalculations;
@@ -1,4 +1,6 @@
1
1
  import "core-js/modules/es.error.cause.js";
2
+ import "core-js/modules/esnext.iterator.constructor.js";
3
+ import "core-js/modules/esnext.iterator.every.js";
2
4
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
4
6
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -35,35 +37,20 @@ class AutofillCalculations {
35
37
  this.mergedCellsCollection = this.plugin.mergedCellsCollection;
36
38
  }
37
39
 
38
- /**
39
- * Correct the provided selection area, so it's not selecting only a part of a merged cell.
40
- *
41
- * @param {Array} selectionArea The selection to correct.
42
- */
43
- correctSelectionAreaSize(selectionArea) {
44
- if (selectionArea[0] === selectionArea[2] && selectionArea[1] === selectionArea[3]) {
45
- const mergedCell = this.mergedCellsCollection.get(selectionArea[0], selectionArea[1]);
46
- if (mergedCell) {
47
- selectionArea[2] = selectionArea[0] + mergedCell.rowspan - 1;
48
- selectionArea[3] = selectionArea[1] + mergedCell.colspan - 1;
49
- }
50
- }
51
- }
52
-
53
40
  /**
54
41
  * Get the direction of the autofill process.
55
42
  *
56
- * @param {Array} selectionArea The selection area.
57
- * @param {Array} finalArea The final area (base + drag).
43
+ * @param {Array} baseArea The selection area.
44
+ * @param {Array} fullArea The final area (base + drag).
58
45
  * @returns {string} `up`, `down`, `left` or `right`.
59
46
  */
60
- getDirection(selectionArea, finalArea) {
47
+ getDirection(baseArea, fullArea) {
61
48
  let direction = null;
62
- if (finalArea[0] === selectionArea[0] && finalArea[1] === selectionArea[1] && finalArea[3] === selectionArea[3]) {
49
+ if (fullArea[0] === baseArea[0] && fullArea[1] === baseArea[1] && fullArea[3] === baseArea[3]) {
63
50
  direction = 'down';
64
- } else if (finalArea[2] === selectionArea[2] && finalArea[1] === selectionArea[1] && finalArea[3] === selectionArea[3]) {
51
+ } else if (fullArea[2] === baseArea[2] && fullArea[1] === baseArea[1] && fullArea[3] === baseArea[3]) {
65
52
  direction = 'up';
66
- } else if (finalArea[1] === selectionArea[1] && finalArea[2] === selectionArea[2]) {
53
+ } else if (fullArea[1] === baseArea[1] && fullArea[2] === baseArea[2]) {
67
54
  direction = 'right';
68
55
  } else {
69
56
  direction = 'left';
@@ -75,20 +62,20 @@ class AutofillCalculations {
75
62
  * Snap the drag area to the farthest merged cell, so it won't clip any of the merged cells.
76
63
  *
77
64
  * @param {Array} baseArea The base selected area.
78
- * @param {Array} dragArea The drag area.
65
+ * @param {Array} fullArea The drag area.
79
66
  * @param {string} dragDirection The autofill drag direction.
80
67
  * @param {Array} foundMergedCells MergeCellCoords found in the base selection area.
81
68
  * @returns {Array} The new drag area.
82
69
  */
83
- snapDragArea(baseArea, dragArea, dragDirection, foundMergedCells) {
84
- const newDragArea = dragArea.slice(0);
85
- const fillSize = this.getAutofillSize(baseArea, dragArea, dragDirection);
70
+ snapDragArea(baseArea, fullArea, dragDirection, foundMergedCells) {
71
+ const newDragArea = fullArea.slice(0);
72
+ const fillSize = this.getAutofillSize(baseArea, fullArea, dragDirection);
86
73
  const [baseAreaStartRow, baseAreaStartColumn, baseAreaEndRow, baseAreaEndColumn] = baseArea;
87
74
  const verticalDirection = ['up', 'down'].indexOf(dragDirection) > -1;
88
75
  const fullCycle = verticalDirection ? baseAreaEndRow - baseAreaStartRow + 1 : baseAreaEndColumn - baseAreaStartColumn + 1;
89
76
  const fulls = Math.floor(fillSize / fullCycle) * fullCycle;
90
77
  const partials = fillSize - fulls;
91
- const farthestCollection = this.getFarthestCollection(baseArea, dragArea, dragDirection, foundMergedCells);
78
+ const farthestCollection = this.getFarthestCollection(baseArea, fullArea, dragDirection, foundMergedCells);
92
79
  if (farthestCollection) {
93
80
  if (dragDirection === 'down') {
94
81
  const fill = farthestCollection.row + farthestCollection.rowspan - baseAreaStartRow - partials;
@@ -153,13 +140,13 @@ class AutofillCalculations {
153
140
  *
154
141
  * @private
155
142
  * @param {Array} baseArea The base selection area.
156
- * @param {Array} dragArea The drag area (containing the base area).
143
+ * @param {Array} fullArea The drag area (containing the base area).
157
144
  * @param {string} direction The drag direction.
158
145
  * @returns {number|null} The "length" (height or width, depending on the direction) of the drag.
159
146
  */
160
- getAutofillSize(baseArea, dragArea, direction) {
147
+ getAutofillSize(baseArea, fullArea, direction) {
161
148
  const [baseAreaStartRow, baseAreaStartColumn, baseAreaEndRow, baseAreaEndColumn] = baseArea;
162
- const [dragAreaStartRow, dragAreaStartColumn, dragAreaEndRow, dragAreaEndColumn] = dragArea;
149
+ const [dragAreaStartRow, dragAreaStartColumn, dragAreaEndRow, dragAreaEndColumn] = fullArea;
163
150
  switch (direction) {
164
151
  case 'up':
165
152
  return baseAreaStartRow - dragAreaStartRow;
@@ -179,22 +166,30 @@ class AutofillCalculations {
179
166
  *
180
167
  * @private
181
168
  * @param {Array} baseArea The base selection area.
182
- * @param {Array} dragArea The base selection area extended by the drag area.
169
+ * @param {Array} fullArea The base selection area extended by the drag area.
183
170
  * @param {string} direction Drag direction.
184
171
  * @returns {Array|null} Array representing the drag area coordinates.
185
172
  */
186
- getDragArea(baseArea, dragArea, direction) {
173
+ getDragArea(baseArea, fullArea, direction) {
187
174
  const [baseAreaStartRow, baseAreaStartColumn, baseAreaEndRow, baseAreaEndColumn] = baseArea;
188
- const [dragAreaStartRow, dragAreaStartColumn, dragAreaEndRow, dragAreaEndColumn] = dragArea;
175
+ const [fullAreaStartRow, fullAreaStartColumn, fullAreaEndRow, fullAreaEndColumn] = fullArea;
189
176
  switch (direction) {
190
177
  case 'up':
191
- return [dragAreaStartRow, dragAreaStartColumn, baseAreaStartRow - 1, baseAreaEndColumn];
178
+ return [fullAreaStartRow, fullAreaStartColumn, baseAreaStartRow - 1, baseAreaEndColumn];
192
179
  case 'down':
193
- return [baseAreaEndRow + 1, baseAreaStartColumn, dragAreaEndRow, baseAreaEndColumn];
180
+ {
181
+ const mergedCell = this.mergedCellsCollection.get(fullAreaEndRow, baseAreaEndColumn);
182
+ const rowShift = mergedCell ? mergedCell.rowspan - 1 : 0;
183
+ return [baseAreaEndRow + 1, baseAreaStartColumn, fullAreaEndRow + rowShift, baseAreaEndColumn];
184
+ }
194
185
  case 'left':
195
- return [dragAreaStartRow, dragAreaStartColumn, baseAreaEndRow, baseAreaStartColumn - 1];
186
+ return [fullAreaStartRow, fullAreaStartColumn, baseAreaEndRow, baseAreaStartColumn - 1];
196
187
  case 'right':
197
- return [baseAreaStartRow, baseAreaEndColumn + 1, dragAreaEndRow, dragAreaEndColumn];
188
+ {
189
+ const mergedCell = this.mergedCellsCollection.get(fullAreaEndRow, baseAreaEndColumn);
190
+ const columnShift = mergedCell ? mergedCell.colspan - 1 : 0;
191
+ return [baseAreaStartRow, baseAreaEndColumn + columnShift, fullAreaEndRow, fullAreaEndColumn];
192
+ }
198
193
  default:
199
194
  return null;
200
195
  }
@@ -205,17 +200,17 @@ class AutofillCalculations {
205
200
  *
206
201
  * @private
207
202
  * @param {Array} baseArea The base selection area.
208
- * @param {Array} dragArea The drag area (containing the base area).
203
+ * @param {Array} fullArea The drag area (containing the base area).
209
204
  * @param {string} direction The drag direction.
210
205
  * @param {Array} mergedCellArray Array of the merged cells found in the base area.
211
206
  * @returns {MergedCellCoords|null}
212
207
  */
213
- getFarthestCollection(baseArea, dragArea, direction, mergedCellArray) {
208
+ getFarthestCollection(baseArea, fullArea, direction, mergedCellArray) {
214
209
  const [baseAreaStartRow, baseAreaStartColumn, baseAreaEndRow, baseAreaEndColumn] = baseArea;
215
210
  const verticalDirection = ['up', 'down'].indexOf(direction) > -1;
216
211
  const baseEnd = verticalDirection ? baseAreaEndRow : baseAreaEndColumn;
217
212
  const baseStart = verticalDirection ? baseAreaStartRow : baseAreaStartColumn;
218
- const fillSize = this.getAutofillSize(baseArea, dragArea, direction);
213
+ const fillSize = this.getAutofillSize(baseArea, fullArea, direction);
219
214
  const fullCycle = verticalDirection ? baseAreaEndRow - baseAreaStartRow + 1 : baseAreaEndColumn - baseAreaStartColumn + 1;
220
215
  const fulls = Math.floor(fillSize / fullCycle) * fullCycle;
221
216
  const partials = fillSize - fulls;
@@ -290,7 +285,7 @@ class AutofillCalculations {
290
285
  rowspan: current.rowspan,
291
286
  col: current.col,
292
287
  colspan: current.colspan
293
- });
288
+ }, true);
294
289
  break;
295
290
  case 'down':
296
291
  this.plugin.mergedCellsCollection.add({
@@ -298,7 +293,7 @@ class AutofillCalculations {
298
293
  rowspan: current.rowspan,
299
294
  col: current.col,
300
295
  colspan: current.colspan
301
- });
296
+ }, true);
302
297
  break;
303
298
  case 'left':
304
299
  this.plugin.mergedCellsCollection.add({
@@ -306,7 +301,7 @@ class AutofillCalculations {
306
301
  rowspan: current.rowspan,
307
302
  col: current.col - fillOffset,
308
303
  colspan: current.colspan
309
- });
304
+ }, true);
310
305
  break;
311
306
  case 'right':
312
307
  this.plugin.mergedCellsCollection.add({
@@ -314,7 +309,7 @@ class AutofillCalculations {
314
309
  rowspan: current.rowspan,
315
310
  col: current.col + fillOffset,
316
311
  colspan: current.colspan
317
- });
312
+ }, true);
318
313
  break;
319
314
  default:
320
315
  }
@@ -389,7 +384,28 @@ class AutofillCalculations {
389
384
  const topLeft = this.plugin.hot._createCellCoords(dragAreaStartRow, dragAreaStartColumn);
390
385
  const bottomRight = this.plugin.hot._createCellCoords(dragAreaEndRow, dragAreaEndColumn);
391
386
  const dragRange = this.plugin.hot._createCellRange(topLeft, topLeft, bottomRight);
392
- return this.mergedCellsCollection.getWithinRange(dragRange, true).length > 0;
387
+ const mergedCellsWithPartials = this.mergedCellsCollection.getWithinRange(dragRange, true);
388
+ if (mergedCellsWithPartials.length === 0) {
389
+ return false;
390
+ }
391
+ const mergedCellsWithoutPartials = this.mergedCellsCollection.getWithinRange(dragRange, false);
392
+ if (mergedCellsWithoutPartials.length === 0) {
393
+ return true;
394
+ }
395
+ if (direction === 'up' || direction === 'down') {
396
+ return !mergedCellsWithoutPartials.every(_ref => {
397
+ let {
398
+ colspan
399
+ } = _ref;
400
+ return colspan === dragRange.getWidth();
401
+ });
402
+ }
403
+ return !mergedCellsWithoutPartials.every(_ref2 => {
404
+ let {
405
+ rowspan
406
+ } = _ref2;
407
+ return rowspan === dragRange.getHeight();
408
+ });
393
409
  }
394
410
  }
395
411
  export default AutofillCalculations;
@@ -109,18 +109,33 @@ class MergedCellsCollection {
109
109
  /**
110
110
  * Get the first-found merged cell containing the provided range.
111
111
  *
112
- * @param {CellRange|object} range The range to search merged cells for.
113
- * @returns {MergedCellCoords|boolean}
112
+ * @param {CellRange} range The range to search merged cells for.
113
+ * @returns {MergedCellCoords | false}
114
114
  */
115
115
  getByRange(range) {
116
+ const {
117
+ row: rowStart,
118
+ col: columnStart
119
+ } = range.getTopStartCorner();
120
+ const {
121
+ row: rowEnd,
122
+ col: columnEnd
123
+ } = range.getBottomEndCorner();
124
+ const mergedCellsLength = this.mergedCells.length;
116
125
  let result = false;
117
- (0, _array.arrayEach)(this.mergedCells, mergedCell => {
118
- if (mergedCell.row <= range.from.row && mergedCell.row + mergedCell.rowspan - 1 >= range.to.row && mergedCell.col <= range.from.col && mergedCell.col + mergedCell.colspan - 1 >= range.to.col) {
126
+ for (let i = 0; i < mergedCellsLength; i++) {
127
+ const mergedCell = this.mergedCells[i];
128
+ const {
129
+ row,
130
+ col,
131
+ rowspan,
132
+ colspan
133
+ } = mergedCell;
134
+ if (row >= rowStart && row + rowspan - 1 <= rowEnd && col >= columnStart && col + colspan - 1 <= columnEnd) {
119
135
  result = mergedCell;
120
- return result;
136
+ break;
121
137
  }
122
- return true;
123
- });
138
+ }
124
139
  return result;
125
140
  }
126
141
 
@@ -230,7 +245,9 @@ class MergedCellsCollection {
230
245
  _assertClassBrand(_MergedCellsCollection_brand, this, _addMergedCellToMatrix).call(this, newMergedCell);
231
246
  return newMergedCell;
232
247
  }
233
- (0, _console.warn)(MergedCellsCollection.IS_OVERLAPPING_WARNING(newMergedCell));
248
+ if (isOverlapping) {
249
+ (0, _console.warn)(MergedCellsCollection.IS_OVERLAPPING_WARNING(newMergedCell));
250
+ }
234
251
  return false;
235
252
  }
236
253
 
@@ -105,18 +105,33 @@ class MergedCellsCollection {
105
105
  /**
106
106
  * Get the first-found merged cell containing the provided range.
107
107
  *
108
- * @param {CellRange|object} range The range to search merged cells for.
109
- * @returns {MergedCellCoords|boolean}
108
+ * @param {CellRange} range The range to search merged cells for.
109
+ * @returns {MergedCellCoords | false}
110
110
  */
111
111
  getByRange(range) {
112
+ const {
113
+ row: rowStart,
114
+ col: columnStart
115
+ } = range.getTopStartCorner();
116
+ const {
117
+ row: rowEnd,
118
+ col: columnEnd
119
+ } = range.getBottomEndCorner();
120
+ const mergedCellsLength = this.mergedCells.length;
112
121
  let result = false;
113
- arrayEach(this.mergedCells, mergedCell => {
114
- if (mergedCell.row <= range.from.row && mergedCell.row + mergedCell.rowspan - 1 >= range.to.row && mergedCell.col <= range.from.col && mergedCell.col + mergedCell.colspan - 1 >= range.to.col) {
122
+ for (let i = 0; i < mergedCellsLength; i++) {
123
+ const mergedCell = this.mergedCells[i];
124
+ const {
125
+ row,
126
+ col,
127
+ rowspan,
128
+ colspan
129
+ } = mergedCell;
130
+ if (row >= rowStart && row + rowspan - 1 <= rowEnd && col >= columnStart && col + colspan - 1 <= columnEnd) {
115
131
  result = mergedCell;
116
- return result;
132
+ break;
117
133
  }
118
- return true;
119
- });
134
+ }
120
135
  return result;
121
136
  }
122
137
 
@@ -226,7 +241,9 @@ class MergedCellsCollection {
226
241
  _assertClassBrand(_MergedCellsCollection_brand, this, _addMergedCellToMatrix).call(this, newMergedCell);
227
242
  return newMergedCell;
228
243
  }
229
- warn(MergedCellsCollection.IS_OVERLAPPING_WARNING(newMergedCell));
244
+ if (isOverlapping) {
245
+ warn(MergedCellsCollection.IS_OVERLAPPING_WARNING(newMergedCell));
246
+ }
230
247
  return false;
231
248
  }
232
249
 
@@ -909,8 +909,8 @@ class MergeCells extends _base.BasePlugin {
909
909
  /**
910
910
  * The `modifyAutofillRange` hook callback.
911
911
  *
912
- * @param {Array} drag The drag area coordinates.
913
- * @param {Array} select The selection information.
912
+ * @param {Array} fullArea The drag + base area coordinates.
913
+ * @param {Array} baseArea The selection information.
914
914
  * @returns {Array} The new drag area.
915
915
  */
916
916
  }
@@ -1294,23 +1294,19 @@ function _onAfterViewportColumnCalculatorOverride(calc) {
1294
1294
  this.modifyViewportColumnStart(calc, nrOfRows);
1295
1295
  this.modifyViewportColumnEnd(calc, nrOfRows);
1296
1296
  }
1297
- function _onModifyAutofillRange(drag, select) {
1298
- this.autofillCalculations.correctSelectionAreaSize(select);
1299
- const dragDirection = this.autofillCalculations.getDirection(select, drag);
1300
- let dragArea = drag;
1301
- if (this.autofillCalculations.dragAreaOverlapsCollections(select, dragArea, dragDirection)) {
1302
- dragArea = select;
1303
- return dragArea;
1297
+ function _onModifyAutofillRange(fullArea, baseArea) {
1298
+ const dragDirection = this.autofillCalculations.getDirection(baseArea, fullArea);
1299
+ if (this.autofillCalculations.dragAreaOverlapsCollections(baseArea, fullArea, dragDirection)) {
1300
+ return baseArea;
1304
1301
  }
1305
- const from = this.hot._createCellCoords(select[0], select[1]);
1306
- const to = this.hot._createCellCoords(select[2], select[3]);
1302
+ const from = this.hot._createCellCoords(baseArea[0], baseArea[1]);
1303
+ const to = this.hot._createCellCoords(baseArea[2], baseArea[3]);
1307
1304
  const range = this.hot._createCellRange(from, from, to);
1308
1305
  const mergedCellsWithinSelectionArea = this.mergedCellsCollection.getWithinRange(range);
1309
1306
  if (mergedCellsWithinSelectionArea.length === 0) {
1310
- return dragArea;
1307
+ return fullArea;
1311
1308
  }
1312
- dragArea = this.autofillCalculations.snapDragArea(select, dragArea, dragDirection, mergedCellsWithinSelectionArea);
1313
- return dragArea;
1309
+ return this.autofillCalculations.snapDragArea(baseArea, fullArea, dragDirection, mergedCellsWithinSelectionArea);
1314
1310
  }
1315
1311
  /**
1316
1312
  * `afterCreateCol` hook callback.
@@ -1474,7 +1470,6 @@ function _onModifyRowHeightByOverlayName(height, row, overlayType) {
1474
1470
  rowspanCorrection = maxRowspan - mergedCellsWithinRange[0].rowspan;
1475
1471
  }
1476
1472
  mergedCellsWithinRange.forEach(_ref2 => {
1477
- var _height;
1478
1473
  let {
1479
1474
  rowspan
1480
1475
  } = _ref2;
@@ -1484,7 +1479,7 @@ function _onModifyRowHeightByOverlayName(height, row, overlayType) {
1484
1479
  } else {
1485
1480
  rowspanAfterCorrection = rowspan - rowspanCorrection;
1486
1481
  }
1487
- height = Math.max((_height = height) !== null && _height !== void 0 ? _height : 0, _assertClassBrand(_MergeCells_brand, this, _sumCellsHeights).call(this, row, rowspanAfterCorrection));
1482
+ height = Math.max(height !== null && height !== void 0 ? height : 0, _assertClassBrand(_MergeCells_brand, this, _sumCellsHeights).call(this, row, rowspanAfterCorrection));
1488
1483
  });
1489
1484
  return height;
1490
1485
  }
@@ -1496,6 +1491,7 @@ function _onModifyRowHeightByOverlayName(height, row, overlayType) {
1496
1491
  * @returns {number}
1497
1492
  */
1498
1493
  function _sumCellsHeights(row, rowspan) {
1494
+ const stylesHandler = this.hot.view.getStylesHandler();
1499
1495
  const defaultHeight = this.hot.view.getDefaultRowHeight();
1500
1496
  const autoRowSizePlugin = this.hot.getPlugin('autoRowSize');
1501
1497
  let height = 0;
@@ -1503,6 +1499,9 @@ function _sumCellsHeights(row, rowspan) {
1503
1499
  if (!this.hot.rowIndexMapper.isHidden(i)) {
1504
1500
  var _autoRowSizePlugin$ge;
1505
1501
  height += (_autoRowSizePlugin$ge = autoRowSizePlugin === null || autoRowSizePlugin === void 0 ? void 0 : autoRowSizePlugin.getRowHeight(i)) !== null && _autoRowSizePlugin$ge !== void 0 ? _autoRowSizePlugin$ge : defaultHeight;
1502
+ if (i === 0 && !stylesHandler.isClassicTheme()) {
1503
+ height += 1; // border-top-width
1504
+ }
1506
1505
  }
1507
1506
  }
1508
1507
  return height;