"use client"; import React from "react"; import { cn } from "@/lib/utils"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; export interface SectionCardProps { component?: { id: string; componentConfig?: { title?: string; description?: string; showHeader?: boolean; headerPosition?: "top" | "left"; padding?: "none" | "sm" | "md" | "lg"; backgroundColor?: "default" | "muted" | "transparent"; borderStyle?: "solid" | "dashed" | "none"; collapsible?: boolean; defaultOpen?: boolean; }; style?: React.CSSProperties; }; children?: React.ReactNode; className?: string; onClick?: (e?: React.MouseEvent) => void; isSelected?: boolean; isDesignMode?: boolean; } /** * Section Card 컴포넌트 * 제목과 테두리가 있는 명확한 그룹화 컨테이너 */ export function SectionCardComponent({ component, children, className, onClick, isSelected = false, isDesignMode = false, }: SectionCardProps) { const config = component?.componentConfig || {}; const [isOpen, setIsOpen] = React.useState(config.defaultOpen !== false); // 🔄 실시간 업데이트를 위해 config에서 직접 읽기 const title = config.title || ""; const description = config.description || ""; const showHeader = config.showHeader !== false; // 기본값: true const padding = config.padding || "md"; const backgroundColor = config.backgroundColor || "default"; const borderStyle = config.borderStyle || "solid"; const collapsible = config.collapsible || false; // 🎯 디버깅: config 값 확인 React.useEffect(() => { console.log("✅ Section Card Config:", { title, description, showHeader, fullConfig: config, }); }, [config.title, config.description, config.showHeader]); // 패딩 매핑 const paddingMap = { none: "p-0", sm: "p-3", md: "p-6", lg: "p-8", }; // 배경색 매핑 const backgroundColorMap = { default: "bg-card", muted: "bg-muted/30", transparent: "bg-transparent", }; // 테두리 스타일 매핑 const borderStyleMap = { solid: "border-solid", dashed: "border-dashed", none: "border-none", }; const handleToggle = () => { if (collapsible) { setIsOpen(!isOpen); } }; return ( {/* 헤더 */} {showHeader && (title || description || isDesignMode) && (
{(title || isDesignMode) && ( {title || (isDesignMode ? "섹션 제목" : "")} )} {(description || isDesignMode) && ( {description || (isDesignMode ? "섹션 설명 (선택사항)" : "")} )}
{collapsible && (
)}
)} {/* 컨텐츠 */} {(!collapsible || isOpen) && ( {/* 디자인 모드에서 빈 상태 안내 */} {isDesignMode && !children && (
🃏 Section Card
컴포넌트를 이곳에 배치하세요
)} {/* 자식 컴포넌트들 */} {children}
)}
); }