UNPKG

4.19 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 unstable_flushSync?: boolean;
59 unstable_viewTransition?: boolean;
60}
61/**
62 * A Navigator is a "location changer"; it's how you get to different locations.
63 *
64 * Every history instance conforms to the Navigator interface, but the
65 * distinction is useful primarily when it comes to the low-level `<Router>` API
66 * where both the location and a navigator must be provided separately in order
67 * to avoid "tearing" that may occur in a suspense-enabled app if the action
68 * and/or location were to be read directly from the history instance.
69 */
70export interface Navigator {
71 createHref: History["createHref"];
72 encodeLocation?: History["encodeLocation"];
73 go: History["go"];
74 push(to: To, state?: any, opts?: NavigateOptions): void;
75 replace(to: To, state?: any, opts?: NavigateOptions): void;
76}
77interface NavigationContextObject {
78 basename: string;
79 navigator: Navigator;
80 static: boolean;
81}
82export declare const NavigationContext: React.Context<NavigationContextObject>;
83interface LocationContextObject {
84 location: Location;
85 navigationType: NavigationType;
86}
87export declare const LocationContext: React.Context<LocationContextObject>;
88export interface RouteContextObject {
89 outlet: React.ReactElement | null;
90 matches: RouteMatch[];
91 isDataRoute: boolean;
92}
93export declare const RouteContext: React.Context<RouteContextObject>;
94export declare const RouteErrorContext: React.Context<any>;
95export {};