UNPKG

952 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.withStorySource = withStorySource;
7
8var _addons = _interopRequireDefault(require("@storybook/addons"));
9
10var _events = require("./events");
11
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
14var getLocation = function getLocation(context, locationsMap) {
15 return locationsMap[context.id];
16};
17
18function setStorySource(context, source, locationsMap) {
19 var currentLocation = getLocation(context, locationsMap);
20
21 _addons["default"].getChannel().emit(_events.EVENT_ID, {
22 source: source,
23 currentLocation: currentLocation,
24 locationsMap: locationsMap
25 });
26}
27
28function withStorySource(source) {
29 var locationsMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
30 return function (storyFn, context) {
31 setStorySource(context, source, locationsMap);
32 return storyFn();
33 };
34}
\No newline at end of file