2022-06-03 17:22:11 +03:00

36 lines
780 B
TypeScript

import type { SpaceProps } from 'antd';
import { Form, Segmented as AntSegmented } from 'antd';
import type { BaseElementProps, BaseOption } from './types';
const { Item: FormItem } = Form;
type ElementProps = BaseElementProps<string | number> & {
options: BaseOption[];
spaceProps?: SpaceProps;
};
export default function Segmented({
value,
setValue,
options,
status,
isValid,
help,
spaceProps,
...props
}: ElementProps) {
return (
<FormItem hasFeedback validateStatus={isValid === false ? 'error' : ''} help={help}>
<AntSegmented
value={value}
onChange={setValue}
disabled={status === 'Disabled'}
options={options}
{...props}
/>
</FormItem>
);
}
export { type SegmentedProps } from 'antd';