@fileverse-dev/fortune-react 1.3.12-mixed-a → 1.3.13-create-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/components/ContextMenu/index.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 +406 -194
- 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 -45
- package/es/components/SheetOverlay/index.js +26 -14
- package/es/components/Workbook/index.js +5 -8
- 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/ContextMenu/index.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 +404 -192
- 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 -45
- package/lib/components/SheetOverlay/index.js +25 -13
- package/lib/components/Workbook/index.js +5 -8
- 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
|
@@ -23,11 +23,21 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
23
23
|
};
|
|
24
24
|
return __assign.apply(this, arguments);
|
|
25
25
|
};
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
27
|
+
var t = {};
|
|
28
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
30
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
31
|
+
}
|
|
32
|
+
return t;
|
|
33
|
+
};
|
|
34
|
+
var FormulaSearch = function FormulaSearch(_a) {
|
|
35
|
+
var _b, _c, _d;
|
|
36
|
+
var from = _a.from,
|
|
37
|
+
divProps = __rest(_a, ["from"]);
|
|
38
|
+
var _e = (0, _react.useContext)(_context.default),
|
|
39
|
+
context = _e.context,
|
|
40
|
+
isAuthorized = _e.settings.isAuthorized;
|
|
31
41
|
var authedFunction = ["COINGECKO", "ETHERSCAN", "DEFILLAMA", "GNOSIS", "BASE", "EOA", "PNL", "SAFE", "BLOCKSCOUT", "LENS", "FARCASTER", "Ethereum", "SMARTCONTRACT", "DUNESIM"];
|
|
32
42
|
var filteredDefaultCandidates = context.defaultCandidates.filter(function (item) {
|
|
33
43
|
return !authedFunction.includes(item.n);
|
|
@@ -39,39 +49,58 @@ var FormulaSearch = function FormulaSearch(props) {
|
|
|
39
49
|
var finalFunctionCandidates = isAuthorized ? context.functionCandidates : context.functionCandidates.filter(function (item) {
|
|
40
50
|
return item.t !== 20;
|
|
41
51
|
});
|
|
42
|
-
var firstSelection = (
|
|
52
|
+
var firstSelection = (_b = context.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b[0];
|
|
53
|
+
var cellHeightPx = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move) != null ? Number(firstSelection.height_move) : 24;
|
|
54
|
+
var belowCellTop = cellHeightPx + 4;
|
|
43
55
|
var hintRef = (0, _react.useRef)(null);
|
|
44
|
-
var
|
|
45
|
-
top =
|
|
46
|
-
setTop =
|
|
47
|
-
var
|
|
48
|
-
var _a
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
var _f = (0, _react.useState)(belowCellTop),
|
|
57
|
+
top = _f[0],
|
|
58
|
+
setTop = _f[1];
|
|
59
|
+
var applyPlacement = (0, _react.useCallback)(function () {
|
|
60
|
+
var _a;
|
|
61
|
+
if ((firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) == null || firstSelection.height_move == null) {
|
|
62
|
+
setTop(belowCellTop);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
var fromFx = from === "fx";
|
|
66
|
+
var cellH = Number(firstSelection.height_move) || cellHeightPx;
|
|
67
|
+
if (fromFx) {
|
|
68
|
+
setTop(25);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
var innerEl = hintRef.current;
|
|
72
|
+
var popupHeight = Math.min((innerEl === null || innerEl === void 0 ? void 0 : innerEl.offsetHeight) || 360, 360);
|
|
73
|
+
var inputBox = document.getElementById("luckysheet-input-box");
|
|
74
|
+
var rect = inputBox === null || inputBox === void 0 ? void 0 : inputBox.getBoundingClientRect();
|
|
75
|
+
if (!rect) {
|
|
76
|
+
setTop(cellH + 4);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
var cellBottomViewport = rect.top + cellH;
|
|
80
|
+
var availableBelow = window.innerHeight - cellBottomViewport - 12;
|
|
81
|
+
var preferBelow = popupHeight <= availableBelow;
|
|
82
|
+
var topV = preferBelow ? cellH + 4 : -(popupHeight + 8);
|
|
83
|
+
var fxHint = (_a = document.getElementsByClassName("fx-hint")) === null || _a === void 0 ? void 0 : _a[0];
|
|
84
|
+
if (fxHint && fxHint.style.display !== "none") {
|
|
60
85
|
topV = 25;
|
|
61
86
|
}
|
|
62
87
|
setTop(topV);
|
|
63
|
-
};
|
|
64
|
-
(0, _react.
|
|
65
|
-
|
|
66
|
-
|
|
88
|
+
}, [belowCellTop, cellHeightPx, firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move, firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top, from]);
|
|
89
|
+
(0, _react.useLayoutEffect)(function () {
|
|
90
|
+
applyPlacement();
|
|
91
|
+
var id = requestAnimationFrame(applyPlacement);
|
|
92
|
+
return function () {
|
|
93
|
+
cancelAnimationFrame(id);
|
|
94
|
+
};
|
|
95
|
+
}, [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]);
|
|
67
96
|
if (_lodash.default.isEmpty(context.functionCandidates) && _lodash.default.isEmpty(context.defaultCandidates)) return null;
|
|
68
97
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
69
|
-
className: "flex color-border-default border flex-col luckysheet-formula-search-c-p custom-scroll ".concat(
|
|
98
|
+
className: "flex color-border-default border flex-col luckysheet-formula-search-c-p custom-scroll ".concat(from === "fx" ? "fx-search" : "cell-search"),
|
|
70
99
|
id: "luckysheet-formula-search-c-p",
|
|
71
100
|
style: {
|
|
72
101
|
top: top
|
|
73
102
|
}
|
|
74
|
-
}, /*#__PURE__*/_react.default.createElement("div", __assign({},
|
|
103
|
+
}, /*#__PURE__*/_react.default.createElement("div", __assign({}, divProps, {
|
|
75
104
|
ref: hintRef,
|
|
76
105
|
id: "luckysheet-formula-search-c",
|
|
77
106
|
className: "luckysheet-formula-search-c"
|