handsontable 0.0.0-next-be16baf-20230809 → 0.0.0-next-912c214-20230818

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (299) hide show
  1. package/3rdparty/walkontable/src/{selection/border/border.js → border.js} +12 -7
  2. package/3rdparty/walkontable/src/{selection/border/border.mjs → border.mjs} +12 -7
  3. package/3rdparty/walkontable/src/cell/coords.d.ts +1 -6
  4. package/3rdparty/walkontable/src/cell/coords.js +11 -50
  5. package/3rdparty/walkontable/src/cell/coords.mjs +11 -50
  6. package/3rdparty/walkontable/src/cell/range.d.ts +2 -9
  7. package/3rdparty/walkontable/src/cell/range.js +7 -38
  8. package/3rdparty/walkontable/src/cell/range.mjs +7 -38
  9. package/3rdparty/walkontable/src/core/_base.js +3 -9
  10. package/3rdparty/walkontable/src/core/_base.mjs +3 -9
  11. package/3rdparty/walkontable/src/core/clone.js +2 -2
  12. package/3rdparty/walkontable/src/core/clone.mjs +2 -2
  13. package/3rdparty/walkontable/src/core/core.js +2 -3
  14. package/3rdparty/walkontable/src/core/core.mjs +2 -3
  15. package/3rdparty/walkontable/src/event.js +7 -7
  16. package/3rdparty/walkontable/src/event.mjs +7 -7
  17. package/3rdparty/walkontable/src/facade/core.js +2 -2
  18. package/3rdparty/walkontable/src/facade/core.mjs +2 -2
  19. package/3rdparty/walkontable/src/index.js +2 -10
  20. package/3rdparty/walkontable/src/index.mjs +2 -2
  21. package/3rdparty/walkontable/src/overlay/_base.js +1 -1
  22. package/3rdparty/walkontable/src/overlay/_base.mjs +1 -1
  23. package/3rdparty/walkontable/src/overlay/inlineStart.js +6 -2
  24. package/3rdparty/walkontable/src/overlay/inlineStart.mjs +6 -2
  25. package/3rdparty/walkontable/src/overlay/top.js +6 -2
  26. package/3rdparty/walkontable/src/overlay/top.mjs +6 -2
  27. package/3rdparty/walkontable/src/selection.js +295 -0
  28. package/3rdparty/walkontable/src/selection.mjs +290 -0
  29. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.js +0 -9
  30. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.mjs +0 -9
  31. package/3rdparty/walkontable/src/table/mixin/calculatedRows.js +0 -9
  32. package/3rdparty/walkontable/src/table/mixin/calculatedRows.mjs +0 -9
  33. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.js +0 -9
  34. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.mjs +0 -9
  35. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.js +0 -9
  36. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.mjs +0 -9
  37. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.js +0 -9
  38. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.mjs +0 -9
  39. package/3rdparty/walkontable/src/table.js +78 -6
  40. package/3rdparty/walkontable/src/table.mjs +79 -7
  41. package/base.js +2 -2
  42. package/base.mjs +2 -2
  43. package/common.d.ts +1 -1
  44. package/core.d.ts +3 -6
  45. package/core.js +293 -176
  46. package/core.mjs +293 -176
  47. package/dataMap/metaManager/metaSchema.js +0 -41
  48. package/dataMap/metaManager/metaSchema.mjs +0 -41
  49. package/dist/handsontable.css +4 -24
  50. package/dist/handsontable.full.css +4 -24
  51. package/dist/handsontable.full.js +5592 -8690
  52. package/dist/handsontable.full.min.css +3 -3
  53. package/dist/handsontable.full.min.js +25 -25
  54. package/dist/handsontable.js +8038 -11136
  55. package/dist/handsontable.min.css +3 -3
  56. package/dist/handsontable.min.js +19 -19
  57. package/editorManager.js +75 -11
  58. package/editorManager.mjs +74 -11
  59. package/editors/baseEditor/baseEditor.d.ts +1 -0
  60. package/editors/textEditor/textEditor.js +11 -3
  61. package/editors/textEditor/textEditor.mjs +12 -4
  62. package/helpers/mixed.js +1 -1
  63. package/helpers/mixed.mjs +1 -1
  64. package/helpers/number.d.ts +0 -1
  65. package/helpers/number.js +0 -18
  66. package/helpers/number.mjs +0 -17
  67. package/package.json +1 -1
  68. package/pluginHooks.d.ts +1 -7
  69. package/pluginHooks.js +1 -106
  70. package/pluginHooks.mjs +1 -106
  71. package/plugins/collapsibleColumns/collapsibleColumns.js +4 -58
  72. package/plugins/collapsibleColumns/collapsibleColumns.mjs +4 -58
  73. package/plugins/columnSorting/columnSorting.js +0 -38
  74. package/plugins/columnSorting/columnSorting.mjs +2 -38
  75. package/plugins/columnSorting/index.js +1 -3
  76. package/plugins/columnSorting/index.mjs +1 -1
  77. package/plugins/comments/commentEditor.js +0 -1
  78. package/plugins/comments/commentEditor.mjs +0 -1
  79. package/plugins/comments/comments.js +189 -251
  80. package/plugins/comments/comments.mjs +190 -250
  81. package/plugins/contextMenu/contextMenu.d.ts +1 -1
  82. package/plugins/contextMenu/contextMenu.js +30 -72
  83. package/plugins/contextMenu/contextMenu.mjs +31 -73
  84. package/plugins/contextMenu/predefinedItems/alignment.js +0 -7
  85. package/plugins/contextMenu/predefinedItems/alignment.mjs +0 -7
  86. package/plugins/contextMenu/predefinedItems/clearColumn.js +3 -5
  87. package/plugins/contextMenu/predefinedItems/clearColumn.mjs +3 -5
  88. package/plugins/contextMenu/predefinedItems/columnLeft.js +3 -5
  89. package/plugins/contextMenu/predefinedItems/columnLeft.mjs +3 -5
  90. package/plugins/contextMenu/predefinedItems/columnRight.js +3 -5
  91. package/plugins/contextMenu/predefinedItems/columnRight.mjs +3 -5
  92. package/plugins/contextMenu/predefinedItems/readOnly.js +0 -7
  93. package/plugins/contextMenu/predefinedItems/readOnly.mjs +0 -7
  94. package/plugins/contextMenu/predefinedItems/removeColumn.js +5 -7
  95. package/plugins/contextMenu/predefinedItems/removeColumn.mjs +3 -5
  96. package/plugins/contextMenu/predefinedItems/removeRow.js +5 -7
  97. package/plugins/contextMenu/predefinedItems/removeRow.mjs +3 -5
  98. package/plugins/contextMenu/predefinedItems/rowAbove.js +3 -5
  99. package/plugins/contextMenu/predefinedItems/rowAbove.mjs +3 -5
  100. package/plugins/contextMenu/predefinedItems/rowBelow.js +3 -5
  101. package/plugins/contextMenu/predefinedItems/rowBelow.mjs +3 -5
  102. package/plugins/contextMenu/utils.js +16 -28
  103. package/plugins/contextMenu/utils.mjs +15 -27
  104. package/plugins/copyPaste/contextMenuItem/copy.js +0 -7
  105. package/plugins/copyPaste/contextMenuItem/copy.mjs +0 -7
  106. package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.js +1 -9
  107. package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.mjs +1 -9
  108. package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.js +1 -9
  109. package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.mjs +1 -9
  110. package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.js +1 -9
  111. package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.mjs +1 -9
  112. package/plugins/copyPaste/contextMenuItem/cut.js +0 -7
  113. package/plugins/copyPaste/contextMenuItem/cut.mjs +0 -7
  114. package/plugins/copyPaste/copyPaste.js +10 -14
  115. package/plugins/copyPaste/copyPaste.mjs +10 -14
  116. package/plugins/customBorders/customBorders.js +20 -23
  117. package/plugins/customBorders/customBorders.mjs +21 -24
  118. package/plugins/dropdownMenu/dropdownMenu.d.ts +1 -1
  119. package/plugins/dropdownMenu/dropdownMenu.js +32 -89
  120. package/plugins/dropdownMenu/dropdownMenu.mjs +32 -89
  121. package/plugins/filters/filters.js +14 -31
  122. package/plugins/filters/filters.mjs +13 -30
  123. package/plugins/manualColumnResize/manualColumnResize.js +6 -0
  124. package/plugins/manualColumnResize/manualColumnResize.mjs +7 -1
  125. package/plugins/mergeCells/mergeCells.js +17 -5
  126. package/plugins/mergeCells/mergeCells.mjs +17 -5
  127. package/plugins/multiColumnSorting/multiColumnSorting.js +2 -37
  128. package/plugins/multiColumnSorting/multiColumnSorting.mjs +2 -37
  129. package/plugins/nestedHeaders/nestedHeaders.js +8 -121
  130. package/plugins/nestedHeaders/nestedHeaders.mjs +8 -121
  131. package/plugins/nestedHeaders/stateManager/index.js +0 -37
  132. package/plugins/nestedHeaders/stateManager/index.mjs +0 -37
  133. package/plugins/nestedRows/nestedRows.js +0 -41
  134. package/plugins/nestedRows/nestedRows.mjs +0 -41
  135. package/renderers/checkboxRenderer/checkboxRenderer.js +2 -2
  136. package/renderers/checkboxRenderer/checkboxRenderer.mjs +1 -1
  137. package/selection/highlight/constants.js +15 -0
  138. package/selection/highlight/constants.mjs +6 -0
  139. package/selection/highlight/highlight.js +71 -256
  140. package/selection/highlight/highlight.mjs +71 -250
  141. package/selection/highlight/types/activeHeader.js +8 -10
  142. package/selection/highlight/types/activeHeader.mjs +8 -10
  143. package/selection/highlight/types/area.js +18 -6
  144. package/selection/highlight/types/area.mjs +18 -6
  145. package/selection/highlight/types/{focus.js → cell.js} +7 -5
  146. package/selection/highlight/types/{focus.mjs → cell.mjs} +7 -5
  147. package/selection/highlight/types/customSelection.js +9 -7
  148. package/selection/highlight/types/customSelection.mjs +9 -7
  149. package/selection/highlight/types/fill.js +7 -5
  150. package/selection/highlight/types/fill.mjs +7 -5
  151. package/selection/highlight/types/header.js +18 -9
  152. package/selection/highlight/types/header.mjs +18 -9
  153. package/selection/highlight/types/index.js +35 -0
  154. package/selection/highlight/types/index.mjs +31 -0
  155. package/selection/highlight/visualSelection.js +27 -31
  156. package/selection/highlight/visualSelection.mjs +27 -31
  157. package/selection/index.js +7 -4
  158. package/selection/index.mjs +3 -2
  159. package/selection/mouseEventHandler.js +1 -1
  160. package/selection/mouseEventHandler.mjs +1 -1
  161. package/selection/range.js +8 -8
  162. package/selection/range.mjs +8 -8
  163. package/selection/selection.js +154 -293
  164. package/selection/selection.mjs +153 -290
  165. package/selection/transformation.js +90 -232
  166. package/selection/transformation.mjs +90 -232
  167. package/selection/utils.js +21 -15
  168. package/selection/utils.mjs +21 -16
  169. package/settings.d.ts +0 -2
  170. package/shortcuts/manager.js +0 -2
  171. package/shortcuts/manager.mjs +0 -2
  172. package/shortcuts/recorder.js +2 -2
  173. package/shortcuts/recorder.mjs +2 -2
  174. package/shortcuts/utils.js +5 -19
  175. package/shortcuts/utils.mjs +4 -18
  176. package/tableView.js +13 -67
  177. package/tableView.mjs +13 -67
  178. package/3rdparty/walkontable/src/selection/border/constants.js +0 -16
  179. package/3rdparty/walkontable/src/selection/border/constants.mjs +0 -12
  180. package/3rdparty/walkontable/src/selection/constants.js +0 -62
  181. package/3rdparty/walkontable/src/selection/constants.mjs +0 -51
  182. package/3rdparty/walkontable/src/selection/index.js +0 -26
  183. package/3rdparty/walkontable/src/selection/index.mjs +0 -5
  184. package/3rdparty/walkontable/src/selection/manager.js +0 -259
  185. package/3rdparty/walkontable/src/selection/manager.mjs +0 -254
  186. package/3rdparty/walkontable/src/selection/scanner.js +0 -270
  187. package/3rdparty/walkontable/src/selection/scanner.mjs +0 -267
  188. package/3rdparty/walkontable/src/selection/selection.js +0 -101
  189. package/3rdparty/walkontable/src/selection/selection.mjs +0 -96
  190. package/core/focusCatcher/focusDetector.js +0 -58
  191. package/core/focusCatcher/focusDetector.mjs +0 -54
  192. package/core/focusCatcher/index.js +0 -142
  193. package/core/focusCatcher/index.mjs +0 -138
  194. package/core/index.js +0 -9
  195. package/core/index.mjs +0 -1
  196. package/plugins/comments/contextMenuItem/addEditComment.js +0 -41
  197. package/plugins/comments/contextMenuItem/addEditComment.mjs +0 -35
  198. package/plugins/comments/contextMenuItem/readOnlyComment.js +0 -49
  199. package/plugins/comments/contextMenuItem/readOnlyComment.mjs +0 -43
  200. package/plugins/comments/contextMenuItem/removeComment.js +0 -38
  201. package/plugins/comments/contextMenuItem/removeComment.mjs +0 -32
  202. package/selection/highlight/types/areaLayered.js +0 -31
  203. package/selection/highlight/types/areaLayered.mjs +0 -26
  204. package/selection/highlight/types/column.js +0 -27
  205. package/selection/highlight/types/column.mjs +0 -22
  206. package/selection/highlight/types/row.js +0 -27
  207. package/selection/highlight/types/row.mjs +0 -22
  208. package/shortcutContexts/commands/editor/closeAndSave.js +0 -12
  209. package/shortcutContexts/commands/editor/closeAndSave.mjs +0 -8
  210. package/shortcutContexts/commands/editor/closeWithoutSaving.js +0 -12
  211. package/shortcutContexts/commands/editor/closeWithoutSaving.mjs +0 -8
  212. package/shortcutContexts/commands/editor/fastOpen.js +0 -16
  213. package/shortcutContexts/commands/editor/fastOpen.mjs +0 -12
  214. package/shortcutContexts/commands/editor/index.js +0 -16
  215. package/shortcutContexts/commands/editor/index.mjs +0 -12
  216. package/shortcutContexts/commands/editor/open.js +0 -27
  217. package/shortcutContexts/commands/editor/open.mjs +0 -23
  218. package/shortcutContexts/commands/emptySelectedCells.js +0 -11
  219. package/shortcutContexts/commands/emptySelectedCells.mjs +0 -7
  220. package/shortcutContexts/commands/extendCellsSelection/down.js +0 -15
  221. package/shortcutContexts/commands/extendCellsSelection/down.mjs +0 -11
  222. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +0 -21
  223. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +0 -17
  224. package/shortcutContexts/commands/extendCellsSelection/index.js +0 -26
  225. package/shortcutContexts/commands/extendCellsSelection/index.mjs +0 -22
  226. package/shortcutContexts/commands/extendCellsSelection/left.js +0 -15
  227. package/shortcutContexts/commands/extendCellsSelection/left.mjs +0 -11
  228. package/shortcutContexts/commands/extendCellsSelection/right.js +0 -15
  229. package/shortcutContexts/commands/extendCellsSelection/right.mjs +0 -11
  230. package/shortcutContexts/commands/extendCellsSelection/toColumns.js +0 -19
  231. package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +0 -15
  232. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +0 -29
  233. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +0 -25
  234. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +0 -19
  235. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +0 -15
  236. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +0 -19
  237. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +0 -15
  238. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +0 -29
  239. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +0 -25
  240. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +0 -29
  241. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +0 -25
  242. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +0 -29
  243. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +0 -25
  244. package/shortcutContexts/commands/extendCellsSelection/toRows.js +0 -19
  245. package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +0 -15
  246. package/shortcutContexts/commands/extendCellsSelection/up.js +0 -15
  247. package/shortcutContexts/commands/extendCellsSelection/up.mjs +0 -11
  248. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +0 -21
  249. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +0 -17
  250. package/shortcutContexts/commands/index.js +0 -35
  251. package/shortcutContexts/commands/index.mjs +0 -31
  252. package/shortcutContexts/commands/moveCellSelection/down.js +0 -13
  253. package/shortcutContexts/commands/moveCellSelection/down.mjs +0 -9
  254. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +0 -31
  255. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +0 -27
  256. package/shortcutContexts/commands/moveCellSelection/index.js +0 -28
  257. package/shortcutContexts/commands/moveCellSelection/index.mjs +0 -24
  258. package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +0 -12
  259. package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +0 -8
  260. package/shortcutContexts/commands/moveCellSelection/inlineStart.js +0 -12
  261. package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +0 -8
  262. package/shortcutContexts/commands/moveCellSelection/left.js +0 -10
  263. package/shortcutContexts/commands/moveCellSelection/left.mjs +0 -6
  264. package/shortcutContexts/commands/moveCellSelection/right.js +0 -10
  265. package/shortcutContexts/commands/moveCellSelection/right.mjs +0 -6
  266. package/shortcutContexts/commands/moveCellSelection/toMostBottom.js +0 -17
  267. package/shortcutContexts/commands/moveCellSelection/toMostBottom.mjs +0 -13
  268. package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.js +0 -18
  269. package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.mjs +0 -14
  270. package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.js +0 -14
  271. package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.mjs +0 -10
  272. package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.js +0 -17
  273. package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.mjs +0 -13
  274. package/shortcutContexts/commands/moveCellSelection/toMostLeft.js +0 -19
  275. package/shortcutContexts/commands/moveCellSelection/toMostLeft.mjs +0 -15
  276. package/shortcutContexts/commands/moveCellSelection/toMostRight.js +0 -21
  277. package/shortcutContexts/commands/moveCellSelection/toMostRight.mjs +0 -17
  278. package/shortcutContexts/commands/moveCellSelection/toMostTop.js +0 -17
  279. package/shortcutContexts/commands/moveCellSelection/toMostTop.mjs +0 -13
  280. package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.js +0 -19
  281. package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.mjs +0 -15
  282. package/shortcutContexts/commands/moveCellSelection/up.js +0 -13
  283. package/shortcutContexts/commands/moveCellSelection/up.mjs +0 -9
  284. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +0 -31
  285. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +0 -27
  286. package/shortcutContexts/commands/populateSelectedCellsData.js +0 -29
  287. package/shortcutContexts/commands/populateSelectedCellsData.mjs +0 -25
  288. package/shortcutContexts/commands/scrollToFocusedCell.js +0 -36
  289. package/shortcutContexts/commands/scrollToFocusedCell.mjs +0 -32
  290. package/shortcutContexts/commands/selectAll.js +0 -10
  291. package/shortcutContexts/commands/selectAll.mjs +0 -6
  292. package/shortcutContexts/constants.js +0 -13
  293. package/shortcutContexts/constants.mjs +0 -8
  294. package/shortcutContexts/editor.js +0 -25
  295. package/shortcutContexts/editor.mjs +0 -21
  296. package/shortcutContexts/grid.js +0 -163
  297. package/shortcutContexts/grid.mjs +0 -159
  298. package/shortcutContexts/index.js +0 -24
  299. package/shortcutContexts/index.mjs +0 -11
