@dynamic-labs/sdk-react-core 0.18.100-viem.3 → 0.18.100-viem.30

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 (165) hide show
  1. package/CHANGELOG.md +233 -0
  2. package/package.cjs +3 -3
  3. package/package.js +3 -3
  4. package/package.json +10 -10
  5. package/src/index.cjs +1 -2
  6. package/src/index.d.ts +1 -1
  7. package/src/index.js +1 -1
  8. package/src/lib/components/MenuList/Dropdown/Dropdown.cjs +1 -1
  9. package/src/lib/components/MenuList/Dropdown/Dropdown.js +1 -1
  10. package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.cjs +6 -2
  11. package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.d.ts +2 -1
  12. package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.js +6 -2
  13. package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +2 -2
  14. package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
  15. package/src/lib/components/OTPVerificationView/OTPVerificationView.js +2 -2
  16. package/src/lib/components/SignMessagePreview/SignMessagePreview.cjs +27 -0
  17. package/src/lib/components/SignMessagePreview/SignMessagePreview.d.ts +6 -0
  18. package/src/lib/components/SignMessagePreview/SignMessagePreview.js +23 -0
  19. package/src/lib/components/SignMessagePreview/SignMessagePreview.types.d.ts +8 -0
  20. package/src/lib/components/SignMessagePreview/components/SignTypedDataPreview/SignTypedDataPreview.cjs +44 -0
  21. package/src/lib/components/SignMessagePreview/components/SignTypedDataPreview/SignTypedDataPreview.d.ts +8 -0
  22. package/src/lib/components/SignMessagePreview/components/SignTypedDataPreview/SignTypedDataPreview.js +40 -0
  23. package/src/lib/components/SignMessagePreview/components/SignTypedDataPreview/index.d.ts +1 -0
  24. package/src/lib/components/SignMessagePreview/components/index.d.ts +1 -0
  25. package/src/lib/components/SignMessagePreview/index.d.ts +1 -0
  26. package/src/lib/components/SignMessagePreview/utils/index.d.ts +1 -0
  27. package/src/lib/components/SignMessagePreview/utils/isSignTypedData/index.d.ts +1 -0
  28. package/src/lib/components/SignMessagePreview/utils/isSignTypedData/isSignTypedData.cjs +17 -0
  29. package/src/lib/components/SignMessagePreview/utils/isSignTypedData/isSignTypedData.d.ts +2 -0
  30. package/src/lib/components/SignMessagePreview/utils/isSignTypedData/isSignTypedData.js +13 -0
  31. package/src/lib/components/Typography/Typography.cjs +1 -0
  32. package/src/lib/components/Typography/Typography.js +1 -0
  33. package/src/lib/components/Typography/Typography.types.d.ts +1 -1
  34. package/src/lib/components/UserProfile/UserProfile.cjs +1 -1
  35. package/src/lib/components/UserProfile/UserProfile.js +1 -1
  36. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +1 -1
  37. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +1 -1
  38. package/src/lib/components/index.d.ts +1 -0
  39. package/src/lib/context/DynamicContext/DynamicContext.cjs +20 -6
  40. package/src/lib/context/DynamicContext/DynamicContext.d.ts +11 -1
  41. package/src/lib/context/DynamicContext/DynamicContext.js +21 -7
  42. package/src/lib/context/DynamicContext/helpers.cjs +42 -3
  43. package/src/lib/context/DynamicContext/helpers.d.ts +7 -1
  44. package/src/lib/context/DynamicContext/helpers.js +38 -4
  45. package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.cjs +5 -2
  46. package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.d.ts +4 -2
  47. package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.js +5 -2
  48. package/src/lib/context/DynamicContext/internalEvents/index.d.ts +2 -0
  49. package/src/lib/context/DynamicContext/internalEvents/internalEvents.cjs +14 -0
  50. package/src/lib/context/DynamicContext/internalEvents/internalEvents.d.ts +8 -0
  51. package/src/lib/context/DynamicContext/internalEvents/internalEvents.js +6 -0
  52. package/src/lib/context/DynamicContext/types/index.d.ts +7 -1
  53. package/src/lib/context/DynamicContext/useDynamicContext.cjs +2 -1
  54. package/src/lib/context/DynamicContext/useDynamicContext.d.ts +1 -1
  55. package/src/lib/context/DynamicContext/useDynamicContext.js +2 -1
  56. package/src/lib/context/ErrorContext/ErrorContext.cjs +1 -0
  57. package/src/lib/context/ErrorContext/ErrorContext.js +1 -0
  58. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +33 -7
  59. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +33 -7
  60. package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
  61. package/src/lib/context/WalletContext/WalletContext.cjs +2 -16
  62. package/src/lib/context/WalletContext/WalletContext.js +2 -16
  63. package/src/lib/data/api.cjs +20 -12
  64. package/src/lib/data/api.d.ts +3 -2
  65. package/src/lib/data/api.js +20 -12
  66. package/src/lib/main.global.cjs +1 -1
  67. package/src/lib/main.global.js +1 -1
  68. package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +2 -1
  69. package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +2 -1
  70. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +2 -1
  71. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +2 -1
  72. package/src/lib/shared/types/index.d.ts +4 -0
  73. package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.cjs +28 -2
  74. package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.js +28 -2
  75. package/src/lib/styles/index.shadow.cjs +1 -1
  76. package/src/lib/styles/index.shadow.js +1 -1
  77. package/src/lib/utils/constants/localStorage.cjs +4 -0
  78. package/src/lib/utils/constants/localStorage.d.ts +2 -0
  79. package/src/lib/utils/constants/localStorage.js +3 -1
  80. package/src/lib/utils/functions/createUserProfile/createUserProfile.cjs +1 -1
  81. package/src/lib/utils/functions/createUserProfile/createUserProfile.js +1 -1
  82. package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.cjs +6 -1
  83. package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.js +6 -1
  84. package/src/lib/utils/functions/getProviderByType/getProviderByType.cjs +7 -0
  85. package/src/lib/utils/functions/getProviderByType/getProviderByType.d.ts +2 -0
  86. package/src/lib/utils/functions/getProviderByType/getProviderByType.js +3 -0
  87. package/src/lib/utils/functions/getProviderByType/index.d.ts +1 -0
  88. package/src/lib/utils/functions/index.d.ts +2 -0
  89. package/src/lib/utils/functions/sendTransactionWithAutoNonce/index.d.ts +1 -0
  90. package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs +48 -0
  91. package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.d.ts +18 -0
  92. package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js +43 -0
  93. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +10 -5
  94. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +10 -5
  95. package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +6 -2
  96. package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +6 -2
  97. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +13 -4
  98. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +1 -19
  99. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +13 -4
  100. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +22 -32
  101. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -2
  102. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +23 -33
  103. package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +7 -6
  104. package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +7 -6
  105. package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs +10 -1
  106. package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js +10 -1
  107. package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.cjs +15 -1
  108. package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.js +15 -1
  109. package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.cjs +6 -2
  110. package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.d.ts +2 -1
  111. package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.js +6 -2
  112. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +94 -16
  113. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +5 -1
  114. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +94 -16
  115. package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs +5 -1
  116. package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js +5 -1
  117. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +13 -3
  118. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +13 -3
  119. package/src/lib/utils/hooks/useWallets/useWallets.cjs +20 -26
  120. package/src/lib/utils/hooks/useWallets/useWallets.d.ts +3 -2
  121. package/src/lib/utils/hooks/useWallets/useWallets.js +21 -27
  122. package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +3 -3
  123. package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +3 -3
  124. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +1 -1
  125. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +1 -1
  126. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +1 -1
  127. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +1 -1
  128. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +3 -2
  129. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +3 -2
  130. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +3 -2
  131. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +3 -2
  132. package/src/lib/views/SendBalanceView/SendBalanceView.cjs +19 -3
  133. package/src/lib/views/SendBalanceView/SendBalanceView.js +19 -3
  134. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +4 -16
  135. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +2 -0
  136. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +5 -17
  137. package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.cjs +1 -0
  138. package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.js +1 -0
  139. package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +1 -1
  140. package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +1 -1
  141. package/src/lib/views/WalletList/data.cjs +2 -14
  142. package/src/lib/views/WalletList/data.d.ts +4 -2
  143. package/src/lib/views/WalletList/data.js +2 -13
  144. package/src/lib/views/viewToComponentMap.cjs +1 -0
  145. package/src/lib/views/viewToComponentMap.js +1 -0
  146. package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.cjs +3 -3
  147. package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.js +3 -3
  148. package/src/lib/widgets/DynamicWidget/DynamicWidget.cjs +2 -2
  149. package/src/lib/widgets/DynamicWidget/DynamicWidget.js +3 -3
  150. package/src/lib/widgets/DynamicWidget/components/DynamicNav/DynamicNav.cjs +36 -1
  151. package/src/lib/widgets/DynamicWidget/components/DynamicNav/DynamicNav.js +36 -1
  152. package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.cjs +2 -2
  153. package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.js +2 -2
  154. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +7 -10
  155. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.d.ts +1 -0
  156. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +8 -11
  157. package/src/lib/widgets/DynamicWidget/hooks/index.d.ts +1 -0
  158. package/src/lib/widgets/DynamicWidget/hooks/useViewController/index.d.ts +1 -0
  159. package/src/lib/widgets/DynamicWidget/hooks/useViewController/useViewController.cjs +17 -0
  160. package/src/lib/widgets/DynamicWidget/hooks/useViewController/useViewController.d.ts +6 -0
  161. package/src/lib/widgets/DynamicWidget/hooks/useViewController/useViewController.js +13 -0
  162. package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +3 -3
  163. package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +3 -3
  164. package/src/lib/widgets/DynamicWidget/views/SendBalanceWidgetView/SendBalanceWidgetView.cjs +2 -3
  165. package/src/lib/widgets/DynamicWidget/views/SendBalanceWidgetView/SendBalanceWidgetView.js +2 -3
