InvokeAI/invokeai/frontend/web/src/common/components/IAIInput.tsx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
904 B
TypeScript
Raw Normal View History

2023-03-06 09:02:40 +00:00
import {
FormControl,
FormControlProps,
FormLabel,
Input,
InputProps,
} from '@chakra-ui/react';
import { stopPastePropagation } from 'common/util/stopPastePropagation';
import { ChangeEvent, memo } from 'react';
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'>;
}
const IAIInput = (props: IAIInputProps) => {
const {
2022-12-24 20:28:59 +00:00
label = '',
isDisabled = false,
isInvalid,
2023-03-06 09:02:40 +00:00
formControlProps,
...rest
} = props;
return (
<FormControl
isInvalid={isInvalid}
isDisabled={isDisabled}
2023-03-06 09:02:40 +00:00
{...formControlProps}
>
2023-03-06 09:02:40 +00:00
{label !== '' && <FormLabel>{label}</FormLabel>}
<Input {...rest} onPaste={stopPastePropagation} />
</FormControl>
);
};
export default memo(IAIInput);