@react-navigation/core 6.0.2
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/LICENSE +21 -0
- package/README.md +38 -0
- package/lib/commonjs/BaseNavigationContainer.js +393 -0
- package/lib/commonjs/BaseNavigationContainer.js.map +1 -0
- package/lib/commonjs/CurrentRenderContext.js +21 -0
- package/lib/commonjs/CurrentRenderContext.js.map +1 -0
- package/lib/commonjs/EnsureSingleNavigator.js +53 -0
- package/lib/commonjs/EnsureSingleNavigator.js.map +1 -0
- package/lib/commonjs/Group.js +15 -0
- package/lib/commonjs/Group.js.map +1 -0
- package/lib/commonjs/NavigationBuilderContext.js +23 -0
- package/lib/commonjs/NavigationBuilderContext.js.map +1 -0
- package/lib/commonjs/NavigationContainerRefContext.js +20 -0
- package/lib/commonjs/NavigationContainerRefContext.js.map +1 -0
- package/lib/commonjs/NavigationContext.js +20 -0
- package/lib/commonjs/NavigationContext.js.map +1 -0
- package/lib/commonjs/NavigationHelpersContext.js +21 -0
- package/lib/commonjs/NavigationHelpersContext.js.map +1 -0
- package/lib/commonjs/NavigationRouteContext.js +20 -0
- package/lib/commonjs/NavigationRouteContext.js.map +1 -0
- package/lib/commonjs/NavigationStateContext.js +42 -0
- package/lib/commonjs/NavigationStateContext.js.map +1 -0
- package/lib/commonjs/SceneView.js +97 -0
- package/lib/commonjs/SceneView.js.map +1 -0
- package/lib/commonjs/Screen.js +15 -0
- package/lib/commonjs/Screen.js.map +1 -0
- package/lib/commonjs/StaticContainer.js +43 -0
- package/lib/commonjs/StaticContainer.js.map +1 -0
- package/lib/commonjs/UnhandledActionContext.js +17 -0
- package/lib/commonjs/UnhandledActionContext.js.map +1 -0
- package/lib/commonjs/checkDuplicateRouteNames.js +31 -0
- package/lib/commonjs/checkDuplicateRouteNames.js.map +1 -0
- package/lib/commonjs/checkSerializable.js +59 -0
- package/lib/commonjs/checkSerializable.js.map +1 -0
- package/lib/commonjs/createNavigationContainerRef.js +82 -0
- package/lib/commonjs/createNavigationContainerRef.js.map +1 -0
- package/lib/commonjs/createNavigatorFactory.js +34 -0
- package/lib/commonjs/createNavigatorFactory.js.map +1 -0
- package/lib/commonjs/findFocusedRoute.js +22 -0
- package/lib/commonjs/findFocusedRoute.js.map +1 -0
- package/lib/commonjs/fromEntries.js +19 -0
- package/lib/commonjs/fromEntries.js.map +1 -0
- package/lib/commonjs/getActionFromState.js +99 -0
- package/lib/commonjs/getActionFromState.js.map +1 -0
- package/lib/commonjs/getFocusedRouteNameFromRoute.js +23 -0
- package/lib/commonjs/getFocusedRouteNameFromRoute.js.map +1 -0
- package/lib/commonjs/getPathFromState.js +238 -0
- package/lib/commonjs/getPathFromState.js.map +1 -0
- package/lib/commonjs/getStateFromPath.js +450 -0
- package/lib/commonjs/getStateFromPath.js.map +1 -0
- package/lib/commonjs/index.js +227 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/isArrayEqual.js +15 -0
- package/lib/commonjs/isArrayEqual.js.map +1 -0
- package/lib/commonjs/types.js +18 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/useChildListeners.js +38 -0
- package/lib/commonjs/useChildListeners.js.map +1 -0
- package/lib/commonjs/useComponent.js +36 -0
- package/lib/commonjs/useComponent.js.map +1 -0
- package/lib/commonjs/useCurrentRender.js +33 -0
- package/lib/commonjs/useCurrentRender.js.map +1 -0
- package/lib/commonjs/useDescriptors.js +141 -0
- package/lib/commonjs/useDescriptors.js.map +1 -0
- package/lib/commonjs/useEventEmitter.js +118 -0
- package/lib/commonjs/useEventEmitter.js.map +1 -0
- package/lib/commonjs/useFocusEffect.js +97 -0
- package/lib/commonjs/useFocusEffect.js.map +1 -0
- package/lib/commonjs/useFocusEvents.js +77 -0
- package/lib/commonjs/useFocusEvents.js.map +1 -0
- package/lib/commonjs/useFocusedListenersChildrenAdapter.js +57 -0
- package/lib/commonjs/useFocusedListenersChildrenAdapter.js.map +1 -0
- package/lib/commonjs/useIsFocused.js +47 -0
- package/lib/commonjs/useIsFocused.js.map +1 -0
- package/lib/commonjs/useKeyedChildListeners.js +35 -0
- package/lib/commonjs/useKeyedChildListeners.js.map +1 -0
- package/lib/commonjs/useNavigation.js +36 -0
- package/lib/commonjs/useNavigation.js.map +1 -0
- package/lib/commonjs/useNavigationBuilder.js +480 -0
- package/lib/commonjs/useNavigationBuilder.js.map +1 -0
- package/lib/commonjs/useNavigationCache.js +122 -0
- package/lib/commonjs/useNavigationCache.js.map +1 -0
- package/lib/commonjs/useNavigationContainerRef.js +27 -0
- package/lib/commonjs/useNavigationContainerRef.js.map +1 -0
- package/lib/commonjs/useNavigationHelpers.js +77 -0
- package/lib/commonjs/useNavigationHelpers.js.map +1 -0
- package/lib/commonjs/useNavigationState.js +41 -0
- package/lib/commonjs/useNavigationState.js.map +1 -0
- package/lib/commonjs/useOnAction.js +118 -0
- package/lib/commonjs/useOnAction.js.map +1 -0
- package/lib/commonjs/useOnGetState.js +60 -0
- package/lib/commonjs/useOnGetState.js.map +1 -0
- package/lib/commonjs/useOnPreventRemove.js +89 -0
- package/lib/commonjs/useOnPreventRemove.js.map +1 -0
- package/lib/commonjs/useOnRouteFocus.js +45 -0
- package/lib/commonjs/useOnRouteFocus.js.map +1 -0
- package/lib/commonjs/useOptionsGetters.js +99 -0
- package/lib/commonjs/useOptionsGetters.js.map +1 -0
- package/lib/commonjs/useRegisterNavigator.js +40 -0
- package/lib/commonjs/useRegisterNavigator.js.map +1 -0
- package/lib/commonjs/useRoute.js +32 -0
- package/lib/commonjs/useRoute.js.map +1 -0
- package/lib/commonjs/useRouteCache.js +61 -0
- package/lib/commonjs/useRouteCache.js.map +1 -0
- package/lib/commonjs/useScheduleUpdate.js +44 -0
- package/lib/commonjs/useScheduleUpdate.js.map +1 -0
- package/lib/commonjs/useSyncState.js +76 -0
- package/lib/commonjs/useSyncState.js.map +1 -0
- package/lib/commonjs/validatePathConfig.js +31 -0
- package/lib/commonjs/validatePathConfig.js.map +1 -0
- package/lib/module/BaseNavigationContainer.js +360 -0
- package/lib/module/BaseNavigationContainer.js.map +1 -0
- package/lib/module/CurrentRenderContext.js +9 -0
- package/lib/module/CurrentRenderContext.js.map +1 -0
- package/lib/module/EnsureSingleNavigator.js +38 -0
- package/lib/module/EnsureSingleNavigator.js.map +1 -0
- package/lib/module/Group.js +8 -0
- package/lib/module/Group.js.map +1 -0
- package/lib/module/NavigationBuilderContext.js +11 -0
- package/lib/module/NavigationBuilderContext.js.map +1 -0
- package/lib/module/NavigationContainerRefContext.js +8 -0
- package/lib/module/NavigationContainerRefContext.js.map +1 -0
- package/lib/module/NavigationContext.js +8 -0
- package/lib/module/NavigationContext.js.map +1 -0
- package/lib/module/NavigationHelpersContext.js +9 -0
- package/lib/module/NavigationHelpersContext.js.map +1 -0
- package/lib/module/NavigationRouteContext.js +8 -0
- package/lib/module/NavigationRouteContext.js.map +1 -0
- package/lib/module/NavigationStateContext.js +27 -0
- package/lib/module/NavigationStateContext.js.map +1 -0
- package/lib/module/SceneView.js +80 -0
- package/lib/module/SceneView.js.map +1 -0
- package/lib/module/Screen.js +8 -0
- package/lib/module/Screen.js.map +1 -0
- package/lib/module/StaticContainer.js +30 -0
- package/lib/module/StaticContainer.js.map +1 -0
- package/lib/module/UnhandledActionContext.js +4 -0
- package/lib/module/UnhandledActionContext.js.map +1 -0
- package/lib/module/checkDuplicateRouteNames.js +24 -0
- package/lib/module/checkDuplicateRouteNames.js.map +1 -0
- package/lib/module/checkSerializable.js +52 -0
- package/lib/module/checkSerializable.js.map +1 -0
- package/lib/module/createNavigationContainerRef.js +71 -0
- package/lib/module/createNavigationContainerRef.js.map +1 -0
- package/lib/module/createNavigatorFactory.js +24 -0
- package/lib/module/createNavigatorFactory.js.map +1 -0
- package/lib/module/findFocusedRoute.js +15 -0
- package/lib/module/findFocusedRoute.js.map +1 -0
- package/lib/module/fromEntries.js +12 -0
- package/lib/module/fromEntries.js.map +1 -0
- package/lib/module/getActionFromState.js +92 -0
- package/lib/module/getActionFromState.js.map +1 -0
- package/lib/module/getFocusedRouteNameFromRoute.js +15 -0
- package/lib/module/getFocusedRouteNameFromRoute.js.map +1 -0
- package/lib/module/getPathFromState.js +223 -0
- package/lib/module/getPathFromState.js.map +1 -0
- package/lib/module/getStateFromPath.js +434 -0
- package/lib/module/getStateFromPath.js.map +1 -0
- package/lib/module/index.js +24 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/isArrayEqual.js +8 -0
- package/lib/module/isArrayEqual.js.map +1 -0
- package/lib/module/types.js +9 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/useChildListeners.js +27 -0
- package/lib/module/useChildListeners.js.map +1 -0
- package/lib/module/useComponent.js +24 -0
- package/lib/module/useComponent.js.map +1 -0
- package/lib/module/useCurrentRender.js +19 -0
- package/lib/module/useCurrentRender.js.map +1 -0
- package/lib/module/useDescriptors.js +122 -0
- package/lib/module/useDescriptors.js.map +1 -0
- package/lib/module/useEventEmitter.js +107 -0
- package/lib/module/useEventEmitter.js.map +1 -0
- package/lib/module/useFocusEffect.js +83 -0
- package/lib/module/useFocusEffect.js.map +1 -0
- package/lib/module/useFocusEvents.js +63 -0
- package/lib/module/useFocusEvents.js.map +1 -0
- package/lib/module/useFocusedListenersChildrenAdapter.js +43 -0
- package/lib/module/useFocusedListenersChildrenAdapter.js.map +1 -0
- package/lib/module/useIsFocused.js +34 -0
- package/lib/module/useIsFocused.js.map +1 -0
- package/lib/module/useKeyedChildListeners.js +24 -0
- package/lib/module/useKeyedChildListeners.js.map +1 -0
- package/lib/module/useNavigation.js +21 -0
- package/lib/module/useNavigation.js.map +1 -0
- package/lib/module/useNavigationBuilder.js +443 -0
- package/lib/module/useNavigationBuilder.js.map +1 -0
- package/lib/module/useNavigationCache.js +107 -0
- package/lib/module/useNavigationCache.js.map +1 -0
- package/lib/module/useNavigationContainerRef.js +12 -0
- package/lib/module/useNavigationContainerRef.js.map +1 -0
- package/lib/module/useNavigationHelpers.js +59 -0
- package/lib/module/useNavigationHelpers.js.map +1 -0
- package/lib/module/useNavigationState.js +27 -0
- package/lib/module/useNavigationState.js.map +1 -0
- package/lib/module/useOnAction.js +103 -0
- package/lib/module/useOnAction.js.map +1 -0
- package/lib/module/useOnGetState.js +43 -0
- package/lib/module/useOnGetState.js.map +1 -0
- package/lib/module/useOnPreventRemove.js +68 -0
- package/lib/module/useOnPreventRemove.js.map +1 -0
- package/lib/module/useOnRouteFocus.js +31 -0
- package/lib/module/useOnRouteFocus.js.map +1 -0
- package/lib/module/useOptionsGetters.js +83 -0
- package/lib/module/useOptionsGetters.js.map +1 -0
- package/lib/module/useRegisterNavigator.js +27 -0
- package/lib/module/useRegisterNavigator.js.map +1 -0
- package/lib/module/useRoute.js +18 -0
- package/lib/module/useRoute.js.map +1 -0
- package/lib/module/useRouteCache.js +47 -0
- package/lib/module/useRouteCache.js.map +1 -0
- package/lib/module/useScheduleUpdate.js +29 -0
- package/lib/module/useScheduleUpdate.js.map +1 -0
- package/lib/module/useSyncState.js +64 -0
- package/lib/module/useSyncState.js.map +1 -0
- package/lib/module/validatePathConfig.js +24 -0
- package/lib/module/validatePathConfig.js.map +1 -0
- package/lib/typescript/src/BaseNavigationContainer.d.ts +14 -0
- package/lib/typescript/src/CurrentRenderContext.d.ts +9 -0
- package/lib/typescript/src/EnsureSingleNavigator.d.ts +13 -0
- package/lib/typescript/src/Group.d.ts +6 -0
- package/lib/typescript/src/NavigationBuilderContext.d.ts +34 -0
- package/lib/typescript/src/NavigationContainerRefContext.d.ts +8 -0
- package/lib/typescript/src/NavigationContext.d.ts +24 -0
- package/lib/typescript/src/NavigationHelpersContext.d.ts +9 -0
- package/lib/typescript/src/NavigationRouteContext.d.ts +7 -0
- package/lib/typescript/src/NavigationStateContext.d.ts +45 -0
- package/lib/typescript/src/SceneView.d.ts +21 -0
- package/lib/typescript/src/Screen.d.ts +6 -0
- package/lib/typescript/src/StaticContainer.d.ts +7 -0
- package/lib/typescript/src/UnhandledActionContext.d.ts +4 -0
- package/lib/typescript/src/checkDuplicateRouteNames.d.ts +2 -0
- package/lib/typescript/src/checkSerializable.d.ts +9 -0
- package/lib/typescript/src/createNavigationContainerRef.d.ts +3 -0
- package/lib/typescript/src/createNavigatorFactory.d.ts +11 -0
- package/lib/typescript/src/findFocusedRoute.d.ts +22 -0
- package/lib/typescript/src/fromEntries.d.ts +1 -0
- package/lib/typescript/src/getActionFromState.d.ts +16 -0
- package/lib/typescript/src/getFocusedRouteNameFromRoute.d.ts +2 -0
- package/lib/typescript/src/getPathFromState.d.ts +38 -0
- package/lib/typescript/src/getStateFromPath.d.ts +32 -0
- package/lib/typescript/src/index.d.ts +23 -0
- package/lib/typescript/src/isArrayEqual.d.ts +5 -0
- package/lib/typescript/src/types.d.ts +485 -0
- package/lib/typescript/src/useChildListeners.d.ts +11 -0
- package/lib/typescript/src/useComponent.d.ts +2 -0
- package/lib/typescript/src/useCurrentRender.d.ts +13 -0
- package/lib/typescript/src/useDescriptors.d.ts +89 -0
- package/lib/typescript/src/useEventEmitter.d.ts +8 -0
- package/lib/typescript/src/useFocusEffect.d.ts +10 -0
- package/lib/typescript/src/useFocusEvents.d.ts +12 -0
- package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts +12 -0
- package/lib/typescript/src/useIsFocused.d.ts +5 -0
- package/lib/typescript/src/useKeyedChildListeners.d.ts +11 -0
- package/lib/typescript/src/useNavigation.d.ts +7 -0
- package/lib/typescript/src/useNavigationBuilder.d.ts +223 -0
- package/lib/typescript/src/useNavigationCache.d.ts +19 -0
- package/lib/typescript/src/useNavigationContainerRef.d.ts +2 -0
- package/lib/typescript/src/useNavigationHelpers.d.ts +174 -0
- package/lib/typescript/src/useNavigationState.d.ts +9 -0
- package/lib/typescript/src/useOnAction.d.ts +25 -0
- package/lib/typescript/src/useOnGetState.d.ts +8 -0
- package/lib/typescript/src/useOnPreventRemove.d.ts +16 -0
- package/lib/typescript/src/useOnRouteFocus.d.ts +14 -0
- package/lib/typescript/src/useOptionsGetters.d.ts +12 -0
- package/lib/typescript/src/useRegisterNavigator.d.ts +5 -0
- package/lib/typescript/src/useRoute.d.ts +8 -0
- package/lib/typescript/src/useRouteCache.d.ts +13 -0
- package/lib/typescript/src/useScheduleUpdate.d.ts +13 -0
- package/lib/typescript/src/useSyncState.d.ts +4 -0
- package/lib/typescript/src/validatePathConfig.d.ts +1 -0
- package/package.json +73 -0
- package/src/BaseNavigationContainer.tsx +453 -0
- package/src/CurrentRenderContext.tsx +10 -0
- package/src/EnsureSingleNavigator.tsx +53 -0
- package/src/Group.tsx +14 -0
- package/src/NavigationBuilderContext.tsx +70 -0
- package/src/NavigationContainerRefContext.tsx +14 -0
- package/src/NavigationContext.tsx +12 -0
- package/src/NavigationHelpersContext.tsx +13 -0
- package/src/NavigationRouteContext.tsx +10 -0
- package/src/NavigationStateContext.tsx +39 -0
- package/src/SceneView.tsx +134 -0
- package/src/Screen.tsx +17 -0
- package/src/StaticContainer.tsx +29 -0
- package/src/UnhandledActionContext.tsx +9 -0
- package/src/checkDuplicateRouteNames.tsx +33 -0
- package/src/checkSerializable.tsx +74 -0
- package/src/createNavigationContainerRef.tsx +97 -0
- package/src/createNavigatorFactory.tsx +40 -0
- package/src/findFocusedRoute.tsx +13 -0
- package/src/fromEntries.tsx +13 -0
- package/src/getActionFromState.tsx +154 -0
- package/src/getFocusedRouteNameFromRoute.tsx +28 -0
- package/src/getPathFromState.tsx +297 -0
- package/src/getStateFromPath.tsx +575 -0
- package/src/index.tsx +23 -0
- package/src/isArrayEqual.tsx +7 -0
- package/src/types.tsx +645 -0
- package/src/useChildListeners.tsx +37 -0
- package/src/useComponent.tsx +30 -0
- package/src/useCurrentRender.tsx +35 -0
- package/src/useDescriptors.tsx +229 -0
- package/src/useEventEmitter.tsx +130 -0
- package/src/useFocusEffect.tsx +112 -0
- package/src/useFocusEvents.tsx +73 -0
- package/src/useFocusedListenersChildrenAdapter.tsx +47 -0
- package/src/useIsFocused.tsx +43 -0
- package/src/useKeyedChildListeners.tsx +40 -0
- package/src/useNavigation.tsx +26 -0
- package/src/useNavigationBuilder.tsx +640 -0
- package/src/useNavigationCache.tsx +159 -0
- package/src/useNavigationContainerRef.tsx +17 -0
- package/src/useNavigationHelpers.tsx +98 -0
- package/src/useNavigationState.tsx +41 -0
- package/src/useOnAction.tsx +166 -0
- package/src/useOnGetState.tsx +47 -0
- package/src/useOnPreventRemove.tsx +99 -0
- package/src/useOnRouteFocus.tsx +47 -0
- package/src/useOptionsGetters.tsx +98 -0
- package/src/useRegisterNavigator.tsx +29 -0
- package/src/useRoute.tsx +22 -0
- package/src/useRouteCache.tsx +55 -0
- package/src/useScheduleUpdate.tsx +32 -0
- package/src/useSyncState.tsx +74 -0
- package/src/validatePathConfig.tsx +32 -0
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import type { DefaultRouterOptions, InitialState, NavigationAction, NavigationState, ParamListBase, PartialState, Route } from '@react-navigation/routers';
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
declare global {
|
|
4
|
+
namespace ReactNavigation {
|
|
5
|
+
interface RootParamList {
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
declare type Keyof<T extends {}> = Extract<keyof T, string>;
|
|
10
|
+
export declare type DefaultNavigatorOptions<ParamList extends ParamListBase, State extends NavigationState, ScreenOptions extends {}, EventMap extends EventMapBase> = DefaultRouterOptions<Keyof<ParamList>> & {
|
|
11
|
+
/**
|
|
12
|
+
* Children React Elements to extract the route configuration from.
|
|
13
|
+
* Only `Screen`, `Group` and `React.Fragment` are supported as children.
|
|
14
|
+
*/
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Event listeners for all the screens in the navigator.
|
|
18
|
+
*/
|
|
19
|
+
screenListeners?: ScreenListeners<State, EventMap> | ((props: {
|
|
20
|
+
route: RouteProp<ParamList>;
|
|
21
|
+
navigation: any;
|
|
22
|
+
}) => ScreenListeners<State, EventMap>);
|
|
23
|
+
/**
|
|
24
|
+
* Default options for all screens under this navigator.
|
|
25
|
+
*/
|
|
26
|
+
screenOptions?: ScreenOptions | ((props: {
|
|
27
|
+
route: RouteProp<ParamList>;
|
|
28
|
+
navigation: any;
|
|
29
|
+
}) => ScreenOptions);
|
|
30
|
+
/**
|
|
31
|
+
* Default options specified by the navigator.
|
|
32
|
+
* It receives the custom options in the arguments if a function is specified.
|
|
33
|
+
*/
|
|
34
|
+
defaultScreenOptions?: ScreenOptions | ((props: {
|
|
35
|
+
route: RouteProp<ParamList>;
|
|
36
|
+
navigation: any;
|
|
37
|
+
options: ScreenOptions;
|
|
38
|
+
}) => ScreenOptions);
|
|
39
|
+
};
|
|
40
|
+
export declare type EventMapBase = Record<string, {
|
|
41
|
+
data?: any;
|
|
42
|
+
canPreventDefault?: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
export declare type EventMapCore<State extends NavigationState> = {
|
|
45
|
+
focus: {
|
|
46
|
+
data: undefined;
|
|
47
|
+
};
|
|
48
|
+
blur: {
|
|
49
|
+
data: undefined;
|
|
50
|
+
};
|
|
51
|
+
state: {
|
|
52
|
+
data: {
|
|
53
|
+
state: State;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
beforeRemove: {
|
|
57
|
+
data: {
|
|
58
|
+
action: NavigationAction;
|
|
59
|
+
};
|
|
60
|
+
canPreventDefault: true;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export declare type EventArg<EventName extends string, CanPreventDefault extends boolean | undefined = false, Data = undefined> = {
|
|
64
|
+
/**
|
|
65
|
+
* Type of the event (e.g. `focus`, `blur`)
|
|
66
|
+
*/
|
|
67
|
+
readonly type: EventName;
|
|
68
|
+
readonly target?: string;
|
|
69
|
+
} & (CanPreventDefault extends true ? {
|
|
70
|
+
/**
|
|
71
|
+
* Whether `event.preventDefault()` was called on this event object.
|
|
72
|
+
*/
|
|
73
|
+
readonly defaultPrevented: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Prevent the default action which happens on this event.
|
|
76
|
+
*/
|
|
77
|
+
preventDefault(): void;
|
|
78
|
+
} : {}) & (undefined extends Data ? {
|
|
79
|
+
readonly data?: Readonly<Data>;
|
|
80
|
+
} : {
|
|
81
|
+
readonly data: Readonly<Data>;
|
|
82
|
+
});
|
|
83
|
+
export declare type EventListenerCallback<EventMap extends EventMapBase, EventName extends keyof EventMap> = (e: EventArg<Extract<EventName, string>, EventMap[EventName]['canPreventDefault'], EventMap[EventName]['data']>) => void;
|
|
84
|
+
export declare type EventConsumer<EventMap extends EventMapBase> = {
|
|
85
|
+
/**
|
|
86
|
+
* Subscribe to events from the parent navigator.
|
|
87
|
+
*
|
|
88
|
+
* @param type Type of the event (e.g. `focus`, `blur`)
|
|
89
|
+
* @param callback Callback listener which is executed upon receiving the event.
|
|
90
|
+
*/
|
|
91
|
+
addListener<EventName extends Keyof<EventMap>>(type: EventName, callback: EventListenerCallback<EventMap, EventName>): () => void;
|
|
92
|
+
removeListener<EventName extends Keyof<EventMap>>(type: EventName, callback: EventListenerCallback<EventMap, EventName>): void;
|
|
93
|
+
};
|
|
94
|
+
export declare type EventEmitter<EventMap extends EventMapBase> = {
|
|
95
|
+
/**
|
|
96
|
+
* Emit an event to child screens.
|
|
97
|
+
*
|
|
98
|
+
* @param options.type Type of the event (e.g. `focus`, `blur`)
|
|
99
|
+
* @param [options.data] Optional information regarding the event.
|
|
100
|
+
* @param [options.target] Key of the target route which should receive the event.
|
|
101
|
+
* If not specified, all routes receive the event.
|
|
102
|
+
*/
|
|
103
|
+
emit<EventName extends Keyof<EventMap>>(options: {
|
|
104
|
+
type: EventName;
|
|
105
|
+
target?: string;
|
|
106
|
+
} & (EventMap[EventName]['canPreventDefault'] extends true ? {
|
|
107
|
+
canPreventDefault: true;
|
|
108
|
+
} : {}) & (undefined extends EventMap[EventName]['data'] ? {
|
|
109
|
+
data?: EventMap[EventName]['data'];
|
|
110
|
+
} : {
|
|
111
|
+
data: EventMap[EventName]['data'];
|
|
112
|
+
})): EventArg<EventName, EventMap[EventName]['canPreventDefault'], EventMap[EventName]['data']>;
|
|
113
|
+
};
|
|
114
|
+
export declare class PrivateValueStore<A, B, C> {
|
|
115
|
+
/**
|
|
116
|
+
* UGLY HACK! DO NOT USE THE TYPE!!!
|
|
117
|
+
*
|
|
118
|
+
* TypeScript requires a type to be used to be able to infer it.
|
|
119
|
+
* The type should exist as its own without any operations such as union.
|
|
120
|
+
* So we need to figure out a way to store this type in a property.
|
|
121
|
+
* The problem with a normal property is that it shows up in intelliSense.
|
|
122
|
+
* Adding private keyword works, but the annotation is stripped away in declaration.
|
|
123
|
+
* Turns out if we use an empty string, it doesn't show up in intelliSense.
|
|
124
|
+
*/
|
|
125
|
+
protected ''?: {
|
|
126
|
+
a: A;
|
|
127
|
+
b: B;
|
|
128
|
+
c: C;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
declare type NavigationHelpersCommon<ParamList extends ParamListBase, State extends NavigationState = NavigationState> = {
|
|
132
|
+
/**
|
|
133
|
+
* Dispatch an action or an update function to the router.
|
|
134
|
+
* The update function will receive the current state,
|
|
135
|
+
*
|
|
136
|
+
* @param action Action object or update function.
|
|
137
|
+
*/
|
|
138
|
+
dispatch(action: NavigationAction | ((state: State) => NavigationAction)): void;
|
|
139
|
+
/**
|
|
140
|
+
* Navigate to a route in current navigation tree.
|
|
141
|
+
*
|
|
142
|
+
* @param name Name of the route to navigate to.
|
|
143
|
+
* @param [params] Params object for the route.
|
|
144
|
+
*/
|
|
145
|
+
navigate<RouteName extends keyof ParamList>(...args: undefined extends ParamList[RouteName] ? [screen: RouteName] | [screen: RouteName, params: ParamList[RouteName]] : [screen: RouteName, params: ParamList[RouteName]]): void;
|
|
146
|
+
/**
|
|
147
|
+
* Navigate to a route in current navigation tree.
|
|
148
|
+
*
|
|
149
|
+
* @param route Object with `key` or `name` for the route to navigate to, and a `params` object.
|
|
150
|
+
*/
|
|
151
|
+
navigate<RouteName extends keyof ParamList>(options: {
|
|
152
|
+
key: string;
|
|
153
|
+
params?: ParamList[RouteName];
|
|
154
|
+
merge?: boolean;
|
|
155
|
+
} | {
|
|
156
|
+
name: RouteName;
|
|
157
|
+
key?: string;
|
|
158
|
+
params: ParamList[RouteName];
|
|
159
|
+
merge?: boolean;
|
|
160
|
+
}): void;
|
|
161
|
+
/**
|
|
162
|
+
* Reset the navigation state to the provided state.
|
|
163
|
+
*
|
|
164
|
+
* @param state Navigation state object.
|
|
165
|
+
*/
|
|
166
|
+
reset(state: PartialState<State> | State): void;
|
|
167
|
+
/**
|
|
168
|
+
* Go back to the previous route in history.
|
|
169
|
+
*/
|
|
170
|
+
goBack(): void;
|
|
171
|
+
/**
|
|
172
|
+
* Check if the screen is focused. The method returns `true` if focused, `false` otherwise.
|
|
173
|
+
* Note that this method doesn't re-render screen when the focus changes. So don't use it in `render`.
|
|
174
|
+
* To get notified of focus changes, use `addListener('focus', cb)` and `addListener('blur', cb)`.
|
|
175
|
+
* To conditionally render content based on focus state, use the `useIsFocused` hook.
|
|
176
|
+
*/
|
|
177
|
+
isFocused(): boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Check if dispatching back action will be handled by navigation.
|
|
180
|
+
* Note that this method doesn't re-render screen when the result changes. So don't use it in `render`.
|
|
181
|
+
*/
|
|
182
|
+
canGoBack(): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Returns the navigation prop from the parent navigator,
|
|
185
|
+
*/
|
|
186
|
+
getParent<T = NavigationProp<ParamListBase> | undefined>(): T;
|
|
187
|
+
/**
|
|
188
|
+
* Returns the navigator's state.
|
|
189
|
+
* Note that this method doesn't re-render screen when the result changes. So don't use it in `render`.
|
|
190
|
+
*/
|
|
191
|
+
getState(): State;
|
|
192
|
+
} & PrivateValueStore<ParamList, keyof ParamList, {}>;
|
|
193
|
+
export declare type NavigationHelpers<ParamList extends ParamListBase, EventMap extends EventMapBase = {}> = NavigationHelpersCommon<ParamList> & EventEmitter<EventMap> & {
|
|
194
|
+
/**
|
|
195
|
+
* Update the param object for the route.
|
|
196
|
+
* The new params will be shallow merged with the old one.
|
|
197
|
+
*
|
|
198
|
+
* @param params Params object for the current route.
|
|
199
|
+
*/
|
|
200
|
+
setParams<RouteName extends keyof ParamList>(params: Partial<ParamList[RouteName]>): void;
|
|
201
|
+
};
|
|
202
|
+
export declare type NavigationContainerProps = {
|
|
203
|
+
/**
|
|
204
|
+
* Initial navigation state for the child navigators.
|
|
205
|
+
*/
|
|
206
|
+
initialState?: InitialState;
|
|
207
|
+
/**
|
|
208
|
+
* Callback which is called with the latest navigation state when it changes.
|
|
209
|
+
*/
|
|
210
|
+
onStateChange?: (state: NavigationState | undefined) => void;
|
|
211
|
+
/**
|
|
212
|
+
* Callback which is called when an action is not handled.
|
|
213
|
+
*/
|
|
214
|
+
onUnhandledAction?: (action: NavigationAction) => void;
|
|
215
|
+
/**
|
|
216
|
+
* Whether this navigation container should be independent of parent containers.
|
|
217
|
+
* If this is not set to `true`, this container cannot be nested inside another container.
|
|
218
|
+
* Setting it to `true` disconnects any children navigators from parent container.
|
|
219
|
+
*/
|
|
220
|
+
independent?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Children elements to render.
|
|
223
|
+
*/
|
|
224
|
+
children: React.ReactNode;
|
|
225
|
+
};
|
|
226
|
+
export declare type NavigationProp<ParamList extends {}, RouteName extends keyof ParamList = Keyof<ParamList>, State extends NavigationState = NavigationState<ParamList>, ScreenOptions extends {} = {}, EventMap extends EventMapBase = {}> = NavigationHelpersCommon<ParamList, State> & {
|
|
227
|
+
/**
|
|
228
|
+
* Update the param object for the route.
|
|
229
|
+
* The new params will be shallow merged with the old one.
|
|
230
|
+
*
|
|
231
|
+
* @param params Params object for the current route.
|
|
232
|
+
*/
|
|
233
|
+
setParams(params: Partial<ParamList[RouteName]>): void;
|
|
234
|
+
/**
|
|
235
|
+
* Update the options for the route.
|
|
236
|
+
* The options object will be shallow merged with default options object.
|
|
237
|
+
*
|
|
238
|
+
* @param options Options object for the route.
|
|
239
|
+
*/
|
|
240
|
+
setOptions(options: Partial<ScreenOptions>): void;
|
|
241
|
+
} & EventConsumer<EventMap & EventMapCore<State>> & PrivateValueStore<ParamList, RouteName, EventMap>;
|
|
242
|
+
export declare type RouteProp<ParamList extends ParamListBase, RouteName extends keyof ParamList = Keyof<ParamList>> = Route<Extract<RouteName, string>, ParamList[RouteName]>;
|
|
243
|
+
export declare type CompositeNavigationProp<A extends NavigationProp<ParamListBase, string, any, any>, B extends NavigationHelpersCommon<ParamListBase, any>> = Omit<A & B, keyof NavigationProp<any>> & NavigationProp<
|
|
244
|
+
/**
|
|
245
|
+
* Param list from both navigation objects needs to be combined
|
|
246
|
+
* For example, we should be able to navigate to screens in both A and B
|
|
247
|
+
*/
|
|
248
|
+
(A extends NavigationHelpersCommon<infer T> ? T : never) & (B extends NavigationHelpersCommon<infer U> ? U : never),
|
|
249
|
+
/**
|
|
250
|
+
* The route name should refer to the route name specified in the first type
|
|
251
|
+
* Ideally it should work for any of them, but it's not possible to infer that way
|
|
252
|
+
*/
|
|
253
|
+
A extends NavigationProp<any, infer R> ? R : string,
|
|
254
|
+
/**
|
|
255
|
+
* The type of state should refer to the state specified in the first type
|
|
256
|
+
*/
|
|
257
|
+
A extends NavigationProp<any, any, infer S> ? S : NavigationState,
|
|
258
|
+
/**
|
|
259
|
+
* Screen options from both navigation objects needs to be combined
|
|
260
|
+
* This allows typechecking `setOptions`
|
|
261
|
+
*/
|
|
262
|
+
(A extends NavigationProp<any, any, any, infer O> ? O : {}) & (B extends NavigationProp<any, any, any, infer P> ? P : {}),
|
|
263
|
+
/**
|
|
264
|
+
* Event consumer config should refer to the config specified in the first type
|
|
265
|
+
* This allows typechecking `addListener`/`removeListener`
|
|
266
|
+
*/
|
|
267
|
+
A extends NavigationProp<any, any, any, any, infer E> ? E : {}>;
|
|
268
|
+
export declare type CompositeScreenProps<A extends {
|
|
269
|
+
navigation: NavigationProp<ParamListBase, string, any, any>;
|
|
270
|
+
route: RouteProp<ParamListBase>;
|
|
271
|
+
}, B extends {
|
|
272
|
+
navigation: NavigationHelpersCommon<ParamListBase, any>;
|
|
273
|
+
}> = {
|
|
274
|
+
navigation: CompositeNavigationProp<A['navigation'], B['navigation']>;
|
|
275
|
+
route: A['route'];
|
|
276
|
+
};
|
|
277
|
+
export declare type Descriptor<ScreenOptions extends {}, Navigation extends NavigationProp<any, any, any, any, any>, Route extends RouteProp<any, any>> = {
|
|
278
|
+
/**
|
|
279
|
+
* Render the component associated with this route.
|
|
280
|
+
*/
|
|
281
|
+
render(): JSX.Element;
|
|
282
|
+
/**
|
|
283
|
+
* Options for the route.
|
|
284
|
+
*/
|
|
285
|
+
options: ScreenOptions;
|
|
286
|
+
/**
|
|
287
|
+
* Route object for the screen
|
|
288
|
+
*/
|
|
289
|
+
route: Route;
|
|
290
|
+
/**
|
|
291
|
+
* Navigation object for the screen
|
|
292
|
+
*/
|
|
293
|
+
navigation: Navigation;
|
|
294
|
+
};
|
|
295
|
+
export declare type ScreenListeners<State extends NavigationState, EventMap extends EventMapBase> = Partial<{
|
|
296
|
+
[EventName in keyof (EventMap & EventMapCore<State>)]: EventListenerCallback<EventMap, EventName>;
|
|
297
|
+
}>;
|
|
298
|
+
export declare type RouteConfigComponent<ParamList extends ParamListBase, RouteName extends keyof ParamList> = {
|
|
299
|
+
/**
|
|
300
|
+
* React component to render for this screen.
|
|
301
|
+
*/
|
|
302
|
+
component: React.ComponentType<any>;
|
|
303
|
+
getComponent?: never;
|
|
304
|
+
children?: never;
|
|
305
|
+
} | {
|
|
306
|
+
/**
|
|
307
|
+
* Lazily get a React component to render for this screen.
|
|
308
|
+
*/
|
|
309
|
+
getComponent: () => React.ComponentType<any>;
|
|
310
|
+
component?: never;
|
|
311
|
+
children?: never;
|
|
312
|
+
} | {
|
|
313
|
+
/**
|
|
314
|
+
* Render callback to render content of this screen.
|
|
315
|
+
*/
|
|
316
|
+
children: (props: {
|
|
317
|
+
route: RouteProp<ParamList, RouteName>;
|
|
318
|
+
navigation: any;
|
|
319
|
+
}) => React.ReactNode;
|
|
320
|
+
component?: never;
|
|
321
|
+
getComponent?: never;
|
|
322
|
+
};
|
|
323
|
+
export declare type RouteConfig<ParamList extends ParamListBase, RouteName extends keyof ParamList, State extends NavigationState, ScreenOptions extends {}, EventMap extends EventMapBase> = {
|
|
324
|
+
/**
|
|
325
|
+
* Route name of this screen.
|
|
326
|
+
*/
|
|
327
|
+
name: RouteName;
|
|
328
|
+
/**
|
|
329
|
+
* Navigator options for this screen.
|
|
330
|
+
*/
|
|
331
|
+
options?: ScreenOptions | ((props: {
|
|
332
|
+
route: RouteProp<ParamList, RouteName>;
|
|
333
|
+
navigation: any;
|
|
334
|
+
}) => ScreenOptions);
|
|
335
|
+
/**
|
|
336
|
+
* Event listeners for this screen.
|
|
337
|
+
*/
|
|
338
|
+
listeners?: ScreenListeners<State, EventMap> | ((props: {
|
|
339
|
+
route: RouteProp<ParamList, RouteName>;
|
|
340
|
+
navigation: any;
|
|
341
|
+
}) => ScreenListeners<State, EventMap>);
|
|
342
|
+
/**
|
|
343
|
+
* Function to return an unique ID for this screen.
|
|
344
|
+
* Receives an object with the route params.
|
|
345
|
+
* For a given screen name, there will always be only one screen corresponding to an ID.
|
|
346
|
+
* If `undefined` is returned, it acts same as no `getId` being specified.
|
|
347
|
+
*/
|
|
348
|
+
getId?: ({ params }: {
|
|
349
|
+
params: ParamList[RouteName];
|
|
350
|
+
}) => string | undefined;
|
|
351
|
+
/**
|
|
352
|
+
* Initial params object for the route.
|
|
353
|
+
*/
|
|
354
|
+
initialParams?: Partial<ParamList[RouteName]>;
|
|
355
|
+
} & RouteConfigComponent<ParamList, RouteName>;
|
|
356
|
+
export declare type RouteGroupConfig<ParamList extends ParamListBase, ScreenOptions extends {}> = {
|
|
357
|
+
/**
|
|
358
|
+
* Navigator options for this screen.
|
|
359
|
+
*/
|
|
360
|
+
screenOptions?: ScreenOptions | ((props: {
|
|
361
|
+
route: RouteProp<ParamList, keyof ParamList>;
|
|
362
|
+
navigation: any;
|
|
363
|
+
}) => ScreenOptions);
|
|
364
|
+
/**
|
|
365
|
+
* Children React Elements to extract the route configuration from.
|
|
366
|
+
* Only `Screen`, `Group` and `React.Fragment` are supported as children.
|
|
367
|
+
*/
|
|
368
|
+
children: React.ReactNode;
|
|
369
|
+
};
|
|
370
|
+
export declare type NavigationContainerEventMap = {
|
|
371
|
+
/**
|
|
372
|
+
* Event which fires when the navigation state changes.
|
|
373
|
+
*/
|
|
374
|
+
state: {
|
|
375
|
+
data: {
|
|
376
|
+
/**
|
|
377
|
+
* The updated state object after the state change.
|
|
378
|
+
*/
|
|
379
|
+
state: NavigationState | PartialState<NavigationState> | undefined;
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
/**
|
|
383
|
+
* Event which fires when current options changes.
|
|
384
|
+
*/
|
|
385
|
+
options: {
|
|
386
|
+
data: {
|
|
387
|
+
options: object;
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* Event which fires when an action is dispatched.
|
|
392
|
+
* Only intended for debugging purposes, don't use it for app logic.
|
|
393
|
+
* This event will be emitted before state changes have been applied.
|
|
394
|
+
*/
|
|
395
|
+
__unsafe_action__: {
|
|
396
|
+
data: {
|
|
397
|
+
/**
|
|
398
|
+
* The action object which was dispatched.
|
|
399
|
+
*/
|
|
400
|
+
action: NavigationAction;
|
|
401
|
+
/**
|
|
402
|
+
* Whether the action was a no-op, i.e. resulted any state changes.
|
|
403
|
+
*/
|
|
404
|
+
noop: boolean;
|
|
405
|
+
/**
|
|
406
|
+
* Stack trace of the action, this will only be available during development.
|
|
407
|
+
*/
|
|
408
|
+
stack: string | undefined;
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
export declare type NavigationContainerRef<ParamList extends {}> = NavigationHelpers<ParamList> & EventConsumer<NavigationContainerEventMap> & {
|
|
413
|
+
/**
|
|
414
|
+
* Reset the navigation state of the root navigator to the provided state.
|
|
415
|
+
*
|
|
416
|
+
* @param state Navigation state object.
|
|
417
|
+
*/
|
|
418
|
+
resetRoot(state?: PartialState<NavigationState> | NavigationState): void;
|
|
419
|
+
/**
|
|
420
|
+
* Get the rehydrated navigation state of the navigation tree.
|
|
421
|
+
*/
|
|
422
|
+
getRootState(): NavigationState;
|
|
423
|
+
/**
|
|
424
|
+
* Get the currently focused navigation route.
|
|
425
|
+
*/
|
|
426
|
+
getCurrentRoute(): Route<string> | undefined;
|
|
427
|
+
/**
|
|
428
|
+
* Get the currently focused route's options.
|
|
429
|
+
*/
|
|
430
|
+
getCurrentOptions(): object | undefined;
|
|
431
|
+
/**
|
|
432
|
+
* Whether the navigation container is ready to handle actions.
|
|
433
|
+
*/
|
|
434
|
+
isReady(): boolean;
|
|
435
|
+
};
|
|
436
|
+
export declare type NavigationContainerRefWithCurrent<ParamList extends {}> = NavigationContainerRef<ParamList> & {
|
|
437
|
+
current: NavigationContainerRef<ParamList> | null;
|
|
438
|
+
};
|
|
439
|
+
export declare type TypedNavigator<ParamList extends ParamListBase, State extends NavigationState, ScreenOptions extends {}, EventMap extends EventMapBase, Navigator extends React.ComponentType<any>> = {
|
|
440
|
+
/**
|
|
441
|
+
* Navigator component which manages the child screens.
|
|
442
|
+
*/
|
|
443
|
+
Navigator: React.ComponentType<Omit<React.ComponentProps<Navigator>, keyof DefaultNavigatorOptions<any, any, any, any>> & DefaultNavigatorOptions<ParamList, State, ScreenOptions, EventMap>>;
|
|
444
|
+
/**
|
|
445
|
+
* Component used for grouping multiple route configuration.
|
|
446
|
+
*/
|
|
447
|
+
Group: React.ComponentType<RouteGroupConfig<ParamList, ScreenOptions>>;
|
|
448
|
+
/**
|
|
449
|
+
* Component used for specifying route configuration.
|
|
450
|
+
*/
|
|
451
|
+
Screen: <RouteName extends keyof ParamList>(_: RouteConfig<ParamList, RouteName, State, ScreenOptions, EventMap>) => null;
|
|
452
|
+
};
|
|
453
|
+
export declare type NavigatorScreenParams<ParamList, State extends NavigationState = NavigationState> = {
|
|
454
|
+
screen?: never;
|
|
455
|
+
params?: never;
|
|
456
|
+
initial?: never;
|
|
457
|
+
path?: string;
|
|
458
|
+
state: PartialState<State> | State | undefined;
|
|
459
|
+
} | {
|
|
460
|
+
[RouteName in keyof ParamList]: undefined extends ParamList[RouteName] ? {
|
|
461
|
+
screen: RouteName;
|
|
462
|
+
params?: ParamList[RouteName];
|
|
463
|
+
initial?: boolean;
|
|
464
|
+
path?: string;
|
|
465
|
+
state?: never;
|
|
466
|
+
} : {
|
|
467
|
+
screen: RouteName;
|
|
468
|
+
params: ParamList[RouteName];
|
|
469
|
+
initial?: boolean;
|
|
470
|
+
path?: string;
|
|
471
|
+
state?: never;
|
|
472
|
+
};
|
|
473
|
+
}[keyof ParamList];
|
|
474
|
+
export declare type PathConfig<ParamList extends {}> = {
|
|
475
|
+
path?: string;
|
|
476
|
+
exact?: boolean;
|
|
477
|
+
parse?: Record<string, (value: string) => any>;
|
|
478
|
+
stringify?: Record<string, (value: any) => string>;
|
|
479
|
+
screens?: PathConfigMap<ParamList>;
|
|
480
|
+
initialRouteName?: keyof ParamList;
|
|
481
|
+
};
|
|
482
|
+
export declare type PathConfigMap<ParamList extends {}> = {
|
|
483
|
+
[RouteName in keyof ParamList]?: NonNullable<ParamList[RouteName]> extends NavigatorScreenParams<infer T, any> ? string | PathConfig<T> : string | Omit<PathConfig<{}>, 'screens' | 'initialRouteName'>;
|
|
484
|
+
};
|
|
485
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ListenerMap } from './NavigationBuilderContext';
|
|
2
|
+
/**
|
|
3
|
+
* Hook which lets child navigators add action listeners.
|
|
4
|
+
*/
|
|
5
|
+
export default function useChildListeners(): {
|
|
6
|
+
listeners: {
|
|
7
|
+
action: import("./NavigationBuilderContext").ChildActionListener[];
|
|
8
|
+
focus: import("./NavigationBuilderContext").FocusedNavigationListener[];
|
|
9
|
+
};
|
|
10
|
+
addListener: <T extends keyof ListenerMap>(type: T, listener: ListenerMap[T]) => () => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NavigationState, ParamListBase } from '@react-navigation/routers';
|
|
2
|
+
import type { Descriptor, NavigationHelpers, NavigationProp, RouteProp } from './types';
|
|
3
|
+
declare type Options = {
|
|
4
|
+
state: NavigationState;
|
|
5
|
+
navigation: NavigationHelpers<ParamListBase>;
|
|
6
|
+
descriptors: Record<string, Descriptor<object, NavigationProp<ParamListBase>, RouteProp<ParamListBase>>>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Write the current options, so that server renderer can get current values
|
|
10
|
+
* Mutating values like this is not safe in async mode, but it doesn't apply to SSR
|
|
11
|
+
*/
|
|
12
|
+
export default function useCurrentRender({ state, navigation, descriptors, }: Options): void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { NavigationAction, NavigationState, ParamListBase, Router } from '@react-navigation/routers';
|
|
2
|
+
import { AddKeyedListener, AddListener } from './NavigationBuilderContext';
|
|
3
|
+
import type { Descriptor, EventMapBase, NavigationHelpers, NavigationProp, RouteConfig, RouteProp } from './types';
|
|
4
|
+
import type { NavigationEventEmitter } from './useEventEmitter';
|
|
5
|
+
export declare type ScreenConfigWithParent<State extends NavigationState, ScreenOptions extends {}, EventMap extends EventMapBase> = [
|
|
6
|
+
(ScreenOptionsOrCallback<ScreenOptions> | undefined)[] | undefined,
|
|
7
|
+
RouteConfig<ParamListBase, string, State, ScreenOptions, EventMap>
|
|
8
|
+
];
|
|
9
|
+
declare type ScreenOptionsOrCallback<ScreenOptions extends {}> = ScreenOptions | ((props: {
|
|
10
|
+
route: RouteProp<ParamListBase, string>;
|
|
11
|
+
navigation: any;
|
|
12
|
+
}) => ScreenOptions);
|
|
13
|
+
declare type Options<State extends NavigationState, ScreenOptions extends {}, EventMap extends EventMapBase> = {
|
|
14
|
+
state: State;
|
|
15
|
+
screens: Record<string, ScreenConfigWithParent<State, ScreenOptions, EventMap>>;
|
|
16
|
+
navigation: NavigationHelpers<ParamListBase>;
|
|
17
|
+
screenOptions?: ScreenOptionsOrCallback<ScreenOptions>;
|
|
18
|
+
defaultScreenOptions?: ScreenOptions | ((props: {
|
|
19
|
+
route: RouteProp<ParamListBase>;
|
|
20
|
+
navigation: any;
|
|
21
|
+
options: ScreenOptions;
|
|
22
|
+
}) => ScreenOptions);
|
|
23
|
+
onAction: (action: NavigationAction) => boolean;
|
|
24
|
+
getState: () => State;
|
|
25
|
+
setState: (state: State) => void;
|
|
26
|
+
addListener: AddListener;
|
|
27
|
+
addKeyedListener: AddKeyedListener;
|
|
28
|
+
onRouteFocus: (key: string) => void;
|
|
29
|
+
router: Router<State, NavigationAction>;
|
|
30
|
+
emitter: NavigationEventEmitter<EventMap>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Hook to create descriptor objects for the child routes.
|
|
34
|
+
*
|
|
35
|
+
* A descriptor object provides 3 things:
|
|
36
|
+
* - Helper method to render a screen
|
|
37
|
+
* - Options specified by the screen for the navigator
|
|
38
|
+
* - Navigation object intended for the route
|
|
39
|
+
*/
|
|
40
|
+
export default function useDescriptors<State extends NavigationState, ActionHelpers extends Record<string, () => void>, ScreenOptions extends {}, EventMap extends EventMapBase>({ state, screens, navigation, screenOptions, defaultScreenOptions, onAction, getState, setState, addListener, addKeyedListener, onRouteFocus, router, emitter, }: Options<State, ScreenOptions, EventMap>): Record<string, Descriptor<ScreenOptions, {
|
|
41
|
+
dispatch(action: Readonly<{
|
|
42
|
+
type: string;
|
|
43
|
+
payload?: object | undefined;
|
|
44
|
+
source?: string | undefined;
|
|
45
|
+
target?: string | undefined;
|
|
46
|
+
}> | ((state: State) => Readonly<{
|
|
47
|
+
type: string;
|
|
48
|
+
payload?: object | undefined;
|
|
49
|
+
source?: string | undefined;
|
|
50
|
+
target?: string | undefined;
|
|
51
|
+
}>)): void;
|
|
52
|
+
navigate<RouteName extends string>(...args: [screen: RouteName] | [screen: RouteName, params: object | undefined]): void;
|
|
53
|
+
navigate<RouteName_1 extends string>(options: {
|
|
54
|
+
key: string;
|
|
55
|
+
params?: object | undefined;
|
|
56
|
+
merge?: boolean | undefined;
|
|
57
|
+
} | {
|
|
58
|
+
name: RouteName_1;
|
|
59
|
+
key?: string | undefined;
|
|
60
|
+
params: object | undefined;
|
|
61
|
+
merge?: boolean | undefined;
|
|
62
|
+
}): void;
|
|
63
|
+
reset(state: State | import("@react-navigation/routers").PartialState<State>): void;
|
|
64
|
+
goBack(): void;
|
|
65
|
+
isFocused(): boolean;
|
|
66
|
+
canGoBack(): boolean;
|
|
67
|
+
getParent<T = NavigationProp<ParamListBase, string, Readonly<{
|
|
68
|
+
key: string;
|
|
69
|
+
index: number;
|
|
70
|
+
routeNames: string[];
|
|
71
|
+
history?: unknown[] | undefined;
|
|
72
|
+
routes: (Readonly<{
|
|
73
|
+
key: string;
|
|
74
|
+
name: string;
|
|
75
|
+
path?: string | undefined;
|
|
76
|
+
}> & Readonly<{
|
|
77
|
+
params?: Readonly<object | undefined>;
|
|
78
|
+
}> & {
|
|
79
|
+
state?: Readonly<any> | import("@react-navigation/routers").PartialState<Readonly<any>> | undefined;
|
|
80
|
+
})[];
|
|
81
|
+
type: string;
|
|
82
|
+
stale: false;
|
|
83
|
+
}>, {}, {}> | undefined>(): T;
|
|
84
|
+
getState(): State;
|
|
85
|
+
} & import("./types").PrivateValueStore<ParamListBase, string, {}> & {
|
|
86
|
+
setParams(params: Partial<object | undefined>): void;
|
|
87
|
+
setOptions(options: Partial<ScreenOptions>): void;
|
|
88
|
+
} & import("./types").EventConsumer<EventMap & import("./types").EventMapCore<State>> & import("./types").PrivateValueStore<ParamListBase, string, EventMap> & ActionHelpers, RouteProp<ParamListBase, string>>>;
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EventConsumer, EventEmitter } from './types';
|
|
2
|
+
export declare type NavigationEventEmitter<T extends Record<string, any>> = EventEmitter<T> & {
|
|
3
|
+
create: (target: string) => EventConsumer<T>;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Hook to manage the event system used by the navigator to notify screens of various events.
|
|
7
|
+
*/
|
|
8
|
+
export default function useEventEmitter<T extends Record<string, any>>(listen?: (e: any) => void): NavigationEventEmitter<T>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare type EffectCallback = () => undefined | void | (() => void);
|
|
2
|
+
/**
|
|
3
|
+
* Hook to run an effect in a focused screen, similar to `React.useEffect`.
|
|
4
|
+
* This can be used to perform side-effects such as fetching data or subscribing to events.
|
|
5
|
+
* The passed callback should be wrapped in `React.useCallback` to avoid running the effect too often.
|
|
6
|
+
*
|
|
7
|
+
* @param callback Memoized callback containing the effect, should optionally return a cleanup function.
|
|
8
|
+
*/
|
|
9
|
+
export default function useFocusEffect(effect: EffectCallback): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NavigationState } from '@react-navigation/routers';
|
|
2
|
+
import type { EventMapCore } from './types';
|
|
3
|
+
import type { NavigationEventEmitter } from './useEventEmitter';
|
|
4
|
+
declare type Options<State extends NavigationState> = {
|
|
5
|
+
state: State;
|
|
6
|
+
emitter: NavigationEventEmitter<EventMapCore<State>>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Hook to take care of emitting `focus` and `blur` events.
|
|
10
|
+
*/
|
|
11
|
+
export default function useFocusEvents<State extends NavigationState>({ state, emitter, }: Options<State>): void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ParamListBase } from '@react-navigation/routers';
|
|
2
|
+
import { FocusedNavigationListener } from './NavigationBuilderContext';
|
|
3
|
+
import type { NavigationHelpers } from './types';
|
|
4
|
+
declare type Options = {
|
|
5
|
+
navigation: NavigationHelpers<ParamListBase>;
|
|
6
|
+
focusedListeners: FocusedNavigationListener[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Hook for passing focus callback to children
|
|
10
|
+
*/
|
|
11
|
+
export default function useFocusedListenersChildrenAdapter({ navigation, focusedListeners, }: Options): void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { KeyedListenerMap } from './NavigationBuilderContext';
|
|
2
|
+
/**
|
|
3
|
+
* Hook which lets child navigators add getters to be called for obtaining rehydrated state.
|
|
4
|
+
*/
|
|
5
|
+
export default function useKeyedChildListeners(): {
|
|
6
|
+
keyedListeners: {
|
|
7
|
+
getState: Record<string, import("./NavigationBuilderContext").GetStateListener | undefined>;
|
|
8
|
+
beforeRemove: Record<string, import("./NavigationBuilderContext").ChildBeforeRemoveListener | undefined>;
|
|
9
|
+
};
|
|
10
|
+
addKeyedListener: <T extends keyof KeyedListenerMap>(type: T, key: string, listener: KeyedListenerMap[T]) => () => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NavigationProp } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to access the navigation prop of the parent screen anywhere.
|
|
4
|
+
*
|
|
5
|
+
* @returns Navigation prop of the parent screen.
|
|
6
|
+
*/
|
|
7
|
+
export default function useNavigation<T = NavigationProp<ReactNavigation.RootParamList>>(): T;
|