"use client"; import React from "react"; import { ComponentData } from "@/types/screen"; import { componentRegistry, ComponentRenderer } from "../DynamicComponentRenderer"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; // 탭 컴포넌트 렌더러 const TabsRenderer: ComponentRenderer = ({ component, children, ...props }) => { const config = component.componentConfig || {}; const { tabs = [ { id: "tab1", label: "탭 1", content: "첫 번째 탭 내용" }, { id: "tab2", label: "탭 2", content: "두 번째 탭 내용" }, { id: "tab3", label: "탭 3", content: "세 번째 탭 내용" }, ], defaultTab = "tab1", orientation = "horizontal", // horizontal, vertical style = {}, } = config; return (
{tabs.map((tab: any) => ( {tab.label} ))} {tabs.map((tab: any) => ( {children && React.Children.count(children) > 0 ? ( children ) : (
{tab.content}
탭 내용 영역
)}
))}
); }; // 레지스트리에 등록 componentRegistry.register("tabs", TabsRenderer); componentRegistry.register("tabs-horizontal", TabsRenderer); export { TabsRenderer };