import { __assign } from 'tslib';
import { classNamesFunction, css, KeyCodes } from '@uifabric-vue/utilities';
import Vue from 'vue';
import { withCalendarYearProps } from './useCalendarYear.js';

var getClassNames = classNamesFunction();
var CalendarYearGridCell = Vue.extend({
  name: "CalendarYearGridCell",
  functional: true,
  props: __assign(__assign({}, withCalendarYearProps()), { year: { type: Number, default: void 0 }, current: { type: Boolean, default: void 0 }, selected: { type: Boolean, default: void 0 }, disabled: { type: Boolean, default: void 0 } }),
  render: function(h, ctx) {
    var _a;
    var _b = ctx.props, styles = _b.styles, theme = _b.theme, className = _b.className, highlightCurrentYear = _b.highlightCurrentYear, highlightSelectedYear = _b.highlightSelectedYear, selected = _b.selected, disabled = _b.disabled, year = _b.year;
    var onClick = function() {
      var _a2;
      (_a2 = ctx.listeners.onSelectYear) === null || _a2 === void 0 ? void 0 : _a2(year);
    };
    var onKeyDown = function(ev) {
      var _a2;
      if (ev.which === KeyCodes.enter) {
        (_a2 = ctx.listeners.onSelectYear) === null || _a2 === void 0 ? void 0 : _a2(year);
      }
    };
    var classNames = getClassNames(styles, {
      theme: theme,
      className: className,
      highlightCurrent: highlightCurrentYear,
      highlightSelected: highlightSelectedYear
    });
    var onRenderYear = function(value) {
      var _a2, _b2, _c;
      return (_c = (_b2 = (_a2 = ctx.scopedSlots).onRenderYear) === null || _b2 === void 0 ? void 0 : _b2.call(_a2, value)) !== null && _c !== void 0 ? _c : "".concat(value);
    };
    return h("button", {
      class: css(classNames.itemButton, (_a = {}, _a[classNames.selected] = selected, _a[classNames.disabled] = disabled, _a)),
      attrs: {
        type: "button",
        role: "gridcell",
        disabled: disabled,
        "aria-selected": selected
      },
      on: __assign({}, !disabled && {
        click: onClick,
        keydown: onKeyDown
      })
    }, onRenderYear(year));
  }
});

export { CalendarYearGridCell };
