handsontable 0.0.0-next-221e46b-20240307 → 0.0.0-next-200799f-20240311

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.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

Files changed (98) hide show
  1. package/3rdparty/walkontable/src/cell/range.d.ts +1 -0
  2. package/3rdparty/walkontable/src/cell/range.js +22 -5
  3. package/3rdparty/walkontable/src/cell/range.mjs +22 -5
  4. package/base.js +2 -2
  5. package/base.mjs +2 -2
  6. package/core/viewportScroll/index.js +4 -1
  7. package/core/viewportScroll/index.mjs +4 -1
  8. package/core/viewportScroll/scrollStrategies/focusScroll.js +15 -0
  9. package/core/viewportScroll/scrollStrategies/focusScroll.mjs +11 -0
  10. package/core.d.ts +4 -3
  11. package/core.js +78 -21
  12. package/core.mjs +78 -21
  13. package/dist/handsontable.css +2 -2
  14. package/dist/handsontable.full.css +2 -2
  15. package/dist/handsontable.full.js +2645 -1363
  16. package/dist/handsontable.full.min.css +2 -2
  17. package/dist/handsontable.full.min.js +152 -152
  18. package/dist/handsontable.js +2645 -1363
  19. package/dist/handsontable.min.css +2 -2
  20. package/dist/handsontable.min.js +32 -32
  21. package/editorManager.js +12 -8
  22. package/editorManager.mjs +12 -8
  23. package/helpers/mixed.js +1 -1
  24. package/helpers/mixed.mjs +1 -1
  25. package/package.json +1 -1
  26. package/pluginHooks.d.ts +1 -0
  27. package/pluginHooks.js +43 -1
  28. package/pluginHooks.mjs +43 -1
  29. package/plugins/collapsibleColumns/collapsibleColumns.js +7 -1
  30. package/plugins/collapsibleColumns/collapsibleColumns.mjs +7 -1
  31. package/plugins/columnSorting/columnSorting.js +6 -0
  32. package/plugins/columnSorting/columnSorting.mjs +6 -0
  33. package/plugins/contextMenu/menu/defaultShortcutsList.js +26 -10
  34. package/plugins/contextMenu/menu/defaultShortcutsList.mjs +26 -10
  35. package/plugins/mergeCells/calculations/selection.js +1 -70
  36. package/plugins/mergeCells/calculations/selection.mjs +1 -70
  37. package/plugins/mergeCells/cellsCollection.js +116 -0
  38. package/plugins/mergeCells/cellsCollection.mjs +116 -0
  39. package/plugins/mergeCells/contextMenuItem/toggleMerge.js +11 -1
  40. package/plugins/mergeCells/contextMenuItem/toggleMerge.mjs +11 -1
  41. package/plugins/mergeCells/focusOrder.js +258 -0
  42. package/plugins/mergeCells/focusOrder.mjs +253 -0
  43. package/plugins/mergeCells/mergeCells.js +394 -199
  44. package/plugins/mergeCells/mergeCells.mjs +394 -199
  45. package/plugins/multiColumnSorting/multiColumnSorting.js +6 -0
  46. package/plugins/multiColumnSorting/multiColumnSorting.mjs +6 -0
  47. package/plugins/nestedHeaders/nestedHeaders.js +1 -0
  48. package/plugins/nestedHeaders/nestedHeaders.mjs +1 -0
  49. package/plugins/nestedRows/nestedRows.js +7 -1
  50. package/plugins/nestedRows/nestedRows.mjs +7 -1
  51. package/renderers/checkboxRenderer/checkboxRenderer.js +4 -4
  52. package/renderers/checkboxRenderer/checkboxRenderer.mjs +4 -4
  53. package/selection/highlight/visualSelection.js +16 -2
  54. package/selection/highlight/visualSelection.mjs +16 -2
  55. package/selection/selection.js +225 -44
  56. package/selection/selection.mjs +224 -43
  57. package/selection/transformation.js +86 -32
  58. package/selection/transformation.mjs +86 -32
  59. package/shortcutContexts/commands/editor/closeAndSave.js +2 -2
  60. package/shortcutContexts/commands/editor/closeAndSave.mjs +2 -2
  61. package/shortcutContexts/commands/editor/open.js +18 -3
  62. package/shortcutContexts/commands/editor/open.mjs +18 -3
  63. package/shortcutContexts/commands/extendCellsSelection/down.js +1 -1
  64. package/shortcutContexts/commands/extendCellsSelection/down.mjs +1 -1
  65. package/shortcutContexts/commands/extendCellsSelection/left.js +1 -1
  66. package/shortcutContexts/commands/extendCellsSelection/left.mjs +1 -1
  67. package/shortcutContexts/commands/extendCellsSelection/right.js +1 -1
  68. package/shortcutContexts/commands/extendCellsSelection/right.mjs +1 -1
  69. package/shortcutContexts/commands/extendCellsSelection/toColumns.js +1 -1
  70. package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +1 -1
  71. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +3 -1
  72. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +3 -1
  73. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +9 -3
  74. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +9 -3
  75. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +10 -3
  76. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +10 -3
  77. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +3 -1
  78. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +3 -1
  79. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +3 -1
  80. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +3 -1
  81. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +3 -1
  82. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +3 -1
  83. package/shortcutContexts/commands/extendCellsSelection/toRows.js +1 -1
  84. package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +1 -1
  85. package/shortcutContexts/commands/extendCellsSelection/up.js +1 -1
  86. package/shortcutContexts/commands/extendCellsSelection/up.mjs +1 -1
  87. package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +6 -1
  88. package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +6 -1
  89. package/shortcutContexts/commands/moveCellSelection/inlineStart.js +6 -1
  90. package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +6 -1
  91. package/shortcutContexts/grid.js +2 -2
  92. package/shortcutContexts/grid.mjs +2 -2
  93. package/shortcuts/context.js +2 -1
  94. package/shortcuts/context.mjs +2 -1
  95. package/tableView.js +20 -0
  96. package/tableView.mjs +20 -0
  97. package/utils/dataStructures/linkedList.js +6 -1
  98. package/utils/dataStructures/linkedList.mjs +6 -1
@@ -17,6 +17,7 @@ var _number = require("../../helpers/number");
17
17
  var _utils = require("./utils");
18
18
  var _element = require("../../helpers/dom/element");
19
19
  var _browser = require("../../helpers/browser");
