@react-navigation/routers 6.1.5 → 7.0.0-alpha.0

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.
Files changed (46) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/BaseRouter.js +11 -18
  3. package/lib/commonjs/BaseRouter.js.map +1 -1
  4. package/lib/commonjs/CommonActions.js +23 -8
  5. package/lib/commonjs/CommonActions.js.map +1 -1
  6. package/lib/commonjs/DrawerRouter.js +13 -45
  7. package/lib/commonjs/DrawerRouter.js.map +1 -1
  8. package/lib/commonjs/StackRouter.js +155 -97
  9. package/lib/commonjs/StackRouter.js.map +1 -1
  10. package/lib/commonjs/TabRouter.js +28 -69
  11. package/lib/commonjs/TabRouter.js.map +1 -1
  12. package/lib/commonjs/index.js +0 -11
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/commonjs/types.js.map +1 -1
  15. package/lib/module/BaseRouter.js +11 -17
  16. package/lib/module/BaseRouter.js.map +1 -1
  17. package/lib/module/CommonActions.js +22 -4
  18. package/lib/module/CommonActions.js.map +1 -1
  19. package/lib/module/DrawerRouter.js +13 -39
  20. package/lib/module/DrawerRouter.js.map +1 -1
  21. package/lib/module/StackRouter.js +155 -92
  22. package/lib/module/StackRouter.js.map +1 -1
  23. package/lib/module/TabRouter.js +28 -65
  24. package/lib/module/TabRouter.js.map +1 -1
  25. package/lib/module/index.js.map +1 -1
  26. package/lib/module/types.js.map +1 -1
  27. package/lib/typescript/src/BaseRouter.d.ts +1 -0
  28. package/lib/typescript/src/BaseRouter.d.ts.map +1 -0
  29. package/lib/typescript/src/CommonActions.d.ts +14 -13
  30. package/lib/typescript/src/CommonActions.d.ts.map +1 -0
  31. package/lib/typescript/src/DrawerRouter.d.ts +6 -5
  32. package/lib/typescript/src/DrawerRouter.d.ts.map +1 -0
  33. package/lib/typescript/src/StackRouter.d.ts +24 -5
  34. package/lib/typescript/src/StackRouter.d.ts.map +1 -0
  35. package/lib/typescript/src/TabRouter.d.ts +6 -5
  36. package/lib/typescript/src/TabRouter.d.ts.map +1 -0
  37. package/lib/typescript/src/index.d.ts +1 -0
  38. package/lib/typescript/src/index.d.ts.map +1 -0
  39. package/lib/typescript/src/types.d.ts +15 -14
  40. package/lib/typescript/src/types.d.ts.map +1 -0
  41. package/package.json +5 -5
  42. package/src/BaseRouter.tsx +1 -1
  43. package/src/CommonActions.tsx +48 -28
  44. package/src/DrawerRouter.tsx +2 -1
  45. package/src/StackRouter.tsx +270 -147
  46. package/src/TabRouter.tsx +10 -17
@@ -1,5 +1,5 @@
1
1
  import type { DefaultRouterOptions, NavigationState, ParamListBase, Router } from './types';
