"use client";
/**
* shared.tsx — 모달 내부 공통 UI 헬퍼 컴포넌트
*
* Section, TabContent, Field, FieldGroup, Grid, InfoBox, PreviewPanel 등
* 모든 컴포넌트 설정 모달에서 일관된 UI를 유지하기 위한 빌딩 블록.
*/
import React, { type ReactNode } from "react";
import { cn } from "@/lib/utils";
import { Label } from "@/components/ui/label";
// ─── 섹션 컨테이너 ────────────────────────────────────────────────────────────
interface SectionProps {
emphasis?: boolean;
icon?: ReactNode;
title?: string;
children: ReactNode;
className?: string;
}
export function Section({
emphasis = false,
icon,
title,
children,
className,
}: SectionProps) {
return (
{(icon || title) && (
{icon && (
{icon}
)}
{title && (
{title}
)}
)}
{children}
);
}
// ─── 탭 콘텐츠 래퍼 ──────────────────────────────────────────────────────────
interface TabContentProps {
children: ReactNode;
className?: string;
}
export function TabContent({ children, className }: TabContentProps) {
return (
{children}
);
}
// ─── 폼 필드 래퍼 ────────────────────────────────────────────────────────────
interface FieldProps {
label: string;
help?: string;
children: ReactNode;
className?: string;
htmlFor?: string;
}
export function Field({ label, help, children, className, htmlFor }: FieldProps) {
return (
{children}
{help && (
{help}
)}
);
}
// ─── 2/3열 그리드 ─────────────────────────────────────────────────────────────
interface GridProps {
children: ReactNode;
cols?: 2 | 3;
className?: string;
}
export function Grid({ children, cols = 2, className }: GridProps) {
return (
{children}
);
}
// ─── 필드 그룹 (space-y-3) ───────────────────────────────────────────────────
interface FieldGroupProps {
children: ReactNode;
className?: string;
}
export function FieldGroup({ children, className }: FieldGroupProps) {
return (
{children}
);
}
// ─── 인라인 정보 박스 ─────────────────────────────────────────────────────────
interface InfoBoxProps {
children: ReactNode;
variant?: "blue" | "gray";
}
export function InfoBox({ children, variant = "blue" }: InfoBoxProps) {
return (
{children}
);
}
// ─── 미리보기 패널 ────────────────────────────────────────────────────────────
interface PreviewPanelProps {
children?: ReactNode;
label?: string;
height?: string;
}
export function PreviewPanel({
children,
label = "미리보기",
height = "h-48",
}: PreviewPanelProps) {
return (
{children ? (
{children}
) : (
)}
);
}