@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.
Files changed (45) hide show
  1. package/es/components/CryptoDenominationSelector/index.css +67 -0
  2. package/es/components/CryptoDenominationSelector/index.d.ts +8 -0
  3. package/es/components/CryptoDenominationSelector/index.js +272 -0
  4. package/es/components/FormatSearch/index.js +9 -5
  5. package/es/components/SVGDefines.js +60 -1
  6. package/es/components/SheetTab/index.js +23 -2
  7. package/es/components/Toolbar/Combo.js +18 -4
  8. package/es/components/Toolbar/index.css +6 -0
  9. package/es/components/Toolbar/index.d.ts +1 -1
  10. package/es/components/Toolbar/index.js +334 -3
  11. package/es/components/Workbook/api.d.ts +2 -0
  12. package/es/components/Workbook/api.js +2 -0
  13. package/es/components/Workbook/index.d.ts +24 -23
  14. package/es/components/Workbook/index.js +36 -1
  15. package/es/constants.d.ts +26 -0
  16. package/es/constants.js +44 -3
  17. package/es/utils/convertCellsToCrypto.d.ts +8 -0
  18. package/es/utils/convertCellsToCrypto.js +215 -0
  19. package/es/utils/cryptoApi.d.ts +2 -0
  20. package/es/utils/cryptoApi.js +154 -0
  21. package/es/utils/updateCellsDecimalFormat.d.ts +6 -0
  22. package/es/utils/updateCellsDecimalFormat.js +80 -0
  23. package/lib/components/CryptoDenominationSelector/index.css +67 -0
  24. package/lib/components/CryptoDenominationSelector/index.d.ts +8 -0
  25. package/lib/components/CryptoDenominationSelector/index.js +281 -0
  26. package/lib/components/FormatSearch/index.js +9 -5
  27. package/lib/components/SVGDefines.js +60 -1
  28. package/lib/components/SheetTab/index.js +23 -2
  29. package/lib/components/Toolbar/Combo.js +18 -4
  30. package/lib/components/Toolbar/index.css +6 -0
  31. package/lib/components/Toolbar/index.d.ts +1 -1
  32. package/lib/components/Toolbar/index.js +333 -2
  33. package/lib/components/Workbook/api.d.ts +2 -0
  34. package/lib/components/Workbook/api.js +2 -0
  35. package/lib/components/Workbook/index.d.ts +24 -23
  36. package/lib/components/Workbook/index.js +35 -0
  37. package/lib/constants.d.ts +26 -0
  38. package/lib/constants.js +45 -3
  39. package/lib/utils/convertCellsToCrypto.d.ts +8 -0
  40. package/lib/utils/convertCellsToCrypto.js +222 -0
  41. package/lib/utils/cryptoApi.d.ts +2 -0
  42. package/lib/utils/cryptoApi.js +161 -0
  43. package/lib/utils/updateCellsDecimalFormat.d.ts +6 -0
  44. package/lib/utils/updateCellsDecimalFormat.js +86 -0
  45. 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":
@@ -65,6 +193,8 @@ export var getLucideIcon = function getLucideIcon(title) {
65
193
  return "DollarSign";
66
194
  case "currency-format":
67
195
  return "DollarSign";
196
+ case "currency":
197
+ return "ChevronDown";
68
198
  case "percentage-format":
69
199
  return "Percent";
70
200
  case "number-decrease":
@@ -89,6 +219,8 @@ export var getLucideIcon = function getLucideIcon(title) {
89
219
  return "Search";
90
220
  case "dune":
91
221
  return "DuneChart";
222
+ case "crypto":
223
+ return "Ethereum";
92
224
  case "Ellipsis":
93
225
  return "Ellipsis";
94
226
  default:
@@ -154,6 +286,15 @@ var Toolbar = function Toolbar(_a) {
154
286
  var defaultFormat = defaultFmt(currency);
155
287
  var customColor = useState("#000000")[0];
156
288
  var customStyle = useState("1")[0];
289
+ var _m = useState(""),
290
+ searchTerm = _m[0],
291
+ setSearchTerm = _m[1];
292
+ var _o = useState(2),
293
+ decimals = _o[0],
294
+ setDecimals = _o[1];
295
+ var _p = useState("USD"),
296
+ selectedFiat = _p[0],
297
+ setSelectedFiat = _p[1];
157
298
  var showSubMenu = useCallback(function (e, className) {
158
299
  var target = e.target;
159
300
  var menuItem = target.className === "fortune-toolbar-menu-line" ? target.parentElement : target;
@@ -1246,6 +1387,183 @@ var Toolbar = function Toolbar(_a) {
1246
1387
  }));
1247
1388
  });
1248
1389
  }
