"use client" import * as React from "react" import { cva } from "class-variance-authority" import { cn } from "cn" import { Calendar as AriaCalendar, CalendarGridHeader as AriaCalendarGridHeader, RangeCalendar as AriaRangeCalendar, CalendarCell, CalendarGrid, CalendarGridBody, CalendarHeaderCell, CalendarHeading, CalendarMonthPicker, CalendarYearPicker, type CalendarCellRenderProps, type CalendarProps, type DateValue, type RangeCalendarProps, } from "react-aria-components" import { Button, buttonVariants } from "@/registry/bases/aria/ui/button" import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, } from "@/registry/bases/aria/ui/select" import { IconPlaceholder } from "@/app/(create)/components/icon-placeholder" const cellVariants = cva( "group/day relative mt-2 aspect-square h-full w-full cursor-default rounded-(--cell-radius) p-0 text-center select-none [&:is(:last-child>[data-selected=true])>div]:rounded-r-(--cell-radius)", { variants: { showWeekNumber: { false: "[&:is(:first-child>[data-selected=true])>div]:rounded-l-(--cell-radius)", true: "[&:is(:nth-child(2)>[data-selected=true])>div]:rounded-l-(--cell-radius)", }, isToday: { true: "rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none", }, isSelectionStart: { true: "relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted", }, isSelectionEnd: { true: "relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted", }, isUnavailable: { true: "text-muted-foreground opacity-50 [&>div]:line-through", }, isDisabled: { true: "text-muted-foreground opacity-50", }, isOutsideMonth: { true: "text-muted-foreground aria-selected:text-muted-foreground", }, }, } ) function Calendar< T extends DateValue, M extends "single" | "multiple" = "single", >( props: Omit, "visibleDuration"> & { buttonVariant?: React.ComponentProps["variant"] captionLayout?: "label" | "dropdown" numberOfMonths?: number showWeekNumber?: boolean headerFormat?: Intl.DateTimeFormatOptions renderCell?: ( renderProps: CalendarCellRenderProps & { defaultChildren: React.ReactNode } ) => React.ReactNode } ) { return ( ) } function RangeCalendar( props: RangeCalendarProps & { buttonVariant?: React.ComponentProps["variant"] captionLayout?: "label" | "dropdown" headerFormat?: Intl.DateTimeFormatOptions numberOfMonths?: number showWeekNumber?: boolean renderCell?: ( renderProps: CalendarCellRenderProps & { defaultChildren: React.ReactNode } ) => React.ReactNode } ) { return ( ) } function CalendarInner({ captionLayout = "label", buttonVariant = "ghost", numberOfMonths = 1, showWeekNumber = false, headerFormat, renderCell, isRange, }: { buttonVariant?: React.ComponentProps["variant"] captionLayout?: "label" | "dropdown" numberOfMonths?: number showWeekNumber?: boolean headerFormat?: Intl.DateTimeFormatOptions renderCell?: ( renderProps: CalendarCellRenderProps & { defaultChildren: React.ReactNode } ) => React.ReactNode isRange?: boolean }) { return (
{Array.from({ length: numberOfMonths }, (_, i) => (
{captionLayout === "dropdown" ? ( <> ) : ( )}
{(day) => ( {day} )} {(date) => ( cellVariants({ ...renderProps, showWeekNumber }) } > {(renderProps) => (
span]:text-xs [&>span]:opacity-70" )} > {renderCell ? renderCell(renderProps) : renderProps.defaultChildren}
)}
)}
))}
) } function MonthDropdown({ format }: { format?: Intl.DateTimeFormatOptions }) { return ( {(props) => ( )} ) } function YearDropdown({ format }: { format?: Intl.DateTimeFormatOptions }) { return ( {(props) => ( )} ) } export { Calendar, RangeCalendar }