react-router-dom 4.3.1 → 5.3.4
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/BrowserRouter.js +2 -66
- package/HashRouter.js +2 -65
- package/LICENSE +22 -0
- package/Link.js +2 -116
- package/MemoryRouter.js +2 -10
- package/NavLink.js +2 -90
- package/Prompt.js +2 -10
- package/README.md +7 -7
- package/Redirect.js +2 -10
- package/Route.js +2 -10
- package/Router.js +2 -10
- package/StaticRouter.js +2 -10
- package/Switch.js +2 -10
- package/cjs/react-router-dom.js +455 -0
- package/cjs/react-router-dom.js.map +1 -0
- package/cjs/react-router-dom.min.js +2 -0
- package/cjs/react-router-dom.min.js.map +1 -0
- package/es/BrowserRouter.js +4 -51
- package/es/HashRouter.js +4 -50
- package/es/Link.js +4 -103
- package/es/MemoryRouter.js +4 -3
- package/es/NavLink.js +4 -73
- package/es/Prompt.js +4 -3
- package/es/Redirect.js +4 -3
- package/es/Route.js +4 -3
- package/es/Router.js +4 -3
- package/es/StaticRouter.js +4 -3
- package/es/Switch.js +4 -3
- package/es/generatePath.js +4 -3
- package/es/matchPath.js +4 -3
- package/es/warnAboutDeprecatedESMImport.js +34 -0
- package/es/withRouter.js +4 -3
- package/esm/react-router-dom.js +319 -0
- package/esm/react-router-dom.js.map +1 -0
- package/generatePath.js +2 -10
- package/index.js +5 -75
- package/matchPath.js +2 -10
- package/modules/BrowserRouter.js +36 -0
- package/modules/HashRouter.js +35 -0
- package/modules/Link.js +148 -0
- package/modules/NavLink.js +134 -0
- package/modules/index.js +21 -0
- package/modules/utils/locationUtils.js +10 -0
- package/package.json +24 -51
- package/umd/react-router-dom.js +1911 -1713
- package/umd/react-router-dom.js.map +1 -0
- package/umd/react-router-dom.min.js +2 -1
- package/umd/react-router-dom.min.js.map +1 -0
- package/warnAboutDeprecatedCJSRequire.js +36 -0
- package/withRouter.js +2 -10
- package/es/RouterContext.js +0 -4
- package/es/index.js +0 -28
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-router-dom.js","sources":["../modules/BrowserRouter.js","../modules/HashRouter.js","../modules/utils/locationUtils.js","../modules/Link.js","../modules/NavLink.js"],"sourcesContent":["import React from \"react\";\nimport { Router } from \"react-router\";\nimport { createBrowserHistory as createHistory } from \"history\";\nimport PropTypes from \"prop-types\";\nimport warning from \"tiny-warning\";\n\n/**\n * The public API for a <Router> that uses HTML5 history.\n */\nclass BrowserRouter extends React.Component {\n history = createHistory(this.props);\n\n render() {\n return <Router history={this.history} children={this.props.children} />;\n }\n}\n\nif (__DEV__) {\n BrowserRouter.propTypes = {\n basename: PropTypes.string,\n children: PropTypes.node,\n forceRefresh: PropTypes.bool,\n getUserConfirmation: PropTypes.func,\n keyLength: PropTypes.number\n };\n\n BrowserRouter.prototype.componentDidMount = function() {\n warning(\n !this.props.history,\n \"<BrowserRouter> ignores the history prop. To use a custom history, \" +\n \"use `import { Router }` instead of `import { BrowserRouter as Router }`.\"\n );\n };\n}\n\nexport default BrowserRouter;\n","import React from \"react\";\nimport { Router } from \"react-router\";\nimport { createHashHistory as createHistory } from \"history\";\nimport PropTypes from \"prop-types\";\nimport warning from \"tiny-warning\";\n\n/**\n * The public API for a <Router> that uses window.location.hash.\n */\nclass HashRouter extends React.Component {\n history = createHistory(this.props);\n\n render() {\n return <Router history={this.history} children={this.props.children} />;\n }\n}\n\nif (__DEV__) {\n HashRouter.propTypes = {\n basename: PropTypes.string,\n children: PropTypes.node,\n getUserConfirmation: PropTypes.func,\n hashType: PropTypes.oneOf([\"hashbang\", \"noslash\", \"slash\"])\n };\n\n HashRouter.prototype.componentDidMount = function() {\n warning(\n !this.props.history,\n \"<HashRouter> ignores the history prop. To use a custom history, \" +\n \"use `import { Router }` instead of `import { HashRouter as Router }`.\"\n );\n };\n}\n\nexport default HashRouter;\n","import { createLocation } from \"history\";\n\nexport const resolveToLocation = (to, currentLocation) =>\n typeof to === \"function\" ? to(currentLocation) : to;\n\nexport const normalizeToLocation = (to, currentLocation) => {\n return typeof to === \"string\"\n ? createLocation(to, null, null, currentLocation)\n : to;\n};\n","import React from \"react\";\nimport { __RouterContext as RouterContext } from \"react-router\";\nimport { createPath } from 'history';\nimport PropTypes from \"prop-types\";\nimport invariant from \"tiny-invariant\";\nimport {\n resolveToLocation,\n normalizeToLocation\n} from \"./utils/locationUtils.js\";\n\n// React 15 compat\nconst forwardRefShim = C => C;\nlet { forwardRef } = React;\nif (typeof forwardRef === \"undefined\") {\n forwardRef = forwardRefShim;\n}\n\nfunction isModifiedEvent(event) {\n return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);\n}\n\nconst LinkAnchor = forwardRef(\n (\n {\n innerRef, // TODO: deprecate\n navigate,\n onClick,\n ...rest\n },\n forwardedRef\n ) => {\n const { target } = rest;\n\n let props = {\n ...rest,\n onClick: event => {\n try {\n if (onClick) onClick(event);\n } catch (ex) {\n event.preventDefault();\n throw ex;\n }\n\n if (\n !event.defaultPrevented && // onClick prevented default\n event.button === 0 && // ignore everything but left clicks\n (!target || target === \"_self\") && // let browser handle \"target=_blank\" etc.\n !isModifiedEvent(event) // ignore clicks with modifier keys\n ) {\n event.preventDefault();\n navigate();\n }\n }\n };\n\n // React 15 compat\n if (forwardRefShim !== forwardRef) {\n props.ref = forwardedRef || innerRef;\n } else {\n props.ref = innerRef;\n }\n\n /* eslint-disable-next-line jsx-a11y/anchor-has-content */\n return <a {...props} />;\n }\n);\n\nif (__DEV__) {\n LinkAnchor.displayName = \"LinkAnchor\";\n}\n\n/**\n * The public API for rendering a history-aware <a>.\n */\nconst Link = forwardRef(\n (\n {\n component = LinkAnchor,\n replace,\n to,\n innerRef, // TODO: deprecate\n ...rest\n },\n forwardedRef\n ) => {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Link> outside a <Router>\");\n\n const { history } = context;\n\n const location = normalizeToLocation(\n resolveToLocation(to, context.location),\n context.location\n );\n\n const href = location ? history.createHref(location) : \"\";\n const props = {\n ...rest,\n href,\n navigate() {\n const location = resolveToLocation(to, context.location);\n const isDuplicateNavigation = createPath(context.location) === createPath(normalizeToLocation(location));\n const method = (replace || isDuplicateNavigation) ? history.replace : history.push;\n\n method(location);\n }\n };\n\n // React 15 compat\n if (forwardRefShim !== forwardRef) {\n props.ref = forwardedRef || innerRef;\n } else {\n props.innerRef = innerRef;\n }\n\n return React.createElement(component, props);\n }}\n </RouterContext.Consumer>\n );\n }\n);\n\nif (__DEV__) {\n const toType = PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.object,\n PropTypes.func\n ]);\n const refType = PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.func,\n PropTypes.shape({ current: PropTypes.any })\n ]);\n\n Link.displayName = \"Link\";\n\n Link.propTypes = {\n innerRef: refType,\n onClick: PropTypes.func,\n replace: PropTypes.bool,\n target: PropTypes.string,\n to: toType.isRequired\n };\n}\n\nexport default Link;\n","import React from \"react\";\nimport { __RouterContext as RouterContext, matchPath } from \"react-router\";\nimport PropTypes from \"prop-types\";\nimport invariant from \"tiny-invariant\";\nimport Link from \"./Link.js\";\nimport {\n resolveToLocation,\n normalizeToLocation\n} from \"./utils/locationUtils.js\";\n\n// React 15 compat\nconst forwardRefShim = C => C;\nlet { forwardRef } = React;\nif (typeof forwardRef === \"undefined\") {\n forwardRef = forwardRefShim;\n}\n\nfunction joinClassnames(...classnames) {\n return classnames.filter(i => i).join(\" \");\n}\n\n/**\n * A <Link> wrapper that knows if it's \"active\" or not.\n */\nconst NavLink = forwardRef(\n (\n {\n \"aria-current\": ariaCurrent = \"page\",\n activeClassName = \"active\", // TODO: deprecate\n activeStyle, // TODO: deprecate\n className: classNameProp,\n exact,\n isActive: isActiveProp,\n location: locationProp,\n sensitive,\n strict,\n style: styleProp,\n to,\n innerRef, // TODO: deprecate\n ...rest\n },\n forwardedRef\n ) => {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <NavLink> outside a <Router>\");\n\n const currentLocation = locationProp || context.location;\n const toLocation = normalizeToLocation(\n resolveToLocation(to, currentLocation),\n currentLocation\n );\n const { pathname: path } = toLocation;\n // Regex taken from: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L202\n const escapedPath =\n path && path.replace(/([.+*?=^!:${}()[\\]|/\\\\])/g, \"\\\\$1\");\n\n const match = escapedPath\n ? matchPath(currentLocation.pathname, {\n path: escapedPath,\n exact,\n sensitive,\n strict\n })\n : null;\n const isActive = !!(isActiveProp\n ? isActiveProp(match, currentLocation)\n : match);\n\n let className =\n typeof classNameProp === \"function\"\n ? classNameProp(isActive)\n : classNameProp;\n\n let style =\n typeof styleProp === \"function\" ? styleProp(isActive) : styleProp;\n\n if (isActive) {\n className = joinClassnames(className, activeClassName);\n style = { ...style, ...activeStyle };\n }\n\n const props = {\n \"aria-current\": (isActive && ariaCurrent) || null,\n className,\n style,\n to: toLocation,\n ...rest\n };\n\n // React 15 compat\n if (forwardRefShim !== forwardRef) {\n props.ref = forwardedRef || innerRef;\n } else {\n props.innerRef = innerRef;\n }\n\n return <Link {...props} />;\n }}\n </RouterContext.Consumer>\n );\n }\n);\n\nif (__DEV__) {\n NavLink.displayName = \"NavLink\";\n\n const ariaCurrentType = PropTypes.oneOf([\n \"page\",\n \"step\",\n \"location\",\n \"date\",\n \"time\",\n \"true\",\n \"false\"\n ]);\n\n NavLink.propTypes = {\n ...Link.propTypes,\n \"aria-current\": ariaCurrentType,\n activeClassName: PropTypes.string,\n activeStyle: PropTypes.object,\n className: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),\n exact: PropTypes.bool,\n isActive: PropTypes.func,\n location: PropTypes.object,\n sensitive: PropTypes.bool,\n strict: PropTypes.bool,\n style: PropTypes.oneOfType([PropTypes.object, PropTypes.func])\n };\n}\n\nexport default NavLink;\n"],"names":["BrowserRouter","history","createHistory","props","render","children","React","Component","propTypes","basename","PropTypes","string","node","forceRefresh","bool","getUserConfirmation","func","keyLength","number","prototype","componentDidMount","warning","HashRouter","hashType","oneOf","resolveToLocation","to","currentLocation","normalizeToLocation","createLocation","forwardRefShim","C","forwardRef","isModifiedEvent","event","metaKey","altKey","ctrlKey","shiftKey","LinkAnchor","forwardedRef","innerRef","navigate","onClick","rest","target","ex","preventDefault","defaultPrevented","button","ref","displayName","Link","component","replace","RouterContext","context","invariant","location","href","createHref","isDuplicateNavigation","createPath","method","push","createElement","toType","oneOfType","object","refType","shape","current","any","isRequired","joinClassnames","classnames","filter","i","join","NavLink","ariaCurrent","activeClassName","activeStyle","classNameProp","className","exact","isActiveProp","isActive","locationProp","sensitive","strict","styleProp","style","toLocation","path","pathname","escapedPath","match","matchPath","ariaCurrentType"],"mappings":";;;;;;;;;;;AAMA;;;;IAGMA;;;;;;;;;;;UACJC,UAAUC,oBAAa,CAAC,MAAKC,KAAN;;;;;;SAEvBC,SAAA,kBAAS;wBACA,oBAAC,MAAD;MAAQ,OAAO,EAAE,KAAKH,OAAtB;MAA+B,QAAQ,EAAE,KAAKE,KAAL,CAAWE;MAA3D;;;;EAJwBC,KAAK,CAACC;;AAQlC,2CAAa;EACXP,aAAa,CAACQ,SAAd,GAA0B;IACxBC,QAAQ,EAAEC,SAAS,CAACC,MADI;IAExBN,QAAQ,EAAEK,SAAS,CAACE,IAFI;IAGxBC,YAAY,EAAEH,SAAS,CAACI,IAHA;IAIxBC,mBAAmB,EAAEL,SAAS,CAACM,IAJP;IAKxBC,SAAS,EAAEP,SAAS,CAACQ;GALvB;;EAQAlB,aAAa,CAACmB,SAAd,CAAwBC,iBAAxB,GAA4C,YAAW;4CACrDC,OAAO,CACL,CAAC,KAAKlB,KAAL,CAAWF,OADP,EAEL,wEACE,0EAHG,CAAP;GADF;;;ACpBF;;;;IAGMqB;;;;;;;;;;;UACJrB,UAAUC,iBAAa,CAAC,MAAKC,KAAN;;;;;;SAEvBC,SAAA,kBAAS;wBACA,oBAAC,MAAD;MAAQ,OAAO,EAAE,KAAKH,OAAtB;MAA+B,QAAQ,EAAE,KAAKE,KAAL,CAAWE;MAA3D;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AHsC,EAItC,MAJsC,EAKtC,MALsC,EAMtC,MANsC,EAOtC,OAPsC,CAAhB,CAAxB;EAUAuD,OAAO,CAACvE,SAAR,gBACK4C,IAAI,CAAC5C,SADV;oBAEkB2F,eAFlB;IAGElB,eAAe,EAAEvE,SAAS,CAACC,MAH7B;IAIEuE,WAAW,EAAExE,SAAS,CAAC0D,MAJzB;IAKEgB,SAAS,EAAE1E,SAAS,CAACyD,SAAV,CAAoB,CAACzD,SAAS,CAACC,MAAX,EAAmBD,SAAS,CAACM,IAA7B,CAApB,CALb;IAMEqE,KAAK,EAAE3E,SAAS,CAACI,IANnB;IAOEyE,QAAQ,EAAE7E,SAAS,CAACM,IAPtB;IAQE0C,QAAQ,EAAEhD,SAAS,CAAC0D,MARtB;IASEqB,SAAS,EAAE/E,SAAS,CAACI,IATvB;IAUE4E,MAAM,EAAEhF,SAAS,CAACI,IAVpB;IAWE8E,KAAK,EAAElF,SAAS,CAACyD,SAAV,CAAoB,CAACzD,SAAS,CAAC0D,MAAX,EAAmB1D,SAAS,CAACM,IAA7B,CAApB;;;;;;"}
|
package/generatePath.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
5
|
-
var _generatePath = require("react-router/generatePath");
|
|
6
|
-
|
|
7
|
-
var _generatePath2 = _interopRequireDefault(_generatePath);
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
exports.default = _generatePath2.default; // Written in this round about way for babel-transform-imports
|
|
2
|
+
require("./warnAboutDeprecatedCJSRequire")("generatePath");
|
|
3
|
+
module.exports = require("./index.js").generatePath;
|
package/index.js
CHANGED
|
@@ -1,77 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _BrowserRouter3 = _interopRequireDefault(_BrowserRouter2);
|
|
9
|
-
|
|
10
|
-
var _HashRouter2 = require("./HashRouter");
|
|
11
|
-
|
|
12
|
-
var _HashRouter3 = _interopRequireDefault(_HashRouter2);
|
|
13
|
-
|
|
14
|
-
var _Link2 = require("./Link");
|
|
15
|
-
|
|
16
|
-
var _Link3 = _interopRequireDefault(_Link2);
|
|
17
|
-
|
|
18
|
-
var _MemoryRouter2 = require("./MemoryRouter");
|
|
19
|
-
|
|
20
|
-
var _MemoryRouter3 = _interopRequireDefault(_MemoryRouter2);
|
|
21
|
-
|
|
22
|
-
var _NavLink2 = require("./NavLink");
|
|
23
|
-
|
|
24
|
-
var _NavLink3 = _interopRequireDefault(_NavLink2);
|
|
25
|
-
|
|
26
|
-
var _Prompt2 = require("./Prompt");
|
|
27
|
-
|
|
28
|
-
var _Prompt3 = _interopRequireDefault(_Prompt2);
|
|
29
|
-
|
|
30
|
-
var _Redirect2 = require("./Redirect");
|
|
31
|
-
|
|
32
|
-
var _Redirect3 = _interopRequireDefault(_Redirect2);
|
|
33
|
-
|
|
34
|
-
var _Route2 = require("./Route");
|
|
35
|
-
|
|
36
|
-
var _Route3 = _interopRequireDefault(_Route2);
|
|
37
|
-
|
|
38
|
-
var _Router2 = require("./Router");
|
|
39
|
-
|
|
40
|
-
var _Router3 = _interopRequireDefault(_Router2);
|
|
41
|
-
|
|
42
|
-
var _StaticRouter2 = require("./StaticRouter");
|
|
43
|
-
|
|
44
|
-
var _StaticRouter3 = _interopRequireDefault(_StaticRouter2);
|
|
45
|
-
|
|
46
|
-
var _Switch2 = require("./Switch");
|
|
47
|
-
|
|
48
|
-
var _Switch3 = _interopRequireDefault(_Switch2);
|
|
49
|
-
|
|
50
|
-
var _generatePath2 = require("./generatePath");
|
|
51
|
-
|
|
52
|
-
var _generatePath3 = _interopRequireDefault(_generatePath2);
|
|
53
|
-
|
|
54
|
-
var _matchPath2 = require("./matchPath");
|
|
55
|
-
|
|
56
|
-
var _matchPath3 = _interopRequireDefault(_matchPath2);
|
|
57
|
-
|
|
58
|
-
var _withRouter2 = require("./withRouter");
|
|
59
|
-
|
|
60
|
-
var _withRouter3 = _interopRequireDefault(_withRouter2);
|
|
61
|
-
|
|
62
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
63
|
-
|
|
64
|
-
exports.BrowserRouter = _BrowserRouter3.default;
|
|
65
|
-
exports.HashRouter = _HashRouter3.default;
|
|
66
|
-
exports.Link = _Link3.default;
|
|
67
|
-
exports.MemoryRouter = _MemoryRouter3.default;
|
|
68
|
-
exports.NavLink = _NavLink3.default;
|
|
69
|
-
exports.Prompt = _Prompt3.default;
|
|
70
|
-
exports.Redirect = _Redirect3.default;
|
|
71
|
-
exports.Route = _Route3.default;
|
|
72
|
-
exports.Router = _Router3.default;
|
|
73
|
-
exports.StaticRouter = _StaticRouter3.default;
|
|
74
|
-
exports.Switch = _Switch3.default;
|
|
75
|
-
exports.generatePath = _generatePath3.default;
|
|
76
|
-
exports.matchPath = _matchPath3.default;
|
|
77
|
-
exports.withRouter = _withRouter3.default;
|
|
3
|
+
if (process.env.NODE_ENV === "production") {
|
|
4
|
+
module.exports = require("./cjs/react-router-dom.min.js");
|
|
5
|
+
} else {
|
|
6
|
+
module.exports = require("./cjs/react-router-dom.js");
|
|
7
|
+
}
|
package/matchPath.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
5
|
-
var _matchPath = require("react-router/matchPath");
|
|
6
|
-
|
|
7
|
-
var _matchPath2 = _interopRequireDefault(_matchPath);
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
exports.default = _matchPath2.default; // Written in this round about way for babel-transform-imports
|
|
2
|
+
require("./warnAboutDeprecatedCJSRequire")("matchPath");
|
|
3
|
+
module.exports = require("./index.js").matchPath;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Router } from "react-router";
|
|
3
|
+
import { createBrowserHistory as createHistory } from "history";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
import warning from "tiny-warning";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The public API for a <Router> that uses HTML5 history.
|
|
9
|
+
*/
|
|
10
|
+
class BrowserRouter extends React.Component {
|
|
11
|
+
history = createHistory(this.props);
|
|
12
|
+
|
|
13
|
+
render() {
|
|
14
|
+
return <Router history={this.history} children={this.props.children} />;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (__DEV__) {
|
|
19
|
+
BrowserRouter.propTypes = {
|
|
20
|
+
basename: PropTypes.string,
|
|
21
|
+
children: PropTypes.node,
|
|
22
|
+
forceRefresh: PropTypes.bool,
|
|
23
|
+
getUserConfirmation: PropTypes.func,
|
|
24
|
+
keyLength: PropTypes.number
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
BrowserRouter.prototype.componentDidMount = function() {
|
|
28
|
+
warning(
|
|
29
|
+
!this.props.history,
|
|
30
|
+
"<BrowserRouter> ignores the history prop. To use a custom history, " +
|
|
31
|
+
"use `import { Router }` instead of `import { BrowserRouter as Router }`."
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default BrowserRouter;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Router } from "react-router";
|
|
3
|
+
import { createHashHistory as createHistory } from "history";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
import warning from "tiny-warning";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The public API for a <Router> that uses window.location.hash.
|
|
9
|
+
*/
|
|
10
|
+
class HashRouter extends React.Component {
|
|
11
|
+
history = createHistory(this.props);
|
|
12
|
+
|
|
13
|
+
render() {
|
|
14
|
+
return <Router history={this.history} children={this.props.children} />;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (__DEV__) {
|
|
19
|
+
HashRouter.propTypes = {
|
|
20
|
+
basename: PropTypes.string,
|
|
21
|
+
children: PropTypes.node,
|
|
22
|
+
getUserConfirmation: PropTypes.func,
|
|
23
|
+
hashType: PropTypes.oneOf(["hashbang", "noslash", "slash"])
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
HashRouter.prototype.componentDidMount = function() {
|
|
27
|
+
warning(
|
|
28
|
+
!this.props.history,
|
|
29
|
+
"<HashRouter> ignores the history prop. To use a custom history, " +
|
|
30
|
+
"use `import { Router }` instead of `import { HashRouter as Router }`."
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default HashRouter;
|
package/modules/Link.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { __RouterContext as RouterContext } from "react-router";
|
|
3
|
+
import { createPath } from 'history';
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
import invariant from "tiny-invariant";
|
|
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 isModifiedEvent(event) {
|
|
19
|
+
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const LinkAnchor = forwardRef(
|
|
23
|
+
(
|
|
24
|
+
{
|
|
25
|
+
innerRef, // TODO: deprecate
|
|
26
|
+
navigate,
|
|
27
|
+
onClick,
|
|
28
|
+
...rest
|
|
29
|
+
},
|
|
30
|
+
forwardedRef
|
|
31
|
+
) => {
|
|
32
|
+
const { target } = rest;
|
|
33
|
+
|
|
34
|
+
let props = {
|
|
35
|
+
...rest,
|
|
36
|
+
onClick: event => {
|
|
37
|
+
try {
|
|
38
|
+
if (onClick) onClick(event);
|
|
39
|
+
} catch (ex) {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
throw ex;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
!event.defaultPrevented && // onClick prevented default
|
|
46
|
+
event.button === 0 && // ignore everything but left clicks
|
|
47
|
+
(!target || target === "_self") && // let browser handle "target=_blank" etc.
|
|
48
|
+
!isModifiedEvent(event) // ignore clicks with modifier keys
|
|
49
|
+
) {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
navigate();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// React 15 compat
|
|
57
|
+
if (forwardRefShim !== forwardRef) {
|
|
58
|
+
props.ref = forwardedRef || innerRef;
|
|
59
|
+
} else {
|
|
60
|
+
props.ref = innerRef;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* eslint-disable-next-line jsx-a11y/anchor-has-content */
|
|
64
|
+
return <a {...props} />;
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
if (__DEV__) {
|
|
69
|
+
LinkAnchor.displayName = "LinkAnchor";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The public API for rendering a history-aware <a>.
|
|
74
|
+
*/
|
|
75
|
+
const Link = forwardRef(
|
|
76
|
+
(
|
|
77
|
+
{
|
|
78
|
+
component = LinkAnchor,
|
|
79
|
+
replace,
|
|
80
|
+
to,
|
|
81
|
+
innerRef, // TODO: deprecate
|
|
82
|
+
...rest
|
|
83
|
+
},
|
|
84
|
+
forwardedRef
|
|
85
|
+
) => {
|
|
86
|
+
return (
|
|
87
|
+
<RouterContext.Consumer>
|
|
88
|
+
{context => {
|
|
89
|
+
invariant(context, "You should not use <Link> outside a <Router>");
|
|
90
|
+
|
|
91
|
+
const { history } = context;
|
|
92
|
+
|
|
93
|
+
const location = normalizeToLocation(
|
|
94
|
+
resolveToLocation(to, context.location),
|
|
95
|
+
context.location
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const href = location ? history.createHref(location) : "";
|
|
99
|
+
const props = {
|
|
100
|
+
...rest,
|
|
101
|
+
href,
|
|
102
|
+
navigate() {
|
|
103
|
+
const location = resolveToLocation(to, context.location);
|
|
104
|
+
const isDuplicateNavigation = createPath(context.location) === createPath(normalizeToLocation(location));
|
|
105
|
+
const method = (replace || isDuplicateNavigation) ? history.replace : history.push;
|
|
106
|
+
|
|
107
|
+
method(location);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// React 15 compat
|
|
112
|
+
if (forwardRefShim !== forwardRef) {
|
|
113
|
+
props.ref = forwardedRef || innerRef;
|
|
114
|
+
} else {
|
|
115
|
+
props.innerRef = innerRef;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return React.createElement(component, props);
|
|
119
|
+
}}
|
|
120
|
+
</RouterContext.Consumer>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
if (__DEV__) {
|
|
126
|
+
const toType = PropTypes.oneOfType([
|
|
127
|
+
PropTypes.string,
|
|
128
|
+
PropTypes.object,
|
|
129
|
+
PropTypes.func
|
|
130
|
+
]);
|
|
131
|
+
const refType = PropTypes.oneOfType([
|
|
132
|
+
PropTypes.string,
|
|
133
|
+
PropTypes.func,
|
|
134
|
+
PropTypes.shape({ current: PropTypes.any })
|
|
135
|
+
]);
|
|
136
|
+
|
|
137
|
+
Link.displayName = "Link";
|
|
138
|
+
|
|
139
|
+
Link.propTypes = {
|
|
140
|
+
innerRef: refType,
|
|
141
|
+
onClick: PropTypes.func,
|
|
142
|
+
replace: PropTypes.bool,
|
|
143
|
+
target: PropTypes.string,
|
|
144
|
+
to: toType.isRequired
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default Link;
|
|
@@ -0,0 +1,134 @@
|
|
|
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", // TODO: deprecate
|
|
30
|
+
activeStyle, // TODO: deprecate
|
|
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
|
+
let className =
|
|
72
|
+
typeof classNameProp === "function"
|
|
73
|
+
? classNameProp(isActive)
|
|
74
|
+
: classNameProp;
|
|
75
|
+
|
|
76
|
+
let style =
|
|
77
|
+
typeof styleProp === "function" ? styleProp(isActive) : styleProp;
|
|
78
|
+
|
|
79
|
+
if (isActive) {
|
|
80
|
+
className = joinClassnames(className, activeClassName);
|
|
81
|
+
style = { ...style, ...activeStyle };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const props = {
|
|
85
|
+
"aria-current": (isActive && ariaCurrent) || null,
|
|
86
|
+
className,
|
|
87
|
+
style,
|
|
88
|
+
to: toLocation,
|
|
89
|
+
...rest
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// React 15 compat
|
|
93
|
+
if (forwardRefShim !== forwardRef) {
|
|
94
|
+
props.ref = forwardedRef || innerRef;
|
|
95
|
+
} else {
|
|
96
|
+
props.innerRef = innerRef;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return <Link {...props} />;
|
|
100
|
+
}}
|
|
101
|
+
</RouterContext.Consumer>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
if (__DEV__) {
|
|
107
|
+
NavLink.displayName = "NavLink";
|
|
108
|
+
|
|
109
|
+
const ariaCurrentType = PropTypes.oneOf([
|
|
110
|
+
"page",
|
|
111
|
+
"step",
|
|
112
|
+
"location",
|
|
113
|
+
"date",
|
|
114
|
+
"time",
|
|
115
|
+
"true",
|
|
116
|
+
"false"
|
|
117
|
+
]);
|
|
118
|
+
|
|
119
|
+
NavLink.propTypes = {
|
|
120
|
+
...Link.propTypes,
|
|
121
|
+
"aria-current": ariaCurrentType,
|
|
122
|
+
activeClassName: PropTypes.string,
|
|
123
|
+
activeStyle: PropTypes.object,
|
|
124
|
+
className: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
125
|
+
exact: PropTypes.bool,
|
|
126
|
+
isActive: PropTypes.func,
|
|
127
|
+
location: PropTypes.object,
|
|
128
|
+
sensitive: PropTypes.bool,
|
|
129
|
+
strict: PropTypes.bool,
|
|
130
|
+
style: PropTypes.oneOfType([PropTypes.object, PropTypes.func])
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default NavLink;
|
package/modules/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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";
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-router-dom",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.3.4",
|
|
4
4
|
"description": "DOM bindings for React Router",
|
|
5
|
-
"
|
|
5
|
+
"homepage": "https://reactrouter.com/",
|
|
6
|
+
"repository": {
|
|
7
|
+
"url": "https://github.com/remix-run/react-router.git",
|
|
8
|
+
"type": "git",
|
|
9
|
+
"directory": "packages/react-router-dom"
|
|
10
|
+
},
|
|
6
11
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
"Michael Jackson",
|
|
9
|
-
"Ryan Florence"
|
|
10
|
-
],
|
|
12
|
+
"author": "Remix Software <hello@remix.run>",
|
|
11
13
|
"files": [
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"README.md",
|
|
12
16
|
"BrowserRouter.js",
|
|
13
17
|
"HashRouter.js",
|
|
14
18
|
"Link.js",
|
|
@@ -20,73 +24,42 @@
|
|
|
20
24
|
"Router.js",
|
|
21
25
|
"StaticRouter.js",
|
|
22
26
|
"Switch.js",
|
|
27
|
+
"cjs",
|
|
23
28
|
"es",
|
|
29
|
+
"esm",
|
|
24
30
|
"index.js",
|
|
25
31
|
"generatePath.js",
|
|
26
32
|
"matchPath.js",
|
|
33
|
+
"modules/*.js",
|
|
34
|
+
"modules/utils/*.js",
|
|
27
35
|
"withRouter.js",
|
|
36
|
+
"warnAboutDeprecatedCJSRequire.js",
|
|
28
37
|
"umd"
|
|
29
38
|
],
|
|
30
39
|
"main": "index.js",
|
|
31
|
-
"module": "
|
|
40
|
+
"module": "esm/react-router-dom.js",
|
|
32
41
|
"sideEffects": false,
|
|
33
42
|
"scripts": {
|
|
34
|
-
"build": "
|
|
35
|
-
"
|
|
36
|
-
"prepublishOnly": "node ./tools/build.js",
|
|
37
|
-
"clean": "git clean -fdX .",
|
|
38
|
-
"lint": "eslint modules",
|
|
39
|
-
"test": "jest"
|
|
43
|
+
"build": "rollup -c",
|
|
44
|
+
"lint": "eslint modules"
|
|
40
45
|
},
|
|
41
46
|
"peerDependencies": {
|
|
42
47
|
"react": ">=15"
|
|
43
48
|
},
|
|
44
49
|
"dependencies": {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
50
|
+
"@babel/runtime": "^7.12.13",
|
|
51
|
+
"history": "^4.9.0",
|
|
47
52
|
"loose-envify": "^1.3.1",
|
|
48
|
-
"prop-types": "^15.6.
|
|
49
|
-
"react-router": "
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"babel-cli": "^6.26.0",
|
|
54
|
-
"babel-eslint": "^8.2.3",
|
|
55
|
-
"babel-jest": "^23.0.1",
|
|
56
|
-
"babel-plugin-dev-expression": "^0.2.1",
|
|
57
|
-
"babel-plugin-external-helpers": "^6.22.0",
|
|
58
|
-
"babel-plugin-transform-imports": "^1.5.0",
|
|
59
|
-
"babel-plugin-transform-react-remove-prop-types": "^0.4.13",
|
|
60
|
-
"babel-preset-es2015": "^6.14.0",
|
|
61
|
-
"babel-preset-react": "^6.5.0",
|
|
62
|
-
"babel-preset-stage-1": "^6.5.0",
|
|
63
|
-
"eslint": "^4.19.1",
|
|
64
|
-
"eslint-plugin-import": "^2.12.0",
|
|
65
|
-
"eslint-plugin-react": "^7.9.1",
|
|
66
|
-
"gzip-size": "^4.1.0",
|
|
67
|
-
"jest": "^23.1.0",
|
|
68
|
-
"pretty-bytes": "^5.0.0",
|
|
69
|
-
"raf": "^3.4.0",
|
|
70
|
-
"react": "^16.4.0",
|
|
71
|
-
"react-addons-test-utils": "^15.6.2",
|
|
72
|
-
"react-dom": "^16.4.0",
|
|
73
|
-
"rollup": "^0.60.0",
|
|
74
|
-
"rollup-plugin-babel": "^3.0.4",
|
|
75
|
-
"rollup-plugin-commonjs": "^9.1.3",
|
|
76
|
-
"rollup-plugin-node-resolve": "^3.3.0",
|
|
77
|
-
"rollup-plugin-replace": "^2.0.0",
|
|
78
|
-
"rollup-plugin-uglify": "^3.0.0"
|
|
53
|
+
"prop-types": "^15.6.2",
|
|
54
|
+
"react-router": "5.3.4",
|
|
55
|
+
"tiny-invariant": "^1.0.2",
|
|
56
|
+
"tiny-warning": "^1.0.0"
|
|
79
57
|
},
|
|
80
58
|
"browserify": {
|
|
81
59
|
"transform": [
|
|
82
60
|
"loose-envify"
|
|
83
61
|
]
|
|
84
62
|
},
|
|
85
|
-
"jest": {
|
|
86
|
-
"setupFiles": [
|
|
87
|
-
"raf/polyfill"
|
|
88
|
-
]
|
|
89
|
-
},
|
|
90
63
|
"keywords": [
|
|
91
64
|
"react",
|
|
92
65
|
"router",
|