File size: 1,142 Bytes
d092f57 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import { FC, useRef } from "react"
import IconClose from "../icon/IconClose"
import classNames from "classnames"
interface Props {
value: string
placeholder: string
onChange: (value: string) => void
required?: boolean
className?: string
icon?: any
}
const InputText: FC<Props> = ({
value,
onChange,
placeholder,
icon,
className = "",
required = false,
}) => {
const inputRef = useRef<HTMLInputElement>(null)
return (
<div
className={classNames(
"rounded grow flex flex-row items-center bg-dark-800 action",
className
)}
>
{icon && <div className={"ml-1"}>{icon}</div>}
<input
ref={inputRef}
size={1}
className={"grow rounded bg-dark-800 px-2 py-1.5" + className}
placeholder={placeholder}
value={value}
onChange={(event) => onChange(event.target.value)}
type={"text"}
required={required}
onFocus={() => inputRef.current?.select()}
/>
<div className={"p-1 cursor-pointer"} onClick={() => onChange("")}>
<IconClose />
</div>
</div>
)
}
export default InputText
|