import React from 'react' import PropTypes from 'prop-types' import classnames from 'classnames' import DocLabel from '../fields/DocLabel' /** Wrap a component with a label */ class InputBlock extends React.Component { static propTypes = { label: PropTypes.oneOfType([ PropTypes.string, PropTypes.element, ]).isRequired, doc: PropTypes.string, action: PropTypes.element, children: PropTypes.element.isRequired, style: PropTypes.object, onChange: PropTypes.func, } onChange(e) { const value = e.target.value return this.props.onChange(value === "" ? null: value) } render() { return
{this.props.doc &&
} {!this.props.doc && } {this.props.action &&
{this.props.action}
}
{this.props.children}
} } export default InputBlock