@@ -18,7 +18,7 @@ const getEnabledChains = (chains) => chains
18
18
  .filter(({ enabled }) => enabled)
19
19
  .map(({ name }) => { var _a; return (_a = getChainInfo(name)) === null || _a === void 0 ? void 0 : _a.symbol; })
20
20
  .filter((chain) => Boolean(chain));
21
- const createWallets = (props) => {
21
+ const getWallets = (props) => {
22
22
  var _a, _b, _c, _d;
23
23
  return getEnabledWallets({
24
24
  enabledChains: getEnabledChains(props.settings.chains),
@@ -27,18 +27,7 @@ const createWallets = (props) => {
27
27
  ((_b = props.settings.sdk.walletConnect) === null || _b === void 0 ? void 0 : _b.projectId)
28
28
  ? (_c = props.settings.sdk.walletConnect) === null || _c === void 0 ? void 0 : _c.v2Enabled
29
29
  : false, walletConnectProjectId: (_d = props.settings.sdk.walletConnect) === null || _d === void 0 ? void 0 : _d.projectId }),
30
- installed: props.installed,
31
30
  }).map((wallet) => createWallet(props.getSupportedWalletOpts.walletBook, wallet));
32
31
  };
33
- const getInstalledWallets = (settings, getSupportedWalletOpts) => createWallets({
34
- getSupportedWalletOpts,
35
- installed: true,
36
- settings,
37
- });
38
- const getNotInstalledWallets = (settings, getSupportedWalletOpts) => createWallets({
39
- getSupportedWalletOpts,
40
- installed: false,
41
- settings,
42
- });
43
32
 
