import { useEffect, useState } from 'react'; import type { StringFormField } from '@douglasneuroinformatics/libui-form-types'; import { EyeIcon, EyeOffIcon } from 'lucide-react'; import { motion } from 'motion/react'; import { Input, Label } from '#components'; import { cn } from '#utils'; import { FieldGroup } from '../FieldGroup/FieldGroup.tsx'; import type { BaseFieldComponentProps } from '../types.ts'; export type PasswordStrengthValue = 0 | 1 | 2 | 3 | 4; export type StringFieldPasswordProps = BaseFieldComponentProps & Extract; export const StringFieldPassword = ({ calculateStrength, description, disabled, error, label, name, readOnly, setValue, value }: StringFieldPasswordProps) => { const [strength, setStrength] = useState(calculateStrength ? 0 : null); const [show, setShow] = useState(false); useEffect(() => { if (calculateStrength) { setStrength(value ? calculateStrength(value) : 0); } }, [value]); return ( setValue(event.target.value)} /> {strength !== null && (
)} ); };