mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-07-28 22:32:02 +08:00

Co-authored-by: John Wang <takatost@gmail.com> Co-authored-by: Jyong <718720800@qq.com> Co-authored-by: 金伟强 <iamjoel007@gmail.com>
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import type { ChangeEvent } from 'react'
|
|
import type { ReactElement } from 'react-markdown/lib/react-markdown'
|
|
|
|
type IProviderInputProps = {
|
|
value?: string
|
|
name: string
|
|
placeholder: string
|
|
className?: string
|
|
onChange: (v: string) => void
|
|
onFocus?: () => void
|
|
validatedIcon?: ReactElement
|
|
validatedTip?: ReactElement
|
|
}
|
|
|
|
const ProviderInput = ({
|
|
value,
|
|
name,
|
|
placeholder,
|
|
className,
|
|
onChange,
|
|
onFocus,
|
|
validatedIcon,
|
|
validatedTip,
|
|
}: 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
|
|
className='
|
|
w-full py-[9px]
|
|
text-xs font-medium text-gray-700 leading-[18px]
|
|
appearance-none outline-none bg-transparent
|
|
'
|
|
value={value}
|
|
placeholder={placeholder}
|
|
onChange={handleChange}
|
|
onFocus={onFocus}
|
|
/>
|
|
{validatedIcon}
|
|
</div>
|
|
{validatedTip}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default ProviderInput
|