Rev 2079 | Rev 2081 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React from 'react'
import {
FormControl,
InputAdornment,
InputBase,
InputLabel,
styled
} from '@mui/material'
import FormErrorFeedback from '../form/FormErrorFeedback'
const AppInput = styled(InputBase)(({ theme }) => ({
'& .MuiInputBase-input': {
borderRadius: 4,
position: 'relative',
backgroundColor: theme.palette.background.default,
border: `1px solid var(--border-primary)`,
fontSize: 14,
padding: '5px 10px',
transition: theme.transitions.create([
'border-color',
'background-color',
'box-shadow'
])
},
'& svg': {
fontSize: '1.3rem'
}
}))
const Input = ({
label = '',
inputRef = null,
icon: Icon = null,
error = null,
name = '',
onChange = () => {},
value = '',
type = 'text',
placeholder = '',
accept = '',
className = '',
id = ''
}) => {
return (
<FormControl variant='standard' fullWidth>
<InputLabel shrink>{label}</InputLabel>
<AppInput
id={id}
className={className}
name={name}
onChange={onChange}
value={value}
type={type}
placeholder={placeholder}
inputRef={inputRef}
accept={accept}
startAdornment={
Icon ? (
<InputAdornment>
<Icon />
</InputAdornment>
) : null
}
fullWidth
/>
{error ? <FormErrorFeedback>{error}</FormErrorFeedback> : null}
</FormControl>
)
}
export default Input