import { DatePicker as AriaDatePicker, Button, Dialog, Group, OverlayArrow, Popover } from 'react-aria-components'; import dayjs from 'dayjs'; import { tv } from 'tailwind-variants'; import { Calendar } from '../calendar'; import { calendarDateToDate, dateToCalendarDate } from '../calendar/utils'; import { CalendarIcon } from '../icons'; const trigger = tv({ base: 'flex h-9 w-[156px] cursor-pointer items-center border border-kc-gray-be bg-white text-left outline-none transition', variants: { isHovered: { true: 'border-kc-black-34', }, isFocused: { true: 'border-kc-black-34', }, isDisabled: { true: 'cursor-default border-kc-gray-99 bg-kc-gray-eb', }, isFocusVisible: { true: 'ring-2 ring-offset-2 ring-primary', }, }, }); export type DatePickerProps = { value: Date | null; onChange: (date: Date | null) => void; maxValue?: Date | null; minValue?: Date | null; isDisabled?: boolean; className?: string; name?: string; }; export function DatePicker({ value, onChange, maxValue, minValue, isDisabled, className, name }: DatePickerProps) { return ( onChange(calendarDateToDate(val))} maxValue={maxValue !== undefined ? dateToCalendarDate(maxValue) : undefined} minValue={minValue !== undefined ? dateToCalendarDate(minValue) : undefined} isDisabled={isDisabled} granularity="day" firstDayOfWeek="sun" className={className} name={name} > ); }