@deframe-sdk/components 0.1.52 → 0.1.54
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 +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +80 -123
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -123
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +20 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1691,7 +1691,7 @@ var BannerNotification = (_a) => {
|
|
|
1691
1691
|
error: "text-[var(--deframe-widget-color-state-error)]",
|
|
1692
1692
|
success: "text-[var(--deframe-widget-color-state-success)]"
|
|
1693
1693
|
};
|
|
1694
|
-
const
|
|
1694
|
+
const variantIcons2 = {
|
|
1695
1695
|
info: MdInfoOutline,
|
|
1696
1696
|
warning: MdWarningAmber,
|
|
1697
1697
|
error: MdErrorOutline,
|
|
@@ -1763,7 +1763,7 @@ var BannerNotification = (_a) => {
|
|
|
1763
1763
|
isExiting && "opacity-0 -translate-y-2",
|
|
1764
1764
|
className
|
|
1765
1765
|
);
|
|
1766
|
-
const IconComponent =
|
|
1766
|
+
const IconComponent = variantIcons2[v];
|
|
1767
1767
|
const resolvedIcon = icon != null ? icon : /* @__PURE__ */ jsx(IconComponent, {});
|
|
1768
1768
|
return /* @__PURE__ */ jsxs(
|
|
1769
1769
|
"div",
|
|
@@ -6037,41 +6037,10 @@ var SwapToCardView = ({
|
|
|
6037
6037
|
] })
|
|
6038
6038
|
] }) });
|
|
6039
6039
|
};
|
|
6040
|
-
var SLIPPAGE_OPTIONS = [10, 50, 100];
|
|
6041
|
-
var SwapSlippageToleranceButtonsView = ({
|
|
6042
|
-
slippageBps,
|
|
6043
|
-
onSelect,
|
|
6044
|
-
formatPercentage,
|
|
6045
|
-
className
|
|
6046
|
-
}) => {
|
|
6047
|
-
const baseClasses = "flex gap-[var(--deframe-widget-size-gap-xs)]";
|
|
6048
|
-
return /* @__PURE__ */ jsx("div", { "data-test-id": "swap-slippage-tolerance-buttons", className: twMerge(baseClasses, className), children: SLIPPAGE_OPTIONS.map((option) => {
|
|
6049
|
-
const isActive = slippageBps === option;
|
|
6050
|
-
const activeClasses = "border-[color:var(--deframe-widget-color-brand-primary)] text-[color:var(--deframe-widget-color-brand-primary)] bg-[color:color-mix(in_srgb,var(--deframe-widget-color-brand-primary)_18%,transparent)]";
|
|
6051
|
-
const inactiveClasses = "border-[color:var(--deframe-widget-color-border-tertiary)] text-[color:var(--deframe-widget-color-text-secondary)] bg-[var(--deframe-widget-color-bg-primary)]";
|
|
6052
|
-
const buttonBase = "px-[var(--deframe-widget-size-padding-x-sm)] py-[var(--deframe-widget-size-padding-y-xs)] rounded-[var(--deframe-widget-size-radius-xs)] border [font-size:var(--deframe-widget-font-size-sm)] [line-height:var(--deframe-widget-font-leading-sm)] cursor-pointer";
|
|
6053
|
-
return /* @__PURE__ */ jsx(
|
|
6054
|
-
"button",
|
|
6055
|
-
{
|
|
6056
|
-
"data-test-id": `slippage-option-${option}`,
|
|
6057
|
-
type: "button",
|
|
6058
|
-
onClick: () => onSelect(option),
|
|
6059
|
-
className: twMerge(buttonBase, isActive ? activeClasses : inactiveClasses),
|
|
6060
|
-
"aria-label": `${formatPercentage(option)}% slippage`,
|
|
6061
|
-
"aria-pressed": isActive,
|
|
6062
|
-
children: formatPercentage(option)
|
|
6063
|
-
},
|
|
6064
|
-
option
|
|
6065
|
-
);
|
|
6066
|
-
}) });
|
|
6067
|
-
};
|
|
6068
6040
|
var SwapAdvancedSettingsView = ({
|
|
6069
6041
|
title,
|
|
6070
6042
|
isOpen,
|
|
6071
6043
|
onOpenChange,
|
|
6072
|
-
slippageBps,
|
|
6073
|
-
onSlippageSelect,
|
|
6074
|
-
formatPercentage,
|
|
6075
6044
|
percentageOptions,
|
|
6076
6045
|
onPercentageClick,
|
|
6077
6046
|
slippageFormatted,
|
|
@@ -6079,7 +6048,7 @@ var SwapAdvancedSettingsView = ({
|
|
|
6079
6048
|
expandText,
|
|
6080
6049
|
maxLabel
|
|
6081
6050
|
}) => {
|
|
6082
|
-
return /* @__PURE__ */ jsx("div", { className: "pb-2 mt-md", children: /* @__PURE__ */ jsx(SectionCard, { children: /* @__PURE__ */
|
|
6051
|
+
return /* @__PURE__ */ jsx("div", { className: "pb-2 mt-md", children: /* @__PURE__ */ jsx(SectionCard, { children: /* @__PURE__ */ jsx(
|
|
6083
6052
|
CollapsibleSection,
|
|
6084
6053
|
{
|
|
6085
6054
|
title,
|
|
@@ -6088,30 +6057,19 @@ var SwapAdvancedSettingsView = ({
|
|
|
6088
6057
|
onOpenChange,
|
|
6089
6058
|
collapseText,
|
|
6090
6059
|
expandText,
|
|
6091
|
-
children:
|
|
6092
|
-
|
|
6093
|
-
|
|
6060
|
+
children: /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsx("div", { className: "flex w-full gap-sm", children: percentageOptions.map((pct, index) => {
|
|
6061
|
+
const isMax = index === percentageOptions.length - 1;
|
|
6062
|
+
const label = isMax ? maxLabel : `${pct / 100}%`;
|
|
6063
|
+
return /* @__PURE__ */ jsx(
|
|
6064
|
+
PercentageButton,
|
|
6094
6065
|
{
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
)
|
|
6101
|
-
|
|
6102
|
-
const isMax = index === percentageOptions.length - 1;
|
|
6103
|
-
const label = isMax ? maxLabel : `${pct / 100}%`;
|
|
6104
|
-
return /* @__PURE__ */ jsx(
|
|
6105
|
-
PercentageButton,
|
|
6106
|
-
{
|
|
6107
|
-
type: "button",
|
|
6108
|
-
onClick: () => onPercentageClick(pct),
|
|
6109
|
-
children: label
|
|
6110
|
-
},
|
|
6111
|
-
pct
|
|
6112
|
-
);
|
|
6113
|
-
}) }) })
|
|
6114
|
-
]
|
|
6066
|
+
type: "button",
|
|
6067
|
+
onClick: () => onPercentageClick(pct),
|
|
6068
|
+
children: label
|
|
6069
|
+
},
|
|
6070
|
+
pct
|
|
6071
|
+
);
|
|
6072
|
+
}) }) })
|
|
6115
6073
|
}
|
|
6116
6074
|
) }) });
|
|
6117
6075
|
};
|
|
@@ -6287,6 +6245,39 @@ var ConfirmSwapButtonView = ({
|
|
|
6287
6245
|
}
|
|
6288
6246
|
) });
|
|
6289
6247
|
};
|
|
6248
|
+
var variantClasses2 = {
|
|
6249
|
+
error: "border-[color:color-mix(in_srgb,var(--deframe-widget-color-state-error)_42%,transparent)] bg-[color:color-mix(in_srgb,var(--deframe-widget-color-state-error)_16%,transparent)] text-[color:var(--deframe-widget-color-state-error)]",
|
|
6250
|
+
warning: "border-[color:color-mix(in_srgb,var(--deframe-widget-color-state-warning)_42%,transparent)] bg-[color:color-mix(in_srgb,var(--deframe-widget-color-state-warning)_16%,transparent)] text-[color:var(--deframe-widget-color-state-warning)]"
|
|
6251
|
+
};
|
|
6252
|
+
var variantIcons = {
|
|
6253
|
+
error: MdErrorOutline,
|
|
6254
|
+
warning: MdWarningAmber
|
|
6255
|
+
};
|
|
6256
|
+
function SwapPriceImpactWarning({ warning, className }) {
|
|
6257
|
+
const Icon = variantIcons[warning.variant];
|
|
6258
|
+
return /* @__PURE__ */ jsxs(
|
|
6259
|
+
"div",
|
|
6260
|
+
{
|
|
6261
|
+
"data-test-id": "swap-price-impact-warning",
|
|
6262
|
+
role: "alert",
|
|
6263
|
+
className: twMerge(
|
|
6264
|
+
"flex items-start gap-[var(--deframe-widget-size-gap-sm)]",
|
|
6265
|
+
"rounded-[var(--deframe-widget-size-radius-sm)] border",
|
|
6266
|
+
"px-[var(--deframe-widget-size-padding-x-md)] py-[var(--deframe-widget-size-padding-y-sm)]",
|
|
6267
|
+
"font-[var(--deframe-widget-font-family)]",
|
|
6268
|
+
variantClasses2[warning.variant],
|
|
6269
|
+
className
|
|
6270
|
+
),
|
|
6271
|
+
children: [
|
|
6272
|
+
/* @__PURE__ */ jsx(Icon, { className: "mt-[2px] h-5 w-5 flex-shrink-0" }),
|
|
6273
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-[2px]", children: [
|
|
6274
|
+
/* @__PURE__ */ jsx("span", { className: "text-[13px] [font-weight:var(--deframe-widget-font-weight-semibold)] leading-[1.35] text-[color:var(--deframe-widget-color-text-primary)]", children: warning.title }),
|
|
6275
|
+
/* @__PURE__ */ jsx("span", { className: "text-[12px] leading-[1.45] text-[color:var(--deframe-widget-color-text-secondary)]", children: warning.message })
|
|
6276
|
+
] })
|
|
6277
|
+
]
|
|
6278
|
+
}
|
|
6279
|
+
);
|
|
6280
|
+
}
|
|
6290
6281
|
var SwapFormView = ({
|
|
6291
6282
|
onSubmit,
|
|
6292
6283
|
formRef,
|
|
@@ -6298,6 +6289,7 @@ var SwapFormView = ({
|
|
|
6298
6289
|
toCard,
|
|
6299
6290
|
advancedSettings,
|
|
6300
6291
|
transactionDetails,
|
|
6292
|
+
priceImpactWarning,
|
|
6301
6293
|
confirmButton
|
|
6302
6294
|
}) => {
|
|
6303
6295
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -6344,12 +6336,15 @@ var SwapFormView = ({
|
|
|
6344
6336
|
] }) })
|
|
6345
6337
|
}
|
|
6346
6338
|
),
|
|
6347
|
-
/* @__PURE__ */
|
|
6339
|
+
/* @__PURE__ */ jsxs(
|
|
6348
6340
|
"div",
|
|
6349
6341
|
{
|
|
6350
6342
|
"data-testid": "swap-flow-footer",
|
|
6351
6343
|
className: "border-t p-md border-[color:var(--deframe-widget-color-border-secondary)] dark:border-[color:var(--deframe-widget-color-border-secondary-dark)] bg-[var(--deframe-widget-color-bg-primary)] dark:bg-[var(--deframe-widget-color-bg-primary-dark)]",
|
|
6352
|
-
children:
|
|
6344
|
+
children: [
|
|
6345
|
+
priceImpactWarning && /* @__PURE__ */ jsx(SwapPriceImpactWarning, { warning: priceImpactWarning, className: "mb-sm" }),
|
|
6346
|
+
/* @__PURE__ */ jsx(ConfirmSwapButtonView, __spreadValues({}, confirmButton))
|
|
6347
|
+
]
|
|
6353
6348
|
}
|
|
6354
6349
|
)
|
|
6355
6350
|
] });
|
|
@@ -7250,6 +7245,7 @@ var SwapFormViewSimple = ({
|
|
|
7250
7245
|
toCard,
|
|
7251
7246
|
advancedSettings,
|
|
7252
7247
|
transactionDetails,
|
|
7248
|
+
priceImpactWarning,
|
|
7253
7249
|
confirmButton
|
|
7254
7250
|
}) => {
|
|
7255
7251
|
const containerRef = useRef(null);
|
|
@@ -7359,7 +7355,16 @@ var SwapFormViewSimple = ({
|
|
|
7359
7355
|
)
|
|
7360
7356
|
] }),
|
|
7361
7357
|
/* @__PURE__ */ jsx("div", { className: "flex-1" }),
|
|
7362
|
-
/* @__PURE__ */
|
|
7358
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-[var(--deframe-widget-size-gap-sm)]", children: [
|
|
7359
|
+
priceImpactWarning && /* @__PURE__ */ jsx(
|
|
7360
|
+
SwapPriceImpactWarning,
|
|
7361
|
+
{
|
|
7362
|
+
warning: priceImpactWarning,
|
|
7363
|
+
className: "mb-[var(--deframe-widget-size-gap-sm)]"
|
|
7364
|
+
}
|
|
7365
|
+
),
|
|
7366
|
+
/* @__PURE__ */ jsx(ConfirmSwapButtonViewSimple, __spreadValues({}, confirmButton))
|
|
7367
|
+
] })
|
|
7363
7368
|
] }),
|
|
7364
7369
|
showPanel && panelPos && /* @__PURE__ */ jsx(
|
|
7365
7370
|
"div",
|
|
@@ -7608,55 +7613,7 @@ function AdvancedPanelContent({ advancedSettings, transactionDetails }) {
|
|
|
7608
7613
|
/* @__PURE__ */ jsx(DetailRow, { label: transactionDetails.labels.protocolFeeLabel, value: transactionDetails.protocolFee }),
|
|
7609
7614
|
/* @__PURE__ */ jsx(DetailRow, { label: transactionDetails.labels.slippageLabel, value: transactionDetails.slippageFormatted }),
|
|
7610
7615
|
/* @__PURE__ */ jsx(DetailRow, { label: transactionDetails.labels.etaLabel, value: transactionDetails.etaFormatted }),
|
|
7611
|
-
transactionDetails.quoteId && /* @__PURE__ */ jsx(DetailRow, { label: transactionDetails.labels.quoteIdLabel, value: transactionDetails.quoteId })
|
|
7612
|
-
/* @__PURE__ */ jsx(
|
|
7613
|
-
"div",
|
|
7614
|
-
{
|
|
7615
|
-
"data-test-id": "swap-form-simple-advanced-panel-divider-2",
|
|
7616
|
-
className: "h-px bg-[var(--deframe-widget-color-border-secondary)] my-[var(--deframe-widget-size-gap-sm)]"
|
|
7617
|
-
}
|
|
7618
|
-
),
|
|
7619
|
-
/* @__PURE__ */ jsxs("div", { "data-test-id": "swap-form-simple-advanced-panel-slippage", children: [
|
|
7620
|
-
/* @__PURE__ */ jsxs(
|
|
7621
|
-
"span",
|
|
7622
|
-
{
|
|
7623
|
-
"data-test-id": "swap-form-simple-advanced-panel-slippage-label",
|
|
7624
|
-
className: "text-[11px] [font-weight:var(--deframe-widget-font-weight-medium)] uppercase tracking-[0.07em] text-[color:var(--deframe-widget-color-text-tertiary)] font-[var(--deframe-widget-font-family)]",
|
|
7625
|
-
children: [
|
|
7626
|
-
"Slippage: ",
|
|
7627
|
-
advancedSettings.slippageFormatted
|
|
7628
|
-
]
|
|
7629
|
-
}
|
|
7630
|
-
),
|
|
7631
|
-
/* @__PURE__ */ jsx(
|
|
7632
|
-
"div",
|
|
7633
|
-
{
|
|
7634
|
-
"data-test-id": "swap-form-simple-advanced-panel-slippage-buttons",
|
|
7635
|
-
className: "flex gap-[6px] mt-[var(--deframe-widget-size-gap-sm)]",
|
|
7636
|
-
children: [10, 50, 100].map((bps) => {
|
|
7637
|
-
const isActive = advancedSettings.slippageBps === bps;
|
|
7638
|
-
return /* @__PURE__ */ jsx(
|
|
7639
|
-
"button",
|
|
7640
|
-
{
|
|
7641
|
-
"data-test-id": "swap-form-simple-slippage-btn",
|
|
7642
|
-
type: "button",
|
|
7643
|
-
onClick: () => advancedSettings.onSlippageSelect(bps),
|
|
7644
|
-
className: twMerge(
|
|
7645
|
-
"py-[3px] px-[10px]",
|
|
7646
|
-
"rounded-[var(--deframe-widget-size-radius-full)]",
|
|
7647
|
-
"text-[12px] font-[var(--deframe-widget-font-family)]",
|
|
7648
|
-
"border cursor-pointer outline-none",
|
|
7649
|
-
"transition-all duration-150",
|
|
7650
|
-
isActive ? "border-[color:color-mix(in_srgb,var(--deframe-widget-color-brand-primary)_32%,transparent)] bg-[color:color-mix(in_srgb,var(--deframe-widget-color-brand-primary)_12%,transparent)] text-[color:var(--deframe-widget-color-brand-primary)] [font-weight:var(--deframe-widget-font-weight-semibold)]" : "border-[color:var(--deframe-widget-color-border-secondary)] bg-transparent text-[color:var(--deframe-widget-color-text-secondary)] hover:border-[color:var(--deframe-widget-color-border-primary)]"
|
|
7651
|
-
),
|
|
7652
|
-
children: advancedSettings.formatPercentage(bps)
|
|
7653
|
-
},
|
|
7654
|
-
bps
|
|
7655
|
-
);
|
|
7656
|
-
})
|
|
7657
|
-
}
|
|
7658
|
-
)
|
|
7659
|
-
] })
|
|
7616
|
+
transactionDetails.quoteId && /* @__PURE__ */ jsx(DetailRow, { label: transactionDetails.labels.quoteIdLabel, value: transactionDetails.quoteId })
|
|
7660
7617
|
]
|
|
7661
7618
|
}
|
|
7662
7619
|
);
|
|
@@ -8768,11 +8725,16 @@ function historyResolveLabel(item, labels) {
|
|
|
8768
8725
|
};
|
|
8769
8726
|
return labelMap[item.type]();
|
|
8770
8727
|
}
|
|
8771
|
-
function
|
|
8728
|
+
function resolveDisplayAsset(item) {
|
|
8772
8729
|
var _a, _b;
|
|
8773
|
-
const
|
|
8774
|
-
const
|
|
8775
|
-
|
|
8730
|
+
const assetIn = (_a = item.amounts) == null ? void 0 : _a.assetIn;
|
|
8731
|
+
const assetOut = (_b = item.amounts) == null ? void 0 : _b.assetOut;
|
|
8732
|
+
if (item.type === "TRANSFER_OUT" || item.type === "OFF_RAMP_FIAT") return assetIn;
|
|
8733
|
+
if (item.type === "SAMECHAIN_INVESTMENT_DEPOSIT" || item.type === "CROSSCHAIN_INVESTMENT_DEPOSIT") return assetIn;
|
|
8734
|
+
return assetOut;
|
|
8735
|
+
}
|
|
8736
|
+
function historyResolveAmounts(item) {
|
|
8737
|
+
const displayAsset = resolveDisplayAsset(item);
|
|
8776
8738
|
if (!displayAsset) return { primary: "\u2014", secondary: "" };
|
|
8777
8739
|
if (isAssetAmount(displayAsset)) {
|
|
8778
8740
|
const primary = `${displayAsset.amountHumanized} ${displayAsset.symbol}`;
|
|
@@ -8809,18 +8771,13 @@ function historyIsDeposit(type) {
|
|
|
8809
8771
|
return DEPOSIT_TYPES.includes(type);
|
|
8810
8772
|
}
|
|
8811
8773
|
function historyResolveIconUrl(item) {
|
|
8812
|
-
var _a, _b
|
|
8813
|
-
const
|
|
8814
|
-
|
|
8815
|
-
const displayAsset = item.type === "TRANSFER_OUT" || item.type === "OFF_RAMP_FIAT" ? assetIn : assetOut;
|
|
8816
|
-
if (displayAsset && isAssetAmount(displayAsset)) return (_d = (_c = displayAsset.token) == null ? void 0 : _c.logoURI) != null ? _d : "";
|
|
8774
|
+
var _a, _b;
|
|
8775
|
+
const displayAsset = resolveDisplayAsset(item);
|
|
8776
|
+
if (displayAsset && isAssetAmount(displayAsset)) return (_b = (_a = displayAsset.token) == null ? void 0 : _a.logoURI) != null ? _b : "";
|
|
8817
8777
|
return "";
|
|
8818
8778
|
}
|
|
8819
8779
|
function historyResolveIconAlt(item) {
|
|
8820
|
-
|
|
8821
|
-
const assetOut = (_a = item.amounts) == null ? void 0 : _a.assetOut;
|
|
8822
|
-
const assetIn = (_b = item.amounts) == null ? void 0 : _b.assetIn;
|
|
8823
|
-
const displayAsset = item.type === "TRANSFER_OUT" || item.type === "OFF_RAMP_FIAT" ? assetIn : assetOut;
|
|
8780
|
+
const displayAsset = resolveDisplayAsset(item);
|
|
8824
8781
|
if (displayAsset && isAssetAmount(displayAsset)) return displayAsset.symbol;
|
|
8825
8782
|
if (displayAsset && isFiatAmount(displayAsset)) return displayAsset.currency;
|
|
8826
8783
|
return "";
|
|
@@ -9178,7 +9135,7 @@ var SwapHistoryViewSimple = ({
|
|
|
9178
9135
|
"px-[var(--deframe-widget-size-padding-x-md)] py-[var(--deframe-widget-size-padding-y-md)]",
|
|
9179
9136
|
"flex flex-col gap-[var(--deframe-widget-size-gap-md)] h-[calc(100vh-48px)]",
|
|
9180
9137
|
"font-[var(--deframe-widget-font-family)]",
|
|
9181
|
-
|
|
9138
|
+
"w-full max-w-[900px] mx-auto shrink-0 box-border",
|
|
9182
9139
|
className
|
|
9183
9140
|
),
|
|
9184
9141
|
children: [
|