@lodev09/react-native-true-sheet 4.0.0-beta.5 → 4.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/android/src/main/java/com/lodev09/truesheet/TrueSheetOverlayView.kt +106 -0
  2. package/android/src/main/java/com/lodev09/truesheet/TrueSheetOverlayViewManager.kt +45 -0
  3. package/android/src/main/java/com/lodev09/truesheet/TrueSheetPackage.kt +2 -1
  4. package/android/src/main/java/com/lodev09/truesheet/TrueSheetStateUpdater.kt +18 -0
  5. package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +3 -25
  6. package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetOverlayRootView.kt +137 -0
  7. package/android/src/main/java/com/lodev09/truesheet/utils/ViewUtils.kt +19 -0
  8. package/android/src/main/jni/TrueSheetSpec.h +1 -0
  9. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetLayoutUtils.h +46 -0
  10. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetOverlayViewComponentDescriptor.h +21 -0
  11. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetOverlayViewShadowNode.cpp +17 -0
  12. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetOverlayViewShadowNode.h +36 -0
  13. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.cpp +4 -35
  14. package/ios/TrueSheetContentView.h +3 -1
  15. package/ios/TrueSheetContentView.mm +11 -0
  16. package/ios/TrueSheetOverlayView.h +32 -0
  17. package/ios/TrueSheetOverlayView.mm +141 -0
  18. package/ios/TrueSheetView.mm +17 -0
  19. package/ios/TrueSheetViewController.mm +27 -13
  20. package/ios/core/TrueSheetOverlayContainerView.h +31 -0
  21. package/ios/core/TrueSheetOverlayContainerView.mm +35 -0
  22. package/ios/tvos/TrueSheetStubs.mm +12 -0
  23. package/lib/module/TrueSheetOverlay.js +30 -0
  24. package/lib/module/TrueSheetOverlay.js.map +1 -0
  25. package/lib/module/TrueSheetOverlay.web.js +35 -0
  26. package/lib/module/TrueSheetOverlay.web.js.map +1 -0
  27. package/lib/module/fabric/TrueSheetOverlayViewNativeComponent.ts +12 -0
  28. package/lib/module/index.js +1 -0
  29. package/lib/module/index.js.map +1 -1
  30. package/lib/module/mocks/index.js +10 -0
  31. package/lib/module/mocks/index.js.map +1 -1
  32. package/lib/module/mocks/navigationExpoRouter.js.map +1 -1
  33. package/lib/module/navigation/base-types.js +2 -0
  34. package/lib/module/navigation/base-types.js.map +1 -0
  35. package/lib/module/navigation/createTrueSheetRouter.js +0 -9
  36. package/lib/module/navigation/createTrueSheetRouter.js.map +1 -1
  37. package/lib/module/navigation/expo-router/base-types.js +2 -0
  38. package/lib/module/navigation/expo-router/base-types.js.map +1 -0
  39. package/lib/module/navigation/expo-router/index.js +5 -3
  40. package/lib/module/navigation/expo-router/index.js.map +1 -1
  41. package/lib/module/navigation/expo-router/types.js +4 -0
  42. package/lib/module/navigation/expo-router/types.js.map +1 -0
  43. package/lib/module/navigation/index.js.map +1 -1
  44. package/lib/typescript/src/TrueSheetOverlay.d.ts +8 -0
  45. package/lib/typescript/src/TrueSheetOverlay.d.ts.map +1 -0
  46. package/lib/typescript/src/TrueSheetOverlay.web.d.ts +8 -0
  47. package/lib/typescript/src/TrueSheetOverlay.web.d.ts.map +1 -0
  48. package/lib/typescript/src/fabric/TrueSheetOverlayViewNativeComponent.d.ts +6 -0
  49. package/lib/typescript/src/fabric/TrueSheetOverlayViewNativeComponent.d.ts.map +1 -0
  50. package/lib/typescript/src/index.d.ts +1 -0
  51. package/lib/typescript/src/index.d.ts.map +1 -1
  52. package/lib/typescript/src/mocks/index.d.ts +4 -0
  53. package/lib/typescript/src/mocks/index.d.ts.map +1 -1
  54. package/lib/typescript/src/mocks/navigationExpoRouter.d.ts +3 -3
  55. package/lib/typescript/src/mocks/navigationExpoRouter.d.ts.map +1 -1
  56. package/lib/typescript/src/navigation/base-types.d.ts +9 -0
  57. package/lib/typescript/src/navigation/base-types.d.ts.map +1 -0
  58. package/lib/typescript/src/navigation/createTrueSheetRouter.d.ts +2 -13
  59. package/lib/typescript/src/navigation/createTrueSheetRouter.d.ts.map +1 -1
  60. package/lib/typescript/src/navigation/expo-router/base-types.d.ts +8 -0
  61. package/lib/typescript/src/navigation/expo-router/base-types.d.ts.map +1 -0
  62. package/lib/typescript/src/navigation/expo-router/index.d.ts +5 -5
  63. package/lib/typescript/src/navigation/expo-router/index.d.ts.map +1 -1
  64. package/lib/typescript/src/navigation/expo-router/types.d.ts +44 -0
  65. package/lib/typescript/src/navigation/expo-router/types.d.ts.map +1 -0
  66. package/lib/typescript/src/navigation/index.d.ts +3 -4
  67. package/lib/typescript/src/navigation/index.d.ts.map +1 -1
  68. package/lib/typescript/src/navigation/types.d.ts +34 -4
  69. package/lib/typescript/src/navigation/types.d.ts.map +1 -1
  70. package/package.json +9 -1
  71. package/react-native.config.js +1 -0
  72. package/src/TrueSheetOverlay.tsx +24 -0
  73. package/src/TrueSheetOverlay.web.tsx +33 -0
  74. package/src/fabric/TrueSheetOverlayViewNativeComponent.ts +12 -0
  75. package/src/index.ts +1 -0
  76. package/src/mocks/index.ts +7 -0
  77. package/src/mocks/navigationExpoRouter.ts +6 -5
  78. package/src/navigation/base-types.ts +20 -0
  79. package/src/navigation/createTrueSheetRouter.ts +5 -33
  80. package/src/navigation/expo-router/base-types.ts +18 -0
  81. package/src/navigation/expo-router/index.ts +20 -19
  82. package/src/navigation/expo-router/types.ts +116 -0
  83. package/src/navigation/index.ts +6 -7
  84. package/src/navigation/types.ts +65 -19
