Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2110 | Rev 2146 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 2110 Rev 2114
Línea 9... Línea 9...
9
 
9
 
Línea 10... Línea 10...
10
import FormErrorFeedback from '../form/FormErrorFeedback'
10
import FormErrorFeedback from '../form/FormErrorFeedback'
11
 
11
 
12
const Select = ({
12
const Select = ({
13
  label,
13
  label,
14
  name,
14
  name = '',
15
  control,
15
  control,
16
  placeholder = 'Seleccione una opción',
16
  placeholder = 'Seleccione una opción',
17
  defaultValue,
17
  defaultValue,
-
 
18
  options = [],
-
 
19
  rules,
18
  options = [],
20
  value,
19
  rules,
21
  onChange,
20
  error = null
22
  error = null
21
}) => {
23
}) => {
22
  return (
24
  return (
23
    <FormControl fullWidth>
25
    <FormControl fullWidth>
24
      {label ? (
26
      {label ? (
25
        <InputLabel shrink htmlFor={name}>
27
        <InputLabel shrink htmlFor={name}>
26
          {label}
28
          {label}
Línea -... Línea 29...
-
 
29
        </InputLabel>
27
        </InputLabel>
30
      ) : null}
28
      ) : null}
31
 
29
 
32
      {control ? (
30
      <Controller
33
        <Controller
31
        name={name}
34
          name={name}
32
        control={control}
35
          control={control}
33
        rules={rules}
36
          rules={rules}
34
        defaultValue={defaultValue}
37
          defaultValue={defaultValue}
35
        render={(field) => (
38
          render={(field) => (
36
          <MuiSelect
39
            <MuiSelect
37
            {...field}
40
              {...field}
38
            fullWidth
41
              fullWidth
39
            displayEmpty
42
              displayEmpty
40
            sx={{
43
              sx={{
41
              borderRadius: '4px'
44
                borderRadius: '4px'
42
            }}
45
              }}
43
          >
46
            >
44
            <MenuItem value=''>{placeholder}</MenuItem>
47
              <MenuItem value=''>{placeholder}</MenuItem>
45
 
48
 
46
            {options.map(({ name, value }) => (
49
              {options.map(({ name, value }) => (
47
              <MenuItem key={value} value={value}>
50
                <MenuItem key={value} value={value}>
48
                {name}
51
                  {name}
49
              </MenuItem>
52
                </MenuItem>
50
            ))}
53
              ))}
-
 
54
            </MuiSelect>
-
 
55
          )}
-
 
56
        />
-
 
57
      ) : (
-
 
58
        <MuiSelect
-
 
59
          name={name}
-
 
60
          defaultValue={defaultValue}
-
 
61
          value={value}
-
 
62
          onChange={onChange}
-
 
63
          fullWidth
-
 
64
          displayEmpty
-
 
65
          sx={{
-
 
66
            borderRadius: '4px'
-
 
67
          }}
-
 
68
        >
-
 
69
          <MenuItem value=''>{placeholder}</MenuItem>
-
 
70
 
-
 
71
          {options.map(({ name, value }) => (
-
 
72
            <MenuItem key={value} value={value}>
-
 
73
              {name}
-
 
74
            </MenuItem>
Línea 51... Línea 75...
51
          </MuiSelect>
75
          ))}
52
        )}
76
        </MuiSelect>
53
      />
77
      )}
54
 
78