{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "object-header",
  "title": "Object Header",
  "description": "A record page header row: the object type with an icon, stacked avatars for the people viewing the record, and dashed copy buttons for the page URL and the object ID.",
  "files": [
    {
      "path": "components/dentil/object-header/object-header.tsx",
      "content": "'use client';\n\nimport { Check, Copy, type LucideIcon } from 'lucide-react';\nimport { useEffect, useRef, useState, type ComponentProps, type ReactNode } from 'react';\n\nimport { cn } from '@/lib/utils';\n\n/*\n * The small row at the top of a record page: the object type with its icon on the left, and the people viewing the\n * record and copy buttons for its URL and ID on the right. Its 20px side padding lines up with the dashboard layout.\n */\n\nexport interface ObjectHeaderProps extends Omit<ComponentProps<'div'>, 'title' | 'id' | 'onCopy'> {\n  /** The object type, such as \"Invoice\" or \"Customer\". */\n  title: ReactNode;\n  /** Icon shown before the title. */\n  icon?: LucideIcon;\n  /** The object's ID. Shown as a copy button labelled with the ID itself. */\n  id?: string;\n  /** Shows a \"URL\" copy button. Pass a URL to copy, or `true` to copy the page's address at the moment of the click. */\n  url?: string | true;\n  /** People viewing the record, shown as stacked avatars before the copy buttons. */\n  presence?: ObjectHeaderUser[];\n  /** Called after a value is written to the clipboard, e.g. to show a toast. */\n  onCopy?: (value: string) => void;\n}\n\nexport function ObjectHeader({\n  title,\n  icon: Icon,\n  id,\n  url,\n  presence,\n  onCopy,\n  className,\n  children,\n  ...props\n}: ObjectHeaderProps) {\n  return (\n    <div\n      data-slot=\"object-header\"\n      className={cn('flex min-h-8 min-w-0 items-center justify-between gap-3 px-5 pt-3', className)}\n      {...props}>\n      <div data-slot=\"object-header-title\" className=\"text-muted-foreground flex min-w-0 items-center gap-1\">\n        {Icon ? <Icon aria-hidden className=\"size-3 shrink-0\" /> : null}\n        <span className=\"truncate text-xs\">{title}</span>\n      </div>\n\n      <div data-slot=\"object-header-actions\" className=\"flex min-w-0 items-center gap-2\">\n        {presence?.length ? <ObjectHeaderPresence users={presence} /> : null}\n        {children}\n        {url || id ? (\n          <div className=\"flex min-w-0 items-center gap-1\">\n            {url ? (\n              <ObjectHeaderCopyButton value={url === true ? currentUrl : url} aria-label=\"Copy URL\" onCopy={onCopy}>\n                URL\n              </ObjectHeaderCopyButton>\n            ) : null}\n            {id ? (\n              <ObjectHeaderCopyButton value={id} aria-label=\"Copy ID\" onCopy={onCopy}>\n                {id}\n              </ObjectHeaderCopyButton>\n            ) : null}\n          </div>\n        ) : null}\n      </div>\n    </div>\n  );\n}\n\nconst currentUrl = () => window.location.href;\n\nexport interface ObjectHeaderCopyButtonProps extends Omit<ComponentProps<'button'>, 'value' | 'onCopy'> {\n  /** Text written to the clipboard, or a function that returns it at the moment of the click. */\n  value: string | (() => string);\n  /** Called after the value is written to the clipboard. */\n  onCopy?: (value: string) => void;\n}\n\n/** A dashed chip with a monospace label that copies a value and shows a check for a moment. */\nexport function ObjectHeaderCopyButton({\n  value,\n  onCopy,\n  className,\n  onClick,\n  children,\n  'aria-label': ariaLabel = 'Copy',\n  ...props\n}: ObjectHeaderCopyButtonProps) {\n  const [copied, setCopied] = useState(false);\n  const timeout = useRef<ReturnType<typeof setTimeout>>(undefined);\n\n  useEffect(() => () => clearTimeout(timeout.current), []);\n\n  return (\n    <button\n      type=\"button\"\n      data-slot=\"object-header-copy-button\"\n      aria-label={copied ? 'Copied' : ariaLabel}\n      className={cn(\n        'text-muted-foreground hover:bg-muted focus-visible:ring-ring/50 inline-flex h-5 max-w-60 min-w-0 shrink-0 items-center gap-1 rounded-sm border border-dashed px-1 transition-colors outline-none focus-visible:ring-[3px]',\n        className\n      )}\n      onClick={(event) => {\n        onClick?.(event);\n        if (event.defaultPrevented) return;\n        const text = typeof value === 'function' ? value() : value;\n        void navigator.clipboard.writeText(text).then(() => {\n          setCopied(true);\n          onCopy?.(text);\n          clearTimeout(timeout.current);\n          timeout.current = setTimeout(() => setCopied(false), 2000);\n        });\n      }}\n      {...props}>\n      <span className=\"min-w-0 truncate font-mono text-xs\">{children}</span>\n      <span aria-hidden className=\"relative size-3 shrink-0\">\n        <Check\n          className={cn(\n            'absolute inset-0 size-3 text-green-600 transition-[opacity,scale] duration-150 motion-reduce:transition-none dark:text-green-500',\n            copied ? 'scale-100 opacity-100' : 'scale-50 opacity-0'\n          )}\n        />\n        <Copy\n          className={cn(\n            'absolute inset-0 size-3 transition-[opacity,scale] duration-150 motion-reduce:transition-none',\n            copied ? 'scale-50 opacity-0' : 'scale-100 opacity-100'\n          )}\n        />\n      </span>\n    </button>\n  );\n}\n\nexport interface ObjectHeaderUser {\n  /** Stable key, such as a user or connection ID. Falls back to the name. */\n  id?: string;\n  name: string;\n  /** Image URL. Without one, the avatar shows the name's first letter. */\n  avatar?: string;\n}\n\nexport interface ObjectHeaderPresenceProps extends ComponentProps<'div'> {\n  /** People viewing the record. Put the current user first: earlier avatars sit on top of later ones. */\n  users: ObjectHeaderUser[];\n  /** Avatars shown before the rest collapse into a \"+N\" count. */\n  max?: number;\n}\n\n// The opaque background stops the tinted fill of an avatar showing the one beneath it through the overlap.\nconst avatar =\n  'ring-background bg-background relative -ms-1.5 inline-flex shrink-0 rounded-full text-[8px] font-medium uppercase ring-2';\nconst avatarFill = 'bg-muted-foreground/25 text-foreground flex size-full items-center justify-center rounded-full';\n\n/** Stacked avatars for the people viewing a record. Each new avatar grows in from the left. */\nexport function ObjectHeaderPresence({ users, max = 5, className, ...props }: ObjectHeaderPresenceProps) {\n  const shown = users.slice(0, max);\n  const hidden = users.slice(max);\n  const names = users.map((user) => user.name).join(', ');\n\n  return (\n    <div\n      role=\"group\"\n      aria-label={`Viewing: ${names}`}\n      data-slot=\"object-header-presence\"\n      className={cn('flex items-center ps-1.5', className)}\n      {...props}>\n      {shown.map((user, index) => (\n        <span\n          key={user.id ?? user.name}\n          title={user.name}\n          className={cn(avatar, 'animate-in fade-in zoom-in-50 size-5 duration-200 motion-reduce:animate-none')}\n          style={{ zIndex: shown.length - index }}>\n          {user.avatar ? (\n            <img src={user.avatar} alt=\"\" className=\"size-full rounded-full object-cover\" />\n          ) : (\n            <span aria-hidden className={avatarFill}>\n              {user.name.slice(0, 1)}\n            </span>\n          )}\n        </span>\n      ))}\n      {hidden.length ? (\n        <span title={hidden.map((user) => user.name).join(', ')} className={cn(avatar, 'h-5 min-w-5')}>\n          <span className={cn(avatarFill, 'px-1')}>+{hidden.length}</span>\n        </span>\n      ) : null}\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/dentil/object-header/object-header.tsx"
    }
  ],
  "type": "registry:component"
}