import { ChangeEventHandler } from 'react'; import { RadioSize } from '@mezzanine-ui/core/radio'; import { IconDefinition } from '@mezzanine-ui/icons'; import { InputCheckProps } from '../_internal/InputCheck/InputCheck'; import { BaseInputProps } from '../Input'; import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types'; export interface RadioBaseProps extends Omit { /** * Whether the radio is checked. */ checked?: boolean; /** * Whether the radio is checked by default. * @default false */ defaultChecked?: boolean; /** * Since at Mezzanine we use a host element to wrap our input, most derived props will be passed to the host element. * If you need direct control to the input element, use this prop to provide to it. * * Noticed that if you pass an id within this prop, * the rendered label element will have `htmlFor` sync with passed in id. */ inputProps?: Omit, 'checked' | 'defaultChecked' | 'disabled' | 'onChange' | 'placeholder' | 'readOnly' | 'required' | 'type' | 'value' | `aria-${'disabled' | 'checked'}`>; /** * The change event handler of input in radio. */ onChange?: ChangeEventHandler; /** * The size of radio. * @default 'main' */ size?: RadioSize; /** * The value of input in radio. */ value?: string; } export interface RadioNormalProps extends RadioBaseProps { /** 此模式下不適用,僅限 segment 類型。 */ icon?: never; /** 顯示在 radio 標籤下方的輔助說明文字。 */ hint?: string; /** * The type of radio. * @default 'radio' */ type?: 'radio'; /** * When `withInputConfig` is provided, an `Input` component is rendered alongside the * radio using the passed props. By default, this input has a width of 120px unless you * override it via the `width` property below. */ withInputConfig?: Pick & { width?: number; }; } export interface RadioSegmentProps extends RadioBaseProps { /** * The icon in radio prefix. */ icon?: IconDefinition; /** 此模式下不適用,僅限 radio 類型。 */ hint?: never; /** * The type of radio. * @default 'radio' */ type: 'segment'; /** 此模式下不適用,僅限 radio 類型。 */ withInputConfig?: never; } export type RadioProps = RadioNormalProps | RadioSegmentProps; /** * 單選按鈕元件,支援標準(radio)與區段(segment)兩種類型。 * * 在 `RadioGroup` 內使用時,會自動繼承群組的 `name`、`size` 與 `type`; * 也可獨立使用,透過 `checked`/`defaultChecked` 進行受控或非受控操作。 * `segment` 類型可搭配 `icon` 屬性顯示圖示,適合用於分頁切換情境。 * * @example * ```tsx * import Radio from '@mezzanine-ui/react/Radio'; * * // 基本用法(非受控) * 男性 * * // 受控用法 * const [value, setValue] = useState('a'); * setValue('a')} * > * 選項 A * * * // Segment 類型搭配圖示 * import { ListIcon } from '@mezzanine-ui/icons'; * 列表 * ``` * * @see {@link RadioGroup} 管理多個單選按鈕的群組元件 * @see {@link useRadioControlValue} 單選按鈕受控值的自訂 Hook */ declare const Radio: import("react").ForwardRefExoticComponent>; export default Radio;