"use client"; import { ReactNode } from "react"; import { Checkbox } from "@/components/ui/checkbox"; import { Separator } from "@/components/ui/separator"; /** * 목록 모바일 카드 컴포넌트 * * 모바일 환경에서 사용하는 공통 목록 카드 컴포넌트입니다. * 체크박스, 헤더, 뱃지, 정보 그리드, 액션 버튼을 포함합니다. * * @example * ```tsx * handleToggle("item-1")} * onCardClick={() => handleView("item-1")} * headerBadges={[ * #{1}, * Q2024-001 * ]} * title="ABC건설" * statusBadge={} * infoGrid={ *
* * *
* } * actions={isSelected && } * /> * ``` */ export interface ListMobileCardProps { /** 아이템 고유 ID */ id: string; /** 선택 상태 */ isSelected: boolean; /** 체크박스 토글 핸들러 */ onToggleSelection: () => void; /** 카드 클릭 핸들러 */ onCardClick?: () => void; /** 카드 클릭 핸들러 (onCardClick 별칭) */ onClick?: () => void; /** 체크박스 표시 여부 */ showCheckbox?: boolean; /** 헤더 영역 뱃지들 (번호, 코드 등) */ headerBadges?: ReactNode; /** 카드 제목 (주요 정보) */ title: string | ReactNode; /** 상태 뱃지 (우측 상단) */ statusBadge?: ReactNode; /** 정보 그리드 영역 */ infoGrid: ReactNode; /** 액션 버튼 영역 */ actions?: ReactNode; /** 추가 className */ className?: string; /** 카드 상단 추가 콘텐츠 */ topContent?: ReactNode; /** 카드 하단 추가 콘텐츠 */ bottomContent?: ReactNode; } /** * 정보 필드 컴포넌트 * * 카드 내부의 레이블-값 쌍을 표시합니다. */ export interface InfoFieldProps { label: string; value: string | number | ReactNode; valueClassName?: string; /** 추가 className */ className?: string; } export function InfoField({ label, value, valueClassName = "", className = "" }: InfoFieldProps) { return (

{label}

{value}
); } export function ListMobileCard({ id, isSelected, onToggleSelection, onCardClick, onClick, showCheckbox = true, headerBadges, title, statusBadge, infoGrid, actions, className = "", topContent, bottomContent }: ListMobileCardProps) { const handleCardClick = onClick || onCardClick; return (
{/* 상단 추가 콘텐츠 */} {topContent} {/* 헤더: 체크박스 + 뱃지 + 제목 / 우측에 상태 뱃지 */}
{showCheckbox && ( e.stopPropagation()} className="mt-0.5 h-5 w-5" /> )}
{/* 헤더 뱃지들 (번호, 코드 등) */} {headerBadges && (
{headerBadges}
)} {/* 제목 */}

{title}

{/* 우측 상단: 상태 뱃지 */} {statusBadge && (
{statusBadge}
)}
{/* 구분선 */} {/* 정보 그리드 */} {infoGrid} {/* 액션 버튼 - 선택된 경우만 표시 */} {actions && ( <> {actions} )} {/* 하단 추가 콘텐츠 */} {bottomContent}
); }