Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2766 Rev 2773
Línea 4... Línea 4...
4
  InputAdornment,
4
  InputAdornment,
5
  InputBase,
5
  InputBase,
6
  InputLabel,
6
  InputLabel,
7
  styled
7
  styled
8
} from '@mui/material'
8
} from '@mui/material'
-
 
9
import { Controller } from 'react-hook-form'
-
 
10
 
-
 
11
import { colors } from '@app/styles/mui/colors'
-
 
12
 
9
import FormErrorFeedback from '../form/FormErrorFeedback'
13
import FormErrorFeedback from '../form/FormErrorFeedback'
Línea 10... Línea 14...
10
 
14
 
11
export const AppInput = styled(InputBase)(({ theme }) => ({
15
const CustomInput = styled(InputBase)(({ theme }) => ({
12
  borderRadius: 4,
16
  borderRadius: 4,
13
  position: 'relative',
17
  position: 'relative',
14
  backgroundColor: theme.palette.background.default,
18
  backgroundColor: colors.main,
15
  border: `1px solid var(--border-primary)`,
19
  border: `1px solid var(--border-primary)`,
16
  fontSize: 14,
20
  fontSize: 14,
17
  padding: '5px 10px',
21
  padding: '5px 10px',
18
  transition: theme.transitions.create([
22
  transition: theme.transitions.create([
Línea 31... Línea 35...
31
    fontSize: '1.3rem'
35
    fontSize: '1.3rem'
32
  }
36
  }
33
}))
37
}))
Línea 34... Línea 38...
34
 
38
 
35
const Input = ({
-
 
36
  label,
-
 
37
  inputRef,
39
const Input = ({
-
 
40
  name,
-
 
41
  control,
38
  name,
42
  label,
-
 
43
  rules,
39
  value,
44
  defaultValue = '',
-
 
45
  onChange,
-
 
46
  value: propValue,
40
  placeholder,
47
  icon,
41
  accept,
-
 
42
  id,
-
 
43
  className,
48
  accept,
44
  error = null,
-
 
45
  onChange = () => {},
-
 
46
  type = 'text',
-
 
47
  icon: Icon = null,
49
  error,
48
  disabled
50
  ...props
-
 
51
}) => {
-
 
52
  if (control) {
-
 
53
    return (
-
 
54
      <Controller
-
 
55
        name={name}
-
 
56
        control={control}
-
 
57
        defaultValue={defaultValue}
-
 
58
        rules={rules}
-
 
59
        render={(field) => (
-
 
60
          <FormControl variant='standard' fullWidth>
-
 
61
            <InputLabel shrink>{label}</InputLabel>
-
 
62
 
-
 
63
            <CustomInput
-
 
64
              {...field}
-
 
65
              inputProps={{
-
 
66
                accept
-
 
67
              }}
-
 
68
              startAdornment={
-
 
69
                icon ? <InputAdornment>{icon}</InputAdornment> : null
-
 
70
              }
-
 
71
              fullWidth
-
 
72
              {...props}
-
 
73
            />
-
 
74
 
-
 
75
            {error ? <FormErrorFeedback>{error}</FormErrorFeedback> : null}
-
 
76
          </FormControl>
-
 
77
        )}
-
 
78
      />
-
 
79
    )
-
 
80
  }
49
}) => {
81
 
50
  return (
82
  return (
51
    <FormControl variant='standard' fullWidth>
83
    <FormControl variant='standard' fullWidth>
Línea 52... Línea 84...
52
      <InputLabel shrink>{label}</InputLabel>
84
      <InputLabel shrink>{label}</InputLabel>
53
 
-
 
54
      <AppInput
-
 
55
        id={id}
85
 
56
        className={className}
86
      <CustomInput
57
        name={name}
87
        name={name}
58
        onChange={onChange}
88
        onChange={onChange}
59
        value={value}
-
 
60
        type={type}
-
 
61
        placeholder={placeholder}
-
 
62
        disabled={disabled}
89
        defaultValue={defaultValue}
63
        inputRef={inputRef}
90
        value={propValue}
64
        inputProps={{
91
        inputProps={{
65
          accept
-
 
66
        }}
-
 
67
        startAdornment={
-
 
68
          Icon ? (
-
 
69
            <InputAdornment>
92
          accept
70
              <Icon />
-
 
71
            </InputAdornment>
-
 
72
          ) : null
93
        }}
-
 
94
        startAdornment={icon ? <InputAdornment>{icon}</InputAdornment> : null}
73
        }
95
        fullWidth
Línea 74... Línea 96...
74
        fullWidth
96
        {...props}
75
      />
97
      />
76
 
98