@getpara/react-sdk 0.1.0
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/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/modal/ParaModal.d.ts +2 -0
- package/dist/modal/ParaModal.js +250 -0
- package/dist/modal/components/Account/Account.d.ts +5 -0
- package/dist/modal/components/Account/Account.js +59 -0
- package/dist/modal/components/AddFunds/AddFunds.d.ts +3 -0
- package/dist/modal/components/AddFunds/AddFunds.js +146 -0
- package/dist/modal/components/AddFunds/AddFundsAwaiting.d.ts +1 -0
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +64 -0
- package/dist/modal/components/AddFunds/AddFundsDone.d.ts +6 -0
- package/dist/modal/components/AddFunds/AddFundsDone.js +26 -0
- package/dist/modal/components/AddFunds/MoonPayEmbed.d.ts +2 -0
- package/dist/modal/components/AddFunds/MoonPayEmbed.js +2 -0
- package/dist/modal/components/AddFunds/index.d.ts +3 -0
- package/dist/modal/components/AddFunds/index.js +3 -0
- package/dist/modal/components/AuthInput/AuthInput.d.ts +6 -0
- package/dist/modal/components/AuthInput/AuthInput.js +214 -0
- package/dist/modal/components/AuthInput/countryCodes.d.ts +8 -0
- package/dist/modal/components/AuthInput/countryCodes.js +40 -0
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +7 -0
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +23 -0
- package/dist/modal/components/AuthInput/phoneMasks.d.ts +247 -0
- package/dist/modal/components/AuthInput/phoneMasks.js +247 -0
- package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +8 -0
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +21 -0
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +8 -0
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +89 -0
- package/dist/modal/components/AuthOptions/AuthOptions.d.ts +8 -0
- package/dist/modal/components/AuthOptions/AuthOptions.js +28 -0
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.d.ts +1 -0
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +7 -0
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.d.ts +1 -0
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +5 -0
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.d.ts +1 -0
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +7 -0
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +1 -0
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +18 -0
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +4 -0
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +17 -0
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -0
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +127 -0
- package/dist/modal/components/Body/AnimatedHeightWrapper.d.ts +6 -0
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +26 -0
- package/dist/modal/components/Body/Body.d.ts +12 -0
- package/dist/modal/components/Body/Body.js +232 -0
- package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -0
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +77 -0
- package/dist/modal/components/ChainSwitch/config.d.ts +7 -0
- package/dist/modal/components/ChainSwitch/config.js +11 -0
- package/dist/modal/components/Controls/Controls.d.ts +5 -0
- package/dist/modal/components/Controls/Controls.js +54 -0
- package/dist/modal/components/Controls/Selects.d.ts +2 -0
- package/dist/modal/components/Controls/Selects.js +157 -0
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -0
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +116 -0
- package/dist/modal/components/ExternalWalletStep/config.d.ts +7 -0
- package/dist/modal/components/ExternalWalletStep/config.js +11 -0
- package/dist/modal/components/ExternalWallets/ExternalWallets.d.ts +1 -0
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +142 -0
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +7 -0
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +118 -0
- package/dist/modal/components/Footer/Footer.d.ts +1 -0
- package/dist/modal/components/Footer/Footer.js +71 -0
- package/dist/modal/components/Header/Header.d.ts +1 -0
- package/dist/modal/components/Header/Header.js +24 -0
- package/dist/modal/components/Header/hooks/useStepTitle.d.ts +3 -0
- package/dist/modal/components/Header/hooks/useStepTitle.js +42 -0
- package/dist/modal/components/Hero/Hero.d.ts +1 -0
- package/dist/modal/components/Hero/Hero.js +118 -0
- package/dist/modal/components/IFrameStep/IFrameStep.d.ts +1 -0
- package/dist/modal/components/IFrameStep/IFrameStep.js +41 -0
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.d.ts +1 -0
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +18 -0
- package/dist/modal/components/ModalContent/ModalContent.d.ts +10 -0
- package/dist/modal/components/ModalContent/ModalContent.js +276 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +2 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +81 -0
- package/dist/modal/components/OAuth/OAuth.d.ts +6 -0
- package/dist/modal/components/OAuth/OAuth.js +124 -0
- package/dist/modal/components/OAuth/TelegramOAuthStep.d.ts +1 -0
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +132 -0
- package/dist/modal/components/OnRampComponents/AddingFunds.d.ts +1 -0
- package/dist/modal/components/OnRampComponents/AddingFunds.js +10 -0
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.d.ts +9 -0
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +72 -0
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.d.ts +6 -0
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +67 -0
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.d.ts +5 -0
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +104 -0
- package/dist/modal/components/StripeComponents/StripeComponents.d.ts +16 -0
- package/dist/modal/components/StripeComponents/StripeComponents.js +78 -0
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.d.ts +5 -0
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +8 -0
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.d.ts +1 -0
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +130 -0
- package/dist/modal/components/Waiting/Waiting.d.ts +6 -0
- package/dist/modal/components/Waiting/Waiting.js +6 -0
- package/dist/modal/components/WalletCard/PartnerIcon.d.ts +6 -0
- package/dist/modal/components/WalletCard/PartnerIcon.js +29 -0
- package/dist/modal/components/WalletCard/WalletCard.d.ts +18 -0
- package/dist/modal/components/WalletCard/WalletCard.js +91 -0
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.d.ts +6 -0
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +49 -0
- package/dist/modal/components/common.d.ts +19 -0
- package/dist/modal/components/common.js +67 -0
- package/dist/modal/components/index.d.ts +1 -0
- package/dist/modal/components/index.js +1 -0
- package/dist/modal/constants/constants.d.ts +32 -0
- package/dist/modal/constants/constants.js +93 -0
- package/dist/modal/constants/defaults.d.ts +5 -0
- package/dist/modal/constants/defaults.js +5 -0
- package/dist/modal/constants/oAuthLogos.d.ts +8 -0
- package/dist/modal/constants/oAuthLogos.js +18 -0
- package/dist/modal/css/modal.css +13 -0
- package/dist/modal/hooks/useActiveWallet.d.ts +1 -0
- package/dist/modal/hooks/useActiveWallet.js +9 -0
- package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +1 -0
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +46 -0
- package/dist/modal/hooks/useGoBack.d.ts +1 -0
- package/dist/modal/hooks/useGoBack.js +34 -0
- package/dist/modal/index.d.ts +10 -0
- package/dist/modal/index.js +9 -0
- package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +29 -0
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +18 -0
- package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +33 -0
- package/dist/modal/providers/EvmExternalWalletContextStub.js +22 -0
- package/dist/modal/providers/ExternalWalletContext.d.ts +75 -0
- package/dist/modal/providers/ExternalWalletContext.js +252 -0
- package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +21 -0
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +12 -0
- package/dist/modal/public/Inter-VariableFont_slnt,wght.ttf +0 -0
- package/dist/modal/stores/externalWalletProvider/actions.d.ts +3 -0
- package/dist/modal/stores/externalWalletProvider/actions.js +5 -0
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +20 -0
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +13 -0
- package/dist/modal/stores/index.d.ts +4 -0
- package/dist/modal/stores/index.js +4 -0
- package/dist/modal/stores/modal/actions.d.ts +3 -0
- package/dist/modal/stores/modal/actions.js +65 -0
- package/dist/modal/stores/modal/useModalStore.d.ts +82 -0
- package/dist/modal/stores/modal/useModalStore.js +41 -0
- package/dist/modal/stores/para/actions.d.ts +3 -0
- package/dist/modal/stores/para/actions.js +5 -0
- package/dist/modal/stores/para/useParaStore.d.ts +10 -0
- package/dist/modal/stores/para/useParaStore.js +3 -0
- package/dist/modal/stores/theme/actions.d.ts +3 -0
- package/dist/modal/stores/theme/actions.js +24 -0
- package/dist/modal/stores/theme/useThemeStore.d.ts +20 -0
- package/dist/modal/stores/theme/useThemeStore.js +14 -0
- package/dist/modal/stores/userInfo/actions.d.ts +3 -0
- package/dist/modal/stores/userInfo/actions.js +28 -0
- package/dist/modal/stores/userInfo/useUserInfoStore.d.ts +19 -0
- package/dist/modal/stores/userInfo/useUserInfoStore.js +9 -0
- package/dist/modal/types/commonTypes.d.ts +48 -0
- package/dist/modal/types/commonTypes.js +1 -0
- package/dist/modal/types/externalWallets.d.ts +31 -0
- package/dist/modal/types/externalWallets.js +21 -0
- package/dist/modal/types/modalProps.d.ts +138 -0
- package/dist/modal/types/modalProps.js +7 -0
- package/dist/modal/utils/authLayoutHelpers.d.ts +3 -0
- package/dist/modal/utils/authLayoutHelpers.js +2 -0
- package/dist/modal/utils/getMailtoLink.d.ts +1 -0
- package/dist/modal/utils/getMailtoLink.js +5 -0
- package/dist/modal/utils/getTileButtonFlex.d.ts +1 -0
- package/dist/modal/utils/getTileButtonFlex.js +15 -0
- package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
- package/dist/modal/utils/isPasskeySupported.js +10 -0
- package/dist/modal/utils/openPopup.d.ts +1 -0
- package/dist/modal/utils/openPopup.js +55 -0
- package/dist/modal/utils/routeMobileExternalWallet.d.ts +1 -0
- package/dist/modal/utils/routeMobileExternalWallet.js +35 -0
- package/dist/modal/utils/steps.d.ts +112 -0
- package/dist/modal/utils/steps.js +215 -0
- package/dist/modal/utils/stringFormatters.d.ts +4 -0
- package/dist/modal/utils/stringFormatters.js +12 -0
- package/dist/modal/utils/validateOnRampConfig.d.ts +5 -0
- package/dist/modal/utils/validateOnRampConfig.js +26 -0
- package/package.json +51 -0
- package/styles.css/package.json +3 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { motion } from 'framer-motion';
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
export const AnimatedHeightWrapper = ({ children, className }) => {
|
|
6
|
+
const containerRef = useRef(null);
|
|
7
|
+
const [height, setHeight] = useState('auto');
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (containerRef.current) {
|
|
10
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
11
|
+
// We only have one entry, so we can use entries[0].
|
|
12
|
+
const observedHeight = entries[0].contentRect.height;
|
|
13
|
+
setHeight(observedHeight);
|
|
14
|
+
});
|
|
15
|
+
resizeObserver.observe(containerRef.current);
|
|
16
|
+
return () => {
|
|
17
|
+
// Cleanup the observer when the component is unmounted
|
|
18
|
+
resizeObserver.disconnect();
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}, []);
|
|
22
|
+
return (_jsx(Container, { className: className, style: { height }, animate: { height }, transition: { duration: 0.2 }, children: _jsx("div", { ref: containerRef, children: children }) }));
|
|
23
|
+
};
|
|
24
|
+
const Container = styled(motion.div) `
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
`;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OAuthMethod } from '@getpara/web-sdk';
|
|
2
|
+
interface BodyProps {
|
|
3
|
+
oAuthMethods?: OAuthMethod[];
|
|
4
|
+
twoFactorAuthEnabled?: boolean;
|
|
5
|
+
disableEmailLogin: boolean;
|
|
6
|
+
disablePhoneLogin: boolean;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
createAccountWithPasskey: () => Promise<void>;
|
|
9
|
+
createAccountWithPassword: () => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare const Body: ({ oAuthMethods, twoFactorAuthEnabled, disableEmailLogin, disablePhoneLogin, onClose, createAccountWithPasskey, createAccountWithPassword, }: BodyProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { styled } from 'styled-components';
|
|
3
|
+
import { IFrameSteps, ModalStep } from '../../utils/steps.js';
|
|
4
|
+
import { CpslAlert, CpslIcon } from '@getpara/react-components';
|
|
5
|
+
import { VerificationCodeStep } from '../VerificationCodeStep/VerificationCodeStep.js';
|
|
6
|
+
import { useModalStore, useThemeStore } from '../../stores/index.js';
|
|
7
|
+
import { BiometricLoginStep } from '../BiometricLoginStep/BiometricLoginStep.js';
|
|
8
|
+
import { Setup2FAStep } from '../Setup2FAStep/Setup2FAStep.js';
|
|
9
|
+
import { LoginDoneStep } from '../LoginDoneStep/LoginDoneStep.js';
|
|
10
|
+
import { EnabledFlow } from '@getpara/web-sdk';
|
|
11
|
+
import { AwaitingBiometricsStep } from '../AwaitingBiometricsStep/AwaitingBiometricsStep.js';
|
|
12
|
+
import { AwaitingWalletCreationStep } from '../AwaitingWalletCreationStep/AwaitingWalletCreationStep.js';
|
|
13
|
+
import { WalletCreationDoneStep } from '../WalletCreationDoneStep/WalletCreationDoneStep.js';
|
|
14
|
+
import { RecoverySecretStep } from '../RecoverySecretStep/RecoverySecretStep.js';
|
|
15
|
+
import { TwoFactorDoneStep } from '../TwoFactorDoneStep/TwoFactorDoneStep.js';
|
|
16
|
+
import { BiometricCreationStep } from '../BiometricCreationStep/BiometricCreationStep.js';
|
|
17
|
+
import { AwaitingOAuthStep } from '../AwaitingOAuthStep/AwaitingOAuthStep.js';
|
|
18
|
+
import { AddFundsAwaiting, AddFundsDone, AddFunds } from '../AddFunds/index.js';
|
|
19
|
+
import FarcasterOAuthStep from '../OAuth/FarcasterOAuthStep.js';
|
|
20
|
+
import { Header } from '../Header/Header.js';
|
|
21
|
+
import { AuthMainStep } from '../AuthMainStep/AuthMainStep.js';
|
|
22
|
+
import { BODY_MOTION_VARIANTS, BODY_TRANSITION, MOBILE_SIZE } from '../../constants/constants.js';
|
|
23
|
+
import { Account } from '../Account/Account.js';
|
|
24
|
+
import { AuthOptions } from '../AuthOptions/AuthOptions.js';
|
|
25
|
+
import { ExternalWallets } from '../ExternalWallets/ExternalWallets.js';
|
|
26
|
+
import { ExternalWalletStep } from '../ExternalWalletStep/ExternalWalletStep.js';
|
|
27
|
+
import { Hero } from '../Hero/Hero.js';
|
|
28
|
+
import { AnimatedHeightWrapper } from './AnimatedHeightWrapper.js';
|
|
29
|
+
import { ChainSwitch } from '../ChainSwitch/ChainSwitch.js';
|
|
30
|
+
import { motion, AnimatePresence } from 'framer-motion';
|
|
31
|
+
import { Controls } from '../Controls/Controls.js';
|
|
32
|
+
import { useEffect, useState } from 'react';
|
|
33
|
+
import { TelegramOAuthStep } from '../OAuth/TelegramOAuthStep.js';
|
|
34
|
+
import { AwaitingPasswordStep } from '../AwaitingPasswordStep/AwaitingPasswordStep.js';
|
|
35
|
+
import { IFrameStep } from '../IFrameStep/IFrameStep.js';
|
|
36
|
+
const MIN_HEIGHT = {
|
|
37
|
+
[ModalStep.ADD_FUNDS_AWAITING]: '680px',
|
|
38
|
+
};
|
|
39
|
+
const PADDING_TOP = {
|
|
40
|
+
[ModalStep.TELEGRAM_OAUTH]: '36px',
|
|
41
|
+
};
|
|
42
|
+
const PADDING_BOTTOM = {
|
|
43
|
+
[ModalStep.TELEGRAM_OAUTH]: '16px',
|
|
44
|
+
};
|
|
45
|
+
export const Body = ({ oAuthMethods, twoFactorAuthEnabled, disableEmailLogin, disablePhoneLogin, onClose, createAccountWithPasskey, createAccountWithPassword, }) => {
|
|
46
|
+
const currentStep = useModalStore(state => state.step);
|
|
47
|
+
const onRampConfig = useModalStore(state => state.onRampConfig);
|
|
48
|
+
const stepDirection = useModalStore(state => state.stepDirection);
|
|
49
|
+
const setStepDirection = useModalStore(state => state.setStepDirection);
|
|
50
|
+
const accountAddFundTab = useModalStore(state => state.accountAddFundTab);
|
|
51
|
+
const setAccountAddFundTab = useModalStore(state => state.setAccountAddFundTab);
|
|
52
|
+
const appName = useThemeStore(state => state.appName);
|
|
53
|
+
const embeddedModal = useThemeStore(state => state.embeddedModal);
|
|
54
|
+
const [isTestModeAlert, setIsTestModeAlert] = useState(onRampConfig === null || onRampConfig === void 0 ? void 0 : onRampConfig.testMode);
|
|
55
|
+
const Content = () => {
|
|
56
|
+
switch (currentStep) {
|
|
57
|
+
case ModalStep.AUTH_MAIN: {
|
|
58
|
+
return (_jsx(AuthMainStep, { oAuthMethods: oAuthMethods, disableEmailLogin: disableEmailLogin, disablePhoneLogin: disablePhoneLogin }));
|
|
59
|
+
}
|
|
60
|
+
case ModalStep.EX_WALLET_MORE: {
|
|
61
|
+
return _jsx(ExternalWallets, {});
|
|
62
|
+
}
|
|
63
|
+
case ModalStep.AUTH_MORE: {
|
|
64
|
+
return (_jsx(AuthOptions, { oAuthMethods: oAuthMethods, disableEmailLogin: disableEmailLogin, disablePhoneLogin: disablePhoneLogin }));
|
|
65
|
+
}
|
|
66
|
+
case ModalStep.VERIFICATIONS: {
|
|
67
|
+
return _jsx(VerificationCodeStep, {});
|
|
68
|
+
}
|
|
69
|
+
case ModalStep.BIOMETRIC_LOGIN: {
|
|
70
|
+
return _jsx(BiometricLoginStep, {});
|
|
71
|
+
}
|
|
72
|
+
case ModalStep.SETUP_2FA:
|
|
73
|
+
case ModalStep.VERIFY_2FA: {
|
|
74
|
+
return _jsx(Setup2FAStep, { onClose: onClose });
|
|
75
|
+
}
|
|
76
|
+
case ModalStep.LOGIN_DONE: {
|
|
77
|
+
return _jsx(LoginDoneStep, { onClose: onClose });
|
|
78
|
+
}
|
|
79
|
+
case ModalStep.AWAITING_BIOMETRIC_LOGIN:
|
|
80
|
+
case ModalStep.AWAITING_BIOMETRIC_CREATION: {
|
|
81
|
+
return _jsx(AwaitingBiometricsStep, {});
|
|
82
|
+
}
|
|
83
|
+
case ModalStep.AWAITING_PASSWORD_LOGIN:
|
|
84
|
+
case ModalStep.AWAITING_PASSWORD_CREATION: {
|
|
85
|
+
return _jsx(AwaitingPasswordStep, {});
|
|
86
|
+
}
|
|
87
|
+
case ModalStep.AWAITING_WALLET_CREATION: {
|
|
88
|
+
return _jsx(AwaitingWalletCreationStep, {});
|
|
89
|
+
}
|
|
90
|
+
case ModalStep.WALLET_CREATION_DONE: {
|
|
91
|
+
return _jsx(WalletCreationDoneStep, { twoFactorAuthEnabled: twoFactorAuthEnabled, onClose: onClose });
|
|
92
|
+
}
|
|
93
|
+
case ModalStep.SECRET: {
|
|
94
|
+
return _jsx(RecoverySecretStep, {});
|
|
95
|
+
}
|
|
96
|
+
case ModalStep.TWO_FACTOR_DONE: {
|
|
97
|
+
return _jsx(TwoFactorDoneStep, { onClose: onClose });
|
|
98
|
+
}
|
|
99
|
+
case ModalStep.BIOMETRIC_CREATION: {
|
|
100
|
+
return (_jsx(BiometricCreationStep, { handlePasswordClick: createAccountWithPassword, handlePasskeyClick: createAccountWithPasskey }));
|
|
101
|
+
}
|
|
102
|
+
case ModalStep.AWAITING_OAUTH: {
|
|
103
|
+
return _jsx(AwaitingOAuthStep, {});
|
|
104
|
+
}
|
|
105
|
+
case ModalStep.FARCASTER_OAUTH: {
|
|
106
|
+
return _jsx(FarcasterOAuthStep, {});
|
|
107
|
+
}
|
|
108
|
+
case ModalStep.TELEGRAM_OAUTH: {
|
|
109
|
+
return _jsx(TelegramOAuthStep, {});
|
|
110
|
+
}
|
|
111
|
+
case ModalStep.ADD_FUNDS_BUY:
|
|
112
|
+
case ModalStep.ADD_FUNDS_RECEIVE:
|
|
113
|
+
case ModalStep.ADD_FUNDS_WITHDRAW: {
|
|
114
|
+
return _jsx(AddFunds, {});
|
|
115
|
+
}
|
|
116
|
+
case ModalStep.ADD_FUNDS_AWAITING: {
|
|
117
|
+
return _jsx(AddFundsAwaiting, {});
|
|
118
|
+
}
|
|
119
|
+
case ModalStep.ADD_FUNDS_SUCCESS: {
|
|
120
|
+
return _jsx(AddFundsDone, { isSuccess: true, onClose: onClose });
|
|
121
|
+
}
|
|
122
|
+
case ModalStep.ADD_FUNDS_FAILURE: {
|
|
123
|
+
return _jsx(AddFundsDone, { onClose: onClose });
|
|
124
|
+
}
|
|
125
|
+
case ModalStep.ACCOUNT_MAIN: {
|
|
126
|
+
return _jsx(Account, { onClose: onClose });
|
|
127
|
+
}
|
|
128
|
+
case ModalStep.EX_WALLET_SELECTED: {
|
|
129
|
+
return _jsx(ExternalWalletStep, {});
|
|
130
|
+
}
|
|
131
|
+
case ModalStep.CHAIN_SWITCH: {
|
|
132
|
+
return _jsx(ChainSwitch, {});
|
|
133
|
+
}
|
|
134
|
+
default: {
|
|
135
|
+
if (IFrameSteps.includes(currentStep)) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (!isTestModeAlert && (onRampConfig === null || onRampConfig === void 0 ? void 0 : onRampConfig.testMode)) {
|
|
143
|
+
setIsTestModeAlert(true);
|
|
144
|
+
}
|
|
145
|
+
}, [onRampConfig === null || onRampConfig === void 0 ? void 0 : onRampConfig.testMode]);
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
switch (currentStep) {
|
|
148
|
+
case ModalStep.ADD_FUNDS_BUY:
|
|
149
|
+
setAccountAddFundTab(EnabledFlow.BUY);
|
|
150
|
+
break;
|
|
151
|
+
case ModalStep.ADD_FUNDS_RECEIVE:
|
|
152
|
+
setAccountAddFundTab(EnabledFlow.RECEIVE);
|
|
153
|
+
break;
|
|
154
|
+
case ModalStep.ADD_FUNDS_WITHDRAW:
|
|
155
|
+
setAccountAddFundTab(EnabledFlow.WITHDRAW);
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
}, [currentStep]);
|
|
161
|
+
return (_jsxs(Container, { slot: "body", "data-testid": "modal-content", children: [!embeddedModal && (_jsxs(_Fragment, { children: [_jsx(Controls, { onClose: onClose }), _jsx(Header, {})] })), _jsxs(AnimatedWrapper, { children: [_jsx(AnimatePresence, { mode: "popLayout", initial: false, onExitComplete: () => {
|
|
162
|
+
setStepDirection(1);
|
|
163
|
+
}, custom: stepDirection, children: _jsxs(BodyContainer, { custom: stepDirection, variants: BODY_MOTION_VARIANTS, initial: "enter", animate: "center", exit: "exit", transition: BODY_TRANSITION, children: [_jsx(Hero, {}), _jsxs(InnerContainer, { "$embeddedModal": embeddedModal, "$step": currentStep, "$isIFrameStep": IFrameSteps.includes(currentStep), children: [Content(), (onRampConfig === null || onRampConfig === void 0 ? void 0 : onRampConfig.testMode) &&
|
|
164
|
+
[
|
|
165
|
+
ModalStep.ADD_FUNDS_BUY,
|
|
166
|
+
ModalStep.ADD_FUNDS_WITHDRAW,
|
|
167
|
+
ModalStep.ADD_FUNDS_AWAITING,
|
|
168
|
+
ModalStep.ADD_FUNDS_FAILURE,
|
|
169
|
+
ModalStep.ADD_FUNDS_SUCCESS,
|
|
170
|
+
].includes(currentStep) &&
|
|
171
|
+
isTestModeAlert &&
|
|
172
|
+
accountAddFundTab !== EnabledFlow.RECEIVE && (_jsx(TestModeAlert, { children: _jsxs("div", { style: { fontSize: '14px' }, children: ["This Para Modal is configured to run on-ramp services in ", _jsx("b", { children: "test mode" }), " only, for development purposes. If you are a user of ", appName, ", please contact support.", _jsx(CloseButton, { onClick: () => setIsTestModeAlert(false), children: _jsx(CloseX, { icon: "x" }) })] }) }))] })] }, ['ADD_FUNDS_BUY', 'ADD_FUNDS_RECEIVE', 'ADD_FUNDS_WITHDRAW'].includes(currentStep) ? 'ADD_FUNDS' : currentStep) }), _jsx(IFrameStep, {})] })] }));
|
|
173
|
+
};
|
|
174
|
+
const Container = styled.div `
|
|
175
|
+
position: relative;
|
|
176
|
+
`;
|
|
177
|
+
const AnimatedWrapper = styled(AnimatedHeightWrapper) `
|
|
178
|
+
margin-top: -16px;
|
|
179
|
+
`;
|
|
180
|
+
const BodyContainer = styled(motion.div) `
|
|
181
|
+
position: relative;
|
|
182
|
+
display: flex;
|
|
183
|
+
flex-direction: column;
|
|
184
|
+
gap: 24px;
|
|
185
|
+
will-change: auto !important;
|
|
186
|
+
`;
|
|
187
|
+
const InnerContainer = styled.div `
|
|
188
|
+
z-index: 1;
|
|
189
|
+
flex: 1;
|
|
190
|
+
display: flex;
|
|
191
|
+
flex-direction: column;
|
|
192
|
+
justify-content: flex-start;
|
|
193
|
+
gap: 24px;
|
|
194
|
+
padding: ${({ $embeddedModal, $step, $isIFrameStep }) => {
|
|
195
|
+
var _a, _b;
|
|
196
|
+
return $isIFrameStep
|
|
197
|
+
? '0px'
|
|
198
|
+
: $embeddedModal
|
|
199
|
+
? '12px 0px 0px'
|
|
200
|
+
: `${(_a = PADDING_TOP[$step]) !== null && _a !== void 0 ? _a : '72px'} 72px ${(_b = PADDING_BOTTOM[$step]) !== null && _b !== void 0 ? _b : '32px'}`;
|
|
201
|
+
}};
|
|
202
|
+
min-height: ${({ $step }) => { var _a; return (_a = MIN_HEIGHT[$step]) !== null && _a !== void 0 ? _a : 'auto'; }};
|
|
203
|
+
height: ${({ $step }) => { var _a; return (_a = MIN_HEIGHT[$step]) !== null && _a !== void 0 ? _a : 'auto'; }};
|
|
204
|
+
|
|
205
|
+
@media (max-width: ${MOBILE_SIZE}px) {
|
|
206
|
+
padding: ${({ $embeddedModal, $step, $isIFrameStep }) => { var _a; return $isIFrameStep ? '0px' : $embeddedModal ? '12px 0px 0px' : `${(_a = PADDING_TOP[$step]) !== null && _a !== void 0 ? _a : '72px'} 16px 0px`; }};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
cpsl-auth-modal.force-mobile-media & {
|
|
210
|
+
padding: 72px 16px 0px;
|
|
211
|
+
}
|
|
212
|
+
`;
|
|
213
|
+
const TestModeAlert = styled(CpslAlert) `
|
|
214
|
+
--container-padding-end: 40px;
|
|
215
|
+
position: absolute;
|
|
216
|
+
bottom: 16px;
|
|
217
|
+
left: 16px;
|
|
218
|
+
right: 16px;
|
|
219
|
+
z-index: 1000;
|
|
220
|
+
`;
|
|
221
|
+
const CloseButton = styled.button `
|
|
222
|
+
background-color: transparent;
|
|
223
|
+
border: none;
|
|
224
|
+
padding: 4px;
|
|
225
|
+
cursor: pointer;
|
|
226
|
+
position: absolute;
|
|
227
|
+
top: 0;
|
|
228
|
+
right: 0;
|
|
229
|
+
`;
|
|
230
|
+
const CloseX = styled(CpslIcon) `
|
|
231
|
+
--icon-color: var(--cpsl-color-foreground-0);
|
|
232
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ChainSwitch: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from '@getpara/react-components';
|
|
12
|
+
import { CenteredText, InnerStepContainer, QRContainer, StepContainer } from '../common.js';
|
|
13
|
+
import { useEffect, useMemo } from 'react';
|
|
14
|
+
import { useModalStore } from '../../stores/index.js';
|
|
15
|
+
import styled from 'styled-components';
|
|
16
|
+
import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
|
|
17
|
+
import { useCopyToClipboard } from '@getpara/react-common';
|
|
18
|
+
import { ModalStep } from '../../utils/steps.js';
|
|
19
|
+
import { routeMobileExternalWallet } from '../../utils/routeMobileExternalWallet.js';
|
|
20
|
+
import { NETWORK_NOT_SUPPORTED_ERROR } from '../../constants/constants.js';
|
|
21
|
+
import { WalletType } from '@getpara/web-sdk';
|
|
22
|
+
export const ChainSwitch = () => {
|
|
23
|
+
const [isCopied, copy] = useCopyToClipboard();
|
|
24
|
+
const externalWalletError = useModalStore(state => state.externalWalletError);
|
|
25
|
+
const setStep = useModalStore(state => state.setStep);
|
|
26
|
+
const setStepDirection = useModalStore(state => state.setStepDirection);
|
|
27
|
+
const { switchChain, wallet, qrUri, chainIdSwitchingTo, walletDisplayHelpers } = useExternalWallets();
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if ((wallet === null || wallet === void 0 ? void 0 : wallet.type) === WalletType.COSMOS) {
|
|
30
|
+
routeMobileExternalWallet(qrUri);
|
|
31
|
+
}
|
|
32
|
+
}, [qrUri, wallet]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!wallet) {
|
|
35
|
+
setStepDirection(-1);
|
|
36
|
+
setStep(ModalStep.ACCOUNT_MAIN);
|
|
37
|
+
}
|
|
38
|
+
}, [wallet]);
|
|
39
|
+
const handleTryAgainClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
if (chainIdSwitchingTo) {
|
|
41
|
+
yield switchChain(chainIdSwitchingTo);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const handleCopy = () => {
|
|
45
|
+
copy(qrUri);
|
|
46
|
+
};
|
|
47
|
+
const Content = useMemo(() => {
|
|
48
|
+
var _a;
|
|
49
|
+
if (!wallet) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const { isCosmosMobileWallet } = walletDisplayHelpers;
|
|
53
|
+
if (isCosmosMobileWallet) {
|
|
54
|
+
return (_jsx(_Fragment, { children: _jsxs(InnerStepContainer, { children: [_jsx(CpslText, { weight: "semiBold", children: "Scan with your mobile device to switch networks" }), _jsx(QRContainer, { children: !qrUri ? _jsx(CpslSpinner, { size: 100 }) : _jsx(CpslQrCode, { url: qrUri, imageSrc: wallet.iconUrl }) }), _jsxs(CpslButton, { size: "small", variant: "ghost", onClick: handleCopy, children: [_jsx(CpslIcon, { slot: "start", icon: isCopied ? 'check' : 'copy' }), isCopied ? 'Copied' : 'Copy Link'] })] }) }));
|
|
55
|
+
}
|
|
56
|
+
return (_jsxs(InnerStepContainer, { children: [!(externalWalletError === null || externalWalletError === void 0 ? void 0 : externalWalletError.length) ? (_jsx(CenteredText, { color: "contrast", weight: "semiBold", children: `Confirm the request to change networks in your ${wallet.name} wallet.` })) : (_jsxs(_Fragment, { children: [_jsxs(ErrorContainer, { children: [_jsx(ErrorIcon, { icon: "alertCircle" }), _jsx(CenteredText, { weight: "semiBold", color: "error", children: externalWalletError[0] })] }), externalWalletError[1] && (_jsx(CenteredText, { color: "secondary", weight: "medium", children: externalWalletError[1] }))] })), ((_a = externalWalletError === null || externalWalletError === void 0 ? void 0 : externalWalletError[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== NETWORK_NOT_SUPPORTED_ERROR && (_jsxs(CpslButton, { variant: "secondary", onClick: handleTryAgainClick, children: [_jsx(CpslIcon, { slot: "start", icon: "refresh" }), "Try Again"] }))] }));
|
|
57
|
+
}, [wallet, walletDisplayHelpers, externalWalletError, qrUri]);
|
|
58
|
+
if (!wallet) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return _jsx(Container, { children: Content });
|
|
62
|
+
};
|
|
63
|
+
const Container = styled(StepContainer) `
|
|
64
|
+
flex: 1;
|
|
65
|
+
justify-content: space-between;
|
|
66
|
+
`;
|
|
67
|
+
const ErrorContainer = styled.div `
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
gap: 4px;
|
|
72
|
+
`;
|
|
73
|
+
const ErrorIcon = styled(CpslIcon) `
|
|
74
|
+
--height: 16px;
|
|
75
|
+
--width: 16px;
|
|
76
|
+
--icon-color: var(--cpsl-color-text-error);
|
|
77
|
+
`;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var TabValue;
|
|
2
|
+
(function (TabValue) {
|
|
3
|
+
TabValue["extension"] = "extension";
|
|
4
|
+
TabValue["mobile"] = "mobile";
|
|
5
|
+
TabValue["web"] = "web";
|
|
6
|
+
})(TabValue || (TabValue = {}));
|
|
7
|
+
export const TABS = {
|
|
8
|
+
extension: { label: 'Extension', value: TabValue.extension, icon: 'puzzlePiece' },
|
|
9
|
+
mobile: { label: 'Mobile', value: TabValue.mobile, icon: 'phone' },
|
|
10
|
+
web: { label: 'Web', value: TabValue.web, icon: 'globe' },
|
|
11
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CpslIcon } from '@getpara/react-components';
|
|
3
|
+
import { styled } from 'styled-components';
|
|
4
|
+
import { useModalStore } from '../../stores/index.js';
|
|
5
|
+
import { useThemeStore } from '../../stores/theme/useThemeStore.js';
|
|
6
|
+
import { useGoBack } from '../../hooks/useGoBack.js';
|
|
7
|
+
import { AccountSelect, ChainSelect } from './Selects.js';
|
|
8
|
+
import { ModalStep } from '../../utils/steps.js';
|
|
9
|
+
import { HeaderButton } from '@getpara/react-common';
|
|
10
|
+
export const Controls = ({ onClose }) => {
|
|
11
|
+
const bareModal = useThemeStore(state => state.bareModal);
|
|
12
|
+
const hasPreviousStep = useModalStore(state => state.hasPreviousStep());
|
|
13
|
+
const step = useModalStore(state => state.step);
|
|
14
|
+
const isFullyLoggedIn = useModalStore(state => state.isFullyLoggedIn);
|
|
15
|
+
const goBack = useGoBack();
|
|
16
|
+
const shouldShowSelects = [
|
|
17
|
+
ModalStep.ACCOUNT_MAIN,
|
|
18
|
+
ModalStep.CHAIN_SWITCH,
|
|
19
|
+
ModalStep.ADD_FUNDS_BUY,
|
|
20
|
+
ModalStep.ADD_FUNDS_RECEIVE,
|
|
21
|
+
ModalStep.ADD_FUNDS_WITHDRAW,
|
|
22
|
+
].includes(step);
|
|
23
|
+
const handleBackClick = () => {
|
|
24
|
+
goBack();
|
|
25
|
+
};
|
|
26
|
+
return (_jsxs(Container, { children: [_jsx(BackButton, { variant: "ghost", style: {
|
|
27
|
+
visibility: hasPreviousStep ? 'visible' : 'hidden',
|
|
28
|
+
}, onClick: handleBackClick, children: _jsx(CpslIcon, { icon: "arrow" }) }), _jsx(MiddleContainer, { children: shouldShowSelects && isFullyLoggedIn && (_jsxs(_Fragment, { children: [_jsx(ChainSelect, {}), _jsx(AccountSelect, {})] })) }), _jsx(CloseButton, { bareModal: bareModal, variant: "ghost", onClick: onClose, children: _jsx(CpslIcon, { icon: "close" }) })] }));
|
|
29
|
+
};
|
|
30
|
+
const Container = styled.div `
|
|
31
|
+
position: absolute;
|
|
32
|
+
width: 100%;
|
|
33
|
+
top: 16px;
|
|
34
|
+
|
|
35
|
+
z-index: 3;
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
gap: 8px;
|
|
40
|
+
`;
|
|
41
|
+
const MiddleContainer = styled.div `
|
|
42
|
+
flex: 1;
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
gap: 4px;
|
|
47
|
+
`;
|
|
48
|
+
const CloseButton = styled(HeaderButton) `
|
|
49
|
+
transform: rotate(180deg);
|
|
50
|
+
visibility: ${({ bareModal }) => (bareModal ? 'hidden' : 'visible')};
|
|
51
|
+
`;
|
|
52
|
+
const BackButton = styled(HeaderButton) `
|
|
53
|
+
transform: rotate(180deg);
|
|
54
|
+
`;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { CpslIdenticon, CpslSelect, CpslSelectItem, CpslText } from '@getpara/react-components';
|
|
12
|
+
import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
|
|
13
|
+
import styled from 'styled-components';
|
|
14
|
+
import { useParaStore, useModalStore, useThemeStore } from '../../stores/index.js';
|
|
15
|
+
import { truncateAddress, WalletType } from '@getpara/web-sdk';
|
|
16
|
+
import { useEffect, useRef } from 'react';
|
|
17
|
+
import { useDropdownPosition } from '../AuthInput/hooks/useDropdownPosition.js';
|
|
18
|
+
import { MOBILE_SIZE } from '../../constants/constants.js';
|
|
19
|
+
import { useActiveWallet } from '../../hooks/useActiveWallet.js';
|
|
20
|
+
const getValue = (id, type) => {
|
|
21
|
+
return id && type ? `${id}~${type}` : undefined;
|
|
22
|
+
};
|
|
23
|
+
const WALLET_TYPES = {
|
|
24
|
+
[WalletType.EVM]: 'EVM',
|
|
25
|
+
[WalletType.SOLANA]: 'Solana',
|
|
26
|
+
[WalletType.COSMOS]: 'Cosmos',
|
|
27
|
+
};
|
|
28
|
+
export const ChainSelect = () => {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
const containerRef = useRef(null);
|
|
31
|
+
const { dropdownMaxHeight, dropdownWidth, mobileAnchor, resize } = useDropdownPosition(containerRef);
|
|
32
|
+
const activeWallet = useActiveWallet();
|
|
33
|
+
const { switchChain, chainId, chains, chainIdSwitchingTo } = useExternalWallets();
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (dropdownMaxHeight && chainId) {
|
|
36
|
+
resize();
|
|
37
|
+
}
|
|
38
|
+
}, [chainId, chainIdSwitchingTo, dropdownMaxHeight]);
|
|
39
|
+
const handleChainChange = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
yield switchChain(chainId);
|
|
41
|
+
});
|
|
42
|
+
if (!activeWallet || !activeWallet.isExternal || activeWallet.type === WalletType.SOLANA) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const chainIdToUse = chainIdSwitchingTo !== null && chainIdSwitchingTo !== void 0 ? chainIdSwitchingTo : chainId;
|
|
46
|
+
const selectedChainName = (_a = chains.find(c => c.id.toString() === chainIdToUse)) === null || _a === void 0 ? void 0 : _a.name;
|
|
47
|
+
return (_jsx(Container, { children: _jsx(SelectContainer, { ref: containerRef, id: "inputContainer", children: _jsxs(StyledSelect, { selectedValue: (_b = chainIdToUse === null || chainIdToUse === void 0 ? void 0 : chainIdToUse.toString()) !== null && _b !== void 0 ? _b : '', onCpslSelectValueChange: e => {
|
|
48
|
+
handleChainChange(e.detail);
|
|
49
|
+
}, showFormattedSelectedItem: true, placeholder: "Choose chain...", anchorElId: "inputContainer", dropdownMaxHeight: dropdownMaxHeight, "$width": dropdownWidth, "$top": mobileAnchor + 16 + 1, autoWidth: true, selectedItemVariant: "bodyXS", children: [chainIdToUse && (_jsx(ChainName, { variant: "bodyXS", color: "contrast", slot: "selected-item", children: selectedChainName })), chains === null || chains === void 0 ? void 0 : chains.map(chain => (_jsx(StyledSelectItem, { slot: "items", value: chain.id.toString(), children: _jsx(ChainName, { variant: "bodyXS", color: "contrast", children: chain.name }) }, chain.id)))] }) }) }));
|
|
50
|
+
};
|
|
51
|
+
function getName(para, { type, isExternal, name, isMenu = false, hideWallets = false, }) {
|
|
52
|
+
if (para.isMultiWallet) {
|
|
53
|
+
return (name !== null && name !== void 0 ? name : `${isExternal ? 'External ' : ''}${WALLET_TYPES[type]}${!hideWallets && (isMenu || isExternal) ? ' Wallet' : ''}`);
|
|
54
|
+
}
|
|
55
|
+
return hideWallets ? 'My Account' : name || 'My Wallet';
|
|
56
|
+
}
|
|
57
|
+
export const AccountSelect = () => {
|
|
58
|
+
const hideWallets = useThemeStore(state => state.hideWallets);
|
|
59
|
+
const para = useParaStore(state => state.para);
|
|
60
|
+
const containerRef = useRef(null);
|
|
61
|
+
const { dropdownMaxHeight, dropdownWidth, mobileAnchor, resize } = useDropdownPosition(containerRef);
|
|
62
|
+
const setActiveWallet = useModalStore(state => state.setActiveWallet);
|
|
63
|
+
const activeWallet = useActiveWallet();
|
|
64
|
+
const ActiveWalletNode = activeWallet ? (_jsxs(FlexRow, { slot: "selected-item", children: [_jsx(CpslIdenticon, { variant: "avatar", size: "14px", hash: para.getIdenticonHash(activeWallet.id, activeWallet.type) }), _jsx(WalletName, { variant: "bodyXS", color: "contrast", children: getName(para, Object.assign(Object.assign({}, activeWallet), { hideWallets })) }), !hideWallets && (_jsx(CpslText, { variant: "bodyXS", color: "secondary", children: para.getDisplayAddress(activeWallet.id, { truncate: true, addressType: activeWallet.type }) }))] })) : null;
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (dropdownMaxHeight && (activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.address)) {
|
|
67
|
+
resize();
|
|
68
|
+
}
|
|
69
|
+
}, [activeWallet, para.availableWallets, dropdownMaxHeight]);
|
|
70
|
+
return (_jsx(Container, { children: _jsx(SelectContainer, { ref: containerRef, id: "addressInputContainer", children: para.availableWallets.length > 1 ? (_jsxs(StyledSelect, { selectedValue: getValue(activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.id, activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.type), onCpslSelectValueChange: e => {
|
|
71
|
+
const [id, type] = e.detail.split('~');
|
|
72
|
+
setActiveWallet([id, type]);
|
|
73
|
+
}, showFormattedSelectedItem: true, placeholder: "Choose wallet...", anchorElId: "addressInputContainer", dropdownMaxHeight: dropdownMaxHeight, "$width": dropdownWidth, "$top": mobileAnchor + 16 + 1, autoWidth: true, selectedItemVariant: "bodyXS", children: [activeWallet && ActiveWalletNode, para.availableWallets.map(({ address, name: _name, id, type, isExternal }) => {
|
|
74
|
+
const key = getValue(id, type);
|
|
75
|
+
const name = _name !== null && _name !== void 0 ? _name : getName(para, { type, isExternal, isMenu: true, hideWallets });
|
|
76
|
+
return (_jsx(StyledSelectItem, { slot: "items", value: key, children: _jsxs(FlexRow, { children: [_jsx(CpslIdenticon, { size: "40px", hash: para.getIdenticonHash(id, type) }), _jsxs(FlexCol, { children: [name && (_jsx(CpslText, { variant: "bodyS", color: "contrast", children: name })), !hideWallets && (_jsx(CpslText, { variant: "bodyXS", color: "secondary", children: truncateAddress(address, type, { prefix: para.cosmosPrefix }) }))] })] }) }, key));
|
|
77
|
+
})] })) : (ActiveWalletNode) }) }));
|
|
78
|
+
};
|
|
79
|
+
const Container = styled.div `
|
|
80
|
+
flex: 0;
|
|
81
|
+
width: 100%;
|
|
82
|
+
display: flex;
|
|
83
|
+
justify-content: center;
|
|
84
|
+
`;
|
|
85
|
+
const FlexRow = styled.div `
|
|
86
|
+
display: flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
gap: 8px;
|
|
89
|
+
`;
|
|
90
|
+
const FlexCol = styled.div `
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
align-items: flex-start;
|
|
94
|
+
`;
|
|
95
|
+
const WalletName = styled(CpslText) `
|
|
96
|
+
white-space: nowrap;
|
|
97
|
+
`;
|
|
98
|
+
const SelectContainer = styled.div `
|
|
99
|
+
position: relative;
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
gap: 8px;
|
|
103
|
+
border-radius: 1000px;
|
|
104
|
+
background-color: var(--cpsl-color-background-8);
|
|
105
|
+
padding: 8px;
|
|
106
|
+
`;
|
|
107
|
+
const ChainName = styled(CpslText) `
|
|
108
|
+
max-width: 150px;
|
|
109
|
+
text-transform: capitalize;
|
|
110
|
+
|
|
111
|
+
&::part(text-element) {
|
|
112
|
+
white-space: nowrap;
|
|
113
|
+
text-overflow: ellipsis;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
}
|
|
116
|
+
`;
|
|
117
|
+
const StyledSelect = styled(CpslSelect) `
|
|
118
|
+
--container-height: auto;
|
|
119
|
+
--container-border-width: 0px;
|
|
120
|
+
--container-padding-end: 0px;
|
|
121
|
+
--container-padding-start: 0px;
|
|
122
|
+
--container-background-color: transparent;
|
|
123
|
+
--container-box-shadow: none;
|
|
124
|
+
--container-gap: 2px;
|
|
125
|
+
--icon-width: 16px;
|
|
126
|
+
--icon-height: 16px;
|
|
127
|
+
|
|
128
|
+
&::part(selected-text) {
|
|
129
|
+
white-space: nowrap;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&::part(dropdown) {
|
|
133
|
+
min-width: ${({ $width }) => `${$width - 2}px`};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&::part(popover) {
|
|
137
|
+
/* Have to adjust the top of the popover here since we're using a transform on the modal which causes fixed position items to not be relative to the viewport */
|
|
138
|
+
@media (max-width: ${MOBILE_SIZE}px) {
|
|
139
|
+
top: ${({ $top }) => ($top ? `${$top}px` : '0px')};
|
|
140
|
+
bottom: 16px;
|
|
141
|
+
}
|
|
142
|
+
cpsl-auth-modal.force-mobile-media & {
|
|
143
|
+
top: ${({ $top }) => ($top ? `${$top}px` : '0px')};
|
|
144
|
+
bottom: 16px;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
&::part(icon) {
|
|
149
|
+
--icon-color: var(--cpsl-color-contrast);
|
|
150
|
+
}
|
|
151
|
+
`;
|
|
152
|
+
const StyledSelectItem = styled(CpslSelectItem) `
|
|
153
|
+
--outer-container-padding-start: 4px;
|
|
154
|
+
--outer-container-padding-end: 4px;
|
|
155
|
+
--outer-container-padding-top: 4px;
|
|
156
|
+
--outer-container-padding-bottom: 4px;
|
|
157
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ExternalWalletStep: () => import("react/jsx-runtime").JSX.Element;
|