react-native-bottom-sheet-stack 1.0.1 → 1.0.3

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.
Files changed (70) hide show
  1. package/lib/commonjs/BottomSheet.context.js.map +1 -1
  2. package/lib/commonjs/BottomSheetBackdrop.js +76 -0
  3. package/lib/commonjs/BottomSheetBackdrop.js.map +1 -0
  4. package/lib/commonjs/BottomSheetHost.js +215 -51
  5. package/lib/commonjs/BottomSheetHost.js.map +1 -1
  6. package/lib/commonjs/BottomSheetManaged.js +128 -38
  7. package/lib/commonjs/BottomSheetManaged.js.map +1 -1
  8. package/lib/commonjs/BottomSheetManager.context.js.map +1 -1
  9. package/lib/commonjs/BottomSheetManager.provider.js +38 -13
  10. package/lib/commonjs/BottomSheetManager.provider.js.map +1 -1
  11. package/lib/commonjs/BottomSheetScaleView.js +67 -0
  12. package/lib/commonjs/BottomSheetScaleView.js.map +1 -0
  13. package/lib/commonjs/animatedRegistry.js +25 -0
  14. package/lib/commonjs/animatedRegistry.js.map +1 -0
  15. package/lib/commonjs/bottomSheet.store.js +86 -73
  16. package/lib/commonjs/bottomSheet.store.js.map +1 -1
  17. package/lib/commonjs/bottomSheetCoordinator.js +12 -14
  18. package/lib/commonjs/bottomSheetCoordinator.js.map +1 -1
  19. package/lib/commonjs/index.js +3 -3
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/useBottomSheetManager.js +88 -44
  22. package/lib/commonjs/useBottomSheetManager.js.map +1 -1
  23. package/lib/commonjs/useBottomSheetState.js +40 -17
  24. package/lib/commonjs/useBottomSheetState.js.map +1 -1
  25. package/lib/commonjs/useScaleAnimation.js +108 -0
  26. package/lib/commonjs/useScaleAnimation.js.map +1 -0
  27. package/lib/typescript/example/src/App.d.ts +0 -2
  28. package/lib/typescript/example/src/App.d.ts.map +1 -1
  29. package/lib/typescript/src/BottomSheetBackdrop.d.ts +12 -0
  30. package/lib/typescript/src/BottomSheetBackdrop.d.ts.map +1 -0
  31. package/lib/typescript/src/BottomSheetHost.d.ts +2 -6
  32. package/lib/typescript/src/BottomSheetHost.d.ts.map +1 -1
  33. package/lib/typescript/src/BottomSheetManaged.d.ts.map +1 -1
  34. package/lib/typescript/src/BottomSheetManager.context.d.ts +2 -0
  35. package/lib/typescript/src/BottomSheetManager.context.d.ts.map +1 -1
  36. package/lib/typescript/src/BottomSheetManager.provider.d.ts +4 -3
  37. package/lib/typescript/src/BottomSheetManager.provider.d.ts.map +1 -1
  38. package/lib/typescript/src/BottomSheetScaleView.d.ts +18 -0
  39. package/lib/typescript/src/BottomSheetScaleView.d.ts.map +1 -0
  40. package/lib/typescript/src/animatedRegistry.d.ts +4 -0
  41. package/lib/typescript/src/animatedRegistry.d.ts.map +1 -0
  42. package/lib/typescript/src/bottomSheet.store.d.ts +6 -4
  43. package/lib/typescript/src/bottomSheet.store.d.ts.map +1 -1
  44. package/lib/typescript/src/bottomSheetCoordinator.d.ts +1 -1
  45. package/lib/typescript/src/bottomSheetCoordinator.d.ts.map +1 -1
  46. package/lib/typescript/src/index.d.ts +2 -1
  47. package/lib/typescript/src/index.d.ts.map +1 -1
  48. package/lib/typescript/src/useBottomSheetManager.d.ts.map +1 -1
  49. package/lib/typescript/src/useBottomSheetState.d.ts.map +1 -1
  50. package/lib/typescript/src/useScaleAnimation.d.ts +43 -0
  51. package/lib/typescript/src/useScaleAnimation.d.ts.map +1 -0
  52. package/package.json +9 -2
  53. package/src/BottomSheetBackdrop.tsx +61 -0
  54. package/src/BottomSheetHost.tsx +89 -51
  55. package/src/BottomSheetManaged.tsx +26 -33
  56. package/src/BottomSheetManager.context.tsx +2 -0
  57. package/src/BottomSheetManager.provider.tsx +10 -6
  58. package/src/BottomSheetScaleView.tsx +41 -0
  59. package/src/animatedRegistry.ts +22 -0
  60. package/src/bottomSheet.store.ts +132 -97
  61. package/src/bottomSheetCoordinator.ts +15 -15
  62. package/src/index.tsx +2 -4
  63. package/src/useBottomSheetManager.tsx +37 -48
  64. package/src/useBottomSheetState.ts +5 -17
  65. package/src/useScaleAnimation.ts +114 -0
  66. package/lib/commonjs/ScaleBackgroundWrapper.js +0 -69
  67. package/lib/commonjs/ScaleBackgroundWrapper.js.map +0 -1
  68. package/lib/typescript/src/ScaleBackgroundWrapper.d.ts +0 -32
  69. package/lib/typescript/src/ScaleBackgroundWrapper.d.ts.map +0 -1
  70. package/src/ScaleBackgroundWrapper.tsx +0 -98
