handsontable 0.0.0-next-06a64be-20230621 → 0.0.0-next-be250b6-20230621

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

Potentially problematic release.


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

Files changed (237) hide show
  1. package/3rdparty/walkontable/src/cell/coords.d.ts +6 -1
  2. package/3rdparty/walkontable/src/cell/coords.js +61 -12
  3. package/3rdparty/walkontable/src/cell/coords.mjs +61 -12
  4. package/3rdparty/walkontable/src/cell/range.d.ts +9 -2
  5. package/3rdparty/walkontable/src/cell/range.js +44 -7
  6. package/3rdparty/walkontable/src/cell/range.mjs +44 -7
  7. package/3rdparty/walkontable/src/core/_base.js +9 -3
  8. package/3rdparty/walkontable/src/core/_base.mjs +9 -3
  9. package/3rdparty/walkontable/src/core/clone.js +2 -2
  10. package/3rdparty/walkontable/src/core/clone.mjs +2 -2
  11. package/3rdparty/walkontable/src/core/core.js +3 -2
  12. package/3rdparty/walkontable/src/core/core.mjs +3 -2
  13. package/3rdparty/walkontable/src/event.js +7 -7
  14. package/3rdparty/walkontable/src/event.mjs +7 -7
  15. package/3rdparty/walkontable/src/facade/core.js +2 -2
  16. package/3rdparty/walkontable/src/facade/core.mjs +2 -2
  17. package/3rdparty/walkontable/src/index.js +10 -2
  18. package/3rdparty/walkontable/src/index.mjs +2 -2
  19. package/3rdparty/walkontable/src/overlay/_base.js +1 -1
  20. package/3rdparty/walkontable/src/overlay/_base.mjs +1 -1
  21. package/3rdparty/walkontable/src/overlay/inlineStart.js +2 -4
  22. package/3rdparty/walkontable/src/overlay/inlineStart.mjs +2 -4
  23. package/3rdparty/walkontable/src/overlay/top.js +2 -4
  24. package/3rdparty/walkontable/src/overlay/top.mjs +2 -4
  25. package/3rdparty/walkontable/src/{border.js → selection/border/border.js} +7 -12
  26. package/3rdparty/walkontable/src/{border.mjs → selection/border/border.mjs} +7 -12
  27. package/3rdparty/walkontable/src/selection/border/constants.js +18 -0
  28. package/3rdparty/walkontable/src/selection/border/constants.mjs +13 -0
  29. package/3rdparty/walkontable/src/selection/constants.js +63 -0
  30. package/3rdparty/walkontable/src/selection/constants.mjs +51 -0
  31. package/3rdparty/walkontable/src/selection/index.js +30 -0
  32. package/3rdparty/walkontable/src/selection/index.mjs +5 -0
  33. package/3rdparty/walkontable/src/selection/manager.js +329 -0
  34. package/3rdparty/walkontable/src/selection/manager.mjs +323 -0
  35. package/3rdparty/walkontable/src/selection/scanner.js +364 -0
  36. package/3rdparty/walkontable/src/selection/scanner.mjs +360 -0
  37. package/3rdparty/walkontable/src/selection/selection.js +133 -0
  38. package/3rdparty/walkontable/src/selection/selection.mjs +127 -0
  39. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.js +9 -0
  40. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.mjs +9 -0
  41. package/3rdparty/walkontable/src/table/mixin/calculatedRows.js +9 -0
  42. package/3rdparty/walkontable/src/table/mixin/calculatedRows.mjs +9 -0
  43. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.js +9 -0
  44. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.mjs +9 -0
  45. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.js +9 -0
  46. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.mjs +9 -0
  47. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.js +9 -0
  48. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.mjs +9 -0
  49. package/3rdparty/walkontable/src/table.js +7 -79
  50. package/3rdparty/walkontable/src/table.mjs +8 -80
  51. package/base.js +2 -2
  52. package/base.mjs +2 -2
  53. package/core.d.ts +5 -3
  54. package/core.js +127 -309
  55. package/core.mjs +127 -309
  56. package/dataMap/metaManager/metaSchema.js +19 -0
  57. package/dataMap/metaManager/metaSchema.mjs +19 -0
  58. package/dist/handsontable.css +8 -3
  59. package/dist/handsontable.full.css +8 -3
  60. package/dist/handsontable.full.js +11930 -9113
  61. package/dist/handsontable.full.min.css +3 -3
  62. package/dist/handsontable.full.min.js +107 -107
  63. package/dist/handsontable.js +15163 -12346
  64. package/dist/handsontable.min.css +3 -3
  65. package/dist/handsontable.min.js +4 -4
  66. package/editorManager.js +21 -94
  67. package/editorManager.mjs +26 -98
  68. package/editors/textEditor/textEditor.js +3 -11
  69. package/editors/textEditor/textEditor.mjs +4 -12
  70. package/helpers/mixed.js +1 -1
  71. package/helpers/mixed.mjs +1 -1
  72. package/helpers/number.d.ts +1 -0
  73. package/helpers/number.js +18 -0
  74. package/helpers/number.mjs +17 -0
  75. package/package.json +1 -1
  76. package/pluginHooks.d.ts +5 -1
  77. package/pluginHooks.js +89 -1
  78. package/pluginHooks.mjs +89 -1
  79. package/plugins/collapsibleColumns/collapsibleColumns.js +81 -24
  80. package/plugins/collapsibleColumns/collapsibleColumns.mjs +81 -24
  81. package/plugins/columnSorting/columnSorting.js +50 -8
  82. package/plugins/columnSorting/columnSorting.mjs +49 -9
  83. package/plugins/columnSorting/index.js +4 -2
  84. package/plugins/columnSorting/index.mjs +1 -1
  85. package/plugins/copyPaste/copyPaste.js +5 -1
  86. package/plugins/copyPaste/copyPaste.mjs +5 -1
  87. package/plugins/customBorders/customBorders.js +18 -53
  88. package/plugins/customBorders/customBorders.mjs +19 -54
  89. package/plugins/mergeCells/mergeCells.js +5 -18
  90. package/plugins/mergeCells/mergeCells.mjs +5 -18
  91. package/plugins/multiColumnSorting/multiColumnSorting.js +42 -3
  92. package/plugins/multiColumnSorting/multiColumnSorting.mjs +42 -3
  93. package/plugins/nestedHeaders/nestedHeaders.js +132 -10
  94. package/plugins/nestedHeaders/nestedHeaders.mjs +132 -10
  95. package/plugins/nestedHeaders/stateManager/index.js +37 -0
  96. package/plugins/nestedHeaders/stateManager/index.mjs +37 -0
  97. package/plugins/nestedRows/nestedRows.js +52 -7
  98. package/plugins/nestedRows/nestedRows.mjs +52 -7
  99. package/renderers/checkboxRenderer/checkboxRenderer.js +2 -2
  100. package/renderers/checkboxRenderer/checkboxRenderer.mjs +1 -1
  101. package/selection/highlight/highlight.js +312 -89
  102. package/selection/highlight/highlight.mjs +302 -85
  103. package/selection/highlight/types/activeHeader.js +10 -9
  104. package/selection/highlight/types/activeHeader.mjs +10 -8
  105. package/selection/highlight/types/area.js +12 -27
  106. package/selection/highlight/types/area.mjs +16 -30
  107. package/selection/highlight/types/areaLayered.js +54 -0
  108. package/selection/highlight/types/areaLayered.mjs +49 -0
  109. package/selection/highlight/types/column.js +50 -0
  110. package/selection/highlight/types/column.mjs +45 -0
  111. package/selection/highlight/types/customSelection.js +7 -10
  112. package/selection/highlight/types/customSelection.mjs +7 -9
  113. package/selection/highlight/types/fill.js +5 -8
  114. package/selection/highlight/types/fill.mjs +5 -7
  115. package/selection/highlight/types/{cell.js → focus.js} +5 -8
  116. package/selection/highlight/types/{cell.mjs → focus.mjs} +5 -7
  117. package/selection/highlight/types/header.js +10 -20
  118. package/selection/highlight/types/header.mjs +10 -19
  119. package/selection/highlight/types/{index.js → row.js} +27 -31
  120. package/selection/highlight/types/{index.mjs → row.mjs} +24 -29
  121. package/selection/highlight/visualSelection.js +31 -27
  122. package/selection/highlight/visualSelection.mjs +31 -27
  123. package/selection/index.js +4 -7
  124. package/selection/index.mjs +2 -3
  125. package/selection/mouseEventHandler.js +1 -1
  126. package/selection/mouseEventHandler.mjs +1 -1
  127. package/selection/range.js +8 -8
  128. package/selection/range.mjs +8 -8
  129. package/selection/selection.js +315 -181
  130. package/selection/selection.mjs +310 -180
  131. package/selection/transformation.js +233 -96
  132. package/selection/transformation.mjs +230 -93
  133. package/selection/utils.js +12 -36
  134. package/selection/utils.mjs +13 -36
  135. package/settings.d.ts +1 -0
  136. package/shortcutContexts/commands/editor/closeAndSave.js +15 -0
  137. package/shortcutContexts/commands/editor/closeAndSave.mjs +10 -0
  138. package/shortcutContexts/commands/editor/closeWithoutSaving.js +13 -0
  139. package/shortcutContexts/commands/editor/closeWithoutSaving.mjs +8 -0
  140. package/shortcutContexts/commands/editor/fastOpen.js +16 -0
  141. package/shortcutContexts/commands/editor/fastOpen.mjs +11 -0
  142. package/shortcutContexts/commands/editor/index.js +16 -0
  143. package/shortcutContexts/commands/editor/index.mjs +12 -0
  144. package/shortcutContexts/commands/editor/open.js +29 -0
  145. package/shortcutContexts/commands/editor/open.mjs +24 -0
  146. package/shortcutContexts/commands/emptySelectedCells.js +12 -0
  147. package/shortcutContexts/commands/emptySelectedCells.mjs +7 -0
  148. package/shortcutContexts/commands/extendCellsSelection/down.js +15 -0
  149. package/shortcutContexts/commands/extendCellsSelection/down.mjs +10 -0
  150. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +21 -0
  151. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +16 -0
  152. package/shortcutContexts/commands/extendCellsSelection/index.js +26 -0
  153. package/shortcutContexts/commands/extendCellsSelection/index.mjs +22 -0
  154. package/shortcutContexts/commands/extendCellsSelection/left.js +15 -0
  155. package/shortcutContexts/commands/extendCellsSelection/left.mjs +10 -0
  156. package/shortcutContexts/commands/extendCellsSelection/right.js +15 -0
  157. package/shortcutContexts/commands/extendCellsSelection/right.mjs +10 -0
  158. package/shortcutContexts/commands/extendCellsSelection/toColumns.js +19 -0
  159. package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +14 -0
  160. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +22 -0
  161. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +17 -0
  162. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +17 -0
  163. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +12 -0
  164. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +17 -0
  165. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +12 -0
  166. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +40 -0
  167. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +35 -0
  168. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +40 -0
  169. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +35 -0
  170. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +22 -0
  171. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +17 -0
  172. package/shortcutContexts/commands/extendCellsSelection/toRows.js +19 -0
  173. package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +14 -0
  174. package/shortcutContexts/commands/extendCellsSelection/up.js +15 -0
  175. package/shortcutContexts/commands/extendCellsSelection/up.mjs +10 -0
  176. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +21 -0
  177. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +16 -0
  178. package/shortcutContexts/commands/index.js +53 -0
  179. package/shortcutContexts/commands/index.mjs +49 -0
  180. package/shortcutContexts/commands/moveCellSelection/down.js +12 -0
  181. package/shortcutContexts/commands/moveCellSelection/down.mjs +7 -0
  182. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +29 -0
  183. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +24 -0
  184. package/shortcutContexts/commands/moveCellSelection/index.js +28 -0
  185. package/shortcutContexts/commands/moveCellSelection/index.mjs +24 -0
  186. package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +13 -0
  187. package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +8 -0
  188. package/shortcutContexts/commands/moveCellSelection/inlineStart.js +13 -0
  189. package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +8 -0
  190. package/shortcutContexts/commands/moveCellSelection/left.js +11 -0
  191. package/shortcutContexts/commands/moveCellSelection/left.mjs +6 -0
  192. package/shortcutContexts/commands/moveCellSelection/right.js +11 -0
  193. package/shortcutContexts/commands/moveCellSelection/right.mjs +6 -0
  194. package/shortcutContexts/commands/moveCellSelection/toMostBottom.js +16 -0
  195. package/shortcutContexts/commands/moveCellSelection/toMostBottom.mjs +11 -0
  196. package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.js +17 -0
  197. package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.mjs +12 -0
  198. package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.js +13 -0
  199. package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.mjs +8 -0
  200. package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.js +16 -0
  201. package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.mjs +11 -0
  202. package/shortcutContexts/commands/moveCellSelection/toMostLeft.js +36 -0
  203. package/shortcutContexts/commands/moveCellSelection/toMostLeft.mjs +31 -0
  204. package/shortcutContexts/commands/moveCellSelection/toMostRight.js +36 -0
  205. package/shortcutContexts/commands/moveCellSelection/toMostRight.mjs +31 -0
  206. package/shortcutContexts/commands/moveCellSelection/toMostTop.js +16 -0
  207. package/shortcutContexts/commands/moveCellSelection/toMostTop.mjs +11 -0
  208. package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.js +18 -0
  209. package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.mjs +13 -0
  210. package/shortcutContexts/commands/moveCellSelection/up.js +12 -0
  211. package/shortcutContexts/commands/moveCellSelection/up.mjs +7 -0
  212. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +29 -0
  213. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +24 -0
  214. package/shortcutContexts/commands/populateSelectedCellsData.js +35 -0
  215. package/shortcutContexts/commands/populateSelectedCellsData.mjs +30 -0
  216. package/shortcutContexts/commands/scrollToFocusedCell.js +38 -0
  217. package/shortcutContexts/commands/scrollToFocusedCell.mjs +33 -0
  218. package/shortcutContexts/commands/selectAll.js +11 -0
  219. package/shortcutContexts/commands/selectAll.mjs +6 -0
  220. package/shortcutContexts/constants.js +19 -0
  221. package/shortcutContexts/constants.mjs +12 -0
  222. package/shortcutContexts/editor.js +29 -0
  223. package/shortcutContexts/editor.mjs +25 -0
  224. package/shortcutContexts/grid.js +252 -0
  225. package/shortcutContexts/grid.mjs +248 -0
  226. package/shortcutContexts/index.js +29 -0
  227. package/shortcutContexts/index.mjs +15 -0
  228. package/shortcuts/manager.js +2 -0
  229. package/shortcuts/manager.mjs +2 -0
  230. package/tableView.js +58 -9
  231. package/tableView.mjs +58 -9
  232. package/translations/indexMapper.js +8 -9
  233. package/translations/indexMapper.mjs +8 -9
  234. package/3rdparty/walkontable/src/selection.js +0 -355
  235. package/3rdparty/walkontable/src/selection.mjs +0 -349
  236. package/selection/highlight/constants.js +0 -16
  237. package/selection/highlight/constants.mjs +0 -6
