handsontable 0.0.0-next-b66c79f-20230713 → 0.0.0-next-08765b9-20230714

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