88 lines
2.4 KiB
TypeScript
88 lines
2.4 KiB
TypeScript
"use client";
|
|
|
|
/**
|
|
* V2ComponentRenderer
|
|
*
|
|
* V2 컴포넌트를 동적으로 렌더링하는 컴포넌트
|
|
* props.v2Type에 따라 적절한 컴포넌트를 렌더링
|
|
*/
|
|
|
|
import React, { forwardRef, useMemo } from "react";
|
|
import {
|
|
V2ComponentProps,
|
|
isV2Text,
|
|
isV2Layout,
|
|
isV2Group,
|
|
isV2Biz,
|
|
isV2Hierarchy,
|
|
} from "@/types/v2-components";
|
|
// 옛 입력/선택 import 는 Phase D.3 에서 제거. V2Media 는 Phase D.5 에서 제거 — canonical input 으로 흡수.
|
|
// V2List 는 Phase F.8 (2026-05-21) 에서 제거 — canonical table 로 흡수.
|
|
import { V2Layout } from "./V2Layout";
|
|
import { V2Group } from "./V2Group";
|
|
import { V2Biz } from "./V2Biz";
|
|
import { V2Hierarchy } from "./V2Hierarchy";
|
|
|
|
interface V2ComponentRendererProps {
|
|
props: V2ComponentProps;
|
|
className?: string;
|
|
}
|
|
|
|
/**
|
|
* V2 컴포넌트 렌더러
|
|
*/
|
|
export const V2ComponentRenderer = forwardRef<HTMLDivElement, V2ComponentRendererProps>(
|
|
({ props, className }, ref) => {
|
|
const component = useMemo(() => {
|
|
// 타입 가드를 사용하여 적절한 컴포넌트 렌더링
|
|
// (옛 입력/선택 분기 — Phase D.3 에서 제거. canonical `input` 으로 흡수됨)
|
|
|
|
if (isV2Text(props)) {
|
|
// V2Text 는 canonical `input` (textarea 모드) 으로 대체. 필요시 별도 구현
|
|
return (
|
|
<div className="p-2 border rounded text-sm text-muted-foreground">
|
|
V2Text (canonical `input` textarea 모드 사용 권장)
|
|
</div>
|
|
);
|
|
}
|
|
|
|
// V2Media — Phase D.5 폐기. canonical input 의 file 분기로 흡수.
|
|
// V2List — Phase F.8 폐기. canonical table 로 흡수.
|
|
|
|
if (isV2Layout(props)) {
|
|
return <V2Layout {...props} />;
|
|
}
|
|
|
|
if (isV2Group(props)) {
|
|
return <V2Group {...props} />;
|
|
}
|
|
|
|
if (isV2Biz(props)) {
|
|
return <V2Biz {...props} />;
|
|
}
|
|
|
|
if (isV2Hierarchy(props)) {
|
|
return <V2Hierarchy {...props} />;
|
|
}
|
|
|
|
// 알 수 없는 타입
|
|
return (
|
|
<div className="p-2 border border-destructive rounded text-sm text-destructive">
|
|
알 수 없는 컴포넌트 타입: {(props as { v2Type?: string }).v2Type}
|
|
</div>
|
|
);
|
|
}, [props]);
|
|
|
|
return (
|
|
<div ref={ref} className={className}>
|
|
{component}
|
|
</div>
|
|
);
|
|
}
|
|
);
|
|
|
|
V2ComponentRenderer.displayName = "V2ComponentRenderer";
|
|
|
|
export default V2ComponentRenderer;
|
|
|