import React, { useState } from "react"; import { Eye, EyeOff } from "lucide-react"; import { useTranslation } from "react-i18next"; interface ApiKeyInputProps { value: string; onChange: (value: string) => void; placeholder?: string; disabled?: boolean; required?: boolean; label?: string; id?: string; } const ApiKeyInput: React.FC = ({ value, onChange, placeholder, disabled = false, required = false, label = "API Key", id = "apiKey", }) => { const { t } = useTranslation(); const [showKey, setShowKey] = useState(false); const toggleShowKey = () => { setShowKey(!showKey); }; const inputClass = `w-full px-3 py-2 pr-10 border rounded-lg text-sm transition-colors ${ disabled ? "bg-gray-100 dark:bg-gray-800 border-gray-200 dark:border-gray-700 text-gray-400 dark:text-gray-500 cursor-not-allowed" : "border-gray-200 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:focus:ring-blue-400/20 focus:border-blue-500 dark:focus:border-blue-400" }`; return (
onChange(e.target.value)} placeholder={placeholder ?? t("apiKeyInput.placeholder")} disabled={disabled} required={required} autoComplete="off" className={inputClass} /> {!disabled && value && ( )}
); }; export default ApiKeyInput;