@@ -1,20 +1,26 @@
1
- import type { ParamListBase } from '@react-navigation/core';
2
1
  import { StackRouter, unstable_integrateWithRouter, useNavigation } from 'expo-router';
3
2
 
4
- import {
5
- createTrueSheetRouter,
6
- type StackRouterFactory,
7
- type TrueSheetRouterOptions,
8
- } from '../createTrueSheetRouter';
3
+ import { createTrueSheetRouter } from '../createTrueSheetRouter';
9
4
  import { trueSheetNavigator } from '../navigator';
5
+ import type { ParamListBase } from './base-types';
10
6
  import type {
7
+ StackRouterFactory,
11
8
  TrueSheetNavigationOptions,
12
9
  TrueSheetNavigationProp,
13
10
  TrueSheetNavigationState,
14
11
  TrueSheetNavigatorContentExtraProps,
15
12
  TrueSheetNavigatorProps,
13
+ TrueSheetRouterFactory,
14
+ TrueSheetRouterOptions,
16
15
  TrueSheetStandardEventMap,
17
- } from '../types';
16
+ } from './types';
17
+
18
+ // expo-router's vendored StackRouter is structurally identical to @react-navigation's.
19
+ // Pinned to this entry's own router types: `createTrueSheetRouter` is shared and typed
20
+ // against React Navigation, which resolves to `any` in apps that only install expo-router.
21
+ const sheetRouter: TrueSheetRouterFactory = createTrueSheetRouter(
22
+ StackRouter as StackRouterFactory
23
+ );
18
24
 
19
25
  const SheetNavigator = unstable_integrateWithRouter<
20
26
  TrueSheetNavigationOptions,
@@ -22,17 +28,12 @@ const SheetNavigator = unstable_integrateWithRouter<
22
28
  TrueSheetStandardEventMap,
23
29
  TrueSheetNavigatorContentExtraProps,
24
30
  TrueSheetRouterOptions
