@fileverse-dev/fortune-core 1.1.65 → 1.1.66-error-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.
package/es/api/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export * from "./range";
7
7
  export * from "./merge";
8
8
  export * from "./sheet";
9
9
  export * from "./workbook";
10
+ export * from "../modules/error-state-helpers";
package/es/api/index.js CHANGED
@@ -5,4 +5,5 @@ export * from "./rowcol";
5
5
  export * from "./range";
6
6
  export * from "./merge";
7
7
  export * from "./sheet";
8
- export * from "./workbook";
8
+ export * from "./workbook";
9
+ export * from "../modules/error-state-helpers";
package/es/canvas.js CHANGED
@@ -1121,6 +1121,31 @@ var Canvas = function () {
1121
1121
  endX: cellsize[2] + cellsize[0],
1122
1122
  endY: cellsize[3] + cellsize[1]
1123
1123
  }, renderCtx);
1124
+ if (cell === null || cell === void 0 ? void 0 : cell.error) {
1125
+ var errorColor = "#FB3449";
1126
+ var bw = 1;
1127
+ var L = Math.round(startX + offsetLeft - 1 + bodrder05);
1128
+ var T = Math.round(startY + offsetTop - 1 + bodrder05);
1129
+ var R = Math.round(endX + offsetLeft - 2 + bodrder05);
1130
+ var B = Math.round(endY + offsetTop - 2 + bodrder05);
1131
+ var wInside = R - L;
1132
+ var hInside = B - T;
1133
+ var ctx2 = renderCtx;
1134
+ ctx2.save();
1135
+ ctx2.fillStyle = errorColor;
1136
+ ctx2.fillRect(L, T, wInside, bw);
1137
+ ctx2.fillRect(L, B - bw, wInside, bw);
1138
+ ctx2.fillRect(L, T, bw, hInside);
1139
+ ctx2.fillRect(R - bw, T, bw, hInside);
1140
+ var ribbon = 8 * this.sheetCtx.zoomRatio;
1141
+ ctx2.beginPath();
1142
+ ctx2.moveTo(L + bw, T + bw);
1143
+ ctx2.lineTo(L + bw + ribbon, T + bw);
1144
+ ctx2.lineTo(L + bw, T + bw + ribbon);
1145
+ ctx2.closePath();
1146
+ ctx2.fill();
1147
+ ctx2.restore();
1148
+ }
1124
1149
  };
