ripal-ui 1.1.394 → 2.0.0

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.
Files changed (65) hide show
  1. package/README.md +3 -0
  2. package/components/Alert.jsx +74 -0
  3. package/components/Avatar.jsx +157 -0
  4. package/components/Button.jsx +58 -0
  5. package/components/COLORS.js +138 -0
  6. package/components/Checkbox.jsx +51 -0
  7. package/components/Dialog.jsx +221 -0
  8. package/components/Divider.jsx +62 -0
  9. package/components/Dropdown.jsx +229 -0
  10. package/components/Inline.jsx +37 -0
  11. package/components/Input.jsx +89 -0
  12. package/components/Rate.jsx +39 -0
  13. package/components/Slider.jsx +219 -0
  14. package/components/Switch.jsx +45 -0
  15. package/components/Table.jsx +67 -0
  16. package/components/Text.jsx +56 -0
  17. package/components/Toggle.jsx +88 -0
  18. package/index.js +16 -2
  19. package/package.json +20 -20
  20. package/babel.config.js +0 -3
  21. package/components/BottomSheet.tsx +0 -197
  22. package/components/Carousel.tsx +0 -61
  23. package/components/Circle.tsx +0 -44
  24. package/components/DatePicker.jsx +0 -181
  25. package/components/Tab.tsx +0 -90
  26. package/components/Table.tsx +0 -95
  27. package/components/index.ts +0 -5
  28. package/config.js +0 -4
  29. package/dist/BottomSheet.js +0 -186
  30. package/dist/Button.js +0 -109
  31. package/dist/Carousel.js +0 -52
  32. package/dist/Circle.js +0 -42
  33. package/dist/DatePicker.js +0 -199
  34. package/dist/Dialog.js +0 -81
  35. package/dist/Dropdown.js +0 -97
  36. package/dist/Inline.js +0 -38
  37. package/dist/Input.js +0 -88
  38. package/dist/ProgressBar.js +0 -64
  39. package/dist/Separator.js +0 -47
  40. package/dist/Skeleton.js +0 -62
  41. package/dist/Switch.js +0 -74
  42. package/dist/Tab.js +0 -85
  43. package/dist/Table.js +0 -96
  44. package/dist/Text.js +0 -78
  45. package/dist/Toast.js +0 -72
  46. package/dist/Toggle.js +0 -54
  47. package/dist/index.js +0 -96
  48. package/elements/Button.tsx +0 -121
  49. package/elements/ColorPicker.tsx +0 -70
  50. package/elements/Dialog.tsx +0 -87
  51. package/elements/Dropdown.tsx +0 -88
  52. package/elements/Inline.tsx +0 -52
  53. package/elements/Input.tsx +0 -83
  54. package/elements/ProgressBar.tsx +0 -52
  55. package/elements/SecureStorage.js +0 -27
  56. package/elements/Separator.tsx +0 -71
  57. package/elements/Skeleton.tsx +0 -64
  58. package/elements/Slider.tsx +0 -133
  59. package/elements/Switch.tsx +0 -63
  60. package/elements/Text.tsx +0 -95
  61. package/elements/Toast.tsx +0 -71
  62. package/elements/Toggle.tsx +0 -59
  63. package/elements/index.js +0 -14
  64. package/index.d.ts +0 -237
  65. package/scripts/generateConfig.js +0 -80
