@aws-amplify/ui-react-native 1.2.19 → 1.2.21
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 +57 -0
- package/dist/Authenticator/Authenticator.d.ts +101 -148
- package/dist/Authenticator/Authenticator.js +7 -3
- package/dist/Authenticator/Defaults/ConfirmResetPassword/ConfirmResetPassword.d.ts +13 -2
- package/dist/Authenticator/Defaults/ConfirmResetPassword/ConfirmResetPassword.js +4 -3
- package/dist/Authenticator/Defaults/ConfirmSignIn/ConfirmSignIn.d.ts +13 -2
- package/dist/Authenticator/Defaults/ConfirmSignIn/ConfirmSignIn.js +4 -3
- package/dist/Authenticator/Defaults/ConfirmSignUp/ConfirmSignUp.d.ts +13 -2
- package/dist/Authenticator/Defaults/ConfirmSignUp/ConfirmSignUp.js +4 -3
- package/dist/Authenticator/Defaults/ConfirmVerifyUser/ConfirmVerifyUser.d.ts +13 -2
- package/dist/Authenticator/Defaults/ConfirmVerifyUser/ConfirmVerifyUser.js +4 -3
- package/dist/Authenticator/Defaults/ForceNewPassword/ForceNewPassword.d.ts +13 -2
- package/dist/Authenticator/Defaults/ForceNewPassword/ForceNewPassword.js +4 -3
- package/dist/Authenticator/Defaults/ResetPassword/ResetPassword.d.ts +13 -2
- package/dist/Authenticator/Defaults/ResetPassword/ResetPassword.js +4 -3
- package/dist/Authenticator/Defaults/SetupTOTP/SetupTOTP.d.ts +13 -2
- package/dist/Authenticator/Defaults/SetupTOTP/SetupTOTP.js +4 -3
- package/dist/Authenticator/Defaults/SignIn/SignIn.d.ts +13 -2
- package/dist/Authenticator/Defaults/SignIn/SignIn.js +4 -3
- package/dist/Authenticator/Defaults/SignUp/SignUp.d.ts +13 -2
- package/dist/Authenticator/Defaults/SignUp/SignUp.js +4 -3
- package/dist/Authenticator/Defaults/VerifyUser/VerifyUser.d.ts +13 -2
- package/dist/Authenticator/Defaults/VerifyUser/VerifyUser.js +4 -3
- package/dist/Authenticator/Defaults/types.d.ts +21 -20
- package/dist/Authenticator/common/DefaultContent/types.d.ts +1 -1
- package/dist/Authenticator/common/DefaultFormFields/DefaultRadioFormFields.d.ts +7 -3
- package/dist/Authenticator/common/DefaultFormFields/DefaultRadioFormFields.js +4 -3
- package/dist/Authenticator/common/DefaultFormFields/DefaultTextFormFields.d.ts +6 -2
- package/dist/Authenticator/common/DefaultFormFields/DefaultTextFormFields.js +3 -3
- package/dist/Authenticator/common/DefaultFormFields/types.d.ts +12 -3
- package/dist/Authenticator/hooks/types.d.ts +3 -2
- package/dist/Authenticator/hooks/useFieldValues/types.d.ts +4 -1
- package/dist/Authenticator/hooks/useFieldValues/useFieldValues.d.ts +1 -1
- package/dist/Authenticator/hooks/useFieldValues/useFieldValues.js +21 -3
- package/dist/Authenticator/hooks/useFieldValues/utils.d.ts +10 -1
- package/dist/Authenticator/hooks/useFieldValues/utils.js +32 -2
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useDeprecationWarning/index.d.ts +1 -0
- package/dist/hooks/useDeprecationWarning/index.js +1 -0
- package/dist/hooks/useDeprecationWarning/useDeprecationWarning.d.ts +6 -0
- package/dist/hooks/useDeprecationWarning/useDeprecationWarning.js +11 -0
- package/dist/primitives/TextField/TextField.js +2 -1
- package/dist/primitives/TextField/styles.js +3 -0
- package/dist/primitives/TextField/types.d.ts +1 -0
- package/dist/theme/createTheme.js +24 -18
- package/dist/theme/types.d.ts +1 -1
- package/dist/utils/platform.d.ts +5 -0
- package/dist/utils/platform.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/jest.config.js +1 -0
- package/package.json +6 -5
- package/src/Authenticator/Authenticator.tsx +9 -6
- package/src/Authenticator/Defaults/ConfirmResetPassword/ConfirmResetPassword.tsx +7 -3
- package/src/Authenticator/Defaults/ConfirmSignIn/ConfirmSignIn.tsx +7 -3
- package/src/Authenticator/Defaults/ConfirmSignIn/__tests__/ConfirmSignIn.spec.tsx +1 -0
- package/src/Authenticator/Defaults/ConfirmSignUp/ConfirmSignUp.tsx +7 -3
- package/src/Authenticator/Defaults/ConfirmSignUp/__tests__/ConfirmSignUp.spec.tsx +1 -0
- package/src/Authenticator/Defaults/ConfirmVerifyUser/ConfirmVerifyUser.tsx +7 -3
- package/src/Authenticator/Defaults/ConfirmVerifyUser/__tests__/ConfirmVerifyUser.spec.tsx +1 -0
- package/src/Authenticator/Defaults/ForceNewPassword/ForceNewPassword.tsx +7 -3
- package/src/Authenticator/Defaults/ForceNewPassword/__tests__/__snapshots__/ForceNewPassword.spec.tsx.snap +1 -1
- package/src/Authenticator/Defaults/ResetPassword/ResetPassword.tsx +7 -3
- package/src/Authenticator/Defaults/ResetPassword/__tests__/ResetPassword.spec.tsx +1 -0
- package/src/Authenticator/Defaults/SetupTOTP/SetupTOTP.tsx +7 -3
- package/src/Authenticator/Defaults/SetupTOTP/__tests__/SetupTOTP.spec.tsx +1 -0
- package/src/Authenticator/Defaults/SignIn/SignIn.tsx +7 -3
- package/src/Authenticator/Defaults/SignIn/__tests__/SignIn.spec.tsx +1 -0
- package/src/Authenticator/Defaults/SignUp/SignUp.tsx +7 -3
- package/src/Authenticator/Defaults/SignUp/__tests__/__snapshots__/SignUp.spec.tsx.snap +1 -1
- package/src/Authenticator/Defaults/VerifyUser/VerifyUser.tsx +7 -3
- package/src/Authenticator/Defaults/VerifyUser/__tests__/VerifyUser.spec.tsx +1 -0
- package/src/Authenticator/Defaults/types.ts +63 -49
- package/src/Authenticator/__tests__/Authenticator.spec.tsx +16 -19
- package/src/Authenticator/__tests__/__snapshots__/Authenticator.spec.tsx.snap +1 -9
- package/src/Authenticator/__tests__/withAuthenticator.spec.tsx +1 -1
- package/src/Authenticator/common/DefaultContent/types.ts +1 -4
- package/src/Authenticator/common/DefaultFormFields/DefaultRadioFormFields.tsx +8 -6
- package/src/Authenticator/common/DefaultFormFields/DefaultTextFormFields.tsx +10 -7
- package/src/Authenticator/common/DefaultFormFields/types.ts +15 -5
- package/src/Authenticator/hooks/types.ts +3 -0
- package/src/Authenticator/hooks/useFieldValues/__tests__/useFieldValues.spec.ts +75 -2
- package/src/Authenticator/hooks/useFieldValues/__tests__/utils.spec.ts +67 -1
- package/src/Authenticator/hooks/useFieldValues/types.ts +5 -0
- package/src/Authenticator/hooks/useFieldValues/useFieldValues.ts +26 -1
- package/src/Authenticator/hooks/useFieldValues/utils.ts +44 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useDeprecationWarning/__tests__/useDeprecationWarning.spec.ts +42 -0
- package/src/hooks/useDeprecationWarning/index.ts +1 -0
- package/src/hooks/useDeprecationWarning/useDeprecationWarning.ts +21 -0
- package/src/primitives/TextField/TextField.tsx +2 -1
- package/src/primitives/TextField/__tests__/TextField.spec.tsx +57 -8
- package/src/primitives/TextField/__tests__/__snapshots__/TextField.spec.tsx.snap +31 -31
- package/src/primitives/TextField/styles.ts +3 -0
- package/src/primitives/TextField/types.ts +1 -0
- package/src/theme/__tests__/createTheme.spec.ts +48 -0
- package/src/theme/createTheme.ts +44 -21
- package/src/theme/types.ts +17 -16
- package/src/utils/platform.ts +2 -0
- package/src/version.ts +1 -1
package/src/theme/createTheme.ts
CHANGED
|
@@ -2,21 +2,33 @@ 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
4
|
import { isFunction, setupTokens } from '@aws-amplify/ui';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Theme,
|
|
7
|
+
StrictTheme,
|
|
8
|
+
ColorMode,
|
|
9
|
+
Components,
|
|
10
|
+
StrictTokens,
|
|
11
|
+
} from './types';
|
|
6
12
|
import { defaultTheme } from './defaultTheme';
|
|
7
13
|
|
|
8
14
|
// This will resolve all references in component themes by either
|
|
9
15
|
// calling the component theme function with the already resolved base tokens
|
|
10
16
|
// OR
|
|
11
17
|
// resolving the component theme object
|
|
12
|
-
const setupComponents = ({
|
|
18
|
+
const setupComponents = ({
|
|
19
|
+
components,
|
|
20
|
+
tokens,
|
|
21
|
+
}: {
|
|
22
|
+
components: Components;
|
|
23
|
+
tokens: StrictTokens;
|
|
24
|
+
}) => {
|
|
13
25
|
const output = components
|
|
14
26
|
? Object.entries(components).reduce(
|
|
15
27
|
(acc, [key, value]) => ({
|
|
16
28
|
...acc,
|
|
17
29
|
[key]: isFunction(value) ? (value(tokens) as typeof value) : value,
|
|
18
30
|
}),
|
|
19
|
-
{}
|
|
31
|
+
{}
|
|
20
32
|
)
|
|
21
33
|
: {};
|
|
22
34
|
|
|
@@ -26,6 +38,16 @@ const setupComponents = ({ components, tokens }: StrictTheme) => {
|
|
|
26
38
|
}).components;
|
|
27
39
|
};
|
|
28
40
|
|
|
41
|
+
const shouldParseFloatValue = (pathKey: string) =>
|
|
42
|
+
[
|
|
43
|
+
'space',
|
|
44
|
+
'borderWidths',
|
|
45
|
+
'opacities',
|
|
46
|
+
'fontSizes',
|
|
47
|
+
'lineHeights',
|
|
48
|
+
'radii',
|
|
49
|
+
].includes(pathKey);
|
|
50
|
+
|
|
29
51
|
const setupToken = ({
|
|
30
52
|
token,
|
|
31
53
|
path = [],
|
|
@@ -39,27 +61,28 @@ const setupToken = ({
|
|
|
39
61
|
}): string | number => {
|
|
40
62
|
const { value } = token;
|
|
41
63
|
if (typeof value === 'string') {
|
|
42
|
-
// Perform transforms
|
|
43
|
-
if (path[0] === 'space') {
|
|
44
|
-
if (value.includes('rem')) {
|
|
45
|
-
return Math.floor(parseFloat(value) * 16 * spaceModifier);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (value.includes('rem')) {
|
|
49
|
-
return Math.floor(parseFloat(value) * 16);
|
|
50
|
-
}
|
|
51
|
-
if (value.includes('px')) {
|
|
52
|
-
return parseInt(value, 10);
|
|
53
|
-
}
|
|
54
|
-
if (path[0] === 'opacities') {
|
|
55
|
-
return parseFloat(value);
|
|
56
|
-
}
|
|
57
64
|
// Remove .value from references if there is a reference
|
|
65
|
+
// this needs to come first so we don't get NaNs for references
|
|
58
66
|
if (usesReference(value)) {
|
|
59
67
|
return value.replace('.value', '');
|
|
60
68
|
}
|
|
69
|
+
|
|
70
|
+
if (shouldParseFloatValue(path[0])) {
|
|
71
|
+
if (value.includes('rem')) {
|
|
72
|
+
if (path[0] === 'space') {
|
|
73
|
+
return Math.floor(parseFloat(value) * 16 * spaceModifier);
|
|
74
|
+
}
|
|
75
|
+
return Math.floor(parseFloat(value) * 16);
|
|
76
|
+
}
|
|
77
|
+
if (value.includes('px')) {
|
|
78
|
+
return parseInt(value, 10);
|
|
79
|
+
}
|
|
80
|
+
return parseFloat(value);
|
|
81
|
+
}
|
|
82
|
+
|
|
61
83
|
return value;
|
|
62
84
|
}
|
|
85
|
+
|
|
63
86
|
// Font Weights in RN are strings
|
|
64
87
|
if (path[0] === 'fontWeights') {
|
|
65
88
|
return `${value}`;
|
|
@@ -118,14 +141,14 @@ export const createTheme = (
|
|
|
118
141
|
}) as StrictTheme['tokens']
|
|
119
142
|
);
|
|
120
143
|
|
|
121
|
-
let
|
|
144
|
+
let components;
|
|
122
145
|
|
|
123
146
|
// Resolve component token references too
|
|
124
147
|
if (mergedTheme.components) {
|
|
125
148
|
components = setupComponents({
|
|
126
|
-
|
|
149
|
+
components: mergedTheme.components,
|
|
127
150
|
tokens,
|
|
128
|
-
})
|
|
151
|
+
});
|
|
129
152
|
}
|
|
130
153
|
|
|
131
154
|
return { ...mergedTheme, tokens, components };
|
package/src/theme/types.ts
CHANGED
|
@@ -26,22 +26,23 @@ type ComponentTheme<ComponentType, Output> = Output extends 'output'
|
|
|
26
26
|
: ((tokens: StrictTheme['tokens']) => ComponentType) | ComponentType;
|
|
27
27
|
|
|
28
28
|
// TODO: make optional all the way down
|
|
29
|
-
export type Components<Output
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
export type Components<Output extends 'input' | 'output' | unknown = unknown> =
|
|
30
|
+
{
|
|
31
|
+
button?: ComponentTheme<ButtonStyles, Output>;
|
|
32
|
+
checkbox?: ComponentTheme<CheckboxStyles, Output>;
|
|
33
|
+
divider?: ComponentTheme<DividerStyles, Output>;
|
|
34
|
+
errorMessage?: ComponentTheme<ErrorMessageStyles, Output>;
|
|
35
|
+
heading?: ComponentTheme<HeadingStyles, Output>;
|
|
36
|
+
icon?: ComponentTheme<IconStyles, Output>;
|
|
37
|
+
iconButton?: ComponentTheme<IconButtonStyles, Output>;
|
|
38
|
+
label?: ComponentTheme<LabelStyles, Output>;
|
|
39
|
+
passwordField?: ComponentTheme<PasswordFieldStyles, Output>;
|
|
40
|
+
phoneNumberField?: ComponentTheme<PhoneNumberFieldStyles, Output>;
|
|
41
|
+
radio?: ComponentTheme<RadioStyles, Output>;
|
|
42
|
+
radioGroup?: ComponentTheme<RadioGroupStyles, Output>;
|
|
43
|
+
tabs?: ComponentTheme<TabsStyles, Output>;
|
|
44
|
+
textField?: ComponentTheme<TextFieldStyles, Output>;
|
|
45
|
+
};
|
|
45
46
|
|
|
46
47
|
export type ColorMode = 'light' | 'dark' | 'system' | null;
|
|
47
48
|
export type Override = Omit<Theme, 'overrides'> & {
|
package/src/utils/platform.ts
CHANGED
|
@@ -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.
|
|
1
|
+
export const VERSION = '1.2.21';
|