'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 QuarterBody = require('./QuarterBody.cjs');
var QuarterHeader = require('./QuarterHeader.cjs');

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

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