@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,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 LoginWithEmailForm = ({ currentEmail }) => {
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 || loading, [isEmailProviderLoading, loading]);
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
- setLoading(true);
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: onChangeHandler, label: 'Enter your email', error: emailError, message: emailError && 'Please enter a valid email address', suffix: emailInputSuffixIcon }) })));
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, LoginWithEmailForm };
106
+ export { EMAIL_REGEX, LoginEmailForm };
@@ -0,0 +1 @@
1
+ export { LoginEmailForm } from './LoginEmailForm';
@@ -0,0 +1,5 @@
1
+ export interface LoginWidgetProps {
2
+ onSubmit?: () => void;
3
+ onSubmitError?: () => void;
4
+ isLoading: boolean;
5
+ }
@@ -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 };
@@ -3,14 +3,12 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
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');
6
+ require('react');
11
7
  require('@dynamic-labs/sdk-api');
12
8
  require('../../../../shared/logger.cjs');
9
+ require('@dynamic-labs/iconic');
13
10
  require('@dynamic-labs/wallet-connector-core');
11
+ require('../../../../context/ViewContext/ViewContext.cjs');
14
12
  require('@dynamic-labs/wallet-book');
15
13
  require('@dynamic-labs/utils');
16
14
  require('../../../../utils/constants/colors.cjs');
@@ -21,7 +19,6 @@ require('../../../../context/DynamicContext/DynamicContext.cjs');
21
19
  require('@dynamic-labs/multi-wallet');
22
20
  require('../../../../components/ShadowDOM/ShadowDOM.cjs');
23
21
  require('../../../../context/ThemeContext/ThemeContext.cjs');
24
- var Icon = require('../../../../components/Icon/Icon.cjs');
25
22
  require('react-dom');
26
23
  require('react-focus-lock');
27
24
  require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
@@ -34,6 +31,7 @@ require('../../../../context/ErrorContext/ErrorContext.cjs');
34
31
  require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
35
32
  require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
36
33
  require('../../../../components/IconButton/IconButton.cjs');
34
+ var Button = require('../../../../components/Button/Button.cjs');
37
35
  require('../../../../components/Alert/Alert.cjs');
38
36
  require('formik');
39
37
  require('yup');
