Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2843 | Rev 3234 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
2073 stevensc 1
import React from 'react'
2080 stevensc 2
import {
3
  FormControl,
4
  InputAdornment,
5
  InputBase,
2843 stevensc 6
  InputLabel
2080 stevensc 7
} from '@mui/material'
2773 stevensc 8
import { Controller } from 'react-hook-form'
9
 
2080 stevensc 10
import FormErrorFeedback from '../form/FormErrorFeedback'
2073 stevensc 11
 
2080 stevensc 12
const Input = ({
2773 stevensc 13
  name,
14
  control,
2081 stevensc 15
  label,
2773 stevensc 16
  rules,
2791 stevensc 17
  defaultValue,
2773 stevensc 18
  onChange,
2791 stevensc 19
  value,
2773 stevensc 20
  icon,
2081 stevensc 21
  accept,
2773 stevensc 22
  error,
23
  ...props
2080 stevensc 24
}) => {
2773 stevensc 25
  if (control) {
26
    return (
27
      <Controller
28
        name={name}
29
        control={control}
30
        defaultValue={defaultValue}
31
        rules={rules}
2794 stevensc 32
        render={({ field }) => (
2773 stevensc 33
          <FormControl variant='standard' fullWidth>
3000 stevensc 34
            {label && <InputLabel shrink>{label}</InputLabel>}
2773 stevensc 35
 
2843 stevensc 36
            <InputBase
2773 stevensc 37
              {...field}
38
              inputProps={{
39
                accept
40
              }}
41
              startAdornment={
42
                icon ? <InputAdornment>{icon}</InputAdornment> : null
43
              }
44
              fullWidth
45
              {...props}
46
            />
47
 
48
            {error ? <FormErrorFeedback>{error}</FormErrorFeedback> : null}
49
          </FormControl>
50
        )}
51
      />
52
    )
53
  }
54
 
2077 stevensc 55
  return (
2079 stevensc 56
    <FormControl variant='standard' fullWidth>
3000 stevensc 57
      {label && <InputLabel shrink>{label}</InputLabel>}
2099 stevensc 58
 
2843 stevensc 59
      <InputBase
2080 stevensc 60
        name={name}
61
        onChange={onChange}
2773 stevensc 62
        defaultValue={defaultValue}
2791 stevensc 63
        value={value}
2099 stevensc 64
        inputProps={{
65
          accept
66
        }}
2773 stevensc 67
        startAdornment={icon ? <InputAdornment>{icon}</InputAdornment> : null}
2080 stevensc 68
        fullWidth
2773 stevensc 69
        {...props}
2080 stevensc 70
      />
2099 stevensc 71
 
2080 stevensc 72
      {error ? <FormErrorFeedback>{error}</FormErrorFeedback> : null}
2078 stevensc 73
    </FormControl>
2077 stevensc 74
  )
2073 stevensc 75
}
76
 
77
export default Input