@fileverse-dev/fortune-react 1.0.38 → 1.0.39

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 (55) hide show
  1. package/es/assets/paint-roller.png +0 -0
  2. package/es/components/FormatSearch/index.js +5 -9
  3. package/es/components/SVGDefines.js +1 -60
  4. package/es/components/SheetOverlay/index.css +0 -2
  5. package/es/components/SheetOverlay/index.js +2 -2
  6. package/es/components/SheetTab/index.css +0 -2
  7. package/es/components/SheetTab/index.js +2 -22
  8. package/es/components/Toolbar/Combo.js +4 -18
  9. package/es/components/Toolbar/index.css +0 -6
  10. package/es/components/Toolbar/index.d.ts +1 -1
  11. package/es/components/Toolbar/index.js +5 -334
  12. package/es/components/Workbook/index.css +4 -0
  13. package/es/components/Workbook/index.d.ts +23 -23
  14. package/es/components/Workbook/index.js +1 -25
  15. package/es/constants.d.ts +0 -26
  16. package/es/constants.js +3 -44
  17. package/lib/assets/paint-roller.png +0 -0
  18. package/lib/components/FormatSearch/index.js +5 -9
  19. package/lib/components/SVGDefines.js +1 -60
  20. package/lib/components/SheetOverlay/index.css +0 -2
  21. package/lib/components/SheetOverlay/index.js +2 -2
  22. package/lib/components/SheetTab/index.css +0 -2
  23. package/lib/components/SheetTab/index.js +2 -22
  24. package/lib/components/Toolbar/Combo.js +4 -18
  25. package/lib/components/Toolbar/index.css +0 -6
  26. package/lib/components/Toolbar/index.d.ts +1 -1
  27. package/lib/components/Toolbar/index.js +4 -333
  28. package/lib/components/Workbook/index.css +4 -0
  29. package/lib/components/Workbook/index.d.ts +23 -23
  30. package/lib/components/Workbook/index.js +0 -24
  31. package/lib/constants.d.ts +0 -26
  32. package/lib/constants.js +3 -45
  33. package/package.json +2 -2
  34. package/es/components/CryptoDenominationSelector/index.css +0 -67
  35. package/es/components/CryptoDenominationSelector/index.d.ts +0 -8
  36. package/es/components/CryptoDenominationSelector/index.js +0 -272
  37. package/es/hooks/useCryptoCells.d.ts +0 -11
  38. package/es/hooks/useCryptoCells.js +0 -210
  39. package/es/utils/convertCellsToCrypto.d.ts +0 -8
  40. package/es/utils/convertCellsToCrypto.js +0 -215
  41. package/es/utils/cryptoApi.d.ts +0 -2
  42. package/es/utils/cryptoApi.js +0 -154
  43. package/es/utils/updateCellsDecimalFormat.d.ts +0 -6
  44. package/es/utils/updateCellsDecimalFormat.js +0 -80
  45. package/lib/components/CryptoDenominationSelector/index.css +0 -67
  46. package/lib/components/CryptoDenominationSelector/index.d.ts +0 -8
  47. package/lib/components/CryptoDenominationSelector/index.js +0 -281
  48. package/lib/hooks/useCryptoCells.d.ts +0 -11
  49. package/lib/hooks/useCryptoCells.js +0 -216
  50. package/lib/utils/convertCellsToCrypto.d.ts +0 -8
  51. package/lib/utils/convertCellsToCrypto.js +0 -222
  52. package/lib/utils/cryptoApi.d.ts +0 -2
  53. package/lib/utils/cryptoApi.js +0 -161
  54. package/lib/utils/updateCellsDecimalFormat.d.ts +0 -6
  55. package/lib/utils/updateCellsDecimalFormat.js +0 -86
