'use strict';

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

var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

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

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

  function SidebarListItem() {
    (0, _classCallCheck3.default)(this, SidebarListItem);
    return (0, _possibleConstructorReturn3.default)(this, (SidebarListItem.__proto__ || (0, _getPrototypeOf2.default)(SidebarListItem)).apply(this, arguments));
  }

  (0, _createClass3.default)(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;