handsontable 0.0.0-next-2b3d6d8-20230623 → 0.0.0-next-74a68c1-20230627

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

Files changed (279) hide show
  1. package/3rdparty/walkontable/src/cell/coords.d.ts +6 -1
  2. package/3rdparty/walkontable/src/cell/coords.js +61 -12
  3. package/3rdparty/walkontable/src/cell/coords.mjs +61 -12
  4. package/3rdparty/walkontable/src/cell/range.d.ts +9 -2
  5. package/3rdparty/walkontable/src/cell/range.js +44 -7
  6. package/3rdparty/walkontable/src/cell/range.mjs +44 -7
  7. package/3rdparty/walkontable/src/core/_base.js +9 -3
  8. package/3rdparty/walkontable/src/core/_base.mjs +9 -3
  9. package/3rdparty/walkontable/src/core/clone.js +2 -2
  10. package/3rdparty/walkontable/src/core/clone.mjs +2 -2
  11. package/3rdparty/walkontable/src/core/core.js +3 -2
  12. package/3rdparty/walkontable/src/core/core.mjs +3 -2
  13. package/3rdparty/walkontable/src/event.js +7 -7
  14. package/3rdparty/walkontable/src/event.mjs +7 -7
  15. package/3rdparty/walkontable/src/facade/core.js +2 -2
  16. package/3rdparty/walkontable/src/facade/core.mjs +2 -2
  17. package/3rdparty/walkontable/src/index.js +10 -2
  18. package/3rdparty/walkontable/src/index.mjs +2 -2
  19. package/3rdparty/walkontable/src/overlay/_base.js +1 -1
  20. package/3rdparty/walkontable/src/overlay/_base.mjs +1 -1
  21. package/3rdparty/walkontable/src/overlay/inlineStart.js +2 -4
  22. package/3rdparty/walkontable/src/overlay/inlineStart.mjs +2 -4
  23. package/3rdparty/walkontable/src/overlay/top.js +2 -4
  24. package/3rdparty/walkontable/src/overlay/top.mjs +2 -4
  25. package/3rdparty/walkontable/src/{border.js → selection/border/border.js} +7 -12
  26. package/3rdparty/walkontable/src/{border.mjs → selection/border/border.mjs} +7 -12
  27. package/3rdparty/walkontable/src/selection/border/constants.js +18 -0
  28. package/3rdparty/walkontable/src/selection/border/constants.mjs +13 -0
  29. package/3rdparty/walkontable/src/selection/constants.js +63 -0
  30. package/3rdparty/walkontable/src/selection/constants.mjs +51 -0
  31. package/3rdparty/walkontable/src/selection/index.js +30 -0
  32. package/3rdparty/walkontable/src/selection/index.mjs +5 -0
  33. package/3rdparty/walkontable/src/selection/manager.js +329 -0
  34. package/3rdparty/walkontable/src/selection/manager.mjs +323 -0
  35. package/3rdparty/walkontable/src/selection/scanner.js +364 -0
  36. package/3rdparty/walkontable/src/selection/scanner.mjs +360 -0
  37. package/3rdparty/walkontable/src/selection/selection.js +133 -0
  38. package/3rdparty/walkontable/src/selection/selection.mjs +127 -0
  39. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.js +9 -0
  40. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.mjs +9 -0
  41. package/3rdparty/walkontable/src/table/mixin/calculatedRows.js +9 -0
  42. package/3rdparty/walkontable/src/table/mixin/calculatedRows.mjs +9 -0
  43. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.js +9 -0
  44. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.mjs +9 -0
  45. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.js +9 -0
  46. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.mjs +9 -0
  47. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.js +9 -0
  48. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.mjs +9 -0
  49. package/3rdparty/walkontable/src/table.js +7 -79
  50. package/3rdparty/walkontable/src/table.mjs +8 -80
  51. package/base.js +2 -2
  52. package/base.mjs +2 -2
  53. package/core.d.ts +5 -3
  54. package/core.js +127 -309
  55. package/core.mjs +127 -309
  56. package/dataMap/metaManager/metaSchema.js +19 -0
  57. package/dataMap/metaManager/metaSchema.mjs +19 -0
  58. package/dist/handsontable.css +8 -3
  59. package/dist/handsontable.full.css +8 -3
  60. package/dist/handsontable.full.js +13762 -10716
  61. package/dist/handsontable.full.min.css +3 -3
  62. package/dist/handsontable.full.min.js +115 -115
  63. package/dist/handsontable.js +16626 -13580
  64. package/dist/handsontable.min.css +3 -3
  65. package/dist/handsontable.min.js +4 -4
  66. package/editorManager.js +21 -94
  67. package/editorManager.mjs +26 -98
  68. package/editors/textEditor/textEditor.js +3 -11
  69. package/editors/textEditor/textEditor.mjs +4 -12
  70. package/helpers/mixed.js +1 -1
  71. package/helpers/mixed.mjs +1 -1
  72. package/helpers/number.d.ts +1 -0
  73. package/helpers/number.js +18 -0
  74. package/helpers/number.mjs +17 -0
  75. package/package.json +1 -1
  76. package/pluginHooks.d.ts +5 -1
  77. package/pluginHooks.js +89 -1
  78. package/pluginHooks.mjs +89 -1
  79. package/plugins/collapsibleColumns/collapsibleColumns.js +81 -24
  80. package/plugins/collapsibleColumns/collapsibleColumns.mjs +81 -24
  81. package/plugins/columnSorting/columnSorting.js +50 -8
  82. package/plugins/columnSorting/columnSorting.mjs +49 -9
  83. package/plugins/columnSorting/index.js +4 -2
  84. package/plugins/columnSorting/index.mjs +1 -1
  85. package/plugins/comments/comments.js +11 -4
  86. package/plugins/comments/comments.mjs +11 -4
  87. package/plugins/contextMenu/contextMenu.d.ts +1 -1
  88. package/plugins/contextMenu/contextMenu.js +80 -29
  89. package/plugins/contextMenu/contextMenu.mjs +81 -30
  90. package/plugins/contextMenu/predefinedItems/alignment.js +7 -0
  91. package/plugins/contextMenu/predefinedItems/alignment.mjs +7 -0
  92. package/plugins/contextMenu/predefinedItems/clearColumn.js +5 -3
  93. package/plugins/contextMenu/predefinedItems/clearColumn.mjs +5 -3
  94. package/plugins/contextMenu/predefinedItems/columnLeft.js +5 -3
  95. package/plugins/contextMenu/predefinedItems/columnLeft.mjs +5 -3
  96. package/plugins/contextMenu/predefinedItems/columnRight.js +5 -3
  97. package/plugins/contextMenu/predefinedItems/columnRight.mjs +5 -3
  98. package/plugins/contextMenu/predefinedItems/readOnly.js +7 -0
  99. package/plugins/contextMenu/predefinedItems/readOnly.mjs +7 -0
  100. package/plugins/contextMenu/predefinedItems/removeColumn.js +7 -5
  101. package/plugins/contextMenu/predefinedItems/removeColumn.mjs +5 -3
  102. package/plugins/contextMenu/predefinedItems/removeRow.js +7 -5
  103. package/plugins/contextMenu/predefinedItems/removeRow.mjs +5 -3
  104. package/plugins/contextMenu/predefinedItems/rowAbove.js +5 -3
  105. package/plugins/contextMenu/predefinedItems/rowAbove.mjs +5 -3
  106. package/plugins/contextMenu/predefinedItems/rowBelow.js +5 -3
  107. package/plugins/contextMenu/predefinedItems/rowBelow.mjs +5 -3
  108. package/plugins/contextMenu/utils.js +25 -16
  109. package/plugins/contextMenu/utils.mjs +24 -15
  110. package/plugins/copyPaste/contextMenuItem/copy.js +7 -0
  111. package/plugins/copyPaste/contextMenuItem/copy.mjs +7 -0
  112. package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.js +9 -1
  113. package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.mjs +9 -1
  114. package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.js +9 -1
  115. package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.mjs +9 -1
  116. package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.js +9 -1
  117. package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.mjs +9 -1
  118. package/plugins/copyPaste/contextMenuItem/cut.js +7 -0
  119. package/plugins/copyPaste/contextMenuItem/cut.mjs +7 -0
  120. package/plugins/copyPaste/copyPaste.js +5 -1
  121. package/plugins/copyPaste/copyPaste.mjs +5 -1
  122. package/plugins/customBorders/customBorders.js +25 -53
  123. package/plugins/customBorders/customBorders.mjs +26 -54
  124. package/plugins/dropdownMenu/dropdownMenu.d.ts +1 -1
  125. package/plugins/dropdownMenu/dropdownMenu.js +94 -30
  126. package/plugins/dropdownMenu/dropdownMenu.mjs +94 -30
  127. package/plugins/filters/filters.js +62 -42
  128. package/plugins/filters/filters.mjs +61 -41
  129. package/plugins/mergeCells/mergeCells.js +5 -18
  130. package/plugins/mergeCells/mergeCells.mjs +5 -18
  131. package/plugins/multiColumnSorting/multiColumnSorting.js +42 -3
  132. package/plugins/multiColumnSorting/multiColumnSorting.mjs +42 -3
  133. package/plugins/nestedHeaders/nestedHeaders.js +132 -10
  134. package/plugins/nestedHeaders/nestedHeaders.mjs +132 -10
  135. package/plugins/nestedHeaders/stateManager/index.js +37 -0
  136. package/plugins/nestedHeaders/stateManager/index.mjs +37 -0
  137. package/plugins/nestedRows/nestedRows.js +52 -7
  138. package/plugins/nestedRows/nestedRows.mjs +52 -7
  139. package/renderers/checkboxRenderer/checkboxRenderer.js +2 -2
  140. package/renderers/checkboxRenderer/checkboxRenderer.mjs +1 -1
  141. package/selection/highlight/highlight.js +312 -89
  142. package/selection/highlight/highlight.mjs +302 -85
  143. package/selection/highlight/types/activeHeader.js +10 -9
  144. package/selection/highlight/types/activeHeader.mjs +10 -8
  145. package/selection/highlight/types/area.js +12 -27
  146. package/selection/highlight/types/area.mjs +16 -30
  147. package/selection/highlight/types/areaLayered.js +54 -0
  148. package/selection/highlight/types/areaLayered.mjs +49 -0
  149. package/selection/highlight/types/column.js +50 -0
  150. package/selection/highlight/types/column.mjs +45 -0
  151. package/selection/highlight/types/customSelection.js +7 -10
  152. package/selection/highlight/types/customSelection.mjs +7 -9
  153. package/selection/highlight/types/fill.js +5 -8
  154. package/selection/highlight/types/fill.mjs +5 -7
  155. package/selection/highlight/types/{cell.js → focus.js} +5 -8
  156. package/selection/highlight/types/{cell.mjs → focus.mjs} +5 -7
  157. package/selection/highlight/types/header.js +10 -20
  158. package/selection/highlight/types/header.mjs +10 -19
  159. package/selection/highlight/types/{index.js → row.js} +27 -31
  160. package/selection/highlight/types/{index.mjs → row.mjs} +24 -29
  161. package/selection/highlight/visualSelection.js +31 -27
  162. package/selection/highlight/visualSelection.mjs +31 -27
  163. package/selection/index.js +4 -7
  164. package/selection/index.mjs +2 -3
  165. package/selection/mouseEventHandler.js +1 -1
  166. package/selection/mouseEventHandler.mjs +1 -1
  167. package/selection/range.js +8 -8
  168. package/selection/range.mjs +8 -8
  169. package/selection/selection.js +315 -181
  170. package/selection/selection.mjs +310 -180
  171. package/selection/transformation.js +233 -96
  172. package/selection/transformation.mjs +230 -93
  173. package/selection/utils.js +12 -36
  174. package/selection/utils.mjs +13 -36
  175. package/settings.d.ts +1 -0
  176. package/shortcutContexts/commands/editor/closeAndSave.js +15 -0
  177. package/shortcutContexts/commands/editor/closeAndSave.mjs +10 -0
  178. package/shortcutContexts/commands/editor/closeWithoutSaving.js +13 -0
  179. package/shortcutContexts/commands/editor/closeWithoutSaving.mjs +8 -0
  180. package/shortcutContexts/commands/editor/fastOpen.js +16 -0
  181. package/shortcutContexts/commands/editor/fastOpen.mjs +11 -0
  182. package/shortcutContexts/commands/editor/index.js +16 -0
  183. package/shortcutContexts/commands/editor/index.mjs +12 -0
  184. package/shortcutContexts/commands/editor/open.js +29 -0
  185. package/shortcutContexts/commands/editor/open.mjs +24 -0
  186. package/shortcutContexts/commands/emptySelectedCells.js +12 -0
  187. package/shortcutContexts/commands/emptySelectedCells.mjs +7 -0
  188. package/shortcutContexts/commands/extendCellsSelection/down.js +15 -0
  189. package/shortcutContexts/commands/extendCellsSelection/down.mjs +10 -0
  190. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +21 -0
  191. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +16 -0
  192. package/shortcutContexts/commands/extendCellsSelection/index.js +26 -0
  193. package/shortcutContexts/commands/extendCellsSelection/index.mjs +22 -0
  194. package/shortcutContexts/commands/extendCellsSelection/left.js +15 -0
  195. package/shortcutContexts/commands/extendCellsSelection/left.mjs +10 -0
  196. package/shortcutContexts/commands/extendCellsSelection/right.js +15 -0
  197. package/shortcutContexts/commands/extendCellsSelection/right.mjs +10 -0
  198. package/shortcutContexts/commands/extendCellsSelection/toColumns.js +19 -0
  199. package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +14 -0
  200. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +22 -0
  201. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +17 -0
  202. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +17 -0
  203. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +12 -0
  204. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +17 -0
  205. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +12 -0
  206. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +40 -0
  207. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +35 -0
  208. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +40 -0
  209. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +35 -0
  210. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +22 -0
  211. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +17 -0
  212. package/shortcutContexts/commands/extendCellsSelection/toRows.js +19 -0
  213. package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +14 -0
  214. package/shortcutContexts/commands/extendCellsSelection/up.js +15 -0
  215. package/shortcutContexts/commands/extendCellsSelection/up.mjs +10 -0
  216. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +21 -0
  217. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +16 -0
  218. package/shortcutContexts/commands/index.js +53 -0
  219. package/shortcutContexts/commands/index.mjs +49 -0
  220. package/shortcutContexts/commands/moveCellSelection/down.js +12 -0
  221. package/shortcutContexts/commands/moveCellSelection/down.mjs +7 -0
  222. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +29 -0
  223. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +24 -0
  224. package/shortcutContexts/commands/moveCellSelection/index.js +28 -0
  225. package/shortcutContexts/commands/moveCellSelection/index.mjs +24 -0
  226. package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +13 -0
  227. package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +8 -0
  228. package/shortcutContexts/commands/moveCellSelection/inlineStart.js +13 -0
  229. package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +8 -0
  230. package/shortcutContexts/commands/moveCellSelection/left.js +11 -0
  231. package/shortcutContexts/commands/moveCellSelection/left.mjs +6 -0
  232. package/shortcutContexts/commands/moveCellSelection/right.js +11 -0
  233. package/shortcutContexts/commands/moveCellSelection/right.mjs +6 -0
  234. package/shortcutContexts/commands/moveCellSelection/toMostBottom.js +16 -0
  235. package/shortcutContexts/commands/moveCellSelection/toMostBottom.mjs +11 -0
  236. package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.js +17 -0
  237. package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.mjs +12 -0
  238. package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.js +13 -0
  239. package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.mjs +8 -0
  240. package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.js +16 -0
  241. package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.mjs +11 -0
  242. package/shortcutContexts/commands/moveCellSelection/toMostLeft.js +36 -0
  243. package/shortcutContexts/commands/moveCellSelection/toMostLeft.mjs +31 -0
  244. package/shortcutContexts/commands/moveCellSelection/toMostRight.js +36 -0
  245. package/shortcutContexts/commands/moveCellSelection/toMostRight.mjs +31 -0
  246. package/shortcutContexts/commands/moveCellSelection/toMostTop.js +16 -0
  247. package/shortcutContexts/commands/moveCellSelection/toMostTop.mjs +11 -0
  248. package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.js +18 -0
  249. package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.mjs +13 -0
  250. package/shortcutContexts/commands/moveCellSelection/up.js +12 -0
  251. package/shortcutContexts/commands/moveCellSelection/up.mjs +7 -0
  252. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +29 -0
  253. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +24 -0
  254. package/shortcutContexts/commands/populateSelectedCellsData.js +35 -0
  255. package/shortcutContexts/commands/populateSelectedCellsData.mjs +30 -0
  256. package/shortcutContexts/commands/scrollToFocusedCell.js +38 -0
  257. package/shortcutContexts/commands/scrollToFocusedCell.mjs +33 -0
  258. package/shortcutContexts/commands/selectAll.js +11 -0
  259. package/shortcutContexts/commands/selectAll.mjs +6 -0
  260. package/shortcutContexts/constants.js +19 -0
  261. package/shortcutContexts/constants.mjs +12 -0
  262. package/shortcutContexts/editor.js +29 -0
  263. package/shortcutContexts/editor.mjs +25 -0
  264. package/shortcutContexts/grid.js +252 -0
  265. package/shortcutContexts/grid.mjs +248 -0
  266. package/shortcutContexts/index.js +29 -0
  267. package/shortcutContexts/index.mjs +15 -0
  268. package/shortcuts/manager.js +2 -0
  269. package/shortcuts/manager.mjs +2 -0
  270. package/shortcuts/recorder.js +2 -2
  271. package/shortcuts/recorder.mjs +2 -2
  272. package/shortcuts/utils.js +21 -5
  273. package/shortcuts/utils.mjs +20 -4
  274. package/tableView.js +58 -9
  275. package/tableView.mjs +58 -9
  276. package/3rdparty/walkontable/src/selection.js +0 -355
  277. package/3rdparty/walkontable/src/selection.mjs +0 -349
  278. package/selection/highlight/constants.js +0 -16
  279. package/selection/highlight/constants.mjs +0 -6
