handsontable 0.0.0-next-08765b9-20230809 → 0.0.0-next-7e1ba35-20230821

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 (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 +290 -173
  46. package/core.mjs +290 -173
  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 +5384 -8679
  52. package/dist/handsontable.full.min.css +3 -4
  53. package/dist/handsontable.full.min.js +960 -29
  54. package/dist/handsontable.js +8132 -11427
  55. package/dist/handsontable.min.css +3 -4
  56. package/dist/handsontable.min.js +61 -24
  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 -290
  164. package/selection/selection.mjs +153 -287
  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
@@ -0,0 +1,290 @@
1
+ import "core-js/modules/es.array.push.js";
2
+ import { addClass, hasClass } from "./../../../helpers/dom/element.mjs";
3
+ import Border from "./border.mjs";
4
+ /**
5
+ * @class Selection
6
+ */
7
+ class Selection {
8
+ /**
9
+ * @param {object} settings The selection settings object. @todo type.
10
+ * @param {CellRange} cellRange The cell range instance.
11
+ */
12
+ constructor(settings, cellRange) {
13
+ this.settings = settings;
14
+ this.cellRange = cellRange || null;
15
+ this.instanceBorders = {};
16
+ this.classNames = [this.settings.className];
17
+ this.classNameGenerator = this.linearClassNameGenerator(this.settings.className, this.settings.layerLevel);
18
+ }
19
+
20
+ /**
21
+ * Each Walkontable clone requires it's own border for every selection. This method creates and returns selection
22
+ * borders per instance.
23
+ *
24
+ * @param {WalkontableFacade} wotInstance The Walkontable instance.
25
+ * @returns {Border}
26
+ */
27
+ getBorder(wotInstance) {
28
+ if (!this.instanceBorders[wotInstance.guid]) {
29
+ this.instanceBorders[wotInstance.guid] = new Border(wotInstance, this.settings);
30
+ }
31
+ return this.instanceBorders[wotInstance.guid];
32
+ }
33
+
34
+ /**
35
+ * Checks if selection is empty.
36
+ *
37
+ * @returns {boolean}
38
+ */
39
+ isEmpty() {
40
+ return this.cellRange === null;
41
+ }
42
+
43
+ /**
44
+ * Adds a cell coords to the selection.
45
+ *
46
+ * @param {CellCoords} coords The cell coordinates to add.
47
+ * @returns {Selection}
48
+ */
49
+ add(coords) {
50
+ if (this.isEmpty()) {
51
+ this.cellRange = this.settings.createCellRange(coords);
52
+ } else {
53
+ this.cellRange.expand(coords);
54
+ }
55
+ return this;
56
+ }
57
+
58
+ /**
59
+ * If selection range from or to property equals oldCoords, replace it with newCoords. Return boolean
60
+ * information about success.
61
+ *
62
+ * @param {CellCoords} oldCoords An old cell coordinates to replace.
63
+ * @param {CellCoords} newCoords The new cell coordinates.
64
+ * @returns {boolean}
65
+ */
66
+ replace(oldCoords, newCoords) {
67
+ if (!this.isEmpty()) {
68
+ if (this.cellRange.from.isEqual(oldCoords)) {
69
+ this.cellRange.from = newCoords;
70
+ return true;
71
+ }
72
+ if (this.cellRange.to.isEqual(oldCoords)) {
73
+ this.cellRange.to = newCoords;
74
+ return true;
75
+ }
76
+ }
77
+ return false;
78
+ }
79
+
80
+ /**
81
+ * Clears selection.
82
+ *
83
+ * @returns {Selection}
84
+ */
85
+ clear() {
86
+ this.cellRange = null;
87
+ return this;
88
+ }
89
+
90
+ /**
91
+ * Returns the top left (or top right in RTL) and bottom right (or bottom left in RTL) selection coordinates.
92
+ *
93
+ * @returns {Array} Returns array of coordinates for example `[1, 1, 5, 5]`.
94
+ */
95
+ getCorners() {
96
+ const topStart = this.cellRange.getOuterTopStartCorner();
97
+ const bottomEnd = this.cellRange.getOuterBottomEndCorner();
98
+ return [topStart.row, topStart.col, bottomEnd.row, bottomEnd.col];
99
+ }
100
+
101
+ /**
102
+ * Adds class name to cell element at given coords.
103
+ *
104
+ * @param {WalkontableFacade} wotInstance Walkontable instance.
105
+ * @param {number} sourceRow Cell row coord.
106
+ * @param {number} sourceColumn Cell column coord.
107
+ * @param {string} className Class name.
108
+ * @param {boolean} [markIntersections=false] If `true`, linear className generator will be used to add CSS classes
109
+ * in a continuous way.
110
+ * @returns {Selection}
111
+ */
112
+ addClassAtCoords(wotInstance, sourceRow, sourceColumn, className) {
113
+ let markIntersections = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
114
+ const TD = wotInstance.wtTable.getCell(this.settings.createCellCoords(sourceRow, sourceColumn));
115
+ if (typeof TD === 'object') {
116
+ let cellClassName = className;
117
+ if (markIntersections) {
118
+ cellClassName = this.classNameGenerator(TD);
119
+ if (!this.classNames.includes(cellClassName)) {
120
+ this.classNames.push(cellClassName);
121
+ }
122
+ }
123
+ addClass(TD, cellClassName);
124
+ }
125
+ return this;
126
+ }
127
+
128
+ /**
129
+ * Generate helper for calculating classNames based on previously added base className.
130
+ * The generated className is always generated as a continuation of the previous className. For example, when
131
+ * the currently checked element has 'area-2' className the generated new className will be 'area-3'. When
132
+ * the element doesn't have any classNames than the base className will be returned ('area');.
133
+ *
134
+ * @param {string} baseClassName Base className to be used.
135
+ * @param {number} layerLevelOwner Layer level which the instance of the Selection belongs to.
136
+ * @returns {Function}
137
+ */
138
+ linearClassNameGenerator(baseClassName, layerLevelOwner) {
139
+ // TODO: Make this recursive function Proper Tail Calls (TCO/PTC) friendly.
140
+ return function calcClassName(element) {
141
+ let previousIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
142
+ if (layerLevelOwner === 0 || previousIndex === 0) {
143
+ return baseClassName;
144
+ }
145
+ let index = previousIndex >= 0 ? previousIndex : layerLevelOwner;
146
+ let className = baseClassName;
147
+ index -= 1;
148
+ const previousClassName = index === 0 ? baseClassName : `${baseClassName}-${index}`;
149
+ if (hasClass(element, previousClassName)) {
150
+ const currentLayer = index + 1;
151
+ className = `${baseClassName}-${currentLayer}`;
152
+ } else {
153
+ className = calcClassName(element, index);
154
+ }
155
+ return className;
156
+ };
157
+ }
158
+
159
+ /**
160
+ * @param {WalkontableFacade} wotInstance The Walkontable instance.
161
+ */
162
+ draw(wotInstance) {
163
+ if (this.isEmpty()) {
164
+ if (this.settings.border) {
165
+ this.getBorder(wotInstance).disappear();
166
+ }
167
+ return;
168
+ }
169
+ const renderedRows = wotInstance.wtTable.getRenderedRowsCount();
170
+ const renderedColumns = wotInstance.wtTable.getRenderedColumnsCount();
171
+ const corners = this.getCorners();
172
+ const [topRow, topColumn, bottomRow, bottomColumn] = corners;
173
+ const {
174
+ highlightHeaderClassName,
175
+ highlightColumnClassName,
176
+ highlightRowClassName,
177
+ highlightOnlyClosestHeader,
178
+ selectionType
179
+ } = this.settings;
180
+ const isHeaderSelectionType = selectionType === void 0 || ['active-header', 'header'].includes(selectionType);
181
+ if (isHeaderSelectionType && topColumn !== null && bottomColumn !== null) {
182
+ let selectionColumnCursor = 0;
183
+ for (let column = 0; column < renderedColumns; column += 1) {
184
+ const sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column);
185
+ if (sourceCol >= topColumn && sourceCol <= bottomColumn) {
186
+ let THs = wotInstance.wtTable.getColumnHeaders(sourceCol);
187
+ const closestHeaderLevel = THs.length - 1;
188
+ if (highlightOnlyClosestHeader && THs.length > 1) {
189
+ THs = [THs[closestHeaderLevel]];
190
+ }
191
+ for (let headerLevel = 0; headerLevel < THs.length; headerLevel += 1) {
192
+ const newClasses = [];
193
+ let TH = THs[headerLevel];
194
+ if (highlightHeaderClassName) {
195
+ newClasses.push(highlightHeaderClassName);
196
+ }
197
+ if (highlightColumnClassName) {
198
+ newClasses.push(highlightColumnClassName);
199
+ }
200
+ headerLevel = highlightOnlyClosestHeader ? closestHeaderLevel : headerLevel;
201
+ const newSourceCol = wotInstance.getSetting('onBeforeHighlightingColumnHeader', sourceCol, headerLevel, {
202
+ selectionType,
203
+ columnCursor: selectionColumnCursor,
204
+ selectionWidth: bottomColumn - topColumn + 1,
205
+ classNames: newClasses
206
+ });
207
+ if (newSourceCol !== sourceCol) {
208
+ TH = wotInstance.wtTable.getColumnHeader(newSourceCol, headerLevel);
209
+ }
210
+ addClass(TH, newClasses);
211
+ }
212
+ selectionColumnCursor += 1;
213
+ }
214
+ }
215
+ }
216
+ if (topRow !== null && bottomRow !== null) {
217
+ let selectionRowCursor = 0;
218
+ for (let row = 0; row < renderedRows; row += 1) {
219
+ const sourceRow = wotInstance.wtTable.rowFilter.renderedToSource(row);
220
+ if (isHeaderSelectionType && sourceRow >= topRow && sourceRow <= bottomRow) {
221
+ let THs = wotInstance.wtTable.getRowHeaders(sourceRow);
222
+ const closestHeaderLevel = THs.length - 1;
223
+ if (highlightOnlyClosestHeader && THs.length > 1) {
224
+ THs = [THs[closestHeaderLevel]];
225
+ }
226
+ for (let headerLevel = 0; headerLevel < THs.length; headerLevel += 1) {
227
+ const newClasses = [];
228
+ let TH = THs[headerLevel];
229
+ if (highlightHeaderClassName) {
230
+ newClasses.push(highlightHeaderClassName);
231
+ }
232
+ if (highlightRowClassName) {
233
+ newClasses.push(highlightRowClassName);
234
+ }
235
+ headerLevel = highlightOnlyClosestHeader ? closestHeaderLevel : headerLevel;
236
+ const newSourceRow = wotInstance.getSetting('onBeforeHighlightingRowHeader', sourceRow, headerLevel, {
237
+ selectionType,
238
+ rowCursor: selectionRowCursor,
239
+ selectionHeight: bottomRow - topRow + 1,
240
+ classNames: newClasses
241
+ });
242
+ if (newSourceRow !== sourceRow) {
243
+ TH = wotInstance.wtTable.getRowHeader(newSourceRow, headerLevel);
244
+ }
245
+ addClass(TH, newClasses);
246
+ }
247
+ selectionRowCursor += 1;
248
+ }
249
+ if (topColumn !== null && bottomColumn !== null) {
250
+ for (let column = 0; column < renderedColumns; column += 1) {
251
+ const sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column);
252
+ if (sourceRow >= topRow && sourceRow <= bottomRow && sourceCol >= topColumn && sourceCol <= bottomColumn) {
253
+ // selected cell
254
+ if (this.settings.className) {
255
+ this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.className, this.settings.markIntersections);
256
+ }
257
+ } else if (sourceRow >= topRow && sourceRow <= bottomRow) {
258
+ // selection is in this row
259
+ if (highlightRowClassName) {
260
+ this.addClassAtCoords(wotInstance, sourceRow, sourceCol, highlightRowClassName);
261
+ }
262
+ } else if (sourceCol >= topColumn && sourceCol <= bottomColumn) {
263
+ // selection is in this column
264
+ if (highlightColumnClassName) {
265
+ this.addClassAtCoords(wotInstance, sourceRow, sourceCol, highlightColumnClassName);
266
+ }
267
+ }
268
+ const additionalSelectionClass = wotInstance.getSetting('onAfterDrawSelection', sourceRow, sourceCol, this.settings.layerLevel);
269
+ if (typeof additionalSelectionClass === 'string') {
270
+ this.addClassAtCoords(wotInstance, sourceRow, sourceCol, additionalSelectionClass);
271
+ }
272
+ }
273
+ }
274
+ }
275
+ }
276
+ wotInstance.getSetting('onBeforeDrawBorders', corners, this.settings.className);
277
+ if (this.settings.border) {
278
+ // warning! border.appear modifies corners!
279
+ this.getBorder(wotInstance).appear(corners);
280
+ }
281
+ }
282
+
283
+ /**
284
+ * Cleans up all the DOM state related to a Selection instance. Call this prior to deleting a Selection instance.
285
+ */
286
+ destroy() {
287
+ Object.values(this.instanceBorders).forEach(border => border.destroy());
288
+ }
289
+ }
290
+ export default Selection;
@@ -82,15 +82,6 @@ const calculatedColumns = {
82
82
  */
83
83
  getVisibleColumnsCount() {
84
84
  return this.dataAccessObject.countColumnsVisible;
85
- },
86
- /**
87
- * Get the number of rendered row headers.
88
- *
89
- * @returns {number}
90
- * @this Table
91
- */
92
- getRowHeadersCount() {
93
- return this.dataAccessObject.rowHeaders.length;
94
85
  }
95
86
  };
