"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _datePicker = _interopRequireDefault(require("antd/lib/date-picker"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _moment = _interopRequireDefault(require("moment"));
var _localHelper = require("./localHelper");
require("./index.less");
var _excluded = ["DatePickerType", "allowClear", "autoFocus", "bordered", "dateRender", "disabled", "disabledDate", "placement", "size", "defaultValue", "format", "showTime", "showNow", "showToday", "renderExtraFooter", "flag", "style"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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,
    flag = _ref.flag,
    style = _ref.style,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_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["default"], (0, _extends2["default"])({
      className: flag ? "isflag" : "",
      locale: _localHelper.LocalFormat.getDefinedChineseLocal(),
      inputReadOnly: true,
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      placement: placement,
      size: size,
      defaultValue: (0, _moment["default"])(defaultValue, format),
      value: defaultValue ? (0, _moment["default"])(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["default"], (0, _extends2["default"])({
      className: flag ? "isflag" : "",
      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: (0, _moment["default"])(defaultValue, 'YYYY-wo'),
      value: defaultValue ? (0, _moment["default"])(defaultValue, 'YYYY-wo') : null
    }, _otherProps));
  };
  var month = function month() {
    return /*#__PURE__*/React.createElement(_datePicker["default"], (0, _extends2["default"])({
      className: flag ? "isflag" : "",
      picker: "month",
      inputReadOnly: true,
      locale: _localHelper.LocalFormat.getDefinedChineseLocal(),
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      placement: placement,
      size: size,
      defaultValue: (0, _moment["default"])(defaultValue, 'YYYY-MM'),
      value: defaultValue ? (0, _moment["default"])(defaultValue, 'YYYY-MM') : null,
      renderExtraFooter: function renderExtraFooter() {
        return _renderExtraFooter;
      }
    }, _otherProps));
  };
  var quarter = function quarter() {
    return /*#__PURE__*/React.createElement(_datePicker["default"], (0, _extends2["default"])({
      className: flag ? "isflag" : "",
      picker: "quarter",
      inputReadOnly: true,
      locale: _localHelper.LocalFormat.getDefinedChineseLocal(),
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      placement: placement,
      size: size,
      defaultValue: (0, _moment["default"])(defaultValue, 'YYYY-\QQ'),
      value: defaultValue ? (0, _moment["default"])(defaultValue, 'YYYY-\QQ') : null,
      renderExtraFooter: function renderExtraFooter() {
        return _renderExtraFooter;
      }
    }, _otherProps));
  };
  var year = function year() {
    return /*#__PURE__*/React.createElement(_datePicker["default"], (0, _extends2["default"])({
      className: flag ? "isflag" : "",
      picker: "year",
      inputReadOnly: true,
      locale: _localHelper.LocalFormat.getDefinedChineseLocal(),
      allowClear: allowClear,
      autoFocus: autoFocus,
      bordered: !bordered,
      dateRender: dateRender,
      disabled: disabled,
      disabledDate: disabledDate,
      placement: placement,
      size: size,
      defaultValue: (0, _moment["default"])(defaultValue, 'YYYY'),
      value: defaultValue ? (0, _moment["default"])(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';
var _default = antDatePicker;
exports["default"] = _default;