1 | import "core-js/modules/es.array.sort.js";
|
2 | import "core-js/modules/es.object.to-string.js";
|
3 | import "core-js/modules/es.object.values.js";
|
4 | import "core-js/modules/es.object.entries.js";
|
5 | import "core-js/modules/es.object.assign.js";
|
6 | import "core-js/modules/es.symbol.js";
|
7 | import "core-js/modules/es.symbol.description.js";
|
8 | import "core-js/modules/es.symbol.iterator.js";
|
9 | import "core-js/modules/es.array.iterator.js";
|
10 | import "core-js/modules/es.string.iterator.js";
|
11 | import "core-js/modules/web.dom-collections.iterator.js";
|
12 | import "core-js/modules/es.array.slice.js";
|
13 | import "core-js/modules/es.function.name.js";
|
14 | import "core-js/modules/es.array.from.js";
|
15 | import "core-js/modules/es.regexp.exec.js";
|
16 |
|
17 | function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
18 |
|
19 | 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."); }
|
20 |
|
21 | 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); }
|
22 |
|
23 | 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; }
|
24 |
|
25 | 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; }
|
26 |
|
27 | function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
28 |
|
29 | import React from 'react';
|
30 | import { useArgs, useGlobals, useArgTypes, useParameter, useStorybookState } from '@storybook/api';
|
31 | import { ArgsTable, NoControlsWarning } from '@storybook/components';
|
32 | import { PARAM_KEY } from './constants';
|
33 | export var ControlsPanel = function ControlsPanel() {
|
34 | var _useArgs = useArgs(),
|
35 | _useArgs2 = _slicedToArray(_useArgs, 3),
|
36 | args = _useArgs2[0],
|
37 | updateArgs = _useArgs2[1],
|
38 | resetArgs = _useArgs2[2];
|
39 |
|
40 | var _useGlobals = useGlobals(),
|
41 | _useGlobals2 = _slicedToArray(_useGlobals, 1),
|
42 | globals = _useGlobals2[0];
|
43 |
|
44 | var rows = useArgTypes();
|
45 | var isArgsStory = useParameter('__isArgsStory', false);
|
46 |
|
47 | var _useParameter = useParameter(PARAM_KEY, {}),
|
48 | expanded = _useParameter.expanded,
|
49 | sort = _useParameter.sort,
|
50 | presetColors = _useParameter.presetColors,
|
51 | _useParameter$hideNoC = _useParameter.hideNoControlsWarning,
|
52 | hideNoControlsWarning = _useParameter$hideNoC === void 0 ? false : _useParameter$hideNoC;
|
53 |
|
54 | var _useStorybookState = useStorybookState(),
|
55 | path = _useStorybookState.path;
|
56 |
|
57 | var hasControls = Object.values(rows).some(function (arg) {
|
58 | return arg === null || arg === void 0 ? void 0 : arg.control;
|
59 | });
|
60 | var showWarning = !(hasControls && isArgsStory) && !hideNoControlsWarning;
|
61 | var withPresetColors = Object.entries(rows).reduce(function (acc, _ref) {
|
62 | var _arg$control, _arg$control2;
|
63 |
|
64 | var _ref2 = _slicedToArray(_ref, 2),
|
65 | key = _ref2[0],
|
66 | arg = _ref2[1];
|
67 |
|
68 | 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, {
|
69 | control: Object.assign({}, arg.control, {
|
70 | presetColors: presetColors
|
71 | })
|
72 | });
|
73 | return acc;
|
74 | }, {});
|
75 | return React.createElement(React.Fragment, null, showWarning && React.createElement(NoControlsWarning, null), React.createElement(ArgsTable, {
|
76 | key: path,
|
77 |
|
78 | compact: !expanded && hasControls,
|
79 | rows: withPresetColors,
|
80 | args: args,
|
81 | globals: globals,
|
82 | updateArgs: updateArgs,
|
83 | resetArgs: resetArgs,
|
84 | inAddonPanel: true,
|
85 | sort: sort
|
86 | }));
|
87 | }; |
\ | No newline at end of file |