@aws-amplify/ui-react-native 1.2.27 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/Authenticator/Authenticator.d.ts +83 -12
  2. package/dist/Authenticator/Authenticator.js +19 -16
  3. package/dist/Authenticator/Defaults/{ResetPassword/ResetPassword.d.ts → ForgotPassword/ForgotPassword.d.ts} +2 -2
  4. package/dist/Authenticator/Defaults/{ResetPassword/ResetPassword.js → ForgotPassword/ForgotPassword.js} +1 -1
  5. package/dist/Authenticator/Defaults/ForgotPassword/index.d.ts +1 -0
  6. package/dist/Authenticator/Defaults/ForgotPassword/index.js +1 -0
  7. package/dist/Authenticator/Defaults/{SetupTOTP/SetupTOTP.d.ts → SetupTotp/SetupTotp.d.ts} +4 -4
  8. package/dist/Authenticator/Defaults/{SetupTOTP/SetupTOTP.js → SetupTotp/SetupTotp.js} +10 -10
  9. package/dist/Authenticator/Defaults/SetupTotp/index.d.ts +1 -0
  10. package/dist/Authenticator/Defaults/SetupTotp/index.js +1 -0
  11. package/dist/Authenticator/Defaults/SetupTotp/styles.d.ts +5 -0
  12. package/dist/Authenticator/Defaults/SignIn/SignIn.d.ts +1 -1
  13. package/dist/Authenticator/Defaults/SignIn/SignIn.js +6 -5
  14. package/dist/Authenticator/Defaults/SignUp/SignUp.d.ts +1 -1
  15. package/dist/Authenticator/Defaults/SignUp/SignUp.js +4 -3
  16. package/dist/Authenticator/Defaults/index.d.ts +2 -2
  17. package/dist/Authenticator/Defaults/index.js +2 -2
  18. package/dist/Authenticator/Defaults/types.d.ts +11 -11
  19. package/dist/Authenticator/common/FederatedProviderButton/FederatedProviderButton.js +2 -4
  20. package/dist/Authenticator/common/FederatedProviderButton/types.d.ts +3 -1
  21. package/dist/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.d.ts +1 -1
  22. package/dist/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.js +24 -11
  23. package/dist/Authenticator/common/FederatedProviderButtons/styles.d.ts +2 -1
  24. package/dist/Authenticator/common/FederatedProviderButtons/styles.js +14 -4
  25. package/dist/Authenticator/common/FederatedProviderButtons/types.d.ts +5 -3
  26. package/dist/Authenticator/hooks/useFieldValues/useFieldValues.js +1 -1
  27. package/dist/Authenticator/hooks/useFieldValues/utils.js +1 -1
  28. package/dist/Authenticator/types.d.ts +1 -1
  29. package/dist/InAppMessaging/components/InAppMessageDisplay/handleMessageLinkAction.js +2 -2
  30. package/dist/InAppMessaging/hooks/useMessageImage/useMessageImage.d.ts +2 -2
  31. package/dist/InAppMessaging/hooks/useMessageImage/useMessageImage.js +2 -2
  32. package/dist/InAppMessaging/hooks/useMessageImage/utils.d.ts +2 -2
  33. package/dist/InAppMessaging/hooks/useMessageImage/utils.js +2 -2
  34. package/dist/InAppMessaging/hooks/useMessageProps/types.d.ts +2 -2
  35. package/dist/InAppMessaging/hooks/useMessageProps/utils.d.ts +2 -2
  36. package/dist/InAppMessaging/index.d.ts +1 -1
  37. package/dist/InAppMessaging/index.js +1 -0
  38. package/dist/assets/icons/icons.ts +3 -0
  39. package/dist/primitives/Button/styles.js +4 -2
  40. package/dist/primitives/Carousel/Carousel.js +1 -11
  41. package/dist/primitives/Divider/styles.js +4 -3
  42. package/dist/primitives/ErrorMessage/ErrorMessage.d.ts +1 -1
  43. package/dist/primitives/ErrorMessage/ErrorMessage.js +2 -2
  44. package/dist/primitives/Icon/Icon.d.ts +1 -1
  45. package/dist/primitives/Icon/Icon.js +2 -1
  46. package/dist/primitives/Icon/styles.js +1 -1
  47. package/dist/primitives/Radio/styles.js +1 -1
  48. package/dist/primitives/RadioGroup/RadioGroup.d.ts +1 -1
  49. package/dist/primitives/RadioGroup/RadioGroup.js +2 -2
  50. package/dist/primitives/Tabs/Tabs.d.ts +1 -1
  51. package/dist/primitives/Tabs/Tabs.js +2 -2
  52. package/dist/primitives/Tabs/styles.js +3 -3
  53. package/dist/utils/platform.d.ts +1 -2
  54. package/dist/version.d.ts +1 -1
  55. package/dist/version.js +1 -1
  56. package/lib/Authenticator/Authenticator.js +17 -14
  57. package/lib/Authenticator/Defaults/{ResetPassword/ResetPassword.js → ForgotPassword/ForgotPassword.js} +1 -1
  58. package/lib/Authenticator/Defaults/ForgotPassword/index.js +8 -0
  59. package/lib/Authenticator/Defaults/{SetupTOTP/SetupTOTP.js → SetupTotp/SetupTotp.js} +10 -10
  60. package/lib/Authenticator/Defaults/{SetupTOTP → SetupTotp}/index.js +3 -3
  61. package/lib/Authenticator/Defaults/SignIn/SignIn.js +5 -4
  62. package/lib/Authenticator/Defaults/SignUp/SignUp.js +3 -2
  63. package/lib/Authenticator/Defaults/index.js +5 -5
  64. package/lib/Authenticator/common/FederatedProviderButton/FederatedProviderButton.js +2 -4
  65. package/lib/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.js +22 -9
  66. package/lib/Authenticator/common/FederatedProviderButtons/styles.js +16 -5
  67. package/lib/Authenticator/hooks/useFieldValues/useFieldValues.js +8 -8
  68. package/lib/Authenticator/hooks/useFieldValues/utils.js +2 -2
  69. package/lib/InAppMessaging/components/InAppMessageDisplay/handleMessageLinkAction.js +2 -2
  70. package/lib/InAppMessaging/hooks/useMessageImage/types.js +1 -1
  71. package/lib/InAppMessaging/hooks/useMessageImage/useMessageImage.js +5 -5
  72. package/lib/InAppMessaging/hooks/useMessageImage/utils.js +2 -2
  73. package/lib/InAppMessaging/index.js +1 -0
  74. package/lib/assets/icons/icons.ts +3 -0
  75. package/lib/primitives/Button/styles.js +4 -2
  76. package/lib/primitives/Carousel/Carousel.js +1 -11
  77. package/lib/primitives/Divider/styles.js +4 -3
  78. package/lib/primitives/ErrorMessage/ErrorMessage.js +2 -2
  79. package/lib/primitives/Icon/Icon.js +2 -1
  80. package/lib/primitives/Icon/styles.js +2 -2
  81. package/lib/primitives/Radio/styles.js +1 -1
  82. package/lib/primitives/RadioGroup/RadioGroup.js +2 -2
  83. package/lib/primitives/Tabs/Tabs.js +2 -2
  84. package/lib/primitives/Tabs/styles.js +3 -3
  85. package/lib/version.js +1 -1
  86. package/package.json +16 -31
  87. package/src/Authenticator/Authenticator.tsx +20 -17
  88. package/src/Authenticator/Defaults/{ResetPassword/ResetPassword.tsx → ForgotPassword/ForgotPassword.tsx} +3 -3
  89. package/src/Authenticator/Defaults/ForgotPassword/index.ts +1 -0
  90. package/src/Authenticator/Defaults/{SetupTOTP/SetupTOTP.tsx → SetupTotp/SetupTotp.tsx} +13 -13
  91. package/src/Authenticator/Defaults/SetupTotp/index.ts +1 -0
  92. package/src/Authenticator/Defaults/{SetupTOTP → SetupTotp}/styles.ts +2 -2
  93. package/src/Authenticator/Defaults/SignIn/SignIn.tsx +15 -3
  94. package/src/Authenticator/Defaults/SignUp/SignUp.tsx +12 -0
  95. package/src/Authenticator/Defaults/index.ts +2 -2
  96. package/src/Authenticator/Defaults/types.ts +13 -13
  97. package/src/Authenticator/common/FederatedProviderButton/FederatedProviderButton.tsx +2 -4
  98. package/src/Authenticator/common/FederatedProviderButton/types.ts +3 -1
  99. package/src/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.tsx +41 -13
  100. package/src/Authenticator/common/FederatedProviderButtons/styles.ts +19 -4
  101. package/src/Authenticator/common/FederatedProviderButtons/types.ts +9 -6
  102. package/src/Authenticator/hooks/useFieldValues/useFieldValues.ts +1 -1
  103. package/src/Authenticator/hooks/useFieldValues/utils.ts +1 -1
  104. package/src/Authenticator/types.ts +1 -4
  105. package/src/InAppMessaging/components/InAppMessageDisplay/handleMessageLinkAction.ts +2 -2
  106. package/src/InAppMessaging/hooks/useMessageImage/useMessageImage.ts +6 -6
  107. package/src/InAppMessaging/hooks/useMessageImage/utils.ts +5 -5
  108. package/src/InAppMessaging/hooks/useMessageProps/types.ts +3 -3
  109. package/src/InAppMessaging/hooks/useMessageProps/utils.ts +2 -2
  110. package/src/InAppMessaging/index.ts +9 -0
  111. package/src/assets/icons/icons.ts +3 -0
  112. package/src/hooks/useDeviceOrientation/useDeviceOrientation.ts +6 -1
  113. package/src/primitives/Button/styles.ts +4 -2
  114. package/src/primitives/Carousel/Carousel.tsx +1 -10
  115. package/src/primitives/Divider/styles.ts +4 -3
  116. package/src/primitives/ErrorMessage/ErrorMessage.tsx +4 -1
  117. package/src/primitives/Icon/Icon.tsx +2 -0
  118. package/src/primitives/Icon/styles.ts +1 -1
  119. package/src/primitives/Radio/styles.ts +1 -1
  120. package/src/primitives/RadioGroup/RadioGroup.tsx +6 -1
  121. package/src/primitives/Tabs/Tabs.tsx +4 -1
  122. package/src/primitives/Tabs/styles.ts +3 -3
  123. package/src/version.ts +1 -1
  124. package/dist/Authenticator/Defaults/ResetPassword/index.d.ts +0 -1
  125. package/dist/Authenticator/Defaults/ResetPassword/index.js +0 -1
  126. package/dist/Authenticator/Defaults/SetupTOTP/index.d.ts +0 -1
  127. package/dist/Authenticator/Defaults/SetupTOTP/index.js +0 -1
  128. package/dist/Authenticator/Defaults/SetupTOTP/styles.d.ts +0 -5
  129. package/dist/Authenticator/common/FederatedProviderButton/styles.d.ts +0 -2
  130. package/dist/Authenticator/common/FederatedProviderButton/styles.js +0 -18
  131. package/lib/Authenticator/Defaults/ResetPassword/index.js +0 -8
  132. package/lib/Authenticator/common/FederatedProviderButton/styles.js +0 -21
  133. package/src/Authenticator/Defaults/ResetPassword/index.ts +0 -1
  134. package/src/Authenticator/Defaults/SetupTOTP/index.ts +0 -1
  135. package/src/Authenticator/common/FederatedProviderButton/styles.ts +0 -21
  136. /package/dist/Authenticator/Defaults/{SetupTOTP → SetupTotp}/styles.js +0 -0
  137. /package/lib/Authenticator/Defaults/{SetupTOTP → SetupTotp}/styles.js +0 -0
