react-router 6.26.2 → 7.0.0-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 (84) hide show
  1. package/CHANGELOG.md +307 -0
  2. package/README.md +1 -14
  3. package/dist/dom-export.d.ts +3 -0
  4. package/dist/dom-export.mjs +205 -0
  5. package/dist/dom-export.mjs.map +1 -0
  6. package/dist/index.d.ts +74 -29
  7. package/dist/index.mjs +11551 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/dist/lib/components.d.ts +250 -35
  10. package/dist/lib/context.d.ts +20 -7
  11. package/dist/lib/dom/dom.d.ts +123 -0
  12. package/dist/lib/dom/global.d.ts +40 -0
  13. package/dist/lib/dom/lib.d.ts +940 -0
  14. package/dist/lib/dom/server.d.ts +41 -0
  15. package/dist/lib/dom/ssr/components.d.ts +123 -0
  16. package/dist/lib/dom/ssr/data.d.ts +7 -0
  17. package/dist/lib/dom/ssr/entry.d.ts +47 -0
  18. package/dist/lib/dom/ssr/errorBoundaries.d.ts +36 -0
  19. package/dist/lib/dom/ssr/errors.d.ts +2 -0
  20. package/dist/lib/dom/ssr/fallback.d.ts +2 -0
  21. package/dist/lib/dom/ssr/fog-of-war.d.ts +28 -0
  22. package/dist/lib/dom/ssr/invariant.d.ts +2 -0
  23. package/dist/lib/dom/ssr/links.d.ts +25 -0
  24. package/dist/lib/dom/ssr/markup.d.ts +5 -0
  25. package/dist/lib/dom/ssr/routeModules.d.ts +141 -0
  26. package/dist/lib/dom/ssr/routes-test-stub.d.ts +59 -0
  27. package/dist/lib/dom/ssr/routes.d.ts +32 -0
  28. package/dist/lib/dom/ssr/server.d.ts +16 -0
  29. package/dist/lib/dom/ssr/single-fetch.d.ts +37 -0
  30. package/dist/lib/dom-export/dom-router-provider.d.ts +5 -0
  31. package/dist/lib/dom-export/hydrated-router.d.ts +5 -0
  32. package/dist/lib/dom-export.d.ts +3 -0
  33. package/dist/lib/hooks.d.ts +286 -57
  34. package/dist/lib/router/history.d.ts +253 -0
  35. package/dist/lib/router/links.d.ts +104 -0
  36. package/dist/lib/router/router.d.ts +540 -0
  37. package/dist/lib/router/utils.d.ts +505 -0
  38. package/dist/lib/server-runtime/build.d.ts +38 -0
  39. package/dist/lib/server-runtime/cookies.d.ts +62 -0
  40. package/dist/lib/server-runtime/crypto.d.ts +2 -0
  41. package/dist/lib/server-runtime/data.d.ts +15 -0
  42. package/dist/lib/server-runtime/dev.d.ts +8 -0
  43. package/dist/lib/server-runtime/entry.d.ts +3 -0
  44. package/dist/lib/server-runtime/errors.d.ts +51 -0
  45. package/dist/lib/server-runtime/headers.d.ts +3 -0
  46. package/dist/lib/server-runtime/invariant.d.ts +2 -0
  47. package/dist/lib/server-runtime/jsonify.d.ts +33 -0
  48. package/dist/lib/server-runtime/markup.d.ts +1 -0
  49. package/dist/lib/server-runtime/mode.d.ts +9 -0
  50. package/dist/lib/server-runtime/responses.d.ts +37 -0
  51. package/dist/lib/server-runtime/routeMatching.d.ts +8 -0
  52. package/dist/lib/server-runtime/routeModules.d.ts +212 -0
  53. package/dist/lib/server-runtime/routes.d.ts +31 -0
  54. package/dist/lib/server-runtime/server.d.ts +5 -0
  55. package/dist/lib/server-runtime/serverHandoff.d.ts +11 -0
  56. package/dist/lib/server-runtime/sessions/cookieStorage.d.ts +19 -0
  57. package/dist/lib/server-runtime/sessions/memoryStorage.d.ts +17 -0
  58. package/dist/lib/server-runtime/sessions.d.ts +140 -0
  59. package/dist/lib/server-runtime/single-fetch.d.ts +30 -0
  60. package/dist/lib/server-runtime/typecheck.d.ts +4 -0
  61. package/dist/lib/server-runtime/warnings.d.ts +1 -0
  62. package/dist/lib/types.d.ts +71 -0
  63. package/dist/lib/types.mjs +10 -0
  64. package/dist/main-dom-export.js +19 -0
  65. package/dist/main.js +1 -1
  66. package/dist/react-router-dom.development.js +199 -0
  67. package/dist/react-router-dom.development.js.map +1 -0
  68. package/dist/react-router-dom.production.min.js +12 -0
  69. package/dist/react-router-dom.production.min.js.map +1 -0
  70. package/dist/react-router.development.js +12271 -1129
  71. package/dist/react-router.development.js.map +1 -1
  72. package/dist/react-router.production.min.js +2 -2
  73. package/dist/react-router.production.min.js.map +1 -1
  74. package/dist/umd/react-router-dom.development.js +241 -0
  75. package/dist/umd/react-router-dom.development.js.map +1 -0
  76. package/dist/umd/react-router-dom.production.min.js +12 -0
  77. package/dist/umd/react-router-dom.production.min.js.map +1 -0
  78. package/dist/umd/react-router.development.js +12459 -1224
  79. package/dist/umd/react-router.development.js.map +1 -1
  80. package/dist/umd/react-router.production.min.js +2 -2
  81. package/dist/umd/react-router.production.min.js.map +1 -1
  82. package/package.json +35 -6
  83. package/dist/index.js +0 -1467
  84. package/dist/index.js.map +0 -1
