{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toolbar",
  "title": "Toolbar",
  "description": "A customizable toolbar component with various button styles and group",
  "dependencies": [
    "@radix-ui/react-toolbar"
  ],
  "registryDependencies": [
    "tooltip",
    "separator",
    "dropdown-menu"
  ],
  "files": [
    {
      "path": "src/registry/ui/toolbar.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\n\nimport * as ToolbarPrimitive from '@radix-ui/react-toolbar';\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\nimport { type VariantProps, cva } from 'class-variance-authority';\nimport { ChevronDown } from 'lucide-react';\n\nimport {\n  DropdownMenuLabel,\n  DropdownMenuRadioGroup,\n  DropdownMenuSeparator,\n} from '@/components/ui/dropdown-menu';\nimport { Separator } from '@/components/ui/separator';\nimport { Tooltip, TooltipTrigger } from '@/components/ui/tooltip';\nimport { cn } from '@/lib/utils';\n\nexport function Toolbar({\n  className,\n  ...props\n}: React.ComponentProps<typeof ToolbarPrimitive.Root>) {\n  return (\n    <ToolbarPrimitive.Root\n      className={cn('relative flex select-none items-center', className)}\n      {...props}\n    />\n  );\n}\n\nexport function ToolbarToggleGroup({\n  className,\n  ...props\n}: React.ComponentProps<typeof ToolbarPrimitive.ToolbarToggleGroup>) {\n  return (\n    <ToolbarPrimitive.ToolbarToggleGroup\n      className={cn('flex items-center', className)}\n      {...props}\n    />\n  );\n}\n\nexport function ToolbarLink({\n  className,\n  ...props\n}: React.ComponentProps<typeof ToolbarPrimitive.Link>) {\n  return (\n    <ToolbarPrimitive.Link\n      className={cn('font-medium underline underline-offset-4', className)}\n      {...props}\n    />\n  );\n}\n\nexport function ToolbarSeparator({\n  className,\n  ...props\n}: React.ComponentProps<typeof ToolbarPrimitive.Separator>) {\n  return (\n    <ToolbarPrimitive.Separator\n      className={cn('mx-2 my-1 w-px shrink-0 bg-border', className)}\n      {...props}\n    />\n  );\n}\n\n// From toggleVariants\nconst toolbarButtonVariants = cva(\n  \"inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium text-sm outline-none transition-[color,box-shadow] 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:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0\",\n  {\n    defaultVariants: {\n      size: 'default',\n      variant: 'default',\n    },\n    variants: {\n      size: {\n        default: 'h-9 min-w-9 px-2',\n        lg: 'h-10 min-w-10 px-2.5',\n        sm: 'h-8 min-w-8 px-1.5',\n      },\n      variant: {\n        default: 'bg-transparent',\n        outline:\n          'border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground',\n      },\n    },\n  }\n);\n\nconst dropdownArrowVariants = cva(\n  cn(\n    'inline-flex items-center justify-center rounded-r-md font-medium text-foreground text-sm transition-colors disabled:pointer-events-none disabled:opacity-50'\n  ),\n  {\n    defaultVariants: {\n      size: 'sm',\n      variant: 'default',\n    },\n    variants: {\n      size: {\n        default: 'h-9 w-6',\n        lg: 'h-10 w-8',\n        sm: 'h-8 w-4',\n      },\n      variant: {\n        default:\n          'bg-transparent hover:bg-muted hover:text-muted-foreground aria-checked:bg-accent aria-checked:text-accent-foreground',\n        outline:\n          'border border-input border-l-0 bg-transparent hover:bg-accent hover:text-accent-foreground',\n      },\n    },\n  }\n);\n\ntype ToolbarButtonProps = {\n  isDropdown?: boolean;\n  pressed?: boolean;\n} & Omit<\n  React.ComponentPropsWithoutRef<typeof ToolbarToggleItem>,\n  'asChild' | 'value'\n> &\n  VariantProps<typeof toolbarButtonVariants>;\n\nexport const ToolbarButton = withTooltip(function ToolbarButton({\n  children,\n  className,\n  isDropdown,\n  pressed,\n  size = 'sm',\n  variant,\n  ...props\n}: ToolbarButtonProps) {\n  return typeof pressed === 'boolean' ? (\n    <ToolbarToggleGroup disabled={props.disabled} value=\"single\" type=\"single\">\n      <ToolbarToggleItem\n        className={cn(\n          toolbarButtonVariants({\n            size,\n            variant,\n          }),\n          isDropdown && 'justify-between gap-1 pr-1',\n          className\n        )}\n        value={pressed ? 'single' : ''}\n        {...props}\n      >\n        {isDropdown ? (\n          <>\n            <div className=\"flex flex-1 items-center gap-2 whitespace-nowrap\">\n              {children}\n            </div>\n            <div>\n              <ChevronDown\n                className=\"size-3.5 text-muted-foreground\"\n                data-icon\n              />\n            </div>\n          </>\n        ) : (\n          children\n        )}\n      </ToolbarToggleItem>\n    </ToolbarToggleGroup>\n  ) : (\n    <ToolbarPrimitive.Button\n      className={cn(\n        toolbarButtonVariants({\n          size,\n          variant,\n        }),\n        isDropdown && 'pr-1',\n        className\n      )}\n      {...props}\n    >\n      {children}\n    </ToolbarPrimitive.Button>\n  );\n});\n\nexport function ToolbarSplitButton({\n  className,\n  ...props\n}: React.ComponentPropsWithoutRef<typeof ToolbarButton>) {\n  return (\n    <ToolbarButton\n      className={cn('group flex gap-0 px-0 hover:bg-transparent', className)}\n      {...props}\n    />\n  );\n}\n\ntype ToolbarSplitButtonPrimaryProps = Omit<\n  React.ComponentPropsWithoutRef<typeof ToolbarToggleItem>,\n  'value'\n> &\n  VariantProps<typeof toolbarButtonVariants>;\n\nexport function ToolbarSplitButtonPrimary({\n  children,\n  className,\n  size = 'sm',\n  variant,\n  ...props\n}: ToolbarSplitButtonPrimaryProps) {\n  return (\n    <span\n      className={cn(\n        toolbarButtonVariants({\n          size,\n          variant,\n        }),\n        'rounded-r-none',\n        'group-data-[pressed=true]:bg-accent group-data-[pressed=true]:text-accent-foreground',\n        className\n      )}\n      {...props}\n    >\n      {children}\n    </span>\n  );\n}\n\nexport function ToolbarSplitButtonSecondary({\n  className,\n  size,\n  variant,\n  ...props\n}: React.ComponentPropsWithoutRef<'span'> &\n  VariantProps<typeof dropdownArrowVariants>) {\n  return (\n    <span\n      className={cn(\n        dropdownArrowVariants({\n          size,\n          variant,\n        }),\n        'group-data-[pressed=true]:bg-accent group-data-[pressed=true]:text-accent-foreground',\n        className\n      )}\n      onClick={(e) => e.stopPropagation()}\n      role=\"button\"\n      {...props}\n    >\n      <ChevronDown className=\"size-3.5 text-muted-foreground\" data-icon />\n    </span>\n  );\n}\n\nexport function ToolbarToggleItem({\n  className,\n  size = 'sm',\n  variant,\n  ...props\n}: React.ComponentProps<typeof ToolbarPrimitive.ToggleItem> &\n  VariantProps<typeof toolbarButtonVariants>) {\n  return (\n    <ToolbarPrimitive.ToggleItem\n      className={cn(toolbarButtonVariants({ size, variant }), className)}\n      {...props}\n    />\n  );\n}\n\nexport function ToolbarGroup({\n  children,\n  className,\n}: React.ComponentProps<'div'>) {\n  return (\n    <div\n      className={cn(\n        'group/toolbar-group',\n        'relative hidden has-[button]:flex',\n        className\n      )}\n    >\n      <div className=\"flex items-center\">{children}</div>\n\n      <div className=\"group-last/toolbar-group:hidden! mx-1.5 py-0.5\">\n        <Separator orientation=\"vertical\" />\n      </div>\n    </div>\n  );\n}\n\ntype TooltipProps<T extends React.ElementType> = {\n  tooltip?: React.ReactNode;\n  tooltipContentProps?: Omit<\n    React.ComponentPropsWithoutRef<typeof TooltipContent>,\n    'children'\n  >;\n  tooltipProps?: Omit<\n    React.ComponentPropsWithoutRef<typeof Tooltip>,\n    'children'\n  >;\n  tooltipTriggerProps?: React.ComponentPropsWithoutRef<typeof TooltipTrigger>;\n} & React.ComponentProps<T>;\n\nfunction withTooltip<T extends React.ElementType>(Component: T) {\n  return function ExtendComponent({\n    tooltip,\n    tooltipContentProps,\n    tooltipProps,\n    tooltipTriggerProps,\n    ...props\n  }: TooltipProps<T>) {\n    const [mounted, setMounted] = React.useState(false);\n\n    React.useEffect(() => {\n      setMounted(true);\n    }, []);\n\n    const component = <Component {...(props as React.ComponentProps<T>)} />;\n\n    if (tooltip && mounted) {\n      return (\n        <Tooltip {...tooltipProps}>\n          <TooltipTrigger asChild {...tooltipTriggerProps}>\n            {component}\n          </TooltipTrigger>\n\n          <TooltipContent {...tooltipContentProps}>{tooltip}</TooltipContent>\n        </Tooltip>\n      );\n    }\n\n    return component;\n  };\n}\n\nfunction TooltipContent({\n  children,\n  className,\n  // CHANGE\n  sideOffset = 4,\n  ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Content>) {\n  return (\n    <TooltipPrimitive.Portal>\n      <TooltipPrimitive.Content\n        className={cn(\n          'z-50 w-fit origin-(--radix-tooltip-content-transform-origin) text-balance rounded-md bg-primary px-3 py-1.5 text-primary-foreground text-xs',\n          className\n        )}\n        data-slot=\"tooltip-content\"\n        sideOffset={sideOffset}\n        {...props}\n      >\n        {children}\n        {/* CHANGE */}\n        {/* <TooltipPrimitive.Arrow className=\"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-primary fill-primary\" /> */}\n      </TooltipPrimitive.Content>\n    </TooltipPrimitive.Portal>\n  );\n}\n\nexport function ToolbarMenuGroup({\n  children,\n  className,\n  label,\n  ...props\n}: React.ComponentProps<typeof DropdownMenuRadioGroup> & { label?: string }) {\n  return (\n    <>\n      <DropdownMenuSeparator\n        className={cn(\n          'hidden',\n          'mb-0 shrink-0 peer-has-[[role=menuitem]]/menu-group:block peer-has-[[role=menuitemradio]]/menu-group:block peer-has-[[role=option]]/menu-group:block'\n        )}\n      />\n\n      <DropdownMenuRadioGroup\n        {...props}\n        className={cn(\n          'hidden',\n          'peer/menu-group group/menu-group my-1.5 has-[[role=menuitem]]:block has-[[role=menuitemradio]]:block has-[[role=option]]:block',\n          className\n        )}\n      >\n        {label && (\n          <DropdownMenuLabel className=\"select-none font-semibold text-muted-foreground text-xs\">\n            {label}\n          </DropdownMenuLabel>\n        )}\n        {children}\n      </DropdownMenuRadioGroup>\n    </>\n  );\n}\n",
      "type": "registry:ui"
    }
  ],
  "meta": {},
  "type": "registry:ui"
}