import React from 'react'; import { FormControlledComponent } from '../../models/form-component'; import { FieldPath } from 'react-hook-form/dist/types/path'; import { FieldPathValue, UnpackNestedValue } from 'react-hook-form/dist/types'; import { Controller, Path } from 'react-hook-form'; import Switch from 'react-switch'; import { AbstractFormItem, AbstractFormItemProps } from './abstract-form-item'; interface FormSwitchProps extends FormControlledComponent, AbstractFormItemProps { defaultValue?: boolean, } /** * This component is a wrapper for react-switch, to use with react-hook-form. */ export const FormSwitch = ({ id, label, tooltip, className, error, rules, disabled, control, defaultValue, formState, readOnly, warning }: FormSwitchProps) => { return ( } control={control} defaultValue={defaultValue as UnpackNestedValue>>} render={({ field: { onChange, value, ref } }) => } /> ); };