Proyectos de Subversion LeadersLinked - SPA

Rev

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