import "core-js/modules/es6.object.assign";
import "core-js/modules/web.dom.iterable";
import "core-js/modules/es6.array.iterator";
import "core-js/modules/es6.object.keys";

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 _objectWithoutPropertiesLoose(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]; } 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,
        message = _this$props.message,
        showCloseButton = _this$props.showCloseButton,
        props = _objectWithoutPropertiesLoose(_this$props, ["children", "className", "headerLabel", "message", "showCloseButton"]);

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

  return ModalHeader;
}(React.PureComponent);

ModalHeader.propTypes = {
  /** @prop Children nodes to render inside of ModalHeader | null */
  children: PropTypes.node,

  /** @prop Optional CSS class names | '' */
  className: PropTypes.string,

  /** @prop ModalHeader label text | '' */
  headerLabel: PropTypes.string,

  /** @prop Modal message | '' */
  message: PropTypes.string,

  /** @prop show/hide close button | true */
  showCloseButton: PropTypes.bool
};
ModalHeader.defaultProps = {
  children: null,
  className: '',
  headerLabel: '',
  message: '',
  showCloseButton: true
};
ModalHeader.contextTypes = {
  handleClose: PropTypes.func
};
ModalHeader.displayName = 'ModalHeader';
export default ModalHeader;