1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | var _react = _interopRequireDefault(require("react"));
|
9 |
|
10 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | var LEFT_BUTTON = 0;
|
19 |
|
20 | var isPlainLeftClick = function isPlainLeftClick(e) {
|
21 | return e.button === LEFT_BUTTON && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey;
|
22 | };
|
23 |
|
24 | var RoutedLink = function RoutedLink(_ref) {
|
25 | var _ref$href = _ref.href,
|
26 | href = _ref$href === void 0 ? '#' : _ref$href,
|
27 | children = _ref.children,
|
28 | onClick = _ref.onClick,
|
29 | className = _ref.className,
|
30 | style = _ref.style;
|
31 |
|
32 | var handleClick = function handleClick(e) {
|
33 | if (isPlainLeftClick(e)) {
|
34 | e.preventDefault();
|
35 | onClick(e);
|
36 | }
|
37 | };
|
38 |
|
39 | var props = onClick ? {
|
40 | href: href,
|
41 | className: className,
|
42 | style: style,
|
43 | onClick: handleClick
|
44 | } : {
|
45 | href: href,
|
46 | className: className,
|
47 | style: style
|
48 | };
|
49 | return _react.default.createElement("a", props, children);
|
50 | };
|
51 |
|
52 | var _default = RoutedLink;
|
53 | exports.default = _default; |
\ | No newline at end of file |