ant-design/components/radio/interface.tsx
vagusX afa4442a10
refactor: add optionType for Radio internally (#34849)
* refactor: add optionType for Radio internally

* fix: lint

* fix: update snapshot

* feat: remove useless condition for RadioGroupContext

* test: add test case for Radio.Button
2022-04-08 15:23:52 +08:00

51 lines
1.4 KiB
TypeScript

import * as React from 'react';
import { AbstractCheckboxGroupProps } from '../checkbox/Group';
import { AbstractCheckboxProps } from '../checkbox/Checkbox';
import { SizeType } from '../config-provider/SizeContext';
export type RadioGroupButtonStyle = 'outline' | 'solid';
export type RadioGroupOptionType = 'default' | 'button';
export interface RadioGroupProps extends AbstractCheckboxGroupProps {
defaultValue?: any;
value?: any;
onChange?: (e: RadioChangeEvent) => void;
size?: SizeType;
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
name?: string;
children?: React.ReactNode;
id?: string;
optionType?: RadioGroupOptionType;
buttonStyle?: RadioGroupButtonStyle;
}
export interface RadioGroupContextProps {
onChange: (e: RadioChangeEvent) => void;
value: any;
disabled?: boolean;
name?: string;
/**
* Control the appearance for Radio to display as button or not
*
* @default 'default'
* @internal
*/
optionType?: RadioGroupOptionType;
}
export type RadioProps = AbstractCheckboxProps<RadioChangeEvent>;
export interface RadioChangeEventTarget extends RadioProps {
checked: boolean;
}
export interface RadioChangeEvent {
target: RadioChangeEventTarget;
stopPropagation: () => void;
preventDefault: () => void;
nativeEvent: MouseEvent;
}
export type RadioOptionTypeContextProps = RadioGroupOptionType;