{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "password-input",
  "title": "Password Input",
  "author": "VenusUI",
  "description": "A password field with a show/hide toggle and an optional strength meter.",
  "dependencies": [
    "lucide-react"
  ],
  "files": [
    {
      "path": "registry/default/ui/password-input.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Eye, EyeOff } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface PasswordInputProps extends Omit<React.ComponentProps<\"input\">, \"type\"> {\n  /** Show a strength meter and hint under the field. */\n  showStrength?: boolean\n}\n\nconst LEVELS = [\"Too short\", \"Weak\", \"Fair\", \"Good\", \"Strong\"] as const\n\n/**\n * A rough guide, not a security check: rewards length and character variety.\n * Enforce your real password policy on the server.\n */\nfunction scorePassword(password: string): number {\n  if (password.length < 8) return 0\n  let score = 1\n  if (password.length >= 12) score++\n  if (/[a-z]/.test(password) && /[A-Z]/.test(password)) score++\n  if (/\\d/.test(password) && /[^a-zA-Z0-9]/.test(password)) score++\n  return Math.min(score, 4)\n}\n\n/**\n * A password field with a show/hide toggle and an optional strength meter.\n * The toggle is a labelled button with `aria-pressed`; the strength hint is\n * announced politely as it changes.\n */\nfunction PasswordInput({ showStrength = false, className, value, defaultValue, onChange, id, ...props }: PasswordInputProps) {\n  const [visible, setVisible] = React.useState(false)\n  const [internal, setInternal] = React.useState(String(defaultValue ?? \"\"))\n  const current = value !== undefined ? String(value) : internal\n  const score = scorePassword(current)\n  const generatedId = React.useId()\n  const hintId = `${id ?? generatedId}-strength`\n\n  return (\n    <div data-slot=\"password-input\" className={cn(\"w-full space-y-2\", className)}>\n      <div className=\"relative\">\n        <input\n          id={id}\n          type={visible ? \"text\" : \"password\"}\n          value={value}\n          defaultValue={value === undefined ? defaultValue : undefined}\n          onChange={(event) => {\n            if (value === undefined) setInternal(event.target.value)\n            onChange?.(event)\n          }}\n          aria-describedby={showStrength ? hintId : undefined}\n          className={cn(\n            \"h-10 w-full rounded-lg border bg-transparent pr-10 pl-3 text-sm outline-none transition-colors\",\n            \"focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive disabled:opacity-50\"\n          )}\n          {...props}\n        />\n        <button\n          type=\"button\"\n          aria-label=\"Show password\"\n          aria-pressed={visible}\n          onClick={() => setVisible((v) => !v)}\n          className=\"absolute top-1/2 right-1.5 inline-flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50\"\n        >\n          {visible ? <EyeOff aria-hidden=\"true\" className=\"size-4\" /> : <Eye aria-hidden=\"true\" className=\"size-4\" />}\n        </button>\n      </div>\n      {showStrength ? (\n        <div className=\"space-y-1.5\">\n          <div aria-hidden=\"true\" className=\"grid grid-cols-4 gap-1\">\n            {[1, 2, 3, 4].map((step) => (\n              <span\n                key={step}\n                className={cn(\n                  \"h-1 rounded-full bg-muted transition-colors\",\n                  current && step <= score && (score <= 1 ? \"bg-destructive\" : score === 2 ? \"bg-amber-500\" : \"bg-emerald-500\")\n                )}\n              />\n            ))}\n          </div>\n          <p id={hintId} aria-live=\"polite\" className=\"text-xs text-muted-foreground\">\n            {current ? `Strength: ${LEVELS[score]}` : \"Use 12 or more characters with a mix of letters, numbers and symbols.\"}\n          </p>\n        </div>\n      ) : null}\n    </div>\n  )\n}\n\nexport { PasswordInput, scorePassword, type PasswordInputProps }\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "inputs",
    "forms"
  ],
  "type": "registry:ui"
}