@@ -1,33 +1,53 @@
1
- import type { InitialEntry, LazyRouteFunction, Location, RelativeRoutingType, Router as RemixRouter, To, TrackedPromise } from "@remix-run/router";
2
- import { Action as NavigationType } from "@remix-run/router";
3
1
  import * as React from "react";
4
- import type { IndexRouteObject, Navigator, NonIndexRouteObject, RouteMatch, RouteObject } from "./context";
5
- export interface FutureConfig {
6
- v7_relativeSplatPath: boolean;
7
- v7_startTransition: boolean;
8
- }
2
+ import type { InitialEntry, Location, To } from "./router/history";
3
+ import { Action as NavigationType } from "./router/history";
4
+ import type { FutureConfig, HydrationState, RelativeRoutingType, Router as DataRouter } from "./router/router";
5
+ import type { DataStrategyFunction, LazyRouteFunction, TrackedPromise } from "./router/utils";
6
+ import type { IndexRouteObject, Navigator, NonIndexRouteObject, PatchRoutesOnNavigationFunction, RouteMatch, RouteObject } from "./context";
7
+ /**
8
+ * @private
9
+ */
10
+ export declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
11
+ hasErrorBoundary: boolean;
12
+ };
13
+ /**
14
+ * @category Routers
15
+ */
16
+ export declare function createMemoryRouter(routes: RouteObject[], opts?: {
17
+ basename?: string;
18
+ future?: Partial<FutureConfig>;
19
+ hydrationData?: HydrationState;
20
+ initialEntries?: InitialEntry[];
21
+ initialIndex?: number;
22
+ dataStrategy?: DataStrategyFunction;
23
+ patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
24
+ }): DataRouter;
9
25
  export interface RouterProviderProps {
10
- fallbackElement?: React.ReactNode;
11
- router: RemixRouter;
12
- future?: Partial<Pick<FutureConfig, "v7_startTransition">>;
26
+ router: DataRouter;
27
+ flushSync?: (fn: () => unknown) => undefined;
13
28
  }
14
29
  /**
15
30
  * Given a Remix Router instance, render the appropriate UI
16
31
  */
17
- export declare function RouterProvider({ fallbackElement, router, future, }: RouterProviderProps): React.ReactElement;
32
+ export declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, }: RouterProviderProps): React.ReactElement;
33
+ /**
34
+ * @category Types
35
+ */
18
36
  export interface MemoryRouterProps {
19
37
  basename?: string;
20
38
  children?: React.ReactNode;
21
39
  initialEntries?: InitialEntry[];
22
40
  initialIndex?: number;
23
- future?: Partial<FutureConfig>;
24
41
  }
