@deframe-sdk/components 0.1.64 → 0.1.66
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 +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +33 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2198,6 +2198,7 @@ interface EarnDesktopLabels {
|
|
|
2198
2198
|
columnApy?: string;
|
|
2199
2199
|
columnProfit?: string;
|
|
2200
2200
|
columnInvested?: string;
|
|
2201
|
+
columnTotalValue?: string;
|
|
2201
2202
|
totalInvestedLabel?: string;
|
|
2202
2203
|
totalInvestedDescription?: string;
|
|
2203
2204
|
accumulatedEarningsLabel?: string;
|
|
@@ -2306,6 +2307,12 @@ interface EarnDesktopViewSimpleProps extends Partial<EarnDesktopViewProps> {
|
|
|
2306
2307
|
historyItems?: EarnHistoryItem[];
|
|
2307
2308
|
/** Currency formatter — e.g. (1000) => "R$ 1.000,00" */
|
|
2308
2309
|
formatCurrency?: (amount: number) => string;
|
|
2310
|
+
/**
|
|
2311
|
+
* User's preferred currency. Used to bypass USD→local round-trip for tokens
|
|
2312
|
+
* already denominated in that currency (e.g. BRLA on BRL). When omitted, all
|
|
2313
|
+
* amounts go through `formatCurrency` (USD-equivalent flow).
|
|
2314
|
+
*/
|
|
2315
|
+
currency?: 'USD' | 'BRL';
|
|
2309
2316
|
/** Locale for date formatting — e.g. "pt-BR" */
|
|
2310
2317
|
locale?: string;
|
|
2311
2318
|
/** Called when user clicks deposit on a strategy */
|
package/dist/index.d.ts
CHANGED
|
@@ -2198,6 +2198,7 @@ interface EarnDesktopLabels {
|
|
|
2198
2198
|
columnApy?: string;
|
|
2199
2199
|
columnProfit?: string;
|
|
2200
2200
|
columnInvested?: string;
|
|
2201
|
+
columnTotalValue?: string;
|
|
2201
2202
|
totalInvestedLabel?: string;
|
|
2202
2203
|
totalInvestedDescription?: string;
|
|
2203
2204
|
accumulatedEarningsLabel?: string;
|
|
@@ -2306,6 +2307,12 @@ interface EarnDesktopViewSimpleProps extends Partial<EarnDesktopViewProps> {
|
|
|
2306
2307
|
historyItems?: EarnHistoryItem[];
|
|
2307
2308
|
/** Currency formatter — e.g. (1000) => "R$ 1.000,00" */
|
|
2308
2309
|
formatCurrency?: (amount: number) => string;
|
|
2310
|
+
/**
|
|
2311
|
+
* User's preferred currency. Used to bypass USD→local round-trip for tokens
|
|
2312
|
+
* already denominated in that currency (e.g. BRLA on BRL). When omitted, all
|
|
2313
|
+
* amounts go through `formatCurrency` (USD-equivalent flow).
|
|
2314
|
+
*/
|
|
2315
|
+
currency?: 'USD' | 'BRL';
|
|
2309
2316
|
/** Locale for date formatting — e.g. "pt-BR" */
|
|
2310
2317
|
locale?: string;
|
|
2311
2318
|
/** 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 =
|
|
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,
|
|
@@ -11555,7 +11585,7 @@ var EarnDesktopViewSimple = ({
|
|
|
11555
11585
|
"px-[var(--deframe-widget-size-padding-x-md)] py-[var(--deframe-widget-size-padding-y-sm)]",
|
|
11556
11586
|
"border-t border-[color:var(--deframe-widget-color-border-secondary)]"
|
|
11557
11587
|
),
|
|
11558
|
-
children: [labels == null ? void 0 : labels.columnStrategy, labels == null ? void 0 : labels.columnApy, labels == null ? void 0 : labels.columnProfit, labels == null ? void 0 : labels.
|
|
11588
|
+
children: [labels == null ? void 0 : labels.columnStrategy, labels == null ? void 0 : labels.columnApy, labels == null ? void 0 : labels.columnProfit, labels == null ? void 0 : labels.columnTotalValue].map((label, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
11559
11589
|
"span",
|
|
11560
11590
|
{
|
|
11561
11591
|
className: tailwindMerge.twMerge(
|