@fileverse-dev/fortune-react 1.0.88-patch-10 → 1.0.89

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.
Files changed (27) hide show
  1. package/es/components/LinkEidtCard/index.js +1 -1
  2. package/es/components/SheetOverlay/FormulaHint/index.js +5 -50
  3. package/es/components/SheetOverlay/FormulaSearch/index.js +5 -30
  4. package/es/components/SheetOverlay/InputBox.js +1 -5
  5. package/es/components/SheetOverlay/index.js +2 -0
  6. package/es/components/index.d.ts +1 -1
  7. package/es/components/index.js +1 -1
  8. package/lib/components/LinkEidtCard/index.js +1 -1
  9. package/lib/components/SheetOverlay/FormulaHint/index.js +5 -50
  10. package/lib/components/SheetOverlay/FormulaSearch/index.js +4 -29
  11. package/lib/components/SheetOverlay/InputBox.js +1 -5
  12. package/lib/components/SheetOverlay/index.js +2 -0
  13. package/lib/components/index.d.ts +1 -1
  14. package/lib/components/index.js +0 -6
  15. package/package.json +2 -2
  16. package/es/components/SheetOverlay/FormulaHint/constants.d.ts +0 -1
  17. package/es/components/SheetOverlay/FormulaHint/constants.js +0 -1
  18. package/es/components/SheetOverlay/FormulaHint/use-gnosis-pay.d.ts +0 -10
  19. package/es/components/SheetOverlay/FormulaHint/use-gnosis-pay.js +0 -93
  20. package/es/components/SheetOverlay/FormulaHint/utils/utils.d.ts +0 -3
  21. package/es/components/SheetOverlay/FormulaHint/utils/utils.js +0 -25
  22. package/lib/components/SheetOverlay/FormulaHint/constants.d.ts +0 -1
  23. package/lib/components/SheetOverlay/FormulaHint/constants.js +0 -7
  24. package/lib/components/SheetOverlay/FormulaHint/use-gnosis-pay.d.ts +0 -10
  25. package/lib/components/SheetOverlay/FormulaHint/use-gnosis-pay.js +0 -99
  26. package/lib/components/SheetOverlay/FormulaHint/utils/utils.d.ts +0 -3
  27. package/lib/components/SheetOverlay/FormulaHint/utils/utils.js +0 -33
