@syncfusion/ej2-calculate 35.1.39 → 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.39
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncfusion/ej2-calculate",
3
- "version": "35.1.39",
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",
@@ -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
  }
@@ -3199,8 +3199,8 @@ var Calculate = /** @class */ (function (_super) {
3199
3199
  return { op: op, criteria: criteria };
3200
3200
  };
3201
3201
  Calculate.prototype.processNestedFormula = function (pText, sFormula, fResult) {
3202
- if (!fResult.toString().includes('"')) {
3203
- var formulaEndIdx = pText.lastIndexOf(sFormula) + sFormula.length;
3202
+ if (fResult && !fResult.toString().includes('"')) {
3203
+ var formulaEndIdx = pText.indexOf(sFormula) + sFormula.length;
3204
3204
  if (pText[formulaEndIdx] === '"' && this.getErrorStrings().indexOf(fResult.toString()) < 0 &&
3205
3205
  !this.isNumber(fResult) && fResult !== this.trueValue && fResult !== this.falseValue) {
3206
3206
  return pText.split(sFormula).join('"' + fResult + '"');
@@ -1067,12 +1067,23 @@ 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
- else if ((libFormula === 'VLOOKUP' || libFormula === 'HLOOKUP') && substr.includes('{')) {
1071
- var leftBraceIdx = substr.indexOf('{');
1072
- var criteriaStr = this_1.parent.substring(substr, leftBraceIdx, substr.indexOf('}') - leftBraceIdx + 1);
1073
- var protectedStr = criteriaStr.split(';').join(this_1.parent.tic + 'RSEP' + this_1.parent.tic)
1074
- .split(argsSep).join(this_1.parent.tic + 'CSEP' + this_1.parent.tic);
1075
- substr = substr.split(criteriaStr).join(protectedStr);
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
+ }
1076
1087
  }
1077
1088
  }
1078
1089
  try {
@@ -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.