@storybook/addon-links 6.5.9 → 7.0.0-alpha.10

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.
Files changed (40) hide show
  1. package/dist/cjs/constants.js +5 -5
  2. package/dist/cjs/index.js +9 -14
  3. package/dist/cjs/manager.js +9 -30
  4. package/dist/cjs/preview.js +1 -1
  5. package/dist/cjs/react/components/RoutedLink.js +23 -23
  6. package/dist/cjs/react/components/link.js +66 -152
  7. package/dist/cjs/utils.js +66 -103
  8. package/dist/esm/constants.js +5 -5
  9. package/dist/esm/index.js +5 -9
  10. package/dist/esm/manager.js +7 -7
  11. package/dist/esm/preview.js +1 -1
  12. package/dist/esm/react/components/RoutedLink.js +21 -21
  13. package/dist/esm/react/components/link.js +64 -136
  14. package/dist/esm/utils.js +72 -88
  15. package/dist/{ts3.9 → types}/constants.d.ts +0 -0
  16. package/dist/{ts3.9 → types}/index.d.ts +0 -0
  17. package/dist/{ts3.9 → types}/manager.d.ts +0 -0
  18. package/dist/{ts3.9 → types}/preview.d.ts +0 -0
  19. package/dist/{ts3.9 → types}/react/components/RoutedLink.d.ts +0 -0
  20. package/dist/{ts3.9 → types}/react/components/link.d.ts +2 -2
  21. package/dist/{ts3.9 → types}/react/index.d.ts +0 -0
  22. package/dist/{ts3.9 → types}/utils.d.ts +1 -1
  23. package/package.json +7 -21
  24. package/react.d.ts +2 -2
  25. package/dist/modern/constants.js +0 -7
  26. package/dist/modern/index.js +0 -19
  27. package/dist/modern/manager.js +0 -12
  28. package/dist/modern/preview.js +0 -2
  29. package/dist/modern/react/components/RoutedLink.js +0 -39
  30. package/dist/modern/react/components/link.js +0 -82
  31. package/dist/modern/react/index.js +0 -2
  32. package/dist/modern/utils.js +0 -99
  33. package/dist/ts3.4/constants.d.ts +0 -8
  34. package/dist/ts3.4/index.d.ts +0 -2
  35. package/dist/ts3.4/manager.d.ts +0 -1
  36. package/dist/ts3.4/preview.d.ts +0 -1
  37. package/dist/ts3.4/react/components/RoutedLink.d.ts +0 -3
  38. package/dist/ts3.4/react/components/link.d.ts +0 -19
  39. package/dist/ts3.4/react/index.d.ts +0 -2
  40. package/dist/ts3.4/utils.d.ts +0 -13
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.PARAM_KEY = exports.ADDON_ID = void 0;
7
- var ADDON_ID = 'storybook/links';
7
+ const ADDON_ID = 'storybook/links';
8
8
  exports.ADDON_ID = ADDON_ID;
9
- var PARAM_KEY = "links";
9
+ const PARAM_KEY = `links`;
10
10
  exports.PARAM_KEY = PARAM_KEY;
11
11
  var _default = {
12
- NAVIGATE: "".concat(ADDON_ID, "/navigate"),
13
- REQUEST: "".concat(ADDON_ID, "/request"),
14
- RECEIVE: "".concat(ADDON_ID, "/receive")
12
+ NAVIGATE: `${ADDON_ID}/navigate`,
13
+ REQUEST: `${ADDON_ID}/request`,
14
+ RECEIVE: `${ADDON_ID}/receive`
15
15
  };
16
16
  exports.default = _default;
package/dist/cjs/index.js CHANGED
@@ -1,34 +1,30 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.array.slice.js");
4
-
5
- require("core-js/modules/es.object.freeze.js");
6
-
7
3
  Object.defineProperty(exports, "__esModule", {
8
4
  value: true
9
5
  });
10
6
  exports.LinkTo = LinkTo;