@@ -12,20 +12,20 @@ import {
12
12
  } from '../../common';
13
13
  import { useFieldValues } from '../../hooks';
14
14
 
15
- import { DefaultSetupTOTPProps } from '../types';
15
+ import { DefaultSetupTotpProps } from '../types';
16
16
  import { styles } from './styles';
17
17
 
18
- const COMPONENT_NAME = 'SetupTOTP';
18
+ const COMPONENT_NAME = 'SetupTotp';
19
19
 
20
20
  const {
21
21
  getBackToSignInText,
22
22
  getConfirmingText,
23
23
  getConfirmText,
24
- getSetupTOTPText,
25
- getSetupTOTPInstructionsText,
24
+ getSetupTotpText,
25
+ getSetupTotpInstructionsText,
26
26
  } = authenticatorTextUtil;
27
27
 
28
- const SetupTOTP = ({
28
+ const SetupTotp = ({
29
29
  fields,
30
30
  handleBlur,
31
31
  handleChange,
@@ -35,7 +35,7 @@ const SetupTOTP = ({
35
35
  totpSecretCode,
36
36
  validationErrors,
37
37
  ...rest
38
- }: DefaultSetupTOTPProps): JSX.Element => {
38
+ }: DefaultSetupTotpProps): JSX.Element => {
39
39
  const {
40
40
  disableFormSubmit: disabled,
41
41
  fields: fieldsWithHandlers,
@@ -50,14 +50,14 @@ const SetupTOTP = ({
50
50
  validationErrors,
51
51
  });
52
52
 
53
- const headerText = getSetupTOTPText();
53
+ const headerText = getSetupTotpText();
54
54
  const primaryButtonText = isPending ? getConfirmingText() : getConfirmText();
55
55
  const secondaryButtonText = getBackToSignInText();
56
56
 
57
57
  const body = (
58
58
  <>
59
59
  <Label style={styles.secretKeyText}>
60
- {getSetupTOTPInstructionsText()}
60
+ {getSetupTotpInstructionsText()}
61
61
  </Label>
62
62
  <Label selectable style={styles.secretKeyText}>
63
63
  {totpSecretCode}
@@ -96,9 +96,9 @@ const SetupTOTP = ({
96
96
  );
97
97
  };
98
98
 
99
- SetupTOTP.Footer = DefaultFooter;
100
- SetupTOTP.FormFields = DefaultTextFormFields;
101
- SetupTOTP.Header = DefaultHeader;
99
+ SetupTotp.Footer = DefaultFooter;
100
+ SetupTotp.FormFields = DefaultTextFormFields;
101
+ SetupTotp.Header = DefaultHeader;
102
102
 
103
- SetupTOTP.displayName = COMPONENT_NAME;
104
- export default SetupTOTP;
103
+ SetupTotp.displayName = COMPONENT_NAME;
104
+ export default SetupTotp;
@@ -0,0 +1 @@
1
+ export { default as SetupTotp } from './SetupTotp';
@@ -1,10 +1,10 @@
1
1
  import { StyleSheet, TextStyle } from 'react-native';
2
2
 
3
- export interface SetupTOTPStyle {
3
+ export interface SetupTotpStyle {
4
4
  secretKeyText: TextStyle;
5
5
  }
6
6
 
7
- export const styles: SetupTOTPStyle = StyleSheet.create({
7
+ export const styles: SetupTotpStyle = StyleSheet.create({
8
8
  // TODO: replace with tokens
9
9
  secretKeyText: { flexWrap: 'wrap', paddingVertical: 4, marginHorizontal: 8 },
10
10
  });
@@ -6,6 +6,7 @@ import {
6
6
  DefaultTextFormFields,
7
7
  DefaultHeader,
8
8
  DefaultContent,
9
+ FederatedProviderButtons,
9
10
  } from '../../common';
10
11
  import { useFieldValues } from '../../hooks';
11
12
 
@@ -19,7 +20,9 @@ const SignIn = ({
19
20
  handleChange,
20
21
  handleSubmit,
21
22
  hideSignUp,
22
- toResetPassword,
23
+ socialProviders,
24
+ toFederatedSignIn,
25
+ toForgotPassword,
23
26
  toSignUp,
24
27
  validationErrors,
25
28
  ...rest
@@ -50,10 +53,18 @@ const SignIn = ({
50
53
  const signInText = getSignInText();
51
54
  const signUpText = getSignUpTabText();
52
55
 
56
+ const body = socialProviders ? (
57
+ <FederatedProviderButtons
58
+ route="signIn"
59
+ socialProviders={socialProviders}
60
+ toFederatedSignIn={toFederatedSignIn}
61
+ />
62
+ ) : null;
63
+
53
64
  const buttons = useMemo(() => {
54
65
  const forgotPassword = {
55
66
  children: forgotPasswordText,
56
- onPress: toResetPassword,
67
+ onPress: toForgotPassword,
57
68
  };
58
69
  return {
59
70
  primary: { children: signInText, disabled, onPress: handleFormSubmit },
@@ -68,13 +79,14 @@ const SignIn = ({
68
79
  hideSignUp,
69
80
  signInText,
70
81
  signUpText,
71
- toResetPassword,
82
+ toForgotPassword,
72
83
  toSignUp,
73
84
  ]);
74
85
 
75
86
  return (
76
87
  <DefaultContent
77
88
  {...rest}
89
+ body={body}
78
90
  buttons={buttons}
79
91
  fields={fieldsWithHandlers}
80
92
  headerText={headerText}
@@ -6,6 +6,7 @@ import {
6
6
  DefaultFooter,
7
7
  DefaultTextFormFields,
8
8
  DefaultHeader,
9
+ FederatedProviderButtons,
9
10
  } from '../../common';
10
11
  import { useFieldValues } from '../../hooks';
11
12
 
@@ -28,6 +29,8 @@ const SignUp = ({
28
29
  hasValidationErrors,
29
30
  hideSignIn,
30
31
  isPending,
32
+ socialProviders,
33
+ toFederatedSignIn,
31
34
  toSignIn,
32
35
  validationErrors,
33
36
  ...rest
@@ -53,6 +56,14 @@ const SignUp = ({
53
56
  : getCreateAccountText();
54
57
  const secondaryButtonText = getSignInTabText();
55
58
 
59
+ const body = socialProviders ? (
60
+ <FederatedProviderButtons
61
+ route="signUp"
62
+ socialProviders={socialProviders}
63
+ toFederatedSignIn={toFederatedSignIn}
64
+ />
65
+ ) : null;
66
+
56
67
  const buttons = useMemo(
57
68
  () => ({
58
69
  primary: {
@@ -77,6 +88,7 @@ const SignUp = ({
77
88
  return (
78
89
  <DefaultContent
79
90
  {...rest}
91
+ body={body}
80
92
  buttons={buttons}
81
93
  fields={fieldsWithHandlers}
82
94
  headerText={headerText}
@@ -3,8 +3,8 @@ export { ConfirmSignIn } from './ConfirmSignIn';
3
3
  export { ConfirmSignUp } from './ConfirmSignUp';
4
4
  export { ConfirmVerifyUser } from './ConfirmVerifyUser';
5
5
  export { ForceNewPassword } from './ForceNewPassword';
6
- export { ResetPassword } from './ResetPassword';
7
- export { SetupTOTP } from './SetupTOTP';
6
+ export { ForgotPassword } from './ForgotPassword';
7
+ export { SetupTotp } from './SetupTotp';
8
8
  export { SignIn } from './SignIn';
9
9
  export { SignUp } from './SignUp';
10
10
  export { VerifyUser } from './VerifyUser';
@@ -11,14 +11,14 @@ export interface ConfirmSignUpStyle {}
11
11
  export interface ConfirmVerifyUserStyle {}
12
12
  export interface ForceNewPasswordStyle {}
13
13
  export interface ResetPasswordStyle {}
14
- export interface SetupTOTPStyle {}
14
+ export interface SetupTotpStyle {}
15
15
  export interface SignInStyle {}
16
16
  export interface SignUpStyle {}
17
17
  export interface VerifyUserStyle {}
18
18
 
19
19
  export type DefaultComponents<
20
20
  FieldType = {},
21
- Props = {}
21
+ Props = {},
22
22
  > = AuthenticatorComponentDefaults<FieldType, Props>;
23
23
 
24
24
  export type DefaultConfirmResetPasswordProps = React.ComponentPropsWithoutRef<
@@ -56,18 +56,18 @@ export type DefaultForceNewPasswordProps = React.ComponentPropsWithoutRef<
56
56
  >['ForceNewPassword']
57
57
  >;
58
58
 
59
- export type DefaultResetPasswordProps = React.ComponentPropsWithoutRef<
59
+ export type DefaultForgotPasswordProps = React.ComponentPropsWithoutRef<
60
60
  DefaultComponents<
61
61
  TextFieldOptionsType,
62
62
  { style?: ResetPasswordStyle }
63
- >['ResetPassword']
63
+ >['ForgotPassword']
64
64
  >;
65
65
 
66
- export type DefaultSetupTOTPProps = React.ComponentPropsWithoutRef<
66
+ export type DefaultSetupTotpProps = React.ComponentPropsWithoutRef<
67
67
  DefaultComponents<
68
68
  TextFieldOptionsType,
69
- { style?: SetupTOTPStyle }
70
- >['SetupTOTP']
69
+ { style?: SetupTotpStyle }
70
+ >['SetupTotp']
71
71
  >;
72
72
 
73
73
  export type DefaultSignInProps = React.ComponentPropsWithoutRef<
@@ -90,7 +90,7 @@ export type DefaultVerifyUserProps = React.ComponentPropsWithoutRef<
90
90
  */
91
91
  type OverrideComponents<
92
92
  FieldType = {},
93
- Props = {}
93
+ Props = {},
94
94
  > = AuthenticatorComponentOverrides<FieldType, Props>;
95
95
 
96
96
  type ConfirmSignInComponent<P = {}> = OverrideComponents<
@@ -121,12 +121,12 @@ type ForceNewPasswordComponent<P = {}> = OverrideComponents<
121
121
  type ResetPasswordComponent<P = {}> = OverrideComponents<
122
122
  TextFieldOptionsType,
123
123
  { style?: ResetPasswordStyle } & P
124
- >['ResetPassword'];
124
+ >['ForgotPassword'];
125
125
 
126
- type SetupTOTPComponent<P = {}> = OverrideComponents<
126
+ type SetupTotpComponent<P = {}> = OverrideComponents<
127
127
  TextFieldOptionsType,
128
- { style?: SetupTOTPStyle } & P
129
- >['SetupTOTP'];
128
+ { style?: SetupTotpStyle } & P
129
+ >['SetupTotp'];
130
130
 
131
131
  type SignInComponent<P = {}> = OverrideComponents<
132
132
  TextFieldOptionsType,
@@ -153,7 +153,7 @@ export interface Components {
153
153
  ConfirmVerifyUser?: ConfirmVerifyUserComponent;
154
154
  ForceNewPassword?: ForceNewPasswordComponent;
155
155
  ResetPassword?: ResetPasswordComponent;
156
- SetupTOTP?: SetupTOTPComponent;
156
+ SetupTotp?: SetupTotpComponent;
157
157
  SignIn?: SignInComponent;
158
158
  SignUp?: SignUpComponent;
159
159
  VerifyUser?: VerifyUserComponent;
@@ -3,7 +3,6 @@ import React from 'react';
3
3
  import { Button, Icon, Label } from '../../../primitives';
4
4
  import { usePressableContainerStyles } from '../../../hooks';
5
5
 
6
- import { styles } from './styles';
7
6
  import { FederatedProviderButtonProps } from './types';
8
7
 
9
8
  export default function FederatedProviderButton({
@@ -14,14 +13,13 @@ export default function FederatedProviderButton({
14
13
  ...rest
15
14
  }: FederatedProviderButtonProps): JSX.Element {
16
15
  const pressableStyle = usePressableContainerStyles({
17
- containerStyle: styles.container,
18
16
  overrideStyle: style,
19
17
  });
20
18
 
21
19
  return (
22
20
  <Button {...rest} style={pressableStyle}>
23
- <Icon source={source} style={styles.icon} size={20} />
24
- <Label style={[styles.label, textStyle]}>{children}</Label>
21
+ <Icon source={source} size={20} />
22
+ <Label style={textStyle}>{children}</Label>
25
23
  </Button>
26
24
  );
27
25
  }
@@ -7,7 +7,9 @@ import {
7
7
 
8
8
  import { ButtonProps } from '../../../primitives';
9
9
 
10
- export interface FederatedProviderButtonProps extends ButtonProps {
10
+ export interface FederatedProviderButtonProps
11
+ extends Omit<ButtonProps, 'children'> {
12
+ children?: React.ReactNode;
11
13
  source: ImageSourcePropType;
12
14
  }
13
15
 
@@ -1,25 +1,48 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { View } from 'react-native';
3
- import { capitalize } from '@aws-amplify/ui';
3
+ import { signInWithRedirect } from 'aws-amplify/auth';
4
4
 
5
- import { icons } from '../../../assets';
6
- import { FederatedProviderButton } from '../FederatedProviderButton';
7
- import { Divider } from '../../../primitives';
5
+ import {
6
+ SocialProvider,
7
+ authenticatorTextUtil,
8
+ capitalize,
9
+ } from '@aws-amplify/ui';
8
10
 
9
- import { styles } from './styles';
11
+ import { Divider } from '../../../primitives';
12
+ import { useTheme } from '../../../theme';
13
+ import { FederatedProviderButton } from '../FederatedProviderButton';
10
14
  import { FederatedProviderButtonsProps } from './types';
15
+ import { icons } from '../../../assets';
16
+ import { getThemedStyles } from './styles';
17
+
18
+ const { getSignInWithFederationText, getOrText } = authenticatorTextUtil;
19
+
20
+ // use `signInWithRedirect` directly instead of `toFederatedSignIn`
21
+ // exposed on `useAuthenticator` for RN. `@aws-amplify/rtn-web-browser`
22
+ // does not emit an event on federated sign in flow cancellation,
23
+ // preventing the `Authenticator` from updating state and leaving the
24
+ // UI in a "pending" state
25
+ const handleSignInWithRedirect = (
26
+ provider: 'amazon' | 'apple' | 'facebook' | 'google'
27
+ ) => signInWithRedirect({ provider: capitalize(provider) });
11
28
 
12
29
  export default function FederatedProviderButtons({
30
+ buttonStyle,
31
+ dividerLabelStyle,
32
+ route,
13
33
  socialProviders,
14
- toFederatedSignIn,
34
+ style,
15
35
  }: FederatedProviderButtonsProps): JSX.Element | null {
36
+ const theme = useTheme();
37
+ const themedStyle = getThemedStyles(theme);
38
+
16
39
  const providerButtons = useMemo(
17
40
  () =>
18
- socialProviders?.map((provider) => {
41
+ socialProviders?.map((provider: SocialProvider) => {
19
42
  const providerIconSource = icons[`${provider}Logo`];
20
43
 
21
44
  const handlePress = () => {
22
- toFederatedSignIn({ provider });
45
+ handleSignInWithRedirect(provider);
23
46
  };
24
47
 
25
48
  return (
@@ -27,19 +50,24 @@ export default function FederatedProviderButtons({
27
50
  key={provider}
28
51
  onPress={handlePress}
29
52
  source={providerIconSource}
30
- style={styles.button}
53
+ style={[themedStyle.button, buttonStyle]}
31
54
  >
32
- {`Sign In with ${capitalize(provider)}`}
55
+ {getSignInWithFederationText(route, provider)}
33
56
  </FederatedProviderButton>
34
57
  );
35
58
  }),
36
- [socialProviders, toFederatedSignIn]
59
+ [route, socialProviders, themedStyle, buttonStyle]
37
60
  );
38
61
 
39
62
  return providerButtons?.length ? (
40
- <View style={styles.container}>
63
+ <View
64
+ style={[themedStyle.container, style]}
65
+ testID="amplify__federated-provider-buttons"
66
+ >
41
67
  {providerButtons}
42
- <Divider labelStyle={styles.text}>Or</Divider>
68
+ <Divider labelStyle={[themedStyle.dividerLabel, dividerLabelStyle]}>
69
+ {getOrText()}
70
+ </Divider>
43
71
  </View>
44
72
  ) : null;
45
73
  }
@@ -1,7 +1,22 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ import { StrictTheme } from '../../../theme';
1
4
  import { FederatedProviderButtonStyle } from './types';
2
5
 
3
- export const styles: FederatedProviderButtonStyle = {
4
- button: { marginVertical: 8 },
5
- container: { paddingVertical: 4 },
6
- text: { paddingVertical: 8, textAlign: 'center' },
6
+ export const getThemedStyles = (
7
+ theme: StrictTheme
8
+ ): FederatedProviderButtonStyle => {
9
+ const { space } = theme.tokens;
10
+
11
+ return StyleSheet.create({
12
+ button: {
13
+ marginVertical: space.xs,
14
+ },
15
+ dividerLabel: {
16
+ textAlign: 'center',
17
+ },
18
+ container: {
19
+ marginHorizontal: space.small,
20
+ },
21
+ });
7
22
  };
@@ -1,16 +1,19 @@
1
- import { TextStyle, ViewStyle } from 'react-native';
1
+ import { StyleProp, TextStyle, ViewProps, ViewStyle } from 'react-native';
2
2
 
3
3
  import { AuthenticatorMachineContext } from '@aws-amplify/ui-react-core';
4
4
 
5
- // TODO extend from ViewProps, add button style related style props
6
5
  export interface FederatedProviderButtonsProps
7
6
  extends Pick<
8
- AuthenticatorMachineContext,
9
- 'socialProviders' | 'toFederatedSignIn'
10
- > {}
7
+ AuthenticatorMachineContext,
8
+ 'route' | 'socialProviders' | 'toFederatedSignIn'
9
+ >,
10
+ ViewProps {
11
+ buttonStyle?: StyleProp<ViewStyle>;
12
+ dividerLabelStyle?: StyleProp<TextStyle>;
13
+ }
11
14
 
12
15
  export interface FederatedProviderButtonStyle {
13
16
  button: ViewStyle;
14
17
  container: ViewStyle;
15
- text: TextStyle;
18
+ dividerLabel: TextStyle;
16
19
  }
@@ -1,5 +1,5 @@
1
1
  import { useMemo, useState } from 'react';
2
- import { Logger } from 'aws-amplify';
2
+ import { ConsoleLogger as Logger } from 'aws-amplify/utils';
3
3
  import { ValidationError } from '@aws-amplify/ui';
4
4
 
5
5
  import { OnChangeText, TextFieldOnBlur, TypedField } from '../types';
@@ -1,4 +1,4 @@
1
- import { Logger } from 'aws-amplify';
1
+ import { ConsoleLogger as Logger } from 'aws-amplify/utils';
2
2
  import {
3
3
  authenticatorTextUtil,
4
4
  isString,
@@ -7,11 +7,8 @@ import { Components } from './Defaults';
7
7
 
8
8
  type SupportedAuthenticatorMachineOptions = Omit<
9
9
  AuthenticatorMachineOptions,
10
- // `socialProviders` not supported as a prop,
11
- // feature is not enabled in React Native `Authenticator`
12
- | 'socialProviders'
13
10
  // `formFields` prop in RWA is to be deprecated
14
- | 'formFields'
11
+ 'formFields'
15
12
  >;
16
13
 
17
14
  export interface AuthenticatorProps
@@ -1,8 +1,8 @@
1
1
  import { Linking } from 'react-native';
2
- import { ConsoleLogger as Logger } from '@aws-amplify/core';
2
+ import { ConsoleLogger as Logger } from 'aws-amplify/utils';
3
3
  import { HandleMessageLinkAction } from '@aws-amplify/ui-react-core-notifications';
4
4
 
5
- const logger = new Logger('Notifications.InAppMessaging');
5
+ const logger = new Logger('InAppMessaging');
6
6
 
7
7
  const handleMessageLinkAction: HandleMessageLinkAction = async (
8
8
  url: string
@@ -1,16 +1,16 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
2
  import { Image } from 'react-native';
3
+ import { ConsoleLogger as Logger } from 'aws-amplify/utils';
3
4
 
4
- import { ConsoleLogger as Logger } from '@aws-amplify/core';
5
5
  import {
6
- MessageImage,
7
- MessageLayout,
6
+ InAppMessageImage,
7
+ InAppMessageLayout,
8
8
  } from '@aws-amplify/ui-react-core-notifications';
9
9
 
10
10
  import { ImageDimensions, ImagePrefetchStatus, UseMessageImage } from './types';
11
11
  import { getLayoutImageDimensions, prefetchNetworkImage } from './utils';
12
12
 
13
- const logger = new Logger('Notifications.InAppMessaging');
13
+ const logger = new Logger('InAppMessaging');
14
14
 
15
15
  /**
16
16
  * Handles prefetching and dimension setting for message images
@@ -20,8 +20,8 @@ const logger = new Logger('Notifications.InAppMessaging');
20
20
  * @returns message image dimensions and rendering related booleans
21
21
  */
22
22
  export default function useMessageImage(
23
- image: MessageImage | undefined,
24
- layout: MessageLayout
23
+ image: InAppMessageImage | undefined,
24
+ layout: InAppMessageLayout
25
25
  ): UseMessageImage {
26
26
  const { src } = image ?? {};
27
27
  const shouldPrefetch = !!src;
@@ -1,6 +1,6 @@
1
1
  import { Image } from 'react-native';
2
- import { ConsoleLogger as Logger } from '@aws-amplify/core';
3
- import { MessageLayout } from '@aws-amplify/ui-react-core-notifications';
2
+ import { ConsoleLogger as Logger } from 'aws-amplify/utils';
3
+ import { InAppMessageLayout } from '@aws-amplify/ui-react-core-notifications';
4
4
 
5
5
  import {
6
6
  BANNER_IMAGE_SCREEN_SIZE,
@@ -10,9 +10,9 @@ import {
10
10
  } from './constants';
11
11
  import { ImageDimensions, ImageLoadingState } from './types';
12
12
 
13
- const logger = new Logger('Notifications.InAppMessaging');
13
+ const logger = new Logger('InAppMessaging');
14
14
 
15
- const inAppMessageImageSizes: Record<MessageLayout, number> = {
15
+ const inAppMessageImageSizes: Record<InAppMessageLayout, number> = {
16
16
  BOTTOM_BANNER: BANNER_IMAGE_SCREEN_SIZE,
17
17
  MIDDLE_BANNER: BANNER_IMAGE_SCREEN_SIZE,
18
18
  TOP_BANNER: BANNER_IMAGE_SCREEN_SIZE,
@@ -41,7 +41,7 @@ export const prefetchNetworkImage = async (
41
41
  export const getLayoutImageDimensions = (
42
42
  imageHeight: number,
43
43
  imageWidth: number,
44
- layout: MessageLayout
44
+ layout: InAppMessageLayout
45
45
  ): ImageDimensions => {
46
46
  // determine aspect ratio for scaling rendered image
47
47
  const aspectRatio = imageWidth / imageHeight;
@@ -6,7 +6,7 @@ import {
6
6
  ViewStyle,
7
7
  } from 'react-native';
8
8
  import {
9
- MessageLayout,
9
+ InAppMessageLayout,
10
10
  MessagePayloadStyle,
11
11
  } from '@aws-amplify/ui-react-core-notifications';
12
12
 
@@ -50,7 +50,7 @@ export interface MessageStyleParams {
50
50
  /**
51
51
  * message specific layout
52
52
  */
53
- layout: MessageLayout;
53
+ layout: InAppMessageLayout;
54
54
 
55
55
  /**
56
56
  * style params to derive resolved style from
@@ -114,7 +114,7 @@ export interface MessageContainerAndWrapperStyle {
114
114
  container: [
115
115
  defaultStyle: StyleProp<ViewStyle>,
116
116
  messageStyle: StyleProp<ViewStyle>,
117
- overrideStyle: StyleProp<ViewStyle>
117
+ overrideStyle: StyleProp<ViewStyle>,
118
118
  ];
119
119
  wrapper: StyleProp<ViewStyle>;
120
120
  }
@@ -1,8 +1,8 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
  import { isFunction } from '@aws-amplify/ui';
3
3
  import {
4
+ InAppMessageLayout,
4
5
  MessageComponentBaseProps,
5
- MessageLayout,
6
6
  MessagePayloadStyle,
7
7
  } from '@aws-amplify/ui-react-core-notifications';
8
8
 
@@ -87,7 +87,7 @@ export const getComponentButtonStyle = ({
87
87
  * @returns {Boolean} boolean indicating whether entire screen should be filled
88
88
  */
89
89
 
90
- export const shouldFillDeviceScreen = (layout: MessageLayout): boolean => {
90
+ export const shouldFillDeviceScreen = (layout: InAppMessageLayout): boolean => {
91
91
  switch (layout) {
92
92
  case 'CAROUSEL':
93
93
  case 'FULL_SCREEN': {
@@ -1,5 +1,14 @@
1
+ // re-export in-app types from '@aws-amplify/ui-react-core-notifications'
1
2
  export {
3
+ InAppMessage,
4
+ InAppMessageAction,
5
+ InAppMessageButton,
6
+ InAppMessageContent,
7
+ InAppMessageImage,
8
+ InAppMessageLayout,
2
9
  InAppMessagingProvider,
10
+ InAppMessageStyle,
11
+ InAppMessageTextAlign,
3
12
  useInAppMessaging,
4
13
  } from '@aws-amplify/ui-react-core-notifications';
5
14
 
@@ -1,3 +1,6 @@
1
+ // disable `@typescript-eslint/no-var-requires` for this file
2
+ // .png icons will be removed in favor of .svg icons
3
+ /* eslint-disable @typescript-eslint/no-var-requires */
1
4
  import { ImageSourcePropType } from 'react-native';
2
5
 
3
6
  const icons = {
@@ -40,7 +40,12 @@ export default function useDeviceOrientation(): {
40
40
  if (isFunction(subscription?.remove)) {
41
41
  subscription.remove();
42
42
  } else {
43
- Dimensions.removeEventListener('change', handler);
43
+ (
44
+ Dimensions as unknown as {
45
+ // @todo-migration remove below, no longer needed
46
+ removeEventListener: (event: 'change', handler: () => void) => void;
47
+ }
48
+ ).removeEventListener('change', handler);
44
49
  }
45
50
  };
46
51
  }, []);
@@ -18,8 +18,10 @@ export const getThemedStyles = (theme: StrictTheme): ButtonStyles => {
18
18
  return StyleSheet.create({
19
19
  container: {
20
20
  alignItems: 'center',
21
- backgroundColor: colors.transparent,
22
21
  justifyContent: 'center',
22
+ flexDirection: 'row',
23
+ gap: space.small,
24
+ backgroundColor: colors.transparent,
23
25
  paddingVertical: space.small,
24
26
  paddingHorizontal: space.medium,
25
27
  borderRadius: radii.small,
@@ -31,7 +33,7 @@ export const getThemedStyles = (theme: StrictTheme): ButtonStyles => {
31
33
  ...components?.button?.containerDefault,
32
34
  },
33
35
  containerPrimary: {
34
- backgroundColor: colors.brand.primary[80],
36
+ backgroundColor: colors.primary[80],
35
37
  ...components?.button?.containerPrimary,
36
38
  },
37
39
  containerLink: {