@dynamic-labs/sdk-react-core 4.9.1 → 4.9.2

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 (96) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +12 -12
  5. package/src/index.cjs +3 -1
  6. package/src/index.d.ts +4 -3
  7. package/src/index.js +2 -1
  8. package/src/lib/components/Portal/ModalComponent/ModalComponent.cjs +32 -0
  9. package/src/lib/components/Portal/ModalComponent/ModalComponent.d.ts +9 -0
  10. package/src/lib/components/Portal/ModalComponent/ModalComponent.js +24 -0
  11. package/src/lib/components/Portal/ModalComponent/index.d.ts +1 -0
  12. package/src/lib/components/Portal/Portal.cjs +3 -119
  13. package/src/lib/components/Portal/Portal.d.ts +3 -8
  14. package/src/lib/components/Portal/Portal.js +3 -115
  15. package/src/lib/components/TransactionCard/SendBalanceTransactionCard.cjs +1 -1
  16. package/src/lib/components/TransactionCard/SendBalanceTransactionCard.js +1 -1
  17. package/src/lib/components/TransactionCard/TransactionCard.cjs +1 -1
  18. package/src/lib/components/TransactionCard/TransactionCard.js +1 -1
  19. package/src/lib/components/Typography/Typography.cjs +1 -0
  20. package/src/lib/components/Typography/Typography.js +1 -0
  21. package/src/lib/components/Typography/Typography.types.d.ts +1 -1
  22. package/src/lib/components/WalletConnectorEvents/WalletConnectorEvents.cjs +10 -2
  23. package/src/lib/components/WalletConnectorEvents/WalletConnectorEvents.js +10 -2
  24. package/src/lib/context/DynamicContext/DynamicContext.cjs +13 -9
  25. package/src/lib/context/DynamicContext/DynamicContext.js +15 -11
  26. package/src/lib/context/DynamicContext/helpers/helpers.cjs +0 -12
  27. package/src/lib/context/DynamicContext/helpers/helpers.d.ts +1 -9
  28. package/src/lib/context/DynamicContext/helpers/helpers.js +1 -12
  29. package/src/lib/context/DynamicContext/hooks/useInitialViewType/index.d.ts +1 -0
  30. package/src/lib/context/DynamicContext/hooks/useInitialViewType/useInitialViewType.cjs +18 -0
  31. package/src/lib/context/DynamicContext/hooks/useInitialViewType/useInitialViewType.d.ts +10 -0
  32. package/src/lib/context/DynamicContext/hooks/useInitialViewType/useInitialViewType.js +14 -0
  33. package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.cjs +1 -1
  34. package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.js +1 -1
  35. package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +6 -2
  36. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +1 -1
  37. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +1 -1
  38. package/src/lib/context/ViewContext/ViewContext.cjs +1 -1
  39. package/src/lib/context/ViewContext/ViewContext.js +1 -1
  40. package/src/lib/locale/en/translation.cjs +2 -2
  41. package/src/lib/locale/en/translation.d.ts +1 -1
  42. package/src/lib/locale/en/translation.js +2 -2
  43. package/src/lib/main.global.cjs +1 -1
  44. package/src/lib/main.global.js +1 -1
  45. package/src/lib/styles/index.shadow.cjs +1 -1
  46. package/src/lib/styles/index.shadow.js +1 -1
  47. package/src/lib/utils/constants/authViewLayoutChecks.cjs +135 -0
  48. package/src/lib/utils/constants/authViewLayoutChecks.d.ts +21 -0
  49. package/src/lib/utils/constants/authViewLayoutChecks.js +123 -0
  50. package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/index.d.ts +1 -0
  51. package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.cjs +36 -0
  52. package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.d.ts +11 -0
  53. package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.js +32 -0
  54. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +20 -93
  55. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.d.ts +1 -0
  56. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +19 -92
  57. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +7 -4
  58. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +5 -2
  59. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +7 -4
  60. package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +2 -1
  61. package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +2 -1
  62. package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.cjs +3 -2
  63. package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.js +3 -2
  64. package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.cjs +8 -2
  65. package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.js +9 -3
  66. package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -1
  67. package/src/lib/views/EmailVerification/EmailVerification.js +1 -1
  68. package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.cjs +4 -1
  69. package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.js +4 -1
  70. package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.cjs +1 -4
  71. package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.js +1 -4
  72. package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +4 -10
  73. package/src/lib/views/MfaVerificationView/MfaVerificationView.js +4 -10
  74. package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs +7 -5
  75. package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js +7 -5
  76. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs +164 -0
  77. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.d.ts +3 -0
  78. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.js +160 -0
  79. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/index.d.ts +1 -0
  80. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +11 -50
  81. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +11 -50
  82. package/src/lib/widgets/DynamicWidget/components/Balance/Balance.cjs +2 -2
  83. package/src/lib/widgets/DynamicWidget/components/Balance/Balance.d.ts +2 -1
  84. package/src/lib/widgets/DynamicWidget/components/Balance/Balance.js +2 -2
  85. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +4 -4
  86. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +4 -4
  87. package/src/lib/widgets/DynamicWidget/views/DepositView/DepositView.cjs +1 -1
  88. package/src/lib/widgets/DynamicWidget/views/DepositView/DepositView.js +1 -1
  89. /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceItem/TokenBalanceItem.cjs +0 -0
  90. /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceItem/TokenBalanceItem.d.ts +0 -0
  91. /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceItem/TokenBalanceItem.js +0 -0
  92. /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceItem/index.d.ts +0 -0
  93. /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceList/TokenBalanceList.cjs +0 -0
  94. /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceList/TokenBalanceList.d.ts +0 -0
  95. /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceList/TokenBalanceList.js +0 -0
  96. /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceList/index.d.ts +0 -0
