'use client'; import * as React from 'react'; import * as ToolbarPrimitive from '@radix-ui/react-toolbar'; import * as TooltipPrimitive from '@radix-ui/react-tooltip'; import { type VariantProps, cva } from 'class-variance-authority'; import { ChevronDown } from 'lucide-react'; import { DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuSeparator, } from '@/components/ui/dropdown-menu'; import { Separator } from '@/components/ui/separator'; import { Tooltip, TooltipTrigger } from '@/components/ui/tooltip'; import { cn } from '@/lib/utils'; export function Toolbar({ className, ...props }: React.ComponentProps) { return ( ); } export function ToolbarToggleGroup({ className, ...props }: React.ComponentProps) { return ( ); } export function ToolbarLink({ className, ...props }: React.ComponentProps) { return ( ); } export function ToolbarSeparator({ className, ...props }: React.ComponentProps) { return ( ); } // From toggleVariants const toolbarButtonVariants = cva( "inline-flex cursor-pointer items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none hover:bg-muted hover:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-checked:bg-accent aria-checked:text-accent-foreground aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", { defaultVariants: { size: 'default', variant: 'default', }, variants: { size: { default: 'h-9 min-w-9 px-2', lg: 'h-10 min-w-10 px-2.5', sm: 'h-8 min-w-8 px-1.5', }, variant: { default: 'bg-transparent', outline: 'border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground', }, }, } ); const dropdownArrowVariants = cva( cn( 'inline-flex items-center justify-center rounded-r-md text-sm font-medium text-foreground transition-colors disabled:pointer-events-none disabled:opacity-50' ), { defaultVariants: { size: 'sm', variant: 'default', }, variants: { size: { default: 'h-9 w-6', lg: 'h-10 w-8', sm: 'h-8 w-4', }, variant: { default: 'bg-transparent hover:bg-muted hover:text-muted-foreground aria-checked:bg-accent aria-checked:text-accent-foreground', outline: 'border border-l-0 border-input bg-transparent hover:bg-accent hover:text-accent-foreground', }, }, } ); type ToolbarButtonProps = { isDropdown?: boolean; pressed?: boolean; } & Omit< React.ComponentPropsWithoutRef, 'asChild' | 'value' > & VariantProps; export const ToolbarButton = withTooltip(function ToolbarButton({ children, className, isDropdown, pressed, size = 'sm', variant, ...props }: ToolbarButtonProps) { return typeof pressed === 'boolean' ? ( {isDropdown ? ( <>
{children}
) : ( children )}
) : ( {children} ); }); export function ToolbarSplitButton({ className, ...props }: React.ComponentPropsWithoutRef) { return ( ); } type ToolbarSplitButtonPrimaryProps = Omit< React.ComponentPropsWithoutRef, 'value' > & VariantProps; export function ToolbarSplitButtonPrimary({ children, className, size = 'sm', variant, ...props }: ToolbarSplitButtonPrimaryProps) { return ( {children} ); } export function ToolbarSplitButtonSecondary({ className, size, variant, ...props }: React.ComponentPropsWithoutRef<'span'> & VariantProps) { return ( e.stopPropagation()} role="button" {...props} > ); } export function ToolbarToggleItem({ className, size = 'sm', variant, ...props }: React.ComponentProps & VariantProps) { return ( ); } export function ToolbarGroup({ children, className, }: React.ComponentProps<'div'>) { return ( ); } type TooltipProps = { tooltip?: React.ReactNode; tooltipContentProps?: Omit< React.ComponentPropsWithoutRef, 'children' >; tooltipProps?: Omit< React.ComponentPropsWithoutRef, 'children' >; tooltipTriggerProps?: React.ComponentPropsWithoutRef; } & React.ComponentProps; function withTooltip(Component: T) { return function ExtendComponent({ tooltip, tooltipContentProps, tooltipProps, tooltipTriggerProps, ...props }: TooltipProps) { const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); const component = )} />; if (tooltip && mounted) { return ( {component} {tooltip} ); } return component; }; } function TooltipContent({ children, className, // CHANGE sideOffset = 4, ...props }: React.ComponentProps) { return ( {children} {/* CHANGE */} {/* */} ); } export function ToolbarMenuGroup({ children, className, label, ...props }: React.ComponentProps & { label?: string }) { return ( <> {label && ( {label} )} {children} ); }