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
@@ -1,63 +0,0 @@
1
- import React, { useState } from "react";
2
- import { Pressable, StyleSheet, View, ViewStyle } from "react-native";
3
- import config from "../config";
4
- import Inline from "./Inline";
5
-
6
- interface SwitchProps {
7
- active?: boolean;
8
- size?: number;
9
- spacer?: number;
10
- onChange?: () => void;
11
- }
12
-
13
- const Switch: React.FC<SwitchProps> = ({
14
- active = false,
15
- size = 24,
16
- spacer = 5,
17
- onChange = null,
18
- }) => {
19
- const [isActive, setActive] = useState(active);
20
-
21
- return (
22
- <Pressable
23
- onPress={() => {
24
- setActive(!isActive);
25
- if (onChange) {
26
- onChange();
27
- }
28
- }}
29
- >
30
- <Inline
31
- style={{
32
- backgroundColor: isActive ? config.colors.green[500] : config.colors.slate[200],
33
- padding: spacer,
34
- borderRadius: 999,
35
- width: size * 2 + spacer + 5,
36
- }}
37
- >
38
- {isActive && <View style={{ flexGrow: 1 }}></View>}
39
- <View
40
- style={{
41
- height: size,
42
- ...styles.circle,
43
- }}
44
- >
45
- {/* Add any inner content here if needed */}
46
- </View>
47
- </Inline>
48
- </Pressable>
49
- );
50
- };
51
-
52
- const styles = StyleSheet.create({
53
- area: {
54
- backgroundColor: config.colors.slate[100],
55
- },
56
- circle: {
57
- backgroundColor: '#fff',
58
- aspectRatio: 1,
59
- borderRadius: 9999,
60
- },
61
- });
62
-
63
- export default Switch;
package/elements/Text.tsx DELETED
@@ -1,95 +0,0 @@
1
- import React, { FC, useEffect, useState } from "react";
2
- import { Text as RNText, TextStyle } from "react-native";
3
- import { useFonts, Poppins_300Light, Poppins_400Regular, Poppins_500Medium, Poppins_600SemiBold, Poppins_700Bold, Poppins_900Black } from "@expo-google-fonts/poppins";
4
- import config from "../config";
5
- import SecureStorage from "./SecureStorage";
6
- import * as Font from "expo-font";
7
-
8
- interface TextProps {
9
- children: React.ReactNode;
10
- weight?: '300Light' | '400Regular' | '500Medium' | '600SemiBold' | '700Bold' | '900Black';
11
- size?: number;
12
- color?: string;
13
- align?: 'left' | 'right' | 'center' | 'justify';
14
- limit?: number;
15
- spacing?: number;
16
- lineHeight?: number | null;
17
- style?: TextStyle;
18
- }
19
-
20
- const Text: FC<TextProps> = ({
21
- children,
22
- weight = "400Regular",
23
- size,
24
- color = config.colors.slate[500],
25
- align = "left",
26
- limit = 0,
27
- spacing = 0,
28
- lineHeight = null,
29
- style
30
- }) => {
31
- const fontName = "Poppins";
32
- const [fontsLoaded, setFontsLoaded] = useState(false);
33
-
34
- useEffect(() => {
35
- Font.loadAsync({
36
- Poppins_300Light: require("@expo-google-fonts/poppins/300Light/Poppins_300Light.ttf"),
37
- Poppins_400Regular: require("@expo-google-fonts/poppins/400Regular/Poppins_400Regular.ttf"),
38
- Poppins_500Medium: require("@expo-google-fonts/poppins/500Medium/Poppins_500Medium.ttf"),
39
- Poppins_600SemiBold: require("@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.ttf"),
40
- Poppins_700Bold: require("@expo-google-fonts/poppins/700Bold/Poppins_700Bold.ttf"),
41
- Poppins_900Black: require("@expo-google-fonts/poppins/900Black/Poppins_900Black.ttf"),
42
- })
43
- .then(() => setFontsLoaded(true))
44
- .catch((err) => console.error("Font loading error:", err));
45
- }, []);
46
-
47
- const [lang, setLang] = useState(config.appLangs.default);
48
-
49
- useEffect(() => {
50
- SecureStorage.getItem('app_lang').then(appLang => {
51
- if (appLang != null) {
52
- setLang(appLang);
53
- }
54
- });
55
- }, []);
56
-
57
- if (lang !== null) {
58
- const ogChildren = children;
59
- if (typeof children === "string") {
60
- children = children.split('.').reduce((acc, key) => {
61
- return acc && acc[key] !== undefined ? acc[key] : ogChildren;
62
- }, config.appLangs[lang]);
63
- }
64
- }
65
-
66
- if (!fontsLoaded) {
67
- console.error('Failed to load font');
68
-
69
- return <RNText>{children}</RNText>; // Return statement added to properly handle loading state
70
- }
71
-
72
- if (limit > 0 && typeof children === "string" && children.length > limit) {
73
- children = children.substr(0, limit) + '...';
74
- }
75
-
76
- return (
77
- <RNText
78
- style={[
79
- {
80
- fontSize: size,
81
- color,
82
- letterSpacing: spacing,
83
- lineHeight: lineHeight ?? undefined,
84
- fontFamily: `${fontName}_${weight}`,
85
- textAlign: align,
86
- },
87
- style,
88
- ]}
89
- >
90
- {children}
91
- </RNText>
92
- );
93
- };
94
-
95
- export default Text;
@@ -1,71 +0,0 @@
1
- import React, { useEffect } from "react";
2
- import { StyleSheet, View, ViewStyle } from "react-native";
3
- import Inline from "./Inline";
4
- import Text from "./Text";
5
- import config from "../config";
6
-
7
- interface ToastProps {
8
- label?: string;
9
- color?: string;
10
- right?: React.ReactNode; // Allows for any valid React node
11
- visible?: boolean;
12
- onDismiss: () => void;
13
- timeout?: number;
14
- containerStyle?: ViewStyle; // Style for the container View
15
- style?: ViewStyle; // Additional style for the Toast
16
- textProps?: React.ComponentProps<typeof Text>; // Props for the Text component
17
- }
18
-
19
- const Toast: React.FC<ToastProps> = ({
20
- label = "Percakapan berhasil dihapus",
21
- right = null,
22
- visible = true,
23
- color = config.colors.slate[800],
24
- onDismiss,
25
- timeout = 3000,
26
- containerStyle,
27
- style,
28
- textProps,
29
- }) => {
30
- useEffect(() => {
31
- if (visible) {
32
- const timer = setTimeout(() => {
33
- onDismiss();
34
- }, timeout);
35
-
36
- return () => clearTimeout(timer);
37
- }
38
- }, [visible, onDismiss, timeout]);
39
-
40
- return visible ? (
41
- <View style={{ ...styles.container, ...containerStyle }}>
42
- <Inline style={{
43
- ...styles.area,
44
- backgroundColor: color,
45
- ...style
46
- }}>
47
- <Text size={12} style={{ flexGrow: 1 }} color="#fff" {...textProps}>
48
- {label}
49
- </Text>
50
- {right}
51
- </Inline>
52
- </View>
53
- ) : null;
54
- };
55
-
56
- const styles = StyleSheet.create({
57
- container: {
58
- position: 'absolute',
59
- bottom: 0,
60
- left: 0,
61
- right: 0,
62
- padding: 20,
63
- },
64
- area: {
65
- borderRadius: 999,
66
- padding: 20,
67
- paddingHorizontal: 30,
68
- },
69
- });
70
-
71
- export default Toast;
@@ -1,59 +0,0 @@
1
- import React from "react";
2
- import { Pressable, StyleSheet, View, ViewStyle } from "react-native";
3
- import config from "../config";
4
- import Text from "./Text";
5
- import Inline from "./Inline";
6
-
7
- interface ToggleProps {
8
- options: string[];
9
- value: any;
10
- setValue: (value: string) => void;
11
- }
12
-
13
- const Toggle: React.FC<ToggleProps> = ({ options, value, setValue }) => {
14
- return (
15
- <Inline style={styles.area}>
16
- {options.map((opt, o) => {
17
- const isActive = value === opt;
18
- return (
19
- <Pressable
20
- key={o}
21
- style={[styles.item, isActive ? styles.item_active : null]}
22
- onPress={() => setValue(opt)}
23
- >
24
- <Text
25
- color={isActive ? config.colors.primary : config.colors.slate[500]}
26
- weight={isActive ? '600SemiBold' : '400Regular'}
27
- >
28
- {opt}
29
- </Text>
30
- </Pressable>
31
- );
32
- })}
33
- </Inline>
34
- );
35
- };
36
-
37
- const styles = StyleSheet.create({
38
- area: {
39
- padding: 10,
40
- backgroundColor: config.colors.slate[100],
41
- borderRadius: 12,
42
- },
43
- item: {
44
- flexGrow: 1,
45
- flexDirection: 'row',
46
- alignItems: 'center',
47
- justifyContent: 'center',
48
- paddingVertical: 10,
49
- borderRadius: 12,
50
- },
51
- item_active: {
52
- backgroundColor: '#fff',
53
- shadowColor: config.colors.slate[300],
54
- shadowOpacity: 0.4,
55
- shadowRadius: 12,
56
- },
57
- });
58
-
59
- export default Toggle;
package/elements/index.js DELETED
@@ -1,14 +0,0 @@
1
- export { default as Button } from './Button';
2
- export { default as ColorPicker } from './ColorPicker';
3
- export { Dialog, DialogActions } from './Dialog';
4
- export { default as Dropdown } from './Dropdown';
5
- export { default as Inline } from './Inline';
6
- export { default as Input } from './Input';
7
- export { default as ProgressBar } from './ProgressBar';
8
- export { default as Separator } from './Separator';
9
- export { default as Skeleton } from './Skeleton';
10
- export { default as Slider } from './Slider';
11
- export { default as Switch } from './Switch';
12
- export { default as Text } from './Text';
13
- export { default as Toast } from './Toast';
14
- export { default as Toggle } from './Toggle';
package/index.d.ts DELETED
@@ -1,237 +0,0 @@
1
- // index.d.ts
2
- declare module 'ripal-ui' {
3
- import * as React from 'react';
4
- import { ViewStyle, TextInputProps } from 'react-native';
5
-
6
- type Size = 'sm' | 'md' | 'lg';
7
- type Variant = 'primary' | 'secondary' | 'success' | 'warning' | 'danger';
8
-
9
- // Button
10
- export interface ButtonProps {
11
- children: React.ReactNode;
12
- accent?: 'primary' | 'secondary' | 'tertiary';
13
- onPress?: () => void;
14
- onLongPress?: () => void;
15
- color?: string;
16
- height?: number;
17
- circle?: boolean;
18
- justifyContent?: ViewStyle['justifyContent'];
19
- style?: ViewStyle;
20
- textProps?: Record<string, unknown>;
21
- }
22
- export const Button: React.FC<ButtonProps>;
23
-
24
- // ColorPicker
25
- export interface ColorPickerProps {
26
- value?: string;
27
- label?: string;
28
- onChange?: (color: string) => void;
29
- }
30
- export const ColorPicker: React.FC<ColorPickerProps>;
31
-
32
- // Input
33
- export interface InputProps {
34
- value?: string;
35
- label?: string | null;
36
- left?: React.ReactNode | null; // Allows for any valid React node
37
- right?: React.ReactNode | null; // Allows for any valid React node
38
- height?: number;
39
- placeholder?: string | null;
40
- mode?: TextInputProps["keyboardType"]; // Use keyboardType from TextInputProps
41
- secureTextEntry?: boolean;
42
- multiline?: boolean;
43
- gap?: number;
44
- onChangeText: (text: string) => void; // Function to handle text changes
45
- }
46
- export const Input: React.FC<InputProps>;
47
-
48
- // ProgressBar
49
- export interface ProgressBarProps {
50
- value: number;
51
- from?: number;
52
- size?: number;
53
- style?: ViewStyle;
54
- percentage?: number | null;
55
- }
56
- export const ProgressBar: React.FC<ProgressBarProps>;
57
-
58
- // Separator
59
- export interface SeparatorProps {
60
- width?: any;
61
- space?: number;
62
- height?: number;
63
- color?: string;
64
- textProps?: React.ComponentProps<typeof Text>;
65
- style?: ViewStyle;
66
- children?: React.ReactNode;
67
- }
68
- export const Separator: React.FC<SeparatorProps>;
69
-
70
- // Checkbox
71
- export interface CheckboxProps {
72
- checked?: boolean;
73
- onChange?: (checked: boolean) => void;
74
- label?: string;
75
- disabled?: boolean;
76
- }
77
- export const Checkbox: React.FC<CheckboxProps>;
78
-
79
- // Text
80
- export interface TextProps {
81
- children: React.ReactNode;
82
- weight?: '300Light' | '400Regular' | '500Medium' | '600SemiBold' | '700Bold' | '900Black';
83
- size?: number;
84
- color?: string;
85
- align?: 'left' | 'right' | 'center' | 'justify';
86
- limit?: number;
87
- spacing?: number;
88
- lineHeight?: number | null;
89
- style?: TextStyle;
90
- }
91
- export const Text: React.FC<TextProps>;
92
-
93
- // Circle
94
- export interface CircleProps {
95
- size?: number;
96
- color?: string;
97
- children?: React.ReactNode;
98
- }
99
- export const Circle: React.FC<CircleProps>;
100
-
101
- // Row
102
- export interface RowProps {
103
- children?: React.ReactNode;
104
- justify?: 'start' | 'center' | 'end' | 'between' | 'around';
105
- align?: 'start' | 'center' | 'end' | 'stretch';
106
- gap?: number;
107
- className?: string;
108
- }
109
- export const Row: React.FC<RowProps>;
110
-
111
- // Inline
112
- export interface InlineProps {
113
- children: React.ReactNode;
114
- alignItems?: "flex-start" | "flex-end" | "center" | "baseline" | "stretch";
115
- justifyContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
116
- gap?: number;
117
- style?: ViewStyle;
118
- onPress?: () => void;
119
- onLongPress?: () => void;
120
- }
121
- export const Inline: React.FC<InlineProps>;
122
-
123
- // Cell
124
- export interface CellProps {
125
- children?: React.ReactNode;
126
- width?: number | string;
127
- }
128
- export const Cell: React.FC<CellProps>;
129
-
130
- // // BottomSheet
131
- // export interface BottomSheetProps {
132
- // open: boolean;
133
- // onClose: () => void;
134
- // children?: React.ReactNode;
135
- // }
136
- // export const BottomSheet: React.FC<BottomSheetProps>;
137
-
138
- // Skeleton
139
- export interface SkeletonProps {
140
- color?: string;
141
- rounded?: number;
142
- width?: any;
143
- height?: number;
144
- aspectRatio?: number | null;
145
- }
146
- export const Skeleton: React.FC<SkeletonProps>;
147
-
148
- // Slider
149
- export interface SliderProps {
150
- start?: number;
151
- end?: number;
152
- value?: number;
153
- rounded?: number;
154
- trackColor?: string;
155
- color?: string;
156
- height?: number;
157
- thumbOpacity?: number;
158
- thumbColor?: string;
159
- onChange?: (value: number) => void;
160
- setScrollEnabled?: (enabled: boolean) => void;
161
- }
162
- export const Slider: React.FC<SliderProps>;
163
-
164
- // Switch
165
- export interface SwitchProps {
166
- active?: boolean;
167
- size?: number;
168
- spacer?: number;
169
- onChange?: () => void;
170
- }
171
- export const Switch: React.FC<SwitchProps>;
172
-
173
- // Dialog
174
- export interface DialogProps {
175
- spacer?: number;
176
- children: React.ReactNode;
177
- visible: boolean;
178
- onDismiss: () => void;
179
- }
180
- export const Dialog: React.FC<DialogProps>;
181
-
182
- // DialogActions
183
- export interface DialogActionsProps {
184
- children: React.ReactNode;
185
- }
186
- export const DialogActions: React.FC<DialogActionsProps>;
187
-
188
- type OptionType<T> = T[] | string[];
189
-
190
- export interface DropdownProps<T> {
191
- options: OptionType<T>;
192
- value: T | null;
193
- setValue: (value: T) => void;
194
- onChange?: (value: T) => void;
195
- color?: string;
196
- label?: string | null;
197
- placeholder?: string;
198
- objectKey?: keyof T | null;
199
- withSearch?: boolean;
200
- }
201
-
202
- // Generic component declaration
203
- export function Dropdown<T>(props: DropdownProps<T>): React.ReactElement;
204
-
205
- // Toast
206
- export interface ToastProps {
207
- label?: string;
208
- color?: string;
209
- right?: React.ReactNode; // Allows for any valid React node
210
- visible?: boolean;
211
- onDismiss: () => void;
212
- timeout?: number;
213
- containerStyle?: ViewStyle; // Style for the container View
214
- style?: ViewStyle; // Additional style for the Toast
215
- textProps?: React.ComponentProps<typeof Text>; // Props for the Text component
216
- }
217
- export const Toast: React.FC<ToastProps>;
218
-
219
- // Toggle
220
- export interface ToggleProps {
221
- options: string[];
222
- value: any;
223
- setValue: (value: string) => void;
224
- }
225
- export const Toggle: React.FC<ToggleProps>;
226
-
227
- // // Table
228
- // export interface TableProps<T = any> {
229
- // data: T[];
230
- // columns: {
231
- // title: string;
232
- // key: keyof T;
233
- // render?: (row: T) => React.ReactNode;
234
- // }[];
235
- // }
236
- // export const Table: React.FC<TableProps>;
237
- }
@@ -1,80 +0,0 @@
1
- // ./scripts/generateConfig.js
2
- const fs = require('fs');
3
- const path = require('path');
4
- const { exec } = require('child_process');
5
-
6
- // Define the config file content
7
- const configContent = `const config = {
8
- appName: "",
9
- appLangs: {
10
- default: null,
11
- en: require('./lang/en.json')
12
- },
13
- colors: {
14
- primary: "#3B82F6",
15
- transparent: "#ffffff00",
16
- white: "#fff",
17
- slate: {
18
- 100: "#F1F5F9",200: "#E2E8F0",300: "#CBD5E1",
19
- 400: "#94A3B8",500: "#64748B",600: "#475569",
20
- 700: "#334155",800: "#1E293B",900: "#0F172A",
21
- },
22
- green: {
23
- 100: "#DCFCE7",200: "#BBF7D0",300: "#86EFAC ",
24
- 400: "#4ADE7F",500: "#22C55E",600: "#16A34A",
25
- 700: "#15803D",800: "#166534",900: "#14532D",
26
- },
27
- orange: {
28
- 100: "#FFEDD5",200: "#FED7AA",300: "#FDBA74",
29
- 400: "#FB923C",500: "#F87316",600: "#EA580C",
30
- 700: "#C2410C",800: "#9A3412",900: "#7C2D12",
31
- },
32
- purple: {
33
- 100: "#F3E8FF",200: "#E9D5FF",300: "#D8B4FE",
34
- 400: "#C084FC",500: "#A855F7",600: "#9333EA",
35
- 700: "#7E22CE",800: "#6B21A8",900: "#581C87",
36
- },
37
- blue: {
38
- 100: "#D8EAFE",200: "#BFD8FE",300: "#94C5FD",
39
- 400: "#60A5FA",500: "#3B82F6",600: "#2563EB",
40
- 700: "#1D4ED8",800: "#1E41AF",900: "#1E3A8A",
41
- },
42
- red: {
43
- 100: "#FEE2E2",200: "#FECACA",300: "#FCA5A5",
44
- 400: "#F87171",500: "#EF4444",600: "#DC2626",
45
- 700: "#B91C1C",800: "#991B1B",900: "#7F1D1D",
46
- },
47
- lime: {
48
- 100: "#ECFCCB",200: "#D9F99D",300: "#BEF264",
49
- 400: "#A3E635",500: "#84CC16",600: "#65A30D",
50
- 700: "#4D7C0F",800: "#3F6212",900: "#365314",
51
- },
52
- yellow: {
53
- 100: "#FEF9C3",200: "#FEF08A",300: "#FDE047",
54
- 400: "#FACC15",500: "#EAB308",600: "#CA8A04",
55
- 700: "#A16207",800: "#854D0E",900: "#713F12",
56
- }
57
- }
58
- }
59
-
60
- export default config
61
- `;
62
-
63
- // Path to generate the config file in the user's project root
64
- const configFilePath = path.resolve(process.cwd(), '../../ripal-ui.config.js');
65
- const langDirPath = path.resolve(process.cwd(), '../../lang');
66
- const enJsonFilePath = path.resolve(langDirPath, 'en.json');
67
-
68
- // Check if the config file already exists
69
- if (!fs.existsSync(configFilePath)) {
70
- // Write the config file
71
- fs.writeFileSync(configFilePath, configContent);
72
- console.log('ripal-ui.config.js has been generated in the root project.');
73
-
74
- fs.mkdirSync(langDirPath, {recursive: true});
75
-
76
- const enContent = JSON.stringify({ say_hello: "Hello world"}, null, 4);
77
- fs.writeFileSync(enJsonFilePath, enContent);
78
- } else {
79
- console.log('ripal-ui.config.js already exists. No changes made.');
80
- }