@dynamic-labs/sdk-react-core 0.19.0-alpha.4 → 0.19.0-alpha.5

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +9 -9
  5. package/src/lib/components/DynamicConnectButton/DynamicConnectButton.cjs +2 -14
  6. package/src/lib/components/DynamicConnectButton/DynamicConnectButton.js +2 -14
  7. package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -1
  8. package/src/lib/context/DynamicContext/DynamicContext.js +1 -1
  9. package/src/lib/context/DynamicContext/helpers.cjs +5 -6
  10. package/src/lib/context/DynamicContext/helpers.d.ts +2 -2
  11. package/src/lib/context/DynamicContext/helpers.js +5 -6
  12. package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
  13. package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpContent.cjs +2 -1
  14. package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpContent.js +2 -1
  15. package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.cjs +6 -0
  16. package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.js +6 -0
  17. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +7 -5
  18. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +7 -5
  19. package/src/lib/views/AccountExistsView/AccountExistsView.cjs +2 -2
  20. package/src/lib/views/AccountExistsView/AccountExistsView.js +2 -2
  21. package/src/lib/views/LoginView/LoginView.cjs +70 -0
  22. package/src/lib/views/LoginView/LoginView.d.ts +2 -0
  23. package/src/lib/views/LoginView/LoginView.js +66 -0
  24. package/src/lib/views/{LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.cjs → LoginView/components/EmailSignIn/LoginEmailForm.cjs} +6 -11
  25. package/src/lib/views/LoginView/components/EmailSignIn/LoginEmailForm.d.ts +8 -0
  26. package/src/lib/views/{LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.js → LoginView/components/EmailSignIn/LoginEmailForm.js} +6 -11
  27. package/src/lib/views/LoginView/components/EmailSignIn/index.d.ts +1 -0
  28. package/src/lib/views/LoginView/components/LoginWidget.d.ts +5 -0
  29. package/src/lib/views/LoginView/components/WalletSignIn/ListItemButton/ListItemButton.cjs +65 -0
  30. package/src/lib/views/{LoginWithEmailView/components → LoginView/components/WalletSignIn}/ListItemButton/ListItemButton.d.ts +2 -1
  31. package/src/lib/views/LoginView/components/WalletSignIn/ListItemButton/ListItemButton.js +61 -0
  32. package/src/lib/views/{LoginWithEmailView/components/ListItemButton/ListItemButton.cjs → LoginView/components/WalletSignIn/WalletSignIn.cjs} +7 -19
  33. package/src/lib/views/LoginView/components/WalletSignIn/WalletSignIn.d.ts +7 -0
  34. package/src/lib/views/{LoginWithEmailView/components/ListItemButton/ListItemButton.js → LoginView/components/WalletSignIn/WalletSignIn.js} +8 -20
  35. package/src/lib/views/LoginView/components/WalletSignIn/WalletSimpleSignIn/WalletSimpleSignIn.cjs +47 -0
  36. package/src/lib/views/LoginView/components/WalletSignIn/WalletSimpleSignIn/WalletSimpleSignIn.d.ts +8 -0
  37. package/src/lib/views/LoginView/components/WalletSignIn/WalletSimpleSignIn/WalletSimpleSignIn.js +43 -0
  38. package/src/lib/views/LoginView/components/WalletSignIn/WalletSimpleSignIn/index.d.ts +1 -0
  39. package/src/lib/views/LoginView/components/WalletSignIn/index.d.ts +1 -0
  40. package/src/lib/views/LoginView/components/index.d.ts +3 -0
  41. package/src/lib/views/LoginView/index.d.ts +1 -0
  42. package/src/lib/views/LoginView/useLoginView.cjs +137 -0
  43. package/src/lib/views/LoginView/useLoginView.d.ts +6 -0
  44. package/src/lib/views/LoginView/useLoginView.js +132 -0
  45. package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +2 -2
  46. package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +2 -2
  47. package/src/lib/views/WalletList/WalletListItem/WalletListItem.types.d.ts +1 -0
  48. package/src/lib/views/viewToComponentMap.cjs +4 -3
  49. package/src/lib/views/viewToComponentMap.js +4 -3
  50. package/src/lib/views/LoginWithEmailView/LoginWithEmailView.cjs +0 -63
  51. package/src/lib/views/LoginWithEmailView/LoginWithEmailView.d.ts +0 -2
  52. package/src/lib/views/LoginWithEmailView/LoginWithEmailView.js +0 -59
  53. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.d.ts +0 -7
  54. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/index.d.ts +0 -1
  55. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.cjs +0 -36
  56. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.d.ts +0 -9
  57. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.js +0 -31
  58. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/index.d.ts +0 -1
  59. package/src/lib/views/LoginWithEmailView/index.d.ts +0 -1
  60. /package/src/lib/views/{LoginWithEmailView → LoginView}/components/SocialSignIn/SocialSignIn.cjs +0 -0
  61. /package/src/lib/views/{LoginWithEmailView → LoginView}/components/SocialSignIn/SocialSignIn.d.ts +0 -0
  62. /package/src/lib/views/{LoginWithEmailView → LoginView}/components/SocialSignIn/SocialSignIn.js +0 -0
  63. /package/src/lib/views/{LoginWithEmailView → LoginView}/components/SocialSignIn/index.d.ts +0 -0
  64. /package/src/lib/views/{LoginWithEmailView/components → LoginView/components/WalletSignIn}/ListItemButton/index.d.ts +0 -0
