handsontable 0.0.0-next-88f4ae4-20250313 → 0.0.0-next-a1cc3b8-20250314

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 (41) hide show
  1. package/base.js +2 -2
  2. package/base.mjs +2 -2
  3. package/core.d.ts +1 -1
  4. package/core.js +7 -1
  5. package/core.mjs +7 -1
  6. package/dataMap/metaManager/index.js +8 -9
  7. package/dataMap/metaManager/index.mjs +8 -9
  8. package/dataMap/metaManager/mods/dynamicCellMeta.js +4 -1
  9. package/dataMap/metaManager/mods/dynamicCellMeta.mjs +4 -1
  10. package/dist/handsontable.css +2 -2
  11. package/dist/handsontable.full.css +2 -2
  12. package/dist/handsontable.full.js +143 -108
  13. package/dist/handsontable.full.min.css +2 -2
  14. package/dist/handsontable.full.min.js +12 -12
  15. package/dist/handsontable.js +143 -108
  16. package/dist/handsontable.min.css +2 -2
  17. package/dist/handsontable.min.js +13 -13
  18. package/editors/textEditor/textEditor.js +1 -1
  19. package/editors/textEditor/textEditor.mjs +2 -2
  20. package/helpers/dom/element.js +2 -2
  21. package/helpers/dom/element.mjs +1 -1
  22. package/helpers/mixed.js +1 -1
  23. package/helpers/mixed.mjs +1 -1
  24. package/package.json +1 -1
  25. package/plugins/autoColumnSize/autoColumnSize.js +37 -16
  26. package/plugins/autoColumnSize/autoColumnSize.mjs +37 -16
  27. package/plugins/autoRowSize/autoRowSize.js +11 -0
  28. package/plugins/autoRowSize/autoRowSize.mjs +11 -0
  29. package/plugins/copyPaste/copyPaste.js +6 -12
  30. package/plugins/copyPaste/copyPaste.mjs +7 -13
  31. package/plugins/formulas/formulas.d.ts +1 -1
  32. package/plugins/formulas/formulas.js +57 -60
  33. package/plugins/formulas/formulas.mjs +59 -62
  34. package/plugins/formulas/indexSyncer/axisSyncer.js +5 -1
  35. package/plugins/formulas/indexSyncer/axisSyncer.mjs +5 -1
  36. package/styles/handsontable.css +2 -2
  37. package/styles/handsontable.min.css +2 -2
  38. package/styles/ht-theme-horizon.css +2 -2
  39. package/styles/ht-theme-horizon.min.css +2 -2
  40. package/styles/ht-theme-main.css +2 -2
  41. package/styles/ht-theme-main.min.css +2 -2
@@ -13,7 +13,6 @@ require("core-js/modules/es.set.symmetric-difference.v2.js");
13
13
  require("core-js/modules/es.set.union.v2.js");
14
14
  require("core-js/modules/esnext.iterator.constructor.js");
15
15
  require("core-js/modules/esnext.iterator.every.js");
16
- require("core-js/modules/esnext.iterator.find.js");
17
16
  require("core-js/modules/esnext.iterator.for-each.js");
18
17
  require("core-js/modules/esnext.iterator.map.js");
19
18
  var _base = require("../base");
