{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "description-list",
  "title": "Description List",
  "description": "Term and detail pairs in one or two columns, built from an array or composed by hand, with links, copy buttons, a \"Show more\" section and a vertical layout for narrow panels.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "https://dentil.dev/r/link.json?via=description-list"
  ],
  "files": [
    {
      "path": "components/dentil/description-list/description-list.tsx",
      "content": "'use client';\n\nimport { useEffect, useId, useRef, useState, type ComponentProps, type ReactNode } from 'react';\nimport { Check, ChevronDown, Copy } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\n\nimport { Link, type LinkComponent } from '../link/link';\n\n/**\n * `responsive` stacks the term above the detail on small screens and puts them side by side from `sm`.\n * `vertical` always stacks them, for narrow containers such as a sidebar.\n */\nexport type DescriptionListOrientation = 'responsive' | 'vertical';\n\nexport function DescriptionListColumns({ className, ...props }: ComponentProps<'div'>) {\n  return (\n    <div\n      data-slot=\"description-list-columns\"\n      className={cn('grid grid-cols-1 items-start sm:grid-cols-2 sm:gap-x-6', className)}\n      {...props}\n    />\n  );\n}\n\nexport type DescriptionListProps = ComponentProps<'dl'> & {\n  orientation?: DescriptionListOrientation;\n};\n\nexport function DescriptionList({ orientation = 'responsive', className, ...props }: DescriptionListProps) {\n  return (\n    <dl\n      data-slot=\"description-list\"\n      data-orientation={orientation}\n      className={cn(\n        'group/description-list grid grid-cols-1 text-sm sm:data-[orientation=responsive]:grid-cols-[min(40%,--spacing(80))_minmax(0,1fr)]',\n        className\n      )}\n      {...props}\n    />\n  );\n}\n\nexport function DescriptionTerm({ className, ...props }: ComponentProps<'dt'>) {\n  return (\n    <dt\n      data-slot=\"description-term\"\n      className={cn(\n        'text-muted-foreground col-start-1 pt-1 pr-2 sm:group-data-[orientation=responsive]/description-list:py-0.5',\n        className\n      )}\n      {...props}\n    />\n  );\n}\n\nexport function DescriptionDetails({ className, ...props }: ComponentProps<'dd'>) {\n  return (\n    <dd\n      data-slot=\"description-details\"\n      className={cn('min-w-0 pb-1 sm:group-data-[orientation=responsive]/description-list:py-0.5', className)}\n      {...props}\n    />\n  );\n}\n\nexport type DescriptionCopyButtonProps = Omit<ComponentProps<'button'>, 'value' | 'children'> & {\n  /** Text written to the clipboard. */\n  value: string;\n};\n\nexport function DescriptionCopyButton({\n  value,\n  className,\n  onClick,\n  'aria-label': ariaLabel = 'Copy',\n  ...props\n}: DescriptionCopyButtonProps) {\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=\"description-copy-button\"\n      aria-label={copied ? 'Copied' : ariaLabel}\n      className={cn(\n        'text-muted-foreground hover:text-foreground focus-visible:ring-ring/50 relative inline-flex size-5 shrink-0 items-center justify-center rounded-sm transition-colors outline-none focus-visible:ring-[3px]',\n        className\n      )}\n      onClick={(event) => {\n        onClick?.(event);\n        if (event.defaultPrevented) return;\n        // Copy buttons often sit inside a clickable row or link.\n        event.preventDefault();\n        event.stopPropagation();\n        void navigator.clipboard.writeText(value).then(() => {\n          setCopied(true);\n          clearTimeout(timeout.current);\n          timeout.current = setTimeout(() => setCopied(false), 1500);\n        });\n      }}\n      {...props}>\n      <Check\n        aria-hidden\n        className={cn(\n          'absolute size-3.5 transition-[opacity,scale] duration-150 motion-reduce:transition-none',\n          copied ? 'scale-100 opacity-100' : 'scale-50 opacity-0'\n        )}\n      />\n      <Copy\n        aria-hidden\n        className={cn(\n          'absolute size-3.5 transition-[opacity,scale] duration-150 motion-reduce:transition-none',\n          copied ? 'scale-50 opacity-0' : 'scale-100 opacity-100'\n        )}\n      />\n    </button>\n  );\n}\n\nexport type DescriptionItem = {\n  /** An empty string renders a continuation line, such as the second line of an address. */\n  term: ReactNode;\n  detail: ReactNode;\n  /** Renders the detail as a `Link` from `@dentil/link`. */\n  href?: string;\n  /** Opens `href` in a new tab with an external-link icon instead of the arrow. */\n  external?: boolean;\n  /** Text copied by a button beside the detail. It shows on hover, on keyboard focus and on touch screens. */\n  copy?: string;\n};\n\n/** Falsy entries are skipped, so `condition && { term, detail }` works inline. */\nexport type DescriptionItems = readonly (DescriptionItem | false | null | undefined | 0 | '')[];\n\ntype DescriptionsData =\n  { items: DescriptionItems; columns?: never } | { columns: readonly DescriptionItems[]; items?: never };\n\nexport type DescriptionsProps = Omit<ComponentProps<'div'>, 'children'> &\n  DescriptionsData & {\n    orientation?: DescriptionListOrientation;\n    /** Items hidden behind a \"Show more\" toggle below the list, lined up with the first column. */\n    more?: DescriptionItems;\n    moreLabel?: ReactNode;\n    defaultMoreOpen?: boolean;\n    /** Component used for item links. Pass `next/link`, React Router's `Link`, etc. Defaults to `<a>`. */\n    linkComponent?: LinkComponent;\n  };\n\nexport function Descriptions({\n  items,\n  columns,\n  orientation = 'responsive',\n  more,\n  moreLabel = 'Show more',\n  defaultMoreOpen = false,\n  linkComponent = 'a',\n  className,\n  ...props\n}: DescriptionsProps) {\n  const renderList = (list: DescriptionItems, key?: number) => (\n    <DescriptionList key={key} orientation={orientation}>\n      {list.map((item, index) =>\n        item ? <DescriptionRow key={index} item={item} linkComponent={linkComponent} /> : null\n      )}\n    </DescriptionList>\n  );\n\n  const showMore =\n    more && more.some(Boolean) ? (\n      <ShowMore label={moreLabel} defaultOpen={defaultMoreOpen}>\n        {renderList(more)}\n      </ShowMore>\n    ) : null;\n\n  return (\n    <div data-slot=\"descriptions\" className={className} {...props}>\n      {columns ? (\n        <DescriptionListColumns>\n          {columns.map((column, index) => renderList(column, index))}\n          {showMore}\n        </DescriptionListColumns>\n      ) : (\n        <>\n          {renderList(items ?? [])}\n          {showMore}\n        </>\n      )}\n    </div>\n  );\n}\n\nfunction DescriptionRow({ item, linkComponent }: { item: DescriptionItem; linkComponent: LinkComponent }) {\n  return (\n    <>\n      <DescriptionTerm>{item.term}</DescriptionTerm>\n      <DescriptionDetails className=\"group/description-details flex items-center gap-2\">\n        {item.href ? (\n          <Link href={item.href} external={item.external} linkComponent={linkComponent} className=\"min-w-0\">\n            {item.detail}\n          </Link>\n        ) : (\n          <div className=\"min-w-0 wrap-break-word\">{item.detail}</div>\n        )}\n        {item.copy ? (\n          <DescriptionCopyButton\n            value={item.copy}\n            aria-label={typeof item.term === 'string' && item.term ? `Copy ${item.term}` : undefined}\n            className=\"opacity-0 transition-[color,opacity] group-hover/description-details:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100\"\n          />\n        ) : null}\n      </DescriptionDetails>\n    </>\n  );\n}\n\nfunction ShowMore({ label, defaultOpen, children }: { label: ReactNode; defaultOpen: boolean; children: ReactNode }) {\n  const [open, setOpen] = useState(defaultOpen);\n  const id = useId();\n\n  return (\n    <div data-slot=\"descriptions-more\" className=\"col-start-1 flex flex-col\">\n      <button\n        type=\"button\"\n        aria-expanded={open}\n        aria-controls={id}\n        onClick={() => setOpen((value) => !value)}\n        className=\"text-primary hover:text-primary/80 focus-visible:ring-ring/50 mt-2 inline-flex items-center gap-1 self-start rounded-sm text-sm font-medium transition-colors outline-none focus-visible:ring-[3px]\">\n        {label}\n        <ChevronDown\n          aria-hidden\n          className={cn('size-4 transition-transform duration-200 motion-reduce:transition-none', open && 'rotate-180')}\n        />\n      </button>\n      <div\n        id={id}\n        inert={!open}\n        data-state={open ? 'open' : 'closed'}\n        className=\"grid grid-rows-[0fr] opacity-0 transition-[grid-template-rows,opacity] duration-200 ease-out data-[state=open]:grid-rows-[1fr] data-[state=open]:opacity-100 motion-reduce:transition-none\">\n        <div className=\"min-h-0 overflow-hidden\">\n          <div className=\"pt-2\">{children}</div>\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/dentil/description-list/description-list.tsx"
    }
  ],
  "type": "registry:component"
}
