import * as React from 'react'; import { createHashHistory, createBrowserHistory, createMemoryHistory, BrowserHistory, MemoryHistory, History, HashHistory } from 'history'; export { createHashHistory, createBrowserHistory, createMemoryHistory }; declare type Timeout = ReturnType; declare type Maybe = T extends {} ? T : TUnknown; export declare type DefaultGenerics = { LoaderData: LoaderData; Params: Params; Search: Search; RouteMeta: RouteMeta; }; export declare type PartialGenerics = Partial; export declare type MakeGenerics = TGenerics; export declare type Search = Record; export declare type Params = Record; export declare type LoaderData = Record; export declare type RouteMeta = Record; export declare type UseGeneric = TGeneric extends 'LoaderData' | 'Search' ? Partial> : Maybe; export declare type ReactLocationOptions = { history?: BrowserHistory | MemoryHistory | HashHistory; stringifySearch?: SearchSerializer; parseSearch?: SearchParser; }; export declare type SearchSerializer = (searchObj: Record) => string; export declare type SearchParser = (searchStr: string) => Record; export declare type Updater = TResult | ((prev?: TResult) => TResult); export declare type Location = { href: string; pathname: string; search: UseGeneric; searchStr: string; hash: string; key?: string; }; export declare type Route = { path?: string; id?: string; caseSensitive?: boolean; search?: SearchPredicate>; pendingMs?: number; pendingMinMs?: number; searchFilters?: SearchFilter[]; children?: Route[]; } & RouteLoaders & { import?: (opts: { params: UseGeneric; search: UseGeneric; }) => Promise>; }; export declare type RouteLoaders = { element?: SyncOrAsyncElement; errorElement?: SyncOrAsyncElement; pendingElement?: SyncOrAsyncElement; loader?: LoaderFn; unloader?: UnloaderFn; loaderMaxAge?: number; onMatch?: (match: RouteMatch) => void | undefined | ((match: RouteMatch) => void); onTransition?: (match: RouteMatch) => void; meta?: UseGeneric; }; export declare type SearchFilter = (prev: UseGeneric) => UseGeneric; export declare type MatchLocation = { to?: string | number | null; search?: SearchPredicate>; fuzzy?: boolean; caseSensitive?: boolean; }; export declare type SearchPredicate = (search: TSearch) => any; export declare type SyncOrAsyncElement = React.ReactNode | AsyncElement; export declare type AsyncElement = (opts: { params: UseGeneric; }) => Promise; export declare type UnloadedMatch = { id: string; route: Route; pathname: string; params: UseGeneric; search: UseGeneric; }; export declare type LoaderFn = (routeMatch: RouteMatch, opts: LoaderFnOptions) => PromiseLike>; export declare type UnloaderFn = (routeMatch: RouteMatch) => void; export declare type LoaderFnOptions = { parentMatch?: RouteMatch; dispatch: (event: LoaderDispatchEvent) => void; }; declare type PromiseLike = Promise | T; export declare type ListenerFn = () => void; export declare type Segment = { type: 'pathname' | 'param' | 'wildcard'; value: string; }; export declare type RouterProps = { children?: React.ReactNode; location: ReactLocation; } & RouterOptions; export declare type RouterOptions = { routes: Route[]; basepath?: string; filterRoutes?: FilterRoutesFn; defaultLinkPreloadMaxAge?: number; defaultLoaderMaxAge?: number; useErrorBoundary?: boolean; defaultElement?: SyncOrAsyncElement; defaultErrorElement?: SyncOrAsyncElement; defaultPendingElement?: SyncOrAsyncElement; defaultPendingMs?: number; defaultPendingMinMs?: number; caseSensitive?: boolean; __experimental__snapshot?: __Experimental__RouterSnapshot; }; export declare type __Experimental__RouterSnapshot = { location: Location; matches: SnapshotRouteMatch[]; }; export declare type SnapshotRouteMatch = { id: string; ownData: UseGeneric; }; export declare type BuildNextOptions = { to?: string | number | null; search?: true | Updater>; hash?: true | Updater; from?: Partial>; key?: string; __searchFilters?: SearchFilter[]; }; export declare type NavigateOptions = BuildNextOptions & { replace?: boolean; fromCurrent?: boolean; }; export declare type PromptProps = { message: string; when?: boolean | any; children?: React.ReactNode; }; export declare type LinkProps = Omit, 'href' | 'children'> & { to?: string | number | null; search?: true | Updater>; hash?: Updater; replace?: boolean; getActiveProps?: () => Record; getInactiveProps?: () => Record; activeOptions?: ActiveOptions; preload?: number; disabled?: boolean; _ref?: React.Ref; children?: React.ReactNode | ((state: { isActive: boolean; }) => React.ReactNode); }; declare type ActiveOptions = { exact?: boolean; includeHash?: boolean; }; export declare type LinkPropsType = LinkProps; export declare type LoaderDispatchEvent = { type: 'maxAge'; maxAge: number; } | { type: 'loading'; } | { type: 'resolve'; data: UseGeneric; } | { type: 'reject'; error: unknown; }; export declare type LoadRouteFn = (next: Location) => MatchLoader; export declare type TransitionState = { location: Location; matches: RouteMatch[]; }; export declare type FilterRoutesFn = (routes: Route[]) => Route[]; export declare type RouterPropsType = RouterProps; export declare type RouterType = (props: RouterProps) => JSX.Element; declare type Listener = () => void; declare class Subscribable { listeners: Listener[]; constructor(); subscribe(listener: Listener): () => void; notify(): void; } export declare class ReactLocation extends Subscribable { history: BrowserHistory | MemoryHistory; stringifySearch: SearchSerializer; parseSearch: SearchParser; current: Location; destroy: () => void; navigateTimeout?: Timeout; nextAction?: 'push' | 'replace'; isTransitioning: boolean; constructor(options?: ReactLocationOptions); buildNext(basepath?: string, dest?: BuildNextOptions): Location; navigate(next: Location, replace?: boolean): void; parseLocation(location: History['location'], previousLocation?: Location): Location; } export declare type MatchesProviderProps = { value: RouteMatch[]; children: React.ReactNode; }; export declare function MatchesProvider(props: MatchesProviderProps): JSX.Element; export declare function Router({ children, location, __experimental__snapshot, ...rest }: RouterProps): JSX.Element; declare type RouterInstanceState = { state: TransitionState; pending?: TransitionState; }; export declare class RouterInstance extends Subscribable { basepath?: string; rootMatch?: RouteMatch; state: TransitionState; pending?: TransitionState; routes: Route[]; filterRoutes?: FilterRoutesFn; defaultLinkPreloadMaxAge?: number; defaultLoaderMaxAge?: number; useErrorBoundary?: boolean; defaultElement: SyncOrAsyncElement; defaultErrorElement: SyncOrAsyncElement; defaultPendingElement: SyncOrAsyncElement; defaultPendingMs?: number; defaultPendingMinMs?: number; caseSensitive?: boolean; routesById: Record>; constructor({ location, __experimental__snapshot, ...rest }: { location: ReactLocation; __experimental__snapshot?: __Experimental__RouterSnapshot; } & RouterOptions); update: ({ basepath, routes, ...opts }: RouterOptions) => void; setState: (updater: (old: RouterInstanceState) => RouterInstanceState) => void; matchCache: Record>; cleanMatchCache: () => void; updateLocation: (next: Location) => { promise: Promise; unsubscribe: () => void; }; __experimental__createSnapshot: () => __Experimental__RouterSnapshot; } export declare type UseLocationType = () => ReactLocation; export declare function useLocation(): ReactLocation; export declare class RouteMatch { id: string; route: Route; pathname: string; params: UseGeneric; search: UseGeneric; updatedAt?: number; element?: React.ReactNode; errorElement?: React.ReactNode; pendingElement?: React.ReactNode; error?: unknown; loaderPromise?: Promise>; maxAge?: number; matchLoader?: MatchLoader; pendingTimeout?: Timeout; pendingMinPromise?: Promise; onExit?: void | ((match: RouteMatch) => void); constructor(unloadedMatch: UnloadedMatch); status: 'loading' | 'pending' | 'resolved' | 'rejected'; ownData: UseGeneric; data: UseGeneric; isLoading: boolean; private notify?; assignMatchLoader?: ((matchLoader: MatchLoader) => void) | undefined; startPending?: (() => void) | undefined; load?: ((opts: { maxAge?: number; parentMatch?: RouteMatch; router: RouterInstance; }) => void) | undefined; } declare class MatchLoader extends Subscribable { router: RouterInstance; location: Location; matches: RouteMatch[]; prepPromise?: Promise; matchPromise?: Promise[]>; firstRenderPromises?: Promise[]; preNotifiedMatches: RouteMatch[]; constructor(router: RouterInstance, nextLocation: Location); status: 'pending' | 'resolved'; preNotify: (routeMatch?: RouteMatch | undefined) => void; loadData: ({ maxAge }?: { maxAge?: number | undefined; }) => Promise[] | undefined>; load: ({ maxAge }?: { maxAge?: number | undefined; }) => Promise[] | undefined>; startPending: () => Promise; } export declare type UseRouterType = () => RouterInstance; export declare function useRouter(): RouterInstance; export interface MatchRoutesOptions { filterRoutes?: FilterRoutesFn; defaultPendingMs?: number; defaultPendingMinMs?: number; defaultElement?: SyncOrAsyncElement; defaultErrorElement?: SyncOrAsyncElement; defaultPendingElement?: SyncOrAsyncElement; } export declare type MatchRoutesType = (router: RouterInstance[], currentLocation: Location) => Promise[]>; export declare function matchRoutes(router: RouterInstance, currentLocation: Location): UnloadedMatch[]; export declare type UseLoadRouteType = (routes?: Route[]) => void; export declare function useLoadRoute(): (navigate?: NavigateOptions | undefined, opts?: { maxAge?: number | undefined; } | undefined) => Promise[] | undefined>; export declare type UseMatchesType = () => RouteMatch[]; export declare function useParentMatches(): RouteMatch[]; export declare function useMatches(): RouteMatch[]; export declare type UseMatchType = () => RouteMatch; export declare function useMatch(): RouteMatch; export declare type UseNavigateType = (options: NavigateOptions) => void; export declare function useNavigate(): (args_0: BuildNextOptions & { replace?: boolean | undefined; fromCurrent?: boolean | undefined; } & { replace?: boolean | undefined; }) => void; export declare type NavigateType = (options: NavigateOptions) => null; export declare function Navigate(options: NavigateOptions): null; export declare type LinkType = (props: LinkProps) => JSX.Element; export declare const Link: = DefaultGenerics>({ to, search, hash, children, target, style, replace, onClick, onMouseEnter, className, getActiveProps, getInactiveProps, activeOptions, preload, disabled, _ref, ...rest }: LinkProps) => JSX.Element; export declare function Outlet(): JSX.Element | null; export declare function useResolvePath(): (path: string) => string; export declare type UseSearchType = () => Partial>>; export declare function useSearch(): Partial>>; export declare type MatchRouteType = (currentLocation: Location, matchLocation: MatchLocation) => UseGeneric | undefined; export declare function matchRoute(currentLocation: Location, matchLocation: MatchLocation): UseGeneric | undefined; export declare type UseMatchRouteType = () => (matchLocation: MatchLocation) => Maybe> | undefined; export declare type UseMatchRouteOptions = MatchLocation & { pending?: boolean; }; export declare function useMatchRoute(): (matchLocation: UseMatchRouteOptions, opts?: { caseSensitive?: boolean; }) => Maybe> | undefined; export declare function MatchRoute({ children, ...rest }: UseMatchRouteOptions & { children: React.ReactNode | ((isNextLocation?: Params) => React.ReactNode); }): any; export declare function usePrompt(message: string, when: boolean | any): void; export declare function Prompt({ message, when, children }: PromptProps): React.ReactNode; export declare function functionalUpdate(updater?: Updater, previous?: TResult): TResult | undefined; export declare function cleanPath(path: string): string; export declare function matchByPath(currentLocation: Location, matchLocation: MatchLocation): UseGeneric | undefined; export declare function parsePathname(pathname?: string): Segment[]; export declare function resolvePath(basepath: string, base: string, to: string): string; export declare const defaultParseSearch: (searchStr: string) => Record; export declare const defaultStringifySearch: (search: Record) => string; export declare function parseSearchWith(parser: (str: string) => any): (searchStr: string) => Record; export declare function stringifySearchWith(stringify: (search: any) => string): (search: Record) => string;