{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "list-rows",
  "title": "List rows",
  "description": "What the Menu and every list you pick from share: its rows, their ticks and headings, and one highlight that glides between them.",
  "dependencies": [
    "class-variance-authority"
  ],
  "registryDependencies": [
    "https://kinoui.com/r/separator.json",
    "https://kinoui.com/r/highlight.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/lib/list-rows.tsx",
      "content": "'use client'\n\nimport { separatorVariants } from '@/registry/components/kino/separator'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { highlightClassName, tintedRowTextClassName } from '@/registry/lib/highlight'\nimport { cva } from 'class-variance-authority'\nimport type { ComponentProps } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * What the lists of rows share, the Menu's and every list you pick from\n * (Select, Listbox, Combobox, Command, Tree): the rows, their ticks and\n * headings, and the one highlight that glides between them.\n */\n\n/**\n * The highlight behind the rows: the accent, a tint behind a destructive\n * row, and the system's own colour under forced colours. Its parent is the\n * list of rows; track it with `followRows`.\n */\nfunction MenuHighlight({ className, ...props }: ComponentProps<'div'>) {\n  return (\n    <div\n      aria-hidden\n      data-slot='menu-highlight'\n      className={cn(\n        highlightClassName,\n        'bg-accent data-[variant=destructive]:bg-destructive/10 dark:data-[variant=destructive]:bg-destructive/20 forced-colors:bg-[Highlight]! forced-colors:forced-color-adjust-none',\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\n/*\n * The gutter a list's rows keep for a tick: the icon's width and the gap, when\n * one of its own rows has a tick with no icon after it (a tick in a row with\n * its own icon, an svg or a `MenuItemIcon`, sits at the row's end). It goes on the element around the\n * rows. CSS takes no `:has()` inside `:has()`, so each case is its own\n * selector. Only rows a few levels down count, so a submenu, which renders inside\n * the list that opened it, keeps a gutter of its own.\n */\nconst menuGutterClassName =\n  '[--menu-gutter:0px] has-[>[data-menu-row]>[data-menu-indicator]:last-child,>[data-menu-row]>[data-menu-indicator]+:not(svg,[data-menu-icon]),>*>[data-menu-row]>[data-menu-indicator]:last-child,>*>[data-menu-row]>[data-menu-indicator]+:not(svg,[data-menu-icon]),>*>*>[data-menu-row]>[data-menu-indicator]:last-child,>*>*>[data-menu-row]>[data-menu-indicator]+:not(svg,[data-menu-icon])]:[--menu-gutter:1.5rem]'\n\n/** A row with no icon of its own lines up with the others' text, past the list's tick gutter. */\nconst menuInset =\n  'not-has-[>:is(svg,[data-menu-icon]):not([data-menu-chevron])]:ps-[calc(var(--control-padding)+var(--menu-gutter,0px))]'\n\nconst menuRowVariants = cva(\n  // overflow-wrap: anywhere lets a URL or an ID break, so a long label wraps\n  // to the next line and is read in full.\n  \"relative flex min-h-(--control-height-sm) cursor-default items-center gap-2 rounded-(--item-radius) px-(--control-padding) py-1 text-start text-sm [overflow-wrap:anywhere] select-none focus:outline-hidden data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 forced-colors:data-highlighted:text-[HighlightText] forced-colors:data-highlighted:forced-color-adjust-none forced-colors:data-highlighted:**:text-[HighlightText]\",\n  {\n    variants: {\n      variant: {\n        default:\n          '[&>:is(svg,[data-menu-icon])]:text-muted-foreground data-highlighted:text-accent-foreground',\n        // A fifth of the foreground takes the text past 4.5:1 on its tint, as on the Button.\n        destructive:\n          'text-[color-mix(in_oklch,var(--destructive),var(--foreground)_20%)] [&>:is(svg,[data-menu-icon])]:text-current [&_[data-menu-shortcut]]:text-current',\n      },\n    },\n    defaultVariants: { variant: 'default' },\n  },\n)\n\n/** The tick: it scales in when picked and out when cleared. */\nconst menuIndicatorClassName =\n  'grid place-items-center transition-[opacity,scale] duration-(--motion-enter-duration) ease-(--motion-enter-easing) data-starting-style:scale-95 data-starting-style:opacity-0 data-ending-style:scale-95 data-ending-style:opacity-0 data-ending-style:duration-(--motion-exit-duration) data-ending-style:ease-(--motion-exit-easing) motion-reduce:scale-100 motion-reduce:data-starting-style:scale-100 motion-reduce:data-ending-style:scale-100'\n\n/**\n * The tick of a ui-sdk list's item, kept mounted (`keepMounted`): it scales\n * in when its item is picked (`data-selected`) and out when cleared, turning\n * back from where it is.\n */\nconst listIndicatorClassName =\n  'grid place-items-center opacity-0 transition-[opacity,scale] duration-(--motion-exit-duration) ease-(--motion-exit-easing) motion-safe:scale-95 [&:is([data-selected],[data-checked])]:opacity-100 [&:is([data-selected],[data-checked])]:duration-(--motion-enter-duration) [&:is([data-selected],[data-checked])]:ease-(--motion-enter-easing) motion-safe:[&:is([data-selected],[data-checked])]:scale-100'\n\n/*\n * Where the tick sits: in the gutter, or at the end of the row when\n * the row has an icon of its own, which takes the gutter as on any other row.\n * One line tall, so it sits on the label's first line in a row that holds its\n * items to the top (the Tree's).\n */\nconst menuIndicatorSlot =\n  'grid h-lh w-4 shrink-0 place-items-center group-has-[>:is(svg,[data-menu-icon])]/menu-row:order-last group-has-[>:is(svg,[data-menu-icon])]/menu-row:ms-auto'\n\n/** The tick of a picked row. */\nfunction MenuTick() {\n  return (\n    <IconPlaceholder\n      lucide='CheckIcon'\n      tabler='IconCheck'\n      hugeicons='Tick02Icon'\n      phosphor='CheckIcon'\n      remixicon='RiCheckLine'\n      aria-hidden\n      className='text-foreground forced-colors:text-current'\n    />\n  )\n}\n\n/**\n * The picked row of a radio group: a tint a step deeper than the highlight's,\n * so the two never read as one, and a medium label, so it shows by more than\n * colour (its muted asides, such as a shortcut, stay regular). No mark beside it keeps a gap on every other row. Under forced\n * colours, where the highlight takes the system's colour, it is outlined.\n */\nconst menuPickedRowClassName = cn(\n  tintedRowTextClassName,\n  'aria-checked:bg-foreground/7 aria-[current=true]:bg-foreground/7 dark:aria-checked:bg-foreground/10 dark:aria-[current=true]:bg-foreground/10',\n  'aria-checked:font-medium aria-[current=true]:font-medium aria-checked:[&_.text-muted-foreground]:font-normal aria-[current=true]:[&_.text-muted-foreground]:font-normal',\n  'forced-colors:aria-checked:outline-1 forced-colors:aria-checked:-outline-offset-1 forced-colors:aria-checked:outline-[CanvasText] forced-colors:aria-[current=true]:outline-1 forced-colors:aria-[current=true]:-outline-offset-1 forced-colors:aria-[current=true]:outline-[CanvasText]',\n  'transition-[background-color] duration-(--motion-press-duration) ease-(--motion-press-fade-easing)',\n)\n\n/** Where a group's heading starts: the rows' text, past any tick's gutter. */\nconst menuLabelInset =\n  'px-(--control-padding) ps-[calc(var(--control-padding)+var(--menu-gutter,0px))]'\n\n/** A group's heading, lined up with the rows' text past any tick's gutter. */\nconst menuLabelClassName = cn(\n  'text-muted-foreground pt-2 pb-1 text-xs font-medium',\n  menuLabelInset,\n)\n\n/*\n * A line in the box where the rows would be, for a list with nothing to\n * show. Kept mounted, so what it announces is heard, and filled only when it\n * has something to say: until then it takes no room.\n */\nconst menuNoticeClassName =\n  'text-muted-foreground flex items-center justify-center gap-2 px-(--control-padding) text-center text-sm [overflow-wrap:anywhere] not-empty:min-h-20 not-empty:flex-1 not-empty:py-4'\n\n/** The Separator's line between groups of rows, across the list's 4px margin. */\nconst menuSeparatorClassName = cn(separatorVariants(), '-mx-1 my-1 w-auto')\n\n/** A shortcut at a row's end, such as `Kbd` keys or an aside. */\nconst menuShortcutClassName =\n  // Muted text on the highlight falls under 4.5:1, so it takes the row's colour there.\n  'text-muted-foreground in-data-highlighted:text-accent-foreground/80 ms-auto shrink-0 ps-4 text-xs whitespace-nowrap tabular-nums forced-colors:in-data-highlighted:text-[HighlightText]'\n\n/** A shortcut or an aside at the end of a list's row that isn't a menu's, such as a Command's. */\nfunction RowShortcut({ className, children, ...props }: ComponentProps<'span'>) {\n  return (\n    <span\n      data-menu-shortcut=''\n      className={cn(menuShortcutClassName, className)}\n      {...props}\n    >\n      {/* Keys read left to right in a right-to-left list too. */}\n      <span dir='ltr'>{children}</span>\n    </span>\n  )\n}\n\nexport {\n  MenuHighlight,\n  MenuTick,\n  RowShortcut,\n  listIndicatorClassName,\n  menuIndicatorClassName,\n  menuIndicatorSlot,\n  menuInset,\n  menuGutterClassName,\n  menuLabelClassName,\n  menuNoticeClassName,\n  menuPickedRowClassName,\n  menuRowVariants,\n  menuSeparatorClassName,\n  menuShortcutClassName,\n}\n",
      "type": "registry:lib",
      "target": "@lib/list-rows.tsx"
    }
  ],
  "type": "registry:lib"
}