react-router 0.0.0-experimental-ffd8c7d0 → 0.0.0-experimental-12345
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/{LICENSE → LICENSE.md} +2 -1
- package/README.md +3 -3
- package/index.d.ts +14 -335
- package/index.js +940 -27
- package/index.js.map +1 -1
- package/lib/components.d.ts +110 -0
- package/lib/context.d.ts +31 -0
- package/lib/hooks.d.ts +99 -0
- package/lib/router.d.ts +120 -0
- package/main.js +19 -1
- package/package.json +15 -12
- package/react-router.development.js +894 -23
- package/react-router.development.js.map +1 -1
- package/react-router.production.min.js +11 -1
- package/react-router.production.min.js.map +1 -1
- package/umd/react-router.development.js +989 -41
- package/umd/react-router.development.js.map +1 -1
- package/umd/react-router.production.min.js +11 -1
- package/umd/react-router.production.min.js.map +1 -1
- package/umd/index.d.ts +0 -335
package/{LICENSE → LICENSE.md}
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) React Training
|
|
3
|
+
Copyright (c) React Training 2015-2019
|
|
4
|
+
Copyright (c) Remix Software 2020-2021
|
|
4
5
|
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# React Router
|
|
2
2
|
|
|
3
|
-
The `react-router` package is the heart of [React Router](/) and provides all
|
|
3
|
+
The `react-router` package is the heart of [React Router](https://github.com/remix-run/react-router) and provides all
|
|
4
4
|
the core functionality for both
|
|
5
|
-
[`react-router-dom`](
|
|
5
|
+
[`react-router-dom`](/packages/react-router-dom)
|
|
6
6
|
and
|
|
7
|
-
[`react-router-native`](
|
|
7
|
+
[`react-router-native`](/packages/react-router-native).
|
|
8
8
|
|
|
9
9
|
If you're using React Router, you should never `import` anything directly from
|
|
10
10
|
the `react-router` package, but you should have everything you need in either
|
package/index.d.ts
CHANGED
|
@@ -1,335 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* A <Router> that stores all entries in memory.
|
|
16
|
-
*
|
|
17
|
-
* @see https://reactrouter.com/api/MemoryRouter
|
|
18
|
-
*/
|
|
19
|
-
export declare function MemoryRouter({ children, initialEntries, initialIndex, timeoutMs }: MemoryRouterProps): React.ReactElement;
|
|
20
|
-
export declare namespace MemoryRouter {
|
|
21
|
-
var displayName: string;
|
|
22
|
-
var propTypes: {
|
|
23
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
24
|
-
initialEntries: PropTypes.Requireable<(string | PropTypes.InferProps<{
|
|
25
|
-
pathname: PropTypes.Requireable<string>;
|
|
26
|
-
search: PropTypes.Requireable<string>;
|
|
27
|
-
hash: PropTypes.Requireable<string>;
|
|
28
|
-
state: PropTypes.Requireable<object>;
|
|
29
|
-
key: PropTypes.Requireable<string>;
|
|
30
|
-
}> | null | undefined)[]>;
|
|
31
|
-
initialIndex: PropTypes.Requireable<number>;
|
|
32
|
-
timeoutMs: PropTypes.Requireable<number>;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export interface MemoryRouterProps {
|
|
36
|
-
children?: React.ReactNode;
|
|
37
|
-
initialEntries?: InitialEntry[];
|
|
38
|
-
initialIndex?: number;
|
|
39
|
-
timeoutMs?: number;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Changes the current location.
|
|
43
|
-
*
|
|
44
|
-
* Note: This API is mostly useful in React.Component subclasses that are not
|
|
45
|
-
* able to use hooks. In functional components, we recommend you use the
|
|
46
|
-
* `useNavigate` hook instead.
|
|
47
|
-
*
|
|
48
|
-
* @see https://reactrouter.com/api/Navigate
|
|
49
|
-
*/
|
|
50
|
-
export declare function Navigate({ to, replace, state }: NavigateProps): null;
|
|
51
|
-
export declare namespace Navigate {
|
|
52
|
-
var displayName: string;
|
|
53
|
-
var propTypes: {
|
|
54
|
-
to: PropTypes.Validator<string | PropTypes.InferProps<{
|
|
55
|
-
pathname: PropTypes.Requireable<string>;
|
|
56
|
-
search: PropTypes.Requireable<string>;
|
|
57
|
-
hash: PropTypes.Requireable<string>;
|
|
58
|
-
}>>;
|
|
59
|
-
replace: PropTypes.Requireable<boolean>;
|
|
60
|
-
state: PropTypes.Requireable<object>;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export interface NavigateProps {
|
|
64
|
-
to: To;
|
|
65
|
-
replace?: boolean;
|
|
66
|
-
state?: State;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Renders the child route's element, if there is one.
|
|
70
|
-
*
|
|
71
|
-
* @see https://reactrouter.com/api/Outlet
|
|
72
|
-
*/
|
|
73
|
-
export declare function Outlet(): React.ReactElement | null;
|
|
74
|
-
export declare namespace Outlet {
|
|
75
|
-
var displayName: string;
|
|
76
|
-
var propTypes: {};
|
|
77
|
-
}
|
|
78
|
-
export interface OutletProps {
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Declares an element that should be rendered at a certain URL path.
|
|
82
|
-
*
|
|
83
|
-
* @see https://reactrouter.com/api/Route
|
|
84
|
-
*/
|
|
85
|
-
export declare function Route({ element }: RouteProps): React.ReactElement | null;
|
|
86
|
-
export declare namespace Route {
|
|
87
|
-
var displayName: string;
|
|
88
|
-
var propTypes: {
|
|
89
|
-
caseSensitive: PropTypes.Requireable<boolean>;
|
|
90
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
91
|
-
element: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
92
|
-
path: PropTypes.Requireable<string>;
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
export interface RouteProps {
|
|
96
|
-
caseSensitive?: boolean;
|
|
97
|
-
children?: React.ReactNode;
|
|
98
|
-
element?: React.ReactElement | null;
|
|
99
|
-
path?: string;
|
|
100
|
-
preload?: RoutePreloadFunction;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Provides location context for the rest of the app.
|
|
104
|
-
*
|
|
105
|
-
* Note: You usually won't render a <Router> directly. Instead, you'll render a
|
|
106
|
-
* router that is more specific to your environment such as a <BrowserRouter>
|
|
107
|
-
* in web browsers or a <StaticRouter> for server rendering.
|
|
108
|
-
*
|
|
109
|
-
* @see https://reactrouter.com/api/Router
|
|
110
|
-
*/
|
|
111
|
-
export declare function Router({ children, action, location, navigator, pending, static: staticProp }: RouterProps): React.ReactElement;
|
|
112
|
-
export declare namespace Router {
|
|
113
|
-
var displayName: string;
|
|
114
|
-
var propTypes: {
|
|
115
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
116
|
-
action: PropTypes.Requireable<string>;
|
|
117
|
-
location: PropTypes.Validator<object>;
|
|
118
|
-
navigator: PropTypes.Validator<PropTypes.InferProps<{
|
|
119
|
-
createHref: PropTypes.Validator<(...args: any[]) => any>;
|
|
120
|
-
push: PropTypes.Validator<(...args: any[]) => any>;
|
|
121
|
-
replace: PropTypes.Validator<(...args: any[]) => any>;
|
|
122
|
-
go: PropTypes.Validator<(...args: any[]) => any>;
|
|
123
|
-
block: PropTypes.Validator<(...args: any[]) => any>;
|
|
124
|
-
}>>;
|
|
125
|
-
pending: PropTypes.Requireable<boolean>;
|
|
126
|
-
static: PropTypes.Requireable<boolean>;
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
export interface RouterProps {
|
|
130
|
-
action?: Action;
|
|
131
|
-
children?: React.ReactNode;
|
|
132
|
-
location: Location;
|
|
133
|
-
navigator: Navigator;
|
|
134
|
-
pending?: boolean;
|
|
135
|
-
static?: boolean;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* A container for a nested tree of <Route> elements that renders the branch
|
|
139
|
-
* that best matches the current location.
|
|
140
|
-
*
|
|
141
|
-
* @see https://reactrouter.com/api/Routes
|
|
142
|
-
*/
|
|
143
|
-
export declare function Routes({ basename, children }: RoutesProps): React.ReactElement | null;
|
|
144
|
-
export declare namespace Routes {
|
|
145
|
-
var displayName: string;
|
|
146
|
-
var propTypes: {
|
|
147
|
-
basename: PropTypes.Requireable<string>;
|
|
148
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
export interface RoutesProps {
|
|
152
|
-
basename?: string;
|
|
153
|
-
children?: React.ReactNode;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Blocks all navigation attempts. This is useful for preventing the page from
|
|
157
|
-
* changing until some condition is met, like saving form data.
|
|
158
|
-
*
|
|
159
|
-
* @see https://reactrouter.com/api/useBlocker
|
|
160
|
-
*/
|
|
161
|
-
export declare function useBlocker(blocker: Blocker, when?: boolean): void;
|
|
162
|
-
/**
|
|
163
|
-
* Returns the full href for the given "to" value. This is useful for building
|
|
164
|
-
* custom links that are also accessible and preserve right-click behavior.
|
|
165
|
-
*
|
|
166
|
-
* @see https://reactrouter.com/api/useHref
|
|
167
|
-
*/
|
|
168
|
-
export declare function useHref(to: To): string;
|
|
169
|
-
/**
|
|
170
|
-
* Returns true if this component is a descendant of a <Router>.
|
|
171
|
-
*
|
|
172
|
-
* @see https://reactrouter.com/api/useInRouterContext
|
|
173
|
-
*/
|
|
174
|
-
export declare function useInRouterContext(): boolean;
|
|
175
|
-
/**
|
|
176
|
-
* Returns the current location object, which represents the current URL in web
|
|
177
|
-
* browsers.
|
|
178
|
-
*
|
|
179
|
-
* Note: If you're using this it may mean you're doing some of your own
|
|
180
|
-
* "routing" in your app, and we'd like to know what your use case is. We may
|
|
181
|
-
* be able to provide something higher-level to better suit your needs.
|
|
182
|
-
*
|
|
183
|
-
* @see https://reactrouter.com/api/useLocation
|
|
184
|
-
*/
|
|
185
|
-
export declare function useLocation(): Location;
|
|
186
|
-
/**
|
|
187
|
-
* Returns true if the router is pending a location update.
|
|
188
|
-
*
|
|
189
|
-
* @see https://reactrouter.com/api/useLocationPending
|
|
190
|
-
*/
|
|
191
|
-
export declare function useLocationPending(): boolean;
|
|
192
|
-
/**
|
|
193
|
-
* Returns true if the URL for the given "to" value matches the current URL.
|
|
194
|
-
* This is useful for components that need to know "active" state, e.g.
|
|
195
|
-
* <NavLink>.
|
|
196
|
-
*
|
|
197
|
-
* @see https://reactrouter.com/api/useMatch
|
|
198
|
-
*/
|
|
199
|
-
export declare function useMatch(pattern: PathPattern): PathMatch | null;
|
|
200
|
-
declare type PathPattern = string | {
|
|
201
|
-
path: string;
|
|
202
|
-
caseSensitive?: boolean;
|
|
203
|
-
end?: boolean;
|
|
204
|
-
};
|
|
205
|
-
/**
|
|
206
|
-
* The interface for the navigate() function returned from useNavigate().
|
|
207
|
-
*/
|
|
208
|
-
export interface NavigateFunction {
|
|
209
|
-
(to: To, options?: {
|
|
210
|
-
replace?: boolean;
|
|
211
|
-
state?: State;
|
|
212
|
-
}): void;
|
|
213
|
-
(delta: number): void;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Returns an imperative method for changing the location. Used by <Link>s, but
|
|
217
|
-
* may also be used by other elements to change the location.
|
|
218
|
-
*
|
|
219
|
-
* @see https://reactrouter.com/api/useNavigate
|
|
220
|
-
*/
|
|
221
|
-
export declare function useNavigate(): NavigateFunction;
|
|
222
|
-
/**
|
|
223
|
-
* Returns the element for the child route at this level of the route
|
|
224
|
-
* hierarchy. Used internally by <Outlet> to render child routes.
|
|
225
|
-
*
|
|
226
|
-
* @see https://reactrouter.com/api/useOutlet
|
|
227
|
-
*/
|
|
228
|
-
export declare function useOutlet(): React.ReactElement | null;
|
|
229
|
-
/**
|
|
230
|
-
* Returns an object of key/value pairs of the dynamic params from the current
|
|
231
|
-
* URL that were matched by the route path.
|
|
232
|
-
*
|
|
233
|
-
* @see https://reactrouter.com/api/useParams
|
|
234
|
-
*/
|
|
235
|
-
export declare function useParams(): Params;
|
|
236
|
-
/**
|
|
237
|
-
* Resolves the pathname of the given `to` value against the current location.
|
|
238
|
-
*
|
|
239
|
-
* @see https://reactrouter.com/api/useResolvedPath
|
|
240
|
-
*/
|
|
241
|
-
export declare function useResolvedPath(to: To): Path;
|
|
242
|
-
/**
|
|
243
|
-
* Returns the element of the route that matched the current location, prepared
|
|
244
|
-
* with the correct context to render the remainder of the route tree. Route
|
|
245
|
-
* elements in the tree must render an <Outlet> to render their child route's
|
|
246
|
-
* element.
|
|
247
|
-
*
|
|
248
|
-
* @see https://reactrouter.com/api/useRoutes
|
|
249
|
-
*/
|
|
250
|
-
export declare function useRoutes(partialRoutes: PartialRouteObject[], basename?: string): React.ReactElement | null;
|
|
251
|
-
/**
|
|
252
|
-
* Creates a route config from an array of JavaScript objects. Used internally
|
|
253
|
-
* by `useRoutes` to normalize the route config.
|
|
254
|
-
*
|
|
255
|
-
* @see https://reactrouter.com/api/createRoutesFromArray
|
|
256
|
-
*/
|
|
257
|
-
export declare function createRoutesFromArray(array: PartialRouteObject[]): RouteObject[];
|
|
258
|
-
/**
|
|
259
|
-
* Creates a route config from a React "children" object, which is usually
|
|
260
|
-
* either a `<Route>` element or an array of them. Used internally by
|
|
261
|
-
* `<Routes>` to create a route config from its children.
|
|
262
|
-
*
|
|
263
|
-
* @see https://reactrouter.com/api/createRoutesFromChildren
|
|
264
|
-
*/
|
|
265
|
-
export declare function createRoutesFromChildren(children: React.ReactNode): RouteObject[];
|
|
266
|
-
/**
|
|
267
|
-
* The parameters that were parsed from the URL path.
|
|
268
|
-
*/
|
|
269
|
-
export declare type Params = Record<string, string>;
|
|
270
|
-
/**
|
|
271
|
-
* A route object represents a logical route, with (optionally) its child
|
|
272
|
-
* routes organized in a tree-like structure.
|
|
273
|
-
*/
|
|
274
|
-
export interface RouteObject {
|
|
275
|
-
caseSensitive: boolean;
|
|
276
|
-
children?: RouteObject[];
|
|
277
|
-
element: React.ReactNode;
|
|
278
|
-
path: string;
|
|
279
|
-
preload?: RoutePreloadFunction;
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* A "partial route" object is usually supplied by the user and may omit
|
|
283
|
-
* certain properties of a real route object such as `path` and `element`,
|
|
284
|
-
* which have reasonable defaults.
|
|
285
|
-
*/
|
|
286
|
-
export interface PartialRouteObject {
|
|
287
|
-
caseSensitive?: boolean;
|
|
288
|
-
children?: PartialRouteObject[];
|
|
289
|
-
element?: React.ReactNode;
|
|
290
|
-
path?: string;
|
|
291
|
-
preload?: RoutePreloadFunction;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* A function that will be called when the router is about to render the
|
|
295
|
-
* associated route. This function usually kicks off a fetch or similar
|
|
296
|
-
* operation that primes a local data cache for retrieval while rendering
|
|
297
|
-
* later.
|
|
298
|
-
*/
|
|
299
|
-
declare type RoutePreloadFunction = (params: Params, location: Location, index: number) => void;
|
|
300
|
-
/**
|
|
301
|
-
* Returns a path with params interpolated.
|
|
302
|
-
*
|
|
303
|
-
* @see https://reactrouter.com/api/generatePath
|
|
304
|
-
*/
|
|
305
|
-
export declare function generatePath(path: string, params?: Params): string;
|
|
306
|
-
/**
|
|
307
|
-
* Matches the given routes to a location and returns the match data.
|
|
308
|
-
*
|
|
309
|
-
* @see https://reactrouter.com/api/matchRoutes
|
|
310
|
-
*/
|
|
311
|
-
export declare function matchRoutes(routes: RouteObject[], location: string | PartialLocation, basename?: string): RouteMatch[] | null;
|
|
312
|
-
export interface RouteMatch {
|
|
313
|
-
route: RouteObject;
|
|
314
|
-
pathname: string;
|
|
315
|
-
params: Params;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Performs pattern matching on a URL pathname and returns information about
|
|
319
|
-
* the match.
|
|
320
|
-
*
|
|
321
|
-
* @see https://reactrouter.com/api/matchPath
|
|
322
|
-
*/
|
|
323
|
-
export declare function matchPath(pattern: PathPattern, pathname: string): PathMatch | null;
|
|
324
|
-
export interface PathMatch {
|
|
325
|
-
path: string;
|
|
326
|
-
pathname: string;
|
|
327
|
-
params: Params;
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Returns a resolved path object relative to the given pathname.
|
|
331
|
-
*
|
|
332
|
-
* @see https://reactrouter.com/api/resolvePath
|
|
333
|
-
*/
|
|
334
|
-
export declare function resolvePath(to: To, fromPathname?: string): Path;
|
|
335
|
-
export {};
|
|
1
|
+
import type { Hash, Location, Path, Pathname, Search, To } from "history";
|
|
2
|
+
import { Action as NavigationType, parsePath, createPath } from "history";
|
|
3
|
+
import type { MemoryRouterProps, NavigateProps, OutletProps, RouteProps, PathRouteProps, LayoutRouteProps, IndexRouteProps, RouterProps, RoutesProps } from "./lib/components";
|
|
4
|
+
import { createRoutesFromChildren, renderMatches, MemoryRouter, Navigate, Outlet, Route, Router, Routes } from "./lib/components";
|
|
5
|
+
import type { Navigator } from "./lib/context";
|
|
6
|
+
import { LocationContext, NavigationContext, RouteContext } from "./lib/context";
|
|
7
|
+
import type { NavigateFunction, NavigateOptions } from "./lib/hooks";
|
|
8
|
+
import { useHref, useInRouterContext, useLocation, useMatch, useNavigationType, useNavigate, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes } from "./lib/hooks";
|
|
9
|
+
import type { Params, PathMatch, PathPattern, RouteMatch, RouteObject } from "./lib/router";
|
|
10
|
+
import { generatePath, matchPath, matchRoutes, resolvePath } from "./lib/router";
|
|
11
|
+
export type { Hash, IndexRouteProps, LayoutRouteProps, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, OutletProps, PathMatch, PathPattern, PathRouteProps, RouteMatch, RouteObject, RouteProps, RouterProps, RoutesProps, Navigator, Params, Path, Pathname, Search, To, };
|
|
12
|
+
export { MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, Routes, createPath, createRoutesFromChildren, generatePath, matchPath, matchRoutes, parsePath, renderMatches, resolvePath, useHref, useInRouterContext, useLocation, useMatch, useNavigate, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, };
|
|
13
|
+
/** @internal */
|
|
14
|
+
export { NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext, };
|