'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 YearBody = require('./YearBody.cjs');
var YearHeader = require('./YearHeader.cjs');
var constant = require('./constant.cjs');

function YearPanel(_props) {
  const props = useMergeProps.default(_props);
  const {
    prefixCls,
    operationRef,
    onViewDateChange,
    generateConfig,
    value,
    viewDate,
    sourceMode,
    onSelect,
    onPanelChange
  } = props;
  const panelPrefixCls = `${prefixCls}-year-panel`;
  operationRef.value = {
    onKeydown: (event) => uiUtil.createKeydownHandler(event, {
      onLeftRight: (diff) => {
        onSelect(generateConfig.addYear(value || viewDate, diff), "key");
      },
      onCtrlLeftRight: (diff) => {
        onSelect(generateConfig.addYear(value || viewDate, diff * constant.YEAR_DECADE_COUNT), "key");
      },
      onUpDown: (diff) => {
        onSelect(generateConfig.addYear(value || viewDate, diff * YearBody.YEAR_COL_COUNT), "key");
      },
      onEnter: () => {
        onPanelChange(sourceMode === "date" ? "date" : "month", value || viewDate);
      }
    })
  };
  const onDecadeChange = (diff) => {
    const newDate = generateConfig.addYear(viewDate, diff * 10);
    onViewDateChange(newDate);
    onPanelChange(null, newDate);
  };
  return vue.createVNode("div", {
    "class": panelPrefixCls
  }, [vue.createVNode(YearHeader.default, {
    ...props,
    "prefixCls": prefixCls,
    "onPrevDecade": () => {
      onDecadeChange(-1);
    },
    "onNextDecade": () => {
      onDecadeChange(1);
    },
    "onDecadeClick": () => {
      onPanelChange("decade", viewDate);
    }
  }, null), vue.createVNode(YearBody.default, {
    ...props,
    "prefixCls": prefixCls,
    "onSelect": (date) => {
      onPanelChange(sourceMode === "date" ? "date" : "month", date);
      onSelect(date, "mouse");
    }
  }, null)]);
}
YearPanel.displayName = "YearPanel";
YearPanel.inheritAttrs = false;

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