@fileverse-dev/fortune-react 1.3.12 → 1.3.13-create-2
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/components/ConditionFormat/ConditionRules.js +15 -5
- package/es/components/ConditionFormat/index.js +3 -0
- package/es/components/ContextMenu/index.js +1 -1
- package/es/components/DataVerification/ColorPicker.js +1 -1
- package/es/components/FxEditor/index.js +316 -60
- package/es/components/SheetOverlay/FormulaHint/index.js +46 -25
- package/es/components/SheetOverlay/FormulaSearch/index.d.ts +3 -1
- package/es/components/SheetOverlay/FormulaSearch/index.js +58 -29
- package/es/components/SheetOverlay/InputBox.js +421 -160
- package/es/components/SheetOverlay/drag_and_drop/column-helpers.js +34 -48
- package/es/components/SheetOverlay/drag_and_drop/row-helpers.js +31 -41
- package/es/components/SheetOverlay/formula-segment-boundary.d.ts +1 -0
- package/es/components/SheetOverlay/formula-segment-boundary.js +4 -0
- package/es/components/SheetOverlay/helper.d.ts +7 -0
- package/es/components/SheetOverlay/helper.js +95 -0
- package/es/components/SheetOverlay/index.css +6 -39
- package/es/components/SheetOverlay/index.js +29 -17
- package/es/components/Toolbar/index.js +17 -12
- package/es/components/Workbook/api.d.ts +3 -0
- package/es/components/Workbook/index.d.ts +3 -0
- package/es/components/Workbook/index.js +9 -3
- package/es/hooks/useFormulaEditorHistory.d.ts +24 -0
- package/es/hooks/useFormulaEditorHistory.js +119 -0
- package/es/hooks/useRerenderOnFormulaCaret.d.ts +2 -0
- package/es/hooks/useRerenderOnFormulaCaret.js +28 -0
- package/lib/components/ConditionFormat/ConditionRules.js +15 -5
- package/lib/components/ConditionFormat/index.js +3 -0
- package/lib/components/ContextMenu/index.js +1 -1
- package/lib/components/DataVerification/ColorPicker.js +1 -1
- package/lib/components/FxEditor/index.js +314 -58
- package/lib/components/SheetOverlay/FormulaHint/index.js +45 -24
- package/lib/components/SheetOverlay/FormulaSearch/index.d.ts +3 -1
- package/lib/components/SheetOverlay/FormulaSearch/index.js +57 -28
- package/lib/components/SheetOverlay/InputBox.js +419 -158
- package/lib/components/SheetOverlay/drag_and_drop/column-helpers.js +33 -47
- package/lib/components/SheetOverlay/drag_and_drop/row-helpers.js +31 -41
- package/lib/components/SheetOverlay/formula-segment-boundary.d.ts +1 -0
- package/lib/components/SheetOverlay/formula-segment-boundary.js +10 -0
- package/lib/components/SheetOverlay/helper.d.ts +7 -0
- package/lib/components/SheetOverlay/helper.js +99 -0
- package/lib/components/SheetOverlay/index.css +6 -39
- package/lib/components/SheetOverlay/index.js +28 -16
- package/lib/components/Toolbar/index.js +16 -11
- package/lib/components/Workbook/api.d.ts +3 -0
- package/lib/components/Workbook/index.d.ts +3 -0
- package/lib/components/Workbook/index.js +8 -2
- package/lib/hooks/useFormulaEditorHistory.d.ts +24 -0
- package/lib/hooks/useFormulaEditorHistory.js +126 -0
- package/lib/hooks/useRerenderOnFormulaCaret.d.ts +2 -0
- package/lib/hooks/useRerenderOnFormulaCaret.js +34 -0
- package/package.json +2 -2
|
@@ -10,7 +10,7 @@ var __assign = this && this.__assign || function () {
|
|
|
10
10
|
};
|
|
11
11
|
import { locale } from "@fileverse-dev/fortune-core";
|
|
12
12
|
import { Button, TextField, LucideIcon, Tooltip } from "@fileverse/ui";
|
|
13
|
-
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
13
|
+
import React, { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
14
14
|
import WorkbookContext from "../../../context";
|
|
15
15
|
import "./index.css";
|
|
16
16
|
import { DraggableDiv } from "./dragable-div";
|
|
@@ -49,29 +49,49 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
49
49
|
ETHERSCAN_API_KEY: "Etherscan API key"
|
|
50
50
|
};
|
|
51
51
|
var hintRef = useRef(null);
|
|
52
|
-
var
|
|
52
|
+
var cellHeightPx = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move) != null ? Number(firstSelection.height_move) : 24;
|
|
53
|
+
var belowCellTop = cellHeightPx + 4;
|
|
54
|
+
var _h = useState(belowCellTop),
|
|
53
55
|
top = _h[0],
|
|
54
56
|
setTop = _h[1];
|
|
55
57
|
var _j = useState(false),
|
|
56
58
|
showDelayedHint = _j[0],
|
|
57
59
|
setShowDelayedHint = _j[1];
|
|
58
|
-
var
|
|
59
|
-
var _a
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
var measureFormulaHintPlacement = useCallback(function () {
|
|
61
|
+
var _a;
|
|
62
|
+
if ((firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) == null || firstSelection.height_move == null) {
|
|
63
|
+
setTop(belowCellTop);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
var cellH = Number(firstSelection.height_move) || cellHeightPx;
|
|
67
|
+
var innerEl = hintRef.current;
|
|
68
|
+
var popupHeight = Math.min((innerEl === null || innerEl === void 0 ? void 0 : innerEl.offsetHeight) || 360, 360);
|
|
69
|
+
var inputBox = document.getElementById("luckysheet-input-box");
|
|
70
|
+
var rect = inputBox === null || inputBox === void 0 ? void 0 : inputBox.getBoundingClientRect();
|
|
71
|
+
if (!rect) {
|
|
72
|
+
setTop(cellH + 4);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
var cellBottomViewport = rect.top + cellH;
|
|
76
|
+
var availableBelow = window.innerHeight - cellBottomViewport - 12;
|
|
77
|
+
var preferBelow = popupHeight <= availableBelow;
|
|
78
|
+
var topV = preferBelow ? cellH + 4 : -(popupHeight + 8);
|
|
79
|
+
var fxHint = (_a = document.getElementsByClassName("fx-hint")) === null || _a === void 0 ? void 0 : _a[0];
|
|
80
|
+
if (fxHint && fxHint.style.display !== "none") {
|
|
71
81
|
topV = 25;
|
|
72
82
|
}
|
|
73
83
|
setTop(topV);
|
|
74
|
-
};
|
|
84
|
+
}, [belowCellTop, cellHeightPx, firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move, firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top]);
|
|
85
|
+
useLayoutEffect(function () {
|
|
86
|
+
if (!fn) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
measureFormulaHintPlacement();
|
|
90
|
+
var id = requestAnimationFrame(measureFormulaHintPlacement);
|
|
91
|
+
return function () {
|
|
92
|
+
cancelAnimationFrame(id);
|
|
93
|
+
};
|
|
94
|
+
}, [functionName, context.functionHint, measureFormulaHintPlacement, showFormulaHint, commaCount, showFunctionBody]);
|
|
75
95
|
var hexToRgbString = function hexToRgbString(hex) {
|
|
76
96
|
hex = hex.replace("#", "");
|
|
77
97
|
var r = parseInt(hex.substring(0, 2), 16);
|
|
@@ -84,14 +104,13 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
84
104
|
return bg;
|
|
85
105
|
};
|
|
86
106
|
useEffect(function () {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
107
|
+
setShowDelayedHint(false);
|
|
108
|
+
var t = setTimeout(function () {
|
|
109
|
+
return setShowDelayedHint(true);
|
|
110
|
+
}, 40);
|
|
111
|
+
return function () {
|
|
112
|
+
return clearTimeout(t);
|
|
113
|
+
};
|
|
95
114
|
}, [top]);
|
|
96
115
|
if (!fn) return null;
|
|
97
116
|
var fnNameClass = fn.n ? String(fn.n).replace(/[^a-zA-Z0-9-]/g, "-").replace(/-+/g, "-") : "";
|
|
@@ -174,7 +193,7 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
174
193
|
localStorage.setItem("formula-expand", "".concat(!showFunctionBody));
|
|
175
194
|
setShouldShowFunctionBody(!showFunctionBody);
|
|
176
195
|
setTimeout(function () {
|
|
177
|
-
|
|
196
|
+
measureFormulaHintPlacement();
|
|
178
197
|
}, 50);
|
|
179
198
|
}
|
|
180
199
|
dragHasMoved.current = false;
|
|
@@ -277,6 +296,7 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
277
296
|
cursor: "auto"
|
|
278
297
|
}
|
|
279
298
|
}, fn.API_KEY && (/*#__PURE__*/React.createElement("div", {
|
|
299
|
+
className: "luckysheet-formula-help-content-api",
|
|
280
300
|
style: {
|
|
281
301
|
borderLeft: "4px solid ".concat(isKeyAdded ? "#177E23" : "#fb923c"),
|
|
282
302
|
backgroundColor: "white",
|
|
@@ -340,6 +360,7 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
340
360
|
className: "fortune-formula-hint__cta min-w-[80px]",
|
|
341
361
|
"data-testid": "formula-hint-cta-ok"
|
|
342
362
|
}, "Ok"))))))), /*#__PURE__*/React.createElement("div", {
|
|
363
|
+
id: "luckysheet-formula-help-content-example",
|
|
343
364
|
style: {
|
|
344
365
|
backgroundColor: "white",
|
|
345
366
|
padding: "6px",
|
|
@@ -8,17 +8,27 @@ var __assign = this && this.__assign || function () {
|
|
|
8
8
|
};
|
|
9
9
|
return __assign.apply(this, arguments);
|
|
10
10
|
};
|
|
11
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
15
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
18
|
+
};
|
|
11
19
|
import _ from "lodash";
|
|
12
|
-
import React, { useContext,
|
|
20
|
+
import React, { useCallback, useContext, useLayoutEffect, useRef, useState } from "react";
|
|
13
21
|
import { LucideIcon, Tooltip } from "@fileverse/ui";
|
|
14
22
|
import { UNFilter } from "./constant";
|
|
15
23
|
import WorkbookContext from "../../../context";
|
|
16
24
|
import "./index.css";
|
|
17
|
-
var FormulaSearch = function FormulaSearch(
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
var FormulaSearch = function FormulaSearch(_a) {
|
|
26
|
+
var _b, _c, _d;
|
|
27
|
+
var from = _a.from,
|
|
28
|
+
divProps = __rest(_a, ["from"]);
|
|
29
|
+
var _e = useContext(WorkbookContext),
|
|
30
|
+
context = _e.context,
|
|
31
|
+
isAuthorized = _e.settings.isAuthorized;
|
|
22
32
|
var authedFunction = ["COINGECKO", "ETHERSCAN", "DEFILLAMA", "GNOSIS", "BASE", "EOA", "PNL", "SAFE", "BLOCKSCOUT", "LENS", "FARCASTER", "Ethereum", "SMARTCONTRACT", "DUNESIM"];
|
|
23
33
|
var filteredDefaultCandidates = context.defaultCandidates.filter(function (item) {
|
|
24
34
|
return !authedFunction.includes(item.n);
|
|
@@ -30,39 +40,58 @@ var FormulaSearch = function FormulaSearch(props) {
|
|
|
30
40
|
var finalFunctionCandidates = isAuthorized ? context.functionCandidates : context.functionCandidates.filter(function (item) {
|
|
31
41
|
return item.t !== 20;
|
|
32
42
|
});
|
|
33
|
-
var firstSelection = (
|
|
43
|
+
var firstSelection = (_b = context.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b[0];
|
|
44
|
+
var cellHeightPx = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move) != null ? Number(firstSelection.height_move) : 24;
|
|
45
|
+
var belowCellTop = cellHeightPx + 4;
|
|
34
46
|
var hintRef = useRef(null);
|
|
35
|
-
var
|
|
36
|
-
top =
|
|
37
|
-
setTop =
|
|
38
|
-
var
|
|
39
|
-
var _a
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
var _f = useState(belowCellTop),
|
|
48
|
+
top = _f[0],
|
|
49
|
+
setTop = _f[1];
|
|
50
|
+
var applyPlacement = useCallback(function () {
|
|
51
|
+
var _a;
|
|
52
|
+
if ((firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) == null || firstSelection.height_move == null) {
|
|
53
|
+
setTop(belowCellTop);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
var fromFx = from === "fx";
|
|
57
|
+
var cellH = Number(firstSelection.height_move) || cellHeightPx;
|
|
58
|
+
if (fromFx) {
|
|
59
|
+
setTop(25);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
var innerEl = hintRef.current;
|
|
63
|
+
var popupHeight = Math.min((innerEl === null || innerEl === void 0 ? void 0 : innerEl.offsetHeight) || 360, 360);
|
|
64
|
+
var inputBox = document.getElementById("luckysheet-input-box");
|
|
65
|
+
var rect = inputBox === null || inputBox === void 0 ? void 0 : inputBox.getBoundingClientRect();
|
|
66
|
+
if (!rect) {
|
|
67
|
+
setTop(cellH + 4);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
var cellBottomViewport = rect.top + cellH;
|
|
71
|
+
var availableBelow = window.innerHeight - cellBottomViewport - 12;
|
|
72
|
+
var preferBelow = popupHeight <= availableBelow;
|
|
73
|
+
var topV = preferBelow ? cellH + 4 : -(popupHeight + 8);
|
|
74
|
+
var fxHint = (_a = document.getElementsByClassName("fx-hint")) === null || _a === void 0 ? void 0 : _a[0];
|
|
75
|
+
if (fxHint && fxHint.style.display !== "none") {
|
|
51
76
|
topV = 25;
|
|
52
77
|
}
|
|
53
78
|
setTop(topV);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
79
|
+
}, [belowCellTop, cellHeightPx, firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move, firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top, from]);
|
|
80
|
+
useLayoutEffect(function () {
|
|
81
|
+
applyPlacement();
|
|
82
|
+
var id = requestAnimationFrame(applyPlacement);
|
|
83
|
+
return function () {
|
|
84
|
+
cancelAnimationFrame(id);
|
|
85
|
+
};
|
|
86
|
+
}, [applyPlacement, (_c = context.defaultCandidates) === null || _c === void 0 ? void 0 : _c.length, (_d = context.functionCandidates) === null || _d === void 0 ? void 0 : _d.length, context.functionHint]);
|
|
58
87
|
if (_.isEmpty(context.functionCandidates) && _.isEmpty(context.defaultCandidates)) return null;
|
|
59
88
|
return /*#__PURE__*/React.createElement("div", {
|
|
60
|
-
className: "flex color-border-default border flex-col luckysheet-formula-search-c-p custom-scroll ".concat(
|
|
89
|
+
className: "flex color-border-default border flex-col luckysheet-formula-search-c-p custom-scroll ".concat(from === "fx" ? "fx-search" : "cell-search"),
|
|
61
90
|
id: "luckysheet-formula-search-c-p",
|
|
62
91
|
style: {
|
|
63
92
|
top: top
|
|
64
93
|
}
|
|
65
|
-
}, /*#__PURE__*/React.createElement("div", __assign({},
|
|
94
|
+
}, /*#__PURE__*/React.createElement("div", __assign({}, divProps, {
|
|
66
95
|
ref: hintRef,
|
|
67
96
|
id: "luckysheet-formula-search-c",
|
|
68
97
|
className: "luckysheet-formula-search-c"
|