handsontable 14.0.0-next-c080457-20231107 → 14.0.0-next-bfad250-20231108

Sign up to get free protection for your applications and to get access to all the features.
Files changed (327) hide show
  1. package/3rdparty/SheetClip/SheetClip.js +2 -2
  2. package/3rdparty/SheetClip/SheetClip.mjs +2 -2
  3. package/3rdparty/autoResize/autoResize.js +2 -2
  4. package/3rdparty/autoResize/autoResize.mjs +2 -2
  5. package/3rdparty/walkontable/src/calculator/viewportColumns.js +108 -85
  6. package/3rdparty/walkontable/src/calculator/viewportColumns.mjs +108 -85
  7. package/3rdparty/walkontable/src/calculator/viewportRows.js +60 -52
  8. package/3rdparty/walkontable/src/calculator/viewportRows.mjs +60 -52
  9. package/3rdparty/walkontable/src/cell/coords.js +7 -5
  10. package/3rdparty/walkontable/src/cell/coords.mjs +7 -5
  11. package/3rdparty/walkontable/src/core/clone.js +6 -0
  12. package/3rdparty/walkontable/src/core/clone.mjs +6 -0
  13. package/3rdparty/walkontable/src/event.js +125 -74
  14. package/3rdparty/walkontable/src/event.mjs +125 -74
  15. package/3rdparty/walkontable/src/filter/column.js +16 -0
  16. package/3rdparty/walkontable/src/filter/column.mjs +16 -0
  17. package/3rdparty/walkontable/src/filter/row.js +16 -0
  18. package/3rdparty/walkontable/src/filter/row.mjs +16 -0
  19. package/3rdparty/walkontable/src/overlay/bottom.js +1 -1
  20. package/3rdparty/walkontable/src/overlay/bottom.mjs +1 -1
  21. package/3rdparty/walkontable/src/overlay/top.js +1 -1
  22. package/3rdparty/walkontable/src/overlay/top.mjs +1 -1
  23. package/3rdparty/walkontable/src/renderer/_base.js +12 -5
  24. package/3rdparty/walkontable/src/renderer/_base.mjs +12 -5
  25. package/3rdparty/walkontable/src/renderer/cells.js +6 -2
  26. package/3rdparty/walkontable/src/renderer/cells.mjs +6 -2
  27. package/3rdparty/walkontable/src/renderer/rowHeaders.js +6 -2
  28. package/3rdparty/walkontable/src/renderer/rowHeaders.mjs +6 -2
  29. package/3rdparty/walkontable/src/renderer/rows.js +5 -0
  30. package/3rdparty/walkontable/src/renderer/rows.mjs +5 -0
  31. package/3rdparty/walkontable/src/renderer/table.js +24 -17
  32. package/3rdparty/walkontable/src/renderer/table.mjs +24 -17
  33. package/3rdparty/walkontable/src/scroll.js +2 -2
  34. package/3rdparty/walkontable/src/scroll.mjs +2 -2
  35. package/3rdparty/walkontable/src/selection/border/border.js +1 -1
  36. package/3rdparty/walkontable/src/selection/border/border.mjs +1 -1
  37. package/3rdparty/walkontable/src/settings.js +10 -10
  38. package/3rdparty/walkontable/src/settings.mjs +10 -10
  39. package/3rdparty/walkontable/src/table.js +3 -3
  40. package/3rdparty/walkontable/src/table.mjs +3 -3
  41. package/3rdparty/walkontable/src/utils/column.js +19 -4
  42. package/3rdparty/walkontable/src/utils/column.mjs +19 -4
  43. package/3rdparty/walkontable/src/utils/nodesPool.js +5 -0
  44. package/3rdparty/walkontable/src/utils/nodesPool.mjs +5 -0
  45. package/3rdparty/walkontable/src/utils/orderView/view.js +13 -6
  46. package/3rdparty/walkontable/src/utils/orderView/view.mjs +13 -6
  47. package/3rdparty/walkontable/src/utils/orderView/viewSize.js +9 -6
  48. package/3rdparty/walkontable/src/utils/orderView/viewSize.mjs +9 -6
  49. package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.js +7 -4
  50. package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.mjs +7 -4
  51. package/3rdparty/walkontable/src/utils/row.js +14 -2
  52. package/3rdparty/walkontable/src/utils/row.mjs +14 -2
  53. package/3rdparty/walkontable/src/viewport.js +9 -9
  54. package/3rdparty/walkontable/src/viewport.mjs +9 -9
  55. package/base.js +2 -2
  56. package/base.mjs +2 -2
  57. package/core.js +25 -25
  58. package/core.mjs +25 -25
  59. package/dataMap/dataMap.js +99 -90
  60. package/dataMap/dataMap.mjs +99 -90
  61. package/dataMap/dataSource.js +14 -8
  62. package/dataMap/dataSource.mjs +14 -8
  63. package/dataMap/metaManager/lazyFactoryMap.js +19 -7
  64. package/dataMap/metaManager/lazyFactoryMap.mjs +19 -7
  65. package/dataMap/metaManager/metaLayers/cellMeta.js +8 -3
  66. package/dataMap/metaManager/metaLayers/cellMeta.mjs +8 -3
  67. package/dataMap/metaManager/metaLayers/columnMeta.js +7 -1
  68. package/dataMap/metaManager/metaLayers/columnMeta.mjs +7 -1
  69. package/dataMap/metaManager/metaLayers/globalMeta.js +6 -1
  70. package/dataMap/metaManager/metaLayers/globalMeta.mjs +6 -1
  71. package/dataMap/metaManager/metaLayers/tableMeta.js +6 -2
  72. package/dataMap/metaManager/metaLayers/tableMeta.mjs +6 -2
  73. package/dataMap/metaManager/metaSchema.js +55 -55
  74. package/dataMap/metaManager/metaSchema.mjs +55 -55
  75. package/dataMap/metaManager/mods/dynamicCellMeta.js +7 -2
  76. package/dataMap/metaManager/mods/dynamicCellMeta.mjs +7 -2
  77. package/dataMap/metaManager/mods/extendMetaProperties.js +8 -4
  78. package/dataMap/metaManager/mods/extendMetaProperties.mjs +8 -4
  79. package/dataMap/metaManager/utils.js +2 -2
  80. package/dataMap/metaManager/utils.mjs +2 -2
  81. package/dist/handsontable.css +2 -2
  82. package/dist/handsontable.full.css +2 -2
  83. package/dist/handsontable.full.js +7337 -6389
  84. package/dist/handsontable.full.min.css +2 -2
  85. package/dist/handsontable.full.min.js +154 -154
  86. package/dist/handsontable.js +7336 -6388
  87. package/dist/handsontable.min.css +2 -2
  88. package/dist/handsontable.min.js +28 -28
  89. package/editorManager.js +105 -95
  90. package/editorManager.mjs +105 -95
  91. package/editors/autocompleteEditor/autocompleteEditor.js +47 -46
  92. package/editors/autocompleteEditor/autocompleteEditor.mjs +46 -45
  93. package/editors/baseEditor/baseEditor.js +23 -26
  94. package/editors/baseEditor/baseEditor.mjs +23 -26
  95. package/editors/dateEditor/dateEditor.js +24 -15
  96. package/editors/dateEditor/dateEditor.mjs +24 -15
  97. package/editors/dropdownEditor/dropdownEditor.js +1 -1
  98. package/editors/dropdownEditor/dropdownEditor.mjs +1 -1
  99. package/editors/handsontableEditor/handsontableEditor.js +4 -4
  100. package/editors/handsontableEditor/handsontableEditor.mjs +4 -4
  101. package/editors/textEditor/textEditor.js +23 -17
  102. package/editors/textEditor/textEditor.mjs +24 -18
  103. package/eventManager.js +8 -0
  104. package/eventManager.mjs +8 -0
  105. package/helpers/array.js +2 -2
  106. package/helpers/array.mjs +2 -2
  107. package/helpers/dom/element.js +7 -7
  108. package/helpers/dom/element.mjs +7 -7
  109. package/helpers/function.js +1 -1
  110. package/helpers/function.mjs +1 -1
  111. package/helpers/mixed.js +1 -1
  112. package/helpers/mixed.mjs +1 -1
  113. package/helpers/object.js +4 -4
  114. package/helpers/object.mjs +4 -4
  115. package/helpers/string.js +1 -1
  116. package/helpers/string.mjs +1 -1
  117. package/package.json +1 -1
  118. package/pluginHooks.d.ts +0 -2
  119. package/pluginHooks.js +12 -3
  120. package/pluginHooks.mjs +12 -3
  121. package/plugins/autoColumnSize/autoColumnSize.js +141 -130
  122. package/plugins/autoColumnSize/autoColumnSize.mjs +140 -129
  123. package/plugins/autoRowSize/autoRowSize.js +112 -125
  124. package/plugins/autoRowSize/autoRowSize.mjs +110 -123
  125. package/plugins/autofill/autofill.d.ts +0 -1
  126. package/plugins/autofill/autofill.js +98 -102
  127. package/plugins/autofill/autofill.mjs +97 -101
  128. package/plugins/base/base.js +61 -28
  129. package/plugins/base/base.mjs +60 -28
  130. package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.js +29 -24
  131. package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.mjs +28 -23
  132. package/plugins/collapsibleColumns/collapsibleColumns.js +104 -107
  133. package/plugins/collapsibleColumns/collapsibleColumns.mjs +102 -104
  134. package/plugins/columnSorting/columnSorting.js +107 -99
  135. package/plugins/columnSorting/columnSorting.mjs +106 -98
  136. package/plugins/columnSorting/columnStatesManager.js +12 -6
  137. package/plugins/columnSorting/columnStatesManager.mjs +12 -6
  138. package/plugins/columnSummary/columnSummary.js +71 -58
  139. package/plugins/columnSummary/columnSummary.mjs +70 -57
  140. package/plugins/columnSummary/endpoints.js +20 -14
  141. package/plugins/columnSummary/endpoints.mjs +20 -14
  142. package/plugins/comments/commentEditor.js +30 -2
  143. package/plugins/comments/commentEditor.mjs +30 -2
  144. package/plugins/comments/comments.js +158 -169
  145. package/plugins/comments/comments.mjs +157 -168
  146. package/plugins/comments/displaySwitch.js +7 -3
  147. package/plugins/comments/displaySwitch.mjs +7 -3
  148. package/plugins/contextMenu/commandExecutor.js +15 -2
  149. package/plugins/contextMenu/commandExecutor.mjs +15 -2
  150. package/plugins/contextMenu/contextMenu.js +96 -102
  151. package/plugins/contextMenu/contextMenu.mjs +95 -101
  152. package/plugins/contextMenu/itemsFactory.js +19 -4
  153. package/plugins/contextMenu/itemsFactory.mjs +19 -4
  154. package/plugins/contextMenu/menu/cursor.js +36 -0
  155. package/plugins/contextMenu/menu/cursor.mjs +36 -0
  156. package/plugins/contextMenu/menu/menu.js +57 -5
  157. package/plugins/contextMenu/menu/menu.mjs +57 -5
  158. package/plugins/contextMenu/predefinedItems/removeColumn.js +1 -1
  159. package/plugins/contextMenu/predefinedItems/removeColumn.mjs +1 -1
  160. package/plugins/contextMenu/predefinedItems/removeRow.js +1 -1
  161. package/plugins/contextMenu/predefinedItems/removeRow.mjs +1 -1
  162. package/plugins/copyPaste/copyPaste.js +74 -75
  163. package/plugins/copyPaste/copyPaste.mjs +74 -75
  164. package/plugins/customBorders/customBorders.js +57 -50
  165. package/plugins/customBorders/customBorders.mjs +56 -49
  166. package/plugins/dragToScroll/dragToScroll.js +50 -54
  167. package/plugins/dragToScroll/dragToScroll.mjs +49 -52
  168. package/plugins/dropdownMenu/dropdownMenu.js +136 -131
  169. package/plugins/dropdownMenu/dropdownMenu.mjs +136 -131
  170. package/plugins/exportFile/dataProvider.js +7 -2
  171. package/plugins/exportFile/dataProvider.mjs +7 -2
  172. package/plugins/exportFile/exportFile.js +1 -1
  173. package/plugins/exportFile/exportFile.mjs +1 -1
  174. package/plugins/exportFile/types/_base.js +14 -6
  175. package/plugins/exportFile/types/_base.mjs +14 -6
  176. package/plugins/filters/component/actionBar.js +9 -0
  177. package/plugins/filters/component/actionBar.mjs +9 -0
  178. package/plugins/filters/component/condition.js +13 -0
  179. package/plugins/filters/component/condition.mjs +13 -0
  180. package/plugins/filters/component/operators.js +9 -0
  181. package/plugins/filters/component/operators.mjs +9 -0
  182. package/plugins/filters/component/value.js +9 -0
  183. package/plugins/filters/component/value.mjs +9 -0
  184. package/plugins/filters/conditionCollection.js +9 -4
  185. package/plugins/filters/conditionCollection.mjs +9 -4
  186. package/plugins/filters/conditionUpdateObserver.js +53 -42
  187. package/plugins/filters/conditionUpdateObserver.mjs +53 -42
  188. package/plugins/filters/dataFilter.js +9 -3
  189. package/plugins/filters/dataFilter.mjs +9 -3
  190. package/plugins/filters/filters.js +184 -189
  191. package/plugins/filters/filters.mjs +182 -187
  192. package/plugins/filters/ui/_base.js +1 -1
  193. package/plugins/filters/ui/_base.mjs +1 -1
  194. package/plugins/filters/utils.js +1 -1
  195. package/plugins/filters/utils.mjs +1 -1
  196. package/plugins/formulas/engine/settings.js +1 -1
  197. package/plugins/formulas/engine/settings.mjs +1 -1
  198. package/plugins/formulas/formulas.js +684 -602
  199. package/plugins/formulas/formulas.mjs +682 -600
  200. package/plugins/hiddenColumns/hiddenColumns.js +174 -169
  201. package/plugins/hiddenColumns/hiddenColumns.mjs +173 -168
  202. package/plugins/hiddenRows/hiddenRows.js +170 -165
  203. package/plugins/hiddenRows/hiddenRows.mjs +169 -164
  204. package/plugins/manualColumnFreeze/contextMenuItem/freezeColumn.js +1 -1
  205. package/plugins/manualColumnFreeze/contextMenuItem/freezeColumn.mjs +1 -1
  206. package/plugins/manualColumnFreeze/contextMenuItem/unfreezeColumn.js +1 -1
  207. package/plugins/manualColumnFreeze/contextMenuItem/unfreezeColumn.mjs +1 -1
  208. package/plugins/manualColumnFreeze/manualColumnFreeze.js +66 -53
  209. package/plugins/manualColumnFreeze/manualColumnFreeze.mjs +64 -51
  210. package/plugins/manualColumnMove/manualColumnMove.js +287 -232
  211. package/plugins/manualColumnMove/manualColumnMove.mjs +286 -231
  212. package/plugins/manualColumnMove/ui/_base.js +9 -3
  213. package/plugins/manualColumnMove/ui/_base.mjs +9 -3
  214. package/plugins/manualColumnResize/manualColumnResize.js +291 -246
  215. package/plugins/manualColumnResize/manualColumnResize.mjs +290 -244
  216. package/plugins/manualRowMove/manualRowMove.js +223 -208
  217. package/plugins/manualRowMove/manualRowMove.mjs +222 -207
  218. package/plugins/manualRowMove/ui/_base.js +10 -5
  219. package/plugins/manualRowMove/ui/_base.mjs +10 -5
  220. package/plugins/manualRowResize/manualRowResize.js +254 -209
  221. package/plugins/manualRowResize/manualRowResize.mjs +253 -207
  222. package/plugins/mergeCells/calculations/autofill.js +9 -3
  223. package/plugins/mergeCells/calculations/autofill.mjs +9 -3
  224. package/plugins/mergeCells/calculations/selection.js +10 -4
  225. package/plugins/mergeCells/calculations/selection.mjs +10 -4
  226. package/plugins/mergeCells/cellCoords.js +16 -6
  227. package/plugins/mergeCells/cellCoords.mjs +16 -6
  228. package/plugins/mergeCells/cellsCollection.js +10 -4
  229. package/plugins/mergeCells/cellsCollection.mjs +10 -4
  230. package/plugins/mergeCells/mergeCells.js +582 -502
  231. package/plugins/mergeCells/mergeCells.mjs +580 -500
  232. package/plugins/multiColumnSorting/multiColumnSorting.js +15 -11
  233. package/plugins/multiColumnSorting/multiColumnSorting.mjs +15 -11
  234. package/plugins/multipleSelectionHandles/multipleSelectionHandles.js +16 -28
  235. package/plugins/multipleSelectionHandles/multipleSelectionHandles.mjs +16 -27
  236. package/plugins/nestedHeaders/nestedHeaders.js +542 -499
  237. package/plugins/nestedHeaders/nestedHeaders.mjs +554 -511
  238. package/plugins/nestedHeaders/stateManager/index.js +1 -1
  239. package/plugins/nestedHeaders/stateManager/index.mjs +1 -1
  240. package/plugins/nestedRows/data/dataManager.js +21 -15
  241. package/plugins/nestedRows/data/dataManager.mjs +21 -15
  242. package/plugins/nestedRows/nestedRows.js +335 -279
  243. package/plugins/nestedRows/nestedRows.mjs +334 -278
  244. package/plugins/nestedRows/ui/_base.js +7 -1
  245. package/plugins/nestedRows/ui/_base.mjs +7 -1
  246. package/plugins/nestedRows/ui/collapsing.js +2 -2
  247. package/plugins/nestedRows/ui/collapsing.mjs +2 -2
  248. package/plugins/nestedRows/ui/contextMenu.js +28 -18
  249. package/plugins/nestedRows/ui/contextMenu.mjs +28 -18
  250. package/plugins/nestedRows/utils/rowMoveController.js +12 -4
  251. package/plugins/nestedRows/utils/rowMoveController.mjs +12 -4
  252. package/plugins/persistentState/persistentState.js +14 -11
  253. package/plugins/persistentState/persistentState.mjs +14 -11
  254. package/plugins/persistentState/storage.js +11 -6
  255. package/plugins/persistentState/storage.mjs +11 -6
  256. package/plugins/registry.js +2 -2
  257. package/plugins/registry.mjs +2 -2
  258. package/plugins/search/search.js +57 -46
  259. package/plugins/search/search.mjs +56 -45
  260. package/plugins/touchScroll/touchScroll.js +102 -100
  261. package/plugins/touchScroll/touchScroll.mjs +100 -98
  262. package/plugins/trimRows/trimRows.js +33 -28
  263. package/plugins/trimRows/trimRows.mjs +32 -27
  264. package/plugins/undoRedo/undoRedo.js +2 -2
  265. package/plugins/undoRedo/undoRedo.mjs +2 -2
  266. package/renderers/autocompleteRenderer/autocompleteRenderer.js +11 -11
  267. package/renderers/autocompleteRenderer/autocompleteRenderer.mjs +11 -11
  268. package/renderers/baseRenderer/baseRenderer.js +2 -2
  269. package/renderers/baseRenderer/baseRenderer.mjs +2 -2
  270. package/renderers/checkboxRenderer/checkboxRenderer.js +23 -23
  271. package/renderers/checkboxRenderer/checkboxRenderer.mjs +23 -23
  272. package/renderers/dateRenderer/dateRenderer.js +4 -4
  273. package/renderers/dateRenderer/dateRenderer.mjs +4 -4
  274. package/renderers/handsontableRenderer/handsontableRenderer.js +4 -4
  275. package/renderers/handsontableRenderer/handsontableRenderer.mjs +4 -4
  276. package/renderers/htmlRenderer/htmlRenderer.js +4 -4
  277. package/renderers/htmlRenderer/htmlRenderer.mjs +4 -4
  278. package/renderers/numericRenderer/numericRenderer.js +3 -3
  279. package/renderers/numericRenderer/numericRenderer.mjs +3 -3
  280. package/renderers/passwordRenderer/passwordRenderer.js +3 -3
  281. package/renderers/passwordRenderer/passwordRenderer.mjs +3 -3
  282. package/renderers/selectRenderer/selectRenderer.js +4 -4
  283. package/renderers/selectRenderer/selectRenderer.mjs +4 -4
  284. package/renderers/textRenderer/textRenderer.js +5 -5
  285. package/renderers/textRenderer/textRenderer.mjs +5 -5
  286. package/renderers/timeRenderer/timeRenderer.js +3 -3
  287. package/renderers/timeRenderer/timeRenderer.mjs +3 -3
  288. package/selection/range.js +12 -2
  289. package/selection/range.mjs +12 -2
  290. package/selection/selection.js +28 -10
  291. package/selection/selection.mjs +28 -10
  292. package/selection/utils.js +24 -14
  293. package/selection/utils.mjs +25 -15
  294. package/shortcuts/manager.js +1 -1
  295. package/shortcuts/manager.mjs +1 -1
  296. package/tableView.js +208 -200
  297. package/tableView.mjs +208 -200
  298. package/translations/changesObservable/utils.js +2 -2
  299. package/translations/changesObservable/utils.mjs +2 -2
  300. package/translations/indexMapper.js +25 -22
  301. package/translations/indexMapper.mjs +25 -22
  302. package/translations/mapCollections/aggregatedCollection.js +8 -2
  303. package/translations/mapCollections/aggregatedCollection.mjs +8 -2
  304. package/translations/mapCollections/mapCollection.js +5 -2
  305. package/translations/mapCollections/mapCollection.mjs +5 -2
  306. package/translations/maps/indexMap.js +6 -1
  307. package/translations/maps/indexMap.mjs +6 -1
  308. package/translations/maps/utils/physicallyIndexed.js +2 -2
  309. package/translations/maps/utils/physicallyIndexed.mjs +2 -2
  310. package/utils/dataStructures/linkedList.js +10 -6
  311. package/utils/dataStructures/linkedList.mjs +10 -6
  312. package/utils/dataStructures/queue.js +1 -1
  313. package/utils/dataStructures/queue.mjs +1 -1
  314. package/utils/dataStructures/stack.js +1 -1
  315. package/utils/dataStructures/stack.mjs +1 -1
  316. package/utils/ghostTable.js +2 -2
  317. package/utils/ghostTable.mjs +2 -2
  318. package/utils/interval.js +73 -36
  319. package/utils/interval.mjs +73 -36
  320. package/utils/parseTable.js +1 -1
  321. package/utils/parseTable.mjs +1 -1
  322. package/validators/autocompleteValidator/autocompleteValidator.js +1 -1
  323. package/validators/autocompleteValidator/autocompleteValidator.mjs +1 -1
  324. package/validators/dateValidator/dateValidator.js +1 -1
  325. package/validators/dateValidator/dateValidator.mjs +1 -1
  326. package/validators/numericValidator/numericValidator.js +1 -1
  327. package/validators/numericValidator/numericValidator.mjs +1 -1
