import React from 'react';
import { isEmptyRadio } from '../../utils/validate';
import FieldWrapper from './FieldWrapper';
import withField from './withField'; // group of radio buttons with optional help text and label
// displays error if validation fails

var FieldSelect = function FieldSelect(props) {
  var input = props.input,
      options = props.options,
      disabled = props.disabled,
      multiple = props.multiple;
  var labelClass = "select ".concat(multiple ? 'multiple' : '');
  return React.createElement(FieldWrapper, props, React.createElement("label", {
    className: labelClass
  }, React.createElement("select", Object.assign({}, input, {
    multiple: multiple,
    disabled: disabled
  }), React.createElement("option", {
    disabled: true,
    hidden: true,
    style: {
      display: 'none'
    },
    value: ''
  }), options.filter(function (x) {
    return !x.hidden;
  }).map(function (option) {
    return React.createElement("option", {
      key: option.value,
      value: option.value
    }, option.label);
  }))));
};

FieldSelect.defaultProps = {
  disabled: false,
  multiple: false
};
var withReduxField = withField(isEmptyRadio);
export default withReduxField(FieldSelect);