@saber2pr/react-router 0.0.6 → 0.0.7
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.
@@ -7,5 +7,6 @@ export interface NavLink extends Link {
|
|
7
7
|
exact?: boolean;
|
8
8
|
isActive?: (to: string, contextPath: string) => boolean;
|
9
9
|
style?: CSSProperties;
|
10
|
+
useBrowserLink?: boolean;
|
10
11
|
}
|
11
|
-
export declare function NavLink({ activeClassName, activeStyle, className: classNameProp, exact, isActive: isActiveProp, style: styleProp, to, ...rest }: NavLink): JSX.Element;
|
12
|
+
export declare function NavLink({ activeClassName, activeStyle, className: classNameProp, exact, isActive: isActiveProp, style: styleProp, to, useBrowserLink, ...rest }: NavLink): JSX.Element;
|
@@ -36,7 +36,7 @@ function joinClassnames() {
|
|
36
36
|
return classnames.filter(function (i) { return i; }).join(" ");
|
37
37
|
}
|
38
38
|
function NavLink(_a) {
|
39
|
-
var _b = _a.activeClassName, activeClassName = _b === void 0 ? "active" : _b, activeStyle = _a.activeStyle, classNameProp = _a.className, exact = _a.exact, isActiveProp = _a.isActive, styleProp = _a.style, to = _a.to, rest = __rest(_a, ["activeClassName", "activeStyle", "className", "exact", "isActive", "style", "to"]);
|
39
|
+
var _b = _a.activeClassName, activeClassName = _b === void 0 ? "active" : _b, activeStyle = _a.activeStyle, classNameProp = _a.className, exact = _a.exact, isActiveProp = _a.isActive, styleProp = _a.style, to = _a.to, useBrowserLink = _a.useBrowserLink, rest = __rest(_a, ["activeClassName", "activeStyle", "className", "exact", "isActive", "style", "to", "useBrowserLink"]);
|
40
40
|
return (react_1.default.createElement(context_1.RouterContext.Consumer, null, function (context) {
|
41
41
|
var currentLocation = context.location;
|
42
42
|
var pathToMatch = currentLocation.pathname;
|
@@ -47,6 +47,9 @@ function NavLink(_a) {
|
|
47
47
|
? joinClassnames(classNameProp, activeClassName)
|
48
48
|
: classNameProp;
|
49
49
|
var style = isActive ? __assign(__assign({}, styleProp), activeStyle) : styleProp;
|
50
|
+
if (useBrowserLink) {
|
51
|
+
return react_1.default.createElement("a", __assign({ className: className, style: style, href: to }, rest));
|
52
|
+
}
|
50
53
|
return react_1.default.createElement(link_1.Link, __assign({ className: className, style: style, to: to }, rest));
|
51
54
|
}));
|
52
55
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@saber2pr/react-router",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.7",
|
4
4
|
"description": "react-router.",
|
5
5
|
"scripts": {
|
6
6
|
"start": "cross-env NODE_ENV=development webpack -w",
|
@@ -43,4 +43,4 @@
|
|
43
43
|
"webpack-cli": "^3.3.3",
|
44
44
|
"webpack-dev-server": "^3.7.1"
|
45
45
|
}
|
46
|
-
}
|
46
|
+
}
|