44
- export { getEnabledChains, getInstalledWallets, getNotInstalledWallets };
33
+ export { getEnabledChains, getWallets };
@@ -46,6 +46,7 @@ const viewToComponentMap = {
46
46
  'login-with-email-or-wallet-full-wallet-list': jsxRuntime.jsx(WalletList.WalletList, {}),
47
47
  'login-with-email-verification': jsxRuntime.jsx(EmailVerification.EmailVerification, {}),
48
48
  'merge-user-accounts': jsxRuntime.jsx(MergeUserAccountsView.MergeUserAccountsView, {}),
49
+ 'multi-wallet-wallet-list': jsxRuntime.jsx(WalletList.WalletList, {}),
49
50
  'network-not-supported': jsxRuntime.jsx(NetworkNotSupported.NetworkNotSupported, {}),
50
51
  'network-not-supported-manual': jsxRuntime.jsx(NetworkNotSupportedSwitchManual.NetworkNotSupportedSwitchManual, {}),
51
52
  'no-access': jsxRuntime.jsx(NoAccess.NoAccess, {}),
@@ -42,6 +42,7 @@ const viewToComponentMap = {
42
42
  'login-with-email-or-wallet-full-wallet-list': jsx(WalletList, {}),
43
43
  'login-with-email-verification': jsx(EmailVerification, {}),
44
44
  'merge-user-accounts': jsx(MergeUserAccountsView, {}),
45
+ 'multi-wallet-wallet-list': jsx(WalletList, {}),
45
46
  'network-not-supported': jsx(NetworkNotSupported, {}),
46
47
  'network-not-supported-manual': jsx(NetworkNotSupportedSwitchManual, {}),
47
48
  'no-access': jsx(NoAccess, {}),
@@ -14,7 +14,7 @@ var UserProfileForm = require('../../../../components/UserProfileForm/UserProfil
14
14
  const EditProfileView = () => {
15
15
  const { setView } = ViewContext.useViewContext();
16
16
  const { goToProfileView } = DynamicBridgeWidgetContext.useDynamicBridgeWidgetContext();
17
- const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
17
+ const { internalSetShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
18
18
  const { updateUser } = useUserUpdateRequest.useUserUpdateRequestInternal({
19
19
  validationSchemaStripUnknown: true,
20
20
  });
@@ -22,10 +22,10 @@ const EditProfileView = () => {
22
22
  const { isEmailVerificationRequired } = yield updateUser(formValues);
23
23
  goToProfileView();
24
24
  if (isEmailVerificationRequired) {
25
- setShowAuthFlow(true);
25
+ internalSetShowAuthFlow(true);
26
26
  setView('verify-email');
27
27
  }
28
- }), [goToProfileView, setShowAuthFlow, setView, updateUser]);
28
+ }), [goToProfileView, internalSetShowAuthFlow, setView, updateUser]);
29
29
  return (jsxRuntime.jsx(UserProfileForm.UserProfileForm, { onEditProfileSubmit: onEditProfileFormSubmit, onEditProfileCancel: goToProfileView }));
30
30
  };
31
31
 
@@ -10,7 +10,7 @@ import { UserProfileForm } from '../../../../components/UserProfileForm/UserProf
10
10
  const EditProfileView = () => {
11
11
  const { setView } = useViewContext();
12
12
  const { goToProfileView } = useDynamicBridgeWidgetContext();
13
- const { setShowAuthFlow } = useInternalDynamicContext();
13
+ const { internalSetShowAuthFlow } = useInternalDynamicContext();
14
14
  const { updateUser } = useUserUpdateRequestInternal({
15
15
  validationSchemaStripUnknown: true,
16
16
  });
@@ -18,10 +18,10 @@ const EditProfileView = () => {
18
18
  const { isEmailVerificationRequired } = yield updateUser(formValues);
19
19
  goToProfileView();
20
20
  if (isEmailVerificationRequired) {
21
- setShowAuthFlow(true);
21
+ internalSetShowAuthFlow(true);
22
22
  setView('verify-email');
23
23
  }
24
- }), [goToProfileView, setShowAuthFlow, setView, updateUser]);
24
+ }), [goToProfileView, internalSetShowAuthFlow, setView, updateUser]);
25
25
  return (jsx(UserProfileForm, { onEditProfileSubmit: onEditProfileFormSubmit, onEditProfileCancel: goToProfileView }));
26
26
  };
27
27
 
@@ -38,7 +38,7 @@ require('../../context/CaptchaContext/CaptchaContext.cjs');
38
38
  require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
39
39
  var DynamicConnectButton = require('../../components/DynamicConnectButton/DynamicConnectButton.cjs');
40
40
  require('../../components/Popper/Popper/Popper.cjs');
41
- var PopperContext = require('../../components/Popper/PopperContext/PopperContext.cjs');
41
+ require('../../components/Popper/PopperContext/PopperContext.cjs');
42
42
  require('formik');
43
43
  require('yup');
44
44
  require('../../components/InlineWidget/InlineWidget.cjs');
@@ -67,7 +67,7 @@ const DynamicWidget = ({ buttonContainerClassName = '', buttonClassName = '', in
67
67
  }
68
68
  return Boolean(!primaryWallet);
69
69
  }, [authMode, primaryWallet, user]);
70
- return (jsxRuntime.jsx(IsBrowser.IsBrowser, { children: jsxRuntime.jsx(ShadowDOM.ShadowDOM, { className: 'dynamic-widget__container', id: 'dynamic-widget', children: showDynamicConnectButton ? (jsxRuntime.jsx(DynamicConnectButton.DynamicConnectButton, { buttonContainerClassName: buttonContainerClassName, buttonClassName: buttonClassName, children: innerButtonComponent })) : (jsxRuntime.jsxs(PopperContext.PopperProvider, { children: [jsxRuntime.jsx(DynamicNav.DynamicNav, {}), jsxRuntime.jsx(DynamicUserProfile.DynamicUserProfile, { variant: variant })] })) }) }));
70
+ return (jsxRuntime.jsx(IsBrowser.IsBrowser, { children: jsxRuntime.jsx(ShadowDOM.ShadowDOM, { className: 'dynamic-widget__container', id: 'dynamic-widget', children: showDynamicConnectButton ? (jsxRuntime.jsx(DynamicConnectButton.DynamicConnectButton, { buttonContainerClassName: buttonContainerClassName, buttonClassName: buttonClassName, children: innerButtonComponent })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(DynamicNav.DynamicNav, {}), jsxRuntime.jsx(DynamicUserProfile.DynamicUserProfile, { variant: variant })] })) }) }));
71
71
  };
72
72
 
73
73
  exports.DynamicWidget = DynamicWidget;
@@ -1,4 +1,4 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useCallback, useMemo } from 'react';
3
3
  import '@dynamic-labs/sdk-api';
4
4
  import '../../shared/logger.js';
