import { FieldName, useField } from "@conform-to/react/future"; import { Field, FieldProps } from "../field/Field"; import { SelectOption } from "../select/types"; import { Checkbox } from "./Checkbox"; import clsx from "clsx"; interface Props extends Omit { name: FieldName<(string | number)[] | null | undefined>; options: SelectOption[]; direction?: "horizontal" | "vertical"; } export function CheckboxesField({ name, options, id: forcedId, direction, className, ...rest }: Props) { const field = useField(name); const id = forcedId ?? field.id; const itemErrors = Object.values(field.fieldErrors).flat(); const errors = field.errors ?? (itemErrors.length > 0 ? itemErrors : undefined); return (
{options.map((option) => ( {option.label} ))}
); }