@@ -3,45 +3,71 @@ import { ChevronLeft, ChevronRight } from 'lucide-react';
33import { DayPicker } from 'react-day-picker' ;
44
55import { cn } from '@/src/lib/utils' ;
6-
7- export type CalendarProps = React . ComponentProps < typeof DayPicker > ;
6+ import { buttonVariants } from '@/src/components/ui/button' ;
87
98function Calendar ( {
109 className,
1110 classNames,
1211 showOutsideDays = true ,
1312 ...props
14- } : CalendarProps ) {
13+ } : React . ComponentProps < typeof DayPicker > ) {
1514 return (
1615 < DayPicker
1716 showOutsideDays = { showOutsideDays }
1817 className = { cn ( 'p-3' , className ) }
1918 classNames = { {
20- months : 'flex flex-col sm:flex-row gap-4' ,
21- month : 'flex flex-col gap-y-4' ,
22- month_caption : 'flex h-8 w-full items-center justify-center relative' ,
23- caption_label : 'font-medium text-sm mt-1' ,
24- nav : 'flex items-center justify-between absolute left-0 right-0 z-10' ,
25- month_grid : 'w-full border-collapse mt-1' ,
26- weekdays : 'flex' ,
27- weekday :
28- 'text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]' ,
29- week : 'flex w-full mt-2' ,
30- day : 'h-9 w-9 text-center text-sm p-0 relative' ,
19+ months : 'flex flex-col sm:flex-row gap-2' ,
20+ month : 'flex flex-col gap-4' ,
21+ caption : 'flex justify-center pt-1 relative items-center w-full' ,
22+ caption_label : 'text-sm font-medium' ,
23+ nav : 'flex items-center gap-1' ,
24+ nav_button : cn (
25+ buttonVariants ( { variant : 'outline' } ) ,
26+ 'size-7 bg-transparent p-0 opacity-50 hover:opacity-100' ,
27+ ) ,
28+ nav_button_previous : 'absolute left-1' ,
29+ nav_button_next : 'absolute right-1' ,
30+ table : 'w-full border-collapse space-x-1' ,
31+ head_row : 'flex' ,
32+ head_cell :
33+ 'text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]' ,
34+ row : 'flex w-full mt-2' ,
35+ cell : cn (
36+ 'relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md' ,
37+ props . mode === 'range'
38+ ? '[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md'
39+ : '[&:has([aria-selected])]:rounded-md' ,
40+ ) ,
41+ day : cn (
42+ buttonVariants ( { variant : 'ghost' } ) ,
43+ 'size-8 p-0 font-normal aria-selected:opacity-100' ,
44+ ) ,
45+ day_range_start :
46+ 'day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground' ,
47+ day_range_end :
48+ 'day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground' ,
49+ day_selected :
50+ 'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground' ,
51+ day_today : 'bg-accent text-accent-foreground' ,
52+ day_outside :
53+ 'day-outside text-muted-foreground aria-selected:text-muted-foreground' ,
54+ day_disabled : 'text-muted-foreground opacity-50' ,
55+ day_range_middle :
56+ 'aria-selected:bg-accent aria-selected:text-accent-foreground' ,
57+ day_hidden : 'invisible' ,
3158 ...classNames ,
3259 } }
3360 components = { {
34- Chevron : ( { orientation , ...props } ) => {
35- if ( orientation === 'left' ) {
36- return < ChevronLeft { ... props } /> ;
37- }
38- return < ChevronRight { ...props } /> ;
39- } ,
61+ IconLeft : ( { className , ...props } ) => (
62+ < ChevronLeft className = { cn ( 'size-4' , className ) } { ... props } />
63+ ) ,
64+ IconRight : ( { className , ... props } ) => (
65+ < ChevronRight className = { cn ( 'size-4' , className ) } { ...props } />
66+ ) ,
4067 } }
4168 { ...props }
4269 />
4370 ) ;
4471}
45- Calendar . displayName = 'Calendar' ;
4672
4773export { Calendar } ;
0 commit comments