{
  "name": "token-field",
  "type": "registry:ui",
  "framework": "react",
  "title": "Token Field",
  "description": "A read-only, masked monospace input with reveal and copy-to-clipboard actions for secrets such as bot tokens.",
  "registryDependencies": [
    "@newtui/form-fields",
    "@newtui/button"
  ],
  "files": [
    {
      "path": "ui/token-field.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Button } from \"@/registry/bases/newt/ui/button\"\nimport { Input } from \"@/registry/bases/newt/ui/form-fields\"\n\nexport interface TokenFieldProps extends Omit<\n  React.ComponentProps<\"div\">,\n  \"children\"\n> {\n  /** The secret value. Masked until revealed. */\n  value: string\n  /** Id forwarded to the input so a label can target it. */\n  id?: string\n  /** Accessible name for the input when no visible label is linked. */\n  name?: string\n  /** Label of the reveal button while hidden. */\n  revealLabel?: string\n  /** Label of the reveal button while shown. */\n  hideLabel?: string\n  /** Label of the copy button. */\n  copyLabel?: string\n  /** Label of the copy button right after copying. */\n  copiedLabel?: string\n  /** How long (ms) the copied label is shown. */\n  copiedDuration?: number\n  /** Called after the value is written to the clipboard. */\n  onCopy?: () => void\n}\n\nconst TokenField = React.forwardRef<HTMLDivElement, TokenFieldProps>(\n  (\n    {\n      className,\n      value,\n      id,\n      name,\n      revealLabel = \"Reveal\",\n      hideLabel = \"Hide\",\n      copyLabel = \"Copy\",\n      copiedLabel = \"Copied!\",\n      copiedDuration = 1500,\n      onCopy,\n      ...props\n    },\n    ref\n  ) => {\n    const [revealed, setRevealed] = React.useState(false)\n    const [copied, setCopied] = React.useState(false)\n    const timeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)\n\n    React.useEffect(\n      () => () => {\n        if (timeoutRef.current) clearTimeout(timeoutRef.current)\n      },\n      []\n    )\n\n    const handleCopy = async () => {\n      await navigator.clipboard.writeText(value)\n      onCopy?.()\n      setCopied(true)\n      if (timeoutRef.current) clearTimeout(timeoutRef.current)\n      timeoutRef.current = setTimeout(() => setCopied(false), copiedDuration)\n    }\n\n    return (\n      <div ref={ref} className={cn(\"flex gap-2\", className)} {...props}>\n        <Input\n          id={id}\n          name={name}\n          type={revealed ? \"text\" : \"password\"}\n          value={value}\n          readOnly\n          className=\"font-[family-name:var(--newt-font-mono)] tracking-[0.05em]\"\n        />\n        <Button\n          type=\"button\"\n          variant=\"secondary\"\n          aria-pressed={revealed}\n          onClick={() => setRevealed((r) => !r)}\n        >\n          {revealed ? hideLabel : revealLabel}\n        </Button>\n        <Button\n          type=\"button\"\n          variant=\"secondary\"\n          aria-live=\"polite\"\n          onClick={() => void handleCopy()}\n        >\n          {copied ? copiedLabel : copyLabel}\n        </Button>\n      </div>\n    )\n  }\n)\nTokenField.displayName = \"TokenField\"\n\nexport { TokenField }\n",
      "type": "registry:ui"
    }
  ]
}