25
- >(
26
- trueSheetNavigator,
27
- // expo-router's vendored StackRouter is structurally identical to @react-navigation's
28
- createTrueSheetRouter(StackRouter as StackRouterFactory),
29
- {
30
- createProps: ({ state, dispatch }) => ({
31
- routes: state.routes,
32
- dispatch,
33
- }),
34
- }
35
- );
31
+ >(trueSheetNavigator, sheetRouter, {
32
+ createProps: ({ state, dispatch }) => ({
33
+ routes: state.routes,
34
+ dispatch,
35
+ }),
36
+ });
36
37
 
37
38
  // Public props: `routes`/`dispatch` are injected by `createProps` (optional here
38
39
  // so the navigator type stays comparable), and expo-router intersects the event
@@ -86,4 +87,4 @@ export type {
86
87
  TrueSheetNavigationProp,
87
88
  TrueSheetNavigationState,
88
89
  TrueSheetScreenProps,
89
- } from '../types';
90
+ } from './types';
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Expo Router flavour of `../types`: same shapes, but bound to Expo Router's
3
+ * vendored React Navigation types so apps that only install `expo-router` still
4
+ * get real types instead of `any` — see `./base-types`.
5
+ */
6
+ import type { TrueSheetActionType } from '../actions';
7
+ import type {
8
+ TrueSheetActionHelpersOf,
9
+ TrueSheetDispatch,
10
+ TrueSheetNavigationEventMap,
11
+ TrueSheetNavigationOptions,
12
+ TrueSheetStateOf,
13
+ } from '../types';
14
+ import type {
15
+ DefaultNavigatorOptions,
16
+ NavigationAction,
17
+ NavigationHelpers,
18
+ NavigationProp,
19
+ NavigationState,
20
+ ParamListBase,
21
+ RouteProp,
22
+ Router,
23
+ StackActionHelpers,
24
+ StackRouterOptions,
25
+ } from './base-types';
26
+
27
+ export type TrueSheetRouterOptions = StackRouterOptions;
28
+
29
+ export type TrueSheetNavigationState<ParamList extends ParamListBase> = TrueSheetStateOf<
30
+ NavigationState<ParamList>
31
+ >;
32
+
33
+ export type TrueSheetRouterState = TrueSheetNavigationState<ParamListBase>;
34
+
35
+ export type TrueSheetRouter = Router<TrueSheetRouterState, TrueSheetActionType>;
36
+
37
+ export type TrueSheetRouterFactory = (options: TrueSheetRouterOptions) => TrueSheetRouter;
38
+
39
+ /**
40
+ * The base `StackRouter` factory to wrap — see `../types` for the shared contract.
41
+ */
42
+ export type StackRouterFactory = <
43
+ State extends NavigationState<ParamListBase>,
44
+ Action extends NavigationAction,
45
+ >(
46
+ options: TrueSheetRouterOptions
47
+ ) => Router<State, Action>;
48
+
49
+ export type TrueSheetRoute = TrueSheetNavigationState<ParamListBase>['routes'][number];
50
+
51
+ /**
52
+ * Props injected into the navigator content by Expo Router's `createProps`.
53
+ * Raw routes carry the custom fields (`closing`, `resizeIndex`, `resizeKey`)
54
+ * that the standard state strips out.
55
+ */
56
+ export interface TrueSheetNavigatorContentExtraProps {
57
+ routes: TrueSheetRoute[];
58
+ dispatch: TrueSheetDispatch;
59
+ }
60
+
61
+ export type TrueSheetActionHelpers<ParamList extends ParamListBase> = TrueSheetActionHelpersOf<
62
+ StackActionHelpers<ParamList>
63
+ >;
64
+
65
+ export type TrueSheetNavigationProp<
66
+ ParamList extends ParamListBase,
67
+ RouteName extends keyof ParamList = string,
68
+ NavigatorID extends string | undefined = undefined,
69
+ > = NavigationProp<
70
+ ParamList,
71
+ RouteName,
72
+ NavigatorID,
73
+ TrueSheetNavigationState<ParamList>,
74
+ TrueSheetNavigationOptions,
75
+ TrueSheetNavigationEventMap
76
+ > &
77
+ TrueSheetActionHelpers<ParamList>;
78
+
79
+ export type TrueSheetScreenProps<
80
+ ParamList extends ParamListBase,
81
+ RouteName extends keyof ParamList = string,
82
+ NavigatorID extends string | undefined = undefined,
83
+ > = {
84
+ navigation: TrueSheetNavigationProp<ParamList, RouteName, NavigatorID>;
85
+ route: RouteProp<ParamList, RouteName>;
86
+ };
87
+
88
+ export type TrueSheetNavigationHelpers = NavigationHelpers<
89
+ ParamListBase,
90
+ TrueSheetNavigationEventMap
91
+ >;
92
+
93
+ export type TrueSheetNavigatorProps = DefaultNavigatorOptions<
94
+ ParamListBase,
95
+ string | undefined,
96
+ TrueSheetNavigationState<ParamListBase>,
97
+ TrueSheetNavigationOptions,
98
+ TrueSheetNavigationEventMap,
99
+ unknown
100
+ > & {
101
+ /**
102
+ * The name of the route to use as the base screen.
103
+ * This screen will be rendered as a regular screen, while other screens are presented as sheets.
104
+ * Defaults to the first screen defined in the navigator.
105
+ */
106
+ initialRouteName?: string;
107
+ };
108
+
109
+ export type {
110
+ PositionChangeHandler,
111
+ TrueSheetDispatch,
112
+ TrueSheetNavigationEventMap,
113
+ TrueSheetNavigationOptions,
114
+ TrueSheetNavigationSheetProps,
115
+ TrueSheetStandardEventMap,
116
+ } from '../types';
@@ -4,16 +4,17 @@ import {
4
4
  type StandardNavigationTypeBagBase,
5
5
  } from '@react-navigation/native';