25
42
  /**
26
43
  * A `<Router>` that stores all entries in memory.
27
44
  *
28
- * @see https://reactrouter.com/router-components/memory-router
45
+ * @category Router Components
46
+ */
47
+ export declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
48
+ /**
49
+ * @category Types
29
50
  */
30
- export declare function MemoryRouter({ basename, children, initialEntries, initialIndex, future, }: MemoryRouterProps): React.ReactElement;
31
51
  export interface NavigateProps {
32
52
  to: To;
33
53
  replace?: boolean;
@@ -35,24 +55,52 @@ export interface NavigateProps {
35
55
  relative?: RelativeRoutingType;
36
56
  }
37
57
  /**
38
- * Changes the current location.
58
+ * A component-based version of {@link useNavigate} to use in a [`React.Component
59
+ * Class`](https://reactjs.org/docs/react-component.html) where hooks are not
60
+ * able to be used.
39
61
  *
40
- * Note: This API is mostly useful in React.Component subclasses that are not
41
- * able to use hooks. In functional components, we recommend you use the
42
- * `useNavigate` hook instead.
62
+ * It's recommended to avoid using this component in favor of {@link useNavigate}
43
63
  *
44
- * @see https://reactrouter.com/components/navigate
64
+ * @category Components
45
65
  */
46
66
  export declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
67
+ /**
68
+ * @category Types
69
+ */
47
70
  export interface OutletProps {
71
+ /**
72
+ Provides a context value to the element tree below the outlet. Use when the parent route needs to provide values to child routes.
73
+
74
+ ```tsx
75
+ <Outlet context={myContextValue} />
76
+ ```
77
+
78
+ Access the context with {@link useOutletContext}.
79
+ */
48
80
  context?: unknown;
49
81
  }
50
82
  /**
51
- * Renders the child route's element, if there is one.
52
- *
53
- * @see https://reactrouter.com/components/outlet
83
+ Renders the matching child route of a parent route or nothing if no child route matches.
84
+
85
+ ```tsx
86
+ import { Outlet } from "react-router"
87
+
88
+ export default function SomeParent() {
89
+ return (
90
+ <div>
91
+ <h1>Parent Content</h1>
92
+ <Outlet />
93
+ </div>
94
+ );
95
+ }
96
+ ```
97
+
98
+ @category Components
54
99
  */
55
100
  export declare function Outlet(props: OutletProps): React.ReactElement | null;
101
+ /**
102
+ * @category Types
103
+ */
56
104
  export interface PathRouteProps {
57
105
  caseSensitive?: NonIndexRouteObject["caseSensitive"];
58
106
  path?: NonIndexRouteObject["path"];
@@ -72,8 +120,14 @@ export interface PathRouteProps {
72
120
  HydrateFallback?: React.ComponentType | null;
73
121
  ErrorBoundary?: React.ComponentType | null;
74
122
  }
123
+ /**
124
+ * @category Types
125
+ */
75
126
  export interface LayoutRouteProps extends PathRouteProps {
76
127
  }
128
+ /**
129
+ * @category Types
130
+ */
77
131
  export interface IndexRouteProps {
78
132
  caseSensitive?: IndexRouteObject["caseSensitive"];
79
133
  path?: IndexRouteObject["path"];
@@ -95,11 +149,17 @@ export interface IndexRouteProps {
95
149
  }
96
150
  export type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
97
151
  /**
98
- * Declares an element that should be rendered at a certain URL path.
152
+ * Configures an element to render when a pattern matches the current location.
153
+ * It must be rendered within a {@link Routes} element. Note that these routes
154
+ * do not participate in data loading, actions, code splitting, or any other
155
+ * route module features.
99
156
  *
100
- * @see https://reactrouter.com/components/route
157
+ * @category Components
101
158
  */
102
159
  export declare function Route(_props: RouteProps): React.ReactElement | null;
160
+ /**
161
+ * @category Types
162
+ */
103
163
  export interface RouterProps {
104
164
  basename?: string;
105
165
  children?: React.ReactNode;
@@ -107,7 +167,6 @@ export interface RouterProps {
107
167
  navigationType?: NavigationType;
108
168
  navigator: Navigator;
109
169
  static?: boolean;
110
- future?: Partial<Pick<FutureConfig, "v7_relativeSplatPath">>;
111
170
  }
112
171
  /**
113
172
  * Provides location context for the rest of the app.
@@ -116,42 +175,198 @@ export interface RouterProps {
116
175
  * router that is more specific to your environment such as a `<BrowserRouter>`
117
176
  * in web browsers or a `<StaticRouter>` for server rendering.
118
177
  *
119
- * @see https://reactrouter.com/router-components/router
178
+ * @category Components
179
+ */
180
+ export declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
181
+ /**
182
+ * @category Types
120
183
  */
121
- export declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, future, }: RouterProps): React.ReactElement | null;
122
184
  export interface RoutesProps {
185
+ /**
186
+ * Nested {@link Route} elements
187
+ */
123
188
  children?: React.ReactNode;
189
+ /**
190
+ * The location to match against. Defaults to the current location.
191
+ */
124
192
  location?: Partial<Location> | string;
125
193
  }
126
194
  /**
127
- * A container for a nested tree of `<Route>` elements that renders the branch
128
- * that best matches the current location.
129
- *
130
- * @see https://reactrouter.com/components/routes
195
+ Renders a branch of {@link Route | `<Routes>`} that best matches the current
196
+ location. Note that these routes do not participate in data loading, actions,
197
+ code splitting, or any other route module features.
198
+
199
+ ```tsx
200
+ import { Routes, Route } from "react-router"
201
+
202
+ <Routes>
203
+ <Route index element={<StepOne />} />
204
+ <Route path="step-2" element={<StepTwo />} />
205
+ <Route path="step-3" element={<StepThree />}>
206
+ </Routes>
207
+ ```
208
+
209
+ @category Components
131
210
  */
132
211
  export declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
133
212
  export interface AwaitResolveRenderFunction {
134
213
  (data: Awaited<any>): React.ReactNode;
135
214
  }
215
+ /**
216
+ * @category Types
217
+ */
136
218
  export interface AwaitProps {
219
+ /**
220
+ When using a function, the resolved value is provided as the parameter.
221
+
222
+ ```tsx [2]
223
+ <Await resolve={reviewsPromise}>
224
+ {(resolvedReviews) => <Reviews items={resolvedReviews} />}
225
+ </Await>
226
+ ```
227
+
228
+ When using React elements, {@link useAsyncValue} will provide the
229
+ resolved value:
230
+
231
+ ```tsx [2]
232
+ <Await resolve={reviewsPromise}>
233
+ <Reviews />
234
+ </Await>
235
+
236
+ function Reviews() {
237
+ const resolvedReviews = useAsyncValue()
238
+ return <div>...</div>
239
+ }
240
+ ```
241
+ */
137
242
  children: React.ReactNode | AwaitResolveRenderFunction;
243
+ /**
244
+ The error element renders instead of the children when the promise rejects.
245
+
246
+ ```tsx
247
+ <Await
248
+ errorElement={<div>Oops</div>}
249
+ resolve={reviewsPromise}
250
+ >
251
+ <Reviews />
252
+ </Await>
253
+ ```
254
+
255
+ To provide a more contextual error, you can use the {@link useAsyncError} in a
256
+ child component
257
+
258
+ ```tsx
259
+ <Await
260
+ errorElement={<ReviewsError />}
261
+ resolve={reviewsPromise}
262
+ >
263
+ <Reviews />
264
+ </Await>
265
+
266
+ function ReviewsError() {
267
+ const error = useAsyncError()
268
+ return <div>Error loading reviews: {error.message}</div>
269
+ }
270
+ ```
271
+
272
+ If you do not provide an errorElement, the rejected value will bubble up to
273
+ the nearest route-level {@link NonIndexRouteObject#ErrorBoundary | ErrorBoundary} and be accessible
274
+ via {@link useRouteError} hook.
275
+ */
138
276
  errorElement?: React.ReactNode;
277
+ /**
278
+ Takes a promise returned from a {@link LoaderFunction | loader} value to be resolved and rendered.
279
+
280
+ ```jsx
281
+ import { useLoaderData, Await } from "react-router"
282
+
283
+ export async function loader() {
284
+ let reviews = getReviews() // not awaited
285
+ let book = await getBook()
286
+ return {
287
+ book,
288
+ reviews, // this is a promise
289
+ }
290
+ }
291
+
292
+ export default function Book() {
293
+ const {
294
+ book,
295
+ reviews, // this is the same promise
296
+ } = useLoaderData()
297
+
298
+ return (
299
+ <div>
300
+ <h1>{book.title}</h1>
301
+ <p>{book.description}</p>
302
+ <React.Suspense fallback={<ReviewsSkeleton />}>
303
+ <Await
304
+ // and is the promise we pass to Await
305
+ resolve={reviews}
306
+ >
307
+ <Reviews />
308
+ </Await>
309
+ </React.Suspense>
310
+ </div>
311
+ );
312
+ }
313
+ ```
314
+ */
139
315
  resolve: TrackedPromise | any;
140
316
  }
141
317
  /**
142
- * Component to use for rendering lazily loaded data from returning defer()
143
- * in a loader function
144
- */
318
+ Used to render promise values with automatic error handling.
319
+
320
+ ```tsx
321
+ import { Await, useLoaderData } from "react-router";
322
+
323
+ export function loader() {
324
+ // not awaited
325
+ const reviews = getReviews()
326
+ // awaited (blocks the transition)
327
+ const book = await fetch("/api/book").then((res) => res.json())
328
+ return { book, reviews }
329
+ }
330
+
331
+ function Book() {
332
+ const { book, reviews } = useLoaderData();
333
+ return (
334
+ <div>
335
+ <h1>{book.title}</h1>
336
+ <p>{book.description}</p>
337
+ <React.Suspense fallback={<ReviewsSkeleton />}>
338
+ <Await
339
+ resolve={reviews}
340
+ errorElement={
341
+ <div>Could not load reviews 😬</div>
342
+ }
343
+ children={(resolvedReviews) => (
344
+ <Reviews items={resolvedReviews} />
345
+ )}
346
+ />
347
+ </React.Suspense>
348
+ </div>
349
+ );
350
+ }
351
+ ```
352
+
353
+ **Note:** `<Await>` expects to be rendered inside of a `<React.Suspense>`
354
+
355
+ @category Components
356
+
357
+ */
145
358
  export declare function Await({ children, errorElement, resolve }: AwaitProps): React.JSX.Element;
146
359
  /**
147
360
  * Creates a route config from a React "children" object, which is usually
148
361
  * either a `<Route>` element or an array of them. Used internally by
149
362
  * `<Routes>` to create a route config from its children.
150
363
  *
151
- * @see https://reactrouter.com/utils/create-routes-from-children
364
+ * @category Utils
152
365
  */
153
366
  export declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
154
367
  /**
155
368
  * Renders the result of `matchRoutes()` into a React element.
369
+ *
370
+ * @category Utils
156
371
  */
157
372
  export declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
@@ -1,5 +1,7 @@
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 "@remix-run/router";
2
+ import type { History, Action as NavigationType, Location, To } from "./router/history";
3
+ import type { RelativeRoutingType, Router, StaticHandlerContext } from "./router/router";
4
+ import type { AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticPatchRoutesOnNavigationFunction, AgnosticPatchRoutesOnNavigationFunctionArgs, AgnosticRouteMatch, LazyRouteFunction, TrackedPromise } from "./router/utils";
3
5
  export interface IndexRouteObject {
4
6
  caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
5
7
  path?: AgnosticIndexRouteObject["path"];
@@ -47,20 +49,33 @@ export interface RouteMatch<ParamKey extends string = string, RouteObjectType ex
47
49
  }
48
50
  export interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
49
51
  }
52
+ export type PatchRoutesOnNavigationFunctionArgs = AgnosticPatchRoutesOnNavigationFunctionArgs<RouteObject, RouteMatch>;
53
+ export type PatchRoutesOnNavigationFunction = AgnosticPatchRoutesOnNavigationFunction<RouteObject, RouteMatch>;
50
54
  export interface DataRouterContextObject extends Omit<NavigationContextObject, "future"> {
51
55
  router: Router;
52
56
  staticContext?: StaticHandlerContext;
53
57
  }
54
58
  export declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
55
- export declare const DataRouterStateContext: React.Context<import("@remix-run/router").RouterState | null>;
59
+ export declare const DataRouterStateContext: React.Context<import("./router/router").RouterState | null>;
60
+ export type ViewTransitionContextObject = {
61
+ isTransitioning: false;
62
+ } | {
63
+ isTransitioning: true;
64
+ flushSync: boolean;
65
+ currentLocation: Location;
66
+ nextLocation: Location;
67
+ };
68
+ export declare const ViewTransitionContext: React.Context<ViewTransitionContextObject>;
69
+ export type FetchersContextObject = Map<string, any>;
70
+ export declare const FetchersContext: React.Context<FetchersContextObject>;
56
71
  export declare const AwaitContext: React.Context<TrackedPromise | null>;
57
72
  export interface NavigateOptions {
58
73
  replace?: boolean;
59
74
  state?: any;
60
75
  preventScrollReset?: boolean;
61
76
  relative?: RelativeRoutingType;
62
- unstable_flushSync?: boolean;
63
- unstable_viewTransition?: boolean;
77
+ flushSync?: boolean;
78
+ viewTransition?: boolean;
64
79
  }
65
80
  /**
66
81
  * A Navigator is a "location changer"; it's how you get to different locations.
@@ -82,9 +97,7 @@ interface NavigationContextObject {
82
97
  basename: string;
83
98
  navigator: Navigator;
84
99
  static: boolean;
85
- future: {
86
- v7_relativeSplatPath: boolean;
87
- };
100
+ future: {};
88
101
  }
89
102
  export declare const NavigationContext: React.Context<NavigationContextObject>;
90
103
  interface LocationContextObject {
@@ -0,0 +1,123 @@
1
+ import type { RelativeRoutingType } from "../router/router";
2
+ import type { FormEncType, HTMLFormMethod } from "../router/utils";
3
+ export declare const defaultMethod: HTMLFormMethod;
4
+ export declare function isHtmlElement(object: any): object is HTMLElement;
5
+ export declare function isButtonElement(object: any): object is HTMLButtonElement;
6
+ export declare function isFormElement(object: any): object is HTMLFormElement;
7
+ export declare function isInputElement(object: any): object is HTMLInputElement;
8
+ type LimitedMouseEvent = Pick<MouseEvent, "button" | "metaKey" | "altKey" | "ctrlKey" | "shiftKey">;
9
+ export declare function shouldProcessLinkClick(event: LimitedMouseEvent, target?: string): boolean;
10
+ export type ParamKeyValuePair = [string, string];
11
+ export type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
12
+ /**
13
+ Creates a URLSearchParams object using the given initializer.
14
+
15
+ This is identical to `new URLSearchParams(init)` except it also
16
+ supports arrays as values in the object form of the initializer
17
+ instead of just strings. This is convenient when you need multiple
18
+ values for a given key, but don't want to use an array initializer.
19
+
20
+ For example, instead of:
21
+
22
+ ```tsx
23
+ let searchParams = new URLSearchParams([
24
+ ['sort', 'name'],
25
+ ['sort', 'price']
26
+ ]);
27
+ ```
28
+ you can do:
29
+
30
+ ```
31
+ let searchParams = createSearchParams({
32
+ sort: ['name', 'price']
33
+ });
34
+ ```
35
+
36
+ @category Utils
37
+ */
38
+ export declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
39
+ export declare function getSearchParamsForLocation(locationSearch: string, defaultSearchParams: URLSearchParams | null): URLSearchParams;
40
+ type JsonObject = {
41
+ [Key in string]: JsonValue;
42
+ } & {
43
+ [Key in string]?: JsonValue | undefined;
44
+ };
45
+ type JsonArray = JsonValue[] | readonly JsonValue[];
46
+ type JsonPrimitive = string | number | boolean | null;
47
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
48
+ export type SubmitTarget = HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | JsonValue | null;
49
+ /**
50
+ * Submit options shared by both navigations and fetchers
51
+ */
52
+ interface SharedSubmitOptions {
53
+ /**
54
+ * The HTTP method used to submit the form. Overrides `<form method>`.
55
+ * Defaults to "GET".
56
+ */
57
+ method?: HTMLFormMethod;
58
+ /**
59
+ * The action URL path used to submit the form. Overrides `<form action>`.
60
+ * Defaults to the path of the current route.
61
+ */
62
+ action?: string;
63
+ /**
64
+ * The encoding used to submit the form. Overrides `<form encType>`.
65
+ * Defaults to "application/x-www-form-urlencoded".
66
+ */
67
+ encType?: FormEncType;
68
+ /**
69
+ * Determines whether the form action is relative to the route hierarchy or
70
+ * the pathname. Use this if you want to opt out of navigating the route
71
+ * hierarchy and want to instead route based on /-delimited URL segments
72
+ */
73
+ relative?: RelativeRoutingType;
74
+ /**
75
+ * In browser-based environments, prevent resetting scroll after this
76
+ * navigation when using the <ScrollRestoration> component
77
+ */
78
+ preventScrollReset?: boolean;
79
+ /**
80
+ * Enable flushSync for this submission's state updates
81
+ */
82
+ flushSync?: boolean;
83
+ }
84
+ /**
85
+ * Submit options available to fetchers
86
+ */
87
+ export interface FetcherSubmitOptions extends SharedSubmitOptions {
88
+ }
89
+ /**
90
+ * Submit options available to navigations
91
+ */
92
+ export interface SubmitOptions extends FetcherSubmitOptions {
93
+ /**
94
+ * Set `true` to replace the current entry in the browser's history stack
95
+ * instead of creating a new one (i.e. stay on "the same page"). Defaults
96
+ * to `false`.
97
+ */
98
+ replace?: boolean;
99
+ /**
100
+ * State object to add to the history stack entry for this navigation
101
+ */
102
+ state?: any;
103
+ /**
104
+ * Indicate a specific fetcherKey to use when using navigate=false
105
+ */
106
+ fetcherKey?: string;
107
+ /**
108
+ * navigate=false will use a fetcher instead of a navigation
109
+ */
110
+ navigate?: boolean;
111
+ /**
112
+ * Enable view transitions on this submission navigation
113
+ */
114
+ viewTransition?: boolean;
115
+ }
116
+ export declare function getFormSubmissionInfo(target: SubmitTarget, basename: string): {
117
+ action: string | null;
118
+ method: string;
119
+ encType: string;
120
+ formData: FormData | undefined;
121
+ body: any;
122
+ };
123
+ export {};
@@ -0,0 +1,40 @@
1
+ import type { HydrationState, Router as DataRouter } from "../router/router";
2
+ import type { AssetsManifest, FutureConfig } from "./ssr/entry";
3
+ import type { RouteModules } from "./ssr/routeModules";
4
+ export type WindowReactRouterContext = {
5
+ basename?: string;
6
+ state: HydrationState;
7
+ criticalCss?: string;
8
+ future: FutureConfig;
9
+ isSpaMode: boolean;
10
+ stream: ReadableStream<Uint8Array> | undefined;
11
+ streamController: ReadableStreamDefaultController<Uint8Array>;
12
+ a?: number;
13
+ dev?: {
14
+ port?: number;
15
+ hmrRuntime?: string;
16
+ };
17
+ };
18
+ export interface ViewTransition {
19
+ finished: Promise<void>;
20
+ ready: Promise<void>;
21
+ updateCallbackDone: Promise<void>;
22
+ skipTransition(): void;
23
+ }
24
+ declare global {
25
+ var __staticRouterHydrationData: HydrationState | undefined;
26
+ var __reactRouterVersion: string;
27
+ interface Document {
28
+ startViewTransition(cb: () => Promise<void> | void): ViewTransition;
29
+ }
30
+ var __reactRouterContext: WindowReactRouterContext | undefined;
31
+ var __reactRouterManifest: AssetsManifest | undefined;
32
+ var __reactRouterRouteModules: RouteModules | undefined;
33
+ var __reactRouterInstance: DataRouter | undefined;
34
+ var __reactRouterHdrActive: boolean;
35
+ var __reactRouterClearCriticalCss: (() => void) | undefined;
36
+ var $RefreshRuntime$: {
37
+ performReactRefresh: () => void;
38
+ } | undefined;
39
+ }
40
+ export {};