handsontable 0.0.0-next-612100d-20240219 → 0.0.0-next-d96e9b5-20240220

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 (89) hide show
  1. package/3rdparty/walkontable/src/cell/range.d.ts +1 -0
  2. package/3rdparty/walkontable/src/cell/range.js +12 -0
  3. package/3rdparty/walkontable/src/cell/range.mjs +12 -0
  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.js +14 -0
  11. package/core.mjs +14 -0
  12. package/dist/handsontable.css +2 -2
  13. package/dist/handsontable.full.css +2 -2
  14. package/dist/handsontable.full.js +1606 -1328
  15. package/dist/handsontable.full.min.css +2 -2
  16. package/dist/handsontable.full.min.js +151 -151
  17. package/dist/handsontable.js +1606 -1328
  18. package/dist/handsontable.min.css +2 -2
  19. package/dist/handsontable.min.js +19 -19
  20. package/editorManager.js +12 -8
  21. package/editorManager.mjs +12 -8
  22. package/helpers/mixed.js +1 -1
  23. package/helpers/mixed.mjs +1 -1
  24. package/package.json +1 -1
  25. package/pluginHooks.d.ts +1 -0
  26. package/pluginHooks.js +43 -1
  27. package/pluginHooks.mjs +43 -1
  28. package/plugins/collapsibleColumns/collapsibleColumns.js +7 -1
  29. package/plugins/collapsibleColumns/collapsibleColumns.mjs +7 -1
  30. package/plugins/columnSorting/columnSorting.js +6 -0
  31. package/plugins/columnSorting/columnSorting.mjs +6 -0
  32. package/plugins/contextMenu/menu/defaultShortcutsList.js +26 -10
  33. package/plugins/contextMenu/menu/defaultShortcutsList.mjs +26 -10
  34. package/plugins/mergeCells/calculations/selection.js +1 -70
  35. package/plugins/mergeCells/calculations/selection.mjs +1 -70
  36. package/plugins/mergeCells/contextMenuItem/toggleMerge.js +11 -1
  37. package/plugins/mergeCells/contextMenuItem/toggleMerge.mjs +11 -1
  38. package/plugins/mergeCells/mergeCells.js +182 -207
  39. package/plugins/mergeCells/mergeCells.mjs +182 -207
  40. package/plugins/multiColumnSorting/multiColumnSorting.js +6 -0
  41. package/plugins/multiColumnSorting/multiColumnSorting.mjs +6 -0
  42. package/plugins/nestedHeaders/nestedHeaders.js +1 -0
  43. package/plugins/nestedHeaders/nestedHeaders.mjs +1 -0
  44. package/plugins/nestedRows/nestedRows.js +7 -1
  45. package/plugins/nestedRows/nestedRows.mjs +7 -1
  46. package/renderers/checkboxRenderer/checkboxRenderer.js +4 -4
  47. package/renderers/checkboxRenderer/checkboxRenderer.mjs +4 -4
  48. package/selection/highlight/visualSelection.js +2 -0
  49. package/selection/highlight/visualSelection.mjs +2 -0
  50. package/selection/selection.js +195 -34
  51. package/selection/selection.mjs +194 -33
  52. package/selection/transformation.js +45 -30
  53. package/selection/transformation.mjs +45 -30
  54. package/shortcutContexts/commands/editor/closeAndSave.js +2 -2
  55. package/shortcutContexts/commands/editor/closeAndSave.mjs +2 -2
  56. package/shortcutContexts/commands/editor/open.js +18 -3
  57. package/shortcutContexts/commands/editor/open.mjs +18 -3
  58. package/shortcutContexts/commands/extendCellsSelection/down.js +1 -1
  59. package/shortcutContexts/commands/extendCellsSelection/down.mjs +1 -1
  60. package/shortcutContexts/commands/extendCellsSelection/left.js +1 -1
  61. package/shortcutContexts/commands/extendCellsSelection/left.mjs +1 -1
  62. package/shortcutContexts/commands/extendCellsSelection/right.js +1 -1
  63. package/shortcutContexts/commands/extendCellsSelection/right.mjs +1 -1
  64. package/shortcutContexts/commands/extendCellsSelection/toColumns.js +1 -1
  65. package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +1 -1
  66. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +3 -1
  67. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +3 -1
  68. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +9 -3
  69. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +9 -3
  70. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +10 -3
  71. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +10 -3
  72. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +3 -1
  73. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +3 -1
  74. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +3 -1
  75. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +3 -1
  76. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +3 -1
  77. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +3 -1
  78. package/shortcutContexts/commands/extendCellsSelection/toRows.js +1 -1
  79. package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +1 -1
  80. package/shortcutContexts/commands/extendCellsSelection/up.js +1 -1
  81. package/shortcutContexts/commands/extendCellsSelection/up.mjs +1 -1
  82. package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +6 -1
  83. package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +6 -1
  84. package/shortcutContexts/commands/moveCellSelection/inlineStart.js +6 -1
  85. package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +6 -1
  86. package/shortcutContexts/grid.js +2 -2
  87. package/shortcutContexts/grid.mjs +2 -2
  88. package/shortcuts/context.js +2 -1
  89. package/shortcuts/context.mjs +2 -1
