'use client'; import {ChevronLeft, ChevronRight} from 'lucide-react'; import React from 'react'; import { Calendar as AriaCalendar, CalendarGridHeader as AriaCalendarGridHeader, type CalendarProps as AriaCalendarProps, CalendarCell, CalendarGrid, CalendarGridBody, CalendarHeaderCell, CalendarHeading, Text, type DateValue } from 'react-aria-components/Calendar'; import {useLocale} from 'react-aria-components/I18nProvider'; import {tv} from 'tailwind-variants'; import {Button} from './Button'; import {composeTailwindRenderProps, focusRing} from './utils'; const cellStyles = tv({ extend: focusRing, base: 'w-[calc(100cqw/7)] aspect-square text-sm cursor-default rounded-full flex items-center justify-center forced-color-adjust-none [-webkit-tap-highlight-color:transparent]', variants: { isSelected: { false: 'text-neutral-900 dark:text-neutral-200 hover:bg-neutral-200 dark:hover:bg-neutral-700 pressed:bg-neutral-300 dark:pressed:bg-neutral-600', true: 'bg-blue-600 invalid:bg-red-600 text-white forced-colors:bg-[Highlight] forced-colors:invalid:bg-[Mark] forced-colors:text-[HighlightText]' }, isDisabled: { true: 'text-neutral-300 dark:text-neutral-600 forced-colors:text-[GrayText]' } } }); export interface CalendarProps extends AriaCalendarProps { errorMessage?: string; } export function Calendar({errorMessage, ...props}: CalendarProps) { let {direction} = useLocale(); let months = props.visibleDuration?.months || 1; return ( {Array.from({length: months}, (_, i) => (
{i === 0 && ( )} {i === months - 1 && ( )}
{date => }
))} {errorMessage && ( {errorMessage} )}
); } export function CalendarGridHeader() { return ( {day => ( {day} )} ); }