"use client"; import { type InputHTMLAttributes, forwardRef, useState } from "react"; import { Eye, EyeOff } from "lucide-react"; import clsx from "clsx"; interface PasswordFieldProps extends Omit, "type"> { label: string; error?: string; hint?: string; } /** Same visual language as `FormField`, plus a show/hide toggle - same * crossfade-icon-swap technique as `ApiKeyRow`'s Show/Hide button. */ export const PasswordField = forwardRef( ({ label, error, hint, id, className, ...props }, ref) => { const [revealed, setRevealed] = useState(false); const fieldId = id ?? props.name; return ( {label} setRevealed((r) => !r)} title={revealed ? "Hide password" : "Show password"} tabIndex={-1} className="focus-ring absolute inset-y-0 right-0 flex w-9 items-center justify-center text-slate-400 transition-colors duration-150 hover:text-slate-600" > {hint && !error && ( {hint} )} {error && ( {error} )} ); }, ); PasswordField.displayName = "PasswordField";
{hint}
{error}