@getpara/react-sdk 1.2.0 → 1.3.1-dev.1
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/cli/cli.mjs +43 -0
- package/dist/index.js +6428 -5
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/modal/components/AuthInput/AuthInput.d.ts +1 -1
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +4 -4
- package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -1
- package/dist/modal/components/Controls/Selects.d.ts +1 -1
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -1
- package/dist/modal/components/Footer/Footer.d.ts +1 -1
- package/dist/modal/components/WalletCard/WalletCard.d.ts +2 -2
- package/dist/modal/components/common.d.ts +2 -2
- package/dist/modal/index.d.ts +0 -1
- package/dist/modal/stores/index.d.ts +0 -1
- package/dist/modal/stores/modal/useModalStore.d.ts +6 -3
- package/dist/modal/types/modalProps.d.ts +1 -27
- package/dist/modal/utils/authLayoutHelpers.d.ts +2 -2
- package/dist/modal/utils/getTileButtonFlex.d.ts +1 -1
- package/dist/modal/utils/openPopup.d.ts +1 -1
- package/dist/provider/ParaProvider.d.ts +3 -1
- package/dist/provider/actions/checkIfUserExists.d.ts +2 -7
- package/dist/provider/actions/createUser.d.ts +2 -10
- package/dist/provider/actions/getAccount.d.ts +9 -6
- package/dist/provider/actions/getWallet.d.ts +1 -1
- package/dist/provider/actions/logout.d.ts +4 -1
- package/dist/provider/actions/waitForLoginAndSetup.d.ts +1 -1
- package/dist/provider/components/CosmosWalletWrapper.d.ts +12 -0
- package/dist/provider/components/EvmWalletWrapper.d.ts +12 -0
- package/dist/provider/components/ExternalWalletWrapper.d.ts +8 -0
- package/dist/provider/components/SolanaWalletWrapper.d.ts +9 -0
- package/dist/provider/external/getParaCosmosConnector.d.ts +7 -0
- package/dist/provider/external/getParaEvmConnector.d.ts +7 -0
- package/dist/provider/external/getParaSolanaConnector.d.ts +7 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +10 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +3 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +6 -0
- package/dist/provider/hooks/mutations/useLogout.d.ts +3 -2
- package/dist/provider/hooks/queries/useAccount.d.ts +4 -3
- package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
- package/dist/provider/hooks/utils/useClient.d.ts +1 -1
- package/dist/provider/hooks/utils/useWalletState.d.ts +2 -2
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/EvmExternalWalletProvider.d.ts +7 -0
- package/dist/{modal/providers/ExternalWalletContext.d.ts → provider/providers/ExternalWalletProvider.d.ts} +20 -29
- package/dist/provider/providers/SolanaExternalWalletProvider.d.ts +7 -0
- package/dist/provider/stores/getters.d.ts +3 -3
- package/dist/provider/stores/setters.d.ts +1 -0
- package/dist/provider/stores/slices/config.d.ts +3 -0
- package/dist/provider/stores/slices/externalWallets.d.ts +3 -0
- package/dist/provider/stores/slices/index.d.ts +1 -0
- package/dist/provider/stores/types.d.ts +43 -1
- package/dist/provider/types/externalWalletProviders.d.ts +12 -0
- package/dist/provider/types/provider.d.ts +115 -16
- package/dist/provider/types/utils.d.ts +1 -0
- package/dist/provider/utils/paraConfigTypeGuards.d.ts +7 -0
- package/package.json +33 -9
- package/dist/modal/ParaModal.js +0 -281
- package/dist/modal/components/Account/Account.js +0 -60
- package/dist/modal/components/AddFunds/AddFunds.js +0 -147
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -65
- package/dist/modal/components/AddFunds/AddFundsDone.js +0 -26
- package/dist/modal/components/AddFunds/MoonPayEmbed.js +0 -2
- package/dist/modal/components/AddFunds/index.js +0 -3
- package/dist/modal/components/AuthInput/AuthInput.js +0 -221
- package/dist/modal/components/AuthInput/countryCodes.js +0 -40
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -23
- package/dist/modal/components/AuthInput/phoneMasks.js +0 -247
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -21
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -89
- package/dist/modal/components/AuthOptions/AuthOptions.js +0 -28
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -7
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -5
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -7
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -18
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -17
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -131
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -26
- package/dist/modal/components/Body/Body.js +0 -232
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -77
- package/dist/modal/components/ChainSwitch/config.js +0 -11
- package/dist/modal/components/Controls/Controls.js +0 -54
- package/dist/modal/components/Controls/Selects.js +0 -159
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -116
- package/dist/modal/components/ExternalWalletStep/config.js +0 -11
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -142
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +0 -7
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -119
- package/dist/modal/components/Footer/Footer.js +0 -71
- package/dist/modal/components/Header/Header.js +0 -24
- package/dist/modal/components/Header/hooks/useStepTitle.js +0 -42
- package/dist/modal/components/Hero/Hero.js +0 -119
- package/dist/modal/components/IFrameStep/IFrameStep.js +0 -41
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -19
- package/dist/modal/components/ModalContent/ModalContent.js +0 -282
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -81
- package/dist/modal/components/OAuth/OAuth.js +0 -125
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -133
- package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -10
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -72
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -67
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -105
- package/dist/modal/components/StripeComponents/StripeComponents.js +0 -78
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -8
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -135
- package/dist/modal/components/Waiting/Waiting.js +0 -6
- package/dist/modal/components/WalletCard/PartnerIcon.js +0 -29
- package/dist/modal/components/WalletCard/WalletCard.js +0 -93
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -50
- package/dist/modal/components/common.js +0 -67
- package/dist/modal/components/index.js +0 -1
- package/dist/modal/constants/constants.js +0 -93
- package/dist/modal/constants/defaults.js +0 -5
- package/dist/modal/constants/oAuthLogos.js +0 -18
- package/dist/modal/hooks/useActiveWallet.d.ts +0 -1
- package/dist/modal/hooks/useActiveWallet.js +0 -11
- package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +0 -1
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -46
- package/dist/modal/hooks/useGoBack.js +0 -34
- package/dist/modal/index.js +0 -9
- package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +0 -29
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -18
- package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +0 -33
- package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -22
- package/dist/modal/providers/ExternalWalletContext.js +0 -253
- package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +0 -21
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -12
- package/dist/modal/stores/externalWalletProvider/actions.d.ts +0 -3
- package/dist/modal/stores/externalWalletProvider/actions.js +0 -5
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +0 -20
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -13
- package/dist/modal/stores/index.js +0 -3
- package/dist/modal/stores/modal/actions.js +0 -64
- package/dist/modal/stores/modal/useModalStore.js +0 -41
- package/dist/modal/stores/para/actions.d.ts +0 -3
- package/dist/modal/stores/para/actions.js +0 -5
- package/dist/modal/stores/para/useParaStore.d.ts +0 -10
- package/dist/modal/stores/para/useParaStore.js +0 -3
- package/dist/modal/stores/theme/actions.d.ts +0 -3
- package/dist/modal/stores/theme/actions.js +0 -24
- package/dist/modal/stores/theme/useThemeStore.d.ts +0 -20
- package/dist/modal/stores/theme/useThemeStore.js +0 -14
- package/dist/modal/stores/userInfo/actions.js +0 -34
- package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -9
- package/dist/modal/types/commonTypes.js +0 -1
- package/dist/modal/types/externalWallets.js +0 -21
- package/dist/modal/types/modalProps.js +0 -7
- package/dist/modal/utils/authLayoutHelpers.js +0 -2
- package/dist/modal/utils/getMailtoLink.js +0 -5
- package/dist/modal/utils/getTileButtonFlex.js +0 -15
- package/dist/modal/utils/isPasskeySupported.js +0 -10
- package/dist/modal/utils/openPopup.js +0 -55
- package/dist/modal/utils/routeMobileExternalWallet.js +0 -35
- package/dist/modal/utils/steps.js +0 -215
- package/dist/modal/utils/stringFormatters.js +0 -12
- package/dist/modal/utils/validateOnRampConfig.js +0 -26
- package/dist/provider/ParaProvider.js +0 -17
- package/dist/provider/actions/checkIfUserExists.js +0 -26
- package/dist/provider/actions/createUser.js +0 -30
- package/dist/provider/actions/getAccount.js +0 -24
- package/dist/provider/actions/getWallet.js +0 -16
- package/dist/provider/actions/initiateLogin.js +0 -23
- package/dist/provider/actions/keepSessionAlive.js +0 -23
- package/dist/provider/actions/logout.js +0 -20
- package/dist/provider/actions/signMessage.js +0 -23
- package/dist/provider/actions/signTransaction.js +0 -23
- package/dist/provider/actions/waitForAccountCreation.js +0 -24
- package/dist/provider/actions/waitForLoginAndSetup.js +0 -27
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -24
- package/dist/provider/hooks/index.js +0 -3
- package/dist/provider/hooks/mutations/index.js +0 -10
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
- package/dist/provider/hooks/mutations/useCreateUser.js +0 -23
- package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -23
- package/dist/provider/hooks/mutations/useLogout.js +0 -33
- package/dist/provider/hooks/mutations/useSignMessage.js +0 -33
- package/dist/provider/hooks/mutations/useSignTransaction.js +0 -33
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
- package/dist/provider/hooks/queries/index.js +0 -2
- package/dist/provider/hooks/queries/useAccount.js +0 -23
- package/dist/provider/hooks/queries/useWallet.js +0 -24
- package/dist/provider/hooks/utils/index.js +0 -3
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -79
- package/dist/provider/hooks/utils/useClient.js +0 -8
- package/dist/provider/hooks/utils/useEventListeners.js +0 -87
- package/dist/provider/hooks/utils/useInternalClient.js +0 -9
- package/dist/provider/hooks/utils/useModal.js +0 -15
- package/dist/provider/hooks/utils/useWalletState.js +0 -33
- package/dist/provider/index.js +0 -3
- package/dist/provider/stores/getters.js +0 -5
- package/dist/provider/stores/slices/client.js +0 -4
- package/dist/provider/stores/slices/index.js +0 -3
- package/dist/provider/stores/slices/modal.js +0 -4
- package/dist/provider/stores/slices/wallet.js +0 -6
- package/dist/provider/stores/types.js +0 -1
- package/dist/provider/stores/useStore.js +0 -14
- package/dist/provider/types/provider.js +0 -1
- package/dist/provider/types/query.js +0 -1
- package/dist/provider/types/utils.js +0 -1
- package/dist/provider/utils/renameMutations.js +0 -19
- /package/dist/{modal/css → css}/modal.css +0 -0
- /package/dist/{modal/public → public}/Inter-VariableFont_slnt,wght.ttf +0 -0
|
@@ -1,147 +0,0 @@
|
|
|
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 { EnabledFlow, getOnRampAssets, getOnRampNetworks, OnRampProvider, OnRampPurchaseType, toAssetInfoArray, WalletType, } from '@getpara/web-sdk';
|
|
12
|
-
import { CenteredText, FilledDisabledInput, Heading, InnerStepContainer, QRContainer, StepContainer } from '../common.js';
|
|
13
|
-
import { CpslButton, CpslDivider, CpslIcon, CpslIdenticon, CpslQrCode, CpslSpinner, CpslTab, CpslTabs, CpslText, } from '@getpara/react-components';
|
|
14
|
-
import { useModalStore, useThemeStore } from '../../stores/index.js';
|
|
15
|
-
import { useEffect, useMemo } from 'react';
|
|
16
|
-
import { OnRampProviderButton } from '../OnRampComponents/OnRampProviderButton.js';
|
|
17
|
-
import { isMobile } from '@getpara/web-sdk';
|
|
18
|
-
import { useActiveWallet } from '../../hooks/useActiveWallet.js';
|
|
19
|
-
import { getAddFundsStep, ModalStep } from '../../utils/steps.js';
|
|
20
|
-
import { motion, AnimatePresence } from 'framer-motion';
|
|
21
|
-
import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
|
|
22
|
-
import { getNetworkFromChainId, getNetworkOrMainNetEquivalent, useCopyToClipboard } from '@getpara/react-common';
|
|
23
|
-
import { formatNetworkList } from '../../utils/stringFormatters.js';
|
|
24
|
-
import styled from 'styled-components';
|
|
25
|
-
import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
|
|
26
|
-
const TABS = [
|
|
27
|
-
[EnabledFlow.BUY, 'isBuyEnabled', 'creditCard', 'Buy'],
|
|
28
|
-
[EnabledFlow.RECEIVE, 'isReceiveEnabled', 'qrCode', 'Receive'],
|
|
29
|
-
[EnabledFlow.WITHDRAW, 'isWithdrawEnabled', 'arrowCircleBrokenDownLeft', 'Withdraw'],
|
|
30
|
-
];
|
|
31
|
-
const GENERIC_WALLET = {
|
|
32
|
-
[WalletType.EVM]: 'Ethereum or EVM-based L2s',
|
|
33
|
-
[WalletType.SOLANA]: 'Solana',
|
|
34
|
-
[WalletType.COSMOS]: 'Cosmos',
|
|
35
|
-
};
|
|
36
|
-
export const AddFunds = () => {
|
|
37
|
-
const [isCopied, copy] = useCopyToClipboard();
|
|
38
|
-
const para = useInternalClient();
|
|
39
|
-
const appName = useThemeStore(state => state.appName);
|
|
40
|
-
const onRampConfig = useModalStore(state => state.onRampConfig);
|
|
41
|
-
const hideWallets = useThemeStore(state => state.hideWallets);
|
|
42
|
-
const storedTab = useModalStore(state => state.accountAddFundTab);
|
|
43
|
-
const setStep = useModalStore(state => state.setStep);
|
|
44
|
-
const setOnRampPurchase = useModalStore(state => state.setOnRampPurchase);
|
|
45
|
-
const { chainId } = useExternalWallets();
|
|
46
|
-
const activeWallet = useActiveWallet();
|
|
47
|
-
const tabs = TABS.filter(([, key]) => !!onRampConfig[key]);
|
|
48
|
-
const isMultiFlow = tabs.length > 1;
|
|
49
|
-
const tab = storedTab !== null && storedTab !== void 0 ? storedTab : tabs[0][0];
|
|
50
|
-
const address = useMemo(() => (activeWallet ? para.getDisplayAddress(activeWallet.id, { addressType: activeWallet.type }) : ''), [para, activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.id, activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.type]);
|
|
51
|
-
const onSetTab = (event) => {
|
|
52
|
-
setStep(getAddFundsStep(event.detail.tab));
|
|
53
|
-
};
|
|
54
|
-
const onCopy = () => {
|
|
55
|
-
copy(address);
|
|
56
|
-
};
|
|
57
|
-
const [allowedNetworks, allowedAssets, isProviderAllowed] = useMemo(() => {
|
|
58
|
-
if (!onRampConfig || !activeWallet) {
|
|
59
|
-
return [[], [], {}];
|
|
60
|
-
}
|
|
61
|
-
const action = tab === EnabledFlow.BUY ? OnRampPurchaseType.BUY : OnRampPurchaseType.SELL;
|
|
62
|
-
const detectedNetwork = getNetworkFromChainId(chainId);
|
|
63
|
-
const isExternal = activeWallet.isExternal && !!detectedNetwork;
|
|
64
|
-
const allowedNetworks = isExternal
|
|
65
|
-
? [getNetworkOrMainNetEquivalent(detectedNetwork, onRampConfig.testMode)]
|
|
66
|
-
: getOnRampNetworks(onRampConfig.assetInfo, {
|
|
67
|
-
walletType: activeWallet.type,
|
|
68
|
-
allowed: onRampConfig.allowedAssets ? Object.keys(onRampConfig.allowedAssets) : undefined,
|
|
69
|
-
});
|
|
70
|
-
const allowedAssetsLookup = allowedNetworks.reduce((acc, network) => {
|
|
71
|
-
var _a;
|
|
72
|
-
const configValue = (_a = onRampConfig.allowedAssets) === null || _a === void 0 ? void 0 : _a[network];
|
|
73
|
-
const allowed = configValue === true ? undefined : configValue;
|
|
74
|
-
return Object.assign(Object.assign({}, acc), { [network]: getOnRampAssets(onRampConfig.assetInfo, { walletType: activeWallet.type, network, allowed }) });
|
|
75
|
-
}, {});
|
|
76
|
-
const isProviderAllowed = onRampConfig.providers.reduce((acc, id) => {
|
|
77
|
-
const hasMatch = toAssetInfoArray(onRampConfig.assetInfo).some(([type, network, asset, validProviders]) => {
|
|
78
|
-
var _a, _b;
|
|
79
|
-
return (type === activeWallet.type &&
|
|
80
|
-
allowedNetworks.includes(network) &&
|
|
81
|
-
(!allowedAssetsLookup[network] || allowedAssetsLookup[network].includes(asset)) &&
|
|
82
|
-
!!((_b = (_a = validProviders[id]) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b[action]));
|
|
83
|
-
});
|
|
84
|
-
return Object.assign(Object.assign({}, acc), { [id]: hasMatch });
|
|
85
|
-
}, {});
|
|
86
|
-
return [allowedNetworks, [...new Set(Object.values(allowedAssetsLookup).flat())], isProviderAllowed];
|
|
87
|
-
}, [activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.type, activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.isExternal, tab, onRampConfig.assetInfo, onRampConfig.allowedAssets, chainId]);
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
setOnRampPurchase(undefined);
|
|
90
|
-
}, []);
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
setOnRampPurchase(undefined);
|
|
93
|
-
}, []);
|
|
94
|
-
if (!onRampConfig || !activeWallet) {
|
|
95
|
-
return (_jsx(SpinnerContainer, { children: _jsx(CpslSpinner, {}) }));
|
|
96
|
-
}
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
setOnRampPurchase(undefined);
|
|
99
|
-
}, []);
|
|
100
|
-
return (_jsxs(StepContainer, { children: [isMultiFlow && (_jsx(InnerStepContainer, { children: _jsx(CpslTabs, { selectedTab: tab, onCpslTabsChanged: onSetTab, children: TABS.map(([tab, _, icon, title]) => (_jsxs(CpslTab, { tab: tab, children: [_jsx(CpslIcon, { slot: "start", icon: icon }), title] }, tab))) }) })), _jsx(_Fragment, { children: [EnabledFlow.BUY, EnabledFlow.WITHDRAW].includes(tab) ? (_jsxs(_Fragment, { children: [_jsx(Heading, { variant: "headingS", weight: "bold", children: "Choose Provider" }), _jsxs($InnerStepContainer, { children: [_jsxs(NoProviders, { isHidden: Object.values(isProviderAllowed).some(v => !!v), variant: "bodyM", children: ["No providers are available for this ", hideWallets ? 'account' : 'wallet'] }), _jsx(AnimatePresence, { children: onRampConfig.providers.map((id, index) => {
|
|
101
|
-
return isProviderAllowed[id] ? (_jsx(motion.div, { style: { width: '100%' }, layout: true, initial: { opacity: 0, transform: 'translateX(25px)' }, animate: { opacity: 1, transform: 'none' }, exit: { opacity: 0, transform: 'translateX(-25px)' }, transition: { duration: 0.2 }, children: _jsx(OnRampProviderButton, { config: onRampConfig, index: index, onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
-
var _a;
|
|
103
|
-
if (!(activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.type))
|
|
104
|
-
return;
|
|
105
|
-
const isPopup = id !== OnRampProvider.RAMP;
|
|
106
|
-
const { onRampPurchase: newOnRampPurchase } = yield para.initiateOnRampTransaction({
|
|
107
|
-
walletId: activeWallet.isExternal ? undefined : activeWallet.id,
|
|
108
|
-
externalWalletAddress: activeWallet.isExternal ? activeWallet.id : undefined,
|
|
109
|
-
shouldOpenPopup: isPopup,
|
|
110
|
-
params: {
|
|
111
|
-
type: tab === EnabledFlow.BUY ? OnRampPurchaseType.BUY : OnRampPurchaseType.SELL,
|
|
112
|
-
walletType: activeWallet.type,
|
|
113
|
-
provider: id,
|
|
114
|
-
networks: allowedNetworks,
|
|
115
|
-
assets: allowedAssets,
|
|
116
|
-
defaultNetwork: onRampConfig.defaultOnRampNetwork,
|
|
117
|
-
defaultAsset: onRampConfig.defaultOnRampAsset,
|
|
118
|
-
fiatQuantity: (_a = onRampConfig.defaultBuyAmount) === null || _a === void 0 ? void 0 : _a[0],
|
|
119
|
-
testMode: onRampConfig.testMode,
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
setOnRampPurchase(Object.assign(Object.assign({}, newOnRampPurchase), { fiat: 'USD' }));
|
|
123
|
-
!isPopup && setStep(ModalStep.ADD_FUNDS_AWAITING);
|
|
124
|
-
}) }, id) }, id)) : null;
|
|
125
|
-
}) })] })] })) : (_jsxs(_Fragment, { children: [_jsx(InnerStepContainer, { children: _jsxs(FilledDisabledInput, { noAutoDisable: true, readonly: true, placeholder: address, children: [_jsx(CpslIdenticon, { slot: "start", size: "32px", hash: para.getIdenticonHash(activeWallet.id, activeWallet.type) }), _jsx(CpslButton, { slot: "end", variant: "ghost", onClick: onCopy, children: _jsx(CpslIcon, { icon: isCopied ? 'check' : 'copy' }) })] }, address) }), !isMobile() && (_jsxs(_Fragment, { children: [_jsx(CpslDivider, { children: "or" }), _jsxs(InnerStepContainer, { children: [_jsx(QRContainer, { children: !address ? _jsx(CpslSpinner, { size: 100 }) : _jsx(CpslQrCode, { url: address }, address) }), _jsx(CpslText, { weight: "semiBold", color: "secondary", children: "Scan with your crypto wallet" })] })] })), _jsxs(InnerStepContainer, { children: [_jsxs(CenteredText, { weight: "semiBold", children: [(!!onRampConfig.allowedAssets && allowedNetworks.length > 0) || hideWallets
|
|
126
|
-
? (appName !== null && appName !== void 0 ? appName : 'This App')
|
|
127
|
-
: 'This Wallet', ' ', "Only Supports:"] }), _jsx(CenteredText, { weight: "medium", color: "secondary", children: !!onRampConfig.allowedAssets && allowedNetworks.length > 0
|
|
128
|
-
? formatNetworkList(allowedNetworks)
|
|
129
|
-
: GENERIC_WALLET[activeWallet.type] })] })] })) })] }));
|
|
130
|
-
};
|
|
131
|
-
const SpinnerContainer = styled(StepContainer) `
|
|
132
|
-
margin: 50% 0;
|
|
133
|
-
`;
|
|
134
|
-
const $InnerStepContainer = styled(InnerStepContainer) `
|
|
135
|
-
position: relative;
|
|
136
|
-
min-height: 270px;
|
|
137
|
-
`;
|
|
138
|
-
const NoProviders = styled(CpslText) `
|
|
139
|
-
width: 100%;
|
|
140
|
-
text-align: center;
|
|
141
|
-
visibility: ${({ isHidden }) => (isHidden ? 'hidden' : 'visible')};
|
|
142
|
-
position: absolute;
|
|
143
|
-
top: 0;
|
|
144
|
-
left: 0;
|
|
145
|
-
right: 0;
|
|
146
|
-
transition: visibility 0.2s;
|
|
147
|
-
`;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { StepContainer } from '../common.js';
|
|
3
|
-
import { OnRampProvider } from '@getpara/web-sdk';
|
|
4
|
-
import { useModalStore, useThemeStore } from '../../stores/index.js';
|
|
5
|
-
import { lazy, useEffect, useMemo, useState } from 'react';
|
|
6
|
-
import { ModalStep } from '../../utils/steps.js';
|
|
7
|
-
import { RampEmbed, StripeEmbed } from '@getpara/react-common';
|
|
8
|
-
import styled from 'styled-components';
|
|
9
|
-
import { useGoBack } from '../../hooks/useGoBack.js';
|
|
10
|
-
import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
|
|
11
|
-
const STEPS = {
|
|
12
|
-
CANCELLED: ModalStep.ADD_FUNDS_FAILURE,
|
|
13
|
-
FINISHED: ModalStep.ADD_FUNDS_SUCCESS,
|
|
14
|
-
};
|
|
15
|
-
export const AddFundsAwaiting = () => {
|
|
16
|
-
const setStep = useModalStore(state => state.setStep);
|
|
17
|
-
const goBack = useGoBack();
|
|
18
|
-
const onRampConfig = useModalStore(state => state.onRampConfig);
|
|
19
|
-
const onRampPurchase = useModalStore(state => state.onRampPurchase);
|
|
20
|
-
const setOnRampPurchase = useModalStore(state => state.setOnRampPurchase);
|
|
21
|
-
const para = useInternalClient();
|
|
22
|
-
const appName = useThemeStore(state => state.appName);
|
|
23
|
-
const isDark = useThemeStore(state => state.isDark);
|
|
24
|
-
const [MoonPayEmbed, setMoonPayEmbed] = useState(null);
|
|
25
|
-
const props = {
|
|
26
|
-
para,
|
|
27
|
-
appName,
|
|
28
|
-
onRampConfig,
|
|
29
|
-
onRampPurchase: onRampPurchase,
|
|
30
|
-
isDark,
|
|
31
|
-
isEmbedded: true,
|
|
32
|
-
setOnRampPurchase,
|
|
33
|
-
onClose: goBack,
|
|
34
|
-
};
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
const _MoonPayEmbed = lazy(() => import(`./MoonPayEmbed.js`));
|
|
37
|
-
setMoonPayEmbed(_MoonPayEmbed);
|
|
38
|
-
}, []);
|
|
39
|
-
const onRampEmbed = useMemo(() => {
|
|
40
|
-
if (!onRampPurchase.id) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
switch (onRampPurchase === null || onRampPurchase === void 0 ? void 0 : onRampPurchase.provider) {
|
|
44
|
-
case OnRampProvider.STRIPE:
|
|
45
|
-
return _jsx(StripeEmbed, Object.assign({}, props));
|
|
46
|
-
case OnRampProvider.MOONPAY:
|
|
47
|
-
return !MoonPayEmbed || typeof window === 'undefined' ? null : _jsx(MoonPayEmbed, Object.assign({}, props));
|
|
48
|
-
case OnRampProvider.RAMP:
|
|
49
|
-
return _jsx(RampEmbed, Object.assign({ apiKey: onRampConfig.rampApiKey }, props));
|
|
50
|
-
}
|
|
51
|
-
}, [onRampPurchase === null || onRampPurchase === void 0 ? void 0 : onRampPurchase.provider, MoonPayEmbed]);
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
let timeoutId;
|
|
54
|
-
if ((onRampPurchase === null || onRampPurchase === void 0 ? void 0 : onRampPurchase.status) && ['CANCELLED', 'FINISHED'].includes(onRampPurchase.status)) {
|
|
55
|
-
timeoutId = setTimeout(() => {
|
|
56
|
-
setStep(STEPS[onRampPurchase.status]);
|
|
57
|
-
}, 5000);
|
|
58
|
-
}
|
|
59
|
-
return () => clearTimeout(timeoutId);
|
|
60
|
-
}, [onRampPurchase === null || onRampPurchase === void 0 ? void 0 : onRampPurchase.status]);
|
|
61
|
-
return _jsx(Container, { "$wide": true, children: onRampEmbed });
|
|
62
|
-
};
|
|
63
|
-
const Container = styled(StepContainer) `
|
|
64
|
-
flex: 1;
|
|
65
|
-
`;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Heading, HeroIcon, InnerStepContainer, StepContainer } from '../common.js';
|
|
3
|
-
import { useModalStore, useThemeStore } from '../../stores/index.js';
|
|
4
|
-
import { useMemo } from 'react';
|
|
5
|
-
import { CpslButton, CpslText } from '@getpara/react-components';
|
|
6
|
-
import { getAddFundsStep } from '../../utils/steps.js';
|
|
7
|
-
export const AddFundsDone = ({ isSuccess, onClose }) => {
|
|
8
|
-
const hideWallets = useThemeStore(state => state.hideWallets);
|
|
9
|
-
const setStep = useModalStore(state => state.setStep);
|
|
10
|
-
const onRampPurchase = useModalStore(state => state.onRampPurchase);
|
|
11
|
-
const accountAddFundTab = useModalStore(state => state.accountAddFundTab);
|
|
12
|
-
const formatter = useMemo(() => {
|
|
13
|
-
return new Intl.NumberFormat('en-US', {
|
|
14
|
-
style: 'currency',
|
|
15
|
-
currency: (onRampPurchase === null || onRampPurchase === void 0 ? void 0 : onRampPurchase.fiat) || 'USD',
|
|
16
|
-
});
|
|
17
|
-
}, [onRampPurchase === null || onRampPurchase === void 0 ? void 0 : onRampPurchase.fiat]);
|
|
18
|
-
const heading = isSuccess ? 'Transaction Successful' : 'Something Went Wrong';
|
|
19
|
-
const text = isSuccess
|
|
20
|
-
? `${formatter.format(parseFloat(onRampPurchase === null || onRampPurchase === void 0 ? void 0 : onRampPurchase.fiatQuantity))} is now available in your ${hideWallets ? 'account' : 'wallet'}.`
|
|
21
|
-
: `No funds were added to your ${hideWallets ? 'account' : 'wallet'}.`;
|
|
22
|
-
const buttonText = isSuccess ? 'Done' : 'Try Again';
|
|
23
|
-
return (_jsxs(StepContainer, { children: [_jsx(HeroIcon, { icon: "checkCircleFilled" }), _jsxs(InnerStepContainer, { children: [_jsx(Heading, { variant: "headingS", weight: "bold", children: heading }), _jsx(CpslText, { variant: "bodyS", color: "secondary", children: text })] }), _jsx(CpslButton, { fullWidth: true, onClick: () => {
|
|
24
|
-
isSuccess ? onClose() : setStep(getAddFundsStep(accountAddFundTab));
|
|
25
|
-
}, children: buttonText })] }));
|
|
26
|
-
};
|
|
@@ -1,221 +0,0 @@
|
|
|
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 { CpslButton, CpslIcon, CpslInput, CpslSelect, CpslSelectItem, CpslSpinner, CpslText, } from '@getpara/react-components';
|
|
12
|
-
import { useRef, useState } from 'react';
|
|
13
|
-
import styled from 'styled-components';
|
|
14
|
-
import countryCodes from './countryCodes.js';
|
|
15
|
-
import { useModalStore, useUserInfoStore } from '../../stores/index.js';
|
|
16
|
-
import { EMAIL_REGEX, MOBILE_SIZE } from '../../constants/constants.js';
|
|
17
|
-
import { useDropdownPosition } from './hooks/useDropdownPosition.js';
|
|
18
|
-
import { ModalStep } from '../../utils/steps.js';
|
|
19
|
-
import { defaultPhoneMask, phoneMasks } from './phoneMasks.js';
|
|
20
|
-
import { AuthMethod } from '@getpara/web-sdk';
|
|
21
|
-
import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
|
|
22
|
-
const DEFAULT_COUNTRY = { label: 'United States', value: '+1', selectedLabel: 'US', icon: 'US' };
|
|
23
|
-
export const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
|
|
24
|
-
var _a;
|
|
25
|
-
const inputRef = useRef(null);
|
|
26
|
-
const { dropdownMaxHeight, dropdownWidth } = useDropdownPosition(inputRef);
|
|
27
|
-
const para = useInternalClient();
|
|
28
|
-
const setAuthInfo = useUserInfoStore(state => state.setAuthInfo);
|
|
29
|
-
const authInfo = useUserInfoStore(state => state.getAuthInfo());
|
|
30
|
-
const setFlow = useModalStore(state => state.setFlow);
|
|
31
|
-
const setStep = useModalStore(state => state.setStep);
|
|
32
|
-
const setSupportedAuthMethods = useModalStore(state => state.setSupportedAuthMethods);
|
|
33
|
-
const setBiometricLocationHints = useModalStore(state => state.setBiometricLocationHints);
|
|
34
|
-
const [countryCode, setCountryCode] = useState(((authInfo === null || authInfo === void 0 ? void 0 : authInfo.authType) === 'phone' ? authInfo.auth.countryCode : '+1'));
|
|
35
|
-
const [identifier, setIdentifier] = useState((() => {
|
|
36
|
-
if (!authInfo || ['telegramUserId', 'farcasterUsername'].includes(authInfo.authType)) {
|
|
37
|
-
return '';
|
|
38
|
-
}
|
|
39
|
-
if (authInfo.authType !== 'phone') {
|
|
40
|
-
return authInfo.identifier;
|
|
41
|
-
}
|
|
42
|
-
return authInfo.auth.phone;
|
|
43
|
-
})());
|
|
44
|
-
const [identifierType, setIdentifierType] = useState(authInfo && (authInfo.authType === 'email' || authInfo.authType === 'phone') ? authInfo.authType : undefined);
|
|
45
|
-
const [matchedCountryCode, setMatchedCountryCode] = useState(DEFAULT_COUNTRY);
|
|
46
|
-
const [isLoggingIn, setIsLoggingIn] = useState(false);
|
|
47
|
-
const [error, setError] = useState('');
|
|
48
|
-
const [search, setSearch] = useState('');
|
|
49
|
-
const isEmail = identifierType === 'email';
|
|
50
|
-
const isPhone = identifierType === 'phone';
|
|
51
|
-
const isUnknown = !identifierType;
|
|
52
|
-
const filteredCountryCodes = search
|
|
53
|
-
? countryCodes.filter(cc => cc.selectedLabel.toLowerCase().includes(search.toLowerCase()) ||
|
|
54
|
-
cc.label.toLowerCase().includes(search.toLowerCase()) ||
|
|
55
|
-
cc.value.toLowerCase().includes(search.toLowerCase()))
|
|
56
|
-
: countryCodes;
|
|
57
|
-
const handleSearchInput = (ev) => {
|
|
58
|
-
setSearch(ev.detail);
|
|
59
|
-
};
|
|
60
|
-
const handleIdentifierInput = (ev) => {
|
|
61
|
-
const newIdentifier = ev.detail.value;
|
|
62
|
-
let isNewPhone = false, isNewEmail = false;
|
|
63
|
-
if (!disablePhoneLogin) {
|
|
64
|
-
const countryCodeInputMatch = countryCodes.find(cc => cc.value === newIdentifier);
|
|
65
|
-
if (countryCodeInputMatch) {
|
|
66
|
-
setCountryCode(countryCodeInputMatch.value);
|
|
67
|
-
setMatchedCountryCode(countryCodeInputMatch);
|
|
68
|
-
setIdentifierType('phone');
|
|
69
|
-
setIdentifier('');
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
isNewPhone = !isEmail && isPhone ? /\d+$/.test(newIdentifier) : /\d\d\d+$/.test(newIdentifier);
|
|
73
|
-
}
|
|
74
|
-
if (!disableEmailLogin) {
|
|
75
|
-
isNewEmail = /\D.*$/.test(newIdentifier);
|
|
76
|
-
}
|
|
77
|
-
setIdentifierType(isNewEmail ? 'email' : isNewPhone ? 'phone' : undefined);
|
|
78
|
-
setIdentifier(newIdentifier);
|
|
79
|
-
};
|
|
80
|
-
const handleCountryCodeInput = (ev) => {
|
|
81
|
-
const matchedCountryCode = countryCodes.find(code => code.selectedLabel === ev.detail);
|
|
82
|
-
setCountryCode(matchedCountryCode.value);
|
|
83
|
-
setMatchedCountryCode(matchedCountryCode);
|
|
84
|
-
};
|
|
85
|
-
const login = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
-
setError('');
|
|
87
|
-
if (isUnknown) {
|
|
88
|
-
setError('Please enter a valid email or phone number!');
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
let auth;
|
|
92
|
-
if (isEmail) {
|
|
93
|
-
if (!EMAIL_REGEX.test(identifier)) {
|
|
94
|
-
setError('Please enter a valid email!');
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
// Logout to ensure cleared Capsule state but preserve pregen wallets
|
|
98
|
-
// TODO: migrate to hook once we force the use of the CapsuleProvider
|
|
99
|
-
yield para.logout();
|
|
100
|
-
auth = { email: identifier };
|
|
101
|
-
setAuthInfo(auth);
|
|
102
|
-
const userExists = yield para.checkIfUserExists({ email: identifier });
|
|
103
|
-
if (userExists) {
|
|
104
|
-
const supportedAuthMethods = yield para.initiateUserLoginV2(auth);
|
|
105
|
-
const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY)
|
|
106
|
-
? yield para.getUserBiometricLocationHints()
|
|
107
|
-
: [];
|
|
108
|
-
setFlow('login');
|
|
109
|
-
setStep(ModalStep.BIOMETRIC_LOGIN);
|
|
110
|
-
setSupportedAuthMethods(supportedAuthMethods);
|
|
111
|
-
setBiometricLocationHints(biometricLocationHints);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
// TODO: migrate to hook once we force the use of the CapsuleProvider
|
|
115
|
-
yield para.createUser(auth);
|
|
116
|
-
setFlow('signUp');
|
|
117
|
-
setStep(ModalStep.VERIFICATIONS);
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (isPhone) {
|
|
121
|
-
// Logout to ensure cleared Capsule state but preserve pregen wallets
|
|
122
|
-
// TODO: migrate to hook once we force the use of the CapsuleProvider
|
|
123
|
-
yield para.logout();
|
|
124
|
-
let userExists = false;
|
|
125
|
-
try {
|
|
126
|
-
userExists = yield para.checkIfUserExistsByPhone({ phone: identifier, countryCode });
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
setError('Please enter a valid phone number!');
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
auth = { phone: identifier, countryCode };
|
|
133
|
-
setAuthInfo(auth);
|
|
134
|
-
if (userExists) {
|
|
135
|
-
// TODO: migrate to hook once we force the use of the CapsuleProvider
|
|
136
|
-
const supportedAuthMethods = yield para.initiateUserLoginV2(auth);
|
|
137
|
-
const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY)
|
|
138
|
-
? yield para.getUserBiometricLocationHints()
|
|
139
|
-
: [];
|
|
140
|
-
setFlow('login');
|
|
141
|
-
setStep(ModalStep.BIOMETRIC_LOGIN);
|
|
142
|
-
setSupportedAuthMethods(supportedAuthMethods);
|
|
143
|
-
setBiometricLocationHints(biometricLocationHints);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
// TODO: migrate to hook once we force the use of the CapsuleProvider
|
|
147
|
-
yield para.createUserByPhone(auth);
|
|
148
|
-
setFlow('signUp');
|
|
149
|
-
setStep(ModalStep.VERIFICATIONS);
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
const handleSubmit = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
154
|
-
setIsLoggingIn(true);
|
|
155
|
-
yield login();
|
|
156
|
-
setIsLoggingIn(false);
|
|
157
|
-
});
|
|
158
|
-
if (disableEmailLogin && disablePhoneLogin) {
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
return (_jsx("form", { onSubmit: (e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
162
|
-
e.preventDefault();
|
|
163
|
-
yield handleSubmit();
|
|
164
|
-
}), children: _jsxs(StyledInput, { ref: inputRef, id: "authInput", placeholder: isEmail || disablePhoneLogin
|
|
165
|
-
? 'Enter email'
|
|
166
|
-
: isPhone || disableEmailLogin
|
|
167
|
-
? 'Enter phone'
|
|
168
|
-
: 'Enter email or phone', onCpslInput: handleIdentifierInput, value: identifier, errorText: error, autofocus: true, inputMode: "email", onKeyDown: (e) => __awaiter(void 0, void 0, void 0, function* () { return e.key === 'Enter' && handleSubmit(); }), contrastText: true, isPhone: isPhone, mask: identifierType === 'phone' ? ((_a = phoneMasks[matchedCountryCode.selectedLabel]) !== null && _a !== void 0 ? _a : defaultPhoneMask) : undefined, enterkeyhint: "go", noAutoDisable: true, disabled: isLoggingIn, "data-testid": "auth-input", children: [_jsxs(IconContainer, { slot: "start", children: [!disableEmailLogin && (isUnknown || isEmail) && _jsx(CpslIcon, { "aria-label": "email", icon: "mail" }), !disablePhoneLogin && isUnknown && _jsx(CpslIcon, { "aria-label": "phone", icon: "phone" }), isPhone && (_jsxs(CountryCodeSelect, { selectedValue: matchedCountryCode.selectedLabel, onCpslSelectValueChange: handleCountryCodeInput, showFormattedSelectedItem: true, autoWidth: true, dropdownMaxHeight: dropdownMaxHeight, anchorElId: "authInput", "$width": dropdownWidth, showSearch: true, searchPlaceholder: "Search Countries", onCpslSearchChange: handleSearchInput, "data-testid": "country-code-select", children: [matchedCountryCode && (_jsxs(SelectedItem, { slot: "selected-item", children: [_jsx(CpslText, { children: matchedCountryCode.selectedLabel }), _jsx(CpslText, { children: matchedCountryCode.value })] })), filteredCountryCodes.map(cc => (_jsxs(StyledSelectItem, { slot: "items", value: cc.selectedLabel, children: [_jsx(CpslText, { children: cc.label }), _jsx(CpslText, { children: cc.value })] }, cc.selectedLabel)))] }))] }), identifier && (_jsx(CpslButton, { slot: "end", size: "small", fullWidth: true, disabled: isLoggingIn, onClick: handleSubmit, children: isLoggingIn ? _jsx(CpslSpinner, { size: 16 }) : _jsx(CpslIcon, { icon: "arrowNarrow" }) }))] }, 'email') }));
|
|
169
|
-
};
|
|
170
|
-
const IconContainer = styled.div `
|
|
171
|
-
height: 100%;
|
|
172
|
-
display: flex;
|
|
173
|
-
align-items: center;
|
|
174
|
-
gap: 8px;
|
|
175
|
-
padding-right: 12px;
|
|
176
|
-
border-right: 1px solid var(--cpsl-color-background-16);
|
|
177
|
-
|
|
178
|
-
& cpsl-icon {
|
|
179
|
-
--icon-color: var(--cpsl-color-contrast);
|
|
180
|
-
}
|
|
181
|
-
`;
|
|
182
|
-
const CountryCodeSelect = styled(CpslSelect) `
|
|
183
|
-
--container-height: 100%;
|
|
184
|
-
--container-padding-start: 0px;
|
|
185
|
-
--container-padding-end: 0px;
|
|
186
|
-
--container-border-width: 0px;
|
|
187
|
-
--container-gap: 4px;
|
|
188
|
-
--container-background-color: transparent;
|
|
189
|
-
--container-box-shadow: none;
|
|
190
|
-
|
|
191
|
-
&::part(dropdown) {
|
|
192
|
-
width: ${({ $width }) => `${$width - 2}px`};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
&::part(popover) {
|
|
196
|
-
@media (max-width: ${MOBILE_SIZE}px) {
|
|
197
|
-
top: unset !important;
|
|
198
|
-
bottom: 16px;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
cpsl-auth-modal.force-mobile-media & {
|
|
202
|
-
top: unset !important;
|
|
203
|
-
bottom: 16px;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
`;
|
|
207
|
-
const StyledSelectItem = styled(CpslSelectItem) `
|
|
208
|
-
&::part(inner-container) {
|
|
209
|
-
justify-content: space-between;
|
|
210
|
-
}
|
|
211
|
-
`;
|
|
212
|
-
const SelectedItem = styled.div `
|
|
213
|
-
display: flex;
|
|
214
|
-
gap: 4px;
|
|
215
|
-
align-items: center;
|
|
216
|
-
`;
|
|
217
|
-
const StyledInput = styled(CpslInput) `
|
|
218
|
-
--container-background-color: var(--cpsl-color-background-8);
|
|
219
|
-
--input-background-color: var(--cpsl-color-background-8);
|
|
220
|
-
--container-padding-end: 8px;
|
|
221
|
-
`;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { getCountries, getCountryCallingCode } from 'libphonenumber-js';
|
|
2
|
-
const excludedCountries = [
|
|
3
|
-
'AC',
|
|
4
|
-
'CG',
|
|
5
|
-
'CI',
|
|
6
|
-
'CV',
|
|
7
|
-
'GF',
|
|
8
|
-
'GP',
|
|
9
|
-
'MF',
|
|
10
|
-
'NC',
|
|
11
|
-
'PM',
|
|
12
|
-
'RE',
|
|
13
|
-
'SD',
|
|
14
|
-
'SH',
|
|
15
|
-
'SJ',
|
|
16
|
-
'TA',
|
|
17
|
-
'VA',
|
|
18
|
-
'WF',
|
|
19
|
-
'XK',
|
|
20
|
-
'YT',
|
|
21
|
-
];
|
|
22
|
-
const generateCountryCodes = () => {
|
|
23
|
-
const countries = getCountries();
|
|
24
|
-
const countryList = countries
|
|
25
|
-
.filter(country => !excludedCountries.includes(country))
|
|
26
|
-
.map(country => {
|
|
27
|
-
const countryCode = getCountryCallingCode(country);
|
|
28
|
-
const countryName = new Intl.DisplayNames(['en'], { type: 'region' }).of(country);
|
|
29
|
-
return {
|
|
30
|
-
label: countryName,
|
|
31
|
-
value: `+${countryCode}`,
|
|
32
|
-
selectedLabel: country,
|
|
33
|
-
icon: country,
|
|
34
|
-
};
|
|
35
|
-
})
|
|
36
|
-
.sort((a, b) => a.label.localeCompare(b.label));
|
|
37
|
-
return countryList;
|
|
38
|
-
};
|
|
39
|
-
const countryCodes = generateCountryCodes();
|
|
40
|
-
export default countryCodes;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
export const useDropdownPosition = (inputRef) => {
|
|
3
|
-
const [dropdownMaxHeight, setDropdownMaxHeight] = useState();
|
|
4
|
-
const [dropdownWidth, setDropdownWidth] = useState();
|
|
5
|
-
const [mobileAnchor, setMobileAnchor] = useState();
|
|
6
|
-
const resize = () => {
|
|
7
|
-
var _a, _b, _c;
|
|
8
|
-
const newMaxHeight = Math.max(window.innerHeight - ((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().bottom) - 20, window.innerHeight * 0.25);
|
|
9
|
-
setDropdownMaxHeight(newMaxHeight);
|
|
10
|
-
setDropdownWidth((_b = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().width);
|
|
11
|
-
setMobileAnchor((_c = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().height);
|
|
12
|
-
};
|
|
13
|
-
if (inputRef.current && !dropdownMaxHeight) {
|
|
14
|
-
resize();
|
|
15
|
-
}
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
window.addEventListener('resize', resize);
|
|
18
|
-
return () => {
|
|
19
|
-
window.removeEventListener('resize', resize);
|
|
20
|
-
};
|
|
21
|
-
}, []);
|
|
22
|
-
return { dropdownMaxHeight, dropdownWidth, mobileAnchor, resize };
|
|
23
|
-
};
|