2019-11-15 03:45:59 +05:00
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { Icon, Input } from 'semantic-ui-react';
|
|
|
|
import { useToggle } from '../../../hooks';
|
|
|
|
|
|
|
|
const InputPassword = React.forwardRef((props, ref) => {
|
2019-11-18 11:59:37 +05:00
|
|
|
const [isVisible, toggleVisible] = useToggle();
|
2019-11-15 03:45:59 +05:00
|
|
|
|
|
|
|
const handleToggleClick = useCallback(() => {
|
2019-11-18 11:59:37 +05:00
|
|
|
toggleVisible();
|
|
|
|
}, [toggleVisible]);
|
2019-11-15 03:45:59 +05:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Input
|
|
|
|
{...props} // eslint-disable-line react/jsx-props-no-spreading
|
|
|
|
ref={ref}
|
2019-11-18 11:59:37 +05:00
|
|
|
type={isVisible ? 'text' : 'password'}
|
|
|
|
icon={<Icon link name={isVisible ? 'eye' : 'eye slash'} onClick={handleToggleClick} />}
|
2019-11-15 03:45:59 +05:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
export default React.memo(InputPassword);
|