{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "emoji-suggestions",
  "title": "Emoji Suggestions",
  "description": "The shortcode suggestions menu for what useEmojiSuggestions returns, at the caret on Floating UI. It never takes focus; the hook handles the keys. The Tiptap and Lexical items render it.",
  "dependencies": [
    "emoji-components@1.0.0-alpha.4",
    "@floating-ui/react"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "registry/emoji-suggestions.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { autoUpdate, flip, FloatingPortal, getOverflowAncestors, hide, offset, type Placement, shift, size, useDismiss, useFloating, useInteractions } from \"@floating-ui/react\";\nimport { Emoji, useEmojiStore, type UseEmojiSuggestionsReturnValue } from \"emoji-components\";\nimport { cn } from \"@/lib/utils\";\n\ntype EmojiSuggestionsProps = UseEmojiSuggestionsReturnValue & { placement?: Placement; className?: string };\n\nfunction EmojiSuggestions({ open, anchor, dismiss, suggestions, getListProps, getOptionProps, placement = \"bottom-start\", className }: EmojiSuggestionsProps) {\n  const store = useEmojiStore();\n  // Floating UI watches the field's scrolling ancestors, not the field: a textarea or editor that scrolls itself moves the query too\n  const field = anchor.contextElement;\n  const { refs, floatingStyles, context, middlewareData } = useFloating({\n    open,\n    onOpenChange: (next) => next || dismiss(),\n    placement,\n    strategy: \"fixed\",\n    transform: false,\n    whileElementsMounted: (reference, floating, update) => {\n      const stop = autoUpdate(reference, floating, update);\n      // A frame later: a text field's query is measured on a clone that syncs its scroll each frame\n      const onScroll = () => requestAnimationFrame(update);\n      field?.addEventListener(\"scroll\", onScroll, { passive: true });\n      return () => {\n        stop();\n        field?.removeEventListener(\"scroll\", onScroll);\n      };\n    },\n    middleware: [\n      offset(6),\n      flip({ padding: 8, crossAxis: false }),\n      shift({ padding: 8 }),\n      size({ padding: 8, apply: ({ availableHeight, elements }) => void elements.floating.style.setProperty(\"max-height\", `${Math.floor(availableHeight)}px`) }),\n      hide({ boundary: field ? [field, ...getOverflowAncestors(field).filter((el): el is Element => el instanceof Element && el !== el.ownerDocument.body)] : \"clippingAncestors\" }),\n    ],\n  });\n  // The field keeps focus and handles the keys, Escape included\n  React.useLayoutEffect(() => refs.setPositionReference(anchor), [refs, anchor]);\n  const { getFloatingProps } = useInteractions([useDismiss(context, { escapeKey: false })]);\n  if (!open) return null;\n  return (\n    <FloatingPortal>\n      <ul\n        ref={refs.setFloating}\n        style={{ ...floatingStyles, visibility: middlewareData.hide?.referenceHidden ? \"hidden\" : undefined }}\n        {...getListProps(getFloatingProps())}\n        data-slot=\"emoji-suggestions\"\n        className={cn(\"z-50 w-64 overflow-y-auto rounded-lg border border-border bg-popover p-1 text-sm text-popover-foreground shadow-lg\", className)}\n      >\n        {suggestions.map((s, i) => {\n          const [start, end] = s.match ?? [0, 0];\n          return (\n            <li key={s.record.unified} {...getOptionProps(i)} className=\"flex h-8 cursor-default items-center gap-2 rounded-md px-2 data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground\">\n              <Emoji emoji={store.withSkinTone(s.record.unified)} size={18} className=\"shrink-0 leading-none\" />\n              <span className=\"truncate font-mono text-[13px]\">\n                :{s.shortcode.slice(0, start)}\n                <b className=\"font-semibold\">{s.shortcode.slice(start, end)}</b>\n                {s.shortcode.slice(end)}:\n              </span>\n            </li>\n          );\n        })}\n      </ul>\n    </FloatingPortal>\n  );\n}\n\nexport { EmojiSuggestions };\nexport type { EmojiSuggestionsProps };\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}