import React from 'react'
import PropTypes from 'prop-types'

import { componentPropType } from '../utils/props/componentPropType'

export const SelectGroup = React.forwardRef(({ children, label }, ref) => {
  return (
    <optgroup label={label} ref={ref}>
      {children}
    </optgroup>
  )
})

SelectGroup.displayName = 'SelectGroup'

SelectGroup.propTypes = {
  /**
   * `Select.Item` elements grouped under this group.
   */
  children: componentPropType('Item'),
  /**
   * The label for the group.
   */
  label: PropTypes.string.isRequired
}
