@momo-kits/foundation 0.113.0-optimize.5 → 0.113.0-optimize.8
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/Badge/Badge.tsx +10 -2
- package/Badge/types.ts +2 -0
- package/Button/index.tsx +12 -3
- package/CheckBox/index.tsx +10 -1
- package/CheckBox/types.ts +5 -0
- package/Input/Input.tsx +24 -5
- package/Input/InputDropDown.tsx +12 -2
- package/Input/InputMoney.tsx +8 -0
- package/Input/common.tsx +9 -2
- package/Input/index.tsx +42 -0
- package/Layout/Card.tsx +4 -1
- package/Layout/Section.tsx +4 -1
- package/Radio/index.tsx +12 -1
- package/Radio/types.ts +5 -0
- package/package.json +1 -1
package/Badge/Badge.tsx
CHANGED
|
@@ -7,7 +7,12 @@ import styles from './styles';
|
|
|
7
7
|
import {Colors} from '../Consts';
|
|
8
8
|
import {Text} from '../Text';
|
|
9
9
|
|
|
10
|
-
const Badge: FC<BadgeProps> = ({
|
|
10
|
+
const Badge: FC<BadgeProps> = ({
|
|
11
|
+
label = 'Label',
|
|
12
|
+
style,
|
|
13
|
+
backgroundColor,
|
|
14
|
+
accessibilityLabel,
|
|
15
|
+
}) => {
|
|
11
16
|
const {theme} = useContext(ApplicationContext);
|
|
12
17
|
|
|
13
18
|
const isValidatedColor = () => {
|
|
@@ -46,7 +51,10 @@ const Badge: FC<BadgeProps> = ({label = 'Label', style, backgroundColor}) => {
|
|
|
46
51
|
|
|
47
52
|
return (
|
|
48
53
|
<View style={[style, styles.badge, {backgroundColor: badgeColor}]}>
|
|
49
|
-
<Text
|
|
54
|
+
<Text
|
|
55
|
+
color={Colors.black_01}
|
|
56
|
+
typography={'action_xxs_bold'}
|
|
57
|
+
accessibilityLabel={accessibilityLabel}>
|
|
50
58
|
{formatTitle()}
|
|
51
59
|
</Text>
|
|
52
60
|
</View>
|
package/Badge/types.ts
CHANGED
package/Button/index.tsx
CHANGED
|
@@ -76,6 +76,8 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
76
76
|
onPress: () => void;
|
|
77
77
|
|
|
78
78
|
params?: any;
|
|
79
|
+
|
|
80
|
+
accessibilityLabelTitle?: string;
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
const Button: FC<ButtonProps> = ({
|
|
@@ -89,7 +91,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
89
91
|
title = 'Button',
|
|
90
92
|
onPress,
|
|
91
93
|
params,
|
|
92
|
-
|
|
94
|
+
accessibilityLabelTitle,
|
|
93
95
|
...rest
|
|
94
96
|
}) => {
|
|
95
97
|
const {theme, config} = useContext(ApplicationContext);
|
|
@@ -225,7 +227,11 @@ const Button: FC<ButtonProps> = ({
|
|
|
225
227
|
const typography = getTypography();
|
|
226
228
|
const textColor = getTextColor();
|
|
227
229
|
return (
|
|
228
|
-
<Text
|
|
230
|
+
<Text
|
|
231
|
+
typography={typography}
|
|
232
|
+
color={textColor}
|
|
233
|
+
numberOfLines={1}
|
|
234
|
+
accessibilityLabel={accessibilityLabelTitle}>
|
|
229
235
|
{title}
|
|
230
236
|
</Text>
|
|
231
237
|
);
|
|
@@ -311,7 +317,10 @@ const Button: FC<ButtonProps> = ({
|
|
|
311
317
|
<TouchableOpacity
|
|
312
318
|
{...rest}
|
|
313
319
|
disabled={type === 'disabled'}
|
|
314
|
-
|
|
320
|
+
accessibilityState={{
|
|
321
|
+
...rest.accessibilityState,
|
|
322
|
+
disabled: type === 'disabled',
|
|
323
|
+
}}
|
|
315
324
|
activeOpacity={0.5}
|
|
316
325
|
onPress={onPress}
|
|
317
326
|
style={buttonStyle}>
|
package/CheckBox/index.tsx
CHANGED
|
@@ -15,6 +15,8 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
15
15
|
indeterminate,
|
|
16
16
|
params,
|
|
17
17
|
accessibilityLabel,
|
|
18
|
+
accessibilityState,
|
|
19
|
+
accessibilityLabelLabel,
|
|
18
20
|
}) => {
|
|
19
21
|
const {theme} = useContext(ApplicationContext);
|
|
20
22
|
const haveValue = value || indeterminate;
|
|
@@ -47,6 +49,7 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
47
49
|
}}>
|
|
48
50
|
<TouchableOpacity
|
|
49
51
|
accessibilityLabel={accessibilityLabel}
|
|
52
|
+
accessibilityState={accessibilityState}
|
|
50
53
|
activeOpacity={0.8}
|
|
51
54
|
onPress={() => onChange?.(!value)}
|
|
52
55
|
disabled={disabled}
|
|
@@ -64,7 +67,13 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
64
67
|
/>
|
|
65
68
|
)}
|
|
66
69
|
</View>
|
|
67
|
-
{!!label &&
|
|
70
|
+
{!!label && (
|
|
71
|
+
<Text
|
|
72
|
+
typography={'body_default_regular'}
|
|
73
|
+
accessibilityLabel={accessibilityLabelLabel}>
|
|
74
|
+
{label}
|
|
75
|
+
</Text>
|
|
76
|
+
)}
|
|
68
77
|
</TouchableOpacity>
|
|
69
78
|
</ComponentContext.Provider>
|
|
70
79
|
);
|
package/CheckBox/types.ts
CHANGED
package/Input/Input.tsx
CHANGED
|
@@ -13,7 +13,11 @@ import {
|
|
|
13
13
|
TouchableOpacity,
|
|
14
14
|
View,
|
|
15
15
|
} from 'react-native';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
ApplicationContext,
|
|
18
|
+
ComponentContext,
|
|
19
|
+
setAutomationID,
|
|
20
|
+
} from '../Application';
|
|
17
21
|
import {Icon} from '../Icon';
|
|
18
22
|
import {Loader} from '../Loader';
|
|
19
23
|
import {exportFontFamily, Text} from '../Text';
|
|
@@ -61,6 +65,11 @@ const Input = forwardRef(
|
|
|
61
65
|
onPressFloatingIcon,
|
|
62
66
|
onPressLeadingIcon,
|
|
63
67
|
showClearIcon = true,
|
|
68
|
+
accessibilityLabelErrorMessage,
|
|
69
|
+
accessibilityLabelFloatingValue,
|
|
70
|
+
accessibilityLabelLeadingIcon,
|
|
71
|
+
accessibilityLabelTrailingIcon,
|
|
72
|
+
accessibilityLabelClearIcon,
|
|
64
73
|
...props
|
|
65
74
|
}: InputProps,
|
|
66
75
|
ref
|
|
@@ -117,7 +126,8 @@ const Input = forwardRef(
|
|
|
117
126
|
return (
|
|
118
127
|
<TouchableOpacity
|
|
119
128
|
onPress={() => setSecureTextInput(!secureTextInput)}
|
|
120
|
-
style={styles.icon}
|
|
129
|
+
style={styles.icon}
|
|
130
|
+
accessibilityLabel={accessibilityLabelTrailingIcon}>
|
|
121
131
|
<Icon
|
|
122
132
|
color={color}
|
|
123
133
|
size={24}
|
|
@@ -190,11 +200,14 @@ const Input = forwardRef(
|
|
|
190
200
|
required={required}
|
|
191
201
|
floatingIcon={floatingIcon}
|
|
192
202
|
onPress={onPressFloatingIcon}
|
|
203
|
+
accessibilityLabel={accessibilityLabelFloatingValue}
|
|
193
204
|
/>
|
|
194
205
|
<View style={styles.inputView}>
|
|
195
206
|
{!!leadingIcon && (
|
|
196
207
|
<View style={styles.leadingIconContainer}>
|
|
197
|
-
<TouchableOpacity
|
|
208
|
+
<TouchableOpacity
|
|
209
|
+
onPress={onPressLeadingIcon}
|
|
210
|
+
accessibilityLabel={accessibilityLabelLeadingIcon}>
|
|
198
211
|
<Icon
|
|
199
212
|
color={leadingIconColor}
|
|
200
213
|
source={leadingIcon}
|
|
@@ -205,7 +218,11 @@ const Input = forwardRef(
|
|
|
205
218
|
)}
|
|
206
219
|
<TextInput
|
|
207
220
|
{...props}
|
|
208
|
-
|
|
221
|
+
{...setAutomationID(accessibilityLabel)}
|
|
222
|
+
accessibilityState={{
|
|
223
|
+
...props.accessibilityState,
|
|
224
|
+
disabled: disabled,
|
|
225
|
+
}}
|
|
209
226
|
editable={editable && !disabled}
|
|
210
227
|
secureTextEntry={secure}
|
|
211
228
|
textAlignVertical="center"
|
|
@@ -234,7 +251,8 @@ const Input = forwardRef(
|
|
|
234
251
|
{showClearIcon && focused && haveValue && (
|
|
235
252
|
<TouchableOpacity
|
|
236
253
|
style={styles.iconWrapper}
|
|
237
|
-
onPress={onClearText}
|
|
254
|
+
onPress={onClearText}
|
|
255
|
+
accessibilityLabel={accessibilityLabelClearIcon}>
|
|
238
256
|
<Icon
|
|
239
257
|
source="24_navigation_close_circle_full"
|
|
240
258
|
size={16}
|
|
@@ -272,6 +290,7 @@ const Input = forwardRef(
|
|
|
272
290
|
errorMessage={errorMessage}
|
|
273
291
|
errorSpacing={errorSpacing}
|
|
274
292
|
hintText={hintText}
|
|
293
|
+
accessibilityLabel={accessibilityLabelErrorMessage}
|
|
275
294
|
/>
|
|
276
295
|
</View>
|
|
277
296
|
</ComponentContext.Provider>
|
package/Input/InputDropDown.tsx
CHANGED
|
@@ -28,6 +28,10 @@ const InputDropDown = ({
|
|
|
28
28
|
accessibilityLabel,
|
|
29
29
|
hintText,
|
|
30
30
|
multiline,
|
|
31
|
+
accessibilityLabelText,
|
|
32
|
+
accessibilityLabelTouchable,
|
|
33
|
+
accessibilityLabelErrorMessage,
|
|
34
|
+
accessibilityLabelFloatingValue,
|
|
31
35
|
}: InputDropDownProps) => {
|
|
32
36
|
const {theme} = useContext(ApplicationContext);
|
|
33
37
|
|
|
@@ -59,6 +63,7 @@ const InputDropDown = ({
|
|
|
59
63
|
required={required}
|
|
60
64
|
floatingIcon={floatingIcon}
|
|
61
65
|
onPress={onPressFloatingIcon}
|
|
66
|
+
accessibilityLabel={accessibilityLabelFloatingValue}
|
|
62
67
|
/>
|
|
63
68
|
<View style={styles.inputDropDownView}>
|
|
64
69
|
{!!leadingIcon && (
|
|
@@ -83,7 +88,8 @@ const InputDropDown = ({
|
|
|
83
88
|
<Text
|
|
84
89
|
numberOfLines={multiline ? undefined : 1}
|
|
85
90
|
typography={'body_default_regular'}
|
|
86
|
-
color={value ? textColor : placeholderColor}
|
|
91
|
+
color={value ? textColor : placeholderColor}
|
|
92
|
+
accessibilityLabel={accessibilityLabelText}>
|
|
87
93
|
{value || placeholder}
|
|
88
94
|
</Text>
|
|
89
95
|
</View>
|
|
@@ -112,12 +118,16 @@ const InputDropDown = ({
|
|
|
112
118
|
<TouchableOpacity
|
|
113
119
|
activeOpacity={0.6}
|
|
114
120
|
onPress={onPress}
|
|
115
|
-
style={[style, styles.wrapper]}
|
|
121
|
+
style={[style, styles.wrapper]}
|
|
122
|
+
accessibilityLabel={accessibilityLabelTouchable}
|
|
123
|
+
accessibilityState={{disabled}}
|
|
124
|
+
disabled={disabled}>
|
|
116
125
|
{renderInputView()}
|
|
117
126
|
<ErrorView
|
|
118
127
|
errorMessage={errorMessage}
|
|
119
128
|
errorSpacing={errorSpacing}
|
|
120
129
|
hintText={hintText}
|
|
130
|
+
accessibilityLabel={accessibilityLabelErrorMessage}
|
|
121
131
|
/>
|
|
122
132
|
</TouchableOpacity>
|
|
123
133
|
</ComponentContext.Provider>
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -57,6 +57,8 @@ const InputMoney = forwardRef(
|
|
|
57
57
|
placeholder = '0đ',
|
|
58
58
|
currency = 'đ',
|
|
59
59
|
showClearIcon = true,
|
|
60
|
+
accessibilityLabelErrorMessage,
|
|
61
|
+
accessibilityLabelFloatingValue,
|
|
60
62
|
...props
|
|
61
63
|
}: InputMoneyProps,
|
|
62
64
|
ref
|
|
@@ -142,11 +144,16 @@ const InputMoney = forwardRef(
|
|
|
142
144
|
required={required}
|
|
143
145
|
floatingIcon={floatingIcon}
|
|
144
146
|
onPress={onPressFloatingIcon}
|
|
147
|
+
accessibilityLabel={accessibilityLabelFloatingValue}
|
|
145
148
|
/>
|
|
146
149
|
<View style={styles.inputView}>
|
|
147
150
|
<TextInput
|
|
148
151
|
{...props}
|
|
149
152
|
accessibilityLabel={accessibilityLabel}
|
|
153
|
+
accessibilityState={{
|
|
154
|
+
...props.accessibilityState,
|
|
155
|
+
disabled: disabled,
|
|
156
|
+
}}
|
|
150
157
|
editable={!disabled}
|
|
151
158
|
ref={inputRef}
|
|
152
159
|
keyboardType={'number-pad'}
|
|
@@ -217,6 +224,7 @@ const InputMoney = forwardRef(
|
|
|
217
224
|
errorMessage={errorMessage}
|
|
218
225
|
errorSpacing={errorSpacing}
|
|
219
226
|
hintText={hintText}
|
|
227
|
+
accessibilityLabel={accessibilityLabelErrorMessage}
|
|
220
228
|
/>
|
|
221
229
|
</View>
|
|
222
230
|
</ComponentContext.Provider>
|
package/Input/common.tsx
CHANGED
|
@@ -22,6 +22,7 @@ type FloatingViewProps = {
|
|
|
22
22
|
required?: boolean;
|
|
23
23
|
style?: ViewStyle;
|
|
24
24
|
onPress?: (e: GestureResponderEvent) => void;
|
|
25
|
+
accessibilityLabel?: string;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
type TrailingProps = {
|
|
@@ -80,7 +81,8 @@ export const ErrorView: FC<{
|
|
|
80
81
|
errorMessage?: string;
|
|
81
82
|
errorSpacing?: boolean;
|
|
82
83
|
hintText?: string;
|
|
83
|
-
|
|
84
|
+
accessibilityLabel?: string;
|
|
85
|
+
}> = ({errorMessage, errorSpacing, hintText, accessibilityLabel}) => {
|
|
84
86
|
const {theme} = useContext(ApplicationContext);
|
|
85
87
|
const errorColor = theme.colors.error.primary;
|
|
86
88
|
const hintColor = theme.colors.text.hint;
|
|
@@ -98,6 +100,7 @@ export const ErrorView: FC<{
|
|
|
98
100
|
<Text
|
|
99
101
|
style={Styles.flex}
|
|
100
102
|
color={errorMessage ? errorColor : hintColor}
|
|
103
|
+
accessibilityLabel={accessibilityLabel}
|
|
101
104
|
typography={'description_default_regular'}>
|
|
102
105
|
{errorMessage ?? hintTextDefault}
|
|
103
106
|
</Text>
|
|
@@ -118,6 +121,7 @@ export const FloatingView: FC<FloatingViewProps> = ({
|
|
|
118
121
|
required,
|
|
119
122
|
style,
|
|
120
123
|
onPress,
|
|
124
|
+
accessibilityLabel,
|
|
121
125
|
}) => {
|
|
122
126
|
const {theme} = useContext(ApplicationContext);
|
|
123
127
|
|
|
@@ -139,7 +143,10 @@ export const FloatingView: FC<FloatingViewProps> = ({
|
|
|
139
143
|
},
|
|
140
144
|
style,
|
|
141
145
|
]}>
|
|
142
|
-
<Text
|
|
146
|
+
<Text
|
|
147
|
+
color={floatingTextColor}
|
|
148
|
+
typography={'label_s_medium'}
|
|
149
|
+
accessibilityLabel={accessibilityLabel}>
|
|
143
150
|
{floatingValue}
|
|
144
151
|
{required && (
|
|
145
152
|
<Text
|
package/Input/index.tsx
CHANGED
|
@@ -131,6 +131,36 @@ export interface InputProps extends TextInputProps {
|
|
|
131
131
|
* Optional. Represents the style of the Input component.
|
|
132
132
|
*/
|
|
133
133
|
showClearIcon?: boolean;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Optional. Represents the accessibility label for the error message.
|
|
137
|
+
* This is read out by screen readers.
|
|
138
|
+
*/
|
|
139
|
+
accessibilityLabelErrorMessage?: string;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Optional. Represents the accessibility label for the Floating Value.
|
|
143
|
+
* This is read out by screen readers.
|
|
144
|
+
*/
|
|
145
|
+
accessibilityLabelFloatingValue?: string;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Optional. Represents the accessibility label for the leading Icon.
|
|
149
|
+
* This is read out by screen readers.
|
|
150
|
+
*/
|
|
151
|
+
accessibilityLabelLeadingIcon?: string;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Optional. Represents the accessibility label for the trailing Icon.
|
|
155
|
+
* This is read out by screen readers.
|
|
156
|
+
*/
|
|
157
|
+
accessibilityLabelTrailingIcon?: string;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Optional. Represents the accessibility label for the clear Icon.
|
|
161
|
+
* This is read out by screen readers.
|
|
162
|
+
*/
|
|
163
|
+
accessibilityLabelClearIcon?: string;
|
|
134
164
|
}
|
|
135
165
|
|
|
136
166
|
export interface InputTextAreaProps extends Omit<InputProps, 'size'> {
|
|
@@ -295,6 +325,18 @@ export interface InputDropDownProps
|
|
|
295
325
|
* Optional. Represents the data for the dropdown.
|
|
296
326
|
*/
|
|
297
327
|
multiline?: boolean;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Optional. Represents the accessibility label for the InputDropDown component.
|
|
331
|
+
* This is read out by screen readers.
|
|
332
|
+
*/
|
|
333
|
+
accessibilityLabelText?: string;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Optional. Represents the accessibility Touchable for the InputDropDown component.
|
|
337
|
+
* This is read out by screen readers.
|
|
338
|
+
*/
|
|
339
|
+
accessibilityLabelTouchable?: string;
|
|
298
340
|
}
|
|
299
341
|
|
|
300
342
|
export type InputRef = {
|
package/Layout/Card.tsx
CHANGED
|
@@ -27,6 +27,7 @@ const Card: React.FC<CardProps> = ({
|
|
|
27
27
|
style,
|
|
28
28
|
backgroundImage,
|
|
29
29
|
useShadow = false,
|
|
30
|
+
accessibilityLabel,
|
|
30
31
|
...props
|
|
31
32
|
}) => {
|
|
32
33
|
const {showGrid, theme} = useContext(ApplicationContext);
|
|
@@ -156,7 +157,9 @@ const Card: React.FC<CardProps> = ({
|
|
|
156
157
|
},
|
|
157
158
|
!!backgroundImage && {backgroundColor: undefined},
|
|
158
159
|
useShadow && Shadow.Light,
|
|
159
|
-
]}
|
|
160
|
+
]}
|
|
161
|
+
accessibilityLabel={accessibilityLabel}
|
|
162
|
+
>
|
|
160
163
|
{!!backgroundImage && (
|
|
161
164
|
<Image
|
|
162
165
|
source={{uri: backgroundImage}}
|
package/Layout/Section.tsx
CHANGED
|
@@ -33,6 +33,7 @@ const Section: React.FC<SectionProps> = ({
|
|
|
33
33
|
useMargin = true,
|
|
34
34
|
backgroundImage,
|
|
35
35
|
style,
|
|
36
|
+
accessibilityLabel,
|
|
36
37
|
...props
|
|
37
38
|
}) => {
|
|
38
39
|
const {showGrid} = useContext(ApplicationContext);
|
|
@@ -161,7 +162,9 @@ const Section: React.FC<SectionProps> = ({
|
|
|
161
162
|
flexDirection: 'row',
|
|
162
163
|
flexWrap: 'wrap',
|
|
163
164
|
},
|
|
164
|
-
]}
|
|
165
|
+
]}
|
|
166
|
+
accessibilityLabel={accessibilityLabel}
|
|
167
|
+
>
|
|
165
168
|
{!!backgroundImage && (
|
|
166
169
|
<Image
|
|
167
170
|
source={{uri: backgroundImage}}
|
package/Radio/index.tsx
CHANGED
|
@@ -16,6 +16,8 @@ const Radio: FC<RadioProps> = ({
|
|
|
16
16
|
style,
|
|
17
17
|
params,
|
|
18
18
|
accessibilityLabel,
|
|
19
|
+
accessibilityLabelText,
|
|
20
|
+
accessibilityState,
|
|
19
21
|
}) => {
|
|
20
22
|
const {theme} = useContext(ApplicationContext);
|
|
21
23
|
const selected = value === groupValue;
|
|
@@ -50,6 +52,7 @@ const Radio: FC<RadioProps> = ({
|
|
|
50
52
|
}}>
|
|
51
53
|
<TouchableOpacity
|
|
52
54
|
accessibilityLabel={accessibilityLabel}
|
|
55
|
+
accessibilityState={accessibilityState}
|
|
53
56
|
onPress={onChange}
|
|
54
57
|
disabled={disabled}
|
|
55
58
|
style={[
|
|
@@ -67,10 +70,18 @@ const Radio: FC<RadioProps> = ({
|
|
|
67
70
|
{marginRight: label ? Spacing.S : 0},
|
|
68
71
|
]}
|
|
69
72
|
/>
|
|
70
|
-
{!!label &&
|
|
73
|
+
{!!label && (
|
|
74
|
+
<Text
|
|
75
|
+
typography={'body_default_regular'}
|
|
76
|
+
style={styles.radioText}
|
|
77
|
+
accessibilityLabel={accessibilityLabelText}>
|
|
78
|
+
{label}
|
|
79
|
+
</Text>
|
|
80
|
+
)}
|
|
71
81
|
</TouchableOpacity>
|
|
72
82
|
</ComponentContext.Provider>
|
|
73
83
|
);
|
|
74
84
|
};
|
|
75
85
|
|
|
76
86
|
export {Radio};
|
|
87
|
+
export type {RadioProps};
|
package/Radio/types.ts
CHANGED