6
6
 
7
- import { createTrueSheetRouter, type StackRouterFactory } from './createTrueSheetRouter';
7
+ import { createTrueSheetRouter } from './createTrueSheetRouter';
8
8
  import { trueSheetNavigator } from './navigator';
9
9
  import type {
10
+ StackRouterFactory,
10
11
  TrueSheetActionHelpers,
11
12
  TrueSheetNavigationOptions,
12
13
  TrueSheetNavigationEventMap,
13
14
  TrueSheetNavigationState,
14
15
  TrueSheetNavigatorContentExtraProps,
16
+ TrueSheetRouterOptions,
15
17
  } from './types';
16
- import type { TrueSheetRouterOptions } from './createTrueSheetRouter';
17
18
 
18
19
  export interface TrueSheetNavigationTypeBag extends StandardNavigationTypeBagBase {
19
20
  State: TrueSheetNavigationState<this['ParamList']>;
@@ -62,20 +63,18 @@ export const createTrueSheetNavigator = createNavigator;
62
63
  export const createTrueSheetScreen = createScreen;
63
64
 
64
65
  export { TrueSheetActions, type TrueSheetActionType } from './actions';
65
- export {
66
- createTrueSheetRouter,
67
- type StackRouterFactory,
68
- type TrueSheetRouterOptions,
69
- } from './createTrueSheetRouter';
66
+ export { createTrueSheetRouter } from './createTrueSheetRouter';
70
67
  export { useTrueSheetNavigation } from './useTrueSheetNavigation';
71
68
 
72
69
  export type { DetentInfoEventPayload, PositionChangeEventPayload } from '../TrueSheet.types';
73
70
 
74
71
  export type {
72
+ StackRouterFactory,
75
73
  TrueSheetNavigationEventMap,
76
74
  TrueSheetNavigationHelpers,
77
75
  TrueSheetNavigationOptions,
78
76
  TrueSheetNavigationProp,
79
77
  TrueSheetNavigationState,
78
+ TrueSheetRouterOptions,
80
79
  TrueSheetScreenProps,
81
80
  } from './types';
@@ -1,21 +1,24 @@
1
+ import type { NavigatorArgs } from 'standard-navigation';
2
+
3
+ import type {
4
+ DetentInfoEventPayload,
5
+ PositionChangeEventPayload,
6
+ TrueSheetProps,
7
+ } from '../TrueSheet.types';
8
+ import type { TrueSheetActionType } from './actions';
1
9
  import type {
2
10
  DefaultNavigatorOptions,
3
11
  Descriptor,
12
+ NavigationAction,
4
13
  NavigationHelpers,
5
14
  NavigationProp,
6
15
  NavigationState,
7
16
  ParamListBase,
8
17
  RouteProp,
18
+ Router,
9
19
  StackActionHelpers,
10
- } from '@react-navigation/core';
11
- import type { NavigatorArgs } from 'standard-navigation';
12
-
13
- import type {
14
- DetentInfoEventPayload,
15
- PositionChangeEventPayload,
16
- TrueSheetProps,
17
- } from '../TrueSheet.types';
18
- import type { TrueSheetActionType } from './actions';
20
+ StackRouterOptions,
21
+ } from './base-types';
19
22
 