@@ -0,0 +1,132 @@
1
+ import { useMemo } from 'react';
2
+ import { SdkViewType, SdkViewSectionType } from '@dynamic-labs/sdk-api';
3
+ import { useInternalDynamicContext } from '../../context/DynamicContext/useInternalDynamicContext.js';
4
+
5
+ const NUMBER_OF_WALLETS = 3;
6
+ const useLoginView = () => {
7
+ const { projectSettings, authorizationViewDisplayOrder, loginWithEmail, wallets, } = useInternalDynamicContext();
8
+ const isWalletOnly = useMemo(() => {
9
+ var _a, _b, _c, _d, _e, _f;
10
+ if (!projectSettings) {
11
+ return false;
12
+ }
13
+ // toolkit functionality overrides whatever is defined
14
+ if (!loginWithEmail) {
15
+ return true;
16
+ }
17
+ const loginView = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.views) === null || _b === void 0 ? void 0 : _b.find((view) => view.type === SdkViewType.Login);
18
+ // backwards compatibility for those that didn't set up login view sessions
19
+ if (!((_c = loginView === null || loginView === void 0 ? void 0 : loginView.sections) === null || _c === void 0 ? void 0 : _c.length)) {
20
+ return (!((_e = (_d = projectSettings.design) === null || _d === void 0 ? void 0 : _d.modal) === null || _e === void 0 ? void 0 : _e.emailOnly) &&
21
+ !((_f = projectSettings.providers) === null || _f === void 0 ? void 0 : _f.length));
22
+ }
23
+ return (loginView.sections.length === 1 && loginView.sections[0].type === 'wallet');
24
+ }, [projectSettings, loginWithEmail]);
25
+ /**
26
+ * build email and social view sections from project settings design.modal props - backwards compatibility
27
+ * @returns SdkViewSection[]
28
+ */
29
+ const getEmailViewSectionDefinition = () => {
30
+ var _a, _b, _c;
31
+ const loginViewSections = [
32
+ {
33
+ type: SdkViewSectionType.Email,
34
+ },
35
+ ];
36
+ if ((_c = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.socialSignIn) === null || _b === void 0 ? void 0 : _b.providers) === null || _c === void 0 ? void 0 : _c.length) {
37
+ const numOfProvidersToDisplay = projectSettings.sdk.socialSignIn.providers.filter((provider) => provider.enabled).length;
38
+ loginViewSections.push({
39
+ numOfItemsToDisplay: numOfProvidersToDisplay,
40
+ type: SdkViewSectionType.Social,
41
+ });
42
+ }
43
+ return loginViewSections;
44
+ };
45
+ // TODO: https://linear.app/dynamic-labs/issue/GVTY-212/rethink-or-implement-toolkit-template-for-email-wallet-order
46
+ /**
47
+ * remove wallet view section from projectSettings?.sdk?.views if no wallet defined
48
+ * @param sections
49
+ * @returns
50
+ */
51
+ const filterLoginViewSections = (sections) => {
52
+ if (wallets === null || wallets === void 0 ? void 0 : wallets.length) {
53
+ return sections;
54
+ }
55
+ return sections.filter((section) => section.type !== 'wallet');
56
+ };
57
+ const addSeparator = (index, loginItem) => {
58
+ var _a;
59
+ // if not the first index, no separator is needed
60
+ // if the first index but does not have wallets or providers,
61
+ // it'll show only one view section - no separator is needed
62
+ if (index !== 0 ||
63
+ !(wallets === null || wallets === void 0 ? void 0 : wallets.length) ||
64
+ !((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) === null || _a === void 0 ? void 0 : _a.length)) {
65
+ return [];
66
+ }
67
+ const label = loginItem === 'email' ? 'Or continue with a wallet' : 'Or continue with';
68
+ return [
69
+ {
70
+ label,
71
+ type: SdkViewSectionType.Separator,
72
+ },
73
+ ];
74
+ };
75
+ /**
76
+ * build login view sections array from project settings design.modal props - backwards compatibility
77
+ * @returns SdkViewSection[]
78
+ */
79
+ const buildLoginSections = () => {
80
+ let loginViewSections = [];
81
+ authorizationViewDisplayOrder === null || authorizationViewDisplayOrder === void 0 ? void 0 : authorizationViewDisplayOrder.forEach((loginItem, index) => {
82
+ var _a, _b, _c;
83
+ if (loginItem === 'email' && ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) === null || _a === void 0 ? void 0 : _a.length)) {
84
+ loginViewSections = loginViewSections.concat(getEmailViewSectionDefinition(),
85
+ // add separator if wallets defined
86
+ addSeparator(index, loginItem));
87
+ }
88
+ if (loginItem === 'wallet' && (wallets === null || wallets === void 0 ? void 0 : wallets.length)) {
89
+ // if showWalletsButton is true, it should show "Connec with Wallet" button
90
+ const numOfItemsToDisplay = ((_c = (_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _b === void 0 ? void 0 : _b.modal) === null || _c === void 0 ? void 0 : _c.showWalletsButton)
91
+ ? 0
92
+ : NUMBER_OF_WALLETS;
93
+ loginViewSections = loginViewSections.concat([
94
+ {
95
+ numOfItemsToDisplay,
96
+ type: SdkViewSectionType.Wallet,
97
+ },
98
+ ],
99
+ // add separator if email providers defined
100
+ addSeparator(index, loginItem));
101
+ }
102
+ });
103
+ return loginViewSections;
104
+ };
105
+ /**
106
+ * returns the login view sections to be displayed in order from projectSettings?.sdk?.views
107
+ * and has backwards compatibility with project settings design.modal props
108
+ */
109
+ const logingViewSections = useMemo(() => {
110
+ var _a, _b, _c, _d, _e;
111
+ const loginView = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.views) === null || _b === void 0 ? void 0 : _b.find((view) => view.type === SdkViewType.Login);
112
+ if ((_c = loginView === null || loginView === void 0 ? void 0 : loginView.sections) === null || _c === void 0 ? void 0 : _c.length) {
113
+ return filterLoginViewSections(loginView === null || loginView === void 0 ? void 0 : loginView.sections);
114
+ }
115
+ if ((_e = (_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _d === void 0 ? void 0 : _d.modal) === null || _e === void 0 ? void 0 : _e.emailOnly) {
116
+ return getEmailViewSectionDefinition();
117
+ }
118
+ return buildLoginSections();
119
+ }, [
120
+ projectSettings,
121
+ authorizationViewDisplayOrder,
122
+ getEmailViewSectionDefinition,
123
+ filterLoginViewSections,
124
+ buildLoginSections,
125
+ ]);
126
+ return {
127
+ isWalletOnly,
128
+ logingViewSections,
129
+ };
130
+ };
131
+
132
+ export { NUMBER_OF_WALLETS, useLoginView };
@@ -57,7 +57,7 @@ var Badge = require('../../../components/Badge/Badge.cjs');
57
57
  var isWalletGroup = require('../../../utils/functions/walletListBuilder/utils/isWalletGroup/isWalletGroup.cjs');
