'use strict';

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

var vue = require('vue');
var uiUtil = require('../../utils/uiUtil.js');
var useMergeProps = require('../../hooks/useMergeProps.js');
var constants = require('../constants.js');
var DecadeHeader = require('./DecadeHeader.js');
var DecadeBody = require('./DecadeBody.js');

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 * constants.DECADE_UNIT_DIFF), "key");
      },
      onCtrlLeftRight: (diff) => {
        onSelect(generateConfig.addYear(viewDate, diff * constants.DECADE_DISTANCE_COUNT), "key");
      },
      onUpDown: (diff) => {
        onSelect(generateConfig.addYear(viewDate, diff * constants.DECADE_UNIT_DIFF * constants.DECADE_COL_COUNT), "key");
      },
      onEnter: () => {
        onPanelChange("year", viewDate);
      }
    })
  };
  const onDecadesChange = (diff) => {
    const newDate = generateConfig.addYear(viewDate, diff * constants.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, vue.mergeProps(props, {
    "prefixCls": prefixCls,
    "onPrevDecades": () => {
      onDecadesChange(-1);
    },
    "onNextDecades": () => {
      onDecadesChange(1);
    }
  }), null), vue.createVNode(DecadeBody.default, vue.mergeProps(props, {
    "prefixCls": prefixCls,
    "onSelect": onInternalSelect
  }), null)]);
}
DecadePanel.displayName = "DecadePanel";
DecadePanel.inheritAttrs = false;

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