"use client"; import { useDrag } from "react-dnd"; import { Type, CreditCard, Minus, Tag, ImageIcon, Hash, Calendar, Link2, Circle, Space, FileText, } from "lucide-react"; import type { CardElementType } from "@/types/report"; interface CardElementItem { type: CardElementType; label: string; icon: React.ReactNode; } const CARD_ELEMENTS: CardElementItem[] = [ { type: "header", label: "헤더", icon: }, { type: "dataCell", label: "데이터 셀", icon: }, { type: "divider", label: "구분선", icon: }, { type: "badge", label: "뱃지", icon: }, { type: "image", label: "이미지", icon: }, { type: "number", label: "숫자/금액", icon: }, { type: "date", label: "날짜", icon: }, { type: "link", label: "링크", icon: }, { type: "status", label: "상태", icon: }, { type: "spacer", label: "빈 공간", icon: }, { type: "staticText", label: "고정 텍스트", icon: }, ]; export const CARD_ELEMENT_DND_TYPE = "card-element"; interface DraggableElementProps { type: CardElementType; label: string; icon: React.ReactNode; } function DraggableElement({ type, label, icon }: DraggableElementProps) { const [{ isDragging }, drag] = useDrag(() => ({ type: CARD_ELEMENT_DND_TYPE, item: { elementType: type }, collect: (monitor) => ({ isDragging: monitor.isDragging(), }), })); return (
{icon}
{label}
); } export function CardElementPalette() { return (
요소 팔레트 드래그하여 추가
{CARD_ELEMENTS.map((item) => ( ))}
); }