import { HistoryNavigator, LocationChangeEvent, NavigateOptions } from "./HistoryNavigator"; import { PathMatch, PathMatcher } from "./PathMatcher"; export type LazyImportFn = () => Promise; export interface ComponentRoute { path: string; Component: React.ComponentType; } export interface LazyComponentRoute { path: string; LazyComponent: LazyImportFn; } export type Route = ComponentRoute | LazyComponentRoute; export interface RouteMatch extends PathMatch { state: any; } export interface NavigationPrompt { message: string; when?: boolean; } export declare abstract class BaseRouter { index?: string; matcher: PathMatcher; constructor(routes: Route[], index?: string); abstract getTopRouter(): Router; match(path: string): PathMatch | null; abstract navigate(path: string, options?: NavigateOptions): void; } export declare class Router extends BaseRouter { prompt?: NavigationPrompt; observer?: (event: LocationChangeEvent) => void; navigator: HistoryNavigator; constructor(routes: Route[], updateState: (route: RouteMatch | null) => void); getTopRouter(): Router; /** * Subsequent navigations will preserve the given params in the query string. * Use null to clear the sticky params. * @param params */ setStickyParams(params: Record | null): void; withObserver(observer?: ((event: LocationChangeEvent) => void) | undefined): this; start(): void; stop(): void; navigate(path: string, options?: NavigateOptions): void; } export declare class NestedRouter extends BaseRouter { parent: BaseRouter; basePath: string; constructor(parent: BaseRouter, basePath: string, routes: Route[]); getTopRouter(): Router; navigate(path: string, options?: NavigateOptions | undefined): void; } export interface RouterContext { location: Location; route: Route; router: BaseRouter; params: Record; state: any; /** * The path that matched the route. For wildcard `/*` paths this does not include the wildcard part. * You can get the wildcard path from `remainingPath`. */ matchedRoutePath: string; remainingPath?: string; navigate: (path: string, options?: NavigateOptions) => void; } declare const ReactRouterContext: import("react").Context; export { ReactRouterContext }; export declare function useRouterContext(): RouterContext; export declare function useNavigate(): (path: string, options?: NavigateOptions) => void; export declare function useRouterBasePath(): string; type UseParamsReturn = T extends string ? string : Record; export declare function useParams(arg?: T): UseParamsReturn; export declare function useLocation(): Location; export declare function usePageTitle(title: string): void; export declare function useNavigationPrompt(prompt: NavigationPrompt): void; //# sourceMappingURL=Router.d.ts.map