| 10 | export type CalendarProps = React.ComponentProps<typeof DayPicker> |
| 11 | |
| 12 | function Calendar({ |
| 13 | className, |
| 14 | classNames, |
| 15 | showOutsideDays = true, |
| 16 | ...props |
| 17 | }: CalendarProps) { |
| 18 | return ( |
| 19 | <DayPicker |
| 20 | showOutsideDays={showOutsideDays} |
| 21 | className={cn("p-3", className)} |
| 22 | classNames={{ |
| 23 | months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0", |
| 24 | month: "space-y-4", |
| 25 | caption: "flex justify-center pt-1 relative items-center", |
| 26 | caption_label: "text-sm font-medium", |
| 27 | nav: "space-x-1 flex items-center", |
| 28 | nav_button: cn( |
| 29 | buttonVariants({ variant: "outline" }), |
| 30 | "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100" |
| 31 | ), |
| 32 | nav_button_previous: "absolute left-1", |
| 33 | nav_button_next: "absolute right-1", |
| 34 | table: "w-full border-collapse space-y-1", |
| 35 | head_row: "flex", |
| 36 | head_cell: |
| 37 | "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]", |
| 38 | row: "flex w-full mt-2", |
| 39 | cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20", |
| 40 | day: cn( |
| 41 | buttonVariants({ variant: "ghost" }), |
| 42 | "h-9 w-9 p-0 font-normal aria-selected:opacity-100" |
| 43 | ), |
| 44 | day_range_end: "day-range-end", |
| 45 | day_selected: |
| 46 | "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground", |
| 47 | day_today: "bg-accent text-accent-foreground", |
| 48 | day_outside: |
| 49 | "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30", |
| 50 | day_disabled: "text-muted-foreground opacity-50", |
| 51 | day_range_middle: |
| 52 | "aria-selected:bg-accent aria-selected:text-accent-foreground", |
| 53 | day_hidden: "invisible", |
| 54 | ...classNames, |
| 55 | }} |
| 56 | components={{ |
| 57 | IconLeft: ({ ...props }) => <ChevronLeft className="h-4 w-4" />, |
| 58 | IconRight: ({ ...props }) => <ChevronRight className="h-4 w-4" />, |
| 59 | }} |
| 60 | {...props} |
| 61 | /> |
| 62 | ) |
| 63 | } |
| 64 | Calendar.displayName = "Calendar" |
| 65 | |
| 66 | export { Calendar } |