import _defineProperty from 'babel-runtime/helpers/defineProperty';
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/DatePicker.jsx';
import React from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';
import Input from '../input';
import DtItem from './dateItem';
import Tooltip from '../tooltip';
import Icon from '../icon';
import classNames from 'classnames';
import { isFunction } from '../util/isType';

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

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

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

        _initialiseProps.call(_this);

        var _this$props = _this.props,
            defaultValue = _this$props.defaultValue,
            format = _this$props.format,
            type = _this$props.type;

        defaultValue = defaultValue !== '' ? defaultValue : void 0;
        var onlyTimeValue = void 0;
        var beginTimeValue = void 0;
        var endTimeValue = void 0;
        _this.datePickerKey = 'datePicker-' + Math.random();
        if (type === 'date') {
            onlyTimeValue = defaultValue && moment(defaultValue).format(format);
        } else {
            beginTimeValue = defaultValue && defaultValue[0] && moment(defaultValue[0] !== '' ? defaultValue[0] : void 0).format(format);
            endTimeValue = defaultValue && defaultValue[1] && moment(defaultValue[1] !== '' ? defaultValue[1] : void 0).format(format);
        }
        _this.state = {
            displayPicker: false,
            beginPicker: false,
            endPicker: false,
            onlyTimeValue: onlyTimeValue,
            beginTimeValue: beginTimeValue,
            endTimeValue: endTimeValue
        };
        return _this;
    }

    _createClass(DatePicker, [{
        key: 'componentWillReceiveProps',
        value: function componentWillReceiveProps(props) {
            var defaultValue = props.defaultValue,
                type = props.type;
            var _state = this.state,
                beginTimeValue = _state.beginTimeValue,
                endTimeValue = _state.endTimeValue,
                onlyTimeValue = _state.onlyTimeValue;

            if (defaultValue !== this.props.defaultValue) {
                if (type === 'date') {
                    if (onlyTimeValue !== defaultValue) {
                        this.setState({
                            onlyTimeValue: defaultValue
                        });
                    }
                } else {
                    if (beginTimeValue !== defaultValue[0] || endTimeValue !== defaultValue[1]) {
                        this.setState({
                            beginTimeValue: defaultValue[0],
                            endTimeValue: defaultValue[1]
                        });
                    }
                }
            }
        }
    }, {
        key: 'shouldComponentUpdate',
        value: function shouldComponentUpdate(nextProps, nextStates) {
            var defaultValue = this.props.defaultValue;

            var boolProps = false;
            if (Array.isArray(defaultValue)) {
                boolProps = defaultValue[0] !== nextProps.defaultValue[0] || defaultValue[1] !== nextProps.defaultValue[1];
            } else {
                boolProps = defaultValue !== nextProps.defaultValue;
            }
            var _state2 = this.state,
                beginTimeValue = _state2.beginTimeValue,
                endTimeValue = _state2.endTimeValue,
                onlyTimeValue = _state2.onlyTimeValue,
                onActive = _state2.onActive,
                beginActive = _state2.beginActive,
                endActive = _state2.endActive;

            var boolState = false;
            if (beginTimeValue !== nextStates.beginTimeValue || endTimeValue !== nextStates.endTimeValue || onlyTimeValue !== nextStates.onlyTimeValue || onActive !== nextStates.onActive || beginActive !== nextStates.beginActive || endActive !== nextStates.endActive) {
                boolState = true;
            } else {
                boolState = false;
            }
            return boolProps || boolState;
        }
    }, {
        key: 'componentDidUpdate',
        value: function componentDidUpdate(prevProps, prevState) {
            var _props = this.props,
                type = _props.type,
                onChange = _props.onChange;
            var _state3 = this.state,
                beginTimeValue = _state3.beginTimeValue,
                endTimeValue = _state3.endTimeValue,
                onlyTimeValue = _state3.onlyTimeValue;

            if (prevState.beginTimeValue !== beginTimeValue || prevState.endTimeValue !== endTimeValue || prevState.onlyTimeValue !== onlyTimeValue) {
                var switchType = type === 'date-range-whole' ? 'date-range-unity' : type;
                switch (switchType) {
                    case 'date-range':
                        onChange([beginTimeValue, endTimeValue]);
                        break;
                    case 'date-range-unity':
                        onChange([beginTimeValue, endTimeValue]);
                        break;
                    default:
                        onChange(onlyTimeValue);
                        break;
                }
            }
        }
    }, {
        key: 'render',
        value: function render() {
            var _this2 = this;

            var _props2 = this.props,
                prefixCls = _props2.prefixCls,
                dateRangeStyle = _props2.dateRangeStyle,
                type = _props2.type,
                format = _props2.format,
                separator = _props2.separator,
                selectType = _props2.selectType,
                readOnly = _props2.readOnly,
                disabled = _props2.disabled,
                showTime = _props2.showTime,
                inputClass = _props2.inputClass,
                disabledBeforeDate = _props2.disabledBeforeDate,
                disabledAfterDate = _props2.disabledAfterDate,
                inputPrefix = _props2.inputPrefix,
                dateClassName = _props2.dateClassName,
                tipPosition = _props2.tipPosition,
                beginInputClass = _props2.beginInputClass,
                endInputClass = _props2.endInputClass,
                beginInputPrefix = _props2.beginInputPrefix,
                endInputPrefix = _props2.endInputPrefix,
                inputProps = _props2.inputProps,
                dateRangeWholeStyle = _props2.dateRangeWholeStyle,
                convenientRange = _props2.convenientRange,
                inputSize = _props2.inputSize,
                local = _props2.local,
                clearable = _props2.clearable,
                clearInfo = _props2.clearInfo,
                disableTime = _props2.disableTime,
                disableExquisiteTimeRules = _props2.disableExquisiteTimeRules;

            if (Array.isArray(inputProps)) {
                inputProps.forEach(function (item) {
                    item.readOnly = readOnly;
                });
            } else {
                inputProps.readOnly = readOnly;
            }
            var _state4 = this.state,
                onlyTimeValue = _state4.onlyTimeValue,
                beginTimeValue = _state4.beginTimeValue,
                endTimeValue = _state4.endTimeValue,
                dateRangeOpen = _state4.dateRangeOpen,
                onActive = _state4.onActive,
                beginActive = _state4.beginActive,
                endActive = _state4.endActive;

            var clearBtn = function clearBtn(dateItemType) {
                if (clearInfo || clearable) {
                    var bool = false;
                    if (type === 'date-range') {
                        if (dateItemType === 'begin' && beginActive) {
                            bool = true;
                        } else if (dateItemType === 'end' && endActive) {
                            bool = true;
                        }
                    } else {
                        bool = onActive;
                    }
                    return bool && React.createElement(Icon, {
                        onClick: function onClick(e) {
                            return _this2.clearDateInfo(e, dateItemType);
                        },
                        style: { position: 'absolute', right: 0, color: '#ddd' },
                        type: 'cancel-o',
                        __source: {
                            fileName: _jsxFileName,
                            lineNumber: 398
                        },
                        __self: _this2
                    });
                }
            };
            if (onlyTimeValue && !moment(onlyTimeValue).isValid() || beginTimeValue && !moment(beginTimeValue).isValid() || endTimeValue && !moment(endTimeValue).isValid()) {
                return React.createElement(
                    'div',
                    {
                        __source: {
                            fileName: _jsxFileName,
                            lineNumber: 412
                        },
                        __self: this
                    },
                    '\u6240\u4F20\u65F6\u95F4\u53C2\u6570\u4E0D\u5408\u6CD5\uFF01'
                );
            }
            // todo 兼容旧类型date-range-whole，正式版本后移除
            var switchType = type === 'date-range-whole' ? 'date-range-unity' : type;
            var prefixClsDatePicker = prefixCls + '-datePicker';
            var singleDisableExquisiteTimeRules = null;
            var beginDisableExquisiteTimeRules = null;
            var endDisableExquisiteTimeRules = null;
            switch (switchType) {
                // 单个时间容器选择
                case 'date':
                    if (disableExquisiteTimeRules) {
                        singleDisableExquisiteTimeRules = disableExquisiteTimeRules.singleTime;
                    }
                    return React.createElement(
                        'div',
                        { className: prefixClsDatePicker, __source: {
                                fileName: _jsxFileName,
                                lineNumber: 427
                            },
                            __self: this
                        },
                        React.createElement(
                            Tooltip,
                            {
                                position: tipPosition,
                                trigger: 'click',
                                className: 'dp-panel',
                                content: React.createElement(
                                    'div',
                                    {
                                        className: prefixClsDatePicker + '-input-item',
                                        onMouseEnter: function onMouseEnter() {
                                            return _this2.onActive(true);
                                        },
                                        onMouseLeave: function onMouseLeave() {
                                            return _this2.onActive(false);
                                        }, __source: {
                                            fileName: _jsxFileName,
                                            lineNumber: 433
                                        },
                                        __self: this
                                    },
                                    React.createElement(Input, {
                                        defaultValue: onlyTimeValue,
                                        disabled: disabled,
                                        readOnly: readOnly,
                                        style: { flex: 1 },
                                        className: inputClass,
                                        prefix: inputPrefix,
                                        size: inputSize,
                                        inputProps: Array.isArray(inputProps) ? inputProps[0] : inputProps,
                                        __source: {
                                            fileName: _jsxFileName,
                                            lineNumber: 437
                                        },
                                        __self: this
                                    }),
                                    clearBtn()
                                ), __source: {
                                    fileName: _jsxFileName,
                                    lineNumber: 428
                                },
                                __self: this
                            },
                            React.createElement(DtItem, {
                                type: 'date',
                                local: local,
                                selectType: selectType,
                                currentTime: onlyTimeValue,
                                prefixCls: prefixClsDatePicker,
                                className: dateClassName,
                                format: format,
                                dateClassName: dateClassName,
                                onChange: this.onChange,
                                showTime: showTime,
                                disableTime: disableTime,
                                disabledBeforeDate: disabledBeforeDate,
                                disableExquisiteTimeRules: singleDisableExquisiteTimeRules,
                                __source: {
                                    fileName: _jsxFileName,
                                    lineNumber: 450
                                },
                                __self: this
                            })
                        )
                    );
                case 'date-range':
                    // 范围时间选择，两个容器
                    if (disableExquisiteTimeRules) {
                        beginDisableExquisiteTimeRules = disableExquisiteTimeRules.beginTime;
                        endDisableExquisiteTimeRules = disableExquisiteTimeRules.endTime;
                    }
                    return React.createElement(
                        'div',
                        { className: prefixClsDatePicker, style: dateRangeStyle, __source: {
                                fileName: _jsxFileName,
                                lineNumber: 475
                            },
                            __self: this
                        },
                        React.createElement(
                            Tooltip,
                            {
                                position: 'bottomLeft',
                                trigger: 'click',
                                className: 'dt-item',
                                content: React.createElement(
                                    'div',
                                    {
                                        className: prefixCls + '-datePicker-input-item',
                                        onMouseEnter: function onMouseEnter() {
                                            return _this2.onActive(true, 'beginActive');
                                        },
                                        onMouseLeave: function onMouseLeave() {
                                            return _this2.onActive(false, 'beginActive');
                                        }, __source: {
                                            fileName: _jsxFileName,
                                            lineNumber: 481
                                        },
                                        __self: this
                                    },
                                    React.createElement(Input, {
                                        defaultValue: beginTimeValue,
                                        readOnly: readOnly,
                                        inputProps: Array.isArray(inputProps) ? inputProps[0] : inputProps,
                                        disabled: disabled,
                                        className: inputClass,
                                        prefix: inputPrefix,
                                        size: inputSize,
                                        __source: {
                                            fileName: _jsxFileName,
                                            lineNumber: 485
                                        },
                                        __self: this
                                    }),
                                    clearBtn('begin')
                                ), __source: {
                                    fileName: _jsxFileName,
                                    lineNumber: 476
                                },
                                __self: this
                            },
                            React.createElement(DtItem, {
                                type: 'date-range-begin',
                                local: local,
                                selectType: selectType,
                                beginTime: beginTimeValue,
                                endTime: endTimeValue,
                                datePickerType: type,
                                format: format,
                                prefixCls: prefixClsDatePicker,
                                className: dateClassName,
                                onChange: this.onChange,
                                showTime: showTime,
                                currentTime: beginTimeValue,
                                disabledBeforeDate: disabledBeforeDate,
                                disableTime: disableTime,
                                disableExquisiteTimeRules: beginDisableExquisiteTimeRules,
                                __source: {
                                    fileName: _jsxFileName,
                                    lineNumber: 497
                                },
                                __self: this
                            })
                        ),
                        React.createElement(
                            'span',
                            { className: prefixClsDatePicker + '-separator', __source: {
                                    fileName: _jsxFileName,
                                    lineNumber: 515
                                },
                                __self: this
                            },
                            isFunction(separator) ? separator() : separator
                        ),
                        React.createElement(
                            Tooltip,
                            {
                                position: 'bottomRight',
                                trigger: 'click',
                                className: 'dt-item',
                                content: React.createElement(
                                    'div',
                                    {
                                        className: prefixCls + '-datePicker-input-item',
                                        onMouseEnter: function onMouseEnter() {
                                            return _this2.onActive(true, 'endActive');
                                        },
                                        onMouseLeave: function onMouseLeave() {
                                            return _this2.onActive(false, 'endActive');
                                        }, __source: {
                                            fileName: _jsxFileName,
                                            lineNumber: 523
                                        },
                                        __self: this
                                    },
                                    React.createElement(Input, {
                                        defaultValue: endTimeValue,
                                        inputProps: Array.isArray(inputProps) ? inputProps[1] : inputProps,
                                        disabled: disabled,
                                        className: inputClass,
                                        prefix: inputPrefix,
                                        size: inputSize,
                                        __source: {
                                            fileName: _jsxFileName,
                                            lineNumber: 527
                                        },
                                        __self: this
                                    }),
                                    clearBtn('end')
                                ), __source: {
                                    fileName: _jsxFileName,
                                    lineNumber: 518
                                },
                                __self: this
                            },
                            React.createElement(DtItem, {
                                type: 'date-range-end',
                                local: local,
                                selectType: selectType,
                                beginTime: beginTimeValue,
                                endTime: endTimeValue,
                                datePickerType: type,
                                format: format,
                                prefixCls: prefixClsDatePicker,
                                className: dateClassName,
                                onChange: this.onChange,
                                showTime: showTime,
                                currentTime: endTimeValue,
                                disabledAfterDate: disabledAfterDate,
                                disableTime: disableTime,
                                disableExquisiteTimeRules: endDisableExquisiteTimeRules,
                                __source: {
                                    fileName: _jsxFileName,
                                    lineNumber: 538
                                },
                                __self: this
                            })
                        )
                    );
                case 'date-range-unity':
                    // 范围时间选择，两个容器合为一个
                    var prefixClsDatePickerUnity = prefixClsDatePicker + '-unity-inputs';
                    var clsDatePickerUnityFocus = prefixClsDatePickerUnity + '-focus';
                    var clsDatePickerUnityItem = prefixClsDatePickerUnity + '-item';
                    var dprInputsClass = classNames(prefixClsDatePickerUnity, _defineProperty({}, clsDatePickerUnityFocus, dateRangeOpen));
                    var beginInputsClass = classNames(clsDatePickerUnityItem, beginInputClass);
                    var endInputsClass = classNames(clsDatePickerUnityItem, endInputClass);
                    var prefixSlideCls = prefixClsDatePicker + '-panel-slide-bar';
                    if (disableExquisiteTimeRules) {
                        beginDisableExquisiteTimeRules = disableExquisiteTimeRules.beginTime;
                        endDisableExquisiteTimeRules = disableExquisiteTimeRules.endTime;
                    }
                    return React.createElement(
                        'div',
                        { className: prefixClsDatePicker, __source: {
                                fileName: _jsxFileName,
                                lineNumber: 572
                            },
                            __self: this
                        },
                        React.createElement(
                            Tooltip,
                            {
                                position: tipPosition,
                                trigger: 'click',
                                className: 'dp-panel',
                                content: React.createElement(
                                    'div',
                                    {
                                        className: dprInputsClass,
                                        style: dateRangeWholeStyle,
                                        onMouseEnter: function onMouseEnter() {
                                            return _this2.onActive(true);
                                        },
                                        onMouseLeave: function onMouseLeave() {
                                            return _this2.onActive(false);
                                        }, __source: {
                                            fileName: _jsxFileName,
                                            lineNumber: 578
                                        },
                                        __self: this
                                    },
                                    React.createElement(Input, {
                                        defaultValue: beginTimeValue,
                                        inputProps: Array.isArray(inputProps) ? inputProps[0] : inputProps,
                                        disabled: disabled,
                                        className: beginInputsClass,
                                        prefix: beginInputPrefix,
                                        size: inputSize,
                                        __source: {
                                            fileName: _jsxFileName,
                                            lineNumber: 583
                                        },
                                        __self: this
                                    }),
                                    React.createElement(
                                        'span',
                                        { className: prefixClsDatePicker + '-separator', __source: {
                                                fileName: _jsxFileName,
                                                lineNumber: 591
                                            },
                                            __self: this
                                        },
                                        isFunction(separator) ? separator() : separator
                                    ),
                                    React.createElement(Input, {
                                        defaultValue: endTimeValue,
                                        inputProps: Array.isArray(inputProps) ? inputProps[1] : inputProps,
                                        disabled: disabled,
                                        className: endInputsClass + ' ' + clsDatePickerUnityItem + '-end',
                                        prefix: endInputPrefix,
                                        size: inputSize,
                                        __source: {
                                            fileName: _jsxFileName,
                                            lineNumber: 594
                                        },
                                        __self: this
                                    }),
                                    clearBtn()
                                ), __source: {
                                    fileName: _jsxFileName,
                                    lineNumber: 573
                                },
                                __self: this
                            },
                            React.createElement(
                                'div',
                                { className: prefixClsDatePicker + '-panel', __source: {
                                        fileName: _jsxFileName,
                                        lineNumber: 605
                                    },
                                    __self: this
                                },
                                convenientRange && React.createElement(
                                    'ul',
                                    {
                                        className: classNames(prefixSlideCls, {
                                            'overflow-scroll': convenientRange.length >= 12
                                        }), __source: {
                                            fileName: _jsxFileName,
                                            lineNumber: 607
                                        },
                                        __self: this
                                    },
                                    convenientRange.map(function (item) {
                                        var label = item.label,
                                            range = item.range;
                                        var selectRangeBar = _this2.state.selectRangeBar;

                                        var slideLiCls = prefixSlideCls + '-li';
                                        if (selectRangeBar === label) {
                                            slideLiCls += ' ' + prefixSlideCls + '-selected';
                                        }
                                        return React.createElement(
                                            'li',
                                            {
                                                key: label,
                                                onClick: function onClick() {
                                                    return _this2.handleSelectRange(range, label);
                                                },
                                                className: slideLiCls, __source: {
                                                    fileName: _jsxFileName,
                                                    lineNumber: 619
                                                },
                                                __self: _this2
                                            },
                                            label
                                        );
                                    })
                                ),
                                React.createElement(DtItem, {
                                    type: 'date-range-begin',
                                    local: local,
                                    switchType: switchType,
                                    datePickerKey: this.datePickerKey,
                                    selectType: selectType,
                                    beginTime: beginTimeValue,
                                    endTime: endTimeValue,
                                    datePickerType: type,
                                    format: format,
                                    prefixCls: prefixClsDatePicker,
                                    className: dateClassName,
                                    onChange: this.onChange,
                                    showTime: showTime,
                                    currentTime: beginTimeValue,
                                    disabledBeforeDate: disabledBeforeDate,
                                    disableTime: disableTime,
                                    disableExquisiteTimeRules: beginDisableExquisiteTimeRules,
                                    __source: {
                                        fileName: _jsxFileName,
                                        lineNumber: 629
                                    },
                                    __self: this
                                }),
                                React.createElement(DtItem, {
                                    type: 'date-range-end',
                                    local: local,
                                    switchType: switchType,
                                    datePickerKey: this.datePickerKey,
                                    selectType: selectType,
                                    beginTime: beginTimeValue,
                                    endTime: endTimeValue,
                                    datePickerType: type,
                                    format: format,
                                    prefixCls: prefixClsDatePicker,
                                    className: dateClassName,
                                    onChange: this.onChange,
                                    showTime: showTime,
                                    currentTime: endTimeValue,
                                    disabledAfterDate: disabledAfterDate,
                                    disableTime: disableTime,
                                    disableExquisiteTimeRules: endDisableExquisiteTimeRules,
                                    __source: {
                                        fileName: _jsxFileName,
                                        lineNumber: 648
                                    },
                                    __self: this
                                })
                            )
                        )
                    );
                default:
                    return React.createElement(
                        'span',
                        {
                            __source: {
                                fileName: _jsxFileName,
                                lineNumber: 672
                            },
                            __self: this
                        },
                        '\u8BF7\u9009\u62E9\u5408\u9002\u7684\u65F6\u95F4\u7EC4\u4EF6\u7C7B\u578B\uFF01'
                    );
            }
        }
    }]);

    return DatePicker;
}(React.Component);