@@ -34,7 +34,7 @@ import '../../context/CaptchaContext/CaptchaContext.js';
34
34
  import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
35
35
  import { DynamicConnectButton } from '../../components/DynamicConnectButton/DynamicConnectButton.js';
36
36
  import '../../components/Popper/Popper/Popper.js';
37
- import { PopperProvider } from '../../components/Popper/PopperContext/PopperContext.js';
37
+ import '../../components/Popper/PopperContext/PopperContext.js';
38
38
  import 'formik';
39
39
  import 'yup';
40
40
  import '../../components/InlineWidget/InlineWidget.js';
@@ -63,7 +63,7 @@ const DynamicWidget = ({ buttonContainerClassName = '', buttonClassName = '', in
63
63
  }
64
64
  return Boolean(!primaryWallet);
65
65
  }, [authMode, primaryWallet, user]);
66
- return (jsx(IsBrowser, { children: jsx(ShadowDOM, { className: 'dynamic-widget__container', id: 'dynamic-widget', children: showDynamicConnectButton ? (jsx(DynamicConnectButton, { buttonContainerClassName: buttonContainerClassName, buttonClassName: buttonClassName, children: innerButtonComponent })) : (jsxs(PopperProvider, { children: [jsx(DynamicNav, {}), jsx(DynamicUserProfile, { variant: variant })] })) }) }));
66
+ return (jsx(IsBrowser, { children: jsx(ShadowDOM, { className: 'dynamic-widget__container', id: 'dynamic-widget', children: showDynamicConnectButton ? (jsx(DynamicConnectButton, { buttonContainerClassName: buttonContainerClassName, buttonClassName: buttonClassName, children: innerButtonComponent })) : (jsxs(Fragment, { children: [jsx(DynamicNav, {}), jsx(DynamicUserProfile, { variant: variant })] })) }) }));
67
67
  };
68
68
 
69
69
  export { DynamicWidget };
@@ -10,6 +10,41 @@ var ShadowDOM = require('../../../../components/ShadowDOM/ShadowDOM.cjs');
10
10
  var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
11
11
  var IsBrowser = require('../../../../components/IsBrowser/IsBrowser.cjs');
12
12
  var NetworkPicker = require('../../../../components/NetworkPicker/NetworkPicker.cjs');
