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