11
7
  Object.defineProperty(exports, "hrefTo", {
12
8
  enumerable: true,
13
- get: function get() {
9
+ get: function () {
14
10
  return _utils.hrefTo;
15
11
  }
16
12
  });
17
13
  Object.defineProperty(exports, "linkTo", {
18
14
  enumerable: true,
19
- get: function get() {
15
+ get: function () {
20
16
  return _utils.linkTo;
21
17
  }
22
18
  });
23
19
  Object.defineProperty(exports, "navigate", {
24
20
  enumerable: true,
25
- get: function get() {
21
+ get: function () {
26
22
  return _utils.navigate;
27
23
  }
28
24
  });
29
25
  Object.defineProperty(exports, "withLinks", {
30
26
  enumerable: true,
31
- get: function get() {
27
+ get: function () {
32
28
  return _utils.withLinks;
33
29
  }
34
30
  });
@@ -37,18 +33,17 @@ var _tsDedent = _interopRequireDefault(require("ts-dedent"));
37
33
 
38
34
  var _utils = require("./utils");
39
35
 
40
- var _templateObject;
41
-
42
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
37
 
44
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
45
-
46
- var hasWarned = false;
38
+ let hasWarned = false;
47
39
 
48
40
  function LinkTo() {
49
41
  if (!hasWarned) {
50
42
  // eslint-disable-next-line no-console
51
- console.error((0, _tsDedent.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n LinkTo has moved to addon-links/react:\n import LinkTo from '@storybook/addon-links/react';\n "]))));
43
+ console.error((0, _tsDedent.default)`
44
+ LinkTo has moved to addon-links/react:
45
+ import LinkTo from '@storybook/addon-links/react';
46
+ `);
52
47
  hasWarned = true;
53
48
  }
54
49
 
@@ -1,42 +1,21 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
- require("core-js/modules/es.array.iterator.js");
6
-
7
- require("core-js/modules/es.object.to-string.js");
8
-
9
- require("core-js/modules/es.string.iterator.js");
10
-
11
- require("core-js/modules/es.weak-map.js");
12
-
13
- require("core-js/modules/web.dom-collections.iterator.js");
14
-
15
- require("core-js/modules/es.object.get-own-property-descriptor.js");
16
-
17
- require("core-js/modules/es.symbol.js");
18
-
19
- require("core-js/modules/es.symbol.description.js");
20
-
21
- require("core-js/modules/es.symbol.iterator.js");
22
-
23
- require("core-js/modules/es.function.name.js");
24
-
25
3
  var _addons = require("@storybook/addons");
26
4
 
27
5
  var _constants = _interopRequireWildcard(require("./constants"));
28
6
 
29
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
7
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
30
8
 
31
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
9
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
32
10
 
33
- _addons.addons.register(_constants.ADDON_ID, function (api) {
34
- var channel = _addons.addons.getChannel();
11
+ _addons.addons.register(_constants.ADDON_ID, api => {
12
+ const channel = _addons.addons.getChannel();
35
13
 
36
- channel.on(_constants.default.REQUEST, function (_ref) {
37
- var kind = _ref.kind,
38
- name = _ref.name;
39
- var id = api.storyId(kind, name);
14
+ channel.on(_constants.default.REQUEST, ({
15
+ kind,
16
+ name
17
+ }) => {
18
+ const id = api.storyId(kind, name);
40
19
  api.emit(_constants.default.RECEIVE, id);
41
20
  });
42
21
  });
@@ -7,5 +7,5 @@ exports.decorators = void 0;
7
7
 
8
8
  var _index = require("./index");
9
9
 
10
- var decorators = [_index.withLinks];
10
+ const decorators = [_index.withLinks];
11
11
  exports.decorators = decorators;
@@ -15,36 +15,36 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
15
15
  // The proper DRY solution is to create a new package that doesn't depend
16
16
  // on a specific react version. However, that's a heavy-handed solution for
17
17
  // one trivial file.
18
- var LEFT_BUTTON = 0; // Cmd/Ctrl/Shift/Alt + Click should trigger default browser behaviour. Same applies to non-left clicks
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) {
18
+ const LEFT_BUTTON = 0; // Cmd/Ctrl/Shift/Alt + Click should trigger default browser behaviour. Same applies to non-left clicks
19
+
20
+ const isPlainLeftClick = e => e.button === LEFT_BUTTON && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey;
21
+
22
+ const RoutedLink = ({
23
+ href = '#',
24
+ children,
25
+ onClick,
26
+ className,
27
+ style
28
+ }) => {
29
+ const handleClick = e => {
33
30
  if (isPlainLeftClick(e)) {
34
31
  e.preventDefault();
35
- onClick(e);
32
+
33
+ if (onClick) {
34
+ onClick(e);
35
+ }
36
36
  }
37
37
  };
38
38
 
39
- var props = onClick ? {
40
- href: href,
41
- className: className,
42
- style: style,
39
+ const props = onClick ? {
40
+ href,
41
+ className,
42
+ style,
43
43
  onClick: handleClick
44
44
  } : {
45
- href: href,
46
- className: className,
47
- style: style
45
+ href,
46
+ className,
47
+ style
48
48
  };
49
49
  return /*#__PURE__*/_react.default.createElement("a", props, children);
50
50
  };
@@ -1,192 +1,106 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
- require("core-js/modules/es.object.to-string.js");
6
-
7
- require("core-js/modules/es.reflect.construct.js");
8
-
9
- require("core-js/modules/es.promise.js");
10
-
11
- require("core-js/modules/es.object.keys.js");
12
-
13
- require("core-js/modules/es.symbol.js");
14
-
15
- require("core-js/modules/es.object.assign.js");
16
-
17
- require("core-js/modules/es.array.iterator.js");
18
-
19
- require("core-js/modules/es.string.iterator.js");
20
-
21
- require("core-js/modules/es.weak-map.js");
22
-
23
- require("core-js/modules/web.dom-collections.iterator.js");
24
-
25
- require("core-js/modules/es.object.get-own-property-descriptor.js");
26
-
27
- require("core-js/modules/es.symbol.description.js");
28
-
29
- require("core-js/modules/es.symbol.iterator.js");
30
-
31
3
  Object.defineProperty(exports, "__esModule", {
32
4
  value: true
33
5
  });
34
6
  exports.default = void 0;
35
7
 
36
- require("regenerator-runtime/runtime.js");
37
-
38
- require("core-js/modules/es.array.concat.js");
39
-
40
- require("core-js/modules/es.object.get-prototype-of.js");
41
-
42
8
  var _react = _interopRequireWildcard(require("react"));
43
9
 
44
10
  var _utils = require("../../utils");
45
11
 
46
- var _excluded = ["kind", "story", "children"];
12
+ const _excluded = ["kind", "story", "children"];
47
13
 
48
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
49
15
 
50
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
51
17
 
52
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
53
-
54
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
18
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
55
19
 
56
20
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
57
21
 
58
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
59
-
60
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
61
-
62
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
63
-
64
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
65
-
66
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
67
-
68
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
69
-
70
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
71
-
72
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
73
-
74
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
75
-
76
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
77
-
78
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
79
-
80
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
81
-
82
22
  // FIXME: copied from Typography.Link. Code is duplicated to
83
23
  // avoid emotion dependency which breaks React 15.x back-compat
84
24
  // Cmd/Ctrl/Shift/Alt + Click should trigger default browser behaviour. Same applies to non-left clicks
85
- var LEFT_BUTTON = 0;
25
+ const LEFT_BUTTON = 0;
86
26
 
87
- var isPlainLeftClick = function isPlainLeftClick(e) {
88
- return e.button === LEFT_BUTTON && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey;
89
- };
90
-
91
- var cancelled = function cancelled(e) {
92
- var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (_e) {};
27
+ const isPlainLeftClick = e => e.button === LEFT_BUTTON && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey;
93
28
 
29
+ const cancelled = (e, cb = _e => {}) => {
94
30
  if (isPlainLeftClick(e)) {
95
31
  e.preventDefault();
96
32
  cb(e);
97
33
  }
98
34
  };
99
35
 
100
- var LinkTo = /*#__PURE__*/function (_PureComponent) {
101
- _inherits(LinkTo, _PureComponent);
102
-
103
- var _super = _createSuper(LinkTo);
104
-
105
- function LinkTo() {
106
- var _this;
107
-
108
- _classCallCheck(this, LinkTo);
109
-
110
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
111
- args[_key] = arguments[_key];
112
- }
113
-
114
- _this = _super.call.apply(_super, [this].concat(args));
115
- _this.state = {
36
+ class LinkTo extends _react.PureComponent {
37
+ constructor(...args) {
38
+ super(...args);
39
+ this.state = {
116
40
  href: '/'
117
41
  };
118
- _this.updateHref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
119
- var _this$props, kind, story, href;
120
-
121
- return regeneratorRuntime.wrap(function _callee$(_context) {
122
- while (1) {
123
- switch (_context.prev = _context.next) {
124
- case 0:
125
- _this$props = _this.props, kind = _this$props.kind, story = _this$props.story;
126
- _context.next = 3;
127
- return (0, _utils.hrefTo)(kind, story);
128
-
129
- case 3:
130
- href = _context.sent;
131
-
132
- _this.setState({
133
- href: href
134
- });
135
-
136
- case 5:
137
- case "end":
138
- return _context.stop();
139
- }
140
- }
141
- }, _callee);
142
- }));
143
-
144
- _this.handleClick = function () {
145
- (0, _utils.navigate)(_this.props);
42
+
43
+ this.updateHref = async () => {
44
+ const {
45
+ kind,
46
+ story
47
+ } = this.props;
48
+
49
+ if (kind && story) {
50
+ const href = await (0, _utils.hrefTo)(kind, story);
51
+ this.setState({
52
+ href
53
+ });
54
+ }
55
+ };
56
+
57
+ this.handleClick = () => {
58
+ const {
59
+ kind,
60
+ story
61
+ } = this.props;
62
+
63
+ if (kind && story) {
64
+ (0, _utils.navigate)({
65
+ kind,
66
+ story
67
+ });
68
+ }
146
69
  };
70
+ }
147
71
 
148
- return _this;
72
+ componentDidMount() {
73
+ this.updateHref();
149
74
  }
150
75
 
151
- _createClass(LinkTo, [{
152
- key: "componentDidMount",
153
- value: function componentDidMount() {
76
+ componentDidUpdate(prevProps) {
77
+ const {
78
+ kind,
79
+ story
80
+ } = this.props;
81
+
82
+ if (prevProps.kind !== kind || prevProps.story !== story) {
154
83
  this.updateHref();
155
84
  }
156
- }, {
157
- key: "componentDidUpdate",
158
- value: function componentDidUpdate(prevProps) {
159
- var _this$props2 = this.props,
160
- kind = _this$props2.kind,
161
- story = _this$props2.story;
162
-
163
- if (prevProps.kind !== kind || prevProps.story !== story) {
164
- this.updateHref();
165
- }
166
- }
167
- }, {
168
- key: "render",
169
- value: function render() {
170
- var _this2 = this;
171
-
172
- var _this$props3 = this.props,
173
- kind = _this$props3.kind,
174
- story = _this$props3.story,
175
- children = _this$props3.children,
176
- rest = _objectWithoutProperties(_this$props3, _excluded);
177
-
178
- var href = this.state.href;
179
- return /*#__PURE__*/_react.default.createElement("a", _extends({
180
- href: href,
181
- onClick: function onClick(e) {
182
- return cancelled(e, _this2.handleClick);
183
- }
184
- }, rest), children);
185
- }
186
- }]);
85
+ }
86
+
87
+ render() {
88
+ const _this$props = this.props,
89
+ {
90
+ children
91
+ } = _this$props,
92
+ rest = _objectWithoutPropertiesLoose(_this$props, _excluded);
93
+
94
+ const {
95
+ href
96
+ } = this.state;
97
+ return /*#__PURE__*/_react.default.createElement("a", _extends({
98
+ href: href,
99
+ onClick: e => cancelled(e, this.handleClick)
100
+ }, rest), children);
101
+ }
187
102
 
188
- return LinkTo;
189
- }(_react.PureComponent);
103
+ }
190
104
 
191
105
  exports.default = LinkTo;
192
106
  LinkTo.defaultProps = {