"use client";
/**
* pop-card-list 디자인 모드 미리보기 컴포넌트 (V2)
*
* 디자이너 캔버스에서 표시되는 미리보기
* 이미지 참조 기반 카드 구조 반영
*/
import React from "react";
import { LayoutGrid, Package } from "lucide-react";
import type { PopCardListConfig } from "../types";
import {
CARD_SCROLL_DIRECTION_LABELS,
CARD_SIZE_LABELS,
DEFAULT_CARD_IMAGE,
} from "../types";
interface PopCardListPreviewProps {
config?: PopCardListConfig;
}
export function PopCardListPreviewComponent({
config,
}: PopCardListPreviewProps) {
const scrollDirection = config?.scrollDirection || "vertical";
const cardSize = config?.cardSize || "medium";
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 = 2;
return (
{/* 헤더 */}
카드 목록
{/* 설정 배지 */}
{CARD_SCROLL_DIRECTION_LABELS[scrollDirection]}
{CARD_SIZE_LABELS[cardSize]}
{/* 테이블 미선택 시 안내 */}
{!hasTable ? (
) : (
<>
{/* 테이블 정보 */}
{dataSource.tableName}
{/* 카드 미리보기 */}
{Array.from({ length: sampleCardCount }).map((_, idx) => (
))}
{/* 필드 정보 */}
{fieldCount > 0 && (
{fieldCount}개 필드 설정됨
)}
>
)}
);
}
// ===== 미리보기 카드 컴포넌트 =====
function PreviewCard({
index,
hasHeader,
hasImage,
fieldCount,
cardSize,
scrollDirection,
}: {
index: number;
hasHeader: boolean;
hasImage: boolean;
fieldCount: number;
cardSize: string;
scrollDirection: string;
}) {
const sizeClass =
cardSize === "small"
? "min-h-[60px]"
: cardSize === "large"
? "min-h-[100px]"
: "min-h-[80px]";
const widthClass =
scrollDirection === "vertical"
? "w-full"
: "min-w-[140px] flex-shrink-0";
return (
{/* 헤더 */}
{hasHeader && (
)}
{/* 본문 */}
{/* 이미지 */}
{hasImage && (
)}
{/* 필드 목록 */}
{fieldCount > 0 ? (
Array.from({ length: Math.min(fieldCount, 3) }).map((_, i) => (
))
) : (
필드 추가
)}
);
}