handsontable 0.0.0-next-f748da8-20240318 → 0.0.0-next-76fc9bd-20240319

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 (96) hide show
  1. package/3rdparty/walkontable/src/cell/range.d.ts +1 -2
  2. package/3rdparty/walkontable/src/cell/range.js +5 -22
  3. package/3rdparty/walkontable/src/cell/range.mjs +5 -22
  4. package/base.js +2 -2
  5. package/base.mjs +2 -2
  6. package/core/viewportScroll/index.js +1 -4
  7. package/core/viewportScroll/index.mjs +1 -4
  8. package/core.d.ts +3 -4
  9. package/core.js +21 -76
  10. package/core.mjs +21 -76
  11. package/dist/handsontable.css +2 -2
  12. package/dist/handsontable.full.css +2 -2
  13. package/dist/handsontable.full.js +1359 -2612
  14. package/dist/handsontable.full.min.css +2 -2
  15. package/dist/handsontable.full.min.js +64 -64
  16. package/dist/handsontable.js +1363 -2616
  17. package/dist/handsontable.min.css +2 -2
  18. package/dist/handsontable.min.js +19 -19
  19. package/editorManager.js +8 -12
  20. package/editorManager.mjs +8 -12
  21. package/helpers/mixed.js +1 -1
  22. package/helpers/mixed.mjs +1 -1
  23. package/package.json +1 -1
  24. package/pluginHooks.d.ts +0 -4
  25. package/pluginHooks.js +1 -69
  26. package/pluginHooks.mjs +1 -69
  27. package/plugins/collapsibleColumns/collapsibleColumns.js +3 -9
  28. package/plugins/collapsibleColumns/collapsibleColumns.mjs +3 -9
  29. package/plugins/columnSorting/columnSorting.js +2 -8
  30. package/plugins/columnSorting/columnSorting.mjs +2 -8
  31. package/plugins/contextMenu/menu/defaultShortcutsList.js +10 -26
  32. package/plugins/contextMenu/menu/defaultShortcutsList.mjs +10 -26
  33. package/plugins/mergeCells/calculations/selection.js +70 -1
  34. package/plugins/mergeCells/calculations/selection.mjs +70 -1
  35. package/plugins/mergeCells/cellsCollection.js +0 -116
  36. package/plugins/mergeCells/cellsCollection.mjs +0 -116
  37. package/plugins/mergeCells/contextMenuItem/toggleMerge.js +1 -11
  38. package/plugins/mergeCells/contextMenuItem/toggleMerge.mjs +1 -11
  39. package/plugins/mergeCells/mergeCells.js +192 -336
  40. package/plugins/mergeCells/mergeCells.mjs +192 -336
  41. package/plugins/multiColumnSorting/multiColumnSorting.js +2 -8
  42. package/plugins/multiColumnSorting/multiColumnSorting.mjs +2 -8
  43. package/plugins/nestedHeaders/nestedHeaders.js +0 -1
  44. package/plugins/nestedHeaders/nestedHeaders.mjs +0 -1
  45. package/plugins/nestedRows/nestedRows.js +3 -9
  46. package/plugins/nestedRows/nestedRows.mjs +3 -9
  47. package/renderers/checkboxRenderer/checkboxRenderer.js +5 -8
  48. package/renderers/checkboxRenderer/checkboxRenderer.mjs +5 -8
  49. package/selection/highlight/visualSelection.js +0 -2
  50. package/selection/highlight/visualSelection.mjs +0 -2
  51. package/selection/selection.js +40 -209
  52. package/selection/selection.mjs +39 -208
  53. package/selection/transformation.js +32 -83
  54. package/selection/transformation.mjs +32 -83
  55. package/shortcutContexts/commands/editor/closeAndSave.js +2 -2
  56. package/shortcutContexts/commands/editor/closeAndSave.mjs +2 -2
  57. package/shortcutContexts/commands/editor/open.js +3 -18
  58. package/shortcutContexts/commands/editor/open.mjs +3 -18
  59. package/shortcutContexts/commands/extendCellsSelection/down.js +1 -1
  60. package/shortcutContexts/commands/extendCellsSelection/down.mjs +1 -1
  61. package/shortcutContexts/commands/extendCellsSelection/left.js +1 -1
  62. package/shortcutContexts/commands/extendCellsSelection/left.mjs +1 -1
  63. package/shortcutContexts/commands/extendCellsSelection/right.js +1 -1
  64. package/shortcutContexts/commands/extendCellsSelection/right.mjs +1 -1
  65. package/shortcutContexts/commands/extendCellsSelection/toColumns.js +1 -1
  66. package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +1 -1
  67. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +1 -3
  68. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +1 -3
  69. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +3 -9
  70. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +3 -9
  71. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +3 -10
  72. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +3 -10
  73. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +1 -3
  74. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +1 -3
  75. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +1 -3
  76. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +1 -3
  77. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +1 -3
  78. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +1 -3
  79. package/shortcutContexts/commands/extendCellsSelection/toRows.js +1 -1
  80. package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +1 -1
  81. package/shortcutContexts/commands/extendCellsSelection/up.js +1 -1
  82. package/shortcutContexts/commands/extendCellsSelection/up.mjs +1 -1
  83. package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +1 -6
  84. package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +1 -6
  85. package/shortcutContexts/commands/moveCellSelection/inlineStart.js +1 -6
  86. package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +1 -6
  87. package/shortcutContexts/grid.js +9 -3
  88. package/shortcutContexts/grid.mjs +9 -3
  89. package/shortcuts/context.js +1 -2
  90. package/shortcuts/context.mjs +1 -2
  91. package/utils/dataStructures/linkedList.js +1 -6
  92. package/utils/dataStructures/linkedList.mjs +1 -6
  93. package/core/viewportScroll/scrollStrategies/focusScroll.js +0 -15
  94. package/core/viewportScroll/scrollStrategies/focusScroll.mjs +0 -11
  95. package/plugins/mergeCells/focusOrder.js +0 -303
  96. package/plugins/mergeCells/focusOrder.mjs +0 -298
