{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "item",
  "title": "Item",
  "description": "A row of content: a picture or an icon, a title and a line under it, and actions at the end, alone or in a group that reads as a list. One that is a link or a button takes the rows’ tint, and in a group one highlight glides from row to row, as in the Listbox and the Sidebar.",
  "dependencies": [
    "@ui-sdk/react",
    "@ui-sdk/core",
    "class-variance-authority"
  ],
  "registryDependencies": [
    "https://kinoui.com/r/icon-tile.json",
    "https://kinoui.com/r/separator.json",
    "https://kinoui.com/r/highlight.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/item.tsx",
      "content": "'use client'\n\nimport { IconTile } from '@/registry/components/kino/icon-tile'\nimport { Separator } from '@/registry/components/kino/separator'\nimport {\n  followPointer,\n  hoveredRowTextClassName,\n  itemMatching,\n  rowHighlightClassName,\n  rowTintClassName,\n  tintedRowTextClassName,\n} from '@/registry/lib/highlight'\nimport { mergeProps, type PartProps, renderElement } from '@ui-sdk/react/primitive'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport {\n  type ComponentProps,\n  createContext,\n  type MouseEvent,\n  type ReactNode,\n  use,\n  useEffect,\n  useRef,\n  useState,\n} from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * A row of content: a picture or an icon, a title and a line under it, and\n * actions at the end. One that is a link or a button takes the rows' tint\n * under the pointer, as a Listbox's or a Sidebar's rows do: in a group, one\n * highlight glides from row to row.\n */\n\nconst GroupContext = createContext(false)\n\nconst itemVariants = cva(\n  [\n    // A row as wide as its group; a header or a footer takes a line of its own.\n    'group/item relative flex min-w-0 flex-wrap items-center rounded-(--list-radius) border border-transparent text-sm',\n    '[&_svg]:pointer-events-none [&_svg]:shrink-0',\n    'transition-[border-color,box-shadow] duration-(--motion-press-duration) ease-(--motion-press-fade-easing)',\n    // Inset, as on the Listbox's and the Sidebar's rows, so a list that scrolls never clips it.\n    'focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset focus-visible:outline-hidden',\n    'aria-disabled:pointer-events-none aria-disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 disabled:pointer-events-none disabled:opacity-50',\n    // Muted text in a tinted row is darker, so it keeps 4.5:1 on the tint.\n    tintedRowTextClassName,\n  ],\n  {\n    variants: {\n      variant: {\n        default: '',\n        /** A border, for an item that stands on its own. */\n        outline: 'border-border',\n        /** A muted fill, for an item set apart from what's around it. */\n        muted: 'bg-muted/50',\n      },\n      size: {\n        // Less the 1px border, so the content lines up with a card's header beside it.\n        default: 'gap-3 p-[calc(var(--surface-padding)-1px)]',\n        // As tall as a control with one line of text, as a Sidebar's row is.\n        sm: 'gap-2.5 px-[calc(var(--surface-padding)-1px)] py-[calc((var(--control-height)-1lh)/2-1px)]',\n      },\n    },\n    defaultVariants: { variant: 'default', size: 'default' },\n  },\n)\n\n/*\n * A lone item that acts takes the highlight's tint under the pointer, over\n * its own fill and border, fading in on `enter` and out on `exit` as the\n * highlight does. In a group, the group's one highlight does it instead.\n */\nconst loneTintClassName = cn(\n  rowTintClassName,\n  'pointer-events-none absolute -inset-px rounded-[inherit] opacity-0 [transition:opacity_var(--motion-exit-duration)_var(--motion-exit-easing)] group-hover/item:opacity-100 group-hover/item:[transition:opacity_var(--motion-enter-duration)_var(--motion-enter-easing)]',\n  // Only on an item that acts.\n  'group-[:not(a[href],button)]/item:hidden',\n)\n\n/**\n * A row: a `<div>`, or a link or a button with `render`. In a group it sits\n * in a list item of its own, so the group reads as a list.\n */\nfunction Item({\n  className,\n  variant,\n  size,\n  render,\n  children,\n  onClick,\n  ...props\n}: Omit<PartProps<'div'>, 'className'> & {\n  className?: string\n} & VariantProps<typeof itemVariants>) {\n  const inGroup = use(GroupContext)\n  const item = renderElement(\n    'div',\n    mergeProps(\n      {\n        'data-slot': 'item',\n        'data-variant': variant ?? 'default',\n        'data-size': size ?? 'default',\n        className: cn(\n          itemVariants({ variant, size }),\n          !inGroup && hoveredRowTextClassName,\n          className,\n        ),\n        onClick: (event: MouseEvent<HTMLDivElement>) => {\n          // A link can't be disabled: one marked `aria-disabled` still takes focus, so it\n          // is read, but Enter and a press do nothing.\n          if (event.currentTarget.getAttribute('aria-disabled') === 'true') {\n            event.preventDefault()\n            return\n          }\n          onClick?.(event)\n        },\n        children: inGroup ? (\n          children\n        ) : (\n          <>\n            {children}\n            <span aria-hidden data-slot='item-tint' className={loneTintClassName} />\n          </>\n        ),\n      },\n      props,\n    ),\n    render,\n  )\n  if (!inGroup) return item\n  return (\n    <div role='listitem' data-slot='item-listitem' className='grid min-w-0'>\n      {item}\n    </div>\n  )\n}\n\n/**\n * Items read as a list, with one highlight that glides between those that\n * act, under the pointer and with focus.\n */\nfunction ItemGroup({\n  className,\n  children,\n  render,\n  ...props\n}: Omit<PartProps<'div'>, 'className' | 'children'> & {\n  className?: string\n  children?: ReactNode\n}) {\n  const [group, setGroup] = useState<HTMLDivElement | null>(null)\n  const layerRef = useRef<HTMLSpanElement>(null)\n  useEffect(() => {\n    const layer = layerRef.current\n    if (!group || !layer) return\n    return followPointer(group, layer, {\n      itemOf: itemMatching(group, 'a[href][data-slot=item], button[data-slot=item]', {\n        rows: '[data-slot=item-listitem]',\n      }),\n      focus: true,\n    })\n  }, [group])\n  return renderElement(\n    'div',\n    mergeProps(\n      {\n        'data-slot': 'item-group',\n        ref: setGroup,\n        role: 'list',\n        className: cn(\n          'group/item-group relative isolate flex min-w-0 flex-col',\n          className,\n        ),\n        children: (\n          <GroupContext value>\n            {children}\n            <span\n              ref={layerRef}\n              aria-hidden\n              data-slot='item-highlight'\n              className={rowHighlightClassName}\n            />\n          </GroupContext>\n        ),\n      },\n      props,\n    ),\n    render,\n  )\n}\n\n/** A line between items. Decorative: the list already says where each item ends. */\nfunction ItemSeparator({ className, ...props }: ComponentProps<typeof Separator>) {\n  return (\n    <Separator\n      aria-hidden\n      data-item-separator=''\n      className={cn('my-0', className)}\n      {...props}\n    />\n  )\n}\n\nconst itemMediaVariants = cva(\n  // Level with the title when a description runs under it.\n  'flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none',\n  {\n    variants: {\n      variant: {\n        /** Whatever it holds, as it is: an avatar, a logo. */\n        default: 'bg-transparent',\n        /** An icon in an Icon tile; put an `IconTile` in a default one for another tone. */\n        icon: '',\n        /** A picture, cropped to a square. */\n        image:\n          'size-10 overflow-hidden rounded-(--control-radius-sm) group-data-[size=sm]/item:size-8 [&_img]:size-full [&_img]:object-cover',\n        /** A product's photo, large enough to see what it is, as in a cart. */\n        product:\n          'bg-muted size-16 overflow-hidden rounded-(--list-radius) group-data-[size=sm]/item:size-12 [&_img]:size-full [&_img]:object-cover',\n      },\n    },\n    defaultVariants: { variant: 'default' },\n  },\n)\n\n/** The picture: decorative, since the title names the item. */\nfunction ItemMedia({\n  className,\n  variant,\n  render,\n  children,\n  ...props\n}: Omit<PartProps<'div'>, 'className' | 'children'> & {\n  className?: string\n  children?: ReactNode\n} & VariantProps<typeof itemMediaVariants>) {\n  return renderElement(\n    'div',\n    mergeProps(\n      {\n        'data-slot': 'item-media',\n        'data-variant': variant ?? 'default',\n        'aria-hidden': true,\n        className: cn(itemMediaVariants({ variant }), className),\n        children: variant === 'icon' ? <IconTile>{children}</IconTile> : children,\n      },\n      props,\n    ),\n    render,\n  )\n}\n\n/** The title and the description, taking the room the media and actions leave. */\nfunction ItemContent({\n  className,\n  render,\n  ...props\n}: Omit<PartProps<'div'>, 'className'> & { className?: string }) {\n  return renderElement(\n    'div',\n    mergeProps(\n      {\n        'data-slot': 'item-content',\n        className: cn(\n          // Never narrower than a short name: below that, the actions wrap onto a line of\n          // their own rather than squeeze the text to a letter a line. A second content\n          // block, such as a price at the end, keeps its own width.\n          'flex min-w-0 grow basis-28 flex-col gap-1 group-data-[size=sm]/item:gap-0.5 [&+[data-slot=item-content]]:flex-none',\n          className,\n        ),\n      },\n      props,\n    ),\n    render,\n  )\n}\n\n/** A long unbroken word, such as an ID or a URL, breaks rather than run out of the row. */\nfunction ItemTitle({\n  className,\n  render,\n  ...props\n}: Omit<PartProps<'div'>, 'className'> & { className?: string }) {\n  return renderElement(\n    'div',\n    mergeProps(\n      {\n        'data-slot': 'item-title',\n        className: cn(\n          'flex w-fit max-w-full min-w-0 items-center gap-2 text-sm leading-5 font-medium wrap-anywhere',\n          className,\n        ),\n      },\n      props,\n    ),\n    render,\n  )\n}\n\nfunction ItemDescription({\n  className,\n  render,\n  ...props\n}: Omit<PartProps<'p'>, 'className'> & { className?: string }) {\n  return renderElement(\n    'p',\n    mergeProps(\n      {\n        'data-slot': 'item-description',\n        className: cn(\n          // A small item's line is the small print under a name, as in a list of people.\n          'text-muted-foreground *:[a]:hover:text-foreground text-sm leading-5 text-pretty wrap-anywhere group-data-[size=sm]/item:text-xs group-data-[size=sm]/item:leading-4 *:[a]:underline *:[a]:underline-offset-3',\n          className,\n        ),\n      },\n      props,\n    ),\n    render,\n  )\n}\n\n/** Buttons and controls at the end of the row. */\nfunction ItemActions({\n  className,\n  render,\n  ...props\n}: Omit<PartProps<'div'>, 'className'> & { className?: string }) {\n  return renderElement(\n    'div',\n    mergeProps(\n      {\n        'data-slot': 'item-actions',\n        className: cn('flex shrink-0 items-center gap-2', className),\n      },\n      props,\n    ),\n    render,\n  )\n}\n\n/** A line across the whole row, above the rest, such as a picture's. */\nfunction ItemHeader({\n  className,\n  render,\n  ...props\n}: Omit<PartProps<'div'>, 'className'> & { className?: string }) {\n  return renderElement(\n    'div',\n    mergeProps(\n      {\n        'data-slot': 'item-header',\n        className: cn('flex basis-full items-center justify-between gap-2', className),\n      },\n      props,\n    ),\n    render,\n  )\n}\n\n/** A line across the whole row, below the rest. */\nfunction ItemFooter({\n  className,\n  render,\n  ...props\n}: Omit<PartProps<'div'>, 'className'> & { className?: string }) {\n  return renderElement(\n    'div',\n    mergeProps(\n      {\n        'data-slot': 'item-footer',\n        className: cn('flex basis-full items-center justify-between gap-2', className),\n      },\n      props,\n    ),\n    render,\n  )\n}\n\nexport {\n  Item,\n  ItemActions,\n  ItemContent,\n  ItemDescription,\n  ItemFooter,\n  ItemGroup,\n  ItemHeader,\n  ItemMedia,\n  ItemSeparator,\n  ItemTitle,\n  itemMediaVariants,\n  itemVariants,\n}\n",
      "type": "registry:component",
      "target": "@components/kino/item.tsx"
    }
  ],
  "type": "registry:component"
}