package/tableView.mjs CHANGED
@@ -608,6 +608,44 @@ var TableView = /*#__PURE__*/function () {
608
608
  return this.countNotHiddenRowIndexes(visualFixedRowsBottom, 1);
609
609
  }
610
610
 
611
+ /**
612
+ * The function returns the number of renderable column indexes within the passed range of the visual indexes.
613
+ *
614
+ * @param {number} columnStart The column visual start index.
615
+ * @param {number} columnEnd The column visual end index.
616
+ * @returns {number}
617
+ */
618
+ }, {
619
+ key: "countRenderableColumnsInRange",
620
+ value: function countRenderableColumnsInRange(columnStart, columnEnd) {
621
+ var count = 0;
622
+ for (var column = columnStart; column <= columnEnd; column++) {
623
+ if (this.instance.columnIndexMapper.getRenderableFromVisualIndex(column) !== null) {
624
+ count += 1;
625
+ }
626
+ }
627
+ return count;
628
+ }
629
+
630
+ /**
631
+ * The function returns the number of renderable row indexes within the passed range of the visual indexes.
632
+ *
633
+ * @param {number} rowStart The row visual start index.
634
+ * @param {number} rowEnd The row visual end index.
635
+ * @returns {number}
636
+ */
637
+ }, {
638
+ key: "countRenderableRowsInRange",
639
+ value: function countRenderableRowsInRange(rowStart, rowEnd) {
640
+ var count = 0;
641
+ for (var row = rowStart; row <= rowEnd; row++) {
642
+ if (this.instance.rowIndexMapper.getRenderableFromVisualIndex(row) !== null) {
643
+ count += 1;
644
+ }
645
+ }
646
+ return count;
647
+ }
648
+
611
649
  /**
612
650
  * Checks if at least one cell than belongs to the main table is not covered by the top, left or
613
651
  * bottom overlay.
@@ -879,15 +917,29 @@ var TableView = /*#__PURE__*/function () {
879
917
  },
880
918
  onBeforeHighlightingRowHeader: function onBeforeHighlightingRowHeader(renderableRow, headerLevel, highlightMeta) {
881
919
  var rowMapper = _this2.instance.rowIndexMapper;
882
- var visualRow = rowMapper.getVisualFromRenderableIndex(renderableRow);
920
+ var areColumnHeadersSelected = renderableRow < 0;
921
+ var visualRow = renderableRow;
922
+ if (!areColumnHeadersSelected) {
923
+ visualRow = rowMapper.getVisualFromRenderableIndex(renderableRow);
924
+ }
883
925
  var newVisualRow = _this2.instance.runHooks('beforeHighlightingRowHeader', visualRow, headerLevel, highlightMeta);
884
- return rowMapper.getRenderableFromVisualIndex(rowMapper.getNearestNotHiddenIndex(newVisualRow, 1));
926
+ if (!areColumnHeadersSelected) {
927
+ return rowMapper.getRenderableFromVisualIndex(rowMapper.getNearestNotHiddenIndex(newVisualRow, 1));
928
+ }
929
+ return newVisualRow;
885
930
  },
886
931
  onBeforeHighlightingColumnHeader: function onBeforeHighlightingColumnHeader(renderableColumn, headerLevel, highlightMeta) {
887
932
  var columnMapper = _this2.instance.columnIndexMapper;
888
- var visualColumn = columnMapper.getVisualFromRenderableIndex(renderableColumn);
933
+ var areRowHeadersSelected = renderableColumn < 0;
934
+ var visualColumn = renderableColumn;
935
+ if (!areRowHeadersSelected) {
936
+ visualColumn = columnMapper.getVisualFromRenderableIndex(renderableColumn);
937
+ }
889
938
  var newVisualColumn = _this2.instance.runHooks('beforeHighlightingColumnHeader', visualColumn, headerLevel, highlightMeta);
890
- return columnMapper.getRenderableFromVisualIndex(columnMapper.getNearestNotHiddenIndex(newVisualColumn, 1));
939
+ if (!areRowHeadersSelected) {
940
+ return columnMapper.getRenderableFromVisualIndex(columnMapper.getNearestNotHiddenIndex(newVisualColumn, 1));
941
+ }
942
+ return newVisualColumn;
891
943
  },
892
944
  onAfterDrawSelection: function onAfterDrawSelection(currentRow, currentColumn, layerLevel) {
893
945
  var cornersOfSelection;
@@ -898,10 +950,7 @@ var TableView = /*#__PURE__*/function () {
898
950
  var selectedRange = _this2.instance.selection.getSelectedRange();
899
951
  var selectionRangeSize = selectedRange.size();
900
952
  if (selectionRangeSize > 0) {
901
- // Selection layers are stored from the "oldest" to the "newest". We should calculate the offset.
902
- // Please look at the `SelectedRange` class and it's method for getting selection's layer for more information.
903
- var selectionOffset = (layerLevel !== null && layerLevel !== void 0 ? layerLevel : 0) + 1 - selectionRangeSize;
904
- var selectionForLayer = selectedRange.peekByIndex(selectionOffset);
953
+ var selectionForLayer = selectedRange.peekByIndex(layerLevel !== null && layerLevel !== void 0 ? layerLevel : 0);
905
954
  cornersOfSelection = [selectionForLayer.from.row, selectionForLayer.from.col, selectionForLayer.to.row, selectionForLayer.to.col];
906
955
  }
907
956
  return _this2.instance.runHooks('afterDrawSelection', visualRowIndex, visualColumnIndex, cornersOfSelection, layerLevel);
@@ -1075,7 +1124,7 @@ var TableView = /*#__PURE__*/function () {
1075
1124
  key: "isSelectedOnlyCell",
1076
1125
  value: function isSelectedOnlyCell() {
1077
1126
  var _this$instance$getSel, _this$instance$getSel2;
1078
- return (_this$instance$getSel = (_this$instance$getSel2 = this.instance.getSelectedRangeLast()) === null || _this$instance$getSel2 === void 0 ? void 0 : _this$instance$getSel2.isSingle()) !== null && _this$instance$getSel !== void 0 ? _this$instance$getSel : false;
1127
+ return (_this$instance$getSel = (_this$instance$getSel2 = this.instance.getSelectedRangeLast()) === null || _this$instance$getSel2 === void 0 ? void 0 : _this$instance$getSel2.isSingleCell()) !== null && _this$instance$getSel !== void 0 ? _this$instance$getSel : false;
1079
1128
  }
1080
1129
 
1081
1130
  /**
@@ -675,25 +675,24 @@ var IndexMapper = /*#__PURE__*/function () {
675
675
  var notTrimmedIndexesLength = this.getNotTrimmedIndexesLength();
676
676
  var movedIndexesLength = movedIndexes.length;
677
677
 
678
- // Removing moved indexes without re-indexing.
679
- var notMovedIndexes = (0, _maps.getListWithRemovedItems)(this.getIndexesSequence(), physicalMovedIndexes);
680
- var notTrimmedNotMovedItems = notMovedIndexes.filter(function (index) {
681
- return _this5.isTrimmed(index) === false;
682
- });
678
+ // Removing indexes without re-indexing.
679
+ var listWithRemovedItems = (0, _maps.getListWithRemovedItems)(this.getIndexesSequence(), physicalMovedIndexes);
683
680
 
684
681
  // When item(s) are moved after the last visible item we assign the last possible index.
685
- var destinationPosition = notMovedIndexes.indexOf(notTrimmedNotMovedItems[notTrimmedNotMovedItems.length - 1]) + 1;
682
+ var destinationPosition = notTrimmedIndexesLength - movedIndexesLength;
686
683
 
687
684
  // Otherwise, we find proper index for inserted item(s).
688
685
  if (finalIndex + movedIndexesLength < notTrimmedIndexesLength) {
689
686
  // Physical index at final index position.
690
- var physicalIndex = notTrimmedNotMovedItems[finalIndex];
691
- destinationPosition = notMovedIndexes.indexOf(physicalIndex);
687
+ var physicalIndex = listWithRemovedItems.filter(function (index) {
688
+ return _this5.isTrimmed(index) === false;
689
+ })[finalIndex];
690
+ destinationPosition = listWithRemovedItems.indexOf(physicalIndex);
692
691
  }
693
692
  this.indexesChangeSource = 'move';
694
693
 
695
694
  // Adding indexes without re-indexing.
696
- this.setIndexesSequence((0, _maps.getListWithInsertedItems)(notMovedIndexes, destinationPosition, physicalMovedIndexes));
695
+ this.setIndexesSequence((0, _maps.getListWithInsertedItems)(listWithRemovedItems, destinationPosition, physicalMovedIndexes));
697
696
  this.indexesChangeSource = void 0;
698
697
  }
699
698
 
@@ -671,25 +671,24 @@ export var IndexMapper = /*#__PURE__*/function () {
671
671
  var notTrimmedIndexesLength = this.getNotTrimmedIndexesLength();
672
672
  var movedIndexesLength = movedIndexes.length;
673
673
 
674
- // Removing moved indexes without re-indexing.
675
- var notMovedIndexes = getListWithRemovedItems(this.getIndexesSequence(), physicalMovedIndexes);
676
- var notTrimmedNotMovedItems = notMovedIndexes.filter(function (index) {
677
- return _this5.isTrimmed(index) === false;
678
- });
674
+ // Removing indexes without re-indexing.
675
+ var listWithRemovedItems = getListWithRemovedItems(this.getIndexesSequence(), physicalMovedIndexes);
679
676
 
680
677
  // When item(s) are moved after the last visible item we assign the last possible index.
681
- var destinationPosition = notMovedIndexes.indexOf(notTrimmedNotMovedItems[notTrimmedNotMovedItems.length - 1]) + 1;
678
+ var destinationPosition = notTrimmedIndexesLength - movedIndexesLength;
682
679
 
683
680
  // Otherwise, we find proper index for inserted item(s).
684
681
  if (finalIndex + movedIndexesLength < notTrimmedIndexesLength) {
685
682
  // Physical index at final index position.
686
- var physicalIndex = notTrimmedNotMovedItems[finalIndex];
687
- destinationPosition = notMovedIndexes.indexOf(physicalIndex);
683
+ var physicalIndex = listWithRemovedItems.filter(function (index) {
684
+ return _this5.isTrimmed(index) === false;
685
+ })[finalIndex];
686
+ destinationPosition = listWithRemovedItems.indexOf(physicalIndex);
688
687
  }
689
688
  this.indexesChangeSource = 'move';
690
689
 
691
690
  // Adding indexes without re-indexing.
692
- this.setIndexesSequence(getListWithInsertedItems(notMovedIndexes, destinationPosition, physicalMovedIndexes));
691
+ this.setIndexesSequence(getListWithInsertedItems(listWithRemovedItems, destinationPosition, physicalMovedIndexes));
693
692
  this.indexesChangeSource = void 0;
694
693
  }
695
694
 
@@ -1,355 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.symbol.iterator.js");
4
- require("core-js/modules/es.array.iterator.js");
5
- require("core-js/modules/es.string.iterator.js");
6
- require("core-js/modules/web.dom-collections.iterator.js");
7
- require("core-js/modules/es.array.slice.js");
8
- require("core-js/modules/es.regexp.to-string.js");
9
- require("core-js/modules/es.function.name.js");
10
- require("core-js/modules/es.array.from.js");
11
- require("core-js/modules/es.regexp.exec.js");
12
- exports.__esModule = true;
13
- exports.default = void 0;
14
- require("core-js/modules/es.array.includes.js");
15
- require("core-js/modules/es.string.includes.js");
16
- require("core-js/modules/es.array.concat.js");
17
- require("core-js/modules/es.object.to-string.js");
18
- require("core-js/modules/web.dom-collections.for-each.js");
19
- require("core-js/modules/es.object.values.js");
20
- require("core-js/modules/es.symbol.to-primitive.js");
21
- require("core-js/modules/es.date.to-primitive.js");
22
- require("core-js/modules/es.symbol.js");
23
- require("core-js/modules/es.symbol.description.js");
24
- require("core-js/modules/es.number.constructor.js");
25
- var _element = require("./../../../helpers/dom/element");
26
- var _border = _interopRequireDefault(require("./border"));
27
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
29
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
30
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
31
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
32
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
33
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
34
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
35
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
36
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
37
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
38
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
39
- 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); }
40
- /**
41
- * @class Selection
42
- */
43
- var Selection = /*#__PURE__*/function () {
44
- /**
45
- * @param {object} settings The selection settings object. @todo type.
46
- * @param {CellRange} cellRange The cell range instance.
47
- */
48
- function Selection(settings, cellRange) {
49
- _classCallCheck(this, Selection);
50
- this.settings = settings;
51
- this.cellRange = cellRange || null;
52
- this.instanceBorders = {};
53
- this.classNames = [this.settings.className];
54
- this.classNameGenerator = this.linearClassNameGenerator(this.settings.className, this.settings.layerLevel);
55
- }
56
-
57
- /**
58
- * Each Walkontable clone requires it's own border for every selection. This method creates and returns selection
59
- * borders per instance.
60
- *
61
- * @param {WalkontableFacade} wotInstance The Walkontable instance.
62
- * @returns {Border}
63
- */
64
- _createClass(Selection, [{
65
- key: "getBorder",
66
- value: function getBorder(wotInstance) {
67
- if (!this.instanceBorders[wotInstance.guid]) {
68
- this.instanceBorders[wotInstance.guid] = new _border.default(wotInstance, this.settings);
69
- }
70
- return this.instanceBorders[wotInstance.guid];
71
- }
72
-
73
- /**
74
- * Checks if selection is empty.
75
- *
76
- * @returns {boolean}
77
- */
78
- }, {
79
- key: "isEmpty",
80
- value: function isEmpty() {
81
- return this.cellRange === null;
82
- }
83
-
84
- /**
85
- * Adds a cell coords to the selection.
86
- *
87
- * @param {CellCoords} coords The cell coordinates to add.
88
- * @returns {Selection}
89
- */
90
- }, {
91
- key: "add",
92
- value: function add(coords) {
93
- if (this.isEmpty()) {
94
- this.cellRange = this.settings.createCellRange(coords);
95
- } else {
96
- this.cellRange.expand(coords);
97
- }
98
- return this;
99
- }
100
-
101
- /**
102
- * If selection range from or to property equals oldCoords, replace it with newCoords. Return boolean
103
- * information about success.
104
- *
105
- * @param {CellCoords} oldCoords An old cell coordinates to replace.
106
- * @param {CellCoords} newCoords The new cell coordinates.
107
- * @returns {boolean}
108
- */
109
- }, {
110
- key: "replace",
111
- value: function replace(oldCoords, newCoords) {
112
- if (!this.isEmpty()) {
113
- if (this.cellRange.from.isEqual(oldCoords)) {
114
- this.cellRange.from = newCoords;
115
- return true;
116
- }
117
- if (this.cellRange.to.isEqual(oldCoords)) {
118
- this.cellRange.to = newCoords;
119
- return true;
120
- }
121
- }
122
- return false;
123
- }
124
-
125
- /**
126
- * Clears selection.
127
- *
128
- * @returns {Selection}
129
- */
130
- }, {
131
- key: "clear",
132
- value: function clear() {
133
- this.cellRange = null;
134
- return this;
135
- }
136
-
137
- /**
138
- * Returns the top left (or top right in RTL) and bottom right (or bottom left in RTL) selection coordinates.
139
- *
140
- * @returns {Array} Returns array of coordinates for example `[1, 1, 5, 5]`.
141
- */
142
- }, {
143
- key: "getCorners",
144
- value: function getCorners() {
145
- var topStart = this.cellRange.getOuterTopStartCorner();
146
- var bottomEnd = this.cellRange.getOuterBottomEndCorner();
147
- return [topStart.row, topStart.col, bottomEnd.row, bottomEnd.col];
148
- }
149
-
150
- /**
151
- * Adds class name to cell element at given coords.
152
- *
153
- * @param {WalkontableFacade} wotInstance Walkontable instance.
154
- * @param {number} sourceRow Cell row coord.
155
- * @param {number} sourceColumn Cell column coord.
156
- * @param {string} className Class name.
157
- * @param {boolean} [markIntersections=false] If `true`, linear className generator will be used to add CSS classes
158
- * in a continuous way.
159
- * @returns {Selection}
160
- */
161
- }, {
162
- key: "addClassAtCoords",
163
- value: function addClassAtCoords(wotInstance, sourceRow, sourceColumn, className) {
164
- var markIntersections = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
165
- var TD = wotInstance.wtTable.getCell(this.settings.createCellCoords(sourceRow, sourceColumn));
166
- if (_typeof(TD) === 'object') {
167
- var cellClassName = className;
168
- if (markIntersections) {
169
- cellClassName = this.classNameGenerator(TD);
170
- if (!this.classNames.includes(cellClassName)) {
171
- this.classNames.push(cellClassName);
172
- }
173
- }
174
- (0, _element.addClass)(TD, cellClassName);
175
- }
176
- return this;
177
- }
178
-
179
- /**
180
- * Generate helper for calculating classNames based on previously added base className.
181
- * The generated className is always generated as a continuation of the previous className. For example, when
182
- * the currently checked element has 'area-2' className the generated new className will be 'area-3'. When
183
- * the element doesn't have any classNames than the base className will be returned ('area');.
184
- *
185
- * @param {string} baseClassName Base className to be used.
186
- * @param {number} layerLevelOwner Layer level which the instance of the Selection belongs to.
187
- * @returns {Function}
188
- */
189
- }, {
190
- key: "linearClassNameGenerator",
191
- value: function linearClassNameGenerator(baseClassName, layerLevelOwner) {
192
- // TODO: Make this recursive function Proper Tail Calls (TCO/PTC) friendly.
193
- return function calcClassName(element) {
194
- var previousIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
195
- if (layerLevelOwner === 0 || previousIndex === 0) {
196
- return baseClassName;
197
- }
198
- var index = previousIndex >= 0 ? previousIndex : layerLevelOwner;
199
- var className = baseClassName;
200
- index -= 1;
201
- var previousClassName = index === 0 ? baseClassName : "".concat(baseClassName, "-").concat(index);
202
- if ((0, _element.hasClass)(element, previousClassName)) {
203
- var currentLayer = index + 1;
204
- className = "".concat(baseClassName, "-").concat(currentLayer);
205
- } else {
206
- className = calcClassName(element, index);
207
- }
208
- return className;
209
- };
210
- }
211
-
212
- /**
213
- * @param {WalkontableFacade} wotInstance The Walkontable instance.
214
- */
215
- }, {
216
- key: "draw",
217
- value: function draw(wotInstance) {
218
- if (this.isEmpty()) {
219
- if (this.settings.border) {
220
- this.getBorder(wotInstance).disappear();
221
- }
222
- return;
223
- }
224
- var renderedRows = wotInstance.wtTable.getRenderedRowsCount();
225
- var renderedColumns = wotInstance.wtTable.getRenderedColumnsCount();
226
- var corners = this.getCorners();
227
- var _corners = _slicedToArray(corners, 4),
228
- topRow = _corners[0],
229
- topColumn = _corners[1],
230
- bottomRow = _corners[2],
231
- bottomColumn = _corners[3];
232
- var _this$settings = this.settings,
233
- highlightHeaderClassName = _this$settings.highlightHeaderClassName,
234
- highlightColumnClassName = _this$settings.highlightColumnClassName,
235
- highlightRowClassName = _this$settings.highlightRowClassName,
236
- highlightOnlyClosestHeader = _this$settings.highlightOnlyClosestHeader,
237
- selectionType = _this$settings.selectionType;
238
- var isHeaderSelectionType = selectionType === void 0 || ['active-header', 'header'].includes(selectionType);
239
- if (isHeaderSelectionType && topColumn !== null && bottomColumn !== null) {
240
- var selectionColumnCursor = 0;
241
- for (var column = 0; column < renderedColumns; column += 1) {
242
- var sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column);
243
- if (sourceCol >= topColumn && sourceCol <= bottomColumn) {
244
- var THs = wotInstance.wtTable.getColumnHeaders(sourceCol);
245
- var closestHeaderLevel = THs.length - 1;
246
- if (highlightOnlyClosestHeader && THs.length > 1) {
247
- THs = [THs[closestHeaderLevel]];
248
- }
249
- for (var headerLevel = 0; headerLevel < THs.length; headerLevel += 1) {
250
- var newClasses = [];
251
- var TH = THs[headerLevel];
252
- if (highlightHeaderClassName) {
253
- newClasses.push(highlightHeaderClassName);
254
- }
255
- if (highlightColumnClassName) {
256
- newClasses.push(highlightColumnClassName);
257
- }
258
- headerLevel = highlightOnlyClosestHeader ? closestHeaderLevel : headerLevel;
259
- var newSourceCol = wotInstance.getSetting('onBeforeHighlightingColumnHeader', sourceCol, headerLevel, {
260
- selectionType: selectionType,
261
- columnCursor: selectionColumnCursor,
262
- selectionWidth: bottomColumn - topColumn + 1,
263
- classNames: newClasses
264
- });
265
- if (newSourceCol !== sourceCol) {
266
- TH = wotInstance.wtTable.getColumnHeader(newSourceCol, headerLevel);
267
- }
268
- (0, _element.addClass)(TH, newClasses);
269
- }
270
- selectionColumnCursor += 1;
271
- }
272
- }
273
- }
274
- if (topRow !== null && bottomRow !== null) {
275
- var selectionRowCursor = 0;
276
- for (var row = 0; row < renderedRows; row += 1) {
277
- var sourceRow = wotInstance.wtTable.rowFilter.renderedToSource(row);
278
- if (isHeaderSelectionType && sourceRow >= topRow && sourceRow <= bottomRow) {
279
- var _THs = wotInstance.wtTable.getRowHeaders(sourceRow);
280
- var _closestHeaderLevel = _THs.length - 1;
281
- if (highlightOnlyClosestHeader && _THs.length > 1) {
282
- _THs = [_THs[_closestHeaderLevel]];
283
- }
284
- for (var _headerLevel = 0; _headerLevel < _THs.length; _headerLevel += 1) {
285
- var _newClasses = [];
286
- var _TH = _THs[_headerLevel];
287
- if (highlightHeaderClassName) {
288
- _newClasses.push(highlightHeaderClassName);
289
- }
290
- if (highlightRowClassName) {
291
- _newClasses.push(highlightRowClassName);
292
- }
293
- _headerLevel = highlightOnlyClosestHeader ? _closestHeaderLevel : _headerLevel;
294
- var newSourceRow = wotInstance.getSetting('onBeforeHighlightingRowHeader', sourceRow, _headerLevel, {
295
- selectionType: selectionType,
296
- rowCursor: selectionRowCursor,
297
- selectionHeight: bottomRow - topRow + 1,
298
- classNames: _newClasses
299
- });
300
- if (newSourceRow !== sourceRow) {
301
- _TH = wotInstance.wtTable.getRowHeader(newSourceRow, _headerLevel);
302
- }
303
- (0, _element.addClass)(_TH, _newClasses);
304
- }
305
- selectionRowCursor += 1;
306
- }
307
- if (topColumn !== null && bottomColumn !== null) {
308
- for (var _column = 0; _column < renderedColumns; _column += 1) {
309
- var _sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(_column);
310
- if (sourceRow >= topRow && sourceRow <= bottomRow && _sourceCol >= topColumn && _sourceCol <= bottomColumn) {
311
- // selected cell
312
- if (this.settings.className) {
313
- this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, this.settings.className, this.settings.markIntersections);
314
- }
315
- } else if (sourceRow >= topRow && sourceRow <= bottomRow) {
316
- // selection is in this row
317
- if (highlightRowClassName) {
318
- this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, highlightRowClassName);
319
- }
320
- } else if (_sourceCol >= topColumn && _sourceCol <= bottomColumn) {
321
- // selection is in this column
322
- if (highlightColumnClassName) {
323
- this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, highlightColumnClassName);
324
- }
325
- }
326
- var additionalSelectionClass = wotInstance.getSetting('onAfterDrawSelection', sourceRow, _sourceCol, this.settings.layerLevel);
327
- if (typeof additionalSelectionClass === 'string') {
328
- this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, additionalSelectionClass);
329
- }
330
- }
331
- }
332
- }
333
- }
334
- wotInstance.getSetting('onBeforeDrawBorders', corners, this.settings.className);
335
- if (this.settings.border) {
336
- // warning! border.appear modifies corners!
337
- this.getBorder(wotInstance).appear(corners);
338
- }
339
- }
340
-
341
- /**
342
- * Cleans up all the DOM state related to a Selection instance. Call this prior to deleting a Selection instance.
343
- */
344
- }, {
345
- key: "destroy",
346
- value: function destroy() {
347
- Object.values(this.instanceBorders).forEach(function (border) {
348
- return border.destroy();
349
- });
350
- }
351
- }]);
352
- return Selection;
353
- }();
354
- var _default = Selection;
355
- exports.default = _default;