@aws-amplify/ui-react-native 1.2.7 → 1.2.9
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/.eslintrc.js +8 -13
- package/CHANGELOG.md +26 -0
- package/dist/Authenticator/common/DefaultContainer/DefaultContainer.js +1 -9
- package/dist/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.js +1 -1
- package/dist/InAppMessaging/hooks/useMessageProps/useMessageProps.js +1 -1
- package/dist/InAppMessaging/hooks/useMessageProps/utils.js +2 -1
- package/dist/hooks/useDeviceOrientation/useDeviceOrientation.js +2 -1
- package/dist/hooks/usePressableContainerStyles/usePressableContainerStyles.js +2 -1
- package/dist/primitives/Button/Button.js +1 -1
- package/dist/primitives/Carousel/Carousel.js +3 -2
- package/dist/primitives/Radio/getRadioDimensions.js +1 -1
- package/dist/theme/createTheme.js +13 -16
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -5
- package/src/Authenticator/common/DefaultContainer/DefaultContainer.tsx +1 -12
- package/src/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.tsx +1 -1
- package/src/Authenticator/hooks/useFieldValues/__tests__/useFieldValues.spec.ts +1 -1
- package/src/InAppMessaging/components/InAppMessageDisplay/__tests__/InAppMessageDisplay.spec.tsx +2 -2
- package/src/InAppMessaging/hooks/useMessageImage/__tests__/useMessageImage.spec.ts +1 -1
- package/src/InAppMessaging/hooks/useMessageProps/__tests__/utils.spec.ts +2 -1
- package/src/InAppMessaging/hooks/useMessageProps/useMessageProps.ts +1 -1
- package/src/InAppMessaging/hooks/useMessageProps/utils.ts +4 -4
- package/src/__mocks__/@react-native-community/netinfo.ts +1 -0
- package/src/hooks/useDeviceOrientation/__tests__/useDeviceOrientation.spec.ts +5 -3
- package/src/hooks/useDeviceOrientation/useDeviceOrientation.ts +3 -1
- package/src/hooks/usePressableContainerStyles/usePressableContainerStyles.ts +4 -4
- package/src/primitives/Button/Button.tsx +2 -2
- package/src/primitives/Carousel/Carousel.tsx +4 -4
- package/src/primitives/Checkbox/__tests__/Checkbox.spec.tsx +2 -7
- package/src/primitives/Radio/__tests__/Radio.spec.tsx +2 -1
- package/src/primitives/Radio/getRadioDimensions.ts +1 -1
- package/src/theme/createTheme.ts +18 -16
- package/src/utils/index.ts +0 -1
- package/src/version.ts +1 -1
- package/tsconfig.dist.json +1 -1
- package/tsconfig.json +1 -1
- package/dist/__mocks__/@react-native-async-storage/async-storage.d.ts +0 -1
- package/dist/__mocks__/@react-native-async-storage/async-storage.js +0 -2
- package/dist/__mocks__/@react-native-community/netinfo.d.ts +0 -1
- package/dist/__mocks__/@react-native-community/netinfo.js +0 -2
- package/dist/__mocks__/react-native-safe-area-context.d.ts +0 -8
- package/dist/__mocks__/react-native-safe-area-context.js +0 -6
- package/dist/utils/utils.d.ts +0 -1
- package/dist/utils/utils.js +0 -3
- package/src/utils/utils.ts +0 -3
package/.eslintrc.js
CHANGED
|
@@ -23,7 +23,7 @@ module.exports = {
|
|
|
23
23
|
parserOptions: {
|
|
24
24
|
ecmaFeatures: { jsx: true },
|
|
25
25
|
ecmaVersion: 12,
|
|
26
|
-
project: ['
|
|
26
|
+
project: ['tsconfig.json'],
|
|
27
27
|
tsconfigRootDir: __dirname,
|
|
28
28
|
sourceType: 'module',
|
|
29
29
|
},
|
|
@@ -36,13 +36,8 @@ module.exports = {
|
|
|
36
36
|
{
|
|
37
37
|
files: ['**/*.spec.*', '**/*.test.*'],
|
|
38
38
|
parser: '@typescript-eslint/parser',
|
|
39
|
-
parserOptions: {
|
|
40
|
-
project: ['./tsconfig.json'],
|
|
41
|
-
},
|
|
42
39
|
plugins: ['@typescript-eslint', 'jest'],
|
|
43
40
|
rules: {
|
|
44
|
-
// Turn the original rule off for test files, turn on the jest rule
|
|
45
|
-
'@typescript-eslint/unbound-method': 'off',
|
|
46
41
|
'jest/unbound-method': 'error',
|
|
47
42
|
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
48
43
|
},
|
|
@@ -53,19 +48,19 @@ module.exports = {
|
|
|
53
48
|
'@typescript-eslint/explicit-module-boundary-types': 2,
|
|
54
49
|
'@typescript-eslint/member-ordering': 'error',
|
|
55
50
|
'@typescript-eslint/no-extra-semi': 'error',
|
|
56
|
-
'@typescript-eslint/no-floating-promises':
|
|
51
|
+
'@typescript-eslint/no-floating-promises': 'off',
|
|
57
52
|
'@typescript-eslint/no-unused-expressions': [
|
|
58
53
|
'error',
|
|
59
54
|
{ allowTernary: true },
|
|
60
55
|
],
|
|
61
|
-
'@typescript-eslint/no-use-before-define':
|
|
56
|
+
'@typescript-eslint/no-use-before-define': 'error',
|
|
62
57
|
'@typescript-eslint/no-unused-vars': [
|
|
63
58
|
'error',
|
|
64
59
|
{ argsIgnorePattern: '_', varsIgnorePattern: '_' },
|
|
65
60
|
],
|
|
66
61
|
'@typescript-eslint/prefer-nullish-coalescing': 'error',
|
|
67
|
-
'@typescript-eslint/restrict-template-expressions':
|
|
68
|
-
'@typescript-eslint/unbound-method': '
|
|
62
|
+
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
63
|
+
'@typescript-eslint/unbound-method': 'off',
|
|
69
64
|
|
|
70
65
|
// eslint rules either not in recommended rule set or overridden
|
|
71
66
|
'comma-dangle': ['error', 'only-multiline'],
|
|
@@ -89,13 +84,13 @@ module.exports = {
|
|
|
89
84
|
// react rules either not in recommended rule set or overridden
|
|
90
85
|
'react/destructuring-assignment': ['error', 'always'],
|
|
91
86
|
'react/jsx-boolean-value': 'error',
|
|
92
|
-
'react/jsx-no-constructed-context-values':
|
|
87
|
+
'react/jsx-no-constructed-context-values': 'error',
|
|
93
88
|
'react/jsx-no-useless-fragment': ['error', { allowExpressions: true }],
|
|
94
89
|
'react/jsx-props-no-spreading': 'off',
|
|
95
90
|
'react/jsx-wrap-multilines': ['error', { declaration: 'ignore' }],
|
|
96
91
|
'react/no-array-index-key': 'off',
|
|
97
|
-
'react/no-danger':
|
|
98
|
-
'react/no-unused-prop-types':
|
|
92
|
+
'react/no-danger': 'error',
|
|
93
|
+
'react/no-unused-prop-types': 'error',
|
|
99
94
|
'react/prop-types': 'off',
|
|
100
95
|
'react/static-property-placement': ['error', 'static public field'],
|
|
101
96
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @aws-amplify/ui-react-native
|
|
2
2
|
|
|
3
|
+
## 1.2.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3483](https://github.com/aws-amplify/amplify-ui/pull/3483) [`d7cc72c72`](https://github.com/aws-amplify/amplify-ui/commit/d7cc72c72844733d42a9504aa2ae1f2249abc178) Thanks [@calebpollman](https://github.com/calebpollman)! - chore(ui-react-native): add TS noImplicitAny for dist build
|
|
8
|
+
|
|
9
|
+
- [#3473](https://github.com/aws-amplify/amplify-ui/pull/3473) [`12d166209`](https://github.com/aws-amplify/amplify-ui/commit/12d166209b91ee94661e586a2f77e9fbf75b3d64) Thanks [@calebpollman](https://github.com/calebpollman)! - chore(ui): remove type-fest
|
|
10
|
+
|
|
11
|
+
- [#3486](https://github.com/aws-amplify/amplify-ui/pull/3486) [`eb9df76f0`](https://github.com/aws-amplify/amplify-ui/commit/eb9df76f0b46aa577965740b476b18d070ccb276) Thanks [@calebpollman](https://github.com/calebpollman)! - chore(ui-react-native): remove extraneous optional chaining
|
|
12
|
+
|
|
13
|
+
- [#3446](https://github.com/aws-amplify/amplify-ui/pull/3446) [`ef40fcc76`](https://github.com/aws-amplify/amplify-ui/commit/ef40fcc7673a1d1ed7c7a006fa34d3d5b029956f) Thanks [@calebpollman](https://github.com/calebpollman)! - refactor(ui-react-native): update default keyboardVerticalOffset handling of RNA DefaultContainer
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`3c5fef84c`](https://github.com/aws-amplify/amplify-ui/commit/3c5fef84cb6ad0cb830416e70028c0bb313dd99c), [`e08e62234`](https://github.com/aws-amplify/amplify-ui/commit/e08e6223473f56cbbc2d0ce4bab85ebd1caf020c), [`12d166209`](https://github.com/aws-amplify/amplify-ui/commit/12d166209b91ee94661e586a2f77e9fbf75b3d64), [`e283f14ca`](https://github.com/aws-amplify/amplify-ui/commit/e283f14cadf54c6f6ab7e729151ea5fe97776c6a), [`d28e31c36`](https://github.com/aws-amplify/amplify-ui/commit/d28e31c36a243d04737b6c13ce0307495680498a), [`c3116b894`](https://github.com/aws-amplify/amplify-ui/commit/c3116b89470587c127d53a5cb370b2574bde553a)]:
|
|
16
|
+
- @aws-amplify/ui@5.5.6
|
|
17
|
+
- @aws-amplify/ui-react-core@2.1.14
|
|
18
|
+
|
|
19
|
+
## 1.2.8
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#3417](https://github.com/aws-amplify/amplify-ui/pull/3417) [`0c8fa2ac2`](https://github.com/aws-amplify/amplify-ui/commit/0c8fa2ac2b89e7617bbc601f29cc9cbf902d08ae) Thanks [@calebpollman](https://github.com/calebpollman)! - Migrate `capitalize` util to UI package
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`0c8fa2ac2`](https://github.com/aws-amplify/amplify-ui/commit/0c8fa2ac2b89e7617bbc601f29cc9cbf902d08ae), [`d214551f0`](https://github.com/aws-amplify/amplify-ui/commit/d214551f0edb001878f7a04b4206c57a677ecfa8)]:
|
|
26
|
+
- @aws-amplify/ui@5.5.5
|
|
27
|
+
- @aws-amplify/ui-react-core@2.1.13
|
|
28
|
+
|
|
3
29
|
## 1.2.7
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { KeyboardAvoidingView, ScrollView } from 'react-native';
|
|
3
3
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
4
|
-
import { useDeviceOrientation } from '../../../hooks';
|
|
5
4
|
import { useTheme } from '../../../theme';
|
|
6
5
|
import { platform } from '../../../utils';
|
|
7
6
|
import { getThemedStyles } from './styles';
|
|
@@ -11,16 +10,9 @@ const BEHAVIOR = platform.IS_IOS ? 'padding' : 'height';
|
|
|
11
10
|
// prevent keyboard dismiss when press is handled by `ScrollView` children,
|
|
12
11
|
// otherwise dismiss
|
|
13
12
|
const KEYBOARD_SHOULD_PERSIST_TAPS = 'handled';
|
|
14
|
-
// TEMPORARY: value to prevent initial `TextField` from being pushed too high
|
|
15
|
-
// in default use case
|
|
16
|
-
const KEYBOARD_VERTICAL_OFFSET = platform.IS_IOS ? -160 : -80;
|
|
17
13
|
export default function DefaultContainer({ alwaysBounceVertical = ALWAYS_BOUNCE_VERTICAL, behavior = BEHAVIOR, children, keyboardAvoidingViewStyle, keyboardShouldPersistTaps = KEYBOARD_SHOULD_PERSIST_TAPS, keyboardVerticalOffset, scrollViewContentContainerStyle, style, ...rest }) {
|
|
18
14
|
const theme = useTheme();
|
|
19
|
-
const { isPortraitMode } = useDeviceOrientation();
|
|
20
15
|
const insets = useSafeAreaInsets();
|
|
21
|
-
const verticalOffset = keyboardVerticalOffset ?? isPortraitMode
|
|
22
|
-
? KEYBOARD_VERTICAL_OFFSET
|
|
23
|
-
: undefined;
|
|
24
16
|
const themedStyle = useMemo(() => {
|
|
25
17
|
const { bottom, left, right, top } = insets;
|
|
26
18
|
return getThemedStyles(theme, {
|
|
@@ -30,7 +22,7 @@ export default function DefaultContainer({ alwaysBounceVertical = ALWAYS_BOUNCE_
|
|
|
30
22
|
paddingTop: top,
|
|
31
23
|
});
|
|
32
24
|
}, [insets, theme]);
|
|
33
|
-
return (<KeyboardAvoidingView behavior={behavior} keyboardVerticalOffset={
|
|
25
|
+
return (<KeyboardAvoidingView behavior={behavior} keyboardVerticalOffset={keyboardVerticalOffset} style={[themedStyle.keyboardAvoidingView, keyboardAvoidingViewStyle]}>
|
|
34
26
|
<ScrollView {...rest} alwaysBounceVertical={alwaysBounceVertical} keyboardShouldPersistTaps={keyboardShouldPersistTaps} contentContainerStyle={[
|
|
35
27
|
themedStyle.scrollViewContentContainer,
|
|
36
28
|
scrollViewContentContainerStyle,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
+
import { capitalize } from '@aws-amplify/ui';
|
|
3
4
|
import { icons } from '../../../assets';
|
|
4
|
-
import { capitalize } from '../../../utils';
|
|
5
5
|
import { FederatedProviderButton } from '../FederatedProviderButton';
|
|
6
6
|
import { Divider } from '../../../primitives';
|
|
7
7
|
import { styles } from './styles';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { isFunction } from '@aws-amplify/ui';
|
|
2
3
|
import { DEFAULT_CAROUSEL_INDICATOR_SIZE } from '../../../primitives';
|
|
3
4
|
import { BUTTON_PRESSED_OPACITY, SPACING_EXTRA_LARGE } from '../../constants';
|
|
4
5
|
// Carousel page indicator size + margins
|
|
@@ -31,7 +32,7 @@ export const getComponentButtonStyle = ({ styleParams, buttonType, }) => {
|
|
|
31
32
|
const pressedOpacity = pressed ? { opacity: BUTTON_PRESSED_OPACITY } : {};
|
|
32
33
|
// pass `pressed` to containerOverrideStyle and evaluate if the consumer passed a function for custom
|
|
33
34
|
// button style
|
|
34
|
-
const containerOverrideFinalStyle =
|
|
35
|
+
const containerOverrideFinalStyle = isFunction(containerOverrideStyle)
|
|
35
36
|
? containerOverrideStyle({ pressed })
|
|
36
37
|
: containerOverrideStyle;
|
|
37
38
|
return [
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import { Dimensions } from 'react-native';
|
|
3
|
+
import { isFunction } from '@aws-amplify/ui';
|
|
3
4
|
const getDeviceOrientation = () => {
|
|
4
5
|
const { height, width } = Dimensions.get('screen');
|
|
5
6
|
return height >= width ? 'portrait' : 'landscape';
|
|
@@ -21,7 +22,7 @@ export default function useDeviceOrientation() {
|
|
|
21
22
|
// which is deprecated in v0.65
|
|
22
23
|
const subscription = Dimensions.addEventListener('change', handler);
|
|
23
24
|
return () => {
|
|
24
|
-
if (
|
|
25
|
+
if (isFunction(subscription?.remove)) {
|
|
25
26
|
subscription.remove();
|
|
26
27
|
}
|
|
27
28
|
else {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
+
import { isFunction } from '@aws-amplify/ui';
|
|
2
3
|
export const usePressableContainerStyles = ({ overrideStyle, containerStyle, pressedStyle, }) => {
|
|
3
4
|
return useCallback(({ pressed }) => {
|
|
4
|
-
const pressedOverrideStyle =
|
|
5
|
+
const pressedOverrideStyle = isFunction(overrideStyle)
|
|
5
6
|
? overrideStyle({ pressed })
|
|
6
7
|
: overrideStyle;
|
|
7
8
|
return [
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { Pressable, Text } from 'react-native';
|
|
3
|
+
import { capitalize } from '@aws-amplify/ui';
|
|
3
4
|
import { usePressableContainerStyles } from '../../hooks';
|
|
4
5
|
import { useTheme } from '../../theme';
|
|
5
|
-
import { capitalize } from '../../utils';
|
|
6
6
|
import { getThemedStyles } from './styles';
|
|
7
7
|
export default function Button({ accessibilityRole = 'button', children, disabled, style, textStyle, variant = 'default', ...rest }) {
|
|
8
8
|
const theme = useTheme();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { Dimensions, FlatList, View, } from 'react-native';
|
|
3
|
+
import { isFunction } from '@aws-amplify/ui';
|
|
3
4
|
import CarouselPageIndicator from './CarouselPageIndicator';
|
|
4
5
|
import { VIEWABILITY_CONFIG } from './constants';
|
|
5
6
|
import { styles } from './styles';
|
|
@@ -39,8 +40,8 @@ export default function Carousel(props) {
|
|
|
39
40
|
// Clean up listener. Dimensions.removeEventListener is deprecated as of React Native 0.65 but it is technically
|
|
40
41
|
// available so try to remove via a `EmitterSubscription` first before falling back to `removeEventListener`
|
|
41
42
|
return () => {
|
|
42
|
-
if (
|
|
43
|
-
subscription
|
|
43
|
+
if (isFunction(subscription?.remove)) {
|
|
44
|
+
subscription.remove();
|
|
44
45
|
}
|
|
45
46
|
else {
|
|
46
47
|
Dimensions.removeEventListener('change', orientationHandler);
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import deepExtend from 'style-dictionary/lib/utils/deepExtend';
|
|
2
2
|
import resolveObject from 'style-dictionary/lib/utils/resolveObject';
|
|
3
3
|
import usesReference from 'style-dictionary/lib/utils/references/usesReference';
|
|
4
|
-
import { setupTokens } from '@aws-amplify/ui';
|
|
4
|
+
import { isFunction, setupTokens } from '@aws-amplify/ui';
|
|
5
5
|
import { defaultTheme } from './defaultTheme';
|
|
6
6
|
// This will resolve all references in component themes by either
|
|
7
7
|
// calling the component theme function with the already resolved base tokens
|
|
8
8
|
// OR
|
|
9
9
|
// resolving the component theme object
|
|
10
|
-
const setupComponents = (
|
|
11
|
-
const output =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
output[key] = value;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
10
|
+
const setupComponents = ({ components, tokens }) => {
|
|
11
|
+
const output = components
|
|
12
|
+
? Object.entries(components).reduce((acc, [key, value]) => ({
|
|
13
|
+
...acc,
|
|
14
|
+
[key]: isFunction(value) ? value(tokens) : value,
|
|
15
|
+
}), {})
|
|
16
|
+
: {};
|
|
23
17
|
return resolveObject({
|
|
24
|
-
...
|
|
18
|
+
...tokens,
|
|
25
19
|
components: output,
|
|
26
20
|
}).components;
|
|
27
21
|
};
|
|
@@ -99,7 +93,10 @@ export const createTheme = (theme, colorMode) => {
|
|
|
99
93
|
let { components } = mergedTheme;
|
|
100
94
|
// Resolve component token references too
|
|
101
95
|
if (mergedTheme.components) {
|
|
102
|
-
components = setupComponents({
|
|
96
|
+
components = setupComponents({
|
|
97
|
+
...mergedTheme,
|
|
98
|
+
tokens,
|
|
99
|
+
});
|
|
103
100
|
}
|
|
104
101
|
return { ...mergedTheme, tokens, components };
|
|
105
102
|
};
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.2.
|
|
1
|
+
export declare const VERSION = "1.2.9";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '1.2.
|
|
1
|
+
export const VERSION = '1.2.9';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-native",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -39,12 +39,11 @@
|
|
|
39
39
|
"react-native": "^0.68.1",
|
|
40
40
|
"react-native-safe-area-context": "^4.2.5",
|
|
41
41
|
"react-test-renderer": "^17.0.2",
|
|
42
|
-
"rimraf": "^3.0.2"
|
|
43
|
-
"type-fest": "^2.3.4"
|
|
42
|
+
"rimraf": "^3.0.2"
|
|
44
43
|
},
|
|
45
44
|
"dependencies": {
|
|
46
|
-
"@aws-amplify/ui": "5.5.
|
|
47
|
-
"@aws-amplify/ui-react-core": "2.1.
|
|
45
|
+
"@aws-amplify/ui": "5.5.6",
|
|
46
|
+
"@aws-amplify/ui-react-core": "2.1.14"
|
|
48
47
|
},
|
|
49
48
|
"peerDependencies": {
|
|
50
49
|
"aws-amplify": ">= 5.0.1",
|
|
@@ -2,7 +2,6 @@ import React, { useMemo } from 'react';
|
|
|
2
2
|
import { KeyboardAvoidingView, ScrollView } from 'react-native';
|
|
3
3
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
4
4
|
|
|
5
|
-
import { useDeviceOrientation } from '../../../hooks';
|
|
6
5
|
import { useTheme } from '../../../theme';
|
|
7
6
|
import { platform } from '../../../utils';
|
|
8
7
|
|
|
@@ -17,10 +16,6 @@ const BEHAVIOR = platform.IS_IOS ? 'padding' : 'height';
|
|
|
17
16
|
// otherwise dismiss
|
|
18
17
|
const KEYBOARD_SHOULD_PERSIST_TAPS = 'handled';
|
|
19
18
|
|
|
20
|
-
// TEMPORARY: value to prevent initial `TextField` from being pushed too high
|
|
21
|
-
// in default use case
|
|
22
|
-
const KEYBOARD_VERTICAL_OFFSET = platform.IS_IOS ? -160 : -80;
|
|
23
|
-
|
|
24
19
|
export default function DefaultContainer({
|
|
25
20
|
alwaysBounceVertical = ALWAYS_BOUNCE_VERTICAL,
|
|
26
21
|
behavior = BEHAVIOR,
|
|
@@ -33,14 +28,8 @@ export default function DefaultContainer({
|
|
|
33
28
|
...rest
|
|
34
29
|
}: ContainerProps): JSX.Element | null {
|
|
35
30
|
const theme = useTheme();
|
|
36
|
-
const { isPortraitMode } = useDeviceOrientation();
|
|
37
31
|
const insets = useSafeAreaInsets();
|
|
38
32
|
|
|
39
|
-
const verticalOffset =
|
|
40
|
-
keyboardVerticalOffset ?? isPortraitMode
|
|
41
|
-
? KEYBOARD_VERTICAL_OFFSET
|
|
42
|
-
: undefined;
|
|
43
|
-
|
|
44
33
|
const themedStyle = useMemo(() => {
|
|
45
34
|
const { bottom, left, right, top } = insets;
|
|
46
35
|
return getThemedStyles(theme, {
|
|
@@ -54,7 +43,7 @@ export default function DefaultContainer({
|
|
|
54
43
|
return (
|
|
55
44
|
<KeyboardAvoidingView
|
|
56
45
|
behavior={behavior}
|
|
57
|
-
keyboardVerticalOffset={
|
|
46
|
+
keyboardVerticalOffset={keyboardVerticalOffset}
|
|
58
47
|
style={[themedStyle.keyboardAvoidingView, keyboardAvoidingViewStyle]}
|
|
59
48
|
>
|
|
60
49
|
<ScrollView
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
+
import { capitalize } from '@aws-amplify/ui';
|
|
3
4
|
|
|
4
5
|
import { icons } from '../../../assets';
|
|
5
|
-
import { capitalize } from '../../../utils';
|
|
6
6
|
import { FederatedProviderButton } from '../FederatedProviderButton';
|
|
7
7
|
import { Divider } from '../../../primitives';
|
|
8
8
|
|
package/src/InAppMessaging/components/InAppMessageDisplay/__tests__/InAppMessageDisplay.spec.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Text, View } from 'react-native';
|
|
3
3
|
import { render } from '@testing-library/react-native';
|
|
4
|
-
import { useMessage } from '@aws-amplify/ui-react-core';
|
|
4
|
+
import { MessageLayout, useMessage } from '@aws-amplify/ui-react-core';
|
|
5
5
|
|
|
6
6
|
import InAppMessageDisplay from '../InAppMessageDisplay';
|
|
7
7
|
|
|
@@ -15,7 +15,7 @@ describe('InAppMessageDisplay', () => {
|
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
it('renders the expected component in the happy path', () => {
|
|
18
|
-
const Component = ({ layout }) => (
|
|
18
|
+
const Component = ({ layout }: { layout: MessageLayout }) => (
|
|
19
19
|
<View>
|
|
20
20
|
<Text>{layout}</Text>
|
|
21
21
|
</View>
|
|
@@ -60,7 +60,7 @@ describe('useMessageImage', () => {
|
|
|
60
60
|
|
|
61
61
|
(prefetchNetworkImage as jest.Mock).mockResolvedValue('loaded');
|
|
62
62
|
(Image.getSize as jest.Mock).mockImplementationOnce(
|
|
63
|
-
(_, __, onError: (error) => void) => {
|
|
63
|
+
(_, __, onError: (error: string) => void) => {
|
|
64
64
|
onError(error);
|
|
65
65
|
}
|
|
66
66
|
);
|
|
@@ -139,7 +139,8 @@ describe('getComponentButtonStyle', () => {
|
|
|
139
139
|
const unpressedStyle = { backgroundColor: 'fuschia' };
|
|
140
140
|
const overrideStyle = {
|
|
141
141
|
primaryButton: {
|
|
142
|
-
container: ({ pressed }
|
|
142
|
+
container: ({ pressed }: { pressed: boolean }) =>
|
|
143
|
+
pressed ? pressedStyle : unpressedStyle,
|
|
143
144
|
},
|
|
144
145
|
};
|
|
145
146
|
const styleParams = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { isFunction } from '@aws-amplify/ui';
|
|
2
3
|
import {
|
|
3
4
|
MessageComponentBaseProps,
|
|
4
5
|
MessageLayout,
|
|
@@ -64,10 +65,9 @@ export const getComponentButtonStyle = ({
|
|
|
64
65
|
|
|
65
66
|
// pass `pressed` to containerOverrideStyle and evaluate if the consumer passed a function for custom
|
|
66
67
|
// button style
|
|
67
|
-
const containerOverrideFinalStyle =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
: containerOverrideStyle;
|
|
68
|
+
const containerOverrideFinalStyle = isFunction(containerOverrideStyle)
|
|
69
|
+
? containerOverrideStyle({ pressed })
|
|
70
|
+
: containerOverrideStyle;
|
|
71
71
|
|
|
72
72
|
return [
|
|
73
73
|
pressedOpacity,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Dimensions, EventSubscription
|
|
1
|
+
import { Dimensions, EventSubscription } from 'react-native';
|
|
2
2
|
import { renderHook } from '@testing-library/react-hooks';
|
|
3
|
-
import useDeviceOrientation
|
|
3
|
+
import useDeviceOrientation, {
|
|
4
|
+
DeviceOrientation,
|
|
5
|
+
} from '../useDeviceOrientation';
|
|
4
6
|
|
|
5
7
|
const dimensions = {
|
|
6
8
|
landscape: { height: 100, width: 300 },
|
|
@@ -74,7 +76,7 @@ describe('useDeviceOrientation', () => {
|
|
|
74
76
|
'returns the expected values when the device is in %s mode',
|
|
75
77
|
(deviceOrientation, isLandscapeMode, isPortraitMode) => {
|
|
76
78
|
getSpy.mockImplementation(
|
|
77
|
-
(_: string) => dimensions[deviceOrientation
|
|
79
|
+
(_: string) => dimensions[deviceOrientation as DeviceOrientation]
|
|
78
80
|
);
|
|
79
81
|
|
|
80
82
|
const { result } = renderHook(() => useDeviceOrientation());
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import { Dimensions, EventSubscription } from 'react-native';
|
|
3
3
|
|
|
4
|
+
import { isFunction } from '@aws-amplify/ui';
|
|
5
|
+
|
|
4
6
|
export type DeviceOrientation = 'portrait' | 'landscape';
|
|
5
7
|
const getDeviceOrientation = (): DeviceOrientation => {
|
|
6
8
|
const { height, width } = Dimensions.get('screen');
|
|
@@ -35,7 +37,7 @@ export default function useDeviceOrientation(): {
|
|
|
35
37
|
) as unknown as EventSubscription;
|
|
36
38
|
|
|
37
39
|
return () => {
|
|
38
|
-
if (
|
|
40
|
+
if (isFunction(subscription?.remove)) {
|
|
39
41
|
subscription.remove();
|
|
40
42
|
} else {
|
|
41
43
|
Dimensions.removeEventListener('change', handler);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
+
import { isFunction } from '@aws-amplify/ui';
|
|
2
3
|
import {
|
|
3
4
|
PressableProps,
|
|
4
5
|
PressableStateCallbackType,
|
|
@@ -35,10 +36,9 @@ export const usePressableContainerStyles = ({
|
|
|
35
36
|
}: PressableStateCallbackType) => StyleProp<ViewStyle>) => {
|
|
36
37
|
return useCallback(
|
|
37
38
|
({ pressed }: PressableStateCallbackType): StyleProp<ViewStyle> => {
|
|
38
|
-
const pressedOverrideStyle =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
: overrideStyle;
|
|
39
|
+
const pressedOverrideStyle = isFunction(overrideStyle)
|
|
40
|
+
? overrideStyle({ pressed })
|
|
41
|
+
: overrideStyle;
|
|
42
42
|
return [
|
|
43
43
|
containerStyle,
|
|
44
44
|
pressed ? pressedStyle : undefined,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { Pressable, Text, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { capitalize } from '@aws-amplify/ui';
|
|
4
4
|
|
|
5
|
+
import { usePressableContainerStyles } from '../../hooks';
|
|
5
6
|
import { useTheme } from '../../theme';
|
|
6
|
-
import { capitalize } from '../../utils';
|
|
7
7
|
import { getThemedStyles } from './styles';
|
|
8
8
|
import { ButtonProps } from './types';
|
|
9
9
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Dimensions,
|
|
4
|
-
EventSubscription,
|
|
5
4
|
FlatList,
|
|
6
5
|
ListRenderItemInfo,
|
|
7
6
|
ScaledSize,
|
|
8
7
|
View,
|
|
9
8
|
ViewToken,
|
|
10
9
|
} from 'react-native';
|
|
10
|
+
import { isFunction } from '@aws-amplify/ui';
|
|
11
11
|
|
|
12
12
|
import CarouselPageIndicator from './CarouselPageIndicator';
|
|
13
13
|
import { VIEWABILITY_CONFIG } from './constants';
|
|
@@ -63,13 +63,13 @@ export default function Carousel<T>(
|
|
|
63
63
|
const subscription = Dimensions.addEventListener(
|
|
64
64
|
'change',
|
|
65
65
|
orientationHandler
|
|
66
|
-
)
|
|
66
|
+
);
|
|
67
67
|
|
|
68
68
|
// Clean up listener. Dimensions.removeEventListener is deprecated as of React Native 0.65 but it is technically
|
|
69
69
|
// available so try to remove via a `EmitterSubscription` first before falling back to `removeEventListener`
|
|
70
70
|
return () => {
|
|
71
|
-
if (
|
|
72
|
-
subscription
|
|
71
|
+
if (isFunction(subscription?.remove)) {
|
|
72
|
+
subscription.remove();
|
|
73
73
|
} else {
|
|
74
74
|
Dimensions.removeEventListener('change', orientationHandler);
|
|
75
75
|
}
|
|
@@ -6,7 +6,6 @@ import Checkbox from '../Checkbox';
|
|
|
6
6
|
import { useTheme } from '../../../theme';
|
|
7
7
|
import { getThemedStyles } from '../styles';
|
|
8
8
|
import { icons } from '../../../assets';
|
|
9
|
-
import { IconStyles } from '../../Icon/types';
|
|
10
9
|
|
|
11
10
|
const onChange = jest.fn();
|
|
12
11
|
const testID = 'checkboxTestID';
|
|
@@ -106,9 +105,7 @@ describe('Checkbox', () => {
|
|
|
106
105
|
undefined,
|
|
107
106
|
]);
|
|
108
107
|
|
|
109
|
-
const iconStyle = (
|
|
110
|
-
getByRole('image').props.style as IconStyles
|
|
111
|
-
)[0] as ImageStyle;
|
|
108
|
+
const iconStyle = (getByRole('image').props.style as ImageStyle[])[0];
|
|
112
109
|
expect(iconStyle.height).toBe(customSize);
|
|
113
110
|
expect(iconStyle.width).toBe(customSize);
|
|
114
111
|
});
|
|
@@ -121,9 +118,7 @@ describe('Checkbox', () => {
|
|
|
121
118
|
|
|
122
119
|
expect(toJSON()).toMatchSnapshot();
|
|
123
120
|
|
|
124
|
-
const checkboxStyle = (
|
|
125
|
-
getByTestId(testID).props.style as IconStyles
|
|
126
|
-
)[0] as ViewStyle;
|
|
121
|
+
const checkboxStyle = (getByTestId(testID).props.style as ViewStyle[])[0];
|
|
127
122
|
expect(checkboxStyle.flexDirection).toBe('column');
|
|
128
123
|
});
|
|
129
124
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { fireEvent, render, renderHook } from '@testing-library/react-native';
|
|
3
|
+
import { capitalize } from '@aws-amplify/ui';
|
|
4
|
+
|
|
3
5
|
import { useTheme } from '../../../theme';
|
|
4
|
-
import { capitalize } from '../../../utils';
|
|
5
6
|
import { RADIO_DOT_PROPORTION } from '../getRadioDimensions';
|
|
6
7
|
import Radio, { CONTAINER_TEST_ID, DOT_TEST_ID } from '../Radio';
|
|
7
8
|
import { getThemedStyles } from '../styles';
|
package/src/theme/createTheme.ts
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import deepExtend from 'style-dictionary/lib/utils/deepExtend';
|
|
2
2
|
import resolveObject from 'style-dictionary/lib/utils/resolveObject';
|
|
3
3
|
import usesReference from 'style-dictionary/lib/utils/references/usesReference';
|
|
4
|
-
import { setupTokens } from '@aws-amplify/ui';
|
|
5
|
-
import { Theme, StrictTheme, ColorMode } from './types';
|
|
4
|
+
import { isFunction, setupTokens } from '@aws-amplify/ui';
|
|
5
|
+
import { Theme, StrictTheme, ColorMode, Components } from './types';
|
|
6
6
|
import { defaultTheme } from './defaultTheme';
|
|
7
7
|
|
|
8
8
|
// This will resolve all references in component themes by either
|
|
9
9
|
// calling the component theme function with the already resolved base tokens
|
|
10
10
|
// OR
|
|
11
11
|
// resolving the component theme object
|
|
12
|
-
const setupComponents = (
|
|
13
|
-
const output =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
12
|
+
const setupComponents = ({ components, tokens }: StrictTheme) => {
|
|
13
|
+
const output = components
|
|
14
|
+
? Object.entries(components).reduce(
|
|
15
|
+
(acc, [key, value]) => ({
|
|
16
|
+
...acc,
|
|
17
|
+
[key]: isFunction(value) ? (value(tokens) as typeof value) : value,
|
|
18
|
+
}),
|
|
19
|
+
{} as Components<'components'>
|
|
20
|
+
)
|
|
21
|
+
: {};
|
|
22
|
+
|
|
24
23
|
return resolveObject({
|
|
25
|
-
...
|
|
24
|
+
...tokens,
|
|
26
25
|
components: output,
|
|
27
26
|
}).components;
|
|
28
27
|
};
|
|
@@ -123,7 +122,10 @@ export const createTheme = (
|
|
|
123
122
|
|
|
124
123
|
// Resolve component token references too
|
|
125
124
|
if (mergedTheme.components) {
|
|
126
|
-
components = setupComponents({
|
|
125
|
+
components = setupComponents({
|
|
126
|
+
...mergedTheme,
|
|
127
|
+
tokens,
|
|
128
|
+
}) as Components<'output'>;
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
return { ...mergedTheme, tokens, components };
|
package/src/utils/index.ts
CHANGED
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '1.2.
|
|
1
|
+
export const VERSION = '1.2.9';
|
package/tsconfig.dist.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from '@react-native-async-storage/async-storage/jest/async-storage-mock';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from '@react-native-community/netinfo/jest/netinfo-mock.js';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
declare const SafeAreaProvider = "SafeAreaProvider";
|
|
3
|
-
declare const SafeAreaView = "SafeAreaView";
|
|
4
|
-
declare const useSafeAreaInsets: jest.Mock<{
|
|
5
|
-
bottom: number;
|
|
6
|
-
top: number;
|
|
7
|
-
}, []>;
|
|
8
|
-
export { SafeAreaProvider, SafeAreaView, useSafeAreaInsets };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
jest.mock('react-native-safe-area-context');
|
|
2
|
-
const SafeAreaProvider = 'SafeAreaProvider';
|
|
3
|
-
const SafeAreaView = 'SafeAreaView';
|
|
4
|
-
// return somewhat arbitrary values, safe area insets of iPhone 13
|
|
5
|
-
const useSafeAreaInsets = jest.fn(() => ({ bottom: 44, top: 47 }));
|
|
6
|
-
export { SafeAreaProvider, SafeAreaView, useSafeAreaInsets };
|
package/dist/utils/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function capitalize<T extends string>(value: T): Capitalize<T>;
|
package/dist/utils/utils.js
DELETED
package/src/utils/utils.ts
DELETED