{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "typing-indicator",
  "title": "Typing indicator",
  "description": "Three dots waving in turn with an \"Aiko is typing\" sentence for one or several names, as a chat bubble, inline or dots only, mounting and leaving on a spring; reduced motion keeps the dots still.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json",
    "https://goodui.dev/r/locale.json"
  ],
  "files": [
    {
      "path": "registry/components/ai/typing-indicator.tsx",
      "content": "\"use client\"\r\n\r\nimport * as React from \"react\"\r\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\"\r\nimport { cn } from \"@/lib/utils\"\r\nimport { useLabels } from \"@/lib/goodui-locale\"\r\nimport { GooduiTokens, spring } from \"@/lib/goodui-motion\"\r\n\r\n/*\r\n * \"Aiko is typing\" with three dots that wave. Bubble, inline and dots-only variants, one or several names,\r\n * and an enter/exit animation driven by `show`. Reduced motion keeps the dots still.\r\n */\r\n\r\nconst CSS = `\r\n@keyframes pc-typing-wave{0%,60%,100%{transform:translateY(0);opacity:.45}30%{transform:translateY(-35%);opacity:1}}\r\n.pc-typing-dot{animation:pc-typing-wave 1.2s ease-in-out infinite}\r\n.pc-typing-dot:nth-child(2){animation-delay:.15s}\r\n.pc-typing-dot:nth-child(3){animation-delay:.3s}\r\n@media (prefers-reduced-motion:reduce){.pc-typing-dot{animation:none;opacity:.7}}\r\n`\r\n\r\nexport type TypingIndicatorLabels = {\r\n  /** Builds the sentence from the names: \"Aiko is typing\", \"Aiko and Sam are typing\". */\r\n  typing: (names: string[]) => string\r\n  /** Used when no name is given. */\r\n  someone: string\r\n}\r\nconst list = (names: string[]) => (names.length <= 1 ? (names[0] ?? \"\") : names.length === 2 ? `${names[0]} and ${names[1]}` : `${names.slice(0, -1).join(\", \")} and ${names[names.length - 1]}`)\r\nconst DEFAULT_LABELS: TypingIndicatorLabels = { typing: (names) => (names.length ? `${list(names)} ${names.length > 1 ? \"are\" : \"is\"} typing` : \"Typing\"), someone: \"Someone\" }\r\n\r\nexport type TypingIndicatorProps = Omit<React.ComponentProps<\"div\">, \"children\" | \"onDrag\" | \"onDragStart\" | \"onDragEnd\" | \"onAnimationStart\"> & {\r\n  /** Who is typing. */\r\n  names?: string | string[]\r\n  /** Mount and unmount with an animation. */\r\n  show?: boolean\r\n  /** bubble: a chat bubble with the dots. inline: dots and the sentence on one line. dots: dots only (the sentence stays for screen readers). */\r\n  variant?: \"bubble\" | \"inline\" | \"dots\"\r\n  size?: \"sm\" | \"md\" | \"lg\"\r\n  /** Avatar or icon shown before the bubble. */\r\n  avatar?: React.ReactNode\r\n  /** Text for screen readers; pass translations here. */\r\n  labels?: Partial<TypingIndicatorLabels>\r\n}\r\n\r\nconst DOT = { sm: \"size-1\", md: \"size-1.5\", lg: \"size-2\" }\r\nconst GAP = { sm: \"gap-0.5\", md: \"gap-1\", lg: \"gap-1.5\" }\r\nconst TEXT = { sm: \"text-[11px]\", md: \"text-xs\", lg: \"text-sm\" }\r\n\r\n/** Three-dot wave with an \"is typing\" sentence. */\r\nexport function TypingIndicator({ names, show = true, variant = \"bubble\", size = \"md\", avatar, labels, className, ...props }: TypingIndicatorProps) {\r\n  const l = useLabels(\"typing-indicator\", DEFAULT_LABELS, labels)\r\n  const reduce = useReducedMotion() ?? false\r\n  const people = names === undefined ? [] : Array.isArray(names) ? names : [names]\r\n  const sentence = l.typing(people)\r\n  const dots = (\r\n    <span className={cn(\"inline-flex items-center\", GAP[size])} aria-hidden=\"true\">\r\n      <span className={cn(\"pc-typing-dot rounded-full bg-current\", DOT[size])} />\r\n      <span className={cn(\"pc-typing-dot rounded-full bg-current\", DOT[size])} />\r\n      <span className={cn(\"pc-typing-dot rounded-full bg-current\", DOT[size])} />\r\n    </span>\r\n  )\r\n\r\n  return (\r\n    <AnimatePresence initial={false}>\r\n      {show && (\r\n        <motion.div\r\n          key=\"typing\"\r\n          role=\"status\"\r\n          aria-live=\"polite\"\r\n          initial={reduce ? { opacity: 0 } : { opacity: 0, y: 6, scale: 0.92 }}\r\n          animate={{ opacity: 1, y: 0, scale: 1 }}\r\n          exit={reduce ? { opacity: 0, transition: { duration: 0.1 } } : { opacity: 0, scale: 0.9, transition: { duration: 0.14 } }}\r\n          transition={reduce ? { duration: 0 } : spring.ui}\r\n          className={cn(\"pc-typing inline-flex items-center gap-2 text-muted-foreground\", variant === \"bubble\" ? \"origin-bottom-left rtl:origin-bottom-right\" : \"origin-left rtl:origin-right\", className)}\r\n          {...props}\r\n        >\r\n          <GooduiTokens />\r\n          <style href=\"pc-typing-indicator\" precedence=\"default\">\r\n            {CSS}\r\n          </style>\r\n          {variant === \"bubble\" ? (\r\n            <>\r\n              {avatar && <span className=\"grid size-7 shrink-0 place-items-center overflow-hidden rounded-full bg-muted [&_img]:size-full [&_svg]:size-4\">{avatar}</span>}\r\n              <span className={cn(\"flex flex-col gap-0.5\", TEXT[size])}>\r\n                <span className={cn(\"inline-flex items-center rounded-2xl rounded-ss-md bg-muted text-foreground\", size === \"sm\" ? \"h-7 px-3\" : size === \"lg\" ? \"h-10 px-4\" : \"h-9 px-3.5\")}>{dots}</span>\r\n                <span className=\"ps-1\">{sentence}</span>\r\n              </span>\r\n            </>\r\n          ) : (\r\n            <>\r\n              {avatar && <span className=\"grid size-5 shrink-0 place-items-center overflow-hidden rounded-full bg-muted [&_img]:size-full [&_svg]:size-3\">{avatar}</span>}\r\n              <span className=\"text-foreground\">{dots}</span>\r\n              <span className={cn(TEXT[size], variant === \"dots\" && \"sr-only\")}>{sentence}</span>\r\n            </>\r\n          )}\r\n        </motion.div>\r\n      )}\r\n    </AnimatePresence>\r\n  )\r\n}\r\n",
      "type": "registry:component",
      "target": "components/goodui/typing-indicator.tsx"
    }
  ],
  "categories": [
    "components",
    "ai"
  ],
  "type": "registry:component"
}