@automattic/form-components
Version:
React-based form components, as used on WordPress.com
26 lines (23 loc) • 645 B
JSX
/**
* External dependencies
*/
import React from 'react';
import { omit } from 'lodash';
const SelectOptGroups = props => {
const { optGroups, ...selectProps } = props;
return <select { ...omit( selectProps, [ 'moment', 'numberFormat', 'translate' ] ) }>
{ optGroups.map( optGroup =>
<optgroup label={ optGroup.label } key={ `optgroup-${ optGroup.label }` } >
{ optGroup.options.map( option =>
<option
value={ option.value }
key={ `option-${ optGroup.label }${ option.label }` }
>
{ option.label }
</option>
) }
</optgroup>
) }
</select>;
};
export default SelectOptGroups;