"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _moment = _interopRequireDefault(require("moment"));

var _utils = require("../../../utils");

var _dateHead = _interopRequireDefault(require("./date-head"));

var _dateBody = _interopRequireDefault(require("./date-body"));

require("./index.css");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

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); }

var DatePanel = function DatePanel(props) {
  var viewDate = props.viewDate,
      onViewDateChange = props.onViewDateChange;

  var onMonthChange = function onMonthChange(diff) {
    if (onViewDateChange) {
      onViewDateChange((0, _moment["default"])(viewDate).add(diff, 'M'));
    }
  };

  return /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(_utils.PickerPanelClass, "__date"))
  }, /*#__PURE__*/_react["default"].createElement(_dateHead["default"], _extends({}, props, {
    onPrev: function onPrev() {
      return onMonthChange(-1);
    },
    onNext: function onNext() {
      return onMonthChange(1);
    }
  })), /*#__PURE__*/_react["default"].createElement(_dateBody["default"], props));
};

var _default = DatePanel;
exports["default"] = _default;