@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { locale, searchAll, searchNext, normalizeSelection,
|
|
1
|
+
import { locale, searchAll, searchNext, normalizeSelection, replace, replaceAll, scrollToHighlightCell } from "@fileverse-dev/fortune-core";
|
|
2
2
|
import { Button, Checkbox, cn, Divider, IconButton, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, TextField } from "@fileverse/ui";
|
|
3
3
|
import produce from "immer";
|
|
4
4
|
import React, { useContext, useState, useCallback, useRef } from "react";
|
|
@@ -6,36 +6,35 @@ import _ from "lodash";
|
|
|
6
6
|
import WorkbookContext from "../../context";
|
|
7
7
|
import { useAlert } from "../../hooks/useAlert";
|
|
8
8
|
import "./index.css";
|
|
9
|
-
var SearchReplace = function SearchReplace(
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
refs = _b.refs;
|
|
9
|
+
var SearchReplace = function SearchReplace() {
|
|
10
|
+
var _a = useContext(WorkbookContext),
|
|
11
|
+
context = _a.context,
|
|
12
|
+
setContext = _a.setContext,
|
|
13
|
+
refs = _a.refs;
|
|
15
14
|
var findAndReplace = locale(context).findAndReplace;
|
|
15
|
+
var _b = useState(""),
|
|
16
|
+
searchText = _b[0],
|
|
17
|
+
setSearchText = _b[1];
|
|
16
18
|
var _c = useState(""),
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _d = useState(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var _e = useState(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var _f = useState(),
|
|
26
|
-
selectedCell = _f[0],
|
|
27
|
-
setSelectedCell = _f[1];
|
|
19
|
+
replaceText = _c[0],
|
|
20
|
+
setReplaceText = _c[1];
|
|
21
|
+
var _d = useState([]),
|
|
22
|
+
searchResult = _d[0],
|
|
23
|
+
setSearchResult = _d[1];
|
|
24
|
+
var _e = useState(),
|
|
25
|
+
selectedCell = _e[0],
|
|
26
|
+
setSelectedCell = _e[1];
|
|
28
27
|
var showAlert = useAlert().showAlert;
|
|
29
28
|
var tableContainerRef = useRef(null);
|
|
30
29
|
var searchInputRef = useRef(null);
|
|
31
30
|
var replaceInputRef = useRef(null);
|
|
32
|
-
var
|
|
31
|
+
var _f = useState({
|
|
33
32
|
regCheck: false,
|
|
34
33
|
wordCheck: false,
|
|
35
34
|
caseCheck: false
|
|
36
35
|
}),
|
|
37
|
-
checkMode =
|
|
38
|
-
checkModeReplace =
|
|
36
|
+
checkMode = _f[0],
|
|
37
|
+
checkModeReplace = _f[1];
|
|
39
38
|
var closeDialog = useCallback(function () {
|
|
40
39
|
_.set(refs.globalCache, "searchDialog.mouseEnter", false);
|
|
41
40
|
setContext(function (draftCtx) {
|
|
@@ -48,27 +47,19 @@ var SearchReplace = function SearchReplace(_a) {
|
|
|
48
47
|
_.set(draft, mode, value);
|
|
49
48
|
}));
|
|
50
49
|
}, []);
|
|
51
|
-
var getInitialPosition = useCallback(function (container) {
|
|
52
|
-
var rect = container.getBoundingClientRect();
|
|
53
|
-
return {
|
|
54
|
-
left: (rect.width - 500) / 2,
|
|
55
|
-
top: (rect.height - 200) / 3
|
|
56
|
-
};
|
|
57
|
-
}, []);
|
|
58
50
|
return /*#__PURE__*/React.createElement("div", {
|
|
59
51
|
id: "fortune-search-replace",
|
|
60
52
|
className: "fortune-search-replace fortune-dialog",
|
|
61
|
-
style:
|
|
53
|
+
style: {
|
|
54
|
+
top: "50%",
|
|
55
|
+
left: "50%",
|
|
56
|
+
transform: "translate(-50%, -50%)"
|
|
57
|
+
},
|
|
62
58
|
onMouseEnter: function onMouseEnter() {
|
|
63
59
|
_.set(refs.globalCache, "searchDialog.mouseEnter", true);
|
|
64
60
|
},
|
|
65
61
|
onMouseLeave: function onMouseLeave() {
|
|
66
62
|
_.set(refs.globalCache, "searchDialog.mouseEnter", false);
|
|
67
|
-
},
|
|
68
|
-
onMouseDown: function onMouseDown(e) {
|
|
69
|
-
var nativeEvent = e.nativeEvent;
|
|
70
|
-
onSearchDialogMoveStart(refs.globalCache, nativeEvent, getContainer());
|
|
71
|
-
e.stopPropagation();
|
|
72
63
|
}
|
|
73
64
|
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
74
65
|
className: "flex items-center justify-between border-b color-border-default py-3 px-6"
|
|
@@ -144,11 +144,12 @@ var Sheet = function Sheet(_a) {
|
|
|
144
144
|
}
|
|
145
145
|
}, [context, refs.canvas, refs.globalCache.freezen, setContext, sheet.id]);
|
|
146
146
|
var onWheel = useCallback(function (e) {
|
|
147
|
+
var _a, _b;
|
|
147
148
|
var functionDetailsEl = document.getElementById("function-details");
|
|
148
149
|
var formulaSearchEl = document.getElementById("luckysheet-formula-search-c");
|
|
149
150
|
var isMouseOverFunctionDetails = functionDetailsEl === null || functionDetailsEl === void 0 ? void 0 : functionDetailsEl.matches(":hover");
|
|
150
151
|
var isMouseOverFormulaSearch = formulaSearchEl === null || formulaSearchEl === void 0 ? void 0 : formulaSearchEl.matches(":hover");
|
|
151
|
-
if (functionDetailsEl && isMouseOverFunctionDetails || formulaSearchEl && isMouseOverFormulaSearch) return;
|
|
152
|
+
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;
|
|
152
153
|
setContext(function (draftCtx) {
|
|
153
154
|
handleGlobalWheel(draftCtx, e, refs.globalCache, refs.scrollbarX.current, refs.scrollbarY.current);
|
|
154
155
|
});
|
|
@@ -19,7 +19,7 @@ var FormulaSearch = function FormulaSearch(props) {
|
|
|
19
19
|
var _b = useContext(WorkbookContext),
|
|
20
20
|
context = _b.context,
|
|
21
21
|
isAuthorized = _b.settings.isAuthorized;
|
|
22
|
-
var authedFunction = ["COINGECKO", "ETHERSCAN", "DEFILLAMA", "GNOSIS", "BASE", "EOA", "PNL", "SAFE", "BLOCKSCOUT", "GNOSIS", "LENS", "FARCASTER", "Ethereum", "SMARTCONTRACT"];
|
|
22
|
+
var authedFunction = ["COINGECKO", "ETHERSCAN", "DEFILLAMA", "GNOSIS", "BASE", "EOA", "PNL", "SAFE", "BLOCKSCOUT", "GNOSIS", "LENS", "FARCASTER", "Ethereum", "SMARTCONTRACT", "DUNESIM"];
|
|
23
23
|
var filteredDefaultCandidates = context.defaultCandidates.filter(function (item) {
|
|
24
24
|
return !authedFunction.includes(item.n);
|
|
25
25
|
});
|
|
@@ -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;
|
|
@@ -10,7 +10,8 @@ var Combo = function Combo(_a) {
|
|
|
10
10
|
_b = _a.showArrow,
|
|
11
11
|
showArrow = _b === void 0 ? true : _b,
|
|
12
12
|
children = _a.children,
|
|
13
|
-
fillColor = _a.fillColor
|
|
13
|
+
fillColor = _a.fillColor,
|
|
14
|
+
triggerRef = _a.triggerRef;
|
|
14
15
|
var style = {
|
|
15
16
|
userSelect: "none"
|
|
16
17
|
};
|
|
@@ -18,6 +19,10 @@ var Combo = function Combo(_a) {
|
|
|
18
19
|
open = _c[0],
|
|
19
20
|
setOpen = _c[1];
|
|
20
21
|
var buttonRef = useRef(null);
|
|
22
|
+
var ref = useRef(null);
|
|
23
|
+
if (!triggerRef) {
|
|
24
|
+
triggerRef = ref;
|
|
25
|
+
}
|
|
21
26
|
var handleOpenChange = function handleOpenChange(newOpen) {
|
|
22
27
|
setOpen(newOpen);
|
|
23
28
|
};
|
|
@@ -73,7 +78,7 @@ var Combo = function Combo(_a) {
|
|
|
73
78
|
icon: getLucideIcon(iconId),
|
|
74
79
|
variant: "ghost",
|
|
75
80
|
onClick: function onClick() {
|
|
76
|
-
|
|
81
|
+
setOpen(!open);
|
|
77
82
|
},
|
|
78
83
|
className: cn("fortune-toolbar-combo-button", {
|
|
79
84
|
"custom-color-button": iconId === "font-color" && fillColor,
|
|
@@ -94,6 +99,7 @@ var Combo = function Combo(_a) {
|
|
|
94
99
|
onOpenChange: handleOpenChange,
|
|
95
100
|
modal: true
|
|
96
101
|
}, /*#__PURE__*/React.createElement(PopoverTrigger, {
|
|
102
|
+
ref: triggerRef,
|
|
97
103
|
asChild: true
|
|
98
104
|
}, /*#__PURE__*/React.createElement("div", {
|
|
99
105
|
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;
|
|
@@ -227,6 +227,223 @@ export var getLucideIcon = function getLucideIcon(title) {
|
|
|
227
227
|
return "";
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
+
export var CurrencySelector = function CurrencySelector(_a) {
|
|
231
|
+
var cell = _a.cell,
|
|
232
|
+
defaultTextFormat = _a.defaultTextFormat,
|
|
233
|
+
toolTipText = _a.toolTipText;
|
|
234
|
+
var _b = useContext(WorkbookContext),
|
|
235
|
+
context = _b.context,
|
|
236
|
+
setContext = _b.setContext,
|
|
237
|
+
refs = _b.refs;
|
|
238
|
+
var _c = useState(""),
|
|
239
|
+
searchTerm = _c[0],
|
|
240
|
+
setSearchTerm = _c[1];
|
|
241
|
+
var _d = useState(2),
|
|
242
|
+
decimals = _d[0],
|
|
243
|
+
setDecimals = _d[1];
|
|
244
|
+
var _e = useState("USD"),
|
|
245
|
+
selectedFiat = _e[0],
|
|
246
|
+
setSelectedFiat = _e[1];
|
|
247
|
+
var currentFmt = defaultTextFormat;
|
|
248
|
+
var currentIcon = "currency";
|
|
249
|
+
if (cell) {
|
|
250
|
+
var curr_1 = normalizedCellAttr(cell, "ct");
|
|
251
|
+
if (curr_1 === null || curr_1 === void 0 ? void 0 : curr_1.fa) {
|
|
252
|
+
var allOptions = __spreadArray(__spreadArray([], CRYPTO_OPTIONS, true), locale(context).currencyDetail.map(function (c) {
|
|
253
|
+
return {
|
|
254
|
+
label: c.name,
|
|
255
|
+
value: c.value,
|
|
256
|
+
icon: undefined,
|
|
257
|
+
type: "fiat"
|
|
258
|
+
};
|
|
259
|
+
}), true);
|
|
260
|
+
var found = __spreadArray([], allOptions, true).sort(function (a, b) {
|
|
261
|
+
return b.value.length - a.value.length;
|
|
262
|
+
}).find(function (o) {
|
|
263
|
+
return curr_1.fa.includes(o.value);
|
|
264
|
+
});
|
|
265
|
+
if (found) {
|
|
266
|
+
currentFmt = found.label;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
var groupedOptions = getGroupedCurrencyOptions(locale(context).currencyDetail);
|
|
271
|
+
var filterOptions = function filterOptions(options) {
|
|
272
|
+
if (!searchTerm.trim()) return options;
|
|
273
|
+
var query = searchTerm.trim().toLowerCase();
|
|
274
|
+
return options.filter(function (opt) {
|
|
275
|
+
return query.split(/\s+/).every(function (word) {
|
|
276
|
+
return opt.label.toLowerCase().includes(word) || opt.value.toLowerCase().includes(word);
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
var dedupeByValue = function dedupeByValue(options) {
|
|
281
|
+
var seen = new Set();
|
|
282
|
+
return options.filter(function (opt) {
|
|
283
|
+
if (seen.has(opt.value)) return false;
|
|
284
|
+
seen.add(opt.value);
|
|
285
|
+
return true;
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
var handleCurrencyDecimalsChange = function handleCurrencyDecimalsChange(newDecimals) {
|
|
289
|
+
setDecimals(newDecimals);
|
|
290
|
+
var isCrypto = false;
|
|
291
|
+
if (cell && cell.ct && typeof cell.ct.fa === "string") {
|
|
292
|
+
var _a = cell.ct.fa.match(/"([A-Z]+)"/) || [],
|
|
293
|
+
matchedDenom = _a[1];
|
|
294
|
+
if (matchedDenom) isCrypto = true;
|
|
295
|
+
}
|
|
296
|
+
updateCellsDecimalFormat({
|
|
297
|
+
context: context,
|
|
298
|
+
setContext: setContext,
|
|
299
|
+
decimals: newDecimals,
|
|
300
|
+
denomination: isCrypto ? undefined : selectedFiat
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
var triggerRef = useRef(null);
|
|
304
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
305
|
+
className: "items-center fortune-toolbar-button"
|
|
306
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
307
|
+
text: toolTipText,
|
|
308
|
+
placement: "bottom"
|
|
309
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
310
|
+
className: "",
|
|
311
|
+
onClick: function onClick() {
|
|
312
|
+
var _a;
|
|
313
|
+
(_a = triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
314
|
+
},
|
|
315
|
+
tabIndex: 0,
|
|
316
|
+
role: "button"
|
|
317
|
+
}, /*#__PURE__*/React.createElement(LucideIcon, {
|
|
318
|
+
name: getLucideIcon("currency-format"),
|
|
319
|
+
width: 16,
|
|
320
|
+
height: 16
|
|
321
|
+
}))), /*#__PURE__*/React.createElement(Combo, {
|
|
322
|
+
iconId: currentIcon,
|
|
323
|
+
text: currentFmt,
|
|
324
|
+
key: "currency",
|
|
325
|
+
tooltip: "",
|
|
326
|
+
showArrow: true,
|
|
327
|
+
triggerRef: triggerRef
|
|
328
|
+
}, function (setOpen) {
|
|
329
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
330
|
+
style: {
|
|
331
|
+
minWidth: "20rem",
|
|
332
|
+
boxShadow: "2px 2px 10px rgba(0, 0, 0, 0.2)",
|
|
333
|
+
borderRadius: "8px"
|
|
334
|
+
}
|
|
335
|
+
}, /*#__PURE__*/React.createElement(Command, {
|
|
336
|
+
className: "border color-border-default rounded-lg"
|
|
337
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
338
|
+
id: "search-input-container"
|
|
339
|
+
}, /*#__PURE__*/React.createElement(CommandInput, {
|
|
340
|
+
placeholder: "Search by name or code",
|
|
341
|
+
value: searchTerm,
|
|
342
|
+
onValueChange: setSearchTerm
|
|
343
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
344
|
+
className: "px-4 py-2 border-b color-border-default flex items-center justify-between gap-2 text-body-sm color-text-default",
|
|
345
|
+
onClick: function onClick(e) {
|
|
346
|
+
return e.stopPropagation();
|
|
347
|
+
}
|
|
348
|
+
}, /*#__PURE__*/React.createElement("span", null, "Decimal places:"), /*#__PURE__*/React.createElement("span", {
|
|
349
|
+
className: "cds-row flex items-center"
|
|
350
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
351
|
+
icon: "Minus",
|
|
352
|
+
variant: "ghost",
|
|
353
|
+
size: "sm",
|
|
354
|
+
className: "",
|
|
355
|
+
disabled: decimals === 1,
|
|
356
|
+
onClick: function onClick() {
|
|
357
|
+
return handleCurrencyDecimalsChange(Math.max(1, decimals - 1));
|
|
358
|
+
}
|
|
359
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
360
|
+
type: "number",
|
|
361
|
+
min: 1,
|
|
362
|
+
max: 18,
|
|
363
|
+
value: decimals,
|
|
364
|
+
onChange: function onChange(e) {
|
|
365
|
+
return handleCurrencyDecimalsChange(Math.max(1, Math.min(18, Number(e.target.value))));
|
|
366
|
+
}
|
|
367
|
+
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
368
|
+
icon: "Plus",
|
|
369
|
+
variant: "ghost",
|
|
370
|
+
size: "sm",
|
|
371
|
+
disabled: decimals === 18,
|
|
372
|
+
onClick: function onClick() {
|
|
373
|
+
return handleCurrencyDecimalsChange(Math.min(18, decimals + 1));
|
|
374
|
+
}
|
|
375
|
+
}))), /*#__PURE__*/React.createElement(CommandList, null, /*#__PURE__*/React.createElement(CommandEmpty, {
|
|
376
|
+
className: "text-center text-body-sm color-text-secondary flex items-center justify-center",
|
|
377
|
+
style: {
|
|
378
|
+
minHeight: "5rem"
|
|
379
|
+
}
|
|
380
|
+
}, "No results found."), groupedOptions.map(function (group) {
|
|
381
|
+
var filtered = dedupeByValue(filterOptions(group.options));
|
|
382
|
+
return /*#__PURE__*/React.createElement(CommandGroup, {
|
|
383
|
+
key: group.group,
|
|
384
|
+
heading: group.group
|
|
385
|
+
}, filtered.map(function (opt) {
|
|
386
|
+
return /*#__PURE__*/React.createElement(CommandItem, {
|
|
387
|
+
key: opt.value,
|
|
388
|
+
value: "".concat(opt.label, " ").concat(opt.value),
|
|
389
|
+
onSelect: function onSelect() {
|
|
390
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
391
|
+
return __generator(this, function (_a) {
|
|
392
|
+
switch (_a.label) {
|
|
393
|
+
case 0:
|
|
394
|
+
if (!(opt.type === "crypto")) return [3, 2];
|
|
395
|
+
return [4, convertCellsToCrypto({
|
|
396
|
+
context: context,
|
|
397
|
+
setContext: setContext,
|
|
398
|
+
denomination: opt.value,
|
|
399
|
+
decimals: decimals
|
|
400
|
+
})];
|
|
401
|
+
case 1:
|
|
402
|
+
_a.sent();
|
|
403
|
+
return [3, 3];
|
|
404
|
+
case 2:
|
|
405
|
+
setSelectedFiat(opt.value);
|
|
406
|
+
setContext(function (ctx) {
|
|
407
|
+
var d = getFlowdata(ctx);
|
|
408
|
+
if (d == null) return;
|
|
409
|
+
var formatString = "".concat(getFiatSymbol(opt.value), " #,##0.").concat("0".repeat(decimals));
|
|
410
|
+
updateFormat(ctx, refs.cellInput.current, d, "ct", formatString);
|
|
411
|
+
});
|
|
412
|
+
_a.label = 3;
|
|
413
|
+
case 3:
|
|
414
|
+
setOpen(false);
|
|
415
|
+
return [2];
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
421
|
+
className: "fortune-toolbar-menu-line flex items-center justify-between w-full"
|
|
422
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
423
|
+
className: "flex items-center gap-2 w-[250px]"
|
|
424
|
+
}, currentFmt === opt.label ? (/*#__PURE__*/React.createElement(LucideIcon, {
|
|
425
|
+
name: "Check",
|
|
426
|
+
className: "w-4 h-4"
|
|
427
|
+
})) : (/*#__PURE__*/React.createElement("span", {
|
|
428
|
+
className: "w-4 h-4"
|
|
429
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
430
|
+
className: "truncate flex-1 overflow-hidden whitespace-nowrap"
|
|
431
|
+
}, opt.label)), opt.type === "crypto" ? (/*#__PURE__*/React.createElement("span", {
|
|
432
|
+
className: "color-text-secondary"
|
|
433
|
+
}, /*#__PURE__*/React.createElement(LucideIcon, {
|
|
434
|
+
name: opt.icon,
|
|
435
|
+
className: "cds-icon"
|
|
436
|
+
}), opt.value === "SOL" && (/*#__PURE__*/React.createElement(SVGIcon, {
|
|
437
|
+
name: "solana",
|
|
438
|
+
width: 16,
|
|
439
|
+
height: 16
|
|
440
|
+
})))) : (/*#__PURE__*/React.createElement("span", {
|
|
441
|
+
className: "color-text-secondary"
|
|
442
|
+
}, opt.value))));
|
|
443
|
+
}));
|
|
444
|
+
}))));
|
|
445
|
+
}));
|
|
446
|
+
};
|
|
230
447
|
var Toolbar = function Toolbar(_a) {
|
|
231
448
|
var _b, _c, _d;
|
|
232
449
|
var setMoreItems = _a.setMoreItems,
|
|
@@ -286,15 +503,6 @@ var Toolbar = function Toolbar(_a) {
|
|
|
286
503
|
var defaultFormat = defaultFmt(currency);
|
|
287
504
|
var customColor = useState("#000000")[0];
|
|
288
505
|
var customStyle = useState("1")[0];
|
|
289
|
-
var _m = useState(""),
|
|
290
|
-
searchTerm = _m[0],
|
|
291
|
-
setSearchTerm = _m[1];
|
|
292
|
-
var _o = useState(2),
|
|
293
|
-
decimals = _o[0],
|
|
294
|
-
setDecimals = _o[1];
|
|
295
|
-
var _p = useState("USD"),
|
|
296
|
-
selectedFiat = _p[0],
|
|
297
|
-
setSelectedFiat = _p[1];
|
|
298
506
|
var showSubMenu = useCallback(function (e, className) {
|
|
299
507
|
var target = e.target;
|
|
300
508
|
var menuItem = target.className === "fortune-toolbar-menu-line" ? target.parentElement : target;
|
|
@@ -429,11 +637,11 @@ var Toolbar = function Toolbar(_a) {
|
|
|
429
637
|
if (name === "format") {
|
|
430
638
|
var currentFmt = defaultFormat[0].text;
|
|
431
639
|
if (cell) {
|
|
432
|
-
var
|
|
640
|
+
var curr_2 = normalizedCellAttr(cell, "ct");
|
|
433
641
|
var format = _.find(defaultFormat, function (v) {
|
|
434
|
-
return v.value === (
|
|
642
|
+
return v.value === (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa);
|
|
435
643
|
});
|
|
436
|
-
if ((
|
|
644
|
+
if ((curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) != null) {
|
|
437
645
|
if (format != null) {
|
|
438
646
|
currentFmt = format.text;
|
|
439
647
|
} else {
|
|
@@ -1210,12 +1418,12 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1210
1418
|
iconId: "text-wrap",
|
|
1211
1419
|
value: "wrap"
|
|
1212
1420
|
}];
|
|
1213
|
-
var
|
|
1421
|
+
var curr_3 = items_7[0];
|
|
1214
1422
|
if ((cell === null || cell === void 0 ? void 0 : cell.tb) != null) {
|
|
1215
|
-
|
|
1423
|
+
curr_3 = _.get(items_7, cell.tb);
|
|
1216
1424
|
}
|
|
1217
1425
|
return /*#__PURE__*/React.createElement(Combo, {
|
|
1218
|
-
iconId:
|
|
1426
|
+
iconId: curr_3.iconId,
|
|
1219
1427
|
key: name,
|
|
1220
1428
|
tooltip: toolbar.textWrap,
|
|
1221
1429
|
showArrow: false
|
|
@@ -1234,7 +1442,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1234
1442
|
value = _a.value;
|
|
1235
1443
|
return /*#__PURE__*/React.createElement(IconButton, {
|
|
1236
1444
|
key: value,
|
|
1237
|
-
isActive:
|
|
1445
|
+
isActive: curr_3.value === value,
|
|
1238
1446
|
icon: getLucideIcon(iconId),
|
|
1239
1447
|
variant: "ghost",
|
|
1240
1448
|
onClick: function onClick() {
|
|
@@ -1388,185 +1596,10 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1388
1596
|
});
|
|
1389
1597
|
}
|
|
1390
1598
|
if (name === "currency") {
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
if (curr_3 === null || curr_3 === void 0 ? void 0 : curr_3.fa) {
|
|
1396
|
-
var allOptions = __spreadArray(__spreadArray([], CRYPTO_OPTIONS, true), locale(context).currencyDetail.map(function (c) {
|
|
1397
|
-
return {
|
|
1398
|
-
label: c.name,
|
|
1399
|
-
value: c.value,
|
|
1400
|
-
icon: undefined,
|
|
1401
|
-
type: "fiat"
|
|
1402
|
-
};
|
|
1403
|
-
}), true);
|
|
1404
|
-
var found = __spreadArray([], allOptions, true).sort(function (a, b) {
|
|
1405
|
-
return b.value.length - a.value.length;
|
|
1406
|
-
}).find(function (o) {
|
|
1407
|
-
return curr_3.fa.includes(o.value);
|
|
1408
|
-
});
|
|
1409
|
-
if (found) {
|
|
1410
|
-
currentFmt_1 = found.label;
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
var groupedOptions_1 = getGroupedCurrencyOptions(locale(context).currencyDetail);
|
|
1415
|
-
var filterOptions_1 = function filterOptions_1(options) {
|
|
1416
|
-
if (!searchTerm.trim()) return options;
|
|
1417
|
-
var query = searchTerm.trim().toLowerCase();
|
|
1418
|
-
return options.filter(function (opt) {
|
|
1419
|
-
return query.split(/\s+/).every(function (word) {
|
|
1420
|
-
return opt.label.toLowerCase().includes(word) || opt.value.toLowerCase().includes(word);
|
|
1421
|
-
});
|
|
1422
|
-
});
|
|
1423
|
-
};
|
|
1424
|
-
var dedupeByValue_1 = function dedupeByValue_1(options) {
|
|
1425
|
-
var seen = new Set();
|
|
1426
|
-
return options.filter(function (opt) {
|
|
1427
|
-
if (seen.has(opt.value)) return false;
|
|
1428
|
-
seen.add(opt.value);
|
|
1429
|
-
return true;
|
|
1430
|
-
});
|
|
1431
|
-
};
|
|
1432
|
-
var handleCurrencyDecimalsChange_1 = function handleCurrencyDecimalsChange_1(newDecimals) {
|
|
1433
|
-
setDecimals(newDecimals);
|
|
1434
|
-
var isCrypto = false;
|
|
1435
|
-
if (cell && cell.ct && typeof cell.ct.fa === "string") {
|
|
1436
|
-
var _a = cell.ct.fa.match(/"([A-Z]+)"/) || [],
|
|
1437
|
-
matchedDenom = _a[1];
|
|
1438
|
-
if (matchedDenom) isCrypto = true;
|
|
1439
|
-
}
|
|
1440
|
-
updateCellsDecimalFormat({
|
|
1441
|
-
context: context,
|
|
1442
|
-
setContext: setContext,
|
|
1443
|
-
decimals: newDecimals,
|
|
1444
|
-
denomination: isCrypto ? undefined : selectedFiat
|
|
1445
|
-
});
|
|
1446
|
-
};
|
|
1447
|
-
return /*#__PURE__*/React.createElement(Combo, {
|
|
1448
|
-
iconId: currentIcon,
|
|
1449
|
-
text: currentFmt_1,
|
|
1450
|
-
key: name,
|
|
1451
|
-
tooltip: tooltip,
|
|
1452
|
-
showArrow: true
|
|
1453
|
-
}, function (setOpen) {
|
|
1454
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1455
|
-
style: {
|
|
1456
|
-
minWidth: "20rem",
|
|
1457
|
-
boxShadow: "2px 2px 10px rgba(0, 0, 0, 0.2)",
|
|
1458
|
-
borderRadius: "8px"
|
|
1459
|
-
}
|
|
1460
|
-
}, /*#__PURE__*/React.createElement(Command, {
|
|
1461
|
-
className: "border color-border-default rounded-lg"
|
|
1462
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
1463
|
-
id: "search-input-container"
|
|
1464
|
-
}, /*#__PURE__*/React.createElement(CommandInput, {
|
|
1465
|
-
placeholder: "Search by name or code",
|
|
1466
|
-
value: searchTerm,
|
|
1467
|
-
onValueChange: setSearchTerm
|
|
1468
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
1469
|
-
className: "px-4 py-2 border-b color-border-default flex items-center justify-between gap-2 text-body-sm color-text-default",
|
|
1470
|
-
onClick: function onClick(e) {
|
|
1471
|
-
return e.stopPropagation();
|
|
1472
|
-
}
|
|
1473
|
-
}, /*#__PURE__*/React.createElement("span", null, "Decimal places:"), /*#__PURE__*/React.createElement("span", {
|
|
1474
|
-
className: "cds-row flex items-center"
|
|
1475
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
1476
|
-
icon: "Minus",
|
|
1477
|
-
variant: "ghost",
|
|
1478
|
-
size: "sm",
|
|
1479
|
-
className: "",
|
|
1480
|
-
disabled: decimals === 1,
|
|
1481
|
-
onClick: function onClick() {
|
|
1482
|
-
return handleCurrencyDecimalsChange_1(Math.max(1, decimals - 1));
|
|
1483
|
-
}
|
|
1484
|
-
}), /*#__PURE__*/React.createElement("input", {
|
|
1485
|
-
type: "number",
|
|
1486
|
-
min: 1,
|
|
1487
|
-
max: 18,
|
|
1488
|
-
value: decimals,
|
|
1489
|
-
onChange: function onChange(e) {
|
|
1490
|
-
return handleCurrencyDecimalsChange_1(Math.max(1, Math.min(18, Number(e.target.value))));
|
|
1491
|
-
}
|
|
1492
|
-
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
1493
|
-
icon: "Plus",
|
|
1494
|
-
variant: "ghost",
|
|
1495
|
-
size: "sm",
|
|
1496
|
-
disabled: decimals === 18,
|
|
1497
|
-
onClick: function onClick() {
|
|
1498
|
-
return handleCurrencyDecimalsChange_1(Math.min(18, decimals + 1));
|
|
1499
|
-
}
|
|
1500
|
-
}))), /*#__PURE__*/React.createElement(CommandList, null, /*#__PURE__*/React.createElement(CommandEmpty, {
|
|
1501
|
-
className: "text-center text-body-sm color-text-secondary flex items-center justify-center",
|
|
1502
|
-
style: {
|
|
1503
|
-
minHeight: "5rem"
|
|
1504
|
-
}
|
|
1505
|
-
}, "No results found."), groupedOptions_1.map(function (group) {
|
|
1506
|
-
var filtered = dedupeByValue_1(filterOptions_1(group.options));
|
|
1507
|
-
return /*#__PURE__*/React.createElement(CommandGroup, {
|
|
1508
|
-
key: group.group,
|
|
1509
|
-
heading: group.group
|
|
1510
|
-
}, filtered.map(function (opt) {
|
|
1511
|
-
return /*#__PURE__*/React.createElement(CommandItem, {
|
|
1512
|
-
key: opt.value,
|
|
1513
|
-
value: "".concat(opt.label, " ").concat(opt.value),
|
|
1514
|
-
onSelect: function onSelect() {
|
|
1515
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
1516
|
-
return __generator(this, function (_a) {
|
|
1517
|
-
switch (_a.label) {
|
|
1518
|
-
case 0:
|
|
1519
|
-
if (!(opt.type === "crypto")) return [3, 2];
|
|
1520
|
-
return [4, convertCellsToCrypto({
|
|
1521
|
-
context: context,
|
|
1522
|
-
setContext: setContext,
|
|
1523
|
-
denomination: opt.value,
|
|
1524
|
-
decimals: decimals
|
|
1525
|
-
})];
|
|
1526
|
-
case 1:
|
|
1527
|
-
_a.sent();
|
|
1528
|
-
return [3, 3];
|
|
1529
|
-
case 2:
|
|
1530
|
-
setSelectedFiat(opt.value);
|
|
1531
|
-
setContext(function (ctx) {
|
|
1532
|
-
var d = getFlowdata(ctx);
|
|
1533
|
-
if (d == null) return;
|
|
1534
|
-
var formatString = "".concat(getFiatSymbol(opt.value), " #,##0.").concat("0".repeat(decimals));
|
|
1535
|
-
updateFormat(ctx, refs.cellInput.current, d, "ct", formatString);
|
|
1536
|
-
});
|
|
1537
|
-
_a.label = 3;
|
|
1538
|
-
case 3:
|
|
1539
|
-
setOpen(false);
|
|
1540
|
-
return [2];
|
|
1541
|
-
}
|
|
1542
|
-
});
|
|
1543
|
-
});
|
|
1544
|
-
}
|
|
1545
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
1546
|
-
className: "fortune-toolbar-menu-line flex items-center justify-between w-full"
|
|
1547
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
1548
|
-
className: "flex items-center gap-2 w-[250px]"
|
|
1549
|
-
}, currentFmt_1 === opt.label ? (/*#__PURE__*/React.createElement(LucideIcon, {
|
|
1550
|
-
name: "Check",
|
|
1551
|
-
className: "w-4 h-4"
|
|
1552
|
-
})) : (/*#__PURE__*/React.createElement("span", {
|
|
1553
|
-
className: "w-4 h-4"
|
|
1554
|
-
})), /*#__PURE__*/React.createElement("span", {
|
|
1555
|
-
className: "truncate flex-1 overflow-hidden whitespace-nowrap"
|
|
1556
|
-
}, opt.label)), opt.type === "crypto" ? (/*#__PURE__*/React.createElement("span", {
|
|
1557
|
-
className: "color-text-secondary"
|
|
1558
|
-
}, /*#__PURE__*/React.createElement(LucideIcon, {
|
|
1559
|
-
name: opt.icon,
|
|
1560
|
-
className: "cds-icon"
|
|
1561
|
-
}), opt.value === "SOL" && (/*#__PURE__*/React.createElement(SVGIcon, {
|
|
1562
|
-
name: "solana",
|
|
1563
|
-
width: 16,
|
|
1564
|
-
height: 16
|
|
1565
|
-
})))) : (/*#__PURE__*/React.createElement("span", {
|
|
1566
|
-
className: "color-text-secondary"
|
|
1567
|
-
}, opt.value))));
|
|
1568
|
-
}));
|
|
1569
|
-
}))));
|
|
1599
|
+
return /*#__PURE__*/React.createElement(CurrencySelector, {
|
|
1600
|
+
cell: cell,
|
|
1601
|
+
defaultTextFormat: defaultFormat[0].text,
|
|
1602
|
+
toolTipText: toolbar["currency-format"]
|
|
1570
1603
|
});
|
|
1571
1604
|
}
|
|
1572
1605
|
return /*#__PURE__*/React.createElement(Tooltip, {
|