@fileverse-dev/fortune-react 1.0.35 → 1.0.36
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/CryptoDenominationSelector/index.css +67 -0
- package/es/components/CryptoDenominationSelector/index.d.ts +8 -0
- package/es/components/CryptoDenominationSelector/index.js +272 -0
- package/es/components/FormatSearch/index.js +9 -5
- package/es/components/SVGDefines.js +60 -1
- package/es/components/SheetTab/index.js +22 -2
- package/es/components/Toolbar/Combo.js +18 -4
- package/es/components/Toolbar/index.css +6 -0
- package/es/components/Toolbar/index.d.ts +1 -1
- package/es/components/Toolbar/index.js +334 -3
- package/es/components/Workbook/index.d.ts +23 -23
- package/es/components/Workbook/index.js +25 -1
- package/es/constants.d.ts +26 -0
- package/es/constants.js +42 -1
- package/es/hooks/useCryptoCells.d.ts +11 -0
- package/es/hooks/useCryptoCells.js +210 -0
- package/es/utils/convertCellsToCrypto.d.ts +8 -0
- package/es/utils/convertCellsToCrypto.js +215 -0
- package/es/utils/cryptoApi.d.ts +2 -0
- package/es/utils/cryptoApi.js +154 -0
- package/es/utils/updateCellsDecimalFormat.d.ts +6 -0
- package/es/utils/updateCellsDecimalFormat.js +80 -0
- package/lib/components/CryptoDenominationSelector/index.css +67 -0
- package/lib/components/CryptoDenominationSelector/index.d.ts +8 -0
- package/lib/components/CryptoDenominationSelector/index.js +281 -0
- package/lib/components/FormatSearch/index.js +9 -5
- package/lib/components/SVGDefines.js +60 -1
- package/lib/components/SheetTab/index.js +22 -2
- package/lib/components/Toolbar/Combo.js +18 -4
- package/lib/components/Toolbar/index.css +6 -0
- package/lib/components/Toolbar/index.d.ts +1 -1
- package/lib/components/Toolbar/index.js +333 -2
- package/lib/components/Workbook/index.d.ts +23 -23
- package/lib/components/Workbook/index.js +24 -0
- package/lib/constants.d.ts +26 -0
- package/lib/constants.js +44 -2
- package/lib/hooks/useCryptoCells.d.ts +11 -0
- package/lib/hooks/useCryptoCells.js +216 -0
- package/lib/utils/convertCellsToCrypto.d.ts +8 -0
- package/lib/utils/convertCellsToCrypto.js +222 -0
- package/lib/utils/cryptoApi.d.ts +2 -0
- package/lib/utils/cryptoApi.js +161 -0
- package/lib/utils/updateCellsDecimalFormat.d.ts +6 -0
- package/lib/utils/updateCellsDecimalFormat.js +86 -0
- package/package.json +2 -2
|
@@ -1,7 +1,131 @@
|
|
|
1
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) {
|
|
3
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
+
resolve(value);
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) {
|
|
9
|
+
try {
|
|
10
|
+
step(generator.next(value));
|
|
11
|
+
} catch (e) {
|
|
12
|
+
reject(e);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function rejected(value) {
|
|
16
|
+
try {
|
|
17
|
+
step(generator["throw"](value));
|
|
18
|
+
} catch (e) {
|
|
19
|
+
reject(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function step(result) {
|
|
23
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
24
|
+
}
|
|
25
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
29
|
+
var _ = {
|
|
30
|
+
label: 0,
|
|
31
|
+
sent: function sent() {
|
|
32
|
+
if (t[0] & 1) throw t[1];
|
|
33
|
+
return t[1];
|
|
34
|
+
},
|
|
35
|
+
trys: [],
|
|
36
|
+
ops: []
|
|
37
|
+
},
|
|
38
|
+
f,
|
|
39
|
+
y,
|
|
40
|
+
t,
|
|
41
|
+
g;
|
|
42
|
+
return g = {
|
|
43
|
+
next: verb(0),
|
|
44
|
+
"throw": verb(1),
|
|
45
|
+
"return": verb(2)
|
|
46
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
47
|
+
return this;
|
|
48
|
+
}), g;
|
|
49
|
+
function verb(n) {
|
|
50
|
+
return function (v) {
|
|
51
|
+
return step([n, v]);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function step(op) {
|
|
55
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
56
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
57
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
58
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
59
|
+
switch (op[0]) {
|
|
60
|
+
case 0:
|
|
61
|
+
case 1:
|
|
62
|
+
t = op;
|
|
63
|
+
break;
|
|
64
|
+
case 4:
|
|
65
|
+
_.label++;
|
|
66
|
+
return {
|
|
67
|
+
value: op[1],
|
|
68
|
+
done: false
|
|
69
|
+
};
|
|
70
|
+
case 5:
|
|
71
|
+
_.label++;
|
|
72
|
+
y = op[1];
|
|
73
|
+
op = [0];
|
|
74
|
+
continue;
|
|
75
|
+
case 7:
|
|
76
|
+
op = _.ops.pop();
|
|
77
|
+
_.trys.pop();
|
|
78
|
+
continue;
|
|
79
|
+
default:
|
|
80
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
81
|
+
_ = 0;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
85
|
+
_.label = op[1];
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
89
|
+
_.label = t[1];
|
|
90
|
+
t = op;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
if (t && _.label < t[2]) {
|
|
94
|
+
_.label = t[2];
|
|
95
|
+
_.ops.push(op);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
if (t[2]) _.ops.pop();
|
|
99
|
+
_.trys.pop();
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
op = body.call(thisArg, _);
|
|
103
|
+
} catch (e) {
|
|
104
|
+
op = [6, e];
|
|
105
|
+
y = 0;
|
|
106
|
+
} finally {
|
|
107
|
+
f = t = 0;
|
|
108
|
+
}
|
|
109
|
+
if (op[0] & 5) throw op[1];
|
|
110
|
+
return {
|
|
111
|
+
value: op[0] ? op[1] : void 0,
|
|
112
|
+
done: true
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
117
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
118
|
+
if (ar || !(i in from)) {
|
|
119
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
120
|
+
ar[i] = from[i];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
124
|
+
};
|
|
1
125
|
import React, { useContext, useCallback, useRef, useEffect, useState } from "react";
|
|
2
126
|
import { toolbarItemClickHandler, handleTextBackground, handleTextColor, handleTextSize, normalizedCellAttr, getFlowdata, newComment, editComment, deleteComment, showHideComment, showHideAllComments, autoSelectionFormula, handleSum, locale, handleMerge, handleBorder, toolbarItemSelectedFunc, handleFreeze, insertImage, showImgChooser, updateFormat, handleSort, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, createFilter, clearFilter, applyLocation, insertDuneChart } from "@fileverse-dev/fortune-core";
|
|
3
127
|
import _ from "lodash";
|
|
4
|
-
import { IconButton, LucideIcon, Tooltip } from "@fileverse/ui";
|
|
128
|
+
import { IconButton, LucideIcon, Tooltip, Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from "@fileverse/ui";
|
|
5
129
|
import WorkbookContext from "../../context";
|
|
6
130
|
import "./index.css";
|
|
7
131
|
import Button from "./Button";
|
|
@@ -19,6 +143,10 @@ import { CustomColor } from "./CustomColor";
|
|
|
19
143
|
import { FormatSearch } from "../FormatSearch";
|
|
20
144
|
import DuneChartsInputModal from "../DuneChartsInputModal/DuneChartsInputModal";
|
|
21
145
|
import MoreItemsContaier from "./MoreItemsContainer";
|
|
146
|
+
import CryptoDenominationSelector from "../CryptoDenominationSelector";
|
|
147
|
+
import { getGroupedCurrencyOptions, CRYPTO_OPTIONS } from "../../constants";
|
|
148
|
+
import { convertCellsToCrypto, getFiatSymbol } from "../../utils/convertCellsToCrypto";
|
|
149
|
+
import { updateCellsDecimalFormat } from "../../utils/updateCellsDecimalFormat";
|
|
22
150
|
export var getLucideIcon = function getLucideIcon(title) {
|
|
23
151
|
switch (title) {
|
|
24
152
|
case "undo":
|
|
@@ -63,6 +191,8 @@ export var getLucideIcon = function getLucideIcon(title) {
|
|
|
63
191
|
return "DollarSign";
|
|
64
192
|
case "currency-format":
|
|
65
193
|
return "DollarSign";
|
|
194
|
+
case "currency":
|
|
195
|
+
return "ChevronDown";
|
|
66
196
|
case "percentage-format":
|
|
67
197
|
return "Percent";
|
|
68
198
|
case "number-decrease":
|
|
@@ -87,6 +217,8 @@ export var getLucideIcon = function getLucideIcon(title) {
|
|
|
87
217
|
return "Search";
|
|
88
218
|
case "dune":
|
|
89
219
|
return "DuneChart";
|
|
220
|
+
case "crypto":
|
|
221
|
+
return "Ethereum";
|
|
90
222
|
case "Ellipsis":
|
|
91
223
|
return "Ellipsis";
|
|
92
224
|
default:
|
|
@@ -152,6 +284,15 @@ var Toolbar = function Toolbar(_a) {
|
|
|
152
284
|
var defaultFormat = defaultFmt(currency);
|
|
153
285
|
var customColor = useState("#000000")[0];
|
|
154
286
|
var customStyle = useState("1")[0];
|
|
287
|
+
var _m = useState(""),
|
|
288
|
+
searchTerm = _m[0],
|
|
289
|
+
setSearchTerm = _m[1];
|
|
290
|
+
var _o = useState(2),
|
|
291
|
+
decimals = _o[0],
|
|
292
|
+
setDecimals = _o[1];
|
|
293
|
+
var _p = useState("USD"),
|
|
294
|
+
selectedFiat = _p[0],
|
|
295
|
+
setSelectedFiat = _p[1];
|
|
155
296
|
var showSubMenu = useCallback(function (e, className) {
|
|
156
297
|
var target = e.target;
|
|
157
298
|
var menuItem = target.className === "fortune-toolbar-menu-line" ? target.parentElement : target;
|
|
@@ -1244,6 +1385,183 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1244
1385
|
}));
|
|
1245
1386
|
});
|
|
1246
1387
|
}
|
|
1388
|
+
if (name === "currency") {
|
|
1389
|
+
var currentFmt_1 = defaultFormat[0].text;
|
|
1390
|
+
var currentIcon = "currency";
|
|
1391
|
+
if (cell) {
|
|
1392
|
+
var curr_3 = normalizedCellAttr(cell, "ct");
|
|
1393
|
+
if (curr_3 === null || curr_3 === void 0 ? void 0 : curr_3.fa) {
|
|
1394
|
+
var allOptions = __spreadArray(__spreadArray([], CRYPTO_OPTIONS, true), locale(context).currencyDetail.map(function (c) {
|
|
1395
|
+
return {
|
|
1396
|
+
label: c.name,
|
|
1397
|
+
value: c.value,
|
|
1398
|
+
icon: undefined,
|
|
1399
|
+
type: "fiat"
|
|
1400
|
+
};
|
|
1401
|
+
}), true);
|
|
1402
|
+
var found = allOptions.find(function (o) {
|
|
1403
|
+
return curr_3.fa.includes(o.value);
|
|
1404
|
+
});
|
|
1405
|
+
if (found) {
|
|
1406
|
+
currentFmt_1 = found.label;
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
var groupedOptions_1 = getGroupedCurrencyOptions(locale(context).currencyDetail);
|
|
1411
|
+
var filterOptions_1 = function filterOptions_1(options) {
|
|
1412
|
+
if (!searchTerm.trim()) return options;
|
|
1413
|
+
var query = searchTerm.trim().toLowerCase();
|
|
1414
|
+
return options.filter(function (opt) {
|
|
1415
|
+
return query.split(/\s+/).every(function (word) {
|
|
1416
|
+
return opt.label.toLowerCase().includes(word) || opt.value.toLowerCase().includes(word);
|
|
1417
|
+
});
|
|
1418
|
+
});
|
|
1419
|
+
};
|
|
1420
|
+
var dedupeByValue_1 = function dedupeByValue_1(options) {
|
|
1421
|
+
var seen = new Set();
|
|
1422
|
+
return options.filter(function (opt) {
|
|
1423
|
+
if (seen.has(opt.value)) return false;
|
|
1424
|
+
seen.add(opt.value);
|
|
1425
|
+
return true;
|
|
1426
|
+
});
|
|
1427
|
+
};
|
|
1428
|
+
var handleCurrencyDecimalsChange_1 = function handleCurrencyDecimalsChange_1(newDecimals) {
|
|
1429
|
+
setDecimals(newDecimals);
|
|
1430
|
+
var isCrypto = false;
|
|
1431
|
+
if (cell && cell.ct && typeof cell.ct.fa === "string") {
|
|
1432
|
+
var _a = cell.ct.fa.match(/"([A-Z]+)"/) || [],
|
|
1433
|
+
matchedDenom = _a[1];
|
|
1434
|
+
if (matchedDenom) isCrypto = true;
|
|
1435
|
+
}
|
|
1436
|
+
updateCellsDecimalFormat({
|
|
1437
|
+
context: context,
|
|
1438
|
+
setContext: setContext,
|
|
1439
|
+
decimals: newDecimals,
|
|
1440
|
+
denomination: isCrypto ? undefined : selectedFiat
|
|
1441
|
+
});
|
|
1442
|
+
};
|
|
1443
|
+
return /*#__PURE__*/React.createElement(Combo, {
|
|
1444
|
+
iconId: currentIcon,
|
|
1445
|
+
text: currentFmt_1,
|
|
1446
|
+
key: name,
|
|
1447
|
+
tooltip: tooltip,
|
|
1448
|
+
showArrow: true
|
|
1449
|
+
}, function () {
|
|
1450
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1451
|
+
style: {
|
|
1452
|
+
minWidth: "20rem"
|
|
1453
|
+
}
|
|
1454
|
+
}, /*#__PURE__*/React.createElement(Command, {
|
|
1455
|
+
className: "border color-border-default rounded-lg"
|
|
1456
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1457
|
+
id: "search-input-container"
|
|
1458
|
+
}, /*#__PURE__*/React.createElement(CommandInput, {
|
|
1459
|
+
placeholder: "Search by name or code",
|
|
1460
|
+
value: searchTerm,
|
|
1461
|
+
onValueChange: setSearchTerm
|
|
1462
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
1463
|
+
className: "px-4 py-2 border-b color-border-default flex items-center justify-between gap-2 text-body-sm color-text-default",
|
|
1464
|
+
onClick: function onClick(e) {
|
|
1465
|
+
return e.stopPropagation();
|
|
1466
|
+
}
|
|
1467
|
+
}, /*#__PURE__*/React.createElement("span", null, "Decimal places:"), /*#__PURE__*/React.createElement("span", {
|
|
1468
|
+
className: "cds-row flex items-center"
|
|
1469
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
1470
|
+
icon: "Minus",
|
|
1471
|
+
variant: "ghost",
|
|
1472
|
+
size: "sm",
|
|
1473
|
+
className: "!bg-transparent",
|
|
1474
|
+
disabled: decimals === 1,
|
|
1475
|
+
onClick: function onClick() {
|
|
1476
|
+
return handleCurrencyDecimalsChange_1(Math.max(1, decimals - 1));
|
|
1477
|
+
}
|
|
1478
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
1479
|
+
type: "number",
|
|
1480
|
+
min: 1,
|
|
1481
|
+
max: 18,
|
|
1482
|
+
value: decimals,
|
|
1483
|
+
onChange: function onChange(e) {
|
|
1484
|
+
return handleCurrencyDecimalsChange_1(Math.max(1, Math.min(18, Number(e.target.value))));
|
|
1485
|
+
}
|
|
1486
|
+
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
1487
|
+
icon: "Plus",
|
|
1488
|
+
variant: "ghost",
|
|
1489
|
+
size: "sm",
|
|
1490
|
+
className: "!bg-transparent",
|
|
1491
|
+
disabled: decimals === 18,
|
|
1492
|
+
onClick: function onClick() {
|
|
1493
|
+
return handleCurrencyDecimalsChange_1(Math.min(18, decimals + 1));
|
|
1494
|
+
}
|
|
1495
|
+
}))), /*#__PURE__*/React.createElement(CommandList, null, /*#__PURE__*/React.createElement(CommandEmpty, {
|
|
1496
|
+
className: "text-center text-body-sm color-text-secondary flex items-center justify-center",
|
|
1497
|
+
style: {
|
|
1498
|
+
minHeight: "5rem"
|
|
1499
|
+
}
|
|
1500
|
+
}, "No results found."), groupedOptions_1.map(function (group) {
|
|
1501
|
+
var filtered = dedupeByValue_1(filterOptions_1(group.options));
|
|
1502
|
+
return /*#__PURE__*/React.createElement(CommandGroup, {
|
|
1503
|
+
key: group.group,
|
|
1504
|
+
heading: group.group
|
|
1505
|
+
}, filtered.map(function (opt) {
|
|
1506
|
+
return /*#__PURE__*/React.createElement(CommandItem, {
|
|
1507
|
+
key: opt.value,
|
|
1508
|
+
value: "".concat(opt.label, " ").concat(opt.value),
|
|
1509
|
+
onSelect: function onSelect() {
|
|
1510
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
1511
|
+
return __generator(this, function (_a) {
|
|
1512
|
+
switch (_a.label) {
|
|
1513
|
+
case 0:
|
|
1514
|
+
if (!(opt.type === "crypto")) return [3, 2];
|
|
1515
|
+
return [4, convertCellsToCrypto({
|
|
1516
|
+
context: context,
|
|
1517
|
+
setContext: setContext,
|
|
1518
|
+
denomination: opt.value,
|
|
1519
|
+
decimals: decimals,
|
|
1520
|
+
baseCurrency: "USD"
|
|
1521
|
+
})];
|
|
1522
|
+
case 1:
|
|
1523
|
+
_a.sent();
|
|
1524
|
+
return [3, 3];
|
|
1525
|
+
case 2:
|
|
1526
|
+
setSelectedFiat(opt.value);
|
|
1527
|
+
setContext(function (ctx) {
|
|
1528
|
+
var d = getFlowdata(ctx);
|
|
1529
|
+
if (d == null) return;
|
|
1530
|
+
var formatString = "".concat(getFiatSymbol(opt.value), " #,##0.").concat("0".repeat(decimals));
|
|
1531
|
+
updateFormat(ctx, refs.cellInput.current, d, "ct", formatString);
|
|
1532
|
+
});
|
|
1533
|
+
_a.label = 3;
|
|
1534
|
+
case 3:
|
|
1535
|
+
return [2];
|
|
1536
|
+
}
|
|
1537
|
+
});
|
|
1538
|
+
});
|
|
1539
|
+
}
|
|
1540
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1541
|
+
className: "fortune-toolbar-menu-line flex items-center justify-between w-full"
|
|
1542
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1543
|
+
className: "flex items-center gap-2"
|
|
1544
|
+
}, currentFmt_1 === opt.label ? (/*#__PURE__*/React.createElement(LucideIcon, {
|
|
1545
|
+
name: "Check",
|
|
1546
|
+
className: "w-4 h-4"
|
|
1547
|
+
})) : (/*#__PURE__*/React.createElement("span", {
|
|
1548
|
+
className: "w-4 h-4"
|
|
1549
|
+
})), /*#__PURE__*/React.createElement("span", null, opt.label)), opt.type === "crypto" ? (/*#__PURE__*/React.createElement("span", {
|
|
1550
|
+
className: "color-text-secondary"
|
|
1551
|
+
}, /*#__PURE__*/React.createElement(LucideIcon, {
|
|
1552
|
+
name: opt.icon,
|
|
1553
|
+
className: "cds-icon"
|
|
1554
|
+
}), opt.value === "SOL" && (/*#__PURE__*/React.createElement(SVGIcon, {
|
|
1555
|
+
name: "solana",
|
|
1556
|
+
width: 16,
|
|
1557
|
+
height: 16
|
|
1558
|
+
})))) : (/*#__PURE__*/React.createElement("span", {
|
|
1559
|
+
className: "color-text-secondary"
|
|
1560
|
+
}, opt.value))));
|
|
1561
|
+
}));
|
|
1562
|
+
}))));
|
|
1563
|
+
});
|
|
1564
|
+
}
|
|
1247
1565
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
1248
1566
|
text: tooltip,
|
|
1249
1567
|
placement: "bottom"
|
|
@@ -1296,7 +1614,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1296
1614
|
onClose: onMoreToolbarItemsClose
|
|
1297
1615
|
}, moreToolbarItems))), /*#__PURE__*/React.createElement("div", {
|
|
1298
1616
|
className: "fortune-toolbar-right"
|
|
1299
|
-
}, settings.customToolbarItems.length > 0 && (/*#__PURE__*/React.createElement(Button, {
|
|
1617
|
+
}, settings.customToolbarItems.length > 0 && (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
1300
1618
|
iconId: "dune",
|
|
1301
1619
|
tooltip: "Insert Dune Chart",
|
|
1302
1620
|
key: "dune-charts",
|
|
@@ -1308,7 +1626,20 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1308
1626
|
backgroundColor: "#F4603E2E",
|
|
1309
1627
|
borderRadius: "8px"
|
|
1310
1628
|
}
|
|
1311
|
-
})
|
|
1629
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
1630
|
+
style: {
|
|
1631
|
+
display: "inline-block",
|
|
1632
|
+
position: "relative"
|
|
1633
|
+
}
|
|
1634
|
+
}, /*#__PURE__*/React.createElement(CryptoDenominationSelector, null, /*#__PURE__*/React.createElement(Button, {
|
|
1635
|
+
iconId: "crypto",
|
|
1636
|
+
tooltip: "Crypto denominations",
|
|
1637
|
+
key: "crypto-denominations",
|
|
1638
|
+
style: {
|
|
1639
|
+
backgroundColor: "#e8ebec",
|
|
1640
|
+
borderRadius: "8px"
|
|
1641
|
+
}
|
|
1642
|
+
}))))), settings.customToolbarItems.filter(function (n) {
|
|
1312
1643
|
return n.key !== "import-export";
|
|
1313
1644
|
}).map(function (n) {
|
|
1314
1645
|
return /*#__PURE__*/React.createElement(CustomButton, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Settings, Context, CellWithRowAndCol, Sheet as SheetType, Op, CellMatrix } from "@fileverse-dev/fortune-core";
|
|
1
|
+
import { Settings, Context, CellWithRowAndCol, Sheet as SheetType, Op, CellMatrix, api } from "@fileverse-dev/fortune-core";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import "./index.css";
|
|
4
4
|
import { generateAPIs } from "./api";
|
|
@@ -9,29 +9,29 @@ type AdditionalProps = {
|
|
|
9
9
|
};
|
|
10
10
|
declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalProps & React.RefAttributes<{
|
|
11
11
|
applyOp: (ops: Op[]) => void;
|
|
12
|
-
getCellValue: (row: number, column: number, options?:
|
|
12
|
+
getCellValue: (row: number, column: number, options?: api.CommonOptions & {
|
|
13
13
|
type?: "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
|
|
14
14
|
}) => any;
|
|
15
15
|
onboardingActiveCell: (functionName: string) => void;
|
|
16
16
|
initializeComment: (row: number, column: number) => void;
|
|
17
|
-
setCellValue: (row: number, column: number, value: any, options?:
|
|
17
|
+
setCellValue: (row: number, column: number, value: any, options?: api.CommonOptions & {
|
|
18
18
|
type?: "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
|
|
19
19
|
}) => void;
|
|
20
|
-
clearCell: (row: number, column: number, options?:
|
|
21
|
-
setCellFormat: (row: number, column: number, attr: "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, options?:
|
|
20
|
+
clearCell: (row: number, column: number, options?: api.CommonOptions) => void;
|
|
21
|
+
setCellFormat: (row: number, column: number, attr: "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, options?: api.CommonOptions) => void;
|
|
22
22
|
autoFillCell: (copyRange: import("@fileverse-dev/fortune-core").SingleRange, applyRange: import("@fileverse-dev/fortune-core").SingleRange, direction: "left" | "right" | "down" | "up") => void;
|
|
23
23
|
freeze: (type: "column" | "both" | "row", range: {
|
|
24
24
|
row: number;
|
|
25
25
|
column: number;
|
|
26
|
-
}, options?:
|
|
27
|
-
insertRowOrColumn: (type: "column" | "row", index: number, count: number, direction?: "lefttop" | "rightbottom", options?:
|
|
28
|
-
deleteRowOrColumn: (type: "column" | "row", start: number, end: number, options?:
|
|
26
|
+
}, options?: api.CommonOptions) => void;
|
|
27
|
+
insertRowOrColumn: (type: "column" | "row", index: number, count: number, direction?: "lefttop" | "rightbottom", options?: api.CommonOptions) => void;
|
|
28
|
+
deleteRowOrColumn: (type: "column" | "row", start: number, end: number, options?: api.CommonOptions) => void;
|
|
29
29
|
hideRowOrColumn: (rowOrColInfo: string[], type: "column" | "row") => void;
|
|
30
30
|
showRowOrColumn: (rowOrColInfo: string[], type: "column" | "row") => void;
|
|
31
|
-
setRowHeight: (rowInfo: Record<string, number>, options?:
|
|
32
|
-
setColumnWidth: (columnInfo: Record<string, number>, options?:
|
|
33
|
-
getRowHeight: (rows: number[], options?:
|
|
34
|
-
getColumnWidth: (columns: number[], options?:
|
|
31
|
+
setRowHeight: (rowInfo: Record<string, number>, options?: api.CommonOptions, custom?: boolean) => void;
|
|
32
|
+
setColumnWidth: (columnInfo: Record<string, number>, options?: api.CommonOptions, custom?: boolean) => void;
|
|
33
|
+
getRowHeight: (rows: number[], options?: api.CommonOptions) => Record<number, number>;
|
|
34
|
+
getColumnWidth: (columns: number[], options?: api.CommonOptions) => Record<number, number>;
|
|
35
35
|
getSelection: () => {
|
|
36
36
|
row: number[];
|
|
37
37
|
column: number[];
|
|
@@ -45,15 +45,15 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
45
45
|
c: number;
|
|
46
46
|
}[] | undefined) => (import("@fileverse-dev/fortune-core").Cell | null)[];
|
|
47
47
|
getSelectionCoordinates: () => string[];
|
|
48
|
-
getCellsByRange: (range: import("@fileverse-dev/fortune-core").Selection, options?:
|
|
49
|
-
getHtmlByRange: (range: import("@fileverse-dev/fortune-core").Range, options?:
|
|
50
|
-
setSelection: (range: import("@fileverse-dev/fortune-core").Range, options?:
|
|
51
|
-
setCellValuesByRange: (data: any[][], range: import("@fileverse-dev/fortune-core").SingleRange, options?:
|
|
52
|
-
setCellFormatByRange: (attr: "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, range: import("@fileverse-dev/fortune-core").SingleRange | import("@fileverse-dev/fortune-core").Range, options?:
|
|
53
|
-
mergeCells: (ranges: import("@fileverse-dev/fortune-core").Range, type: string, options?:
|
|
54
|
-
cancelMerge: (ranges: import("@fileverse-dev/fortune-core").Range, options?:
|
|
48
|
+
getCellsByRange: (range: import("@fileverse-dev/fortune-core").Selection, options?: api.CommonOptions) => (import("@fileverse-dev/fortune-core").Cell | null)[][];
|
|
49
|
+
getHtmlByRange: (range: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => string | null;
|
|
50
|
+
setSelection: (range: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
|
|
51
|
+
setCellValuesByRange: (data: any[][], range: import("@fileverse-dev/fortune-core").SingleRange, options?: api.CommonOptions) => void;
|
|
52
|
+
setCellFormatByRange: (attr: "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, range: import("@fileverse-dev/fortune-core").SingleRange | import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
|
|
53
|
+
mergeCells: (ranges: import("@fileverse-dev/fortune-core").Range, type: string, options?: api.CommonOptions) => void;
|
|
54
|
+
cancelMerge: (ranges: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
|
|
55
55
|
getAllSheets: () => SheetType[];
|
|
56
|
-
getSheet: (options?:
|
|
56
|
+
getSheet: (options?: api.CommonOptions) => {
|
|
57
57
|
celldata: CellWithRowAndCol[];
|
|
58
58
|
name: string;
|
|
59
59
|
config?: import("@fileverse-dev/fortune-core").SheetConfig | undefined;
|
|
@@ -116,10 +116,10 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
116
116
|
} | undefined;
|
|
117
117
|
};
|
|
118
118
|
addSheet: () => void;
|
|
119
|
-
deleteSheet: (options?:
|
|
119
|
+
deleteSheet: (options?: api.CommonOptions) => void;
|
|
120
120
|
updateSheet: (data: SheetType[]) => void;
|
|
121
|
-
activateSheet: (options?:
|
|
122
|
-
setSheetName: (name: string, options?:
|
|
121
|
+
activateSheet: (options?: api.CommonOptions) => void;
|
|
122
|
+
setSheetName: (name: string, options?: api.CommonOptions) => void;
|
|
123
123
|
setSheetOrder: (orderList: Record<string, number>) => void;
|
|
124
124
|
scroll: (options: {
|
|
125
125
|
scrollLeft?: number | undefined;
|
|
@@ -15,7 +15,7 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
15
15
|
}
|
|
16
16
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
17
17
|
};
|
|
18
|
-
import { defaultContext, defaultSettings, initSheetIndex, handleGlobalKeyDown, getSheetIndex, handlePaste, filterPatch, patchToOp, inverseRowColOptions, ensureSheetIndex, insertRowCol, locale, calcSelectionInfo, groupValuesRefresh, insertDuneChart } from "@fileverse-dev/fortune-core";
|
|
18
|
+
import { defaultContext, defaultSettings, initSheetIndex, handleGlobalKeyDown, getSheetIndex, handlePaste, filterPatch, patchToOp, inverseRowColOptions, ensureSheetIndex, insertRowCol, locale, calcSelectionInfo, groupValuesRefresh, insertDuneChart, getFlowdata, api } from "@fileverse-dev/fortune-core";
|
|
19
19
|
import React, { useMemo, useState, useCallback, useEffect, useRef, useImperativeHandle } from "react";
|
|
20
20
|
import "./index.css";
|
|
21
21
|
import produce, { applyPatches, enablePatches, produceWithPatches } from "immer";
|
|
@@ -320,6 +320,30 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
320
320
|
}, [emitOp]);
|
|
321
321
|
useEffect(function () {
|
|
322
322
|
var _a, _b;
|
|
323
|
+
setContext(function (ctx) {
|
|
324
|
+
var _a, _b;
|
|
325
|
+
var gridData = getFlowdata(ctx);
|
|
326
|
+
var cellData = api.dataToCelldata(gridData);
|
|
327
|
+
var denominatedUsed = false;
|
|
328
|
+
for (var _i = 0, cellData_1 = cellData; _i < cellData_1.length; _i++) {
|
|
329
|
+
var cell = cellData_1[_i];
|
|
330
|
+
var value = (_b = (_a = cell === null || cell === void 0 ? void 0 : cell.v) === null || _a === void 0 ? void 0 : _a.m) === null || _b === void 0 ? void 0 : _b.toString();
|
|
331
|
+
if ((value === null || value === void 0 ? void 0 : value.includes("BTC")) || (value === null || value === void 0 ? void 0 : value.includes("ETH")) || (value === null || value === void 0 ? void 0 : value.includes("SOL"))) {
|
|
332
|
+
denominatedUsed = true;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
var denoWarn = document.getElementById("denomination-warning");
|
|
337
|
+
var scrollBar = document.getElementsByClassName("luckysheet-scrollbar-x")[0];
|
|
338
|
+
if (denominatedUsed && denoWarn) {
|
|
339
|
+
denoWarn.style.display = "block";
|
|
340
|
+
if (scrollBar) scrollBar.style.bottom = "28px";
|
|
341
|
+
} else if (!denominatedUsed && denoWarn) {
|
|
342
|
+
denoWarn.style.display = "none";
|
|
343
|
+
if (scrollBar) scrollBar.style.bottom = "0px";
|
|
344
|
+
}
|
|
345
|
+
return ctx;
|
|
346
|
+
});
|
|
323
347
|
if (context.luckysheet_select_save != null) {
|
|
324
348
|
(_b = (_a = mergedSettings.hooks) === null || _a === void 0 ? void 0 : _a.afterSelectionChange) === null || _b === void 0 ? void 0 : _b.call(_a, context.currentSheetId, context.luckysheet_select_save[0]);
|
|
325
349
|
}
|
package/es/constants.d.ts
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
1
|
export declare const API_KEY_PLACEHOLDER: Record<string, string>;
|
|
2
|
+
export declare const CRYPTO_OPTIONS: {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
icon: string;
|
|
6
|
+
type: string;
|
|
7
|
+
}[];
|
|
8
|
+
export declare const FIAT_ICON_MAP: {
|
|
9
|
+
USD: string;
|
|
10
|
+
EUR: string;
|
|
11
|
+
GBP: string;
|
|
12
|
+
JPY: string;
|
|
13
|
+
CNY: string;
|
|
14
|
+
INR: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function getGroupedCurrencyOptions(currencyDetail: Array<{
|
|
17
|
+
name: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}>): {
|
|
20
|
+
group: string;
|
|
21
|
+
options: {
|
|
22
|
+
label: string;
|
|
23
|
+
value: string;
|
|
24
|
+
icon: string | undefined;
|
|
25
|
+
type: string;
|
|
26
|
+
}[];
|
|
27
|
+
}[];
|
package/es/constants.js
CHANGED
|
@@ -1,4 +1,45 @@
|
|
|
1
1
|
import { SERVICE_API_KEY } from "@fileverse-dev/formulajs/crypto-constants";
|
|
2
2
|
export var API_KEY_PLACEHOLDER = Object.fromEntries(Object.values(SERVICE_API_KEY).map(function (key) {
|
|
3
3
|
return [key, "".concat(key.replace(/_/g, " ").replace(/\bAPI\b/, "API key"))];
|
|
4
|
-
}));
|
|
4
|
+
}));
|
|
5
|
+
export var CRYPTO_OPTIONS = [{
|
|
6
|
+
label: "Bitcoin (BTC)",
|
|
7
|
+
value: "BTC",
|
|
8
|
+
icon: "Btc",
|
|
9
|
+
type: "crypto"
|
|
10
|
+
}, {
|
|
11
|
+
label: "Ethereum (ETH)",
|
|
12
|
+
value: "ETH",
|
|
13
|
+
icon: "Ethereum",
|
|
14
|
+
type: "crypto"
|
|
15
|
+
}, {
|
|
16
|
+
label: "Solana (SOL)",
|
|
17
|
+
value: "SOL",
|
|
18
|
+
icon: "Solana",
|
|
19
|
+
type: "crypto"
|
|
20
|
+
}];
|
|
21
|
+
export var FIAT_ICON_MAP = {
|
|
22
|
+
USD: "DollarSign",
|
|
23
|
+
EUR: "Euro",
|
|
24
|
+
GBP: "PoundSterling",
|
|
25
|
+
JPY: "Yen",
|
|
26
|
+
CNY: "Yuan",
|
|
27
|
+
INR: "Rupee"
|
|
28
|
+
};
|
|
29
|
+
export function getGroupedCurrencyOptions(currencyDetail) {
|
|
30
|
+
var fiatOptions = currencyDetail.map(function (c) {
|
|
31
|
+
return {
|
|
32
|
+
label: c.name,
|
|
33
|
+
value: c.value,
|
|
34
|
+
icon: FIAT_ICON_MAP[c.value] || undefined,
|
|
35
|
+
type: "fiat"
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
return [{
|
|
39
|
+
group: "Crypto",
|
|
40
|
+
options: CRYPTO_OPTIONS
|
|
41
|
+
}, {
|
|
42
|
+
group: "Currency",
|
|
43
|
+
options: fiatOptions
|
|
44
|
+
}];
|
|
45
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface CryptoCell {
|
|
2
|
+
cellId: string;
|
|
3
|
+
baseValue: number;
|
|
4
|
+
cryptoType: string;
|
|
5
|
+
fiat: string;
|
|
6
|
+
value: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function useCryptoCells(): {
|
|
9
|
+
cryptoCells: CryptoCell[];
|
|
10
|
+
upsertCryptoCell: (cellId: string, baseValue: number, cryptoType: string, fiat: string) => Promise<void>;
|
|
11
|
+
};
|