UNPKG

2.49 kBJavaScriptView Raw
1import "core-js/modules/es.symbol.js";
2import "core-js/modules/es.symbol.description.js";
3import "core-js/modules/es.array.filter.js";
4import "core-js/modules/es.array.map.js";
5import "core-js/modules/es.function.name.js";
6import React from 'react';
7import { styled } from '@storybook/theming';
8import { codeCommon } from '../../typography/shared';
9export var Table = styled.table(function (_ref) {
10 var theme = _ref.theme;
11 return {
12 '&&': {
13 // Escape default table styles
14 borderCollapse: 'collapse',
15 borderSpacing: 0,
16 border: 'none',
17 tr: {
18 border: 'none !important',
19 background: 'none'
20 },
21 'td, th': {
22 padding: 0,
23 border: 'none',
24 width: 'auto!important'
25 },
26 // End escape
27 marginTop: 0,
28 marginBottom: 0,
29 'th:first-of-type, td:first-of-type': {
30 paddingLeft: 0
31 },
32 'th:last-of-type, td:last-of-type': {
33 paddingRight: 0
34 },
35 td: {
36 paddingTop: 0,
37 paddingBottom: 4,
38 '&:not(:first-of-type)': {
39 paddingLeft: 10,
40 paddingRight: 0
41 }
42 },
43 tbody: {
44 boxShadow: 'none',
45 border: 'none'
46 },
47 code: codeCommon({
48 theme: theme
49 }),
50 '& code': {
51 margin: 0,
52 display: 'inline-block',
53 fontSize: theme.typography.size.s1
54 }
55 }
56 };
57});
58export var ArgJsDoc = function ArgJsDoc(_ref2) {
59 var tags = _ref2.tags;
60 var params = (tags.params || []).filter(function (x) {
61 return x.description;
62 });
63 var hasDisplayableParams = params.length !== 0;
64 var hasDisplayableReturns = tags.returns != null && tags.returns.description != null;
65
66 if (!hasDisplayableParams && !hasDisplayableReturns) {
67 return null;
68 }
69
70 return /*#__PURE__*/React.createElement(Table, null, /*#__PURE__*/React.createElement("tbody", null, hasDisplayableParams && params.map(function (x) {
71 return /*#__PURE__*/React.createElement("tr", {
72 key: x.name
73 }, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("code", null, x.name)), /*#__PURE__*/React.createElement("td", null, x.description));
74 }), hasDisplayableReturns && /*#__PURE__*/React.createElement("tr", {
75 key: "returns"
76 }, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("code", null, "Returns")), /*#__PURE__*/React.createElement("td", null, tags.returns.description))));
77};
78ArgJsDoc.displayName = "ArgJsDoc";
\No newline at end of file