1 | import "core-js/modules/es.symbol.js";
|
2 | import "core-js/modules/es.symbol.description.js";
|
3 | import "core-js/modules/es.function.name.js";
|
4 | import React from 'react';
|
5 | import Markdown from 'markdown-to-jsx';
|
6 | import { transparentize } from 'polished';
|
7 | import { styled } from '@storybook/theming';
|
8 | import { ArgJsDoc } from './ArgJsDoc';
|
9 | import { ArgValue } from './ArgValue';
|
10 | import { ArgControl } from './ArgControl';
|
11 | import { codeCommon } from '../../typography/shared';
|
12 | var Name = styled.span({
|
13 | fontWeight: 'bold'
|
14 | });
|
15 | var 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 | });
|
23 | var 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 | });
|
43 | var 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 | });
|
51 | var 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 | });
|
60 | var 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 | });
|
67 | export 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 React.createElement("tr", null, React.createElement(StyledTd, {
|
83 | expandable: expandable
|
84 | }, React.createElement(Name, null, name), required ? React.createElement(Required, {
|
85 | title: "Required"
|
86 | }, "*") : null), compact ? null : React.createElement("td", null, hasDescription && React.createElement(Description, null, React.createElement(Markdown, null, description)), table.jsDocTags != null ? React.createElement(React.Fragment, null, React.createElement(TypeWithJsDoc, {
|
87 | hasDescription: hasDescription
|
88 | }, React.createElement(ArgValue, {
|
89 | value: type,
|
90 | initialExpandedArgs: initialExpandedArgs
|
91 | })), React.createElement(ArgJsDoc, {
|
92 | tags: table.jsDocTags
|
93 | })) : React.createElement(Type, {
|
94 | hasDescription: hasDescription
|
95 | }, React.createElement(ArgValue, {
|
96 | value: type,
|
97 | initialExpandedArgs: initialExpandedArgs
|
98 | }))), compact ? null : React.createElement("td", null, React.createElement(ArgValue, {
|
99 | value: defaultValue,
|
100 | initialExpandedArgs: initialExpandedArgs
|
101 | })), updateArgs ? React.createElement("td", null, React.createElement(ArgControl, props)) : null);
|
102 | };
|
103 | ArgRow.displayName = "ArgRow"; |
\ | No newline at end of file |