@lodev09/react-native-true-sheet 4.0.0-beta.4 → 4.0.0-beta.6
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.
- package/README.md +21 -2
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +0 -7
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentView.kt +0 -36
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentViewManager.kt +0 -1
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +0 -1
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewComponentDescriptor.h +0 -8
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewShadowNode.cpp +17 -38
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewShadowNode.h +0 -2
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewState.cpp +1 -2
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewState.h +1 -7
- package/ios/TrueSheetContainerView.h +0 -6
- package/ios/TrueSheetContainerView.mm +0 -1
- package/ios/TrueSheetContentView.h +0 -7
- package/ios/TrueSheetContentView.mm +0 -32
- package/ios/TrueSheetView.mm +0 -6
- package/ios/TrueSheetViewController.mm +35 -27
- package/lib/module/TrueSheet.js +10 -5
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/TrueSheet.web.js.map +1 -1
- package/lib/module/mocks/navigationExpoRouter.js.map +1 -1
- package/lib/module/navigation/base-types.js +2 -0
- package/lib/module/navigation/base-types.js.map +1 -0
- package/lib/module/navigation/createTrueSheetRouter.js +0 -9
- package/lib/module/navigation/createTrueSheetRouter.js.map +1 -1
- package/lib/module/navigation/expo-router/base-types.js +2 -0
- package/lib/module/navigation/expo-router/base-types.js.map +1 -0
- package/lib/module/navigation/expo-router/index.js +5 -3
- package/lib/module/navigation/expo-router/index.js.map +1 -1
- package/lib/module/navigation/expo-router/types.js +4 -0
- package/lib/module/navigation/expo-router/types.js.map +1 -0
- package/lib/module/navigation/index.js.map +1 -1
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +14 -0
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.web.d.ts.map +1 -1
- package/lib/typescript/src/mocks/navigationExpoRouter.d.ts +3 -3
- package/lib/typescript/src/mocks/navigationExpoRouter.d.ts.map +1 -1
- package/lib/typescript/src/navigation/base-types.d.ts +9 -0
- package/lib/typescript/src/navigation/base-types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/createTrueSheetRouter.d.ts +2 -13
- package/lib/typescript/src/navigation/createTrueSheetRouter.d.ts.map +1 -1
- package/lib/typescript/src/navigation/expo-router/base-types.d.ts +8 -0
- package/lib/typescript/src/navigation/expo-router/base-types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/expo-router/index.d.ts +5 -5
- package/lib/typescript/src/navigation/expo-router/index.d.ts.map +1 -1
- package/lib/typescript/src/navigation/expo-router/types.d.ts +44 -0
- package/lib/typescript/src/navigation/expo-router/types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/index.d.ts +3 -4
- package/lib/typescript/src/navigation/index.d.ts.map +1 -1
- package/lib/typescript/src/navigation/types.d.ts +34 -4
- package/lib/typescript/src/navigation/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/TrueSheet.tsx +14 -5
- package/src/TrueSheet.types.ts +15 -0
- package/src/TrueSheet.web.tsx +2 -1
- package/src/mocks/navigationExpoRouter.ts +6 -5
- package/src/navigation/base-types.ts +20 -0
- package/src/navigation/createTrueSheetRouter.ts +5 -33
- package/src/navigation/expo-router/base-types.ts +18 -0
- package/src/navigation/expo-router/index.ts +20 -19
- package/src/navigation/expo-router/types.ts +116 -0
- package/src/navigation/index.ts +6 -7
- package/src/navigation/types.ts +65 -19
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ParamListBase } from '
|
|
2
|
-
import type { TrueSheetNavigationOptions, TrueSheetNavigationProp, TrueSheetNavigationState, TrueSheetNavigatorContentExtraProps, TrueSheetNavigatorProps, TrueSheetStandardEventMap } from '
|
|
3
|
-
declare const SheetNavigator: import("react").ForwardRefExoticComponent<Omit<import("expo-router/build/standard-navigation/types").StandardRouterNavigatorProps<TrueSheetNavigationState<ParamListBase>, TrueSheetNavigationOptions, TrueSheetStandardEventMap, TrueSheetNavigatorContentExtraProps, import("
|
|
4
|
-
Screen: (props: import("expo-router").ScreenProps<TrueSheetNavigationOptions, TrueSheetNavigationState<ParamListBase>, TrueSheetStandardEventMap & import("expo-router/
|
|
1
|
+
import type { ParamListBase } from './base-types';
|
|
2
|
+
import type { TrueSheetNavigationOptions, TrueSheetNavigationProp, TrueSheetNavigationState, TrueSheetNavigatorContentExtraProps, TrueSheetNavigatorProps, TrueSheetStandardEventMap } from './types';
|
|
3
|
+
declare const SheetNavigator: import("react").ForwardRefExoticComponent<Omit<import("expo-router/build/standard-navigation/types").StandardRouterNavigatorProps<TrueSheetNavigationState<ParamListBase>, TrueSheetNavigationOptions, TrueSheetStandardEventMap, TrueSheetNavigatorContentExtraProps, import("expo-router").StackRouterOptions>, "children"> & Partial<Pick<import("expo-router/build/standard-navigation/types").StandardRouterNavigatorProps<TrueSheetNavigationState<ParamListBase>, TrueSheetNavigationOptions, TrueSheetStandardEventMap, TrueSheetNavigatorContentExtraProps, import("expo-router").StackRouterOptions>, "children">> & import("react").RefAttributes<unknown>> & {
|
|
4
|
+
Screen: (props: import("expo-router").ScreenProps<TrueSheetNavigationOptions, TrueSheetNavigationState<ParamListBase>, TrueSheetStandardEventMap & import("expo-router/react-navigation").EventMapBase>) => null;
|
|
5
5
|
Protected: typeof import("expo-router/build/views/Protected").Protected;
|
|
6
6
|
};
|
|
7
7
|
type SheetProps = Omit<React.ComponentProps<typeof SheetNavigator>, 'screenListeners' | 'routes' | 'dispatch'> & Partial<Pick<React.ComponentProps<typeof SheetNavigator>, 'routes' | 'dispatch'>> & Pick<TrueSheetNavigatorProps, 'screenListeners'>;
|
|
@@ -33,5 +33,5 @@ export declare const Sheet: React.ComponentType<SheetProps> & {
|
|
|
33
33
|
export declare const useTrueSheetNavigation: <T extends ParamListBase = ParamListBase>() => TrueSheetNavigationProp<T>;
|
|
34
34
|
export { TrueSheetActions, type TrueSheetActionType } from '../actions';
|
|
35
35
|
export type { DetentInfoEventPayload, PositionChangeEventPayload } from '../../TrueSheet.types';
|
|
36
|
-
export type { TrueSheetNavigationEventMap, TrueSheetNavigationHelpers, TrueSheetNavigationOptions, TrueSheetNavigationProp, TrueSheetNavigationState, TrueSheetScreenProps, } from '
|
|
36
|
+
export type { TrueSheetNavigationEventMap, TrueSheetNavigationHelpers, TrueSheetNavigationOptions, TrueSheetNavigationProp, TrueSheetNavigationState, TrueSheetScreenProps, } from './types';
|
|
37
37
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/navigation/expo-router/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/navigation/expo-router/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAEV,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EACxB,mCAAmC,EACnC,uBAAuB,EAGvB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AASjB,QAAA,MAAM,cAAc;;;CAWlB,CAAC;AAMH,KAAK,UAAU,GAAG,IAAI,CACpB,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,EAC3C,iBAAiB,GAAG,QAAQ,GAAG,UAAU,CAC1C,GACC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC,CAAC,GACjF,IAAI,CAAC,uBAAuB,EAAE,iBAAiB,CAAC,CAAC;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,KAAK,EAAqB,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG;IACvE,MAAM,EAAE,OAAO,cAAc,CAAC,MAAM,CAAC;IACrC,SAAS,EAAE,OAAO,cAAc,CAAC,SAAS,CAAC;CAC5C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,CAAC,SAAS,aAAa,GAAG,aAAa,OACpC,uBAAuB,CAAC,CAAC,CAAgD,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAExE,YAAY,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEhG,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 { TrueSheetActionHelpersOf, TrueSheetDispatch, TrueSheetNavigationEventMap, TrueSheetNavigationOptions, TrueSheetStateOf } from '../types';
|
|
8
|
+
import type { DefaultNavigatorOptions, NavigationAction, NavigationHelpers, NavigationProp, NavigationState, ParamListBase, RouteProp, Router, StackActionHelpers, StackRouterOptions } from './base-types';
|
|
9
|
+
export type TrueSheetRouterOptions = StackRouterOptions;
|
|
10
|
+
export type TrueSheetNavigationState<ParamList extends ParamListBase> = TrueSheetStateOf<NavigationState<ParamList>>;
|
|
11
|
+
export type TrueSheetRouterState = TrueSheetNavigationState<ParamListBase>;
|
|
12
|
+
export type TrueSheetRouter = Router<TrueSheetRouterState, TrueSheetActionType>;
|
|
13
|
+
export type TrueSheetRouterFactory = (options: TrueSheetRouterOptions) => TrueSheetRouter;
|
|
14
|
+
/**
|
|
15
|
+
* The base `StackRouter` factory to wrap — see `../types` for the shared contract.
|
|
16
|
+
*/
|
|
17
|
+
export type StackRouterFactory = <State extends NavigationState<ParamListBase>, Action extends NavigationAction>(options: TrueSheetRouterOptions) => Router<State, Action>;
|
|
18
|
+
export type TrueSheetRoute = TrueSheetNavigationState<ParamListBase>['routes'][number];
|
|
19
|
+
/**
|
|
20
|
+
* Props injected into the navigator content by Expo Router's `createProps`.
|
|
21
|
+
* Raw routes carry the custom fields (`closing`, `resizeIndex`, `resizeKey`)
|
|
22
|
+
* that the standard state strips out.
|
|
23
|
+
*/
|
|
24
|
+
export interface TrueSheetNavigatorContentExtraProps {
|
|
25
|
+
routes: TrueSheetRoute[];
|
|
26
|
+
dispatch: TrueSheetDispatch;
|
|
27
|
+
}
|
|
28
|
+
export type TrueSheetActionHelpers<ParamList extends ParamListBase> = TrueSheetActionHelpersOf<StackActionHelpers<ParamList>>;
|
|
29
|
+
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>;
|
|
30
|
+
export type TrueSheetScreenProps<ParamList extends ParamListBase, RouteName extends keyof ParamList = string, NavigatorID extends string | undefined = undefined> = {
|
|
31
|
+
navigation: TrueSheetNavigationProp<ParamList, RouteName, NavigatorID>;
|
|
32
|
+
route: RouteProp<ParamList, RouteName>;
|
|
33
|
+
};
|
|
34
|
+
export type TrueSheetNavigationHelpers = NavigationHelpers<ParamListBase, TrueSheetNavigationEventMap>;
|
|
35
|
+
export type TrueSheetNavigatorProps = DefaultNavigatorOptions<ParamListBase, string | undefined, TrueSheetNavigationState<ParamListBase>, TrueSheetNavigationOptions, TrueSheetNavigationEventMap, unknown> & {
|
|
36
|
+
/**
|
|
37
|
+
* The name of the route to use as the base screen.
|
|
38
|
+
* This screen will be rendered as a regular screen, while other screens are presented as sheets.
|
|
39
|
+
* Defaults to the first screen defined in the navigator.
|
|
40
|
+
*/
|
|
41
|
+
initialRouteName?: string;
|
|
42
|
+
};
|
|
43
|
+
export type { PositionChangeHandler, TrueSheetDispatch, TrueSheetNavigationEventMap, TrueSheetNavigationOptions, TrueSheetNavigationSheetProps, TrueSheetStandardEventMap, } from '../types';
|
|
44
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/navigation/expo-router/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,2BAA2B,EAC3B,0BAA0B,EAC1B,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,EACb,SAAS,EACT,MAAM,EACN,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAExD,MAAM,MAAM,wBAAwB,CAAC,SAAS,SAAS,aAAa,IAAI,gBAAgB,CACtF,eAAe,CAAC,SAAS,CAAC,CAC3B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,wBAAwB,CAAC,aAAa,CAAC,CAAC;AAE3E,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,CAAC;AAEhF,MAAM,MAAM,sBAA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A2B,CAC5B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,uBAAuB,CAC3D,aAAa,EACb,MAAM,GAAG,SAAS,EAClB,wBAAwB,CAAC,aAAa,CAAC,EACvC,0BAA0B,EAC1B,2BAA2B,EAC3B,OAAO,CACR,GAAG;IACF;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,YAAY,EACV,qBAAqB,EACrB,iBAAiB,EACjB,2BAA2B,EAC3B,0BAA0B,EAC1B,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,UAAU,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type StandardNavigationTypeBagBase } from '@react-navigation/native';
|
|
2
|
-
import type { TrueSheetActionHelpers, TrueSheetNavigationOptions, TrueSheetNavigationEventMap, TrueSheetNavigationState } from './types';
|
|
3
|
-
import type { TrueSheetRouterOptions } from './createTrueSheetRouter';
|
|
2
|
+
import type { TrueSheetActionHelpers, TrueSheetNavigationOptions, TrueSheetNavigationEventMap, TrueSheetNavigationState, TrueSheetRouterOptions } from './types';
|
|
4
3
|
export interface TrueSheetNavigationTypeBag extends StandardNavigationTypeBagBase {
|
|
5
4
|
State: TrueSheetNavigationState<this['ParamList']>;
|
|
6
5
|
ActionHelpers: TrueSheetActionHelpers<this['ParamList']>;
|
|
@@ -39,8 +38,8 @@ export declare const createTrueSheetScreen: import("@react-navigation/core").Sta
|
|
|
39
38
|
Navigator: import("react").ComponentType<{}>;
|
|
40
39
|
}>;
|
|
41
40
|
export { TrueSheetActions, type TrueSheetActionType } from './actions';
|
|
42
|
-
export { createTrueSheetRouter
|
|
41
|
+
export { createTrueSheetRouter } from './createTrueSheetRouter';
|
|
43
42
|
export { useTrueSheetNavigation } from './useTrueSheetNavigation';
|
|
44
43
|
export type { DetentInfoEventPayload, PositionChangeEventPayload } from '../TrueSheet.types';
|
|
45
|
-
export type { TrueSheetNavigationEventMap, TrueSheetNavigationHelpers, TrueSheetNavigationOptions, TrueSheetNavigationProp, TrueSheetNavigationState, TrueSheetScreenProps, } from './types';
|
|
44
|
+
export type { StackRouterFactory, TrueSheetNavigationEventMap, TrueSheetNavigationHelpers, TrueSheetNavigationOptions, TrueSheetNavigationProp, TrueSheetNavigationState, TrueSheetRouterOptions, TrueSheetScreenProps, } from './types';
|
|
46
45
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/navigation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,0BAA0B,CAAC;AAIlC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/navigation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,0BAA0B,CAAC;AAIlC,OAAO,KAAK,EAEV,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EAExB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,0BAA2B,SAAQ,6BAA6B;IAC/E,KAAK,EAAE,wBAAwB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACnD,aAAa,EAAE,sBAAsB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACzD,aAAa,EAAE,0BAA0B,CAAC;IAC1C,QAAQ,EAAE,2BAA2B,CAAC;IACtC,aAAa,EAAE,sBAAsB,CAAC;CACvC;AAYD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,wBAAwB,sGAAkB,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;EAAe,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,YAAY,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAE7F,YAAY,EACV,kBAAkB,EAClB,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { DefaultNavigatorOptions, Descriptor, NavigationHelpers, NavigationProp, NavigationState, ParamListBase, RouteProp, StackActionHelpers } from '@react-navigation/core';
|
|
2
1
|
import type { NavigatorArgs } from 'standard-navigation';
|
|
3
2
|
import type { DetentInfoEventPayload, PositionChangeEventPayload, TrueSheetProps } from '../TrueSheet.types';
|
|
4
3
|
import type { TrueSheetActionType } from './actions';
|
|
4
|
+
import type { DefaultNavigatorOptions, Descriptor, NavigationAction, NavigationHelpers, NavigationProp, NavigationState, ParamListBase, RouteProp, Router, StackActionHelpers, StackRouterOptions } from './base-types';
|
|
5
5
|
export type PositionChangeHandler = (payload: PositionChangeEventPayload) => void;
|
|
6
6
|
export type TrueSheetNavigationEventMap = {
|
|
7
7
|
/**
|
|
@@ -83,14 +83,39 @@ export type TrueSheetNavigationEventMap = {
|
|
|
83
83
|
data: undefined;
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
|
-
|
|
86
|
+
/**
|
|
87
|
+
* A navigation state tagged as `true-sheet`, with the sheet fields the router
|
|
88
|
+
* adds to each route.
|
|
89
|
+
* Generic over the base state so each entry point can bind its own
|
|
90
|
+
* `NavigationState` — see `./base-types`.
|
|
91
|
+
*/
|
|
92
|
+
export type TrueSheetStateOf<State extends {
|
|
93
|
+
routes: readonly unknown[];
|
|
94
|
+
}> = Omit<State, 'routes'> & {
|
|
87
95
|
type: 'true-sheet';
|
|
88
|
-
routes: (
|
|
96
|
+
routes: (State['routes'][number] & {
|
|
89
97
|
resizeIndex?: number;
|
|
90
98
|
resizeKey?: number;
|
|
91
99
|
closing?: boolean;
|
|
92
100
|
})[];
|
|
93
101
|
};
|
|
102
|
+
export type TrueSheetNavigationState<ParamList extends ParamListBase> = TrueSheetStateOf<NavigationState<ParamList>>;
|
|
103
|
+
export type TrueSheetRouterState = TrueSheetNavigationState<ParamListBase>;
|
|
104
|
+
export type TrueSheetRouterOptions = StackRouterOptions;
|
|
105
|
+
export type TrueSheetRouter = Router<TrueSheetRouterState, TrueSheetActionType>;
|
|
106
|
+
/**
|
|
107
|
+
* The wrapped router factory — also the shape `createTrueSheetRouter` accepts,
|
|
108
|
+
* pre-instantiated so either entry point's `StackRouterFactory` fits it.
|
|
109
|
+
*/
|
|
110
|
+
export type TrueSheetRouterFactory = (options: TrueSheetRouterOptions) => TrueSheetRouter;
|
|
111
|
+
/**
|
|
112
|
+
* The base `StackRouter` factory to wrap, typed generically over the state and
|
|
113
|
+
* action types the wrapper threads through — `StackRouter` is structural and
|
|
114
|
+
* never touches the sheet-specific fields.
|
|
115
|
+
* Injected by each entry point so the shared router never imports
|
|
116
|
+
* `@react-navigation/*` at runtime (Expo Router apps don't install it).
|
|
117
|
+
*/
|
|
118
|
+
export type StackRouterFactory = <State extends NavigationState<ParamListBase>, Action extends NavigationAction>(options: TrueSheetRouterOptions) => Router<State, Action>;
|
|
94
119
|
/**
|
|
95
120
|
* `TrueSheetNavigationEventMap` in the `standard-navigation` event-map shape.
|
|
96
121
|
*/
|
|
@@ -113,12 +138,17 @@ export interface TrueSheetNavigatorContentExtraProps {
|
|
|
113
138
|
routes: TrueSheetRoute[];
|
|
114
139
|
dispatch: TrueSheetDispatch;
|
|
115
140
|
}
|
|
116
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Generic over the base helpers so each entry point can bind its own
|
|
143
|
+
* `StackActionHelpers` — see `./base-types`.
|
|
144
|
+
*/
|
|
145
|
+
export type TrueSheetActionHelpersOf<Helpers> = Helpers & {
|
|
117
146
|
/**
|
|
118
147
|
* Resize the sheet to a specific detent index.
|
|
119
148
|
*/
|
|
120
149
|
resize(index?: number): void;
|
|
121
150
|
};
|
|
151
|
+
export type TrueSheetActionHelpers<ParamList extends ParamListBase> = TrueSheetActionHelpersOf<StackActionHelpers<ParamList>>;
|
|
122
152
|
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>;
|
|
123
153
|
export type TrueSheetScreenProps<ParamList extends ParamListBase, RouteName extends keyof ParamList = string, NavigatorID extends string | undefined = undefined> = {
|
|
124
154
|
navigation: TrueSheetNavigationProp<ParamList, RouteName, NavigatorID>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/navigation/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/navigation/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EACV,sBAAsB,EACtB,0BAA0B,EAC1B,cAAc,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EACV,uBAAuB,EACvB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,EACb,SAAS,EACT,MAAM,EACN,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,0BAA0B,KAAK,IAAI,CAAC;AAElF,MAAM,MAAM,2BAA2B,GAAG;IACxC;;OAEG;IACH,gBAAgB,EAAE;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ACb,kBAAkB,GAClB,iBAAiB,GACjB,cAAc,GACd,OAAO,GACP,QAAQ,GACR,aAAa,GACb,eAAe,GACf,QAAQ,GACR,aAAa,GACb,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,iBAAiB,GACjB,QAAQ,GACR,cAAc,GACd,WAAW,GACX,UAAU,GACV,gBAAgB,CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,6BAA6B,GAAG;IACvE;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;;;;;;;;;;;;;OAiBG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,uBAAuB,CAC3D,aAAa,EACb,MAAM,GAAG,SAAS,EAClB,wBAAwB,CAAC,aAAa,CAAC,EACvC,0BAA0B,EAC1B,2BAA2B,EAC3B,OAAO,CACR,GAAG;IACF;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,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"}
|
package/package.json
CHANGED
package/src/TrueSheet.tsx
CHANGED
|
@@ -130,9 +130,10 @@ export class TrueSheet
|
|
|
130
130
|
|
|
131
131
|
this.validateDetents();
|
|
132
132
|
|
|
133
|
-
// Lazy load by default, except when
|
|
133
|
+
// Lazy load by default, except when auto-presenting or when lazy is disabled
|
|
134
134
|
const shouldRenderImmediately =
|
|
135
|
-
props.initialDetentIndex !== undefined && props.initialDetentIndex >= 0
|
|
135
|
+
(props.initialDetentIndex !== undefined && props.initialDetentIndex >= 0) ||
|
|
136
|
+
props.lazy === false;
|
|
136
137
|
|
|
137
138
|
this.state = {
|
|
138
139
|
shouldRenderNativeView: shouldRenderImmediately,
|
|
@@ -350,9 +351,8 @@ export class TrueSheet
|
|
|
350
351
|
this.backHandlerSubscription?.remove();
|
|
351
352
|
this.backHandlerSubscription = null;
|
|
352
353
|
|
|
353
|
-
//
|
|
354
|
-
|
|
355
|
-
if (!this.isPresenting) {
|
|
354
|
+
// Non-lazy content stays mounted; otherwise clean it up unless another presentation is active.
|
|
355
|
+
if (!this.isPresenting && this.props.lazy !== false) {
|
|
356
356
|
this.setState({ shouldRenderNativeView: false });
|
|
357
357
|
}
|
|
358
358
|
|
|
@@ -484,6 +484,14 @@ export class TrueSheet
|
|
|
484
484
|
this.registerInstance();
|
|
485
485
|
this.updateScrollableHandle();
|
|
486
486
|
|
|
487
|
+
if (
|
|
488
|
+
prevProps.lazy !== false &&
|
|
489
|
+
this.props.lazy === false &&
|
|
490
|
+
!this.state.shouldRenderNativeView
|
|
491
|
+
) {
|
|
492
|
+
this.setState({ shouldRenderNativeView: true });
|
|
493
|
+
}
|
|
494
|
+
|
|
487
495
|
// Validate when detents prop changes
|
|
488
496
|
if (prevProps.detents !== this.props.detents) {
|
|
489
497
|
this.validateDetents();
|
|
@@ -543,6 +551,7 @@ export class TrueSheet
|
|
|
543
551
|
insetAdjustment = 'automatic',
|
|
544
552
|
...rest
|
|
545
553
|
} = this.props;
|
|
554
|
+
delete rest.lazy;
|
|
546
555
|
|
|
547
556
|
// Trim to max 3 detents and clamp fractions
|
|
548
557
|
const resolvedDetents: number[] = detents.slice(0, 3).map((detent) => {
|
package/src/TrueSheet.types.ts
CHANGED
|
@@ -431,6 +431,21 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
431
431
|
*/
|
|
432
432
|
initialDetentAnimated?: boolean;
|
|
433
433
|
|
|
434
|
+
/**
|
|
435
|
+
* Specify whether the sheet content should mount lazily, on first presentation.
|
|
436
|
+
* Set to `false` to mount the content before presentation without presenting the sheet.
|
|
437
|
+
* Use this when content is not ready on the first render, then call `present()`
|
|
438
|
+
* after your readiness signal so auto detents measure the settled content.
|
|
439
|
+
*
|
|
440
|
+
* Content that requires window attachment to measure, such as SwiftUI-hosted views,
|
|
441
|
+
* still only measures during presentation.
|
|
442
|
+
*
|
|
443
|
+
* @platform android
|
|
444
|
+
* @platform ios
|
|
445
|
+
* @default true
|
|
446
|
+
*/
|
|
447
|
+
lazy?: boolean;
|
|
448
|
+
|
|
434
449
|
/**
|
|
435
450
|
* The detent index that the sheet should start to dim the background.
|
|
436
451
|
* This is ignored if `dimmed` is set to `false`.
|
package/src/TrueSheet.web.tsx
CHANGED
|
@@ -1268,7 +1268,8 @@ const TrueSheetComponent = forwardRef<TrueSheetMethods, TrueSheetProps>((props,
|
|
|
1268
1268
|
{/* Content lays out naturally like native — fill only for auto
|
|
1269
1269
|
detents with a plugged scrollable, where natural layout is
|
|
1270
1270
|
circular (sheet height derives from the scroll content size).
|
|
1271
|
-
|
|
1271
|
+
Unlike native, CSS won't cap the content to the container
|
|
1272
|
+
(no fit-content flex basis), so the fill is still needed here. */}
|
|
1272
1273
|
<View
|
|
1273
1274
|
ref={contentRef}
|
|
1274
1275
|
style={hasAutoDetent && hasBoundedScrollable ? [contentFillStyle, style] : style}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { ParamListBase } from '
|
|
2
|
-
|
|
3
|
-
import type { TrueSheetNavigationProp } from '../navigation/types';
|
|
1
|
+
import type { ParamListBase } from '../navigation/expo-router/base-types';
|
|
2
|
+
import type { TrueSheetNavigationProp } from '../navigation/expo-router/types';
|
|
4
3
|
import {
|
|
5
4
|
TrueSheetActions,
|
|
6
5
|
useTrueSheetNavigation as useTrueSheetNavigationMock,
|
|
@@ -22,8 +21,10 @@ export const Sheet = Object.assign(
|
|
|
22
21
|
* Mock useTrueSheetNavigation hook for testing.
|
|
23
22
|
*/
|
|
24
23
|
export const useTrueSheetNavigation = jest.fn(
|
|
24
|
+
// Double cast: the shared mock is typed against React Navigation, this entry
|
|
25
|
+
// against Expo Router's vendored copy — identical shapes, unrelated declarations
|
|
25
26
|
<T extends ParamListBase = ParamListBase>(): TrueSheetNavigationProp<T> =>
|
|
26
|
-
useTrueSheetNavigationMock() as TrueSheetNavigationProp<T>
|
|
27
|
+
useTrueSheetNavigationMock() as unknown as TrueSheetNavigationProp<T>
|
|
27
28
|
);
|
|
28
29
|
|
|
29
30
|
export { TrueSheetActions };
|
|
@@ -37,4 +38,4 @@ export type {
|
|
|
37
38
|
TrueSheetNavigationProp,
|
|
38
39
|
TrueSheetNavigationState,
|
|
39
40
|
TrueSheetScreenProps,
|
|
40
|
-
} from '../navigation/types';
|
|
41
|
+
} from '../navigation/expo-router/types';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base navigation types for the React Navigation entry point.
|
|
3
|
+
*
|
|
4
|
+
* The Expo Router entry has its own copy sourced from `expo-router/react-navigation`
|
|
5
|
+
* (see `./expo-router/base-types`) because Expo Router apps never install
|
|
6
|
+
* `@react-navigation/*` — importing it there would silently resolve to `any`.
|
|
7
|
+
*/
|
|
8
|
+
export type {
|
|
9
|
+
DefaultNavigatorOptions,
|
|
10
|
+
Descriptor,
|
|
11
|
+
NavigationAction,
|
|
12
|
+
NavigationHelpers,
|
|
13
|
+
NavigationProp,
|
|
14
|
+
NavigationState,
|
|
15
|
+
ParamListBase,
|
|
16
|
+
RouteProp,
|
|
17
|
+
Router,
|
|
18
|
+
StackActionHelpers,
|
|
19
|
+
StackRouterOptions,
|
|
20
|
+
} from '@react-navigation/core';
|
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
NavigationState,
|
|
4
|
-
ParamListBase,
|
|
5
|
-
Router,
|
|
6
|
-
StackRouterOptions,
|
|
7
|
-
} from '@react-navigation/core';
|
|
8
|
-
|
|
9
|
-
import { TrueSheetActions, type TrueSheetActionType } from './actions';
|
|
10
|
-
import type { TrueSheetNavigationState } from './types';
|
|
11
|
-
|
|
12
|
-
export type TrueSheetRouterOptions = StackRouterOptions;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The base `StackRouter` factory to wrap, typed generically over the state and
|
|
16
|
-
* action types the wrapper threads through — `StackRouter` is structural and
|
|
17
|
-
* never touches the sheet-specific fields.
|
|
18
|
-
* Injected by each entry point so the shared router never imports
|
|
19
|
-
* `@react-navigation/*` at runtime (Expo Router apps don't install it).
|
|
20
|
-
*/
|
|
21
|
-
export type StackRouterFactory = <
|
|
22
|
-
State extends NavigationState<ParamListBase>,
|
|
23
|
-
Action extends NavigationAction,
|
|
24
|
-
>(
|
|
25
|
-
options: TrueSheetRouterOptions
|
|
26
|
-
) => Router<State, Action>;
|
|
1
|
+
import { TrueSheetActions } from './actions';
|
|
2
|
+
import type { TrueSheetRouter, TrueSheetRouterFactory, TrueSheetRouterOptions } from './types';
|
|
27
3
|
|
|
28
4
|
const uid = () => Math.random().toString(36).slice(2, 10);
|
|
29
5
|
|
|
@@ -56,13 +32,9 @@ const ensureBaseRoute = <T extends { routes: { name: string }[] }>(
|
|
|
56
32
|
};
|
|
57
33
|
|
|
58
34
|
export const createTrueSheetRouter =
|
|
59
|
-
(stackRouter:
|
|
60
|
-
(
|
|
61
|
-
routerOptions
|
|
62
|
-
): Router<TrueSheetNavigationState<ParamListBase>, TrueSheetActionType> => {
|
|
63
|
-
const baseRouter = stackRouter<TrueSheetNavigationState<ParamListBase>, TrueSheetActionType>(
|
|
64
|
-
routerOptions
|
|
65
|
-
);
|
|
35
|
+
(stackRouter: TrueSheetRouterFactory) =>
|
|
36
|
+
(routerOptions: TrueSheetRouterOptions): TrueSheetRouter => {
|
|
37
|
+
const baseRouter = stackRouter(routerOptions);
|
|
66
38
|
|
|
67
39
|
return {
|
|
68
40
|
...baseRouter,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base navigation types for the Expo Router entry point.
|
|
3
|
+
*
|
|
4
|
+
* Sourced from Expo Router's vendored React Navigation so apps that only install
|
|
5
|
+
* `expo-router` still get real types — see `../base-types` for the React Navigation copy.
|
|
6
|
+
*/
|
|
7
|
+
export type {
|
|
8
|
+
DefaultNavigatorOptions,
|
|
9
|
+
NavigationAction,
|
|
10
|
+
NavigationHelpers,
|
|
11
|
+
NavigationProp,
|
|
12
|
+
NavigationState,
|
|
13
|
+
ParamListBase,
|
|
14
|
+
RouteProp,
|
|
15
|
+
Router,
|
|
16
|
+
StackActionHelpers,
|
|
17
|
+
StackRouterOptions,
|
|
18
|
+
} from 'expo-router/react-navigation';
|
|
@@ -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 '
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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 '
|
|
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';
|
package/src/navigation/index.ts
CHANGED
|
@@ -4,16 +4,17 @@ import {
|
|
|
4
4
|
type StandardNavigationTypeBagBase,
|
|
5
5
|
} from '@react-navigation/native';
|
|
6
6
|
|
|
7
|
-
import { 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';
|