@@ -32,14 +32,17 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
32
32
  import { BasePlugin } from "../base/index.mjs";
33
33
  import Hooks from "../../pluginHooks.mjs";
34
34
  import { arrayEach } from "../../helpers/array.mjs";
35
+ import { objectEach } from "../../helpers/object.mjs";
35
36
  import CommandExecutor from "./commandExecutor.mjs";
36
37
  import EventManager from "../../eventManager.mjs";
37
38
  import ItemsFactory from "./itemsFactory.mjs";
38
39
  import Menu from "./menu.mjs";
39
- import { getWindowScrollLeft, getWindowScrollTop, hasClass } from "../../helpers/dom/element.mjs";
40
+ import { getDocumentOffsetByElement } from "./utils.mjs";
41
+ import { hasClass } from "../../helpers/dom/element.mjs";
40
42
  import { ROW_ABOVE, ROW_BELOW, COLUMN_LEFT, COLUMN_RIGHT, REMOVE_ROW, REMOVE_COLUMN, UNDO, REDO, READ_ONLY, ALIGNMENT, SEPARATOR } from "./predefinedItems.mjs";
41
43
  export var PLUGIN_KEY = 'contextMenu';
42
44
  export var PLUGIN_PRIORITY = 70;
45
+ var SHORTCUTS_GROUP = PLUGIN_KEY;
43
46
  Hooks.getSingleton().register('afterContextMenuDefaultOptions');