96
87
  (0, _object.defineGetter)(calculatedColumns, 'MIXIN_NAME', MIXIN_NAME, {
@@ -79,15 +79,6 @@ const calculatedColumns = {
79
79
  */
80
80
  getVisibleColumnsCount() {
81
81
  return this.dataAccessObject.countColumnsVisible;
82
- },
83
- /**
84
- * Get the number of rendered row headers.
85
- *
86
- * @returns {number}
87
- * @this Table
88
- */
89
- getRowHeadersCount() {
90
- return this.dataAccessObject.rowHeaders.length;
91
82
  }
92
83
  };
93
84
  defineGetter(calculatedColumns, 'MIXIN_NAME', MIXIN_NAME, {
@@ -82,15 +82,6 @@ const calculatedRows = {
82
82
  */
83
83
  getVisibleRowsCount() {
84
84
  return this.dataAccessObject.countRowsVisible;
85
- },
86
- /**
87
- * Get the number of rendered column headers.
88
- *
89
- * @returns {number}
90
- * @this Table
91
- */
92
- getColumnHeadersCount() {
93
- return this.dataAccessObject.columnHeaders.length;
94
85
  }
95
86
  };
96
87
  (0, _object.defineGetter)(calculatedRows, 'MIXIN_NAME', MIXIN_NAME, {
@@ -79,15 +79,6 @@ const calculatedRows = {
79
79
  */
80
80
  getVisibleRowsCount() {
81
81
  return this.dataAccessObject.countRowsVisible;
82
- },
83
- /**
84
- * Get the number of rendered column headers.
85
- *
86
- * @returns {number}
87
- * @this Table
88
- */
89
- getColumnHeadersCount() {
90
- return this.dataAccessObject.columnHeaders.length;
91
82
  }
92
83
  };
93
84
  defineGetter(calculatedRows, 'MIXIN_NAME', MIXIN_NAME, {
@@ -74,15 +74,6 @@ const stickyColumnsStart = {
74
74
  */
75
75
  getVisibleColumnsCount() {
76
76
  return this.getRenderedColumnsCount();
77
- },
78
- /**
79
- * Get the number of rendered row headers.
80
- *
81
- * @returns {number}
82
- * @this Table
83
- */
84
- getRowHeadersCount() {
85
- return this.dataAccessObject.rowHeaders.length;
86
77
  }
87
78
  };
88
79
  (0, _object.defineGetter)(stickyColumnsStart, 'MIXIN_NAME', MIXIN_NAME, {
@@ -71,15 +71,6 @@ const stickyColumnsStart = {
71
71
  */
72
72
  getVisibleColumnsCount() {
73
73
  return this.getRenderedColumnsCount();
74
- },
75
- /**
76
- * Get the number of rendered row headers.
77
- *
78
- * @returns {number}
79
- * @this Table
80
- */
81
- getRowHeadersCount() {
82
- return this.dataAccessObject.rowHeaders.length;
83
74
  }
84
75
  };
85
76
  defineGetter(stickyColumnsStart, 'MIXIN_NAME', MIXIN_NAME, {
@@ -79,15 +79,6 @@ const stickyRowsBottom = {
79
79
  */
80
80
  getVisibleRowsCount() {
81
81
  return this.getRenderedRowsCount();
82
- },
83
- /**
84
- * Get the number of rendered column headers.
85
- *
86
- * @returns {number}
87
- * @this Table
88
- */
89
- getColumnHeadersCount() {
90
- return 0;
91
82
  }
92
83
  };
93
84
  (0, _object.defineGetter)(stickyRowsBottom, 'MIXIN_NAME', MIXIN_NAME, {
@@ -76,15 +76,6 @@ const stickyRowsBottom = {
76
76
  */
77
77
  getVisibleRowsCount() {
78
78
  return this.getRenderedRowsCount();
79
- },
80
- /**
81
- * Get the number of rendered column headers.
82
- *
83
- * @returns {number}
84
- * @this Table
85
- */
86
- getColumnHeadersCount() {
87
- return 0;
88
79
  }
89
80
  };
90
81
  defineGetter(stickyRowsBottom, 'MIXIN_NAME', MIXIN_NAME, {
@@ -74,15 +74,6 @@ const stickyRowsTop = {
74
74
  */
75
75
  getVisibleRowsCount() {
76
76
  return this.getRenderedRowsCount();
77
- },
78
- /**
79
- * Get the number of rendered column headers.
80
- *
81
- * @returns {number}
82
- * @this Table
83
- */
84
- getColumnHeadersCount() {
85
- return this.dataAccessObject.columnHeaders.length;
86
77
  }
87
78
  };
88
79
  (0, _object.defineGetter)(stickyRowsTop, 'MIXIN_NAME', MIXIN_NAME, {
@@ -71,15 +71,6 @@ const stickyRowsTop = {
71
71
  */
72
72
  getVisibleRowsCount() {
73
73
  return this.getRenderedRowsCount();
74
- },
75
- /**
76
- * Get the number of rendered column headers.
77
- *
78
- * @returns {number}
79
- * @this Table
80
- */
81
- getColumnHeadersCount() {
82
- return this.dataAccessObject.columnHeaders.length;
83
74
  }
84
75
  };
85
76
  defineGetter(stickyRowsTop, 'MIXIN_NAME', MIXIN_NAME, {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- require("core-js/modules/es.error.cause.js");
5
4
  require("core-js/modules/es.array.push.js");
5
+ require("core-js/modules/es.error.cause.js");
6
6
  var _element = require("../../../helpers/dom/element");
7
7
  var _function = require("../../../helpers/function");
8
8
  var _column = _interopRequireDefault(require("./filter/column"));
@@ -345,7 +345,7 @@ class Table {
345
345
  wtOverlays.refreshAll(); // `refreshAll()` internally already calls `refreshSelections()` method
346
346
  wtOverlays.adjustElementsSize();
347
347
  } else {
348
- this.dataAccessObject.selectionManager.setActiveOverlay(this.facadeGetter()).render(runFastDraw);
348
+ this.refreshSelections(runFastDraw);
349
349
  }
350
350
  if (syncScroll) {
351
351
  wtOverlays.syncScrollWithMaster();
@@ -437,6 +437,75 @@ class Table {
437
437
  }
438
438
  }
439
439
 
440
+ /**
441
+ * @param {string} className The CSS class name to remove from the table cells.
442
+ */
443
+ removeClassFromCells(className) {
444
+ const nodes = this.TABLE.querySelectorAll(`.${className}`);
445
+ for (let i = 0, len = nodes.length; i < len; i++) {
446
+ (0, _element.removeClass)(nodes[i], className);
447
+ }
448
+ }
449
+
450
+ /**
451
+ * Refresh the table selection by re-rendering Selection instances connected with that instance.
452
+ *
453
+ * @param {boolean} fastDraw If fast drawing is enabled than additionally className clearing is applied.
454
+ */
455
+ refreshSelections(fastDraw) {
456
+ const {
457
+ wtSettings
458
+ } = this;
459
+ const {
460
+ selections
461
+ } = this.dataAccessObject;
462
+ if (!selections) {
463
+ return;
464
+ }
465
+ const highlights = Array.from(selections);
466
+ const len = highlights.length;
467
+ if (fastDraw) {
468
+ const classesToRemove = [];
469
+ for (let i = 0; i < len; i++) {
470
+ const {
471
+ highlightHeaderClassName,
472
+ highlightRowClassName,
473
+ highlightColumnClassName
474
+ } = highlights[i].settings;
475
+ const classNames = highlights[i].classNames;
476
+ const classNamesLength = classNames.length;
477
+ for (let j = 0; j < classNamesLength; j++) {
478
+ if (!classesToRemove.includes(classNames[j])) {
479
+ classesToRemove.push(classNames[j]);
480
+ }
481
+ }
482
+ if (highlightHeaderClassName && !classesToRemove.includes(highlightHeaderClassName)) {
483
+ classesToRemove.push(highlightHeaderClassName);
484
+ }
485
+ if (highlightRowClassName && !classesToRemove.includes(highlightRowClassName)) {
486
+ classesToRemove.push(highlightRowClassName);
487
+ }
488
+ if (highlightColumnClassName && !classesToRemove.includes(highlightColumnClassName)) {
489
+ classesToRemove.push(highlightColumnClassName);
490
+ }
491
+ }
492
+ const additionalClassesToRemove = wtSettings.getSetting('onBeforeRemoveCellClassNames');
493
+ if (Array.isArray(additionalClassesToRemove)) {
494
+ for (let i = 0; i < additionalClassesToRemove.length; i++) {
495
+ classesToRemove.push(additionalClassesToRemove[i]);
496
+ }
497
+ }
498
+ const classesToRemoveLength = classesToRemove.length;
499
+ for (let i = 0; i < classesToRemoveLength; i++) {
500
+ // there was no rerender, so we need to remove classNames by ourselves
501
+ this.removeClassFromCells(classesToRemove[i]);
502
+ }
503
+ }
504
+ for (let i = 0; i < len; i++) {
505
+ highlights[i].draw(this.facadeGetter(), fastDraw);
506
+ }
507
+ }
508
+
440
509
  /**
441
510
  * Get cell element at coords.
442
511
  * Negative coords.row or coords.col are used to retrieve header cells. If there are multiple header levels, the
@@ -558,14 +627,14 @@ class Table {
558
627
  */
559
628
  getRowHeader(row) {
560
629
  let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
630
+ if (this.columnFilter.sourceColumnToVisibleRowHeadedColumn(0) === 0) {
631
+ return;
632
+ }
561
633
  const rowHeadersCount = this.wtSettings.getSetting('rowHeaders').length;
562
634
  if (level >= rowHeadersCount) {
563
635
  return;
564
636
  }
565
- const renderedRow = this.rowFilter.sourceToRendered(row);
566
- const visibleRow = renderedRow < 0 ? this.rowFilter.sourceRowToVisibleColHeadedRow(row) : renderedRow;
567
- const parentElement = renderedRow < 0 ? this.THEAD : this.TBODY;
568
- const TR = parentElement.childNodes[visibleRow];
637
+ const TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
569
638
  return TR === null || TR === void 0 ? void 0 : TR.childNodes[level];
570
639
  }
571
640
 
@@ -576,6 +645,9 @@ class Table {
576
645
  * @returns {HTMLTableCellElement[]}
577
646
  */
578
647
  getRowHeaders(row) {
648
+ if (this.columnFilter.sourceColumnToVisibleRowHeadedColumn(0) === 0) {
649
+ return [];
650
+ }
579
651
  const THs = [];
580
652
  const rowHeadersCount = this.wtSettings.getSetting('rowHeaders').length;
581
653
  for (let renderedRowIndex = 0; renderedRowIndex < rowHeadersCount; renderedRowIndex++) {