"use client"; import * as TabsPrimitive from "@radix-ui/react-tabs"; import { AnimatePresence, type HTMLMotionProps, motion, type Transition, } from "motion/react"; import * as React from "react"; import { AutoHeight } from "@/components/ui/auto-height"; import { Highlight, HighlightItem, type HighlightItemProps, type HighlightProps, } from "@/components/ui/highlight"; import { useControlledState } from "@/hooks/use-controlled-state"; import { getStrictContext } from "@/lib/get-strict-context"; import { cn } from "@/lib/utils"; type TabsContextType = { value: string | undefined; setValue: TabsProps["onValueChange"]; }; const [TabsProvider, useTabs] = getStrictContext("TabsContext"); type TabsProps = React.ComponentProps; function Tabs(props: TabsProps) { const [value, setValue] = useControlledState({ value: props.value, defaultValue: props.defaultValue, onChange: props.onValueChange, }); return ( ); } type TabsHighlightProps = Omit; function TabsHighlight({ transition = { type: "spring", stiffness: 200, damping: 25 }, ...props }: TabsHighlightProps) { const { value } = useTabs(); return ( ); } type TabsListProps = React.ComponentProps; const TabsList = React.forwardRef< React.ElementRef, TabsListProps >(({ className, ...props }, ref) => ( )); TabsList.displayName = TabsPrimitive.List.displayName; type TabsHighlightItemProps = HighlightItemProps & { value: string; }; function TabsHighlightItem(props: TabsHighlightItemProps) { return ; } type TabsTriggerProps = React.ComponentProps; const TabsTrigger = React.forwardRef< React.ElementRef, TabsTriggerProps >(({ className, ...props }, ref) => ( )); TabsTrigger.displayName = TabsPrimitive.Trigger.displayName; type TabsContentProps = React.ComponentProps & HTMLMotionProps<"div">; function TabsContent({ value, forceMount, transition = { duration: 0.5, ease: "easeInOut" }, className, ...props }: TabsContentProps) { return ( ); } type TabsContentsAutoProps = React.ComponentProps & { mode?: "auto-height"; children: React.ReactNode; transition?: Transition; }; type TabsContentsLayoutProps = Omit, "transition"> & { mode: "layout"; children: React.ReactNode; transition?: Transition; }; type TabsContentsProps = TabsContentsAutoProps | TabsContentsLayoutProps; const defaultTransition: Transition = { type: "spring", stiffness: 200, damping: 30, }; function isAutoMode(props: TabsContentsProps): props is TabsContentsAutoProps { return !("mode" in props) || props.mode === "auto-height"; } function TabsContents(props: TabsContentsProps) { const { value } = useTabs(); if (isAutoMode(props)) { const { transition = defaultTransition, ...autoProps } = props; return ( ); } const { transition = defaultTransition, style, ...layoutProps } = props; return ( ); } export { Tabs, TabsHighlight, TabsHighlightItem, TabsList, TabsTrigger, TabsContent, TabsContents, type TabsProps, type TabsHighlightProps, type TabsHighlightItemProps, type TabsListProps, type TabsTriggerProps, type TabsContentProps, type TabsContentsProps, };