UNPKG

@kadconsulting/dry

Version:
32 lines (31 loc) 1.27 kB
import type { ReactNode, HTMLAttributes, ChangeEvent } from 'react'; /** Adds an "indeterminate" minus sign icon inside the checkbox; useful for "global" or parent checkbox state that indicates some children are checked and some are not, such as in a table header whose table rows contain checkboxes */ export type IndeterminateCheckboxProps = { checked?: never; indeterminate?: boolean; }; export type CheckedCheckboxProps = { checked: boolean; indeterminate?: never; }; export type CheckboxState = CheckedCheckboxProps | IndeterminateCheckboxProps; export type BaseCheckboxProps = CheckboxState & HTMLAttributes<HTMLDivElement> & { passProps?: object; 'data-testid'?: string; disabled?: boolean; onChange?: (event: ChangeEvent<HTMLInputElement>) => void; LabelContent: ReactNode | ReactNode[]; color?: 'light-contrast' | 'dark-contrast'; LabelProps?: HTMLAttributes<HTMLLabelElement> & { labelColor?: 'light-contrast' | 'dark-contrast'; }; }; export type ExtendedCheckboxProps = BaseCheckboxProps & { subText?: string; extraText?: string; extraTextPosition?: 'left' | 'right'; isCard?: boolean; value?: string; extraColor?: string; }; export type CheckboxProps = ExtendedCheckboxProps;