react-router 7.8.1 → 7.8.2-pre.0

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/development/{chunk-UH6JLGW7.mjs → chunk-5LNVHL6T.mjs} +185 -201
  3. package/dist/development/{chunk-TGXCWGPT.js → chunk-KUJAVZYD.js} +123 -180
  4. package/dist/development/{chunk-IFMMFE4R.mjs → chunk-RVSOEW4N.mjs} +34 -75
  5. package/dist/development/{chunk-IIA3TUI2.js → chunk-UMVNFWBW.js} +210 -169
  6. package/dist/development/{context-DohQKLID.d.mts → context-D5hQ2yCL.d.mts} +843 -6
  7. package/dist/development/dom-export.d.mts +20 -2
  8. package/dist/development/dom-export.d.ts +20 -1
  9. package/dist/development/dom-export.js +10 -4
  10. package/dist/development/dom-export.mjs +10 -4
  11. package/dist/{production/index-react-server-client-BQ6FxdA_.d.ts → development/index-react-server-client-C4AMmMi3.d.ts} +6 -816
  12. package/dist/{production/index-react-server-client-11fLy3qB.d.mts → development/index-react-server-client-DgVbd8DS.d.mts} +2 -3
  13. package/dist/development/index-react-server-client.d.mts +3 -4
  14. package/dist/development/index-react-server-client.d.ts +2 -2
  15. package/dist/development/index-react-server-client.js +4 -4
  16. package/dist/development/index-react-server-client.mjs +2 -2
  17. package/dist/development/index-react-server.d.mts +1 -1
  18. package/dist/development/index-react-server.d.ts +1 -1
  19. package/dist/development/index-react-server.js +39 -45
  20. package/dist/development/index-react-server.mjs +39 -45
  21. package/dist/development/index.d.mts +7 -9
  22. package/dist/development/index.d.ts +5 -5
  23. package/dist/development/index.js +122 -163
  24. package/dist/development/index.mjs +3 -3
  25. package/dist/development/lib/types/internal.d.mts +3 -3
  26. package/dist/development/lib/types/internal.d.ts +2 -2
  27. package/dist/development/lib/types/internal.js +1 -1
  28. package/dist/development/lib/types/internal.mjs +1 -1
  29. package/dist/development/{route-data-CNjObrhZ.d.mts → route-data-B3sNokxM.d.mts} +2 -2
  30. package/dist/development/{routeModules-C3oqzPpI.d.ts → routeModules-DRWHoPcT.d.ts} +844 -7
  31. package/dist/production/{chunk-YMYXECPK.js → chunk-3PSRBVDP.js} +210 -169
  32. package/dist/production/{chunk-5Y7ELDIJ.mjs → chunk-4HHN5NDL.mjs} +34 -75
  33. package/dist/production/{chunk-KHPQXKYM.js → chunk-NCRSBAFG.js} +123 -180
  34. package/dist/production/{chunk-PFDCNQUK.mjs → chunk-O46NJYOA.mjs} +185 -201
  35. package/dist/production/{context-DohQKLID.d.mts → context-D5hQ2yCL.d.mts} +843 -6
  36. package/dist/production/dom-export.d.mts +20 -2
  37. package/dist/production/dom-export.d.ts +20 -1
  38. package/dist/production/dom-export.js +10 -4
  39. package/dist/production/dom-export.mjs +10 -4
  40. package/dist/{development/index-react-server-client-BQ6FxdA_.d.ts → production/index-react-server-client-C4AMmMi3.d.ts} +6 -816
  41. package/dist/{development/index-react-server-client-11fLy3qB.d.mts → production/index-react-server-client-DgVbd8DS.d.mts} +2 -3
  42. package/dist/production/index-react-server-client.d.mts +3 -4
  43. package/dist/production/index-react-server-client.d.ts +2 -2
  44. package/dist/production/index-react-server-client.js +4 -4
  45. package/dist/production/index-react-server-client.mjs +2 -2
  46. package/dist/production/index-react-server.d.mts +1 -1
  47. package/dist/production/index-react-server.d.ts +1 -1
  48. package/dist/production/index-react-server.js +39 -45
  49. package/dist/production/index-react-server.mjs +39 -45
  50. package/dist/production/index.d.mts +7 -9
  51. package/dist/production/index.d.ts +5 -5
  52. package/dist/production/index.js +122 -163
  53. package/dist/production/index.mjs +3 -3
  54. package/dist/production/lib/types/internal.d.mts +3 -3
  55. package/dist/production/lib/types/internal.d.ts +2 -2
  56. package/dist/production/lib/types/internal.js +1 -1
  57. package/dist/production/lib/types/internal.mjs +1 -1
  58. package/dist/production/{route-data-CNjObrhZ.d.mts → route-data-B3sNokxM.d.mts} +2 -2
  59. package/dist/production/{routeModules-C3oqzPpI.d.ts → routeModules-DRWHoPcT.d.ts} +844 -7
  60. package/package.json +1 -1
  61. package/dist/development/components-CuPfnyiZ.d.mts +0 -814
  62. package/dist/production/components-CuPfnyiZ.d.mts +0 -814
