'use strict';

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

exports.__esModule = true;
exports.Checkbox = void 0;

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

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

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

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

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

var _FormGroup2 = require("./FormGroup");

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

var _CheckboxControl = require("./CheckboxControl");

var Checkbox =
/*#__PURE__*/
function (_FormGroup) {
  (0, _inheritsLoose2.default)(Checkbox, _FormGroup);

  function Checkbox() {
    return _FormGroup.apply(this, arguments) || this;
  }

  var _proto = Checkbox.prototype;

  _proto.controlLabelFallback = function controlLabelFallback() {
    return false;
  };

  _proto.renderInput = function renderInput(hasError) {
    var _this$props = this.props,
        label = _this$props.label,
        children = _this$props.children,
        props = (0, _objectWithoutPropertiesLoose2.default)(_this$props, ["label", "children"]);
    var ariaDescProps = this.getAriaDescProps(hasError);
    return _react.default.createElement(_CheckboxControl.CheckboxControl, (0, _extends2.default)({}, this.getSafeProps(props), {
      ref: "control",
      hiddenLabel: this.props.hiddenLabel,
      removeName: this.props.removeName,
      hasFormGroupContainer: true
    }, ariaDescProps), children || label);
  };

  return Checkbox;
}(_FormGroup2.FormGroup);

exports.Checkbox = Checkbox;
(0, _defineProperty2.default)(Checkbox, "propTypes", Object.assign({}, _FormGroup2.FormGroup.propTypes, {
  hiddenLabel: _propTypes.default.bool,
  removeName: _propTypes.default.bool
}));
(0, _defineProperty2.default)(Checkbox, "defaultProps", Object.assign({}, _FormGroup2.FormGroup.defaultProps, {
  testAutomationId: 'checkbox',
  hiddenLabel: false,
  removeName: false
}));