@retray-dev/ui-kit 2.3.0 → 2.5.1
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.
- package/COMPONENTS.md +80 -26
- package/README.md +3 -5
- package/dist/index.d.mts +35 -3
- package/dist/index.d.ts +35 -3
- package/dist/index.js +204 -143
- package/dist/index.mjs +204 -143
- package/package.json +4 -2
- package/src/components/Accordion/Accordion.tsx +4 -6
- package/src/components/AlertBanner/AlertBanner.tsx +16 -14
- package/src/components/Badge/Badge.tsx +1 -1
- package/src/components/Button/Button.tsx +4 -4
- package/src/components/Card/Card.tsx +8 -13
- package/src/components/Checkbox/Checkbox.tsx +4 -4
- package/src/components/Input/Input.tsx +6 -6
- package/src/components/ListItem/ListItem.tsx +157 -21
- package/src/components/MonthPicker/MonthPicker.tsx +3 -6
- package/src/components/RadioGroup/RadioGroup.tsx +2 -2
- package/src/components/Select/Select.tsx +17 -13
- package/src/components/Textarea/Textarea.tsx +4 -5
- package/src/components/Toast/Toast.tsx +23 -18
- package/src/components/Toggle/Toggle.tsx +29 -49
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { createContext, useContext, useState, useCallback, useEffect } from 'react'
|
|
2
|
-
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native'
|
|
2
|
+
import { View, Text, TouchableOpacity, StyleSheet, Platform } from 'react-native'
|
|
3
|
+
import { FontAwesome5, MaterialIcons, Entypo, AntDesign } from '@expo/vector-icons'
|
|
3
4
|
import Animated, {
|
|
4
5
|
useSharedValue,
|
|
5
6
|
useAnimatedStyle,
|
|
@@ -98,11 +99,16 @@ function ToastNotification({ item, onDismiss }: { item: ToastItem; onDismiss: ()
|
|
|
98
99
|
success: colors.successForeground,
|
|
99
100
|
}[item.variant ?? 'default']
|
|
100
101
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
const defaultIcon =
|
|
103
|
+
item.variant === 'success' ? (
|
|
104
|
+
<FontAwesome5 name="check-circle" size={22} color={textColor} />
|
|
105
|
+
) : item.variant === 'destructive' ? (
|
|
106
|
+
<MaterialIcons name="error-outline" size={24} color={textColor} />
|
|
107
|
+
) : (
|
|
108
|
+
<Entypo name="info-with-circle" size={22} color={textColor} />
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
const leftIcon = item.icon ?? defaultIcon
|
|
106
112
|
|
|
107
113
|
return (
|
|
108
114
|
<GestureDetector gesture={panGesture}>
|
|
@@ -113,13 +119,13 @@ function ToastNotification({ item, onDismiss }: { item: ToastItem; onDismiss: ()
|
|
|
113
119
|
<Text style={[styles.toastTitle, { color: textColor }]}>{item.title}</Text>
|
|
114
120
|
) : null}
|
|
115
121
|
{item.description ? (
|
|
116
|
-
<Text style={[styles.toastDescription, { color: textColor, opacity: 0.85 }]}>
|
|
122
|
+
<Text style={[styles.toastDescription, { color: textColor, opacity: 0.85 }]}>
|
|
117
123
|
{item.description}
|
|
118
124
|
</Text>
|
|
119
125
|
) : null}
|
|
120
126
|
</View>
|
|
121
127
|
<TouchableOpacity onPress={onDismiss} style={styles.dismissButton} touchSoundDisabled={true}>
|
|
122
|
-
<
|
|
128
|
+
<AntDesign name="close-circle" size={18} color={textColor} />
|
|
123
129
|
</TouchableOpacity>
|
|
124
130
|
</Animated.View>
|
|
125
131
|
</GestureDetector>
|
|
@@ -158,7 +164,7 @@ export function ToastProvider({ children }: ToastProviderProps) {
|
|
|
158
164
|
return (
|
|
159
165
|
<ToastContext.Provider value={{ toast, dismiss }}>
|
|
160
166
|
{children}
|
|
161
|
-
<View style={[styles.container, { top: insets.top + 8 }]} pointerEvents="box-none">
|
|
167
|
+
<View style={[styles.container, Platform.OS === 'web' && styles.containerWeb, { top: insets.top + 8 }]} pointerEvents="box-none">
|
|
162
168
|
{toasts.map((item) => (
|
|
163
169
|
<ToastNotification key={item.id} item={item} onDismiss={() => dismiss(item.id)} />
|
|
164
170
|
))}
|
|
@@ -175,6 +181,12 @@ const styles = StyleSheet.create({
|
|
|
175
181
|
gap: 8,
|
|
176
182
|
zIndex: 9999,
|
|
177
183
|
},
|
|
184
|
+
containerWeb: {
|
|
185
|
+
left: undefined,
|
|
186
|
+
right: undefined,
|
|
187
|
+
alignSelf: 'center',
|
|
188
|
+
width: 400,
|
|
189
|
+
},
|
|
178
190
|
toast: {
|
|
179
191
|
flexDirection: 'row',
|
|
180
192
|
alignItems: 'center',
|
|
@@ -192,15 +204,11 @@ const styles = StyleSheet.create({
|
|
|
192
204
|
gap: 4,
|
|
193
205
|
},
|
|
194
206
|
leftIconContainer: {
|
|
195
|
-
width:
|
|
207
|
+
width: 40,
|
|
196
208
|
alignItems: 'center',
|
|
197
209
|
justifyContent: 'center',
|
|
198
210
|
marginRight: 8,
|
|
199
211
|
},
|
|
200
|
-
defaultIcon: {
|
|
201
|
-
fontSize: 22,
|
|
202
|
-
fontWeight: '700',
|
|
203
|
-
},
|
|
204
212
|
toastTitle: {
|
|
205
213
|
fontSize: 15,
|
|
206
214
|
fontWeight: '600',
|
|
@@ -209,10 +217,7 @@ const styles = StyleSheet.create({
|
|
|
209
217
|
fontSize: 14,
|
|
210
218
|
},
|
|
211
219
|
dismissButton: {
|
|
212
|
-
padding:
|
|
220
|
+
padding: 8,
|
|
213
221
|
marginLeft: 4,
|
|
214
222
|
},
|
|
215
|
-
dismissIcon: {
|
|
216
|
-
fontSize: 14,
|
|
217
|
-
},
|
|
218
223
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useRef, useEffect } from 'react'
|
|
2
|
-
import { TouchableOpacity, Animated,
|
|
2
|
+
import { TouchableOpacity, Animated, StyleSheet, TouchableOpacityProps, ViewStyle, View, Easing } from 'react-native'
|
|
3
|
+
import { FontAwesome5 } from '@expo/vector-icons'
|
|
3
4
|
import * as Haptics from 'expo-haptics'
|
|
4
5
|
import { useTheme } from '../../theme'
|
|
5
6
|
|
|
@@ -86,50 +87,43 @@ export function Toggle({
|
|
|
86
87
|
if (pressed) {
|
|
87
88
|
const active = renderProp(activeIcon)
|
|
88
89
|
if (active) return <>{active}</>
|
|
89
|
-
return
|
|
90
|
-
<View style={[styles.checkContainer, { borderColor: colors.primary, backgroundColor: colors.primary }]}>
|
|
91
|
-
<Text style={[styles.checkMark, { color: colors.primaryForeground }]}>✓</Text>
|
|
92
|
-
</View>
|
|
93
|
-
)
|
|
90
|
+
return <FontAwesome5 name="check-circle" size={20} color={colors.primary} />
|
|
94
91
|
}
|
|
95
92
|
|
|
96
93
|
const custom = renderProp(icon)
|
|
97
94
|
if (custom) return <>{custom}</>
|
|
98
95
|
|
|
99
96
|
// Default: empty circle to signal an action is available
|
|
100
|
-
return
|
|
101
|
-
<View style={[styles.checkContainer, { borderColor: colors.mutedForeground }]} />
|
|
102
|
-
)
|
|
97
|
+
return <FontAwesome5 name="circle" size={20} color={colors.mutedForeground} />
|
|
103
98
|
}
|
|
104
99
|
|
|
105
100
|
return (
|
|
106
|
-
<Animated.View style={{ transform: [{ scale }] }}>
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
101
|
+
<Animated.View style={[{ transform: [{ scale }] }, disabled && styles.disabled, style]}>
|
|
102
|
+
<TouchableOpacity
|
|
103
|
+
onPress={() => {
|
|
104
|
+
Haptics.selectionAsync()
|
|
105
|
+
onPressedChange?.(!pressed)
|
|
106
|
+
}}
|
|
107
|
+
onPressIn={handlePressIn}
|
|
108
|
+
onPressOut={handlePressOut}
|
|
109
|
+
disabled={disabled}
|
|
110
|
+
activeOpacity={1}
|
|
111
|
+
touchSoundDisabled={true}
|
|
112
|
+
{...props}
|
|
115
113
|
>
|
|
116
|
-
<
|
|
117
|
-
style={
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
onPressIn={handlePressIn}
|
|
123
|
-
onPressOut={handlePressOut}
|
|
124
|
-
disabled={disabled}
|
|
125
|
-
activeOpacity={1}
|
|
126
|
-
touchSoundDisabled={true}
|
|
127
|
-
{...props}
|
|
114
|
+
<Animated.View
|
|
115
|
+
style={[
|
|
116
|
+
styles.base,
|
|
117
|
+
sizeStyles[size],
|
|
118
|
+
{ borderColor, backgroundColor, borderWidth: 2 },
|
|
119
|
+
]}
|
|
128
120
|
>
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
121
|
+
<View style={styles.inner}>
|
|
122
|
+
<LeftIcon />
|
|
123
|
+
{label ? <Animated.Text style={[styles.label, { color: textColor }]}>{label}</Animated.Text> : null}
|
|
124
|
+
</View>
|
|
125
|
+
</Animated.View>
|
|
126
|
+
</TouchableOpacity>
|
|
133
127
|
</Animated.View>
|
|
134
128
|
)
|
|
135
129
|
}
|
|
@@ -137,14 +131,12 @@ export function Toggle({
|
|
|
137
131
|
const styles = StyleSheet.create({
|
|
138
132
|
base: {
|
|
139
133
|
borderRadius: 8,
|
|
140
|
-
overflow: 'hidden',
|
|
141
134
|
},
|
|
142
|
-
|
|
135
|
+
inner: {
|
|
143
136
|
flexDirection: 'row',
|
|
144
137
|
alignItems: 'center',
|
|
145
138
|
justifyContent: 'center',
|
|
146
139
|
gap: 8,
|
|
147
|
-
flex: 1,
|
|
148
140
|
},
|
|
149
141
|
disabled: {
|
|
150
142
|
opacity: 0.45,
|
|
@@ -153,16 +145,4 @@ const styles = StyleSheet.create({
|
|
|
153
145
|
fontSize: 14,
|
|
154
146
|
fontWeight: '500',
|
|
155
147
|
},
|
|
156
|
-
checkContainer: {
|
|
157
|
-
width: 24,
|
|
158
|
-
height: 24,
|
|
159
|
-
borderRadius: 12,
|
|
160
|
-
borderWidth: 2,
|
|
161
|
-
alignItems: 'center',
|
|
162
|
-
justifyContent: 'center',
|
|
163
|
-
},
|
|
164
|
-
checkMark: {
|
|
165
|
-
fontSize: 14,
|
|
166
|
-
fontWeight: '700',
|
|
167
|
-
},
|
|
168
148
|
})
|