'use client'; import type { BaseFormInputProps } from '@/components/blocks/asset-form/asset-form-types'; import { getAriaAttributes } from '@/components/blocks/asset-form/asset-form-types'; import { Checkbox } from '@/components/ui/checkbox'; import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form'; import { cn } from '@/lib/utils'; import type { ComponentPropsWithoutRef } from 'react'; import type { FieldValues } from 'react-hook-form'; type CheckboxProps = ComponentPropsWithoutRef; type AssetFormCheckboxProps = Omit> & BaseFormInputProps; /** * A form checkbox component that wraps shadcn's Checkbox component with form field functionality. * * @example * ```tsx * * ``` */ export function AssetFormCheckbox({ label, rules, description, className, ...props }: AssetFormCheckboxProps) { return ( { const ariaAttrs = getAriaAttributes(field.name, !!fieldState.error, props.disabled); return (
{label && ( {label} {props.required && *} )} {description && ( {description} )}
); }} /> ); }