cdslibrary 1.2.2 → 1.2.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/assets/images/anillo.png +0 -0
- package/components/CDSButton.jsx +1 -5
- package/components/CDSButtonGroup.jsx +0 -3
- package/components/CDSInput.jsx +38 -20
- package/index.js +22 -16
- package/package.json +1 -1
|
Binary file
|
package/components/CDSButton.jsx
CHANGED
|
@@ -39,7 +39,7 @@ export const CDSButton = ({
|
|
|
39
39
|
activeOpacity={0.7}
|
|
40
40
|
style={[
|
|
41
41
|
styles.container,
|
|
42
|
-
{ flexGrow: (variant === "fill" ? 1 : 0), backgroundColor, borderRadius: theme.radius.full },
|
|
42
|
+
{ flexGrow: (variant === "fill" ? 1 : 0), paddingHorizontal: theme.space.sm, paddingVertical: theme.space.xs, backgroundColor, borderRadius: theme.radius.full, gap: theme.space.xs },
|
|
43
43
|
flexend && { justifyContent: "flex-end", paddingHorizontal: 0 },
|
|
44
44
|
{
|
|
45
45
|
paddingHorizontal: type === "icon" ? theme.space.xs : theme.space.sm,
|
|
@@ -87,10 +87,6 @@ const styles = StyleSheet.create({
|
|
|
87
87
|
flexDirection: "row",
|
|
88
88
|
alignItems: "center",
|
|
89
89
|
justifyContent: "center",
|
|
90
|
-
paddingVertical: 12,
|
|
91
|
-
paddingHorizontal: 24,
|
|
92
|
-
borderRadius: 8,
|
|
93
|
-
gap: 8,
|
|
94
90
|
},
|
|
95
91
|
});
|
|
96
92
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
import { View, Text, StyleSheet, TouchableOpacity } from "react-native";
|
|
3
|
-
import { Dimensions, Platform } from "react-native";
|
|
4
|
-
import { MaterialIcons } from "@expo/vector-icons";
|
|
5
3
|
import { useTheme } from "../context/CDSThemeContext";
|
|
6
4
|
import { CDSButton } from "./CDSButton";
|
|
7
5
|
|
|
@@ -45,7 +43,6 @@ const styles = StyleSheet.create({
|
|
|
45
43
|
flex: 1,
|
|
46
44
|
flexDirection: 'row',
|
|
47
45
|
width: '100%',
|
|
48
|
-
backgroundColor: 'red',
|
|
49
46
|
alignItems: 'center',
|
|
50
47
|
justifyContent: 'center',
|
|
51
48
|
},
|
package/components/CDSInput.jsx
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import { View, Text, TextInput, StyleSheet } from "react-native";
|
|
2
|
+
import { View, Text, TextInput, StyleSheet, Platform } from "react-native"; // Añadido Platform
|
|
3
3
|
import { useTheme } from "../context/CDSThemeContext";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// Agregamos 'value' y 'onChangeText' a las props para que sea un "Controlled Component"
|
|
6
|
+
export const CDSInput = ({ label, type, keyboard, placeholder, value, onChangeText }) => {
|
|
6
7
|
const { theme } = useTheme();
|
|
7
|
-
const [text, setText] = useState("");
|
|
8
8
|
const [isFocused, setIsFocused] = useState(false);
|
|
9
9
|
|
|
10
|
+
const handleTextChange = (inputText) => {
|
|
11
|
+
if (keyboard === "numeric" || keyboard === "decimal-pad") {
|
|
12
|
+
let cleaned = inputText.replace(',', '.');
|
|
13
|
+
cleaned = cleaned.replace(/[^0-9.]/g, "");
|
|
14
|
+
|
|
15
|
+
const parts = cleaned.split('.');
|
|
16
|
+
if (parts.length > 2) {
|
|
17
|
+
cleaned = parts[0] + '.' + parts.slice(1).join('');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Enviamos el valor limpio al padre (index.js)
|
|
21
|
+
onChangeText && onChangeText(cleaned);
|
|
22
|
+
} else {
|
|
23
|
+
onChangeText && onChangeText(inputText);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
10
27
|
return (
|
|
11
28
|
<View style={[styles.container, { gap: theme.space.xs }]}>
|
|
12
29
|
{label && (
|
|
@@ -18,27 +35,26 @@ export const CDSInput = ({ label, type, keyboard, placeholder }) => {
|
|
|
18
35
|
<TextInput
|
|
19
36
|
style={[
|
|
20
37
|
styles.textBox,
|
|
21
|
-
theme.typography.inputText.value,
|
|
38
|
+
theme.typography.inputText.value,
|
|
22
39
|
{
|
|
23
40
|
backgroundColor: theme.surface.neutral.primary,
|
|
24
|
-
//
|
|
25
|
-
borderColor: isFocused
|
|
26
|
-
? theme.outline.neutral.focus
|
|
41
|
+
// Usamos 'value' (la prop) para decidir el color del borde
|
|
42
|
+
borderColor: isFocused
|
|
43
|
+
? theme.outline.neutral.focus
|
|
44
|
+
: value ? theme.outline.neutral.tertiaryVariant // Cambiado 'text' por 'value'
|
|
27
45
|
: theme.outline.neutral.primary,
|
|
28
46
|
borderRadius: theme.radius.sm,
|
|
29
47
|
paddingHorizontal: theme.space.xs,
|
|
30
48
|
color: theme.text.neutral.primary,
|
|
31
|
-
|
|
32
|
-
outlineStyle: 'none',
|
|
49
|
+
outlineStyle: 'none',
|
|
33
50
|
},
|
|
34
51
|
]}
|
|
35
52
|
placeholder={placeholder}
|
|
36
|
-
placeholderTextColor={theme.
|
|
37
|
-
keyboardType={keyboard}
|
|
53
|
+
placeholderTextColor={theme.text.neutral.placeholder} // Usar el color directo del tema es más seguro
|
|
54
|
+
keyboardType={keyboard === "numeric" ? (Platform.OS === 'ios' ? 'decimal-pad' : 'numeric') : keyboard}
|
|
55
|
+
onChangeText={handleTextChange}
|
|
56
|
+
value={value} // Ahora recibe el valor del simulador
|
|
38
57
|
secureTextEntry={type === "password"}
|
|
39
|
-
onChangeText={setText}
|
|
40
|
-
value={text}
|
|
41
|
-
// Manejo de estados de Focus
|
|
42
58
|
onFocus={() => setIsFocused(true)}
|
|
43
59
|
onBlur={() => setIsFocused(false)}
|
|
44
60
|
underlineColorAndroid="transparent"
|
|
@@ -48,14 +64,16 @@ export const CDSInput = ({ label, type, keyboard, placeholder }) => {
|
|
|
48
64
|
};
|
|
49
65
|
|
|
50
66
|
const styles = StyleSheet.create({
|
|
51
|
-
container: {
|
|
52
|
-
width: "100%",
|
|
53
|
-
},
|
|
67
|
+
container: { width: "100%" },
|
|
54
68
|
textBox: {
|
|
55
69
|
borderWidth: 1,
|
|
56
70
|
height: 48,
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
// transitionProperty solo funciona en Web, en móvil se ignora sin error
|
|
72
|
+
...Platform.select({
|
|
73
|
+
web: {
|
|
74
|
+
transitionProperty: 'border-color',
|
|
75
|
+
transitionDuration: '0.2s',
|
|
76
|
+
}
|
|
77
|
+
})
|
|
60
78
|
},
|
|
61
79
|
});
|
package/index.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
// Exportaciones de Componentes
|
|
2
|
-
export { CDSAccordion } from './components/CDSAccordion'; // ¡No olvides este!
|
|
3
|
-
export { CDSBottomSheet } from './components/CDSBottomSheet';
|
|
4
|
-
export { CDSButton } from './components/CDSButton';
|
|
5
|
-
export { CDSInput } from './components/CDSInput';
|
|
6
|
-
export { CDSSwitch } from './components/CDSSwitch';
|
|
7
|
-
export { CDSNavBar } from './components/CDSNavBar';
|
|
8
|
-
export { CDSCardFeedback } from './components/CDSCardFeedback';
|
|
9
|
-
export { CDSSplashScreen } from './components/CDSSplashScreen';
|
|
10
|
-
export { CDSButtonGroup } from './components/CDSButtonGroup';
|
|
11
|
-
export { CDSSelect } from './components/CDSSelect';
|
|
12
|
-
export { CDSLoader } from './components/CDSLoader';
|
|
13
|
-
export { CDSOffer } from './components/CDSOffer';
|
|
14
|
-
export { CDSTable } from './components/CDSTable';
|
|
15
1
|
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
import { registerRootComponent } from 'expo';
|
|
3
|
+
|
|
4
|
+
import App from './App';
|
|
5
|
+
registerRootComponent(App);
|
|
6
|
+
|
|
7
|
+
export {CDSBottomSheet} from './components/CDSBottomSheet';
|
|
8
|
+
export {CDSButton} from './components/CDSButton';
|
|
9
|
+
// export {CDSCarousel} from './components/CDSCarousel';
|
|
10
|
+
// export {CDSCarouselDots} from './components/CDSCarouselDots';
|
|
11
|
+
export {CDSInput} from './components/CDSInput';
|
|
12
|
+
// export {CDSOnboarding} from './components/CDSOnboarding';
|
|
13
|
+
export {CDSSwitch} from './components/CDSSwitch';
|
|
14
|
+
export {CDSNavBar} from './components/CDSNavBar';
|
|
15
|
+
export {CDSCardFeedback} from './components/CDSCardFeedback';
|
|
16
|
+
export {CDSSplashScreen} from './components/CDSSplashScreen';
|
|
17
|
+
export {CDSButtonGroup} from './components/CDSButtonGroup';
|
|
18
|
+
export {CDSSelect} from './components/CDSSelect';
|
|
19
|
+
export {CDSLoader} from './components/CDSLoader';
|
|
20
|
+
export {CDSOffer} from './components/CDSOffer';
|
|
21
|
+
export {CDSTable} from './components/CDSTable';
|
|
22
|
+
|
|
23
|
+
export {CDSThemeProvider, useTheme} from './context/CDSThemeContext';
|