'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 _styledComponents = require('styled-components');

var _styledComponents2 = _interopRequireDefault(_styledComponents);

var _NewBadge = require('../NewBadge');

var _NewBadge2 = _interopRequireDefault(_NewBadge);

var _SidebarListItemContainer = require('./styles/SidebarListItemContainer');

var _SidebarListItemContainer2 = _interopRequireDefault(_SidebarListItemContainer);

var _SidebarListItemLabel = require('./styles/SidebarListItemLabel');

var _SidebarListItemLabel2 = _interopRequireDefault(_SidebarListItemLabel);

var _SidebarListItemDetails = require('./styles/SidebarListItemDetails');

var _SidebarListItemDetails2 = _interopRequireDefault(_SidebarListItemDetails);

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; }

/**
 * An element of a [SidebarList](/#!/SidebarList).
 */
var SidebarListItem = function (_React$PureComponent) {
  _inherits(SidebarListItem, _React$PureComponent);

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

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

  _createClass(SidebarListItem, [{
    key: 'render',
    value: function render() {
      var _props = this.props,
          label = _props.label,
          details = _props.details,
          active = _props.active,
          isNew = _props.isNew,
          id = _props.id,
          className = _props.className,
          Container = _props.Container,
          Label = _props.Label,
          Details = _props.Details;


      return _react2.default.createElement(
        Container,
        { active: active, className: className, id: id },
        _react2.default.createElement(
          Label,
          null,
          isNew ? _react2.default.createElement(_NewBadge2.default, null) : null,
          label
        ),
        _react2.default.createElement(
          Details,
          null,
          details
        )
      );
    }
  }]);

  return SidebarListItem;
}(_react2.default.PureComponent);

SidebarListItem.propTypes = {
  /**
   * The main details of the list item.
   */
  label: _propTypes2.default.string,
  /**
   * Extra details to render on another line.
   */
  details: _propTypes2.default.node,
  /**
   * Renders the item as the one currently selected.
   */
  active: _propTypes2.default.bool,
  /**
   * Adds a new badge to the list item.
   */
  isNew: _propTypes2.default.bool,
  /**
   * Adds a class name to the outer item element.
   */
  className: _propTypes2.default.string,
  /**
   * Adds an id to the outer item element.
   */
  id: _propTypes2.default.string,
  /**
   * A component for rendering a container of an item
   */
  Container: _propTypes2.default.func,
  /**
   * A component for rendering an item label
   */
  Label: _propTypes2.default.func,
  /**
   * A component for rendering the details container in the item
   */
  Details: _propTypes2.default.func
};
SidebarListItem.defaultProps = {
  label: null,
  details: null,
  active: false,
  isNew: false,
  className: null,
  id: null,
  Container: _SidebarListItemContainer2.default,
  Details: _SidebarListItemDetails2.default,
  Label: _SidebarListItemLabel2.default
};
exports.default = SidebarListItem;