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