Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2148 Rev 2795
Línea 8... Línea 8...
8
} from '@mui/material'
8
} from '@mui/material'
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 = ({
-
 
13
  label,
12
const Select = ({
14
  name = '',
-
 
15
  control,
13
  name,
16
  placeholder = 'Seleccione una opción',
-
 
17
  defaultValue,
14
  control,
18
  options = [],
15
  label,
19
  rules,
16
  rules,
-
 
17
  defaultValue,
-
 
18
  onChange,
-
 
19
  value,
20
  value,
20
  icon,
-
 
21
  accept,
-
 
22
  error,
-
 
23
  placeholder = 'Seleccione una opción',
21
  onChange,
24
  options = [],
22
  error = null
-
 
23
}) => {
-
 
24
  return (
25
  ...props
25
    <FormControl fullWidth>
-
 
26
      {label ? (
-
 
27
        <InputLabel shrink htmlFor={name}>
-
 
28
          {label}
26
}) => {
29
        </InputLabel>
-
 
30
      ) : null}
-
 
31
 
27
  if (control) {
32
      {control ? (
28
    return (
33
        <Controller
29
      <Controller
34
          name={name}
30
        name={name}
35
          control={control}
31
        control={control}
36
          rules={rules}
32
        rules={rules}
-
 
33
        defaultValue={defaultValue}
-
 
34
        render={({ field }) => (
-
 
35
          <FormControl fullWidth>
37
          defaultValue={defaultValue}
36
            <InputLabel shrink>{label}</InputLabel>
38
          render={(field) => (
37
 
39
            <MuiSelect
38
            <MuiSelect
40
              {...field}
39
              {...field}
41
              fullWidth
40
              fullWidth
42
              displayEmpty
41
              displayEmpty
43
              sx={{
42
              sx={{
-
 
43
                borderRadius: '4px'
44
                borderRadius: '4px'
44
              }}
45
              }}
45
              {...props}
46
            >
46
            >
47
              <MenuItem value='' disabled>
47
              <MenuItem value='' disabled>
Línea 52... Línea 52...
52
                <MenuItem key={value} value={value}>
52
                <MenuItem key={value} value={value}>
53
                  {name}
53
                  {name}
54
                </MenuItem>
54
                </MenuItem>
55
              ))}
55
              ))}
56
            </MuiSelect>
56
            </MuiSelect>
57
          )}
-
 
58
        />
-
 
59
      ) : (
-
 
60
        <MuiSelect
-
 
61
          name={name}
-
 
62
          defaultValue={defaultValue}
-
 
63
          value={value}
-
 
64
          onChange={onChange}
-
 
65
          fullWidth
-
 
66
          displayEmpty
-
 
67
          sx={{
-
 
68
            borderRadius: '4px'
-
 
69
          }}
-
 
70
        >
-
 
71
          <MenuItem value='' disabled>
-
 
72
            {placeholder}
-
 
73
          </MenuItem>
-
 
Línea -... Línea 57...
-
 
57
 
-
 
58
            {error ? <FormErrorFeedback>{error}</FormErrorFeedback> : null}
-
 
59
          </FormControl>
-
 
60
        )}
-
 
61
      />
-
 
62
    )
-
 
63
  }
-
 
64
 
-
 
65
  return (
-
 
66
    <FormControl fullWidth>
-
 
67
      <InputLabel shrink>{label}</InputLabel>
-
 
68
 
-
 
69
      <MuiSelect
-
 
70
        name={name}
-
 
71
        defaultValue={defaultValue}
-
 
72
        value={value}
-
 
73
        onChange={onChange}
-
 
74
        fullWidth
-
 
75
        displayEmpty
-
 
76
        sx={{
-
 
77
          borderRadius: '4px'
-
 
78
        }}
-
 
79
        {...props}
-
 
80
      >
-
 
81
        <MenuItem value='' disabled>
-
 
82
          {placeholder}
-
 
83
        </MenuItem>
74
 
84
 
75
          {options.map(({ name, value }) => (
85
        {options.map(({ name, value }) => (
76
            <MenuItem key={value} value={value}>
86
          <MenuItem key={value} value={value}>
77
              {name}
87
            {name}
78
            </MenuItem>
88
          </MenuItem>
79
          ))}
89
        ))}
80
        </MuiSelect>
-
 
Línea 81... Línea 90...
81
      )}
90
      </MuiSelect>
82
 
91
 
83
      {error ? <FormErrorFeedback>{error}</FormErrorFeedback> : null}
92
      {error ? <FormErrorFeedback>{error}</FormErrorFeedback> : null}
84
    </FormControl>
93
    </FormControl>