2022-10-03 16:15:26 +00:00
|
|
|
import { FormControl, FormLabel, Input, InputProps } from '@chakra-ui/react';
|
|
|
|
import { ChangeEvent } from 'react';
|
|
|
|
|
|
|
|
interface IAIInputProps extends InputProps {
|
|
|
|
styleClass?: string;
|
|
|
|
label?: string;
|
|
|
|
width?: string | number;
|
2022-12-24 20:28:59 +00:00
|
|
|
value?: string;
|
2022-12-26 15:07:40 +00:00
|
|
|
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
2022-10-03 16:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default function IAIInput(props: IAIInputProps) {
|
|
|
|
const {
|
2022-12-24 20:28:59 +00:00
|
|
|
label = '',
|
2022-10-03 16:15:26 +00:00
|
|
|
styleClass,
|
|
|
|
isDisabled = false,
|
2022-12-24 18:23:21 +00:00
|
|
|
fontSize = 'sm',
|
2022-10-03 16:15:26 +00:00
|
|
|
width,
|
|
|
|
isInvalid,
|
|
|
|
...rest
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<FormControl
|
|
|
|
className={`input ${styleClass}`}
|
|
|
|
isInvalid={isInvalid}
|
|
|
|
isDisabled={isDisabled}
|
|
|
|
>
|
2022-12-26 15:07:40 +00:00
|
|
|
{label !== '' && (
|
|
|
|
<FormLabel
|
|
|
|
fontSize={fontSize}
|
|
|
|
fontWeight="bold"
|
|
|
|
alignItems="center"
|
|
|
|
whiteSpace="nowrap"
|
|
|
|
marginBottom={0}
|
|
|
|
marginRight={0}
|
|
|
|
className="input-label"
|
|
|
|
>
|
|
|
|
{label}
|
|
|
|
</FormLabel>
|
|
|
|
)}
|
2022-10-03 16:15:26 +00:00
|
|
|
<Input {...rest} className="input-entry" size={'sm'} width={width} />
|
|
|
|
</FormControl>
|
|
|
|
);
|
|
|
|
}
|