@@ -0,0 +1,135 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const viewsThatPreventBorderBelowHeader = [
7
+ 'wallet-list',
8
+ 'login-with-email-or-wallet-full-wallet-list',
9
+ 'multi-wallet-wallet-list',
10
+ 'login-with-wallet-only',
11
+ ];
12
+ const viewsWithWalletListType = [
13
+ 'wallet-connect-mobile-wallets-list',
14
+ 'wallet-list',
15
+ 'login-with-email-or-wallet-full-wallet-list',
16
+ 'login-with-wallet-only',
17
+ ];
18
+ const viewsThatHideHelpContent = [
19
+ 'qr-code',
20
+ 'no-qr-not-installed',
21
+ 'wallet-used',
22
+ 'chainalysis-blocked-wallet',
23
+ 'wallet-sign',
24
+ 'collect-user-data',
25
+ 'passkey-new-domain-detected',
26
+ ];
27
+ const viewsThatHideHeader = [
28
+ 'collect-user-data',
29
+ 'no-access',
30
+ 'chainalysis-blocked-wallet',
31
+ 'wallet-locked-view',
32
+ 'gate-blocked-wallet',
33
+ 'email-wallet-otp-verification-view',
34
+ 'bridge-welcome',
35
+ 'bridge-summary',
36
+ 'bridge-next-wallet-connection',
37
+ 'passkey-intro',
38
+ 'passkey-new-domain-detected',
39
+ 'social-redirect-view',
40
+ 'collect-user-data-login-no-wallet',
41
+ 'passkey-recovery-bundle',
42
+ 'passkey-recovery-start',
43
+ 'embedded-reveal-view',
44
+ 'embedded-reveal-account-view',
45
+ 'rename-passkey',
46
+ 'embedded-wallet-auth-choice',
47
+ 'passkey-recovery-add-email',
48
+ 'global-wallet-confirm',
49
+ 'global-wallet-malicious',
50
+ 'global-wallet-info',
51
+ 'mfa-choose-device',
52
+ 'mfa-verification',
53
+ ];
54
+ const viewsThatShowConnectedWalletProgress = [
55
+ 'wallet-list',
56
+ 'qr-code',
57
+ 'wallet-connect-mobile-wallets-list',
58
+ 'pending-connect',
59
+ 'pending-signature',
60
+ 'pending-signature-without-back-button',
61
+ 'bridge-next-wallet-connection',
62
+ 'bridge-summary',
63
+ ];
64
+ const viewsThatShowDynamicFooter = [
65
+ 'login-with-email-or-wallet',
66
+ 'login-with-email-or-wallet-full-wallet-list',
67
+ 'login-with-wallet-only',
68
+ 'login-with-email-verification',
69
+ 'login-with-sms-verification',
70
+ 'verify-email',
71
+ 'verify-sms',
72
+ 'pending-connect',
73
+ 'wallet-group',
74
+ 'select-wallet-in-wallet-group',
75
+ 'select-hardware-wallet',
76
+ 'pending-signature',
77
+ 'qr-code',
78
+ 'wallet-used',
79
+ 'email-wallet-otp-verification-view',
80
+ 'farcaster-connect-view',
81
+ 'merge-user-accounts',
82
+ 'merge-user-accounts-conflicts',
83
+ 'mfa-verification',
84
+ 'mfa-display-backup-codes',
85
+ 'mfa-recovery',
86
+ ];
87
+ /**
88
+ * User is not able to close the modal in these views at all
89
+ */
90
+ const viewsThatPreventModalClose = [
91
+ 'collect-user-data',
92
+ 'login-with-email-verification',
93
+ 'login-with-sms-verification',
94
+ ];
95
+ /**
96
+ * When hasPendingMfaAction returns true, user is not able to close the modal in these views at all
97
+ */
98
+ const mfaViewsThatPreventModalClose = [
99
+ 'mfa-verification',
100
+ 'mfa-choose-device',
101
+ 'mfa-secure-device',
102
+ 'mfa-display-backup-codes',
103
+ 'mfa-recovery',
104
+ ];
105
+ /**
106
+ * These views only hide the close button, but unless they are also
107
+ * in the viewsThatPreventModalClose array, the user can still close the modal
108
+ * via other means (such as pressing the escape key or clicking the backdrop).
109
+ */
110
+ const viewsThatHideCloseButton = [
111
+ 'login-with-email-or-wallet-full-wallet-list',
112
+ 'login-with-email-verification',
113
+ 'login-with-sms-verification',
114
+ 'network-not-supported',
115
+ 'passkey-recovery-complete',
116
+ 'passkey-recovery-start',
117
+ 'passkey-recovery-bundle',
118
+ 'rename-passkey',
119
+ 'mobile-wallet-redirect-view',
120
+ 'qr-code',
121
+ 'mfa-verification',
122
+ 'mfa-display-backup-codes',
123
+ 'mfa-recovery',
124
+ 'user-delete-account',
125
+ ];
126
+
127
+ exports.mfaViewsThatPreventModalClose = mfaViewsThatPreventModalClose;
128
+ exports.viewsThatHideCloseButton = viewsThatHideCloseButton;
129
+ exports.viewsThatHideHeader = viewsThatHideHeader;
130
+ exports.viewsThatHideHelpContent = viewsThatHideHelpContent;
131
+ exports.viewsThatPreventBorderBelowHeader = viewsThatPreventBorderBelowHeader;
132
+ exports.viewsThatPreventModalClose = viewsThatPreventModalClose;
133
+ exports.viewsThatShowConnectedWalletProgress = viewsThatShowConnectedWalletProgress;
134
+ exports.viewsThatShowDynamicFooter = viewsThatShowDynamicFooter;
135
+ exports.viewsWithWalletListType = viewsWithWalletListType;
@@ -0,0 +1,21 @@
1
+ import type { ViewType } from '../../context/ViewContext/types';
2
+ export declare const viewsThatPreventBorderBelowHeader: ViewType[];
3
+ export declare const viewsWithWalletListType: ViewType[];
4
+ export declare const viewsThatHideHelpContent: ViewType[];
5
+ export declare const viewsThatHideHeader: ViewType[];
6
+ export declare const viewsThatShowConnectedWalletProgress: ViewType[];
7
+ export declare const viewsThatShowDynamicFooter: ViewType[];
8
+ /**
9
+ * User is not able to close the modal in these views at all
10
+ */
11
+ export declare const viewsThatPreventModalClose: ViewType[];
12
+ /**
13
+ * When hasPendingMfaAction returns true, user is not able to close the modal in these views at all
14
+ */
15
+ export declare const mfaViewsThatPreventModalClose: ViewType[];
16
+ /**
17
+ * These views only hide the close button, but unless they are also
18
+ * in the viewsThatPreventModalClose array, the user can still close the modal
19
+ * via other means (such as pressing the escape key or clicking the backdrop).
20
+ */
21
+ export declare const viewsThatHideCloseButton: ViewType[];
@@ -0,0 +1,123 @@
1
+ 'use client'
2
+ const viewsThatPreventBorderBelowHeader = [
3
+ 'wallet-list',
4
+ 'login-with-email-or-wallet-full-wallet-list',
5
+ 'multi-wallet-wallet-list',
6
+ 'login-with-wallet-only',
7
+ ];
8
+ const viewsWithWalletListType = [
9
+ 'wallet-connect-mobile-wallets-list',
10
+ 'wallet-list',
11
+ 'login-with-email-or-wallet-full-wallet-list',
12
+ 'login-with-wallet-only',
13
+ ];
14
+ const viewsThatHideHelpContent = [
15
+ 'qr-code',
16
+ 'no-qr-not-installed',
17
+ 'wallet-used',
18
+ 'chainalysis-blocked-wallet',
19
+ 'wallet-sign',
20
+ 'collect-user-data',
21
+ 'passkey-new-domain-detected',
22
+ ];
23
+ const viewsThatHideHeader = [
24
+ 'collect-user-data',
25
+ 'no-access',
26
+ 'chainalysis-blocked-wallet',
27
+ 'wallet-locked-view',
28
+ 'gate-blocked-wallet',
29
+ 'email-wallet-otp-verification-view',
30
+ 'bridge-welcome',
31
+ 'bridge-summary',
32
+ 'bridge-next-wallet-connection',
33
+ 'passkey-intro',
34
+ 'passkey-new-domain-detected',
35
+ 'social-redirect-view',
36
+ 'collect-user-data-login-no-wallet',
37
+ 'passkey-recovery-bundle',
38
+ 'passkey-recovery-start',
39
+ 'embedded-reveal-view',
40
+ 'embedded-reveal-account-view',
41
+ 'rename-passkey',
42
+ 'embedded-wallet-auth-choice',
43
+ 'passkey-recovery-add-email',
44
+ 'global-wallet-confirm',
45
+ 'global-wallet-malicious',
46
+ 'global-wallet-info',
47
+ 'mfa-choose-device',
48
+ 'mfa-verification',
49
+ ];
50
+ const viewsThatShowConnectedWalletProgress = [
51
+ 'wallet-list',
52
+ 'qr-code',
53
+ 'wallet-connect-mobile-wallets-list',
54
+ 'pending-connect',
55
+ 'pending-signature',
56
+ 'pending-signature-without-back-button',
57
+ 'bridge-next-wallet-connection',
58
+ 'bridge-summary',
59
+ ];
60
+ const viewsThatShowDynamicFooter = [
61
+ 'login-with-email-or-wallet',
62
+ 'login-with-email-or-wallet-full-wallet-list',
63
+ 'login-with-wallet-only',
64
+ 'login-with-email-verification',
65
+ 'login-with-sms-verification',
66
+ 'verify-email',
67
+ 'verify-sms',
68
+ 'pending-connect',
69
+ 'wallet-group',
70
+ 'select-wallet-in-wallet-group',
71
+ 'select-hardware-wallet',
72
+ 'pending-signature',
73
+ 'qr-code',
74
+ 'wallet-used',
75
+ 'email-wallet-otp-verification-view',
76
+ 'farcaster-connect-view',
77
+ 'merge-user-accounts',
78
+ 'merge-user-accounts-conflicts',
79
+ 'mfa-verification',
80
+ 'mfa-display-backup-codes',
81
+ 'mfa-recovery',
82
+ ];
83
+ /**
84
+ * User is not able to close the modal in these views at all
85
+ */
86
+ const viewsThatPreventModalClose = [
87
+ 'collect-user-data',
88
+ 'login-with-email-verification',
89
+ 'login-with-sms-verification',
90
+ ];
91
+ /**
92
+ * When hasPendingMfaAction returns true, user is not able to close the modal in these views at all
93
+ */
94
+ const mfaViewsThatPreventModalClose = [
95
+ 'mfa-verification',
96
+ 'mfa-choose-device',
97
+ 'mfa-secure-device',
98
+ 'mfa-display-backup-codes',
99
+ 'mfa-recovery',
100
+ ];
101
+ /**
102
+ * These views only hide the close button, but unless they are also
103
+ * in the viewsThatPreventModalClose array, the user can still close the modal
104
+ * via other means (such as pressing the escape key or clicking the backdrop).
105
+ */
106
+ const viewsThatHideCloseButton = [
107
+ 'login-with-email-or-wallet-full-wallet-list',
108
+ 'login-with-email-verification',
109
+ 'login-with-sms-verification',
110
+ 'network-not-supported',
111
+ 'passkey-recovery-complete',
112
+ 'passkey-recovery-start',
113
+ 'passkey-recovery-bundle',
114
+ 'rename-passkey',
115
+ 'mobile-wallet-redirect-view',
116
+ 'qr-code',
117
+ 'mfa-verification',
118
+ 'mfa-display-backup-codes',
119
+ 'mfa-recovery',
120
+ 'user-delete-account',
121
+ ];
122
+
123
+ export { mfaViewsThatPreventModalClose, viewsThatHideCloseButton, viewsThatHideHeader, viewsThatHideHelpContent, viewsThatPreventBorderBelowHeader, viewsThatPreventModalClose, viewsThatShowConnectedWalletProgress, viewsThatShowDynamicFooter, viewsWithWalletListType };
@@ -0,0 +1 @@
1
+ export * from './useAllowClose';
@@ -0,0 +1,36 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var ViewContext = require('../../../../context/ViewContext/ViewContext.cjs');
7
+ var hasPendingMfaAction = require('../../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.cjs');
8
+ var user = require('../../../../store/state/user/user.cjs');
9
+ require('@dynamic-labs/utils');
10
+ require('../../../constants/values.cjs');
11
+ require('@dynamic-labs/sdk-api-core');
12
+ require('../../../../store/state/projectSettings/projectSettings.cjs');
13
+ var authViewLayoutChecks = require('../../../constants/authViewLayoutChecks.cjs');
14
+
15
+ const useAllowClose = () => {
16
+ const { view } = ViewContext.useViewContext();
17
+ const user$1 = user.useUserCoalesced();
18
+ const isMfaPreventingClose = user$1 &&
19
+ hasPendingMfaAction.hasPendingMfaAction(user$1) &&
20
+ authViewLayoutChecks.mfaViewsThatPreventModalClose.includes(view.type);
21
+ const allowsClosing = !isMfaPreventingClose && !authViewLayoutChecks.viewsThatPreventModalClose.includes(view.type);
22
+ const showCloseButton = allowsClosing && !authViewLayoutChecks.viewsThatHideCloseButton.includes(view.type);
23
+ return {
24
+ /**
25
+ * Whether user can close the current view
26
+ */
27
+ allowsClosing,
28
+ /**
29
+ * Whether the close button should be shown.
30
+ * Even if the view allows closing, the close button may still be hidden.
31
+ */
32
+ showCloseButton,
33
+ };
34
+ };
35
+
36
+ exports.useAllowClose = useAllowClose;
@@ -0,0 +1,11 @@
1
+ export declare const useAllowClose: () => {
2
+ /**
3
+ * Whether user can close the current view
4
+ */
5
+ allowsClosing: boolean;
6
+ /**
7
+ * Whether the close button should be shown.
8
+ * Even if the view allows closing, the close button may still be hidden.
9
+ */
10
+ showCloseButton: boolean;
11
+ };
@@ -0,0 +1,32 @@
1
+ 'use client'
2
+ import { useViewContext } from '../../../../context/ViewContext/ViewContext.js';
3
+ import { hasPendingMfaAction } from '../../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.js';
4
+ import { useUserCoalesced } from '../../../../store/state/user/user.js';
5
+ import '@dynamic-labs/utils';
6
+ import '../../../constants/values.js';
7
+ import '@dynamic-labs/sdk-api-core';
8
+ import '../../../../store/state/projectSettings/projectSettings.js';
9
+ import { mfaViewsThatPreventModalClose, viewsThatPreventModalClose, viewsThatHideCloseButton } from '../../../constants/authViewLayoutChecks.js';
10
+
11
+ const useAllowClose = () => {
12
+ const { view } = useViewContext();
13
+ const user = useUserCoalesced();
14
+ const isMfaPreventingClose = user &&
15
+ hasPendingMfaAction(user) &&
16
+ mfaViewsThatPreventModalClose.includes(view.type);
17
+ const allowsClosing = !isMfaPreventingClose && !viewsThatPreventModalClose.includes(view.type);
18
+ const showCloseButton = allowsClosing && !viewsThatHideCloseButton.includes(view.type);
19
+ return {
20
+ /**
21
+ * Whether user can close the current view
22
+ */
23
+ allowsClosing,
24
+ /**
25
+ * Whether the close button should be shown.
26
+ * Even if the view allows closing, the close button may still be hidden.
27
+ */
28
+ showCloseButton,
29
+ };
30
+ };
31
+
32
+ export { useAllowClose };
@@ -23,9 +23,9 @@ require('../../../context/ErrorContext/ErrorContext.cjs');
23
23
  require('@dynamic-labs/multi-wallet');
