@swype-org/react-sdk 0.1.189 → 0.1.190
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.cjs +163 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +163 -78
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3859,6 +3859,22 @@ function DepositScreen({
|
|
|
3859
3859
|
}) {
|
|
3860
3860
|
const { tokens } = useSwypeConfig();
|
|
3861
3861
|
const amount = initialAmount;
|
|
3862
|
+
const [accountPickerOpen, setAccountPickerOpen] = react.useState(false);
|
|
3863
|
+
const pickerRef = react.useRef(null);
|
|
3864
|
+
react.useEffect(() => {
|
|
3865
|
+
if (!accountPickerOpen) return;
|
|
3866
|
+
const handleClick = (e) => {
|
|
3867
|
+
if (pickerRef.current && !pickerRef.current.contains(e.target)) {
|
|
3868
|
+
setAccountPickerOpen(false);
|
|
3869
|
+
}
|
|
3870
|
+
};
|
|
3871
|
+
document.addEventListener("mousedown", handleClick);
|
|
3872
|
+
return () => document.removeEventListener("mousedown", handleClick);
|
|
3873
|
+
}, [accountPickerOpen]);
|
|
3874
|
+
const selectedAccount = accounts?.find((a) => a.id === selectedAccountId);
|
|
3875
|
+
const selectedProviderName = selectedAccount?.name ?? "Wallet";
|
|
3876
|
+
const selectedProviderLogo = KNOWN_LOGOS[selectedProviderName.toLowerCase()];
|
|
3877
|
+
const hasMultipleAccounts = accounts != null && accounts.length > 1;
|
|
3862
3878
|
const isLowBalance = availableBalance < MIN_DEPOSIT;
|
|
3863
3879
|
const exceedsLimit = remainingLimit != null && amount > remainingLimit && !isLowBalance;
|
|
3864
3880
|
const canDeposit = amount >= MIN_DEPOSIT && !exceedsLimit && !isLowBalance && !processing;
|
|
@@ -3924,94 +3940,116 @@ function DepositScreen({
|
|
|
3924
3940
|
] }),
|
|
3925
3941
|
children: [
|
|
3926
3942
|
/* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { onBack }),
|
|
3927
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style:
|
|
3928
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3929
|
-
|
|
3930
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style:
|
|
3931
|
-
"
|
|
3932
|
-
|
|
3943
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { ref: pickerRef, style: depositCardWrapStyle, children: [
|
|
3944
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: depositCardStyle(tokens), children: [
|
|
3945
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: depositLabelStyle(tokens.textMuted), children: "Depositing" }),
|
|
3946
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: amountRowStyle2, children: [
|
|
3947
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: amountValueStyle(tokens.text), children: [
|
|
3948
|
+
"$",
|
|
3949
|
+
amount.toLocaleString("en-US", { minimumFractionDigits: 0, maximumFractionDigits: 2 })
|
|
3950
|
+
] }),
|
|
3951
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3952
|
+
"button",
|
|
3953
|
+
{
|
|
3954
|
+
type: "button",
|
|
3955
|
+
onClick: onSelectToken,
|
|
3956
|
+
style: tokenIconButtonStyle2(!!onSelectToken),
|
|
3957
|
+
children: [
|
|
3958
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: tokenIconWrapStyle2, children: [
|
|
3959
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", children: [
|
|
3960
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "18", cy: "18", r: "18", fill: "#2DB84B" }),
|
|
3961
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: "18", y: "23", textAnchor: "middle", fontSize: "18", fill: "#fff", fontWeight: "700", children: "$" })
|
|
3962
|
+
] }),
|
|
3963
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", style: checkBadgeStyle2, children: [
|
|
3964
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "8", cy: "8", r: "8", fill: "#2775CA" }),
|
|
3965
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 8l2 2 4-4", stroke: "#fff", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
3966
|
+
] })
|
|
3967
|
+
] }),
|
|
3968
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", style: { opacity: 0.5 }, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6 9l6 6 6-6", stroke: tokens.textMuted, strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
3969
|
+
]
|
|
3970
|
+
}
|
|
3971
|
+
)
|
|
3933
3972
|
] }),
|
|
3934
3973
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3935
3974
|
"button",
|
|
3936
3975
|
{
|
|
3937
3976
|
type: "button",
|
|
3938
|
-
onClick:
|
|
3939
|
-
style:
|
|
3977
|
+
onClick: hasMultipleAccounts ? () => setAccountPickerOpen(!accountPickerOpen) : void 0,
|
|
3978
|
+
style: walletBalanceRowStyle(hasMultipleAccounts),
|
|
3940
3979
|
children: [
|
|
3941
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
] }),
|
|
3946
|
-
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", style: checkBadgeStyle2, children: [
|
|
3947
|
-
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "8", cy: "8", r: "8", fill: "#2775CA" }),
|
|
3948
|
-
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 8l2 2 4-4", stroke: "#fff", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
3949
|
-
] })
|
|
3980
|
+
selectedProviderLogo ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: selectedProviderLogo, alt: selectedProviderName, style: providerLogoStyle }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: providerFallbackStyle(tokens.textMuted), children: selectedProviderName.charAt(0) }),
|
|
3981
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: walletBalanceStyle(tokens.text), children: [
|
|
3982
|
+
"$",
|
|
3983
|
+
availableBalance.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
|
3950
3984
|
] }),
|
|
3951
|
-
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "
|
|
3985
|
+
hasMultipleAccounts && /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", style: { opacity: 0.4 }, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7 10l5-5 5 5M7 14l5 5 5-5", stroke: tokens.textMuted, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
3952
3986
|
]
|
|
3953
3987
|
}
|
|
3954
3988
|
)
|
|
3955
|
-
] })
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3989
|
+
] }),
|
|
3990
|
+
accountPickerOpen && accounts && accounts.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: accountDropdownOuterStyle(tokens), children: [
|
|
3991
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: accountDropdownLabelStyle(tokens.textMuted), children: "Choose account" }),
|
|
3992
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: accountDropdownInnerStyle(tokens), children: [
|
|
3993
|
+
accounts.map((account) => {
|
|
3994
|
+
const preferredWallet = getPreferredDepositWallet(account, amount);
|
|
3995
|
+
const active = hasActiveDepositWallet(account);
|
|
3996
|
+
const isSelected = account.id === selectedAccountId;
|
|
3997
|
+
const walletAddress = preferredWallet ? getWalletAddress(preferredWallet) : null;
|
|
3998
|
+
const truncatedAddress = walletAddress ? `${walletAddress.slice(0, 6)}...${walletAddress.slice(-4)}` : null;
|
|
3999
|
+
const accountBalance = account.wallets.reduce(
|
|
4000
|
+
(sum, w) => sum + w.balance.available.amount,
|
|
4001
|
+
0
|
|
4002
|
+
);
|
|
4003
|
+
const providerLogo = KNOWN_LOGOS[account.name.toLowerCase()];
|
|
4004
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4005
|
+
"button",
|
|
4006
|
+
{
|
|
4007
|
+
type: "button",
|
|
4008
|
+
onClick: () => {
|
|
4009
|
+
if (active) {
|
|
4010
|
+
onSelectAccount?.(account.id);
|
|
4011
|
+
} else {
|
|
4012
|
+
onAuthorizeAccount?.(account.id);
|
|
4013
|
+
}
|
|
4014
|
+
setAccountPickerOpen(false);
|
|
4015
|
+
},
|
|
4016
|
+
style: accountRowStyle(tokens, isSelected),
|
|
4017
|
+
children: [
|
|
4018
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: accountRowLeftStyle, children: [
|
|
4019
|
+
providerLogo ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: providerLogo, alt: account.name, style: accountLogoStyle }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: accountFallbackIconStyle(tokens.textMuted), children: account.name.charAt(0) }),
|
|
4020
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: accountInfoStyle, children: [
|
|
4021
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: accountAddressStyle(tokens.text), children: truncatedAddress ?? account.nickname ?? account.name }),
|
|
4022
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: accountBalanceTextStyle(tokens.textMuted), children: [
|
|
4023
|
+
"$",
|
|
4024
|
+
accountBalance.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
|
4025
|
+
] })
|
|
4026
|
+
] })
|
|
4027
|
+
] }),
|
|
4028
|
+
isSelected ? /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "22", height: "22", viewBox: "0 0 22 22", fill: "none", children: [
|
|
4029
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "11", cy: "11", r: "11", fill: tokens.success }),
|
|
4030
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7 11l3 3 5-5", stroke: "#fff", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
4031
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: radioEmptyStyle(tokens.border) })
|
|
4032
|
+
]
|
|
4033
|
+
},
|
|
4034
|
+
account.id
|
|
4035
|
+
);
|
|
4036
|
+
}),
|
|
4037
|
+
onAddProvider && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3972
4038
|
"button",
|
|
3973
4039
|
{
|
|
3974
4040
|
type: "button",
|
|
3975
4041
|
onClick: () => {
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
} else {
|
|
3979
|
-
onAuthorizeAccount?.(account.id);
|
|
3980
|
-
}
|
|
4042
|
+
onAddProvider();
|
|
4043
|
+
setAccountPickerOpen(false);
|
|
3981
4044
|
},
|
|
3982
|
-
style:
|
|
4045
|
+
style: addAccountBtnStyle(tokens),
|
|
3983
4046
|
children: [
|
|
3984
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3985
|
-
|
|
3986
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: accountInfoStyle, children: [
|
|
3987
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: accountAddressStyle(tokens.text), children: truncatedAddress ?? account.nickname ?? account.name }),
|
|
3988
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: accountBalanceTextStyle(tokens.textMuted), children: [
|
|
3989
|
-
"$",
|
|
3990
|
-
accountBalance.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
|
3991
|
-
] })
|
|
3992
|
-
] })
|
|
3993
|
-
] }),
|
|
3994
|
-
isSelected ? /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "22", height: "22", viewBox: "0 0 22 22", fill: "none", children: [
|
|
3995
|
-
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "11", cy: "11", r: "11", fill: tokens.success }),
|
|
3996
|
-
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7 11l3 3 5-5", stroke: "#fff", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
3997
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: radioEmptyStyle(tokens.border) })
|
|
4047
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 5v14M5 12h14", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round" }) }),
|
|
4048
|
+
"Add Account"
|
|
3998
4049
|
]
|
|
3999
|
-
}
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
}),
|
|
4003
|
-
onAddProvider && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4004
|
-
"button",
|
|
4005
|
-
{
|
|
4006
|
-
type: "button",
|
|
4007
|
-
onClick: onAddProvider,
|
|
4008
|
-
style: addAccountBtnStyle(tokens),
|
|
4009
|
-
children: [
|
|
4010
|
-
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 5v14M5 12h14", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round" }) }),
|
|
4011
|
-
"Add Account"
|
|
4012
|
-
]
|
|
4013
|
-
}
|
|
4014
|
-
)
|
|
4050
|
+
}
|
|
4051
|
+
)
|
|
4052
|
+
] })
|
|
4015
4053
|
] })
|
|
4016
4054
|
] }),
|
|
4017
4055
|
remainingLimit != null && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: spendingLimitStyle(tokens.textMuted), children: [
|
|
@@ -4027,12 +4065,15 @@ function DepositScreen({
|
|
|
4027
4065
|
}
|
|
4028
4066
|
);
|
|
4029
4067
|
}
|
|
4068
|
+
var depositCardWrapStyle = {
|
|
4069
|
+
position: "relative",
|
|
4070
|
+
marginBottom: 20
|
|
4071
|
+
};
|
|
4030
4072
|
var depositCardStyle = (tokens) => ({
|
|
4031
4073
|
background: tokens.bgInput,
|
|
4032
4074
|
border: `1px solid ${tokens.border}`,
|
|
4033
4075
|
borderRadius: tokens.radiusLg,
|
|
4034
|
-
padding: "16px 20px"
|
|
4035
|
-
marginBottom: 20
|
|
4076
|
+
padding: "16px 20px"
|
|
4036
4077
|
});
|
|
4037
4078
|
var depositLabelStyle = (color) => ({
|
|
4038
4079
|
fontSize: "0.75rem",
|
|
@@ -4072,16 +4113,60 @@ var checkBadgeStyle2 = {
|
|
|
4072
4113
|
bottom: -1,
|
|
4073
4114
|
right: -3
|
|
4074
4115
|
};
|
|
4075
|
-
var
|
|
4076
|
-
|
|
4116
|
+
var walletBalanceRowStyle = (clickable) => ({
|
|
4117
|
+
display: "flex",
|
|
4118
|
+
alignItems: "center",
|
|
4119
|
+
gap: 8,
|
|
4120
|
+
background: "transparent",
|
|
4121
|
+
border: "none",
|
|
4122
|
+
padding: 0,
|
|
4123
|
+
cursor: clickable ? "pointer" : "default",
|
|
4124
|
+
fontFamily: "inherit",
|
|
4125
|
+
outline: "none"
|
|
4126
|
+
});
|
|
4127
|
+
var providerLogoStyle = {
|
|
4128
|
+
width: 18,
|
|
4129
|
+
height: 18,
|
|
4130
|
+
borderRadius: "50%",
|
|
4131
|
+
objectFit: "contain"
|
|
4077
4132
|
};
|
|
4078
|
-
var
|
|
4133
|
+
var providerFallbackStyle = (color) => ({
|
|
4134
|
+
width: 18,
|
|
4135
|
+
height: 18,
|
|
4136
|
+
borderRadius: "50%",
|
|
4137
|
+
display: "flex",
|
|
4138
|
+
alignItems: "center",
|
|
4139
|
+
justifyContent: "center",
|
|
4140
|
+
fontSize: "0.65rem",
|
|
4141
|
+
fontWeight: 700,
|
|
4142
|
+
color,
|
|
4143
|
+
flexShrink: 0
|
|
4144
|
+
});
|
|
4145
|
+
var walletBalanceStyle = (color) => ({
|
|
4146
|
+
fontSize: "0.9rem",
|
|
4147
|
+
fontWeight: 600,
|
|
4148
|
+
color
|
|
4149
|
+
});
|
|
4150
|
+
var accountDropdownOuterStyle = (tokens) => ({
|
|
4151
|
+
position: "absolute",
|
|
4152
|
+
top: "100%",
|
|
4153
|
+
left: 0,
|
|
4154
|
+
right: 0,
|
|
4155
|
+
marginTop: 4,
|
|
4156
|
+
background: tokens.bgCard,
|
|
4157
|
+
border: `1px solid ${tokens.border}`,
|
|
4158
|
+
borderRadius: tokens.radiusLg,
|
|
4159
|
+
boxShadow: tokens.shadowLg,
|
|
4160
|
+
zIndex: 50,
|
|
4161
|
+
padding: "12px 14px 14px"
|
|
4162
|
+
});
|
|
4163
|
+
var accountDropdownLabelStyle = (color) => ({
|
|
4079
4164
|
fontSize: "0.78rem",
|
|
4080
4165
|
fontWeight: 500,
|
|
4081
4166
|
color,
|
|
4082
4167
|
marginBottom: 8
|
|
4083
4168
|
});
|
|
4084
|
-
var
|
|
4169
|
+
var accountDropdownInnerStyle = (tokens) => ({
|
|
4085
4170
|
background: tokens.bgInput,
|
|
4086
4171
|
border: `1px solid ${tokens.border}`,
|
|
4087
4172
|
borderRadius: tokens.radiusLg,
|
|
@@ -4093,7 +4178,7 @@ var accountRowStyle = (tokens, isSelected) => ({
|
|
|
4093
4178
|
justifyContent: "space-between",
|
|
4094
4179
|
width: "100%",
|
|
4095
4180
|
padding: "14px 16px",
|
|
4096
|
-
background: "transparent",
|
|
4181
|
+
background: isSelected ? `${tokens.accent}10` : "transparent",
|
|
4097
4182
|
border: "none",
|
|
4098
4183
|
borderBottom: `1px solid ${tokens.border}`,
|
|
4099
4184
|
cursor: "pointer",
|