1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.withStorySource = withStorySource;
|
7 |
|
8 | var _addons = _interopRequireDefault(require("@storybook/addons"));
|
9 |
|
10 | var _events = require("./events");
|
11 |
|
12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
13 |
|
14 | var getLocation = function getLocation(context, locationsMap) {
|
15 | return locationsMap[context.id];
|
16 | };
|
17 |
|
18 | function 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 |
|
28 | function 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 |