@@ -22,9 +22,6 @@ import { A11Y_SELECTED } from "../helpers/a11y.mjs";
22
22
  * @class Selection
23
23
  * @util
24
24
  */
25
- var _transformation = /*#__PURE__*/new WeakMap();
26
- var _focusTransformation = /*#__PURE__*/new WeakMap();
27
- var _isFocusSelectionChanged = /*#__PURE__*/new WeakMap();
28
25
  var _disableHeadersHighlight = /*#__PURE__*/new WeakMap();
29
26
  var _selectionSource = /*#__PURE__*/new WeakMap();
30
27
  var _expectedLayersCount = /*#__PURE__*/new WeakMap();
@@ -64,17 +61,11 @@ class Selection {
64
61
  */
65
62
  _defineProperty(this, "highlight", void 0);
66
63
  /**
67
- * The module for modifying coordinates of the start and end selection.
64
+ * The module for modifying coordinates.
68
65
  *
69
66
  * @type {Transformation}
70
67
  */
71
- _classPrivateFieldInitSpec(this, _transformation, void 0);
72
- /**
73
- * The module for modifying coordinates of the focus selection.
74
- *
75
- * @type {Transformation}
76
- */
77
- _classPrivateFieldInitSpec(this, _focusTransformation, void 0);
68
+ _defineProperty(this, "transformation", void 0);
78
69
  /**
79
70
  * The collection of the selection layer levels where the whole row was selected using the row header or
80
71
  * the corner header.
@@ -89,12 +80,6 @@ class Selection {
89
80
  * @type {Set<number>}
90
81
  */
91
82
  _defineProperty(this, "selectedByColumnHeader", new Set());
92
- /**
93
- * The flag which determines if the focus selection was changed.
94
- *
95
- * @type {boolean}
96
- */
97
- _classPrivateFieldInitSpec(this, _isFocusSelectionChanged, false);
98
83
  /**
99
84
  * When sets disable highlighting the headers even when the logical coordinates points on them.
100
85
  *
@@ -136,112 +121,71 @@ class Selection {
136
121
  createCellCoords: (row, column) => this.tableProps.createCellCoords(row, column),
137
122
  createCellRange: (highlight, from, to) => this.tableProps.createCellRange(highlight, from, to)
138
123
  });
139
- _classPrivateFieldSet(_transformation, this, new Transformation(this.selectedRange, {
124
+ this.transformation = new Transformation(this.selectedRange, {
140
125
  rowIndexMapper: this.tableProps.rowIndexMapper,
141
126
  columnIndexMapper: this.tableProps.columnIndexMapper,
142
127
  countRenderableRows: () => this.tableProps.countRenderableRows(),
143
128
  countRenderableColumns: () => this.tableProps.countRenderableColumns(),
129
+ countRowHeaders: () => this.tableProps.countRowHeaders(),
130
+ countColHeaders: () => this.tableProps.countColHeaders(),
144
131
  visualToRenderableCoords: coords => this.tableProps.visualToRenderableCoords(coords),
145
132
  renderableToVisualCoords: coords => this.tableProps.renderableToVisualCoords(coords),
146
- findFirstNonHiddenRenderableRow: function () {
147
- return _this.tableProps.findFirstNonHiddenRenderableRow(...arguments);
148
- },
149
- findFirstNonHiddenRenderableColumn: function () {
150
- return _this.tableProps.findFirstNonHiddenRenderableColumn(...arguments);
151
- },
152
133
  createCellCoords: (row, column) => this.tableProps.createCellCoords(row, column),
134
+ navigableHeaders: () => settings.navigableHeaders,
153
135
  fixedRowsBottom: () => settings.fixedRowsBottom,
154
136
  minSpareRows: () => settings.minSpareRows,
155
137
  minSpareCols: () => settings.minSpareCols,
156
138
  autoWrapRow: () => settings.autoWrapRow,
157
139
  autoWrapCol: () => settings.autoWrapCol
158
- }));
159
- _classPrivateFieldSet(_focusTransformation, this, new Transformation(this.selectedRange, {
160
- rowIndexMapper: this.tableProps.rowIndexMapper,
161
- columnIndexMapper: this.tableProps.columnIndexMapper,
162
- countRenderableRows: () => {
163
- const range = this.selectedRange.current();
164
- return this.tableProps.countRenderableRowsInRange(0, range.getOuterBottomEndCorner().row);
165
- },
166
- countRenderableColumns: () => {
167
- const range = this.selectedRange.current();
168
- return this.tableProps.countRenderableColumnsInRange(0, range.getOuterBottomEndCorner().col);
169
- },
170
- visualToRenderableCoords: coords => this.tableProps.visualToRenderableCoords(coords),
171
- renderableToVisualCoords: coords => this.tableProps.renderableToVisualCoords(coords),
172
- findFirstNonHiddenRenderableRow: function () {
173
- return _this.tableProps.findFirstNonHiddenRenderableRow(...arguments);
174
- },
175
- findFirstNonHiddenRenderableColumn: function () {
176
- return _this.tableProps.findFirstNonHiddenRenderableColumn(...arguments);
177
- },
178
- createCellCoords: (row, column) => this.tableProps.createCellCoords(row, column),
179
- fixedRowsBottom: () => 0,
180
- minSpareRows: () => 0,
181
- minSpareCols: () => 0,
182
- autoWrapRow: () => true,
183
- autoWrapCol: () => true
184
- }));
185
- _classPrivateFieldGet(_transformation, this).addLocalHook('beforeTransformStart', function () {
140
+ });
141
+ this.transformation.addLocalHook('beforeTransformStart', function () {
186
142
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
187
143
  args[_key] = arguments[_key];
188
144
  }
189
145
  return _this.runLocalHooks('beforeModifyTransformStart', ...args);
190
146
  });
191
- _classPrivateFieldGet(_transformation, this).addLocalHook('afterTransformStart', function () {
147
+ this.transformation.addLocalHook('afterTransformStart', function () {
192
148
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
193
149
  args[_key2] = arguments[_key2];
194
150
  }
195
151
  return _this.runLocalHooks('afterModifyTransformStart', ...args);
196
152
  });
197
- _classPrivateFieldGet(_transformation, this).addLocalHook('beforeTransformEnd', function () {
153
+ this.transformation.addLocalHook('beforeTransformEnd', function () {
198
154
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
199
155
  args[_key3] = arguments[_key3];
200
156
  }
201
157
  return _this.runLocalHooks('beforeModifyTransformEnd', ...args);
202
158
  });
203
- _classPrivateFieldGet(_transformation, this).addLocalHook('afterTransformEnd', function () {
159
+ this.transformation.addLocalHook('afterTransformEnd', function () {
204
160
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
205
161
  args[_key4] = arguments[_key4];
206
162
  }
207
163
  return _this.runLocalHooks('afterModifyTransformEnd', ...args);
208
164
  });
209
- _classPrivateFieldGet(_transformation, this).addLocalHook('insertRowRequire', function () {
165
+ this.transformation.addLocalHook('insertRowRequire', function () {
210
166
  for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
211
167
  args[_key5] = arguments[_key5];
212
168
  }
213
169
  return _this.runLocalHooks('insertRowRequire', ...args);
214
170
  });
215
- _classPrivateFieldGet(_transformation, this).addLocalHook('insertColRequire', function () {
171
+ this.transformation.addLocalHook('insertColRequire', function () {
216
172
  for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
217
173
  args[_key6] = arguments[_key6];
218
174
  }
219
175
  return _this.runLocalHooks('insertColRequire', ...args);
220
176
  });
221
- _classPrivateFieldGet(_transformation, this).addLocalHook('beforeRowWrap', function () {
177
+ this.transformation.addLocalHook('beforeRowWrap', function () {
222
178
  for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
223
179
  args[_key7] = arguments[_key7];
224
180
  }
225
181
  return _this.runLocalHooks('beforeRowWrap', ...args);
226
182
  });
227
- _classPrivateFieldGet(_transformation, this).addLocalHook('beforeColumnWrap', function () {
183
+ this.transformation.addLocalHook('beforeColumnWrap', function () {
228
184
  for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
229
185
  args[_key8] = arguments[_key8];
230
186
  }
231
187
  return _this.runLocalHooks('beforeColumnWrap', ...args);
232
188
  });
233
- _classPrivateFieldGet(_focusTransformation, this).addLocalHook('beforeTransformStart', function () {
234
- for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
235
- args[_key9] = arguments[_key9];
236
- }
237
- return _this.runLocalHooks('beforeModifyTransformFocus', ...args);
238
- });
239
- _classPrivateFieldGet(_focusTransformation, this).addLocalHook('afterTransformStart', function () {
240
- for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
241
- args[_key10] = arguments[_key10];
242
- }
243
- return _this.runLocalHooks('afterModifyTransformFocus', ...args);
244
- });
245
189
  }
246
190
 
247
191
  /**
@@ -332,7 +276,6 @@ class Selection {
332
276
  // We are creating copy. We would like to modify just the start of the selection by below hook. Then original coords
333
277
  // should be handled by next methods.
334
278
  const coordsClone = coords.clone();
335
- _classPrivateFieldSet(_isFocusSelectionChanged, this, false);
336
279
  this.runLocalHooks(`beforeSetRangeStart${fragment ? 'Only' : ''}`, coordsClone);
337
280
  if (!isMultipleMode || isMultipleMode && !isMultipleSelection && isUndefined(multipleSelection)) {
338
281
  this.selectedRange.clear();
@@ -390,20 +333,7 @@ class Selection {
390
333
  cellRange.setFrom(cellRange.highlight);
391
334
  cellRange.setTo(cellRange.highlight);
392
335
  } else {
393
- const horizontalDir = cellRange.getHorizontalDirection();
394
- const verticalDir = cellRange.getVerticalDirection();
395
- const isMultiple = this.isMultiple();
396
336
  cellRange.setTo(coordsClone);
397
- if (isMultiple && (horizontalDir !== cellRange.getHorizontalDirection() || cellRange.getWidth() === 1 && !cellRange.includes(cellRange.highlight))) {
398
- cellRange.from.assign({
399
- col: cellRange.highlight.col
400
- });
401
- }
402
- if (isMultiple && (verticalDir !== cellRange.getVerticalDirection() || cellRange.getHeight() === 1 && !cellRange.includes(cellRange.highlight))) {
403
- cellRange.from.assign({
404
- row: cellRange.highlight.row
405
- });
406
- }
407
337
  }
408
338
 
409
339
  // Prevent creating "area" selection that overlaps headers.
@@ -413,7 +343,11 @@ class Selection {
413
343
  }
414
344
  }
415
345
  this.runLocalHooks('beforeHighlightSet');
416
- this.setRangeFocus(this.selectedRange.current().highlight);
346
+ const focusHighlight = this.highlight.getFocus();
347
+ focusHighlight.clear();
348
+ if (this.highlight.isEnabledFor(FOCUS_TYPE, cellRange.highlight)) {
349
+ focusHighlight.add(this.selectedRange.current().highlight).commit().syncWith(cellRange);
350
+ }
417
351
  const layerLevel = this.getLayerLevel();
418
352
 
419
353
  // If the next layer level is lower than previous then clear all area and header highlights. This is the
@@ -501,31 +435,15 @@ class Selection {
501
435
  }
502
436
 
503
437
  /**
504
- * Sets the selection focus position at the specified coordinates.
438
+ * Returns information if we have a multiselection. This method check multiselection only on the latest layer of
439
+ * the selection.
505
440
  *
506
- * @param {CellCoords} coords The CellCoords instance with defined visual coordinates.
441
+ * @returns {boolean}
507
442
  */
508
- setRangeFocus(coords) {
509
- if (this.selectedRange.isEmpty()) {
510
- return;
511
- }
512
- const cellRange = this.selectedRange.current();
513
- if (!this.inProgress) {
514
- this.runLocalHooks('beforeSetFocus', coords);
515
- }
516
- const focusHighlight = this.highlight.getFocus();
517
- focusHighlight.clear();
518
- cellRange.setHighlight(coords);
519
- if (!this.inProgress) {
520
- this.runLocalHooks('beforeHighlightSet');
521
- }
522
- if (this.highlight.isEnabledFor(FOCUS_TYPE, cellRange.highlight)) {
523
- focusHighlight.add(cellRange.highlight).commit().syncWith(cellRange);
524
- }
525
- if (!this.inProgress) {
526
- _classPrivateFieldSet(_isFocusSelectionChanged, this, true);
527
- this.runLocalHooks('afterSetFocus', cellRange.highlight);
528
- }
443
+ isMultiple() {
444
+ const isMultipleListener = createObjectPropListener(!this.selectedRange.current().isSingle());
445
+ this.runLocalHooks('afterIsMultipleSelection', isMultipleListener);
446
+ return isMultipleListener.value;
529
447
  }
530
448
 
531
449
  /**
@@ -538,13 +456,7 @@ class Selection {
538
456
  */
539
457
  transformStart(rowDelta, colDelta) {
540
458
  let createMissingRecords = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
541
- if (this.settings.navigableHeaders) {
542
- _classPrivateFieldGet(_transformation, this).setOffsetSize({
543
- x: this.tableProps.countRowHeaders(),
544
- y: this.tableProps.countColHeaders()
545
- });
546
- }
547
- this.setRangeStart(_classPrivateFieldGet(_transformation, this).transformStart(rowDelta, colDelta, createMissingRecords));
459
+ this.setRangeStart(this.transformation.transformStart(rowDelta, colDelta, createMissingRecords));
548
460
  }
549
461
 
550
462
  /**
@@ -554,44 +466,7 @@ class Selection {
554
466
  * @param {number} colDelta Columns number to move, value can be passed as negative number.
555
467
  */
556
468
  transformEnd(rowDelta, colDelta) {
557
- if (this.settings.navigableHeaders) {
558
- _classPrivateFieldGet(_transformation, this).setOffsetSize({
559
- x: this.tableProps.countRowHeaders(),
560
- y: this.tableProps.countColHeaders()
561
- });
562
- }
563
- this.setRangeEnd(_classPrivateFieldGet(_transformation, this).transformEnd(rowDelta, colDelta));
564
- }
565
-
566
- /**
567
- * Transforms the focus cell selection relative to the current focus position.
568
- *
569
- * @param {number} rowDelta Rows number to move, value can be passed as negative number.
570
- * @param {number} colDelta Columns number to move, value can be passed as negative number.
571
- */
572
- transformFocus(rowDelta, colDelta) {
573
- const range = this.selectedRange.current();
574
- const {
575
- row,
576
- col
577
- } = range.getOuterTopStartCorner();
578
- const columnsInRange = this.tableProps.countRenderableColumnsInRange(0, col - 1);
579
- const rowsInRange = this.tableProps.countRenderableRowsInRange(0, row - 1);
580
- if (range.highlight.isHeader()) {
581
- // for header focus selection calculate the new coords based on the selection including headers
582
- _classPrivateFieldGet(_focusTransformation, this).setOffsetSize({
583
- x: col < 0 ? Math.abs(col) : -columnsInRange,
584
- y: row < 0 ? Math.abs(row) : -rowsInRange
585
- });
586
- } else {
587
- // for focus selection in cells calculate the new coords only based on the selected cells
588
- _classPrivateFieldGet(_focusTransformation, this).setOffsetSize({
589
- x: col < 0 ? 0 : -columnsInRange,
590
- y: row < 0 ? 0 : -rowsInRange
591
- });
592
- }
593
- const focusCoords = _classPrivateFieldGet(_focusTransformation, this).transformStart(rowDelta, colDelta);
594
- this.setRangeFocus(focusCoords.normalize());
469
+ this.setRangeEnd(this.transformation.transformEnd(rowDelta, colDelta));
595
470
  }
596
471
 
597
472
  /**
@@ -612,30 +487,6 @@ class Selection {
612
487
  return !this.selectedRange.isEmpty();
613
488
  }
614
489
 
615
- /**
616
- * Returns information if we have a multi-selection. This method check multi-selection only on the latest layer of
617
- * the selection.
618
- *
619
- * @returns {boolean}
620
- */
621
- isMultiple() {
622
- if (!this.isSelected()) {
623
- return false;
624
- }
625
- const isMultipleListener = createObjectPropListener(!this.selectedRange.current().isSingle());
626
- this.runLocalHooks('afterIsMultipleSelection', isMultipleListener);
627
- return isMultipleListener.value;
628
- }
629
-
630
- /**
631
- * Checks if the last selection involves changing the focus cell position only.
632
- *
633
- * @returns {boolean}
634
- */
635
- isFocusSelectionChanged() {
636
- return this.isSelected() && _classPrivateFieldGet(_isFocusSelectionChanged, this);
637
- }
638
-
639
490
  /**
640
491
  * Returns `true` if the selection was applied by clicking to the row header. If the `layerLevel`
641
492
  * argument is passed then only that layer will be checked. Otherwise, it checks if any row header
@@ -918,10 +769,9 @@ class Selection {
918
769
  *
919
770
  * @param {number|string} startColumn Visual column index or column property from which the selection starts.
920
771
  * @param {number|string} [endColumn] Visual column index or column property from to the selection finishes.
921
- * @param {number | { row: number, col: number }} [focusPosition=0] The argument allows changing the cell/header focus
922
- * position. The value can take visual row index from -N to N, where negative values point to the headers and positive
923
- * values point to the cell range. An object with `row` and `col` properties also can be passed to change the focus
924
- * position horizontally.
772
+ * @param {number} [focusPosition=0] The argument allows changing the cell/header focus position.
773
+ * The value can take visual row index from -N to N, where negative values
774
+ * point to the headers and positive values point to the cell range.
925
775
  * @returns {boolean} Returns `true` if selection was successful, `false` otherwise.
926
776
  */
927
777
  selectColumns(startColumn) {
@@ -942,20 +792,11 @@ class Selection {
942
792
  countColHeaders
943
793
  });
944
794
  if (isValid) {
945
- let highlightRow = 0;
946
- let highlightColumn = 0;
947
- if (Number.isInteger(focusPosition === null || focusPosition === void 0 ? void 0 : focusPosition.row) && Number.isInteger(focusPosition === null || focusPosition === void 0 ? void 0 : focusPosition.col)) {
948
- highlightRow = clamp(focusPosition.row, columnHeaderLastIndex, countRows - 1);
949
- highlightColumn = clamp(focusPosition.col, Math.min(start, end), Math.max(start, end));
950
- } else {
951
- highlightRow = clamp(focusPosition, columnHeaderLastIndex, countRows - 1);
952
- highlightColumn = start;
953
- }
954
- const highlight = this.tableProps.createCellCoords(highlightRow, highlightColumn);
955
- const fromRow = countColHeaders === 0 ? 0 : clamp(highlight.row, columnHeaderLastIndex, -1);
795
+ const fromRow = countColHeaders === 0 ? 0 : clamp(focusPosition, columnHeaderLastIndex, -1);
956
796
  const toRow = countRows - 1;
957
797
  const from = this.tableProps.createCellCoords(fromRow, start);
958
798
  const to = this.tableProps.createCellCoords(toRow, end);
799
+ const highlight = this.tableProps.createCellCoords(clamp(focusPosition, columnHeaderLastIndex, countRows - 1), start);
959
800
  this.runLocalHooks('beforeSelectColumns', from, to, highlight);
960
801
 
961
802
  // disallow modifying row axis for that hooks
@@ -975,10 +816,9 @@ class Selection {
975
816
  *
976
817
  * @param {number} startRow Visual row index from which the selection starts.
977
818
  * @param {number} [endRow] Visual row index from to the selection finishes.
978
- * @param {number | { row: number, col: number }} [focusPosition=0] The argument allows changing the cell/header focus
979
- * position. The value can take visual row index from -N to N, where negative values point to the headers and positive
980
- * values point to the cell range. An object with `row` and `col` properties also can be passed to change the focus
981
- * position horizontally.
819
+ * @param {number} [focusPosition=0] The argument allows changing the cell/header focus position.
820
+ * The value can take visual column index from -N to N, where negative values
821
+ * point to the headers and positive values point to the cell range.
982
822
  * @returns {boolean} Returns `true` if selection was successful, `false` otherwise.
983
823
  */
984
824
  selectRows(startRow) {
@@ -997,20 +837,11 @@ class Selection {
997
837
  countColHeaders: 0
998
838
  });
999
839
  if (isValid) {
1000
- let highlightRow = 0;
1001
- let highlightColumn = 0;
1002
- if (Number.isInteger(focusPosition === null || focusPosition === void 0 ? void 0 : focusPosition.row) && Number.isInteger(focusPosition === null || focusPosition === void 0 ? void 0 : focusPosition.col)) {
1003
- highlightRow = clamp(focusPosition.row, Math.min(startRow, endRow), Math.max(startRow, endRow));
1004
- highlightColumn = clamp(focusPosition.col, rowHeaderLastIndex, countCols - 1);
1005
- } else {
1006
- highlightRow = startRow;
1007
- highlightColumn = clamp(focusPosition, rowHeaderLastIndex, countCols - 1);
1008
- }
1009
- const highlight = this.tableProps.createCellCoords(highlightRow, highlightColumn);
1010
- const fromColumn = countRowHeaders === 0 ? 0 : clamp(highlight.col, rowHeaderLastIndex, -1);
840
+ const fromColumn = countRowHeaders === 0 ? 0 : clamp(focusPosition, rowHeaderLastIndex, -1);
1011
841
  const toColumn = countCols - 1;
1012
842
  const from = this.tableProps.createCellCoords(startRow, fromColumn);
1013
843
  const to = this.tableProps.createCellCoords(endRow, toColumn);
844
+ const highlight = this.tableProps.createCellCoords(startRow, clamp(focusPosition, rowHeaderLastIndex, countCols - 1));
1014
845
  this.runLocalHooks('beforeSelectRows', from, to, highlight);
1015
846
 
1016
847
  // disallow modifying column axis for that hooks
@@ -33,10 +33,10 @@ var _Transformation_brand = /*#__PURE__*/new WeakSet();
33
33
  class Transformation {
34
34
  constructor(range, options) {
35
35
  /**
36
- * Clamps the coords to make sure they points to the cell (or header) in the table range.
36
+ * Sets the additional offset in table size that may occur when the `navigableHeaders` option
37
+ * is enabled.
37
38
  *
38
- * @param {CellCoords} zeroBasedCoords The coords object to clamp.
39
- * @returns {{rowDir: 1|0|-1, colDir: 1|0|-1}}
39
+ * @param {{x: number, y: number}} offset Offset as x and y properties.
40
40
  */
41
41
  _classPrivateMethodInitSpec(this, _Transformation_brand);
42
42
  /**
@@ -77,6 +77,10 @@ class Transformation {
77
77
  */
78
78
  transformStart(rowDelta, colDelta) {
79
79
  let createMissingRecords = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
80
+ _assertClassBrand(_Transformation_brand, this, _setOffsetSize).call(this, {
81
+ x: _classPrivateFieldGet(_options, this).navigableHeaders() ? _classPrivateFieldGet(_options, this).countRowHeaders() : 0,
82
+ y: _classPrivateFieldGet(_options, this).navigableHeaders() ? _classPrivateFieldGet(_options, this).countColHeaders() : 0
83
+ });
80
84
  const delta = _classPrivateFieldGet(_options, this).createCellCoords(rowDelta, colDelta);
81
85
  let visualCoords = _classPrivateFieldGet(_range, this).current().highlight;
82
86
  const highlightRenderableCoords = _classPrivateFieldGet(_options, this).visualToRenderableCoords(visualCoords);
@@ -156,46 +160,23 @@ class Transformation {
156
160
  * @returns {CellCoords} Visual coordinates after transformation.
157
161
  */
158
162
  transformEnd(rowDelta, colDelta) {
163
+ _assertClassBrand(_Transformation_brand, this, _setOffsetSize).call(this, {
164
+ x: _classPrivateFieldGet(_options, this).navigableHeaders() ? _classPrivateFieldGet(_options, this).countRowHeaders() : 0,
165
+ y: _classPrivateFieldGet(_options, this).navigableHeaders() ? _classPrivateFieldGet(_options, this).countColHeaders() : 0
166
+ });
159
167
  const delta = _classPrivateFieldGet(_options, this).createCellCoords(rowDelta, colDelta);
160
168
  const cellRange = _classPrivateFieldGet(_range, this).current();
161
169
  const highlightRenderableCoords = _classPrivateFieldGet(_options, this).visualToRenderableCoords(cellRange.highlight);
162
- const toRow = _assertClassBrand(_Transformation_brand, this, _findFirstNonHiddenZeroBasedRow).call(this, cellRange.to.row, cellRange.from.row);
163
- const toColumn = _assertClassBrand(_Transformation_brand, this, _findFirstNonHiddenZeroBasedColumn).call(this, cellRange.to.col, cellRange.from.col);
164
170
  const visualCoords = cellRange.to.clone();
165
171
  let rowTransformDir = 0;
166
172
  let colTransformDir = 0;
167
173
  this.runLocalHooks('beforeTransformEnd', delta);
168
- if (highlightRenderableCoords.row !== null && highlightRenderableCoords.col !== null && toRow !== null && toColumn !== null) {
174
+ if (highlightRenderableCoords.row !== null && highlightRenderableCoords.col !== null) {
169
175
  const {
170
- row: highlightRow,
171
- col: highlightColumn
172
- } = _assertClassBrand(_Transformation_brand, this, _visualToZeroBasedCoords).call(this, cellRange.highlight);
173
- const coords = _classPrivateFieldGet(_options, this).createCellCoords(toRow + delta.row, toColumn + delta.col);
174
- const topStartCorner = cellRange.getTopStartCorner();
175
- const topEndCorner = cellRange.getTopEndCorner();
176
- const bottomEndCorner = cellRange.getBottomEndCorner();
177
- const restDelta = {
178
- row: coords.row - highlightRow,
179
- col: coords.col - highlightColumn
180
- };
181
- if (delta.col < 0) {
182
- if (toColumn >= highlightColumn && coords.col < highlightColumn) {
183
- coords.col = _assertClassBrand(_Transformation_brand, this, _findFirstNonHiddenZeroBasedColumn).call(this, topStartCorner.col, topEndCorner.col) + restDelta.col;
184
- }
185
- } else if (delta.col > 0) {
186
- if (toColumn <= highlightColumn && coords.col > highlightColumn) {
187
- coords.col = _assertClassBrand(_Transformation_brand, this, _findFirstNonHiddenZeroBasedColumn).call(this, topEndCorner.col, topStartCorner.col) + restDelta.col;
188
- }
189
- }
190
- if (delta.row < 0) {
191
- if (toRow >= highlightRow && coords.row < highlightRow) {
192
- coords.row = _assertClassBrand(_Transformation_brand, this, _findFirstNonHiddenZeroBasedRow).call(this, topStartCorner.row, bottomEndCorner.row) + restDelta.row;
193
- }
194
- } else if (delta.row > 0) {
195
- if (toRow <= highlightRow && coords.row > highlightRow) {
196
- coords.row = _assertClassBrand(_Transformation_brand, this, _findFirstNonHiddenZeroBasedRow).call(this, bottomEndCorner.row, topStartCorner.row) + restDelta.row;
197
- }
198
- }
176
+ row,
177
+ col
178
+ } = _assertClassBrand(_Transformation_brand, this, _visualToZeroBasedCoords).call(this, cellRange.to);
179
+ const coords = _classPrivateFieldGet(_options, this).createCellCoords(row + delta.row, col + delta.col);
199
180
  const {
200
181
  rowDir,
201
182
  colDir
@@ -215,24 +196,23 @@ class Transformation {
215
196
  this.runLocalHooks('afterTransformEnd', visualCoords, rowTransformDir, colTransformDir);
216
197
  return visualCoords;
217
198
  }
218
-
219
- /**
220
- * Sets the additional offset in table size that may occur when the `navigableHeaders` option
221
- * is enabled.
222
- *
223
- * @param {{x: number, y: number}} offset Offset as x and y properties.
224
- */
225
- setOffsetSize(_ref) {
226
- let {
227
- x,
228
- y
229
- } = _ref;
230
- _classPrivateFieldSet(_offset, this, {
231
- x,
232
- y
233
- });
234
- }
235
199
  }
200
+ function _setOffsetSize(_ref) {
201
+ let {
202
+ x,
203
+ y
204
+ } = _ref;
205
+ _classPrivateFieldSet(_offset, this, {
206
+ x,
207
+ y
208
+ });
209
+ }
210
+ /**
211
+ * Clamps the coords to make sure they points to the cell (or header) in the table range.
212
+ *
213
+ * @param {CellCoords} zeroBasedCoords The coords object to clamp.
214
+ * @returns {{rowDir: 1|0|-1, colDir: 1|0|-1}}
215
+ */
236
216
  function _clampCoords(zeroBasedCoords) {
237
217
  const {
238
218
  width,
@@ -271,34 +251,6 @@ function _getTableSize() {
271
251
  height: _classPrivateFieldGet(_offset, this).y + _classPrivateFieldGet(_options, this).countRenderableRows()
272
252
  };
273
253
  }
274
- /**
275
- * Finds the first non-hidden zero-based row in the table range.
276
- *
277
- * @param {number} visualRowFrom The visual row from which the search should start.
278
- * @param {number} visualRowTo The visual row to which the search should end.
279
- * @returns {number | null}
280
- */
281
- function _findFirstNonHiddenZeroBasedRow(visualRowFrom, visualRowTo) {
282
- const row = _classPrivateFieldGet(_options, this).findFirstNonHiddenRenderableRow(visualRowFrom, visualRowTo);
283
- if (row === null) {
284
- return null;
285
- }
286
- return _classPrivateFieldGet(_offset, this).y + row;
287
- }
288
- /**
289
- * Finds the first non-hidden zero-based column in the table range.
290
- *
291
- * @param {number} visualColumnFrom The visual column from which the search should start.
292
- * @param {number} visualColumnTo The visual column to which the search should end.
293
- * @returns {number | null}
294
- */
295
- function _findFirstNonHiddenZeroBasedColumn(visualColumnFrom, visualColumnTo) {
296
- const column = _classPrivateFieldGet(_options, this).findFirstNonHiddenRenderableColumn(visualColumnFrom, visualColumnTo);
297
- if (column === null) {
298
- return null;
299
- }
300
- return _classPrivateFieldGet(_offset, this).x + column;
301
- }
302
254
  /**
303
255
  * Translates the visual coordinates to zero-based ones.
304
256
  *
@@ -310,9 +262,6 @@ function _visualToZeroBasedCoords(visualCoords) {
310
262
  row,
311
263
  col
312
264
  } = _classPrivateFieldGet(_options, this).visualToRenderableCoords(visualCoords);
313
- if (row === null || col === null) {
314
- throw new Error('Renderable coords are not visible.');
315
- }
316
265
  return _classPrivateFieldGet(_options, this).createCellCoords(_classPrivateFieldGet(_offset, this).y + row, _classPrivateFieldGet(_offset, this).x + col);
317
266
  }
318
267
  /**