react-native-bottom-sheet-stack 1.7.6 → 1.9.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 (112) hide show
  1. package/lib/commonjs/BottomSheetManaged.js +5 -172
  2. package/lib/commonjs/BottomSheetManaged.js.map +1 -1
  3. package/lib/commonjs/BottomSheetPersistent.js.map +1 -1
  4. package/lib/commonjs/BottomSheetRef.context.js.map +1 -1
  5. package/lib/commonjs/adapter.types.js +6 -0
  6. package/lib/commonjs/adapter.types.js.map +1 -0
  7. package/lib/commonjs/adapters/actions-sheet/ActionsSheetAdapter.js +137 -0
  8. package/lib/commonjs/adapters/actions-sheet/ActionsSheetAdapter.js.map +1 -0
  9. package/lib/commonjs/adapters/actions-sheet/index.js +13 -0
  10. package/lib/commonjs/adapters/actions-sheet/index.js.map +1 -0
  11. package/lib/commonjs/adapters/custom-modal/CustomModalAdapter.js +136 -0
  12. package/lib/commonjs/adapters/custom-modal/CustomModalAdapter.js.map +1 -0
  13. package/lib/commonjs/adapters/custom-modal/index.js +19 -0
  14. package/lib/commonjs/adapters/custom-modal/index.js.map +1 -0
  15. package/lib/commonjs/adapters/gorhom-sheet/GorhomSheetAdapter.js +189 -0
  16. package/lib/commonjs/adapters/gorhom-sheet/GorhomSheetAdapter.js.map +1 -0
  17. package/lib/commonjs/adapters/gorhom-sheet/index.js +13 -0
  18. package/lib/commonjs/adapters/gorhom-sheet/index.js.map +1 -0
  19. package/lib/commonjs/adapters/index.js +40 -0
  20. package/lib/commonjs/adapters/index.js.map +1 -0
  21. package/lib/commonjs/adapters/react-native-modal/ReactNativeModalAdapter.js +119 -0
  22. package/lib/commonjs/adapters/react-native-modal/ReactNativeModalAdapter.js.map +1 -0
  23. package/lib/commonjs/adapters/react-native-modal/index.js +13 -0
  24. package/lib/commonjs/adapters/react-native-modal/index.js.map +1 -0
  25. package/lib/commonjs/animatedRegistry.js +11 -1
  26. package/lib/commonjs/animatedRegistry.js.map +1 -1
  27. package/lib/commonjs/bottomSheetCoordinator.js +29 -22
  28. package/lib/commonjs/bottomSheetCoordinator.js.map +1 -1
  29. package/lib/commonjs/index.js +75 -1
  30. package/lib/commonjs/index.js.map +1 -1
  31. package/lib/commonjs/refsMap.js.map +1 -1
  32. package/lib/commonjs/useAdapterRef.js +29 -0
  33. package/lib/commonjs/useAdapterRef.js.map +1 -0
  34. package/lib/commonjs/useAnimatedIndex.js +47 -0
  35. package/lib/commonjs/useAnimatedIndex.js.map +1 -0
  36. package/lib/commonjs/useBackHandler.js +59 -0
  37. package/lib/commonjs/useBackHandler.js.map +1 -0
  38. package/lib/commonjs/useBottomSheetControl.js.map +1 -1
  39. package/lib/commonjs/useBottomSheetManager.js.map +1 -1
  40. package/lib/typescript/example/src/App.d.ts.map +1 -1
  41. package/lib/typescript/example/src/screens/HomeScreen.d.ts.map +1 -1
  42. package/lib/typescript/example/src/sheets/ContextSheets.d.ts.map +1 -1
  43. package/lib/typescript/example/src/sheets/ModalSheets.d.ts +8 -0
  44. package/lib/typescript/example/src/sheets/ModalSheets.d.ts.map +1 -0
  45. package/lib/typescript/example/src/sheets/PersistentMixedAdapters.d.ts +2 -0
  46. package/lib/typescript/example/src/sheets/PersistentMixedAdapters.d.ts.map +1 -0
  47. package/lib/typescript/example/src/sheets/ThirdPartyAdapterSheets.d.ts +17 -0
  48. package/lib/typescript/example/src/sheets/ThirdPartyAdapterSheets.d.ts.map +1 -0
  49. package/lib/typescript/example/src/sheets/index.d.ts +3 -0
  50. package/lib/typescript/example/src/sheets/index.d.ts.map +1 -1
  51. package/lib/typescript/src/BottomSheetManaged.d.ts +10 -9
  52. package/lib/typescript/src/BottomSheetManaged.d.ts.map +1 -1
  53. package/lib/typescript/src/BottomSheetPersistent.d.ts.map +1 -1
  54. package/lib/typescript/src/BottomSheetRef.context.d.ts +1 -4
  55. package/lib/typescript/src/BottomSheetRef.context.d.ts.map +1 -1
  56. package/lib/typescript/src/adapter.types.d.ts +33 -0
  57. package/lib/typescript/src/adapter.types.d.ts.map +1 -0
  58. package/lib/typescript/src/adapters/actions-sheet/ActionsSheetAdapter.d.ts +23 -0
  59. package/lib/typescript/src/adapters/actions-sheet/ActionsSheetAdapter.d.ts.map +1 -0
  60. package/lib/typescript/src/adapters/actions-sheet/index.d.ts +2 -0
  61. package/lib/typescript/src/adapters/actions-sheet/index.d.ts.map +1 -0
  62. package/lib/typescript/src/adapters/custom-modal/CustomModalAdapter.d.ts +9 -0
  63. package/lib/typescript/src/adapters/custom-modal/CustomModalAdapter.d.ts.map +1 -0
  64. package/lib/typescript/src/adapters/custom-modal/index.d.ts +4 -0
  65. package/lib/typescript/src/adapters/custom-modal/index.d.ts.map +1 -0
  66. package/lib/typescript/src/adapters/gorhom-sheet/GorhomSheetAdapter.d.ts +7 -0
  67. package/lib/typescript/src/adapters/gorhom-sheet/GorhomSheetAdapter.d.ts.map +1 -0
  68. package/lib/typescript/src/adapters/gorhom-sheet/index.d.ts +2 -0
  69. package/lib/typescript/src/adapters/gorhom-sheet/index.d.ts.map +1 -0
  70. package/lib/typescript/src/adapters/index.d.ts +5 -0
  71. package/lib/typescript/src/adapters/index.d.ts.map +1 -0
  72. package/lib/typescript/src/adapters/react-native-modal/ReactNativeModalAdapter.d.ts +22 -0
  73. package/lib/typescript/src/adapters/react-native-modal/ReactNativeModalAdapter.d.ts.map +1 -0
  74. package/lib/typescript/src/adapters/react-native-modal/index.d.ts +2 -0
  75. package/lib/typescript/src/adapters/react-native-modal/index.d.ts.map +1 -0
  76. package/lib/typescript/src/animatedRegistry.d.ts +4 -0
  77. package/lib/typescript/src/animatedRegistry.d.ts.map +1 -1
  78. package/lib/typescript/src/bottomSheetCoordinator.d.ts +13 -7
  79. package/lib/typescript/src/bottomSheetCoordinator.d.ts.map +1 -1
  80. package/lib/typescript/src/index.d.ts +12 -0
  81. package/lib/typescript/src/index.d.ts.map +1 -1
  82. package/lib/typescript/src/refsMap.d.ts +1 -4
  83. package/lib/typescript/src/refsMap.d.ts.map +1 -1
  84. package/lib/typescript/src/useAdapterRef.d.ts +21 -0
  85. package/lib/typescript/src/useAdapterRef.d.ts.map +1 -0
  86. package/lib/typescript/src/useAnimatedIndex.d.ts +25 -0
  87. package/lib/typescript/src/useAnimatedIndex.d.ts.map +1 -0
  88. package/lib/typescript/src/useBackHandler.d.ts +8 -0
  89. package/lib/typescript/src/useBackHandler.d.ts.map +1 -0
  90. package/package.json +33 -2
  91. package/src/BottomSheetManaged.tsx +14 -106
  92. package/src/BottomSheetPersistent.tsx +2 -2
  93. package/src/BottomSheetRef.context.ts +2 -4
  94. package/src/adapter.types.ts +35 -0
  95. package/src/adapters/actions-sheet/ActionsSheetAdapter.tsx +83 -0
  96. package/src/adapters/actions-sheet/index.ts +4 -0
  97. package/src/adapters/custom-modal/CustomModalAdapter.tsx +117 -0
  98. package/src/adapters/custom-modal/index.ts +7 -0
  99. package/src/adapters/gorhom-sheet/GorhomSheetAdapter.tsx +121 -0
  100. package/src/adapters/gorhom-sheet/index.ts +4 -0
  101. package/src/adapters/index.ts +17 -0
  102. package/src/adapters/react-native-modal/ReactNativeModalAdapter.tsx +81 -0
  103. package/src/adapters/react-native-modal/index.ts +4 -0
  104. package/src/animatedRegistry.ts +10 -1
  105. package/src/bottomSheetCoordinator.ts +32 -24
  106. package/src/index.tsx +34 -0
  107. package/src/refsMap.ts +1 -4
  108. package/src/useAdapterRef.ts +28 -0
  109. package/src/useAnimatedIndex.ts +31 -0
  110. package/src/useBackHandler.ts +32 -0
  111. package/src/useBottomSheetControl.ts +2 -2
  112. package/src/useBottomSheetManager.tsx +2 -2
