@aws-amplify/ui-react-native 1.1.3 → 1.2.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 (77) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/Authenticator/Authenticator.js +8 -0
  3. package/dist/Authenticator/common/DefaultContent/DefaultContent.js +1 -1
  4. package/dist/Authenticator/common/DefaultContent/styles.js +2 -1
  5. package/dist/Authenticator/common/DefaultContent/types.d.ts +2 -1
  6. package/dist/Authenticator/common/FederatedProviderButton/FederatedProviderButton.js +8 -7
  7. package/dist/hooks/index.d.ts +1 -0
  8. package/dist/hooks/index.js +1 -0
  9. package/dist/hooks/usePressableContainerStyles/index.d.ts +1 -0
  10. package/dist/hooks/usePressableContainerStyles/index.js +1 -0
  11. package/dist/hooks/usePressableContainerStyles/usePressableContainerStyles.d.ts +19 -0
  12. package/dist/hooks/usePressableContainerStyles/usePressableContainerStyles.js +14 -0
  13. package/dist/primitives/Button/Button.js +13 -12
  14. package/dist/primitives/ErrorMessage/ErrorMessage.d.ts +1 -1
  15. package/dist/primitives/ErrorMessage/ErrorMessage.js +2 -2
  16. package/dist/primitives/ErrorMessage/styles.js +4 -2
  17. package/dist/primitives/ErrorMessage/types.d.ts +2 -0
  18. package/dist/primitives/IconButton/IconButton.js +12 -11
  19. package/dist/primitives/Radio/Radio.js +12 -10
  20. package/dist/primitives/Radio/styles.js +4 -0
  21. package/dist/primitives/Radio/types.d.ts +1 -0
  22. package/dist/primitives/Tabs/Tab.js +13 -13
  23. package/dist/primitives/Tabs/styles.js +4 -0
  24. package/dist/primitives/Tabs/types.d.ts +1 -0
  25. package/dist/version.d.ts +1 -0
  26. package/dist/version.js +1 -0
  27. package/package.json +3 -3
  28. package/src/Authenticator/Authenticator.tsx +10 -0
  29. package/src/Authenticator/Defaults/ConfirmResetPassword/__tests__/__snapshots__/ConfirmResetPassword.spec.tsx.snap +24 -37
  30. package/src/Authenticator/Defaults/ConfirmSignIn/__tests__/__snapshots__/ConfirmSignIn.spec.tsx.snap +16 -23
  31. package/src/Authenticator/Defaults/ConfirmSignUp/__tests__/__snapshots__/ConfirmSignUp.spec.tsx.snap +25 -41
  32. package/src/Authenticator/Defaults/ConfirmVerifyUser/__tests__/__snapshots__/ConfirmVerifyUser.spec.tsx.snap +19 -32
  33. package/src/Authenticator/Defaults/ForceNewPassword/__tests__/__snapshots__/ForceNewPassword.spec.tsx.snap +22 -38
  34. package/src/Authenticator/Defaults/ResetPassword/__tests__/__snapshots__/ResetPassword.spec.tsx.snap +16 -23
  35. package/src/Authenticator/Defaults/SetupTOTP/__tests__/__snapshots__/SetupTOTP.spec.tsx.snap +16 -23
  36. package/src/Authenticator/Defaults/SignIn/__tests__/__snapshots__/SignIn.spec.tsx.snap +24 -44
  37. package/src/Authenticator/Defaults/SignUp/__tests__/__snapshots__/SignUp.spec.tsx.snap +34 -67
  38. package/src/Authenticator/Defaults/VerifyUser/__tests__/__snapshots__/VerifyUser.spec.tsx.snap +20 -23
  39. package/src/Authenticator/common/DefaultContainer/__tests__/__snapshots__/DefaultContainer.spec.tsx.snap +3 -6
  40. package/src/Authenticator/common/DefaultContent/DefaultContent.tsx +2 -1
  41. package/src/Authenticator/common/DefaultContent/styles.ts +2 -1
  42. package/src/Authenticator/common/DefaultContent/types.ts +2 -1
  43. package/src/Authenticator/common/DefaultFooter/__tests__/__snapshots__/DefaultFooter.spec.tsx.snap +3 -6
  44. package/src/Authenticator/common/FederatedProviderButton/FederatedProviderButton.tsx +8 -12
  45. package/src/Authenticator/common/FederatedProviderButton/__tests__/FederatedProviderButton.spec.tsx +34 -3
  46. package/src/Authenticator/common/FederatedProviderButton/__tests__/__snapshots__/FederatedProviderButton.spec.tsx.snap +94 -3
  47. package/src/Authenticator/common/FederatedProviderButtons/__tests__/__snapshots__/FederatedProviderButtons.spec.tsx.snap +4 -6
  48. package/src/InAppMessaging/components/BannerMessage/__tests__/__snapshots__/BannerMessage.spec.tsx.snap +2 -4
  49. package/src/InAppMessaging/components/ModalMessage/__tests__/ModalMessage.spec.tsx +1 -1
  50. package/src/InAppMessaging/components/ModalMessage/__tests__/__snapshots__/ModalMessage.spec.tsx.snap +3 -6
  51. package/src/hooks/index.ts +1 -0
  52. package/src/hooks/usePressableContainerStyles/__tests__/usePressableContainerStyles.spec.ts +68 -0
  53. package/src/hooks/usePressableContainerStyles/index.ts +1 -0
  54. package/src/hooks/usePressableContainerStyles/usePressableContainerStyles.ts +51 -0
  55. package/src/primitives/Button/Button.tsx +16 -23
  56. package/src/primitives/Button/__tests__/__snapshots__/Button.spec.tsx.snap +9 -18
  57. package/src/primitives/ErrorMessage/ErrorMessage.tsx +6 -1
  58. package/src/primitives/ErrorMessage/__tests__/__snapshots__/ErrorMessage.spec.tsx.snap +18 -8
  59. package/src/primitives/ErrorMessage/styles.ts +4 -2
  60. package/src/primitives/ErrorMessage/types.ts +3 -0
  61. package/src/primitives/IconButton/IconButton.tsx +16 -19
  62. package/src/primitives/IconButton/__tests__/IconButton.spec.tsx +6 -6
  63. package/src/primitives/IconButton/__tests__/__snapshots__/IconButton.spec.tsx.snap +4 -8
  64. package/src/primitives/PasswordField/__tests__/__snapshots__/PasswordField.spec.tsx.snap +4 -8
  65. package/src/primitives/Radio/Radio.tsx +15 -16
  66. package/src/primitives/Radio/__tests__/Radio.spec.tsx +1 -0
  67. package/src/primitives/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +9 -0
  68. package/src/primitives/Radio/styles.ts +4 -0
  69. package/src/primitives/Radio/types.ts +1 -0
  70. package/src/primitives/RadioGroup/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +24 -0
  71. package/src/primitives/Tabs/Tab.tsx +17 -18
  72. package/src/primitives/Tabs/__tests__/Tab.spec.tsx +20 -13
  73. package/src/primitives/Tabs/__tests__/__snapshots__/Tab.spec.tsx.snap +23 -43
  74. package/src/primitives/Tabs/__tests__/__snapshots__/Tabs.spec.tsx.snap +14 -26
  75. package/src/primitives/Tabs/styles.ts +4 -0
  76. package/src/primitives/Tabs/types.ts +1 -0
  77. package/src/version.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @aws-amplify/ui-react-native
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#3158](https://github.com/aws-amplify/amplify-ui/pull/3158) [`0bbb9980c`](https://github.com/aws-amplify/amplify-ui/commit/0bbb9980c55f212ce54c5449a2dcc64bfce6ca8f) Thanks [@nandanbhat](https://github.com/nandanbhat)! - feat(Authenticator): Enable password validation on resetPassword and forceNewPassword screen
8
+
9
+ ### Patch Changes
10
+
11
+ - [#2830](https://github.com/aws-amplify/amplify-ui/pull/2830) [`168185211`](https://github.com/aws-amplify/amplify-ui/commit/1681852112748717e44d199d0c62de83ab1541ca) Thanks [@dbanksdesign](https://github.com/dbanksdesign)! - chore(authenticator): adding package version to cognito user agent string
12
+
13
+ - Updated dependencies [[`0bbb9980c`](https://github.com/aws-amplify/amplify-ui/commit/0bbb9980c55f212ce54c5449a2dcc64bfce6ca8f), [`168185211`](https://github.com/aws-amplify/amplify-ui/commit/1681852112748717e44d199d0c62de83ab1541ca)]:
14
+ - @aws-amplify/ui@5.4.0
15
+ - @aws-amplify/ui-react-core@2.1.5
16
+
17
+ ## 1.1.4
18
+
19
+ ### Patch Changes
20
+
21
+ - [#3164](https://github.com/aws-amplify/amplify-ui/pull/3164) [`7f99d8b1a`](https://github.com/aws-amplify/amplify-ui/commit/7f99d8b1a16b23c180c42a11a9bc992b5c4f2861) Thanks [@calebpollman](https://github.com/calebpollman)! - fix(ui-react-native): update ErrorMessage style
22
+
23
+ - [#2921](https://github.com/aws-amplify/amplify-ui/pull/2921) [`2d0799002`](https://github.com/aws-amplify/amplify-ui/commit/2d0799002dbfa843a1720c2384eadba942333f76) Thanks [@ioanabrooks](https://github.com/ioanabrooks)! - chore(ui-react-native): Add utility hook for pressable styles
24
+
25
+ - Updated dependencies [[`c31a9bf69`](https://github.com/aws-amplify/amplify-ui/commit/c31a9bf693b3507e8a2b9d0790423a9f64e533cf), [`1847840c0`](https://github.com/aws-amplify/amplify-ui/commit/1847840c00c0f9f7be31e9735c31bd596f4056e9)]:
26
+ - @aws-amplify/ui@5.3.1
27
+ - @aws-amplify/ui-react-core@2.1.4
28
+
3
29
  ## 1.1.3
4
30
 
5
31
  ### Patch Changes
@@ -1,8 +1,10 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { SafeAreaProvider } from 'react-native-safe-area-context';
3
3
  import { AuthenticatorProvider as Provider, resolveAuthenticatorComponents, useAuthenticator, useAuthenticatorRoute, useAuthenticatorInitMachine, } from '@aws-amplify/ui-react-core';
4
+ import { configureComponent } from '@aws-amplify/ui';
4
5
  import { DefaultContainer, InnerContainer } from './common';
5
6
  import { getRouteTypedFields } from './hooks';
7
+ import { VERSION } from '../version';
6
8
  import { ConfirmResetPassword, ConfirmSignIn, ConfirmSignUp, ConfirmVerifyUser, ForceNewPassword, ResetPassword, SetupTOTP, SignIn, SignUp, VerifyUser, } from './Defaults';
7
9
  const DEFAULTS = {
8
10
  ConfirmResetPassword,
@@ -21,6 +23,12 @@ const routePropSelector = ({ route, }) => [
21
23
  route,
22
24
  ];
23
25
  function Authenticator({ children, components: overrides, Container = DefaultContainer, Footer, Header, ...options }) {
26
+ React.useEffect(() => {
27
+ configureComponent({
28
+ packageName: '@aws-amplify/ui-react-native',
29
+ version: VERSION,
30
+ });
31
+ }, []);
24
32
  useAuthenticatorInitMachine(options);
25
33
  const { fields, route } = useAuthenticator(routePropSelector);
26
34
  const components = useMemo(
@@ -18,7 +18,7 @@ export default function DefaultContent({ body, buttons: { primary, links, second
18
18
  <Header style={themedStyles.header}>{headerText}</Header>
19
19
  {body ? (typeof body === 'string' ? (<Label style={themedStyles.body}>{body}</Label>) : (body)) : null}
20
20
  <FormFields fieldContainerStyle={themedStyles.fieldContainer} fieldErrorsContainer={themedStyles.fieldErrorsContainer} fieldErrorStyle={themedStyles.fieldError} fieldLabelStyle={themedStyles.fieldLabel} fieldStyle={themedStyles.fieldStyle} fields={fields} isPending={isPending} validationErrors={validationErrors} style={themedStyles.formFields}/>
21
- {error ? (<ErrorMessage style={themedStyles.errorMessage} labelStyle={themedStyles.errorMessageLabel}>
21
+ {error ? (<ErrorMessage iconStyle={themedStyles.errorMessageIcon} labelStyle={themedStyles.errorMessageLabel} style={themedStyles.errorMessage}>
22
22
  {error}
23
23
  </ErrorMessage>) : null}
24
24
  <Button {...primary} variant="primary" textStyle={themedStyles.buttonPrimaryLabel} style={themedStyles.buttonPrimary}/>
@@ -14,8 +14,9 @@ export const getDefaultStyle = ({ tokens: { colors, fontSizes, space }, }) => St
14
14
  },
15
15
  buttonSecondaryLabel: {},
16
16
  errorMessage: {
17
- marginVertical: space.small,
17
+ marginHorizontal: space.small,
18
18
  },
19
+ errorMessageIcon: {},
19
20
  errorMessageLabel: {},
20
21
  fieldContainer: {
21
22
  paddingHorizontal: space.small,
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { StyleProp, TextStyle, ViewStyle } from 'react-native';
2
+ import { ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native';
3
3
  import { AuthenticatorComponentDefaultProps, AuthenticatorHeaderComponent, AuthenticatorFooterComponent, AuthenticatorMachineContext, AuthenticatorRouteComponentName } from '@aws-amplify/ui-react-core';
4
4
  import { ButtonProps } from '../../../primitives';
5
5
  import { DefaultFormFieldsComponent, DefaultFormFieldsStyle } from '../../common';
@@ -11,6 +11,7 @@ export interface DefaultContentStyle {
11
11
  buttonSecondary?: ViewStyle;
12
12
  buttonSecondaryLabel?: TextStyle;
13
13
  errorMessage?: ViewStyle;
14
+ errorMessageIcon?: ImageStyle;
14
15
  errorMessageLabel?: TextStyle;
15
16
  fieldErrorsContainer?: ViewStyle;
16
17
  fieldContainer?: ViewStyle;
@@ -1,13 +1,14 @@
1
- import React, { useCallback } from 'react';
1
+ import React from 'react';
2
2
  import { Button, Icon, Label } from '../../../primitives';
3
+ import { usePressableContainerStyles } from '../../../hooks';
3
4
  import { styles } from './styles';
4
5
  export default function FederatedProviderButton({ children, source, style, textStyle, ...rest }) {
5
- const containerStyle = useCallback(({ pressed }) => {
6
- const pressedStateStyle = typeof style === 'function' ? style({ pressed }) : style;
7
- return [styles.container, pressedStateStyle];
8
- }, [style]);
9
- return (<Button {...rest} style={containerStyle}>
10
- {source ? <Icon source={source} style={styles.icon} size={20}/> : null}
6
+ const pressableStyle = usePressableContainerStyles({
7
+ containerStyle: styles.container,
8
+ overrideStyle: style,
9
+ });
10
+ return (<Button {...rest} style={pressableStyle}>
11
+ <Icon source={source} style={styles.icon} size={20}/>
11
12
  <Label style={[styles.label, textStyle]}>{children}</Label>
12
13
  </Button>);
13
14
  }
@@ -1 +1,2 @@
1
1
  export { DeviceOrientation, useDeviceOrientation, } from './useDeviceOrientation';
2
+ export { usePressableContainerStyles } from './usePressableContainerStyles';
@@ -1 +1,2 @@
1
1
  export { useDeviceOrientation, } from './useDeviceOrientation';
2
+ export { usePressableContainerStyles } from './usePressableContainerStyles';
@@ -0,0 +1 @@
1
+ export { usePressableContainerStyles } from './usePressableContainerStyles';
@@ -0,0 +1 @@
1
+ export { usePressableContainerStyles } from './usePressableContainerStyles';
@@ -0,0 +1,19 @@
1
+ import { PressableProps, PressableStateCallbackType, StyleProp, ViewStyle } from 'react-native';
2
+ export interface UsePressableContainerStyleProps {
3
+ /**
4
+ * @description
5
+ * Either view styles or a function representing override styles for the pressed state
6
+ */
7
+ overrideStyle: PressableProps['style'];
8
+ /**
9
+ * @description
10
+ * Pass-through view styles, typically includes theme, disabled, variant styles
11
+ */
12
+ containerStyle?: StyleProp<ViewStyle>;
13
+ /**
14
+ * @description
15
+ * Pass-through view styles for the pressed state applied before the override styles
16
+ */
17
+ pressedStyle?: StyleProp<ViewStyle>;
18
+ }
19
+ export declare const usePressableContainerStyles: ({ overrideStyle, containerStyle, pressedStyle, }: UsePressableContainerStyleProps) => ({ pressed, }: PressableStateCallbackType) => StyleProp<ViewStyle>;
@@ -0,0 +1,14 @@
1
+ import { useCallback } from 'react';
2
+ export const usePressableContainerStyles = ({ overrideStyle, containerStyle, pressedStyle, }) => {
3
+ return useCallback(({ pressed }) => {
4
+ const pressedOverrideStyle = typeof overrideStyle === 'function'
5
+ ? overrideStyle({ pressed })
6
+ : overrideStyle;
7
+ return [
8
+ containerStyle,
9
+ pressed ? pressedStyle : undefined,
10
+ // include last to override other styles
11
+ pressedOverrideStyle,
12
+ ];
13
+ }, [containerStyle, overrideStyle, pressedStyle]);
14
+ };
@@ -1,21 +1,22 @@
1
- import React, { useCallback, useMemo } from 'react';
2
- import { Pressable, Text, } from 'react-native';
1
+ import React, { useMemo } from 'react';
2
+ import { Pressable, Text } from 'react-native';
3
+ import { usePressableContainerStyles } from '../../hooks';
3
4
  import { useTheme } from '../../theme';
4
5
  import { capitalize } from '../../utils';
5
6
  import { getThemedStyles } from './styles';
6
7
  export default function Button({ accessibilityRole = 'button', children, disabled, style, textStyle, variant = 'default', ...rest }) {
7
8
  const theme = useTheme();
8
9
  const themedStyle = getThemedStyles(theme);
9
- const pressableStyle = useCallback(({ pressed }) => {
10
- const pressedStateStyle = typeof style === 'function' ? style({ pressed }) : style;
11
- return [
12
- themedStyle.container,
13
- themedStyle[`container${capitalize(variant)}`],
14
- disabled ? themedStyle.disabled : null,
15
- pressed ? themedStyle.pressed : null,
16
- pressedStateStyle,
17
- ];
18
- }, [disabled, style, themedStyle, variant]);
10
+ const containerStyle = useMemo(() => ({
11
+ ...themedStyle.container,
12
+ ...themedStyle[`container${capitalize(variant)}`],
13
+ ...(disabled && themedStyle.disabled),
14
+ }), [disabled, themedStyle, variant]);
15
+ const pressableStyle = usePressableContainerStyles({
16
+ overrideStyle: style,
17
+ containerStyle,
18
+ pressedStyle: themedStyle.pressed,
19
+ });
19
20
  const buttonTextStyle = useMemo(() => ({
20
21
  ...themedStyle.text,
21
22
  ...themedStyle[`text${capitalize(variant)}`],
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { ErrorMessageProps } from './types';
3
3
  export declare const CLOSE_BUTTON_TEST_ID = "authenticator--error-message--close-button";
4
- export default function ErrorMessage({ children, labelStyle, onDismiss, style, ...rest }: ErrorMessageProps): JSX.Element;
4
+ export default function ErrorMessage({ children, iconStyle, labelStyle, onDismiss, style, ...rest }: ErrorMessageProps): JSX.Element;
@@ -6,11 +6,11 @@ import { IconButton } from '../IconButton';
6
6
  import { useTheme } from '../../theme';
7
7
  import { getThemedStyles } from './styles';
8
8
  export const CLOSE_BUTTON_TEST_ID = 'authenticator--error-message--close-button';
9
- export default function ErrorMessage({ children, labelStyle, onDismiss, style, ...rest }) {
9
+ export default function ErrorMessage({ children, iconStyle, labelStyle, onDismiss, style, ...rest }) {
10
10
  const theme = useTheme();
11
11
  const themedStyle = getThemedStyles(theme);
12
12
  return (<View {...rest} accessibilityRole="alert" style={[themedStyle.container, style]}>
13
- <Icon size={20} source={icons.error} style={themedStyle.icon}/>
13
+ <Icon size={20} source={icons.error} style={[themedStyle.icon, iconStyle]}/>
14
14
  <Text style={[themedStyle.label, labelStyle]}>{children}</Text>
15
15
  {onDismiss ? (<IconButton onPress={onDismiss} size={20} source={icons.close} style={themedStyle.icon} testID={CLOSE_BUTTON_TEST_ID}/>) : null}
16
16
  </View>);
@@ -1,22 +1,24 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
  export const getThemedStyles = (theme) => {
3
- const { tokens: { colors, space }, components, } = theme;
3
+ const { tokens: { colors, fontSizes, space }, components, } = theme;
4
4
  return StyleSheet.create({
5
5
  container: {
6
6
  alignItems: 'center',
7
7
  backgroundColor: colors.background.error,
8
8
  flexDirection: 'row',
9
9
  paddingHorizontal: space.xs,
10
- paddingVertical: space.xl,
10
+ paddingVertical: space.small,
11
11
  ...components?.errorMessage?.container,
12
12
  },
13
13
  icon: {
14
14
  margin: space.xs,
15
+ tintColor: colors.font.error,
15
16
  ...components?.errorMessage?.icon,
16
17
  },
17
18
  label: {
18
19
  color: colors.font.error,
19
20
  flex: 1,
21
+ fontSize: fontSizes.medium,
20
22
  paddingHorizontal: space.xs,
21
23
  ...components?.errorMessage?.label,
22
24
  },
@@ -1,5 +1,7 @@
1
1
  import { ImageStyle, StyleProp, TextStyle, ViewProps, ViewStyle } from 'react-native';
2
+ import { IconProps } from '../Icon';
2
3
  export interface ErrorMessageProps extends ViewProps {
4
+ iconStyle?: IconProps['style'];
3
5
  labelStyle?: StyleProp<TextStyle>;
4
6
  onDismiss?: () => void;
5
7
  }
@@ -1,20 +1,21 @@
1
- import React, { useCallback } from 'react';
2
- import { Pressable, } from 'react-native';
1
+ import React, { useMemo } from 'react';
2
+ import { Pressable } from 'react-native';
3
3
  import { useTheme } from '../../theme';
4
+ import { usePressableContainerStyles } from '../../hooks';
4
5
  import { getThemedStyles } from './styles';
5
6
  import { Icon, iconSizes } from '../Icon';
6
7
  export default function IconButton({ accessibilityRole = 'button', color, disabled, iconStyle, size = iconSizes.medium, source, style, ...rest }) {
7
8
  const theme = useTheme();
8
9
  const themedStyle = getThemedStyles(theme);
9
- const pressableStyle = useCallback(({ pressed }) => {
10
- const pressedStateStyle = typeof style === 'function' ? style({ pressed }) : style;
11
- return [
12
- themedStyle.container,
13
- disabled ? themedStyle.disabled : null,
14
- pressed ? themedStyle.pressed : null,
15
- pressedStateStyle,
16
- ];
17
- }, [disabled, style, themedStyle]);
10
+ const containerStyle = useMemo(() => ({
11
+ ...themedStyle.container,
12
+ ...(disabled && themedStyle.disabled),
13
+ }), [disabled, themedStyle]);
14
+ const pressableStyle = usePressableContainerStyles({
15
+ overrideStyle: style,
16
+ containerStyle,
17
+ pressedStyle: themedStyle.pressed,
18
+ });
18
19
  return (<Pressable {...rest} accessibilityRole={accessibilityRole} disabled={disabled} style={pressableStyle}>
19
20
  <Icon color={color} size={size} source={source} style={iconStyle}/>
20
21
  </Pressable>);
@@ -3,6 +3,7 @@ import { Pressable, View, } from 'react-native';
3
3
  import { useTheme } from '../../theme';
4
4
  import { Label } from '../Label';
5
5
  import { getFlexDirectionFromLabelPosition } from '../Label/utils';
6
+ import { usePressableContainerStyles } from '../../hooks';
6
7
  import { getThemedStyles } from './styles';
7
8
  import { getRadioDimensions } from './getRadioDimensions';
8
9
  export const CONTAINER_TEST_ID = 'amplify__radio-button__container';
@@ -16,17 +17,18 @@ export default function Radio({ accessibilityRole = 'radio', disabled, label, la
16
17
  onPress?.(event);
17
18
  }
18
19
  }, [disabled, onChange, onPress, value]);
19
- const containerStyle = useCallback(({ pressed }) => {
20
- const containerStyle = {
21
- ...themedStyle.container,
22
- flexDirection: getFlexDirectionFromLabelPosition(labelPosition),
23
- ...(disabled && themedStyle.disabled),
24
- };
25
- const pressedStateStyle = typeof style === 'function' ? style({ pressed }) : style;
26
- return [containerStyle, pressedStateStyle];
27
- }, [disabled, labelPosition, style, themedStyle]);
20
+ const containerStyle = useMemo(() => ({
21
+ ...themedStyle.container,
22
+ flexDirection: getFlexDirectionFromLabelPosition(labelPosition),
23
+ ...(disabled && themedStyle.disabled),
24
+ }), [disabled, labelPosition, themedStyle]);
25
+ const pressableStyle = usePressableContainerStyles({
26
+ overrideStyle: style,
27
+ containerStyle,
28
+ pressedStyle: themedStyle.pressed,
29
+ });
28
30
  const { radioContainerDimensions, radioDotDimensions } = useMemo(() => getRadioDimensions(size, themedStyle), [size, themedStyle]);
29
- return (<Pressable {...rest} accessibilityRole={accessibilityRole} onPress={handleOnChange} style={containerStyle}>
31
+ return (<Pressable {...rest} accessibilityRole={accessibilityRole} onPress={handleOnChange} style={pressableStyle}>
30
32
  <View style={[
31
33
  themedStyle.radioContainer,
32
34
  radioContainerDimensions,
@@ -12,6 +12,10 @@ export const getThemedStyles = (theme) => {
12
12
  opacity: opacities[60],
13
13
  ...components?.radio?.disabled,
14
14
  },
15
+ pressed: {
16
+ opacity: opacities[60],
17
+ ...components?.radio?.pressed,
18
+ },
15
19
  radioContainer: {
16
20
  alignItems: 'center',
17
21
  borderColor: colors.border.primary,
@@ -17,6 +17,7 @@ export declare type RadioDimensions = Pick<ViewStyle, 'height' | 'width'>;
17
17
  export interface RadioStyles {
18
18
  container?: ViewStyle;
19
19
  disabled?: ViewStyle;
20
+ pressed?: ViewStyle;
20
21
  radioContainer?: ViewStyle;
21
22
  radioContainerLarge?: RadioDimensions;
22
23
  radioContainerMedium?: RadioDimensions;
@@ -1,23 +1,23 @@
1
- import React, { useCallback } from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { useTheme } from '../../theme';
3
+ import { usePressableContainerStyles } from '../../hooks';
3
4
  import { Button } from '../Button';
4
5
  import { getThemedStyles } from './styles';
5
6
  export default function Tab({ children, selected, style, textStyle, indicatorPosition, ...rest }) {
6
7
  const theme = useTheme();
7
8
  const themedStyle = getThemedStyles(theme, indicatorPosition);
8
9
  const selectedStyles = selected ? themedStyle.selected : null;
9
- const containerStyle = useCallback(({ pressed }) => {
10
- const readonlyStyle = selected ? themedStyle.readonly : null;
11
- const pressedStateStyle = (typeof style === 'function' ? style({ pressed }) : style) ?? null;
12
- // include `pressedStateStyle` last to override other styles
13
- return [
14
- themedStyle.tab,
15
- readonlyStyle,
16
- selectedStyles,
17
- pressedStateStyle,
18
- ];
19
- }, [selected, selectedStyles, style, themedStyle]);
20
- return (<Button {...rest} accessibilityRole="tab" style={containerStyle} textStyle={[themedStyle.tabText, textStyle, selectedStyles]}>
10
+ const containerStyle = useMemo(() => ({
11
+ ...themedStyle.tab,
12
+ ...(selected && themedStyle.readonly),
13
+ ...selectedStyles,
14
+ }), [selected, selectedStyles, themedStyle]);
15
+ const pressableStyle = usePressableContainerStyles({
16
+ overrideStyle: style,
17
+ containerStyle,
18
+ pressedStyle: themedStyle.pressed,
19
+ });
20
+ return (<Button {...rest} accessibilityRole="tab" style={pressableStyle} textStyle={[themedStyle.tabText, textStyle, selectedStyles]}>
21
21
  {children}
22
22
  </Button>);
23
23
  }
@@ -18,6 +18,10 @@ export const getThemedStyles = (theme, indicatorPosition) => {
18
18
  opacity: opacities[100],
19
19
  ...components?.tabs?.readonly,
20
20
  },
21
+ pressed: {
22
+ opacity: opacities[60],
23
+ ...components?.tabs?.pressed,
24
+ },
21
25
  tabList: {
22
26
  flexDirection: 'row',
23
27
  width: '100%',
@@ -36,6 +36,7 @@ export interface TabProps extends ButtonProps {
36
36
  indicatorPosition?: IndicatorPosition;
37
37
  }
38
38
  export interface TabsStyles {
39
+ pressed?: ViewStyle;
39
40
  readonly?: ViewStyle;
40
41
  selected?: ViewStyle;
41
42
  tabList?: ViewStyle;
@@ -0,0 +1 @@
1
+ export declare const VERSION = "1.2.0";
@@ -0,0 +1 @@
1
+ export const VERSION = '1.2.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-native",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -43,8 +43,8 @@
43
43
  "type-fest": "^2.3.4"
44
44
  },
45
45
  "dependencies": {
46
- "@aws-amplify/ui": "5.3.0",
47
- "@aws-amplify/ui-react-core": "2.1.3"
46
+ "@aws-amplify/ui": "5.4.0",
47
+ "@aws-amplify/ui-react-core": "2.1.5"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "aws-amplify": ">= 5.0.1",
@@ -11,9 +11,12 @@ import {
11
11
  UseAuthenticator,
12
12
  } from '@aws-amplify/ui-react-core';
13
13
 
14
+ import { configureComponent } from '@aws-amplify/ui';
15
+
14
16
  import { DefaultContainer, InnerContainer } from './common';
15
17
  import { TypedField, getRouteTypedFields } from './hooks';
16
18
  import { AuthenticatorProps } from './types';
19
+ import { VERSION } from '../version';
17
20
 
18
21
  import {
19
22
  ConfirmResetPassword,
@@ -58,6 +61,13 @@ function Authenticator({
58
61
  Header,
59
62
  ...options
60
63
  }: AuthenticatorProps): JSX.Element | null {
64
+ React.useEffect(() => {
65
+ configureComponent({
66
+ packageName: '@aws-amplify/ui-react-native',
67
+ version: VERSION,
68
+ });
69
+ }, []);
70
+
61
71
  useAuthenticatorInitMachine(options);
62
72
 
63
73
  const { fields, route } = useAuthenticator(routePropSelector);
@@ -217,8 +217,7 @@ Array [
217
217
  style={
218
218
  Array [
219
219
  Object {},
220
- null,
221
- null,
220
+ undefined,
222
221
  undefined,
223
222
  ]
224
223
  }
@@ -356,8 +355,7 @@ Array [
356
355
  style={
357
356
  Array [
358
357
  Object {},
359
- null,
360
- null,
358
+ undefined,
361
359
  undefined,
362
360
  ]
363
361
  }
@@ -399,10 +397,10 @@ Array [
399
397
  "backgroundColor": "hsl(0, 75%, 85%)",
400
398
  "flexDirection": "row",
401
399
  "paddingHorizontal": 8,
402
- "paddingVertical": 32,
400
+ "paddingVertical": 12,
403
401
  },
404
402
  Object {
405
- "marginVertical": 12,
403
+ "marginHorizontal": 12,
406
404
  },
407
405
  ]
408
406
  }
@@ -422,9 +420,13 @@ Array [
422
420
  "tintColor": undefined,
423
421
  "width": 20,
424
422
  },
425
- Object {
426
- "margin": 8,
427
- },
423
+ Array [
424
+ Object {
425
+ "margin": 8,
426
+ "tintColor": "hsl(0, 100%, 20%)",
427
+ },
428
+ Object {},
429
+ ],
428
430
  ]
429
431
  }
430
432
  />
@@ -434,6 +436,7 @@ Array [
434
436
  Object {
435
437
  "color": "hsl(0, 100%, 20%)",
436
438
  "flex": 1,
439
+ "fontSize": 16,
437
440
  "paddingHorizontal": 8,
438
441
  },
439
442
  Object {},
@@ -461,17 +464,13 @@ Array [
461
464
  Array [
462
465
  Object {
463
466
  "alignItems": "center",
464
- "backgroundColor": "transparent",
467
+ "backgroundColor": "hsl(190, 95%, 30%)",
465
468
  "borderRadius": 4,
466
469
  "justifyContent": "center",
467
470
  "paddingHorizontal": 16,
468
471
  "paddingVertical": 12,
469
472
  },
470
- Object {
471
- "backgroundColor": "hsl(190, 95%, 30%)",
472
- },
473
- null,
474
- null,
473
+ undefined,
475
474
  Object {
476
475
  "marginHorizontal": 16,
477
476
  "marginVertical": 12,
@@ -514,17 +513,14 @@ Array [
514
513
  Object {
515
514
  "alignItems": "center",
516
515
  "backgroundColor": "transparent",
516
+ "borderColor": "hsl(210, 10%, 58%)",
517
517
  "borderRadius": 4,
518
+ "borderWidth": 1,
518
519
  "justifyContent": "center",
519
520
  "paddingHorizontal": 16,
520
521
  "paddingVertical": 12,
521
522
  },
522
- Object {
523
- "borderColor": "hsl(210, 10%, 58%)",
524
- "borderWidth": 1,
525
- },
526
- null,
527
- null,
523
+ undefined,
528
524
  Object {
529
525
  "marginHorizontal": 16,
530
526
  },
@@ -767,8 +763,7 @@ Array [
767
763
  style={
768
764
  Array [
769
765
  Object {},
770
- null,
771
- null,
766
+ undefined,
772
767
  undefined,
773
768
  ]
774
769
  }
@@ -906,8 +901,7 @@ Array [
906
901
  style={
907
902
  Array [
908
903
  Object {},
909
- null,
910
- null,
904
+ undefined,
911
905
  undefined,
912
906
  ]
913
907
  }
@@ -958,17 +952,13 @@ Array [
958
952
  Array [
959
953
  Object {
960
954
  "alignItems": "center",
961
- "backgroundColor": "transparent",
955
+ "backgroundColor": "hsl(190, 95%, 30%)",
962
956
  "borderRadius": 4,
963
957
  "justifyContent": "center",
964
958
  "paddingHorizontal": 16,
965
959
  "paddingVertical": 12,
966
960
  },
967
- Object {
968
- "backgroundColor": "hsl(190, 95%, 30%)",
969
- },
970
- null,
971
- null,
961
+ undefined,
972
962
  Object {
973
963
  "marginHorizontal": 16,
974
964
  "marginVertical": 12,
@@ -1011,17 +1001,14 @@ Array [
1011
1001
  Object {
1012
1002
  "alignItems": "center",
1013
1003
  "backgroundColor": "transparent",
1004
+ "borderColor": "hsl(210, 10%, 58%)",
1014
1005
  "borderRadius": 4,
1006
+ "borderWidth": 1,
1015
1007
  "justifyContent": "center",
1016
1008
  "paddingHorizontal": 16,
1017
1009
  "paddingVertical": 12,
1018
1010
  },
1019
- Object {
1020
- "borderColor": "hsl(210, 10%, 58%)",
1021
- "borderWidth": 1,
1022
- },
1023
- null,
1024
- null,
1011
+ undefined,
1025
1012
  Object {
1026
1013
  "marginHorizontal": 16,
1027
1014
  },