@@ -74,13 +73,9 @@ class Formulas extends _base.BasePlugin {
74
73
  super(...arguments);
75
74
  _this = this;
76
75
  /**
77
- * The hook allows to translate the formula value to calculated value before it goes to the
78
- * validator function.
76
+ * Update sheetName and sheetId properties.
79
77
  *
80
- * @param {*} value The cell value to validate.
81
- * @param {number} visualRow The visual row index.
82
- * @param {number|string} prop The visual column index or property name of the column.
83
- * @returns {*} Returns value to validate.
78
+ * @param {string} [sheetName] The new sheet name.
84
79
  */
85
80
  _classPrivateMethodInitSpec(this, _Formulas_brand);
86
81
  /**
@@ -147,6 +142,12 @@ class Formulas extends _base.BasePlugin {
147
142
  * @type {HyperFormula|null}
148
143
  */
149
144
  _defineProperty(this, "engine", null);
145
+ /**
146
+ * HyperFormula's sheet id.
147
+ *
148
+ * @type {number|null}
149
+ */
150
+ _defineProperty(this, "sheetId", null);
150
151
  /**
151
152
  * HyperFormula's sheet name.
152
153
  *
@@ -181,15 +182,6 @@ class Formulas extends _base.BasePlugin {
181
182
  static get SETTING_KEYS() {
182
183
  return [PLUGIN_KEY, ...SETTING_KEYS];
183
184
  }
184
- /**
185
- * HyperFormula's sheet id.
186
- *
187
- * @type {number|null}
188
- */
189
- get sheetId() {
190
- return this.sheetName === null ? null : this.engine.getSheetId(this.sheetName);
191
- }
192
-
193
185
  /**
194
186
  * Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
195
187
  * hook and if it returns `true` then the {@link Formulas#enablePlugin} method is called.
@@ -220,7 +212,7 @@ class Formulas extends _base.BasePlugin {
220
212
  if (this.sheetName !== null && !this.engine.doesSheetExist(this.sheetName)) {
221
213
  const newSheetName = this.addSheet(this.sheetName, this.hot.getSourceDataArray());
222
214
  if (newSheetName !== false) {
223
- this.sheetName = newSheetName;
215
+ _assertClassBrand(_Formulas_brand, this, _updateSheetNameAndSheetId).call(this, newSheetName);
224
216
  }
225
217
  }
226
218
  this.addHook('beforeLoadData', function () {
@@ -451,7 +443,8 @@ class Formulas extends _base.BasePlugin {
451
443
  if (sheetName && this.engine.doesSheetExist(sheetName)) {
452
444
  this.switchSheet(this.sheetName);
453
445
  } else {
454
- this.sheetName = this.addSheet(sheetName !== null && sheetName !== void 0 ? sheetName : undefined, this.hot.getSourceDataArray());
446
+ const newSheetName = this.addSheet(sheetName !== null && sheetName !== void 0 ? sheetName : undefined, this.hot.getSourceDataArray());
447
+ _assertClassBrand(_Formulas_brand, this, _updateSheetNameAndSheetId).call(this, newSheetName);
455
448
  }
456
449
  }
457
450
  super.updatePlugin(newSettings);
@@ -471,7 +464,6 @@ class Formulas extends _base.BasePlugin {
471
464
  this.engine = null;
472
465
  super.destroy();
473
466
  }
474
-
475
467
  /**
476
468
  * Add a sheet to the shared HyperFormula instance.
477
469
  *
@@ -514,7 +506,7 @@ class Formulas extends _base.BasePlugin {
514
506
  (0, _console.error)(`The sheet named \`${sheetName}\` does not exist, switch aborted.`);
515
507
  return;
516
508
  }
517
- this.sheetName = sheetName;
509
+ _assertClassBrand(_Formulas_brand, this, _updateSheetNameAndSheetId).call(this, sheetName);
518
510
  const serialized = this.engine.getSheetSerialized(this.sheetId);
519
511
  if (serialized.length > 0) {
520
512
  this.hot.loadData(serialized, `${(0, _string.toUpperCaseFirst)(PLUGIN_KEY)}.switchSheet`);
@@ -674,8 +666,22 @@ class Formulas extends _base.BasePlugin {
674
666
  }
675
667
  return this.engine.setCellContents(address, newValue);
676
668
  }
669
+
670
+ /**
671
+ * The hook allows to translate the formula value to calculated value before it goes to the
672
+ * validator function.
673
+ *
674
+ * @param {*} value The cell value to validate.
675
+ * @param {number} visualRow The visual row index.
676
+ * @param {number|string} prop The visual column index or property name of the column.
677
+ * @returns {*} Returns value to validate.
678
+ */
677
679
  }
678
680
  exports.Formulas = Formulas;
