import React from 'react';
import { classes, st } from './YearDropdown.st.css.js';
import setYear from 'date-fns/setYear';
import DatePickerDropdown from '../../DatePickerDropdown';
const YearDropdown = ({ className, date, onChange, ariaLabel, ariaLabelledBy, }) => {
    const year = date.getFullYear();
    const maxYear = Math.max(year, new Date().getFullYear() + 15);
    const minYear = Math.min(year - 1, 1899);
    const years = Array.from({ length: maxYear - minYear }, (_, i) => ({
        id: i,
        value: maxYear - i,
    }));
    const selectedYear = years.find(({ value }) => value === year) ?? years[0];
    return (React.createElement(DatePickerDropdown, { dataHook: "datepicker-year-dropdown", className: st(classes.root, className), caption: selectedYear.value, options: years, selectedId: selectedYear.id, onChange: ({ value }) => onChange(setYear(date, value)), ariaLabel: ariaLabel, ariaLabelledBy: ariaLabelledBy }));
};
export default YearDropdown;
//# sourceMappingURL=YearDropdown.js.map