@dynamic-labs/sdk-react-core 2.1.0-alpha.15 → 2.1.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/package.cjs +3 -2
- package/package.js +3 -2
- package/package.json +13 -12
- package/src/index.cjs +0 -2
- package/src/index.d.ts +1 -3
- package/src/index.js +0 -1
- package/src/lib/components/Portal/Portal.cjs +3 -1
- package/src/lib/components/Portal/Portal.js +3 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +20 -14
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +2 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +20 -14
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +5 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +5 -1
- package/src/lib/context/DynamicContext/types/index.d.ts +4 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +2 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +2 -1
- package/src/lib/context/DynamicContext/validators/validators.cjs +0 -29
- package/src/lib/context/DynamicContext/validators/validators.d.ts +0 -2
- package/src/lib/context/DynamicContext/validators/validators.js +1 -29
- package/src/lib/context/ViewContext/types/index.d.ts +1 -1
- package/src/lib/locale/en/translation.cjs +18 -0
- package/src/lib/locale/en/translation.d.ts +18 -0
- package/src/lib/locale/en/translation.js +18 -0
- package/src/lib/shared/utils/classes/storage/localStorage.cjs +1 -8
- package/src/lib/shared/utils/classes/storage/localStorage.js +2 -9
- package/src/lib/shared/utils/functions/index.d.ts +0 -1
- package/src/lib/shared/utils/functions/wallet/createWallet.d.ts +0 -4
- package/src/lib/store/actions/storeActions/index.d.ts +1 -0
- package/src/lib/store/actions/storeActions/storeActions.cjs +10 -0
- package/src/lib/store/actions/storeActions/storeActions.d.ts +1 -0
- package/src/lib/store/actions/storeActions/storeActions.js +6 -0
- package/src/lib/store/actions/userActions/index.d.ts +1 -0
- package/src/lib/store/actions/userActions/userActions.cjs +10 -0
- package/src/lib/store/actions/userActions/userActions.d.ts +7 -0
- package/src/lib/store/actions/userActions/userActions.js +6 -0
- package/src/lib/store/hooks/useUser/index.d.ts +1 -0
- package/src/lib/store/hooks/useUser/useUser.cjs +12 -0
- package/src/lib/store/hooks/useUser/useUser.d.ts +1 -0
- package/src/lib/store/hooks/useUser/useUser.js +8 -0
- package/src/lib/store/index.d.ts +4 -0
- package/src/lib/store/store.cjs +24 -0
- package/src/lib/store/store.d.ts +13 -0
- package/src/lib/store/store.js +19 -0
- package/src/lib/store/types.d.ts +4 -0
- package/src/lib/store/utils/createStore/createStore.cjs +21 -0
- package/src/lib/store/utils/createStore/createStore.d.ts +16 -0
- package/src/lib/store/utils/createStore/createStore.js +17 -0
- package/src/lib/store/utils/createStore/index.d.ts +1 -0
- package/src/lib/store/utils/syncLegacyStorage/index.d.ts +1 -0
- package/src/lib/store/utils/syncLegacyStorage/syncLegacyStorage.cjs +30 -0
- package/src/lib/store/utils/syncLegacyStorage/syncLegacyStorage.d.ts +2 -0
- package/src/lib/store/utils/syncLegacyStorage/syncLegacyStorage.js +26 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/index.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.cjs +2 -2
- package/src/lib/utils/constants/localStorage.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.js +2 -2
- package/src/lib/utils/functions/downloadFile/downloadFile.cjs +15 -0
- package/src/lib/utils/functions/downloadFile/downloadFile.d.ts +1 -0
- package/src/lib/utils/functions/downloadFile/downloadFile.js +11 -0
- package/src/lib/utils/functions/downloadFile/index.d.ts +1 -0
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +4 -2
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +4 -2
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.cjs +4 -0
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.js +4 -0
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.cjs +6 -3
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.d.ts +1 -4
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.js +5 -2
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.cjs +6 -2
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.d.ts +1 -4
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.js +5 -1
- package/src/lib/utils/hooks/useWalletConnectorOptions/useWalletConnectorOptions.cjs +2 -1
- package/src/lib/utils/hooks/useWalletConnectorOptions/useWalletConnectorOptions.d.ts +3 -2
- package/src/lib/utils/hooks/useWalletConnectorOptions/useWalletConnectorOptions.js +2 -1
- package/src/lib/views/CreatePasswordView/SavePasswordStep/SavePasswordStep.cjs +5 -10
- package/src/lib/views/CreatePasswordView/SavePasswordStep/SavePasswordStep.js +5 -10
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.cjs +111 -0
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.d.ts +2 -0
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.js +107 -0
- package/src/lib/views/MfaDisplayBackupCodesView/index.d.ts +1 -0
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +3 -3
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +3 -3
- package/src/lib/views/WalletList/WalletListGridTabs/WalletListGridTabs.cjs +1 -1
- package/src/lib/views/WalletList/WalletListGridTabs/WalletListGridTabs.js +1 -1
- package/src/lib/views/WalletList/hooks/useTabState.cjs +4 -1
- package/src/lib/views/WalletList/hooks/useTabState.js +4 -1
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.cjs +22 -0
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.d.ts +2 -0
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.js +18 -0
- package/src/lib/views/WalletList/utils/getInitialTabIndex/index.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/shared/utils/functions/validateType/index.d.ts +0 -1
- package/src/lib/shared/utils/functions/validateType/validateType.cjs +0 -30
- package/src/lib/shared/utils/functions/validateType/validateType.d.ts +0 -1
- package/src/lib/shared/utils/functions/validateType/validateType.js +0 -26
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import '../../events/dynamicEvents.js';
|
|
6
|
+
import '../../../../_virtual/_tslib.js';
|
|
7
|
+
import '@dynamic-labs/utils';
|
|
8
|
+
import '../../context/DynamicContext/DynamicContext.js';
|
|
9
|
+
import '@dynamic-labs/sdk-api-core';
|
|
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 { ReactComponent as SvgCopy } from '../../shared/assets/copy.js';
|
|
15
|
+
import { ReactComponent as SvgDownload } from '../../shared/assets/download.js';
|
|
16
|
+
import '@dynamic-labs/wallet-book';
|
|
17
|
+
import '../../utils/constants/colors.js';
|
|
18
|
+
import '../../utils/constants/values.js';
|
|
19
|
+
import '../../shared/utils/classes/storage/localStorage.js';
|
|
20
|
+
import '../../shared/consts/index.js';
|
|
21
|
+
import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
22
|
+
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
23
|
+
import '../../context/ErrorContext/ErrorContext.js';
|
|
24
|
+
import '@dynamic-labs/multi-wallet';
|
|
25
|
+
import 'react-international-phone';
|
|
26
|
+
import 'viem';
|
|
27
|
+
import 'viem/chains';
|
|
28
|
+
import '../../config/ApiEndpoint.js';
|
|
29
|
+
import '../../locale/locale.js';
|
|
30
|
+
import { downloadFile } from '../../utils/functions/downloadFile/downloadFile.js';
|
|
31
|
+
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
32
|
+
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
33
|
+
import '../../context/UserWalletsContext/UserWalletsContext.js';
|
|
34
|
+
import '../../context/VerificationContext/VerificationContext.js';
|
|
35
|
+
import 'react-dom';
|
|
36
|
+
import '../../context/WalletContext/WalletContext.js';
|
|
37
|
+
import { usePromise } from '../../utils/hooks/usePromise/usePromise.js';
|
|
38
|
+
import '../../context/ThemeContext/ThemeContext.js';
|
|
39
|
+
import '@dynamic-labs/types';
|
|
40
|
+
import '../../context/LoadingContext/LoadingContext.js';
|
|
41
|
+
import 'yup';
|
|
42
|
+
import '../../context/MockContext/MockContext.js';
|
|
43
|
+
import '../../context/FieldsStateContext/FieldsStateContext.js';
|
|
44
|
+
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
45
|
+
import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
46
|
+
import '@dynamic-labs/rpc-providers';
|
|
47
|
+
import { Typography } from '../../components/Typography/Typography.js';
|
|
48
|
+
import '../../context/FooterAnimationContext/index.js';
|
|
49
|
+
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
50
|
+
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
51
|
+
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
52
|
+
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
53
|
+
import '../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
54
|
+
import '../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
55
|
+
import '../../context/WalletGroupContext/WalletGroupContext.js';
|
|
56
|
+
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
57
|
+
import 'react-focus-lock';
|
|
58
|
+
import { Icon } from '../../components/Icon/Icon.js';
|
|
59
|
+
import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
60
|
+
import '../../components/IconButton/IconButton.js';
|
|
61
|
+
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
62
|
+
import 'formik';
|
|
63
|
+
import { TypographyButton } from '../../components/TypographyButton/TypographyButton.js';
|
|
64
|
+
import '../TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
65
|
+
import { Spinner } from '../../components/Spinner/spinner.js';
|
|
66
|
+
import { Alert } from '../../components/Alert/Alert.js';
|
|
67
|
+
import '../../components/Input/Input.js';
|
|
68
|
+
import '../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
69
|
+
import '../../context/PasskeyContext/PasskeyContext.js';
|
|
70
|
+
import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
71
|
+
import { useMfa } from '../../utils/hooks/useMfa/useMfa.js';
|
|
72
|
+
import { Checkbox } from '../../components/Checkbox/Checkbox.js';
|
|
73
|
+
import { CopyButton } from '../../components/CopyButton/CopyButton.js';
|
|
74
|
+
import '../../components/InlineWidget/InlineWidget.js';
|
|
75
|
+
import '../../components/IsBrowser/IsBrowser.js';
|
|
76
|
+
import '../../components/Popper/Popper/Popper.js';
|
|
77
|
+
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
78
|
+
import 'qrcode';
|
|
79
|
+
import '../WalletList/WalletList.js';
|
|
80
|
+
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
81
|
+
import '@hcaptcha/react-hcaptcha';
|
|
82
|
+
import '../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.js';
|
|
83
|
+
|
|
84
|
+
const MfaDisplayBackupCodesView = () => {
|
|
85
|
+
const { setShowAuthFlow } = useInternalDynamicContext();
|
|
86
|
+
const [acknowledgement, setAcknowledgement] = useState(false);
|
|
87
|
+
const { t } = useTranslation();
|
|
88
|
+
const { getRecoveryCodes } = useMfa();
|
|
89
|
+
const { data: codes, isLoading } = usePromise(() => getRecoveryCodes());
|
|
90
|
+
const codesAsString = (codes || []).join('\n');
|
|
91
|
+
return (jsxs("div", { className: 'mfa-display-backup-codes-view__body', "data-testid": 'mfa-display-backup-codes-view', children: [jsx(Typography, { className: 'mfa-display-backup-codes-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: t('dyn_mfa.display_backup_codes_view.body') }), jsx(Alert, { variant: 'warning', copykey: 'dyn_mfa.display_backup_codes_view.warning', className: 'mfa-display-backup-codes-view__warning', children: t('dyn_mfa.display_backup_codes_view.warning') }), isLoading ? (jsx(Spinner, { className: 'mfa-display-backup-codes-view__loading-spinner' })) : (jsxs("div", { className: 'mfa-display-backup-codes-view__codes', children: [codes === null || codes === void 0 ? void 0 : codes.map((code, index) => (jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'mfa-display-backup-codes-view__code', children: code }, index))), jsxs("div", { className: 'mfa-display-backup-codes-view__actions', children: [jsx(CopyButton, { variant: 'button', textToCopy: codesAsString, copykey: 'dyn_mfa.display_backup_codes_view.copy_all', startSlot:
|
|
92
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
93
|
+
jsx(Icon, { size: 'mini', color: 'text-tertiary', children: jsx(SvgCopy, {}) }), children: t('dyn_mfa.display_backup_codes_view.copy_all') }), jsx(TypographyButton, { dataTestId: 'download-button', buttonPadding: 'small', buttonVariant: 'primary', onClick: (e) => {
|
|
94
|
+
e.preventDefault();
|
|
95
|
+
downloadFile('mfa-backup-codes.txt', codesAsString);
|
|
96
|
+
}, startSlot: jsx(SvgDownload, {}), expanded: true, copykey: 'dyn_mfa.display_backup_codes_view.download', children: t('dyn_mfa.display_backup_codes_view.download') })] })] })), jsxs("div", { className: 'mfa-display-backup-codes-view__complete', children: [jsx(TypographyButton, { buttonClassName: 'mfa-display-backup-codes-view__acknowledgement', dataTestId: 'ack-button', buttonPadding: 'small', buttonVariant: 'primary', onClick: () => setAcknowledgement(!acknowledgement), startSlot:
|
|
97
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
98
|
+
jsx(Checkbox, { checked: acknowledgement, onChange: () => {
|
|
99
|
+
setAcknowledgement(!acknowledgement);
|
|
100
|
+
}, className: 'mfa-display-backup-codes-view__acknowledgement__checkbox' }), expanded: true, typographyProps: {
|
|
101
|
+
color: 'secondary',
|
|
102
|
+
}, copykey: 'dyn_mfa.display_backup_codes_view.checkbox', children: t('dyn_mfa.display_backup_codes_view.checkbox') }), jsx(TypographyButton, { dataTestId: 'complete-button', buttonPadding: 'large', buttonVariant: 'brand-primary', typographyProps: {
|
|
103
|
+
color: 'inherit',
|
|
104
|
+
}, disabled: !acknowledgement, expanded: true, copykey: 'dyn_mfa.display_backup_codes_view.complete', onClick: () => setShowAuthFlow(false), children: t('dyn_mfa.display_backup_codes_view.complete') })] })] }));
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { MfaDisplayBackupCodesView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MfaDisplayBackupCodesView';
|
|
@@ -15,7 +15,7 @@ require('@dynamic-labs/sdk-api-core');
|
|
|
15
15
|
require('../../shared/logger.cjs');
|
|
16
16
|
require('@dynamic-labs/iconic');
|
|
17
17
|
require('@dynamic-labs/wallet-connector-core');
|
|
18
|
-
require('../../context/ViewContext/ViewContext.cjs');
|
|
18
|
+
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
19
19
|
var passwordHero = require('../../shared/assets/password-hero.cjs');
|
|
20
20
|
require('@dynamic-labs/wallet-book');
|
|
21
21
|
require('../../utils/constants/colors.cjs');
|
|
@@ -79,6 +79,7 @@ require('../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/
|
|
|
79
79
|
|
|
80
80
|
const MfaVerificationView = ({ type }) => {
|
|
81
81
|
const { t } = reactI18next.useTranslation();
|
|
82
|
+
const { setView } = ViewContext.useViewContext();
|
|
82
83
|
const { authDevice } = useMfa.useMfa();
|
|
83
84
|
const [code, setCode] = React.useState('');
|
|
84
85
|
const [error, setError] = React.useState();
|
|
@@ -90,8 +91,7 @@ const MfaVerificationView = ({ type }) => {
|
|
|
90
91
|
},
|
|
91
92
|
onResolve: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
92
93
|
yield utils.sleep(1500);
|
|
93
|
-
|
|
94
|
-
//setView('mfa-display-backup-codes');
|
|
94
|
+
setView('mfa-display-backup-codes');
|
|
95
95
|
}),
|
|
96
96
|
});
|
|
97
97
|
const onCodeChange = (code) => {
|
|
@@ -11,7 +11,7 @@ import '@dynamic-labs/sdk-api-core';
|
|
|
11
11
|
import '../../shared/logger.js';
|
|
12
12
|
import '@dynamic-labs/iconic';
|
|
13
13
|
import '@dynamic-labs/wallet-connector-core';
|
|
14
|
-
import '../../context/ViewContext/ViewContext.js';
|
|
14
|
+
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
15
15
|
import { ReactComponent as SvgPasswordHero } from '../../shared/assets/password-hero.js';
|
|
16
16
|
import '@dynamic-labs/wallet-book';
|
|
17
17
|
import '../../utils/constants/colors.js';
|
|
@@ -75,6 +75,7 @@ import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/P
|
|
|
75
75
|
|
|
76
76
|
const MfaVerificationView = ({ type }) => {
|
|
77
77
|
const { t } = useTranslation();
|
|
78
|
+
const { setView } = useViewContext();
|
|
78
79
|
const { authDevice } = useMfa();
|
|
79
80
|
const [code, setCode] = useState('');
|
|
80
81
|
const [error, setError] = useState();
|
|
@@ -86,8 +87,7 @@ const MfaVerificationView = ({ type }) => {
|
|
|
86
87
|
},
|
|
87
88
|
onResolve: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
89
|
yield sleep(1500);
|
|
89
|
-
|
|
90
|
-
//setView('mfa-display-backup-codes');
|
|
90
|
+
setView('mfa-display-backup-codes');
|
|
91
91
|
}),
|
|
92
92
|
});
|
|
93
93
|
const onCodeChange = (code) => {
|
|
@@ -79,7 +79,7 @@ require('../../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSect
|
|
|
79
79
|
const WalletListGridTabs = ({ items, onSelect, value, }) => (jsxRuntime.jsx("div", { className: 'wallet-list-grid-tabs', children: items.map((item, index) => {
|
|
80
80
|
const selected = value === index;
|
|
81
81
|
const { icon, text } = item.label;
|
|
82
|
-
const key = `${text}-${icon}`;
|
|
82
|
+
const key = `${text}-${icon}-${items.indexOf(item)}`;
|
|
83
83
|
const TabIcon = typeof icon === 'string' ? jsxRuntime.jsx("img", { src: icon, alt: text }) : icon;
|
|
84
84
|
return (jsxRuntime.jsxs("button", { type: 'button', className: classNames.classNames('wallet-list-grid-tabs__button', {
|
|
85
85
|
'wallet-list-grid-tabs__button--selected': selected,
|
|
@@ -75,7 +75,7 @@ import '../../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSecti
|
|
|
75
75
|
const WalletListGridTabs = ({ items, onSelect, value, }) => (jsx("div", { className: 'wallet-list-grid-tabs', children: items.map((item, index) => {
|
|
76
76
|
const selected = value === index;
|
|
77
77
|
const { icon, text } = item.label;
|
|
78
|
-
const key = `${text}-${icon}`;
|
|
78
|
+
const key = `${text}-${icon}-${items.indexOf(item)}`;
|
|
79
79
|
const TabIcon = typeof icon === 'string' ? jsx("img", { src: icon, alt: text }) : icon;
|
|
80
80
|
return (jsxs("button", { type: 'button', className: classNames('wallet-list-grid-tabs__button', {
|
|
81
81
|
'wallet-list-grid-tabs__button--selected': selected,
|
|
@@ -19,6 +19,7 @@ require('../../../utils/constants/colors.cjs');
|
|
|
19
19
|
require('../../../utils/constants/values.cjs');
|
|
20
20
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
21
21
|
require('../../../shared/consts/index.cjs');
|
|
22
|
+
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
22
23
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
23
24
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
24
25
|
require('@dynamic-labs/multi-wallet');
|
|
@@ -73,11 +74,13 @@ require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
|
73
74
|
require('../../TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
74
75
|
require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
75
76
|
var useViewSettings = require('../../../utils/hooks/useViewSettings/useViewSettings.cjs');
|
|
77
|
+
var getInitialTabIndex = require('../utils/getInitialTabIndex/getInitialTabIndex.cjs');
|
|
76
78
|
|
|
77
79
|
const useTabState = () => {
|
|
78
80
|
var _a, _b;
|
|
81
|
+
const { defaultTabIndex } = useInternalDynamicContext.useInternalDynamicContext();
|
|
79
82
|
const walletListViewSettings = useViewSettings.useViewSettings('wallet-list');
|
|
80
|
-
const [selectedTabIndex, setSelectedTabIndex] = React.useState(() =>
|
|
83
|
+
const [selectedTabIndex, setSelectedTabIndex] = React.useState(() => getInitialTabIndex.getInitialTabIndex(walletListViewSettings, defaultTabIndex));
|
|
81
84
|
const selectedTabSettings = selectedTabIndex === null
|
|
82
85
|
? undefined
|
|
83
86
|
: (_a = walletListViewSettings === null || walletListViewSettings === void 0 ? void 0 : walletListViewSettings.tabs) === null || _a === void 0 ? void 0 : _a.items[selectedTabIndex];
|
|
@@ -15,6 +15,7 @@ import '../../../utils/constants/colors.js';
|
|
|
15
15
|
import '../../../utils/constants/values.js';
|
|
16
16
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
17
17
|
import '../../../shared/consts/index.js';
|
|
18
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
18
19
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
19
20
|
import '../../../context/ErrorContext/ErrorContext.js';
|
|
20
21
|
import '@dynamic-labs/multi-wallet';
|
|
@@ -69,11 +70,13 @@ import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
|
69
70
|
import '../../TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
70
71
|
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
71
72
|
import { useViewSettings } from '../../../utils/hooks/useViewSettings/useViewSettings.js';
|
|
73
|
+
import { getInitialTabIndex } from '../utils/getInitialTabIndex/getInitialTabIndex.js';
|
|
72
74
|
|
|
73
75
|
const useTabState = () => {
|
|
74
76
|
var _a, _b;
|
|
77
|
+
const { defaultTabIndex } = useInternalDynamicContext();
|
|
75
78
|
const walletListViewSettings = useViewSettings('wallet-list');
|
|
76
|
-
const [selectedTabIndex, setSelectedTabIndex] = useState(() =>
|
|
79
|
+
const [selectedTabIndex, setSelectedTabIndex] = useState(() => getInitialTabIndex(walletListViewSettings, defaultTabIndex));
|
|
77
80
|
const selectedTabSettings = selectedTabIndex === null
|
|
78
81
|
? undefined
|
|
79
82
|
: (_a = walletListViewSettings === null || walletListViewSettings === void 0 ? void 0 : walletListViewSettings.tabs) === null || _a === void 0 ? void 0 : _a.items[selectedTabIndex];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const getInitialTabIndex = (walletListViewSettings, defaultTabIndex) => {
|
|
7
|
+
var _a, _b, _c, _d;
|
|
8
|
+
if (!walletListViewSettings) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
if (!((_b = (_a = walletListViewSettings.tabs) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
if (defaultTabIndex < 0) {
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
const lastIndex = ((_d = (_c = walletListViewSettings.tabs) === null || _c === void 0 ? void 0 : _c.items.length) !== null && _d !== void 0 ? _d : 1) - 1;
|
|
18
|
+
const initialTabIndex = Math.min(lastIndex, defaultTabIndex);
|
|
19
|
+
return initialTabIndex;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.getInitialTabIndex = getInitialTabIndex;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const getInitialTabIndex = (walletListViewSettings, defaultTabIndex) => {
|
|
3
|
+
var _a, _b, _c, _d;
|
|
4
|
+
if (!walletListViewSettings) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
if (!((_b = (_a = walletListViewSettings.tabs) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
if (defaultTabIndex < 0) {
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
const lastIndex = ((_d = (_c = walletListViewSettings.tabs) === null || _c === void 0 ? void 0 : _c.items.length) !== null && _d !== void 0 ? _d : 1) - 1;
|
|
14
|
+
const initialTabIndex = Math.min(lastIndex, defaultTabIndex);
|
|
15
|
+
return initialTabIndex;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { getInitialTabIndex };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getInitialTabIndex } from './getInitialTabIndex';
|
|
@@ -115,6 +115,7 @@ var WalletLockedView = require('./WalletLockedView/WalletLockedView.cjs');
|
|
|
115
115
|
var WalletRedirectView = require('./WalletRedirectView/WalletRedirectView.cjs');
|
|
116
116
|
var WalletSignSpinnerView = require('./WalletSignSpinnerView/WalletSignSpinnerView.cjs');
|
|
117
117
|
var WalletUsedView = require('./WalletUsedView/WalletUsedView.cjs');
|
|
118
|
+
var MfaDisplayBackupCodesView = require('./MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.cjs');
|
|
118
119
|
var MfaVerificationView = require('./MfaVerificationView/MfaVerificationView.cjs');
|
|
119
120
|
var PasskeyNewDomainDetectedView = require('./Passkey/PasskeyNewDomainDetectedView/PasskeyNewDomainDetectedView.cjs');
|
|
120
121
|
|
|
@@ -143,6 +144,7 @@ const viewToComponentMap = {
|
|
|
143
144
|
'merge-user-accounts-conflicts': MergeUserAccountsConflictsView.MergeUserAccountsConflictsView,
|
|
144
145
|
'merge-user-accounts-with-same-email': MergeUserAccountsWithSameEmailView.MergeUserAccountsWithSameEmailView,
|
|
145
146
|
'mfa-choose-device': MfaChooseDeviceView.MfaChooseDeviceView,
|
|
147
|
+
'mfa-display-backup-codes': MfaDisplayBackupCodesView.MfaDisplayBackupCodesView,
|
|
146
148
|
'mfa-secure-device': MfaSecureDeviceView.MfaSecureDeviceView,
|
|
147
149
|
'mfa-verification': MfaVerificationView.MfaVerificationView,
|
|
148
150
|
'multi-wallet-wallet-list': WalletList.WalletList,
|
|
@@ -27,6 +27,7 @@ export declare const viewToComponentMap: {
|
|
|
27
27
|
'merge-user-accounts-conflicts': import("react").FC<import("./MergeUserAccountsConflictsView/MergeUserAccountsConflictsView").MergeUserAccountsConflictsViewProps>;
|
|
28
28
|
'merge-user-accounts-with-same-email': import("react").FC<import("./MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView").MergeUserAccountsWithSameEmailViewProps>;
|
|
29
29
|
'mfa-choose-device': () => JSX.Element;
|
|
30
|
+
'mfa-display-backup-codes': () => JSX.Element;
|
|
30
31
|
'mfa-secure-device': ({ type }: import("./MfaSecureDeviceView").MfaSecureDeviceViewProps) => JSX.Element;
|
|
31
32
|
'mfa-verification': ({ type }: import("./MfaVerificationView").MfaVerificationViewProps) => JSX.Element;
|
|
32
33
|
'multi-wallet-wallet-list': ({ isWalletConnectList, }: import("./WalletList").WalletListProps) => JSX.Element;
|
|
@@ -111,6 +111,7 @@ import { WalletLockedView } from './WalletLockedView/WalletLockedView.js';
|
|
|
111
111
|
import { WalletRedirectView } from './WalletRedirectView/WalletRedirectView.js';
|
|
112
112
|
import { WalletSignSpinnerView } from './WalletSignSpinnerView/WalletSignSpinnerView.js';
|
|
113
113
|
import { WalletUsedView } from './WalletUsedView/WalletUsedView.js';
|
|
114
|
+
import { MfaDisplayBackupCodesView } from './MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.js';
|
|
114
115
|
import { MfaVerificationView } from './MfaVerificationView/MfaVerificationView.js';
|
|
115
116
|
import { PasskeyNewDomainDetectedView } from './Passkey/PasskeyNewDomainDetectedView/PasskeyNewDomainDetectedView.js';
|
|
116
117
|
|
|
@@ -139,6 +140,7 @@ const viewToComponentMap = {
|
|
|
139
140
|
'merge-user-accounts-conflicts': MergeUserAccountsConflictsView,
|
|
140
141
|
'merge-user-accounts-with-same-email': MergeUserAccountsWithSameEmailView,
|
|
141
142
|
'mfa-choose-device': MfaChooseDeviceView,
|
|
143
|
+
'mfa-display-backup-codes': MfaDisplayBackupCodesView,
|
|
142
144
|
'mfa-secure-device': MfaSecureDeviceView,
|
|
143
145
|
'mfa-verification': MfaVerificationView,
|
|
144
146
|
'multi-wallet-wallet-list': WalletList,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { validateType } from './validateType';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
const validateType = (
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
-
newValue, validationDataValue) => {
|
|
9
|
-
// arrays are also objects, but we need to handle arrays
|
|
10
|
-
// in a different way than objects
|
|
11
|
-
if (Array.isArray(newValue) && Array.isArray(validationDataValue)) {
|
|
12
|
-
if (newValue.length === 0) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
// eslint-disable-next-line prefer-destructuring
|
|
16
|
-
const itemValidationData = validationDataValue[0];
|
|
17
|
-
// validate all items in newData array matches item validation data
|
|
18
|
-
return Object.entries(newValue).every(([arrIndex, newValueItem]) => validateType(newValueItem, itemValidationData));
|
|
19
|
-
}
|
|
20
|
-
else if (typeof newValue === 'object' &&
|
|
21
|
-
typeof validationDataValue === 'object' &&
|
|
22
|
-
validationDataValue) {
|
|
23
|
-
return Object.entries(validationDataValue).every(([key, value]) => validateType(newValue[key], value));
|
|
24
|
-
}
|
|
25
|
-
// the data types are not arrays or objects, just do a direct comparison
|
|
26
|
-
// this will apply to primitive data types (string, number, boolean)
|
|
27
|
-
return typeof newValue === typeof validationDataValue;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
exports.validateType = validateType;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const validateType: <T>(newValue: any, validationDataValue: T) => newValue is T;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
const validateType = (
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
-
newValue, validationDataValue) => {
|
|
5
|
-
// arrays are also objects, but we need to handle arrays
|
|
6
|
-
// in a different way than objects
|
|
7
|
-
if (Array.isArray(newValue) && Array.isArray(validationDataValue)) {
|
|
8
|
-
if (newValue.length === 0) {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
// eslint-disable-next-line prefer-destructuring
|
|
12
|
-
const itemValidationData = validationDataValue[0];
|
|
13
|
-
// validate all items in newData array matches item validation data
|
|
14
|
-
return Object.entries(newValue).every(([arrIndex, newValueItem]) => validateType(newValueItem, itemValidationData));
|
|
15
|
-
}
|
|
16
|
-
else if (typeof newValue === 'object' &&
|
|
17
|
-
typeof validationDataValue === 'object' &&
|
|
18
|
-
validationDataValue) {
|
|
19
|
-
return Object.entries(validationDataValue).every(([key, value]) => validateType(newValue[key], value));
|
|
20
|
-
}
|
|
21
|
-
// the data types are not arrays or objects, just do a direct comparison
|
|
22
|
-
// this will apply to primitive data types (string, number, boolean)
|
|
23
|
-
return typeof newValue === typeof validationDataValue;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export { validateType };
|