@deframe-sdk/components 0.1.9 → 0.1.10

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
@@ -3,7 +3,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import * as React6 from 'react';
4
4
  import React6__default, { useState, useEffect, useMemo } from 'react';
5
5
  import { motion, AnimatePresence } from 'framer-motion';
6
- import { MdClose, MdOutlineSearch, MdOutlineSearchOff, MdOutlineSwapHoriz, MdCheckCircleOutline, MdErrorOutline, MdWarningAmber, MdInfoOutline } from 'react-icons/md';
6
+ import { MdClose, MdOutlineSearch, MdOutlineSearchOff, MdOutlineSwapHoriz, MdHistory, MdCheckCircleOutline, MdErrorOutline, MdWarningAmber, MdInfoOutline } from 'react-icons/md';
7
7
  import { HiChevronUp, HiChevronDown, HiChevronLeft, HiXMark, HiArrowRight } from 'react-icons/hi2';
8
8
  import { IoAlertCircleOutline, IoTimeOutline, IoCheckmarkOutline } from 'react-icons/io5';
9
9
 
@@ -2785,7 +2785,7 @@ var SwapSlippageToleranceButtonsView = ({
2785
2785
  const activeClasses = "border-brand-primary text-brand-primary bg-brand-tint dark:bg-brand-tint-dark";
2786
2786
  const inactiveClasses = "border-border-subtle dark:border-border-subtle-dark text-text-secondary dark:text-text-secondary-dark bg-bg-default dark:bg-bg-default-dark";
2787
2787
  const buttonBase = "px-sm py-xs rounded border text-text-sm cursor-pointer";
2788
- return /* @__PURE__ */ jsxs(
2788
+ return /* @__PURE__ */ jsx(
2789
2789
  "button",
2790
2790
  {
2791
2791
  "data-test-id": `slippage-option-${option}`,
@@ -2794,10 +2794,7 @@ var SwapSlippageToleranceButtonsView = ({
2794
2794
  className: twMerge(buttonBase, isActive ? activeClasses : inactiveClasses),
2795
2795
  "aria-label": `${formatPercentage(option)}% slippage`,
2796
2796
  "aria-pressed": isActive,
2797
- children: [
2798
- formatPercentage(option),
2799
- "%"
2800
- ]
2797
+ children: formatPercentage(option)
2801
2798
  },
2802
2799
  option
2803
2800
  );
@@ -3786,7 +3783,386 @@ var ChooseAnAssetSwapView = ({
3786
3783
  }
3787
3784
  ) });
3788
3785
  };
3786
+ var SwapFormView = ({
3787
+ labels,
3788
+ onHistoryClick,
3789
+ fromCard,
3790
+ switchButton,
3791
+ toCard,
3792
+ advancedSettings,
3793
+ transactionDetails,
3794
+ confirmButton
3795
+ }) => {
3796
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3797
+ /* @__PURE__ */ jsx(
3798
+ "div",
3799
+ {
3800
+ "data-testid": "swap-form-view",
3801
+ className: "flex-1 min-h-0 overflow-y-auto swap-flow-content pr-sm",
3802
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-md text-text-secondary dark:text-text-secondary-dark", children: [
3803
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-md", children: [
3804
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-sm", children: [
3805
+ /* @__PURE__ */ jsx(TextHeading, { variant: "h5", className: "!text-[21px]", children: /* @__PURE__ */ jsx("span", { "data-testid": "swap-flow-title", children: labels.title }) }),
3806
+ labels.subtitle && /* @__PURE__ */ jsx(TextBody, { variant: "text-small", className: "!text-[14px]", children: labels.subtitle })
3807
+ ] }),
3808
+ /* @__PURE__ */ jsx(
3809
+ "button",
3810
+ {
3811
+ "data-testid": "swap-history-button",
3812
+ type: "button",
3813
+ onClick: onHistoryClick,
3814
+ className: "flex items-center justify-center w-12 h-12 transition-colors rounded-full cursor-pointer text-text-secondary dark:text-text-secondary-dark hover:text-brand-primary",
3815
+ "aria-label": labels.historyAriaLabel,
3816
+ children: /* @__PURE__ */ jsx(MdHistory, { className: "w-6 h-6" })
3817
+ }
3818
+ )
3819
+ ] }),
3820
+ /* @__PURE__ */ jsxs("div", { className: "relative flex flex-col items-stretch gap-sm", children: [
3821
+ fromCard,
3822
+ switchButton,
3823
+ toCard
3824
+ ] }),
3825
+ advancedSettings,
3826
+ /* @__PURE__ */ jsx("div", { className: "pb-xl", children: transactionDetails })
3827
+ ] })
3828
+ }
3829
+ ),
3830
+ /* @__PURE__ */ jsx(
3831
+ "div",
3832
+ {
3833
+ "data-testid": "swap-flow-footer",
3834
+ className: "border-t p-md border-border-default dark:border-border-default-dark bg-bg-primary dark:bg-bg-primary-dark",
3835
+ children: confirmButton
3836
+ }
3837
+ )
3838
+ ] });
3839
+ };
3840
+ var SwapFromCardView = ({
3841
+ labels,
3842
+ selectedToken,
3843
+ onTokenClick,
3844
+ balanceFormatted,
3845
+ balanceUsdFormatted,
3846
+ onBalanceClick,
3847
+ chainLabel,
3848
+ chainImage,
3849
+ onNetworkClick,
3850
+ amountValue,
3851
+ amountHasError,
3852
+ onAmountChange,
3853
+ maxFractionDigits,
3854
+ amountUsdFormatted,
3855
+ isAmountUsdLoading,
3856
+ amountSlot
3857
+ }) => {
3858
+ return /* @__PURE__ */ jsx(SectionCard, { className: "flex flex-col gap-sm", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-row gap-md items-center", children: [
3859
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-sm flex-1", children: [
3860
+ /* @__PURE__ */ jsx(
3861
+ SwapTokenSelectorView,
3862
+ {
3863
+ token: selectedToken,
3864
+ onClick: onTokenClick,
3865
+ testId: "swap-from-token-selector",
3866
+ selectTokenLabel: labels.selectTokenLabel
3867
+ }
3868
+ ),
3869
+ /* @__PURE__ */ jsx(
3870
+ TextBody,
3871
+ {
3872
+ variant: "text-small",
3873
+ className: "text-text-tertiary dark:text-text-tertiary-dark",
3874
+ children: onBalanceClick ? /* @__PURE__ */ jsxs(
3875
+ "button",
3876
+ {
3877
+ type: "button",
3878
+ onClick: onBalanceClick,
3879
+ className: "cursor-pointer hover:text-text-secondary dark:hover:text-text-secondary-dark transition-colors",
3880
+ "data-testid": "swap-from-balance",
3881
+ children: [
3882
+ labels.balanceLabel,
3883
+ ": ",
3884
+ balanceFormatted,
3885
+ " (",
3886
+ balanceUsdFormatted,
3887
+ ")"
3888
+ ]
3889
+ }
3890
+ ) : /* @__PURE__ */ jsxs("span", { "data-testid": "swap-from-balance", children: [
3891
+ labels.balanceLabel,
3892
+ ": ",
3893
+ balanceFormatted,
3894
+ " (",
3895
+ balanceUsdFormatted,
3896
+ ")"
3897
+ ] })
3898
+ }
3899
+ ),
3900
+ /* @__PURE__ */ jsx(
3901
+ SwapNetworkSelectorView,
3902
+ {
3903
+ chainLabel,
3904
+ chainImage,
3905
+ onClick: onNetworkClick,
3906
+ directionLabel: labels.directionLabel,
3907
+ testId: "swap-from-network-selector"
3908
+ }
3909
+ )
3910
+ ] }),
3911
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col flex-1 items-end justify-center gap-xs", children: amountSlot != null ? amountSlot : /* @__PURE__ */ jsxs(Fragment, { children: [
3912
+ /* @__PURE__ */ jsx(
3913
+ SwapAmountInputView,
3914
+ {
3915
+ value: amountValue,
3916
+ hasError: amountHasError,
3917
+ onChange: onAmountChange,
3918
+ maxFractionDigits,
3919
+ ariaLabel: labels.amountPlaceholder
3920
+ }
3921
+ ),
3922
+ /* @__PURE__ */ jsx(
3923
+ TextBody,
3924
+ {
3925
+ as: "span",
3926
+ variant: "text-small",
3927
+ className: amountHasError ? "text-state-error dark:text-state-error" : "text-text-tertiary dark:text-text-tertiary-dark",
3928
+ children: isAmountUsdLoading ? /* @__PURE__ */ jsx(LoadingDots, {}) : amountUsdFormatted
3929
+ }
3930
+ )
3931
+ ] }) })
3932
+ ] }) });
3933
+ };
3934
+ var SwapToCardView = ({
3935
+ labels,
3936
+ selectedToken,
3937
+ onTokenClick,
3938
+ balanceFormatted,
3939
+ balanceUsdFormatted,
3940
+ chainLabel,
3941
+ chainImage,
3942
+ onNetworkClick,
3943
+ outputAmount,
3944
+ isOutputLoading,
3945
+ outputUsdFormatted,
3946
+ isOutputUsdLoading
3947
+ }) => {
3948
+ const loadingElement = labels.searchingQuoteLabel ? /* @__PURE__ */ jsxs(Fragment, { children: [
3949
+ labels.searchingQuoteLabel,
3950
+ /* @__PURE__ */ jsx(LoadingDots, {})
3951
+ ] }) : void 0;
3952
+ return /* @__PURE__ */ jsx(SectionCard, { className: "flex flex-col gap-sm", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-row gap-md items-center", children: [
3953
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-sm flex-1", children: [
3954
+ /* @__PURE__ */ jsx(
3955
+ SwapTokenSelectorView,
3956
+ {
3957
+ token: selectedToken,
3958
+ onClick: onTokenClick,
3959
+ testId: "swap-to-token-selector",
3960
+ selectTokenLabel: labels.selectTokenLabel
3961
+ }
3962
+ ),
3963
+ /* @__PURE__ */ jsx(
3964
+ TextBody,
3965
+ {
3966
+ variant: "text-small",
3967
+ className: "text-text-tertiary dark:text-text-tertiary-dark",
3968
+ children: /* @__PURE__ */ jsxs("span", { "data-testid": "swap-to-balance", children: [
3969
+ labels.balanceLabel,
3970
+ ": ",
3971
+ balanceFormatted,
3972
+ " (",
3973
+ balanceUsdFormatted,
3974
+ ")"
3975
+ ] })
3976
+ }
3977
+ ),
3978
+ /* @__PURE__ */ jsx(
3979
+ SwapNetworkSelectorView,
3980
+ {
3981
+ chainLabel,
3982
+ chainImage,
3983
+ onClick: onNetworkClick,
3984
+ directionLabel: labels.directionLabel,
3985
+ testId: "swap-to-network-selector"
3986
+ }
3987
+ )
3988
+ ] }),
3989
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col flex-1 items-end justify-center gap-xs", children: [
3990
+ /* @__PURE__ */ jsx(
3991
+ SwapOutputAmountView,
3992
+ {
3993
+ displayOutput: outputAmount,
3994
+ isLoading: isOutputLoading,
3995
+ loadingElement,
3996
+ searchingQuoteLabel: labels.searchingQuoteLabel
3997
+ }
3998
+ ),
3999
+ /* @__PURE__ */ jsx(
4000
+ TextBody,
4001
+ {
4002
+ as: "span",
4003
+ variant: "text-small",
4004
+ className: "text-text-tertiary dark:text-text-tertiary-dark",
4005
+ children: isOutputUsdLoading ? /* @__PURE__ */ jsx(LoadingDots, {}) : outputUsdFormatted
4006
+ }
4007
+ )
4008
+ ] })
4009
+ ] }) });
4010
+ };
4011
+ var SwapQuoteDetailsView = ({
4012
+ labels,
4013
+ isVisible,
4014
+ isLoading,
4015
+ quoteHeaderLabel,
4016
+ timerElement,
4017
+ exchangeRateFormatted,
4018
+ totalCostFormatted,
4019
+ feePercentage,
4020
+ gasCostFormatted,
4021
+ protocolFee,
4022
+ slippageFormatted,
4023
+ etaFormatted,
4024
+ quoteId,
4025
+ hasQuoteError,
4026
+ hasBytecodeError,
4027
+ quoteErrorMessage,
4028
+ bytecodeErrorMessage
4029
+ }) => {
4030
+ const headerLabel = isLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
4031
+ quoteHeaderLabel,
4032
+ /* @__PURE__ */ jsx(LoadingDots, {})
4033
+ ] }) : quoteHeaderLabel;
4034
+ const items = [
4035
+ {
4036
+ label: "",
4037
+ value: /* @__PURE__ */ jsx(SwapQuoteHeaderView, { label: headerLabel, timerElement }),
4038
+ valueClassName: "w-full"
4039
+ },
4040
+ {
4041
+ label: labels.exchangeRateLabel,
4042
+ value: exchangeRateFormatted
4043
+ },
4044
+ {
4045
+ label: "",
4046
+ value: /* @__PURE__ */ jsx(
4047
+ SwapQuoteBlockchainCostsView,
4048
+ {
4049
+ totalCostFormatted,
4050
+ feePercentage,
4051
+ gasCostFormatted,
4052
+ protocolFee,
4053
+ blockchainCostsLabel: labels.blockchainCostsLabel,
4054
+ networkGasLabel: labels.networkGasLabel,
4055
+ protocolFeeLabel: labels.protocolFeeLabel,
4056
+ collapseLabel: labels.costsCollapseLabel,
4057
+ expandLabel: labels.costsExpandLabel
4058
+ }
4059
+ ),
4060
+ valueClassName: "flex flex-col gap-sm w-full text-right"
4061
+ },
4062
+ {
4063
+ label: labels.slippageLabel,
4064
+ value: slippageFormatted
4065
+ },
4066
+ {
4067
+ label: labels.etaLabel,
4068
+ value: etaFormatted
4069
+ }
4070
+ ];
4071
+ if (quoteId) {
4072
+ items.push({ label: labels.quoteIdLabel, value: quoteId });
4073
+ }
4074
+ return /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
4075
+ /* @__PURE__ */ jsx(
4076
+ SummaryDetails,
4077
+ {
4078
+ title: labels.headerLabel,
4079
+ items,
4080
+ defaultOpen: isVisible,
4081
+ className: "bg-bg-subtle dark:bg-bg-subtle-dark rounded shadow-sm p-md flex flex-col lg:!bg-bg-raised"
4082
+ },
4083
+ `details-${isVisible}`
4084
+ ),
4085
+ /* @__PURE__ */ jsx(
4086
+ SwapQuoteErrorsView,
4087
+ {
4088
+ hasQuoteError,
4089
+ hasBytecodeError,
4090
+ quoteErrorMessage,
4091
+ bytecodeErrorMessage
4092
+ }
4093
+ )
4094
+ ] });
4095
+ };
4096
+ var SwapAdvancedSettingsView = ({
4097
+ title,
4098
+ isOpen,
4099
+ onOpenChange,
4100
+ slippageBps,
4101
+ onSlippageSelect,
4102
+ formatPercentage,
4103
+ percentageOptions,
4104
+ onPercentageClick,
4105
+ slippageFormatted,
4106
+ collapseText,
4107
+ expandText,
4108
+ maxLabel
4109
+ }) => {
4110
+ return /* @__PURE__ */ jsx("div", { className: "pb-2 mt-md", children: /* @__PURE__ */ jsx(SectionCard, { children: /* @__PURE__ */ jsxs(
4111
+ CollapsibleSection,
4112
+ {
4113
+ title,
4114
+ subtitle: slippageFormatted,
4115
+ open: isOpen,
4116
+ onOpenChange,
4117
+ collapseText,
4118
+ expandText,
4119
+ children: [
4120
+ /* @__PURE__ */ jsx(
4121
+ SwapSlippageToleranceButtonsView,
4122
+ {
4123
+ slippageBps,
4124
+ onSelect: onSlippageSelect,
4125
+ formatPercentage,
4126
+ className: "mt-md"
4127
+ }
4128
+ ),
4129
+ /* @__PURE__ */ jsx("div", { className: "w-full mt-md", children: /* @__PURE__ */ jsx("div", { className: "flex w-full gap-sm", children: percentageOptions.map((pct, index) => {
4130
+ const isMax = index === percentageOptions.length - 1;
4131
+ const label = isMax ? maxLabel : `${pct / 100}%`;
4132
+ return /* @__PURE__ */ jsx(
4133
+ PercentageButton,
4134
+ {
4135
+ type: "button",
4136
+ onClick: () => onPercentageClick(pct),
4137
+ children: label
4138
+ },
4139
+ pct
4140
+ );
4141
+ }) }) })
4142
+ ]
4143
+ }
4144
+ ) }) });
4145
+ };
4146
+ var ConfirmSwapButtonView = ({
4147
+ buttonLabel,
4148
+ disabled,
4149
+ isLoading,
4150
+ onClick
4151
+ }) => {
4152
+ return /* @__PURE__ */ jsx("div", { "data-testid": "swap-confirm-button-wrapper", children: /* @__PURE__ */ jsxs(
4153
+ PrimaryButton,
4154
+ {
4155
+ onClick,
4156
+ className: "w-full",
4157
+ disabled,
4158
+ children: [
4159
+ buttonLabel,
4160
+ isLoading && /* @__PURE__ */ jsx(LoadingDots, {})
4161
+ ]
4162
+ }
4163
+ ) });
4164
+ };
3789
4165
 
