@retray-dev/ui-kit 10.0.0 → 10.1.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.
- package/COMPONENTS.md +15 -13
- package/CONSUMER.md +1 -1
- package/dist/Accordion.d.mts +1 -1
- package/dist/Accordion.d.ts +1 -1
- package/dist/Accordion.js +2 -2
- package/dist/Accordion.mjs +1 -1
- package/dist/ConfirmDialog.d.mts +6 -1
- package/dist/ConfirmDialog.d.ts +6 -1
- package/dist/ConfirmDialog.js +44 -14
- package/dist/ConfirmDialog.mjs +1 -1
- package/dist/ImageViewer.js +282 -141
- package/dist/ImageViewer.mjs +3 -1
- package/dist/Sheet.js +16 -13
- package/dist/Sheet.mjs +1 -1
- package/dist/Switch.js +40 -17
- package/dist/Switch.mjs +1 -1
- package/dist/{chunk-O3HA6TYM.mjs → chunk-DJ7RN37L.mjs} +2 -2
- package/dist/{chunk-FZZLPJ6B.mjs → chunk-KZL5VTYK.mjs} +43 -14
- package/dist/{chunk-QKH5ZOD5.mjs → chunk-WF2XDFRK.mjs} +40 -17
- package/dist/{chunk-Z4BVUWW6.mjs → chunk-WOEYDUJZ.mjs} +19 -31
- package/dist/{chunk-PFZTM6D5.mjs → chunk-Y2NS74WS.mjs} +9 -7
- package/dist/index.js +119 -76
- package/dist/index.mjs +5 -5
- package/package.json +1 -1
- package/src/components/Accordion/Accordion.tsx +7 -3
- package/src/components/ConfirmDialog/ConfirmDialog.tsx +61 -23
- package/src/components/ImageViewer/ImageViewer.tsx +25 -30
- package/src/components/Sheet/Sheet.tsx +10 -9
- package/src/components/Switch/Switch.tsx +30 -17
|
@@ -2,7 +2,8 @@ import React, { useState, useCallback } from 'react'
|
|
|
2
2
|
import {
|
|
3
3
|
Modal,
|
|
4
4
|
View,
|
|
5
|
-
|
|
5
|
+
Image,
|
|
6
|
+
Dimensions,
|
|
6
7
|
StyleSheet,
|
|
7
8
|
useWindowDimensions,
|
|
8
9
|
ImageSourcePropType,
|
|
@@ -18,7 +19,7 @@ import Animated, {
|
|
|
18
19
|
runOnJS,
|
|
19
20
|
} from 'react-native-reanimated'
|
|
20
21
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
21
|
-
import {
|
|
22
|
+
import { IconButton } from '../IconButton'
|
|
22
23
|
import { PagerDots } from '../PagerDots'
|
|
23
24
|
import { s, vs } from '../../utils/scaling'
|
|
24
25
|
|
|
@@ -102,13 +103,11 @@ function ZoomableImage({ source, width, height, onZoomChange }: ZoomableImagePro
|
|
|
102
103
|
|
|
103
104
|
return (
|
|
104
105
|
<GestureDetector gesture={composed}>
|
|
105
|
-
<
|
|
106
|
-
<Animated.
|
|
107
|
-
source={source}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
/>
|
|
111
|
-
</Animated.View>
|
|
106
|
+
<View style={[{ width, height }, styles.imageWrap]} collapsable={false}>
|
|
107
|
+
<Animated.View style={[{ width, height }, animatedStyle]}>
|
|
108
|
+
<Image source={source} style={{ width, height }} resizeMode="contain" />
|
|
109
|
+
</Animated.View>
|
|
110
|
+
</View>
|
|
112
111
|
</GestureDetector>
|
|
113
112
|
)
|
|
114
113
|
}
|
|
@@ -132,7 +131,9 @@ export interface ImageViewerProps {
|
|
|
132
131
|
* <ImageViewer images={pages} visible={open} initialIndex={page} onClose={() => setOpen(false)} />
|
|
133
132
|
*/
|
|
134
133
|
export function ImageViewer({ images, visible, onClose, initialIndex = 0 }: ImageViewerProps) {
|
|
135
|
-
const
|
|
134
|
+
const window = useWindowDimensions()
|
|
135
|
+
const width = window.width > 0 ? window.width : Dimensions.get('window').width
|
|
136
|
+
const height = window.height > 0 ? window.height : Dimensions.get('window').height
|
|
136
137
|
const insets = useSafeAreaInsets()
|
|
137
138
|
const [index, setIndex] = useState(initialIndex)
|
|
138
139
|
const [pagingEnabled, setPagingEnabled] = useState(true)
|
|
@@ -203,7 +204,7 @@ export function ImageViewer({ images, visible, onClose, initialIndex = 0 }: Imag
|
|
|
203
204
|
<Animated.View style={[styles.backdrop, backdropStyle]} pointerEvents="none" />
|
|
204
205
|
<Animated.View style={[styles.container, dismissStyle]}>
|
|
205
206
|
<GestureDetector gesture={swipeDown}>
|
|
206
|
-
<
|
|
207
|
+
<View style={styles.root} collapsable={false}>
|
|
207
208
|
<ScrollView
|
|
208
209
|
ref={scrollRef}
|
|
209
210
|
horizontal
|
|
@@ -223,20 +224,20 @@ export function ImageViewer({ images, visible, onClose, initialIndex = 0 }: Imag
|
|
|
223
224
|
/>
|
|
224
225
|
))}
|
|
225
226
|
</ScrollView>
|
|
226
|
-
</
|
|
227
|
+
</View>
|
|
227
228
|
</GestureDetector>
|
|
228
229
|
|
|
229
|
-
<
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
</
|
|
230
|
+
<View style={[styles.closeButtonWrapper, { top: insets.top + vs(8) }]}>
|
|
231
|
+
<IconButton
|
|
232
|
+
iconName="x"
|
|
233
|
+
size="md"
|
|
234
|
+
variant="text"
|
|
235
|
+
style={{ backgroundColor: 'rgba(255,255,255,0.18)' }}
|
|
236
|
+
iconColor="#fff"
|
|
237
|
+
onPress={onClose}
|
|
238
|
+
accessibilityLabel="Close"
|
|
239
|
+
/>
|
|
240
|
+
</View>
|
|
240
241
|
|
|
241
242
|
{images.length > 1 ? (
|
|
242
243
|
<View style={[styles.dots, { bottom: insets.bottom + vs(16) }]} pointerEvents="box-none">
|
|
@@ -271,15 +272,9 @@ const styles = StyleSheet.create({
|
|
|
271
272
|
justifyContent: 'center',
|
|
272
273
|
overflow: 'hidden',
|
|
273
274
|
},
|
|
274
|
-
|
|
275
|
+
closeButtonWrapper: {
|
|
275
276
|
position: 'absolute',
|
|
276
277
|
right: s(12),
|
|
277
|
-
width: s(40),
|
|
278
|
-
height: s(40),
|
|
279
|
-
borderRadius: s(20),
|
|
280
|
-
backgroundColor: 'rgba(0,0,0,0.4)',
|
|
281
|
-
alignItems: 'center',
|
|
282
|
-
justifyContent: 'center',
|
|
283
278
|
},
|
|
284
279
|
dots: {
|
|
285
280
|
position: 'absolute',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef } from 'react'
|
|
2
2
|
import { View, Text, TouchableOpacity, StyleSheet, ViewStyle, Dimensions, Platform, Modal, ScrollView, useWindowDimensions, Pressable } from 'react-native'
|
|
3
|
-
import {
|
|
4
|
-
BottomSheetModal,
|
|
3
|
+
import BottomSheet, {
|
|
5
4
|
BottomSheetView,
|
|
6
5
|
BottomSheetScrollView,
|
|
7
6
|
BottomSheetBackdrop,
|
|
@@ -149,7 +148,7 @@ export function Sheet({
|
|
|
149
148
|
const { colors } = useTheme()
|
|
150
149
|
const insets = useSafeAreaInsets()
|
|
151
150
|
const { width: windowWidth } = useWindowDimensions()
|
|
152
|
-
const ref = useRef<
|
|
151
|
+
const ref = useRef<BottomSheet>(null)
|
|
153
152
|
const asDialog = responsive && windowWidth >= BREAKPOINTS.wide
|
|
154
153
|
|
|
155
154
|
// 'interactive' + 'adjustPan' works properly with enableDynamicSizing on both platforms
|
|
@@ -159,9 +158,9 @@ export function Sheet({
|
|
|
159
158
|
useEffect(() => {
|
|
160
159
|
if (open) {
|
|
161
160
|
impactMedium()
|
|
162
|
-
ref.current?.
|
|
161
|
+
ref.current?.snapToIndex(0)
|
|
163
162
|
} else {
|
|
164
|
-
ref.current?.
|
|
163
|
+
ref.current?.close()
|
|
165
164
|
}
|
|
166
165
|
}, [open])
|
|
167
166
|
|
|
@@ -193,7 +192,7 @@ export function Sheet({
|
|
|
193
192
|
const showHeader = !!(title || effectiveSubtitle || showCloseButton) && !customHeader
|
|
194
193
|
|
|
195
194
|
const headerNode = customHeader ? customHeader : (showHeader ? (
|
|
196
|
-
<View style={styles.header} accessibilityRole="header">
|
|
195
|
+
<View style={[styles.header, { backgroundColor: colors.card }]} accessibilityRole="header">
|
|
197
196
|
<View style={styles.headerRow}>
|
|
198
197
|
{title ? (
|
|
199
198
|
<Text style={[styles.title, { color: colors.foreground }]} allowFontScaling={true}>
|
|
@@ -270,12 +269,13 @@ export function Sheet({
|
|
|
270
269
|
const useDynamicSizing = !snapPoints
|
|
271
270
|
|
|
272
271
|
return (
|
|
273
|
-
<
|
|
272
|
+
<BottomSheet
|
|
274
273
|
ref={ref}
|
|
274
|
+
index={-1}
|
|
275
|
+
onClose={onClose}
|
|
275
276
|
enableDynamicSizing={useDynamicSizing}
|
|
276
277
|
snapPoints={snapPoints}
|
|
277
278
|
maxDynamicContentSize={useDynamicSizing ? effectiveMaxHeight : undefined}
|
|
278
|
-
onDismiss={onClose}
|
|
279
279
|
backdropComponent={renderBackdrop}
|
|
280
280
|
footerComponent={effectiveFooter ? renderFooter : undefined}
|
|
281
281
|
backgroundStyle={[styles.background, { backgroundColor: colors.card }]}
|
|
@@ -297,6 +297,7 @@ export function Sheet({
|
|
|
297
297
|
showsVerticalScrollIndicator={true}
|
|
298
298
|
indicatorStyle="black"
|
|
299
299
|
persistentScrollbar={isAndroid}
|
|
300
|
+
stickyHeaderIndices={headerNode ? [0] : undefined}
|
|
300
301
|
>
|
|
301
302
|
{headerNode}
|
|
302
303
|
{contentNode}
|
|
@@ -307,7 +308,7 @@ export function Sheet({
|
|
|
307
308
|
{contentNode}
|
|
308
309
|
</BottomSheetView>
|
|
309
310
|
)}
|
|
310
|
-
</
|
|
311
|
+
</BottomSheet>
|
|
311
312
|
)
|
|
312
313
|
}
|
|
313
314
|
|
|
@@ -14,6 +14,8 @@ const THUMB_OFFSET = s(3)
|
|
|
14
14
|
const THUMB_TRAVEL = TRACK_WIDTH - THUMB_SIZE - THUMB_OFFSET * 2
|
|
15
15
|
const ICON_SIZE = s(13)
|
|
16
16
|
|
|
17
|
+
const DISABLED_OPACITY = 0.45
|
|
18
|
+
|
|
17
19
|
export interface SwitchProps {
|
|
18
20
|
checked?: boolean
|
|
19
21
|
onCheckedChange?: (checked: boolean) => void
|
|
@@ -24,9 +26,10 @@ export interface SwitchProps {
|
|
|
24
26
|
|
|
25
27
|
export function Switch({ checked = false, onCheckedChange, disabled, style, accessibilityLabel }: SwitchProps) {
|
|
26
28
|
const { colors } = useTheme()
|
|
29
|
+
const isDisabled = !!disabled
|
|
27
30
|
|
|
28
31
|
return (
|
|
29
|
-
<View style={[{
|
|
32
|
+
<View style={[{ alignSelf: 'flex-start' }, style]}>
|
|
30
33
|
<TouchableOpacity
|
|
31
34
|
onPress={() => {
|
|
32
35
|
hapticSelection()
|
|
@@ -37,20 +40,15 @@ export function Switch({ checked = false, onCheckedChange, disabled, style, acce
|
|
|
37
40
|
touchSoundDisabled={true}
|
|
38
41
|
accessibilityRole="switch"
|
|
39
42
|
accessibilityLabel={accessibilityLabel}
|
|
40
|
-
accessibilityState={{ checked, disabled:
|
|
43
|
+
accessibilityState={{ checked, disabled: isDisabled }}
|
|
41
44
|
style={styles.touchable}
|
|
42
45
|
>
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
AUDIT FIX: the off-state track used surfaceStrong (~#ebebeb in light mode)
|
|
50
|
-
with no border — nearly invisible on white page/card surfaces. A 1.5px border
|
|
51
|
-
that fades out as the track fills gives the off state clear visual definition
|
|
52
|
-
without adding visual weight to the on state.
|
|
53
|
-
*/}
|
|
46
|
+
<View style={styles.trackContainer}>
|
|
47
|
+
<EaseView
|
|
48
|
+
style={[styles.track, isDisabled && styles.disabledTrack]}
|
|
49
|
+
animate={{ backgroundColor: checked ? colors.primary : colors.surfaceStrong }}
|
|
50
|
+
transition={COLOR_TRANSITION}
|
|
51
|
+
/>
|
|
54
52
|
<EaseView
|
|
55
53
|
style={[styles.trackBorder, { borderWidth: 1.5 }]}
|
|
56
54
|
pointerEvents="none"
|
|
@@ -62,14 +60,22 @@ export function Switch({ checked = false, onCheckedChange, disabled, style, acce
|
|
|
62
60
|
animate={{ translateX: checked ? THUMB_TRAVEL : 0 }}
|
|
63
61
|
transition={SPRING_ELASTIC}
|
|
64
62
|
>
|
|
65
|
-
<EaseView
|
|
63
|
+
<EaseView
|
|
64
|
+
style={styles.iconWrapper}
|
|
65
|
+
animate={{ opacity: checked ? (isDisabled ? DISABLED_OPACITY : 1) : 0 }}
|
|
66
|
+
transition={OPACITY_TRANSITION}
|
|
67
|
+
>
|
|
66
68
|
<Feather name="check" size={ICON_SIZE} color={colors.primary} />
|
|
67
69
|
</EaseView>
|
|
68
|
-
<EaseView
|
|
70
|
+
<EaseView
|
|
71
|
+
style={styles.iconWrapper}
|
|
72
|
+
animate={{ opacity: checked ? 0 : (isDisabled ? DISABLED_OPACITY : 1) }}
|
|
73
|
+
transition={OPACITY_TRANSITION}
|
|
74
|
+
>
|
|
69
75
|
<Feather name="x" size={ICON_SIZE} color={colors.foregroundMuted} />
|
|
70
76
|
</EaseView>
|
|
71
77
|
</EaseView>
|
|
72
|
-
</
|
|
78
|
+
</View>
|
|
73
79
|
</TouchableOpacity>
|
|
74
80
|
</View>
|
|
75
81
|
)
|
|
@@ -79,11 +85,18 @@ const styles = StyleSheet.create({
|
|
|
79
85
|
touchable: {
|
|
80
86
|
alignSelf: 'flex-start',
|
|
81
87
|
},
|
|
82
|
-
|
|
88
|
+
trackContainer: {
|
|
89
|
+
position: 'relative',
|
|
83
90
|
width: TRACK_WIDTH,
|
|
84
91
|
height: TRACK_HEIGHT,
|
|
92
|
+
},
|
|
93
|
+
track: {
|
|
94
|
+
...StyleSheet.absoluteFillObject,
|
|
85
95
|
borderRadius: TRACK_HEIGHT / 2,
|
|
86
96
|
},
|
|
97
|
+
disabledTrack: {
|
|
98
|
+
opacity: DISABLED_OPACITY,
|
|
99
|
+
},
|
|
87
100
|
trackBorder: {
|
|
88
101
|
...StyleSheet.absoluteFillObject,
|
|
89
102
|
borderRadius: TRACK_HEIGHT / 2,
|