UNPKG

4.33 kBTypeScriptView Raw
1
2import { Action, History, Location, To } from "./router/history.js";
3import { RouteMatch, TrackedPromise } from "./router/utils.js";
4import { RelativeRoutingType, Router, RouterState, 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>;
15declare const DataRouterStateContext: React$1.Context<RouterState | null>;
16type ViewTransitionContextObject = {
17 isTransitioning: false;
18} | {
19 isTransitioning: true;
20 flushSync: boolean;
21 currentLocation: Location;
22 nextLocation: Location;
23};
24declare const ViewTransitionContext: React$1.Context<ViewTransitionContextObject>;
25type FetchersContextObject = Map<string, any>;
26declare const FetchersContext: React$1.Context<FetchersContextObject>;
27declare const AwaitContext: React$1.Context<TrackedPromise | null>;
28declare const AwaitContextProvider: (props: React$1.ComponentProps<typeof AwaitContext.Provider>) => React$1.FunctionComponentElement<React$1.ProviderProps<TrackedPromise | null>>;
29interface NavigateOptions {
30 /** Replace the current entry in the history stack instead of pushing a new one */
31 replace?: boolean;
32 /** Masked URL */
33 mask?: To;
34 /** Adds persistent client side routing state to the next location */
35 state?: any;
36 /** If you are using {@link ScrollRestoration `<ScrollRestoration>`}, prevent the scroll position from being reset to the top of the window when navigating */
37 preventScrollReset?: boolean;
38 /** 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. */
39 relative?: RelativeRoutingType;
40 /** 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} */
41 flushSync?: boolean;
42 /** Enables a {@link https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API View Transition} for this navigation by wrapping the final state update in `document.startViewTransition()`. If you need to apply specific styles for this view transition, you will also need to leverage the {@link useViewTransitionState `useViewTransitionState()`} hook. */
43 viewTransition?: boolean;
44 /** Specifies the default revalidation behavior after this submission */
45 defaultShouldRevalidate?: boolean;
46}
47/**
48 * A Navigator is a "location changer"; it's how you get to different locations.
49 *
50 * Every history instance conforms to the Navigator interface, but the
51 * distinction is useful primarily when it comes to the low-level `<Router>` API
52 * where both the location and a navigator must be provided separately in order
53 * to avoid "tearing" that may occur in a suspense-enabled app if the action
54 * and/or location were to be read directly from the history instance.
55 */
56interface Navigator {
57 createHref: History["createHref"];
58 encodeLocation?: History["encodeLocation"];
59 go: History["go"];
60 push(to: To, state?: any, opts?: NavigateOptions): void;
61 replace(to: To, state?: any, opts?: NavigateOptions): void;
62}
63interface NavigationContextObject {
64 basename: string;
65 navigator: Navigator;
66 static: boolean;
67 useTransitions: boolean | undefined;
68 future: {};
69}
70declare const NavigationContext: React$1.Context<NavigationContextObject>;
71interface LocationContextObject {
72 location: Location;
73 navigationType: Action;
74}
75declare const LocationContext: React$1.Context<LocationContextObject>;
76interface RouteContextObject {
77 outlet: React$1.ReactElement | null;
78 matches: RouteMatch[];
79 isDataRoute: boolean;
80}
81declare const RouteContext: React$1.Context<RouteContextObject>;
82//#endregion
83export { AwaitContextProvider, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigateOptions, NavigationContext, Navigator, RouteContext, ViewTransitionContext };
\No newline at end of file