import _extends from "@babel/runtime/helpers/extends";
import _DatePicker from "antd/es/date-picker";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["DatePickerType", "allowClear", "autoFocus", "bordered", "dateRender", "disabled", "disabledDate", "placement", "size", "defaultValue", "format", "showTime", "showNow", "showToday", "renderExtraFooter", "flag", "style"];
/* eslint-disable @typescript-eslint/no-shadow */

import * as React from 'react';
import moment from 'moment';
import { LocalFormat } from "./localHelper";
import "./index.less";
var antDatePickerScope = function antDatePickerScope(_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,
    flag = _ref.flag,
    style = _ref.style,
    otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
  var RangePicker = _DatePicker.RangePicker;
  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(RangePicker, _extends({
      className: flag ? "isflag" : "",
      locale: LocalFormat.getDefinedChineseLocal(),
      inputReadOnly: true,
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      size: size,
      defaultValue: [moment(defaultValue[0], format), moment(defaultValue[1], format)],
      value: defaultValue ? [moment(defaultValue[0], format), moment(defaultValue[1], format)] : null,
      format: format,
      showTime: showTime,
      showNow: showNow,
      renderExtraFooter: function renderExtraFooter() {
        return _renderExtraFooter;
      }
    }, _otherProps));
  };
  var week = function week() {
    return /*#__PURE__*/React.createElement(RangePicker, _extends({
      picker: "week",
      className: flag ? "isflag" : "",
      locale: LocalFormat.getDefinedChineseLocal(),
      inputReadOnly: true,
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      placement: placement,
      size: size,
      allowEmpty: [true, false],
      defaultValue: [moment(defaultValue[0], 'YYYY-wo'), moment(defaultValue[1], 'YYYY-wo')],
      value: defaultValue ? [moment(defaultValue[0], 'YYYY-wo'), moment(defaultValue[1], 'YYYY-wo')] : null
    }, _otherProps));
  };
  var month = function month() {
    return /*#__PURE__*/React.createElement(RangePicker, _extends({
      picker: "month",
      className: flag ? "isflag" : "",
      locale: LocalFormat.getDefinedChineseLocal(),
      inputReadOnly: true,
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      placement: placement,
      size: size,
      defaultValue: [moment(defaultValue[0], 'YYYY-MM'), moment(defaultValue[1], 'YYYY-MM')],
      value: defaultValue ? [moment(defaultValue[0], 'YYYY-MM'), moment(defaultValue[1], 'YYYY-MM')] : null
      // format={format}
      ,
      renderExtraFooter: function renderExtraFooter() {
        return _renderExtraFooter;
      }
    }, _otherProps));
  };
  var quarter = function quarter() {
    return /*#__PURE__*/React.createElement(RangePicker, _extends({
      picker: "quarter",
      className: flag ? "isflag" : "",
      locale: LocalFormat.getDefinedChineseLocal(),
      inputReadOnly: true,
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      placement: placement,
      size: size,
      defaultValue: [moment(defaultValue[0], 'YYYY-\QQ'), moment(defaultValue[1], 'YYYY-\QQ')],
      value: defaultValue ? [moment(defaultValue[0], 'YYYY-\QQ'), moment(defaultValue[1], 'YYYY-\QQ')] : null
      // format={format}
      ,
      renderExtraFooter: function renderExtraFooter() {
        return _renderExtraFooter;
      }
    }, _otherProps));
  };
  var year = function year() {
    return /*#__PURE__*/React.createElement(RangePicker, _extends({
      inputReadOnly: true,
      picker: "year",
      className: flag ? "isflag" : "",
      locale: LocalFormat.getDefinedChineseLocal(),
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      placement: placement,
      size: size,
      defaultValue: [moment(defaultValue[0], 'YYYY'), moment(defaultValue[1], 'YYYY')],
      value: defaultValue ? [moment(defaultValue[0], 'YYYY'), moment(defaultValue[1], 'YYYY')] : null
      // format={format}
      ,
      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;
    }
  }();
};
antDatePickerScope.displayName = 'antDatePickerScope';
export default antDatePickerScope;