import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["children", "hideLabel", "input", "label", "id", "isRequired"];
import React from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';

var Label = function Label(_ref) {
  var children = _ref.children,
      hideLabel = _ref.hideLabel,
      input = _ref.input,
      label = _ref.label,
      id = _ref.id,
      isRequired = _ref.isRequired,
      other = _objectWithoutProperties(_ref, _excluded);

  if (children !== false && label !== false) {
    var labelClasses = classNames({
      'wfp--label': true,
      'wfp--visually-hidden': hideLabel,
      'label--required': isRequired
    });
    return /*#__PURE__*/React.createElement("label", _extends({}, other, {
      className: labelClasses,
      htmlFor: id ? id : input ? input.name : ''
    }), children ? children : label);
  } else {
    return null;
  }
};

Label.propTypes = {
  children: PropTypes.node,
  isRequired: PropTypes.bool
};
export default Label;