2023-02-06 12:19:39 +03:00

17 lines
573 B
TypeScript

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