1125
1150
  Canvas.prototype.cellOverflowRender = function (r, c, stc, edc, renderCtx, scrollHeight, scrollWidth, offsetLeft, offsetTop, afCompute, cfCompute) {
1126
1151
  var startY;
package/es/context.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { SheetConfig } from ".";
2
2
  import { FormulaCache } from "./modules";
3
3
  import { Hooks } from "./settings";
4
- import { Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache } from "./types";
4
+ import { Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache, CellError } from "./types";
5
5
  interface MutableRefObject<T> {
6
6
  current: T;
7
7
  }
@@ -21,8 +21,10 @@ export type Context = {
21
21
  fullscreenmode: boolean;
22
22
  devicePixelRatio: number;
23
23
  commentBoxes?: CommentBox[];
24
+ errorBoxes?: CellError[];
24
25
  editingCommentBox?: CommentBox;
25
26
  hoveredCommentBox?: CommentBox;
27
+ hoverErrorBox?: CellError;
26
28
  insertedImgs?: Image[];
27
29
  editingInsertedImgs?: Image;
28
30
  activeImg?: string;
@@ -1,6 +1,6 @@
1
1
  import _ from "lodash";
2
2
  import { getFlowdata } from "../context";
3
- import { cancelActiveImgItem, cancelPaintModel, functionHTMLGenerate, israngeseleciton, rangeHightlightselected, rangeSetValue, onCommentBoxMove, onCommentBoxMoveEnd, onCommentBoxResize, onCommentBoxResizeEnd, onImageMove, onImageMoveEnd, onImageResize, onImageResizeEnd, removeEditingComment, overShowComment, removeOverShowComment, rangeDrag, onFormulaRangeDragEnd, createFormulaRangeSelect, createRangeHightlight, onCellsMoveEnd, onCellsMove, cellFocus, editComment, onIframeMoveEnd, onIframeResizeEnd } from "../modules";
3
+ import { cancelActiveImgItem, cancelPaintModel, functionHTMLGenerate, israngeseleciton, rangeHightlightselected, rangeSetValue, onCommentBoxMove, onCommentBoxMoveEnd, onCommentBoxResize, onCommentBoxResizeEnd, onImageMove, onImageMoveEnd, onImageResize, onImageResizeEnd, removeEditingComment, overShowComment, removeOverShowComment, rangeDrag, onFormulaRangeDragEnd, createFormulaRangeSelect, createRangeHightlight, onCellsMoveEnd, onCellsMove, cellFocus, editComment, onIframeMoveEnd, onIframeResizeEnd, overShowError } from "../modules";
4
4
  import { getFrozenHandleLeft, getFrozenHandleTop, scrollToFrozenRowCol } from "../modules/freeze";
5
5
  import { cancelFunctionrangeSelected, mergeBorder, mergeMoveMain, updateCell, luckysheetUpdateCell } from "../modules/cell";
6
6
  import { colLocation, colLocationByIndex, rowLocation, rowLocationByIndex } from "../modules/location";
@@ -899,6 +899,7 @@ export function handleOverlayMouseMove(ctx, globalCache, e, cellInput, scrollX,
899
899
  if (onImageResize(ctx, globalCache, e)) return;
900
900
  onCellsMove(ctx, globalCache, e, scrollX, scrollY, container);
901
901
  overShowComment(ctx, e, scrollX, scrollY, container);
902
+ overShowError(ctx, e, scrollX, scrollY, container);
902
903
  onSearchDialogMove(globalCache, e);
903
904
  onRangeSelectionModalMove(globalCache, e);
904
905
  if (!!ctx.luckysheet_scroll_status || !!ctx.luckysheet_select_status || !!ctx.luckysheet_rows_selected_status || !!ctx.luckysheet_cols_selected_status || !!ctx.luckysheet_cell_selected_move || !!ctx.luckysheet_cell_selected_extend || !!ctx.luckysheet_cols_change_size || !!ctx.luckysheet_rows_change_size) {
@@ -0,0 +1,9 @@
1
+ import { Context } from "../context";
2
+ import { CellError } from "../types";
3
+ export declare function overShowError(ctx: Context, e: MouseEvent, scrollX: HTMLDivElement, scrollY: HTMLDivElement, container: HTMLDivElement): void;
4
+ export declare function setCellError(ctx: Context, r: number, c: number, err: CellError): void;
5
+ export declare function clearCellError(ctx: Context, r: number, c: number): void;
6
+ export declare function showErrors(ctx: Context, errorShowCells: {
7
+ r: number;
8
+ c: number;
9
+ }[]): void;
@@ -0,0 +1,86 @@
1
+ var __assign = this && this.__assign || function () {
2
+ __assign = Object.assign || function (t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
6
+ }
7
+ return t;
8
+ };
9
+ return __assign.apply(this, arguments);
10
+ };
11
+ import _ from "lodash";
12
+ import { getFlowdata } from "../context";
13
+ import { getCommentBoxByRC } from "./comment";
14
+ import { colLocation, rowLocation } from "./location";
15
+ import { mergeBorder } from "./cell";
16
+ export function overShowError(ctx, e, scrollX, scrollY, container) {
17
+ var _a, _b, _c;
18
+ var _d, _e, _f, _g;
19
+ var flowdata = getFlowdata(ctx);
20
+ if (!flowdata) return;
21
+ var scrollLeft = scrollX.scrollLeft;
22
+ var scrollTop = scrollY.scrollTop;
23
+ var rect = container.getBoundingClientRect();
24
+ var x = e.pageX - rect.left - ctx.rowHeaderWidth + scrollLeft;
25
+ var y = e.pageY - rect.top - ctx.columnHeaderHeight + scrollTop;
26
+ var r = rowLocation(y, ctx.visibledatarow)[2];
27
+ var c = colLocation(x, ctx.visibledatacolumn)[2];
28
+ var merge = mergeBorder(ctx, flowdata, r, c);
29
+ if (merge) {
30
+ _a = merge.row, r = _a[2];
31
+ _b = merge.column, c = _b[2];
32
+ }
33
+ var row_column = "".concat(r, "_").concat(c);
34
+ var cell = (_d = flowdata[r]) === null || _d === void 0 ? void 0 : _d[c];
35
+ var err = cell === null || cell === void 0 ? void 0 : cell.error;
36
+ var errorAlreadyListed = Array.isArray(ctx.errorBoxes) ? _.findIndex(ctx.errorBoxes, function (v) {
37
+ return v.row_column === row_column;
38
+ }) !== -1 : false;
39
+ if (!err || errorAlreadyListed) {
40
+ ctx.hoverErrorBox = undefined;
41
+ return;
42
+ }
43
+ if (((_e = ctx.hoverErrorBox) === null || _e === void 0 ? void 0 : _e.row_column) === row_column) return;
44
+ var rowTop = r - 1 === -1 ? 0 : ctx.visibledatarow[r - 1];
45
+ var colLeft = ctx.visibledatacolumn[c];
46
+ if (merge) {
47
+ rowTop = merge.row[0];
48
+ _c = merge.column, colLeft = _c[1];
49
+ }
50
+ var toX = colLeft;
51
+ var toY = rowTop;
52
+ var zoom = ctx.zoomRatio;
53
+ var left = err.left == null ? toX + 8 * zoom : err.left * zoom;
54
+ var top = err.top == null ? toY - 2 * zoom : err.top * zoom;
55
+ if (top < 0) top = 2;
56
+ ctx.hoverErrorBox = {
57
+ row_column: row_column,
58
+ left: left,
59
+ top: top,
60
+ title: ((_f = cell.error) === null || _f === void 0 ? void 0 : _f.title) || "Error",
61
+ message: ((_g = cell.error) === null || _g === void 0 ? void 0 : _g.message) || "Default error message"
62
+ };
63
+ }
64
+ export function setCellError(ctx, r, c, err) {
65
+ var flow = getFlowdata(ctx);
66
+ if (!flow) return;
67
+ if (!flow[r]) flow[r] = [];
68
+ if (!flow[r][c]) flow[r][c] = {};
69
+ flow[r][c].error = __assign({}, err);
70
+ }
71
+ export function clearCellError(ctx, r, c) {
72
+ var _a;
73
+ var flow = getFlowdata(ctx);
74
+ if (!((_a = flow === null || flow === void 0 ? void 0 : flow[r]) === null || _a === void 0 ? void 0 : _a[c])) return;
75
+ delete flow[r][c].error;
76
+ }
77
+ export function showErrors(ctx, errorShowCells) {
78
+ var flowdata = getFlowdata(ctx);
79
+ if (!flowdata) return;
80
+ var errorBoxes = errorShowCells.map(function (_a) {
81
+ var r = _a.r,
82
+ c = _a.c;
83
+ return getCommentBoxByRC(ctx, flowdata, r, c);
84
+ });
85
+ ctx.errorBoxes = errorBoxes;
86
+ }
@@ -27,7 +27,7 @@ import { error } from "./validation";
27
27
  import { locale } from "../locale";
28
28
  import { colors } from "./color";
29
29
  import { colLocation, mousePosition, rowLocation } from "./location";
30
- import { cancelFunctionrangeSelected, seletedHighlistByindex, spillSortResult } from ".";
30
+ import { cancelFunctionrangeSelected, clearCellError, seletedHighlistByindex, setCellError, spillSortResult } from ".";
31
31
  import { isLetterNumberPattern, removeLastSpan } from "../utils/index";
32
32
  var functionHTMLIndex = 0;
33
33
  var rangeIndexes = [];
@@ -729,7 +729,17 @@ export function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notIns
729
729
  var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
730
730
  finalResult = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
731
731
  }
732
- return [true, _.isNil(formulaError) ? finalResult : formulaError, txt];
732
+ var isError = !_.isNil(formulaError);
733
+ if (isError) {
734
+ setCellError(ctx, r, c, {
735
+ row_column: "".concat(r, "_").concat(c),
736
+ title: "Error",
737
+ message: (formulaError === null || formulaError === void 0 ? void 0 : formulaError.toString()) || "Unknown Error"
738
+ });
739
+ } else {
740
+ clearCellError(ctx, r, c);
741
+ }
742
+ return [true, !isError ? finalResult : formulaError, txt];
733
743
  }
734
744
  function insertUpdateDynamicArray(ctx, dynamicArrayItem) {
735
745
  var r = dynamicArrayItem.r,
@@ -34,3 +34,4 @@ export * from "./ConditionFormat";
34
34
  export * from "./zoom";
35
35
  export * from "./refresh";
36
36
  export * from "./iframe";
37
+ export * from "./error-state-helpers";
@@ -33,4 +33,5 @@ export * from "./dataVerification";
33
33
  export * from "./ConditionFormat";
34
34
  export * from "./zoom";
35
35
  export * from "./refresh";
36
- export * from "./iframe";
36
+ export * from "./iframe";
37
+ export * from "./error-state-helpers";
package/es/types.d.ts CHANGED
@@ -25,6 +25,13 @@ export type CellStyle = {
25
25
  un?: number;
26
26
  tr?: string;
27
27
  };
28
+ export type CellError = {
29
+ title: string;
30
+ message: string;
31
+ left?: number;
32
+ top?: number;
33
+ row_column?: string;
34
+ };
28
35
  export type Cell = {
29
36
  v?: string | number | boolean;
30
37
  m?: string | number;
@@ -62,6 +69,7 @@ export type Cell = {
62
69
  c: number;
63
70
  id: string;
64
71
  };
72
+ error?: CellError;
65
73
  } & CellStyle;
66
74
  export type CellWithRowAndCol = {
67
75
  r: number;
@@ -7,3 +7,4 @@ export * from "./range";
7
7
  export * from "./merge";
8
8
  export * from "./sheet";
9
9
  export * from "./workbook";
10
+ export * from "../modules/error-state-helpers";
package/lib/api/index.js CHANGED
@@ -98,4 +98,16 @@ Object.keys(_workbook).forEach(function (key) {
98
98
  return _workbook[key];
99
99
  }
100
100
  });
101
+ });
102
+ var _errorStateHelpers = require("../modules/error-state-helpers");
103
+ Object.keys(_errorStateHelpers).forEach(function (key) {
104
+ if (key === "default" || key === "__esModule") return;
105
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
106
+ if (key in exports && exports[key] === _errorStateHelpers[key]) return;
107
+ Object.defineProperty(exports, key, {
108
+ enumerable: true,
109
+ get: function get() {
110
+ return _errorStateHelpers[key];
111
+ }
112
+ });
101
113
  });
