@momo-kits/foundation 0.77.8 → 0.78.1
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/BottomTab.tsx +13 -3
- package/Application/Components.tsx +51 -4
- package/Application/ModalScreen.tsx +17 -16
- package/Application/Navigation.ts +4 -2
- package/Application/NavigationContainer.tsx +22 -1
- package/Application/index.ts +8 -2
- package/Application/types.ts +19 -15
- package/Application/utils.tsx +13 -0
- package/Assets/DotAnimation.json +256 -0
- package/Assets/SpinnerAnimation.json +1027 -0
- package/Button/index.tsx +25 -14
- package/CheckBox/index.tsx +29 -24
- package/CheckBox/styles.ts +1 -1
- package/CheckBox/types.ts +1 -1
- package/Consts/styles.ts +0 -26
- package/Divider/index.tsx +2 -0
- package/Input/Input.tsx +126 -106
- package/Input/InputMoney.tsx +118 -110
- package/Input/InputSearch.tsx +129 -134
- package/Input/InputTextArea.tsx +126 -118
- package/Input/common.tsx +11 -5
- package/Input/index.tsx +12 -0
- package/Layout/Card.tsx +9 -2
- package/Layout/GridSystem.tsx +1 -1
- package/Layout/Item.tsx +15 -2
- package/Layout/Screen.tsx +76 -8
- package/Layout/Section.tsx +36 -3
- package/Layout/index.ts +1 -1
- package/Layout/types.ts +0 -37
- package/Layout/utils.ts +6 -9
- package/Loader/DotLoader.tsx +37 -0
- package/Loader/Loader.tsx +13 -0
- package/Loader/ProgressBar.tsx +44 -0
- package/Loader/Spinner.tsx +29 -0
- package/Loader/index.tsx +4 -0
- package/Loader/styles.ts +10 -0
- package/Loader/types.ts +35 -0
- package/Loader/utils.ts +25 -0
- package/Pagination/PaginationNumber.tsx +1 -2
- package/Pagination/PaginationWhiteDot.tsx +1 -3
- package/Popup/PopupNotify.tsx +11 -17
- package/Popup/PopupPromotion.tsx +19 -13
- package/Popup/types.ts +9 -1
- package/Radio/index.tsx +1 -1
- package/Skeleton/types.ts +3 -0
- package/Text/index.tsx +1 -16
- package/Text/utils.ts +1 -1
- package/code-scanner.js +51 -0
- package/index.ts +2 -0
- package/package.json +8 -4
- package/tsconfig.json +25 -0
- package/Application/NavigationButton.tsx +0 -54
package/Input/InputMoney.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {FC, useContext, useRef, useState} from 'react';
|
|
1
|
+
import React, {FC, forwardRef, useContext, useRef, useState} from 'react';
|
|
2
2
|
import {
|
|
3
3
|
NativeSyntheticEvent,
|
|
4
4
|
TextInput,
|
|
@@ -13,123 +13,131 @@ import {InputMoneyProps} from './index';
|
|
|
13
13
|
import {Icon} from '../Icon';
|
|
14
14
|
import {formatMoneyToNumber, formatNumberToMoney} from './utils';
|
|
15
15
|
|
|
16
|
-
const InputMoney: FC<InputMoneyProps> = (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
16
|
+
const InputMoney: FC<InputMoneyProps> = forwardRef(
|
|
17
|
+
(
|
|
18
|
+
{
|
|
19
|
+
onChangeText,
|
|
20
|
+
floatingValue,
|
|
21
|
+
floatingIcon,
|
|
22
|
+
size = 'small',
|
|
23
|
+
onBlur,
|
|
24
|
+
onFocus,
|
|
25
|
+
errorMessage,
|
|
26
|
+
icon,
|
|
27
|
+
disabled,
|
|
28
|
+
floatingIconColor,
|
|
29
|
+
iconColor,
|
|
30
|
+
required,
|
|
31
|
+
errorSpacing,
|
|
32
|
+
...props
|
|
33
|
+
},
|
|
34
|
+
ref,
|
|
35
|
+
) => {
|
|
36
|
+
const {theme} = useContext(ApplicationContext);
|
|
37
|
+
const [focused, setFocused] = useState(false);
|
|
38
|
+
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
39
|
+
const [value, setValue] = useState('');
|
|
40
|
+
const onClearText = () => {
|
|
41
|
+
inputRef?.current?.clear();
|
|
42
|
+
setValue('');
|
|
43
|
+
onChangeText?.('');
|
|
44
|
+
};
|
|
45
|
+
const _onChangeText = (text: string) => {
|
|
46
|
+
if (text.length < value.length && value.indexOf(text) === 0) {
|
|
47
|
+
text = value.slice(0, -2) + 'đ';
|
|
48
|
+
}
|
|
49
|
+
const valueFormat = formatMoneyToNumber(text, 'đ');
|
|
50
|
+
setValue(formatNumberToMoney(valueFormat, 'đ'));
|
|
51
|
+
onChangeText?.(formatMoneyToNumber(text, 'đ').toString());
|
|
52
|
+
};
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
55
|
+
setFocused(true);
|
|
56
|
+
onFocus?.(e);
|
|
57
|
+
};
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
60
|
+
setFocused(false);
|
|
61
|
+
onBlur?.(e);
|
|
62
|
+
};
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
const renderInputView = () => {
|
|
65
|
+
const disabledColor = theme.colors.text.disable;
|
|
66
|
+
let textColor = theme.colors.text.default;
|
|
67
|
+
let placeholderColor = theme.colors.text.hint;
|
|
68
|
+
let iconTintColor = iconColor;
|
|
64
69
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
if (disabled) {
|
|
71
|
+
textColor = disabledColor;
|
|
72
|
+
placeholderColor = disabledColor;
|
|
73
|
+
iconTintColor = disabledColor;
|
|
74
|
+
}
|
|
70
75
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
/>
|
|
86
|
-
<View style={styles.inputView}>
|
|
87
|
-
<TextInput
|
|
88
|
-
{...props}
|
|
89
|
-
accessibilityLabel={`TextInput`}
|
|
90
|
-
editable={!disabled}
|
|
91
|
-
textAlignVertical="top"
|
|
92
|
-
ref={inputRef}
|
|
93
|
-
keyboardType={'number-pad'}
|
|
94
|
-
style={[
|
|
95
|
-
styles.moneyInput,
|
|
96
|
-
{
|
|
97
|
-
color: textColor,
|
|
98
|
-
},
|
|
99
|
-
]}
|
|
100
|
-
value={value}
|
|
101
|
-
onChangeText={_onChangeText}
|
|
102
|
-
onFocus={_onFocus}
|
|
103
|
-
onBlur={_onBlur}
|
|
104
|
-
selectionColor={theme.colors.primary}
|
|
105
|
-
placeholderTextColor={placeholderColor}
|
|
106
|
-
placeholder={'0đ'}
|
|
76
|
+
return (
|
|
77
|
+
<View
|
|
78
|
+
style={[
|
|
79
|
+
styles.inputWrapper,
|
|
80
|
+
{backgroundColor: theme.colors.background.surface},
|
|
81
|
+
getSizeStyle(size),
|
|
82
|
+
getBorderColor(theme, focused, errorMessage, disabled),
|
|
83
|
+
]}>
|
|
84
|
+
<FloatingView
|
|
85
|
+
floatingValue={floatingValue}
|
|
86
|
+
floatingIconColor={floatingIconColor}
|
|
87
|
+
disabled={disabled}
|
|
88
|
+
required={required}
|
|
89
|
+
floatingIcon={floatingIcon}
|
|
107
90
|
/>
|
|
91
|
+
<View style={styles.inputView}>
|
|
92
|
+
<TextInput
|
|
93
|
+
{...props}
|
|
94
|
+
accessibilityLabel={`TextInput`}
|
|
95
|
+
editable={!disabled}
|
|
96
|
+
textAlignVertical="top"
|
|
97
|
+
ref={inputRef}
|
|
98
|
+
keyboardType={'number-pad'}
|
|
99
|
+
style={[
|
|
100
|
+
styles.moneyInput,
|
|
101
|
+
{
|
|
102
|
+
color: textColor,
|
|
103
|
+
},
|
|
104
|
+
]}
|
|
105
|
+
value={value}
|
|
106
|
+
onChangeText={_onChangeText}
|
|
107
|
+
onFocus={_onFocus}
|
|
108
|
+
onBlur={_onBlur}
|
|
109
|
+
selectionColor={theme.colors.primary}
|
|
110
|
+
placeholderTextColor={placeholderColor}
|
|
111
|
+
placeholder={'0đ'}
|
|
112
|
+
/>
|
|
113
|
+
</View>
|
|
114
|
+
<View style={styles.iconView}>
|
|
115
|
+
{focused && (
|
|
116
|
+
<TouchableOpacity
|
|
117
|
+
style={styles.iconWrapper}
|
|
118
|
+
onPress={onClearText}>
|
|
119
|
+
<Icon
|
|
120
|
+
source="24_navigation_close_circle_full"
|
|
121
|
+
size={16}
|
|
122
|
+
color={theme.colors.text.hint}
|
|
123
|
+
/>
|
|
124
|
+
</TouchableOpacity>
|
|
125
|
+
)}
|
|
126
|
+
{!!icon && <Icon color={iconTintColor} source={icon} />}
|
|
127
|
+
</View>
|
|
108
128
|
</View>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
)}
|
|
119
|
-
{!!icon && <Icon color={iconTintColor} source={icon} />}
|
|
120
|
-
</View>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<View
|
|
134
|
+
style={styles.wrapper}
|
|
135
|
+
accessibilityLabel={`InputMoney/${floatingValue}`}>
|
|
136
|
+
{renderInputView()}
|
|
137
|
+
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
121
138
|
</View>
|
|
122
139
|
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return (
|
|
126
|
-
<View
|
|
127
|
-
style={styles.wrapper}
|
|
128
|
-
accessibilityLabel={`InputMoney/${floatingValue}`}>
|
|
129
|
-
{renderInputView()}
|
|
130
|
-
<ErrorView errorMessage={errorMessage} />
|
|
131
|
-
</View>
|
|
132
|
-
);
|
|
133
|
-
};
|
|
140
|
+
},
|
|
141
|
+
);
|
|
134
142
|
|
|
135
143
|
export default InputMoney;
|
package/Input/InputSearch.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {FC, useContext, useRef, useState} from 'react';
|
|
1
|
+
import React, {FC, forwardRef, useContext, useRef, useState} from 'react';
|
|
2
2
|
import {
|
|
3
3
|
NativeSyntheticEvent,
|
|
4
4
|
TextInput,
|
|
@@ -13,151 +13,146 @@ import {Icon} from '../Icon';
|
|
|
13
13
|
import {Text} from '../Text';
|
|
14
14
|
import {checkTyping} from './utils';
|
|
15
15
|
|
|
16
|
-
const InputSearch: FC<InputSearchProps> = (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
16
|
+
const InputSearch: FC<InputSearchProps> = forwardRef(
|
|
17
|
+
(
|
|
18
|
+
{
|
|
19
|
+
placeholder,
|
|
20
|
+
onFocus,
|
|
21
|
+
onBlur,
|
|
22
|
+
iconColor,
|
|
23
|
+
value,
|
|
24
|
+
onChangeText,
|
|
25
|
+
icon,
|
|
26
|
+
buttonText = 'Hủy',
|
|
27
|
+
showButtonText = true,
|
|
28
|
+
showBorder = true,
|
|
29
|
+
style,
|
|
30
|
+
defaultValue,
|
|
31
|
+
onPressButtonText,
|
|
32
|
+
...props
|
|
33
|
+
},
|
|
34
|
+
ref,
|
|
35
|
+
) => {
|
|
36
|
+
const {theme} = useContext(ApplicationContext);
|
|
37
|
+
const [focused, setFocused] = useState(false);
|
|
38
|
+
const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
|
|
39
|
+
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
40
|
+
let iconTintColor = iconColor;
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
43
|
+
setFocused(true);
|
|
44
|
+
onFocus?.(e);
|
|
45
|
+
};
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
48
|
+
setFocused(false);
|
|
49
|
+
onBlur?.(e);
|
|
50
|
+
};
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
const onClearText = () => {
|
|
53
|
+
inputRef?.current?.clear();
|
|
54
|
+
_onChangeText('');
|
|
55
|
+
};
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
const _onChangeText = (text: string) => {
|
|
58
|
+
checkTyping(text, haveValue, setHaveValue);
|
|
59
|
+
onChangeText?.(text);
|
|
60
|
+
};
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
: theme.colors.background.surface;
|
|
62
|
+
const renderInputView = () => {
|
|
63
|
+
let textColor = theme.colors.text.default;
|
|
64
|
+
let placeholderColor = theme.colors.text.hint;
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
]}
|
|
86
|
-
value={value}
|
|
87
|
-
onChangeText={_onChangeText}
|
|
88
|
-
onFocus={_onFocus}
|
|
89
|
-
onBlur={_onBlur}
|
|
90
|
-
placeholder={placeholder}
|
|
91
|
-
selectionColor={theme.colors.primary}
|
|
92
|
-
placeholderTextColor={placeholderColor}
|
|
93
|
-
/>
|
|
94
|
-
);
|
|
95
|
-
};
|
|
66
|
+
return (
|
|
67
|
+
<TextInput
|
|
68
|
+
{...props}
|
|
69
|
+
accessibilityLabel={`TextInput`}
|
|
70
|
+
textAlignVertical="top"
|
|
71
|
+
ref={inputRef}
|
|
72
|
+
style={[
|
|
73
|
+
styles.searchInput,
|
|
74
|
+
{
|
|
75
|
+
color: textColor,
|
|
76
|
+
},
|
|
77
|
+
]}
|
|
78
|
+
value={value}
|
|
79
|
+
onChangeText={_onChangeText}
|
|
80
|
+
onFocus={_onFocus}
|
|
81
|
+
onBlur={_onBlur}
|
|
82
|
+
placeholder={placeholder}
|
|
83
|
+
selectionColor={theme.colors.primary}
|
|
84
|
+
placeholderTextColor={placeholderColor}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
96
88
|
|
|
97
|
-
|
|
89
|
+
const renderIconView = () => {
|
|
90
|
+
return (
|
|
91
|
+
<View
|
|
92
|
+
style={{
|
|
93
|
+
flexDirection: 'row',
|
|
94
|
+
}}>
|
|
95
|
+
{focused && haveValue && (
|
|
96
|
+
<TouchableOpacity style={styles.iconWrapper} onPress={onClearText}>
|
|
97
|
+
<Icon
|
|
98
|
+
source="24_navigation_close_circle_full"
|
|
99
|
+
size={16}
|
|
100
|
+
color={theme.colors.text.hint}
|
|
101
|
+
/>
|
|
102
|
+
</TouchableOpacity>
|
|
103
|
+
)}
|
|
104
|
+
{!!icon && (
|
|
105
|
+
<View style={{flexDirection: 'row'}}>
|
|
106
|
+
<View
|
|
107
|
+
style={[
|
|
108
|
+
styles.divider,
|
|
109
|
+
{
|
|
110
|
+
backgroundColor: theme.colors.primary,
|
|
111
|
+
},
|
|
112
|
+
]}
|
|
113
|
+
/>
|
|
114
|
+
<Icon
|
|
115
|
+
color={iconTintColor}
|
|
116
|
+
source={icon}
|
|
117
|
+
style={styles.iconSearchInput}
|
|
118
|
+
/>
|
|
119
|
+
</View>
|
|
120
|
+
)}
|
|
121
|
+
</View>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
98
124
|
return (
|
|
99
125
|
<View
|
|
100
|
-
style={
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
126
|
+
style={[style, styles.searchInputContainer]}
|
|
127
|
+
accessibilityLabel={`InputSearch/${placeholder}`}>
|
|
128
|
+
<View
|
|
129
|
+
style={[
|
|
130
|
+
styles.searchInputWrapper,
|
|
131
|
+
{
|
|
132
|
+
backgroundColor: theme.colors.background.surface,
|
|
133
|
+
borderColor: theme.colors.background.surface,
|
|
134
|
+
},
|
|
135
|
+
showBorder && {borderColor: theme.colors.border.default},
|
|
136
|
+
focused && {borderColor: theme.colors.primary},
|
|
137
|
+
]}>
|
|
138
|
+
<Icon
|
|
139
|
+
source={'navigation_search'}
|
|
140
|
+
size={24}
|
|
141
|
+
color={theme.colors.text.hint}
|
|
142
|
+
/>
|
|
143
|
+
{renderInputView()}
|
|
144
|
+
{renderIconView()}
|
|
145
|
+
</View>
|
|
146
|
+
{showButtonText && (
|
|
147
|
+
<TouchableOpacity onPress={onPressButtonText}>
|
|
148
|
+
<Text typography={'action_default'} style={styles.textButton}>
|
|
149
|
+
{buttonText}
|
|
150
|
+
</Text>
|
|
110
151
|
</TouchableOpacity>
|
|
111
152
|
)}
|
|
112
|
-
{!!icon && (
|
|
113
|
-
<View style={{flexDirection: 'row'}}>
|
|
114
|
-
<View
|
|
115
|
-
style={[
|
|
116
|
-
styles.divider,
|
|
117
|
-
{
|
|
118
|
-
backgroundColor: theme.colors.primary,
|
|
119
|
-
},
|
|
120
|
-
]}
|
|
121
|
-
/>
|
|
122
|
-
<Icon
|
|
123
|
-
color={iconTintColor}
|
|
124
|
-
source={icon}
|
|
125
|
-
style={styles.iconSearchInput}
|
|
126
|
-
/>
|
|
127
|
-
</View>
|
|
128
|
-
)}
|
|
129
153
|
</View>
|
|
130
154
|
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
<View
|
|
134
|
-
style={[style, styles.searchInputContainer]}
|
|
135
|
-
accessibilityLabel={`InputSearch/${placeholder}`}>
|
|
136
|
-
<View
|
|
137
|
-
style={[
|
|
138
|
-
getBorderColor(),
|
|
139
|
-
styles.searchInputWrapper,
|
|
140
|
-
{
|
|
141
|
-
backgroundColor: theme.colors.background.surface,
|
|
142
|
-
},
|
|
143
|
-
]}>
|
|
144
|
-
<Icon
|
|
145
|
-
source={'navigation_search'}
|
|
146
|
-
size={24}
|
|
147
|
-
color={theme.colors.text.hint}
|
|
148
|
-
/>
|
|
149
|
-
{renderInputView()}
|
|
150
|
-
{renderIconView()}
|
|
151
|
-
</View>
|
|
152
|
-
{showButtonText && (
|
|
153
|
-
<TouchableOpacity onPress={onPressButtonText}>
|
|
154
|
-
<Text typography={'action_default'} style={styles.textButton}>
|
|
155
|
-
{buttonText}
|
|
156
|
-
</Text>
|
|
157
|
-
</TouchableOpacity>
|
|
158
|
-
)}
|
|
159
|
-
</View>
|
|
160
|
-
);
|
|
161
|
-
};
|
|
155
|
+
},
|
|
156
|
+
);
|
|
162
157
|
|
|
163
158
|
export default InputSearch;
|