@umituz/react-native-design-system 2.6.50 → 2.6.52

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.50",
3
+ "version": "2.6.52",
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",
@@ -50,7 +50,6 @@
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@expo/vector-icons": ">=15.0.0",
53
- "@gorhom/bottom-sheet": ">=5.0.0",
54
53
  "@react-native-community/datetimepicker": ">=8.0.0",
55
54
  "@react-navigation/bottom-tabs": ">=7.0.0",
56
55
  "@react-navigation/native": ">=7.0.0",
@@ -70,7 +69,6 @@
70
69
  "react-native": ">=0.81.0",
71
70
  "react-native-gesture-handler": ">=2.20.0",
72
71
  "react-native-haptic-feedback": ">=2.0.0",
73
- "react-native-reanimated": ">=3.16.0",
74
72
  "react-native-safe-area-context": ">=5.0.0",
75
73
  "react-native-svg": ">=15.0.0",
76
74
  "rn-emoji-keyboard": ">=1.7.0",
@@ -83,9 +81,6 @@
83
81
  "@react-navigation/native": {
84
82
  "optional": true
85
83
  },
86
- "@gorhom/bottom-sheet": {
87
- "optional": true
88
- },
89
84
  "expo-device": {
90
85
  "optional": true
91
86
  },
@@ -96,7 +91,6 @@
96
91
  "devDependencies": {
97
92
  "@eslint/js": "^9.39.2",
98
93
  "@expo/vector-icons": "^15.0.0",
99
- "@gorhom/bottom-sheet": "^5.0.0",
100
94
  "@react-native-async-storage/async-storage": "^2.2.0",
101
95
  "@react-native-community/datetimepicker": "^8.5.1",
102
96
  "@react-navigation/bottom-tabs": "^7.9.0",
@@ -131,7 +125,6 @@
131
125
  "react-native": "0.81.5",
132
126
  "react-native-gesture-handler": "^2.20.0",
133
127
  "react-native-haptic-feedback": "^2.3.3",
134
- "react-native-reanimated": "^3.16.0",
135
128
  "react-native-safe-area-context": "^5.6.0",
136
129
  "react-native-svg": "15.12.1",
137
130
  "rn-emoji-keyboard": "^1.7.0",
@@ -1,17 +1,12 @@
1
- import React, { forwardRef, useCallback, useMemo, useImperativeHandle, useRef } from 'react';
2
- import { StyleSheet } from 'react-native';
3
- import GorhomBottomSheet, {
4
- BottomSheetView,
5
- BottomSheetBackdrop,
6
- type BottomSheetBackdropProps,
7
- } from '@gorhom/bottom-sheet';
1
+ import React, { forwardRef, useCallback, useMemo, useImperativeHandle, useState } from 'react';
2
+ import { Modal, View, StyleSheet, Pressable } from 'react-native';
8
3
  import { useAppDesignTokens } from '../../../theme';
4
+ import { useSafeAreaInsets } from '../../../safe-area';
5
+ import { getResponsiveBottomSheetLayout } from '../../../responsive';
9
6
  import type {
10
- BottomSheetConfig,
11
7
  BottomSheetRef,
12
8
  BottomSheetProps,
13
9
  } from '../types/BottomSheet';
14
- import { BottomSheetUtils } from '../types/BottomSheet';
15
10
 
16
11
  export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>((props, ref) => {
17
12
  const {
@@ -19,104 +14,102 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>((props,
19
14
  preset = 'medium',
20
15
  snapPoints: customSnapPoints,
21
16
  initialIndex,
22
- enableBackdrop = true,
23
- backdropAppearsOnIndex,
24
- backdropDisappearsOnIndex,
25
- keyboardBehavior = 'interactive',
26
- enableHandleIndicator = true,
27
- enablePanDownToClose = true,
28
- enableDynamicSizing = false,
17
+ backgroundColor,
29
18
  onChange,
30
19
  onClose,
31
20
  } = props;
32
21
 
22
+ const [visible, setVisible] = useState(initialIndex !== undefined && initialIndex >= 0);
33
23
  const tokens = useAppDesignTokens();
34
- const sheetRef = useRef<GorhomBottomSheet>(null);
24
+ const insets = useSafeAreaInsets();
25
+ const { maxHeight, borderRadius } = getResponsiveBottomSheetLayout();
35
26
 
36
- const config: BottomSheetConfig = useMemo(() => {
37
- if (customSnapPoints) {
38
- return BottomSheetUtils.createConfig({
39
- snapPoints: customSnapPoints,
40
- initialIndex,
41
- enableBackdrop,
42
- backdropAppearsOnIndex,
43
- backdropDisappearsOnIndex,
44
- keyboardBehavior,
45
- enableHandleIndicator,
46
- enablePanDownToClose,
47
- enableDynamicSizing,
48
- });
27
+ const sheetHeight = useMemo(() => {
28
+ if (customSnapPoints && customSnapPoints.length > 0) {
29
+ const highest = customSnapPoints[customSnapPoints.length - 1];
30
+ if (typeof highest === 'number') return highest;
31
+ if (typeof highest === 'string' && highest.endsWith('%')) {
32
+ return (maxHeight * parseFloat(highest)) / 100;
33
+ }
49
34
  }
50
- return BottomSheetUtils.getPreset(preset);
51
- }, [preset, customSnapPoints, initialIndex, enableBackdrop, backdropAppearsOnIndex, backdropDisappearsOnIndex, keyboardBehavior, enableHandleIndicator, enablePanDownToClose, enableDynamicSizing]);
35
+
36
+ const PRESET_HEIGHTS = {
37
+ small: maxHeight * 0.35,
38
+ medium: maxHeight * 0.6,
39
+ large: maxHeight * 0.85,
40
+ full: maxHeight,
41
+ custom: maxHeight * 0.6,
42
+ };
43
+ return PRESET_HEIGHTS[preset] || PRESET_HEIGHTS.medium;
44
+ }, [preset, customSnapPoints, maxHeight]);
52
45
 
53
- const renderBackdrop = useCallback(
54
- (backdropProps: BottomSheetBackdropProps) =>
55
- enableBackdrop ? (
56
- <BottomSheetBackdrop
57
- {...backdropProps}
58
- appearsOnIndex={config.backdropAppearsOnIndex ?? 0}
59
- disappearsOnIndex={config.backdropDisappearsOnIndex ?? -1}
60
- opacity={0.5}
61
- pressBehavior="close"
62
- />
63
- ) : null,
64
- [enableBackdrop, config.backdropAppearsOnIndex, config.backdropDisappearsOnIndex]
65
- );
46
+ const present = useCallback(() => {
47
+ setVisible(true);
48
+ onChange?.(0);
49
+ }, [onChange]);
66
50
 
67
- const handleSheetChange = useCallback(
68
- (index: number) => {
69
- onChange?.(index);
70
- if (index === -1) onClose?.();
71
- },
72
- [onChange, onClose]
73
- );
51
+ const dismiss = useCallback(() => {
52
+ setVisible(false);
53
+ onClose?.();
54
+ onChange?.(-1);
55
+ }, [onClose, onChange]);
74
56
 
75
57
  useImperativeHandle(ref, () => ({
76
- snapToIndex: (index: number) => sheetRef.current?.snapToIndex(index),
77
- snapToPosition: (pos: string | number) => sheetRef.current?.snapToPosition(pos),
78
- expand: () => sheetRef.current?.expand(),
79
- collapse: () => sheetRef.current?.collapse(),
80
- close: () => sheetRef.current?.close(),
58
+ snapToIndex: (index: number) => {
59
+ if (index >= 0) present();
60
+ else dismiss();
61
+ },
62
+ snapToPosition: () => present(),
63
+ expand: () => present(),
64
+ collapse: () => dismiss(),
65
+ close: () => dismiss(),
81
66
  }));
82
67
 
83
- if (!config.snapPoints || config.snapPoints.length === 0) return null;
68
+ const styles = StyleSheet.create({
69
+ overlay: {
70
+ flex: 1,
71
+ backgroundColor: tokens.colors.modalOverlay,
72
+ justifyContent: 'flex-end',
73
+ },
74
+ container: {
75
+ height: sheetHeight,
76
+ backgroundColor: backgroundColor || tokens.colors.surface,
77
+ borderTopLeftRadius: borderRadius,
78
+ borderTopRightRadius: borderRadius,
79
+ paddingBottom: Math.max(insets.bottom, 8),
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
+ content: {
91
+ flex: 1,
92
+ }
93
+ });
84
94
 
85
95
  return (
86
- <GorhomBottomSheet
87
- ref={sheetRef}
88
- index={-1}
89
- snapPoints={config.snapPoints}
90
- enableDynamicSizing={config.enableDynamicSizing}
91
- backdropComponent={renderBackdrop}
92
- keyboardBehavior={config.keyboardBehavior}
93
- enableHandlePanningGesture={config.enableHandleIndicator}
94
- enablePanDownToClose={config.enablePanDownToClose}
95
- onChange={handleSheetChange}
96
- backgroundStyle={[styles.background, { backgroundColor: tokens.colors.surface }]}
97
- handleIndicatorStyle={[styles.handleIndicator, { backgroundColor: tokens.colors.border }]}
96
+ <Modal
97
+ visible={visible}
98
+ transparent
99
+ animationType="slide"
100
+ onRequestClose={dismiss}
101
+ statusBarTranslucent
98
102
  >
99
- <BottomSheetView style={styles.contentContainer}>
100
- {children}
101
- </BottomSheetView>
102
- </GorhomBottomSheet>
103
+ <Pressable style={styles.overlay} onPress={dismiss}>
104
+ <View style={styles.container}>
105
+ <Pressable onPress={(e) => e.stopPropagation()} style={styles.content}>
106
+ <View style={styles.handle} />
107
+ {children}
108
+ </Pressable>
109
+ </View>
110
+ </Pressable>
111
+ </Modal>
103
112
  );
104
113
  });
105
114
 
106
115
  BottomSheet.displayName = 'BottomSheet';
107
-
108
- const styles = StyleSheet.create({
109
- background: {
110
- borderTopLeftRadius: 16,
111
- borderTopRightRadius: 16,
112
- },
113
- handleIndicator: {
114
- width: 40,
115
- height: 4,
116
- borderRadius: 2,
117
- },
118
- contentContainer: {
119
- flex: 1,
120
- },
121
- });
122
-
@@ -76,6 +76,9 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
76
76
  marginTop: 12,
77
77
  marginBottom: 8,
78
78
  },
79
+ content: {
80
+ flex: 1,
81
+ },
79
82
  });
80
83
 
81
84
  return (
@@ -88,7 +91,7 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
88
91
  >
89
92
  <Pressable style={styles.overlay} onPress={dismiss}>
90
93
  <View style={styles.container}>
91
- <Pressable onPress={(e) => e.stopPropagation()}>
94
+ <Pressable onPress={(e) => e.stopPropagation()} style={styles.content}>
92
95
  <View style={styles.handle} />
93
96
  {children}
94
97
  </Pressable>
@@ -45,6 +45,7 @@ export interface BottomSheetProps {
45
45
  enableHandleIndicator?: boolean;
46
46
  enablePanDownToClose?: boolean;
47
47
  enableDynamicSizing?: boolean;
48
+ backgroundColor?: string;
48
49
  onChange?: (index: number) => void;
49
50
  onClose?: () => void;
50
51
  }