24
24
  require('react-international-phone');
25
25
  require('../../../store/state/nonce/nonce.cjs');
26
- require('../../../store/state/projectSettings/projectSettings.cjs');
26
+ var projectSettings = require('../../../store/state/projectSettings/projectSettings.cjs');
27
27
  require('../../../config/ApiEndpoint.cjs');
28
- require('../../../store/state/user/user.cjs');
28
+ var user = require('../../../store/state/user/user.cjs');
29
29
  require('../../../locale/locale.cjs');
30
30
  require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
31
31
  require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
@@ -69,6 +69,7 @@ require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBa
69
69
  require('../../../components/Popper/Popper/Popper.cjs');
70
70
  require('../../../components/Popper/PopperContext/PopperContext.cjs');
71
71
  require('react-focus-lock');
72
+ var useAllowClose = require('./useAllowClose/useAllowClose.cjs');
72
73
  require('qrcode');
73
74
  require('formik');
74
75
  require('../useSubdomainCheck/useSubdomainCheck.cjs');
@@ -79,9 +80,10 @@ require('../../../context/ConnectWithOtpContext/constants.cjs');
79
80
  require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
80
81
  require('@hcaptcha/react-hcaptcha');
81
82
  require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
83
+ var index = require('../../../context/FooterAnimationContext/index.cjs');
82
84
  var isUserLinkingWallet = require('../../../shared/utils/functions/isUserLinkingWallet/isUserLinkingWallet.cjs');
