@umituz/react-native-design-system 2.6.47 → 2.6.48
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-design-system",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.48",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive and safe area utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -1,192 +1,113 @@
|
|
|
1
|
-
import React, { forwardRef,
|
|
2
|
-
import { StyleSheet } from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
BottomSheetModal as GorhomBottomSheetModal,
|
|
5
|
-
BottomSheetView,
|
|
6
|
-
BottomSheetBackdrop,
|
|
7
|
-
type BottomSheetBackdropProps,
|
|
8
|
-
} from '@gorhom/bottom-sheet';
|
|
1
|
+
import React, { forwardRef, useImperativeHandle, useState, useCallback } from 'react';
|
|
2
|
+
import { Modal, View, StyleSheet, Pressable, Platform } from 'react-native';
|
|
9
3
|
import { useAppDesignTokens } from '../../../theme';
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
BottomSheetModalProps,
|
|
14
|
-
} from '../types/BottomSheet';
|
|
15
|
-
import { BottomSheetUtils } from '../types/BottomSheet';
|
|
4
|
+
import { useSafeAreaInsets } from '../../../safe-area';
|
|
5
|
+
import { getResponsiveBottomSheetLayout } from '../../../responsive';
|
|
6
|
+
import type { BottomSheetModalRef, BottomSheetModalProps } from '../types/BottomSheet';
|
|
16
7
|
|
|
17
|
-
|
|
18
|
-
const {
|
|
19
|
-
children,
|
|
20
|
-
preset = 'medium',
|
|
21
|
-
snapPoints: customSnapPoints,
|
|
22
|
-
initialIndex,
|
|
23
|
-
enableBackdrop = true,
|
|
24
|
-
backdropAppearsOnIndex,
|
|
25
|
-
backdropDisappearsOnIndex,
|
|
26
|
-
keyboardBehavior = 'interactive',
|
|
27
|
-
enableHandleIndicator = true,
|
|
28
|
-
enablePanDownToClose = true,
|
|
29
|
-
enableDynamicSizing = false,
|
|
30
|
-
onChange,
|
|
31
|
-
onDismiss,
|
|
32
|
-
backgroundColor,
|
|
33
|
-
} = props;
|
|
8
|
+
declare const __DEV__: boolean;
|
|
34
9
|
|
|
35
|
-
|
|
36
|
-
|
|
10
|
+
export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModalProps>(
|
|
11
|
+
(props, ref) => {
|
|
12
|
+
const {
|
|
13
|
+
children,
|
|
14
|
+
preset = 'medium',
|
|
15
|
+
onDismiss,
|
|
16
|
+
backgroundColor,
|
|
17
|
+
} = props;
|
|
37
18
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
initialIndex,
|
|
43
|
-
enableBackdrop,
|
|
44
|
-
backdropAppearsOnIndex,
|
|
45
|
-
backdropDisappearsOnIndex,
|
|
46
|
-
keyboardBehavior,
|
|
47
|
-
enableHandleIndicator,
|
|
48
|
-
enablePanDownToClose,
|
|
49
|
-
enableDynamicSizing,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return BottomSheetUtils.getPreset(preset);
|
|
53
|
-
}, [preset, customSnapPoints, initialIndex, enableBackdrop, backdropAppearsOnIndex, backdropDisappearsOnIndex, keyboardBehavior, enableHandleIndicator, enablePanDownToClose, enableDynamicSizing]);
|
|
19
|
+
const [visible, setVisible] = useState(false);
|
|
20
|
+
const tokens = useAppDesignTokens();
|
|
21
|
+
const insets = useSafeAreaInsets();
|
|
22
|
+
const { maxHeight, borderRadius } = getResponsiveBottomSheetLayout();
|
|
54
23
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
opacity={0.5}
|
|
63
|
-
pressBehavior="close"
|
|
64
|
-
/>
|
|
65
|
-
) : null,
|
|
66
|
-
[enableBackdrop, config.backdropAppearsOnIndex, config.backdropDisappearsOnIndex]
|
|
67
|
-
);
|
|
24
|
+
const PRESET_HEIGHTS = {
|
|
25
|
+
small: maxHeight * 0.35,
|
|
26
|
+
medium: maxHeight * 0.6,
|
|
27
|
+
large: maxHeight * 0.85,
|
|
28
|
+
full: maxHeight,
|
|
29
|
+
custom: maxHeight * 0.6,
|
|
30
|
+
};
|
|
68
31
|
|
|
69
|
-
|
|
70
|
-
(index: number) => {
|
|
71
|
-
if (__DEV__) {
|
|
72
|
-
console.log('[BottomSheetModal] onChange triggered', { index });
|
|
73
|
-
}
|
|
74
|
-
onChange?.(index);
|
|
75
|
-
if (index === -1) onDismiss?.();
|
|
76
|
-
},
|
|
77
|
-
[onChange, onDismiss]
|
|
78
|
-
);
|
|
32
|
+
const sheetHeight = PRESET_HEIGHTS[preset] || PRESET_HEIGHTS.medium;
|
|
79
33
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
refExists: !!modalRef.current,
|
|
85
|
-
hasPresentMethod: typeof modalRef.current?.present === 'function',
|
|
86
|
-
refType: typeof modalRef.current,
|
|
87
|
-
refKeys: modalRef.current ? Object.keys(modalRef.current) : []
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
try {
|
|
92
|
-
if (!modalRef.current) {
|
|
93
|
-
if (__DEV__) console.error('[BottomSheetModal] modalRef.current is null!');
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (typeof modalRef.current.present !== 'function') {
|
|
98
|
-
if (__DEV__) console.error('[BottomSheetModal] present is not a function!', typeof modalRef.current.present);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (__DEV__) console.log('[BottomSheetModal] Calling modalRef.current.present()...');
|
|
103
|
-
modalRef.current.present();
|
|
104
|
-
if (__DEV__) console.log('[BottomSheetModal] modalRef.current.present() executed');
|
|
105
|
-
|
|
106
|
-
// Fallback: Also try snapToIndex as a workaround
|
|
107
|
-
setTimeout(() => {
|
|
108
|
-
if (modalRef.current && typeof modalRef.current.snapToIndex === 'function') {
|
|
109
|
-
if (__DEV__) console.log('[BottomSheetModal] Fallback: calling snapToIndex(0)');
|
|
110
|
-
modalRef.current.snapToIndex(0);
|
|
111
|
-
}
|
|
112
|
-
}, 50);
|
|
113
|
-
} catch (error) {
|
|
114
|
-
if (__DEV__) console.error('[BottomSheetModal] Error calling present():', error);
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
dismiss: () => {
|
|
118
|
-
if (__DEV__) console.log('[BottomSheetModal] dismiss() called');
|
|
119
|
-
modalRef.current?.dismiss();
|
|
120
|
-
},
|
|
121
|
-
snapToIndex: (index: number) => {
|
|
122
|
-
if (__DEV__) console.log('[BottomSheetModal] snapToIndex called', { index });
|
|
123
|
-
modalRef.current?.snapToIndex(index);
|
|
124
|
-
},
|
|
125
|
-
snapToPosition: (pos: string | number) => modalRef.current?.snapToPosition(pos),
|
|
126
|
-
expand: () => modalRef.current?.expand(),
|
|
127
|
-
collapse: () => modalRef.current?.collapse(),
|
|
128
|
-
}));
|
|
34
|
+
const present = useCallback(() => {
|
|
35
|
+
if (__DEV__) console.log('[BottomSheetModal] Opening');
|
|
36
|
+
setVisible(true);
|
|
37
|
+
}, []);
|
|
129
38
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
preset
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}, []);
|
|
39
|
+
const dismiss = useCallback(() => {
|
|
40
|
+
if (__DEV__) console.log('[BottomSheetModal] Closing');
|
|
41
|
+
setVisible(false);
|
|
42
|
+
onDismiss?.();
|
|
43
|
+
}, [onDismiss]);
|
|
139
44
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
45
|
+
useImperativeHandle(ref, () => ({
|
|
46
|
+
present,
|
|
47
|
+
dismiss,
|
|
48
|
+
snapToIndex: (index: number) => {
|
|
49
|
+
if (index >= 0) present();
|
|
50
|
+
else dismiss();
|
|
51
|
+
},
|
|
52
|
+
snapToPosition: () => present(),
|
|
53
|
+
expand: () => present(),
|
|
54
|
+
collapse: () => dismiss(),
|
|
55
|
+
}));
|
|
147
56
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
57
|
+
const styles = StyleSheet.create({
|
|
58
|
+
overlay: {
|
|
59
|
+
flex: 1,
|
|
60
|
+
backgroundColor: tokens.colors.modalOverlay,
|
|
61
|
+
justifyContent: 'flex-end',
|
|
62
|
+
},
|
|
63
|
+
container: {
|
|
64
|
+
height: sheetHeight,
|
|
65
|
+
backgroundColor: backgroundColor || tokens.colors.surface,
|
|
66
|
+
borderTopLeftRadius: borderRadius,
|
|
67
|
+
borderTopRightRadius: borderRadius,
|
|
68
|
+
paddingBottom: Math.max(insets.bottom, 8),
|
|
69
|
+
...Platform.select({
|
|
70
|
+
ios: {
|
|
71
|
+
shadowColor: tokens.colors.black,
|
|
72
|
+
shadowOffset: { width: 0, height: -4 },
|
|
73
|
+
shadowOpacity: 0.15,
|
|
74
|
+
shadowRadius: 12,
|
|
75
|
+
},
|
|
76
|
+
android: {
|
|
77
|
+
elevation: 8,
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
},
|
|
81
|
+
handle: {
|
|
82
|
+
width: 40,
|
|
83
|
+
height: 4,
|
|
84
|
+
backgroundColor: tokens.colors.border,
|
|
85
|
+
borderRadius: 2,
|
|
86
|
+
alignSelf: 'center',
|
|
87
|
+
marginTop: 12,
|
|
88
|
+
marginBottom: 8,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
175
91
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
92
|
+
return (
|
|
93
|
+
<Modal
|
|
94
|
+
visible={visible}
|
|
95
|
+
transparent
|
|
96
|
+
animationType="slide"
|
|
97
|
+
onRequestClose={dismiss}
|
|
98
|
+
statusBarTranslucent
|
|
99
|
+
>
|
|
100
|
+
<Pressable style={styles.overlay} onPress={dismiss}>
|
|
101
|
+
<View style={styles.container}>
|
|
102
|
+
<Pressable onPress={(e) => e.stopPropagation()}>
|
|
103
|
+
<View style={styles.handle} />
|
|
104
|
+
{children}
|
|
105
|
+
</Pressable>
|
|
106
|
+
</View>
|
|
107
|
+
</Pressable>
|
|
108
|
+
</Modal>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
);
|
|
192
112
|
|
|
113
|
+
BottomSheetModal.displayName = 'BottomSheetModal';
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
|
|
3
2
|
|
|
4
|
-
interface SafeBottomSheetModalProviderProps {
|
|
3
|
+
export interface SafeBottomSheetModalProviderProps {
|
|
5
4
|
children: ReactNode;
|
|
6
5
|
}
|
|
7
6
|
|
|
7
|
+
/**
|
|
8
|
+
* SafeBottomSheetModalProvider
|
|
9
|
+
*
|
|
10
|
+
* Simple wrapper for backward compatibility.
|
|
11
|
+
* No longer uses @gorhom/bottom-sheet provider.
|
|
12
|
+
*/
|
|
8
13
|
export const SafeBottomSheetModalProvider = ({ children }: SafeBottomSheetModalProviderProps) => {
|
|
9
|
-
|
|
10
|
-
if (__DEV__) {
|
|
11
|
-
console.log('[SafeBottomSheetModalProvider] Mounted and providing context');
|
|
12
|
-
}
|
|
13
|
-
}, []);
|
|
14
|
-
|
|
15
|
-
if (__DEV__) {
|
|
16
|
-
console.log('[SafeBottomSheetModalProvider] Rendering');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return <BottomSheetModalProvider>{children}</BottomSheetModalProvider>;
|
|
14
|
+
return <>{children}</>;
|
|
20
15
|
};
|
|
21
|
-
|