"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _antd = require("antd");
require("./styles/index.less");
var _dayjs = _interopRequireDefault(require("dayjs"));
require("dayjs/locale/zh-cn");
var _excluded = ["year", "month"]; // moment与dayjs不能同时使用，不然locale配置会无效
// import moment from 'moment'
//去除RFC2822/ISO date formats的警告
// moment.suppressDeprecationWarnings = true;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
_dayjs.default.locale('zh-cn');
var CalendarMonthPicker = function CalendarMonthPicker(props) {
  var year = props.year,
    month = props.month,
    others = _objectWithoutProperties(props, _excluded);
  var monthRangeDays = (0, _react.useMemo)(function () {
    var time = (year || (0, _dayjs.default)().year()) + '-01';
    var startTime = (0, _dayjs.default)(time).month(month - 1).date(1).startOf("month"); //.format('YYYY-MM-DD')
    var endTime = (0, _dayjs.default)(time).month(month - 1).date(1).endOf("month"); //.format('YYYY-MM-DD')
    return [startTime, endTime];
  }, [year]);
  // dayjs.locale('zh-cn')
  return /*#__PURE__*/_react.default.createElement(_antd.Calendar, _extends({
    fullscreen: false,
    value: (0, _dayjs.default)((year || (0, _dayjs.default)().year()) + '-' + month),
    validRange: monthRangeDays
  }, others));
};
var _default = exports.default = CalendarMonthPicker;