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';
var _jsxFileName = 'src/datePicker/panel/typeSelectPanel.jsx';
/**
 * typeSelectPanel.jsx
 *
 * @Author: apple
 * @Date: 2017/12/14 13:20
 */

import React from 'react';
import Icon from '../../icon';
import Button from '../../button';
import className from 'classnames';

/**
 * @ignore
 * */

var TypeSelectPanel = function (_React$PureComponent) {
    _inherits(TypeSelectPanel, _React$PureComponent);

    function TypeSelectPanel(props) {
        _classCallCheck(this, TypeSelectPanel);

        var _this = _possibleConstructorReturn(this, (TypeSelectPanel.__proto__ || Object.getPrototypeOf(TypeSelectPanel)).call(this, props));

        _this.onChangePanel = function (type) {
            var _this$props = _this.props,
                onChangePanel = _this$props.onChangePanel,
                actionArray = _this$props.actionArray;

            onChangePanel(actionArray[type]);
        };

        _this.pubsubEvent = {
            observerKey: _this.props.observerKey
        };
        _this.state = {
            currentDate: new Date(_this.props.currentTime)
        };
        return _this;
    }

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

            var _props = this.props,
                onChangeSelectType = _props.onChangeSelectType,
                actionArray = _props.actionArray,
                title = _props.title,
                selectType = _props.selectType,
                days = _props.days,
                prefixCls = _props.prefixCls;

            var headPrefixCls = prefixCls + '-head';
            var secondPrefixCls = prefixCls + '-second';
            return React.createElement(
                'div',
                { className: headPrefixCls, __source: {
                        fileName: _jsxFileName,
                        lineNumber: 36
                    },
                    __self: this
                },
                React.createElement(
                    'div',
                    { className: headPrefixCls + '-tr', __source: {
                            fileName: _jsxFileName,
                            lineNumber: 37
                        },
                        __self: this
                    },
                    React.createElement(
                        Button,
                        {
                            shape: 'none',
                            onClick: function onClick() {
                                return _this2.onChangePanel('prev');
                            },
                            ref: function ref(prevBtn) {
                                return _this2.prevBtn = prevBtn;
                            }, __source: {
                                fileName: _jsxFileName,
                                lineNumber: 38
                            },
                            __self: this
                        },
                        React.createElement(Icon, { type: 'left-arrow', __source: {
                                fileName: _jsxFileName,
                                lineNumber: 42
                            },
                            __self: this
                        })
                    ),
                    React.createElement(
                        'span',
                        {
                            className: headPrefixCls + '-tr-switch',
                            onClick: function onClick() {
                                return onChangeSelectType(actionArray.outPanel);
                            }, __source: {
                                fileName: _jsxFileName,
                                lineNumber: 44
                            },
                            __self: this
                        },
                        title
                    ),
                    React.createElement(
                        Button,
                        { shape: 'none', onClick: function onClick() {
                                return _this2.onChangePanel('next');
                            }, __source: {
                                fileName: _jsxFileName,
                                lineNumber: 49
                            },
                            __self: this
                        },
                        React.createElement(Icon, { type: 'right-arrow', __source: {
                                fileName: _jsxFileName,
                                lineNumber: 50
                            },
                            __self: this
                        })
                    )
                ),
                selectType === 'day' && React.createElement(
                    'div',
                    { className: secondPrefixCls + '-tr', __source: {
                            fileName: _jsxFileName,
                            lineNumber: 54
                        },
                        __self: this
                    },
                    days.map(function (item, index) {
                        return React.createElement(
                            'span',
                            { className: secondPrefixCls + '-tr-td', key: 'item-' + index, __source: {
                                    fileName: _jsxFileName,
                                    lineNumber: 57
                                },
                                __self: _this2
                            },
                            item
                        );
                    })
                )
            );
        }
    }]);

    return TypeSelectPanel;
}(React.PureComponent);

export default TypeSelectPanel;