ikualo-ui-kit-mobile 2.1.16 → 2.1.17
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/Input.tsx +19 -63
package/app.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HelperText, TextInput, Text } from 'react-native-paper';
|
|
2
2
|
import { getStyleInput } from '../../../assets/styles/elements/inputs';
|
|
3
|
-
import { useState
|
|
3
|
+
import { useState } from 'react';
|
|
4
4
|
import { View } from 'react-native';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import useStore from '../../store';
|
|
@@ -43,64 +43,25 @@ export const Input = (props: IInputText) => {
|
|
|
43
43
|
const patternNumber = /^[0-9]*$/;
|
|
44
44
|
const patternAlphanumeric = /^[a-zA-Z0-9]*$/;
|
|
45
45
|
const patternLettersWithAccentsAndSpaces = /^[a-zA-ZáéíóúÁÉÍÓÚñÑ\s]*$/;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Solo si el usuario no está escribiendo
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (!isUserTypingRef.current && stringValue !== lastPropValueRef.current) {
|
|
60
|
-
lastPropValueRef.current = stringValue;
|
|
61
|
-
setLocalValue(stringValue);
|
|
46
|
+
const onChangeText = (text: string) => {
|
|
47
|
+
onChange(text);
|
|
48
|
+
setErrorRequired(false);
|
|
49
|
+
if (type === 'number' && !patternNumber.test(text)) {
|
|
50
|
+
onInvalid && onInvalid();
|
|
51
|
+
} else if (type === 'alphanumeric' && !patternAlphanumeric.test(text)) {
|
|
52
|
+
onInvalid && onInvalid();
|
|
53
|
+
} else if (type === 'text' && !patternLettersWithAccentsAndSpaces.test(text)) {
|
|
54
|
+
onInvalid && onInvalid();
|
|
55
|
+
} else if (pattern && !pattern.test(text)) {
|
|
56
|
+
onInvalid && onInvalid();
|
|
62
57
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const onChangeText = useCallback(
|
|
66
|
-
(text: string) => {
|
|
67
|
-
// Asegurar que el texto sea una cadena
|
|
68
|
-
const cleanText = typeof text === 'string' ? text : String(text);
|
|
69
|
-
|
|
70
|
-
// Marcar que el usuario está escribiendo
|
|
71
|
-
isUserTypingRef.current = true;
|
|
72
|
-
|
|
73
|
-
// Actualizar el estado local inmediatamente
|
|
74
|
-
setLocalValue(cleanText);
|
|
75
|
-
lastPropValueRef.current = cleanText;
|
|
76
|
-
|
|
77
|
-
// Pasar el texto directamente al onChange
|
|
78
|
-
onChange(cleanText);
|
|
79
|
-
|
|
80
|
-
// Resetear el flag después de un breve delay
|
|
81
|
-
setTimeout(() => {
|
|
82
|
-
isUserTypingRef.current = false;
|
|
83
|
-
}, 50);
|
|
84
|
-
|
|
85
|
-
setErrorRequired(false);
|
|
86
|
-
if (type === 'number' && !patternNumber.test(cleanText)) {
|
|
87
|
-
onInvalid && onInvalid();
|
|
88
|
-
} else if (type === 'alphanumeric' && !patternAlphanumeric.test(cleanText)) {
|
|
89
|
-
onInvalid && onInvalid();
|
|
90
|
-
} else if (type === 'text' && !patternLettersWithAccentsAndSpaces.test(cleanText)) {
|
|
91
|
-
onInvalid && onInvalid();
|
|
92
|
-
} else if (pattern && !pattern.test(cleanText)) {
|
|
93
|
-
onInvalid && onInvalid();
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
[onChange, type, pattern, onInvalid]
|
|
97
|
-
);
|
|
58
|
+
};
|
|
98
59
|
return (
|
|
99
60
|
<View>
|
|
100
61
|
<TextInput
|
|
101
|
-
label={!isFocus && placeholder &&
|
|
62
|
+
label={!isFocus && placeholder && value?.trim() === '' ? placeholder : label}
|
|
102
63
|
mode={mode ?? 'flat'}
|
|
103
|
-
value={
|
|
64
|
+
value={value}
|
|
104
65
|
onChangeText={onChangeText}
|
|
105
66
|
maxLength={maxLength}
|
|
106
67
|
selectionColor={
|
|
@@ -134,7 +95,7 @@ export const Input = (props: IInputText) => {
|
|
|
134
95
|
isFocus && isValid && !errorRequired && { backgroundColor: 'transparent' },
|
|
135
96
|
style ?? [],
|
|
136
97
|
]}
|
|
137
|
-
contentStyle={[styleInput['input-txt'], contentStyle ??
|
|
98
|
+
contentStyle={[styleInput['input-txt'], contentStyle ?? {}]}
|
|
138
99
|
underlineColor={
|
|
139
100
|
underlineColor
|
|
140
101
|
? underlineColor
|
|
@@ -145,7 +106,7 @@ export const Input = (props: IInputText) => {
|
|
|
145
106
|
activeUnderlineColor={
|
|
146
107
|
activeUnderlineColor
|
|
147
108
|
? activeUnderlineColor
|
|
148
|
-
: !isValid && value
|
|
109
|
+
: !isValid && value?.trim() !== ''
|
|
149
110
|
? styleInput['input-text--activeUnderline'].color
|
|
150
111
|
: errorRequired
|
|
151
112
|
? styleInput['input-txt-error'].color
|
|
@@ -153,14 +114,9 @@ export const Input = (props: IInputText) => {
|
|
|
153
114
|
}
|
|
154
115
|
underlineStyle={{ height: isFocus ? 1.5 : 2 }}
|
|
155
116
|
keyboardType={type === 'number' ? 'numeric' : 'default'}
|
|
156
|
-
autoCorrect={false}
|
|
157
|
-
autoCapitalize="none"
|
|
158
|
-
autoComplete="off"
|
|
159
|
-
textContentType="none"
|
|
160
|
-
spellCheck={false}
|
|
161
117
|
right={icon && <TextInput.Icon color={theme.colors.icon} icon={icon ?? ''} />}
|
|
162
|
-
|
|
163
|
-
|
|
118
|
+
readOnly={isDisabled || readonly}
|
|
119
|
+
selection={selection}
|
|
164
120
|
/>
|
|
165
121
|
{!isDisabled && (
|
|
166
122
|
<>
|