@fileverse-dev/fortune-core 1.0.68 → 1.0.70

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/es/api/sheet.js CHANGED
@@ -112,15 +112,15 @@ export function copySheet(ctx, sheetId) {
112
112
  api.setSheetOrder(ctx, sheetOrderList);
113
113
  }
114
114
  export function calculateSheetFromula(ctx, id) {
115
- var _a, _b;
115
+ var _a, _b, _c;
116
116
  var index = getSheetIndex(ctx, id);
117
117
  if (!ctx.luckysheetfile[index].data) return;
118
118
  for (var r = 0; r < ctx.luckysheetfile[index].data.length; r += 1) {
119
119
  for (var c = 0; c < ctx.luckysheetfile[index].data[r].length; c += 1) {
120
- if (!((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f)) {
120
+ if (!((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f) || ((_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.isDataBlockFormula)) {
121
121
  continue;
122
122
  }
123
- var result = execfunction(ctx, (_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.f, r, c, id);
123
+ var result = execfunction(ctx, (_c = ctx.luckysheetfile[index].data[r][c]) === null || _c === void 0 ? void 0 : _c.f, r, c, id);
124
124
  api.setCellValue(ctx, r, c, result[1], null);
125
125
  insertUpdateFunctionGroup(ctx, r, c, id);
126
126
  }
@@ -12,7 +12,7 @@ var __assign = this && this.__assign || function () {
12
12
  import _ from "lodash";
13
13
  import { getFlowdata } from "../context";
14
14
  import { locale } from "../locale";
15
- import { delFunctionGroup, execfunction, execFunctionGroup, functionCopy } from "../modules/formula";
15
+ import { execfunction, functionCopy } from "../modules/formula";
16
16
  import { getdatabyselection, getQKBorder } from "../modules/cell";
17
17
  import { genarate, update } from "../modules/format";
18
18
  import { normalizeSelection, selectionCache } from "../modules/selection";
@@ -105,14 +105,12 @@ function postPasteCut(ctx, source, target, RowlChange) {
105
105
  ctx.luckysheetfile[getSheetIndex(ctx, source.sheetId)].dataVerification = source.curDataVerification;
106
106
  ctx.luckysheetfile[getSheetIndex(ctx, target.sheetId)].dataVerification = target.curDataVerification;
107
107
  ctx.formulaCache.execFunctionExist.reverse();
108
- execFunctionGroup(ctx, null, null, null, null, target.curData);
109
108
  ctx.formulaCache.execFunctionGlobalData = null;
110
109
  storeSheetParamALL(ctx);
111
110
  }
112
111
  function pasteHandler(ctx, data, borderInfo) {
113
112
  var _a;
114
113
  var _b, _c, _d, _e, _f, _g;
115
- console.log("pasteHandler", ctx.isFlvReadOnly);
116
114
  var allowEdit = isAllowEdit(ctx);
117
115
  if (!allowEdit || ctx.isFlvReadOnly) return;
118
116
  if (((_c = (_b = ctx.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) !== 1) {
@@ -273,7 +271,6 @@ function pasteHandler(ctx, data, borderInfo) {
273
271
  }
274
272
  if (originCell.f != null && originCell.f.length > 0) {
275
273
  originCell.f = "";
276
- delFunctionGroup(ctx, r + curR, c + curC, ctx.currentSheetId);
277
274
  }
278
275
  } else {
279
276
  var cell = {};
@@ -858,6 +855,9 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
858
855
  var value = null;
859
856
  if ((_f = copyData[h - mth]) === null || _f === void 0 ? void 0 : _f[c - mtc]) {
860
857
  value = _.cloneDeep(copyData[h - mth][c - mtc]);
858
+ if ((value === null || value === void 0 ? void 0 : value.v) && (value === null || value === void 0 ? void 0 : value.isDataBlockFormula) && arr.length === 1) {
859
+ value.m = "Loading...";
860
+ }
861
861
  }
862
862
  if (!_.isNil(value) && !_.isNil(value.f)) {
863
863
  var func = value.f;
@@ -874,14 +874,15 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
874
874
  func = "=".concat(functionCopy(ctx, func, "left", Math.abs(offsetCol)));
875
875
  }
876
876
  var funcV = execfunction(ctx, func, h, c, undefined, undefined, true);
877
- if (!_.isNil(value.spl)) {} else {
878
- value.v = funcV[1], value.f = funcV[2];
879
- if (!_.isNil(value.ct) && !_.isNil(value.ct.fa)) {
880
- value.m = update(value.ct.fa, funcV[1]);
881
- } else {
882
- value.m = update("General", funcV[1]);
883
- }
877
+ var afterUpdateCell = ctx.hooks.afterUpdateCell;
878
+ console.log("fortune about to call afterUpdateCell");
879
+ if (afterUpdateCell && arr.length === 1) {
880
+ afterUpdateCell(h, c, null, __assign(__assign({}, value), {
881
+ v: funcV[1],
882
+ m: "[object Promise]"
883
+ }));
884
884
  }
885
+ if (!_.isNil(value.spl)) {}
885
886
  }
886
887
  x[c] = _.cloneDeep(value);
887
888
  if (value != null && copyHasMC && ((_g = x === null || x === void 0 ? void 0 : x[c]) === null || _g === void 0 ? void 0 : _g.mc)) {
@@ -970,12 +971,25 @@ function handleFormulaStringPaste(ctx, formulaStr) {
970
971
  var c = ctx.luckysheet_select_save[0].column[0];
971
972
  var funcV = execfunction(ctx, formulaStr, r, c, undefined, undefined, true);
972
973
  var val = funcV[1];
974
+ var isDataBlockRespose = typeof val !== "string" && typeof val !== "number";
973
975
  var d = getFlowdata(ctx);
974
976
  if (!d) return;
975
977
  if (!d[r][c]) d[r][c] = {};
976
- d[r][c].m = val.toString();
978
+ d[r][c].m = isDataBlockRespose ? "Loading..." : val.toString();
977
979
  d[r][c].v = val;
978
980
  d[r][c].f = formulaStr;
981
+ var cellTemp = {
982
+ m: "",
983
+ v: "",
984
+ f: ""
985
+ };
986
+ cellTemp.m = isDataBlockRespose ? "Loading..." : val.toString();
987
+ cellTemp.v = val;
988
+ cellTemp.f = formulaStr;
989
+ var afterUpdateCell = ctx.hooks.afterUpdateCell;
990
+ if (afterUpdateCell && isDataBlockRespose) {
991
+ afterUpdateCell(r, c, null, cellTemp);
992
+ }
979
993
  }
980
994
  export function handlePaste(ctx, e) {
981
995
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
@@ -688,12 +688,12 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
688
688
  }
689
689
  if (typeof value === "string") {
690
690
  value = {
691
- "ct": {
692
- "fa": "General",
693
- "t": "g"
691
+ ct: {
692
+ fa: "General",
693
+ t: "g"
694
694
  },
695
- "v": value,
696
- "tb": "1"
695
+ v: value,
696
+ tb: "1"
697
697
  };
698
698
  } else if (_typeof(value) === "object" && !value.tb) {
699
699
  value.tb = "1";
@@ -121,8 +121,8 @@ var FormulaCache = function () {
121
121
  }
122
122
  FormulaCache.prototype.tryGetCellAsNumber = function (cell) {
123
123
  var _a, _b, _c, _d;
124
- var isCryptoDeno = ((_a = cell === null || cell === void 0 ? void 0 : cell.m) === null || _a === void 0 ? void 0 : _a.includes("ETH")) || ((_b = cell === null || cell === void 0 ? void 0 : cell.m) === null || _b === void 0 ? void 0 : _b.includes("SOL")) || ((_c = cell === null || cell === void 0 ? void 0 : cell.m) === null || _c === void 0 ? void 0 : _c.includes("BTC"));
125
- if (isCryptoDeno) {
124
+ var isCryptoDeno = typeof (cell === null || cell === void 0 ? void 0 : cell.m) === "string" ? ((_a = cell === null || cell === void 0 ? void 0 : cell.m) === null || _a === void 0 ? void 0 : _a.includes("ETH")) || ((_b = cell === null || cell === void 0 ? void 0 : cell.m) === null || _b === void 0 ? void 0 : _b.includes("SOL")) || ((_c = cell === null || cell === void 0 ? void 0 : cell.m) === null || _c === void 0 ? void 0 : _c.includes("BTC")) : false;
125
+ if (isCryptoDeno && typeof (cell === null || cell === void 0 ? void 0 : cell.m) === "string") {
126
126
  var splitedNumberString = cell.m.split(" ")[0];
127
127
  return Number(splitedNumberString);
128
128
  }
@@ -708,7 +708,7 @@ export function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notIns
708
708
  if (!_.isNil(r) && !_.isNil(c)) {
709
709
  if (isrefresh) {
710
710
  var finalResult_1 = result;
711
- if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "") {
711
+ if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "" && (typeof result === "number" || typeof result === "string")) {
712
712
  var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
713
713
  finalResult_1 = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
714
714
  }
@@ -719,7 +719,7 @@ export function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notIns
719
719
  }
720
720
  }
721
721
  var finalResult = result;
722
- if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "") {
722
+ if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "" && (typeof result === "number" || typeof result === "string")) {
723
723
  var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
724
724
  finalResult = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
725
725
  }
package/es/types.d.ts CHANGED
@@ -45,6 +45,10 @@ export type Cell = {
45
45
  bg?: string;
46
46
  lo?: number;
47
47
  rt?: number;
48
+ baseValue?: number | string;
49
+ baseCurrency?: string;
50
+ baseCurrencyPrice?: string | number;
51
+ isDataBlockFormula?: boolean;
48
52
  ps?: {
49
53
  left: number | null;
50
54
  top: number | null;
package/lib/api/sheet.js CHANGED
@@ -129,15 +129,15 @@ function copySheet(ctx, sheetId) {
129
129
  _2.api.setSheetOrder(ctx, sheetOrderList);
130
130
  }
131
131
  function calculateSheetFromula(ctx, id) {
132
- var _a, _b;
132
+ var _a, _b, _c;
133
133
  var index = (0, _utils.getSheetIndex)(ctx, id);
134
134
  if (!ctx.luckysheetfile[index].data) return;
135
135
  for (var r = 0; r < ctx.luckysheetfile[index].data.length; r += 1) {
136
136
  for (var c = 0; c < ctx.luckysheetfile[index].data[r].length; c += 1) {
137
- if (!((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f)) {
137
+ if (!((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f) || ((_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.isDataBlockFormula)) {
138
138
  continue;
139
139
  }
140
- var result = (0, _2.execfunction)(ctx, (_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.f, r, c, id);
140
+ var result = (0, _2.execfunction)(ctx, (_c = ctx.luckysheetfile[index].data[r][c]) === null || _c === void 0 ? void 0 : _c.f, r, c, id);
141
141
  _2.api.setCellValue(ctx, r, c, result[1], null);
142
142
  (0, _2.insertUpdateFunctionGroup)(ctx, r, c, id);
143
143
  }
@@ -113,14 +113,12 @@ function postPasteCut(ctx, source, target, RowlChange) {
113
113
  ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, source.sheetId)].dataVerification = source.curDataVerification;
114
114
  ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, target.sheetId)].dataVerification = target.curDataVerification;
115
115
  ctx.formulaCache.execFunctionExist.reverse();
116
- (0, _formula.execFunctionGroup)(ctx, null, null, null, null, target.curData);
117
116
  ctx.formulaCache.execFunctionGlobalData = null;
118
117
  (0, _sheet.storeSheetParamALL)(ctx);
119
118
  }
120
119
  function pasteHandler(ctx, data, borderInfo) {
121
120
  var _a;
122
121
  var _b, _c, _d, _e, _f, _g;
123
- console.log("pasteHandler", ctx.isFlvReadOnly);
124
122
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
125
123
  if (!allowEdit || ctx.isFlvReadOnly) return;
126
124
  if (((_c = (_b = ctx.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) !== 1) {
@@ -281,7 +279,6 @@ function pasteHandler(ctx, data, borderInfo) {
281
279
  }
282
280
  if (originCell.f != null && originCell.f.length > 0) {
283
281
  originCell.f = "";
284
- (0, _formula.delFunctionGroup)(ctx, r + curR, c + curC, ctx.currentSheetId);
285
282
  }
286
283
  } else {
287
284
  var cell = {};
@@ -866,6 +863,9 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
866
863
  var value = null;
867
864
  if ((_f = copyData[h - mth]) === null || _f === void 0 ? void 0 : _f[c - mtc]) {
868
865
  value = _lodash.default.cloneDeep(copyData[h - mth][c - mtc]);
866
+ if ((value === null || value === void 0 ? void 0 : value.v) && (value === null || value === void 0 ? void 0 : value.isDataBlockFormula) && arr.length === 1) {
867
+ value.m = "Loading...";
868
+ }
869
869
  }
870
870
  if (!_lodash.default.isNil(value) && !_lodash.default.isNil(value.f)) {
871
871
  var func = value.f;
@@ -882,14 +882,15 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
882
882
  func = "=".concat((0, _formula.functionCopy)(ctx, func, "left", Math.abs(offsetCol)));
883
883
  }
884
884
  var funcV = (0, _formula.execfunction)(ctx, func, h, c, undefined, undefined, true);
885
- if (!_lodash.default.isNil(value.spl)) {} else {
886
- value.v = funcV[1], value.f = funcV[2];
887
- if (!_lodash.default.isNil(value.ct) && !_lodash.default.isNil(value.ct.fa)) {
888
- value.m = (0, _format.update)(value.ct.fa, funcV[1]);
889
- } else {
890
- value.m = (0, _format.update)("General", funcV[1]);
891
- }
885
+ var afterUpdateCell = ctx.hooks.afterUpdateCell;
886
+ console.log("fortune about to call afterUpdateCell");
887
+ if (afterUpdateCell && arr.length === 1) {
888
+ afterUpdateCell(h, c, null, __assign(__assign({}, value), {
889
+ v: funcV[1],
890
+ m: "[object Promise]"
891
+ }));
892
892
  }
893
+ if (!_lodash.default.isNil(value.spl)) {}
893
894
  }
894
895
  x[c] = _lodash.default.cloneDeep(value);
895
896
  if (value != null && copyHasMC && ((_g = x === null || x === void 0 ? void 0 : x[c]) === null || _g === void 0 ? void 0 : _g.mc)) {
@@ -978,12 +979,25 @@ function handleFormulaStringPaste(ctx, formulaStr) {
978
979
  var c = ctx.luckysheet_select_save[0].column[0];
979
980
  var funcV = (0, _formula.execfunction)(ctx, formulaStr, r, c, undefined, undefined, true);
980
981
  var val = funcV[1];
982
+ var isDataBlockRespose = typeof val !== "string" && typeof val !== "number";
981
983
  var d = (0, _context.getFlowdata)(ctx);
982
984
  if (!d) return;
983
985
  if (!d[r][c]) d[r][c] = {};
984
- d[r][c].m = val.toString();
986
+ d[r][c].m = isDataBlockRespose ? "Loading..." : val.toString();
985
987
  d[r][c].v = val;
986
988
  d[r][c].f = formulaStr;
989
+ var cellTemp = {
990
+ m: "",
991
+ v: "",
992
+ f: ""
993
+ };
994
+ cellTemp.m = isDataBlockRespose ? "Loading..." : val.toString();
995
+ cellTemp.v = val;
996
+ cellTemp.f = formulaStr;
997
+ var afterUpdateCell = ctx.hooks.afterUpdateCell;
998
+ if (afterUpdateCell && isDataBlockRespose) {
999
+ afterUpdateCell(r, c, null, cellTemp);
1000
+ }
987
1001
  }
988
1002
  function handlePaste(ctx, e) {
989
1003
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
@@ -718,12 +718,12 @@ function updateCell(ctx, r, c, $input, value, canvas) {
718
718
  }
719
719
  if (typeof value === "string") {
720
720
  value = {
721
- "ct": {
722
- "fa": "General",
723
- "t": "g"
721
+ ct: {
722
+ fa: "General",
723
+ t: "g"
724
724
  },
725
- "v": value,
726
- "tb": "1"
725
+ v: value,
726
+ tb: "1"
727
727
  };
728
728
  } else if (_typeof(value) === "object" && !value.tb) {
729
729
  value.tb = "1";
@@ -151,8 +151,8 @@ var FormulaCache = exports.FormulaCache = function () {
151
151
  }
152
152
  FormulaCache.prototype.tryGetCellAsNumber = function (cell) {
153
153
  var _a, _b, _c, _d;
154
- var isCryptoDeno = ((_a = cell === null || cell === void 0 ? void 0 : cell.m) === null || _a === void 0 ? void 0 : _a.includes("ETH")) || ((_b = cell === null || cell === void 0 ? void 0 : cell.m) === null || _b === void 0 ? void 0 : _b.includes("SOL")) || ((_c = cell === null || cell === void 0 ? void 0 : cell.m) === null || _c === void 0 ? void 0 : _c.includes("BTC"));
155
- if (isCryptoDeno) {
154
+ var isCryptoDeno = typeof (cell === null || cell === void 0 ? void 0 : cell.m) === "string" ? ((_a = cell === null || cell === void 0 ? void 0 : cell.m) === null || _a === void 0 ? void 0 : _a.includes("ETH")) || ((_b = cell === null || cell === void 0 ? void 0 : cell.m) === null || _b === void 0 ? void 0 : _b.includes("SOL")) || ((_c = cell === null || cell === void 0 ? void 0 : cell.m) === null || _c === void 0 ? void 0 : _c.includes("BTC")) : false;
155
+ if (isCryptoDeno && typeof (cell === null || cell === void 0 ? void 0 : cell.m) === "string") {
156
156
  var splitedNumberString = cell.m.split(" ")[0];
157
157
  return Number(splitedNumberString);
158
158
  }
@@ -737,7 +737,7 @@ function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notInsertFunc
737
737
  if (!_lodash.default.isNil(r) && !_lodash.default.isNil(c)) {
738
738
  if (isrefresh) {
739
739
  var finalResult_1 = result;
740
- if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "") {
740
+ if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "" && (typeof result === "number" || typeof result === "string")) {
741
741
  var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
742
742
  finalResult_1 = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
743
743
  }
@@ -748,7 +748,7 @@ function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notInsertFunc
748
748
  }
749
749
  }
750
750
  var finalResult = result;
751
- if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "") {
751
+ if (ctx.formulaCache.parser.cryptoDenomination && ctx.formulaCache.parser.cryptoDenomination !== "" && (typeof result === "number" || typeof result === "string")) {
752
752
  var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
753
753
  finalResult = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
754
754
  }
package/lib/types.d.ts CHANGED
@@ -45,6 +45,10 @@ export type Cell = {
45
45
  bg?: string;
46
46
  lo?: number;
47
47
  rt?: number;
48
+ baseValue?: number | string;
49
+ baseCurrency?: string;
50
+ baseCurrencyPrice?: string | number;
51
+ isDataBlockFormula?: boolean;
48
52
  ps?: {
49
53
  left: number | null;
50
54
  top: number | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.0.68",
3
+ "version": "1.0.70",
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.45",
18
+ "@fileverse-dev/formula-parser": "0.2.47",
19
19
  "dayjs": "^1.11.0",
20
20
  "immer": "^9.0.12",
21
21
  "lodash": "^4.17.21",