dev
This commit is contained in:
@@ -1,35 +1,28 @@
|
||||
import {
|
||||
FieldValues,
|
||||
Path,
|
||||
RegisterOptions,
|
||||
UseFormReturn,
|
||||
} from 'react-hook-form';
|
||||
import { cn } from '../../../helper/cn';
|
||||
import { FieldValues, Path, RegisterOptions, UseFormReturn } from "react-hook-form";
|
||||
import { cn } from "../../../helper/cn";
|
||||
|
||||
interface InputProps<T extends FieldValues>
|
||||
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'form'> {
|
||||
name: Path<T>;
|
||||
form: UseFormReturn<T>;
|
||||
formOptions?: RegisterOptions<T>;
|
||||
label?: string;
|
||||
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "form"> {
|
||||
name: Path<T>;
|
||||
form: UseFormReturn<T>;
|
||||
formOptions?: RegisterOptions<T>;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export const Switch = <T extends FieldValues>({
|
||||
name,
|
||||
label = name,
|
||||
form,
|
||||
formOptions,
|
||||
className,
|
||||
...inputProps
|
||||
name,
|
||||
label = name,
|
||||
form,
|
||||
formOptions,
|
||||
className,
|
||||
...inputProps
|
||||
}: InputProps<T>) => {
|
||||
return (
|
||||
<div className="form-control ">
|
||||
<label className="label cursor-pointer w-full">
|
||||
<span className={cn('label-text text-left w-full', className)}>
|
||||
{label}
|
||||
</span>
|
||||
<input type="checkbox" className="toggle" {...form.register(name)} />
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div className="form-control ">
|
||||
<label className="label cursor-pointer w-full">
|
||||
<span className={cn("label-text text-left w-full", className)}>{label}</span>
|
||||
<input type="checkbox" className={cn("toggle", className)} {...form.register(name)} />
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user