import { useEffect, useRef } from 'react'; import { range } from 'lodash-es'; import { cn } from '#utils'; import { ScrollArea } from '../ScrollArea/ScrollArea.tsx'; export type YearSelectorProps = { onSelection: (date: Date) => void; selected: Date; }; export const YearSelector = (props: YearSelectorProps) => { const selectedRef = useRef(null); const currentYear = new Date().getFullYear(); const years = Array.from(range(currentYear - 100, currentYear + 8)).reverse(); useEffect(() => { if (selectedRef.current) { selectedRef.current.scrollIntoView({ block: 'center' }); } }, []); return (
{years.map((year) => (
))}
); };