import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import React, { forwardRef } from 'react';
import PropTypes from 'prop-types';
import getEventHandlersFromProps from '../utils/getEventHandlersFromProps';
import Select from '../Select';
import SuperField from '../SuperField';
import SuperFieldLabel from '../SuperFieldLabel';
import SuperFieldHint from '../SuperFieldHint';
/**
 * Convenient component for most of the SelectFields. But with SuperField is
 * simple to compose its own.  It just specified that this is a input field,
 * that can have an error, hint, prefix or suffix.
 */

var SelectField = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var id = _ref.id,
      label = _ref.label,
      hasError = _ref.hasError,
      hint = _ref.hint,
      onChange = _ref.onChange,
      value = _ref.value,
      name = _ref.name,
      disabled = _ref.disabled,
      readOnly = _ref.readOnly,
      placeholder = _ref.placeholder,
      inputProps = _ref.inputProps,
      labelAlwaysShrank = _ref.labelAlwaysShrank,
      getLabel = _ref.getLabel,
      getValue = _ref.getValue,
      items = _ref.items,
      rest = _objectWithoutProperties(_ref, ["id", "label", "hasError", "hint", "onChange", "value", "name", "disabled", "readOnly", "placeholder", "inputProps", "labelAlwaysShrank", "getLabel", "getValue", "items"]);

  return /*#__PURE__*/React.createElement(SuperField, _extends({
    ref: ref
  }, rest, {
    disabled: disabled,
    readOnly: readOnly,
    hasError: hasError,
    id: id
  }), /*#__PURE__*/React.createElement(SuperFieldLabel, {
    alwaysShrank: !!(labelAlwaysShrank || placeholder)
  }, label), /*#__PURE__*/React.createElement(Select, _extends({
    placeholder: placeholder,
    value: value,
    name: name,
    onChange: onChange,
    disabled: disabled,
    readOnly: readOnly,
    items: items,
    getLabel: getLabel,
    getValue: getValue
  }, getEventHandlersFromProps(rest), inputProps)), /*#__PURE__*/React.createElement(SuperFieldHint, null, hint));
});
SelectField.displayName = 'SelectField';
SelectField.propTypes = {
  disabled: PropTypes.bool,
  getLabel: PropTypes.func,
  getValue: PropTypes.func,
  hasError: PropTypes.bool,
  hint: PropTypes.node,
  id: PropTypes.string,
  inputProps: PropTypes.object,
  items: PropTypes.array,
  label: PropTypes.node,
  labelAlwaysShrank: PropTypes.bool,
  name: PropTypes.string,
  onChange: PropTypes.func,
  placeholder: PropTypes.string,
  readOnly: PropTypes.bool,
  value: PropTypes.any
};
export default SelectField;