@momo-kits/foundation 0.103.1 → 0.103.2
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/Application/Localize.ts +13 -6
- package/Application/NavigationContainer.tsx +2 -1
- package/Layout/styles.ts +0 -1
- package/Tag/index.tsx +9 -2
- package/Tag/types.ts +12 -0
- package/Text/index.tsx +3 -1
- package/Text/utils.ts +14 -2
- package/package.json +4 -3
- package/publish.sh +6 -6
package/Application/Localize.ts
CHANGED
|
@@ -17,20 +17,27 @@ class Localize {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
get getCurrentLanguage() {
|
|
21
|
+
return this.currentLanguage;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get getAssets() {
|
|
25
|
+
return this.assets;
|
|
26
|
+
}
|
|
27
|
+
|
|
20
28
|
translate(key: string) {
|
|
21
29
|
return this.assets[this.currentLanguage]?.[key] || key;
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
translateData(data: {vi: string; en: string}) {
|
|
25
|
-
return data[this.currentLanguage] ||
|
|
33
|
+
return data[this.currentLanguage] || JSON.stringify(data);
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
addTranslations(translations: LocalizationObject) {
|
|
29
|
-
this.assets =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.currentLanguage = language;
|
|
37
|
+
this.assets = {
|
|
38
|
+
vi: {...translations?.vi, ...this.assets.vi},
|
|
39
|
+
en: {...translations?.en, ...this.assets.en},
|
|
40
|
+
};
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
|
|
@@ -13,12 +13,13 @@ import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
|
|
|
13
13
|
import {NavigationContainerProps} from './types';
|
|
14
14
|
import {ApplicationContext} from './index';
|
|
15
15
|
import Localize from './Localize';
|
|
16
|
+
import {defaultTheme} from '../Consts';
|
|
16
17
|
|
|
17
18
|
const Stack = createStackNavigator();
|
|
18
19
|
|
|
19
20
|
const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
20
21
|
screen,
|
|
21
|
-
theme,
|
|
22
|
+
theme = defaultTheme,
|
|
22
23
|
options,
|
|
23
24
|
maxApi,
|
|
24
25
|
initialParams,
|
package/Layout/styles.ts
CHANGED
package/Tag/index.tsx
CHANGED
|
@@ -31,6 +31,8 @@ const Tag: FC<TagProps> = ({
|
|
|
31
31
|
size = 'large',
|
|
32
32
|
style,
|
|
33
33
|
customColor,
|
|
34
|
+
accessibilityLabelContainer,
|
|
35
|
+
accessibilityLabelText,
|
|
34
36
|
}) => {
|
|
35
37
|
let labelColor = textColor[color];
|
|
36
38
|
let tagColor = backgroundColor[color];
|
|
@@ -60,7 +62,9 @@ const Tag: FC<TagProps> = ({
|
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
return (
|
|
63
|
-
<View
|
|
65
|
+
<View
|
|
66
|
+
style={[style, sizeStyle, {backgroundColor: tagColor}]}
|
|
67
|
+
accessibilityLabel={accessibilityLabelContainer}>
|
|
64
68
|
{!!icon && (
|
|
65
69
|
<Icon
|
|
66
70
|
style={styles.icon}
|
|
@@ -69,7 +73,10 @@ const Tag: FC<TagProps> = ({
|
|
|
69
73
|
color={labelColor}
|
|
70
74
|
/>
|
|
71
75
|
)}
|
|
72
|
-
<Text
|
|
76
|
+
<Text
|
|
77
|
+
color={labelColor}
|
|
78
|
+
typography={'label_s_medium'}
|
|
79
|
+
accessibilityLabel={accessibilityLabelText}>
|
|
73
80
|
{label}
|
|
74
81
|
</Text>
|
|
75
82
|
</View>
|
package/Tag/types.ts
CHANGED
|
@@ -33,4 +33,16 @@ export type TagProps = {
|
|
|
33
33
|
* that can be applied to the Tag component.
|
|
34
34
|
*/
|
|
35
35
|
customColor?: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Overrides the text that's read by the screen reader when the user interacts with the element. By default, the
|
|
39
|
+
* label is constructed by traversing all the children and accumulating all the Text nodes separated by space.
|
|
40
|
+
*/
|
|
41
|
+
accessibilityLabelContainer?: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Overrides the text that's read by the screen reader when the user interacts with the element. By default, the
|
|
45
|
+
* label is constructed by traversing all the children and accumulating all the Text nodes separated by space.
|
|
46
|
+
*/
|
|
47
|
+
accessibilityLabelText?: string;
|
|
36
48
|
};
|
package/Text/index.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import {Text as RNText, TextProps as RNTextProps} from 'react-native';
|
|
|
3
3
|
import styles from './styles';
|
|
4
4
|
import {Typography, TypographyWeight} from './types';
|
|
5
5
|
import {ApplicationContext} from '../Application';
|
|
6
|
-
import {scaleSize} from './utils';
|
|
6
|
+
import {getAccessibilityID, scaleSize} from './utils';
|
|
7
7
|
|
|
8
8
|
const SFProText: TypographyWeight = {
|
|
9
9
|
100: 'Thin',
|
|
@@ -109,6 +109,7 @@ const Text: React.FC<TextProps> = ({
|
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
+
|
|
112
113
|
const textStyle = getTypoStyle(typography);
|
|
113
114
|
|
|
114
115
|
if (deprecatedValues.includes(typography)) {
|
|
@@ -120,6 +121,7 @@ const Text: React.FC<TextProps> = ({
|
|
|
120
121
|
return (
|
|
121
122
|
<RNText
|
|
122
123
|
{...rest}
|
|
124
|
+
{...getAccessibilityID((rest.accessibilityLabel))}
|
|
123
125
|
style={[style, textStyle, {color: color ?? theme.colors.text.default}]}>
|
|
124
126
|
{children ?? ''}
|
|
125
127
|
</RNText>
|
package/Text/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Dimensions} from 'react-native';
|
|
1
|
+
import {Dimensions, Platform} from 'react-native';
|
|
2
2
|
|
|
3
3
|
const deviceWidth = Dimensions.get('window').width;
|
|
4
4
|
const DEFAULT_SCREEN_SIZE = 375;
|
|
@@ -11,4 +11,16 @@ const scaleSize = (size: number) => {
|
|
|
11
11
|
|
|
12
12
|
return size;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
const getAccessibilityID = (accessibilityLabel = '') => {
|
|
15
|
+
if (Platform.OS ==='ios') {
|
|
16
|
+
return {
|
|
17
|
+
accessible: true,
|
|
18
|
+
testID: accessibilityLabel,
|
|
19
|
+
};
|
|
20
|
+
} else {
|
|
21
|
+
return {
|
|
22
|
+
accessibilityLabel,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export {scaleSize,getAccessibilityID};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.103.
|
|
3
|
+
"version": "0.103.2",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {},
|
|
@@ -39,8 +39,9 @@
|
|
|
39
39
|
"react-test-renderer": "17.0.1",
|
|
40
40
|
"typescript": "^4.0.3",
|
|
41
41
|
"@momo-platform/versions": "4.1.11",
|
|
42
|
-
"react-scanner": "^1.1.0"
|
|
42
|
+
"react-scanner": "^1.1.0",
|
|
43
|
+
"@types/color": "3.0.6"
|
|
43
44
|
},
|
|
44
45
|
"author": "@momo-kits/foundation",
|
|
45
46
|
"license": "ISC"
|
|
46
|
-
}
|
|
47
|
+
}
|
package/publish.sh
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
3
|
if [ "$1" == "stable" ]; then
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
npm version $(npm view @momo-kits/foundation@stable version)
|
|
5
|
+
npm version patch
|
|
6
6
|
npm publish --tag stable --access=public
|
|
7
7
|
elif [ "$1" == "latest" ]; then
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
npm version $(npm view @momo-kits/foundation@latest version)
|
|
9
|
+
npm version prerelease --preid=rc
|
|
10
10
|
npm publish --tag latest --access=public
|
|
11
11
|
else
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
npm version $(npm view @momo-kits/foundation@beta version)
|
|
13
|
+
npm version prerelease --preid=beta
|
|
14
14
|
npm publish --tag beta --access=public
|
|
15
15
|
fi
|
|
16
16
|
|