@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.
- package/es/assets/paint-roller.png +0 -0
- package/es/components/FormatSearch/index.js +5 -9
- package/es/components/SVGDefines.js +1 -60
- package/es/components/SheetOverlay/index.css +0 -2
- package/es/components/SheetOverlay/index.js +2 -2
- package/es/components/SheetTab/index.css +0 -2
- package/es/components/SheetTab/index.js +2 -22
- package/es/components/Toolbar/Combo.js +4 -18
- package/es/components/Toolbar/index.css +0 -6
- package/es/components/Toolbar/index.d.ts +1 -1
- package/es/components/Toolbar/index.js +5 -334
- package/es/components/Workbook/index.css +4 -0
- package/es/components/Workbook/index.d.ts +23 -23
- package/es/components/Workbook/index.js +1 -25
- package/es/constants.d.ts +0 -26
- package/es/constants.js +3 -44
- package/lib/assets/paint-roller.png +0 -0
- package/lib/components/FormatSearch/index.js +5 -9
- package/lib/components/SVGDefines.js +1 -60
- package/lib/components/SheetOverlay/index.css +0 -2
- package/lib/components/SheetOverlay/index.js +2 -2
- package/lib/components/SheetTab/index.css +0 -2
- package/lib/components/SheetTab/index.js +2 -22
- package/lib/components/Toolbar/Combo.js +4 -18
- package/lib/components/Toolbar/index.css +0 -6
- package/lib/components/Toolbar/index.d.ts +1 -1
- package/lib/components/Toolbar/index.js +4 -333
- package/lib/components/Workbook/index.css +4 -0
- package/lib/components/Workbook/index.d.ts +23 -23
- package/lib/components/Workbook/index.js +0 -24
- package/lib/constants.d.ts +0 -26
- package/lib/constants.js +3 -45
- package/package.json +2 -2
- package/es/components/CryptoDenominationSelector/index.css +0 -67
- package/es/components/CryptoDenominationSelector/index.d.ts +0 -8
- package/es/components/CryptoDenominationSelector/index.js +0 -272
- package/es/hooks/useCryptoCells.d.ts +0 -11
- package/es/hooks/useCryptoCells.js +0 -210
- package/es/utils/convertCellsToCrypto.d.ts +0 -8
- package/es/utils/convertCellsToCrypto.js +0 -215
- package/es/utils/cryptoApi.d.ts +0 -2
- package/es/utils/cryptoApi.js +0 -154
- package/es/utils/updateCellsDecimalFormat.d.ts +0 -6
- package/es/utils/updateCellsDecimalFormat.js +0 -80
- package/lib/components/CryptoDenominationSelector/index.css +0 -67
- package/lib/components/CryptoDenominationSelector/index.d.ts +0 -8
- package/lib/components/CryptoDenominationSelector/index.js +0 -281
- package/lib/hooks/useCryptoCells.d.ts +0 -11
- package/lib/hooks/useCryptoCells.js +0 -216
- package/lib/utils/convertCellsToCrypto.d.ts +0 -8
- package/lib/utils/convertCellsToCrypto.js +0 -222
- package/lib/utils/cryptoApi.d.ts +0 -2
- package/lib/utils/cryptoApi.js +0 -161
- package/lib/utils/updateCellsDecimalFormat.d.ts +0 -6
- package/lib/utils/updateCellsDecimalFormat.js +0 -86
|
@@ -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;
|
|
@@ -1,272 +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 React, { useState, useContext, useCallback, useMemo } from "react";
|
|
117
|
-
import { getFlowdata, normalizedCellAttr } from "@fileverse-dev/fortune-core";
|
|
118
|
-
import { IconButton, LucideIcon, Popover, PopoverContent, PopoverTrigger } from "@fileverse/ui";
|
|
119
|
-
import "./index.css";
|
|
120
|
-
import SVGIcon from "../SVGIcon";
|
|
121
|
-
import WorkbookContext from "../../context";
|
|
122
|
-
import { convertCellsToCrypto } from "../../utils/convertCellsToCrypto";
|
|
123
|
-
import { updateCellsDecimalFormat } from "../../utils/updateCellsDecimalFormat";
|
|
124
|
-
var CRYPTO_OPTIONS = [{
|
|
125
|
-
label: "Bitcoin (BTC)",
|
|
126
|
-
value: "BTC",
|
|
127
|
-
icon: "Btc"
|
|
128
|
-
}, {
|
|
129
|
-
label: "Ethereum (ETH)",
|
|
130
|
-
value: "ETH",
|
|
131
|
-
icon: "Ethereum"
|
|
132
|
-
}, {
|
|
133
|
-
label: "Solana (SOL)",
|
|
134
|
-
value: "SOL",
|
|
135
|
-
icon: "Solana"
|
|
136
|
-
}];
|
|
137
|
-
var CryptoDenominationSelector = function CryptoDenominationSelector(_a) {
|
|
138
|
-
var _b = _a.initialDecimals,
|
|
139
|
-
initialDecimals = _b === void 0 ? 6 : _b,
|
|
140
|
-
children = _a.children;
|
|
141
|
-
var _c = useContext(WorkbookContext),
|
|
142
|
-
setContext = _c.setContext,
|
|
143
|
-
context = _c.context;
|
|
144
|
-
var activeCryptoCurrency = useMemo(function () {
|
|
145
|
-
var _a, _b;
|
|
146
|
-
var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
|
|
147
|
-
var flowdata = getFlowdata(context);
|
|
148
|
-
if (!firstSelection || !flowdata) return null;
|
|
149
|
-
var row = firstSelection.row_focus;
|
|
150
|
-
var col = firstSelection.column_focus;
|
|
151
|
-
if (row == null || col == null) return null;
|
|
152
|
-
var cell = (_b = flowdata[row]) === null || _b === void 0 ? void 0 : _b[col];
|
|
153
|
-
if (!cell) return null;
|
|
154
|
-
var curr = normalizedCellAttr(cell, "ct");
|
|
155
|
-
if (!(curr === null || curr === void 0 ? void 0 : curr.fa)) return null;
|
|
156
|
-
var found = CRYPTO_OPTIONS.find(function (option) {
|
|
157
|
-
return curr.fa.includes(option.value);
|
|
158
|
-
});
|
|
159
|
-
return found ? found.value : null;
|
|
160
|
-
}, [context]);
|
|
161
|
-
var _d = useState(initialDecimals),
|
|
162
|
-
decimals = _d[0],
|
|
163
|
-
setDecimals = _d[1];
|
|
164
|
-
var _e = useState(false),
|
|
165
|
-
open = _e[0],
|
|
166
|
-
setOpen = _e[1];
|
|
167
|
-
var handleDenominationChange = useCallback(function (newDenomination) {
|
|
168
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
169
|
-
return __generator(this, function (_a) {
|
|
170
|
-
switch (_a.label) {
|
|
171
|
-
case 0:
|
|
172
|
-
return [4, convertCellsToCrypto({
|
|
173
|
-
context: context,
|
|
174
|
-
setContext: setContext,
|
|
175
|
-
denomination: newDenomination,
|
|
176
|
-
decimals: decimals,
|
|
177
|
-
baseCurrency: "USD"
|
|
178
|
-
})];
|
|
179
|
-
case 1:
|
|
180
|
-
_a.sent();
|
|
181
|
-
return [2];
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
}, [context, setContext, decimals]);
|
|
186
|
-
var handleDecimalsChange = useCallback(function (newDecimals) {
|
|
187
|
-
setDecimals(newDecimals);
|
|
188
|
-
updateCellsDecimalFormat({
|
|
189
|
-
context: context,
|
|
190
|
-
setContext: setContext,
|
|
191
|
-
decimals: newDecimals
|
|
192
|
-
});
|
|
193
|
-
}, [context, setContext]);
|
|
194
|
-
var handleTriggerClick = useCallback(function (e) {
|
|
195
|
-
e.preventDefault();
|
|
196
|
-
e.stopPropagation();
|
|
197
|
-
if (context.allowEdit === false) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
setOpen(!open);
|
|
201
|
-
}, [open, context.allowEdit]);
|
|
202
|
-
return /*#__PURE__*/React.createElement(Popover, {
|
|
203
|
-
open: open,
|
|
204
|
-
onOpenChange: setOpen
|
|
205
|
-
}, /*#__PURE__*/React.createElement(PopoverTrigger, {
|
|
206
|
-
asChild: true
|
|
207
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
208
|
-
onClick: handleTriggerClick
|
|
209
|
-
}, children)), /*#__PURE__*/React.createElement(PopoverContent, {
|
|
210
|
-
align: "end",
|
|
211
|
-
side: "bottom",
|
|
212
|
-
sideOffset: 4,
|
|
213
|
-
className: "p-2"
|
|
214
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
215
|
-
className: "crypto-denomination-selector"
|
|
216
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
217
|
-
className: "cds-row px-2"
|
|
218
|
-
}, /*#__PURE__*/React.createElement("span", null, "Decimal places:"), /*#__PURE__*/React.createElement("span", {
|
|
219
|
-
className: "flex items-center"
|
|
220
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
221
|
-
icon: "Minus",
|
|
222
|
-
variant: "ghost",
|
|
223
|
-
size: "sm",
|
|
224
|
-
className: "!bg-transparent",
|
|
225
|
-
disabled: decimals === 1,
|
|
226
|
-
onClick: function onClick() {
|
|
227
|
-
return handleDecimalsChange(Math.max(1, decimals - 1));
|
|
228
|
-
}
|
|
229
|
-
}), /*#__PURE__*/React.createElement("input", {
|
|
230
|
-
type: "number",
|
|
231
|
-
min: 1,
|
|
232
|
-
max: 18,
|
|
233
|
-
value: decimals,
|
|
234
|
-
onChange: function onChange(e) {
|
|
235
|
-
return handleDecimalsChange(Math.max(1, Math.min(18, Number(e.target.value))));
|
|
236
|
-
}
|
|
237
|
-
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
238
|
-
icon: "Plus",
|
|
239
|
-
variant: "ghost",
|
|
240
|
-
size: "sm",
|
|
241
|
-
className: "!bg-transparent",
|
|
242
|
-
disabled: decimals === 18,
|
|
243
|
-
onClick: function onClick() {
|
|
244
|
-
return handleDecimalsChange(Math.min(18, decimals + 1));
|
|
245
|
-
}
|
|
246
|
-
}))), /*#__PURE__*/React.createElement("div", {
|
|
247
|
-
className: "cds-list"
|
|
248
|
-
}, CRYPTO_OPTIONS.map(function (opt) {
|
|
249
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
250
|
-
key: opt.value,
|
|
251
|
-
className: "flex items-center justify-between cds-option".concat(activeCryptoCurrency === opt.value ? " selected" : ""),
|
|
252
|
-
onClick: function onClick() {
|
|
253
|
-
return handleDenominationChange(opt.value);
|
|
254
|
-
}
|
|
255
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
256
|
-
className: "flex items-center gap-2"
|
|
257
|
-
}, activeCryptoCurrency === opt.value ? (/*#__PURE__*/React.createElement(LucideIcon, {
|
|
258
|
-
name: "Check",
|
|
259
|
-
className: "w-4 h-4"
|
|
260
|
-
})) : (/*#__PURE__*/React.createElement("div", {
|
|
261
|
-
className: "w-4 h-4"
|
|
262
|
-
})), opt.label), /*#__PURE__*/React.createElement(LucideIcon, {
|
|
263
|
-
name: opt.icon,
|
|
264
|
-
className: "cds-icon"
|
|
265
|
-
}), opt.value === "SOL" && (/*#__PURE__*/React.createElement(SVGIcon, {
|
|
266
|
-
name: "solana",
|
|
267
|
-
width: 16,
|
|
268
|
-
height: 16
|
|
269
|
-
})));
|
|
270
|
-
})))));
|
|
271
|
-
};
|
|
272
|
-
export default CryptoDenominationSelector;
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
var __assign = this && this.__assign || function () {
|
|
2
|
-
__assign = Object.assign || function (t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
6
|
-
}
|
|
7
|
-
return t;
|
|
8
|
-
};
|
|
9
|
-
return __assign.apply(this, arguments);
|
|
10
|
-
};
|
|
11
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
12
|
-
function adopt(value) {
|
|
13
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
14
|
-
resolve(value);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
-
function fulfilled(value) {
|
|
19
|
-
try {
|
|
20
|
-
step(generator.next(value));
|
|
21
|
-
} catch (e) {
|
|
22
|
-
reject(e);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function rejected(value) {
|
|
26
|
-
try {
|
|
27
|
-
step(generator["throw"](value));
|
|
28
|
-
} catch (e) {
|
|
29
|
-
reject(e);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function step(result) {
|
|
33
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
34
|
-
}
|
|
35
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
var __generator = this && this.__generator || function (thisArg, body) {
|
|
39
|
-
var _ = {
|
|
40
|
-
label: 0,
|
|
41
|
-
sent: function sent() {
|
|
42
|
-
if (t[0] & 1) throw t[1];
|
|
43
|
-
return t[1];
|
|
44
|
-
},
|
|
45
|
-
trys: [],
|
|
46
|
-
ops: []
|
|
47
|
-
},
|
|
48
|
-
f,
|
|
49
|
-
y,
|
|
50
|
-
t,
|
|
51
|
-
g;
|
|
52
|
-
return g = {
|
|
53
|
-
next: verb(0),
|
|
54
|
-
"throw": verb(1),
|
|
55
|
-
"return": verb(2)
|
|
56
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
57
|
-
return this;
|
|
58
|
-
}), g;
|
|
59
|
-
function verb(n) {
|
|
60
|
-
return function (v) {
|
|
61
|
-
return step([n, v]);
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function step(op) {
|
|
65
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
66
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
67
|
-
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;
|
|
68
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
69
|
-
switch (op[0]) {
|
|
70
|
-
case 0:
|
|
71
|
-
case 1:
|
|
72
|
-
t = op;
|
|
73
|
-
break;
|
|
74
|
-
case 4:
|
|
75
|
-
_.label++;
|
|
76
|
-
return {
|
|
77
|
-
value: op[1],
|
|
78
|
-
done: false
|
|
79
|
-
};
|
|
80
|
-
case 5:
|
|
81
|
-
_.label++;
|
|
82
|
-
y = op[1];
|
|
83
|
-
op = [0];
|
|
84
|
-
continue;
|
|
85
|
-
case 7:
|
|
86
|
-
op = _.ops.pop();
|
|
87
|
-
_.trys.pop();
|
|
88
|
-
continue;
|
|
89
|
-
default:
|
|
90
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
91
|
-
_ = 0;
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
95
|
-
_.label = op[1];
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
99
|
-
_.label = t[1];
|
|
100
|
-
t = op;
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
if (t && _.label < t[2]) {
|
|
104
|
-
_.label = t[2];
|
|
105
|
-
_.ops.push(op);
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
if (t[2]) _.ops.pop();
|
|
109
|
-
_.trys.pop();
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
op = body.call(thisArg, _);
|
|
113
|
-
} catch (e) {
|
|
114
|
-
op = [6, e];
|
|
115
|
-
y = 0;
|
|
116
|
-
} finally {
|
|
117
|
-
f = t = 0;
|
|
118
|
-
}
|
|
119
|
-
if (op[0] & 5) throw op[1];
|
|
120
|
-
return {
|
|
121
|
-
value: op[0] ? op[1] : void 0,
|
|
122
|
-
done: true
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
127
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
128
|
-
if (ar || !(i in from)) {
|
|
129
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
130
|
-
ar[i] = from[i];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
134
|
-
};
|
|
135
|
-
import { useEffect, useRef, useState } from "react";
|
|
136
|
-
import { getCryptoPrice } from "../utils/cryptoApi";
|
|
137
|
-
export function useCryptoCells() {
|
|
138
|
-
var _this = this;
|
|
139
|
-
var _a = useState([]),
|
|
140
|
-
cryptoCells = _a[0],
|
|
141
|
-
setCryptoCells = _a[1];
|
|
142
|
-
var timerRef = useRef(null);
|
|
143
|
-
var upsertCryptoCell = function upsertCryptoCell(cellId, baseValue, cryptoType, fiat) {
|
|
144
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
145
|
-
var price;
|
|
146
|
-
return __generator(this, function (_a) {
|
|
147
|
-
switch (_a.label) {
|
|
148
|
-
case 0:
|
|
149
|
-
return [4, getCryptoPrice(cryptoType, fiat)];
|
|
150
|
-
case 1:
|
|
151
|
-
price = _a.sent();
|
|
152
|
-
setCryptoCells(function (prev) {
|
|
153
|
-
var idx = prev.findIndex(function (c) {
|
|
154
|
-
return c.cellId === cellId;
|
|
155
|
-
});
|
|
156
|
-
var newCell = {
|
|
157
|
-
cellId: cellId,
|
|
158
|
-
baseValue: baseValue,
|
|
159
|
-
cryptoType: cryptoType,
|
|
160
|
-
fiat: fiat,
|
|
161
|
-
value: baseValue / price
|
|
162
|
-
};
|
|
163
|
-
if (idx === -1) return __spreadArray(__spreadArray([], prev, true), [newCell], false);
|
|
164
|
-
var updated = __spreadArray([], prev, true);
|
|
165
|
-
updated[idx] = newCell;
|
|
166
|
-
return updated;
|
|
167
|
-
});
|
|
168
|
-
return [2];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
useEffect(function () {
|
|
174
|
-
function refreshAll() {
|
|
175
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
-
var _this = this;
|
|
177
|
-
return __generator(this, function (_a) {
|
|
178
|
-
setCryptoCells(function (prev) {
|
|
179
|
-
var updatePromises = prev.map(function (cell) {
|
|
180
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
181
|
-
var price;
|
|
182
|
-
return __generator(this, function (_a) {
|
|
183
|
-
switch (_a.label) {
|
|
184
|
-
case 0:
|
|
185
|
-
return [4, getCryptoPrice(cell.cryptoType, cell.fiat)];
|
|
186
|
-
case 1:
|
|
187
|
-
price = _a.sent();
|
|
188
|
-
return [2, __assign(__assign({}, cell), {
|
|
189
|
-
value: cell.baseValue / price
|
|
190
|
-
})];
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
return Promise.all(updatePromises);
|
|
196
|
-
});
|
|
197
|
-
return [2];
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
timerRef.current = setInterval(refreshAll, 20 * 60 * 1000);
|
|
202
|
-
return function () {
|
|
203
|
-
if (timerRef.current) clearInterval(timerRef.current);
|
|
204
|
-
};
|
|
205
|
-
}, []);
|
|
206
|
-
return {
|
|
207
|
-
cryptoCells: cryptoCells,
|
|
208
|
-
upsertCryptoCell: upsertCryptoCell
|
|
209
|
-
};
|
|
210
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
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>;
|