@fileverse-dev/fortune-react 1.0.97 → 1.0.99
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/SearchReplace/index.js +25 -34
- package/es/components/Sheet/index.js +2 -1
- package/es/components/SheetOverlay/FormulaSearch/index.js +1 -1
- package/es/components/Toolbar/Combo.d.ts +1 -0
- package/es/components/Toolbar/Combo.js +8 -2
- package/es/components/Toolbar/index.css +4 -0
- package/es/components/Toolbar/index.d.ts +6 -0
- package/es/components/Toolbar/index.js +228 -195
- package/lib/components/SearchReplace/index.js +24 -33
- package/lib/components/Sheet/index.js +2 -1
- package/lib/components/SheetOverlay/FormulaSearch/index.js +1 -1
- package/lib/components/Toolbar/Combo.d.ts +1 -0
- package/lib/components/Toolbar/Combo.js +8 -2
- package/lib/components/Toolbar/index.css +4 -0
- package/lib/components/Toolbar/index.d.ts +6 -0
- package/lib/components/Toolbar/index.js +229 -196
- package/package.json +2 -2
|
@@ -15,36 +15,35 @@ var _useAlert = require("../../hooks/useAlert");
|
|
|
15
15
|
require("./index.css");
|
|
16
16
|
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
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
-
var SearchReplace = function SearchReplace(
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
refs = _b.refs;
|
|
18
|
+
var SearchReplace = function SearchReplace() {
|
|
19
|
+
var _a = (0, _react.useContext)(_context.default),
|
|
20
|
+
context = _a.context,
|
|
21
|
+
setContext = _a.setContext,
|
|
22
|
+
refs = _a.refs;
|
|
24
23
|
var findAndReplace = (0, _fortuneCore.locale)(context).findAndReplace;
|
|
24
|
+
var _b = (0, _react.useState)(""),
|
|
25
|
+
searchText = _b[0],
|
|
26
|
+
setSearchText = _b[1];
|
|
25
27
|
var _c = (0, _react.useState)(""),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var _d = (0, _react.useState)(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var _e = (0, _react.useState)(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var _f = (0, _react.useState)(),
|
|
35
|
-
selectedCell = _f[0],
|
|
36
|
-
setSelectedCell = _f[1];
|
|
28
|
+
replaceText = _c[0],
|
|
29
|
+
setReplaceText = _c[1];
|
|
30
|
+
var _d = (0, _react.useState)([]),
|
|
31
|
+
searchResult = _d[0],
|
|
32
|
+
setSearchResult = _d[1];
|
|
33
|
+
var _e = (0, _react.useState)(),
|
|
34
|
+
selectedCell = _e[0],
|
|
35
|
+
setSelectedCell = _e[1];
|
|
37
36
|
var showAlert = (0, _useAlert.useAlert)().showAlert;
|
|
38
37
|
var tableContainerRef = (0, _react.useRef)(null);
|
|
39
38
|
var searchInputRef = (0, _react.useRef)(null);
|
|
40
39
|
var replaceInputRef = (0, _react.useRef)(null);
|
|
41
|
-
var
|
|
40
|
+
var _f = (0, _react.useState)({
|
|
42
41
|
regCheck: false,
|
|
43
42
|
wordCheck: false,
|
|
44
43
|
caseCheck: false
|
|
45
44
|
}),
|
|
46
|
-
checkMode =
|
|
47
|
-
checkModeReplace =
|
|
45
|
+
checkMode = _f[0],
|
|
46
|
+
checkModeReplace = _f[1];
|
|
48
47
|
var closeDialog = (0, _react.useCallback)(function () {
|
|
49
48
|
_lodash.default.set(refs.globalCache, "searchDialog.mouseEnter", false);
|
|
50
49
|
setContext(function (draftCtx) {
|
|
@@ -57,27 +56,19 @@ var SearchReplace = function SearchReplace(_a) {
|
|
|
57
56
|
_lodash.default.set(draft, mode, value);
|
|
58
57
|
}));
|
|
59
58
|
}, []);
|
|
60
|
-
var getInitialPosition = (0, _react.useCallback)(function (container) {
|
|
61
|
-
var rect = container.getBoundingClientRect();
|
|
62
|
-
return {
|
|
63
|
-
left: (rect.width - 500) / 2,
|
|
64
|
-
top: (rect.height - 200) / 3
|
|
65
|
-
};
|
|
66
|
-
}, []);
|
|
67
59
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
68
60
|
id: "fortune-search-replace",
|
|
69
61
|
className: "fortune-search-replace fortune-dialog",
|
|
70
|
-
style:
|
|
62
|
+
style: {
|
|
63
|
+
top: "50%",
|
|
64
|
+
left: "50%",
|
|
65
|
+
transform: "translate(-50%, -50%)"
|
|
66
|
+
},
|
|
71
67
|
onMouseEnter: function onMouseEnter() {
|
|
72
68
|
_lodash.default.set(refs.globalCache, "searchDialog.mouseEnter", true);
|
|
73
69
|
},
|
|
74
70
|
onMouseLeave: function onMouseLeave() {
|
|
75
71
|
_lodash.default.set(refs.globalCache, "searchDialog.mouseEnter", false);
|
|
76
|
-
},
|
|
77
|
-
onMouseDown: function onMouseDown(e) {
|
|
78
|
-
var nativeEvent = e.nativeEvent;
|
|
79
|
-
(0, _fortuneCore.onSearchDialogMoveStart)(refs.globalCache, nativeEvent, getContainer());
|
|
80
|
-
e.stopPropagation();
|
|
81
72
|
}
|
|
82
73
|
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
83
74
|
className: "flex items-center justify-between border-b color-border-default py-3 px-6"
|
|
@@ -153,11 +153,12 @@ var Sheet = function Sheet(_a) {
|
|
|
153
153
|
}
|
|
154
154
|
}, [context, refs.canvas, refs.globalCache.freezen, setContext, sheet.id]);
|
|
155
155
|
var onWheel = (0, _react.useCallback)(function (e) {
|
|
156
|
+
var _a, _b;
|
|
156
157
|
var functionDetailsEl = document.getElementById("function-details");
|
|
157
158
|
var formulaSearchEl = document.getElementById("luckysheet-formula-search-c");
|
|
158
159
|
var isMouseOverFunctionDetails = functionDetailsEl === null || functionDetailsEl === void 0 ? void 0 : functionDetailsEl.matches(":hover");
|
|
159
160
|
var isMouseOverFormulaSearch = formulaSearchEl === null || formulaSearchEl === void 0 ? void 0 : formulaSearchEl.matches(":hover");
|
|
160
|
-
if (functionDetailsEl && isMouseOverFunctionDetails || formulaSearchEl && isMouseOverFormulaSearch) return;
|
|
161
|
+
if (functionDetailsEl && isMouseOverFunctionDetails || formulaSearchEl && isMouseOverFormulaSearch || ((_b = (_a = refs === null || refs === void 0 ? void 0 : refs.globalCache) === null || _a === void 0 ? void 0 : _a.searchDialog) === null || _b === void 0 ? void 0 : _b.mouseEnter)) return;
|
|
161
162
|
setContext(function (draftCtx) {
|
|
162
163
|
(0, _fortuneCore.handleGlobalWheel)(draftCtx, e, refs.globalCache, refs.scrollbarX.current, refs.scrollbarY.current);
|
|
163
164
|
});
|
|
@@ -28,7 +28,7 @@ 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 authedFunction = ["COINGECKO", "ETHERSCAN", "DEFILLAMA", "GNOSIS", "BASE", "EOA", "PNL", "SAFE", "BLOCKSCOUT", "GNOSIS", "LENS", "FARCASTER", "Ethereum", "SMARTCONTRACT"];
|
|
31
|
+
var authedFunction = ["COINGECKO", "ETHERSCAN", "DEFILLAMA", "GNOSIS", "BASE", "EOA", "PNL", "SAFE", "BLOCKSCOUT", "GNOSIS", "LENS", "FARCASTER", "Ethereum", "SMARTCONTRACT", "DUNESIM"];
|
|
32
32
|
var filteredDefaultCandidates = context.defaultCandidates.filter(function (item) {
|
|
33
33
|
return !authedFunction.includes(item.n);
|
|
34
34
|
});
|
|
@@ -7,6 +7,7 @@ type Props = {
|
|
|
7
7
|
onClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
8
8
|
children: (setOpen: React.Dispatch<React.SetStateAction<boolean>>) => React.ReactNode;
|
|
9
9
|
fillColor?: string;
|
|
10
|
+
triggerRef?: React.RefObject<HTMLButtonElement | null>;
|
|
10
11
|
};
|
|
11
12
|
declare const Combo: React.FC<Props>;
|
|
12
13
|
export default Combo;
|
|
@@ -19,7 +19,8 @@ var Combo = function Combo(_a) {
|
|
|
19
19
|
_b = _a.showArrow,
|
|
20
20
|
showArrow = _b === void 0 ? true : _b,
|
|
21
21
|
children = _a.children,
|
|
22
|
-
fillColor = _a.fillColor
|
|
22
|
+
fillColor = _a.fillColor,
|
|
23
|
+
triggerRef = _a.triggerRef;
|
|
23
24
|
var style = {
|
|
24
25
|
userSelect: "none"
|
|
25
26
|
};
|
|
@@ -27,6 +28,10 @@ var Combo = function Combo(_a) {
|
|
|
27
28
|
open = _c[0],
|
|
28
29
|
setOpen = _c[1];
|
|
29
30
|
var buttonRef = (0, _react.useRef)(null);
|
|
31
|
+
var ref = (0, _react.useRef)(null);
|
|
32
|
+
if (!triggerRef) {
|
|
33
|
+
triggerRef = ref;
|
|
34
|
+
}
|
|
30
35
|
var handleOpenChange = function handleOpenChange(newOpen) {
|
|
31
36
|
setOpen(newOpen);
|
|
32
37
|
};
|
|
@@ -82,7 +87,7 @@ var Combo = function Combo(_a) {
|
|
|
82
87
|
icon: (0, _.getLucideIcon)(iconId),
|
|
83
88
|
variant: "ghost",
|
|
84
89
|
onClick: function onClick() {
|
|
85
|
-
|
|
90
|
+
setOpen(!open);
|
|
86
91
|
},
|
|
87
92
|
className: (0, _ui.cn)("fortune-toolbar-combo-button", {
|
|
88
93
|
"custom-color-button": iconId === "font-color" && fillColor,
|
|
@@ -103,6 +108,7 @@ var Combo = function Combo(_a) {
|
|
|
103
108
|
onOpenChange: handleOpenChange,
|
|
104
109
|
modal: true
|
|
105
110
|
}, /*#__PURE__*/_react.default.createElement(_ui.PopoverTrigger, {
|
|
111
|
+
ref: triggerRef,
|
|
106
112
|
asChild: true
|
|
107
113
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
108
114
|
className: "flex items-center"
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { Cell } from "@fileverse-dev/fortune-core";
|
|
2
3
|
import "./index.css";
|
|
3
4
|
export declare const getLucideIcon: (title: string) => "Ethereum" | "DollarSign" | "" | "ChevronDown" | "Undo" | "Redo" | "PaintRoller" | "Bold" | "Italic" | "Strikethrough" | "Underline" | "AlignLeft" | "AlignCenter" | "AlignRight" | "ArrowUpFromLine" | "AlignVerticalMiddle" | "ArrowDownToLine" | "TextOverflow" | "WrapText" | "TextClip" | "Baseline" | "PaintBucket" | "Border" | "MergeHorizontal" | "Percent" | "DecimalsArrowLeft" | "DecimalsArrowRight" | "PaintbrushVertical" | "Filter" | "Link" | "MessageSquarePlus" | "Image" | "Sigma" | "ShieldCheck" | "Search" | "DuneChart" | "Ellipsis";
|
|
5
|
+
export declare const CurrencySelector: ({ cell, defaultTextFormat, toolTipText, }: {
|
|
6
|
+
cell: Cell | null | undefined;
|
|
7
|
+
defaultTextFormat: string;
|
|
8
|
+
toolTipText: string;
|
|
9
|
+
}) => React.JSX.Element;
|
|
4
10
|
declare const Toolbar: React.FC<{
|
|
5
11
|
setMoreItems: React.Dispatch<React.SetStateAction<React.ReactNode>>;
|
|
6
12
|
moreItemsOpen: boolean;
|
|
@@ -4,7 +4,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getLucideIcon = exports.default = void 0;
|
|
7
|
+
exports.getLucideIcon = exports.default = exports.CurrencySelector = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _fortuneCore = require("@fileverse-dev/fortune-core");
|
|
10
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
@@ -236,6 +236,223 @@ var getLucideIcon = exports.getLucideIcon = function getLucideIcon(title) {
|
|
|
236
236
|
return "";
|
|
237
237
|
}
|
|
238
238
|
};
|
|
239
|
+
var CurrencySelector = exports.CurrencySelector = function CurrencySelector(_a) {
|
|
240
|
+
var cell = _a.cell,
|
|
241
|
+
defaultTextFormat = _a.defaultTextFormat,
|
|
242
|
+
toolTipText = _a.toolTipText;
|
|
243
|
+
var _b = (0, _react.useContext)(_context.default),
|
|
244
|
+
context = _b.context,
|
|
245
|
+
setContext = _b.setContext,
|
|
246
|
+
refs = _b.refs;
|
|
247
|
+
var _c = (0, _react.useState)(""),
|
|
248
|
+
searchTerm = _c[0],
|
|
249
|
+
setSearchTerm = _c[1];
|
|
250
|
+
var _d = (0, _react.useState)(2),
|
|
251
|
+
decimals = _d[0],
|
|
252
|
+
setDecimals = _d[1];
|
|
253
|
+
var _e = (0, _react.useState)("USD"),
|
|
254
|
+
selectedFiat = _e[0],
|
|
255
|
+
setSelectedFiat = _e[1];
|
|
256
|
+
var currentFmt = defaultTextFormat;
|
|
257
|
+
var currentIcon = "currency";
|
|
258
|
+
if (cell) {
|
|
259
|
+
var curr_1 = (0, _fortuneCore.normalizedCellAttr)(cell, "ct");
|
|
260
|
+
if (curr_1 === null || curr_1 === void 0 ? void 0 : curr_1.fa) {
|
|
261
|
+
var allOptions = __spreadArray(__spreadArray([], _constants.CRYPTO_OPTIONS, true), (0, _fortuneCore.locale)(context).currencyDetail.map(function (c) {
|
|
262
|
+
return {
|
|
263
|
+
label: c.name,
|
|
264
|
+
value: c.value,
|
|
265
|
+
icon: undefined,
|
|
266
|
+
type: "fiat"
|
|
267
|
+
};
|
|
268
|
+
}), true);
|
|
269
|
+
var found = __spreadArray([], allOptions, true).sort(function (a, b) {
|
|
270
|
+
return b.value.length - a.value.length;
|
|
271
|
+
}).find(function (o) {
|
|
272
|
+
return curr_1.fa.includes(o.value);
|
|
273
|
+
});
|
|
274
|
+
if (found) {
|
|
275
|
+
currentFmt = found.label;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
var groupedOptions = (0, _constants.getGroupedCurrencyOptions)((0, _fortuneCore.locale)(context).currencyDetail);
|
|
280
|
+
var filterOptions = function filterOptions(options) {
|
|
281
|
+
if (!searchTerm.trim()) return options;
|
|
282
|
+
var query = searchTerm.trim().toLowerCase();
|
|
283
|
+
return options.filter(function (opt) {
|
|
284
|
+
return query.split(/\s+/).every(function (word) {
|
|
285
|
+
return opt.label.toLowerCase().includes(word) || opt.value.toLowerCase().includes(word);
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
var dedupeByValue = function dedupeByValue(options) {
|
|
290
|
+
var seen = new Set();
|
|
291
|
+
return options.filter(function (opt) {
|
|
292
|
+
if (seen.has(opt.value)) return false;
|
|
293
|
+
seen.add(opt.value);
|
|
294
|
+
return true;
|
|
295
|
+
});
|
|
296
|
+
};
|
|
297
|
+
var handleCurrencyDecimalsChange = function handleCurrencyDecimalsChange(newDecimals) {
|
|
298
|
+
setDecimals(newDecimals);
|
|
299
|
+
var isCrypto = false;
|
|
300
|
+
if (cell && cell.ct && typeof cell.ct.fa === "string") {
|
|
301
|
+
var _a = cell.ct.fa.match(/"([A-Z]+)"/) || [],
|
|
302
|
+
matchedDenom = _a[1];
|
|
303
|
+
if (matchedDenom) isCrypto = true;
|
|
304
|
+
}
|
|
305
|
+
(0, _updateCellsDecimalFormat.updateCellsDecimalFormat)({
|
|
306
|
+
context: context,
|
|
307
|
+
setContext: setContext,
|
|
308
|
+
decimals: newDecimals,
|
|
309
|
+
denomination: isCrypto ? undefined : selectedFiat
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
var triggerRef = (0, _react.useRef)(null);
|
|
313
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
314
|
+
className: "items-center fortune-toolbar-button"
|
|
315
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
|
|
316
|
+
text: toolTipText,
|
|
317
|
+
placement: "bottom"
|
|
318
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
319
|
+
className: "",
|
|
320
|
+
onClick: function onClick() {
|
|
321
|
+
var _a;
|
|
322
|
+
(_a = triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
323
|
+
},
|
|
324
|
+
tabIndex: 0,
|
|
325
|
+
role: "button"
|
|
326
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
|
|
327
|
+
name: getLucideIcon("currency-format"),
|
|
328
|
+
width: 16,
|
|
329
|
+
height: 16
|
|
330
|
+
}))), /*#__PURE__*/_react.default.createElement(_Combo.default, {
|
|
331
|
+
iconId: currentIcon,
|
|
332
|
+
text: currentFmt,
|
|
333
|
+
key: "currency",
|
|
334
|
+
tooltip: "",
|
|
335
|
+
showArrow: true,
|
|
336
|
+
triggerRef: triggerRef
|
|
337
|
+
}, function (setOpen) {
|
|
338
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
339
|
+
style: {
|
|
340
|
+
minWidth: "20rem",
|
|
341
|
+
boxShadow: "2px 2px 10px rgba(0, 0, 0, 0.2)",
|
|
342
|
+
borderRadius: "8px"
|
|
343
|
+
}
|
|
344
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Command, {
|
|
345
|
+
className: "border color-border-default rounded-lg"
|
|
346
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
347
|
+
id: "search-input-container"
|
|
348
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.CommandInput, {
|
|
349
|
+
placeholder: "Search by name or code",
|
|
350
|
+
value: searchTerm,
|
|
351
|
+
onValueChange: setSearchTerm
|
|
352
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
353
|
+
className: "px-4 py-2 border-b color-border-default flex items-center justify-between gap-2 text-body-sm color-text-default",
|
|
354
|
+
onClick: function onClick(e) {
|
|
355
|
+
return e.stopPropagation();
|
|
356
|
+
}
|
|
357
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, "Decimal places:"), /*#__PURE__*/_react.default.createElement("span", {
|
|
358
|
+
className: "cds-row flex items-center"
|
|
359
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.IconButton, {
|
|
360
|
+
icon: "Minus",
|
|
361
|
+
variant: "ghost",
|
|
362
|
+
size: "sm",
|
|
363
|
+
className: "",
|
|
364
|
+
disabled: decimals === 1,
|
|
365
|
+
onClick: function onClick() {
|
|
366
|
+
return handleCurrencyDecimalsChange(Math.max(1, decimals - 1));
|
|
367
|
+
}
|
|
368
|
+
}), /*#__PURE__*/_react.default.createElement("input", {
|
|
369
|
+
type: "number",
|
|
370
|
+
min: 1,
|
|
371
|
+
max: 18,
|
|
372
|
+
value: decimals,
|
|
373
|
+
onChange: function onChange(e) {
|
|
374
|
+
return handleCurrencyDecimalsChange(Math.max(1, Math.min(18, Number(e.target.value))));
|
|
375
|
+
}
|
|
376
|
+
}), /*#__PURE__*/_react.default.createElement(_ui.IconButton, {
|
|
377
|
+
icon: "Plus",
|
|
378
|
+
variant: "ghost",
|
|
379
|
+
size: "sm",
|
|
380
|
+
disabled: decimals === 18,
|
|
381
|
+
onClick: function onClick() {
|
|
382
|
+
return handleCurrencyDecimalsChange(Math.min(18, decimals + 1));
|
|
383
|
+
}
|
|
384
|
+
}))), /*#__PURE__*/_react.default.createElement(_ui.CommandList, null, /*#__PURE__*/_react.default.createElement(_ui.CommandEmpty, {
|
|
385
|
+
className: "text-center text-body-sm color-text-secondary flex items-center justify-center",
|
|
386
|
+
style: {
|
|
387
|
+
minHeight: "5rem"
|
|
388
|
+
}
|
|
389
|
+
}, "No results found."), groupedOptions.map(function (group) {
|
|
390
|
+
var filtered = dedupeByValue(filterOptions(group.options));
|
|
391
|
+
return /*#__PURE__*/_react.default.createElement(_ui.CommandGroup, {
|
|
392
|
+
key: group.group,
|
|
393
|
+
heading: group.group
|
|
394
|
+
}, filtered.map(function (opt) {
|
|
395
|
+
return /*#__PURE__*/_react.default.createElement(_ui.CommandItem, {
|
|
396
|
+
key: opt.value,
|
|
397
|
+
value: "".concat(opt.label, " ").concat(opt.value),
|
|
398
|
+
onSelect: function onSelect() {
|
|
399
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
400
|
+
return __generator(this, function (_a) {
|
|
401
|
+
switch (_a.label) {
|
|
402
|
+
case 0:
|
|
403
|
+
if (!(opt.type === "crypto")) return [3, 2];
|
|
404
|
+
return [4, (0, _convertCellsToCrypto.convertCellsToCrypto)({
|
|
405
|
+
context: context,
|
|
406
|
+
setContext: setContext,
|
|
407
|
+
denomination: opt.value,
|
|
408
|
+
decimals: decimals
|
|
409
|
+
})];
|
|
410
|
+
case 1:
|
|
411
|
+
_a.sent();
|
|
412
|
+
return [3, 3];
|
|
413
|
+
case 2:
|
|
414
|
+
setSelectedFiat(opt.value);
|
|
415
|
+
setContext(function (ctx) {
|
|
416
|
+
var d = (0, _fortuneCore.getFlowdata)(ctx);
|
|
417
|
+
if (d == null) return;
|
|
418
|
+
var formatString = "".concat((0, _convertCellsToCrypto.getFiatSymbol)(opt.value), " #,##0.").concat("0".repeat(decimals));
|
|
419
|
+
(0, _fortuneCore.updateFormat)(ctx, refs.cellInput.current, d, "ct", formatString);
|
|
420
|
+
});
|
|
421
|
+
_a.label = 3;
|
|
422
|
+
case 3:
|
|
423
|
+
setOpen(false);
|
|
424
|
+
return [2];
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
430
|
+
className: "fortune-toolbar-menu-line flex items-center justify-between w-full"
|
|
431
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
432
|
+
className: "flex items-center gap-2 w-[250px]"
|
|
433
|
+
}, currentFmt === opt.label ? (/*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
|
|
434
|
+
name: "Check",
|
|
435
|
+
className: "w-4 h-4"
|
|
436
|
+
})) : (/*#__PURE__*/_react.default.createElement("span", {
|
|
437
|
+
className: "w-4 h-4"
|
|
438
|
+
})), /*#__PURE__*/_react.default.createElement("span", {
|
|
439
|
+
className: "truncate flex-1 overflow-hidden whitespace-nowrap"
|
|
440
|
+
}, opt.label)), opt.type === "crypto" ? (/*#__PURE__*/_react.default.createElement("span", {
|
|
441
|
+
className: "color-text-secondary"
|
|
442
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
|
|
443
|
+
name: opt.icon,
|
|
444
|
+
className: "cds-icon"
|
|
445
|
+
}), opt.value === "SOL" && (/*#__PURE__*/_react.default.createElement(_SVGIcon.default, {
|
|
446
|
+
name: "solana",
|
|
447
|
+
width: 16,
|
|
448
|
+
height: 16
|
|
449
|
+
})))) : (/*#__PURE__*/_react.default.createElement("span", {
|
|
450
|
+
className: "color-text-secondary"
|
|
451
|
+
}, opt.value))));
|
|
452
|
+
}));
|
|
453
|
+
}))));
|
|
454
|
+
}));
|
|
455
|
+
};
|
|
239
456
|
var Toolbar = function Toolbar(_a) {
|
|
240
457
|
var _b, _c, _d;
|
|
241
458
|
var setMoreItems = _a.setMoreItems,
|
|
@@ -295,15 +512,6 @@ var Toolbar = function Toolbar(_a) {
|
|
|
295
512
|
var defaultFormat = defaultFmt(currency);
|
|
296
513
|
var customColor = (0, _react.useState)("#000000")[0];
|
|
297
514
|
var customStyle = (0, _react.useState)("1")[0];
|
|
298
|
-
var _m = (0, _react.useState)(""),
|
|
299
|
-
searchTerm = _m[0],
|
|
300
|
-
setSearchTerm = _m[1];
|
|
301
|
-
var _o = (0, _react.useState)(2),
|
|
302
|
-
decimals = _o[0],
|
|
303
|
-
setDecimals = _o[1];
|
|
304
|
-
var _p = (0, _react.useState)("USD"),
|
|
305
|
-
selectedFiat = _p[0],
|
|
306
|
-
setSelectedFiat = _p[1];
|
|
307
515
|
var showSubMenu = (0, _react.useCallback)(function (e, className) {
|
|
308
516
|
var target = e.target;
|
|
309
517
|
var menuItem = target.className === "fortune-toolbar-menu-line" ? target.parentElement : target;
|
|
@@ -438,11 +646,11 @@ var Toolbar = function Toolbar(_a) {
|
|
|
438
646
|
if (name === "format") {
|
|
439
647
|
var currentFmt = defaultFormat[0].text;
|
|
440
648
|
if (cell) {
|
|
441
|
-
var
|
|
649
|
+
var curr_2 = (0, _fortuneCore.normalizedCellAttr)(cell, "ct");
|
|
442
650
|
var format = _lodash.default.find(defaultFormat, function (v) {
|
|
443
|
-
return v.value === (
|
|
651
|
+
return v.value === (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa);
|
|
444
652
|
});
|
|
445
|
-
if ((
|
|
653
|
+
if ((curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) != null) {
|
|
446
654
|
if (format != null) {
|
|
447
655
|
currentFmt = format.text;
|
|
448
656
|
} else {
|
|
@@ -1219,12 +1427,12 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1219
1427
|
iconId: "text-wrap",
|
|
1220
1428
|
value: "wrap"
|
|
1221
1429
|
}];
|
|
1222
|
-
var
|
|
1430
|
+
var curr_3 = items_7[0];
|
|
1223
1431
|
if ((cell === null || cell === void 0 ? void 0 : cell.tb) != null) {
|
|
1224
|
-
|
|
1432
|
+
curr_3 = _lodash.default.get(items_7, cell.tb);
|
|
1225
1433
|
}
|
|
1226
1434
|
return /*#__PURE__*/_react.default.createElement(_Combo.default, {
|
|
1227
|
-
iconId:
|
|
1435
|
+
iconId: curr_3.iconId,
|
|
1228
1436
|
key: name,
|
|
1229
1437
|
tooltip: toolbar.textWrap,
|
|
1230
1438
|
showArrow: false
|
|
@@ -1243,7 +1451,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1243
1451
|
value = _a.value;
|
|
1244
1452
|
return /*#__PURE__*/_react.default.createElement(_ui.IconButton, {
|
|
1245
1453
|
key: value,
|
|
1246
|
-
isActive:
|
|
1454
|
+
isActive: curr_3.value === value,
|
|
1247
1455
|
icon: getLucideIcon(iconId),
|
|
1248
1456
|
variant: "ghost",
|
|
1249
1457
|
onClick: function onClick() {
|
|
@@ -1397,185 +1605,10 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1397
1605
|
});
|
|
1398
1606
|
}
|
|
1399
1607
|
if (name === "currency") {
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
if (curr_3 === null || curr_3 === void 0 ? void 0 : curr_3.fa) {
|
|
1405
|
-
var allOptions = __spreadArray(__spreadArray([], _constants.CRYPTO_OPTIONS, true), (0, _fortuneCore.locale)(context).currencyDetail.map(function (c) {
|
|
1406
|
-
return {
|
|
1407
|
-
label: c.name,
|
|
1408
|
-
value: c.value,
|
|
1409
|
-
icon: undefined,
|
|
1410
|
-
type: "fiat"
|
|
1411
|
-
};
|
|
1412
|
-
}), true);
|
|
1413
|
-
var found = __spreadArray([], allOptions, true).sort(function (a, b) {
|
|
1414
|
-
return b.value.length - a.value.length;
|
|
1415
|
-
}).find(function (o) {
|
|
1416
|
-
return curr_3.fa.includes(o.value);
|
|
1417
|
-
});
|
|
1418
|
-
if (found) {
|
|
1419
|
-
currentFmt_1 = found.label;
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
var groupedOptions_1 = (0, _constants.getGroupedCurrencyOptions)((0, _fortuneCore.locale)(context).currencyDetail);
|
|
1424
|
-
var filterOptions_1 = function filterOptions_1(options) {
|
|
1425
|
-
if (!searchTerm.trim()) return options;
|
|
1426
|
-
var query = searchTerm.trim().toLowerCase();
|
|
1427
|
-
return options.filter(function (opt) {
|
|
1428
|
-
return query.split(/\s+/).every(function (word) {
|
|
1429
|
-
return opt.label.toLowerCase().includes(word) || opt.value.toLowerCase().includes(word);
|
|
1430
|
-
});
|
|
1431
|
-
});
|
|
1432
|
-
};
|
|
1433
|
-
var dedupeByValue_1 = function dedupeByValue_1(options) {
|
|
1434
|
-
var seen = new Set();
|
|
1435
|
-
return options.filter(function (opt) {
|
|
1436
|
-
if (seen.has(opt.value)) return false;
|
|
1437
|
-
seen.add(opt.value);
|
|
1438
|
-
return true;
|
|
1439
|
-
});
|
|
1440
|
-
};
|
|
1441
|
-
var handleCurrencyDecimalsChange_1 = function handleCurrencyDecimalsChange_1(newDecimals) {
|
|
1442
|
-
setDecimals(newDecimals);
|
|
1443
|
-
var isCrypto = false;
|
|
1444
|
-
if (cell && cell.ct && typeof cell.ct.fa === "string") {
|
|
1445
|
-
var _a = cell.ct.fa.match(/"([A-Z]+)"/) || [],
|
|
1446
|
-
matchedDenom = _a[1];
|
|
1447
|
-
if (matchedDenom) isCrypto = true;
|
|
1448
|
-
}
|
|
1449
|
-
(0, _updateCellsDecimalFormat.updateCellsDecimalFormat)({
|
|
1450
|
-
context: context,
|
|
1451
|
-
setContext: setContext,
|
|
1452
|
-
decimals: newDecimals,
|
|
1453
|
-
denomination: isCrypto ? undefined : selectedFiat
|
|
1454
|
-
});
|
|
1455
|
-
};
|
|
1456
|
-
return /*#__PURE__*/_react.default.createElement(_Combo.default, {
|
|
1457
|
-
iconId: currentIcon,
|
|
1458
|
-
text: currentFmt_1,
|
|
1459
|
-
key: name,
|
|
1460
|
-
tooltip: tooltip,
|
|
1461
|
-
showArrow: true
|
|
1462
|
-
}, function (setOpen) {
|
|
1463
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
1464
|
-
style: {
|
|
1465
|
-
minWidth: "20rem",
|
|
1466
|
-
boxShadow: "2px 2px 10px rgba(0, 0, 0, 0.2)",
|
|
1467
|
-
borderRadius: "8px"
|
|
1468
|
-
}
|
|
1469
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.Command, {
|
|
1470
|
-
className: "border color-border-default rounded-lg"
|
|
1471
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1472
|
-
id: "search-input-container"
|
|
1473
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.CommandInput, {
|
|
1474
|
-
placeholder: "Search by name or code",
|
|
1475
|
-
value: searchTerm,
|
|
1476
|
-
onValueChange: setSearchTerm
|
|
1477
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
1478
|
-
className: "px-4 py-2 border-b color-border-default flex items-center justify-between gap-2 text-body-sm color-text-default",
|
|
1479
|
-
onClick: function onClick(e) {
|
|
1480
|
-
return e.stopPropagation();
|
|
1481
|
-
}
|
|
1482
|
-
}, /*#__PURE__*/_react.default.createElement("span", null, "Decimal places:"), /*#__PURE__*/_react.default.createElement("span", {
|
|
1483
|
-
className: "cds-row flex items-center"
|
|
1484
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.IconButton, {
|
|
1485
|
-
icon: "Minus",
|
|
1486
|
-
variant: "ghost",
|
|
1487
|
-
size: "sm",
|
|
1488
|
-
className: "",
|
|
1489
|
-
disabled: decimals === 1,
|
|
1490
|
-
onClick: function onClick() {
|
|
1491
|
-
return handleCurrencyDecimalsChange_1(Math.max(1, decimals - 1));
|
|
1492
|
-
}
|
|
1493
|
-
}), /*#__PURE__*/_react.default.createElement("input", {
|
|
1494
|
-
type: "number",
|
|
1495
|
-
min: 1,
|
|
1496
|
-
max: 18,
|
|
1497
|
-
value: decimals,
|
|
1498
|
-
onChange: function onChange(e) {
|
|
1499
|
-
return handleCurrencyDecimalsChange_1(Math.max(1, Math.min(18, Number(e.target.value))));
|
|
1500
|
-
}
|
|
1501
|
-
}), /*#__PURE__*/_react.default.createElement(_ui.IconButton, {
|
|
1502
|
-
icon: "Plus",
|
|
1503
|
-
variant: "ghost",
|
|
1504
|
-
size: "sm",
|
|
1505
|
-
disabled: decimals === 18,
|
|
1506
|
-
onClick: function onClick() {
|
|
1507
|
-
return handleCurrencyDecimalsChange_1(Math.min(18, decimals + 1));
|
|
1508
|
-
}
|
|
1509
|
-
}))), /*#__PURE__*/_react.default.createElement(_ui.CommandList, null, /*#__PURE__*/_react.default.createElement(_ui.CommandEmpty, {
|
|
1510
|
-
className: "text-center text-body-sm color-text-secondary flex items-center justify-center",
|
|
1511
|
-
style: {
|
|
1512
|
-
minHeight: "5rem"
|
|
1513
|
-
}
|
|
1514
|
-
}, "No results found."), groupedOptions_1.map(function (group) {
|
|
1515
|
-
var filtered = dedupeByValue_1(filterOptions_1(group.options));
|
|
1516
|
-
return /*#__PURE__*/_react.default.createElement(_ui.CommandGroup, {
|
|
1517
|
-
key: group.group,
|
|
1518
|
-
heading: group.group
|
|
1519
|
-
}, filtered.map(function (opt) {
|
|
1520
|
-
return /*#__PURE__*/_react.default.createElement(_ui.CommandItem, {
|
|
1521
|
-
key: opt.value,
|
|
1522
|
-
value: "".concat(opt.label, " ").concat(opt.value),
|
|
1523
|
-
onSelect: function onSelect() {
|
|
1524
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
1525
|
-
return __generator(this, function (_a) {
|
|
1526
|
-
switch (_a.label) {
|
|
1527
|
-
case 0:
|
|
1528
|
-
if (!(opt.type === "crypto")) return [3, 2];
|
|
1529
|
-
return [4, (0, _convertCellsToCrypto.convertCellsToCrypto)({
|
|
1530
|
-
context: context,
|
|
1531
|
-
setContext: setContext,
|
|
1532
|
-
denomination: opt.value,
|
|
1533
|
-
decimals: decimals
|
|
1534
|
-
})];
|
|
1535
|
-
case 1:
|
|
1536
|
-
_a.sent();
|
|
1537
|
-
return [3, 3];
|
|
1538
|
-
case 2:
|
|
1539
|
-
setSelectedFiat(opt.value);
|
|
1540
|
-
setContext(function (ctx) {
|
|
1541
|
-
var d = (0, _fortuneCore.getFlowdata)(ctx);
|
|
1542
|
-
if (d == null) return;
|
|
1543
|
-
var formatString = "".concat((0, _convertCellsToCrypto.getFiatSymbol)(opt.value), " #,##0.").concat("0".repeat(decimals));
|
|
1544
|
-
(0, _fortuneCore.updateFormat)(ctx, refs.cellInput.current, d, "ct", formatString);
|
|
1545
|
-
});
|
|
1546
|
-
_a.label = 3;
|
|
1547
|
-
case 3:
|
|
1548
|
-
setOpen(false);
|
|
1549
|
-
return [2];
|
|
1550
|
-
}
|
|
1551
|
-
});
|
|
1552
|
-
});
|
|
1553
|
-
}
|
|
1554
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1555
|
-
className: "fortune-toolbar-menu-line flex items-center justify-between w-full"
|
|
1556
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1557
|
-
className: "flex items-center gap-2 w-[250px]"
|
|
1558
|
-
}, currentFmt_1 === opt.label ? (/*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
|
|
1559
|
-
name: "Check",
|
|
1560
|
-
className: "w-4 h-4"
|
|
1561
|
-
})) : (/*#__PURE__*/_react.default.createElement("span", {
|
|
1562
|
-
className: "w-4 h-4"
|
|
1563
|
-
})), /*#__PURE__*/_react.default.createElement("span", {
|
|
1564
|
-
className: "truncate flex-1 overflow-hidden whitespace-nowrap"
|
|
1565
|
-
}, opt.label)), opt.type === "crypto" ? (/*#__PURE__*/_react.default.createElement("span", {
|
|
1566
|
-
className: "color-text-secondary"
|
|
1567
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
|
|
1568
|
-
name: opt.icon,
|
|
1569
|
-
className: "cds-icon"
|
|
1570
|
-
}), opt.value === "SOL" && (/*#__PURE__*/_react.default.createElement(_SVGIcon.default, {
|
|
1571
|
-
name: "solana",
|
|
1572
|
-
width: 16,
|
|
1573
|
-
height: 16
|
|
1574
|
-
})))) : (/*#__PURE__*/_react.default.createElement("span", {
|
|
1575
|
-
className: "color-text-secondary"
|
|
1576
|
-
}, opt.value))));
|
|
1577
|
-
}));
|
|
1578
|
-
}))));
|
|
1608
|
+
return /*#__PURE__*/_react.default.createElement(CurrencySelector, {
|
|
1609
|
+
cell: cell,
|
|
1610
|
+
defaultTextFormat: defaultFormat[0].text,
|
|
1611
|
+
toolTipText: toolbar["currency-format"]
|
|
1579
1612
|
});
|
|
1580
1613
|
}
|
|
1581
1614
|
return /*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
|