@aws-amplify/ui-react-native 1.2.18 → 1.2.20
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 +24 -0
- package/dist/Authenticator/Authenticator.d.ts +6 -12
- package/dist/Authenticator/Authenticator.js +5 -0
- package/dist/Authenticator/Defaults/ConfirmResetPassword/ConfirmResetPassword.js +15 -4
- package/dist/Authenticator/Defaults/ConfirmSignIn/ConfirmSignIn.js +13 -3
- package/dist/Authenticator/Defaults/ConfirmSignUp/ConfirmSignUp.js +13 -3
- package/dist/Authenticator/Defaults/ConfirmVerifyUser/ConfirmVerifyUser.js +13 -3
- package/dist/Authenticator/Defaults/ForceNewPassword/ForceNewPassword.js +15 -4
- package/dist/Authenticator/Defaults/ResetPassword/ResetPassword.js +13 -3
- package/dist/Authenticator/Defaults/SetupTOTP/SetupTOTP.js +13 -3
- package/dist/Authenticator/Defaults/SignIn/SignIn.js +3 -2
- package/dist/Authenticator/Defaults/SignUp/SignUp.js +9 -3
- package/dist/Authenticator/Defaults/VerifyUser/VerifyUser.js +3 -3
- package/dist/Authenticator/common/DefaultContent/DefaultContent.js +2 -2
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useDeprecationWarning/index.d.ts +1 -0
- package/dist/hooks/useDeprecationWarning/index.js +1 -0
- package/dist/hooks/useDeprecationWarning/useDeprecationWarning.d.ts +6 -0
- package/dist/hooks/useDeprecationWarning/useDeprecationWarning.js +11 -0
- package/dist/primitives/Radio/styles.js +2 -1
- package/dist/utils/platform.d.ts +5 -0
- package/dist/utils/platform.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -4
- package/src/Authenticator/Authenticator.tsx +7 -0
- package/src/Authenticator/Defaults/ConfirmResetPassword/ConfirmResetPassword.tsx +19 -3
- package/src/Authenticator/Defaults/ConfirmResetPassword/__tests__/ConfirmResetPassword.spec.tsx +1 -0
- package/src/Authenticator/Defaults/ConfirmResetPassword/__tests__/__snapshots__/ConfirmResetPassword.spec.tsx.snap +13 -0
- package/src/Authenticator/Defaults/ConfirmSignIn/ConfirmSignIn.tsx +17 -3
- package/src/Authenticator/Defaults/ConfirmSignIn/__tests__/__snapshots__/ConfirmSignIn.spec.tsx.snap +13 -0
- package/src/Authenticator/Defaults/ConfirmSignUp/ConfirmSignUp.tsx +17 -3
- package/src/Authenticator/Defaults/ConfirmSignUp/__tests__/__snapshots__/ConfirmSignUp.spec.tsx.snap +19 -0
- package/src/Authenticator/Defaults/ConfirmVerifyUser/ConfirmVerifyUser.tsx +17 -3
- package/src/Authenticator/Defaults/ConfirmVerifyUser/__tests__/__snapshots__/ConfirmVerifyUser.spec.tsx.snap +19 -0
- package/src/Authenticator/Defaults/ForceNewPassword/ForceNewPassword.tsx +19 -3
- package/src/Authenticator/Defaults/ForceNewPassword/__tests__/ForceNewPassword.spec.tsx +1 -0
- package/src/Authenticator/Defaults/ForceNewPassword/__tests__/__snapshots__/ForceNewPassword.spec.tsx.snap +19 -0
- package/src/Authenticator/Defaults/ResetPassword/ResetPassword.tsx +17 -3
- package/src/Authenticator/Defaults/ResetPassword/__tests__/__snapshots__/ResetPassword.spec.tsx.snap +13 -0
- package/src/Authenticator/Defaults/SetupTOTP/SetupTOTP.tsx +17 -3
- package/src/Authenticator/Defaults/SetupTOTP/__tests__/__snapshots__/SetupTOTP.spec.tsx.snap +13 -0
- package/src/Authenticator/Defaults/SignIn/SignIn.tsx +7 -2
- package/src/Authenticator/Defaults/SignIn/__tests__/__snapshots__/SignIn.spec.tsx.snap +19 -0
- package/src/Authenticator/Defaults/SignUp/SignUp.tsx +13 -2
- package/src/Authenticator/Defaults/SignUp/__tests__/SignUp.spec.tsx +1 -0
- package/src/Authenticator/Defaults/SignUp/__tests__/__snapshots__/SignUp.spec.tsx.snap +31 -0
- package/src/Authenticator/Defaults/VerifyUser/VerifyUser.tsx +7 -3
- package/src/Authenticator/Defaults/VerifyUser/__tests__/__snapshots__/VerifyUser.spec.tsx.snap +19 -0
- package/src/Authenticator/common/DefaultContent/DefaultContent.tsx +2 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useDeprecationWarning/__tests__/useDeprecationWarning.spec.ts +42 -0
- package/src/hooks/useDeprecationWarning/index.ts +1 -0
- package/src/hooks/useDeprecationWarning/useDeprecationWarning.ts +21 -0
- package/src/primitives/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +9 -0
- package/src/primitives/Radio/styles.ts +2 -1
- package/src/primitives/RadioGroup/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +24 -0
- package/src/utils/platform.ts +2 -0
- package/src/version.ts +1 -1
|
@@ -30,7 +30,11 @@ const SignIn: DefaultSignInComponent = ({
|
|
|
30
30
|
getForgotPasswordText,
|
|
31
31
|
} = authenticatorTextUtil;
|
|
32
32
|
|
|
33
|
-
const {
|
|
33
|
+
const {
|
|
34
|
+
disableFormSubmit: disabled,
|
|
35
|
+
fields: fieldsWithHandlers,
|
|
36
|
+
handleFormSubmit,
|
|
37
|
+
} = useFieldValues({
|
|
34
38
|
componentName: COMPONENT_NAME,
|
|
35
39
|
fields,
|
|
36
40
|
handleBlur,
|
|
@@ -49,12 +53,13 @@ const SignIn: DefaultSignInComponent = ({
|
|
|
49
53
|
onPress: toResetPassword,
|
|
50
54
|
};
|
|
51
55
|
return {
|
|
52
|
-
primary: { children: signInText, onPress: handleFormSubmit },
|
|
56
|
+
primary: { children: signInText, disabled, onPress: handleFormSubmit },
|
|
53
57
|
links: hideSignUp
|
|
54
58
|
? [forgotPassword]
|
|
55
59
|
: [forgotPassword, { children: signUpText, onPress: toSignUp }],
|
|
56
60
|
};
|
|
57
61
|
}, [
|
|
62
|
+
disabled,
|
|
58
63
|
forgotPasswordText,
|
|
59
64
|
handleFormSubmit,
|
|
60
65
|
hideSignUp,
|
|
@@ -261,6 +261,11 @@ Array [
|
|
|
261
261
|
</View>,
|
|
262
262
|
<View
|
|
263
263
|
accessibilityRole="button"
|
|
264
|
+
accessibilityState={
|
|
265
|
+
Object {
|
|
266
|
+
"disabled": false,
|
|
267
|
+
}
|
|
268
|
+
}
|
|
264
269
|
accessible={true}
|
|
265
270
|
collapsable={false}
|
|
266
271
|
focusable={true}
|
|
@@ -290,6 +295,7 @@ Array [
|
|
|
290
295
|
},
|
|
291
296
|
]
|
|
292
297
|
}
|
|
298
|
+
testID="amplify__button"
|
|
293
299
|
>
|
|
294
300
|
<Text
|
|
295
301
|
style={
|
|
@@ -677,6 +683,11 @@ Array [
|
|
|
677
683
|
</View>,
|
|
678
684
|
<View
|
|
679
685
|
accessibilityRole="button"
|
|
686
|
+
accessibilityState={
|
|
687
|
+
Object {
|
|
688
|
+
"disabled": false,
|
|
689
|
+
}
|
|
690
|
+
}
|
|
680
691
|
accessible={true}
|
|
681
692
|
collapsable={false}
|
|
682
693
|
focusable={true}
|
|
@@ -706,6 +717,7 @@ Array [
|
|
|
706
717
|
},
|
|
707
718
|
]
|
|
708
719
|
}
|
|
720
|
+
testID="amplify__button"
|
|
709
721
|
>
|
|
710
722
|
<Text
|
|
711
723
|
style={
|
|
@@ -1059,6 +1071,7 @@ Array [
|
|
|
1059
1071
|
},
|
|
1060
1072
|
]
|
|
1061
1073
|
}
|
|
1074
|
+
testID="amplify__error-message"
|
|
1062
1075
|
>
|
|
1063
1076
|
<Image
|
|
1064
1077
|
accessibilityRole="image"
|
|
@@ -1103,6 +1116,11 @@ Array [
|
|
|
1103
1116
|
</View>,
|
|
1104
1117
|
<View
|
|
1105
1118
|
accessibilityRole="button"
|
|
1119
|
+
accessibilityState={
|
|
1120
|
+
Object {
|
|
1121
|
+
"disabled": false,
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1106
1124
|
accessible={true}
|
|
1107
1125
|
collapsable={false}
|
|
1108
1126
|
focusable={true}
|
|
@@ -1132,6 +1150,7 @@ Array [
|
|
|
1132
1150
|
},
|
|
1133
1151
|
]
|
|
1134
1152
|
}
|
|
1153
|
+
testID="amplify__button"
|
|
1135
1154
|
>
|
|
1136
1155
|
<Text
|
|
1137
1156
|
style={
|
|
@@ -25,12 +25,17 @@ const SignUp: DefaultSignUpComponent = ({
|
|
|
25
25
|
handleBlur,
|
|
26
26
|
handleChange,
|
|
27
27
|
handleSubmit,
|
|
28
|
+
hasValidationErrors,
|
|
28
29
|
hideSignIn,
|
|
29
30
|
isPending,
|
|
30
31
|
toSignIn,
|
|
31
32
|
...rest
|
|
32
33
|
}) => {
|
|
33
|
-
const {
|
|
34
|
+
const {
|
|
35
|
+
disableFormSubmit,
|
|
36
|
+
fields: fieldsWithHandlers,
|
|
37
|
+
handleFormSubmit,
|
|
38
|
+
} = useFieldValues({
|
|
34
39
|
componentName: COMPONENT_NAME,
|
|
35
40
|
fields,
|
|
36
41
|
handleBlur,
|
|
@@ -38,6 +43,7 @@ const SignUp: DefaultSignUpComponent = ({
|
|
|
38
43
|
handleSubmit,
|
|
39
44
|
});
|
|
40
45
|
|
|
46
|
+
const disabled = hasValidationErrors || disableFormSubmit;
|
|
41
47
|
const headerText = getSignUpTabText();
|
|
42
48
|
const primaryButtonText = isPending
|
|
43
49
|
? getCreatingAccountText()
|
|
@@ -46,12 +52,17 @@ const SignUp: DefaultSignUpComponent = ({
|
|
|
46
52
|
|
|
47
53
|
const buttons = useMemo(
|
|
48
54
|
() => ({
|
|
49
|
-
primary: {
|
|
55
|
+
primary: {
|
|
56
|
+
children: primaryButtonText,
|
|
57
|
+
disabled,
|
|
58
|
+
onPress: handleFormSubmit,
|
|
59
|
+
},
|
|
50
60
|
links: hideSignIn
|
|
51
61
|
? undefined
|
|
52
62
|
: [{ children: secondaryButtonText, onPress: toSignIn }],
|
|
53
63
|
}),
|
|
54
64
|
[
|
|
65
|
+
disabled,
|
|
55
66
|
handleFormSubmit,
|
|
56
67
|
hideSignIn,
|
|
57
68
|
primaryButtonText,
|
|
@@ -499,6 +499,11 @@ Array [
|
|
|
499
499
|
</View>,
|
|
500
500
|
<View
|
|
501
501
|
accessibilityRole="button"
|
|
502
|
+
accessibilityState={
|
|
503
|
+
Object {
|
|
504
|
+
"disabled": false,
|
|
505
|
+
}
|
|
506
|
+
}
|
|
502
507
|
accessible={true}
|
|
503
508
|
collapsable={false}
|
|
504
509
|
focusable={true}
|
|
@@ -528,6 +533,7 @@ Array [
|
|
|
528
533
|
},
|
|
529
534
|
]
|
|
530
535
|
}
|
|
536
|
+
testID="amplify__button"
|
|
531
537
|
>
|
|
532
538
|
<Text
|
|
533
539
|
style={
|
|
@@ -1105,6 +1111,11 @@ Array [
|
|
|
1105
1111
|
</View>,
|
|
1106
1112
|
<View
|
|
1107
1113
|
accessibilityRole="button"
|
|
1114
|
+
accessibilityState={
|
|
1115
|
+
Object {
|
|
1116
|
+
"disabled": false,
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1108
1119
|
accessible={true}
|
|
1109
1120
|
collapsable={false}
|
|
1110
1121
|
focusable={true}
|
|
@@ -1134,6 +1145,7 @@ Array [
|
|
|
1134
1145
|
},
|
|
1135
1146
|
]
|
|
1136
1147
|
}
|
|
1148
|
+
testID="amplify__button"
|
|
1137
1149
|
>
|
|
1138
1150
|
<Text
|
|
1139
1151
|
style={
|
|
@@ -1661,6 +1673,11 @@ Array [
|
|
|
1661
1673
|
</View>,
|
|
1662
1674
|
<View
|
|
1663
1675
|
accessibilityRole="button"
|
|
1676
|
+
accessibilityState={
|
|
1677
|
+
Object {
|
|
1678
|
+
"disabled": false,
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1664
1681
|
accessible={true}
|
|
1665
1682
|
collapsable={false}
|
|
1666
1683
|
focusable={true}
|
|
@@ -1690,6 +1707,7 @@ Array [
|
|
|
1690
1707
|
},
|
|
1691
1708
|
]
|
|
1692
1709
|
}
|
|
1710
|
+
testID="amplify__button"
|
|
1693
1711
|
>
|
|
1694
1712
|
<Text
|
|
1695
1713
|
style={
|
|
@@ -2281,6 +2299,7 @@ Array [
|
|
|
2281
2299
|
},
|
|
2282
2300
|
]
|
|
2283
2301
|
}
|
|
2302
|
+
testID="amplify__error-message"
|
|
2284
2303
|
>
|
|
2285
2304
|
<Image
|
|
2286
2305
|
accessibilityRole="image"
|
|
@@ -2325,6 +2344,11 @@ Array [
|
|
|
2325
2344
|
</View>,
|
|
2326
2345
|
<View
|
|
2327
2346
|
accessibilityRole="button"
|
|
2347
|
+
accessibilityState={
|
|
2348
|
+
Object {
|
|
2349
|
+
"disabled": false,
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2328
2352
|
accessible={true}
|
|
2329
2353
|
collapsable={false}
|
|
2330
2354
|
focusable={true}
|
|
@@ -2354,6 +2378,7 @@ Array [
|
|
|
2354
2378
|
},
|
|
2355
2379
|
]
|
|
2356
2380
|
}
|
|
2381
|
+
testID="amplify__button"
|
|
2357
2382
|
>
|
|
2358
2383
|
<Text
|
|
2359
2384
|
style={
|
|
@@ -2968,6 +2993,11 @@ Array [
|
|
|
2968
2993
|
</View>,
|
|
2969
2994
|
<View
|
|
2970
2995
|
accessibilityRole="button"
|
|
2996
|
+
accessibilityState={
|
|
2997
|
+
Object {
|
|
2998
|
+
"disabled": false,
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
2971
3001
|
accessible={true}
|
|
2972
3002
|
collapsable={false}
|
|
2973
3003
|
focusable={true}
|
|
@@ -2997,6 +3027,7 @@ Array [
|
|
|
2997
3027
|
},
|
|
2998
3028
|
]
|
|
2999
3029
|
}
|
|
3030
|
+
testID="amplify__button"
|
|
3000
3031
|
>
|
|
3001
3032
|
<Text
|
|
3002
3033
|
style={
|
|
@@ -27,7 +27,11 @@ const VerifyUser: DefaultVerifyUserComponent = ({
|
|
|
27
27
|
skipVerification,
|
|
28
28
|
...rest
|
|
29
29
|
}) => {
|
|
30
|
-
const {
|
|
30
|
+
const {
|
|
31
|
+
disableFormSubmit: disabled,
|
|
32
|
+
fields: fieldsWithHandlers,
|
|
33
|
+
handleFormSubmit,
|
|
34
|
+
} = useFieldValues({
|
|
31
35
|
componentName: COMPONENT_NAME,
|
|
32
36
|
fields,
|
|
33
37
|
handleBlur,
|
|
@@ -42,10 +46,10 @@ const VerifyUser: DefaultVerifyUserComponent = ({
|
|
|
42
46
|
|
|
43
47
|
const buttons = useMemo(
|
|
44
48
|
() => ({
|
|
45
|
-
primary: { children: verifyText, onPress: handleFormSubmit },
|
|
49
|
+
primary: { children: verifyText, disabled, onPress: handleFormSubmit },
|
|
46
50
|
links: [{ children: skipText, onPress: skipVerification }],
|
|
47
51
|
}),
|
|
48
|
-
[handleFormSubmit, skipText, skipVerification, verifyText]
|
|
52
|
+
[disabled, handleFormSubmit, skipText, skipVerification, verifyText]
|
|
49
53
|
);
|
|
50
54
|
|
|
51
55
|
return (
|
package/src/Authenticator/Defaults/VerifyUser/__tests__/__snapshots__/VerifyUser.spec.tsx.snap
CHANGED
|
@@ -102,6 +102,7 @@ Array [
|
|
|
102
102
|
"borderRadius": 999,
|
|
103
103
|
"borderWidth": 2,
|
|
104
104
|
"justifyContent": "center",
|
|
105
|
+
"margin": 4,
|
|
105
106
|
},
|
|
106
107
|
Object {
|
|
107
108
|
"height": 20,
|
|
@@ -168,6 +169,7 @@ Array [
|
|
|
168
169
|
"borderRadius": 999,
|
|
169
170
|
"borderWidth": 2,
|
|
170
171
|
"justifyContent": "center",
|
|
172
|
+
"margin": 4,
|
|
171
173
|
},
|
|
172
174
|
Object {
|
|
173
175
|
"height": 20,
|
|
@@ -201,6 +203,11 @@ Array [
|
|
|
201
203
|
</View>,
|
|
202
204
|
<View
|
|
203
205
|
accessibilityRole="button"
|
|
206
|
+
accessibilityState={
|
|
207
|
+
Object {
|
|
208
|
+
"disabled": true,
|
|
209
|
+
}
|
|
210
|
+
}
|
|
204
211
|
accessible={true}
|
|
205
212
|
collapsable={false}
|
|
206
213
|
focusable={true}
|
|
@@ -220,6 +227,7 @@ Array [
|
|
|
220
227
|
"backgroundColor": "hsl(190, 95%, 30%)",
|
|
221
228
|
"borderRadius": 4,
|
|
222
229
|
"justifyContent": "center",
|
|
230
|
+
"opacity": 0.6,
|
|
223
231
|
"paddingHorizontal": 16,
|
|
224
232
|
"paddingVertical": 12,
|
|
225
233
|
},
|
|
@@ -230,6 +238,7 @@ Array [
|
|
|
230
238
|
},
|
|
231
239
|
]
|
|
232
240
|
}
|
|
241
|
+
testID="amplify__button"
|
|
233
242
|
>
|
|
234
243
|
<Text
|
|
235
244
|
style={
|
|
@@ -410,6 +419,7 @@ Array [
|
|
|
410
419
|
"borderRadius": 999,
|
|
411
420
|
"borderWidth": 2,
|
|
412
421
|
"justifyContent": "center",
|
|
422
|
+
"margin": 4,
|
|
413
423
|
},
|
|
414
424
|
Object {
|
|
415
425
|
"height": 20,
|
|
@@ -476,6 +486,7 @@ Array [
|
|
|
476
486
|
"borderRadius": 999,
|
|
477
487
|
"borderWidth": 2,
|
|
478
488
|
"justifyContent": "center",
|
|
489
|
+
"margin": 4,
|
|
479
490
|
},
|
|
480
491
|
Object {
|
|
481
492
|
"height": 20,
|
|
@@ -523,6 +534,7 @@ Array [
|
|
|
523
534
|
},
|
|
524
535
|
]
|
|
525
536
|
}
|
|
537
|
+
testID="amplify__error-message"
|
|
526
538
|
>
|
|
527
539
|
<Image
|
|
528
540
|
accessibilityRole="image"
|
|
@@ -567,6 +579,11 @@ Array [
|
|
|
567
579
|
</View>,
|
|
568
580
|
<View
|
|
569
581
|
accessibilityRole="button"
|
|
582
|
+
accessibilityState={
|
|
583
|
+
Object {
|
|
584
|
+
"disabled": true,
|
|
585
|
+
}
|
|
586
|
+
}
|
|
570
587
|
accessible={true}
|
|
571
588
|
collapsable={false}
|
|
572
589
|
focusable={true}
|
|
@@ -586,6 +603,7 @@ Array [
|
|
|
586
603
|
"backgroundColor": "hsl(190, 95%, 30%)",
|
|
587
604
|
"borderRadius": 4,
|
|
588
605
|
"justifyContent": "center",
|
|
606
|
+
"opacity": 0.6,
|
|
589
607
|
"paddingHorizontal": 16,
|
|
590
608
|
"paddingVertical": 12,
|
|
591
609
|
},
|
|
@@ -596,6 +614,7 @@ Array [
|
|
|
596
614
|
},
|
|
597
615
|
]
|
|
598
616
|
}
|
|
617
|
+
testID="amplify__button"
|
|
599
618
|
>
|
|
600
619
|
<Text
|
|
601
620
|
style={
|
|
@@ -69,6 +69,7 @@ export default function DefaultContent<
|
|
|
69
69
|
iconStyle={themedStyles.errorMessageIcon}
|
|
70
70
|
labelStyle={themedStyles.errorMessageLabel}
|
|
71
71
|
style={themedStyles.errorMessage}
|
|
72
|
+
testID="amplify__error-message"
|
|
72
73
|
>
|
|
73
74
|
{error}
|
|
74
75
|
</ErrorMessage>
|
|
@@ -78,6 +79,7 @@ export default function DefaultContent<
|
|
|
78
79
|
variant="primary"
|
|
79
80
|
textStyle={themedStyles.buttonPrimaryLabel}
|
|
80
81
|
style={themedStyles.buttonPrimary}
|
|
82
|
+
testID="amplify__button"
|
|
81
83
|
/>
|
|
82
84
|
{secondary ? (
|
|
83
85
|
<Button
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { renderHook } from '@testing-library/react-hooks';
|
|
2
|
+
|
|
3
|
+
import { platform } from '../../../utils';
|
|
4
|
+
import useDeprecationWarning from '../useDeprecationWarning';
|
|
5
|
+
|
|
6
|
+
const mockIsDev = jest.fn();
|
|
7
|
+
jest.mock('../../../utils', () => ({
|
|
8
|
+
...jest.requireActual('../../../utils'),
|
|
9
|
+
IS_DEV: mockIsDev,
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
// add empty mockImplementation to prevent logging output to the console
|
|
13
|
+
const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation();
|
|
14
|
+
|
|
15
|
+
const message = 'This component is deprecated, use X instead';
|
|
16
|
+
const shouldWarn = true;
|
|
17
|
+
|
|
18
|
+
describe('useDeprecationWarning', () => {
|
|
19
|
+
beforeAll(() => {
|
|
20
|
+
platform.IS_DEV = true;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
consoleWarnSpy.mockClear();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should log an error if `shouldWarn` is set to `true` and `__DEV__` is `true`', () => {
|
|
28
|
+
renderHook(() => useDeprecationWarning({ shouldWarn, message }));
|
|
29
|
+
expect(consoleWarnSpy).toHaveBeenCalledTimes(1);
|
|
30
|
+
expect(consoleWarnSpy).toHaveBeenCalledWith(message);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should not log an error if `shouldWarn` is set to `true` and `__DEV__` is `false`', () => {
|
|
34
|
+
const message = 'This component is deprecated, use X instead';
|
|
35
|
+
|
|
36
|
+
platform.IS_DEV = false;
|
|
37
|
+
|
|
38
|
+
renderHook(() => useDeprecationWarning({ shouldWarn, message }));
|
|
39
|
+
expect(consoleWarnSpy).toHaveBeenCalledTimes(0);
|
|
40
|
+
expect(consoleWarnSpy).not.toHaveBeenCalledWith(message);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as useDeprecationWarning } from './useDeprecationWarning';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useDeprecationWarning as useDeprecationWarningBase,
|
|
3
|
+
UseDeprecationWarning,
|
|
4
|
+
} from '@aws-amplify/ui-react-core';
|
|
5
|
+
|
|
6
|
+
import { platform } from '../../utils';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Logs a deprecation warning `message` to the console.
|
|
10
|
+
*/
|
|
11
|
+
const useDeprecationWarning: UseDeprecationWarning = ({
|
|
12
|
+
message,
|
|
13
|
+
shouldWarn: _shouldWarn,
|
|
14
|
+
}): void => {
|
|
15
|
+
// only log warnings in dev
|
|
16
|
+
const shouldWarn = _shouldWarn && platform.IS_DEV;
|
|
17
|
+
|
|
18
|
+
useDeprecationWarningBase({ message, shouldWarn });
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default useDeprecationWarning;
|
|
@@ -37,6 +37,7 @@ exports[`Radio applies theme and custom styles 1`] = `
|
|
|
37
37
|
"borderRadius": 999,
|
|
38
38
|
"borderWidth": 2,
|
|
39
39
|
"justifyContent": "center",
|
|
40
|
+
"margin": 4,
|
|
40
41
|
},
|
|
41
42
|
Object {
|
|
42
43
|
"height": 20,
|
|
@@ -108,6 +109,7 @@ exports[`Radio renders as expected when disabled 1`] = `
|
|
|
108
109
|
"borderRadius": 999,
|
|
109
110
|
"borderWidth": 2,
|
|
110
111
|
"justifyContent": "center",
|
|
112
|
+
"margin": 4,
|
|
111
113
|
},
|
|
112
114
|
Object {
|
|
113
115
|
"height": 20,
|
|
@@ -174,6 +176,7 @@ exports[`Radio renders as expected when passing a number to the size prop 1`] =
|
|
|
174
176
|
"borderRadius": 999,
|
|
175
177
|
"borderWidth": 2,
|
|
176
178
|
"justifyContent": "center",
|
|
179
|
+
"margin": 4,
|
|
177
180
|
},
|
|
178
181
|
Object {
|
|
179
182
|
"height": 40,
|
|
@@ -257,6 +260,7 @@ exports[`Radio renders as expected when selected is false 1`] = `
|
|
|
257
260
|
"borderRadius": 999,
|
|
258
261
|
"borderWidth": 2,
|
|
259
262
|
"justifyContent": "center",
|
|
263
|
+
"margin": 4,
|
|
260
264
|
},
|
|
261
265
|
Object {
|
|
262
266
|
"height": 20,
|
|
@@ -323,6 +327,7 @@ exports[`Radio renders as expected when selected is true 1`] = `
|
|
|
323
327
|
"borderRadius": 999,
|
|
324
328
|
"borderWidth": 2,
|
|
325
329
|
"justifyContent": "center",
|
|
330
|
+
"margin": 4,
|
|
326
331
|
},
|
|
327
332
|
Object {
|
|
328
333
|
"height": 20,
|
|
@@ -406,6 +411,7 @@ exports[`Radio renders as expected when size is large 1`] = `
|
|
|
406
411
|
"borderRadius": 999,
|
|
407
412
|
"borderWidth": 2,
|
|
408
413
|
"justifyContent": "center",
|
|
414
|
+
"margin": 4,
|
|
409
415
|
},
|
|
410
416
|
Object {
|
|
411
417
|
"height": 24,
|
|
@@ -489,6 +495,7 @@ exports[`Radio renders as expected when size is medium 1`] = `
|
|
|
489
495
|
"borderRadius": 999,
|
|
490
496
|
"borderWidth": 2,
|
|
491
497
|
"justifyContent": "center",
|
|
498
|
+
"margin": 4,
|
|
492
499
|
},
|
|
493
500
|
Object {
|
|
494
501
|
"height": 20,
|
|
@@ -572,6 +579,7 @@ exports[`Radio renders as expected when size is small 1`] = `
|
|
|
572
579
|
"borderRadius": 999,
|
|
573
580
|
"borderWidth": 2,
|
|
574
581
|
"justifyContent": "center",
|
|
582
|
+
"margin": 4,
|
|
575
583
|
},
|
|
576
584
|
Object {
|
|
577
585
|
"height": 16,
|
|
@@ -655,6 +663,7 @@ exports[`Radio renders as expected with accessibilityRole 1`] = `
|
|
|
655
663
|
"borderRadius": 999,
|
|
656
664
|
"borderWidth": 2,
|
|
657
665
|
"justifyContent": "center",
|
|
666
|
+
"margin": 4,
|
|
658
667
|
},
|
|
659
668
|
Object {
|
|
660
669
|
"height": 20,
|
|
@@ -9,7 +9,7 @@ const ROUNDED_BORDER_RADIUS = 999;
|
|
|
9
9
|
export const getThemedStyles = (theme: StrictTheme): Required<RadioStyles> => {
|
|
10
10
|
const {
|
|
11
11
|
components,
|
|
12
|
-
tokens: { colors, fontSizes, opacities, borderWidths },
|
|
12
|
+
tokens: { colors, fontSizes, opacities, borderWidths, space },
|
|
13
13
|
} = theme;
|
|
14
14
|
|
|
15
15
|
return StyleSheet.create({
|
|
@@ -31,6 +31,7 @@ export const getThemedStyles = (theme: StrictTheme): Required<RadioStyles> => {
|
|
|
31
31
|
borderRadius: ROUNDED_BORDER_RADIUS,
|
|
32
32
|
borderWidth: borderWidths.medium,
|
|
33
33
|
justifyContent: 'center',
|
|
34
|
+
margin: space.xxs,
|
|
34
35
|
...components?.radio?.radioContainer,
|
|
35
36
|
},
|
|
36
37
|
radioDot: {
|