cdslibrary 1.2.95 → 1.2.97

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.
@@ -4,7 +4,7 @@ import { MaterialIcons } from "@expo/vector-icons";
4
4
  import { useTheme } from "../context/CDSThemeContext";
5
5
  import { CDSTooltip } from "./CDSTooltip"; // Asegúrate de importar tu Tooltip
6
6
 
7
- export const CDSImageButton = ({ object, isActive, onPress, hasHelper, helperMessage, arrowAlignment }) => {
7
+ export const CDSImageButton = ({ object, isActive, onPress, hasHelper, helperMessage, arrowAlignment, isGrid }) => {
8
8
  const { theme } = useTheme();
9
9
 
10
10
  // Estados para controlar el Tooltip interno
@@ -34,6 +34,7 @@ export const CDSImageButton = ({ object, isActive, onPress, hasHelper, helperMes
34
34
  setTooltipVisible(true);
35
35
  };
36
36
 
37
+ console.log(isGrid)
37
38
  return (
38
39
  <>
39
40
  <TouchableOpacity
@@ -42,6 +43,8 @@ export const CDSImageButton = ({ object, isActive, onPress, hasHelper, helperMes
42
43
  style={[
43
44
  styles.mainContainer,
44
45
  {
46
+ width: isGrid ? 192 : 'auto' ,
47
+ maxWidth: isGrid ? 192 : 160,
45
48
  backgroundColor: isActive
46
49
  ? theme.surface.neutral.primaryVariant
47
50
  : theme.surface.neutral.primary,
@@ -3,7 +3,7 @@ import { View, Animated, StyleSheet, ScrollView } from 'react-native';
3
3
  import { CDSImageButton } from './CDSImageButton';
4
4
  import { useTheme } from "../context/CDSThemeContext";
5
5
 
6
- export const CDSImageButtonGroup = ({ array, onSelect, isCentered }) => {
6
+ export const CDSImageButtonGroup = ({ array, onSelect, isCentered, isGrid }) => {
7
7
  const { theme } = useTheme();
8
8
  const isMobile = theme.isMobile
9
9
  const [selectedId, setSelectedId] = useState(null);
@@ -29,42 +29,56 @@ export const CDSImageButtonGroup = ({ array, onSelect, isCentered }) => {
29
29
  const animatedLayout = {
30
30
  maxHeight: animatedValue.interpolate({
31
31
  inputRange: [0, 1],
32
- outputRange: [0, 250]
32
+ outputRange: [0, 250]
33
33
  }),
34
34
  opacity: animatedValue,
35
35
  };
36
36
 
37
+ const Container = isGrid ? View : ScrollView;
38
+
37
39
  return (
38
40
  <Animated.View style={[
39
41
  animatedLayout,
40
42
  { width: '100%' } // Asegura que el contenedor ocupe todo el ancho disponible
41
43
  ]}>
42
- <ScrollView
43
- horizontal={true}
44
+ <Container
45
+ // Props para ScrollView (se ignoran si es View)
46
+ horizontal={!isGrid}
44
47
  showsHorizontalScrollIndicator={false}
45
- style={styles.scrollView}
46
- contentContainerStyle={[
47
- styles.scrollContent,
48
- {
48
+ style={isGrid ? {
49
+ flexDirection: 'row',
50
+ flexWrap: 'wrap',
51
+ justifyContent: 'center',
52
+ gap: theme.space.sm,
53
+ padding: theme.space.md,
54
+ width: '100%'
55
+ } : styles.scrollView}
56
+ contentContainerStyle={!isGrid ? [
57
+ styles.scrollContent,
58
+ {
49
59
  justifyContent: (isCentered || !isMobile || (isMobile && array.length <= 2) ? 'center' : 'flex-start'),
50
60
  gap: theme.space.sm,
51
61
  padding: theme.space.md,
52
- minWidth: '100%'
62
+ minWidth: '100%'
53
63
  }
54
- ]}
64
+ ] : undefined}
65
+
55
66
  >
56
67
  {array.map((item) => (
57
68
  <CDSImageButton
69
+ isGrid={isGrid}
58
70
  key={item.id}
59
71
  object={item}
60
72
  isActive={selectedId === item.id}
61
73
  onPress={() => handlePress(item.id)}
62
- hasHelper={item.helper ? true : false}
74
+ hasHelper={!!item.helper}
63
75
  helperMessage={item.helper}
64
76
  arrowAlignment={item.arrowAlignment}
77
+ // Opcional: Ajustar ancho en grid
78
+ style={isGrid ? { width: '47%' } : undefined}
65
79
  />
66
80
  ))}
67
- </ScrollView>
81
+ </Container>
68
82
  </Animated.View>
69
83
  );
70
84
  }
@@ -62,7 +62,7 @@ export const CDSLoader = ({ visible = false, message }) => {
62
62
  paddingHorizontal: 20
63
63
  }
64
64
  ]}>
65
- {/* {message} */}
65
+ {message}
66
66
  </Text>
67
67
  )}
68
68
  </View>
@@ -44,7 +44,7 @@ export const CDSModal = ({
44
44
  }
45
45
  ]}>
46
46
  {/* Header */}
47
- <View style={[styles.modalHeader, { borderBottomColor: theme.outline.neutral.primary, paddingVertical: theme.space.md, paddingHorizontal: theme.space.sm }]}>
47
+ <View style={[styles.modalHeader, { borderBottomColor: theme.outline.neutral.primary, paddingVertical: theme.space.md, paddingHorizontal: theme.space.md }]}>
48
48
  <Text style={[theme.typography.semiBold.md, { color: theme.text.neutral.primary, flex: 1 }]}>
49
49
  {title}
50
50
  </Text>
@@ -54,7 +54,7 @@ export const CDSModal = ({
54
54
  </View>
55
55
 
56
56
  {/* Body */}
57
- <ScrollView style={[styles.body, {padding: theme.space.sm}]} bounces={false}>
57
+ <ScrollView style={[styles.body, {padding: theme.space.md}]} bounces={false}>
58
58
  {message && (
59
59
  <Text style={[
60
60
  theme.typography.regular.md,
@@ -33,7 +33,7 @@ export const CDSSelect = ({ label, options = [], onSelect, selectedValue = null,
33
33
  return (
34
34
  <View style={styles.mainContainer}>
35
35
  {label && (
36
- <Text style={[theme.typography.label, { color: theme.text.neutral.primary, marginBottom: theme.space.sm }]}>
36
+ <Text style={[theme.typography.label, { color: theme.text.neutral.primary, marginBottom: theme.space.md }]}>
37
37
  {label}
38
38
  </Text>
39
39
  )}
@@ -47,7 +47,7 @@ export const CDSSelect = ({ label, options = [], onSelect, selectedValue = null,
47
47
  backgroundColor: theme.surface.neutral.primary,
48
48
  borderColor: theme.outline.neutral.primary,
49
49
  borderRadius: theme.radius.sm,
50
- paddingHorizontal: theme.space.sm
50
+ paddingHorizontal: theme.space.md
51
51
  }
52
52
  ]}
53
53
  onPress={() => setModalVisible(true)}
@@ -80,7 +80,7 @@ export const CDSSelect = ({ label, options = [], onSelect, selectedValue = null,
80
80
  }
81
81
  ]}>
82
82
  {/* Header del Modal */}
83
- <View style={[styles.modalHeader, { borderBottomColor: theme.outline.neutral.primary, padding: theme.space.sm }]}>
83
+ <View style={[styles.modalHeader, { borderBottomColor: theme.outline.neutral.primary, padding: theme.space.md }]}>
84
84
  <Text style={theme.typography.semiBold.md}>{'Selecciona una opción'}</Text>
85
85
  <TouchableOpacity onPress={() => setModalVisible(false)} hitSlop={{top: 10, bottom: 10, left: 10, right: 10}}>
86
86
  <MaterialIcons name="close" size={24} color={theme.text.neutral.primary} />
@@ -102,7 +102,7 @@ export const CDSSelect = ({ label, options = [], onSelect, selectedValue = null,
102
102
  {
103
103
  height: ITEM_HEIGHT,
104
104
  backgroundColor: selectedItem?.value === item.value ? theme.surface.neutral.secondary : 'transparent',
105
- paddingHorizontal: theme.space.sm
105
+ paddingHorizontal: theme.space.md
106
106
 
107
107
  }
108
108
  ]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cdslibrary",
3
3
  "license": "0BSD",
4
- "version": "1.2.95",
4
+ "version": "1.2.97",
5
5
  "main": "index.js",
6
6
  "author": "Nat Viramontes",
7
7
  "description": "A library of components for the CDS project",