@leankylin-sheet/core 2.0.21 → 2.0.22

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
@@ -44935,10 +44935,16 @@ var make_ssf = function make_ssf(SSF) {
44935
44935
  }
44936
44936
  function format(fmt, v, o) {
44937
44937
  if (fmt === null || fmt === void 0 ? void 0 : fmt.includes('leanky_n')) {
44938
+ if (isNaN(v)) {
44939
+ return '#VALUE!';
44940
+ }
44938
44941
  var precision = fmt.replace('leanky_n', '');
44939
44942
  return numberThousands(v, ',', precision);
44940
44943
  }
44941
44944
  if (fmt === null || fmt === void 0 ? void 0 : fmt.includes('leanky_p')) {
44945
+ if (isNaN(v)) {
44946
+ return '#VALUE!';
44947
+ }
44942
44948
  var _precision = fmt.replace('leanky_p', '');
44943
44949
  return numberThousands(v * 100, ',', _precision) + '%';
44944
44950
  }
@@ -45119,9 +45125,6 @@ var numberThousands = function numberThousands(num) {
45119
45125
  var groupSeparator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';
45120
45126
  var precision = arguments.length > 2 ? arguments[2] : undefined;
45121
45127
  var number = Number(num).toFixed(precision);
45122
- if (isNaN(number)) {
45123
- return '';
45124
- }
45125
45128
  var _String$split = String(number).split('.'),
45126
45129
  _String$split2 = _slicedToArray(_String$split, 2),
45127
45130
  init = _String$split2[0],
@@ -49921,28 +49924,15 @@ function setCellValue(ctx, r, c, d, v) {
49921
49924
  if (cell.v === Infinity || cell.v === -Infinity) {
49922
49925
  cell.m = cell.v.toString();
49923
49926
  } else {
49924
- if (cell.v.toString().indexOf("e") > -1) {
49925
- var len;
49926
- if (cell.v.toString().split(".").length === 1) {
49927
- len = 0;
49928
- } else {
49929
- len = cell.v.toString().split(".")[1].split("e")[0].length;
49927
+ var v_p = Math.round(cell.v * 1000000000) / 1000000000;
49928
+ if (_.isNil(cell.ct)) {
49929
+ var mask = genarate(v_p);
49930
+ if (mask != null) {
49931
+ cell.m = mask[0].toString();
49930
49932
  }
49931
- if (len > 5) {
49932
- len = 5;
49933
- }
49934
- cell.m = cell.v.toExponential(len).toString();
49935
49933
  } else {
49936
- var v_p = Math.round(cell.v * 1000000000) / 1000000000;
49937
- if (_.isNil(cell.ct)) {
49938
- var mask = genarate(v_p);
49939
- if (mask != null) {
49940
- cell.m = mask[0].toString();
49941
- }
49942
- } else {
49943
- var _mask = update(cell.ct.fa, v_p);
49944
- cell.m = _mask.toString();
49945
- }
49934
+ var _mask = update(cell.ct.fa, v_p);
49935
+ cell.m = _mask.toString();
49946
49936
  }
49947
49937
  }
49948
49938
  } else if (!_.isNil(cell.ct) && cell.ct.fa === "@") {
package/dist/index.js CHANGED
@@ -44945,10 +44945,16 @@ var make_ssf = function make_ssf(SSF) {
44945
44945
  }
44946
44946
  function format(fmt, v, o) {
44947
44947
  if (fmt === null || fmt === void 0 ? void 0 : fmt.includes('leanky_n')) {
44948
+ if (isNaN(v)) {
44949
+ return '#VALUE!';
44950
+ }
44948
44951
  var precision = fmt.replace('leanky_n', '');
44949
44952
  return numberThousands(v, ',', precision);
44950
44953
  }
44951
44954
  if (fmt === null || fmt === void 0 ? void 0 : fmt.includes('leanky_p')) {
44955
+ if (isNaN(v)) {
44956
+ return '#VALUE!';
44957
+ }
44952
44958
  var _precision = fmt.replace('leanky_p', '');
44953
44959
  return numberThousands(v * 100, ',', _precision) + '%';
44954
44960
  }
@@ -45129,9 +45135,6 @@ var numberThousands = function numberThousands(num) {
45129
45135
  var groupSeparator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';
45130
45136
  var precision = arguments.length > 2 ? arguments[2] : undefined;
45131
45137
  var number = Number(num).toFixed(precision);
45132
- if (isNaN(number)) {
45133
- return '';
45134
- }
45135
45138
  var _String$split = String(number).split('.'),
45136
45139
  _String$split2 = _slicedToArray(_String$split, 2),
45137
45140
  init = _String$split2[0],
@@ -49931,28 +49934,15 @@ function setCellValue(ctx, r, c, d, v) {
49931
49934
  if (cell.v === Infinity || cell.v === -Infinity) {
49932
49935
  cell.m = cell.v.toString();
49933
49936
  } else {
49934
- if (cell.v.toString().indexOf("e") > -1) {
49935
- var len;
49936
- if (cell.v.toString().split(".").length === 1) {
49937
- len = 0;
49938
- } else {
49939
- len = cell.v.toString().split(".")[1].split("e")[0].length;
49937
+ var v_p = Math.round(cell.v * 1000000000) / 1000000000;
49938
+ if (___default['default'].isNil(cell.ct)) {
49939
+ var mask = genarate(v_p);
49940
+ if (mask != null) {
49941
+ cell.m = mask[0].toString();
49940
49942
  }
49941
- if (len > 5) {
49942
- len = 5;
49943
- }
49944
- cell.m = cell.v.toExponential(len).toString();
49945
49943
  } else {
49946
- var v_p = Math.round(cell.v * 1000000000) / 1000000000;
49947
- if (___default['default'].isNil(cell.ct)) {
49948
- var mask = genarate(v_p);
49949
- if (mask != null) {
49950
- cell.m = mask[0].toString();
49951
- }
49952
- } else {
49953
- var _mask = update(cell.ct.fa, v_p);
49954
- cell.m = _mask.toString();
49955
- }
49944
+ var _mask = update(cell.ct.fa, v_p);
49945
+ cell.m = _mask.toString();
49956
49946
  }
49957
49947
  }
49958
49948
  } else if (!___default['default'].isNil(cell.ct) && cell.ct.fa === "@") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leankylin-sheet/core",
3
- "version": "2.0.21",
3
+ "version": "2.0.22",
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": "^2.0.21",
16
+ "@leankylin-sheet/formula-parser": "^2.0.22",
17
17
  "dayjs": "^1.11.0",
18
18
  "immer": "^9.0.12",
19
19
  "lodash": "^4.17.21",