13
+ require('@dynamic-labs/sdk-api');
14
+ require('../../../../shared/logger.cjs');
15
+ require('@dynamic-labs/iconic');
16
+ require('@dynamic-labs/wallet-connector-core');
17
+ require('../../../../context/ViewContext/ViewContext.cjs');
18
+ require('@dynamic-labs/wallet-book');
19
+ require('@dynamic-labs/utils');
20
+ require('../../../../utils/constants/colors.cjs');
21
+ require('../../../../shared/utils/classes/storage/localStorage.cjs');
22
+ require('viem');
23
+ require('../../../../shared/consts/index.cjs');
24
+ require('@dynamic-labs/multi-wallet');
25
+ require('../../../../context/ThemeContext/ThemeContext.cjs');
26
+ require('react-dom');
27
+ require('react-focus-lock');
28
+ require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
29
+ require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
30
+ require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
31
+ require('../../../../config/ApiEndpoint.cjs');
32
+ require('@dynamic-labs/rpc-providers');
33
+ require('../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
34
+ require('../../../../context/ErrorContext/ErrorContext.cjs');
35
+ require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
36
+ require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
37
+ require('../../../../components/IconButton/IconButton.cjs');
38
+ require('../../../../components/Alert/Alert.cjs');
39
+ require('../../../../context/MockContext/MockContext.cjs');
40
+ require('../../../../context/CaptchaContext/CaptchaContext.cjs');
41
+ require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
42
+ require('../../../../components/Popper/Popper/Popper.cjs');
43
+ var PopperContext = require('../../../../components/Popper/PopperContext/PopperContext.cjs');
44
+ require('formik');
45
+ require('yup');
46
+ require('../../../../components/InlineWidget/InlineWidget.cjs');
47
+ require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
13
48
 
14
49
  const DynamicNav = () => {
15
50
  const [isNetworkPickerOpen, setIsNetworkPickerOpen] = React.useState(false);
@@ -20,7 +55,7 @@ const DynamicNav = () => {
20
55
  [];
21
56
  if (!projectSettings)
22
57
  return null;
23
- return (jsxRuntime.jsx(IsBrowser.IsBrowser, { children: jsxRuntime.jsxs("div", { ref: inlineControlsRef, "data-testid": 'DynamicNav', className: 'dynamic-widget-inline-controls', children: [primaryWallet && (jsxRuntime.jsx(NetworkPicker.NetworkPicker, { connector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, showNetworkName: true, isNetworkPickerOpen: isNetworkPickerOpen, setIsNetworkPickerOpen: setIsNetworkPickerOpen, mainClassName: 'dynamic-widget-inline-controls__network-picker-main', buttonClassName: 'dynamic-widget-inline-controls__network-picker', listClassName: 'dynamic-widget-inline-controls__network-picker-list', checkboxClassName: 'dynamic-widget-inline-controls__network-picker-checkbox', evmNetworks: evmNetworks })), jsxRuntime.jsx("div", { className: 'dynamic-widget-inline-controls__account-control-container', children: jsxRuntime.jsx(AccountControl.AccountControl, { className: 'dynamic-widget-inline-controls__account-control' }) })] }) }));
58
+ return (jsxRuntime.jsx(IsBrowser.IsBrowser, { children: jsxRuntime.jsxs("div", { ref: inlineControlsRef, "data-testid": 'DynamicNav', className: 'dynamic-widget-inline-controls', children: [primaryWallet && (jsxRuntime.jsx(PopperContext.PopperProvider, { children: jsxRuntime.jsx(NetworkPicker.NetworkPicker, { connector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, showNetworkName: true, isNetworkPickerOpen: isNetworkPickerOpen, setIsNetworkPickerOpen: setIsNetworkPickerOpen, mainClassName: 'dynamic-widget-inline-controls__network-picker-main', buttonClassName: 'dynamic-widget-inline-controls__network-picker', listClassName: 'dynamic-widget-inline-controls__network-picker-list', checkboxClassName: 'dynamic-widget-inline-controls__network-picker-checkbox', evmNetworks: evmNetworks }) })), jsxRuntime.jsx("div", { className: 'dynamic-widget-inline-controls__account-control-container', children: jsxRuntime.jsx(AccountControl.AccountControl, { className: 'dynamic-widget-inline-controls__account-control' }) })] }) }));
24
59
  };
25
60
  const ShadowedDynamicNav = () => (jsxRuntime.jsx(ShadowDOM.ShadowDOM, { children: jsxRuntime.jsx(DynamicNav, {}) }));
26
61
 
@@ -6,6 +6,41 @@ import { ShadowDOM } from '../../../../components/ShadowDOM/ShadowDOM.js';
6
6
  import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
7
7
  import { IsBrowser } from '../../../../components/IsBrowser/IsBrowser.js';
8
8
  import { NetworkPicker } from '../../../../components/NetworkPicker/NetworkPicker.js';
9
+ import '@dynamic-labs/sdk-api';
10
+ import '../../../../shared/logger.js';
11
+ import '@dynamic-labs/iconic';
12
+ import '@dynamic-labs/wallet-connector-core';
13
+ import '../../../../context/ViewContext/ViewContext.js';
14
+ import '@dynamic-labs/wallet-book';
15
+ import '@dynamic-labs/utils';
16
+ import '../../../../utils/constants/colors.js';
17
+ import '../../../../shared/utils/classes/storage/localStorage.js';
18
+ import 'viem';
19
+ import '../../../../shared/consts/index.js';
20
+ import '@dynamic-labs/multi-wallet';
21
+ import '../../../../context/ThemeContext/ThemeContext.js';
22
+ import 'react-dom';
23
+ import 'react-focus-lock';
24
+ import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
25
+ import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
26
+ import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
27
+ import '../../../../config/ApiEndpoint.js';
28
+ import '@dynamic-labs/rpc-providers';
29
+ import '../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
30
+ import '../../../../context/ErrorContext/ErrorContext.js';
31
+ import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
32
+ import '../../../../context/AccountExistsContext/AccountExistsContext.js';
33
+ import '../../../../components/IconButton/IconButton.js';
34
+ import '../../../../components/Alert/Alert.js';
35
+ import '../../../../context/MockContext/MockContext.js';
36
+ import '../../../../context/CaptchaContext/CaptchaContext.js';
37
+ import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
38
+ import '../../../../components/Popper/Popper/Popper.js';
39
+ import { PopperProvider } from '../../../../components/Popper/PopperContext/PopperContext.js';
40
+ import 'formik';
41
+ import 'yup';
42
+ import '../../../../components/InlineWidget/InlineWidget.js';
43
+ import '../../../../components/MenuList/Dropdown/Dropdown.js';
9
44
 
10
45
  const DynamicNav = () => {
11
46
  const [isNetworkPickerOpen, setIsNetworkPickerOpen] = useState(false);
@@ -16,7 +51,7 @@ const DynamicNav = () => {
16
51
  [];
17
52
  if (!projectSettings)
18
53
  return null;
19
- return (jsx(IsBrowser, { children: jsxs("div", { ref: inlineControlsRef, "data-testid": 'DynamicNav', className: 'dynamic-widget-inline-controls', children: [primaryWallet && (jsx(NetworkPicker, { connector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, showNetworkName: true, isNetworkPickerOpen: isNetworkPickerOpen, setIsNetworkPickerOpen: setIsNetworkPickerOpen, mainClassName: 'dynamic-widget-inline-controls__network-picker-main', buttonClassName: 'dynamic-widget-inline-controls__network-picker', listClassName: 'dynamic-widget-inline-controls__network-picker-list', checkboxClassName: 'dynamic-widget-inline-controls__network-picker-checkbox', evmNetworks: evmNetworks })), jsx("div", { className: 'dynamic-widget-inline-controls__account-control-container', children: jsx(AccountControl, { className: 'dynamic-widget-inline-controls__account-control' }) })] }) }));
54
+ return (jsx(IsBrowser, { children: jsxs("div", { ref: inlineControlsRef, "data-testid": 'DynamicNav', className: 'dynamic-widget-inline-controls', children: [primaryWallet && (jsx(PopperProvider, { children: jsx(NetworkPicker, { connector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, showNetworkName: true, isNetworkPickerOpen: isNetworkPickerOpen, setIsNetworkPickerOpen: setIsNetworkPickerOpen, mainClassName: 'dynamic-widget-inline-controls__network-picker-main', buttonClassName: 'dynamic-widget-inline-controls__network-picker', listClassName: 'dynamic-widget-inline-controls__network-picker-list', checkboxClassName: 'dynamic-widget-inline-controls__network-picker-checkbox', evmNetworks: evmNetworks }) })), jsx("div", { className: 'dynamic-widget-inline-controls__account-control-container', children: jsx(AccountControl, { className: 'dynamic-widget-inline-controls__account-control' }) })] }) }));
20
55
  };
21
56
  const ShadowedDynamicNav = () => (jsx(ShadowDOM, { children: jsx(DynamicNav, {}) }));
22
57
 
@@ -41,7 +41,7 @@ require('../../../../context/MockContext/MockContext.cjs');
41
41
  require('../../../../context/CaptchaContext/CaptchaContext.cjs');
42
42
  require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
43
43
  require('../../../../components/Popper/Popper/Popper.cjs');
44
- require('../../../../components/Popper/PopperContext/PopperContext.cjs');
44
+ var PopperContext = require('../../../../components/Popper/PopperContext/PopperContext.cjs');
45
45
  require('formik');
46
46
  require('yup');
47
47
  require('../../../../components/InlineWidget/InlineWidget.cjs');
@@ -63,7 +63,7 @@ const DynamicUserProfile = ({ variant, }) => {
63
63
  if (!projectSettings)
64
64
  return null;
65
65
  const shouldRenderHeader = dynamicWidgetView !== 'send-balance';
66
- return (jsxRuntime.jsx(IsBrowser.IsBrowser, { children: jsxRuntime.jsx(DynamicWidgetVariants.DynamicWidgetVariants, { isOpen: isOpen, setIsOpen: setIsOpen, variant: _variant, zIndex: index.widgetModalZIndex, children: jsxRuntime.jsx(DynamicWidgetCard.DynamicWidgetCard, { ref: widgetRef, children: jsxRuntime.jsxs(OverlayCardTarget.OverlayCardTarget, { children: [shouldRenderHeader && jsxRuntime.jsx(DynamicWidgetHeader.MemoizedDynamicWidgetHeader, { variant: variant }), jsxRuntime.jsx(DynamicWidgetViews.DynamicWidgetViews, {}), jsxRuntime.jsx(DynamicWidgetPrompts.DynamicWidgetPrompts, {})] }) }) }) }));
66
+ return (jsxRuntime.jsx(IsBrowser.IsBrowser, { children: jsxRuntime.jsx(PopperContext.PopperProvider, { children: jsxRuntime.jsx(DynamicWidgetVariants.DynamicWidgetVariants, { isOpen: isOpen, setIsOpen: setIsOpen, variant: _variant, zIndex: index.widgetModalZIndex, children: jsxRuntime.jsx(DynamicWidgetCard.DynamicWidgetCard, { ref: widgetRef, children: jsxRuntime.jsxs(OverlayCardTarget.OverlayCardTarget, { children: [shouldRenderHeader && jsxRuntime.jsx(DynamicWidgetHeader.MemoizedDynamicWidgetHeader, { variant: variant }), jsxRuntime.jsx(DynamicWidgetViews.DynamicWidgetViews, {}), jsxRuntime.jsx(DynamicWidgetPrompts.DynamicWidgetPrompts, {})] }) }) }) }) }));
67
67
  };
68
68
  const ShadowedDynamicUserProfile = () => (jsxRuntime.jsx(ShadowDOM.ShadowDOM, { zIndex: index.widgetModalZIndex, children: jsxRuntime.jsx(DynamicUserProfile, {}) }));
69
69
 
@@ -37,7 +37,7 @@ import '../../../../context/MockContext/MockContext.js';
37
37
  import '../../../../context/CaptchaContext/CaptchaContext.js';
38
38
  import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
39
39
  import '../../../../components/Popper/Popper/Popper.js';
40
- import '../../../../components/Popper/PopperContext/PopperContext.js';
40
+ import { PopperProvider } from '../../../../components/Popper/PopperContext/PopperContext.js';
41
41
  import 'formik';
42
42
  import 'yup';
43
43
  import '../../../../components/InlineWidget/InlineWidget.js';
@@ -59,7 +59,7 @@ const DynamicUserProfile = ({ variant, }) => {
59
59
  if (!projectSettings)
60
60
  return null;
61
61
  const shouldRenderHeader = dynamicWidgetView !== 'send-balance';
62
- return (jsx(IsBrowser, { children: jsx(DynamicWidgetVariants, { isOpen: isOpen, setIsOpen: setIsOpen, variant: _variant, zIndex: widgetModalZIndex, children: jsx(DynamicWidgetCard, { ref: widgetRef, children: jsxs(OverlayCardTarget, { children: [shouldRenderHeader && jsx(MemoizedDynamicWidgetHeader, { variant: variant }), jsx(DynamicWidgetViews, {}), jsx(DynamicWidgetPrompts, {})] }) }) }) }));
62
+ return (jsx(IsBrowser, { children: jsx(PopperProvider, { children: jsx(DynamicWidgetVariants, { isOpen: isOpen, setIsOpen: setIsOpen, variant: _variant, zIndex: widgetModalZIndex, children: jsx(DynamicWidgetCard, { ref: widgetRef, children: jsxs(OverlayCardTarget, { children: [shouldRenderHeader && jsx(MemoizedDynamicWidgetHeader, { variant: variant }), jsx(DynamicWidgetViews, {}), jsx(DynamicWidgetPrompts, {})] }) }) }) }) }));
63
63
  };
64
64
  const ShadowedDynamicUserProfile = () => (jsx(ShadowDOM, { zIndex: widgetModalZIndex, children: jsx(DynamicUserProfile, {}) }));
65
65
 
@@ -38,6 +38,7 @@ require('formik');
38
38
  require('yup');
39
39
  require('../../../components/InlineWidget/InlineWidget.cjs');
40
40
  require('../../../components/MenuList/Dropdown/Dropdown.cjs');
41
+ var useViewController = require('../hooks/useViewController/useViewController.cjs');
41
42
  var useKYCFlag = require('../../../utils/hooks/useKYCFlag/useKYCFlag.cjs');
42
43
  var useMultiWalletFlag = require('../../../utils/hooks/useMultiWalletFlag/useMultiWalletFlag.cjs');
43
44
  require('../../../context/MockContext/MockContext.cjs');
@@ -52,8 +53,7 @@ const DynamicWidgetContextProvider = ({ children, }) => {
52
53
  const { setShowDynamicUserProfile, showDynamicUserProfile } = useInternalDynamicContext.useInternalDynamicContext();
53
54
  const isKYCEnabled = useKYCFlag.useKYCFlag();
54
55
  const isMultiWalletEnabled = useMultiWalletFlag.useMultiWalletFlag();
55
- const initialView = React.useMemo(() => (isKYCEnabled && !isMultiWalletEnabled ? 'profile' : 'wallets'), [isKYCEnabled, isMultiWalletEnabled]);
56
- const [dynamicWidgetView, setDynamicWidgetView] = React.useState(initialView);
56
+ const { view: dynamicWidgetView, setView: setDynamicWidgetView, goToInitialView: goToInitialDynamicWidgetView, } = useViewController.useViewController(isKYCEnabled && !isMultiWalletEnabled ? 'profile' : 'wallets');
57
57
  const goToProfileView = React.useCallback(() => {
58
58
  if (isKYCEnabled)
59
59
  return setDynamicWidgetView('profile');
@@ -64,18 +64,14 @@ const DynamicWidgetContextProvider = ({ children, }) => {
64
64
  if (!showDynamicUserProfile) {
65
65
  // wait for exit animation to finish
66
66
  setTimeout(() => {
67
- setDynamicWidgetView(initialView);
67
+ goToInitialDynamicWidgetView();
68
68
  }, 200);
69
69
  }
70
- }, [initialView, showDynamicUserProfile]);
71
- // set correct initial view once isKYCEnabled and isMultiWalletEnabled values are correctly set
72
- // *isKYCEnabled is always false when the context initializes, so the initial view is set to index
73
- React.useEffect(() => {
74
- setDynamicWidgetView(initialView);
75
- }, [initialView, isKYCEnabled, isMultiWalletEnabled]);
70
+ }, [goToInitialDynamicWidgetView, showDynamicUserProfile]);
76
71
  const value = React.useMemo(() => ({
77
72
  availableWalletsContainerRef,
78
73
  dynamicWidgetView,
74
+ goToInitialDynamicWidgetView,
79
75
  goToProfileView,
80
76
  inlineControlsRef,
81
77
  isOpen: showDynamicUserProfile,
@@ -84,8 +80,9 @@ const DynamicWidgetContextProvider = ({ children, }) => {
84
80
  widgetRef,
85
81
  }), [
86
82
  dynamicWidgetView,
87
- goToProfileView,
88
83
  setShowDynamicUserProfile,
84
+ goToInitialDynamicWidgetView,
85
+ goToProfileView,
89
86
  showDynamicUserProfile,
90
87
  ]);
91
88
  return (jsxRuntime.jsx(DynamicWidgetContext.Provider, { value: value, children: children }));
@@ -3,6 +3,7 @@ export interface WidgetContextProps {
3
3
  availableWalletsContainerRef: RefObject<HTMLDivElement>;
4
4
  dynamicWidgetView: DynamicWidgetViews;
5
5
  goToProfileView: () => void;
6
+ goToInitialDynamicWidgetView: () => void;
6
7
  inlineControlsRef: RefObject<HTMLDivElement>;
7
8
  isOpen: boolean;
8
9
  setDynamicWidgetView: Dispatch<SetStateAction<DynamicWidgetViews>>;
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { createContext, useRef, useMemo, useState, useCallback, useEffect, useContext } from 'react';
2
+ import { createContext, useRef, useCallback, useEffect, useMemo, useContext } from 'react';
3
3
  import '@dynamic-labs/utils';
4
4
  import '@dynamic-labs/sdk-api';
5
5
  import '../../../config/ApiEndpoint.js';
@@ -34,6 +34,7 @@ import 'formik';
34
34
  import 'yup';
35
35
  import '../../../components/InlineWidget/InlineWidget.js';
36
36
  import '../../../components/MenuList/Dropdown/Dropdown.js';
37
+ import { useViewController } from '../hooks/useViewController/useViewController.js';
37
38
  import { useKYCFlag } from '../../../utils/hooks/useKYCFlag/useKYCFlag.js';
38
39
  import { useMultiWalletFlag } from '../../../utils/hooks/useMultiWalletFlag/useMultiWalletFlag.js';
39
40
  import '../../../context/MockContext/MockContext.js';
@@ -48,8 +49,7 @@ const DynamicWidgetContextProvider = ({ children, }) => {
48
49
  const { setShowDynamicUserProfile, showDynamicUserProfile } = useInternalDynamicContext();
49
50
  const isKYCEnabled = useKYCFlag();
50
51
  const isMultiWalletEnabled = useMultiWalletFlag();
51
- const initialView = useMemo(() => (isKYCEnabled && !isMultiWalletEnabled ? 'profile' : 'wallets'), [isKYCEnabled, isMultiWalletEnabled]);
52
- const [dynamicWidgetView, setDynamicWidgetView] = useState(initialView);
52
+ const { view: dynamicWidgetView, setView: setDynamicWidgetView, goToInitialView: goToInitialDynamicWidgetView, } = useViewController(isKYCEnabled && !isMultiWalletEnabled ? 'profile' : 'wallets');
53
53
  const goToProfileView = useCallback(() => {
54
54
  if (isKYCEnabled)
55
55
  return setDynamicWidgetView('profile');
@@ -60,18 +60,14 @@ const DynamicWidgetContextProvider = ({ children, }) => {
60
60
  if (!showDynamicUserProfile) {
61
61
  // wait for exit animation to finish
62
62
  setTimeout(() => {
63
- setDynamicWidgetView(initialView);
63
+ goToInitialDynamicWidgetView();
64
64
  }, 200);
65
65
  }
66
- }, [initialView, showDynamicUserProfile]);
67
- // set correct initial view once isKYCEnabled and isMultiWalletEnabled values are correctly set
68
- // *isKYCEnabled is always false when the context initializes, so the initial view is set to index
69
- useEffect(() => {
70
- setDynamicWidgetView(initialView);
71
- }, [initialView, isKYCEnabled, isMultiWalletEnabled]);
66
+ }, [goToInitialDynamicWidgetView, showDynamicUserProfile]);
72
67
  const value = useMemo(() => ({
73
68
  availableWalletsContainerRef,
74
69
  dynamicWidgetView,
70
+ goToInitialDynamicWidgetView,
75
71
  goToProfileView,
76
72
  inlineControlsRef,
77
73
  isOpen: showDynamicUserProfile,
@@ -80,8 +76,9 @@ const DynamicWidgetContextProvider = ({ children, }) => {
80
76
  widgetRef,
81
77
  }), [
82
78
  dynamicWidgetView,
83
- goToProfileView,
84
79
  setShowDynamicUserProfile,
80
+ goToInitialDynamicWidgetView,
81
+ goToProfileView,
85
82
  showDynamicUserProfile,
86
83
  ]);
87
84
  return (jsx(DynamicWidgetContext.Provider, { value: value, children: children }));
@@ -2,3 +2,4 @@ export { useContent } from './useContent';
2
2
  export { useFetchBalance } from './useFetchBalance';
3
3
  export { useFetchChain } from './useFetchChain';
4
4
  export { useFetchCurrency } from './useFetchCurrency';
5
+ export { useViewController } from './useViewController';
@@ -0,0 +1 @@
1
+ export { useViewController } from './useViewController';
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+
7
+ const useViewController = (initialView) => {
8
+ const [_view, setView] = React.useState(null);
9
+ const goToInitialView = () => setView(null);
10
+ return {
11
+ goToInitialView,
12
+ setView: setView,
13
+ view: _view || initialView,
14
+ };
15
+ };
16
+
17
+ exports.useViewController = useViewController;
@@ -0,0 +1,6 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ export declare const useViewController: <VIEW extends string>(initialView: VIEW) => {
3
+ goToInitialView: () => void;
4
+ setView: Dispatch<SetStateAction<VIEW>>;
5
+ view: VIEW;
6
+ };
@@ -0,0 +1,13 @@
1
+ import { useState } from 'react';
2
+
3
+ const useViewController = (initialView) => {
4
+ const [_view, setView] = useState(null);
5
+ const goToInitialView = () => setView(null);
6
+ return {
7
+ goToInitialView,
8
+ setView: setView,
9
+ view: _view || initialView,
10
+ };
11
+ };
12
+
13
+ export { useViewController };
@@ -50,7 +50,7 @@ var UserProfileForm = require('../../../../components/UserProfileForm/UserProfil
50
50
 
51
51
  const EditProfileView = ({ rootClassName, }) => {
52
52
  const { setView } = ViewContext.useViewContext();
53
- const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
53
+ const { internalSetShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
54
54
  const { goToProfileView } = DynamicWidgetContext.useWidgetContext();
55
55
  const { updateUser } = useUserUpdateRequest.useUserUpdateRequestInternal({
56
56
  validationSchemaStripUnknown: true,
@@ -59,10 +59,10 @@ const EditProfileView = ({ rootClassName, }) => {
59
59
  const { isEmailVerificationRequired } = yield updateUser(formValues);
60
60
  goToProfileView();
61
61
  if (isEmailVerificationRequired) {
62
- setShowAuthFlow(true);
62
+ internalSetShowAuthFlow(true);
63
63
  setView('verify-email');
64
64
  }
65
- }), [goToProfileView, setShowAuthFlow, setView, updateUser]);
65
+ }), [goToProfileView, internalSetShowAuthFlow, setView, updateUser]);
66
66
  const isKYCEnabled = useKYCFlag.useKYCFlag();
67
67
  const isMultiWalletEnabled = useMultiWalletFlag.useMultiWalletFlag();
68
68
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!isMultiWalletEnabled && isKYCEnabled && (jsxRuntime.jsx(Typography.Typography, { weight: 'regular', color: 'secondary', variant: 'body_normal', className: 'dynamic-widget-edit-profile-view__profile-title', children: "My profile" })), jsxRuntime.jsx(UserProfileForm.UserProfileForm, { formClassName: rootClassName, onEditProfileSubmit: onEditProfileFormSubmit, onEditProfileCancel: goToProfileView })] }));
@@ -46,7 +46,7 @@ import { UserProfileForm } from '../../../../components/UserProfileForm/UserProf
46
46
 
47
47
  const EditProfileView = ({ rootClassName, }) => {
48
48
  const { setView } = useViewContext();
49
- const { setShowAuthFlow } = useInternalDynamicContext();
49
+ const { internalSetShowAuthFlow } = useInternalDynamicContext();
50
50
  const { goToProfileView } = useWidgetContext();
51
51
  const { updateUser } = useUserUpdateRequestInternal({
52
52
  validationSchemaStripUnknown: true,
@@ -55,10 +55,10 @@ const EditProfileView = ({ rootClassName, }) => {
55
55
  const { isEmailVerificationRequired } = yield updateUser(formValues);
56
56
  goToProfileView();
57
57
  if (isEmailVerificationRequired) {
58
- setShowAuthFlow(true);
58
+ internalSetShowAuthFlow(true);
59
59
  setView('verify-email');
60
60
  }
61
- }), [goToProfileView, setShowAuthFlow, setView, updateUser]);
61
+ }), [goToProfileView, internalSetShowAuthFlow, setView, updateUser]);
62
62
  const isKYCEnabled = useKYCFlag();
