import { CSSProperties, ChangeEvent, ReactNode, HTMLAttributes } from 'react'; /** * @title Radio */ export interface RadioProps extends Omit, 'children' | 'className' | 'onChange'> { style?: CSSProperties; className?: string | string[]; /** * 是否禁用 */ disabled?: boolean; /** * 控件的 `value` */ value?: T; /** * 是否选中(受控模式) */ checked?: boolean; /** * 初始是否选中 */ defaultChecked?: boolean; /** * 值变化的回调 */ onChange?: (checked: boolean, event: ChangeEvent) => void; children?: ReactNode | ((value: { checked: boolean; }) => ReactNode); } /** * @title Radio.Group */ export interface RadioGroupProps { style?: CSSProperties; className?: string | string[]; disabled?: boolean; /** * 按钮风格,描边及填色两种 * @defaultValue outline */ buttonStyle?: 'outline' | 'solid'; /** * `Radio` 的 name */ name?: string; /** * 单选的类型,是单选还是按钮 * @defaultValue radio */ type?: 'radio' | 'button'; /** * 方向 * @defaultValue horizontal */ direction?: 'vertical' | 'horizontal'; /** * 按钮类型的单选框尺寸(只在按钮类型下生效) */ size?: 'small' | 'middle' | 'large'; /** * 点击单选的回调 */ onChange?: (value: any, event: ChangeEvent) => void; /** * 默认选中的值 */ defaultValue?: any; /** * 选中的值(受控模式) */ value?: any; /** * 以数组配置的形式来设置单选组 */ options?: (string | number | { label: ReactNode; value: any; disabled?: boolean; })[]; } export interface RadioGroupContextProps { type: 'radio' | 'button'; value?: any; disabled?: boolean; group?: boolean; name?: RadioGroupProps['name']; onChangeValue?: (value: any, event: ChangeEvent) => void; }