'use strict';

import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React from 'react';
import PropTypes from 'prop-types';
import BSPanel from 'react-bootstrap/lib/Panel';
import classnames from 'classnames';
import { Button } from './Button';
import { Icon } from './Icon';
export var Panel =
/*#__PURE__*/
function (_React$Component) {
  _inheritsLoose(Panel, _React$Component);

  function Panel(props, context) {
    return _React$Component.call(this, props, context) || this;
  }

  var _proto = Panel.prototype;

  _proto.getCloseButton = function getCloseButton() {
    if (this.props.closable && this.props.header) {
      return React.createElement(Button, {
        iconOnly: true,
        bsStyle: "link",
        className: "rc-panel-close-button",
        testAutomationId: "closeButton",
        onClick: this.props.onClose,
        "aria-label": this.props.closeLabel
      }, React.createElement(Icon, {
        name: "close"
      }));
    } else {
      return null;
    }
  };

  _proto.render = function render() {
    var _this$props = this.props,
        onClose = _this$props.onClose,
        className = _this$props.className,
        closable = _this$props.closable,
        closeLabel = _this$props.closeLabel,
        noPadding = _this$props.noPadding,
        noHeaderPadding = _this$props.noHeaderPadding,
        smallHeaderPadding = _this$props.smallHeaderPadding,
        cancelMinHeight = _this$props.cancelMinHeight,
        noBorder = _this$props.noBorder,
        noLeftBorder = _this$props.noLeftBorder,
        noRightBorder = _this$props.noRightBorder,
        addHeaderBorder = _this$props.addHeaderBorder,
        noHeaderBorder = _this$props.noHeaderBorder,
        testAutomationId = _this$props.testAutomationId,
        flexContent = _this$props.flexContent,
        flexContainer = _this$props.flexContainer,
        cancelBottomOffset = _this$props.cancelBottomOffset,
        isTransparent = _this$props.isTransparent,
        props = _objectWithoutPropertiesLoose(_this$props, ["onClose", "className", "closable", "closeLabel", "noPadding", "noHeaderPadding", "smallHeaderPadding", "cancelMinHeight", "noBorder", "noLeftBorder", "noRightBorder", "addHeaderBorder", "noHeaderBorder", "testAutomationId", "flexContent", "flexContainer", "cancelBottomOffset", "isTransparent"]);

    var containerClassName = classnames('rc-panel', {
      'rc-panel-flexContainer': flexContainer
    });
    return React.createElement("div", {
      className: containerClassName,
      "data-test-automation-id": testAutomationId
    }, this.getCloseButton(), React.createElement(BSPanel, _extends({
      className: classnames({
        'rc-panel-noPadding': noPadding,
        'rc-panel-noHeaderPadding': noHeaderPadding,
        'rc-panel-cancelMinHeight': cancelMinHeight,
        'rc-panel-noBorder': noBorder,
        'rc-panel-noLeftBorder': noLeftBorder,
        'rc-panel-noRightBorder': noRightBorder,
        'rc-panel-noHeaderBorder': noHeaderBorder,
        'rc-panel-addHeaderBorder': addHeaderBorder,
        'rc-panel-smallHeaderPadding': smallHeaderPadding,
        //FIXME
        'rc-panel-flexContent': flexContent,
        'rc-panel-noBottomOffset': cancelBottomOffset,
        'rc-panel-transparent': isTransparent
      }, className)
    }, props), this.props.children));
  };

  return Panel;
}(React.Component);

_defineProperty(Panel, "propTypes", {
  children: PropTypes.node,
  className: PropTypes.string,
  header: PropTypes.node,
  footer: PropTypes.node,
  testAutomationId: PropTypes.string,
  closable: PropTypes.bool,
  noPadding: PropTypes.bool,
  noHeaderPadding: PropTypes.bool,
  noBorder: PropTypes.bool,
  noLeftBorder: PropTypes.bool,
  noRightBorder: PropTypes.bool,
  cancelMinHeight: PropTypes.bool,
  smallHeaderPadding: PropTypes.bool,
  addHeaderBorder: PropTypes.bool,
  noHeaderBorder: PropTypes.bool,
  onClose: PropTypes.func,
  flexContent: PropTypes.bool,
  flexContainer: PropTypes.bool,
  isTransparent: PropTypes.bool,
  cancelBottomOffset: PropTypes.bool,
  closeLabel: PropTypes.string
});

_defineProperty(Panel, "defaultProps", {
  children: null,
  className: null,
  header: null,
  footer: null,
  testAutomationId: 'panel',
  closable: false,
  noPadding: false,
  noHeaderPadding: false,
  noBorder: false,
  noLeftBorder: false,
  noRightBorder: false,
  cancelMinHeight: false,
  smallHeaderPadding: false,
  addHeaderBorder: false,
  noHeaderBorder: false,
  onClose: null,
  flexContent: false,
  flexContainer: false,
  isTransparent: false,
  cancelBottomOffset: false,
  closeLabel: 'TRANSLATE:CLOSE'
});