@fileverse-dev/fortune-core 1.0.66 → 1.0.68

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.
@@ -108,6 +108,11 @@ export function setCellValue(ctx, r, c, d, v) {
108
108
  } else if ("f" in cell) {
109
109
  delete cell.f;
110
110
  }
111
+ if (!_.isNil(v.baseCurrency)) {
112
+ cell.baseValue = v.baseValue;
113
+ cell.baseCurrency = v.baseCurrency;
114
+ cell.baseCurrencyPrice = v.baseCurrencyPrice;
115
+ }
111
116
  if (!_.isNil(v.ct)) {
112
117
  cell.ct = v.ct;
113
118
  }
@@ -609,7 +614,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
609
614
  } else {
610
615
  delFunctionGroup(ctx, r, c);
611
616
  curv = _.cloneDeep(((_e = d === null || d === void 0 ? void 0 : d[r]) === null || _e === void 0 ? void 0 : _e[c]) || {});
612
- curv.v = value.toString();
617
+ curv.v = value;
613
618
  delete curv.f;
614
619
  delete curv.spl;
615
620
  var decemialCount_1 = ((_f = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _f === void 0 ? void 0 : _f.toString().includes(".")) ? (_g = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _g === void 0 ? void 0 : _g.toString().split(" ")[0].split(".")[1].length : 0;
@@ -680,8 +685,18 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
680
685
  var coin = (_l = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _l === void 0 ? void 0 : _l.toString().split(" ")[1];
681
686
  if (_typeof(value) === "object" && value.baseValue && !(value === null || value === void 0 ? void 0 : value.m)) {
682
687
  value.m = "".concat((parseFloat(value === null || value === void 0 ? void 0 : value.v) / (oldValue === null || oldValue === void 0 ? void 0 : oldValue.baseCurrencyPrice)).toFixed(decemialCount), " ").concat(coin);
683
- value.baseValue = Number(value === null || value === void 0 ? void 0 : value.v);
684
- value.v = value === null || value === void 0 ? void 0 : value.v.toString();
688
+ }
689
+ if (typeof value === "string") {
690
+ value = {
691
+ "ct": {
692
+ "fa": "General",
693
+ "t": "g"
694
+ },
695
+ "v": value,
696
+ "tb": "1"
697
+ };
698
+ } else if (_typeof(value) === "object" && !value.tb) {
699
+ value.tb = "1";
685
700
  }
686
701
  setCellValue(ctx, r, c, d, value);
687
702
  cancelNormalSelected(ctx);
@@ -706,7 +721,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
706
721
  }
707
722
  }
708
723
  }
709
- if (ctx.hooks.afterUpdateCell) {
724
+ if (!(value === null || value === void 0 ? void 0 : value.baseValue) && ctx.hooks.afterUpdateCell) {
710
725
  var newValue_1 = _.cloneDeep(flowdata[r][c]);
711
726
  var afterUpdateCell_1 = ctx.hooks.afterUpdateCell;
712
727
  setTimeout(function () {
@@ -707,7 +707,12 @@ export function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notIns
707
707
  }
708
708
  if (!_.isNil(r) && !_.isNil(c)) {
709
709
  if (isrefresh) {
710
- execFunctionGroup(ctx, r, c, _.isNil(formulaError) ? result : formulaError, id);
710
+ var finalResult_1 = result;
711
+ if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "") {
712
+ var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
713
+ finalResult_1 = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
714
+ }
715
+ execFunctionGroup(ctx, r, c, _.isNil(formulaError) ? finalResult_1 : formulaError, id);
711
716
  }
712
717
  if (!notInsertFunc) {
713
718
  insertUpdateFunctionGroup(ctx, r, c, id, calcChainSet);
@@ -138,6 +138,11 @@ function setCellValue(ctx, r, c, d, v) {
138
138
  } else if ("f" in cell) {
139
139
  delete cell.f;
140
140
  }
141
+ if (!_lodash.default.isNil(v.baseCurrency)) {
142
+ cell.baseValue = v.baseValue;
143
+ cell.baseCurrency = v.baseCurrency;
144
+ cell.baseCurrencyPrice = v.baseCurrencyPrice;
145
+ }
141
146
  if (!_lodash.default.isNil(v.ct)) {
142
147
  cell.ct = v.ct;
143
148
  }
@@ -639,7 +644,7 @@ function updateCell(ctx, r, c, $input, value, canvas) {
639
644
  } else {
640
645
  (0, _formula.delFunctionGroup)(ctx, r, c);
641
646
  curv = _lodash.default.cloneDeep(((_e = d === null || d === void 0 ? void 0 : d[r]) === null || _e === void 0 ? void 0 : _e[c]) || {});
642
- curv.v = value.toString();
647
+ curv.v = value;
643
648
  delete curv.f;
644
649
  delete curv.spl;
645
650
  var decemialCount_1 = ((_f = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _f === void 0 ? void 0 : _f.toString().includes(".")) ? (_g = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _g === void 0 ? void 0 : _g.toString().split(" ")[0].split(".")[1].length : 0;
@@ -710,8 +715,18 @@ function updateCell(ctx, r, c, $input, value, canvas) {
710
715
  var coin = (_l = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _l === void 0 ? void 0 : _l.toString().split(" ")[1];
711
716
  if (_typeof(value) === "object" && value.baseValue && !(value === null || value === void 0 ? void 0 : value.m)) {
712
717
  value.m = "".concat((parseFloat(value === null || value === void 0 ? void 0 : value.v) / (oldValue === null || oldValue === void 0 ? void 0 : oldValue.baseCurrencyPrice)).toFixed(decemialCount), " ").concat(coin);
713
- value.baseValue = Number(value === null || value === void 0 ? void 0 : value.v);
714
- value.v = value === null || value === void 0 ? void 0 : value.v.toString();
718
+ }
719
+ if (typeof value === "string") {
720
+ value = {
721
+ "ct": {
722
+ "fa": "General",
723
+ "t": "g"
724
+ },
725
+ "v": value,
726
+ "tb": "1"
727
+ };
728
+ } else if (_typeof(value) === "object" && !value.tb) {
729
+ value.tb = "1";
715
730
  }
716
731
  setCellValue(ctx, r, c, d, value);
717
732
  cancelNormalSelected(ctx);
@@ -736,7 +751,7 @@ function updateCell(ctx, r, c, $input, value, canvas) {
736
751
  }
737
752
  }
738
753
  }
739
- if (ctx.hooks.afterUpdateCell) {
754
+ if (!(value === null || value === void 0 ? void 0 : value.baseValue) && ctx.hooks.afterUpdateCell) {
740
755
  var newValue_1 = _lodash.default.cloneDeep(flowdata[r][c]);
741
756
  var afterUpdateCell_1 = ctx.hooks.afterUpdateCell;
742
757
  setTimeout(function () {
@@ -736,7 +736,12 @@ function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notInsertFunc
736
736
  }
737
737
  if (!_lodash.default.isNil(r) && !_lodash.default.isNil(c)) {
738
738
  if (isrefresh) {
739
- execFunctionGroup(ctx, r, c, _lodash.default.isNil(formulaError) ? result : formulaError, id);
739
+ var finalResult_1 = result;
740
+ if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "") {
741
+ var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
742
+ finalResult_1 = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
743
+ }
744
+ execFunctionGroup(ctx, r, c, _lodash.default.isNil(formulaError) ? finalResult_1 : formulaError, id);
740
745
  }
741
746
  if (!notInsertFunc) {
742
747
  insertUpdateFunctionGroup(ctx, r, c, id, calcChainSet);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.0.66",
3
+ "version": "1.0.68",
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.43",
18
+ "@fileverse-dev/formula-parser": "0.2.45",
19
19
  "dayjs": "^1.11.0",
20
20
  "immer": "^9.0.12",
21
21
  "lodash": "^4.17.21",