import { __assign } from "tslib";
import { classNamesFunction, css, KeyCodes } from '@uifabric-vue/utilities';
import Vue from 'vue';
import { withCalendarYearProps } from './useCalendarYear';
var getClassNames = classNamesFunction();
export var CalendarYearGridCell = Vue.extend({
    name: 'CalendarYearGridCell',
    functional: true,
    props: __assign(__assign({}, withCalendarYearProps()), { year: { type: Number, default: undefined }, current: { type: Boolean, default: undefined }, selected: { type: Boolean, default: undefined }, disabled: { type: Boolean, default: undefined } }),
    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 _a, _b;
            (_b = (_a = ctx.listeners).onSelectYear) === null || _b === void 0 ? void 0 : _b.call(_a, year);
        };
        var onKeyDown = function (ev) {
            var _a, _b;
            if (ev.which === KeyCodes.enter) {
                (_b = (_a = ctx.listeners).onSelectYear) === null || _b === void 0 ? void 0 : _b.call(_a, year);
            }
        };
        var classNames = getClassNames(styles, {
            theme: theme,
            className: className,
            highlightCurrent: highlightCurrentYear,
            highlightSelected: highlightSelectedYear,
        });
        var onRenderYear = function (value) {
            var _a, _b, _c;
            return (_c = (_b = (_a = ctx.scopedSlots).onRenderYear) === null || _b === void 0 ? void 0 : _b.call(_a, 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 && {
                // @ts-ignore
                click: onClick,
                keydown: onKeyDown,
            }),
        }, onRenderYear(year));
    },
});
//# sourceMappingURL=CalendarYearGridCell.js.map