2017-11-21 15:12:03 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
import { AbstractCheckboxGroupProps } from '../checkbox/Group';
|
2018-03-08 21:42:22 +08:00
|
|
|
import { AbstractCheckboxProps } from '../checkbox/Checkbox';
|
2017-11-21 15:12:03 +08:00
|
|
|
|
2018-07-23 10:01:42 +08:00
|
|
|
export type RadioGroupButtonStyle = 'outline' | 'solid';
|
|
|
|
|
2017-11-21 15:12:03 +08:00
|
|
|
export interface RadioGroupProps extends AbstractCheckboxGroupProps {
|
2019-06-16 20:51:47 +08:00
|
|
|
defaultValue?: unknown;
|
|
|
|
value?: unknown;
|
2018-03-08 20:34:40 +08:00
|
|
|
onChange?: (e: RadioChangeEvent) => void;
|
2017-11-21 15:12:03 +08:00
|
|
|
size?: 'large' | 'default' | 'small';
|
|
|
|
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
|
|
|
|
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
|
|
|
|
name?: string;
|
2017-11-24 15:36:59 +08:00
|
|
|
children?: React.ReactNode;
|
2017-12-01 11:50:07 +08:00
|
|
|
id?: string;
|
2018-07-23 10:01:42 +08:00
|
|
|
buttonStyle?: RadioGroupButtonStyle;
|
2017-11-21 15:12:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface RadioGroupState {
|
2019-06-16 20:51:47 +08:00
|
|
|
value: unknown;
|
2017-11-21 15:12:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface RadioGroupContext {
|
|
|
|
radioGroup: {
|
|
|
|
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
2019-06-16 20:51:47 +08:00
|
|
|
value: unknown;
|
2017-11-21 15:12:03 +08:00
|
|
|
disabled: boolean;
|
|
|
|
name: string;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-03-08 20:34:40 +08:00
|
|
|
export type RadioProps = AbstractCheckboxProps<RadioChangeEvent>;
|
|
|
|
|
|
|
|
export interface RadioChangeEventTarget extends RadioProps {
|
|
|
|
checked: boolean;
|
|
|
|
}
|
|
|
|
|
2018-03-08 21:42:22 +08:00
|
|
|
export interface RadioChangeEvent {
|
|
|
|
target: RadioChangeEventTarget;
|
|
|
|
stopPropagation: () => void;
|
|
|
|
preventDefault: () => void;
|
2018-07-24 14:49:23 +08:00
|
|
|
nativeEvent: MouseEvent;
|
2018-03-08 21:42:22 +08:00
|
|
|
}
|