import React from 'react'; import PropTypes from 'prop-types'; import Option from './Option'; import { ComponentProps } from '../utils/types'; /** @public */ type RadioBarChangeHandler = (e: React.MouseEvent | React.KeyboardEvent, data: { label?: string; name?: string; value: any; }) => void; interface RadioBarPropsBase { /** * `children` should be `RadioBar.Option`. */ children?: React.ReactNode; /** * The default value. Only applicable if this is an uncontrolled component. Otherwise, use * the value prop. */ defaultValue?: string | number | boolean; /** * The id of the description. When placed in a ControlGroup, this is automatically set to the * ControlGroup's help component. */ describedBy?: string; /** * A React ref which is set to the DOM element when the component mounts, and null when it unmounts. */ elementRef?: React.Ref; /** * Disable all options in the RadioBar. * This will override the disabled prop on any individual Option. */ disabled?: boolean; /** * Highlight the field as having an error. The buttons will turn red. */ error?: boolean; inline?: boolean; /** * 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; /** A callback that receives the new value. */ onChange?: RadioBarChangeHandler; /** @private. */ required?: boolean; /** The role of the RadioBar. The children Options' `role` will be set to `radio` or `menuitemradio` respectively. */ role?: 'radiogroup' | 'menubar'; /** * The currently selected value. Only applicable if this is a controlled component. */ value?: string | number | boolean; } interface RadioBarPropsBaseControlled extends RadioBarPropsBase { defaultValue?: never; onChange: RadioBarChangeHandler; value?: any; } interface RadioBarPropsBaseUncontrolled extends RadioBarPropsBase { defaultValue?: any; value?: never; } type RadioBarProps = ComponentProps; /** * RadioBar is a form control that provides the ability to select one option out of a group. */ declare function RadioBar({ children, defaultValue: defaultValueProp, describedBy, disabled: disabledProp, elementRef, error, labelledBy, name: nameProp, onChange, required, role, value: valueProp, ...otherProps }: RadioBarProps): React.JSX.Element; declare namespace RadioBar { var Option: typeof import("./Option").default; var propTypes: { children: PropTypes.Requireable; defaultValue: PropTypes.Requireable>; describedBy: PropTypes.Requireable; disabled: PropTypes.Requireable; elementRef: PropTypes.Requireable; error: PropTypes.Requireable; inline: PropTypes.Requireable; labelledBy: PropTypes.Requireable; name: PropTypes.Requireable; onChange: PropTypes.Requireable<(...args: any[]) => any>; /** @private. */ required: PropTypes.Requireable; role: PropTypes.Requireable; value: PropTypes.Requireable>; }; var componentType: string; } export default RadioBar; export { Option, RadioBarChangeHandler }; export type { RadioBarPropsBase, RadioBarPropsBaseControlled, RadioBarPropsBaseUncontrolled };