handsontable 0.0.0-next-bfb0e3a-20240403 → 0.0.0-next-5a535ed-20240403

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 (280) hide show
  1. package/3rdparty/walkontable/src/calculator/viewportColumns.js +17 -12
  2. package/3rdparty/walkontable/src/calculator/viewportColumns.mjs +17 -12
  3. package/3rdparty/walkontable/src/calculator/viewportRows.js +15 -10
  4. package/3rdparty/walkontable/src/calculator/viewportRows.mjs +15 -10
  5. package/3rdparty/walkontable/src/cell/coords.js +17 -12
  6. package/3rdparty/walkontable/src/cell/coords.mjs +17 -12
  7. package/3rdparty/walkontable/src/cell/range.d.ts +1 -2
  8. package/3rdparty/walkontable/src/cell/range.js +28 -40
  9. package/3rdparty/walkontable/src/cell/range.mjs +28 -40
  10. package/3rdparty/walkontable/src/core/_base.js +1 -1
  11. package/3rdparty/walkontable/src/core/_base.mjs +1 -1
  12. package/3rdparty/walkontable/src/event.js +104 -72
  13. package/3rdparty/walkontable/src/event.mjs +104 -72
  14. package/3rdparty/walkontable/src/overlays.js +1 -1
  15. package/3rdparty/walkontable/src/overlays.mjs +1 -1
  16. package/3rdparty/walkontable/src/scroll.js +17 -15
  17. package/3rdparty/walkontable/src/scroll.mjs +17 -15
  18. package/3rdparty/walkontable/src/selection/manager.js +69 -48
  19. package/3rdparty/walkontable/src/selection/manager.mjs +69 -48
  20. package/3rdparty/walkontable/src/selection/scanner.js +42 -33
  21. package/3rdparty/walkontable/src/selection/scanner.mjs +42 -33
  22. package/3rdparty/walkontable/src/utils/columnStretching.js +44 -27
  23. package/3rdparty/walkontable/src/utils/columnStretching.mjs +44 -27
  24. package/3rdparty/walkontable/src/utils/orderView/view.js +1 -1
  25. package/3rdparty/walkontable/src/utils/orderView/view.mjs +1 -1
  26. package/base.js +2 -2
  27. package/base.mjs +2 -2
  28. package/core/viewportScroll/index.js +1 -4
  29. package/core/viewportScroll/index.mjs +1 -4
  30. package/core.d.ts +3 -4
  31. package/core.js +22 -77
  32. package/core.mjs +22 -77
  33. package/dataMap/dataSource.js +1 -1
  34. package/dataMap/dataSource.mjs +1 -1
  35. package/dataMap/metaManager/metaLayers/cellMeta.js +1 -1
  36. package/dataMap/metaManager/metaLayers/cellMeta.mjs +1 -1
  37. package/dataMap/metaManager/metaSchema.js +1 -1
  38. package/dataMap/metaManager/metaSchema.mjs +1 -1
  39. package/dataMap/replaceData.js +1 -1
  40. package/dataMap/replaceData.mjs +1 -1
  41. package/dist/handsontable.css +4 -4
  42. package/dist/handsontable.full.css +4 -4
  43. package/dist/handsontable.full.js +9117 -8969
  44. package/dist/handsontable.full.min.css +3 -3
  45. package/dist/handsontable.full.min.js +292 -292
  46. package/dist/handsontable.js +6569 -6874
  47. package/dist/handsontable.min.css +3 -3
  48. package/dist/handsontable.min.js +25 -25
  49. package/dist/languages/all.min.js +1 -1
  50. package/dist/languages/ar-AR.min.js +1 -1
  51. package/dist/languages/cs-CZ.min.js +1 -1
  52. package/dist/languages/de-CH.min.js +1 -1
  53. package/dist/languages/de-DE.min.js +1 -1
  54. package/dist/languages/en-US.min.js +1 -1
  55. package/dist/languages/es-MX.min.js +1 -1
  56. package/dist/languages/fr-FR.min.js +1 -1
  57. package/dist/languages/hr-HR.min.js +1 -1
  58. package/dist/languages/it-IT.min.js +1 -1
  59. package/dist/languages/ja-JP.min.js +1 -1
  60. package/dist/languages/ko-KR.min.js +1 -1
  61. package/dist/languages/lv-LV.min.js +1 -1
  62. package/dist/languages/nb-NO.min.js +1 -1
  63. package/dist/languages/nl-NL.min.js +1 -1
  64. package/dist/languages/pl-PL.min.js +1 -1
  65. package/dist/languages/pt-BR.min.js +1 -1
  66. package/dist/languages/ru-RU.min.js +1 -1
  67. package/dist/languages/sr-SP.min.js +1 -1
  68. package/dist/languages/zh-CN.min.js +1 -1
  69. package/dist/languages/zh-TW.min.js +1 -1
  70. package/editorManager.js +23 -25
  71. package/editorManager.mjs +23 -25
  72. package/editors/autocompleteEditor/autocompleteEditor.js +10 -6
  73. package/editors/autocompleteEditor/autocompleteEditor.mjs +10 -6
  74. package/editors/selectEditor/selectEditor.js +19 -20
  75. package/editors/selectEditor/selectEditor.mjs +19 -20
  76. package/eventManager.js +1 -1
  77. package/eventManager.mjs +1 -1
  78. package/focusManager.js +82 -64
  79. package/focusManager.mjs +82 -64
  80. package/helpers/dom/element.js +1 -1
  81. package/helpers/dom/element.mjs +1 -1
  82. package/helpers/mixed.js +1 -1
  83. package/helpers/mixed.mjs +1 -1
  84. package/helpers/object.js +2 -2
  85. package/helpers/object.mjs +2 -2
  86. package/index.d.ts +0 -10
  87. package/package.json +2 -7
  88. package/pluginHooks.d.ts +3 -4
  89. package/pluginHooks.js +38 -99
  90. package/pluginHooks.mjs +38 -99
  91. package/plugins/autoColumnSize/autoColumnSize.js +65 -49
  92. package/plugins/autoColumnSize/autoColumnSize.mjs +65 -49
  93. package/plugins/autoRowSize/autoRowSize.js +34 -28
  94. package/plugins/autoRowSize/autoRowSize.mjs +34 -28
  95. package/plugins/autofill/autofill.js +38 -30
  96. package/plugins/autofill/autofill.mjs +38 -30
  97. package/plugins/base/base.js +17 -12
  98. package/plugins/base/base.mjs +17 -12
  99. package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.js +5 -5
  100. package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.mjs +5 -5
  101. package/plugins/collapsibleColumns/collapsibleColumns.js +50 -59
  102. package/plugins/collapsibleColumns/collapsibleColumns.mjs +50 -59
  103. package/plugins/columnSorting/columnSorting.js +45 -49
  104. package/plugins/columnSorting/columnSorting.mjs +45 -49
  105. package/plugins/columnSummary/columnSummary.js +26 -22
  106. package/plugins/columnSummary/columnSummary.mjs +26 -22
  107. package/plugins/comments/comments.js +158 -116
  108. package/plugins/comments/comments.mjs +158 -116
  109. package/plugins/contextMenu/contextMenu.js +26 -20
  110. package/plugins/contextMenu/contextMenu.mjs +26 -20
  111. package/plugins/contextMenu/itemsFactory.js +1 -1
  112. package/plugins/contextMenu/itemsFactory.mjs +1 -1
  113. package/plugins/contextMenu/menu/defaultShortcutsList.js +10 -26
  114. package/plugins/contextMenu/menu/defaultShortcutsList.mjs +10 -26
  115. package/plugins/contextMenu/menu/menu.js +21 -13
  116. package/plugins/contextMenu/menu/menu.mjs +21 -13
  117. package/plugins/contextMenu/menu/positioner.js +58 -41
  118. package/plugins/contextMenu/menu/positioner.mjs +58 -41
  119. package/plugins/copyPaste/copyPaste.js +157 -116
  120. package/plugins/copyPaste/copyPaste.mjs +157 -116
  121. package/plugins/copyPaste/copyableRanges.js +66 -43
  122. package/plugins/copyPaste/copyableRanges.mjs +66 -43
  123. package/plugins/customBorders/customBorders.js +13 -11
  124. package/plugins/customBorders/customBorders.mjs +13 -11
  125. package/plugins/dragToScroll/dragToScroll.js +6 -6
  126. package/plugins/dragToScroll/dragToScroll.mjs +6 -6
  127. package/plugins/dropdownMenu/dropdownMenu.js +106 -80
  128. package/plugins/dropdownMenu/dropdownMenu.mjs +106 -80
  129. package/plugins/exportFile/dataProvider.js +1 -1
  130. package/plugins/exportFile/dataProvider.mjs +1 -1
  131. package/plugins/filters/component/actionBar.js +9 -9
  132. package/plugins/filters/component/actionBar.mjs +8 -8
  133. package/plugins/filters/component/condition.js +15 -13
  134. package/plugins/filters/component/condition.mjs +15 -13
  135. package/plugins/filters/component/operators.js +6 -6
  136. package/plugins/filters/component/operators.mjs +6 -6
  137. package/plugins/filters/component/value.js +28 -24
  138. package/plugins/filters/component/value.mjs +28 -24
  139. package/plugins/filters/conditionUpdateObserver.js +24 -22
  140. package/plugins/filters/conditionUpdateObserver.mjs +24 -22
  141. package/plugins/filters/dataFilter.js +1 -1
  142. package/plugins/filters/dataFilter.mjs +1 -1
  143. package/plugins/filters/filters.js +95 -81
  144. package/plugins/filters/filters.mjs +95 -81
  145. package/plugins/filters/ui/input.js +19 -13
  146. package/plugins/filters/ui/input.mjs +19 -13
  147. package/plugins/filters/ui/link.js +13 -8
  148. package/plugins/filters/ui/link.mjs +13 -8
  149. package/plugins/filters/ui/multipleSelect.js +112 -85
  150. package/plugins/filters/ui/multipleSelect.mjs +112 -85
  151. package/plugins/filters/ui/radioInput.js +20 -12
  152. package/plugins/filters/ui/radioInput.mjs +20 -12
  153. package/plugins/filters/ui/select.js +72 -50
  154. package/plugins/filters/ui/select.mjs +71 -49
  155. package/plugins/formulas/formulas.js +326 -268
  156. package/plugins/formulas/formulas.mjs +327 -269
  157. package/plugins/formulas/indexSyncer/axisSyncer.js +61 -38
  158. package/plugins/formulas/indexSyncer/axisSyncer.mjs +61 -38
  159. package/plugins/formulas/indexSyncer/index.js +48 -25
  160. package/plugins/formulas/indexSyncer/index.mjs +48 -25
  161. package/plugins/hiddenColumns/hiddenColumns.js +83 -64
  162. package/plugins/hiddenColumns/hiddenColumns.mjs +83 -64
  163. package/plugins/hiddenRows/hiddenRows.js +82 -63
  164. package/plugins/hiddenRows/hiddenRows.mjs +82 -63
  165. package/plugins/manualColumnFreeze/manualColumnFreeze.js +32 -24
  166. package/plugins/manualColumnFreeze/manualColumnFreeze.mjs +33 -25
  167. package/plugins/manualColumnMove/manualColumnMove.js +170 -126
  168. package/plugins/manualColumnMove/manualColumnMove.mjs +170 -126
  169. package/plugins/manualColumnResize/manualColumnResize.js +230 -169
  170. package/plugins/manualColumnResize/manualColumnResize.mjs +230 -169
  171. package/plugins/manualRowMove/manualRowMove.js +128 -99
  172. package/plugins/manualRowMove/manualRowMove.mjs +128 -99
  173. package/plugins/manualRowResize/manualRowResize.js +209 -150
  174. package/plugins/manualRowResize/manualRowResize.mjs +209 -150
  175. package/plugins/mergeCells/calculations/selection.js +71 -2
  176. package/plugins/mergeCells/calculations/selection.mjs +71 -2
  177. package/plugins/mergeCells/cellsCollection.js +1 -117
  178. package/plugins/mergeCells/cellsCollection.mjs +1 -117
  179. package/plugins/mergeCells/contextMenuItem/toggleMerge.js +1 -11
  180. package/plugins/mergeCells/contextMenuItem/toggleMerge.mjs +1 -11
  181. package/plugins/mergeCells/mergeCells.js +397 -499
  182. package/plugins/mergeCells/mergeCells.mjs +397 -499
  183. package/plugins/multiColumnSorting/multiColumnSorting.js +2 -8
  184. package/plugins/multiColumnSorting/multiColumnSorting.mjs +2 -8
  185. package/plugins/multipleSelectionHandles/multipleSelectionHandles.js +1 -1
  186. package/plugins/multipleSelectionHandles/multipleSelectionHandles.mjs +1 -1
  187. package/plugins/nestedHeaders/nestedHeaders.js +253 -205
  188. package/plugins/nestedHeaders/nestedHeaders.mjs +254 -206
  189. package/plugins/nestedHeaders/stateManager/headersTree.js +32 -21
  190. package/plugins/nestedHeaders/stateManager/headersTree.mjs +32 -21
  191. package/plugins/nestedHeaders/stateManager/index.js +41 -30
  192. package/plugins/nestedHeaders/stateManager/index.mjs +41 -30
  193. package/plugins/nestedHeaders/stateManager/sourceSettings.js +30 -19
  194. package/plugins/nestedHeaders/stateManager/sourceSettings.mjs +30 -19
  195. package/plugins/nestedRows/data/dataManager.js +1 -1
  196. package/plugins/nestedRows/data/dataManager.mjs +1 -1
  197. package/plugins/nestedRows/nestedRows.js +182 -151
  198. package/plugins/nestedRows/nestedRows.mjs +183 -152
  199. package/plugins/nestedRows/ui/contextMenu.js +15 -11
  200. package/plugins/nestedRows/ui/contextMenu.mjs +14 -10
  201. package/plugins/nestedRows/utils/rowMoveController.js +1 -1
  202. package/plugins/nestedRows/utils/rowMoveController.mjs +1 -1
  203. package/plugins/persistentState/storage.js +2 -2
  204. package/plugins/persistentState/storage.mjs +2 -2
  205. package/plugins/search/search.js +7 -7
  206. package/plugins/search/search.mjs +7 -7
  207. package/plugins/touchScroll/touchScroll.js +19 -15
  208. package/plugins/touchScroll/touchScroll.mjs +20 -16
  209. package/plugins/trimRows/trimRows.js +6 -6
  210. package/plugins/trimRows/trimRows.mjs +6 -6
  211. package/renderers/checkboxRenderer/checkboxRenderer.js +5 -8
  212. package/renderers/checkboxRenderer/checkboxRenderer.mjs +5 -8
  213. package/selection/highlight/highlight.js +14 -14
  214. package/selection/highlight/highlight.mjs +13 -13
  215. package/selection/highlight/visualSelection.js +0 -2
  216. package/selection/highlight/visualSelection.mjs +0 -2
  217. package/selection/selection.js +67 -225
  218. package/selection/selection.mjs +66 -224
  219. package/selection/transformation.js +118 -149
  220. package/selection/transformation.mjs +118 -149
  221. package/shortcutContexts/commands/editor/closeAndSave.js +2 -2
  222. package/shortcutContexts/commands/editor/closeAndSave.mjs +2 -2
  223. package/shortcutContexts/commands/editor/open.js +3 -18
  224. package/shortcutContexts/commands/editor/open.mjs +3 -18
  225. package/shortcutContexts/commands/extendCellsSelection/down.js +1 -1
  226. package/shortcutContexts/commands/extendCellsSelection/down.mjs +1 -1
  227. package/shortcutContexts/commands/extendCellsSelection/left.js +1 -1
  228. package/shortcutContexts/commands/extendCellsSelection/left.mjs +1 -1
  229. package/shortcutContexts/commands/extendCellsSelection/right.js +1 -1
  230. package/shortcutContexts/commands/extendCellsSelection/right.mjs +1 -1
  231. package/shortcutContexts/commands/extendCellsSelection/toColumns.js +1 -1
  232. package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +1 -1
  233. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +1 -3
  234. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +1 -3
  235. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +3 -9
  236. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +3 -9
  237. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +3 -10
  238. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +3 -10
  239. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +1 -3
  240. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +1 -3
  241. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +1 -3
  242. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +1 -3
  243. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +1 -3
  244. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +1 -3
  245. package/shortcutContexts/commands/extendCellsSelection/toRows.js +1 -1
  246. package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +1 -1
  247. package/shortcutContexts/commands/extendCellsSelection/up.js +1 -1
  248. package/shortcutContexts/commands/extendCellsSelection/up.mjs +1 -1
  249. package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +1 -6
  250. package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +1 -6
  251. package/shortcutContexts/commands/moveCellSelection/inlineStart.js +1 -6
  252. package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +1 -6
  253. package/shortcutContexts/grid.js +3 -9
  254. package/shortcutContexts/grid.mjs +3 -9
  255. package/shortcuts/context.js +1 -2
  256. package/shortcuts/context.mjs +1 -2
  257. package/tableView.js +78 -52
  258. package/tableView.mjs +78 -52
  259. package/translations/changesObservable/observable.js +38 -21
  260. package/translations/changesObservable/observable.mjs +38 -21
  261. package/translations/changesObservable/observer.js +12 -7
  262. package/translations/changesObservable/observer.mjs +11 -6
  263. package/translations/mapCollections/aggregatedCollection.js +1 -1
  264. package/translations/mapCollections/aggregatedCollection.mjs +1 -1
  265. package/translations/maps/indexMap.js +1 -1
  266. package/translations/maps/indexMap.mjs +1 -1
  267. package/utils/dataStructures/linkedList.js +1 -6
  268. package/utils/dataStructures/linkedList.mjs +1 -6
  269. package/utils/dataStructures/tree.js +1 -1
  270. package/utils/dataStructures/tree.mjs +1 -1
  271. package/utils/interval.js +44 -26
  272. package/utils/interval.mjs +44 -26
  273. package/core/viewportScroll/scrollStrategies/focusScroll.js +0 -15
  274. package/core/viewportScroll/scrollStrategies/focusScroll.mjs +0 -11
  275. package/i18n/languages/ar-AR.d.ts +0 -5
  276. package/i18n/languages/cs-CZ.d.ts +0 -5
  277. package/i18n/languages/hr-HR.d.ts +0 -5
  278. package/i18n/languages/sr-SP.d.ts +0 -5
  279. package/plugins/mergeCells/focusOrder.js +0 -305
  280. package/plugins/mergeCells/focusOrder.mjs +0 -300
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- require("core-js/modules/es.error.cause.js");
5
4
  require("core-js/modules/es.array.push.js");
