@aws-amplify/ui-react-native 1.2.19 → 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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @aws-amplify/ui-react-native
2
2
 
3
+ ## 1.2.20
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4168](https://github.com/aws-amplify/amplify-ui/pull/4168) [`d930e2ed1`](https://github.com/aws-amplify/amplify-ui/commit/d930e2ed17f3e638e2b62699ba2dd164b32f8118) Thanks [@calebpollman](https://github.com/calebpollman)! - chore(RWA/RNA): deprecate passwordSettings prop
8
+
9
+ - Updated dependencies [[`b0e16e78c`](https://github.com/aws-amplify/amplify-ui/commit/b0e16e78c6a41945aa79f3e14fa3f9e6cb0e5e76), [`d930e2ed1`](https://github.com/aws-amplify/amplify-ui/commit/d930e2ed17f3e638e2b62699ba2dd164b32f8118)]:
10
+ - @aws-amplify/ui@5.6.6
11
+ - @aws-amplify/ui-react-core@2.1.25
12
+ - @aws-amplify/ui-react-core-notifications@1.0.2
13
+
3
14
  ## 1.2.19
4
15
 
5
16
  ### Patch Changes
@@ -2,6 +2,7 @@ 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
4
  import { configureComponent } from '@aws-amplify/ui';
5
+ import { useDeprecationWarning } from '../hooks';
5
6
  import { DefaultContainer, InnerContainer } from './common';
6
7
  import { getRouteTypedFields } from './hooks';
7
8
  import { VERSION } from '../version';
@@ -23,6 +24,10 @@ const routePropSelector = ({ route, }) => [
23
24
  route,
24
25
  ];
25
26
  function Authenticator({ children, components: overrides, Container = DefaultContainer, Footer, Header, ...options }) {
27
+ useDeprecationWarning({
28
+ message: 'The `passwordSettings` prop has been deprecated and will be removed in a future major version of Amplify UI.',
29
+ shouldWarn: !!options?.passwordSettings,
30
+ });
26
31
  React.useEffect(() => {
27
32
  configureComponent({
28
33
  packageName: '@aws-amplify/ui-react-native',
@@ -1,2 +1,3 @@
1
+ export { useDeprecationWarning } from './useDeprecationWarning';
1
2
  export { DeviceOrientation, useDeviceOrientation, } from './useDeviceOrientation';
2
3
  export { usePressableContainerStyles } from './usePressableContainerStyles';
@@ -1,2 +1,3 @@
1
+ export { useDeprecationWarning } from './useDeprecationWarning';
1
2
  export { useDeviceOrientation, } from './useDeviceOrientation';
2
3
  export { usePressableContainerStyles } from './usePressableContainerStyles';
@@ -0,0 +1 @@
1
+ export { default as useDeprecationWarning } from './useDeprecationWarning';
@@ -0,0 +1 @@
1
+ export { default as useDeprecationWarning } from './useDeprecationWarning';
@@ -0,0 +1,6 @@
1
+ import { UseDeprecationWarning } from '@aws-amplify/ui-react-core';
2
+ /**
3
+ * Logs a deprecation warning `message` to the console.
4
+ */
5
+ declare const useDeprecationWarning: UseDeprecationWarning;
6
+ export default useDeprecationWarning;
@@ -0,0 +1,11 @@
1
+ import { useDeprecationWarning as useDeprecationWarningBase, } from '@aws-amplify/ui-react-core';
2
+ import { platform } from '../../utils';
3
+ /**
4
+ * Logs a deprecation warning `message` to the console.
5
+ */
6
+ const useDeprecationWarning = ({ message, shouldWarn: _shouldWarn, }) => {
7
+ // only log warnings in dev
8
+ const shouldWarn = _shouldWarn && platform.IS_DEV;
9
+ useDeprecationWarningBase({ message, shouldWarn });
10
+ };
11
+ export default useDeprecationWarning;
@@ -1,5 +1,6 @@
1
1
  declare const _default: {
2
2
  IS_ANDROID: boolean;
3
+ IS_DEV: boolean;
3
4
  IS_IOS: boolean;
4
5
  PLATFORM_TOUCH_TARGET: number | undefined;
5
6
  constants: import("react-native").PlatformConstants & {
@@ -41,6 +42,7 @@ declare const _default: {
41
42
  }): T_1 | undefined;
42
43
  } | {
43
44
  IS_ANDROID: boolean;
45
+ IS_DEV: boolean;
44
46
  IS_IOS: boolean;
45
47
  PLATFORM_TOUCH_TARGET: number | undefined;
46
48
  constants: import("react-native").PlatformConstants & {
@@ -85,6 +87,7 @@ declare const _default: {
85
87
  }): T_1 | undefined;
86
88
  } | {
87
89
  IS_ANDROID: boolean;
90
+ IS_DEV: boolean;
88
91
  IS_IOS: boolean;
89
92
  PLATFORM_TOUCH_TARGET: number | undefined;
90
93
  OS: "windows";
@@ -121,6 +124,7 @@ declare const _default: {
121
124
  }): T_1 | undefined;
122
125
  } | {
123
126
  IS_ANDROID: boolean;
127
+ IS_DEV: boolean;
124
128
  IS_IOS: boolean;
125
129
  PLATFORM_TOUCH_TARGET: number | undefined;
126
130
  OS: "macos";
@@ -157,6 +161,7 @@ declare const _default: {
157
161
  }): T_1 | undefined;
158
162
  } | {
159
163
  IS_ANDROID: boolean;
164
+ IS_DEV: boolean;
160
165
  IS_IOS: boolean;
161
166
  PLATFORM_TOUCH_TARGET: number | undefined;
162
167
  OS: "web";
@@ -1,4 +1,5 @@
1
1
  import { Platform } from 'react-native';
2
+ const IS_DEV = __DEV__;
2
3
  const IS_ANDROID = Platform.OS === 'android';
3
4
  const IS_IOS = Platform.OS === 'ios';
4
5
  // https://material.io/design/layout/spacing-methods.html#touch-targets
@@ -12,6 +13,7 @@ const PLATFORM_TOUCH_TARGET = Platform.select({
12
13
  export default {
13
14
  ...Platform,
14
15
  IS_ANDROID,
16
+ IS_DEV,
15
17
  IS_IOS,
16
18
  PLATFORM_TOUCH_TARGET,
17
19
  };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.2.19";
1
+ export declare const VERSION = "1.2.20";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.2.19';
1
+ export const VERSION = '1.2.20';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-native",
3
- "version": "1.2.19",
3
+ "version": "1.2.20",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,6 +29,7 @@
29
29
  "@types/react-test-renderer": "^17.0.1",
30
30
  "babel-jest": "^28.0.3",
31
31
  "eslint": "^8.14.0",
32
+ "jest": "^27.0.4",
32
33
  "metro-react-native-babel-preset": "^0.70.2",
33
34
  "react": "^17.0.2",
34
35
  "react-native": "^0.68.1",
@@ -37,9 +38,9 @@
37
38
  "rimraf": "^3.0.2"
38
39
  },
39
40
  "dependencies": {
40
- "@aws-amplify/ui": "5.6.5",
41
- "@aws-amplify/ui-react-core": "2.1.24",
42
- "@aws-amplify/ui-react-core-notifications": "1.0.1"
41
+ "@aws-amplify/ui": "5.6.6",
42
+ "@aws-amplify/ui-react-core": "2.1.25",
43
+ "@aws-amplify/ui-react-core-notifications": "1.0.2"
43
44
  },
44
45
  "peerDependencies": {
45
46
  "aws-amplify": ">= 5.0.1",
@@ -13,6 +13,7 @@ import {
13
13
 
14
14
  import { configureComponent } from '@aws-amplify/ui';
15
15
 
16
+ import { useDeprecationWarning } from '../hooks';
16
17
  import { DefaultContainer, InnerContainer } from './common';
17
18
  import { TypedField, getRouteTypedFields } from './hooks';
18
19
  import { AuthenticatorProps } from './types';
@@ -61,6 +62,12 @@ function Authenticator({
61
62
  Header,
62
63
  ...options
63
64
  }: AuthenticatorProps): JSX.Element | null {
65
+ useDeprecationWarning({
66
+ message:
67
+ 'The `passwordSettings` prop has been deprecated and will be removed in a future major version of Amplify UI.',
68
+ shouldWarn: !!options?.passwordSettings,
69
+ });
70
+
64
71
  React.useEffect(() => {
65
72
  configureComponent({
66
73
  packageName: '@aws-amplify/ui-react-native',
@@ -1,3 +1,4 @@
1
+ export { useDeprecationWarning } from './useDeprecationWarning';
1
2
  export {
2
3
  DeviceOrientation,
3
4
  useDeviceOrientation,
@@ -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;
@@ -1,5 +1,6 @@
1
1
  import { Platform } from 'react-native';
2
2
 
3
+ const IS_DEV = __DEV__;
3
4
  const IS_ANDROID = Platform.OS === 'android';
4
5
  const IS_IOS = Platform.OS === 'ios';
5
6
 
@@ -16,6 +17,7 @@ const PLATFORM_TOUCH_TARGET = Platform.select({
16
17
  export default {
17
18
  ...Platform,
18
19
  IS_ANDROID,
20
+ IS_DEV,
19
21
  IS_IOS,
20
22
  PLATFORM_TOUCH_TARGET,
21
23
  };
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.2.19';
1
+ export const VERSION = '1.2.20';