index.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import type { ChangeEvent } from 'react'
  2. import type { ReactElement } from 'react-markdown/lib/react-markdown'
  3. type IProviderInputProps = {
  4. value?: string
  5. name: string
  6. placeholder: string
  7. className?: string
  8. onChange: (v: string) => void
  9. onFocus?: () => void
  10. validatedIcon?: ReactElement
  11. validatedTip?: ReactElement
  12. }
  13. const ProviderInput = ({
  14. value,
  15. name,
  16. placeholder,
  17. className,
  18. onChange,
  19. onFocus,
  20. validatedIcon,
  21. validatedTip,
  22. }: IProviderInputProps) => {
  23. const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
  24. const inputValue = e.target.value
  25. onChange(inputValue)
  26. }
  27. return (
  28. <div className={className}>
  29. <div className="mb-2 text-[13px] font-medium text-gray-800">{name}</div>
  30. <div className='
  31. flex items-center px-3 bg-white rounded-lg
  32. shadow-[0_1px_2px_rgba(16,24,40,0.05)]
  33. '>
  34. <input
  35. className='
  36. w-full py-[9px]
  37. text-xs font-medium text-gray-700 leading-[18px]
  38. appearance-none outline-none bg-transparent
  39. '
  40. value={value}
  41. placeholder={placeholder}
  42. onChange={handleChange}
  43. onFocus={onFocus}
  44. />
  45. {validatedIcon}
  46. </div>
  47. {validatedTip}
  48. </div>
  49. )
  50. }
  51. export default ProviderInput