@dynamic-labs/sdk-react-core 0.19.0-alpha.4 → 0.19.0-alpha.6
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/CHANGELOG.md +23 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +9 -9
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.cjs +2 -14
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.js +2 -14
- package/src/lib/components/UserProfile/UserProfile.cjs +1 -1
- package/src/lib/components/UserProfile/UserProfile.js +1 -1
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +1 -1
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +1 -1
- package/src/lib/context/DynamicContext/helpers.cjs +5 -6
- package/src/lib/context/DynamicContext/helpers.d.ts +2 -2
- package/src/lib/context/DynamicContext/helpers.js +5 -6
- package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpContent.cjs +2 -1
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpContent.js +2 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.cjs +1 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.js +1 -1
- package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.cjs +6 -0
- package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.js +6 -0
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +4 -4
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +4 -4
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +7 -5
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +7 -5
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +14 -16
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +15 -17
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +1 -6
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +1 -6
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +15 -10
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +15 -10
- package/src/lib/views/AccountExistsView/AccountExistsView.cjs +2 -2
- package/src/lib/views/AccountExistsView/AccountExistsView.js +2 -2
- package/src/lib/views/LoginView/LoginView.cjs +70 -0
- package/src/lib/views/LoginView/LoginView.d.ts +2 -0
- package/src/lib/views/LoginView/LoginView.js +66 -0
- package/src/lib/views/{LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.cjs → LoginView/components/EmailSignIn/LoginEmailForm.cjs} +6 -11
- package/src/lib/views/LoginView/components/EmailSignIn/LoginEmailForm.d.ts +8 -0
- package/src/lib/views/{LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.js → LoginView/components/EmailSignIn/LoginEmailForm.js} +6 -11
- package/src/lib/views/LoginView/components/EmailSignIn/index.d.ts +1 -0
- package/src/lib/views/LoginView/components/LoginWidget.d.ts +5 -0
- package/src/lib/views/LoginView/components/WalletSignIn/ListItemButton/ListItemButton.cjs +65 -0
- package/src/lib/views/{LoginWithEmailView/components → LoginView/components/WalletSignIn}/ListItemButton/ListItemButton.d.ts +2 -1
- package/src/lib/views/LoginView/components/WalletSignIn/ListItemButton/ListItemButton.js +61 -0
- package/src/lib/views/{LoginWithEmailView/components/ListItemButton/ListItemButton.cjs → LoginView/components/WalletSignIn/WalletSignIn.cjs} +7 -19
- package/src/lib/views/LoginView/components/WalletSignIn/WalletSignIn.d.ts +7 -0
- package/src/lib/views/{LoginWithEmailView/components/ListItemButton/ListItemButton.js → LoginView/components/WalletSignIn/WalletSignIn.js} +8 -20
- package/src/lib/views/LoginView/components/WalletSignIn/WalletSimpleSignIn/WalletSimpleSignIn.cjs +47 -0
- package/src/lib/views/LoginView/components/WalletSignIn/WalletSimpleSignIn/WalletSimpleSignIn.d.ts +8 -0
- package/src/lib/views/LoginView/components/WalletSignIn/WalletSimpleSignIn/WalletSimpleSignIn.js +43 -0
- package/src/lib/views/LoginView/components/WalletSignIn/WalletSimpleSignIn/index.d.ts +1 -0
- package/src/lib/views/LoginView/components/WalletSignIn/index.d.ts +1 -0
- package/src/lib/views/LoginView/components/index.d.ts +3 -0
- package/src/lib/views/LoginView/index.d.ts +1 -0
- package/src/lib/views/LoginView/useLoginView.cjs +146 -0
- package/src/lib/views/LoginView/useLoginView.d.ts +6 -0
- package/src/lib/views/LoginView/useLoginView.js +141 -0
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +2 -2
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +2 -2
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.types.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.cjs +4 -3
- package/src/lib/views/viewToComponentMap.js +4 -3
- package/src/lib/views/LoginWithEmailView/LoginWithEmailView.cjs +0 -63
- package/src/lib/views/LoginWithEmailView/LoginWithEmailView.d.ts +0 -2
- package/src/lib/views/LoginWithEmailView/LoginWithEmailView.js +0 -59
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.d.ts +0 -7
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/index.d.ts +0 -1
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.cjs +0 -36
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.d.ts +0 -9
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.js +0 -31
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/index.d.ts +0 -1
- package/src/lib/views/LoginWithEmailView/index.d.ts +0 -1
- /package/src/lib/views/{LoginWithEmailView → LoginView}/components/SocialSignIn/SocialSignIn.cjs +0 -0
- /package/src/lib/views/{LoginWithEmailView → LoginView}/components/SocialSignIn/SocialSignIn.d.ts +0 -0
- /package/src/lib/views/{LoginWithEmailView → LoginView}/components/SocialSignIn/SocialSignIn.js +0 -0
- /package/src/lib/views/{LoginWithEmailView → LoginView}/components/SocialSignIn/index.d.ts +0 -0
- /package/src/lib/views/{LoginWithEmailView/components → LoginView/components/WalletSignIn}/ListItemButton/index.d.ts +0 -0
|
@@ -143,6 +143,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
143
143
|
if (!isValidMessage) {
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
+
setIsProcessing(true);
|
|
146
147
|
if (!((_c = providersWaitingOauthMessages.current) === null || _c === void 0 ? void 0 : _c[provider])) {
|
|
147
148
|
handleError(SocialOAuthErrorCode.SESSION_TIMEOUT, `Linking ${provider} account session timeout.`);
|
|
148
149
|
return;
|
|
@@ -197,15 +198,9 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
197
198
|
if (!providersWithoutWindowOpenerRefence.includes(provider)) {
|
|
198
199
|
// For provider that support window.opener, we need to clear all states/listeners when the window is closed
|
|
199
200
|
authWindowInterval.current = setInterval(() => {
|
|
200
|
-
var _a;
|
|
201
201
|
if (!(authWindow === null || authWindow === void 0 ? void 0 : authWindow.closed)) {
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
|
-
// window was closed by user, before completing oauth
|
|
205
|
-
if ((_a = providersWaitingOauthMessages.current) === null || _a === void 0 ? void 0 : _a[provider]) {
|
|
206
|
-
clearListeners();
|
|
207
|
-
handleError(SocialOAuthErrorCode.OAUTH_WINDOW_CLOSED, `Linking ${provider} account window closed.`);
|
|
208
|
-
}
|
|
209
204
|
clearInterval(authWindowInterval.current);
|
|
210
205
|
setIsProcessing(false);
|
|
211
206
|
});
|
|
@@ -90,21 +90,26 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
+
const handleWalletUsedError = (e) => {
|
|
94
|
+
var _a;
|
|
95
|
+
// This is a special case where the user is trying to link a wallet
|
|
96
|
+
// and the wallet is already linked and we don't want to kill the session.
|
|
97
|
+
setShowAuthFlow(true);
|
|
98
|
+
setView('wallet-used');
|
|
99
|
+
setIsSingleWalletAccount(false);
|
|
100
|
+
if (e.code === 'reassign_wallet_error') {
|
|
101
|
+
if ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.preventOrphanedAccounts) {
|
|
102
|
+
setView('wallet-cannot-be-transferred');
|
|
103
|
+
}
|
|
104
|
+
setIsSingleWalletAccount(true);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
93
107
|
const handleError = (e, walletConnector, address, oauth) => {
|
|
94
108
|
removeConnectedWalletsInfo();
|
|
95
109
|
// Ensure auth verification flag is taken down
|
|
96
110
|
setIsVerificationInProgress(false);
|
|
97
|
-
// This is a special case where the user is trying to link a wallet
|
|
98
|
-
// and the wallet is already linked and we don't want to kill the session.
|
|
99
111
|
if (e instanceof utils.WalletUsedError) {
|
|
100
|
-
|
|
101
|
-
setView('wallet-used');
|
|
102
|
-
setIsSingleWalletAccount(false);
|
|
103
|
-
if (e.code === 'reassign_wallet_error') {
|
|
104
|
-
setView('wallet-cannot-be-transferred');
|
|
105
|
-
setIsSingleWalletAccount(true);
|
|
106
|
-
}
|
|
107
|
-
return;
|
|
112
|
+
return handleWalletUsedError(e);
|
|
108
113
|
}
|
|
109
114
|
walletConnector.endSession();
|
|
110
115
|
if (e instanceof utils.ChainalysisError) {
|
|
@@ -86,21 +86,26 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
|
+
const handleWalletUsedError = (e) => {
|
|
90
|
+
var _a;
|
|
91
|
+
// This is a special case where the user is trying to link a wallet
|
|
92
|
+
// and the wallet is already linked and we don't want to kill the session.
|
|
93
|
+
setShowAuthFlow(true);
|
|
94
|
+
setView('wallet-used');
|
|
95
|
+
setIsSingleWalletAccount(false);
|
|
96
|
+
if (e.code === 'reassign_wallet_error') {
|
|
97
|
+
if ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.preventOrphanedAccounts) {
|
|
98
|
+
setView('wallet-cannot-be-transferred');
|
|
99
|
+
}
|
|
100
|
+
setIsSingleWalletAccount(true);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
89
103
|
const handleError = (e, walletConnector, address, oauth) => {
|
|
90
104
|
removeConnectedWalletsInfo();
|
|
91
105
|
// Ensure auth verification flag is taken down
|
|
92
106
|
setIsVerificationInProgress(false);
|
|
93
|
-
// This is a special case where the user is trying to link a wallet
|
|
94
|
-
// and the wallet is already linked and we don't want to kill the session.
|
|
95
107
|
if (e instanceof WalletUsedError) {
|
|
96
|
-
|
|
97
|
-
setView('wallet-used');
|
|
98
|
-
setIsSingleWalletAccount(false);
|
|
99
|
-
if (e.code === 'reassign_wallet_error') {
|
|
100
|
-
setView('wallet-cannot-be-transferred');
|
|
101
|
-
setIsSingleWalletAccount(true);
|
|
102
|
-
}
|
|
103
|
-
return;
|
|
108
|
+
return handleWalletUsedError(e);
|
|
104
109
|
}
|
|
105
110
|
walletConnector.endSession();
|
|
106
111
|
if (e instanceof ChainalysisError) {
|
|
@@ -53,7 +53,7 @@ require('../../components/InlineWidget/InlineWidget.cjs');
|
|
|
53
53
|
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
54
54
|
var capitalize = require('../../shared/utils/functions/capitalize/capitalize.cjs');
|
|
55
55
|
var SocialRedirectContext = require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
56
|
-
var
|
|
56
|
+
var LoginEmailForm = require('../LoginView/components/EmailSignIn/LoginEmailForm.cjs');
|
|
57
57
|
|
|
58
58
|
const AccountExistsView = () => {
|
|
59
59
|
const { existentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
@@ -71,7 +71,7 @@ const AccountExistsView = () => {
|
|
|
71
71
|
: '. Please log in with your email.';
|
|
72
72
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: ["It looks like an account already exists using ", jsxRuntime.jsx("strong", { children: email }), '', messageTrail] }));
|
|
73
73
|
};
|
|
74
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className: 'account-exists__container' }, { children: [jsxRuntime.jsx(iconic.UserProfileIcon, { className: 'account-exists__image' }), jsxRuntime.jsxs("div", Object.assign({ className: 'account-exists__main' }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'account-exists__content' }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'account-exists__content--secondary' }, { children: renderFullMessage() })) })), embeddedSocialSigninProvider ? (jsxRuntime.jsxs(IconListTile.IconListTile, Object.assign({ dataTestId: `inline-${embeddedSocialSigninProvider}`, onClick: () => handleNewLoging(), className: 'social-sign-in--tile' }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: findSocialIcon(embeddedSocialSigninProvider), isSpinning: socialProvider === embeddedSocialSigninProvider, iconSize: 32 }), jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with", ' ', capitalize.capitalize(embeddedSocialSigninProvider === null || embeddedSocialSigninProvider === void 0 ? void 0 : embeddedSocialSigninProvider.toString())] }))] }), embeddedSocialSigninProvider)) : (jsxRuntime.jsx(
|
|
74
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: 'account-exists__container' }, { children: [jsxRuntime.jsx(iconic.UserProfileIcon, { className: 'account-exists__image' }), jsxRuntime.jsxs("div", Object.assign({ className: 'account-exists__main' }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'account-exists__content' }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'account-exists__content--secondary' }, { children: renderFullMessage() })) })), embeddedSocialSigninProvider ? (jsxRuntime.jsxs(IconListTile.IconListTile, Object.assign({ dataTestId: `inline-${embeddedSocialSigninProvider}`, onClick: () => handleNewLoging(), className: 'social-sign-in--tile' }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: findSocialIcon(embeddedSocialSigninProvider), isSpinning: socialProvider === embeddedSocialSigninProvider, iconSize: 32 }), jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with", ' ', capitalize.capitalize(embeddedSocialSigninProvider === null || embeddedSocialSigninProvider === void 0 ? void 0 : embeddedSocialSigninProvider.toString())] }))] }), embeddedSocialSigninProvider)) : (jsxRuntime.jsx(LoginEmailForm.LoginEmailForm, { isLoading: false, currentEmail: email }))] }))] })));
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
exports.AccountExistsView = AccountExistsView;
|
|
@@ -49,7 +49,7 @@ import '../../components/InlineWidget/InlineWidget.js';
|
|
|
49
49
|
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
50
50
|
import { capitalize } from '../../shared/utils/functions/capitalize/capitalize.js';
|
|
51
51
|
import { useSocialRedirectContext } from '../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
52
|
-
import {
|
|
52
|
+
import { LoginEmailForm } from '../LoginView/components/EmailSignIn/LoginEmailForm.js';
|
|
53
53
|
|
|
54
54
|
const AccountExistsView = () => {
|
|
55
55
|
const { existentAccountData } = useAccountExistsContext();
|
|
@@ -67,7 +67,7 @@ const AccountExistsView = () => {
|
|
|
67
67
|
: '. Please log in with your email.';
|
|
68
68
|
return (jsxs(Fragment, { children: ["It looks like an account already exists using ", jsx("strong", { children: email }), '', messageTrail] }));
|
|
69
69
|
};
|
|
70
|
-
return (jsxs("div", Object.assign({ className: 'account-exists__container' }, { children: [jsx(UserProfileIcon, { className: 'account-exists__image' }), jsxs("div", Object.assign({ className: 'account-exists__main' }, { children: [jsx("div", Object.assign({ className: 'account-exists__content' }, { children: jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'account-exists__content--secondary' }, { children: renderFullMessage() })) })), embeddedSocialSigninProvider ? (jsxs(IconListTile, Object.assign({ dataTestId: `inline-${embeddedSocialSigninProvider}`, onClick: () => handleNewLoging(), className: 'social-sign-in--tile' }, { children: [jsx(IconWithSpinner, { Icon: findSocialIcon(embeddedSocialSigninProvider), isSpinning: socialProvider === embeddedSocialSigninProvider, iconSize: 32 }), jsxs(Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with", ' ', capitalize(embeddedSocialSigninProvider === null || embeddedSocialSigninProvider === void 0 ? void 0 : embeddedSocialSigninProvider.toString())] }))] }), embeddedSocialSigninProvider)) : (jsx(
|
|
70
|
+
return (jsxs("div", Object.assign({ className: 'account-exists__container' }, { children: [jsx(UserProfileIcon, { className: 'account-exists__image' }), jsxs("div", Object.assign({ className: 'account-exists__main' }, { children: [jsx("div", Object.assign({ className: 'account-exists__content' }, { children: jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'account-exists__content--secondary' }, { children: renderFullMessage() })) })), embeddedSocialSigninProvider ? (jsxs(IconListTile, Object.assign({ dataTestId: `inline-${embeddedSocialSigninProvider}`, onClick: () => handleNewLoging(), className: 'social-sign-in--tile' }, { children: [jsx(IconWithSpinner, { Icon: findSocialIcon(embeddedSocialSigninProvider), isSpinning: socialProvider === embeddedSocialSigninProvider, iconSize: 32 }), jsxs(Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with", ' ', capitalize(embeddedSocialSigninProvider === null || embeddedSocialSigninProvider === void 0 ? void 0 : embeddedSocialSigninProvider.toString())] }))] }), embeddedSocialSigninProvider)) : (jsx(LoginEmailForm, { isLoading: false, currentEmail: email }))] }))] })));
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
export { AccountExistsView };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var Divider = require('../../components/Divider/Divider.cjs');
|
|
8
|
+
var ErrorContext = require('../../context/ErrorContext/ErrorContext.cjs');
|
|
9
|
+
var ErrorContainer = require('../../components/ErrorContainer/ErrorContainer.cjs');
|
|
10
|
+
var LoadingContext = require('../../context/LoadingContext/LoadingContext.cjs');
|
|
11
|
+
var useAuthLayoutChecks = require('../../utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs');
|
|
12
|
+
var classNames = require('../../utils/functions/classNames/classNames.cjs');
|
|
13
|
+
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
14
|
+
var WalletList = require('../WalletList/WalletList.cjs');
|
|
15
|
+
var SocialSignIn = require('./components/SocialSignIn/SocialSignIn.cjs');
|
|
16
|
+
var WalletSignIn = require('./components/WalletSignIn/WalletSignIn.cjs');
|
|
17
|
+
var LoginEmailForm = require('./components/EmailSignIn/LoginEmailForm.cjs');
|
|
18
|
+
var useLoginView = require('./useLoginView.cjs');
|
|
19
|
+
|
|
20
|
+
const LoginView = () => {
|
|
21
|
+
const { error } = ErrorContext.useErrorContext();
|
|
22
|
+
const { loading } = LoadingContext.useLoadingContext();
|
|
23
|
+
const { showToSFooter } = useAuthLayoutChecks.useAuthLayoutChecks();
|
|
24
|
+
const { view, setView } = ViewContext.useViewContext();
|
|
25
|
+
const { isWalletOnly, logingViewSections } = useLoginView.useLoginView();
|
|
26
|
+
const [showWalletList, setShowWalletList] = React.useState(isWalletOnly);
|
|
27
|
+
const [isLoading, setIsLoading] = React.useState(loading);
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
// toolkit log in with email was set to false
|
|
30
|
+
if (isWalletOnly) {
|
|
31
|
+
setView('login-with-wallet-only');
|
|
32
|
+
setShowWalletList(true);
|
|
33
|
+
}
|
|
34
|
+
// returning from 'View all wallets' button
|
|
35
|
+
if (!isWalletOnly && view === 'login-with-email-or-wallet') {
|
|
36
|
+
setShowWalletList(false);
|
|
37
|
+
}
|
|
38
|
+
// toolkit log in with email was set back to true
|
|
39
|
+
if (!isWalletOnly &&
|
|
40
|
+
(!showWalletList || view === 'login-with-wallet-only')) {
|
|
41
|
+
setView('login-with-email-or-wallet');
|
|
42
|
+
setShowWalletList(false);
|
|
43
|
+
}
|
|
44
|
+
}, [isWalletOnly, view]);
|
|
45
|
+
const renderViewSections = React.useMemo(() => logingViewSections.map((viewSection, index) => {
|
|
46
|
+
switch (viewSection.type) {
|
|
47
|
+
case 'separator':
|
|
48
|
+
return (jsxRuntime.jsx(Divider.Divider, { text: viewSection.label }, `${viewSection.type}_${index}`));
|
|
49
|
+
case 'email':
|
|
50
|
+
return (jsxRuntime.jsx(LoginEmailForm.LoginEmailForm, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading }, `${viewSection.type}_${index}`));
|
|
51
|
+
case 'wallet':
|
|
52
|
+
return (jsxRuntime.jsx(WalletSignIn.WalletSignIn, { numberOfItensToShow: viewSection.numOfItemsToDisplay || 0, onSubmit: () => {
|
|
53
|
+
setView('login-with-email-or-wallet-full-wallet-list'); // this view is just to show the back button
|
|
54
|
+
setShowWalletList(true);
|
|
55
|
+
}, isLoading: isLoading }, `${viewSection.type}_${index}`));
|
|
56
|
+
case 'social':
|
|
57
|
+
return jsxRuntime.jsx(SocialSignIn.SocialSignIn, {}, `${viewSection.type}_${index}`);
|
|
58
|
+
default:
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}), [logingViewSections, isLoading, setView]);
|
|
62
|
+
if (showWalletList) {
|
|
63
|
+
return jsxRuntime.jsx(WalletList.WalletList, {});
|
|
64
|
+
}
|
|
65
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: 'login-with-email__container' }, { children: [error && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: error }), jsxRuntime.jsx("div", Object.assign({ className: classNames.classNames('login-with-email__scroll', {
|
|
66
|
+
'login-with-email__scroll--with-footer': showToSFooter,
|
|
67
|
+
}), "data-testid": 'login-with-email-scroll' }, { children: renderViewSections }))] })));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.LoginView = LoginView;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
3
|
+
import { Divider } from '../../components/Divider/Divider.js';
|
|
4
|
+
import { useErrorContext } from '../../context/ErrorContext/ErrorContext.js';
|
|
5
|
+
import { ErrorContainer } from '../../components/ErrorContainer/ErrorContainer.js';
|
|
6
|
+
import { useLoadingContext } from '../../context/LoadingContext/LoadingContext.js';
|
|
7
|
+
import { useAuthLayoutChecks } from '../../utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js';
|
|
8
|
+
import { classNames } from '../../utils/functions/classNames/classNames.js';
|
|
9
|
+
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
10
|
+
import { WalletList } from '../WalletList/WalletList.js';
|
|
11
|
+
import { SocialSignIn } from './components/SocialSignIn/SocialSignIn.js';
|
|
12
|
+
import { WalletSignIn } from './components/WalletSignIn/WalletSignIn.js';
|
|
13
|
+
import { LoginEmailForm } from './components/EmailSignIn/LoginEmailForm.js';
|
|
14
|
+
import { useLoginView } from './useLoginView.js';
|
|
15
|
+
|
|
16
|
+
const LoginView = () => {
|
|
17
|
+
const { error } = useErrorContext();
|
|
18
|
+
const { loading } = useLoadingContext();
|
|
19
|
+
const { showToSFooter } = useAuthLayoutChecks();
|
|
20
|
+
const { view, setView } = useViewContext();
|
|
21
|
+
const { isWalletOnly, logingViewSections } = useLoginView();
|
|
22
|
+
const [showWalletList, setShowWalletList] = useState(isWalletOnly);
|
|
23
|
+
const [isLoading, setIsLoading] = useState(loading);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
// toolkit log in with email was set to false
|
|
26
|
+
if (isWalletOnly) {
|
|
27
|
+
setView('login-with-wallet-only');
|
|
28
|
+
setShowWalletList(true);
|
|
29
|
+
}
|
|
30
|
+
// returning from 'View all wallets' button
|
|
31
|
+
if (!isWalletOnly && view === 'login-with-email-or-wallet') {
|
|
32
|
+
setShowWalletList(false);
|
|
33
|
+
}
|
|
34
|
+
// toolkit log in with email was set back to true
|
|
35
|
+
if (!isWalletOnly &&
|
|
36
|
+
(!showWalletList || view === 'login-with-wallet-only')) {
|
|
37
|
+
setView('login-with-email-or-wallet');
|
|
38
|
+
setShowWalletList(false);
|
|
39
|
+
}
|
|
40
|
+
}, [isWalletOnly, view]);
|
|
41
|
+
const renderViewSections = useMemo(() => logingViewSections.map((viewSection, index) => {
|
|
42
|
+
switch (viewSection.type) {
|
|
43
|
+
case 'separator':
|
|
44
|
+
return (jsx(Divider, { text: viewSection.label }, `${viewSection.type}_${index}`));
|
|
45
|
+
case 'email':
|
|
46
|
+
return (jsx(LoginEmailForm, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading }, `${viewSection.type}_${index}`));
|
|
47
|
+
case 'wallet':
|
|
48
|
+
return (jsx(WalletSignIn, { numberOfItensToShow: viewSection.numOfItemsToDisplay || 0, onSubmit: () => {
|
|
49
|
+
setView('login-with-email-or-wallet-full-wallet-list'); // this view is just to show the back button
|
|
50
|
+
setShowWalletList(true);
|
|
51
|
+
}, isLoading: isLoading }, `${viewSection.type}_${index}`));
|
|
52
|
+
case 'social':
|
|
53
|
+
return jsx(SocialSignIn, {}, `${viewSection.type}_${index}`);
|
|
54
|
+
default:
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}), [logingViewSections, isLoading, setView]);
|
|
58
|
+
if (showWalletList) {
|
|
59
|
+
return jsx(WalletList, {});
|
|
60
|
+
}
|
|
61
|
+
return (jsxs("div", Object.assign({ className: 'login-with-email__container' }, { children: [error && jsx(ErrorContainer, { children: error }), jsx("div", Object.assign({ className: classNames('login-with-email__scroll', {
|
|
62
|
+
'login-with-email__scroll--with-footer': showToSFooter,
|
|
63
|
+
}), "data-testid": 'login-with-email-scroll' }, { children: renderViewSections }))] })));
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { LoginView };
|
|
@@ -48,14 +48,12 @@ require('../../../../components/Popper/Popper/Popper.cjs');
|
|
|
48
48
|
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
49
49
|
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
50
50
|
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
51
|
-
var LoadingContext = require('../../../../context/LoadingContext/LoadingContext.cjs');
|
|
52
51
|
var useEmailProvider = require('../../../../utils/hooks/useEmailProvider/useEmailProvider.cjs');
|
|
53
52
|
|
|
54
53
|
const EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
|
55
|
-
const
|
|
54
|
+
const LoginEmailForm = ({ isLoading: isExternalLoading, onSubmit, onSubmitError, currentEmail, }) => {
|
|
56
55
|
var _a;
|
|
57
56
|
const { environmentId, wallets, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
58
|
-
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
59
57
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
60
58
|
const [emailInput, setEmailInput] = React.useState(currentEmail !== null && currentEmail !== void 0 ? currentEmail : '');
|
|
61
59
|
const [emailError, setEmailError] = React.useState(false);
|
|
@@ -65,13 +63,12 @@ const LoginWithEmailForm = ({ currentEmail }) => {
|
|
|
65
63
|
const { handleEmailOnlyLoginSubmit, submitEmail, isEmailProviderLoading } = useEmailProvider.useEmailProvider({
|
|
66
64
|
emailWalletConnector,
|
|
67
65
|
});
|
|
68
|
-
const isLoading = React.useMemo(() => isEmailProviderLoading ||
|
|
66
|
+
const isLoading = React.useMemo(() => isEmailProviderLoading || isExternalLoading, [isEmailProviderLoading, isExternalLoading]);
|
|
69
67
|
const handleEmailOnChangeEvent = (event) => {
|
|
70
68
|
const { value } = event.currentTarget;
|
|
71
69
|
setEmailInput(value);
|
|
72
70
|
};
|
|
73
71
|
const isInjectedWalletProviderEnabled = emailWalletConnector !== undefined;
|
|
74
|
-
const onChangeHandler = handleEmailOnChangeEvent;
|
|
75
72
|
const emailInputSuffixIcon = (jsxRuntime.jsx(IconButton.IconButton, Object.assign({ "data-testid": 'email_submit_button', type: 'submit', className: `icon-button${((_a = emailInput === null || emailInput === void 0 ? void 0 : emailInput.trim()) === null || _a === void 0 ? void 0 : _a.length) ? '--visible' : ''}`, disabled: isLoading }, { children: jsxRuntime.jsx(arrowRight.ReactComponent, {}) })));
|
|
76
73
|
const handleSubmit = (e) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
77
74
|
e.preventDefault();
|
|
@@ -80,7 +77,7 @@ const LoginWithEmailForm = ({ currentEmail }) => {
|
|
|
80
77
|
return;
|
|
81
78
|
}
|
|
82
79
|
try {
|
|
83
|
-
|
|
80
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit();
|
|
84
81
|
if (isInjectedWalletProviderEnabled &&
|
|
85
82
|
(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.confirmEmailProviderForVerify)) {
|
|
86
83
|
// see: https://linear.app/dynamic-labs/issue/DYN-2517
|
|
@@ -103,14 +100,12 @@ const LoginWithEmailForm = ({ currentEmail }) => {
|
|
|
103
100
|
catch (error) {
|
|
104
101
|
logger.logger.debug(error);
|
|
105
102
|
setErrorMessage(error.code);
|
|
106
|
-
|
|
107
|
-
finally {
|
|
108
|
-
setLoading(false);
|
|
103
|
+
onSubmitError === null || onSubmitError === void 0 ? void 0 : onSubmitError();
|
|
109
104
|
}
|
|
110
105
|
});
|
|
111
106
|
// social sign in currently coupled to email... might be better to decouple
|
|
112
|
-
return (jsxRuntime.jsx("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: jsxRuntime.jsx(Input.Input, { id: 'email_field', value: emailInput, onChange:
|
|
107
|
+
return (jsxRuntime.jsx("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: jsxRuntime.jsx(Input.Input, { id: 'email_field', value: emailInput, onChange: handleEmailOnChangeEvent, label: 'Enter your email', error: emailError, message: emailError && 'Please enter a valid email address', suffix: emailInputSuffixIcon, disabled: isLoading }) })));
|
|
113
108
|
};
|
|
114
109
|
|
|
115
110
|
exports.EMAIL_REGEX = EMAIL_REGEX;
|
|
116
|
-
exports.
|
|
111
|
+
exports.LoginEmailForm = LoginEmailForm;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { LoginWidgetProps } from '../LoginWidget';
|
|
3
|
+
export declare const EMAIL_REGEX: RegExp;
|
|
4
|
+
interface Props extends LoginWidgetProps {
|
|
5
|
+
currentEmail?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const LoginEmailForm: React.FC<Props>;
|
|
8
|
+
export {};
|
|
@@ -44,14 +44,12 @@ import '../../../../components/Popper/Popper/Popper.js';
|
|
|
44
44
|
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
45
45
|
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
46
46
|
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
47
|
-
import { useLoadingContext } from '../../../../context/LoadingContext/LoadingContext.js';
|
|
48
47
|
import { useEmailProvider } from '../../../../utils/hooks/useEmailProvider/useEmailProvider.js';
|
|
49
48
|
|
|
50
49
|
const EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
|
51
|
-
const
|
|
50
|
+
const LoginEmailForm = ({ isLoading: isExternalLoading, onSubmit, onSubmitError, currentEmail, }) => {
|
|
52
51
|
var _a;
|
|
53
52
|
const { environmentId, wallets, projectSettings } = useInternalDynamicContext();
|
|
54
|
-
const { loading, setLoading } = useLoadingContext();
|
|
55
53
|
const { setErrorMessage } = useErrorContext();
|
|
56
54
|
const [emailInput, setEmailInput] = useState(currentEmail !== null && currentEmail !== void 0 ? currentEmail : '');
|
|
57
55
|
const [emailError, setEmailError] = useState(false);
|
|
@@ -61,13 +59,12 @@ const LoginWithEmailForm = ({ currentEmail }) => {
|
|
|
61
59
|
const { handleEmailOnlyLoginSubmit, submitEmail, isEmailProviderLoading } = useEmailProvider({
|
|
62
60
|
emailWalletConnector,
|
|
63
61
|
});
|
|
64
|
-
const isLoading = useMemo(() => isEmailProviderLoading ||
|
|
62
|
+
const isLoading = useMemo(() => isEmailProviderLoading || isExternalLoading, [isEmailProviderLoading, isExternalLoading]);
|
|
65
63
|
const handleEmailOnChangeEvent = (event) => {
|
|
66
64
|
const { value } = event.currentTarget;
|
|
67
65
|
setEmailInput(value);
|
|
68
66
|
};
|
|
69
67
|
const isInjectedWalletProviderEnabled = emailWalletConnector !== undefined;
|
|
70
|
-
const onChangeHandler = handleEmailOnChangeEvent;
|
|
71
68
|
const emailInputSuffixIcon = (jsx(IconButton, Object.assign({ "data-testid": 'email_submit_button', type: 'submit', className: `icon-button${((_a = emailInput === null || emailInput === void 0 ? void 0 : emailInput.trim()) === null || _a === void 0 ? void 0 : _a.length) ? '--visible' : ''}`, disabled: isLoading }, { children: jsx(SvgArrowRight, {}) })));
|
|
72
69
|
const handleSubmit = (e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
70
|
e.preventDefault();
|
|
@@ -76,7 +73,7 @@ const LoginWithEmailForm = ({ currentEmail }) => {
|
|
|
76
73
|
return;
|
|
77
74
|
}
|
|
78
75
|
try {
|
|
79
|
-
|
|
76
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit();
|
|
80
77
|
if (isInjectedWalletProviderEnabled &&
|
|
81
78
|
(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.confirmEmailProviderForVerify)) {
|
|
82
79
|
// see: https://linear.app/dynamic-labs/issue/DYN-2517
|
|
@@ -99,13 +96,11 @@ const LoginWithEmailForm = ({ currentEmail }) => {
|
|
|
99
96
|
catch (error) {
|
|
100
97
|
logger.debug(error);
|
|
101
98
|
setErrorMessage(error.code);
|
|
102
|
-
|
|
103
|
-
finally {
|
|
104
|
-
setLoading(false);
|
|
99
|
+
onSubmitError === null || onSubmitError === void 0 ? void 0 : onSubmitError();
|
|
105
100
|
}
|
|
106
101
|
});
|
|
107
102
|
// social sign in currently coupled to email... might be better to decouple
|
|
108
|
-
return (jsx("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: jsx(Input, { id: 'email_field', value: emailInput, onChange:
|
|
103
|
+
return (jsx("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: jsx(Input, { id: 'email_field', value: emailInput, onChange: handleEmailOnChangeEvent, label: 'Enter your email', error: emailError, message: emailError && 'Please enter a valid email address', suffix: emailInputSuffixIcon, disabled: isLoading }) })));
|
|
109
104
|
};
|
|
110
105
|
|
|
111
|
-
export { EMAIL_REGEX,
|
|
106
|
+
export { EMAIL_REGEX, LoginEmailForm };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LoginEmailForm } from './LoginEmailForm';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
require('@dynamic-labs/iconic');
|
|
8
|
+
require('../../../../../context/ViewContext/ViewContext.cjs');
|
|
9
|
+
var stroke = require('../../../../../shared/assets/stroke.cjs');
|
|
10
|
+
var classNames = require('../../../../../utils/functions/classNames/classNames.cjs');
|
|
11
|
+
require('@dynamic-labs/sdk-api');
|
|
12
|
+
require('../../../../../shared/logger.cjs');
|
|
13
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
14
|
+
require('@dynamic-labs/wallet-book');
|
|
15
|
+
require('@dynamic-labs/utils');
|
|
16
|
+
require('../../../../../utils/constants/colors.cjs');
|
|
17
|
+
require('../../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
|
+
require('ethers');
|
|
19
|
+
require('../../../../../shared/consts/index.cjs');
|
|
20
|
+
require('../../../../../context/DynamicContext/DynamicContext.cjs');
|
|
21
|
+
require('@dynamic-labs/multi-wallet');
|
|
22
|
+
require('../../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
23
|
+
require('../../../../../context/ThemeContext/ThemeContext.cjs');
|
|
24
|
+
var Icon = require('../../../../../components/Icon/Icon.cjs');
|
|
25
|
+
require('react-dom');
|
|
26
|
+
require('react-focus-lock');
|
|
27
|
+
require('../../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
28
|
+
require('../../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
29
|
+
require('../../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
30
|
+
require('../../../../../config/ApiEndpoint.cjs');
|
|
31
|
+
require('@dynamic-labs/rpc-providers');
|
|
32
|
+
require('../../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
|
|
33
|
+
require('../../../../../context/ErrorContext/ErrorContext.cjs');
|
|
34
|
+
require('../../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
35
|
+
require('../../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
36
|
+
require('../../../../../components/IconButton/IconButton.cjs');
|
|
37
|
+
require('../../../../../components/Alert/Alert.cjs');
|
|
38
|
+
require('formik');
|
|
39
|
+
require('yup');
|
|
40
|
+
require('../../../../CollectUserDataView/fieldsConfig.cjs');
|
|
41
|
+
require('../../../../../context/MockContext/MockContext.cjs');
|
|
42
|
+
require('../../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
43
|
+
require('../../../../../context/EmailVerificationContext/EmailVerificationContext.cjs');
|
|
44
|
+
require('@dynamic-labs/types');
|
|
45
|
+
require('../../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
|
|
46
|
+
require('../../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
47
|
+
var ListTile = require('../../../../../components/ListTile/ListTile.cjs');
|
|
48
|
+
require('../../../../../components/Popper/Popper/Popper.cjs');
|
|
49
|
+
require('../../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
50
|
+
require('../../../../../components/InlineWidget/InlineWidget.cjs');
|
|
51
|
+
require('../../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
52
|
+
var Badge = require('../../../../../components/Badge/Badge.cjs');
|
|
53
|
+
|
|
54
|
+
const ListItemButton = ({ text, onClick, numberOfWallets, disabled = false, }) => {
|
|
55
|
+
const numberOfWalletsText = React.useMemo(() => {
|
|
56
|
+
if (numberOfWallets <= 10) {
|
|
57
|
+
return numberOfWallets;
|
|
58
|
+
}
|
|
59
|
+
return `+${Math.floor(numberOfWallets / 10) * 10}`;
|
|
60
|
+
}, [numberOfWallets]);
|
|
61
|
+
const trailing = (jsxRuntime.jsxs("div", Object.assign({ className: 'list-item-button__trailing' }, { children: [jsxRuntime.jsx("div", Object.assign({ className: classNames.classNames('list-item-button__trailing-child', 'list-item-button__trailing-label') }, { children: jsxRuntime.jsx(Badge.Badge, { text: `${numberOfWalletsText} available` }) })), jsxRuntime.jsx("div", Object.assign({ className: classNames.classNames('list-item-button__trailing-child', 'list-item-button__trailing-icon') }, { children: jsxRuntime.jsx(Icon.Icon, Object.assign({ color: 'text-primary', size: 'small' }, { children: jsxRuntime.jsx(stroke.ReactComponent, {}) })) }))] })));
|
|
62
|
+
return (jsxRuntime.jsx(ListTile.ListTile, Object.assign({ trailing: trailing, onClick: onClick, className: 'list-item-button', disabled: disabled }, { children: text })));
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.ListItemButton = ListItemButton;
|
|
@@ -3,6 +3,7 @@ type Props = {
|
|
|
3
3
|
numberOfWallets: number;
|
|
4
4
|
onClick: VoidFunction;
|
|
5
5
|
text: string;
|
|
6
|
+
disabled?: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare const ListItemButton: ({ text, onClick, numberOfWallets }: Props) => JSX.Element;
|
|
8
|
+
export declare const ListItemButton: ({ text, onClick, numberOfWallets, disabled, }: Props) => JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import '@dynamic-labs/iconic';
|
|
4
|
+
import '../../../../../context/ViewContext/ViewContext.js';
|
|
5
|
+
import { ReactComponent as SvgStroke } from '../../../../../shared/assets/stroke.js';
|
|
6
|
+
import { classNames } from '../../../../../utils/functions/classNames/classNames.js';
|
|
7
|
+
import '@dynamic-labs/sdk-api';
|
|
8
|
+
import '../../../../../shared/logger.js';
|
|
9
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
10
|
+
import '@dynamic-labs/wallet-book';
|
|
11
|
+
import '@dynamic-labs/utils';
|
|
12
|
+
import '../../../../../utils/constants/colors.js';
|
|
13
|
+
import '../../../../../shared/utils/classes/storage/localStorage.js';
|
|
14
|
+
import 'ethers';
|
|
15
|
+
import '../../../../../shared/consts/index.js';
|
|
16
|
+
import '../../../../../context/DynamicContext/DynamicContext.js';
|
|
17
|
+
import '@dynamic-labs/multi-wallet';
|
|
18
|
+
import '../../../../../components/ShadowDOM/ShadowDOM.js';
|
|
19
|
+
import '../../../../../context/ThemeContext/ThemeContext.js';
|
|
20
|
+
import { Icon } from '../../../../../components/Icon/Icon.js';
|
|
21
|
+
import 'react-dom';
|
|
22
|
+
import 'react-focus-lock';
|
|
23
|
+
import '../../../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
24
|
+
import '../../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
25
|
+
import '../../../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
26
|
+
import '../../../../../config/ApiEndpoint.js';
|
|
27
|
+
import '@dynamic-labs/rpc-providers';
|
|
28
|
+
import '../../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
|
|
29
|
+
import '../../../../../context/ErrorContext/ErrorContext.js';
|
|
30
|
+
import '../../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
31
|
+
import '../../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
32
|
+
import '../../../../../components/IconButton/IconButton.js';
|
|
33
|
+
import '../../../../../components/Alert/Alert.js';
|
|
34
|
+
import 'formik';
|
|
35
|
+
import 'yup';
|
|
36
|
+
import '../../../../CollectUserDataView/fieldsConfig.js';
|
|
37
|
+
import '../../../../../context/MockContext/MockContext.js';
|
|
38
|
+
import '../../../../../context/CaptchaContext/CaptchaContext.js';
|
|
39
|
+
import '../../../../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
40
|
+
import '@dynamic-labs/types';
|
|
41
|
+
import '../../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
42
|
+
import '../../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
43
|
+
import { ListTile } from '../../../../../components/ListTile/ListTile.js';
|
|
44
|
+
import '../../../../../components/Popper/Popper/Popper.js';
|
|
45
|
+
import '../../../../../components/Popper/PopperContext/PopperContext.js';
|
|
46
|
+
import '../../../../../components/InlineWidget/InlineWidget.js';
|
|
47
|
+
import '../../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
48
|
+
import { Badge } from '../../../../../components/Badge/Badge.js';
|
|
49
|
+
|
|
50
|
+
const ListItemButton = ({ text, onClick, numberOfWallets, disabled = false, }) => {
|
|
51
|
+
const numberOfWalletsText = useMemo(() => {
|
|
52
|
+
if (numberOfWallets <= 10) {
|
|
53
|
+
return numberOfWallets;
|
|
54
|
+
}
|
|
55
|
+
return `+${Math.floor(numberOfWallets / 10) * 10}`;
|
|
56
|
+
}, [numberOfWallets]);
|
|
57
|
+
const trailing = (jsxs("div", Object.assign({ className: 'list-item-button__trailing' }, { children: [jsx("div", Object.assign({ className: classNames('list-item-button__trailing-child', 'list-item-button__trailing-label') }, { children: jsx(Badge, { text: `${numberOfWalletsText} available` }) })), jsx("div", Object.assign({ className: classNames('list-item-button__trailing-child', 'list-item-button__trailing-icon') }, { children: jsx(Icon, Object.assign({ color: 'text-primary', size: 'small' }, { children: jsx(SvgStroke, {}) })) }))] })));
|
|
58
|
+
return (jsx(ListTile, Object.assign({ trailing: trailing, onClick: onClick, className: 'list-item-button', disabled: disabled }, { children: text })));
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { ListItemButton };
|