UNPKG

wix-storybook-utils

Version:

Utilities for automated component documentation within Storybook

27 lines 1.19 kB
import React from 'react'; import PropTypes from 'prop-types'; import { Layout, Cell } from '../../ui/Layout'; import Markdown from '../../Markdown'; import styles from './styles.scss'; var Option = function (_a) { var label = _a.label, value = _a.value, children = _a.children, onChange = _a.onChange, defaultValue = _a.defaultValue, isRequired = _a.isRequired, dataHook = _a.dataHook; return children ? (React.createElement(Layout, { dataHook: dataHook, className: styles.option }, React.createElement(Cell, { span: 5 }, React.createElement(Markdown, { source: "`".concat(label).concat(isRequired ? '*' : '', "`") })), React.createElement(Cell, { span: 7 }, React.cloneElement(children, { value: children.type === 'div' ? value.toString() : value, defaultValue: defaultValue, onChange: onChange, })))) : null; }; Option.propTypes = { label: PropTypes.string, value: PropTypes.any, defaultValue: PropTypes.any, children: PropTypes.node, onChange: PropTypes.func, isRequired: PropTypes.bool, dataHook: PropTypes.string, }; export default Option; //# sourceMappingURL=option.js.map