handsontable 0.0.0-next-2becb78-20240313 → 0.0.0-next-bff5041-20240315

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 (272) hide show
  1. package/3rdparty/walkontable/src/calculator/viewportColumns.js +12 -17
  2. package/3rdparty/walkontable/src/calculator/viewportColumns.mjs +12 -17
  3. package/3rdparty/walkontable/src/calculator/viewportRows.js +10 -15
  4. package/3rdparty/walkontable/src/calculator/viewportRows.mjs +10 -15
  5. package/3rdparty/walkontable/src/cell/coords.js +12 -17
  6. package/3rdparty/walkontable/src/cell/coords.mjs +12 -17
  7. package/3rdparty/walkontable/src/cell/range.d.ts +0 -1
  8. package/3rdparty/walkontable/src/cell/range.js +23 -45
  9. package/3rdparty/walkontable/src/cell/range.mjs +23 -45
  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 +72 -104
  13. package/3rdparty/walkontable/src/event.mjs +72 -104
  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 +15 -17
  17. package/3rdparty/walkontable/src/scroll.mjs +15 -17
  18. package/3rdparty/walkontable/src/selection/manager.js +48 -69
  19. package/3rdparty/walkontable/src/selection/manager.mjs +48 -69
  20. package/3rdparty/walkontable/src/selection/scanner.js +33 -42
  21. package/3rdparty/walkontable/src/selection/scanner.mjs +33 -42
  22. package/3rdparty/walkontable/src/utils/columnStretching.js +27 -44
  23. package/3rdparty/walkontable/src/utils/columnStretching.mjs +27 -44
  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 -82
  32. package/core.mjs +22 -82
  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/replaceData.js +1 -1
  38. package/dataMap/replaceData.mjs +1 -1
  39. package/dist/handsontable.css +2 -2
  40. package/dist/handsontable.full.css +2 -2
  41. package/dist/handsontable.full.js +7619 -10404
  42. package/dist/handsontable.full.min.css +2 -2
  43. package/dist/handsontable.full.min.js +277 -277
  44. package/dist/handsontable.js +5525 -7857
  45. package/dist/handsontable.min.css +2 -2
  46. package/dist/handsontable.min.js +33 -33
  47. package/dist/languages/all.min.js +1 -1
  48. package/dist/languages/ar-AR.min.js +1 -1
  49. package/dist/languages/cs-CZ.min.js +1 -1
  50. package/dist/languages/de-CH.min.js +1 -1
  51. package/dist/languages/de-DE.min.js +1 -1
  52. package/dist/languages/en-US.min.js +1 -1
  53. package/dist/languages/es-MX.min.js +1 -1
  54. package/dist/languages/fr-FR.min.js +1 -1
  55. package/dist/languages/hr-HR.min.js +1 -1
  56. package/dist/languages/it-IT.min.js +1 -1
  57. package/dist/languages/ja-JP.min.js +1 -1
  58. package/dist/languages/ko-KR.min.js +1 -1
  59. package/dist/languages/lv-LV.min.js +1 -1
  60. package/dist/languages/nb-NO.min.js +1 -1
  61. package/dist/languages/nl-NL.min.js +1 -1
  62. package/dist/languages/pl-PL.min.js +1 -1
  63. package/dist/languages/pt-BR.min.js +1 -1
  64. package/dist/languages/ru-RU.min.js +1 -1
  65. package/dist/languages/sr-SP.min.js +1 -1
  66. package/dist/languages/zh-CN.min.js +1 -1
  67. package/dist/languages/zh-TW.min.js +1 -1
  68. package/editorManager.js +21 -27
  69. package/editorManager.mjs +21 -27
  70. package/editors/autocompleteEditor/autocompleteEditor.js +6 -10
  71. package/editors/autocompleteEditor/autocompleteEditor.mjs +6 -10
  72. package/eventManager.js +1 -1
  73. package/eventManager.mjs +1 -1
  74. package/focusManager.js +58 -82
  75. package/focusManager.mjs +58 -82
  76. package/helpers/dom/element.js +1 -1
  77. package/helpers/dom/element.mjs +1 -1
  78. package/helpers/mixed.js +1 -1
  79. package/helpers/mixed.mjs +1 -1
  80. package/helpers/object.js +2 -2
  81. package/helpers/object.mjs +2 -2
  82. package/index.d.ts +10 -0
  83. package/package.json +2 -1
  84. package/pluginHooks.d.ts +0 -4
  85. package/pluginHooks.js +2 -44
  86. package/pluginHooks.mjs +2 -44
  87. package/plugins/autoColumnSize/autoColumnSize.js +49 -65
  88. package/plugins/autoColumnSize/autoColumnSize.mjs +49 -65
  89. package/plugins/autoRowSize/autoRowSize.js +28 -34
  90. package/plugins/autoRowSize/autoRowSize.mjs +28 -34
  91. package/plugins/autofill/autofill.js +30 -38
  92. package/plugins/autofill/autofill.mjs +30 -38
  93. package/plugins/base/base.js +12 -17
  94. package/plugins/base/base.mjs +12 -17
  95. package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.js +5 -5
  96. package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.mjs +5 -5
  97. package/plugins/collapsibleColumns/collapsibleColumns.js +36 -54
  98. package/plugins/collapsibleColumns/collapsibleColumns.mjs +36 -54
  99. package/plugins/columnSorting/columnSorting.js +40 -46
  100. package/plugins/columnSorting/columnSorting.mjs +40 -46
  101. package/plugins/columnSummary/columnSummary.js +22 -26
  102. package/plugins/columnSummary/columnSummary.mjs +22 -26
  103. package/plugins/comments/comments.js +116 -158
  104. package/plugins/comments/comments.mjs +116 -158
  105. package/plugins/contextMenu/contextMenu.js +20 -26
  106. package/plugins/contextMenu/contextMenu.mjs +20 -26
  107. package/plugins/contextMenu/itemsFactory.js +1 -1
  108. package/plugins/contextMenu/itemsFactory.mjs +1 -1
  109. package/plugins/contextMenu/menu/defaultShortcutsList.js +10 -26
  110. package/plugins/contextMenu/menu/defaultShortcutsList.mjs +10 -26
  111. package/plugins/contextMenu/menu/menu.js +13 -21
  112. package/plugins/contextMenu/menu/menu.mjs +13 -21
  113. package/plugins/contextMenu/menu/positioner.js +41 -58
  114. package/plugins/contextMenu/menu/positioner.mjs +41 -58
  115. package/plugins/copyPaste/copyPaste.js +113 -154
  116. package/plugins/copyPaste/copyPaste.mjs +113 -154
  117. package/plugins/copyPaste/copyableRanges.js +43 -66
  118. package/plugins/copyPaste/copyableRanges.mjs +43 -66
  119. package/plugins/customBorders/customBorders.js +11 -13
  120. package/plugins/customBorders/customBorders.mjs +11 -13
  121. package/plugins/dragToScroll/dragToScroll.js +6 -6
  122. package/plugins/dragToScroll/dragToScroll.mjs +6 -6
  123. package/plugins/dropdownMenu/dropdownMenu.js +78 -100
  124. package/plugins/dropdownMenu/dropdownMenu.mjs +78 -100
  125. package/plugins/exportFile/dataProvider.js +1 -1
  126. package/plugins/exportFile/dataProvider.mjs +1 -1
  127. package/plugins/filters/component/actionBar.js +9 -9
  128. package/plugins/filters/component/actionBar.mjs +8 -8
  129. package/plugins/filters/component/condition.js +13 -15
  130. package/plugins/filters/component/condition.mjs +13 -15
  131. package/plugins/filters/component/operators.js +6 -6
  132. package/plugins/filters/component/operators.mjs +6 -6
  133. package/plugins/filters/component/value.js +24 -28
  134. package/plugins/filters/component/value.mjs +24 -28
  135. package/plugins/filters/conditionUpdateObserver.js +22 -24
  136. package/plugins/filters/conditionUpdateObserver.mjs +22 -24
  137. package/plugins/filters/dataFilter.js +1 -1
  138. package/plugins/filters/dataFilter.mjs +1 -1
  139. package/plugins/filters/filters.js +81 -95
  140. package/plugins/filters/filters.mjs +81 -95
  141. package/plugins/filters/ui/input.js +13 -19
  142. package/plugins/filters/ui/input.mjs +13 -19
  143. package/plugins/filters/ui/link.js +8 -13
  144. package/plugins/filters/ui/link.mjs +8 -13
  145. package/plugins/filters/ui/multipleSelect.js +85 -112
  146. package/plugins/filters/ui/multipleSelect.mjs +85 -112
  147. package/plugins/filters/ui/radioInput.js +12 -20
  148. package/plugins/filters/ui/radioInput.mjs +12 -20
  149. package/plugins/filters/ui/select.js +50 -72
  150. package/plugins/filters/ui/select.mjs +49 -71
  151. package/plugins/formulas/formulas.js +268 -326
  152. package/plugins/formulas/formulas.mjs +269 -327
  153. package/plugins/formulas/indexSyncer/axisSyncer.js +38 -61
  154. package/plugins/formulas/indexSyncer/axisSyncer.mjs +38 -61
  155. package/plugins/formulas/indexSyncer/index.js +25 -48
  156. package/plugins/formulas/indexSyncer/index.mjs +25 -48
  157. package/plugins/hiddenColumns/hiddenColumns.js +64 -83
  158. package/plugins/hiddenColumns/hiddenColumns.mjs +64 -83
  159. package/plugins/hiddenRows/hiddenRows.js +63 -82
  160. package/plugins/hiddenRows/hiddenRows.mjs +63 -82
  161. package/plugins/manualColumnFreeze/manualColumnFreeze.js +24 -32
  162. package/plugins/manualColumnFreeze/manualColumnFreeze.mjs +25 -33
  163. package/plugins/manualColumnMove/manualColumnMove.js +126 -170
  164. package/plugins/manualColumnMove/manualColumnMove.mjs +126 -170
  165. package/plugins/manualColumnResize/manualColumnResize.js +169 -230
  166. package/plugins/manualColumnResize/manualColumnResize.mjs +169 -230
  167. package/plugins/manualRowMove/manualRowMove.js +99 -128
  168. package/plugins/manualRowMove/manualRowMove.mjs +99 -128
  169. package/plugins/manualRowResize/manualRowResize.js +150 -209
  170. package/plugins/manualRowResize/manualRowResize.mjs +150 -209
  171. package/plugins/mergeCells/calculations/selection.js +71 -2
  172. package/plugins/mergeCells/calculations/selection.mjs +71 -2
  173. package/plugins/mergeCells/cellsCollection.js +1 -117
  174. package/plugins/mergeCells/cellsCollection.mjs +1 -117
  175. package/plugins/mergeCells/contextMenuItem/toggleMerge.js +1 -11
  176. package/plugins/mergeCells/contextMenuItem/toggleMerge.mjs +1 -11
  177. package/plugins/mergeCells/mergeCells.js +353 -593
  178. package/plugins/mergeCells/mergeCells.mjs +353 -593
  179. package/plugins/multiColumnSorting/multiColumnSorting.js +0 -6
  180. package/plugins/multiColumnSorting/multiColumnSorting.mjs +0 -6
  181. package/plugins/multipleSelectionHandles/multipleSelectionHandles.js +1 -1
  182. package/plugins/multipleSelectionHandles/multipleSelectionHandles.mjs +1 -1
  183. package/plugins/nestedHeaders/nestedHeaders.js +204 -254
  184. package/plugins/nestedHeaders/nestedHeaders.mjs +205 -255
  185. package/plugins/nestedHeaders/stateManager/headersTree.js +21 -32
  186. package/plugins/nestedHeaders/stateManager/headersTree.mjs +21 -32
  187. package/plugins/nestedHeaders/stateManager/index.js +30 -41
  188. package/plugins/nestedHeaders/stateManager/index.mjs +30 -41
  189. package/plugins/nestedHeaders/stateManager/sourceSettings.js +19 -30
  190. package/plugins/nestedHeaders/stateManager/sourceSettings.mjs +19 -30
  191. package/plugins/nestedRows/data/dataManager.js +1 -1
  192. package/plugins/nestedRows/data/dataManager.mjs +1 -1
  193. package/plugins/nestedRows/nestedRows.js +138 -179
  194. package/plugins/nestedRows/nestedRows.mjs +139 -180
  195. package/plugins/nestedRows/ui/contextMenu.js +11 -15
  196. package/plugins/nestedRows/ui/contextMenu.mjs +10 -14
  197. package/plugins/nestedRows/utils/rowMoveController.js +1 -1
  198. package/plugins/nestedRows/utils/rowMoveController.mjs +1 -1
  199. package/plugins/persistentState/storage.js +2 -2
  200. package/plugins/persistentState/storage.mjs +2 -2
  201. package/plugins/search/search.js +7 -7
  202. package/plugins/search/search.mjs +7 -7
  203. package/plugins/touchScroll/touchScroll.js +15 -19
  204. package/plugins/touchScroll/touchScroll.mjs +16 -20
  205. package/plugins/trimRows/trimRows.js +6 -6
  206. package/plugins/trimRows/trimRows.mjs +6 -6
  207. package/renderers/checkboxRenderer/checkboxRenderer.js +5 -8
  208. package/renderers/checkboxRenderer/checkboxRenderer.mjs +5 -8
  209. package/selection/highlight/highlight.js +14 -14
  210. package/selection/highlight/highlight.mjs +13 -13
  211. package/selection/highlight/visualSelection.js +2 -16
  212. package/selection/highlight/visualSelection.mjs +2 -16
  213. package/selection/selection.js +60 -255
  214. package/selection/selection.mjs +59 -254
  215. package/selection/transformation.js +101 -175
  216. package/selection/transformation.mjs +101 -175
  217. package/shortcutContexts/commands/editor/closeAndSave.js +2 -2
  218. package/shortcutContexts/commands/editor/closeAndSave.mjs +2 -2
  219. package/shortcutContexts/commands/editor/open.js +3 -18
  220. package/shortcutContexts/commands/editor/open.mjs +3 -18
  221. package/shortcutContexts/commands/extendCellsSelection/down.js +1 -1
  222. package/shortcutContexts/commands/extendCellsSelection/down.mjs +1 -1
  223. package/shortcutContexts/commands/extendCellsSelection/left.js +1 -1
  224. package/shortcutContexts/commands/extendCellsSelection/left.mjs +1 -1
  225. package/shortcutContexts/commands/extendCellsSelection/right.js +1 -1
  226. package/shortcutContexts/commands/extendCellsSelection/right.mjs +1 -1
  227. package/shortcutContexts/commands/extendCellsSelection/toColumns.js +1 -1
  228. package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +1 -1
  229. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +1 -3
  230. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +1 -3
  231. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +3 -9
  232. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +3 -9
  233. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +3 -10
  234. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +3 -10
  235. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +1 -3
  236. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +1 -3
  237. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +1 -3
  238. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +1 -3
  239. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +1 -3
  240. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +1 -3
  241. package/shortcutContexts/commands/extendCellsSelection/toRows.js +1 -1
  242. package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +1 -1
  243. package/shortcutContexts/commands/extendCellsSelection/up.js +1 -1
  244. package/shortcutContexts/commands/extendCellsSelection/up.mjs +1 -1
  245. package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +1 -6
  246. package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +1 -6
  247. package/shortcutContexts/commands/moveCellSelection/inlineStart.js +1 -6
  248. package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +1 -6
  249. package/shortcutContexts/grid.js +2 -2
  250. package/shortcutContexts/grid.mjs +2 -2
  251. package/shortcuts/context.js +1 -2
  252. package/shortcuts/context.mjs +1 -2
  253. package/tableView.js +52 -98
  254. package/tableView.mjs +52 -98
  255. package/translations/changesObservable/observable.js +21 -38
  256. package/translations/changesObservable/observable.mjs +21 -38
  257. package/translations/changesObservable/observer.js +7 -12
  258. package/translations/changesObservable/observer.mjs +6 -11
  259. package/translations/mapCollections/aggregatedCollection.js +1 -1
  260. package/translations/mapCollections/aggregatedCollection.mjs +1 -1
  261. package/translations/maps/indexMap.js +1 -1
  262. package/translations/maps/indexMap.mjs +1 -1
  263. package/utils/dataStructures/linkedList.js +1 -6
  264. package/utils/dataStructures/linkedList.mjs +1 -6
  265. package/utils/dataStructures/tree.js +1 -1
  266. package/utils/dataStructures/tree.mjs +1 -1
  267. package/utils/interval.js +26 -44
  268. package/utils/interval.mjs +26 -44
  269. package/core/viewportScroll/scrollStrategies/focusScroll.js +0 -15
  270. package/core/viewportScroll/scrollStrategies/focusScroll.mjs +0 -11
  271. package/plugins/mergeCells/focusOrder.js +0 -327
  272. package/plugins/mergeCells/focusOrder.mjs +0 -322
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- require("core-js/modules/es.array.push.js");
5
4
  require("core-js/modules/es.error.cause.js");
