cdslibrary 1.2.2 → 1.2.3

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.
@@ -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
- export const CDSInput = ({ label, type, keyboard, placeholder }) => {
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, // La tipografía se aplica aquí y la hereda el placeholder
38
+ theme.typography.inputText.value,
22
39
  {
23
40
  backgroundColor: theme.surface.neutral.primary,
24
- // Cambia el color del borde si está en focus
25
- borderColor: isFocused
26
- ? theme.outline.neutral.focus : text ? theme.outline.neutral.tertiaryVariant
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
- // Elimina el borde azul en Web/Android
32
- outlineStyle: 'none',
49
+ outlineStyle: 'none',
33
50
  },
34
51
  ]}
35
52
  placeholder={placeholder}
36
- placeholderTextColor={theme.typography.inputText.placeholder}
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
- // Asegura que la transición de color no sea brusca en web
58
- transitionProperty: 'border-color',
59
- transitionDuration: '0.2s',
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
- // Exportaciones de Contexto y Hooks
17
- export { CDSThemeProvider, useTheme } from './context/CDSThemeContext';
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';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cdslibrary",
3
3
  "license": "0BSD",
4
- "version": "1.2.2",
4
+ "version": "1.2.3",
5
5
  "main": "index.js",
6
6
  "author": "Nat Viramontes",
7
7
  "description": "A library of components for the CDS project",