import clsx from "clsx"; import React, { useId } from "react"; import { ChoiceFieldProps } from "../choicefield"; import { Checkbox } from "./checkbox"; import "./checkboxgroup.scss"; export type CheckboxGroupProps = ChoiceFieldProps< HTMLDivElement, HTMLInputElement > & { /** Whether the items appear horizontally (h) or vertically (v), mobile devices always use vertical. */ direction?: "h" | "v"; }; export const CheckboxGroup: React.FC = ({ form, direction = "v", id = "", label, name, options, variant, required, onChange, onClick, disabled, }) => { const reactId = useId(); const _id = id || reactId; return (
{options.map((option, index) => { const checkboxId = `${_id}-choice-${index}`; return ( {option.label} ); })}
); };