2
- export declare type TabActionType = {
2
+ export type TabActionType = {
3
3
  type: 'JUMP_TO';
4
4
  payload: {
5
5
  name: string;
@@ -8,11 +8,11 @@ export declare type TabActionType = {
8
8
  source?: string;
9
9
  target?: string;
10
10
  };
11
- export declare type BackBehavior = 'initialRoute' | 'firstRoute' | 'history' | 'order' | 'none';
12
- export declare type TabRouterOptions = DefaultRouterOptions & {
11
+ export type BackBehavior = 'initialRoute' | 'firstRoute' | 'history' | 'order' | 'none';
12
+ export type TabRouterOptions = DefaultRouterOptions & {
13
13
  backBehavior?: BackBehavior;
14
14
  };
15
- export declare type TabNavigationState<ParamList extends ParamListBase> = Omit<NavigationState<ParamList>, 'history'> & {
15
+ export type TabNavigationState<ParamList extends ParamListBase> = Omit<NavigationState<ParamList>, 'history'> & {
16
16
  /**
17
17
  * Type of the router, in this case, it's tab.
18
18
  */
@@ -25,7 +25,7 @@ export declare type TabNavigationState<ParamList extends ParamListBase> = Omit<N
25
25
  key: string;
26
26
  }[];
27
27
  };
28
- export declare type TabActionHelpers<ParamList extends ParamListBase> = {
28
+ export type TabActionHelpers<ParamList extends ParamListBase> = {
29
29
  /**
30
30
  * Jump to an existing tab.
31
31
  *
@@ -38,3 +38,4 @@ export declare const TabActions: {
38
38
  jumpTo(name: string, params?: object): TabActionType;
39
39
  };
40
40
  export default function TabRouter({ initialRouteName, backBehavior, }: TabRouterOptions): Router<TabNavigationState<ParamListBase>, import("./CommonActions").Action | TabActionType>;
41
+ //# sourceMappingURL=TabRouter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabRouter.d.ts","sourceRoot":"","sources":["../../../src/TabRouter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,oBAAoB,EACpB,eAAe,EACf,aAAa,EAGb,MAAM,EACP,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB,cAAc,GACd,YAAY,GACZ,SAAS,GACT,OAAO,GACP,MAAM,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG;IACpD,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,SAAS,SAAS,aAAa,IAAI,IAAI,CACpE,eAAe,CAAC,SAAS,CAAC,EAC1B,SAAS,CACV,GAAG;IACF;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IACZ;;OAEG;IACH,OAAO,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,SAAS,SAAS,aAAa,IAAI;IAC9D;;;;;OAKG;IACH,MAAM,CAAC,SAAS,SAAS,OAAO,CAAC,MAAM,SAAS,EAAE,MAAM,CAAC,EACvD,GAAG,IAAI,EAAE,SAAS,SAAS,SAAS,CAAC,SAAS,CAAC,GAC3C,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,GACvE,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,GACpD,IAAI,CAAC;CACT,CAAC;AAIF,eAAO,MAAM,UAAU;iBACR,MAAM,WAAW,MAAM,GAAG,aAAa;CAGrD,CAAC;AA4EF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,gBAAgB,EAChB,YAA2B,GAC5B,EAAE,gBAAgB,+FAiPlB"}
@@ -8,3 +8,4 @@ export { StackActions, default as StackRouter } from './StackRouter';
8
8
  export type { TabActionHelpers, TabActionType, TabNavigationState, TabRouterOptions, } from './TabRouter';
9
9
  export { TabActions, default as TabRouter } from './TabRouter';
10
10
  export * from './types';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxE,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACrE,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/D,cAAc,SAAS,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import type * as CommonActions from './CommonActions';
2
- export declare type CommonNavigationAction = CommonActions.Action;
3
- declare type NavigationRoute<ParamList extends ParamListBase, RouteName extends keyof ParamList> = Route<Extract<RouteName, string>, ParamList[RouteName]> & {
2
+ export type CommonNavigationAction = CommonActions.Action;
3
+ type NavigationRoute<ParamList extends ParamListBase, RouteName extends keyof ParamList> = Route<Extract<RouteName, string>, ParamList[RouteName]> & {
4
4
  state?: NavigationState | PartialState<NavigationState>;
5
5
  };
6
- export declare type NavigationState<ParamList extends ParamListBase = ParamListBase> = Readonly<{
6
+ export type NavigationState<ParamList extends ParamListBase = ParamListBase> = Readonly<{
7
7
  /**
8
8
  * Unique key for the navigation state.
9
9
  */
@@ -35,20 +35,20 @@ export declare type NavigationState<ParamList extends ParamListBase = ParamListB
35
35
  */
36
36
  stale: false;
37
37
  }>;
38
- export declare type InitialState = Readonly<Partial<Omit<NavigationState, 'stale' | 'routes'>> & {
38
+ export type InitialState = Readonly<Partial<Omit<NavigationState, 'stale' | 'routes'>> & {
39
39
  routes: (Omit<Route<string>, 'key'> & {
40
40
  state?: InitialState;
41
41
  })[];
42
42
  }>;
43
- export declare type PartialRoute<R extends Route<string>> = Omit<R, 'key'> & {
43
+ export type PartialRoute<R extends Route<string>> = Omit<R, 'key'> & {
44
44
  key?: string;
45
45
  state?: PartialState<NavigationState>;
46
46
  };
47
- export declare type PartialState<State extends NavigationState> = Partial<Omit<State, 'stale' | 'routes'>> & Readonly<{
47
+ export type PartialState<State extends NavigationState> = Partial<Omit<State, 'stale' | 'routes'>> & Readonly<{
48
48
  stale?: true;
49
49
  routes: PartialRoute<Route<State['routeNames'][number]>>[];
50
50
  }>;
51
- export declare type Route<RouteName extends string, Params extends object | undefined = object | undefined> = Readonly<{
51
+ export type Route<RouteName extends string, Params extends object | undefined = object | undefined> = Readonly<{
52
52
  /**
53
53
  * Unique key for the route.
54
54
  */
@@ -73,8 +73,8 @@ export declare type Route<RouteName extends string, Params extends object | unde
73
73
  */
74
74
  params: Readonly<Params>;
75
75
  }>);
76
- export declare type ParamListBase = Record<string, object | undefined>;
77
- export declare type NavigationAction = Readonly<{
76
+ export type ParamListBase = Record<string, object | undefined>;
77
+ export type NavigationAction = Readonly<{
78
78
  /**
79
79
  * Type of the action (e.g. `NAVIGATE`)
80
80
  */
@@ -92,25 +92,25 @@ export declare type NavigationAction = Readonly<{
92
92
  */
93
93
  target?: string;
94
94
  }>;
95
- export declare type ActionCreators<Action extends NavigationAction> = {
95
+ export type ActionCreators<Action extends NavigationAction> = {
96
96
  [key: string]: (...args: any) => Action;
97
97
  };
98
- export declare type DefaultRouterOptions<RouteName extends string = string> = {
98
+ export type DefaultRouterOptions<RouteName extends string = string> = {
99
99
  /**
100
100
  * Name of the route to focus by on initial render.
101
101
  * If not specified, usually the first route is used.
102
102
  */
103
103
  initialRouteName?: RouteName;
104
104
  };
105
- export declare type RouterFactory<State extends NavigationState, Action extends NavigationAction, RouterOptions extends DefaultRouterOptions> = (options: RouterOptions) => Router<State, Action>;
106
- export declare type RouterConfigOptions = {
105
+ export type RouterFactory<State extends NavigationState, Action extends NavigationAction, RouterOptions extends DefaultRouterOptions> = (options: RouterOptions) => Router<State, Action>;
106
+ export type RouterConfigOptions = {
107
107
  routeNames: string[];
108
108
  routeParamList: ParamListBase;
109
109
  routeGetIdList: Record<string, ((options: {
110
110
  params?: Record<string, any>;
111
111
  }) => string | undefined) | undefined>;
112
112
  };
113
- export declare type Router<State extends NavigationState, Action extends NavigationAction> = {
113
+ export type Router<State extends NavigationState, Action extends NavigationAction> = {
114
114
  /**
115
115
  * Type of the router. Should match the `type` property in state.
116
116
  * If the type doesn't match, the state will be discarded during rehydration.
@@ -174,3 +174,4 @@ export declare type Router<State extends NavigationState, Action extends Navigat
174
174
  actionCreators?: ActionCreators<Action>;
175
175
  };
176
176
  export {};
177
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,KAAK,eAAe,CAClB,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,EAAE,OAAO,EAAE,CAAC;IACpB;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC,SAAS,EAAE,MAAM,SAAS,CAAC,EAAE,CAAC;IACtD;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;CACd,CAAC,CAAC;AAEL,MAAM,MAAM,YAAY,GAAG,QAAQ,CACjC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC,GAAG;IACnD,MAAM,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG;QAAE,KAAK,CAAC,EAAE,YAAY,CAAA;KAAE,CAAC,EAAE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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,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/routers",
3
3
  "description": "Routers to help build custom navigators",
4
- "version": "6.1.5",
4
+ "version": "7.0.0-alpha.0",
5
5
  "keywords": [
6
6
  "react",
7
7
  "react-native",
@@ -39,9 +39,9 @@
39
39
  "nanoid": "^3.1.23"
40
40
  },
41
41
  "devDependencies": {
42
- "del-cli": "^3.0.1",
43
- "react-native-builder-bob": "^0.18.1",
44
- "typescript": "^4.7.4"
42
+ "del-cli": "^5.0.0",
43
+ "react-native-builder-bob": "^0.20.3",
44
+ "typescript": "^4.9.4"
45
45
  },
46
46
  "react-native-builder-bob": {
47
47
  "source": "src",
@@ -57,5 +57,5 @@
57
57
  ]
58
58
  ]
59
59
  },
60
- "gitHead": "4e29403ec63d9304561e296667f6cf15806c316b"
60
+ "gitHead": "ad722b882e0c40b1d1bc025d70112ddb126f265e"
61
61
  }
@@ -74,7 +74,7 @@ const BaseRouter = {
74
74
  },
75
75
 
76
76
  shouldActionChangeFocus(action: CommonNavigationAction) {
77
- return action.type === 'NAVIGATE';
77
+ return action.type === 'NAVIGATE' || action.type === 'NAVIGATE_DEPRECATED';
78
78
  },
79
79
  };
80
80
 
@@ -15,21 +15,22 @@ export type Action =
15
15
  }
16
16
  | {
17
17
  type: 'NAVIGATE';
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
- };
18
+ payload: {
19
+ name: string;
20
+ params?: object;
21
+ path?: string;
22
+ merge?: boolean;
23
+ };
24
+ source?: string;
25
+ target?: string;
26
+ }
27
+ | {
28
+ type: 'NAVIGATE_DEPRECATED';
29
+ payload: {
30
+ name: string;
31
+ params?: object;
32
+ merge?: boolean;
33
+ };
33
34
  source?: string;
34
35
  target?: string;
35
36
  }
@@ -50,17 +51,12 @@ export function goBack(): Action {
50
51
  return { type: 'GO_BACK' };
51
52
  }
52
53
 
53
- export function navigate(
54
- options:
55
- | { key: string; params?: object; path?: string; merge?: boolean }
56
- | {
57
- name: string;
58
- key?: string;
59
- params?: object;
60
- path?: string;
61
- merge?: boolean;
62
- }
63
- ): Action;
54
+ export function navigate(options: {
55
+ name: string;
56
+ params?: object;
57
+ path?: string;
58
+ merge?: boolean;
59
+ }): Action;
64
60
  // eslint-disable-next-line no-redeclare
65
61
  export function navigate(name: string, params?: object): Action;
66
62
  // eslint-disable-next-line no-redeclare
@@ -70,9 +66,9 @@ export function navigate(...args: any): Action {
70
66
  } else {
71
67
  const payload = args[0] || {};
72
68
 
73
- if (!payload.hasOwnProperty('key') && !payload.hasOwnProperty('name')) {
69
+ if (!payload.hasOwnProperty('name')) {
74
70
  throw new Error(
75
- 'You need to specify name or key when calling navigate with an object as the argument. See https://reactnavigation.org/docs/navigation-actions#navigate for usage.'
71
+ '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
72
  );
77
73
  }
78
74
 
@@ -80,6 +76,30 @@ export function navigate(...args: any): Action {
80
76
  }
81
77
  }
82
78
 
79
+ export function navigateDeprecated(
80
+ ...args:
81
+ | [name: string]
82
+ | [name: string, params: object | undefined]
83
+ | [route: { name: string; params?: object }]
84
+ ): Action {
85
+ if (typeof args[0] === 'string') {
86
+ return {
87
+ type: 'NAVIGATE_DEPRECATED',
88
+ payload: { name: args[0], params: args[1] },
89
+ };
90
+ } else {
91
+ const payload = args[0] || {};
92
+
93
+ if (!payload.hasOwnProperty('name')) {
94
+ throw new Error(
95
+ 'You need to specify a name when calling navigate with an object as the argument. See https://reactnavigation.org/docs/navigation-actions#navigatelegacy for usage.'
96
+ );
97
+ }
98
+
99
+ return { type: 'NAVIGATE_DEPRECATED', payload };
100
+ }
101
+ }
102
+
83
103
  export function reset(state: ResetState | undefined): Action {
84
104
  return { type: 'RESET', payload: state };
85
105
  }
@@ -220,7 +220,8 @@ export default function DrawerRouter({
220
220
  return addDrawerToHistory(state);
221
221
 
222
222
  case 'JUMP_TO':
223
- case 'NAVIGATE': {
223
+ case 'NAVIGATE':
224
+ case 'NAVIGATE_DEPRECATED': {
224
225
  const result = router.getStateForAction(state, action, options);
225
226
 
226
227
  if (result != null && result.index !== state.index) {