Files
invyone/frontend/components/v2/V2ComponentRenderer.tsx
DDD1542 4a8413000b
Build & Deploy to K8s / build-and-deploy (push) Failing after 11m17s
Consolidate canonical input migration
Remove legacy v2 input/select and file/media runtimes, add canonical option/file loaders, and document Codex handoff.
2026-05-12 18:36:43 +09:00

92 lines
2.4 KiB
TypeScript

"use client";
/**
* V2ComponentRenderer
*
* V2 컴포넌트를 동적으로 렌더링하는 컴포넌트
* props.v2Type에 따라 적절한 컴포넌트를 렌더링
*/
import React, { forwardRef, useMemo } from "react";
import {
V2ComponentProps,
isV2Text,
isV2List,
isV2Layout,
isV2Group,
isV2Biz,
isV2Hierarchy,
} from "@/types/v2-components";
// 옛 입력/선택 import 는 Phase D.3 에서 제거. V2Media 는 Phase D.5 에서 제거 — canonical input 으로 흡수.
import { V2List } from "./V2List";
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 분기로 흡수.
if (isV2List(props)) {
return <V2List {...props} />;
}
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;