import classNames from 'classnames'; import React from 'react'; import InlineSVG from 'react-inlinesvg'; import { defineMessages, useIntl } from 'react-intl'; import Icon from '../../icon'; import Tooltip from '../tooltip/tooltip'; const messages = defineMessages({ showPassword: { id: 'input.password.show_password', defaultMessage: 'Show password' }, hidePassword: { id: 'input.password.hide_password', defaultMessage: 'Hide password' }, }); interface IInput extends Pick, 'onChange' | 'type'> { autoFocus?: boolean, defaultValue?: string, className?: string, icon?: string, name?: string, placeholder?: string, value?: string, onChange?: () => void, type: 'text' | 'email' | 'tel' | 'password' } const Input = React.forwardRef( (props, ref) => { const intl = useIntl(); const { type = 'text', icon, className, ...filteredProps } = props; const [revealed, setRevealed] = React.useState(false); const isPassword = type === 'password'; const togglePassword = React.useCallback(() => { setRevealed((prev) => !prev); }, []); return (
{icon ? (
) : null} {isPassword ? (
) : null}
); }, ); export default Input;