@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.js CHANGED
@@ -2806,7 +2806,7 @@ var SwapSlippageToleranceButtonsView = ({
2806
2806
  const activeClasses = "border-brand-primary text-brand-primary bg-brand-tint dark:bg-brand-tint-dark";
2807
2807
  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";
2808
2808
  const buttonBase = "px-sm py-xs rounded border text-text-sm cursor-pointer";
2809
- return /* @__PURE__ */ jsxRuntime.jsxs(
2809
+ return /* @__PURE__ */ jsxRuntime.jsx(
2810
2810
  "button",
2811
2811
  {
2812
2812
  "data-test-id": `slippage-option-${option}`,
@@ -2815,10 +2815,7 @@ var SwapSlippageToleranceButtonsView = ({
2815
2815
  className: tailwindMerge.twMerge(buttonBase, isActive ? activeClasses : inactiveClasses),
2816
2816
  "aria-label": `${formatPercentage(option)}% slippage`,
2817
2817
  "aria-pressed": isActive,
2818
- children: [
2819
- formatPercentage(option),
2820
- "%"
2821
- ]
2818
+ children: formatPercentage(option)
2822
2819
  },
2823
2820
  option
2824
2821
  );
@@ -3807,6 +3804,385 @@ var ChooseAnAssetSwapView = ({
3807
3804
  }
3808
3805
  ) });
3809
3806
  };
3807
+ var SwapFormView = ({
3808
+ labels,
3809
+ onHistoryClick,
3810
+ fromCard,
3811
+ switchButton,
3812
+ toCard,
3813
+ advancedSettings,
3814
+ transactionDetails,
3815
+ confirmButton
3816
+ }) => {
3817
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3818
+ /* @__PURE__ */ jsxRuntime.jsx(
3819
+ "div",
3820
+ {
3821
+ "data-testid": "swap-form-view",
3822
+ className: "flex-1 min-h-0 overflow-y-auto swap-flow-content pr-sm",
3823
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-md text-text-secondary dark:text-text-secondary-dark", children: [
3824
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-md", children: [
3825
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-sm", children: [
3826
+ /* @__PURE__ */ jsxRuntime.jsx(TextHeading, { variant: "h5", className: "!text-[21px]", children: /* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": "swap-flow-title", children: labels.title }) }),
3827
+ labels.subtitle && /* @__PURE__ */ jsxRuntime.jsx(TextBody, { variant: "text-small", className: "!text-[14px]", children: labels.subtitle })
3828
+ ] }),
3829
+ /* @__PURE__ */ jsxRuntime.jsx(
3830
+ "button",
3831
+ {
3832
+ "data-testid": "swap-history-button",
3833
+ type: "button",
3834
+ onClick: onHistoryClick,
3835
+ 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",
3836
+ "aria-label": labels.historyAriaLabel,
3837
+ children: /* @__PURE__ */ jsxRuntime.jsx(md.MdHistory, { className: "w-6 h-6" })
3838
+ }
3839
+ )
3840
+ ] }),
3841
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex flex-col items-stretch gap-sm", children: [
3842
+ fromCard,
3843
+ switchButton,
3844
+ toCard
3845
+ ] }),
3846
+ advancedSettings,
3847
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pb-xl", children: transactionDetails })
3848
+ ] })
3849
+ }
3850
+ ),
3851
+ /* @__PURE__ */ jsxRuntime.jsx(
3852
+ "div",
3853
+ {
3854
+ "data-testid": "swap-flow-footer",
3855
+ className: "border-t p-md border-border-default dark:border-border-default-dark bg-bg-primary dark:bg-bg-primary-dark",
3856
+ children: confirmButton
3857
+ }
3858
+ )
3859
+ ] });
3860
+ };
3861
+ var SwapFromCardView = ({
3862
+ labels,
3863
+ selectedToken,
3864
+ onTokenClick,
3865
+ balanceFormatted,
3866
+ balanceUsdFormatted,
3867
+ onBalanceClick,
3868
+ chainLabel,
3869
+ chainImage,
3870
+ onNetworkClick,
3871
+ amountValue,
3872
+ amountHasError,
3873
+ onAmountChange,
3874
+ maxFractionDigits,
3875
+ amountUsdFormatted,
3876
+ isAmountUsdLoading,
3877
+ amountSlot
3878
+ }) => {
3879
+ return /* @__PURE__ */ jsxRuntime.jsx(SectionCard, { className: "flex flex-col gap-sm", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row gap-md items-center", children: [
3880
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-sm flex-1", children: [
3881
+ /* @__PURE__ */ jsxRuntime.jsx(
3882
+ SwapTokenSelectorView,
3883
+ {
3884
+ token: selectedToken,
3885
+ onClick: onTokenClick,
3886
+ testId: "swap-from-token-selector",
3887
+ selectTokenLabel: labels.selectTokenLabel
3888
+ }
3889
+ ),
3890
+ /* @__PURE__ */ jsxRuntime.jsx(
3891
+ TextBody,
3892
+ {
3893
+ variant: "text-small",
3894
+ className: "text-text-tertiary dark:text-text-tertiary-dark",
3895
+ children: onBalanceClick ? /* @__PURE__ */ jsxRuntime.jsxs(
3896
+ "button",
3897
+ {
3898
+ type: "button",
3899
+ onClick: onBalanceClick,
3900
+ className: "cursor-pointer hover:text-text-secondary dark:hover:text-text-secondary-dark transition-colors",
3901
+ "data-testid": "swap-from-balance",
3902
+ children: [
3903
+ labels.balanceLabel,
3904
+ ": ",
3905
+ balanceFormatted,
3906
+ " (",
3907
+ balanceUsdFormatted,
3908
+ ")"
3909
+ ]
3910
+ }
3911
+ ) : /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-testid": "swap-from-balance", children: [
3912
+ labels.balanceLabel,
3913
+ ": ",
3914
+ balanceFormatted,
3915
+ " (",
3916
+ balanceUsdFormatted,
3917
+ ")"
3918
+ ] })
3919
+ }
3920
+ ),
3921
+ /* @__PURE__ */ jsxRuntime.jsx(
3922
+ SwapNetworkSelectorView,
3923
+ {
3924
+ chainLabel,
3925
+ chainImage,
3926
+ onClick: onNetworkClick,
3927
+ directionLabel: labels.directionLabel,
3928
+ testId: "swap-from-network-selector"
3929
+ }
3930
+ )
3931
+ ] }),
3932
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col flex-1 items-end justify-center gap-xs", children: amountSlot != null ? amountSlot : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3933
+ /* @__PURE__ */ jsxRuntime.jsx(
3934
+ SwapAmountInputView,
3935
+ {
3936
+ value: amountValue,
3937
+ hasError: amountHasError,
3938
+ onChange: onAmountChange,
3939
+ maxFractionDigits,
3940
+ ariaLabel: labels.amountPlaceholder
3941
+ }
3942
+ ),
3943
+ /* @__PURE__ */ jsxRuntime.jsx(
3944
+ TextBody,
3945
+ {
3946
+ as: "span",
3947
+ variant: "text-small",
3948
+ className: amountHasError ? "text-state-error dark:text-state-error" : "text-text-tertiary dark:text-text-tertiary-dark",
3949
+ children: isAmountUsdLoading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingDots, {}) : amountUsdFormatted
3950
+ }
3951
+ )
3952
+ ] }) })
3953
+ ] }) });
3954
+ };
3955
+ var SwapToCardView = ({
3956
+ labels,
3957
+ selectedToken,
3958
+ onTokenClick,
3959
+ balanceFormatted,
3960
+ balanceUsdFormatted,
3961
+ chainLabel,
3962
+ chainImage,
3963
+ onNetworkClick,
3964
+ outputAmount,
3965
+ isOutputLoading,
3966
+ outputUsdFormatted,
3967
+ isOutputUsdLoading
3968
+ }) => {
3969
+ const loadingElement = labels.searchingQuoteLabel ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3970
+ labels.searchingQuoteLabel,
3971
+ /* @__PURE__ */ jsxRuntime.jsx(LoadingDots, {})
3972
+ ] }) : void 0;
3973
+ return /* @__PURE__ */ jsxRuntime.jsx(SectionCard, { className: "flex flex-col gap-sm", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row gap-md items-center", children: [
3974
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-sm flex-1", children: [
3975
+ /* @__PURE__ */ jsxRuntime.jsx(
3976
+ SwapTokenSelectorView,
3977
+ {
3978
+ token: selectedToken,
3979
+ onClick: onTokenClick,
3980
+ testId: "swap-to-token-selector",
3981
+ selectTokenLabel: labels.selectTokenLabel
3982
+ }
3983
+ ),
3984
+ /* @__PURE__ */ jsxRuntime.jsx(
3985
+ TextBody,
3986
+ {
3987
+ variant: "text-small",
3988
+ className: "text-text-tertiary dark:text-text-tertiary-dark",
3989
+ children: /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-testid": "swap-to-balance", children: [
3990
+ labels.balanceLabel,
3991
+ ": ",
3992
+ balanceFormatted,
3993
+ " (",
3994
+ balanceUsdFormatted,
3995
+ ")"
3996
+ ] })
3997
+ }
3998
+ ),
3999
+ /* @__PURE__ */ jsxRuntime.jsx(
4000
+ SwapNetworkSelectorView,
4001
+ {
4002
+ chainLabel,
4003
+ chainImage,
4004
+ onClick: onNetworkClick,
4005
+ directionLabel: labels.directionLabel,
4006
+ testId: "swap-to-network-selector"
4007
+ }
4008
+ )
4009
+ ] }),
4010
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col flex-1 items-end justify-center gap-xs", children: [
4011
+ /* @__PURE__ */ jsxRuntime.jsx(
4012
+ SwapOutputAmountView,
4013
+ {
4014
+ displayOutput: outputAmount,
4015
+ isLoading: isOutputLoading,
4016
+ loadingElement,
4017
+ searchingQuoteLabel: labels.searchingQuoteLabel
4018
+ }
4019
+ ),
4020
+ /* @__PURE__ */ jsxRuntime.jsx(
4021
+ TextBody,
4022
+ {
4023
+ as: "span",
4024
+ variant: "text-small",
4025
+ className: "text-text-tertiary dark:text-text-tertiary-dark",
4026
+ children: isOutputUsdLoading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingDots, {}) : outputUsdFormatted
4027
+ }
4028
+ )
4029
+ ] })
4030
+ ] }) });
4031
+ };
4032
+ var SwapQuoteDetailsView = ({
4033
+ labels,
4034
+ isVisible,
4035
+ isLoading,
4036
+ quoteHeaderLabel,
4037
+ timerElement,
4038
+ exchangeRateFormatted,
4039
+ totalCostFormatted,
4040
+ feePercentage,
4041
+ gasCostFormatted,
4042
+ protocolFee,
4043
+ slippageFormatted,
4044
+ etaFormatted,
4045
+ quoteId,
4046
+ hasQuoteError,
4047
+ hasBytecodeError,
4048
+ quoteErrorMessage,
4049
+ bytecodeErrorMessage
4050
+ }) => {
4051
+ const headerLabel = isLoading ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4052
+ quoteHeaderLabel,
4053
+ /* @__PURE__ */ jsxRuntime.jsx(LoadingDots, {})
4054
+ ] }) : quoteHeaderLabel;
4055
+ const items = [
4056
+ {
4057
+ label: "",
4058
+ value: /* @__PURE__ */ jsxRuntime.jsx(SwapQuoteHeaderView, { label: headerLabel, timerElement }),
4059
+ valueClassName: "w-full"
4060
+ },
4061
+ {
4062
+ label: labels.exchangeRateLabel,
4063
+ value: exchangeRateFormatted
4064
+ },
4065
+ {
4066
+ label: "",
4067
+ value: /* @__PURE__ */ jsxRuntime.jsx(
4068
+ SwapQuoteBlockchainCostsView,
4069
+ {
4070
+ totalCostFormatted,
4071
+ feePercentage,
4072
+ gasCostFormatted,
4073
+ protocolFee,
4074
+ blockchainCostsLabel: labels.blockchainCostsLabel,
4075
+ networkGasLabel: labels.networkGasLabel,
4076
+ protocolFeeLabel: labels.protocolFeeLabel,
4077
+ collapseLabel: labels.costsCollapseLabel,
4078
+ expandLabel: labels.costsExpandLabel
4079
+ }
4080
+ ),
4081
+ valueClassName: "flex flex-col gap-sm w-full text-right"
4082
+ },
4083
+ {
4084
+ label: labels.slippageLabel,
4085
+ value: slippageFormatted
4086
+ },
4087
+ {
4088
+ label: labels.etaLabel,
4089
+ value: etaFormatted
4090
+ }
4091
+ ];
4092
+ if (quoteId) {
4093
+ items.push({ label: labels.quoteIdLabel, value: quoteId });
4094
+ }
4095
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", children: [
4096
+ /* @__PURE__ */ jsxRuntime.jsx(
4097
+ SummaryDetails,
4098
+ {
4099
+ title: labels.headerLabel,
4100
+ items,
4101
+ defaultOpen: isVisible,
4102
+ className: "bg-bg-subtle dark:bg-bg-subtle-dark rounded shadow-sm p-md flex flex-col lg:!bg-bg-raised"
4103
+ },
4104
+ `details-${isVisible}`
4105
+ ),
4106
+ /* @__PURE__ */ jsxRuntime.jsx(
4107
+ SwapQuoteErrorsView,
4108
+ {
4109
+ hasQuoteError,
4110
+ hasBytecodeError,
4111
+ quoteErrorMessage,
4112
+ bytecodeErrorMessage
4113
+ }
4114
+ )
4115
+ ] });
4116
+ };
4117
+ var SwapAdvancedSettingsView = ({
4118
+ title,
4119
+ isOpen,
4120
+ onOpenChange,
4121
+ slippageBps,
4122
+ onSlippageSelect,
4123
+ formatPercentage,
4124
+ percentageOptions,
4125
+ onPercentageClick,
4126
+ slippageFormatted,
4127
+ collapseText,
4128
+ expandText,
4129
+ maxLabel
4130
+ }) => {
4131
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pb-2 mt-md", children: /* @__PURE__ */ jsxRuntime.jsx(SectionCard, { children: /* @__PURE__ */ jsxRuntime.jsxs(
4132
+ CollapsibleSection,
4133
+ {
4134
+ title,
4135
+ subtitle: slippageFormatted,
4136
+ open: isOpen,
4137
+ onOpenChange,
4138
+ collapseText,
4139
+ expandText,
4140
+ children: [
4141
+ /* @__PURE__ */ jsxRuntime.jsx(
4142
+ SwapSlippageToleranceButtonsView,
4143
+ {
4144
+ slippageBps,
4145
+ onSelect: onSlippageSelect,
4146
+ formatPercentage,
4147
+ className: "mt-md"
4148
+ }
4149
+ ),
4150
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full mt-md", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full gap-sm", children: percentageOptions.map((pct, index) => {
4151
+ const isMax = index === percentageOptions.length - 1;
4152
+ const label = isMax ? maxLabel : `${pct / 100}%`;
4153
+ return /* @__PURE__ */ jsxRuntime.jsx(
4154
+ PercentageButton,
4155
+ {
4156
+ type: "button",
4157
+ onClick: () => onPercentageClick(pct),
4158
+ children: label
4159
+ },
4160
+ pct
4161
+ );
4162
+ }) }) })
4163
+ ]
4164
+ }
4165
+ ) }) });
4166
+ };
4167
+ var ConfirmSwapButtonView = ({
4168
+ buttonLabel,
4169
+ disabled,
4170
+ isLoading,
4171
+ onClick
4172
+ }) => {
4173
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "swap-confirm-button-wrapper", children: /* @__PURE__ */ jsxRuntime.jsxs(
4174
+ PrimaryButton,
4175
+ {
4176
+ onClick,
4177
+ className: "w-full",
4178
+ disabled,
4179
+ children: [
4180
+ buttonLabel,
4181
+ isLoading && /* @__PURE__ */ jsxRuntime.jsx(LoadingDots, {})
4182
+ ]
4183
+ }
4184
+ ) });
4185
+ };
3810
4186
 
