@fileverse-dev/fortune-react 1.0.45 → 1.0.47

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.
@@ -75,7 +75,7 @@ var SheetTab = function SheetTab() {
75
75
  }, /*#__PURE__*/React.createElement("div", {
76
76
  className: "max-w-7xl mx-auto px-4 py-1"
77
77
  }, /*#__PURE__*/React.createElement("p", {
78
- className: "text-sm text-center"
78
+ className: "text-center text-xsm"
79
79
  }, /*#__PURE__*/React.createElement("span", {
80
80
  className: "font-medium"
81
81
  }, "Disclaimer:"), " Prices aren't updated in real time, so they might be slightly different from the source when you check. Updates can be delayed by up to 20 minutes."))), /*#__PURE__*/React.createElement("div", {
@@ -1448,10 +1448,12 @@ var Toolbar = function Toolbar(_a) {
1448
1448
  key: name,
1449
1449
  tooltip: tooltip,
1450
1450
  showArrow: true
1451
- }, function () {
1451
+ }, function (setOpen) {
1452
1452
  return /*#__PURE__*/React.createElement("div", {
1453
1453
  style: {
1454
- minWidth: "20rem"
1454
+ minWidth: "20rem",
1455
+ boxShadow: "2px 2px 10px rgba(0, 0, 0, 0.2)",
1456
+ borderRadius: "8px"
1455
1457
  }
1456
1458
  }, /*#__PURE__*/React.createElement(Command, {
1457
1459
  className: "border color-border-default rounded-lg"
@@ -1534,6 +1536,7 @@ var Toolbar = function Toolbar(_a) {
1534
1536
  });
1535
1537
  _a.label = 3;
1536
1538
  case 3:
1539
+ setOpen(false);
1537
1540
  return [2];
1538
1541
  }
1539
1542
  });
@@ -145,7 +145,7 @@ export function convertCellsToCrypto(_a) {
145
145
  decimals = _a.decimals,
146
146
  baseCurrency = _a.baseCurrency;
147
147
  return __awaiter(this, void 0, void 0, function () {
148
- var selections, flowdata, selectedCells, denomStr, coingeckoId, price;
148
+ var selections, flowdata, selectedCells, denomStr, coingeckoId, price, cellUpdates;
149
149
  return __generator(this, function (_b) {
150
150
  switch (_b.label) {
151
151
  case 0:
@@ -169,6 +169,7 @@ export function convertCellsToCrypto(_a) {
169
169
  return [4, getCryptoPrice(String(coingeckoId), baseCurrency.toLowerCase())];
170
170
  case 1:
171
171
  price = _b.sent();
172
+ cellUpdates = [];
172
173
  selectedCells.forEach(function (_a) {
173
174
  var _b, _c, _d;
174
175
  var row = _a.row,
@@ -192,9 +193,21 @@ export function convertCellsToCrypto(_a) {
192
193
  }
193
194
  if (!baseValue || Number.isNaN(baseValue)) return;
194
195
  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;
196
+ cellUpdates.push({
197
+ row: row,
198
+ col: col,
199
+ baseValue: baseValue,
200
+ cryptoValue: cryptoValue
201
+ });
202
+ });
203
+ setContext(function (ctx) {
204
+ var d = getFlowdata(ctx);
205
+ if (!d || !Array.isArray(d)) return;
206
+ cellUpdates.forEach(function (_a) {
207
+ var row = _a.row,
208
+ col = _a.col,
209
+ baseValue = _a.baseValue,
210
+ cryptoValue = _a.cryptoValue;
198
211
  if (!d[row]) d[row] = [];
199
212
  if (!d[row][col]) d[row][col] = {};
200
213
  var cellCp = d[row][col];
@@ -125,7 +125,9 @@ export function getCryptoPrice(crypto, fiat) {
125
125
  case 0:
126
126
  key = "".concat(crypto, "-").concat(fiat).toLowerCase();
127
127
  now = Date.now();
128
+ console.log("Fetching crypto price for ".concat(key), priceCache);
128
129
  if (priceCache[key] && now - priceCache[key].timestamp < CACHE_DURATION) {
130
+ console.log("Using cached price for ".concat(key));
129
131
  return [2, priceCache[key].price];
130
132
  }
131
133
  url = "".concat(COINGECKO_API, "?ids=").concat(crypto, "&vs_currencies=").concat(fiat);
@@ -84,7 +84,7 @@ var SheetTab = function SheetTab() {
84
84
  }, /*#__PURE__*/_react.default.createElement("div", {
85
85
  className: "max-w-7xl mx-auto px-4 py-1"
86
86
  }, /*#__PURE__*/_react.default.createElement("p", {
87
- className: "text-sm text-center"
87
+ className: "text-center text-xsm"
88
88
  }, /*#__PURE__*/_react.default.createElement("span", {
89
89
  className: "font-medium"
90
90
  }, "Disclaimer:"), " Prices aren't updated in real time, so they might be slightly different from the source when you check. Updates can be delayed by up to 20 minutes."))), /*#__PURE__*/_react.default.createElement("div", {
@@ -1457,10 +1457,12 @@ var Toolbar = function Toolbar(_a) {
1457
1457
  key: name,
1458
1458
  tooltip: tooltip,
1459
1459
  showArrow: true
1460
- }, function () {
1460
+ }, function (setOpen) {
1461
1461
  return /*#__PURE__*/_react.default.createElement("div", {
1462
1462
  style: {
1463
- minWidth: "20rem"
1463
+ minWidth: "20rem",
1464
+ boxShadow: "2px 2px 10px rgba(0, 0, 0, 0.2)",
1465
+ borderRadius: "8px"
1464
1466
  }
1465
1467
  }, /*#__PURE__*/_react.default.createElement(_ui.Command, {
1466
1468
  className: "border color-border-default rounded-lg"
@@ -1543,6 +1545,7 @@ var Toolbar = function Toolbar(_a) {
1543
1545
  });
1544
1546
  _a.label = 3;
1545
1547
  case 3:
1548
+ setOpen(false);
1546
1549
  return [2];
1547
1550
  }
1548
1551
  });
@@ -152,7 +152,7 @@ function convertCellsToCrypto(_a) {
152
152
  decimals = _a.decimals,
153
153
  baseCurrency = _a.baseCurrency;
154
154
  return __awaiter(this, void 0, void 0, function () {
155
- var selections, flowdata, selectedCells, denomStr, coingeckoId, price;
155
+ var selections, flowdata, selectedCells, denomStr, coingeckoId, price, cellUpdates;
156
156
  return __generator(this, function (_b) {
157
157
  switch (_b.label) {
158
158
  case 0:
@@ -176,6 +176,7 @@ function convertCellsToCrypto(_a) {
176
176
  return [4, (0, _cryptoApi.getCryptoPrice)(String(coingeckoId), baseCurrency.toLowerCase())];
177
177
  case 1:
178
178
  price = _b.sent();
179
+ cellUpdates = [];
179
180
  selectedCells.forEach(function (_a) {
180
181
  var _b, _c, _d;
181
182
  var row = _a.row,
@@ -199,9 +200,21 @@ function convertCellsToCrypto(_a) {
199
200
  }
200
201
  if (!baseValue || Number.isNaN(baseValue)) return;
201
202
  var cryptoValue = baseValue / price;
202
- setContext(function (ctx) {
203
- var d = (0, _fortuneCore.getFlowdata)(ctx);
204
- if (!d || !Array.isArray(d) || !d[row] || !d[row][col] || cryptoValue === null) return;
203
+ cellUpdates.push({
204
+ row: row,
205
+ col: col,
206
+ baseValue: baseValue,
207
+ cryptoValue: cryptoValue
208
+ });
209
+ });
210
+ setContext(function (ctx) {
211
+ var d = (0, _fortuneCore.getFlowdata)(ctx);
212
+ if (!d || !Array.isArray(d)) return;
213
+ cellUpdates.forEach(function (_a) {
214
+ var row = _a.row,
215
+ col = _a.col,
216
+ baseValue = _a.baseValue,
217
+ cryptoValue = _a.cryptoValue;
205
218
  if (!d[row]) d[row] = [];
206
219
  if (!d[row][col]) d[row][col] = {};
207
220
  var cellCp = d[row][col];
@@ -132,7 +132,9 @@ function getCryptoPrice(crypto, fiat) {
132
132
  case 0:
133
133
  key = "".concat(crypto, "-").concat(fiat).toLowerCase();
134
134
  now = Date.now();
135
+ console.log("Fetching crypto price for ".concat(key), priceCache);
135
136
  if (priceCache[key] && now - priceCache[key].timestamp < CACHE_DURATION) {
137
+ console.log("Using cached price for ".concat(key));
136
138
  return [2, priceCache[key].price];
137
139
  }
138
140
  url = "".concat(COINGECKO_API, "?ids=").concat(crypto, "&vs_currencies=").concat(fiat);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.0.45",
3
+ "version": "1.0.47",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "module": "es/index.js",
@@ -16,7 +16,7 @@
16
16
  "tsc": "tsc"
17
17
  },
18
18
  "dependencies": {
19
- "@fileverse-dev/fortune-core": "1.0.45",
19
+ "@fileverse-dev/fortune-core": "1.0.47",
20
20
  "@fileverse/ui": "^4.1.7-patch-16",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",