@saber2pr/react-router 0.0.6 → 0.0.8

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/lib/app.js CHANGED
@@ -25,11 +25,12 @@ var Blog = function () {
25
25
  } }),
26
26
  react_1.default.createElement(_1.Route, { path: "/blog/3", component: function () { return react_1.default.createElement("div", null, "blog3"); } })));
27
27
  };
28
+ var HashHistory = _1.createHashHistory();
28
29
  exports.App = function () {
29
30
  return (react_1.default.createElement(react_1.default.Fragment, null,
30
31
  react_1.default.createElement("header", { className: "title" }, "app"),
31
32
  react_1.default.createElement("main", null,
32
- react_1.default.createElement(_1.Router, { history: _1.HashHistory },
33
+ react_1.default.createElement(_1.Router, { history: HashHistory },
33
34
  react_1.default.createElement("ul", null,
34
35
  react_1.default.createElement("li", null,
35
36
  react_1.default.createElement(_1.NavLink, { className: "a", to: "/" }, "home"),
@@ -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
  }
@@ -9,4 +9,3 @@ export declare type History = {
9
9
  };
10
10
  export declare const createLocation: () => Location;
11
11
  export declare const createHashHistory: () => History;
12
- export declare const HashHistory: History;
@@ -45,4 +45,3 @@ exports.createHashHistory = function () {
45
45
  push: push
46
46
  };
47
47
  };
48
- exports.HashHistory = exports.createHashHistory();
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "./components";
2
2
  export * from "./context";
3
- export { HashHistory } from "./history";
3
+ export { createHashHistory } from "./history";
4
4
  export * from "./hooks";
5
5
  export * from "./utils";
package/lib/index.js CHANGED
@@ -6,6 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  __export(require("./components"));
7
7
  __export(require("./context"));
8
8
  var history_1 = require("./history");
9
- exports.HashHistory = history_1.HashHistory;
9
+ exports.createHashHistory = history_1.createHashHistory;
10
10
  __export(require("./hooks"));
11
11
  __export(require("./utils"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saber2pr/react-router",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
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
+ }