react-native-bottom-sheet-stack 1.4.2 → 1.5.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.
Files changed (65) hide show
  1. package/README.md +7 -3
  2. package/lib/commonjs/BottomSheetHost.js +106 -79
  3. package/lib/commonjs/BottomSheetHost.js.map +1 -1
  4. package/lib/commonjs/BottomSheetScaleView.js +23 -14
  5. package/lib/commonjs/BottomSheetScaleView.js.map +1 -1
  6. package/lib/commonjs/bottomSheet.store.js +3 -55
  7. package/lib/commonjs/bottomSheet.store.js.map +1 -1
  8. package/lib/commonjs/useBottomSheetControl.js +12 -5
  9. package/lib/commonjs/useBottomSheetControl.js.map +1 -1
  10. package/lib/commonjs/useBottomSheetManager.js +24 -43
  11. package/lib/commonjs/useBottomSheetManager.js.map +1 -1
  12. package/lib/commonjs/useScaleAnimation.js +15 -10
  13. package/lib/commonjs/useScaleAnimation.js.map +1 -1
  14. package/lib/typescript/example/src/App.d.ts.map +1 -1
  15. package/lib/typescript/example/src/components/Badge.d.ts +9 -0
  16. package/lib/typescript/example/src/components/Badge.d.ts.map +1 -0
  17. package/lib/typescript/example/src/components/Button.d.ts +14 -0
  18. package/lib/typescript/example/src/components/Button.d.ts.map +1 -0
  19. package/lib/typescript/example/src/components/DemoCard.d.ts +14 -0
  20. package/lib/typescript/example/src/components/DemoCard.d.ts.map +1 -0
  21. package/lib/typescript/example/src/components/Sheet.d.ts +14 -0
  22. package/lib/typescript/example/src/components/Sheet.d.ts.map +1 -0
  23. package/lib/typescript/example/src/components/index.d.ts +5 -0
  24. package/lib/typescript/example/src/components/index.d.ts.map +1 -0
  25. package/lib/typescript/example/src/context/UserContext.d.ts +13 -0
  26. package/lib/typescript/example/src/context/UserContext.d.ts.map +1 -0
  27. package/lib/typescript/example/src/context/index.d.ts +2 -0
  28. package/lib/typescript/example/src/context/index.d.ts.map +1 -0
  29. package/lib/typescript/example/src/screens/HomeScreen.d.ts +2 -0
  30. package/lib/typescript/example/src/screens/HomeScreen.d.ts.map +1 -0
  31. package/lib/typescript/example/src/screens/index.d.ts +2 -0
  32. package/lib/typescript/example/src/screens/index.d.ts.map +1 -0
  33. package/lib/typescript/example/src/sheets/ContextSheets.d.ts +10 -0
  34. package/lib/typescript/example/src/sheets/ContextSheets.d.ts.map +1 -0
  35. package/lib/typescript/example/src/sheets/DynamicContentSheet.d.ts +3 -0
  36. package/lib/typescript/example/src/sheets/DynamicContentSheet.d.ts.map +1 -0
  37. package/lib/typescript/example/src/sheets/NavigationSheets.d.ts +6 -0
  38. package/lib/typescript/example/src/sheets/NavigationSheets.d.ts.map +1 -0
  39. package/lib/typescript/example/src/sheets/NestedScaleSheets.d.ts +5 -0
  40. package/lib/typescript/example/src/sheets/NestedScaleSheets.d.ts.map +1 -0
  41. package/lib/typescript/example/src/sheets/PortalModeSheets.d.ts +4 -0
  42. package/lib/typescript/example/src/sheets/PortalModeSheets.d.ts.map +1 -0
  43. package/lib/typescript/example/src/sheets/index.d.ts +6 -0
  44. package/lib/typescript/example/src/sheets/index.d.ts.map +1 -0
  45. package/lib/typescript/example/src/styles/index.d.ts +2 -0
  46. package/lib/typescript/example/src/styles/index.d.ts.map +1 -0
  47. package/lib/typescript/example/src/styles/theme.d.ts +164 -0
  48. package/lib/typescript/example/src/styles/theme.d.ts.map +1 -0
  49. package/lib/typescript/src/BottomSheetHost.d.ts.map +1 -1
  50. package/lib/typescript/src/BottomSheetScaleView.d.ts.map +1 -1
  51. package/lib/typescript/src/bottomSheet.store.d.ts +1 -8
  52. package/lib/typescript/src/bottomSheet.store.d.ts.map +1 -1
  53. package/lib/typescript/src/useBottomSheetControl.d.ts +7 -2
  54. package/lib/typescript/src/useBottomSheetControl.d.ts.map +1 -1
  55. package/lib/typescript/src/useBottomSheetManager.d.ts +0 -16
  56. package/lib/typescript/src/useBottomSheetManager.d.ts.map +1 -1
  57. package/lib/typescript/src/useScaleAnimation.d.ts +4 -1
  58. package/lib/typescript/src/useScaleAnimation.d.ts.map +1 -1
  59. package/package.json +1 -1
  60. package/src/BottomSheetHost.tsx +7 -11
  61. package/src/BottomSheetScaleView.tsx +2 -3
  62. package/src/bottomSheet.store.ts +4 -65
  63. package/src/useBottomSheetControl.ts +20 -4
  64. package/src/useBottomSheetManager.tsx +11 -26
  65. package/src/useScaleAnimation.ts +7 -2
