56 lines
1.3 KiB
TypeScript
Raw Normal View History

import type { ChangeEvent } from 'react'
import type { ReactElement } from 'react-markdown/lib/react-markdown'
2023-05-15 08:51:32 +08:00
type IProviderInputProps = {
2023-05-15 08:51:32 +08:00
value?: string
name: string
placeholder: string
className?: string
onChange: (v: string) => void
onFocus?: () => void
2023-05-23 14:15:33 +08:00
validatedIcon?: ReactElement
validatedTip?: ReactElement
2023-05-15 08:51:32 +08:00
}
const ProviderInput = ({
value,
name,
placeholder,
className,
onChange,
onFocus,
2023-05-23 14:15:33 +08:00
validatedIcon,
validatedTip,
2023-05-15 08:51:32 +08:00
}: IProviderInputProps) => {
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
const inputValue = e.target.value
onChange(inputValue)
}
return (
<div className={className}>
<div className="mb-2 text-[13px] font-medium text-gray-800">{name}</div>
<div className='
flex items-center px-3 bg-white rounded-lg
shadow-[0_1px_2px_rgba(16,24,40,0.05)]
'>
<input
2023-05-15 08:51:32 +08:00
className='
w-full py-[9px]
text-xs font-medium text-gray-700 leading-[18px]
appearance-none outline-none bg-transparent
'
2023-05-15 08:51:32 +08:00
value={value}
placeholder={placeholder}
onChange={handleChange}
onFocus={onFocus}
/>
2023-05-23 14:15:33 +08:00
{validatedIcon}
2023-05-15 08:51:32 +08:00
</div>
2023-05-23 14:15:33 +08:00
{validatedTip}
2023-05-15 08:51:32 +08:00
</div>
)
}
export default ProviderInput