ikualo-ui-kit-mobile 2.1.13 → 2.1.15

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "ikualo-app-2.0",
4
4
  "slug": "ikualo-app-20",
5
5
  "owner": "ikualo",
6
- "version": "2.1.13",
6
+ "version": "2.1.15",
7
7
  "orientation": "portrait",
8
8
  "icon": "./assets/icon.png",
9
9
  "userInterfaceStyle": "automatic",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ikualo-ui-kit-mobile",
3
- "version": "2.1.13",
3
+ "version": "2.1.15",
4
4
  "main": "src/index.ts",
5
5
  "scripts": {
6
6
  "start": "expo start",
@@ -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 } from 'react';
3
+ import { useState, useCallback, useEffect, useRef } from 'react';
4
4
  import { View } from 'react-native';
5
5
  import React from 'react';
6
6
  import useStore from '../../store';
@@ -43,25 +43,64 @@ 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
- 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();
46
+
47
+ // Normalizar el valor para asegurar que siempre sea una cadena
48
+ const normalizedValue = value ?? '';
49
+ const stringValue = typeof normalizedValue === 'string' ? normalizedValue : String(normalizedValue);
50
+
51
+ // Estado local para controlar el valor del input
52
+ const [localValue, setLocalValue] = useState<string>(stringValue);
53
+ const isUserTypingRef = useRef<boolean>(false);
54
+ const lastPropValueRef = useRef<string>(stringValue);
55
+
56
+ // Sincronizar el estado local con el prop value cuando cambia desde fuera
57
+ // Solo si el usuario no está escribiendo
58
+ useEffect(() => {
59
+ if (!isUserTypingRef.current && stringValue !== lastPropValueRef.current) {
60
+ lastPropValueRef.current = stringValue;
61
+ setLocalValue(stringValue);
57
62
  }
58
- };
63
+ }, [stringValue]);
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
+ );
59
98
  return (
60
99
  <View>
61
100
  <TextInput
62
- label={!isFocus && placeholder && value?.trim() === '' ? placeholder : label}
101
+ label={!isFocus && placeholder && (!value || value.trim() === '') ? placeholder : label}
63
102
  mode={mode ?? 'flat'}
64
- value={value}
103
+ value={localValue}
65
104
  onChangeText={onChangeText}
66
105
  maxLength={maxLength}
67
106
  selectionColor={
@@ -95,7 +134,7 @@ export const Input = (props: IInputText) => {
95
134
  isFocus && isValid && !errorRequired && { backgroundColor: 'transparent' },
96
135
  style ?? [],
97
136
  ]}
98
- contentStyle={[styleInput['input-txt'], contentStyle ?? {}]}
137
+ contentStyle={[styleInput['input-txt'], contentStyle ?? []]}
99
138
  underlineColor={
100
139
  underlineColor
101
140
  ? underlineColor
@@ -106,7 +145,7 @@ export const Input = (props: IInputText) => {
106
145
  activeUnderlineColor={
107
146
  activeUnderlineColor
108
147
  ? activeUnderlineColor
109
- : !isValid && value?.trim() !== ''
148
+ : !isValid && value && value.trim() !== ''
110
149
  ? styleInput['input-text--activeUnderline'].color
111
150
  : errorRequired
112
151
  ? styleInput['input-txt-error'].color
@@ -114,9 +153,14 @@ export const Input = (props: IInputText) => {
114
153
  }
115
154
  underlineStyle={{ height: isFocus ? 1.5 : 2 }}
116
155
  keyboardType={type === 'number' ? 'numeric' : 'default'}
156
+ autoCorrect={false}
157
+ autoCapitalize="none"
158
+ autoComplete="off"
159
+ textContentType="none"
160
+ spellCheck={false}
117
161
  right={icon && <TextInput.Icon color={theme.colors.icon} icon={icon ?? ''} />}
118
- readOnly={isDisabled || readonly}
119
- selection={selection}
162
+ disabled={isDisabled}
163
+ readOnly={readonly}
120
164
  />
121
165
  {!isDisabled && (
122
166
  <>