@umituz/react-native-design-system 2.6.46 → 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.46",
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,184 +1,113 @@
1
- import React, { forwardRef, useCallback, useMemo, useImperativeHandle, useRef } from 'react';
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 type {
11
- BottomSheetConfig,
12
- BottomSheetModalRef,
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
- export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModalProps>((props, ref) => {
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
- const tokens = useAppDesignTokens();
36
- const modalRef = useRef<GorhomBottomSheetModal>(null);
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
- const config: BottomSheetConfig = useMemo(() => {
39
- if (customSnapPoints) {
40
- return BottomSheetUtils.createConfig({
41
- snapPoints: customSnapPoints,
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
- const renderBackdrop = useCallback(
56
- (backdropProps: BottomSheetBackdropProps) =>
57
- enableBackdrop ? (
58
- <BottomSheetBackdrop
59
- {...backdropProps}
60
- appearsOnIndex={config.backdropAppearsOnIndex ?? 0}
61
- disappearsOnIndex={config.backdropDisappearsOnIndex ?? -1}
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
- const handleSheetChange = useCallback(
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
- useImperativeHandle(ref, () => ({
81
- present: () => {
82
- if (__DEV__) {
83
- console.log('[BottomSheetModal] present() called', {
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
- } catch (error) {
106
- if (__DEV__) console.error('[BottomSheetModal] Error calling present():', error);
107
- }
108
- },
109
- dismiss: () => {
110
- if (__DEV__) console.log('[BottomSheetModal] dismiss() called');
111
- modalRef.current?.dismiss();
112
- },
113
- snapToIndex: (index: number) => {
114
- if (__DEV__) console.log('[BottomSheetModal] snapToIndex called', { index });
115
- modalRef.current?.snapToIndex(index);
116
- },
117
- snapToPosition: (pos: string | number) => modalRef.current?.snapToPosition(pos),
118
- expand: () => modalRef.current?.expand(),
119
- collapse: () => modalRef.current?.collapse(),
120
- }));
34
+ const present = useCallback(() => {
35
+ if (__DEV__) console.log('[BottomSheetModal] Opening');
36
+ setVisible(true);
37
+ }, []);
121
38
 
122
- React.useEffect(() => {
123
- if (__DEV__) {
124
- console.log('[BottomSheetModal] Component mounted', {
125
- hasModalRef: !!modalRef.current,
126
- snapPoints: config.snapPoints,
127
- preset
128
- });
129
- }
130
- }, []);
39
+ const dismiss = useCallback(() => {
40
+ if (__DEV__) console.log('[BottomSheetModal] Closing');
41
+ setVisible(false);
42
+ onDismiss?.();
43
+ }, [onDismiss]);
131
44
 
132
- React.useEffect(() => {
133
- if (__DEV__) {
134
- console.log('[BottomSheetModal] modalRef updated', {
135
- hasModalRef: !!modalRef.current,
136
- });
137
- }
138
- }, [modalRef.current]);
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
+ }));
139
56
 
140
- return (
141
- <GorhomBottomSheetModal
142
- ref={modalRef}
143
- index={-1}
144
- snapPoints={config.snapPoints}
145
- enableDynamicSizing={false}
146
- backdropComponent={renderBackdrop}
147
- keyboardBehavior={config.keyboardBehavior}
148
- enableHandlePanningGesture={config.enableHandleIndicator}
149
- enablePanDownToClose={config.enablePanDownToClose ?? true}
150
- onChange={handleSheetChange}
151
- onDismiss={onDismiss}
152
- onAnimate={(fromIndex, toIndex) => {
153
- if (__DEV__) {
154
- console.log('[BottomSheetModal] onAnimate', { fromIndex, toIndex });
155
- }
156
- }}
157
- backgroundStyle={[styles.background, { backgroundColor: backgroundColor || tokens.colors.surface }]}
158
- handleIndicatorStyle={[styles.handleIndicator, { backgroundColor: tokens.colors.border }]}
159
- enableOverDrag={false}
160
- >
161
- <BottomSheetView style={styles.contentContainer}>
162
- {children}
163
- </BottomSheetView>
164
- </GorhomBottomSheetModal>
165
- );
166
- });
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
+ });
167
91
 
168
- BottomSheetModal.displayName = 'BottomSheetModal';
169
-
170
- const styles = StyleSheet.create({
171
- background: {
172
- borderTopLeftRadius: 16,
173
- borderTopRightRadius: 16,
174
- },
175
- handleIndicator: {
176
- width: 40,
177
- height: 4,
178
- borderRadius: 2,
179
- },
180
- contentContainer: {
181
- flex: 1,
182
- },
183
- });
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
+ );
184
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
- React.useEffect(() => {
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
-