ikualo-ui-kit-mobile 2.1.3 → 2.1.4
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/app.json +1 -1
- package/package.json +1 -1
- package/src/elements/inputs/InputEmail.tsx +16 -5
package/app.json
CHANGED
package/package.json
CHANGED
|
@@ -5,10 +5,12 @@ import { View } from 'react-native';
|
|
|
5
5
|
import useStore from '../../store';
|
|
6
6
|
import { IInputEmail } from '../../models';
|
|
7
7
|
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
|
|
8
|
+
|
|
8
9
|
export const InputEmail = (props: IInputEmail) => {
|
|
9
10
|
const theme = useStore().theme;
|
|
10
11
|
const styleInput = getStyleInput(theme);
|
|
11
12
|
const [isFocus, setIsFocus] = useState<boolean>(false);
|
|
13
|
+
|
|
12
14
|
const {
|
|
13
15
|
label,
|
|
14
16
|
isDisabled,
|
|
@@ -29,10 +31,12 @@ export const InputEmail = (props: IInputEmail) => {
|
|
|
29
31
|
pattern,
|
|
30
32
|
placeholder,
|
|
31
33
|
} = props;
|
|
34
|
+
|
|
32
35
|
const patternEmailDefault = pattern ?? /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
36
|
+
|
|
33
37
|
const handleInputChange = (text: string) => {
|
|
34
|
-
onChange(text
|
|
35
|
-
if (patternEmailDefault && !patternEmailDefault.test(text)) {
|
|
38
|
+
onChange(text);
|
|
39
|
+
if (patternEmailDefault && !patternEmailDefault.test(text.trim().toLowerCase())) {
|
|
36
40
|
onInvalid && onInvalid();
|
|
37
41
|
}
|
|
38
42
|
};
|
|
@@ -40,7 +44,7 @@ export const InputEmail = (props: IInputEmail) => {
|
|
|
40
44
|
return (
|
|
41
45
|
<View>
|
|
42
46
|
<TextInput
|
|
43
|
-
label={!isFocus && placeholder && value
|
|
47
|
+
label={!isFocus && placeholder && (!value || value.trim() === '') ? placeholder : label}
|
|
44
48
|
mode={mode ?? 'flat'}
|
|
45
49
|
disabled={isDisabled}
|
|
46
50
|
value={value}
|
|
@@ -66,7 +70,7 @@ export const InputEmail = (props: IInputEmail) => {
|
|
|
66
70
|
style={[styleInput['input-label'], style ?? []]}
|
|
67
71
|
contentStyle={[
|
|
68
72
|
styleInput['input-label'],
|
|
69
|
-
!isValid && !isFocus && value.trim() !== '' && styleInput['input-txt-error'],
|
|
73
|
+
!isValid && !isFocus && value && value.trim() !== '' && styleInput['input-txt-error'],
|
|
70
74
|
style ?? [styleInput['input-txt']],
|
|
71
75
|
]}
|
|
72
76
|
underlineColor={
|
|
@@ -79,11 +83,18 @@ export const InputEmail = (props: IInputEmail) => {
|
|
|
79
83
|
activeUnderlineColor={
|
|
80
84
|
activeUnderlineColor
|
|
81
85
|
? activeUnderlineColor
|
|
82
|
-
: !isValid && value.trim() !== ''
|
|
86
|
+
: !isValid && value && value.trim() !== ''
|
|
83
87
|
? styleInput['input-text--activeUnderline'].color
|
|
84
88
|
: ''
|
|
85
89
|
}
|
|
86
90
|
underlineStyle={{ height: isFocus ? 1.5 : 2 }}
|
|
91
|
+
autoCapitalize="none"
|
|
92
|
+
autoCorrect={false}
|
|
93
|
+
keyboardType="email-address"
|
|
94
|
+
autoComplete="email"
|
|
95
|
+
textContentType="emailAddress"
|
|
96
|
+
importantForAutofill="yes"
|
|
97
|
+
spellCheck={false}
|
|
87
98
|
/>
|
|
88
99
|
{isValid && (
|
|
89
100
|
<HelperText type="info" style={styleInput['input-password-helper']} visible={true}>
|