import type { ChangeEvent, ReactNode, RefAttributes } from "react"; import type { DOMProps } from "../../types/dom"; import type { Validation } from "../../types"; export type CheckboxElementType = HTMLInputElement; export interface CheckboxProps extends DOMProps, Validation, RefAttributes { className?: string; label?: ReactNode; errorMessage?: string; /** The name of the input */ name?: string; /** The current value (controlled). */ value?: string; isDisabled?: boolean; onChange?: (event: ChangeEvent, isLastItem?: boolean) => void; defaultSelected?: boolean; isReadOnly?: boolean; isRequired?: boolean; "aria-errormessage"?: string; /** * Identifies the element (or elements) that describes the object. */ "aria-describedby"?: string; /** * Whether the checkbox is the last item of a group. */ isLastItem?: boolean; /** * **Internal:** Do not use */ groupDisabled?: boolean; /** * Whether the checkbox is selected. */ selected?: boolean; } export type CheckboxGroupElementType = HTMLDivElement; interface CheckboxGroupPropsInternal extends DOMProps, Validation, RefAttributes { children: ReactNode; className?: string; orientation?: "horizontal" | "vertical"; itemsPerRow?: number; errorMessage?: string; onChange?: (values: string[]) => void; "aria-labelledby"?: string; "aria-describedby"?: string; isRequired?: boolean; isDisabled?: boolean; isReadOnly?: boolean; defaultValue?: string[]; label?: ReactNode; /** * The value of the radio button, used when submitting an HTML form. * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio#Value). */ value?: string; /** * This determines if the last item in the group should disable the other items when selected. */ lastItemDisables?: boolean; } interface HorizontalCheckboxGroupProps extends CheckboxGroupPropsInternal { orientation?: "horizontal"; itemsPerRow: number; } interface VerticalCheckboxGroupProps extends CheckboxGroupPropsInternal { orientation?: "vertical"; itemsPerRow?: never; } export type CheckboxGroupProps = HorizontalCheckboxGroupProps | VerticalCheckboxGroupProps; export {};