@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.
Files changed (180) hide show
  1. package/dist/index.d.ts +5 -0
  2. package/dist/index.js +4 -0
  3. package/dist/modal/ParaModal.d.ts +2 -0
  4. package/dist/modal/ParaModal.js +250 -0
  5. package/dist/modal/components/Account/Account.d.ts +5 -0
  6. package/dist/modal/components/Account/Account.js +59 -0
  7. package/dist/modal/components/AddFunds/AddFunds.d.ts +3 -0
  8. package/dist/modal/components/AddFunds/AddFunds.js +146 -0
  9. package/dist/modal/components/AddFunds/AddFundsAwaiting.d.ts +1 -0
  10. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +64 -0
  11. package/dist/modal/components/AddFunds/AddFundsDone.d.ts +6 -0
  12. package/dist/modal/components/AddFunds/AddFundsDone.js +26 -0
  13. package/dist/modal/components/AddFunds/MoonPayEmbed.d.ts +2 -0
  14. package/dist/modal/components/AddFunds/MoonPayEmbed.js +2 -0
  15. package/dist/modal/components/AddFunds/index.d.ts +3 -0
  16. package/dist/modal/components/AddFunds/index.js +3 -0
  17. package/dist/modal/components/AuthInput/AuthInput.d.ts +6 -0
  18. package/dist/modal/components/AuthInput/AuthInput.js +214 -0
  19. package/dist/modal/components/AuthInput/countryCodes.d.ts +8 -0
  20. package/dist/modal/components/AuthInput/countryCodes.js +40 -0
  21. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +7 -0
  22. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +23 -0
  23. package/dist/modal/components/AuthInput/phoneMasks.d.ts +247 -0
  24. package/dist/modal/components/AuthInput/phoneMasks.js +247 -0
  25. package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +8 -0
  26. package/dist/modal/components/AuthMainStep/AuthMainStep.js +21 -0
  27. package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +8 -0
  28. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +89 -0
  29. package/dist/modal/components/AuthOptions/AuthOptions.d.ts +8 -0
  30. package/dist/modal/components/AuthOptions/AuthOptions.js +28 -0
  31. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.d.ts +1 -0
  32. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +7 -0
  33. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.d.ts +1 -0
  34. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +5 -0
  35. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.d.ts +1 -0
  36. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +7 -0
  37. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +1 -0
  38. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +18 -0
  39. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +4 -0
  40. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +17 -0
  41. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -0
  42. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +127 -0
  43. package/dist/modal/components/Body/AnimatedHeightWrapper.d.ts +6 -0
  44. package/dist/modal/components/Body/AnimatedHeightWrapper.js +26 -0
  45. package/dist/modal/components/Body/Body.d.ts +12 -0
  46. package/dist/modal/components/Body/Body.js +232 -0
  47. package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -0
  48. package/dist/modal/components/ChainSwitch/ChainSwitch.js +77 -0
  49. package/dist/modal/components/ChainSwitch/config.d.ts +7 -0
  50. package/dist/modal/components/ChainSwitch/config.js +11 -0
  51. package/dist/modal/components/Controls/Controls.d.ts +5 -0
  52. package/dist/modal/components/Controls/Controls.js +54 -0
  53. package/dist/modal/components/Controls/Selects.d.ts +2 -0
  54. package/dist/modal/components/Controls/Selects.js +157 -0
  55. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -0
  56. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +116 -0
  57. package/dist/modal/components/ExternalWalletStep/config.d.ts +7 -0
  58. package/dist/modal/components/ExternalWalletStep/config.js +11 -0
  59. package/dist/modal/components/ExternalWallets/ExternalWallets.d.ts +1 -0
  60. package/dist/modal/components/ExternalWallets/ExternalWallets.js +142 -0
  61. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +7 -0
  62. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +118 -0
  63. package/dist/modal/components/Footer/Footer.d.ts +1 -0
  64. package/dist/modal/components/Footer/Footer.js +71 -0
  65. package/dist/modal/components/Header/Header.d.ts +1 -0
  66. package/dist/modal/components/Header/Header.js +24 -0
  67. package/dist/modal/components/Header/hooks/useStepTitle.d.ts +3 -0
  68. package/dist/modal/components/Header/hooks/useStepTitle.js +42 -0
  69. package/dist/modal/components/Hero/Hero.d.ts +1 -0
  70. package/dist/modal/components/Hero/Hero.js +118 -0
  71. package/dist/modal/components/IFrameStep/IFrameStep.d.ts +1 -0
  72. package/dist/modal/components/IFrameStep/IFrameStep.js +41 -0
  73. package/dist/modal/components/LoginDoneStep/LoginDoneStep.d.ts +1 -0
  74. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +18 -0
  75. package/dist/modal/components/ModalContent/ModalContent.d.ts +10 -0
  76. package/dist/modal/components/ModalContent/ModalContent.js +276 -0
  77. package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +2 -0
  78. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +81 -0
  79. package/dist/modal/components/OAuth/OAuth.d.ts +6 -0
  80. package/dist/modal/components/OAuth/OAuth.js +124 -0
  81. package/dist/modal/components/OAuth/TelegramOAuthStep.d.ts +1 -0
  82. package/dist/modal/components/OAuth/TelegramOAuthStep.js +132 -0
  83. package/dist/modal/components/OnRampComponents/AddingFunds.d.ts +1 -0
  84. package/dist/modal/components/OnRampComponents/AddingFunds.js +10 -0
  85. package/dist/modal/components/OnRampComponents/OnRampProviderButton.d.ts +9 -0
  86. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +72 -0
  87. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.d.ts +6 -0
  88. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +67 -0
  89. package/dist/modal/components/Setup2FAStep/Setup2FAStep.d.ts +5 -0
  90. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +104 -0
  91. package/dist/modal/components/StripeComponents/StripeComponents.d.ts +16 -0
  92. package/dist/modal/components/StripeComponents/StripeComponents.js +78 -0
  93. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.d.ts +5 -0
  94. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +8 -0
  95. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.d.ts +1 -0
  96. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +130 -0
  97. package/dist/modal/components/Waiting/Waiting.d.ts +6 -0
  98. package/dist/modal/components/Waiting/Waiting.js +6 -0
  99. package/dist/modal/components/WalletCard/PartnerIcon.d.ts +6 -0
  100. package/dist/modal/components/WalletCard/PartnerIcon.js +29 -0
  101. package/dist/modal/components/WalletCard/WalletCard.d.ts +18 -0
  102. package/dist/modal/components/WalletCard/WalletCard.js +91 -0
  103. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.d.ts +6 -0
  104. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +49 -0
  105. package/dist/modal/components/common.d.ts +19 -0
  106. package/dist/modal/components/common.js +67 -0
  107. package/dist/modal/components/index.d.ts +1 -0
  108. package/dist/modal/components/index.js +1 -0
  109. package/dist/modal/constants/constants.d.ts +32 -0
  110. package/dist/modal/constants/constants.js +93 -0
  111. package/dist/modal/constants/defaults.d.ts +5 -0
  112. package/dist/modal/constants/defaults.js +5 -0
  113. package/dist/modal/constants/oAuthLogos.d.ts +8 -0
  114. package/dist/modal/constants/oAuthLogos.js +18 -0
  115. package/dist/modal/css/modal.css +13 -0
  116. package/dist/modal/hooks/useActiveWallet.d.ts +1 -0
  117. package/dist/modal/hooks/useActiveWallet.js +9 -0
  118. package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +1 -0
  119. package/dist/modal/hooks/useEmbeddedExternalConnection.js +46 -0
  120. package/dist/modal/hooks/useGoBack.d.ts +1 -0
  121. package/dist/modal/hooks/useGoBack.js +34 -0
  122. package/dist/modal/index.d.ts +10 -0
  123. package/dist/modal/index.js +9 -0
  124. package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +29 -0
  125. package/dist/modal/providers/CosmosExternalWalletContextStub.js +18 -0
  126. package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +33 -0
  127. package/dist/modal/providers/EvmExternalWalletContextStub.js +22 -0
  128. package/dist/modal/providers/ExternalWalletContext.d.ts +75 -0
  129. package/dist/modal/providers/ExternalWalletContext.js +252 -0
  130. package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +21 -0
  131. package/dist/modal/providers/SolanaExternalWalletContextStub.js +12 -0
  132. package/dist/modal/public/Inter-VariableFont_slnt,wght.ttf +0 -0
  133. package/dist/modal/stores/externalWalletProvider/actions.d.ts +3 -0
  134. package/dist/modal/stores/externalWalletProvider/actions.js +5 -0
  135. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +20 -0
  136. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +13 -0
  137. package/dist/modal/stores/index.d.ts +4 -0
  138. package/dist/modal/stores/index.js +4 -0
  139. package/dist/modal/stores/modal/actions.d.ts +3 -0
  140. package/dist/modal/stores/modal/actions.js +65 -0
  141. package/dist/modal/stores/modal/useModalStore.d.ts +82 -0
  142. package/dist/modal/stores/modal/useModalStore.js +41 -0
  143. package/dist/modal/stores/para/actions.d.ts +3 -0
  144. package/dist/modal/stores/para/actions.js +5 -0
  145. package/dist/modal/stores/para/useParaStore.d.ts +10 -0
  146. package/dist/modal/stores/para/useParaStore.js +3 -0
  147. package/dist/modal/stores/theme/actions.d.ts +3 -0
  148. package/dist/modal/stores/theme/actions.js +24 -0
  149. package/dist/modal/stores/theme/useThemeStore.d.ts +20 -0
  150. package/dist/modal/stores/theme/useThemeStore.js +14 -0
  151. package/dist/modal/stores/userInfo/actions.d.ts +3 -0
  152. package/dist/modal/stores/userInfo/actions.js +28 -0
  153. package/dist/modal/stores/userInfo/useUserInfoStore.d.ts +19 -0
  154. package/dist/modal/stores/userInfo/useUserInfoStore.js +9 -0
  155. package/dist/modal/types/commonTypes.d.ts +48 -0
  156. package/dist/modal/types/commonTypes.js +1 -0
  157. package/dist/modal/types/externalWallets.d.ts +31 -0
  158. package/dist/modal/types/externalWallets.js +21 -0
  159. package/dist/modal/types/modalProps.d.ts +138 -0
  160. package/dist/modal/types/modalProps.js +7 -0
  161. package/dist/modal/utils/authLayoutHelpers.d.ts +3 -0
  162. package/dist/modal/utils/authLayoutHelpers.js +2 -0
  163. package/dist/modal/utils/getMailtoLink.d.ts +1 -0
  164. package/dist/modal/utils/getMailtoLink.js +5 -0
  165. package/dist/modal/utils/getTileButtonFlex.d.ts +1 -0
  166. package/dist/modal/utils/getTileButtonFlex.js +15 -0
  167. package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
  168. package/dist/modal/utils/isPasskeySupported.js +10 -0
  169. package/dist/modal/utils/openPopup.d.ts +1 -0
  170. package/dist/modal/utils/openPopup.js +55 -0
  171. package/dist/modal/utils/routeMobileExternalWallet.d.ts +1 -0
  172. package/dist/modal/utils/routeMobileExternalWallet.js +35 -0
  173. package/dist/modal/utils/steps.d.ts +112 -0
  174. package/dist/modal/utils/steps.js +215 -0
  175. package/dist/modal/utils/stringFormatters.d.ts +4 -0
  176. package/dist/modal/utils/stringFormatters.js +12 -0
  177. package/dist/modal/utils/validateOnRampConfig.d.ts +5 -0
  178. package/dist/modal/utils/validateOnRampConfig.js +26 -0
  179. package/package.json +51 -0
  180. package/styles.css/package.json +3 -0
