Files
omnex/web/src/components/PasswordInput.tsx
T
Xor290 c5ee5636ef
ci-api / test (push) Successful in 22m17s
ci-web / test (push) Successful in 13m44s
chore: update
2026-08-02 18:34:59 +02:00

27 lines
1.0 KiB
TypeScript

import { forwardRef, useState } from 'react'
import { IconButton, Input, InputGroup, InputRightElement, type InputProps } from '@chakra-ui/react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faEye, faEyeSlash } from '@fortawesome/free-solid-svg-icons'
// Input mot de passe avec bascule affichage clair/masqué (icône Font Awesome).
export const PasswordInput = forwardRef<HTMLInputElement, InputProps>((props, ref) => {
const [visible, setVisible] = useState(false)
return (
<InputGroup>
<Input ref={ref} type={visible ? 'text' : 'password'} {...props} />
<InputRightElement>
<IconButton
aria-label={visible ? 'Masquer le mot de passe' : 'Afficher le mot de passe'}
icon={<FontAwesomeIcon icon={visible ? faEyeSlash : faEye} />}
size="sm"
variant="ghost"
tabIndex={-1}
onClick={() => setVisible((v) => !v)}
/>
</InputRightElement>
</InputGroup>
)
})
PasswordInput.displayName = 'PasswordInput'