20
+ var _focusOrder2 = require("./focusOrder");
20
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
22
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
22
23
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
@@ -75,16 +76,21 @@ const SHORTCUTS_GROUP = PLUGIN_KEY;
75
76
  * ```
76
77
  * :::
77
78
  */
78
- var _lastDesiredCoords = /*#__PURE__*/new WeakMap();
79
+ var _lastSelectedCoords = /*#__PURE__*/new WeakMap();
80
+ var _focusOrder = /*#__PURE__*/new WeakMap();
79
81
  var _onAfterInit = /*#__PURE__*/new WeakSet();
80
82
  var _onAfterIsMultipleSelection = /*#__PURE__*/new WeakSet();
83
+ var _onModifyTransformFocus = /*#__PURE__*/new WeakSet();
81
84
  var _onModifyTransformStart = /*#__PURE__*/new WeakSet();
82
85
  var _onModifyTransformEnd = /*#__PURE__*/new WeakSet();
86
+ var _onModifyTransformEndRestDelta = /*#__PURE__*/new WeakSet();
87
+ var _onBeforeSelectionHighlightSet = /*#__PURE__*/new WeakSet();
83
88
  var _onModifyGetCellCoords = /*#__PURE__*/new WeakSet();
84
89
  var _addMergeActionsToContextMenu = /*#__PURE__*/new WeakSet();
85
90
  var _onAfterRenderer = /*#__PURE__*/new WeakSet();
86
91
  var _onBeforeSetRangeStart = /*#__PURE__*/new WeakSet();
87
- var _onBeforeSetRangeEnd = /*#__PURE__*/new WeakSet();
92
+ var _onAfterSelectionFocusSet = /*#__PURE__*/new WeakSet();
93
+ var _onAfterSelectionEnd = /*#__PURE__*/new WeakSet();
88
94
  var _onAfterGetCellMeta = /*#__PURE__*/new WeakSet();
89
95
  var _onAfterViewportRowCalculatorOverride = /*#__PURE__*/new WeakSet();
90
96
  var _onAfterViewportColumnCalculatorOverride = /*#__PURE__*/new WeakSet();
@@ -95,7 +101,6 @@ var _onAfterCreateRow = /*#__PURE__*/new WeakSet();
95
101
  var _onAfterRemoveRow = /*#__PURE__*/new WeakSet();
96
102
  var _onAfterChange = /*#__PURE__*/new WeakSet();
97
103
  var _onBeforeDrawAreaBorders = /*#__PURE__*/new WeakSet();
98
- var _onAfterModifyTransformStart = /*#__PURE__*/new WeakSet();
99
104
  var _onAfterDrawSelection = /*#__PURE__*/new WeakSet();
100
105
  var _onBeforeRemoveCellClassNames = /*#__PURE__*/new WeakSet();
101
106
  var _onBeforeBeginEditing = /*#__PURE__*/new WeakSet();
@@ -131,17 +136,6 @@ class MergeCells extends _base.BasePlugin {
131
136
  * processed cell.
132
137
  */
133
138
  _classPrivateMethodInitSpec(this, _onAfterDrawSelection);
134
- /**
135
- * `afterModifyTransformStart` hook callback. Fixes a problem with navigating through merged cells at the edges of
136
- * the table with the <kbd>**Enter**</kbd>/<kbd>**Shift**</kbd>+<kbd>**Enter**</kbd>/<kbd>**Tab**</kbd>/<kbd>**Shift**</kbd>+<kbd>**Tab**</kbd> keys.
137
- *
138
- * @param {CellCoords} coords Coordinates of the to-be-selected cell.
139
- * @param {number} rowTransformDir Row transformation direction (negative value = up, 0 = none, positive value =
140
- * down).
141
- * @param {number} colTransformDir Column transformation direction (negative value = up, 0 = none, positive value =
142
- * down).
143
- */
144
- _classPrivateMethodInitSpec(this, _onAfterModifyTransformStart);
145
139
  /**
146
140
  * `beforeDrawAreaBorders` hook callback.
147
141
  *
@@ -214,20 +208,18 @@ class MergeCells extends _base.BasePlugin {
214
208
  */
215
209
  _classPrivateMethodInitSpec(this, _onAfterGetCellMeta);
216
210
  /**
217
- * `beforeSetRangeEnd` hook callback.
218
- * While selecting cells with keyboard or mouse, make sure that rectangular area is expanded to the extent of the
219
- * merged cell.
220
- *
221
- * Note: Please keep in mind that callback may modify both start and end range coordinates by the reference.
222
- *
223
- * @param {object} coords Cell coords.
211
+ * Creates the horizontal and vertical cells order matrix (linked lists) for focused cell.
224
212
  */
225
- _classPrivateMethodInitSpec(this, _onBeforeSetRangeEnd);
213
+ _classPrivateMethodInitSpec(this, _onAfterSelectionEnd);
226
214
  /**
227
- * `beforeSetRangeStart` and `beforeSetRangeStartOnly` hook callback.
228
- * A selection within merge area should be rewritten to the start of merge area.
215
+ * Searches for the node that is currently focused within the vertical and horizontal linked lists.
229
216
  *
230
- * @param {object} coords Cell coords.
217
+ * @param {number} row Visual row index.
218
+ * @param {number} column Visual column index.
219
+ */
220
+ _classPrivateMethodInitSpec(this, _onAfterSelectionFocusSet);
221
+ /**
222
+ * Clears the last selected coordinates before setting a new selection range.
231
223
  */
232
224
  _classPrivateMethodInitSpec(this, _onBeforeSetRangeStart);
233
225
  /**
@@ -253,9 +245,23 @@ class MergeCells extends _base.BasePlugin {
253
245
  */
254
246
  _classPrivateMethodInitSpec(this, _onModifyGetCellCoords);
255
247
  /**
256
- * `modifyTransformEnd` hook callback. Needed to handle "jumping over" merged merged cells, while selecting.
248
+ * The hook corrects the range (before drawing it) after the selection was made on the merged cells.
249
+ * It expands the range to cover the entire area of the selected merged cells.
250
+ */
251
+ _classPrivateMethodInitSpec(this, _onBeforeSelectionHighlightSet);
252
+ /**
253
+ * The hooks allows to modify the delta transformation object necessary for correct selection end transformations.
257
254
  *
258
- * @param {object} delta The transformation delta.
255
+ * @param {{ row: number, col: number }} restDelta The transformation delta for the rest of the selection.
256
+ * @param {{ row: number, col: number }} delta The general transformation delta.
257
+ * @param {CellCoords} coords The coordinates of the next position of the end selection.
258
+ */
259
+ _classPrivateMethodInitSpec(this, _onModifyTransformEndRestDelta);
260
+ /**
261
+ * The hook allows to modify the delta transformation object necessary for correct selection end transformations.
262
+ * The logic here handles "jumping over" merged merged cells, while selecting.
263
+ *
264
+ * @param {{ row: number, col: number }} delta The transformation delta.
259
265
  */
260
266
  _classPrivateMethodInitSpec(this, _onModifyTransformEnd);
261
267
  /**
@@ -264,6 +270,13 @@ class MergeCells extends _base.BasePlugin {
264
270
  * @param {object} delta The transformation delta.
265
271
  */
266
272
  _classPrivateMethodInitSpec(this, _onModifyTransformStart);
273
+ /**
274
+ * The hook controls the position of the focus position. For merge cells there is need to shift the focus to the
275
+ * next merged cell not to the next hidden cell (overlapped by merged cell).
276
+ *
277
+ * @param {object} delta The transformation delta.
278
+ */
279
+ _classPrivateMethodInitSpec(this, _onModifyTransformFocus);
267
280
  /**
268
281
  * Modifies the information on whether the current selection contains multiple cells. The `afterIsMultipleSelection`
269
282
  * hook callback.
@@ -298,12 +311,25 @@ class MergeCells extends _base.BasePlugin {
298
311
  */
299
312
  _defineProperty(this, "selectionCalculations", null);
300
313
  /**
314
+ * The holder for the last selected coordinates. This allows keeping the correct coordinates in cases after the
315
+ * focus is moved out of the merged cell.
316
+ *
301
317
  * @type {CellCoords}
302
318
  */
303
- _classPrivateFieldInitSpec(this, _lastDesiredCoords, {
319
+ _classPrivateFieldInitSpec(this, _lastSelectedCoords, {
304
320
  writable: true,
305
321
  value: null
306
322
  });
323
+ /**
324
+ * The module responsible for providing the correct focus order (vertical and horizontal) within a selection that
325
+ * contains merged cells.
326
+ *
327
+ * @type {FocusOrder}
328
+ */
329
+ _classPrivateFieldInitSpec(this, _focusOrder, {
330
+ writable: true,
331
+ value: new _focusOrder2.FocusOrder((row, column) => this.mergedCellsCollection.get(row, column))
332
+ });
307
333
  }
308
334
  static get PLUGIN_KEY() {
309
335
  return PLUGIN_KEY;
@@ -338,17 +364,17 @@ class MergeCells extends _base.BasePlugin {
338
364
  }
339
365
  return _classPrivateMethodGet(_this, _onAfterInit, _onAfterInit2).call(_this, ...args);
340
366
  });
341
- this.addHook('modifyTransformStart', function () {
367
+ this.addHook('modifyTransformFocus', function () {
342
368
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
343
369
  args[_key2] = arguments[_key2];
344
370
  }
345
- return _classPrivateMethodGet(_this, _onModifyTransformStart, _onModifyTransformStart2).call(_this, ...args);
371
+ return _classPrivateMethodGet(_this, _onModifyTransformFocus, _onModifyTransformFocus2).call(_this, ...args);
346
372
  });
347
- this.addHook('afterModifyTransformStart', function () {
373
+ this.addHook('modifyTransformStart', function () {
348
374
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
349
375
  args[_key3] = arguments[_key3];
350
376
  }
351
- return _classPrivateMethodGet(_this, _onAfterModifyTransformStart, _onAfterModifyTransformStart2).call(_this, ...args);
377
+ return _classPrivateMethodGet(_this, _onModifyTransformStart, _onModifyTransformStart2).call(_this, ...args);
352
378
  });
353
379
  this.addHook('modifyTransformEnd', function () {
354
380
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
@@ -356,124 +382,142 @@ class MergeCells extends _base.BasePlugin {
356
382
  }
357
383
  return _classPrivateMethodGet(_this, _onModifyTransformEnd, _onModifyTransformEnd2).call(_this, ...args);
358
384
  });
359
- this.addHook('modifyGetCellCoords', function () {
385
+ this.addHook('modifyTransformEndRestDelta', function () {
360
386
  for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
361
387
  args[_key5] = arguments[_key5];
362
388
  }
363
- return _classPrivateMethodGet(_this, _onModifyGetCellCoords, _onModifyGetCellCoords2).call(_this, ...args);
389
+ return _classPrivateMethodGet(_this, _onModifyTransformEndRestDelta, _onModifyTransformEndRestDelta2).call(_this, ...args);
364
390
  });
365
- this.addHook('beforeSetRangeStart', function () {
391
+ this.addHook('beforeSelectionHighlightSet', function () {
366
392
  for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
367
393
  args[_key6] = arguments[_key6];
368
394
  }
369
- return _classPrivateMethodGet(_this, _onBeforeSetRangeStart, _onBeforeSetRangeStart2).call(_this, ...args);
395
+ return _classPrivateMethodGet(_this, _onBeforeSelectionHighlightSet, _onBeforeSelectionHighlightSet2).call(_this, ...args);
370
396
  });
371
- this.addHook('beforeSetRangeStartOnly', function () {
397
+ this.addHook('beforeSetRangeStart', function () {
372
398
  for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
373
399
  args[_key7] = arguments[_key7];
374
400
  }
375
401
  return _classPrivateMethodGet(_this, _onBeforeSetRangeStart, _onBeforeSetRangeStart2).call(_this, ...args);
376
402
  });
377
- this.addHook('beforeSetRangeEnd', function () {
403
+ this.addHook('beforeSetRangeStartOnly', function () {
378
404
  for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
379
405
  args[_key8] = arguments[_key8];
380
406
  }
381
- return _classPrivateMethodGet(_this, _onBeforeSetRangeEnd, _onBeforeSetRangeEnd2).call(_this, ...args);
407
+ return _classPrivateMethodGet(_this, _onBeforeSetRangeStart, _onBeforeSetRangeStart2).call(_this, ...args);
382
408
  });
383
- this.addHook('afterIsMultipleSelection', function () {
409
+ this.addHook('afterSelectionFocusSet', function () {
384
410
  for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
385
411
  args[_key9] = arguments[_key9];
386
412
  }
387
- return _classPrivateMethodGet(_this, _onAfterIsMultipleSelection, _onAfterIsMultipleSelection2).call(_this, ...args);
413
+ return _classPrivateMethodGet(_this, _onAfterSelectionFocusSet, _onAfterSelectionFocusSet2).call(_this, ...args);
388
414
  });
389
- this.addHook('afterRenderer', function () {
415
+ this.addHook('afterSelectionEnd', function () {
390
416
  for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
391
417
  args[_key10] = arguments[_key10];
392
418
  }
393
- return _classPrivateMethodGet(_this, _onAfterRenderer, _onAfterRenderer2).call(_this, ...args);
419
+ return _classPrivateMethodGet(_this, _onAfterSelectionEnd, _onAfterSelectionEnd2).call(_this, ...args);
394
420
  });
395
- this.addHook('afterContextMenuDefaultOptions', function () {
421
+ this.addHook('modifyGetCellCoords', function () {
396
422
  for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
397
423
  args[_key11] = arguments[_key11];
398
424
  }
399
- return _classPrivateMethodGet(_this, _addMergeActionsToContextMenu, _addMergeActionsToContextMenu2).call(_this, ...args);
425
+ return _classPrivateMethodGet(_this, _onModifyGetCellCoords, _onModifyGetCellCoords2).call(_this, ...args);
400
426
  });
401
- this.addHook('afterGetCellMeta', function () {
427
+ this.addHook('afterIsMultipleSelection', function () {
402
428
  for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
403
429
  args[_key12] = arguments[_key12];
404
430
  }
405
- return _classPrivateMethodGet(_this, _onAfterGetCellMeta, _onAfterGetCellMeta2).call(_this, ...args);
431
+ return _classPrivateMethodGet(_this, _onAfterIsMultipleSelection, _onAfterIsMultipleSelection2).call(_this, ...args);
406
432
  });
407
- this.addHook('afterViewportRowCalculatorOverride', function () {
433
+ this.addHook('afterRenderer', function () {
408
434
  for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
409
435
  args[_key13] = arguments[_key13];
410
436
  }
411
- return _classPrivateMethodGet(_this, _onAfterViewportRowCalculatorOverride, _onAfterViewportRowCalculatorOverride2).call(_this, ...args);
437
+ return _classPrivateMethodGet(_this, _onAfterRenderer, _onAfterRenderer2).call(_this, ...args);
412
438
  });
413
- this.addHook('afterViewportColumnCalculatorOverride', function () {
439
+ this.addHook('afterContextMenuDefaultOptions', function () {
414
440
  for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
415
441
  args[_key14] = arguments[_key14];
416
442
  }
417
- return _classPrivateMethodGet(_this, _onAfterViewportColumnCalculatorOverride, _onAfterViewportColumnCalculatorOverride2).call(_this, ...args);
443
+ return _classPrivateMethodGet(_this, _addMergeActionsToContextMenu, _addMergeActionsToContextMenu2).call(_this, ...args);
418
444
  });
419
- this.addHook('modifyAutofillRange', function () {
445
+ this.addHook('afterGetCellMeta', function () {
420
446
  for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
421
447
  args[_key15] = arguments[_key15];
422
448
  }
423
- return _classPrivateMethodGet(_this, _onModifyAutofillRange, _onModifyAutofillRange2).call(_this, ...args);
449
+ return _classPrivateMethodGet(_this, _onAfterGetCellMeta, _onAfterGetCellMeta2).call(_this, ...args);
424
450
  });
425
- this.addHook('afterCreateCol', function () {
451
+ this.addHook('afterViewportRowCalculatorOverride', function () {
426
452
  for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
427
453
  args[_key16] = arguments[_key16];
428
454
  }
429
- return _classPrivateMethodGet(_this, _onAfterCreateCol, _onAfterCreateCol2).call(_this, ...args);
455
+ return _classPrivateMethodGet(_this, _onAfterViewportRowCalculatorOverride, _onAfterViewportRowCalculatorOverride2).call(_this, ...args);
430
456
  });
431
- this.addHook('afterRemoveCol', function () {
457
+ this.addHook('afterViewportColumnCalculatorOverride', function () {
432
458
  for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
433
459
  args[_key17] = arguments[_key17];
434
460
  }
435
- return _classPrivateMethodGet(_this, _onAfterRemoveCol, _onAfterRemoveCol2).call(_this, ...args);
461
+ return _classPrivateMethodGet(_this, _onAfterViewportColumnCalculatorOverride, _onAfterViewportColumnCalculatorOverride2).call(_this, ...args);
436
462
  });
437
- this.addHook('afterCreateRow', function () {
463
+ this.addHook('modifyAutofillRange', function () {
438
464
  for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
439
465
  args[_key18] = arguments[_key18];
440
466
  }
441
- return _classPrivateMethodGet(_this, _onAfterCreateRow, _onAfterCreateRow2).call(_this, ...args);
467
+ return _classPrivateMethodGet(_this, _onModifyAutofillRange, _onModifyAutofillRange2).call(_this, ...args);
442
468
  });
443
- this.addHook('afterRemoveRow', function () {
469
+ this.addHook('afterCreateCol', function () {
444
470
  for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
445
471
  args[_key19] = arguments[_key19];
446
472
  }
447
- return _classPrivateMethodGet(_this, _onAfterRemoveRow, _onAfterRemoveRow2).call(_this, ...args);
473
+ return _classPrivateMethodGet(_this, _onAfterCreateCol, _onAfterCreateCol2).call(_this, ...args);
448
474
  });
449
- this.addHook('afterChange', function () {
475
+ this.addHook('afterRemoveCol', function () {
450
476
  for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
451
477
  args[_key20] = arguments[_key20];
452
478
  }
453
- return _classPrivateMethodGet(_this, _onAfterChange, _onAfterChange2).call(_this, ...args);
479
+ return _classPrivateMethodGet(_this, _onAfterRemoveCol, _onAfterRemoveCol2).call(_this, ...args);
454
480
  });
455
- this.addHook('beforeDrawBorders', function () {
481
+ this.addHook('afterCreateRow', function () {
456
482
  for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
457
483
  args[_key21] = arguments[_key21];
458
484
  }
459
- return _classPrivateMethodGet(_this, _onBeforeDrawAreaBorders, _onBeforeDrawAreaBorders2).call(_this, ...args);
485
+ return _classPrivateMethodGet(_this, _onAfterCreateRow, _onAfterCreateRow2).call(_this, ...args);
460
486
  });
461
- this.addHook('afterDrawSelection', function () {
487
+ this.addHook('afterRemoveRow', function () {
462
488
  for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
463
489
  args[_key22] = arguments[_key22];
464
490
  }
465
- return _classPrivateMethodGet(_this, _onAfterDrawSelection, _onAfterDrawSelection2).call(_this, ...args);
491
+ return _classPrivateMethodGet(_this, _onAfterRemoveRow, _onAfterRemoveRow2).call(_this, ...args);
466
492
  });
467
- this.addHook('beforeRemoveCellClassNames', function () {
493
+ this.addHook('afterChange', function () {
468
494
  for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
469
495
  args[_key23] = arguments[_key23];
470
496
  }
471
- return _classPrivateMethodGet(_this, _onBeforeRemoveCellClassNames, _onBeforeRemoveCellClassNames2).call(_this, ...args);
497
+ return _classPrivateMethodGet(_this, _onAfterChange, _onAfterChange2).call(_this, ...args);
472
498
  });
473
- this.addHook('beforeBeginEditing', function () {
499
+ this.addHook('beforeDrawBorders', function () {
474
500
  for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
475
501
  args[_key24] = arguments[_key24];
476
502
  }
503
+ return _classPrivateMethodGet(_this, _onBeforeDrawAreaBorders, _onBeforeDrawAreaBorders2).call(_this, ...args);
504
+ });
505
+ this.addHook('afterDrawSelection', function () {
506
+ for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
507
+ args[_key25] = arguments[_key25];
508
+ }
509
+ return _classPrivateMethodGet(_this, _onAfterDrawSelection, _onAfterDrawSelection2).call(_this, ...args);
510
+ });
511
+ this.addHook('beforeRemoveCellClassNames', function () {
512
+ for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
513
+ args[_key26] = arguments[_key26];
514
+ }
515
+ return _classPrivateMethodGet(_this, _onBeforeRemoveCellClassNames, _onBeforeRemoveCellClassNames2).call(_this, ...args);
516
+ });
517
+ this.addHook('beforeBeginEditing', function () {
518
+ for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
519
+ args[_key27] = arguments[_key27];
520
+ }
477
521
  return _classPrivateMethodGet(_this, _onBeforeBeginEditing, _onBeforeBeginEditing2).call(_this, ...args);
478
522
  });
479
523
  this.addHook('beforeUndoStackChange', (action, source) => {
@@ -642,25 +686,6 @@ class MergeCells extends _base.BasePlugin {
642
686
  return auto ? true : this.validateSetting(newMergedCellInfo);
643
687
  }
644
688
 
645
- /**
646
- * Merge or unmerge, based on last selected range.
647
- *
648
- * @private
649
- */
650
- toggleMergeOnSelection() {
651
- const currentRange = this.hot.getSelectedRangeLast();
652
- if (!currentRange) {
653
- return;
654
- }
655
- currentRange.setDirection(this.hot.isRtl() ? 'NE-SW' : 'NW-SE');
656
- const {
657
- from,
658
- to
659
- } = currentRange;
660
- this.toggleMerge(currentRange);
661
- this.hot.selectCell(from.row, from.col, to.row, to.col, false);
662
- }
663
-
664
689
  /**
665
690
  * Merges the selection provided as a cell range.
666
691
  *
@@ -1031,84 +1056,295 @@ function _onAfterIsMultipleSelection2(isMultiple) {
1031
1056
  if (isMultiple) {
1032
1057
  const mergedCells = this.mergedCellsCollection.mergedCells;
1033
1058
  const selectionRange = this.hot.getSelectedRangeLast();
1059
+ const topStartCoords = selectionRange.getTopStartCorner();
1060
+ const bottomEndCoords = selectionRange.getBottomEndCorner();
1034
1061
  for (let group = 0; group < mergedCells.length; group += 1) {
1035
- if (selectionRange.from.row === mergedCells[group].row && selectionRange.from.col === mergedCells[group].col && selectionRange.to.row === mergedCells[group].row + mergedCells[group].rowspan - 1 && selectionRange.to.col === mergedCells[group].col + mergedCells[group].colspan - 1) {
1062
+ if (topStartCoords.row === mergedCells[group].row && topStartCoords.col === mergedCells[group].col && bottomEndCoords.row === mergedCells[group].row + mergedCells[group].rowspan - 1 && bottomEndCoords.col === mergedCells[group].col + mergedCells[group].colspan - 1) {
1036
1063
  return false;
1037
1064
  }
1038
1065
  }
1039
1066
  }
1040
1067
  return isMultiple;
1041
1068
  }
1042
- function _onModifyTransformStart2(delta) {
1043
- const currentlySelectedRange = this.hot.getSelectedRangeLast();
1044
- let newDelta = {
1045
- row: delta.row,
1046
- col: delta.col
1069
+ function _onModifyTransformFocus2(delta) {
1070
+ const selectedRange = this.hot.getSelectedRangeLast();
1071
+ const {
1072
+ highlight
1073
+ } = selectedRange;
1074
+ const {
1075
+ columnIndexMapper,
1076
+ rowIndexMapper
1077
+ } = this.hot;
1078
+ const deltaCorrection = {
1079
+ row: 0,
1080
+ col: 0
1047
1081
  };
1048
- let nextPosition = null;
1049
- const currentPosition = this.hot._createCellCoords(currentlySelectedRange.highlight.row, currentlySelectedRange.highlight.col);
1050
- const mergedParent = this.mergedCellsCollection.get(currentPosition.row, currentPosition.col);
1051
- if (!_classPrivateFieldGet(this, _lastDesiredCoords)) {
1052
- _classPrivateFieldSet(this, _lastDesiredCoords, this.hot._createCellCoords(null, null));
1082
+ if (delta.col < 0) {
1083
+ const {
1084
+ rowStart,
1085
+ colEnd
1086
+ } = _classPrivateFieldGet(this, _focusOrder).getPrevHorizontalNode();
1087
+ const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(colEnd, -1);
1088
+ const notHiddenRowStart = rowIndexMapper.getNearestNotHiddenIndex(rowStart, -1);
1089
+ if (notHiddenRowStart > highlight.row) {
1090
+ delta.col = this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnIndex) - 1;
1091
+ deltaCorrection.row = this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowStart) - 1;
1092
+ } else if (notHiddenRowStart < highlight.row) {
1093
+ delta.col = this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnIndex) - 1;
1094
+ deltaCorrection.row = -(this.hot.view.countRenderableRowsInRange(notHiddenRowStart, highlight.row) - 1);
1095
+ } else if (notHiddenColumnIndex === null) {
1096
+ delta.col = -this.hot.view.countRenderableColumnsInRange(0, highlight.col);
1097
+ } else if (notHiddenColumnIndex <= highlight.col) {
1098
+ delta.col = -Math.max(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, highlight.col) - 1, 1);
1099
+ } else {
1100
+ delta.col = this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnIndex) - 1;
1101
+ }
1102
+ } else if (delta.col > 0) {
1103
+ const {
1104
+ rowStart,
1105
+ colStart
1106
+ } = _classPrivateFieldGet(this, _focusOrder).getNextHorizontalNode();
1107
+ const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(colStart, 1);
1108
+ const notHiddenRowStart = rowIndexMapper.getNearestNotHiddenIndex(rowStart, 1);
1109
+ if (notHiddenRowStart > highlight.row) {
1110
+ delta.col = -(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, highlight.col) - 1);
1111
+ deltaCorrection.row = this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowStart) - 1;
1112
+ } else if (notHiddenRowStart < highlight.row) {
1113
+ delta.col = -(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, highlight.col) - 1);
1114
+ deltaCorrection.row = -(this.hot.view.countRenderableRowsInRange(notHiddenRowStart, highlight.row) - 1);
1115
+ } else if (notHiddenColumnIndex === null) {
1116
+ delta.col = this.hot.view.countRenderableColumnsInRange(highlight.col, this.hot.countCols());
1117
+ } else if (highlight.col <= notHiddenColumnIndex) {
1118
+ delta.col = Math.max(this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnIndex) - 1, 1);
1119
+ } else {
1120
+ delta.col = -(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, highlight.col) - 1);
1121
+ }
1053
1122
  }
1054
- if (mergedParent) {
1055
- // only merge selected
1056
- const mergeTopLeft = this.hot._createCellCoords(mergedParent.row, mergedParent.col);
1057
- const mergeBottomRight = this.hot._createCellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1);
1058
- const mergeRange = this.hot._createCellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight);
1059
- if (!mergeRange.includes(_classPrivateFieldGet(this, _lastDesiredCoords))) {
1060
- _classPrivateFieldSet(this, _lastDesiredCoords, this.hot._createCellCoords(null, null)); // reset outdated version of lastDesiredCoords
1123
+ if (delta.row < 0) {
1124
+ const {
1125
+ colStart,
1126
+ rowEnd
1127
+ } = _classPrivateFieldGet(this, _focusOrder).getPrevVerticalNode();
1128
+ const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(rowEnd, -1);
1129
+ const notHiddenColumnStart = columnIndexMapper.getNearestNotHiddenIndex(colStart, -1);
1130
+ if (notHiddenColumnStart > highlight.col) {
1131
+ delta.row = this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowIndex) - 1;
1132
+ deltaCorrection.col = this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnStart) - 1;
1133
+ } else if (notHiddenColumnStart < highlight.col) {
1134
+ delta.row = this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowIndex) - 1;
1135
+ deltaCorrection.col = -(this.hot.view.countRenderableColumnsInRange(notHiddenColumnStart, highlight.col) - 1);
1136
+ } else if (notHiddenRowIndex === null) {
1137
+ delta.row = -this.hot.view.countRenderableRowsInRange(0, highlight.row);
1138
+ } else if (notHiddenRowIndex <= highlight.row) {
1139
+ delta.row = -Math.max(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, highlight.row) - 1, 1);
1140
+ } else {
1141
+ delta.row = this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowIndex) - 1;
1061
1142
  }
1062
- newDelta.row = _classPrivateFieldGet(this, _lastDesiredCoords).row ? _classPrivateFieldGet(this, _lastDesiredCoords).row - currentPosition.row : newDelta.row;
1063
- newDelta.col = _classPrivateFieldGet(this, _lastDesiredCoords).col ? _classPrivateFieldGet(this, _lastDesiredCoords).col - currentPosition.col : newDelta.col;
1064
- if (delta.row > 0) {
1065
- // moving down
1066
- newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row;
1067
- } else if (delta.row < 0) {
1068
- // moving up
1069
- newDelta.row = currentPosition.row - mergedParent.row + delta.row;
1143
+ } else if (delta.row > 0) {
1144
+ const {
1145
+ colStart,
1146
+ rowStart
1147
+ } = _classPrivateFieldGet(this, _focusOrder).getNextVerticalNode();
1148
+ const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(rowStart, 1);
1149
+ const notHiddenColumnStart = columnIndexMapper.getNearestNotHiddenIndex(colStart, 1);
1150
+ if (notHiddenColumnStart > highlight.col) {
1151
+ delta.row = -(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, highlight.row) - 1);
1152
+ deltaCorrection.col = this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnStart) - 1;
1153
+ } else if (notHiddenColumnStart < highlight.col) {
1154
+ delta.row = -(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, highlight.row) - 1);
1155
+ deltaCorrection.col = -(this.hot.view.countRenderableColumnsInRange(notHiddenColumnStart, highlight.col) - 1);
1156
+ } else if (notHiddenRowIndex === null) {
1157
+ delta.row = this.hot.view.countRenderableRowsInRange(highlight.row, this.hot.countRows());
1158
+ } else if (highlight.row <= notHiddenRowIndex) {
1159
+ delta.row = Math.max(this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowIndex) - 1, 1);
1160
+ } else {
1161
+ delta.row = -(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, highlight.row) - 1);
1162
+ }
1163
+ }
1164
+ if (deltaCorrection.row !== 0) {
1165
+ delta.row = deltaCorrection.row;
1166
+ }
1167
+ if (deltaCorrection.col !== 0) {
1168
+ delta.col = deltaCorrection.col;
1169
+ }
1170
+ }
1171
+ function _onModifyTransformStart2(delta) {
1172
+ const selectedRange = this.hot.getSelectedRangeLast();
1173
+ const {
1174
+ highlight
1175
+ } = selectedRange;
1176
+ const {
1177
+ columnIndexMapper,
1178
+ rowIndexMapper
1179
+ } = this.hot;
1180
+ if (_classPrivateFieldGet(this, _lastSelectedCoords)) {
1181
+ if (rowIndexMapper.getRenderableFromVisualIndex(_classPrivateFieldGet(this, _lastSelectedCoords).row) !== null) {
1182
+ highlight.row = _classPrivateFieldGet(this, _lastSelectedCoords).row;
1070
1183
  }
1071
- if (delta.col > 0) {
1072
- // moving right
1073
- newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col;
1074
- } else if (delta.col < 0) {
1075
- // moving left
1076
- newDelta.col = currentPosition.col - mergedParent.col + delta.col;
1184
+ if (columnIndexMapper.getRenderableFromVisualIndex(_classPrivateFieldGet(this, _lastSelectedCoords).col) !== null) {
1185
+ highlight.col = _classPrivateFieldGet(this, _lastSelectedCoords).col;
1077
1186
  }
1187
+ _classPrivateFieldSet(this, _lastSelectedCoords, null);
1078
1188
  }
1079
- nextPosition = this.hot._createCellCoords(currentlySelectedRange.highlight.row + newDelta.row, currentlySelectedRange.highlight.col + newDelta.col);
1080
- const nextPositionMergedCell = this.mergedCellsCollection.get(nextPosition.row, nextPosition.col);
1081
- if (nextPositionMergedCell) {
1082
- // skipping the invisible cells in the merge range
1083
- const firstRenderableCoords = this.mergedCellsCollection.getFirstRenderableCoords(nextPositionMergedCell.row, nextPositionMergedCell.col);
1084
- _classPrivateFieldSet(this, _lastDesiredCoords, nextPosition);
1085
- newDelta = {
1086
- row: firstRenderableCoords.row - currentPosition.row,
1087
- col: firstRenderableCoords.col - currentPosition.col
1088
- };
1189
+ const mergedParent = this.mergedCellsCollection.get(highlight.row, highlight.col);
1190
+ if (!mergedParent) {
1191
+ return;
1089
1192
  }
1090
- if (newDelta.row !== 0) {
1091
- delta.row = newDelta.row;
1193
+ const visualColumnIndexStart = mergedParent.col;
1194
+ const visualColumnIndexEnd = mergedParent.col + mergedParent.colspan - 1;
1195
+ if (delta.col < 0) {
1196
+ const nextColumn = highlight.col >= visualColumnIndexStart && highlight.col <= visualColumnIndexEnd ? visualColumnIndexStart - 1 : visualColumnIndexEnd;
1197
+ const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(nextColumn, -1);
1198
+ if (notHiddenColumnIndex === null) {
1199
+ // There are no visible columns anymore, so move the selection out of the table edge. This will
1200
+ // be processed by the selection Transformer class as a move selection to the previous row (if autoWrapRow is enabled).
1201
+ delta.col = -this.hot.view.countRenderableColumnsInRange(0, highlight.col);
1202
+ } else {
1203
+ delta.col = -Math.max(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, highlight.col) - 1, 1);
1204
+ }
1205
+ } else if (delta.col > 0) {
1206
+ const nextColumn = highlight.col >= visualColumnIndexStart && highlight.col <= visualColumnIndexEnd ? visualColumnIndexEnd + 1 : visualColumnIndexStart;
1207
+ const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(nextColumn, 1);
1208
+ if (notHiddenColumnIndex === null) {
1209
+ // There are no visible columns anymore, so move the selection out of the table edge. This will
1210
+ // be processed by the selection Transformer class as a move selection to the next row (if autoWrapRow is enabled).
1211
+ delta.col = this.hot.view.countRenderableColumnsInRange(highlight.col, this.hot.countCols());
1212
+ } else {
1213
+ delta.col = Math.max(this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnIndex) - 1, 1);
1214
+ }
1092
1215
  }
1093
- if (newDelta.col !== 0) {
1094
- delta.col = newDelta.col;
1216
+ const visualRowIndexStart = mergedParent.row;
1217
+ const visualRowIndexEnd = mergedParent.row + mergedParent.rowspan - 1;
1218
+ if (delta.row < 0) {
1219
+ const nextRow = highlight.row >= visualRowIndexStart && highlight.row <= visualRowIndexEnd ? visualRowIndexStart - 1 : visualRowIndexEnd;
1220
+ const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(nextRow, -1);
1221
+ if (notHiddenRowIndex === null) {
1222
+ // There are no visible rows anymore, so move the selection out of the table edge. This will
1223
+ // be processed by the selection Transformer class as a move selection to the previous column (if autoWrapCol is enabled).
1224
+ delta.row = -this.hot.view.countRenderableRowsInRange(0, highlight.row);
1225
+ } else {
1226
+ delta.row = -Math.max(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, highlight.row) - 1, 1);
1227
+ }
1228
+ } else if (delta.row > 0) {
1229
+ const nextRow = highlight.row >= visualRowIndexStart && highlight.row <= visualRowIndexEnd ? visualRowIndexEnd + 1 : visualRowIndexStart;
1230
+ const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(nextRow, 1);
1231
+ if (notHiddenRowIndex === null) {
1232
+ // There are no visible rows anymore, so move the selection out of the table edge. This will
1233
+ // be processed by the selection Transformer class as a move selection to the next column (if autoWrapCol is enabled).
1234
+ delta.row = this.hot.view.countRenderableRowsInRange(highlight.row, this.hot.countRows());
1235
+ } else {
1236
+ delta.row = Math.max(this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowIndex) - 1, 1);
1237
+ }
1095
1238
  }
1096
1239
  }
1097
1240
  function _onModifyTransformEnd2(delta) {
1098
- const currentSelectionRange = this.hot.getSelectedRangeLast();
1099
- const newDelta = (0, _object.clone)(delta);
1100
- const newSelectionRange = this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, delta);
1101
- let tempDelta = (0, _object.clone)(newDelta);
1102
- const mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(newSelectionRange, true);
1103
- do {
1104
- tempDelta = (0, _object.clone)(newDelta);
1105
- this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, newDelta);
1106
- (0, _array.arrayEach)(mergedCellsWithinRange, mergedCell => {
1107
- this.selectionCalculations.snapDelta(newDelta, currentSelectionRange, mergedCell);
1108
- });
1109
- } while (newDelta.row !== tempDelta.row || newDelta.col !== tempDelta.col);
1110
- delta.row = newDelta.row;
1111
- delta.col = newDelta.col;
1241
+ const selectedRange = this.hot.getSelectedRangeLast();
1242
+ const cloneRange = selectedRange.clone();
1243
+ const {
1244
+ to
1245
+ } = selectedRange;
1246
+ const {
1247
+ columnIndexMapper,
1248
+ rowIndexMapper
1249
+ } = this.hot;
1250
+ const expandCloneRange = (row, col) => {
1251
+ cloneRange.expand(this.hot._createCellCoords(row, col));
1252
+ for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
1253
+ cloneRange.expandByRange(this.mergedCellsCollection.mergedCells[i].getRange());
1254
+ }
1255
+ };
1256
+ if (delta.col < 0) {
1257
+ let nextColumn = this.mergedCellsCollection.getStartMostColumnIndex(selectedRange, to.col) + delta.col;
1258
+ expandCloneRange(to.row, nextColumn);
1259
+ if (selectedRange.getHorizontalDirection() === 'E-W' && cloneRange.getHorizontalDirection() === 'E-W') {
1260
+ nextColumn = cloneRange.getTopStartCorner().col;
1261
+ }
1262
+ const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(nextColumn, 1);
1263
+ if (notHiddenColumnIndex !== null) {
1264
+ delta.col = -Math.max(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, to.col) - 1, 1);
1265
+ }
1266
+ } else if (delta.col > 0) {
1267
+ let nextColumn = this.mergedCellsCollection.getEndMostColumnIndex(selectedRange, to.col) + delta.col;
1268
+ expandCloneRange(to.row, nextColumn);
1269
+ if (selectedRange.getHorizontalDirection() === 'W-E' && cloneRange.getHorizontalDirection() === 'W-E') {
1270
+ nextColumn = cloneRange.getBottomEndCorner().col;
1271
+ }
1272
+ const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(nextColumn, -1);
1273
+ if (notHiddenColumnIndex !== null) {
1274
+ delta.col = Math.max(this.hot.view.countRenderableColumnsInRange(to.col, notHiddenColumnIndex) - 1, 1);
1275
+ }
1276
+ }
1277
+ if (delta.row < 0) {
1278
+ let nextRow = this.mergedCellsCollection.getTopMostRowIndex(selectedRange, to.row) + delta.row;
1279
+ expandCloneRange(nextRow, to.col);
1280
+ if (selectedRange.getVerticalDirection() === 'S-N' && cloneRange.getVerticalDirection() === 'S-N') {
1281
+ nextRow = cloneRange.getTopStartCorner().row;
1282
+ }
1283
+ const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(nextRow, 1);
1284
+ if (notHiddenRowIndex !== null) {
1285
+ delta.row = -Math.max(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, to.row) - 1, 1);
1286
+ }
1287
+ } else if (delta.row > 0) {
1288
+ let nextRow = this.mergedCellsCollection.getBottomMostRowIndex(selectedRange, to.row) + delta.row;
1289
+ expandCloneRange(nextRow, to.col);
1290
+ if (selectedRange.getVerticalDirection() === 'N-S' && cloneRange.getVerticalDirection() === 'N-S') {
1291
+ nextRow = cloneRange.getBottomStartCorner().row;
1292
+ }
1293
+ const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(nextRow, -1);
1294
+ if (notHiddenRowIndex !== null) {
1295
+ delta.row = Math.max(this.hot.view.countRenderableRowsInRange(to.row, notHiddenRowIndex) - 1, 1);
1296
+ }
1297
+ }
1298
+ }
1299
+ function _onModifyTransformEndRestDelta2(restDelta, delta, coords) {
1300
+ const selectedRange = this.hot.getSelectedRangeLast();
1301
+ const {
1302
+ highlight
1303
+ } = selectedRange;
1304
+ const mergeParent = this.mergedCellsCollection.get(highlight.row, highlight.col);
1305
+ if (!mergeParent) {
1306
+ return;
1307
+ }
1308
+ const topStartCorner = selectedRange.getTopStartCorner();
1309
+ const topEndCorner = selectedRange.getTopEndCorner();
1310
+ const bottomEndCorner = selectedRange.getBottomEndCorner();
1311
+ if (delta.col > 0) {
1312
+ const renderableColumns = this.hot.view.countRenderableColumnsInRange(topEndCorner.col, coords.col) - 1;
1313
+ restDelta.col = Math.max(renderableColumns, 1);
1314
+ } else if (delta.col < 0) {
1315
+ const renderableColumns = this.hot.view.countRenderableColumnsInRange(coords.col, topStartCorner.col) - 1;
1316
+ restDelta.col = -Math.max(renderableColumns, 1);
1317
+ }
1318
+ if (delta.row > 0) {
1319
+ const renderableRows = this.hot.view.countRenderableRowsInRange(bottomEndCorner.row, coords.row) - 1;
1320
+ restDelta.row = Math.max(renderableRows, 1);
1321
+ } else if (delta.row < 0) {
1322
+ const renderableRows = this.hot.view.countRenderableRowsInRange(coords.row, topStartCorner.row) - 1;
1323
+ restDelta.row = -Math.max(renderableRows, 1);
1324
+ }
1325
+ }
1326
+ function _onBeforeSelectionHighlightSet2() {
1327
+ if (this.hot.selection.isSelectedByColumnHeader() || this.hot.selection.isSelectedByRowHeader()) {
1328
+ return;
1329
+ }
1330
+ const selectedRange = this.hot.getSelectedRangeLast();
1331
+ const {
1332
+ highlight
1333
+ } = selectedRange;
1334
+ for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
1335
+ selectedRange.expandByRange(this.mergedCellsCollection.mergedCells[i].getRange(), false);
1336
+ }
1337
+ // TODO: This is a workaround for an issue with the selection not being extended properly.
1338
+ // In some cases when the merge cells are defined in random order the selection is not
1339
+ // extended in that way that it covers all overlapped merge cells.
1340
+ for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
1341
+ selectedRange.expandByRange(this.mergedCellsCollection.mergedCells[i].getRange(), false);
1342
+ }
1343
+ const mergedParent = this.mergedCellsCollection.get(highlight.row, highlight.col);
1344
+ _classPrivateFieldSet(this, _lastSelectedCoords, highlight.clone());
1345
+ if (mergedParent) {
1346
+ highlight.assign(mergedParent);
1347
+ }
1112
1348
  }
1113
1349
  function _onModifyGetCellCoords2(row, column) {
1114
1350
  if (row < 0 || column < 0) {
@@ -1167,37 +1403,17 @@ function _onAfterRenderer2(TD, row, col) {
1167
1403
  }
1168
1404
  (0, _utils.applySpanProperties)(TD, mergedCellCopy, row, col);
1169
1405
  }
1170
- function _onBeforeSetRangeStart2(coords) {
1171
- // TODO: It is a workaround, but probably this hook may be needed. Every selection on the merge area
1172
- // could set start point of the selection to the start of the merge area. However, logic inside `expandByRange` need
1173
- // an initial start point. Click on the merge cell when there are some hidden indexes break the logic in some cases.
1174
- // Please take a look at #7010 for more information. I'm not sure if selection directions are calculated properly
1175
- // and what was idea for flipping direction inside `expandByRange` method.
1176
- if (this.mergedCellsCollection.isFirstRenderableMergedCell(coords.row, coords.col)) {
1177
- const mergeParent = this.mergedCellsCollection.get(coords.row, coords.col);
1178
- [coords.row, coords.col] = [mergeParent.row, mergeParent.col];
1179
- }
1406
+ function _onBeforeSetRangeStart2() {
1407
+ _classPrivateFieldSet(this, _lastSelectedCoords, null);
1180
1408
  }
1181
- function _onBeforeSetRangeEnd2(coords) {
1182
- const selRange = this.hot.getSelectedRangeLast();
1183
- selRange.highlight = this.hot._createCellCoords(selRange.highlight.row, selRange.highlight.col); // clone in case we will modify its reference
1184
- selRange.to = coords;
1185
- let rangeExpanded = false;
1186
- if (this.hot.selection.isSelectedByColumnHeader() || this.hot.selection.isSelectedByRowHeader()) {
1187
- return;
1409
+ function _onAfterSelectionFocusSet2(row, column) {
1410
+ _classPrivateFieldGet(this, _focusOrder).setActiveNode(row, column);
1411
+ }
1412
+ function _onAfterSelectionEnd2() {
1413
+ const selection = this.hot.getSelectedRangeLast();
1414
+ if (!selection.isHeader()) {
1415
+ _classPrivateFieldGet(this, _focusOrder).buildFocusOrder(this.hot.getSelectedRangeLast());
1188
1416
  }
1189
- do {
1190
- rangeExpanded = false;
1191
- for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
1192
- const cellInfo = this.mergedCellsCollection.mergedCells[i];
1193
- const mergedCellRange = cellInfo.getRange();
1194
- if (selRange.expandByRange(mergedCellRange)) {
1195
- coords.row = selRange.to.row;
1196
- coords.col = selRange.to.col;
1197
- rangeExpanded = true;
1198
- }
1199
- }
1200
- } while (rangeExpanded);
1201
1417
  }
1202
1418
  function _onAfterGetCellMeta2(row, col, cellProperties) {
1203
1419
  const mergeParent = this.mergedCellsCollection.get(row, col);
@@ -1277,27 +1493,6 @@ function _onBeforeDrawAreaBorders2(corners, className) {
1277
1493
  });
1278
1494
  }
1279
1495
  }
1280
- function _onAfterModifyTransformStart2(coords, rowTransformDir, colTransformDir) {
1281
- if (!this.enabled) {
1282
- return;
1283
- }
1284
- const mergedCellAtCoords = this.mergedCellsCollection.get(coords.row, coords.col);
1285
- if (!mergedCellAtCoords) {
1286
- return;
1287
- }
1288
- const goingDown = rowTransformDir > 0;
1289
- const goingUp = rowTransformDir < 0;
1290
- const goingLeft = colTransformDir < 0;
1291
- const goingRight = colTransformDir > 0;
1292
- const mergedCellOnBottomEdge = mergedCellAtCoords.row + mergedCellAtCoords.rowspan - 1 === this.hot.countRows() - 1;
1293
- const mergedCellOnTopEdge = mergedCellAtCoords.row === 0;
1294
- const mergedCellOnRightEdge = mergedCellAtCoords.col + mergedCellAtCoords.colspan - 1 === this.hot.countCols() - 1;
1295
- const mergedCellOnLeftEdge = mergedCellAtCoords.col === 0;
1296
- if (goingDown && mergedCellOnBottomEdge || goingUp && mergedCellOnTopEdge || goingRight && mergedCellOnRightEdge || goingLeft && mergedCellOnLeftEdge) {
1297
- coords.row = mergedCellAtCoords.row;
1298
- coords.col = mergedCellAtCoords.col;
1299
- }
1300
- }
1301
1496
  function _onAfterDrawSelection2(currentRow, currentColumn, cornersOfSelection, layerLevel) {
1302
1497
  // Nothing's selected (hook might be triggered by the custom borders)
1303
1498
  if (!cornersOfSelection) {