handsontable 0.0.0-next-deccb4d-20240618 → 0.0.0-next-fcd6191-20240619

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.

package/helpers/mixed.js CHANGED
@@ -134,7 +134,7 @@ const domMessages = {
134
134
  function _injectProductInfo(key, element) {
135
135
  const hasValidType = !isEmpty(key);
136
136
  const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
137
- const hotVersion = "0.0.0-next-deccb4d-20240618";
137
+ const hotVersion = "0.0.0-next-fcd6191-20240619";
138
138
  let keyValidityDate;
139
139
  let consoleMessageState = 'invalid';
140
140
  let domMessageState = 'invalid';
package/helpers/mixed.mjs CHANGED
@@ -124,7 +124,7 @@ const domMessages = {
124
124
  export function _injectProductInfo(key, element) {
125
125
  const hasValidType = !isEmpty(key);
126
126
  const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
127
- const hotVersion = "0.0.0-next-deccb4d-20240618";
127
+ const hotVersion = "0.0.0-next-fcd6191-20240619";
128
128
  let keyValidityDate;
129
129
  let consoleMessageState = 'invalid';
130
130
  let domMessageState = 'invalid';
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/handsontable/handsontable/issues"
11
11
  },
12
12
  "author": "Handsoncode <hello@handsontable.com>",
13
- "version": "0.0.0-next-deccb4d-20240618",
13
+ "version": "0.0.0-next-fcd6191-20240619",
14
14
  "main": "index",
15
15
  "module": "index.mjs",
16
16
  "jsnext:main": "index.mjs",
@@ -199,6 +199,7 @@ class ColumnSorting extends _base.BasePlugin {
199
199
  if (this.indexesSequenceCache !== null) {
200
200
  this.hot.rowIndexMapper.setIndexesSequence(this.indexesSequenceCache.getValues());
201
201
  this.hot.rowIndexMapper.unregisterMap(this.pluginKey);
202
+ this.indexesSequenceCache = null;
202
203
  }
203
204
  }, true);
204
205
  this.hot.columnIndexMapper.unregisterMap(`${this.pluginKey}.columnMeta`);
@@ -586,8 +587,8 @@ class ColumnSorting extends _base.BasePlugin {
586
587
  * @private
587
588
  */
588
589
  sortByPresetSortStates(sortConfigs) {
590
+ this.hot.rowIndexMapper.setIndexesSequence(this.indexesSequenceCache.getValues());
589
591
  if (sortConfigs.length === 0) {
590
- this.hot.rowIndexMapper.setIndexesSequence(this.indexesSequenceCache.getValues());
591
592
  return;
592
593
  }
593
594
  const indexesWithData = [];
@@ -195,6 +195,7 @@ export class ColumnSorting extends BasePlugin {
195
195
  if (this.indexesSequenceCache !== null) {
196
196
  this.hot.rowIndexMapper.setIndexesSequence(this.indexesSequenceCache.getValues());
197
197
  this.hot.rowIndexMapper.unregisterMap(this.pluginKey);
198
+ this.indexesSequenceCache = null;
198
199
  }
199
200
  }, true);
200
201
  this.hot.columnIndexMapper.unregisterMap(`${this.pluginKey}.columnMeta`);
@@ -582,8 +583,8 @@ export class ColumnSorting extends BasePlugin {
582
583
  * @private
583
584
  */
584
585
  sortByPresetSortStates(sortConfigs) {
586
+ this.hot.rowIndexMapper.setIndexesSequence(this.indexesSequenceCache.getValues());
585
587
  if (sortConfigs.length === 0) {
586
- this.hot.rowIndexMapper.setIndexesSequence(this.indexesSequenceCache.getValues());
587
588
  return;
588
589
  }
589
590
  const indexesWithData = [];
@@ -104,6 +104,7 @@ class MultiColumnSorting extends _columnSorting.ColumnSorting {
104
104
  enablePlugin() {
105
105
  if (!this.enabled && this.hot.getSettings()[this.pluginKey] && this.hot.getSettings()[CONFLICTED_PLUGIN_KEY]) {
106
106
  (0, _utils2.warnAboutPluginsConflict)();
107
+ this.hot.getPlugin(CONFLICTED_PLUGIN_KEY).disablePlugin();
107
108
  }
108
109
  super.enablePlugin();
109
110
  }
@@ -101,6 +101,7 @@ export class MultiColumnSorting extends ColumnSorting {
101
101
  enablePlugin() {
102
102
  if (!this.enabled && this.hot.getSettings()[this.pluginKey] && this.hot.getSettings()[CONFLICTED_PLUGIN_KEY]) {
103
103
  warnAboutPluginsConflict();
104
+ this.hot.getPlugin(CONFLICTED_PLUGIN_KEY).disablePlugin();
104
105
  }
105
106
  super.enablePlugin();
106
107
  }
@@ -9,5 +9,5 @@ var _templateLiteralTag = require("../../helpers/templateLiteralTag");
9
9
  */
10
10
  function warnAboutPluginsConflict() {
11
11
  (0, _console.warn)((0, _templateLiteralTag.toSingleLine)`Plugins \`columnSorting\` and \`multiColumnSorting\` should not be enabled simultaneously.
12
- Only \`multiColumnSorting\` will work.`);
12
+ Only \`multiColumnSorting\` will work. The \`columnSorting\` plugin will be disabled.`);
13
13
  }
@@ -5,5 +5,5 @@ import { toSingleLine } from "../../helpers/templateLiteralTag.mjs";
5
5
  */
6
6
  export function warnAboutPluginsConflict() {
7
7
  warn(toSingleLine`Plugins \`columnSorting\` and \`multiColumnSorting\` should not be enabled simultaneously.
8
- Only \`multiColumnSorting\` will work.`);
8
+ Only \`multiColumnSorting\` will work. The \`columnSorting\` plugin will be disabled.`);
9
9
  }
@@ -151,6 +151,12 @@ function UndoRedo(instance) {
151
151
  }
152
152
  plugin.done(() => new UndoRedo.UnmergeCellsAction(instance, cellRange));
153
153
  });
154
+ instance.addHook('beforeColumnSort', (currentSortConfig, destinationSortConfigs, sortPossible) => {
155
+ if (!sortPossible) {
156
+ return;
157
+ }
158
+ plugin.done(() => new UndoRedo.ColumnSortAction(currentSortConfig, destinationSortConfigs));
159
+ });
154
160
 
155
161
  // TODO: Why this callback is needed? One test doesn't pass after calling method right after plugin creation (outside the callback).
156
162
  instance.addHook('afterInit', () => {
@@ -792,6 +798,37 @@ UndoRedo.ColumnMoveAction.prototype.redo = function (instance, redoneCallback) {
792
798
  instance.selectColumns(this.finalColumnIndex, this.finalColumnIndex + this.columns.length - 1);
793
799
  };
794
800
 
801
+ /**
802
+ * ColumnSort action.
803
+ *
804
+ * @private
805
+ * @param {Array} currentSortState The current sort state.
806
+ * @param {Array} newSortState The new sort state.
807
+ */
808
+ UndoRedo.ColumnSortAction = function (currentSortState, newSortState) {
809
+ this.previousSortState = currentSortState;
810
+ this.nextSortState = newSortState;
811
+ };
812
+ (0, _object.inherit)(UndoRedo.ColumnSortAction, UndoRedo.Action);
813
+ UndoRedo.ColumnSortAction.prototype.undo = function (instance, undoneCallback) {
814
+ const sortPlugin = instance.getPlugin('columnSorting');
815
+ const multiSortPlugin = instance.getPlugin('multiColumnSorting');
816
+ const enabledSortPlugin = multiSortPlugin.isEnabled() ? multiSortPlugin : sortPlugin;
817
+ if (this.previousSortState.length) {
818
+ enabledSortPlugin.sort(this.previousSortState);
819
+ } else {
820
+ enabledSortPlugin.clearSort();
821
+ }
822
+ undoneCallback();
823
+ };
824
+ UndoRedo.ColumnSortAction.prototype.redo = function (instance, redoneCallback) {
825
+ const sortPlugin = instance.getPlugin('columnSorting');
826
+ const multiSortPlugin = instance.getPlugin('multiColumnSorting');
827
+ const enabledSortPlugin = multiSortPlugin.isEnabled() ? multiSortPlugin : sortPlugin;
828
+ enabledSortPlugin.sort(this.nextSortState);
829
+ redoneCallback();
830
+ };
831
+
795
832
  /**
796
833
  * Enabling and disabling plugin and attaching its to an instance.
797
834
  *
@@ -147,6 +147,12 @@ function UndoRedo(instance) {
147
147
  }
148
148
  plugin.done(() => new UndoRedo.UnmergeCellsAction(instance, cellRange));
149
149
  });
150
+ instance.addHook('beforeColumnSort', (currentSortConfig, destinationSortConfigs, sortPossible) => {
151
+ if (!sortPossible) {
152
+ return;
153
+ }
154
+ plugin.done(() => new UndoRedo.ColumnSortAction(currentSortConfig, destinationSortConfigs));
155
+ });
150
156
 
151
157
  // TODO: Why this callback is needed? One test doesn't pass after calling method right after plugin creation (outside the callback).
152
158
  instance.addHook('afterInit', () => {
@@ -788,6 +794,37 @@ UndoRedo.ColumnMoveAction.prototype.redo = function (instance, redoneCallback) {
788
794
  instance.selectColumns(this.finalColumnIndex, this.finalColumnIndex + this.columns.length - 1);
789
795
  };
790
796
 
797
+ /**
798
+ * ColumnSort action.
799
+ *
800
+ * @private
801
+ * @param {Array} currentSortState The current sort state.
802
+ * @param {Array} newSortState The new sort state.
803
+ */
804
+ UndoRedo.ColumnSortAction = function (currentSortState, newSortState) {
805
+ this.previousSortState = currentSortState;
806
+ this.nextSortState = newSortState;
807
+ };
808
+ inherit(UndoRedo.ColumnSortAction, UndoRedo.Action);
809
+ UndoRedo.ColumnSortAction.prototype.undo = function (instance, undoneCallback) {
810
+ const sortPlugin = instance.getPlugin('columnSorting');
811
+ const multiSortPlugin = instance.getPlugin('multiColumnSorting');
812
+ const enabledSortPlugin = multiSortPlugin.isEnabled() ? multiSortPlugin : sortPlugin;
813
+ if (this.previousSortState.length) {
814
+ enabledSortPlugin.sort(this.previousSortState);
815
+ } else {
816
+ enabledSortPlugin.clearSort();
817
+ }
818
+ undoneCallback();
819
+ };
820
+ UndoRedo.ColumnSortAction.prototype.redo = function (instance, redoneCallback) {
821
+ const sortPlugin = instance.getPlugin('columnSorting');
822
+ const multiSortPlugin = instance.getPlugin('multiColumnSorting');
823
+ const enabledSortPlugin = multiSortPlugin.isEnabled() ? multiSortPlugin : sortPlugin;
824
+ enabledSortPlugin.sort(this.nextSortState);
825
+ redoneCallback();
826
+ };
827
+
791
828
  /**
792
829
  * Enabling and disabling plugin and attaching its to an instance.
793
830
  *