@@ -1,17 +1,13 @@
1
1
  import "core-js/modules/es.error.cause.js";
2
- 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; }
3
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
4
- 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); }
5
- import { CellCoords, CellRange } from "./../3rdparty/walkontable/src/index.mjs";
6
- import Highlight, { AREA_TYPE, HEADER_TYPE, FOCUS_TYPE } from "./highlight/highlight.mjs";
2
+ import Highlight from "./highlight/highlight.mjs";
3
+ import { AREA_TYPE, HEADER_TYPE, CELL_TYPE } from "./highlight/constants.mjs";
7
4
  import SelectionRange from "./range.mjs";
8
5
  import { createObjectPropListener, mixin } from "./../helpers/object.mjs";
9
6
  import { isUndefined } from "./../helpers/mixed.mjs";
10
- import { clamp } from "./../helpers/number.mjs";
11
7
  import { arrayEach } from "./../helpers/array.mjs";
12
8
  import localHooks from "./../mixins/localHooks.mjs";
13
9
  import Transformation from "./transformation.mjs";
14
- import { detectSelectionType, normalizeSelectionFactory, SELECTION_TYPE_EMPTY, SELECTION_TYPE_UNRECOGNIZED } from "./utils.mjs";
10
+ import { detectSelectionType, isValidCoord, normalizeSelectionFactory, SELECTION_TYPE_EMPTY, SELECTION_TYPE_UNRECOGNIZED } from "./utils.mjs";
15
11
  import { toSingleLine } from "./../helpers/templateLiteralTag.mjs";
