react-router 0.0.0-experimental-e16afd9b7 → 0.0.0-experimental-52e9b8eb3
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 +8 -0
- package/README.md +10 -1
- package/dist/index.d.ts +16 -33
- package/dist/index.js +1114 -9501
- package/dist/index.js.map +1 -1
- package/dist/lib/components.d.ts +19 -189
- package/dist/lib/context.d.ts +4 -4
- package/dist/lib/hooks.d.ts +17 -46
- package/dist/main.js +1 -1
- package/dist/react-router.development.js +1152 -10370
- 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 +1259 -10541
- 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 +4 -19
- package/dist/lib/dom/dom.d.ts +0 -104
- package/dist/lib/dom/global.d.ts +0 -38
- package/dist/lib/dom/lib.d.ts +0 -572
- package/dist/lib/dom/server.d.ts +0 -32
- package/dist/lib/dom/ssr/browser.d.ts +0 -3
- package/dist/lib/dom/ssr/components.d.ts +0 -94
- package/dist/lib/dom/ssr/create-remix-stub.d.ts +0 -56
- package/dist/lib/dom/ssr/data.d.ts +0 -7
- package/dist/lib/dom/ssr/errorBoundaries.d.ts +0 -33
- package/dist/lib/dom/ssr/errors.d.ts +0 -2
- package/dist/lib/dom/ssr/fallback.d.ts +0 -2
- package/dist/lib/dom/ssr/invariant.d.ts +0 -2
- package/dist/lib/dom/ssr/links.d.ts +0 -126
- package/dist/lib/dom/ssr/markup.d.ts +0 -5
- package/dist/lib/dom/ssr/routeModules.d.ts +0 -141
- package/dist/lib/dom/ssr/routes.d.ts +0 -32
- package/dist/lib/dom/ssr/server.d.ts +0 -13
- package/dist/lib/dom/ssr/single-fetch.d.ts +0 -37
- package/dist/lib/router/history.d.ts +0 -249
- package/dist/lib/router/index.d.ts +0 -9
- package/dist/lib/router/router.d.ts +0 -521
- package/dist/lib/router/utils.d.ts +0 -520
- package/dist/rsc.js +0 -1641
package/dist/lib/dom/lib.d.ts
DELETED
|
@@ -1,572 +0,0 @@
|
|
|
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
|
-
/**
|
|
80
|
-
Defines the data and module prefetching behavior for the link.
|
|
81
|
-
|
|
82
|
-
```tsx
|
|
83
|
-
<Link /> // default
|
|
84
|
-
<Link prefetch="none" />
|
|
85
|
-
<Link prefetch="intent" />
|
|
86
|
-
<Link prefetch="render" />
|
|
87
|
-
<Link prefetch="viewport" />
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
- **none** - default, no prefetching
|
|
91
|
-
- **intent** - prefetches when the user hovers or focuses the link
|
|
92
|
-
- **render** - prefetches when the link renders
|
|
93
|
-
- **viewport** - prefetches when the link is in the viewport, very useful for mobile
|
|
94
|
-
|
|
95
|
-
Prefetching is done with HTML `<link rel="prefetch">` tags. They are inserted after the link.
|
|
96
|
-
|
|
97
|
-
```tsx
|
|
98
|
-
<a href="..." />
|
|
99
|
-
<a href="..." />
|
|
100
|
-
<link rel="prefetch" /> // might conditionally render
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Because of this, if you are using `nav :last-child` you will need to use `nav :last-of-type` so the styles don't conditionally fall off your last link (and any other similar selectors).
|
|
104
|
-
*/
|
|
105
|
-
prefetch?: PrefetchBehavior;
|
|
106
|
-
/**
|
|
107
|
-
Will use document navigation instead of client side routing when the link is clicked: the browser will handle the transition normally (as if it were an `<a href>`).
|
|
108
|
-
|
|
109
|
-
```tsx
|
|
110
|
-
<Link to="/logout" reloadDocument />
|
|
111
|
-
```
|
|
112
|
-
*/
|
|
113
|
-
reloadDocument?: boolean;
|
|
114
|
-
/**
|
|
115
|
-
Replaces the current entry in the history stack instead of pushing a new one onto it.
|
|
116
|
-
|
|
117
|
-
```tsx
|
|
118
|
-
<Link replace />
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
# with a history stack like this
|
|
123
|
-
A -> B
|
|
124
|
-
|
|
125
|
-
# normal link click pushes a new entry
|
|
126
|
-
A -> B -> C
|
|
127
|
-
|
|
128
|
-
# but with `replace`, B is replaced by C
|
|
129
|
-
A -> C
|
|
130
|
-
```
|
|
131
|
-
*/
|
|
132
|
-
replace?: boolean;
|
|
133
|
-
/**
|
|
134
|
-
Adds persistent client side routing state to the next location.
|
|
135
|
-
|
|
136
|
-
```tsx
|
|
137
|
-
<Link to="/somewhere/else" state={{ some: "value" }} />
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
The location state is accessed from the `location`.
|
|
141
|
-
|
|
142
|
-
```tsx
|
|
143
|
-
function SomeComp() {
|
|
144
|
-
const location = useLocation()
|
|
145
|
-
location.state; // { some: "value" }
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
This state is inaccessible on the server as it is implemented on top of [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state)
|
|
150
|
-
*/
|
|
151
|
-
state?: any;
|
|
152
|
-
/**
|
|
153
|
-
Prevents the scroll position from being reset to the top of the window when the link is clicked and the app is using {@link ScrollRestoration}. This only prevents new locations reseting scroll to the top, scroll position will be restored for back/forward button navigation.
|
|
154
|
-
|
|
155
|
-
```tsx
|
|
156
|
-
<Link to="?tab=one" preventScrollReset />
|
|
157
|
-
```
|
|
158
|
-
*/
|
|
159
|
-
preventScrollReset?: boolean;
|
|
160
|
-
/**
|
|
161
|
-
Defines the relative path behavior for the link.
|
|
162
|
-
|
|
163
|
-
```tsx
|
|
164
|
-
<Link to=".." /> // default: "route"
|
|
165
|
-
<Link relative="route" />
|
|
166
|
-
<Link relative="path" />
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
Consider a route hierarchy where a parent route pattern is "blog" and a child route pattern is "blog/:slug/edit".
|
|
170
|
-
|
|
171
|
-
- **route** - default, resolves the link relative to the route pattern. In the example above a relative link of `".."` will remove both `:slug/edit` segments back to "/blog".
|
|
172
|
-
- **path** - relative to the path so `..` will only remove one URL segment up to "/blog/:slug"
|
|
173
|
-
*/
|
|
174
|
-
relative?: RelativeRoutingType;
|
|
175
|
-
/**
|
|
176
|
-
Can be a string or a partial {@link Path}:
|
|
177
|
-
|
|
178
|
-
```tsx
|
|
179
|
-
<Link to="/some/path" />
|
|
180
|
-
|
|
181
|
-
<Link
|
|
182
|
-
to={{
|
|
183
|
-
pathname: "/some/path",
|
|
184
|
-
search: "?query=string",
|
|
185
|
-
hash: "#hash",
|
|
186
|
-
}}
|
|
187
|
-
/>
|
|
188
|
-
```
|
|
189
|
-
*/
|
|
190
|
-
to: To;
|
|
191
|
-
/**
|
|
192
|
-
Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) for this navigation.
|
|
193
|
-
|
|
194
|
-
```jsx
|
|
195
|
-
<Link to={to} unstable_viewTransition>
|
|
196
|
-
Click me
|
|
197
|
-
</Link>
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
To apply specific styles for the transition, see {@link useViewTransitionState}
|
|
201
|
-
*/
|
|
202
|
-
unstable_viewTransition?: boolean;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
A progressively enhanced `<a href>` wrapper to enable navigation with client-side routing.
|
|
206
|
-
|
|
207
|
-
```tsx
|
|
208
|
-
import { Link } from "react-router";
|
|
209
|
-
|
|
210
|
-
<Link to="/dashboard">Dashboard</Link>;
|
|
211
|
-
|
|
212
|
-
<Link
|
|
213
|
-
to={{
|
|
214
|
-
pathname: "/some/path",
|
|
215
|
-
search: "?query=string",
|
|
216
|
-
hash: "#hash",
|
|
217
|
-
}}
|
|
218
|
-
/>
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
@category Components
|
|
222
|
-
*/
|
|
223
|
-
export declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
224
|
-
/**
|
|
225
|
-
The object passed to {@link NavLink} `children`, `className`, and `style` prop callbacks to render and style the link based on its state.
|
|
226
|
-
|
|
227
|
-
```
|
|
228
|
-
// className
|
|
229
|
-
<NavLink
|
|
230
|
-
to="/messages"
|
|
231
|
-
className={({ isActive, isPending }) =>
|
|
232
|
-
isPending ? "pending" : isActive ? "active" : ""
|
|
233
|
-
}
|
|
234
|
-
>
|
|
235
|
-
Messages
|
|
236
|
-
</NavLink>
|
|
237
|
-
|
|
238
|
-
// style
|
|
239
|
-
<NavLink
|
|
240
|
-
to="/messages"
|
|
241
|
-
style={({ isActive, isPending }) => {
|
|
242
|
-
return {
|
|
243
|
-
fontWeight: isActive ? "bold" : "",
|
|
244
|
-
color: isPending ? "red" : "black",
|
|
245
|
-
}
|
|
246
|
-
)}
|
|
247
|
-
/>
|
|
248
|
-
|
|
249
|
-
// children
|
|
250
|
-
<NavLink to="/tasks">
|
|
251
|
-
{({ isActive, isPending }) => (
|
|
252
|
-
<span className={isActive ? "active" : ""}>Tasks</span>
|
|
253
|
-
)}
|
|
254
|
-
</NavLink>
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
*/
|
|
258
|
-
export type NavLinkRenderProps = {
|
|
259
|
-
/**
|
|
260
|
-
* Indicates if the link's URL matches the current location.
|
|
261
|
-
*/
|
|
262
|
-
isActive: boolean;
|
|
263
|
-
/**
|
|
264
|
-
* Indicates if the pending location matches the link's URL.
|
|
265
|
-
*/
|
|
266
|
-
isPending: boolean;
|
|
267
|
-
/**
|
|
268
|
-
* Indicates if a view transition to the link's URL is in progress. See {@link useViewTransitionState}
|
|
269
|
-
*/
|
|
270
|
-
isTransitioning: boolean;
|
|
271
|
-
};
|
|
272
|
-
export interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
|
|
273
|
-
/**
|
|
274
|
-
Can be regular React children or a function that receives an object with the active and pending states of the link.
|
|
275
|
-
|
|
276
|
-
```tsx
|
|
277
|
-
<NavLink to="/tasks">
|
|
278
|
-
{({ isActive }) => (
|
|
279
|
-
<span className={isActive ? "active" : ""}>Tasks</span>
|
|
280
|
-
)}
|
|
281
|
-
</NavLink>
|
|
282
|
-
```
|
|
283
|
-
*/
|
|
284
|
-
children?: React.ReactNode | ((props: NavLinkRenderProps) => React.ReactNode);
|
|
285
|
-
/**
|
|
286
|
-
Changes the matching logic to make it case-sensitive:
|
|
287
|
-
|
|
288
|
-
| Link | URL | isActive |
|
|
289
|
-
| -------------------------------------------- | ------------- | -------- |
|
|
290
|
-
| `<NavLink to="/SpOnGe-bOB" />` | `/sponge-bob` | true |
|
|
291
|
-
| `<NavLink to="/SpOnGe-bOB" caseSensitive />` | `/sponge-bob` | false |
|
|
292
|
-
*/
|
|
293
|
-
caseSensitive?: boolean;
|
|
294
|
-
/**
|
|
295
|
-
Classes are automatically applied to NavLink that correspond to {@link NavLinkRenderProps}.
|
|
296
|
-
|
|
297
|
-
```css
|
|
298
|
-
a.active { color: red; }
|
|
299
|
-
a.pending { color: blue; }
|
|
300
|
-
a.transitioning {
|
|
301
|
-
view-transition-name: my-transition;
|
|
302
|
-
}
|
|
303
|
-
```
|
|
304
|
-
*/
|
|
305
|
-
className?: string | ((props: NavLinkRenderProps) => string | undefined);
|
|
306
|
-
/**
|
|
307
|
-
Changes the matching logic for the `active` and `pending` states to only match to the "end" of the {@link NavLink#to}. If the URL is longer, it will no longer be considered active.
|
|
308
|
-
|
|
309
|
-
| Link | URL | isActive |
|
|
310
|
-
| ----------------------------- | ------------ | -------- |
|
|
311
|
-
| `<NavLink to="/tasks" />` | `/tasks` | true |
|
|
312
|
-
| `<NavLink to="/tasks" />` | `/tasks/123` | true |
|
|
313
|
-
| `<NavLink to="/tasks" end />` | `/tasks` | true |
|
|
314
|
-
| `<NavLink to="/tasks" end />` | `/tasks/123` | false |
|
|
315
|
-
|
|
316
|
-
`<NavLink to="/">` is an exceptional case because _every_ URL matches `/`. To avoid this matching every single route by default, it effectively ignores the `end` prop and only matches when you're at the root route.
|
|
317
|
-
*/
|
|
318
|
-
end?: boolean;
|
|
319
|
-
style?: React.CSSProperties | ((props: NavLinkRenderProps) => React.CSSProperties | undefined);
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
Wraps {@link Link | `<Link>`} with additional props for styling active and pending states.
|
|
323
|
-
|
|
324
|
-
- Automatically applies classes to the link based on its active and pending states, see {@link NavLinkProps.className}.
|
|
325
|
-
- Automatically applies `aria-current="page"` to the link when the link is active. See [`aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current) on MDN.
|
|
326
|
-
|
|
327
|
-
```tsx
|
|
328
|
-
import { NavLink } from "react-router"
|
|
329
|
-
<NavLink to="/message" />
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
States are available through the className, style, and children render props. See {@link NavLinkRenderProps}.
|
|
333
|
-
|
|
334
|
-
```tsx
|
|
335
|
-
<NavLink
|
|
336
|
-
to="/messages"
|
|
337
|
-
className={({ isActive, isPending }) =>
|
|
338
|
-
isPending ? "pending" : isActive ? "active" : ""
|
|
339
|
-
}
|
|
340
|
-
>
|
|
341
|
-
Messages
|
|
342
|
-
</NavLink>
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
@category Components
|
|
346
|
-
*/
|
|
347
|
-
export declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
348
|
-
export interface FetcherFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
|
|
349
|
-
/**
|
|
350
|
-
* The HTTP verb to use when the form is submitted. Supports "get", "post",
|
|
351
|
-
* "put", "delete", and "patch".
|
|
352
|
-
*
|
|
353
|
-
* Native `<form>` only supports `get` and `post`, avoid the other verbs if
|
|
354
|
-
* you'd like to support progressive enhancement
|
|
355
|
-
*/
|
|
356
|
-
method?: HTMLFormMethod;
|
|
357
|
-
/**
|
|
358
|
-
* The encoding type to use for the form submission.
|
|
359
|
-
*/
|
|
360
|
-
encType?: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
|
|
361
|
-
/**
|
|
362
|
-
* The URL to submit the form data to. If `undefined`, this defaults to the closest route in context.
|
|
363
|
-
*/
|
|
364
|
-
action?: string;
|
|
365
|
-
/**
|
|
366
|
-
* Determines whether the form action is relative to the route hierarchy or
|
|
367
|
-
* the pathname. Use this if you want to opt out of navigating the route
|
|
368
|
-
* hierarchy and want to instead route based on /-delimited URL segments
|
|
369
|
-
*/
|
|
370
|
-
relative?: RelativeRoutingType;
|
|
371
|
-
/**
|
|
372
|
-
* Prevent the scroll position from resetting to the top of the viewport on
|
|
373
|
-
* completion of the navigation when using the <ScrollRestoration> component
|
|
374
|
-
*/
|
|
375
|
-
preventScrollReset?: boolean;
|
|
376
|
-
/**
|
|
377
|
-
* A function to call when the form is submitted. If you call
|
|
378
|
-
* `event.preventDefault()` then this form will not do anything.
|
|
379
|
-
*/
|
|
380
|
-
onSubmit?: React.FormEventHandler<HTMLFormElement>;
|
|
381
|
-
}
|
|
382
|
-
export interface FormProps extends FetcherFormProps {
|
|
383
|
-
/**
|
|
384
|
-
* Indicates a specific fetcherKey to use when using `navigate={false}` so you
|
|
385
|
-
* can pick up the fetcher's state in a different component in a {@link
|
|
386
|
-
* useFetcher}.
|
|
387
|
-
*/
|
|
388
|
-
fetcherKey?: string;
|
|
389
|
-
/**
|
|
390
|
-
* Skips the navigation and uses a {@link useFetcher | fetcher} internally
|
|
391
|
-
* when `false`. This is essentially a shorthand for `useFetcher()` +
|
|
392
|
-
* `<fetcher.Form>` where you don't care about the resulting data in this
|
|
393
|
-
* component.
|
|
394
|
-
*/
|
|
395
|
-
navigate?: boolean;
|
|
396
|
-
/**
|
|
397
|
-
* Forces a full document navigation instead of client side routing + data
|
|
398
|
-
* fetch.
|
|
399
|
-
*/
|
|
400
|
-
reloadDocument?: boolean;
|
|
401
|
-
/**
|
|
402
|
-
* Replaces the current entry in the browser history stack when the form
|
|
403
|
-
* navigates. Use this if you don't want the user to be able to click "back"
|
|
404
|
-
* to the page with the form on it.
|
|
405
|
-
*/
|
|
406
|
-
replace?: boolean;
|
|
407
|
-
/**
|
|
408
|
-
* State object to add to the history stack entry for this navigation
|
|
409
|
-
*/
|
|
410
|
-
state?: any;
|
|
411
|
-
/**
|
|
412
|
-
* Enables a [View
|
|
413
|
-
* Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
|
|
414
|
-
* for this navigation. To apply specific styles during the transition see
|
|
415
|
-
* {@link unstable_useViewTransitionState}.
|
|
416
|
-
*/
|
|
417
|
-
unstable_viewTransition?: boolean;
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
|
|
421
|
-
A progressively enhanced HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) that submits data to actions via `fetch`, activating pending states in `useNavigation` which enables advanced user interfaces beyond a basic HTML form. After a form's action completes, all data on the page is automatically revalidated to keep the UI in sync with the data.
|
|
422
|
-
|
|
423
|
-
Because it uses the HTML form API, server rendered pages are interactive at a basic level before JavaScript loads. Instead of React Router managing the submission, the browser manages the submission as well as the pending states (like the spinning favicon). After JavaScript loads, React Router takes over enabling web application user experiences.
|
|
424
|
-
|
|
425
|
-
Form is most useful for submissions that should also change the URL or otherwise add an entry to the browser history stack. For forms that shouldn't manipulate the browser history stack, use [`<fetcher.Form>`][fetcher_form].
|
|
426
|
-
|
|
427
|
-
```tsx
|
|
428
|
-
import { Form } from "react-router";
|
|
429
|
-
|
|
430
|
-
function NewEvent() {
|
|
431
|
-
return (
|
|
432
|
-
<Form action="/events" method="post">
|
|
433
|
-
<input name="title" type="text" />
|
|
434
|
-
<input name="description" type="text" />
|
|
435
|
-
</Form>
|
|
436
|
-
)
|
|
437
|
-
}
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
@category Components
|
|
441
|
-
*/
|
|
442
|
-
export declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
|
|
443
|
-
export type ScrollRestorationProps = ScriptProps & {
|
|
444
|
-
getKey?: GetScrollRestorationKeyFunction;
|
|
445
|
-
storageKey?: string;
|
|
446
|
-
};
|
|
447
|
-
/**
|
|
448
|
-
* This component will emulate the browser's scroll restoration on location
|
|
449
|
-
* changes.
|
|
450
|
-
*/
|
|
451
|
-
export declare function ScrollRestoration({ getKey, storageKey, ...props }: ScrollRestorationProps): React.JSX.Element | null;
|
|
452
|
-
export declare namespace ScrollRestoration {
|
|
453
|
-
var displayName: string;
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Handles the click behavior for router `<Link>` components. This is useful if
|
|
457
|
-
* you need to create custom `<Link>` components with the same click behavior we
|
|
458
|
-
* use in our exported `<Link>`.
|
|
459
|
-
*/
|
|
460
|
-
export declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, unstable_viewTransition, }?: {
|
|
461
|
-
target?: React.HTMLAttributeAnchorTarget;
|
|
462
|
-
replace?: boolean;
|
|
463
|
-
state?: any;
|
|
464
|
-
preventScrollReset?: boolean;
|
|
465
|
-
relative?: RelativeRoutingType;
|
|
466
|
-
unstable_viewTransition?: boolean;
|
|
467
|
-
}): (event: React.MouseEvent<E, MouseEvent>) => void;
|
|
468
|
-
/**
|
|
469
|
-
* A convenient wrapper for reading and writing search parameters via the
|
|
470
|
-
* URLSearchParams interface.
|
|
471
|
-
*/
|
|
472
|
-
export declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URLSearchParams, SetURLSearchParams];
|
|
473
|
-
export type SetURLSearchParams = (nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit), navigateOpts?: NavigateOptions) => void;
|
|
474
|
-
/**
|
|
475
|
-
* Submits a HTML `<form>` to the server without reloading the page.
|
|
476
|
-
*/
|
|
477
|
-
export interface SubmitFunction {
|
|
478
|
-
(
|
|
479
|
-
/**
|
|
480
|
-
* Specifies the `<form>` to be submitted to the server, a specific
|
|
481
|
-
* `<button>` or `<input type="submit">` to use to submit the form, or some
|
|
482
|
-
* arbitrary data to submit.
|
|
483
|
-
*
|
|
484
|
-
* Note: When using a `<button>` its `name` and `value` will also be
|
|
485
|
-
* included in the form data that is submitted.
|
|
486
|
-
*/
|
|
487
|
-
target: SubmitTarget,
|
|
488
|
-
/**
|
|
489
|
-
* Options that override the `<form>`'s own attributes. Required when
|
|
490
|
-
* submitting arbitrary data without a backing `<form>`.
|
|
491
|
-
*/
|
|
492
|
-
options?: SubmitOptions): Promise<void>;
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* Submits a fetcher `<form>` to the server without reloading the page.
|
|
496
|
-
*/
|
|
497
|
-
export interface FetcherSubmitFunction {
|
|
498
|
-
(target: SubmitTarget, options?: Omit<SubmitOptions, "replace" | "state">): Promise<void>;
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
* Returns a function that may be used to programmatically submit a form (or
|
|
502
|
-
* some arbitrary data) to the server.
|
|
503
|
-
*/
|
|
504
|
-
export declare function useSubmit(): SubmitFunction;
|
|
505
|
-
export declare function useFormAction(action?: string, { relative }?: {
|
|
506
|
-
relative?: RelativeRoutingType;
|
|
507
|
-
}): string;
|
|
508
|
-
export type FetcherWithComponents<TData> = Fetcher<TData> & {
|
|
509
|
-
Form: React.ForwardRefExoticComponent<FetcherFormProps & React.RefAttributes<HTMLFormElement>>;
|
|
510
|
-
submit: FetcherSubmitFunction;
|
|
511
|
-
load: (href: string, opts?: {
|
|
512
|
-
unstable_flushSync?: boolean;
|
|
513
|
-
}) => Promise<void>;
|
|
514
|
-
};
|
|
515
|
-
/**
|
|
516
|
-
* Interacts with route loaders and actions without causing a navigation. Great
|
|
517
|
-
* for any interaction that stays on the same page.
|
|
518
|
-
*/
|
|
519
|
-
export declare function useFetcher<TData = any>({ key, }?: {
|
|
520
|
-
key?: string;
|
|
521
|
-
}): FetcherWithComponents<TData>;
|
|
522
|
-
/**
|
|
523
|
-
* Provides all fetchers currently on the page. Useful for layouts and parent
|
|
524
|
-
* routes that need to provide pending/optimistic UI regarding the fetch.
|
|
525
|
-
*/
|
|
526
|
-
export declare function useFetchers(): (Fetcher & {
|
|
527
|
-
key: string;
|
|
528
|
-
})[];
|
|
529
|
-
/**
|
|
530
|
-
* When rendered inside a RouterProvider, will restore scroll positions on navigations
|
|
531
|
-
*/
|
|
532
|
-
declare function useScrollRestoration({ getKey, storageKey, }?: {
|
|
533
|
-
getKey?: GetScrollRestorationKeyFunction;
|
|
534
|
-
storageKey?: string;
|
|
535
|
-
}): void;
|
|
536
|
-
export { useScrollRestoration as UNSAFE_useScrollRestoration };
|
|
537
|
-
/**
|
|
538
|
-
* Setup a callback to be fired on the window's `beforeunload` event. This is
|
|
539
|
-
* useful for saving some data to `window.localStorage` just before the page
|
|
540
|
-
* refreshes.
|
|
541
|
-
*
|
|
542
|
-
* Note: The `callback` argument should be a function created with
|
|
543
|
-
* `React.useCallback()`.
|
|
544
|
-
*/
|
|
545
|
-
export declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any, options?: {
|
|
546
|
-
capture?: boolean;
|
|
547
|
-
}): void;
|
|
548
|
-
/**
|
|
549
|
-
* Wrapper around useBlocker to show a window.confirm prompt to users instead
|
|
550
|
-
* of building a custom UI with useBlocker.
|
|
551
|
-
*
|
|
552
|
-
* Warning: This has *a lot of rough edges* and behaves very differently (and
|
|
553
|
-
* very incorrectly in some cases) across browsers if user click addition
|
|
554
|
-
* back/forward navigations while the confirm is open. Use at your own risk.
|
|
555
|
-
*/
|
|
556
|
-
declare function usePrompt({ when, message, }: {
|
|
557
|
-
when: boolean | BlockerFunction;
|
|
558
|
-
message: string;
|
|
559
|
-
}): void;
|
|
560
|
-
export { usePrompt as unstable_usePrompt };
|
|
561
|
-
/**
|
|
562
|
-
* Return a boolean indicating if there is an active view transition to the
|
|
563
|
-
* given href. You can use this value to render CSS classes or viewTransitionName
|
|
564
|
-
* styles onto your elements
|
|
565
|
-
*
|
|
566
|
-
* @param href The destination href
|
|
567
|
-
* @param [opts.relative] Relative routing type ("route" | "path")
|
|
568
|
-
*/
|
|
569
|
-
declare function useViewTransitionState(to: To, opts?: {
|
|
570
|
-
relative?: RelativeRoutingType;
|
|
571
|
-
}): boolean;
|
|
572
|
-
export { useViewTransitionState as unstable_useViewTransitionState };
|
package/dist/lib/dom/server.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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 {};
|