'use client';
import { ChevronLeft, ChevronRight } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { cn } from '@/components/ui/utils';
import type { CalendarHeaderProps, CalendarView } from './types';
import { formatYearMonth } from './utils';
/**
* 달력 헤더 컴포넌트
* - 년월 표시 및 네비게이션 (◀ ▶)
* - 주/월 뷰 전환 탭
* - 필터 slot (children으로 외부 주입)
*/
export function CalendarHeader({
currentDate,
view,
onPrevMonth,
onNextMonth,
onViewChange,
titleSlot,
filterSlot,
}: CalendarHeaderProps) {
const views: { value: CalendarView; label: string }[] = [
{ value: 'week', label: '주' },
{ value: 'month', label: '월' },
];
return (
{/* PC: 타이틀 + 네비게이션 | 뷰전환 + 필터 (한 줄) */}
{/* 모바일: 타이틀 / 네비게이션 + 뷰전환 / 필터 (세 줄) */}
{/* 1줄(모바일) / 좌측(PC): 타이틀 */}
{titleSlot && (
{titleSlot}
)}
{/* 2줄(모바일) / 전체(PC): 네비게이션 + 뷰전환 + 필터 */}
{/* 좌측: (PC에서만 타이틀) + 네비게이션 */}
{titleSlot && (
{titleSlot}
)}
{formatYearMonth(currentDate)}
{/* 모바일: 뷰 전환 탭 (네비게이션 옆) */}
{views.map((v) => (
))}
{/* 우측(PC만): 뷰 전환 + 필터 */}
{views.map((v) => (
))}
{filterSlot &&
{filterSlot}
}
{/* 3줄(모바일만): 필터 */}
{filterSlot && (
{filterSlot}
)}
);
}