Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32088809
password-input.react.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
password-input.react.js
View Options
// @flow
import
*
as
React
from
'react'
;
import
SWMansionIcon
,
{
type
Icon
,
}
from
'lib/components/SWMansionIcon.react.js'
;
import
css
from
'./password-input.css'
;
import
Button
from
'../components/button.react.js'
;
import
Input
,
{
type
BaseInputProps
}
from
'../modals/input.react.js'
;
type
PasswordInputProps
=
BaseInputProps
;
function
PasswordInput
(
props
:
PasswordInputProps
,
ref
)
:
React
.
Node
{
const
[
htmlInputType
,
setHtmlInputType
]
=
React
.
useState
<
'password'
|
'text'
>
(
'password'
,
);
const
onToggleShowPassword
=
React
.
useCallback
(()
=>
{
setHtmlInputType
(
oldType
=>
(
oldType
===
'password'
?
'text'
:
'password'
));
},
[]);
const
icon
:
Icon
=
htmlInputType
===
'password'
?
'eye-open'
:
'eye-closed'
;
return
(
<
div
className
=
{
css
.
wrapper
}
>
<
Input
className
=
{
css
.
input
}
{...
props
}
placeholder
=
"Password"
type
=
{
htmlInputType
}
ref
=
{
ref
}
/>
<
Button
className
=
{
css
.
button
}
onClick
=
{
onToggleShowPassword
}
>
<
SWMansionIcon
size
=
{
24
}
icon
=
{
icon
}
/>
<
/Button>
<
/div>
);
}
const
ForwardedPasswordInput
:
React
.
AbstractComponent
<
PasswordInputProps
,
HTMLInputElement
,
>
=
React
.
forwardRef
<
PasswordInputProps
,
HTMLInputElement
>
(
PasswordInput
);
export
default
ForwardedPasswordInput
;
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sun, Dec 7, 7:53 AM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5642184
Default Alt Text
password-input.react.js (1 KB)
Attached To
Mode
rCOMM Comm
Attached
Detach File
Event Timeline
Log In to Comment