var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import ConfigProvider from '../config-provider';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import cls from 'classnames';
import { DatePicker as NextDatePicker } from '@alifd/next';
import { getTheme } from '../utils/getTheme';
class BdesignRangePicker extends Component {
    constructor() {
        super(...arguments);
        this.onFocus = (e) => {
            const { prefix = 'next-' } = this.props;
            const dom = e.target;
            dom.parentNode.parentElement.classList.add(`${prefix}range-date-picker-focus`);
            if (this.props.onFocus) {
                return this.onFocus(e) && this.props.onFocus;
            }
        };
        this.onBlur = (e) => {
            const { prefix = 'next-' } = this.props;
            const dom = e.target;
            dom.parentNode.parentElement.classList.remove(`${prefix}range-date-picker-focus`);
            if (this.props.onBlur) {
                return this.onBlur(e) && this.props.onBlur;
            }
        };
    }
    render() {
        const _a = this.props, { prefix = 'next-', popupAlign = 'bl tl', className, size = 'medium', popupClassName = '' } = _a, otherProps = __rest(_a, ["prefix", "popupAlign", "className", "size", "popupClassName"]);
        const theme = getTheme(this.context, this.props);
        const { RangePicker } = NextDatePicker;
        return (React.createElement(RangePicker, Object.assign({}, otherProps, { size: size, prefix: prefix, onFocus: this.onFocus, onBlur: this.onBlur, popupClassName: `${prefix}${theme} ${popupClassName}`, popupAlign: popupAlign, className: cls(className, {
                [`${prefix}small`]: size === 'small',
                [`${prefix}medium`]: size === 'medium',
                [`${prefix}large`]: size === 'large',
                [`${prefix}grey`]: theme === 'grey',
                [`${prefix}white`]: theme === 'white',
            }) })));
    }
}
// contextTypes
BdesignRangePicker.contextTypes = {
    theme: PropTypes.string,
};
class BdesignMonthPicker extends Component {
    render() {
        const _a = this.props, { prefix = 'next-', popupAlign = 'bl tl', className, size = 'medium', popupClassName = '' } = _a, otherProps = __rest(_a, ["prefix", "popupAlign", "className", "size", "popupClassName"]);
        const { MonthPicker } = NextDatePicker;
        const theme = getTheme(this.context, this.props);
        return (React.createElement(MonthPicker, Object.assign({}, otherProps, { size: size, prefix: prefix, popupClassName: `${prefix}${theme} ${popupClassName}`, popupAlign: popupAlign, className: cls(className, {
                [`${prefix}small`]: size === 'small',
                [`${prefix}medium`]: size === 'medium',
                [`${prefix}large`]: size === 'large',
                [`${prefix}grey`]: theme === 'grey',
                [`${prefix}white`]: theme === 'white',
            }) })));
    }
}
// contextTypes
BdesignMonthPicker.contextTypes = {
    theme: PropTypes.string,
};
class BdesignYearPicker extends Component {
    render() {
        const _a = this.props, { prefix = 'next-', popupAlign = 'bl tl', className, popupClassName = '', size = 'medium' } = _a, otherProps = __rest(_a, ["prefix", "popupAlign", "className", "popupClassName", "size"]);
        const { YearPicker } = NextDatePicker;
        const theme = getTheme(this.context, this.props);
        return (React.createElement(YearPicker, Object.assign({}, otherProps, { size: size, prefix: prefix, popupClassName: `${prefix}${theme} ${popupClassName}`, popupAlign: popupAlign, className: cls(className, {
                [`${prefix}small`]: size === 'small',
                [`${prefix}medium`]: size === 'medium',
                [`${prefix}large`]: size === 'large',
                [`${prefix}grey`]: theme === 'grey',
                [`${prefix}white`]: theme === 'white',
            }) })));
    }
}
// contextTypes
BdesignYearPicker.contextTypes = {
    theme: PropTypes.string,
};
class BdesignWeekPicker extends Component {
    render() {
        const _a = this.props, { prefix = 'next-', popupAlign = 'bl tl', className, size = 'medium', popupClassName = '' } = _a, otherProps = __rest(_a, ["prefix", "popupAlign", "className", "size", "popupClassName"]);
        const { WeekPicker } = NextDatePicker;
        const theme = getTheme(this.context, this.props);
        return (React.createElement(WeekPicker, Object.assign({}, otherProps, { prefix: prefix, size: size, popupAlign: popupAlign, popupClassName: `${prefix}${theme} ${popupClassName}`, className: cls(className, {
                [`${prefix}small`]: size === 'small',
                [`${prefix}medium`]: size === 'medium',
                [`${prefix}large`]: size === 'large',
                [`${prefix}grey`]: theme === 'grey',
                [`${prefix}white`]: theme === 'white',
            }) })));
    }
}
// contextTypes
BdesignWeekPicker.contextTypes = {
    theme: PropTypes.string,
};
class DatePicker extends Component {
    render() {
        const _a = this.props, { prefix = 'next-', popupAlign = 'bl tl', className, popupClassName = '', size = 'medium' } = _a, otherProps = __rest(_a, ["prefix", "popupAlign", "className", "popupClassName", "size"]);
        const theme = getTheme(this.context, this.props);
        return (React.createElement(NextDatePicker, Object.assign({}, otherProps, { size: size, prefix: prefix, popupAlign: popupAlign, popupClassName: `${prefix}${theme} ${popupClassName}`, className: cls(className, {
                [`${prefix}small`]: size === 'small',
                [`${prefix}medium`]: size === 'medium',
                [`${prefix}large`]: size === 'large',
                [`${prefix}white`]: theme === 'white',
                [`${prefix}grey`]: theme === 'grey',
            }) })));
    }
}
DatePicker.RangePicker = ConfigProvider.config(BdesignRangePicker);
DatePicker.MonthPicker = ConfigProvider.config(BdesignMonthPicker);
DatePicker.YearPicker = ConfigProvider.config(BdesignYearPicker);
DatePicker.WeekPicker = ConfigProvider.config(BdesignWeekPicker);
// contextTypes
DatePicker.contextTypes = {
    theme: PropTypes.string,
};
export default ConfigProvider.config(DatePicker);
