{
  "name": "reply-preview",
  "type": "registry:ui",
  "framework": "react",
  "title": "Reply Preview",
  "description": "A compact \"replying to\" bar showing the author, a truncated excerpt, or the slash command that was used.",
  "files": [
    {
      "path": "ui/reply-preview.tsx",
      "content": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst ReplyPreview = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\n      \"relative mb-1 flex min-w-0 items-center gap-1.5 ps-[18px] text-[13px] leading-4 text-newt-text-muted\",\n      /* The elbow that hooks the preview back up to the message above it. */\n      \"before:absolute before:start-0 before:top-1/2 before:h-3 before:w-3 before:-translate-y-full before:rounded-ss-[6px] before:border-s-2 before:border-t-2 before:border-newt-border before:content-['']\",\n      /*\n       * In the reply slot of a message group the preview has no margin and no\n       * padding: the row sets the distance to the author line. The reach is\n       * the distance from the preview back to the centre of the avatar, from\n       * the two properties the group publishes. The fallbacks are the values\n       * of a group that does not publish them.\n       */\n      \"[[data-slot=message-reply]_&]:mb-0 [[data-slot=message-reply]_&]:ps-0 [[data-slot=message-reply]_&]:[--newt-reply-spine-reach:calc(var(--newt-message-group-avatar-size,40px)_/_2_+_var(--newt-message-group-gap,16px))]\",\n      /*\n       * There the spine leaves the preview. It starts above the centre of the\n       * avatar, half a stroke back so the 2px stroke is centred, and stops\n       * 4px before the preview.\n       */\n      \"[[data-slot=message-reply]_&]:before:bottom-0 [[data-slot=message-reply]_&]:before:end-[calc(100%_+_4px)] [[data-slot=message-reply]_&]:before:start-[calc(-1_*_var(--newt-reply-spine-reach)_-_1px)] [[data-slot=message-reply]_&]:before:top-[calc(50%_-_1px)] [[data-slot=message-reply]_&]:before:h-auto [[data-slot=message-reply]_&]:before:w-auto [[data-slot=message-reply]_&]:before:translate-y-0\",\n      className\n    )}\n    {...props}\n  />\n))\nReplyPreview.displayName = \"ReplyPreview\"\n\nexport interface ReplyPreviewAvatarProps extends Omit<\n  React.ImgHTMLAttributes<HTMLImageElement>,\n  \"children\"\n> {\n  /**\n   * The fallback, drawn when there is no `src` and no `srcSet`: an icon or\n   * initials in a\n   * 16px circle. The circle sizes an `svg` to 10px.\n   */\n  children?: React.ReactNode\n}\n\n/*\n * The avatar of the referenced author. With a `src` or a `srcSet` it is an\n * image. Without either it is a circle that holds its children, so an avatar that is an icon\n * can be drawn. An empty `alt` hides either form from a screen reader.\n */\nconst ReplyPreviewAvatar = React.forwardRef<\n  HTMLElement,\n  ReplyPreviewAvatarProps\n>(({ className, alt = \"\", src, srcSet, children, ...props }, ref) => {\n  const decorative = alt === \"\"\n  if (src !== undefined || srcSet !== undefined) {\n    /*\n     * `createElement` types the ref by the element it is given here, so the\n     * one `HTMLElement` ref serves both forms without an assertion.\n     */\n    return React.createElement(\"img\", {\n      ref,\n      src,\n      srcSet,\n      alt,\n      \"aria-hidden\": decorative ? true : undefined,\n      className: cn(\"h-4 w-4 shrink-0 rounded-full object-cover\", className),\n      ...props,\n    })\n  }\n  return (\n    <span\n      ref={ref}\n      role={decorative ? undefined : \"img\"}\n      aria-label={decorative ? undefined : alt}\n      aria-hidden={decorative ? true : undefined}\n      className={cn(\n        \"inline-flex h-4 w-4 shrink-0 items-center justify-center overflow-hidden rounded-full bg-newt-brand text-[9px] font-semibold text-newt-on-accent [&>svg]:h-2.5 [&>svg]:w-2.5\",\n        className\n      )}\n      {...props}\n    >\n      {children}\n    </span>\n  )\n})\nReplyPreviewAvatar.displayName = \"ReplyPreviewAvatar\"\n\nconst ReplyPreviewAuthor = React.forwardRef<\n  HTMLSpanElement,\n  React.ComponentProps<\"span\">\n>(({ className, ...props }, ref) => (\n  <span\n    ref={ref}\n    className={cn(\"shrink-0 font-medium text-newt-text-link\", className)}\n    {...props}\n  />\n))\nReplyPreviewAuthor.displayName = \"ReplyPreviewAuthor\"\n\nconst ReplyPreviewText = React.forwardRef<\n  HTMLSpanElement,\n  React.ComponentProps<\"span\">\n>(({ className, ...props }, ref) => (\n  <span\n    ref={ref}\n    className={cn(\n      \"min-w-0 max-w-[360px] truncate text-newt-text-muted\",\n      className\n    )}\n    {...props}\n  />\n))\nReplyPreviewText.displayName = \"ReplyPreviewText\"\n\n/* \"used\" — the verb between the author and an interaction chip. */\nconst ReplyPreviewAction = React.forwardRef<\n  HTMLSpanElement,\n  React.ComponentProps<\"span\">\n>(({ className, ...props }, ref) => (\n  <span ref={ref} className={cn(\"shrink-0\", className)} {...props} />\n))\nReplyPreviewAction.displayName = \"ReplyPreviewAction\"\n\nexport interface ReplyPreviewCommandProps extends React.ComponentProps<\"span\"> {\n  /**\n   * An icon before the command name. It sits outside the truncating label,\n   * so the gap of the chip applies and the icon never clips.\n   */\n  icon?: React.ReactNode\n}\n\n/* The command chip shown when the reply is a slash-command interaction. */\nconst ReplyPreviewCommand = React.forwardRef<\n  HTMLSpanElement,\n  ReplyPreviewCommandProps\n>(({ className, icon, children, ...props }, ref) => (\n  <span\n    ref={ref}\n    className={cn(\n      \"inline-flex min-w-0 items-center gap-0.5 rounded-[var(--newt-radius-sm)] bg-[color-mix(in_srgb,var(--newt-brand)_15%,transparent)] px-1 font-medium text-newt-mention-text [&>svg]:h-3 [&>svg]:w-3 [&>svg]:shrink-0\",\n      className\n    )}\n    {...props}\n  >\n    {icon}\n    <span className=\"truncate\">{children}</span>\n  </span>\n))\nReplyPreviewCommand.displayName = \"ReplyPreviewCommand\"\n\nexport {\n  ReplyPreview,\n  ReplyPreviewAvatar,\n  ReplyPreviewAuthor,\n  ReplyPreviewText,\n  ReplyPreviewAction,\n  ReplyPreviewCommand,\n}\n",
      "type": "registry:ui"
    }
  ]
}