@retray-dev/ui-kit 0.1.0 → 1.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 (56) hide show
  1. package/COMPONENTS.md +654 -0
  2. package/LICENSE +21 -0
  3. package/README.md +151 -0
  4. package/dist/index.d.mts +309 -3
  5. package/dist/index.d.ts +309 -3
  6. package/dist/index.js +1477 -57
  7. package/dist/index.mjs +1424 -57
  8. package/package.json +27 -5
  9. package/src/components/Accordion/Accordion.tsx +161 -0
  10. package/src/components/Accordion/index.ts +2 -0
  11. package/src/components/Alert/Alert.tsx +57 -0
  12. package/src/components/Alert/index.ts +2 -0
  13. package/src/components/Avatar/Avatar.tsx +67 -0
  14. package/src/components/Avatar/index.ts +2 -0
  15. package/src/components/Badge/Badge.tsx +48 -0
  16. package/src/components/Badge/index.ts +2 -0
  17. package/src/components/Button/Button.tsx +78 -45
  18. package/src/components/Card/Card.tsx +109 -0
  19. package/src/components/Card/index.ts +9 -0
  20. package/src/components/Checkbox/Checkbox.tsx +70 -0
  21. package/src/components/Checkbox/index.ts +2 -0
  22. package/src/components/EmptyState/EmptyState.tsx +69 -0
  23. package/src/components/EmptyState/index.ts +2 -0
  24. package/src/components/Input/Input.tsx +26 -41
  25. package/src/components/Progress/Progress.tsx +53 -0
  26. package/src/components/Progress/index.ts +2 -0
  27. package/src/components/RadioGroup/RadioGroup.tsx +105 -0
  28. package/src/components/RadioGroup/index.ts +2 -0
  29. package/src/components/Select/Select.tsx +185 -0
  30. package/src/components/Select/index.ts +2 -0
  31. package/src/components/Separator/Separator.tsx +33 -0
  32. package/src/components/Separator/index.ts +2 -0
  33. package/src/components/Sheet/Sheet.tsx +108 -0
  34. package/src/components/Sheet/index.ts +2 -0
  35. package/src/components/Skeleton/Skeleton.tsx +40 -0
  36. package/src/components/Skeleton/index.ts +2 -0
  37. package/src/components/Slider/Slider.tsx +142 -0
  38. package/src/components/Slider/index.ts +2 -0
  39. package/src/components/Spinner/Spinner.tsx +27 -0
  40. package/src/components/Spinner/index.ts +2 -0
  41. package/src/components/Switch/Switch.tsx +82 -0
  42. package/src/components/Switch/index.ts +2 -0
  43. package/src/components/Tabs/Tabs.tsx +145 -0
  44. package/src/components/Tabs/index.ts +2 -0
  45. package/src/components/Text/Text.tsx +10 -4
  46. package/src/components/Textarea/Textarea.tsx +70 -0
  47. package/src/components/Textarea/index.ts +2 -0
  48. package/src/components/Toast/Toast.tsx +164 -0
  49. package/src/components/Toast/index.ts +2 -0
  50. package/src/components/Toggle/Toggle.tsx +80 -0
  51. package/src/components/Toggle/index.ts +2 -0
  52. package/src/index.ts +26 -0
  53. package/src/theme/ThemeProvider.tsx +47 -0
  54. package/src/theme/colors.ts +41 -0
  55. package/src/theme/index.ts +4 -0
  56. package/src/theme/types.ts +31 -0
