@deframe-sdk/components 0.1.64 → 0.1.65

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/dist/index.d.mts CHANGED
@@ -2306,6 +2306,12 @@ interface EarnDesktopViewSimpleProps extends Partial<EarnDesktopViewProps> {
2306
2306
  historyItems?: EarnHistoryItem[];
2307
2307
  /** Currency formatter — e.g. (1000) => "R$ 1.000,00" */
2308
2308
  formatCurrency?: (amount: number) => string;
2309
+ /**
2310
+ * User's preferred currency. Used to bypass USD→local round-trip for tokens
2311
+ * already denominated in that currency (e.g. BRLA on BRL). When omitted, all
2312
+ * amounts go through `formatCurrency` (USD-equivalent flow).
2313
+ */
2314
+ currency?: 'USD' | 'BRL';
2309
2315
  /** Locale for date formatting — e.g. "pt-BR" */
2310
2316
  locale?: string;
2311
2317
  /** Called when user clicks deposit on a strategy */
package/dist/index.d.ts CHANGED
@@ -2306,6 +2306,12 @@ interface EarnDesktopViewSimpleProps extends Partial<EarnDesktopViewProps> {
2306
2306
  historyItems?: EarnHistoryItem[];
2307
2307
  /** Currency formatter — e.g. (1000) => "R$ 1.000,00" */
2308
2308
  formatCurrency?: (amount: number) => string;
2309
+ /**
2310
+ * User's preferred currency. Used to bypass USD→local round-trip for tokens
2311
+ * already denominated in that currency (e.g. BRLA on BRL). When omitted, all
2312
+ * amounts go through `formatCurrency` (USD-equivalent flow).
2313
+ */
2314
+ currency?: 'USD' | 'BRL';
2309
2315
  /** Locale for date formatting — e.g. "pt-BR" */
2310
2316
  locale?: string;
2311
2317
  /** Called when user clicks deposit on a strategy */
package/dist/index.js CHANGED
@@ -11231,6 +11231,28 @@ var SimpleEmptyState = ({ title, description }) => {
11231
11231
  }
11232
11232
  );
11233
11233
  };
11234
+
11235
+ // src/utils/formatHistoryAssetAmount.ts
11236
+ var BRL_PEGGED_SYMBOLS = /* @__PURE__ */ new Set(["BRLA"]);
11237
+ function formatHistoryAssetAmount(input) {
11238
+ const { amountHumanized, amountInUSD, symbol, currency, locale, formatCurrency } = input;
11239
+ if (currency === "BRL" && BRL_PEGGED_SYMBOLS.has(symbol) && amountHumanized) {
11240
+ const num = parseFloat(amountHumanized);
11241
+ if (Number.isFinite(num)) {
11242
+ return `R$${num.toLocaleString(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
11243
+ }
11244
+ }
11245
+ if (amountInUSD) {
11246
+ const num = parseFloat(amountInUSD);
11247
+ if (Number.isFinite(num)) {
11248
+ return formatCurrency(num);
11249
+ }
11250
+ }
11251
+ if (amountHumanized) {
11252
+ return `${amountHumanized} ${symbol}`;
11253
+ }
11254
+ return "";
11255
+ }
11234
11256
  var EARN_CATEGORY_DEFINITIONS = [
11235
11257
  {
11236
11258
  id: "dolar",
@@ -11311,6 +11333,7 @@ var EarnDesktopViewSimple = ({
11311
11333
  strategies = [],
11312
11334
  historyItems = [],
11313
11335
  formatCurrency = defaultFormatCurrency,
11336
+ currency,
11314
11337
  locale = "pt-BR",
11315
11338
  onDeposit,
11316
11339
  onWithdraw,
@@ -11358,7 +11381,14 @@ var EarnDesktopViewSimple = ({
11358
11381
  const primaryAsset = isDeposit ? (_a = item.amounts) == null ? void 0 : _a.assetIn : (_b = item.amounts) == null ? void 0 : _b.assetOut;
11359
11382
  const symbol = (_e = primaryAsset && "token" in primaryAsset ? (_d = (_c = primaryAsset.token) == null ? void 0 : _c.symbol) == null ? void 0 : _d.toUpperCase() : null) != null ? _e : "";
11360
11383
  if (!symbol) continue;
11361
- const amount = primaryAsset && "amountInUSD" in primaryAsset && primaryAsset.amountInUSD ? formatCurrency(parseFloat(primaryAsset.amountInUSD)) : primaryAsset && "amountHumanized" in primaryAsset ? `${primaryAsset.amountHumanized} ${symbol}` : "";
11384
+ const amount = formatHistoryAssetAmount({
11385
+ amountHumanized: primaryAsset && "amountHumanized" in primaryAsset ? primaryAsset.amountHumanized : void 0,
11386
+ amountInUSD: primaryAsset && "amountInUSD" in primaryAsset ? primaryAsset.amountInUSD : void 0,
11387
+ symbol,
11388
+ currency,
11389
+ locale,
11390
+ formatCurrency
11391
+ });
11362
11392
  const date = new Date(item.createdAt).toLocaleString(locale, {
11363
11393
  day: "2-digit",
11364
11394
  month: "2-digit",
@@ -11377,7 +11407,7 @@ var EarnDesktopViewSimple = ({
11377
11407
  map.get(symbol).push(entry);
11378
11408
  }
11379
11409
  return map;
11380
- }, [historyItems, locale, formatCurrency, onHistoryDetail]);
11410
+ }, [historyItems, locale, formatCurrency, currency, onHistoryDetail]);
11381
11411
  const cardLabels = React6__namespace.default.useMemo(() => ({
11382
11412
  investLabel: labels == null ? void 0 : labels.investLabel,
11383
11413
  withdrawLabel: labels == null ? void 0 : labels.cardWithdrawLabel,