@aws-amplify/ui-react-native 1.2.20 → 1.2.22
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/CHANGELOG.md +57 -0
- package/dist/Authenticator/Authenticator.d.ts +101 -148
- package/dist/Authenticator/Authenticator.js +2 -3
- package/dist/Authenticator/Defaults/ConfirmResetPassword/ConfirmResetPassword.d.ts +13 -2
- package/dist/Authenticator/Defaults/ConfirmResetPassword/ConfirmResetPassword.js +4 -3
- package/dist/Authenticator/Defaults/ConfirmSignIn/ConfirmSignIn.d.ts +13 -2
- package/dist/Authenticator/Defaults/ConfirmSignIn/ConfirmSignIn.js +4 -3
- package/dist/Authenticator/Defaults/ConfirmSignUp/ConfirmSignUp.d.ts +13 -2
- package/dist/Authenticator/Defaults/ConfirmSignUp/ConfirmSignUp.js +4 -3
- package/dist/Authenticator/Defaults/ConfirmVerifyUser/ConfirmVerifyUser.d.ts +13 -2
- package/dist/Authenticator/Defaults/ConfirmVerifyUser/ConfirmVerifyUser.js +4 -3
- package/dist/Authenticator/Defaults/ForceNewPassword/ForceNewPassword.d.ts +13 -2
- package/dist/Authenticator/Defaults/ForceNewPassword/ForceNewPassword.js +4 -3
- package/dist/Authenticator/Defaults/ResetPassword/ResetPassword.d.ts +13 -2
- package/dist/Authenticator/Defaults/ResetPassword/ResetPassword.js +4 -3
- package/dist/Authenticator/Defaults/SetupTOTP/SetupTOTP.d.ts +13 -2
- package/dist/Authenticator/Defaults/SetupTOTP/SetupTOTP.js +4 -3
- package/dist/Authenticator/Defaults/SignIn/SignIn.d.ts +13 -2
- package/dist/Authenticator/Defaults/SignIn/SignIn.js +4 -3
- package/dist/Authenticator/Defaults/SignUp/SignUp.d.ts +13 -2
- package/dist/Authenticator/Defaults/SignUp/SignUp.js +4 -3
- package/dist/Authenticator/Defaults/VerifyUser/VerifyUser.d.ts +13 -2
- package/dist/Authenticator/Defaults/VerifyUser/VerifyUser.js +4 -3
- package/dist/Authenticator/Defaults/types.d.ts +21 -20
- package/dist/Authenticator/common/DefaultContent/styles.js +1 -2
- package/dist/Authenticator/common/DefaultContent/types.d.ts +1 -1
- package/dist/Authenticator/common/DefaultFormFields/DefaultRadioFormFields.d.ts +7 -3
- package/dist/Authenticator/common/DefaultFormFields/DefaultRadioFormFields.js +4 -3
- package/dist/Authenticator/common/DefaultFormFields/DefaultTextFormFields.d.ts +6 -2
- package/dist/Authenticator/common/DefaultFormFields/DefaultTextFormFields.js +3 -3
- package/dist/Authenticator/common/DefaultFormFields/types.d.ts +12 -3
- package/dist/Authenticator/hooks/types.d.ts +3 -2
- package/dist/Authenticator/hooks/useFieldValues/types.d.ts +4 -1
- package/dist/Authenticator/hooks/useFieldValues/useFieldValues.d.ts +1 -1
- package/dist/Authenticator/hooks/useFieldValues/useFieldValues.js +21 -3
- package/dist/Authenticator/hooks/useFieldValues/utils.d.ts +10 -1
- package/dist/Authenticator/hooks/useFieldValues/utils.js +32 -2
- package/dist/primitives/Heading/styles.js +5 -5
- package/dist/primitives/Label/styles.js +2 -2
- package/dist/primitives/TextField/TextField.js +2 -1
- package/dist/primitives/TextField/styles.js +6 -3
- package/dist/primitives/TextField/types.d.ts +1 -0
- package/dist/theme/createTheme.js +24 -18
- package/dist/theme/types.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/jest.config.js +1 -0
- package/package.json +5 -5
- package/src/Authenticator/Authenticator.tsx +2 -6
- package/src/Authenticator/Defaults/ConfirmResetPassword/ConfirmResetPassword.tsx +7 -3
- package/src/Authenticator/Defaults/ConfirmResetPassword/__tests__/__snapshots__/ConfirmResetPassword.spec.tsx.snap +34 -30
- package/src/Authenticator/Defaults/ConfirmSignIn/ConfirmSignIn.tsx +7 -3
- package/src/Authenticator/Defaults/ConfirmSignIn/__tests__/ConfirmSignIn.spec.tsx +1 -0
- package/src/Authenticator/Defaults/ConfirmSignIn/__tests__/__snapshots__/ConfirmSignIn.spec.tsx.snap +14 -14
- package/src/Authenticator/Defaults/ConfirmSignUp/ConfirmSignUp.tsx +7 -3
- package/src/Authenticator/Defaults/ConfirmSignUp/__tests__/ConfirmSignUp.spec.tsx +1 -0
- package/src/Authenticator/Defaults/ConfirmSignUp/__tests__/__snapshots__/ConfirmSignUp.spec.tsx.snap +12 -15
- package/src/Authenticator/Defaults/ConfirmVerifyUser/ConfirmVerifyUser.tsx +7 -3
- package/src/Authenticator/Defaults/ConfirmVerifyUser/__tests__/ConfirmVerifyUser.spec.tsx +1 -0
- package/src/Authenticator/Defaults/ConfirmVerifyUser/__tests__/__snapshots__/ConfirmVerifyUser.spec.tsx.snap +6 -9
- package/src/Authenticator/Defaults/ForceNewPassword/ForceNewPassword.tsx +7 -3
- package/src/Authenticator/Defaults/ForceNewPassword/__tests__/__snapshots__/ForceNewPassword.spec.tsx.snap +13 -10
- package/src/Authenticator/Defaults/ResetPassword/ResetPassword.tsx +7 -3
- package/src/Authenticator/Defaults/ResetPassword/__tests__/ResetPassword.spec.tsx +1 -0
- package/src/Authenticator/Defaults/ResetPassword/__tests__/__snapshots__/ResetPassword.spec.tsx.snap +14 -14
- package/src/Authenticator/Defaults/SetupTOTP/SetupTOTP.tsx +7 -3
- package/src/Authenticator/Defaults/SetupTOTP/__tests__/SetupTOTP.spec.tsx +1 -0
- package/src/Authenticator/Defaults/SetupTOTP/__tests__/__snapshots__/SetupTOTP.spec.tsx.snap +22 -22
- package/src/Authenticator/Defaults/SignIn/SignIn.tsx +7 -3
- package/src/Authenticator/Defaults/SignIn/__tests__/SignIn.spec.tsx +1 -0
- package/src/Authenticator/Defaults/SignIn/__tests__/__snapshots__/SignIn.spec.tsx.snap +36 -33
- package/src/Authenticator/Defaults/SignUp/SignUp.tsx +7 -3
- package/src/Authenticator/Defaults/SignUp/__tests__/__snapshots__/SignUp.spec.tsx.snap +111 -96
- package/src/Authenticator/Defaults/VerifyUser/VerifyUser.tsx +7 -3
- package/src/Authenticator/Defaults/VerifyUser/__tests__/VerifyUser.spec.tsx +1 -0
- package/src/Authenticator/Defaults/VerifyUser/__tests__/__snapshots__/VerifyUser.spec.tsx.snap +16 -18
- package/src/Authenticator/Defaults/types.ts +63 -49
- package/src/Authenticator/__tests__/Authenticator.spec.tsx +16 -19
- package/src/Authenticator/__tests__/__snapshots__/Authenticator.spec.tsx.snap +1 -9
- package/src/Authenticator/__tests__/withAuthenticator.spec.tsx +1 -1
- package/src/Authenticator/common/DefaultContent/styles.ts +1 -2
- package/src/Authenticator/common/DefaultContent/types.ts +1 -4
- package/src/Authenticator/common/DefaultFormFields/DefaultRadioFormFields.tsx +8 -6
- package/src/Authenticator/common/DefaultFormFields/DefaultTextFormFields.tsx +10 -7
- package/src/Authenticator/common/DefaultFormFields/types.ts +15 -5
- package/src/Authenticator/common/DefaultHeader/__tests__/__snapshots__/DefaultHeader.spec.tsx.snap +1 -1
- package/src/Authenticator/common/FederatedProviderButton/__tests__/__snapshots__/FederatedProviderButton.spec.tsx.snap +4 -4
- package/src/Authenticator/common/FederatedProviderButtons/__tests__/__snapshots__/FederatedProviderButtons.spec.tsx.snap +4 -4
- package/src/Authenticator/hooks/types.ts +3 -0
- package/src/Authenticator/hooks/useFieldValues/__tests__/useFieldValues.spec.ts +75 -2
- package/src/Authenticator/hooks/useFieldValues/__tests__/utils.spec.ts +67 -1
- package/src/Authenticator/hooks/useFieldValues/types.ts +5 -0
- package/src/Authenticator/hooks/useFieldValues/useFieldValues.ts +26 -1
- package/src/Authenticator/hooks/useFieldValues/utils.ts +44 -1
- package/src/primitives/Checkbox/__tests__/__snapshots__/Checkbox.spec.tsx.snap +14 -14
- package/src/primitives/Divider/__tests__/__snapshots__/Divider.spec.tsx.snap +4 -4
- package/src/primitives/Heading/__tests__/__snapshots__/Heading.spec.tsx.snap +7 -7
- package/src/primitives/Heading/styles.ts +5 -5
- package/src/primitives/Label/__tests__/__snapshots__/Label.spec.tsx.snap +8 -8
- package/src/primitives/Label/styles.ts +2 -2
- package/src/primitives/PasswordField/__tests__/__snapshots__/PasswordField.spec.tsx.snap +25 -20
- package/src/primitives/PhoneNumberField/__tests__/__snapshots__/PhoneNumberField.spec.tsx.snap +6 -0
- package/src/primitives/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +14 -14
- package/src/primitives/RadioGroup/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +48 -48
- package/src/primitives/TextField/TextField.tsx +2 -1
- package/src/primitives/TextField/__tests__/TextField.spec.tsx +57 -8
- package/src/primitives/TextField/__tests__/__snapshots__/TextField.spec.tsx.snap +61 -55
- package/src/primitives/TextField/styles.ts +6 -3
- package/src/primitives/TextField/types.ts +1 -0
- package/src/theme/__tests__/createTheme.spec.ts +48 -0
- package/src/theme/createTheme.ts +44 -21
- package/src/theme/types.ts +17 -16
- package/src/version.ts +1 -1
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
DefaultRadioFormFields,
|
|
9
9
|
} from '../../common';
|
|
10
10
|
import { useFieldValues } from '../../hooks';
|
|
11
|
-
import {
|
|
11
|
+
import { DefaultVerifyUserProps } from '../types';
|
|
12
12
|
|
|
13
13
|
const COMPONENT_NAME = 'VerifyUser';
|
|
14
14
|
|
|
@@ -19,17 +19,19 @@ const {
|
|
|
19
19
|
getAccountRecoveryInfoText,
|
|
20
20
|
} = authenticatorTextUtil;
|
|
21
21
|
|
|
22
|
-
const VerifyUser
|
|
22
|
+
const VerifyUser = ({
|
|
23
23
|
fields,
|
|
24
24
|
handleBlur,
|
|
25
25
|
handleChange,
|
|
26
26
|
handleSubmit,
|
|
27
27
|
skipVerification,
|
|
28
|
+
validationErrors,
|
|
28
29
|
...rest
|
|
29
|
-
}) => {
|
|
30
|
+
}: DefaultVerifyUserProps): JSX.Element => {
|
|
30
31
|
const {
|
|
31
32
|
disableFormSubmit: disabled,
|
|
32
33
|
fields: fieldsWithHandlers,
|
|
34
|
+
fieldValidationErrors,
|
|
33
35
|
handleFormSubmit,
|
|
34
36
|
} = useFieldValues({
|
|
35
37
|
componentName: COMPONENT_NAME,
|
|
@@ -37,6 +39,7 @@ const VerifyUser: DefaultVerifyUserComponent = ({
|
|
|
37
39
|
handleBlur,
|
|
38
40
|
handleChange,
|
|
39
41
|
handleSubmit,
|
|
42
|
+
validationErrors,
|
|
40
43
|
});
|
|
41
44
|
|
|
42
45
|
const headerText = getVerifyContactText();
|
|
@@ -59,6 +62,7 @@ const VerifyUser: DefaultVerifyUserComponent = ({
|
|
|
59
62
|
buttons={buttons}
|
|
60
63
|
fields={fieldsWithHandlers}
|
|
61
64
|
headerText={headerText}
|
|
65
|
+
validationErrors={fieldValidationErrors}
|
|
62
66
|
/>
|
|
63
67
|
);
|
|
64
68
|
};
|
package/src/Authenticator/Defaults/VerifyUser/__tests__/__snapshots__/VerifyUser.spec.tsx.snap
CHANGED
|
@@ -11,7 +11,7 @@ Array [
|
|
|
11
11
|
},
|
|
12
12
|
Object {
|
|
13
13
|
"fontSize": 24,
|
|
14
|
-
"fontWeight": "
|
|
14
|
+
"fontWeight": "500",
|
|
15
15
|
"lineHeight": 36,
|
|
16
16
|
},
|
|
17
17
|
Object {
|
|
@@ -28,9 +28,9 @@ Array [
|
|
|
28
28
|
style={
|
|
29
29
|
Array [
|
|
30
30
|
Object {
|
|
31
|
-
"fontSize":
|
|
31
|
+
"fontSize": 16,
|
|
32
32
|
"fontWeight": "400",
|
|
33
|
-
"lineHeight":
|
|
33
|
+
"lineHeight": 24,
|
|
34
34
|
},
|
|
35
35
|
Object {
|
|
36
36
|
"color": "hsl(210, 50%, 10%)",
|
|
@@ -118,9 +118,9 @@ Array [
|
|
|
118
118
|
style={
|
|
119
119
|
Array [
|
|
120
120
|
Object {
|
|
121
|
-
"fontSize":
|
|
121
|
+
"fontSize": 16,
|
|
122
122
|
"fontWeight": "400",
|
|
123
|
-
"lineHeight":
|
|
123
|
+
"lineHeight": 24,
|
|
124
124
|
},
|
|
125
125
|
Object {
|
|
126
126
|
"color": "hsl(210, 50%, 10%)",
|
|
@@ -185,9 +185,9 @@ Array [
|
|
|
185
185
|
style={
|
|
186
186
|
Array [
|
|
187
187
|
Object {
|
|
188
|
-
"fontSize":
|
|
188
|
+
"fontSize": 16,
|
|
189
189
|
"fontWeight": "400",
|
|
190
|
-
"lineHeight":
|
|
190
|
+
"lineHeight": 24,
|
|
191
191
|
},
|
|
192
192
|
Object {
|
|
193
193
|
"color": "hsl(210, 50%, 10%)",
|
|
@@ -233,8 +233,7 @@ Array [
|
|
|
233
233
|
},
|
|
234
234
|
undefined,
|
|
235
235
|
Object {
|
|
236
|
-
"
|
|
237
|
-
"marginVertical": 12,
|
|
236
|
+
"margin": 12,
|
|
238
237
|
},
|
|
239
238
|
]
|
|
240
239
|
}
|
|
@@ -328,7 +327,7 @@ Array [
|
|
|
328
327
|
},
|
|
329
328
|
Object {
|
|
330
329
|
"fontSize": 24,
|
|
331
|
-
"fontWeight": "
|
|
330
|
+
"fontWeight": "500",
|
|
332
331
|
"lineHeight": 36,
|
|
333
332
|
},
|
|
334
333
|
Object {
|
|
@@ -345,9 +344,9 @@ Array [
|
|
|
345
344
|
style={
|
|
346
345
|
Array [
|
|
347
346
|
Object {
|
|
348
|
-
"fontSize":
|
|
347
|
+
"fontSize": 16,
|
|
349
348
|
"fontWeight": "400",
|
|
350
|
-
"lineHeight":
|
|
349
|
+
"lineHeight": 24,
|
|
351
350
|
},
|
|
352
351
|
Object {
|
|
353
352
|
"color": "hsl(210, 50%, 10%)",
|
|
@@ -435,9 +434,9 @@ Array [
|
|
|
435
434
|
style={
|
|
436
435
|
Array [
|
|
437
436
|
Object {
|
|
438
|
-
"fontSize":
|
|
437
|
+
"fontSize": 16,
|
|
439
438
|
"fontWeight": "400",
|
|
440
|
-
"lineHeight":
|
|
439
|
+
"lineHeight": 24,
|
|
441
440
|
},
|
|
442
441
|
Object {
|
|
443
442
|
"color": "hsl(210, 50%, 10%)",
|
|
@@ -502,9 +501,9 @@ Array [
|
|
|
502
501
|
style={
|
|
503
502
|
Array [
|
|
504
503
|
Object {
|
|
505
|
-
"fontSize":
|
|
504
|
+
"fontSize": 16,
|
|
506
505
|
"fontWeight": "400",
|
|
507
|
-
"lineHeight":
|
|
506
|
+
"lineHeight": 24,
|
|
508
507
|
},
|
|
509
508
|
Object {
|
|
510
509
|
"color": "hsl(210, 50%, 10%)",
|
|
@@ -609,8 +608,7 @@ Array [
|
|
|
609
608
|
},
|
|
610
609
|
undefined,
|
|
611
610
|
Object {
|
|
612
|
-
"
|
|
613
|
-
"marginVertical": 12,
|
|
611
|
+
"margin": 12,
|
|
614
612
|
},
|
|
615
613
|
]
|
|
616
614
|
}
|
|
@@ -21,55 +21,69 @@ export type DefaultComponents<
|
|
|
21
21
|
Props = {}
|
|
22
22
|
> = AuthenticatorComponentDefaults<FieldType, Props>;
|
|
23
23
|
|
|
24
|
-
export type
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
>['
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
export type
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
24
|
+
export type DefaultConfirmResetPasswordProps = React.ComponentPropsWithoutRef<
|
|
25
|
+
DefaultComponents<
|
|
26
|
+
TextFieldOptionsType,
|
|
27
|
+
{ style?: ConfirmResetPasswordStyle }
|
|
28
|
+
>['ConfirmResetPassword']
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
export type DefaultConfirmSignInProps = React.ComponentPropsWithoutRef<
|
|
32
|
+
DefaultComponents<
|
|
33
|
+
TextFieldOptionsType,
|
|
34
|
+
{ style?: ConfirmSignInStyle }
|
|
35
|
+
>['ConfirmSignIn']
|
|
36
|
+
>;
|
|
37
|
+
|
|
38
|
+
export type DefaultConfirmSignUpProps = React.ComponentPropsWithoutRef<
|
|
39
|
+
DefaultComponents<
|
|
40
|
+
TextFieldOptionsType,
|
|
41
|
+
{ style?: ConfirmSignUpStyle }
|
|
42
|
+
>['ConfirmSignUp']
|
|
43
|
+
>;
|
|
44
|
+
|
|
45
|
+
export type DefaultConfirmVerifyUserProps = React.ComponentPropsWithoutRef<
|
|
46
|
+
DefaultComponents<
|
|
47
|
+
TextFieldOptionsType,
|
|
48
|
+
{ style?: ConfirmVerifyUserStyle }
|
|
49
|
+
>['ConfirmVerifyUser']
|
|
50
|
+
>;
|
|
51
|
+
|
|
52
|
+
export type DefaultForceNewPasswordProps = React.ComponentPropsWithoutRef<
|
|
53
|
+
DefaultComponents<
|
|
54
|
+
TextFieldOptionsType,
|
|
55
|
+
{ style?: ForceNewPasswordStyle }
|
|
56
|
+
>['ForceNewPassword']
|
|
57
|
+
>;
|
|
58
|
+
|
|
59
|
+
export type DefaultResetPasswordProps = React.ComponentPropsWithoutRef<
|
|
60
|
+
DefaultComponents<
|
|
61
|
+
TextFieldOptionsType,
|
|
62
|
+
{ style?: ResetPasswordStyle }
|
|
63
|
+
>['ResetPassword']
|
|
64
|
+
>;
|
|
65
|
+
|
|
66
|
+
export type DefaultSetupTOTPProps = React.ComponentPropsWithoutRef<
|
|
67
|
+
DefaultComponents<
|
|
68
|
+
TextFieldOptionsType,
|
|
69
|
+
{ style?: SetupTOTPStyle }
|
|
70
|
+
>['SetupTOTP']
|
|
71
|
+
>;
|
|
72
|
+
|
|
73
|
+
export type DefaultSignInProps = React.ComponentPropsWithoutRef<
|
|
74
|
+
DefaultComponents<TextFieldOptionsType, { style?: SignInStyle }>['SignIn']
|
|
75
|
+
>;
|
|
76
|
+
|
|
77
|
+
export type DefaultSignUpProps = React.ComponentPropsWithoutRef<
|
|
78
|
+
DefaultComponents<TextFieldOptionsType, { style?: SignUpStyle }>['SignUp']
|
|
79
|
+
>;
|
|
80
|
+
|
|
81
|
+
export type DefaultVerifyUserProps = React.ComponentPropsWithoutRef<
|
|
82
|
+
DefaultComponents<
|
|
83
|
+
RadioFieldOptions,
|
|
84
|
+
{ style?: VerifyUserStyle }
|
|
85
|
+
>['VerifyUser']
|
|
86
|
+
>;
|
|
73
87
|
|
|
74
88
|
/**
|
|
75
89
|
* Custom Authenticator components
|
|
@@ -81,30 +81,27 @@ describe('Authenticator', () => {
|
|
|
81
81
|
expect(toJSON()).toMatchSnapshot();
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
it
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
() => ({ route } as unknown as UseAuthenticator)
|
|
89
|
-
);
|
|
84
|
+
it('handles `authStatus` of authenticated as expected', () => {
|
|
85
|
+
useAuthenticatorSpy.mockImplementation(
|
|
86
|
+
() => ({ authStatus: 'authenticated' } as unknown as UseAuthenticator)
|
|
87
|
+
);
|
|
90
88
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
const { getByTestId, toJSON } = render(
|
|
90
|
+
<Authenticator>
|
|
91
|
+
<TestChildren />
|
|
92
|
+
</Authenticator>
|
|
93
|
+
);
|
|
96
94
|
|
|
97
|
-
|
|
95
|
+
const children = getByTestId(CHILD_TEST_ID);
|
|
98
96
|
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
expect(children.type).toBe('Text');
|
|
98
|
+
expect(children.props.children).toBe(CHILD_CONTENT);
|
|
101
99
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
);
|
|
100
|
+
expect(toJSON()).toMatchSnapshot();
|
|
101
|
+
});
|
|
105
102
|
|
|
106
|
-
it.each(['
|
|
107
|
-
'handles
|
|
103
|
+
it.each(['unauthenticated', 'configuring'])(
|
|
104
|
+
'handles an authStatus of %s as expected',
|
|
108
105
|
(route) => {
|
|
109
106
|
useAuthenticatorSpy.mockImplementation(
|
|
110
107
|
() => ({ route } as unknown as UseAuthenticator)
|
|
@@ -59,15 +59,7 @@ exports[`Authenticator behaves as expected in the happy path 1`] = `
|
|
|
59
59
|
</SafeAreaProvider>
|
|
60
60
|
`;
|
|
61
61
|
|
|
62
|
-
exports[`Authenticator handles
|
|
63
|
-
<Text
|
|
64
|
-
testID="child-test-id"
|
|
65
|
-
>
|
|
66
|
-
Test Children
|
|
67
|
-
</Text>
|
|
68
|
-
`;
|
|
69
|
-
|
|
70
|
-
exports[`Authenticator handles the signOut route as expected with children 1`] = `
|
|
62
|
+
exports[`Authenticator handles \`authStatus\` of authenticated as expected 1`] = `
|
|
71
63
|
<Text
|
|
72
64
|
testID="child-test-id"
|
|
73
65
|
>
|
|
@@ -12,8 +12,7 @@ export const getDefaultStyle = ({
|
|
|
12
12
|
paddingHorizontal: space.small,
|
|
13
13
|
},
|
|
14
14
|
buttonPrimary: {
|
|
15
|
-
|
|
16
|
-
marginVertical: space.small,
|
|
15
|
+
margin: space.small,
|
|
17
16
|
},
|
|
18
17
|
buttonPrimaryLabel: {}, // themed value only
|
|
19
18
|
buttonSecondary: {
|
|
@@ -60,10 +60,7 @@ export type DefaultContentProps<
|
|
|
60
60
|
| TextFieldOptionsType
|
|
61
61
|
| RadioFieldOptions
|
|
62
62
|
| unknown = unknown
|
|
63
|
-
> = Pick<
|
|
64
|
-
DefaultComponentProps<FieldsType>,
|
|
65
|
-
'error' | 'Footer' | 'isPending'
|
|
66
|
-
> & {
|
|
63
|
+
> = Pick<DefaultComponentProps<FieldsType>, 'error' | 'isPending'> & {
|
|
67
64
|
buttons: DefaultButtons;
|
|
68
65
|
body?: React.ReactNode;
|
|
69
66
|
fields: FieldsType[];
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { censorAllButFirstAndLast, censorPhoneNumber } from '@aws-amplify/ui';
|
|
3
3
|
|
|
4
4
|
import { Radio, RadioGroup } from '../../../primitives';
|
|
5
|
-
import {
|
|
5
|
+
import { DefaultRadioFormFieldsProps } from './types';
|
|
6
6
|
|
|
7
7
|
const censorContactInformation = (name: string, value: string): string => {
|
|
8
8
|
let censoredVal = value;
|
|
@@ -17,16 +17,16 @@ const censorContactInformation = (name: string, value: string): string => {
|
|
|
17
17
|
return censoredVal;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const DefaultRadioFormFields = ({
|
|
21
21
|
fields,
|
|
22
|
-
isPending,
|
|
23
22
|
fieldContainerStyle,
|
|
24
23
|
fieldLabelStyle,
|
|
24
|
+
isPending,
|
|
25
25
|
style,
|
|
26
|
-
}) => {
|
|
26
|
+
}: DefaultRadioFormFieldsProps): JSX.Element => {
|
|
27
27
|
return (
|
|
28
28
|
<RadioGroup disabled={isPending} style={style}>
|
|
29
|
-
{fields.map(({ name, value, ...props }) => (
|
|
29
|
+
{(fields ?? []).map(({ name, value, ...props }) => (
|
|
30
30
|
<Radio
|
|
31
31
|
{...props}
|
|
32
32
|
key={value}
|
|
@@ -42,4 +42,6 @@ const DefaultFormFields: DefaultRadioFormFieldsComponent = ({
|
|
|
42
42
|
);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
DefaultRadioFormFields.displayName = 'FormFields';
|
|
46
|
+
|
|
47
|
+
export default DefaultRadioFormFields;
|
|
@@ -5,19 +5,22 @@ import { getErrors } from '@aws-amplify/ui';
|
|
|
5
5
|
|
|
6
6
|
import Field from './Field';
|
|
7
7
|
import { FieldErrors } from './FieldErrors';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
// DefaultTextFormFieldsComponent,
|
|
10
|
+
DefaultTextFormFieldsProps,
|
|
11
|
+
} from './types';
|
|
9
12
|
|
|
10
|
-
const DefaultTextFormFields
|
|
13
|
+
const DefaultTextFormFields = ({
|
|
11
14
|
fieldContainerStyle,
|
|
12
15
|
fieldErrorsContainer,
|
|
13
16
|
fieldErrorStyle,
|
|
14
17
|
fieldStyle,
|
|
15
|
-
fields
|
|
16
|
-
isPending,
|
|
18
|
+
fields,
|
|
19
|
+
isPending = false,
|
|
17
20
|
style,
|
|
18
21
|
validationErrors,
|
|
19
|
-
}) => {
|
|
20
|
-
const formFields = fields.map(({ name, type, ...field }) => {
|
|
22
|
+
}: DefaultTextFormFieldsProps): JSX.Element => {
|
|
23
|
+
const formFields = (fields ?? []).map(({ name, type, ...field }) => {
|
|
21
24
|
const errors = validationErrors ? getErrors(validationErrors?.[name]) : [];
|
|
22
25
|
|
|
23
26
|
const hasError = errors?.length > 0;
|
|
@@ -44,6 +47,6 @@ const DefaultTextFormFields: DefaultTextFormFieldsComponent = ({
|
|
|
44
47
|
return <View style={style}>{formFields}</View>;
|
|
45
48
|
};
|
|
46
49
|
|
|
47
|
-
DefaultTextFormFields.displayName = '
|
|
50
|
+
DefaultTextFormFields.displayName = 'FormFields';
|
|
48
51
|
|
|
49
52
|
export default DefaultTextFormFields;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
AuthenticatorFormFieldsComponent,
|
|
4
|
+
UseAuthenticator,
|
|
5
|
+
} from '@aws-amplify/ui-react-core';
|
|
3
6
|
|
|
4
7
|
import { RadioFieldOptions, TextFieldOptionsType } from '../../hooks';
|
|
5
8
|
|
|
@@ -25,8 +28,15 @@ export interface DefaultFormFieldsStyle {
|
|
|
25
28
|
export type DefaultFormFieldsComponent<FieldsType> =
|
|
26
29
|
AuthenticatorFormFieldsComponent<FieldsType, DefaultFormFieldsStyle>;
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
interface FormFieldsProps extends DefaultFormFieldsStyle {
|
|
32
|
+
isPending?: UseAuthenticator['isPending'];
|
|
33
|
+
validationErrors?: UseAuthenticator['validationErrors'];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface DefaultTextFormFieldsProps extends FormFieldsProps {
|
|
37
|
+
fields?: TextFieldOptionsType[];
|
|
38
|
+
}
|
|
30
39
|
|
|
31
|
-
export
|
|
32
|
-
|
|
40
|
+
export interface DefaultRadioFormFieldsProps extends FormFieldsProps {
|
|
41
|
+
fields?: RadioFieldOptions[];
|
|
42
|
+
}
|
|
@@ -72,9 +72,9 @@ exports[`FederatedProviderButton applies style props 1`] = `
|
|
|
72
72
|
style={
|
|
73
73
|
Array [
|
|
74
74
|
Object {
|
|
75
|
-
"fontSize":
|
|
75
|
+
"fontSize": 16,
|
|
76
76
|
"fontWeight": "400",
|
|
77
|
-
"lineHeight":
|
|
77
|
+
"lineHeight": 24,
|
|
78
78
|
},
|
|
79
79
|
Object {
|
|
80
80
|
"color": "hsl(210, 50%, 10%)",
|
|
@@ -163,9 +163,9 @@ exports[`FederatedProviderButton renders default button as expected 1`] = `
|
|
|
163
163
|
style={
|
|
164
164
|
Array [
|
|
165
165
|
Object {
|
|
166
|
-
"fontSize":
|
|
166
|
+
"fontSize": 16,
|
|
167
167
|
"fontWeight": "400",
|
|
168
|
-
"lineHeight":
|
|
168
|
+
"lineHeight": 24,
|
|
169
169
|
},
|
|
170
170
|
Object {
|
|
171
171
|
"color": "hsl(210, 50%, 10%)",
|
|
@@ -79,9 +79,9 @@ exports[`FederatedProviderButtons renders as expected 1`] = `
|
|
|
79
79
|
style={
|
|
80
80
|
Array [
|
|
81
81
|
Object {
|
|
82
|
-
"fontSize":
|
|
82
|
+
"fontSize": 16,
|
|
83
83
|
"fontWeight": "400",
|
|
84
|
-
"lineHeight":
|
|
84
|
+
"lineHeight": 24,
|
|
85
85
|
},
|
|
86
86
|
Object {
|
|
87
87
|
"color": "hsl(210, 50%, 10%)",
|
|
@@ -127,9 +127,9 @@ exports[`FederatedProviderButtons renders as expected 1`] = `
|
|
|
127
127
|
style={
|
|
128
128
|
Array [
|
|
129
129
|
Object {
|
|
130
|
-
"fontSize":
|
|
130
|
+
"fontSize": 16,
|
|
131
131
|
"fontWeight": "400",
|
|
132
|
-
"lineHeight":
|
|
132
|
+
"lineHeight": 24,
|
|
133
133
|
},
|
|
134
134
|
Object {
|
|
135
135
|
"color": "hsl(210, 50%, 10%)",
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
|
|
8
8
|
export type MachineFieldTypeKey = 'password' | 'tel';
|
|
9
9
|
export type AuthenticatorFieldTypeKey =
|
|
10
|
+
| 'email'
|
|
10
11
|
| 'password'
|
|
11
12
|
| 'phone'
|
|
12
13
|
| 'default'
|
|
@@ -23,10 +24,12 @@ type FieldOptions<FieldProps, Type extends AuthenticatorFieldTypeKey> = {
|
|
|
23
24
|
type: Type;
|
|
24
25
|
} & Omit<FieldProps, 'disabled' | 'onBlur'>;
|
|
25
26
|
|
|
27
|
+
type EmailFieldOptions = FieldOptions<PhoneNumberFieldProps, 'email'>;
|
|
26
28
|
type PasswordFieldOptions = FieldOptions<PasswordFieldProps, 'password'>;
|
|
27
29
|
type PhoneFieldOptions = FieldOptions<PhoneNumberFieldProps, 'phone'>;
|
|
28
30
|
type DefaultFieldOptions = FieldOptions<TextFieldProps, 'default'>;
|
|
29
31
|
export type TextFieldOptionsType = (
|
|
32
|
+
| EmailFieldOptions
|
|
30
33
|
| PasswordFieldOptions
|
|
31
34
|
| PhoneFieldOptions
|
|
32
35
|
| DefaultFieldOptions
|