@leankylin-sheet/core 4.0.39 → 4.0.41

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.
package/dist/index.esm.js CHANGED
@@ -34892,16 +34892,22 @@ var make_ssf = function make_ssf(SSF) {
34892
34892
  }
34893
34893
  function format(fmt, v, o) {
34894
34894
  if (fmt === null || fmt === void 0 ? void 0 : fmt.includes('leanky_n')) {
34895
- if (isNaN(v) || Infinity == v || -Infinity == v) {
34895
+ if (Number.isNaN(v) || Infinity == v || -Infinity == v || v === null || v === '' || v === undefined) {
34896
34896
  return '';
34897
34897
  }
34898
+ if (isNaN(v)) {
34899
+ return v;
34900
+ }
34898
34901
  var precision = fmt.replace('leanky_n', '');
34899
34902
  return numberThousands(v, ',', precision);
34900
34903
  }
34901
34904
  if (fmt === null || fmt === void 0 ? void 0 : fmt.includes('leanky_p')) {
34902
- if (isNaN(v) || Infinity == v || -Infinity == v) {
34905
+ if (Number.isNaN(v) || Infinity == v || -Infinity == v || v === null || v === '' || v === undefined) {
34903
34906
  return '';
34904
34907
  }
34908
+ if (isNaN(v)) {
34909
+ return v;
34910
+ }
34905
34911
  var _precision = fmt.replace('leanky_p', '');
34906
34912
  return numberThousands(v * 100, ',', _precision) + '%';
34907
34913
  }
@@ -35447,7 +35453,7 @@ for (var i = 0; i < operatorArr.length; i += 1) {
35447
35453
  var simpleSheetName = "[A-Za-z0-9_\u4E00-\u9FFF]+";
35448
35454
  var quotedSheetName = "'(?:(?!').|'')*'";
35449
35455
  var sheetNameRegexp = "(".concat(simpleSheetName, "|").concat(quotedSheetName, ")!");
35450
- var rowColumnRegexp = "[$]?[A-Za-z]+[$]?[0-9]+";
35456
+ var rowColumnRegexp = "[$]?[A-Za-z]+[$]?[0-9]*";
35451
35457
  var rowColumnWithSheetName = "(?:".concat(sheetNameRegexp, ")?(").concat(rowColumnRegexp, ")");
35452
35458
  var LABEL_EXTRACT_REGEXP = new RegExp("^".concat(rowColumnWithSheetName, "(?:[:]").concat(rowColumnWithSheetName, ")?$"));
35453
35459
  var FormulaCache = /*#__PURE__*/function () {
@@ -35503,16 +35509,20 @@ var FormulaCache = /*#__PURE__*/function () {
35503
35509
  var endRow = endCellCoord.row.index;
35504
35510
  var startCol = startCellCoord.column.index;
35505
35511
  var endCol = endCellCoord.column.index;
35506
- var emptyRow = startRow === -1 || endRow === -1;
35507
- var emptyCol = startCol === -1 || endCol === -1;
35508
- if (emptyRow) {
35509
- var _flowdata$length;
35512
+ var emptyRow = startRow === -1 && endRow === -1;
35513
+ var emptyCol = startCol === -1 && endCol === -1;
35514
+ if (startRow === -1) {
35510
35515
  startRow = 0;
35516
+ }
35517
+ if (endRow === -1) {
35518
+ var _flowdata$length;
35511
35519
  endRow = (_flowdata$length = flowdata === null || flowdata === void 0 ? void 0 : flowdata.length) !== null && _flowdata$length !== void 0 ? _flowdata$length : 0;
35512
35520
  }
35513
- if (emptyCol) {
35514
- var _flowdata$0$length;
35521
+ if (startCol === -1) {
35515
35522
  startCol = 0;
35523
+ }
35524
+ if (endCol === -1) {
35525
+ var _flowdata$0$length;
35516
35526
  endCol = (_flowdata$0$length = flowdata === null || flowdata === void 0 ? void 0 : flowdata[0].length) !== null && _flowdata$0$length !== void 0 ? _flowdata$0$length : 0;
35517
35527
  }
35518
35528
  if (emptyRow && emptyCol) throw Error(ERROR_REF);
@@ -36181,7 +36191,7 @@ function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36181
36191
  var cellCache = [[{
36182
36192
  v: undefined
36183
36193
  }]];
36184
- setCellValue(ctx, 0, 0, cellCache, value);
36194
+ setCellValue(ctx, 0, 0, cellCache, value, true);
36185
36195
  var _cellCache$ = _slicedToArray(cellCache[0], 1);
36186
36196
  ctx.formulaCache.execFunctionGlobalData["".concat(origin_r, "_").concat(origin_c, "_").concat(id)] = _cellCache$[0];
36187
36197
  }
@@ -36241,6 +36251,7 @@ function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36241
36251
  var formulaCell = calcChains[_i12];
36242
36252
  var key = "r".concat(formulaCell.r, "c").concat(formulaCell.c, "i").concat(formulaCell.id);
36243
36253
  var calc_funcStr = getcellFormula(ctx, formulaCell.r, formulaCell.c, formulaCell.id);
36254
+ console.log("calc_funcStr", key, calc_funcStr);
36244
36255
  if (_.isNil(calc_funcStr)) {
36245
36256
  return 1; // continue
36246
36257
  }
@@ -39825,50 +39836,8 @@ function getCellValue(r, c, data, attr) {
39825
39836
  }
39826
39837
  return retv;
39827
39838
  }
39828
- function setCellValue(ctx, r, c, d, v) {
39839
+ function setVUpdateStr(cell, vupdateStr, d, r, c, vupdate) {
39829
39840
  var _cell$ct, _cell$ct2, _cell$ct3, _cell$ct4, _cell$ct5, _cell$ct6;
39830
- if (_.isNil(d)) {
39831
- d = getFlowdata(ctx);
39832
- }
39833
- if (!d) return;
39834
- var cell = d[r][c];
39835
- var vupdate;
39836
- if (_.isPlainObject(v)) {
39837
- if (_.isNil(cell)) {
39838
- cell = v;
39839
- } else {
39840
- if (!_.isNil(v.f)) {
39841
- cell.f = v.f;
39842
- } else if ("f" in cell) {
39843
- delete cell.f;
39844
- }
39845
- if (!_.isNil(v.ct)) {
39846
- cell.ct = v.ct;
39847
- }
39848
- }
39849
- if (_.isPlainObject(v.v)) {
39850
- vupdate = v.v.v;
39851
- } else {
39852
- vupdate = v.v;
39853
- }
39854
- } else {
39855
- vupdate = v;
39856
- }
39857
- if (isRealNull(vupdate)) {
39858
- if (_.isPlainObject(cell)) {
39859
- delete cell.m;
39860
- delete cell.v;
39861
- } else {
39862
- cell = null;
39863
- }
39864
- d[r][c] = cell;
39865
- return;
39866
- }
39867
- if (isRealNull(cell) || (_.isString(cell) || _.isNumber(cell)) && cell === v) {
39868
- cell = {};
39869
- }
39870
- if (!cell) return;
39871
- var vupdateStr = vupdate.toString();
39872
39841
  if (vupdateStr.substr(0, 1) === "'") {
39873
39842
  cell.m = vupdateStr.substr(1);
39874
39843
  cell.ct = {
@@ -40004,7 +39973,67 @@ function setCellValue(ctx, r, c, d, v) {
40004
39973
  }
40005
39974
  }
40006
39975
  }
40007
- d[r][c] = cell;
39976
+ if (d[r]) {
39977
+ d[r][c] = cell;
39978
+ }
39979
+ }
39980
+ function setCellValue(ctx, r, c, d, v, isCache) {
39981
+ if (_.isNil(d)) {
39982
+ d = getFlowdata(ctx);
39983
+ }
39984
+ if (!d) return;
39985
+ var cell = d[r][c];
39986
+ var vupdate;
39987
+ if (_.isPlainObject(v)) {
39988
+ if (_.isNil(cell)) {
39989
+ cell = v;
39990
+ } else {
39991
+ if (!_.isNil(v.f)) {
39992
+ cell.f = v.f;
39993
+ } else if ("f" in cell) {
39994
+ delete cell.f;
39995
+ }
39996
+ if (!_.isNil(v.ct)) {
39997
+ cell.ct = v.ct;
39998
+ }
39999
+ }
40000
+ if (_.isPlainObject(v.v)) {
40001
+ vupdate = v.v.v;
40002
+ } else {
40003
+ vupdate = v.v;
40004
+ }
40005
+ } else {
40006
+ vupdate = v;
40007
+ }
40008
+ if (isRealNull(vupdate)) {
40009
+ if (_.isPlainObject(cell)) {
40010
+ delete cell.m;
40011
+ delete cell.v;
40012
+ } else {
40013
+ cell = null;
40014
+ }
40015
+ d[r][c] = cell;
40016
+ return;
40017
+ }
40018
+ if (isRealNull(cell) || (_.isString(cell) || _.isNumber(cell)) && cell === v) {
40019
+ cell = {};
40020
+ }
40021
+ if (!cell) return;
40022
+ if (Array.isArray(vupdate) && !isCache) {
40023
+ for (var rIndex = 0; rIndex < vupdate.length; rIndex++) {
40024
+ var _vupdate$rIndex;
40025
+ var row = (_vupdate$rIndex = vupdate[rIndex]) !== null && _vupdate$rIndex !== void 0 ? _vupdate$rIndex : "";
40026
+ for (var cIndex = 0; cIndex < row.length; cIndex++) {
40027
+ var vUpdateCell = row[cIndex] || "";
40028
+ var vupdateStr = vUpdateCell.toString();
40029
+ var _cell = _objectSpread2({}, cell || {});
40030
+ setVUpdateStr(_cell, vupdateStr, d, r + rIndex, c + cIndex, vUpdateCell);
40031
+ }
40032
+ }
40033
+ } else {
40034
+ var _vupdateStr = vupdate.toString();
40035
+ setVUpdateStr(cell, _vupdateStr, d, r, c, vupdate);
40036
+ }
40008
40037
  }
40009
40038
  function getRealCellValue(r, c, data, attr) {
40010
40039
  var value = getCellValue(r, c, data, "m");
package/dist/index.js CHANGED
@@ -34902,16 +34902,22 @@ var make_ssf = function make_ssf(SSF) {
34902
34902
  }
34903
34903
  function format(fmt, v, o) {
34904
34904
  if (fmt === null || fmt === void 0 ? void 0 : fmt.includes('leanky_n')) {
34905
- if (isNaN(v) || Infinity == v || -Infinity == v) {
34905
+ if (Number.isNaN(v) || Infinity == v || -Infinity == v || v === null || v === '' || v === undefined) {
34906
34906
  return '';
34907
34907
  }
34908
+ if (isNaN(v)) {
34909
+ return v;
34910
+ }
34908
34911
  var precision = fmt.replace('leanky_n', '');
34909
34912
  return numberThousands(v, ',', precision);
34910
34913
  }
34911
34914
  if (fmt === null || fmt === void 0 ? void 0 : fmt.includes('leanky_p')) {
34912
- if (isNaN(v) || Infinity == v || -Infinity == v) {
34915
+ if (Number.isNaN(v) || Infinity == v || -Infinity == v || v === null || v === '' || v === undefined) {
34913
34916
  return '';
34914
34917
  }
34918
+ if (isNaN(v)) {
34919
+ return v;
34920
+ }
34915
34921
  var _precision = fmt.replace('leanky_p', '');
34916
34922
  return numberThousands(v * 100, ',', _precision) + '%';
34917
34923
  }
@@ -35457,7 +35463,7 @@ for (var i = 0; i < operatorArr.length; i += 1) {
35457
35463
  var simpleSheetName = "[A-Za-z0-9_\u4E00-\u9FFF]+";
35458
35464
  var quotedSheetName = "'(?:(?!').|'')*'";
35459
35465
  var sheetNameRegexp = "(".concat(simpleSheetName, "|").concat(quotedSheetName, ")!");
35460
- var rowColumnRegexp = "[$]?[A-Za-z]+[$]?[0-9]+";
35466
+ var rowColumnRegexp = "[$]?[A-Za-z]+[$]?[0-9]*";
35461
35467
  var rowColumnWithSheetName = "(?:".concat(sheetNameRegexp, ")?(").concat(rowColumnRegexp, ")");
35462
35468
  var LABEL_EXTRACT_REGEXP = new RegExp("^".concat(rowColumnWithSheetName, "(?:[:]").concat(rowColumnWithSheetName, ")?$"));
35463
35469
  var FormulaCache = /*#__PURE__*/function () {
@@ -35513,16 +35519,20 @@ var FormulaCache = /*#__PURE__*/function () {
35513
35519
  var endRow = endCellCoord.row.index;
35514
35520
  var startCol = startCellCoord.column.index;
35515
35521
  var endCol = endCellCoord.column.index;
35516
- var emptyRow = startRow === -1 || endRow === -1;
35517
- var emptyCol = startCol === -1 || endCol === -1;
35518
- if (emptyRow) {
35519
- var _flowdata$length;
35522
+ var emptyRow = startRow === -1 && endRow === -1;
35523
+ var emptyCol = startCol === -1 && endCol === -1;
35524
+ if (startRow === -1) {
35520
35525
  startRow = 0;
35526
+ }
35527
+ if (endRow === -1) {
35528
+ var _flowdata$length;
35521
35529
  endRow = (_flowdata$length = flowdata === null || flowdata === void 0 ? void 0 : flowdata.length) !== null && _flowdata$length !== void 0 ? _flowdata$length : 0;
35522
35530
  }
35523
- if (emptyCol) {
35524
- var _flowdata$0$length;
35531
+ if (startCol === -1) {
35525
35532
  startCol = 0;
35533
+ }
35534
+ if (endCol === -1) {
35535
+ var _flowdata$0$length;
35526
35536
  endCol = (_flowdata$0$length = flowdata === null || flowdata === void 0 ? void 0 : flowdata[0].length) !== null && _flowdata$0$length !== void 0 ? _flowdata$0$length : 0;
35527
35537
  }
35528
35538
  if (emptyRow && emptyCol) throw Error(formulaParser.ERROR_REF);
@@ -36191,7 +36201,7 @@ function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36191
36201
  var cellCache = [[{
36192
36202
  v: undefined
36193
36203
  }]];
36194
- setCellValue(ctx, 0, 0, cellCache, value);
36204
+ setCellValue(ctx, 0, 0, cellCache, value, true);
36195
36205
  var _cellCache$ = _slicedToArray(cellCache[0], 1);
36196
36206
  ctx.formulaCache.execFunctionGlobalData["".concat(origin_r, "_").concat(origin_c, "_").concat(id)] = _cellCache$[0];
36197
36207
  }
@@ -36251,6 +36261,7 @@ function execFunctionGroup(ctx, origin_r, origin_c, value, id, data) {
36251
36261
  var formulaCell = calcChains[_i12];
36252
36262
  var key = "r".concat(formulaCell.r, "c").concat(formulaCell.c, "i").concat(formulaCell.id);
36253
36263
  var calc_funcStr = getcellFormula(ctx, formulaCell.r, formulaCell.c, formulaCell.id);
36264
+ console.log("calc_funcStr", key, calc_funcStr);
36254
36265
  if (___default['default'].isNil(calc_funcStr)) {
36255
36266
  return 1; // continue
36256
36267
  }
@@ -39835,50 +39846,8 @@ function getCellValue(r, c, data, attr) {
39835
39846
  }
39836
39847
  return retv;
39837
39848
  }
39838
- function setCellValue(ctx, r, c, d, v) {
39849
+ function setVUpdateStr(cell, vupdateStr, d, r, c, vupdate) {
39839
39850
  var _cell$ct, _cell$ct2, _cell$ct3, _cell$ct4, _cell$ct5, _cell$ct6;
39840
- if (___default['default'].isNil(d)) {
39841
- d = getFlowdata(ctx);
39842
- }
39843
- if (!d) return;
39844
- var cell = d[r][c];
39845
- var vupdate;
39846
- if (___default['default'].isPlainObject(v)) {
39847
- if (___default['default'].isNil(cell)) {
39848
- cell = v;
39849
- } else {
39850
- if (!___default['default'].isNil(v.f)) {
39851
- cell.f = v.f;
39852
- } else if ("f" in cell) {
39853
- delete cell.f;
39854
- }
39855
- if (!___default['default'].isNil(v.ct)) {
39856
- cell.ct = v.ct;
39857
- }
39858
- }
39859
- if (___default['default'].isPlainObject(v.v)) {
39860
- vupdate = v.v.v;
39861
- } else {
39862
- vupdate = v.v;
39863
- }
39864
- } else {
39865
- vupdate = v;
39866
- }
39867
- if (isRealNull(vupdate)) {
39868
- if (___default['default'].isPlainObject(cell)) {
39869
- delete cell.m;
39870
- delete cell.v;
39871
- } else {
39872
- cell = null;
39873
- }
39874
- d[r][c] = cell;
39875
- return;
39876
- }
39877
- if (isRealNull(cell) || (___default['default'].isString(cell) || ___default['default'].isNumber(cell)) && cell === v) {
39878
- cell = {};
39879
- }
39880
- if (!cell) return;
39881
- var vupdateStr = vupdate.toString();
39882
39851
  if (vupdateStr.substr(0, 1) === "'") {
39883
39852
  cell.m = vupdateStr.substr(1);
39884
39853
  cell.ct = {
@@ -40014,7 +39983,67 @@ function setCellValue(ctx, r, c, d, v) {
40014
39983
  }
40015
39984
  }
40016
39985
  }
40017
- d[r][c] = cell;
39986
+ if (d[r]) {
39987
+ d[r][c] = cell;
39988
+ }
39989
+ }
39990
+ function setCellValue(ctx, r, c, d, v, isCache) {
39991
+ if (___default['default'].isNil(d)) {
39992
+ d = getFlowdata(ctx);
39993
+ }
39994
+ if (!d) return;
39995
+ var cell = d[r][c];
39996
+ var vupdate;
39997
+ if (___default['default'].isPlainObject(v)) {
39998
+ if (___default['default'].isNil(cell)) {
39999
+ cell = v;
40000
+ } else {
40001
+ if (!___default['default'].isNil(v.f)) {
40002
+ cell.f = v.f;
40003
+ } else if ("f" in cell) {
40004
+ delete cell.f;
40005
+ }
40006
+ if (!___default['default'].isNil(v.ct)) {
40007
+ cell.ct = v.ct;
40008
+ }
40009
+ }
40010
+ if (___default['default'].isPlainObject(v.v)) {
40011
+ vupdate = v.v.v;
40012
+ } else {
40013
+ vupdate = v.v;
40014
+ }
40015
+ } else {
40016
+ vupdate = v;
40017
+ }
40018
+ if (isRealNull(vupdate)) {
40019
+ if (___default['default'].isPlainObject(cell)) {
40020
+ delete cell.m;
40021
+ delete cell.v;
40022
+ } else {
40023
+ cell = null;
40024
+ }
40025
+ d[r][c] = cell;
40026
+ return;
40027
+ }
40028
+ if (isRealNull(cell) || (___default['default'].isString(cell) || ___default['default'].isNumber(cell)) && cell === v) {
40029
+ cell = {};
40030
+ }
40031
+ if (!cell) return;
40032
+ if (Array.isArray(vupdate) && !isCache) {
40033
+ for (var rIndex = 0; rIndex < vupdate.length; rIndex++) {
40034
+ var _vupdate$rIndex;
40035
+ var row = (_vupdate$rIndex = vupdate[rIndex]) !== null && _vupdate$rIndex !== void 0 ? _vupdate$rIndex : "";
40036
+ for (var cIndex = 0; cIndex < row.length; cIndex++) {
40037
+ var vUpdateCell = row[cIndex] || "";
40038
+ var vupdateStr = vUpdateCell.toString();
40039
+ var _cell = _objectSpread2({}, cell || {});
40040
+ setVUpdateStr(_cell, vupdateStr, d, r + rIndex, c + cIndex, vUpdateCell);
40041
+ }
40042
+ }
40043
+ } else {
40044
+ var _vupdateStr = vupdate.toString();
40045
+ setVUpdateStr(cell, _vupdateStr, d, r, c, vupdate);
40046
+ }
40018
40047
  }
40019
40048
  function getRealCellValue(r, c, data, attr) {
40020
40049
  var value = getCellValue(r, c, data, "m");
@@ -3,7 +3,7 @@ import { Cell, CellMatrix, Range, Selection, SingleRange } from "../types";
3
3
  export declare function normalizedCellAttr(cell: Cell, attr: keyof Cell, defaultFontSize?: number): any;
4
4
  export declare function normalizedAttr(data: CellMatrix, r: number, c: number, attr: keyof Cell): any;
5
5
  export declare function getCellValue(r: number, c: number, data: CellMatrix, attr?: keyof Cell): any;
6
- export declare function setCellValue(ctx: Context, r: number, c: number, d: CellMatrix | null | undefined, v: any): void;
6
+ export declare function setCellValue(ctx: Context, r: number, c: number, d: CellMatrix | null | undefined, v: any, isCache?: boolean): void;
7
7
  export declare function getRealCellValue(r: number, c: number, data: CellMatrix, attr?: keyof Cell): any;
8
8
  export declare function mergeBorder(ctx: Context, d: CellMatrix, row_index: number, col_index: number): {
9
9
  row: number[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leankylin-sheet/core",
3
- "version": "4.0.39",
3
+ "version": "4.0.41",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "build": "father-build"
14
14
  },
15
15
  "dependencies": {
16
- "@leankylin-sheet/formula-parser": "4.0.39",
16
+ "@leankylin-sheet/formula-parser": "4.0.41",
17
17
  "dayjs": "^1.11.0",
18
18
  "immer": "^9.0.12",
19
19
  "lodash": "^4.17.21",