UNPKG

7.62 kBTypeScriptView Raw
1import { DefaultRouterOptions, NavigationState, ParamListBase, PartialState, RouterFactory } from '@react-navigation/routers';
2import * as React from 'react';
3import { DefaultNavigatorOptions, EventMapCore, PrivateValueStore, RouteProp } from './types';
4declare type NavigationBuilderOptions<ScreenOptions extends {}> = {
5 /**
6 * Default options specified by the navigator.
7 * It receives the custom options in the arguments if a function is specified.
8 */
9 defaultScreenOptions?: ScreenOptions | ((props: {
10 route: RouteProp<ParamListBase>;
11 navigation: any;
12 options: ScreenOptions;
13 }) => ScreenOptions);
14};
15/**
16 * Hook for building navigators.
17 *
18 * @param createRouter Factory method which returns router object.
19 * @param options Options object containing `children` and additional options for the router.
20 * @returns An object containing `state`, `navigation`, `descriptors` objects.
21 */
22export default function useNavigationBuilder<State extends NavigationState, RouterOptions extends DefaultRouterOptions, ActionHelpers extends Record<string, () => void>, ScreenOptions extends {}, EventMap extends Record<string, any>>(createRouter: RouterFactory<State, any, RouterOptions>, options: DefaultNavigatorOptions<ParamListBase, State, ScreenOptions, EventMap> & NavigationBuilderOptions<ScreenOptions> & RouterOptions): {
23 state: State;
24 navigation: {
25 dispatch(action: Readonly<{
26 type: string;
27 payload?: object | undefined;
28 source?: string | undefined;
29 target?: string | undefined;
30 }> | ((state: Readonly<{
31 key: string;
32 index: number;
33 routeNames: string[];
34 history?: unknown[] | undefined;
35 routes: (Readonly<{
36 key: string;
37 name: string;
38 path?: string | undefined;
39 }> & Readonly<{
40 params?: Readonly<object | undefined>;
41 }> & {
42 state?: Readonly<any> | PartialState<Readonly<any>> | undefined;
43 })[];
44 type: string;
45 stale: false;
46 }>) => Readonly<{
47 type: string;
48 payload?: object | undefined;
49 source?: string | undefined;
50 target?: string | undefined;
51 }>)): void;
52 navigate<RouteName extends string>(...args: RouteName extends unknown ? [screen: RouteName] | [screen: RouteName, params: object | undefined] : never): void;
53 navigate<RouteName_1 extends string>(options: RouteName_1 extends unknown ? {
54 key: string;
55 params?: object | undefined;
56 merge?: boolean | undefined;
57 } | {
58 name: RouteName_1;
59 key?: string | undefined;
60 params: object | undefined;
61 merge?: boolean | undefined;
62 } : never): void;
63 reset(state: Readonly<{
64 key: string;
65 index: number;
66 routeNames: string[];
67 history?: unknown[] | undefined;
68 routes: (Readonly<{
69 key: string;
70 name: string;
71 path?: string | undefined;
72 }> & Readonly<{
73 params?: Readonly<object | undefined>;
74 }> & {
75 state?: Readonly<any> | PartialState<Readonly<any>> | undefined;
76 })[];
77 type: string;
78 stale: false;
79 }> | PartialState<Readonly<{
80 key: string;
81 index: number;
82 routeNames: string[];
83 history?: unknown[] | undefined;
84 routes: (Readonly<{
85 key: string;
86 name: string;
87 path?: string | undefined;
88 }> & Readonly<{
89 params?: Readonly<object | undefined>;
90 }> & {
91 state?: Readonly<any> | PartialState<Readonly<any>> | undefined;
92 })[];
93 type: string;
94 stale: false;
95 }>>): void;
96 goBack(): void;
97 isFocused(): boolean;
98 canGoBack(): boolean;
99 getId(): string | undefined;
100 getParent<T = import("./types").NavigationHelpers<ParamListBase, {}> | undefined>(id?: string | undefined): T;
101 getState(): Readonly<{
102 key: string;
103 index: number;
104 routeNames: string[];
105 history?: unknown[] | undefined;
106 routes: (Readonly<{
107 key: string;
108 name: string;
109 path?: string | undefined;
110 }> & Readonly<{
111 params?: Readonly<object | undefined>;
112 }> & {
113 state?: Readonly<any> | PartialState<Readonly<any>> | undefined;
114 })[];
115 type: string;
116 stale: false;
117 }>;
118 } & PrivateValueStore<[ParamListBase, unknown, unknown]> & import("./types").EventEmitter<EventMap> & {
119 setParams<RouteName_2 extends string>(params: Partial<object | undefined>): void;
120 } & ActionHelpers;
121 descriptors: Record<string, import("./types").Descriptor<ScreenOptions, Omit<{
122 dispatch(action: Readonly<{
123 type: string;
124 payload?: object | undefined;
125 source?: string | undefined;
126 target?: string | undefined;
127 }> | ((state: State) => Readonly<{
128 type: string;
129 payload?: object | undefined;
130 source?: string | undefined;
131 target?: string | undefined;
132 }>)): void;
133 navigate<RouteName extends string>(...args: RouteName extends unknown ? [screen: RouteName] | [screen: RouteName, params: object | undefined] : never): void;
134 navigate<RouteName_1 extends string>(options: RouteName_1 extends unknown ? {
135 key: string;
136 params?: object | undefined;
137 merge?: boolean | undefined;
138 } | {
139 name: RouteName_1;
140 key?: string | undefined;
141 params: object | undefined;
142 merge?: boolean | undefined;
143 } : never): void;
144 reset(state: State | PartialState<State>): void;
145 goBack(): void;
146 isFocused(): boolean;
147 canGoBack(): boolean;
148 getId(): string | undefined;
149 getParent<T = import("./types").NavigationHelpers<ParamListBase, {}> | undefined>(id?: string | undefined): T;
150 getState(): State;
151 } & PrivateValueStore<[ParamListBase, unknown, unknown]>, "getParent"> & {
152 getParent<T_1 = import("./types").NavigationProp<ParamListBase, string, undefined, Readonly<{
153 key: string;
154 index: number;
155 routeNames: string[];
156 history?: unknown[] | undefined;
157 routes: (Readonly<{
158 key: string;
159 name: string;
160 path?: string | undefined;
161 }> & Readonly<{
162 params?: Readonly<object | undefined>;
163 }> & {
164 state?: Readonly<any> | PartialState<Readonly<any>> | undefined;
165 })[];
166 type: string;
167 stale: false;
168 }>, {}, {}> | undefined>(id?: string | undefined): T_1;
169 setParams(params: Partial<object | undefined>): void;
170 setOptions(options: Partial<ScreenOptions>): void;
171 } & import("./types").EventConsumer<EventMap & EventMapCore<State>> & PrivateValueStore<[ParamListBase, string, EventMap]> & ActionHelpers, RouteProp<ParamListBase, string>>>;
172 NavigationContent: ({ children }: {
173 children: React.ReactNode;
174 }) => JSX.Element;
175};
176export {};
177//# sourceMappingURL=useNavigationBuilder.d.ts.map
\No newline at end of file