@saber2pr/react-router 0.0.5 → 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.
- package/ReadMe.md +0 -0
- package/lib/app.d.ts +0 -0
- package/lib/app.js +0 -0
- package/lib/components/index.d.ts +0 -0
- package/lib/components/index.js +0 -0
- package/lib/components/link.d.ts +2 -1
- package/lib/components/link.js +2 -2
- package/lib/components/nav-link.d.ts +2 -1
- package/lib/components/nav-link.js +4 -1
- package/lib/components/route.d.ts +0 -0
- package/lib/components/route.js +0 -0
- package/lib/components/router.d.ts +0 -0
- package/lib/components/router.js +0 -0
- package/lib/components/switch.d.ts +0 -0
- package/lib/components/switch.js +0 -0
- package/lib/context/index.d.ts +0 -0
- package/lib/context/index.js +0 -0
- package/lib/history/index.d.ts +0 -0
- package/lib/history/index.js +0 -0
- package/lib/hooks/index.d.ts +0 -0
- package/lib/hooks/index.js +0 -0
- package/lib/hooks/useHistory.d.ts +0 -0
- package/lib/hooks/useHistory.js +0 -0
- package/lib/hooks/usePush.d.ts +0 -0
- package/lib/hooks/usePush.js +0 -0
- package/lib/index.d.ts +0 -0
- package/lib/index.js +0 -0
- package/lib/utils/getHash.d.ts +0 -0
- package/lib/utils/getHash.js +0 -0
- package/lib/utils/index.d.ts +0 -0
- package/lib/utils/index.js +0 -0
- package/lib/utils/matchPath.d.ts +0 -0
- package/lib/utils/matchPath.js +0 -0
- package/package.json +4 -1
package/ReadMe.md
CHANGED
File without changes
|
package/lib/app.d.ts
CHANGED
File without changes
|
package/lib/app.js
CHANGED
File without changes
|
File without changes
|
package/lib/components/index.js
CHANGED
File without changes
|
package/lib/components/link.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
2
|
export interface Link extends React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> {
|
3
3
|
to: string;
|
4
|
+
forwardRef?: React.MutableRefObject<HTMLAnchorElement>;
|
4
5
|
}
|
5
|
-
export declare const Link: ({ to, onClick, target, ...rest }: Link) => JSX.Element;
|
6
|
+
export declare const Link: ({ to, onClick, target, forwardRef, ...rest }: Link) => JSX.Element;
|
package/lib/components/link.js
CHANGED
@@ -34,10 +34,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
var react_1 = __importDefault(require("react"));
|
35
35
|
var context_1 = require("../context");
|
36
36
|
exports.Link = function (_a) {
|
37
|
-
var to = _a.to, onClick = _a.onClick, target = _a.target, rest = __rest(_a, ["to", "onClick", "target"]);
|
37
|
+
var to = _a.to, onClick = _a.onClick, target = _a.target, forwardRef = _a.forwardRef, rest = __rest(_a, ["to", "onClick", "target", "forwardRef"]);
|
38
38
|
return (react_1.default.createElement(context_1.RouterContext.Consumer, null, function (context) {
|
39
39
|
var history = context.history;
|
40
|
-
return (react_1.default.createElement("a", __assign({}, rest, { href: "#" + to, onClick: function (event) {
|
40
|
+
return (react_1.default.createElement("a", __assign({}, rest, { ref: forwardRef, href: "#" + to, onClick: function (event) {
|
41
41
|
try {
|
42
42
|
if (onClick)
|
43
43
|
onClick(event);
|
@@ -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
|
}
|
File without changes
|
package/lib/components/route.js
CHANGED
File without changes
|
File without changes
|
package/lib/components/router.js
CHANGED
File without changes
|
File without changes
|
package/lib/components/switch.js
CHANGED
File without changes
|
package/lib/context/index.d.ts
CHANGED
File without changes
|
package/lib/context/index.js
CHANGED
File without changes
|
package/lib/history/index.d.ts
CHANGED
File without changes
|
package/lib/history/index.js
CHANGED
File without changes
|
package/lib/hooks/index.d.ts
CHANGED
File without changes
|
package/lib/hooks/index.js
CHANGED
File without changes
|
File without changes
|
package/lib/hooks/useHistory.js
CHANGED
File without changes
|
package/lib/hooks/usePush.d.ts
CHANGED
File without changes
|
package/lib/hooks/usePush.js
CHANGED
File without changes
|
package/lib/index.d.ts
CHANGED
File without changes
|
package/lib/index.js
CHANGED
File without changes
|
package/lib/utils/getHash.d.ts
CHANGED
File without changes
|
package/lib/utils/getHash.js
CHANGED
File without changes
|
package/lib/utils/index.d.ts
CHANGED
File without changes
|
package/lib/utils/index.js
CHANGED
File without changes
|
package/lib/utils/matchPath.d.ts
CHANGED
File without changes
|
package/lib/utils/matchPath.js
CHANGED
File without changes
|
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",
|
@@ -23,6 +23,9 @@
|
|
23
23
|
"ts",
|
24
24
|
"router"
|
25
25
|
],
|
26
|
+
"publishConfig": {
|
27
|
+
"registry": "https://registry.npmjs.org/"
|
28
|
+
},
|
26
29
|
"dependencies": {
|
27
30
|
"@types/react": "^16.8.19",
|
28
31
|
"@types/react-dom": "^16.8.4",
|