@@ -0,0 +1,70 @@
1
+ import React from 'react'
2
+ import { TouchableOpacity, View, Text, StyleSheet, ViewStyle } from 'react-native'
3
+ import * as Haptics from 'expo-haptics'
4
+ import { useTheme } from '../../theme'
5
+
6
+ export interface CheckboxProps {
7
+ checked?: boolean
8
+ onCheckedChange?: (checked: boolean) => void
9
+ label?: string
10
+ disabled?: boolean
11
+ style?: ViewStyle
12
+ }
13
+
14
+ export function Checkbox({ checked = false, onCheckedChange, label, disabled, style }: CheckboxProps) {
15
+ const { colors } = useTheme()
16
+
17
+ return (
18
+ <TouchableOpacity
19
+ style={[styles.row, style]}
20
+ onPress={() => { Haptics.selectionAsync(); onCheckedChange?.(!checked) }}
21
+ disabled={disabled}
22
+ activeOpacity={0.7}
23
+ >
24
+ <View
25
+ style={[
26
+ styles.box,
27
+ {
28
+ borderColor: checked ? colors.primary : colors.border,
29
+ backgroundColor: checked ? colors.primary : 'transparent',
30
+ opacity: disabled ? 0.45 : 1,
31
+ },
32
+ ]}
33
+ >
34
+ {checked ? <View style={[styles.checkmark, { borderColor: colors.primaryForeground }]} /> : null}
35
+ </View>
36
+ {label ? (
37
+ <Text style={[styles.label, { color: disabled ? colors.mutedForeground : colors.foreground }]}>
38
+ {label}
39
+ </Text>
40
+ ) : null}
41
+ </TouchableOpacity>
42
+ )
43
+ }
44
+
45
+ const styles = StyleSheet.create({
46
+ row: {
47
+ flexDirection: 'row',
48
+ alignItems: 'center',
49
+ gap: 10,
50
+ },
51
+ box: {
52
+ width: 24,
53
+ height: 24,
54
+ borderRadius: 6,
55
+ borderWidth: 1.5,
56
+ alignItems: 'center',
57
+ justifyContent: 'center',
58
+ },
59
+ checkmark: {
60
+ width: 13,
61
+ height: 8,
62
+ borderLeftWidth: 2,
63
+ borderBottomWidth: 2,
64
+ transform: [{ rotate: '-45deg' }, { translateY: -1 }],
65
+ },
66
+ label: {
67
+ fontSize: 14,
68
+ lineHeight: 20,
69
+ },
70
+ })
@@ -0,0 +1,2 @@
1
+ export { Checkbox } from './Checkbox'
2
+ export type { CheckboxProps } from './Checkbox'
@@ -0,0 +1,69 @@
1
+ import React from 'react'
2
+ import { View, Text, StyleSheet, ViewStyle } from 'react-native'
3
+ import { useTheme } from '../../theme'
4
+
5
+ export interface EmptyStateProps {
6
+ icon?: React.ReactNode
7
+ title: string
8
+ description?: string
9
+ action?: React.ReactNode
10
+ style?: ViewStyle
11
+ }
12
+
13
+ export function EmptyState({ icon, title, description, action, style }: EmptyStateProps) {
14
+ const { colors } = useTheme()
15
+
16
+ return (
17
+ <View style={[styles.container, { borderColor: colors.border }, style]}>
18
+ {icon ? (
19
+ <View style={[styles.iconWrapper, { backgroundColor: colors.muted }]}>
20
+ {icon}
21
+ </View>
22
+ ) : null}
23
+ <View style={styles.textWrapper}>
24
+ <Text style={[styles.title, { color: colors.foreground }]}>{title}</Text>
25
+ {description ? (
26
+ <Text style={[styles.description, { color: colors.mutedForeground }]}>{description}</Text>
27
+ ) : null}
28
+ </View>
29
+ {action ? <View style={styles.action}>{action}</View> : null}
30
+ </View>
31
+ )
32
+ }
33
+
34
+ const styles = StyleSheet.create({
35
+ container: {
36
+ alignItems: 'center',
37
+ justifyContent: 'center',
38
+ borderWidth: 1,
39
+ borderStyle: 'dashed',
40
+ borderRadius: 12,
41
+ padding: 32,
42
+ gap: 16,
43
+ },
44
+ iconWrapper: {
45
+ width: 48,
46
+ height: 48,
47
+ borderRadius: 12,
48
+ alignItems: 'center',
49
+ justifyContent: 'center',
50
+ },
51
+ textWrapper: {
52
+ alignItems: 'center',
53
+ gap: 8,
54
+ maxWidth: 320,
55
+ },
56
+ title: {
57
+ fontSize: 18,
58
+ fontWeight: '500',
59
+ textAlign: 'center',
60
+ },
61
+ description: {
62
+ fontSize: 14,
63
+ lineHeight: 20,
64
+ textAlign: 'center',
65
+ },
66
+ action: {
67
+ marginTop: 8,
68
+ },
69
+ })
@@ -0,0 +1,2 @@
1
+ export { EmptyState } from './EmptyState'
2
+ export type { EmptyStateProps } from './EmptyState'
@@ -1,11 +1,6 @@
1
1
  import React, { useState } from 'react'
