Sha256: 071937a6c2a4dbc2b70a593b740aa5f49646150aaa103529b6717d36e8bac163
Contents?: true
Size: 1.12 KB
Versions: 22
Compression:
Stored size: 1.12 KB
Contents
import React from 'react'; import PropTypes from 'prop-types'; import InputField from './InputField'; import SelectField from './SelectField'; import CheckboxField from './CheckboxField'; const FieldType = ({ item, fieldSelector, input, disabled, blank }) => { if (!fieldSelector) { return <InputField input={input} disabled={disabled} />; } switch (fieldSelector(item)) { case 'text': return <InputField input={input} disabled={disabled} />; case 'select': return ( <SelectField input={input} blank={blank} item={item} disabled={disabled} /> ); case 'checkbox': return <CheckboxField input={input} item={item} disabled={disabled} />; default: throw new Error(`Unknown field type ${fieldSelector(item)} for ${item}`); } }; FieldType.propTypes = { item: PropTypes.object.isRequired, fieldSelector: PropTypes.func, input: PropTypes.object.isRequired, disabled: PropTypes.bool, blank: PropTypes.object, }; FieldType.defaultProps = { fieldSelector: null, disabled: false, blank: {}, }; export default FieldType;
Version data entries
22 entries across 22 versions & 1 rubygems