681
+ function _updateSheetNameAndSheetId(sheetName) {
682
+ this.sheetName = sheetName;
683
+ this.sheetId = this.engine.getSheetId(this.sheetName);
684
+ }
679
685
  function _onBeforeValidate(value, visualRow, prop) {
680
686
  const visualColumn = this.hot.propToCol(prop);
681
687
  if (this.isFormulaCellType(visualRow, visualColumn)) {
@@ -803,29 +809,33 @@ function _onBeforeLoadData(sourceData, initialLoad) {
803
809
  * Callback to `afterCellMetaReset` hook which is triggered after setting cell meta.
804
810
  */
805
811
  function _onAfterCellMetaReset() {
812
+ if (_classPrivateFieldGet(_hotWasInitializedWithEmptyData, this)) {
813
+ this.switchSheet(this.sheetName);
814
+ return;
815
+ }
806
816
  const sourceDataArray = this.hot.getSourceDataArray();
807
- let valueChanged = false;
808
817
  sourceDataArray.forEach((rowData, rowIndex) => {
809
818
  rowData.forEach((cellValue, columnIndex) => {
810
- const cellMeta = this.hot.getCellMeta(rowIndex, columnIndex);
819
+ const cellMeta = this.hot.getCellMeta(rowIndex, columnIndex, {
820
+ skipMetaExtension: true
821
+ });
811
822
  const dateFormat = cellMeta.dateFormat;
812
823
  if ((0, _utils.isDate)(cellValue, cellMeta.type)) {
813
- valueChanged = true;
814
824
  if ((0, _utils.isDateValid)(cellValue, dateFormat)) {
815
825
  // Rewriting date in HOT format to HF format.
816
826
  sourceDataArray[rowIndex][columnIndex] = (0, _utils.getDateInHfFormat)(cellValue, dateFormat);
817
- } else if (this.isFormulaCellType(rowIndex, columnIndex) === false) {
827
+ } else if (!cellValue.startsWith('=')) {
818
828
  // Escaping value from date parsing using "'" sign (HF feature).
819
829
  sourceDataArray[rowIndex][columnIndex] = `'${cellValue}`;
820
830
  }
821
831
  }
822
832
  });
823
833
  });
824
- if (valueChanged === true) {
825
- _classPrivateFieldSet(_internalOperationPending, this, true);
826
- this.engine.setSheetContent(this.sheetId, sourceDataArray);
827
- _classPrivateFieldSet(_internalOperationPending, this, false);
828
- }
834
+ _classPrivateFieldSet(_internalOperationPending, this, true);
835
+ const dependentCells = this.engine.setSheetContent(this.sheetId, sourceDataArray);
836
+ this.indexSyncer.setupSyncEndpoint(this.engine, this.sheetId);
837
+ this.renderDependentSheets(dependentCells);
838
+ _classPrivateFieldSet(_internalOperationPending, this, false);
829
839
  }
830
840
  /**
831
841
  * `afterLoadData` hook callback.
@@ -839,7 +849,12 @@ function _onAfterLoadData(sourceData, initialLoad) {
839
849
  if (source.includes((0, _string.toUpperCaseFirst)(PLUGIN_KEY))) {
840
850
  return;
841
851
  }
842
- this.sheetName = (0, _register.setupSheet)(this.engine, this.hot.getSettings()[PLUGIN_KEY].sheetName);
852
+ const sheetName = (0, _register.setupSheet)(this.engine, this.hot.getSettings()[PLUGIN_KEY].sheetName);
853
+ _assertClassBrand(_Formulas_brand, this, _updateSheetNameAndSheetId).call(this, sheetName);
854
+ if (source === 'updateSettings') {
855
+ // For performance reasons, the initialization will be done in afterCellMetaReset hook
856
+ return;
857
+ }
843
858
  if (!_classPrivateFieldGet(_hotWasInitializedWithEmptyData, this)) {
844
859
  const sourceDataArray = this.hot.getSourceDataArray();
845
860
  if (this.engine.isItPossibleToReplaceSheetContent(this.sheetId, sourceDataArray)) {
@@ -870,17 +885,10 @@ function _onModifyData(physicalRow, visualColumn, valueHolder, ioMode) {
870
885
  if (visualRow === null || visualColumn === null) {
871
886
  return;
872
887
  }
873
-
874
- // `column` is here as visual index because of inconsistencies related to hook execution in `src/dataMap`.
875
- const isFormulaCellType = this.isFormulaCellType(visualRow, visualColumn);
876
- if (!isFormulaCellType) {
877
- const cellType = this.getCellType(visualRow, visualColumn);
878
- if (cellType !== 'ARRAY') {
879
- if ((0, _utils.isEscapedFormulaExpression)(valueHolder.value)) {
880
- valueHolder.value = (0, _utils.unescapeFormulaExpression)(valueHolder.value);
881
- }
882
- return;
883
- }
888
+ const cellType = this.getCellType(visualRow, visualColumn);
889
+ if (cellType === 'VALUE' || cellType === 'EMPTY') {
890
+ valueHolder.value = (0, _utils.unescapeFormulaExpression)(valueHolder.value);
891
+ return;
884
892
  }
885
893
  const address = {
886
894
  row: this.rowAxisSyncer.getHfIndexFromVisualIndex(visualRow),
@@ -889,21 +897,15 @@ function _onModifyData(physicalRow, visualColumn, valueHolder, ioMode) {
889
897
  };
890
898
  let cellValue = this.engine.getCellValue(address); // Date as an integer (Excel like date).
891
899
 
892
- // TODO: Workaround. We use HOT's `getCellsMeta` method instead of HOT's `getCellMeta` method. Getting cell meta
893
- // using the second method lead to execution of the `cells` method. Using the `getDataAtCell` (which may be useful)
894
- // in a callback to the `cells` method leads to triggering the `modifyData` hook. Thus, the `onModifyData` callback
895
- // is executed once again and it cause creation of an infinite loop.
896
- let cellMeta = this.hot.getCellsMeta().find(singleCellMeta => singleCellMeta.visualRow === visualRow && singleCellMeta.visualCol === visualColumn);
897
- if (cellMeta === undefined) {
898
- cellMeta = {};
899
- }
900
+ const cellMeta = this.hot.getCellMeta(visualRow, visualColumn, {
901
+ skipMetaExtension: true
902
+ });
900
903
  if (cellMeta.type === 'date' && (0, _number.isNumeric)(cellValue)) {
901
904
  cellValue = (0, _utils.getDateFromExcelDate)(cellValue, cellMeta.dateFormat);
902
905
  }
903
906
 
904
907
  // If `cellValue` is an object it is expected to be an error
905
- const value = typeof cellValue === 'object' && cellValue !== null ? cellValue.value : cellValue;
906
- valueHolder.value = value;
908
+ valueHolder.value = typeof cellValue === 'object' && cellValue !== null ? cellValue.value : cellValue;
907
909
  }
908
910
  /**
909
911
  * `modifySourceData` hook callback.
@@ -923,14 +925,9 @@ function _onModifySourceData(row, columnOrProp, valueHolder, ioMode) {
923
925
  if (visualRow === null || visualColumn === null) {
924
926
  return;
925
927
  }
926
-
927
- // `column` is here as visual index because of inconsistencies related to hook execution in `src/dataMap`.
928
- const isFormulaCellType = this.isFormulaCellType(visualRow, visualColumn);
929
- if (!isFormulaCellType) {
930
- const cellType = this.getCellType(visualRow, visualColumn);
931
- if (cellType !== 'ARRAY') {
932
- return;
933
- }
928
+ const cellType = this.getCellType(visualRow, visualColumn);
929
+ if (cellType === 'VALUE' || cellType === 'EMPTY') {
930
+ return;
934
931
  }
935
932
  const dimensions = this.engine.getSheetDimensions(this.engine.getSheetId(this.sheetName));
936
933
 
@@ -1239,7 +1236,7 @@ function _onEngineSheetAdded(addedSheetDisplayName) {
1239
1236
  * @param {string} newDisplayName The new name of the sheet.
1240
1237
  */
1241
1238
  function _onEngineSheetRenamed(oldDisplayName, newDisplayName) {
1242
- this.sheetName = newDisplayName;
1239
+ _assertClassBrand(_Formulas_brand, this, _updateSheetNameAndSheetId).call(this, newDisplayName);
1243
1240
  this.hot.runHooks('afterSheetRenamed', oldDisplayName, newDisplayName);
1244
1241
  }
1245
1242
  /**
@@ -10,7 +10,6 @@ import "core-js/modules/es.set.symmetric-difference.v2.js";
10
10
  import "core-js/modules/es.set.union.v2.js";
11
11
  import "core-js/modules/esnext.iterator.constructor.js";
12
12
  import "core-js/modules/esnext.iterator.every.js";
13
- import "core-js/modules/esnext.iterator.find.js";
14
13
  import "core-js/modules/esnext.iterator.for-each.js";
15
14
  import "core-js/modules/esnext.iterator.map.js";
16
15
  function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
@@ -27,8 +26,8 @@ import staticRegister from "../../utils/staticRegister.mjs";
27
26
  import { error, warn } from "../../helpers/console.mjs";
28
27
  import { isNumeric } from "../../helpers/number.mjs";
29
28
  import { isDefined, isUndefined } from "../../helpers/mixed.mjs";
30
- import { setupEngine, setupSheet, unregisterEngine, getRegisteredHotInstances } from "./engine/register.mjs";
31
- import { isEscapedFormulaExpression, unescapeFormulaExpression, isDate, isDateValid, getDateInHfFormat, getDateFromExcelDate, getDateInHotFormat, isFormula } from "./utils.mjs";
29
+ import { getRegisteredHotInstances, setupEngine, setupSheet, unregisterEngine } from "./engine/register.mjs";
30
+ import { getDateFromExcelDate, getDateInHfFormat, getDateInHotFormat, isDate, isDateValid, isFormula, unescapeFormulaExpression } from "./utils.mjs";
32
31
  import { getEngineSettingsWithOverrides, haveEngineSettingsChanged } from "./engine/settings.mjs";
33
32
  import { isArrayOfArrays } from "../../helpers/data.mjs";
34
33
  import { toUpperCaseFirst } from "../../helpers/string.mjs";
@@ -70,13 +69,9 @@ export class Formulas extends BasePlugin {
70
69
  super(...arguments);
71
70
  _this = this;
72
71
  /**
73
- * The hook allows to translate the formula value to calculated value before it goes to the
74
- * validator function.
72
+ * Update sheetName and sheetId properties.
75
73
  *
76
- * @param {*} value The cell value to validate.
77
- * @param {number} visualRow The visual row index.
78
- * @param {number|string} prop The visual column index or property name of the column.
79
- * @returns {*} Returns value to validate.
74
+ * @param {string} [sheetName] The new sheet name.
80
75
  */
81
76
  _classPrivateMethodInitSpec(this, _Formulas_brand);
82
77
  /**
@@ -143,6 +138,12 @@ export class Formulas extends BasePlugin {
143
138
  * @type {HyperFormula|null}
144
139
  */
145
140
  _defineProperty(this, "engine", null);
141
+ /**
142
+ * HyperFormula's sheet id.
143
+ *
144
+ * @type {number|null}
145
+ */
146
+ _defineProperty(this, "sheetId", null);
146
147
  /**
147
148
  * HyperFormula's sheet name.
148
149
  *
@@ -177,15 +178,6 @@ export class Formulas extends BasePlugin {
177
178
  static get SETTING_KEYS() {
178
179
  return [PLUGIN_KEY, ...SETTING_KEYS];
179
180
  }
180
- /**
181
- * HyperFormula's sheet id.
182
- *
183
- * @type {number|null}
184
- */
185
- get sheetId() {
186
- return this.sheetName === null ? null : this.engine.getSheetId(this.sheetName);
187
- }
188
-
189
181
  /**
190
182
  * Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
191
183
  * hook and if it returns `true` then the {@link Formulas#enablePlugin} method is called.
@@ -216,7 +208,7 @@ export class Formulas extends BasePlugin {
216
208
  if (this.sheetName !== null && !this.engine.doesSheetExist(this.sheetName)) {
217
209
  const newSheetName = this.addSheet(this.sheetName, this.hot.getSourceDataArray());
218
210
  if (newSheetName !== false) {
219
- this.sheetName = newSheetName;
211
+ _assertClassBrand(_Formulas_brand, this, _updateSheetNameAndSheetId).call(this, newSheetName);
220
212
  }
221
213
  }
222
214
  this.addHook('beforeLoadData', function () {
@@ -447,7 +439,8 @@ export class Formulas extends BasePlugin {
447
439
  if (sheetName && this.engine.doesSheetExist(sheetName)) {
448
440
  this.switchSheet(this.sheetName);
449
441
  } else {
450
- this.sheetName = this.addSheet(sheetName !== null && sheetName !== void 0 ? sheetName : undefined, this.hot.getSourceDataArray());
442
+ const newSheetName = this.addSheet(sheetName !== null && sheetName !== void 0 ? sheetName : undefined, this.hot.getSourceDataArray());
443
+ _assertClassBrand(_Formulas_brand, this, _updateSheetNameAndSheetId).call(this, newSheetName);
451
444
  }
452
445
  }
453
446
  super.updatePlugin(newSettings);
@@ -467,7 +460,6 @@ export class Formulas extends BasePlugin {
467
460
  this.engine = null;
468
461
  super.destroy();
469
462
  }
470
-
471
463
  /**
472
464
  * Add a sheet to the shared HyperFormula instance.
473
465
  *
@@ -510,7 +502,7 @@ export class Formulas extends BasePlugin {
510
502
  error(`The sheet named \`${sheetName}\` does not exist, switch aborted.`);
511
503
  return;
512
504
  }
513
- this.sheetName = sheetName;
505
+ _assertClassBrand(_Formulas_brand, this, _updateSheetNameAndSheetId).call(this, sheetName);
514
506
  const serialized = this.engine.getSheetSerialized(this.sheetId);
515
507
  if (serialized.length > 0) {
516
508
  this.hot.loadData(serialized, `${toUpperCaseFirst(PLUGIN_KEY)}.switchSheet`);
@@ -670,6 +662,20 @@ export class Formulas extends BasePlugin {
670
662
  }
671
663
  return this.engine.setCellContents(address, newValue);
672
664
  }
665
+
666
+ /**
667
+ * The hook allows to translate the formula value to calculated value before it goes to the
668
+ * validator function.
669
+ *
670
+ * @param {*} value The cell value to validate.
671
+ * @param {number} visualRow The visual row index.
672
+ * @param {number|string} prop The visual column index or property name of the column.
673
+ * @returns {*} Returns value to validate.
674
+ */
675
+ }
676
+ function _updateSheetNameAndSheetId(sheetName) {
677
+ this.sheetName = sheetName;
678
+ this.sheetId = this.engine.getSheetId(this.sheetName);
673
679
  }
674
680
  function _onBeforeValidate(value, visualRow, prop) {
675
681
  const visualColumn = this.hot.propToCol(prop);
@@ -798,29 +804,33 @@ function _onBeforeLoadData(sourceData, initialLoad) {
798
804
  * Callback to `afterCellMetaReset` hook which is triggered after setting cell meta.
799
805
  */
800
806
  function _onAfterCellMetaReset() {
807
+ if (_classPrivateFieldGet(_hotWasInitializedWithEmptyData, this)) {
808
+ this.switchSheet(this.sheetName);
809
+ return;
810
+ }
801
811
  const sourceDataArray = this.hot.getSourceDataArray();
802
- let valueChanged = false;
803
812
  sourceDataArray.forEach((rowData, rowIndex) => {
804
813
  rowData.forEach((cellValue, columnIndex) => {
805
- const cellMeta = this.hot.getCellMeta(rowIndex, columnIndex);
814
+ const cellMeta = this.hot.getCellMeta(rowIndex, columnIndex, {
815
+ skipMetaExtension: true
816
+ });
806
817
  const dateFormat = cellMeta.dateFormat;
807
818
  if (isDate(cellValue, cellMeta.type)) {
808
- valueChanged = true;
809
819
  if (isDateValid(cellValue, dateFormat)) {
810
820
  // Rewriting date in HOT format to HF format.
811
821
  sourceDataArray[rowIndex][columnIndex] = getDateInHfFormat(cellValue, dateFormat);
812
- } else if (this.isFormulaCellType(rowIndex, columnIndex) === false) {
822
+ } else if (!cellValue.startsWith('=')) {
813
823
  // Escaping value from date parsing using "'" sign (HF feature).
814
824
  sourceDataArray[rowIndex][columnIndex] = `'${cellValue}`;
815
825
  }
816
826
  }
817
827
  });
818
828
  });
819
- if (valueChanged === true) {
820
- _classPrivateFieldSet(_internalOperationPending, this, true);
821
- this.engine.setSheetContent(this.sheetId, sourceDataArray);
822
- _classPrivateFieldSet(_internalOperationPending, this, false);
823
- }
829
+ _classPrivateFieldSet(_internalOperationPending, this, true);
830
+ const dependentCells = this.engine.setSheetContent(this.sheetId, sourceDataArray);
831
+ this.indexSyncer.setupSyncEndpoint(this.engine, this.sheetId);
832
+ this.renderDependentSheets(dependentCells);
833
+ _classPrivateFieldSet(_internalOperationPending, this, false);
824
834
  }
825
835
  /**
826
836
  * `afterLoadData` hook callback.
@@ -834,7 +844,12 @@ function _onAfterLoadData(sourceData, initialLoad) {
834
844
  if (source.includes(toUpperCaseFirst(PLUGIN_KEY))) {
835
845
  return;
836
846
  }
837
- this.sheetName = setupSheet(this.engine, this.hot.getSettings()[PLUGIN_KEY].sheetName);
847
+ const sheetName = setupSheet(this.engine, this.hot.getSettings()[PLUGIN_KEY].sheetName);
848
+ _assertClassBrand(_Formulas_brand, this, _updateSheetNameAndSheetId).call(this, sheetName);
849
+ if (source === 'updateSettings') {
850
+ // For performance reasons, the initialization will be done in afterCellMetaReset hook
851
+ return;
852
+ }
838
853
  if (!_classPrivateFieldGet(_hotWasInitializedWithEmptyData, this)) {
839
854
  const sourceDataArray = this.hot.getSourceDataArray();
840
855
  if (this.engine.isItPossibleToReplaceSheetContent(this.sheetId, sourceDataArray)) {
@@ -865,17 +880,10 @@ function _onModifyData(physicalRow, visualColumn, valueHolder, ioMode) {
865
880
  if (visualRow === null || visualColumn === null) {
866
881
  return;
867
882
  }
868
-
869
- // `column` is here as visual index because of inconsistencies related to hook execution in `src/dataMap`.
870
- const isFormulaCellType = this.isFormulaCellType(visualRow, visualColumn);
871
- if (!isFormulaCellType) {
872
- const cellType = this.getCellType(visualRow, visualColumn);
873
- if (cellType !== 'ARRAY') {
874
- if (isEscapedFormulaExpression(valueHolder.value)) {
875
- valueHolder.value = unescapeFormulaExpression(valueHolder.value);
876
- }
877
- return;
878
- }
883
+ const cellType = this.getCellType(visualRow, visualColumn);
884
+ if (cellType === 'VALUE' || cellType === 'EMPTY') {
885
+ valueHolder.value = unescapeFormulaExpression(valueHolder.value);
886
+ return;
879
887
  }
880
888
  const address = {
881
889
  row: this.rowAxisSyncer.getHfIndexFromVisualIndex(visualRow),
@@ -884,21 +892,15 @@ function _onModifyData(physicalRow, visualColumn, valueHolder, ioMode) {
884
892
  };
885
893
  let cellValue = this.engine.getCellValue(address); // Date as an integer (Excel like date).
886
894
 
887
- // TODO: Workaround. We use HOT's `getCellsMeta` method instead of HOT's `getCellMeta` method. Getting cell meta
888
- // using the second method lead to execution of the `cells` method. Using the `getDataAtCell` (which may be useful)
889
- // in a callback to the `cells` method leads to triggering the `modifyData` hook. Thus, the `onModifyData` callback
890
- // is executed once again and it cause creation of an infinite loop.
891
- let cellMeta = this.hot.getCellsMeta().find(singleCellMeta => singleCellMeta.visualRow === visualRow && singleCellMeta.visualCol === visualColumn);
892
- if (cellMeta === undefined) {
893
- cellMeta = {};
894
- }
895
+ const cellMeta = this.hot.getCellMeta(visualRow, visualColumn, {
896
+ skipMetaExtension: true
897
+ });
895
898
  if (cellMeta.type === 'date' && isNumeric(cellValue)) {
896
899
  cellValue = getDateFromExcelDate(cellValue, cellMeta.dateFormat);
897
900
  }
898
901
 
899
902
  // If `cellValue` is an object it is expected to be an error
900
- const value = typeof cellValue === 'object' && cellValue !== null ? cellValue.value : cellValue;
901
- valueHolder.value = value;
903
+ valueHolder.value = typeof cellValue === 'object' && cellValue !== null ? cellValue.value : cellValue;
902
904
  }
903
905
  /**
904
906
  * `modifySourceData` hook callback.
@@ -918,14 +920,9 @@ function _onModifySourceData(row, columnOrProp, valueHolder, ioMode) {
918
920
  if (visualRow === null || visualColumn === null) {
919
921
  return;
920
922
  }
921
-
922
- // `column` is here as visual index because of inconsistencies related to hook execution in `src/dataMap`.
923
- const isFormulaCellType = this.isFormulaCellType(visualRow, visualColumn);
924
- if (!isFormulaCellType) {
925
- const cellType = this.getCellType(visualRow, visualColumn);
926
- if (cellType !== 'ARRAY') {
927
- return;
928
- }
923
+ const cellType = this.getCellType(visualRow, visualColumn);
924
+ if (cellType === 'VALUE' || cellType === 'EMPTY') {
925
+ return;
929
926
  }
930
927
  const dimensions = this.engine.getSheetDimensions(this.engine.getSheetId(this.sheetName));
931
928
 
@@ -1234,7 +1231,7 @@ function _onEngineSheetAdded(addedSheetDisplayName) {
1234
1231
  * @param {string} newDisplayName The new name of the sheet.
1235
1232
  */
1236
1233
  function _onEngineSheetRenamed(oldDisplayName, newDisplayName) {
1237
- this.sheetName = newDisplayName;
1234
+ _assertClassBrand(_Formulas_brand, this, _updateSheetNameAndSheetId).call(this, newDisplayName);
1238
1235
  this.hot.runHooks('afterSheetRenamed', oldDisplayName, newDisplayName);
1239
1236
  }
1240
1237
  /**
@@ -118,7 +118,11 @@ class AxisSyncer {
118
118
  getHfIndexFromVisualIndex(visualIndex) {
119
119
  const indexesSequence = _classPrivateFieldGet(_indexMapper, this).getIndexesSequence();
120
120
  const notTrimmedIndexes = _classPrivateFieldGet(_indexMapper, this).getNotTrimmedIndexes();
121
- return indexesSequence.indexOf(notTrimmedIndexes[visualIndex]);
121
+
122
+ // Optimization:
123
+ // notTrimmedIndexes is a subset of indexesSequence,
124
+ // so for every x indexesSequence.indexOf(x) is always >= notTrimmedIndexes.indexOf(x)
125
+ return indexesSequence.indexOf(notTrimmedIndexes[visualIndex], visualIndex);
122
126
  }
123
127
 
124
128
  /**
@@ -115,7 +115,11 @@ class AxisSyncer {
115
115
  getHfIndexFromVisualIndex(visualIndex) {
116
116
  const indexesSequence = _classPrivateFieldGet(_indexMapper, this).getIndexesSequence();
117
117
  const notTrimmedIndexes = _classPrivateFieldGet(_indexMapper, this).getNotTrimmedIndexes();
118
- return indexesSequence.indexOf(notTrimmedIndexes[visualIndex]);
118
+
119
+ // Optimization:
120
+ // notTrimmedIndexes is a subset of indexesSequence,
121
+ // so for every x indexesSequence.indexOf(x) is always >= notTrimmedIndexes.indexOf(x)
122
+ return indexesSequence.indexOf(notTrimmedIndexes[visualIndex], visualIndex);
119
123
  }
120
124
 
121
125
  /**
@@ -25,8 +25,8 @@
25
25
  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING FROM
26
26
  * USE OR INABILITY TO USE THIS SOFTWARE.
27
27
  *
28
- * Version: 0.0.0-next-88f4ae4-20250313
29
- * Release date: 20/02/2025 (built at 13/03/2025 08:17:35)
28
+ * Version: 0.0.0-next-a1cc3b8-20250314
29
+ * Release date: 20/02/2025 (built at 14/03/2025 11:34:35)
30
30
  */
31
31
  .ht-wrapper:not([class*=ht-theme]) {
32
32
  --ht-gap-size: 4px;