44
47
  Hooks.getSingleton().register('beforeContextMenuShow');
45
48
  Hooks.getSingleton().register('afterContextMenuShow');
@@ -161,6 +164,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
161
164
  this.addHook('afterOnCellContextMenu', function (event) {
162
165
  return _this2.onAfterOnCellContextMenu(event);
163
166
  });
167
+ this.registerShortcuts();
164
168
  _get(_getPrototypeOf(ContextMenu.prototype), "enablePlugin", this).call(this);
165
169
  }
166
170
 
@@ -175,6 +179,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
175
179
  value: function updatePlugin() {
176
180
  this.disablePlugin();
177
181
  this.enablePlugin();
182
+ this.unregisterShortcuts();
178
183
  _get(_getPrototypeOf(ContextMenu.prototype), "updatePlugin", this).call(this);
179
184
  }
180
185
 
@@ -192,39 +197,83 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
192
197
  _get(_getPrototypeOf(ContextMenu.prototype), "disablePlugin", this).call(this);
193
198
  }
194
199
 
200
+ /**
201
+ * Register shortcuts responsible for toggling context menu.
202
+ *
203
+ * @private
204
+ */
205
+ }, {
206
+ key: "registerShortcuts",
207
+ value: function registerShortcuts() {
208
+ var _this3 = this;
209
+ this.hot.getShortcutManager().getContext('grid').addShortcut({
210
+ keys: [['Control/Meta', 'Shift', '\\'], ['Shift', 'F10']],
211
+ callback: function callback() {
212
+ var _this3$hot$getSelecte = _this3.hot.getSelectedRangeLast(),
213
+ highlight = _this3$hot$getSelecte.highlight;
214
+ var rect = _this3.hot.getCell(highlight.row, highlight.col, true).getBoundingClientRect();
215
+ var offset = getDocumentOffsetByElement(_this3.menu.container, _this3.hot.rootDocument);
216
+ _this3.open({
217
+ left: rect.left + offset.left,
218
+ top: rect.top + offset.top - 1 + rect.height
219
+ }, {
220
+ left: rect.width,
221
+ above: -rect.height
222
+ });
223
+ _this3.hot._registerTimeout(function () {
224
+ _this3.menu.selectFirstCell();
225
+ });
226
+ },
227
+ runOnlyIf: function runOnlyIf() {
228
+ return _this3.hot.getSelectedRangeLast() && !_this3.menu.isOpened();
229
+ },
230
+ group: SHORTCUTS_GROUP
231
+ });
232
+ }
233
+
234
+ /**
235
+ * Unregister shortcuts responsible for toggling context menu.
236
+ *
237
+ * @private
238
+ */
239
+ }, {
240
+ key: "unregisterShortcuts",
241
+ value: function unregisterShortcuts() {
242
+ this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
243
+ }
244
+
195
245
  /**
196
246
  * Opens menu and re-position it based on the passed coordinates.
197
247
  *
198
- * @param {Event} event The mouse event object.
248
+ * @param {{ top: number, left: number }|Event} position An object with `top` and `left` properties
249
+ * which contains coordinates relative to the browsers viewport (without included scroll offsets).
250
+ * Or if the native event is passed the menu will be positioned based on the `pageX` and `pageY`
251
+ * coordinates.
252
+ * @param {{ above: number, below: number, left: number, right: number }} offset An object allows applying
253
+ * the offset to the menu position.
254
+ * @fires Hooks#beforeContextMenuShow
255
+ * @fires Hooks#afterContextMenuShow
199
256
  */
200
257
  }, {
201
258
  key: "open",
202
- value: function open(event) {
203
- if (!this.menu) {
259
+ value: function open(position) {
260
+ var _this$menu,
261
+ _this4 = this;
262
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
263
+ above: 0,
264
+ below: 0,
265
+ left: 0,
266
+ right: 0
267
+ };
268
+ if ((_this$menu = this.menu) !== null && _this$menu !== void 0 && _this$menu.isOpened()) {
204
269
  return;
205
270
  }
206
271
  this.prepareMenuItems();
207
272
  this.menu.open();
208
- if (!this.menu.isOpened()) {
209
- return;
210
- }
211
- var offsetTop = 0;
212
- var offsetLeft = 0;
213
- if (this.hot.rootDocument !== this.menu.container.ownerDocument) {
214
- var frameElement = this.hot.rootWindow.frameElement;
215
- var _frameElement$getBoun = frameElement.getBoundingClientRect(),
216
- top = _frameElement$getBoun.top,
217
- left = _frameElement$getBoun.left;
218
- offsetTop = top - getWindowScrollTop(event.view);
219
- offsetLeft = left - getWindowScrollLeft(event.view);
220
- } else {
221
- offsetTop = -1 * getWindowScrollTop(this.menu.hotMenu.rootWindow);
222
- offsetLeft = -1 * getWindowScrollLeft(this.menu.hotMenu.rootWindow);
223
- }
224
- this.menu.setPosition({
225
- top: parseInt(event.pageY, 10) + offsetTop,
226
- left: parseInt(event.pageX, 10) + offsetLeft
273
+ objectEach(offset, function (value, key) {
274
+ _this4.menu.setOffset(key, value);
227
275
  });
276
+ this.menu.setPosition(position);
228
277
  }
229
278
 
230
279
  /**
@@ -233,10 +282,8 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
233
282
  }, {
234
283
  key: "close",
235
284
  value: function close() {
236
- if (!this.menu) {
237
- return;
238
- }
239
- this.menu.close();
285
+ var _this$menu2;
286
+ (_this$menu2 = this.menu) === null || _this$menu2 === void 0 ? void 0 : _this$menu2.close();
240
287
  this.itemsFactory = null;
241
288
  }
242
289
 
@@ -293,7 +340,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
293
340
  }, {
294
341
  key: "prepareMenuItems",
295
342
  value: function prepareMenuItems() {
296
- var _this3 = this;
343
+ var _this5 = this;
297
344
  this.itemsFactory = new ItemsFactory(this.hot, ContextMenu.DEFAULT_ITEMS);
298
345
  var settings = this.hot.getSettings()[PLUGIN_KEY];
299
346
  var predefinedItems = {
@@ -307,7 +354,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
307
354
 
308
355
  // Register all commands. Predefined and added by user or by plugins
309
356
  arrayEach(menuItems, function (command) {
310
- return _this3.commandExecutor.registerCommand(command.key, command);
357
+ return _this5.commandExecutor.registerCommand(command.key, command);
311
358
  });
312
359
  }
313
360
 
@@ -344,7 +391,11 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
344
391
  return;
345
392
  }
346
393
  }
347
- this.open(event);
394
+ var offset = getDocumentOffsetByElement(this.menu.container, this.hot.rootDocument);
395
+ this.open({
396
+ top: event.clientY + offset.top,
397
+ left: event.clientX + offset.left
398
+ });
348
399
  }
349
400
 
350
401
  /**
@@ -35,6 +35,13 @@ function alignmentItem() {
35
35
  if (this.countRows() === 0 || this.countCols() === 0) {
36
36
  return true;
37
37
  }
38
+ var range = this.getSelectedRangeLast();
39
+ if (!range) {
40
+ return true;
41
+ }
42
+ if (range.isSingleHeader()) {
43
+ return true;
44
+ }
38
45
  return !(this.getSelectedRange() && !this.selection.isSelectedByCorner());
39
46
  },
40
47
  submenu: {
@@ -17,6 +17,13 @@ export default function alignmentItem() {
17
17
  if (this.countRows() === 0 || this.countCols() === 0) {
18
18
  return true;
19
19
  }
20
+ var range = this.getSelectedRangeLast();
21
+ if (!range) {
22
+ return true;
23
+ }
24
+ if (range.isSingleHeader()) {
25
+ return true;
26
+ }
20
27
  return !(this.getSelectedRange() && !this.selection.isSelectedByCorner());
21
28
  },
22
29
  submenu: {
@@ -13,7 +13,6 @@ require("core-js/modules/es.symbol.iterator.js");
13
13
  exports.__esModule = true;
14
14
  exports.KEY = void 0;
15
15
  exports.default = clearColumnItem;
16
- var _utils = require("../utils");
17
16
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
18
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -37,8 +36,11 @@ function clearColumnItem() {
37
36
  }
38
37
  },
39
38
  disabled: function disabled() {
40
- var selected = (0, _utils.getValidSelection)(this);
41
- if (!selected) {
39
+ var range = this.getSelectedRangeLast();
40
+ if (!range) {
41
+ return true;
42
+ }
43
+ if (range.isSingleHeader() && range.highlight.col < 0) {
42
44
  return true;
43
45
  }
44
46
  return !this.selection.isSelectedByColumnHeader();
@@ -1,4 +1,3 @@
1
- import { getValidSelection } from "../utils.mjs";
2
1
  import * as C from "../../../i18n/constants.mjs";
3
2
  export var KEY = 'clear_column';
4
3
 
@@ -19,8 +18,11 @@ export default function clearColumnItem() {
19
18
  }
20
19
  },
21
20
  disabled: function disabled() {
22
- var selected = getValidSelection(this);
23
- if (!selected) {
21
+ var range = this.getSelectedRangeLast();
22
+ if (!range) {
23
+ return true;
24
+ }
25
+ if (range.isSingleHeader() && range.highlight.col < 0) {
24
26
  return true;
25
27
  }
26
28
  return !this.selection.isSelectedByColumnHeader();
@@ -13,7 +13,6 @@ require("core-js/modules/es.symbol.iterator.js");
13
13
  exports.__esModule = true;
14
14
  exports.KEY = void 0;
15
15
  exports.default = columnLeftItem;
16
- var _utils = require("../utils");
17
16
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
18
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -38,8 +37,11 @@ function columnLeftItem() {
38
37
  if (!this.isColumnModificationAllowed()) {
39
38
  return true;
40
39
  }
41
- var selected = (0, _utils.getValidSelection)(this);
42
- if (!selected) {
40
+ var range = this.getSelectedRangeLast();
41
+ if (!range) {
42
+ return true;
43
+ }
44
+ if (range.isSingleHeader() && range.highlight.col < 0) {
43
45
  return true;
44
46
  }
45
47
  if (this.selection.isSelectedByCorner()) {
@@ -1,4 +1,3 @@
1
- import { getValidSelection } from "../utils.mjs";
2
1
  import * as C from "../../../i18n/constants.mjs";
3
2
  export var KEY = 'col_left';
4
3
 
@@ -20,8 +19,11 @@ export default function columnLeftItem() {
20
19
  if (!this.isColumnModificationAllowed()) {
21
20
  return true;
22
21
  }
23
- var selected = getValidSelection(this);
24
- if (!selected) {
22
+ var range = this.getSelectedRangeLast();
23
+ if (!range) {
24
+ return true;
25
+ }
26
+ if (range.isSingleHeader() && range.highlight.col < 0) {
25
27
  return true;
26
28
  }
27
29
  if (this.selection.isSelectedByCorner()) {
@@ -13,7 +13,6 @@ require("core-js/modules/es.symbol.iterator.js");
13
13
  exports.__esModule = true;
14
14
  exports.KEY = void 0;
15
15
  exports.default = columnRightItem;
16
- var _utils = require("../utils");
17
16
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
18
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -38,8 +37,11 @@ function columnRightItem() {
38
37
  if (!this.isColumnModificationAllowed()) {
39
38
  return true;
40
39
  }
41
- var selected = (0, _utils.getValidSelection)(this);
42
- if (!selected) {
40
+ var range = this.getSelectedRangeLast();
41
+ if (!range) {
42
+ return true;
43
+ }
44
+ if (range.isSingleHeader() && range.highlight.col < 0) {
43
45
  return true;
44
46
  }
45
47
  if (this.selection.isSelectedByCorner()) {
@@ -1,4 +1,3 @@
1
- import { getValidSelection } from "../utils.mjs";
2
1
  import * as C from "../../../i18n/constants.mjs";
3
2
  export var KEY = 'col_right';
4
3
 
@@ -20,8 +19,11 @@ export default function columnRightItem() {
20
19
  if (!this.isColumnModificationAllowed()) {
21
20
  return true;
22
21
  }
23
- var selected = getValidSelection(this);
24
- if (!selected) {
22
+ var range = this.getSelectedRangeLast();
23
+ if (!range) {
24
+ return true;
25
+ }
26
+ if (range.isSingleHeader() && range.highlight.col < 0) {
25
27
  return true;
26
28
  }
27
29
  if (this.selection.isSelectedByCorner()) {
@@ -54,6 +54,13 @@ function readOnlyItem() {
54
54
  this.render();
55
55
  },
56
56
  disabled: function disabled() {
57
+ var range = this.getSelectedRangeLast();
58
+ if (!range) {
59
+ return true;
60
+ }
61
+ if (range.isSingleHeader()) {
62
+ return true;
63
+ }
57
64
  if (this.selection.isSelectedByCorner()) {
58
65
  return true;
59
66
  }
@@ -36,6 +36,13 @@ export default function readOnlyItem() {
36
36
  this.render();
37
37
  },
38
38
  disabled: function disabled() {
39
+ var range = this.getSelectedRangeLast();
40
+ if (!range) {
41
+ return true;
42
+ }
43
+ if (range.isSingleHeader()) {
44
+ return true;
45
+ }
39
46
  if (this.selection.isSelectedByCorner()) {
40
47
  return true;
41
48
  }
@@ -18,8 +18,7 @@ require("core-js/modules/es.object.get-own-property-descriptor.js");
18
18
  exports.__esModule = true;
19
19
  exports.KEY = void 0;
20
20
  exports.default = removeColumnItem;
21
- var _utils = require("../utils");
22
- var _utils2 = require("../../../selection/utils");
21
+ var _utils = require("../../../selection/utils");
23
22
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
24
23
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
24
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -56,14 +55,17 @@ function removeColumnItem() {
56
55
  return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COLUMN, pluralForm);
57
56
  },
58
57
  callback: function callback() {
59
- this.alter('remove_col', (0, _utils2.transformSelectionToColumnDistance)(this.getSelected()), null, 'ContextMenu.removeColumn');
58
+ this.alter('remove_col', (0, _utils.transformSelectionToColumnDistance)(this.getSelected()), null, 'ContextMenu.removeColumn');
60
59
  },
61
60
  disabled: function disabled() {
62
61
  if (!this.isColumnModificationAllowed()) {
63
62
  return true;
64
63
  }
65
- var selected = (0, _utils.getValidSelection)(this);
66
- if (!selected) {
64
+ var range = this.getSelectedRangeLast();
65
+ if (!range) {
66
+ return true;
67
+ }
68
+ if (range.isSingleHeader() && range.highlight.col < 0) {
67
69
  return true;
68
70
  }
69
71
  var totalColumns = this.countCols();
@@ -16,7 +16,6 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
16
16
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
17
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
18
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
- import { getValidSelection } from "../utils.mjs";
20
19
  import { transformSelectionToColumnDistance } from "../../../selection/utils.mjs";
21
20
  import * as C from "../../../i18n/constants.mjs";
22
21
  export var KEY = 'remove_col';
@@ -51,8 +50,11 @@ export default function removeColumnItem() {
51
50
  if (!this.isColumnModificationAllowed()) {
52
51
  return true;
53
52
  }
54
- var selected = getValidSelection(this);
55
- if (!selected) {
53
+ var range = this.getSelectedRangeLast();
54
+ if (!range) {
55
+ return true;
56
+ }
57
+ if (range.isSingleHeader() && range.highlight.col < 0) {
56
58
  return true;
57
59
  }
58
60
  var totalColumns = this.countCols();
@@ -18,8 +18,7 @@ require("core-js/modules/es.object.get-own-property-descriptor.js");
18
18
  exports.__esModule = true;
19
19
  exports.KEY = void 0;
20
20
  exports.default = removeRowItem;
21
- var _utils = require("../utils");
22
- var _utils2 = require("../../../selection/utils");
21
+ var _utils = require("../../../selection/utils");
23
22
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
24
23
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
24
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -58,11 +57,14 @@ function removeRowItem() {
58
57
  callback: function callback() {
59
58
  // TODO: Please keep in mind that below `1` may be improper. The table's way of work, before change `f1747b3912ea3b21fe423fd102ca94c87db81379` was restored.
60
59
  // There is still problem when removing more than one row.
61
- this.alter('remove_row', (0, _utils2.transformSelectionToRowDistance)(this.getSelected()), 1, 'ContextMenu.removeRow');
60
+ this.alter('remove_row', (0, _utils.transformSelectionToRowDistance)(this.getSelected()), 1, 'ContextMenu.removeRow');
62
61
  },
63
62
  disabled: function disabled() {
64
- var selected = (0, _utils.getValidSelection)(this);
65
- if (!selected) {
63
+ var range = this.getSelectedRangeLast();
64
+ if (!range) {
65
+ return true;
66
+ }
67
+ if (range.isSingleHeader() && range.highlight.row < 0) {
66
68
  return true;
67
69
  }
68
70
  var totalRows = this.countRows();
@@ -16,7 +16,6 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
16
16
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
17
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
18
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
- import { getValidSelection } from "../utils.mjs";
20
19
  import { transformSelectionToRowDistance } from "../../../selection/utils.mjs";
21
20
  import * as C from "../../../i18n/constants.mjs";
22
21
  export var KEY = 'remove_row';
@@ -50,8 +49,11 @@ export default function removeRowItem() {
50
49
  this.alter('remove_row', transformSelectionToRowDistance(this.getSelected()), 1, 'ContextMenu.removeRow');
51
50
  },
52
51
  disabled: function disabled() {
53
- var selected = getValidSelection(this);
54
- if (!selected) {
52
+ var range = this.getSelectedRangeLast();
53
+ if (!range) {
54
+ return true;
55
+ }
56
+ if (range.isSingleHeader() && range.highlight.row < 0) {
55
57
  return true;
56
58
  }
57
59
  var totalRows = this.countRows();
@@ -13,7 +13,6 @@ require("core-js/modules/es.symbol.iterator.js");
13
13
  exports.__esModule = true;
14
14
  exports.KEY = void 0;
15
15
  exports.default = rowAboveItem;
16
- var _utils = require("../utils");
17
16
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
18
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -34,8 +33,11 @@ function rowAboveItem() {
34
33
  this.alter('insert_row_above', latestSelection.row, 1, 'ContextMenu.rowAbove');
35
34
  },
36
35
  disabled: function disabled() {
37
- var selected = (0, _utils.getValidSelection)(this);
38
- if (!selected) {
36
+ var range = this.getSelectedRangeLast();
37
+ if (!range) {
38
+ return true;
39
+ }
40
+ if (range.isSingleHeader() && range.highlight.row < 0) {
39
41
  return true;
40
42
  }
41
43
  if (this.selection.isSelectedByCorner()) {
@@ -1,4 +1,3 @@
1
- import { getValidSelection } from "../utils.mjs";
2
1
  import * as C from "../../../i18n/constants.mjs";
3
2
  export var KEY = 'row_above';
4
3
 
@@ -16,8 +15,11 @@ export default function rowAboveItem() {
16
15
  this.alter('insert_row_above', latestSelection.row, 1, 'ContextMenu.rowAbove');
17
16
  },
18
17
  disabled: function disabled() {
19
- var selected = getValidSelection(this);
20
- if (!selected) {
18
+ var range = this.getSelectedRangeLast();
19
+ if (!range) {
20
+ return true;
21
+ }
22
+ if (range.isSingleHeader() && range.highlight.row < 0) {
21
23
  return true;
22
24
  }
23
25
  if (this.selection.isSelectedByCorner()) {
@@ -13,7 +13,6 @@ require("core-js/modules/es.symbol.iterator.js");
13
13
  exports.__esModule = true;
14
14
  exports.KEY = void 0;
15
15
  exports.default = rowBelowItem;
16
- var _utils = require("../utils");
17
16
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
18
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -34,8 +33,11 @@ function rowBelowItem() {
34
33
  this.alter('insert_row_below', latestSelection.row, 1, 'ContextMenu.rowBelow');
35
34
  },
36
35
  disabled: function disabled() {
37
- var selected = (0, _utils.getValidSelection)(this);
38
- if (!selected) {
36
+ var range = this.getSelectedRangeLast();
37
+ if (!range) {
38
+ return true;
39
+ }
40
+ if (range.isSingleHeader() && range.highlight.row < 0) {
39
41
  return true;
40
42
  }
41
43
  if (this.selection.isSelectedByCorner()) {
@@ -1,4 +1,3 @@
1
- import { getValidSelection } from "../utils.mjs";
2
1
  import * as C from "../../../i18n/constants.mjs";
3
2
  export var KEY = 'row_below';
4
3
 
@@ -16,8 +15,11 @@ export default function rowBelowItem() {
16
15
  this.alter('insert_row_below', latestSelection.row, 1, 'ContextMenu.rowBelow');
17
16
  },
18
17
  disabled: function disabled() {
19
- var selected = getValidSelection(this);
20
- if (!selected) {
18
+ var range = this.getSelectedRangeLast();
19
+ if (!range) {
20
+ return true;
21
+ }
22
+ if (range.isSingleHeader() && range.highlight.row < 0) {
21
23
  return true;
22
24
  }
23
25
  if (this.selection.isSelectedByCorner()) {
@@ -5,7 +5,7 @@ exports.align = align;
5
5
  exports.checkSelectionConsistency = checkSelectionConsistency;
6
6
  exports.filterSeparators = filterSeparators;
7
7
  exports.getAlignmentClasses = getAlignmentClasses;
8
- exports.getValidSelection = getValidSelection;
8
+ exports.getDocumentOffsetByElement = getDocumentOffsetByElement;
9
9
  exports.hasSubMenu = hasSubMenu;
10
10
  exports.isDisabled = isDisabled;
11
11
  exports.isItemHidden = isItemHidden;
@@ -70,21 +70,6 @@ function isSelectionDisabled(cell) {
70
70
  return (0, _element.hasClass)(cell, 'htSelectionDisabled');
71
71
  }
72
72
 
73
- /**
74
- * @param {Core} hot The Handsontable instance.
75
- * @returns {Array[]|null}
76
- */
77
- function getValidSelection(hot) {
78
- var selected = hot.getSelected();
79
- if (!selected) {
80
- return null;
81
- }
82
- if (selected[0] < 0) {
83
- return null;
84
- }
85
- return selected;
86
- }
87
-
88
73
  /**
89
74
  * @param {string} className The full element class name to process.
90
75
  * @param {string} alignment The slignment class name to compare with.
@@ -275,4 +260,28 @@ function filterSeparators(items) {
275
260
  result = popSeparators(result, separator);
276
261
  result = removeDuplicatedSeparators(result);
277
262
  return result;
263
+ }
264
+
265
+ /**
266
+ * Returns document offset based on the passed element. If the document objects between element and the
267
+ * base document are not the same the offset as top and left properties will be returned.
268
+ *
269
+ * @param {Element} elementToCheck The element to compare with Document object.
270
+ * @param {Document} baseDocument The base Document object.
271
+ * @returns {{ top: number, left: number }}
272
+ */
273
+ function getDocumentOffsetByElement(elementToCheck, baseDocument) {
274
+ var offset = {
275
+ top: 0,
276
+ left: 0
277
+ };
278
+ if (baseDocument !== elementToCheck.ownerDocument) {
279
+ var frameElement = baseDocument.defaultView.frameElement;
280
+ var _frameElement$getBoun = frameElement.getBoundingClientRect(),
281
+ top = _frameElement$getBoun.top,
282
+ left = _frameElement$getBoun.left;
283
+ offset.top = top;
284
+ offset.left = left;
285
+ }
286
+ return offset;
278
287
  }