@syncfusion/ej2-calculate 35.1.37 → 35.1.40

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * filename: index.d.ts
3
- * version : 35.1.37
3
+ * version : 35.1.40
4
4
  * Copyright Syncfusion Inc. 2001 - 2025. All rights reserved.
5
5
  * Use of this code is subject to the terms of our license.
6
6
  * A copy of the current license can be obtained at any time by e-mailing
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@syncfusion/ej2-calculate",
3
- "version": "35.1.37",
3
+ "version": "35.1.40",
4
4
  "description": "JavaScript formula calculation engine for Syncfusion Spreadsheet and compatible workbook/xlsx hosts",
5
5
  "author": "Syncfusion Inc.",
6
6
  "license": "SEE LICENSE IN license",
7
- "main": "./src/index.js",
7
+ "main": "./dist/ej2-calculate.umd.min.js",
8
8
  "module": "./index.js",
9
- "es2015": "./src/index.js",
9
+ "es2015": "./dist/es6/ej2-calculate.es5.js",
10
10
  "typings": "index.d.ts",
11
11
  "dependencies": {
12
12
  "@syncfusion/ej2-base": "~35.1.37"
@@ -1144,7 +1144,7 @@ var Calculate = /** @class */ (function (_super) {
1144
1144
  }
1145
1145
  if (nestedFormula && libFormula) {
1146
1146
  var formulas = ['IF', 'INDEX', 'SORT', 'T', 'EXACT',
1147
- 'PROPER', 'DOLLAR', 'DATE', 'TEXT', 'ISNUMBER'];
1147
+ 'PROPER', 'DOLLAR', 'DATE', 'TEXT', 'ISNUMBER', 'TRIM', 'LEFT'];
1148
1148
  if (formulas.some(function (formula) { return formula === libFormula; })) {
1149
1149
  args.push('nestedFormulaTrue');
1150
1150
  }
@@ -1541,7 +1541,52 @@ var Calculate = /** @class */ (function (_super) {
1541
1541
  return errorStrings[CommonErrors.Value];
1542
1542
  }
1543
1543
  }
1544
- var rangeArr = argArr[1].split(':');
1544
+ var rangeArg = argArr[1];
1545
+ var rowSepMarker = this.tic + 'RSEP' + this.tic;
1546
+ var isInlineArray = rangeArg.includes(rowSepMarker) ||
1547
+ (rangeArg.startsWith('(') && rangeArg.endsWith(')') && rangeArg.includes(rowSepMarker));
1548
+ if (isInlineArray) {
1549
+ var innerStr = rangeArg.startsWith('(') && rangeArg.endsWith(')')
1550
+ ? rangeArg.substring(1, rangeArg.length - 1) : rangeArg;
1551
+ var rowBoundary = this.tic + 'RSEP' + this.tic;
1552
+ var colBoundary_1 = this.tic + 'CSEP' + this.tic;
1553
+ var rows = innerStr.split(rowBoundary).map(function (rowStr) {
1554
+ return rowStr.split(colBoundary_1).map(function (cell) {
1555
+ if (cell.startsWith(_this.tic) && cell.endsWith(_this.tic)) {
1556
+ return cell.substring(1, cell.length - 1);
1557
+ }
1558
+ if (_this.isCellReference(cell.trim())) {
1559
+ return _this.getValueFromArg(cell.trim());
1560
+ }
1561
+ return cell.trim();
1562
+ });
1563
+ });
1564
+ var numRows = rows.length;
1565
+ var numCols = rows[0] ? rows[0].length : 0;
1566
+ var matchColIdx = colNumIdx - 1;
1567
+ if (isVlookup && numCols <= matchColIdx) {
1568
+ return errorStrings[CommonErrors.Ref];
1569
+ }
1570
+ if (!isVlookup && numRows <= matchColIdx) {
1571
+ return errorStrings[CommonErrors.Ref];
1572
+ }
1573
+ var lookupValUpper = lookupValue.toUpperCase();
1574
+ var iterCount = isVlookup ? numRows : numCols;
1575
+ for (var r = 0; r < iterCount; r++) {
1576
+ var cellVal = (isVlookup ? rows[r][0] : rows[0][r]) || '';
1577
+ var isMatch = this.isNumber(lookupValue) && this.isNumber(cellVal)
1578
+ ? this.parseFloat(lookupValue) === this.parseFloat(cellVal) : cellVal.toUpperCase() === lookupValUpper;
1579
+ if (isMatch) {
1580
+ var matchVal = isVlookup
1581
+ ? (rows[r][matchColIdx] !== undefined ? rows[r][matchColIdx] : '')
1582
+ : (rows[matchColIdx] !== undefined && rows[matchColIdx][r] !== undefined
1583
+ ? rows[matchColIdx][r] : '');
1584
+ return matchVal !== '' ? matchVal : '';
1585
+ }
1586
+ }
1587
+ return errorStrings[CommonErrors.NA];
1588
+ }
1589
+ var rangeArr = rangeArg.split(':');
1545
1590
  var startIdx;
1546
1591
  var endIdx;
1547
1592
  var idx;
@@ -1067,6 +1067,24 @@ var Parser = /** @class */ (function () {
1067
1067
  var criteriaStr = this_1.parent.substring(substr, leftBraceIdx, substr.indexOf('}') - leftBraceIdx + 1);
1068
1068
  substr = substr.split(criteriaStr).join(criteriaStr.split(argsSep).join(this_1.parent.tic + this_1.parent.tic));
1069
1069
  }
1070
+ if ((libFormula === 'VLOOKUP' || libFormula === 'HLOOKUP') && substr.includes('{')) {
1071
+ var searchStartIdx = 0;
1072
+ var leftBraceIdx = substr.indexOf('{', searchStartIdx);
1073
+ while (leftBraceIdx > -1) {
1074
+ var rightBraceIdx = substr.indexOf('}', leftBraceIdx);
1075
+ if (rightBraceIdx > leftBraceIdx) {
1076
+ var criteriaStr = this_1.parent.substring(substr, leftBraceIdx, rightBraceIdx - leftBraceIdx + 1);
1077
+ var protectedStr = criteriaStr.split(';').join(this_1.parent.tic + 'RSEP' + this_1.parent.tic)
1078
+ .split(argsSep).join(this_1.parent.tic + 'CSEP' + this_1.parent.tic);
1079
+ substr = substr.split(criteriaStr).join(protectedStr);
1080
+ searchStartIdx = leftBraceIdx + protectedStr.length;
1081
+ leftBraceIdx = substr.indexOf('{', searchStartIdx);
1082
+ }
1083
+ else {
1084
+ break;
1085
+ }
1086
+ }
1087
+ }
1070
1088
  }
1071
1089
  try {
1072
1090
  var args = void 0;
@@ -91,6 +91,11 @@ var TextExtraFormulas = /** @class */ (function (_super) {
91
91
  return this.substringSide(args, false);
92
92
  };
93
93
  TextExtraFormulas.prototype.substringSide = function (args, fromLeft) {
94
+ var nestedFormula;
95
+ if (args && args.length > 0 && args[args.length - 1] === 'nestedFormulaTrue') {
96
+ nestedFormula = true;
97
+ args.pop();
98
+ }
94
99
  var errCollection = this.parent.getErrorStrings();
95
100
  if (isNullOrUndefined(args) || (args.length === 1 && args[0] === '')) {
96
101
  return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
@@ -113,10 +118,8 @@ var TextExtraFormulas = /** @class */ (function (_super) {
113
118
  return errCollection[CommonErrors.Value];
114
119
  }
115
120
  }
116
- if (fromLeft) {
117
- return text.substring(0, count);
118
- }
119
- return count >= text.length ? text : text.substring(text.length - count);
121
+ var result = fromLeft ? text.substring(0, count) : (count >= text.length ? text : text.substring(text.length - count));
122
+ return nestedFormula ? this.parent.tic + result + this.parent.tic : result;
120
123
  };
121
124
  /**
122
125
  * Returns a specific number of characters from a text string starting at the position you specify.
@@ -212,6 +215,11 @@ var TextExtraFormulas = /** @class */ (function (_super) {
212
215
  for (var _i = 0; _i < arguments.length; _i++) {
213
216
  args[_i] = arguments[_i];
214
217
  }
218
+ var nestedFormula;
219
+ if (args && args.length > 0 && args[args.length - 1] === 'nestedFormulaTrue') {
220
+ nestedFormula = true;
221
+ args.pop();
222
+ }
215
223
  var errCollection = this.parent.getErrorStrings();
216
224
  if (isNullOrUndefined(args) || args.length !== 1) {
217
225
  return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
@@ -220,7 +228,8 @@ var TextExtraFormulas = /** @class */ (function (_super) {
220
228
  if (errCollection.indexOf(text) > -1) {
221
229
  return text;
222
230
  }
223
- return text.trim().replace(/\s+/g, ' ');
231
+ var result = text.trim().replace(/\s+/g, ' ');
232
+ return nestedFormula ? this.parent.tic + result + this.parent.tic : result;
224
233
  };
225
234
  /**
226
235
  * Replaces characters within text.