1 | "use strict";
|
2 |
|
3 | require("core-js/modules/es.symbol.js");
|
4 |
|
5 | require("core-js/modules/es.symbol.description.js");
|
6 |
|
7 | require("core-js/modules/es.symbol.iterator.js");
|
8 |
|
9 | require("core-js/modules/es.array.iterator.js");
|
10 |
|
11 | require("core-js/modules/es.string.iterator.js");
|
12 |
|
13 | require("core-js/modules/web.dom-collections.iterator.js");
|
14 |
|
15 | require("core-js/modules/es.array.slice.js");
|
16 |
|
17 | require("core-js/modules/es.function.name.js");
|
18 |
|
19 | require("core-js/modules/es.array.from.js");
|
20 |
|
21 | require("core-js/modules/es.regexp.exec.js");
|
22 |
|
23 | Object.defineProperty(exports, "__esModule", {
|
24 | value: true
|
25 | });
|
26 | exports.ControlsPanel = void 0;
|
27 |
|
28 | require("core-js/modules/es.array.sort.js");
|
29 |
|
30 | require("core-js/modules/es.object.to-string.js");
|
31 |
|
32 | require("core-js/modules/es.object.values.js");
|
33 |
|
34 | require("core-js/modules/es.object.entries.js");
|
35 |
|
36 | require("core-js/modules/es.object.assign.js");
|
37 |
|
38 | var _react = _interopRequireDefault(require("react"));
|
39 |
|
40 | var _api = require("@storybook/api");
|
41 |
|
42 | var _components = require("@storybook/components");
|
43 |
|
44 | var _constants = require("./constants");
|
45 |
|
46 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
47 |
|
48 | function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
49 |
|
50 | function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
51 |
|
52 | function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
53 |
|
54 | function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
55 |
|
56 | function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
57 |
|
58 | function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
59 |
|
60 | var ControlsPanel = function ControlsPanel() {
|
61 | var _useArgs = (0, _api.useArgs)(),
|
62 | _useArgs2 = _slicedToArray(_useArgs, 3),
|
63 | args = _useArgs2[0],
|
64 | updateArgs = _useArgs2[1],
|
65 | resetArgs = _useArgs2[2];
|
66 |
|
67 | var _useGlobals = (0, _api.useGlobals)(),
|
68 | _useGlobals2 = _slicedToArray(_useGlobals, 1),
|
69 | globals = _useGlobals2[0];
|
70 |
|
71 | var rows = (0, _api.useArgTypes)();
|
72 | var isArgsStory = (0, _api.useParameter)('__isArgsStory', false);
|
73 |
|
74 | var _useParameter = (0, _api.useParameter)(_constants.PARAM_KEY, {}),
|
75 | expanded = _useParameter.expanded,
|
76 | sort = _useParameter.sort,
|
77 | presetColors = _useParameter.presetColors,
|
78 | _useParameter$hideNoC = _useParameter.hideNoControlsWarning,
|
79 | hideNoControlsWarning = _useParameter$hideNoC === void 0 ? false : _useParameter$hideNoC;
|
80 |
|
81 | var _useStorybookState = (0, _api.useStorybookState)(),
|
82 | path = _useStorybookState.path;
|
83 |
|
84 | var hasControls = Object.values(rows).some(function (arg) {
|
85 | return arg === null || arg === void 0 ? void 0 : arg.control;
|
86 | });
|
87 | var showWarning = !(hasControls && isArgsStory) && !hideNoControlsWarning;
|
88 | var withPresetColors = Object.entries(rows).reduce(function (acc, _ref) {
|
89 | var _arg$control, _arg$control2;
|
90 |
|
91 | var _ref2 = _slicedToArray(_ref, 2),
|
92 | key = _ref2[0],
|
93 | arg = _ref2[1];
|
94 |
|
95 | if ((arg === null || arg === void 0 ? void 0 : (_arg$control = arg.control) === null || _arg$control === void 0 ? void 0 : _arg$control.type) !== 'color' || arg !== null && arg !== void 0 && (_arg$control2 = arg.control) !== null && _arg$control2 !== void 0 && _arg$control2.presetColors) acc[key] = arg;else acc[key] = Object.assign({}, arg, {
|
96 | control: Object.assign({}, arg.control, {
|
97 | presetColors: presetColors
|
98 | })
|
99 | });
|
100 | return acc;
|
101 | }, {});
|
102 | return _react.default.createElement(_react.default.Fragment, null, showWarning && _react.default.createElement(_components.NoControlsWarning, null), _react.default.createElement(_components.ArgsTable, {
|
103 | key: path,
|
104 |
|
105 | compact: !expanded && hasControls,
|
106 | rows: withPresetColors,
|
107 | args: args,
|
108 | globals: globals,
|
109 | updateArgs: updateArgs,
|
110 | resetArgs: resetArgs,
|
111 | inAddonPanel: true,
|
112 | sort: sort
|
113 | }));
|
114 | };
|
115 |
|
116 | exports.ControlsPanel = ControlsPanel; |
\ | No newline at end of file |