'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _PaneSectionContent = require('./styles/PaneSectionContent');

var _PaneSectionContent2 = _interopRequireDefault(_PaneSectionContent);

var _PaneSectionTitle = require('./styles/PaneSectionTitle');

var _PaneSectionTitle2 = _interopRequireDefault(_PaneSectionTitle);

var _PaneSectionWrap = require('./styles/PaneSectionWrap');

var _PaneSectionWrap2 = _interopRequireDefault(_PaneSectionWrap);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var PaneSection = function (_React$Component) {
  _inherits(PaneSection, _React$Component);

  function PaneSection() {
    _classCallCheck(this, PaneSection);

    return _possibleConstructorReturn(this, (PaneSection.__proto__ || Object.getPrototypeOf(PaneSection)).apply(this, arguments));
  }

  _createClass(PaneSection, [{
    key: 'render',
    value: function render() {
      var _props = this.props,
          title = _props.title,
          children = _props.children,
          id = _props.id,
          className = _props.className,
          Wrap = _props.Wrap,
          Title = _props.Title,
          Content = _props.Content;

      return _react2.default.createElement(
        Wrap,
        { id: id, className: className },
        title ? _react2.default.createElement(
          Title,
          null,
          title
        ) : null,
        _react2.default.createElement(
          Content,
          null,
          children
        )
      );
    }
  }]);

  return PaneSection;
}(_react2.default.Component);

PaneSection.propTypes = {
  /**
   * Optional title for the top of the pane section.
   */
  title: _propTypes2.default.string,
  /**
   * Pane section contents.
   */
  children: _propTypes2.default.node.isRequired,
  /**
   * Adds an id to the section.
   */
  id: _propTypes2.default.string,
  /**
   * Adds a class name to the section.
   */
  className: _propTypes2.default.string,
  /**
   * A component to render the content of the pane section
   */
  Content: _propTypes2.default.func,
  /**
   * A component to render the title of the pane section
   */
  Title: _propTypes2.default.func,
  /**
   * A component to render the outer wrapper of the pane section
   */
  Wrap: _propTypes2.default.func
};
PaneSection.defaultProps = {
  title: null,
  id: null,
  className: null,
  Content: _PaneSectionContent2.default,
  Title: _PaneSectionTitle2.default,
  Wrap: _PaneSectionWrap2.default
};
exports.default = PaneSection;