2023-03-06 09:02:40 +00:00
|
|
|
import {
|
|
|
|
FormControl,
|
|
|
|
FormControlProps,
|
|
|
|
FormLabel,
|
|
|
|
Input,
|
|
|
|
InputProps,
|
|
|
|
} from '@chakra-ui/react';
|
2023-05-15 07:45:05 +00:00
|
|
|
import { stopPastePropagation } from 'common/util/stopPastePropagation';
|
2023-03-09 09:30:29 +00:00
|
|
|
import { ChangeEvent, memo } from 'react';
|
2022-10-03 16:15:26 +00:00
|
|
|
|
|
|
|
interface IAIInputProps extends InputProps {
|
|
|
|
label?: string;
|
2022-12-24 20:28:59 +00:00
|
|
|
value?: string;
|
2022-12-27 17:19:23 +00:00
|
|
|
size?: string;
|
2022-12-26 15:07:40 +00:00
|
|
|
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
2023-03-06 09:02:40 +00:00
|
|
|
formControlProps?: Omit<FormControlProps, 'isInvalid' | 'isDisabled'>;
|
2022-10-03 16:15:26 +00:00
|
|
|
}
|
|
|
|
|
2023-03-09 09:30:29 +00:00
|
|
|
const IAIInput = (props: IAIInputProps) => {
|
2022-10-03 16:15:26 +00:00
|
|
|
const {
|
2022-12-24 20:28:59 +00:00
|
|
|
label = '',
|
2022-10-03 16:15:26 +00:00
|
|
|
isDisabled = false,
|
|
|
|
isInvalid,
|
2023-03-06 09:02:40 +00:00
|
|
|
formControlProps,
|
2022-10-03 16:15:26 +00:00
|
|
|
...rest
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<FormControl
|
|
|
|
isInvalid={isInvalid}
|
|
|
|
isDisabled={isDisabled}
|
2023-03-06 09:02:40 +00:00
|
|
|
{...formControlProps}
|
2022-10-03 16:15:26 +00:00
|
|
|
>
|
2023-03-06 09:02:40 +00:00
|
|
|
{label !== '' && <FormLabel>{label}</FormLabel>}
|
2023-05-15 07:45:05 +00:00
|
|
|
<Input {...rest} onPaste={stopPastePropagation} />
|
2022-10-03 16:15:26 +00:00
|
|
|
</FormControl>
|
|
|
|
);
|
2023-03-09 09:30:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default memo(IAIInput);
|