UNPKG

1.15 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.createAddonDecorator = void 0;
7
8var _addons = require("@storybook/addons");
9
10var _ContextsPreviewAPI2 = require("./preview/ContextsPreviewAPI");
11
12var _constants = require("./shared/constants");
13
14var createAddonDecorator = function createAddonDecorator(render) {
15 var wrapper = function wrapper(getStory, context, settings) {
16 var _ContextsPreviewAPI = (0, _ContextsPreviewAPI2.ContextsPreviewAPI)(),
17 getContextNodes = _ContextsPreviewAPI.getContextNodes,
18 getSelectionState = _ContextsPreviewAPI.getSelectionState,
19 getPropsMap = _ContextsPreviewAPI.getPropsMap;
20
21 var nodes = getContextNodes(settings);
22 var state = getSelectionState();
23 var props = getPropsMap(nodes, state);
24 return render(nodes, props, function () {
25 return getStory(context);
26 });
27 };
28
29 return (0, _addons.makeDecorator)({
30 name: _constants.ID,
31 parameterName: _constants.PARAM,
32 skipIfNoParametersOrOptions: true,
33 allowDeprecatedUsage: false,
34 wrapper: wrapper
35 });
36};
37
38exports.createAddonDecorator = createAddonDecorator;
\No newline at end of file