"use client"; /** * pop-string-list 디자이너 미리보기 * * 디자인 모드에서 캔버스에 표시되는 간략한 미리보기. * 실제 데이터는 가져오지 않고 더미 데이터로 레이아웃만 시각화. */ import type { PopStringListConfig } from "./types"; interface PopStringListPreviewProps { config?: PopStringListConfig; } export function PopStringListPreviewComponent({ config, }: PopStringListPreviewProps) { const displayMode = config?.displayMode || "list"; const header = config?.header; const tableName = config?.dataSource?.tableName; const listColumns = config?.listColumns || []; const cardGrid = config?.cardGrid; // 테이블 미선택 if (!tableName) { return (
테이블을 선택하세요
); } return (
{/* 헤더 */} {header?.enabled && (
{header.label || "리스트 목록"}
)} {/* 모드별 미리보기 */}
{displayMode === "list" ? ( ) : ( )}
{/* 모드 라벨 */}
{displayMode === "list" ? "리스트" : "카드"} | {tableName}
); } // ===== 리스트 미리보기 ===== function ListPreview({ columns, }: { columns: PopStringListConfig["listColumns"]; }) { const cols = columns || []; if (cols.length === 0) { return (
컬럼 미설정
); } const gridCols = cols.map((c) => c.width || "1fr").join(" "); const dummyRows = 3; return (
{/* 헤더 */}
{cols.map((col) => (
{col.label}
))}
{/* 더미 행 */} {Array.from({ length: dummyRows }).map((_, i) => (
{cols.map((col) => (
))}
))}
); } // ===== 카드 미리보기 ===== function CardPreview({ cardGrid, }: { cardGrid: PopStringListConfig["cardGrid"]; }) { if (!cardGrid || cardGrid.cells.length === 0) { return (
카드 레이아웃 미설정
); } // 더미 카드 2장 return (
{[0, 1].map((i) => (
{cardGrid.cells.map((cell) => (
))}
))}
); }