Proyectos de Subversion LeadersLinked - SPA

Rev

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

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