feat: Calendar 컴포넌트에 연도 선택 기능 추가

This commit is contained in:
2025-06-27 17:45:10 +09:00
parent 47cbdf5fa9
commit 2b9028492b
7 changed files with 287 additions and 67 deletions
@@ -3,19 +3,20 @@
import { useEffect, useState } from "react";
import { format } from "date-fns";
import { CalendarIcon } from "lucide-react";
import type { DateRange } from "react-day-picker";
import type { DateRange, DayPicker } from "react-day-picker";
import { cn } from "../../lib/utils";
import { Button } from "../button";
import { Calendar } from "../calendar";
import { Popover, PopoverContent, PopoverTrigger } from "../popover";
type DateRangePickerProps = React.HTMLAttributes<HTMLDivElement> & {
value?: DateRange;
defaultValue?: DateRange;
disabled?: boolean;
onValueChange?: (date: DateRange | undefined) => void;
};
type DateRangePickerProps = React.HTMLAttributes<HTMLDivElement> &
React.ComponentProps<typeof DayPicker> & {
value?: DateRange;
defaultValue?: DateRange;
disabled?: boolean;
onValueChange?: (date: DateRange | undefined) => void;
};
export function DateRangePicker({
value,
@@ -24,6 +25,7 @@ export function DateRangePicker({
className,
children,
onValueChange,
...props
}: DateRangePickerProps) {
const [dateState, setDateState] = useState<DateRange | undefined>(
defaultValue,
@@ -77,7 +79,7 @@ export function DateRangePicker({
<div>
{children}
<Calendar
initialFocus
{...props}
mode="range"
defaultMonth={dateValue?.from}
selected={dateValue}