'use strict';

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

exports.__esModule = true;
exports.Panel = 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 _propTypes = _interopRequireDefault(require("prop-types"));

var _Panel = _interopRequireDefault(require("react-bootstrap/lib/Panel"));

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

var _Button = require("./Button");

var _Icon = require("./Icon");

var Panel =
/*#__PURE__*/
function (_React$Component) {
  (0, _inheritsLoose2.default)(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.default.createElement(_Button.Button, {
        iconOnly: true,
        bsStyle: "link",
        className: "rc-panel-close-button",
        testAutomationId: "closeButton",
        onClick: this.props.onClose,
        "aria-label": this.props.closeLabel
      }, _react.default.createElement(_Icon.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 = (0, _objectWithoutPropertiesLoose2.default)(_this$props, ["onClose", "className", "closable", "closeLabel", "noPadding", "noHeaderPadding", "smallHeaderPadding", "cancelMinHeight", "noBorder", "noLeftBorder", "noRightBorder", "addHeaderBorder", "noHeaderBorder", "testAutomationId", "flexContent", "flexContainer", "cancelBottomOffset", "isTransparent"]);
    var containerClassName = (0, _classnames.default)('rc-panel', {
      'rc-panel-flexContainer': flexContainer
    });
    return _react.default.createElement("div", {
      className: containerClassName,
      "data-test-automation-id": testAutomationId
    }, this.getCloseButton(), _react.default.createElement(_Panel.default, (0, _extends2.default)({
      className: (0, _classnames.default)({
        '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.default.Component);

exports.Panel = Panel;
(0, _defineProperty2.default)(Panel, "propTypes", {
  children: _propTypes.default.node,
  className: _propTypes.default.string,
  header: _propTypes.default.node,
  footer: _propTypes.default.node,
  testAutomationId: _propTypes.default.string,
  closable: _propTypes.default.bool,
  noPadding: _propTypes.default.bool,
  noHeaderPadding: _propTypes.default.bool,
  noBorder: _propTypes.default.bool,
  noLeftBorder: _propTypes.default.bool,
  noRightBorder: _propTypes.default.bool,
  cancelMinHeight: _propTypes.default.bool,
  smallHeaderPadding: _propTypes.default.bool,
  addHeaderBorder: _propTypes.default.bool,
  noHeaderBorder: _propTypes.default.bool,
  onClose: _propTypes.default.func,
  flexContent: _propTypes.default.bool,
  flexContainer: _propTypes.default.bool,
  isTransparent: _propTypes.default.bool,
  cancelBottomOffset: _propTypes.default.bool,
  closeLabel: _propTypes.default.string
});
(0, _defineProperty2.default)(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'
});