@lodev09/react-native-true-sheet 3.1.0-beta.0 → 3.1.0-beta.10

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 (61) hide show
  1. package/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +12 -10
  2. package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +19 -7
  3. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +119 -208
  4. package/android/src/main/java/com/lodev09/truesheet/core/RNScreensFragmentObserver.kt +17 -5
  5. package/android/src/main/jni/CMakeLists.txt +6 -30
  6. package/android/src/main/res/anim/true_sheet_slide_in.xml +4 -4
  7. package/android/src/main/res/anim/true_sheet_slide_out.xml +4 -3
  8. package/ios/TrueSheetContainerView.mm +4 -0
  9. package/ios/TrueSheetContentView.mm +4 -0
  10. package/ios/TrueSheetFooterView.mm +4 -0
  11. package/ios/TrueSheetHeaderView.mm +4 -0
  12. package/ios/TrueSheetModule.mm +24 -5
  13. package/ios/TrueSheetView.h +2 -0
  14. package/ios/TrueSheetView.mm +17 -5
  15. package/ios/TrueSheetViewController.h +3 -2
  16. package/ios/TrueSheetViewController.mm +204 -95
  17. package/lib/module/TrueSheet.js +12 -8
  18. package/lib/module/TrueSheet.js.map +1 -1
  19. package/lib/module/navigation/TrueSheetRouter.js +119 -0
  20. package/lib/module/navigation/TrueSheetRouter.js.map +1 -0
  21. package/lib/module/navigation/TrueSheetView.js +169 -0
  22. package/lib/module/navigation/TrueSheetView.js.map +1 -0
  23. package/lib/module/navigation/createTrueSheetNavigator.js +59 -0
  24. package/lib/module/navigation/createTrueSheetNavigator.js.map +1 -0
  25. package/lib/module/navigation/index.js +6 -0
  26. package/lib/module/navigation/index.js.map +1 -0
  27. package/lib/module/navigation/types.js +4 -0
  28. package/lib/module/navigation/types.js.map +1 -0
  29. package/lib/module/navigation/useTrueSheetNavigation.js +26 -0
  30. package/lib/module/navigation/useTrueSheetNavigation.js.map +1 -0
  31. package/lib/module/reanimated/ReanimatedTrueSheetProvider.js +3 -3
  32. package/lib/module/reanimated/ReanimatedTrueSheetProvider.js.map +1 -1
  33. package/lib/module/specs/NativeTrueSheetModule.js.map +1 -1
  34. package/lib/typescript/src/TrueSheet.d.ts +8 -4
  35. package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
  36. package/lib/typescript/src/navigation/TrueSheetRouter.d.ts +57 -0
  37. package/lib/typescript/src/navigation/TrueSheetRouter.d.ts.map +1 -0
  38. package/lib/typescript/src/navigation/TrueSheetView.d.ts +10 -0
  39. package/lib/typescript/src/navigation/TrueSheetView.d.ts.map +1 -0
  40. package/lib/typescript/src/navigation/createTrueSheetNavigator.d.ts +35 -0
  41. package/lib/typescript/src/navigation/createTrueSheetNavigator.d.ts.map +1 -0
  42. package/lib/typescript/src/navigation/index.d.ts +6 -0
  43. package/lib/typescript/src/navigation/index.d.ts.map +1 -0
  44. package/lib/typescript/src/navigation/types.d.ts +125 -0
  45. package/lib/typescript/src/navigation/types.d.ts.map +1 -0
  46. package/lib/typescript/src/navigation/useTrueSheetNavigation.d.ts +23 -0
  47. package/lib/typescript/src/navigation/useTrueSheetNavigation.d.ts.map +1 -0
  48. package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts.map +1 -1
  49. package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts +4 -2
  50. package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts.map +1 -1
  51. package/package.json +13 -2
  52. package/src/TrueSheet.tsx +16 -8
  53. package/src/__mocks__/index.js +6 -5
  54. package/src/navigation/TrueSheetRouter.ts +172 -0
  55. package/src/navigation/TrueSheetView.tsx +271 -0
  56. package/src/navigation/createTrueSheetNavigator.tsx +89 -0
  57. package/src/navigation/index.ts +14 -0
  58. package/src/navigation/types.ts +176 -0
  59. package/src/navigation/useTrueSheetNavigation.ts +28 -0
  60. package/src/reanimated/ReanimatedTrueSheetProvider.tsx +6 -9
  61. package/src/specs/NativeTrueSheetModule.ts +4 -2
