@umituz/react-native-bottom-sheet 1.2.5 → 1.2.7
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/README.md +0 -0
- package/package.json +1 -4
- package/src/domain/entities/BottomSheet.ts +0 -0
- package/src/index.ts +0 -0
- package/src/presentation/components/BottomSheet.tsx +1 -10
- package/src/presentation/components/BottomSheetModal.tsx +3 -28
- package/src/presentation/components/SafeBottomSheetModalProvider.tsx +1 -11
- package/src/presentation/hooks/useBottomSheet.ts +1 -1
- package/src/presentation/hooks/useBottomSheetModal.ts +1 -1
- package/LICENSE +0 -22
package/README.md
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-bottom-sheet",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "Modern, performant bottom sheets for React Native with preset configurations, keyboard handling, and smooth animations",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "tsc",
|
|
9
8
|
"typecheck": "tsc --noEmit",
|
|
10
9
|
"lint": "tsc --noEmit",
|
|
11
10
|
"clean": "rm -rf lib",
|
|
@@ -30,7 +29,6 @@
|
|
|
30
29
|
},
|
|
31
30
|
"peerDependencies": {
|
|
32
31
|
"@gorhom/bottom-sheet": ">=5.0.0",
|
|
33
|
-
"@umituz/react-native-animation": "*",
|
|
34
32
|
"@umituz/react-native-design-system": "*",
|
|
35
33
|
"@umituz/react-native-design-system-theme": "*",
|
|
36
34
|
"react": ">=18.2.0",
|
|
@@ -43,7 +41,6 @@
|
|
|
43
41
|
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
44
42
|
"@types/react": "^18.2.45",
|
|
45
43
|
"@types/react-native": "^0.73.0",
|
|
46
|
-
"@umituz/react-native-animation": "latest",
|
|
47
44
|
"@umituz/react-native-design-system": "latest",
|
|
48
45
|
"@umituz/react-native-design-system-theme": "latest",
|
|
49
46
|
"react": "^18.2.0",
|
|
File without changes
|
package/src/index.ts
CHANGED
|
File without changes
|
|
@@ -37,7 +37,6 @@ import GorhomBottomSheet, {
|
|
|
37
37
|
type BottomSheetBackdropProps,
|
|
38
38
|
} from '@gorhom/bottom-sheet';
|
|
39
39
|
import { useAppDesignTokens } from '@umituz/react-native-design-system-theme';
|
|
40
|
-
import { useReanimatedReady } from '@umituz/react-native-animation';
|
|
41
40
|
import type {
|
|
42
41
|
BottomSheetConfig,
|
|
43
42
|
BottomSheetPreset,
|
|
@@ -155,8 +154,6 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
|
|
|
155
154
|
) => {
|
|
156
155
|
const tokens = useAppDesignTokens();
|
|
157
156
|
const sheetRef = React.useRef<GorhomBottomSheet>(null);
|
|
158
|
-
// Don't render until Reanimated is ready to prevent layoutState.get errors
|
|
159
|
-
const isReanimatedReady = useReanimatedReady();
|
|
160
157
|
|
|
161
158
|
// Get configuration from preset or custom (must be before useImperativeHandle)
|
|
162
159
|
const config: BottomSheetConfig = useMemo(() => {
|
|
@@ -213,8 +210,7 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
|
|
|
213
210
|
[onChange, onClose]
|
|
214
211
|
);
|
|
215
212
|
|
|
216
|
-
// Expose ref methods
|
|
217
|
-
// No need to check isReanimatedReady here - component won't render if not ready
|
|
213
|
+
// Expose ref methods
|
|
218
214
|
React.useImperativeHandle(ref, () => ({
|
|
219
215
|
snapToIndex: (index: number) => {
|
|
220
216
|
sheetRef.current?.snapToIndex(index);
|
|
@@ -233,11 +229,6 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
|
|
|
233
229
|
},
|
|
234
230
|
}), []);
|
|
235
231
|
|
|
236
|
-
// Don't render until Reanimated is ready
|
|
237
|
-
if (!isReanimatedReady) {
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
232
|
// Ensure valid config
|
|
242
233
|
if (!config.snapPoints || config.snapPoints.length === 0) {
|
|
243
234
|
return null;
|
|
@@ -39,7 +39,6 @@ import {
|
|
|
39
39
|
type BottomSheetBackdropProps,
|
|
40
40
|
} from '@gorhom/bottom-sheet';
|
|
41
41
|
import { useAppDesignTokens } from '@umituz/react-native-design-system-theme';
|
|
42
|
-
import { useReanimatedReady } from '@umituz/react-native-animation';
|
|
43
42
|
import type {
|
|
44
43
|
BottomSheetConfig,
|
|
45
44
|
BottomSheetPreset,
|
|
@@ -157,8 +156,6 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
|
|
|
157
156
|
) => {
|
|
158
157
|
const tokens = useAppDesignTokens();
|
|
159
158
|
const modalRef = React.useRef<GorhomBottomSheetModal>(null);
|
|
160
|
-
// Use centralized Reanimated ready check from animation package
|
|
161
|
-
const isMounted = useReanimatedReady();
|
|
162
159
|
|
|
163
160
|
// Get configuration from preset or custom (must be before useImperativeHandle)
|
|
164
161
|
const config: BottomSheetConfig = useMemo(() => {
|
|
@@ -215,49 +212,27 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
|
|
|
215
212
|
[onChange, onDismiss]
|
|
216
213
|
);
|
|
217
214
|
|
|
218
|
-
// Expose ref methods
|
|
215
|
+
// Expose ref methods
|
|
219
216
|
React.useImperativeHandle(ref, () => ({
|
|
220
217
|
present: () => {
|
|
221
|
-
|
|
222
|
-
// useReanimatedReady() ensures GorhomBottomSheetModal is only rendered when Reanimated is ready
|
|
223
|
-
// So we can safely call present() without additional delays
|
|
224
|
-
if (isMounted && modalRef.current) {
|
|
225
|
-
modalRef.current.present();
|
|
226
|
-
}
|
|
218
|
+
modalRef.current?.present();
|
|
227
219
|
},
|
|
228
220
|
dismiss: () => {
|
|
229
|
-
if (isMounted) {
|
|
230
221
|
modalRef.current?.dismiss();
|
|
231
|
-
}
|
|
232
222
|
},
|
|
233
223
|
snapToIndex: (index: number) => {
|
|
234
|
-
if (isMounted) {
|
|
235
224
|
modalRef.current?.snapToIndex(index);
|
|
236
|
-
}
|
|
237
225
|
},
|
|
238
226
|
snapToPosition: (position: string | number) => {
|
|
239
|
-
if (isMounted) {
|
|
240
227
|
modalRef.current?.snapToPosition(position);
|
|
241
|
-
}
|
|
242
228
|
},
|
|
243
229
|
expand: () => {
|
|
244
|
-
if (isMounted) {
|
|
245
230
|
modalRef.current?.expand();
|
|
246
|
-
}
|
|
247
231
|
},
|
|
248
232
|
collapse: () => {
|
|
249
|
-
if (isMounted) {
|
|
250
233
|
modalRef.current?.collapse();
|
|
251
|
-
}
|
|
252
234
|
},
|
|
253
|
-
}));
|
|
254
|
-
|
|
255
|
-
// Don't render until mounted to prevent early hook execution
|
|
256
|
-
// This ensures @gorhom/bottom-sheet's internal hooks don't run before Reanimated is ready
|
|
257
|
-
// IMPORTANT: All hooks must be called before this early return to maintain hook order
|
|
258
|
-
if (!isMounted) {
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
235
|
+
}), []);
|
|
261
236
|
|
|
262
237
|
return (
|
|
263
238
|
<GorhomBottomSheetModal
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
|
|
19
19
|
import React from 'react';
|
|
20
20
|
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
|
|
21
|
-
import { useReanimatedReady } from '@umituz/react-native-animation';
|
|
22
21
|
|
|
23
22
|
interface SafeBottomSheetModalProviderProps {
|
|
24
23
|
children: React.ReactNode;
|
|
@@ -27,20 +26,11 @@ interface SafeBottomSheetModalProviderProps {
|
|
|
27
26
|
/**
|
|
28
27
|
* SafeBottomSheetModalProvider
|
|
29
28
|
*
|
|
30
|
-
*
|
|
31
|
-
* This prevents layoutState.get errors during initial render.
|
|
29
|
+
* Wrapper around BottomSheetModalProvider for consistency.
|
|
32
30
|
*/
|
|
33
31
|
export const SafeBottomSheetModalProvider: React.FC<SafeBottomSheetModalProviderProps> = ({
|
|
34
32
|
children,
|
|
35
33
|
}) => {
|
|
36
|
-
// Use centralized Reanimated ready check from animation package
|
|
37
|
-
const isReanimatedReady = useReanimatedReady();
|
|
38
|
-
|
|
39
|
-
// Don't render BottomSheetModalProvider until Reanimated is ready
|
|
40
|
-
if (!isReanimatedReady) {
|
|
41
|
-
return <>{children}</>;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
34
|
return <BottomSheetModalProvider>{children}</BottomSheetModalProvider>;
|
|
45
35
|
};
|
|
46
36
|
|
package/LICENSE
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Ümit UZ
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
22
|
-
|