@@ -44,22 +42,12 @@ require('../../../../context/EmailVerificationContext/EmailVerificationContext.c
44
42
  require('@dynamic-labs/types');
45
43
  require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
46
44
  require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
47
- var ListTile = require('../../../../components/ListTile/ListTile.cjs');
48
45
  require('../../../../components/Popper/Popper/Popper.cjs');
49
46
  require('../../../../components/Popper/PopperContext/PopperContext.cjs');
50
47
  require('../../../../components/InlineWidget/InlineWidget.cjs');
51
48
  require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
52
- var Badge = require('../../../../components/Badge/Badge.cjs');
49
+ var WalletSimpleSignIn = require('./WalletSimpleSignIn/WalletSimpleSignIn.cjs');
53
50
 
54
- const ListItemButton = ({ text, onClick, numberOfWallets }) => {
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' }, { children: text })));
63
- };
51
+ const WalletSignIn = ({ numberOfItensToShow, isLoading, onSubmit, }) => numberOfItensToShow > 0 ? (jsxRuntime.jsx(WalletSimpleSignIn.WalletSimpleSignIn, { previewWalletsNumber: numberOfItensToShow, onshowAllWallets: () => onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(), disabled: isLoading })) : (jsxRuntime.jsx(Button.Button, Object.assign({ disabled: isLoading, onClick: () => onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(), buttonVariant: 'primary', buttonPadding: 'large' }, { children: "Connect with Wallet" })));
64
52
 
65
- exports.ListItemButton = ListItemButton;
53
+ exports.WalletSignIn = WalletSignIn;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { LoginWidgetProps } from '../LoginWidget';
3
+ interface WalletLoginProps extends LoginWidgetProps {
4
+ numberOfItensToShow: number;
5
+ }
6
+ export declare const WalletSignIn: React.FC<WalletLoginProps>;
7
+ export {};
@@ -1,12 +1,10 @@
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';
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import 'react';
7
3
  import '@dynamic-labs/sdk-api';
8
4
  import '../../../../shared/logger.js';
5
+ import '@dynamic-labs/iconic';
9
6
  import '@dynamic-labs/wallet-connector-core';
7
+ import '../../../../context/ViewContext/ViewContext.js';
10
8
  import '@dynamic-labs/wallet-book';
11
9
  import '@dynamic-labs/utils';
12
10
  import '../../../../utils/constants/colors.js';
@@ -17,7 +15,6 @@ import '../../../../context/DynamicContext/DynamicContext.js';
17
15
  import '@dynamic-labs/multi-wallet';
18
16
  import '../../../../components/ShadowDOM/ShadowDOM.js';
19
17
  import '../../../../context/ThemeContext/ThemeContext.js';
20
- import { Icon } from '../../../../components/Icon/Icon.js';
21
18
  import 'react-dom';
22
19
  import 'react-focus-lock';
23
20
  import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
@@ -30,6 +27,7 @@ import '../../../../context/ErrorContext/ErrorContext.js';
30
27
  import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
31
28
  import '../../../../context/AccountExistsContext/AccountExistsContext.js';
32
29
  import '../../../../components/IconButton/IconButton.js';
30
+ import { Button } from '../../../../components/Button/Button.js';
33
31
  import '../../../../components/Alert/Alert.js';
34
32
  import 'formik';
35
33
  import 'yup';
@@ -40,22 +38,12 @@ import '../../../../context/EmailVerificationContext/EmailVerificationContext.js
40
38
  import '@dynamic-labs/types';
41
39
  import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
42
40
  import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
43
- import { ListTile } from '../../../../components/ListTile/ListTile.js';
44
41
  import '../../../../components/Popper/Popper/Popper.js';
45
42
  import '../../../../components/Popper/PopperContext/PopperContext.js';
46
43
  import '../../../../components/InlineWidget/InlineWidget.js';
47
44
  import '../../../../components/MenuList/Dropdown/Dropdown.js';
48
- import { Badge } from '../../../../components/Badge/Badge.js';
45
+ import { WalletSimpleSignIn } from './WalletSimpleSignIn/WalletSimpleSignIn.js';
49
46
 
50
- const ListItemButton = ({ text, onClick, numberOfWallets }) => {
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' }, { children: text })));
59
- };
47
+ const WalletSignIn = ({ numberOfItensToShow, isLoading, onSubmit, }) => numberOfItensToShow > 0 ? (jsx(WalletSimpleSignIn, { previewWalletsNumber: numberOfItensToShow, onshowAllWallets: () => onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(), disabled: isLoading })) : (jsx(Button, Object.assign({ disabled: isLoading, onClick: () => onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(), buttonVariant: 'primary', buttonPadding: 'large' }, { children: "Connect with Wallet" })));
60
48
 
61
- export { ListItemButton };
49
+ export { WalletSignIn };
@@ -0,0 +1,47 @@
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 Skeleton = require('../../../../../components/Skeleton/Skeleton.cjs');
8
+ var useInternalDynamicContext = require('../../../../../context/DynamicContext/useInternalDynamicContext.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('../../../../../context/ViewContext/ViewContext.cjs');
14
+ require('react');
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
+ var walletListBuilder = require('../../../../../utils/functions/walletListBuilder/walletListBuilder.cjs');
24
+
25
+ const WalletSimpleSignIn = ({ previewWalletsNumber, disabled = false, onshowAllWallets, }) => {
26
+ const { wallets, projectSettings, walletsFilter, signWithEmailWalletName } = useInternalDynamicContext.useInternalDynamicContext();
27
+ const { walletBook: walletBook$1 } = walletBook.useWalletBookContext();
28
+ const { numberOfWallets, walletsList } = walletListBuilder.walletListBuilder({
29
+ groupWallets: true,
30
+ inputList: wallets,
31
+ isWalletConnectList: false,
32
+ lastUsedWalletName: localStorage.LocalStorage.getFromLS(localStorage$1.LAST_USED_WALLET),
33
+ loginWithEmail: true,
34
+ numberOfWalletsToShow: previewWalletsNumber,
35
+ searchFilter: undefined,
36
+ signWithEmailWalletName,
37
+ walletBook: walletBook$1,
38
+ walletsFilter,
39
+ });
40
+ const isUsingMultiWallet = Boolean(localStorage.LocalStorage.getFromLS(localStorage$1.AUTH_USER));
41
+ return !projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { count: previewWalletsNumber + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxRuntime.jsxs("div", Object.assign({ className: 'login-with-email-wallet-list__container', "data-testid": 'top-wallets-list' }, { children: [walletsList.map((wallet) => {
42
+ var _a;
43
+ return (jsxRuntime.jsx(WalletListItem.WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet, disabled: disabled }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
44
+ }), jsxRuntime.jsx(ListItemButton.ListItemButton, { text: 'View all wallets', onClick: onshowAllWallets, numberOfWallets: numberOfWallets, disabled: disabled })] })));
45
+ };
46
+
47
+ exports.WalletSimpleSignIn = WalletSimpleSignIn;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ interface WalletSimpleSignInProp {
3
+ previewWalletsNumber: number;
4
+ disabled: boolean;
5
+ onshowAllWallets: () => void;
6
+ }
7
+ export declare const WalletSimpleSignIn: React.FC<WalletSimpleSignInProp>;
8
+ export {};
@@ -0,0 +1,43 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { useWalletBookContext } from '@dynamic-labs/wallet-book';
3
+ import { Skeleton } from '../../../../../components/Skeleton/Skeleton.js';
4
+ import { useInternalDynamicContext } from '../../../../../context/DynamicContext/useInternalDynamicContext.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 '../../../../../context/ViewContext/ViewContext.js';
10
+ import 'react';
11
+ import '@dynamic-labs/utils';
12
+ import { LAST_USED_WALLET, 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
+ import { walletListBuilder } from '../../../../../utils/functions/walletListBuilder/walletListBuilder.js';
20
+
21
+ const WalletSimpleSignIn = ({ previewWalletsNumber, disabled = false, onshowAllWallets, }) => {
22
+ const { wallets, projectSettings, walletsFilter, signWithEmailWalletName } = useInternalDynamicContext();
23
+ const { walletBook } = useWalletBookContext();
24
+ const { numberOfWallets, walletsList } = walletListBuilder({
25
+ groupWallets: true,
26
+ inputList: wallets,
27
+ isWalletConnectList: false,
28
+ lastUsedWalletName: LocalStorage.getFromLS(LAST_USED_WALLET),
29
+ loginWithEmail: true,
30
+ numberOfWalletsToShow: previewWalletsNumber,
31
+ searchFilter: undefined,
32
+ signWithEmailWalletName,
33
+ walletBook,
34
+ walletsFilter,
35
+ });
36
+ const isUsingMultiWallet = Boolean(LocalStorage.getFromLS(AUTH_USER));
37
+ return !projectSettings ? (jsx(Skeleton, { count: previewWalletsNumber + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxs("div", Object.assign({ className: 'login-with-email-wallet-list__container', "data-testid": 'top-wallets-list' }, { children: [walletsList.map((wallet) => {
38
+ var _a;
39
+ return (jsx(WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet, disabled: disabled }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
40
+ }), jsx(ListItemButton, { text: 'View all wallets', onClick: onshowAllWallets, numberOfWallets: numberOfWallets, disabled: disabled })] })));
41
+ };
42
+
43
+ export { WalletSimpleSignIn };
@@ -0,0 +1 @@
1
+ export { WalletSimpleSignIn } from './WalletSimpleSignIn';
@@ -0,0 +1 @@
1
+ export { WalletSignIn } from './WalletSignIn';
@@ -0,0 +1,3 @@
1
+ export * from './EmailSignIn';
2
+ export * from './LoginWidget';
3
+ export * from './WalletSignIn';
@@ -0,0 +1 @@
1
+ export { LoginView } from './LoginView';
@@ -0,0 +1,137 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var sdkApi = require('@dynamic-labs/sdk-api');
7
+ var useInternalDynamicContext = require('../../context/DynamicContext/useInternalDynamicContext.cjs');
8
+
9
+ const NUMBER_OF_WALLETS = 3;
10
+ const useLoginView = () => {
11
+ const { projectSettings, authorizationViewDisplayOrder, loginWithEmail, wallets, } = useInternalDynamicContext.useInternalDynamicContext();
12
+ const isWalletOnly = React.useMemo(() => {
13
+ var _a, _b, _c, _d, _e, _f;
14
+ if (!projectSettings) {
15
+ return false;
16
+ }
17
+ // toolkit functionality overrides whatever is defined
18
+ if (!loginWithEmail) {
19
+ return true;
20
+ }
21
+ 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 === sdkApi.SdkViewType.Login);
22
+ // backwards compatibility for those that didn't set up login view sessions
23
+ if (!((_c = loginView === null || loginView === void 0 ? void 0 : loginView.sections) === null || _c === void 0 ? void 0 : _c.length)) {
24
+ return (!((_e = (_d = projectSettings.design) === null || _d === void 0 ? void 0 : _d.modal) === null || _e === void 0 ? void 0 : _e.emailOnly) &&
25
+ !((_f = projectSettings.providers) === null || _f === void 0 ? void 0 : _f.length));
26
+ }
27
+ return (loginView.sections.length === 1 && loginView.sections[0].type === 'wallet');
28
+ }, [projectSettings, loginWithEmail]);
29
+ /**
30
+ * build email and social view sections from project settings design.modal props - backwards compatibility
31
+ * @returns SdkViewSection[]
32
+ */
33
+ const getEmailViewSectionDefinition = () => {
34
+ var _a, _b, _c;
35
+ const loginViewSections = [
36
+ {
37
+ type: sdkApi.SdkViewSectionType.Email,
38
+ },
39
+ ];
40
+ 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) {
41
+ const numOfProvidersToDisplay = projectSettings.sdk.socialSignIn.providers.filter((provider) => provider.enabled).length;
42
+ loginViewSections.push({
43
+ numOfItemsToDisplay: numOfProvidersToDisplay,
44
+ type: sdkApi.SdkViewSectionType.Social,
45
+ });
46
+ }
47
+ return loginViewSections;
48
+ };
49
+ // TODO: https://linear.app/dynamic-labs/issue/GVTY-212/rethink-or-implement-toolkit-template-for-email-wallet-order
50
+ /**
51
+ * remove wallet view section from projectSettings?.sdk?.views if no wallet defined
52
+ * @param sections
53
+ * @returns
54
+ */
55
+ const filterLoginViewSections = (sections) => {
56
+ if (wallets === null || wallets === void 0 ? void 0 : wallets.length) {
57
+ return sections;
58
+ }
59
+ return sections.filter((section) => section.type !== 'wallet');
60
+ };
61
+ const addSeparator = (index, loginItem) => {
62
+ var _a;
63
+ // if not the first index, no separator is needed
64
+ // if the first index but does not have wallets or providers,
65
+ // it'll show only one view section - no separator is needed
66
+ if (index !== 0 ||
67
+ !(wallets === null || wallets === void 0 ? void 0 : wallets.length) ||
68
+ !((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) === null || _a === void 0 ? void 0 : _a.length)) {
69
+ return [];
70
+ }
71
+ const label = loginItem === 'email' ? 'Or continue with a wallet' : 'Or continue with';
72
+ return [
73
+ {
74
+ label,
75
+ type: sdkApi.SdkViewSectionType.Separator,
76
+ },
77
+ ];
78
+ };
79
+ /**
80
+ * build login view sections array from project settings design.modal props - backwards compatibility
81
+ * @returns SdkViewSection[]
82
+ */
83
+ const buildLoginSections = () => {
84
+ let loginViewSections = [];
85
+ authorizationViewDisplayOrder === null || authorizationViewDisplayOrder === void 0 ? void 0 : authorizationViewDisplayOrder.forEach((loginItem, index) => {
86
+ var _a, _b, _c;
87
+ if (loginItem === 'email' && ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) === null || _a === void 0 ? void 0 : _a.length)) {
88
+ loginViewSections = loginViewSections.concat(getEmailViewSectionDefinition(),
89
+ // add separator if wallets defined
90
+ addSeparator(index, loginItem));
91
+ }
92
+ if (loginItem === 'wallet' && (wallets === null || wallets === void 0 ? void 0 : wallets.length)) {
93
+ // if showWalletsButton is true, it should show "Connec with Wallet" button
94
+ 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)
95
+ ? 0
96
+ : NUMBER_OF_WALLETS;
97
+ loginViewSections = loginViewSections.concat([
98
+ {
99
+ numOfItemsToDisplay,
100
+ type: sdkApi.SdkViewSectionType.Wallet,
101
+ },
102
+ ],
103
+ // add separator if email providers defined
104
+ addSeparator(index, loginItem));
105
+ }
106
+ });
107
+ return loginViewSections;
108
+ };
109
+ /**
110
+ * returns the login view sections to be displayed in order from projectSettings?.sdk?.views
111
+ * and has backwards compatibility with project settings design.modal props
112
+ */
113
+ const logingViewSections = React.useMemo(() => {
114
+ var _a, _b, _c, _d, _e;
115
+ 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 === sdkApi.SdkViewType.Login);
116
+ if ((_c = loginView === null || loginView === void 0 ? void 0 : loginView.sections) === null || _c === void 0 ? void 0 : _c.length) {
117
+ return filterLoginViewSections(loginView === null || loginView === void 0 ? void 0 : loginView.sections);
118
+ }
119
+ 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) {
120
+ return getEmailViewSectionDefinition();
121
+ }
122
+ return buildLoginSections();
123
+ }, [
124
+ projectSettings,
125
+ authorizationViewDisplayOrder,
126
+ getEmailViewSectionDefinition,
127
+ filterLoginViewSections,
128
+ buildLoginSections,
129
+ ]);
130
+ return {
131
+ isWalletOnly,
132
+ logingViewSections,
133
+ };
134
+ };
135
+
136
+ exports.NUMBER_OF_WALLETS = NUMBER_OF_WALLETS;
137
+ exports.useLoginView = useLoginView;
@@ -0,0 +1,6 @@
1
+ import { SdkViewSection } from '@dynamic-labs/sdk-api';
2
+ export declare const NUMBER_OF_WALLETS = 3;
3
+ export declare const useLoginView: () => {
4
+ isWalletOnly: boolean;
5
+ logingViewSections: SdkViewSection[];
6
+ };