1 | "use strict";
|
2 |
|
3 | function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
4 |
|
5 | require("core-js/modules/es.symbol");
|
6 |
|
7 | require("core-js/modules/es.array.index-of");
|
8 |
|
9 | require("core-js/modules/es.object.assign");
|
10 |
|
11 | require("core-js/modules/es.object.keys");
|
12 |
|
13 | Object.defineProperty(exports, "__esModule", {
|
14 | value: true
|
15 | });
|
16 | exports.withOptions = exports.setOptions = void 0;
|
17 |
|
18 | var _utilDeprecate = _interopRequireDefault(require("util-deprecate"));
|
19 |
|
20 | var _addons = _interopRequireWildcard(require("@storybook/addons"));
|
21 |
|
22 | var _constants = _interopRequireDefault(require("./constants"));
|
23 |
|
24 | function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
25 |
|
26 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
27 |
|
28 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
29 |
|
30 | 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; }
|
31 |
|
32 | 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; }
|
33 |
|
34 | function emitOptions(options) {
|
35 | var channel = _addons["default"].getChannel();
|
36 |
|
37 | if (!channel) {
|
38 | throw new Error('Failed to find addon channel. This may be due to https://github.com/storybookjs/storybook/issues/1192.');
|
39 | }
|
40 |
|
41 |
|
42 |
|
43 | channel.emit(_constants["default"].SET, {
|
44 | options: options
|
45 | });
|
46 | }
|
47 |
|
48 |
|
49 |
|
50 | var globalOptions = {};
|
51 | var setOptions = (0, _utilDeprecate["default"])(function (options) {
|
52 | globalOptions = options;
|
53 | emitOptions(options);
|
54 | }, '`setOptions(options)` is deprecated. Please use the `withOptions(options)` decorator globally.');
|
55 | exports.setOptions = setOptions;
|
56 | var withOptions = (0, _addons.makeDecorator)({
|
57 | name: 'withOptions',
|
58 | parameterName: 'options',
|
59 | skipIfNoParametersOrOptions: false,
|
60 | wrapper: (0, _utilDeprecate["default"])(function (getStory, context, _ref) {
|
61 | var inputOptions = _ref.options,
|
62 | parameters = _ref.parameters;
|
63 |
|
64 |
|
65 | var _globalOptions$inputO = Object.assign({}, globalOptions, {}, inputOptions, {}, parameters),
|
66 | hierarchySeparator = _globalOptions$inputO.hierarchySeparator,
|
67 | hierarchyRootSeparator = _globalOptions$inputO.hierarchyRootSeparator,
|
68 | change = _objectWithoutProperties(_globalOptions$inputO, ["hierarchySeparator", "hierarchyRootSeparator"]);
|
69 |
|
70 | if (Object.keys(change).length) {
|
71 | emitOptions(Object.assign({}, globalOptions, {}, inputOptions, {}, parameters));
|
72 | }
|
73 |
|
74 |
|
75 |
|
76 | context.options = Object.assign({}, globalOptions, {}, inputOptions, {}, parameters);
|
77 | return getStory(Object.assign({}, context, {
|
78 | options: Object.assign({}, globalOptions, {}, inputOptions, {}, parameters)
|
79 | }));
|
80 | }, 'withOptions is deprecated, use addParameters({ options: {} }) instead')
|
81 | });
|
82 | exports.withOptions = withOptions;
|
83 |
|
84 | if (module && module.hot && module.hot.decline) {
|
85 | module.hot.decline();
|
86 | } |
\ | No newline at end of file |