import React, { useState, createContext, useContext } from 'react'; interface TabsContextType { activeTab: string; setActiveTab: (tab: string) => void; } const TabsContext = createContext(null); interface TabsProps { defaultValue: string; children: React.ReactNode; className?: string; } export function Tabs({ defaultValue, children, className = '' }: TabsProps) { const [activeTab, setActiveTab] = useState(defaultValue); return (
{children}
); } interface TabsListProps { children: React.ReactNode; className?: string; } export function TabsList({ children, className = '' }: TabsListProps) { return (
{children}
); } interface TabsTriggerProps { value: string; children: React.ReactNode; className?: string; } export function TabsTrigger({ value, children, className = '' }: TabsTriggerProps) { const context = useContext(TabsContext); if (!context) throw new Error('TabsTrigger must be used within Tabs'); const isActive = context.activeTab === value; return ( ); } interface TabsContentProps { value: string; children: React.ReactNode; className?: string; } export function TabsContent({ value, children, className = '' }: TabsContentProps) { const context = useContext(TabsContext); if (!context) throw new Error('TabsContent must be used within Tabs'); if (context.activeTab !== value) return null; return (
{children}
); }