react-router-dom 5.0.0 → 5.0.1
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/cjs/react-router-dom.js +26 -24
- package/cjs/react-router-dom.min.js +1 -1
- package/esm/react-router-dom.js +27 -23
- package/package.json +15 -16
- package/umd/react-router-dom.js +189 -253
- package/umd/react-router-dom.min.js +1 -1
package/cjs/react-router-dom.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
4
|
|
|
7
5
|
var React = _interopDefault(require('react'));
|
|
@@ -163,7 +161,12 @@ function (_React$Component) {
|
|
|
163
161
|
var _proto = Link.prototype;
|
|
164
162
|
|
|
165
163
|
_proto.handleClick = function handleClick(event, history$$1) {
|
|
166
|
-
|
|
164
|
+
try {
|
|
165
|
+
if (this.props.onClick) this.props.onClick(event);
|
|
166
|
+
} catch (ex) {
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
throw ex;
|
|
169
|
+
}
|
|
167
170
|
|
|
168
171
|
if (!event.defaultPrevented && // onClick prevented default
|
|
169
172
|
event.button === 0 && ( // ignore everything but left clicks
|
|
@@ -240,7 +243,7 @@ function NavLink(_ref) {
|
|
|
240
243
|
classNameProp = _ref.className,
|
|
241
244
|
exact = _ref.exact,
|
|
242
245
|
isActiveProp = _ref.isActive,
|
|
243
|
-
|
|
246
|
+
locationProp = _ref.location,
|
|
244
247
|
strict = _ref.strict,
|
|
245
248
|
styleProp = _ref.style,
|
|
246
249
|
to = _ref.to,
|
|
@@ -249,24 +252,23 @@ function NavLink(_ref) {
|
|
|
249
252
|
var path = typeof to === "object" ? to.pathname : to; // Regex taken from: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L202
|
|
250
253
|
|
|
251
254
|
var escapedPath = path && path.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
|
252
|
-
return React.createElement(reactRouter.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
255
|
+
return React.createElement(reactRouter.__RouterContext.Consumer, null, function (context) {
|
|
256
|
+
!context ? invariant(false, "You should not use <NavLink> outside a <Router>") : void 0;
|
|
257
|
+
var pathToMatch = locationProp ? locationProp.pathname : context.location.pathname;
|
|
258
|
+
var match = escapedPath ? reactRouter.matchPath(pathToMatch, {
|
|
259
|
+
path: escapedPath,
|
|
260
|
+
exact: exact,
|
|
261
|
+
strict: strict
|
|
262
|
+
}) : null;
|
|
263
|
+
var isActive = !!(isActiveProp ? isActiveProp(match, context.location) : match);
|
|
264
|
+
var className = isActive ? joinClassnames(classNameProp, activeClassName) : classNameProp;
|
|
265
|
+
var style = isActive ? _extends({}, styleProp, activeStyle) : styleProp;
|
|
266
|
+
return React.createElement(Link, _extends({
|
|
267
|
+
"aria-current": isActive && ariaCurrent || null,
|
|
268
|
+
className: className,
|
|
269
|
+
style: style,
|
|
270
|
+
to: to
|
|
271
|
+
}, rest));
|
|
270
272
|
});
|
|
271
273
|
}
|
|
272
274
|
|
|
@@ -277,10 +279,10 @@ function NavLink(_ref) {
|
|
|
277
279
|
activeClassName: PropTypes.string,
|
|
278
280
|
activeStyle: PropTypes.object,
|
|
279
281
|
className: PropTypes.string,
|
|
280
|
-
exact:
|
|
282
|
+
exact: PropTypes.bool,
|
|
281
283
|
isActive: PropTypes.func,
|
|
282
284
|
location: PropTypes.object,
|
|
283
|
-
strict:
|
|
285
|
+
strict: PropTypes.bool,
|
|
284
286
|
style: PropTypes.object
|
|
285
287
|
});
|
|
286
288
|
}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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(e,t){try{this.props.onClick&&this.props.onClick(e)}catch(t){throw e.preventDefault(),t}e.defaultPrevented||0!==e.button||this.props.target&&"_self"!==this.props.target||isModifiedEvent(e)||(e.preventDefault(),(this.props.replace?t.replace:t.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,l=t.exact,p=t.isActive,h=t.location,f=t.strict,y=t.style,v=t.to,R=_objectWithoutPropertiesLoose(t,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","strict","style","to"]),o="object"==typeof v?v.pathname:v,d=o&&o.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1");return React.createElement(reactRouter.__RouterContext.Consumer,null,function(t){t||invariant(!1);var e=h?h.pathname:t.location.pathname,r=d?reactRouter.matchPath(e,{path:d,exact:l,strict:f}):null,o=!!(p?p(r,t.location):r),n=o?joinClassnames(u,s):u,i=o?_extends({},y,c):y;return React.createElement(Link,_extends({"aria-current":o&&a||null,className:n,style:i,to:v},R))})}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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { Router, __RouterContext,
|
|
3
|
+
import { Router, __RouterContext, matchPath } from 'react-router';
|
|
4
4
|
export * from 'react-router';
|
|
5
5
|
import { createBrowserHistory, createHashHistory, createLocation } from 'history';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -122,7 +122,12 @@ function (_React$Component) {
|
|
|
122
122
|
var _proto = Link.prototype;
|
|
123
123
|
|
|
124
124
|
_proto.handleClick = function handleClick(event, history) {
|
|
125
|
-
|
|
125
|
+
try {
|
|
126
|
+
if (this.props.onClick) this.props.onClick(event);
|
|
127
|
+
} catch (ex) {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
throw ex;
|
|
130
|
+
}
|
|
126
131
|
|
|
127
132
|
if (!event.defaultPrevented && // onClick prevented default
|
|
128
133
|
event.button === 0 && ( // ignore everything but left clicks
|
|
@@ -199,7 +204,7 @@ function NavLink(_ref) {
|
|
|
199
204
|
classNameProp = _ref.className,
|
|
200
205
|
exact = _ref.exact,
|
|
201
206
|
isActiveProp = _ref.isActive,
|
|
202
|
-
|
|
207
|
+
locationProp = _ref.location,
|
|
203
208
|
strict = _ref.strict,
|
|
204
209
|
styleProp = _ref.style,
|
|
205
210
|
to = _ref.to,
|
|
@@ -208,24 +213,23 @@ function NavLink(_ref) {
|
|
|
208
213
|
var path = typeof to === "object" ? to.pathname : to; // Regex taken from: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L202
|
|
209
214
|
|
|
210
215
|
var escapedPath = path && path.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
|
211
|
-
return React.createElement(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
216
|
+
return React.createElement(__RouterContext.Consumer, null, function (context) {
|
|
217
|
+
!context ? process.env.NODE_ENV !== "production" ? invariant(false, "You should not use <NavLink> outside a <Router>") : invariant(false) : void 0;
|
|
218
|
+
var pathToMatch = locationProp ? locationProp.pathname : context.location.pathname;
|
|
219
|
+
var match = escapedPath ? matchPath(pathToMatch, {
|
|
220
|
+
path: escapedPath,
|
|
221
|
+
exact: exact,
|
|
222
|
+
strict: strict
|
|
223
|
+
}) : null;
|
|
224
|
+
var isActive = !!(isActiveProp ? isActiveProp(match, context.location) : match);
|
|
225
|
+
var className = isActive ? joinClassnames(classNameProp, activeClassName) : classNameProp;
|
|
226
|
+
var style = isActive ? _extends({}, styleProp, activeStyle) : styleProp;
|
|
227
|
+
return React.createElement(Link, _extends({
|
|
228
|
+
"aria-current": isActive && ariaCurrent || null,
|
|
229
|
+
className: className,
|
|
230
|
+
style: style,
|
|
231
|
+
to: to
|
|
232
|
+
}, rest));
|
|
229
233
|
});
|
|
230
234
|
}
|
|
231
235
|
|
|
@@ -236,10 +240,10 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
236
240
|
activeClassName: PropTypes.string,
|
|
237
241
|
activeStyle: PropTypes.object,
|
|
238
242
|
className: PropTypes.string,
|
|
239
|
-
exact:
|
|
243
|
+
exact: PropTypes.bool,
|
|
240
244
|
isActive: PropTypes.func,
|
|
241
245
|
location: PropTypes.object,
|
|
242
|
-
strict:
|
|
246
|
+
strict: PropTypes.bool,
|
|
243
247
|
style: PropTypes.object
|
|
244
248
|
});
|
|
245
249
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-router-dom",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "DOM bindings for React Router",
|
|
5
5
|
"repository": "ReactTraining/react-router",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"history": "^4.9.0",
|
|
48
48
|
"loose-envify": "^1.3.1",
|
|
49
49
|
"prop-types": "^15.6.2",
|
|
50
|
-
"react-router": "5.0.
|
|
50
|
+
"react-router": "5.0.1",
|
|
51
51
|
"tiny-invariant": "^1.0.2",
|
|
52
52
|
"tiny-warning": "^1.0.0"
|
|
53
53
|
},
|
|
@@ -57,25 +57,24 @@
|
|
|
57
57
|
"@babel/plugin-transform-runtime": "^7.1.0",
|
|
58
58
|
"@babel/preset-env": "^7.1.0",
|
|
59
59
|
"@babel/preset-react": "^7.0.0",
|
|
60
|
-
"babel-core": "^7.0.0-bridge.0",
|
|
61
60
|
"babel-eslint": "^10.0.1",
|
|
62
|
-
"babel-jest": "^
|
|
61
|
+
"babel-jest": "^24.8.0",
|
|
63
62
|
"babel-plugin-dev-expression": "^0.2.1",
|
|
64
|
-
"eslint": "^5.
|
|
65
|
-
"eslint-plugin-import": "^2.
|
|
63
|
+
"eslint": "^5.16.0",
|
|
64
|
+
"eslint-plugin-import": "^2.17.0",
|
|
66
65
|
"eslint-plugin-react": "^7.9.1",
|
|
67
|
-
"jest": "^
|
|
68
|
-
"jest-circus": "^
|
|
69
|
-
"raf": "^3.4.
|
|
66
|
+
"jest": "^24.8.0",
|
|
67
|
+
"jest-circus": "^24.8.0",
|
|
68
|
+
"raf": "^3.4.1",
|
|
70
69
|
"react": "^16.5.2",
|
|
71
70
|
"react-dom": "^16.5.2",
|
|
72
71
|
"rollup": "^0.66.6",
|
|
73
|
-
"rollup-plugin-babel": "^4.
|
|
74
|
-
"rollup-plugin-commonjs": "^9.
|
|
75
|
-
"rollup-plugin-node-resolve": "^3.
|
|
76
|
-
"rollup-plugin-replace": "^2.
|
|
77
|
-
"rollup-plugin-size-snapshot": "
|
|
78
|
-
"rollup-plugin-uglify": "^6.0.
|
|
72
|
+
"rollup-plugin-babel": "^4.3.2",
|
|
73
|
+
"rollup-plugin-commonjs": "^9.3.4",
|
|
74
|
+
"rollup-plugin-node-resolve": "^3.4.0",
|
|
75
|
+
"rollup-plugin-replace": "^2.2.0",
|
|
76
|
+
"rollup-plugin-size-snapshot": "0.7.0",
|
|
77
|
+
"rollup-plugin-uglify": "^6.0.2"
|
|
79
78
|
},
|
|
80
79
|
"browserify": {
|
|
81
80
|
"transform": [
|
|
@@ -90,5 +89,5 @@
|
|
|
90
89
|
"history",
|
|
91
90
|
"link"
|
|
92
91
|
],
|
|
93
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "0c9a10d9807b879912f2dff2fbebffe0aa7048ed"
|
|
94
93
|
}
|