@@ -1,6 +1,10 @@
1
1
  import { type SharedValue } from 'react-native-reanimated';
2
2
  export declare function ensureAnimatedIndex(sheetId: string): SharedValue<number>;
3
3
  export declare function getAnimatedIndex(sheetId: string): SharedValue<number> | undefined;
4
+ /**
5
+ * Set the animated index value for a sheet.
6
+ */
7
+ export declare function setAnimatedIndexValue(sheetId: string, value: number): void;
4
8
  export declare function cleanupAnimatedIndex(sheetId: string): void;
5
9
  /**
6
10
  * Reset all animated indexes. Useful for testing.
@@ -1 +1 @@
1
- {"version":3,"file":"animatedRegistry.d.ts","sourceRoot":"","sources":["../../../src/animatedRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AASxE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CASxE;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,GACd,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAGjC;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAE1E"}
1
+ {"version":3,"file":"animatedRegistry.d.ts","sourceRoot":"","sources":["../../../src/animatedRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AASxE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CASxE;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,GACd,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAEjC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAK1E;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAE1E"}
@@ -1,11 +1,17 @@
1
+ import type { SheetAdapterEvents } from './adapter.types';
2
+ /**
3
+ * Subscribes to store changes and calls adapter ref methods.
4
+ * Direction: Store → Adapter (via SheetAdapterRef)
5
+ */
1
6
  export declare function initBottomSheetCoordinator(groupId: string): () => void;