2
- import {
3
- TextInput,
4
- View,
5
- Text,
6
- StyleSheet,
7
- TextInputProps,
8
- } from 'react-native'
2
+ import { TextInput, View, Text, StyleSheet, TextInputProps } from 'react-native'
3
+ import { useTheme } from '../../theme'
9
4
 
10
5
  export interface InputProps extends TextInputProps {
11
6
  label?: string
@@ -14,31 +9,36 @@ export interface InputProps extends TextInputProps {
14
9
  }
15
10
 
16
11
  export function Input({ label, error, hint, style, onFocus, onBlur, ...props }: InputProps) {
12
+ const { colors } = useTheme()
17
13
  const [focused, setFocused] = useState(false)
18
14
 
19
15
  return (
20
16
  <View style={styles.container}>
21
- {label ? <Text style={styles.label}>{label}</Text> : null}
17
+ {label ? (
18
+ <Text style={[styles.label, { color: colors.foreground }]}>{label}</Text>
19
+ ) : null}
22
20
  <TextInput
23
21
  style={[
24
22
  styles.input,
25
- focused && styles.inputFocused,
26
- error ? styles.inputError : undefined,
23
+ {
24
+ borderColor: error ? colors.destructive : focused ? colors.ring : colors.border,
25
+ color: colors.foreground,
26
+ backgroundColor: colors.background,
27
+ },
27
28
  style,
28
29
  ]}
29
- onFocus={(e) => {
30
- setFocused(true)
31
- onFocus?.(e)
32
- }}
33
- onBlur={(e) => {
34
- setFocused(false)
35
- onBlur?.(e)
36
- }}
37
- placeholderTextColor="#9CA3AF"
30
+ onFocus={(e) => { setFocused(true); onFocus?.(e) }}
31
+ onBlur={(e) => { setFocused(false); onBlur?.(e) }}
32
+ placeholderTextColor={colors.mutedForeground}
33
+ allowFontScaling={true}
38
34
  {...props}
39
35
  />
40
- {error ? <Text style={styles.errorText}>{error}</Text> : null}
41
- {!error && hint ? <Text style={styles.hintText}>{hint}</Text> : null}
36
+ {error ? (
37
+ <Text style={[styles.helperText, { color: colors.destructive }]}>{error}</Text>
38
+ ) : null}
39
+ {!error && hint ? (
40
+ <Text style={[styles.helperText, { color: colors.mutedForeground }]}>{hint}</Text>
41
+ ) : null}
42
42
  </View>
43
43
  )
44
44
  }
@@ -50,31 +50,16 @@ const styles = StyleSheet.create({
50
50
  label: {
51
51
  fontSize: 14,
52
52
  fontWeight: '500',
53
- color: '#111827',
54
- marginBottom: 2,
53
+ marginBottom: 4,
55
54
  },
56
55
  input: {
57
56
  borderWidth: 1.5,
58
- borderColor: '#D1D5DB',
59
57
  borderRadius: 8,
60
- paddingHorizontal: 12,
61
- paddingVertical: 10,
62
- fontSize: 15,
63
- color: '#111827',
64
- backgroundColor: '#fff',
58
+ paddingHorizontal: 16,
59
+ paddingVertical: 14,
60
+ fontSize: 16,
65
61
  },
66
- inputFocused: {
67
- borderColor: '#000',
68
- },
69
- inputError: {
70
- borderColor: '#EF4444',
71
- },
72
- errorText: {
73
- fontSize: 12,
74
- color: '#EF4444',
75
- },
76
- hintText: {
62
+ helperText: {
77
63
  fontSize: 12,
78
- color: '#6B7280',
79
64
  },
80
65
  })
@@ -0,0 +1,53 @@
1
+ import React, { useRef, useState, useEffect } from 'react'
2
+ import { View, Animated, StyleSheet, ViewStyle } from 'react-native'
3
+ import { useTheme } from '../../theme'
4
+
5
+ export interface ProgressProps {
6
+ value?: number
7
+ max?: number
8
+ style?: ViewStyle
9
+ }
10
+
11
+ export function Progress({ value = 0, max = 100, style }: ProgressProps) {
12
+ const { colors } = useTheme()
13
+ const percent = Math.min(Math.max((value / max) * 100, 0), 100)
14
+ const [trackWidth, setTrackWidth] = useState(0)
15
+ const animatedWidth = useRef(new Animated.Value(0)).current
16
+
17
+ useEffect(() => {
18
+ if (trackWidth === 0) return
19
+ Animated.spring(animatedWidth, {
20
+ toValue: (percent / 100) * trackWidth,
21
+ useNativeDriver: false,
22
+ speed: 20,
23
+ bounciness: 0,
24
+ }).start()
25
+ }, [percent, trackWidth])
26
+
27
+ return (
28
+ <View
29
+ style={[styles.track, { backgroundColor: colors.muted }, style]}
30
+ onLayout={(e) => setTrackWidth(e.nativeEvent.layout.width)}
31
+ >
32
+ <Animated.View
33
+ style={[
34
+ styles.indicator,
35
+ { width: animatedWidth, backgroundColor: colors.primary },
36
+ ]}
37
+ />
38
+ </View>
39
+ )
40
+ }
41
+
42
+ const styles = StyleSheet.create({
43
+ track: {
44
+ height: 8,
45
+ borderRadius: 999,
46
+ overflow: 'hidden',
47
+ width: '100%',
48
+ },
49
+ indicator: {
50
+ height: '100%',
51
+ borderRadius: 999,
52
+ },
53
+ })
@@ -0,0 +1,2 @@
1
+ export { Progress } from './Progress'
2
+ export type { ProgressProps } from './Progress'
@@ -0,0 +1,105 @@
1
+ import React from 'react'
2
+ import { TouchableOpacity, View, Text, StyleSheet, ViewStyle } from 'react-native'
3
+ import * as Haptics from 'expo-haptics'
4
+ import { useTheme } from '../../theme'
5
+
6
+ export interface RadioOption {
7
+ label: string
8
+ value: string
9
+ disabled?: boolean
10
+ }
11
+
12
+ export interface RadioGroupProps {
13
+ options: RadioOption[]
14
+ value?: string
15
+ onValueChange?: (value: string) => void
16
+ orientation?: 'vertical' | 'horizontal'
17
+ style?: ViewStyle
18
+ }
19
+
20
+ export function RadioGroup({
21
+ options,
22
+ value,
23
+ onValueChange,
24
+ orientation = 'vertical',
25
+ style,
26
+ }: RadioGroupProps) {
27
+ const { colors } = useTheme()
28
+
29
+ return (
30
+ <View
31
+ style={[
32
+ styles.container,
33
+ orientation === 'horizontal' && styles.horizontal,
34
+ style,
35
+ ]}
36
+ >
37
+ {options.map((option) => {
38
+ const selected = option.value === value
39
+ return (
40
+ <TouchableOpacity
41
+ key={option.value}
42
+ style={styles.row}
43
+ onPress={() => { if (!option.disabled) { Haptics.selectionAsync(); onValueChange?.(option.value) } }}
44
+ activeOpacity={0.7}
45
+ disabled={option.disabled}
46
+ >
47
+ <View
48
+ style={[
49
+ styles.radio,
50
+ {
51
+ borderColor: selected ? colors.primary : colors.border,
52
+ opacity: option.disabled ? 0.45 : 1,
53
+ },
54
+ ]}
55
+ >
56
+ {selected ? (
57
+ <View style={[styles.dot, { backgroundColor: colors.primary }]} />
58
+ ) : null}
59
+ </View>
60
+ <Text
61
+ style={[
62
+ styles.label,
63
+ { color: option.disabled ? colors.mutedForeground : colors.foreground },
64
+ ]}
65
+ >
66
+ {option.label}
67
+ </Text>
68
+ </TouchableOpacity>
69
+ )
70
+ })}
71
+ </View>
72
+ )
73
+ }
74
+
75
+ const styles = StyleSheet.create({
76
+ container: {
77
+ gap: 10,
78
+ },
79
+ horizontal: {
80
+ flexDirection: 'row',
81
+ flexWrap: 'wrap',
82
+ },
83
+ row: {
84
+ flexDirection: 'row',
85
+ alignItems: 'center',
86
+ gap: 10,
87
+ },
88
+ radio: {
89
+ width: 24,
90
+ height: 24,
91
+ borderRadius: 12,
92
+ borderWidth: 1.5,
93
+ alignItems: 'center',
94
+ justifyContent: 'center',
95
+ },
96
+ dot: {
97
+ width: 10,
98
+ height: 10,
99
+ borderRadius: 5,
100
+ },
101
+ label: {
102
+ fontSize: 14,
103
+ lineHeight: 20,
104
+ },
105
+ })
@@ -0,0 +1,2 @@
1
+ export { RadioGroup } from './RadioGroup'
2
+ export type { RadioGroupProps, RadioOption } from './RadioGroup'
@@ -0,0 +1,185 @@
1
+ import React, { useState } from 'react'
2
+ import {
3
+ Modal,
4
+ View,
5
+ Text,
6
+ TouchableOpacity,
7
+ FlatList,
8
+ StyleSheet,
9
+ ViewStyle,
10
+ } from 'react-native'
11
+ import * as Haptics from 'expo-haptics'
12
+ import { useTheme } from '../../theme'
13
+
14
+ export interface SelectOption {
15
+ label: string
16
+ value: string
17
+ disabled?: boolean
18
+ }
19
+
20
+ export interface SelectProps {
21
+ options: SelectOption[]
22
+ value?: string
23
+ onValueChange?: (value: string) => void
24
+ placeholder?: string
25
+ label?: string
26
+ error?: string
27
+ disabled?: boolean
28
+ style?: ViewStyle
29
+ }
30
+
31
+ export function Select({
32
+ options,
33
+ value,
34
+ onValueChange,
35
+ placeholder = 'Select an option',
36
+ label,
37
+ error,
38
+ disabled,
39
+ style,
40
+ }: SelectProps) {
41
+ const { colors } = useTheme()
42
+ const [open, setOpen] = useState(false)
43
+
44
+ const selected = options.find((o) => o.value === value)
45
+
46
+ return (
47
+ <View style={[styles.container, style]}>
48
+ {label ? (
49
+ <Text style={[styles.label, { color: colors.foreground }]}>{label}</Text>
50
+ ) : null}
51
+
52
+ <TouchableOpacity
53
+ style={[
54
+ styles.trigger,
55
+ {
56
+ borderColor: error ? colors.destructive : colors.border,
57
+ backgroundColor: colors.background,
58
+ opacity: disabled ? 0.45 : 1,
59
+ },
60
+ ]}
61
+ onPress={() => { if (!disabled) { Haptics.selectionAsync(); setOpen(true) } }}
62
+ activeOpacity={0.7}
63
+ >
64
+ <Text
65
+ style={[
66
+ styles.triggerText,
67
+ { color: selected ? colors.foreground : colors.mutedForeground },
68
+ ]}
69
+ numberOfLines={1}
70
+ >
71
+ {selected?.label ?? placeholder}
72
+ </Text>
73
+ <Text style={[styles.chevron, { color: colors.mutedForeground }]}>▾</Text>
74
+ </TouchableOpacity>
75
+
76
+ {error ? (
77
+ <Text style={[styles.helperText, { color: colors.destructive }]}>{error}</Text>
78
+ ) : null}
79
+
80
+ <Modal transparent visible={open} onRequestClose={() => setOpen(false)} animationType="fade">
81
+ <TouchableOpacity style={styles.overlay} onPress={() => setOpen(false)} activeOpacity={1}>
82
+ <View style={[styles.list, { backgroundColor: colors.card, borderColor: colors.border }]}>
83
+ <FlatList
84
+ data={options}
85
+ keyExtractor={(item) => item.value}
86
+ renderItem={({ item }) => {
87
+ const isSelected = item.value === value
88
+ return (
89
+ <TouchableOpacity
90
+ style={[
91
+ styles.option,
92
+ isSelected && { backgroundColor: colors.accent },
93
+ item.disabled && styles.disabledOption,
94
+ ]}
95
+ onPress={() => {
96
+ if (!item.disabled) {
97
+ Haptics.selectionAsync()
98
+ onValueChange?.(item.value)
99
+ setOpen(false)
100
+ }
101
+ }}
102
+ activeOpacity={0.7}
103
+ >
104
+ <Text
105
+ style={[
106
+ styles.optionText,
107
+ { color: item.disabled ? colors.mutedForeground : colors.foreground },
108
+ isSelected && { fontWeight: '500' },
109
+ ]}
110
+ >
111
+ {item.label}
112
+ </Text>
113
+ {isSelected ? (
114
+ <Text style={[styles.checkmark, { color: colors.primary }]}>✓</Text>
115
+ ) : null}
116
+ </TouchableOpacity>
117
+ )
118
+ }}
119
+ />
120
+ </View>
121
+ </TouchableOpacity>
122
+ </Modal>
123
+ </View>
124
+ )
125
+ }
126
+
127
+ const styles = StyleSheet.create({
128
+ container: {
129
+ gap: 4,
130
+ },
131
+ label: {
132
+ fontSize: 14,
133
+ fontWeight: '500',
134
+ marginBottom: 2,
135
+ },
136
+ trigger: {
137
+ flexDirection: 'row',
138
+ alignItems: 'center',
139
+ justifyContent: 'space-between',
140
+ borderWidth: 1.5,
141
+ borderRadius: 8,
142
+ paddingHorizontal: 16,
143
+ paddingVertical: 14,
144
+ },
145
+ triggerText: {
146
+ fontSize: 16,
147
+ flex: 1,
148
+ },
149
+ chevron: {
150
+ fontSize: 14,
151
+ marginLeft: 8,
152
+ },
153
+ helperText: {
154
+ fontSize: 12,
155
+ },
156
+ overlay: {
157
+ flex: 1,
158
+ backgroundColor: 'rgba(0,0,0,0.3)',
159
+ justifyContent: 'center',
160
+ padding: 24,
161
+ },
162
+ list: {
163
+ borderRadius: 12,
164
+ borderWidth: 1,
165
+ maxHeight: 300,
166
+ overflow: 'hidden',
167
+ },
168
+ option: {
169
+ flexDirection: 'row',
170
+ alignItems: 'center',
171
+ justifyContent: 'space-between',
172
+ paddingHorizontal: 12,
173
+ paddingVertical: 10,
174
+ },
175
+ optionText: {
176
+ fontSize: 15,
177
+ },
178
+ disabledOption: {
179
+ opacity: 0.45,
180
+ },
181
+ checkmark: {
182
+ fontSize: 14,
183
+ fontWeight: '600',
184
+ },
185
+ })
@@ -0,0 +1,2 @@
1
+ export { Select } from './Select'
2
+ export type { SelectProps, SelectOption } from './Select'
@@ -0,0 +1,33 @@
1
+ import React from 'react'
2
+ import { View, StyleSheet, ViewStyle } from 'react-native'
3
+ import { useTheme } from '../../theme'
4
+
5
+ export interface SeparatorProps {
6
+ orientation?: 'horizontal' | 'vertical'
7
+ style?: ViewStyle
8
+ }
9
+
10
+ export function Separator({ orientation = 'horizontal', style }: SeparatorProps) {
11
+ const { colors } = useTheme()
12
+
13
+ return (
14
+ <View
15
+ style={[
16
+ orientation === 'horizontal' ? styles.horizontal : styles.vertical,
17
+ { backgroundColor: colors.border },
18
+ style,
19
+ ]}
20
+ />
21
+ )
22
+ }
23
+
24
+ const styles = StyleSheet.create({
25
+ horizontal: {
26
+ height: 1,
27
+ width: '100%',
28
+ },
29
+ vertical: {
30
+ width: 1,
31
+ height: '100%',
32
+ },
33
+ })
@@ -0,0 +1,2 @@
1
+ export { Separator } from './Separator'
2
+ export type { SeparatorProps } from './Separator'