'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var uiUtil = require('../../utils/uiUtil.cjs');
var useMergeProps = require('../../hooks/useMergeProps.cjs');
var MonthHeader = require('./MonthHeader.cjs');
var MonthBody = require('./MonthBody.cjs');

function MonthPanel(_props) {
  const props = useMergeProps.default(_props);
  const {
    prefixCls,
    operationRef,
    onViewDateChange,
    generateConfig,
    value,
    viewDate,
    onPanelChange,
    onSelect
  } = props;
  const panelPrefixCls = `${prefixCls}-month-panel`;
  operationRef.value = {
    onKeydown: (event) => uiUtil.createKeydownHandler(event, {
      onLeftRight: (diff) => {
        onSelect(generateConfig.addMonth(value || viewDate, diff), "key");
      },
      onCtrlLeftRight: (diff) => {
        onSelect(generateConfig.addYear(value || viewDate, diff), "key");
      },
      onUpDown: (diff) => {
        onSelect(generateConfig.addMonth(value || viewDate, diff * MonthBody.MONTH_COL_COUNT), "key");
      },
      onEnter: () => {
        onPanelChange("date", value || viewDate);
      }
    })
  };
  const onYearChange = (diff) => {
    const newDate = generateConfig.addYear(viewDate, diff);
    onViewDateChange(newDate);
    onPanelChange(null, newDate);
  };
  return vue.createVNode("div", {
    "class": panelPrefixCls
  }, [vue.createVNode(MonthHeader.default, {
    ...props,
    "prefixCls": prefixCls,
    "onPrevYear": () => {
      onYearChange(-1);
    },
    "onNextYear": () => {
      onYearChange(1);
    },
    "onYearClick": () => {
      onPanelChange("year", viewDate);
    }
  }, null), vue.createVNode(MonthBody.default, {
    ...props,
    "prefixCls": prefixCls,
    "onSelect": (date) => {
      onSelect(date, "mouse");
      onPanelChange("date", date);
    }
  }, null)]);
}
MonthPanel.displayName = "MonthPanel";
MonthPanel.inheritAttrs = false;

exports.default = MonthPanel;
//# sourceMappingURL=index.cjs.map
