function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }

import React from 'react';
import PropTypes from 'prop-types';
import { CloseIcon } from "./..";

var ModalHeader =
/*#__PURE__*/
function (_React$PureComponent) {
  _inheritsLoose(ModalHeader, _React$PureComponent);

  function ModalHeader() {
    return _React$PureComponent.apply(this, arguments) || this;
  }

  var _proto = ModalHeader.prototype;

  _proto.render = function render() {
    var _this$props = this.props,
        children = _this$props.children,
        className = _this$props.className,
        headerLabel = _this$props.headerLabel,
        showCloseButton = _this$props.showCloseButton,
        props = _objectWithoutProperties(_this$props, ["children", "className", "headerLabel", "showCloseButton"]);

    var handleClose = this.context.handleClose;
    return React.createElement("div", _extends({
      className: 'cui-modal__header' + ("" + (className && " " + className || ''))
    }, props), children ? children : React.createElement("span", {
      className: "cui-modal__title"
    }, headerLabel), showCloseButton && React.createElement(CloseIcon, {
      className: "cui-modal__close",
      onClick: handleClose
    }));
  };

  return ModalHeader;
}(React.PureComponent);

ModalHeader.contextTypes = {
  handleClose: PropTypes.func
};
ModalHeader.defaultProps = {
  children: null,
  className: '',
  headerLabel: '',
  showCloseButton: true
};
ModalHeader.propTypes = {
  /**
   * header label.
   */
  children: PropTypes.node,

  /**
   * CSS classnames
   */
  className: PropTypes.string,

  /**
   * header label.
   */
  headerLabel: PropTypes.string,

  /**
   * show/hide close button
   */
  showCloseButton: PropTypes.bool
};
ModalHeader.displayName = 'ModalHeader';
export default ModalHeader;