@@ -24,6 +24,9 @@ import { A11Y_SELECTED } from "../helpers/a11y.mjs";
24
24
  * @class Selection
25
25
  * @util
26
26
  */
27
+ var _transformation = /*#__PURE__*/new WeakMap();
28
+ var _focusTransformation = /*#__PURE__*/new WeakMap();
29
+ var _isFocusSelectionChanged = /*#__PURE__*/new WeakMap();
27
30
  var _disableHeadersHighlight = /*#__PURE__*/new WeakMap();
28
31
  var _selectionSource = /*#__PURE__*/new WeakMap();
29
32
  var _expectedLayersCount = /*#__PURE__*/new WeakMap();
@@ -63,11 +66,23 @@ class Selection {
63
66
  */
64
67
  _defineProperty(this, "highlight", void 0);
65
68
  /**
66
- * The module for modifying coordinates.
69
+ * The module for modifying coordinates of the start and end selection.
67
70
  *
68
71
  * @type {Transformation}
69
72
  */
70
- _defineProperty(this, "transformation", void 0);
73
+ _classPrivateFieldInitSpec(this, _transformation, {
74
+ writable: true,
75
+ value: void 0
76
+ });
77
+ /**
78
+ * The module for modifying coordinates of the focus selection.
79
+ *
80
+ * @type {Transformation}
81
+ */
82
+ _classPrivateFieldInitSpec(this, _focusTransformation, {
83
+ writable: true,
84
+ value: void 0
85
+ });
71
86
  /**
72
87
  * The collection of the selection layer levels where the whole row was selected using the row header or
73
88
  * the corner header.
@@ -82,6 +97,15 @@ class Selection {
82
97
  * @type {Set<number>}
83
98
  */
84
99
  _defineProperty(this, "selectedByColumnHeader", new Set());
100
+ /**
101
+ * The flag which determines if the focus selection was changed.
102
+ *
103
+ * @type {boolean}
104
+ */
105
+ _classPrivateFieldInitSpec(this, _isFocusSelectionChanged, {
106
+ writable: true,
107
+ value: false
108
+ });
85
109
  /**
86
110
  * When sets disable highlighting the headers even when the logical coordinates points on them.
87
111
  *
@@ -132,71 +156,100 @@ class Selection {
132
156
  createCellCoords: (row, column) => this.tableProps.createCellCoords(row, column),
133
157
  createCellRange: (highlight, from, to) => this.tableProps.createCellRange(highlight, from, to)
134
158
  });
135
- this.transformation = new Transformation(this.selectedRange, {
159
+ _classPrivateFieldSet(this, _transformation, new Transformation(this.selectedRange, {
136
160
  rowIndexMapper: this.tableProps.rowIndexMapper,
137
161
  columnIndexMapper: this.tableProps.columnIndexMapper,
138
162
  countRenderableRows: () => this.tableProps.countRenderableRows(),
139
163
  countRenderableColumns: () => this.tableProps.countRenderableColumns(),
140
- countRowHeaders: () => this.tableProps.countRowHeaders(),
141
- countColHeaders: () => this.tableProps.countColHeaders(),
142
164
  visualToRenderableCoords: coords => this.tableProps.visualToRenderableCoords(coords),
143
165
  renderableToVisualCoords: coords => this.tableProps.renderableToVisualCoords(coords),
144
166
  createCellCoords: (row, column) => this.tableProps.createCellCoords(row, column),
145
- navigableHeaders: () => settings.navigableHeaders,
146
167
  fixedRowsBottom: () => settings.fixedRowsBottom,
147
168
  minSpareRows: () => settings.minSpareRows,
148
169
  minSpareCols: () => settings.minSpareCols,
149
170
  autoWrapRow: () => settings.autoWrapRow,
150
171
  autoWrapCol: () => settings.autoWrapCol
151
- });
152
- this.transformation.addLocalHook('beforeTransformStart', function () {
172
+ }));
173
+ _classPrivateFieldSet(this, _focusTransformation, new Transformation(this.selectedRange, {
174
+ rowIndexMapper: this.tableProps.rowIndexMapper,
175
+ columnIndexMapper: this.tableProps.columnIndexMapper,
176
+ countRenderableRows: () => {
177
+ const range = this.selectedRange.current();
178
+ return this.tableProps.countRenderableRowsInRange(0, range.getOuterBottomEndCorner().row);
179
+ },
180
+ countRenderableColumns: () => {
181
+ const range = this.selectedRange.current();
182
+ return this.tableProps.countRenderableColumnsInRange(0, range.getOuterBottomEndCorner().col);
183
+ },
184
+ visualToRenderableCoords: coords => this.tableProps.visualToRenderableCoords(coords),
185
+ renderableToVisualCoords: coords => this.tableProps.renderableToVisualCoords(coords),
186
+ createCellCoords: (row, column) => this.tableProps.createCellCoords(row, column),
187
+ fixedRowsBottom: () => 0,
188
+ minSpareRows: () => 0,
189
+ minSpareCols: () => 0,
190
+ autoWrapRow: () => true,
191
+ autoWrapCol: () => true
192
+ }));
193
+ _classPrivateFieldGet(this, _transformation).addLocalHook('beforeTransformStart', function () {
153
194
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
154
195
  args[_key] = arguments[_key];
155
196
  }
156
197
  return _this.runLocalHooks('beforeModifyTransformStart', ...args);
157
198
  });
158
- this.transformation.addLocalHook('afterTransformStart', function () {
199
+ _classPrivateFieldGet(this, _transformation).addLocalHook('afterTransformStart', function () {
159
200
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
160
201
  args[_key2] = arguments[_key2];
161
202
  }
162
203
  return _this.runLocalHooks('afterModifyTransformStart', ...args);
163
204
  });
164
- this.transformation.addLocalHook('beforeTransformEnd', function () {
205
+ _classPrivateFieldGet(this, _transformation).addLocalHook('beforeTransformEnd', function () {
165
206
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
166
207
  args[_key3] = arguments[_key3];
167
208
  }
168
209
  return _this.runLocalHooks('beforeModifyTransformEnd', ...args);
169
210
  });
170
- this.transformation.addLocalHook('afterTransformEnd', function () {
211
+ _classPrivateFieldGet(this, _transformation).addLocalHook('afterTransformEnd', function () {
171
212
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
172
213
  args[_key4] = arguments[_key4];
173
214
  }
174
215
  return _this.runLocalHooks('afterModifyTransformEnd', ...args);
175
216
  });
176
- this.transformation.addLocalHook('insertRowRequire', function () {
217
+ _classPrivateFieldGet(this, _transformation).addLocalHook('insertRowRequire', function () {
177
218
  for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
178
219
  args[_key5] = arguments[_key5];
179
220
  }
180
221
  return _this.runLocalHooks('insertRowRequire', ...args);
181
222
  });
182
- this.transformation.addLocalHook('insertColRequire', function () {
223
+ _classPrivateFieldGet(this, _transformation).addLocalHook('insertColRequire', function () {
183
224
  for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
184
225
  args[_key6] = arguments[_key6];
185
226
  }
186
227
  return _this.runLocalHooks('insertColRequire', ...args);
187
228
  });
188
- this.transformation.addLocalHook('beforeRowWrap', function () {
229
+ _classPrivateFieldGet(this, _transformation).addLocalHook('beforeRowWrap', function () {
189
230
  for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
190
231
  args[_key7] = arguments[_key7];
191
232
  }
192
233
  return _this.runLocalHooks('beforeRowWrap', ...args);
193
234
  });
194
- this.transformation.addLocalHook('beforeColumnWrap', function () {
235
+ _classPrivateFieldGet(this, _transformation).addLocalHook('beforeColumnWrap', function () {
195
236
  for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
196
237
  args[_key8] = arguments[_key8];
197
238
  }
198
239
  return _this.runLocalHooks('beforeColumnWrap', ...args);
199
240
  });
241
+ _classPrivateFieldGet(this, _focusTransformation).addLocalHook('beforeTransformStart', function () {
242
+ for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
243
+ args[_key9] = arguments[_key9];
244
+ }
245
+ return _this.runLocalHooks('beforeModifyTransformStart', ...args);
246
+ });
247
+ _classPrivateFieldGet(this, _focusTransformation).addLocalHook('afterTransformStart', function () {
248
+ for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
249
+ args[_key10] = arguments[_key10];
250
+ }
251
+ return _this.runLocalHooks('afterModifyTransformStart', ...args);
252
+ });
200
253
  }
201
254
 
202
255
  /**
@@ -287,6 +340,7 @@ class Selection {
287
340
  // We are creating copy. We would like to modify just the start of the selection by below hook. Then original coords
288
341
  // should be handled by next methods.
289
342
  const coordsClone = coords.clone();
343
+ _classPrivateFieldSet(this, _isFocusSelectionChanged, false);
290
344
  this.runLocalHooks(`beforeSetRangeStart${fragment ? 'Only' : ''}`, coordsClone);
291
345
  if (!isMultipleMode || isMultipleMode && !isMultipleSelection && isUndefined(multipleSelection)) {
292
346
  this.selectedRange.clear();
@@ -344,7 +398,20 @@ class Selection {
344
398
  cellRange.setFrom(cellRange.highlight);
345
399
  cellRange.setTo(cellRange.highlight);
346
400
  } else {
401
+ const horizontalDir = cellRange.getHorizontalDirection();
402
+ const verticalDir = cellRange.getVerticalDirection();
403
+ const isMultiple = this.isMultiple();
347
404
  cellRange.setTo(coordsClone);
405
+ if (isMultiple && horizontalDir !== cellRange.getHorizontalDirection()) {
406
+ cellRange.from.assign({
407
+ col: cellRange.highlight.col
408
+ });
409
+ }
410
+ if (isMultiple && verticalDir !== cellRange.getVerticalDirection()) {
411
+ cellRange.from.assign({
412
+ row: cellRange.highlight.row
413
+ });
414
+ }
348
415
  }
349
416
 
350
417
  // Prevent creating "area" selection that overlaps headers.
@@ -354,11 +421,7 @@ class Selection {
354
421
  }
355
422
  }
356
423
  this.runLocalHooks('beforeHighlightSet');
357
- const focusHighlight = this.highlight.getFocus();
358
- focusHighlight.clear();
359
- if (this.highlight.isEnabledFor(FOCUS_TYPE, cellRange.highlight)) {
360
- focusHighlight.add(this.selectedRange.current().highlight).commit().syncWith(cellRange);
361
- }
424
+ this.setRangeFocus(this.selectedRange.current().highlight);
362
425
  const layerLevel = this.getLayerLevel();
363
426
 
364
427
  // If the next layer level is lower than previous then clear all area and header highlights. This is the
@@ -446,15 +509,28 @@ class Selection {
446
509
  }
447
510
 
448
511
  /**
449
- * Returns information if we have a multiselection. This method check multiselection only on the latest layer of
450
- * the selection.
512
+ * Sets the selection focus position at the specified coordinates.
451
513
  *
452
- * @returns {boolean}
514
+ * @param {CellCoords} coords The CellCoords instance with defined visual coordinates.
453
515
  */
454
- isMultiple() {
455
- const isMultipleListener = createObjectPropListener(!this.selectedRange.current().isSingle());
456
- this.runLocalHooks('afterIsMultipleSelection', isMultipleListener);
457
- return isMultipleListener.value;
516
+ setRangeFocus(coords) {
517
+ if (this.selectedRange.isEmpty()) {
518
+ return;
519
+ }
520
+ const cellRange = this.selectedRange.current();
521
+ const focusHighlight = this.highlight.getFocus();
522
+ focusHighlight.clear();
523
+ cellRange.setHighlight(coords);
524
+ if (!this.inProgress) {
525
+ this.runLocalHooks('beforeHighlightSet');
526
+ }
527
+ if (this.highlight.isEnabledFor(FOCUS_TYPE, cellRange.highlight)) {
528
+ focusHighlight.add(cellRange.highlight).commit().syncWith(cellRange);
529
+ }
530
+ if (!this.inProgress) {
531
+ _classPrivateFieldSet(this, _isFocusSelectionChanged, true);
532
+ this.runLocalHooks('afterSetFocus', cellRange.highlight);
533
+ }
458
534
  }
459
535
 
460
536
  /**
@@ -467,7 +543,13 @@ class Selection {
467
543
  */
468
544
  transformStart(rowDelta, colDelta) {
469
545
  let createMissingRecords = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
470
- this.setRangeStart(this.transformation.transformStart(rowDelta, colDelta, createMissingRecords));
546
+ if (this.settings.navigableHeaders) {
547
+ _classPrivateFieldGet(this, _transformation).setOffsetSize({
548
+ x: this.tableProps.countRowHeaders(),
549
+ y: this.tableProps.countColHeaders()
550
+ });
551
+ }
552
+ this.setRangeStart(_classPrivateFieldGet(this, _transformation).transformStart(rowDelta, colDelta, createMissingRecords));
471
553
  }
472
554
 
473
555
  /**
@@ -477,7 +559,44 @@ class Selection {
477
559
  * @param {number} colDelta Columns number to move, value can be passed as negative number.
478
560
  */
479
561
  transformEnd(rowDelta, colDelta) {
480
- this.setRangeEnd(this.transformation.transformEnd(rowDelta, colDelta));
562
+ if (this.settings.navigableHeaders) {
563
+ _classPrivateFieldGet(this, _transformation).setOffsetSize({
564
+ x: this.tableProps.countRowHeaders(),
565
+ y: this.tableProps.countColHeaders()
566
+ });
567
+ }
568
+ this.setRangeEnd(_classPrivateFieldGet(this, _transformation).transformEnd(rowDelta, colDelta));
569
+ }
570
+
571
+ /**
572
+ * Transforms the focus cell selection relative to the current focus position.
573
+ *
574
+ * @param {number} rowDelta Rows number to move, value can be passed as negative number.
575
+ * @param {number} colDelta Columns number to move, value can be passed as negative number.
576
+ */
577
+ transformFocus(rowDelta, colDelta) {
578
+ const range = this.selectedRange.current();
579
+ const {
580
+ row,
581
+ col
582
+ } = range.getOuterTopStartCorner();
583
+ const columnsInRange = this.tableProps.countRenderableColumnsInRange(0, col - 1);
584
+ const rowsInRange = this.tableProps.countRenderableRowsInRange(0, row - 1);
585
+ if (range.highlight.isHeader()) {
586
+ // for header focus selection calculate the new coords based on the selection including headers
587
+ _classPrivateFieldGet(this, _focusTransformation).setOffsetSize({
588
+ x: col < 0 ? Math.abs(col) : -columnsInRange,
589
+ y: row < 0 ? Math.abs(row) : -rowsInRange
590
+ });
591
+ } else {
592
+ // for focus selection in cells calculate the new coords only based on the selected cells
593
+ _classPrivateFieldGet(this, _focusTransformation).setOffsetSize({
594
+ x: col < 0 ? 0 : -columnsInRange,
595
+ y: row < 0 ? 0 : -rowsInRange
596
+ });
597
+ }
598
+ const focusCoords = _classPrivateFieldGet(this, _focusTransformation).transformStart(rowDelta, colDelta);
599
+ this.setRangeFocus(focusCoords.normalize());
481
600
  }
482
601
 
483
602
  /**
@@ -498,6 +617,30 @@ class Selection {
498
617
  return !this.selectedRange.isEmpty();
499
618
  }
500
619
 
620
+ /**
621
+ * Returns information if we have a multi-selection. This method check multi-selection only on the latest layer of
622
+ * the selection.
623
+ *
624
+ * @returns {boolean}
625
+ */
626
+ isMultiple() {
627
+ if (!this.isSelected()) {
628
+ return false;
629
+ }
630
+ const isMultipleListener = createObjectPropListener(!this.selectedRange.current().isSingle());
631
+ this.runLocalHooks('afterIsMultipleSelection', isMultipleListener);
632
+ return isMultipleListener.value;
633
+ }
634
+
635
+ /**
636
+ * Checks if the last selection involves changing the focus cell position only.
637
+ *
638
+ * @returns {boolean}
639
+ */
640
+ isFocusSelectionChanged() {
641
+ return this.isSelected() && _classPrivateFieldGet(this, _isFocusSelectionChanged);
642
+ }
643
+
501
644
  /**
502
645
  * Returns `true` if the selection was applied by clicking to the row header. If the `layerLevel`
503
646
  * argument is passed then only that layer will be checked. Otherwise, it checks if any row header
@@ -803,11 +946,20 @@ class Selection {
803
946
  countColHeaders
804
947
  });
805
948
  if (isValid) {
806
- const fromRow = countColHeaders === 0 ? 0 : clamp(focusPosition, columnHeaderLastIndex, -1);
949
+ let highlightRow = 0;
950
+ let highlightColumn = 0;
951
+ if (Number.isInteger(focusPosition === null || focusPosition === void 0 ? void 0 : focusPosition.row) && Number.isInteger(focusPosition === null || focusPosition === void 0 ? void 0 : focusPosition.col)) {
952
+ highlightRow = clamp(focusPosition.row, columnHeaderLastIndex, countRows - 1);
953
+ highlightColumn = clamp(focusPosition.col, Math.min(start, end), Math.max(start, end));
954
+ } else {
955
+ highlightRow = clamp(focusPosition, columnHeaderLastIndex, countRows - 1);
956
+ highlightColumn = start;
957
+ }
958
+ const highlight = this.tableProps.createCellCoords(highlightRow, highlightColumn);
959
+ const fromRow = countColHeaders === 0 ? 0 : clamp(highlight.row, columnHeaderLastIndex, -1);
807
960
  const toRow = countRows - 1;
808
961
  const from = this.tableProps.createCellCoords(fromRow, start);
809
962
  const to = this.tableProps.createCellCoords(toRow, end);
810
- const highlight = this.tableProps.createCellCoords(clamp(focusPosition, columnHeaderLastIndex, countRows - 1), start);
811
963
  this.runLocalHooks('beforeSelectColumns', from, to, highlight);
812
964
 
813
965
  // disallow modifying row axis for that hooks
@@ -848,11 +1000,20 @@ class Selection {
848
1000
  countColHeaders: 0
849
1001
  });
850
1002
  if (isValid) {
851
- const fromColumn = countRowHeaders === 0 ? 0 : clamp(focusPosition, rowHeaderLastIndex, -1);
1003
+ let highlightRow = 0;
1004
+ let highlightColumn = 0;
1005
+ if (Number.isInteger(focusPosition === null || focusPosition === void 0 ? void 0 : focusPosition.row) && Number.isInteger(focusPosition === null || focusPosition === void 0 ? void 0 : focusPosition.col)) {
1006
+ highlightRow = clamp(focusPosition.row, Math.min(startRow, endRow), Math.max(startRow, endRow));
1007
+ highlightColumn = clamp(focusPosition.col, rowHeaderLastIndex, countCols - 1);
1008
+ } else {
1009
+ highlightRow = startRow;
1010
+ highlightColumn = clamp(focusPosition, rowHeaderLastIndex, countCols - 1);
1011
+ }
1012
+ const highlight = this.tableProps.createCellCoords(highlightRow, highlightColumn);
1013
+ const fromColumn = countRowHeaders === 0 ? 0 : clamp(highlight.col, rowHeaderLastIndex, -1);
852
1014
  const toColumn = countCols - 1;
853
1015
  const from = this.tableProps.createCellCoords(startRow, fromColumn);
854
1016
  const to = this.tableProps.createCellCoords(endRow, toColumn);
855
- const highlight = this.tableProps.createCellCoords(startRow, clamp(focusPosition, rowHeaderLastIndex, countCols - 1));
856
1017
  this.runLocalHooks('beforeSelectRows', from, to, highlight);
857
1018
 
858
1019
  // disallow modifying column axis for that hooks
@@ -8,9 +8,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
8
8
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
9
9
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
10
10
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
11
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
11
12
  function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
12
13
  function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
13
- function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
14
14
  function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
15
15
  function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
16
16
  function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
@@ -32,7 +32,6 @@ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.
32
32
  var _range = /*#__PURE__*/new WeakMap();
33
33
  var _options = /*#__PURE__*/new WeakMap();
34
34
  var _offset = /*#__PURE__*/new WeakMap();
35
- var _setOffsetSize = /*#__PURE__*/new WeakSet();
36
35
  var _clampCoords = /*#__PURE__*/new WeakSet();
37
36
  var _getTableSize = /*#__PURE__*/new WeakSet();
38
37
  var _visualToZeroBasedCoords = /*#__PURE__*/new WeakSet();
@@ -67,13 +66,6 @@ class Transformation {
67
66
  * @returns {{rowDir: 1|0|-1, colDir: 1|0|-1}}
68
67
  */
69
68
  _classPrivateMethodInitSpec(this, _clampCoords);
70
- /**
71
- * Sets the additional offset in table size that may occur when the `navigableHeaders` option
72
- * is enabled.
73
- *
74
- * @param {{x: number, y: number}} offset Offset as x and y properties.
75
- */
76
- _classPrivateMethodInitSpec(this, _setOffsetSize);
77
69
  /**
78
70
  * Instance of the SelectionRange, holder for visual coordinates applied to the table.
79
71
  *
@@ -121,10 +113,6 @@ class Transformation {
121
113
  */
122
114
  transformStart(rowDelta, colDelta) {
123
115
  let createMissingRecords = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
124
- _classPrivateMethodGet(this, _setOffsetSize, _setOffsetSize2).call(this, {
125
- x: _classPrivateFieldGet(this, _options).navigableHeaders() ? _classPrivateFieldGet(this, _options).countRowHeaders() : 0,
126
- y: _classPrivateFieldGet(this, _options).navigableHeaders() ? _classPrivateFieldGet(this, _options).countColHeaders() : 0
127
- });
128
116
  const delta = _classPrivateFieldGet(this, _options).createCellCoords(rowDelta, colDelta);
129
117
  let visualCoords = _classPrivateFieldGet(this, _range).current().highlight;
130
118
  const highlightRenderableCoords = _classPrivateFieldGet(this, _options).visualToRenderableCoords(visualCoords);
@@ -204,10 +192,6 @@ class Transformation {
204
192
  * @returns {CellCoords} Visual coordinates after transformation.
205
193
  */
206
194
  transformEnd(rowDelta, colDelta) {
207
- _classPrivateMethodGet(this, _setOffsetSize, _setOffsetSize2).call(this, {
208
- x: _classPrivateFieldGet(this, _options).navigableHeaders() ? _classPrivateFieldGet(this, _options).countRowHeaders() : 0,
209
- y: _classPrivateFieldGet(this, _options).navigableHeaders() ? _classPrivateFieldGet(this, _options).countColHeaders() : 0
210
- });
211
195
  const delta = _classPrivateFieldGet(this, _options).createCellCoords(rowDelta, colDelta);
212
196
  const cellRange = _classPrivateFieldGet(this, _range).current();
213
197
  const highlightRenderableCoords = _classPrivateFieldGet(this, _options).visualToRenderableCoords(cellRange.highlight);
@@ -217,10 +201,34 @@ class Transformation {
217
201
  this.runLocalHooks('beforeTransformEnd', delta);
218
202
  if (highlightRenderableCoords.row !== null && highlightRenderableCoords.col !== null) {
219
203
  const {
220
- row,
221
- col
204
+ row: toRow,
205
+ col: toColumn
222
206
  } = _classPrivateMethodGet(this, _visualToZeroBasedCoords, _visualToZeroBasedCoords2).call(this, cellRange.to);
223
- const coords = _classPrivateFieldGet(this, _options).createCellCoords(row + delta.row, col + delta.col);
207
+ const {
208
+ row: highlightRow,
209
+ col: highlightColumn
210
+ } = _classPrivateMethodGet(this, _visualToZeroBasedCoords, _visualToZeroBasedCoords2).call(this, cellRange.highlight);
211
+ const coords = _classPrivateFieldGet(this, _options).createCellCoords(toRow + delta.row, toColumn + delta.col);
212
+ const columnDeltaRest = coords.col - highlightColumn;
213
+ const rowDeltaRest = coords.row - highlightRow;
214
+ if (delta.col < 0) {
215
+ if (toColumn >= highlightColumn && coords.col < highlightColumn) {
216
+ coords.col = _classPrivateMethodGet(this, _visualToZeroBasedCoords, _visualToZeroBasedCoords2).call(this, cellRange.getTopStartCorner()).col + columnDeltaRest;
217
+ }
218
+ } else if (delta.col > 0) {
219
+ if (toColumn <= highlightColumn && coords.col > highlightColumn) {
220
+ coords.col = _classPrivateMethodGet(this, _visualToZeroBasedCoords, _visualToZeroBasedCoords2).call(this, cellRange.getTopEndCorner()).col + columnDeltaRest;
221
+ }
222
+ }
223
+ if (delta.row < 0) {
224
+ if (toRow >= highlightRow && coords.row < highlightRow) {
225
+ coords.row = _classPrivateMethodGet(this, _visualToZeroBasedCoords, _visualToZeroBasedCoords2).call(this, cellRange.getTopStartCorner()).row + rowDeltaRest;
226
+ }
227
+ } else if (delta.row > 0) {
228
+ if (toRow <= highlightRow && coords.row > highlightRow) {
229
+ coords.row = _classPrivateMethodGet(this, _visualToZeroBasedCoords, _visualToZeroBasedCoords2).call(this, cellRange.getBottomStartCorner()).row + rowDeltaRest;
230
+ }
231
+ }
224
232
  const {
225
233
  rowDir,
226
234
  colDir
@@ -240,16 +248,23 @@ class Transformation {
240
248
  this.runLocalHooks('afterTransformEnd', visualCoords, rowTransformDir, colTransformDir);
241
249
  return visualCoords;
242
250
  }
243
- }
244
- function _setOffsetSize2(_ref) {
245
- let {
246
- x,
247
- y
248
- } = _ref;
249
- _classPrivateFieldSet(this, _offset, {
250
- x,
251
- y
252
- });
251
+
252
+ /**
253
+ * Sets the additional offset in table size that may occur when the `navigableHeaders` option
254
+ * is enabled.
255
+ *
256
+ * @param {{x: number, y: number}} offset Offset as x and y properties.
257
+ */
258
+ setOffsetSize(_ref) {
259
+ let {
260
+ x,
261
+ y
262
+ } = _ref;
263
+ _classPrivateFieldSet(this, _offset, {
264
+ x,
265
+ y
266
+ });
267
+ }
253
268
  }
254
269
  function _clampCoords2(zeroBasedCoords) {
255
270
  const {
@@ -2,9 +2,9 @@ import "core-js/modules/es.error.cause.js";
2
2
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
3
3
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
4
4
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
5
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
5
6
  function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
6
7
  function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
7
- function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
8
8
  function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
9
9
  function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
10
10
  function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
@@ -28,7 +28,6 @@ import localHooks from "./../mixins/localHooks.mjs";
28
28
  var _range = /*#__PURE__*/new WeakMap();
29
29
  var _options = /*#__PURE__*/new WeakMap();
30
30
  var _offset = /*#__PURE__*/new WeakMap();
31
- var _setOffsetSize = /*#__PURE__*/new WeakSet();
32
31
  var _clampCoords = /*#__PURE__*/new WeakSet();
33
32
  var _getTableSize = /*#__PURE__*/new WeakSet();
34
33
  var _visualToZeroBasedCoords = /*#__PURE__*/new WeakSet();
@@ -63,13 +62,6 @@ class Transformation {
63
62
  * @returns {{rowDir: 1|0|-1, colDir: 1|0|-1}}
64
63
  */
65
64
  _classPrivateMethodInitSpec(this, _clampCoords);
66
- /**
67
- * Sets the additional offset in table size that may occur when the `navigableHeaders` option
68
- * is enabled.
69
- *
70
- * @param {{x: number, y: number}} offset Offset as x and y properties.
71
- */
72
- _classPrivateMethodInitSpec(this, _setOffsetSize);
73
65
  /**
74
66
  * Instance of the SelectionRange, holder for visual coordinates applied to the table.
75
67
  *
@@ -117,10 +109,6 @@ class Transformation {
117
109
  */
118
110
  transformStart(rowDelta, colDelta) {
119
111
  let createMissingRecords = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
120
- _classPrivateMethodGet(this, _setOffsetSize, _setOffsetSize2).call(this, {
121
- x: _classPrivateFieldGet(this, _options).navigableHeaders() ? _classPrivateFieldGet(this, _options).countRowHeaders() : 0,
122
- y: _classPrivateFieldGet(this, _options).navigableHeaders() ? _classPrivateFieldGet(this, _options).countColHeaders() : 0
123
- });
124
112
  const delta = _classPrivateFieldGet(this, _options).createCellCoords(rowDelta, colDelta);
125
113
  let visualCoords = _classPrivateFieldGet(this, _range).current().highlight;
126
114
  const highlightRenderableCoords = _classPrivateFieldGet(this, _options).visualToRenderableCoords(visualCoords);
@@ -200,10 +188,6 @@ class Transformation {
200
188
  * @returns {CellCoords} Visual coordinates after transformation.
201
189
  */
202
190
  transformEnd(rowDelta, colDelta) {
203
- _classPrivateMethodGet(this, _setOffsetSize, _setOffsetSize2).call(this, {
204
- x: _classPrivateFieldGet(this, _options).navigableHeaders() ? _classPrivateFieldGet(this, _options).countRowHeaders() : 0,
205
- y: _classPrivateFieldGet(this, _options).navigableHeaders() ? _classPrivateFieldGet(this, _options).countColHeaders() : 0
206
- });
207
191
  const delta = _classPrivateFieldGet(this, _options).createCellCoords(rowDelta, colDelta);
208
192
  const cellRange = _classPrivateFieldGet(this, _range).current();
209
193
  const highlightRenderableCoords = _classPrivateFieldGet(this, _options).visualToRenderableCoords(cellRange.highlight);
@@ -213,10 +197,34 @@ class Transformation {
213
197
  this.runLocalHooks('beforeTransformEnd', delta);
214
198
  if (highlightRenderableCoords.row !== null && highlightRenderableCoords.col !== null) {
215
199
  const {
216
- row,
217
- col
200
+ row: toRow,
201
+ col: toColumn
218
202
  } = _classPrivateMethodGet(this, _visualToZeroBasedCoords, _visualToZeroBasedCoords2).call(this, cellRange.to);
219
- const coords = _classPrivateFieldGet(this, _options).createCellCoords(row + delta.row, col + delta.col);
203
+ const {
204
+ row: highlightRow,
205
+ col: highlightColumn
206
+ } = _classPrivateMethodGet(this, _visualToZeroBasedCoords, _visualToZeroBasedCoords2).call(this, cellRange.highlight);
207
+ const coords = _classPrivateFieldGet(this, _options).createCellCoords(toRow + delta.row, toColumn + delta.col);
208
+ const columnDeltaRest = coords.col - highlightColumn;
209
+ const rowDeltaRest = coords.row - highlightRow;
210
+ if (delta.col < 0) {
211
+ if (toColumn >= highlightColumn && coords.col < highlightColumn) {
212
+ coords.col = _classPrivateMethodGet(this, _visualToZeroBasedCoords, _visualToZeroBasedCoords2).call(this, cellRange.getTopStartCorner()).col + columnDeltaRest;
213
+ }
214
+ } else if (delta.col > 0) {
215
+ if (toColumn <= highlightColumn && coords.col > highlightColumn) {
216
+ coords.col = _classPrivateMethodGet(this, _visualToZeroBasedCoords, _visualToZeroBasedCoords2).call(this, cellRange.getTopEndCorner()).col + columnDeltaRest;
217
+ }
218
+ }
219
+ if (delta.row < 0) {
220
+ if (toRow >= highlightRow && coords.row < highlightRow) {
221
+ coords.row = _classPrivateMethodGet(this, _visualToZeroBasedCoords, _visualToZeroBasedCoords2).call(this, cellRange.getTopStartCorner()).row + rowDeltaRest;
222
+ }
223
+ } else if (delta.row > 0) {
224
+ if (toRow <= highlightRow && coords.row > highlightRow) {
225
+ coords.row = _classPrivateMethodGet(this, _visualToZeroBasedCoords, _visualToZeroBasedCoords2).call(this, cellRange.getBottomStartCorner()).row + rowDeltaRest;
226
+ }
227
+ }
220
228
  const {
221
229
  rowDir,
222
230
  colDir
@@ -236,16 +244,23 @@ class Transformation {
236
244
  this.runLocalHooks('afterTransformEnd', visualCoords, rowTransformDir, colTransformDir);
237
245
  return visualCoords;
238
246
  }
239
- }
240
- function _setOffsetSize2(_ref) {
241
- let {
242
- x,
243
- y
244
- } = _ref;
245
- _classPrivateFieldSet(this, _offset, {
246
- x,
247
- y
248
- });
247
+
248
+ /**
249
+ * Sets the additional offset in table size that may occur when the `navigableHeaders` option
250
+ * is enabled.
251
+ *
252
+ * @param {{x: number, y: number}} offset Offset as x and y properties.
253
+ */
254
+ setOffsetSize(_ref) {
255
+ let {
256
+ x,
257
+ y
258
+ } = _ref;
259
+ _classPrivateFieldSet(this, _offset, {
260
+ x,
261
+ y
262
+ });
263
+ }
249
264
  }
250
265
  function _clampCoords2(zeroBasedCoords) {
251
266
  const {
@@ -3,9 +3,9 @@
3
3
  exports.__esModule = true;
4
4
  const command = exports.command = {
5
5
  name: 'editorCloseAndSave',
6
- callback(hot, event, keys) {
6
+ callback(hot, event) {
7
7
  const editorManager = hot._getEditorManager();
8
8
  editorManager.closeEditorAndSaveChanges(event.ctrlKey || event.metaKey);
9
- editorManager.moveSelectionAfterEnter(keys.includes('shift'));
9
+ editorManager.moveSelectionAfterEnter(event);
10
10
  }
11
11
  };
@@ -1,8 +1,8 @@
1
1
  export const command = {
2
2
  name: 'editorCloseAndSave',
3
- callback(hot, event, keys) {
3
+ callback(hot, event) {
4
4
  const editorManager = hot._getEditorManager();
5
5
  editorManager.closeEditorAndSaveChanges(event.ctrlKey || event.metaKey);
6
- editorManager.moveSelectionAfterEnter(keys.includes('shift'));
6
+ editorManager.moveSelectionAfterEnter(event);
7
7
  }
8
8
  };