ikualo-ui-kit-mobile 2.1.13 → 2.1.16
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
|
@@ -140,6 +140,7 @@ const getStylesBtnLightSmall = (theme: ITheme) =>
|
|
|
140
140
|
},
|
|
141
141
|
'btn-light-small__container-main': { alignItems: 'center', width: 'auto' },
|
|
142
142
|
'btn-light-small__text': { textAlign: 'center', width: 'auto', marginTop: 5 },
|
|
143
|
+
'btn-light-small__text--disabled': { opacity: 0.25 },
|
|
143
144
|
'btn-light-small--transparent': {
|
|
144
145
|
backgroundColor: theme.colors.transparent,
|
|
145
146
|
borderColor: theme.colors.icon,
|
|
@@ -158,9 +159,9 @@ const getStylesBtnLightSmall = (theme: ITheme) =>
|
|
|
158
159
|
fontSize: 24,
|
|
159
160
|
},
|
|
160
161
|
'btn-light-small--disabled': {
|
|
161
|
-
backgroundColor: theme.colors.
|
|
162
|
-
borderColor: theme.colors.
|
|
163
|
-
|
|
162
|
+
backgroundColor: theme.colors.background_focus,
|
|
163
|
+
borderColor: theme.colors.icon,
|
|
164
|
+
opacity: 0.25,
|
|
164
165
|
borderWidth: 1,
|
|
165
166
|
maxWidth: 50,
|
|
166
167
|
minWidth: 50,
|
|
@@ -251,10 +252,10 @@ const getStylesButtonActionCircle = (theme: ITheme) =>
|
|
|
251
252
|
});
|
|
252
253
|
|
|
253
254
|
export {
|
|
255
|
+
getStylesBtnLightSmall,
|
|
256
|
+
getStylesButtonActionCircle,
|
|
257
|
+
getStylesButtonCircle,
|
|
254
258
|
getStylesButtonContained,
|
|
255
259
|
getStylesButtonOutlined,
|
|
256
260
|
getStylesButtonText,
|
|
257
|
-
getStylesBtnLightSmall,
|
|
258
|
-
getStylesButtonCircle,
|
|
259
|
-
getStylesButtonActionCircle,
|
|
260
261
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import React, { cloneElement } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
1
3
|
import { ActivityIndicator, Button } from 'react-native-paper';
|
|
4
|
+
import { Text } from '../../';
|
|
2
5
|
import { getStylesBtnLightSmall } from '../../../assets/styles/elements/buttons';
|
|
3
|
-
import { View } from 'react-native';
|
|
4
|
-
import { cloneElement } from 'react';
|
|
5
|
-
import useStore from '../../store';
|
|
6
6
|
import { IBtnLightSmall } from '../../models';
|
|
7
|
-
import
|
|
8
|
-
import { Text } from '../../';
|
|
7
|
+
import useStore from '../../store';
|
|
9
8
|
|
|
10
9
|
export const BtnLightSmall = (props: IBtnLightSmall) => {
|
|
11
10
|
const theme = useStore().theme;
|
|
@@ -14,8 +13,6 @@ export const BtnLightSmall = (props: IBtnLightSmall) => {
|
|
|
14
13
|
const { onPress, icon, disabled = false, active, isLoading, text, transparent, maxWidth, iconSize } = props;
|
|
15
14
|
const color = active
|
|
16
15
|
? stylesBtnLightSmall['btn-light-small--active'].borderColor
|
|
17
|
-
: disabled
|
|
18
|
-
? theme.colors.border_disabled
|
|
19
16
|
: stylesBtnLightSmall['btn-light-small--primary'].borderColor;
|
|
20
17
|
|
|
21
18
|
const colorBtnText = active ? theme.colors.freezed : theme.colors.text_p;
|
|
@@ -56,7 +53,11 @@ export const BtnLightSmall = (props: IBtnLightSmall) => {
|
|
|
56
53
|
</Button>
|
|
57
54
|
{text && (
|
|
58
55
|
<Text
|
|
59
|
-
style={[
|
|
56
|
+
style={[
|
|
57
|
+
stylesBtnLightSmall['btn-light-small__text'],
|
|
58
|
+
{ maxWidth: maxWidth || 'auto' },
|
|
59
|
+
disabled && stylesBtnLightSmall['btn-light-small__text--disabled'],
|
|
60
|
+
]}
|
|
60
61
|
color={colorBtnText}
|
|
61
62
|
lineHeight={15}
|
|
62
63
|
fontWeight="MontserratSemiBold600"
|
|
@@ -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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
|
101
|
+
label={!isFocus && placeholder && (!value || value.trim() === '') ? placeholder : label}
|
|
63
102
|
mode={mode ?? 'flat'}
|
|
64
|
-
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
|
|
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
|
-
|
|
119
|
-
|
|
162
|
+
disabled={isDisabled}
|
|
163
|
+
readOnly={readonly}
|
|
120
164
|
/>
|
|
121
165
|
{!isDisabled && (
|
|
122
166
|
<>
|