@klyftig/mobile-ui 1.3.0 → 1.3.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/package.json
CHANGED
|
@@ -4,13 +4,15 @@ import { MaterialCommunityIcons as Icon } from '@expo/vector-icons';
|
|
|
4
4
|
import { useTheme } from '../hooks/useTheme';
|
|
5
5
|
|
|
6
6
|
interface GlassInputProps {
|
|
7
|
-
label
|
|
7
|
+
label?: string;
|
|
8
8
|
value: string;
|
|
9
9
|
onChangeText: (text: string) => void;
|
|
10
10
|
placeholder?: string;
|
|
11
11
|
secureTextEntry?: boolean;
|
|
12
|
-
keyboardType?: 'default' | 'email-address' | 'numeric' | 'phone-pad';
|
|
12
|
+
keyboardType?: 'default' | 'email-address' | 'numeric' | 'phone-pad' | 'decimal-pad' | 'number-pad';
|
|
13
13
|
autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters';
|
|
14
|
+
multiline?: boolean;
|
|
15
|
+
numberOfLines?: number;
|
|
14
16
|
// Off by default for fields where iOS would otherwise replace partially-edited
|
|
15
17
|
// multi-word values with its autocorrect suggestion and snap the caret to end.
|
|
16
18
|
autoCorrect?: boolean;
|
|
@@ -45,6 +47,8 @@ const GlassInputComponent: React.FC<GlassInputProps> = ({
|
|
|
45
47
|
onFocus,
|
|
46
48
|
onBlur,
|
|
47
49
|
selectTextOnFocus,
|
|
50
|
+
multiline = false,
|
|
51
|
+
numberOfLines,
|
|
48
52
|
}) => {
|
|
49
53
|
const { colors } = useTheme();
|
|
50
54
|
const [isSecure, setIsSecure] = useState(secureTextEntry);
|
|
@@ -66,7 +70,9 @@ const GlassInputComponent: React.FC<GlassInputProps> = ({
|
|
|
66
70
|
|
|
67
71
|
return (
|
|
68
72
|
<View style={styles.container}>
|
|
69
|
-
|
|
73
|
+
{label ? (
|
|
74
|
+
<Text style={[styles.label, { color: colors.text.primary }]}>{label}</Text>
|
|
75
|
+
) : null}
|
|
70
76
|
<View
|
|
71
77
|
style={[
|
|
72
78
|
styles.inputContainer,
|
|
@@ -74,7 +80,7 @@ const GlassInputComponent: React.FC<GlassInputProps> = ({
|
|
|
74
80
|
disabled && styles.inputContainerDisabled,
|
|
75
81
|
]}
|
|
76
82
|
>
|
|
77
|
-
<View style={styles.inputWrapper}>
|
|
83
|
+
<View style={[styles.inputWrapper, multiline && styles.inputWrapperMultiline]}>
|
|
78
84
|
{icon && (
|
|
79
85
|
<Icon name={icon} size={20} color="#9B9B9B" style={styles.leftIcon} />
|
|
80
86
|
)}
|
|
@@ -92,12 +98,20 @@ const GlassInputComponent: React.FC<GlassInputProps> = ({
|
|
|
92
98
|
onFocus={handleFocus}
|
|
93
99
|
onBlur={handleBlur}
|
|
94
100
|
selectTextOnFocus={selectTextOnFocus}
|
|
101
|
+
multiline={multiline}
|
|
102
|
+
numberOfLines={numberOfLines}
|
|
103
|
+
textAlignVertical={multiline ? 'top' : undefined}
|
|
95
104
|
textContentType={textContentType ?? (secureTextEntry ? 'oneTimeCode' : undefined)}
|
|
96
105
|
autoComplete={autoComplete as any}
|
|
97
106
|
accessibilityLabel={label}
|
|
98
|
-
accessibilityHint={placeholder ? `Enter ${label.toLowerCase()}` : undefined}
|
|
107
|
+
accessibilityHint={placeholder && label ? `Enter ${label.toLowerCase()}` : undefined}
|
|
99
108
|
accessibilityState={{ disabled }}
|
|
100
|
-
style={[
|
|
109
|
+
style={[
|
|
110
|
+
styles.input,
|
|
111
|
+
icon && styles.inputWithLeftIcon,
|
|
112
|
+
(rightText || showPasswordToggle) && styles.inputWithRightIcon,
|
|
113
|
+
multiline && styles.inputMultiline,
|
|
114
|
+
]}
|
|
101
115
|
/>
|
|
102
116
|
{rightText && (
|
|
103
117
|
<Text style={styles.rightText}>{rightText}</Text>
|
|
@@ -154,6 +168,17 @@ const styles = StyleSheet.create({
|
|
|
154
168
|
paddingHorizontal: 16,
|
|
155
169
|
height: 56,
|
|
156
170
|
},
|
|
171
|
+
inputWrapperMultiline: {
|
|
172
|
+
height: undefined,
|
|
173
|
+
minHeight: 96,
|
|
174
|
+
paddingVertical: 12,
|
|
175
|
+
alignItems: 'flex-start',
|
|
176
|
+
},
|
|
177
|
+
inputMultiline: {
|
|
178
|
+
height: undefined,
|
|
179
|
+
minHeight: 72,
|
|
180
|
+
paddingTop: 4,
|
|
181
|
+
},
|
|
157
182
|
leftIcon: {
|
|
158
183
|
marginRight: 12,
|
|
159
184
|
},
|