@@ -1,4 +1,17 @@
1
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 _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
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
10
+ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
11
+ function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
12
+ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
13
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
14
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
2
15
  import { BasePlugin } from "../base/index.mjs";
3
16
  import Hooks from "../../pluginHooks.mjs";
4
17
  import MergedCellsCollection from "./cellsCollection.mjs";
@@ -19,7 +32,6 @@ Hooks.getSingleton().register('beforeUnmergeCells');
19
32
  Hooks.getSingleton().register('afterUnmergeCells');
20
33
  export const PLUGIN_KEY = 'mergeCells';
21
34
  export const PLUGIN_PRIORITY = 150;
22
- const privatePool = new WeakMap();
23
35
  const SHORTCUTS_GROUP = PLUGIN_KEY;
24
36
 
25
37
  /* eslint-disable jsdoc/require-description-complete-sentence */
@@ -59,42 +71,231 @@ const SHORTCUTS_GROUP = PLUGIN_KEY;
59
71
  * ```
60
72
  * :::
61
73
  */
74
+ var _lastDesiredCoords = /*#__PURE__*/new WeakMap();
75
+ var _onAfterInit = /*#__PURE__*/new WeakSet();
76
+ var _onAfterIsMultipleSelection = /*#__PURE__*/new WeakSet();
77
+ var _onModifyTransformStart = /*#__PURE__*/new WeakSet();
78
+ var _onModifyTransformEnd = /*#__PURE__*/new WeakSet();
79
+ var _onModifyGetCellCoords = /*#__PURE__*/new WeakSet();
80
+ var _addMergeActionsToContextMenu = /*#__PURE__*/new WeakSet();
81
+ var _onAfterRenderer = /*#__PURE__*/new WeakSet();
82
+ var _onBeforeSetRangeStart = /*#__PURE__*/new WeakSet();
83
+ var _onBeforeSetRangeEnd = /*#__PURE__*/new WeakSet();
84
+ var _onAfterGetCellMeta = /*#__PURE__*/new WeakSet();
85
+ var _onAfterViewportRowCalculatorOverride = /*#__PURE__*/new WeakSet();
86
+ var _onAfterViewportColumnCalculatorOverride = /*#__PURE__*/new WeakSet();
87
+ var _onModifyAutofillRange = /*#__PURE__*/new WeakSet();
88
+ var _onAfterCreateCol = /*#__PURE__*/new WeakSet();
89
+ var _onAfterRemoveCol = /*#__PURE__*/new WeakSet();
90
+ var _onAfterCreateRow = /*#__PURE__*/new WeakSet();
91
+ var _onAfterRemoveRow = /*#__PURE__*/new WeakSet();
92
+ var _onAfterChange = /*#__PURE__*/new WeakSet();
93
+ var _onBeforeDrawAreaBorders = /*#__PURE__*/new WeakSet();
94
+ var _onAfterModifyTransformStart = /*#__PURE__*/new WeakSet();
95
+ var _onAfterDrawSelection = /*#__PURE__*/new WeakSet();
96
+ var _onBeforeRemoveCellClassNames = /*#__PURE__*/new WeakSet();
62
97
  export class MergeCells extends BasePlugin {
63
- static get PLUGIN_KEY() {
64
- return PLUGIN_KEY;
65
- }
66
- static get PLUGIN_PRIORITY() {
67
- return PLUGIN_PRIORITY;
68
- }
69
- constructor(hotInstance) {
70
- super(hotInstance);
71
- privatePool.set(this, {
72
- lastDesiredCoords: null
73
- });
74
-
98
+ constructor() {
99
+ super(...arguments);
100
+ /**
101
+ * `beforeRemoveCellClassNames` hook callback. Used to remove additional class name from all cells in the table.
102
+ *
103
+ * @returns {string[]} An `Array` of `String`s. Each of these strings will act like class names to be removed from
104
+ * all the cells in the table.
105
+ */
106
+ _classPrivateMethodInitSpec(this, _onBeforeRemoveCellClassNames);
107
+ /**
108
+ * `afterDrawSelection` hook callback. Used to add the additional class name for the entirely-selected merged cells.
109
+ *
110
+ * @param {number} currentRow Visual row index of the currently processed cell.
111
+ * @param {number} currentColumn Visual column index of the currently cell.
112
+ * @param {Array} cornersOfSelection Array of the current selection in a form of `[startRow, startColumn, endRow,
113
+ * endColumn]`.
114
+ * @param {number|undefined} layerLevel Number indicating which layer of selection is currently processed.
115
+ * @returns {string|undefined} A `String`, which will act as an additional `className` to be added to the currently
116
+ * processed cell.
117
+ */
118
+ _classPrivateMethodInitSpec(this, _onAfterDrawSelection);
119
+ /**
120
+ * `afterModifyTransformStart` hook callback. Fixes a problem with navigating through merged cells at the edges of
121
+ * the table with the ENTER/SHIFT+ENTER/TAB/SHIFT+TAB keys.
122
+ *
123
+ * @param {CellCoords} coords Coordinates of the to-be-selected cell.
124
+ * @param {number} rowTransformDir Row transformation direction (negative value = up, 0 = none, positive value =
125
+ * down).
126
+ * @param {number} colTransformDir Column transformation direction (negative value = up, 0 = none, positive value =
127
+ * down).
128
+ */
129
+ _classPrivateMethodInitSpec(this, _onAfterModifyTransformStart);
130
+ /**
131
+ * `beforeDrawAreaBorders` hook callback.
132
+ *
133
+ * @param {Array} corners Visual coordinates of the area corners.
134
+ * @param {string} className Class name for the area.
135
+ */
136
+ _classPrivateMethodInitSpec(this, _onBeforeDrawAreaBorders);
137
+ /**
138
+ * `afterChange` hook callback. Used to propagate merged cells after using Autofill.
139
+ *
140
+ * @param {Array} changes The changes array.
141
+ * @param {string} source Determines the source of the change.
142
+ */
143
+ _classPrivateMethodInitSpec(this, _onAfterChange);
144
+ /**
145
+ * `afterRemoveRow` hook callback.
146
+ *
147
+ * @param {number} row Row index.
148
+ * @param {number} count Number of removed rows.
149
+ */
150
+ _classPrivateMethodInitSpec(this, _onAfterRemoveRow);
151
+ /**
152
+ * `afterCreateRow` hook callback.
153
+ *
154
+ * @param {number} row Row index.
155
+ * @param {number} count Number of created rows.
156
+ * @param {string} source Source of change.
157
+ */
158
+ _classPrivateMethodInitSpec(this, _onAfterCreateRow);
159
+ /**
160
+ * `afterRemoveCol` hook callback.
161
+ *
162
+ * @param {number} column Column index.
163
+ * @param {number} count Number of removed columns.
164
+ */
165
+ _classPrivateMethodInitSpec(this, _onAfterRemoveCol);
166
+ /**
167
+ * `afterCreateCol` hook callback.
168
+ *
169
+ * @param {number} column Column index.
170
+ * @param {number} count Number of created columns.
171
+ */
172
+ _classPrivateMethodInitSpec(this, _onAfterCreateCol);
173
+ /**
174
+ * The `modifyAutofillRange` hook callback.
175
+ *
176
+ * @param {Array} drag The drag area coordinates.
177
+ * @param {Array} select The selection information.
178
+ * @returns {Array} The new drag area.
179
+ */
180
+ _classPrivateMethodInitSpec(this, _onModifyAutofillRange);
181
+ /**
182
+ * `afterViewportColumnCalculatorOverride` hook callback.
183
+ *
184
+ * @param {object} calc The column calculator object.
185
+ */
186
+ _classPrivateMethodInitSpec(this, _onAfterViewportColumnCalculatorOverride);
187
+ /**
188
+ * `afterViewportRowCalculatorOverride` hook callback.
189
+ *
190
+ * @param {object} calc The row calculator object.
191
+ */
192
+ _classPrivateMethodInitSpec(this, _onAfterViewportRowCalculatorOverride);
193
+ /**
194
+ * The `afterGetCellMeta` hook callback.
195
+ *
196
+ * @param {number} row Row index.
197
+ * @param {number} col Column index.
198
+ * @param {object} cellProperties The cell properties object.
199
+ */
200
+ _classPrivateMethodInitSpec(this, _onAfterGetCellMeta);
201
+ /**
202
+ * `beforeSetRangeEnd` hook callback.
203
+ * While selecting cells with keyboard or mouse, make sure that rectangular area is expanded to the extent of the
204
+ * merged cell.
205
+ *
206
+ * Note: Please keep in mind that callback may modify both start and end range coordinates by the reference.
207
+ *
208
+ * @param {object} coords Cell coords.
209
+ */
210
+ _classPrivateMethodInitSpec(this, _onBeforeSetRangeEnd);
211
+ /**
212
+ * `beforeSetRangeStart` and `beforeSetRangeStartOnly` hook callback.
213
+ * A selection within merge area should be rewritten to the start of merge area.
214
+ *
215
+ * @param {object} coords Cell coords.
216
+ */
217
+ _classPrivateMethodInitSpec(this, _onBeforeSetRangeStart);
218
+ /**
219
+ * `afterRenderer` hook callback.
220
+ *
221
+ * @param {HTMLElement} TD The cell to be modified.
222
+ * @param {number} row Row index.
223
+ * @param {number} col Visual column index.
224
+ */
225
+ _classPrivateMethodInitSpec(this, _onAfterRenderer);
226
+ /**
227
+ * `afterContextMenuDefaultOptions` hook callback.
228
+ *
229
+ * @param {object} defaultOptions The default context menu options.
230
+ */
231
+ _classPrivateMethodInitSpec(this, _addMergeActionsToContextMenu);
232
+ /**
233
+ * `modifyGetCellCoords` hook callback. Swaps the `getCell` coords with the merged parent coords.
234
+ *
235
+ * @param {number} row Row index.
236
+ * @param {number} column Visual column index.
237
+ * @returns {Array|undefined} Visual coordinates of the merge.
238
+ */
239
+ _classPrivateMethodInitSpec(this, _onModifyGetCellCoords);
240
+ /**
241
+ * `modifyTransformEnd` hook callback. Needed to handle "jumping over" merged merged cells, while selecting.
242
+ *
243
+ * @param {object} delta The transformation delta.
244
+ */
245
+ _classPrivateMethodInitSpec(this, _onModifyTransformEnd);
246
+ /**
247
+ * `modifyTransformStart` hook callback.
248
+ *
249
+ * @param {object} delta The transformation delta.
250
+ */
251
+ _classPrivateMethodInitSpec(this, _onModifyTransformStart);
252
+ /**
253
+ * Modifies the information on whether the current selection contains multiple cells. The `afterIsMultipleSelection`
254
+ * hook callback.
255
+ *
256
+ * @param {boolean} isMultiple Determines whether the current selection contains multiple cells.
257
+ * @returns {boolean}
258
+ */
259
+ _classPrivateMethodInitSpec(this, _onAfterIsMultipleSelection);
260
+ /**
261
+ * `afterInit` hook callback.
262
+ */
263
+ _classPrivateMethodInitSpec(this, _onAfterInit);
75
264
  /**
76
265
  * A container for all the merged cells.
77
266
  *
78
267
  * @private
79
268
  * @type {MergedCellsCollection}
80
269
  */
81
- this.mergedCellsCollection = null;
270
+ _defineProperty(this, "mergedCellsCollection", null);
82
271
  /**
83
272
  * Instance of the class responsible for all the autofill-related calculations.
84
273
  *
85
274
  * @private
86
275
  * @type {AutofillCalculations}
87
276
  */
88
- this.autofillCalculations = null;
277
+ _defineProperty(this, "autofillCalculations", null);
89
278
  /**
90
279
  * Instance of the class responsible for the selection-related calculations.
91
280
  *
92
281
  * @private
93
282
  * @type {SelectionCalculations}
94
283
  */
95
- this.selectionCalculations = null;
284
+ _defineProperty(this, "selectionCalculations", null);
285
+ /**
286
+ * @type {CellCoords}
287
+ */
288
+ _classPrivateFieldInitSpec(this, _lastDesiredCoords, {
289
+ writable: true,
290
+ value: null
291
+ });
292
+ }
293
+ static get PLUGIN_KEY() {
294
+ return PLUGIN_KEY;
295
+ }
296
+ static get PLUGIN_PRIORITY() {
297
+ return PLUGIN_PRIORITY;
96
298
  }
97
-
98
299
  /**
99
300
  * Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
100
301
  * hook and if it returns `true` then the {@link MergeCells#enablePlugin} method is called.
@@ -117,73 +318,142 @@ export class MergeCells extends BasePlugin {
117
318
  this.autofillCalculations = new AutofillCalculations(this);
118
319
  this.selectionCalculations = new SelectionCalculations(this);
119
320
  this.addHook('afterInit', function () {
120
- return _this.onAfterInit(...arguments);
321
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
322
+ args[_key] = arguments[_key];
323
+ }
324
+ return _classPrivateMethodGet(_this, _onAfterInit, _onAfterInit2).call(_this, ...args);
121
325
  });
122
326
  this.addHook('modifyTransformStart', function () {
123
- return _this.onModifyTransformStart(...arguments);
327
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
328
+ args[_key2] = arguments[_key2];
329
+ }
330
+ return _classPrivateMethodGet(_this, _onModifyTransformStart, _onModifyTransformStart2).call(_this, ...args);
124
331
  });
125
332
  this.addHook('afterModifyTransformStart', function () {
126
- return _this.onAfterModifyTransformStart(...arguments);
333
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
334
+ args[_key3] = arguments[_key3];
335
+ }
336
+ return _classPrivateMethodGet(_this, _onAfterModifyTransformStart, _onAfterModifyTransformStart2).call(_this, ...args);
127
337
  });
128
338
  this.addHook('modifyTransformEnd', function () {
129
- return _this.onModifyTransformEnd(...arguments);
339
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
340
+ args[_key4] = arguments[_key4];
341
+ }
342
+ return _classPrivateMethodGet(_this, _onModifyTransformEnd, _onModifyTransformEnd2).call(_this, ...args);
130
343
  });
131
344
  this.addHook('modifyGetCellCoords', function () {
132
- return _this.onModifyGetCellCoords(...arguments);
345
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
346
+ args[_key5] = arguments[_key5];
347
+ }
348
+ return _classPrivateMethodGet(_this, _onModifyGetCellCoords, _onModifyGetCellCoords2).call(_this, ...args);
133
349
  });
134
350
  this.addHook('beforeSetRangeStart', function () {
135
- return _this.onBeforeSetRangeStart(...arguments);
351
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
352
+ args[_key6] = arguments[_key6];
353
+ }
354
+ return _classPrivateMethodGet(_this, _onBeforeSetRangeStart, _onBeforeSetRangeStart2).call(_this, ...args);
136
355
  });
137
356
  this.addHook('beforeSetRangeStartOnly', function () {
138
- return _this.onBeforeSetRangeStart(...arguments);
357
+ for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
358
+ args[_key7] = arguments[_key7];
359
+ }
360
+ return _classPrivateMethodGet(_this, _onBeforeSetRangeStart, _onBeforeSetRangeStart2).call(_this, ...args);
139
361
  });
140
362
  this.addHook('beforeSetRangeEnd', function () {
141
- return _this.onBeforeSetRangeEnd(...arguments);
363
+ for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
364
+ args[_key8] = arguments[_key8];
365
+ }
366
+ return _classPrivateMethodGet(_this, _onBeforeSetRangeEnd, _onBeforeSetRangeEnd2).call(_this, ...args);
142
367
  });
143
368
  this.addHook('afterIsMultipleSelection', function () {
144
- return _this.onAfterIsMultipleSelection(...arguments);
369
+ for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
370
+ args[_key9] = arguments[_key9];
371
+ }
372
+ return _classPrivateMethodGet(_this, _onAfterIsMultipleSelection, _onAfterIsMultipleSelection2).call(_this, ...args);
145
373
  });
146
374
  this.addHook('afterRenderer', function () {
147
- return _this.onAfterRenderer(...arguments);
375
+ for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
376
+ args[_key10] = arguments[_key10];
377
+ }
378
+ return _classPrivateMethodGet(_this, _onAfterRenderer, _onAfterRenderer2).call(_this, ...args);
148
379
  });
149
380
  this.addHook('afterContextMenuDefaultOptions', function () {
150
- return _this.addMergeActionsToContextMenu(...arguments);
381
+ for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
382
+ args[_key11] = arguments[_key11];
383
+ }
384
+ return _classPrivateMethodGet(_this, _addMergeActionsToContextMenu, _addMergeActionsToContextMenu2).call(_this, ...args);
151
385
  });
152
386
  this.addHook('afterGetCellMeta', function () {
153
- return _this.onAfterGetCellMeta(...arguments);
387
+ for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
388
+ args[_key12] = arguments[_key12];
389
+ }
390
+ return _classPrivateMethodGet(_this, _onAfterGetCellMeta, _onAfterGetCellMeta2).call(_this, ...args);
154
391
  });
155
392
  this.addHook('afterViewportRowCalculatorOverride', function () {
156
- return _this.onAfterViewportRowCalculatorOverride(...arguments);
393
+ for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
394
+ args[_key13] = arguments[_key13];
395
+ }
396
+ return _classPrivateMethodGet(_this, _onAfterViewportRowCalculatorOverride, _onAfterViewportRowCalculatorOverride2).call(_this, ...args);
157
397
  });
158
398
  this.addHook('afterViewportColumnCalculatorOverride', function () {
159
- return _this.onAfterViewportColumnCalculatorOverride(...arguments);
399
+ for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
400
+ args[_key14] = arguments[_key14];
401
+ }
402
+ return _classPrivateMethodGet(_this, _onAfterViewportColumnCalculatorOverride, _onAfterViewportColumnCalculatorOverride2).call(_this, ...args);
160
403
  });
161
404
  this.addHook('modifyAutofillRange', function () {
162
- return _this.onModifyAutofillRange(...arguments);
405
+ for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
406
+ args[_key15] = arguments[_key15];
407
+ }
408
+ return _classPrivateMethodGet(_this, _onModifyAutofillRange, _onModifyAutofillRange2).call(_this, ...args);
163
409
  });
164
410
  this.addHook('afterCreateCol', function () {
165
- return _this.onAfterCreateCol(...arguments);
411
+ for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
412
+ args[_key16] = arguments[_key16];
413
+ }
414
+ return _classPrivateMethodGet(_this, _onAfterCreateCol, _onAfterCreateCol2).call(_this, ...args);
166
415
  });
167
416
  this.addHook('afterRemoveCol', function () {
168
- return _this.onAfterRemoveCol(...arguments);
417
+ for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
418
+ args[_key17] = arguments[_key17];
419
+ }
420
+ return _classPrivateMethodGet(_this, _onAfterRemoveCol, _onAfterRemoveCol2).call(_this, ...args);
169
421
  });
170
422
  this.addHook('afterCreateRow', function () {
171
- return _this.onAfterCreateRow(...arguments);
423
+ for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
424
+ args[_key18] = arguments[_key18];
425
+ }
426
+ return _classPrivateMethodGet(_this, _onAfterCreateRow, _onAfterCreateRow2).call(_this, ...args);
172
427
  });
173
428
  this.addHook('afterRemoveRow', function () {
174
- return _this.onAfterRemoveRow(...arguments);
429
+ for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
430
+ args[_key19] = arguments[_key19];
431
+ }
432
+ return _classPrivateMethodGet(_this, _onAfterRemoveRow, _onAfterRemoveRow2).call(_this, ...args);
175
433
  });
176
434
  this.addHook('afterChange', function () {
177
- return _this.onAfterChange(...arguments);
435
+ for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
436
+ args[_key20] = arguments[_key20];
437
+ }
438
+ return _classPrivateMethodGet(_this, _onAfterChange, _onAfterChange2).call(_this, ...args);
178
439
  });
179
440
  this.addHook('beforeDrawBorders', function () {
180
- return _this.onBeforeDrawAreaBorders(...arguments);
441
+ for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
442
+ args[_key21] = arguments[_key21];
443
+ }
444
+ return _classPrivateMethodGet(_this, _onBeforeDrawAreaBorders, _onBeforeDrawAreaBorders2).call(_this, ...args);
181
445
  });
182
446
  this.addHook('afterDrawSelection', function () {
183
- return _this.onAfterDrawSelection(...arguments);
447
+ for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
448
+ args[_key22] = arguments[_key22];
449
+ }
450
+ return _classPrivateMethodGet(_this, _onAfterDrawSelection, _onAfterDrawSelection2).call(_this, ...args);
184
451
  });
185
452
  this.addHook('beforeRemoveCellClassNames', function () {
186
- return _this.onBeforeRemoveCellClassNames(...arguments);
453
+ for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
454
+ args[_key23] = arguments[_key23];
455
+ }
456
+ return _classPrivateMethodGet(_this, _onBeforeRemoveCellClassNames, _onBeforeRemoveCellClassNames2).call(_this, ...args);
187
457
  });
188
458
  this.addHook('beforeUndoStackChange', (action, source) => {
189
459
  if (source === 'MergeCells') {
@@ -458,7 +728,7 @@ export class MergeCells extends BasePlugin {
458
728
  if (preventPopulation) {
459
729
  populationInfo = [mergeParent.row, mergeParent.col, clearedData];
460
730
  } else {
461
- this.hot.populateFromArray(mergeParent.row, mergeParent.col, clearedData, void 0, void 0, this.pluginName);
731
+ this.hot.populateFromArray(mergeParent.row, mergeParent.col, clearedData, undefined, undefined, this.pluginName);
462
732
  }
463
733
  if (!auto) {
464
734
  this.ifChromeForceRepaint();
@@ -547,17 +817,6 @@ export class MergeCells extends BasePlugin {
547
817
  const end = this.hot._createCellCoords(endRow, endColumn);
548
818
  this.unmergeRange(this.hot._createCellRange(start, start, end));
549
819
  }
550
-
551
- /**
552
- * `afterInit` hook callback.
553
- *
554
- * @private
555
- */
556
- onAfterInit() {
557
- this.generateFromSettings(this.hot.getSettings()[PLUGIN_KEY]);
558
- this.hot.render();
559
- }
560
-
561
820
  /**
562
821
  * Register shortcuts responsible for toggling a merge.
563
822
  *
@@ -591,280 +850,6 @@ export class MergeCells extends BasePlugin {
591
850
  const gridContext = shortcutManager.getContext('grid');
592
851
  gridContext.removeShortcutsByGroup(SHORTCUTS_GROUP);
593
852
  }
594
-
595
- /**
596
- * Modifies the information on whether the current selection contains multiple cells. The `afterIsMultipleSelection`
597
- * hook callback.
598
- *
599
- * @private
600
- * @param {boolean} isMultiple Determines whether the current selection contains multiple cells.
601
- * @returns {boolean}
602
- */
603
- onAfterIsMultipleSelection(isMultiple) {
604
- if (isMultiple) {
605
- const mergedCells = this.mergedCellsCollection.mergedCells;
606
- const selectionRange = this.hot.getSelectedRangeLast();
607
- for (let group = 0; group < mergedCells.length; group += 1) {
608
- if (selectionRange.from.row === mergedCells[group].row && selectionRange.from.col === mergedCells[group].col && selectionRange.to.row === mergedCells[group].row + mergedCells[group].rowspan - 1 && selectionRange.to.col === mergedCells[group].col + mergedCells[group].colspan - 1) {
609
- return false;
610
- }
611
- }
612
- }
613
- return isMultiple;
614
- }
615
-
616
- /**
617
- * `modifyTransformStart` hook callback.
618
- *
619
- * @private
620
- * @param {object} delta The transformation delta.
621
- */
622
- onModifyTransformStart(delta) {
623
- const priv = privatePool.get(this);
624
- const currentlySelectedRange = this.hot.getSelectedRangeLast();
625
- let newDelta = {
626
- row: delta.row,
627
- col: delta.col
628
- };
629
- let nextPosition = null;
630
- const currentPosition = this.hot._createCellCoords(currentlySelectedRange.highlight.row, currentlySelectedRange.highlight.col);
631
- const mergedParent = this.mergedCellsCollection.get(currentPosition.row, currentPosition.col);
632
- if (!priv.lastDesiredCoords) {
633
- priv.lastDesiredCoords = this.hot._createCellCoords(null, null);
634
- }
635
- if (mergedParent) {
636
- // only merge selected
637
- const mergeTopLeft = this.hot._createCellCoords(mergedParent.row, mergedParent.col);
638
- const mergeBottomRight = this.hot._createCellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1);
639
- const mergeRange = this.hot._createCellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight);
640
- if (!mergeRange.includes(priv.lastDesiredCoords)) {
641
- priv.lastDesiredCoords = this.hot._createCellCoords(null, null); // reset outdated version of lastDesiredCoords
642
- }
643
-
644
- newDelta.row = priv.lastDesiredCoords.row ? priv.lastDesiredCoords.row - currentPosition.row : newDelta.row;
645
- newDelta.col = priv.lastDesiredCoords.col ? priv.lastDesiredCoords.col - currentPosition.col : newDelta.col;
646
- if (delta.row > 0) {
647
- // moving down
648
- newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row;
649
- } else if (delta.row < 0) {
650
- // moving up
651
- newDelta.row = currentPosition.row - mergedParent.row + delta.row;
652
- }
653
- if (delta.col > 0) {
654
- // moving right
655
- newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col;
656
- } else if (delta.col < 0) {
657
- // moving left
658
- newDelta.col = currentPosition.col - mergedParent.col + delta.col;
659
- }
660
- }
661
- nextPosition = this.hot._createCellCoords(currentlySelectedRange.highlight.row + newDelta.row, currentlySelectedRange.highlight.col + newDelta.col);
662
- const nextPositionMergedCell = this.mergedCellsCollection.get(nextPosition.row, nextPosition.col);
663
- if (nextPositionMergedCell) {
664
- // skipping the invisible cells in the merge range
665
- const firstRenderableCoords = this.mergedCellsCollection.getFirstRenderableCoords(nextPositionMergedCell.row, nextPositionMergedCell.col);
666
- priv.lastDesiredCoords = nextPosition;
667
- newDelta = {
668
- row: firstRenderableCoords.row - currentPosition.row,
669
- col: firstRenderableCoords.col - currentPosition.col
670
- };
671
- }
672
- if (newDelta.row !== 0) {
673
- delta.row = newDelta.row;
674
- }
675
- if (newDelta.col !== 0) {
676
- delta.col = newDelta.col;
677
- }
678
- }
679
-
680
- /**
681
- * `modifyTransformEnd` hook callback. Needed to handle "jumping over" merged merged cells, while selecting.
682
- *
683
- * @private
684
- * @param {object} delta The transformation delta.
685
- */
686
- onModifyTransformEnd(delta) {
687
- const currentSelectionRange = this.hot.getSelectedRangeLast();
688
- const newDelta = clone(delta);
689
- const newSelectionRange = this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, delta);
690
- let tempDelta = clone(newDelta);
691
- const mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(newSelectionRange, true);
692
- do {
693
- tempDelta = clone(newDelta);
694
- this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, newDelta);
695
- arrayEach(mergedCellsWithinRange, mergedCell => {
696
- this.selectionCalculations.snapDelta(newDelta, currentSelectionRange, mergedCell);
697
- });
698
- } while (newDelta.row !== tempDelta.row || newDelta.col !== tempDelta.col);
699
- delta.row = newDelta.row;
700
- delta.col = newDelta.col;
701
- }
702
-
703
- /**
704
- * `modifyGetCellCoords` hook callback. Swaps the `getCell` coords with the merged parent coords.
705
- *
706
- * @private
707
- * @param {number} row Row index.
708
- * @param {number} column Visual column index.
709
- * @returns {Array|undefined} Visual coordinates of the merge.
710
- */
711
- onModifyGetCellCoords(row, column) {
712
- if (row < 0 || column < 0) {
713
- return;
714
- }
715
- const mergeParent = this.mergedCellsCollection.get(row, column);
716
- if (!mergeParent) {
717
- return;
718
- }
719
- const {
720
- row: mergeRow,
721
- col: mergeColumn,
722
- colspan,
723
- rowspan
724
- } = mergeParent;
725
- return [
726
- // Most top-left merged cell coords.
727
- mergeRow, mergeColumn,
728
- // Most bottom-right merged cell coords.
729
- mergeRow + rowspan - 1, mergeColumn + colspan - 1];
730
- }
731
-
732
- /**
733
- * `afterContextMenuDefaultOptions` hook callback.
734
- *
735
- * @private
736
- * @param {object} defaultOptions The default context menu options.
737
- */
738
- addMergeActionsToContextMenu(defaultOptions) {
739
- defaultOptions.items.push({
740
- name: '---------'
741
- }, toggleMergeItem(this));
742
- }
743
-
744
- /**
745
- * `afterRenderer` hook callback.
746
- *
747
- * @private
748
- * @param {HTMLElement} TD The cell to be modified.
749
- * @param {number} row Row index.
750
- * @param {number} col Visual column index.
751
- */
752
- onAfterRenderer(TD, row, col) {
753
- const mergedCell = this.mergedCellsCollection.get(row, col);
754
- // We shouldn't override data in the collection.
755
- const mergedCellCopy = isObject(mergedCell) ? clone(mergedCell) : void 0;
756
- if (isObject(mergedCellCopy)) {
757
- const {
758
- rowIndexMapper: rowMapper,
759
- columnIndexMapper: columnMapper
760
- } = this.hot;
761
- const {
762
- row: mergeRow,
763
- col: mergeColumn,
764
- colspan,
765
- rowspan
766
- } = mergedCellCopy;
767
- const [lastMergedRowIndex, lastMergedColumnIndex] = this.translateMergedCellToRenderable(mergeRow, rowspan, mergeColumn, colspan);
768
- const renderedRowIndex = rowMapper.getRenderableFromVisualIndex(row);
769
- const renderedColumnIndex = columnMapper.getRenderableFromVisualIndex(col);
770
- const maxRowSpan = lastMergedRowIndex - renderedRowIndex + 1; // Number of rendered columns.
771
- const maxColSpan = lastMergedColumnIndex - renderedColumnIndex + 1; // Number of rendered columns.
772
-
773
- // We just try to determine some values basing on the actual number of rendered indexes (some columns may be hidden).
774
- mergedCellCopy.row = rowMapper.getNearestNotHiddenIndex(mergedCellCopy.row, 1);
775
- // We just try to determine some values basing on the actual number of rendered indexes (some columns may be hidden).
776
- mergedCellCopy.col = columnMapper.getNearestNotHiddenIndex(mergedCellCopy.col, 1);
777
- // The `rowSpan` property for a `TD` element should be at most equal to number of rendered rows in the merge area.
778
- mergedCellCopy.rowspan = Math.min(mergedCellCopy.rowspan, maxRowSpan);
779
- // The `colSpan` property for a `TD` element should be at most equal to number of rendered columns in the merge area.
780
- mergedCellCopy.colspan = Math.min(mergedCellCopy.colspan, maxColSpan);
781
- }
782
- applySpanProperties(TD, mergedCellCopy, row, col);
783
- }
784
-
785
- /**
786
- * `beforeSetRangeStart` and `beforeSetRangeStartOnly` hook callback.
787
- * A selection within merge area should be rewritten to the start of merge area.
788
- *
789
- * @private
790
- * @param {object} coords Cell coords.
791
- */
792
- onBeforeSetRangeStart(coords) {
793
- // TODO: It is a workaround, but probably this hook may be needed. Every selection on the merge area
794
- // could set start point of the selection to the start of the merge area. However, logic inside `expandByRange` need
795
- // an initial start point. Click on the merge cell when there are some hidden indexes break the logic in some cases.
796
- // Please take a look at #7010 for more information. I'm not sure if selection directions are calculated properly
797
- // and what was idea for flipping direction inside `expandByRange` method.
798
- if (this.mergedCellsCollection.isFirstRenderableMergedCell(coords.row, coords.col)) {
799
- const mergeParent = this.mergedCellsCollection.get(coords.row, coords.col);
800
- [coords.row, coords.col] = [mergeParent.row, mergeParent.col];
801
- }
802
- }
803
-
804
- /**
805
- * `beforeSetRangeEnd` hook callback.
806
- * While selecting cells with keyboard or mouse, make sure that rectangular area is expanded to the extent of the
807
- * merged cell.
808
- *
809
- * Note: Please keep in mind that callback may modify both start and end range coordinates by the reference.
810
- *
811
- * @private
812
- * @param {object} coords Cell coords.
813
- */
814
- onBeforeSetRangeEnd(coords) {
815
- const selRange = this.hot.getSelectedRangeLast();
816
- selRange.highlight = this.hot._createCellCoords(selRange.highlight.row, selRange.highlight.col); // clone in case we will modify its reference
817
- selRange.to = coords;
818
- let rangeExpanded = false;
819
- if (this.hot.selection.isSelectedByColumnHeader() || this.hot.selection.isSelectedByRowHeader()) {
820
- return;
821
- }
822
- do {
823
- rangeExpanded = false;
824
- for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
825
- const cellInfo = this.mergedCellsCollection.mergedCells[i];
826
- const mergedCellRange = cellInfo.getRange();
827
- if (selRange.expandByRange(mergedCellRange)) {
828
- coords.row = selRange.to.row;
829
- coords.col = selRange.to.col;
830
- rangeExpanded = true;
831
- }
832
- }
833
- } while (rangeExpanded);
834
- }
835
-
836
- /**
837
- * The `afterGetCellMeta` hook callback.
838
- *
839
- * @private
840
- * @param {number} row Row index.
841
- * @param {number} col Column index.
842
- * @param {object} cellProperties The cell properties object.
843
- */
844
- onAfterGetCellMeta(row, col, cellProperties) {
845
- const mergeParent = this.mergedCellsCollection.get(row, col);
846
- if (mergeParent) {
847
- if (mergeParent.row !== row || mergeParent.col !== col) {
848
- cellProperties.copyable = false;
849
- } else {
850
- cellProperties.rowspan = mergeParent.rowspan;
851
- cellProperties.colspan = mergeParent.colspan;
852
- }
853
- }
854
- }
855
-
856
- /**
857
- * `afterViewportRowCalculatorOverride` hook callback.
858
- *
859
- * @private
860
- * @param {object} calc The row calculator object.
861
- */
862
- onAfterViewportRowCalculatorOverride(calc) {
863
- const nrOfColumns = this.hot.countCols();
864
- this.modifyViewportRowStart(calc, nrOfColumns);
865
- this.modifyViewportRowEnd(calc, nrOfColumns);
866
- }
867
-
868
853
  /**
869
854
  * Modify viewport start when needed. We extend viewport when merged cells aren't fully visible.
870
855
  *
@@ -922,18 +907,6 @@ export class MergeCells extends BasePlugin {
922
907
  }
923
908
  }
924
909
 
925
- /**
926
- * `afterViewportColumnCalculatorOverride` hook callback.
927
- *
928
- * @private
929
- * @param {object} calc The column calculator object.
930
- */
931
- onAfterViewportColumnCalculatorOverride(calc) {
932
- const nrOfRows = this.hot.countRows();
933
- this.modifyViewportColumnStart(calc, nrOfRows);
934
- this.modifyViewportColumnEnd(calc, nrOfRows);
935
- }
936
-
937
910
  /**
938
911
  * Modify viewport start when needed. We extend viewport when merged cells aren't fully visible.
939
912
  *
@@ -1028,183 +1001,290 @@ export class MergeCells extends BasePlugin {
1028
1001
  const renderableColumn = parentColumn >= 0 ? columnMapper.getRenderableFromVisualIndex(firstNonHiddenColumn) : parentColumn;
1029
1002
  return [renderableRow, renderableColumn];
1030
1003
  }
1031
-
1032
- /**
1033
- * The `modifyAutofillRange` hook callback.
1034
- *
1035
- * @private
1036
- * @param {Array} drag The drag area coordinates.
1037
- * @param {Array} select The selection information.
1038
- * @returns {Array} The new drag area.
1039
- */
1040
- onModifyAutofillRange(drag, select) {
1041
- this.autofillCalculations.correctSelectionAreaSize(select);
1042
- const dragDirection = this.autofillCalculations.getDirection(select, drag);
1043
- let dragArea = drag;
1044
- if (this.autofillCalculations.dragAreaOverlapsCollections(select, dragArea, dragDirection)) {
1045
- dragArea = select;
1046
- return dragArea;
1047
- }
1048
- const mergedCellsWithinSelectionArea = this.mergedCellsCollection.getWithinRange({
1049
- from: {
1050
- row: select[0],
1051
- col: select[1]
1052
- },
1053
- to: {
1054
- row: select[2],
1055
- col: select[3]
1004
+ }
1005
+ function _onAfterInit2() {
1006
+ this.generateFromSettings(this.hot.getSettings()[PLUGIN_KEY]);
1007
+ this.hot.render();
1008
+ }
1009
+ function _onAfterIsMultipleSelection2(isMultiple) {
1010
+ if (isMultiple) {
1011
+ const mergedCells = this.mergedCellsCollection.mergedCells;
1012
+ const selectionRange = this.hot.getSelectedRangeLast();
1013
+ for (let group = 0; group < mergedCells.length; group += 1) {
1014
+ if (selectionRange.from.row === mergedCells[group].row && selectionRange.from.col === mergedCells[group].col && selectionRange.to.row === mergedCells[group].row + mergedCells[group].rowspan - 1 && selectionRange.to.col === mergedCells[group].col + mergedCells[group].colspan - 1) {
1015
+ return false;
1056
1016
  }
1057
- });
1058
- if (!mergedCellsWithinSelectionArea) {
1059
- return dragArea;
1060
1017
  }
1061
- dragArea = this.autofillCalculations.snapDragArea(select, dragArea, dragDirection, mergedCellsWithinSelectionArea);
1062
- return dragArea;
1063
- }
1064
-
1065
- /**
1066
- * `afterCreateCol` hook callback.
1067
- *
1068
- * @private
1069
- * @param {number} column Column index.
1070
- * @param {number} count Number of created columns.
1071
- */
1072
- onAfterCreateCol(column, count) {
1073
- this.mergedCellsCollection.shiftCollections('right', column, count);
1074
1018
  }
1075
-
1076
- /**
1077
- * `afterRemoveCol` hook callback.
1078
- *
1079
- * @private
1080
- * @param {number} column Column index.
1081
- * @param {number} count Number of removed columns.
1082
- */
1083
- onAfterRemoveCol(column, count) {
1084
- this.mergedCellsCollection.shiftCollections('left', column, count);
1019
+ return isMultiple;
1020
+ }
1021
+ function _onModifyTransformStart2(delta) {
1022
+ const currentlySelectedRange = this.hot.getSelectedRangeLast();
1023
+ let newDelta = {
1024
+ row: delta.row,
1025
+ col: delta.col
1026
+ };
1027
+ let nextPosition = null;
1028
+ const currentPosition = this.hot._createCellCoords(currentlySelectedRange.highlight.row, currentlySelectedRange.highlight.col);
1029
+ const mergedParent = this.mergedCellsCollection.get(currentPosition.row, currentPosition.col);
1030
+ if (!_classPrivateFieldGet(this, _lastDesiredCoords)) {
1031
+ _classPrivateFieldSet(this, _lastDesiredCoords, this.hot._createCellCoords(null, null));
1085
1032
  }
1033
+ if (mergedParent) {
1034
+ // only merge selected
1035
+ const mergeTopLeft = this.hot._createCellCoords(mergedParent.row, mergedParent.col);
1036
+ const mergeBottomRight = this.hot._createCellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1);
1037
+ const mergeRange = this.hot._createCellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight);
1038
+ if (!mergeRange.includes(_classPrivateFieldGet(this, _lastDesiredCoords))) {
1039
+ _classPrivateFieldSet(this, _lastDesiredCoords, this.hot._createCellCoords(null, null)); // reset outdated version of lastDesiredCoords
1040
+ }
1086
1041
 
1087
- /**
1088
- * `afterCreateRow` hook callback.
1089
- *
1090
- * @private
1091
- * @param {number} row Row index.
1092
- * @param {number} count Number of created rows.
1093
- * @param {string} source Source of change.
1094
- */
1095
- onAfterCreateRow(row, count, source) {
1096
- if (source === 'auto') {
1097
- return;
1042
+ newDelta.row = _classPrivateFieldGet(this, _lastDesiredCoords).row ? _classPrivateFieldGet(this, _lastDesiredCoords).row - currentPosition.row : newDelta.row;
1043
+ newDelta.col = _classPrivateFieldGet(this, _lastDesiredCoords).col ? _classPrivateFieldGet(this, _lastDesiredCoords).col - currentPosition.col : newDelta.col;
1044
+ if (delta.row > 0) {
1045
+ // moving down
1046
+ newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row;
1047
+ } else if (delta.row < 0) {
1048
+ // moving up
1049
+ newDelta.row = currentPosition.row - mergedParent.row + delta.row;
1050
+ }
1051
+ if (delta.col > 0) {
1052
+ // moving right
1053
+ newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col;
1054
+ } else if (delta.col < 0) {
1055
+ // moving left
1056
+ newDelta.col = currentPosition.col - mergedParent.col + delta.col;
1098
1057
  }
1099
- this.mergedCellsCollection.shiftCollections('down', row, count);
1100
1058
  }
1101
-
1102
- /**
1103
- * `afterRemoveRow` hook callback.
1104
- *
1105
- * @private
1106
- * @param {number} row Row index.
1107
- * @param {number} count Number of removed rows.
1108
- */
1109
- onAfterRemoveRow(row, count) {
1110
- this.mergedCellsCollection.shiftCollections('up', row, count);
1059
+ nextPosition = this.hot._createCellCoords(currentlySelectedRange.highlight.row + newDelta.row, currentlySelectedRange.highlight.col + newDelta.col);
1060
+ const nextPositionMergedCell = this.mergedCellsCollection.get(nextPosition.row, nextPosition.col);
1061
+ if (nextPositionMergedCell) {
1062
+ // skipping the invisible cells in the merge range
1063
+ const firstRenderableCoords = this.mergedCellsCollection.getFirstRenderableCoords(nextPositionMergedCell.row, nextPositionMergedCell.col);
1064
+ _classPrivateFieldSet(this, _lastDesiredCoords, nextPosition);
1065
+ newDelta = {
1066
+ row: firstRenderableCoords.row - currentPosition.row,
1067
+ col: firstRenderableCoords.col - currentPosition.col
1068
+ };
1111
1069
  }
1112
-
1113
- /**
1114
- * `afterChange` hook callback. Used to propagate merged cells after using Autofill.
1115
- *
1116
- * @private
1117
- * @param {Array} changes The changes array.
1118
- * @param {string} source Determines the source of the change.
1119
- */
1120
- onAfterChange(changes, source) {
1121
- if (source !== 'Autofill.fill') {
1122
- return;
1123
- }
1124
- this.autofillCalculations.recreateAfterDataPopulation(changes);
1070
+ if (newDelta.row !== 0) {
1071
+ delta.row = newDelta.row;
1125
1072
  }
1126
-
1127
- /**
1128
- * `beforeDrawAreaBorders` hook callback.
1129
- *
1130
- * @private
1131
- * @param {Array} corners Visual coordinates of the area corners.
1132
- * @param {string} className Class name for the area.
1133
- */
1134
- onBeforeDrawAreaBorders(corners, className) {
1135
- if (className && className === 'area') {
1136
- const selectedRange = this.hot.getSelectedRangeLast();
1137
- const mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(selectedRange);
1138
- arrayEach(mergedCellsWithinRange, mergedCell => {
1139
- if (selectedRange.getBottomEndCorner().row === mergedCell.getLastRow() && selectedRange.getBottomEndCorner().col === mergedCell.getLastColumn()) {
1140
- corners[2] = mergedCell.row;
1141
- corners[3] = mergedCell.col;
1142
- }
1143
- });
1144
- }
1073
+ if (newDelta.col !== 0) {
1074
+ delta.col = newDelta.col;
1075
+ }
1076
+ }
1077
+ function _onModifyTransformEnd2(delta) {
1078
+ const currentSelectionRange = this.hot.getSelectedRangeLast();
1079
+ const newDelta = clone(delta);
1080
+ const newSelectionRange = this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, delta);
1081
+ let tempDelta = clone(newDelta);
1082
+ const mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(newSelectionRange, true);
1083
+ do {
1084
+ tempDelta = clone(newDelta);
1085
+ this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, newDelta);
1086
+ arrayEach(mergedCellsWithinRange, mergedCell => {
1087
+ this.selectionCalculations.snapDelta(newDelta, currentSelectionRange, mergedCell);
1088
+ });
1089
+ } while (newDelta.row !== tempDelta.row || newDelta.col !== tempDelta.col);
1090
+ delta.row = newDelta.row;
1091
+ delta.col = newDelta.col;
1092
+ }
1093
+ function _onModifyGetCellCoords2(row, column) {
1094
+ if (row < 0 || column < 0) {
1095
+ return;
1096
+ }
1097
+ const mergeParent = this.mergedCellsCollection.get(row, column);
1098
+ if (!mergeParent) {
1099
+ return;
1145
1100
  }
1101
+ const {
1102
+ row: mergeRow,
1103
+ col: mergeColumn,
1104
+ colspan,
1105
+ rowspan
1106
+ } = mergeParent;
1107
+ return [
1108
+ // Most top-left merged cell coords.
1109
+ mergeRow, mergeColumn,
1110
+ // Most bottom-right merged cell coords.
1111
+ mergeRow + rowspan - 1, mergeColumn + colspan - 1];
1112
+ }
1113
+ function _addMergeActionsToContextMenu2(defaultOptions) {
1114
+ defaultOptions.items.push({
1115
+ name: '---------'
1116
+ }, toggleMergeItem(this));
1117
+ }
1118
+ function _onAfterRenderer2(TD, row, col) {
1119
+ const mergedCell = this.mergedCellsCollection.get(row, col);
1120
+ // We shouldn't override data in the collection.
1121
+ const mergedCellCopy = isObject(mergedCell) ? clone(mergedCell) : undefined;
1122
+ if (isObject(mergedCellCopy)) {
1123
+ const {
1124
+ rowIndexMapper: rowMapper,
1125
+ columnIndexMapper: columnMapper
1126
+ } = this.hot;
1127
+ const {
1128
+ row: mergeRow,
1129
+ col: mergeColumn,
1130
+ colspan,
1131
+ rowspan
1132
+ } = mergedCellCopy;
1133
+ const [lastMergedRowIndex, lastMergedColumnIndex] = this.translateMergedCellToRenderable(mergeRow, rowspan, mergeColumn, colspan);
1134
+ const renderedRowIndex = rowMapper.getRenderableFromVisualIndex(row);
1135
+ const renderedColumnIndex = columnMapper.getRenderableFromVisualIndex(col);
1136
+ const maxRowSpan = lastMergedRowIndex - renderedRowIndex + 1; // Number of rendered columns.
1137
+ const maxColSpan = lastMergedColumnIndex - renderedColumnIndex + 1; // Number of rendered columns.
1146
1138
 
1147
- /**
1148
- * `afterModifyTransformStart` hook callback. Fixes a problem with navigating through merged cells at the edges of
1149
- * the table with the ENTER/SHIFT+ENTER/TAB/SHIFT+TAB keys.
1150
- *
1151
- * @private
1152
- * @param {CellCoords} coords Coordinates of the to-be-selected cell.
1153
- * @param {number} rowTransformDir Row transformation direction (negative value = up, 0 = none, positive value =
1154
- * down).
1155
- * @param {number} colTransformDir Column transformation direction (negative value = up, 0 = none, positive value =
1156
- * down).
1157
- */
1158
- onAfterModifyTransformStart(coords, rowTransformDir, colTransformDir) {
1159
- if (!this.enabled) {
1160
- return;
1161
- }
1162
- const mergedCellAtCoords = this.mergedCellsCollection.get(coords.row, coords.col);
1163
- if (!mergedCellAtCoords) {
1164
- return;
1139
+ // We just try to determine some values basing on the actual number of rendered indexes (some columns may be hidden).
1140
+ mergedCellCopy.row = rowMapper.getNearestNotHiddenIndex(mergedCellCopy.row, 1);
1141
+ // We just try to determine some values basing on the actual number of rendered indexes (some columns may be hidden).
1142
+ mergedCellCopy.col = columnMapper.getNearestNotHiddenIndex(mergedCellCopy.col, 1);
1143
+ // The `rowSpan` property for a `TD` element should be at most equal to number of rendered rows in the merge area.
1144
+ mergedCellCopy.rowspan = Math.min(mergedCellCopy.rowspan, maxRowSpan);
1145
+ // The `colSpan` property for a `TD` element should be at most equal to number of rendered columns in the merge area.
1146
+ mergedCellCopy.colspan = Math.min(mergedCellCopy.colspan, maxColSpan);
1147
+ }
1148
+ applySpanProperties(TD, mergedCellCopy, row, col);
1149
+ }
1150
+ function _onBeforeSetRangeStart2(coords) {
1151
+ // TODO: It is a workaround, but probably this hook may be needed. Every selection on the merge area
1152
+ // could set start point of the selection to the start of the merge area. However, logic inside `expandByRange` need
1153
+ // an initial start point. Click on the merge cell when there are some hidden indexes break the logic in some cases.
1154
+ // Please take a look at #7010 for more information. I'm not sure if selection directions are calculated properly
1155
+ // and what was idea for flipping direction inside `expandByRange` method.
1156
+ if (this.mergedCellsCollection.isFirstRenderableMergedCell(coords.row, coords.col)) {
1157
+ const mergeParent = this.mergedCellsCollection.get(coords.row, coords.col);
1158
+ [coords.row, coords.col] = [mergeParent.row, mergeParent.col];
1159
+ }
1160
+ }
1161
+ function _onBeforeSetRangeEnd2(coords) {
1162
+ const selRange = this.hot.getSelectedRangeLast();
1163
+ selRange.highlight = this.hot._createCellCoords(selRange.highlight.row, selRange.highlight.col); // clone in case we will modify its reference
1164
+ selRange.to = coords;
1165
+ let rangeExpanded = false;
1166
+ if (this.hot.selection.isSelectedByColumnHeader() || this.hot.selection.isSelectedByRowHeader()) {
1167
+ return;
1168
+ }
1169
+ do {
1170
+ rangeExpanded = false;
1171
+ for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
1172
+ const cellInfo = this.mergedCellsCollection.mergedCells[i];
1173
+ const mergedCellRange = cellInfo.getRange();
1174
+ if (selRange.expandByRange(mergedCellRange)) {
1175
+ coords.row = selRange.to.row;
1176
+ coords.col = selRange.to.col;
1177
+ rangeExpanded = true;
1178
+ }
1165
1179
  }
1166
- const goingDown = rowTransformDir > 0;
1167
- const goingUp = rowTransformDir < 0;
1168
- const goingLeft = colTransformDir < 0;
1169
- const goingRight = colTransformDir > 0;
1170
- const mergedCellOnBottomEdge = mergedCellAtCoords.row + mergedCellAtCoords.rowspan - 1 === this.hot.countRows() - 1;
1171
- const mergedCellOnTopEdge = mergedCellAtCoords.row === 0;
1172
- const mergedCellOnRightEdge = mergedCellAtCoords.col + mergedCellAtCoords.colspan - 1 === this.hot.countCols() - 1;
1173
- const mergedCellOnLeftEdge = mergedCellAtCoords.col === 0;
1174
- if (goingDown && mergedCellOnBottomEdge || goingUp && mergedCellOnTopEdge || goingRight && mergedCellOnRightEdge || goingLeft && mergedCellOnLeftEdge) {
1175
- coords.row = mergedCellAtCoords.row;
1176
- coords.col = mergedCellAtCoords.col;
1180
+ } while (rangeExpanded);
1181
+ }
1182
+ function _onAfterGetCellMeta2(row, col, cellProperties) {
1183
+ const mergeParent = this.mergedCellsCollection.get(row, col);
1184
+ if (mergeParent) {
1185
+ if (mergeParent.row !== row || mergeParent.col !== col) {
1186
+ cellProperties.copyable = false;
1187
+ } else {
1188
+ cellProperties.rowspan = mergeParent.rowspan;
1189
+ cellProperties.colspan = mergeParent.colspan;
1177
1190
  }
1178
1191
  }
1179
-
1180
- /**
1181
- * `afterDrawSelection` hook callback. Used to add the additional class name for the entirely-selected merged cells.
1182
- *
1183
- * @private
1184
- * @param {number} currentRow Visual row index of the currently processed cell.
1185
- * @param {number} currentColumn Visual column index of the currently cell.
1186
- * @param {Array} cornersOfSelection Array of the current selection in a form of `[startRow, startColumn, endRow,
1187
- * endColumn]`.
1188
- * @param {number|undefined} layerLevel Number indicating which layer of selection is currently processed.
1189
- * @returns {string|undefined} A `String`, which will act as an additional `className` to be added to the currently
1190
- * processed cell.
1191
- */
1192
- onAfterDrawSelection(currentRow, currentColumn, cornersOfSelection, layerLevel) {
1193
- // Nothing's selected (hook might be triggered by the custom borders)
1194
- if (!cornersOfSelection) {
1195
- return;
1192
+ }
1193
+ function _onAfterViewportRowCalculatorOverride2(calc) {
1194
+ const nrOfColumns = this.hot.countCols();
1195
+ this.modifyViewportRowStart(calc, nrOfColumns);
1196
+ this.modifyViewportRowEnd(calc, nrOfColumns);
1197
+ }
1198
+ function _onAfterViewportColumnCalculatorOverride2(calc) {
1199
+ const nrOfRows = this.hot.countRows();
1200
+ this.modifyViewportColumnStart(calc, nrOfRows);
1201
+ this.modifyViewportColumnEnd(calc, nrOfRows);
1202
+ }
1203
+ function _onModifyAutofillRange2(drag, select) {
1204
+ this.autofillCalculations.correctSelectionAreaSize(select);
1205
+ const dragDirection = this.autofillCalculations.getDirection(select, drag);
1206
+ let dragArea = drag;
1207
+ if (this.autofillCalculations.dragAreaOverlapsCollections(select, dragArea, dragDirection)) {
1208
+ dragArea = select;
1209
+ return dragArea;
1210
+ }
1211
+ const mergedCellsWithinSelectionArea = this.mergedCellsCollection.getWithinRange({
1212
+ from: {
1213
+ row: select[0],
1214
+ col: select[1]
1215
+ },
1216
+ to: {
1217
+ row: select[2],
1218
+ col: select[3]
1196
1219
  }
1197
- return this.selectionCalculations.getSelectedMergedCellClassName(currentRow, currentColumn, cornersOfSelection, layerLevel);
1220
+ });
1221
+ if (!mergedCellsWithinSelectionArea) {
1222
+ return dragArea;
1198
1223
  }
1199
-
1200
- /**
1201
- * `beforeRemoveCellClassNames` hook callback. Used to remove additional class name from all cells in the table.
1202
- *
1203
- * @private
1204
- * @returns {string[]} An `Array` of `String`s. Each of these strings will act like class names to be removed from
1205
- * all the cells in the table.
1206
- */
1207
- onBeforeRemoveCellClassNames() {
1208
- return this.selectionCalculations.getSelectedMergedCellClassNameToRemove();
1224
+ dragArea = this.autofillCalculations.snapDragArea(select, dragArea, dragDirection, mergedCellsWithinSelectionArea);
1225
+ return dragArea;
1226
+ }
1227
+ function _onAfterCreateCol2(column, count) {
1228
+ this.mergedCellsCollection.shiftCollections('right', column, count);
1229
+ }
1230
+ function _onAfterRemoveCol2(column, count) {
1231
+ this.mergedCellsCollection.shiftCollections('left', column, count);
1232
+ }
1233
+ function _onAfterCreateRow2(row, count, source) {
1234
+ if (source === 'auto') {
1235
+ return;
1236
+ }
1237
+ this.mergedCellsCollection.shiftCollections('down', row, count);
1238
+ }
1239
+ function _onAfterRemoveRow2(row, count) {
1240
+ this.mergedCellsCollection.shiftCollections('up', row, count);
1241
+ }
1242
+ function _onAfterChange2(changes, source) {
1243
+ if (source !== 'Autofill.fill') {
1244
+ return;
1245
+ }
1246
+ this.autofillCalculations.recreateAfterDataPopulation(changes);
1247
+ }
1248
+ function _onBeforeDrawAreaBorders2(corners, className) {
1249
+ if (className && className === 'area') {
1250
+ const selectedRange = this.hot.getSelectedRangeLast();
1251
+ const mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(selectedRange);
1252
+ arrayEach(mergedCellsWithinRange, mergedCell => {
1253
+ if (selectedRange.getBottomEndCorner().row === mergedCell.getLastRow() && selectedRange.getBottomEndCorner().col === mergedCell.getLastColumn()) {
1254
+ corners[2] = mergedCell.row;
1255
+ corners[3] = mergedCell.col;
1256
+ }
1257
+ });
1258
+ }
1259
+ }
1260
+ function _onAfterModifyTransformStart2(coords, rowTransformDir, colTransformDir) {
1261
+ if (!this.enabled) {
1262
+ return;
1263
+ }
1264
+ const mergedCellAtCoords = this.mergedCellsCollection.get(coords.row, coords.col);
1265
+ if (!mergedCellAtCoords) {
1266
+ return;
1267
+ }
1268
+ const goingDown = rowTransformDir > 0;
1269
+ const goingUp = rowTransformDir < 0;
1270
+ const goingLeft = colTransformDir < 0;
1271
+ const goingRight = colTransformDir > 0;
1272
+ const mergedCellOnBottomEdge = mergedCellAtCoords.row + mergedCellAtCoords.rowspan - 1 === this.hot.countRows() - 1;
1273
+ const mergedCellOnTopEdge = mergedCellAtCoords.row === 0;
1274
+ const mergedCellOnRightEdge = mergedCellAtCoords.col + mergedCellAtCoords.colspan - 1 === this.hot.countCols() - 1;
1275
+ const mergedCellOnLeftEdge = mergedCellAtCoords.col === 0;
1276
+ if (goingDown && mergedCellOnBottomEdge || goingUp && mergedCellOnTopEdge || goingRight && mergedCellOnRightEdge || goingLeft && mergedCellOnLeftEdge) {
1277
+ coords.row = mergedCellAtCoords.row;
1278
+ coords.col = mergedCellAtCoords.col;
1279
+ }
1280
+ }
1281
+ function _onAfterDrawSelection2(currentRow, currentColumn, cornersOfSelection, layerLevel) {
1282
+ // Nothing's selected (hook might be triggered by the custom borders)
1283
+ if (!cornersOfSelection) {
1284
+ return;
1209
1285
  }
1286
+ return this.selectionCalculations.getSelectedMergedCellClassName(currentRow, currentColumn, cornersOfSelection, layerLevel);
1287
+ }
1288
+ function _onBeforeRemoveCellClassNames2() {
1289
+ return this.selectionCalculations.getSelectedMergedCellClassNameToRemove();
1210
1290
  }