"use client"; /** * pop-card-list 디자인 모드 미리보기 컴포넌트 (V2) * * 디자이너 캔버스에서 표시되는 미리보기 * 이미지 참조 기반 카드 구조 반영 */ import React from "react"; import { LayoutGrid, Package } from "lucide-react"; import type { PopCardListConfig } from "../types"; import { CARD_LAYOUT_MODE_LABELS, CARD_SIZE_LABELS, DEFAULT_CARD_IMAGE, } from "../types"; interface PopCardListPreviewProps { config?: PopCardListConfig; } export function PopCardListPreviewComponent({ config, }: PopCardListPreviewProps) { const layoutMode = config?.layoutMode || "grid"; const cardSize = config?.cardSize || "medium"; const cardsPerRow = config?.cardsPerRow || 3; const dataSource = config?.dataSource; const template = config?.cardTemplate; // 설정 상태 확인 const hasTable = !!dataSource?.tableName; const hasHeader = !!template?.header?.codeField || !!template?.header?.titleField; const hasImage = template?.image?.enabled ?? true; const fieldCount = template?.body?.fields?.length || 0; // 샘플 카드 개수 (미리보기용) const sampleCardCount = layoutMode === "grid" ? Math.min(cardsPerRow, 3) : 2; return (
{/* 헤더 */}
카드 목록
{/* 설정 배지 */}
{CARD_LAYOUT_MODE_LABELS[layoutMode]} {CARD_SIZE_LABELS[cardSize]}
{/* 테이블 미선택 시 안내 */} {!hasTable ? (

데이터 소스를 설정하세요

) : ( <> {/* 테이블 정보 */}
{dataSource.tableName}
{/* 카드 미리보기 */}
{Array.from({ length: sampleCardCount }).map((_, idx) => ( ))}
{/* 필드 정보 */} {fieldCount > 0 && (
{fieldCount}개 필드 설정됨
)} )}
); } // ===== 미리보기 카드 컴포넌트 ===== function PreviewCard({ index, hasHeader, hasImage, fieldCount, cardSize, layoutMode, }: { index: number; hasHeader: boolean; hasImage: boolean; fieldCount: number; cardSize: string; layoutMode: string; }) { // 카드 크기 const sizeClass = cardSize === "small" ? "min-h-[60px]" : cardSize === "large" ? "min-h-[100px]" : "min-h-[80px]"; const widthClass = layoutMode === "vertical" ? "w-full" : layoutMode === "horizontal" ? "min-w-[140px] flex-shrink-0" : "w-[140px]"; return (
{/* 헤더 */} {hasHeader && (
)} {/* 본문 */}
{/* 이미지 */} {hasImage && (
)} {/* 필드 목록 */}
{fieldCount > 0 ? ( Array.from({ length: Math.min(fieldCount, 3) }).map((_, i) => (
)) ) : (
필드 추가
)}
); }