3811
4187
  exports.ActionButton = ActionButton;
3812
4188
  exports.ActionSheet = ActionSheet;
@@ -3818,6 +4194,7 @@ exports.ChooseAnAssetSwapView = ChooseAnAssetSwapView;
3818
4194
  exports.CloseButton = CloseButton;
3819
4195
  exports.CollapsibleInfoRow = CollapsibleInfoRow;
3820
4196
  exports.CollapsibleSection = CollapsibleSection;
4197
+ exports.ConfirmSwapButtonView = ConfirmSwapButtonView;
3821
4198
  exports.ConnectWalletList = ConnectWalletList;
3822
4199
  exports.Currency = Currency;
3823
4200
  exports.DeframeComponentsProvider = DeframeComponentsProvider;
@@ -3863,17 +4240,22 @@ exports.StepStatusText = StepStatusText;
3863
4240
  exports.StrategyDetailsView = StrategyDetailsView;
3864
4241
  exports.SummaryDetails = SummaryDetails;
3865
4242
  exports.SummaryDetailsCryptoControlV2 = SummaryDetailsCryptoControlV2;
4243
+ exports.SwapAdvancedSettingsView = SwapAdvancedSettingsView;
3866
4244
  exports.SwapAmountInputView = SwapAmountInputView;
3867
4245
  exports.SwapCrossChainProcessingView = SwapCrossChainProcessingView;
