UNPKG

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