@@ -108,7 +108,7 @@ export var LinkEditCard = function LinkEditCard(_a) {
108
108
  className: "fortune-link-modify-modal link-toolbar",
109
109
  style: {
110
110
  left: position.cellLeft + 20,
111
- top: position.cellBottom
111
+ top: position.cellBottom - 5
112
112
  }
113
113
  }), /*#__PURE__*/React.createElement("div", {
114
114
  className: "link-content",
@@ -13,8 +13,6 @@ import { Button, TextField, LucideIcon } from "@fileverse/ui";
13
13
  import React, { useContext, useEffect, useRef, useState } from "react";
14
14
  import WorkbookContext from "../../../context";
15
15
  import "./index.css";
16
- import { timeFromNowMessage } from "./utils/utils";
17
- import useGnosisPay from "./use-gnosis-pay";
18
16
  var FormulaHint = function FormulaHint(props) {
19
17
  var _a;
20
18
  var context = useContext(WorkbookContext).context;
@@ -33,29 +31,20 @@ var FormulaHint = function FormulaHint(props) {
33
31
  var _e = useState(true),
34
32
  showFunctionBody = _e[0],
35
33
  setShouldShowFunctionBody = _e[1];
36
- var _f = useGnosisPay(fn),
37
- grantAccess = _f.grantAccess,
38
- handleGnosisPayToken = _f.handleGnosisPayToken,
39
- hasGnosisPayToken = _f.hasGnosisPayToken,
40
- isWrongGnosisPayConnector = _f.isWrongGnosisPayConnector,
41
- isLoading = _f.isLoading,
42
- accessTokenCreatedAt = _f.accessTokenCreatedAt,
43
- timeLeft = _f.timeLeft;
44
34
  useEffect(function () {
45
35
  if (fn) {
46
36
  setApiKeyAdded(!!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
47
37
  setAPI_KEY(localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY) || "");
48
38
  setShowAPInput(!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
49
- handleGnosisPayToken();
50
39
  }
51
40
  }, [fn]);
52
41
  var apiKeyPlaceholder = {
53
42
  ETHERSCAN_API_KEY: "Etherscan API key"
54
43
  };
55
44
  var hintRef = useRef(null);
56
- var _g = useState(0),
57
- top = _g[0],
58
- setTop = _g[1];
45
+ var _f = useState(0),
46
+ top = _f[0],
47
+ setTop = _f[1];
59
48
  var calcuatePopUpPlacement = function calcuatePopUpPlacement() {
60
49
  var _a, _b, _c;
61
50
  if (!((_a = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) === null || _a === void 0 ? void 0 : _a.toString()) || !((_b = firstSelection.height_move) === null || _b === void 0 ? void 0 : _b.toString()) || !hintRef.current) return;
@@ -211,7 +200,7 @@ var FormulaHint = function FormulaHint(props) {
211
200
  style: {
212
201
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA"),
213
202
  maxHeight: "318px",
214
- overflowY: "auto"
203
+ overflowY: "scroll"
215
204
  }
216
205
  }, fn.API_KEY && (/*#__PURE__*/React.createElement("div", {
217
206
  style: {
@@ -265,41 +254,7 @@ var FormulaHint = function FormulaHint(props) {
265
254
  },
266
255
  disabled: !API_KEY,
267
256
  className: "min-w-[80px]"
268
- }, "Ok"))))))), fn.n === "GNOSISPAY" && (/*#__PURE__*/React.createElement("div", {
269
- id: "gnosis-pay-area",
270
- style: {
271
- borderLeft: "4px solid ".concat(hasGnosisPayToken ? "#177E23" : "#fb923c"),
272
- backgroundColor: "white",
273
- padding: "8px",
274
- margin: "4px 4px 0px 4px",
275
- borderRadius: "4px"
276
- }
277
- }, /*#__PURE__*/React.createElement("div", {
278
- style: {
279
- display: "flex",
280
- justifyContent: "space-between",
281
- cursor: "pointer"
282
- },
283
- onClick: function onClick() {}
284
- }, /*#__PURE__*/React.createElement("h3", {
285
- style: {
286
- margin: "0 0 8px 0"
287
- },
288
- className: "text-heading-xsm color-text-default"
289
- }, hasGnosisPayToken ? "Access granted" : "Connect your Gnosis Pay account")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", {
290
- style: {
291
- margin: "0 0 8px 0"
292
- },
293
- className: "text-body-sm color-text-default"
294
- }, !hasGnosisPayToken ? "Grant access to your Gnosis Pay account and ensure you're using the same wallet for both Gnosis Pay and dSheet." : " You can now interact with your Gnosis Pay account for the next ".concat(timeFromNowMessage(timeLeft), ". When the timer\u2019s up, just re-grant access and you're good to go!")), /*#__PURE__*/React.createElement(Button, {
295
- onClick: grantAccess,
296
- disabled: hasGnosisPayToken || isWrongGnosisPayConnector || isLoading,
297
- className: "w-full items-center flex gap-1"
298
- }, isLoading && (/*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(LucideIcon, {
299
- name: "LoaderCircle",
300
- className: "animate-spin",
301
- size: "sm"
302
- }))), /*#__PURE__*/React.createElement("p", null, "Grant access "), " ", accessTokenCreatedAt > 0 && /*#__PURE__*/React.createElement("div", null, timeLeft))))), /*#__PURE__*/React.createElement("div", {
257
+ }, "Ok"))))))), /*#__PURE__*/React.createElement("div", {
303
258
  style: {
304
259
  backgroundColor: "white",
305
260
  padding: "6px",
@@ -10,7 +10,7 @@ var __assign = this && this.__assign || function () {
10
10
  };
11
11
  import _ from "lodash";
12
12
  import React, { useContext, useEffect, useRef, useState } from "react";
13
- import { cn, LucideIcon, Tooltip } from "@fileverse/ui";
13
+ import { LucideIcon, Tooltip } from "@fileverse/ui";
14
14
  import { UNFilter } from "./constant";
15
15
  import WorkbookContext from "../../../context";
16
16
  import "./index.css";
@@ -19,7 +19,6 @@ var FormulaSearch = function FormulaSearch(props) {
19
19
  var _b = useContext(WorkbookContext),
20
20
  context = _b.context,
21
21
  isAuthorized = _b.settings.isAuthorized;
22
- var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
23
22
  var authedFunction = ["COINGECKO", "ETHERSCAN", "DEFILLAMA", "GNOSIS", "BASE", "EOA", "PNL", "SAFE", "BLOCKSCOUT", "GNOSIS", "LENS", "FARCASTER", "Ethereum", "SMARTCONTRACT"];
24
23
  var filteredDefaultCandidates = context.defaultCandidates.filter(function (item) {
25
24
  return !authedFunction.includes(item.n);
@@ -160,9 +159,6 @@ var FormulaSearch = function FormulaSearch(props) {
160
159
  return /*#__PURE__*/React.createElement("div", {
161
160
  key: v.n,
162
161
  "data-func": v.n,
163
- style: {
164
- cursor: isWrongGnosisPayConnector && v.n === "GNOSISPAY" ? "not-allowed" : "pointer"
165
- },
166
162
  className: "luckysheet-formula-search-item"
167
163
  }, /*#__PURE__*/React.createElement("div", {
168
164
  style: {
@@ -170,18 +166,8 @@ var FormulaSearch = function FormulaSearch(props) {
170
166
  justifyContent: "space-between"
171
167
  }
172
168
  }, /*#__PURE__*/React.createElement("div", {
173
- className: "flex items-center"
174
- }, v.LOGO && isWrongGnosisPayConnector && v.n === "GNOSISPAY" && (/*#__PURE__*/React.createElement("div", {
175
- className: "mr-2"
176
- }, /*#__PURE__*/React.createElement("img", {
177
- src: v.LOGO,
178
- alt: "Service Logo",
179
- style: {
180
- width: "16px"
181
- }
182
- }))), /*#__PURE__*/React.createElement("div", {
183
- className: cn("luckysheet-formula-search-func color-text-default text-body-sm", isWrongGnosisPayConnector && v.n === "GNOSISPAY" ? "color-text-disabled" : "")
184
- }, v.n)), /*#__PURE__*/React.createElement("div", {
169
+ className: "luckysheet-formula-search-func color-text-default text-body-sm"
170
+ }, v.n), /*#__PURE__*/React.createElement("div", {
185
171
  style: {
186
172
  display: "flex",
187
173
  justifyContent: "end",
@@ -189,18 +175,7 @@ var FormulaSearch = function FormulaSearch(props) {
189
175
  alignItems: "center",
190
176
  gap: "6px"
191
177
  }
192
- }, isWrongGnosisPayConnector && v.n === "GNOSISPAY" ? (/*#__PURE__*/React.createElement(Tooltip, {
193
- position: "right",
194
- text: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, "Your dSheet account was created via email/social. Unfortunately you are not able to use Gnosis Pay onchain function."), /*#__PURE__*/React.createElement("p", {
195
- className: "mt-4"
196
- }, "To use Gnosis Pay onchain function you need to create a new dSheets account via the same wallet as your Gnosis Pay account."))
197
- }, /*#__PURE__*/React.createElement(LucideIcon, {
198
- name: "Info",
199
- size: "sm",
200
- style: {
201
- color: "#F16227"
202
- }
203
- }))) : (/*#__PURE__*/React.createElement(React.Fragment, null, v.LOGO && (/*#__PURE__*/React.createElement("img", {
178
+ }, v.LOGO && (/*#__PURE__*/React.createElement("img", {
204
179
  src: v.LOGO,
205
180
  alt: "Service Logo",
206
181
  style: {
@@ -229,7 +204,7 @@ var FormulaSearch = function FormulaSearch(props) {
229
204
  width: "12px",
230
205
  height: "12px"
231
206
  }
232
- })))))))), /*#__PURE__*/React.createElement("div", {
207
+ })))))), /*#__PURE__*/React.createElement("div", {
233
208
  className: "luckysheet-formula-search-detail mt-1 text-helper-text-sm color-text-secondary"
234
209
  }, v.d));
235
210
  }), finalFunctionCandidates.length === 0 && (/*#__PURE__*/React.createElement("span", null, !isAuthorized && (/*#__PURE__*/React.createElement("div", {
@@ -169,8 +169,6 @@ var InputBox = function InputBox() {
169
169
  var selectActiveFormula = useCallback(function (e) {
170
170
  var _a, _b;
171
171
  var formulaName = (_b = (_a = getActiveFormula()) === null || _a === void 0 ? void 0 : _a.querySelector(".luckysheet-formula-search-func")) === null || _b === void 0 ? void 0 : _b.textContent;
172
- var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
173
- if (isWrongGnosisPayConnector && formulaName === "GNOSISPAY") return;
174
172
  if (formulaName) {
175
173
  insertSelectedFormula(formulaName);
176
174
  e.preventDefault();
@@ -180,10 +178,8 @@ var InputBox = function InputBox() {
180
178
  var selectActiveFormulaOnClick = useCallback(function (e) {
181
179
  var _a, _b;
182
180
  if (e.target.className.includes("sign-fortune")) return;
183
- var formulaName = (_b = (_a = getActiveFormula()) === null || _a === void 0 ? void 0 : _a.querySelector(".luckysheet-formula-search-func")) === null || _b === void 0 ? void 0 : _b.textContent;
184
- var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
185
- if (isWrongGnosisPayConnector && formulaName === "GNOSISPAY") return;
186
181
  preText.current = inputRef.current.innerText;
182
+ var formulaName = (_b = (_a = getActiveFormula()) === null || _a === void 0 ? void 0 : _a.querySelector(".luckysheet-formula-search-func")) === null || _b === void 0 ? void 0 : _b.textContent;
187
183
  if (formulaName) {
188
184
  insertSelectedFormula(formulaName);
189
185
  e.preventDefault();
@@ -88,12 +88,14 @@ var SheetOverlay = function SheetOverlay() {
88
88
  }, 800);
89
89
  }, [setContext]);
90
90
  var overShowLinkCard = useCallback(function (ctx, globalCache, e, container, scrollX, scrollY) {
91
+ var _a;
91
92
  var rc = getCellRowColumn(ctx, e, container, scrollX, scrollY);
92
93
  if (rc == null) return;
93
94
  var link = getCellHyperlink(ctx, rc.r, rc.c);
94
95
  if (link == null) {
95
96
  debouncedShowLinkCard(globalCache, rc.r, rc.c, false);
96
97
  } else {
98
+ if ((_a = globalCache.linkCard) === null || _a === void 0 ? void 0 : _a.mouseEnter) return;
97
99
  showLinkCard(ctx, rc.r, rc.c, false);
98
100
  debouncedShowLinkCard(globalCache, rc.r, rc.c, false, true);
99
101
  }
@@ -1,5 +1,5 @@
1
1
  import Workbook from "./Workbook";
2
- export { ERROR_MESSAGES_FLAG, SERVICES_API_KEY, isGnosisPayAccessExpired, } from "@fileverse-dev/formulajs/crypto-constants";
2
+ export { ERROR_MESSAGES_FLAG, SERVICES_API_KEY, } from "@fileverse-dev/formulajs/crypto-constants";
3
3
  export { Workbook };
4
4
  export type { WorkbookInstance } from "./Workbook";
5
5
  export type { Cell, Sheet } from "@fileverse-dev/fortune-core";
@@ -1,3 +1,3 @@
1
1
  import Workbook from "./Workbook";
2
- export { ERROR_MESSAGES_FLAG, SERVICES_API_KEY, isGnosisPayAccessExpired } from "@fileverse-dev/formulajs/crypto-constants";
2
+ export { ERROR_MESSAGES_FLAG, SERVICES_API_KEY } from "@fileverse-dev/formulajs/crypto-constants";
3
3
  export { Workbook };
@@ -117,7 +117,7 @@ var LinkEditCard = exports.LinkEditCard = function LinkEditCard(_a) {
117
117
  className: "fortune-link-modify-modal link-toolbar",
118
118
  style: {
119
119
  left: position.cellLeft + 20,
120
- top: position.cellBottom
120
+ top: position.cellBottom - 5
121
121
  }
122
122
  }), /*#__PURE__*/_react.default.createElement("div", {
123
123
  className: "link-content",
@@ -10,8 +10,6 @@ var _ui = require("@fileverse/ui");
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _context = _interopRequireDefault(require("../../../context"));
12
12
  require("./index.css");
13
- var _utils = require("./utils/utils");
14
- var _useGnosisPay = _interopRequireDefault(require("./use-gnosis-pay"));
15
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
14
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
17
15
  var __assign = void 0 && (void 0).__assign || function () {
@@ -42,29 +40,20 @@ var FormulaHint = function FormulaHint(props) {
42
40
  var _e = (0, _react.useState)(true),
43
41
  showFunctionBody = _e[0],
44
42
  setShouldShowFunctionBody = _e[1];
45
- var _f = (0, _useGnosisPay.default)(fn),
46
- grantAccess = _f.grantAccess,
47
- handleGnosisPayToken = _f.handleGnosisPayToken,
48
- hasGnosisPayToken = _f.hasGnosisPayToken,
49
- isWrongGnosisPayConnector = _f.isWrongGnosisPayConnector,
50
- isLoading = _f.isLoading,
51
- accessTokenCreatedAt = _f.accessTokenCreatedAt,
52
- timeLeft = _f.timeLeft;
53
43
  (0, _react.useEffect)(function () {
54
44
  if (fn) {
55
45
  setApiKeyAdded(!!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
56
46
  setAPI_KEY(localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY) || "");
57
47
  setShowAPInput(!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
58
- handleGnosisPayToken();
59
48
  }
60
49
  }, [fn]);
61
50
  var apiKeyPlaceholder = {
62
51
  ETHERSCAN_API_KEY: "Etherscan API key"
63
52
  };
64
53
  var hintRef = (0, _react.useRef)(null);
65
- var _g = (0, _react.useState)(0),
66
- top = _g[0],
67
- setTop = _g[1];
54
+ var _f = (0, _react.useState)(0),
55
+ top = _f[0],
56
+ setTop = _f[1];
68
57
  var calcuatePopUpPlacement = function calcuatePopUpPlacement() {
69
58
  var _a, _b, _c;
70
59
  if (!((_a = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) === null || _a === void 0 ? void 0 : _a.toString()) || !((_b = firstSelection.height_move) === null || _b === void 0 ? void 0 : _b.toString()) || !hintRef.current) return;
@@ -220,7 +209,7 @@ var FormulaHint = function FormulaHint(props) {
220
209
  style: {
221
210
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA"),
222
211
  maxHeight: "318px",
223
- overflowY: "auto"
212
+ overflowY: "scroll"
224
213
  }
225
214
  }, fn.API_KEY && (/*#__PURE__*/_react.default.createElement("div", {
226
215
  style: {
@@ -274,41 +263,7 @@ var FormulaHint = function FormulaHint(props) {
274
263
  },
275
264
  disabled: !API_KEY,
276
265
  className: "min-w-[80px]"
277
- }, "Ok"))))))), fn.n === "GNOSISPAY" && (/*#__PURE__*/_react.default.createElement("div", {
278
- id: "gnosis-pay-area",
279
- style: {
280
- borderLeft: "4px solid ".concat(hasGnosisPayToken ? "#177E23" : "#fb923c"),
281
- backgroundColor: "white",
282
- padding: "8px",
283
- margin: "4px 4px 0px 4px",
284
- borderRadius: "4px"
285
- }
286
- }, /*#__PURE__*/_react.default.createElement("div", {
287
- style: {
288
- display: "flex",
289
- justifyContent: "space-between",
290
- cursor: "pointer"
291
- },
292
- onClick: function onClick() {}
293
- }, /*#__PURE__*/_react.default.createElement("h3", {
294
- style: {
295
- margin: "0 0 8px 0"
296
- },
297
- className: "text-heading-xsm color-text-default"
298
- }, hasGnosisPayToken ? "Access granted" : "Connect your Gnosis Pay account")), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", {
299
- style: {
300
- margin: "0 0 8px 0"
301
- },
302
- className: "text-body-sm color-text-default"
303
- }, !hasGnosisPayToken ? "Grant access to your Gnosis Pay account and ensure you're using the same wallet for both Gnosis Pay and dSheet." : " You can now interact with your Gnosis Pay account for the next ".concat((0, _utils.timeFromNowMessage)(timeLeft), ". When the timer\u2019s up, just re-grant access and you're good to go!")), /*#__PURE__*/_react.default.createElement(_ui.Button, {
304
- onClick: grantAccess,
305
- disabled: hasGnosisPayToken || isWrongGnosisPayConnector || isLoading,
306
- className: "w-full items-center flex gap-1"
307
- }, isLoading && (/*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
308
- name: "LoaderCircle",
309
- className: "animate-spin",
310
- size: "sm"
311
- }))), /*#__PURE__*/_react.default.createElement("p", null, "Grant access "), " ", accessTokenCreatedAt > 0 && /*#__PURE__*/_react.default.createElement("div", null, timeLeft))))), /*#__PURE__*/_react.default.createElement("div", {
266
+ }, "Ok"))))))), /*#__PURE__*/_react.default.createElement("div", {
312
267
  style: {
313
268
  backgroundColor: "white",
314
269
  padding: "6px",
@@ -28,7 +28,6 @@ var FormulaSearch = function FormulaSearch(props) {
28
28
  var _b = (0, _react.useContext)(_context.default),
29
29
  context = _b.context,
30
30
  isAuthorized = _b.settings.isAuthorized;
31
- var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
32
31
  var authedFunction = ["COINGECKO", "ETHERSCAN", "DEFILLAMA", "GNOSIS", "BASE", "EOA", "PNL", "SAFE", "BLOCKSCOUT", "GNOSIS", "LENS", "FARCASTER", "Ethereum", "SMARTCONTRACT"];
33
32
  var filteredDefaultCandidates = context.defaultCandidates.filter(function (item) {
34
33
  return !authedFunction.includes(item.n);
@@ -169,9 +168,6 @@ var FormulaSearch = function FormulaSearch(props) {
169
168
  return /*#__PURE__*/_react.default.createElement("div", {
170
169
  key: v.n,
171
170
  "data-func": v.n,
172
- style: {
173
- cursor: isWrongGnosisPayConnector && v.n === "GNOSISPAY" ? "not-allowed" : "pointer"
174
- },
175
171
  className: "luckysheet-formula-search-item"
176
172
  }, /*#__PURE__*/_react.default.createElement("div", {
177
173
  style: {
@@ -179,18 +175,8 @@ var FormulaSearch = function FormulaSearch(props) {
179
175
  justifyContent: "space-between"
180
176
  }
181
177
  }, /*#__PURE__*/_react.default.createElement("div", {
182
- className: "flex items-center"
183
- }, v.LOGO && isWrongGnosisPayConnector && v.n === "GNOSISPAY" && (/*#__PURE__*/_react.default.createElement("div", {
184
- className: "mr-2"
185
- }, /*#__PURE__*/_react.default.createElement("img", {
186
- src: v.LOGO,
187
- alt: "Service Logo",
188
- style: {
189
- width: "16px"
190
- }
191
- }))), /*#__PURE__*/_react.default.createElement("div", {
192
- className: (0, _ui.cn)("luckysheet-formula-search-func color-text-default text-body-sm", isWrongGnosisPayConnector && v.n === "GNOSISPAY" ? "color-text-disabled" : "")
193
- }, v.n)), /*#__PURE__*/_react.default.createElement("div", {
178
+ className: "luckysheet-formula-search-func color-text-default text-body-sm"
179
+ }, v.n), /*#__PURE__*/_react.default.createElement("div", {
194
180
  style: {
195
181
  display: "flex",
196
182
  justifyContent: "end",
@@ -198,18 +184,7 @@ var FormulaSearch = function FormulaSearch(props) {
198
184
  alignItems: "center",
199
185
  gap: "6px"
200
186
  }
201
- }, isWrongGnosisPayConnector && v.n === "GNOSISPAY" ? (/*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
202
- position: "right",
203
- text: /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", null, "Your dSheet account was created via email/social. Unfortunately you are not able to use Gnosis Pay onchain function."), /*#__PURE__*/_react.default.createElement("p", {
204
- className: "mt-4"
205
- }, "To use Gnosis Pay onchain function you need to create a new dSheets account via the same wallet as your Gnosis Pay account."))
206
- }, /*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
207
- name: "Info",
208
- size: "sm",
209
- style: {
210
- color: "#F16227"
211
- }
212
- }))) : (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, v.LOGO && (/*#__PURE__*/_react.default.createElement("img", {
187
+ }, v.LOGO && (/*#__PURE__*/_react.default.createElement("img", {
213
188
  src: v.LOGO,
214
189
  alt: "Service Logo",
215
190
  style: {
@@ -238,7 +213,7 @@ var FormulaSearch = function FormulaSearch(props) {
238
213
  width: "12px",
239
214
  height: "12px"
240
215
  }
241
- })))))))), /*#__PURE__*/_react.default.createElement("div", {
216
+ })))))), /*#__PURE__*/_react.default.createElement("div", {
242
217
  className: "luckysheet-formula-search-detail mt-1 text-helper-text-sm color-text-secondary"
243
218
  }, v.d));
244
219
  }), finalFunctionCandidates.length === 0 && (/*#__PURE__*/_react.default.createElement("span", null, !isAuthorized && (/*#__PURE__*/_react.default.createElement("div", {
@@ -178,8 +178,6 @@ var InputBox = function InputBox() {
178
178
  var selectActiveFormula = (0, _react.useCallback)(function (e) {
179
179
  var _a, _b;
180
180
  var formulaName = (_b = (_a = getActiveFormula()) === null || _a === void 0 ? void 0 : _a.querySelector(".luckysheet-formula-search-func")) === null || _b === void 0 ? void 0 : _b.textContent;
181
- var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
182
- if (isWrongGnosisPayConnector && formulaName === "GNOSISPAY") return;
183
181
  if (formulaName) {
184
182
  insertSelectedFormula(formulaName);
185
183
  e.preventDefault();
@@ -189,10 +187,8 @@ var InputBox = function InputBox() {
189
187
  var selectActiveFormulaOnClick = (0, _react.useCallback)(function (e) {
190
188
  var _a, _b;
191
189
  if (e.target.className.includes("sign-fortune")) return;
192
- var formulaName = (_b = (_a = getActiveFormula()) === null || _a === void 0 ? void 0 : _a.querySelector(".luckysheet-formula-search-func")) === null || _b === void 0 ? void 0 : _b.textContent;
193
- var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
194
- if (isWrongGnosisPayConnector && formulaName === "GNOSISPAY") return;
195
190
  preText.current = inputRef.current.innerText;
191
+ var formulaName = (_b = (_a = getActiveFormula()) === null || _a === void 0 ? void 0 : _a.querySelector(".luckysheet-formula-search-func")) === null || _b === void 0 ? void 0 : _b.textContent;
196
192
  if (formulaName) {
197
193
  insertSelectedFormula(formulaName);
198
194
  e.preventDefault();
@@ -97,12 +97,14 @@ var SheetOverlay = function SheetOverlay() {
97
97
  }, 800);
98
98
  }, [setContext]);
99
99
  var overShowLinkCard = (0, _react.useCallback)(function (ctx, globalCache, e, container, scrollX, scrollY) {
100
+ var _a;
100
101
  var rc = (0, _fortuneCore.getCellRowColumn)(ctx, e, container, scrollX, scrollY);
101
102
  if (rc == null) return;
102
103
  var link = (0, _fortuneCore.getCellHyperlink)(ctx, rc.r, rc.c);
103
104
  if (link == null) {
104
105
  debouncedShowLinkCard(globalCache, rc.r, rc.c, false);
105
106
  } else {
107
+ if ((_a = globalCache.linkCard) === null || _a === void 0 ? void 0 : _a.mouseEnter) return;
106
108
  (0, _fortuneCore.showLinkCard)(ctx, rc.r, rc.c, false);
107
109
  debouncedShowLinkCard(globalCache, rc.r, rc.c, false, true);
108
110
  }
@@ -1,5 +1,5 @@
1
1
  import Workbook from "./Workbook";
2
- export { ERROR_MESSAGES_FLAG, SERVICES_API_KEY, isGnosisPayAccessExpired, } from "@fileverse-dev/formulajs/crypto-constants";
2
+ export { ERROR_MESSAGES_FLAG, SERVICES_API_KEY, } from "@fileverse-dev/formulajs/crypto-constants";
3
3
  export { Workbook };
4
4
  export type { WorkbookInstance } from "./Workbook";
5
5
  export type { Cell, Sheet } from "@fileverse-dev/fortune-core";
@@ -21,12 +21,6 @@ Object.defineProperty(exports, "Workbook", {
21
21
  return _Workbook.default;
22
22
  }
23
23
  });
24
- Object.defineProperty(exports, "isGnosisPayAccessExpired", {
25
- enumerable: true,
26
- get: function get() {
27
- return _cryptoConstants.isGnosisPayAccessExpired;
28
- }
29
- });
30
24
  var _Workbook = _interopRequireDefault(require("./Workbook"));
31
25
  var _cryptoConstants = require("@fileverse-dev/formulajs/crypto-constants");
32
26
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.0.88-patch-10",
3
+ "version": "1.0.89",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "module": "es/index.js",
@@ -16,7 +16,7 @@
16
16
  "tsc": "tsc"
17
17
  },
18
18
  "dependencies": {
19
- "@fileverse-dev/fortune-core": "1.0.88-patch-9",
19
+ "@fileverse-dev/fortune-core": "1.0.89",
20
20
  "@fileverse/ui": "^4.1.7-patch-21",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",
@@ -1 +0,0 @@
1
- export declare const GNOSIS_PAY_ACCESS = "GNOSIS_PAY_ACCESS";
@@ -1 +0,0 @@
1
- export var GNOSIS_PAY_ACCESS = "GNOSIS_PAY_ACCESS";
@@ -1,10 +0,0 @@
1
- declare const useGnosisPay: (fn: any) => {
2
- grantAccess: () => void;
3
- handleGnosisPayToken: (onDone?: () => void) => void;
4
- hasGnosisPayToken: boolean;
5
- isWrongGnosisPayConnector: boolean;
6
- isLoading: boolean;
7
- accessTokenCreatedAt: number;
8
- timeLeft: string;
9
- };
10
- export default useGnosisPay;
@@ -1,93 +0,0 @@
1
- import { useEffect, useRef, useState } from "react";
2
- import { isGnosisPayAccessExpired } from "@fileverse-dev/formulajs/crypto-constants";
3
- import { GNOSIS_PAY_ACCESS } from "./constants";
4
- import { formatTimeLeft, getJwtExpiry } from "./utils/utils";
5
- var useGnosisPay = function useGnosisPay(fn) {
6
- var gnosisTokenTokenIntervalRef = useRef(null);
7
- var _a = useState(false),
8
- isLoading = _a[0],
9
- setIsLoading = _a[1];
10
- var _b = useState(false),
11
- hasGnosisPayToken = _b[0],
12
- setHasGnosisPayToken = _b[1];
13
- var _c = useState("00:00"),
14
- timeLeft = _c[0],
15
- setTimeLeft = _c[1];
16
- var _d = useState(0),
17
- accessTokenCreatedAt = _d[0],
18
- setAccessTokenCreatedAt = _d[1];
19
- var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
20
- var handleGnosisPayToken = function handleGnosisPayToken(onDone) {
21
- if (localStorage.getItem(GNOSIS_PAY_ACCESS)) {
22
- var access = localStorage.getItem(GNOSIS_PAY_ACCESS) || "";
23
- if (!access || isGnosisPayAccessExpired(access)) {
24
- if (hasGnosisPayToken) {
25
- setHasGnosisPayToken(false);
26
- }
27
- if (accessTokenCreatedAt) {
28
- setAccessTokenCreatedAt(0);
29
- }
30
- localStorage.removeItem(GNOSIS_PAY_ACCESS);
31
- return;
32
- }
33
- setHasGnosisPayToken(!!access);
34
- setAccessTokenCreatedAt(getJwtExpiry(access));
35
- onDone === null || onDone === void 0 ? void 0 : onDone();
36
- } else {
37
- var urlParams = new URLSearchParams(window.location.search);
38
- var isRejected = urlParams.has("reject");
39
- if (isRejected) {
40
- var url = new URL(window.location.href);
41
- url.searchParams.delete("reject");
42
- window.history.replaceState({}, "", url.toString());
43
- onDone === null || onDone === void 0 ? void 0 : onDone();
44
- }
45
- }
46
- };
47
- useEffect(function () {
48
- return function () {
49
- if (gnosisTokenTokenIntervalRef.current) clearInterval(gnosisTokenTokenIntervalRef.current);
50
- };
51
- }, [gnosisTokenTokenIntervalRef]);
52
- useEffect(function () {
53
- if (accessTokenCreatedAt <= 0) return function () {};
54
- var interval = setInterval(function () {
55
- var access = localStorage.getItem(GNOSIS_PAY_ACCESS) || "";
56
- var expiryTimestamp = getJwtExpiry(access) * 1000;
57
- var newTimeLeft = expiryTimestamp - Date.now();
58
- setTimeLeft(formatTimeLeft(newTimeLeft));
59
- if (isGnosisPayAccessExpired(localStorage.getItem(GNOSIS_PAY_ACCESS)) || !document.getElementById("gnosis-pay-area")) {
60
- localStorage.removeItem(GNOSIS_PAY_ACCESS);
61
- setHasGnosisPayToken(false);
62
- setAccessTokenCreatedAt(0);
63
- clearInterval(interval);
64
- }
65
- }, 1000);
66
- return function () {
67
- clearInterval(interval);
68
- };
69
- }, [accessTokenCreatedAt, fn]);
70
- var grantAccess = function grantAccess() {
71
- var button = document.getElementById("grant-gnosispay-access");
72
- if (!button) return;
73
- button.click();
74
- setIsLoading(true);
75
- var interval = setInterval(function () {
76
- handleGnosisPayToken(function () {
77
- clearInterval(interval);
78
- setIsLoading(false);
79
- });
80
- }, 5000);
81
- gnosisTokenTokenIntervalRef.current = interval;
82
- };
83
- return {
84
- grantAccess: grantAccess,
85
- handleGnosisPayToken: handleGnosisPayToken,
86
- hasGnosisPayToken: hasGnosisPayToken,
87
- isWrongGnosisPayConnector: isWrongGnosisPayConnector,
88
- isLoading: isLoading,
89
- accessTokenCreatedAt: accessTokenCreatedAt,
90
- timeLeft: timeLeft
91
- };
92
- };
93
- export default useGnosisPay;
@@ -1,3 +0,0 @@
1
- export declare function formatTimeLeft(msLeft: number): string;
2
- export declare function timeFromNowMessage(expiryStr: string): string;
3
- export declare function getJwtExpiry(token: string): number;
@@ -1,25 +0,0 @@
1
- export function formatTimeLeft(msLeft) {
2
- var totalSeconds = Math.max(0, Math.floor(msLeft / 1000));
3
- var minutes = String(Math.floor(totalSeconds / 60)).padStart(2, "0");
4
- var seconds = String(totalSeconds % 60).padStart(2, "0");
5
- return "".concat(minutes, ":").concat(seconds);
6
- }
7
- export function timeFromNowMessage(expiryStr) {
8
- if (!expiryStr) {
9
- return "0 minute";
10
- }
11
- var mm = expiryStr.split(":").map(Number)[0];
12
- return "".concat(mm, " minute").concat(mm !== 1 ? "s" : "");
13
- }
14
- export function getJwtExpiry(token) {
15
- var _a;
16
- try {
17
- var payloadBase64 = (_a = token === null || token === void 0 ? void 0 : token.split(".")) === null || _a === void 0 ? void 0 : _a[1];
18
- if (!payloadBase64) return 0;
19
- var payloadJson = atob(payloadBase64);
20
- var payload = JSON.parse(payloadJson);
21
- return typeof payload.exp === "number" ? payload.exp : 0;
22
- } catch (error) {
23
- return 0;
24
- }
25
- }
@@ -1 +0,0 @@
1
- export declare const GNOSIS_PAY_ACCESS = "GNOSIS_PAY_ACCESS";
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.GNOSIS_PAY_ACCESS = void 0;
7
- var GNOSIS_PAY_ACCESS = exports.GNOSIS_PAY_ACCESS = "GNOSIS_PAY_ACCESS";
@@ -1,10 +0,0 @@
1
- declare const useGnosisPay: (fn: any) => {
2
- grantAccess: () => void;
3
- handleGnosisPayToken: (onDone?: () => void) => void;
4
- hasGnosisPayToken: boolean;
5
- isWrongGnosisPayConnector: boolean;
6
- isLoading: boolean;
7
- accessTokenCreatedAt: number;
8
- timeLeft: string;
9
- };
10
- export default useGnosisPay;
@@ -1,99 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = require("react");
8
- var _cryptoConstants = require("@fileverse-dev/formulajs/crypto-constants");
9
- var _constants = require("./constants");
10
- var _utils = require("./utils/utils");
11
- var useGnosisPay = function useGnosisPay(fn) {
12
- var gnosisTokenTokenIntervalRef = (0, _react.useRef)(null);
13
- var _a = (0, _react.useState)(false),
14
- isLoading = _a[0],
15
- setIsLoading = _a[1];
16
- var _b = (0, _react.useState)(false),
17
- hasGnosisPayToken = _b[0],
18
- setHasGnosisPayToken = _b[1];
19
- var _c = (0, _react.useState)("00:00"),
20
- timeLeft = _c[0],
21
- setTimeLeft = _c[1];
22
- var _d = (0, _react.useState)(0),
23
- accessTokenCreatedAt = _d[0],
24
- setAccessTokenCreatedAt = _d[1];
25
- var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
26
- var handleGnosisPayToken = function handleGnosisPayToken(onDone) {
27
- if (localStorage.getItem(_constants.GNOSIS_PAY_ACCESS)) {
28
- var access = localStorage.getItem(_constants.GNOSIS_PAY_ACCESS) || "";
29
- if (!access || (0, _cryptoConstants.isGnosisPayAccessExpired)(access)) {
30
- if (hasGnosisPayToken) {
31
- setHasGnosisPayToken(false);
32
- }
33
- if (accessTokenCreatedAt) {
34
- setAccessTokenCreatedAt(0);
35
- }
36
- localStorage.removeItem(_constants.GNOSIS_PAY_ACCESS);
37
- return;
38
- }
39
- setHasGnosisPayToken(!!access);
40
- setAccessTokenCreatedAt((0, _utils.getJwtExpiry)(access));
41
- onDone === null || onDone === void 0 ? void 0 : onDone();
42
- } else {
43
- var urlParams = new URLSearchParams(window.location.search);
44
- var isRejected = urlParams.has("reject");
45
- if (isRejected) {
46
- var url = new URL(window.location.href);
47
- url.searchParams.delete("reject");
48
- window.history.replaceState({}, "", url.toString());
49
- onDone === null || onDone === void 0 ? void 0 : onDone();
50
- }
51
- }
52
- };
53
- (0, _react.useEffect)(function () {
54
- return function () {
55
- if (gnosisTokenTokenIntervalRef.current) clearInterval(gnosisTokenTokenIntervalRef.current);
56
- };
57
- }, [gnosisTokenTokenIntervalRef]);
58
- (0, _react.useEffect)(function () {
59
- if (accessTokenCreatedAt <= 0) return function () {};
60
- var interval = setInterval(function () {
61
- var access = localStorage.getItem(_constants.GNOSIS_PAY_ACCESS) || "";
62
- var expiryTimestamp = (0, _utils.getJwtExpiry)(access) * 1000;
63
- var newTimeLeft = expiryTimestamp - Date.now();
64
- setTimeLeft((0, _utils.formatTimeLeft)(newTimeLeft));
65
- if ((0, _cryptoConstants.isGnosisPayAccessExpired)(localStorage.getItem(_constants.GNOSIS_PAY_ACCESS)) || !document.getElementById("gnosis-pay-area")) {
66
- localStorage.removeItem(_constants.GNOSIS_PAY_ACCESS);
67
- setHasGnosisPayToken(false);
68
- setAccessTokenCreatedAt(0);
69
- clearInterval(interval);
70
- }
71
- }, 1000);
72
- return function () {
73
- clearInterval(interval);
74
- };
75
- }, [accessTokenCreatedAt, fn]);
76
- var grantAccess = function grantAccess() {
77
- var button = document.getElementById("grant-gnosispay-access");
78
- if (!button) return;
79
- button.click();
80
- setIsLoading(true);
81
- var interval = setInterval(function () {
82
- handleGnosisPayToken(function () {
83
- clearInterval(interval);
84
- setIsLoading(false);
85
- });
86
- }, 5000);
87
- gnosisTokenTokenIntervalRef.current = interval;
88
- };
89
- return {
90
- grantAccess: grantAccess,
91
- handleGnosisPayToken: handleGnosisPayToken,
92
- hasGnosisPayToken: hasGnosisPayToken,
93
- isWrongGnosisPayConnector: isWrongGnosisPayConnector,
94
- isLoading: isLoading,
95
- accessTokenCreatedAt: accessTokenCreatedAt,
96
- timeLeft: timeLeft
97
- };
98
- };
99
- var _default = exports.default = useGnosisPay;
@@ -1,3 +0,0 @@
1
- export declare function formatTimeLeft(msLeft: number): string;
2
- export declare function timeFromNowMessage(expiryStr: string): string;
3
- export declare function getJwtExpiry(token: string): number;
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.formatTimeLeft = formatTimeLeft;
7
- exports.getJwtExpiry = getJwtExpiry;
8
- exports.timeFromNowMessage = timeFromNowMessage;
9
- function formatTimeLeft(msLeft) {
10
- var totalSeconds = Math.max(0, Math.floor(msLeft / 1000));
11
- var minutes = String(Math.floor(totalSeconds / 60)).padStart(2, "0");
12
- var seconds = String(totalSeconds % 60).padStart(2, "0");
13
- return "".concat(minutes, ":").concat(seconds);
14
- }
15
- function timeFromNowMessage(expiryStr) {
16
- if (!expiryStr) {
17
- return "0 minute";
18
- }
19
- var mm = expiryStr.split(":").map(Number)[0];
20
- return "".concat(mm, " minute").concat(mm !== 1 ? "s" : "");
21
- }
22
- function getJwtExpiry(token) {
23
- var _a;
24
- try {
25
- var payloadBase64 = (_a = token === null || token === void 0 ? void 0 : token.split(".")) === null || _a === void 0 ? void 0 : _a[1];
26
- if (!payloadBase64) return 0;
27
- var payloadJson = atob(payloadBase64);
28
- var payload = JSON.parse(payloadJson);
29
- return typeof payload.exp === "number" ? payload.exp : 0;
30
- } catch (error) {
31
- return 0;
32
- }
33
- }