import React from 'react'; import PropTypes from 'prop-types'; import { ComponentProps } from '../utils/types'; /** @public */ type CheckboxChangeHandler = (event: React.ChangeEvent, data: { checked: boolean; name?: string; value?: string; }) => void; interface CheckboxPropsBase { /** * Setting this value makes the component controlled. If set, the onChange callback is required. * A setting of "indeterminate" is considered unchecked for the purposes of form submission. */ checked?: boolean | 'indeterminate'; /** The content to display inside the checkbox label. */ children?: React.ReactNode; /** Set this property instead of checked to make the component uncontrolled. */ defaultChecked?: boolean; /** * The id of the description. * When placed in a ControlGroup, this is automatically set to the ControlGroup's help component. */ describedBy?: string; disabled?: boolean; /** * A React ref which is set to the DOM element when the component mounts, and null when it unmounts. */ elementRef?: React.Ref; /** * Mark the component as having an error. */ error?: boolean; inert?: boolean; /** * A React ref which is set to the input element when the component mounts and null when it unmounts. */ inputRef?: React.Ref; /** * The id of the label. * When placed in a ControlGroup, this is automatically set to the ControlGroup's label. */ labelledBy?: string; /** * The name is returned with onChange events, which can be used to identify the * control when multiple controls share an onChange callback. */ name?: string; /** * Fires when the checked state changes. */ onChange?: CheckboxChangeHandler; /** @private. */ required?: boolean; /** * Returned by the onChange handler and submitted during form submission if the checkbox is checked. * This defaults to "on" if the input is checked. */ value?: string; } interface CheckboxPropsBaseControlled extends CheckboxPropsBase { defaultChecked?: never; onChange: CheckboxChangeHandler; } interface CheckboxPropsBaseUncontrolled extends CheckboxPropsBase { defaultChecked?: boolean; checked?: never; } type CheckboxProps = ComponentProps; declare const Checkbox: { ({ checked, children, defaultChecked, describedBy, disabled, elementRef, error, id, inert, inputRef, labelledBy, name, onChange, required, role, tabIndex, value, ...otherProps }: CheckboxProps): React.JSX.Element; propTypes: { checked: PropTypes.Requireable; children: PropTypes.Requireable; defaultChecked: PropTypes.Requireable; describedBy: PropTypes.Requireable; disabled: PropTypes.Requireable; elementRef: PropTypes.Requireable; error: PropTypes.Requireable; inert: PropTypes.Requireable; inputRef: PropTypes.Requireable; labelledBy: PropTypes.Requireable; name: PropTypes.Requireable; onChange: PropTypes.Requireable<(...args: any[]) => any>; /** @private. */ required: PropTypes.Requireable; }; }; export default Checkbox; export { CheckboxChangeHandler, CheckboxPropsBase, CheckboxPropsBaseControlled, CheckboxPropsBaseUncontrolled, };