85
+ var authViewLayoutChecks = require('../../constants/authViewLayoutChecks.cjs');
83
86
  var useDynamicLayoutData = require('../useDynamicLayoutData/useDynamicLayoutData.cjs');
84
- var index = require('../../../context/FooterAnimationContext/index.cjs');
85
87
  require('../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
86
88
  require('../../../context/PasskeyContext/PasskeyContext.cjs');
87
89
  require('../../../store/state/sendBalances.cjs');
@@ -100,67 +102,24 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
100
102
  const useAuthLayoutChecks = () => {
101
103
  var _a;
102
104
  const { view } = ViewContext.useViewContext();
103
- const { user, customPrivacyPolicy, customTermsOfServices, privacyPolicyUrl, termsOfServiceUrl, isBridgeFlow, authMode, projectSettings, } = useInternalDynamicContext.useInternalDynamicContext();
105
+ const { customPrivacyPolicy, customTermsOfServices, privacyPolicyUrl, termsOfServiceUrl, isBridgeFlow, authMode, } = useInternalDynamicContext.useInternalDynamicContext();
104
106
  const { isFooterExpanded } = index.useFooterAnimationContext();
105
107
  const { mockedSDK } = MockContext.useMockContext();
106
108
  const { helpHeaderData } = useDynamicLayoutData.useDynamicLayoutData({
107
109
  authMode,
108
110
  view: view.type,
109
111
  });
110
- const displayBorderBelowHeader = (view.type !== 'wallet-list' &&
111
- view.type !== 'login-with-email-or-wallet-full-wallet-list' &&
112
- view.type !== 'multi-wallet-wallet-list' &&
113
- view.type !== 'login-with-wallet-only') ||
114
- isFooterExpanded;
115
- const isWalletListTypeView = view.type === 'wallet-connect-mobile-wallets-list' ||
116
- view.type === 'wallet-list' ||
117
- view.type === 'login-with-email-or-wallet-full-wallet-list' ||
118
- view.type === 'login-with-wallet-only';
112
+ const user$1 = user.useUserCoalesced();
113
+ const projectSettings$1 = projectSettings.useProjectSettings();
114
+ const isLinkingWallet = isUserLinkingWallet.isUserLinkingWallet(user$1, view.type, mockedSDK);
115
+ const displayBorderBelowHeader = !authViewLayoutChecks.viewsThatPreventBorderBelowHeader.includes(view.type) || isFooterExpanded;
116
+ const isWalletListTypeView = authViewLayoutChecks.viewsWithWalletListType.includes(view.type);
119
117
  const showHelpContent = Boolean(helpHeaderData &&
120
- // Notice the negation here
121
- !(view.type === 'qr-code' ||
122
- view.type === 'no-qr-not-installed' ||
123
- view.type === 'wallet-used' ||
124
- view.type === 'chainalysis-blocked-wallet' ||
125
- view.type === 'wallet-sign' ||
126
- view.type === 'collect-user-data' ||
127
- view.type === 'passkey-new-domain-detected' ||
128
- isUserLinkingWallet.isUserLinkingWallet(user, view.type, mockedSDK)));
129
- const showHeader = view.type !== 'collect-user-data' &&
130
- view.type !== 'no-access' &&
131
- view.type !== 'chainalysis-blocked-wallet' &&
132
- view.type !== 'wallet-locked-view' &&
133
- view.type !== 'gate-blocked-wallet' &&
134
- view.type !== 'email-wallet-otp-verification-view' &&
135
- view.type !== 'bridge-welcome' &&
136
- view.type !== 'bridge-summary' &&
137
- view.type !== 'bridge-next-wallet-connection' &&
138
- view.type !== 'passkey-intro' &&
139
- view.type !== 'passkey-new-domain-detected' &&
140
- view.type !== 'social-redirect-view' &&
141
- view.type !== 'collect-user-data-login-no-wallet' &&
142
- view.type !== 'passkey-recovery-bundle' &&
143
- view.type !== 'passkey-recovery-start' &&
144
- view.type !== 'embedded-reveal-view' &&
145
- view.type !== 'embedded-reveal-account-view' &&
146
- view.type !== 'rename-passkey' &&
147
- view.type !== 'embedded-wallet-auth-choice' &&
148
- view.type !== 'passkey-recovery-add-email' &&
149
- view.type !== 'global-wallet-confirm' &&
150
- view.type !== 'global-wallet-malicious' &&
151
- view.type !== 'global-wallet-info' &&
152
- view.type !== 'mfa-choose-device' &&
153
- view.type !== 'mfa-verification';
154
- const showConnectedWalletProgress = isBridgeFlow &&
155
- (view.type === 'wallet-list' ||
156
- view.type === 'qr-code' ||
157
- view.type === 'wallet-connect-mobile-wallets-list' ||
158
- view.type === 'pending-connect' ||
159
- view.type === 'pending-signature' ||
160
- view.type === 'pending-signature-without-back-button' ||
161
- view.type === 'bridge-next-wallet-connection' ||
162
- view.type === 'bridge-summary');
163
- const showToSFooter = Boolean(!isUserLinkingWallet.isUserLinkingWallet(user, view.type, mockedSDK) &&
118
+ !authViewLayoutChecks.viewsThatHideHelpContent.includes(view.type) &&
119
+ !isLinkingWallet);
120
+ const showHeader = !authViewLayoutChecks.viewsThatHideHeader.includes(view.type);
121
+ const showConnectedWalletProgress = isBridgeFlow && authViewLayoutChecks.viewsThatShowConnectedWalletProgress.includes(view.type);
122
+ const showToSFooter = Boolean(!isLinkingWallet &&
164
123
  (view.type === 'wallet-list' ||
165
124
  view.type === 'wallet-connect-mobile-wallets-list' ||
166
125
  // Don't show empty footer during the login
@@ -172,45 +131,13 @@ const useAuthLayoutChecks = () => {
172
131
  privacyPolicyUrl ||
173
132
  customPrivacyPolicy ||
174
133
  customTermsOfServices))));
175
- const showDynamicFooter = Boolean((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.displayDynamicMessaging) &&
176
- (view.type === 'login-with-email-or-wallet' ||
177
- view.type === 'login-with-email-or-wallet-full-wallet-list' ||
178
- view.type === 'login-with-wallet-only' ||
179
- view.type === 'login-with-email-verification' ||
180
- view.type === 'login-with-sms-verification' ||
181
- view.type === 'verify-email' ||
182
- view.type === 'verify-sms' ||
183
- view.type === 'pending-connect' ||
184
- view.type === 'wallet-group' ||
185
- view.type === 'select-wallet-in-wallet-group' ||
186
- view.type === 'select-hardware-wallet' ||
187
- view.type === 'pending-signature' ||
188
- view.type === 'qr-code' ||
189
- view.type === 'wallet-used' ||
190
- view.type === 'email-wallet-otp-verification-view' ||
191
- view.type === 'farcaster-connect-view' ||
192
- view.type === 'merge-user-accounts' ||
193
- view.type === 'merge-user-accounts-conflicts' ||
194
- view.type === 'mfa-verification' ||
195
- view.type === 'mfa-display-backup-codes' ||
196
- view.type === 'mfa-recovery');
197
- const showCloseButton = view.type !== 'login-with-email-or-wallet-full-wallet-list' &&
198
- view.type !== 'login-with-email-verification' &&
199
- view.type !== 'login-with-sms-verification' &&
200
- view.type !== 'network-not-supported' &&
201
- view.type !== 'passkey-recovery-complete' &&
202
- view.type !== 'passkey-recovery-start' &&
203
- view.type !== 'passkey-recovery-bundle' &&
204
- view.type !== 'rename-passkey' &&
205
- view.type !== 'mobile-wallet-redirect-view' &&
206
- view.type !== 'qr-code' &&
207
- view.type !== 'mfa-verification' &&
208
- view.type !== 'mfa-display-backup-codes' &&
209
- view.type !== 'mfa-recovery' &&
210
- view.type !== 'user-delete-account';
134
+ const showDynamicFooter = Boolean((_a = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk) === null || _a === void 0 ? void 0 : _a.displayDynamicMessaging) &&
135
+ authViewLayoutChecks.viewsThatShowDynamicFooter.includes(view.type);
211
136
  const showDefaultFooter = !showConnectedWalletProgress && !showDynamicFooter && !showToSFooter;
212
137
  const shouldHideDynamicFooterSeparator = showDynamicFooter && showToSFooter;
138
+ const { allowsClosing, showCloseButton } = useAllowClose.useAllowClose();
213
139
  return {
140
+ allowsClosing,
214
141
  displayBorderBelowHeader,
215
142
  isWalletListTypeView,
216
143
  shouldHideDynamicFooterSeparator,
@@ -1,4 +1,5 @@
1
1
  export declare const useAuthLayoutChecks: () => {
2
+ allowsClosing: boolean;
2
3
  displayBorderBelowHeader: boolean;
3
4
  isWalletListTypeView: boolean;
4
5
  shouldHideDynamicFooterSeparator: boolean;