"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _datePicker = _interopRequireDefault(require("@alifd/next/lib/date-picker2"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _dayjs = _interopRequireDefault(require("dayjs"));
require("./index.scss");
var _excluded = ["type", "section", "label", "state", "placeholder", "value", "format", "size", "disabled", "hasClear", "showTime", "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 MyDatePicker = function MyDatePicker(_ref) {
  var type = _ref.type,
    section = _ref.section,
    label = _ref.label,
    state = _ref.state,
    placeholder = _ref.placeholder,
    value = _ref.value,
    format = _ref.format,
    size = _ref.size,
    disabled = _ref.disabled,
    hasClear = _ref.hasClear,
    showTime = _ref.showTime,
    _ref$style = _ref.style,
    style = _ref$style === void 0 ? {} : _ref$style,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var _style = style || {};
  var _otherProps = otherProps || {};
  _otherProps.style = _style;
  var MonthPicker = _datePicker["default"].MonthPicker,
    YearPicker = _datePicker["default"].YearPicker,
    WeekPicker = _datePicker["default"].WeekPicker,
    QuarterPicker = _datePicker["default"].QuarterPicker,
    RangePicker = _datePicker["default"].RangePicker;
  var RangePreset = {
    今天: [(0, _dayjs["default"])(), (0, _dayjs["default"])()],
    本月: [(0, _dayjs["default"])().startOf("month"), (0, _dayjs["default"])().endOf("month")]
  };
  var nian = function nian() {
    return section === '关闭' ? /*#__PURE__*/React.createElement(YearPicker, (0, _extends2["default"])({
      popupClassName: "nianName",
      label: label,
      state: state,
      placeholder: placeholder,
      defaultValue: value,
      value: value,
      format: format,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps)) : /*#__PURE__*/React.createElement(RangePicker, (0, _extends2["default"])({
      popupClassName: "nianNameQj",
      placeholder: ["开始年", "结束年"],
      mode: "year",
      label: label,
      state: state,
      value: value,
      format: format,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps));
  };
  var yue = function yue() {
    return section === '关闭' ? /*#__PURE__*/React.createElement(MonthPicker, (0, _extends2["default"])({
      popupClassName: "yueName",
      label: label,
      state: state,
      placeholder: placeholder,
      value: value,
      format: format,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps)) : /*#__PURE__*/React.createElement(RangePicker, (0, _extends2["default"])({
      popupClassName: "yueNameQj",
      placeholder: ["开始月", "结束月"],
      mode: "month",
      label: label,
      state: state
      // placeholder={placeholder}
      ,
      value: value,
      format: format,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps));
  };
  var riqi = function riqi() {
    return section === '关闭' ? /*#__PURE__*/React.createElement(_datePicker["default"], (0, _extends2["default"])({
      popupClassName: "riqiName",
      label: label,
      state: state,
      placeholder: placeholder,
      value: value,
      format: format,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps)) : /*#__PURE__*/React.createElement(RangePicker, (0, _extends2["default"])({
      popupClassName: "riqiNameQj",
      label: label,
      preset: RangePreset,
      state: state
      // placeholder={placeholder}
      ,
      value: value,
      format: format,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps));
  };
  var shijian = function shijian() {
    return section === '关闭' ? /*#__PURE__*/React.createElement(_datePicker["default"], (0, _extends2["default"])({
      popupClassName: "shijianName",
      showTime: true,
      format: "YYYY/MM/DD HH:mm:ss",
      label: label,
      state: state,
      placeholder: placeholder,
      value: value,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps)) : /*#__PURE__*/React.createElement(RangePicker, (0, _extends2["default"])({
      popupClassName: "shijianNameQj",
      format: "YYYY/MM/DD HH:mm:ss",
      showTime: true,
      label: label,
      state: state,
      preset: RangePreset
      // placeholder={placeholder}
      ,
      value: value,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps));
  };
  return function () {
    switch (type) {
      case "年":
        return nian();
        break;
      case "月":
        return yue();
        break;
      case "日":
        return riqi();
        break;
      case "时间":
        return shijian();
        break;
      default:
        return null;
    }
  }();
};
var _default = MyDatePicker;
exports["default"] = _default;