This repository has been archived on 2025-05-09. You can view files and clone it, but cannot push or open issues or pull requests.
2022-02-03 15:56:32 +03:00

51 lines
1.1 KiB
JavaScript

import { Form, Radio as AntRadio } from 'antd';
import { ElementStatus } from 'types/elements';
const Radio = ({
value,
setCurrentValue,
status,
validateStatus,
message,
options,
style,
...props
}) => {
return (
<Form.Item validateStatus={validateStatus} help={message}>
<AntRadio.Group
{...props}
disabled={status === ElementStatus.Disabled}
buttonStyle={style === 'button' && 'solid'}
value={value}
onChange={e => {
if (e && e.target) setCurrentValue(e.target.value);
}}
>
{options.map((option, i) => {
if (style === 'button') {
return (
<AntRadio.Button key={i} value={option.value || ''}>
{option.name}
</AntRadio.Button>
);
}
return (
<AntRadio key={i} value={option.value || ''} style={styles.radio}>
{option.name}
</AntRadio>
);
})}
</AntRadio.Group>
</Form.Item>
);
};
const styles = {
radio: {
display: 'block',
},
};
export default Radio;