@storybook/addon-links 7.0.0-alpha.1 → 7.0.0-alpha.2
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/dist/cjs/constants.js +5 -5
- package/dist/cjs/index.js +9 -14
- package/dist/cjs/manager.js +9 -30
- package/dist/cjs/preview.js +1 -1
- package/dist/cjs/react/components/RoutedLink.js +19 -22
- package/dist/cjs/react/components/link.js +52 -165
- package/dist/cjs/utils.js +53 -114
- package/package.json +6 -6
package/dist/cjs/constants.js
CHANGED
|
@@ -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
|
-
|
|
7
|
+
const ADDON_ID = 'storybook/links';
|
|
8
8
|
exports.ADDON_ID = ADDON_ID;
|
|
9
|
-
|
|
9
|
+
const PARAM_KEY = `links`;
|
|
10
10
|
exports.PARAM_KEY = PARAM_KEY;
|
|
11
11
|
var _default = {
|
|
12
|
-
NAVIGATE:
|
|
13
|
-
REQUEST:
|
|
14
|
-
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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)
|
|
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
|
|
package/dist/cjs/manager.js
CHANGED
|
@@ -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
|
|
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 ||
|
|
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,
|
|
34
|
-
|
|
11
|
+
_addons.addons.register(_constants.ADDON_ID, api => {
|
|
12
|
+
const channel = _addons.addons.getChannel();
|
|
35
13
|
|
|
36
|
-
channel.on(_constants.default.REQUEST,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
});
|
package/dist/cjs/preview.js
CHANGED
|
@@ -15,36 +15,33 @@ 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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
32
|
onClick(e);
|
|
36
33
|
}
|
|
37
34
|
};
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
href
|
|
41
|
-
className
|
|
42
|
-
style
|
|
36
|
+
const props = onClick ? {
|
|
37
|
+
href,
|
|
38
|
+
className,
|
|
39
|
+
style,
|
|
43
40
|
onClick: handleClick
|
|
44
41
|
} : {
|
|
45
|
-
href
|
|
46
|
-
className
|
|
47
|
-
style
|
|
42
|
+
href,
|
|
43
|
+
className,
|
|
44
|
+
style
|
|
48
45
|
};
|
|
49
46
|
return /*#__PURE__*/_react.default.createElement("a", props, children);
|
|
50
47
|
};
|
|
@@ -1,206 +1,93 @@
|
|
|
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.symbol.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.symbol.description.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.symbol.iterator.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/web.dom-collections.iterator.js");
|
|
22
|
-
|
|
23
|
-
require("core-js/modules/es.symbol.async-iterator.js");
|
|
24
|
-
|
|
25
|
-
require("core-js/modules/es.symbol.to-string-tag.js");
|
|
26
|
-
|
|
27
|
-
require("core-js/modules/es.json.to-string-tag.js");
|
|
28
|
-
|
|
29
|
-
require("core-js/modules/es.math.to-string-tag.js");
|
|
30
|
-
|
|
31
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
32
|
-
|
|
33
|
-
require("core-js/modules/es.function.name.js");
|
|
34
|
-
|
|
35
|
-
require("core-js/modules/es.array.slice.js");
|
|
36
|
-
|
|
37
|
-
require("core-js/modules/es.object.keys.js");
|
|
38
|
-
|
|
39
|
-
require("core-js/modules/es.object.assign.js");
|
|
40
|
-
|
|
41
|
-
require("core-js/modules/es.weak-map.js");
|
|
42
|
-
|
|
43
|
-
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
44
|
-
|
|
45
3
|
Object.defineProperty(exports, "__esModule", {
|
|
46
4
|
value: true
|
|
47
5
|
});
|
|
48
6
|
exports.default = void 0;
|
|
49
7
|
|
|
50
|
-
require("core-js/modules/es.array.concat.js");
|
|
51
|
-
|
|
52
|
-
require("core-js/modules/es.object.get-prototype-of.js");
|
|
53
|
-
|
|
54
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
55
9
|
|
|
56
10
|
var _utils = require("../../utils");
|
|
57
11
|
|
|
58
|
-
|
|
12
|
+
const _excluded = ["kind", "story", "children"];
|
|
59
13
|
|
|
60
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function
|
|
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); }
|
|
61
15
|
|
|
62
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
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; }
|
|
63
17
|
|
|
64
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); }
|
|
65
19
|
|
|
66
|
-
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; }
|
|
67
|
-
|
|
68
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; }
|
|
69
21
|
|
|
70
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
71
|
-
|
|
72
|
-
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); } }
|
|
73
|
-
|
|
74
|
-
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); }); }; }
|
|
75
|
-
|
|
76
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
77
|
-
|
|
78
|
-
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); } }
|
|
79
|
-
|
|
80
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
81
|
-
|
|
82
|
-
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); }
|
|
83
|
-
|
|
84
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
85
|
-
|
|
86
|
-
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); }; }
|
|
87
|
-
|
|
88
|
-
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); }
|
|
89
|
-
|
|
90
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
91
|
-
|
|
92
|
-
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; } }
|
|
93
|
-
|
|
94
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
95
|
-
|
|
96
22
|
// FIXME: copied from Typography.Link. Code is duplicated to
|
|
97
23
|
// avoid emotion dependency which breaks React 15.x back-compat
|
|
98
24
|
// Cmd/Ctrl/Shift/Alt + Click should trigger default browser behaviour. Same applies to non-left clicks
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var isPlainLeftClick = function isPlainLeftClick(e) {
|
|
102
|
-
return e.button === LEFT_BUTTON && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey;
|
|
103
|
-
};
|
|
25
|
+
const LEFT_BUTTON = 0;
|
|
104
26
|
|
|
105
|
-
|
|
106
|
-
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;
|
|
107
28
|
|
|
29
|
+
const cancelled = (e, cb = _e => {}) => {
|
|
108
30
|
if (isPlainLeftClick(e)) {
|
|
109
31
|
e.preventDefault();
|
|
110
32
|
cb(e);
|
|
111
33
|
}
|
|
112
34
|
};
|
|
113
35
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
function LinkTo() {
|
|
120
|
-
var _this;
|
|
121
|
-
|
|
122
|
-
_classCallCheck(this, LinkTo);
|
|
123
|
-
|
|
124
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
125
|
-
args[_key] = arguments[_key];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
129
|
-
_this.state = {
|
|
36
|
+
class LinkTo extends _react.PureComponent {
|
|
37
|
+
constructor(...args) {
|
|
38
|
+
super(...args);
|
|
39
|
+
this.state = {
|
|
130
40
|
href: '/'
|
|
131
41
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
case 3:
|
|
144
|
-
href = _context.sent;
|
|
145
|
-
|
|
146
|
-
_this.setState({
|
|
147
|
-
href: href
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
case 5:
|
|
151
|
-
case "end":
|
|
152
|
-
return _context.stop();
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}, _callee);
|
|
156
|
-
}));
|
|
157
|
-
|
|
158
|
-
_this.handleClick = function () {
|
|
159
|
-
(0, _utils.navigate)(_this.props);
|
|
42
|
+
|
|
43
|
+
this.updateHref = async () => {
|
|
44
|
+
const {
|
|
45
|
+
kind,
|
|
46
|
+
story
|
|
47
|
+
} = this.props;
|
|
48
|
+
const href = await (0, _utils.hrefTo)(kind, story);
|
|
49
|
+
this.setState({
|
|
50
|
+
href
|
|
51
|
+
});
|
|
160
52
|
};
|
|
161
53
|
|
|
162
|
-
|
|
54
|
+
this.handleClick = () => {
|
|
55
|
+
(0, _utils.navigate)(this.props);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
componentDidMount() {
|
|
60
|
+
this.updateHref();
|
|
163
61
|
}
|
|
164
62
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
63
|
+
componentDidUpdate(prevProps) {
|
|
64
|
+
const {
|
|
65
|
+
kind,
|
|
66
|
+
story
|
|
67
|
+
} = this.props;
|
|
68
|
+
|
|
69
|
+
if (prevProps.kind !== kind || prevProps.story !== story) {
|
|
168
70
|
this.updateHref();
|
|
169
71
|
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
kind = _this$props3.kind,
|
|
188
|
-
story = _this$props3.story,
|
|
189
|
-
children = _this$props3.children,
|
|
190
|
-
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
191
|
-
|
|
192
|
-
var href = this.state.href;
|
|
193
|
-
return /*#__PURE__*/_react.default.createElement("a", _extends({
|
|
194
|
-
href: href,
|
|
195
|
-
onClick: function onClick(e) {
|
|
196
|
-
return cancelled(e, _this2.handleClick);
|
|
197
|
-
}
|
|
198
|
-
}, rest), children);
|
|
199
|
-
}
|
|
200
|
-
}]);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
render() {
|
|
75
|
+
const _this$props = this.props,
|
|
76
|
+
{
|
|
77
|
+
children
|
|
78
|
+
} = _this$props,
|
|
79
|
+
rest = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
80
|
+
|
|
81
|
+
const {
|
|
82
|
+
href
|
|
83
|
+
} = this.state;
|
|
84
|
+
return /*#__PURE__*/_react.default.createElement("a", _extends({
|
|
85
|
+
href: href,
|
|
86
|
+
onClick: e => cancelled(e, this.handleClick)
|
|
87
|
+
}, rest), children);
|
|
88
|
+
}
|
|
201
89
|
|
|
202
|
-
|
|
203
|
-
}(_react.PureComponent);
|
|
90
|
+
}
|
|
204
91
|
|
|
205
92
|
exports.default = LinkTo;
|
|
206
93
|
LinkTo.defaultProps = {
|
package/dist/cjs/utils.js
CHANGED
|
@@ -1,52 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.js");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.symbol.description.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.symbol.iterator.js");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.array.iterator.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.string.iterator.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.array.from.js");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.array.slice.js");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.function.name.js");
|
|
20
|
-
|
|
21
3
|
Object.defineProperty(exports, "__esModule", {
|
|
22
4
|
value: true
|
|
23
5
|
});
|
|
24
6
|
exports.withLinks = exports.navigate = exports.linkTo = exports.hrefTo = void 0;
|
|
25
7
|
|
|
26
|
-
require("core-js/modules/es.array.filter.js");
|
|
27
|
-
|
|
28
|
-
require("core-js/modules/es.object.to-string.js");
|
|
29
|
-
|
|
30
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
31
|
-
|
|
32
|
-
require("core-js/modules/es.string.split.js");
|
|
33
|
-
|
|
34
|
-
require("core-js/modules/es.promise.js");
|
|
35
|
-
|
|
36
|
-
require("core-js/modules/es.string.search.js");
|
|
37
|
-
|
|
38
|
-
require("core-js/modules/es.array.concat.js");
|
|
39
|
-
|
|
40
|
-
require("core-js/modules/es.array.join.js");
|
|
41
|
-
|
|
42
|
-
require("core-js/modules/es.array.map.js");
|
|
43
|
-
|
|
44
|
-
require("core-js/modules/es.object.entries.js");
|
|
45
|
-
|
|
46
|
-
require("core-js/modules/es.object.assign.js");
|
|
47
|
-
|
|
48
|
-
require("core-js/modules/es.string.match.js");
|
|
49
|
-
|
|
50
8
|
var _global = _interopRequireDefault(require("global"));
|
|
51
9
|
|
|
52
10
|
var _addons = require("@storybook/addons");
|
|
@@ -59,129 +17,110 @@ var _constants = require("./constants");
|
|
|
59
17
|
|
|
60
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
61
19
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
67
|
-
|
|
68
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
69
|
-
|
|
70
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
71
|
-
|
|
72
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
73
|
-
|
|
74
|
-
var document = _global.default.document,
|
|
75
|
-
HTMLElement = _global.default.HTMLElement;
|
|
20
|
+
const {
|
|
21
|
+
document,
|
|
22
|
+
HTMLElement
|
|
23
|
+
} = _global.default;
|
|
76
24
|
|
|
77
25
|
function parseQuery(queryString) {
|
|
78
|
-
|
|
79
|
-
|
|
26
|
+
const query = {};
|
|
27
|
+
const pairs = (queryString[0] === '?' ? queryString.substring(1) : queryString).split('&').filter(Boolean); // eslint-disable-next-line no-plusplus
|
|
80
28
|
|
|
81
|
-
for (
|
|
82
|
-
|
|
29
|
+
for (let i = 0; i < pairs.length; i++) {
|
|
30
|
+
const pair = pairs[i].split('=');
|
|
83
31
|
query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
|
|
84
32
|
}
|
|
85
33
|
|
|
86
34
|
return query;
|
|
87
35
|
}
|
|
88
36
|
|
|
89
|
-
|
|
90
|
-
return _addons.addons.getChannel().emit(_coreEvents.SELECT_STORY, params);
|
|
91
|
-
};
|
|
37
|
+
const navigate = params => _addons.addons.getChannel().emit(_coreEvents.SELECT_STORY, params);
|
|
92
38
|
|
|
93
39
|
exports.navigate = navigate;
|
|
94
40
|
|
|
95
|
-
|
|
96
|
-
return new Promise(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
}).join('&')
|
|
41
|
+
const hrefTo = (title, name) => {
|
|
42
|
+
return new Promise(resolve => {
|
|
43
|
+
const {
|
|
44
|
+
location
|
|
45
|
+
} = document;
|
|
46
|
+
const query = parseQuery(location.search);
|
|
47
|
+
const existingId = [].concat(query.id)[0];
|
|
48
|
+
const titleToLink = title || existingId.split('--', 2)[0];
|
|
49
|
+
const id = (0, _csf.toId)(titleToLink, name);
|
|
50
|
+
const url = `${location.origin + location.pathname}?${Object.entries(Object.assign({}, query, {
|
|
51
|
+
id
|
|
52
|
+
})).map(item => `${item[0]}=${item[1]}`).join('&')}`;
|
|
107
53
|
resolve(url);
|
|
108
54
|
});
|
|
109
55
|
};
|
|
110
56
|
|
|
111
57
|
exports.hrefTo = hrefTo;
|
|
112
58
|
|
|
113
|
-
|
|
114
|
-
return function (value) {
|
|
115
|
-
return typeof value === 'function' ? value.apply(void 0, _toConsumableArray(args)) : value;
|
|
116
|
-
};
|
|
117
|
-
};
|
|
59
|
+
const valueOrCall = args => value => typeof value === 'function' ? value(...args) : value;
|
|
118
60
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
navigate({
|
|
135
|
-
kind: title,
|
|
136
|
-
story: name
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
};
|
|
61
|
+
const linkTo = (idOrTitle, nameInput) => (...args) => {
|
|
62
|
+
const resolver = valueOrCall(args);
|
|
63
|
+
const title = resolver(idOrTitle);
|
|
64
|
+
const name = resolver(nameInput);
|
|
65
|
+
|
|
66
|
+
if (title !== null && title !== void 0 && title.match(/--/) && !name) {
|
|
67
|
+
navigate({
|
|
68
|
+
storyId: title
|
|
69
|
+
});
|
|
70
|
+
} else {
|
|
71
|
+
navigate({
|
|
72
|
+
kind: title,
|
|
73
|
+
story: name
|
|
74
|
+
});
|
|
75
|
+
}
|
|
140
76
|
};
|
|
141
77
|
|
|
142
78
|
exports.linkTo = linkTo;
|
|
143
79
|
|
|
144
|
-
|
|
145
|
-
|
|
80
|
+
const linksListener = e => {
|
|
81
|
+
const {
|
|
82
|
+
target
|
|
83
|
+
} = e;
|
|
146
84
|
|
|
147
85
|
if (!(target instanceof HTMLElement)) {
|
|
148
86
|
return;
|
|
149
87
|
}
|
|
150
88
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
89
|
+
const element = target;
|
|
90
|
+
const {
|
|
91
|
+
sbKind: kind,
|
|
92
|
+
sbStory: story
|
|
93
|
+
} = element.dataset;
|
|
155
94
|
|
|
156
95
|
if (kind || story) {
|
|
157
96
|
e.preventDefault();
|
|
158
97
|
navigate({
|
|
159
|
-
kind
|
|
160
|
-
story
|
|
98
|
+
kind,
|
|
99
|
+
story
|
|
161
100
|
});
|
|
162
101
|
}
|
|
163
102
|
};
|
|
164
103
|
|
|
165
|
-
|
|
104
|
+
let hasListener = false;
|
|
166
105
|
|
|
167
|
-
|
|
106
|
+
const on = () => {
|
|
168
107
|
if (!hasListener) {
|
|
169
108
|
hasListener = true;
|
|
170
109
|
document.addEventListener('click', linksListener);
|
|
171
110
|
}
|
|
172
111
|
};
|
|
173
112
|
|
|
174
|
-
|
|
113
|
+
const off = () => {
|
|
175
114
|
if (hasListener) {
|
|
176
115
|
hasListener = false;
|
|
177
116
|
document.removeEventListener('click', linksListener);
|
|
178
117
|
}
|
|
179
118
|
};
|
|
180
119
|
|
|
181
|
-
|
|
120
|
+
const withLinks = (0, _addons.makeDecorator)({
|
|
182
121
|
name: 'withLinks',
|
|
183
122
|
parameterName: _constants.PARAM_KEY,
|
|
184
|
-
wrapper:
|
|
123
|
+
wrapper: (getStory, context) => {
|
|
185
124
|
on();
|
|
186
125
|
|
|
187
126
|
_addons.addons.getChannel().once(_coreEvents.STORY_CHANGED, off);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-links",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.2",
|
|
4
4
|
"description": "Link stories together to build demos and prototypes with your UI components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"addon",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"prepare": "node ../../scripts/prepare.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@storybook/addons": "7.0.0-alpha.
|
|
38
|
-
"@storybook/client-logger": "7.0.0-alpha.
|
|
39
|
-
"@storybook/core-events": "7.0.0-alpha.
|
|
37
|
+
"@storybook/addons": "7.0.0-alpha.2",
|
|
38
|
+
"@storybook/client-logger": "7.0.0-alpha.2",
|
|
39
|
+
"@storybook/core-events": "7.0.0-alpha.2",
|
|
40
40
|
"@storybook/csf": "0.0.2--canary.4566f4d.1",
|
|
41
|
-
"@storybook/router": "7.0.0-alpha.
|
|
41
|
+
"@storybook/router": "7.0.0-alpha.2",
|
|
42
42
|
"core-js": "^3.8.2",
|
|
43
43
|
"global": "^4.4.0",
|
|
44
44
|
"prop-types": "^15.7.2",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "44920e2b6bd51981bac5124743c29fb9f5517e44",
|
|
64
64
|
"storybook": {
|
|
65
65
|
"displayName": "Links",
|
|
66
66
|
"icon": "https://user-images.githubusercontent.com/263385/101991673-48355c80-3c7c-11eb-9b6e-b627c96a75f6.png",
|