1390
+ if (name === "currency") {
1391
+ var currentFmt_1 = defaultFormat[0].text;
1392
+ var currentIcon = "currency";
1393
+ if (cell) {
1394
+ var curr_3 = normalizedCellAttr(cell, "ct");
1395
+ if (curr_3 === null || curr_3 === void 0 ? void 0 : curr_3.fa) {
1396
+ var allOptions = __spreadArray(__spreadArray([], CRYPTO_OPTIONS, true), locale(context).currencyDetail.map(function (c) {
1397
+ return {
1398
+ label: c.name,
1399
+ value: c.value,
1400
+ icon: undefined,
1401
+ type: "fiat"
1402
+ };
1403
+ }), true);
1404
+ var found = allOptions.find(function (o) {
1405
+ return curr_3.fa.includes(o.value);
1406
+ });
1407
+ if (found) {
1408
+ currentFmt_1 = found.label;
1409
+ }
1410
+ }
1411
+ }
1412
+ var groupedOptions_1 = getGroupedCurrencyOptions(locale(context).currencyDetail);
1413
+ var filterOptions_1 = function filterOptions_1(options) {
1414
+ if (!searchTerm.trim()) return options;
1415
+ var query = searchTerm.trim().toLowerCase();
1416
+ return options.filter(function (opt) {
1417
+ return query.split(/\s+/).every(function (word) {
1418
+ return opt.label.toLowerCase().includes(word) || opt.value.toLowerCase().includes(word);
1419
+ });
1420
+ });
1421
+ };
1422
+ var dedupeByValue_1 = function dedupeByValue_1(options) {
1423
+ var seen = new Set();
1424
+ return options.filter(function (opt) {
1425
+ if (seen.has(opt.value)) return false;
1426
+ seen.add(opt.value);
1427
+ return true;
1428
+ });
1429
+ };
1430
+ var handleCurrencyDecimalsChange_1 = function handleCurrencyDecimalsChange_1(newDecimals) {
1431
+ setDecimals(newDecimals);
1432
+ var isCrypto = false;
1433
+ if (cell && cell.ct && typeof cell.ct.fa === "string") {
1434
+ var _a = cell.ct.fa.match(/"([A-Z]+)"/) || [],
1435
+ matchedDenom = _a[1];
1436
+ if (matchedDenom) isCrypto = true;
1437
+ }
1438
+ updateCellsDecimalFormat({
1439
+ context: context,
1440
+ setContext: setContext,
1441
+ decimals: newDecimals,
1442
+ denomination: isCrypto ? undefined : selectedFiat
1443
+ });
1444
+ };
1445
+ return /*#__PURE__*/React.createElement(Combo, {
1446
+ iconId: currentIcon,
1447
+ text: currentFmt_1,
1448
+ key: name,
1449
+ tooltip: tooltip,
1450
+ showArrow: true
1451
+ }, function () {
1452
+ return /*#__PURE__*/React.createElement("div", {
1453
+ style: {
1454
+ minWidth: "20rem"
1455
+ }
1456
+ }, /*#__PURE__*/React.createElement(Command, {
1457
+ className: "border color-border-default rounded-lg"
1458
+ }, /*#__PURE__*/React.createElement("div", {
1459
+ id: "search-input-container"
1460
+ }, /*#__PURE__*/React.createElement(CommandInput, {
1461
+ placeholder: "Search by name or code",
1462
+ value: searchTerm,
1463
+ onValueChange: setSearchTerm
1464
+ })), /*#__PURE__*/React.createElement("div", {
1465
+ className: "px-4 py-2 border-b color-border-default flex items-center justify-between gap-2 text-body-sm color-text-default",
1466
+ onClick: function onClick(e) {
1467
+ return e.stopPropagation();
1468
+ }
1469
+ }, /*#__PURE__*/React.createElement("span", null, "Decimal places:"), /*#__PURE__*/React.createElement("span", {
1470
+ className: "cds-row flex items-center"
1471
+ }, /*#__PURE__*/React.createElement(IconButton, {
1472
+ icon: "Minus",
1473
+ variant: "ghost",
1474
+ size: "sm",
1475
+ className: "!bg-transparent",
1476
+ disabled: decimals === 1,
1477
+ onClick: function onClick() {
1478
+ return handleCurrencyDecimalsChange_1(Math.max(1, decimals - 1));
1479
+ }
1480
+ }), /*#__PURE__*/React.createElement("input", {
1481
+ type: "number",
1482
+ min: 1,
1483
+ max: 18,
1484
+ value: decimals,
1485
+ onChange: function onChange(e) {
1486
+ return handleCurrencyDecimalsChange_1(Math.max(1, Math.min(18, Number(e.target.value))));
1487
+ }
1488
+ }), /*#__PURE__*/React.createElement(IconButton, {
1489
+ icon: "Plus",
1490
+ variant: "ghost",
1491
+ size: "sm",
1492
+ className: "!bg-transparent",
1493
+ disabled: decimals === 18,
1494
+ onClick: function onClick() {
1495
+ return handleCurrencyDecimalsChange_1(Math.min(18, decimals + 1));
1496
+ }
1497
+ }))), /*#__PURE__*/React.createElement(CommandList, null, /*#__PURE__*/React.createElement(CommandEmpty, {
1498
+ className: "text-center text-body-sm color-text-secondary flex items-center justify-center",
1499
+ style: {
1500
+ minHeight: "5rem"
1501
+ }
1502
+ }, "No results found."), groupedOptions_1.map(function (group) {
1503
+ var filtered = dedupeByValue_1(filterOptions_1(group.options));
1504
+ return /*#__PURE__*/React.createElement(CommandGroup, {
1505
+ key: group.group,
1506
+ heading: group.group
1507
+ }, filtered.map(function (opt) {
1508
+ return /*#__PURE__*/React.createElement(CommandItem, {
1509
+ key: opt.value,
1510
+ value: "".concat(opt.label, " ").concat(opt.value),
1511
+ onSelect: function onSelect() {
1512
+ return __awaiter(void 0, void 0, void 0, function () {
1513
+ return __generator(this, function (_a) {
1514
+ switch (_a.label) {
1515
+ case 0:
1516
+ if (!(opt.type === "crypto")) return [3, 2];
1517
+ return [4, convertCellsToCrypto({
1518
+ context: context,
1519
+ setContext: setContext,
1520
+ denomination: opt.value,
1521
+ decimals: decimals,
1522
+ baseCurrency: "USD"
1523
+ })];
1524
+ case 1:
1525
+ _a.sent();
1526
+ return [3, 3];
1527
+ case 2:
1528
+ setSelectedFiat(opt.value);
1529
+ setContext(function (ctx) {
1530
+ var d = getFlowdata(ctx);
1531
+ if (d == null) return;
1532
+ var formatString = "".concat(getFiatSymbol(opt.value), " #,##0.").concat("0".repeat(decimals));
1533
+ updateFormat(ctx, refs.cellInput.current, d, "ct", formatString);
1534
+ });
1535
+ _a.label = 3;
1536
+ case 3:
1537
+ return [2];
1538
+ }
1539
+ });
1540
+ });
1541
+ }
1542
+ }, /*#__PURE__*/React.createElement("div", {
1543
+ className: "fortune-toolbar-menu-line flex items-center justify-between w-full"
1544
+ }, /*#__PURE__*/React.createElement("div", {
1545
+ className: "flex items-center gap-2"
1546
+ }, currentFmt_1 === opt.label ? (/*#__PURE__*/React.createElement(LucideIcon, {
1547
+ name: "Check",
1548
+ className: "w-4 h-4"
1549
+ })) : (/*#__PURE__*/React.createElement("span", {
1550
+ className: "w-4 h-4"
1551
+ })), /*#__PURE__*/React.createElement("span", null, opt.label)), opt.type === "crypto" ? (/*#__PURE__*/React.createElement("span", {
1552
+ className: "color-text-secondary"
1553
+ }, /*#__PURE__*/React.createElement(LucideIcon, {
1554
+ name: opt.icon,
1555
+ className: "cds-icon"
1556
+ }), opt.value === "SOL" && (/*#__PURE__*/React.createElement(SVGIcon, {
1557
+ name: "solana",
1558
+ width: 16,
1559
+ height: 16
1560
+ })))) : (/*#__PURE__*/React.createElement("span", {
1561
+ className: "color-text-secondary"
1562
+ }, opt.value))));
1563
+ }));
1564
+ }))));
1565
+ });
1566
+ }
1249
1567
  return /*#__PURE__*/React.createElement(Tooltip, {
1250
1568
  text: tooltip,
1251
1569
  placement: "bottom"
@@ -1298,7 +1616,7 @@ var Toolbar = function Toolbar(_a) {
1298
1616
  onClose: onMoreToolbarItemsClose
1299
1617
  }, moreToolbarItems))), /*#__PURE__*/React.createElement("div", {
1300
1618
  className: "fortune-toolbar-right"
1301
- }, settings.customToolbarItems.length > 0 && (/*#__PURE__*/React.createElement(Button, {
1619
+ }, settings.customToolbarItems.length > 0 && (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
1302
1620
  iconId: "dune",
1303
1621
  tooltip: "Insert Dune Chart",
1304
1622
  key: "dune-charts",
@@ -1310,7 +1628,20 @@ var Toolbar = function Toolbar(_a) {
1310
1628
  backgroundColor: "#F4603E2E",
1311
1629
  borderRadius: "8px"
1312
1630
  }
1313
- })), settings.customToolbarItems.filter(function (n) {
1631
+ }), /*#__PURE__*/React.createElement("span", {
1632
+ style: {
1633
+ display: "inline-block",
1634
+ position: "relative"
1635
+ }
1636
+ }, /*#__PURE__*/React.createElement(CryptoDenominationSelector, null, /*#__PURE__*/React.createElement(Button, {
1637
+ iconId: "crypto",
1638
+ tooltip: "Crypto denominations",
1639
+ key: "crypto-denominations",
1640
+ style: {
1641
+ backgroundColor: "#e8ebec",
1642
+ borderRadius: "8px"
1643
+ }
1644
+ }))))), settings.customToolbarItems.filter(function (n) {
1314
1645
  return n.key !== "import-export";
1315
1646
  }).map(function (n) {
1316
1647
  return /*#__PURE__*/React.createElement(CustomButton, {
@@ -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;
@@ -1,6 +1,7 @@
1
1
  import { addSheet, api, deleteRowCol, deleteSheet, insertRowCol, opToPatch, createFilterOptions, getSheetIndex, locale, setCaretPosition, newComment } from "@fileverse-dev/fortune-core";
2
2
  import { applyPatches } from "immer";
3
3
  import _ from "lodash";
4
+ import { getCryptoPrice } from "../../utils/cryptoApi";
4
5
  export function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cellInput, scrollbarX, scrollbarY, globalCache) {
5
6
  return {
6
7
  applyOp: function applyOp(ops) {
@@ -54,6 +55,7 @@ export function generateAPIs(context, setContext, handleUndo, handleRedo, settin
54
55
  noHistory: true
55
56
  });
56
57
  },
58
+ getCryptoPrice: getCryptoPrice,
57
59
  getCellValue: function getCellValue(row, column, options) {
58
60
  if (options === void 0) {
59
61
  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
- getCellValue: (row: number, column: number, options?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions & {
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?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions & {
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?: import("@fileverse-dev/fortune-core/lib/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?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => void;
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?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => void;
27
- insertRowOrColumn: (type: "column" | "row", index: number, count: number, direction?: "lefttop" | "rightbottom", options?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => void;
28
- deleteRowOrColumn: (type: "column" | "row", start: number, end: number, options?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => void;
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?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions, custom?: boolean) => void;
32
- setColumnWidth: (columnInfo: Record<string, number>, options?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions, custom?: boolean) => void;
33
- getRowHeight: (rows: number[], options?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => Record<number, number>;
34
- getColumnWidth: (columns: number[], options?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => Record<number, number>;
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?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => (import("@fileverse-dev/fortune-core").Cell | null)[][];
49
- getHtmlByRange: (range: import("@fileverse-dev/fortune-core").Range, options?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => string | null;
50
- setSelection: (range: import("@fileverse-dev/fortune-core").Range, options?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => void;
51
- setCellValuesByRange: (data: any[][], range: import("@fileverse-dev/fortune-core").SingleRange, options?: import("@fileverse-dev/fortune-core/lib/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?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => void;
53
- mergeCells: (ranges: import("@fileverse-dev/fortune-core").Range, type: string, options?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => void;
54
- cancelMerge: (ranges: import("@fileverse-dev/fortune-core").Range, options?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => void;
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?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => {
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?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => void;
120
+ deleteSheet: (options?: api.CommonOptions) => void;
120
121
  updateSheet: (data: SheetType[]) => void;
121
- activateSheet: (options?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => void;
122
- setSheetName: (name: string, options?: import("@fileverse-dev/fortune-core/lib/api").CommonOptions) => void;
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;
@@ -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,41 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
320
320
  }, [emitOp]);
321
321
  useEffect(function () {
322
322
  var _a, _b;
323
+ (_b = (_a = mergedSettings.hooks) === null || _a === void 0 ? void 0 : _a.afterActivateSheet) === null || _b === void 0 ? void 0 : _b.call(_a, context.currentSheetId);
324
+ }, [context.currentSheetId]);
325
+ useEffect(function () {
326
+ var _a, _b;
327
+ setContext(function (ctx) {
328
+ var _a, _b;
329
+ var gridData = getFlowdata(ctx);
330
+ var cellData = api.dataToCelldata(gridData);
331
+ var denominatedUsed = false;
332
+ for (var _i = 0, cellData_1 = cellData; _i < cellData_1.length; _i++) {
333
+ var cell = cellData_1[_i];
334
+ 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();
335
+ 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"))) {
336
+ denominatedUsed = true;
337
+ break;
338
+ }
339
+ }
340
+ var denoWarn = document.getElementById("denomination-warning");
341
+ var scrollBar = document.getElementsByClassName("luckysheet-scrollbar-x")[0];
342
+ if (denominatedUsed && denoWarn) {
343
+ denoWarn.style.display = "block";
344
+ denoWarn.style.left = "0px";
345
+ if (scrollBar) {
346
+ scrollBar.style.bottom = "40px !important";
347
+ scrollBar.style.backgroundColor = "red !important";
348
+ }
349
+ } else if (!denominatedUsed && denoWarn) {
350
+ denoWarn.style.display = "none";
351
+ denoWarn.style.left = "-9999px";
352
+ if (scrollBar) {
353
+ scrollBar.style.bottom = "12px !important";
354
+ }
355
+ }
356
+ return ctx;
357
+ });
323
358
  if (context.luckysheet_select_save != null) {
324
359
  (_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
360
  }
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
- import { SERVICE_API_KEY } from "@fileverse-dev/formulajs/crypto-constants";
2
- export var API_KEY_PLACEHOLDER = Object.fromEntries(Object.values(SERVICE_API_KEY).map(function (key) {
1
+ import { SERVICES_API_KEY } from "@fileverse-dev/formulajs/crypto-constants";
2
+ export var API_KEY_PLACEHOLDER = Object.fromEntries(Object.values(SERVICES_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,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>;