@amazon-devices/react-navigation__routers 7.0.1759135970 → 8.0.9000000000-rn-83
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/b6cc62e27d70be8722b0e7aef9fd04a870d49127e6c724fe934d1f8ca4ff8177.bundle +1298 -0
- package/SystemBundles/b6cc62e27d70be8722b0e7aef9fd04a870d49127e6c724fe934d1f8ca4ff8177.map +373 -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 +261 -80
- 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 +73 -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/oss-attribution/attribution.txt +0 -0
- package/oss-attribution/licenseInfos.json +1 -0
- package/package.json +80 -1
- package/src/BaseRouter.tsx +11 -6
- package/src/CommonActions.tsx +147 -56
- package/src/DrawerRouter.tsx +15 -13
- package/src/StackRouter.tsx +437 -199
- 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
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) {
|