cdslibrary 1.1.2 → 1.1.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.
@@ -0,0 +1,80 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import { View, StyleSheet, Modal } from "react-native";
3
+ import LottieView from "lottie-react-native";
4
+ import Animated, {
5
+ useSharedValue,
6
+ useAnimatedStyle,
7
+ withTiming,
8
+ withDelay, // 👈 Importamos withDelay
9
+ runOnJS
10
+ } from "react-native-reanimated";
11
+ import { useTheme } from "../context/CDSThemeContext";
12
+
13
+ export const CDSLoader = ({ visible = false }) => {
14
+ const { theme } = useTheme();
15
+ const [shouldRender, setShouldRender] = useState(visible);
16
+ const opacity = useSharedValue(0);
17
+
18
+ useEffect(() => {
19
+ if (visible) {
20
+ setShouldRender(true);
21
+ // Entrada rápida para que no se sienta lag al empezar
22
+ opacity.value = withTiming(1, { duration: 300 });
23
+ } else {
24
+ // 1. Espera 800ms antes de hacer nada (Sostenido)
25
+ // 2. Desvanece lentamente en 1200ms
26
+ opacity.value = withDelay(
27
+ 1000,
28
+ withTiming(0, { duration: 1200 }, (isFinished) => {
29
+ if (isFinished) {
30
+ runOnJS(setShouldRender)(false);
31
+ }
32
+ })
33
+ );
34
+ }
35
+ }, [visible]);
36
+
37
+ const animatedStyle = useAnimatedStyle(() => ({
38
+ opacity: opacity.value,
39
+ }));
40
+
41
+ if (!shouldRender && !visible) return null;
42
+
43
+ return (
44
+ <Modal transparent visible={shouldRender} animationType="none">
45
+ <Animated.View style={[styles.overlay, animatedStyle,
46
+ { backgroundColor: theme.overlay },]}>
47
+ <View
48
+ style={[
49
+ styles.loaderContainer,
50
+ ]}
51
+ >
52
+ <LottieView
53
+ autoPlay
54
+ loop
55
+ source={require("../assets/animations/animationLoaderWhite.json")}
56
+ resizeMode="contain"
57
+ />
58
+ </View>
59
+ </Animated.View>
60
+ </Modal>
61
+ );
62
+ };
63
+
64
+ const styles = StyleSheet.create({
65
+ overlay: {
66
+ height: '100%',
67
+ width: '100%',
68
+ justifyContent: "center",
69
+ alignItems: "center",
70
+ zIndex: 1000,
71
+ },
72
+ loaderContainer: {
73
+ padding: 20,
74
+ // O si usas fijos, asegúrate que sean mayores al estilo del Lottie
75
+ minWidth: 180,
76
+ minHeight: 180,
77
+ justifyContent: "center",
78
+ alignItems: "center",
79
+ },
80
+ });
@@ -48,7 +48,6 @@ export const CDSSelect = ({ label, options = [], onSelect, placeholder = "Selecc
48
48
  },
49
49
  ],
50
50
  };
51
- console.log(theme);
52
51
  return (
53
52
  <View style={[styles.mainContainer, { zIndex: isOpen ? 1000 : 1, gap: theme.space.xs }]}>
54
53
  {label && <Text style={[theme.typography.label, { color: theme.text.neutral.primary }]}>{label}</Text>}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cdslibrary",
3
3
  "license": "0BSD",
4
- "version": "1.1.2",
4
+ "version": "1.1.3",
5
5
  "main": "index.js",
6
6
  "author": "Nat Viramontes",
7
7
  "description": "A library of components for the CDS project",
@@ -2,8 +2,8 @@ import { CDSprimitiveColors } from "./CDSprimitiveTokens";
2
2
 
3
3
  export const CDSsemanticColors = {
4
4
  light: {
5
- logo:{
6
- source:"../assets/logoMonte.png"
5
+ logo: {
6
+ source: "../assets/logoMonte.png"
7
7
  },
8
8
  icon: {
9
9
  neutral: {
@@ -104,10 +104,11 @@ export const CDSsemanticColors = {
104
104
  error: CDSprimitiveColors.scarlet[300],
105
105
  },
106
106
  },
107
+ overlay: CDSprimitiveColors.overlay.light,
107
108
  },
108
109
  dark: {
109
- logo:{
110
- source:'../assets/logoMonteW.png'
110
+ logo: {
111
+ source: '../assets/logoMonteW.png'
111
112
  },
112
113
  icon: {
113
114
  neutral: {
@@ -208,5 +209,6 @@ export const CDSsemanticColors = {
208
209
  error: CDSprimitiveColors.scarlet[350],
209
210
  },
210
211
  },
212
+ overlay: CDSprimitiveColors.overlay.dark,
211
213
  },
212
214
  };