'use strict';

exports.__esModule = true;

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

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

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

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

/**
 * DropdownMenu is component for rendering dropdown menu
 * @param props
 * @returns {XML}
 * @constructor
 */

var DropdownMenu = function (_React$Component) {
  (0, _inherits3.default)(DropdownMenu, _React$Component);

  function DropdownMenu() {
    (0, _classCallCheck3.default)(this, DropdownMenu);
    return (0, _possibleConstructorReturn3.default)(this, _React$Component.apply(this, arguments));
  }

  DropdownMenu.prototype.render = function render() {
    var _this2 = this;

    var _props = this.props,
        isNested = _props.isNested,
        children = _props.children;
    var _context = this.context,
        isOpen = _context.isOpen,
        visibleClass = _context.visibleClass;


    return _react2.default.createElement(
      'div',
      {
        className: 'cui-list' + ('' + (isNested ? ' nested' : '')) + ('' + (isOpen ? ' visible' : '')) + (' ' + visibleClass),
        ref: function ref(_ref) {
          return _this2.menu = _ref;
        },
        role: 'menu'
      },
      children
    );
  };

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

DropdownMenu.displayName = 'DropdownMenu';
exports.default = DropdownMenu;


DropdownMenu.contextTypes = {
  /** optional isOpen prop type */
  isOpen: _propTypes2.default.bool,
  /** optional visibleClass prop type */
  visibleClass: _propTypes2.default.string
};

DropdownMenu.defaultProps = {
  isOpen: false,
  visibleClass: '',
  isNested: false,
  children: null
};
module.exports = exports['default'];