-
-
Notifications
You must be signed in to change notification settings - Fork 302
Expand file tree
/
Copy pathcalendar.tsx
More file actions
74 lines (69 loc) · 3.22 KB
/
Copy pathcalendar.tsx
File metadata and controls
74 lines (69 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"use client";
import * as React from "react";
import { ChevronLeft, ChevronRight } from "lucide-react";
import { DayPicker } from "react-day-picker";
import { cn } from "@/helpers/utils";
import { buttonVariants } from "@/components/ui/button";
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
function Calendar({
className,
classNames,
showOutsideDays = true,
...props
}: CalendarProps) {
return (
<DayPicker
showOutsideDays={showOutsideDays}
className={cn("p-3", className)}
classNames={{
months: "relative flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
month: "space-y-4",
month_caption:
"flex justify-center pt-1 px-10 relative items-center",
caption_label: "text-sm font-medium",
nav: "pointer-events-none absolute inset-x-3 z-20 flex items-center justify-between",
button_previous: cn(
buttonVariants({ variant: "outline" }),
"pointer-events-auto h-8 w-8 bg-background p-0 opacity-70 hover:opacity-100",
),
button_next: cn(
buttonVariants({ variant: "outline" }),
"pointer-events-auto h-8 w-8 bg-background p-0 opacity-70 hover:opacity-100",
),
month_grid: "w-full border-collapse space-y-1",
weekdays: "flex",
weekday:
"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
week: "flex w-full mt-2",
day: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].range_end)]:rounded-r-md [&:has([aria-selected].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",
day_button: cn(
buttonVariants({ variant: "ghost" }),
"h-9 w-9 p-0 font-normal aria-selected:opacity-100",
),
range_end: "range-end",
selected:
"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
today: "bg-accent text-accent-foreground",
outside:
"outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",
disabled: "text-muted-foreground opacity-50",
range_middle:
"aria-selected:bg-accent aria-selected:text-accent-foreground",
hidden: "invisible",
...classNames,
}}
components={{
Chevron: ({ className, orientation, ...props }) => {
const Icon =
orientation === "left" ? ChevronLeft : ChevronRight;
return (
<Icon className={cn("h-4 w-4", className)} {...props} />
);
},
}}
{...props}
/>
);
}
Calendar.displayName = "Calendar";
export { Calendar };