import { Checkbox, Field, FieldContent, FieldDescription, FieldError, } from "@repo/shadcn-ui/components"; import { cn } from "@repo/shadcn-ui/lib/utils"; import * as React from "react"; import { Controller, type FieldPath, type FieldValues, useFormContext } from "react-hook-form"; import { FormFieldLabel } from "./form-field-label.tsx"; type CheckboxFieldProps = { name: FieldPath; label: string; description?: string; reserveDescriptionSpace?: boolean; disabled?: boolean; required?: boolean; readOnly?: boolean; orientation?: "vertical" | "horizontal" | "responsive"; className?: string; inputClassName?: string; }; export const CheckboxField = ({ name, label, description, reserveDescriptionSpace = false, disabled = false, required = false, readOnly = false, orientation = "horizontal", className, inputClassName, }: CheckboxFieldProps) => { const { control, formState } = useFormContext(); const inputId = React.useId(); const descriptionId = description ? `${inputId}-description` : undefined; const isDisabled = disabled || readOnly || formState.isSubmitting; return ( { const hasError = Boolean(fieldState.error); return ( { field.onChange(checked === true); }} ref={field.ref} required={required} /> {label} {description ? ( {description} ) : reserveDescriptionSpace ? (