{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "list-item",
  "type": "registry:ui",
  "title": "List Item",
  "description": "List Item is a single row inside a collection — avatar, title, description, metadata, and optional trailing content.",
  "author": "Skrewww",
  "dependencies": [],
  "registryDependencies": [
    "@skrewww/foundation"
  ],
  "docs": "Host requirements (assumed already present, not installed by this command): react, react-dom.",
  "files": [
    {
      "path": "components/ui/ListItem.tsx",
      "content": "/** @skrewww-component list-item */\n\"use client\";\n\nimport { useEffect, type ReactNode } from \"react\";\nimport { getLinkRel, shouldUseNativeAnchor } from \"@/components/ui/internal/link-utils\";\nimport { cn } from \"@/lib/cn\";\nimport { RouterAnchor } from \"@/components/ui/router-navigation\";\nimport styles from \"@/components/ui/list-item.module.css\";\n\nexport type ListItemProps = {\n  title: ReactNode;\n  description?: ReactNode;\n  metadata?: ReactNode;\n  leading?: ReactNode;\n  trailing?: ReactNode;\n  href?: string;\n  onClick?: () => void;\n  disabled?: boolean;\n  className?: string;\n  /**\n   * ARIA disclosure attributes for an action row (onClick) that toggles\n   * external content it doesn't own — e.g. a row that opens a Popover\n   * anchored to it via PopoverAnchor (added for Banking Transaction Row,\n   * which needed the whole row to announce its expanded/collapsed state).\n   * No-ops on navigational (href) or plain static rows.\n   */\n  \"aria-expanded\"?: boolean;\n  \"aria-haspopup\"?: \"dialog\" | \"menu\" | \"listbox\" | \"true\";\n  \"aria-controls\"?: string;\n};\n\nfunction warnInvalidCombination(message: string) {\n  if (process.env.NODE_ENV === \"development\") {\n    console.warn(`[Skrewww ListItem] ${message}`);\n  }\n}\n\nfunction ListItemContent({\n  title,\n  description,\n  metadata,\n  leading,\n  trailing,\n}: Pick<ListItemProps, \"title\" | \"description\" | \"metadata\" | \"leading\" | \"trailing\">) {\n  return (\n    <>\n      {leading ? <span className={styles.leading}>{leading}</span> : null}\n      <span className={styles.body}>\n        <span className={styles.title}>{title}</span>\n        {description ? <span className={styles.description}>{description}</span> : null}\n      </span>\n      {metadata ? <span className={styles.metadata}>{metadata}</span> : null}\n      {trailing ? <span className={styles.trailing}>{trailing}</span> : null}\n    </>\n  );\n}\n\nexport function ListItem({\n  title,\n  description,\n  metadata,\n  leading,\n  trailing,\n  href,\n  onClick,\n  disabled = false,\n  className,\n  \"aria-expanded\": ariaExpanded,\n  \"aria-haspopup\": ariaHaspopup,\n  \"aria-controls\": ariaControls,\n}: ListItemProps) {\n  const isNavigational = Boolean(href);\n  const isAction = Boolean(onClick);\n  const isInteractive = isNavigational || isAction;\n\n  useEffect(() => {\n    if (href && onClick) {\n      warnInvalidCombination(\"Provide either href or onClick — not both.\");\n    }\n    if (isInteractive && trailing) {\n      warnInvalidCombination(\n        \"Interactive List Item rows cannot include a trailing control — keep trailing content static or use a static row with a separate trailing action.\",\n      );\n    }\n  }, [href, isInteractive, onClick, trailing]);\n\n  if (isNavigational && href) {\n    const rowClassName = cn(styles.row, styles.interactive);\n    const content = (\n      <ListItemContent\n        title={title}\n        description={description}\n        metadata={metadata}\n        leading={leading}\n        trailing={trailing}\n      />\n    );\n\n    return (\n      <li className={cn(styles.item, className)}>\n        {shouldUseNativeAnchor(href) ? (\n          <a\n            href={href}\n            className={rowClassName}\n            aria-disabled={disabled || undefined}\n            tabIndex={disabled ? -1 : undefined}\n          >\n            {content}\n          </a>\n        ) : (\n          <RouterAnchor\n            href={href}\n            className={rowClassName}\n            aria-disabled={disabled || undefined}\n            tabIndex={disabled ? -1 : undefined}\n          >\n            {content}\n          </RouterAnchor>\n        )}\n      </li>\n    );\n  }\n\n  if (isAction && onClick) {\n    return (\n      <li className={cn(styles.item, className)}>\n        <button\n          type=\"button\"\n          className={cn(styles.row, styles.interactive)}\n          onClick={onClick}\n          disabled={disabled}\n          aria-expanded={ariaExpanded}\n          aria-haspopup={ariaHaspopup}\n          aria-controls={ariaControls}\n        >\n          <ListItemContent\n            title={title}\n            description={description}\n            metadata={metadata}\n            leading={leading}\n            trailing={trailing}\n          />\n        </button>\n      </li>\n    );\n  }\n\n  return (\n    <li className={cn(styles.item, styles.static, className)}>\n      <div className={styles.row}>\n        <ListItemContent\n          title={title}\n          description={description}\n          metadata={metadata}\n          leading={leading}\n          trailing={trailing}\n        />\n      </div>\n    </li>\n  );\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/ListItem.tsx"
    },
    {
      "path": "components/ui/list-item.module.css",
      "content": ".item {\n  list-style: none;\n}\n\n.row {\n  display: flex;\n  align-items: center;\n  gap: var(--list-item-gap);\n  width: 100%;\n  min-height: var(--list-item-min-height);\n  padding: var(--list-item-padding-y) var(--list-item-padding-x);\n  border: 0;\n  background: transparent;\n  color: inherit;\n  text-align: left;\n  text-decoration: none;\n  border-radius: var(--list-item-radius);\n}\n\n.static .row {\n  background: transparent;\n}\n\n.interactive {\n  cursor: pointer;\n  background: transparent;\n}\n\n.interactive:hover {\n  background: var(--list-item-hover-surface);\n  backdrop-filter: var(--component-surface-backdrop-filter);\n}\n\n.interactive:focus-visible {\n  outline: 2px solid var(--semantic-focus-ring);\n  outline-offset: 2px;\n}\n\n.interactive:disabled {\n  cursor: not-allowed;\n  opacity: var(--opacity-disabled);\n}\n\n.leading {\n  display: inline-flex;\n  flex-shrink: 0;\n  align-items: center;\n  justify-content: center;\n  width: var(--list-item-leading-size);\n  color: var(--component-surface-content-muted);\n}\n\n.body {\n  display: flex;\n  flex: 1;\n  flex-direction: column;\n  gap: 0.125rem;\n  min-width: 0;\n}\n\n.title {\n  font-size: 0.9375rem;\n  font-weight: 600;\n  line-height: 1.35;\n  color: var(--list-item-title-text);\n  overflow: hidden;\n  text-overflow: ellipsis;\n  white-space: nowrap;\n}\n\n.description {\n  font-size: 0.8125rem;\n  line-height: 1.4;\n  color: var(--list-item-description-text);\n  overflow: hidden;\n  text-overflow: ellipsis;\n  white-space: nowrap;\n}\n\n.metadata {\n  flex-shrink: 0;\n  font-size: 0.75rem;\n  line-height: 1.3;\n  color: var(--list-item-metadata-text);\n}\n\n.trailing {\n  display: inline-flex;\n  flex-shrink: 0;\n  align-items: center;\n  gap: 0.375rem;\n}\n\n[data-skrewww-shape=\"pill\"] .row {\n  border-radius: min(var(--list-item-radius), 1rem);\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/list-item.module.css"
    },
    {
      "path": "lib/cn.ts",
      "content": "export function cn(...classes: Array<string | false | null | undefined>): string {\n  return classes.filter(Boolean).join(\" \");\n}\n",
      "type": "registry:lib",
      "target": "~/lib/cn.ts"
    },
    {
      "path": "components/ui/internal/link-utils.ts",
      "content": "/**\n * Framework-neutral link classification helpers.\n * No docs-site / repository configuration imports — origin is either passed\n * explicitly or read from the runtime location when available.\n */\n\nfunction normalizeHref(href: string): string {\n  return href.trim();\n}\n\nfunction resolveDefaultOrigin(): string | undefined {\n  if (typeof globalThis === \"undefined\") return undefined;\n  const locationLike = (globalThis as { location?: { origin?: string } }).location;\n  return locationLike?.origin;\n}\n\nexport function isHashHref(href: string): boolean {\n  return normalizeHref(href).startsWith(\"#\");\n}\n\nexport function isSpecialProtocolHref(href: string): boolean {\n  const value = normalizeHref(href).toLowerCase();\n  return value.startsWith(\"mailto:\") || value.startsWith(\"tel:\");\n}\n\nexport function isExternalHref(href: string, origin: string | undefined = resolveDefaultOrigin()): boolean {\n  const value = normalizeHref(href);\n\n  if (!value || isHashHref(value) || value.startsWith(\"/\") || value.startsWith(\"./\") || value.startsWith(\"../\")) {\n    return false;\n  }\n\n  if (isSpecialProtocolHref(value)) {\n    return true;\n  }\n\n  if (value.startsWith(\"//\")) {\n    return true;\n  }\n\n  if (/^https?:\\/\\//i.test(value)) {\n    if (!origin) {\n      // No origin context (SSR without an explicit origin) — treat absolute\n      // http(s) as external so NextLink is not used for foreign hosts.\n      return true;\n    }\n    try {\n      return new URL(value).origin !== origin;\n    } catch {\n      return true;\n    }\n  }\n\n  return false;\n}\n\nexport function shouldUseNativeAnchor(\n  href: string,\n  origin: string | undefined = resolveDefaultOrigin(),\n): boolean {\n  const value = normalizeHref(href);\n  return isSpecialProtocolHref(value) || isExternalHref(value, origin);\n}\n\nexport function getLinkRel(target?: string, rel?: string): string | undefined {\n  if (rel) return rel;\n  if (target === \"_blank\") return \"noopener noreferrer\";\n  return undefined;\n}\n\n/**\n * True only for root-relative internal paths (\"/components/button\"). These are\n * the only hrefs a host router can be asked to navigate to: hash-only links,\n * relative paths, protocol-relative URLs, mailto:/tel: and absolute URLs are\n * left to the browser so native behavior (scrolling, resolution against the\n * current URL, other origins) is never reimplemented.\n */\nexport function isRouterNavigableHref(href: string): boolean {\n  const value = normalizeHref(href);\n  return value.startsWith(\"/\") && !value.startsWith(\"//\");\n}\n\nexport type NavigationInterceptionInput = {\n  href: string;\n  target?: string;\n  download?: unknown;\n  button: number;\n  metaKey: boolean;\n  ctrlKey: boolean;\n  shiftKey: boolean;\n  altKey: boolean;\n  defaultPrevented: boolean;\n};\n\n/**\n * Whether a click on an anchor should be handed to the host router instead of\n * the browser. Only a plain, primary-button, same-window activation of an\n * internal path qualifies; every case where the browser should win returns\n * false.\n */\nexport function shouldInterceptNavigation(input: NavigationInterceptionInput): boolean {\n  if (input.defaultPrevented) return false;\n  if (input.button !== 0) return false;\n  if (input.metaKey || input.ctrlKey || input.shiftKey || input.altKey) return false;\n  if (input.target && input.target !== \"_self\") return false;\n  if (input.download !== undefined && input.download !== false) return false;\n  return isRouterNavigableHref(input.href);\n}\n",
      "type": "registry:lib",
      "target": "~/components/ui/internal/link-utils.ts"
    },
    {
      "path": "components/ui/router-navigation.tsx",
      "content": "\"use client\";\n\nimport {\n  createContext,\n  forwardRef,\n  useContext,\n  type AnchorHTMLAttributes,\n  type MouseEvent,\n  type ReactNode,\n} from \"react\";\nimport { shouldInterceptNavigation } from \"@/components/ui/internal/link-utils\";\n\n/**\n * Router integration for link-bearing components (Button, Link, Pagination,\n * List Item). Components always render a native `<a href>`; with no provider\n * a click is ordinary browser navigation. A host application may mount one\n * `SkrewwwRouterProvider` so eligible internal navigations are handed to its\n * own router instead of reloading the page. The contract is navigation\n * intent (\"go to this path\"), not any particular router.\n */\nexport type SkrewwwNavigate = (href: string) => void;\n\nconst SkrewwwNavigateContext = createContext<SkrewwwNavigate | null>(null);\n\nexport type SkrewwwRouterProviderProps = {\n  /**\n   * Called with the root-relative href of a plain, same-window click on an\n   * internal link. Modified or non-primary clicks, `target` other than\n   * `_self`, `download`, prevented events and every non-root-relative href\n   * are never passed to it. Memoize it to avoid re-rendering link consumers.\n   */\n  navigate: SkrewwwNavigate;\n  children: ReactNode;\n};\n\nexport function SkrewwwRouterProvider({ navigate, children }: SkrewwwRouterProviderProps) {\n  return <SkrewwwNavigateContext.Provider value={navigate}>{children}</SkrewwwNavigateContext.Provider>;\n}\n\nexport type RouterAnchorProps = AnchorHTMLAttributes<HTMLAnchorElement> & { href: string };\n\n/** Internal building block — not part of the public package API. */\nexport const RouterAnchor = forwardRef<HTMLAnchorElement, RouterAnchorProps>(function RouterAnchor(\n  { href, target, download, onClick, ...rest },\n  ref,\n) {\n  const navigate = useContext(SkrewwwNavigateContext);\n\n  function handleClick(event: MouseEvent<HTMLAnchorElement>) {\n    onClick?.(event);\n    if (!navigate) return;\n    const intercept = shouldInterceptNavigation({\n      href,\n      target,\n      download,\n      button: event.button,\n      metaKey: event.metaKey,\n      ctrlKey: event.ctrlKey,\n      shiftKey: event.shiftKey,\n      altKey: event.altKey,\n      defaultPrevented: event.defaultPrevented,\n    });\n    if (!intercept) return;\n    event.preventDefault();\n    navigate(href);\n  }\n\n  return <a ref={ref} href={href} target={target} download={download} onClick={handleClick} {...rest} />;\n});\n",
      "type": "registry:ui",
      "target": "~/components/ui/router-navigation.tsx"
    }
  ]
}
