import React from 'react'; import styles from './CredentialInput.module.css'; interface CredentialInputProps { credential: string; setCredential: (credential: string) => void; inputProps?: React.InputHTMLAttributes; } function isEncrypted(value: string): boolean { return value.match(/^E-[0-9a-fA-F]{32}-[0-9a-fA-F]+$/) !== null; } const CredentialInput: React.FC = ({ credential, setCredential, inputProps = {}, }) => { const [showPassword, setShowPassword] = React.useState(false); return (
setCredential(e.target.value.trim())} className={styles.credentialInput} {...inputProps} disabled={isEncrypted(credential) ? true : inputProps.disabled || false} /> {!isEncrypted(credential) && ( )} {isEncrypted(credential) && ( )}
); }; export default CredentialInput;