@@ -1,32 +0,0 @@
1
- import { type PropsWithChildren } from 'react';
2
- export interface ScaleBackgroundConfig {
3
- /** Scale factor when sheet is open (default: 0.92) */
4
- scale?: number;
5
- /** Vertical translation when sheet is open (default: 10) */
6
- translateY?: number;
7
- /** Border radius when sheet is open (default: 12) */
8
- borderRadius?: number;
9
- /** Animation duration in ms (default: 300) */
10
- duration?: number;
11
- }
12
- interface ScaleBackgroundWrapperProps extends PropsWithChildren {
13
- config?: ScaleBackgroundConfig;
14
- }
15
- /**
16
- * Wraps content with iOS-style scale animation when a bottom sheet with
17
- * scaleBackground: true is open. Place your main content inside this wrapper,
18
- * but keep BottomSheetHost outside of it.
19
- *
20
- * @example
21
- * ```tsx
22
- * <BottomSheetManagerProvider id="default">
23
- * <ScaleBackgroundWrapper config={{ scale: 0.92 }}>
24
- * <MainContent />
25
- * </ScaleBackgroundWrapper>
26
- * <BottomSheetHost />
27
- * </BottomSheetManagerProvider>
28
- * ```
29
- */
30
- export declare function ScaleBackgroundWrapper({ children, config, }: ScaleBackgroundWrapperProps): import("react/jsx-runtime").JSX.Element;
31
- export {};
32
- //# sourceMappingURL=ScaleBackgroundWrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScaleBackgroundWrapper.d.ts","sourceRoot":"","sources":["../../../src/ScaleBackgroundWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAY3D,MAAM,WAAW,qBAAqB;IACpC,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,2BAA4B,SAAQ,iBAAiB;IAC7D,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,MAAM,GACP,EAAE,2BAA2B,2CA8C7B"}
@@ -1,98 +0,0 @@
1
- import { useContext, type PropsWithChildren } from 'react';
2
- import { StyleSheet } from 'react-native';
3
- import Animated, {
4
- interpolate,
5
- useAnimatedStyle,
6
- useDerivedValue,
7
- withTiming,
8
- } from 'react-native-reanimated';
9
- import { shallow } from 'zustand/shallow';
10
- import { BottomSheetManagerContext } from './BottomSheetManager.context';
11
- import { useBottomSheetStore } from './bottomSheet.store';
12
-
13
- export interface ScaleBackgroundConfig {
14
- /** Scale factor when sheet is open (default: 0.92) */
15
- scale?: number;
16
- /** Vertical translation when sheet is open (default: 10) */
17
- translateY?: number;
18
- /** Border radius when sheet is open (default: 12) */
19
- borderRadius?: number;
20
- /** Animation duration in ms (default: 300) */
21
- duration?: number;
22
- }
23
-
24
- interface ScaleBackgroundWrapperProps extends PropsWithChildren {
25
- config?: ScaleBackgroundConfig;
26
- }
27
-
28
- /**
29
- * Wraps content with iOS-style scale animation when a bottom sheet with
30
- * scaleBackground: true is open. Place your main content inside this wrapper,
31
- * but keep BottomSheetHost outside of it.
32
- *
33
- * @example
34
- * ```tsx
35
- * <BottomSheetManagerProvider id="default">
36
- * <ScaleBackgroundWrapper config={{ scale: 0.92 }}>
37
- * <MainContent />
38
- * </ScaleBackgroundWrapper>
39
- * <BottomSheetHost />
40
- * </BottomSheetManagerProvider>
41
- * ```
42
- */
43
- export function ScaleBackgroundWrapper({
44
- children,
45
- config,
46
- }: ScaleBackgroundWrapperProps) {
47
- const context = useContext(BottomSheetManagerContext);
48
- const groupId = context?.groupId ?? 'default';
49
-
50
- const {
51
- scale = 0.92,
52
- translateY = 10,
53
- borderRadius = 12,
54
- duration = 300,
55
- } = config ?? {};
56
-
57
- const hasActiveScaleSheet = useBottomSheetStore(
58
- (store) =>
59
- store.stack.some(
60
- (sheet) =>
61
- sheet.groupId === groupId &&
62
- sheet.scaleBackground &&
63
- sheet.status !== 'closing'
64
- ),
65
- shallow
66
- );
67
-
68
- const animationProgress = useDerivedValue(() =>
69
- withTiming(hasActiveScaleSheet ? 1 : 0, {
70
- duration,
71
- })
72
- );
73
-
74
- const animatedStyle = useAnimatedStyle(() => {
75
- const progress = animationProgress.value;
76
-
77
- return {
78
- transform: [
79
- { scale: interpolate(progress, [0, 1], [1, scale]) },
80
- { translateY: interpolate(progress, [0, 1], [0, translateY]) },
81
- ],
82
- borderRadius: interpolate(progress, [0, 1], [0, borderRadius]),
83
- overflow: progress > 0 ? ('hidden' as const) : ('visible' as const),
84
- };
85
- });
86
-
87
- return (
88
- <Animated.View style={[styles.scaleWrapper, animatedStyle]}>
89
- {children}
90
- </Animated.View>
91
- );
92
- }
93
-
94
- const styles = StyleSheet.create({
95
- scaleWrapper: {
96
- flex: 1,
97
- },
98
- });