package/lib/canvas.js CHANGED
@@ -1128,6 +1128,31 @@ var Canvas = exports.Canvas = function () {
1128
1128
  endX: cellsize[2] + cellsize[0],
1129
1129
  endY: cellsize[3] + cellsize[1]
1130
1130
  }, renderCtx);
1131
+ if (cell === null || cell === void 0 ? void 0 : cell.error) {
1132
+ var errorColor = "#FB3449";
1133
+ var bw = 1;
1134
+ var L = Math.round(startX + offsetLeft - 1 + bodrder05);
1135
+ var T = Math.round(startY + offsetTop - 1 + bodrder05);
1136
+ var R = Math.round(endX + offsetLeft - 2 + bodrder05);
1137
+ var B = Math.round(endY + offsetTop - 2 + bodrder05);
1138
+ var wInside = R - L;
1139
+ var hInside = B - T;
1140
+ var ctx2 = renderCtx;
1141
+ ctx2.save();
1142
+ ctx2.fillStyle = errorColor;
1143
+ ctx2.fillRect(L, T, wInside, bw);
1144
+ ctx2.fillRect(L, B - bw, wInside, bw);
1145
+ ctx2.fillRect(L, T, bw, hInside);
1146
+ ctx2.fillRect(R - bw, T, bw, hInside);
1147
+ var ribbon = 8 * this.sheetCtx.zoomRatio;
1148
+ ctx2.beginPath();
1149
+ ctx2.moveTo(L + bw, T + bw);
1150
+ ctx2.lineTo(L + bw + ribbon, T + bw);
1151
+ ctx2.lineTo(L + bw, T + bw + ribbon);
1152
+ ctx2.closePath();
1153
+ ctx2.fill();
1154
+ ctx2.restore();
1155
+ }
1131
1156
  };
