INDIE UNPKG

4.87 kBTypeScriptView Raw
1
2import { Action, History, Location, To } from "./router/history.js";
3import { RouteMatch, TrackedPromise } from "./router/utils.js";
4import { RelativeRoutingType, Router, StaticHandlerContext } from "./router/router.js";
5import { ClientOnErrorFunction } from "./components.js";
6import * as React$1 from "react";
7
8//#region lib/context.d.ts
9interface DataRouterContextObject extends Omit<NavigationContextObject, "future" | "useTransitions"> {
10 router: Router;
11 staticContext?: StaticHandlerContext;
12 onError?: ClientOnErrorFunction;
13}
14declare const DataRouterContext: React$1.Context<DataRouterContextObject | null>;
15type DataRouterDataContextObject = Pick<Router["state"], "loaderData" | "actionData" | "errors">;
16type DataRouterNavigationContextObject = Pick<Router["state"], "navigation" | "revalidation">;
17type DataRouterStateContextObject = Omit<Router["state"], keyof DataRouterDataContextObject | keyof DataRouterNavigationContextObject | "fetchers">;
18declare const DataRouterStateContext: React$1.Context<DataRouterStateContextObject | null>;
19declare const DataRouterDataContext: React$1.Context<DataRouterDataContextObject | null>;
20declare const DataRouterNavigationContext: React$1.Context<DataRouterNavigationContextObject | null>;
21type ViewTransitionContextObject = {
22 isTransitioning: false;
23} | {
24 isTransitioning: true;
25 flushSync: boolean;
26 currentLocation: Location;
27 nextLocation: Location;
28};
29declare const ViewTransitionContext: React$1.Context<ViewTransitionContextObject>;
30type FetchersContextObject = {
31 fetchers: Router["state"]["fetchers"];
32 fetcherData: Map<string, any>;
33};
34declare const FetchersContext: React$1.Context<FetchersContextObject | null>;
35declare const AwaitContext: React$1.Context<TrackedPromise | null>;
36declare const AwaitContextProvider: (props: React$1.ComponentProps<typeof AwaitContext.Provider>) => React$1.FunctionComponentElement<React$1.ProviderProps<TrackedPromise | null>>;
37interface NavigateOptions {
38 /** Replace the current entry in the history stack instead of pushing a new one */
39 replace?: boolean;
40 /** Masked URL */
41 mask?: To;
42 /** Adds persistent client side routing state to the next location */
43 state?: any;
44 /** If you are using {@link ScrollRestoration `<ScrollRestoration>`}, prevent the scroll position from being reset to the top of the window when navigating */
45 preventScrollReset?: boolean;
46 /** Defines the relative path behavior for the link. "route" will use the route hierarchy so ".." will remove all URL segments of the current route pattern while "path" will use the URL path so ".." will remove one URL segment. */
47 relative?: RelativeRoutingType;
48 /** Wraps the initial state update for this navigation in a {@link https://react.dev/reference/react-dom/flushSync ReactDOM.flushSync} call instead of the default {@link https://react.dev/reference/react/startTransition React.startTransition} */
49 flushSync?: boolean;
50 /**
51 * Enables a view transition for this navigation.
52 *
53 * @deprecated Use React's `<ViewTransition>` component instead. See the
54 * [migration guide](https://reactrouter.com/how-to/view-transitions).
55 */
56 viewTransition?: boolean;
57 /** Specifies the default revalidation behavior after this submission */
58 defaultShouldRevalidate?: boolean;
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 */
69interface Navigator {
70 createHref: History["createHref"];
71 createURL?: History["createURL"];
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 useTransitions: boolean | undefined;
82 future: {};
83}
84declare const NavigationContext: React$1.Context<NavigationContextObject>;
85interface LocationContextObject {
86 location: Location;
87 navigationType: Action;
88}
89declare const LocationContext: React$1.Context<LocationContextObject>;
90interface RouteContextObject {
91 outlet: React$1.ReactElement | null;
92 matches: RouteMatch[];
93 isDataRoute: boolean;
94}
95declare const RouteContext: React$1.Context<RouteContextObject>;
96//#endregion
97export { AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigateOptions, NavigationContext, Navigator, RouteContext, ViewTransitionContext };
\No newline at end of file