2022-05-16 19:44:42 +03:00

34 lines
735 B
TypeScript

import type { RadioProps } from 'antd';
import { Form, Radio } from 'antd';
import type { BaseElementProps, BaseOption } from './types';
const { Item: FormItem } = Form;
type ElementProps = BaseElementProps<string | null> & {
options: BaseOption[];
};
export default function Element({
value = null,
setValue,
options,
status,
isValid,
help,
...props
}: ElementProps) {
return (
<FormItem hasFeedback validateStatus={isValid === false ? 'error' : ''} help={help}>
<Radio.Group
defaultValue={value}
options={options}
onChange={(e) => setValue(e.target.value)}
disabled={status === 'Disabled'}
{...props}
/>
</FormItem>
);
}
export type { RadioProps };