@momo-kits/foundation 0.81.43-tracking.7 → 0.81.43-tracking.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/Button/index.tsx +7 -6
- package/CheckBox/index.tsx +21 -34
- package/IconButton/index.tsx +10 -3
- package/Input/Input.tsx +5 -4
- package/Input/InputMoney.tsx +18 -5
- package/Input/InputOTP.tsx +5 -4
- package/Input/InputSearch.tsx +5 -5
- package/Input/index.tsx +4 -4
- package/Radio/index.tsx +19 -33
- package/Switch/index.tsx +14 -27
- package/package.json +1 -1
package/Button/index.tsx
CHANGED
|
@@ -74,9 +74,9 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
74
74
|
*/
|
|
75
75
|
onPress: () => void;
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
params?: any;
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
componentId?: string;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
const Button: FC<ButtonProps> = ({
|
|
@@ -89,8 +89,8 @@ const Button: FC<ButtonProps> = ({
|
|
|
89
89
|
loading = false,
|
|
90
90
|
title = 'Button',
|
|
91
91
|
onPress,
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
params,
|
|
93
|
+
componentId,
|
|
94
94
|
...rest
|
|
95
95
|
}) => {
|
|
96
96
|
const {theme, config} = useContext(ApplicationContext);
|
|
@@ -306,9 +306,10 @@ const Button: FC<ButtonProps> = ({
|
|
|
306
306
|
value={{
|
|
307
307
|
...screenInfo,
|
|
308
308
|
componentName: 'Button',
|
|
309
|
-
params
|
|
309
|
+
params,
|
|
310
310
|
state: type === 'disabled' ? 'disabled' : 'enabled',
|
|
311
|
-
|
|
311
|
+
componentId,
|
|
312
|
+
action: 'click',
|
|
312
313
|
}}>
|
|
313
314
|
<TouchableOpacity
|
|
314
315
|
{...rest}
|
package/CheckBox/index.tsx
CHANGED
|
@@ -6,10 +6,6 @@ import {ApplicationContext} from '../Application';
|
|
|
6
6
|
import {Text} from '../Text';
|
|
7
7
|
import {Icon} from '../Icon';
|
|
8
8
|
|
|
9
|
-
const {
|
|
10
|
-
ScreenContext,
|
|
11
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
12
|
-
|
|
13
9
|
const CheckBox: FC<CheckBoxProps> = ({
|
|
14
10
|
value,
|
|
15
11
|
disabled,
|
|
@@ -23,7 +19,6 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
23
19
|
const iconSource = indeterminate ? 'ic_minus' : 'ic_checked';
|
|
24
20
|
let borderColor = theme.colors.text.default;
|
|
25
21
|
let backgroundColor = theme.colors.background.surface;
|
|
26
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
27
22
|
|
|
28
23
|
if (haveValue) {
|
|
29
24
|
borderColor = theme.colors.primary;
|
|
@@ -40,35 +35,27 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
return (
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
size={20}
|
|
65
|
-
source={iconSource}
|
|
66
|
-
/>
|
|
67
|
-
)}
|
|
68
|
-
</View>
|
|
69
|
-
{!!label && <Text typography={'body_default_regular'}>{label}</Text>}
|
|
70
|
-
</TouchableOpacity>
|
|
71
|
-
</ScreenContext.Provider>
|
|
38
|
+
<TouchableOpacity
|
|
39
|
+
accessibilityLabel={`CheckBox/${label}/${value}`}
|
|
40
|
+
activeOpacity={0.8}
|
|
41
|
+
onPress={() => onChange?.(!value)}
|
|
42
|
+
disabled={disabled}
|
|
43
|
+
style={[style, styles.container]}>
|
|
44
|
+
<View
|
|
45
|
+
style={[
|
|
46
|
+
{borderColor, backgroundColor, borderWidth: 1},
|
|
47
|
+
styles.checkbox,
|
|
48
|
+
]}>
|
|
49
|
+
{haveValue && (
|
|
50
|
+
<Icon
|
|
51
|
+
color={theme.colors.background.surface}
|
|
52
|
+
size={20}
|
|
53
|
+
source={iconSource}
|
|
54
|
+
/>
|
|
55
|
+
)}
|
|
56
|
+
</View>
|
|
57
|
+
{!!label && <Text typography={'body_default_regular'}>{label}</Text>}
|
|
58
|
+
</TouchableOpacity>
|
|
72
59
|
);
|
|
73
60
|
};
|
|
74
61
|
|
package/IconButton/index.tsx
CHANGED
|
@@ -30,6 +30,10 @@ export interface IconButtonProps extends TouchableOpacityProps {
|
|
|
30
30
|
* Optional. Defines the size of the IconButton.
|
|
31
31
|
*/
|
|
32
32
|
size?: 'large' | 'small';
|
|
33
|
+
|
|
34
|
+
params?: any;
|
|
35
|
+
|
|
36
|
+
componentId?: string;
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
const IconButton: React.FC<IconButtonProps> = ({
|
|
@@ -37,6 +41,8 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
37
41
|
icon,
|
|
38
42
|
size,
|
|
39
43
|
onPress,
|
|
44
|
+
params,
|
|
45
|
+
componentId,
|
|
40
46
|
...rest
|
|
41
47
|
}) => {
|
|
42
48
|
const {theme} = useContext(ApplicationContext);
|
|
@@ -130,9 +136,10 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
130
136
|
value={{
|
|
131
137
|
...screenInfo,
|
|
132
138
|
componentName: 'IconButton',
|
|
133
|
-
params
|
|
134
|
-
|
|
135
|
-
|
|
139
|
+
params,
|
|
140
|
+
state: type === 'disabled' ? 'disabled' : 'enabled',
|
|
141
|
+
componentId,
|
|
142
|
+
action: 'click',
|
|
136
143
|
}}>
|
|
137
144
|
<TouchableOpacity
|
|
138
145
|
{...rest}
|
package/Input/Input.tsx
CHANGED
|
@@ -42,8 +42,8 @@ const Input = forwardRef(
|
|
|
42
42
|
fontWeight = 'Regular',
|
|
43
43
|
onPressIcon,
|
|
44
44
|
style,
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
params,
|
|
46
|
+
componentId,
|
|
47
47
|
...props
|
|
48
48
|
}: InputProps,
|
|
49
49
|
ref,
|
|
@@ -171,9 +171,10 @@ const Input = forwardRef(
|
|
|
171
171
|
value={{
|
|
172
172
|
...screenInfo,
|
|
173
173
|
componentName: 'Input',
|
|
174
|
-
params
|
|
174
|
+
params,
|
|
175
175
|
state: disabled ? 'disabled' : 'enabled',
|
|
176
|
-
|
|
176
|
+
componentId,
|
|
177
|
+
action: 'focus',
|
|
177
178
|
}}>
|
|
178
179
|
<View
|
|
179
180
|
style={[style, styles.wrapper]}
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useContext,
|
|
4
|
+
useImperativeHandle,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import {
|
|
3
9
|
NativeSyntheticEvent,
|
|
4
10
|
TextInput,
|
|
@@ -34,9 +40,9 @@ const InputMoney = forwardRef(
|
|
|
34
40
|
required = false,
|
|
35
41
|
errorSpacing,
|
|
36
42
|
style,
|
|
37
|
-
|
|
43
|
+
params,
|
|
38
44
|
defaultValue = '',
|
|
39
|
-
|
|
45
|
+
componentId,
|
|
40
46
|
...props
|
|
41
47
|
}: InputMoneyProps,
|
|
42
48
|
ref,
|
|
@@ -70,6 +76,12 @@ const InputMoney = forwardRef(
|
|
|
70
76
|
onChangeText?.(formatMoneyToNumber(text, 'đ').toString());
|
|
71
77
|
};
|
|
72
78
|
|
|
79
|
+
useImperativeHandle(ref, () => {
|
|
80
|
+
return {
|
|
81
|
+
setText: _onChangeText,
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
|
|
73
85
|
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
74
86
|
setFocused(true);
|
|
75
87
|
onFocus?.(e);
|
|
@@ -153,9 +165,10 @@ const InputMoney = forwardRef(
|
|
|
153
165
|
value={{
|
|
154
166
|
...screenInfo,
|
|
155
167
|
componentName: 'InputMoney',
|
|
156
|
-
params
|
|
168
|
+
params,
|
|
157
169
|
state: 'enable',
|
|
158
|
-
|
|
170
|
+
componentId,
|
|
171
|
+
action: 'focus',
|
|
159
172
|
}}>
|
|
160
173
|
<View
|
|
161
174
|
style={[style, styles.wrapper]}
|
package/Input/InputOTP.tsx
CHANGED
|
@@ -82,9 +82,9 @@ const InputOTP = forwardRef(
|
|
|
82
82
|
onFocus,
|
|
83
83
|
onBlur,
|
|
84
84
|
dataType = 'number',
|
|
85
|
-
|
|
85
|
+
params,
|
|
86
86
|
style,
|
|
87
|
-
|
|
87
|
+
componentId,
|
|
88
88
|
...props
|
|
89
89
|
}: InputOTPProps,
|
|
90
90
|
ref,
|
|
@@ -234,9 +234,10 @@ const InputOTP = forwardRef(
|
|
|
234
234
|
value={{
|
|
235
235
|
...screenInfo,
|
|
236
236
|
componentName: 'InputOTP',
|
|
237
|
-
params
|
|
237
|
+
params,
|
|
238
238
|
state: 'enable',
|
|
239
|
-
|
|
239
|
+
componentId,
|
|
240
|
+
action: 'focus',
|
|
240
241
|
}}>
|
|
241
242
|
<TouchableOpacity
|
|
242
243
|
activeOpacity={1}
|
package/Input/InputSearch.tsx
CHANGED
|
@@ -33,9 +33,8 @@ const InputSearch = forwardRef(
|
|
|
33
33
|
style,
|
|
34
34
|
defaultValue,
|
|
35
35
|
onPressButtonText,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
params,
|
|
37
|
+
componentId,
|
|
39
38
|
...props
|
|
40
39
|
}: InputSearchProps,
|
|
41
40
|
ref,
|
|
@@ -131,9 +130,10 @@ const InputSearch = forwardRef(
|
|
|
131
130
|
value={{
|
|
132
131
|
...screenInfo,
|
|
133
132
|
componentName: 'InputSearch',
|
|
134
|
-
params
|
|
133
|
+
params,
|
|
135
134
|
state: 'enabled',
|
|
136
|
-
|
|
135
|
+
componentId,
|
|
136
|
+
action: 'focus',
|
|
137
137
|
}}>
|
|
138
138
|
<View
|
|
139
139
|
style={[style, styles.searchInputContainer]}
|
package/Input/index.tsx
CHANGED
|
@@ -81,8 +81,8 @@ export interface InputProps extends TextInputProps {
|
|
|
81
81
|
|
|
82
82
|
onPressIcon?: () => void;
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
params?: any;
|
|
85
|
+
componentId?: string;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
type InputPropsWithoutSizeAndIcon = Omit<
|
|
@@ -130,9 +130,9 @@ export interface InputSearchProps extends TextInputProps {
|
|
|
130
130
|
*/
|
|
131
131
|
icon?: string;
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
params?: any;
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
componentId?: string;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
export interface InputMoneyProps extends InputPropsWithoutPlaceholder {}
|
package/Radio/index.tsx
CHANGED
|
@@ -7,10 +7,6 @@ import styles from './styles';
|
|
|
7
7
|
import {ApplicationContext} from '../Application';
|
|
8
8
|
import {Spacing} from '../Consts';
|
|
9
9
|
|
|
10
|
-
const {
|
|
11
|
-
ScreenContext,
|
|
12
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
13
|
-
|
|
14
10
|
const Radio: FC<RadioProps> = ({
|
|
15
11
|
value,
|
|
16
12
|
groupValue,
|
|
@@ -41,38 +37,28 @@ const Radio: FC<RadioProps> = ({
|
|
|
41
37
|
};
|
|
42
38
|
}
|
|
43
39
|
|
|
44
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
45
|
-
|
|
46
40
|
return (
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
<TouchableOpacity
|
|
42
|
+
accessibilityLabel={`Radio/${label}/${value}`}
|
|
43
|
+
onPress={onChange}
|
|
44
|
+
disabled={disabled}
|
|
45
|
+
style={[
|
|
46
|
+
style,
|
|
47
|
+
{
|
|
48
|
+
flexDirection: 'row',
|
|
49
|
+
alignItems: 'center',
|
|
53
50
|
},
|
|
54
|
-
}
|
|
55
|
-
<
|
|
56
|
-
onPress={onChange}
|
|
57
|
-
disabled={disabled}
|
|
51
|
+
]}>
|
|
52
|
+
<View
|
|
58
53
|
style={[
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
styles.radio,
|
|
68
|
-
checkBoxStyle,
|
|
69
|
-
disabledStyle,
|
|
70
|
-
{marginRight: label ? Spacing.XS : 0},
|
|
71
|
-
]}
|
|
72
|
-
/>
|
|
73
|
-
{!!label && <Text typography={'body_default_regular'}>{label}</Text>}
|
|
74
|
-
</TouchableOpacity>
|
|
75
|
-
</ScreenContext.Provider>
|
|
54
|
+
styles.radio,
|
|
55
|
+
checkBoxStyle,
|
|
56
|
+
disabledStyle,
|
|
57
|
+
{marginRight: label ? Spacing.XS : 0},
|
|
58
|
+
]}
|
|
59
|
+
/>
|
|
60
|
+
{!!label && <Text typography={'body_default_regular'}>{label}</Text>}
|
|
61
|
+
</TouchableOpacity>
|
|
76
62
|
);
|
|
77
63
|
};
|
|
78
64
|
|
package/Switch/index.tsx
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import React, {FC
|
|
1
|
+
import React, {FC} from 'react';
|
|
2
2
|
import {TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {SwitchProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import {Colors} from '../Consts';
|
|
6
6
|
|
|
7
|
-
const {
|
|
8
|
-
ScreenContext,
|
|
9
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
10
|
-
|
|
11
7
|
const Switch: FC<SwitchProps> = props => {
|
|
12
8
|
const {value, onChange, disabled, style} = props;
|
|
13
9
|
const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
|
|
14
10
|
const circleAlign = value ? 'flex-end' : 'flex-start';
|
|
15
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
16
11
|
|
|
17
12
|
let backgroundColor = value ? Colors.green_03 : Colors.black_07;
|
|
18
13
|
if (disabled) {
|
|
@@ -20,27 +15,19 @@ const Switch: FC<SwitchProps> = props => {
|
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
return (
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
styles.container,
|
|
37
|
-
{backgroundColor, alignItems: circleAlign},
|
|
38
|
-
]}>
|
|
39
|
-
<View style={[styles.circle, {backgroundColor: circleBackgroundColor}]}>
|
|
40
|
-
<View style={[styles.circleSmall, {backgroundColor}]} />
|
|
41
|
-
</View>
|
|
42
|
-
</TouchableOpacity>
|
|
43
|
-
</ScreenContext.Provider>
|
|
18
|
+
<TouchableOpacity
|
|
19
|
+
accessibilityLabel={'Switch'}
|
|
20
|
+
disabled={disabled}
|
|
21
|
+
onPress={() => onChange?.(!value)}
|
|
22
|
+
style={[
|
|
23
|
+
style,
|
|
24
|
+
styles.container,
|
|
25
|
+
{backgroundColor, alignItems: circleAlign},
|
|
26
|
+
]}>
|
|
27
|
+
<View style={[styles.circle, {backgroundColor: circleBackgroundColor}]}>
|
|
28
|
+
<View style={[styles.circleSmall, {backgroundColor}]} />
|
|
29
|
+
</View>
|
|
30
|
+
</TouchableOpacity>
|
|
44
31
|
);
|
|
45
32
|
};
|
|
46
33
|
|