@@ -1,6 +1,11 @@
1
- import { type BottomSheetStatus, type PortalOpenOptions } from './bottomSheet.store';
1
+ import { type BottomSheetStatus, type OpenMode } from './bottomSheet.store';
2
2
  import type { BottomSheetPortalId, BottomSheetPortalParams, HasParams } from './portal.types';
3
- type OpenOptions<T extends BottomSheetPortalId> = Omit<PortalOpenOptions<BottomSheetPortalParams<T>>, 'params'> & (HasParams<T> extends true ? {
3
+ interface BaseOpenOptions<TParams> {
4
+ mode?: OpenMode;
5
+ scaleBackground?: boolean;
6
+ params?: TParams;
7
+ }
8
+ type OpenOptions<T extends BottomSheetPortalId> = Omit<BaseOpenOptions<BottomSheetPortalParams<T>>, 'params'> & (HasParams<T> extends true ? {
4
9
  params: BottomSheetPortalParams<T>;
5
10
  } : {
6
11
  params?: BottomSheetPortalParams<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"useBottomSheetControl.d.ts","sourceRoot":"","sources":["../../../src/useBottomSheetControl.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EACV,mBAAmB,EACnB,uBAAuB,EACvB,SAAS,EACV,MAAM,gBAAgB,CAAC;AAGxB,KAAK,WAAW,CAAC,CAAC,SAAS,mBAAmB,IAAI,IAAI,CACpD,iBAAiB,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,EAC7C,QAAQ,CACT,GACC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,IAAI,GACtB;IAAE,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAA;CAAE,GACtC;IAAE,MAAM,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC,CAAC;AAE/C,KAAK,YAAY,CAAC,CAAC,SAAS,mBAAmB,IAC7C,SAAS,CAAC,CAAC,CAAC,SAAS,IAAI,GACrB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,GACjC,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAEzC,MAAM,WAAW,2BAA2B,CAAC,CAAC,SAAS,mBAAmB;IACxE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACtB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,YAAY,EAAE,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC3D,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAClC;AAED,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,mBAAmB,EACjE,EAAE,EAAE,CAAC,GACJ,2BAA2B,CAAC,CAAC,CAAC,CAyChC"}
1
+ {"version":3,"file":"useBottomSheetControl.d.ts","sourceRoot":"","sources":["../../../src/useBottomSheetControl.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EACV,mBAAmB,EACnB,uBAAuB,EACvB,SAAS,EACV,MAAM,gBAAgB,CAAC;AAGxB,UAAU,eAAe,CAAC,OAAO;IAC/B,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,KAAK,WAAW,CAAC,CAAC,SAAS,mBAAmB,IAAI,IAAI,CACpD,eAAe,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,EAC3C,QAAQ,CACT,GACC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,IAAI,GACtB;IAAE,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAA;CAAE,GACtC;IAAE,MAAM,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC,CAAC;AAE/C,KAAK,YAAY,CAAC,CAAC,SAAS,mBAAmB,IAC7C,SAAS,CAAC,CAAC,CAAC,SAAS,IAAI,GACrB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,GACjC,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAEzC,MAAM,WAAW,2BAA2B,CAAC,CAAC,SAAS,mBAAmB;IACxE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACtB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,YAAY,EAAE,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC3D,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAClC;AAED,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,mBAAmB,EACjE,EAAE,EAAE,CAAC,GACJ,2BAA2B,CAAC,CAAC,CAAC,CAmDhC"}
@@ -9,21 +9,5 @@ export declare const useBottomSheetManager: () => {
9
9
  mode?: OpenMode;
10
10
  scaleBackground?: boolean;
11
11
  }) => string;
12
- pushBottomSheet: (sheet: {
13
- groupId: string;
14
- id: string;
15
- content: React.ReactNode;
16
- scaleBackground?: boolean | undefined;
17
- usePortal?: boolean | undefined;
18
- params?: Record<string, unknown> | undefined;
19
- }) => void;
20
- replaceBottomSheet: (sheet: {
21
- groupId: string;
22
- id: string;
23
- content: React.ReactNode;
24
- scaleBackground?: boolean | undefined;
25
- usePortal?: boolean | undefined;
26
- params?: Record<string, unknown> | undefined;
27
- }) => void;
28
12
  };
29
13
  //# sourceMappingURL=useBottomSheetManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useBottomSheetManager.d.ts","sourceRoot":"","sources":["../../../src/useBottomSheetManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAuB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAMzE,eAAO,MAAM,qBAAqB;;gBA0Db,MAAM;+BArCd,KAAK,CAAC,YAAY,YAClB;QACP,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,QAAQ,CAAC;QAChB,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B;;;;;;;;;;;;;;;;;CA8CJ,CAAC"}
1
+ {"version":3,"file":"useBottomSheetManager.d.ts","sourceRoot":"","sources":["../../../src/useBottomSheetManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAuB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAMzE,eAAO,MAAM,qBAAqB;;gBA6Cb,MAAM;+BAhCd,KAAK,CAAC,YAAY,YAClB;QACP,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,QAAQ,CAAC;QAChB,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B;CAuCJ,CAAC"}
@@ -19,7 +19,10 @@ export declare function useScaleDepth(groupId: string, sheetId?: string): number
19
19
  * Returns animated style for scale effect based on depth.
20
20
  * Uses power scaling: scale^depth for cascading effect.
21
21
  */
22
- export declare function useScaleAnimatedStyle(depth: number, config?: ScaleConfig): {
22
+ export declare function useScaleAnimatedStyle({ groupId, id }: {
23
+ groupId: string;
24
+ id?: string;
25
+ }, config?: ScaleConfig): {
23
26
  transform: ({
24
27
  scale: number;
25
28
  translateY?: undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useScaleAnimation.d.ts","sourceRoot":"","sources":["../../../src/useScaleAnimation.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,WAAW;IAC1B,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;AASD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAuCvE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;EAiCxE"}
1
+ {"version":3,"file":"useScaleAnimation.d.ts","sourceRoot":"","sources":["../../../src/useScaleAnimation.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,WAAW;IAC1B,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;AASD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAuCvE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EACjD,MAAM,CAAC,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;EAoCrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-bottom-sheet-stack",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "description": "Bottom Sheet Stack Manager",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "lib/commonjs/index.js",
@@ -6,16 +6,12 @@ import { PortalHost } from 'react-native-teleport';
6
6
 
7
7
  import { shallow } from 'zustand/shallow';
8
8
  import { cleanupAnimatedIndex } from './animatedRegistry';
9
- import { BottomSheetBackdrop } from './BottomSheetBackdrop';
10
9
  import { BottomSheetContext } from './BottomSheet.context';
11
10
  import { useBottomSheetStore } from './bottomSheet.store';
12
- import { useBottomSheetManagerContext } from './BottomSheetManager.provider';
11
+ import { BottomSheetBackdrop } from './BottomSheetBackdrop';
13
12
  import { initBottomSheetCoordinator } from './bottomSheetCoordinator';
14
- import {
15
- useScaleAnimatedStyle,
16
- useScaleDepth,
17
- type ScaleConfig,
18
- } from './useScaleAnimation';
13
+ import { useBottomSheetManagerContext } from './BottomSheetManager.provider';
14
+ import { useScaleAnimatedStyle, type ScaleConfig } from './useScaleAnimation';
19
15
 
20
16
  function PortalHostWrapper({
21
17
  id,
@@ -27,7 +23,7 @@ function PortalHostWrapper({
27
23
  height: number;
28
24
  }) {
29
25
  return (
30
- <View style={{ flex: 1, width, height }}>
26
+ <View style={{ flex: 1, width, height }} pointerEvents="box-none">
31
27
  <PortalHost name={`bottomsheet-${id}`} style={{ width, height }} />
32
28
  </View>
33
29
  );
@@ -79,12 +75,12 @@ function QueueItem({
79
75
  stackIndex: number;
80
76
  }) {
81
77
  const sheet = useBottomSheetStore((state) => state.sheetsById[id]);
78
+ const startClosing = useBottomSheetStore((state) => state.startClosing);
82
79
 
83
80
  const { width, height } = useSafeAreaFrame();
84
81
  const value = { id };
85
82
 
86
- const scaleDepth = useScaleDepth(groupId, id);
87
- const scaleStyle = useScaleAnimatedStyle(scaleDepth, scaleConfig);
83
+ const scaleStyle = useScaleAnimatedStyle({ groupId, id }, scaleConfig);
88
84
 
89
85
  useEffect(() => {
90
86
  return () => {
@@ -98,7 +94,7 @@ function QueueItem({
98
94
  return (
99
95
  <BottomSheetContext.Provider value={value}>
100
96
  <View style={[StyleSheet.absoluteFillObject, { zIndex: backdropZIndex }]}>
101
- <BottomSheetBackdrop sheetId={id} />
97
+ <BottomSheetBackdrop sheetId={id} onPress={() => startClosing(id)} />
102
98
  </View>
103
99
 
104
100
  {/* Sheet content - rendered with scaling */}
@@ -2,7 +2,7 @@ import { useContext, type PropsWithChildren } from 'react';
2
2
  import { StyleSheet } from 'react-native';
3
3
  import Animated from 'react-native-reanimated';
4
4
  import { BottomSheetManagerContext } from './BottomSheetManager.context';
5
- import { useScaleAnimatedStyle, useScaleDepth } from './useScaleAnimation';
5
+ import { useScaleAnimatedStyle } from './useScaleAnimation';
6
6
 
7
7
  /**
8
8
  * Wraps your app content with iOS-style scale animation when a bottom sheet
@@ -24,8 +24,7 @@ export function BottomSheetScaleView({ children }: PropsWithChildren) {
24
24
  const groupId = context?.groupId ?? 'default';
25
25
  const scaleConfig = context?.scaleConfig;
26
26
 
27
- const scaleDepth = useScaleDepth(groupId);
28
- const animatedStyle = useScaleAnimatedStyle(scaleDepth, scaleConfig);
27
+ const animatedStyle = useScaleAnimatedStyle({ groupId }, scaleConfig);
29
28
 
30
29
  return (
31
30
  <Animated.View style={[styles.container, animatedStyle]}>
@@ -22,16 +22,8 @@ interface BottomSheetStoreState {
22
22
  stackOrder: string[];
23
23
  }
24
24
 
25
- export interface PortalOpenOptions<TParams = Record<string, unknown>> {
26
- scaleBackground?: boolean;
27
- params?: TParams;
28
- }
29
-
30
25
  interface BottomSheetStoreActions {
31
- push(sheet: TriggerState): void;
32
- switch(sheet: TriggerState): void;
33
- replace(sheet: TriggerState): void;
34
- openPortal(id: string, groupId: string, options?: PortalOpenOptions): void;
26
+ open(sheet: TriggerState, mode?: OpenMode): void;
35
27
  markOpen(id: string): void;
36
28
  startClosing(id: string): void;
37
29
  finishClosing(id: string): void;
@@ -46,21 +38,7 @@ export const useBottomSheetStore = create(
46
38
  sheetsById: {},
47
39
  stackOrder: [],
48
40
 
49
- push: (sheet) =>
50
- set((state) => {
51
- if (state.sheetsById[sheet.id]) {
52
- return state;
53
- }
54
- return {
55
- sheetsById: {
56
- ...state.sheetsById,
57
- [sheet.id]: { ...sheet, status: 'opening' },
58
- },
59
- stackOrder: [...state.stackOrder, sheet.id],
60
- };
61
- }),
62
-
63
- switch: (sheet) =>
41
+ open: (sheet, mode = 'push') =>
64
42
  set((state) => {
65
43
  if (state.sheetsById[sheet.id]) {
66
44
  return state;
@@ -69,31 +47,14 @@ export const useBottomSheetStore = create(
69
47
  const newSheetsById = { ...state.sheetsById };
70
48
  const topId = state.stackOrder[state.stackOrder.length - 1];
71
49
 
72
- if (topId && newSheetsById[topId]) {
50
+ if (mode === 'switch' && topId && newSheetsById[topId]) {
73
51
  newSheetsById[topId] = {
74
52
  ...newSheetsById[topId],
75
53
  status: 'hidden',
76
54
  };
77
55
  }
78
56
 
79
- newSheetsById[sheet.id] = { ...sheet, status: 'opening' };
80
-
81
- return {
82
- sheetsById: newSheetsById,
83
- stackOrder: [...state.stackOrder, sheet.id],
84
- };
85
- }),
86
-
87
- replace: (sheet) =>
88
- set((state) => {
89
- if (state.sheetsById[sheet.id]) {
90
- return state;
91
- }
92
-
93
- const newSheetsById = { ...state.sheetsById };
94
- const topId = state.stackOrder[state.stackOrder.length - 1];
95
-
96
- if (topId && newSheetsById[topId]) {
57
+ if (mode === 'replace' && topId && newSheetsById[topId]) {
97
58
  newSheetsById[topId] = {
98
59
  ...newSheetsById[topId],
99
60
  status: 'closing',
@@ -108,28 +69,6 @@ export const useBottomSheetStore = create(
108
69
  };
109
70
  }),
110
71
 
111
- openPortal: (id, groupId, options) =>
112
- set((state) => {
113
- if (state.sheetsById[id]) {
114
- return state;
115
- }
116
- return {
117
- sheetsById: {
118
- ...state.sheetsById,
119
- [id]: {
120
- id,
121
- groupId,
122
- content: null,
123
- status: 'opening',
124
- usePortal: true,
125
- scaleBackground: options?.scaleBackground,
126
- params: options?.params,
127
- },
128
- },
129
- stackOrder: [...state.stackOrder, id],
130
- };
131
- }),
132
-
133
72
  markOpen: (id) =>
134
73
  set((state) => {
135
74
  const sheet = state.sheetsById[id];
@@ -4,7 +4,7 @@ import type { BottomSheetMethods } from '@gorhom/bottom-sheet/lib/typescript/typ
4
4
  import {
5
5
  useBottomSheetStore,
6
6
  type BottomSheetStatus,
7
- type PortalOpenOptions,
7
+ type OpenMode,
8
8
  } from './bottomSheet.store';
9
9
  import { useMaybeBottomSheetManagerContext } from './BottomSheetManager.provider';
10
10
  import type {
@@ -14,8 +14,14 @@ import type {
14
14
  } from './portal.types';
15
15
  import { sheetRefs } from './refsMap';
16
16
 
17
+ interface BaseOpenOptions<TParams> {
18
+ mode?: OpenMode;
19
+ scaleBackground?: boolean;
20
+ params?: TParams;
21
+ }
22
+
17
23
  type OpenOptions<T extends BottomSheetPortalId> = Omit<
18
- PortalOpenOptions<BottomSheetPortalParams<T>>,
24
+ BaseOpenOptions<BottomSheetPortalParams<T>>,
19
25
  'params'
20
26
  > &
21
27
  (HasParams<T> extends true
@@ -41,7 +47,7 @@ export function useBottomSheetControl<T extends BottomSheetPortalId>(
41
47
  ): UseBottomSheetControlReturn<T> {
42
48
  const bottomSheetManagerContext = useMaybeBottomSheetManagerContext();
43
49
 
44
- const openPortal = useBottomSheetStore((state) => state.openPortal);
50
+ const storeOpen = useBottomSheetStore((state) => state.open);
45
51
  const startClosing = useBottomSheetStore((state) => state.startClosing);
46
52
  const storeUpdateParams = useBottomSheetStore((state) => state.updateParams);
47
53
  const sheetState = useBottomSheetStore((state) => state.sheetsById[id]);
@@ -53,7 +59,17 @@ export function useBottomSheetControl<T extends BottomSheetPortalId>(
53
59
  const ref = React.createRef<BottomSheetMethods>();
54
60
  sheetRefs[id] = ref;
55
61
 
56
- openPortal(id, groupId, options);
62
+ storeOpen(
63
+ {
64
+ id,
65
+ groupId,
66
+ content: null,
67
+ usePortal: true,
68
+ scaleBackground: options?.scaleBackground,
69
+ params: options?.params as Record<string, unknown>,
70
+ },
71
+ options?.mode
72
+ );
57
73
  };
58
74
 
59
75
  const close = () => {
@@ -9,18 +9,10 @@ import { shallow } from 'zustand/shallow';
9
9
  export const useBottomSheetManager = () => {
10
10
  const bottomSheetManagerContext = useMaybeBottomSheetManagerContext();
11
11
 
12
- const {
13
- pushBottomSheet,
14
- replaceBottomSheet,
15
- switchBottomSheet,
16
- startClosing,
17
- storeClearAll,
18
- } = useBottomSheetStore(
12
+ const { storeOpen, startClosing, storeClearAll } = useBottomSheetStore(
19
13
  (store) => ({
14
+ storeOpen: store.open,
20
15
  storeClearAll: store.clearAll,
21
- replaceBottomSheet: store.replace,
22
- pushBottomSheet: store.push,
23
- switchBottomSheet: store.switch,
24
16
  startClosing: store.startClosing,
25
17
  }),
26
18
  shallow
@@ -46,20 +38,15 @@ export const useBottomSheetManager = () => {
46
38
  // @ts-ignore
47
39
  const contentWithRef = React.cloneElement(content, { ref });
48
40
 
49
- const sheetData = {
50
- id,
51
- groupId,
52
- content: contentWithRef,
53
- scaleBackground: options.scaleBackground,
54
- };
55
-
56
- if (options.mode === 'replace') {
57
- replaceBottomSheet(sheetData);
58
- } else if (options.mode === 'switch') {
59
- switchBottomSheet(sheetData);
60
- } else {
61
- pushBottomSheet(sheetData);
62
- }
41
+ storeOpen(
42
+ {
43
+ id,
44
+ groupId,
45
+ content: contentWithRef,
46
+ scaleBackground: options.scaleBackground,
47
+ },
48
+ options.mode
49
+ );
63
50
 
64
51
  return id;
65
52
  };
@@ -76,7 +63,5 @@ export const useBottomSheetManager = () => {
76
63
  clearAll,
77
64
  close,
78
65
  openBottomSheet,
79
- pushBottomSheet,
80
- replaceBottomSheet,
81
66
  };
82
67
  };
@@ -78,7 +78,12 @@ export function useScaleDepth(groupId: string, sheetId?: string): number {
78
78
  * Returns animated style for scale effect based on depth.
79
79
  * Uses power scaling: scale^depth for cascading effect.
80
80
  */
81
- export function useScaleAnimatedStyle(depth: number, config?: ScaleConfig) {
81
+ export function useScaleAnimatedStyle(
82
+ { groupId, id }: { groupId: string; id?: string },
83
+ config?: ScaleConfig
84
+ ) {
85
+ const scaleDepth = useScaleDepth(groupId, id);
86
+
82
87
  const {
83
88
  scale = DEFAULT_CONFIG.scale,
84
89
  translateY = DEFAULT_CONFIG.translateY,
@@ -87,7 +92,7 @@ export function useScaleAnimatedStyle(depth: number, config?: ScaleConfig) {
87
92
  } = config ?? {};
88
93
 
89
94
  const progress = useDerivedValue(() => {
90
- return withTiming(depth, { duration });
95
+ return withTiming(scaleDepth, { duration });
91
96
  });
92
97
 
93
98
  return useAnimatedStyle(() => {