field.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import cn from 'classnames'
  5. import Input from './input'
  6. import TooltipPlus from '@/app/components/base/tooltip-plus'
  7. import { HelpCircle } from '@/app/components/base/icons/src/vender/line/general'
  8. type Props = {
  9. className?: string
  10. label: string
  11. labelClassName?: string
  12. value: string | number
  13. onChange: (value: string | number) => void
  14. isRequired?: boolean
  15. placeholder?: string
  16. isNumber?: boolean
  17. tooltip?: string
  18. }
  19. const Field: FC<Props> = ({
  20. className,
  21. label,
  22. labelClassName,
  23. value,
  24. onChange,
  25. isRequired = false,
  26. placeholder = '',
  27. isNumber = false,
  28. tooltip,
  29. }) => {
  30. return (
  31. <div className={cn(className)}>
  32. <div className='flex py-[7px]'>
  33. <div className={cn(labelClassName, 'flex items-center h-[18px] text-[13px] font-medium text-gray-900')}>{label} </div>
  34. {isRequired && <span className='ml-0.5 text-xs font-semibold text-[#D92D20]'>*</span>}
  35. {tooltip && (
  36. <TooltipPlus popupContent={
  37. <div className='w-[200px]'>{tooltip}</div>
  38. }>
  39. <HelpCircle className='relative top-[3px] w-3 h-3 ml-1 text-gray-500' />
  40. </TooltipPlus>
  41. )}
  42. </div>
  43. <Input
  44. value={value}
  45. onChange={onChange}
  46. placeholder={placeholder}
  47. isNumber={isNumber}
  48. />
  49. </div>
  50. )
  51. }
  52. export default React.memo(Field)