@terreno/ui 57.19.2 → 57.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ai/guidelines/core.md +1 -1
- package/CHANGELOG.md +393 -0
- package/dist/Accordion.d.ts.map +1 -1
- package/dist/Accordion.js +3 -3
- package/dist/Accordion.js.map +1 -1
- package/dist/Avatar.d.ts.map +1 -1
- package/dist/Avatar.js +3 -1
- package/dist/Avatar.js.map +1 -1
- package/dist/Box.d.ts.map +1 -1
- package/dist/Box.js +38 -2
- package/dist/Box.js.map +1 -1
- package/dist/Card.js +2 -2
- package/dist/Card.js.map +1 -1
- package/dist/Common.d.ts +120 -7
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/ConsentFormScreen.d.ts +1 -1
- package/dist/ConsentFormScreen.d.ts.map +1 -1
- package/dist/ConsentFormScreen.js +13 -4
- package/dist/ConsentFormScreen.js.map +1 -1
- package/dist/DateTimeField.d.ts.map +1 -1
- package/dist/DateTimeField.js +5 -3
- package/dist/DateTimeField.js.map +1 -1
- package/dist/Field.d.ts.map +1 -1
- package/dist/Field.js +2 -0
- package/dist/Field.js.map +1 -1
- package/dist/FormContainer.d.ts +68 -0
- package/dist/FormContainer.d.ts.map +1 -0
- package/dist/FormContainer.js +79 -0
- package/dist/FormContainer.js.map +1 -0
- package/dist/GPTChat.d.ts.map +1 -1
- package/dist/GPTChat.js +2 -1
- package/dist/GPTChat.js.map +1 -1
- package/dist/Heading.d.ts +1 -1
- package/dist/Heading.d.ts.map +1 -1
- package/dist/Heading.js +5 -2
- package/dist/Heading.js.map +1 -1
- package/dist/Icon.d.ts +4 -0
- package/dist/Icon.d.ts.map +1 -1
- package/dist/Icon.js +43 -2
- package/dist/Icon.js.map +1 -1
- package/dist/LabeledCheckBox.d.ts +22 -0
- package/dist/LabeledCheckBox.d.ts.map +1 -0
- package/dist/LabeledCheckBox.js +30 -0
- package/dist/LabeledCheckBox.js.map +1 -0
- package/dist/ListDetailLayout.d.ts +36 -0
- package/dist/ListDetailLayout.d.ts.map +1 -0
- package/dist/ListDetailLayout.js +153 -0
- package/dist/ListDetailLayout.js.map +1 -0
- package/dist/MarkdownEditor.d.ts.map +1 -1
- package/dist/MarkdownEditor.js +2 -1
- package/dist/MarkdownEditor.js.map +1 -1
- package/dist/MediaQuery.d.ts +1 -1
- package/dist/MediaQuery.d.ts.map +1 -1
- package/dist/MediaQuery.js +1 -1
- package/dist/MediaQuery.js.map +1 -1
- package/dist/OtpField.d.ts +60 -0
- package/dist/OtpField.d.ts.map +1 -0
- package/dist/OtpField.js +154 -0
- package/dist/OtpField.js.map +1 -0
- package/dist/ProvisionalConsentSigner.d.ts +21 -0
- package/dist/ProvisionalConsentSigner.d.ts.map +1 -0
- package/dist/ProvisionalConsentSigner.js +199 -0
- package/dist/ProvisionalConsentSigner.js.map +1 -0
- package/dist/ResponsiveBreakpoint.d.ts +5 -0
- package/dist/ResponsiveBreakpoint.d.ts.map +1 -1
- package/dist/ResponsiveBreakpoint.js +7 -0
- package/dist/ResponsiveBreakpoint.js.map +1 -1
- package/dist/SocialLoginButton.d.ts +10 -0
- package/dist/SocialLoginButton.d.ts.map +1 -1
- package/dist/SocialLoginButton.js +26 -8
- package/dist/SocialLoginButton.js.map +1 -1
- package/dist/SplitPage.d.ts +11 -0
- package/dist/SplitPage.d.ts.map +1 -1
- package/dist/SplitPage.js +11 -5
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.d.ts.map +1 -1
- package/dist/SplitPage.native.js +3 -1
- package/dist/SplitPage.native.js.map +1 -1
- package/dist/SyncStatusBanner.d.ts +7 -1
- package/dist/SyncStatusBanner.d.ts.map +1 -1
- package/dist/SyncStatusBanner.js +20 -4
- package/dist/SyncStatusBanner.js.map +1 -1
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TextField.js +44 -10
- package/dist/TextField.js.map +1 -1
- package/dist/fieldElements/FieldError.d.ts.map +1 -1
- package/dist/fieldElements/FieldError.js +1 -1
- package/dist/fieldElements/FieldError.js.map +1 -1
- package/dist/index.d.ts +19 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/lazyBoundaries/heavyOptionalExports.d.ts +3 -0
- package/dist/lazyBoundaries/heavyOptionalExports.d.ts.map +1 -1
- package/dist/lazyBoundaries/heavyOptionalExports.js +2 -0
- package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -1
- package/dist/login/LastUsedBadge.d.ts +14 -0
- package/dist/login/LastUsedBadge.d.ts.map +1 -0
- package/dist/login/LastUsedBadge.js +23 -0
- package/dist/login/LastUsedBadge.js.map +1 -0
- package/dist/login/LoginAccountCard.d.ts +38 -0
- package/dist/login/LoginAccountCard.d.ts.map +1 -0
- package/dist/login/LoginAccountCard.js +72 -0
- package/dist/login/LoginAccountCard.js.map +1 -0
- package/dist/login/LoginAccountList.d.ts +33 -0
- package/dist/login/LoginAccountList.d.ts.map +1 -0
- package/dist/login/LoginAccountList.js +30 -0
- package/dist/login/LoginAccountList.js.map +1 -0
- package/dist/login/LoginScreen.d.ts +4 -4
- package/dist/login/LoginScreen.d.ts.map +1 -1
- package/dist/login/LoginScreen.js +294 -13
- package/dist/login/LoginScreen.js.map +1 -1
- package/dist/login/OutlinePill.d.ts +28 -0
- package/dist/login/OutlinePill.d.ts.map +1 -0
- package/dist/login/OutlinePill.js +48 -0
- package/dist/login/OutlinePill.js.map +1 -0
- package/dist/login/TwoFactorChallengeScreen.d.ts +26 -0
- package/dist/login/TwoFactorChallengeScreen.d.ts.map +1 -0
- package/dist/login/TwoFactorChallengeScreen.js +139 -0
- package/dist/login/TwoFactorChallengeScreen.js.map +1 -0
- package/dist/login/loginMethods.d.ts +27 -0
- package/dist/login/loginMethods.d.ts.map +1 -0
- package/dist/login/loginMethods.js +37 -0
- package/dist/login/loginMethods.js.map +1 -0
- package/dist/login/loginTypes.d.ts +202 -5
- package/dist/login/loginTypes.d.ts.map +1 -1
- package/dist/pdfHtmlTemplate.d.ts +17 -0
- package/dist/pdfHtmlTemplate.d.ts.map +1 -1
- package/dist/pdfHtmlTemplate.js +78 -0
- package/dist/pdfHtmlTemplate.js.map +1 -1
- package/dist/security/AccountSecurityScreen.d.ts +10 -0
- package/dist/security/AccountSecurityScreen.d.ts.map +1 -0
- package/dist/security/AccountSecurityScreen.js +50 -0
- package/dist/security/AccountSecurityScreen.js.map +1 -0
- package/dist/security/LinkedAccountsCard.d.ts +32 -0
- package/dist/security/LinkedAccountsCard.d.ts.map +1 -0
- package/dist/security/LinkedAccountsCard.js +145 -0
- package/dist/security/LinkedAccountsCard.js.map +1 -0
- package/dist/security/PasskeysCard.d.ts +39 -0
- package/dist/security/PasskeysCard.d.ts.map +1 -0
- package/dist/security/PasskeysCard.js +168 -0
- package/dist/security/PasskeysCard.js.map +1 -0
- package/dist/security/PasswordCard.d.ts +32 -0
- package/dist/security/PasswordCard.d.ts.map +1 -0
- package/dist/security/PasswordCard.js +198 -0
- package/dist/security/PasswordCard.js.map +1 -0
- package/dist/security/SessionsCard.d.ts +39 -0
- package/dist/security/SessionsCard.d.ts.map +1 -0
- package/dist/security/SessionsCard.js +168 -0
- package/dist/security/SessionsCard.js.map +1 -0
- package/dist/security/TwoFactorSettingsCard.d.ts +55 -0
- package/dist/security/TwoFactorSettingsCard.d.ts.map +1 -0
- package/dist/security/TwoFactorSettingsCard.js +458 -0
- package/dist/security/TwoFactorSettingsCard.js.map +1 -0
- package/dist/security/securityMethods.d.ts +40 -0
- package/dist/security/securityMethods.d.ts.map +1 -0
- package/dist/security/securityMethods.js +66 -0
- package/dist/security/securityMethods.js.map +1 -0
- package/dist/security/securityTypes.d.ts +467 -0
- package/dist/security/securityTypes.d.ts.map +1 -0
- package/dist/security/securityTypes.js +2 -0
- package/dist/security/securityTypes.js.map +1 -0
- package/dist/security/userAgent.d.ts +26 -0
- package/dist/security/userAgent.d.ts.map +1 -0
- package/dist/security/userAgent.js +80 -0
- package/dist/security/userAgent.js.map +1 -0
- package/dist/signUp/OAuthButtons.d.ts +28 -5
- package/dist/signUp/OAuthButtons.d.ts.map +1 -1
- package/dist/signUp/OAuthButtons.js +44 -5
- package/dist/signUp/OAuthButtons.js.map +1 -1
- package/dist/signUp/SignUpScreen.d.ts.map +1 -1
- package/dist/signUp/SignUpScreen.js +50 -5
- package/dist/signUp/SignUpScreen.js.map +1 -1
- package/dist/signUp/signUpTypes.d.ts +21 -1
- package/dist/signUp/signUpTypes.d.ts.map +1 -1
- package/dist/useConsentForms.d.ts +9 -0
- package/dist/useConsentForms.d.ts.map +1 -1
- package/dist/useConsentForms.js +18 -0
- package/dist/useConsentForms.js.map +1 -1
- package/dist/useProvisionalConsent.d.ts +124 -0
- package/dist/useProvisionalConsent.d.ts.map +1 -0
- package/dist/useProvisionalConsent.js +79 -0
- package/dist/useProvisionalConsent.js.map +1 -0
- package/package.json +3 -2
- package/src/Accordion.test.tsx +5 -0
- package/src/Accordion.tsx +3 -8
- package/src/AreaChart.test.tsx +15 -0
- package/src/Avatar.test.tsx +8 -0
- package/src/Avatar.tsx +2 -0
- package/src/BarChart.test.tsx +15 -0
- package/src/Box.test.tsx +61 -1
- package/src/Box.tsx +44 -2
- package/src/Card.tsx +2 -2
- package/src/Common.ts +134 -7
- package/src/ConsentFormScreen.test.tsx +84 -0
- package/src/ConsentFormScreen.tsx +28 -4
- package/src/DateTimeField.tsx +5 -3
- package/src/DonutChart.test.tsx +15 -0
- package/src/Field.tsx +2 -0
- package/src/FilePickerButton.test.tsx +35 -0
- package/src/FormContainer.test.tsx +242 -0
- package/src/FormContainer.tsx +177 -0
- package/src/GPTChat.test.tsx +16 -0
- package/src/GPTChat.tsx +8 -2
- package/src/Heading.test.tsx +14 -0
- package/src/Heading.tsx +6 -1
- package/src/Icon.test.tsx +52 -1
- package/src/Icon.tsx +92 -3
- package/src/IconButton.test.tsx +85 -0
- package/src/LabeledCheckBox.test.tsx +45 -0
- package/src/LabeledCheckBox.tsx +89 -0
- package/src/ListDetailLayout.tsx +247 -0
- package/src/MarkdownEditor.tsx +2 -1
- package/src/MediaQuery.ts +1 -0
- package/src/OtpField.test.tsx +280 -0
- package/src/OtpField.tsx +307 -0
- package/src/ProvisionalConsentSigner.test.tsx +625 -0
- package/src/ProvisionalConsentSigner.tsx +423 -0
- package/src/ResponsiveBreakpoint.test.tsx +7 -0
- package/src/ResponsiveBreakpoint.tsx +14 -0
- package/src/RootImportRegression.test.tsx +3 -0
- package/src/SocialLoginButton.test.tsx +14 -0
- package/src/SocialLoginButton.tsx +51 -7
- package/src/SplitPage.native.tsx +3 -1
- package/src/SplitPage.tsx +11 -5
- package/src/SyncStatusBanner.test.tsx +61 -4
- package/src/SyncStatusBanner.tsx +29 -3
- package/src/TextField.test.tsx +150 -0
- package/src/TextField.tsx +66 -8
- package/src/__snapshots__/AddressField.test.tsx.snap +12 -0
- package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +15 -0
- package/src/__snapshots__/Avatar.test.tsx.snap +1 -0
- package/src/__snapshots__/CustomSelectField.test.tsx.snap +3 -0
- package/src/__snapshots__/EmailField.test.tsx.snap +6 -0
- package/src/__snapshots__/Field.test.tsx.snap +37 -0
- package/src/__snapshots__/HeightField.test.tsx.snap +2 -0
- package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +3 -0
- package/src/__snapshots__/NumberField.test.tsx.snap +3 -0
- package/src/__snapshots__/PhoneNumberField.test.tsx.snap +12 -0
- package/src/__snapshots__/Slider.test.tsx.snap +1 -0
- package/src/__snapshots__/SocialLoginButton.test.tsx.snap +43 -22
- package/src/__snapshots__/TapToEdit.test.tsx.snap +3 -0
- package/src/__snapshots__/TextArea.test.tsx.snap +17 -1
- package/src/__snapshots__/TextField.test.tsx.snap +19 -2
- package/src/__snapshots__/TypedSignatureField.test.tsx.snap +3 -0
- package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +18 -0
- package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +12 -0
- package/src/bunSetup.ts +13 -1
- package/src/fieldElements/FieldError.tsx +1 -0
- package/src/fieldElements/__snapshots__/FieldError.test.tsx.snap +2 -0
- package/src/index.tsx +42 -1
- package/src/isolated/ListDetailLayout.isolated.tsx +634 -0
- package/src/lazyBoundaries/heavyOptionalExports.tsx +7 -0
- package/src/login/LastUsedBadge.tsx +40 -0
- package/src/login/LoginAccountCard.tsx +205 -0
- package/src/login/LoginAccountList.tsx +115 -0
- package/src/login/LoginScreen.test.tsx +837 -1
- package/src/login/LoginScreen.tsx +674 -91
- package/src/login/OutlinePill.tsx +110 -0
- package/src/login/TwoFactorChallengeScreen.test.tsx +376 -0
- package/src/login/TwoFactorChallengeScreen.tsx +307 -0
- package/src/login/__snapshots__/LoginScreen.test.tsx.snap +1454 -334
- package/src/login/loginMethods.test.ts +53 -0
- package/src/login/loginMethods.ts +60 -0
- package/src/login/loginTypes.ts +208 -5
- package/src/pdfHtmlTemplate.test.ts +243 -4
- package/src/pdfHtmlTemplate.ts +93 -0
- package/src/security/AccountSecurityScreen.test.tsx +262 -0
- package/src/security/AccountSecurityScreen.tsx +156 -0
- package/src/security/LinkedAccountsCard.test.tsx +371 -0
- package/src/security/LinkedAccountsCard.tsx +297 -0
- package/src/security/PasskeysCard.test.tsx +378 -0
- package/src/security/PasskeysCard.tsx +371 -0
- package/src/security/PasswordCard.test.tsx +445 -0
- package/src/security/PasswordCard.tsx +342 -0
- package/src/security/SessionsCard.test.tsx +349 -0
- package/src/security/SessionsCard.tsx +362 -0
- package/src/security/TwoFactorSettingsCard.test.tsx +700 -0
- package/src/security/TwoFactorSettingsCard.tsx +872 -0
- package/src/security/securityMethods.test.ts +101 -0
- package/src/security/securityMethods.ts +104 -0
- package/src/security/securityTypes.ts +480 -0
- package/src/security/userAgent.test.ts +119 -0
- package/src/security/userAgent.ts +102 -0
- package/src/signUp/OAuthButtons.test.tsx +27 -0
- package/src/signUp/OAuthButtons.tsx +153 -19
- package/src/signUp/SignUpScreen.test.tsx +170 -1
- package/src/signUp/SignUpScreen.tsx +87 -25
- package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +22 -11
- package/src/signUp/signUpTypes.ts +23 -1
- package/src/useConsentForms.test.ts +37 -1
- package/src/useConsentForms.ts +25 -0
- package/src/useProvisionalConsent.test.ts +256 -0
- package/src/useProvisionalConsent.ts +218 -0
|
@@ -1,18 +1,190 @@
|
|
|
1
|
-
import type {FC} from "react";
|
|
2
|
-
import {useCallback, useState} from "react";
|
|
1
|
+
import type {FC, ReactElement, ReactNode} from "react";
|
|
2
|
+
import {useCallback, useEffect, useRef, useState} from "react";
|
|
3
|
+
import {Platform, Pressable, type TextInput, View} from "react-native";
|
|
3
4
|
|
|
5
|
+
import {Avatar} from "../Avatar";
|
|
4
6
|
import {Box} from "../Box";
|
|
5
7
|
import {Button} from "../Button";
|
|
8
|
+
import type {IconName, TextFieldProps} from "../Common";
|
|
9
|
+
import {FormContainer, type FormContainerHandle} from "../FormContainer";
|
|
6
10
|
import {Heading} from "../Heading";
|
|
11
|
+
import {Icon} from "../Icon";
|
|
7
12
|
import {Page} from "../Page";
|
|
8
13
|
import {OAuthButtons} from "../signUp/OAuthButtons";
|
|
9
14
|
import {Text} from "../Text";
|
|
10
15
|
import {TextField} from "../TextField";
|
|
11
|
-
import
|
|
16
|
+
import {useTheme} from "../Theme";
|
|
17
|
+
import {LastUsedPill} from "./LastUsedBadge";
|
|
18
|
+
import {LoginAccountList} from "./LoginAccountList";
|
|
19
|
+
import {getLoginMethodLabels, withLastUsedLabel} from "./loginMethods";
|
|
20
|
+
import type {
|
|
21
|
+
LoginAccountOption,
|
|
22
|
+
LoginFieldConfig,
|
|
23
|
+
LoginNotice,
|
|
24
|
+
LoginScreenProps,
|
|
25
|
+
} from "./loginTypes";
|
|
26
|
+
import {OutlinePill} from "./OutlinePill";
|
|
27
|
+
|
|
28
|
+
const DEFAULT_LAST_USED_LABEL = "Last used";
|
|
29
|
+
const DEFAULT_SIGN_UP_LINK = "Create an account";
|
|
30
|
+
const DEFAULT_FORGOT_PASSWORD = "Forgot password?";
|
|
31
|
+
|
|
32
|
+
const isEmailField = (field: LoginFieldConfig): boolean => {
|
|
33
|
+
return field.type === "email" || field.name === "email";
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const isPasswordField = (field: LoginFieldConfig): boolean => {
|
|
37
|
+
return field.type === "password" || field.name === "password";
|
|
38
|
+
};
|
|
12
39
|
|
|
13
40
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
41
|
+
* The autofill hint for a field: passkey autofill on a web email field, else the field's own hint,
|
|
42
|
+
* else "username" for the email field and "current-password" for password fields, so password
|
|
43
|
+
* managers pair the two.
|
|
44
|
+
*/
|
|
45
|
+
const getFieldAutoComplete = ({
|
|
46
|
+
field,
|
|
47
|
+
passkeyAutofill,
|
|
48
|
+
}: {
|
|
49
|
+
field: LoginFieldConfig;
|
|
50
|
+
passkeyAutofill: boolean;
|
|
51
|
+
}): TextFieldProps["autoComplete"] => {
|
|
52
|
+
if (passkeyAutofill && Platform.OS === "web" && isEmailField(field)) {
|
|
53
|
+
return "username webauthn";
|
|
54
|
+
}
|
|
55
|
+
if (field.autoComplete) {
|
|
56
|
+
return field.autoComplete;
|
|
57
|
+
}
|
|
58
|
+
if (isEmailField(field)) {
|
|
59
|
+
return "username";
|
|
60
|
+
}
|
|
61
|
+
return field.type === "password" ? "current-password" : undefined;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** A labelled rule between two groups of sign-in methods. */
|
|
65
|
+
const MethodDivider: FC<{text: string}> = ({text}) => {
|
|
66
|
+
const {theme} = useTheme();
|
|
67
|
+
if (!theme) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return (
|
|
71
|
+
<View style={{alignItems: "center", flexDirection: "row", gap: 12, width: "100%"}}>
|
|
72
|
+
<View style={{backgroundColor: theme.border.default, flex: 1, height: 1}} />
|
|
73
|
+
<Text color="secondaryLight" size="sm">
|
|
74
|
+
{text}
|
|
75
|
+
</Text>
|
|
76
|
+
<View style={{backgroundColor: theme.border.default, flex: 1, height: 1}} />
|
|
77
|
+
</View>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const TextLink: FC<{
|
|
82
|
+
text: string;
|
|
83
|
+
onPress: () => void;
|
|
84
|
+
testID: string;
|
|
85
|
+
disabled?: boolean;
|
|
86
|
+
color?: "link" | "secondaryLight";
|
|
87
|
+
}> = ({text, onPress, testID, disabled = false, color = "link"}) => {
|
|
88
|
+
return (
|
|
89
|
+
<Pressable
|
|
90
|
+
accessibilityRole="link"
|
|
91
|
+
accessibilityState={{disabled}}
|
|
92
|
+
disabled={disabled}
|
|
93
|
+
onPress={onPress}
|
|
94
|
+
testID={testID}
|
|
95
|
+
>
|
|
96
|
+
<Text bold color={color} size="sm">
|
|
97
|
+
{text}
|
|
98
|
+
</Text>
|
|
99
|
+
</Pressable>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const NoticeBox: FC<{
|
|
104
|
+
notice: LoginNotice;
|
|
105
|
+
onAction: () => void;
|
|
106
|
+
onDismiss?: () => void;
|
|
107
|
+
testID: string;
|
|
108
|
+
}> = ({notice, onAction, onDismiss, testID}) => {
|
|
109
|
+
const {theme} = useTheme();
|
|
110
|
+
if (!theme) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const tone = notice.tone;
|
|
114
|
+
const isInfo = tone === "info";
|
|
115
|
+
const fill =
|
|
116
|
+
tone === "error"
|
|
117
|
+
? theme.surface.errorLight
|
|
118
|
+
: tone === "warning"
|
|
119
|
+
? theme.surface.warningLight
|
|
120
|
+
: theme.surface.secondaryExtraLight;
|
|
121
|
+
const border =
|
|
122
|
+
tone === "error"
|
|
123
|
+
? theme.border.error
|
|
124
|
+
: tone === "warning"
|
|
125
|
+
? theme.border.warning
|
|
126
|
+
: theme.surface.secondaryLight;
|
|
127
|
+
const iconName: IconName =
|
|
128
|
+
tone === "error"
|
|
129
|
+
? "circle-exclamation"
|
|
130
|
+
: tone === "warning"
|
|
131
|
+
? "triangle-exclamation"
|
|
132
|
+
: "circle-info";
|
|
133
|
+
const iconColor = tone === "error" ? "error" : tone === "warning" ? "warning" : "secondaryDark";
|
|
134
|
+
const textColor = isInfo ? "secondaryDark" : "primary";
|
|
135
|
+
return (
|
|
136
|
+
<View role={isInfo ? "status" : "alert"} style={{width: "100%"}} testID={testID}>
|
|
137
|
+
<View
|
|
138
|
+
style={{
|
|
139
|
+
backgroundColor: fill,
|
|
140
|
+
borderColor: border,
|
|
141
|
+
borderRadius: theme.radius.full,
|
|
142
|
+
borderWidth: 1,
|
|
143
|
+
gap: 12,
|
|
144
|
+
paddingHorizontal: 16,
|
|
145
|
+
paddingVertical: 12,
|
|
146
|
+
width: "100%",
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
<Box alignItems="start" direction="row" gap={3}>
|
|
150
|
+
<Icon color={iconColor} iconName={iconName} size="lg" />
|
|
151
|
+
<Box flex="shrink" gap={1}>
|
|
152
|
+
{Boolean(notice.title) && (
|
|
153
|
+
<Text bold color={textColor}>
|
|
154
|
+
{notice.title}
|
|
155
|
+
</Text>
|
|
156
|
+
)}
|
|
157
|
+
<Text color={textColor}>{notice.text}</Text>
|
|
158
|
+
</Box>
|
|
159
|
+
{isInfo && Boolean(onDismiss) && (
|
|
160
|
+
<Pressable
|
|
161
|
+
accessibilityLabel="Dismiss"
|
|
162
|
+
accessibilityRole="button"
|
|
163
|
+
onPress={onDismiss}
|
|
164
|
+
testID={`${testID}-dismiss`}
|
|
165
|
+
>
|
|
166
|
+
<Icon color="secondaryDark" iconName="xmark" size="md" />
|
|
167
|
+
</Pressable>
|
|
168
|
+
)}
|
|
169
|
+
</Box>
|
|
170
|
+
{Boolean(notice.actionLabel) && (
|
|
171
|
+
<Box alignItems="start">
|
|
172
|
+
<Button
|
|
173
|
+
onClick={onAction}
|
|
174
|
+
testID={`${testID}-action`}
|
|
175
|
+
text={notice.actionLabel!}
|
|
176
|
+
variant="outline"
|
|
177
|
+
/>
|
|
178
|
+
</Box>
|
|
179
|
+
)}
|
|
180
|
+
</View>
|
|
181
|
+
</View>
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* A configurable login screen. It is presentational: it renders the methods and accounts it is
|
|
187
|
+
* given and reports presses through callbacks.
|
|
16
188
|
*
|
|
17
189
|
* @example
|
|
18
190
|
* ```tsx
|
|
@@ -27,9 +199,9 @@ import type {LoginScreenProps} from "./loginTypes";
|
|
|
27
199
|
* oauthProviders={[
|
|
28
200
|
* {provider: "google", onPress: () => signInWithSocial("google")},
|
|
29
201
|
* ]}
|
|
202
|
+
* lastUsedMethod="google"
|
|
203
|
+
* onPasskeyPress={signInWithPasskey}
|
|
30
204
|
* onSignUpPress={() => router.push("/signup")}
|
|
31
|
-
* onForgotPasswordPress={() => router.push("/forgot-password")}
|
|
32
|
-
// or onForgotPassword={() => router.push("/forgot-password")}
|
|
33
205
|
* />
|
|
34
206
|
* ```
|
|
35
207
|
*/
|
|
@@ -37,24 +209,65 @@ export const LoginScreen: FC<LoginScreenProps> = ({
|
|
|
37
209
|
fields,
|
|
38
210
|
onSubmit,
|
|
39
211
|
oauthProviders,
|
|
212
|
+
genericProviders,
|
|
40
213
|
logo,
|
|
41
|
-
title
|
|
214
|
+
title,
|
|
215
|
+
subtitle,
|
|
42
216
|
loading = false,
|
|
43
217
|
error,
|
|
44
|
-
|
|
218
|
+
passwordError,
|
|
219
|
+
signUpLinkText = DEFAULT_SIGN_UP_LINK,
|
|
45
220
|
onSignUpPress,
|
|
46
|
-
forgotPasswordText =
|
|
221
|
+
forgotPasswordText = DEFAULT_FORGOT_PASSWORD,
|
|
47
222
|
onForgotPasswordPress,
|
|
48
223
|
onForgotPassword,
|
|
224
|
+
lastUsedMethod,
|
|
225
|
+
lastUsedLabel = DEFAULT_LAST_USED_LABEL,
|
|
226
|
+
currentSessions,
|
|
227
|
+
rememberedAccounts,
|
|
228
|
+
onContinue,
|
|
229
|
+
onForget,
|
|
230
|
+
continuingAccount,
|
|
231
|
+
onCancelContinue,
|
|
232
|
+
initialMethodsExpanded = false,
|
|
233
|
+
initialAccountsEditing = false,
|
|
234
|
+
onPasskeyPress,
|
|
235
|
+
passkeyButtonText = "Sign in with a passkey",
|
|
236
|
+
passkeyAutofill = false,
|
|
237
|
+
notice,
|
|
238
|
+
initialValues,
|
|
49
239
|
testID = "login-screen",
|
|
50
240
|
}) => {
|
|
51
241
|
const [formValues, setFormValues] = useState<Record<string, string>>(() => {
|
|
52
242
|
const initial: Record<string, string> = {};
|
|
53
243
|
for (const field of fields) {
|
|
54
|
-
initial[field.name] = "";
|
|
244
|
+
initial[field.name] = initialValues?.[field.name] ?? "";
|
|
55
245
|
}
|
|
56
246
|
return initial;
|
|
57
247
|
});
|
|
248
|
+
const [methodsExpanded, setMethodsExpanded] = useState(initialMethodsExpanded);
|
|
249
|
+
const [dismissedNotice, setDismissedNotice] = useState<string | undefined>();
|
|
250
|
+
const [pendingFocus, setPendingFocus] = useState<string | undefined>();
|
|
251
|
+
|
|
252
|
+
// Applies a new initialValues object over the form; the first render already used it.
|
|
253
|
+
const appliedInitialValues = useRef(initialValues);
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
if (!initialValues || appliedInitialValues.current === initialValues) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
appliedInitialValues.current = initialValues;
|
|
259
|
+
setFormValues((prev) => ({...prev, ...initialValues}));
|
|
260
|
+
}, [initialValues]);
|
|
261
|
+
|
|
262
|
+
const noticeText = notice?.text;
|
|
263
|
+
// A replaced notice is shown again. Dismiss only hides the notice currently on screen.
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
if (noticeText === undefined) {
|
|
266
|
+
setDismissedNotice(undefined);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
setDismissedNotice(undefined);
|
|
270
|
+
}, [noticeText]);
|
|
58
271
|
|
|
59
272
|
const onForgotPasswordAction = onForgotPasswordPress ?? onForgotPassword;
|
|
60
273
|
|
|
@@ -62,103 +275,473 @@ export const LoginScreen: FC<LoginScreenProps> = ({
|
|
|
62
275
|
setFormValues((prev) => ({...prev, [fieldName]: value}));
|
|
63
276
|
}, []);
|
|
64
277
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
278
|
+
const formRef = useRef<FormContainerHandle>(null);
|
|
279
|
+
const inputRefs = useRef<Record<string, TextInput | null>>({});
|
|
280
|
+
const isSubmittingRef = useRef(false);
|
|
281
|
+
|
|
282
|
+
const handlePasskeyPress = useCallback(async (): Promise<void> => {
|
|
283
|
+
await onPasskeyPress?.();
|
|
284
|
+
}, [onPasskeyPress]);
|
|
68
285
|
|
|
286
|
+
const passwordField = fields.find((field) => isPasswordField(field));
|
|
69
287
|
const requiredFieldsFilled = fields
|
|
70
|
-
.filter((
|
|
71
|
-
.every((
|
|
288
|
+
.filter((field) => field.required)
|
|
289
|
+
.every((field) => {
|
|
290
|
+
if (continuingAccount?.email && isEmailField(field)) {
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
return (formValues[field.name] ?? "").trim().length > 0;
|
|
294
|
+
});
|
|
72
295
|
|
|
73
296
|
const isSubmitDisabled = loading || !requiredFieldsFilled;
|
|
74
297
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
298
|
+
const handleSubmit = useCallback(async (): Promise<void> => {
|
|
299
|
+
if (isSubmitDisabled || isSubmittingRef.current) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
isSubmittingRef.current = true;
|
|
303
|
+
try {
|
|
304
|
+
const values = {...formValues};
|
|
305
|
+
if (continuingAccount?.email) {
|
|
306
|
+
values.email = continuingAccount.email;
|
|
307
|
+
}
|
|
308
|
+
await onSubmit(values);
|
|
309
|
+
} finally {
|
|
310
|
+
isSubmittingRef.current = false;
|
|
311
|
+
}
|
|
312
|
+
}, [continuingAccount?.email, formValues, isSubmitDisabled, onSubmit]);
|
|
88
313
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
314
|
+
const requestSubmit = useCallback(async (): Promise<void> => {
|
|
315
|
+
if (isSubmitDisabled) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
await formRef.current?.requestSubmit();
|
|
319
|
+
}, [isSubmitDisabled]);
|
|
92
320
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
autoComplete={field.autoComplete}
|
|
97
|
-
disabled={loading}
|
|
98
|
-
id={`${testID}-${field.name}-input`}
|
|
99
|
-
key={field.name}
|
|
100
|
-
onChange={(value: string) => handleFieldChange(field.name, value)}
|
|
101
|
-
placeholder={field.placeholder ?? field.label}
|
|
102
|
-
testID={`${testID}-${field.name}-input`}
|
|
103
|
-
title={field.label}
|
|
104
|
-
type={
|
|
105
|
-
field.type === "email" ? "email" : field.type === "password" ? "password" : "text"
|
|
106
|
-
}
|
|
107
|
-
value={formValues[field.name]}
|
|
108
|
-
/>
|
|
109
|
-
))}
|
|
321
|
+
const focusField = useCallback((fieldName: string): void => {
|
|
322
|
+
inputRefs.current[fieldName]?.focus();
|
|
323
|
+
}, []);
|
|
110
324
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
325
|
+
// The password step opens with the password field focused so the user can type at once.
|
|
326
|
+
useEffect(() => {
|
|
327
|
+
if (!continuingAccount) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
focusField("password");
|
|
331
|
+
}, [continuingAccount, focusField]);
|
|
116
332
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
333
|
+
// An account-not-linked action expands the methods, then focuses email once the field is mounted.
|
|
334
|
+
useEffect(() => {
|
|
335
|
+
if (pendingFocus !== "email") {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
const emailInput = inputRefs.current.email;
|
|
339
|
+
if (!emailInput) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
emailInput.focus();
|
|
343
|
+
setPendingFocus(undefined);
|
|
344
|
+
}, [pendingFocus]);
|
|
127
345
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
346
|
+
const brandedProviders = oauthProviders ?? [];
|
|
347
|
+
const otherProviders = genericProviders ?? [];
|
|
348
|
+
const hasProviders = brandedProviders.length > 0 || otherProviders.length > 0;
|
|
349
|
+
const hasPasskey = Boolean(onPasskeyPress);
|
|
350
|
+
const hasMethods = hasProviders || hasPasskey;
|
|
351
|
+
const hasForm = fields.length > 0;
|
|
352
|
+
const isProviderLastUsed =
|
|
353
|
+
Boolean(lastUsedMethod) &&
|
|
354
|
+
(brandedProviders.some((config) => config.provider === lastUsedMethod) ||
|
|
355
|
+
otherProviders.some((config) => config.id === lastUsedMethod));
|
|
356
|
+
const isPasskeyLastUsed = lastUsedMethod === "passkey" && hasPasskey;
|
|
357
|
+
const isEmailLastUsed = lastUsedMethod === "email";
|
|
139
358
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
)
|
|
359
|
+
const accountEntries =
|
|
360
|
+
onContinue === undefined
|
|
361
|
+
? []
|
|
362
|
+
: [
|
|
363
|
+
...(currentSessions ?? []).map((account) => ({
|
|
364
|
+
account,
|
|
365
|
+
method: getLoginMethodLabels({
|
|
366
|
+
genericProviders: otherProviders,
|
|
367
|
+
method: account.method,
|
|
368
|
+
}),
|
|
369
|
+
source: "session" as const,
|
|
370
|
+
})),
|
|
371
|
+
...(rememberedAccounts ?? []).map((account) => ({
|
|
372
|
+
account,
|
|
373
|
+
method: getLoginMethodLabels({
|
|
374
|
+
genericProviders: otherProviders,
|
|
375
|
+
method: account.method,
|
|
376
|
+
}),
|
|
377
|
+
source: "remembered" as const,
|
|
378
|
+
})),
|
|
379
|
+
];
|
|
380
|
+
const hasAccounts = accountEntries.length > 0;
|
|
381
|
+
const showMethods = !hasAccounts || methodsExpanded;
|
|
382
|
+
const resolvedTitle = title ?? (hasAccounts ? "Welcome back" : "Sign in");
|
|
383
|
+
const resolvedSubtitle =
|
|
384
|
+
subtitle ?? (hasAccounts ? "Pick up where you left off." : "Choose how you want to sign in.");
|
|
385
|
+
|
|
386
|
+
const visibleNotice =
|
|
387
|
+
notice && dismissedNotice !== `${notice.tone}:${notice.title ?? ""}:${notice.text}`
|
|
388
|
+
? notice
|
|
389
|
+
: undefined;
|
|
390
|
+
const banner: LoginNotice | undefined = visibleNotice
|
|
391
|
+
? visibleNotice
|
|
392
|
+
: error
|
|
393
|
+
? {text: error, tone: "error"}
|
|
394
|
+
: undefined;
|
|
395
|
+
|
|
396
|
+
const handleNoticeAction = useCallback((): void => {
|
|
397
|
+
if (notice?.focusMethod) {
|
|
398
|
+
setMethodsExpanded(true);
|
|
399
|
+
setPendingFocus(notice.focusMethod);
|
|
400
|
+
}
|
|
401
|
+
void notice?.onAction?.();
|
|
402
|
+
}, [notice]);
|
|
152
403
|
|
|
153
|
-
|
|
154
|
-
|
|
404
|
+
const handleDismissNotice = useCallback((): void => {
|
|
405
|
+
if (!notice) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
setDismissedNotice(`${notice.tone}:${notice.title ?? ""}:${notice.text}`);
|
|
409
|
+
}, [notice]);
|
|
410
|
+
|
|
411
|
+
const expandMethods = useCallback((): void => {
|
|
412
|
+
setMethodsExpanded(true);
|
|
413
|
+
}, []);
|
|
414
|
+
|
|
415
|
+
const handleCancelContinue = useCallback((): void => {
|
|
416
|
+
onCancelContinue?.();
|
|
417
|
+
}, [onCancelContinue]);
|
|
418
|
+
|
|
419
|
+
const renderPasskey = (): ReactElement => (
|
|
420
|
+
<OutlinePill
|
|
421
|
+
accessibilityLabel={
|
|
422
|
+
isPasskeyLastUsed
|
|
423
|
+
? withLastUsedLabel({label: passkeyButtonText, lastUsedLabel})
|
|
424
|
+
: passkeyButtonText
|
|
425
|
+
}
|
|
426
|
+
disabled={loading}
|
|
427
|
+
icon={<Icon color={loading ? "secondaryLight" : "primary"} iconName="key" size="md" />}
|
|
428
|
+
lastUsedLabel={isPasskeyLastUsed ? lastUsedLabel : undefined}
|
|
429
|
+
lastUsedTestID={`${testID}-last-used-passkey`}
|
|
430
|
+
onPress={handlePasskeyPress}
|
|
431
|
+
testID={`${testID}-passkey-button`}
|
|
432
|
+
text={passkeyButtonText}
|
|
433
|
+
/>
|
|
434
|
+
);
|
|
435
|
+
|
|
436
|
+
const renderMethodStack = (): ReactElement => (
|
|
437
|
+
<Box gap={3} width="100%">
|
|
438
|
+
{isPasskeyLastUsed && renderPasskey()}
|
|
439
|
+
{hasProviders && (
|
|
440
|
+
<OAuthButtons
|
|
441
|
+
appearance="pill"
|
|
442
|
+
disabled={loading}
|
|
443
|
+
dividerPosition="none"
|
|
444
|
+
genericProviders={otherProviders}
|
|
445
|
+
lastUsed={
|
|
446
|
+
isProviderLastUsed
|
|
447
|
+
? {
|
|
448
|
+
label: lastUsedLabel,
|
|
449
|
+
provider: lastUsedMethod!,
|
|
450
|
+
testID: `${testID}-last-used-${lastUsedMethod}`,
|
|
451
|
+
}
|
|
452
|
+
: undefined
|
|
453
|
+
}
|
|
454
|
+
providers={brandedProviders}
|
|
455
|
+
testID={`${testID}-oauth`}
|
|
456
|
+
/>
|
|
457
|
+
)}
|
|
458
|
+
{hasPasskey && !isPasskeyLastUsed && renderPasskey()}
|
|
459
|
+
</Box>
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
const renderField = (
|
|
463
|
+
field: LoginFieldConfig,
|
|
464
|
+
index: number,
|
|
465
|
+
visibleFields: LoginFieldConfig[]
|
|
466
|
+
): ReactElement => {
|
|
467
|
+
const nextField = visibleFields[index + 1];
|
|
468
|
+
const emailLastUsed = isEmailLastUsed && isEmailField(field);
|
|
469
|
+
const showForgot = isPasswordField(field) && Boolean(onForgotPasswordAction);
|
|
470
|
+
const fieldError = isPasswordField(field) ? passwordError : undefined;
|
|
471
|
+
const placeholder = isPasswordField(field)
|
|
472
|
+
? undefined
|
|
473
|
+
: isEmailField(field)
|
|
474
|
+
? (field.placeholder ?? "you@example.com")
|
|
475
|
+
: (field.placeholder ?? field.label);
|
|
476
|
+
return (
|
|
477
|
+
<Box gap={2} key={field.name} width="100%">
|
|
478
|
+
<Box alignItems="center" direction="row" justifyContent="between" width="100%">
|
|
479
|
+
<Box alignItems="center" direction="row" gap={2}>
|
|
480
|
+
<Text bold>{field.label}</Text>
|
|
481
|
+
{emailLastUsed && (
|
|
482
|
+
<LastUsedPill label={lastUsedLabel} testID={`${testID}-last-used-email`} />
|
|
483
|
+
)}
|
|
484
|
+
</Box>
|
|
485
|
+
{showForgot && (
|
|
486
|
+
<TextLink
|
|
155
487
|
disabled={loading}
|
|
156
|
-
|
|
157
|
-
testID={`${testID}-
|
|
488
|
+
onPress={onForgotPasswordAction!}
|
|
489
|
+
testID={`${testID}-forgot-password`}
|
|
490
|
+
text={forgotPasswordText}
|
|
158
491
|
/>
|
|
159
492
|
)}
|
|
160
493
|
</Box>
|
|
494
|
+
<TextField
|
|
495
|
+
accessibilityLabel={
|
|
496
|
+
emailLastUsed ? withLastUsedLabel({label: field.label, lastUsedLabel}) : field.label
|
|
497
|
+
}
|
|
498
|
+
autoComplete={getFieldAutoComplete({field, passkeyAutofill})}
|
|
499
|
+
blurOnSubmit={!nextField}
|
|
500
|
+
disabled={loading}
|
|
501
|
+
errorPosition="below"
|
|
502
|
+
errorText={fieldError}
|
|
503
|
+
id={`${testID}-${field.name}-input`}
|
|
504
|
+
inputRef={(ref) => {
|
|
505
|
+
inputRefs.current[field.name] = ref;
|
|
506
|
+
}}
|
|
507
|
+
onChange={(value: string) => handleFieldChange(field.name, value)}
|
|
508
|
+
onEnter={nextField ? () => focusField(nextField.name) : requestSubmit}
|
|
509
|
+
placeholder={placeholder}
|
|
510
|
+
returnKeyType={nextField ? "next" : "go"}
|
|
511
|
+
testID={`${testID}-${field.name}-input`}
|
|
512
|
+
type={field.type === "email" ? "email" : field.type === "password" ? "password" : "text"}
|
|
513
|
+
value={formValues[field.name]}
|
|
514
|
+
/>
|
|
515
|
+
</Box>
|
|
516
|
+
);
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
const renderFooter = (): ReactNode => {
|
|
520
|
+
if (!onSignUpPress) {
|
|
521
|
+
return null;
|
|
522
|
+
}
|
|
523
|
+
return (
|
|
524
|
+
<Box alignItems="center" direction="row" gap={1} justifyContent="center" paddingY={2}>
|
|
525
|
+
<Text color="secondaryLight">New here?</Text>
|
|
526
|
+
<Pressable
|
|
527
|
+
accessibilityRole="link"
|
|
528
|
+
disabled={loading}
|
|
529
|
+
onPress={onSignUpPress}
|
|
530
|
+
testID={`${testID}-signup-link`}
|
|
531
|
+
>
|
|
532
|
+
<Text bold color="link">
|
|
533
|
+
{signUpLinkText}
|
|
534
|
+
</Text>
|
|
535
|
+
</Pressable>
|
|
536
|
+
</Box>
|
|
537
|
+
);
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
const renderContinueStep = (): ReactElement => {
|
|
541
|
+
const account = continuingAccount!;
|
|
542
|
+
const who = account.name ?? account.email ?? "this account";
|
|
543
|
+
return (
|
|
544
|
+
<Box gap={6} width="100%">
|
|
545
|
+
<Pressable
|
|
546
|
+
accessibilityRole="link"
|
|
547
|
+
disabled={loading}
|
|
548
|
+
onPress={handleCancelContinue}
|
|
549
|
+
testID={`${testID}-continue-back`}
|
|
550
|
+
>
|
|
551
|
+
<Box alignItems="center" direction="row" gap={1}>
|
|
552
|
+
<Icon color="link" iconName="chevron-left" size="md" />
|
|
553
|
+
<Text bold color="link">
|
|
554
|
+
All sign-in options
|
|
555
|
+
</Text>
|
|
556
|
+
</Box>
|
|
557
|
+
</Pressable>
|
|
558
|
+
<Heading size="xl">Enter your password</Heading>
|
|
559
|
+
<IdentityChip
|
|
560
|
+
account={account}
|
|
561
|
+
disabled={loading}
|
|
562
|
+
onNotYou={handleCancelContinue}
|
|
563
|
+
testID={`${testID}-continue-not-you`}
|
|
564
|
+
who={who}
|
|
565
|
+
/>
|
|
566
|
+
<FormContainer
|
|
567
|
+
accessibilityLabel="Enter your password"
|
|
568
|
+
gap={4}
|
|
569
|
+
onSubmit={handleSubmit}
|
|
570
|
+
ref={formRef}
|
|
571
|
+
testID={`${testID}-form`}
|
|
572
|
+
width="100%"
|
|
573
|
+
>
|
|
574
|
+
<View
|
|
575
|
+
accessibilityElementsHidden
|
|
576
|
+
importantForAccessibility="no-hide-descendants"
|
|
577
|
+
style={{height: 0, overflow: "hidden", width: "100%"}}
|
|
578
|
+
>
|
|
579
|
+
<TextField
|
|
580
|
+
accessibilityLabel="Email"
|
|
581
|
+
autoComplete="username"
|
|
582
|
+
onChange={() => {}}
|
|
583
|
+
testID={`${testID}-email-input`}
|
|
584
|
+
type="email"
|
|
585
|
+
value={account.email ?? ""}
|
|
586
|
+
/>
|
|
587
|
+
</View>
|
|
588
|
+
{passwordField && renderField(passwordField, 0, [passwordField])}
|
|
589
|
+
<Button
|
|
590
|
+
disabled={isSubmitDisabled}
|
|
591
|
+
fullWidth
|
|
592
|
+
loading={loading}
|
|
593
|
+
onClick={requestSubmit}
|
|
594
|
+
testID={`${testID}-submit-button`}
|
|
595
|
+
text={loading ? "Signing in" : "Sign in"}
|
|
596
|
+
/>
|
|
597
|
+
</FormContainer>
|
|
161
598
|
</Box>
|
|
599
|
+
);
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
const visibleFields = continuingAccount ? [] : fields;
|
|
603
|
+
|
|
604
|
+
return (
|
|
605
|
+
<Page navigation={undefined}>
|
|
606
|
+
<View
|
|
607
|
+
accessibilityState={{busy: loading}}
|
|
608
|
+
aria-busy={loading}
|
|
609
|
+
style={{alignItems: "center", flexGrow: 1, width: "100%"}}
|
|
610
|
+
>
|
|
611
|
+
<Box alignSelf="center" flex="grow" maxWidth={400} padding={4} testID={testID} width="100%">
|
|
612
|
+
<Box flex="grow" gap={5} width="100%">
|
|
613
|
+
{Boolean(logo) && <Box>{logo}</Box>}
|
|
614
|
+
{!continuingAccount && (
|
|
615
|
+
<Box gap={1}>
|
|
616
|
+
<Heading size="xl" testID={`${testID}-title`}>
|
|
617
|
+
{resolvedTitle}
|
|
618
|
+
</Heading>
|
|
619
|
+
<Text color="secondaryLight" testID={`${testID}-subtitle`}>
|
|
620
|
+
{resolvedSubtitle}
|
|
621
|
+
</Text>
|
|
622
|
+
</Box>
|
|
623
|
+
)}
|
|
624
|
+
{Boolean(banner) && (
|
|
625
|
+
<NoticeBox
|
|
626
|
+
notice={banner!}
|
|
627
|
+
onAction={handleNoticeAction}
|
|
628
|
+
onDismiss={banner?.tone === "info" ? handleDismissNotice : undefined}
|
|
629
|
+
testID={
|
|
630
|
+
banner?.tone === "error" && !visibleNotice
|
|
631
|
+
? `${testID}-error`
|
|
632
|
+
: `${testID}-notice`
|
|
633
|
+
}
|
|
634
|
+
/>
|
|
635
|
+
)}
|
|
636
|
+
{continuingAccount ? (
|
|
637
|
+
renderContinueStep()
|
|
638
|
+
) : (
|
|
639
|
+
<Box gap={5} width="100%">
|
|
640
|
+
{hasAccounts && (
|
|
641
|
+
<LoginAccountList
|
|
642
|
+
accounts={accountEntries}
|
|
643
|
+
disabled={loading}
|
|
644
|
+
initialEditing={initialAccountsEditing}
|
|
645
|
+
lastUsedLabel={lastUsedLabel}
|
|
646
|
+
lastUsedMethod={lastUsedMethod}
|
|
647
|
+
onContinue={onContinue!}
|
|
648
|
+
onForget={onForget}
|
|
649
|
+
testID={testID}
|
|
650
|
+
/>
|
|
651
|
+
)}
|
|
652
|
+
{hasAccounts && (hasMethods || hasForm) && !showMethods && (
|
|
653
|
+
<Button
|
|
654
|
+
disabled={loading}
|
|
655
|
+
fullWidth
|
|
656
|
+
onClick={expandMethods}
|
|
657
|
+
testID={`${testID}-another-way`}
|
|
658
|
+
text="Sign in another way"
|
|
659
|
+
variant="muted"
|
|
660
|
+
/>
|
|
661
|
+
)}
|
|
662
|
+
{showMethods && hasAccounts && hasMethods && (
|
|
663
|
+
<MethodDivider text="or sign in another way" />
|
|
664
|
+
)}
|
|
665
|
+
{showMethods && hasMethods && renderMethodStack()}
|
|
666
|
+
{showMethods && hasForm && hasMethods && <MethodDivider text="or use your email" />}
|
|
667
|
+
{showMethods && hasForm && (
|
|
668
|
+
<FormContainer
|
|
669
|
+
accessibilityLabel={resolvedTitle}
|
|
670
|
+
gap={4}
|
|
671
|
+
onSubmit={handleSubmit}
|
|
672
|
+
ref={formRef}
|
|
673
|
+
testID={`${testID}-form`}
|
|
674
|
+
width="100%"
|
|
675
|
+
>
|
|
676
|
+
{visibleFields.map((field, index) => renderField(field, index, visibleFields))}
|
|
677
|
+
<Button
|
|
678
|
+
accessibilityLabel={
|
|
679
|
+
isEmailLastUsed
|
|
680
|
+
? withLastUsedLabel({label: "Sign in", lastUsedLabel})
|
|
681
|
+
: undefined
|
|
682
|
+
}
|
|
683
|
+
disabled={isSubmitDisabled}
|
|
684
|
+
fullWidth
|
|
685
|
+
loading={loading}
|
|
686
|
+
onClick={requestSubmit}
|
|
687
|
+
testID={`${testID}-submit-button`}
|
|
688
|
+
text={loading ? "Signing in" : "Sign in"}
|
|
689
|
+
/>
|
|
690
|
+
</FormContainer>
|
|
691
|
+
)}
|
|
692
|
+
</Box>
|
|
693
|
+
)}
|
|
694
|
+
</Box>
|
|
695
|
+
{renderFooter()}
|
|
696
|
+
</Box>
|
|
697
|
+
</View>
|
|
162
698
|
</Page>
|
|
163
699
|
);
|
|
164
700
|
};
|
|
701
|
+
|
|
702
|
+
const IdentityChip: FC<{
|
|
703
|
+
account: LoginAccountOption;
|
|
704
|
+
who: string;
|
|
705
|
+
onNotYou: () => void;
|
|
706
|
+
disabled: boolean;
|
|
707
|
+
testID: string;
|
|
708
|
+
}> = ({account, who, onNotYou, disabled, testID}) => {
|
|
709
|
+
const {theme} = useTheme();
|
|
710
|
+
if (!theme) {
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
713
|
+
return (
|
|
714
|
+
<View
|
|
715
|
+
style={{
|
|
716
|
+
alignItems: "center",
|
|
717
|
+
backgroundColor: theme.surface.secondaryExtraLight,
|
|
718
|
+
borderColor: theme.surface.secondaryLight,
|
|
719
|
+
borderRadius: theme.radius.full,
|
|
720
|
+
borderWidth: 1,
|
|
721
|
+
flexDirection: "row",
|
|
722
|
+
gap: 12,
|
|
723
|
+
paddingHorizontal: 16,
|
|
724
|
+
paddingVertical: 12,
|
|
725
|
+
width: "100%",
|
|
726
|
+
}}
|
|
727
|
+
>
|
|
728
|
+
<AvatarOrIcon account={account} who={who} />
|
|
729
|
+
<Box flex="shrink">
|
|
730
|
+
<Text bold>{account.name ?? who}</Text>
|
|
731
|
+
{Boolean(account.email) && (
|
|
732
|
+
<Text color="secondaryLight" size="sm">
|
|
733
|
+
{account.email}
|
|
734
|
+
</Text>
|
|
735
|
+
)}
|
|
736
|
+
</Box>
|
|
737
|
+
<TextLink disabled={disabled} onPress={onNotYou} testID={testID} text="Not you?" />
|
|
738
|
+
</View>
|
|
739
|
+
);
|
|
740
|
+
};
|
|
741
|
+
|
|
742
|
+
const AvatarOrIcon: FC<{account: LoginAccountOption; who: string}> = ({account, who}) => {
|
|
743
|
+
if (account.name || account.email) {
|
|
744
|
+
return <Avatar name={account.name ?? account.email ?? who} size="sm" src={account.image} />;
|
|
745
|
+
}
|
|
746
|
+
return <Icon color="secondaryLight" iconName="circle-user" size="xl" />;
|
|
747
|
+
};
|