@@ -1,816 +1,6 @@
1
- import { I as InitialEntry, T as To, i as RelativeRoutingType, w as NonIndexRouteObject, ag as LazyRouteFunction, q as IndexRouteObject, a as Location, A as Action, aD as Navigator, d as Router$1, V as RouterInit, aZ as FutureConfig$1, H as HydrationState, D as DataStrategyFunction, X as PatchRoutesOnNavigationFunction, p as RouteObject, aF as RouteMatch, o as Params, U as UIMatch, af as HTMLFormMethod, ad as FormEncType, a_ as RouteManifest, a$ as ServerRouteModule, z as MiddlewareEnabled, y as unstable_RouterContextProvider, x as AppLoadContext, ah as LoaderFunctionArgs, a7 as ActionFunctionArgs, e as RouteModules, Y as DataRouteObject, K as ClientLoaderFunction, a0 as StaticHandlerContext, aK as PageLinkDescriptor, b0 as History, $ as GetScrollRestorationKeyFunction, f as NavigateOptions, a1 as Fetcher, h as SerializeFrom, B as BlockerFunction, b1 as CreateStaticHandlerOptions$1, Z as StaticHandler } from './routeModules-C3oqzPpI.js';
1
+ import { ai as HTMLFormMethod, ag as FormEncType, j as RelativeRoutingType, bx as RouteManifest, by as ServerRouteModule, O as MiddlewareEnabled, K as unstable_RouterContextProvider, J as AppLoadContext, ak as LoaderFunctionArgs, ab as ActionFunctionArgs, e as RouteModules, H as HydrationState, a0 as DataRouteObject, W as ClientLoaderFunction, a4 as StaticHandlerContext, ba as PageLinkDescriptor, T as To, bz as History, a3 as GetScrollRestorationKeyFunction, Z as RouterInit, bA as FutureConfig$1, f as DataStrategyFunction, $ as PatchRoutesOnNavigationFunction, g as NavigateOptions, a5 as Fetcher, q as RouteObject, d as Router, i as SerializeFrom, B as BlockerFunction, a as Location, bB as CreateStaticHandlerOptions$1, a1 as StaticHandler } from './routeModules-DRWHoPcT.js';
2
2
  import * as React from 'react';
3
3
 
