"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _excluded = ["children", "hideLabel", "input", "label", "id", "isRequired"];

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 = (0, _objectWithoutProperties2.default)(_ref, _excluded);

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

Label.propTypes = {
  children: _propTypes.default.node,
  isRequired: _propTypes.default.bool
};
var _default = Label;
exports.default = _default;