1132
1157
  Canvas.prototype.cellOverflowRender = function (r, c, stc, edc, renderCtx, scrollHeight, scrollWidth, offsetLeft, offsetTop, afCompute, cfCompute) {
1133
1158
  var startY;
package/lib/context.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { SheetConfig } from ".";
2
2
  import { FormulaCache } from "./modules";
3
3
  import { Hooks } from "./settings";
4
- import { Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache } from "./types";
4
+ import { Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache, CellError } from "./types";
5
5
  interface MutableRefObject<T> {
6
6
  current: T;
7
7
  }
@@ -21,8 +21,10 @@ export type Context = {
21
21
  fullscreenmode: boolean;
22
22
  devicePixelRatio: number;
23
23
  commentBoxes?: CommentBox[];
24
+ errorBoxes?: CellError[];
24
25
  editingCommentBox?: CommentBox;
25
26
  hoveredCommentBox?: CommentBox;
27
+ hoverErrorBox?: CellError;
26
28
  insertedImgs?: Image[];
27
29
  editingInsertedImgs?: Image;
28
30
  activeImg?: string;
@@ -918,6 +918,7 @@ function handleOverlayMouseMove(ctx, globalCache, e, cellInput, scrollX, scrollY
918
918
  if ((0, _modules.onImageResize)(ctx, globalCache, e)) return;
919
919
  (0, _modules.onCellsMove)(ctx, globalCache, e, scrollX, scrollY, container);
920
920
  (0, _modules.overShowComment)(ctx, e, scrollX, scrollY, container);
921
+ (0, _modules.overShowError)(ctx, e, scrollX, scrollY, container);
921
922
  (0, _searchReplace.onSearchDialogMove)(globalCache, e);
922
923
  (0, _hyperlink.onRangeSelectionModalMove)(globalCache, e);
923
924
  if (!!ctx.luckysheet_scroll_status || !!ctx.luckysheet_select_status || !!ctx.luckysheet_rows_selected_status || !!ctx.luckysheet_cols_selected_status || !!ctx.luckysheet_cell_selected_move || !!ctx.luckysheet_cell_selected_extend || !!ctx.luckysheet_cols_change_size || !!ctx.luckysheet_rows_change_size) {
@@ -0,0 +1,9 @@
1
+ import { Context } from "../context";
2
+ import { CellError } from "../types";
3
+ export declare function overShowError(ctx: Context, e: MouseEvent, scrollX: HTMLDivElement, scrollY: HTMLDivElement, container: HTMLDivElement): void;
4
+ export declare function setCellError(ctx: Context, r: number, c: number, err: CellError): void;
5
+ export declare function clearCellError(ctx: Context, r: number, c: number): void;
6
+ export declare function showErrors(ctx: Context, errorShowCells: {
7
+ r: number;
8
+ c: number;
9
+ }[]): void;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.clearCellError = clearCellError;
7
+ exports.overShowError = overShowError;
8
+ exports.setCellError = setCellError;
9
+ exports.showErrors = showErrors;
10
+ var _lodash = _interopRequireDefault(require("lodash"));
11
+ var _context = require("../context");
12
+ var _comment = require("./comment");
13
+ var _location = require("./location");
14
+ var _cell = require("./cell");
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ var __assign = void 0 && (void 0).__assign || function () {
17
+ __assign = Object.assign || function (t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
21
+ }
22
+ return t;
23
+ };
24
+ return __assign.apply(this, arguments);
25
+ };
26
+ function overShowError(ctx, e, scrollX, scrollY, container) {
27
+ var _a, _b, _c;
28
+ var _d, _e, _f, _g;
29
+ var flowdata = (0, _context.getFlowdata)(ctx);
30
+ if (!flowdata) return;
31
+ var scrollLeft = scrollX.scrollLeft;
32
+ var scrollTop = scrollY.scrollTop;
33
+ var rect = container.getBoundingClientRect();
34
+ var x = e.pageX - rect.left - ctx.rowHeaderWidth + scrollLeft;
35
+ var y = e.pageY - rect.top - ctx.columnHeaderHeight + scrollTop;
36
+ var r = (0, _location.rowLocation)(y, ctx.visibledatarow)[2];
37
+ var c = (0, _location.colLocation)(x, ctx.visibledatacolumn)[2];
38
+ var merge = (0, _cell.mergeBorder)(ctx, flowdata, r, c);
39
+ if (merge) {
40
+ _a = merge.row, r = _a[2];
41
+ _b = merge.column, c = _b[2];
42
+ }
43
+ var row_column = "".concat(r, "_").concat(c);
44
+ var cell = (_d = flowdata[r]) === null || _d === void 0 ? void 0 : _d[c];
45
+ var err = cell === null || cell === void 0 ? void 0 : cell.error;
46
+ var errorAlreadyListed = Array.isArray(ctx.errorBoxes) ? _lodash.default.findIndex(ctx.errorBoxes, function (v) {
47
+ return v.row_column === row_column;
48
+ }) !== -1 : false;
49
+ if (!err || errorAlreadyListed) {
50
+ ctx.hoverErrorBox = undefined;
51
+ return;
52
+ }
53
+ if (((_e = ctx.hoverErrorBox) === null || _e === void 0 ? void 0 : _e.row_column) === row_column) return;
54
+ var rowTop = r - 1 === -1 ? 0 : ctx.visibledatarow[r - 1];
55
+ var colLeft = ctx.visibledatacolumn[c];
56
+ if (merge) {
57
+ rowTop = merge.row[0];
58
+ _c = merge.column, colLeft = _c[1];
59
+ }
60
+ var toX = colLeft;
61
+ var toY = rowTop;
62
+ var zoom = ctx.zoomRatio;
63
+ var left = err.left == null ? toX + 8 * zoom : err.left * zoom;
64
+ var top = err.top == null ? toY - 2 * zoom : err.top * zoom;
65
+ if (top < 0) top = 2;
66
+ ctx.hoverErrorBox = {
67
+ row_column: row_column,
68
+ left: left,
69
+ top: top,
70
+ title: ((_f = cell.error) === null || _f === void 0 ? void 0 : _f.title) || "Error",
71
+ message: ((_g = cell.error) === null || _g === void 0 ? void 0 : _g.message) || "Default error message"
72
+ };
73
+ }
74
+ function setCellError(ctx, r, c, err) {
75
+ var flow = (0, _context.getFlowdata)(ctx);
76
+ if (!flow) return;
77
+ if (!flow[r]) flow[r] = [];
78
+ if (!flow[r][c]) flow[r][c] = {};
79
+ flow[r][c].error = __assign({}, err);
80
+ }
81
+ function clearCellError(ctx, r, c) {
82
+ var _a;
83
+ var flow = (0, _context.getFlowdata)(ctx);
84
+ if (!((_a = flow === null || flow === void 0 ? void 0 : flow[r]) === null || _a === void 0 ? void 0 : _a[c])) return;
85
+ delete flow[r][c].error;
86
+ }
87
+ function showErrors(ctx, errorShowCells) {
88
+ var flowdata = (0, _context.getFlowdata)(ctx);
89
+ if (!flowdata) return;
90
+ var errorBoxes = errorShowCells.map(function (_a) {
91
+ var r = _a.r,
92
+ c = _a.c;
93
+ return (0, _comment.getCommentBoxByRC)(ctx, flowdata, r, c);
94
+ });
95
+ ctx.errorBoxes = errorBoxes;
96
+ }
@@ -759,7 +759,17 @@ function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notInsertFunc
759
759
  var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
760
760
  finalResult = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
761
761
  }
762
- return [true, _lodash.default.isNil(formulaError) ? finalResult : formulaError, txt];
762
+ var isError = !_lodash.default.isNil(formulaError);
763
+ if (isError) {
764
+ (0, _2.setCellError)(ctx, r, c, {
765
+ row_column: "".concat(r, "_").concat(c),
766
+ title: "Error",
767
+ message: (formulaError === null || formulaError === void 0 ? void 0 : formulaError.toString()) || "Unknown Error"
768
+ });
769
+ } else {
770
+ (0, _2.clearCellError)(ctx, r, c);
771
+ }
772
+ return [true, !isError ? finalResult : formulaError, txt];
763
773
  }
764
774
  function insertUpdateDynamicArray(ctx, dynamicArrayItem) {
765
775
  var r = dynamicArrayItem.r,
@@ -34,3 +34,4 @@ export * from "./ConditionFormat";
34
34
  export * from "./zoom";
35
35
  export * from "./refresh";
36
36
  export * from "./iframe";
37
+ export * from "./error-state-helpers";
@@ -398,4 +398,15 @@ Object.keys(_iframe).forEach(function (key) {
398
398
  return _iframe[key];
399
399
  }
400
400
  });
401
+ });
402
+ var _errorStateHelpers = require("./error-state-helpers");
403
+ Object.keys(_errorStateHelpers).forEach(function (key) {
404
+ if (key === "default" || key === "__esModule") return;
405
+ if (key in exports && exports[key] === _errorStateHelpers[key]) return;
406
+ Object.defineProperty(exports, key, {
407
+ enumerable: true,
408
+ get: function get() {
409
+ return _errorStateHelpers[key];
410
+ }
411
+ });
401
412
  });
package/lib/types.d.ts CHANGED
@@ -25,6 +25,13 @@ export type CellStyle = {
25
25
  un?: number;
26
26
  tr?: string;
27
27
  };
28
+ export type CellError = {
29
+ title: string;
30
+ message: string;
31
+ left?: number;
32
+ top?: number;
33
+ row_column?: string;
34
+ };
28
35
  export type Cell = {
29
36
  v?: string | number | boolean;
30
37
  m?: string | number;
@@ -62,6 +69,7 @@ export type Cell = {
62
69
  c: number;
63
70
  id: string;
64
71
  };
72
+ error?: CellError;
65
73
  } & CellStyle;
66
74
  export type CellWithRowAndCol = {
67
75
  r: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.1.65",
3
+ "version": "1.1.66-error-1",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",