import _DatePicker from "antd/es/date-picker";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["DatePickerType", "allowClear", "autoFocus", "bordered", "dateRender", "disabled", "disabledDate", "placement", "size", "defaultValue", "format", "showTime", "showNow", "showToday", "renderExtraFooter", "style"];
/* eslint-disable @typescript-eslint/no-shadow */
import * as React from 'react';
import moment from 'moment';
// import 'moment/dist/locale/zh-cn';
import { LocalFormat } from "./localHelper";
import "./index.less";
var antDatePicker = function antDatePicker(_ref) {
  var DatePickerType = _ref.DatePickerType,
    allowClear = _ref.allowClear,
    autoFocus = _ref.autoFocus,
    bordered = _ref.bordered,
    dateRender = _ref.dateRender,
    disabled = _ref.disabled,
    disabledDate = _ref.disabledDate,
    placement = _ref.placement,
    size = _ref.size,
    defaultValue = _ref.defaultValue,
    format = _ref.format,
    showTime = _ref.showTime,
    showNow = _ref.showNow,
    showToday = _ref.showToday,
    _renderExtraFooter = _ref.renderExtraFooter,
    style = _ref.style,
    otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
  var _style = style || {};
  // _style['height'] = _style['height'] ? _style['height'] : '30px';
  // _style['width'] = _style['width'] ? _style['width'] : '300px';
  var _otherProps = otherProps || {};
  _otherProps.style = _style;
  var date = function date() {
    return /*#__PURE__*/React.createElement(_DatePicker, _extends({
      locale: LocalFormat.getDefinedChineseLocal(),
      inputReadOnly: true,
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      placement: placement,
      size: size,
      defaultValue: moment(defaultValue, format),
      value: defaultValue ? moment(defaultValue, format) : null
      // defaultValue={defaultValue}
      // defaultPickerValue={defaultValue}
      ,
      format: format,
      showTime: showTime,
      showNow: showNow,
      showToday: showToday,
      renderExtraFooter: function renderExtraFooter() {
        return _renderExtraFooter;
      }
    }, _otherProps));
  };
  var week = function week() {
    return /*#__PURE__*/React.createElement(_DatePicker, _extends({
      picker: "week",
      placeholder: "\u8BF7\u9009\u62E9\u5468",
      inputReadOnly: true,
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      placement: placement,
      size: size,
      defaultValue: moment(defaultValue, 'YYYY-wo'),
      value: defaultValue ? moment(defaultValue, 'YYYY-wo') : null
    }, _otherProps));
  };
  var month = function month() {
    return /*#__PURE__*/React.createElement(_DatePicker, _extends({
      picker: "month",
      inputReadOnly: true,
      locale: LocalFormat.getDefinedChineseLocal(),
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      placement: placement,
      size: size,
      defaultValue: moment(defaultValue, 'YYYY-MM'),
      value: defaultValue ? moment(defaultValue, 'YYYY-MM') : null,
      renderExtraFooter: function renderExtraFooter() {
        return _renderExtraFooter;
      }
    }, _otherProps));
  };
  var quarter = function quarter() {
    return /*#__PURE__*/React.createElement(_DatePicker, _extends({
      picker: "quarter",
      inputReadOnly: true,
      locale: LocalFormat.getDefinedChineseLocal(),
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      placement: placement,
      size: size,
      defaultValue: moment(defaultValue, 'YYYY-\QQ'),
      value: defaultValue ? moment(defaultValue, 'YYYY-\QQ') : null,
      renderExtraFooter: function renderExtraFooter() {
        return _renderExtraFooter;
      }
    }, _otherProps));
  };
  var year = function year() {
    return /*#__PURE__*/React.createElement(_DatePicker, _extends({
      picker: "year",
      inputReadOnly: true,
      locale: LocalFormat.getDefinedChineseLocal(),
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      placement: placement,
      size: size,
      defaultValue: moment(defaultValue, 'YYYY'),
      value: defaultValue ? moment(defaultValue, 'YYYY') : null,
      renderExtraFooter: function renderExtraFooter() {
        return _renderExtraFooter;
      }
    }, _otherProps));
  };
  return function () {
    switch (DatePickerType) {
      case '日期':
        return date();
        break;
      case '周':
        return week();
        break;
      case '月份':
        return month();
        break;
      case '季度':
        return quarter();
        break;
      case '年份':
        return year();
        break;
      default:
        return false;
    }
  }();
};
antDatePicker.displayName = 'antDatePicker';
export default antDatePicker;