handsontable 15.0.1-next-ab94a4c-20250207 → 15.1.0-next-5e493ee-20250207

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.
Files changed (170) hide show
  1. package/3rdparty/walkontable/src/index.js +2 -0
  2. package/3rdparty/walkontable/src/index.mjs +2 -1
  3. package/3rdparty/walkontable/src/overlays.js +2 -39
  4. package/3rdparty/walkontable/src/overlays.mjs +2 -39
  5. package/3rdparty/walkontable/src/renderer/_base.js +3 -4
  6. package/3rdparty/walkontable/src/renderer/_base.mjs +2 -2
  7. package/3rdparty/walkontable/src/renderer/cells.js +7 -11
  8. package/3rdparty/walkontable/src/renderer/cells.mjs +6 -9
  9. package/3rdparty/walkontable/src/renderer/colGroup.js +6 -7
  10. package/3rdparty/walkontable/src/renderer/colGroup.mjs +5 -5
  11. package/3rdparty/walkontable/src/renderer/columnHeaders.js +4 -5
  12. package/3rdparty/walkontable/src/renderer/columnHeaders.mjs +3 -3
  13. package/3rdparty/walkontable/src/renderer/index.js +18 -19
  14. package/3rdparty/walkontable/src/renderer/index.mjs +6 -6
  15. package/3rdparty/walkontable/src/renderer/rowHeaders.js +6 -7
  16. package/3rdparty/walkontable/src/renderer/rowHeaders.mjs +5 -5
  17. package/3rdparty/walkontable/src/renderer/rows.js +23 -11
  18. package/3rdparty/walkontable/src/renderer/rows.mjs +23 -10
  19. package/3rdparty/walkontable/src/renderer/table.js +1 -1
  20. package/3rdparty/walkontable/src/renderer/table.mjs +1 -1
  21. package/3rdparty/walkontable/src/selection/border/border.js +10 -2
  22. package/3rdparty/walkontable/src/selection/border/border.mjs +10 -2
  23. package/3rdparty/walkontable/src/utils/nodesPool.js +21 -6
  24. package/3rdparty/walkontable/src/utils/nodesPool.mjs +21 -6
  25. package/3rdparty/walkontable/src/utils/orderView/index.js +4 -5
  26. package/3rdparty/walkontable/src/utils/orderView/index.mjs +2 -2
  27. package/3rdparty/walkontable/src/utils/orderView/sharedView.js +3 -4
  28. package/3rdparty/walkontable/src/utils/orderView/sharedView.mjs +2 -2
  29. package/3rdparty/walkontable/src/utils/orderView/view.js +60 -76
  30. package/3rdparty/walkontable/src/utils/orderView/view.mjs +59 -74
  31. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.js +138 -0
  32. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.mjs +135 -0
  33. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.js +72 -0
  34. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.mjs +68 -0
  35. package/3rdparty/walkontable/src/utils/orderView/viewSize.js +1 -1
  36. package/3rdparty/walkontable/src/utils/orderView/viewSize.mjs +1 -1
  37. package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.js +4 -5
  38. package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.mjs +3 -3
  39. package/CHANGELOG.md +48 -2
  40. package/README.md +3 -3
  41. package/base.js +2 -2
  42. package/base.mjs +2 -2
  43. package/cellTypes/dropdownType/dropdownType.js +4 -2
  44. package/cellTypes/dropdownType/dropdownType.mjs +4 -2
  45. package/core.js +39 -38
  46. package/core.mjs +36 -35
  47. package/dataMap/dataMap.js +8 -0
  48. package/dataMap/dataMap.mjs +8 -0
  49. package/dataMap/dataSource.js +4 -0
  50. package/dataMap/dataSource.mjs +4 -0
  51. package/dataMap/metaManager/lazyFactoryMap.js +8 -5
  52. package/dataMap/metaManager/lazyFactoryMap.mjs +8 -5
  53. package/dataMap/metaManager/metaSchema.js +24 -9
  54. package/dataMap/metaManager/metaSchema.mjs +24 -9
  55. package/dist/handsontable.css +6 -2
  56. package/dist/handsontable.full.css +6 -2
  57. package/dist/handsontable.full.js +8026 -6927
  58. package/dist/handsontable.full.min.css +3 -3
  59. package/dist/handsontable.full.min.js +530 -528
  60. package/dist/handsontable.js +3833 -2914
  61. package/dist/handsontable.min.css +3 -3
  62. package/dist/handsontable.min.js +35 -33
  63. package/editors/autocompleteEditor/autocompleteEditor.js +1 -3
  64. package/editors/autocompleteEditor/autocompleteEditor.mjs +1 -3
  65. package/editors/dateEditor/dateEditor.js +4 -0
  66. package/editors/dateEditor/dateEditor.mjs +4 -0
  67. package/editors/dropdownEditor/dropdownEditor.js +3 -16
  68. package/editors/dropdownEditor/dropdownEditor.mjs +3 -16
  69. package/editors/handsontableEditor/handsontableEditor.js +4 -4
  70. package/editors/handsontableEditor/handsontableEditor.mjs +4 -4
  71. package/focusManager.js +1 -1
  72. package/focusManager.mjs +1 -1
  73. package/helpers/dom/element.d.ts +0 -1
  74. package/helpers/mixed.js +2 -2
  75. package/helpers/mixed.mjs +2 -2
  76. package/helpers/object.js +4 -0
  77. package/helpers/object.mjs +4 -0
  78. package/package.json +2 -2
  79. package/plugins/base/base.js +0 -7
  80. package/plugins/base/base.mjs +0 -7
  81. package/plugins/comments/comments.js +12 -3
  82. package/plugins/comments/comments.mjs +12 -3
  83. package/plugins/contextMenu/contextMenu.js +2 -7
  84. package/plugins/contextMenu/contextMenu.mjs +2 -7
  85. package/plugins/contextMenu/menu/menu.js +2 -2
  86. package/plugins/contextMenu/menu/menu.mjs +2 -2
  87. package/plugins/contextMenu/predefinedItems/clearColumn.js +15 -4
  88. package/plugins/contextMenu/predefinedItems/clearColumn.mjs +15 -4
  89. package/plugins/copyPaste/copyPaste.js +6 -12
  90. package/plugins/copyPaste/copyPaste.mjs +6 -12
  91. package/plugins/filters/conditionCollection.js +8 -7
  92. package/plugins/filters/conditionCollection.mjs +8 -7
  93. package/plugins/filters/filters.js +26 -16
  94. package/plugins/filters/filters.mjs +26 -16
  95. package/plugins/filters/utils.js +7 -24
  96. package/plugins/filters/utils.mjs +7 -24
  97. package/plugins/hiddenColumns/hiddenColumns.js +1 -3
  98. package/plugins/hiddenColumns/hiddenColumns.mjs +1 -3
  99. package/plugins/hiddenRows/hiddenRows.js +1 -3
  100. package/plugins/hiddenRows/hiddenRows.mjs +1 -3
  101. package/plugins/manualRowMove/manualRowMove.js +1 -1
  102. package/plugins/manualRowMove/manualRowMove.mjs +1 -1
  103. package/plugins/mergeCells/calculations/autofill.js +60 -44
  104. package/plugins/mergeCells/calculations/autofill.mjs +60 -44
  105. package/plugins/mergeCells/cellsCollection.js +25 -8
  106. package/plugins/mergeCells/cellsCollection.mjs +25 -8
  107. package/plugins/mergeCells/mergeCells.js +15 -16
  108. package/plugins/mergeCells/mergeCells.mjs +15 -16
  109. package/plugins/nestedHeaders/nestedHeaders.js +6 -1
  110. package/plugins/nestedHeaders/nestedHeaders.mjs +6 -1
  111. package/plugins/nestedHeaders/stateManager/index.js +1 -2
  112. package/plugins/nestedHeaders/stateManager/index.mjs +1 -2
  113. package/plugins/nestedHeaders/utils/ghostTable.js +4 -0
  114. package/plugins/nestedHeaders/utils/ghostTable.mjs +4 -0
  115. package/plugins/nestedRows/utils/rowMoveController.js +1 -6
  116. package/plugins/nestedRows/utils/rowMoveController.mjs +1 -6
  117. package/plugins/undoRedo/actions/_base.js +19 -0
  118. package/plugins/undoRedo/actions/_base.mjs +15 -0
  119. package/plugins/undoRedo/actions/cellAlignment.js +85 -0
  120. package/plugins/undoRedo/actions/cellAlignment.mjs +81 -0
  121. package/plugins/undoRedo/actions/columnMove.js +84 -0
  122. package/plugins/undoRedo/actions/columnMove.mjs +80 -0
  123. package/plugins/undoRedo/actions/columnSort.js +73 -0
  124. package/plugins/undoRedo/actions/columnSort.mjs +69 -0
  125. package/plugins/undoRedo/actions/createColumn.js +60 -0
  126. package/plugins/undoRedo/actions/createColumn.mjs +56 -0
  127. package/plugins/undoRedo/actions/createRow.js +65 -0
  128. package/plugins/undoRedo/actions/createRow.mjs +61 -0
  129. package/plugins/undoRedo/actions/dataChange.js +123 -0
  130. package/plugins/undoRedo/actions/dataChange.mjs +119 -0
  131. package/plugins/undoRedo/actions/filters.js +66 -0
  132. package/plugins/undoRedo/actions/filters.mjs +62 -0
  133. package/plugins/undoRedo/actions/index.js +27 -0
  134. package/plugins/undoRedo/actions/index.mjs +23 -0
  135. package/plugins/undoRedo/actions/mergeCells.js +63 -0
  136. package/plugins/undoRedo/actions/mergeCells.mjs +59 -0
  137. package/plugins/undoRedo/actions/removeColumn.js +176 -0
  138. package/plugins/undoRedo/actions/removeColumn.mjs +172 -0
  139. package/plugins/undoRedo/actions/removeRow.js +119 -0
  140. package/plugins/undoRedo/actions/removeRow.mjs +115 -0
  141. package/plugins/undoRedo/actions/rowMove.js +84 -0
  142. package/plugins/undoRedo/actions/rowMove.mjs +80 -0
  143. package/plugins/undoRedo/actions/unmergeCells.js +56 -0
  144. package/plugins/undoRedo/actions/unmergeCells.mjs +52 -0
  145. package/plugins/undoRedo/index.js +3 -4
  146. package/plugins/undoRedo/index.mjs +1 -2
  147. package/plugins/undoRedo/undoRedo.js +277 -879
  148. package/plugins/undoRedo/undoRedo.mjs +277 -880
  149. package/plugins/undoRedo/utils.js +37 -0
  150. package/plugins/undoRedo/utils.mjs +33 -0
  151. package/renderers/checkboxRenderer/checkboxRenderer.js +8 -1
  152. package/renderers/checkboxRenderer/checkboxRenderer.mjs +8 -1
  153. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +1 -0
  154. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +1 -0
  155. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +2 -1
  156. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +2 -1
  157. package/styles/handsontable.css +75 -103
  158. package/styles/handsontable.min.css +3 -3
  159. package/styles/ht-theme-horizon.css +2 -2
  160. package/styles/ht-theme-horizon.min.css +2 -2
  161. package/styles/ht-theme-main.css +2 -2
  162. package/styles/ht-theme-main.min.css +2 -2
  163. package/tableView.js +17 -1
  164. package/tableView.mjs +17 -1
  165. package/utils/autoResize.js +1 -1
  166. package/utils/autoResize.mjs +1 -1
  167. package/utils/parseTable.js +1 -1
  168. package/utils/parseTable.mjs +1 -1
  169. package/validators/dateValidator/dateValidator.js +1 -1
  170. package/validators/dateValidator/dateValidator.mjs +1 -1
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ require("core-js/modules/es.error.cause.js");
5
+ require("core-js/modules/esnext.iterator.constructor.js");
6
+ require("core-js/modules/esnext.iterator.filter.js");
7
+ var _base = require("./_base");
8
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
10
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
+ /**
12
+ * Action that tracks filter changes.
13
+ *
14
+ * @class FiltersAction
15
+ * @private
16
+ */
17
+ class FiltersAction extends _base.BaseAction {
18
+ constructor(_ref) {
19
+ let {
20
+ conditionsStack,
21
+ previousConditionsStack
22
+ } = _ref;
23
+ super();
24
+ /**
25
+ * @param {Array} previousConditionsStack An array of the previous filter conditions.
26
+ */
27
+ _defineProperty(this, "conditionsStack", void 0);
28
+ /**
29
+ * @param {Array} conditionsStack An array of the filter conditions.
30
+ */
31
+ _defineProperty(this, "previousConditionsStack", void 0);
32
+ this.conditionsStack = conditionsStack;
33
+ this.previousConditionsStack = previousConditionsStack;
34
+ }
35
+ static startRegisteringEvents(hot, undoRedoPlugin) {
36
+ hot.addHook('beforeFilter', (conditionsStack, previousConditionsStack) => {
37
+ undoRedoPlugin.done(() => new FiltersAction({
38
+ conditionsStack,
39
+ previousConditionsStack
40
+ }));
41
+ });
42
+ }
43
+
44
+ /**
45
+ * @param {Core} hot The Handsontable instance.
46
+ * @param {function(): void} undoneCallback The callback to be called after the action is undone.
47
+ */
48
+ undo(hot, undoneCallback) {
49
+ const filters = hot.getPlugin('filters');
50
+ hot.addHookOnce('afterViewRender', undoneCallback);
51
+ filters.conditionCollection.importAllConditions(this.previousConditionsStack);
52
+ filters.filter();
53
+ }
54
+
55
+ /**
56
+ * @param {Core} hot The Handsontable instance.
57
+ * @param {function(): void} redoneCallback The callback to be called after the action is redone.
58
+ */
59
+ redo(hot, redoneCallback) {
60
+ const filters = hot.getPlugin('filters');
61
+ hot.addHookOnce('afterViewRender', redoneCallback);
62
+ filters.conditionCollection.importAllConditions(this.conditionsStack);
63
+ filters.filter();
64
+ }
65
+ }
66
+ exports.FiltersAction = FiltersAction;
@@ -0,0 +1,62 @@
1
+ import "core-js/modules/es.error.cause.js";
2
+ import "core-js/modules/esnext.iterator.constructor.js";
3
+ import "core-js/modules/esnext.iterator.filter.js";
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { BaseAction } from "./_base.mjs";
8
+ /**
9
+ * Action that tracks filter changes.
10
+ *
11
+ * @class FiltersAction
12
+ * @private
13
+ */
14
+ export class FiltersAction extends BaseAction {
15
+ constructor(_ref) {
16
+ let {
17
+ conditionsStack,
18
+ previousConditionsStack
19
+ } = _ref;
20
+ super();
21
+ /**
22
+ * @param {Array} previousConditionsStack An array of the previous filter conditions.
23
+ */
24
+ _defineProperty(this, "conditionsStack", void 0);
25
+ /**
26
+ * @param {Array} conditionsStack An array of the filter conditions.
27
+ */
28
+ _defineProperty(this, "previousConditionsStack", void 0);
29
+ this.conditionsStack = conditionsStack;
30
+ this.previousConditionsStack = previousConditionsStack;
31
+ }
32
+ static startRegisteringEvents(hot, undoRedoPlugin) {
33
+ hot.addHook('beforeFilter', (conditionsStack, previousConditionsStack) => {
34
+ undoRedoPlugin.done(() => new FiltersAction({
35
+ conditionsStack,
36
+ previousConditionsStack
37
+ }));
38
+ });
39
+ }
40
+
41
+ /**
42
+ * @param {Core} hot The Handsontable instance.
43
+ * @param {function(): void} undoneCallback The callback to be called after the action is undone.
44
+ */
45
+ undo(hot, undoneCallback) {
46
+ const filters = hot.getPlugin('filters');
47
+ hot.addHookOnce('afterViewRender', undoneCallback);
48
+ filters.conditionCollection.importAllConditions(this.previousConditionsStack);
49
+ filters.filter();
50
+ }
51
+
52
+ /**
53
+ * @param {Core} hot The Handsontable instance.
54
+ * @param {function(): void} redoneCallback The callback to be called after the action is redone.
55
+ */
56
+ redo(hot, redoneCallback) {
57
+ const filters = hot.getPlugin('filters');
58
+ hot.addHookOnce('afterViewRender', redoneCallback);
59
+ filters.conditionCollection.importAllConditions(this.conditionsStack);
60
+ filters.filter();
61
+ }
62
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.registerActions = registerActions;
5
+ require("core-js/modules/esnext.iterator.constructor.js");
6
+ require("core-js/modules/esnext.iterator.for-each.js");
7
+ var _cellAlignment = require("./cellAlignment");
8
+ var _columnMove = require("./columnMove");
9
+ var _columnSort = require("./columnSort");
10
+ var _createColumn = require("./createColumn");
11
+ var _createRow = require("./createRow");
12
+ var _dataChange = require("./dataChange");
13
+ var _filters = require("./filters");
14
+ var _mergeCells = require("./mergeCells");
15
+ var _removeColumn = require("./removeColumn");
16
+ var _removeRow = require("./removeRow");
17
+ var _rowMove = require("./rowMove");
18
+ var _unmergeCells = require("./unmergeCells");
19
+ /**
20
+ * Register all undo/redo actions.
21
+ *
22
+ * @param {Core} hot The Handsontable instance.
23
+ * @param {UndoRedo} undoRedoPlugin The undoRedo plugin instance.
24
+ */
25
+ function registerActions(hot, undoRedoPlugin) {
26
+ [_cellAlignment.CellAlignmentAction, _columnMove.ColumnMoveAction, _columnSort.ColumnSortAction, _createColumn.CreateColumnAction, _createRow.CreateRowAction, _dataChange.DataChangeAction, _filters.FiltersAction, _mergeCells.MergeCellsAction, _removeColumn.RemoveColumnAction, _removeRow.RemoveRowAction, _rowMove.RowMoveAction, _unmergeCells.UnmergeCellsAction].forEach(action => action.startRegisteringEvents(hot, undoRedoPlugin));
27
+ }
@@ -0,0 +1,23 @@
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.for-each.js";
3
+ import { CellAlignmentAction } from "./cellAlignment.mjs";
4
+ import { ColumnMoveAction } from "./columnMove.mjs";
5
+ import { ColumnSortAction } from "./columnSort.mjs";
6
+ import { CreateColumnAction } from "./createColumn.mjs";
7
+ import { CreateRowAction } from "./createRow.mjs";
8
+ import { DataChangeAction } from "./dataChange.mjs";
9
+ import { FiltersAction } from "./filters.mjs";
10
+ import { MergeCellsAction } from "./mergeCells.mjs";
11
+ import { RemoveColumnAction } from "./removeColumn.mjs";
12
+ import { RemoveRowAction } from "./removeRow.mjs";
13
+ import { RowMoveAction } from "./rowMove.mjs";
14
+ import { UnmergeCellsAction } from "./unmergeCells.mjs";
15
+ /**
16
+ * Register all undo/redo actions.
17
+ *
18
+ * @param {Core} hot The Handsontable instance.
19
+ * @param {UndoRedo} undoRedoPlugin The undoRedo plugin instance.
20
+ */
21
+ export function registerActions(hot, undoRedoPlugin) {
22
+ [CellAlignmentAction, ColumnMoveAction, ColumnSortAction, CreateColumnAction, CreateRowAction, DataChangeAction, FiltersAction, MergeCellsAction, RemoveColumnAction, RemoveRowAction, RowMoveAction, UnmergeCellsAction].forEach(action => action.startRegisteringEvents(hot, undoRedoPlugin));
23
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ require("core-js/modules/es.error.cause.js");
5
+ var _base = require("./_base");
6
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
8
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ /**
10
+ * Action that tracks changes in merged cells.
11
+ *
12
+ * @class MergeCellsAction
13
+ * @private
14
+ */
15
+ class MergeCellsAction extends _base.BaseAction {
16
+ constructor(_ref) {
17
+ let {
18
+ data,
19
+ cellRange
20
+ } = _ref;
21
+ super();
22
+ _defineProperty(this, "cellRange", void 0);
23
+ this.cellRange = cellRange;
24
+ this.data = data;
25
+ }
26
+ static startRegisteringEvents(hot, undoRedoPlugin) {
27
+ hot.addHook('beforeMergeCells', (cellRange, auto) => {
28
+ if (auto) {
29
+ return;
30
+ }
31
+ const topStartCorner = cellRange.getTopStartCorner();
32
+ const bottomEndCorner = cellRange.getBottomEndCorner();
33
+ const data = hot.getData(topStartCorner.row, topStartCorner.col, bottomEndCorner.row, bottomEndCorner.col);
34
+ undoRedoPlugin.done(() => new MergeCellsAction({
35
+ data,
36
+ cellRange
37
+ }));
38
+ });
39
+ }
40
+
41
+ /**
42
+ * @param {Core} hot The Handsontable instance.
43
+ * @param {function(): void} undoneCallback The callback to be called after the action is undone.
44
+ */
45
+ undo(hot, undoneCallback) {
46
+ const mergeCellsPlugin = hot.getPlugin('mergeCells');
47
+ hot.addHookOnce('afterViewRender', undoneCallback);
48
+ mergeCellsPlugin.unmergeRange(this.cellRange, true);
49
+ const topStartCorner = this.cellRange.getTopStartCorner();
50
+ hot.populateFromArray(topStartCorner.row, topStartCorner.col, this.data, undefined, undefined, 'MergeCells');
51
+ }
52
+
53
+ /**
54
+ * @param {Core} hot The Handsontable instance.
55
+ * @param {function(): void} redoneCallback The callback to be called after the action is redone.
56
+ */
57
+ redo(hot, redoneCallback) {
58
+ const mergeCellsPlugin = hot.getPlugin('mergeCells');
59
+ hot.addHookOnce('afterViewRender', redoneCallback);
60
+ mergeCellsPlugin.mergeRange(this.cellRange);
61
+ }
62
+ }
63
+ exports.MergeCellsAction = MergeCellsAction;
@@ -0,0 +1,59 @@
1
+ import "core-js/modules/es.error.cause.js";
2
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
4
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
+ import { BaseAction } from "./_base.mjs";
6
+ /**
7
+ * Action that tracks changes in merged cells.
8
+ *
9
+ * @class MergeCellsAction
10
+ * @private
11
+ */
12
+ export class MergeCellsAction extends BaseAction {
13
+ constructor(_ref) {
14
+ let {
15
+ data,
16
+ cellRange
17
+ } = _ref;
18
+ super();
19
+ _defineProperty(this, "cellRange", void 0);
20
+ this.cellRange = cellRange;
21
+ this.data = data;
22
+ }
23
+ static startRegisteringEvents(hot, undoRedoPlugin) {
24
+ hot.addHook('beforeMergeCells', (cellRange, auto) => {
25
+ if (auto) {
26
+ return;
27
+ }
28
+ const topStartCorner = cellRange.getTopStartCorner();
29
+ const bottomEndCorner = cellRange.getBottomEndCorner();
30
+ const data = hot.getData(topStartCorner.row, topStartCorner.col, bottomEndCorner.row, bottomEndCorner.col);
31
+ undoRedoPlugin.done(() => new MergeCellsAction({
32
+ data,
33
+ cellRange
34
+ }));
35
+ });
36
+ }
37
+
38
+ /**
39
+ * @param {Core} hot The Handsontable instance.
40
+ * @param {function(): void} undoneCallback The callback to be called after the action is undone.
41
+ */
42
+ undo(hot, undoneCallback) {
43
+ const mergeCellsPlugin = hot.getPlugin('mergeCells');
44
+ hot.addHookOnce('afterViewRender', undoneCallback);
45
+ mergeCellsPlugin.unmergeRange(this.cellRange, true);
46
+ const topStartCorner = this.cellRange.getTopStartCorner();
47
+ hot.populateFromArray(topStartCorner.row, topStartCorner.col, this.data, undefined, undefined, 'MergeCells');
48
+ }
49
+
50
+ /**
51
+ * @param {Core} hot The Handsontable instance.
52
+ * @param {function(): void} redoneCallback The callback to be called after the action is redone.
53
+ */
54
+ redo(hot, redoneCallback) {
55
+ const mergeCellsPlugin = hot.getPlugin('mergeCells');
56
+ hot.addHookOnce('afterViewRender', redoneCallback);
57
+ mergeCellsPlugin.mergeRange(this.cellRange);
58
+ }
59
+ }
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ require("core-js/modules/es.error.cause.js");
5
+ require("core-js/modules/es.array.push.js");
6
+ require("core-js/modules/esnext.iterator.constructor.js");
7
+ require("core-js/modules/esnext.iterator.for-each.js");
8
+ var _base = require("./_base");
9
+ var _utils = require("../utils");
10
+ var _number = require("../../../helpers/number");
11
+ var _array = require("../../../helpers/array");
12
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
14
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
+ /**
16
+ * Action that tracks changes in column removal.
17
+ *
18
+ * @class RemoveColumnAction
19
+ * @private
20
+ */
21
+ class RemoveColumnAction extends _base.BaseAction {
22
+ constructor(_ref) {
23
+ let {
24
+ index,
25
+ indexes,
26
+ data,
27
+ headers,
28
+ columnPositions,
29
+ rowPositions,
30
+ fixedColumnsStart,
31
+ removedCellMetas
32
+ } = _ref;
33
+ super();
34
+ /**
35
+ * @param {number} index The visual column index.
36
+ */
37
+ _defineProperty(this, "index", void 0);
38
+ /**
39
+ * @param {number[]} indexes The visual column indexes.
40
+ */
41
+ _defineProperty(this, "indexes", void 0);
42
+ /**
43
+ * @param {Array} data The removed data.
44
+ */
45
+ _defineProperty(this, "data", void 0);
46
+ /**
47
+ * @param {number} amount The number of removed columns.
48
+ */
49
+ _defineProperty(this, "amount", void 0);
50
+ /**
51
+ * @param {Array} headers The header values.
52
+ */
53
+ _defineProperty(this, "headers", void 0);
54
+ /**
55
+ * @param {number[]} columnPositions The column position.
56
+ */
57
+ _defineProperty(this, "columnPositions", void 0);
58
+ /**
59
+ * @param {number[]} rowPositions The row position.
60
+ */
61
+ _defineProperty(this, "rowPositions", void 0);
62
+ /**
63
+ * @param {number} fixedColumnsStart Number of fixed columns on the left. Remove column action change it sometimes.
64
+ */
65
+ _defineProperty(this, "fixedColumnsStart", void 0);
66
+ /**
67
+ * @param {Array} removedCellMetas List of removed cell metas.
68
+ */
69
+ _defineProperty(this, "removedCellMetas", void 0);
70
+ this.index = index;
71
+ this.indexes = indexes;
72
+ this.data = data;
73
+ this.amount = this.data[0].length;
74
+ this.headers = headers;
75
+ this.columnPositions = columnPositions.slice(0);
76
+ this.rowPositions = rowPositions.slice(0);
77
+ this.fixedColumnsStart = fixedColumnsStart;
78
+ this.removedCellMetas = removedCellMetas;
79
+ }
80
+ static startRegisteringEvents(hot, undoRedoPlugin) {
81
+ hot.addHook('beforeRemoveCol', (index, amount, logicColumns, source) => {
82
+ const wrappedAction = () => {
83
+ const originalData = hot.getSourceDataArray();
84
+ const columnIndex = (hot.countCols() + index) % hot.countCols();
85
+ const lastColumnIndex = columnIndex + amount - 1;
86
+ const removedData = [];
87
+ const headers = [];
88
+ const indexes = [];
89
+ (0, _number.rangeEach)(originalData.length - 1, i => {
90
+ const column = [];
91
+ const origRow = originalData[i];
92
+ (0, _number.rangeEach)(columnIndex, lastColumnIndex, j => {
93
+ column.push(origRow[hot.toPhysicalColumn(j)]);
94
+ });
95
+ removedData.push(column);
96
+ });
97
+ (0, _number.rangeEach)(amount - 1, i => {
98
+ indexes.push(hot.toPhysicalColumn(columnIndex + i));
99
+ });
100
+ if (Array.isArray(hot.getSettings().colHeaders)) {
101
+ (0, _number.rangeEach)(amount - 1, i => {
102
+ headers.push(hot.getSettings().colHeaders[hot.toPhysicalColumn(columnIndex + i)] || null);
103
+ });
104
+ }
105
+ const columnsMap = hot.columnIndexMapper.getIndexesSequence();
106
+ const rowsMap = hot.rowIndexMapper.getIndexesSequence();
107
+ return new RemoveColumnAction({
108
+ index: columnIndex,
109
+ indexes,
110
+ data: removedData,
111
+ headers,
112
+ columnPositions: columnsMap,
113
+ rowPositions: rowsMap,
114
+ fixedColumnsStart: hot.getSettings().fixedColumnsStart,
115
+ removedCellMetas: (0, _utils.getCellMetas)(hot, 0, hot.countRows(), columnIndex, lastColumnIndex)
116
+ });
117
+ };
118
+ undoRedoPlugin.done(wrappedAction, source);
119
+ });
120
+ }
121
+
122
+ /**
123
+ * @param {Core} hot The Handsontable instance.
124
+ * @param {function(): void} undoneCallback The callback to be called after the action is undone.
125
+ */
126
+ undo(hot, undoneCallback) {
127
+ const settings = hot.getSettings();
128
+
129
+ // Changing by the reference as `updateSettings` doesn't work the best.
130
+ settings.fixedColumnsStart = this.fixedColumnsStart;
131
+ const ascendingIndexes = this.indexes.slice(0).sort();
132
+ const sortByIndexes = (elem, j, arr) => arr[this.indexes.indexOf(ascendingIndexes[j])];
133
+ const removedDataLength = this.data.length;
134
+ const sortedData = [];
135
+ for (let rowIndex = 0; rowIndex < removedDataLength; rowIndex++) {
136
+ sortedData.push((0, _array.arrayMap)(this.data[rowIndex], sortByIndexes));
137
+ }
138
+ const sortedHeaders = (0, _array.arrayMap)(this.headers, sortByIndexes);
139
+ const changes = [];
140
+ hot.alter('insert_col_start', this.indexes[0], this.indexes.length, 'UndoRedo.undo');
141
+ (0, _array.arrayEach)(hot.getSourceDataArray(), (rowData, rowIndex) => {
142
+ (0, _array.arrayEach)(ascendingIndexes, (changedIndex, contiquesIndex) => {
143
+ rowData[changedIndex] = sortedData[rowIndex][contiquesIndex];
144
+ changes.push([rowIndex, changedIndex, rowData[changedIndex]]);
145
+ });
146
+ });
147
+ hot.setSourceDataAtCell(changes, undefined, undefined, 'UndoRedo.undo');
148
+ if (typeof this.headers !== 'undefined') {
149
+ (0, _array.arrayEach)(sortedHeaders, (headerData, columnIndex) => {
150
+ hot.getSettings().colHeaders[ascendingIndexes[columnIndex]] = headerData;
151
+ });
152
+ }
153
+ this.removedCellMetas.forEach(_ref2 => {
154
+ let [rowIndex, columnIndex, cellMeta] = _ref2;
155
+ hot.setCellMetaObject(rowIndex, columnIndex, cellMeta);
156
+ });
157
+ hot.batchExecution(() => {
158
+ // Restore row sequence in a case when all columns are removed. the original
159
+ // row sequence is lost in that case.
160
+ hot.rowIndexMapper.setIndexesSequence(this.rowPositions);
161
+ hot.columnIndexMapper.setIndexesSequence(this.columnPositions);
162
+ }, true);
163
+ hot.addHookOnce('afterViewRender', undoneCallback);
164
+ hot.render();
165
+ }
166
+
167
+ /**
168
+ * @param {Core} hot The Handsontable instance.
169
+ * @param {function(): void} redoneCallback The callback to be called after the action is redone.
170
+ */
171
+ redo(hot, redoneCallback) {
172
+ hot.addHookOnce('afterRemoveCol', redoneCallback);
173
+ hot.alter('remove_col', this.index, this.amount, 'UndoRedo.redo');
174
+ }
175
+ }
176
+ exports.RemoveColumnAction = RemoveColumnAction;
@@ -0,0 +1,172 @@
1
+ import "core-js/modules/es.error.cause.js";
2
+ import "core-js/modules/es.array.push.js";
3
+ import "core-js/modules/esnext.iterator.constructor.js";
4
+ import "core-js/modules/esnext.iterator.for-each.js";
5
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
7
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ import { BaseAction } from "./_base.mjs";
9
+ import { getCellMetas } from "../utils.mjs";
10
+ import { rangeEach } from "../../../helpers/number.mjs";
11
+ import { arrayMap, arrayEach } from "../../../helpers/array.mjs";
12
+ /**
13
+ * Action that tracks changes in column removal.
14
+ *
15
+ * @class RemoveColumnAction
16
+ * @private
17
+ */
18
+ export class RemoveColumnAction extends BaseAction {
19
+ constructor(_ref) {
20
+ let {
21
+ index,
22
+ indexes,
23
+ data,
24
+ headers,
25
+ columnPositions,
26
+ rowPositions,
27
+ fixedColumnsStart,
28
+ removedCellMetas
29
+ } = _ref;
30
+ super();
31
+ /**
32
+ * @param {number} index The visual column index.
33
+ */
34
+ _defineProperty(this, "index", void 0);
35
+ /**
36
+ * @param {number[]} indexes The visual column indexes.
37
+ */
38
+ _defineProperty(this, "indexes", void 0);
39
+ /**
40
+ * @param {Array} data The removed data.
41
+ */
42
+ _defineProperty(this, "data", void 0);
43
+ /**
44
+ * @param {number} amount The number of removed columns.
45
+ */
46
+ _defineProperty(this, "amount", void 0);
47
+ /**
48
+ * @param {Array} headers The header values.
49
+ */
50
+ _defineProperty(this, "headers", void 0);
51
+ /**
52
+ * @param {number[]} columnPositions The column position.
53
+ */
54
+ _defineProperty(this, "columnPositions", void 0);
55
+ /**
56
+ * @param {number[]} rowPositions The row position.
57
+ */
58
+ _defineProperty(this, "rowPositions", void 0);
59
+ /**
60
+ * @param {number} fixedColumnsStart Number of fixed columns on the left. Remove column action change it sometimes.
61
+ */
62
+ _defineProperty(this, "fixedColumnsStart", void 0);
63
+ /**
64
+ * @param {Array} removedCellMetas List of removed cell metas.
65
+ */
66
+ _defineProperty(this, "removedCellMetas", void 0);
67
+ this.index = index;
68
+ this.indexes = indexes;
69
+ this.data = data;
70
+ this.amount = this.data[0].length;
71
+ this.headers = headers;
72
+ this.columnPositions = columnPositions.slice(0);
73
+ this.rowPositions = rowPositions.slice(0);
74
+ this.fixedColumnsStart = fixedColumnsStart;
75
+ this.removedCellMetas = removedCellMetas;
76
+ }
77
+ static startRegisteringEvents(hot, undoRedoPlugin) {
78
+ hot.addHook('beforeRemoveCol', (index, amount, logicColumns, source) => {
79
+ const wrappedAction = () => {
80
+ const originalData = hot.getSourceDataArray();
81
+ const columnIndex = (hot.countCols() + index) % hot.countCols();
82
+ const lastColumnIndex = columnIndex + amount - 1;
83
+ const removedData = [];
84
+ const headers = [];
85
+ const indexes = [];
86
+ rangeEach(originalData.length - 1, i => {
87
+ const column = [];
88
+ const origRow = originalData[i];
89
+ rangeEach(columnIndex, lastColumnIndex, j => {
90
+ column.push(origRow[hot.toPhysicalColumn(j)]);
91
+ });
92
+ removedData.push(column);
93
+ });
94
+ rangeEach(amount - 1, i => {
95
+ indexes.push(hot.toPhysicalColumn(columnIndex + i));
96
+ });
97
+ if (Array.isArray(hot.getSettings().colHeaders)) {
98
+ rangeEach(amount - 1, i => {
99
+ headers.push(hot.getSettings().colHeaders[hot.toPhysicalColumn(columnIndex + i)] || null);
100
+ });
101
+ }
102
+ const columnsMap = hot.columnIndexMapper.getIndexesSequence();
103
+ const rowsMap = hot.rowIndexMapper.getIndexesSequence();
104
+ return new RemoveColumnAction({
105
+ index: columnIndex,
106
+ indexes,
107
+ data: removedData,
108
+ headers,
109
+ columnPositions: columnsMap,
110
+ rowPositions: rowsMap,
111
+ fixedColumnsStart: hot.getSettings().fixedColumnsStart,
112
+ removedCellMetas: getCellMetas(hot, 0, hot.countRows(), columnIndex, lastColumnIndex)
113
+ });
114
+ };
115
+ undoRedoPlugin.done(wrappedAction, source);
116
+ });
117
+ }
118
+
119
+ /**
120
+ * @param {Core} hot The Handsontable instance.
121
+ * @param {function(): void} undoneCallback The callback to be called after the action is undone.
122
+ */
123
+ undo(hot, undoneCallback) {
124
+ const settings = hot.getSettings();
125
+
126
+ // Changing by the reference as `updateSettings` doesn't work the best.
127
+ settings.fixedColumnsStart = this.fixedColumnsStart;
128
+ const ascendingIndexes = this.indexes.slice(0).sort();
129
+ const sortByIndexes = (elem, j, arr) => arr[this.indexes.indexOf(ascendingIndexes[j])];
130
+ const removedDataLength = this.data.length;
131
+ const sortedData = [];
132
+ for (let rowIndex = 0; rowIndex < removedDataLength; rowIndex++) {
133
+ sortedData.push(arrayMap(this.data[rowIndex], sortByIndexes));
134
+ }
135
+ const sortedHeaders = arrayMap(this.headers, sortByIndexes);
136
+ const changes = [];
137
+ hot.alter('insert_col_start', this.indexes[0], this.indexes.length, 'UndoRedo.undo');
138
+ arrayEach(hot.getSourceDataArray(), (rowData, rowIndex) => {
139
+ arrayEach(ascendingIndexes, (changedIndex, contiquesIndex) => {
140
+ rowData[changedIndex] = sortedData[rowIndex][contiquesIndex];
141
+ changes.push([rowIndex, changedIndex, rowData[changedIndex]]);
142
+ });
143
+ });
144
+ hot.setSourceDataAtCell(changes, undefined, undefined, 'UndoRedo.undo');
145
+ if (typeof this.headers !== 'undefined') {
146
+ arrayEach(sortedHeaders, (headerData, columnIndex) => {
147
+ hot.getSettings().colHeaders[ascendingIndexes[columnIndex]] = headerData;
148
+ });
149
+ }
150
+ this.removedCellMetas.forEach(_ref2 => {
151
+ let [rowIndex, columnIndex, cellMeta] = _ref2;
152
+ hot.setCellMetaObject(rowIndex, columnIndex, cellMeta);
153
+ });
154
+ hot.batchExecution(() => {
155
+ // Restore row sequence in a case when all columns are removed. the original
156
+ // row sequence is lost in that case.
157
+ hot.rowIndexMapper.setIndexesSequence(this.rowPositions);
158
+ hot.columnIndexMapper.setIndexesSequence(this.columnPositions);
159
+ }, true);
160
+ hot.addHookOnce('afterViewRender', undoneCallback);
161
+ hot.render();
162
+ }
163
+
164
+ /**
165
+ * @param {Core} hot The Handsontable instance.
166
+ * @param {function(): void} redoneCallback The callback to be called after the action is redone.
167
+ */
168
+ redo(hot, redoneCallback) {
169
+ hot.addHookOnce('afterRemoveCol', redoneCallback);
170
+ hot.alter('remove_col', this.index, this.amount, 'UndoRedo.redo');
171
+ }
172
+ }