@react-navigation/core 8.0.0-alpha.4 → 8.0.0-alpha.40
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 +17 -14
- package/lib/module/BaseNavigationContainer.js +168 -87
- package/lib/module/BaseNavigationContainer.js.map +1 -1
- package/lib/module/ConsumedParamsContext.js +5 -0
- package/lib/module/ConsumedParamsContext.js.map +1 -0
- package/lib/module/DataLoading.js +129 -0
- package/lib/module/DataLoading.js.map +1 -0
- package/lib/module/NavigationBuilderContext.js +7 -10
- package/lib/module/NavigationBuilderContext.js.map +1 -1
- package/lib/module/NavigationIndependentTree.js +54 -9
- package/lib/module/NavigationIndependentTree.js.map +1 -1
- package/lib/module/NavigationProvider.js +36 -11
- package/lib/module/NavigationProvider.js.map +1 -1
- package/lib/module/NavigationRootContext.js +8 -0
- package/lib/module/NavigationRootContext.js.map +1 -0
- package/lib/module/NavigationStateContext.js +3 -0
- package/lib/module/NavigationStateContext.js.map +1 -1
- package/lib/module/PreventRemoveContext.js.map +1 -1
- package/lib/module/PreventRemoveProvider.js +40 -31
- package/lib/module/PreventRemoveProvider.js.map +1 -1
- package/lib/module/SceneView.js +12 -42
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/StaticNavigation.js +219 -67
- package/lib/module/StaticNavigation.js.map +1 -1
- package/lib/module/StaticTreeContext.js +5 -0
- package/lib/module/StaticTreeContext.js.map +1 -0
- package/lib/module/createNavigationContainerRef.js +7 -9
- package/lib/module/createNavigationContainerRef.js.map +1 -1
- package/lib/module/createNavigatorFactory.js +27 -5
- package/lib/module/createNavigatorFactory.js.map +1 -1
- package/lib/module/findFocusedRoute.js +7 -4
- package/lib/module/findFocusedRoute.js.map +1 -1
- package/lib/module/getActionFromState.js +45 -20
- package/lib/module/getActionFromState.js.map +1 -1
- package/lib/module/getPathFromState.js +204 -94
- package/lib/module/getPathFromState.js.map +1 -1
- package/lib/module/getPatternParts.js +61 -14
- package/lib/module/getPatternParts.js.map +1 -1
- package/lib/module/getStateFromPath.js +608 -272
- package/lib/module/getStateFromPath.js.map +1 -1
- package/lib/module/getStateFromRouteParams.js +23 -0
- package/lib/module/getStateFromRouteParams.js.map +1 -0
- package/lib/module/index.js +7 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +2 -0
- package/lib/module/internal.js.map +1 -0
- package/lib/module/isRecordEqual.js +1 -1
- package/lib/module/isRecordEqual.js.map +1 -1
- package/lib/module/queryString.js +71 -0
- package/lib/module/queryString.js.map +1 -0
- package/lib/module/theming/useTheme.js +1 -1
- package/lib/module/theming/useTheme.js.map +1 -1
- package/lib/module/types.js +35 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/useDescriptors.js +65 -25
- package/lib/module/useDescriptors.js.map +1 -1
- package/lib/module/useEventEmitter.js +48 -33
- package/lib/module/useEventEmitter.js.map +1 -1
- package/lib/module/useFocusEffect.js +4 -2
- package/lib/module/useFocusEffect.js.map +1 -1
- package/lib/module/useFocusEvents.js +15 -5
- package/lib/module/useFocusEvents.js.map +1 -1
- package/lib/module/useFocusedListenersChildrenAdapter.js +3 -3
- package/lib/module/useFocusedListenersChildrenAdapter.js.map +1 -1
- package/lib/module/useIsFocused.js +8 -12
- package/lib/module/useIsFocused.js.map +1 -1
- package/lib/module/useKeyedChildListeners.js +5 -2
- package/lib/module/useKeyedChildListeners.js.map +1 -1
- package/lib/module/useLazyValue.js.map +1 -1
- package/lib/module/useNavigation.js +4 -17
- package/lib/module/useNavigation.js.map +1 -1
- package/lib/module/useNavigationBuilder.js +244 -147
- package/lib/module/useNavigationBuilder.js.map +1 -1
- package/lib/module/useNavigationCache.js +92 -89
- package/lib/module/useNavigationCache.js.map +1 -1
- package/lib/module/useNavigationHelpers.js +22 -29
- package/lib/module/useNavigationHelpers.js.map +1 -1
- package/lib/module/useNavigationIndependentTree.js +1 -1
- package/lib/module/useNavigationIndependentTree.js.map +1 -1
- package/lib/module/useNavigationState.js +158 -46
- package/lib/module/useNavigationState.js.map +1 -1
- package/lib/module/useOnAction.js +58 -11
- package/lib/module/useOnAction.js.map +1 -1
- package/lib/module/useOnGetNavigation.js +26 -0
- package/lib/module/useOnGetNavigation.js.map +1 -0
- package/lib/module/useOnGetState.js +7 -4
- package/lib/module/useOnGetState.js.map +1 -1
- package/lib/module/useOnPreventRemove.js +40 -31
- package/lib/module/useOnPreventRemove.js.map +1 -1
- package/lib/module/useOnRouteFocus.js +2 -2
- package/lib/module/useOnRouteFocus.js.map +1 -1
- package/lib/module/useOptionsGetters.js +34 -24
- package/lib/module/useOptionsGetters.js.map +1 -1
- package/lib/module/usePreventRemove.js +11 -5
- package/lib/module/usePreventRemove.js.map +1 -1
- package/lib/module/usePreventRemoveContext.js +2 -2
- package/lib/module/usePreventRemoveContext.js.map +1 -1
- package/lib/module/useRegisterNavigator.js +3 -4
- package/lib/module/useRegisterNavigator.js.map +1 -1
- package/lib/module/useRoute.js +2 -0
- package/lib/module/useRoute.js.map +1 -1
- package/lib/module/useRouteCache.js +51 -35
- package/lib/module/useRouteCache.js.map +1 -1
- package/lib/module/useScheduleUpdate.js +12 -10
- package/lib/module/useScheduleUpdate.js.map +1 -1
- package/lib/module/useStateForPath.js +1 -1
- package/lib/module/useStateForPath.js.map +1 -1
- package/lib/module/useSyncState.js +37 -15
- package/lib/module/useSyncState.js.map +1 -1
- package/lib/module/validatePathConfig.js +50 -36
- package/lib/module/validatePathConfig.js.map +1 -1
- package/lib/typescript/src/BaseNavigationContainer.d.ts +6 -3
- package/lib/typescript/src/BaseNavigationContainer.d.ts.map +1 -1
- package/lib/typescript/src/ConsumedParamsContext.d.ts +3 -0
- package/lib/typescript/src/ConsumedParamsContext.d.ts.map +1 -0
- package/lib/typescript/src/DataLoading.d.ts +21 -0
- package/lib/typescript/src/DataLoading.d.ts.map +1 -0
- package/lib/typescript/src/EnsureSingleNavigator.d.ts +1 -1
- package/lib/typescript/src/EnsureSingleNavigator.d.ts.map +1 -1
- package/lib/typescript/src/Group.d.ts +1 -1
- package/lib/typescript/src/Group.d.ts.map +1 -1
- package/lib/typescript/src/NavigationBuilderContext.d.ts +22 -14
- package/lib/typescript/src/NavigationBuilderContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationContainerRefContext.d.ts +1 -1
- package/lib/typescript/src/NavigationContainerRefContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationFocusedRouteStateContext.d.ts +4 -4
- package/lib/typescript/src/NavigationFocusedRouteStateContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationHelpersContext.d.ts +1 -1
- package/lib/typescript/src/NavigationHelpersContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationIndependentTree.d.ts +1 -1
- package/lib/typescript/src/NavigationIndependentTree.d.ts.map +1 -1
- package/lib/typescript/src/NavigationProvider.d.ts +21 -18
- package/lib/typescript/src/NavigationProvider.d.ts.map +1 -1
- package/lib/typescript/src/NavigationRootContext.d.ts +8 -0
- package/lib/typescript/src/NavigationRootContext.d.ts.map +1 -0
- package/lib/typescript/src/NavigationStateContext.d.ts +4 -3
- package/lib/typescript/src/NavigationStateContext.d.ts.map +1 -1
- package/lib/typescript/src/PreventRemoveContext.d.ts +1 -0
- package/lib/typescript/src/PreventRemoveContext.d.ts.map +1 -1
- package/lib/typescript/src/PreventRemoveProvider.d.ts +1 -1
- package/lib/typescript/src/PreventRemoveProvider.d.ts.map +1 -1
- package/lib/typescript/src/SceneView.d.ts +5 -2
- package/lib/typescript/src/SceneView.d.ts.map +1 -1
- package/lib/typescript/src/Screen.d.ts +1 -1
- package/lib/typescript/src/Screen.d.ts.map +1 -1
- package/lib/typescript/src/StaticContainer.d.ts +1 -1
- package/lib/typescript/src/StaticContainer.d.ts.map +1 -1
- package/lib/typescript/src/StaticNavigation.d.ts +189 -111
- package/lib/typescript/src/StaticNavigation.d.ts.map +1 -1
- package/lib/typescript/src/StaticTreeContext.d.ts +4 -0
- package/lib/typescript/src/StaticTreeContext.d.ts.map +1 -0
- package/lib/typescript/src/createNavigationContainerRef.d.ts +1 -1
- package/lib/typescript/src/createNavigationContainerRef.d.ts.map +1 -1
- package/lib/typescript/src/createNavigatorFactory.d.ts +23 -5
- package/lib/typescript/src/createNavigatorFactory.d.ts.map +1 -1
- package/lib/typescript/src/findFocusedRoute.d.ts +3 -8
- package/lib/typescript/src/findFocusedRoute.d.ts.map +1 -1
- package/lib/typescript/src/getActionFromState.d.ts +4 -4
- package/lib/typescript/src/getActionFromState.d.ts.map +1 -1
- package/lib/typescript/src/getPathFromState.d.ts +3 -3
- package/lib/typescript/src/getPathFromState.d.ts.map +1 -1
- package/lib/typescript/src/getPatternParts.d.ts +5 -2
- package/lib/typescript/src/getPatternParts.d.ts.map +1 -1
- package/lib/typescript/src/getStateFromPath.d.ts +4 -7
- package/lib/typescript/src/getStateFromPath.d.ts.map +1 -1
- package/lib/typescript/src/getStateFromRouteParams.d.ts +3 -0
- package/lib/typescript/src/getStateFromRouteParams.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +36 -33
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/internal.d.ts +3 -0
- package/lib/typescript/src/internal.d.ts.map +1 -0
- package/lib/typescript/src/isRecordEqual.d.ts.map +1 -1
- package/lib/typescript/src/queryString.d.ts +5 -0
- package/lib/typescript/src/queryString.d.ts.map +1 -0
- package/lib/typescript/src/theming/ThemeContext.d.ts +1 -1
- package/lib/typescript/src/theming/ThemeContext.d.ts.map +1 -1
- package/lib/typescript/src/theming/ThemeProvider.d.ts +2 -2
- package/lib/typescript/src/theming/ThemeProvider.d.ts.map +1 -1
- package/lib/typescript/src/theming/useTheme.d.ts +1 -1
- package/lib/typescript/src/theming/useTheme.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +265 -167
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useChildListeners.d.ts +3 -3
- package/lib/typescript/src/useChildListeners.d.ts.map +1 -1
- package/lib/typescript/src/useDescriptors.d.ts +13 -11
- package/lib/typescript/src/useDescriptors.d.ts.map +1 -1
- package/lib/typescript/src/useEventEmitter.d.ts +2 -2
- package/lib/typescript/src/useEventEmitter.d.ts.map +1 -1
- package/lib/typescript/src/useFocusEffect.d.ts.map +1 -1
- package/lib/typescript/src/useFocusEvents.d.ts +2 -2
- package/lib/typescript/src/useFocusEvents.d.ts.map +1 -1
- package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts +2 -2
- package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts.map +1 -1
- package/lib/typescript/src/useIsFocused.d.ts +4 -0
- package/lib/typescript/src/useIsFocused.d.ts.map +1 -1
- package/lib/typescript/src/useKeyedChildListeners.d.ts +4 -3
- package/lib/typescript/src/useKeyedChildListeners.d.ts.map +1 -1
- package/lib/typescript/src/useLazyValue.d.ts.map +1 -1
- package/lib/typescript/src/useNavigation.d.ts +4 -2
- package/lib/typescript/src/useNavigation.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationBuilder.d.ts +22 -63
- package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationCache.d.ts +6 -5
- package/lib/typescript/src/useNavigationCache.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationContainerRef.d.ts +1 -1
- package/lib/typescript/src/useNavigationContainerRef.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationHelpers.d.ts +18 -58
- package/lib/typescript/src/useNavigationHelpers.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationState.d.ts +19 -3
- package/lib/typescript/src/useNavigationState.d.ts.map +1 -1
- package/lib/typescript/src/useOnAction.d.ts +9 -9
- package/lib/typescript/src/useOnAction.d.ts.map +1 -1
- package/lib/typescript/src/useOnGetNavigation.d.ts +12 -0
- package/lib/typescript/src/useOnGetNavigation.d.ts.map +1 -0
- package/lib/typescript/src/useOnGetState.d.ts +1 -1
- package/lib/typescript/src/useOnGetState.d.ts.map +1 -1
- package/lib/typescript/src/useOnPreventRemove.d.ts +5 -9
- package/lib/typescript/src/useOnPreventRemove.d.ts.map +1 -1
- package/lib/typescript/src/useOnRouteFocus.d.ts +6 -6
- package/lib/typescript/src/useOnRouteFocus.d.ts.map +1 -1
- package/lib/typescript/src/useOptionsGetters.d.ts +2 -4
- package/lib/typescript/src/useOptionsGetters.d.ts.map +1 -1
- package/lib/typescript/src/usePreventRemove.d.ts.map +1 -1
- package/lib/typescript/src/usePreventRemoveContext.d.ts +2 -1
- package/lib/typescript/src/usePreventRemoveContext.d.ts.map +1 -1
- package/lib/typescript/src/useRegisterNavigator.d.ts.map +1 -1
- package/lib/typescript/src/useRoute.d.ts +7 -3
- package/lib/typescript/src/useRoute.d.ts.map +1 -1
- package/lib/typescript/src/useRouteCache.d.ts +7 -12
- package/lib/typescript/src/useRouteCache.d.ts.map +1 -1
- package/lib/typescript/src/useScheduleUpdate.d.ts +5 -4
- package/lib/typescript/src/useScheduleUpdate.d.ts.map +1 -1
- package/lib/typescript/src/useStateForPath.d.ts +1 -1
- package/lib/typescript/src/useStateForPath.d.ts.map +1 -1
- package/lib/typescript/src/useSyncState.d.ts +1 -0
- package/lib/typescript/src/useSyncState.d.ts.map +1 -1
- package/lib/typescript/src/utilities.d.ts +79 -39
- package/lib/typescript/src/utilities.d.ts.map +1 -1
- package/lib/typescript/src/validatePathConfig.d.ts.map +1 -1
- package/package.json +26 -22
- package/src/BaseNavigationContainer.tsx +468 -333
- package/src/ConsumedParamsContext.tsx +5 -0
- package/src/DataLoading.tsx +206 -0
- package/src/NavigationBuilderContext.tsx +44 -25
- package/src/NavigationFocusedRouteStateContext.tsx +4 -4
- package/src/NavigationIndependentTree.tsx +60 -12
- package/src/NavigationProvider.tsx +47 -20
- package/src/NavigationRootContext.tsx +11 -0
- package/src/NavigationStateContext.tsx +9 -6
- package/src/PreventRemoveContext.tsx +1 -0
- package/src/PreventRemoveProvider.tsx +55 -56
- package/src/SceneView.tsx +14 -40
- package/src/StaticNavigation.tsx +715 -328
- package/src/StaticTreeContext.tsx +7 -0
- package/src/createNavigationContainerRef.tsx +12 -11
- package/src/createNavigatorFactory.tsx +92 -8
- package/src/findFocusedRoute.tsx +16 -16
- package/src/getActionFromState.tsx +87 -51
- package/src/getPathFromState.tsx +310 -134
- package/src/getPatternParts.tsx +98 -16
- package/src/getStateFromPath.tsx +971 -344
- package/src/getStateFromRouteParams.tsx +59 -0
- package/src/index.tsx +57 -6
- package/src/internal.tsx +2 -0
- package/src/isRecordEqual.tsx +3 -1
- package/src/queryString.ts +109 -0
- package/src/theming/useTheme.tsx +1 -1
- package/src/types.tsx +799 -377
- package/src/useDescriptors.tsx +151 -43
- package/src/useEventEmitter.tsx +53 -39
- package/src/useFocusEffect.tsx +5 -2
- package/src/useFocusEvents.tsx +19 -8
- package/src/useFocusedListenersChildrenAdapter.tsx +3 -3
- package/src/useIsFocused.tsx +18 -21
- package/src/useKeyedChildListeners.tsx +5 -2
- package/src/useLazyValue.tsx +2 -2
- package/src/useNavigation.tsx +9 -26
- package/src/useNavigationBuilder.tsx +370 -201
- package/src/useNavigationCache.tsx +148 -123
- package/src/useNavigationHelpers.tsx +27 -37
- package/src/useNavigationIndependentTree.tsx +1 -1
- package/src/useNavigationState.tsx +207 -69
- package/src/useOnAction.tsx +92 -18
- package/src/useOnGetNavigation.tsx +30 -0
- package/src/useOnGetState.tsx +8 -4
- package/src/useOnPreventRemove.tsx +78 -43
- package/src/useOnRouteFocus.tsx +11 -15
- package/src/useOptionsGetters.tsx +41 -28
- package/src/usePreventRemove.tsx +13 -5
- package/src/usePreventRemoveContext.tsx +2 -2
- package/src/useRegisterNavigator.tsx +4 -4
- package/src/useRoute.tsx +20 -6
- package/src/useRouteCache.tsx +57 -35
- package/src/useScheduleUpdate.tsx +13 -11
- package/src/useStateForPath.tsx +1 -1
- package/src/useSyncState.tsx +39 -15
- package/src/utilities.tsx +151 -35
- package/src/validatePathConfig.tsx +86 -57
- package/lib/module/CurrentRenderContext.js +0 -10
- package/lib/module/CurrentRenderContext.js.map +0 -1
- package/lib/module/NavigationMetaContext.js +0 -15
- package/lib/module/NavigationMetaContext.js.map +0 -1
- package/lib/module/checkSerializable.js +0 -46
- package/lib/module/checkSerializable.js.map +0 -1
- package/lib/module/useComponent.js +0 -34
- package/lib/module/useComponent.js.map +0 -1
- package/lib/module/useCurrentRender.js +0 -19
- package/lib/module/useCurrentRender.js.map +0 -1
- package/lib/typescript/src/CurrentRenderContext.d.ts +0 -9
- package/lib/typescript/src/CurrentRenderContext.d.ts.map +0 -1
- package/lib/typescript/src/NavigationMetaContext.d.ts +0 -12
- package/lib/typescript/src/NavigationMetaContext.d.ts.map +0 -1
- package/lib/typescript/src/checkSerializable.d.ts +0 -10
- package/lib/typescript/src/checkSerializable.d.ts.map +0 -1
- package/lib/typescript/src/useComponent.d.ts +0 -7
- package/lib/typescript/src/useComponent.d.ts.map +0 -1
- package/lib/typescript/src/useCurrentRender.d.ts +0 -14
- package/lib/typescript/src/useCurrentRender.d.ts.map +0 -1
- package/src/CurrentRenderContext.tsx +0 -9
- package/src/NavigationMetaContext.tsx +0 -14
- package/src/checkSerializable.tsx +0 -74
- package/src/useComponent.tsx +0 -37
- package/src/useCurrentRender.tsx +0 -31
package/src/types.tsx
CHANGED
|
@@ -10,10 +10,12 @@ import type {
|
|
|
10
10
|
} from '@react-navigation/routers';
|
|
11
11
|
import type * as React from 'react';
|
|
12
12
|
|
|
13
|
+
import type { Theme as InternalTheme } from './internal';
|
|
13
14
|
import type {
|
|
14
15
|
FlatType,
|
|
15
16
|
KeyOf,
|
|
16
17
|
NotUndefined,
|
|
18
|
+
StandardSchemaV1,
|
|
17
19
|
UnionToIntersection,
|
|
18
20
|
} from './utilities';
|
|
19
21
|
|
|
@@ -50,17 +52,11 @@ export interface RootNavigator {}
|
|
|
50
52
|
* }
|
|
51
53
|
* ```
|
|
52
54
|
*/
|
|
53
|
-
|
|
54
|
-
export interface Theme {}
|
|
55
|
+
export interface Theme extends InternalTheme {}
|
|
55
56
|
|
|
56
57
|
export type RootParamList =
|
|
57
|
-
RootNavigator extends
|
|
58
|
-
infer ParamList,
|
|
59
|
-
any,
|
|
60
|
-
any,
|
|
61
|
-
any,
|
|
62
|
-
any,
|
|
63
|
-
any
|
|
58
|
+
RootNavigator extends PrivateValueStore<
|
|
59
|
+
[infer ParamList extends {}, any, any, any]
|
|
64
60
|
>
|
|
65
61
|
? ParamList
|
|
66
62
|
: {};
|
|
@@ -82,58 +78,68 @@ export type DefaultNavigatorOptions<
|
|
|
82
78
|
* Layout for the navigator.
|
|
83
79
|
* Useful for wrapping with a component with access to navigator's state and options.
|
|
84
80
|
*/
|
|
85
|
-
layout?:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
81
|
+
layout?:
|
|
82
|
+
| ((props: {
|
|
83
|
+
state: State;
|
|
84
|
+
navigation: NavigationHelpers<ParamList, State>;
|
|
85
|
+
descriptors: Record<
|
|
86
|
+
string,
|
|
87
|
+
Descriptor<
|
|
88
|
+
ScreenOptions,
|
|
89
|
+
NavigationProp<
|
|
90
|
+
ParamList,
|
|
91
|
+
keyof ParamList,
|
|
92
|
+
State,
|
|
93
|
+
ScreenOptions,
|
|
94
|
+
EventMap
|
|
95
|
+
>,
|
|
96
|
+
ScreenRouteProp<ParamList>
|
|
97
|
+
>
|
|
98
|
+
>;
|
|
99
|
+
children: React.ReactNode;
|
|
100
|
+
}) => React.ReactElement)
|
|
101
|
+
| undefined;
|
|
104
102
|
|
|
105
103
|
/**
|
|
106
104
|
* Event listeners for all the screens in the navigator.
|
|
107
105
|
*/
|
|
108
106
|
screenListeners?:
|
|
109
|
-
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
| (
|
|
108
|
+
| ScreenListeners<State, EventMap>
|
|
109
|
+
| ((props: {
|
|
110
|
+
route: ScreenRouteProp<ParamList>;
|
|
111
|
+
navigation: Navigation;
|
|
112
|
+
}) => ScreenListeners<State, EventMap>)
|
|
113
|
+
)
|
|
114
|
+
| undefined;
|
|
114
115
|
|
|
115
116
|
/**
|
|
116
117
|
* Default options for all screens under this navigator.
|
|
117
118
|
*/
|
|
118
119
|
screenOptions?:
|
|
119
|
-
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
| (
|
|
121
|
+
| ScreenOptions
|
|
122
|
+
| ((props: {
|
|
123
|
+
route: ScreenRouteProp<ParamList>;
|
|
124
|
+
navigation: Navigation;
|
|
125
|
+
theme: Theme;
|
|
126
|
+
}) => ScreenOptions)
|
|
127
|
+
)
|
|
128
|
+
| undefined;
|
|
125
129
|
|
|
126
130
|
/**
|
|
127
131
|
* Layout for all screens under this navigator.
|
|
128
132
|
*/
|
|
129
|
-
screenLayout?:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
screenLayout?:
|
|
134
|
+
| ((
|
|
135
|
+
props: ScreenLayoutArgs<
|
|
136
|
+
ParamList,
|
|
137
|
+
keyof ParamList,
|
|
138
|
+
ScreenOptions,
|
|
139
|
+
Navigation
|
|
140
|
+
>
|
|
141
|
+
) => React.ReactElement)
|
|
142
|
+
| undefined;
|
|
137
143
|
|
|
138
144
|
/**
|
|
139
145
|
* A function returning overrides for the underlying router used by the navigator.
|
|
@@ -142,9 +148,11 @@ export type DefaultNavigatorOptions<
|
|
|
142
148
|
*
|
|
143
149
|
* This must be a pure function and cannot reference outside dynamic variables.
|
|
144
150
|
*/
|
|
145
|
-
router?:
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
router?:
|
|
152
|
+
| (<Action extends NavigationAction>(
|
|
153
|
+
original: Router<State, Action>
|
|
154
|
+
) => Partial<Router<State, Action>>)
|
|
155
|
+
| undefined;
|
|
148
156
|
|
|
149
157
|
/**
|
|
150
158
|
* What should happen when the available route names change.
|
|
@@ -165,15 +173,15 @@ export type DefaultNavigatorOptions<
|
|
|
165
173
|
* - Direct navigation is only handled for `NAVIGATE` actions.
|
|
166
174
|
* - Unhandled state is restored only if the current state becomes invalid, i.e. it doesn't contain any currently defined screens.
|
|
167
175
|
*/
|
|
168
|
-
routeNamesChangeBehavior?: 'firstMatch' | 'lastUnhandled';
|
|
176
|
+
routeNamesChangeBehavior?: ('firstMatch' | 'lastUnhandled') | undefined;
|
|
169
177
|
};
|
|
170
178
|
|
|
171
179
|
export type EventMapBase = Record<
|
|
172
180
|
string,
|
|
173
|
-
{ data?: any; canPreventDefault?: boolean }
|
|
181
|
+
{ data?: any; canPreventDefault?: boolean | undefined }
|
|
174
182
|
>;
|
|
175
183
|
|
|
176
|
-
export type EventMapCore<State extends NavigationState> = {
|
|
184
|
+
export type EventMapCore<in out State extends NavigationState> = {
|
|
177
185
|
focus: { data: undefined };
|
|
178
186
|
blur: { data: undefined };
|
|
179
187
|
state: { data: { state: State } };
|
|
@@ -192,7 +200,7 @@ export type EventArg<
|
|
|
192
200
|
/**
|
|
193
201
|
* Key of the route which received the event.
|
|
194
202
|
*/
|
|
195
|
-
readonly target?: string;
|
|
203
|
+
readonly target?: string | undefined;
|
|
196
204
|
} & (CanPreventDefault extends true
|
|
197
205
|
? {
|
|
198
206
|
/**
|
|
@@ -206,15 +214,14 @@ export type EventArg<
|
|
|
206
214
|
}
|
|
207
215
|
: {}) &
|
|
208
216
|
(undefined extends Data
|
|
209
|
-
? { readonly data?: Readonly<Data> }
|
|
217
|
+
? { readonly data?: Readonly<Data> | undefined }
|
|
210
218
|
: { readonly data: Readonly<Data> });
|
|
211
219
|
|
|
212
220
|
export type EventListenerCallback<
|
|
213
|
-
EventMap extends EventMapBase,
|
|
214
|
-
EventName extends keyof EventMap,
|
|
215
|
-
EventCanPreventDefault extends
|
|
216
|
-
|
|
217
|
-
| undefined = EventMap[EventName]['canPreventDefault'],
|
|
221
|
+
in out EventMap extends EventMapBase,
|
|
222
|
+
in out EventName extends keyof EventMap,
|
|
223
|
+
in out EventCanPreventDefault extends boolean | undefined =
|
|
224
|
+
EventMap[EventName]['canPreventDefault'],
|
|
218
225
|
> = (
|
|
219
226
|
e: EventArg<
|
|
220
227
|
EventName,
|
|
@@ -223,7 +230,7 @@ export type EventListenerCallback<
|
|
|
223
230
|
>
|
|
224
231
|
) => void;
|
|
225
232
|
|
|
226
|
-
export type EventConsumer<EventMap extends EventMapBase> = {
|
|
233
|
+
export type EventConsumer<in out EventMap extends EventMapBase> = {
|
|
227
234
|
/**
|
|
228
235
|
* Subscribe to events from the parent navigator.
|
|
229
236
|
*
|
|
@@ -240,7 +247,7 @@ export type EventConsumer<EventMap extends EventMapBase> = {
|
|
|
240
247
|
): void;
|
|
241
248
|
};
|
|
242
249
|
|
|
243
|
-
export type EventEmitter<EventMap extends EventMapBase> = {
|
|
250
|
+
export type EventEmitter<in out EventMap extends EventMapBase> = {
|
|
244
251
|
/**
|
|
245
252
|
* Emit an event to child screens.
|
|
246
253
|
*
|
|
@@ -252,7 +259,7 @@ export type EventEmitter<EventMap extends EventMapBase> = {
|
|
|
252
259
|
emit<EventName extends KeyOf<EventMap>>(
|
|
253
260
|
options: {
|
|
254
261
|
type: EventName;
|
|
255
|
-
target?: string;
|
|
262
|
+
target?: string | undefined;
|
|
256
263
|
} & (EventMap[EventName]['canPreventDefault'] extends true
|
|
257
264
|
? { canPreventDefault: true }
|
|
258
265
|
: {}) &
|
|
@@ -266,7 +273,7 @@ export type EventEmitter<EventMap extends EventMapBase> = {
|
|
|
266
273
|
>;
|
|
267
274
|
};
|
|
268
275
|
|
|
269
|
-
export class PrivateValueStore<T extends [any, any, any]> {
|
|
276
|
+
export class PrivateValueStore<T extends [any, any, any, any]> {
|
|
270
277
|
/**
|
|
271
278
|
* UGLY HACK! DO NOT USE THE TYPE!!!
|
|
272
279
|
*
|
|
@@ -280,6 +287,50 @@ export class PrivateValueStore<T extends [any, any, any]> {
|
|
|
280
287
|
protected ''?: T;
|
|
281
288
|
}
|
|
282
289
|
|
|
290
|
+
type NavigatorLike =
|
|
291
|
+
| {
|
|
292
|
+
Navigator: React.ComponentType<any>;
|
|
293
|
+
Screen: unknown;
|
|
294
|
+
Group: unknown;
|
|
295
|
+
}
|
|
296
|
+
| {
|
|
297
|
+
config: unknown;
|
|
298
|
+
getComponent: () => React.ComponentType<any>;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
export type ParamListForNavigator<T extends {}> = T extends NavigatorLike
|
|
302
|
+
? T extends PrivateValueStore<[infer ParamList extends {}, any, any, any]>
|
|
303
|
+
? ParamList
|
|
304
|
+
: T
|
|
305
|
+
: T;
|
|
306
|
+
|
|
307
|
+
// Remove `undefined` before checking for nested navigator params.
|
|
308
|
+
// If nothing remains, avoid matching `never` against `NavigatorScreenParams`
|
|
309
|
+
type NestedNavigatorForScreenParams<T, Params = NotUndefined<T>> = [
|
|
310
|
+
Params,
|
|
311
|
+
] extends [never]
|
|
312
|
+
? never
|
|
313
|
+
: Params extends NavigatorScreenParams<infer Navigator>
|
|
314
|
+
? Navigator extends PrivateValueStore<[any, any, any, any]>
|
|
315
|
+
? Navigator extends NavigatorLike
|
|
316
|
+
? Navigator
|
|
317
|
+
: never
|
|
318
|
+
: never
|
|
319
|
+
: never;
|
|
320
|
+
|
|
321
|
+
export type NestedNavigatorsForParamList<ParamList extends {}> = {
|
|
322
|
+
[RouteName in keyof ParamList as NestedNavigatorForScreenParams<
|
|
323
|
+
ParamList[RouteName]
|
|
324
|
+
> extends never
|
|
325
|
+
? never
|
|
326
|
+
: RouteName]: NestedNavigatorForScreenParams<ParamList[RouteName]>;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
type NavigateOptions = {
|
|
330
|
+
merge?: boolean | undefined;
|
|
331
|
+
pop?: boolean | undefined;
|
|
332
|
+
};
|
|
333
|
+
|
|
283
334
|
type NavigationHelpersCommon<
|
|
284
335
|
ParamList extends ParamListBase,
|
|
285
336
|
State extends NavigationState = NavigationState,
|
|
@@ -314,37 +365,16 @@ type NavigationHelpersCommon<
|
|
|
314
365
|
? [
|
|
315
366
|
screen: RouteName,
|
|
316
367
|
params?: ParamList[RouteName],
|
|
317
|
-
options?:
|
|
368
|
+
options?: NavigateOptions,
|
|
318
369
|
]
|
|
319
370
|
: [
|
|
320
371
|
screen: RouteName,
|
|
321
372
|
params: ParamList[RouteName],
|
|
322
|
-
options?:
|
|
373
|
+
options?: NavigateOptions,
|
|
323
374
|
]
|
|
324
375
|
: never
|
|
325
376
|
): void;
|
|
326
377
|
|
|
327
|
-
/**
|
|
328
|
-
* Navigate to a route in current navigation tree.
|
|
329
|
-
*
|
|
330
|
-
* @param options.name Name of the route to navigate to.
|
|
331
|
-
* @param [options.params] Params object for the route.
|
|
332
|
-
* @param [options.path] Path to associate the route with (e.g. for deep links).
|
|
333
|
-
* @param [options.merge] Whether to merge the params onto the route. Defaults to `false`.
|
|
334
|
-
* @param [options.pop] Whether to pop routes in a stack to go back to the matching route. Defaults to `false`.
|
|
335
|
-
*/
|
|
336
|
-
navigate<RouteName extends keyof ParamList>(
|
|
337
|
-
options: RouteName extends unknown
|
|
338
|
-
? {
|
|
339
|
-
name: RouteName;
|
|
340
|
-
params: ParamList[RouteName];
|
|
341
|
-
path?: string;
|
|
342
|
-
merge?: boolean;
|
|
343
|
-
pop?: boolean;
|
|
344
|
-
}
|
|
345
|
-
: never
|
|
346
|
-
): void;
|
|
347
|
-
|
|
348
378
|
/**
|
|
349
379
|
* Preloads the route in current navigation tree.
|
|
350
380
|
*
|
|
@@ -395,11 +425,11 @@ type NavigationHelpersCommon<
|
|
|
395
425
|
* So don't use it in `render`.
|
|
396
426
|
*/
|
|
397
427
|
getState(): State;
|
|
398
|
-
}
|
|
428
|
+
};
|
|
399
429
|
|
|
400
430
|
type ParamType<
|
|
401
431
|
ParamList extends {},
|
|
402
|
-
RouteName
|
|
432
|
+
RouteName,
|
|
403
433
|
IsPartial extends boolean = false,
|
|
404
434
|
> = RouteName extends keyof ParamList
|
|
405
435
|
? ParamList[RouteName] extends undefined
|
|
@@ -410,8 +440,8 @@ type ParamType<
|
|
|
410
440
|
: unknown;
|
|
411
441
|
|
|
412
442
|
type NavigationHelpersRoute<
|
|
413
|
-
ParamList extends {},
|
|
414
|
-
RouteName extends keyof ParamList = KeyOf<ParamList>,
|
|
443
|
+
in out ParamList extends {},
|
|
444
|
+
in out RouteName extends keyof ParamList = KeyOf<ParamList>,
|
|
415
445
|
> = {
|
|
416
446
|
/**
|
|
417
447
|
* Update the param object for the route.
|
|
@@ -440,46 +470,55 @@ type NavigationHelpersRoute<
|
|
|
440
470
|
|
|
441
471
|
export type NavigationHelpers<
|
|
442
472
|
ParamList extends ParamListBase,
|
|
473
|
+
State extends NavigationState = NavigationState<ParamList>,
|
|
443
474
|
EventMap extends EventMapBase = {},
|
|
444
|
-
> = NavigationHelpersCommon<ParamList> &
|
|
475
|
+
> = NavigationHelpersCommon<ParamList, State> &
|
|
445
476
|
EventEmitter<EventMap> &
|
|
446
|
-
NavigationHelpersRoute<ParamList, keyof ParamList
|
|
477
|
+
NavigationHelpersRoute<ParamList, keyof ParamList> &
|
|
478
|
+
PrivateValueStore<[ParamList, unknown, unknown, unknown]>;
|
|
447
479
|
|
|
448
480
|
export type NavigationContainerProps = {
|
|
449
481
|
/**
|
|
450
482
|
* Initial state object for the navigation tree.
|
|
451
483
|
*/
|
|
452
|
-
initialState?: InitialState;
|
|
484
|
+
initialState?: InitialState | undefined;
|
|
453
485
|
/**
|
|
454
486
|
* Callback which is called with the latest navigation state when it changes.
|
|
455
487
|
*/
|
|
456
|
-
onStateChange?:
|
|
488
|
+
onStateChange?:
|
|
489
|
+
| ((state: Readonly<NavigationState> | undefined) => void)
|
|
490
|
+
| undefined;
|
|
457
491
|
/**
|
|
458
492
|
* Callback which is called after the navigation tree mounts.
|
|
459
493
|
*/
|
|
460
|
-
onReady?: () => void;
|
|
494
|
+
onReady?: (() => void) | undefined;
|
|
461
495
|
/**
|
|
462
496
|
* Callback which is called when an action is not handled.
|
|
463
497
|
*/
|
|
464
|
-
onUnhandledAction?:
|
|
498
|
+
onUnhandledAction?:
|
|
499
|
+
| ((action: Readonly<NavigationAction>) => void)
|
|
500
|
+
| undefined;
|
|
465
501
|
/**
|
|
466
502
|
* Theme object for the UI elements.
|
|
467
503
|
*/
|
|
468
|
-
theme?: Theme;
|
|
504
|
+
theme?: Theme | undefined;
|
|
469
505
|
/**
|
|
470
506
|
* Children elements to render.
|
|
471
507
|
*/
|
|
472
508
|
children: React.ReactNode;
|
|
473
509
|
};
|
|
474
510
|
|
|
475
|
-
|
|
511
|
+
// Everything in `NavigationProp` except `getParent` and the private brand.
|
|
512
|
+
// The composite navigation prop intersects this directly, so it doesn't have
|
|
513
|
+
// to walk `NavigationProp`'s members with `Omit` to drop `getParent`/the brand.
|
|
514
|
+
type NavigationPropBase<
|
|
476
515
|
ParamList extends {},
|
|
477
516
|
RouteName extends keyof ParamList = KeyOf<ParamList>,
|
|
478
517
|
State extends NavigationState = NavigationState<ParamList>,
|
|
479
518
|
ScreenOptions extends {} = {},
|
|
480
519
|
EventMap extends EventMapBase = {},
|
|
481
520
|
ActionHelpers extends Record<string, (...args: any) => void> = {},
|
|
482
|
-
> =
|
|
521
|
+
> = NavigationHelpersCommon<ParamList, State> & {
|
|
483
522
|
/**
|
|
484
523
|
* Update the options for the route.
|
|
485
524
|
* The options object will be shallow merged with default options object.
|
|
@@ -487,6 +526,25 @@ export type NavigationProp<
|
|
|
487
526
|
* @param options Partial options object for the current screen.
|
|
488
527
|
*/
|
|
489
528
|
setOptions(options: Partial<ScreenOptions>): void;
|
|
529
|
+
} & NavigationHelpersRoute<ParamList, RouteName> &
|
|
530
|
+
ActionHelpers &
|
|
531
|
+
EventConsumer<EventMap & EventMapCore<State>>;
|
|
532
|
+
|
|
533
|
+
export type NavigationProp<
|
|
534
|
+
ParamList extends {},
|
|
535
|
+
RouteName extends keyof ParamList = KeyOf<ParamList>,
|
|
536
|
+
State extends NavigationState = NavigationState<ParamList>,
|
|
537
|
+
ScreenOptions extends {} = {},
|
|
538
|
+
EventMap extends EventMapBase = {},
|
|
539
|
+
ActionHelpers extends Record<string, (...args: any) => void> = {},
|
|
540
|
+
> = NavigationPropBase<
|
|
541
|
+
ParamList,
|
|
542
|
+
RouteName,
|
|
543
|
+
State,
|
|
544
|
+
ScreenOptions,
|
|
545
|
+
EventMap,
|
|
546
|
+
ActionHelpers
|
|
547
|
+
> & {
|
|
490
548
|
/**
|
|
491
549
|
* Returns the navigation prop of the parent screen.
|
|
492
550
|
* If a route name is provided, the navigation prop from the parent screen with matching route name (including current) will be returned.
|
|
@@ -505,58 +563,100 @@ export type NavigationProp<
|
|
|
505
563
|
ActionHelpers
|
|
506
564
|
>;
|
|
507
565
|
getParent(): NavigationProp<ParamListBase> | undefined;
|
|
508
|
-
} &
|
|
509
|
-
ActionHelpers &
|
|
510
|
-
EventConsumer<EventMap & EventMapCore<State>> &
|
|
511
|
-
PrivateValueStore<[ParamList, RouteName, EventMap]>;
|
|
566
|
+
} & PrivateValueStore<[ParamList, RouteName, EventMap, ActionHelpers]>;
|
|
512
567
|
|
|
513
568
|
export type RouteProp<
|
|
569
|
+
in out ParamList extends ParamListBase,
|
|
570
|
+
in out RouteName extends keyof ParamList = KeyOf<ParamList>,
|
|
571
|
+
> = Route<Extract<RouteName, string>, ParamList[RouteName]>;
|
|
572
|
+
|
|
573
|
+
type ScreenRouteProp<
|
|
514
574
|
ParamList extends ParamListBase,
|
|
515
575
|
RouteName extends keyof ParamList = KeyOf<ParamList>,
|
|
516
|
-
> =
|
|
576
|
+
> = {
|
|
577
|
+
[Name in Extract<RouteName, string>]: RouteProp<ParamList, Name>;
|
|
578
|
+
}[Extract<RouteName, string>];
|
|
517
579
|
|
|
518
580
|
export type CompositeNavigationProp<
|
|
519
581
|
A extends NavigationProp<ParamListBase, any, any, any, any>,
|
|
520
582
|
B extends NavigationProp<ParamListBase, any, any, any, any>,
|
|
521
|
-
> =
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
583
|
+
> = CompositeNavigationPropInternal<
|
|
584
|
+
A,
|
|
585
|
+
B,
|
|
586
|
+
/**
|
|
587
|
+
* Param list from both navigation objects needs to be combined
|
|
588
|
+
* For example, we should be able to navigate to screens in both A and B
|
|
589
|
+
*/
|
|
590
|
+
ParamListOfNavigationProp<A> & ParamListOfNavigationProp<B>,
|
|
591
|
+
/**
|
|
592
|
+
* The route name should refer to the route name specified in the first type
|
|
593
|
+
*/
|
|
594
|
+
RouteNameOfNavigationProp<A>,
|
|
595
|
+
/**
|
|
596
|
+
* Event map should refer to the config specified in the first type
|
|
597
|
+
*/
|
|
598
|
+
EventMapOfNavigationProp<A>
|
|
599
|
+
>;
|
|
600
|
+
|
|
601
|
+
type CompositeNavigationPropInternal<
|
|
602
|
+
A extends NavigationProp<ParamListBase, any, any, any, any>,
|
|
603
|
+
B extends NavigationProp<ParamListBase, any, any, any, any>,
|
|
604
|
+
ParamList extends {},
|
|
605
|
+
RouteName extends keyof ParamList,
|
|
606
|
+
EventMap extends EventMapBase,
|
|
607
|
+
> = // Action helpers are read from the private brand (4th slot) instead of
|
|
608
|
+
// `Omit<A & B, keyof NavigationProp>`, which had to walk the whole (possibly
|
|
609
|
+
// deeply composed) member set of `A & B` to drop the standard members.
|
|
610
|
+
ActionHelpersOfNavigationProp<A> &
|
|
611
|
+
ActionHelpersOfNavigationProp<B> &
|
|
612
|
+
// Intersect the brand-free base directly instead of `Omit`-ing `getParent`
|
|
613
|
+
// off a full `NavigationProp`, so we skip a mapped-type pass per composite.
|
|
614
|
+
NavigationPropBase<
|
|
615
|
+
ParamList,
|
|
616
|
+
RouteName,
|
|
617
|
+
StateOfNavigationProp<A>,
|
|
618
|
+
ScreenOptionsOfNavigationProp<A>,
|
|
619
|
+
EventMap
|
|
620
|
+
> & {
|
|
621
|
+
getParent: A['getParent'] & B['getParent'];
|
|
622
|
+
} & PrivateValueStore<
|
|
623
|
+
[
|
|
624
|
+
ParamList,
|
|
625
|
+
RouteName,
|
|
626
|
+
EventMap,
|
|
627
|
+
ActionHelpersOfNavigationProp<A> & ActionHelpersOfNavigationProp<B>,
|
|
628
|
+
]
|
|
629
|
+
>;
|
|
630
|
+
|
|
631
|
+
type PrivateValueOfNavigationProp<T> =
|
|
632
|
+
T extends PrivateValueStore<infer Value> ? Value : [never, unknown, {}, {}];
|
|
633
|
+
|
|
634
|
+
type ParamListOfNavigationProp<T> = PrivateValueOfNavigationProp<T>[0];
|
|
635
|
+
|
|
636
|
+
type RouteNameOfNavigationProp<T> = PrivateValueOfNavigationProp<T>[1];
|
|
637
|
+
|
|
638
|
+
type ActionHelpersOfNavigationProp<T> = PrivateValueOfNavigationProp<T>[3];
|
|
639
|
+
|
|
640
|
+
type StateOfNavigationProp<T> = T extends {
|
|
641
|
+
getState: () => infer State extends NavigationState;
|
|
642
|
+
}
|
|
643
|
+
? State
|
|
644
|
+
: NavigationState;
|
|
645
|
+
|
|
646
|
+
type ScreenOptionsOfNavigationProp<T> = T extends {
|
|
647
|
+
setOptions: (options: Partial<infer ScreenOptions>) => void;
|
|
648
|
+
}
|
|
649
|
+
? ScreenOptions
|
|
650
|
+
: {};
|
|
651
|
+
|
|
652
|
+
type EventMapOfNavigationProp<T> = PrivateValueOfNavigationProp<T>[2];
|
|
553
653
|
|
|
554
654
|
export type CompositeScreenProps<
|
|
555
|
-
A extends {
|
|
655
|
+
in out A extends {
|
|
556
656
|
navigation: NavigationProp<ParamListBase, string, any, any, any>;
|
|
557
657
|
route: RouteProp<ParamListBase>;
|
|
558
658
|
},
|
|
559
|
-
B extends {
|
|
659
|
+
in out B extends {
|
|
560
660
|
navigation: NavigationProp<ParamListBase, string, any, any, any>;
|
|
561
661
|
},
|
|
562
662
|
> = {
|
|
@@ -565,12 +665,12 @@ export type CompositeScreenProps<
|
|
|
565
665
|
};
|
|
566
666
|
|
|
567
667
|
export type ScreenLayoutArgs<
|
|
568
|
-
ParamList extends ParamListBase,
|
|
569
|
-
RouteName extends keyof ParamList,
|
|
570
|
-
ScreenOptions extends {},
|
|
571
|
-
Navigation,
|
|
668
|
+
in out ParamList extends ParamListBase,
|
|
669
|
+
in out RouteName extends keyof ParamList,
|
|
670
|
+
in out ScreenOptions extends {},
|
|
671
|
+
in out Navigation,
|
|
572
672
|
> = {
|
|
573
|
-
route:
|
|
673
|
+
route: ScreenRouteProp<ParamList, RouteName>;
|
|
574
674
|
options: ScreenOptions;
|
|
575
675
|
navigation: Navigation;
|
|
576
676
|
theme: Theme;
|
|
@@ -578,9 +678,9 @@ export type ScreenLayoutArgs<
|
|
|
578
678
|
};
|
|
579
679
|
|
|
580
680
|
export type Descriptor<
|
|
581
|
-
ScreenOptions extends {},
|
|
582
|
-
Navigation extends NavigationProp<
|
|
583
|
-
Route extends RouteProp<any, any>,
|
|
681
|
+
out ScreenOptions extends {},
|
|
682
|
+
out Navigation extends NavigationProp<ParamListBase, any, any, any, any>,
|
|
683
|
+
out Route extends RouteProp<any, any>,
|
|
584
684
|
> = {
|
|
585
685
|
/**
|
|
586
686
|
* Render the component associated with this route.
|
|
@@ -604,8 +704,8 @@ export type Descriptor<
|
|
|
604
704
|
};
|
|
605
705
|
|
|
606
706
|
export type ScreenListeners<
|
|
607
|
-
State extends NavigationState,
|
|
608
|
-
EventMap extends EventMapBase,
|
|
707
|
+
in out State extends NavigationState,
|
|
708
|
+
in out EventMap extends EventMapBase,
|
|
609
709
|
> = Partial<{
|
|
610
710
|
[EventName in keyof (EventMap & EventMapCore<State>)]: EventListenerCallback<
|
|
611
711
|
EventMap & EventMapCore<State>,
|
|
@@ -656,19 +756,19 @@ export type RouteConfigComponent<
|
|
|
656
756
|
};
|
|
657
757
|
|
|
658
758
|
export type RouteConfigProps<
|
|
659
|
-
ParamList extends ParamListBase,
|
|
660
|
-
RouteName extends keyof ParamList,
|
|
661
|
-
State extends NavigationState,
|
|
662
|
-
ScreenOptions extends {},
|
|
663
|
-
EventMap extends EventMapBase,
|
|
664
|
-
Navigation,
|
|
759
|
+
in out ParamList extends ParamListBase,
|
|
760
|
+
in out RouteName extends keyof ParamList,
|
|
761
|
+
in out State extends NavigationState,
|
|
762
|
+
in out ScreenOptions extends {},
|
|
763
|
+
in out EventMap extends EventMapBase,
|
|
764
|
+
in out Navigation,
|
|
665
765
|
> = {
|
|
666
766
|
/**
|
|
667
767
|
* Optional key for this screen. This doesn't need to be unique.
|
|
668
768
|
* If the key changes, existing screens with this name will be removed or reset.
|
|
669
769
|
* Useful when we have some common screens and have conditional rendering.
|
|
670
770
|
*/
|
|
671
|
-
navigationKey?: string;
|
|
771
|
+
navigationKey?: string | undefined;
|
|
672
772
|
|
|
673
773
|
/**
|
|
674
774
|
* Route name of this screen.
|
|
@@ -679,31 +779,39 @@ export type RouteConfigProps<
|
|
|
679
779
|
* Navigator options for this screen.
|
|
680
780
|
*/
|
|
681
781
|
options?:
|
|
682
|
-
|
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
782
|
+
| (
|
|
783
|
+
| ScreenOptions
|
|
784
|
+
| ((props: {
|
|
785
|
+
route: RouteProp<ParamList, RouteName>;
|
|
786
|
+
navigation: Navigation;
|
|
787
|
+
theme: Theme;
|
|
788
|
+
}) => ScreenOptions)
|
|
789
|
+
)
|
|
790
|
+
| undefined;
|
|
688
791
|
|
|
689
792
|
/**
|
|
690
793
|
* Event listeners for this screen.
|
|
691
794
|
*/
|
|
692
795
|
listeners?:
|
|
693
|
-
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
796
|
+
| (
|
|
797
|
+
| ScreenListeners<State, EventMap>
|
|
798
|
+
| ((props: {
|
|
799
|
+
route: RouteProp<ParamList, RouteName>;
|
|
800
|
+
navigation: Navigation;
|
|
801
|
+
}) => ScreenListeners<State, EventMap>)
|
|
802
|
+
)
|
|
803
|
+
| undefined;
|
|
698
804
|
|
|
699
805
|
/**
|
|
700
806
|
* Layout for this screen.
|
|
701
807
|
* Useful for wrapping the screen with custom containers.
|
|
702
808
|
* e.g. for styling, error boundaries, suspense, etc.
|
|
703
809
|
*/
|
|
704
|
-
layout?:
|
|
705
|
-
|
|
706
|
-
|
|
810
|
+
layout?:
|
|
811
|
+
| ((
|
|
812
|
+
props: ScreenLayoutArgs<ParamList, RouteName, ScreenOptions, Navigation>
|
|
813
|
+
) => React.ReactElement)
|
|
814
|
+
| undefined;
|
|
707
815
|
|
|
708
816
|
/**
|
|
709
817
|
* Function to return an unique ID for this screen.
|
|
@@ -711,16 +819,18 @@ export type RouteConfigProps<
|
|
|
711
819
|
* For a given screen name, there will always be only one screen corresponding to an ID.
|
|
712
820
|
* If `undefined` is returned, it acts same as no `getId` being specified.
|
|
713
821
|
*/
|
|
714
|
-
getId?:
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
822
|
+
getId?:
|
|
823
|
+
| (({
|
|
824
|
+
params,
|
|
825
|
+
}: {
|
|
826
|
+
params: Readonly<ParamList[RouteName]>;
|
|
827
|
+
}) => string | undefined)
|
|
828
|
+
| undefined;
|
|
719
829
|
|
|
720
830
|
/**
|
|
721
831
|
* Initial params object for the route.
|
|
722
832
|
*/
|
|
723
|
-
initialParams?: Partial<ParamList[RouteName]
|
|
833
|
+
initialParams?: Partial<ParamList[RouteName]> | undefined;
|
|
724
834
|
};
|
|
725
835
|
|
|
726
836
|
export type RouteConfig<
|
|
@@ -741,43 +851,49 @@ export type RouteConfig<
|
|
|
741
851
|
RouteConfigComponent<ParamList, RouteName>;
|
|
742
852
|
|
|
743
853
|
export type RouteGroupConfig<
|
|
744
|
-
ParamList extends ParamListBase,
|
|
745
|
-
ScreenOptions extends {},
|
|
746
|
-
Navigation,
|
|
854
|
+
in out ParamList extends ParamListBase,
|
|
855
|
+
in out ScreenOptions extends {},
|
|
856
|
+
in out Navigation,
|
|
747
857
|
> = {
|
|
748
858
|
/**
|
|
749
859
|
* Optional key for the screens in this group.
|
|
750
860
|
* If the key changes, all existing screens in this group will be removed or reset.
|
|
751
861
|
*/
|
|
752
|
-
navigationKey?: string;
|
|
862
|
+
navigationKey?: string | undefined;
|
|
753
863
|
|
|
754
864
|
/**
|
|
755
865
|
* Navigator options for this screen.
|
|
756
866
|
*/
|
|
757
867
|
screenOptions?:
|
|
758
|
-
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
868
|
+
| (
|
|
869
|
+
| ScreenOptions
|
|
870
|
+
| ((props: {
|
|
871
|
+
route: ScreenRouteProp<ParamList>;
|
|
872
|
+
navigation: Navigation;
|
|
873
|
+
theme: Theme;
|
|
874
|
+
}) => ScreenOptions)
|
|
875
|
+
)
|
|
876
|
+
| undefined;
|
|
764
877
|
|
|
765
878
|
/**
|
|
766
879
|
* Layout for the screens inside the group.
|
|
767
880
|
* This will override the `screenLayout` of parent group or navigator.
|
|
768
881
|
*/
|
|
769
882
|
screenLayout?:
|
|
770
|
-
| (
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
883
|
+
| (
|
|
884
|
+
| ((
|
|
885
|
+
props: ScreenLayoutArgs<
|
|
886
|
+
ParamList,
|
|
887
|
+
keyof ParamList,
|
|
888
|
+
ScreenOptions,
|
|
889
|
+
Navigation
|
|
890
|
+
>
|
|
891
|
+
) => React.ReactElement)
|
|
892
|
+
| {
|
|
893
|
+
// FIXME: TypeScript doesn't seem to infer `navigation` correctly without this
|
|
894
|
+
}
|
|
895
|
+
)
|
|
896
|
+
| undefined;
|
|
781
897
|
|
|
782
898
|
/**
|
|
783
899
|
* Children React Elements to extract the route configuration from.
|
|
@@ -843,15 +959,19 @@ export type NavigationContainerEventMap = {
|
|
|
843
959
|
/**
|
|
844
960
|
* The data object passed when emitting the event.
|
|
845
961
|
*/
|
|
846
|
-
data
|
|
962
|
+
data?: unknown;
|
|
847
963
|
/**
|
|
848
964
|
* The key of the target route which received the event.
|
|
849
965
|
*/
|
|
850
|
-
target
|
|
966
|
+
target?: string | undefined;
|
|
851
967
|
/**
|
|
852
968
|
* Whether `event.preventDefault()` was called on this event.
|
|
853
969
|
*/
|
|
854
|
-
defaultPrevented
|
|
970
|
+
defaultPrevented?: boolean | undefined;
|
|
971
|
+
/**
|
|
972
|
+
* Prevent the default action which happens on this event.
|
|
973
|
+
*/
|
|
974
|
+
preventDefault?: (() => void) | undefined;
|
|
855
975
|
};
|
|
856
976
|
};
|
|
857
977
|
};
|
|
@@ -922,12 +1042,44 @@ export type GenericNavigation<ParamList extends {}> = Omit<
|
|
|
922
1042
|
export type RouteForName<
|
|
923
1043
|
ParamList extends {},
|
|
924
1044
|
RouteName extends string,
|
|
925
|
-
> =
|
|
1045
|
+
> = string extends RouteName
|
|
1046
|
+
? // RouteName is a not a literal but `string`
|
|
1047
|
+
// Return union of all possible routes in the tree
|
|
1048
|
+
ParamListRoute<ParamList>
|
|
1049
|
+
: RouteForNameInternal<ParamList, RouteName>;
|
|
1050
|
+
|
|
1051
|
+
// Look up route object by checking each level and recursing into the nested param lists
|
|
1052
|
+
// This avoids building a union of all routes, which doesn't scale on large trees
|
|
1053
|
+
type RouteForNameInternal<ParamList extends {}, RouteName extends string> =
|
|
1054
|
+
| (RouteName extends KeyOf<ParamList>
|
|
1055
|
+
? RouteProp<ParamList, RouteName>
|
|
1056
|
+
: never)
|
|
1057
|
+
| RouteForNameNested<NestedParamLists<ParamList>, RouteName>;
|
|
1058
|
+
|
|
1059
|
+
type RouteForNameNested<ParamLists, RouteName extends string> =
|
|
1060
|
+
// Distributes over the union of nested param lists
|
|
1061
|
+
// e.g. if ParamLists is A | B
|
|
1062
|
+
// TypeScript evaluates the branch once per member (A, then B)
|
|
1063
|
+
// and unions the outcomes
|
|
1064
|
+
ParamLists extends {} ? RouteForNameInternal<ParamLists, RouteName> : never;
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Union of param lists of the nested navigators in a param list.
|
|
1068
|
+
*/
|
|
1069
|
+
export type NestedParamLists<ParamList extends {}> = {
|
|
1070
|
+
[RouteName in keyof ParamList]: NavigatorScreenParams<{}> extends ParamList[RouteName]
|
|
1071
|
+
? NotUndefined<ParamList[RouteName]> extends NavigatorScreenParams<infer T>
|
|
1072
|
+
? ParamListForNavigator<T>
|
|
1073
|
+
: never
|
|
1074
|
+
: never;
|
|
1075
|
+
}[keyof ParamList];
|
|
926
1076
|
|
|
927
1077
|
type ParamListRoute<ParamList extends {}> = {
|
|
928
1078
|
[RouteName in keyof ParamList]: NavigatorScreenParams<{}> extends ParamList[RouteName]
|
|
929
1079
|
? NotUndefined<ParamList[RouteName]> extends NavigatorScreenParams<infer T>
|
|
930
|
-
?
|
|
1080
|
+
?
|
|
1081
|
+
| ParamListRoute<ParamListForNavigator<T>>
|
|
1082
|
+
| RouteProp<ParamList, RouteName>
|
|
931
1083
|
: RouteProp<ParamList, RouteName>
|
|
932
1084
|
: RouteProp<ParamList, RouteName>;
|
|
933
1085
|
}[keyof ParamList];
|
|
@@ -938,11 +1090,10 @@ type MaybeParamListRoute<ParamList extends {}> = ParamList extends ParamListBase
|
|
|
938
1090
|
|
|
939
1091
|
type BasicNavigationComposite<
|
|
940
1092
|
Navigation extends NavigationProp<any, any, any, any, any>,
|
|
941
|
-
Parent,
|
|
942
|
-
> =
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
: Navigation;
|
|
1093
|
+
Parent extends NavigationProp<any, any, any, any, any> | undefined,
|
|
1094
|
+
> = Parent extends undefined
|
|
1095
|
+
? Navigation
|
|
1096
|
+
: CompositeNavigationProp<Navigation, NonNullable<Parent>>;
|
|
946
1097
|
|
|
947
1098
|
type BasicNavigationList<
|
|
948
1099
|
ParamList extends {},
|
|
@@ -954,11 +1105,15 @@ type BasicNavigationList<
|
|
|
954
1105
|
? NotUndefined<ParamList[RouteName]> extends NavigatorScreenParams<
|
|
955
1106
|
infer T
|
|
956
1107
|
>
|
|
957
|
-
?
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
1108
|
+
? ParamListForNavigator<T> extends infer NestedParamList extends {}
|
|
1109
|
+
? keyof NestedParamList extends ExcludedRouteNames
|
|
1110
|
+
? {}
|
|
1111
|
+
: BasicNavigationList<
|
|
1112
|
+
NestedParamList,
|
|
1113
|
+
ExcludedRouteNames,
|
|
1114
|
+
NavigationProp<ParamList, RouteName>
|
|
1115
|
+
>
|
|
1116
|
+
: {}
|
|
962
1117
|
: {}
|
|
963
1118
|
: {}) &
|
|
964
1119
|
(RouteName extends ExcludedRouteNames
|
|
@@ -972,178 +1127,403 @@ type BasicNavigationList<
|
|
|
972
1127
|
}[keyof ParamList]
|
|
973
1128
|
>;
|
|
974
1129
|
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
?
|
|
978
|
-
:
|
|
979
|
-
?
|
|
980
|
-
:
|
|
981
|
-
|
|
982
|
-
export type NavigationListForNested<Navigator> = FlatType<
|
|
983
|
-
NavigationListForNestedInternal<Navigator> &
|
|
984
|
-
(Navigator extends TypedNavigator<infer Bag, any>
|
|
985
|
-
? BasicNavigationList<
|
|
986
|
-
Bag['ParamList'],
|
|
987
|
-
keyof NavigationListForNestedInternal<Navigator>,
|
|
988
|
-
undefined
|
|
989
|
-
>
|
|
990
|
-
: Navigator extends PrivateValueStore<[infer ParamList, any, any]>
|
|
991
|
-
? ParamList extends {}
|
|
992
|
-
? BasicNavigationList<
|
|
993
|
-
ParamList,
|
|
994
|
-
keyof NavigationListForNestedInternal<Navigator>,
|
|
995
|
-
undefined
|
|
996
|
-
>
|
|
997
|
-
: {}
|
|
998
|
-
: {})
|
|
999
|
-
>;
|
|
1130
|
+
type InheritedParentParams<ParentParamList, ParamList> = {
|
|
1131
|
+
[K in keyof ParentParamList as K extends keyof ParamList
|
|
1132
|
+
? never
|
|
1133
|
+
: string extends K
|
|
1134
|
+
? never
|
|
1135
|
+
: K]: ParentParamList[K];
|
|
1136
|
+
};
|
|
1000
1137
|
|
|
1001
|
-
type
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1138
|
+
type GenericNavigationComposite<
|
|
1139
|
+
ParamList extends ParamListBase,
|
|
1140
|
+
RouteName extends keyof ParamList,
|
|
1141
|
+
Parent,
|
|
1142
|
+
> =
|
|
1143
|
+
Parent extends NavigationProp<any, any, any, any, any>
|
|
1144
|
+
? ParamListOfNavigationProp<Parent> extends infer ParentParamList
|
|
1145
|
+
? NavigationProp<
|
|
1146
|
+
ParamList & InheritedParentParams<ParentParamList, ParamList>,
|
|
1147
|
+
RouteName
|
|
1148
|
+
> & { getParent: Parent['getParent'] }
|
|
1149
|
+
: never
|
|
1150
|
+
: NavigationProp<ParamList, RouteName>;
|
|
1151
|
+
|
|
1152
|
+
type NavigationListForScreenParams<
|
|
1153
|
+
T extends {},
|
|
1154
|
+
ParamList extends ParamListBase,
|
|
1155
|
+
RouteName extends keyof ParamList,
|
|
1156
|
+
ExcludedRouteNames,
|
|
1157
|
+
Parent extends NavigationProp<any, any, any, any, any> | undefined,
|
|
1158
|
+
> = T extends PrivateValueStore<[any, any, any, any]> & NavigatorLike
|
|
1159
|
+
? NavigationListForNestedInternal<
|
|
1160
|
+
T,
|
|
1161
|
+
GenericNavigationComposite<ParamList, RouteName, Parent>
|
|
1162
|
+
>
|
|
1163
|
+
: NavigationListForParamListScreenParams<
|
|
1164
|
+
T,
|
|
1165
|
+
ParamList,
|
|
1166
|
+
RouteName,
|
|
1167
|
+
ExcludedRouteNames,
|
|
1168
|
+
Parent
|
|
1006
1169
|
>;
|
|
1007
1170
|
|
|
1008
|
-
type
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1171
|
+
type NavigationListForParamListScreenParams<
|
|
1172
|
+
T extends {},
|
|
1173
|
+
ParamList extends ParamListBase,
|
|
1174
|
+
RouteName extends keyof ParamList,
|
|
1175
|
+
ExcludedRouteNames,
|
|
1176
|
+
Parent extends NavigationProp<any, any, any, any, any> | undefined,
|
|
1177
|
+
> =
|
|
1178
|
+
// `T` is only ever a plain param list here, since navigators are routed to
|
|
1179
|
+
// `NavigationListForNestedInternal` by `NavigationListForScreenParams`.
|
|
1180
|
+
// So there's no navigator to unwrap with `ParamListForNavigator`.
|
|
1181
|
+
T extends ParamListBase
|
|
1182
|
+
? BasicNavigationListForParamList<
|
|
1183
|
+
T,
|
|
1184
|
+
ExcludedRouteNames,
|
|
1185
|
+
GenericNavigationComposite<ParamList, RouteName, Parent>
|
|
1186
|
+
>
|
|
1187
|
+
: {};
|
|
1188
|
+
|
|
1189
|
+
type BasicNavigationListForParamList<
|
|
1190
|
+
ParamList extends ParamListBase,
|
|
1191
|
+
ExcludedRouteNames,
|
|
1192
|
+
Parent extends NavigationProp<any, any, any, any, any> | undefined,
|
|
1193
|
+
> = UnionToIntersection<
|
|
1194
|
+
{
|
|
1195
|
+
[RouteName in keyof ParamList]: (NavigatorScreenParams<{}> extends ParamList[RouteName]
|
|
1196
|
+
? NotUndefined<ParamList[RouteName]> extends NavigatorScreenParams<
|
|
1197
|
+
infer T
|
|
1198
|
+
>
|
|
1199
|
+
? NavigationListForScreenParams<
|
|
1200
|
+
T,
|
|
1201
|
+
ParamList,
|
|
1202
|
+
RouteName,
|
|
1203
|
+
ExcludedRouteNames,
|
|
1204
|
+
Parent
|
|
1205
|
+
>
|
|
1206
|
+
: {}
|
|
1207
|
+
: {}) &
|
|
1208
|
+
(RouteName extends ExcludedRouteNames
|
|
1209
|
+
? {}
|
|
1210
|
+
: {
|
|
1211
|
+
[Key in RouteName]: GenericNavigationComposite<
|
|
1212
|
+
ParamList,
|
|
1213
|
+
RouteName,
|
|
1214
|
+
Parent
|
|
1215
|
+
>;
|
|
1216
|
+
});
|
|
1217
|
+
}[keyof ParamList]
|
|
1218
|
+
>;
|
|
1014
1219
|
|
|
1015
|
-
type
|
|
1220
|
+
export type NavigationListForNavigator<Navigator> =
|
|
1221
|
+
Navigator extends PrivateValueStore<infer Value> ? Value[1] : {};
|
|
1222
|
+
|
|
1223
|
+
export type NavigationListForNested<Navigator> =
|
|
1224
|
+
NavigationListForNestedInternal<Navigator> extends infer NavigationList
|
|
1225
|
+
? Navigator extends PrivateValueStore<[infer ParamList, any, any, any]>
|
|
1226
|
+
? ParamList extends {}
|
|
1227
|
+
? NavigationList &
|
|
1228
|
+
BasicNavigationList<ParamList, keyof NavigationList, undefined>
|
|
1229
|
+
: NavigationList
|
|
1230
|
+
: NavigationList
|
|
1231
|
+
: never;
|
|
1232
|
+
|
|
1233
|
+
type NavigationListForNestedInternal<
|
|
1234
|
+
Navigator,
|
|
1235
|
+
Parent = undefined,
|
|
1236
|
+
NavigatorList extends Record<string, any> =
|
|
1237
|
+
NavigationListForNavigator<Navigator>,
|
|
1238
|
+
Navigators = NestedNavigatorsOf<Navigator>,
|
|
1239
|
+
// This navigator's own routes, each composed with the accumulated parent.
|
|
1240
|
+
// It's threaded into the recursion as the parent for nested navigators so
|
|
1241
|
+
// each route is composed with its ancestors exactly once, instead of
|
|
1242
|
+
// re-wrapping the whole descendant list at every level (which is quadratic
|
|
1243
|
+
// in the nesting depth).
|
|
1244
|
+
ComposedList = ComposeNavigationList<NavigatorList, Parent>,
|
|
1245
|
+
> = (Navigator extends {
|
|
1016
1246
|
readonly config: {
|
|
1017
|
-
screens?:
|
|
1018
|
-
groups?:
|
|
1247
|
+
readonly screens?: infer Screens;
|
|
1248
|
+
readonly groups?: infer Groups;
|
|
1019
1249
|
};
|
|
1020
1250
|
}
|
|
1021
|
-
?
|
|
1022
|
-
|
|
1023
|
-
|
|
1251
|
+
? ComposedList &
|
|
1252
|
+
NavigationListForScreens<ComposedList, Screens> &
|
|
1253
|
+
NavigationListForGroups<ComposedList, Groups>
|
|
1254
|
+
: ComposedList) &
|
|
1255
|
+
NavigationListForNestedNavigators<ComposedList, Navigators> &
|
|
1256
|
+
NavigationListForDynamicNestedParamLists<Navigator, ComposedList, Navigators>;
|
|
1257
|
+
|
|
1258
|
+
type NavigationListForDynamicNestedParamLists<
|
|
1259
|
+
Navigator,
|
|
1260
|
+
ParentList,
|
|
1261
|
+
Navigators,
|
|
1262
|
+
> = Navigator extends { readonly config: unknown }
|
|
1263
|
+
? {}
|
|
1264
|
+
: Navigator extends PrivateValueStore<[infer ParamList, any, any, any]>
|
|
1265
|
+
? NavigationListForNestedParamLists<ParentList, ParamList, Navigators>
|
|
1266
|
+
: {};
|
|
1024
1267
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
?
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
NavigationListForNested<Screens[K]>
|
|
1034
|
-
>
|
|
1035
|
-
: Screens[K] extends { screen: { config: any } }
|
|
1036
|
-
? NavigationListWithComposite<
|
|
1037
|
-
ParentList[K],
|
|
1038
|
-
NavigationListForNested<Screens[K]['screen']>
|
|
1039
|
-
>
|
|
1040
|
-
: {}
|
|
1041
|
-
: {};
|
|
1042
|
-
}[keyof Screens]
|
|
1043
|
-
>;
|
|
1268
|
+
// Map of route name to nested navigator type
|
|
1269
|
+
// inferred from `NavigatorScreenParams<typeof Navigator>`
|
|
1270
|
+
type NestedNavigatorsOf<Navigator> =
|
|
1271
|
+
Navigator extends PrivateValueStore<[any, any, any, infer Nesting]>
|
|
1272
|
+
? Nesting extends Record<string, any>
|
|
1273
|
+
? Nesting
|
|
1274
|
+
: {}
|
|
1275
|
+
: {};
|
|
1044
1276
|
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1277
|
+
// Like `NavigationListForScreens`, but reads nested navigators from the brand
|
|
1278
|
+
// map instead of a static config.
|
|
1279
|
+
type NavigationListForNestedNavigators<ParentList, Navigators> =
|
|
1280
|
+
UnionToIntersection<
|
|
1281
|
+
{
|
|
1282
|
+
[K in keyof Navigators]: K extends keyof ParentList
|
|
1283
|
+
? NavigationListForNestedInternal<Navigators[K], ParentList[K]>
|
|
1284
|
+
: {};
|
|
1285
|
+
}[keyof Navigators]
|
|
1286
|
+
>;
|
|
1287
|
+
|
|
1288
|
+
// Fallback for dynamic nested routes declared through NavigatorScreenParams<ParamList>.
|
|
1289
|
+
// Param-list branches expose generic navigation props, while nested navigator
|
|
1290
|
+
// entries still recover their concrete navigator props.
|
|
1291
|
+
type NavigationListForNestedParamLists<ParentList, ParamList, Navigators> =
|
|
1292
|
+
ParentList extends Record<string, any>
|
|
1293
|
+
? ParamList extends ParamListBase
|
|
1294
|
+
? UnionToIntersection<
|
|
1295
|
+
{
|
|
1296
|
+
[K in keyof ParamList]: K extends keyof Navigators
|
|
1297
|
+
? {}
|
|
1298
|
+
: K extends keyof ParentList
|
|
1299
|
+
? NavigatorScreenParams<{}> extends ParamList[K]
|
|
1300
|
+
? NotUndefined<ParamList[K]> extends NavigatorScreenParams<
|
|
1301
|
+
infer T
|
|
1302
|
+
>
|
|
1303
|
+
? NavigationListForScreenParams<
|
|
1304
|
+
T,
|
|
1305
|
+
ParamList,
|
|
1306
|
+
K,
|
|
1307
|
+
keyof ParentList,
|
|
1308
|
+
ParentList[K]
|
|
1309
|
+
>
|
|
1310
|
+
: {}
|
|
1311
|
+
: {}
|
|
1312
|
+
: {};
|
|
1313
|
+
}[keyof ParamList]
|
|
1314
|
+
>
|
|
1315
|
+
: {}
|
|
1055
1316
|
: {};
|
|
1056
1317
|
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1318
|
+
// Compose every entry in a navigator's list with the accumulated parent.
|
|
1319
|
+
// When there's no parent (root navigator), the list is returned as-is so the
|
|
1320
|
+
// common shallow case doesn't pay for a redundant mapped type.
|
|
1321
|
+
type ComposeNavigationList<NavigatorList extends Record<string, any>, Parent> =
|
|
1322
|
+
Parent extends NavigationProp<any, any, any, any, any>
|
|
1323
|
+
? {
|
|
1324
|
+
[K in keyof NavigatorList]: CompositeNavigationProp<
|
|
1325
|
+
NavigatorList[K],
|
|
1326
|
+
Parent
|
|
1327
|
+
>;
|
|
1328
|
+
}
|
|
1329
|
+
: NavigatorList;
|
|
1330
|
+
|
|
1331
|
+
type NavigationListForScreens<ParentList, Screens> = Screens extends {}
|
|
1332
|
+
? UnionToIntersection<
|
|
1333
|
+
{
|
|
1334
|
+
// Only check screens with static config to avoid overly-complex types
|
|
1335
|
+
// Otherwise TypeScript fails to load the types due to complexity
|
|
1336
|
+
[K in keyof Screens]: Screens[K] extends { config: any }
|
|
1337
|
+
? K extends keyof ParentList
|
|
1338
|
+
? NavigationListForNestedInternal<Screens[K], ParentList[K]>
|
|
1339
|
+
: never
|
|
1340
|
+
: Screens[K] extends { screen: { config: any } }
|
|
1341
|
+
? K extends keyof ParentList
|
|
1342
|
+
? NavigationListForNestedInternal<
|
|
1343
|
+
Screens[K]['screen'],
|
|
1344
|
+
ParentList[K]
|
|
1345
|
+
>
|
|
1346
|
+
: never
|
|
1347
|
+
: never;
|
|
1348
|
+
}[keyof Screens]
|
|
1349
|
+
>
|
|
1350
|
+
: {};
|
|
1351
|
+
|
|
1352
|
+
type NavigationListForGroups<ParentList, Groups> = Groups extends {}
|
|
1353
|
+
? UnionToIntersection<
|
|
1354
|
+
{
|
|
1355
|
+
[K in keyof Groups]: Groups[K] extends { screens: any }
|
|
1356
|
+
? NavigationListForScreens<ParentList, Groups[K]['screens']>
|
|
1357
|
+
: never;
|
|
1358
|
+
}[keyof Groups]
|
|
1359
|
+
>
|
|
1360
|
+
: {};
|
|
1361
|
+
|
|
1362
|
+
export type NavigationContainerRef<ParamList extends {}> = Omit<
|
|
1363
|
+
NavigationHelpers<ParamList>,
|
|
1364
|
+
keyof NavigationHelpersRoute<{}> | 'isFocused'
|
|
1365
|
+
> &
|
|
1366
|
+
NavigationHelpersRoute<{}> &
|
|
1367
|
+
EventConsumer<NavigationContainerEventMap> & {
|
|
1368
|
+
/**
|
|
1369
|
+
* Reset the navigation state of the root navigator to the provided state.
|
|
1370
|
+
*
|
|
1371
|
+
* @param state Navigation state object.
|
|
1372
|
+
*/
|
|
1373
|
+
resetRoot(state?: PartialState<NavigationState> | NavigationState): void;
|
|
1374
|
+
/**
|
|
1375
|
+
* Get the rehydrated navigation state of the navigation tree.
|
|
1376
|
+
*/
|
|
1377
|
+
getRootState(): NavigationState | undefined;
|
|
1378
|
+
/**
|
|
1379
|
+
* Get the currently focused navigation route.
|
|
1380
|
+
*/
|
|
1381
|
+
getCurrentRoute(): MaybeParamListRoute<ParamList> | undefined;
|
|
1382
|
+
/**
|
|
1383
|
+
* Get the currently focused route's options.
|
|
1384
|
+
*/
|
|
1385
|
+
getCurrentOptions(): object | undefined;
|
|
1386
|
+
/**
|
|
1387
|
+
* Whether the navigation container is ready to handle actions.
|
|
1388
|
+
*/
|
|
1389
|
+
isReady(): boolean;
|
|
1390
|
+
};
|
|
1091
1391
|
|
|
1092
1392
|
export type NavigationContainerRefWithCurrent<ParamList extends {}> =
|
|
1093
1393
|
NavigationContainerRef<ParamList> & {
|
|
1094
1394
|
current: NavigationContainerRef<ParamList> | null;
|
|
1095
1395
|
};
|
|
1096
1396
|
|
|
1097
|
-
export type NavigationListBase<ParamList extends ParamListBase> = {
|
|
1397
|
+
export type NavigationListBase<in out ParamList extends ParamListBase> = {
|
|
1098
1398
|
[RouteName in keyof ParamList]: unknown;
|
|
1099
1399
|
};
|
|
1100
1400
|
|
|
1101
|
-
|
|
1401
|
+
// Only use action helpers if all values are functions
|
|
1402
|
+
type ActionHelpersOf<T> =
|
|
1403
|
+
T extends Record<string, (...args: any) => void> ? T : {};
|
|
1404
|
+
|
|
1405
|
+
export interface NavigatorTypeBagBase {
|
|
1102
1406
|
ParamList: {};
|
|
1103
1407
|
State: NavigationState;
|
|
1104
1408
|
ScreenOptions: {};
|
|
1105
1409
|
EventMap: {};
|
|
1106
|
-
|
|
1410
|
+
ActionHelpers: {};
|
|
1411
|
+
NavigationList: {
|
|
1412
|
+
[RouteName in keyof this['ParamList']]: NavigationProp<
|
|
1413
|
+
this['ParamList'],
|
|
1414
|
+
RouteName,
|
|
1415
|
+
this['State'],
|
|
1416
|
+
this['ScreenOptions'],
|
|
1417
|
+
this['EventMap'],
|
|
1418
|
+
ActionHelpersOf<this['ActionHelpers']>
|
|
1419
|
+
>;
|
|
1420
|
+
};
|
|
1107
1421
|
Navigator: React.ComponentType<any>;
|
|
1108
|
-
}
|
|
1422
|
+
}
|
|
1109
1423
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
Bag['NavigationList'],
|
|
1119
|
-
Bag['Navigator']
|
|
1120
|
-
> &
|
|
1121
|
-
(undefined extends Config ? {} : { config: Config }) &
|
|
1122
|
-
PrivateValueStore<[Bag['ParamList'], Bag['NavigationList'], unknown]>;
|
|
1424
|
+
/**
|
|
1425
|
+
* Adds a proper `ParamList` to a type bag interface
|
|
1426
|
+
* So it can be used as `this['ParamList']`
|
|
1427
|
+
*/
|
|
1428
|
+
export type NavigatorTypeBagFor<
|
|
1429
|
+
TypeBag extends NavigatorTypeBagBase,
|
|
1430
|
+
ParamList extends {},
|
|
1431
|
+
> = TypeBag & { ParamList: ParamList };
|
|
1123
1432
|
|
|
1124
|
-
type
|
|
1433
|
+
export type NavigatorProps<
|
|
1125
1434
|
ParamList extends ParamListBase,
|
|
1126
1435
|
State extends NavigationState,
|
|
1127
1436
|
ScreenOptions extends {},
|
|
1128
1437
|
EventMap extends EventMapBase,
|
|
1129
|
-
|
|
1438
|
+
Navigation,
|
|
1130
1439
|
Navigator extends React.ComponentType<any>,
|
|
1440
|
+
> = Omit<
|
|
1441
|
+
React.ComponentProps<Navigator>,
|
|
1442
|
+
keyof DefaultNavigatorOptions<any, any, any, any, any>
|
|
1443
|
+
> &
|
|
1444
|
+
DefaultNavigatorOptions<
|
|
1445
|
+
ParamList,
|
|
1446
|
+
State,
|
|
1447
|
+
ScreenOptions,
|
|
1448
|
+
EventMap,
|
|
1449
|
+
Navigation
|
|
1450
|
+
>;
|
|
1451
|
+
|
|
1452
|
+
type TypedNavigatorStaticComponent<Bag extends NavigatorTypeBagBase> =
|
|
1453
|
+
React.ComponentType<
|
|
1454
|
+
Partial<
|
|
1455
|
+
Omit<
|
|
1456
|
+
NavigatorProps<
|
|
1457
|
+
Bag['ParamList'],
|
|
1458
|
+
Bag['State'],
|
|
1459
|
+
Bag['ScreenOptions'],
|
|
1460
|
+
Bag['EventMap'],
|
|
1461
|
+
Bag['NavigationList'][keyof Bag['ParamList']],
|
|
1462
|
+
Bag['Navigator']
|
|
1463
|
+
>,
|
|
1464
|
+
'children'
|
|
1465
|
+
>
|
|
1466
|
+
>
|
|
1467
|
+
>;
|
|
1468
|
+
|
|
1469
|
+
type TypedNavigatorStaticDecorated<Bag extends NavigatorTypeBagBase, Config> = {
|
|
1470
|
+
getComponent: () => React.ComponentType<{}>;
|
|
1471
|
+
config: Config;
|
|
1472
|
+
} & PrivateValueStore<
|
|
1473
|
+
[Bag['ParamList'], Bag['NavigationList'], unknown, unknown]
|
|
1474
|
+
>;
|
|
1475
|
+
|
|
1476
|
+
type TypedNavigatorStatic<
|
|
1477
|
+
in out Bag extends NavigatorTypeBagBase,
|
|
1478
|
+
in out Config,
|
|
1479
|
+
> = {
|
|
1480
|
+
config: Config;
|
|
1481
|
+
with: (
|
|
1482
|
+
Component: React.ComponentType<{
|
|
1483
|
+
Navigator: TypedNavigatorStaticComponent<Bag>;
|
|
1484
|
+
}>
|
|
1485
|
+
) => TypedNavigatorStaticDecorated<Bag, Config>;
|
|
1486
|
+
getComponent: () => TypedNavigatorStaticComponent<Bag>;
|
|
1487
|
+
};
|
|
1488
|
+
|
|
1489
|
+
export type TypedNavigator<
|
|
1490
|
+
Bag extends NavigatorTypeBagBase,
|
|
1491
|
+
Config = unknown,
|
|
1492
|
+
Nesting = unknown,
|
|
1493
|
+
> = (undefined extends Config
|
|
1494
|
+
? TypedNavigatorInternal<
|
|
1495
|
+
Bag['ParamList'],
|
|
1496
|
+
Bag['State'],
|
|
1497
|
+
Bag['ScreenOptions'],
|
|
1498
|
+
Bag['EventMap'],
|
|
1499
|
+
Bag['NavigationList'],
|
|
1500
|
+
Bag['Navigator']
|
|
1501
|
+
>
|
|
1502
|
+
: TypedNavigatorStatic<Bag, Config>) &
|
|
1503
|
+
PrivateValueStore<
|
|
1504
|
+
[Bag['ParamList'], Bag['NavigationList'], unknown, Nesting]
|
|
1505
|
+
>;
|
|
1506
|
+
|
|
1507
|
+
type TypedNavigatorInternal<
|
|
1508
|
+
in out ParamList extends ParamListBase,
|
|
1509
|
+
in out State extends NavigationState,
|
|
1510
|
+
in out ScreenOptions extends {},
|
|
1511
|
+
in out EventMap extends EventMapBase,
|
|
1512
|
+
in out NavigationList extends NavigationListBase<ParamList>,
|
|
1513
|
+
in out Navigator extends React.ComponentType<any>,
|
|
1131
1514
|
> = {
|
|
1132
1515
|
/**
|
|
1133
1516
|
* Navigator component which manages the child screens.
|
|
1134
1517
|
*/
|
|
1135
1518
|
Navigator: React.ComponentType<
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
EventMap,
|
|
1145
|
-
NavigationList[keyof ParamList]
|
|
1146
|
-
>
|
|
1519
|
+
NavigatorProps<
|
|
1520
|
+
ParamList,
|
|
1521
|
+
State,
|
|
1522
|
+
ScreenOptions,
|
|
1523
|
+
EventMap,
|
|
1524
|
+
NavigationList[keyof ParamList],
|
|
1525
|
+
Navigator
|
|
1526
|
+
>
|
|
1147
1527
|
>;
|
|
1148
1528
|
/**
|
|
1149
1529
|
* Component used for grouping multiple route configuration.
|
|
@@ -1166,40 +1546,59 @@ type TypedNavigatorInternal<
|
|
|
1166
1546
|
) => null;
|
|
1167
1547
|
};
|
|
1168
1548
|
|
|
1169
|
-
|
|
1549
|
+
declare const NavigatorScreenParamsSymbol: unique symbol;
|
|
1550
|
+
|
|
1551
|
+
type NavigatorScreenParamsBrand<T extends {}> = {
|
|
1552
|
+
// Preserve the original generic for inference without affecting assignability.
|
|
1553
|
+
// - The symbol key hides the property from normal object usage
|
|
1554
|
+
// - The actual type is intersected for inference
|
|
1555
|
+
// - The `any` makes the property effectively `any` for assignability
|
|
1556
|
+
readonly [NavigatorScreenParamsSymbol]?: any & { readonly type: T };
|
|
1557
|
+
};
|
|
1558
|
+
|
|
1559
|
+
type NavigatorScreenParamsForParamList<ParamList extends {}> =
|
|
1170
1560
|
| {
|
|
1171
1561
|
screen?: never;
|
|
1172
1562
|
params?: never;
|
|
1173
1563
|
merge?: never;
|
|
1174
1564
|
initial?: never;
|
|
1175
1565
|
pop?: never;
|
|
1176
|
-
|
|
1566
|
+
preload?: never;
|
|
1567
|
+
path?: string | undefined;
|
|
1177
1568
|
state: PartialState<NavigationState> | NavigationState | undefined;
|
|
1178
1569
|
}
|
|
1179
1570
|
| {
|
|
1180
1571
|
[RouteName in keyof ParamList]: undefined extends ParamList[RouteName]
|
|
1181
1572
|
? {
|
|
1182
1573
|
screen: RouteName;
|
|
1183
|
-
params?: ParamList[RouteName];
|
|
1184
|
-
merge?: boolean;
|
|
1185
|
-
initial?: boolean;
|
|
1186
|
-
path?: string;
|
|
1187
|
-
pop?: boolean;
|
|
1574
|
+
params?: ParamList[RouteName] | undefined;
|
|
1575
|
+
merge?: boolean | undefined;
|
|
1576
|
+
initial?: boolean | undefined;
|
|
1577
|
+
path?: string | undefined;
|
|
1578
|
+
pop?: boolean | undefined;
|
|
1579
|
+
preload?: boolean | undefined;
|
|
1188
1580
|
state?: never;
|
|
1189
1581
|
}
|
|
1190
1582
|
: {
|
|
1191
1583
|
screen: RouteName;
|
|
1192
1584
|
params: ParamList[RouteName];
|
|
1193
|
-
merge?: boolean;
|
|
1194
|
-
initial?: boolean;
|
|
1195
|
-
path?: string;
|
|
1196
|
-
pop?: boolean;
|
|
1585
|
+
merge?: boolean | undefined;
|
|
1586
|
+
initial?: boolean | undefined;
|
|
1587
|
+
path?: string | undefined;
|
|
1588
|
+
pop?: boolean | undefined;
|
|
1589
|
+
preload?: boolean | undefined;
|
|
1197
1590
|
state?: never;
|
|
1198
1591
|
};
|
|
1199
1592
|
}[keyof ParamList];
|
|
1200
1593
|
|
|
1594
|
+
export type NavigatorScreenParams<ParamList extends {}> =
|
|
1595
|
+
NavigatorScreenParamsForParamList<ParamListForNavigator<ParamList>> &
|
|
1596
|
+
NavigatorScreenParamsBrand<ParamList>;
|
|
1597
|
+
|
|
1201
1598
|
type ParseConfig<Params> = {
|
|
1202
|
-
[K in keyof Params]?:
|
|
1599
|
+
[K in keyof Params]?:
|
|
1600
|
+
| ((value: string) => Params[K])
|
|
1601
|
+
| StandardSchemaV1<string | string[] | null | undefined, Params[K]>;
|
|
1203
1602
|
};
|
|
1204
1603
|
|
|
1205
1604
|
type StringifyConfig<Params> = {
|
|
@@ -1217,9 +1616,9 @@ type PathConfigAlias<Params> = {
|
|
|
1217
1616
|
* By default, paths are relating to the path config on the parent screen.
|
|
1218
1617
|
* If `exact` is set to `true`, the parent path configuration is not used.
|
|
1219
1618
|
*/
|
|
1220
|
-
exact?: boolean;
|
|
1619
|
+
exact?: boolean | undefined;
|
|
1221
1620
|
/**
|
|
1222
|
-
* An object mapping the param name to a function
|
|
1621
|
+
* An object mapping the param name to a parser function or a Standard Schema.
|
|
1223
1622
|
*
|
|
1224
1623
|
* @example
|
|
1225
1624
|
* ```js
|
|
@@ -1229,14 +1628,30 @@ type PathConfigAlias<Params> = {
|
|
|
1229
1628
|
* }
|
|
1230
1629
|
* ```
|
|
1231
1630
|
*/
|
|
1232
|
-
parse?: ParseConfig<Params
|
|
1631
|
+
parse?: ParseConfig<Params> | undefined;
|
|
1632
|
+
/**
|
|
1633
|
+
* Whether this path can resolve to multiple routes.
|
|
1634
|
+
* Both routes should specify `shared: true` for this to work.
|
|
1635
|
+
* By default, a path can only resolve to one route.
|
|
1636
|
+
*
|
|
1637
|
+
* This is useful when same screen used in multiple navigators,
|
|
1638
|
+
* e.g. tabs with stacks containing profile screen in each stack.
|
|
1639
|
+
*
|
|
1640
|
+
* The path defined first will be the canonical path.
|
|
1641
|
+
*/
|
|
1642
|
+
shared?: boolean | undefined;
|
|
1233
1643
|
};
|
|
1234
1644
|
|
|
1235
1645
|
export type PathConfig<Params> = FlatType<
|
|
1236
|
-
Partial<PathConfigAlias<Params>> & {
|
|
1646
|
+
Partial<Omit<PathConfigAlias<Params>, 'path'>> & {
|
|
1647
|
+
/**
|
|
1648
|
+
* Path string to match against.
|
|
1649
|
+
* e.g. `/users/:id` will match `/users/1` and extract `id` param as `1`.
|
|
1650
|
+
*/
|
|
1651
|
+
path?: string | undefined;
|
|
1237
1652
|
/**
|
|
1238
1653
|
* An object mapping the param name to a function which converts the param value to a string.
|
|
1239
|
-
* By default,
|
|
1654
|
+
* By default, arrays and null are preserved for query params, and other values are converted using `String(value)`.
|
|
1240
1655
|
* Keys are constrained to valid param names when Params type is provided.
|
|
1241
1656
|
*
|
|
1242
1657
|
* @example
|
|
@@ -1246,25 +1661,32 @@ export type PathConfig<Params> = FlatType<
|
|
|
1246
1661
|
* }
|
|
1247
1662
|
* ```
|
|
1248
1663
|
*/
|
|
1249
|
-
stringify?: StringifyConfig<Params
|
|
1664
|
+
stringify?: StringifyConfig<Params> | undefined;
|
|
1250
1665
|
/**
|
|
1251
1666
|
* Additional path alias that will be matched to the same screen.
|
|
1252
1667
|
*/
|
|
1253
|
-
alias?: (string | PathConfigAlias<Params>)[];
|
|
1668
|
+
alias?: (string | PathConfigAlias<Params>)[] | undefined;
|
|
1254
1669
|
} & (NonNullable<Params> extends NavigatorScreenParams<infer ParamList>
|
|
1255
|
-
? {
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1670
|
+
? ParamListForNavigator<ParamList> extends infer ChildParamList extends {}
|
|
1671
|
+
? {
|
|
1672
|
+
/**
|
|
1673
|
+
* Path configuration for child screens.
|
|
1674
|
+
*/
|
|
1675
|
+
screens?: PathConfigMap<ChildParamList> | undefined;
|
|
1676
|
+
/**
|
|
1677
|
+
* Name of the initial route to use for the navigator when the path matches.
|
|
1678
|
+
*/
|
|
1679
|
+
initialRouteName?:
|
|
1680
|
+
| Extract<keyof ChildParamList, string>
|
|
1681
|
+
| undefined;
|
|
1682
|
+
}
|
|
1683
|
+
: {}
|
|
1265
1684
|
: {})
|
|
1266
1685
|
>;
|
|
1267
1686
|
|
|
1268
1687
|
export type PathConfigMap<ParamList extends {}> = {
|
|
1269
|
-
[RouteName in keyof ParamList]?:
|
|
1688
|
+
[RouteName in keyof ParamList]?:
|
|
1689
|
+
| string
|
|
1690
|
+
| PathConfig<ParamList[RouteName]>
|
|
1691
|
+
| undefined;
|
|
1270
1692
|
};
|