@dynamic-labs/sdk-react-core
Version:
A React SDK for implementing wallet web3 authentication and authorization to your website.
168 lines (163 loc) • 9.31 kB
JavaScript
'use client'
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var jsxRuntime = require('react/jsx-runtime');
var reactI18next = require('react-i18next');
require('react');
require('react-dom');
require('@dynamic-labs/sdk-api-core');
require('../../shared/logger.cjs');
require('@dynamic-labs/iconic');
require('@dynamic-labs/wallet-connector-core');
var profileOutline = require('../../shared/assets/profile-outline.cjs');
var settingsOutline = require('../../shared/assets/settings-outline.cjs');
var walletOutlineV2 = require('../../shared/assets/wallet-outline-v2.cjs');
require('../../context/ViewContext/ViewContext.cjs');
require('@dynamic-labs/wallet-book');
require('@dynamic-labs/utils');
require('../../utils/constants/colors.cjs');
require('../../utils/constants/values.cjs');
require('../../shared/consts/index.cjs');
var classNames = require('../../utils/functions/classNames/classNames.cjs');
require('../../events/dynamicEvents.cjs');
require('../../../../_virtual/_tslib.cjs');
require('../../context/DynamicContext/DynamicContext.cjs');
require('../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
require('../../store/state/authMode/authMode.cjs');
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
require('../../context/CaptchaContext/CaptchaContext.cjs');
require('../../context/ErrorContext/ErrorContext.cjs');
require('@dynamic-labs/multi-wallet');
require('react-international-phone');
require('../../store/state/nonce/nonce.cjs');
require('../../store/state/projectSettings/projectSettings.cjs');
require('../../config/ApiEndpoint.cjs');
require('../../store/state/user/user.cjs');
require('../../locale/locale.cjs');
require('../../store/state/dynamicContextProps/dynamicContextProps.cjs');
require('../../store/state/primaryWalletId/primaryWalletId.cjs');
require('../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
require('../../context/UserWalletsContext/UserWalletsContext.cjs');
require('../../context/VerificationContext/VerificationContext.cjs');
require('../../utils/functions/compareChains/compareChains.cjs');
require('../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
require('../../context/ThemeContext/ThemeContext.cjs');
require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
var useKYCFlag = require('../../utils/hooks/useKYCFlag/useKYCFlag.cjs');
require('bs58');
require('@dynamic-labs/types');
require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
require('../../context/LoadingContext/LoadingContext.cjs');
require('../../context/WalletContext/WalletContext.cjs');
require('../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
require('yup');
require('../../context/MockContext/MockContext.cjs');
require('../../views/CollectUserDataView/useFields.cjs');
require('../../context/FieldsStateContext/FieldsStateContext.cjs');
require('../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
require('@dynamic-labs/rpc-providers');
require('../../store/state/walletOptions/walletOptions.cjs');
require('../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
require('../../components/Alert/Alert.cjs');
require('../../components/ShadowDOM/ShadowDOM.cjs');
require('../../components/IconButton/IconButton.cjs');
require('../../components/InlineWidget/InlineWidget.cjs');
require('../../components/Input/Input.cjs');
require('../../components/IsBrowser/IsBrowser.cjs');
require('../../components/MenuList/Dropdown/Dropdown.cjs');
require('../../components/OverlayCard/OverlayCard.cjs');
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
require('../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
require('../../components/Popper/Popper/Popper.cjs');
require('../../components/Popper/PopperContext/PopperContext.cjs');
require('react-focus-lock');
require('qrcode');
require('formik');
require('../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
require('../../context/WalletGroupContext/WalletGroupContext.cjs');
require('../../context/IpConfigurationContext/IpConfigurationContext.cjs');
require('../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
require('@hcaptcha/react-hcaptcha');
var DynamicWidgetContext = require('../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
require('../../context/FooterAnimationContext/index.cjs');
require('../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
require('../../context/PasskeyContext/PasskeyContext.cjs');
require('../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.cjs');
require('../../store/state/sendBalances.cjs');
require('../../store/state/connectorsInitializing/connectorsInitializing.cjs');
var BottomNavBar = require('../../widgets/DynamicWidget/components/BottomNavBar/BottomNavBar.cjs');
var DynamicWidgetHeader = require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
var DynamicWidgetPrompts = require('../../widgets/DynamicWidget/components/DynamicWidgetPrompts/DynamicWidgetPrompts.cjs');
var DynamicWidgetViews = require('../../widgets/DynamicWidget/components/DynamicWidgetViews/DynamicWidgetViews.cjs');
var DynamicWidgetContext_types = require('../../widgets/DynamicWidget/context/DynamicWidgetContext.types.cjs');
require('../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
require('../../../index.cjs');
require('../../store/state/tokenBalances.cjs');
require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
var OverlayCardTarget = require('../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
const shouldNotRenderHeaderViews = [
...DynamicWidgetContext_types.DynamicPasskeyWidgetViews,
...DynamicWidgetContext_types.DynamicTransactionsWidgetViews,
...DynamicWidgetContext_types.DynamicMfaWidgetViews,
...DynamicWidgetContext_types.DynamicSettingsViews,
...DynamicWidgetContext_types.DynamicGlobalWalletViews,
'receive-wallet-funds',
'choose-wallet-funding-method',
'deposit-view',
'choose-linked-wallet',
'choose-onramp-provider',
];
/**
* Which views should not render the bottom navbar options
*/
const shouldNotRenderBottomNavBarOptions = [
'receive-wallet-funds',
'choose-wallet-funding-method',
'deposit-view',
'choose-onramp-provider',
'choose-linked-wallet',
'manage-mfa-no-footer',
];
const DynamicUserProfileLayout = ({ variant, className, style, }) => {
const { multiWallet } = useInternalDynamicContext.useInternalDynamicContext();
const isKYCEnabled = useKYCFlag.useKYCFlag();
const { dynamicWidgetView, setDynamicWidgetView, overridenWidgetView } = DynamicWidgetContext.useWidgetContext();
const { t } = reactI18next.useTranslation();
const getNavBarOptions = () => {
const options = [];
if (multiWallet) {
options.push({
copykey: 'dyn_nav_bar.wallets',
icon: jsxRuntime.jsx(walletOutlineV2.ReactComponent, {}),
label: t('dyn_nav_bar.wallets'),
value: 'wallets',
});
}
if (isKYCEnabled) {
options.push({
copykey: 'dyn_nav_bar.profile',
icon: jsxRuntime.jsx(profileOutline.ReactComponent, {}),
label: t('dyn_nav_bar.profile'),
value: 'profile',
});
}
options.push({
copykey: 'dyn_nav_bar.settings',
icon: jsxRuntime.jsx(settingsOutline.ReactComponent, {}),
label: t('dyn_nav_bar.settings'),
value: 'settings',
});
return options;
};
// It should render header only if the view is not send-balance or one of passkey widgets view
const shouldRenderHeader = !shouldNotRenderHeaderViews.includes(dynamicWidgetView);
const shouldRenderOptionsSwitcher = (multiWallet || isKYCEnabled) &&
!shouldNotRenderBottomNavBarOptions.includes(dynamicWidgetView);
return (jsxRuntime.jsx(OverlayCardTarget.OverlayCardTarget, { children: jsxRuntime.jsxs("div", { className: classNames.classNames(className, 'dynamic-user-profile-layout'), style: style, children: [shouldRenderHeader && jsxRuntime.jsx(DynamicWidgetHeader.MemoizedDynamicWidgetHeader, { variant: variant }), jsxRuntime.jsx(DynamicWidgetViews.DynamicWidgetViews, {}), jsxRuntime.jsx(DynamicWidgetPrompts.DynamicWidgetPrompts, {}), shouldRenderOptionsSwitcher && (jsxRuntime.jsx(BottomNavBar.BottomNavBar, { value: overridenWidgetView, onChange: (view) => setDynamicWidgetView(view), options: getNavBarOptions() }))] }) }));
};
exports.DynamicUserProfileLayout = DynamicUserProfileLayout;