@@ -0,0 +1,214 @@
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 { useParaStore, 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
+ const DEFAULT_COUNTRY = { label: 'United States', value: '+1', selectedLabel: 'US', icon: 'US' };
22
+ export const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
23
+ var _a;
24
+ const inputRef = useRef(null);
25
+ const { dropdownMaxHeight, dropdownWidth } = useDropdownPosition(inputRef);
26
+ const para = useParaStore(state => state.para);
27
+ const setAuthInfo = useUserInfoStore(state => state.setAuthInfo);
28
+ const authInfo = useUserInfoStore(state => state.getAuthInfo());
29
+ const setFlow = useModalStore(state => state.setFlow);
30
+ const setStep = useModalStore(state => state.setStep);
31
+ const setSupportedAuthMethods = useModalStore(state => state.setSupportedAuthMethods);
32
+ const setBiometricLocationHints = useModalStore(state => state.setBiometricLocationHints);
33
+ const [countryCode, setCountryCode] = useState(((authInfo === null || authInfo === void 0 ? void 0 : authInfo.authType) === 'phone' ? authInfo.auth.countryCode : '+1'));
34
+ const [identifier, setIdentifier] = useState((() => {
35
+ if (!authInfo || ['telegramUserId', 'farcasterUsername'].includes(authInfo.authType)) {
36
+ return '';
37
+ }
38
+ if (authInfo.authType !== 'phone') {
39
+ return authInfo.identifier;
40
+ }
41
+ return authInfo.auth.phone;
42
+ })());
43
+ const [identifierType, setIdentifierType] = useState(authInfo && (authInfo.authType === 'email' || authInfo.authType === 'phone') ? authInfo.authType : undefined);
44
+ const [matchedCountryCode, setMatchedCountryCode] = useState(DEFAULT_COUNTRY);
45
+ const [isLoggingIn, setIsLoggingIn] = useState(false);
46
+ const [error, setError] = useState('');
47
+ const [search, setSearch] = useState('');
48
+ const isEmail = identifierType === 'email';
49
+ const isPhone = identifierType === 'phone';
50
+ const isUnknown = !identifierType;
51
+ const filteredCountryCodes = search
52
+ ? countryCodes.filter(cc => cc.selectedLabel.toLowerCase().includes(search.toLowerCase()) ||
53
+ cc.label.toLowerCase().includes(search.toLowerCase()) ||
54
+ cc.value.toLowerCase().includes(search.toLowerCase()))
55
+ : countryCodes;
56
+ const handleSearchInput = (ev) => {
57
+ setSearch(ev.detail);
58
+ };
59
+ const handleIdentifierInput = (ev) => {
60
+ const newIdentifier = ev.detail.value;
61
+ let isNewPhone = false, isNewEmail = false;
62
+ if (!disablePhoneLogin) {
63
+ const countryCodeInputMatch = countryCodes.find(cc => cc.value === newIdentifier);
64
+ if (countryCodeInputMatch) {
65
+ setCountryCode(countryCodeInputMatch.value);
66
+ setMatchedCountryCode(countryCodeInputMatch);
67
+ setIdentifierType('phone');
68
+ setIdentifier('');
69
+ return;
70
+ }
71
+ isNewPhone = !isEmail && isPhone ? /\d+$/.test(newIdentifier) : /\d\d\d+$/.test(newIdentifier);
72
+ }
73
+ if (!disableEmailLogin) {
74
+ isNewEmail = /\D.*$/.test(newIdentifier);
75
+ }
76
+ setIdentifierType(isNewEmail ? 'email' : isNewPhone ? 'phone' : undefined);
77
+ setIdentifier(newIdentifier);
78
+ };
79
+ const handleCountryCodeInput = (ev) => {
80
+ const matchedCountryCode = countryCodes.find(code => code.selectedLabel === ev.detail);
81
+ setCountryCode(matchedCountryCode.value);
82
+ setMatchedCountryCode(matchedCountryCode);
83
+ };
84
+ const login = () => __awaiter(void 0, void 0, void 0, function* () {
85
+ setError('');
86
+ if (isUnknown) {
87
+ setError('Please enter a valid email or phone number!');
88
+ return;
89
+ }
90
+ let auth;
91
+ if (isEmail) {
92
+ if (!EMAIL_REGEX.test(identifier)) {
93
+ setError('Please enter a valid email!');
94
+ return;
95
+ }
96
+ // Logout to ensure cleared Para state but preserve pregen wallets
97
+ yield para.logout();
98
+ auth = { email: identifier };
99
+ setAuthInfo(auth);
100
+ const userExists = yield para.checkIfUserExists(identifier);
101
+ if (userExists) {
102
+ const supportedAuthMethods = yield para.initiateUserLoginV2(auth);
103
+ const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY)
104
+ ? yield para.getUserBiometricLocationHints()
105
+ : [];
106
+ setFlow('login');
107
+ setStep(ModalStep.BIOMETRIC_LOGIN);
108
+ setSupportedAuthMethods(supportedAuthMethods);
109
+ setBiometricLocationHints(biometricLocationHints);
110
+ return;
111
+ }
112
+ yield para.createUser(auth);
113
+ setFlow('signUp');
114
+ setStep(ModalStep.VERIFICATIONS);
115
+ return;
116
+ }
117
+ if (isPhone) {
118
+ yield para.logout();
119
+ let userExists = false;
120
+ try {
121
+ userExists = yield para.checkIfUserExistsByPhone(identifier, countryCode);
122
+ }
123
+ catch (error) {
124
+ setError('Please enter a valid phone number!');
125
+ return;
126
+ }
127
+ auth = { phone: identifier, countryCode };
128
+ setAuthInfo(auth);
129
+ if (userExists) {
130
+ const supportedAuthMethods = yield para.initiateUserLoginV2(auth);
131
+ const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY)
132
+ ? yield para.getUserBiometricLocationHints()
133
+ : [];
134
+ setFlow('login');
135
+ setStep(ModalStep.BIOMETRIC_LOGIN);
136
+ setSupportedAuthMethods(supportedAuthMethods);
137
+ setBiometricLocationHints(biometricLocationHints);
138
+ return;
139
+ }
140
+ yield para.createUserByPhone(auth);
141
+ setFlow('signUp');
142
+ setStep(ModalStep.VERIFICATIONS);
143
+ return;
144
+ }
145
+ });
146
+ const handleSubmit = () => __awaiter(void 0, void 0, void 0, function* () {
147
+ setIsLoggingIn(true);
148
+ yield login();
149
+ setIsLoggingIn(false);
150
+ });
151
+ if (disableEmailLogin && disablePhoneLogin) {
152
+ return null;
153
+ }
154
+ return (_jsx("form", { onSubmit: (e) => __awaiter(void 0, void 0, void 0, function* () {
155
+ e.preventDefault();
156
+ yield handleSubmit();
157
+ }), children: _jsxs(StyledInput, { ref: inputRef, id: "authInput", placeholder: isEmail || disablePhoneLogin
158
+ ? 'Enter email'
159
+ : isPhone || disableEmailLogin
160
+ ? 'Enter phone'
161
+ : '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') }));
162
+ };
163
+ const IconContainer = styled.div `
164
+ height: 100%;
165
+ display: flex;
166
+ align-items: center;
167
+ gap: 8px;
168
+ padding-right: 12px;
169
+ border-right: 1px solid var(--cpsl-color-background-16);
170
+
171
+ & cpsl-icon {
172
+ --icon-color: var(--cpsl-color-contrast);
173
+ }
174
+ `;
175
+ const CountryCodeSelect = styled(CpslSelect) `
176
+ --container-height: 100%;
177
+ --container-padding-start: 0px;
178
+ --container-padding-end: 0px;
179
+ --container-border-width: 0px;
180
+ --container-gap: 4px;
181
+ --container-background-color: transparent;
182
+ --container-box-shadow: none;
183
+
184
+ &::part(dropdown) {
185
+ width: ${({ $width }) => `${$width - 2}px`};
186
+ }
187
+
188
+ &::part(popover) {
189
+ @media (max-width: ${MOBILE_SIZE}px) {
190
+ top: unset !important;
191
+ bottom: 16px;
192
+ }
193
+
194
+ cpsl-auth-modal.force-mobile-media & {
195
+ top: unset !important;
196
+ bottom: 16px;
197
+ }
198
+ }
199
+ `;
200
+ const StyledSelectItem = styled(CpslSelectItem) `
201
+ &::part(inner-container) {
202
+ justify-content: space-between;
203
+ }
204
+ `;
205
+ const SelectedItem = styled.div `
206
+ display: flex;
207
+ gap: 4px;
208
+ align-items: center;
209
+ `;
210
+ const StyledInput = styled(CpslInput) `
211
+ --container-background-color: var(--cpsl-color-background-8);
212
+ --input-background-color: var(--cpsl-color-background-8);
213
+ --container-padding-end: 8px;
214
+ `;
@@ -0,0 +1,8 @@
1
+ import { IconType } from '@getpara/core-components';
2
+ declare const countryCodes: {
3
+ label: string;
4
+ value: string;
5
+ selectedLabel: string;
6
+ icon: IconType;
7
+ }[];
8
+ export default countryCodes;
@@ -0,0 +1,40 @@
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;
@@ -0,0 +1,7 @@
1
+ import { MutableRefObject } from 'react';
2
+ export declare const useDropdownPosition: (inputRef: MutableRefObject<HTMLCpslInputElement | HTMLDivElement>) => {
3
+ dropdownMaxHeight: number;
4
+ dropdownWidth: number;
5
+ mobileAnchor: number;
6
+ resize: () => void;
7
+ };
@@ -0,0 +1,23 @@
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
+ };
@@ -0,0 +1,247 @@
1
+ export declare const defaultPhoneMask = "#################";
2
+ export declare const phoneMasks: {
3
+ AF: string;
4
+ AX: string;
5
+ AL: string;
6
+ DZ: string;
7
+ AS: string;
8
+ AD: string;
9
+ AO: string;
10
+ AI: string;
11
+ AG: string;
12
+ AR: string;
13
+ AM: string;
14
+ AW: string;
15
+ AU: string;
16
+ AT: string;
17
+ AZ: string;
18
+ BS: string;
19
+ BH: string;
20
+ BD: string;
21
+ BB: string;
22
+ BY: string;
23
+ BE: string;
24
+ BZ: string;
25
+ BJ: string;
26
+ BM: string;
27
+ BT: string;
28
+ BO: string;
29
+ BA: string;
30
+ BW: string;
31
+ BR: string;
32
+ IO: string;
33
+ BN: string;
34
+ BG: string;
35
+ BF: string;
36
+ BI: string;
37
+ KH: string;
38
+ CM: string;
39
+ CA: string;
40
+ CV: string;
41
+ KY: string;
42
+ CF: string;
43
+ TD: string;
44
+ CL: string;
45
+ CN: string;
46
+ CX: string;
47
+ CC: string;
48
+ CO: string;
49
+ KM: string;
50
+ CG: string;
51
+ CK: string;
52
+ CR: string;
53
+ HR: string;
54
+ CU: string;
55
+ CY: string;
56
+ CZ: string;
57
+ CD: string;
58
+ DK: string;
59
+ DJ: string;
60
+ DM: string;
61
+ DO: string;
62
+ EC: string;
63
+ EG: string;
64
+ SV: string;
65
+ GQ: string;
66
+ ER: string;
67
+ EE: string;
68
+ SZ: string;
69
+ ET: string;
70
+ FK: string;
71
+ FO: string;
72
+ FJ: string;
73
+ FI: string;
74
+ FR: string;
75
+ GF: string;
76
+ PF: string;
77
+ GA: string;
78
+ GM: string;
79
+ GE: string;
80
+ DE: string;
81
+ GH: string;
82
+ GI: string;
83
+ GR: string;
84
+ GL: string;
85
+ GD: string;
86
+ GP: string;
87
+ GU: string;
88
+ GT: string;
89
+ GG: string;
90
+ GN: string;
91
+ GW: string;
92
+ GY: string;
93
+ HT: string;
94
+ VA: string;
95
+ HN: string;
96
+ HK: string;
97
+ HU: string;
98
+ IS: string;
99
+ IN: string;
100
+ ID: string;
101
+ IR: string;
102
+ IQ: string;
103
+ IE: string;
104
+ IM: string;
105
+ IL: string;
106
+ IT: string;
107
+ CI: string;
108
+ JM: string;
109
+ JP: string;
110
+ JE: string;
111
+ JO: string;
112
+ KZ: string;
113
+ KE: string;
114
+ KI: string;
115
+ KP: string;
116
+ KR: string;
117
+ XK: string;
118
+ KW: string;
119
+ KG: string;
120
+ LA: string;
121
+ LV: string;
122
+ LB: string;
123
+ LS: string;
124
+ LR: string;
125
+ LY: string;
126
+ LI: string;
127
+ LT: string;
128
+ LU: string;
129
+ MO: string;
130
+ MG: string;
131
+ MW: string;
132
+ MY: string;
133
+ MV: string;
134
+ ML: string;
135
+ MT: string;
136
+ MH: string;
137
+ MQ: string;
138
+ MR: string;
139
+ MU: string;
140
+ YT: string;
141
+ MX: string;
142
+ FM: string;
143
+ MD: string;
144
+ MC: string;
145
+ MN: string;
146
+ ME: string;
147
+ MS: string;
148
+ MA: string;
149
+ MZ: string;
150
+ MM: string;
151
+ NA: string;
152
+ NR: string;
153
+ NP: string;
154
+ NL: string;
155
+ NC: string;
156
+ NZ: string;
157
+ NI: string;
158
+ NE: string;
159
+ NG: string;
160
+ NU: string;
161
+ NF: string;
162
+ MK: string;
163
+ MP: string;
164
+ NO: string;
165
+ OM: string;
166
+ PK: string;
167
+ PW: string;
168
+ PS: string;
169
+ PA: string;
170
+ PG: string;
171
+ PY: string;
172
+ PE: string;
173
+ PH: string;
174
+ PN: string;
175
+ PL: string;
176
+ PT: string;
177
+ PR: string;
178
+ QA: string;
179
+ RE: string;
180
+ RO: string;
181
+ RU: string;
182
+ RW: string;
183
+ BL: string;
184
+ SH: string;
185
+ KN: string;
186
+ LC: string;
187
+ MF: string;
188
+ PM: string;
189
+ VC: string;
190
+ WS: string;
191
+ SM: string;
192
+ ST: string;
193
+ SA: string;
194
+ SN: string;
195
+ RS: string;
196
+ SC: string;
197
+ SL: string;
198
+ SG: string;
199
+ SX: string;
200
+ SK: string;
201
+ SI: string;
202
+ SB: string;
203
+ SO: string;
204
+ ZA: string;
205
+ GS: string;
206
+ SS: string;
207
+ ES: string;
208
+ LK: string;
209
+ SD: string;
210
+ SR: string;
211
+ SJ: string;
212
+ SE: string;
213
+ CH: string;
214
+ SY: string;
215
+ TW: string;
216
+ TJ: string;
217
+ TZ: string;
218
+ TH: string;
219
+ TL: string;
220
+ TG: string;
221
+ TK: string;
222
+ TO: string;
223
+ TT: string;
224
+ TN: string;
225
+ TR: string;
226
+ TM: string;
227
+ TC: string;
228
+ TV: string;
229
+ UG: string;
230
+ UA: string;
231
+ AE: string;
232
+ GB: string;
233
+ US: string;
234
+ UM: string;
235
+ UY: string;
236
+ UZ: string;
237
+ VU: string;
238
+ VE: string;
239
+ VN: string;
240
+ VG: string;
241
+ VI: string;
242
+ WF: string;
243
+ EH: string;
244
+ YE: string;
245
+ ZM: string;
246
+ ZW: string;
247
+ };