@momo-kits/foundation 0.81.1-optimize.21 → 0.81.1-rc.0
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/BottomSheet.tsx +27 -23
- package/Application/BottomTab/BottomTabBar.tsx +2 -2
- package/Application/BottomTab/index.tsx +2 -3
- package/Application/Components.tsx +288 -42
- package/Application/Localize.ts +44 -0
- package/Application/ModalScreen.tsx +2 -2
- package/Application/Navigation.ts +4 -18
- package/Application/NavigationContainer.tsx +10 -21
- package/Application/Navigator.ts +14 -16
- package/Application/StackScreen.tsx +211 -113
- package/Application/index.ts +5 -3
- package/Application/types.ts +30 -11
- package/Application/utils.tsx +60 -18
- package/Badge/BadgeDotAnimation.tsx +95 -0
- package/Badge/index.tsx +2 -1
- package/Badge/styles.ts +50 -6
- package/Button/index.tsx +0 -1
- package/Icon/types.ts +0 -1
- package/Input/Input.tsx +51 -17
- package/Input/InputDropDown.tsx +44 -47
- package/Input/InputMoney.tsx +56 -6
- package/Input/InputOTP.tsx +10 -6
- package/Input/InputSearch.tsx +259 -146
- package/Input/TextTyping.tsx +113 -0
- package/Input/common.tsx +29 -10
- package/Input/index.tsx +75 -74
- package/Input/styles.ts +43 -7
- package/Layout/FloatingButton.tsx +1 -1
- package/Layout/GridSystem.tsx +1 -1
- package/Layout/ItemList.tsx +3 -2
- package/Layout/Screen.tsx +174 -91
- package/Layout/styles.ts +0 -6
- package/Layout/types.ts +1 -1
- package/Pagination/PaginationScroll.tsx +2 -2
- package/Pagination/styles.ts +1 -1
- package/Popup/PopupNotify.tsx +3 -3
- package/Tag/index.tsx +9 -2
- package/Tag/styles.ts +3 -2
- package/Tag/types.ts +12 -0
- package/Title/index.tsx +6 -9
- package/Title/styles.ts +4 -4
- package/code-scanner.js +4 -4
- package/package.json +6 -5
- package/publish.sh +12 -22
- package/verify.js +36 -42
package/Input/InputDropDown.tsx
CHANGED
|
@@ -1,67 +1,56 @@
|
|
|
1
1
|
import React, {useContext} from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {ApplicationContext, ComponentContext} from '../Application';
|
|
4
|
-
import {Styles} from '../Consts';
|
|
5
4
|
import {Icon} from '../Icon';
|
|
6
|
-
import {
|
|
7
|
-
import {ErrorView, FloatingView, getSizeStyle} from './common';
|
|
5
|
+
import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
|
|
8
6
|
import {InputDropDownProps} from './index';
|
|
7
|
+
import {Text} from '../Text';
|
|
9
8
|
import styles from './styles';
|
|
9
|
+
import {Spacing} from '../Consts';
|
|
10
10
|
|
|
11
11
|
const InputDropDown = ({
|
|
12
12
|
value,
|
|
13
13
|
floatingValue,
|
|
14
14
|
floatingIcon,
|
|
15
|
+
onPressFloatingIcon,
|
|
15
16
|
size = 'small',
|
|
16
17
|
onPress,
|
|
17
18
|
placeholder,
|
|
18
19
|
errorMessage,
|
|
19
|
-
icon = 'arrow_chevron_down_small',
|
|
20
20
|
disabled = false,
|
|
21
21
|
floatingIconColor,
|
|
22
|
-
iconColor,
|
|
23
22
|
required = false,
|
|
24
23
|
errorSpacing,
|
|
25
|
-
loading = false,
|
|
26
24
|
leadingIcon,
|
|
27
25
|
leadingIconColor,
|
|
28
26
|
style,
|
|
29
27
|
params,
|
|
30
28
|
accessibilityLabel,
|
|
31
29
|
hintText,
|
|
32
|
-
|
|
30
|
+
multiline,
|
|
33
31
|
}: InputDropDownProps) => {
|
|
34
32
|
const {theme} = useContext(ApplicationContext);
|
|
35
|
-
const full = !!value || !!placeholder;
|
|
36
|
-
|
|
37
|
-
const renderIcon = (color: string | undefined) => {
|
|
38
|
-
if (loading) {
|
|
39
|
-
return <Loader type={'spinner'} color={color} />;
|
|
40
|
-
}
|
|
41
|
-
if (icon) {
|
|
42
|
-
return <Icon color={color} source={icon} size={24} />;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Render the input view
|
|
36
|
+
*/
|
|
46
37
|
const renderInputView = () => {
|
|
47
38
|
const disabledColor = theme.colors.text.disable;
|
|
48
39
|
let textColor = theme.colors.text.default;
|
|
49
40
|
let placeholderColor = theme.colors.text.hint;
|
|
50
|
-
let iconTintColor = iconColor;
|
|
51
41
|
|
|
52
42
|
if (disabled) {
|
|
53
43
|
textColor = disabledColor;
|
|
54
44
|
placeholderColor = disabledColor;
|
|
55
|
-
iconTintColor = disabledColor;
|
|
56
45
|
}
|
|
57
46
|
|
|
58
47
|
return (
|
|
59
48
|
<View
|
|
60
49
|
style={[
|
|
61
|
-
styles.
|
|
50
|
+
styles.inputDropDownWrapper,
|
|
62
51
|
{backgroundColor: theme.colors.background.surface},
|
|
63
|
-
getSizeStyle(size),
|
|
64
|
-
|
|
52
|
+
getSizeStyle(size, multiline),
|
|
53
|
+
getBorderColor(theme, false, errorMessage, disabled),
|
|
65
54
|
]}>
|
|
66
55
|
<FloatingView
|
|
67
56
|
floatingValue={floatingValue}
|
|
@@ -69,10 +58,18 @@ const InputDropDown = ({
|
|
|
69
58
|
disabled={disabled}
|
|
70
59
|
required={required}
|
|
71
60
|
floatingIcon={floatingIcon}
|
|
61
|
+
onPress={onPressFloatingIcon}
|
|
72
62
|
/>
|
|
73
|
-
<View style={
|
|
63
|
+
<View style={styles.inputDropDownView}>
|
|
74
64
|
{!!leadingIcon && (
|
|
75
|
-
<View
|
|
65
|
+
<View
|
|
66
|
+
style={[
|
|
67
|
+
styles.leadingIconContainerDropDown,
|
|
68
|
+
{
|
|
69
|
+
marginTop: Spacing.M,
|
|
70
|
+
marginRight: Spacing.S,
|
|
71
|
+
},
|
|
72
|
+
]}>
|
|
76
73
|
<Icon
|
|
77
74
|
color={leadingIconColor}
|
|
78
75
|
source={leadingIcon}
|
|
@@ -80,28 +77,27 @@ const InputDropDown = ({
|
|
|
80
77
|
/>
|
|
81
78
|
</View>
|
|
82
79
|
)}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
80
|
+
<View
|
|
81
|
+
accessibilityLabel={accessibilityLabel}
|
|
82
|
+
style={styles.textViewDropDown}>
|
|
83
|
+
<Text
|
|
84
|
+
numberOfLines={multiline ? undefined : 1}
|
|
85
|
+
typography={'body_default_regular'}
|
|
86
|
+
color={value ? textColor : placeholderColor}>
|
|
87
|
+
{value || placeholder}
|
|
88
|
+
</Text>
|
|
89
|
+
</View>
|
|
90
|
+
</View>
|
|
91
|
+
<View
|
|
92
|
+
style={[
|
|
93
|
+
styles.iconViewDropDown,
|
|
94
|
+
{
|
|
95
|
+
alignItems: multiline ? 'flex-start' : 'center',
|
|
96
|
+
paddingTop: multiline ? Spacing.M : 0,
|
|
97
|
+
},
|
|
98
|
+
]}>
|
|
99
|
+
<Icon source={'arrow_chevron_down_small'} />
|
|
103
100
|
</View>
|
|
104
|
-
<View style={styles.iconView}>{renderIcon(iconTintColor)}</View>
|
|
105
101
|
</View>
|
|
106
102
|
);
|
|
107
103
|
};
|
|
@@ -116,8 +112,9 @@ const InputDropDown = ({
|
|
|
116
112
|
componentId: accessibilityLabel,
|
|
117
113
|
}}>
|
|
118
114
|
<TouchableOpacity
|
|
115
|
+
activeOpacity={0.6}
|
|
119
116
|
onPress={onPress}
|
|
120
|
-
style={[style,
|
|
117
|
+
style={[style, styles.wrapper]}>
|
|
121
118
|
{renderInputView()}
|
|
122
119
|
<ErrorView
|
|
123
120
|
errorMessage={errorMessage}
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
forwardRef,
|
|
3
|
+
ReactNode,
|
|
3
4
|
useContext,
|
|
4
5
|
useEffect,
|
|
5
6
|
useImperativeHandle,
|
|
@@ -19,6 +20,8 @@ import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
|
|
|
19
20
|
import {InputMoneyProps} from './index';
|
|
20
21
|
import styles from './styles';
|
|
21
22
|
import {formatMoneyToNumber, formatNumberToMoney} from './utils';
|
|
23
|
+
import {Text} from '../Text';
|
|
24
|
+
import {Loader} from '../Loader';
|
|
22
25
|
|
|
23
26
|
const InputMoney = forwardRef(
|
|
24
27
|
(
|
|
@@ -27,13 +30,18 @@ const InputMoney = forwardRef(
|
|
|
27
30
|
floatingValue,
|
|
28
31
|
floatingIcon,
|
|
29
32
|
size = 'small',
|
|
33
|
+
loading,
|
|
30
34
|
onBlur,
|
|
31
35
|
onFocus,
|
|
32
36
|
errorMessage,
|
|
33
37
|
icon,
|
|
38
|
+
iconColor,
|
|
39
|
+
onPressIcon,
|
|
40
|
+
trailing,
|
|
41
|
+
trailingColor,
|
|
42
|
+
onPressTrailing,
|
|
34
43
|
disabled = false,
|
|
35
44
|
floatingIconColor,
|
|
36
|
-
iconColor,
|
|
37
45
|
required = false,
|
|
38
46
|
errorSpacing,
|
|
39
47
|
style,
|
|
@@ -42,9 +50,10 @@ const InputMoney = forwardRef(
|
|
|
42
50
|
accessibilityLabel,
|
|
43
51
|
hintText,
|
|
44
52
|
value: _value,
|
|
53
|
+
onPressFloatingIcon,
|
|
45
54
|
...props
|
|
46
55
|
}: InputMoneyProps,
|
|
47
|
-
ref
|
|
56
|
+
ref
|
|
48
57
|
) => {
|
|
49
58
|
const {theme} = useContext(ApplicationContext);
|
|
50
59
|
const [focused, setFocused] = useState(false);
|
|
@@ -63,7 +72,7 @@ const InputMoney = forwardRef(
|
|
|
63
72
|
};
|
|
64
73
|
|
|
65
74
|
const [value, setValue] = useState(
|
|
66
|
-
defaultValue ? validateText(defaultValue) : ''
|
|
75
|
+
defaultValue ? validateText(defaultValue) : ''
|
|
67
76
|
);
|
|
68
77
|
|
|
69
78
|
const onClearText = () => {
|
|
@@ -99,11 +108,51 @@ const InputMoney = forwardRef(
|
|
|
99
108
|
onBlur?.(e);
|
|
100
109
|
};
|
|
101
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Render trailing icon or text
|
|
113
|
+
* @param color
|
|
114
|
+
*/
|
|
115
|
+
const renderTrailing = (color?: string) => {
|
|
116
|
+
if (loading) {
|
|
117
|
+
return <Loader type={'spinner'} color={color} style={styles.icon} />;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (icon || trailing) {
|
|
121
|
+
const renderIconTouchable = (icon: ReactNode) => {
|
|
122
|
+
return (
|
|
123
|
+
<TouchableOpacity
|
|
124
|
+
onPress={onPressTrailing ?? onPressIcon}
|
|
125
|
+
style={styles.icon}>
|
|
126
|
+
{icon}
|
|
127
|
+
</TouchableOpacity>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
const trailingValue = icon || trailing;
|
|
131
|
+
if (trailingValue?.includes('_') || trailingValue?.includes('http')) {
|
|
132
|
+
return renderIconTouchable(
|
|
133
|
+
<Icon
|
|
134
|
+
color={color}
|
|
135
|
+
source={(icon || trailing) as string}
|
|
136
|
+
size={24}
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
return renderIconTouchable(
|
|
141
|
+
<Text
|
|
142
|
+
typography="action_xs_bold"
|
|
143
|
+
color={color ?? theme.colors.primary}
|
|
144
|
+
numberOfLines={1}>
|
|
145
|
+
{trailingValue!.substring(0, 15)}
|
|
146
|
+
</Text>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
102
151
|
const renderInputView = () => {
|
|
103
152
|
const disabledColor = theme.colors.text.disable;
|
|
104
153
|
let textColor = theme.colors.text.default;
|
|
105
154
|
let placeholderColor = theme.colors.text.hint;
|
|
106
|
-
let iconTintColor = iconColor;
|
|
155
|
+
let iconTintColor = trailingColor ?? iconColor;
|
|
107
156
|
|
|
108
157
|
if (disabled) {
|
|
109
158
|
textColor = disabledColor;
|
|
@@ -125,6 +174,7 @@ const InputMoney = forwardRef(
|
|
|
125
174
|
disabled={disabled}
|
|
126
175
|
required={required}
|
|
127
176
|
floatingIcon={floatingIcon}
|
|
177
|
+
onPress={onPressFloatingIcon}
|
|
128
178
|
/>
|
|
129
179
|
<View style={styles.inputView}>
|
|
130
180
|
<TextInput
|
|
@@ -160,7 +210,7 @@ const InputMoney = forwardRef(
|
|
|
160
210
|
/>
|
|
161
211
|
</TouchableOpacity>
|
|
162
212
|
)}
|
|
163
|
-
{
|
|
213
|
+
{renderTrailing(iconTintColor)}
|
|
164
214
|
</View>
|
|
165
215
|
</View>
|
|
166
216
|
);
|
|
@@ -198,7 +248,7 @@ const InputMoney = forwardRef(
|
|
|
198
248
|
</View>
|
|
199
249
|
</ComponentContext.Provider>
|
|
200
250
|
);
|
|
201
|
-
}
|
|
251
|
+
}
|
|
202
252
|
);
|
|
203
253
|
|
|
204
254
|
export default InputMoney;
|
package/Input/InputOTP.tsx
CHANGED
|
@@ -41,7 +41,7 @@ const OTPCaret: FC<CaretProps> = ({index, length}) => {
|
|
|
41
41
|
duration: DURATION,
|
|
42
42
|
useNativeDriver: true,
|
|
43
43
|
}),
|
|
44
|
-
])
|
|
44
|
+
])
|
|
45
45
|
).start();
|
|
46
46
|
}, []);
|
|
47
47
|
const spacingStyle = !isNaN(Number(length)) &&
|
|
@@ -74,6 +74,7 @@ const InputOTP = forwardRef(
|
|
|
74
74
|
placeholder,
|
|
75
75
|
onChangeText,
|
|
76
76
|
onBlur,
|
|
77
|
+
onFocus,
|
|
77
78
|
dataType = 'number',
|
|
78
79
|
params,
|
|
79
80
|
style,
|
|
@@ -81,7 +82,7 @@ const InputOTP = forwardRef(
|
|
|
81
82
|
hintText,
|
|
82
83
|
...props
|
|
83
84
|
}: InputOTPProps,
|
|
84
|
-
ref
|
|
85
|
+
ref
|
|
85
86
|
) => {
|
|
86
87
|
const MAX_LENGTH = 10;
|
|
87
88
|
const [value, setValue] = useState('');
|
|
@@ -93,7 +94,10 @@ const InputOTP = forwardRef(
|
|
|
93
94
|
onChangeText: (text: string) => {
|
|
94
95
|
_onChangeText(text);
|
|
95
96
|
},
|
|
96
|
-
focus: () =>
|
|
97
|
+
focus: () => {
|
|
98
|
+
setFocused(true);
|
|
99
|
+
inputRef.current?.focus()
|
|
100
|
+
},
|
|
97
101
|
blur: () => inputRef.current?.blur(),
|
|
98
102
|
setText: (text: string) => _onChangeText(text),
|
|
99
103
|
}));
|
|
@@ -143,7 +147,7 @@ const InputOTP = forwardRef(
|
|
|
143
147
|
{value[i] || '-'}
|
|
144
148
|
</Text>
|
|
145
149
|
)}
|
|
146
|
-
</View
|
|
150
|
+
</View>
|
|
147
151
|
);
|
|
148
152
|
}
|
|
149
153
|
return TextInputs;
|
|
@@ -215,7 +219,7 @@ const InputOTP = forwardRef(
|
|
|
215
219
|
value={value}
|
|
216
220
|
onChangeText={_onChangeText}
|
|
217
221
|
keyboardType={dataType === 'number' ? 'number-pad' : 'default'}
|
|
218
|
-
onFocus={
|
|
222
|
+
onFocus={onFocus}
|
|
219
223
|
onBlur={onBlurInput}
|
|
220
224
|
style={{opacity: 0}}
|
|
221
225
|
selectionColor={theme.colors.primary}
|
|
@@ -248,7 +252,7 @@ const InputOTP = forwardRef(
|
|
|
248
252
|
</TouchableOpacity>
|
|
249
253
|
</ComponentContext.Provider>
|
|
250
254
|
);
|
|
251
|
-
}
|
|
255
|
+
}
|
|
252
256
|
);
|
|
253
257
|
|
|
254
258
|
export default InputOTP;
|