UNPKG

3.85 kBJavaScriptView Raw
1import "core-js/modules/es.symbol.js";
2import "core-js/modules/es.symbol.description.js";
3import "core-js/modules/es.function.name.js";
4import React from 'react';
5import Markdown from 'markdown-to-jsx';
6import { transparentize } from 'polished';
7import { styled } from '@storybook/theming';
8import { ArgJsDoc } from './ArgJsDoc';
9import { ArgValue } from './ArgValue';
10import { ArgControl } from './ArgControl';
11import { codeCommon } from '../../typography/shared';
12var Name = styled.span({
13 fontWeight: 'bold'
14});
15var Required = styled.span(function (_ref) {
16 var theme = _ref.theme;
17 return {
18 color: theme.color.negative,
19 fontFamily: theme.typography.fonts.mono,
20 cursor: 'help'
21 };
22});
23var Description = styled.div(function (_ref2) {
24 var theme = _ref2.theme;
25 return {
26 '&&': {
27 p: {
28 margin: '0 0 10px 0'
29 },
30 a: {
31 color: theme.color.secondary
32 }
33 },
34 code: codeCommon({
35 theme: theme
36 }),
37 '& code': {
38 margin: 0,
39 display: 'inline-block'
40 }
41 };
42});
43var Type = styled.div(function (_ref3) {
44 var theme = _ref3.theme,
45 hasDescription = _ref3.hasDescription;
46 return {
47 color: theme.base === 'light' ? transparentize(0.1, theme.color.defaultText) : transparentize(0.2, theme.color.defaultText),
48 marginTop: hasDescription ? 4 : 0
49 };
50});
51var TypeWithJsDoc = styled.div(function (_ref4) {
52 var theme = _ref4.theme,
53 hasDescription = _ref4.hasDescription;
54 return {
55 color: theme.base === 'light' ? transparentize(0.1, theme.color.defaultText) : transparentize(0.2, theme.color.defaultText),
56 marginTop: hasDescription ? 12 : 0,
57 marginBottom: 12
58 };
59});
60var StyledTd = styled.td(function (_ref5) {
61 var theme = _ref5.theme,
62 expandable = _ref5.expandable;
63 return {
64 paddingLeft: expandable ? '40px !important' : '20px !important'
65 };
66});
67export var ArgRow = function ArgRow(props) {
68 var _row$type;
69
70 var row = props.row,
71 updateArgs = props.updateArgs,
72 compact = props.compact,
73 expandable = props.expandable,
74 initialExpandedArgs = props.initialExpandedArgs;
75 var name = row.name,
76 description = row.description;
77 var table = row.table || {};
78 var type = table.type || row.type;
79 var defaultValue = table.defaultValue || row.defaultValue;
80 var required = (_row$type = row.type) === null || _row$type === void 0 ? void 0 : _row$type.required;
81 var hasDescription = description != null && description !== '';
82 return /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement(StyledTd, {
83 expandable: expandable
84 }, /*#__PURE__*/React.createElement(Name, null, name), required ? /*#__PURE__*/React.createElement(Required, {
85 title: "Required"
86 }, "*") : null), compact ? null : /*#__PURE__*/React.createElement("td", null, hasDescription && /*#__PURE__*/React.createElement(Description, null, /*#__PURE__*/React.createElement(Markdown, null, description)), table.jsDocTags != null ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TypeWithJsDoc, {
87 hasDescription: hasDescription
88 }, /*#__PURE__*/React.createElement(ArgValue, {
89 value: type,
90 initialExpandedArgs: initialExpandedArgs
91 })), /*#__PURE__*/React.createElement(ArgJsDoc, {
92 tags: table.jsDocTags
93 })) : /*#__PURE__*/React.createElement(Type, {
94 hasDescription: hasDescription
95 }, /*#__PURE__*/React.createElement(ArgValue, {
96 value: type,
97 initialExpandedArgs: initialExpandedArgs
98 }))), compact ? null : /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(ArgValue, {
99 value: defaultValue,
100 initialExpandedArgs: initialExpandedArgs
101 })), updateArgs ? /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(ArgControl, props)) : null);
102};
103ArgRow.displayName = "ArgRow";
\No newline at end of file