DatePicker.propTypes = {
    /**
     * @ignore
     * */
    readOnly: PropTypes.bool,
    /**
     * 是否禁用，true：禁用，false：不禁用，禁用状态无法选择时间
     * */
    disabled: PropTypes.bool,
    /**
     * 是否开启清除整个选择框时间功能，true为开启，false为不开启
     * */
    clearable: PropTypes.bool,
    /**
     * 所传组件类型，目前支持三种类型，分别为date（单控件）、date-range（双控件，选择范围）、date-range-unity（整体单控件、选择范围）
     * */
    type: PropTypes.string,
    /**
     * 当所传控件类型为date（单控件）时候，传递时间默认值，可以传字符串（如2018-01-01）、数字（毫秒数）、date（new Date）
     * */
    defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.instanceOf(Date), PropTypes.array]),
    /**
     * input输入框的类名
     * */
    inputClass: PropTypes.string,
    /**
     * 选择时间后返回的时间格式，可以参考moment.js
     * */
    format: PropTypes.string,
    /**
     * 改变时间之后的回调函数
     * */
    onChange: PropTypes.func,
    /**
     * 时间格式化之后的回调函数，可以将格式化后的时间处理成需要的特殊格式
     * */
    onFormatDate: PropTypes.func,
    /**
     * 时间控件显示，true为显示，false为不显示
     * */
    showTime: PropTypes.bool,
    /**
     * 设置禁用时间，所传递的参数之前的时间均会被禁用
     * @deprecated since version 2.0
     * */
    disabledBeforeDate: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.instanceOf(Date)]),
    /**
     * 设置禁用时间，所传递的参数之后的时间均会被禁用
     * @deprecated since version 2.0
     * */
    disabledAfterDate: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.instanceOf(Date)]),
    /**
     * 设置禁用时间
     * @param {Date} date - 传递组件所渲染的选项时间
     * @returns {bool} - 返回true为禁用,false为不禁用
     * */
    disableTime: PropTypes.func,
    /**
     * 设置日期面板的弹出位置
     * */
    tipPosition: PropTypes.string,
    /**
     * 当所传控件类型为date-range（双控件） 或者 date-range-whole（整体单控件、选择范围）时候，传递开始时间input组件的类名
     * */
    beginInputClass: PropTypes.string,
    /**
     * 当所传控件类型为date-range（双控件） 或者 date-range-whole（整体单控件、选择范围）时候，传递结束时间input组件的类名
     * */
    endInputClass: PropTypes.string,
    /**
     * 当所传控件类型为date-range（双控件） 或者 date-range-whole（整体单控件、选择范围）时候，传递中间连接符
     * */
    separator: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
    /**
     * 组件类名
     * */
    className: PropTypes.string,
    /**
     * 当所传控件类型为date-range（双控件） 或者 date-range-whole（整体单控件、选择范围）时候，传递开始日期input前的icon
     * */
    beginInputPrefix: PropTypes.object,
    /**
     * 当所传控件类型为date-range（双控件） 或者 date-range-whole（整体单控件、选择范围）时候，传递结束日期input前的icon
     * */
    endInputPrefix: PropTypes.object,
    /**
     * 组件类名前缀
     * */
    prefixCls: PropTypes.string,
    /**
     * input组件的一些属性设置
     * */
    inputProps: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
    /**
     * 快捷范围选择
     * */
    convenientRange: PropTypes.array,
    /**
     * input 尺寸
     * */
    inputSize: PropTypes.string,
    /**
     * 国际化 zh中文 en英文
     * */
    local: PropTypes.string,
    /**
     * @ignore
     * */
    clearInfo: PropTypes.bool,
    /**
     * 禁用小时、分钟、秒
     * */
    disableExquisiteTimeRules: PropTypes.object
};
DatePicker.defaultProps = {
    type: 'date',
    readOnly: true,
    disabled: false,
    format: 'YYYY-MM-DD',
    clearable: false,
    clearInfo: false,
    onChange: function onChange(obj) {
        return console.log(obj);
    },
    onFormatDate: function onFormatDate(date) {
        return date;
    },
    separator: '-',
    inputClass: 'ne-dpr-input-item',
    selectType: 'select-day',
    className: '',
    showTime: false,
    disabledAfterDate: '9099-01-01 00:00:00', // 这个年份之后应该没人用了
    disabledBeforeDate: '0001-01-01 00:00:00', // 这个年份之前也够呛
    prefixCls: 'ne',
    inputProps: [],
    tipPosition: 'bottomLeft',
    local: 'zh',
    beginInputPrefix: React.createElement(Icon, { type: 'date', __source: {
            fileName: _jsxFileName,
            lineNumber: 151
        },
        __self: this
    })
};

