UNPKG

3.9 kBTypeScriptView Raw
1import * as React from "react";
2import type { AgnosticRouteMatch, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, History, Location, Router, StaticHandlerContext, To, TrackedPromise } from "@remix-run/router";
3import type { Action as NavigationType } from "@remix-run/router";
4export interface IndexRouteObject {
5 caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
6 path?: AgnosticIndexRouteObject["path"];
7 id?: AgnosticIndexRouteObject["id"];
8 loader?: AgnosticIndexRouteObject["loader"];
9 action?: AgnosticIndexRouteObject["action"];
10 hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
11 shouldRevalidate?: AgnosticIndexRouteObject["shouldRevalidate"];
12 handle?: AgnosticIndexRouteObject["handle"];
13 index: true;
14 children?: undefined;
15 element?: React.ReactNode | null;
16 errorElement?: React.ReactNode | null;
17}
18export interface NonIndexRouteObject {
19 caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
20 path?: AgnosticNonIndexRouteObject["path"];
21 id?: AgnosticNonIndexRouteObject["id"];
22 loader?: AgnosticNonIndexRouteObject["loader"];
23 action?: AgnosticNonIndexRouteObject["action"];
24 hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
25 shouldRevalidate?: AgnosticNonIndexRouteObject["shouldRevalidate"];
26 handle?: AgnosticNonIndexRouteObject["handle"];
27 index?: false;
28 children?: RouteObject[];
29 element?: React.ReactNode | null;
30 errorElement?: React.ReactNode | null;
31}
32export declare type RouteObject = IndexRouteObject | NonIndexRouteObject;
33export declare type DataRouteObject = RouteObject & {
34 children?: DataRouteObject[];
35 id: string;
36};
37export interface RouteMatch<ParamKey extends string = string, RouteObjectType extends RouteObject = RouteObject> extends AgnosticRouteMatch<ParamKey, RouteObjectType> {
38}
39export interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
40}
41export interface DataRouterContextObject extends NavigationContextObject {
42 router: Router;
43 staticContext?: StaticHandlerContext;
44}
45export declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
46export declare const DataRouterStateContext: React.Context<import("@remix-run/router").RouterState | null>;
47export declare const AwaitContext: React.Context<TrackedPromise | null>;
48export declare type RelativeRoutingType = "route" | "path";
49export interface NavigateOptions {
50 replace?: boolean;
51 state?: any;
52 preventScrollReset?: boolean;
53 relative?: RelativeRoutingType;
54}
55/**
56 * A Navigator is a "location changer"; it's how you get to different locations.
57 *
58 * Every history instance conforms to the Navigator interface, but the
59 * distinction is useful primarily when it comes to the low-level <Router> API
60 * where both the location and a navigator must be provided separately in order
61 * to avoid "tearing" that may occur in a suspense-enabled app if the action
62 * and/or location were to be read directly from the history instance.
63 */
64export interface Navigator {
65 createHref: History["createHref"];
66 encodeLocation?: History["encodeLocation"];
67 go: History["go"];
68 push(to: To, state?: any, opts?: NavigateOptions): void;
69 replace(to: To, state?: any, opts?: NavigateOptions): void;
70}
71interface NavigationContextObject {
72 basename: string;
73 navigator: Navigator;
74 static: boolean;
75}
76export declare const NavigationContext: React.Context<NavigationContextObject>;
77interface LocationContextObject {
78 location: Location;
79 navigationType: NavigationType;
80}
81export declare const LocationContext: React.Context<LocationContextObject>;
82export interface RouteContextObject {
83 outlet: React.ReactElement | null;
84 matches: RouteMatch[];
85}
86export declare const RouteContext: React.Context<RouteContextObject>;
87export declare const RouteErrorContext: React.Context<any>;
88export {};