manager.js
1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"use strict";
require("core-js/modules/es6.object.define-property");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.register = register;
var _global = require("global");
var _addons = _interopRequireDefault(require("@storybook/addons"));
var _ = require(".");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function register() {
_addons.default.register(_.ADDON_ID, function (api) {
var channel = _addons.default.getChannel();
channel.on(_.EVENT_ID, function (selection) {
if (selection.kind != null) {
api.selectStory(selection.kind, selection.story);
} else {
api.selectInCurrentKind(selection.story);
}
});
channel.on(_.REQUEST_HREF_EVENT_ID, function (selection) {
var params = selection.kind != null ? {
selectedKind: selection.kind,
selectedStory: selection.story
} : {
selectedStory: selection.story
};
var urlState = api.getUrlState(params);
channel.emit(_.RECEIVE_HREF_EVENT_ID, _global.location.pathname + urlState.url);
});
});
}