"use client"; import { getWeeksInMonth } from "@internationalized/date"; import { useCalendarGrid } from "@react-aria/calendar"; import { useLocale } from "@react-aria/i18n"; import type { RangeCalendarState } from "react-stately"; import { CalendarCell } from "./calendar-cell"; import styles from "./calendar.module.css"; export function CalendarGrid({ state, ...props }: { state: RangeCalendarState; }) { let { locale } = useLocale(); let { gridProps, headerProps, weekDays } = useCalendarGrid(props, state); // Get the number of weeks in the month so we can render the proper number of rows. let weeksInMonth = getWeeksInMonth(state.visibleRange.start, locale); return ( {weekDays.map((day, index) => ( ))} {Array.from(new Array(weeksInMonth).keys()).map((weekIndex) => ( {state .getDatesInWeek(weekIndex) .map((date, i) => date ? ( ) : ( ))}
{day}
), )}
); }