UNPKG

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