react-router-dom 5.2.0 → 6.11.2
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 +345 -0
- package/{LICENSE → LICENSE.md} +3 -1
- package/README.md +4 -36
- package/dist/dom.d.ts +76 -0
- package/dist/index.d.ts +246 -0
- package/dist/index.js +1058 -0
- package/dist/index.js.map +1 -0
- package/dist/main.js +19 -0
- package/dist/react-router-dom.development.js +1005 -0
- package/dist/react-router-dom.development.js.map +1 -0
- package/dist/react-router-dom.production.min.js +12 -0
- package/dist/react-router-dom.production.min.js.map +1 -0
- package/dist/server.d.ts +28 -0
- package/dist/server.js +319 -0
- package/dist/server.mjs +291 -0
- package/dist/umd/react-router-dom.development.js +1306 -0
- package/dist/umd/react-router-dom.development.js.map +1 -0
- package/dist/umd/react-router-dom.production.min.js +12 -0
- package/dist/umd/react-router-dom.production.min.js.map +1 -0
- package/package.json +38 -54
- package/server.d.ts +28 -0
- package/server.js +319 -0
- package/server.mjs +291 -0
- package/BrowserRouter.js +0 -3
- package/HashRouter.js +0 -3
- package/Link.js +0 -3
- package/MemoryRouter.js +0 -3
- package/NavLink.js +0 -3
- package/Prompt.js +0 -3
- package/Redirect.js +0 -3
- package/Route.js +0 -3
- package/Router.js +0 -3
- package/StaticRouter.js +0 -3
- package/Switch.js +0 -3
- package/cjs/react-router-dom.js +0 -443
- package/cjs/react-router-dom.js.map +0 -1
- package/cjs/react-router-dom.min.js +0 -2
- package/cjs/react-router-dom.min.js.map +0 -1
- package/es/BrowserRouter.js +0 -5
- package/es/HashRouter.js +0 -5
- package/es/Link.js +0 -5
- package/es/MemoryRouter.js +0 -5
- package/es/NavLink.js +0 -5
- package/es/Prompt.js +0 -5
- package/es/Redirect.js +0 -5
- package/es/Route.js +0 -5
- package/es/Router.js +0 -5
- package/es/StaticRouter.js +0 -5
- package/es/Switch.js +0 -5
- package/es/generatePath.js +0 -5
- package/es/matchPath.js +0 -5
- package/es/warnAboutDeprecatedESMImport.js +0 -34
- package/es/withRouter.js +0 -5
- package/esm/react-router-dom.js +0 -317
- package/esm/react-router-dom.js.map +0 -1
- package/generatePath.js +0 -3
- package/index.js +0 -7
- package/matchPath.js +0 -3
- package/modules/BrowserRouter.js +0 -36
- package/modules/HashRouter.js +0 -35
- package/modules/Link.js +0 -146
- package/modules/NavLink.js +0 -125
- package/modules/index.js +0 -21
- package/modules/utils/locationUtils.js +0 -10
- package/umd/react-router-dom.js +0 -3969
- package/umd/react-router-dom.js.map +0 -1
- package/umd/react-router-dom.min.js +0 -2
- package/umd/react-router-dom.min.js.map +0 -1
- package/warnAboutDeprecatedCJSRequire.js +0 -36
- package/withRouter.js +0 -3
package/modules/NavLink.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { __RouterContext as RouterContext, matchPath } from "react-router";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import invariant from "tiny-invariant";
|
|
5
|
-
import Link from "./Link.js";
|
|
6
|
-
import {
|
|
7
|
-
resolveToLocation,
|
|
8
|
-
normalizeToLocation
|
|
9
|
-
} from "./utils/locationUtils.js";
|
|
10
|
-
|
|
11
|
-
// React 15 compat
|
|
12
|
-
const forwardRefShim = C => C;
|
|
13
|
-
let { forwardRef } = React;
|
|
14
|
-
if (typeof forwardRef === "undefined") {
|
|
15
|
-
forwardRef = forwardRefShim;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function joinClassnames(...classnames) {
|
|
19
|
-
return classnames.filter(i => i).join(" ");
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* A <Link> wrapper that knows if it's "active" or not.
|
|
24
|
-
*/
|
|
25
|
-
const NavLink = forwardRef(
|
|
26
|
-
(
|
|
27
|
-
{
|
|
28
|
-
"aria-current": ariaCurrent = "page",
|
|
29
|
-
activeClassName = "active",
|
|
30
|
-
activeStyle,
|
|
31
|
-
className: classNameProp,
|
|
32
|
-
exact,
|
|
33
|
-
isActive: isActiveProp,
|
|
34
|
-
location: locationProp,
|
|
35
|
-
sensitive,
|
|
36
|
-
strict,
|
|
37
|
-
style: styleProp,
|
|
38
|
-
to,
|
|
39
|
-
innerRef, // TODO: deprecate
|
|
40
|
-
...rest
|
|
41
|
-
},
|
|
42
|
-
forwardedRef
|
|
43
|
-
) => {
|
|
44
|
-
return (
|
|
45
|
-
<RouterContext.Consumer>
|
|
46
|
-
{context => {
|
|
47
|
-
invariant(context, "You should not use <NavLink> outside a <Router>");
|
|
48
|
-
|
|
49
|
-
const currentLocation = locationProp || context.location;
|
|
50
|
-
const toLocation = normalizeToLocation(
|
|
51
|
-
resolveToLocation(to, currentLocation),
|
|
52
|
-
currentLocation
|
|
53
|
-
);
|
|
54
|
-
const { pathname: path } = toLocation;
|
|
55
|
-
// Regex taken from: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L202
|
|
56
|
-
const escapedPath =
|
|
57
|
-
path && path.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
|
58
|
-
|
|
59
|
-
const match = escapedPath
|
|
60
|
-
? matchPath(currentLocation.pathname, {
|
|
61
|
-
path: escapedPath,
|
|
62
|
-
exact,
|
|
63
|
-
sensitive,
|
|
64
|
-
strict
|
|
65
|
-
})
|
|
66
|
-
: null;
|
|
67
|
-
const isActive = !!(isActiveProp
|
|
68
|
-
? isActiveProp(match, currentLocation)
|
|
69
|
-
: match);
|
|
70
|
-
|
|
71
|
-
const className = isActive
|
|
72
|
-
? joinClassnames(classNameProp, activeClassName)
|
|
73
|
-
: classNameProp;
|
|
74
|
-
const style = isActive ? { ...styleProp, ...activeStyle } : styleProp;
|
|
75
|
-
|
|
76
|
-
const props = {
|
|
77
|
-
"aria-current": (isActive && ariaCurrent) || null,
|
|
78
|
-
className,
|
|
79
|
-
style,
|
|
80
|
-
to: toLocation,
|
|
81
|
-
...rest
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// React 15 compat
|
|
85
|
-
if (forwardRefShim !== forwardRef) {
|
|
86
|
-
props.ref = forwardedRef || innerRef;
|
|
87
|
-
} else {
|
|
88
|
-
props.innerRef = innerRef;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return <Link {...props} />;
|
|
92
|
-
}}
|
|
93
|
-
</RouterContext.Consumer>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
if (__DEV__) {
|
|
99
|
-
NavLink.displayName = "NavLink";
|
|
100
|
-
|
|
101
|
-
const ariaCurrentType = PropTypes.oneOf([
|
|
102
|
-
"page",
|
|
103
|
-
"step",
|
|
104
|
-
"location",
|
|
105
|
-
"date",
|
|
106
|
-
"time",
|
|
107
|
-
"true"
|
|
108
|
-
]);
|
|
109
|
-
|
|
110
|
-
NavLink.propTypes = {
|
|
111
|
-
...Link.propTypes,
|
|
112
|
-
"aria-current": ariaCurrentType,
|
|
113
|
-
activeClassName: PropTypes.string,
|
|
114
|
-
activeStyle: PropTypes.object,
|
|
115
|
-
className: PropTypes.string,
|
|
116
|
-
exact: PropTypes.bool,
|
|
117
|
-
isActive: PropTypes.func,
|
|
118
|
-
location: PropTypes.object,
|
|
119
|
-
sensitive: PropTypes.bool,
|
|
120
|
-
strict: PropTypes.bool,
|
|
121
|
-
style: PropTypes.object
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export default NavLink;
|
package/modules/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
MemoryRouter,
|
|
3
|
-
Prompt,
|
|
4
|
-
Redirect,
|
|
5
|
-
Route,
|
|
6
|
-
Router,
|
|
7
|
-
StaticRouter,
|
|
8
|
-
Switch,
|
|
9
|
-
generatePath,
|
|
10
|
-
matchPath,
|
|
11
|
-
withRouter,
|
|
12
|
-
useHistory,
|
|
13
|
-
useLocation,
|
|
14
|
-
useParams,
|
|
15
|
-
useRouteMatch
|
|
16
|
-
} from "react-router";
|
|
17
|
-
|
|
18
|
-
export { default as BrowserRouter } from "./BrowserRouter.js";
|
|
19
|
-
export { default as HashRouter } from "./HashRouter.js";
|
|
20
|
-
export { default as Link } from "./Link.js";
|
|
21
|
-
export { default as NavLink } from "./NavLink.js";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createLocation } from "history";
|
|
2
|
-
|
|
3
|
-
export const resolveToLocation = (to, currentLocation) =>
|
|
4
|
-
typeof to === "function" ? to(currentLocation) : to;
|
|
5
|
-
|
|
6
|
-
export const normalizeToLocation = (to, currentLocation) => {
|
|
7
|
-
return typeof to === "string"
|
|
8
|
-
? createLocation(to, null, null, currentLocation)
|
|
9
|
-
: to;
|
|
10
|
-
};
|