Input.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import type { FC } from 'react'
  2. import { CheckCircle } from '@/app/components/base/icons/src/vender/solid/general'
  3. type InputProps = {
  4. value?: string
  5. onChange: (v: string) => void
  6. onFocus?: () => void
  7. placeholder?: string
  8. validated?: boolean
  9. className?: string
  10. disabled?: boolean
  11. }
  12. const Input: FC<InputProps> = ({
  13. value,
  14. onChange,
  15. onFocus,
  16. placeholder,
  17. validated,
  18. className,
  19. disabled,
  20. }) => {
  21. return (
  22. <div className='relative'>
  23. <input
  24. tabIndex={-1}
  25. className={`
  26. block px-3 w-full h-9 bg-gray-100 text-sm rounded-lg border border-transparent
  27. appearance-none outline-none caret-primary-600
  28. hover:border-[rgba(0,0,0,0.08)] hover:bg-gray-50
  29. focus:bg-white focus:border-gray-300 focus:shadow-xs
  30. placeholder:text-sm placeholder:text-gray-400
  31. ${validated && 'pr-[30px]'}
  32. ${className}
  33. `}
  34. placeholder={placeholder || ''}
  35. onChange={e => onChange(e.target.value)}
  36. onFocus={onFocus}
  37. value={value || ''}
  38. disabled={disabled}
  39. />
  40. {
  41. validated && (
  42. <div className='absolute top-2.5 right-2.5'>
  43. <CheckCircle className='w-4 h-4 text-[#039855]' />
  44. </div>
  45. )
  46. }
  47. </div>
  48. )
  49. }
  50. export default Input