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

function DecadePanel(_props) {
  const props = useMergeProps.default(_props);
  const {
    prefixCls,
    onViewDateChange,
    generateConfig,
    viewDate,
    operationRef,
    onSelect,
    onPanelChange
  } = props;
  const panelPrefixCls = `${prefixCls}-decade-panel`;
  operationRef.value = {
    onKeydown: (event) => uiUtil.createKeydownHandler(event, {
      onLeftRight: (diff) => {
        onSelect(generateConfig.addYear(viewDate, diff * constant.DECADE_UNIT_DIFF), "key");
      },
      onCtrlLeftRight: (diff) => {
        onSelect(generateConfig.addYear(viewDate, diff * constant.DECADE_DISTANCE_COUNT), "key");
      },
      onUpDown: (diff) => {
        onSelect(generateConfig.addYear(viewDate, diff * constant.DECADE_UNIT_DIFF * DecadeBody.DECADE_COL_COUNT), "key");
      },
      onEnter: () => {
        onPanelChange("year", viewDate);
      }
    })
  };
  const onDecadesChange = (diff) => {
    const newDate = generateConfig.addYear(viewDate, diff * constant.DECADE_DISTANCE_COUNT);
    onViewDateChange(newDate);
    onPanelChange(null, newDate);
  };
  const onInternalSelect = (date) => {
    onSelect(date, "mouse");
    onPanelChange("year", date);
  };
  return vue.createVNode("div", {
    "class": panelPrefixCls
  }, [vue.createVNode(DecadeHeader.default, {
    ...props,
    "prefixCls": prefixCls,
    "onPrevDecades": () => {
      onDecadesChange(-1);
    },
    "onNextDecades": () => {
      onDecadesChange(1);
    }
  }, null), vue.createVNode(DecadeBody.default, {
    ...props,
    "prefixCls": prefixCls,
    "onSelect": onInternalSelect
  }, null)]);
}
DecadePanel.displayName = "DecadePanel";
DecadePanel.inheritAttrs = false;

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