@momo-kits/foundation 0.74.2-react-native.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 +120 -0
- package/Application/Components.tsx +534 -0
- package/Application/ModalScreen.tsx +268 -0
- package/Application/Navigation.ts +50 -0
- package/Application/NavigationContainer.tsx +120 -0
- package/Application/Navigator.ts +131 -0
- package/Application/StackScreen.tsx +71 -0
- package/Application/index.ts +41 -0
- package/Application/types.ts +216 -0
- package/Application/utils.tsx +151 -0
- package/Assets/DotAnimation.json +256 -0
- package/Assets/SpinnerAnimation.json +1027 -0
- package/Assets/icon.json +4031 -0
- package/Assets/icon_bank.json +506 -0
- package/Assets/language.json +202 -0
- 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 +310 -0
- package/Button/styles.ts +60 -0
- package/CheckBox/index.tsx +65 -0
- package/CheckBox/styles.ts +15 -0
- package/CheckBox/types.ts +38 -0
- package/Consts/colors+spacing+radius.ts +218 -0
- package/Consts/index.ts +4 -0
- package/Consts/styles.ts +52 -0
- package/Consts/theme.ts +125 -0
- package/Divider/index.tsx +21 -0
- package/Icon/index.tsx +41 -0
- package/Icon/types.ts +27 -0
- package/IconButton/index.tsx +139 -0
- package/IconButton/styles.ts +19 -0
- package/Image/index.tsx +83 -0
- package/Image/styles.ts +5 -0
- package/Image/types.ts +5 -0
- package/Input/Input.tsx +192 -0
- package/Input/InputDropDown.tsx +114 -0
- package/Input/InputMoney.tsx +163 -0
- package/Input/InputOTP.tsx +235 -0
- package/Input/InputSearch.tsx +151 -0
- package/Input/InputTextArea.tsx +159 -0
- package/Input/common.tsx +129 -0
- package/Input/index.tsx +251 -0
- package/Input/styles.ts +160 -0
- package/Input/utils.ts +69 -0
- package/Layout/Card.tsx +180 -0
- package/Layout/GridSystem.tsx +136 -0
- package/Layout/Item.tsx +56 -0
- package/Layout/ItemList.tsx +55 -0
- package/Layout/ItemSectionList.tsx +39 -0
- package/Layout/Screen.tsx +355 -0
- package/Layout/Section.tsx +179 -0
- package/Layout/index.ts +29 -0
- package/Layout/styles.ts +97 -0
- package/Layout/types.ts +23 -0
- package/Layout/utils.ts +55 -0
- package/Loader/DotLoader.tsx +37 -0
- package/Loader/Loader.tsx +13 -0
- package/Loader/ProgressBar.tsx +44 -0
- package/Loader/Spinner.tsx +28 -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/Dot.tsx +16 -0
- package/Pagination/PaginationDot.tsx +38 -0
- package/Pagination/PaginationNumber.tsx +24 -0
- package/Pagination/PaginationScroll.tsx +88 -0
- package/Pagination/PaginationWhiteDot.tsx +35 -0
- package/Pagination/index.tsx +25 -0
- package/Pagination/styles.ts +50 -0
- package/Pagination/types.ts +40 -0
- package/Popup/PopupNotify.tsx +266 -0
- package/Popup/PopupPromotion.tsx +120 -0
- package/Popup/index.tsx +4 -0
- package/Popup/types.ts +87 -0
- package/Radio/index.tsx +64 -0
- package/Radio/styles.ts +11 -0
- package/Radio/types.ts +38 -0
- package/Skeleton/index.tsx +72 -0
- package/Skeleton/styles.ts +5 -0
- package/Skeleton/types.ts +6 -0
- package/Switch/index.tsx +37 -0
- package/Switch/styles.ts +23 -0
- package/Switch/types.ts +26 -0
- package/Tag/index.tsx +79 -0
- package/Tag/styles.ts +24 -0
- package/Tag/types.ts +36 -0
- package/Text/index.tsx +110 -0
- package/Text/styles.ts +73 -0
- package/Text/types.ts +34 -0
- package/Text/utils.ts +14 -0
- package/Title/index.tsx +132 -0
- package/Title/styles.ts +52 -0
- package/Title/types.ts +52 -0
- package/code-scanner.js +51 -0
- package/index.ts +51 -0
- package/package.json +36 -0
- package/publish.sh +23 -0
- package/tsconfig.json +24 -0
- package/verify.js +44 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import React, {forwardRef, useContext, useRef, useState} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
NativeSyntheticEvent,
|
|
4
|
+
TextInput,
|
|
5
|
+
TextInputFocusEventData,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import {InputSearchProps} from './index';
|
|
10
|
+
import {ApplicationContext} from '../Application';
|
|
11
|
+
import styles from './styles';
|
|
12
|
+
import {Icon} from '../Icon';
|
|
13
|
+
import {Text} from '../Text';
|
|
14
|
+
import {checkTyping} from './utils';
|
|
15
|
+
|
|
16
|
+
const InputSearch = 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
|
+
style,
|
|
29
|
+
defaultValue,
|
|
30
|
+
onPressButtonText,
|
|
31
|
+
hasColorBG = true,
|
|
32
|
+
...props
|
|
33
|
+
}: InputSearchProps,
|
|
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
|
+
|
|
41
|
+
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
42
|
+
setFocused(true);
|
|
43
|
+
onFocus?.(e);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
47
|
+
setFocused(false);
|
|
48
|
+
onBlur?.(e);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const onClearText = () => {
|
|
52
|
+
inputRef?.current?.clear();
|
|
53
|
+
_onChangeText('');
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const _onChangeText = (text: string) => {
|
|
57
|
+
checkTyping(text, haveValue, setHaveValue);
|
|
58
|
+
onChangeText?.(text);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const renderInputView = () => {
|
|
62
|
+
return (
|
|
63
|
+
<TextInput
|
|
64
|
+
{...props}
|
|
65
|
+
textAlignVertical="center"
|
|
66
|
+
ref={inputRef}
|
|
67
|
+
style={[
|
|
68
|
+
styles.searchInput,
|
|
69
|
+
{
|
|
70
|
+
color: theme.colors.text.default,
|
|
71
|
+
},
|
|
72
|
+
]}
|
|
73
|
+
value={value}
|
|
74
|
+
onChangeText={_onChangeText}
|
|
75
|
+
onFocus={_onFocus}
|
|
76
|
+
onBlur={_onBlur}
|
|
77
|
+
placeholder={placeholder}
|
|
78
|
+
selectionColor={theme.colors.primary}
|
|
79
|
+
placeholderTextColor={theme.colors.text.hint}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const renderIconView = () => {
|
|
85
|
+
return (
|
|
86
|
+
<View
|
|
87
|
+
style={{
|
|
88
|
+
flexDirection: 'row',
|
|
89
|
+
}}>
|
|
90
|
+
{focused && haveValue && (
|
|
91
|
+
<TouchableOpacity style={styles.iconWrapper} onPress={onClearText}>
|
|
92
|
+
<Icon
|
|
93
|
+
source="24_navigation_close_circle_full"
|
|
94
|
+
size={16}
|
|
95
|
+
color={theme.colors.text.hint}
|
|
96
|
+
/>
|
|
97
|
+
</TouchableOpacity>
|
|
98
|
+
)}
|
|
99
|
+
{!!icon && (
|
|
100
|
+
<View style={{flexDirection: 'row'}}>
|
|
101
|
+
<View
|
|
102
|
+
style={[
|
|
103
|
+
styles.divider,
|
|
104
|
+
{
|
|
105
|
+
backgroundColor: theme.colors.primary,
|
|
106
|
+
},
|
|
107
|
+
]}
|
|
108
|
+
/>
|
|
109
|
+
<Icon
|
|
110
|
+
color={iconColor}
|
|
111
|
+
source={icon}
|
|
112
|
+
style={styles.iconSearchInput}
|
|
113
|
+
/>
|
|
114
|
+
</View>
|
|
115
|
+
)}
|
|
116
|
+
</View>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const backgroundColor = hasColorBG ?theme.colors.background.default:theme.colors.background.surface
|
|
121
|
+
return (
|
|
122
|
+
<View style={[style, styles.searchInputContainer]}>
|
|
123
|
+
<View
|
|
124
|
+
style={[
|
|
125
|
+
styles.searchInputWrapper,
|
|
126
|
+
{
|
|
127
|
+
backgroundColor,
|
|
128
|
+
borderColor: theme.colors.background.surface,
|
|
129
|
+
}
|
|
130
|
+
]}>
|
|
131
|
+
<Icon
|
|
132
|
+
source={'navigation_search'}
|
|
133
|
+
size={24}
|
|
134
|
+
color={theme.colors.text.hint}
|
|
135
|
+
/>
|
|
136
|
+
{renderInputView()}
|
|
137
|
+
{renderIconView()}
|
|
138
|
+
</View>
|
|
139
|
+
{showButtonText && (
|
|
140
|
+
<TouchableOpacity onPress={onPressButtonText}>
|
|
141
|
+
<Text typography={'action_default_bold'} style={styles.textButton}>
|
|
142
|
+
{buttonText}
|
|
143
|
+
</Text>
|
|
144
|
+
</TouchableOpacity>
|
|
145
|
+
)}
|
|
146
|
+
</View>
|
|
147
|
+
);
|
|
148
|
+
},
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
export default InputSearch;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import React, {forwardRef, useContext, useRef, useState} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
NativeSyntheticEvent,
|
|
4
|
+
TextInput,
|
|
5
|
+
TextInputFocusEventData,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import styles from './styles';
|
|
10
|
+
import {Text} from '../Text';
|
|
11
|
+
import {
|
|
12
|
+
DEFAULT_HEIGHT,
|
|
13
|
+
ErrorView,
|
|
14
|
+
FloatingView,
|
|
15
|
+
getBorderColor,
|
|
16
|
+
MAX_LENGTH,
|
|
17
|
+
} from './common';
|
|
18
|
+
import {InputTextAreaProps} from './index';
|
|
19
|
+
import {Icon} from '../Icon';
|
|
20
|
+
import {ApplicationContext} from '../Application';
|
|
21
|
+
|
|
22
|
+
const InputTextArea = forwardRef(
|
|
23
|
+
(
|
|
24
|
+
{
|
|
25
|
+
errorMessage,
|
|
26
|
+
onChangeText,
|
|
27
|
+
floatingIconColor,
|
|
28
|
+
floatingIcon,
|
|
29
|
+
floatingValue,
|
|
30
|
+
onFocus,
|
|
31
|
+
onBlur,
|
|
32
|
+
disabled = false,
|
|
33
|
+
value,
|
|
34
|
+
defaultValue,
|
|
35
|
+
height,
|
|
36
|
+
placeholder,
|
|
37
|
+
maxLength = MAX_LENGTH,
|
|
38
|
+
required,
|
|
39
|
+
errorSpacing,
|
|
40
|
+
style,
|
|
41
|
+
...props
|
|
42
|
+
}: InputTextAreaProps,
|
|
43
|
+
ref,
|
|
44
|
+
) => {
|
|
45
|
+
const {theme} = useContext(ApplicationContext);
|
|
46
|
+
const [focused, setFocused] = useState(false);
|
|
47
|
+
const [inputValue, setInputValue] = useState(defaultValue ?? '');
|
|
48
|
+
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
49
|
+
|
|
50
|
+
const onClearText = () => {
|
|
51
|
+
inputRef?.current?.clear();
|
|
52
|
+
_onChangeText('');
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const _onChangeText = (text: string) => {
|
|
56
|
+
onChangeText?.(text);
|
|
57
|
+
setInputValue(text);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
61
|
+
setFocused(true);
|
|
62
|
+
onFocus?.(e);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
66
|
+
setFocused(false);
|
|
67
|
+
onBlur?.(e);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const renderCountingView = () => {
|
|
71
|
+
return (
|
|
72
|
+
<View style={styles.countingView}>
|
|
73
|
+
<Text
|
|
74
|
+
color={theme.colors.text.hint}
|
|
75
|
+
typography={'description_xs_regular'}>
|
|
76
|
+
{`${inputValue.length}/${maxLength}`}
|
|
77
|
+
</Text>
|
|
78
|
+
</View>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
const renderInputView = () => {
|
|
82
|
+
const disabledColor = theme.colors.text.disable;
|
|
83
|
+
let textColor = theme.colors.text.default;
|
|
84
|
+
let placeholderColor = theme.colors.text.hint;
|
|
85
|
+
|
|
86
|
+
if (disabled) {
|
|
87
|
+
textColor = disabledColor;
|
|
88
|
+
placeholderColor = disabledColor;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<View
|
|
93
|
+
style={[
|
|
94
|
+
styles.textAreaWrapper,
|
|
95
|
+
{
|
|
96
|
+
height: height || DEFAULT_HEIGHT,
|
|
97
|
+
backgroundColor: theme.colors.background.surface,
|
|
98
|
+
},
|
|
99
|
+
getBorderColor(theme, focused, errorMessage, disabled),
|
|
100
|
+
]}>
|
|
101
|
+
<FloatingView
|
|
102
|
+
floatingValue={floatingValue}
|
|
103
|
+
floatingIconColor={floatingIconColor}
|
|
104
|
+
disabled={disabled}
|
|
105
|
+
floatingIcon={floatingIcon}
|
|
106
|
+
required={required}
|
|
107
|
+
/>
|
|
108
|
+
<View style={styles.rowArea}>
|
|
109
|
+
<View style={styles.textAreaView}>
|
|
110
|
+
<TextInput
|
|
111
|
+
{...props}
|
|
112
|
+
ref={inputRef}
|
|
113
|
+
editable={!disabled}
|
|
114
|
+
textAlignVertical="top"
|
|
115
|
+
style={[
|
|
116
|
+
styles.textArea,
|
|
117
|
+
{
|
|
118
|
+
color: textColor,
|
|
119
|
+
},
|
|
120
|
+
]}
|
|
121
|
+
maxLength={maxLength}
|
|
122
|
+
textBreakStrategy="highQuality"
|
|
123
|
+
multiline={true}
|
|
124
|
+
value={value}
|
|
125
|
+
onChangeText={_onChangeText}
|
|
126
|
+
onFocus={_onFocus}
|
|
127
|
+
onBlur={_onBlur}
|
|
128
|
+
placeholder={placeholder}
|
|
129
|
+
selectionColor={theme.colors.primary}
|
|
130
|
+
placeholderTextColor={placeholderColor}
|
|
131
|
+
/>
|
|
132
|
+
</View>
|
|
133
|
+
{focused && inputValue.length > 0 && (
|
|
134
|
+
<TouchableOpacity
|
|
135
|
+
style={styles.iconWrapper}
|
|
136
|
+
onPress={onClearText}>
|
|
137
|
+
<Icon
|
|
138
|
+
source="24_navigation_close_circle_full"
|
|
139
|
+
size={16}
|
|
140
|
+
color={theme.colors.text.hint}
|
|
141
|
+
/>
|
|
142
|
+
</TouchableOpacity>
|
|
143
|
+
)}
|
|
144
|
+
</View>
|
|
145
|
+
{renderCountingView()}
|
|
146
|
+
</View>
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<View style={[style, styles.wrapper]}>
|
|
152
|
+
{renderInputView()}
|
|
153
|
+
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
154
|
+
</View>
|
|
155
|
+
);
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
export default InputTextArea;
|
package/Input/common.tsx
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {View, ViewStyle} from 'react-native';
|
|
2
|
+
import styles from './styles';
|
|
3
|
+
import {scaleSize, Text} from '../Text';
|
|
4
|
+
import React, {FC, useContext} from 'react';
|
|
5
|
+
import {ApplicationContext} from '../Application';
|
|
6
|
+
import {Icon} from '../Icon';
|
|
7
|
+
import {Styles} from '../Consts';
|
|
8
|
+
import {Theme} from '../Application/types';
|
|
9
|
+
|
|
10
|
+
type FloatingViewProps = {
|
|
11
|
+
floatingValue?: string;
|
|
12
|
+
floatingIconColor?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
floatingIcon?: string;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
style?: ViewStyle;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const DEFAULT_HEIGHT = scaleSize(104);
|
|
20
|
+
export const MAX_LENGTH = 300;
|
|
21
|
+
|
|
22
|
+
export const getBorderColor = (
|
|
23
|
+
theme: Theme,
|
|
24
|
+
focused: boolean,
|
|
25
|
+
errorMessage?: string,
|
|
26
|
+
disabled?: boolean,
|
|
27
|
+
) => {
|
|
28
|
+
let borderColor = theme.colors.border.default;
|
|
29
|
+
|
|
30
|
+
if (focused) {
|
|
31
|
+
borderColor = theme.colors.primary;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (errorMessage) {
|
|
35
|
+
borderColor = theme.colors.error.primary;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (disabled) {
|
|
39
|
+
borderColor = theme.colors.border.disable;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {borderColor};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const getSizeStyle = (size?: 'small' | 'large') => {
|
|
46
|
+
if (size === 'small') {
|
|
47
|
+
return styles.smallContainer;
|
|
48
|
+
}
|
|
49
|
+
return styles.container;
|
|
50
|
+
};
|
|
51
|
+
export const ErrorView: FC<{errorMessage?: string; errorSpacing?: boolean}> = ({
|
|
52
|
+
errorMessage,
|
|
53
|
+
errorSpacing,
|
|
54
|
+
}) => {
|
|
55
|
+
const {theme} = useContext(ApplicationContext);
|
|
56
|
+
const errorColor = theme.colors.error.primary;
|
|
57
|
+
if (errorMessage) {
|
|
58
|
+
return (
|
|
59
|
+
<View style={styles.errorView}>
|
|
60
|
+
<View style={styles.errorIcon}>
|
|
61
|
+
<Icon color={errorColor} source="ic_error" size={16} />
|
|
62
|
+
</View>
|
|
63
|
+
<Text
|
|
64
|
+
style={Styles.flex}
|
|
65
|
+
color={errorColor}
|
|
66
|
+
numberOfLines={2}
|
|
67
|
+
typography={'description_default_regular'}>
|
|
68
|
+
{errorMessage}
|
|
69
|
+
</Text>
|
|
70
|
+
</View>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
if (errorSpacing) {
|
|
74
|
+
return <View style={[styles.errorView, {height: 18}]} />;
|
|
75
|
+
}
|
|
76
|
+
return <View />;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const FloatingView: FC<FloatingViewProps> = ({
|
|
80
|
+
floatingValue,
|
|
81
|
+
floatingIconColor,
|
|
82
|
+
disabled,
|
|
83
|
+
floatingIcon,
|
|
84
|
+
required,
|
|
85
|
+
style,
|
|
86
|
+
}) => {
|
|
87
|
+
const {theme} = useContext(ApplicationContext);
|
|
88
|
+
|
|
89
|
+
if (floatingValue) {
|
|
90
|
+
let floatingTextColor = theme.colors.text.hint;
|
|
91
|
+
let floatingIconTintColor = floatingIconColor;
|
|
92
|
+
if (disabled) {
|
|
93
|
+
floatingTextColor = theme.colors.text.disable;
|
|
94
|
+
floatingIconTintColor = theme.colors.text.disable;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<View
|
|
99
|
+
style={[
|
|
100
|
+
styles.floatingView,
|
|
101
|
+
{
|
|
102
|
+
backgroundColor: theme.colors.background.surface,
|
|
103
|
+
zIndex: 10,
|
|
104
|
+
},
|
|
105
|
+
style,
|
|
106
|
+
]}>
|
|
107
|
+
<Text color={floatingTextColor} typography={'label_s_medium'}>
|
|
108
|
+
{floatingValue}
|
|
109
|
+
{required && (
|
|
110
|
+
<Text
|
|
111
|
+
typography={'label_s_medium'}
|
|
112
|
+
color={theme.colors.error.primary}>
|
|
113
|
+
*
|
|
114
|
+
</Text>
|
|
115
|
+
)}
|
|
116
|
+
</Text>
|
|
117
|
+
{!!floatingIcon && (
|
|
118
|
+
<Icon
|
|
119
|
+
color={floatingIconTintColor}
|
|
120
|
+
source={floatingIcon}
|
|
121
|
+
size={16}
|
|
122
|
+
style={styles.floatingIcon}
|
|
123
|
+
/>
|
|
124
|
+
)}
|
|
125
|
+
</View>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
};
|
package/Input/index.tsx
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import Input from './Input';
|
|
2
|
+
import InputTextArea from './InputTextArea';
|
|
3
|
+
import InputSearch from './InputSearch';
|
|
4
|
+
import InputMoney from './InputMoney';
|
|
5
|
+
import InputOTP from './InputOTP';
|
|
6
|
+
import InputDropDown from './InputDropDown';
|
|
7
|
+
import {TextInputProps, ViewStyle} from 'react-native';
|
|
8
|
+
|
|
9
|
+
export interface InputProps extends TextInputProps {
|
|
10
|
+
/**
|
|
11
|
+
* Optional. Defines the size of the Input component.
|
|
12
|
+
*/
|
|
13
|
+
size?: 'small' | 'large';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Optional. Represents the value for the floating title in the Input component.
|
|
17
|
+
*/
|
|
18
|
+
floatingValue?: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Optional. Represents the name or key of the floating icon to be displayed in the Input component.
|
|
22
|
+
*/
|
|
23
|
+
floatingIcon?: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Optional. Represents the error message to be displayed below the Input component when there is an error.
|
|
27
|
+
*/
|
|
28
|
+
errorMessage?: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Optional. Represents the name or key of the icon to be displayed in the Input component.
|
|
32
|
+
*/
|
|
33
|
+
icon?: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Optional. Represents the color of the icon in the Input component.
|
|
37
|
+
*/
|
|
38
|
+
iconColor?: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Optional. If `true`, the user won't be able to interact with the Input component.
|
|
42
|
+
* Defaults to `false` if not provided.
|
|
43
|
+
*/
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Optional. Represents the color of the floating icon in the Input component.
|
|
48
|
+
*/
|
|
49
|
+
floatingIconColor?: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Optional. If `true`, the Input component is marked as required,
|
|
53
|
+
* indicating that the user must provide a value before submitting a form.
|
|
54
|
+
* Defaults to `false` if not provided.
|
|
55
|
+
*/
|
|
56
|
+
required?: boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Optional. If `true`,
|
|
60
|
+
* include spacing when Input not have error message.
|
|
61
|
+
* Defaults to `false` if not provided.
|
|
62
|
+
*/
|
|
63
|
+
errorSpacing?: boolean;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* If true, the icon of input will use be show indicator loading.
|
|
67
|
+
*/
|
|
68
|
+
loading?: boolean;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Optional. Represents the leading icon in the Input component.
|
|
72
|
+
*/
|
|
73
|
+
leadingIcon?: string;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Optional. Represents the color of the leading icon in the Input component.
|
|
77
|
+
*/
|
|
78
|
+
leadingIconColor?: string;
|
|
79
|
+
|
|
80
|
+
fontWeight?: 'Regular' | 'Bold';
|
|
81
|
+
|
|
82
|
+
onPressIcon?: () => void;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
type InputPropsWithoutSizeAndIcon = Omit<
|
|
86
|
+
InputProps,
|
|
87
|
+
'size' | 'icon' | 'iconColor'
|
|
88
|
+
>;
|
|
89
|
+
|
|
90
|
+
type InputPropsWithoutPlaceholder = Omit<InputProps, 'placeholder'>;
|
|
91
|
+
|
|
92
|
+
export interface InputTextAreaProps extends InputPropsWithoutSizeAndIcon {
|
|
93
|
+
/**
|
|
94
|
+
* Optional. Defines the height of the InputTextArea component.
|
|
95
|
+
* It can be used to set a specific height for the text area.
|
|
96
|
+
*/
|
|
97
|
+
height?: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface InputSearchProps extends TextInputProps {
|
|
101
|
+
/**
|
|
102
|
+
* Optional. Represents the text to be displayed on the search button within the InputSearch component.
|
|
103
|
+
*/
|
|
104
|
+
buttonText?: string;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Optional. If `true`, the text on the search button will be displayed.
|
|
108
|
+
* Defaults to `false` if not provided.
|
|
109
|
+
*/
|
|
110
|
+
showButtonText?: boolean;
|
|
111
|
+
|
|
112
|
+
onPressButtonText?: () => void;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Optional. Represents the color of the icon in the Input component.
|
|
116
|
+
*/
|
|
117
|
+
iconColor?: string;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Optional. Represents the name or key of the icon to be displayed in the Input component.
|
|
121
|
+
*/
|
|
122
|
+
icon?: string;
|
|
123
|
+
|
|
124
|
+
hasColorBG?: boolean
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface InputMoneyProps extends InputPropsWithoutPlaceholder {}
|
|
128
|
+
|
|
129
|
+
export type OTPInputLength = 2 | 4 | 6 | 8 | 10;
|
|
130
|
+
|
|
131
|
+
export interface InputOTPProps extends InputPropsWithoutSizeAndIcon {
|
|
132
|
+
/**
|
|
133
|
+
* Optional. Defines the length of the OTP (One Time Password) input.
|
|
134
|
+
* Can be 2, 4, 6, 8, or 10.
|
|
135
|
+
*/
|
|
136
|
+
length?: OTPInputLength;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Optional. Defines the data type of the OTP input.
|
|
140
|
+
* 'string' - The OTP input will be treated as a string.
|
|
141
|
+
* 'number' - The OTP input will be treated as a number.
|
|
142
|
+
*/
|
|
143
|
+
dataType?: 'string' | 'number';
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export type CaretProps = {
|
|
147
|
+
/**
|
|
148
|
+
* Optional. The index of the caret in the input field.
|
|
149
|
+
* Represents the position where the caret is located.
|
|
150
|
+
*/
|
|
151
|
+
index?: number;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Optional. The total length of the input field in which the caret is present.
|
|
155
|
+
* This dictates the maximum value of the 'index' property.
|
|
156
|
+
*/
|
|
157
|
+
length?: number;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export interface InputDropDownProps {
|
|
161
|
+
/**
|
|
162
|
+
* Optional. Defines the size of the InputDropDown component.
|
|
163
|
+
* 'small' - A smaller, less prominent input.
|
|
164
|
+
* 'large' - A larger, more prominent input.
|
|
165
|
+
*/
|
|
166
|
+
size?: 'small' | 'large';
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Optional. The current value of the InputDropDown.
|
|
170
|
+
*/
|
|
171
|
+
value?: string;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Optional. Text that is displayed when there is no value set in the InputDropDown.
|
|
175
|
+
*/
|
|
176
|
+
placeholder?: string;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Optional. Function to be called when the InputDropDown is pressed.
|
|
180
|
+
*/
|
|
181
|
+
onPress?: () => void;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Optional. Represents the value for the floating title in the InputDropDown component.
|
|
185
|
+
*/
|
|
186
|
+
floatingValue?: string;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Optional. Represents the name or key of the floating icon to be displayed in the InputDropDown component.
|
|
190
|
+
*/
|
|
191
|
+
floatingIcon?: string;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Optional. Represents the error message to be displayed below the InputDropDown component when there is an error.
|
|
195
|
+
*/
|
|
196
|
+
errorMessage?: string;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Optional. Represents the name or key of the icon to be displayed in the InputDropDown component.
|
|
200
|
+
*/
|
|
201
|
+
icon?: string;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Optional. Represents the color of the icon in the InputDropDown component.
|
|
205
|
+
*/
|
|
206
|
+
iconColor?: string;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Optional. If `true`, the user won't be able to interact with the InputDropDown component.
|
|
210
|
+
* Defaults to `false` if not provided.
|
|
211
|
+
*/
|
|
212
|
+
disabled?: boolean;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Optional. Represents the color of the floating icon in the InputDropDown component.
|
|
216
|
+
*/
|
|
217
|
+
floatingIconColor?: string;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Optional. If `true`, the InputDropDown component is marked as required,
|
|
221
|
+
* indicating that the user must provide a value before submitting a form.
|
|
222
|
+
* Defaults to `false` if not provided.
|
|
223
|
+
*/
|
|
224
|
+
required?: boolean;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Optional. If `true`,
|
|
228
|
+
* includes spacing when InputDropDown does not have an error message.
|
|
229
|
+
* Defaults to `false` if not provided.
|
|
230
|
+
*/
|
|
231
|
+
errorSpacing?: boolean;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* If `true`, the icon of the input will show an indicator for loading.
|
|
235
|
+
*/
|
|
236
|
+
loading?: boolean;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Optional. Represents the leading icon in the InputDropDown component.
|
|
240
|
+
*/
|
|
241
|
+
leadingIcon?: string;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Optional. Represents the color of the leading icon in the InputDropDown component.
|
|
245
|
+
*/
|
|
246
|
+
leadingIconColor?: string;
|
|
247
|
+
|
|
248
|
+
style: ViewStyle | ViewStyle[];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export {Input, InputTextArea, InputSearch, InputMoney, InputOTP, InputDropDown};
|