5
+ require("core-js/modules/es.array.push.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.array.push.js";
2
1
  import "core-js/modules/es.error.cause.js";
2
+ import "core-js/modules/es.array.push.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.array.push.js");
5
4
  require("core-js/modules/es.error.cause.js");
6
- require("core-js/modules/es.array.unscopables.flat-map.js");
5
+ require("core-js/modules/es.array.push.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 _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
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 _getNonIntersectingIndexes = /*#__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, _getNonIntersectingIndexes);
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 = _classPrivateMethodGet(this, _getNonIntersectingIndexes, _getNonIntersectingIndexes2).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 = _classPrivateMethodGet(this, _getNonIntersectingIndexes, _getNonIntersectingIndexes2).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 = _classPrivateMethodGet(this, _getNonIntersectingIndexes, _getNonIntersectingIndexes2).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 = _classPrivateMethodGet(this, _getNonIntersectingIndexes, _getNonIntersectingIndexes2).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 _getNonIntersectingIndexes2(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.array.push.js";
2
- import "core-js/modules/es.array.unscopables.flat-map.js";
3
1
  import "core-js/modules/es.error.cause.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.array.push.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 _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
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 _getNonIntersectingIndexes = /*#__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, _getNonIntersectingIndexes);
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 = _classPrivateMethodGet(this, _getNonIntersectingIndexes, _getNonIntersectingIndexes2).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 = _classPrivateMethodGet(this, _getNonIntersectingIndexes, _getNonIntersectingIndexes2).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 = _classPrivateMethodGet(this, _getNonIntersectingIndexes, _getNonIntersectingIndexes2).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 = _classPrivateMethodGet(this, _getNonIntersectingIndexes, _getNonIntersectingIndexes2).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 _getNonIntersectingIndexes2(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();