@umituz/react-native-bottom-sheet 1.0.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.
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Bottom Sheet Component
3
+ *
4
+ * Main bottom sheet wrapper using @gorhom/bottom-sheet library.
5
+ * Provides a clean, theme-aware API for bottom sheets across the app.
6
+ *
7
+ * Features:
8
+ * - Snap point support (percentage, fixed, dynamic)
9
+ * - Backdrop with tap-to-close
10
+ * - Keyboard handling (interactive, fillParent, extend)
11
+ * - Theme-aware colors
12
+ * - Handle indicator
13
+ * - Pan down to close
14
+ * - Smooth animations with Reanimated v3
15
+ *
16
+ * Usage:
17
+ * ```tsx
18
+ * const sheetRef = useRef<BottomSheetRef>(null);
19
+ *
20
+ * <BottomSheet
21
+ * ref={sheetRef}
22
+ * preset="medium"
23
+ * onClose={() => console.log('Closed')}
24
+ * >
25
+ * <View>
26
+ * <Text>Bottom Sheet Content</Text>
27
+ * </View>
28
+ * </BottomSheet>
29
+ * ```
30
+ */
31
+ import React, { forwardRef, useCallback, useMemo } from 'react';
32
+ import { StyleSheet } from 'react-native';
33
+ import GorhomBottomSheet, { BottomSheetView, BottomSheetBackdrop, } from '@gorhom/bottom-sheet';
34
+ import { useAppDesignTokens } from '@umituz/react-native-design-system';
35
+ import { BottomSheetUtils } from '../../domain/entities/BottomSheet';
36
+ /**
37
+ * Bottom Sheet Component
38
+ *
39
+ * Modern, performant bottom sheet for React Native.
40
+ * Uses @gorhom/bottom-sheet with Reanimated v3.
41
+ */
42
+ export const BottomSheet = forwardRef(({ children, preset = 'medium', snapPoints: customSnapPoints, initialIndex, enableBackdrop = true, backdropAppearsOnIndex, backdropDisappearsOnIndex, keyboardBehavior = 'interactive', enableHandleIndicator = true, enablePanDownToClose = true, enableDynamicSizing = false, onChange, onClose, }, ref) => {
43
+ const tokens = useAppDesignTokens();
44
+ // Get configuration from preset or custom
45
+ const config = useMemo(() => {
46
+ if (customSnapPoints) {
47
+ return BottomSheetUtils.createConfig({
48
+ snapPoints: customSnapPoints,
49
+ initialIndex,
50
+ enableBackdrop,
51
+ backdropAppearsOnIndex,
52
+ backdropDisappearsOnIndex,
53
+ keyboardBehavior,
54
+ enableHandleIndicator,
55
+ enablePanDownToClose,
56
+ enableDynamicSizing,
57
+ });
58
+ }
59
+ return BottomSheetUtils.getPreset(preset);
60
+ }, [
61
+ preset,
62
+ customSnapPoints,
63
+ initialIndex,
64
+ enableBackdrop,
65
+ backdropAppearsOnIndex,
66
+ backdropDisappearsOnIndex,
67
+ keyboardBehavior,
68
+ enableHandleIndicator,
69
+ enablePanDownToClose,
70
+ enableDynamicSizing,
71
+ ]);
72
+ // Render backdrop component
73
+ const renderBackdrop = useCallback((props) => enableBackdrop ? (<BottomSheetBackdrop {...props} appearsOnIndex={config.backdropAppearsOnIndex ?? 0} disappearsOnIndex={config.backdropDisappearsOnIndex ?? -1} opacity={0.5} pressBehavior="close"/>) : null, [enableBackdrop, config.backdropAppearsOnIndex, config.backdropDisappearsOnIndex]);
74
+ // Handle sheet changes
75
+ const handleSheetChange = useCallback((index) => {
76
+ onChange?.(index);
77
+ if (index === -1) {
78
+ onClose?.();
79
+ }
80
+ }, [onChange, onClose]);
81
+ return (<GorhomBottomSheet ref={ref} index={config.initialIndex ?? 0} snapPoints={config.snapPoints} enableDynamicSizing={config.enableDynamicSizing} backdropComponent={renderBackdrop} keyboardBehavior={config.keyboardBehavior} enableHandlePanningGesture={config.enableHandleIndicator} enablePanDownToClose={config.enablePanDownToClose} onChange={handleSheetChange} backgroundStyle={[
82
+ styles.background,
83
+ { backgroundColor: tokens.colors.surface },
84
+ ]} handleIndicatorStyle={[
85
+ styles.handleIndicator,
86
+ { backgroundColor: tokens.colors.border },
87
+ ]}>
88
+ <BottomSheetView style={styles.contentContainer}>
89
+ {children}
90
+ </BottomSheetView>
91
+ </GorhomBottomSheet>);
92
+ });
93
+ BottomSheet.displayName = 'BottomSheet';
94
+ const styles = StyleSheet.create({
95
+ background: {
96
+ borderTopLeftRadius: 16,
97
+ borderTopRightRadius: 16,
98
+ },
99
+ handleIndicator: {
100
+ width: 40,
101
+ height: 4,
102
+ borderRadius: 2,
103
+ },
104
+ contentContainer: {
105
+ flex: 1,
106
+ },
107
+ });
108
+ //# sourceMappingURL=BottomSheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BottomSheet.js","sourceRoot":"","sources":["../../../src/presentation/components/BottomSheet.tsx"],"names":[],"mappings":"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"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * useBottomSheet Hook
3
+ *
4
+ * React hook for managing bottom sheet state and interactions.
5
+ * Provides a clean API for common bottom sheet operations.
6
+ *
7
+ * Features:
8
+ * - Open/close bottom sheet
9
+ * - Snap to specific index
10
+ * - Expand to max height
11
+ * - Collapse to min height
12
+ * - Track current position
13
+ * - Preset configurations
14
+ *
15
+ * Usage:
16
+ * ```tsx
17
+ * const { sheetRef, open, close, expand, collapse } = useBottomSheet();
18
+ *
19
+ * return (
20
+ * <>
21
+ * <Button onPress={open}>Open Sheet</Button>
22
+ * <BottomSheet ref={sheetRef} preset="medium">
23
+ * <Text>Content</Text>
24
+ * </BottomSheet>
25
+ * </>
26
+ * );
27
+ * ```
28
+ */
29
+ import type { BottomSheetRef } from '../components/BottomSheet';
30
+ /**
31
+ * Return type for useBottomSheet hook
32
+ */
33
+ export interface UseBottomSheetReturn {
34
+ /**
35
+ * Ref to attach to BottomSheet component
36
+ */
37
+ sheetRef: React.RefObject<BottomSheetRef>;
38
+ /**
39
+ * Open bottom sheet to initial index
40
+ */
41
+ open: () => void;
42
+ /**
43
+ * Close bottom sheet completely
44
+ */
45
+ close: () => void;
46
+ /**
47
+ * Expand to maximum height
48
+ */
49
+ expand: () => void;
50
+ /**
51
+ * Collapse to minimum height
52
+ */
53
+ collapse: () => void;
54
+ /**
55
+ * Snap to specific index
56
+ */
57
+ snapToIndex: (index: number) => void;
58
+ /**
59
+ * Snap to specific position
60
+ */
61
+ snapToPosition: (position: string | number) => void;
62
+ }
63
+ /**
64
+ * useBottomSheet Hook
65
+ *
66
+ * Hook for managing bottom sheet state and interactions.
67
+ * Provides imperative methods for controlling the sheet.
68
+ */
69
+ export declare const useBottomSheet: () => UseBottomSheetReturn;
70
+ //# sourceMappingURL=useBottomSheet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBottomSheet.d.ts","sourceRoot":"","sources":["../../../src/presentation/hooks/useBottomSheet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAE1C;;OAEG;IACH,IAAI,EAAE,MAAM,IAAI,CAAC;IAEjB;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAElB;;OAEG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAC;IAErB;;OAEG;IACH,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAErC;;OAEG;IACH,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;CACrD;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAO,oBAsDjC,CAAC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * useBottomSheet Hook
3
+ *
4
+ * React hook for managing bottom sheet state and interactions.
5
+ * Provides a clean API for common bottom sheet operations.
6
+ *
7
+ * Features:
8
+ * - Open/close bottom sheet
9
+ * - Snap to specific index
10
+ * - Expand to max height
11
+ * - Collapse to min height
12
+ * - Track current position
13
+ * - Preset configurations
14
+ *
15
+ * Usage:
16
+ * ```tsx
17
+ * const { sheetRef, open, close, expand, collapse } = useBottomSheet();
18
+ *
19
+ * return (
20
+ * <>
21
+ * <Button onPress={open}>Open Sheet</Button>
22
+ * <BottomSheet ref={sheetRef} preset="medium">
23
+ * <Text>Content</Text>
24
+ * </BottomSheet>
25
+ * </>
26
+ * );
27
+ * ```
28
+ */
29
+ import { useRef, useCallback } from 'react';
30
+ /**
31
+ * useBottomSheet Hook
32
+ *
33
+ * Hook for managing bottom sheet state and interactions.
34
+ * Provides imperative methods for controlling the sheet.
35
+ */
36
+ export const useBottomSheet = () => {
37
+ const sheetRef = useRef(null);
38
+ /**
39
+ * Open bottom sheet to first snap point
40
+ */
41
+ const open = useCallback(() => {
42
+ sheetRef.current?.snapToIndex(0);
43
+ }, []);
44
+ /**
45
+ * Close bottom sheet completely
46
+ */
47
+ const close = useCallback(() => {
48
+ sheetRef.current?.close();
49
+ }, []);
50
+ /**
51
+ * Expand to maximum height (last snap point)
52
+ */
53
+ const expand = useCallback(() => {
54
+ sheetRef.current?.expand();
55
+ }, []);
56
+ /**
57
+ * Collapse to minimum height (first snap point)
58
+ */
59
+ const collapse = useCallback(() => {
60
+ sheetRef.current?.collapse();
61
+ }, []);
62
+ /**
63
+ * Snap to specific index
64
+ */
65
+ const snapToIndex = useCallback((index) => {
66
+ sheetRef.current?.snapToIndex(index);
67
+ }, []);
68
+ /**
69
+ * Snap to specific position (percentage or fixed)
70
+ */
71
+ const snapToPosition = useCallback((position) => {
72
+ sheetRef.current?.snapToPosition(position);
73
+ }, []);
74
+ return {
75
+ sheetRef,
76
+ open,
77
+ close,
78
+ expand,
79
+ collapse,
80
+ snapToIndex,
81
+ snapToPosition,
82
+ };
83
+ };
84
+ //# sourceMappingURL=useBottomSheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBottomSheet.js","sourceRoot":"","sources":["../../../src/presentation/hooks/useBottomSheet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AA2C5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAyB,EAAE;IACvD,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAE9C;;OAEG;IACH,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE;QAC5B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP;;OAEG;IACH,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP;;OAEG;IACH,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP;;OAEG;IACH,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;QAChC,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;IAC/B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP;;OAEG;IACH,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,KAAa,EAAE,EAAE;QAChD,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP;;OAEG;IACH,MAAM,cAAc,GAAG,WAAW,CAAC,CAAC,QAAyB,EAAE,EAAE;QAC/D,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,QAAQ;QACR,IAAI;QACJ,KAAK;QACL,MAAM;QACN,QAAQ;QACR,WAAW;QACX,cAAc;KACf,CAAC;AACJ,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@umituz/react-native-bottom-sheet",
3
+ "version": "1.0.0",
4
+ "description": "Modern, performant bottom sheets for React Native with preset configurations, keyboard handling, and smooth animations",
5
+ "main": "./lib/index.js",
6
+ "types": "./lib/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "typecheck": "tsc --noEmit",
10
+ "lint": "tsc --noEmit",
11
+ "clean": "rm -rf lib",
12
+ "prebuild": "npm run clean",
13
+ "prepublishOnly": "npm run build",
14
+ "version:patch": "npm version patch -m 'chore: release v%s'",
15
+ "version:minor": "npm version minor -m 'chore: release v%s'",
16
+ "version:major": "npm version major -m 'chore: release v%s'"
17
+ },
18
+ "keywords": [
19
+ "react-native",
20
+ "bottom-sheet",
21
+ "modal",
22
+ "sheet",
23
+ "reanimated",
24
+ "gesture-handler"
25
+ ],
26
+ "author": "Ümit UZ <umit@umituz.com>",
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/umituz/react-native-bottom-sheet"
31
+ },
32
+ "peerDependencies": {
33
+ "@gorhom/bottom-sheet": ">=5.0.0",
34
+ "@umituz/react-native-design-system": "*",
35
+ "react": ">=18.2.0",
36
+ "react-native": ">=0.74.0",
37
+ "react-native-gesture-handler": ">=2.16.0",
38
+ "react-native-reanimated": ">=3.10.0"
39
+ },
40
+ "devDependencies": {
41
+ "@gorhom/bottom-sheet": "^5",
42
+ "@types/react": "^18.2.45",
43
+ "@types/react-native": "^0.73.0",
44
+ "@umituz/react-native-design-system": "latest",
45
+ "react": "^18.2.0",
46
+ "react-native": "^0.74.0",
47
+ "react-native-gesture-handler": "~2.16.1",
48
+ "react-native-reanimated": "^3.10.1",
49
+ "typescript": "^5.3.3"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "files": [
55
+ "lib",
56
+ "src",
57
+ "README.md",
58
+ "LICENSE"
59
+ ]
60
+ }
61
+
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Bottom Sheet Domain - Entity
3
+ *
4
+ * Defines bottom sheet types, snap point configurations, and utilities.
5
+ * Provides a clean abstraction over @gorhom/bottom-sheet library.
6
+ *
7
+ * Features:
8
+ * - Snap point types (percentage, fixed, dynamic)
9
+ * - Pre-built configs (small, medium, large, full)
10
+ * - Backdrop configurations
11
+ * - Animation timing configs
12
+ * - Keyboard behavior options
13
+ *
14
+ * Architecture:
15
+ * - Domain Layer: Pure business logic, no UI dependencies
16
+ * - Factory pattern for config creation
17
+ * - Type-safe snap points and options
18
+ */
19
+
20
+ import type { BottomSheetBackdropProps } from '@gorhom/bottom-sheet';
21
+
22
+ /**
23
+ * Snap point types for bottom sheet positioning
24
+ */
25
+ export type SnapPoint = string | number;
26
+
27
+ /**
28
+ * Keyboard behavior strategies
29
+ */
30
+ export type KeyboardBehavior = 'interactive' | 'fillParent' | 'extend';
31
+
32
+ /**
33
+ * Bottom sheet preset sizes
34
+ */
35
+ export type BottomSheetPreset = 'small' | 'medium' | 'large' | 'full';
36
+
37
+ /**
38
+ * Bottom sheet configuration interface
39
+ */
40
+ export interface BottomSheetConfig {
41
+ /**
42
+ * Snap points for the bottom sheet
43
+ * - Percentage: '25%', '50%', '75%'
44
+ * - Fixed: 200, 400, 600
45
+ * - Dynamic: 'CONTENT_HEIGHT'
46
+ */
47
+ snapPoints: SnapPoint[];
48
+
49
+ /**
50
+ * Initial snap point index (default: 0)
51
+ */
52
+ initialIndex?: number;
53
+
54
+ /**
55
+ * Enable backdrop (darkens background)
56
+ */
57
+ enableBackdrop?: boolean;
58
+
59
+ /**
60
+ * Backdrop appears at this snap index (default: 0)
61
+ */
62
+ backdropAppearsOnIndex?: number;
63
+
64
+ /**
65
+ * Backdrop disappears at this snap index (default: -1)
66
+ */
67
+ backdropDisappearsOnIndex?: number;
68
+
69
+ /**
70
+ * Keyboard behavior strategy
71
+ */
72
+ keyboardBehavior?: KeyboardBehavior;
73
+
74
+ /**
75
+ * Enable handle indicator (default: true)
76
+ */
77
+ enableHandleIndicator?: boolean;
78
+
79
+ /**
80
+ * Enable pan down to close (default: true)
81
+ */
82
+ enablePanDownToClose?: boolean;
83
+
84
+ /**
85
+ * Enable dynamic sizing
86
+ */
87
+ enableDynamicSizing?: boolean;
88
+ }
89
+
90
+ /**
91
+ * Backdrop configuration
92
+ */
93
+ export interface BackdropConfig {
94
+ appearsOnIndex: number;
95
+ disappearsOnIndex: number;
96
+ opacity?: number;
97
+ pressBehavior?: 'none' | 'close' | 'collapse';
98
+ }
99
+
100
+ /**
101
+ * Pre-built bottom sheet configurations
102
+ */
103
+ export const BOTTOM_SHEET_PRESETS: Record<BottomSheetPreset, BottomSheetConfig> = {
104
+ small: {
105
+ snapPoints: ['25%'],
106
+ initialIndex: 0,
107
+ enableBackdrop: true,
108
+ backdropAppearsOnIndex: 0,
109
+ backdropDisappearsOnIndex: -1,
110
+ enableHandleIndicator: true,
111
+ enablePanDownToClose: true,
112
+ },
113
+ medium: {
114
+ snapPoints: ['50%'],
115
+ initialIndex: 0,
116
+ enableBackdrop: true,
117
+ backdropAppearsOnIndex: 0,
118
+ backdropDisappearsOnIndex: -1,
119
+ enableHandleIndicator: true,
120
+ enablePanDownToClose: true,
121
+ },
122
+ large: {
123
+ snapPoints: ['75%'],
124
+ initialIndex: 0,
125
+ enableBackdrop: true,
126
+ backdropAppearsOnIndex: 0,
127
+ backdropDisappearsOnIndex: -1,
128
+ enableHandleIndicator: true,
129
+ enablePanDownToClose: true,
130
+ },
131
+ full: {
132
+ snapPoints: ['25%', '50%', '90%'],
133
+ initialIndex: 1,
134
+ enableBackdrop: true,
135
+ backdropAppearsOnIndex: 2,
136
+ backdropDisappearsOnIndex: 1,
137
+ enableHandleIndicator: true,
138
+ enablePanDownToClose: true,
139
+ },
140
+ };
141
+
142
+ /**
143
+ * Default bottom sheet configuration
144
+ */
145
+ export const DEFAULT_BOTTOM_SHEET_CONFIG: BottomSheetConfig = {
146
+ snapPoints: ['50%'],
147
+ initialIndex: 0,
148
+ enableBackdrop: true,
149
+ backdropAppearsOnIndex: 0,
150
+ backdropDisappearsOnIndex: -1,
151
+ keyboardBehavior: 'interactive',
152
+ enableHandleIndicator: true,
153
+ enablePanDownToClose: true,
154
+ enableDynamicSizing: false,
155
+ };
156
+
157
+ /**
158
+ * Bottom sheet utilities
159
+ */
160
+ export const BottomSheetUtils = {
161
+ /**
162
+ * Create custom bottom sheet config
163
+ */
164
+ createConfig: (overrides: Partial<BottomSheetConfig>): BottomSheetConfig => {
165
+ return {
166
+ ...DEFAULT_BOTTOM_SHEET_CONFIG,
167
+ ...overrides,
168
+ };
169
+ },
170
+
171
+ /**
172
+ * Get preset configuration
173
+ */
174
+ getPreset: (preset: BottomSheetPreset): BottomSheetConfig => {
175
+ return BOTTOM_SHEET_PRESETS[preset];
176
+ },
177
+
178
+ /**
179
+ * Validate snap points
180
+ */
181
+ validateSnapPoints: (snapPoints: SnapPoint[]): boolean => {
182
+ if (snapPoints.length === 0) return false;
183
+
184
+ return snapPoints.every(point => {
185
+ if (typeof point === 'number') return point > 0;
186
+ if (typeof point === 'string') {
187
+ if (point === 'CONTENT_HEIGHT') return true;
188
+ if (point.endsWith('%')) {
189
+ const value = parseInt(point);
190
+ return value > 0 && value <= 100;
191
+ }
192
+ }
193
+ return false;
194
+ });
195
+ },
196
+
197
+ /**
198
+ * Create backdrop config
199
+ */
200
+ createBackdropConfig: (
201
+ appearsOnIndex: number = 0,
202
+ disappearsOnIndex: number = -1,
203
+ opacity: number = 0.5
204
+ ): BackdropConfig => {
205
+ return {
206
+ appearsOnIndex,
207
+ disappearsOnIndex,
208
+ opacity,
209
+ pressBehavior: 'close',
210
+ };
211
+ },
212
+ };
package/src/index.ts ADDED
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Bottom Sheet Domain - Barrel Export
3
+ *
4
+ * Public API for the bottom-sheet domain.
5
+ * Provides modern, performant bottom sheets for React Native.
6
+ *
7
+ * Features:
8
+ * - Preset configurations (small, medium, large, full)
9
+ * - Custom snap points (percentage, fixed, dynamic)
10
+ * - Backdrop with tap-to-close
11
+ * - Keyboard handling (interactive, fillParent, extend)
12
+ * - Theme-aware colors
13
+ * - Handle indicator
14
+ * - Pan down to close
15
+ * - Smooth animations with Reanimated v3
16
+ * - Offline-compatible (100% client-side)
17
+ *
18
+ * Usage:
19
+ * ```tsx
20
+ * import { BottomSheet, useBottomSheet } from '@umituz/react-native-bottom-sheet';
21
+ *
22
+ * const MyScreen = () => {
23
+ * const { sheetRef, open, close } = useBottomSheet();
24
+ *
25
+ * return (
26
+ * <>
27
+ * <Button onPress={open}>Open Sheet</Button>
28
+ * <BottomSheet
29
+ * ref={sheetRef}
30
+ * preset="medium"
31
+ * onClose={() => console.log('Closed')}
32
+ * >
33
+ * <View>
34
+ * <Text>Bottom Sheet Content</Text>
35
+ * </View>
36
+ * </BottomSheet>
37
+ * </>
38
+ * );
39
+ * };
40
+ *
41
+ * // Custom snap points
42
+ * <BottomSheet
43
+ * snapPoints={['25%', '50%', '90%']}
44
+ * initialIndex={1}
45
+ * enableBackdrop
46
+ * >
47
+ * <FilterForm />
48
+ * </BottomSheet>
49
+ *
50
+ * // Keyboard-aware sheet
51
+ * <BottomSheet
52
+ * preset="large"
53
+ * keyboardBehavior="fillParent"
54
+ * >
55
+ * <CommentForm />
56
+ * </BottomSheet>
57
+ * ```
58
+ *
59
+ * Presets:
60
+ * - small: 25% height
61
+ * - medium: 50% height
62
+ * - large: 75% height
63
+ * - full: Multi-snap (25%, 50%, 90%)
64
+ *
65
+ * Technical:
66
+ * - Uses @gorhom/bottom-sheet library
67
+ * - Animated with react-native-reanimated v3
68
+ * - Gesture handling with react-native-gesture-handler
69
+ * - Zero backend dependencies
70
+ */
71
+
72
+ // Domain Entities
73
+ export type {
74
+ BottomSheetConfig,
75
+ BottomSheetPreset,
76
+ SnapPoint,
77
+ KeyboardBehavior,
78
+ BackdropConfig,
79
+ } from './domain/entities/BottomSheet';
80
+
81
+ export {
82
+ BOTTOM_SHEET_PRESETS,
83
+ DEFAULT_BOTTOM_SHEET_CONFIG,
84
+ BottomSheetUtils,
85
+ } from './domain/entities/BottomSheet';
86
+
87
+ // Presentation Components
88
+ export {
89
+ BottomSheet,
90
+ type BottomSheetProps,
91
+ type BottomSheetRef,
92
+ } from './presentation/components/BottomSheet';
93
+
94
+ // Presentation Hooks
95
+ export {
96
+ useBottomSheet,
97
+ type UseBottomSheetReturn,
98
+ } from './presentation/hooks/useBottomSheet';