@fileverse-dev/fortune-react 1.0.98 → 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/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/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
|
});
|
|
@@ -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, {
|
|
@@ -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
|
});
|
|
@@ -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, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fileverse-dev/fortune-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.99",
|
|
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.
|
|
19
|
+
"@fileverse-dev/fortune-core": "1.0.99",
|
|
20
20
|
"@fileverse/ui": "^4.1.7-patch-21",
|
|
21
21
|
"@tippyjs/react": "^4.2.6",
|
|
22
22
|
"@types/regenerator-runtime": "^0.13.6",
|