"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var prop_types_1 = __importDefault(require("prop-types"));
var moment_1 = __importDefault(require("moment"));
var datePickerHelpers_1 = require("./datePickerHelpers");
var MonthYearDropDown = /** @class */ (function (_super) {
    __extends(MonthYearDropDown, _super);
    function MonthYearDropDown() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.handleChangeMonth = function (_a) {
            var value = _a.target.value;
            var _b = _this.props, month = _b.month, onMonthSelect = _b.onMonthSelect;
            onMonthSelect(month, value);
        };
        _this.handleChangeYear = function (_a) {
            var value = _a.target.value;
            var _b = _this.props, month = _b.month, onYearSelect = _b.onYearSelect;
            onYearSelect(month, value);
        };
        _this.handleStopPropagation = function (e) { return e.stopPropagation(); };
        return _this;
    }
    MonthYearDropDown.prototype.render = function () {
        var _a = this.props, month = _a.month, monthAriaLabel = _a.monthAriaLabel, yearAriaLabel = _a.yearAriaLabel, yearsAfterCurrent = _a.yearsAfterCurrent, yearsBeforeCurrent = _a.yearsBeforeCurrent;
        var yearList = datePickerHelpers_1.getSiblingYearList(moment_1.default().year(), yearsBeforeCurrent, yearsAfterCurrent);
        return (react_1.default.createElement("div", { "data-test-automation-id": "monthYearDropDown", className: "rc-month-year-dropdown-wrapper", onKeyDown: this.handleStopPropagation, onClick: this.handleStopPropagation, onMouseUp: this.handleStopPropagation, onKeyUp: this.handleStopPropagation },
            react_1.default.createElement("select", { "data-test-automation-id": "monthDropDown", autoFocus: true, className: "month-dropdown form-control", value: month.month(), "aria-label": monthAriaLabel, onChange: this.handleChangeMonth }, moment_1.default.months().map(function (label, value) { return (react_1.default.createElement("option", { key: value, value: value }, label)); })),
            react_1.default.createElement("select", { "data-test-automation-id": "yearDropDown", className: "year-dropdown form-control", value: month.year(), onChange: this.handleChangeYear, "aria-label": yearAriaLabel }, yearList.map(function (year) { return (react_1.default.createElement("option", { key: year, value: year }, year)); }))));
    };
    MonthYearDropDown.propTypes = {
        month: prop_types_1.default.oneOfType([prop_types_1.default.number, prop_types_1.default.object]).isRequired,
        onMonthSelect: prop_types_1.default.func.isRequired,
        onYearSelect: prop_types_1.default.func.isRequired,
        monthAriaLabel: prop_types_1.default.string.isRequired,
        yearAriaLabel: prop_types_1.default.string.isRequired,
        yearsBeforeCurrent: prop_types_1.default.number.isRequired,
        yearsAfterCurrent: prop_types_1.default.number.isRequired
    };
    return MonthYearDropDown;
}(react_1.default.PureComponent));
exports.MonthYearDropDown = MonthYearDropDown;
//# sourceMappingURL=MonthYearDropDown.js.map