handsontable 0.0.0-next-442b0cf-20241209 → 0.0.0-next-aa821c7-20241209

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 (61) hide show
  1. package/base.js +2 -2
  2. package/base.mjs +2 -2
  3. package/core.js +1 -7
  4. package/core.mjs +1 -7
  5. package/dataMap/metaManager/metaSchema.js +2 -3
  6. package/dataMap/metaManager/metaSchema.mjs +2 -3
  7. package/dist/handsontable.css +12 -2
  8. package/dist/handsontable.full.css +12 -2
  9. package/dist/handsontable.full.js +1438 -864
  10. package/dist/handsontable.full.min.css +3 -3
  11. package/dist/handsontable.full.min.js +9 -7
  12. package/dist/handsontable.js +1437 -863
  13. package/dist/handsontable.min.css +3 -3
  14. package/dist/handsontable.min.js +35 -33
  15. package/helpers/mixed.js +1 -1
  16. package/helpers/mixed.mjs +1 -1
  17. package/package.json +1 -1
  18. package/plugins/base/base.js +0 -7
  19. package/plugins/base/base.mjs +0 -7
  20. package/plugins/undoRedo/actions/_base.js +19 -0
  21. package/plugins/undoRedo/actions/_base.mjs +15 -0
  22. package/plugins/undoRedo/actions/cellAlignment.js +85 -0
  23. package/plugins/undoRedo/actions/cellAlignment.mjs +81 -0
  24. package/plugins/undoRedo/actions/columnMove.js +84 -0
  25. package/plugins/undoRedo/actions/columnMove.mjs +80 -0
  26. package/plugins/undoRedo/actions/columnSort.js +73 -0
  27. package/plugins/undoRedo/actions/columnSort.mjs +69 -0
  28. package/plugins/undoRedo/actions/createColumn.js +60 -0
  29. package/plugins/undoRedo/actions/createColumn.mjs +56 -0
  30. package/plugins/undoRedo/actions/createRow.js +65 -0
  31. package/plugins/undoRedo/actions/createRow.mjs +61 -0
  32. package/plugins/undoRedo/actions/dataChange.js +114 -0
  33. package/plugins/undoRedo/actions/dataChange.mjs +110 -0
  34. package/plugins/undoRedo/actions/filters.js +68 -0
  35. package/plugins/undoRedo/actions/filters.mjs +64 -0
  36. package/plugins/undoRedo/actions/index.js +27 -0
  37. package/plugins/undoRedo/actions/index.mjs +23 -0
  38. package/plugins/undoRedo/actions/mergeCells.js +63 -0
  39. package/plugins/undoRedo/actions/mergeCells.mjs +59 -0
  40. package/plugins/undoRedo/actions/removeColumn.js +176 -0
  41. package/plugins/undoRedo/actions/removeColumn.mjs +172 -0
  42. package/plugins/undoRedo/actions/removeRow.js +119 -0
  43. package/plugins/undoRedo/actions/removeRow.mjs +115 -0
  44. package/plugins/undoRedo/actions/rowMove.js +84 -0
  45. package/plugins/undoRedo/actions/rowMove.mjs +80 -0
  46. package/plugins/undoRedo/actions/unmergeCells.js +56 -0
  47. package/plugins/undoRedo/actions/unmergeCells.mjs +52 -0
  48. package/plugins/undoRedo/index.js +3 -4
  49. package/plugins/undoRedo/index.mjs +1 -2
  50. package/plugins/undoRedo/undoRedo.js +277 -879
  51. package/plugins/undoRedo/undoRedo.mjs +277 -880
  52. package/plugins/undoRedo/utils.js +37 -0
  53. package/plugins/undoRedo/utils.mjs +33 -0
  54. package/styles/handsontable.css +9 -2
  55. package/styles/handsontable.min.css +3 -3
  56. package/styles/ht-theme-horizon.css +2 -2
  57. package/styles/ht-theme-horizon.min.css +2 -2
  58. package/styles/ht-theme-main.css +2 -2
  59. package/styles/ht-theme-main.min.css +2 -2
  60. package/utils/ghostTable.js +1 -5
  61. package/utils/ghostTable.mjs +1 -5
