UNPKG

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