@deframe-sdk/components 0.1.52 → 0.1.53

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.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 variantIcons = {
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 = variantIcons[v];
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__ */ jsxs(
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
- /* @__PURE__ */ jsx(
6093
- SwapSlippageToleranceButtonsView,
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
- slippageBps,
6096
- onSelect: onSlippageSelect,
6097
- formatPercentage,
6098
- className: "mt-md"
6099
- }
6100
- ),
6101
- /* @__PURE__ */ jsx("div", { className: "w-full mt-md", children: /* @__PURE__ */ jsx("div", { className: "flex w-full gap-sm", children: percentageOptions.map((pct, index) => {
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__ */ jsx(
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: /* @__PURE__ */ jsx(ConfirmSwapButtonView, __spreadValues({}, confirmButton))
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__ */ jsx("div", { className: "mt-[var(--deframe-widget-size-gap-sm)]", children: /* @__PURE__ */ jsx(ConfirmSwapButtonViewSimple, __spreadValues({}, confirmButton)) })
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
  );