var _initialiseProps = function _initialiseProps() {
    var _this3 = this;

    this.onChange = function (type, time) {
        var onFormatDate = _this3.props.onFormatDate;

        var formatTime = onFormatDate(time);
        if (_this3.props.type === 'date-range-whole' || _this3.props.type === 'date-range-unity') {
            switch (type) {
                case 'date-range-begin':
                    _this3.setState({
                        beginTimeValue: formatTime
                    });
                    return;
                case 'date-range-end':
                    _this3.setState({
                        endTimeValue: formatTime
                    });
                    return;
                default:
                    return;
            }
        } else {
            switch (type) {
                case 'date-range-begin':
                    _this3.setState({
                        beginTimeValue: formatTime
                    });
                    break;
                case 'date-range-end':
                    _this3.setState({
                        endTimeValue: formatTime
                    });
                    break;
                case 'date':
                    _this3.setState({
                        onlyTimeValue: formatTime
                    });
                    break;
                default:
                    return;
            }
        }
    };

    this.clearDateInfo = function (e, dateItemType) {
        e && e.stopPropagation();
        var type = _this3.props.type;

        if (type === 'date-range') {
            if (dateItemType === 'begin') {
                _this3.setState({
                    beginTimeValue: ''
                });
            } else if (dateItemType === 'end') {
                _this3.setState({
                    endTimeValue: ''
                });
            }
        } else {
            _this3.setState({
                beginTimeValue: '',
                endTimeValue: '',
                onlyTimeValue: ''
            });
        }
    };

    this.handleSelectRange = function (range, label) {
        var format = _this3.props.format;

        _this3.setState({
            selectRangeBar: label,
            beginTimeValue: moment(range[0]).format(format),
            endTimeValue: moment(range[1]).format(format)
        });
    };

    this.onActive = function (bool, type) {
        if (type) {
            _this3.setState(_defineProperty({}, type, bool));
        } else {
            _this3.setState({
                onActive: bool
            });
        }
    };
};

export default DatePicker;