@fileverse-dev/fortune-core 1.1.71 → 1.1.73-patch-1

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.
@@ -304,7 +304,7 @@ function setCellHyperlink(ctx, id, r, c, link) {
304
304
  function pasteHandlerOfCutPaste(ctx, copyRange) {
305
305
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
306
306
  var allowEdit = isAllowEdit(ctx);
307
- if (!allowEdit) return;
307
+ if (!allowEdit || ctx.isFlvReadOnly) return;
308
308
  if (!copyRange) return;
309
309
  var cfg = ctx.config || {};
310
310
  if (cfg.merge == null) {
package/es/locale/en.js CHANGED
@@ -2851,6 +2851,55 @@ export default {
2851
2851
  repeat: "y",
2852
2852
  type: "rangeall"
2853
2853
  }]
2854
+ }, {
2855
+ n: "XLOOKUP",
2856
+ t: 2,
2857
+ d: "Cross lookup. Returns the values in the result range at the position where a match was found in the lookup range.",
2858
+ a: "Cross lookup.",
2859
+ m: [3, 4],
2860
+ p: [{
2861
+ name: "search_key",
2862
+ detail: 'The value to search for. For example, `42`, `"Cats"`, or `I24`.',
2863
+ example: "10003",
2864
+ require: "m",
2865
+ repeat: "n",
2866
+ type: "rangeall"
2867
+ }, {
2868
+ name: "lookup_range",
2869
+ detail: "The range to consider for the search. This range must be a singular row or column.",
2870
+ example: "A2:B26",
2871
+ require: "m",
2872
+ repeat: "n",
2873
+ type: "rangeall"
2874
+ }, {
2875
+ name: "result_range",
2876
+ detail: "The range to consider for the result. This range's row or column size should be the same as the lookup_range's, depending on how the lookup is done.",
2877
+ example: "A2:B26",
2878
+ require: "m",
2879
+ repeat: "n",
2880
+ type: "rangeall"
2881
+ }, {
2882
+ name: "missing_value",
2883
+ detail: "The value to return if no match is found. If unspecified, an error is returned.",
2884
+ example: "N/A",
2885
+ require: "o",
2886
+ repeat: "n",
2887
+ type: "rangeall"
2888
+ }, {
2889
+ name: "match_mode",
2890
+ detail: "How to find a match for the search_key. 0 is for an exact match, 1 for an exact match or the next value that is bigger than the search_key, -1 for an exact match or the next value that is lower than the search_key, and 2 for a wildcard match. If unspecified, this defaults to finding an exact match.",
2891
+ example: "0",
2892
+ require: "o",
2893
+ repeat: "n",
2894
+ type: "rangeall"
2895
+ }, {
2896
+ name: "search_mode",
2897
+ detail: "How to search through the lookup range. 1 is to search from the first entry to the last one, -1 to search from the last entry to the first, 2 to search through the range using binary search and assuming the range is sorted in ascending order, and -2 to search through the range using binary search and assuming the range is sorted in descending order. If unspecified, this defaults to searching through the range from the first entry to the last one.",
2898
+ example: "1",
2899
+ require: "o",
2900
+ repeat: "n",
2901
+ type: "rangeall"
2902
+ }]
2854
2903
  }, {
2855
2904
  n: "VLOOKUP",
2856
2905
  t: 2,
@@ -1,7 +1,17 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var __assign = this && this.__assign || function () {
3
+ __assign = Object.assign || function (t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
2
12
  import _ from "lodash";
3
13
  import { getFlowdata } from "../context";
4
- import { getSheetIndex, indexToColumnChar, rgbToHex, processArray, getContentInParentheses } from "../utils";
14
+ import { getSheetIndex, indexToColumnChar, rgbToHex, processArray, getContentInParentheses, getNumberFormat } from "../utils";
5
15
  import { checkCF, getComputeMap } from "./ConditionFormat";
6
16
  import { getFailureText, validateCellData } from "./dataVerification";
7
17
  import { genarate, update } from "./format";
@@ -93,7 +103,7 @@ export function getCellValue(r, c, data, attr) {
93
103
  return retv;
94
104
  }
95
105
  export function setCellValue(ctx, r, c, d, v) {
96
- var _a, _b, _c, _d, _e, _f, _g;
106
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
97
107
  if (_.isNil(d)) {
98
108
  d = getFlowdata(ctx);
99
109
  }
@@ -205,6 +215,18 @@ export function setCellValue(ctx, r, c, d, v) {
205
215
  t: "n"
206
216
  };
207
217
  }
218
+ var isDigit = /^\d+$/.test(vupdate);
219
+ if (isDigit) {
220
+ var flowdata = getFlowdata(ctx);
221
+ var args = (_g = getContentInParentheses(cell === null || cell === void 0 ? void 0 : cell.f)) === null || _g === void 0 ? void 0 : _g.split(",");
222
+ var cellRefs = args === null || args === void 0 ? void 0 : args.map(function (arg) {
223
+ return arg.trim().toUpperCase();
224
+ });
225
+ var formatted = processArray(cellRefs, d, flowdata);
226
+ if (formatted) {
227
+ cell.ct.fa = formatted;
228
+ }
229
+ }
208
230
  if (cell.v === Infinity || cell.v === -Infinity) {
209
231
  cell.m = cell.v.toString();
210
232
  } else {
@@ -244,10 +266,23 @@ export function setCellValue(ctx, r, c, d, v) {
244
266
  cell.m = update(cell.ct.fa, cell.v);
245
267
  }
246
268
  } else if (!_.isNil(cell.ct) && !_.isNil(cell.ct.fa) && cell.ct.fa !== "General") {
269
+ var fa = cell.ct.fa;
247
270
  if (isRealNum(vupdate)) {
271
+ if (commaPresent && !fa.includes(",") || String(vupdate).includes(".") && ((_j = (_h = String(vupdate).split(".")) === null || _h === void 0 ? void 0 : _h[1]) === null || _j === void 0 ? void 0 : _j.length) !== ((_l = (_k = fa.split(".")) === null || _k === void 0 ? void 0 : _k[1]) === null || _l === void 0 ? void 0 : _l.length) || fa.includes(",") !== String(vupdate).includes(",")) {
272
+ if (fa.includes(",") !== String(vupdate).includes(",")) {
273
+ commaPresent = true;
274
+ }
275
+ fa = getNumberFormat(String(vupdate), commaPresent);
276
+ }
248
277
  vupdate = parseFloat(vupdate);
278
+ if (cell === null || cell === void 0 ? void 0 : cell.ct) {
279
+ cell.ct = __assign(__assign({}, cell.ct), {
280
+ fa: fa,
281
+ t: "n"
282
+ });
283
+ }
249
284
  }
250
- var mask = update(cell.ct.fa, vupdate);
285
+ var mask = update(fa, vupdate);
251
286
  if (mask === vupdate) {
252
287
  mask = genarate(vupdate);
253
288
  cell.m = mask[0].toString();
@@ -272,17 +307,7 @@ export function setCellValue(ctx, r, c, d, v) {
272
307
  }
273
308
  cell.v = vupdate;
274
309
  var strValue = String(vupdate);
275
- var format = void 0;
276
- var hasDecimal = strValue.includes(".");
277
- var hasComma = commaPresent;
278
- if (hasDecimal) {
279
- var decimalCount = ((_g = strValue.split(".")[1]) === null || _g === void 0 ? void 0 : _g.length) || 0;
280
- format = hasComma ? "#,##0.".concat("0".repeat(decimalCount)) : "0.".concat("0".repeat(decimalCount));
281
- } else if (hasComma) {
282
- format = "#,##0";
283
- } else {
284
- format = "0";
285
- }
310
+ var format = getNumberFormat(strValue, commaPresent);
286
311
  cell.m = v.m ? v.m : update(format, cell.v);
287
312
  cell.ht = 2;
288
313
  cell.ct = {
@@ -504,9 +529,6 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
504
529
  var inputHtml = $input === null || $input === void 0 ? void 0 : $input.innerHTML;
505
530
  var flowdata = getFlowdata(ctx);
506
531
  if (!flowdata) return;
507
- if (!(value === null || value === void 0 ? void 0 : value.toString())) {
508
- clearCellError(ctx, r, c);
509
- }
510
532
  var index = getSheetIndex(ctx, ctx.currentSheetId);
511
533
  var dataVerification = ctx.luckysheetfile[index].dataVerification;
512
534
  if (!_.isNil(dataVerification)) {
@@ -563,6 +585,10 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
563
585
  }
564
586
  }
565
587
  value = value || ($input === null || $input === void 0 ? void 0 : $input.innerText);
588
+ var shouldClearError = (oldValue === null || oldValue === void 0 ? void 0 : oldValue.f) ? oldValue.f !== value : (oldValue === null || oldValue === void 0 ? void 0 : oldValue.v) !== value;
589
+ if (shouldClearError) {
590
+ clearCellError(ctx, r, c);
591
+ }
566
592
  if (((_b = (_a = ctx.hooks).beforeUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, value)) === false) {
567
593
  cancelNormalSelected(ctx);
568
594
  return;
@@ -174,7 +174,7 @@ function createRowsOrColumnsForSpilledValues(ctx, startRow, startColumn, spillRo
174
174
  export function spillSortResult(ctx, startRow, startCol, formulaResult, flowdata) {
175
175
  var formulaString = formulaResult === null || formulaResult === void 0 ? void 0 : formulaResult.f;
176
176
  var formulaValue = formulaResult === null || formulaResult === void 0 ? void 0 : formulaResult.v;
177
- if (typeof formulaString !== "string" || !/= *SORT\s*\(/i.test(formulaString)) return false;
177
+ if (typeof formulaString !== "string" || !(/= *SORT\s*\(/i.test(formulaString) || /= *XLOOKUP\s*\(/i.test(formulaString))) return false;
178
178
  if (!Array.isArray(formulaValue)) return false;
179
179
  var valueMatrix = Array.isArray(formulaValue[0]) ? formulaValue : formulaValue.map(function (x) {
180
180
  return [x];
@@ -21,3 +21,5 @@ export declare function isLetterNumberPattern(str: string): boolean;
21
21
  export declare function removeLastSpan(htmlString: string): string;
22
22
  export declare function getContentInParentheses(str: string | null): string | null;
23
23
  export declare function processArray(cellReferences: any, d: any, flowData: any): undefined;
24
+ export declare function getNumberFormat(strValue: any, commaPresent: boolean): string;
25
+ export declare function checkIsCol(str: string): boolean | null;
package/es/utils/index.js CHANGED
@@ -290,16 +290,47 @@ export function processArray(cellReferences, d, flowData) {
290
290
  });
291
291
  var formated;
292
292
  coordinates.forEach(function (coord) {
293
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
293
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
294
294
  var row = coord[0],
295
295
  col = coord[1];
296
296
  if (row >= 0 && row < d.length && col >= 0 && col < d[row].length) {
297
297
  if (((_b = (_a = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _a === void 0 ? void 0 : _a.ct) === null || _b === void 0 ? void 0 : _b.fa) && ((_e = (_d = (_c = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _c === void 0 ? void 0 : _c.ct) === null || _d === void 0 ? void 0 : _d.fa) === null || _e === void 0 ? void 0 : _e.includes("#,##0"))) {
298
- formated = "#,##0";
299
- } else if (((_g = (_f = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _f === void 0 ? void 0 : _f.ct) === null || _g === void 0 ? void 0 : _g.fa) && ((_k = (_j = (_h = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _h === void 0 ? void 0 : _h.ct) === null || _j === void 0 ? void 0 : _j.fa) === null || _k === void 0 ? void 0 : _k.includes("#,##0.00"))) {
300
- formated = "#,##0.00";
298
+ formated = (_g = (_f = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _f === void 0 ? void 0 : _f.ct) === null || _g === void 0 ? void 0 : _g.fa;
299
+ }
300
+ if (((_j = (_h = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _h === void 0 ? void 0 : _h.ct) === null || _j === void 0 ? void 0 : _j.fa) && ((_m = (_l = (_k = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _k === void 0 ? void 0 : _k.ct) === null || _l === void 0 ? void 0 : _l.fa) === null || _m === void 0 ? void 0 : _m.includes("#,##0."))) {
301
+ formated = (_p = (_o = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _o === void 0 ? void 0 : _o.ct) === null || _p === void 0 ? void 0 : _p.fa;
301
302
  }
302
303
  }
303
304
  });
304
305
  return formated;
306
+ }
307
+ export function getNumberFormat(strValue, commaPresent) {
308
+ var _a;
309
+ var format = "";
310
+ var hasDecimal = strValue.includes(".");
311
+ var hasComma = commaPresent;
312
+ if (hasDecimal) {
313
+ var decimalCount = ((_a = strValue.split(".")[1]) === null || _a === void 0 ? void 0 : _a.length) || 0;
314
+ format = hasComma ? "#,##0.".concat("0".repeat(decimalCount)) : "0.".concat("0".repeat(decimalCount));
315
+ } else if (hasComma) {
316
+ format = "#,##0";
317
+ } else {
318
+ format = "0";
319
+ }
320
+ return format;
321
+ }
322
+ export function checkIsCol(str) {
323
+ var _a;
324
+ var afterComma = (_a = str.split(",")[1]) === null || _a === void 0 ? void 0 : _a.trim();
325
+ if (!afterComma) return null;
326
+ var firstRange = afterComma.split(/[),]/)[0].trim();
327
+ var match = firstRange.match(/^([A-Z]+)(\d+):([A-Z]+)(\d+)$/i);
328
+ if (!match) return null;
329
+ var col1 = match[1],
330
+ row1 = match[2],
331
+ col2 = match[3],
332
+ row2 = match[4];
333
+ if (col1 === col2 && row1 !== row2) return false;
334
+ if (row1 === row2 && col1 !== col2) return true;
335
+ return null;
305
336
  }
@@ -313,7 +313,7 @@ function setCellHyperlink(ctx, id, r, c, link) {
313
313
  function pasteHandlerOfCutPaste(ctx, copyRange) {
314
314
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
315
315
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
316
- if (!allowEdit) return;
316
+ if (!allowEdit || ctx.isFlvReadOnly) return;
317
317
  if (!copyRange) return;
318
318
  var cfg = ctx.config || {};
319
319
  if (cfg.merge == null) {
package/lib/locale/en.js CHANGED
@@ -2857,6 +2857,55 @@ var _default = exports.default = {
2857
2857
  repeat: "y",
2858
2858
  type: "rangeall"
2859
2859
  }]
2860
+ }, {
2861
+ n: "XLOOKUP",
2862
+ t: 2,
2863
+ d: "Cross lookup. Returns the values in the result range at the position where a match was found in the lookup range.",
2864
+ a: "Cross lookup.",
2865
+ m: [3, 4],
2866
+ p: [{
2867
+ name: "search_key",
2868
+ detail: 'The value to search for. For example, `42`, `"Cats"`, or `I24`.',
2869
+ example: "10003",
2870
+ require: "m",
2871
+ repeat: "n",
2872
+ type: "rangeall"
2873
+ }, {
2874
+ name: "lookup_range",
2875
+ detail: "The range to consider for the search. This range must be a singular row or column.",
2876
+ example: "A2:B26",
2877
+ require: "m",
2878
+ repeat: "n",
2879
+ type: "rangeall"
2880
+ }, {
2881
+ name: "result_range",
2882
+ detail: "The range to consider for the result. This range's row or column size should be the same as the lookup_range's, depending on how the lookup is done.",
2883
+ example: "A2:B26",
2884
+ require: "m",
2885
+ repeat: "n",
2886
+ type: "rangeall"
2887
+ }, {
2888
+ name: "missing_value",
2889
+ detail: "The value to return if no match is found. If unspecified, an error is returned.",
2890
+ example: "N/A",
2891
+ require: "o",
2892
+ repeat: "n",
2893
+ type: "rangeall"
2894
+ }, {
2895
+ name: "match_mode",
2896
+ detail: "How to find a match for the search_key. 0 is for an exact match, 1 for an exact match or the next value that is bigger than the search_key, -1 for an exact match or the next value that is lower than the search_key, and 2 for a wildcard match. If unspecified, this defaults to finding an exact match.",
2897
+ example: "0",
2898
+ require: "o",
2899
+ repeat: "n",
2900
+ type: "rangeall"
2901
+ }, {
2902
+ name: "search_mode",
2903
+ detail: "How to search through the lookup range. 1 is to search from the first entry to the last one, -1 to search from the last entry to the first, 2 to search through the range using binary search and assuming the range is sorted in ascending order, and -2 to search through the range using binary search and assuming the range is sorted in descending order. If unspecified, this defaults to searching through the range from the first entry to the last one.",
2904
+ example: "1",
2905
+ require: "o",
2906
+ repeat: "n",
2907
+ type: "rangeall"
2908
+ }]
2860
2909
  }, {
2861
2910
  n: "VLOOKUP",
2862
2911
  t: 2,
@@ -44,6 +44,16 @@ var _text = require("./text");
44
44
  var _sort = require("./sort");
45
45
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
46
46
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
47
+ var __assign = void 0 && (void 0).__assign || function () {
48
+ __assign = Object.assign || function (t) {
49
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
50
+ s = arguments[i];
51
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
52
+ }
53
+ return t;
54
+ };
55
+ return __assign.apply(this, arguments);
56
+ };
47
57
  function normalizedCellAttr(cell, attr, defaultFontSize) {
48
58
  if (defaultFontSize === void 0) {
49
59
  defaultFontSize = 10;
@@ -126,7 +136,7 @@ function getCellValue(r, c, data, attr) {
126
136
  return retv;
127
137
  }
128
138
  function setCellValue(ctx, r, c, d, v) {
129
- var _a, _b, _c, _d, _e, _f, _g;
139
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
130
140
  if (_lodash.default.isNil(d)) {
131
141
  d = (0, _context.getFlowdata)(ctx);
132
142
  }
@@ -238,6 +248,18 @@ function setCellValue(ctx, r, c, d, v) {
238
248
  t: "n"
239
249
  };
240
250
  }
251
+ var isDigit = /^\d+$/.test(vupdate);
252
+ if (isDigit) {
253
+ var flowdata = (0, _context.getFlowdata)(ctx);
254
+ var args = (_g = (0, _utils.getContentInParentheses)(cell === null || cell === void 0 ? void 0 : cell.f)) === null || _g === void 0 ? void 0 : _g.split(",");
255
+ var cellRefs = args === null || args === void 0 ? void 0 : args.map(function (arg) {
256
+ return arg.trim().toUpperCase();
257
+ });
258
+ var formatted = (0, _utils.processArray)(cellRefs, d, flowdata);
259
+ if (formatted) {
260
+ cell.ct.fa = formatted;
261
+ }
262
+ }
241
263
  if (cell.v === Infinity || cell.v === -Infinity) {
242
264
  cell.m = cell.v.toString();
243
265
  } else {
@@ -277,10 +299,23 @@ function setCellValue(ctx, r, c, d, v) {
277
299
  cell.m = (0, _format.update)(cell.ct.fa, cell.v);
278
300
  }
279
301
  } else if (!_lodash.default.isNil(cell.ct) && !_lodash.default.isNil(cell.ct.fa) && cell.ct.fa !== "General") {
302
+ var fa = cell.ct.fa;
280
303
  if ((0, _validation.isRealNum)(vupdate)) {
304
+ if (commaPresent && !fa.includes(",") || String(vupdate).includes(".") && ((_j = (_h = String(vupdate).split(".")) === null || _h === void 0 ? void 0 : _h[1]) === null || _j === void 0 ? void 0 : _j.length) !== ((_l = (_k = fa.split(".")) === null || _k === void 0 ? void 0 : _k[1]) === null || _l === void 0 ? void 0 : _l.length) || fa.includes(",") !== String(vupdate).includes(",")) {
305
+ if (fa.includes(",") !== String(vupdate).includes(",")) {
306
+ commaPresent = true;
307
+ }
308
+ fa = (0, _utils.getNumberFormat)(String(vupdate), commaPresent);
309
+ }
281
310
  vupdate = parseFloat(vupdate);
311
+ if (cell === null || cell === void 0 ? void 0 : cell.ct) {
312
+ cell.ct = __assign(__assign({}, cell.ct), {
313
+ fa: fa,
314
+ t: "n"
315
+ });
316
+ }
282
317
  }
283
- var mask = (0, _format.update)(cell.ct.fa, vupdate);
318
+ var mask = (0, _format.update)(fa, vupdate);
284
319
  if (mask === vupdate) {
285
320
  mask = (0, _format.genarate)(vupdate);
286
321
  cell.m = mask[0].toString();
@@ -305,17 +340,7 @@ function setCellValue(ctx, r, c, d, v) {
305
340
  }
306
341
  cell.v = vupdate;
307
342
  var strValue = String(vupdate);
308
- var format = void 0;
309
- var hasDecimal = strValue.includes(".");
310
- var hasComma = commaPresent;
311
- if (hasDecimal) {
312
- var decimalCount = ((_g = strValue.split(".")[1]) === null || _g === void 0 ? void 0 : _g.length) || 0;
313
- format = hasComma ? "#,##0.".concat("0".repeat(decimalCount)) : "0.".concat("0".repeat(decimalCount));
314
- } else if (hasComma) {
315
- format = "#,##0";
316
- } else {
317
- format = "0";
318
- }
343
+ var format = (0, _utils.getNumberFormat)(strValue, commaPresent);
319
344
  cell.m = v.m ? v.m : (0, _format.update)(format, cell.v);
320
345
  cell.ht = 2;
321
346
  cell.ct = {
@@ -537,9 +562,6 @@ function updateCell(ctx, r, c, $input, value, canvas) {
537
562
  var inputHtml = $input === null || $input === void 0 ? void 0 : $input.innerHTML;
538
563
  var flowdata = (0, _context.getFlowdata)(ctx);
539
564
  if (!flowdata) return;
540
- if (!(value === null || value === void 0 ? void 0 : value.toString())) {
541
- (0, _api.clearCellError)(ctx, r, c);
542
- }
543
565
  var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
544
566
  var dataVerification = ctx.luckysheetfile[index].dataVerification;
545
567
  if (!_lodash.default.isNil(dataVerification)) {
@@ -596,6 +618,10 @@ function updateCell(ctx, r, c, $input, value, canvas) {
596
618
  }
597
619
  }
598
620
  value = value || ($input === null || $input === void 0 ? void 0 : $input.innerText);
621
+ var shouldClearError = (oldValue === null || oldValue === void 0 ? void 0 : oldValue.f) ? oldValue.f !== value : (oldValue === null || oldValue === void 0 ? void 0 : oldValue.v) !== value;
622
+ if (shouldClearError) {
623
+ (0, _api.clearCellError)(ctx, r, c);
624
+ }
599
625
  if (((_b = (_a = ctx.hooks).beforeUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, value)) === false) {
600
626
  cancelNormalSelected(ctx);
601
627
  return;
@@ -184,7 +184,7 @@ function createRowsOrColumnsForSpilledValues(ctx, startRow, startColumn, spillRo
184
184
  function spillSortResult(ctx, startRow, startCol, formulaResult, flowdata) {
185
185
  var formulaString = formulaResult === null || formulaResult === void 0 ? void 0 : formulaResult.f;
186
186
  var formulaValue = formulaResult === null || formulaResult === void 0 ? void 0 : formulaResult.v;
187
- if (typeof formulaString !== "string" || !/= *SORT\s*\(/i.test(formulaString)) return false;
187
+ if (typeof formulaString !== "string" || !(/= *SORT\s*\(/i.test(formulaString) || /= *XLOOKUP\s*\(/i.test(formulaString))) return false;
188
188
  if (!Array.isArray(formulaValue)) return false;
189
189
  var valueMatrix = Array.isArray(formulaValue[0]) ? formulaValue : formulaValue.map(function (x) {
190
190
  return [x];
@@ -21,3 +21,5 @@ export declare function isLetterNumberPattern(str: string): boolean;
21
21
  export declare function removeLastSpan(htmlString: string): string;
22
22
  export declare function getContentInParentheses(str: string | null): string | null;
23
23
  export declare function processArray(cellReferences: any, d: any, flowData: any): undefined;
24
+ export declare function getNumberFormat(strValue: any, commaPresent: boolean): string;
25
+ export declare function checkIsCol(str: string): boolean | null;
@@ -22,15 +22,19 @@ var _exportNames = {
22
22
  isLetterNumberPattern: true,
23
23
  removeLastSpan: true,
24
24
  getContentInParentheses: true,
25
- processArray: true
25
+ processArray: true,
26
+ getNumberFormat: true,
27
+ checkIsCol: true
26
28
  };
27
29
  exports.chatatABC = chatatABC;
30
+ exports.checkIsCol = checkIsCol;
28
31
  exports.columnCharToIndex = columnCharToIndex;
29
32
  exports.escapeHTMLTag = escapeHTMLTag;
30
33
  exports.escapeScriptTag = escapeScriptTag;
31
34
  exports.generateRandomSheetName = generateRandomSheetName;
32
35
  exports.getContentInParentheses = getContentInParentheses;
33
36
  exports.getNowDateTime = getNowDateTime;
37
+ exports.getNumberFormat = getNumberFormat;
34
38
  exports.getRegExpStr = getRegExpStr;
35
39
  exports.getSheetByIndex = getSheetByIndex;
36
40
  exports.getSheetIdByName = getSheetIdByName;
@@ -358,16 +362,47 @@ function processArray(cellReferences, d, flowData) {
358
362
  });
359
363
  var formated;
360
364
  coordinates.forEach(function (coord) {
361
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
365
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
362
366
  var row = coord[0],
363
367
  col = coord[1];
364
368
  if (row >= 0 && row < d.length && col >= 0 && col < d[row].length) {
365
369
  if (((_b = (_a = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _a === void 0 ? void 0 : _a.ct) === null || _b === void 0 ? void 0 : _b.fa) && ((_e = (_d = (_c = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _c === void 0 ? void 0 : _c.ct) === null || _d === void 0 ? void 0 : _d.fa) === null || _e === void 0 ? void 0 : _e.includes("#,##0"))) {
366
- formated = "#,##0";
367
- } else if (((_g = (_f = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _f === void 0 ? void 0 : _f.ct) === null || _g === void 0 ? void 0 : _g.fa) && ((_k = (_j = (_h = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _h === void 0 ? void 0 : _h.ct) === null || _j === void 0 ? void 0 : _j.fa) === null || _k === void 0 ? void 0 : _k.includes("#,##0.00"))) {
368
- formated = "#,##0.00";
370
+ formated = (_g = (_f = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _f === void 0 ? void 0 : _f.ct) === null || _g === void 0 ? void 0 : _g.fa;
371
+ }
372
+ if (((_j = (_h = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _h === void 0 ? void 0 : _h.ct) === null || _j === void 0 ? void 0 : _j.fa) && ((_m = (_l = (_k = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _k === void 0 ? void 0 : _k.ct) === null || _l === void 0 ? void 0 : _l.fa) === null || _m === void 0 ? void 0 : _m.includes("#,##0."))) {
373
+ formated = (_p = (_o = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _o === void 0 ? void 0 : _o.ct) === null || _p === void 0 ? void 0 : _p.fa;
369
374
  }
370
375
  }
371
376
  });
372
377
  return formated;
378
+ }
379
+ function getNumberFormat(strValue, commaPresent) {
380
+ var _a;
381
+ var format = "";
382
+ var hasDecimal = strValue.includes(".");
383
+ var hasComma = commaPresent;
384
+ if (hasDecimal) {
385
+ var decimalCount = ((_a = strValue.split(".")[1]) === null || _a === void 0 ? void 0 : _a.length) || 0;
386
+ format = hasComma ? "#,##0.".concat("0".repeat(decimalCount)) : "0.".concat("0".repeat(decimalCount));
387
+ } else if (hasComma) {
388
+ format = "#,##0";
389
+ } else {
390
+ format = "0";
391
+ }
392
+ return format;
393
+ }
394
+ function checkIsCol(str) {
395
+ var _a;
396
+ var afterComma = (_a = str.split(",")[1]) === null || _a === void 0 ? void 0 : _a.trim();
397
+ if (!afterComma) return null;
398
+ var firstRange = afterComma.split(/[),]/)[0].trim();
399
+ var match = firstRange.match(/^([A-Z]+)(\d+):([A-Z]+)(\d+)$/i);
400
+ if (!match) return null;
401
+ var col1 = match[1],
402
+ row1 = match[2],
403
+ col2 = match[3],
404
+ row2 = match[4];
405
+ if (col1 === col2 && row1 !== row2) return false;
406
+ if (row1 === row2 && col1 !== col2) return true;
407
+ return null;
373
408
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.1.71",
3
+ "version": "1.1.73-patch-1",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "dev": "father-build --watch"
16
16
  },
17
17
  "dependencies": {
18
- "@fileverse-dev/formula-parser": "0.2.70",
18
+ "@fileverse-dev/formula-parser": "0.2.71",
19
19
  "dayjs": "^1.11.0",
20
20
  "immer": "^9.0.12",
21
21
  "lodash": "^4.17.21",