@@ -0,0 +1,56 @@
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 column creation.
8
+ *
9
+ * @class CreateColumnAction
10
+ * @private
11
+ */
12
+ export class CreateColumnAction extends BaseAction {
13
+ constructor(_ref) {
14
+ let {
15
+ index,
16
+ amount
17
+ } = _ref;
18
+ super();
19
+ /**
20
+ * @param {number} index The visual column index.
21
+ */
22
+ _defineProperty(this, "index", void 0);
23
+ /**
24
+ * @param {number} amount The number of created columns.
25
+ */
26
+ _defineProperty(this, "amount", void 0);
27
+ this.index = index;
28
+ this.amount = amount;
29
+ }
30
+ static startRegisteringEvents(hot, undoRedoPlugin) {
31
+ hot.addHook('afterCreateCol', (index, amount, source) => {
32
+ undoRedoPlugin.done(() => new CreateColumnAction({
33
+ index,
34
+ amount
35
+ }), source);
36
+ });
37
+ }
38
+
39
+ /**
40
+ * @param {Core} hot The Handsontable instance.
41
+ * @param {function(): void} undoneCallback The callback to be called after the action is undone.
42
+ */
43
+ undo(hot, undoneCallback) {
44
+ hot.addHookOnce('afterRemoveCol', undoneCallback);
45
+ hot.alter('remove_col', this.index, this.amount, 'UndoRedo.undo');
46
+ }
47
+
48
+ /**
49
+ * @param {Core} hot The Handsontable instance.
50
+ * @param {function(): void} redoneCallback The callback to be called after the action is redone.
51
+ */
52
+ redo(hot, redoneCallback) {
53
+ hot.addHookOnce('afterCreateCol', redoneCallback);
54
+ hot.alter('insert_col_start', this.index, this.amount, 'UndoRedo.redo');
55
+ }
56
+ }
@@ -0,0 +1,65 @@
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 row creation.
11
+ *
12
+ * @class CreateRowAction
13
+ * @private
14
+ */
15
+ class CreateRowAction extends _base.BaseAction {
16
+ constructor(_ref) {
17
+ let {
18
+ index,
19
+ amount
20
+ } = _ref;
21
+ super();
22
+ /**
23
+ * @param {number} index The visual row index.
24
+ */
25
+ _defineProperty(this, "index", void 0);
26
+ /**
27
+ * @param {number} amount The number of created rows.
28
+ */
29
+ _defineProperty(this, "amount", void 0);
30
+ this.index = index;
31
+ this.amount = amount;
32
+ }
33
+ static startRegisteringEvents(hot, undoRedoPlugin) {
34
+ hot.addHook('afterCreateRow', (index, amount, source) => {
35
+ undoRedoPlugin.done(() => new CreateRowAction({
36
+ index,
37
+ amount
38
+ }), source);
39
+ });
40
+ }
41
+
42
+ /**
43
+ * @param {Core} hot The Handsontable instance.
44
+ * @param {function(): void} undoneCallback The callback to be called after the action is undone.
45
+ */
46
+ undo(hot, undoneCallback) {
47
+ const rowCount = hot.countRows();
48
+ const minSpareRows = hot.getSettings().minSpareRows;
49
+ if (this.index >= rowCount && this.index - minSpareRows < rowCount) {
50
+ this.index -= minSpareRows; // work around the situation where the needed row was removed due to an 'undo' of a made change
51
+ }
52
+ hot.addHookOnce('afterRemoveRow', undoneCallback);
53
+ hot.alter('remove_row', this.index, this.amount, 'UndoRedo.undo');
54
+ }
55
+
56
+ /**
57
+ * @param {Core} hot The Handsontable instance.
58
+ * @param {function(): void} redoneCallback The callback to be called after the action is redone.
59
+ */
60
+ redo(hot, redoneCallback) {
61
+ hot.addHookOnce('afterCreateRow', redoneCallback);
62
+ hot.alter('insert_row_above', this.index, this.amount, 'UndoRedo.redo');
63
+ }
64
+ }
65
+ exports.CreateRowAction = CreateRowAction;
@@ -0,0 +1,61 @@
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 row creation.
8
+ *
9
+ * @class CreateRowAction
10
+ * @private
11
+ */
12
+ export class CreateRowAction extends BaseAction {
13
+ constructor(_ref) {
14
+ let {
15
+ index,
16
+ amount
17
+ } = _ref;
18
+ super();
19
+ /**
20
+ * @param {number} index The visual row index.
21
+ */
22
+ _defineProperty(this, "index", void 0);
23
+ /**
24
+ * @param {number} amount The number of created rows.
25
+ */
26
+ _defineProperty(this, "amount", void 0);
27
+ this.index = index;
28
+ this.amount = amount;
29
+ }
30
+ static startRegisteringEvents(hot, undoRedoPlugin) {
31
+ hot.addHook('afterCreateRow', (index, amount, source) => {
32
+ undoRedoPlugin.done(() => new CreateRowAction({
33
+ index,
34
+ amount
35
+ }), source);
36
+ });
37
+ }
38
+
39
+ /**
40
+ * @param {Core} hot The Handsontable instance.
41
+ * @param {function(): void} undoneCallback The callback to be called after the action is undone.
42
+ */
43
+ undo(hot, undoneCallback) {
44
+ const rowCount = hot.countRows();
45
+ const minSpareRows = hot.getSettings().minSpareRows;
46
+ if (this.index >= rowCount && this.index - minSpareRows < rowCount) {
47
+ this.index -= minSpareRows; // work around the situation where the needed row was removed due to an 'undo' of a made change
48
+ }
49
+ hot.addHookOnce('afterRemoveRow', undoneCallback);
50
+ hot.alter('remove_row', this.index, this.amount, 'UndoRedo.undo');
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
+ hot.addHookOnce('afterCreateRow', redoneCallback);
59
+ hot.alter('insert_row_above', this.index, this.amount, 'UndoRedo.redo');
60
+ }
61
+ }
@@ -0,0 +1,114 @@
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.find.js");
8
+ require("core-js/modules/esnext.iterator.reduce.js");
9
+ var _base = require("./_base");
10
+ var _object = require("../../../helpers/object");
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 data changes.
17
+ *
18
+ * @class DataChangeAction
19
+ * @private
20
+ */
21
+ class DataChangeAction extends _base.BaseAction {
22
+ constructor(_ref) {
23
+ let {
24
+ changes,
25
+ selected
26
+ } = _ref;
27
+ super();
28
+ /**
29
+ * @param {Array} changes 2D array containing information about each of the edited cells.
30
+ */
31
+ _defineProperty(this, "changes", void 0);
32
+ /**
33
+ * @param {number[]} selected The cell selection.
34
+ */
35
+ _defineProperty(this, "selected", void 0);
36
+ this.changes = changes;
37
+ this.selected = selected;
38
+ }
39
+ static startRegisteringEvents(hot, undoRedoPlugin) {
40
+ hot.addHook('afterChange', function (changes, source) {
41
+ const changesLen = changes && changes.length;
42
+ if (!changesLen) {
43
+ return;
44
+ }
45
+ const hasDifferences = changes.find(change => {
46
+ const [,, oldValue, newValue] = change;
47
+ return oldValue !== newValue;
48
+ });
49
+ if (!hasDifferences) {
50
+ return;
51
+ }
52
+ const wrappedAction = () => {
53
+ const clonedChanges = changes.reduce((arr, change) => {
54
+ arr.push([...change]);
55
+ return arr;
56
+ }, []);
57
+ (0, _array.arrayEach)(clonedChanges, change => {
58
+ change[1] = hot.propToCol(change[1]);
59
+ });
60
+ const selected = changesLen > 1 ? this.getSelected() : [[clonedChanges[0][0], clonedChanges[0][1]]];
61
+ return new DataChangeAction({
62
+ changes: clonedChanges,
63
+ selected
64
+ });
65
+ };
66
+ undoRedoPlugin.done(wrappedAction, source);
67
+ });
68
+ }
69
+
70
+ /**
71
+ * @param {Core} hot The Handsontable instance.
72
+ * @param {function(): void} undoneCallback The callback to be called after the action is undone.
73
+ */
74
+ undo(hot, undoneCallback) {
75
+ const data = (0, _object.deepClone)(this.changes);
76
+ const emptyRowsAtTheEnd = hot.countEmptyRows(true);
77
+ const emptyColsAtTheEnd = hot.countEmptyCols(true);
78
+ for (let i = 0, len = data.length; i < len; i++) {
79
+ data[i].splice(3, 1);
80
+ }
81
+ hot.addHookOnce('afterChange', undoneCallback);
82
+ hot.setDataAtCell(data, null, null, 'UndoRedo.undo');
83
+ for (let i = 0, len = data.length; i < len; i++) {
84
+ const [row, column] = data[i];
85
+ if (hot.getSettings().minSpareRows && row + 1 + hot.getSettings().minSpareRows === hot.countRows() && emptyRowsAtTheEnd === hot.getSettings().minSpareRows) {
86
+ hot.alter('remove_row', parseInt(row + 1, 10), hot.getSettings().minSpareRows);
87
+ hot.getPlugin('undoRedo').doneActions.pop();
88
+ }
89
+ if (hot.getSettings().minSpareCols && column + 1 + hot.getSettings().minSpareCols === hot.countCols() && emptyColsAtTheEnd === hot.getSettings().minSpareCols) {
90
+ hot.alter('remove_col', parseInt(column + 1, 10), hot.getSettings().minSpareCols);
91
+ hot.getPlugin('undoRedo').doneActions.pop();
92
+ }
93
+ }
94
+ hot.scrollToFocusedCell();
95
+ hot.selectCells(this.selected, false, false);
96
+ }
97
+
98
+ /**
99
+ * @param {Core} hot The Handsontable instance.
100
+ * @param {function(): void} redoneCallback The callback to be called after the action is redone.
101
+ */
102
+ redo(hot, redoneCallback) {
103
+ const data = (0, _object.deepClone)(this.changes);
104
+ for (let i = 0, len = data.length; i < len; i++) {
105
+ data[i].splice(2, 1);
106
+ }
107
+ hot.addHookOnce('afterChange', redoneCallback);
108
+ hot.setDataAtCell(data, null, null, 'UndoRedo.redo');
109
+ if (this.selected) {
110
+ hot.selectCells(this.selected, false, false);
111
+ }
112
+ }
113
+ }
114
+ exports.DataChangeAction = DataChangeAction;
@@ -0,0 +1,110 @@
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.find.js";
5
+ import "core-js/modules/esnext.iterator.reduce.js";
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
+ import { BaseAction } from "./_base.mjs";
10
+ import { deepClone } from "../../../helpers/object.mjs";
11
+ import { arrayEach } from "../../../helpers/array.mjs";
12
+ /**
13
+ * Action that tracks data changes.
14
+ *
15
+ * @class DataChangeAction
16
+ * @private
17
+ */
18
+ export class DataChangeAction extends BaseAction {
19
+ constructor(_ref) {
20
+ let {
21
+ changes,
22
+ selected
23
+ } = _ref;
24
+ super();
25
+ /**
26
+ * @param {Array} changes 2D array containing information about each of the edited cells.
27
+ */
28
+ _defineProperty(this, "changes", void 0);
29
+ /**
30
+ * @param {number[]} selected The cell selection.
31
+ */
32
+ _defineProperty(this, "selected", void 0);
33
+ this.changes = changes;
34
+ this.selected = selected;
35
+ }
36
+ static startRegisteringEvents(hot, undoRedoPlugin) {
37
+ hot.addHook('afterChange', function (changes, source) {
38
+ const changesLen = changes && changes.length;
39
+ if (!changesLen) {
40
+ return;
41
+ }
42
+ const hasDifferences = changes.find(change => {
43
+ const [,, oldValue, newValue] = change;
44
+ return oldValue !== newValue;
45
+ });
46
+ if (!hasDifferences) {
47
+ return;
48
+ }
49
+ const wrappedAction = () => {
50
+ const clonedChanges = changes.reduce((arr, change) => {
51
+ arr.push([...change]);
52
+ return arr;
53
+ }, []);
54
+ arrayEach(clonedChanges, change => {
55
+ change[1] = hot.propToCol(change[1]);
56
+ });
57
+ const selected = changesLen > 1 ? this.getSelected() : [[clonedChanges[0][0], clonedChanges[0][1]]];
58
+ return new DataChangeAction({
59
+ changes: clonedChanges,
60
+ selected
61
+ });
62
+ };
63
+ undoRedoPlugin.done(wrappedAction, source);
64
+ });
65
+ }
66
+
67
+ /**
68
+ * @param {Core} hot The Handsontable instance.
69
+ * @param {function(): void} undoneCallback The callback to be called after the action is undone.
70
+ */
71
+ undo(hot, undoneCallback) {
72
+ const data = deepClone(this.changes);
73
+ const emptyRowsAtTheEnd = hot.countEmptyRows(true);
74
+ const emptyColsAtTheEnd = hot.countEmptyCols(true);
75
+ for (let i = 0, len = data.length; i < len; i++) {
76
+ data[i].splice(3, 1);
77
+ }
78
+ hot.addHookOnce('afterChange', undoneCallback);
79
+ hot.setDataAtCell(data, null, null, 'UndoRedo.undo');
80
+ for (let i = 0, len = data.length; i < len; i++) {
81
+ const [row, column] = data[i];
82
+ if (hot.getSettings().minSpareRows && row + 1 + hot.getSettings().minSpareRows === hot.countRows() && emptyRowsAtTheEnd === hot.getSettings().minSpareRows) {
83
+ hot.alter('remove_row', parseInt(row + 1, 10), hot.getSettings().minSpareRows);
84
+ hot.getPlugin('undoRedo').doneActions.pop();
85
+ }
86
+ if (hot.getSettings().minSpareCols && column + 1 + hot.getSettings().minSpareCols === hot.countCols() && emptyColsAtTheEnd === hot.getSettings().minSpareCols) {
87
+ hot.alter('remove_col', parseInt(column + 1, 10), hot.getSettings().minSpareCols);
88
+ hot.getPlugin('undoRedo').doneActions.pop();
89
+ }
90
+ }
91
+ hot.scrollToFocusedCell();
92
+ hot.selectCells(this.selected, false, false);
93
+ }
94
+
95
+ /**
96
+ * @param {Core} hot The Handsontable instance.
97
+ * @param {function(): void} redoneCallback The callback to be called after the action is redone.
98
+ */
99
+ redo(hot, redoneCallback) {
100
+ const data = deepClone(this.changes);
101
+ for (let i = 0, len = data.length; i < len; i++) {
102
+ data[i].splice(2, 1);
103
+ }
104
+ hot.addHookOnce('afterChange', redoneCallback);
105
+ hot.setDataAtCell(data, null, null, 'UndoRedo.redo');
106
+ if (this.selected) {
107
+ hot.selectCells(this.selected, false, false);
108
+ }
109
+ }
110
+ }
@@ -0,0 +1,68 @@
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
+ if (this.previousConditionsStack) {
52
+ filters.conditionCollection.importAllConditions(this.previousConditionsStack);
53
+ }
54
+ filters.filter();
55
+ }
56
+
57
+ /**
58
+ * @param {Core} hot The Handsontable instance.
59
+ * @param {function(): void} redoneCallback The callback to be called after the action is redone.
60
+ */
61
+ redo(hot, redoneCallback) {
62
+ const filters = hot.getPlugin('filters');
63
+ hot.addHookOnce('afterViewRender', redoneCallback);
64
+ filters.conditionCollection.importAllConditions(this.conditionsStack);
65
+ filters.filter();
66
+ }
67
+ }
68
+ exports.FiltersAction = FiltersAction;
@@ -0,0 +1,64 @@
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
+ if (this.previousConditionsStack) {
49
+ filters.conditionCollection.importAllConditions(this.previousConditionsStack);
50
+ }
51
+ filters.filter();
52
+ }
53
+
54
+ /**
55
+ * @param {Core} hot The Handsontable instance.
56
+ * @param {function(): void} redoneCallback The callback to be called after the action is redone.
57
+ */
58
+ redo(hot, redoneCallback) {
59
+ const filters = hot.getPlugin('filters');
60
+ hot.addHookOnce('afterViewRender', redoneCallback);
61
+ filters.conditionCollection.importAllConditions(this.conditionsStack);
62
+ filters.filter();
63
+ }
64
+ }
@@ -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;