4
- declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
5
- hasErrorBoundary: boolean;
6
- };
7
- declare const hydrationRouteProperties: (keyof RouteObject)[];
8
- /**
9
- * @category Data Routers
10
- */
11
- interface MemoryRouterOpts {
12
- /**
13
- * Basename path for the application.
14
- */
15
- basename?: string;
16
- /**
17
- * A function that returns an {@link unstable_RouterContextProvider} instance
18
- * which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
19
- * [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
20
- * This function is called to generate a fresh `context` instance on each
21
- * navigation or fetcher call.
22
- */
23
- unstable_getContext?: RouterInit["unstable_getContext"];
24
- /**
25
- * Future flags to enable for the router.
26
- */
27
- future?: Partial<FutureConfig$1>;
28
- /**
29
- * Hydration data to initialize the router with if you have already performed
30
- * data loading on the server.
31
- */
32
- hydrationData?: HydrationState;
33
- /**
34
- * Initial entries in the in-memory history stack
35
- */
36
- initialEntries?: InitialEntry[];
37
- /**
38
- * Index of `initialEntries` the application should initialize to
39
- */
40
- initialIndex?: number;
41
- /**
42
- * Override the default data strategy of loading in parallel.
43
- * Only intended for advanced usage.
44
- */
45
- dataStrategy?: DataStrategyFunction;
46
- /**
47
- * Lazily define portions of the route tree on navigations.
48
- */
49
- patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
50
- }
51
- /**
52
- * Create a new {@link DataRouter} that manages the application path using an
53
- * in-memory [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
54
- * stack. Useful for non-browser environments without a DOM API.
55
- *
56
- * @public
57
- * @category Data Routers
58
- * @mode data
59
- * @param routes Application routes
60
- * @param opts Options
61
- * @param {MemoryRouterOpts.basename} opts.basename n/a
62
- * @param {MemoryRouterOpts.dataStrategy} opts.dataStrategy n/a
63
- * @param {MemoryRouterOpts.future} opts.future n/a
64
- * @param {MemoryRouterOpts.unstable_getContext} opts.unstable_getContext n/a
65
- * @param {MemoryRouterOpts.hydrationData} opts.hydrationData n/a
66
- * @param {MemoryRouterOpts.initialEntries} opts.initialEntries n/a
67
- * @param {MemoryRouterOpts.initialIndex} opts.initialIndex n/a
68
- * @param {MemoryRouterOpts.patchRoutesOnNavigation} opts.patchRoutesOnNavigation n/a
69
- * @returns An initialized {@link DataRouter} to pass to {@link RouterProvider | `<RouterProvider>`}
70
- */
71
- declare function createMemoryRouter(routes: RouteObject[], opts?: MemoryRouterOpts): Router$1;
72
- /**
73
- * @category Types
74
- */
75
- interface RouterProviderProps {
76
- /**
77
- * The {@link DataRouter} instance to use for navigation and data fetching.
78
- */
79
- router: Router$1;
80
- /**
81
- * The [`ReactDOM.flushSync`](https://react.dev/reference/react-dom/flushSync)
82
- * implementation to use for flushing updates.
83
- *
84
- * You usually don't have to worry about this:
85
- * - The `RouterProvider` exported from `react-router/dom` handles this internally for you
86
- * - If you are rendering in a non-DOM environment, you can import
87
- * `RouterProvider` from `react-router` and ignore this prop
88
- */
89
- flushSync?: (fn: () => unknown) => undefined;
90
- }
91
- /**
92
- * Render the UI for the given {@link DataRouter}. This component should
93
- * typically be at the top of an app's element tree.
94
- *
95
- * ```tsx
96
- * import { createBrowserRouter } from "react-router";
97
- * import { RouterProvider } from "react-router/dom";
98
- * import { createRoot } from "react-dom/client";
99
- *
100
- * const router = createBrowserRouter(routes);
101
- * createRoot(document.getElementById("root")).render(
102
- * <RouterProvider router={router} />
103
- * );
104
- * ```
105
- *
106
- * <docs-info>Please note that this component is exported both from
107
- * `react-router` and `react-router/dom` with the only difference being that the
108
- * latter automatically wires up `react-dom`'s [`flushSync`](https://react.dev/reference/react-dom/flushSync)
109
- * implementation. You _almost always_ want to use the version from
110
- * `react-router/dom` unless you're running in a non-DOM environment.</docs-info>
111
- *
112
- *
113
- * @public
114
- * @category Data Routers
115
- * @mode data
116
- * @param props Props
117
- * @param {RouterProviderProps.flushSync} props.flushSync n/a
118
- * @param {RouterProviderProps.router} props.router n/a
119
- * @returns React element for the rendered router
120
- */
121
- declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, }: RouterProviderProps): React.ReactElement;
122
- /**
123
- * @category Types
124
- */
125
- interface MemoryRouterProps {
126
- /**
127
- * Application basename
128
- */
129
- basename?: string;
130
- /**
131
- * Nested {@link Route} elements describing the route tree
132
- */
133
- children?: React.ReactNode;
134
- /**
135
- * Initial entries in the in-memory history stack
136
- */
137
- initialEntries?: InitialEntry[];
138
- /**
139
- * Index of `initialEntries` the application should initialize to
140
- */
141
- initialIndex?: number;
142
- }
143
- /**
144
- * A declarative {@link Router | `<Router>`} that stores all entries in memory.
145
- *
146
- * @public
147
- * @category Declarative Routers
148
- * @mode declarative
149
- * @param props Props
150
- * @param {MemoryRouterProps.basename} props.basename n/a
151
- * @param {MemoryRouterProps.children} props.children n/a
152
- * @param {MemoryRouterProps.initialEntries} props.initialEntries n/a
153
- * @param {MemoryRouterProps.initialIndex} props.initialIndex n/a
154
- * @returns A declarative in-memory {@link Router | `<Router>`} for client-side
155
- * routing.
156
- */
157
- declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
158
- /**
159
- * @category Types
160
- */
161
- interface NavigateProps {
162
- /**
163
- * The path to navigate to. This can be a string or a {@link Path} object
164
- */
165
- to: To;
166
- /**
167
- * Whether to replace the current entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
168
- * stack
169
- */
170
- replace?: boolean;
171
- /**
172
- * State to pass to the new {@link Location} to store in [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state).
173
- */
174
- state?: any;
175
- /**
176
- * How to interpret relative routing in the `to` prop.
177
- * See {@link RelativeRoutingType}.
178
- */
179
- relative?: RelativeRoutingType;
180
- }
181
- /**
182
- * A component-based version of {@link useNavigate} to use in a
183
- * [`React.Component` class](https://react.dev/reference/react/Component) where
184
- * hooks cannot be used.
185
- *
186
- * It's recommended to avoid using this component in favor of {@link useNavigate}.
187
- *
188
- * @example
189
- * <Navigate to="/tasks" />
190
- *
191
- * @public
192
- * @category Components
193
- * @param props Props
194
- * @param {NavigateProps.relative} props.relative n/a
195
- * @param {NavigateProps.replace} props.replace n/a
196
- * @param {NavigateProps.state} props.state n/a
197
- * @param {NavigateProps.to} props.to n/a
198
- * @returns {void}
199
- *
200
- */
201
- declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
202
- /**
203
- * @category Types
204
- */
205
- interface OutletProps {
206
- /**
207
- * Provides a context value to the element tree below the outlet. Use when
208
- * the parent route needs to provide values to child routes.
209
- *
210
- * ```tsx
211
- * <Outlet context={myContextValue} />
212
- * ```
213
- *
214
- * Access the context with {@link useOutletContext}.
215
- */
216
- context?: unknown;
217
- }
218
- /**
219
- * Renders the matching child route of a parent route or nothing if no child
220
- * route matches.
221
- *
222
- * @example
223
- * import { Outlet } from "react-router";
224
- *
225
- * export default function SomeParent() {
226
- * return (
227
- * <div>
228
- * <h1>Parent Content</h1>
229
- * <Outlet />
230
- * </div>
231
- * );
232
- * }
233
- *
234
- * @public
235
- * @category Components
236
- * @param props Props
237
- * @param {OutletProps.context} props.context n/a
238
- * @returns React element for the rendered outlet or `null` if no child route matches.
239
- */
240
- declare function Outlet(props: OutletProps): React.ReactElement | null;
241
- /**
242
- * @category Types
243
- */
244
- interface PathRouteProps {
245
- /**
246
- * Whether the path should be case-sensitive. Defaults to `false`.
247
- */
248
- caseSensitive?: NonIndexRouteObject["caseSensitive"];
249
- /**
250
- * The path pattern to match. If unspecified or empty, then this becomes a
251
- * layout route.
252
- */
253
- path?: NonIndexRouteObject["path"];
254
- /**
255
- * The unique identifier for this route (for use with {@link DataRouter}s)
256
- */
257
- id?: NonIndexRouteObject["id"];
258
- /**
259
- * A function that returns a promise that resolves to the route object.
260
- * Used for code-splitting routes.
261
- * See [`lazy`](../../start/data/route-object#lazy).
262
- */
263
- lazy?: LazyRouteFunction<NonIndexRouteObject>;
264
- /**
265
- * The route loader.
266
- * See [`loader`](../../start/data/route-object#loader).
267
- */
268
- loader?: NonIndexRouteObject["loader"];
269
- /**
270
- * The route action.
271
- * See [`action`](../../start/data/route-object#action).
272
- */
273
- action?: NonIndexRouteObject["action"];
274
- hasErrorBoundary?: NonIndexRouteObject["hasErrorBoundary"];
275
- /**
276
- * The route shouldRevalidate function.
277
- * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
278
- */
279
- shouldRevalidate?: NonIndexRouteObject["shouldRevalidate"];
280
- /**
281
- * The route handle.
282
- */
283
- handle?: NonIndexRouteObject["handle"];
284
- /**
285
- * Whether this is an index route.
286
- */
287
- index?: false;
288
- /**
289
- * Child Route components
290
- */
291
- children?: React.ReactNode;
292
- /**
293
- * The React element to render when this Route matches.
294
- * Mutually exclusive with `Component`.
295
- */
296
- element?: React.ReactNode | null;
297
- /**
298
- * The React element to render while this router is loading data.
299
- * Mutually exclusive with `HydrateFallback`.
300
- */
301
- hydrateFallbackElement?: React.ReactNode | null;
302
- /**
303
- * The React element to render at this route if an error occurs.
304
- * Mutually exclusive with `ErrorBoundary`.
305
- */
306
- errorElement?: React.ReactNode | null;
307
- /**
308
- * The React Component to render when this route matches.
309
- * Mutually exclusive with `element`.
310
- */
311
- Component?: React.ComponentType | null;
312
- /**
313
- * The React Component to render while this router is loading data.
314
- * Mutually exclusive with `hydrateFallbackElement`.
315
- */
316
- HydrateFallback?: React.ComponentType | null;
317
- /**
318
- * The React Component to render at this route if an error occurs.
319
- * Mutually exclusive with `errorElement`.
320
- */
321
- ErrorBoundary?: React.ComponentType | null;
322
- }
323
- /**
324
- * @category Types
325
- */
326
- interface LayoutRouteProps extends PathRouteProps {
327
- }
328
- /**
329
- * @category Types
330
- */
331
- interface IndexRouteProps {
332
- /**
333
- * Whether the path should be case-sensitive. Defaults to `false`.
334
- */
335
- caseSensitive?: IndexRouteObject["caseSensitive"];
336
- /**
337
- * The path pattern to match. If unspecified or empty, then this becomes a
338
- * layout route.
339
- */
340
- path?: IndexRouteObject["path"];
341
- /**
342
- * The unique identifier for this route (for use with {@link DataRouter}s)
343
- */
344
- id?: IndexRouteObject["id"];
345
- /**
346
- * A function that returns a promise that resolves to the route object.
347
- * Used for code-splitting routes.
348
- * See [`lazy`](../../start/data/route-object#lazy).
349
- */
350
- lazy?: LazyRouteFunction<IndexRouteObject>;
351
- /**
352
- * The route loader.
353
- * See [`loader`](../../start/data/route-object#loader).
354
- */
355
- loader?: IndexRouteObject["loader"];
356
- /**
357
- * The route action.
358
- * See [`action`](../../start/data/route-object#action).
359
- */
360
- action?: IndexRouteObject["action"];
361
- hasErrorBoundary?: IndexRouteObject["hasErrorBoundary"];
362
- /**
363
- * The route shouldRevalidate function.
364
- * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
365
- */
366
- shouldRevalidate?: IndexRouteObject["shouldRevalidate"];
367
- /**
368
- * The route handle.
369
- */
370
- handle?: IndexRouteObject["handle"];
371
- /**
372
- * Whether this is an index route.
373
- */
374
- index: true;
375
- /**
376
- * Child Route components
377
- */
378
- children?: undefined;
379
- /**
380
- * The React element to render when this Route matches.
381
- * Mutually exclusive with `Component`.
382
- */
383
- element?: React.ReactNode | null;
384
- /**
385
- * The React element to render while this router is loading data.
386
- * Mutually exclusive with `HydrateFallback`.
387
- */
388
- hydrateFallbackElement?: React.ReactNode | null;
389
- /**
390
- * The React element to render at this route if an error occurs.
391
- * Mutually exclusive with `ErrorBoundary`.
392
- */
393
- errorElement?: React.ReactNode | null;
394
- /**
395
- * The React Component to render when this route matches.
396
- * Mutually exclusive with `element`.
397
- */
398
- Component?: React.ComponentType | null;
399
- /**
400
- * The React Component to render while this router is loading data.
401
- * Mutually exclusive with `hydrateFallbackElement`.
402
- */
403
- HydrateFallback?: React.ComponentType | null;
404
- /**
405
- * The React Component to render at this route if an error occurs.
406
- * Mutually exclusive with `errorElement`.
407
- */
408
- ErrorBoundary?: React.ComponentType | null;
409
- }
410
- type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
411
- /**
412
- * Configures an element to render when a pattern matches the current location.
413
- * It must be rendered within a {@link Routes} element. Note that these routes
414
- * do not participate in data loading, actions, code splitting, or any other
415
- * route module features.
416
- *
417
- * @example
418
- * // Usually used in a declarative router
419
- * function App() {
420
- * return (
421
- * <BrowserRouter>
422
- * <Routes>
423
- * <Route index element={<StepOne />} />
424
- * <Route path="step-2" element={<StepTwo />} />
425
- * <Route path="step-3" element={<StepThree />} />
426
- * </Routes>
427
- * </BrowserRouter>
428
- * );
429
- * }
430
- *
431
- * // But can be used with a data router as well if you prefer the JSX notation
432
- * const routes = createRoutesFromElements(
433
- * <>
434
- * <Route index loader={step1Loader} Component={StepOne} />
435
- * <Route path="step-2" loader={step2Loader} Component={StepTwo} />
436
- * <Route path="step-3" loader={step3Loader} Component={StepThree} />
437
- * </>
438
- * );
439
- *
440
- * const router = createBrowserRouter(routes);
441
- *
442
- * function App() {
443
- * return <RouterProvider router={router} />;
444
- * }
445
- *
446
- * @public
447
- * @category Components
448
- * @param props Props
449
- * @param {PathRouteProps.action} props.action n/a
450
- * @param {PathRouteProps.caseSensitive} props.caseSensitive n/a
451
- * @param {PathRouteProps.Component} props.Component n/a
452
- * @param {PathRouteProps.children} props.children n/a
453
- * @param {PathRouteProps.element} props.element n/a
454
- * @param {PathRouteProps.ErrorBoundary} props.ErrorBoundary n/a
455
- * @param {PathRouteProps.errorElement} props.errorElement n/a
456
- * @param {PathRouteProps.handle} props.handle n/a
457
- * @param {PathRouteProps.HydrateFallback} props.HydrateFallback n/a
458
- * @param {PathRouteProps.hydrateFallbackElement} props.hydrateFallbackElement n/a
459
- * @param {PathRouteProps.id} props.id n/a
460
- * @param {PathRouteProps.index} props.index n/a
461
- * @param {PathRouteProps.lazy} props.lazy n/a
462
- * @param {PathRouteProps.loader} props.loader n/a
463
- * @param {PathRouteProps.path} props.path n/a
464
- * @param {PathRouteProps.shouldRevalidate} props.shouldRevalidate n/a
465
- * @returns {void}
466
- */
467
- declare function Route$1(props: RouteProps): React.ReactElement | null;
468
- /**
469
- * @category Types
470
- */
471
- interface RouterProps {
472
- /**
473
- * The base path for the application. This is prepended to all locations
474
- */
475
- basename?: string;
476
- /**
477
- * Nested {@link Route} elements describing the route tree
478
- */
479
- children?: React.ReactNode;
480
- /**
481
- * The location to match against. Defaults to the current location.
482
- * This can be a string or a {@link Location} object.
483
- */
484
- location: Partial<Location> | string;
485
- /**
486
- * The type of navigation that triggered this `location` change.
487
- * Defaults to {@link NavigationType.Pop}.
488
- */
489
- navigationType?: Action;
490
- /**
491
- * The navigator to use for navigation. This is usually a history object
492
- * or a custom navigator that implements the {@link Navigator} interface.
493
- */
494
- navigator: Navigator;
495
- /**
496
- * Whether this router is static or not (used for SSR). If `true`, the router
497
- * will not be reactive to location changes.
498
- */
499
- static?: boolean;
500
- }
501
- /**
502
- * Provides location context for the rest of the app.
503
- *
504
- * Note: You usually won't render a `<Router>` directly. Instead, you'll render a
505
- * router that is more specific to your environment such as a {@link BrowserRouter}
506
- * in web browsers or a {@link ServerRouter} for server rendering.
507
- *
508
- * @public
509
- * @category Declarative Routers
510
- * @mode declarative
511
- * @param props Props
512
- * @param {RouterProps.basename} props.basename n/a
513
- * @param {RouterProps.children} props.children n/a
514
- * @param {RouterProps.location} props.location n/a
515
- * @param {RouterProps.navigationType} props.navigationType n/a
516
- * @param {RouterProps.navigator} props.navigator n/a
517
- * @param {RouterProps.static} props.static n/a
518
- * @returns React element for the rendered router or `null` if the location does
519
- * not match the {@link props.basename}
520
- */
521
- declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
522
- /**
523
- * @category Types
524
- */
525
- interface RoutesProps {
526
- /**
527
- * Nested {@link Route} elements
528
- */
529
- children?: React.ReactNode;
530
- /**
531
- * The {@link Location} to match against. Defaults to the current location.
532
- */
533
- location?: Partial<Location> | string;
534
- }
535
- /**
536
- * Renders a branch of {@link Route | `<Route>`s} that best matches the current
537
- * location. Note that these routes do not participate in [data loading](../../start/framework/route-module#loader),
538
- * [`action`](../../start/framework/route-module#action), code splitting, or
539
- * any other [route module](../../start/framework/route-module) features.
540
- *
541
- * @example
542
- * import { Route, Routes } from "react-router";
543
- *
544
- * <Routes>
545
- * <Route index element={<StepOne />} />
546
- * <Route path="step-2" element={<StepTwo />} />
547
- * <Route path="step-3" element={<StepThree />}>
548
- * </Routes>
549
- *
550
- * @public
551
- * @category Components
552
- * @param props Props
553
- * @param {RoutesProps.children} props.children n/a
554
- * @param {RoutesProps.location} props.location n/a
555
- * @returns React element for the rendered routes or `null` if no route matches
556
- */
557
- declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
558
- interface AwaitResolveRenderFunction<Resolve = any> {
559
- (data: Awaited<Resolve>): React.ReactNode;
560
- }
561
- /**
562
- * @category Types
563
- */
564
- interface AwaitProps<Resolve> {
565
- /**
566
- * When using a function, the resolved value is provided as the parameter.
567
- *
568
- * ```tsx [2]
569
- * <Await resolve={reviewsPromise}>
570
- * {(resolvedReviews) => <Reviews items={resolvedReviews} />}
571
- * </Await>
572
- * ```
573
- *
574
- * When using React elements, {@link useAsyncValue} will provide the
575
- * resolved value:
576
- *
577
- * ```tsx [2]
578
- * <Await resolve={reviewsPromise}>
579
- * <Reviews />
580
- * </Await>
581
- *
582
- * function Reviews() {
583
- * const resolvedReviews = useAsyncValue();
584
- * return <div>...</div>;
585
- * }
586
- * ```
587
- */
588
- children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
589
- /**
590
- * The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
591
- * rejects.
592
- *
593
- * ```tsx
594
- * <Await
595
- * errorElement={<div>Oops</div>}
596
- * resolve={reviewsPromise}
597
- * >
598
- * <Reviews />
599
- * </Await>
600
- * ```
601
- *
602
- * To provide a more contextual error, you can use the {@link useAsyncError} in a
603
- * child component
604
- *
605
- * ```tsx
606
- * <Await
607
- * errorElement={<ReviewsError />}
608
- * resolve={reviewsPromise}
609
- * >
610
- * <Reviews />
611
- * </Await>
612
- *
613
- * function ReviewsError() {
614
- * const error = useAsyncError();
615
- * return <div>Error loading reviews: {error.message}</div>;
616
- * }
617
- * ```
618
- *
619
- * If you do not provide an `errorElement`, the rejected value will bubble up
620
- * to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
621
- * and be accessible via the {@link useRouteError} hook.
622
- */
623
- errorElement?: React.ReactNode;
624
- /**
625
- * Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
626
- * returned from a [`loader`](../../start/framework/route-module#loader) to be
627
- * resolved and rendered.
628
- *
629
- * ```tsx
630
- * import { Await, useLoaderData } from "react-router";
631
- *
632
- * export async function loader() {
633
- * let reviews = getReviews(); // not awaited
634
- * let book = await getBook();
635
- * return {
636
- * book,
637
- * reviews, // this is a promise
638
- * };
639
- * }
640
- *
641
- * export default function Book() {
642
- * const {
643
- * book,
644
- * reviews, // this is the same promise
645
- * } = useLoaderData();
646
- *
647
- * return (
648
- * <div>
649
- * <h1>{book.title}</h1>
650
- * <p>{book.description}</p>
651
- * <React.Suspense fallback={<ReviewsSkeleton />}>
652
- * <Await
653
- * // and is the promise we pass to Await
654
- * resolve={reviews}
655
- * >
656
- * <Reviews />
657
- * </Await>
658
- * </React.Suspense>
659
- * </div>
660
- * );
661
- * }
662
- * ```
663
- */
664
- resolve: Resolve;
665
- }
666
- /**
667
- * Used to render promise values with automatic error handling.
668
- *
669
- * **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
670
- *
671
- * @example
672
- * import { Await, useLoaderData } from "react-router";
673
- *
674
- * export async function loader() {
675
- * // not awaited
676
- * const reviews = getReviews();
677
- * // awaited (blocks the transition)
678
- * const book = await fetch("/api/book").then((res) => res.json());
679
- * return { book, reviews };
680
- * }
681
- *
682
- * function Book() {
683
- * const { book, reviews } = useLoaderData();
684
- * return (
685
- * <div>
686
- * <h1>{book.title}</h1>
687
- * <p>{book.description}</p>
688
- * <React.Suspense fallback={<ReviewsSkeleton />}>
689
- * <Await
690
- * resolve={reviews}
691
- * errorElement={
692
- * <div>Could not load reviews 😬</div>
693
- * }
694
- * children={(resolvedReviews) => (
695
- * <Reviews items={resolvedReviews} />
696
- * )}
697
- * />
698
- * </React.Suspense>
699
- * </div>
700
- * );
701
- * }
702
- *
703
- * @public
704
- * @category Components
705
- * @mode framework
706
- * @mode data
707
- * @param props Props
708
- * @param {AwaitProps.children} props.children n/a
709
- * @param {AwaitProps.errorElement} props.errorElement n/a
710
- * @param {AwaitProps.resolve} props.resolve n/a
711
- * @returns React element for the rendered awaited value
712
- */
713
- declare function Await<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
714
- /**
715
- * Creates a route config from a React "children" object, which is usually
716
- * either a `<Route>` element or an array of them. Used internally by
717
- * `<Routes>` to create a route config from its children.
718
- *
719
- * @category Utils
720
- * @mode data
721
- * @param children The React children to convert into a route config
722
- * @param parentPath The path of the parent route, used to generate unique IDs.
723
- * @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
724
- */
725
- declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
726
- /**
727
- * Create route objects from JSX elements instead of arrays of objects.
728
- *
729
- * @example
730
- * const routes = createRoutesFromElements(
731
- * <>
732
- * <Route index loader={step1Loader} Component={StepOne} />
733
- * <Route path="step-2" loader={step2Loader} Component={StepTwo} />
734
- * <Route path="step-3" loader={step3Loader} Component={StepThree} />
735
- * </>
736
- * );
737
- *
738
- * const router = createBrowserRouter(routes);
739
- *
740
- * function App() {
741
- * return <RouterProvider router={router} />;
742
- * }
743
- *
744
- * @name createRoutesFromElements
745
- * @public
746
- * @category Utils
747
- * @mode data
748
- * @param children The React children to convert into a route config
749
- * @param parentPath The path of the parent route, used to generate unique IDs.
750
- * This is used for internal recursion and is not intended to be used by the
751
- * application developer.
752
- * @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
753
- */
754
- declare const createRoutesFromElements: typeof createRoutesFromChildren;
755
- /**
756
- * Renders the result of {@link matchRoutes} into a React element.
757
- *
758
- * @public
759
- * @category Utils
760
- * @param matches The array of {@link RouteMatch | route matches} to render
761
- * @returns A React element that renders the matched routes or `null` if no matches
762
- */
763
- declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
764
- declare function useRouteComponentProps(): {
765
- params: Readonly<Params<string>>;
766
- loaderData: any;
767
- actionData: any;
768
- matches: UIMatch<unknown, unknown>[];
769
- };
770
- type RouteComponentProps = ReturnType<typeof useRouteComponentProps>;
771
- type RouteComponentType = React.ComponentType<RouteComponentProps>;
772
- declare function WithComponentProps({ children, }: {
773
- children: React.ReactElement;
774
- }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
775
- declare function withComponentProps(Component: RouteComponentType): () => React.ReactElement<{
776
- params: Readonly<Params<string>>;
777
- loaderData: any;
778
- actionData: any;
779
- matches: UIMatch<unknown, unknown>[];
780
- }, string | React.JSXElementConstructor<any>>;
781
- declare function useHydrateFallbackProps(): {
782
- params: Readonly<Params<string>>;
783
- loaderData: any;
784
- actionData: any;
785
- };
786
- type HydrateFallbackProps = ReturnType<typeof useHydrateFallbackProps>;
787
- type HydrateFallbackType = React.ComponentType<HydrateFallbackProps>;
788
- declare function WithHydrateFallbackProps({ children, }: {
789
- children: React.ReactElement;
790
- }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
791
- declare function withHydrateFallbackProps(HydrateFallback: HydrateFallbackType): () => React.ReactElement<{
792
- params: Readonly<Params<string>>;
793
- loaderData: any;
794
- actionData: any;
795
- }, string | React.JSXElementConstructor<any>>;
796
- declare function useErrorBoundaryProps(): {
797
- params: Readonly<Params<string>>;
798
- loaderData: any;
799
- actionData: any;
800
- error: unknown;
801
- };
802
- type ErrorBoundaryProps = ReturnType<typeof useErrorBoundaryProps>;
803
- type ErrorBoundaryType = React.ComponentType<ErrorBoundaryProps>;
804
- declare function WithErrorBoundaryProps({ children, }: {
805
- children: React.ReactElement;
806
- }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
807
- declare function withErrorBoundaryProps(ErrorBoundary: ErrorBoundaryType): () => React.ReactElement<{
808
- params: Readonly<Params<string>>;
809
- loaderData: any;
810
- actionData: any;
811
- error: unknown;
812
- }, string | React.JSXElementConstructor<any>>;
813
-
814
4
  type ParamKeyValuePair = [string, string];
815
5
  type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
816
6
  /**
@@ -1840,7 +1030,7 @@ interface DOMRouterOpts {
1840
1030
  * @param {DOMRouterOpts.window} opts.window n/a
1841
1031
  * @returns An initialized {@link DataRouter| data router} to pass to {@link RouterProvider | `<RouterProvider>`}
1842
1032
  */
1843
- declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router$1;
1033
+ declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router;
1844
1034
  /**
1845
1035
  * Create a new {@link DataRouter| data router} that manages the application
1846
1036
  * path via the URL [`hash`]https://developer.mozilla.org/en-US/docs/Web/API/URL/hash).
@@ -1859,7 +1049,7 @@ declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts
1859
1049
  * @param {DOMRouterOpts.window} opts.window n/a
1860
1050
  * @returns An initialized {@link DataRouter| data router} to pass to {@link RouterProvider | `<RouterProvider>`}
1861
1051
  */
1862
- declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router$1;
1052
+ declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router;
1863
1053
  /**
1864
1054
  * @category Types
1865
1055
  */
@@ -3207,7 +2397,7 @@ interface StaticRouterProviderProps {
3207
2397
  /**
3208
2398
  * The static {@link DataRouter} from {@link createStaticRouter}
3209
2399
  */
3210
- router: Router$1;
2400
+ router: Router;
3211
2401
  /**
3212
2402
  * Whether to hydrate the router on the client (default `true`)
3213
2403
  */
@@ -3313,6 +2503,6 @@ declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticH
3313
2503
  */
3314
2504
  declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
3315
2505
  future?: Partial<FutureConfig$1>;
3316
- }): Router$1;
2506
+ }): Router;
3317
2507
 
