{
  "name": "slash-command-suggestions",
  "type": "registry:ui",
  "framework": "react",
  "title": "Slash Command Suggestions",
  "description": "The command picker that opens above the composer, with an app rail, grouped options and a matched-command preview.",
  "dependencies": [
    "class-variance-authority"
  ],
  "registryDependencies": [
    "@newtui/slash-command",
    "@newtui/scrollbar"
  ],
  "files": [
    {
      "path": "ui/slash-command-suggestions.tsx",
      "content": "import { cva, type VariantProps } from \"class-variance-authority\"\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { scrollbarClassName } from \"@/registry/bases/newt/ui/scrollbar\"\n\n/*\n * The picker that opens above the composer once a message starts with `/`.\n * Focus stays in the composer: wire `aria-activedescendant` on the input to\n * the id of the active option rather than moving focus into the list.\n *\n * A grid, so the parts need no wrapper: the rail and the list share the first\n * row, the footer takes the second, and a rail laid as a row takes the third.\n * The picker is a size container: its parts change layout from its own width,\n * not from the viewport. Set `--newt-slash-suggestions-max-width` to change\n * the 640px cap, or to `none` to fill the composer.\n */\nconst SlashCommandSuggestions = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\n      \"grid max-h-80 w-full max-w-[var(--newt-slash-suggestions-max-width,640px)] grid-cols-[auto_minmax(0,1fr)] grid-rows-[minmax(0,1fr)_auto_auto] overflow-hidden rounded-[var(--newt-radius-lg)] bg-newt-bg-floating text-newt-text-primary shadow-elevation-high [container-type:inline-size]\",\n      className\n    )}\n    {...props}\n  />\n))\nSlashCommandSuggestions.displayName = \"SlashCommandSuggestions\"\n\nconst railOrientations = {\n  vertical: \"col-start-1 row-start-1 flex-col overflow-y-auto border-e\",\n  horizontal:\n    \"col-span-full row-start-3 flex-row overflow-x-auto overflow-y-hidden border-t\",\n}\n\n/* The horizontal layout again, for a picker narrower than 480px. */\nconst railNarrow =\n  \"[@container_(max-width:480px)]:col-span-full [@container_(max-width:480px)]:row-start-3 [@container_(max-width:480px)]:flex-row [@container_(max-width:480px)]:overflow-x-auto [@container_(max-width:480px)]:overflow-y-hidden [@container_(max-width:480px)]:border-e-0 [@container_(max-width:480px)]:border-t\"\n\nexport interface SlashCommandSuggestionsRailProps extends React.ComponentProps<\"nav\"> {\n  /**\n   * Lays the rail as a column beside the list, or as a row under it. Without\n   * it, the rail is a column, and a row when the picker is narrower than 480px.\n   */\n  orientation?: \"vertical\" | \"horizontal\"\n}\n\n/* Strip of app icons that filters the list by app. */\nconst SlashCommandSuggestionsRail = React.forwardRef<\n  HTMLElement,\n  SlashCommandSuggestionsRailProps\n>(({ className, orientation, ...props }, ref) => (\n  <nav\n    ref={ref}\n    data-orientation={orientation}\n    className={cn(\n      \"flex items-center gap-2 border-newt-border bg-newt-bg-base p-2\",\n      railOrientations[orientation ?? \"vertical\"],\n      orientation === undefined && railNarrow,\n      className\n    )}\n    {...props}\n  />\n))\nSlashCommandSuggestionsRail.displayName = \"SlashCommandSuggestionsRail\"\n\nexport interface SlashCommandSuggestionsRailItemProps extends React.ComponentProps<\"button\"> {\n  active?: boolean\n}\n\nconst SlashCommandSuggestionsRailItem = React.forwardRef<\n  HTMLButtonElement,\n  SlashCommandSuggestionsRailItemProps\n>(({ className, active = false, type = \"button\", ...props }, ref) => (\n  <button\n    ref={ref}\n    type={type}\n    aria-pressed={active}\n    data-state={active ? \"active\" : \"inactive\"}\n    className={cn(\n      \"inline-flex h-9 w-9 shrink-0 cursor-pointer items-center justify-center rounded-full border-0 bg-transparent p-0 text-newt-text-muted transition-colors duration-fast ease-newt\",\n      \"hover:bg-newt-bg-hover hover:text-newt-text-primary\",\n      \"data-[state=active]:bg-newt-bg-active data-[state=active]:text-newt-text-primary\",\n      \"focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link\",\n      className\n    )}\n    {...props}\n  />\n))\nSlashCommandSuggestionsRailItem.displayName = \"SlashCommandSuggestionsRailItem\"\n\nconst SlashCommandSuggestionsList = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, role = \"listbox\", ...props }, ref) => (\n  <div\n    ref={ref}\n    role={role}\n    className={cn(\n      \"col-start-2 row-start-1 min-w-0 overflow-y-auto p-2\",\n      scrollbarClassName,\n      className\n    )}\n    {...props}\n  />\n))\nSlashCommandSuggestionsList.displayName = \"SlashCommandSuggestionsList\"\n\n/* Sticky section header, as used by the \"Frequently Used\" block. */\nconst SlashCommandSuggestionsHeader = React.forwardRef<\n  HTMLParagraphElement,\n  React.ComponentProps<\"p\">\n>(({ className, ...props }, ref) => (\n  <p\n    ref={ref}\n    role=\"presentation\"\n    className={cn(\n      \"sticky top-0 z-[1] m-0 flex items-center gap-1.5 bg-newt-bg-floating px-2 py-1.5 text-sm font-semibold text-newt-text-primary\",\n      className\n    )}\n    {...props}\n  />\n))\nSlashCommandSuggestionsHeader.displayName = \"SlashCommandSuggestionsHeader\"\n\n/* Bar under the rail and the list, for the command being typed. */\nconst SlashCommandSuggestionsFooter = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\n      \"col-span-full row-start-2 flex min-w-0 items-center gap-2 border-t border-newt-border px-3 py-2 text-[13px] leading-snug text-newt-text-secondary\",\n      className\n    )}\n    {...props}\n  />\n))\nSlashCommandSuggestionsFooter.displayName = \"SlashCommandSuggestionsFooter\"\n\nconst SlashCommandSuggestionGroup = React.forwardRef<\n  HTMLElement,\n  React.ComponentProps<\"section\">\n>(({ className, role = \"group\", ...props }, ref) => (\n  <section\n    ref={ref}\n    role={role}\n    className={cn(\"min-w-0\", className)}\n    {...props}\n  />\n))\nSlashCommandSuggestionGroup.displayName = \"SlashCommandSuggestionGroup\"\n\n/*\n * An image fills the circle. Anything else is a glyph at half its size: an\n * inline SVG, or the element an icon component renders, which is often a\n * `<span>`.\n */\nconst appIconVariants = cva(\n  \"inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-newt-bg-elevated text-newt-text-muted [&>img]:h-full [&>img]:w-full [&>img]:object-cover [&>svg]:h-1/2 [&>svg]:w-1/2 [&>:first-child:not(img)]:h-1/2 [&>:first-child:not(img)]:w-1/2\",\n  {\n    variants: {\n      size: {\n        header: \"h-4 w-4\",\n        row: \"h-6 w-6\",\n        rail: \"h-8 w-8\",\n      },\n    },\n    defaultVariants: { size: \"row\" },\n  }\n)\n\nexport interface SlashCommandAppIconProps\n  extends React.ComponentProps<\"span\">, VariantProps<typeof appIconVariants> {}\n\nconst SlashCommandAppIcon = React.forwardRef<\n  HTMLSpanElement,\n  SlashCommandAppIconProps\n>(({ className, size, ...props }, ref) => (\n  <span\n    ref={ref}\n    aria-hidden=\"true\"\n    className={cn(appIconVariants({ size }), className)}\n    {...props}\n  />\n))\nSlashCommandAppIcon.displayName = \"SlashCommandAppIcon\"\n\nexport interface SlashCommandSuggestionProps extends Omit<\n  React.ComponentProps<\"div\">,\n  \"children\"\n> {\n  /** Command path without the leading slash, e.g. `moderation ban`. */\n  name: string\n  description?: string\n  /** Name of the app the command belongs to, shown on the right. */\n  appLabel?: string\n  /** Icon for the owning app; pair with `<SlashCommandAppIcon>`. */\n  icon?: React.ReactNode\n  active?: boolean\n  disabled?: boolean\n}\n\n/*\n * In a picker narrower than 480px, the app name moves beside the command\n * name, and the description takes the full width under them, on up to two\n * lines.\n */\nconst SlashCommandSuggestion = React.forwardRef<\n  HTMLDivElement,\n  SlashCommandSuggestionProps\n>(\n  (\n    {\n      className,\n      name,\n      description,\n      appLabel,\n      icon,\n      active = false,\n      disabled = false,\n      ...props\n    },\n    ref\n  ) => (\n    <div\n      ref={ref}\n      role=\"option\"\n      aria-selected={active}\n      aria-disabled={disabled || undefined}\n      data-state={active ? \"active\" : \"inactive\"}\n      className={cn(\n        \"grid min-h-12 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 rounded-[var(--newt-radius-md)] px-2 py-1.5\",\n        \"[@container_(max-width:480px)]:gap-x-2 [@container_(max-width:480px)]:gap-y-0.5\",\n        disabled\n          ? \"cursor-default opacity-60\"\n          : \"cursor-pointer hover:bg-newt-bg-hover\",\n        \"data-[state=active]:bg-newt-bg-active\",\n        className\n      )}\n      {...props}\n    >\n      {icon}\n      <div className=\"flex min-w-0 flex-col gap-0.5 [@container_(max-width:480px)]:contents\">\n        <span className=\"text-[15px] font-semibold leading-tight text-newt-text-primary [@container_(max-width:480px)]:col-start-2 [@container_(max-width:480px)]:row-start-1\">\n          {/* The slash stands off the command path. A margin keeps the text `/ban`. */}\n          <span className=\"me-1\">/</span>\n          {name}\n        </span>\n        {description ? (\n          <span className=\"truncate text-[13px] leading-snug text-newt-text-secondary [@container_(max-width:480px)]:col-[2/-1] [@container_(max-width:480px)]:row-start-2 [@container_(max-width:480px)]:line-clamp-2 [@container_(max-width:480px)]:whitespace-normal\">\n            {description}\n          </span>\n        ) : null}\n      </div>\n      {appLabel ? (\n        <span className=\"shrink-0 text-[13px] text-newt-text-secondary [@container_(max-width:480px)]:col-start-3 [@container_(max-width:480px)]:row-start-1\">\n          {appLabel}\n        </span>\n      ) : null}\n    </div>\n  )\n)\nSlashCommandSuggestion.displayName = \"SlashCommandSuggestion\"\n\nexport interface SlashCommandSuggestionMatchedProps extends React.ComponentProps<\"div\"> {\n  active?: boolean\n}\n\n/* Row that previews the command already typed, rendered with `<SlashCommand>`. */\nconst SlashCommandSuggestionMatched = React.forwardRef<\n  HTMLDivElement,\n  SlashCommandSuggestionMatchedProps\n>(({ className, active = false, ...props }, ref) => (\n  <div\n    ref={ref}\n    role=\"option\"\n    aria-selected={active}\n    data-state={active ? \"active\" : \"inactive\"}\n    className={cn(\n      \"min-h-11 cursor-pointer rounded-[var(--newt-radius-md)] px-3 py-2 hover:bg-newt-bg-hover\",\n      \"data-[state=active]:bg-newt-bg-active\",\n      className\n    )}\n    {...props}\n  />\n))\nSlashCommandSuggestionMatched.displayName = \"SlashCommandSuggestionMatched\"\n\nexport {\n  SlashCommandSuggestions,\n  SlashCommandSuggestionsRail,\n  SlashCommandSuggestionsRailItem,\n  SlashCommandSuggestionsList,\n  SlashCommandSuggestionsHeader,\n  SlashCommandSuggestionsFooter,\n  SlashCommandSuggestionGroup,\n  SlashCommandAppIcon,\n  SlashCommandSuggestion,\n  SlashCommandSuggestionMatched,\n}\n",
      "type": "registry:ui"
    }
  ]
}