20
23
  export type PositionChangeHandler = (payload: PositionChangeEventPayload) => void;
21
24
 
@@ -74,18 +77,54 @@ export type TrueSheetNavigationEventMap = {
74
77
  sheetDidBlur: { data: undefined };
75
78
  };
76
79
 
77
- export type TrueSheetNavigationState<ParamList extends ParamListBase> = Omit<
78
- NavigationState<ParamList>,
80
+ /**
81
+ * A navigation state tagged as `true-sheet`, with the sheet fields the router
82
+ * adds to each route.
83
+ * Generic over the base state so each entry point can bind its own
84
+ * `NavigationState` — see `./base-types`.
85
+ */
86
+ export type TrueSheetStateOf<State extends { routes: readonly unknown[] }> = Omit<
87
+ State,
79
88
  'routes'
80
89
  > & {
81
90
  type: 'true-sheet';
82
- routes: (NavigationState<ParamList>['routes'][number] & {
91
+ routes: (State['routes'][number] & {
83
92
  resizeIndex?: number;
84
93
  resizeKey?: number;
85
94
  closing?: boolean;
86
95
  })[];
87
96
  };
88
97
 
98
+ export type TrueSheetNavigationState<ParamList extends ParamListBase> = TrueSheetStateOf<
99
+ NavigationState<ParamList>
100
+ >;
101
+
102
+ export type TrueSheetRouterState = TrueSheetNavigationState<ParamListBase>;
103
+
104
+ export type TrueSheetRouterOptions = StackRouterOptions;
105
+
106
+ export type TrueSheetRouter = Router<TrueSheetRouterState, TrueSheetActionType>;
107
+
108
+ /**
109
+ * The wrapped router factory — also the shape `createTrueSheetRouter` accepts,
110
+ * pre-instantiated so either entry point's `StackRouterFactory` fits it.
111
+ */
112
+ export type TrueSheetRouterFactory = (options: TrueSheetRouterOptions) => TrueSheetRouter;
113
+
114
+ /**
115
+ * The base `StackRouter` factory to wrap, typed generically over the state and
116
+ * action types the wrapper threads through — `StackRouter` is structural and
117
+ * never touches the sheet-specific fields.
118
+ * Injected by each entry point so the shared router never imports
119
+ * `@react-navigation/*` at runtime (Expo Router apps don't install it).
120
+ */
121
+ export type StackRouterFactory = <
122
+ State extends NavigationState<ParamListBase>,
123
+ Action extends NavigationAction,
124
+ >(
125
+ options: TrueSheetRouterOptions
126
+ ) => Router<State, Action>;
127
+
89
128
  /**
90
129
  * `TrueSheetNavigationEventMap` in the `standard-navigation` event-map shape.
91
130
  */
@@ -116,13 +155,20 @@ export interface TrueSheetNavigatorContentExtraProps {
116
155
  dispatch: TrueSheetDispatch;
117
156
  }
118
157
 
119
- export type TrueSheetActionHelpers<ParamList extends ParamListBase> =
120
- StackActionHelpers<ParamList> & {
121
- /**
122
- * Resize the sheet to a specific detent index.
123
- */
124
- resize(index?: number): void;
125
- };
158
+ /**
159
+ * Generic over the base helpers so each entry point can bind its own
160
+ * `StackActionHelpers` — see `./base-types`.
161
+ */
162
+ export type TrueSheetActionHelpersOf<Helpers> = Helpers & {
163
+ /**
164
+ * Resize the sheet to a specific detent index.
165
+ */
166
+ resize(index?: number): void;
167
+ };
168
+
169
+ export type TrueSheetActionHelpers<ParamList extends ParamListBase> = TrueSheetActionHelpersOf<
170
+ StackActionHelpers<ParamList>
171
+ >;
126
172
 
127
173
  export type TrueSheetNavigationProp<
128
174
  ParamList extends ParamListBase,