@fileverse-dev/fortune-react 1.0.39 → 1.0.41
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 +23 -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/api.d.ts +2 -0
- package/es/components/Workbook/api.js +2 -0
- package/es/components/Workbook/index.d.ts +24 -23
- package/es/components/Workbook/index.js +36 -1
- package/es/constants.d.ts +26 -0
- package/es/constants.js +44 -3
- 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 +23 -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/api.d.ts +2 -0
- package/lib/components/Workbook/api.js +2 -0
- package/lib/components/Workbook/index.d.ts +24 -23
- package/lib/components/Workbook/index.js +35 -0
- package/lib/constants.d.ts +26 -0
- package/lib/constants.js +45 -3
- 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
|
@@ -26,8 +26,136 @@ var _CustomColor = require("./CustomColor");
|
|
|
26
26
|
var _FormatSearch = require("../FormatSearch");
|
|
27
27
|
var _DuneChartsInputModal = _interopRequireDefault(require("../DuneChartsInputModal/DuneChartsInputModal"));
|
|
28
28
|
var _MoreItemsContainer = _interopRequireDefault(require("./MoreItemsContainer"));
|
|
29
|
+
var _CryptoDenominationSelector = _interopRequireDefault(require("../CryptoDenominationSelector"));
|
|
30
|
+
var _constants = require("../../constants");
|
|
31
|
+
var _convertCellsToCrypto = require("../../utils/convertCellsToCrypto");
|
|
32
|
+
var _updateCellsDecimalFormat = require("../../utils/updateCellsDecimalFormat");
|
|
29
33
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
30
34
|
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); }
|
|
35
|
+
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) {
|
|
37
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
38
|
+
resolve(value);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
42
|
+
function fulfilled(value) {
|
|
43
|
+
try {
|
|
44
|
+
step(generator.next(value));
|
|
45
|
+
} catch (e) {
|
|
46
|
+
reject(e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function rejected(value) {
|
|
50
|
+
try {
|
|
51
|
+
step(generator["throw"](value));
|
|
52
|
+
} catch (e) {
|
|
53
|
+
reject(e);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function step(result) {
|
|
57
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
58
|
+
}
|
|
59
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
63
|
+
var _ = {
|
|
64
|
+
label: 0,
|
|
65
|
+
sent: function sent() {
|
|
66
|
+
if (t[0] & 1) throw t[1];
|
|
67
|
+
return t[1];
|
|
68
|
+
},
|
|
69
|
+
trys: [],
|
|
70
|
+
ops: []
|
|
71
|
+
},
|
|
72
|
+
f,
|
|
73
|
+
y,
|
|
74
|
+
t,
|
|
75
|
+
g;
|
|
76
|
+
return g = {
|
|
77
|
+
next: verb(0),
|
|
78
|
+
"throw": verb(1),
|
|
79
|
+
"return": verb(2)
|
|
80
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
81
|
+
return this;
|
|
82
|
+
}), g;
|
|
83
|
+
function verb(n) {
|
|
84
|
+
return function (v) {
|
|
85
|
+
return step([n, v]);
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function step(op) {
|
|
89
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
90
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
91
|
+
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;
|
|
92
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
93
|
+
switch (op[0]) {
|
|
94
|
+
case 0:
|
|
95
|
+
case 1:
|
|
96
|
+
t = op;
|
|
97
|
+
break;
|
|
98
|
+
case 4:
|
|
99
|
+
_.label++;
|
|
100
|
+
return {
|
|
101
|
+
value: op[1],
|
|
102
|
+
done: false
|
|
103
|
+
};
|
|
104
|
+
case 5:
|
|
105
|
+
_.label++;
|
|
106
|
+
y = op[1];
|
|
107
|
+
op = [0];
|
|
108
|
+
continue;
|
|
109
|
+
case 7:
|
|
110
|
+
op = _.ops.pop();
|
|
111
|
+
_.trys.pop();
|
|
112
|
+
continue;
|
|
113
|
+
default:
|
|
114
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
115
|
+
_ = 0;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
119
|
+
_.label = op[1];
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
123
|
+
_.label = t[1];
|
|
124
|
+
t = op;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
if (t && _.label < t[2]) {
|
|
128
|
+
_.label = t[2];
|
|
129
|
+
_.ops.push(op);
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
if (t[2]) _.ops.pop();
|
|
133
|
+
_.trys.pop();
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
op = body.call(thisArg, _);
|
|
137
|
+
} catch (e) {
|
|
138
|
+
op = [6, e];
|
|
139
|
+
y = 0;
|
|
140
|
+
} finally {
|
|
141
|
+
f = t = 0;
|
|
142
|
+
}
|
|
143
|
+
if (op[0] & 5) throw op[1];
|
|
144
|
+
return {
|
|
145
|
+
value: op[0] ? op[1] : void 0,
|
|
146
|
+
done: true
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
var __spreadArray = void 0 && (void 0).__spreadArray || function (to, from, pack) {
|
|
151
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
152
|
+
if (ar || !(i in from)) {
|
|
153
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
154
|
+
ar[i] = from[i];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
158
|
+
};
|
|
31
159
|
var getLucideIcon = exports.getLucideIcon = function getLucideIcon(title) {
|
|
32
160
|
switch (title) {
|
|
33
161
|
case "undo":
|
|
@@ -74,6 +202,8 @@ var getLucideIcon = exports.getLucideIcon = function getLucideIcon(title) {
|
|
|
74
202
|
return "DollarSign";
|
|
75
203
|
case "currency-format":
|
|
76
204
|
return "DollarSign";
|
|
205
|
+
case "currency":
|
|
206
|
+
return "ChevronDown";
|
|
77
207
|
case "percentage-format":
|
|
78
208
|
return "Percent";
|
|
79
209
|
case "number-decrease":
|
|
@@ -98,6 +228,8 @@ var getLucideIcon = exports.getLucideIcon = function getLucideIcon(title) {
|
|
|
98
228
|
return "Search";
|
|
99
229
|
case "dune":
|
|
100
230
|
return "DuneChart";
|
|
231
|
+
case "crypto":
|
|
232
|
+
return "Ethereum";
|
|
101
233
|
case "Ellipsis":
|
|
102
234
|
return "Ellipsis";
|
|
103
235
|
default:
|
|
@@ -163,6 +295,15 @@ var Toolbar = function Toolbar(_a) {
|
|
|
163
295
|
var defaultFormat = defaultFmt(currency);
|
|
164
296
|
var customColor = (0, _react.useState)("#000000")[0];
|
|
165
297
|
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];
|
|
166
307
|
var showSubMenu = (0, _react.useCallback)(function (e, className) {
|
|
167
308
|
var target = e.target;
|
|
168
309
|
var menuItem = target.className === "fortune-toolbar-menu-line" ? target.parentElement : target;
|
|
@@ -1255,6 +1396,183 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1255
1396
|
}));
|
|
1256
1397
|
});
|
|
1257
1398
|
}
|
|
1399
|
+
if (name === "currency") {
|
|
1400
|
+
var currentFmt_1 = defaultFormat[0].text;
|
|
1401
|
+
var currentIcon = "currency";
|
|
1402
|
+
if (cell) {
|
|
1403
|
+
var curr_3 = (0, _fortuneCore.normalizedCellAttr)(cell, "ct");
|
|
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 = allOptions.find(function (o) {
|
|
1414
|
+
return curr_3.fa.includes(o.value);
|
|
1415
|
+
});
|
|
1416
|
+
if (found) {
|
|
1417
|
+
currentFmt_1 = found.label;
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
var groupedOptions_1 = (0, _constants.getGroupedCurrencyOptions)((0, _fortuneCore.locale)(context).currencyDetail);
|
|
1422
|
+
var filterOptions_1 = function filterOptions_1(options) {
|
|
1423
|
+
if (!searchTerm.trim()) return options;
|
|
1424
|
+
var query = searchTerm.trim().toLowerCase();
|
|
1425
|
+
return options.filter(function (opt) {
|
|
1426
|
+
return query.split(/\s+/).every(function (word) {
|
|
1427
|
+
return opt.label.toLowerCase().includes(word) || opt.value.toLowerCase().includes(word);
|
|
1428
|
+
});
|
|
1429
|
+
});
|
|
1430
|
+
};
|
|
1431
|
+
var dedupeByValue_1 = function dedupeByValue_1(options) {
|
|
1432
|
+
var seen = new Set();
|
|
1433
|
+
return options.filter(function (opt) {
|
|
1434
|
+
if (seen.has(opt.value)) return false;
|
|
1435
|
+
seen.add(opt.value);
|
|
1436
|
+
return true;
|
|
1437
|
+
});
|
|
1438
|
+
};
|
|
1439
|
+
var handleCurrencyDecimalsChange_1 = function handleCurrencyDecimalsChange_1(newDecimals) {
|
|
1440
|
+
setDecimals(newDecimals);
|
|
1441
|
+
var isCrypto = false;
|
|
1442
|
+
if (cell && cell.ct && typeof cell.ct.fa === "string") {
|
|
1443
|
+
var _a = cell.ct.fa.match(/"([A-Z]+)"/) || [],
|
|
1444
|
+
matchedDenom = _a[1];
|
|
1445
|
+
if (matchedDenom) isCrypto = true;
|
|
1446
|
+
}
|
|
1447
|
+
(0, _updateCellsDecimalFormat.updateCellsDecimalFormat)({
|
|
1448
|
+
context: context,
|
|
1449
|
+
setContext: setContext,
|
|
1450
|
+
decimals: newDecimals,
|
|
1451
|
+
denomination: isCrypto ? undefined : selectedFiat
|
|
1452
|
+
});
|
|
1453
|
+
};
|
|
1454
|
+
return /*#__PURE__*/_react.default.createElement(_Combo.default, {
|
|
1455
|
+
iconId: currentIcon,
|
|
1456
|
+
text: currentFmt_1,
|
|
1457
|
+
key: name,
|
|
1458
|
+
tooltip: tooltip,
|
|
1459
|
+
showArrow: true
|
|
1460
|
+
}, function () {
|
|
1461
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
1462
|
+
style: {
|
|
1463
|
+
minWidth: "20rem"
|
|
1464
|
+
}
|
|
1465
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Command, {
|
|
1466
|
+
className: "border color-border-default rounded-lg"
|
|
1467
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1468
|
+
id: "search-input-container"
|
|
1469
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.CommandInput, {
|
|
1470
|
+
placeholder: "Search by name or code",
|
|
1471
|
+
value: searchTerm,
|
|
1472
|
+
onValueChange: setSearchTerm
|
|
1473
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
1474
|
+
className: "px-4 py-2 border-b color-border-default flex items-center justify-between gap-2 text-body-sm color-text-default",
|
|
1475
|
+
onClick: function onClick(e) {
|
|
1476
|
+
return e.stopPropagation();
|
|
1477
|
+
}
|
|
1478
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, "Decimal places:"), /*#__PURE__*/_react.default.createElement("span", {
|
|
1479
|
+
className: "cds-row flex items-center"
|
|
1480
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.IconButton, {
|
|
1481
|
+
icon: "Minus",
|
|
1482
|
+
variant: "ghost",
|
|
1483
|
+
size: "sm",
|
|
1484
|
+
className: "!bg-transparent",
|
|
1485
|
+
disabled: decimals === 1,
|
|
1486
|
+
onClick: function onClick() {
|
|
1487
|
+
return handleCurrencyDecimalsChange_1(Math.max(1, decimals - 1));
|
|
1488
|
+
}
|
|
1489
|
+
}), /*#__PURE__*/_react.default.createElement("input", {
|
|
1490
|
+
type: "number",
|
|
1491
|
+
min: 1,
|
|
1492
|
+
max: 18,
|
|
1493
|
+
value: decimals,
|
|
1494
|
+
onChange: function onChange(e) {
|
|
1495
|
+
return handleCurrencyDecimalsChange_1(Math.max(1, Math.min(18, Number(e.target.value))));
|
|
1496
|
+
}
|
|
1497
|
+
}), /*#__PURE__*/_react.default.createElement(_ui.IconButton, {
|
|
1498
|
+
icon: "Plus",
|
|
1499
|
+
variant: "ghost",
|
|
1500
|
+
size: "sm",
|
|
1501
|
+
className: "!bg-transparent",
|
|
1502
|
+
disabled: decimals === 18,
|
|
1503
|
+
onClick: function onClick() {
|
|
1504
|
+
return handleCurrencyDecimalsChange_1(Math.min(18, decimals + 1));
|
|
1505
|
+
}
|
|
1506
|
+
}))), /*#__PURE__*/_react.default.createElement(_ui.CommandList, null, /*#__PURE__*/_react.default.createElement(_ui.CommandEmpty, {
|
|
1507
|
+
className: "text-center text-body-sm color-text-secondary flex items-center justify-center",
|
|
1508
|
+
style: {
|
|
1509
|
+
minHeight: "5rem"
|
|
1510
|
+
}
|
|
1511
|
+
}, "No results found."), groupedOptions_1.map(function (group) {
|
|
1512
|
+
var filtered = dedupeByValue_1(filterOptions_1(group.options));
|
|
1513
|
+
return /*#__PURE__*/_react.default.createElement(_ui.CommandGroup, {
|
|
1514
|
+
key: group.group,
|
|
1515
|
+
heading: group.group
|
|
1516
|
+
}, filtered.map(function (opt) {
|
|
1517
|
+
return /*#__PURE__*/_react.default.createElement(_ui.CommandItem, {
|
|
1518
|
+
key: opt.value,
|
|
1519
|
+
value: "".concat(opt.label, " ").concat(opt.value),
|
|
1520
|
+
onSelect: function onSelect() {
|
|
1521
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
1522
|
+
return __generator(this, function (_a) {
|
|
1523
|
+
switch (_a.label) {
|
|
1524
|
+
case 0:
|
|
1525
|
+
if (!(opt.type === "crypto")) return [3, 2];
|
|
1526
|
+
return [4, (0, _convertCellsToCrypto.convertCellsToCrypto)({
|
|
1527
|
+
context: context,
|
|
1528
|
+
setContext: setContext,
|
|
1529
|
+
denomination: opt.value,
|
|
1530
|
+
decimals: decimals,
|
|
1531
|
+
baseCurrency: "USD"
|
|
1532
|
+
})];
|
|
1533
|
+
case 1:
|
|
1534
|
+
_a.sent();
|
|
1535
|
+
return [3, 3];
|
|
1536
|
+
case 2:
|
|
1537
|
+
setSelectedFiat(opt.value);
|
|
1538
|
+
setContext(function (ctx) {
|
|
1539
|
+
var d = (0, _fortuneCore.getFlowdata)(ctx);
|
|
1540
|
+
if (d == null) return;
|
|
1541
|
+
var formatString = "".concat((0, _convertCellsToCrypto.getFiatSymbol)(opt.value), " #,##0.").concat("0".repeat(decimals));
|
|
1542
|
+
(0, _fortuneCore.updateFormat)(ctx, refs.cellInput.current, d, "ct", formatString);
|
|
1543
|
+
});
|
|
1544
|
+
_a.label = 3;
|
|
1545
|
+
case 3:
|
|
1546
|
+
return [2];
|
|
1547
|
+
}
|
|
1548
|
+
});
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1552
|
+
className: "fortune-toolbar-menu-line flex items-center justify-between w-full"
|
|
1553
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1554
|
+
className: "flex items-center gap-2"
|
|
1555
|
+
}, currentFmt_1 === opt.label ? (/*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
|
|
1556
|
+
name: "Check",
|
|
1557
|
+
className: "w-4 h-4"
|
|
1558
|
+
})) : (/*#__PURE__*/_react.default.createElement("span", {
|
|
1559
|
+
className: "w-4 h-4"
|
|
1560
|
+
})), /*#__PURE__*/_react.default.createElement("span", null, opt.label)), opt.type === "crypto" ? (/*#__PURE__*/_react.default.createElement("span", {
|
|
1561
|
+
className: "color-text-secondary"
|
|
1562
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
|
|
1563
|
+
name: opt.icon,
|
|
1564
|
+
className: "cds-icon"
|
|
1565
|
+
}), opt.value === "SOL" && (/*#__PURE__*/_react.default.createElement(_SVGIcon.default, {
|
|
1566
|
+
name: "solana",
|
|
1567
|
+
width: 16,
|
|
1568
|
+
height: 16
|
|
1569
|
+
})))) : (/*#__PURE__*/_react.default.createElement("span", {
|
|
1570
|
+
className: "color-text-secondary"
|
|
1571
|
+
}, opt.value))));
|
|
1572
|
+
}));
|
|
1573
|
+
}))));
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1258
1576
|
return /*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
|
|
1259
1577
|
text: tooltip,
|
|
1260
1578
|
placement: "bottom"
|
|
@@ -1307,7 +1625,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1307
1625
|
onClose: onMoreToolbarItemsClose
|
|
1308
1626
|
}, moreToolbarItems))), /*#__PURE__*/_react.default.createElement("div", {
|
|
1309
1627
|
className: "fortune-toolbar-right"
|
|
1310
|
-
}, settings.customToolbarItems.length > 0 && (/*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
1628
|
+
}, settings.customToolbarItems.length > 0 && (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
1311
1629
|
iconId: "dune",
|
|
1312
1630
|
tooltip: "Insert Dune Chart",
|
|
1313
1631
|
key: "dune-charts",
|
|
@@ -1319,7 +1637,20 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1319
1637
|
backgroundColor: "#F4603E2E",
|
|
1320
1638
|
borderRadius: "8px"
|
|
1321
1639
|
}
|
|
1322
|
-
})
|
|
1640
|
+
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
1641
|
+
style: {
|
|
1642
|
+
display: "inline-block",
|
|
1643
|
+
position: "relative"
|
|
1644
|
+
}
|
|
1645
|
+
}, /*#__PURE__*/_react.default.createElement(_CryptoDenominationSelector.default, null, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
1646
|
+
iconId: "crypto",
|
|
1647
|
+
tooltip: "Crypto denominations",
|
|
1648
|
+
key: "crypto-denominations",
|
|
1649
|
+
style: {
|
|
1650
|
+
backgroundColor: "#e8ebec",
|
|
1651
|
+
borderRadius: "8px"
|
|
1652
|
+
}
|
|
1653
|
+
}))))), settings.customToolbarItems.filter(function (n) {
|
|
1323
1654
|
return n.key !== "import-export";
|
|
1324
1655
|
}).map(function (n) {
|
|
1325
1656
|
return /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { api, Cell, Context, Op, Range, Selection, Presence, Settings, SingleRange, Sheet, CellMatrix, CellWithRowAndCol, GlobalCache } from "@fileverse-dev/fortune-core";
|
|
2
|
+
import { getCryptoPrice } from "../../utils/cryptoApi";
|
|
2
3
|
import { SetContextOptions } from "../../context";
|
|
3
4
|
export declare function generateAPIs(context: Context, setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void, handleUndo: () => void, handleRedo: () => void, settings: Required<Settings>, cellInput: HTMLDivElement | null, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, globalCache: GlobalCache | null): {
|
|
4
5
|
applyOp: (ops: Op[]) => void;
|
|
6
|
+
getCryptoPrice: typeof getCryptoPrice;
|
|
5
7
|
getCellValue: (row: number, column: number, options?: api.CommonOptions & {
|
|
6
8
|
type?: keyof Cell;
|
|
7
9
|
}) => any;
|
|
@@ -7,6 +7,7 @@ exports.generateAPIs = generateAPIs;
|
|
|
7
7
|
var _fortuneCore = require("@fileverse-dev/fortune-core");
|
|
8
8
|
var _immer = require("immer");
|
|
9
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
|
+
var _cryptoApi = require("../../utils/cryptoApi");
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cellInput, scrollbarX, scrollbarY, globalCache) {
|
|
12
13
|
return {
|
|
@@ -61,6 +62,7 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
|
|
|
61
62
|
noHistory: true
|
|
62
63
|
});
|
|
63
64
|
},
|
|
65
|
+
getCryptoPrice: _cryptoApi.getCryptoPrice,
|
|
64
66
|
getCellValue: function getCellValue(row, column, options) {
|
|
65
67
|
if (options === void 0) {
|
|
66
68
|
options = {};
|
|
@@ -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,30 @@ type AdditionalProps = {
|
|
|
9
9
|
};
|
|
10
10
|
declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalProps & React.RefAttributes<{
|
|
11
11
|
applyOp: (ops: Op[]) => void;
|
|
12
|
-
|
|
12
|
+
getCryptoPrice: typeof import("../../utils/cryptoApi").getCryptoPrice;
|
|
13
|
+
getCellValue: (row: number, column: number, options?: api.CommonOptions & {
|
|
13
14
|
type?: "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
|
|
14
15
|
}) => any;
|
|
15
16
|
onboardingActiveCell: (functionName: string) => void;
|
|
16
17
|
initializeComment: (row: number, column: number) => void;
|
|
17
|
-
setCellValue: (row: number, column: number, value: any, options?:
|
|
18
|
+
setCellValue: (row: number, column: number, value: any, options?: api.CommonOptions & {
|
|
18
19
|
type?: "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
|
|
19
20
|
}) => 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?:
|
|
21
|
+
clearCell: (row: number, column: number, options?: api.CommonOptions) => void;
|
|
22
|
+
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
23
|
autoFillCell: (copyRange: import("@fileverse-dev/fortune-core").SingleRange, applyRange: import("@fileverse-dev/fortune-core").SingleRange, direction: "left" | "right" | "down" | "up") => void;
|
|
23
24
|
freeze: (type: "column" | "both" | "row", range: {
|
|
24
25
|
row: number;
|
|
25
26
|
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?:
|
|
27
|
+
}, options?: api.CommonOptions) => void;
|
|
28
|
+
insertRowOrColumn: (type: "column" | "row", index: number, count: number, direction?: "lefttop" | "rightbottom", options?: api.CommonOptions) => void;
|
|
29
|
+
deleteRowOrColumn: (type: "column" | "row", start: number, end: number, options?: api.CommonOptions) => void;
|
|
29
30
|
hideRowOrColumn: (rowOrColInfo: string[], type: "column" | "row") => void;
|
|
30
31
|
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?:
|
|
32
|
+
setRowHeight: (rowInfo: Record<string, number>, options?: api.CommonOptions, custom?: boolean) => void;
|
|
33
|
+
setColumnWidth: (columnInfo: Record<string, number>, options?: api.CommonOptions, custom?: boolean) => void;
|
|
34
|
+
getRowHeight: (rows: number[], options?: api.CommonOptions) => Record<number, number>;
|
|
35
|
+
getColumnWidth: (columns: number[], options?: api.CommonOptions) => Record<number, number>;
|
|
35
36
|
getSelection: () => {
|
|
36
37
|
row: number[];
|
|
37
38
|
column: number[];
|
|
@@ -45,15 +46,15 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
45
46
|
c: number;
|
|
46
47
|
}[] | undefined) => (import("@fileverse-dev/fortune-core").Cell | null)[];
|
|
47
48
|
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?:
|
|
49
|
+
getCellsByRange: (range: import("@fileverse-dev/fortune-core").Selection, options?: api.CommonOptions) => (import("@fileverse-dev/fortune-core").Cell | null)[][];
|
|
50
|
+
getHtmlByRange: (range: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => string | null;
|
|
51
|
+
setSelection: (range: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
|
|
52
|
+
setCellValuesByRange: (data: any[][], range: import("@fileverse-dev/fortune-core").SingleRange, options?: api.CommonOptions) => void;
|
|
53
|
+
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;
|
|
54
|
+
mergeCells: (ranges: import("@fileverse-dev/fortune-core").Range, type: string, options?: api.CommonOptions) => void;
|
|
55
|
+
cancelMerge: (ranges: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
|
|
55
56
|
getAllSheets: () => SheetType[];
|
|
56
|
-
getSheet: (options?:
|
|
57
|
+
getSheet: (options?: api.CommonOptions) => {
|
|
57
58
|
celldata: CellWithRowAndCol[];
|
|
58
59
|
name: string;
|
|
59
60
|
config?: import("@fileverse-dev/fortune-core").SheetConfig | undefined;
|
|
@@ -116,10 +117,10 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
116
117
|
} | undefined;
|
|
117
118
|
};
|
|
118
119
|
addSheet: () => void;
|
|
119
|
-
deleteSheet: (options?:
|
|
120
|
+
deleteSheet: (options?: api.CommonOptions) => void;
|
|
120
121
|
updateSheet: (data: SheetType[]) => void;
|
|
121
|
-
activateSheet: (options?:
|
|
122
|
-
setSheetName: (name: string, options?:
|
|
122
|
+
activateSheet: (options?: api.CommonOptions) => void;
|
|
123
|
+
setSheetName: (name: string, options?: api.CommonOptions) => void;
|
|
123
124
|
setSheetOrder: (orderList: Record<string, number>) => void;
|
|
124
125
|
scroll: (options: {
|
|
125
126
|
scrollLeft?: number | undefined;
|
|
@@ -329,6 +329,41 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
|
|
|
329
329
|
}, [emitOp]);
|
|
330
330
|
(0, _react.useEffect)(function () {
|
|
331
331
|
var _a, _b;
|
|
332
|
+
(_b = (_a = mergedSettings.hooks) === null || _a === void 0 ? void 0 : _a.afterActivateSheet) === null || _b === void 0 ? void 0 : _b.call(_a, context.currentSheetId);
|
|
333
|
+
}, [context.currentSheetId]);
|
|
334
|
+
(0, _react.useEffect)(function () {
|
|
335
|
+
var _a, _b;
|
|
336
|
+
setContext(function (ctx) {
|
|
337
|
+
var _a, _b;
|
|
338
|
+
var gridData = (0, _fortuneCore.getFlowdata)(ctx);
|
|
339
|
+
var cellData = _fortuneCore.api.dataToCelldata(gridData);
|
|
340
|
+
var denominatedUsed = false;
|
|
341
|
+
for (var _i = 0, cellData_1 = cellData; _i < cellData_1.length; _i++) {
|
|
342
|
+
var cell = cellData_1[_i];
|
|
343
|
+
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();
|
|
344
|
+
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"))) {
|
|
345
|
+
denominatedUsed = true;
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
var denoWarn = document.getElementById("denomination-warning");
|
|
350
|
+
var scrollBar = document.getElementsByClassName("luckysheet-scrollbar-x")[0];
|
|
351
|
+
if (denominatedUsed && denoWarn) {
|
|
352
|
+
denoWarn.style.display = "block";
|
|
353
|
+
denoWarn.style.left = "0px";
|
|
354
|
+
if (scrollBar) {
|
|
355
|
+
scrollBar.style.bottom = "40px !important";
|
|
356
|
+
scrollBar.style.backgroundColor = "red !important";
|
|
357
|
+
}
|
|
358
|
+
} else if (!denominatedUsed && denoWarn) {
|
|
359
|
+
denoWarn.style.display = "none";
|
|
360
|
+
denoWarn.style.left = "-9999px";
|
|
361
|
+
if (scrollBar) {
|
|
362
|
+
scrollBar.style.bottom = "12px !important";
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return ctx;
|
|
366
|
+
});
|
|
332
367
|
if (context.luckysheet_select_save != null) {
|
|
333
368
|
(_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]);
|
|
334
369
|
}
|
package/lib/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/lib/constants.js
CHANGED
|
@@ -3,8 +3,50 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.API_KEY_PLACEHOLDER = void 0;
|
|
6
|
+
exports.FIAT_ICON_MAP = exports.CRYPTO_OPTIONS = exports.API_KEY_PLACEHOLDER = void 0;
|
|
7
|
+
exports.getGroupedCurrencyOptions = getGroupedCurrencyOptions;
|
|
7
8
|
var _cryptoConstants = require("@fileverse-dev/formulajs/crypto-constants");
|
|
8
|
-
var API_KEY_PLACEHOLDER = exports.API_KEY_PLACEHOLDER = Object.fromEntries(Object.values(_cryptoConstants.
|
|
9
|
+
var API_KEY_PLACEHOLDER = exports.API_KEY_PLACEHOLDER = Object.fromEntries(Object.values(_cryptoConstants.SERVICES_API_KEY).map(function (key) {
|
|
9
10
|
return [key, "".concat(key.replace(/_/g, " ").replace(/\bAPI\b/, "API key"))];
|
|
10
|
-
}));
|
|
11
|
+
}));
|
|
12
|
+
var CRYPTO_OPTIONS = exports.CRYPTO_OPTIONS = [{
|
|
13
|
+
label: "Bitcoin (BTC)",
|
|
14
|
+
value: "BTC",
|
|
15
|
+
icon: "Btc",
|
|
16
|
+
type: "crypto"
|
|
17
|
+
}, {
|
|
18
|
+
label: "Ethereum (ETH)",
|
|
19
|
+
value: "ETH",
|
|
20
|
+
icon: "Ethereum",
|
|
21
|
+
type: "crypto"
|
|
22
|
+
}, {
|
|
23
|
+
label: "Solana (SOL)",
|
|
24
|
+
value: "SOL",
|
|
25
|
+
icon: "Solana",
|
|
26
|
+
type: "crypto"
|
|
27
|
+
}];
|
|
28
|
+
var FIAT_ICON_MAP = exports.FIAT_ICON_MAP = {
|
|
29
|
+
USD: "DollarSign",
|
|
30
|
+
EUR: "Euro",
|
|
31
|
+
GBP: "PoundSterling",
|
|
32
|
+
JPY: "Yen",
|
|
33
|
+
CNY: "Yuan",
|
|
34
|
+
INR: "Rupee"
|
|
35
|
+
};
|
|
36
|
+
function getGroupedCurrencyOptions(currencyDetail) {
|
|
37
|
+
var fiatOptions = currencyDetail.map(function (c) {
|
|
38
|
+
return {
|
|
39
|
+
label: c.name,
|
|
40
|
+
value: c.value,
|
|
41
|
+
icon: FIAT_ICON_MAP[c.value] || undefined,
|
|
42
|
+
type: "fiat"
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
return [{
|
|
46
|
+
group: "Crypto",
|
|
47
|
+
options: CRYPTO_OPTIONS
|
|
48
|
+
}, {
|
|
49
|
+
group: "Currency",
|
|
50
|
+
options: fiatOptions
|
|
51
|
+
}];
|
|
52
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const getFiatSymbol: (code: string) => string;
|
|
2
|
+
export declare function convertCellsToCrypto({ context, setContext, denomination, decimals, baseCurrency, }: {
|
|
3
|
+
context: any;
|
|
4
|
+
setContext: (fn: (ctx: any) => void) => void;
|
|
5
|
+
denomination: string;
|
|
6
|
+
decimals: number;
|
|
7
|
+
baseCurrency: string;
|
|
8
|
+
}): Promise<void>;
|