3318
- export { ScrollRestoration as $, type AssetsManifest as A, type BrowserRouterProps as B, type ScrollRestorationProps as C, type DOMRouterOpts as D, type EntryContext as E, type FutureConfig as F, type SetURLSearchParams as G, type HydrateFallbackType as H, type IndexRouteProps as I, type SubmitFunction as J, type FetcherSubmitFunction as K, type LayoutRouteProps as L, type MemoryRouterOpts as M, type NavigateProps as N, type OutletProps as O, type PathRouteProps as P, type FetcherWithComponents as Q, type RouteComponentType as R, type ServerBuild as S, createBrowserRouter as T, createHashRouter as U, BrowserRouter as V, HashRouter as W, Link as X, HistoryRouter as Y, NavLink as Z, Form as _, type ErrorBoundaryType as a, useLinkClickHandler as a0, useSearchParams as a1, useSubmit as a2, useFormAction as a3, useFetcher as a4, useFetchers as a5, useBeforeUnload as a6, usePrompt as a7, useViewTransitionState as a8, type FetcherSubmitOptions as a9, withComponentProps as aA, WithHydrateFallbackProps as aB, withHydrateFallbackProps as aC, WithErrorBoundaryProps as aD, withErrorBoundaryProps as aE, FrameworkContext as aF, createClientRoutes as aG, createClientRoutesWithHMRRevalidationOptOut as aH, shouldHydrateRouteLoader as aI, useScrollRestoration as aJ, type ParamKeyValuePair as aa, type SubmitOptions as ab, type URLSearchParamsInit as ac, type SubmitTarget as ad, createSearchParams as ae, type StaticRouterProps as af, type StaticRouterProviderProps as ag, createStaticHandler as ah, createStaticRouter as ai, StaticRouter as aj, StaticRouterProvider as ak, Meta as al, Links as am, Scripts as an, PrefetchPageLinks as ao, type LinksProps as ap, type ScriptsProps as aq, type PrefetchBehavior as ar, type DiscoverBehavior as as, type HandleDataRequestFunction as at, type HandleDocumentRequestFunction as au, type HandleErrorFunction as av, type ServerEntryModule as aw, hydrationRouteProperties as ax, mapRouteProperties as ay, WithComponentProps as az, type AwaitProps as b, type MemoryRouterProps as c, type RouteProps as d, type RouterProps as e, type RouterProviderProps as f, type RoutesProps as g, Await as h, MemoryRouter as i, Navigate as j, Outlet as k, Route$1 as l, Router as m, RouterProvider as n, Routes as o, createMemoryRouter as p, createRoutesFromChildren as q, createRoutesFromElements as r, renderMatches as s, type HashRouterProps as t, type HistoryRouterProps as u, type LinkProps as v, type NavLinkProps as w, type NavLinkRenderProps as x, type FetcherFormProps as y, type FormProps as z };
2508
+ export { type ScriptsProps as $, type AssetsManifest as A, type BrowserRouterProps as B, useViewTransitionState as C, type DOMRouterOpts as D, type EntryContext as E, type FutureConfig as F, type FetcherSubmitOptions as G, type HashRouterProps as H, type SubmitOptions as I, type SubmitTarget as J, createSearchParams as K, type LinkProps as L, type StaticRouterProps as M, type NavLinkProps as N, type StaticRouterProviderProps as O, type ParamKeyValuePair as P, createStaticHandler as Q, createStaticRouter as R, type ServerBuild as S, StaticRouter as T, type URLSearchParamsInit as U, StaticRouterProvider as V, Meta as W, Links as X, Scripts as Y, PrefetchPageLinks as Z, type LinksProps as _, type HistoryRouterProps as a, type PrefetchBehavior as a0, type DiscoverBehavior as a1, type HandleDataRequestFunction as a2, type HandleDocumentRequestFunction as a3, type HandleErrorFunction as a4, type ServerEntryModule as a5, FrameworkContext as a6, createClientRoutes as a7, createClientRoutesWithHMRRevalidationOptOut as a8, shouldHydrateRouteLoader as a9, useScrollRestoration as aa, type NavLinkRenderProps as b, type FetcherFormProps as c, type FormProps as d, type ScrollRestorationProps as e, type SetURLSearchParams as f, type SubmitFunction as g, type FetcherSubmitFunction as h, type FetcherWithComponents as i, createBrowserRouter as j, createHashRouter as k, BrowserRouter as l, HashRouter as m, Link as n, HistoryRouter as o, NavLink as p, Form as q, ScrollRestoration as r, useSearchParams as s, useSubmit as t, useLinkClickHandler as u, useFormAction as v, useFetcher as w, useFetchers as x, useBeforeUnload as y, usePrompt as z };