@amazon-devices/react-navigation__routers 8.0.9000000001 → 8.0.9000000002
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/kepler-compatibility.json +2 -1
- package/lib/module/index.js +0 -9
- package/package.json +1 -1
- package/src/index.tsx +0 -27
- package/lib/module/BaseRouter.js +0 -57
- package/lib/module/CommonActions.js +0 -85
- package/lib/module/DrawerRouter.js +0 -145
- package/lib/module/StackRouter.js +0 -483
- package/lib/module/TabRouter.js +0 -328
- package/lib/module/createParamsFromAction.js +0 -16
- package/lib/module/createRouteFromAction.js +0 -21
- package/lib/module/types.js +0 -4
- package/src/BaseRouter.tsx +0 -86
- package/src/CommonActions.tsx +0 -180
- package/src/DrawerRouter.tsx +0 -249
- package/src/StackRouter.tsx +0 -733
- package/src/TabRouter.tsx +0 -546
- package/src/createParamsFromAction.tsx +0 -22
- package/src/createRouteFromAction.tsx +0 -24
- package/src/types.tsx +0 -228
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"versions": {
|
|
3
3
|
"8.0.0": "/com.amazon.kepler.navigation__routers_8@INavigation__Routers_0",
|
|
4
4
|
"8.0.9000000000": "/com.amazon.kepler.navigation__routers_8@INavigation__Routers_0",
|
|
5
|
-
"8.0.9000000001": "/com.amazon.kepler.navigation__routers_8@INavigation__Routers_0"
|
|
5
|
+
"8.0.9000000001": "/com.amazon.kepler.navigation__routers_8@INavigation__Routers_0",
|
|
6
|
+
"8.0.9000000002": "/com.amazon.kepler.navigation__routers_8@INavigation__Routers_0"
|
|
6
7
|
}
|
|
7
8
|
}
|
package/lib/module/index.js
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
import * as CommonActions from "./CommonActions.js";
|
|
4
|
-
export { CommonActions };
|
|
5
|
-
export { BaseRouter } from "./BaseRouter.js";
|
|
6
|
-
export { DrawerActions, DrawerRouter } from "./DrawerRouter.js";
|
|
7
|
-
export { StackActions, StackRouter } from "./StackRouter.js";
|
|
8
|
-
export { TabActions, TabRouter } from "./TabRouter.js";
|
|
9
|
-
export * from "./types.js";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@amazon-devices/react-navigation__routers", "description": "Routers to help build custom navigators", "
|
|
1
|
+
{"name": "@amazon-devices/react-navigation__routers", "version": "8.0.9000000002+7.5.2", "description": "Routers to help build custom navigators", "keywords": ["react", "react-native", "react-navigation"], "homepage": "https://reactnavigation.org/docs/custom-routers/", "bugs": {"url": "https://github.com/react-navigation/react-navigation/issues"}, "license": "See license in LICENSE", "files": ["src", "lib", "!**/__tests__", "kepler-compatibility.json", "SystemModules", "SystemBundles", "oss-attribution", "kepler-transformed-package-info.json"], "exports": {".": {"source": "./src/index.tsx", "types": "./lib/typescript/src/index.d.ts", "default": "./lib/module/index.js"}, "./package.json": "./package.json"}, "main": "./lib/module/index.js", "dependencies": {}, "types": "./lib/typescript/src/index.d.ts"}
|
package/src/index.tsx
CHANGED
|
@@ -1,28 +1 @@
|
|
|
1
|
-
import * as CommonActions from './CommonActions';
|
|
2
1
|
|
|
3
|
-
export { CommonActions };
|
|
4
|
-
|
|
5
|
-
export { BaseRouter } from './BaseRouter';
|
|
6
|
-
export type {
|
|
7
|
-
DrawerActionHelpers,
|
|
8
|
-
DrawerActionType,
|
|
9
|
-
DrawerNavigationState,
|
|
10
|
-
DrawerRouterOptions,
|
|
11
|
-
DrawerStatus,
|
|
12
|
-
} from './DrawerRouter';
|
|
13
|
-
export { DrawerActions, DrawerRouter } from './DrawerRouter';
|
|
14
|
-
export type {
|
|
15
|
-
StackActionHelpers,
|
|
16
|
-
StackActionType,
|
|
17
|
-
StackNavigationState,
|
|
18
|
-
StackRouterOptions,
|
|
19
|
-
} from './StackRouter';
|
|
20
|
-
export { StackActions, StackRouter } from './StackRouter';
|
|
21
|
-
export type {
|
|
22
|
-
TabActionHelpers,
|
|
23
|
-
TabActionType,
|
|
24
|
-
TabNavigationState,
|
|
25
|
-
TabRouterOptions,
|
|
26
|
-
} from './TabRouter';
|
|
27
|
-
export { TabActions, TabRouter } from './TabRouter';
|
|
28
|
-
export * from './types';
|
package/lib/module/BaseRouter.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { nanoid } from 'nanoid/non-secure';
|
|
4
|
-
/**
|
|
5
|
-
* Base router object that can be used when writing custom routers.
|
|
6
|
-
* This provides few helper methods to handle common actions such as `RESET`.
|
|
7
|
-
*/
|
|
8
|
-
export const BaseRouter = {
|
|
9
|
-
getStateForAction(state, action) {
|
|
10
|
-
switch (action.type) {
|
|
11
|
-
case 'SET_PARAMS':
|
|
12
|
-
case 'REPLACE_PARAMS':
|
|
13
|
-
{
|
|
14
|
-
const index = action.source ? state.routes.findIndex(r => r.key === action.source) : state.index;
|
|
15
|
-
if (index === -1) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
...state,
|
|
20
|
-
routes: state.routes.map((r, i) => i === index ? {
|
|
21
|
-
...r,
|
|
22
|
-
params: action.type === 'REPLACE_PARAMS' ? action.payload.params : {
|
|
23
|
-
...r.params,
|
|
24
|
-
...action.payload.params
|
|
25
|
-
}
|
|
26
|
-
} : r)
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
case 'RESET':
|
|
30
|
-
{
|
|
31
|
-
const nextState = action.payload;
|
|
32
|
-
if (nextState.routes.length === 0 || nextState.routes.some(route => !state.routeNames.includes(route.name))) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
if (nextState.stale === false) {
|
|
36
|
-
if (state.routeNames.length !== nextState.routeNames.length || nextState.routeNames.some(name => !state.routeNames.includes(name))) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
...nextState,
|
|
41
|
-
routes: nextState.routes.map(route => route.key ? route : {
|
|
42
|
-
...route,
|
|
43
|
-
key: `${route.name}-${nanoid()}`
|
|
44
|
-
})
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return nextState;
|
|
48
|
-
}
|
|
49
|
-
default:
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
shouldActionChangeFocus(action) {
|
|
54
|
-
return action.type === 'NAVIGATE' || action.type === 'NAVIGATE_DEPRECATED';
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
//# sourceMappingURL=BaseRouter.js.map
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
export function goBack() {
|
|
4
|
-
return {
|
|
5
|
-
type: 'GO_BACK'
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
export function navigate(...args) {
|
|
9
|
-
if (typeof args[0] === 'string') {
|
|
10
|
-
const [name, params, options] = args;
|
|
11
|
-
if (typeof options === 'boolean') {
|
|
12
|
-
console.warn(`Passing a boolean as the third argument to 'navigate' is deprecated. Pass '{ merge: true }' instead.`);
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
type: 'NAVIGATE',
|
|
16
|
-
payload: {
|
|
17
|
-
name,
|
|
18
|
-
params,
|
|
19
|
-
merge: typeof options === 'boolean' ? options : options?.merge,
|
|
20
|
-
pop: options?.pop
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
} else {
|
|
24
|
-
const payload = args[0] || {};
|
|
25
|
-
if (!('name' in payload)) {
|
|
26
|
-
throw new Error('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.');
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
type: 'NAVIGATE',
|
|
30
|
-
payload
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export function navigateDeprecated(...args) {
|
|
35
|
-
if (typeof args[0] === 'string') {
|
|
36
|
-
return {
|
|
37
|
-
type: 'NAVIGATE_DEPRECATED',
|
|
38
|
-
payload: {
|
|
39
|
-
name: args[0],
|
|
40
|
-
params: args[1]
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
} else {
|
|
44
|
-
const payload = args[0] || {};
|
|
45
|
-
if (!('name' in payload)) {
|
|
46
|
-
throw new Error('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.');
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
type: 'NAVIGATE_DEPRECATED',
|
|
50
|
-
payload
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
export function reset(state) {
|
|
55
|
-
return {
|
|
56
|
-
type: 'RESET',
|
|
57
|
-
payload: state
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
export function setParams(params) {
|
|
61
|
-
return {
|
|
62
|
-
type: 'SET_PARAMS',
|
|
63
|
-
payload: {
|
|
64
|
-
params
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
export function replaceParams(params) {
|
|
69
|
-
return {
|
|
70
|
-
type: 'REPLACE_PARAMS',
|
|
71
|
-
payload: {
|
|
72
|
-
params
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
export function preload(name, params) {
|
|
77
|
-
return {
|
|
78
|
-
type: 'PRELOAD',
|
|
79
|
-
payload: {
|
|
80
|
-
name,
|
|
81
|
-
params
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=CommonActions.js.map
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { nanoid } from 'nanoid/non-secure';
|
|
4
|
-
import { TabActions, TabRouter } from "./TabRouter.js";
|
|
5
|
-
export const DrawerActions = {
|
|
6
|
-
...TabActions,
|
|
7
|
-
openDrawer() {
|
|
8
|
-
return {
|
|
9
|
-
type: 'OPEN_DRAWER'
|
|
10
|
-
};
|
|
11
|
-
},
|
|
12
|
-
closeDrawer() {
|
|
13
|
-
return {
|
|
14
|
-
type: 'CLOSE_DRAWER'
|
|
15
|
-
};
|
|
16
|
-
},
|
|
17
|
-
toggleDrawer() {
|
|
18
|
-
return {
|
|
19
|
-
type: 'TOGGLE_DRAWER'
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
export function DrawerRouter({
|
|
24
|
-
defaultStatus = 'closed',
|
|
25
|
-
...rest
|
|
26
|
-
}) {
|
|
27
|
-
const router = TabRouter(rest);
|
|
28
|
-
const isDrawerInHistory = state => Boolean(state.history?.some(it => it.type === 'drawer'));
|
|
29
|
-
const addDrawerToHistory = state => {
|
|
30
|
-
if (isDrawerInHistory(state)) {
|
|
31
|
-
return state;
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
...state,
|
|
35
|
-
history: [...state.history, {
|
|
36
|
-
type: 'drawer',
|
|
37
|
-
status: defaultStatus === 'open' ? 'closed' : 'open'
|
|
38
|
-
}]
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
const removeDrawerFromHistory = state => {
|
|
42
|
-
if (!isDrawerInHistory(state)) {
|
|
43
|
-
return state;
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
...state,
|
|
47
|
-
history: state.history.filter(it => it.type !== 'drawer')
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
const openDrawer = state => {
|
|
51
|
-
if (defaultStatus === 'open') {
|
|
52
|
-
return removeDrawerFromHistory(state);
|
|
53
|
-
}
|
|
54
|
-
return addDrawerToHistory(state);
|
|
55
|
-
};
|
|
56
|
-
const closeDrawer = state => {
|
|
57
|
-
if (defaultStatus === 'open') {
|
|
58
|
-
return addDrawerToHistory(state);
|
|
59
|
-
}
|
|
60
|
-
return removeDrawerFromHistory(state);
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
...router,
|
|
64
|
-
type: 'drawer',
|
|
65
|
-
getInitialState({
|
|
66
|
-
routeNames,
|
|
67
|
-
routeParamList,
|
|
68
|
-
routeGetIdList
|
|
69
|
-
}) {
|
|
70
|
-
const state = router.getInitialState({
|
|
71
|
-
routeNames,
|
|
72
|
-
routeParamList,
|
|
73
|
-
routeGetIdList
|
|
74
|
-
});
|
|
75
|
-
return {
|
|
76
|
-
...state,
|
|
77
|
-
default: defaultStatus,
|
|
78
|
-
stale: false,
|
|
79
|
-
type: 'drawer',
|
|
80
|
-
key: `drawer-${nanoid()}`
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
getRehydratedState(partialState, {
|
|
84
|
-
routeNames,
|
|
85
|
-
routeParamList,
|
|
86
|
-
routeGetIdList
|
|
87
|
-
}) {
|
|
88
|
-
if (partialState.stale === false) {
|
|
89
|
-
return partialState;
|
|
90
|
-
}
|
|
91
|
-
let state = router.getRehydratedState(partialState, {
|
|
92
|
-
routeNames,
|
|
93
|
-
routeParamList,
|
|
94
|
-
routeGetIdList
|
|
95
|
-
});
|
|
96
|
-
if (isDrawerInHistory(partialState)) {
|
|
97
|
-
// Re-sync the drawer entry in history to correct it if it was wrong
|
|
98
|
-
state = removeDrawerFromHistory(state);
|
|
99
|
-
state = addDrawerToHistory(state);
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
...state,
|
|
103
|
-
default: defaultStatus,
|
|
104
|
-
type: 'drawer',
|
|
105
|
-
key: `drawer-${nanoid()}`
|
|
106
|
-
};
|
|
107
|
-
},
|
|
108
|
-
getStateForRouteFocus(state, key) {
|
|
109
|
-
const result = router.getStateForRouteFocus(state, key);
|
|
110
|
-
return closeDrawer(result);
|
|
111
|
-
},
|
|
112
|
-
getStateForAction(state, action, options) {
|
|
113
|
-
switch (action.type) {
|
|
114
|
-
case 'OPEN_DRAWER':
|
|
115
|
-
return openDrawer(state);
|
|
116
|
-
case 'CLOSE_DRAWER':
|
|
117
|
-
return closeDrawer(state);
|
|
118
|
-
case 'TOGGLE_DRAWER':
|
|
119
|
-
if (isDrawerInHistory(state)) {
|
|
120
|
-
return removeDrawerFromHistory(state);
|
|
121
|
-
}
|
|
122
|
-
return addDrawerToHistory(state);
|
|
123
|
-
case 'JUMP_TO':
|
|
124
|
-
case 'NAVIGATE':
|
|
125
|
-
case 'NAVIGATE_DEPRECATED':
|
|
126
|
-
{
|
|
127
|
-
const result = router.getStateForAction(state, action, options);
|
|
128
|
-
if (result != null && result.index !== state.index) {
|
|
129
|
-
return closeDrawer(result);
|
|
130
|
-
}
|
|
131
|
-
return result;
|
|
132
|
-
}
|
|
133
|
-
case 'GO_BACK':
|
|
134
|
-
if (isDrawerInHistory(state)) {
|
|
135
|
-
return removeDrawerFromHistory(state);
|
|
136
|
-
}
|
|
137
|
-
return router.getStateForAction(state, action, options);
|
|
138
|
-
default:
|
|
139
|
-
return router.getStateForAction(state, action, options);
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
actionCreators: DrawerActions
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
//# sourceMappingURL=DrawerRouter.js.map
|