2023-05-24 16:27:10 +00:00
|
|
|
import { SxProps, TextField, Theme, useTheme } from "@mui/material";
|
2023-05-23 12:20:37 +00:00
|
|
|
import { HTMLInputTypeAttribute, ChangeEvent } from "react";
|
2023-11-28 16:12:12 +00:00
|
|
|
import {InputBaseProps} from "@mui/material/InputBase";
|
2023-05-23 12:20:37 +00:00
|
|
|
|
|
|
|
|
|
2023-11-28 16:12:12 +00:00
|
|
|
export function CustomTextField({ id, label, value, name, onBlur,error, type, sx, onChange: setValue }: {
|
2023-05-23 12:20:37 +00:00
|
|
|
id: string;
|
|
|
|
|
label: string;
|
|
|
|
|
value: number | string | null;
|
2023-11-28 16:12:12 +00:00
|
|
|
name?: string;
|
|
|
|
|
onBlur?: InputBaseProps['onBlur'];
|
|
|
|
|
error?: boolean;
|
2023-05-23 12:20:37 +00:00
|
|
|
type?: HTMLInputTypeAttribute;
|
2023-05-24 16:27:10 +00:00
|
|
|
sx?: SxProps<Theme>;
|
|
|
|
|
onChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
2023-05-23 12:20:37 +00:00
|
|
|
}) {
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<TextField
|
|
|
|
|
fullWidth
|
|
|
|
|
id={id}
|
|
|
|
|
label={label}
|
|
|
|
|
variant="filled"
|
2023-11-28 16:12:12 +00:00
|
|
|
name={name}
|
|
|
|
|
onBlur={onBlur}
|
|
|
|
|
error={error}
|
2023-05-23 12:20:37 +00:00
|
|
|
color="secondary"
|
|
|
|
|
type={type}
|
2023-05-24 16:27:10 +00:00
|
|
|
sx={sx}
|
2023-05-23 12:20:37 +00:00
|
|
|
InputProps={{
|
|
|
|
|
style: {
|
|
|
|
|
backgroundColor: theme.palette.content.main,
|
|
|
|
|
color: theme.palette.secondary.main,
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
InputLabelProps={{
|
|
|
|
|
style: {
|
|
|
|
|
color: theme.palette.secondary.main
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
value={value ? value : ""}
|
|
|
|
|
onChange={setValue}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|