'use strict';

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

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

require('./index.less');

var _catalogue = require('../catalogue');

var _catalogue2 = _interopRequireDefault(_catalogue);

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

var CategoryNavi = function (_React$Component) {
    (0, _inherits3['default'])(CategoryNavi, _React$Component);

    function CategoryNavi() {
        (0, _classCallCheck3['default'])(this, CategoryNavi);

        var _this = (0, _possibleConstructorReturn3['default'])(this, (CategoryNavi.__proto__ || Object.getPrototypeOf(CategoryNavi)).apply(this, arguments));

        _this.state = { show: false };
        _this.handleHover = function () {
            _this.setState({ show: true });
        };
        _this.clickItem = function (e, item) {
            e.stopPropagation();
            var naviClick = _this.props.naviClick;

            naviClick && naviClick(item);
        };
        return _this;
    }

    (0, _createClass3['default'])(CategoryNavi, [{
        key: 'render',
        value: function render() {
            var _this2 = this;

            var _props = this.props,
                firstCatalogNmae = _props.firstCatalogNmae,
                data = _props.data,
                navList = _props.navList;

            return _react2['default'].createElement(
                _react2['default'].Fragment,
                null,
                _react2['default'].createElement(
                    'div',
                    { className: 'cnav_content' },
                    _react2['default'].createElement(
                        'div',
                        { className: 'cnav_menu' },
                        _react2['default'].createElement(
                            'a',
                            { onMouseOver: function onMouseOver() {
                                    return _this2.handleHover();
                                } },
                            _react2['default'].createElement('span', { className: 'categoryIcon' }),
                            _react2['default'].createElement(
                                'span',
                                null,
                                firstCatalogNmae
                            )
                        ),
                        navList.map(function (v, i) {
                            return _react2['default'].createElement(
                                'a',
                                { key: i, onClick: function onClick(e) {
                                        return _this2.clickItem(e, v);
                                    } },
                                _react2['default'].createElement(
                                    'span',
                                    null,
                                    v.name
                                )
                            );
                        })
                    ),
                    this.state.show ? _react2['default'].createElement(_catalogue2['default'], { data: data, isShow: this.state.show, onChangeDisplay: function onChangeDisplay(shows) {
                            _this2.setState({ show: shows });
                        } }) : null
                )
            );
        }
    }]);
    return CategoryNavi;
}(_react2['default'].Component);

CategoryNavi.defaultProps = {
    firstCatalogNmae: 'All Category'
};
exports['default'] = CategoryNavi;
module.exports = exports['default'];