react-router-dom 4.4.0-beta.5 → 5.0.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.
- package/README.md +4 -4
- package/cjs/react-router-dom.js +15 -21
- package/cjs/react-router-dom.min.js +1 -1
- package/esm/react-router-dom.js +15 -21
- package/package.json +9 -10
- package/umd/react-router-dom.js +402 -545
- package/umd/react-router-dom.min.js +1 -1
package/README.md
CHANGED
|
@@ -12,12 +12,12 @@ Then with a module bundler like [webpack](https://webpack.github.io/), use as yo
|
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
14
|
// using ES6 modules
|
|
15
|
-
import { BrowserRouter, Route, Link } from
|
|
15
|
+
import { BrowserRouter, Route, Link } from "react-router-dom";
|
|
16
16
|
|
|
17
17
|
// using CommonJS modules
|
|
18
|
-
const BrowserRouter = require(
|
|
19
|
-
const Route = require(
|
|
20
|
-
const Link = require(
|
|
18
|
+
const BrowserRouter = require("react-router-dom").BrowserRouter;
|
|
19
|
+
const Route = require("react-router-dom").Route;
|
|
20
|
+
const Link = require("react-router-dom").Link;
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
The UMD build is also available on [unpkg](https://unpkg.com):
|
package/cjs/react-router-dom.js
CHANGED
|
@@ -8,8 +8,8 @@ var React = _interopDefault(require('react'));
|
|
|
8
8
|
var reactRouter = require('react-router');
|
|
9
9
|
var history = require('history');
|
|
10
10
|
var PropTypes = _interopDefault(require('prop-types'));
|
|
11
|
-
var warning = _interopDefault(require('warning'));
|
|
12
|
-
var invariant = _interopDefault(require('invariant'));
|
|
11
|
+
var warning = _interopDefault(require('tiny-warning'));
|
|
12
|
+
var invariant = _interopDefault(require('tiny-invariant'));
|
|
13
13
|
|
|
14
14
|
function _extends() {
|
|
15
15
|
_extends = Object.assign || function (target) {
|
|
@@ -162,7 +162,7 @@ function (_React$Component) {
|
|
|
162
162
|
|
|
163
163
|
var _proto = Link.prototype;
|
|
164
164
|
|
|
165
|
-
_proto.handleClick = function handleClick(event,
|
|
165
|
+
_proto.handleClick = function handleClick(event, history$$1) {
|
|
166
166
|
if (this.props.onClick) this.props.onClick(event);
|
|
167
167
|
|
|
168
168
|
if (!event.defaultPrevented && // onClick prevented default
|
|
@@ -171,7 +171,7 @@ function (_React$Component) {
|
|
|
171
171
|
!isModifiedEvent(event) // ignore clicks with modifier keys
|
|
172
172
|
) {
|
|
173
173
|
event.preventDefault();
|
|
174
|
-
var method = this.props.replace ?
|
|
174
|
+
var method = this.props.replace ? history$$1.replace : history$$1.push;
|
|
175
175
|
method(this.props.to);
|
|
176
176
|
}
|
|
177
177
|
};
|
|
@@ -192,7 +192,7 @@ function (_React$Component) {
|
|
|
192
192
|
var href = location ? context.history.createHref(location) : "";
|
|
193
193
|
return React.createElement("a", _extends({}, rest, {
|
|
194
194
|
onClick: function onClick(event) {
|
|
195
|
-
return _this.handleClick(event, context);
|
|
195
|
+
return _this.handleClick(event, context.history);
|
|
196
196
|
},
|
|
197
197
|
href: href,
|
|
198
198
|
ref: innerRef
|
|
@@ -203,13 +203,11 @@ function (_React$Component) {
|
|
|
203
203
|
return Link;
|
|
204
204
|
}(React.Component);
|
|
205
205
|
|
|
206
|
-
Link.defaultProps = {
|
|
207
|
-
replace: false
|
|
208
|
-
};
|
|
209
|
-
|
|
210
206
|
{
|
|
211
207
|
var toType = PropTypes.oneOfType([PropTypes.string, PropTypes.object]);
|
|
212
|
-
var innerRefType = PropTypes.oneOfType([PropTypes.string, PropTypes.func
|
|
208
|
+
var innerRefType = PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.shape({
|
|
209
|
+
current: PropTypes.any
|
|
210
|
+
})]);
|
|
213
211
|
Link.propTypes = {
|
|
214
212
|
innerRef: innerRefType,
|
|
215
213
|
onClick: PropTypes.func,
|
|
@@ -234,8 +232,10 @@ function joinClassnames() {
|
|
|
234
232
|
|
|
235
233
|
|
|
236
234
|
function NavLink(_ref) {
|
|
237
|
-
var ariaCurrent = _ref["aria-current"],
|
|
238
|
-
|
|
235
|
+
var _ref$ariaCurrent = _ref["aria-current"],
|
|
236
|
+
ariaCurrent = _ref$ariaCurrent === void 0 ? "page" : _ref$ariaCurrent,
|
|
237
|
+
_ref$activeClassName = _ref.activeClassName,
|
|
238
|
+
activeClassName = _ref$activeClassName === void 0 ? "active" : _ref$activeClassName,
|
|
239
239
|
activeStyle = _ref.activeStyle,
|
|
240
240
|
classNameProp = _ref.className,
|
|
241
241
|
exact = _ref.exact,
|
|
@@ -270,14 +270,9 @@ function NavLink(_ref) {
|
|
|
270
270
|
});
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
NavLink.defaultProps = {
|
|
274
|
-
"aria-current": "page",
|
|
275
|
-
activeClassName: "active"
|
|
276
|
-
};
|
|
277
|
-
|
|
278
273
|
{
|
|
279
274
|
var ariaCurrentType = PropTypes.oneOf(["page", "step", "location", "date", "time", "true"]);
|
|
280
|
-
NavLink.propTypes = {
|
|
275
|
+
NavLink.propTypes = _extends({}, Link.propTypes, {
|
|
281
276
|
"aria-current": ariaCurrentType,
|
|
282
277
|
activeClassName: PropTypes.string,
|
|
283
278
|
activeStyle: PropTypes.object,
|
|
@@ -286,9 +281,8 @@ NavLink.defaultProps = {
|
|
|
286
281
|
isActive: PropTypes.func,
|
|
287
282
|
location: PropTypes.object,
|
|
288
283
|
strict: reactRouter.Route.propTypes.strict,
|
|
289
|
-
style: PropTypes.object
|
|
290
|
-
|
|
291
|
-
};
|
|
284
|
+
style: PropTypes.object
|
|
285
|
+
});
|
|
292
286
|
}
|
|
293
287
|
|
|
294
288
|
Object.keys(reactRouter).forEach(function (key) { exports[key] = reactRouter[key]; });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _interopDefault(
|
|
1
|
+
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var React=_interopDefault(require("react")),reactRouter=require("react-router"),history=require("history");require("prop-types"),require("tiny-warning");var invariant=_interopDefault(require("tiny-invariant"));function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t}).apply(this,arguments)}function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}function _objectWithoutPropertiesLoose(t,e){if(null==t)return{};var r,o,n={},i=Object.keys(t);for(o=0;o<i.length;o++)r=i[o],0<=e.indexOf(r)||(n[r]=t[r]);return n}var BrowserRouter=function(n){function t(){for(var t,e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];return(t=n.call.apply(n,[this].concat(r))||this).history=history.createBrowserHistory(t.props),t}return _inheritsLoose(t,n),t.prototype.render=function(){return React.createElement(reactRouter.Router,{history:this.history,children:this.props.children})},t}(React.Component),HashRouter=function(n){function t(){for(var t,e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];return(t=n.call.apply(n,[this].concat(r))||this).history=history.createHashHistory(t.props),t}return _inheritsLoose(t,n),t.prototype.render=function(){return React.createElement(reactRouter.Router,{history:this.history,children:this.props.children})},t}(React.Component);function isModifiedEvent(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}var Link=function(t){function e(){return t.apply(this,arguments)||this}_inheritsLoose(e,t);var r=e.prototype;return r.handleClick=function(t,e){(this.props.onClick&&this.props.onClick(t),t.defaultPrevented||0!==t.button||this.props.target&&"_self"!==this.props.target||isModifiedEvent(t))||(t.preventDefault(),(this.props.replace?e.replace:e.push)(this.props.to))},r.render=function(){var o=this,t=this.props,n=t.innerRef,i=(t.replace,t.to),a=_objectWithoutPropertiesLoose(t,["innerRef","replace","to"]);return React.createElement(reactRouter.__RouterContext.Consumer,null,function(e){e||invariant(!1);var t="string"==typeof i?history.createLocation(i,null,null,e.location):i,r=t?e.history.createHref(t):"";return React.createElement("a",_extends({},a,{onClick:function(t){return o.handleClick(t,e.history)},href:r,ref:n}))})},e}(React.Component);function joinClassnames(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.filter(function(t){return t}).join(" ")}function NavLink(t){var e=t["aria-current"],a=void 0===e?"page":e,r=t.activeClassName,s=void 0===r?"active":r,c=t.activeStyle,u=t.className,o=t.exact,l=t.isActive,n=t.location,i=t.strict,p=t.style,h=t.to,f=_objectWithoutPropertiesLoose(t,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","strict","style","to"]),y="object"==typeof h?h.pathname:h,v=y&&y.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1");return React.createElement(reactRouter.Route,{path:v,exact:o,strict:i,location:n,children:function(t){var e=t.location,r=t.match,o=!!(l?l(r,e):r),n=o?joinClassnames(u,s):u,i=o?_extends({},p,c):p;return React.createElement(Link,_extends({"aria-current":o&&a||null,className:n,style:i,to:h},f))}})}Object.keys(reactRouter).forEach(function(t){exports[t]=reactRouter[t]}),exports.BrowserRouter=BrowserRouter,exports.HashRouter=HashRouter,exports.Link=Link,exports.NavLink=NavLink;
|
package/esm/react-router-dom.js
CHANGED
|
@@ -4,10 +4,10 @@ import { Router, __RouterContext, Route } from 'react-router';
|
|
|
4
4
|
export * from 'react-router';
|
|
5
5
|
import { createBrowserHistory, createHashHistory, createLocation } from 'history';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
|
-
import warning from 'warning';
|
|
7
|
+
import warning from 'tiny-warning';
|
|
8
8
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
9
9
|
import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose';
|
|
10
|
-
import invariant from 'invariant';
|
|
10
|
+
import invariant from 'tiny-invariant';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* The public API for a <Router> that uses HTML5 history.
|
|
@@ -121,7 +121,7 @@ function (_React$Component) {
|
|
|
121
121
|
|
|
122
122
|
var _proto = Link.prototype;
|
|
123
123
|
|
|
124
|
-
_proto.handleClick = function handleClick(event,
|
|
124
|
+
_proto.handleClick = function handleClick(event, history) {
|
|
125
125
|
if (this.props.onClick) this.props.onClick(event);
|
|
126
126
|
|
|
127
127
|
if (!event.defaultPrevented && // onClick prevented default
|
|
@@ -130,7 +130,7 @@ function (_React$Component) {
|
|
|
130
130
|
!isModifiedEvent(event) // ignore clicks with modifier keys
|
|
131
131
|
) {
|
|
132
132
|
event.preventDefault();
|
|
133
|
-
var method = this.props.replace ?
|
|
133
|
+
var method = this.props.replace ? history.replace : history.push;
|
|
134
134
|
method(this.props.to);
|
|
135
135
|
}
|
|
136
136
|
};
|
|
@@ -151,7 +151,7 @@ function (_React$Component) {
|
|
|
151
151
|
var href = location ? context.history.createHref(location) : "";
|
|
152
152
|
return React.createElement("a", _extends({}, rest, {
|
|
153
153
|
onClick: function onClick(event) {
|
|
154
|
-
return _this.handleClick(event, context);
|
|
154
|
+
return _this.handleClick(event, context.history);
|
|
155
155
|
},
|
|
156
156
|
href: href,
|
|
157
157
|
ref: innerRef
|
|
@@ -162,13 +162,11 @@ function (_React$Component) {
|
|
|
162
162
|
return Link;
|
|
163
163
|
}(React.Component);
|
|
164
164
|
|
|
165
|
-
Link.defaultProps = {
|
|
166
|
-
replace: false
|
|
167
|
-
};
|
|
168
|
-
|
|
169
165
|
if (process.env.NODE_ENV !== "production") {
|
|
170
166
|
var toType = PropTypes.oneOfType([PropTypes.string, PropTypes.object]);
|
|
171
|
-
var innerRefType = PropTypes.oneOfType([PropTypes.string, PropTypes.func
|
|
167
|
+
var innerRefType = PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.shape({
|
|
168
|
+
current: PropTypes.any
|
|
169
|
+
})]);
|
|
172
170
|
Link.propTypes = {
|
|
173
171
|
innerRef: innerRefType,
|
|
174
172
|
onClick: PropTypes.func,
|
|
@@ -193,8 +191,10 @@ function joinClassnames() {
|
|
|
193
191
|
|
|
194
192
|
|
|
195
193
|
function NavLink(_ref) {
|
|
196
|
-
var ariaCurrent = _ref["aria-current"],
|
|
197
|
-
|
|
194
|
+
var _ref$ariaCurrent = _ref["aria-current"],
|
|
195
|
+
ariaCurrent = _ref$ariaCurrent === void 0 ? "page" : _ref$ariaCurrent,
|
|
196
|
+
_ref$activeClassName = _ref.activeClassName,
|
|
197
|
+
activeClassName = _ref$activeClassName === void 0 ? "active" : _ref$activeClassName,
|
|
198
198
|
activeStyle = _ref.activeStyle,
|
|
199
199
|
classNameProp = _ref.className,
|
|
200
200
|
exact = _ref.exact,
|
|
@@ -229,14 +229,9 @@ function NavLink(_ref) {
|
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
NavLink.defaultProps = {
|
|
233
|
-
"aria-current": "page",
|
|
234
|
-
activeClassName: "active"
|
|
235
|
-
};
|
|
236
|
-
|
|
237
232
|
if (process.env.NODE_ENV !== "production") {
|
|
238
233
|
var ariaCurrentType = PropTypes.oneOf(["page", "step", "location", "date", "time", "true"]);
|
|
239
|
-
NavLink.propTypes = {
|
|
234
|
+
NavLink.propTypes = _extends({}, Link.propTypes, {
|
|
240
235
|
"aria-current": ariaCurrentType,
|
|
241
236
|
activeClassName: PropTypes.string,
|
|
242
237
|
activeStyle: PropTypes.object,
|
|
@@ -245,9 +240,8 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
245
240
|
isActive: PropTypes.func,
|
|
246
241
|
location: PropTypes.object,
|
|
247
242
|
strict: Route.propTypes.strict,
|
|
248
|
-
style: PropTypes.object
|
|
249
|
-
|
|
250
|
-
};
|
|
243
|
+
style: PropTypes.object
|
|
244
|
+
});
|
|
251
245
|
}
|
|
252
246
|
|
|
253
247
|
export { BrowserRouter, HashRouter, Link, NavLink };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-router-dom",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "DOM bindings for React Router",
|
|
5
5
|
"repository": "ReactTraining/react-router",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"module": "esm/react-router-dom.js",
|
|
35
35
|
"sideEffects": false,
|
|
36
36
|
"scripts": {
|
|
37
|
-
"build": "
|
|
38
|
-
"prepublishOnly": "del cjs esm umd && rollup -c",
|
|
37
|
+
"build": "rollup -c",
|
|
39
38
|
"lint": "eslint modules",
|
|
39
|
+
"prepublishOnly": "npm run build",
|
|
40
40
|
"test": "jest"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.1.2",
|
|
47
|
-
"history": "^4.
|
|
48
|
-
"invariant": "^2.2.4",
|
|
47
|
+
"history": "^4.9.0",
|
|
49
48
|
"loose-envify": "^1.3.1",
|
|
50
|
-
"prop-types": "^15.6.
|
|
51
|
-
"react-router": "
|
|
52
|
-
"
|
|
49
|
+
"prop-types": "^15.6.2",
|
|
50
|
+
"react-router": "5.0.0",
|
|
51
|
+
"tiny-invariant": "^1.0.2",
|
|
52
|
+
"tiny-warning": "^1.0.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@babel/core": "^7.1.2",
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
"babel-eslint": "^10.0.1",
|
|
62
62
|
"babel-jest": "^23.6.0",
|
|
63
63
|
"babel-plugin-dev-expression": "^0.2.1",
|
|
64
|
-
"del-cli": "^1.1.0",
|
|
65
64
|
"eslint": "^5.7.0",
|
|
66
65
|
"eslint-plugin-import": "^2.12.0",
|
|
67
66
|
"eslint-plugin-react": "^7.9.1",
|
|
@@ -91,5 +90,5 @@
|
|
|
91
90
|
"history",
|
|
92
91
|
"link"
|
|
93
92
|
],
|
|
94
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "ea8eba843bf899daf8a51c2617d05c179b38369d"
|
|
95
94
|
}
|