handsontable 0.0.0-next-44bc39b-20250312 → 0.0.0-next-19f5179-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.
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core.d.ts +1 -1
- package/core.js +7 -1
- package/core.mjs +7 -1
- package/dataMap/metaManager/index.js +8 -9
- package/dataMap/metaManager/index.mjs +8 -9
- package/dataMap/metaManager/mods/dynamicCellMeta.js +4 -1
- package/dataMap/metaManager/mods/dynamicCellMeta.mjs +4 -1
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +134 -93
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +10 -10
- package/dist/handsontable.js +134 -93
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +7 -7
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/plugins/autoColumnSize/autoColumnSize.js +37 -16
- package/plugins/autoColumnSize/autoColumnSize.mjs +37 -16
- package/plugins/autoRowSize/autoRowSize.js +11 -0
- package/plugins/autoRowSize/autoRowSize.mjs +11 -0
- package/plugins/formulas/formulas.d.ts +1 -1
- package/plugins/formulas/formulas.js +57 -60
- package/plugins/formulas/formulas.mjs +59 -62
- package/plugins/formulas/indexSyncer/axisSyncer.js +5 -1
- package/plugins/formulas/indexSyncer/axisSyncer.mjs +5 -1
- package/styles/handsontable.css +3 -4
- package/styles/handsontable.min.css +3 -3
- package/styles/ht-theme-horizon.css +2 -2
- package/styles/ht-theme-horizon.min.css +2 -2
- package/styles/ht-theme-main.css +2 -2
- package/styles/ht-theme-main.min.css +2 -2
|
@@ -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
|
|
31
|
-
import {
|
|
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
|
-
*
|
|
74
|
-
* validator function.
|
|
72
|
+
* Update sheetName and sheetId properties.
|
|
75
73
|
*
|
|
76
|
-
* @param {
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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 (
|
|
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
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
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
|
-
|
|
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
|
-
|
|
870
|
-
|
|
871
|
-
|
|
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
|
-
|
|
888
|
-
|
|
889
|
-
|
|
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
|
-
|
|
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
|
-
|
|
923
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
/**
|
package/styles/handsontable.css
CHANGED
|
@@ -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-
|
|
29
|
-
* Release date: 20/02/2025 (built at
|
|
28
|
+
* Version: 0.0.0-next-19f5179-20250314
|
|
29
|
+
* Release date: 20/02/2025 (built at 14/03/2025 08:46:43)
|
|
30
30
|
*/
|
|
31
31
|
.ht-wrapper:not([class*=ht-theme]) {
|
|
32
32
|
--ht-gap-size: 4px;
|
|
@@ -2145,7 +2145,6 @@
|
|
|
2145
2145
|
cursor: row-resize;
|
|
2146
2146
|
background: none;
|
|
2147
2147
|
opacity: 0;
|
|
2148
|
-
transition: opacity 0.2s ease-in-out;
|
|
2149
2148
|
}
|
|
2150
2149
|
.handsontable .manualRowResizer::before, .handsontable .manualRowResizer::after {
|
|
2151
2150
|
content: "";
|
|
@@ -2172,7 +2171,7 @@
|
|
|
2172
2171
|
left: 0;
|
|
2173
2172
|
bottom: 0;
|
|
2174
2173
|
height: 0;
|
|
2175
|
-
margin-top:
|
|
2174
|
+
margin-top: 5px;
|
|
2176
2175
|
display: none;
|
|
2177
2176
|
border-bottom: 1px solid var(--ht-accent-color);
|
|
2178
2177
|
border-top: none;
|