Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3440 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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