import React from 'react'; import clsx from 'clsx'; import { CalendarDate, DateValue, getDayOfWeek, isSameMonth, isToday, } from '@internationalized/date'; import {useSelectedLocale} from '../../../../../i18n/selected-locale'; import {DatePickerState} from '../date-picker/use-date-picker-state'; import {dateIsInvalid} from '../utils'; import {DateRangePickerState} from '../date-range-picker/use-date-range-picker-state'; interface CalendarCellProps { date: CalendarDate; currentMonth: DateValue; state: DatePickerState | DateRangePickerState; } export function CalendarCell({ date, currentMonth, state: { dayIsActive, dayIsHighlighted, dayIsRangeStart, dayIsRangeEnd, getCellProps, timezone, min, max, }, }: CalendarCellProps) { const {localeCode} = useSelectedLocale(); const dayOfWeek = getDayOfWeek(date, localeCode); const isActive = dayIsActive(date); const isHighlighted = dayIsHighlighted(date); const isRangeStart = dayIsRangeStart(date); const isRangeEnd = dayIsRangeEnd(date); const dayIsToday = isToday(date, timezone); const sameMonth = isSameMonth(date, currentMonth); const isDisabled = dateIsInvalid(date, min, max); return (
{date.day} {isHighlighted && sameMonth && ( )}
); }