@@ -1,215 +0,0 @@
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
- import { getFlowdata } from "@fileverse-dev/fortune-core";
117
- import { getCryptoPrice } from "./cryptoApi";
118
- export var getFiatSymbol = function getFiatSymbol(code) {
119
- switch (code) {
120
- case "USD":
121
- return "$";
122
- case "EUR":
123
- return "€";
124
- case "GBP":
125
- return "£";
126
- case "JPY":
127
- return "¥";
128
- case "CNY":
129
- return "¥";
130
- case "INR":
131
- return "₹";
132
- default:
133
- return code;
134
- }
135
- };
136
- var COINGECKO_IDS = {
137
- BTC: "bitcoin",
138
- ETH: "ethereum",
139
- SOL: "solana"
140
- };
141
- export function convertCellsToCrypto(_a) {
142
- var context = _a.context,
143
- setContext = _a.setContext,
144
- denomination = _a.denomination,
145
- decimals = _a.decimals,
146
- baseCurrency = _a.baseCurrency;
147
- return __awaiter(this, void 0, void 0, function () {
148
- var selections, flowdata, selectedCells, denomStr, coingeckoId, price;
149
- return __generator(this, function (_b) {
150
- switch (_b.label) {
151
- case 0:
152
- selections = context.luckysheet_select_save;
153
- flowdata = getFlowdata(context);
154
- if (!selections || !flowdata) return [2];
155
- selectedCells = [];
156
- selections.forEach(function (selection) {
157
- for (var row = selection.row[0]; row <= selection.row[1]; row += 1) {
158
- for (var col = selection.column[0]; col <= selection.column[1]; col += 1) {
159
- selectedCells.push({
160
- row: row,
161
- col: col
162
- });
163
- }
164
- }
165
- });
166
- denomStr = typeof denomination === "string" && denomination.trim() !== "" ? denomination : "ETH";
167
- denomStr = denomStr.toUpperCase();
168
- coingeckoId = typeof COINGECKO_IDS[denomStr] === "string" ? COINGECKO_IDS[denomStr] : "ethereum";
169
- return [4, getCryptoPrice(String(coingeckoId), baseCurrency.toLowerCase())];
170
- case 1:
171
- price = _b.sent();
172
- selectedCells.forEach(function (_a) {
173
- var _b, _c, _d;
174
- var row = _a.row,
175
- col = _a.col;
176
- var cell = (_b = flowdata[row]) === null || _b === void 0 ? void 0 : _b[col];
177
- var baseValue = 0;
178
- if ((cell === null || cell === void 0 ? void 0 : cell.baseValue) !== undefined) {
179
- baseValue = cell.baseValue;
180
- } else {
181
- if (typeof (cell === null || cell === void 0 ? void 0 : cell.v) === "number") {
182
- baseValue = cell.v;
183
- } else if (typeof (cell === null || cell === void 0 ? void 0 : cell.v) === "string") {
184
- baseValue = parseFloat(cell.v);
185
- }
186
- if (((_c = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _c === void 0 ? void 0 : _c.fa) && cell.ct.fa.includes('"')) {
187
- var numericValue = parseFloat(((_d = cell.v) === null || _d === void 0 ? void 0 : _d.toString()) || "0");
188
- if (!Number.isNaN(numericValue)) {
189
- baseValue = numericValue;
190
- }
191
- }
192
- }
193
- if (!baseValue || Number.isNaN(baseValue)) return;
194
- var cryptoValue = baseValue / price;
195
- setContext(function (ctx) {
196
- var d = getFlowdata(ctx);
197
- if (!d || !Array.isArray(d) || !d[row] || !d[row][col] || cryptoValue === null) return;
198
- if (!d[row]) d[row] = [];
199
- if (!d[row][col]) d[row][col] = {};
200
- var cellCp = d[row][col];
201
- cellCp.v = baseValue.toString();
202
- cellCp.m = "".concat(cryptoValue.toFixed(decimals), " ").concat(denomStr);
203
- cellCp.ct = {
204
- fa: "0.".concat("0".repeat(decimals), " \"").concat(denomStr, "\""),
205
- t: "n"
206
- };
207
- cellCp.baseValue = baseValue;
208
- d[row][col] = cellCp;
209
- });
210
- });
211
- return [2];
212
- }
213
- });
214
- });
215
- }
@@ -1,2 +0,0 @@
1
- export declare function getCryptoPrice(crypto: string, fiat: string): Promise<number>;
2
- export declare function clearCryptoPriceCache(): void;
@@ -1,154 +0,0 @@
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 COINGECKO_API = "https://api.coingecko.com/api/v3/simple/price";
117
- var CACHE_DURATION = 60 * 1000;
118
- var priceCache = {};
119
- export function getCryptoPrice(crypto, fiat) {
120
- var _a;
121
- return __awaiter(this, void 0, void 0, function () {
122
- var key, now, url, resp, data, price;
123
- return __generator(this, function (_b) {
124
- switch (_b.label) {
125
- case 0:
126
- key = "".concat(crypto, "-").concat(fiat).toLowerCase();
127
- now = Date.now();
128
- if (priceCache[key] && now - priceCache[key].timestamp < CACHE_DURATION) {
129
- return [2, priceCache[key].price];
130
- }
131
- url = "".concat(COINGECKO_API, "?ids=").concat(crypto, "&vs_currencies=").concat(fiat);
132
- return [4, fetch(url)];
133
- case 1:
134
- resp = _b.sent();
135
- if (!resp.ok) throw new Error("Failed to fetch crypto price");
136
- return [4, resp.json()];
137
- case 2:
138
- data = _b.sent();
139
- price = (_a = data[crypto]) === null || _a === void 0 ? void 0 : _a[fiat];
140
- if (typeof price !== "number") throw new Error("Invalid price data");
141
- priceCache[key] = {
142
- price: price,
143
- timestamp: now
144
- };
145
- return [2, price];
146
- }
147
- });
148
- });
149
- }
150
- export function clearCryptoPriceCache() {
151
- Object.keys(priceCache).forEach(function (key) {
152
- return delete priceCache[key];
153
- });
154
- }
@@ -1,6 +0,0 @@
1
- export declare function updateCellsDecimalFormat({ context, setContext, decimals, denomination, }: {
2
- context: any;
3
- setContext: (fn: (ctx: any) => void) => void;
4
- decimals: number;
5
- denomination?: string;
6
- }): void;
@@ -1,80 +0,0 @@
1
- import { getFlowdata } from "@fileverse-dev/fortune-core";
2
- import { FIAT_ICON_MAP } from "../constants";
3
- function getFiatSymbol(code) {
4
- switch (code) {
5
- case "USD":
6
- return "$";
7
- case "EUR":
8
- return "€";
9
- case "GBP":
10
- return "£";
11
- case "JPY":
12
- return "¥";
13
- case "CNY":
14
- return "¥";
15
- case "INR":
16
- return "₹";
17
- default:
18
- return code;
19
- }
20
- }
21
- export function updateCellsDecimalFormat(_a) {
22
- var context = _a.context,
23
- setContext = _a.setContext,
24
- decimals = _a.decimals,
25
- denomination = _a.denomination;
26
- var selections = context.luckysheet_select_save;
27
- var flowdata = getFlowdata(context);
28
- if (!selections || !flowdata) return;
29
- var selectedCells = [];
30
- selections.forEach(function (selection) {
31
- for (var row = selection.row[0]; row <= selection.row[1]; row += 1) {
32
- for (var col = selection.column[0]; col <= selection.column[1]; col += 1) {
33
- selectedCells.push({
34
- row: row,
35
- col: col
36
- });
37
- }
38
- }
39
- });
40
- setContext(function (ctx) {
41
- var d = getFlowdata(ctx);
42
- if (!d) return;
43
- selectedCells.forEach(function (_a) {
44
- var _b;
45
- var row = _a.row,
46
- col = _a.col;
47
- var cell = (_b = d[row]) === null || _b === void 0 ? void 0 : _b[col];
48
- if (!cell) return;
49
- var denomStr = "ETH";
50
- var isCrypto = false;
51
- if (cell.ct && typeof cell.ct.fa === "string") {
52
- var _c = cell.ct.fa.match(/"([A-Z]+)"/) || [],
53
- matchedDenom = _c[1];
54
- if (matchedDenom) {
55
- denomStr = matchedDenom;
56
- isCrypto = true;
57
- }
58
- }
59
- if (isCrypto) {
60
- cell.ct = {
61
- fa: "0.".concat("0".repeat(decimals), " \"").concat(denomStr, "\""),
62
- t: "n"
63
- };
64
- if (typeof cell.v === "number") {
65
- cell.m = "".concat(cell.v.toFixed(decimals), " ").concat(denomStr);
66
- }
67
- } else {
68
- var fiat = denomination || "USD";
69
- var symbol = fiat in FIAT_ICON_MAP ? getFiatSymbol(fiat) : fiat;
70
- cell.ct = {
71
- fa: "".concat(symbol, " #,##0.").concat("0".repeat(decimals)),
72
- t: "n"
73
- };
74
- if (typeof cell.v === "number") {
75
- cell.m = "".concat(symbol, " ").concat(cell.v.toFixed(decimals));
76
- }
77
- }
78
- });
79
- });
80
- }
@@ -1,67 +0,0 @@
1
- .crypto-denomination-selector {
2
- min-width: 240px;
3
- font-family: inherit;
4
- color: hsl(var(--color-text-default));
5
- }
6
-
7
- .cds-row {
8
- display: flex;
9
- align-items: center;
10
- justify-content: space-between;
11
- font-size: 14px;
12
- line-height: 20px;
13
- }
14
- .cds-row input[type="number"] {
15
- width: 40px;
16
- height: 28px;
17
- text-align: center;
18
- border: 1px solid hsl(var(--color-border-default));
19
- border-radius: 6px;
20
- font-size: 14px;
21
- padding: 0 4px;
22
- margin: 0 4px;
23
- }
24
-
25
- /* Chrome, Safari, Edge, Opera */
26
- .cds-row input::-webkit-outer-spin-button,
27
- .cds-row input::-webkit-inner-spin-button {
28
- -webkit-appearance: none;
29
- margin: 0;
30
- }
31
-
32
- /* Firefox */
33
- .cds-row input[type=number] {
34
- -moz-appearance: textfield;
35
- }
36
-
37
- .cds-list {
38
- display: flex;
39
- flex-direction: column;
40
- gap: 2px;
41
- margin-top: 8px;
42
- }
43
- .cds-option {
44
- display: flex;
45
- align-items: center;
46
- gap: 10px;
47
- padding: 8px 12px;
48
- border-radius: 8px;
49
- font-size: 14px;
50
- line-height: 20px;
51
- cursor: pointer;
52
- transition: background 0.13s;
53
- position: relative;
54
- }
55
- .cds-option.selected {
56
- background: hsl(var(--color-bg-default-selected));
57
- }
58
- .cds-option:hover {
59
- background: hsl(var(--color-bg-default-hover));
60
- }
61
- .cds-icon {
62
- width: 16px;
63
- height: 16px;
64
- display: inline-block;
65
- background-size: contain;
66
- background-repeat: no-repeat;
67
- }
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- import "./index.css";
3
- interface CryptoDenominationSelectorProps {
4
- initialDecimals?: number;
5
- children: React.ReactNode;
6
- }
7
- declare const CryptoDenominationSelector: React.FC<CryptoDenominationSelectorProps>;
8
- export default CryptoDenominationSelector;