@getpara/react-sdk 2.0.0-alpha.19 → 2.0.0-alpha.21
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 +0 -1
- package/dist/index.js +0 -5
- package/dist/modal/ParaModal.js +15 -5
- package/dist/modal/components/Account/Account.js +14 -8
- package/dist/modal/components/Account/AccountProfile.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfile.js +170 -0
- package/dist/modal/components/Account/AccountProfileLink.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileLink.js +205 -0
- package/dist/modal/components/Account/AccountProfileLinkOptions.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileLinkOptions.js +98 -0
- package/dist/modal/components/Account/AccountProfileUnlink.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileUnlink.js +47 -0
- package/dist/modal/components/AuthInput/AuthInput.d.ts +17 -3
- package/dist/modal/components/AuthInput/AuthInput.js +116 -101
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +2 -2
- package/dist/modal/components/AuthOptions/AuthOptions.js +26 -1
- package/dist/modal/components/Body/Body.js +21 -2
- package/dist/modal/components/Controls/Selects.js +3 -19
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +7 -0
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +75 -44
- package/dist/modal/components/Header/hooks/useStepTitle.js +7 -1
- package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +1 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +6 -2
- package/dist/modal/components/OAuth/OAuth.js +2 -2
- package/dist/modal/components/OAuth/TelegramOAuthStep.d.ts +7 -0
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +36 -52
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.d.ts +12 -1
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +40 -23
- package/dist/modal/components/common.d.ts +18 -1
- package/dist/modal/components/common.js +86 -0
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/constants/constants.js +1 -1
- package/dist/modal/constants/oAuthLogos.d.ts +15 -6
- package/dist/modal/constants/oAuthLogos.js +148 -19
- package/dist/modal/hooks/useTelegramLogin.d.ts +12 -0
- package/dist/modal/hooks/useTelegramLogin.js +65 -0
- package/dist/modal/stores/modal/actions.js +6 -1
- package/dist/modal/stores/modal/useModalStore.d.ts +4 -3
- package/dist/modal/stores/modal/useModalStore.js +7 -2
- package/dist/modal/types/modalProps.d.ts +6 -1
- package/dist/modal/utils/authInputHelpers.d.ts +3 -5
- package/dist/modal/utils/authInputHelpers.js +23 -20
- package/dist/modal/utils/getWalletDisplayName.d.ts +5 -0
- package/dist/modal/utils/getWalletDisplayName.js +22 -0
- package/dist/modal/utils/steps.d.ts +10 -2
- package/dist/modal/utils/steps.js +18 -2
- package/dist/provider/ParaProvider.js +6 -5
- package/dist/provider/actions/index.d.ts +19 -0
- package/dist/provider/actions/index.js +47 -29
- package/dist/provider/actions/utils.d.ts +3 -2
- package/dist/provider/actions/utils.js +25 -6
- package/dist/provider/components/CosmosWalletWrapper.js +2 -2
- package/dist/provider/components/EvmWalletWrapper.js +2 -2
- package/dist/provider/components/ExternalWalletWrapper.js +2 -1
- package/dist/provider/components/SolanaWalletWrapper.js +2 -2
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +0 -10
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +2 -12
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +0 -1
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +2 -15
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +0 -6
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +2 -8
- package/dist/provider/hooks/mutations/core.d.ts +27 -0
- package/dist/provider/hooks/mutations/core.js +66 -0
- package/dist/provider/hooks/mutations/index.d.ts +3 -28
- package/dist/provider/hooks/mutations/index.js +4 -60
- package/dist/provider/hooks/mutations/useLinkAccount.d.ts +9 -0
- package/dist/provider/hooks/mutations/useLinkAccount.js +18 -0
- package/dist/provider/hooks/mutations/utils.d.ts +11 -4
- package/dist/provider/hooks/mutations/utils.js +35 -4
- package/dist/provider/hooks/queries/core.d.ts +2 -0
- package/dist/provider/hooks/queries/core.js +13 -0
- package/dist/provider/hooks/queries/index.d.ts +1 -0
- package/dist/provider/hooks/queries/index.js +1 -0
- package/dist/provider/hooks/queries/utils.d.ts +4 -0
- package/dist/provider/hooks/queries/utils.js +24 -0
- package/dist/provider/hooks/utils/useModal.d.ts +4 -1
- package/dist/provider/hooks/utils/useModal.js +12 -2
- package/dist/provider/providers/AccountLinkProvider.d.ts +42 -0
- package/dist/provider/providers/AccountLinkProvider.js +443 -0
- package/dist/provider/providers/AuthProvider.d.ts +3 -1
- package/dist/provider/providers/AuthProvider.js +8 -5
- package/dist/provider/providers/ExternalWalletProvider.d.ts +18 -35
- package/dist/provider/providers/ExternalWalletProvider.js +169 -39
- package/dist/provider/stores/slices/modal.js +3 -1
- package/dist/provider/stores/types.d.ts +2 -1
- package/dist/provider/types/utils.d.ts +25 -6
- package/dist/provider/utils/renameMutations.d.ts +2 -2
- package/package.json +8 -8
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { CpslButton, CpslText } from "@getpara/react-components";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import { AccountTypeIcon } from "../common.js";
|
|
7
|
+
import { getAccountTypeName } from "../../constants/oAuthLogos.js";
|
|
8
|
+
import styled from "styled-components";
|
|
9
|
+
import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
|
|
10
|
+
function AccountProfileUnlink() {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const { unlinkingAccount, unlinkAccountConfirm, isUnlinkAccountPending } = useAccountLinking(), [accountType, setAccountType] = useState((_b = (_a = unlinkingAccount == null ? void 0 : unlinkingAccount.externalWallet) == null ? void 0 : _a.providerId) != null ? _b : unlinkingAccount == null ? void 0 : unlinkingAccount.type);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
var _a2, _b2;
|
|
15
|
+
if (unlinkingAccount) {
|
|
16
|
+
setAccountType((_b2 = (_a2 = unlinkingAccount == null ? void 0 : unlinkingAccount.externalWallet) == null ? void 0 : _a2.providerId) != null ? _b2 : unlinkingAccount == null ? void 0 : unlinkingAccount.type);
|
|
17
|
+
}
|
|
18
|
+
}, [unlinkingAccount]);
|
|
19
|
+
return /* @__PURE__ */ jsxs(Content, { children: [
|
|
20
|
+
/* @__PURE__ */ jsxs(Upper, { children: [
|
|
21
|
+
/* @__PURE__ */ jsx(AccountTypeIcon, { accountType, size: "80px", inset: "5px" }),
|
|
22
|
+
/* @__PURE__ */ jsxs(Message, { variant: "bodyM", weight: "semiBold", color: "contrast", children: [
|
|
23
|
+
"Are you sure you want to unlink your ",
|
|
24
|
+
getAccountTypeName(accountType, { inline: true }),
|
|
25
|
+
"?"
|
|
26
|
+
] })
|
|
27
|
+
] }),
|
|
28
|
+
/* @__PURE__ */ jsx(CpslButton, { variant: "destructive", fullWidth: true, onClick: unlinkAccountConfirm, disabled: isUnlinkAccountPending, children: "Confirm" })
|
|
29
|
+
] });
|
|
30
|
+
}
|
|
31
|
+
const Content = styled.div`
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: flex-start;
|
|
36
|
+
gap: 32px;
|
|
37
|
+
`;
|
|
38
|
+
const Upper = styled(Content)`
|
|
39
|
+
gap: 8px;
|
|
40
|
+
`;
|
|
41
|
+
const Message = styled(CpslText)`
|
|
42
|
+
text-align: center;
|
|
43
|
+
max-width: 342px;
|
|
44
|
+
`;
|
|
45
|
+
export {
|
|
46
|
+
AccountProfileUnlink
|
|
47
|
+
};
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Auth } from '@getpara/user-management-client';
|
|
3
|
+
type ChildProps = {
|
|
4
|
+
isPending: boolean;
|
|
5
|
+
isSubmitting: boolean;
|
|
6
|
+
onSubmit: () => void;
|
|
7
|
+
};
|
|
8
|
+
type AuthInputProps = {
|
|
9
|
+
defaultAuth?: Auth<'email' | 'phone'>;
|
|
10
|
+
onSubmit: (_: Auth<'email' | 'phone'>) => void;
|
|
11
|
+
isSubmitting: boolean;
|
|
2
12
|
disableEmailLogin?: boolean;
|
|
3
13
|
disablePhoneLogin?: boolean;
|
|
4
|
-
|
|
5
|
-
|
|
14
|
+
disableSubmitButton?: boolean;
|
|
15
|
+
children?: (_: ChildProps) => ReactNode;
|
|
16
|
+
error?: string | null;
|
|
17
|
+
sticky?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare const AuthInput: ({ defaultAuth, disableEmailLogin, disablePhoneLogin, onSubmit: _onSubmit, isSubmitting, disableSubmitButton, children: Children, error: propsError, sticky, }: AuthInputProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
20
|
export {};
|
|
@@ -18,30 +18,35 @@ import countryCodes from "../../utils/countryCodes.js";
|
|
|
18
18
|
import { MOBILE_SIZE } from "../../constants/constants.js";
|
|
19
19
|
import { useDropdownPosition } from "./hooks/useDropdownPosition.js";
|
|
20
20
|
import { defaultPhoneMask, phoneMasks } from "./phoneMasks.js";
|
|
21
|
-
import {
|
|
21
|
+
import { extractAuthInfo } from "@getpara/user-management-client";
|
|
22
22
|
import parsePhoneNumberFromString from "libphonenumber-js";
|
|
23
|
-
import {
|
|
24
|
-
import { useStore } from "../../../provider/stores/useStore.js";
|
|
25
|
-
import { isCcMatch, validateAuth } from "../../utils/authInputHelpers.js";
|
|
23
|
+
import { isCcMatch, validateInput } from "../../utils/authInputHelpers.js";
|
|
26
24
|
const DEFAULT_COUNTRY = { label: "United States", value: "+1", selectedLabel: "US", icon: "US" };
|
|
27
|
-
const AuthInput = ({
|
|
25
|
+
const AuthInput = ({
|
|
26
|
+
defaultAuth,
|
|
27
|
+
disableEmailLogin,
|
|
28
|
+
disablePhoneLogin,
|
|
29
|
+
onSubmit: _onSubmit,
|
|
30
|
+
isSubmitting,
|
|
31
|
+
disableSubmitButton,
|
|
32
|
+
children: Children,
|
|
33
|
+
error: propsError,
|
|
34
|
+
sticky = false
|
|
35
|
+
}) => {
|
|
28
36
|
var _a, _b, _c;
|
|
29
37
|
const inputRef = useRef(null);
|
|
30
38
|
const { dropdownMaxHeight, dropdownWidth } = useDropdownPosition(inputRef);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
const para = useInternalClient();
|
|
36
|
-
const { signUpOrLogIn, isSignUpOrLogInPending } = useAuthActions();
|
|
37
|
-
const authInfo = para.authInfo;
|
|
38
|
-
const [storedNationalNumber, storedCountryCode] = useMemo(() => {
|
|
39
|
-
if ((authInfo == null ? void 0 : authInfo.authType) !== "phone") {
|
|
40
|
-
return [void 0, void 0];
|
|
39
|
+
const [authInfo, storedNationalNumber, storedCountryCode] = useMemo(() => {
|
|
40
|
+
if (!defaultAuth) {
|
|
41
|
+
return [void 0, void 0, void 0];
|
|
41
42
|
}
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const authInfo2 = extractAuthInfo(defaultAuth);
|
|
44
|
+
if (!authInfo2 || (authInfo2 == null ? void 0 : authInfo2.authType) !== "phone") {
|
|
45
|
+
return [authInfo2, void 0, void 0];
|
|
46
|
+
}
|
|
47
|
+
const parsed = parsePhoneNumberFromString(authInfo2.identifier);
|
|
48
|
+
return [authInfo2, parsed == null ? void 0 : parsed.nationalNumber, parsed == null ? void 0 : parsed.countryCallingCode];
|
|
49
|
+
}, [defaultAuth]);
|
|
45
50
|
const [countryCode, setCountryCode] = useState(storedCountryCode != null ? storedCountryCode : "+1");
|
|
46
51
|
const [identifier, setIdentifier] = useState(
|
|
47
52
|
(() => {
|
|
@@ -60,28 +65,13 @@ const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
|
|
|
60
65
|
const [matchedCountryCode, setMatchedCountryCode] = useState(
|
|
61
66
|
(_a = countryCodes.find((option) => isCcMatch(countryCode, option))) != null ? _a : DEFAULT_COUNTRY
|
|
62
67
|
);
|
|
63
|
-
const [error, setError] = useState(
|
|
64
|
-
const [isPending, setIsPending] = useState(
|
|
68
|
+
const [error, setError] = useState(propsError || void 0);
|
|
69
|
+
const [isPending, setIsPending] = useState(isSubmitting || false);
|
|
65
70
|
const [search, setSearch] = useState("");
|
|
66
71
|
const setCountryCodes = (countyCodeInput) => {
|
|
67
72
|
setCountryCode(countyCodeInput.value);
|
|
68
73
|
setMatchedCountryCode(countyCodeInput);
|
|
69
74
|
};
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
if (defaultAuthIdentifier && !authInfo) {
|
|
72
|
-
const number = parsePhoneNumberFromString(defaultAuthIdentifier);
|
|
73
|
-
if (number) {
|
|
74
|
-
const countryCode2 = `+${number.countryCallingCode}`;
|
|
75
|
-
const countryCodeInputMatch = countryCodes.find((option) => isCcMatch(countryCode2, option));
|
|
76
|
-
if (countryCodeInputMatch) {
|
|
77
|
-
setCountryCodes(countryCodeInputMatch);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
handleIdentifierInput({
|
|
81
|
-
detail: { value: number ? number.nationalNumber : defaultAuthIdentifier }
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}, [authInfo]);
|
|
85
75
|
const isEmail = identifierType === "email";
|
|
86
76
|
const isPhone = identifierType === "phone";
|
|
87
77
|
const isUnknown = !identifierType;
|
|
@@ -93,6 +83,9 @@ const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
|
|
|
93
83
|
};
|
|
94
84
|
const handleIdentifierInput = (ev) => {
|
|
95
85
|
var _a2;
|
|
86
|
+
if (!sticky) {
|
|
87
|
+
setError(void 0);
|
|
88
|
+
}
|
|
96
89
|
const newIdentifier = (_a2 = ev.detail.value) != null ? _a2 : "";
|
|
97
90
|
let isNewPhone = false, isNewEmail = false;
|
|
98
91
|
if (!disablePhoneLogin) {
|
|
@@ -118,90 +111,102 @@ const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
|
|
|
118
111
|
}
|
|
119
112
|
};
|
|
120
113
|
const onSubmit = () => __async(void 0, null, function* () {
|
|
121
|
-
setError(
|
|
122
|
-
let auth;
|
|
114
|
+
setError(void 0);
|
|
123
115
|
try {
|
|
124
|
-
auth =
|
|
125
|
-
|
|
116
|
+
const auth = validateInput(identifier, countryCode, identifierType);
|
|
117
|
+
_onSubmit(auth);
|
|
126
118
|
} catch (err) {
|
|
127
119
|
setError(err.message);
|
|
128
120
|
}
|
|
129
121
|
});
|
|
130
122
|
useEffect(() => {
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
setIsPending(isSubmitting);
|
|
124
|
+
}, [isSubmitting]);
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (propsError === null || propsError === void 0 && !sticky) {
|
|
127
|
+
setError(void 0);
|
|
128
|
+
}
|
|
129
|
+
if (propsError) {
|
|
130
|
+
setError(propsError);
|
|
131
|
+
setIsPending(false);
|
|
133
132
|
}
|
|
134
|
-
}, [
|
|
133
|
+
}, [propsError, sticky]);
|
|
135
134
|
useEffect(() => {
|
|
136
|
-
|
|
135
|
+
if (!sticky || isSubmitting) {
|
|
136
|
+
setIsPending(isSubmitting);
|
|
137
|
+
}
|
|
137
138
|
}, [error]);
|
|
138
139
|
if (disableEmailLogin && disablePhoneLogin) {
|
|
139
140
|
return null;
|
|
140
141
|
}
|
|
141
|
-
return /* @__PURE__ */
|
|
142
|
+
return /* @__PURE__ */ jsxs(
|
|
142
143
|
"form",
|
|
143
144
|
{
|
|
144
145
|
onSubmit: (e) => __async(void 0, null, function* () {
|
|
145
146
|
e.preventDefault();
|
|
146
147
|
onSubmit();
|
|
147
148
|
}),
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
/* @__PURE__ */
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
/* @__PURE__ */
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
149
|
+
style: { width: "100%" },
|
|
150
|
+
children: [
|
|
151
|
+
/* @__PURE__ */ jsxs(
|
|
152
|
+
StyledInput,
|
|
153
|
+
{
|
|
154
|
+
ref: inputRef,
|
|
155
|
+
id: "authInput",
|
|
156
|
+
placeholder: isEmail || disablePhoneLogin ? "Enter email" : isPhone || disableEmailLogin ? "Enter phone" : "Enter email or phone",
|
|
157
|
+
onCpslInput: handleIdentifierInput,
|
|
158
|
+
value: identifier,
|
|
159
|
+
errorText: error,
|
|
160
|
+
autofocus: true,
|
|
161
|
+
inputMode: "email",
|
|
162
|
+
onKeyDown: (e) => __async(void 0, null, function* () {
|
|
163
|
+
return e.key === "Enter" && onSubmit();
|
|
164
|
+
}),
|
|
165
|
+
contrastText: true,
|
|
166
|
+
isPhone,
|
|
167
|
+
mask: identifierType === "phone" ? (_c = phoneMasks[(_b = matchedCountryCode.selectedLabel) != null ? _b : ""]) != null ? _c : defaultPhoneMask : void 0,
|
|
168
|
+
enterkeyhint: "go",
|
|
169
|
+
noAutoDisable: true,
|
|
170
|
+
disabled: isPending,
|
|
171
|
+
"data-testid": "auth-input",
|
|
172
|
+
children: [
|
|
173
|
+
/* @__PURE__ */ jsxs(IconContainer, { slot: "start", children: [
|
|
174
|
+
!disableEmailLogin && (isUnknown || isEmail) && /* @__PURE__ */ jsx(CpslIcon, { "aria-label": "email", icon: "mail" }),
|
|
175
|
+
!disablePhoneLogin && isUnknown && /* @__PURE__ */ jsx(CpslIcon, { "aria-label": "phone", icon: "phone" }),
|
|
176
|
+
isPhone && /* @__PURE__ */ jsxs(
|
|
177
|
+
CountryCodeSelect,
|
|
178
|
+
{
|
|
179
|
+
selectedValue: matchedCountryCode.selectedLabel,
|
|
180
|
+
onCpslSelectValueChange: handleCountryCodeInput,
|
|
181
|
+
showFormattedSelectedItem: true,
|
|
182
|
+
autoWidth: true,
|
|
183
|
+
dropdownMaxHeight,
|
|
184
|
+
anchorElId: "authInput",
|
|
185
|
+
$width: dropdownWidth != null ? dropdownWidth : 0,
|
|
186
|
+
showSearch: true,
|
|
187
|
+
searchPlaceholder: "Search Countries",
|
|
188
|
+
onCpslSearchChange: handleSearchInput,
|
|
189
|
+
"data-testid": "country-code-select",
|
|
190
|
+
children: [
|
|
191
|
+
matchedCountryCode && /* @__PURE__ */ jsxs(SelectedItem, { slot: "selected-item", children: [
|
|
192
|
+
/* @__PURE__ */ jsx(CpslText, { children: matchedCountryCode.selectedLabel }),
|
|
193
|
+
/* @__PURE__ */ jsx(CpslText, { children: matchedCountryCode.value })
|
|
194
|
+
] }),
|
|
195
|
+
filteredCountryCodes.map((cc) => /* @__PURE__ */ jsxs(StyledSelectItem, { slot: "items", value: cc.selectedLabel, children: [
|
|
196
|
+
/* @__PURE__ */ jsx(CpslText, { children: cc.label }),
|
|
197
|
+
/* @__PURE__ */ jsx(CpslText, { children: cc.value })
|
|
198
|
+
] }, cc.selectedLabel))
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
] }),
|
|
203
|
+
identifier && !disableSubmitButton && /* @__PURE__ */ jsx(CpslButton, { slot: "end", size: "small", fullWidth: true, disabled: isPending, onClick: onSubmit, children: isPending ? /* @__PURE__ */ jsx(CpslSpinner, { size: 16 }) : /* @__PURE__ */ jsx(CpslIcon, { icon: "arrowNarrow" }) })
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
"email"
|
|
207
|
+
),
|
|
208
|
+
Children && /* @__PURE__ */ jsx(ChildContainer, { children: /* @__PURE__ */ jsx(Children, { onSubmit, isPending, isSubmitting: isPending }) })
|
|
209
|
+
]
|
|
205
210
|
}
|
|
206
211
|
);
|
|
207
212
|
};
|
|
@@ -256,6 +261,16 @@ const StyledInput = safeStyled(CpslInput)`
|
|
|
256
261
|
--container-background-color: var(--cpsl-color-background-8);
|
|
257
262
|
--input-background-color: var(--cpsl-color-background-8);
|
|
258
263
|
--container-padding-end: 8px;
|
|
264
|
+
width: 100%;
|
|
265
|
+
`;
|
|
266
|
+
const ChildContainer = safeStyled.div`
|
|
267
|
+
display: flex;
|
|
268
|
+
flex-direction: column;
|
|
269
|
+
align-items: center;
|
|
270
|
+
justify-content: center;
|
|
271
|
+
gap: 8px;
|
|
272
|
+
margin-top: 24px;
|
|
273
|
+
width: 100%;
|
|
259
274
|
`;
|
|
260
275
|
export {
|
|
261
276
|
AuthInput
|
|
@@ -8,7 +8,7 @@ import { ExternalWallets } from "../ExternalWallets/ExternalWallets.js";
|
|
|
8
8
|
import { useModalStore } from "../../stores/index.js";
|
|
9
9
|
import { ModalStep } from "../../utils/steps.js";
|
|
10
10
|
import { AuthLayout } from "../../types/modalProps.js";
|
|
11
|
-
import {
|
|
11
|
+
import { ACCOUNT_TYPES } from "../../constants/oAuthLogos.js";
|
|
12
12
|
import { AuthOptions } from "../AuthOptions/AuthOptions.js";
|
|
13
13
|
import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
|
|
14
14
|
import { useStore } from "../../../provider/stores/useStore.js";
|
|
@@ -61,7 +61,7 @@ const AuthMainStepContent = ({
|
|
|
61
61
|
}
|
|
62
62
|
case AuthLayout.AUTH_CONDENSED: {
|
|
63
63
|
const icons = [];
|
|
64
|
-
oAuthMethods == null ? void 0 : oAuthMethods.forEach((method) => icons.push(useBrandedLogos ?
|
|
64
|
+
oAuthMethods == null ? void 0 : oAuthMethods.forEach((method) => icons.push(ACCOUNT_TYPES[method][useBrandedLogos ? "logoBranded" : "logo"]));
|
|
65
65
|
methods.push([
|
|
66
66
|
/* @__PURE__ */ jsxs(CondensedButton, { onClick: handleCondensedAuthClick, variant: "tertiary", fullWidth: true, children: [
|
|
67
67
|
/* @__PURE__ */ jsx(IconGroupSpacer, { slot: "start", icons: [], $isDark: useDarkLogos }),
|
|
@@ -8,21 +8,46 @@ import { AuthInput } from "../AuthInput/AuthInput.js";
|
|
|
8
8
|
import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
|
|
9
9
|
import { useModalStore } from "../../stores/index.js";
|
|
10
10
|
import { CpslIcon, CpslText } from "@getpara/react-components";
|
|
11
|
+
import { useAuthActions } from "../../../provider/providers/AuthProvider.js";
|
|
12
|
+
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
13
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
14
|
+
import { isEmail, isPhone } from "@getpara/user-management-client";
|
|
11
15
|
const AuthOptions = ({
|
|
12
16
|
oAuthMethods,
|
|
13
17
|
disableEmailLogin,
|
|
14
18
|
disablePhoneLogin,
|
|
15
19
|
isGuestModeEnabled = false
|
|
16
20
|
}) => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const para = useInternalClient();
|
|
23
|
+
const defaultAuthIdentifier = useStore((state) => {
|
|
24
|
+
var _a2;
|
|
25
|
+
return (_a2 = state.modalConfig) == null ? void 0 : _a2.defaultAuthIdentifier;
|
|
26
|
+
});
|
|
27
|
+
const { signUpOrLogIn, isSignUpOrLogInPending } = useAuthActions();
|
|
17
28
|
const { wallets } = useExternalWallets();
|
|
18
29
|
const guestAddFundsTab = useModalStore((state) => state.guestAddFundsTab);
|
|
30
|
+
const defaultAuth = defaultAuthIdentifier ? /^\+\d+$/.test(defaultAuthIdentifier) ? { phone: defaultAuthIdentifier } : { email: defaultAuthIdentifier } : para.authInfo && (isEmail((_a = para.authInfo) == null ? void 0 : _a.auth) || isPhone((_b = para.authInfo) == null ? void 0 : _b.auth)) ? para.authInfo.auth : void 0;
|
|
19
31
|
const Content = useMemo(() => {
|
|
20
32
|
const Methods = [];
|
|
21
33
|
if (!!(oAuthMethods == null ? void 0 : oAuthMethods.length)) {
|
|
22
34
|
Methods.push(/* @__PURE__ */ jsx(OAuth, { methods: oAuthMethods }, "oAuth"));
|
|
23
35
|
}
|
|
24
36
|
if (!disableEmailLogin || !disablePhoneLogin) {
|
|
25
|
-
Methods.push(
|
|
37
|
+
Methods.push(
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
AuthInput,
|
|
40
|
+
{
|
|
41
|
+
sticky: true,
|
|
42
|
+
defaultAuth,
|
|
43
|
+
disableEmailLogin,
|
|
44
|
+
disablePhoneLogin,
|
|
45
|
+
onSubmit: signUpOrLogIn,
|
|
46
|
+
isSubmitting: isSignUpOrLogInPending
|
|
47
|
+
},
|
|
48
|
+
"input"
|
|
49
|
+
)
|
|
50
|
+
);
|
|
26
51
|
}
|
|
27
52
|
return /* @__PURE__ */ jsx(Fragment, { children: Methods });
|
|
28
53
|
}, [oAuthMethods, disableEmailLogin, disablePhoneLogin, isGuestModeEnabled, wallets]);
|
|
@@ -38,6 +38,10 @@ import { IFrameStep } from "../IFrameStep/IFrameStep.js";
|
|
|
38
38
|
import { useStore } from "../../../provider/stores/useStore.js";
|
|
39
39
|
import { ExternalWalletVerificationStep } from "../ExternalWalletVerificationStep/ExternalWalletVerificationStep.js";
|
|
40
40
|
import { NetworkSpeedBanner } from "@getpara/react-common";
|
|
41
|
+
import { AccountProfile } from "../Account/AccountProfile.js";
|
|
42
|
+
import { AccountProfileLinkOptions } from "../Account/AccountProfileLinkOptions.js";
|
|
43
|
+
import { AccountProfileLink } from "../Account/AccountProfileLink.js";
|
|
44
|
+
import { AccountProfileUnlink } from "../Account/AccountProfileUnlink.js";
|
|
41
45
|
const MIN_HEIGHT = {
|
|
42
46
|
[ModalStep.ADD_FUNDS_AWAITING]: "680px"
|
|
43
47
|
};
|
|
@@ -47,6 +51,9 @@ const PADDING_TOP = {
|
|
|
47
51
|
const PADDING_BOTTOM = {
|
|
48
52
|
[ModalStep.TELEGRAM_OAUTH]: "16px"
|
|
49
53
|
};
|
|
54
|
+
const PADDING_X = {
|
|
55
|
+
[ModalStep.ACCOUNT_PROFILE]: "32px"
|
|
56
|
+
};
|
|
50
57
|
const Body = ({
|
|
51
58
|
oAuthMethods,
|
|
52
59
|
twoFactorAuthEnabled,
|
|
@@ -163,6 +170,18 @@ const Body = ({
|
|
|
163
170
|
case ModalStep.ACCOUNT_MAIN: {
|
|
164
171
|
return /* @__PURE__ */ jsx(Account, { onClose });
|
|
165
172
|
}
|
|
173
|
+
case ModalStep.ACCOUNT_PROFILE: {
|
|
174
|
+
return /* @__PURE__ */ jsx(AccountProfile, {});
|
|
175
|
+
}
|
|
176
|
+
case ModalStep.ACCOUNT_PROFILE_LIST: {
|
|
177
|
+
return /* @__PURE__ */ jsx(AccountProfileLinkOptions, {});
|
|
178
|
+
}
|
|
179
|
+
case ModalStep.ACCOUNT_PROFILE_ADD: {
|
|
180
|
+
return /* @__PURE__ */ jsx(AccountProfileLink, {});
|
|
181
|
+
}
|
|
182
|
+
case ModalStep.ACCOUNT_PROFILE_REMOVE: {
|
|
183
|
+
return /* @__PURE__ */ jsx(AccountProfileUnlink, {});
|
|
184
|
+
}
|
|
166
185
|
case ModalStep.EX_WALLET_SELECTED: {
|
|
167
186
|
return /* @__PURE__ */ jsx(ExternalWalletStep, {});
|
|
168
187
|
}
|
|
@@ -279,8 +298,8 @@ const InnerContainer = safeStyled.div`
|
|
|
279
298
|
justify-content: flex-start;
|
|
280
299
|
gap: 24px;
|
|
281
300
|
padding: ${({ $embeddedModal, $step, $isIFrameStep }) => {
|
|
282
|
-
var _a, _b;
|
|
283
|
-
return $isIFrameStep ? "0px" : $embeddedModal ? "12px 0px 0px" : `${(_a = PADDING_TOP[$step]) != null ? _a : "72px"} 72px ${(
|
|
301
|
+
var _a, _b, _c;
|
|
302
|
+
return $isIFrameStep ? "0px" : $embeddedModal ? "12px 0px 0px" : `${(_a = PADDING_TOP[$step]) != null ? _a : "72px"} ${(_b = PADDING_X[$step]) != null ? _b : "72px"} ${(_c = PADDING_BOTTOM[$step]) != null ? _c : "32px"}`;
|
|
284
303
|
}};
|
|
285
304
|
min-height: ${({ $step }) => {
|
|
286
305
|
var _a;
|
|
@@ -16,14 +16,10 @@ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClie
|
|
|
16
16
|
import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
|
|
17
17
|
import { useStore } from "../../../provider/stores/useStore.js";
|
|
18
18
|
import { useCopyToClipboard } from "@getpara/react-common";
|
|
19
|
+
import { getWalletDisplayName } from "../../utils/getWalletDisplayName.js";
|
|
19
20
|
const getValue = (id, type) => {
|
|
20
21
|
return id && type ? `${id}~${type}` : void 0;
|
|
21
22
|
};
|
|
22
|
-
const WALLET_TYPES = {
|
|
23
|
-
EVM: "EVM",
|
|
24
|
-
SOLANA: "Solana",
|
|
25
|
-
COSMOS: "Cosmos"
|
|
26
|
-
};
|
|
27
23
|
const ChainSelect = () => {
|
|
28
24
|
var _a, _b;
|
|
29
25
|
const containerRef = useRef(null);
|
|
@@ -65,18 +61,6 @@ const ChainSelect = () => {
|
|
|
65
61
|
}
|
|
66
62
|
) }) });
|
|
67
63
|
};
|
|
68
|
-
function getName(para, {
|
|
69
|
-
type,
|
|
70
|
-
isExternal,
|
|
71
|
-
name,
|
|
72
|
-
isMenu = false,
|
|
73
|
-
hideWallets = false
|
|
74
|
-
}) {
|
|
75
|
-
if (para.isMultiWallet) {
|
|
76
|
-
return name != null ? name : `${isExternal ? "External " : ""}${type ? WALLET_TYPES[type] : ""}${!hideWallets && (isMenu || isExternal) ? " Wallet" : ""}`;
|
|
77
|
-
}
|
|
78
|
-
return hideWallets ? "My Account" : name || "My Wallet";
|
|
79
|
-
}
|
|
80
64
|
const AccountSelect = () => {
|
|
81
65
|
var _a;
|
|
82
66
|
const hideWallets = useStore((state) => {
|
|
@@ -97,7 +81,7 @@ const AccountSelect = () => {
|
|
|
97
81
|
};
|
|
98
82
|
const ActiveWalletNode = activeWallet ? /* @__PURE__ */ jsxs(FlexRow, { slot: "selected-item", style: { height: "24px" }, children: [
|
|
99
83
|
!isGuest && /* @__PURE__ */ jsx(CpslIdenticon, { variant: "avatar", size: "24px", hash: para.getIdenticonHash(activeWallet.id, activeWallet.type) }),
|
|
100
|
-
/* @__PURE__ */ jsx(WalletName, { variant: "bodyXS", color: "contrast", style: { marginLeft: isGuest ? "8px" : "0px" }, children: isGuest ? "Guest" :
|
|
84
|
+
/* @__PURE__ */ jsx(WalletName, { variant: "bodyXS", color: "contrast", style: { marginLeft: isGuest ? "8px" : "0px" }, children: isGuest ? "Guest" : getWalletDisplayName(para, __spreadProps(__spreadValues({}, activeWallet), { hideWallets })) }),
|
|
101
85
|
!hideWallets && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
102
86
|
/* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", children: (_a = activeWallet.ensName) != null ? _a : para.getDisplayAddress(activeWallet.id, { truncate: true, addressType: activeWallet.type }) }),
|
|
103
87
|
/* @__PURE__ */ jsx(
|
|
@@ -141,7 +125,7 @@ const AccountSelect = () => {
|
|
|
141
125
|
activeWallet && ActiveWalletNode,
|
|
142
126
|
availableWallets.map(({ address, name: _name, id, type, isExternal }) => {
|
|
143
127
|
const key = getValue(id, type);
|
|
144
|
-
const name = _name != null ? _name :
|
|
128
|
+
const name = _name != null ? _name : getWalletDisplayName(para, { type, isExternal, isMenu: true, hideWallets });
|
|
145
129
|
return /* @__PURE__ */ jsx(HeaderSelectItem, { slot: "items", value: key, children: /* @__PURE__ */ jsxs(FlexRow, { children: [
|
|
146
130
|
/* @__PURE__ */ jsx(CpslIdenticon, { size: "40px", hash: para.getIdenticonHash(id, type) }),
|
|
147
131
|
/* @__PURE__ */ jsxs(FlexCol, { children: [
|
|
@@ -1 +1,8 @@
|
|
|
1
|
+
import { CommonWallet } from '@getpara/react-common';
|
|
2
|
+
export declare const ExternalWalletMobileConnect: ({ wallet, qrUri: propsQrUri, onConnectWc, isSelfFetching, }: {
|
|
3
|
+
wallet: CommonWallet;
|
|
4
|
+
qrUri?: string;
|
|
5
|
+
onConnectWc: (_: CommonWallet) => Promise<void>;
|
|
6
|
+
isSelfFetching?: boolean;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
1
8
|
export declare const ExternalWalletStep: () => import("react/jsx-runtime").JSX.Element | null;
|