2
7
  /**
3
- * Creates event handlers for a bottom sheet that sync gorhom events back to the store.
4
- * Direction: Gorhom Events → Store
8
+ * Creates event handlers that adapters call to sync UI state back to the store.
9
+ * Direction: Adapter Events → Store
10
+ *
11
+ * Adapters must call:
12
+ * - `handleDismiss()` when the user initiates dismissal (swipe, backdrop tap, back button)
13
+ * - `handleOpened()` when the show animation completes
14
+ * - `handleClosed()` when the hide animation completes
5
15
  */
6
- export declare function createSheetEventHandlers(sheetId: string): {
7
- handleAnimate: (_fromIndex: number, toIndex: number) => void;
8
- handleChange: (index: number) => void;
9
- handleClose: () => void;
10
- };
16
+ export declare function createSheetEventHandlers(sheetId: string): SheetAdapterEvents;
11
17
  //# sourceMappingURL=bottomSheetCoordinator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bottomSheetCoordinator.d.ts","sourceRoot":"","sources":["../../../src/bottomSheetCoordinator.ts"],"names":[],"mappings":"AAGA,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,cA8BzD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM;gCAInB,MAAM,WAAW,MAAM;0BAY7B,MAAM;;EAuBpC"}
1
+ {"version":3,"file":"bottomSheetCoordinator.d.ts","sourceRoot":"","sources":["../../../src/bottomSheetCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAI1D;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,cAkCzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAiC5E"}
@@ -4,6 +4,18 @@ export { BottomSheetScaleView } from './BottomSheetScaleView';
4
4
  export { BottomSheetManaged, type BottomSheetRef } from './BottomSheetManaged';
5
5
  export { BottomSheetPortal } from './BottomSheetPortal';
6
6
  export { BottomSheetPersistent } from './BottomSheetPersistent';
7
+ export { GorhomSheetAdapter, type GorhomSheetAdapterProps, } from './adapters/gorhom-sheet';
8
+ export { CustomModalAdapter, type ModalAdapterProps, } from './adapters/custom-modal';
9
+ /** @deprecated Use `CustomModalAdapter` instead. */
10
+ export { ModalAdapter } from './adapters/custom-modal';
11
+ export { ReactNativeModalAdapter, type ReactNativeModalAdapterProps, } from './adapters/react-native-modal';
12
+ export { ActionsSheetAdapter, type ActionsSheetAdapterProps, } from './adapters/actions-sheet';
13
+ export type { SheetAdapterRef, SheetAdapterEvents, SheetRef, } from './adapter.types';
14
+ export { createSheetEventHandlers } from './bottomSheetCoordinator';
15
+ export { useAdapterRef } from './useAdapterRef';
16
+ export { useAnimatedIndex } from './useAnimatedIndex';
17
+ export { useBackHandler } from './useBackHandler';
18
+ export { getAnimatedIndex, setAnimatedIndexValue } from './animatedRegistry';
7
19
  export { useBottomSheetManager } from './useBottomSheetManager';
8
20
  export { useBottomSheetControl, type UseBottomSheetControlReturn, } from './useBottomSheetControl';
9
21
  export { useBottomSheetContext, useBottomSheetState, type UseBottomSheetContextReturn, } from './useBottomSheetContext';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;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B,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -1,6 +1,4 @@
1
- import type { BottomSheetMethods } from '@gorhom/bottom-sheet/lib/typescript/types';
2
- import type { RefObject } from 'react';
3
- type SheetRef = RefObject<BottomSheetMethods | null>;
1
+ import type { SheetRef } from './adapter.types';
4
2
  export declare function getSheetRef(sheetId: string): SheetRef | undefined;
5
3
  export declare function setSheetRef(sheetId: string, ref: SheetRef): void;
6
4
  export declare function cleanupSheetRef(sheetId: string): void;
@@ -9,5 +7,4 @@ export declare function cleanupSheetRef(sheetId: string): void;
9
7
  * @internal
10
8
  */
11
9
  export declare function __resetSheetRefs(): void;
12
- export {};
13
10
  //# sourceMappingURL=refsMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"refsMap.d.ts","sourceRoot":"","sources":["../../../src/refsMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,KAAK,QAAQ,GAAG,SAAS,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;AAIrD,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAEjE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,CAEhE;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAErD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
1
+ {"version":3,"file":"refsMap.d.ts","sourceRoot":"","sources":["../../../src/refsMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAIhD,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAEjE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,CAEhE;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAErD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
@@ -0,0 +1,21 @@
1
+ import type { ForwardedRef } from 'react';
2
+ import type { SheetAdapterRef, SheetRef } from './adapter.types';
3
+ /**
4
+ * Returns the correct ref for a custom adapter.
5
+ *
6
+ * Handles the internal ref routing between portal/persistent mode
7
+ * (where the ref comes from context) and inline mode (where the ref
8
+ * is forwarded by `useBottomSheetManager`).
9
+ *
10
+ * Usage:
11
+ * ```tsx
12
+ * const MyAdapter = React.forwardRef<SheetAdapterRef, Props>(
13
+ * ({ children }, forwardedRef) => {
14
+ * const ref = useAdapterRef(forwardedRef);
15
+ * useImperativeHandle(ref, () => ({ expand: ..., close: ... }));
16
+ * }
17
+ * );
18
+ * ```
19
+ */
20
+ export declare function useAdapterRef(forwardedRef: ForwardedRef<SheetAdapterRef>): SheetRef | ForwardedRef<SheetAdapterRef>;
21
+ //# sourceMappingURL=useAdapterRef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAdapterRef.d.ts","sourceRoot":"","sources":["../../../src/useAdapterRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGjE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC3B,YAAY,EAAE,YAAY,CAAC,eAAe,CAAC,GAC1C,QAAQ,GAAG,YAAY,CAAC,eAAe,CAAC,CAG1C"}
@@ -0,0 +1,25 @@
1
+ import type { SharedValue } from 'react-native-reanimated';
2
+ /**
3
+ * Returns the `animatedIndex` shared value for the current sheet.
4
+ *
5
+ * The value drives backdrop opacity and scale animations:
6
+ * - `-1` = hidden (backdrop transparent)
7
+ * - `0` = fully visible (backdrop opaque)
8
+ *
9
+ * **Binary strategy** — set to `0` on expand and `-1` on close:
10
+ * ```ts
11
+ * const animatedIndex = useAnimatedIndex();
12
+ * // in expand: animatedIndex.set(0);
13
+ * // in close: animatedIndex.set(-1);
14
+ * ```
15
+ *
16
+ * **Continuous strategy** — pass directly to a library that updates it during gestures:
17
+ * ```ts
18
+ * const animatedIndex = useAnimatedIndex();
19
+ * <SomeSheet animatedIndex={animatedIndex} />
20
+ * ```
21
+ *
22
+ * Must be called inside a sheet component (within `BottomSheetContext`).
23
+ */
24
+ export declare function useAnimatedIndex(): SharedValue<number>;
25
+ //# sourceMappingURL=useAnimatedIndex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnimatedIndex.d.ts","sourceRoot":"","sources":["../../../src/useAnimatedIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAK3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,IAAI,WAAW,CAAC,MAAM,CAAC,CAGtD"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Manages Android hardware back button for a sheet.
3
+ *
4
+ * The listener is only active when the sheet is fully open
5
+ * AND is the topmost sheet in the stack.
6
+ */
7
+ export declare function useBackHandler(id: string, onBackPress: () => void): void;
8
+ //# sourceMappingURL=useBackHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBackHandler.d.ts","sourceRoot":"","sources":["../../../src/useBackHandler.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,IAAI,GAAG,IAAI,CAoBxE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-bottom-sheet-stack",
3
- "version": "1.7.6",
3
+ "version": "1.9.0",
4
4
  "description": "Bottom Sheet Stack Manager",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "lib/commonjs/index.js",
@@ -73,12 +73,29 @@
73
73
  "@gorhom/bottom-sheet": ">=5.0.0",
74
74
  "react": "*",
75
75
  "react-native": "*",
76
+ "react-native-actions-sheet": ">=0.9.0",
76
77
  "react-native-gesture-handler": ">=2.0.0",
78
+ "react-native-modal": ">=11.0.0",
77
79
  "react-native-reanimated": ">=3.0.0",
78
80
  "react-native-safe-area-context": ">=5.0.0",
79
81
  "react-native-teleport": ">=0.5.0",
82
+ "react-native-worklets": ">=0.7.0",
80
83
  "zustand": ">=5.0.0"
81
84
  },
85
+ "peerDependenciesMeta": {
86
+ "@gorhom/bottom-sheet": {
87
+ "optional": true
88
+ },
89
+ "react-native-actions-sheet": {
90
+ "optional": true
91
+ },
92
+ "react-native-gesture-handler": {
93
+ "optional": true
94
+ },
95
+ "react-native-modal": {
96
+ "optional": true
97
+ }
98
+ },
82
99
  "workspaces": [
83
100
  "example"
84
101
  ],
@@ -109,7 +126,21 @@
109
126
  "plugins": {
110
127
  "@release-it/conventional-changelog": {
111
128
  "preset": {
112
- "name": "angular"
129
+ "name": "conventionalcommits",
130
+ "types": [
131
+ {
132
+ "type": "feat",
133
+ "section": "Features"
134
+ },
135
+ {
136
+ "type": "fix",
137
+ "section": "Bug Fixes"
138
+ },
139
+ {
140
+ "type": "perf",
141
+ "section": "Performance"
142
+ }
143
+ ]
113
144
  }
114
145
  }
115
146
  }
@@ -1,106 +1,14 @@
1
- import BottomSheetOriginal, {
2
- useBottomSheetSpringConfigs,
3
- type BottomSheetProps,
4
- } from '@gorhom/bottom-sheet';
5
- import { type BottomSheetMethods } from '@gorhom/bottom-sheet/lib/typescript/types';
6
- import React from 'react';
7
-
8
- import { useAnimatedReaction } from 'react-native-reanimated';
9
- import { getAnimatedIndex } from './animatedRegistry';
10
- import { createSheetEventHandlers } from './bottomSheetCoordinator';
11
- import { useBottomSheetDefaultIndex } from './BottomSheetDefaultIndex.context';
12
- import { useBottomSheetRefContext } from './BottomSheetRef.context';
13
- import { useBottomSheetContext } from './useBottomSheetContext';
14
-
15
- export interface BottomSheetRef extends BottomSheetMethods {}
16
-
17
- interface BottomSheetManagedProps extends BottomSheetProps {}
18
-
19
- const nullBackdrop = () => null;
20
-
21
- export const BottomSheetManaged = React.forwardRef<
22
- BottomSheetRef,
23
- BottomSheetManagedProps
24
- >(
25
- (
26
- {
27
- children,
28
- onAnimate,
29
- onChange,
30
- onClose,
31
- enablePanDownToClose = true,
32
- backdropComponent = nullBackdrop,
33
- animatedIndex: externalAnimatedIndex,
34
- ...props
35
- },
36
- forwardedRef
37
- ) => {
38
- const { id } = useBottomSheetContext();
39
- const contextRef = useBottomSheetRefContext();
40
- const ref = contextRef ?? forwardedRef;
41
-
42
- const defaultIndex = useBottomSheetDefaultIndex();
43
- const contextAnimatedIndex = getAnimatedIndex(id);
44
-
45
- if (!contextAnimatedIndex) {
46
- throw new Error('animatedIndex must be defined in BottomSheetManaged');
47
- }
48
-
49
- useAnimatedReaction(
50
- () => contextAnimatedIndex.value,
51
- (value) => {
52
- externalAnimatedIndex?.set(value);
53
- }
54
- );
55
-
56
- const { handleAnimate, handleChange, handleClose } =
57
- createSheetEventHandlers(id);
58
-
59
- const wrappedOnAnimate: BottomSheetProps['onAnimate'] = (
60
- fromIndex,
61
- toIndex,
62
- fromPosition,
63
- toPosition
64
- ) => {
65
- handleAnimate(fromIndex, toIndex);
66
- onAnimate?.(fromIndex, toIndex, fromPosition, toPosition);
67
- };
68
-
69
- const wrappedOnChange: BottomSheetProps['onChange'] = (
70
- index,
71
- position,
72
- type
73
- ) => {
74
- handleChange(index);
75
- onChange?.(index, position, type);
76
- };
77
-
78
- const wrappedOnClose = () => {
79
- onClose?.();
80
- handleClose();
81
- };
82
-
83
- const config = useBottomSheetSpringConfigs({
84
- stiffness: 400,
85
- damping: 80,
86
- mass: 0.7,
87
- });
88
-
89
- return (
90
- <BottomSheetOriginal
91
- animationConfigs={config}
92
- ref={ref}
93
- {...props}
94
- index={defaultIndex}
95
- animatedIndex={contextAnimatedIndex}
96
- onChange={wrappedOnChange}
97
- onClose={wrappedOnClose}
98
- onAnimate={wrappedOnAnimate}
99
- backdropComponent={backdropComponent}
100
- enablePanDownToClose={enablePanDownToClose}
101
- >
102
- {children}
103
- </BottomSheetOriginal>
104
- );
105
- }
106
- );
1
+ /**
2
+ * Backward-compatible re-export of GorhomSheetAdapter.
3
+ *
4
+ * Existing users can continue importing `BottomSheetManaged` and `BottomSheetRef`
5
+ * without any changes. For new code, prefer importing `GorhomSheetAdapter` directly
6
+ * from 'react-native-bottom-sheet-stack/adapters/gorhom' or use the `ModalAdapter`
7
+ * for modal-based sheets.
8
+ */
9
+ export {
10
+ GorhomSheetAdapter as BottomSheetManaged,
11
+ type GorhomSheetAdapterProps as BottomSheetManagedProps,
12
+ } from './adapters/gorhom-sheet';
13
+
14
+ export type { SheetAdapterRef as BottomSheetRef } from './adapter.types';
@@ -1,5 +1,5 @@
1
- import type { BottomSheetMethods } from '@gorhom/bottom-sheet/lib/typescript/types';
2
1
  import React, { useEffect, useRef } from 'react';
2
+ import type { SheetAdapterRef } from './adapter.types';
3
3
 
4
4
  import { Portal } from 'react-native-teleport';
5
5
  import { BottomSheetContext } from './BottomSheet.context';
@@ -30,7 +30,7 @@ export function BottomSheetPersistent({
30
30
  const unmount = useUnmount();
31
31
  const sheetExists = useSheetExists(id);
32
32
  const portalSession = useSheetPortalSession(id);
33
- const sheetRef = useRef<BottomSheetMethods>(null);
33
+ const sheetRef = useRef<SheetAdapterRef>(null);
34
34
  const groupId = bottomSheetManagerContext?.groupId || 'default';
35
35
 
36
36
  const mountSheet = useEvent(() => {
@@ -1,7 +1,5 @@
1
- import { createContext, useContext, type RefObject } from 'react';
2
- import type { BottomSheetMethods } from '@gorhom/bottom-sheet/lib/typescript/types';
3
-
4
- type SheetRef = RefObject<BottomSheetMethods | null>;
1
+ import { createContext, useContext } from 'react';
2
+ import type { SheetRef } from './adapter.types';
5
3
 
6
4
  /**
7
5
  * Context for passing sheet ref from BottomSheetPersistent/BottomSheetPortal
@@ -0,0 +1,35 @@
1
+ import type { RefObject } from 'react';
2
+
3
+ /**
4
+ * Minimal ref interface for controlling a sheet/modal/overlay.
5
+ * Every adapter must implement these two methods.
6
+ *
7
+ * The coordinator calls:
8
+ * - `expand()` when status transitions to 'opening'
9
+ * - `close()` when status transitions to 'closing' or 'hidden'
10
+ */
11
+ export interface SheetAdapterRef {
12
+ expand(): void;
13
+ close(): void;
14
+ }
15
+
16
+ /**
17
+ * Event handlers that adapters MUST call to sync UI state back to the store.
18
+ * Returned by `createSheetEventHandlers(sheetId)`.
19
+ *
20
+ * Lifecycle:
21
+ * 1. Coordinator calls `ref.expand()` → adapter shows UI
22
+ * 2. Adapter calls `handleOpened()` when show animation completes
23
+ * 3. User dismisses (swipe/backdrop/back) → adapter calls `handleDismiss()`
24
+ * 4. Adapter calls `handleClosed()` when hide animation completes
25
+ */
26
+ export interface SheetAdapterEvents {
27
+ /** User-initiated dismiss (swipe down, backdrop tap, hardware back button) */
28
+ handleDismiss(): void;
29
+ /** Show animation completed — sheet is fully visible and interactive */
30
+ handleOpened(): void;
31
+ /** Hide animation completed — sheet is fully hidden */
32
+ handleClosed(): void;
33
+ }
34
+
35
+ export type SheetRef = RefObject<SheetAdapterRef | null>;
@@ -0,0 +1,83 @@
1
+ import React, { useImperativeHandle, useRef } from 'react';
2
+
3
+ import type { SheetAdapterRef } from '../../adapter.types';
4
+ import { createSheetEventHandlers } from '../../bottomSheetCoordinator';
5
+ import { useAdapterRef } from '../../useAdapterRef';
6
+ import { useAnimatedIndex } from '../../useAnimatedIndex';
7
+ import { useBottomSheetContext } from '../../useBottomSheetContext';
8
+
9
+ const ActionSheet = require('react-native-actions-sheet').default;
10
+
11
+ /**
12
+ * Adapter for `react-native-actions-sheet` — a zero-dependency action sheet
13
+ * with snap points and gesture controls.
14
+ *
15
+ * All ActionSheet props are accepted via spread and forwarded to the
16
+ * underlying component. Uses `isModal={false}` internally — the stack
17
+ * manager handles the overlay lifecycle.
18
+ *
19
+ * Requires `react-native-actions-sheet` as a peer dependency:
20
+ * ```
21
+ * npm install react-native-actions-sheet
22
+ * ```
23
+ *
24
+ * @see https://github.com/ammarahm-ed/react-native-actions-sheet
25
+ */
26
+ export interface ActionsSheetAdapterProps {
27
+ children: React.ReactNode;
28
+ [key: string]: unknown;
29
+ }
30
+
31
+ export const ActionsSheetAdapter = React.forwardRef<
32
+ SheetAdapterRef,
33
+ ActionsSheetAdapterProps
34
+ >(({ children, ...sheetProps }, forwardedRef) => {
35
+ const { id } = useBottomSheetContext();
36
+ const ref = useAdapterRef(forwardedRef);
37
+ const animatedIndex = useAnimatedIndex();
38
+
39
+ const actionSheetRef = useRef<any>(null);
40
+
41
+ const { handleDismiss, handleOpened, handleClosed } =
42
+ createSheetEventHandlers(id);
43
+
44
+ useImperativeHandle(
45
+ ref,
46
+ () => ({
47
+ expand: () => actionSheetRef.current?.show(),
48
+ close: () => actionSheetRef.current?.hide(),
49
+ }),
50
+ []
51
+ );
52
+
53
+ const onOpen = () => {
54
+ animatedIndex.set(0);
55
+ handleOpened();
56
+ };
57
+
58
+ const onClose = () => {
59
+ animatedIndex.set(-1);
60
+ handleClosed();
61
+ };
62
+
63
+ return (
64
+ <ActionSheet
65
+ // Adapter defaults (overridable via spread)
66
+ gestureEnabled
67
+ closeOnTouchBackdrop
68
+ closeOnPressBack
69
+ keyboardHandlerEnabled
70
+ {...sheetProps}
71
+ // Managed by adapter (not overridable)
72
+ ref={actionSheetRef}
73
+ isModal={false}
74
+ onOpen={onOpen}
75
+ onClose={onClose}
76
+ onBeforeClose={handleDismiss}
77
+ >
78
+ {children}
79
+ </ActionSheet>
80
+ );
81
+ });
82
+
83
+ ActionsSheetAdapter.displayName = 'ActionsSheetAdapter';
@@ -0,0 +1,4 @@
1
+ export {
2
+ ActionsSheetAdapter,
3
+ type ActionsSheetAdapterProps,
4
+ } from './ActionsSheetAdapter';
@@ -0,0 +1,117 @@
1
+ import React, { useImperativeHandle, useState } from 'react';
2
+ import { StyleSheet, type StyleProp, type ViewStyle } from 'react-native';
3
+ import Animated, {
4
+ useAnimatedReaction,
5
+ useAnimatedStyle,
6
+ useSharedValue,
7
+ withTiming,
8
+ } from 'react-native-reanimated';
9
+ import { scheduleOnRN } from 'react-native-worklets';
10
+
11
+ import type { SheetAdapterRef } from '../../adapter.types';
12
+ import { createSheetEventHandlers } from '../../bottomSheetCoordinator';
13
+ import { useAdapterRef } from '../../useAdapterRef';
14
+ import { useAnimatedIndex } from '../../useAnimatedIndex';
15
+ import { useBackHandler } from '../../useBackHandler';
16
+ import { useBottomSheetContext } from '../../useBottomSheetContext';
17
+
18
+ const ANIMATION_DURATION = 300;
19
+
20
+ const ZOOM_INITIAL_SCALE = 0.85;
21
+
22
+ export interface ModalAdapterProps {
23
+ children: React.ReactNode;
24
+ contentContainerStyle?: StyleProp<ViewStyle>;
25
+ }
26
+
27
+ export const CustomModalAdapter = React.forwardRef<
28
+ SheetAdapterRef,
29
+ ModalAdapterProps
30
+ >(({ children, contentContainerStyle }, forwardedRef) => {
31
+ const { id } = useBottomSheetContext();
32
+ const ref = useAdapterRef(forwardedRef);
33
+ const animatedIndex = useAnimatedIndex();
34
+ const [rendered, setRendered] = useState(false);
35
+ const [open, setOpen] = useState(false);
36
+
37
+ const progress = useSharedValue(0);
38
+
39
+ const { handleDismiss, handleOpened, handleClosed } =
40
+ createSheetEventHandlers(id);
41
+
42
+ useImperativeHandle(
43
+ ref,
44
+ () => ({
45
+ expand: () => {
46
+ setRendered(true);
47
+ setOpen(true);
48
+ animatedIndex.set(0);
49
+ },
50
+ close: () => {
51
+ setOpen(false);
52
+ animatedIndex.set(-1);
53
+ },
54
+ }),
55
+ [animatedIndex]
56
+ );
57
+
58
+ const onAnimationEnd = (value: boolean) => {
59
+ 'worklet';
60
+ if (value) {
61
+ scheduleOnRN(handleOpened);
62
+ } else {
63
+ scheduleOnRN(setRendered, false);
64
+ scheduleOnRN(handleClosed);
65
+ }
66
+ };
67
+
68
+ useAnimatedReaction(
69
+ () => open,
70
+ (value, prevValue) => {
71
+ if (prevValue === null || value === prevValue) return;
72
+ progress.value = withTiming(
73
+ value ? 1 : 0,
74
+ { duration: ANIMATION_DURATION },
75
+ (finished) => {
76
+ if (!finished) return;
77
+ onAnimationEnd(value);
78
+ }
79
+ );
80
+ }
81
+ );
82
+
83
+ useBackHandler(id, handleDismiss);
84
+
85
+ const animatedStyle = useAnimatedStyle(() => {
86
+ return {
87
+ opacity: progress.value,
88
+ transform: [
89
+ {
90
+ scale: ZOOM_INITIAL_SCALE + progress.value * (1 - ZOOM_INITIAL_SCALE),
91
+ },
92
+ ],
93
+ };
94
+ });
95
+
96
+ if (!rendered) {
97
+ return null;
98
+ }
99
+
100
+ return (
101
+ <Animated.View
102
+ style={[styles.container, contentContainerStyle, animatedStyle]}
103
+ >
104
+ {children}
105
+ </Animated.View>
106
+ );
107
+ });
108
+
109
+ CustomModalAdapter.displayName = 'CustomModalAdapter';
110
+
111
+ const styles = StyleSheet.create({
112
+ container: {
113
+ ...StyleSheet.absoluteFillObject,
114
+ justifyContent: 'center',
115
+ alignItems: 'center',
116
+ },
117
+ });
@@ -0,0 +1,7 @@
1
+ export {
2
+ CustomModalAdapter,
3
+ type ModalAdapterProps,
4
+ } from './CustomModalAdapter';
5
+
6
+ /** @deprecated Use `CustomModalAdapter` instead. */
7
+ export { CustomModalAdapter as ModalAdapter } from './CustomModalAdapter';