3790
- export { ActionButton, ActionSheet, AddressDisplay, BackgroundContainer, BannerNotification, ChooseAStrategyActionsheetView, ChooseAnAssetSwapView, CloseButton, CollapsibleInfoRow, CollapsibleSection, ConnectWalletList, Currency, DeframeComponentsProvider, DetailsHeader, Currency as Fiat, FlexCol, FlexRow, HighRiskBadge, HistoryDepositDetailsView, HistoryWithdrawDetailsView, InfoLabel, InfoRow, InfoRowIconLabel, InfoRowIconValue, InfoRowWithIcon, InfoValue, Input2 as Input, Link, ListItem, ListItemContent, ListItemLeftSide, ListItemRightSide, LoadingDots, LowRiskBadge, MediumRiskBadge, Navbar, PercentageButton, PrimaryButton, ProgressIndicator, ScrollableContent, SearchEmptyState, SearchInput, SecondaryButton, SectionCard, Select, SelectContent, SelectItem, SelectTrigger, Skeleton, StepDisplay, StepStatusIcon, StepStatusText, StrategyDetailsView, SummaryDetails, SummaryDetailsCryptoControlV2, SwapAmountInputView, SwapCrossChainProcessingView, SwapNetworkSelectorView, SwapOutputAmountView, SwapProcessingView, SwapQuoteBlockchainCostsView, SwapQuoteErrorsView, SwapQuoteHeaderView, SwapSignatureWarningView, SwapSlippageToleranceButtonsView, SwapSuccessView, SwapTokenSelectorView, SwapTransactionFailedView, Tabs, TabsContent, TabsList, TabsTrigger, TertiaryButton, Text_default as Text, TextAccent, TextBody, TextHeading, Title, TokenWithChainBadge, TransactionProcessingDetails, TransactionScreen, TransactionScreenIcon, TransactionScreenInvestmentCard, WalletItem, ConnectWalletList as WalletList, WalletListContainer, cryptocontrolThemeColors, darkThemeColors, defaultThemeColors, themeToCSS };
4166
+ export { ActionButton, ActionSheet, AddressDisplay, BackgroundContainer, BannerNotification, ChooseAStrategyActionsheetView, ChooseAnAssetSwapView, CloseButton, CollapsibleInfoRow, CollapsibleSection, ConfirmSwapButtonView, ConnectWalletList, Currency, DeframeComponentsProvider, DetailsHeader, Currency as Fiat, FlexCol, FlexRow, HighRiskBadge, HistoryDepositDetailsView, HistoryWithdrawDetailsView, InfoLabel, InfoRow, InfoRowIconLabel, InfoRowIconValue, InfoRowWithIcon, InfoValue, Input2 as Input, Link, ListItem, ListItemContent, ListItemLeftSide, ListItemRightSide, LoadingDots, LowRiskBadge, MediumRiskBadge, Navbar, PercentageButton, PrimaryButton, ProgressIndicator, ScrollableContent, SearchEmptyState, SearchInput, SecondaryButton, SectionCard, Select, SelectContent, SelectItem, SelectTrigger, Skeleton, StepDisplay, StepStatusIcon, StepStatusText, StrategyDetailsView, SummaryDetails, SummaryDetailsCryptoControlV2, SwapAdvancedSettingsView, SwapAmountInputView, SwapCrossChainProcessingView, SwapFormView, SwapFromCardView, SwapNetworkSelectorView, SwapOutputAmountView, SwapProcessingView, SwapQuoteBlockchainCostsView, SwapQuoteDetailsView, SwapQuoteErrorsView, SwapQuoteHeaderView, SwapSignatureWarningView, SwapSlippageToleranceButtonsView, SwapSuccessView, SwapToCardView, SwapTokenSelectorView, SwapTransactionFailedView, Tabs, TabsContent, TabsList, TabsTrigger, TertiaryButton, Text_default as Text, TextAccent, TextBody, TextHeading, Title, TokenWithChainBadge, TransactionProcessingDetails, TransactionScreen, TransactionScreenIcon, TransactionScreenInvestmentCard, WalletItem, ConnectWalletList as WalletList, WalletListContainer, cryptocontrolThemeColors, darkThemeColors, defaultThemeColors, themeToCSS };
3791
4167
  //# sourceMappingURL=index.mjs.map
3792
4168
  //# sourceMappingURL=index.mjs.map