4246
+ exports.SwapFormView = SwapFormView;
4247
+ exports.SwapFromCardView = SwapFromCardView;
3868
4248
  exports.SwapNetworkSelectorView = SwapNetworkSelectorView;
3869
4249
  exports.SwapOutputAmountView = SwapOutputAmountView;
3870
4250
  exports.SwapProcessingView = SwapProcessingView;
3871
4251
  exports.SwapQuoteBlockchainCostsView = SwapQuoteBlockchainCostsView;
4252
+ exports.SwapQuoteDetailsView = SwapQuoteDetailsView;
3872
4253
  exports.SwapQuoteErrorsView = SwapQuoteErrorsView;
3873
4254
  exports.SwapQuoteHeaderView = SwapQuoteHeaderView;
3874
4255
  exports.SwapSignatureWarningView = SwapSignatureWarningView;
3875
4256
  exports.SwapSlippageToleranceButtonsView = SwapSlippageToleranceButtonsView;
3876
4257
  exports.SwapSuccessView = SwapSuccessView;
4258
+ exports.SwapToCardView = SwapToCardView;
3877
4259
  exports.SwapTokenSelectorView = SwapTokenSelectorView;
3878
4260
  exports.SwapTransactionFailedView = SwapTransactionFailedView;
3879
4261
  exports.Tabs = Tabs;