handsontable 0.0.0-next-221e46b-20240307 → 0.0.0-next-2becb78-20240313

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 +81 -21
  12. package/core.mjs +81 -21
  13. package/dist/handsontable.css +2 -2
  14. package/dist/handsontable.full.css +2 -2
  15. package/dist/handsontable.full.js +2721 -1361
  16. package/dist/handsontable.full.min.css +2 -2
  17. package/dist/handsontable.full.min.js +152 -152
  18. package/dist/handsontable.js +2721 -1361
  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 +327 -0
  42. package/plugins/mergeCells/focusOrder.mjs +322 -0
  43. package/plugins/mergeCells/mergeCells.js +392 -197
  44. package/plugins/mergeCells/mergeCells.mjs +392 -197
  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 +8 -5
  52. package/renderers/checkboxRenderer/checkboxRenderer.mjs +8 -5
  53. package/selection/highlight/visualSelection.js +16 -2
  54. package/selection/highlight/visualSelection.mjs +16 -2
  55. package/selection/selection.js +228 -44
  56. package/selection/selection.mjs +227 -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
@@ -0,0 +1,322 @@
1
+ import "core-js/modules/es.array.push.js";
2
+ import "core-js/modules/es.error.cause.js";
3
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
4
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
5
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
6
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
7
+ function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
8
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
9
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
10
+ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
11
+ 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; } }
12
+ import LinkedList from "../../utils/dataStructures/linkedList.mjs";
13
+ /**
14
+ * Class responsible for providing the correct focus order (vertical and horizontal) within a selection that
15
+ * contains merged cells.
16
+ */
17
+ var _cellsHorizontalOrder = /*#__PURE__*/new WeakMap();
18
+ var _cellsVerticalOrder = /*#__PURE__*/new WeakMap();
19
+ var _currentHorizontalLinkedNode = /*#__PURE__*/new WeakMap();
20
+ var _currentVerticalLinkedNode = /*#__PURE__*/new WeakMap();
21
+ var _mergedCellsGetter = /*#__PURE__*/new WeakMap();
22
+ var _rowIndexMapper = /*#__PURE__*/new WeakMap();
23
+ var _columnIndexMapper = /*#__PURE__*/new WeakMap();
24
+ var _pushOrderNode = /*#__PURE__*/new WeakSet();
25
+ export class FocusOrder {
26
+ constructor(_ref) {
27
+ let {
28
+ mergedCellsGetter,
29
+ rowIndexMapper,
30
+ columnIndexMapper
31
+ } = _ref;
32
+ /**
33
+ * Pushes a new node to the provided list order.
34
+ *
35
+ * @param {CellRange} selectedRange The selected range to build the focus order for.
36
+ * @param {LinkedList} listOrder The list order to push the node to.
37
+ * @param {WeakSet} mergeCellsVisitor The set of visited cells.
38
+ * @param {number} row The visual row index.
39
+ * @param {number} column The visual column index.
40
+ * @returns {NodeStructure | null}
41
+ */
42
+ _classPrivateMethodInitSpec(this, _pushOrderNode);
43
+ /**
44
+ * The linked list of the all cells within the current selection in horizontal order. The list is
45
+ * recreated every time the selection is changed.
46
+ *
47
+ * @type {LinkedList}
48
+ */
49
+ _classPrivateFieldInitSpec(this, _cellsHorizontalOrder, {
50
+ writable: true,
51
+ value: new LinkedList()
52
+ });
53
+ /**
54
+ * The linked list of the all cells within the current selection in horizontal order. The list is
55
+ * recreated every time the selection is changed.
56
+ *
57
+ * @type {LinkedList}
58
+ */
59
+ _classPrivateFieldInitSpec(this, _cellsVerticalOrder, {
60
+ writable: true,
61
+ value: new LinkedList()
62
+ });
63
+ /**
64
+ * The currently highlighted cell within the horizontal linked list.
65
+ *
66
+ * @type {NodeStructure | null}
67
+ */
68
+ _classPrivateFieldInitSpec(this, _currentHorizontalLinkedNode, {
69
+ writable: true,
70
+ value: null
71
+ });
72
+ /**
73
+ * The currently highlighted cell within the vertical linked list.
74
+ *
75
+ * @type {NodeStructure | null}
76
+ */
77
+ _classPrivateFieldInitSpec(this, _currentVerticalLinkedNode, {
78
+ writable: true,
79
+ value: null
80
+ });
81
+ /**
82
+ * The merged cells getter function.
83
+ *
84
+ * @type {function(): {row: number, col: number, rowspan: number, colspan: number} | null}}
85
+ */
86
+ _classPrivateFieldInitSpec(this, _mergedCellsGetter, {
87
+ writable: true,
88
+ value: null
89
+ });
90
+ /**
91
+ * The row index mapper.
92
+ *
93
+ * @type {IndexMapper}
94
+ */
95
+ _classPrivateFieldInitSpec(this, _rowIndexMapper, {
96
+ writable: true,
97
+ value: null
98
+ });
99
+ /**
100
+ * The column index mapper.
101
+ *
102
+ * @type {IndexMapper}
103
+ */
104
+ _classPrivateFieldInitSpec(this, _columnIndexMapper, {
105
+ writable: true,
106
+ value: null
107
+ });
108
+ _classPrivateFieldSet(this, _mergedCellsGetter, mergedCellsGetter);
109
+ _classPrivateFieldSet(this, _rowIndexMapper, rowIndexMapper);
110
+ _classPrivateFieldSet(this, _columnIndexMapper, columnIndexMapper);
111
+ }
112
+
113
+ /**
114
+ * Gets the currently selected node data from the vertical focus order list.
115
+ *
116
+ * @returns {NodeStructure}
117
+ */
118
+ getCurrentVerticalNode() {
119
+ return _classPrivateFieldGet(this, _currentVerticalLinkedNode).data;
120
+ }
121
+
122
+ /**
123
+ * Gets the first node data from the vertical focus order list.
124
+ *
125
+ * @returns {NodeStructure}
126
+ */
127
+ getFirstVerticalNode() {
128
+ return _classPrivateFieldGet(this, _cellsVerticalOrder).first.data;
129
+ }
130
+
131
+ /**
132
+ * Gets the next selected node data from the vertical focus order list.
133
+ *
134
+ * @returns {NodeStructure}
135
+ */
136
+ getNextVerticalNode() {
137
+ return _classPrivateFieldGet(this, _currentVerticalLinkedNode).next.data;
138
+ }
139
+
140
+ /**
141
+ * Gets the previous selected node data from the vertical focus order list.
142
+ *
143
+ * @returns {NodeStructure}
144
+ */
145
+ getPrevVerticalNode() {
146
+ return _classPrivateFieldGet(this, _currentVerticalLinkedNode).prev.data;
147
+ }
148
+
149
+ /**
150
+ * Gets the currently selected node data from the horizontal focus order list.
151
+ *
152
+ * @returns {NodeStructure}
153
+ */
154
+ getCurrentHorizontalNode() {
155
+ return _classPrivateFieldGet(this, _currentHorizontalLinkedNode).data;
156
+ }
157
+
158
+ /**
159
+ * Gets the first node data from the horizontal focus order list.
160
+ *
161
+ * @returns {NodeStructure}
162
+ */
163
+ getFirstHorizontalNode() {
164
+ return _classPrivateFieldGet(this, _cellsHorizontalOrder).first.data;
165
+ }
166
+
167
+ /**
168
+ * Gets the next selected node data from the horizontal focus order list.
169
+ *
170
+ * @returns {NodeStructure}
171
+ */
172
+ getNextHorizontalNode() {
173
+ return _classPrivateFieldGet(this, _currentHorizontalLinkedNode).next.data;
174
+ }
175
+
176
+ /**
177
+ * Gets the previous selected node data from the horizontal focus order list.
178
+ *
179
+ * @returns {NodeStructure}
180
+ */
181
+ getPrevHorizontalNode() {
182
+ return _classPrivateFieldGet(this, _currentHorizontalLinkedNode).prev.data;
183
+ }
184
+
185
+ /**
186
+ * Sets the previous node from the vertical focus order list as active.
187
+ */
188
+ setPrevNodeAsActive() {
189
+ _classPrivateFieldSet(this, _currentVerticalLinkedNode, _classPrivateFieldGet(this, _currentVerticalLinkedNode).prev);
190
+ _classPrivateFieldSet(this, _currentHorizontalLinkedNode, _classPrivateFieldGet(this, _currentHorizontalLinkedNode).prev);
191
+ }
192
+
193
+ /**
194
+ * Sets the previous node from the horizontal focus order list as active.
195
+ */
196
+ setNextNodeAsActive() {
197
+ _classPrivateFieldSet(this, _currentVerticalLinkedNode, _classPrivateFieldGet(this, _currentVerticalLinkedNode).next);
198
+ _classPrivateFieldSet(this, _currentHorizontalLinkedNode, _classPrivateFieldGet(this, _currentHorizontalLinkedNode).next);
199
+ }
200
+
201
+ /**
202
+ * Rebuilds the focus order list based on the provided selection.
203
+ *
204
+ * @param {CellRange} selectedRange The selected range to build the focus order for.
205
+ */
206
+ buildFocusOrder(selectedRange) {
207
+ const topStart = selectedRange.getTopStartCorner();
208
+ const bottomEnd = selectedRange.getBottomEndCorner();
209
+ const visitedHorizontalCells = new WeakSet();
210
+ _classPrivateFieldSet(this, _cellsHorizontalOrder, new LinkedList());
211
+ for (let r = topStart.row; r <= bottomEnd.row; r++) {
212
+ if (_classPrivateFieldGet(this, _rowIndexMapper).isHidden(r)) {
213
+ // eslint-disable-next-line no-continue
214
+ continue;
215
+ }
216
+ for (let c = topStart.col; c <= bottomEnd.col; c++) {
217
+ if (_classPrivateFieldGet(this, _columnIndexMapper).isHidden(c)) {
218
+ // eslint-disable-next-line no-continue
219
+ continue;
220
+ }
221
+ const node = _classPrivateMethodGet(this, _pushOrderNode, _pushOrderNode2).call(this, selectedRange, _classPrivateFieldGet(this, _cellsHorizontalOrder), visitedHorizontalCells, r, c);
222
+ if (node) {
223
+ _classPrivateFieldSet(this, _currentHorizontalLinkedNode, node);
224
+ }
225
+ }
226
+ }
227
+
228
+ // create circular linked list
229
+ if (_classPrivateFieldGet(this, _cellsHorizontalOrder).first) {
230
+ _classPrivateFieldGet(this, _cellsHorizontalOrder).first.prev = _classPrivateFieldGet(this, _cellsHorizontalOrder).last;
231
+ _classPrivateFieldGet(this, _cellsHorizontalOrder).last.next = _classPrivateFieldGet(this, _cellsHorizontalOrder).first;
232
+ }
233
+ const visitedVerticalCells = new WeakSet();
234
+ _classPrivateFieldSet(this, _cellsVerticalOrder, new LinkedList());
235
+ for (let c = topStart.col; c <= bottomEnd.col; c++) {
236
+ if (_classPrivateFieldGet(this, _columnIndexMapper).isHidden(c)) {
237
+ // eslint-disable-next-line no-continue
238
+ continue;
239
+ }
240
+ for (let r = topStart.row; r <= bottomEnd.row; r++) {
241
+ if (_classPrivateFieldGet(this, _rowIndexMapper).isHidden(r)) {
242
+ // eslint-disable-next-line no-continue
243
+ continue;
244
+ }
245
+ const node = _classPrivateMethodGet(this, _pushOrderNode, _pushOrderNode2).call(this, selectedRange, _classPrivateFieldGet(this, _cellsVerticalOrder), visitedVerticalCells, r, c);
246
+ if (node) {
247
+ _classPrivateFieldSet(this, _currentVerticalLinkedNode, node);
248
+ }
249
+ }
250
+ }
251
+
252
+ // create circular linked list
253
+ if (_classPrivateFieldGet(this, _cellsVerticalOrder).first) {
254
+ _classPrivateFieldGet(this, _cellsVerticalOrder).first.prev = _classPrivateFieldGet(this, _cellsVerticalOrder).last;
255
+ _classPrivateFieldGet(this, _cellsVerticalOrder).last.next = _classPrivateFieldGet(this, _cellsVerticalOrder).first;
256
+ }
257
+ }
258
+ /**
259
+ * Sets the active node based on the provided row and column.
260
+ *
261
+ * @param {number} row The visual row index.
262
+ * @param {number} column The visual column index.
263
+ * @returns {FocusOrder}
264
+ */
265
+ setActiveNode(row, column) {
266
+ _classPrivateFieldGet(this, _cellsHorizontalOrder).inorder(node => {
267
+ const {
268
+ rowStart,
269
+ rowEnd,
270
+ colStart,
271
+ colEnd
272
+ } = node.data;
273
+ if (row >= rowStart && row <= rowEnd && column >= colStart && column <= colEnd) {
274
+ _classPrivateFieldSet(this, _currentHorizontalLinkedNode, node);
275
+ return false;
276
+ }
277
+ });
278
+ _classPrivateFieldGet(this, _cellsVerticalOrder).inorder(node => {
279
+ const {
280
+ rowStart,
281
+ rowEnd,
282
+ colStart,
283
+ colEnd
284
+ } = node.data;
285
+ if (row >= rowStart && row <= rowEnd && column >= colStart && column <= colEnd) {
286
+ _classPrivateFieldSet(this, _currentVerticalLinkedNode, node);
287
+ return false;
288
+ }
289
+ });
290
+ return this;
291
+ }
292
+ }
293
+ function _pushOrderNode2(selectedRange, listOrder, mergeCellsVisitor, row, column) {
294
+ const topStart = selectedRange.getTopStartCorner();
295
+ const bottomEnd = selectedRange.getBottomEndCorner();
296
+ const highlight = selectedRange.highlight.clone().normalize();
297
+ const mergeParent = _classPrivateFieldGet(this, _mergedCellsGetter).call(this, row, column);
298
+ if (mergeParent && mergeCellsVisitor.has(mergeParent)) {
299
+ return null;
300
+ }
301
+ const node = {
302
+ colStart: column,
303
+ colEnd: column,
304
+ rowStart: row,
305
+ rowEnd: row
306
+ };
307
+ if (mergeParent) {
308
+ mergeCellsVisitor.add(mergeParent);
309
+ if (mergeParent.row < topStart.row || mergeParent.row + mergeParent.rowspan - 1 > bottomEnd.row || mergeParent.col < topStart.col || mergeParent.col + mergeParent.colspan - 1 > bottomEnd.col) {
310
+ return null;
311
+ }
312
+ node.colStart = mergeParent.col;
313
+ node.colEnd = mergeParent.col + mergeParent.colspan - 1;
314
+ node.rowStart = mergeParent.row;
315
+ node.rowEnd = mergeParent.row + mergeParent.rowspan - 1;
316
+ }
317
+ const linkedNode = listOrder.push(node);
318
+ if (row === highlight.row && column === highlight.col || mergeParent && highlight.row >= mergeParent.row && highlight.row <= mergeParent.row + mergeParent.rowspan - 1 && highlight.col >= mergeParent.col && highlight.col <= mergeParent.col + mergeParent.colspan - 1) {
319
+ return linkedNode;
320
+ }
321
+ return null;
322
+ }