UNPKG

1.25 kBJavaScriptView Raw
1import "core-js/modules/es.array.filter.js";
2import "core-js/modules/es.object.to-string.js";
3import "core-js/modules/es.object.values.js";
4import React from 'react';
5import { addons, types } from '@storybook/addons';
6import { AddonPanel } from '@storybook/components';
7import { useArgTypes } from '@storybook/api';
8import { ControlsPanel } from './ControlsPanel';
9import { ADDON_ID, PARAM_KEY } from './constants';
10addons.register(ADDON_ID, function (api) {
11 addons.addPanel(ADDON_ID, {
12 title: function title() {
13 var rows = useArgTypes();
14 var controlsCount = Object.values(rows).filter(function (argType) {
15 return argType === null || argType === void 0 ? void 0 : argType.control;
16 }).length;
17 var suffix = controlsCount === 0 ? '' : " (".concat(controlsCount, ")");
18 return "Controls".concat(suffix);
19 },
20 type: types.PANEL,
21 paramKey: PARAM_KEY,
22 render: function render(_ref) {
23 var key = _ref.key,
24 active = _ref.active;
25
26 if (!active || !api.getCurrentStoryData()) {
27 return null;
28 }
29
30 return /*#__PURE__*/React.createElement(AddonPanel, {
31 key: key,
32 active: active
33 }, /*#__PURE__*/React.createElement(ControlsPanel, null));
34 }
35 });
36});
\No newline at end of file