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