2022-12-20 12:01:31 +03:00

22 lines
579 B
TypeScript

import type { SwitchProps } from 'antd';
import { Form, Switch as AntSwitch } from 'antd';
import type { FC } from 'react';
import type { BaseElementProps } from './types';
const { Item: FormItem } = Form;
export default (function Switch({
value,
setValue,
status,
isValid,
help,
...props
}: BaseElementProps<boolean>) {
return (
<FormItem hasFeedback validateStatus={isValid === false ? 'error' : ''} help={help}>
<AntSwitch checked={value} onChange={setValue} disabled={status === 'Disabled'} {...props} />
</FormItem>
);
} as FC<SwitchProps>);