16
12
  /**
17
13
  * @class Selection
@@ -25,62 +21,57 @@ class Selection {
25
21
  *
26
22
  * @type {GridSettings}
27
23
  */
28
- _defineProperty(this, "settings", void 0);
24
+ this.settings = settings;
29
25
  /**
30
26
  * An additional object with dynamically defined properties which describes table state.
31
27
  *
32
28
  * @type {object}
33
29
  */
34
- _defineProperty(this, "tableProps", void 0);
30
+ this.tableProps = tableProps;
35
31
  /**
36
32
  * The flag which determines if the selection is in progress.
37
33
  *
38
34
  * @type {boolean}
39
35
  */
40
- _defineProperty(this, "inProgress", false);
36
+ this.inProgress = false;
41
37
  /**
42
- * Selection data layer (handle visual coordinates).
38
+ * The flag indicates that selection was performed by clicking the corner overlay.
43
39
  *
44
- * @type {SelectionRange}
40
+ * @type {boolean}
45
41
  */
46
- _defineProperty(this, "selectedRange", new SelectionRange((highlight, from, to) => {
47
- return this.tableProps.createCellRange(highlight, from, to);
48
- }));
42
+ this.selectedByCorner = false;
49
43
  /**
50
- * Visualization layer.
44
+ * The collection of the selection layer levels where the whole row was selected using the row header or
45
+ * the corner header.
51
46
  *
52
- * @type {Highlight}
47
+ * @type {Set.<number>}
53
48
  */
