1 | import "core-js/modules/es.array.filter.js";
|
2 | import "core-js/modules/es.object.to-string.js";
|
3 | import "core-js/modules/es.object.values.js";
|
4 | import React from 'react';
|
5 | import { addons, types } from '@storybook/addons';
|
6 | import { AddonPanel } from '@storybook/components';
|
7 | import { useArgTypes } from '@storybook/api';
|
8 | import { ControlsPanel } from './ControlsPanel';
|
9 | import { ADDON_ID, PARAM_KEY } from './constants';
|
10 | addons.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 React.createElement(AddonPanel, {
|
31 | key: key,
|
32 | active: active
|
33 | }, React.createElement(ControlsPanel, null));
|
34 | }
|
35 | });
|
36 | }); |
\ | No newline at end of file |