"use client"; /** * V2ComponentRenderer * * V2 컴포넌트를 동적으로 렌더링하는 컴포넌트 * props.v2Type에 따라 적절한 컴포넌트를 렌더링 */ import React, { forwardRef, useMemo } from "react"; import { V2ComponentProps, isV2Input, isV2Select, isV2Date, isV2Text, isV2Media, isV2List, isV2Layout, isV2Group, isV2Biz, isV2Hierarchy, } from "@/types/v2-components"; import { V2Input } from "./V2Input"; import { V2Select } from "./V2Select"; import { V2Date } from "./V2Date"; import { V2List } from "./V2List"; import { V2Layout } from "./V2Layout"; import { V2Group } from "./V2Group"; import { V2Media } from "./V2Media"; import { V2Biz } from "./V2Biz"; import { V2Hierarchy } from "./V2Hierarchy"; interface V2ComponentRendererProps { props: V2ComponentProps; className?: string; } /** * V2 컴포넌트 렌더러 */ export const V2ComponentRenderer = forwardRef( ({ props, className }, ref) => { const component = useMemo(() => { // 타입 가드를 사용하여 적절한 컴포넌트 렌더링 if (isV2Input(props)) { return ; } if (isV2Select(props)) { return ; } if (isV2Date(props)) { return ; } if (isV2Text(props)) { // V2Text는 V2Input의 textarea 모드로 대체 // 필요시 별도 구현 return (
V2Text (V2Input textarea 모드 사용 권장)
); } if (isV2Media(props)) { return ; } if (isV2List(props)) { return ; } if (isV2Layout(props)) { return ; } if (isV2Group(props)) { return ; } if (isV2Biz(props)) { return ; } if (isV2Hierarchy(props)) { return ; } // 알 수 없는 타입 return (
알 수 없는 컴포넌트 타입: {(props as { v2Type?: string }).v2Type}
); }, [props]); return (
{component}
); } ); V2ComponentRenderer.displayName = "V2ComponentRenderer"; export default V2ComponentRenderer;