@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
|
@@ -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":
|
|
@@ -72,6 +200,8 @@ var getLucideIcon = exports.getLucideIcon = function getLucideIcon(title) {
|
|
|
72
200
|
return "DollarSign";
|
|
73
201
|
case "currency-format":
|
|
74
202
|
return "DollarSign";
|
|
203
|
+
case "currency":
|
|
204
|
+
return "ChevronDown";
|
|
75
205
|
case "percentage-format":
|
|
76
206
|
return "Percent";
|
|
77
207
|
case "number-decrease":
|
|
@@ -96,6 +226,8 @@ var getLucideIcon = exports.getLucideIcon = function getLucideIcon(title) {
|
|
|
96
226
|
return "Search";
|
|
97
227
|
case "dune":
|
|
98
228
|
return "DuneChart";
|
|
229
|
+
case "crypto":
|
|
230
|
+
return "Ethereum";
|
|
99
231
|
case "Ellipsis":
|
|
100
232
|
return "Ellipsis";
|
|
101
233
|
default:
|
|
@@ -161,6 +293,15 @@ var Toolbar = function Toolbar(_a) {
|
|
|
161
293
|
var defaultFormat = defaultFmt(currency);
|
|
162
294
|
var customColor = (0, _react.useState)("#000000")[0];
|
|
163
295
|
var customStyle = (0, _react.useState)("1")[0];
|
|
296
|
+
var _m = (0, _react.useState)(""),
|
|
297
|
+
searchTerm = _m[0],
|
|
298
|
+
setSearchTerm = _m[1];
|
|
299
|
+
var _o = (0, _react.useState)(2),
|
|
300
|
+
decimals = _o[0],
|
|
301
|
+
setDecimals = _o[1];
|
|
302
|
+
var _p = (0, _react.useState)("USD"),
|
|
303
|
+
selectedFiat = _p[0],
|
|
304
|
+
setSelectedFiat = _p[1];
|
|
164
305
|
var showSubMenu = (0, _react.useCallback)(function (e, className) {
|
|
165
306
|
var target = e.target;
|
|
166
307
|
var menuItem = target.className === "fortune-toolbar-menu-line" ? target.parentElement : target;
|
|
@@ -1253,6 +1394,183 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1253
1394
|
}));
|
|
1254
1395
|
});
|
|
1255
1396
|
}
|
|
1397
|
+
if (name === "currency") {
|
|
1398
|
+
var currentFmt_1 = defaultFormat[0].text;
|
|
1399
|
+
var currentIcon = "currency";
|
|
1400
|
+
if (cell) {
|
|
1401
|
+
var curr_3 = (0, _fortuneCore.normalizedCellAttr)(cell, "ct");
|
|
1402
|
+
if (curr_3 === null || curr_3 === void 0 ? void 0 : curr_3.fa) {
|
|
1403
|
+
var allOptions = __spreadArray(__spreadArray([], _constants.CRYPTO_OPTIONS, true), (0, _fortuneCore.locale)(context).currencyDetail.map(function (c) {
|
|
1404
|
+
return {
|
|
1405
|
+
label: c.name,
|
|
1406
|
+
value: c.value,
|
|
1407
|
+
icon: undefined,
|
|
1408
|
+
type: "fiat"
|
|
1409
|
+
};
|
|
1410
|
+
}), true);
|
|
1411
|
+
var found = allOptions.find(function (o) {
|
|
1412
|
+
return curr_3.fa.includes(o.value);
|
|
1413
|
+
});
|
|
1414
|
+
if (found) {
|
|
1415
|
+
currentFmt_1 = found.label;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
var groupedOptions_1 = (0, _constants.getGroupedCurrencyOptions)((0, _fortuneCore.locale)(context).currencyDetail);
|
|
1420
|
+
var filterOptions_1 = function filterOptions_1(options) {
|
|
1421
|
+
if (!searchTerm.trim()) return options;
|
|
1422
|
+
var query = searchTerm.trim().toLowerCase();
|
|
1423
|
+
return options.filter(function (opt) {
|
|
1424
|
+
return query.split(/\s+/).every(function (word) {
|
|
1425
|
+
return opt.label.toLowerCase().includes(word) || opt.value.toLowerCase().includes(word);
|
|
1426
|
+
});
|
|
1427
|
+
});
|
|
1428
|
+
};
|
|
1429
|
+
var dedupeByValue_1 = function dedupeByValue_1(options) {
|
|
1430
|
+
var seen = new Set();
|
|
1431
|
+
return options.filter(function (opt) {
|
|
1432
|
+
if (seen.has(opt.value)) return false;
|
|
1433
|
+
seen.add(opt.value);
|
|
1434
|
+
return true;
|
|
1435
|
+
});
|
|
1436
|
+
};
|
|
1437
|
+
var handleCurrencyDecimalsChange_1 = function handleCurrencyDecimalsChange_1(newDecimals) {
|
|
1438
|
+
setDecimals(newDecimals);
|
|
1439
|
+
var isCrypto = false;
|
|
1440
|
+
if (cell && cell.ct && typeof cell.ct.fa === "string") {
|
|
1441
|
+
var _a = cell.ct.fa.match(/"([A-Z]+)"/) || [],
|
|
1442
|
+
matchedDenom = _a[1];
|
|
1443
|
+
if (matchedDenom) isCrypto = true;
|
|
1444
|
+
}
|
|
1445
|
+
(0, _updateCellsDecimalFormat.updateCellsDecimalFormat)({
|
|
1446
|
+
context: context,
|
|
1447
|
+
setContext: setContext,
|
|
1448
|
+
decimals: newDecimals,
|
|
1449
|
+
denomination: isCrypto ? undefined : selectedFiat
|
|
1450
|
+
});
|
|
1451
|
+
};
|
|
1452
|
+
return /*#__PURE__*/_react.default.createElement(_Combo.default, {
|
|
1453
|
+
iconId: currentIcon,
|
|
1454
|
+
text: currentFmt_1,
|
|
1455
|
+
key: name,
|
|
1456
|
+
tooltip: tooltip,
|
|
1457
|
+
showArrow: true
|
|
1458
|
+
}, function () {
|
|
1459
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
1460
|
+
style: {
|
|
1461
|
+
minWidth: "20rem"
|
|
1462
|
+
}
|
|
1463
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Command, {
|
|
1464
|
+
className: "border color-border-default rounded-lg"
|
|
1465
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1466
|
+
id: "search-input-container"
|
|
1467
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.CommandInput, {
|
|
1468
|
+
placeholder: "Search by name or code",
|
|
1469
|
+
value: searchTerm,
|
|
1470
|
+
onValueChange: setSearchTerm
|
|
1471
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
1472
|
+
className: "px-4 py-2 border-b color-border-default flex items-center justify-between gap-2 text-body-sm color-text-default",
|
|
1473
|
+
onClick: function onClick(e) {
|
|
1474
|
+
return e.stopPropagation();
|
|
1475
|
+
}
|
|
1476
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, "Decimal places:"), /*#__PURE__*/_react.default.createElement("span", {
|
|
1477
|
+
className: "cds-row flex items-center"
|
|
1478
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.IconButton, {
|
|
1479
|
+
icon: "Minus",
|
|
1480
|
+
variant: "ghost",
|
|
1481
|
+
size: "sm",
|
|
1482
|
+
className: "!bg-transparent",
|
|
1483
|
+
disabled: decimals === 1,
|
|
1484
|
+
onClick: function onClick() {
|
|
1485
|
+
return handleCurrencyDecimalsChange_1(Math.max(1, decimals - 1));
|
|
1486
|
+
}
|
|
1487
|
+
}), /*#__PURE__*/_react.default.createElement("input", {
|
|
1488
|
+
type: "number",
|
|
1489
|
+
min: 1,
|
|
1490
|
+
max: 18,
|
|
1491
|
+
value: decimals,
|
|
1492
|
+
onChange: function onChange(e) {
|
|
1493
|
+
return handleCurrencyDecimalsChange_1(Math.max(1, Math.min(18, Number(e.target.value))));
|
|
1494
|
+
}
|
|
1495
|
+
}), /*#__PURE__*/_react.default.createElement(_ui.IconButton, {
|
|
1496
|
+
icon: "Plus",
|
|
1497
|
+
variant: "ghost",
|
|
1498
|
+
size: "sm",
|
|
1499
|
+
className: "!bg-transparent",
|
|
1500
|
+
disabled: decimals === 18,
|
|
1501
|
+
onClick: function onClick() {
|
|
1502
|
+
return handleCurrencyDecimalsChange_1(Math.min(18, decimals + 1));
|
|
1503
|
+
}
|
|
1504
|
+
}))), /*#__PURE__*/_react.default.createElement(_ui.CommandList, null, /*#__PURE__*/_react.default.createElement(_ui.CommandEmpty, {
|
|
1505
|
+
className: "text-center text-body-sm color-text-secondary flex items-center justify-center",
|
|
1506
|
+
style: {
|
|
1507
|
+
minHeight: "5rem"
|
|
1508
|
+
}
|
|
1509
|
+
}, "No results found."), groupedOptions_1.map(function (group) {
|
|
1510
|
+
var filtered = dedupeByValue_1(filterOptions_1(group.options));
|
|
1511
|
+
return /*#__PURE__*/_react.default.createElement(_ui.CommandGroup, {
|
|
1512
|
+
key: group.group,
|
|
1513
|
+
heading: group.group
|
|
1514
|
+
}, filtered.map(function (opt) {
|
|
1515
|
+
return /*#__PURE__*/_react.default.createElement(_ui.CommandItem, {
|
|
1516
|
+
key: opt.value,
|
|
1517
|
+
value: "".concat(opt.label, " ").concat(opt.value),
|
|
1518
|
+
onSelect: function onSelect() {
|
|
1519
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
1520
|
+
return __generator(this, function (_a) {
|
|
1521
|
+
switch (_a.label) {
|
|
1522
|
+
case 0:
|
|
1523
|
+
if (!(opt.type === "crypto")) return [3, 2];
|
|
1524
|
+
return [4, (0, _convertCellsToCrypto.convertCellsToCrypto)({
|
|
1525
|
+
context: context,
|
|
1526
|
+
setContext: setContext,
|
|
1527
|
+
denomination: opt.value,
|
|
1528
|
+
decimals: decimals,
|
|
1529
|
+
baseCurrency: "USD"
|
|
1530
|
+
})];
|
|
1531
|
+
case 1:
|
|
1532
|
+
_a.sent();
|
|
1533
|
+
return [3, 3];
|
|
1534
|
+
case 2:
|
|
1535
|
+
setSelectedFiat(opt.value);
|
|
1536
|
+
setContext(function (ctx) {
|
|
1537
|
+
var d = (0, _fortuneCore.getFlowdata)(ctx);
|
|
1538
|
+
if (d == null) return;
|
|
1539
|
+
var formatString = "".concat((0, _convertCellsToCrypto.getFiatSymbol)(opt.value), " #,##0.").concat("0".repeat(decimals));
|
|
1540
|
+
(0, _fortuneCore.updateFormat)(ctx, refs.cellInput.current, d, "ct", formatString);
|
|
1541
|
+
});
|
|
1542
|
+
_a.label = 3;
|
|
1543
|
+
case 3:
|
|
1544
|
+
return [2];
|
|
1545
|
+
}
|
|
1546
|
+
});
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1550
|
+
className: "fortune-toolbar-menu-line flex items-center justify-between w-full"
|
|
1551
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1552
|
+
className: "flex items-center gap-2"
|
|
1553
|
+
}, currentFmt_1 === opt.label ? (/*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
|
|
1554
|
+
name: "Check",
|
|
1555
|
+
className: "w-4 h-4"
|
|
1556
|
+
})) : (/*#__PURE__*/_react.default.createElement("span", {
|
|
1557
|
+
className: "w-4 h-4"
|
|
1558
|
+
})), /*#__PURE__*/_react.default.createElement("span", null, opt.label)), opt.type === "crypto" ? (/*#__PURE__*/_react.default.createElement("span", {
|
|
1559
|
+
className: "color-text-secondary"
|
|
1560
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
|
|
1561
|
+
name: opt.icon,
|
|
1562
|
+
className: "cds-icon"
|
|
1563
|
+
}), opt.value === "SOL" && (/*#__PURE__*/_react.default.createElement(_SVGIcon.default, {
|
|
1564
|
+
name: "solana",
|
|
1565
|
+
width: 16,
|
|
1566
|
+
height: 16
|
|
1567
|
+
})))) : (/*#__PURE__*/_react.default.createElement("span", {
|
|
1568
|
+
className: "color-text-secondary"
|
|
1569
|
+
}, opt.value))));
|
|
1570
|
+
}));
|
|
1571
|
+
}))));
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1256
1574
|
return /*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
|
|
1257
1575
|
text: tooltip,
|
|
1258
1576
|
placement: "bottom"
|
|
@@ -1305,7 +1623,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1305
1623
|
onClose: onMoreToolbarItemsClose
|
|
1306
1624
|
}, moreToolbarItems))), /*#__PURE__*/_react.default.createElement("div", {
|
|
1307
1625
|
className: "fortune-toolbar-right"
|
|
1308
|
-
}, settings.customToolbarItems.length > 0 && (/*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
1626
|
+
}, settings.customToolbarItems.length > 0 && (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
1309
1627
|
iconId: "dune",
|
|
1310
1628
|
tooltip: "Insert Dune Chart",
|
|
1311
1629
|
key: "dune-charts",
|
|
@@ -1317,7 +1635,20 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1317
1635
|
backgroundColor: "#F4603E2E",
|
|
1318
1636
|
borderRadius: "8px"
|
|
1319
1637
|
}
|
|
1320
|
-
})
|
|
1638
|
+
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
1639
|
+
style: {
|
|
1640
|
+
display: "inline-block",
|
|
1641
|
+
position: "relative"
|
|
1642
|
+
}
|
|
1643
|
+
}, /*#__PURE__*/_react.default.createElement(_CryptoDenominationSelector.default, null, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
1644
|
+
iconId: "crypto",
|
|
1645
|
+
tooltip: "Crypto denominations",
|
|
1646
|
+
key: "crypto-denominations",
|
|
1647
|
+
style: {
|
|
1648
|
+
backgroundColor: "#e8ebec",
|
|
1649
|
+
borderRadius: "8px"
|
|
1650
|
+
}
|
|
1651
|
+
}))))), settings.customToolbarItems.filter(function (n) {
|
|
1321
1652
|
return n.key !== "import-export";
|
|
1322
1653
|
}).map(function (n) {
|
|
1323
1654
|
return /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
|
|
@@ -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;
|
|
@@ -329,6 +329,30 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
|
|
|
329
329
|
}, [emitOp]);
|
|
330
330
|
(0, _react.useEffect)(function () {
|
|
331
331
|
var _a, _b;
|
|
332
|
+
setContext(function (ctx) {
|
|
333
|
+
var _a, _b;
|
|
334
|
+
var gridData = (0, _fortuneCore.getFlowdata)(ctx);
|
|
335
|
+
var cellData = _fortuneCore.api.dataToCelldata(gridData);
|
|
336
|
+
var denominatedUsed = false;
|
|
337
|
+
for (var _i = 0, cellData_1 = cellData; _i < cellData_1.length; _i++) {
|
|
338
|
+
var cell = cellData_1[_i];
|
|
339
|
+
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();
|
|
340
|
+
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"))) {
|
|
341
|
+
denominatedUsed = true;
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
var denoWarn = document.getElementById("denomination-warning");
|
|
346
|
+
var scrollBar = document.getElementsByClassName("luckysheet-scrollbar-x")[0];
|
|
347
|
+
if (denominatedUsed && denoWarn) {
|
|
348
|
+
denoWarn.style.display = "block";
|
|
349
|
+
if (scrollBar) scrollBar.style.bottom = "28px";
|
|
350
|
+
} else if (!denominatedUsed && denoWarn) {
|
|
351
|
+
denoWarn.style.display = "none";
|
|
352
|
+
if (scrollBar) scrollBar.style.bottom = "0px";
|
|
353
|
+
}
|
|
354
|
+
return ctx;
|
|
355
|
+
});
|
|
332
356
|
if (context.luckysheet_select_save != null) {
|
|
333
357
|
(_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
358
|
}
|
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
9
|
var API_KEY_PLACEHOLDER = exports.API_KEY_PLACEHOLDER = Object.fromEntries(Object.values(_cryptoConstants.SERVICE_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,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
|
+
};
|