react-router 0.0.0-experimental-c7dd3d3a → 0.0.0-experimental-e53172d16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +1 -10
- package/dist/index.d.ts +37 -16
- package/dist/index.js +9809 -1087
- package/dist/index.js.map +1 -1
- package/dist/lib/components.d.ts +13 -2
- package/dist/lib/context.d.ts +2 -2
- package/dist/lib/dom/dom.d.ts +104 -0
- package/dist/lib/dom/global.d.ts +36 -0
- package/dist/lib/dom/lib.d.ts +304 -0
- package/dist/lib/dom/server.d.ts +32 -0
- package/dist/lib/dom/ssr/browser.d.ts +3 -0
- package/dist/lib/dom/ssr/components.d.ts +61 -0
- package/dist/lib/dom/ssr/create-remix-stub.d.ts +56 -0
- package/dist/lib/dom/ssr/data.d.ts +16 -0
- package/dist/lib/dom/ssr/errorBoundaries.d.ts +33 -0
- package/dist/lib/dom/ssr/errors.d.ts +2 -0
- package/dist/lib/dom/ssr/fallback.d.ts +2 -0
- package/dist/lib/dom/ssr/invariant.d.ts +2 -0
- package/dist/lib/dom/ssr/links.d.ts +127 -0
- package/dist/lib/dom/ssr/markup.d.ts +5 -0
- package/dist/lib/dom/ssr/routeModules.d.ts +141 -0
- package/dist/lib/dom/ssr/routes.d.ts +32 -0
- package/dist/lib/dom/ssr/server.d.ts +13 -0
- package/dist/lib/dom/ssr/single-fetch.d.ts +36 -0
- package/dist/lib/hooks.d.ts +3 -3
- package/dist/lib/router/history.d.ts +250 -0
- package/dist/lib/router/index.d.ts +9 -0
- package/dist/lib/router/router.d.ts +512 -0
- package/dist/lib/router/utils.d.ts +520 -0
- package/dist/main.js +1 -1
- package/dist/react-router.development.js +10495 -1126
- package/dist/react-router.development.js.map +1 -1
- package/dist/react-router.production.min.js +2 -2
- package/dist/react-router.production.min.js.map +1 -1
- package/dist/umd/react-router.development.js +10876 -1287
- package/dist/umd/react-router.development.js.map +1 -1
- package/dist/umd/react-router.production.min.js +2 -2
- package/dist/umd/react-router.production.min.js.map +1 -1
- package/package.json +12 -5
package/dist/lib/components.d.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import type { InitialEntry, LazyRouteFunction, Location, RelativeRoutingType, Router as RemixRouter, To, TrackedPromise } from "
|
|
2
|
-
import { Action as NavigationType } from "
|
|
1
|
+
import type { FutureConfig as RouterFutureConfig, HydrationState, InitialEntry, LazyRouteFunction, Location, RelativeRoutingType, Router as RemixRouter, To, TrackedPromise, unstable_DataStrategyFunction } from "./router";
|
|
2
|
+
import { Action as NavigationType } from "./router";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import type { IndexRouteObject, Navigator, NonIndexRouteObject, RouteMatch, RouteObject } from "./context";
|
|
5
5
|
export interface FutureConfig {
|
|
6
6
|
v7_relativeSplatPath: boolean;
|
|
7
7
|
v7_startTransition: boolean;
|
|
8
8
|
}
|
|
9
|
+
export declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
|
|
10
|
+
hasErrorBoundary: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function createMemoryRouter(routes: RouteObject[], opts?: {
|
|
13
|
+
basename?: string;
|
|
14
|
+
future?: Partial<Omit<RouterFutureConfig, "v7_prependBasename">>;
|
|
15
|
+
hydrationData?: HydrationState;
|
|
16
|
+
initialEntries?: InitialEntry[];
|
|
17
|
+
initialIndex?: number;
|
|
18
|
+
unstable_dataStrategy?: unstable_DataStrategyFunction;
|
|
19
|
+
}): RemixRouter;
|
|
9
20
|
export interface RouterProviderProps {
|
|
10
21
|
fallbackElement?: React.ReactNode;
|
|
11
22
|
router: RemixRouter;
|
package/dist/lib/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type { AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticRouteMatch, History, LazyRouteFunction, Location, Action as NavigationType, RelativeRoutingType, Router, StaticHandlerContext, To, TrackedPromise } from "
|
|
2
|
+
import type { AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticRouteMatch, History, LazyRouteFunction, Location, Action as NavigationType, RelativeRoutingType, Router, StaticHandlerContext, To, TrackedPromise } from "./router";
|
|
3
3
|
export interface IndexRouteObject {
|
|
4
4
|
caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
|
|
5
5
|
path?: AgnosticIndexRouteObject["path"];
|
|
@@ -52,7 +52,7 @@ export interface DataRouterContextObject extends Omit<NavigationContextObject, "
|
|
|
52
52
|
staticContext?: StaticHandlerContext;
|
|
53
53
|
}
|
|
54
54
|
export declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
|
|
55
|
-
export declare const DataRouterStateContext: React.Context<import("
|
|
55
|
+
export declare const DataRouterStateContext: React.Context<import("./router").RouterState | null>;
|
|
56
56
|
export declare const AwaitContext: React.Context<TrackedPromise | null>;
|
|
57
57
|
export interface NavigateOptions {
|
|
58
58
|
replace?: boolean;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { FormEncType, HTMLFormMethod, RelativeRoutingType } from "../router";
|
|
2
|
+
export declare const defaultMethod: HTMLFormMethod;
|
|
3
|
+
export declare function isHtmlElement(object: any): object is HTMLElement;
|
|
4
|
+
export declare function isButtonElement(object: any): object is HTMLButtonElement;
|
|
5
|
+
export declare function isFormElement(object: any): object is HTMLFormElement;
|
|
6
|
+
export declare function isInputElement(object: any): object is HTMLInputElement;
|
|
7
|
+
type LimitedMouseEvent = Pick<MouseEvent, "button" | "metaKey" | "altKey" | "ctrlKey" | "shiftKey">;
|
|
8
|
+
export declare function shouldProcessLinkClick(event: LimitedMouseEvent, target?: string): boolean;
|
|
9
|
+
export type ParamKeyValuePair = [string, string];
|
|
10
|
+
export type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a URLSearchParams object using the given initializer.
|
|
13
|
+
*
|
|
14
|
+
* This is identical to `new URLSearchParams(init)` except it also
|
|
15
|
+
* supports arrays as values in the object form of the initializer
|
|
16
|
+
* instead of just strings. This is convenient when you need multiple
|
|
17
|
+
* values for a given key, but don't want to use an array initializer.
|
|
18
|
+
*
|
|
19
|
+
* For example, instead of:
|
|
20
|
+
*
|
|
21
|
+
* let searchParams = new URLSearchParams([
|
|
22
|
+
* ['sort', 'name'],
|
|
23
|
+
* ['sort', 'price']
|
|
24
|
+
* ]);
|
|
25
|
+
*
|
|
26
|
+
* you can do:
|
|
27
|
+
*
|
|
28
|
+
* let searchParams = createSearchParams({
|
|
29
|
+
* sort: ['name', 'price']
|
|
30
|
+
* });
|
|
31
|
+
*/
|
|
32
|
+
export declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
|
|
33
|
+
export declare function getSearchParamsForLocation(locationSearch: string, defaultSearchParams: URLSearchParams | null): URLSearchParams;
|
|
34
|
+
type JsonObject = {
|
|
35
|
+
[Key in string]: JsonValue;
|
|
36
|
+
} & {
|
|
37
|
+
[Key in string]?: JsonValue | undefined;
|
|
38
|
+
};
|
|
39
|
+
type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
40
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
41
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
42
|
+
export type SubmitTarget = HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | JsonValue | null;
|
|
43
|
+
export interface SubmitOptions {
|
|
44
|
+
/**
|
|
45
|
+
* The HTTP method used to submit the form. Overrides `<form method>`.
|
|
46
|
+
* Defaults to "GET".
|
|
47
|
+
*/
|
|
48
|
+
method?: HTMLFormMethod;
|
|
49
|
+
/**
|
|
50
|
+
* The action URL path used to submit the form. Overrides `<form action>`.
|
|
51
|
+
* Defaults to the path of the current route.
|
|
52
|
+
*/
|
|
53
|
+
action?: string;
|
|
54
|
+
/**
|
|
55
|
+
* The encoding used to submit the form. Overrides `<form encType>`.
|
|
56
|
+
* Defaults to "application/x-www-form-urlencoded".
|
|
57
|
+
*/
|
|
58
|
+
encType?: FormEncType;
|
|
59
|
+
/**
|
|
60
|
+
* Indicate a specific fetcherKey to use when using navigate=false
|
|
61
|
+
*/
|
|
62
|
+
fetcherKey?: string;
|
|
63
|
+
/**
|
|
64
|
+
* navigate=false will use a fetcher instead of a navigation
|
|
65
|
+
*/
|
|
66
|
+
navigate?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Set `true` to replace the current entry in the browser's history stack
|
|
69
|
+
* instead of creating a new one (i.e. stay on "the same page"). Defaults
|
|
70
|
+
* to `false`.
|
|
71
|
+
*/
|
|
72
|
+
replace?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* State object to add to the history stack entry for this navigation
|
|
75
|
+
*/
|
|
76
|
+
state?: any;
|
|
77
|
+
/**
|
|
78
|
+
* Determines whether the form action is relative to the route hierarchy or
|
|
79
|
+
* the pathname. Use this if you want to opt out of navigating the route
|
|
80
|
+
* hierarchy and want to instead route based on /-delimited URL segments
|
|
81
|
+
*/
|
|
82
|
+
relative?: RelativeRoutingType;
|
|
83
|
+
/**
|
|
84
|
+
* In browser-based environments, prevent resetting scroll after this
|
|
85
|
+
* navigation when using the <ScrollRestoration> component
|
|
86
|
+
*/
|
|
87
|
+
preventScrollReset?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Enable flushSync for this navigation's state updates
|
|
90
|
+
*/
|
|
91
|
+
unstable_flushSync?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Enable view transitions on this submission navigation
|
|
94
|
+
*/
|
|
95
|
+
unstable_viewTransition?: boolean;
|
|
96
|
+
}
|
|
97
|
+
export declare function getFormSubmissionInfo(target: SubmitTarget, basename: string): {
|
|
98
|
+
action: string | null;
|
|
99
|
+
method: string;
|
|
100
|
+
encType: string;
|
|
101
|
+
formData: FormData | undefined;
|
|
102
|
+
body: any;
|
|
103
|
+
};
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { HydrationState, Router as RemixRouter } from "../router";
|
|
2
|
+
import type { ViewTransition } from "./lib";
|
|
3
|
+
import type { AssetsManifest, FutureConfig as RemixFutureConfig } from "./ssr/entry";
|
|
4
|
+
import type { RouteModules } from "./ssr/routeModules";
|
|
5
|
+
export type WindowRemixContext = {
|
|
6
|
+
url: string;
|
|
7
|
+
basename?: string;
|
|
8
|
+
state: HydrationState;
|
|
9
|
+
criticalCss?: string;
|
|
10
|
+
future: RemixFutureConfig;
|
|
11
|
+
isSpaMode: boolean;
|
|
12
|
+
stream: ReadableStream<Uint8Array> | undefined;
|
|
13
|
+
streamController: ReadableStreamDefaultController<Uint8Array>;
|
|
14
|
+
a?: number;
|
|
15
|
+
dev?: {
|
|
16
|
+
port?: number;
|
|
17
|
+
hmrRuntime?: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
declare global {
|
|
21
|
+
var __staticRouterHydrationData: HydrationState | undefined;
|
|
22
|
+
var __reactRouterVersion: string;
|
|
23
|
+
interface Document {
|
|
24
|
+
startViewTransition(cb: () => Promise<void> | void): ViewTransition;
|
|
25
|
+
}
|
|
26
|
+
var __remixContext: WindowRemixContext | undefined;
|
|
27
|
+
var __remixManifest: AssetsManifest | undefined;
|
|
28
|
+
var __remixRouteModules: RouteModules | undefined;
|
|
29
|
+
var __remixRouter: RemixRouter | undefined;
|
|
30
|
+
var __remixRevalidation: number | undefined;
|
|
31
|
+
var __remixClearCriticalCss: (() => void) | undefined;
|
|
32
|
+
var $RefreshRuntime$: {
|
|
33
|
+
performReactRefresh: () => void;
|
|
34
|
+
} | undefined;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { unstable_DataStrategyFunction, Fetcher, FutureConfig as RouterFutureConfig, GetScrollRestorationKeyFunction, History, HTMLFormMethod, HydrationState, Router as RemixRouter, BlockerFunction, Location, RelativeRoutingType, To } from "../router";
|
|
3
|
+
import "./global";
|
|
4
|
+
import type { SubmitOptions, URLSearchParamsInit, SubmitTarget } from "./dom";
|
|
5
|
+
import type { PrefetchBehavior, ScriptProps } from "./ssr/components";
|
|
6
|
+
import type { RouterProviderProps, FutureConfig as RenderFutureConfig } from "../components";
|
|
7
|
+
import type { RouteObject, NavigateOptions } from "../context";
|
|
8
|
+
interface DOMRouterOpts {
|
|
9
|
+
basename?: string;
|
|
10
|
+
future?: Partial<Omit<RouterFutureConfig, "v7_prependBasename">>;
|
|
11
|
+
hydrationData?: HydrationState;
|
|
12
|
+
unstable_dataStrategy?: unstable_DataStrategyFunction;
|
|
13
|
+
window?: Window;
|
|
14
|
+
}
|
|
15
|
+
export declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): RemixRouter;
|
|
16
|
+
export declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): RemixRouter;
|
|
17
|
+
type ViewTransitionContextObject = {
|
|
18
|
+
isTransitioning: false;
|
|
19
|
+
} | {
|
|
20
|
+
isTransitioning: true;
|
|
21
|
+
flushSync: boolean;
|
|
22
|
+
currentLocation: Location;
|
|
23
|
+
nextLocation: Location;
|
|
24
|
+
};
|
|
25
|
+
declare const ViewTransitionContext: React.Context<ViewTransitionContextObject>;
|
|
26
|
+
export { ViewTransitionContext as UNSAFE_ViewTransitionContext };
|
|
27
|
+
type FetchersContextObject = Map<string, any>;
|
|
28
|
+
declare const FetchersContext: React.Context<FetchersContextObject>;
|
|
29
|
+
export { FetchersContext as UNSAFE_FetchersContext };
|
|
30
|
+
export interface ViewTransition {
|
|
31
|
+
finished: Promise<void>;
|
|
32
|
+
ready: Promise<void>;
|
|
33
|
+
updateCallbackDone: Promise<void>;
|
|
34
|
+
skipTransition(): void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Given a Remix Router instance, render the appropriate UI
|
|
38
|
+
*/
|
|
39
|
+
export declare function RouterProvider({ fallbackElement, router, future, }: RouterProviderProps): React.ReactElement;
|
|
40
|
+
export interface BrowserRouterProps {
|
|
41
|
+
basename?: string;
|
|
42
|
+
children?: React.ReactNode;
|
|
43
|
+
future?: Partial<RenderFutureConfig>;
|
|
44
|
+
window?: Window;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A `<Router>` for use in web browsers. Provides the cleanest URLs.
|
|
48
|
+
*/
|
|
49
|
+
export declare function BrowserRouter({ basename, children, future, window, }: BrowserRouterProps): React.JSX.Element;
|
|
50
|
+
export interface HashRouterProps {
|
|
51
|
+
basename?: string;
|
|
52
|
+
children?: React.ReactNode;
|
|
53
|
+
future?: Partial<RenderFutureConfig>;
|
|
54
|
+
window?: Window;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A `<Router>` for use in web browsers. Stores the location in the hash
|
|
58
|
+
* portion of the URL so it is not sent to the server.
|
|
59
|
+
*/
|
|
60
|
+
export declare function HashRouter({ basename, children, future, window, }: HashRouterProps): React.JSX.Element;
|
|
61
|
+
export interface HistoryRouterProps {
|
|
62
|
+
basename?: string;
|
|
63
|
+
children?: React.ReactNode;
|
|
64
|
+
future?: RenderFutureConfig;
|
|
65
|
+
history: History;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A `<Router>` that accepts a pre-instantiated history object. It's important
|
|
69
|
+
* to note that using your own history object is highly discouraged and may add
|
|
70
|
+
* two versions of the history library to your bundles unless you use the same
|
|
71
|
+
* version of the history library that React Router uses internally.
|
|
72
|
+
*/
|
|
73
|
+
declare function HistoryRouter({ basename, children, future, history, }: HistoryRouterProps): React.JSX.Element;
|
|
74
|
+
declare namespace HistoryRouter {
|
|
75
|
+
var displayName: string;
|
|
76
|
+
}
|
|
77
|
+
export { HistoryRouter as unstable_HistoryRouter };
|
|
78
|
+
export interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
|
|
79
|
+
prefetch?: PrefetchBehavior;
|
|
80
|
+
reloadDocument?: boolean;
|
|
81
|
+
replace?: boolean;
|
|
82
|
+
state?: any;
|
|
83
|
+
preventScrollReset?: boolean;
|
|
84
|
+
relative?: RelativeRoutingType;
|
|
85
|
+
to: To;
|
|
86
|
+
unstable_viewTransition?: boolean;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The public API for rendering a history-aware `<a>`.
|
|
90
|
+
*/
|
|
91
|
+
export declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
92
|
+
type NavLinkRenderProps = {
|
|
93
|
+
isActive: boolean;
|
|
94
|
+
isPending: boolean;
|
|
95
|
+
isTransitioning: boolean;
|
|
96
|
+
};
|
|
97
|
+
export interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
|
|
98
|
+
children?: React.ReactNode | ((props: NavLinkRenderProps) => React.ReactNode);
|
|
99
|
+
caseSensitive?: boolean;
|
|
100
|
+
className?: string | ((props: NavLinkRenderProps) => string | undefined);
|
|
101
|
+
end?: boolean;
|
|
102
|
+
style?: React.CSSProperties | ((props: NavLinkRenderProps) => React.CSSProperties | undefined);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A `<Link>` wrapper that knows if it's "active" or not.
|
|
106
|
+
*/
|
|
107
|
+
export declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
108
|
+
export interface FetcherFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
|
|
109
|
+
/**
|
|
110
|
+
* The HTTP verb to use when the form is submit. Supports "get", "post",
|
|
111
|
+
* "put", "delete", "patch".
|
|
112
|
+
*/
|
|
113
|
+
method?: HTMLFormMethod;
|
|
114
|
+
/**
|
|
115
|
+
* `<form encType>` - enhancing beyond the normal string type and limiting
|
|
116
|
+
* to the built-in browser supported values
|
|
117
|
+
*/
|
|
118
|
+
encType?: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
|
|
119
|
+
/**
|
|
120
|
+
* Normal `<form action>` but supports React Router's relative paths.
|
|
121
|
+
*/
|
|
122
|
+
action?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Determines whether the form action is relative to the route hierarchy or
|
|
125
|
+
* the pathname. Use this if you want to opt out of navigating the route
|
|
126
|
+
* hierarchy and want to instead route based on /-delimited URL segments
|
|
127
|
+
*/
|
|
128
|
+
relative?: RelativeRoutingType;
|
|
129
|
+
/**
|
|
130
|
+
* Prevent the scroll position from resetting to the top of the viewport on
|
|
131
|
+
* completion of the navigation when using the <ScrollRestoration> component
|
|
132
|
+
*/
|
|
133
|
+
preventScrollReset?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* A function to call when the form is submitted. If you call
|
|
136
|
+
* `event.preventDefault()` then this form will not do anything.
|
|
137
|
+
*/
|
|
138
|
+
onSubmit?: React.FormEventHandler<HTMLFormElement>;
|
|
139
|
+
}
|
|
140
|
+
export interface FormProps extends FetcherFormProps {
|
|
141
|
+
/**
|
|
142
|
+
* Indicate a specific fetcherKey to use when using navigate=false
|
|
143
|
+
*/
|
|
144
|
+
fetcherKey?: string;
|
|
145
|
+
/**
|
|
146
|
+
* navigate=false will use a fetcher instead of a navigation
|
|
147
|
+
*/
|
|
148
|
+
navigate?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Forces a full document navigation instead of a fetch.
|
|
151
|
+
*/
|
|
152
|
+
reloadDocument?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Replaces the current entry in the browser history stack when the form
|
|
155
|
+
* navigates. Use this if you don't want the user to be able to click "back"
|
|
156
|
+
* to the page with the form on it.
|
|
157
|
+
*/
|
|
158
|
+
replace?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* State object to add to the history stack entry for this navigation
|
|
161
|
+
*/
|
|
162
|
+
state?: any;
|
|
163
|
+
/**
|
|
164
|
+
* Enable view transitions on this Form navigation
|
|
165
|
+
*/
|
|
166
|
+
unstable_viewTransition?: boolean;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* A `@remix-run/router`-aware `<form>`. It behaves like a normal form except
|
|
170
|
+
* that the interaction with the server is with `fetch` instead of new document
|
|
171
|
+
* requests, allowing components to add nicer UX to the page as the form is
|
|
172
|
+
* submitted and returns with data.
|
|
173
|
+
*/
|
|
174
|
+
export declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
|
|
175
|
+
export type ScrollRestorationProps = ScriptProps & {
|
|
176
|
+
getKey?: GetScrollRestorationKeyFunction;
|
|
177
|
+
storageKey?: string;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* This component will emulate the browser's scroll restoration on location
|
|
181
|
+
* changes.
|
|
182
|
+
*/
|
|
183
|
+
export declare function ScrollRestoration({ getKey, storageKey, ...props }: ScrollRestorationProps): React.JSX.Element | null;
|
|
184
|
+
export declare namespace ScrollRestoration {
|
|
185
|
+
var displayName: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Handles the click behavior for router `<Link>` components. This is useful if
|
|
189
|
+
* you need to create custom `<Link>` components with the same click behavior we
|
|
190
|
+
* use in our exported `<Link>`.
|
|
191
|
+
*/
|
|
192
|
+
export declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, unstable_viewTransition, }?: {
|
|
193
|
+
target?: React.HTMLAttributeAnchorTarget;
|
|
194
|
+
replace?: boolean;
|
|
195
|
+
state?: any;
|
|
196
|
+
preventScrollReset?: boolean;
|
|
197
|
+
relative?: RelativeRoutingType;
|
|
198
|
+
unstable_viewTransition?: boolean;
|
|
199
|
+
}): (event: React.MouseEvent<E, MouseEvent>) => void;
|
|
200
|
+
/**
|
|
201
|
+
* A convenient wrapper for reading and writing search parameters via the
|
|
202
|
+
* URLSearchParams interface.
|
|
203
|
+
*/
|
|
204
|
+
export declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URLSearchParams, SetURLSearchParams];
|
|
205
|
+
export type SetURLSearchParams = (nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit), navigateOpts?: NavigateOptions) => void;
|
|
206
|
+
/**
|
|
207
|
+
* Submits a HTML `<form>` to the server without reloading the page.
|
|
208
|
+
*/
|
|
209
|
+
export interface SubmitFunction {
|
|
210
|
+
(
|
|
211
|
+
/**
|
|
212
|
+
* Specifies the `<form>` to be submitted to the server, a specific
|
|
213
|
+
* `<button>` or `<input type="submit">` to use to submit the form, or some
|
|
214
|
+
* arbitrary data to submit.
|
|
215
|
+
*
|
|
216
|
+
* Note: When using a `<button>` its `name` and `value` will also be
|
|
217
|
+
* included in the form data that is submitted.
|
|
218
|
+
*/
|
|
219
|
+
target: SubmitTarget,
|
|
220
|
+
/**
|
|
221
|
+
* Options that override the `<form>`'s own attributes. Required when
|
|
222
|
+
* submitting arbitrary data without a backing `<form>`.
|
|
223
|
+
*/
|
|
224
|
+
options?: SubmitOptions): void;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Submits a fetcher `<form>` to the server without reloading the page.
|
|
228
|
+
*/
|
|
229
|
+
export interface FetcherSubmitFunction {
|
|
230
|
+
(target: SubmitTarget, options?: Omit<SubmitOptions, "replace" | "state">): void;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Returns a function that may be used to programmatically submit a form (or
|
|
234
|
+
* some arbitrary data) to the server.
|
|
235
|
+
*/
|
|
236
|
+
export declare function useSubmit(): SubmitFunction;
|
|
237
|
+
export declare function useFormAction(action?: string, { relative }?: {
|
|
238
|
+
relative?: RelativeRoutingType;
|
|
239
|
+
}): string;
|
|
240
|
+
export type FetcherWithComponents<TData> = Fetcher<TData> & {
|
|
241
|
+
Form: React.ForwardRefExoticComponent<FetcherFormProps & React.RefAttributes<HTMLFormElement>>;
|
|
242
|
+
submit: FetcherSubmitFunction;
|
|
243
|
+
load: (href: string, opts?: {
|
|
244
|
+
unstable_flushSync?: boolean;
|
|
245
|
+
}) => void;
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Interacts with route loaders and actions without causing a navigation. Great
|
|
249
|
+
* for any interaction that stays on the same page.
|
|
250
|
+
*/
|
|
251
|
+
export declare function useFetcher<TData = any>({ key, }?: {
|
|
252
|
+
key?: string;
|
|
253
|
+
}): FetcherWithComponents<TData>;
|
|
254
|
+
/**
|
|
255
|
+
* Provides all fetchers currently on the page. Useful for layouts and parent
|
|
256
|
+
* routes that need to provide pending/optimistic UI regarding the fetch.
|
|
257
|
+
*/
|
|
258
|
+
export declare function useFetchers(): (Fetcher & {
|
|
259
|
+
key: string;
|
|
260
|
+
})[];
|
|
261
|
+
/**
|
|
262
|
+
* When rendered inside a RouterProvider, will restore scroll positions on navigations
|
|
263
|
+
*/
|
|
264
|
+
declare function useScrollRestoration({ getKey, storageKey, }?: {
|
|
265
|
+
getKey?: GetScrollRestorationKeyFunction;
|
|
266
|
+
storageKey?: string;
|
|
267
|
+
}): void;
|
|
268
|
+
export { useScrollRestoration as UNSAFE_useScrollRestoration };
|
|
269
|
+
/**
|
|
270
|
+
* Setup a callback to be fired on the window's `beforeunload` event. This is
|
|
271
|
+
* useful for saving some data to `window.localStorage` just before the page
|
|
272
|
+
* refreshes.
|
|
273
|
+
*
|
|
274
|
+
* Note: The `callback` argument should be a function created with
|
|
275
|
+
* `React.useCallback()`.
|
|
276
|
+
*/
|
|
277
|
+
export declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any, options?: {
|
|
278
|
+
capture?: boolean;
|
|
279
|
+
}): void;
|
|
280
|
+
/**
|
|
281
|
+
* Wrapper around useBlocker to show a window.confirm prompt to users instead
|
|
282
|
+
* of building a custom UI with useBlocker.
|
|
283
|
+
*
|
|
284
|
+
* Warning: This has *a lot of rough edges* and behaves very differently (and
|
|
285
|
+
* very incorrectly in some cases) across browsers if user click addition
|
|
286
|
+
* back/forward navigations while the confirm is open. Use at your own risk.
|
|
287
|
+
*/
|
|
288
|
+
declare function usePrompt({ when, message, }: {
|
|
289
|
+
when: boolean | BlockerFunction;
|
|
290
|
+
message: string;
|
|
291
|
+
}): void;
|
|
292
|
+
export { usePrompt as unstable_usePrompt };
|
|
293
|
+
/**
|
|
294
|
+
* Return a boolean indicating if there is an active view transition to the
|
|
295
|
+
* given href. You can use this value to render CSS classes or viewTransitionName
|
|
296
|
+
* styles onto your elements
|
|
297
|
+
*
|
|
298
|
+
* @param href The destination href
|
|
299
|
+
* @param [opts.relative] Relative routing type ("route" | "path")
|
|
300
|
+
*/
|
|
301
|
+
declare function useViewTransitionState(to: To, opts?: {
|
|
302
|
+
relative?: RelativeRoutingType;
|
|
303
|
+
}): boolean;
|
|
304
|
+
export { useViewTransitionState as unstable_useViewTransitionState };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Location, Router as RemixRouter, StaticHandlerContext, CreateStaticHandlerOptions as RouterCreateStaticHandlerOptions, FutureConfig as RouterFutureConfig } from "../router";
|
|
3
|
+
import { type FutureConfig } from "../components";
|
|
4
|
+
import type { RouteObject } from "../context";
|
|
5
|
+
export interface StaticRouterProps {
|
|
6
|
+
basename?: string;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
location: Partial<Location> | string;
|
|
9
|
+
future?: Partial<FutureConfig>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A `<Router>` that may not navigate to any other location. This is useful
|
|
13
|
+
* on the server where there is no stateful UI.
|
|
14
|
+
*/
|
|
15
|
+
export declare function StaticRouter({ basename, children, location: locationProp, future, }: StaticRouterProps): React.JSX.Element;
|
|
16
|
+
export interface StaticRouterProviderProps {
|
|
17
|
+
context: StaticHandlerContext;
|
|
18
|
+
router: RemixRouter;
|
|
19
|
+
hydrate?: boolean;
|
|
20
|
+
nonce?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A Data Router that may not navigate to any other location. This is useful
|
|
24
|
+
* on the server where there is no stateful UI.
|
|
25
|
+
*/
|
|
26
|
+
export declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): React.JSX.Element;
|
|
27
|
+
type CreateStaticHandlerOptions = Omit<RouterCreateStaticHandlerOptions, "detectErrorBoundary" | "mapRouteProperties">;
|
|
28
|
+
export declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): import("../router").StaticHandler;
|
|
29
|
+
export declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
|
|
30
|
+
future?: Partial<Pick<RouterFutureConfig, "v7_partialHydration" | "v7_relativeSplatPath">>;
|
|
31
|
+
}): RemixRouter;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { FocusEventHandler, MouseEventHandler, TouchEventHandler } from "react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import type { RemixContextObject } from "./entry";
|
|
4
|
+
import type { PrefetchPageDescriptor } from "./links";
|
|
5
|
+
export type SerializeFrom<D> = D extends () => {} ? Awaited<ReturnType<D>> : D;
|
|
6
|
+
export declare const RemixContext: React.Context<RemixContextObject | undefined>;
|
|
7
|
+
export declare function useRemixContext(): RemixContextObject;
|
|
8
|
+
/**
|
|
9
|
+
* Defines the prefetching behavior of the link:
|
|
10
|
+
*
|
|
11
|
+
* - "none": Never fetched
|
|
12
|
+
* - "intent": Fetched when the user focuses or hovers the link
|
|
13
|
+
* - "render": Fetched when the link is rendered
|
|
14
|
+
* - "viewport": Fetched when the link is in the viewport
|
|
15
|
+
*/
|
|
16
|
+
export type PrefetchBehavior = "intent" | "render" | "none" | "viewport";
|
|
17
|
+
interface PrefetchHandlers {
|
|
18
|
+
onFocus?: FocusEventHandler;
|
|
19
|
+
onBlur?: FocusEventHandler;
|
|
20
|
+
onMouseEnter?: MouseEventHandler;
|
|
21
|
+
onMouseLeave?: MouseEventHandler;
|
|
22
|
+
onTouchStart?: TouchEventHandler;
|
|
23
|
+
}
|
|
24
|
+
export declare function usePrefetchBehavior<T extends HTMLAnchorElement>(prefetch: PrefetchBehavior, theirElementProps: PrefetchHandlers): [boolean, React.RefObject<T>, PrefetchHandlers];
|
|
25
|
+
export declare function composeEventHandlers<EventType extends React.SyntheticEvent | Event>(theirHandler: ((event: EventType) => any) | undefined, ourHandler: (event: EventType) => any): (event: EventType) => any;
|
|
26
|
+
/**
|
|
27
|
+
* Renders the `<link>` tags for the current routes.
|
|
28
|
+
*
|
|
29
|
+
* @see https://remix.run/components/links
|
|
30
|
+
*/
|
|
31
|
+
export declare function Links(): React.JSX.Element;
|
|
32
|
+
/**
|
|
33
|
+
* This component renders all the `<link rel="prefetch">` and
|
|
34
|
+
* `<link rel="modulepreload"/>` tags for all the assets (data, modules, css) of
|
|
35
|
+
* a given page.
|
|
36
|
+
*
|
|
37
|
+
* @param props
|
|
38
|
+
* @param props.page
|
|
39
|
+
* @see https://remix.run/components/prefetch-page-links
|
|
40
|
+
*/
|
|
41
|
+
export declare function PrefetchPageLinks({ page, ...dataLinkProps }: PrefetchPageDescriptor): React.JSX.Element | null;
|
|
42
|
+
/**
|
|
43
|
+
* Renders HTML tags related to metadata for the current route.
|
|
44
|
+
*
|
|
45
|
+
* @see https://remix.run/components/meta
|
|
46
|
+
*/
|
|
47
|
+
export declare function Meta(): React.JSX.Element;
|
|
48
|
+
export type ScriptProps = Omit<React.HTMLProps<HTMLScriptElement>, "children" | "async" | "defer" | "src" | "type" | "noModule" | "dangerouslySetInnerHTML" | "suppressHydrationWarning">;
|
|
49
|
+
/**
|
|
50
|
+
* Renders the `<script>` tags needed for the initial render. Bundles for
|
|
51
|
+
* additional routes are loaded later as needed.
|
|
52
|
+
*
|
|
53
|
+
* @param props Additional properties to add to each script tag that is rendered.
|
|
54
|
+
* In addition to scripts, \<link rel="modulepreload"> tags receive the crossOrigin
|
|
55
|
+
* property if provided.
|
|
56
|
+
*
|
|
57
|
+
* @see https://remix.run/components/scripts
|
|
58
|
+
*/
|
|
59
|
+
export declare function Scripts(props: ScriptProps): React.JSX.Element | null;
|
|
60
|
+
export declare function mergeRefs<T = any>(...refs: Array<React.MutableRefObject<T> | React.LegacyRef<T>>): React.RefCallback<T>;
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ActionFunction, LoaderFunction } from "../../router/utils";
|
|
3
|
+
import type { IndexRouteObject, NonIndexRouteObject } from "../../context";
|
|
4
|
+
import type { LinksFunction, MetaFunction } from "./routeModules";
|
|
5
|
+
import type { InitialEntry } from "../../router/history";
|
|
6
|
+
import type { HydrationState } from "../../router/router";
|
|
7
|
+
import type { FutureConfig } from "./entry";
|
|
8
|
+
interface StubIndexRouteObject extends Omit<IndexRouteObject, "loader" | "action" | "element" | "errorElement" | "children"> {
|
|
9
|
+
loader?: LoaderFunction;
|
|
10
|
+
action?: ActionFunction;
|
|
11
|
+
children?: StubRouteObject[];
|
|
12
|
+
meta?: MetaFunction;
|
|
13
|
+
links?: LinksFunction;
|
|
14
|
+
}
|
|
15
|
+
interface StubNonIndexRouteObject extends Omit<NonIndexRouteObject, "loader" | "action" | "element" | "errorElement" | "children"> {
|
|
16
|
+
loader?: LoaderFunction;
|
|
17
|
+
action?: ActionFunction;
|
|
18
|
+
children?: StubRouteObject[];
|
|
19
|
+
meta?: MetaFunction;
|
|
20
|
+
links?: LinksFunction;
|
|
21
|
+
}
|
|
22
|
+
type StubRouteObject = StubIndexRouteObject | StubNonIndexRouteObject;
|
|
23
|
+
interface AppLoadContext {
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface RemixStubProps {
|
|
27
|
+
/**
|
|
28
|
+
* The initial entries in the history stack. This allows you to start a test with
|
|
29
|
+
* multiple locations already in the history stack (for testing a back navigation, etc.)
|
|
30
|
+
* The test will default to the last entry in initialEntries if no initialIndex is provided.
|
|
31
|
+
* e.g. initialEntries={["/home", "/about", "/contact"]}
|
|
32
|
+
*/
|
|
33
|
+
initialEntries?: InitialEntry[];
|
|
34
|
+
/**
|
|
35
|
+
* The initial index in the history stack to render. This allows you to start a test at a specific entry.
|
|
36
|
+
* It defaults to the last entry in initialEntries.
|
|
37
|
+
* e.g.
|
|
38
|
+
* initialEntries: ["/", "/events/123"]
|
|
39
|
+
* initialIndex: 1 // start at "/events/123"
|
|
40
|
+
*/
|
|
41
|
+
initialIndex?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Used to set the route's initial loader and action data.
|
|
44
|
+
* e.g. hydrationData={{
|
|
45
|
+
* loaderData: { "/contact": { locale: "en-US" } },
|
|
46
|
+
* actionData: { "/login": { errors: { email: "invalid email" } }}
|
|
47
|
+
* }}
|
|
48
|
+
*/
|
|
49
|
+
hydrationData?: HydrationState;
|
|
50
|
+
/**
|
|
51
|
+
* Future flags mimicking the settings in remix.config.js
|
|
52
|
+
*/
|
|
53
|
+
future?: Partial<FutureConfig>;
|
|
54
|
+
}
|
|
55
|
+
export declare function createRemixStub(routes: StubRouteObject[], context?: AppLoadContext): ({ initialEntries, initialIndex, hydrationData, future, }: RemixStubProps) => React.JSX.Element;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UNSAFE_DeferredData as DeferredData } from "../../router";
|
|
2
|
+
import "../global";
|
|
3
|
+
/**
|
|
4
|
+
* Data for a route that was returned from a `loader()`.
|
|
5
|
+
*/
|
|
6
|
+
export type AppData = unknown;
|
|
7
|
+
export declare function isCatchResponse(response: Response): boolean;
|
|
8
|
+
export declare function isErrorResponse(response: any): response is Response;
|
|
9
|
+
export declare function isNetworkErrorResponse(response: any): response is Response;
|
|
10
|
+
export declare function isRedirectResponse(response: Response): boolean;
|
|
11
|
+
export declare function isDeferredResponse(response: Response): boolean;
|
|
12
|
+
export declare function isResponse(value: any): value is Response;
|
|
13
|
+
export declare function isDeferredData(value: any): value is DeferredData;
|
|
14
|
+
export declare function fetchData(request: Request, routeId: string, retry?: number): Promise<Response | Error>;
|
|
15
|
+
export declare function createRequestInit(request: Request): Promise<RequestInit>;
|
|
16
|
+
export declare function parseDeferredReadableStream(stream: ReadableStream<Uint8Array>): Promise<DeferredData>;
|