54
- _defineProperty(this, "highlight", void 0);
49
+ this.selectedByRowHeader = new Set();
55
50
  /**
56
- * The module for modifying coordinates.
51
+ * The collection of the selection layer levels where the whole column was selected using the column header or
52
+ * the corner header.
57
53
  *
58
- * @type {Transformation}
54
+ * @type {Set.<number>}
59
55
  */
60
- _defineProperty(this, "transformation", void 0);
56
+ this.selectedByColumnHeader = new Set();
61
57
  /**
62
- * The collection of the selection layer levels where the whole row was selected using the row header or
63
- * the corner header.
58
+ * Selection data layer (handle visual coordinates).
64
59
  *
65
- * @type {Set<number>}
60
+ * @type {SelectionRange}
66
61
  */
67
- _defineProperty(this, "selectedByRowHeader", new Set());
62
+ this.selectedRange = new SelectionRange((highlight, from, to) => {
63
+ return this.tableProps.createCellRange(highlight, from, to);
64
+ });
68
65
  /**
69
- * The collection of the selection layer levels where the whole column was selected using the column header or
70
- * the corner header.
66
+ * Visualization layer.
71
67
  *
72
- * @type {Set<number>}
68
+ * @type {Highlight}
73
69
  */
74
- _defineProperty(this, "selectedByColumnHeader", new Set());
75
- this.settings = settings;
76
- this.tableProps = tableProps;
77
70
  this.highlight = new Highlight({
78
71
  headerClassName: settings.currentHeaderClassName,
79
72
  activeHeaderClassName: settings.activeHeaderClassName,
80
73
  rowClassName: settings.currentRowClassName,
81
74
  columnClassName: settings.currentColClassName,
82
- rowIndexMapper: this.tableProps.rowIndexMapper,
83
- columnIndexMapper: this.tableProps.columnIndexMapper,
84
75
  disabledCellSelection: (row, column) => this.tableProps.isDisabledCellSelection(row, column),
85
76
  cellCornerVisible: function () {
86
77
  return _this.isCellCornerVisible(...arguments);
@@ -91,19 +82,21 @@ class Selection {
91
82
  visualToRenderableCoords: coords => this.tableProps.visualToRenderableCoords(coords),
92
83
  renderableToVisualCoords: coords => this.tableProps.renderableToVisualCoords(coords),
93
84
  createCellCoords: (row, column) => this.tableProps.createCellCoords(row, column),
94
- createCellRange: (highlight, from, to) => this.tableProps.createCellRange(highlight, from, to)
85
+ createCellRange: (highlight, from, to) => this.tableProps.createCellRange(highlight, from, to),
86
+ rowIndexMapper: () => this.tableProps.rowIndexMapper(),
87
+ columnIndexMapper: () => this.tableProps.columnIndexMapper()
95
88
  });
89
+ /**
90
+ * The module for modifying coordinates.
91
+ *
92
+ * @type {Transformation}
93
+ */
96
94
  this.transformation = new Transformation(this.selectedRange, {
97
- rowIndexMapper: this.tableProps.rowIndexMapper,
98
- columnIndexMapper: this.tableProps.columnIndexMapper,
99
- countRenderableRows: () => this.tableProps.countRenderableRows(),
100
- countRenderableColumns: () => this.tableProps.countRenderableColumns(),
101
- countRowHeaders: () => this.tableProps.countRowHeaders(),
102
- countColHeaders: () => this.tableProps.countColHeaders(),
95
+ countRows: () => this.tableProps.countRowsTranslated(),
96
+ countCols: () => this.tableProps.countColsTranslated(),
103
97
  visualToRenderableCoords: coords => this.tableProps.visualToRenderableCoords(coords),
104
98
  renderableToVisualCoords: coords => this.tableProps.renderableToVisualCoords(coords),
105
99
  createCellCoords: (row, column) => this.tableProps.createCellCoords(row, column),
106
- navigableHeaders: () => settings.navigableHeaders,
107
100
  fixedRowsBottom: () => settings.fixedRowsBottom,
108
101
  minSpareRows: () => settings.minSpareRows,
109
102
  minSpareCols: () => settings.minSpareCols,
@@ -158,14 +151,14 @@ class Selection {
158
151
  }
159
152
 
160
153
  /**
161
- * Indicate that selection process began. It sets internally `.inProgress` property to `true`.
154
+ * Indicate that selection process began. It sets internaly `.inProgress` property to `true`.
162
155
  */
163
156
  begin() {
164
157
  this.inProgress = true;
165
158
  }
166
159
 
167
160
  /**
168
- * Indicate that selection process finished. It sets internally `.inProgress` property to `false`.
161
+ * Indicate that selection process finished. It sets internaly `.inProgress` property to `false`.
169
162
  */
170
163
  finish() {
171
164
  this.runLocalHooks('afterSelectionFinished', Array.from(this.selectedRange));
@@ -190,25 +183,33 @@ class Selection {
190
183
  * the default trigger will be used.
191
184
  * @param {boolean} [fragment=false] If `true`, the selection will be treated as a partial selection where the
192
185
  * `setRangeEnd` method won't be called on every `setRangeStart` call.
193
- * @param {CellCoords} [highlightCoords] If set, allows changing the coordinates of the highlight/focus cell.
194
186
  */
195
187
  setRangeStart(coords, multipleSelection) {
196
188
  let fragment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
197
- let highlightCoords = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : coords;
198
189
  const isMultipleMode = this.settings.selectionMode === 'multiple';
199
190
  const isMultipleSelection = isUndefined(multipleSelection) ? this.tableProps.getShortcutManager().isCtrlPressed() : multipleSelection;
191
+ const isRowNegative = coords.row < 0;
192
+ const isColumnNegative = coords.col < 0;
193
+ const selectedByCorner = isRowNegative && isColumnNegative;
200
194
  // We are creating copy. We would like to modify just the start of the selection by below hook. Then original coords
201
195
  // should be handled by next methods.
202
196
  const coordsClone = coords.clone();
197
+ this.selectedByCorner = selectedByCorner;
203
198
  this.runLocalHooks(`beforeSetRangeStart${fragment ? 'Only' : ''}`, coordsClone);
204
199
  if (!isMultipleMode || isMultipleMode && !isMultipleSelection && isUndefined(multipleSelection)) {
205
200
  this.selectedRange.clear();
206
201
  }
207
- this.selectedRange.add(coordsClone).current().setHighlight(highlightCoords.clone());
202
+ this.selectedRange.add(coordsClone);
208
203
  if (this.getLayerLevel() === 0) {
209
204
  this.selectedByRowHeader.clear();
210
205
  this.selectedByColumnHeader.clear();
211
206
  }
207
+ if (!selectedByCorner && isColumnNegative) {
208
+ this.selectedByRowHeader.add(this.getLayerLevel());
209
+ }
210
+ if (!selectedByCorner && isRowNegative) {
211
+ this.selectedByColumnHeader.add(this.getLayerLevel());
212
+ }
212
213
  if (!fragment) {
213
214
  this.setRangeEnd(coords);
214
215
  }
@@ -221,11 +222,9 @@ class Selection {
221
222
  * @param {boolean} [multipleSelection] If `true`, selection will be worked in 'multiple' mode. This option works
222
223
  * only when 'selectionMode' is set as 'multiple'. If the argument is not defined
223
224
  * the default trigger will be used.
224
- * @param {CellCoords} [highlightCoords] If set, allows changing the coordinates of the highlight/focus cell.
225
225
  */
226
226
  setRangeStartOnly(coords, multipleSelection) {
227
- let highlightCoords = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : coords;
228
- this.setRangeStart(coords, multipleSelection, true, highlightCoords);
227
+ this.setRangeStart(coords, multipleSelection, true);
229
228
  }
230
229
 
231
230
  /**
@@ -237,39 +236,21 @@ class Selection {
237
236
  if (this.selectedRange.isEmpty()) {
238
237
  return;
239
238
  }
240
- const coordsClone = coords.clone();
241
- const countRows = this.tableProps.countRows();
242
- const countCols = this.tableProps.countCols();
243
- const isSingle = this.selectedRange.current().clone().setTo(coords).isSingleHeader();
244
239
 
245
- // Ignore processing the end range when the header selection starts overlapping the corner and
246
- // the selection is not a single header highlight.
247
- if ((countRows > 0 || countCols > 0) && (countRows === 0 && coordsClone.col < 0 && !isSingle || countCols === 0 && coordsClone.row < 0 && !isSingle)) {
248
- return;
249
- }
240
+ // We are creating copy. We would like to modify just the end of the selection by below hook. Then original coords
241
+ // should be handled by next methods.
242
+ const coordsClone = coords.clone();
250
243
  this.runLocalHooks('beforeSetRangeEnd', coordsClone);
251
244
  this.begin();
252
245
  const cellRange = this.selectedRange.current();
253
- if (!this.settings.navigableHeaders) {
254
- cellRange.highlight.normalize();
255
- }
256
- if (this.settings.selectionMode === 'single') {
257
- cellRange.setFrom(cellRange.highlight);
258
- cellRange.setTo(cellRange.highlight);
259
- } else {
260
- cellRange.setTo(coordsClone);
246
+ if (this.settings.selectionMode !== 'single') {
247
+ cellRange.setTo(this.tableProps.createCellCoords(coordsClone.row, coordsClone.col));
261
248
  }
262
249
 
263
- // Prevent creating "area" selection that overlaps headers.
264
- if (countRows > 0 && countCols > 0) {
265
- if (!this.settings.navigableHeaders || this.settings.navigableHeaders && !cellRange.isSingleHeader()) {
266
- cellRange.to.normalize();
267
- }
268
- }
269
- const focusHighlight = this.highlight.getFocus();
270
- focusHighlight.clear();
271
- if (this.highlight.isEnabledFor(FOCUS_TYPE, cellRange.highlight)) {
272
- focusHighlight.add(this.selectedRange.current().highlight).commit().syncWith(cellRange);
250
+ // Set up current selection.
251
+ this.highlight.getCell().clear();
252
+ if (this.highlight.isEnabledFor(CELL_TYPE, cellRange.highlight)) {
253
+ this.highlight.getCell().add(this.selectedRange.current().highlight).commit().syncWith(cellRange);
273
254
  }
274
255
  const layerLevel = this.getLayerLevel();
275
256
 
@@ -277,80 +258,69 @@ class Selection {
277
258
  // indication that the new selection is performing.
278
259
  if (layerLevel < this.highlight.layerLevel) {
279
260
  arrayEach(this.highlight.getAreas(), highlight => void highlight.clear());
280
- arrayEach(this.highlight.getLayeredAreas(), highlight => void highlight.clear());
281
- arrayEach(this.highlight.getRowHeaders(), highlight => void highlight.clear());
282
- arrayEach(this.highlight.getColumnHeaders(), highlight => void highlight.clear());
283
- arrayEach(this.highlight.getActiveRowHeaders(), highlight => void highlight.clear());
284
- arrayEach(this.highlight.getActiveColumnHeaders(), highlight => void highlight.clear());
285
- arrayEach(this.highlight.getActiveCornerHeaders(), highlight => void highlight.clear());
286
- arrayEach(this.highlight.getRowHighlights(), highlight => void highlight.clear());
287
- arrayEach(this.highlight.getColumnHighlights(), highlight => void highlight.clear());
261
+ arrayEach(this.highlight.getHeaders(), highlight => void highlight.clear());
262
+ arrayEach(this.highlight.getActiveHeaders(), highlight => void highlight.clear());
288
263
  }
289
264
  this.highlight.useLayerLevel(layerLevel);
290
- const areaHighlight = this.highlight.createArea();
291
- const layeredAreaHighlight = this.highlight.createLayeredArea();
292
- const rowHeaderHighlight = this.highlight.createRowHeader();
293
- const columnHeaderHighlight = this.highlight.createColumnHeader();
294
- const activeRowHeaderHighlight = this.highlight.createActiveRowHeader();
295
- const activeColumnHeaderHighlight = this.highlight.createActiveColumnHeader();
296
- const activeCornerHeaderHighlight = this.highlight.createActiveCornerHeader();
297
- const rowHighlight = this.highlight.createRowHighlight();
298
- const columnHighlight = this.highlight.createColumnHighlight();
265
+ const areaHighlight = this.highlight.createOrGetArea();
266
+ const headerHighlight = this.highlight.createOrGetHeader();
267
+ const activeHeaderHighlight = this.highlight.createOrGetActiveHeader();
299
268
  areaHighlight.clear();
300
- layeredAreaHighlight.clear();
301
- rowHeaderHighlight.clear();
302
- columnHeaderHighlight.clear();
303
- activeRowHeaderHighlight.clear();
304
- activeColumnHeaderHighlight.clear();
305
- activeCornerHeaderHighlight.clear();
306
- rowHighlight.clear();
307
- columnHighlight.clear();
269
+ headerHighlight.clear();
270
+ activeHeaderHighlight.clear();
308
271
  if (this.highlight.isEnabledFor(AREA_TYPE, cellRange.highlight) && (this.isMultiple() || layerLevel >= 1)) {
309
272
  areaHighlight.add(cellRange.from).add(cellRange.to).commit();
310
- layeredAreaHighlight.add(cellRange.from).add(cellRange.to).commit();
311
273
  if (layerLevel === 1) {
312
274
  // For single cell selection in the same layer, we do not create area selection to prevent blue background.
313
275
  // When non-consecutive selection is performed we have to add that missing area selection to the previous layer
314
276
  // based on previous coordinates. It only occurs when the previous selection wasn't select multiple cells.
315
277
  const previousRange = this.selectedRange.previous();
316
- this.highlight.useLayerLevel(layerLevel - 1);
317
- this.highlight.createArea().add(previousRange.from).commit()
318
- // Range may start with hidden indexes. Commit would not found start point (as we add just the `from` coords).
319
- .syncWith(previousRange);
320
- this.highlight.createLayeredArea().add(previousRange.from).commit()
278
+ this.highlight.useLayerLevel(layerLevel - 1).createOrGetArea().add(previousRange.from).commit()
321
279
  // Range may start with hidden indexes. Commit would not found start point (as we add just the `from` coords).
322
280
  .syncWith(previousRange);
323
281
  this.highlight.useLayerLevel(layerLevel);
324
282
  }
325
283
  }
326
284
  if (this.highlight.isEnabledFor(HEADER_TYPE, cellRange.highlight)) {
327
- if (!cellRange.isSingleHeader()) {
328
- const rowCoordsFrom = this.tableProps.createCellCoords(Math.max(cellRange.from.row, 0), -1);
329
- const rowCoordsTo = this.tableProps.createCellCoords(cellRange.to.row, -1);
330
- const columnCoordsFrom = this.tableProps.createCellCoords(-1, Math.max(cellRange.from.col, 0));
331
- const columnCoordsTo = this.tableProps.createCellCoords(-1, cellRange.to.col);
332
- if (this.settings.selectionMode === 'single') {
333
- rowHeaderHighlight.add(rowCoordsFrom).commit();
334
- columnHeaderHighlight.add(columnCoordsFrom).commit();
335
- rowHighlight.add(rowCoordsFrom).commit();
336
- columnHighlight.add(columnCoordsFrom).commit();
337
- } else {
338
- rowHeaderHighlight.add(rowCoordsFrom).add(rowCoordsTo).commit();
339
- columnHeaderHighlight.add(columnCoordsFrom).add(columnCoordsTo).commit();
340
- rowHighlight.add(rowCoordsFrom).add(rowCoordsTo).commit();
341
- columnHighlight.add(columnCoordsFrom).add(columnCoordsTo).commit();
342
- }
285
+ // The header selection generally contains cell selection. In a case when all rows (or columns)
286
+ // are hidden that visual coordinates are translated to renderable coordinates that do not exist.
287
+ // Hence no header highlight is generated. In that case, to make a column (or a row) header
288
+ // highlight, the row and column index has to point to the header (the negative value). See #7052.
289
+ const areAnyRowsRendered = this.tableProps.countRowsTranslated() === 0;
290
+ const areAnyColumnsRendered = this.tableProps.countColsTranslated() === 0;
291
+ let headerCellRange = cellRange;
292
+ if (areAnyRowsRendered || areAnyColumnsRendered) {
293
+ headerCellRange = cellRange.clone();
294
+ }
295
+ if (areAnyRowsRendered) {
296
+ headerCellRange.from.row = -1;
343
297
  }
344
- const highlightRowHeaders = this.isEntireRowSelected() && (countCols > 0 && countCols === cellRange.getWidth() || countCols === 0 && (this.isSelectedByRowHeader() || this.isSelectedByCorner()));
345
- const highlightColumnHeaders = this.isEntireColumnSelected() && (countRows > 0 && countRows === cellRange.getHeight() || countRows === 0 && (this.isSelectedByColumnHeader() || this.isSelectedByCorner()));
346
- if (highlightRowHeaders) {
347
- activeRowHeaderHighlight.add(this.tableProps.createCellCoords(Math.max(cellRange.from.row, 0), Math.min(-this.tableProps.countRowHeaders(), -1))).add(this.tableProps.createCellCoords(Math.max(cellRange.to.row, 0), -1)).commit();
298
+ if (areAnyColumnsRendered) {
299
+ headerCellRange.from.col = -1;
348
300
  }
349
- if (highlightColumnHeaders) {
350
- activeColumnHeaderHighlight.add(this.tableProps.createCellCoords(Math.min(-this.tableProps.countColHeaders(), -1), Math.max(cellRange.from.col, 0))).add(this.tableProps.createCellCoords(-1, Math.max(cellRange.to.col, 0))).commit();
301
+ if (this.settings.selectionMode === 'single') {
302
+ if (this.isSelectedByAnyHeader()) {
303
+ headerCellRange.from.normalize();
304
+ }
305
+ headerHighlight.add(headerCellRange.from).commit();
306
+ } else {
307
+ headerHighlight.add(headerCellRange.from).add(headerCellRange.to).commit();
351
308
  }
352
- if (highlightRowHeaders && highlightColumnHeaders) {
353
- activeCornerHeaderHighlight.add(this.tableProps.createCellCoords(-this.tableProps.countColHeaders(), -this.tableProps.countRowHeaders())).add(this.tableProps.createCellCoords(-1, -1)).commit();
309
+ if (this.isEntireRowSelected()) {
310
+ const isRowSelected = this.tableProps.countCols() === cellRange.getWidth();
311
+
312
+ // Make sure that the whole row is selected (in case where selectionMode is set to 'single')
313
+ if (isRowSelected) {
314
+ activeHeaderHighlight.add(this.tableProps.createCellCoords(cellRange.from.row, -1)).add(this.tableProps.createCellCoords(cellRange.to.row, -1)).commit();
315
+ }
316
+ }
317
+ if (this.isEntireColumnSelected()) {
318
+ const isColumnSelected = this.tableProps.countRows() === cellRange.getHeight();
319
+
320
+ // Make sure that the whole column is selected (in case where selectionMode is set to 'single')
321
+ if (isColumnSelected) {
322
+ activeHeaderHighlight.add(this.tableProps.createCellCoords(-1, cellRange.from.col)).add(this.tableProps.createCellCoords(-1, cellRange.to.col)).commit();
323
+ }
354
324
  }
355
325
  }
356
326
  this.runLocalHooks('afterSetRangeEnd', coords);
@@ -373,12 +343,12 @@ class Selection {
373
343
  *
374
344
  * @param {number} rowDelta Rows number to move, value can be passed as negative number.
375
345
  * @param {number} colDelta Columns number to move, value can be passed as negative number.
376
- * @param {boolean} [createMissingRecords=false] If `true` the new rows/columns will be created if necessary.
377
- * Otherwise, row/column will be created according to `minSpareRows/minSpareCols` settings of Handsontable.
346
+ * @param {boolean} [force=false] If `true` the new rows/columns will be created if necessary. Otherwise, row/column will
347
+ * be created according to `minSpareRows/minSpareCols` settings of Handsontable.
378
348
  */
379
349
  transformStart(rowDelta, colDelta) {
380
- let createMissingRecords = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
381
- this.setRangeStart(this.transformation.transformStart(rowDelta, colDelta, createMissingRecords));
350
+ let force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
351
+ this.setRangeStart(this.transformation.transformStart(rowDelta, colDelta, force));
382
352
  }
383
353
 
384
354
  /**
@@ -419,7 +389,7 @@ class Selection {
419
389
  */
420
390
  isSelectedByRowHeader() {
421
391
  let layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
422
- return !this.isSelectedByCorner(layerLevel) && (layerLevel === -1 ? this.selectedByRowHeader.size > 0 : this.selectedByRowHeader.has(layerLevel));
392
+ return !this.isSelectedByCorner(layerLevel) && this.isEntireRowSelected(layerLevel);
423
393
  }
424
394
 
425
395
  /**
@@ -431,19 +401,7 @@ class Selection {
431
401
  */
432
402
  isEntireRowSelected() {
433
403
  let layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
434
- const tester = range => {
435
- const {
436
- col
437
- } = range.getOuterTopStartCorner();
438
- const rowHeaders = this.tableProps.countRowHeaders();
439
- const countCols = this.tableProps.countCols();
440
- return (rowHeaders > 0 && col < 0 || rowHeaders === 0) && range.getWidth() === countCols;
441
- };
442
- if (layerLevel === -1) {
443
- return Array.from(this.selectedRange).some(range => tester(range));
444
- }
445
- const range = this.selectedRange.peekByIndex(layerLevel);
446
- return range ? tester(range) : false;
404
+ return layerLevel === -1 ? this.selectedByRowHeader.size > 0 : this.selectedByRowHeader.has(layerLevel);
447
405
  }
448
406
 
449
407
  /**
@@ -456,7 +414,7 @@ class Selection {
456
414
  */
457
415
  isSelectedByColumnHeader() {
458
416
  let layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
459
- return !this.isSelectedByCorner() && (layerLevel === -1 ? this.selectedByColumnHeader.size > 0 : this.selectedByColumnHeader.has(layerLevel));
417
+ return !this.isSelectedByCorner() && this.isEntireColumnSelected(layerLevel);
460
418
  }
461
419
 
462
420
  /**
@@ -468,19 +426,7 @@ class Selection {
468
426
  */
469
427
  isEntireColumnSelected() {
470
428
  let layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
471
- const tester = range => {
472
- const {
473
- row
474
- } = range.getOuterTopStartCorner();
475
- const colHeaders = this.tableProps.countColHeaders();
476
- const countRows = this.tableProps.countRows();
477
- return (colHeaders > 0 && row < 0 || colHeaders === 0) && range.getHeight() === countRows;
478
- };
479
- if (layerLevel === -1) {
480
- return Array.from(this.selectedRange).some(range => tester(range));
481
- }
482
- const range = this.selectedRange.peekByIndex(layerLevel);
483
- return range ? tester(range) : false;
429
+ return layerLevel === -1 ? this.selectedByColumnHeader.size > 0 : this.selectedByColumnHeader.has(layerLevel);
484
430
  }
485
431
 
486
432
  /**
@@ -498,7 +444,7 @@ class Selection {
498
444
  * @returns {boolean}
499
445
  */
500
446
  isSelectedByCorner() {
501
- return this.selectedByColumnHeader.has(this.getLayerLevel()) && this.selectedByRowHeader.has(this.getLayerLevel());
447
+ return this.selectedByCorner;
502
448
  }
503
449
 
504
450
  /**
@@ -557,50 +503,29 @@ class Selection {
557
503
  }
558
504
 
559
505
  /**
560
- * Selects all cells and headers.
506
+ * Select all cells.
561
507
  *
562
- * @param {boolean} [includeRowHeaders=false] `true` If the selection should include the row headers,
563
- * `false` otherwise.
564
- * @param {boolean} [includeColumnHeaders=false] `true` If the selection should include the column
565
- * headers, `false` otherwise.
566
- * @param {{row: number, col: number} | false} [focusPosition] The argument allows changing the cell/header
567
- * focus position. The value takes an object with a `row` and `col` properties from -N to N, where
568
- * negative values point to the headers and positive values point to the cell range.
508
+ * @param {boolean} [includeRowHeaders=false] `true` If the selection should include the row headers, `false`
509
+ * otherwise.
510
+ * @param {boolean} [includeColumnHeaders=false] `true` If the selection should include the column headers, `false`
511
+ * otherwise.
569
512
  */
570
513
  selectAll() {
571
- var _this$getSelectedRang;
572
514
  let includeRowHeaders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
573
515
  let includeColumnHeaders = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
574
- let focusPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
575
516
  const nrOfRows = this.tableProps.countRows();
576
517
  const nrOfColumns = this.tableProps.countCols();
577
- const countRowHeaders = this.tableProps.countRowHeaders();
578
- const countColHeaders = this.tableProps.countColHeaders();
579
- const rowFrom = includeRowHeaders ? -countColHeaders : 0;
580
- const columnFrom = includeColumnHeaders ? -countRowHeaders : 0;
581
518
 
582
519
  // We can't select cells when there is no data.
583
- if (rowFrom === 0 && columnFrom === 0 && (nrOfRows === 0 || nrOfColumns === 0)) {
520
+ if (!includeRowHeaders && !includeColumnHeaders && (nrOfRows === 0 || nrOfColumns === 0)) {
584
521
  return;
585
522
  }
586
- let highlight = (_this$getSelectedRang = this.getSelectedRange().current()) === null || _this$getSelectedRang === void 0 ? void 0 : _this$getSelectedRang.highlight;
587
- let isSelectedByCorner = false;
588
- if (focusPosition && Number.isInteger(focusPosition === null || focusPosition === void 0 ? void 0 : focusPosition.row) && Number.isInteger(focusPosition === null || focusPosition === void 0 ? void 0 : focusPosition.col)) {
589
- isSelectedByCorner = focusPosition.row < 0 && focusPosition.col < 0;
590
- highlight = this.tableProps.createCellCoords(clamp(focusPosition.row, rowFrom, nrOfRows - 1), clamp(focusPosition.col, columnFrom, nrOfColumns - 1));
591
- }
592
- const startCoords = this.tableProps.createCellCoords(rowFrom, columnFrom);
523
+ const startCoords = this.tableProps.createCellCoords(includeColumnHeaders ? -1 : 0, includeRowHeaders ? -1 : 0);
593
524
  const endCoords = this.tableProps.createCellCoords(nrOfRows - 1, nrOfColumns - 1);
594
525
  this.clear();
595
- this.setRangeStartOnly(startCoords, void 0, highlight);
596
- if (isSelectedByCorner) {
597
- this.selectedByRowHeader.add(this.getLayerLevel());
598
- this.selectedByColumnHeader.add(this.getLayerLevel());
599
- } else if (columnFrom < 0) {
600
- this.selectedByRowHeader.add(this.getLayerLevel());
601
- } else if (rowFrom < 0) {
602
- this.selectedByColumnHeader.add(this.getLayerLevel());
603
- }
526
+ this.setRangeStartOnly(startCoords);
527
+ this.selectedByRowHeader.add(this.getLayerLevel());
528
+ this.selectedByColumnHeader.add(this.getLayerLevel());
604
529
  this.setRangeEnd(endCoords);
605
530
  this.finish();
606
531
  }
@@ -627,29 +552,21 @@ class Selection {
627
552
  propToCol: prop => this.tableProps.propToCol(prop),
628
553
  keepDirection: true
629
554
  });
630
- const navigableHeaders = this.settings.navigableHeaders;
631
- const tableParams = {
632
- countRows: this.tableProps.countRows(),
633
- countCols: this.tableProps.countCols(),
634
- countRowHeaders: navigableHeaders ? this.tableProps.countRowHeaders() : 0,
635
- countColHeaders: navigableHeaders ? this.tableProps.countColHeaders() : 0
636
- };
555
+ const nrOfRows = this.tableProps.countRows();
556
+ const nrOfColumns = this.tableProps.countCols();
637
557
 
638
558
  // Check if every layer of the coordinates are valid.
639
559
  const isValid = !selectionRanges.some(selection => {
640
- const cellRange = selectionSchemaNormalizer(selection);
641
- const rangeValidity = cellRange.isValid(tableParams);
642
- return !(rangeValidity && !cellRange.containsHeaders() || rangeValidity && cellRange.containsHeaders() && cellRange.isSingleHeader());
560
+ const [rowStart, columnStart, rowEnd, columnEnd] = selectionSchemaNormalizer(selection);
561
+ const _isValid = isValidCoord(rowStart, nrOfRows) && isValidCoord(columnStart, nrOfColumns) && isValidCoord(rowEnd, nrOfRows) && isValidCoord(columnEnd, nrOfColumns);
562
+ return !_isValid;
643
563
  });
644
564
  if (isValid) {
645
565
  this.clear();
646
566
  arrayEach(selectionRanges, selection => {
647
- const {
648
- from,
649
- to
650
- } = selectionSchemaNormalizer(selection);
651
- this.setRangeStartOnly(from.clone(), false);
652
- this.setRangeEnd(to.clone());
567
+ const [rowStart, columnStart, rowEnd, columnEnd] = selectionSchemaNormalizer(selection);
568
+ this.setRangeStartOnly(this.tableProps.createCellCoords(rowStart, columnStart), false);
569
+ this.setRangeEnd(this.tableProps.createCellCoords(rowEnd, columnEnd));
653
570
  this.finish();
654
571
  });
655
572
  }
@@ -662,43 +579,22 @@ class Selection {
662
579
  *
663
580
  * @param {number|string} startColumn Visual column index or column property from which the selection starts.
664
581
  * @param {number|string} [endColumn] Visual column index or column property from to the selection finishes.
665
- * @param {number} [focusPosition=0] The argument allows changing the cell/header focus position.
666
- * The value can take visual row index from -N to N, where negative values
667
- * point to the headers and positive values point to the cell range.
582
+ * @param {number} [headerLevel=-1] A row header index that triggers the column selection. The value can
583
+ * take -1 to -N, where -1 means the header closest to the cells.
584
+ *
668
585
  * @returns {boolean} Returns `true` if selection was successful, `false` otherwise.
669
586
  */
670
587
  selectColumns(startColumn) {
671
588
  let endColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startColumn;
672
- let focusPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
589
+ let headerLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
673
590
  const start = typeof startColumn === 'string' ? this.tableProps.propToCol(startColumn) : startColumn;
674
591
  const end = typeof endColumn === 'string' ? this.tableProps.propToCol(endColumn) : endColumn;
675
- const countRows = this.tableProps.countRows();
676
- const countCols = this.tableProps.countCols();
677
- const countColHeaders = this.tableProps.countColHeaders();
678
- const columnHeaderLastIndex = countColHeaders === 0 ? 0 : -countColHeaders;
679
- const fromCoords = new CellCoords(columnHeaderLastIndex, start);
680
- const toCoords = new CellCoords(countRows - 1, end);
681
- const isValid = new CellRange(fromCoords, fromCoords, toCoords).isValid({
682
- countRows,
683
- countCols,
684
- countRowHeaders: 0,
685
- countColHeaders
686
- });
592
+ const nrOfColumns = this.tableProps.countCols();
593
+ const nrOfRows = this.tableProps.countRows();
594
+ const isValid = isValidCoord(start, nrOfColumns) && isValidCoord(end, nrOfColumns);
687
595
  if (isValid) {
688
- const fromRow = countColHeaders === 0 ? 0 : clamp(focusPosition, columnHeaderLastIndex, -1);
689
- const toRow = countRows - 1;
690
- const from = this.tableProps.createCellCoords(fromRow, start);
691
- const to = this.tableProps.createCellCoords(toRow, end);
692
- const highlight = this.tableProps.createCellCoords(clamp(focusPosition, columnHeaderLastIndex, countRows - 1), start);
693
- this.runLocalHooks('beforeSelectColumns', from, to, highlight);
694
-
695
- // disallow modifying row axis for that hooks
696
- from.row = fromRow;
697
- to.row = toRow;
698
- this.setRangeStartOnly(from, void 0, highlight);
699
- this.selectedByColumnHeader.add(this.getLayerLevel());
700
- this.setRangeEnd(to);
701
- this.runLocalHooks('afterSelectColumns', from, to, highlight);
596
+ this.setRangeStartOnly(this.tableProps.createCellCoords(headerLevel, start));
597
+ this.setRangeEnd(this.tableProps.createCellCoords(nrOfRows - 1, end));
702
598
  this.finish();
703
599
  }
704
600
  return isValid;
@@ -709,41 +605,20 @@ class Selection {
709
605
  *
710
606
  * @param {number} startRow Visual row index from which the selection starts.
711
607
  * @param {number} [endRow] Visual row index from to the selection finishes.
712
- * @param {number} [focusPosition=0] The argument allows changing the cell/header focus position.
713
- * The value can take visual column index from -N to N, where negative values
714
- * point to the headers and positive values point to the cell range.
608
+ * @param {number} [headerLevel=-1] A column header index that triggers the row selection.
609
+ * The value can take -1 to -N, where -1 means the header
610
+ * closest to the cells.
715
611
  * @returns {boolean} Returns `true` if selection was successful, `false` otherwise.
716
612
  */
717
613
  selectRows(startRow) {
718
614
  let endRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startRow;
719
- let focusPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
720
- const countRows = this.tableProps.countRows();
721
- const countCols = this.tableProps.countCols();
722
- const countRowHeaders = this.tableProps.countRowHeaders();
723
- const rowHeaderLastIndex = countRowHeaders === 0 ? 0 : -countRowHeaders;
724
- const fromCoords = new CellCoords(startRow, rowHeaderLastIndex);
725
- const toCoords = new CellCoords(endRow, countCols - 1);
726
- const isValid = new CellRange(fromCoords, fromCoords, toCoords).isValid({
727
- countRows,
728
- countCols,
729
- countRowHeaders,
730
- countColHeaders: 0
731
- });
615
+ let headerLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
616
+ const nrOfRows = this.tableProps.countRows();
617
+ const nrOfColumns = this.tableProps.countCols();
618
+ const isValid = isValidCoord(startRow, nrOfRows) && isValidCoord(endRow, nrOfRows);
732
619
  if (isValid) {
733
- const fromColumn = countRowHeaders === 0 ? 0 : clamp(focusPosition, rowHeaderLastIndex, -1);
734
- const toColumn = countCols - 1;
735
- const from = this.tableProps.createCellCoords(startRow, fromColumn);
736
- const to = this.tableProps.createCellCoords(endRow, toColumn);
737
- const highlight = this.tableProps.createCellCoords(startRow, clamp(focusPosition, rowHeaderLastIndex, countCols - 1));
738
- this.runLocalHooks('beforeSelectRows', from, to, highlight);
739
-
740
- // disallow modifying column axis for that hooks
741
- from.col = fromColumn;
742
- to.col = toColumn;
743
- this.setRangeStartOnly(from, void 0, highlight);
744
- this.selectedByRowHeader.add(this.getLayerLevel());
745
- this.setRangeEnd(to);
746
- this.runLocalHooks('afterSelectRows', from, to, highlight);
620
+ this.setRangeStartOnly(this.tableProps.createCellCoords(startRow, headerLevel));
621
+ this.setRangeEnd(this.tableProps.createCellCoords(endRow, nrOfColumns - 1));
747
622
  this.finish();
748
623
  }
749
624
  return isValid;
@@ -760,31 +635,19 @@ class Selection {
760
635
  if (!this.isSelected()) {
761
636
  return;
762
637
  }
763
- const focusHighlight = this.highlight.getFocus();
638
+ const cellHighlight = this.highlight.getCell();
764
639
  const currentLayer = this.getLayerLevel();
765
- focusHighlight.commit().syncWith(this.selectedRange.current());
640
+ cellHighlight.commit().syncWith(this.selectedRange.current());
766
641
 
767
642
  // Rewriting rendered ranges going through all layers.
768
643
  for (let layerLevel = 0; layerLevel < this.selectedRange.size(); layerLevel += 1) {
769
644
  this.highlight.useLayerLevel(layerLevel);
770
- const areaHighlight = this.highlight.createArea();
771
- const areaLayeredHighlight = this.highlight.createLayeredArea();
772
- const rowHeaderHighlight = this.highlight.createRowHeader();
773
- const columnHeaderHighlight = this.highlight.createColumnHeader();
774
- const activeRowHeaderHighlight = this.highlight.createActiveRowHeader();
775
- const activeColumnHeaderHighlight = this.highlight.createActiveColumnHeader();
776
- const activeCornerHeaderHighlight = this.highlight.createActiveCornerHeader();
777
- const rowHighlight = this.highlight.createRowHighlight();
778
- const columnHighlight = this.highlight.createColumnHighlight();
645
+ const areaHighlight = this.highlight.createOrGetArea();
646
+ const headerHighlight = this.highlight.createOrGetHeader();
647
+ const activeHeaderHighlight = this.highlight.createOrGetActiveHeader();
779
648
  areaHighlight.commit();
780
- areaLayeredHighlight.commit();
781
- rowHeaderHighlight.commit();
782
- columnHeaderHighlight.commit();
783
- activeRowHeaderHighlight.commit();
784
- activeColumnHeaderHighlight.commit();
785
- activeCornerHeaderHighlight.commit();
786
- rowHighlight.commit();
787
- columnHighlight.commit();
649
+ headerHighlight.commit();
650
+ activeHeaderHighlight.commit();
788
651
  }
789
652
 
790
653
  // Reverting starting layer for the Highlight.