Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3234 | Rev 3435 | 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,
3234 stevensc 23
  style,
2773 stevensc 24
  ...props
2080 stevensc 25
}) => {
2773 stevensc 26
  if (control) {
27
    return (
28
      <Controller
29
        name={name}
30
        control={control}
31
        defaultValue={defaultValue}
32
        rules={rules}
2794 stevensc 33
        render={({ field }) => (
3238 stevensc 34
          <FormControl variant='standard' fullWidth sx={style}>
3000 stevensc 35
            {label && <InputLabel shrink>{label}</InputLabel>}
2773 stevensc 36
 
2843 stevensc 37
            <InputBase
2773 stevensc 38
              {...field}
39
              inputProps={{
40
                accept
41
              }}
42
              startAdornment={
43
                icon ? <InputAdornment>{icon}</InputAdornment> : null
44
              }
45
              fullWidth
46
              {...props}
47
            />
48
 
49
            {error ? <FormErrorFeedback>{error}</FormErrorFeedback> : null}
50
          </FormControl>
51
        )}
52
      />
53
    )
54
  }
55
 
2077 stevensc 56
  return (
3238 stevensc 57
    <FormControl variant='standard' fullWidth sx={style}>
3000 stevensc 58
      {label && <InputLabel shrink>{label}</InputLabel>}
2099 stevensc 59
 
2843 stevensc 60
      <InputBase
2080 stevensc 61
        name={name}
62
        onChange={onChange}
2773 stevensc 63
        defaultValue={defaultValue}
2791 stevensc 64
        value={value}
2099 stevensc 65
        inputProps={{
66
          accept
67
        }}
2773 stevensc 68
        startAdornment={icon ? <InputAdornment>{icon}</InputAdornment> : null}
2080 stevensc 69
        fullWidth
2773 stevensc 70
        {...props}
2080 stevensc 71
      />
2099 stevensc 72
 
2080 stevensc 73
      {error ? <FormErrorFeedback>{error}</FormErrorFeedback> : null}
2078 stevensc 74
    </FormControl>
2077 stevensc 75
  )
2073 stevensc 76
}
77
 
78
export default Input