@amazon-devices/react-navigation__routers 7.0.1759135970 → 8.0.9000000000
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/SystemBundles/21657b0b773752468bbe6711df32d141e12a1ad993b6abbe39ad0de460714386.bundle +1279 -0
- package/SystemBundles/21657b0b773752468bbe6711df32d141e12a1ad993b6abbe39ad0de460714386.map +372 -0
- package/SystemModules/amzn__react-navigation__routers-8.modules.txt +9 -0
- package/SystemModules/amzn__react-navigation__routers-8.private.modules.txt +1 -0
- package/SystemModules/keplerscript-system-bundle-config.json +4 -4
- package/kepler-compatibility.json +2 -2
- package/lib/module/BaseRouter.js +6 -4
- package/lib/module/BaseRouter.js.map +1 -1
- package/lib/module/CommonActions.js +48 -7
- package/lib/module/CommonActions.js.map +1 -1
- package/lib/module/DrawerRouter.js +6 -6
- package/lib/module/DrawerRouter.js.map +1 -1
- package/lib/module/StackRouter.js +240 -77
- package/lib/module/StackRouter.js.map +1 -1
- package/lib/module/TabRouter.js +117 -34
- package/lib/module/TabRouter.js.map +1 -1
- package/lib/module/createParamsFromAction.js +16 -0
- package/lib/module/createParamsFromAction.js.map +1 -0
- package/lib/module/createRouteFromAction.js +21 -0
- package/lib/module/createRouteFromAction.js.map +1 -0
- package/lib/module/index.js +8 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/BaseRouter.d.ts +23 -20
- package/lib/typescript/src/BaseRouter.d.ts.map +1 -1
- package/lib/typescript/src/CommonActions.d.ts +66 -18
- package/lib/typescript/src/CommonActions.d.ts.map +1 -1
- package/lib/typescript/src/DrawerRouter.d.ts +18 -6
- package/lib/typescript/src/DrawerRouter.d.ts.map +1 -1
- package/lib/typescript/src/StackRouter.d.ts +67 -11
- package/lib/typescript/src/StackRouter.d.ts.map +1 -1
- package/lib/typescript/src/TabRouter.d.ts +24 -4
- package/lib/typescript/src/TabRouter.d.ts.map +1 -1
- package/lib/typescript/src/createParamsFromAction.d.ts +13 -0
- package/lib/typescript/src/createParamsFromAction.d.ts.map +1 -0
- package/lib/typescript/src/createRouteFromAction.d.ts +17 -0
- package/lib/typescript/src/createRouteFromAction.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +1 -2
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/BaseRouter.tsx +11 -6
- package/src/CommonActions.tsx +147 -56
- package/src/DrawerRouter.tsx +15 -13
- package/src/StackRouter.tsx +417 -203
- package/src/TabRouter.tsx +192 -53
- package/src/createParamsFromAction.tsx +22 -0
- package/src/createRouteFromAction.tsx +24 -0
- package/src/index.tsx +4 -4
- package/src/types.tsx +5 -5
- package/SystemBundles/2c2b2e72cf9d128296ac83ba53082313ac31f6e9fd98b8e87fe0af40e15fbec1.bundle +0 -3515
- package/SystemBundles/2c2b2e72cf9d128296ac83ba53082313ac31f6e9fd98b8e87fe0af40e15fbec1.map +0 -1
- package/SystemModules/amzn__react-navigation__routers-7.modules.txt +0 -21
- package/SystemModules/amzn__react-navigation__routers-7.private.modules.txt +0 -13
- package/THIRD_PARTY_NOTICES.txt +0 -24
- package/lib/commonjs/BaseRouter.js +0 -61
- package/lib/commonjs/BaseRouter.js.map +0 -1
- package/lib/commonjs/CommonActions.js +0 -53
- package/lib/commonjs/CommonActions.js.map +0 -1
- package/lib/commonjs/DrawerRouter.js +0 -154
- package/lib/commonjs/DrawerRouter.js.map +0 -1
- package/lib/commonjs/StackRouter.js +0 -310
- package/lib/commonjs/StackRouter.js.map +0 -1
- package/lib/commonjs/TabRouter.js +0 -253
- package/lib/commonjs/TabRouter.js.map +0 -1
- package/lib/commonjs/index.js +0 -80
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/types.js +0 -6
- package/lib/commonjs/types.js.map +0 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { DefaultRouterOptions, NavigationState, ParamListBase, Router } from './types';
|
|
1
|
+
import type { DefaultRouterOptions, NavigationRoute, NavigationState, ParamListBase, Router } from './types';
|
|
2
2
|
export type StackActionType = {
|
|
3
3
|
type: 'REPLACE';
|
|
4
4
|
payload: {
|
|
5
5
|
name: string;
|
|
6
|
-
key?: string | undefined;
|
|
7
6
|
params?: object;
|
|
8
7
|
};
|
|
9
8
|
source?: string;
|
|
@@ -27,6 +26,15 @@ export type StackActionType = {
|
|
|
27
26
|
type: 'POP_TO_TOP';
|
|
28
27
|
source?: string;
|
|
29
28
|
target?: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'POP_TO';
|
|
31
|
+
payload: {
|
|
32
|
+
name: string;
|
|
33
|
+
params?: object;
|
|
34
|
+
merge?: boolean;
|
|
35
|
+
};
|
|
36
|
+
source?: string;
|
|
37
|
+
target?: string;
|
|
30
38
|
};
|
|
31
39
|
export type StackRouterOptions = DefaultRouterOptions;
|
|
32
40
|
export type StackNavigationState<ParamList extends ParamListBase> = NavigationState<ParamList> & {
|
|
@@ -34,22 +42,30 @@ export type StackNavigationState<ParamList extends ParamListBase> = NavigationSt
|
|
|
34
42
|
* Type of the router, in this case, it's stack.
|
|
35
43
|
*/
|
|
36
44
|
type: 'stack';
|
|
45
|
+
/**
|
|
46
|
+
* List of routes, which are supposed to be preloaded before navigating to.
|
|
47
|
+
*/
|
|
48
|
+
preloadedRoutes: NavigationRoute<ParamList, keyof ParamList>[];
|
|
37
49
|
};
|
|
38
50
|
export type StackActionHelpers<ParamList extends ParamListBase> = {
|
|
39
51
|
/**
|
|
40
52
|
* Replace the current route with a new one.
|
|
41
53
|
*
|
|
42
|
-
* @param name
|
|
54
|
+
* @param name Name of the new route.
|
|
43
55
|
* @param [params] Params object for the new route.
|
|
44
56
|
*/
|
|
45
|
-
replace<RouteName extends keyof ParamList>(...args:
|
|
57
|
+
replace<RouteName extends keyof ParamList>(...args: {
|
|
58
|
+
[Screen in keyof ParamList]: undefined extends ParamList[Screen] ? [screen: Screen] | [screen: Screen, params: ParamList[Screen]] : [screen: Screen, params: ParamList[Screen]];
|
|
59
|
+
}[RouteName]): void;
|
|
46
60
|
/**
|
|
47
61
|
* Push a new screen onto the stack.
|
|
48
62
|
*
|
|
49
|
-
* @param name Name of the route
|
|
63
|
+
* @param name Name of the route to push onto the stack.
|
|
50
64
|
* @param [params] Params object for the route.
|
|
51
65
|
*/
|
|
52
|
-
push<RouteName extends keyof ParamList>(...args:
|
|
66
|
+
push<RouteName extends keyof ParamList>(...args: {
|
|
67
|
+
[Screen in keyof ParamList]: undefined extends ParamList[Screen] ? [screen: Screen] | [screen: Screen, params: ParamList[Screen]] : [screen: Screen, params: ParamList[Screen]];
|
|
68
|
+
}[RouteName]): void;
|
|
53
69
|
/**
|
|
54
70
|
* Pop a screen from the stack.
|
|
55
71
|
*/
|
|
@@ -58,12 +74,52 @@ export type StackActionHelpers<ParamList extends ParamListBase> = {
|
|
|
58
74
|
* Pop to the first route in the stack, dismissing all other screens.
|
|
59
75
|
*/
|
|
60
76
|
popToTop(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Pop any screens to go back to the specified screen.
|
|
79
|
+
* If the specified screen doesn't exist, it'll be added to the stack.
|
|
80
|
+
*
|
|
81
|
+
* @param name Name of the route to navigate to.
|
|
82
|
+
* @param [params] Params object for the route.
|
|
83
|
+
* @param [merge] Whether to merge the params onto the route.
|
|
84
|
+
*/
|
|
85
|
+
popTo<RouteName extends keyof ParamList>(...args: {
|
|
86
|
+
[Screen in keyof ParamList]: undefined extends ParamList[Screen] ? [screen: Screen] | [screen: Screen, params: ParamList[Screen]] | [screen: Screen, params: ParamList[Screen], merge: boolean] : [screen: Screen, params: ParamList[Screen]] | [screen: Screen, params: ParamList[Screen], merge: boolean];
|
|
87
|
+
}[RouteName]): void;
|
|
61
88
|
};
|
|
62
89
|
export declare const StackActions: {
|
|
63
|
-
replace(name: string, params?: object):
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
90
|
+
replace(name: string, params?: object): {
|
|
91
|
+
readonly type: "REPLACE";
|
|
92
|
+
readonly payload: {
|
|
93
|
+
readonly name: string;
|
|
94
|
+
readonly params: object | undefined;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
push(name: string, params?: object): {
|
|
98
|
+
readonly type: "PUSH";
|
|
99
|
+
readonly payload: {
|
|
100
|
+
readonly name: string;
|
|
101
|
+
readonly params: object | undefined;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
pop(count?: number): {
|
|
105
|
+
readonly type: "POP";
|
|
106
|
+
readonly payload: {
|
|
107
|
+
readonly count: number;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
popToTop(): {
|
|
111
|
+
readonly type: "POP_TO_TOP";
|
|
112
|
+
};
|
|
113
|
+
popTo(name: string, params?: object, options?: {
|
|
114
|
+
merge?: boolean;
|
|
115
|
+
}): {
|
|
116
|
+
readonly type: "POP_TO";
|
|
117
|
+
readonly payload: {
|
|
118
|
+
readonly name: string;
|
|
119
|
+
readonly params: object | undefined;
|
|
120
|
+
readonly merge: boolean | undefined;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
67
123
|
};
|
|
68
|
-
export
|
|
124
|
+
export declare function StackRouter(options: StackRouterOptions): Router<StackNavigationState<ParamListBase>, import("./CommonActions").Action | StackActionType>;
|
|
69
125
|
//# sourceMappingURL=StackRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackRouter.d.ts","sourceRoot":"","sources":["../../../src/StackRouter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StackRouter.d.ts","sourceRoot":"","sources":["../../../src/StackRouter.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,aAAa,EAEb,MAAM,EACP,MAAM,SAAS,CAAC;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CAAC,GAC3C,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,GAE3D,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,GAC3C,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC;KACpE,CAAC,SAAS,CAAC,GACX,IAAI,CAAC;CACT,CAAC;AAEF,eAAO,MAAM,YAAY;kBACT,MAAM,WAAW,MAAM;;;;;;;eAM1B,MAAM,WAAW,MAAM;;;;;;;gBAMvB,MAAM;;;;;;;;;gBASL,MAAM,WAAW,MAAM,YAAY;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;;;;;;;;CAgBnE,CAAC;AAEF,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,mGA+hBtD"}
|
|
@@ -8,8 +8,17 @@ export type TabActionType = {
|
|
|
8
8
|
source?: string;
|
|
9
9
|
target?: string;
|
|
10
10
|
};
|
|
11
|
-
export type BackBehavior = 'initialRoute' | '
|
|
11
|
+
export type BackBehavior = 'firstRoute' | 'initialRoute' | 'order' | 'history' | 'fullHistory' | 'none';
|
|
12
12
|
export type TabRouterOptions = DefaultRouterOptions & {
|
|
13
|
+
/**
|
|
14
|
+
* Control how going back should behave
|
|
15
|
+
* - `firstRoute` - return to the first defined route
|
|
16
|
+
* - `initialRoute` - return to the route from `initialRouteName`
|
|
17
|
+
* - `order` - return to the route defined before the focused route
|
|
18
|
+
* - `history` - return to last visited route; if the same route is visited multiple times, the older entries are dropped from the history
|
|
19
|
+
* - `fullHistory` - return to last visited route; doesn't drop duplicate entries unlike `history` - matches behavior of web pages
|
|
20
|
+
* - `none` - do not handle going back
|
|
21
|
+
*/
|
|
13
22
|
backBehavior?: BackBehavior;
|
|
14
23
|
};
|
|
15
24
|
export type TabNavigationState<ParamList extends ParamListBase> = Omit<NavigationState<ParamList>, 'history'> & {
|
|
@@ -23,7 +32,12 @@ export type TabNavigationState<ParamList extends ParamListBase> = Omit<Navigatio
|
|
|
23
32
|
history: {
|
|
24
33
|
type: 'route';
|
|
25
34
|
key: string;
|
|
35
|
+
params?: object | undefined;
|
|
26
36
|
}[];
|
|
37
|
+
/**
|
|
38
|
+
* List of routes' key, which are supposed to be preloaded before navigating to.
|
|
39
|
+
*/
|
|
40
|
+
preloadedRouteKeys: string[];
|
|
27
41
|
};
|
|
28
42
|
export type TabActionHelpers<ParamList extends ParamListBase> = {
|
|
29
43
|
/**
|
|
@@ -32,10 +46,16 @@ export type TabActionHelpers<ParamList extends ParamListBase> = {
|
|
|
32
46
|
* @param name Name of the route for the tab.
|
|
33
47
|
* @param [params] Params object for the route.
|
|
34
48
|
*/
|
|
35
|
-
jumpTo<RouteName extends
|
|
49
|
+
jumpTo<RouteName extends keyof ParamList>(...args: RouteName extends unknown ? undefined extends ParamList[RouteName] ? [screen: RouteName, params?: ParamList[RouteName]] : [screen: RouteName, params: ParamList[RouteName]] : never): void;
|
|
36
50
|
};
|
|
37
51
|
export declare const TabActions: {
|
|
38
|
-
jumpTo(name: string, params?: object):
|
|
52
|
+
jumpTo(name: string, params?: object): {
|
|
53
|
+
readonly type: "JUMP_TO";
|
|
54
|
+
readonly payload: {
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly params: object | undefined;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
39
59
|
};
|
|
40
|
-
export
|
|
60
|
+
export declare function TabRouter({ initialRouteName, backBehavior, }: TabRouterOptions): Router<TabNavigationState<ParamListBase>, import("./CommonActions").Action | TabActionType>;
|
|
41
61
|
//# sourceMappingURL=TabRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabRouter.d.ts","sourceRoot":"","sources":["../../../src/TabRouter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TabRou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AAE,SAAS,CAAC,SAAS,CAAC,CAAC,GAClD,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,GACnD,KAAK,GACR,IAAI,CAAC;CACT,CAAC;AAIF,eAAO,MAAM,UAAU;iBACR,MAAM,WAAW,MAAM;;;;;;;CAMrC,CAAC;AA6GF,wBAAgB,SAAS,CAAC,EACxB,gBAAgB,EAChB,YAA2B,GAC5B,EAAE,gBAAgB,+FA4VlB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ParamListBase } from './types';
|
|
2
|
+
type Options = {
|
|
3
|
+
action: {
|
|
4
|
+
payload: {
|
|
5
|
+
name: string;
|
|
6
|
+
params?: object;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
routeParamList: ParamListBase;
|
|
10
|
+
};
|
|
11
|
+
export declare function createParamsFromAction({ action, routeParamList }: Options): object | undefined;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=createParamsFromAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createParamsFromAction.d.ts","sourceRoot":"","sources":["../../../src/createParamsFromAction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,KAAK,OAAO,GAAG;IACb,MAAM,EAAE;QACN,OAAO,EAAE;YACP,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,CAAC,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;IACF,cAAc,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,OAAO,sBASzE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ParamListBase } from './types';
|
|
2
|
+
type Options = {
|
|
3
|
+
action: {
|
|
4
|
+
payload: {
|
|
5
|
+
name: string;
|
|
6
|
+
params?: object;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
routeParamList: ParamListBase;
|
|
10
|
+
};
|
|
11
|
+
export declare function createRouteFromAction({ action, routeParamList }: Options): {
|
|
12
|
+
key: string;
|
|
13
|
+
name: string;
|
|
14
|
+
params: object | undefined;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=createRouteFromAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRouteFromAction.d.ts","sourceRoot":"","sources":["../../../src/createRouteFromAction.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,KAAK,OAAO,GAAG;IACb,MAAM,EAAE;QACN,OAAO,EAAE;YACP,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,CAAC,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;IACF,cAAc,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,OAAO;;;;EAQxE"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as CommonActions from './CommonActions';
|
|
2
2
|
export { CommonActions };
|
|
3
|
-
export {
|
|
3
|
+
export { BaseRouter } from './BaseRouter';
|
|
4
4
|
export type { DrawerActionHelpers, DrawerActionType, DrawerNavigationState, DrawerRouterOptions, DrawerStatus, } from './DrawerRouter';
|
|
5
|
-
export { DrawerActions,
|
|
5
|
+
export { DrawerActions, DrawerRouter } from './DrawerRouter';
|
|
6
6
|
export type { StackActionHelpers, StackActionType, StackNavigationState, StackRouterOptions, } from './StackRouter';
|
|
7
|
-
export { StackActions,
|
|
7
|
+
export { StackActions, StackRouter } from './StackRouter';
|
|
8
8
|
export type { TabActionHelpers, TabActionType, TabNavigationState, TabRouterOptions, } from './TabRouter';
|
|
9
|
-
export { TabActions,
|
|
9
|
+
export { TabActions, TabRouter } from './TabRouter';
|
|
10
10
|
export * from './types';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7D,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpD,cAAc,SAAS,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as CommonActions from './CommonActions';
|
|
2
2
|
export type CommonNavigationAction = CommonActions.Action;
|
|
3
|
-
type NavigationRoute<ParamList extends ParamListBase, RouteName extends keyof ParamList> = Route<Extract<RouteName, string>, ParamList[RouteName]> & {
|
|
3
|
+
export type NavigationRoute<ParamList extends ParamListBase, RouteName extends keyof ParamList> = Route<Extract<RouteName, string>, ParamList[RouteName]> & {
|
|
4
4
|
state?: NavigationState | PartialState<NavigationState>;
|
|
5
5
|
};
|
|
6
6
|
export type NavigationState<ParamList extends ParamListBase = ParamListBase> = Readonly<{
|
|
@@ -173,5 +173,4 @@ export type Router<State extends NavigationState, Action extends NavigationActio
|
|
|
173
173
|
*/
|
|
174
174
|
actionCreators?: ActionCreators<Action>;
|
|
175
175
|
};
|
|
176
|
-
export {};
|
|
177
176
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,aAAa,MAAM,iBAAiB,CAAC;AAEtD,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC,MAAM,CAAC;AAE1D,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,aAAa,MAAM,iBAAiB,CAAC;AAEtD,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC,MAAM,CAAC;AAE1D,MAAM,MAAM,eAAe,CACzB,SAAS,SAAS,aAAa,EAC/B,SAAS,SAAS,MAAM,SAAS,IAC/B,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,GAAG;IAC5D,KAAK,CAAC,EAAE,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,SAAS,SAAS,aAAa,GAAG,aAAa,IACzE,QAAQ,CAAC;IACP;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC,MAAM,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC;IAC/C;;OAEG;IACH,OAAO,CAAC,E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OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,KAAK,MAAM,GAAG,SAAS,CAAC,GACnE,SAAS,CACZ,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,MAAM,CAChB,KAAK,SAAS,eAAe,EAC7B,MAAM,SAAS,gBAAgB,IAC7B;IACF;;;OAGG;IACH,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEpB;;;;;OAKG;IACH,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,KAAK,CAAC;IAErD;;;;;;OAMG;IACH,kBAAkB,CAChB,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,GAAG,KAAK,EACzC,OAAO,EAAE,mBAAmB,GAC3B,KAAK,CAAC;IAET;;;;;;OAMG;IACH,2BAA2B,CACzB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,mBAAmB,GAAG;QAC7B;;;WAGG;QACH,eAAe,EAAE,MAAM,EAAE,CAAC;KAC3B,GACA,KAAK,CAAC;IAET;;;;;OAKG;IACH,qBAAqB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;IAExD;;;;;;;;OAQG;IACH,iBAAiB,CACf,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,mBAAmB,GAC3B,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAEtC;;;;OAIG;IACH,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAE3D;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@amazon-devices/react-navigation__routers", "description": "Routers to help build custom navigators", "version": "
|
|
1
|
+
{"name": "@amazon-devices/react-navigation__routers", "description": "Routers to help build custom navigators", "version": "8.0.9000000000+7.5.2", "keywords": ["react", "react-native", "react-navigation"], "license": "See license in LICENSE", "repository": {"type": "git", "url": "https://github.com/react-navigation/react-navigation.git", "directory": "packages/routers"}, "bugs": {"url": "https://github.com/react-navigation/react-navigation/issues"}, "homepage": "https://reactnavigation.org/docs/custom-routers/", "main": "./lib/module/index.js", "types": "./lib/typescript/src/index.d.ts", "exports": {".": {"source": "./src/index.tsx", "types": "./lib/typescript/src/index.d.ts", "default": "./lib/module/index.js"}, "./package.json": "./package.json"}, "files": ["src", "lib", "!**/__tests__", "kepler-compatibility.json", "SystemModules", "SystemBundles", "kepler-transformed-package-info.json"], "sideEffects": false, "kepler": {"temporary-alias-for-package": {"name": "@react-navigation__routers", "version": "7.1.2"}}, "publishConfig": {"access": "public"}, "scripts": {"clean": "del lib"}, "dependencies": {"nanoid": "^3.3.11"}, "devDependencies": {"@jest/globals": "^30.0.0", "del-cli": "^6.0.0", "react-native-builder-bob": "^0.40.12", "typescript": "^5.8.3"}, "react-native-builder-bob": {"source": "src", "output": "lib", "targets": [["module", {"esm": true}], ["typescript", {"project": "tsconfig.build.json"}]]}}
|
package/src/BaseRouter.tsx
CHANGED
|
@@ -10,13 +10,14 @@ import type {
|
|
|
10
10
|
* Base router object that can be used when writing custom routers.
|
|
11
11
|
* This provides few helper methods to handle common actions such as `RESET`.
|
|
12
12
|
*/
|
|
13
|
-
const BaseRouter = {
|
|
13
|
+
export const BaseRouter = {
|
|
14
14
|
getStateForAction<State extends NavigationState>(
|
|
15
15
|
state: State,
|
|
16
16
|
action: CommonNavigationAction
|
|
17
17
|
): State | PartialState<State> | null {
|
|
18
18
|
switch (action.type) {
|
|
19
|
-
case 'SET_PARAMS':
|
|
19
|
+
case 'SET_PARAMS':
|
|
20
|
+
case 'REPLACE_PARAMS': {
|
|
20
21
|
const index = action.source
|
|
21
22
|
? state.routes.findIndex((r) => r.key === action.source)
|
|
22
23
|
: state.index;
|
|
@@ -29,7 +30,13 @@ const BaseRouter = {
|
|
|
29
30
|
...state,
|
|
30
31
|
routes: state.routes.map((r, i) =>
|
|
31
32
|
i === index
|
|
32
|
-
? {
|
|
33
|
+
? {
|
|
34
|
+
...r,
|
|
35
|
+
params:
|
|
36
|
+
action.type === 'REPLACE_PARAMS'
|
|
37
|
+
? action.payload.params
|
|
38
|
+
: { ...r.params, ...action.payload.params },
|
|
39
|
+
}
|
|
33
40
|
: r
|
|
34
41
|
),
|
|
35
42
|
};
|
|
@@ -74,8 +81,6 @@ const BaseRouter = {
|
|
|
74
81
|
},
|
|
75
82
|
|
|
76
83
|
shouldActionChangeFocus(action: CommonNavigationAction) {
|
|
77
|
-
return action.type === 'NAVIGATE';
|
|
84
|
+
return action.type === 'NAVIGATE' || action.type === 'NAVIGATE_DEPRECATED';
|
|
78
85
|
},
|
|
79
86
|
};
|
|
80
|
-
|
|
81
|
-
export default BaseRouter;
|
package/src/CommonActions.tsx
CHANGED
|
@@ -7,72 +7,122 @@ type ResetState =
|
|
|
7
7
|
routes: Omit<Route<string>, 'key'>[];
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
+
type GoBackAction = {
|
|
11
|
+
type: 'GO_BACK';
|
|
12
|
+
source?: string;
|
|
13
|
+
target?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type NavigateAction = {
|
|
17
|
+
type: 'NAVIGATE';
|
|
18
|
+
payload: {
|
|
19
|
+
name: string;
|
|
20
|
+
params?: object;
|
|
21
|
+
path?: string;
|
|
22
|
+
merge?: boolean;
|
|
23
|
+
pop?: boolean;
|
|
24
|
+
};
|
|
25
|
+
source?: string;
|
|
26
|
+
target?: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type NavigateDeprecatedAction = {
|
|
30
|
+
type: 'NAVIGATE_DEPRECATED';
|
|
31
|
+
payload: {
|
|
32
|
+
name: string;
|
|
33
|
+
params?: object;
|
|
34
|
+
merge?: boolean;
|
|
35
|
+
};
|
|
36
|
+
source?: string;
|
|
37
|
+
target?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type ResetAction = {
|
|
41
|
+
type: 'RESET';
|
|
42
|
+
payload: ResetState | undefined;
|
|
43
|
+
source?: string;
|
|
44
|
+
target?: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type SetParamsAction = {
|
|
48
|
+
type: 'SET_PARAMS';
|
|
49
|
+
payload: { params?: object };
|
|
50
|
+
source?: string;
|
|
51
|
+
target?: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type ReplaceParamsAction = {
|
|
55
|
+
type: 'REPLACE_PARAMS';
|
|
56
|
+
payload: { params?: object };
|
|
57
|
+
source?: string;
|
|
58
|
+
target?: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type PreloadAction = {
|
|
62
|
+
type: 'PRELOAD';
|
|
63
|
+
payload: {
|
|
64
|
+
name: string;
|
|
65
|
+
params?: object;
|
|
66
|
+
};
|
|
67
|
+
source?: string;
|
|
68
|
+
target?: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
10
71
|
export type Action =
|
|
11
|
-
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
|
17
|
-
|
|
18
|
-
payload:
|
|
19
|
-
| {
|
|
20
|
-
key: string;
|
|
21
|
-
name?: undefined;
|
|
22
|
-
params?: object;
|
|
23
|
-
path?: string;
|
|
24
|
-
merge?: boolean;
|
|
25
|
-
}
|
|
26
|
-
| {
|
|
27
|
-
name: string;
|
|
28
|
-
key?: string;
|
|
29
|
-
params?: object;
|
|
30
|
-
path?: string;
|
|
31
|
-
merge?: boolean;
|
|
32
|
-
};
|
|
33
|
-
source?: string;
|
|
34
|
-
target?: string;
|
|
35
|
-
}
|
|
36
|
-
| {
|
|
37
|
-
type: 'RESET';
|
|
38
|
-
payload: ResetState | undefined;
|
|
39
|
-
source?: string;
|
|
40
|
-
target?: string;
|
|
41
|
-
}
|
|
42
|
-
| {
|
|
43
|
-
type: 'SET_PARAMS';
|
|
44
|
-
payload: { params?: object };
|
|
45
|
-
source?: string;
|
|
46
|
-
target?: string;
|
|
47
|
-
};
|
|
72
|
+
| GoBackAction
|
|
73
|
+
| NavigateAction
|
|
74
|
+
| NavigateDeprecatedAction
|
|
75
|
+
| ResetAction
|
|
76
|
+
| SetParamsAction
|
|
77
|
+
| ReplaceParamsAction
|
|
78
|
+
| PreloadAction;
|
|
48
79
|
|
|
49
80
|
export function goBack(): Action {
|
|
50
81
|
return { type: 'GO_BACK' };
|
|
51
82
|
}
|
|
52
83
|
|
|
53
84
|
export function navigate(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
path?: string;
|
|
61
|
-
merge?: boolean;
|
|
62
|
-
}
|
|
85
|
+
name: string,
|
|
86
|
+
params?: object,
|
|
87
|
+
options?: {
|
|
88
|
+
merge?: boolean;
|
|
89
|
+
pop?: boolean;
|
|
90
|
+
}
|
|
63
91
|
): Action;
|
|
64
|
-
|
|
65
|
-
export function navigate(
|
|
66
|
-
|
|
92
|
+
|
|
93
|
+
export function navigate(options: {
|
|
94
|
+
name: string;
|
|
95
|
+
params?: object;
|
|
96
|
+
path?: string;
|
|
97
|
+
merge?: boolean;
|
|
98
|
+
pop?: boolean;
|
|
99
|
+
}): Action;
|
|
100
|
+
|
|
67
101
|
export function navigate(...args: any): Action {
|
|
68
102
|
if (typeof args[0] === 'string') {
|
|
69
|
-
|
|
103
|
+
const [name, params, options] = args;
|
|
104
|
+
|
|
105
|
+
if (typeof options === 'boolean') {
|
|
106
|
+
console.warn(
|
|
107
|
+
`Passing a boolean as the third argument to 'navigate' is deprecated. Pass '{ merge: true }' instead.`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
type: 'NAVIGATE',
|
|
113
|
+
payload: {
|
|
114
|
+
name,
|
|
115
|
+
params,
|
|
116
|
+
merge: typeof options === 'boolean' ? options : options?.merge,
|
|
117
|
+
pop: options?.pop,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
70
120
|
} else {
|
|
71
121
|
const payload = args[0] || {};
|
|
72
122
|
|
|
73
|
-
if (!
|
|
123
|
+
if (!('name' in payload)) {
|
|
74
124
|
throw new Error(
|
|
75
|
-
'You need to specify name
|
|
125
|
+
'You need to specify a name when calling navigate with an object as the argument. See https://reactnavigation.org/docs/navigation-actions#navigate for usage.'
|
|
76
126
|
);
|
|
77
127
|
}
|
|
78
128
|
|
|
@@ -80,10 +130,51 @@ export function navigate(...args: any): Action {
|
|
|
80
130
|
}
|
|
81
131
|
}
|
|
82
132
|
|
|
83
|
-
export function
|
|
84
|
-
|
|
133
|
+
export function navigateDeprecated(
|
|
134
|
+
...args:
|
|
135
|
+
| [name: string]
|
|
136
|
+
| [name: string, params: object | undefined]
|
|
137
|
+
| [options: { name: string; params?: object }]
|
|
138
|
+
): Action {
|
|
139
|
+
if (typeof args[0] === 'string') {
|
|
140
|
+
return {
|
|
141
|
+
type: 'NAVIGATE_DEPRECATED',
|
|
142
|
+
payload: { name: args[0], params: args[1] },
|
|
143
|
+
};
|
|
144
|
+
} else {
|
|
145
|
+
const payload = args[0] || {};
|
|
146
|
+
|
|
147
|
+
if (!('name' in payload)) {
|
|
148
|
+
throw new Error(
|
|
149
|
+
'You need to specify a name when calling navigateDeprecated with an object as the argument. See https://reactnavigation.org/docs/navigation-actions#navigatelegacy for usage.'
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return { type: 'NAVIGATE_DEPRECATED', payload };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function reset(state: ResetState | undefined) {
|
|
158
|
+
return { type: 'RESET', payload: state } as const satisfies ResetAction;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function setParams(params: object) {
|
|
162
|
+
return {
|
|
163
|
+
type: 'SET_PARAMS',
|
|
164
|
+
payload: { params },
|
|
165
|
+
} as const satisfies SetParamsAction;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function replaceParams(params: object) {
|
|
169
|
+
return {
|
|
170
|
+
type: 'REPLACE_PARAMS',
|
|
171
|
+
payload: { params },
|
|
172
|
+
} as const satisfies ReplaceParamsAction;
|
|
85
173
|
}
|
|
86
174
|
|
|
87
|
-
export function
|
|
88
|
-
return {
|
|
175
|
+
export function preload(name: string, params?: object) {
|
|
176
|
+
return {
|
|
177
|
+
type: 'PRELOAD',
|
|
178
|
+
payload: { name, params },
|
|
179
|
+
} as const satisfies PreloadAction;
|
|
89
180
|
}
|
package/src/DrawerRouter.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { nanoid } from 'nanoid/non-secure';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
TabActionHelpers,
|
|
3
|
+
import {
|
|
4
|
+
type TabActionHelpers,
|
|
5
5
|
TabActions,
|
|
6
|
-
TabActionType,
|
|
7
|
-
TabNavigationState,
|
|
8
|
-
|
|
6
|
+
type TabActionType,
|
|
7
|
+
type TabNavigationState,
|
|
8
|
+
TabRouter,
|
|
9
|
+
type TabRouterOptions,
|
|
9
10
|
} from './TabRouter';
|
|
10
11
|
import type {
|
|
11
12
|
CommonNavigationAction,
|
|
@@ -68,18 +69,18 @@ export type DrawerActionHelpers<ParamList extends ParamListBase> =
|
|
|
68
69
|
|
|
69
70
|
export const DrawerActions = {
|
|
70
71
|
...TabActions,
|
|
71
|
-
openDrawer()
|
|
72
|
-
return { type: 'OPEN_DRAWER' };
|
|
72
|
+
openDrawer() {
|
|
73
|
+
return { type: 'OPEN_DRAWER' } as const satisfies DrawerActionType;
|
|
73
74
|
},
|
|
74
|
-
closeDrawer()
|
|
75
|
-
return { type: 'CLOSE_DRAWER' };
|
|
75
|
+
closeDrawer() {
|
|
76
|
+
return { type: 'CLOSE_DRAWER' } as const satisfies DrawerActionType;
|
|
76
77
|
},
|
|
77
|
-
toggleDrawer()
|
|
78
|
-
return { type: 'TOGGLE_DRAWER' };
|
|
78
|
+
toggleDrawer() {
|
|
79
|
+
return { type: 'TOGGLE_DRAWER' } as const satisfies DrawerActionType;
|
|
79
80
|
},
|
|
80
81
|
};
|
|
81
82
|
|
|
82
|
-
export
|
|
83
|
+
export function DrawerRouter({
|
|
83
84
|
defaultStatus = 'closed',
|
|
84
85
|
...rest
|
|
85
86
|
}: DrawerRouterOptions): Router<
|
|
@@ -220,7 +221,8 @@ export default function DrawerRouter({
|
|
|
220
221
|
return addDrawerToHistory(state);
|
|
221
222
|
|
|
222
223
|
case 'JUMP_TO':
|
|
223
|
-
case 'NAVIGATE':
|
|
224
|
+
case 'NAVIGATE':
|
|
225
|
+
case 'NAVIGATE_DEPRECATED': {
|
|
224
226
|
const result = router.getStateForAction(state, action, options);
|
|
225
227
|
|
|
226
228
|
if (result != null && result.index !== state.index) {
|