import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import React from 'react';
import './index.less';
import Catalogue from '../catalogue';

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

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

        var _this = _possibleConstructorReturn(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;
    }

    _createClass(CategoryNavi, [{
        key: 'render',
        value: function render() {
            var _this2 = this;

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

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

    return CategoryNavi;
}(React.Component);

CategoryNavi.defaultProps = {
    firstCatalogNmae: 'All Category'
};
export default CategoryNavi;