@react-navigation/core 8.0.0-alpha.37 → 8.0.0-alpha.39
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/lib/module/NavigationBuilderContext.js.map +1 -1
- package/lib/module/NavigationIndependentTree.js +15 -19
- package/lib/module/NavigationIndependentTree.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/useDescriptors.js +4 -1
- package/lib/module/useDescriptors.js.map +1 -1
- package/lib/module/useNavigationBuilder.js +32 -18
- package/lib/module/useNavigationBuilder.js.map +1 -1
- package/lib/module/useNavigationCache.js +4 -2
- package/lib/module/useNavigationCache.js.map +1 -1
- package/lib/module/useNavigationHelpers.js +3 -9
- package/lib/module/useNavigationHelpers.js.map +1 -1
- package/lib/module/useOnAction.js +17 -2
- package/lib/module/useOnAction.js.map +1 -1
- package/lib/typescript/src/BaseNavigationContainer.d.ts +1 -1
- package/lib/typescript/src/BaseNavigationContainer.d.ts.map +1 -1
- package/lib/typescript/src/NavigationBuilderContext.d.ts +1 -0
- package/lib/typescript/src/NavigationBuilderContext.d.ts.map +1 -1
- package/lib/typescript/src/NavigationIndependentTree.d.ts.map +1 -1
- package/lib/typescript/src/StaticNavigation.d.ts +1 -1
- package/lib/typescript/src/StaticNavigation.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +3 -3
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useDescriptors.d.ts +3 -2
- package/lib/typescript/src/useDescriptors.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationBuilder.d.ts +3 -35
- package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationCache.d.ts +3 -2
- package/lib/typescript/src/useNavigationCache.d.ts.map +1 -1
- package/lib/typescript/src/useNavigationHelpers.d.ts +5 -36
- package/lib/typescript/src/useNavigationHelpers.d.ts.map +1 -1
- package/lib/typescript/src/useOnAction.d.ts.map +1 -1
- package/lib/typescript/src/utilities.d.ts +2 -2
- package/lib/typescript/src/utilities.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/BaseNavigationContainer.tsx +1 -1
- package/src/NavigationBuilderContext.tsx +1 -0
- package/src/NavigationIndependentTree.tsx +31 -34
- package/src/StaticNavigation.tsx +1 -1
- package/src/index.tsx +0 -1
- package/src/types.tsx +4 -3
- package/src/useDescriptors.tsx +6 -1
- package/src/useEventEmitter.tsx +1 -1
- package/src/useNavigationBuilder.tsx +48 -20
- package/src/useNavigationCache.tsx +6 -1
- package/src/useNavigationHelpers.tsx +7 -15
- package/src/useOnAction.tsx +27 -2
- package/src/utilities.tsx +2 -2
- package/lib/module/NavigationMetaContext.js +0 -15
- package/lib/module/NavigationMetaContext.js.map +0 -1
- package/lib/typescript/src/NavigationMetaContext.d.ts +0 -12
- package/lib/typescript/src/NavigationMetaContext.d.ts.map +0 -1
- package/src/NavigationMetaContext.tsx +0 -14
|
@@ -5,7 +5,6 @@ import { NavigationContainerRefContext } from './NavigationContainerRefContext';
|
|
|
5
5
|
import { NavigationFocusedRouteStateContext } from './NavigationFocusedRouteStateContext';
|
|
6
6
|
import { NavigationHelpersContext } from './NavigationHelpersContext';
|
|
7
7
|
import { NavigationIndependentTreeContext } from './NavigationIndependentTreeContext';
|
|
8
|
-
import { NavigationMetaContext } from './NavigationMetaContext';
|
|
9
8
|
import {
|
|
10
9
|
IsScreenContext,
|
|
11
10
|
NamedRouteContextListContext,
|
|
@@ -40,41 +39,39 @@ export function NavigationIndependentTree({
|
|
|
40
39
|
<NavigationRootContext.Provider value={undefined}>
|
|
41
40
|
<NavigationBuilderContext.Provider value={undefined}>
|
|
42
41
|
<StaticTreeContext.Provider value={undefined}>
|
|
43
|
-
<
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
<
|
|
47
|
-
<
|
|
48
|
-
|
|
42
|
+
<NavigationHelpersContext.Provider value={undefined}>
|
|
43
|
+
<NavigationStateListenerContext.Provider value={undefined}>
|
|
44
|
+
<FocusedRouteKeyContext.Provider value={undefined}>
|
|
45
|
+
<PreventRemoveContext.Provider value={undefined}>
|
|
46
|
+
<NamedNavigationStateListenerListContext.Provider
|
|
47
|
+
value={undefined}
|
|
48
|
+
>
|
|
49
|
+
<NamedRouteContextListContext.Provider
|
|
49
50
|
value={undefined}
|
|
50
51
|
>
|
|
51
|
-
<
|
|
52
|
-
value={undefined}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
</FocusedRouteKeyContext.Provider>
|
|
75
|
-
</NavigationStateListenerContext.Provider>
|
|
76
|
-
</NavigationHelpersContext.Provider>
|
|
77
|
-
</NavigationMetaContext.Provider>
|
|
52
|
+
<NavigationRouteContext.Provider value={undefined}>
|
|
53
|
+
<NavigationContext.Provider value={undefined}>
|
|
54
|
+
<IsFocusedContext.Provider value={undefined}>
|
|
55
|
+
<IsFocusedGetterContext.Provider
|
|
56
|
+
value={undefined}
|
|
57
|
+
>
|
|
58
|
+
<IsScreenContext.Provider value={false}>
|
|
59
|
+
<NavigationFocusedRouteStateContext.Provider
|
|
60
|
+
value={undefined}
|
|
61
|
+
>
|
|
62
|
+
{children}
|
|
63
|
+
</NavigationFocusedRouteStateContext.Provider>
|
|
64
|
+
</IsScreenContext.Provider>
|
|
65
|
+
</IsFocusedGetterContext.Provider>
|
|
66
|
+
</IsFocusedContext.Provider>
|
|
67
|
+
</NavigationContext.Provider>
|
|
68
|
+
</NavigationRouteContext.Provider>
|
|
69
|
+
</NamedRouteContextListContext.Provider>
|
|
70
|
+
</NamedNavigationStateListenerListContext.Provider>
|
|
71
|
+
</PreventRemoveContext.Provider>
|
|
72
|
+
</FocusedRouteKeyContext.Provider>
|
|
73
|
+
</NavigationStateListenerContext.Provider>
|
|
74
|
+
</NavigationHelpersContext.Provider>
|
|
78
75
|
</StaticTreeContext.Provider>
|
|
79
76
|
</NavigationBuilderContext.Provider>
|
|
80
77
|
</NavigationRootContext.Provider>
|
package/src/StaticNavigation.tsx
CHANGED
|
@@ -522,7 +522,7 @@ type StaticConfigCommon<Bag extends NavigatorTypeBagBase> = Omit<
|
|
|
522
522
|
'screens' | 'children'
|
|
523
523
|
>;
|
|
524
524
|
|
|
525
|
-
|
|
525
|
+
type StaticConfigBase<
|
|
526
526
|
Bag extends NavigatorTypeBagBase,
|
|
527
527
|
Screens = StaticConfigScreensForBag<Bag>,
|
|
528
528
|
Groups = StaticConfigGroupsForBag<Bag>,
|
package/src/index.tsx
CHANGED
|
@@ -17,7 +17,6 @@ export {
|
|
|
17
17
|
} from './NavigationFocusedRouteStateContext';
|
|
18
18
|
export { NavigationHelpersContext } from './NavigationHelpersContext';
|
|
19
19
|
export { NavigationIndependentTree } from './NavigationIndependentTree';
|
|
20
|
-
export { NavigationMetaContext } from './NavigationMetaContext';
|
|
21
20
|
export {
|
|
22
21
|
IsScreenContext,
|
|
23
22
|
NavigationContext,
|
package/src/types.tsx
CHANGED
|
@@ -81,7 +81,7 @@ export type DefaultNavigatorOptions<
|
|
|
81
81
|
layout?:
|
|
82
82
|
| ((props: {
|
|
83
83
|
state: State;
|
|
84
|
-
navigation: NavigationHelpers<ParamList>;
|
|
84
|
+
navigation: NavigationHelpers<ParamList, State>;
|
|
85
85
|
descriptors: Record<
|
|
86
86
|
string,
|
|
87
87
|
Descriptor<
|
|
@@ -259,7 +259,7 @@ export type EventEmitter<in out EventMap extends EventMapBase> = {
|
|
|
259
259
|
emit<EventName extends KeyOf<EventMap>>(
|
|
260
260
|
options: {
|
|
261
261
|
type: EventName;
|
|
262
|
-
target?: string;
|
|
262
|
+
target?: string | undefined;
|
|
263
263
|
} & (EventMap[EventName]['canPreventDefault'] extends true
|
|
264
264
|
? { canPreventDefault: true }
|
|
265
265
|
: {}) &
|
|
@@ -470,8 +470,9 @@ type NavigationHelpersRoute<
|
|
|
470
470
|
|
|
471
471
|
export type NavigationHelpers<
|
|
472
472
|
ParamList extends ParamListBase,
|
|
473
|
+
State extends NavigationState = NavigationState<ParamList>,
|
|
473
474
|
EventMap extends EventMapBase = {},
|
|
474
|
-
> = NavigationHelpersCommon<ParamList> &
|
|
475
|
+
> = NavigationHelpersCommon<ParamList, State> &
|
|
475
476
|
EventEmitter<EventMap> &
|
|
476
477
|
NavigationHelpersRoute<ParamList, keyof ParamList> &
|
|
477
478
|
PrivateValueStore<[ParamList, unknown, unknown, unknown]>;
|
package/src/useDescriptors.tsx
CHANGED
|
@@ -76,10 +76,11 @@ type Options<
|
|
|
76
76
|
ScreenConfigWithParent<State, ScreenOptions, EventMap>
|
|
77
77
|
>;
|
|
78
78
|
state: State;
|
|
79
|
-
navigation: NavigationHelpers<ParamListBase>;
|
|
79
|
+
navigation: NavigationHelpers<ParamListBase, State>;
|
|
80
80
|
screenOptions: ScreenOptionsOrCallback<ScreenOptions> | undefined;
|
|
81
81
|
screenLayout: ScreenLayout<ScreenOptions> | undefined;
|
|
82
82
|
onAction: (action: NavigationAction) => boolean;
|
|
83
|
+
canGoBack: (source?: string) => boolean;
|
|
83
84
|
getState: () => State;
|
|
84
85
|
setState: (state: State) => void;
|
|
85
86
|
subscribe: (callback: () => void) => () => void;
|
|
@@ -134,6 +135,7 @@ export function useDescriptors<
|
|
|
134
135
|
screenOptions,
|
|
135
136
|
screenLayout,
|
|
136
137
|
onAction,
|
|
138
|
+
canGoBack,
|
|
137
139
|
getState,
|
|
138
140
|
setState,
|
|
139
141
|
subscribe,
|
|
@@ -162,6 +164,7 @@ export function useDescriptors<
|
|
|
162
164
|
() => ({
|
|
163
165
|
navigation,
|
|
164
166
|
onAction,
|
|
167
|
+
canGoBack,
|
|
165
168
|
addListener,
|
|
166
169
|
addKeyedListener,
|
|
167
170
|
onRouteFocus,
|
|
@@ -176,6 +179,7 @@ export function useDescriptors<
|
|
|
176
179
|
[
|
|
177
180
|
navigation,
|
|
178
181
|
onAction,
|
|
182
|
+
canGoBack,
|
|
179
183
|
addListener,
|
|
180
184
|
addKeyedListener,
|
|
181
185
|
onRouteFocus,
|
|
@@ -196,6 +200,7 @@ export function useDescriptors<
|
|
|
196
200
|
ActionHelpers
|
|
197
201
|
>({
|
|
198
202
|
routes: state.routes,
|
|
203
|
+
canGoBack,
|
|
199
204
|
getState,
|
|
200
205
|
navigation,
|
|
201
206
|
setOptions,
|
package/src/useEventEmitter.tsx
CHANGED
|
@@ -21,7 +21,6 @@ import { Group } from './Group';
|
|
|
21
21
|
import { isArrayEqual } from './isArrayEqual';
|
|
22
22
|
import { useNavigationBuilderContext } from './NavigationBuilderContext';
|
|
23
23
|
import { NavigationHelpersContext } from './NavigationHelpersContext';
|
|
24
|
-
import { NavigationMetaContext } from './NavigationMetaContext';
|
|
25
24
|
import { IsScreenContext, NavigationRouteContext } from './NavigationProvider';
|
|
26
25
|
import { NavigationStateContext } from './NavigationStateContext';
|
|
27
26
|
import { PreventRemoveProvider } from './PreventRemoveProvider';
|
|
@@ -459,7 +458,11 @@ export function useNavigationBuilder<
|
|
|
459
458
|
getIsInitial,
|
|
460
459
|
} = React.use(NavigationStateContext);
|
|
461
460
|
|
|
462
|
-
const {
|
|
461
|
+
const {
|
|
462
|
+
onEmitEvent,
|
|
463
|
+
getIsStateEmitted,
|
|
464
|
+
canGoBack: canGoBackParent,
|
|
465
|
+
} = useNavigationBuilderContext();
|
|
463
466
|
|
|
464
467
|
const mountStateRef = React.useRef<'initial' | 'mounted' | 'unmounted'>(
|
|
465
468
|
'initial'
|
|
@@ -1003,6 +1006,31 @@ export function useNavigationBuilder<
|
|
|
1003
1006
|
onUnhandledActionParent?.(action);
|
|
1004
1007
|
});
|
|
1005
1008
|
|
|
1009
|
+
const canGoBack = useLatestCallback((source?: string) => {
|
|
1010
|
+
const state = getState();
|
|
1011
|
+
|
|
1012
|
+
return (
|
|
1013
|
+
router.getStateForAction(
|
|
1014
|
+
state,
|
|
1015
|
+
{ ...CommonActions.goBack(), source },
|
|
1016
|
+
{
|
|
1017
|
+
routeNames: state.routeNames,
|
|
1018
|
+
routeParamList: {},
|
|
1019
|
+
routeGetIdList: {},
|
|
1020
|
+
}
|
|
1021
|
+
) !== null ||
|
|
1022
|
+
canGoBackParent?.(
|
|
1023
|
+
// If the `source` belonged to the current navigator,
|
|
1024
|
+
// rewrite the `source` to the parent screen's key when checking
|
|
1025
|
+
// This mirrors the way actions bubble up to the parent
|
|
1026
|
+
source !== undefined && state.routes.some((r) => r.key === source)
|
|
1027
|
+
? route?.key
|
|
1028
|
+
: source
|
|
1029
|
+
) ||
|
|
1030
|
+
false
|
|
1031
|
+
);
|
|
1032
|
+
});
|
|
1033
|
+
|
|
1006
1034
|
const navigation = useNavigationHelpers<
|
|
1007
1035
|
State,
|
|
1008
1036
|
ActionHelpers,
|
|
@@ -1011,6 +1039,7 @@ export function useNavigationBuilder<
|
|
|
1011
1039
|
>({
|
|
1012
1040
|
onAction,
|
|
1013
1041
|
onUnhandledAction,
|
|
1042
|
+
canGoBack,
|
|
1014
1043
|
getState,
|
|
1015
1044
|
emitter,
|
|
1016
1045
|
router,
|
|
@@ -1040,6 +1069,7 @@ export function useNavigationBuilder<
|
|
|
1040
1069
|
screenOptions,
|
|
1041
1070
|
screenLayout,
|
|
1042
1071
|
onAction,
|
|
1072
|
+
canGoBack,
|
|
1043
1073
|
getState,
|
|
1044
1074
|
setState,
|
|
1045
1075
|
subscribe,
|
|
@@ -1069,24 +1099,22 @@ export function useNavigationBuilder<
|
|
|
1069
1099
|
: children;
|
|
1070
1100
|
|
|
1071
1101
|
return (
|
|
1072
|
-
<
|
|
1073
|
-
<
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
>
|
|
1080
|
-
<
|
|
1081
|
-
<
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
</NavigationHelpersContext.Provider>
|
|
1089
|
-
</NavigationMetaContext.Provider>
|
|
1102
|
+
<NavigationHelpersContext.Provider value={navigation}>
|
|
1103
|
+
<NavigationStateListenerProvider
|
|
1104
|
+
isSynced={!shouldUpdate}
|
|
1105
|
+
state={state}
|
|
1106
|
+
getState={getState}
|
|
1107
|
+
subscribe={subscribe}
|
|
1108
|
+
>
|
|
1109
|
+
<FocusedRouteKeyContext.Provider value={focusedRoute.key}>
|
|
1110
|
+
<PreventRemoveProvider>
|
|
1111
|
+
<IsScreenContext.Provider value={false}>
|
|
1112
|
+
{element}
|
|
1113
|
+
</IsScreenContext.Provider>
|
|
1114
|
+
</PreventRemoveProvider>
|
|
1115
|
+
</FocusedRouteKeyContext.Provider>
|
|
1116
|
+
</NavigationStateListenerProvider>
|
|
1117
|
+
</NavigationHelpersContext.Provider>
|
|
1090
1118
|
);
|
|
1091
1119
|
};
|
|
1092
1120
|
|
|
@@ -19,8 +19,9 @@ type Options<
|
|
|
19
19
|
> = {
|
|
20
20
|
routes: State['routes'];
|
|
21
21
|
getState: () => State;
|
|
22
|
-
navigation: NavigationHelpers<ParamListBase> &
|
|
22
|
+
navigation: NavigationHelpers<ParamListBase, State> &
|
|
23
23
|
Partial<NavigationProp<ParamListBase, string, any, any, any>>;
|
|
24
|
+
canGoBack: (source?: string) => boolean;
|
|
24
25
|
setOptions: (
|
|
25
26
|
cb: (
|
|
26
27
|
options: Record<string, Partial<ScreenOptions> | undefined>
|
|
@@ -68,6 +69,7 @@ export function useNavigationCache<
|
|
|
68
69
|
routes,
|
|
69
70
|
getState,
|
|
70
71
|
navigation,
|
|
72
|
+
canGoBack,
|
|
71
73
|
setOptions,
|
|
72
74
|
router,
|
|
73
75
|
emitter,
|
|
@@ -89,6 +91,7 @@ export function useNavigationCache<
|
|
|
89
91
|
getState,
|
|
90
92
|
parentNavigation,
|
|
91
93
|
navigation,
|
|
94
|
+
canGoBack,
|
|
92
95
|
setOptions,
|
|
93
96
|
router,
|
|
94
97
|
emitter,
|
|
@@ -155,6 +158,7 @@ export function useNavigationCache<
|
|
|
155
158
|
// FIXME: too much work to fix the types for now
|
|
156
159
|
...(emitter.create(route.key) as any),
|
|
157
160
|
dispatch,
|
|
161
|
+
canGoBack: () => canGoBack(route.key),
|
|
158
162
|
getParent: (routeName) => {
|
|
159
163
|
if (routeName === route.name) {
|
|
160
164
|
// If the passed route name is the same as the current route's name,
|
|
@@ -203,6 +207,7 @@ export function useNavigationCache<
|
|
|
203
207
|
routes,
|
|
204
208
|
getState,
|
|
205
209
|
navigation,
|
|
210
|
+
canGoBack,
|
|
206
211
|
router,
|
|
207
212
|
withStackTrace,
|
|
208
213
|
emitter,
|
|
@@ -19,6 +19,7 @@ PrivateValueStore;
|
|
|
19
19
|
type Options<State extends NavigationState, Action extends NavigationAction> = {
|
|
20
20
|
onAction: (action: NavigationAction) => boolean;
|
|
21
21
|
onUnhandledAction: (action: NavigationAction) => void;
|
|
22
|
+
canGoBack: (source?: string) => boolean;
|
|
22
23
|
getState: () => State;
|
|
23
24
|
emitter: NavigationEventEmitter<any>;
|
|
24
25
|
router: Router<State, Action>;
|
|
@@ -36,11 +37,13 @@ export function useNavigationHelpers<
|
|
|
36
37
|
>({
|
|
37
38
|
onAction,
|
|
38
39
|
onUnhandledAction,
|
|
40
|
+
canGoBack,
|
|
39
41
|
getState,
|
|
40
42
|
emitter,
|
|
41
43
|
router,
|
|
42
44
|
}: Options<State, Action>) {
|
|
43
45
|
const parentNavigationHelpers = React.use(NavigationContext);
|
|
46
|
+
|
|
44
47
|
const { withStackTrace } = useNavigationBuilderContext();
|
|
45
48
|
|
|
46
49
|
return React.useMemo(() => {
|
|
@@ -82,27 +85,16 @@ export function useNavigationHelpers<
|
|
|
82
85
|
isFocused: parentNavigationHelpers
|
|
83
86
|
? parentNavigationHelpers.isFocused
|
|
84
87
|
: () => true,
|
|
85
|
-
canGoBack: () =>
|
|
86
|
-
const state = getState();
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
router.getStateForAction(state, CommonActions.goBack() as Action, {
|
|
90
|
-
routeNames: state.routeNames,
|
|
91
|
-
routeParamList: {},
|
|
92
|
-
routeGetIdList: {},
|
|
93
|
-
}) !== null ||
|
|
94
|
-
parentNavigationHelpers?.canGoBack() ||
|
|
95
|
-
false
|
|
96
|
-
);
|
|
97
|
-
},
|
|
88
|
+
canGoBack: () => canGoBack(),
|
|
98
89
|
getState,
|
|
99
|
-
} as NavigationHelpers<ParamListBase, EventMap> & ActionHelpers;
|
|
90
|
+
} as NavigationHelpers<ParamListBase, State, EventMap> & ActionHelpers;
|
|
100
91
|
|
|
101
92
|
return navigationHelpers;
|
|
102
93
|
}, [
|
|
103
|
-
router,
|
|
94
|
+
router.actionCreators,
|
|
104
95
|
parentNavigationHelpers,
|
|
105
96
|
emitter.emit,
|
|
97
|
+
canGoBack,
|
|
106
98
|
getState,
|
|
107
99
|
onAction,
|
|
108
100
|
onUnhandledAction,
|
package/src/useOnAction.tsx
CHANGED
|
@@ -166,19 +166,44 @@ export function useOnAction<State extends NavigationState>({
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
const isSourceInCurrentNavigator =
|
|
170
|
+
action.source !== undefined &&
|
|
171
|
+
state.routes.some((r) => r.key === action.source);
|
|
172
|
+
|
|
169
173
|
if (onActionParent !== undefined) {
|
|
170
174
|
// Bubble action to the parent if the current navigator didn't handle it
|
|
171
|
-
|
|
175
|
+
const parentAction =
|
|
176
|
+
isSourceInCurrentNavigator && key !== undefined
|
|
177
|
+
? {
|
|
178
|
+
...action,
|
|
179
|
+
// If the `source` belonged to the current navigator,
|
|
180
|
+
// rewrite the `source` to the parent screen's key when bubbling
|
|
181
|
+
// This will let parent handle it relative to the child that dispatched the action
|
|
182
|
+
source: key,
|
|
183
|
+
}
|
|
184
|
+
: action;
|
|
185
|
+
|
|
186
|
+
if (onActionParent(parentAction, visitedNavigators)) {
|
|
172
187
|
return true;
|
|
173
188
|
}
|
|
174
189
|
}
|
|
175
190
|
|
|
176
191
|
if (typeof action.target === 'string') {
|
|
177
192
|
// If the action wasn't handled by current navigator or a parent navigator, let children handle it
|
|
193
|
+
const childAction = isSourceInCurrentNavigator
|
|
194
|
+
? {
|
|
195
|
+
...action,
|
|
196
|
+
// If the `source` belonged to the current navigator,
|
|
197
|
+
// remove it when targeting a child navigator
|
|
198
|
+
// So child navigators can handle it based on the focused screen
|
|
199
|
+
source: undefined,
|
|
200
|
+
}
|
|
201
|
+
: action;
|
|
202
|
+
|
|
178
203
|
for (let i = actionListeners.length - 1; i >= 0; i--) {
|
|
179
204
|
const listener = actionListeners[i];
|
|
180
205
|
|
|
181
|
-
if (listener?.(
|
|
206
|
+
if (listener?.(childAction, visitedNavigators)) {
|
|
182
207
|
return true;
|
|
183
208
|
}
|
|
184
209
|
}
|
package/src/utilities.tsx
CHANGED
|
@@ -151,7 +151,7 @@ export type QueryParamInput = string | string[] | null | undefined;
|
|
|
151
151
|
* Supports repeated params with `+` and `*` suffixes as strings.
|
|
152
152
|
* Params must start with `:` at the beginning of a segment (after `/`).
|
|
153
153
|
*/
|
|
154
|
-
|
|
154
|
+
type ExtractParamStrings<Path extends string> =
|
|
155
155
|
Path extends `${infer Segment}/${infer Rest}`
|
|
156
156
|
? ExtractSegmentParam<Segment> & ExtractParamStrings<Rest>
|
|
157
157
|
: ExtractSegmentParam<Path>;
|
|
@@ -159,7 +159,7 @@ export type ExtractParamStrings<Path extends string> =
|
|
|
159
159
|
/**
|
|
160
160
|
* Get the type of params based on the `parse` config and the path pattern.
|
|
161
161
|
*/
|
|
162
|
-
|
|
162
|
+
type ExtractParamsType<Params, Parse> = {
|
|
163
163
|
/**
|
|
164
164
|
* Base param types from path pattern
|
|
165
165
|
* Refine the type based on standard schema, then parse function
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Context with additional metadata to pass to child navigator in a screen.
|
|
7
|
-
* For example, child native stack to know it's inside native tabs.
|
|
8
|
-
* So it doesn't implement features such as `popToTop` that are handled by native tabs.
|
|
9
|
-
*
|
|
10
|
-
* Consumers should not make any assumptions about the shape of the object.
|
|
11
|
-
* It can be different depending on the navigator and may change without notice.
|
|
12
|
-
* This is not intended to be used by application code.
|
|
13
|
-
*/
|
|
14
|
-
export const NavigationMetaContext = /*#__PURE__*/React.createContext(undefined);
|
|
15
|
-
//# sourceMappingURL=NavigationMetaContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","NavigationMetaContext","createContext","undefined"],"sourceRoot":"../../src","sources":["NavigationMetaContext.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,gBAAGD,KAAK,CAACE,aAAa,CACtDC,SACF,CAAC","ignoreList":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Context with additional metadata to pass to child navigator in a screen.
|
|
4
|
-
* For example, child native stack to know it's inside native tabs.
|
|
5
|
-
* So it doesn't implement features such as `popToTop` that are handled by native tabs.
|
|
6
|
-
*
|
|
7
|
-
* Consumers should not make any assumptions about the shape of the object.
|
|
8
|
-
* It can be different depending on the navigator and may change without notice.
|
|
9
|
-
* This is not intended to be used by application code.
|
|
10
|
-
*/
|
|
11
|
-
export declare const NavigationMetaContext: React.Context<object | undefined>;
|
|
12
|
-
//# sourceMappingURL=NavigationMetaContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationMetaContext.d.ts","sourceRoot":"","sources":["../../../src/NavigationMetaContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,mCAEjC,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Context with additional metadata to pass to child navigator in a screen.
|
|
5
|
-
* For example, child native stack to know it's inside native tabs.
|
|
6
|
-
* So it doesn't implement features such as `popToTop` that are handled by native tabs.
|
|
7
|
-
*
|
|
8
|
-
* Consumers should not make any assumptions about the shape of the object.
|
|
9
|
-
* It can be different depending on the navigator and may change without notice.
|
|
10
|
-
* This is not intended to be used by application code.
|
|
11
|
-
*/
|
|
12
|
-
export const NavigationMetaContext = React.createContext<object | undefined>(
|
|
13
|
-
undefined
|
|
14
|
-
);
|