5
+ require("core-js/modules/es.error.cause.js");
6
6
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
7
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
8
8
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -36,6 +36,74 @@ class SelectionCalculations {
36
36
  this.hot = plugin.hot;
37
37
  }
38
38
 
39
+ /**
40
+ * "Snap" the delta value according to defined merged cells. (In other words, compensate the rowspan -
41
+ * e.g. Going up with `delta.row = -1` over a merged cell with `rowspan = 3`, `delta.row` should change to `-3`.).
42
+ *
43
+ * @param {object} delta The delta object containing `row` and `col` properties.
44
+ * @param {CellRange} selectionRange The selection range.
45
+ * @param {object} mergedCell A merged cell object.
46
+ */
47
+ snapDelta(delta, selectionRange, mergedCell) {
48
+ const cellCoords = selectionRange.to;
49
+ const newRow = cellCoords.row + delta.row;
50
+ const newColumn = cellCoords.col + delta.col;
51
+ if (delta.row) {
52
+ this.jumpOverMergedCell(delta, mergedCell, newRow);
53
+ } else if (delta.col) {
54
+ this.jumpOverMergedCell(delta, mergedCell, newColumn);
55
+ }
56
+ }
57
+
58
+ /**
59
+ * "Jump" over the merged cell (compensate for the indexes within the merged cell to get past it).
60
+ *
61
+ * @private
62
+ * @param {object} delta The delta object.
63
+ * @param {MergedCellCoords} mergedCell The merge cell object.
64
+ * @param {number} newIndex New row/column index, created with the delta.
65
+ */
66
+ jumpOverMergedCell(delta, mergedCell, newIndex) {
67
+ let flatDelta = delta.row || delta.col;
68
+ let includesIndex = null;
69
+ let firstIndex = null;
70
+ let lastIndex = null;
71
+ if (delta.row) {
72
+ includesIndex = mergedCell.includesVertically(newIndex);
73
+ firstIndex = mergedCell.row;
74
+ lastIndex = mergedCell.getLastRow();
75
+ } else if (delta.col) {
76
+ includesIndex = mergedCell.includesHorizontally(newIndex);
77
+ firstIndex = mergedCell.col;
78
+ lastIndex = mergedCell.getLastColumn();
79
+ }
80
+ if (flatDelta === 0) {
81
+ return;
82
+ } else if (flatDelta > 0) {
83
+ if (includesIndex && newIndex !== firstIndex) {
84
+ flatDelta += lastIndex - newIndex + 1;
85
+ }
86
+ } else if (includesIndex && newIndex !== lastIndex) {
87
+ flatDelta -= newIndex - firstIndex + 1;
88
+ }
89
+ if (delta.row) {
90
+ delta.row = flatDelta;
91
+ } else if (delta.col) {
92
+ delta.col = flatDelta;
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Get a selection range with `to` property incremented by the provided delta.
98
+ *
99
+ * @param {CellRange} oldSelectionRange The base selection range.
100
+ * @param {object} delta The delta object with `row` and `col` properties.
101
+ * @returns {CellRange} A new `CellRange` object.
102
+ */
103
+ getUpdatedSelectionRange(oldSelectionRange, delta) {
104
+ return this.hot._createCellRange(oldSelectionRange.highlight, oldSelectionRange.from, this.hot._createCellCoords(oldSelectionRange.to.row + delta.row, oldSelectionRange.to.col + delta.col));
105
+ }
106
+
39
107
  /**
40
108
  * Generate an additional class name for the entirely-selected merged cells.
41
109
  *
@@ -68,7 +136,8 @@ class SelectionCalculations {
68
136
  const fullMergeAreaWithinSelection = startRow <= mergedCell.row && startColumn <= mergedCell.col && endRow >= mergeRowEnd && endColumn >= mergeColumnEnd;
69
137
  if (fullMergeAreaWithinSelection) {
70
138
  return `${this.fullySelectedMergedCellClassName}-${layerLevel}`;
71
- } else if (this.isMergeCellFullySelected(mergedCell, this.plugin.hot.getSelectedRange())) {
139
+ } else if (this.plugin.selectionCalculations.isMergeCellFullySelected(mergedCell, this.plugin.hot.getSelectedRange())) {
140
+ // eslint-disable-line max-len
72
141
  return `${this.fullySelectedMergedCellClassName}-multiple`;
73
142
  }
74
143
  }
@@ -1,5 +1,5 @@
1
- import "core-js/modules/es.error.cause.js";
2
1
  import "core-js/modules/es.array.push.js";
2
+ import "core-js/modules/es.error.cause.js";
3
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
4
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
5
5
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -33,6 +33,74 @@ class SelectionCalculations {
33
33
  this.hot = plugin.hot;
34
34
  }
35
35
 
36
+ /**
37
+ * "Snap" the delta value according to defined merged cells. (In other words, compensate the rowspan -
38
+ * e.g. Going up with `delta.row = -1` over a merged cell with `rowspan = 3`, `delta.row` should change to `-3`.).
39
+ *
40
+ * @param {object} delta The delta object containing `row` and `col` properties.
41
+ * @param {CellRange} selectionRange The selection range.
42
+ * @param {object} mergedCell A merged cell object.
43
+ */
44
+ snapDelta(delta, selectionRange, mergedCell) {
45
+ const cellCoords = selectionRange.to;
46
+ const newRow = cellCoords.row + delta.row;
47
+ const newColumn = cellCoords.col + delta.col;
48
+ if (delta.row) {
49
+ this.jumpOverMergedCell(delta, mergedCell, newRow);
50
+ } else if (delta.col) {
51
+ this.jumpOverMergedCell(delta, mergedCell, newColumn);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * "Jump" over the merged cell (compensate for the indexes within the merged cell to get past it).
57
+ *
58
+ * @private
59
+ * @param {object} delta The delta object.
60
+ * @param {MergedCellCoords} mergedCell The merge cell object.
61
+ * @param {number} newIndex New row/column index, created with the delta.
62
+ */
63
+ jumpOverMergedCell(delta, mergedCell, newIndex) {
64
+ let flatDelta = delta.row || delta.col;
65
+ let includesIndex = null;
66
+ let firstIndex = null;
67
+ let lastIndex = null;
68
+ if (delta.row) {
69
+ includesIndex = mergedCell.includesVertically(newIndex);
70
+ firstIndex = mergedCell.row;
71
+ lastIndex = mergedCell.getLastRow();
72
+ } else if (delta.col) {
73
+ includesIndex = mergedCell.includesHorizontally(newIndex);
74
+ firstIndex = mergedCell.col;
75
+ lastIndex = mergedCell.getLastColumn();
76
+ }
77
+ if (flatDelta === 0) {
78
+ return;
79
+ } else if (flatDelta > 0) {
80
+ if (includesIndex && newIndex !== firstIndex) {
81
+ flatDelta += lastIndex - newIndex + 1;
82
+ }
83
+ } else if (includesIndex && newIndex !== lastIndex) {
84
+ flatDelta -= newIndex - firstIndex + 1;
85
+ }
86
+ if (delta.row) {
87
+ delta.row = flatDelta;
88
+ } else if (delta.col) {
89
+ delta.col = flatDelta;
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Get a selection range with `to` property incremented by the provided delta.
95
+ *
96
+ * @param {CellRange} oldSelectionRange The base selection range.
97
+ * @param {object} delta The delta object with `row` and `col` properties.
98
+ * @returns {CellRange} A new `CellRange` object.
99
+ */
100
+ getUpdatedSelectionRange(oldSelectionRange, delta) {
101
+ return this.hot._createCellRange(oldSelectionRange.highlight, oldSelectionRange.from, this.hot._createCellCoords(oldSelectionRange.to.row + delta.row, oldSelectionRange.to.col + delta.col));
102
+ }
103
+
36
104
  /**
37
105
  * Generate an additional class name for the entirely-selected merged cells.
38
106
  *
@@ -65,7 +133,8 @@ class SelectionCalculations {
65
133
  const fullMergeAreaWithinSelection = startRow <= mergedCell.row && startColumn <= mergedCell.col && endRow >= mergeRowEnd && endColumn >= mergeColumnEnd;
66
134
  if (fullMergeAreaWithinSelection) {
67
135
  return `${this.fullySelectedMergedCellClassName}-${layerLevel}`;
68
- } else if (this.isMergeCellFullySelected(mergedCell, this.plugin.hot.getSelectedRange())) {
136
+ } else if (this.plugin.selectionCalculations.isMergeCellFullySelected(mergedCell, this.plugin.hot.getSelectedRange())) {
137
+ // eslint-disable-line max-len
69
138
  return `${this.fullySelectedMergedCellClassName}-multiple`;
70
139
  }
71
140
  }
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- require("core-js/modules/es.error.cause.js");
5
4
  require("core-js/modules/es.array.push.js");
6
- require("core-js/modules/es.array.unscopables.flat-map.js");
5
+ require("core-js/modules/es.error.cause.js");
7
6
  var _cellCoords = _interopRequireDefault(require("./cellCoords"));
8
7
  var _number = require("../../helpers/number");
9
8
  var _console = require("../../helpers/console");
@@ -11,30 +10,17 @@ var _array = require("../../helpers/array");
11
10
  var _utils = require("./utils");
12
11
  var _templateLiteralTag = require("../../helpers/templateLiteralTag");
13
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
15
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
16
13
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
14
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
18
15
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
- function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
20
16
  /**
21
17
  * Defines a container object for the merged cells.
22
18
  *
23
19
  * @private
24
20
  * @class MergedCellsCollection
25
21
  */
26
- var _MergedCellsCollection_brand = /*#__PURE__*/new WeakSet();
27
22
  class MergedCellsCollection {
28
23
  constructor(mergeCellsPlugin) {
29
- /**
30
- * Gets the list of the indexes that do not intersect with other merged cells within the provided range.
31
- *
32
- * @param {CellRange} range The range to search within.
33
- * @param {'row' | 'col'} axis The axis to search within.
34
- * @param {number} scanDirection The direction to scan the range. `1` for forward, `-1` for backward.
35
- * @returns {number[]}
36
- */
37
- _classPrivateMethodInitSpec(this, _MergedCellsCollection_brand);
38
24
  /**
39
25
  * Reference to the Merge Cells plugin.
40
26
  *
@@ -273,81 +259,6 @@ class MergedCellsCollection {
273
259
  return this.hot._createCellCoords(firstRenderableRow, firstRenderableColumn);
274
260
  }
275
261
 
276
- /**
277
- * Gets the start-most visual column index that do not intersect with other merged cells within the provided range.
278
- *
279
- * @param {CellRange} range The range to search within.
280
- * @param {number} visualColumnIndex The visual column index to start the search from.
281
- * @returns {number}
282
- */
283
- getStartMostColumnIndex(range, visualColumnIndex) {
284
- const indexes = _assertClassBrand(_MergedCellsCollection_brand, this, _getNonIntersectingIndexes).call(this, range, 'col', -1);
285
- let startMostIndex = visualColumnIndex;
286
- for (let i = 0; i < indexes.length; i++) {
287
- if (indexes[i] <= visualColumnIndex) {
288
- startMostIndex = indexes[i];
289
- break;
290
- }
291
- }
292
- return startMostIndex;
293
- }
294
-
295
- /**
296
- * Gets the end-most visual column index that do not intersect with other merged cells within the provided range.
297
- *
298
- * @param {CellRange} range The range to search within.
299
- * @param {number} visualColumnIndex The visual column index to start the search from.
300
- * @returns {number}
301
- */
302
- getEndMostColumnIndex(range, visualColumnIndex) {
303
- const indexes = _assertClassBrand(_MergedCellsCollection_brand, this, _getNonIntersectingIndexes).call(this, range, 'col', 1);
304
- let endMostIndex = visualColumnIndex;
305
- for (let i = 0; i < indexes.length; i++) {
306
- if (indexes[i] >= visualColumnIndex) {
307
- endMostIndex = indexes[i];
308
- break;
309
- }
310
- }
311
- return endMostIndex;
312
- }
313
-
314
- /**
315
- * Gets the top-most visual row index that do not intersect with other merged cells within the provided range.
316
- *
317
- * @param {CellRange} range The range to search within.
318
- * @param {number} visualRowIndex The visual row index to start the search from.
319
- * @returns {number}
320
- */
321
- getTopMostRowIndex(range, visualRowIndex) {
322
- const indexes = _assertClassBrand(_MergedCellsCollection_brand, this, _getNonIntersectingIndexes).call(this, range, 'row', -1);
323
- let topMostIndex = visualRowIndex;
324
- for (let i = 0; i < indexes.length; i++) {
325
- if (indexes[i] <= visualRowIndex) {
326
- topMostIndex = indexes[i];
327
- break;
328
- }
329
- }
330
- return topMostIndex;
331
- }
332
-
333
- /**
334
- * Gets the bottom-most visual row index that do not intersect with other merged cells within the provided range.
335
- *
336
- * @param {CellRange} range The range to search within.
337
- * @param {number} visualRowIndex The visual row index to start the search from.
338
- * @returns {number}
339
- */
340
- getBottomMostRowIndex(range, visualRowIndex) {
341
- const indexes = _assertClassBrand(_MergedCellsCollection_brand, this, _getNonIntersectingIndexes).call(this, range, 'row', 1);
342
- let bottomMostIndex = visualRowIndex;
343
- for (let i = 0; i < indexes.length; i++) {
344
- if (indexes[i] >= visualRowIndex) {
345
- bottomMostIndex = indexes[i];
346
- break;
347
- }
348
- }
349
- return bottomMostIndex;
350
- }
351
262
  /**
352
263
  * Shift the merged cell in the direction and by an offset defined in the arguments.
353
264
  *
@@ -383,31 +294,4 @@ class MergedCellsCollection {
383
294
  });
384
295
  }
385
296
  }
386
- function _getNonIntersectingIndexes(range, axis) {
387
- let scanDirection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
388
- const indexes = new Map();
389
- const from = scanDirection === 1 ? range.getTopStartCorner() : range.getBottomEndCorner();
390
- const to = scanDirection === 1 ? range.getBottomEndCorner() : range.getTopStartCorner();
391
- for (let row = from.row; scanDirection === 1 ? row <= to.row : row >= to.row; row += scanDirection) {
392
- for (let column = from.col; scanDirection === 1 ? column <= to.col : column >= to.col; column += scanDirection) {
393
- const index = axis === 'row' ? row : column;
394
- const mergedCell = this.get(row, column);
395
- let lastIndex = index;
396
- if (mergedCell) {
397
- lastIndex = scanDirection === 1 ? mergedCell[axis] + mergedCell[`${axis}span`] - 1 : mergedCell[axis];
398
- }
399
- if (!indexes.has(index)) {
400
- indexes.set(index, new Set());
401
- }
402
- indexes.get(index).add(lastIndex);
403
- }
404
- }
405
- return Array.from(new Set(Array.from(indexes.entries()).filter(_ref => {
406
- let [, set] = _ref;
407
- return set.size === 1;
408
- }).flatMap(_ref2 => {
409
- let [, set] = _ref2;
410
- return Array.from(set);
411
- })));
412
- }
413
297
  var _default = exports.default = MergedCellsCollection;
@@ -1,12 +1,8 @@
1
- import "core-js/modules/es.error.cause.js";
2
1
  import "core-js/modules/es.array.push.js";
3
- import "core-js/modules/es.array.unscopables.flat-map.js";
4
- function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
5
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
2
+ import "core-js/modules/es.error.cause.js";
6
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
4
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
8
5
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
- function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
10
6
  import MergedCellCoords from "./cellCoords.mjs";
11
7
  import { rangeEach, rangeEachReverse } from "../../helpers/number.mjs";
12
8
  import { warn } from "../../helpers/console.mjs";
@@ -19,18 +15,8 @@ import { toSingleLine } from "../../helpers/templateLiteralTag.mjs";
19
15
  * @private
20
16
  * @class MergedCellsCollection
21
17
  */
22
- var _MergedCellsCollection_brand = /*#__PURE__*/new WeakSet();
23
18
  class MergedCellsCollection {
24
19
  constructor(mergeCellsPlugin) {
25
- /**
26
- * Gets the list of the indexes that do not intersect with other merged cells within the provided range.
27
- *
28
- * @param {CellRange} range The range to search within.
29
- * @param {'row' | 'col'} axis The axis to search within.
30
- * @param {number} scanDirection The direction to scan the range. `1` for forward, `-1` for backward.
31
- * @returns {number[]}
32
- */
33
- _classPrivateMethodInitSpec(this, _MergedCellsCollection_brand);
34
20
  /**
35
21
  * Reference to the Merge Cells plugin.
36
22
  *
@@ -269,81 +255,6 @@ class MergedCellsCollection {
269
255
  return this.hot._createCellCoords(firstRenderableRow, firstRenderableColumn);
270
256
  }
271
257
 
272
- /**
273
- * Gets the start-most visual column index that do not intersect with other merged cells within the provided range.
274
- *
275
- * @param {CellRange} range The range to search within.
276
- * @param {number} visualColumnIndex The visual column index to start the search from.
277
- * @returns {number}
278
- */
279
- getStartMostColumnIndex(range, visualColumnIndex) {
280
- const indexes = _assertClassBrand(_MergedCellsCollection_brand, this, _getNonIntersectingIndexes).call(this, range, 'col', -1);
281
- let startMostIndex = visualColumnIndex;
282
- for (let i = 0; i < indexes.length; i++) {
283
- if (indexes[i] <= visualColumnIndex) {
284
- startMostIndex = indexes[i];
285
- break;
286
- }
287
- }
288
- return startMostIndex;
289
- }
290
-
291
- /**
292
- * Gets the end-most visual column index that do not intersect with other merged cells within the provided range.
293
- *
294
- * @param {CellRange} range The range to search within.
295
- * @param {number} visualColumnIndex The visual column index to start the search from.
296
- * @returns {number}
297
- */
298
- getEndMostColumnIndex(range, visualColumnIndex) {
299
- const indexes = _assertClassBrand(_MergedCellsCollection_brand, this, _getNonIntersectingIndexes).call(this, range, 'col', 1);
300
- let endMostIndex = visualColumnIndex;
301
- for (let i = 0; i < indexes.length; i++) {
302
- if (indexes[i] >= visualColumnIndex) {
303
- endMostIndex = indexes[i];
304
- break;
305
- }
306
- }
307
- return endMostIndex;
308
- }
309
-
310
- /**
311
- * Gets the top-most visual row index that do not intersect with other merged cells within the provided range.
312
- *
313
- * @param {CellRange} range The range to search within.
314
- * @param {number} visualRowIndex The visual row index to start the search from.
315
- * @returns {number}
316
- */
317
- getTopMostRowIndex(range, visualRowIndex) {
318
- const indexes = _assertClassBrand(_MergedCellsCollection_brand, this, _getNonIntersectingIndexes).call(this, range, 'row', -1);
319
- let topMostIndex = visualRowIndex;
320
- for (let i = 0; i < indexes.length; i++) {
321
- if (indexes[i] <= visualRowIndex) {
322
- topMostIndex = indexes[i];
323
- break;
324
- }
325
- }
326
- return topMostIndex;
327
- }
328
-
329
- /**
330
- * Gets the bottom-most visual row index that do not intersect with other merged cells within the provided range.
331
- *
332
- * @param {CellRange} range The range to search within.
333
- * @param {number} visualRowIndex The visual row index to start the search from.
334
- * @returns {number}
335
- */
336
- getBottomMostRowIndex(range, visualRowIndex) {
337
- const indexes = _assertClassBrand(_MergedCellsCollection_brand, this, _getNonIntersectingIndexes).call(this, range, 'row', 1);
338
- let bottomMostIndex = visualRowIndex;
339
- for (let i = 0; i < indexes.length; i++) {
340
- if (indexes[i] >= visualRowIndex) {
341
- bottomMostIndex = indexes[i];
342
- break;
343
- }
344
- }
345
- return bottomMostIndex;
346
- }
347
258
  /**
348
259
  * Shift the merged cell in the direction and by an offset defined in the arguments.
349
260
  *
@@ -379,31 +290,4 @@ class MergedCellsCollection {
379
290
  });
380
291
  }
381
292
  }
382
- function _getNonIntersectingIndexes(range, axis) {
383
- let scanDirection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
384
- const indexes = new Map();
385
- const from = scanDirection === 1 ? range.getTopStartCorner() : range.getBottomEndCorner();
386
- const to = scanDirection === 1 ? range.getBottomEndCorner() : range.getTopStartCorner();
387
- for (let row = from.row; scanDirection === 1 ? row <= to.row : row >= to.row; row += scanDirection) {
388
- for (let column = from.col; scanDirection === 1 ? column <= to.col : column >= to.col; column += scanDirection) {
389
- const index = axis === 'row' ? row : column;
390
- const mergedCell = this.get(row, column);
391
- let lastIndex = index;
392
- if (mergedCell) {
393
- lastIndex = scanDirection === 1 ? mergedCell[axis] + mergedCell[`${axis}span`] - 1 : mergedCell[axis];
394
- }
395
- if (!indexes.has(index)) {
396
- indexes.set(index, new Set());
397
- }
398
- indexes.get(index).add(lastIndex);
399
- }
400
- }
401
- return Array.from(new Set(Array.from(indexes.entries()).filter(_ref => {
402
- let [, set] = _ref;
403
- return set.size === 1;
404
- }).flatMap(_ref2 => {
405
- let [, set] = _ref2;
406
- return Array.from(set);
407
- })));
408
- }
409
293
  export default MergedCellsCollection;
@@ -25,17 +25,7 @@ function toggleMergeItem(plugin) {
25
25
  return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_MERGE_CELLS);
26
26
  },
27
27
  callback() {
28
- const currentRange = this.getSelectedRangeLast();
29
- if (!currentRange) {
30
- return;
31
- }
32
- currentRange.setDirection(this.isRtl() ? 'NE-SW' : 'NW-SE');
33
- const {
34
- from,
35
- to
36
- } = currentRange;
37
- plugin.toggleMerge(currentRange);
38
- this.selectCell(from.row, from.col, to.row, to.col, false);
28
+ plugin.toggleMergeOnSelection();
39
29
  },
40
30
  disabled() {
41
31
  const sel = this.getSelectedLast();
@@ -18,17 +18,7 @@ export default function toggleMergeItem(plugin) {
18
18
  return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_MERGE_CELLS);
19
19
  },
20
20
  callback() {
21
- const currentRange = this.getSelectedRangeLast();
22
- if (!currentRange) {
23
- return;
24
- }
25
- currentRange.setDirection(this.isRtl() ? 'NE-SW' : 'NW-SE');
26
- const {
27
- from,
28
- to
29
- } = currentRange;
30
- plugin.toggleMerge(currentRange);
31
- this.selectCell(from.row, from.col, to.row, to.col, false);
21
+ plugin.toggleMergeOnSelection();
32
22
  },
33
23
  disabled() {
34
24
  const sel = this.getSelectedLast();