63
63
  const isMultiWalletEnabled = useMultiWalletFlag();
64
64
  return (jsxs(Fragment, { children: [!isMultiWalletEnabled && isKYCEnabled && (jsx(Typography, { weight: 'regular', color: 'secondary', variant: 'body_normal', className: 'dynamic-widget-edit-profile-view__profile-title', children: "My profile" })), jsx(UserProfileForm, { formClassName: rootClassName, onEditProfileSubmit: onEditProfileFormSubmit, onEditProfileCancel: goToProfileView })] }));
@@ -7,9 +7,8 @@ var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
7
7
  var SendBalanceView = require('../../../../views/SendBalanceView/SendBalanceView.cjs');
8
8
 
9
9
  const SendBalanceWidgetView = () => {
10
- const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
11
- const goToIndex = () => setDynamicWidgetView('wallets');
12
- return (jsxRuntime.jsx("div", { className: 'send-balance-widget-view', children: jsxRuntime.jsx(SendBalanceView.SendBalanceView, { onClickBack: goToIndex, onDone: goToIndex }) }));
10
+ const { goToInitialDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
11
+ return (jsxRuntime.jsx("div", { className: 'send-balance-widget-view', children: jsxRuntime.jsx(SendBalanceView.SendBalanceView, { onClickBack: goToInitialDynamicWidgetView, onDone: goToInitialDynamicWidgetView }) }));
13
12
  };
14
13
 
15
14
  exports.SendBalanceWidgetView = SendBalanceWidgetView;
@@ -3,9 +3,8 @@ import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
3
3
  import { SendBalanceView } from '../../../../views/SendBalanceView/SendBalanceView.js';
4
4
 
5
5
  const SendBalanceWidgetView = () => {
6
- const { setDynamicWidgetView } = useWidgetContext();
7
- const goToIndex = () => setDynamicWidgetView('wallets');
8
- return (jsx("div", { className: 'send-balance-widget-view', children: jsx(SendBalanceView, { onClickBack: goToIndex, onDone: goToIndex }) }));
6
+ const { goToInitialDynamicWidgetView } = useWidgetContext();
7
+ return (jsx("div", { className: 'send-balance-widget-view', children: jsx(SendBalanceView, { onClickBack: goToInitialDynamicWidgetView, onDone: goToInitialDynamicWidgetView }) }));
9
8
  };
10
9
 
11
10
  export { SendBalanceWidgetView };