"use client" import * as React from "react" import { cn } from "@/lib/utils" const TabsContext = React.createContext<{ value: string onValueChange: (value: string) => void } | null>(null) interface TabsProps { value: string onValueChange: (value: string) => void children: React.ReactNode className?: string } const Tabs = React.forwardRef( ({ className, value, onValueChange, children, ...props }, ref) => { return (
{children}
) } ) Tabs.displayName = "Tabs" interface TabsListProps { children: React.ReactNode className?: string } const TabsList = React.forwardRef( ({ className, children, ...props }, ref) => { return (
{children}
) } ) TabsList.displayName = "TabsList" interface TabsTriggerProps { value: string children: React.ReactNode className?: string } const TabsTrigger = React.forwardRef( ({ className, children, value, ...props }, ref) => { const context = React.useContext(TabsContext) if (!context) { throw new Error("TabsTrigger must be used within Tabs") } const { value: currentValue, onValueChange } = context const isActive = currentValue === value return ( ) } ) TabsTrigger.displayName = "TabsTrigger" interface TabsContentProps { value: string children: React.ReactNode className?: string } const TabsContent = React.forwardRef( ({ className, children, value, ...props }, ref) => { const context = React.useContext(TabsContext) if (!context) { throw new Error("TabsContent must be used within Tabs") } const { value: currentValue } = context if (currentValue !== value) { return null } return (
{children}
) } ) TabsContent.displayName = "TabsContent" export { Tabs, TabsList, TabsTrigger, TabsContent }