package/README.md CHANGED
@@ -0,0 +1,3 @@
1
+ # Ripal UI
2
+
3
+ The doc is working in progress
@@ -0,0 +1,74 @@
1
+ import React from "react";
2
+ import { StyleSheet, View } from "react-native";
3
+ import Inline from "./Inline";
4
+ import Text from "./Text";
5
+ import COLORS from "./COLORS";
6
+
7
+ /**
8
+ * @typedef {Object} AlertProps
9
+ * @property {string} title - Alert title text
10
+ * @property {string|null} [body] - Optional body text
11
+ * @property {string} [color] - Accent color
12
+ * @property {React.ReactNode|null} [icon] - Icon element
13
+ * @property {number} [iconSize] - Icon size
14
+ * @property {import("react-native").StyleProp<import("react-native").ViewStyle>} [iconStyle]
15
+ * @property {import("react-native").StyleProp<import("react-native").ViewStyle>} [contentStyle]
16
+ */
17
+
18
+ /**
19
+ * @param {AlertProps} props
20
+ */
21
+ const Alert = ({title, body = null, color = COLORS.primary, icon = null, iconSize = 42, iconStyle, contentStyle}) => {
22
+ return (
23
+ <Inline style={[
24
+ styles.container
25
+ ]} gap={15} alignItems={body === null ? 'center' : 'flex-start'}>
26
+ {
27
+ icon !== null &&
28
+ <View style={[
29
+ styles.icon,
30
+ {
31
+ height: iconSize,
32
+ aspectRatio: 1,
33
+ backgroundColor: color,
34
+ },
35
+ iconStyle
36
+ ]}>
37
+ {icon}
38
+ </View>
39
+ }
40
+ <View style={[
41
+ styles.content,
42
+ contentStyle,
43
+ ]}>
44
+ <Text style={{fontWeight: '700'}} color={COLORS.slate[800]}>{title}</Text>
45
+ {
46
+ body &&
47
+ <Text size={12}>{body}</Text>
48
+ }
49
+ </View>
50
+ </Inline>
51
+ )
52
+ }
53
+
54
+ const styles = StyleSheet.create({
55
+ container: {
56
+ borderWidth: 1,
57
+ borderColor: '#ddd',
58
+ borderRadius: 20,
59
+ padding: 10,
60
+ },
61
+ icon: {
62
+ alignItems: 'center',
63
+ justifyContent: 'center',
64
+ borderRadius: 15,
65
+ },
66
+ content: {
67
+ gap: 10,
68
+ flexGrow: 1,
69
+ flexBasis: 20,
70
+ flexShrink: 1,
71
+ }
72
+ });
73
+
74
+ export default Alert;
@@ -0,0 +1,157 @@
1
+ import React from "react";
2
+ import Inline from "./Inline";
3
+ import { Image, StyleSheet, View } from "react-native";
4
+ import Text from "./Text";
5
+
6
+ /**
7
+ * @typedef {Object} AvatarProps
8
+ * @property {string|array} [images] - URI of Avatars image
9
+ * @property {int|null} [size] - Size of the image
10
+ * @property {int|null} [radius] - Rounded level of avatar image (borderRadius)
11
+ * @property {string|null} [borderColor] - Edge color of each image
12
+ * @property {int|null} [borderWidth] - Border with of each image
13
+ * @property {int|null} [limit] - Number of displayed image as in a group
14
+ */
15
+
16
+ /**
17
+ * @param {AvatarProps} props
18
+ */
19
+ const Avatar = ({
20
+ images,
21
+ size = 48,
22
+ radius = 999,
23
+ borderColor = '#fff',
24
+ borderWidth = 4,
25
+ limit = 3
26
+ }) => {
27
+ const theImages = Array.isArray(images) ? images : images ? [images] : [];
28
+
29
+ const visibleImages = theImages.slice(0, limit);
30
+ const remainingImages = theImages.slice(limit);
31
+ const remaining = remainingImages.length;
32
+
33
+ // only render max 4 in grid
34
+ const gridImages = remainingImages.slice(0, 4);
35
+ const gridCount = gridImages.length;
36
+
37
+ const avatarStyle = {
38
+ height: size,
39
+ width: size,
40
+ borderRadius: radius,
41
+ borderColor,
42
+ borderWidth,
43
+ };
44
+
45
+ const getGridLayout = (count) => {
46
+ switch (count) {
47
+ case 1:
48
+ return [{ width: '100%', height: '100%' }];
49
+
50
+ case 2:
51
+ return [
52
+ { width: '50%', height: '100%' },
53
+ { width: '50%', height: '100%' }
54
+ ];
55
+
56
+ case 3:
57
+ return [
58
+ { width: '50%', height: '50%' },
59
+ { width: '50%', height: '50%' },
60
+ { width: '100%', height: '50%' }
61
+ ];
62
+
63
+ default: // 4
64
+ return [
65
+ { width: '50%', height: '50%' },
66
+ { width: '50%', height: '50%' },
67
+ { width: '50%', height: '50%' },
68
+ { width: '50%', height: '50%' }
69
+ ];
70
+ }
71
+ };
72
+
73
+ const gridLayout = getGridLayout(gridCount);
74
+
75
+ return (
76
+ <Inline gap={0}>
77
+ {visibleImages.map((img, i) => (
78
+ <Image
79
+ key={i}
80
+ source={{ uri: img }}
81
+ style={[
82
+ styles.img,
83
+ avatarStyle,
84
+ {
85
+ marginLeft: i === 0 ? 0 : -(size / 2.25),
86
+ }
87
+ ]}
88
+ />
89
+ ))}
90
+
91
+ {remaining > 0 && (
92
+ <View
93
+ style={[
94
+ styles.img,
95
+ avatarStyle,
96
+ {
97
+ marginLeft: -(size / 2.25),
98
+ overflow: 'hidden',
99
+ }
100
+ ]}
101
+ >
102
+ <View style={styles.grid}>
103
+ {gridImages.map((img, i) => (
104
+ <Image
105
+ key={i}
106
+ source={{ uri: img }}
107
+ style={[
108
+ styles.gridImg,
109
+ gridLayout[i]
110
+ ]}
111
+ />
112
+ ))}
113
+ </View>
114
+
115
+ <View style={styles.overlay}>
116
+ <Text style={[styles.overlayText, { fontSize: size * 0.28 }]}>
117
+ +{remaining}
118
+ </Text>
119
+ </View>
120
+ </View>
121
+ )}
122
+ </Inline>
123
+ );
124
+ };
125
+
126
+ const styles = StyleSheet.create({
127
+ img: {
128
+ backgroundColor: '#ddd',
129
+ },
130
+
131
+ grid: {
132
+ flex: 1,
133
+ flexDirection: 'row',
134
+ flexWrap: 'wrap',
135
+ },
136
+
137
+ gridImg: {
138
+ },
139
+
140
+ overlay: {
141
+ position: 'absolute',
142
+ top: 0,
143
+ right: 0,
144
+ bottom: 0,
145
+ left: 0,
146
+ backgroundColor: 'rgba(0,0,0,0.45)',
147
+ justifyContent: 'center',
148
+ alignItems: 'center',
149
+ },
150
+
151
+ overlayText: {
152
+ color: '#fff',
153
+ fontWeight: '700',
154
+ }
155
+ });
156
+
157
+ export default Avatar;
@@ -0,0 +1,58 @@
1
+ import React, { useEffect } from "react";
2
+ import { StyleSheet, TouchableOpacity, View } from "react-native";
3
+ import Inline from "./Inline";
4
+ import Text from "./Text";
5
+ import COLORS from "./COLORS";
6
+
7
+ const Button = ({children, full = false, circle = false, color = COLORS.primary, size = 36, style, onPress, onLongPress, accent = 'primary', align = "center"}) => {
8
+ let computedStyles = {
9
+ flexGrow: full ? 1 : 0,
10
+ };
11
+
12
+ if (accent === "primary") {
13
+ computedStyles['backgroundColor'] = color;
14
+ computedStyles['textColor'] = COLORS.white;
15
+ } else if (accent === "secondary") {
16
+ computedStyles['backgroundColor'] = `${color}30`;
17
+ computedStyles['textColor'] = color;
18
+ } else if (accent == "tertiary") {
19
+ computedStyles['backgroundColor'] = `${color}00`,
20
+ computedStyles['textColor'] = color;
21
+ }
22
+
23
+ computedStyles['justifyContent'] = align === "left" ? "flex-start" : align === "right" ? "flex-end" : align;
24
+
25
+ return (
26
+ <Inline>
27
+ <Inline style={[
28
+ styles.button,
29
+ computedStyles,
30
+ circle ? {...styles.circle_button, height: size } : null,
31
+ style
32
+ ]} onPress={onPress} onLongPress={onLongPress}>
33
+ {typeof children === "string" ?
34
+ <Text color={computedStyles.textColor} style={{fontWeight: '700'}}>{children}</Text>
35
+ :
36
+ children
37
+ }
38
+ </Inline>
39
+ </Inline>
40
+ )
41
+ }
42
+
43
+ const styles = StyleSheet.create({
44
+ button: {
45
+ justifyContent: 'center',
46
+ alignItems: 'center',
47
+ backgroundColor: COLORS.primary,
48
+ borderRadius: 99,
49
+ padding: 12,
50
+ paddingHorizontal: 20,
51
+ },
52
+ circle_button: {
53
+ padding: 0,paddingHorizontal: 0,
54
+ aspectRatio: 1,
55
+ }
56
+ });
57
+
58
+ export default Button;
@@ -0,0 +1,138 @@
1
+ const COLORS = {
2
+ black: "#000",
3
+ white: "#fff",
4
+ primary: "#2196f3",
5
+
6
+ amber: {
7
+ 50: "#fffbeb",
8
+ 100: "#fef3c6", 200: "#fee685", 300: "#ffd230", 400: "#ffb900", 500: "#fe9a00",
9
+ 600: "#e17100", 700: "#bb4d00", 800: "#973c00", 900: "#7b3306", 950: "#461901"
10
+ },
11
+ blue: {
12
+ 50: "#eff6ff",
13
+ 100: "#dbeafe", 200: "#bedbff", 300: "#8ec5ff", 400: "#51a2ff", 500: "#2b7fff",
14
+ 600: "#155dfc", 700: "#1447e6", 800: "#193cb8", 900: "#1c398e", 950: "#162456"
15
+ },
16
+ cyan: {
17
+ 50: "#ecfeff",
18
+ 100: "#cefafe", 200: "#a2f4fd", 300: "#53eafd", 400: "#00d3f2", 500: "#00b8db",
19
+ 600: "#0092b8", 700: "#007595", 800: "#005f78", 900: "#104e64", 950: "#053345"
20
+ },
21
+ emerald: {
22
+ 50: "#ecfdf5",
23
+ 100: "#d0fae5", 200: "#a4f4cf", 300: "#5ee9b5", 400: "#00d492", 500: "#00bc7d",
24
+ 600: "#009966", 700: "#007a55", 800: "#006045", 900: "#004f3b", 950: "#002c22"
25
+ },
26
+ fuchsia: {
27
+ 50: "#fdf4ff",
28
+ 100: "#fae8ff", 200: "#f6cfff", 300: "#f4a8ff", 400: "#ed6aff", 500: "#e12afb",
29
+ 600: "#c800de", 700: "#a800b7", 800: "#8a0194", 900: "#721378", 950: "#4b004f"
30
+ },
31
+ gray: {
32
+ 50: "#f9fafb",
33
+ 100: "#f3f4f6", 200: "#e5e7eb", 300: "#d1d5dc", 400: "#99a1af", 500: "#6a7282",
34
+ 600: "#4a5565", 700: "#364153", 800: "#1e2939", 900: "#101828", 950: "#030712"
35
+ },
36
+ green: {
37
+ 50: "#f0fdf4",
38
+ 100: "#dcfce7", 200: "#b9f8cf", 300: "#7bf1a8", 400: "#05df72", 500: "#00c950",
39
+ 600: "#00a63e", 700: "#008236", 800: "#016630", 900: "#0d542b", 950: "#032e15"
40
+ },
41
+ indigo: {
42
+ 50: "#eef2ff",
43
+ 100: "#e0e7ff", 200: "#c6d2ff", 300: "#a3b3ff", 400: "#7c86ff", 500: "#615fff",
44
+ 600: "#4f39f6", 700: "#432dd7", 800: "#372aac", 900: "#312c85", 950: "#1e1a4d"
45
+ },
46
+ lime: {
47
+ 50: "#f7fee7",
48
+ 100: "#ecfcca", 200: "#d8f999", 300: "#bbf451", 400: "#9ae600", 500: "#7ccf00",
49
+ 600: "#5ea500", 700: "#497d00", 800: "#3c6300", 900: "#35530e", 950: "#192e03"
50
+ },
51
+ mauve: {
52
+ 50: "#fafafa",
53
+ 100: "#f3f1f3", 200: "#e7e4e7", 300: "#d7d0d7", 400: "#a89ea9", 500: "#79697b",
54
+ 600: "#594c5b", 700: "#463947", 800: "#2a212c", 900: "#1d161e", 950: "#0c090c"
55
+ },
56
+ mist: {
57
+ 50: "#f9fbfb",
58
+ 100: "#f1f3f3", 200: "#e3e7e8", 300: "#d0d6d8", 400: "#9ca8ab", 500: "#67787c",
59
+ 600: "#4b585b", 700: "#394447", 800: "#22292b", 900: "#161b1d", 950: "#090b0c"
60
+ },
61
+ neutral: {
62
+ 50: "#fafafa",
63
+ 100: "#f5f5f5", 200: "#e5e5e5", 300: "#d4d4d4", 400: "#a1a1a1", 500: "#737373",
64
+ 600: "#525252", 700: "#404040", 800: "#262626", 900: "#171717", 950: "#0a0a0a"
65
+ },
66
+ olive: {
67
+ 50: "#fbfbf9",
68
+ 100: "#f4f4f0", 200: "#e8e8e3", 300: "#d8d8d0", 400: "#abab9c", 500: "#7c7c67",
69
+ 600: "#5b5b4b", 700: "#474739", 800: "#2b2b22", 900: "#1d1d16", 950: "#0c0c09"
70
+ },
71
+ orange: {
72
+ 50: "#fff7ed",
73
+ 100: "#ffedd4", 200: "#ffd6a7", 300: "#ffb86a", 400: "#ff8904", 500: "#ff6900",
74
+ 600: "#f54900", 700: "#ca3500", 800: "#9f2d00", 900: "#7e2a0c", 950: "#441306"
75
+ },
76
+ pink: {
77
+ 50: "#fdf2f8",
78
+ 100: "#fce7f3", 200: "#fccee8", 300: "#fda5d5", 400: "#fb64b6", 500: "#f6339a",
79
+ 600: "#e60076", 700: "#c6005c", 800: "#a3004c", 900: "#861043", 950: "#510424"
80
+ },
81
+ purple: {
82
+ 50: "#faf5ff",
83
+ 100: "#f3e8ff", 200: "#e9d4ff", 300: "#dab2ff", 400: "#c27aff", 500: "#ad46ff",
84
+ 600: "#9810fa", 700: "#8200db", 800: "#6e11b0", 900: "#59168b", 950: "#3c0366"
85
+ },
86
+ red: {
87
+ 50: "#fef2f2",
88
+ 100: "#ffe2e2", 200: "#ffc9c9", 300: "#ffa2a2", 400: "#ff6467", 500: "#fb2c36",
89
+ 600: "#e7000b", 700: "#c10007", 800: "#9f0712", 900: "#82181a", 950: "#460809"
90
+ },
91
+ rose: {
92
+ 50: "#fff1f2",
93
+ 100: "#ffe4e6", 200: "#ffccd3", 300: "#ffa1ad", 400: "#ff637e", 500: "#ff2056",
94
+ 600: "#ec003f", 700: "#c70036", 800: "#a50036", 900: "#8b0836", 950: "#4d0218"
95
+ },
96
+ sky: {
97
+ 50: "#f0f9ff",
98
+ 100: "#dff2fe", 200: "#b8e6fe", 300: "#74d4ff", 400: "#00bcff", 500: "#00a6f4",
99
+ 600: "#0084d1", 700: "#0069a8", 800: "#00598a", 900: "#024a70", 950: "#052f4a"
100
+ },
101
+ slate: {
102
+ 50: "#f8fafc",
103
+ 100: "#f1f5f9", 200: "#e2e8f0", 300: "#cad5e2", 400: "#90a1b9", 500: "#62748e",
104
+ 600: "#45556c", 700: "#314158", 800: "#1d293d", 900: "#0f172b", 950: "#020618"
105
+ },
106
+ stone: {
107
+ 50: "#fafaf9",
108
+ 100: "#f5f5f4", 200: "#e7e5e4", 300: "#d6d3d1", 400: "#a6a09b", 500: "#79716b",
109
+ 600: "#57534d", 700: "#44403b", 800: "#292524", 900: "#1c1917", 950: "#0c0a09"
110
+ },
111
+ taupe: {
112
+ 50: "#fbfaf9",
113
+ 100: "#f3f1f1", 200: "#e8e4e3", 300: "#d8d2d0", 400: "#aba09c", 500: "#7c6d67",
114
+ 600: "#5b4f4b", 700: "#473c39", 800: "#2b2422", 900: "#1d1816", 950: "#0c0a09"
115
+ },
116
+ teal: {
117
+ 50: "#f0fdfa",
118
+ 100: "#cbfbf1", 200: "#96f7e4", 300: "#46ecd5", 400: "#00d5be", 500: "#00bba7",
119
+ 600: "#009689", 700: "#00786f", 800: "#005f5a", 900: "#0b4f4a", 950: "#022f2e"
120
+ },
121
+ violet: {
122
+ 50: "#f5f3ff",
123
+ 100: "#ede9fe", 200: "#ddd6ff", 300: "#c4b4ff", 400: "#a684ff", 500: "#8e51ff",
124
+ 600: "#7f22fe", 700: "#7008e7", 800: "#5d0ec0", 900: "#4d179a", 950: "#2f0d68"
125
+ },
126
+ yellow: {
127
+ 50: "#fefce8",
128
+ 100: "#fef9c2", 200: "#fff085", 300: "#ffdf20", 400: "#fdc700", 500: "#f0b100",
129
+ 600: "#d08700", 700: "#a65f00", 800: "#894b00", 900: "#733e0a", 950: "#432004"
130
+ },
131
+ zinc: {
132
+ 50: "#fafafa",
133
+ 100: "#f4f4f5", 200: "#e4e4e7", 300: "#d4d4d8", 400: "#9f9fa9", 500: "#71717b",
134
+ 600: "#52525c", 700: "#3f3f46", 800: "#27272a", 900: "#18181b", 950: "#09090b"
135
+ }
136
+ };
137
+
138
+ export default COLORS;
@@ -0,0 +1,51 @@
1
+ import React from "react";
2
+ import { StyleSheet, TouchableOpacity } from "react-native";
3
+ import COLORS from "./COLORS";
4
+ import MaterialIcons from "@react-native-vector-icons/material-icons";
5
+
6
+ /**
7
+ * @typedef {Object} CheckboxProps
8
+ * @property {int} [size] - Checkbox's outer size
9
+ * @property {boolean} [active] - State to control mark's visibility (useState)
10
+ * @property {void} [setActive] - Function to mutate the state (useState)
11
+ * @property {null} [icon] - Icon component to override the default checkmark icon
12
+ * @property {int|null} [iconSize] - Size of default icon (checkmark)
13
+ */
14
+
15
+ /**
16
+ * @param {CheckboxProps} props
17
+ */
18
+ const Checkbox = ({size = 20, active, setActive, icon = null, iconSize = 14}) => {
19
+ return (
20
+ <TouchableOpacity style={[
21
+ styles.box,
22
+ {
23
+ height: size,
24
+ borderColor: active ? COLORS.primary : COLORS.slate[300],
25
+ backgroundColor: active ? COLORS.primary : '#ffffff00'
26
+ }
27
+ ]} onPress={() => {
28
+ setActive(!active);
29
+ }}>
30
+ {
31
+ active &&
32
+ <>
33
+ { icon !== null ? icon :
34
+ <MaterialIcons name="check" size={iconSize} color={'#fff'} />}
35
+ </>
36
+ }
37
+ </TouchableOpacity>
38
+ )
39
+ }
40
+
41
+ const styles = StyleSheet.create({
42
+ box: {
43
+ borderWidth: 1,
44
+ borderRadius: 6,
45
+ aspectRatio: 1,
46
+ alignItems: 'center',
47
+ justifyContent: 'center'
48
+ }
49
+ })
50
+
51
+ export default Checkbox;