@momo-kits/foundation 0.80.9 → 0.81.1-beta.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 +212 -0
- package/Application/BottomTab/BottomTabBar.tsx +278 -0
- package/Application/BottomTab/index.tsx +143 -0
- package/Application/Components.tsx +379 -209
- package/Application/ModalScreen.tsx +14 -178
- package/Application/Navigation.ts +15 -19
- package/Application/NavigationContainer.tsx +66 -63
- package/Application/Navigator.ts +106 -53
- package/Application/StackScreen.tsx +123 -9
- package/Application/index.ts +19 -6
- package/Application/types.ts +83 -26
- package/Application/utils.tsx +38 -49
- package/Assets/icon.json +83 -5
- package/Assets/icon_bank.json +506 -0
- package/Assets/language.json +3 -1
- package/Badge/Badge.tsx +56 -0
- package/Badge/BadgeDot.tsx +11 -0
- package/Badge/BadgeRibbon.tsx +125 -0
- package/Badge/Shape.tsx +29 -0
- package/Badge/index.tsx +7 -0
- package/Badge/styles.ts +58 -0
- package/Badge/types.ts +63 -0
- package/Button/index.tsx +64 -28
- package/Button/styles.ts +19 -0
- package/CheckBox/index.tsx +37 -27
- package/CheckBox/types.ts +5 -3
- package/Consts/colors+spacing+radius.ts +18 -0
- package/Icon/index.tsx +14 -9
- package/Icon/types.ts +4 -3
- package/IconButton/index.tsx +24 -15
- package/Image/index.tsx +62 -47
- package/Image/styles.ts +1 -9
- package/Image/types.ts +5 -1
- package/Input/Input.tsx +104 -25
- package/Input/InputDropDown.tsx +35 -23
- package/Input/InputMoney.tsx +79 -18
- package/Input/InputOTP.tsx +190 -149
- package/Input/InputSearch.tsx +96 -44
- package/Input/InputTextArea.tsx +33 -17
- package/Input/common.tsx +26 -17
- package/Input/index.tsx +69 -24
- package/Input/styles.ts +5 -7
- package/Input/utils.ts +1 -1
- package/Layout/AnimatedInputSearch.tsx +44 -0
- package/Layout/Card.tsx +37 -13
- package/Layout/FloatingButton.tsx +168 -0
- package/Layout/GridSystem.tsx +2 -3
- package/Layout/Item.tsx +1 -2
- package/Layout/ItemList.tsx +55 -0
- package/Layout/ItemSectionList.tsx +39 -0
- package/Layout/Screen.tsx +404 -181
- package/Layout/Section.tsx +22 -22
- package/Layout/TextTyping.tsx +114 -0
- package/Layout/index.ts +12 -2
- package/Layout/styles.ts +46 -13
- package/Layout/types.ts +13 -5
- package/Layout/utils.ts +7 -12
- package/Loader/index.tsx +2 -0
- package/Pagination/PaginationDot.tsx +6 -1
- package/Pagination/PaginationNumber.tsx +7 -4
- package/Pagination/PaginationScroll.tsx +0 -1
- package/Pagination/PaginationWhiteDot.tsx +6 -1
- package/Pagination/styles.ts +3 -0
- package/Pagination/types.ts +2 -0
- package/Popup/PopupNotify.tsx +108 -40
- package/Popup/PopupPromotion.tsx +45 -10
- package/Popup/types.ts +13 -10
- package/Radio/index.tsx +35 -21
- package/Radio/types.ts +7 -5
- package/Skeleton/index.tsx +1 -1
- package/Switch/index.tsx +32 -19
- package/Switch/types.ts +5 -3
- package/Tag/index.tsx +2 -4
- package/Text/index.tsx +26 -6
- package/Text/styles.ts +38 -0
- package/Text/types.ts +25 -13
- package/Title/index.tsx +177 -63
- package/Title/styles.ts +48 -15
- package/Title/types.ts +16 -47
- package/code-scanner.js +125 -16
- package/index.ts +9 -0
- package/migrate_typo.js +56 -0
- package/package.json +9 -8
- package/publish.sh +21 -16
- package/tsconfig.json +1 -2
- package/verify.js +24 -6
- package/Application/BottomTab.tsx +0 -65
package/Input/InputSearch.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,
|
|
@@ -6,12 +12,13 @@ import {
|
|
|
6
12
|
TouchableOpacity,
|
|
7
13
|
View,
|
|
8
14
|
} from 'react-native';
|
|
9
|
-
import {
|
|
10
|
-
import {ApplicationContext} from '../Application';
|
|
11
|
-
import styles from './styles';
|
|
15
|
+
import {ApplicationContext, ComponentContext} from '../Application';
|
|
12
16
|
import {Icon} from '../Icon';
|
|
13
17
|
import {Text} from '../Text';
|
|
18
|
+
import {InputSearchProps} from './index';
|
|
19
|
+
import styles from './styles';
|
|
14
20
|
import {checkTyping} from './utils';
|
|
21
|
+
import TextTyping from '../Layout/TextTyping';
|
|
15
22
|
|
|
16
23
|
const InputSearch = forwardRef(
|
|
17
24
|
(
|
|
@@ -25,19 +32,22 @@ const InputSearch = forwardRef(
|
|
|
25
32
|
icon,
|
|
26
33
|
buttonText = 'Hủy',
|
|
27
34
|
showButtonText = true,
|
|
28
|
-
showBorder = true,
|
|
29
35
|
style,
|
|
30
36
|
defaultValue,
|
|
31
37
|
onPressButtonText,
|
|
38
|
+
params,
|
|
39
|
+
hasColorBG = false,
|
|
40
|
+
accessibilityLabel,
|
|
41
|
+
typingData = [],
|
|
42
|
+
onPress,
|
|
32
43
|
...props
|
|
33
44
|
}: InputSearchProps,
|
|
34
|
-
ref
|
|
45
|
+
ref
|
|
35
46
|
) => {
|
|
36
47
|
const {theme} = useContext(ApplicationContext);
|
|
37
48
|
const [focused, setFocused] = useState(false);
|
|
38
49
|
const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
|
|
39
|
-
const inputRef =
|
|
40
|
-
let iconTintColor = iconColor;
|
|
50
|
+
const inputRef = useRef<TextInput | null>(null);
|
|
41
51
|
|
|
42
52
|
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
43
53
|
setFocused(true);
|
|
@@ -59,20 +69,42 @@ const InputSearch = forwardRef(
|
|
|
59
69
|
onChangeText?.(text);
|
|
60
70
|
};
|
|
61
71
|
|
|
72
|
+
useImperativeHandle(ref, () => {
|
|
73
|
+
return {
|
|
74
|
+
clear: onClearText,
|
|
75
|
+
focus: () => inputRef.current?.focus(),
|
|
76
|
+
blur: () => inputRef.current?.blur(),
|
|
77
|
+
setText: (text: string) => _onChangeText(text),
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
|
|
62
81
|
const renderInputView = () => {
|
|
63
|
-
|
|
64
|
-
|
|
82
|
+
if (typingData?.length > 0) {
|
|
83
|
+
return (
|
|
84
|
+
<TouchableOpacity
|
|
85
|
+
style={[
|
|
86
|
+
styles.searchInput,
|
|
87
|
+
{
|
|
88
|
+
justifyContent: 'center',
|
|
89
|
+
},
|
|
90
|
+
]}
|
|
91
|
+
onPress={onPress}
|
|
92
|
+
activeOpacity={onPress ? 0.6 : 1}>
|
|
93
|
+
<TextTyping data={typingData} />
|
|
94
|
+
</TouchableOpacity>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
65
97
|
|
|
66
98
|
return (
|
|
67
99
|
<TextInput
|
|
68
100
|
{...props}
|
|
69
|
-
accessibilityLabel={
|
|
70
|
-
textAlignVertical="
|
|
101
|
+
accessibilityLabel={accessibilityLabel}
|
|
102
|
+
textAlignVertical="center"
|
|
71
103
|
ref={inputRef}
|
|
72
104
|
style={[
|
|
73
105
|
styles.searchInput,
|
|
74
106
|
{
|
|
75
|
-
color:
|
|
107
|
+
color: theme.colors.text.default,
|
|
76
108
|
},
|
|
77
109
|
]}
|
|
78
110
|
value={value}
|
|
@@ -81,7 +113,7 @@ const InputSearch = forwardRef(
|
|
|
81
113
|
onBlur={_onBlur}
|
|
82
114
|
placeholder={placeholder}
|
|
83
115
|
selectionColor={theme.colors.primary}
|
|
84
|
-
placeholderTextColor={
|
|
116
|
+
placeholderTextColor={theme.colors.text.hint}
|
|
85
117
|
/>
|
|
86
118
|
);
|
|
87
119
|
};
|
|
@@ -112,7 +144,7 @@ const InputSearch = forwardRef(
|
|
|
112
144
|
]}
|
|
113
145
|
/>
|
|
114
146
|
<Icon
|
|
115
|
-
color={
|
|
147
|
+
color={iconColor}
|
|
116
148
|
source={icon}
|
|
117
149
|
style={styles.iconSearchInput}
|
|
118
150
|
/>
|
|
@@ -121,38 +153,58 @@ const InputSearch = forwardRef(
|
|
|
121
153
|
</View>
|
|
122
154
|
);
|
|
123
155
|
};
|
|
156
|
+
|
|
157
|
+
let inputState = 'empty';
|
|
158
|
+
|
|
159
|
+
if (focused) {
|
|
160
|
+
inputState = 'focus';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (value && value?.length > 0) {
|
|
164
|
+
inputState = 'filled';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const backgroundColor = hasColorBG
|
|
168
|
+
? theme.colors.background.default
|
|
169
|
+
: theme.colors.background.surface;
|
|
170
|
+
|
|
124
171
|
return (
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
172
|
+
<ComponentContext.Provider
|
|
173
|
+
value={{
|
|
174
|
+
componentName: 'InputSearch',
|
|
175
|
+
params,
|
|
176
|
+
state: inputState,
|
|
177
|
+
componentId: accessibilityLabel,
|
|
178
|
+
}}>
|
|
179
|
+
<View style={[style, styles.searchInputContainer]}>
|
|
180
|
+
<View
|
|
181
|
+
style={[
|
|
182
|
+
styles.searchInputWrapper,
|
|
183
|
+
{
|
|
184
|
+
backgroundColor,
|
|
185
|
+
},
|
|
186
|
+
]}>
|
|
187
|
+
<Icon
|
|
188
|
+
source={'navigation_search'}
|
|
189
|
+
size={24}
|
|
190
|
+
color={theme.colors.text.hint}
|
|
191
|
+
/>
|
|
192
|
+
{renderInputView()}
|
|
193
|
+
{renderIconView()}
|
|
194
|
+
</View>
|
|
195
|
+
{showButtonText && (
|
|
196
|
+
<TouchableOpacity onPress={onPressButtonText}>
|
|
197
|
+
<Text
|
|
198
|
+
typography={'action_default_bold'}
|
|
199
|
+
style={styles.textButton}>
|
|
200
|
+
{buttonText}
|
|
201
|
+
</Text>
|
|
202
|
+
</TouchableOpacity>
|
|
203
|
+
)}
|
|
145
204
|
</View>
|
|
146
|
-
|
|
147
|
-
<TouchableOpacity onPress={onPressButtonText}>
|
|
148
|
-
<Text typography={'action_default'} style={styles.textButton}>
|
|
149
|
-
{buttonText}
|
|
150
|
-
</Text>
|
|
151
|
-
</TouchableOpacity>
|
|
152
|
-
)}
|
|
153
|
-
</View>
|
|
205
|
+
</ComponentContext.Provider>
|
|
154
206
|
);
|
|
155
|
-
}
|
|
207
|
+
}
|
|
156
208
|
);
|
|
157
209
|
|
|
158
210
|
export default InputSearch;
|
package/Input/InputTextArea.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,
|
|
@@ -6,7 +12,8 @@ import {
|
|
|
6
12
|
TouchableOpacity,
|
|
7
13
|
View,
|
|
8
14
|
} from 'react-native';
|
|
9
|
-
import
|
|
15
|
+
import {ApplicationContext} from '../Application';
|
|
16
|
+
import {Icon} from '../Icon';
|
|
10
17
|
import {Text} from '../Text';
|
|
11
18
|
import {
|
|
12
19
|
DEFAULT_HEIGHT,
|
|
@@ -16,8 +23,7 @@ import {
|
|
|
16
23
|
MAX_LENGTH,
|
|
17
24
|
} from './common';
|
|
18
25
|
import {InputTextAreaProps} from './index';
|
|
19
|
-
import
|
|
20
|
-
import {ApplicationContext} from '../Application';
|
|
26
|
+
import styles from './styles';
|
|
21
27
|
|
|
22
28
|
const InputTextArea = forwardRef(
|
|
23
29
|
(
|
|
@@ -29,14 +35,16 @@ const InputTextArea = forwardRef(
|
|
|
29
35
|
floatingValue,
|
|
30
36
|
onFocus,
|
|
31
37
|
onBlur,
|
|
32
|
-
disabled,
|
|
38
|
+
disabled = false,
|
|
33
39
|
value,
|
|
34
40
|
defaultValue,
|
|
35
41
|
height,
|
|
36
42
|
placeholder,
|
|
37
|
-
maxLength,
|
|
43
|
+
maxLength = MAX_LENGTH,
|
|
38
44
|
required,
|
|
39
45
|
errorSpacing,
|
|
46
|
+
style,
|
|
47
|
+
hintText,
|
|
40
48
|
...props
|
|
41
49
|
}: InputTextAreaProps,
|
|
42
50
|
ref,
|
|
@@ -44,7 +52,7 @@ const InputTextArea = forwardRef(
|
|
|
44
52
|
const {theme} = useContext(ApplicationContext);
|
|
45
53
|
const [focused, setFocused] = useState(false);
|
|
46
54
|
const [inputValue, setInputValue] = useState(defaultValue ?? '');
|
|
47
|
-
const inputRef =
|
|
55
|
+
const inputRef = useRef<TextInput | null>(null);
|
|
48
56
|
|
|
49
57
|
const onClearText = () => {
|
|
50
58
|
inputRef?.current?.clear();
|
|
@@ -66,10 +74,21 @@ const InputTextArea = forwardRef(
|
|
|
66
74
|
onBlur?.(e);
|
|
67
75
|
};
|
|
68
76
|
|
|
77
|
+
useImperativeHandle(ref, () => {
|
|
78
|
+
return {
|
|
79
|
+
clear: onClearText,
|
|
80
|
+
focus: () => inputRef.current?.focus(),
|
|
81
|
+
blur: () => inputRef.current?.blur(),
|
|
82
|
+
setText: (text: string) => _onChangeText(text),
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
|
|
69
86
|
const renderCountingView = () => {
|
|
70
87
|
return (
|
|
71
88
|
<View style={styles.countingView}>
|
|
72
|
-
<Text
|
|
89
|
+
<Text
|
|
90
|
+
color={theme.colors.text.hint}
|
|
91
|
+
typography={'description_xs_regular'}>
|
|
73
92
|
{`${inputValue.length}/${maxLength}`}
|
|
74
93
|
</Text>
|
|
75
94
|
</View>
|
|
@@ -106,7 +125,6 @@ const InputTextArea = forwardRef(
|
|
|
106
125
|
<View style={styles.textAreaView}>
|
|
107
126
|
<TextInput
|
|
108
127
|
{...props}
|
|
109
|
-
accessibilityLabel={`TextInput`}
|
|
110
128
|
ref={inputRef}
|
|
111
129
|
editable={!disabled}
|
|
112
130
|
textAlignVertical="top"
|
|
@@ -146,18 +164,16 @@ const InputTextArea = forwardRef(
|
|
|
146
164
|
};
|
|
147
165
|
|
|
148
166
|
return (
|
|
149
|
-
<View
|
|
150
|
-
style={styles.wrapper}
|
|
151
|
-
accessibilityLabel={`InputTextArea/${floatingValue}`}>
|
|
167
|
+
<View style={[style, styles.wrapper]}>
|
|
152
168
|
{renderInputView()}
|
|
153
|
-
<ErrorView
|
|
169
|
+
<ErrorView
|
|
170
|
+
errorMessage={errorMessage}
|
|
171
|
+
errorSpacing={errorSpacing}
|
|
172
|
+
hintText={hintText}
|
|
173
|
+
/>
|
|
154
174
|
</View>
|
|
155
175
|
);
|
|
156
176
|
},
|
|
157
177
|
);
|
|
158
178
|
|
|
159
|
-
InputTextArea.defaultProps = {
|
|
160
|
-
maxLength: MAX_LENGTH,
|
|
161
|
-
};
|
|
162
|
-
|
|
163
179
|
export default InputTextArea;
|
package/Input/common.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {View, ViewStyle} from 'react-native';
|
|
2
|
-
import styles from './styles';
|
|
3
|
-
import {Text} from '../Text';
|
|
4
1
|
import React, {FC, useContext} from 'react';
|
|
2
|
+
import {View, ViewStyle} from 'react-native';
|
|
5
3
|
import {ApplicationContext} from '../Application';
|
|
6
|
-
import {Icon} from '../Icon';
|
|
7
|
-
import {Styles} from '../Consts';
|
|
8
4
|
import {Theme} from '../Application/types';
|
|
5
|
+
import {Styles} from '../Consts';
|
|
6
|
+
import {Icon} from '../Icon';
|
|
7
|
+
import {scaleSize, Text} from '../Text';
|
|
8
|
+
import styles from './styles';
|
|
9
9
|
|
|
10
10
|
type FloatingViewProps = {
|
|
11
11
|
floatingValue?: string;
|
|
@@ -16,7 +16,7 @@ type FloatingViewProps = {
|
|
|
16
16
|
style?: ViewStyle;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export const DEFAULT_HEIGHT =
|
|
19
|
+
export const DEFAULT_HEIGHT = scaleSize(104);
|
|
20
20
|
export const MAX_LENGTH = 300;
|
|
21
21
|
|
|
22
22
|
export const getBorderColor = (
|
|
@@ -48,24 +48,31 @@ export const getSizeStyle = (size?: 'small' | 'large') => {
|
|
|
48
48
|
}
|
|
49
49
|
return styles.container;
|
|
50
50
|
};
|
|
51
|
-
export const ErrorView: FC<{
|
|
52
|
-
errorMessage
|
|
53
|
-
errorSpacing
|
|
54
|
-
|
|
51
|
+
export const ErrorView: FC<{
|
|
52
|
+
errorMessage?: string;
|
|
53
|
+
errorSpacing?: boolean;
|
|
54
|
+
hintText?: string;
|
|
55
|
+
}> = ({errorMessage, errorSpacing, hintText}) => {
|
|
55
56
|
const {theme} = useContext(ApplicationContext);
|
|
56
57
|
const errorColor = theme.colors.error.primary;
|
|
57
|
-
|
|
58
|
+
const hintColor = theme.colors.text.hint;
|
|
59
|
+
const hintTextDefault = hintText ?? 'Không thể chỉnh sửa';
|
|
60
|
+
if (errorMessage || hintText) {
|
|
58
61
|
return (
|
|
59
62
|
<View style={styles.errorView}>
|
|
60
63
|
<View style={styles.errorIcon}>
|
|
61
|
-
<Icon
|
|
64
|
+
<Icon
|
|
65
|
+
color={errorMessage ? errorColor : hintColor}
|
|
66
|
+
source="ic_error"
|
|
67
|
+
size={16}
|
|
68
|
+
/>
|
|
62
69
|
</View>
|
|
63
70
|
<Text
|
|
64
71
|
style={Styles.flex}
|
|
65
|
-
color={errorColor}
|
|
72
|
+
color={errorMessage ? errorColor : hintColor}
|
|
66
73
|
numberOfLines={2}
|
|
67
|
-
typography={'
|
|
68
|
-
{errorMessage}
|
|
74
|
+
typography={'description_default_regular'}>
|
|
75
|
+
{errorMessage ?? hintTextDefault}
|
|
69
76
|
</Text>
|
|
70
77
|
</View>
|
|
71
78
|
);
|
|
@@ -104,10 +111,12 @@ export const FloatingView: FC<FloatingViewProps> = ({
|
|
|
104
111
|
},
|
|
105
112
|
style,
|
|
106
113
|
]}>
|
|
107
|
-
<Text color={floatingTextColor} typography={'
|
|
114
|
+
<Text color={floatingTextColor} typography={'label_s_medium'}>
|
|
108
115
|
{floatingValue}
|
|
109
116
|
{required && (
|
|
110
|
-
<Text
|
|
117
|
+
<Text
|
|
118
|
+
typography={'label_s_medium'}
|
|
119
|
+
color={theme.colors.error.primary}>
|
|
111
120
|
*
|
|
112
121
|
</Text>
|
|
113
122
|
)}
|
package/Input/index.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import {GestureResponderEvent, TextInputProps, ViewStyle} from 'react-native';
|
|
1
2
|
import Input from './Input';
|
|
2
|
-
import
|
|
3
|
-
import InputSearch from './InputSearch';
|
|
3
|
+
import InputDropDown from './InputDropDown';
|
|
4
4
|
import InputMoney from './InputMoney';
|
|
5
5
|
import InputOTP from './InputOTP';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import InputSearch from './InputSearch';
|
|
7
|
+
import InputTextArea from './InputTextArea';
|
|
8
8
|
|
|
9
9
|
export interface InputProps extends TextInputProps {
|
|
10
10
|
/**
|
|
@@ -76,20 +76,30 @@ export interface InputProps extends TextInputProps {
|
|
|
76
76
|
* Optional. Represents the color of the leading icon in the Input component.
|
|
77
77
|
*/
|
|
78
78
|
leadingIconColor?: string;
|
|
79
|
-
}
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Optional. Represents the font weight of the text in the Input component.
|
|
82
|
+
*/
|
|
83
|
+
fontWeight?: 'Regular' | 'Bold';
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Optional. callback function to be called when the icon is pressed.
|
|
87
|
+
*/
|
|
88
|
+
onPressIcon?: () => void;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Optional. params for element tracking.
|
|
92
|
+
*/
|
|
93
|
+
params?: any;
|
|
85
94
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Optional. Represents text below the Input component.
|
|
97
|
+
*/
|
|
98
|
+
hintText?: string;
|
|
99
|
+
}
|
|
91
100
|
|
|
92
|
-
export interface InputTextAreaProps
|
|
101
|
+
export interface InputTextAreaProps
|
|
102
|
+
extends Omit<InputProps, 'size' | 'icon' | 'iconColor'> {
|
|
93
103
|
/**
|
|
94
104
|
* Optional. Defines the height of the InputTextArea component.
|
|
95
105
|
* It can be used to set a specific height for the text area.
|
|
@@ -97,7 +107,7 @@ export interface InputTextAreaProps extends InputPropsWithoutSizeAndIcon {
|
|
|
97
107
|
height?: number;
|
|
98
108
|
}
|
|
99
109
|
|
|
100
|
-
export interface InputSearchProps extends
|
|
110
|
+
export interface InputSearchProps extends TextInputProps {
|
|
101
111
|
/**
|
|
102
112
|
* Optional. Represents the text to be displayed on the search button within the InputSearch component.
|
|
103
113
|
*/
|
|
@@ -110,19 +120,40 @@ export interface InputSearchProps extends InputPropsOmitForSearch {
|
|
|
110
120
|
showButtonText?: boolean;
|
|
111
121
|
|
|
112
122
|
/**
|
|
113
|
-
* Optional.
|
|
114
|
-
* Defaults to `true` if not provided.
|
|
123
|
+
* Optional. Represents the value for the floating title in the InputSearch component.
|
|
115
124
|
*/
|
|
116
|
-
showBorder?: boolean;
|
|
117
|
-
|
|
118
125
|
onPressButtonText?: () => void;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Optional. Represents the color of the icon in the Input component.
|
|
129
|
+
*/
|
|
130
|
+
iconColor?: string;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Optional. Represents the name or key of the icon to be displayed in the Input component.
|
|
134
|
+
*/
|
|
135
|
+
icon?: string;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Optional. If `true`, the user won't be able to interact with the Input component.
|
|
139
|
+
*/
|
|
140
|
+
hasColorBG?: boolean;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Optional. Represents the style of the InputSearch component.
|
|
144
|
+
*/
|
|
145
|
+
params?: any;
|
|
146
|
+
|
|
147
|
+
typingData?: string[];
|
|
148
|
+
onPress?: (e: GestureResponderEvent) => void;
|
|
119
149
|
}
|
|
120
150
|
|
|
121
|
-
export interface InputMoneyProps extends
|
|
151
|
+
export interface InputMoneyProps extends Omit<InputProps, 'placeholder'> {}
|
|
122
152
|
|
|
123
153
|
export type OTPInputLength = 2 | 4 | 6 | 8 | 10;
|
|
124
154
|
|
|
125
|
-
export interface InputOTPProps
|
|
155
|
+
export interface InputOTPProps
|
|
156
|
+
extends Omit<InputProps, 'size' | 'icon' | 'iconColor'> {
|
|
126
157
|
/**
|
|
127
158
|
* Optional. Defines the length of the OTP (One Time Password) input.
|
|
128
159
|
* Can be 2, 4, 6, 8, or 10.
|
|
@@ -135,6 +166,8 @@ export interface InputOTPProps extends InputPropsWithoutSizeAndIcon {
|
|
|
135
166
|
* 'number' - The OTP input will be treated as a number.
|
|
136
167
|
*/
|
|
137
168
|
dataType?: 'string' | 'number';
|
|
169
|
+
|
|
170
|
+
floatingValue: string;
|
|
138
171
|
}
|
|
139
172
|
|
|
140
173
|
export type CaretProps = {
|
|
@@ -151,7 +184,7 @@ export type CaretProps = {
|
|
|
151
184
|
length?: number;
|
|
152
185
|
};
|
|
153
186
|
|
|
154
|
-
export interface InputDropDownProps {
|
|
187
|
+
export interface InputDropDownProps extends InputProps {
|
|
155
188
|
/**
|
|
156
189
|
* Optional. Defines the size of the InputDropDown component.
|
|
157
190
|
* 'small' - A smaller, less prominent input.
|
|
@@ -238,6 +271,18 @@ export interface InputDropDownProps {
|
|
|
238
271
|
* Optional. Represents the color of the leading icon in the InputDropDown component.
|
|
239
272
|
*/
|
|
240
273
|
leadingIconColor?: string;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Optional. params for element tracking.
|
|
277
|
+
*/
|
|
278
|
+
params?: {
|
|
279
|
+
[key: string]: any;
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Optional. Represents the style of the InputDropDown component.
|
|
284
|
+
*/
|
|
285
|
+
style?: ViewStyle | ViewStyle[];
|
|
241
286
|
}
|
|
242
287
|
|
|
243
|
-
export {Input,
|
|
288
|
+
export {Input, InputDropDown, InputMoney, InputOTP, InputSearch, InputTextArea};
|
package/Input/styles.ts
CHANGED
|
@@ -7,8 +7,8 @@ export default StyleSheet.create({
|
|
|
7
7
|
input: {
|
|
8
8
|
flex: 1,
|
|
9
9
|
paddingLeft: Spacing.M,
|
|
10
|
+
fontSize: scaleSize(14),
|
|
10
11
|
height: '100%',
|
|
11
|
-
fontSize: scaleSize(15),
|
|
12
12
|
},
|
|
13
13
|
wrapper: {
|
|
14
14
|
width: '100%',
|
|
@@ -54,8 +54,7 @@ export default StyleSheet.create({
|
|
|
54
54
|
marginRight: Spacing.M,
|
|
55
55
|
},
|
|
56
56
|
icon: {
|
|
57
|
-
|
|
58
|
-
height: 24,
|
|
57
|
+
marginLeft: Spacing.S,
|
|
59
58
|
},
|
|
60
59
|
iconWrapper: {
|
|
61
60
|
width: 24,
|
|
@@ -77,7 +76,7 @@ export default StyleSheet.create({
|
|
|
77
76
|
flex: 1,
|
|
78
77
|
paddingRight: Spacing.XS,
|
|
79
78
|
paddingVertical: Spacing.XS,
|
|
80
|
-
fontSize: scaleSize(
|
|
79
|
+
fontSize: scaleSize(14),
|
|
81
80
|
},
|
|
82
81
|
textAreaWrapper: {
|
|
83
82
|
borderWidth: 1,
|
|
@@ -102,7 +101,6 @@ export default StyleSheet.create({
|
|
|
102
101
|
searchInputWrapper: {
|
|
103
102
|
flexDirection: 'row',
|
|
104
103
|
borderRadius: Radius.XL,
|
|
105
|
-
borderWidth: 1,
|
|
106
104
|
paddingHorizontal: Spacing.S,
|
|
107
105
|
alignItems: 'center',
|
|
108
106
|
flex: 1,
|
|
@@ -111,7 +109,7 @@ export default StyleSheet.create({
|
|
|
111
109
|
height: 36,
|
|
112
110
|
marginLeft: Spacing.S,
|
|
113
111
|
flex: 1,
|
|
114
|
-
fontSize: scaleSize(
|
|
112
|
+
fontSize: scaleSize(14),
|
|
115
113
|
paddingVertical: Spacing.XS,
|
|
116
114
|
},
|
|
117
115
|
searchInputView: {
|
|
@@ -148,7 +146,7 @@ export default StyleSheet.create({
|
|
|
148
146
|
},
|
|
149
147
|
otpFloatingView: {
|
|
150
148
|
position: 'absolute',
|
|
151
|
-
top: -Spacing.
|
|
149
|
+
top: scaleSize(-Spacing.M + 2),
|
|
152
150
|
alignSelf: 'center',
|
|
153
151
|
paddingHorizontal: Spacing.S,
|
|
154
152
|
},
|
package/Input/utils.ts
CHANGED
|
@@ -61,7 +61,7 @@ const formatMoneyToNumber = (money: string, currencyUnit: string) => {
|
|
|
61
61
|
};
|
|
62
62
|
const checkTyping = (text: string, value: boolean, setValue: any) => {
|
|
63
63
|
let typing = text?.length > 0;
|
|
64
|
-
if (typing
|
|
64
|
+
if (typing !== value) {
|
|
65
65
|
setValue(typing);
|
|
66
66
|
}
|
|
67
67
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, {FC} from 'react';
|
|
2
|
+
import {InputSearch} from '../Input';
|
|
3
|
+
import {Animated, Dimensions} from 'react-native';
|
|
4
|
+
import {AnimatedInputSearchProps} from './types';
|
|
5
|
+
import {Spacing} from '../Consts';
|
|
6
|
+
import {scaleSize} from '../Text';
|
|
7
|
+
|
|
8
|
+
const {width: screenWidth} = Dimensions.get('window');
|
|
9
|
+
const SCREEN_PADDING = 12;
|
|
10
|
+
const BACK_WIDTH = scaleSize(28);
|
|
11
|
+
|
|
12
|
+
const AnimatedInputSearch: FC<AnimatedInputSearchProps> = ({
|
|
13
|
+
animatedValue,
|
|
14
|
+
headerRightWidth,
|
|
15
|
+
inputSearchProps,
|
|
16
|
+
}) => {
|
|
17
|
+
const translateX = animatedValue.interpolate({
|
|
18
|
+
inputRange: [0, 100],
|
|
19
|
+
outputRange: [SCREEN_PADDING, BACK_WIDTH + SCREEN_PADDING * 2],
|
|
20
|
+
extrapolate: 'clamp',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const width = animatedValue.interpolate({
|
|
24
|
+
inputRange: [0, 100],
|
|
25
|
+
outputRange: [
|
|
26
|
+
screenWidth - SCREEN_PADDING * 2,
|
|
27
|
+
screenWidth - SCREEN_PADDING * 3 - BACK_WIDTH - headerRightWidth,
|
|
28
|
+
],
|
|
29
|
+
extrapolate: 'clamp',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Animated.View
|
|
34
|
+
style={{
|
|
35
|
+
transform: [{translateX}],
|
|
36
|
+
marginVertical: Spacing.S,
|
|
37
|
+
width,
|
|
38
|
+
}}>
|
|
39
|
+
<InputSearch {...inputSearchProps} showButtonText={false} />
|
|
40
|
+
</Animated.View>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default AnimatedInputSearch;
|