ripal-ui 1.0.17 → 1.0.21

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,4 +1,4 @@
1
- import React, { useEffect, useRef, useState } from 'react';
1
+ import React, { useEffect, useRef, useState, ReactNode } from 'react';
2
2
  import {
3
3
  Animated,
4
4
  View,
@@ -15,7 +15,26 @@ import config from '../config';
15
15
 
16
16
  const { height: screenHeight } = Dimensions.get('window');
17
17
 
18
- const BottomSheet = ({ isVisible, onClose, children, height = 'auto', scroll = false, style, contentContainerStyle }) => {
18
+ // Define props interface
19
+ interface BottomSheetProps {
20
+ isVisible: boolean;
21
+ onClose: () => void;
22
+ children: ReactNode;
23
+ height?: number | string;
24
+ scroll?: boolean;
25
+ style?: object;
26
+ contentContainerStyle?: object;
27
+ }
28
+
29
+ const BottomSheet: React.FC<BottomSheetProps> = ({
30
+ isVisible,
31
+ onClose,
32
+ children,
33
+ height = 'auto',
34
+ scroll = false,
35
+ style,
36
+ contentContainerStyle,
37
+ }) => {
19
38
  const [visible, setVisible] = useState(isVisible);
20
39
  const translateY = useRef(new Animated.Value(screenHeight)).current;
21
40
  const scrollOffset = useRef(0); // Keep track of ScrollView offset
@@ -102,7 +121,7 @@ const BottomSheet = ({ isVisible, onClose, children, height = 'auto', scroll = f
102
121
  return (
103
122
  <View style={StyleSheet.absoluteFill}>
104
123
  {/* Background Overlay */}
105
- <TouchableWithoutFeedback onPress={() => onClose()}>
124
+ <TouchableWithoutFeedback onPress={onClose}>
106
125
  <View style={styles.overlay} />
107
126
  </TouchableWithoutFeedback>
108
127
 
@@ -111,7 +130,7 @@ const BottomSheet = ({ isVisible, onClose, children, height = 'auto', scroll = f
111
130
  {...panResponder.panHandlers}
112
131
  style={[
113
132
  styles.sheet,
114
- { height, ...style },
133
+ { height: height, ...style },
115
134
  {
116
135
  transform: [
117
136
  { translateY },
@@ -126,7 +145,7 @@ const BottomSheet = ({ isVisible, onClose, children, height = 'auto', scroll = f
126
145
  {/* Children */}
127
146
  <View style={styles.dragIndicatorContainer}>
128
147
  <TouchableWithoutFeedback {...panResponder.panHandlers}>
129
- <Separator height={6} style={{borderRadius: 99}} width='12%' color={config.colors.slate[300]} />
148
+ <Separator height={6} style={{ borderRadius: 99 }} width='12%' color={config.colors.slate[300]} />
130
149
  </TouchableWithoutFeedback>
131
150
  </View>
132
151
 
@@ -168,11 +187,6 @@ const styles = StyleSheet.create({
168
187
  borderTopRightRadius: 20,
169
188
  elevation: 5,
170
189
  },
171
- content: {
172
- flex: 1,
173
- justifyContent: 'center',
174
- alignItems: 'center',
175
- },
176
190
  dragIndicatorContainer: {
177
191
  width: '100%',
178
192
  alignItems: 'center',
@@ -0,0 +1,61 @@
1
+ import React from "react";
2
+ import { Dimensions, Pressable, ScrollView, StyleSheet, View, ViewStyle } from "react-native";
3
+ import { Text } from "../elements";
4
+
5
+ // Define types for the CarouselItem props
6
+ interface CarouselItemProps {
7
+ children: React.ReactNode;
8
+ itemWidth: number;
9
+ onPress?: () => void;
10
+ style?: ViewStyle;
11
+ }
12
+
13
+ // Define the CarouselItem component
14
+ const CarouselItem: React.FC<CarouselItemProps> = ({ children, itemWidth, onPress, style }) => {
15
+ return (
16
+ <Pressable style={{ width: itemWidth, ...style }} onPress={onPress}>
17
+ {children}
18
+ </Pressable>
19
+ );
20
+ };
21
+
22
+ // Define types for the Carousel props
23
+ interface CarouselProps {
24
+ children: React.ReactNode;
25
+ itemWidth?: number;
26
+ showIndicator?: boolean;
27
+ }
28
+
29
+ // Define the Carousel component
30
+ const Carousel: React.FC<CarouselProps> = ({
31
+ children,
32
+ itemWidth = 0.6 * Dimensions.get('window').width,
33
+ showIndicator = false,
34
+ }) => {
35
+ return (
36
+ <ScrollView
37
+ horizontal
38
+ showsHorizontalScrollIndicator={showIndicator}
39
+ contentContainerStyle={styles.container}
40
+ >
41
+ <View></View>
42
+ {React.Children.map(children, (child) =>
43
+ React.cloneElement(child as React.ReactElement<any>, { itemWidth })
44
+ )}
45
+ <View></View>
46
+ </ScrollView>
47
+ );
48
+ };
49
+
50
+ // Define styles
51
+ const styles = StyleSheet.create({
52
+ area: {
53
+ // Add any specific styles if needed
54
+ },
55
+ container: {
56
+ gap: 20,
57
+ },
58
+ });
59
+
60
+ // Export components
61
+ export { Carousel, CarouselItem };
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+ import { Pressable, StyleSheet, PressableProps, ViewStyle } from "react-native";
3
+ import config from "../config";
4
+
5
+ interface CircleProps extends PressableProps {
6
+ size?: number; // Optional size for the circle
7
+ color?: string; // Optional color for the circle
8
+ rounded?: number; // Optional rounded value for the border radius
9
+ children?: React.ReactNode; // Allows for any valid React node
10
+ onPress?: () => void; // Optional onPress function
11
+ }
12
+
13
+ const Circle: React.FC<CircleProps> = ({
14
+ size = 24,
15
+ color = config.colors.primary,
16
+ children,
17
+ onPress,
18
+ rounded = 999,
19
+ }) => {
20
+ return (
21
+ <Pressable
22
+ onPress={onPress}
23
+ style={{
24
+ ...styles.area,
25
+ backgroundColor: color,
26
+ height: size,
27
+ width: size, // Added width to maintain aspect ratio
28
+ borderRadius: rounded,
29
+ }}
30
+ >
31
+ {children}
32
+ </Pressable>
33
+ );
34
+ };
35
+
36
+ const styles = StyleSheet.create({
37
+ area: {
38
+ aspectRatio: 1,
39
+ alignItems: 'center',
40
+ justifyContent: 'center',
41
+ },
42
+ });
43
+
44
+ export default Circle;
@@ -0,0 +1,90 @@
1
+ import React, { useState, ReactNode } from "react";
2
+ import { Pressable, ScrollView, StyleSheet, View } from "react-native";
3
+ import Text from "../elements/Text";
4
+ import Inline from "../elements/Inline";
5
+ import config from "../config";
6
+
7
+ // Define the props for the TabScreen component
8
+ interface TabScreenProps {
9
+ children: ReactNode;
10
+ }
11
+
12
+ // TabScreen component
13
+ const TabScreen: React.FC<TabScreenProps> = ({ children }) => {
14
+ return <>{children}</>;
15
+ };
16
+
17
+ // Define the props for the Tab component
18
+ interface TabProps {
19
+ children: React.ReactElement<{ title: string }>[];
20
+ }
21
+
22
+ // Tab component
23
+ const Tab: React.FC<TabProps> = ({ children }) => {
24
+ const [index, setIndex] = useState(0);
25
+
26
+ return (
27
+ <View>
28
+ {
29
+ children.length > 3 ? (
30
+ <ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.tab_area}>
31
+ {children.map((child, c) => {
32
+ const isActive = c === index;
33
+ return (
34
+ <Pressable
35
+ key={c}
36
+ style={{
37
+ ...styles.tab_item,
38
+ borderBottomColor: isActive ? config.colors.primary : config.colors.slate[200],
39
+ }}
40
+ onPress={() => setIndex(c)}
41
+ >
42
+ <Text
43
+ color={isActive ? config.colors.primary : config.colors.slate[500]}
44
+ weight={isActive ? "600SemiBold" : "400Regular"}
45
+ >
46
+ {child.props.title}
47
+ </Text>
48
+ </Pressable>
49
+ );
50
+ })}
51
+ </ScrollView>
52
+ ) : (
53
+ <Inline style={styles.tab_area} gap={0}>
54
+ {children.map((child, c) => {
55
+ const isActive = c === index;
56
+ return (
57
+ <Inline justifyContent="center" key={c} style={{
58
+ ...styles.tab_item,
59
+ borderBottomColor: isActive ? config.colors.primary : config.colors.slate[200],
60
+ }} onPress={() => setIndex(c)}>
61
+ <Text
62
+ color={isActive ? config.colors.primary : config.colors.slate[500]}
63
+ weight={isActive ? "600SemiBold" : "400Regular"}
64
+ >
65
+ {child.props.title}
66
+ </Text>
67
+ </Inline>
68
+ );
69
+ })}
70
+ </Inline>
71
+ )
72
+ }
73
+ {children[index]}
74
+ </View>
75
+ );
76
+ };
77
+
78
+ const styles = StyleSheet.create({
79
+ tab_area: {
80
+ marginBottom: 10,
81
+ },
82
+ tab_item: {
83
+ paddingHorizontal: 20,
84
+ paddingVertical: 12,
85
+ flexGrow: 1,
86
+ borderBottomWidth: 1,
87
+ }
88
+ });
89
+
90
+ export { Tab, TabScreen };
@@ -1,10 +1,18 @@
1
1
  import React from 'react';
2
- import { View, ScrollView, StyleSheet } from 'react-native';
2
+ import { View, ScrollView, StyleSheet, ViewStyle } from 'react-native';
3
3
  import Text from '../elements/Text';
4
4
  import config from '../config';
5
5
 
6
+ // Define the types for the Cell component props
7
+ interface CellProps {
8
+ children: React.ReactNode;
9
+ isHeader?: boolean;
10
+ width?: number;
11
+ flexible?: boolean;
12
+ }
13
+
6
14
  // Cell component
7
- const Cell = ({ children, isHeader, width, flexible }) => {
15
+ const Cell: React.FC<CellProps> = ({ children, isHeader = false, width, flexible = false }) => {
8
16
  return (
9
17
  <View style={[styles.cell, { width: flexible ? 'auto' : width, flex: flexible ? 1 : undefined }]}>
10
18
  <Text weight={isHeader ? '600SemiBold' : '400Regular'}>
@@ -14,37 +22,51 @@ const Cell = ({ children, isHeader, width, flexible }) => {
14
22
  );
15
23
  };
16
24
 
25
+ // Define the types for the Row component props
26
+ interface RowProps {
27
+ children: React.ReactNode;
28
+ isHeader?: boolean;
29
+ cellWidth?: number;
30
+ flexible?: boolean;
31
+ }
32
+
17
33
  // Row component
18
- const Row = ({ children, isHeader, cellWidth, flexible }) => {
34
+ const Row: React.FC<RowProps> = ({ children, isHeader = false, cellWidth, flexible = false }) => {
19
35
  return (
20
36
  <View style={styles.row}>
21
37
  {React.Children.map(children, (child) =>
22
- React.cloneElement(child, { isHeader, width: cellWidth, flexible })
38
+ React.cloneElement(child as React.ReactElement, { isHeader, width: cellWidth, flexible })
23
39
  )}
24
40
  </View>
25
41
  );
26
42
  };
27
43
 
44
+ // Define the types for the Table component props
45
+ interface TableProps {
46
+ children: React.ReactNode;
47
+ cellWidth?: number;
48
+ }
49
+
28
50
  // Table component with dynamic width adjustment and scroll if more than 3 cells
29
- const Table = ({ children, cellWidth = 100 }) => {
51
+ const Table: React.FC<TableProps> = ({ children, cellWidth = 100 }) => {
30
52
  // Determine if any row has more than 3 cells
31
53
  const hasManyCells = React.Children.toArray(children).some(child => {
32
- return React.Children.count(child.props.children) > 3;
54
+ return React.Children.count((child as React.ReactElement).props.children) > 3;
33
55
  });
34
56
 
35
57
  return hasManyCells ? (
36
58
  <ScrollView horizontal>
37
- <View style={styles.table}>
59
+ <View>
38
60
  {React.Children.map(children, (child, index) => (
39
61
  // Automatically pass `isHeader` for the first row (index 0)
40
- React.cloneElement(child, { isHeader: index === 0, cellWidth, flexible: false })
62
+ React.cloneElement(child as React.ReactElement, { isHeader: index === 0, cellWidth, flexible: false })
41
63
  ))}
42
64
  </View>
43
65
  </ScrollView>
44
66
  ) : (
45
- <View style={styles.table}>
67
+ <View>
46
68
  {React.Children.map(children, (child, index) => (
47
- React.cloneElement(child, { isHeader: index === 0, cellWidth, flexible: true })
69
+ React.cloneElement(child as React.ReactElement, { isHeader: index === 0, cellWidth, flexible: true })
48
70
  ))}
49
71
  </View>
50
72
  );
@@ -0,0 +1,5 @@
1
+ export { default as Circle } from './Circle';
2
+ export { default as BottomSheet } from './BottomSheet';
3
+ export { Carousel, CarouselItem } from "./Carousel";
4
+ export { Table, Cell, Row } from './Table';
5
+ export { Tab, TabScreen } from "./Tab";
package/config.js CHANGED
@@ -1,3 +1,4 @@
1
1
  import config from "../../ripal-ui.config.js"
2
+ // import config from "../ripal-ui.config.js"
2
3
 
3
4
  export default config
package/dist/index.js CHANGED
@@ -3,46 +3,94 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "BottomSheet", {
6
+ Object.defineProperty(exports, "Button", {
7
7
  enumerable: true,
8
8
  get: function get() {
9
- return _BottomSheet["default"];
9
+ return _Button["default"];
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "Carousel", {
12
+ Object.defineProperty(exports, "Dialog", {
13
13
  enumerable: true,
14
14
  get: function get() {
15
- return _Carousel["default"];
15
+ return _Dialog.Dialog;
16
16
  }
17
17
  });
18
- Object.defineProperty(exports, "Circle", {
18
+ Object.defineProperty(exports, "DialogActions", {
19
19
  enumerable: true,
20
20
  get: function get() {
21
- return _Circle["default"];
21
+ return _Dialog.DialogActions;
22
22
  }
23
23
  });
24
- Object.defineProperty(exports, "DatePicker", {
24
+ Object.defineProperty(exports, "Dropdown", {
25
25
  enumerable: true,
26
26
  get: function get() {
27
- return _DatePicker["default"];
27
+ return _Dropdown["default"];
28
28
  }
29
29
  });
30
- Object.defineProperty(exports, "Tab", {
30
+ Object.defineProperty(exports, "Inline", {
31
31
  enumerable: true,
32
32
  get: function get() {
33
- return _Tab["default"];
33
+ return _Inline["default"];
34
34
  }
35
35
  });
36
- Object.defineProperty(exports, "Table", {
36
+ Object.defineProperty(exports, "Input", {
37
37
  enumerable: true,
38
38
  get: function get() {
39
- return _Table["default"];
39
+ return _Input["default"];
40
40
  }
41
41
  });
42
- var _BottomSheet = _interopRequireDefault(require("./BottomSheet"));
43
- var _Carousel = _interopRequireDefault(require("./Carousel"));
44
- var _Circle = _interopRequireDefault(require("./Circle"));
45
- var _DatePicker = _interopRequireDefault(require("./DatePicker"));
46
- var _Tab = _interopRequireDefault(require("./Tab"));
47
- var _Table = _interopRequireDefault(require("./Table"));
42
+ Object.defineProperty(exports, "ProgressBar", {
43
+ enumerable: true,
44
+ get: function get() {
45
+ return _ProgressBar["default"];
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "Separator", {
49
+ enumerable: true,
50
+ get: function get() {
51
+ return _Separator["default"];
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "Skeleton", {
55
+ enumerable: true,
56
+ get: function get() {
57
+ return _Skeleton["default"];
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "Switch", {
61
+ enumerable: true,
62
+ get: function get() {
63
+ return _Switch["default"];
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "Text", {
67
+ enumerable: true,
68
+ get: function get() {
69
+ return _Text["default"];
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "Toast", {
73
+ enumerable: true,
74
+ get: function get() {
75
+ return _Toast["default"];
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "Toggle", {
79
+ enumerable: true,
80
+ get: function get() {
81
+ return _Toggle["default"];
82
+ }
83
+ });
84
+ var _Button = _interopRequireDefault(require("./Button"));
85
+ var _Dialog = require("./Dialog");
86
+ var _Dropdown = _interopRequireDefault(require("./Dropdown"));
87
+ var _Inline = _interopRequireDefault(require("./Inline"));
88
+ var _Input = _interopRequireDefault(require("./Input"));
89
+ var _ProgressBar = _interopRequireDefault(require("./ProgressBar"));
90
+ var _Separator = _interopRequireDefault(require("./Separator"));
91
+ var _Skeleton = _interopRequireDefault(require("./Skeleton"));
92
+ var _Switch = _interopRequireDefault(require("./Switch"));
93
+ var _Text = _interopRequireDefault(require("./Text"));
94
+ var _Toast = _interopRequireDefault(require("./Toast"));
95
+ var _Toggle = _interopRequireDefault(require("./Toggle"));
48
96
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
@@ -1,36 +1,51 @@
1
- import React from 'react';
2
- import { TouchableOpacity, StyleSheet } from 'react-native';
1
+ import React, { FC } from 'react';
2
+ import { TouchableOpacity, StyleSheet, ViewStyle } from 'react-native';
3
3
  import config from '../config';
4
4
  import Text from './Text';
5
5
 
6
- const Button = ({
7
- children,
8
- accent = 'primary',
9
- onPress, onLongPress,
10
- color = config.colors.primary,
11
- height = 50,
12
- circle = false,
13
- justifyContent = 'center',
14
- style, textProps
6
+ interface ButtonProps {
7
+ children: React.ReactNode;
8
+ accent?: 'primary' | 'secondary' | 'tertiary';
9
+ onPress?: () => void;
10
+ onLongPress?: () => void;
11
+ color?: string;
12
+ height?: number;
13
+ circle?: boolean;
14
+ justifyContent?: ViewStyle['justifyContent'];
15
+ style?: ViewStyle;
16
+ textProps?: Record<string, unknown>;
17
+ }
18
+
19
+ const Button: FC<ButtonProps> = ({
20
+ children,
21
+ accent = 'primary',
22
+ onPress,
23
+ onLongPress,
24
+ color = config.colors.primary,
25
+ height = 50,
26
+ circle = false,
27
+ justifyContent = 'center',
28
+ style,
29
+ textProps
15
30
  }) => {
16
- const getAccentStyle = () => {
31
+ const getAccentStyle = (): ViewStyle => {
17
32
  switch (accent) {
18
33
  case 'primary':
19
34
  return {
20
35
  backgroundColor: color,
21
36
  borderColor: color,
22
- color: '#fff',
37
+ // color: '#fff',
23
38
  };
24
39
  case 'secondary':
25
40
  return {
26
41
  backgroundColor: '#fff',
27
42
  borderColor: color,
28
- color: color,
43
+ // color: color,
29
44
  };
30
45
  case 'tertiary':
31
46
  return {
32
47
  backgroundColor: '#fff',
33
- color: color,
48
+ // color: color,
34
49
  borderColor: config.colors.transparent
35
50
  };
36
51
  default:
@@ -38,7 +53,7 @@ const Button = ({
38
53
  }
39
54
  };
40
55
 
41
- const getColorStyle = () => {
56
+ const getColorStyle = (): ViewStyle => {
42
57
  switch (color) {
43
58
  case 'red':
44
59
  return { backgroundColor: '#e74c3c', borderColor: '#e74c3c' };
@@ -56,19 +71,26 @@ const Button = ({
56
71
  onPress={onPress}
57
72
  onLongPress={onLongPress}
58
73
  style={[
59
- styles.button,
60
- getAccentStyle(),
74
+ styles.button,
75
+ getAccentStyle(),
61
76
  getColorStyle(),
62
- {
63
- height: height,
64
- aspectRatio: circle ? 1 : 'auto',
65
- borderRadius: circle ? 999 : 12,
66
- justifyContent: justifyContent,
67
- ...style
77
+ {
78
+ height: height,
79
+ aspectRatio: circle ? 1 : undefined,
80
+ borderRadius: circle ? 999 : 12,
81
+ justifyContent: justifyContent,
82
+ ...style,
68
83
  }
69
84
  ]}
70
85
  >
71
- <Text {...textProps} color={accent === "primary" ? "#fff" : color} style={styles.text} weight='600SemiBold'>{children}</Text>
86
+ <Text
87
+ {...textProps}
88
+ color={accent === "primary" ? "#fff" : color}
89
+ style={styles.text}
90
+ weight='600SemiBold'
91
+ >
92
+ {children}
93
+ </Text>
72
94
  </TouchableOpacity>
73
95
  );
74
96
  };
@@ -77,7 +99,7 @@ const styles = StyleSheet.create({
77
99
  button: {
78
100
  paddingHorizontal: 20,
79
101
  height: 50,
80
- borderRadius: 8,
102
+ borderRadius: 12,
81
103
  fontWeight: '600',
82
104
  fontSize: 14,
83
105
  display: 'flex',
@@ -86,6 +108,9 @@ const styles = StyleSheet.create({
86
108
  justifyContent: 'center',
87
109
  borderWidth: 1,
88
110
  },
111
+ text: {
112
+ // Adjust text style here if necessary
113
+ }
89
114
  });
90
115
 
91
116
  export default Button;