58
58
  var WalletGroupContext = require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
59
59
 
60
- const WalletListItem = ({ usingMultiWallet, wallet, onResetSearchValue, tile = ({ leading, name, onClick, trailing }) => (jsxRuntime.jsx(ListTile.ListTile, Object.assign({ leading: leading, trailing: trailing, onClick: onClick, className: 'wallet-list-item__tile', dataTestId: 'ListTile' }, { children: name }))), }) => {
60
+ const WalletListItem = ({ disabled = false, usingMultiWallet, wallet, onResetSearchValue, tile = ({ leading, name, onClick, trailing }) => (jsxRuntime.jsx(ListTile.ListTile, Object.assign({ leading: leading, trailing: trailing, onClick: onClick, className: 'wallet-list-item__tile', dataTestId: 'ListTile' }, { children: name }))), }) => {
61
61
  const { navigateToWalletGroup } = WalletGroupContext.useWalletGroupContext();
62
62
  const _isWalletGroup = isWalletGroup.isWalletGroup(wallet);
63
63
  const { walletBook: walletBook$1 } = walletBook.useWalletBookContext();
@@ -69,7 +69,7 @@ const WalletListItem = ({ usingMultiWallet, wallet, onResetSearchValue, tile = (
69
69
  const Tile = tile;
70
70
  const isComingSoon = label === 'Coming soon';
71
71
  const handleClick = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
72
- if (isComingSoon) {
72
+ if (isComingSoon || disabled) {
73
73
  return;
74
74
  }
75
75
  onResetSearchValue === null || onResetSearchValue === void 0 ? void 0 : onResetSearchValue('');
@@ -53,7 +53,7 @@ import { Badge } from '../../../components/Badge/Badge.js';
53
53
  import { isWalletGroup } from '../../../utils/functions/walletListBuilder/utils/isWalletGroup/isWalletGroup.js';
54
54
  import { useWalletGroupContext } from '../../../context/WalletGroupContext/WalletGroupContext.js';
55
55
 
56
- const WalletListItem = ({ usingMultiWallet, wallet, onResetSearchValue, tile = ({ leading, name, onClick, trailing }) => (jsx(ListTile, Object.assign({ leading: leading, trailing: trailing, onClick: onClick, className: 'wallet-list-item__tile', dataTestId: 'ListTile' }, { children: name }))), }) => {
56
+ const WalletListItem = ({ disabled = false, usingMultiWallet, wallet, onResetSearchValue, tile = ({ leading, name, onClick, trailing }) => (jsx(ListTile, Object.assign({ leading: leading, trailing: trailing, onClick: onClick, className: 'wallet-list-item__tile', dataTestId: 'ListTile' }, { children: name }))), }) => {
57
57
  const { navigateToWalletGroup } = useWalletGroupContext();
58
58
  const _isWalletGroup = isWalletGroup(wallet);
59
59
  const { walletBook } = useWalletBookContext();
@@ -65,7 +65,7 @@ const WalletListItem = ({ usingMultiWallet, wallet, onResetSearchValue, tile = (
65
65
  const Tile = tile;
66
66
  const isComingSoon = label === 'Coming soon';
67
67
  const handleClick = () => __awaiter(void 0, void 0, void 0, function* () {
68
- if (isComingSoon) {
68
+ if (isComingSoon || disabled) {
69
69
  return;
70
70
  }
71
71
  onResetSearchValue === null || onResetSearchValue === void 0 ? void 0 : onResetSearchValue('');
@@ -5,6 +5,7 @@ export type WalletListItemProps = {
5
5
  tile?: WalletListItemTile;
6
6
  usingMultiWallet: boolean;
7
7
  wallet: WalletOption;
8
+ disabled?: boolean;
8
9
  };
9
10
  export type WalletListItemComponent = (props: WalletListItemProps) => ReactElement;
10
11
  export type WalletListItemTileProps = {
@@ -10,7 +10,6 @@ var EmailConfirmationWaitingView = require('./EmailConfirmationWaitingView/Email
10
10
  var EmailUpdate = require('./EmailUpdate/EmailUpdate.cjs');
11
11
  var EmailVerification = require('./EmailVerification/EmailVerification.cjs');
12
12
  var EmailWalletOTPVerificationView = require('./EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs');
13
- var LoginWithEmailView = require('./LoginWithEmailView/LoginWithEmailView.cjs');
14
13
  var NetworkNotSupported = require('./NetworkNotSupported/NetworkNotSupported.cjs');
15
14
  var NetworkNotSupportedSwitchManual = require('./NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs');
16
15
  var NoQrNotInstalledView = require('./NoQrNotInstalledView/NoQrNotInstalledView.cjs');
@@ -31,6 +30,7 @@ var BridgeNextWalletConnectionView = require('./BridgeNextWalletConnectionView/B
31
30
  var AccountExistsView = require('./AccountExistsView/AccountExistsView.cjs');
32
31
  var MergeUserAccountsView = require('./MergeUserAccountsView/MergeUserAccountsView.cjs');
33
32
  var WalletCannotBeTransferredView = require('./WalletCannotBeTransferredView/WalletCannotBeTransferredView.cjs');
33
+ var LoginView = require('./LoginView/LoginView.cjs');
34
34
 
35
35
  const viewToComponentMap = {
36
36
  'account-exists': jsxRuntime.jsx(AccountExistsView.AccountExistsView, {}),
@@ -43,9 +43,10 @@ const viewToComponentMap = {
43
43
  'collect-user-data-login-with-email': jsxRuntime.jsx(CollectUserDataViewLoginWithEmail.CollectUserDataViewLoginWithEmail, {}),
44
44
  'email-wallet-otp-verification-view': jsxRuntime.jsx(EmailWalletOTPVerificationView.EmailWalletOTPVerificationView, {}),
45
45
  'gate-blocked-wallet': jsxRuntime.jsx(NoAccess.NoAccess, {}),
46
- 'login-with-email-or-wallet': jsxRuntime.jsx(LoginWithEmailView.LoginWithEmailView, {}),
47
- 'login-with-email-or-wallet-full-wallet-list': jsxRuntime.jsx(WalletList.WalletList, {}),
46
+ 'login-with-email-or-wallet': jsxRuntime.jsx(LoginView.LoginView, {}),
47
+ 'login-with-email-or-wallet-full-wallet-list': jsxRuntime.jsx(LoginView.LoginView, {}),
48
48
  'login-with-email-verification': jsxRuntime.jsx(EmailVerification.EmailVerification, {}),
49
+ 'login-with-wallet-only': jsxRuntime.jsx(LoginView.LoginView, {}),
49
50
  'merge-user-accounts': jsxRuntime.jsx(MergeUserAccountsView.MergeUserAccountsView, {}),
50
51
  'network-not-supported': jsxRuntime.jsx(NetworkNotSupported.NetworkNotSupported, {}),
51
52
  'network-not-supported-manual': jsxRuntime.jsx(NetworkNotSupportedSwitchManual.NetworkNotSupportedSwitchManual, {}),
@@ -6,7 +6,6 @@ import { EmailConfirmationWaitingView } from './EmailConfirmationWaitingView/Ema
6
6
  import { EmailUpdate } from './EmailUpdate/EmailUpdate.js';
7
7
  import { EmailVerification } from './EmailVerification/EmailVerification.js';
8
8
  import { EmailWalletOTPVerificationView } from './EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js';
9
- import { LoginWithEmailView } from './LoginWithEmailView/LoginWithEmailView.js';
10
9
  import { NetworkNotSupported } from './NetworkNotSupported/NetworkNotSupported.js';
11
10
  import { NetworkNotSupportedSwitchManual } from './NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js';
12
11
  import { NoQrNotInstalledView } from './NoQrNotInstalledView/NoQrNotInstalledView.js';
@@ -27,6 +26,7 @@ import { BridgeNextWalletConnectionView } from './BridgeNextWalletConnectionView
27
26
  import { AccountExistsView } from './AccountExistsView/AccountExistsView.js';
28
27
  import { MergeUserAccountsView } from './MergeUserAccountsView/MergeUserAccountsView.js';
29
28
  import { WalletCannotBeTransferredView } from './WalletCannotBeTransferredView/WalletCannotBeTransferredView.js';
29
+ import { LoginView } from './LoginView/LoginView.js';
30
30
 
31
31
  const viewToComponentMap = {
32
32
  'account-exists': jsx(AccountExistsView, {}),
@@ -39,9 +39,10 @@ const viewToComponentMap = {
39
39
  'collect-user-data-login-with-email': jsx(CollectUserDataViewLoginWithEmail, {}),
40
40
  'email-wallet-otp-verification-view': jsx(EmailWalletOTPVerificationView, {}),
41
41
  'gate-blocked-wallet': jsx(NoAccess, {}),
42
- 'login-with-email-or-wallet': jsx(LoginWithEmailView, {}),
43
- 'login-with-email-or-wallet-full-wallet-list': jsx(WalletList, {}),
42
+ 'login-with-email-or-wallet': jsx(LoginView, {}),
43
+ 'login-with-email-or-wallet-full-wallet-list': jsx(LoginView, {}),
44
44
  'login-with-email-verification': jsx(EmailVerification, {}),
45
+ 'login-with-wallet-only': jsx(LoginView, {}),
45
46
  'merge-user-accounts': jsx(MergeUserAccountsView, {}),
46
47
  'network-not-supported': jsx(NetworkNotSupported, {}),
47
48
  'network-not-supported-manual': jsx(NetworkNotSupportedSwitchManual, {}),
@@ -1,63 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var jsxRuntime = require('react/jsx-runtime');
6
- var walletBook = require('@dynamic-labs/wallet-book');
7
- var ErrorContext = require('../../context/ErrorContext/ErrorContext.cjs');
8
- require('@dynamic-labs/sdk-api');
9
- require('../../shared/logger.cjs');
10
- require('@dynamic-labs/iconic');
11
- require('@dynamic-labs/wallet-connector-core');
12
- require('../../context/ViewContext/ViewContext.cjs');
13
- require('react');
14
- var isDisplayOrderPriorityForWeb2 = require('../../shared/utils/functions/isDisplayOrderPriorityForWeb2/isDisplayOrderPriorityForWeb2.cjs');
15
- require('@dynamic-labs/utils');
16
- var localStorage$1 = require('../../utils/constants/localStorage.cjs');
17
- require('../../utils/constants/colors.cjs');
18
- var localStorage = require('../../shared/utils/classes/storage/localStorage.cjs');
19
- require('ethers');
20
- require('../../shared/consts/index.cjs');
21
- var ErrorContainer = require('../../components/ErrorContainer/ErrorContainer.cjs');
22
- var Divider = require('../../components/Divider/Divider.cjs');
23
- var useInternalDynamicContext = require('../../context/DynamicContext/useInternalDynamicContext.cjs');
24
- var classNames = require('../../utils/functions/classNames/classNames.cjs');
25
- var walletListBuilder = require('../../utils/functions/walletListBuilder/walletListBuilder.cjs');
26
- var SocialRedirectContext = require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
27
- var useAuthLayoutChecks = require('../../utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs');
28
- var LoginWithEmailForm = require('./components/LoginWithEmailForm/LoginWithEmailForm.cjs');
29
- var LoginWithEmailWalletList = require('./components/LoginWithEmailWalletList/LoginWithEmailWalletList.cjs');
30
- var SocialSignIn = require('./components/SocialSignIn/SocialSignIn.cjs');
31
-
32
- const LoginWithEmailView = () => {
33
- var _a;
34
- const { error } = ErrorContext.useErrorContext();
35
- const { authorizationViewDisplayOrder, wallets, projectSettings, walletsFilter, signWithEmailWalletName, loginWithEmail, } = useInternalDynamicContext.useInternalDynamicContext();
36
- const { walletBook: walletBook$1 } = walletBook.useWalletBookContext();
37
- const { showToSFooter } = useAuthLayoutChecks.useAuthLayoutChecks();
38
- const { enabledSocialProviders } = SocialRedirectContext.useSocialRedirectContext();
39
- const { numberOfWallets, walletsList } = walletListBuilder.walletListBuilder({
40
- groupWallets: true,
41
- inputList: wallets,
42
- isWalletConnectList: false,
43
- lastUsedWalletName: localStorage.LocalStorage.getFromLS(localStorage$1.LAST_USED_WALLET),
44
- loginWithEmail,
45
- numberOfWalletsToShow: LoginWithEmailWalletList.NUMBER_OF_WALLETS,
46
- searchFilter: undefined,
47
- signWithEmailWalletName,
48
- walletBook: walletBook$1,
49
- walletsFilter,
50
- });
51
- const isWeb2Priority = isDisplayOrderPriorityForWeb2.isDisplayOrderPriorityForWeb2(authorizationViewDisplayOrder);
52
- const dividerText = isWeb2Priority
53
- ? 'Or continue with a wallet'
54
- : 'Or continue with';
55
- return (jsxRuntime.jsxs("div", Object.assign({ className: 'login-with-email__container' }, { children: [error && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: error }), jsxRuntime.jsxs("div", Object.assign({ className: classNames.classNames('login-with-email__scroll', {
56
- 'login-with-email__scroll--email-first': isWeb2Priority,
57
- 'login-with-email__scroll--with-footer': showToSFooter,
58
- }), "data-testid": 'login-with-email-scroll' }, { children: [numberOfWallets &&
59
- walletsList.length &&
60
- !((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design.modal) === null || _a === void 0 ? void 0 : _a.emailOnly) ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(LoginWithEmailWalletList.LoginWithEmailWalletList, { walletsList: walletsList, numberOfWallets: numberOfWallets }), jsxRuntime.jsx(Divider.Divider, { text: dividerText })] })) : null, jsxRuntime.jsxs("div", Object.assign({ className: 'login-with-email__scroll__web2' }, { children: [jsxRuntime.jsx(LoginWithEmailForm.LoginWithEmailForm, {}), enabledSocialProviders.length > 0 && jsxRuntime.jsx(SocialSignIn.SocialSignIn, {})] }))] }))] })));
61
- };
62
-
63
- exports.LoginWithEmailView = LoginWithEmailView;
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const LoginWithEmailView: () => JSX.Element;
@@ -1,59 +0,0 @@
1
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
- import { useWalletBookContext } from '@dynamic-labs/wallet-book';
3
- import { useErrorContext } from '../../context/ErrorContext/ErrorContext.js';
4
- import '@dynamic-labs/sdk-api';
5
- import '../../shared/logger.js';
6
- import '@dynamic-labs/iconic';
7
- import '@dynamic-labs/wallet-connector-core';
8
- import '../../context/ViewContext/ViewContext.js';
9
- import 'react';
10
- import { isDisplayOrderPriorityForWeb2 } from '../../shared/utils/functions/isDisplayOrderPriorityForWeb2/isDisplayOrderPriorityForWeb2.js';
11
- import '@dynamic-labs/utils';
12
- import { LAST_USED_WALLET } from '../../utils/constants/localStorage.js';
13
- import '../../utils/constants/colors.js';
14
- import { LocalStorage } from '../../shared/utils/classes/storage/localStorage.js';
15
- import 'ethers';
16
- import '../../shared/consts/index.js';
17
- import { ErrorContainer } from '../../components/ErrorContainer/ErrorContainer.js';
18
- import { Divider } from '../../components/Divider/Divider.js';
19
- import { useInternalDynamicContext } from '../../context/DynamicContext/useInternalDynamicContext.js';
20
- import { classNames } from '../../utils/functions/classNames/classNames.js';
21
- import { walletListBuilder } from '../../utils/functions/walletListBuilder/walletListBuilder.js';
22
- import { useSocialRedirectContext } from '../../context/SocialRedirectContext/SocialRedirectContext.js';
23
- import { useAuthLayoutChecks } from '../../utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js';
24
- import { LoginWithEmailForm } from './components/LoginWithEmailForm/LoginWithEmailForm.js';
25
- import { NUMBER_OF_WALLETS, LoginWithEmailWalletList } from './components/LoginWithEmailWalletList/LoginWithEmailWalletList.js';
26
- import { SocialSignIn } from './components/SocialSignIn/SocialSignIn.js';
27
-
28
- const LoginWithEmailView = () => {
29
- var _a;
30
- const { error } = useErrorContext();
31
- const { authorizationViewDisplayOrder, wallets, projectSettings, walletsFilter, signWithEmailWalletName, loginWithEmail, } = useInternalDynamicContext();
32
- const { walletBook } = useWalletBookContext();
33
- const { showToSFooter } = useAuthLayoutChecks();
34
- const { enabledSocialProviders } = useSocialRedirectContext();
35
- const { numberOfWallets, walletsList } = walletListBuilder({
36
- groupWallets: true,
37
- inputList: wallets,
38
- isWalletConnectList: false,
39
- lastUsedWalletName: LocalStorage.getFromLS(LAST_USED_WALLET),
40
- loginWithEmail,
41
- numberOfWalletsToShow: NUMBER_OF_WALLETS,
42
- searchFilter: undefined,
43
- signWithEmailWalletName,
44
- walletBook,
45
- walletsFilter,
46
- });
47
- const isWeb2Priority = isDisplayOrderPriorityForWeb2(authorizationViewDisplayOrder);
48
- const dividerText = isWeb2Priority
49
- ? 'Or continue with a wallet'
50
- : 'Or continue with';
51
- return (jsxs("div", Object.assign({ className: 'login-with-email__container' }, { children: [error && jsx(ErrorContainer, { children: error }), jsxs("div", Object.assign({ className: classNames('login-with-email__scroll', {
52
- 'login-with-email__scroll--email-first': isWeb2Priority,
53
- 'login-with-email__scroll--with-footer': showToSFooter,
54
- }), "data-testid": 'login-with-email-scroll' }, { children: [numberOfWallets &&
55
- walletsList.length &&
56
- !((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design.modal) === null || _a === void 0 ? void 0 : _a.emailOnly) ? (jsxs(Fragment, { children: [jsx(LoginWithEmailWalletList, { walletsList: walletsList, numberOfWallets: numberOfWallets }), jsx(Divider, { text: dividerText })] })) : null, jsxs("div", Object.assign({ className: 'login-with-email__scroll__web2' }, { children: [jsx(LoginWithEmailForm, {}), enabledSocialProviders.length > 0 && jsx(SocialSignIn, {})] }))] }))] })));
57
- };
58
-
59
- export { LoginWithEmailView };
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const EMAIL_REGEX: RegExp;
3
- type Props = {
4
- currentEmail?: string;
5
- };
6
- export declare const LoginWithEmailForm: ({ currentEmail }: Props) => JSX.Element;
7
- export {};
@@ -1 +0,0 @@
1
- export { LoginWithEmailForm } from './LoginWithEmailForm';
@@ -1,36 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var jsxRuntime = require('react/jsx-runtime');
6
- var Skeleton = require('../../../../components/Skeleton/Skeleton.cjs');
7
- var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
8
- var ViewContext = require('../../../../context/ViewContext/ViewContext.cjs');
9
- require('@dynamic-labs/sdk-api');
10
- require('../../../../shared/logger.cjs');
11
- require('@dynamic-labs/iconic');
12
- require('@dynamic-labs/wallet-connector-core');
13
- require('react');
14
- require('@dynamic-labs/wallet-book');
15
- require('@dynamic-labs/utils');
16
- var localStorage$1 = require('../../../../utils/constants/localStorage.cjs');
17
- require('../../../../utils/constants/colors.cjs');
18
- var localStorage = require('../../../../shared/utils/classes/storage/localStorage.cjs');
19
- require('ethers');
20
- require('../../../../shared/consts/index.cjs');
21
- var WalletListItem = require('../../../WalletList/WalletListItem/WalletListItem.cjs');
22
- var ListItemButton = require('../ListItemButton/ListItemButton.cjs');
23
-
24
- const NUMBER_OF_WALLETS = 3;
25
- const LoginWithEmailWalletList = ({ walletsList, numberOfWallets, }) => {
26
- const { setView } = ViewContext.useViewContext();
27
- const { projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
28
- const isUsingMultiWallet = Boolean(localStorage.LocalStorage.getFromLS(localStorage$1.AUTH_USER));
29
- return !projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxRuntime.jsxs("div", Object.assign({ className: 'login-with-email-wallet-list__container' }, { children: [walletsList.map((wallet) => {
30
- var _a;
31
- return (jsxRuntime.jsx(WalletListItem.WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
32
- }), jsxRuntime.jsx(ListItemButton.ListItemButton, { text: 'View all wallets', onClick: () => setView('login-with-email-or-wallet-full-wallet-list'), numberOfWallets: numberOfWallets })] })));
33
- };
34
-
35
- exports.LoginWithEmailWalletList = LoginWithEmailWalletList;
36
- exports.NUMBER_OF_WALLETS = NUMBER_OF_WALLETS;
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import { WalletOption } from '../../../../shared';
3
- export declare const NUMBER_OF_WALLETS = 3;
4
- type Props = {
5
- numberOfWallets: number;
6
- walletsList: WalletOption[];
7
- };
8
- export declare const LoginWithEmailWalletList: ({ walletsList, numberOfWallets, }: Props) => JSX.Element;
9
- export {};
@@ -1,31 +0,0 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { Skeleton } from '../../../../components/Skeleton/Skeleton.js';
3
- import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
4
- import { useViewContext } from '../../../../context/ViewContext/ViewContext.js';
5
- import '@dynamic-labs/sdk-api';
6
- import '../../../../shared/logger.js';
7
- import '@dynamic-labs/iconic';
8
- import '@dynamic-labs/wallet-connector-core';
9
- import 'react';
10
- import '@dynamic-labs/wallet-book';
11
- import '@dynamic-labs/utils';
12
- import { AUTH_USER } from '../../../../utils/constants/localStorage.js';
13
- import '../../../../utils/constants/colors.js';
14
- import { LocalStorage } from '../../../../shared/utils/classes/storage/localStorage.js';
15
- import 'ethers';
16
- import '../../../../shared/consts/index.js';
17
- import { WalletListItem } from '../../../WalletList/WalletListItem/WalletListItem.js';
18
- import { ListItemButton } from '../ListItemButton/ListItemButton.js';
19
-
20
- const NUMBER_OF_WALLETS = 3;
21
- const LoginWithEmailWalletList = ({ walletsList, numberOfWallets, }) => {
22
- const { setView } = useViewContext();
23
- const { projectSettings } = useInternalDynamicContext();
24
- const isUsingMultiWallet = Boolean(LocalStorage.getFromLS(AUTH_USER));
25
- return !projectSettings ? (jsx(Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxs("div", Object.assign({ className: 'login-with-email-wallet-list__container' }, { children: [walletsList.map((wallet) => {
26
- var _a;
27
- return (jsx(WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
28
- }), jsx(ListItemButton, { text: 'View all wallets', onClick: () => setView('login-with-email-or-wallet-full-wallet-list'), numberOfWallets: numberOfWallets })] })));
29
- };
30
-
31
- export { LoginWithEmailWalletList, NUMBER_OF_WALLETS };
@@ -1 +0,0 @@
1
- export { LoginWithEmailWalletList } from './LoginWithEmailWalletList';
@@ -1 +0,0 @@
1
- export { LoginWithEmailView } from './LoginWithEmailView';