import * as React from 'react'; import PasswordInput from './PasswordInput'; import { useId } from 'react'; import { ChangeEventHandler } from './types'; import { _ } from '@joplin/lib/locale'; interface Props { labelText: string; value: string; onChange: ChangeEventHandler; valid?: boolean; } const LabelledPasswordInput: React.FC = props => { const inputId = useId(); const statusIconId = useId(); const canRenderStatusIcon = (props.valid ?? null) !== null && props.value; const renderStatusIcon = () => { if (!canRenderStatusIcon) return null; let title, classNames; if (props.valid) { title = _('Valid'); classNames = 'fas fa-check -valid'; } else { title = _('Invalid'); classNames = 'fas fa-times -invalid'; } return ; }; return
{renderStatusIcon()}
; }; export default LabelledPasswordInput;