21 lines
683 B
TypeScript
21 lines
683 B
TypeScript
import type { BaseElementProps } from './types';
|
|
import type { InputProps } from 'antd';
|
|
import { Form, Input as AntInput } from 'antd';
|
|
import type { ChangeEvent, FC } from 'react';
|
|
|
|
const { Item: FormItem } = Form;
|
|
|
|
function Input({ value, setValue, status, isValid, help, ...props }: BaseElementProps<string>) {
|
|
function handleChange(event: ChangeEvent<HTMLInputElement>) {
|
|
setValue(event.target.value);
|
|
}
|
|
|
|
return (
|
|
<FormItem hasFeedback help={help} validateStatus={isValid === false ? 'error' : ''}>
|
|
<AntInput disabled={status === 'Disabled'} onChange={handleChange} value={value} {...props} />
|
|
</FormItem>
|
|
);
|
|
}
|
|
|
|
export default Input as FC<InputProps>;
|