@@ -0,0 +1,10 @@
1
+ import type { ParamListBase } from '@react-navigation/native';
2
+ import type { TrueSheetDescriptorMap, TrueSheetNavigationHelpers, TrueSheetNavigationState } from './types';
3
+ interface TrueSheetViewProps {
4
+ state: TrueSheetNavigationState<ParamListBase>;
5
+ navigation: TrueSheetNavigationHelpers;
6
+ descriptors: TrueSheetDescriptorMap;
7
+ }
8
+ export declare function TrueSheetView({ state, navigation, descriptors }: TrueSheetViewProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
10
+ //# sourceMappingURL=TrueSheetView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrueSheetView.d.ts","sourceRoot":"","sources":["../../../../src/navigation/TrueSheetView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAoB9D,OAAO,KAAK,EACV,sBAAsB,EAEtB,0BAA0B,EAG1B,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAoMjB,UAAU,kBAAkB;IAC1B,KAAK,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;IAC/C,UAAU,EAAE,0BAA0B,CAAC;IACvC,WAAW,EAAE,sBAAsB,CAAC;CACrC;AAED,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,kBAAkB,2CAyCnF"}
@@ -0,0 +1,35 @@
1
+ import { type NavigatorTypeBagBase, type ParamListBase, type StaticConfig, type TypedNavigator } from '@react-navigation/native';
2
+ import type { TrueSheetNavigationEventMap, TrueSheetNavigationOptions, TrueSheetNavigationProp, TrueSheetNavigationState, TrueSheetNavigatorProps } from './types';
3
+ declare function TrueSheetNavigator({ id, initialRouteName, children, screenListeners, screenOptions, }: TrueSheetNavigatorProps): import("react/jsx-runtime").JSX.Element;
4
+ /**
5
+ * Creates a TrueSheet navigator.
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * const Sheet = createTrueSheetNavigator();
10
+ *
11
+ * function App() {
12
+ * return (
13
+ * <Sheet.Navigator>
14
+ * <Sheet.Screen name="Home" component={HomeScreen} />
15
+ * <Sheet.Screen
16
+ * name="Details"
17
+ * component={DetailsSheet}
18
+ * options={{ detents: [0.5, 1] }}
19
+ * />
20
+ * </Sheet.Navigator>
21
+ * );
22
+ * }
23
+ * ```
24
+ */
25
+ export declare const createTrueSheetNavigator: <const ParamList extends ParamListBase, const NavigatorID extends string | undefined = undefined, const TypeBag extends NavigatorTypeBagBase = {
26
+ ParamList: ParamList;
27
+ NavigatorID: NavigatorID;
28
+ State: TrueSheetNavigationState<ParamList>;
29
+ ScreenOptions: TrueSheetNavigationOptions;
30
+ EventMap: TrueSheetNavigationEventMap;
31
+ NavigationList: { [RouteName in keyof ParamList]: TrueSheetNavigationProp<ParamList, RouteName, NavigatorID>; };
32
+ Navigator: typeof TrueSheetNavigator;
33
+ }, const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>>(config?: Config) => TypedNavigator<TypeBag, Config>;
34
+ export {};
35
+ //# sourceMappingURL=createTrueSheetNavigator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTrueSheetNavigator.d.ts","sourceRoot":"","sources":["../../../../src/navigation/createTrueSheetNavigator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,cAAc,EAEpB,MAAM,0BAA0B,CAAC;AAIlC,OAAO,KAAK,EAEV,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAEjB,iBAAS,kBAAkB,CAAC,EAC1B,EAAE,EACF,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,aAAa,GACd,EAAE,uBAAuB,2CAoBzB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,wBAAwB,GACnC,KAAK,CAAC,SAAS,SAAS,aAAa,EACrC,KAAK,CAAC,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,EACxD,KAAK,CAAC,OAAO,SAAS,oBAAoB,GAAG;IAC3C,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAC3C,aAAa,EAAE,0BAA0B,CAAC;IAC1C,QAAQ,EAAE,2BAA2B,CAAC;IACtC,cAAc,EAAE,GACb,SAAS,IAAI,MAAM,SAAS,GAAG,uBAAuB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC,GAC3F,CAAC;IACF,SAAS,EAAE,OAAO,kBAAkB,CAAC;CACtC,EACD,KAAK,CAAC,MAAM,SAAS,YAAY,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,EAElE,SAAS,MAAM,KACd,cAAc,CAAC,OAAO,EAAE,MAAM,CAEhC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { createTrueSheetNavigator } from './createTrueSheetNavigator';
2
+ export { TrueSheetActions, type TrueSheetActionType } from './TrueSheetRouter';
3
+ export { useTrueSheetNavigation } from './useTrueSheetNavigation';
4
+ export type { DetentInfoEventPayload, PositionChangeEventPayload } from '../TrueSheet.types';
5
+ export type { TrueSheetNavigationEventMap, TrueSheetNavigationHelpers, TrueSheetNavigationOptions, TrueSheetNavigationProp, TrueSheetNavigationState, TrueSheetScreenProps, } from './types';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/navigation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,YAAY,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAE7F,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,125 @@
1
+ import type { DefaultNavigatorOptions, Descriptor, NavigationHelpers, NavigationProp, NavigationState, ParamListBase, RouteProp, StackActionHelpers } from '@react-navigation/native';
2
+ import type { DetentInfoEventPayload, PositionChangeEventPayload, TrueSheetProps } from '../TrueSheet.types';
3
+ export type TrueSheetNavigationEventMap = {
4
+ /**
5
+ * Event fired when the sheet is about to be presented.
6
+ */
7
+ sheetWillPresent: {
8
+ data: DetentInfoEventPayload;
9
+ };
10
+ /**
11
+ * Event fired when the sheet has been presented.
12
+ */
13
+ sheetDidPresent: {
14
+ data: DetentInfoEventPayload;
15
+ };
16
+ /**
17
+ * Event fired when the sheet is about to be dismissed.
18
+ */
19
+ sheetWillDismiss: {
20
+ data: undefined;
21
+ };
22
+ /**
23
+ * Event fired when the sheet has been dismissed.
24
+ */
25
+ sheetDidDismiss: {
26
+ data: undefined;
27
+ };
28
+ /**
29
+ * Event fired when the sheet's detent changes.
30
+ */
31
+ sheetDetentChange: {
32
+ data: DetentInfoEventPayload;
33
+ };
34
+ /**
35
+ * Event fired when the user starts dragging the sheet.
36
+ */
37
+ sheetDragBegin: {
38
+ data: DetentInfoEventPayload;
39
+ };
40
+ /**
41
+ * Event fired while the user is dragging the sheet.
42
+ */
43
+ sheetDragChange: {
44
+ data: DetentInfoEventPayload;
45
+ };
46
+ /**
47
+ * Event fired when the user stops dragging the sheet.
48
+ */
49
+ sheetDragEnd: {
50
+ data: DetentInfoEventPayload;
51
+ };
52
+ /**
53
+ * Event fired when the sheet's position changes.
54
+ */
55
+ sheetPositionChange: {
56
+ data: PositionChangeEventPayload;
57
+ };
58
+ /**
59
+ * Event fired when the sheet is about to regain focus.
60
+ */
61
+ sheetWillFocus: {
62
+ data: undefined;
63
+ };
64
+ /**
65
+ * Event fired when the sheet regains focus.
66
+ */
67
+ sheetDidFocus: {
68
+ data: undefined;
69
+ };
70
+ /**
71
+ * Event fired when the sheet is about to lose focus.
72
+ */
73
+ sheetWillBlur: {
74
+ data: undefined;
75
+ };
76
+ /**
77
+ * Event fired when the sheet loses focus.
78
+ */
79
+ sheetDidBlur: {
80
+ data: undefined;
81
+ };
82
+ };
83
+ export type TrueSheetNavigationState<ParamList extends ParamListBase> = Omit<NavigationState<ParamList>, 'routes'> & {
84
+ type: 'true-sheet';
85
+ routes: (NavigationState<ParamList>['routes'][number] & {
86
+ resizeIndex?: number;
87
+ resizeKey?: number;
88
+ closing?: boolean;
89
+ })[];
90
+ };
91
+ export type TrueSheetActionHelpers<ParamList extends ParamListBase> = StackActionHelpers<ParamList> & {
92
+ /**
93
+ * Resize the sheet to a specific detent index.
94
+ */
95
+ resize(index?: number): void;
96
+ };
97
+ export type TrueSheetNavigationProp<ParamList extends ParamListBase, RouteName extends keyof ParamList = string, NavigatorID extends string | undefined = undefined> = NavigationProp<ParamList, RouteName, NavigatorID, TrueSheetNavigationState<ParamList>, TrueSheetNavigationOptions, TrueSheetNavigationEventMap> & TrueSheetActionHelpers<ParamList>;
98
+ export type TrueSheetScreenProps<ParamList extends ParamListBase, RouteName extends keyof ParamList = string, NavigatorID extends string | undefined = undefined> = {
99
+ navigation: TrueSheetNavigationProp<ParamList, RouteName, NavigatorID>;
100
+ route: RouteProp<ParamList, RouteName>;
101
+ };
102
+ export type TrueSheetNavigationHelpers = NavigationHelpers<ParamListBase, TrueSheetNavigationEventMap>;
103
+ /**
104
+ * Screen options for TrueSheet navigator screens.
105
+ */
106
+ export type TrueSheetNavigationOptions = Pick<TrueSheetProps, 'detents' | 'backgroundColor' | 'cornerRadius' | 'dismissible' | 'draggable' | 'grabber' | 'grabberOptions' | 'dimmed' | 'dimmedDetentIndex' | 'blurTint' | 'blurOptions' | 'maxHeight' | 'edgeToEdgeFullScreen' | 'scrollable' | 'keyboardMode' | 'pageSizing' | 'header' | 'footer'> & {
107
+ /**
108
+ * The detent index to present at.
109
+ * @default 0
110
+ */
111
+ detentIndex?: number;
112
+ };
113
+ export type TrueSheetNavigatorProps = DefaultNavigatorOptions<ParamListBase, string | undefined, TrueSheetNavigationState<ParamListBase>, TrueSheetNavigationOptions, TrueSheetNavigationEventMap, unknown> & {
114
+ /**
115
+ * The name of the route to use as the base screen.
116
+ * This screen will be rendered as a regular screen, while other screens are presented as sheets.
117
+ * Defaults to the first screen defined in the navigator.
118
+ */
119
+ initialRouteName?: string;
120
+ };
121
+ export type TrueSheetDescriptor = Descriptor<TrueSheetNavigationOptions, TrueSheetNavigationProp<ParamListBase>, RouteProp<ParamListBase>>;
122
+ export type TrueSheetDescriptorMap = {
123
+ [key: string]: TrueSheetDescriptor;
124
+ };
125
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/navigation/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,EACb,SAAS,EACT,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EACV,sBAAsB,EACtB,0BAA0B,EAC1B,cAAc,EACf,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,2BAA2B,GAAG;IACxC;;OAEG;IACH,gBAAgB,EAAE;QAAE,IAAI,EAAE,sBAAsB,CAAA;KAAE,CAAC;IACnD;;OAEG;IACH,eAAe,EAAE;QAAE,IAAI,EAAE,sBAAsB,CAAA;KAAE,CAAC;IAClD;;OAEG;IACH,gBAAgB,EAAE;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC;IACtC;;OAEG;IACH,eAAe,EAAE;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC;IACrC;;OAEG;IACH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C3B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAC1C,0BAA0B,EAC1B,uBAAuB,CAAC,aAAa,CAAC,EACtC,SAAS,CAAC,aAAa,CAAC,CACzB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAAC;CACpC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { type ParamListBase } from '@react-navigation/native';
2
+ import type { TrueSheetNavigationProp } from './types';
3
+ /**
4
+ * Hook to access TrueSheet navigation with the resize helper.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * function MySheet() {
9
+ * const navigation = useTrueSheetNavigation();
10
+ *
11
+ * // Resize to a specific detent
12
+ * const handleExpand = () => {
13
+ * navigation.resize(1); // Resize to second detent
14
+ * };
15
+ *
16
+ * return (
17
+ * <Button title="Expand" onPress={handleExpand} />
18
+ * );
19
+ * }
20
+ * ```
21
+ */
22
+ export declare function useTrueSheetNavigation<T extends ParamListBase = ParamListBase>(): TrueSheetNavigationProp<T>;
23
+ //# sourceMappingURL=useTrueSheetNavigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTrueSheetNavigation.d.ts","sourceRoot":"","sources":["../../../../src/navigation/useTrueSheetNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE7E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CACpC,CAAC,SAAS,aAAa,GAAG,aAAa,KACpC,uBAAuB,CAAC,CAAC,CAAC,CAE9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"ReanimatedTrueSheetProvider.d.ts","sourceRoot":"","sources":["../../../../src/reanimated/ReanimatedTrueSheetProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3E,MAAM,WAAW,+BAA+B;IAC9C;;OAEG;IACH,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC;;;OAGG;IACH,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC;;;OAGG;IACH,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACrC;AAID,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,2BAA2B,GAAI,cAAc,gCAAgC,4CAoBzF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,sBAAsB,QAAO,+BAWzC,CAAC"}
1
+ {"version":3,"file":"ReanimatedTrueSheetProvider.d.ts","sourceRoot":"","sources":["../../../../src/reanimated/ReanimatedTrueSheetProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3E,MAAM,WAAW,+BAA+B;IAC9C;;OAEG;IACH,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC;;;OAGG;IACH,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC;;;OAGG;IACH,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACrC;AAID,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,2BAA2B,GAAI,cAAc,gCAAgC,4CAiBzF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,sBAAsB,QAAO,+BAWzC,CAAC"}
@@ -10,17 +10,19 @@ interface Spec extends TurboModule {
10
10
  * Present a sheet by reference
11
11
  * @param viewTag - Native view tag of the sheet component
12
12
  * @param index - Detent index to present at
13
+ * @param animated - Whether to animate the presentation
13
14
  * @returns Promise that resolves when sheet is fully presented
14
15
  * @throws PRESENT_FAILED if presentation fails
15
16
  */
16
- presentByRef(viewTag: number, index: number): Promise<void>;
17
+ presentByRef(viewTag: number, index: number, animated: boolean): Promise<void>;
17
18
  /**
18
19
  * Dismiss a sheet by reference
19
20
  * @param viewTag - Native view tag of the sheet component
21
+ * @param animated - Whether to animate the dismissal
20
22
  * @returns Promise that resolves when sheet is fully dismissed
21
23
  * @throws DISMISS_FAILED if dismissal fails
22
24
  */
23
- dismissByRef(viewTag: number): Promise<void>;
25
+ dismissByRef(viewTag: number, animated: boolean): Promise<void>;
24
26
  /**
25
27
  * Resize a sheet to a different index by reference
26
28
  * @param viewTag - Native view tag of the sheet component
@@ -1 +1 @@
1
- {"version":3,"file":"NativeTrueSheetModule.d.ts","sourceRoot":"","sources":["../../../../src/specs/NativeTrueSheetModule.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,UAAU,IAAK,SAAQ,WAAW;IAChC;;;;;;OAMG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5D;;;;;OAKG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7C;;;;;OAKG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D;;AAED,wBAAgE"}
1
+ {"version":3,"file":"NativeTrueSheetModule.d.ts","sourceRoot":"","sources":["../../../../src/specs/NativeTrueSheetModule.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,UAAU,IAAK,SAAQ,WAAW;IAChC;;;;;;;OAOG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/E;;;;;;OAMG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhE;;;;;OAKG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D;;AAED,wBAAgE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodev09/react-native-true-sheet",
3
- "version": "3.1.0-beta.0",
3
+ "version": "3.1.0-beta.10",
4
4
  "description": "The true native bottom sheet experience for your React Native Apps.",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",
@@ -16,6 +16,11 @@
16
16
  "types": "./lib/typescript/src/reanimated/index.d.ts",
17
17
  "default": "./lib/module/reanimated/index.js"
18
18
  },
19
+ "./navigation": {
20
+ "source": "./src/navigation/index.ts",
21
+ "types": "./lib/typescript/src/navigation/index.d.ts",
22
+ "default": "./lib/module/navigation/index.js"
23
+ },
19
24
  "./package.json": "./package.json"
20
25
  },
21
26
  "files": [
@@ -80,7 +85,8 @@
80
85
  "@eslint/js": "^9.35.0",
81
86
  "@evilmartians/lefthook": "^2.0.4",
82
87
  "@react-native/babel-preset": "^0.82.1",
83
- "@react-native/eslint-config": "^0.81.1",
88
+ "@react-native/eslint-config": "^0.82.1",
89
+ "@react-navigation/native": "^7.1.6",
84
90
  "@release-it/conventional-changelog": "^10.0.1",
85
91
  "@testing-library/react-native": "^13.3.3",
86
92
  "@types/babel__core": "^7",
@@ -92,6 +98,7 @@
92
98
  "eslint-config-prettier": "^10.1.8",
93
99
  "eslint-plugin-prettier": "^5.5.4",
94
100
  "jest": "^29.7.0",
101
+ "nanoid": "^5.1.5",
95
102
  "prettier": "^3.0.3",
96
103
  "react": "19.1.1",
97
104
  "react-native": "0.82.1",
@@ -107,12 +114,16 @@
107
114
  "@types/react": "19.1.1"
108
115
  },
109
116
  "peerDependencies": {
117
+ "@react-navigation/native": ">=6.0.0",
110
118
  "react": "*",
111
119
  "react-native": "*",
112
120
  "react-native-reanimated": ">=4.0.0",
113
121
  "react-native-worklets": "*"
114
122
  },
115
123
  "peerDependenciesMeta": {
124
+ "@react-navigation/native": {
125
+ "optional": true
126
+ },
116
127
  "react-native-reanimated": {
117
128
  "optional": true
118
129
  },
package/src/TrueSheet.tsx CHANGED
@@ -160,31 +160,37 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
160
160
  * Present the sheet by given `name` (Promise-based)
161
161
  * @param name - Sheet name (must match sheet's name prop)
162
162
  * @param index - Detent index (default: 0)
163
+ * @param animated - Whether to animate the presentation (default: true)
163
164
  * @returns Promise that resolves when sheet is fully presented
164
165
  * @throws Error if sheet not found or presentation fails
165
166
  */
166
- public static async present(name: string, index: number = 0): Promise<void> {
167
+ public static async present(
168
+ name: string,
169
+ index: number = 0,
170
+ animated: boolean = true
171
+ ): Promise<void> {
167
172
  const instance = TrueSheet.getInstance(name);
168
173
  if (!instance) {
169
174
  throw new Error(`Sheet with name "${name}" not found`);
170
175
  }
171
176
 
172
- return instance.present(index);
177
+ return instance.present(index, animated);
173
178
  }
174
179
 
175
180
  /**
176
181
  * Dismiss the sheet by given `name` (Promise-based)
177
182
  * @param name - Sheet name
183
+ * @param animated - Whether to animate the dismissal (default: true)
178
184
  * @returns Promise that resolves when sheet is fully dismissed
179
185
  * @throws Error if sheet not found or dismissal fails
180
186
  */
181
- public static async dismiss(name: string): Promise<void> {
187
+ public static async dismiss(name: string, animated: boolean = true): Promise<void> {
182
188
  const instance = TrueSheet.getInstance(name);
183
189
  if (!instance) {
184
190
  throw new Error(`Sheet with name "${name}" not found`);
185
191
  }
186
192
 
187
- return instance.dismiss();
193
+ return instance.dismiss(animated);
188
194
  }
189
195
 
190
196
  /**
@@ -286,8 +292,9 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
286
292
  /**
287
293
  * Present the Sheet by `index` (Promise-based)
288
294
  * @param index - Detent index (default: 0)
295
+ * @param animated - Whether to animate the presentation (default: true)
289
296
  */
290
- public async present(index: number = 0): Promise<void> {
297
+ public async present(index: number = 0, animated: boolean = true): Promise<void> {
291
298
  const detentsLength = Math.min(this.props.detents?.length ?? 2, 3); // Max 3 detents
292
299
  if (index < 0 || index >= detentsLength) {
293
300
  throw new Error(
@@ -303,7 +310,7 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
303
310
  });
304
311
  }
305
312
 
306
- return TrueSheetModule?.presentByRef(this.handle, index);
313
+ return TrueSheetModule?.presentByRef(this.handle, index, animated);
307
314
  }
308
315
 
309
316
  /**
@@ -316,9 +323,10 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
316
323
 
317
324
  /**
318
325
  * Dismisses the Sheet
326
+ * @param animated - Whether to animate the dismissal (default: true)
319
327
  */
320
- public async dismiss(): Promise<void> {
321
- return TrueSheetModule?.dismissByRef(this.handle);
328
+ public async dismiss(animated: boolean = true): Promise<void> {
329
+ return TrueSheetModule?.dismissByRef(this.handle, animated);
322
330
  }
323
331
 
324
332
  componentDidMount(): void {
@@ -6,13 +6,13 @@ export class TrueSheet extends React.Component {
6
6
  static instances = {};
7
7
 
8
8
  // Static methods
9
- static dismiss = jest.fn((name) => Promise.resolve());
10
- static present = jest.fn((name, index = 0) => Promise.resolve());
9
+ static dismiss = jest.fn((name, animated = true) => Promise.resolve());
10
+ static present = jest.fn((name, index = 0, animated = true) => Promise.resolve());
11
11
  static resize = jest.fn((name, index) => Promise.resolve());
12
12
 
13
13
  // Instance methods
14
- dismiss = jest.fn(() => Promise.resolve());
15
- present = jest.fn((index = 0) => Promise.resolve());
14
+ dismiss = jest.fn((animated = true) => Promise.resolve());
15
+ present = jest.fn((index = 0, animated = true) => Promise.resolve());
16
16
  resize = jest.fn((index) => Promise.resolve());
17
17
 
18
18
  componentDidMount() {
@@ -30,9 +30,10 @@ export class TrueSheet extends React.Component {
30
30
  }
31
31
 
32
32
  render() {
33
- const { children, footer, style, ...rest } = this.props;
33
+ const { children, header, footer, style, ...rest } = this.props;
34
34
  return (
35
35
  <View style={style} {...rest}>
36
+ {header}
36
37
  {children}
37
38
  {footer}
38
39
  </View>
@@ -0,0 +1,172 @@
1
+ import { nanoid } from 'nanoid/non-secure';
2
+ import {
3
+ type CommonActions,
4
+ type ParamListBase,
5
+ type Router,
6
+ StackRouter,
7
+ type StackActionType,
8
+ StackActions,
9
+ type StackRouterOptions,
10
+ } from '@react-navigation/native';
11
+
12
+ import type { TrueSheetNavigationState } from './types';
13
+
14
+ export type TrueSheetRouterOptions = StackRouterOptions;
15
+
16
+ export type TrueSheetActionType =
17
+ | StackActionType
18
+ | ReturnType<typeof CommonActions.goBack>
19
+ | {
20
+ type: 'RESIZE';
21
+ index: number;
22
+ source?: string;
23
+ target?: string;
24
+ }
25
+ | {
26
+ type: 'DISMISS';
27
+ source?: string;
28
+ target?: string;
29
+ }
30
+ | {
31
+ type: 'REMOVE';
32
+ source?: string;
33
+ target?: string;
34
+ };
35
+
36
+ export const TrueSheetActions = {
37
+ ...StackActions,
38
+ resize(index: number): TrueSheetActionType {
39
+ return { type: 'RESIZE', index };
40
+ },
41
+ dismiss(): TrueSheetActionType {
42
+ return { type: 'DISMISS' };
43
+ },
44
+ remove(): TrueSheetActionType {
45
+ return { type: 'REMOVE' };
46
+ },
47
+ };
48
+
49
+ export function TrueSheetRouter(
50
+ routerOptions: StackRouterOptions
51
+ ): Router<TrueSheetNavigationState<ParamListBase>, TrueSheetActionType> {
52
+ const baseRouter = StackRouter(routerOptions) as unknown as Router<
53
+ TrueSheetNavigationState<ParamListBase>,
54
+ TrueSheetActionType
55
+ >;
56
+
57
+ return {
58
+ ...baseRouter,
59
+ type: 'true-sheet',
60
+
61
+ getInitialState(options) {
62
+ const state = baseRouter.getInitialState(options);
63
+
64
+ return {
65
+ ...state,
66
+ stale: false,
67
+ type: 'true-sheet',
68
+ key: `true-sheet-${nanoid()}`,
69
+ };
70
+ },
71
+
72
+ getStateForAction(state, action, options) {
73
+ switch (action.type) {
74
+ case 'RESIZE': {
75
+ const routeIndex =
76
+ action.target === state.key && action.source
77
+ ? state.routes.findIndex((r) => r.key === action.source)
78
+ : state.index;
79
+
80
+ return {
81
+ ...state,
82
+ routes: state.routes.map((route, i) =>
83
+ i === routeIndex
84
+ ? {
85
+ ...route,
86
+ resizeIndex: action.index,
87
+ resizeKey: (route.resizeKey ?? 0) + 1,
88
+ }
89
+ : route
90
+ ),
91
+ };
92
+ }
93
+
94
+ case 'GO_BACK':
95
+ case 'POP':
96
+ case 'DISMISS': {
97
+ // Only base screen remains - let parent navigator handle it
98
+ if (state.routes.length <= 1) {
99
+ return null;
100
+ }
101
+
102
+ // Find the route to dismiss
103
+ const routeIndex =
104
+ action.target === state.key && 'source' in action && action.source
105
+ ? state.routes.findIndex((r) => r.key === action.source)
106
+ : state.index;
107
+
108
+ // Base screen - let parent navigator handle it
109
+ if (routeIndex === 0) {
110
+ return null;
111
+ }
112
+
113
+ // Mark the route as closing instead of removing it
114
+ return {
115
+ ...state,
116
+ routes: state.routes.map((route, i) =>
117
+ i === routeIndex
118
+ ? {
119
+ ...route,
120
+ closing: true,
121
+ }
122
+ : route
123
+ ),
124
+ };
125
+ }
126
+
127
+ case 'REMOVE': {
128
+ // Actually remove the closing route
129
+ const routeKey = action.source;
130
+ const routeIndex = routeKey
131
+ ? state.routes.findIndex((r) => r.key === routeKey)
132
+ : state.routes.findIndex((r) => r.closing);
133
+
134
+ if (routeIndex === -1) {
135
+ return state;
136
+ }
137
+
138
+ const routes = state.routes.filter((_, i) => i !== routeIndex);
139
+
140
+ return {
141
+ ...state,
142
+ index: Math.min(state.index, routes.length - 1),
143
+ routes,
144
+ };
145
+ }
146
+
147
+ default:
148
+ return baseRouter.getStateForAction(state, action, options);
149
+ }
150
+ },
151
+
152
+ getRehydratedState(partialState, { routeNames, routeParamList, routeGetIdList }) {
153
+ if (partialState.stale === false) {
154
+ return partialState;
155
+ }
156
+
157
+ const state = baseRouter.getRehydratedState(partialState, {
158
+ routeNames,
159
+ routeParamList,
160
+ routeGetIdList,
161
+ });
162
+
163
+ return {
164
+ ...state,
165
+ type: 'true-sheet',
166
+ key: `true-sheet-${nanoid()}`,
167
+ };
168
+ },
169
+
170
+ actionCreators: TrueSheetActions,
171
+ };
172
+ }