import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"; import { cva, type VariantProps } from "class-variance-authority"; import * as React from "react"; import { ChevronDownIcon, ChevronRightIcon } from "@sparkle/icons/app"; import { cn } from "@sparkle/lib/utils"; import { Icon } from "./Icon"; const labelVariants = cva( "s-inline-flex s-transition-colors s-ease-out s-duration-400 s-box-border s-gap-x-2 s-select-none s-text-sm", { variants: { variant: { primary: "s-text-highlight-600 dark:s-text-highlight-600-night", secondary: "s-text-foreground dark:s-text-foreground-night", }, disabled: { true: "s-text-muted dark:s-text-muted-night", false: "group-hover/col:s-text-highlight-500 dark:group-hover/col:s-text-highlight-500-night active:s-text-highlight-700 dark:active:s-text-highlight-700-night", }, }, defaultVariants: { variant: "primary", disabled: false, }, } ); const chevronVariants = cva("s-transition-transform s-duration-150", { variants: { variant: { primary: "s-text-muted-foreground dark:s-text-muted-foreground-night", secondary: "s-text-muted-foreground dark:s-text-muted-foreground-night", }, disabled: { true: "s-text-muted dark:s-text-muted-night", false: "group-hover/col:s-text-highlight-500 dark:group-hover/col:s-text-highlight-500-night active:s-text-highlight-700 dark:active:s-text-highlight-700-night", }, }, defaultVariants: { variant: "primary", disabled: false, }, }); export interface CollapsibleProps extends CollapsiblePrimitive.CollapsibleProps { children: React.ReactNode; className?: string; } const Collapsible = React.forwardRef< React.ElementRef, CollapsibleProps >(({ children, className, ...props }, ref) => ( {children} )); Collapsible.displayName = "Collapsible"; export interface CollapsibleTriggerProps extends React.ComponentPropsWithoutRef, Omit, "disabled"> { label?: string; hideChevron?: boolean; } const CollapsibleTrigger = React.forwardRef< React.ElementRef, CollapsibleTriggerProps >( ( { label, children, className, disabled = false, hideChevron = false, variant = "primary", ...props }, ref ) => { return ( {!hideChevron && ( )} {children ?? ( {label} )} ); } ); CollapsibleTrigger.displayName = "CollapsibleTrigger"; const contentVariants = cva("s-overflow-hidden s-transition-all", { variants: { variant: { default: "s-text-foreground dark:s-text-foreground-night", }, }, defaultVariants: { variant: "default", }, }); export interface CollapsibleContentProps extends React.ComponentPropsWithoutRef, VariantProps {} const CollapsibleContent = React.forwardRef< React.ElementRef, CollapsibleContentProps >(({ children, className, variant, ...props }, ref) => ( {children} )); CollapsibleContent.displayName = "CollapsibleContent"; export { Collapsible, CollapsibleContent, CollapsibleTrigger };