Compare commits

...

4 Commits

Author SHA1 Message Date
satyajit.happy
246f4b0e15 chore: release 4.0.9 2019-09-24 13:23:53 +02:00
satyajit.happy
c828050ba1 fix: fix types for switch navigator. fixes #6324 2019-09-24 13:16:11 +02:00
satyajit.happy
5eaec68860 chore: release 4.0.8 2019-09-23 22:35:38 +02:00
satyajit.happy
6142f06bbd fix: add type aliases for switch navigator. fixes #6324 2019-09-23 22:34:14 +02:00
2 changed files with 112 additions and 29 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "react-navigation", "name": "react-navigation",
"version": "4.0.7", "version": "4.0.9",
"description": "Routing and navigation for your React Native apps", "description": "Routing and navigation for your React Native apps",
"main": "src/react-navigation.js", "main": "src/react-navigation.js",
"types": "typescript/react-navigation.d.ts", "types": "typescript/react-navigation.d.ts",

View File

@@ -164,9 +164,13 @@ declare module 'react-navigation' {
params?: NavigationParams; params?: NavigationParams;
}; };
getComponentForRouteName: (routeName: string) => NavigationComponent<{}, NavigationScreenProp<NavigationRoute>>; getComponentForRouteName: (
routeName: string
) => NavigationComponent<{}, NavigationScreenProp<NavigationRoute>>;
getComponentForState: (state: State) => NavigationComponent<{}, NavigationScreenProp<NavigationRoute>>; getComponentForState: (
state: State
) => NavigationComponent<{}, NavigationScreenProp<NavigationRoute>>;
getActionCreators: ( getActionCreators: (
route: NavigationRoute, route: NavigationRoute,
@@ -186,20 +190,36 @@ declare module 'react-navigation' {
getScreenOptions: NavigationScreenOptionsGetter<Options>; getScreenOptions: NavigationScreenOptionsGetter<Options>;
} }
export type NavigationScreenComponent<Options, NavigationScreenPropType> = React.ComponentType<any> & { export type NavigationScreenComponent<
navigationOptions?: NavigationScreenConfig<Options, NavigationScreenPropType>; Options,
NavigationScreenPropType
> = React.ComponentType<any> & {
navigationOptions?: NavigationScreenConfig<
Options,
NavigationScreenPropType
>;
}; };
export interface NavigationScreenConfigProps<NavigationScreenPropType, ScreenProps = unknown> { export interface NavigationScreenConfigProps<
NavigationScreenPropType,
ScreenProps = unknown
> {
navigation: NavigationScreenPropType; navigation: NavigationScreenPropType;
screenProps: ScreenProps; screenProps: ScreenProps;
theme: SupportedThemes; theme: SupportedThemes;
} }
export type NavigationScreenConfig<Options, NavigationScreenPropType, ScreenProps = unknown> = export type NavigationScreenConfig<
Options,
NavigationScreenPropType,
ScreenProps = unknown
> =
| Options | Options
| (( | ((
navigationOptionsContainer: NavigationScreenConfigProps<NavigationScreenPropType, ScreenProps> & { navigationOptionsContainer: NavigationScreenConfigProps<
NavigationScreenPropType,
ScreenProps
> & {
navigationOptions: Options; navigationOptions: Options;
} }
) => Options); ) => Options);
@@ -208,7 +228,10 @@ declare module 'react-navigation' {
| NavigationScreenComponent<Options, NavigationPropType> | NavigationScreenComponent<Options, NavigationPropType>
| NavigationNavigator<Options, NavigationPropType>; | NavigationNavigator<Options, NavigationPropType>;
export type NavigationNavigator<Options, NavigationPropType> = React.ComponentType<NavigationNavigatorProps<Options>> & { export type NavigationNavigator<
Options,
NavigationPropType
> = React.ComponentType<NavigationNavigatorProps<Options>> & {
router: NavigationRouter<Options>; router: NavigationRouter<Options>;
navigationOptions?: NavigationScreenConfig<Options, NavigationPropType>; navigationOptions?: NavigationScreenConfig<Options, NavigationPropType>;
}; };
@@ -399,6 +422,33 @@ declare module 'react-navigation' {
config?: NavigationSwitchRouterConfig config?: NavigationSwitchRouterConfig
): NavigationRouter<any, any>; ): NavigationRouter<any, any>;
export type NavigationSwitchProp<
State = NavigationRoute,
Params = NavigationParams
> = NavigationScreenProp<State, Params> & {
jumpTo(routeName: string, key?: string): void;
};
export type NavigationSwitchScreenProps<
Params = NavigationParams,
ScreenProps = unknown
> = {
theme: SupportedThemes;
navigation: NavigationSwitchProp<NavigationRoute, Params>;
screenProps: ScreenProps;
};
export type NavigationSwitchScreenComponent<
Params = NavigationParams,
ScreenProps = unknown
> = React.ComponentType<NavigationSwitchScreenProps<Params, ScreenProps>> & {
navigationOptions?: NavigationScreenConfig<
{},
NavigationSwitchProp<NavigationRoute, Params>,
ScreenProps
>;
};
export type NavigationStackAction = export type NavigationStackAction =
| NavigationInitAction | NavigationInitAction
| NavigationNavigateAction | NavigationNavigateAction
@@ -437,9 +487,17 @@ declare module 'react-navigation' {
| NavigationComponent<Options, NavigationScreenPropType> | NavigationComponent<Options, NavigationScreenPropType>
| ( | (
| { screen: NavigationComponent<Options, NavigationScreenPropType> } | { screen: NavigationComponent<Options, NavigationScreenPropType> }
| { getScreen(): NavigationScreenComponent<Options, NavigationScreenPropType> }) & { | {
navigationOptions?: NavigationScreenConfig<Options, NavigationScreenPropType>; getScreen(): NavigationScreenComponent<
params?: { [key: string]: any } Options,
NavigationScreenPropType
>;
}) & {
navigationOptions?: NavigationScreenConfig<
Options,
NavigationScreenPropType
>;
params?: { [key: string]: any };
path?: string; path?: string;
}; };
@@ -458,7 +516,10 @@ declare module 'react-navigation' {
} }
export interface NavigationRouteConfigMap<Options, NavigationScreenPropType> { export interface NavigationRouteConfigMap<Options, NavigationScreenPropType> {
[routeName: string]: NavigationRouteConfig<Options, NavigationScreenPropType>; [routeName: string]: NavigationRouteConfig<
Options,
NavigationScreenPropType
>;
} }
export type NavigationDispatch = (action: NavigationAction) => boolean; export type NavigationDispatch = (action: NavigationAction) => boolean;
@@ -542,7 +603,11 @@ declare module 'react-navigation' {
dangerouslyGetParent: () => NavigationScreenProp<S> | undefined; dangerouslyGetParent: () => NavigationScreenProp<S> | undefined;
} }
export interface NavigationNavigatorProps<Options = {}, State = {}, ScreenProps = unknown> { export interface NavigationNavigatorProps<
Options = {},
State = {},
ScreenProps = unknown
> {
theme?: SupportedThemes | 'no-preference'; theme?: SupportedThemes | 'no-preference';
detached?: boolean; detached?: boolean;
navigation?: NavigationProp<State>; navigation?: NavigationProp<State>;
@@ -555,7 +620,11 @@ declare module 'react-navigation' {
| 'react-navigation/TABS' | 'react-navigation/TABS'
| 'react-navigation/DRAWER'; | 'react-navigation/DRAWER';
export interface NavigationContainerProps<State = {}, Options = {}, ScreenProps = unknown> { export interface NavigationContainerProps<
State = {},
Options = {},
ScreenProps = unknown
> {
uriPrefix?: string | RegExp; uriPrefix?: string | RegExp;
/** /**
* Controls whether the navigation container handles URLs opened via 'Linking' * Controls whether the navigation container handles URLs opened via 'Linking'
@@ -606,16 +675,14 @@ declare module 'react-navigation' {
state: { nav: NavigationState | null }; state: { nav: NavigationState | null };
} }
export interface SwitchNavigatorConfig {
initialRouteName: string;
resetOnBlur?: boolean;
paths?: NavigationPathsConfig;
backBehavior?: 'none' | 'initialRoute';
}
export function createSwitchNavigator( export function createSwitchNavigator(
routeConfigMap: NavigationRouteConfigMap<SwitchNavigatorConfig, NavigationScreenProp<NavigationRoute>>, routeConfigMap: NavigationRouteConfigMap<{}, NavigationSwitchProp>,
switchConfig?: SwitchNavigatorConfig switchConfig?: CreateNavigatorConfig<
{},
NavigationSwitchRouterConfig,
{},
NavigationSwitchProp
>
): NavigationNavigator<{}, NavigationProp<NavigationState>>; ): NavigationNavigator<{}, NavigationProp<NavigationState>>;
/** /**
@@ -735,7 +802,11 @@ declare module 'react-navigation' {
getComponent: () => React.ComponentType; getComponent: () => React.ComponentType;
} }
export type NavigationView<Options, State, ScreenProps = unknown> = React.ComponentType< export type NavigationView<
Options,
State,
ScreenProps = unknown
> = React.ComponentType<
{ {
descriptors: { [key: string]: NavigationDescriptor }; descriptors: { [key: string]: NavigationDescriptor };
navigationConfig: Options; navigationConfig: Options;
@@ -743,10 +814,22 @@ declare module 'react-navigation' {
} & NavigationInjectedProps } & NavigationInjectedProps
>; >;
export type CreateNavigatorConfig<NavigatorConfig, RouterConfig, Options, NavigationScreenPropType> = NavigatorConfig & RouterConfig & { export type CreateNavigatorConfig<
defaultNavigationOptions?: NavigationScreenConfig<Options, NavigationScreenPropType>; NavigatorConfig,
navigationOptions?: NavigationScreenConfig<{ [key: string]: any }, NavigationScreenProp<NavigationRoute>>; RouterConfig,
} Options,
NavigationScreenPropType
> = NavigatorConfig &
RouterConfig & {
defaultNavigationOptions?: NavigationScreenConfig<
Options,
NavigationScreenPropType
>;
navigationOptions?: NavigationScreenConfig<
{ [key: string]: any },
NavigationScreenProp<NavigationRoute>
>;
};
export function createNavigator<S, Options>( export function createNavigator<S, Options>(
view: NavigationView<Options, S>, view: NavigationView<Options, S>,