semantic-ui-react
Version:
The official Semantic-UI-React integration.
39 lines (30 loc) • 1.02 kB
JavaScript
import PropTypes from 'prop-types'
import React from 'react'
import { getElementType, getUnhandledProps } from '../../lib'
import Select from '../../addons/Select'
import Dropdown from '../../modules/Dropdown'
import FormField from './FormField'
/**
* Sugar for <Form.Field control={Select} />.
* @see Form
* @see Select
*/
function FormSelect(props) {
const { control, options } = props
const rest = getUnhandledProps(FormSelect, props)
const ElementType = getElementType(FormSelect, props)
return <ElementType {...rest} control={control} options={options} />
}
FormSelect.propTypes = {
/** An element type to render as (string or function). */
as: PropTypes.elementType,
/** A FormField control prop. */
control: FormField.propTypes.control,
/** Array of Dropdown.Item props e.g. `{ text: '', value: '' }` */
options: PropTypes.arrayOf(PropTypes.shape(Dropdown.Item.propTypes)).isRequired,
}
FormSelect.defaultProps = {
as: FormField,
control: Select,
}
export default FormSelect