import { useAutoAnimate } from "@formkit/auto-animate/react"; import { Slot } from "@radix-ui/react-slot"; import cn from "../../classNames"; import type { IconName } from "../icon"; import { Icon as IconComponent } from "../icon"; const Root = ({ children, ref, className, }: { children: React.ReactNode; ref?: React.Ref; className?: string; }) => { const [animateRef] = useAutoAnimate(); return (
{children}
); }; const Title = ({ children, ref, as, }: { children: React.ReactNode; ref?: React.Ref; as?: React.ElementType; }) => { const Component = as ? Slot : "h2"; return ( {children} ); }; const Description = ({ children, ref, as, }: { children: React.ReactNode; ref?: React.Ref; as?: React.ElementType; }) => { const Component = as ? Slot : "h3"; return ( {children} ); }; const Icon = ({ ref, name, size = "md", iconSlot, }: { ref?: React.Ref; size?: "sm" | "md"; name?: IconName; iconSlot?: React.ReactNode; } & ({ name: IconName; iconSlot?: never } | { name?: never; iconSlot: React.ReactNode })) => { return (
{iconSlot ? ( iconSlot ) : ( )}
); }; const Header = ({ children, ref, icon, title, description, iconSlot, rawHeading, }: { children?: React.ReactNode; ref?: React.Ref; icon?: IconName; iconSlot?: React.ReactNode; title?: string; description?: string; rawHeading?: React.ReactNode; }) => { return (
{icon && !iconSlot && } {iconSlot && }
{title && {title}} {description && {description}} {rawHeading && rawHeading}
{children}
); }; const Content = ({ children, ref }: { children: React.ReactNode; ref?: React.Ref }) => { return (
{children}
); }; const SubSection = ({ children, ref }: { children: React.ReactNode; ref?: React.Ref }) => { const [animateRef] = useAutoAnimate(); return (
{children}
); }; const SubSectionHeader = ({ children, ref, icon, title, classNames, justify = "between", labelFor, }: { children: React.ReactNode; icon?: IconName; title: string; labelFor?: string; classNames?: { container?: string; title?: string; description?: string; }; ref?: React.Ref; justify?: "between" | "start"; }) => { return (
{icon && }

{title}

{children}
); }; const SubSectionContent = ({ children, ref, invert, classNames, }: { children: React.ReactNode; ref?: React.Ref; classNames?: { container?: string; }; invert?: boolean; }) => { return (
{children}
); }; const SubSectionNested = ({ children, ref, }: { children: React.ReactNode; ref?: React.Ref; }) => { return (
{children}
); }; export const Section = Object.assign(Root, { Header: Header, Content: Content, Title: Title, Description: Description, SubSection: SubSection, SubSectionHeader: SubSectionHeader, SubSectionContent: SubSectionContent, SubSectionNested: SubSectionNested, });