@douyinfe/semi-ui
Version:
A modern, comprehensive, flexible design system and UI library. Connect DesignOps & DevOps. Quickly build beautiful React apps. Maintained by Douyin-fe team.
99 lines (98 loc) • 3.99 kB
TypeScript
import React from 'react';
import PropTypes from 'prop-types';
import RadioFoundation, { RadioAdapter } from '@douyinfe/semi-foundation/lib/cjs/radio/radioFoundation';
import { RadioChangeEvent } from '@douyinfe/semi-foundation/lib/cjs/radio/radioInnerFoundation';
import { strings } from '@douyinfe/semi-foundation/lib/cjs/radio/constants';
import '@douyinfe/semi-foundation/lib/cjs/radio/radio.css';
import BaseComponent from '../_base/baseComponent';
import RadioInner from './radioInner';
import { RadioContextValue, RadioMode } from './context';
export type RadioDisplayMode = 'vertical' | '';
export type RadioType = typeof strings.TYPE_DEFAULT | typeof strings.TYPE_BUTTON | typeof strings.TYPE_CARD | typeof strings.TYPE_PURECARD;
export type RadioProps = {
autoFocus?: boolean;
checked?: boolean;
children?: React.ReactNode;
defaultChecked?: boolean;
value?: string | number;
disabled?: boolean;
prefixCls?: string;
displayMode?: RadioDisplayMode;
onChange?: (e: RadioChangeEvent) => void;
onMouseEnter?: (e: React.MouseEvent<HTMLLabelElement>) => void;
onMouseLeave?: (e: React.MouseEvent<HTMLLabelElement>) => void;
mode?: RadioMode;
extra?: React.ReactNode;
style?: React.CSSProperties;
className?: string;
addonStyle?: React.CSSProperties;
addonClassName?: string;
type?: RadioType;
'aria-label'?: React.AriaAttributes['aria-label'];
addonId?: string;
extraId?: string;
name?: string;
preventScroll?: boolean;
};
export interface RadioState {
hover?: boolean;
addonId?: string;
extraId?: string;
focusVisible?: boolean;
checked?: boolean;
}
export type { RadioChangeEvent };
declare class Radio extends BaseComponent<RadioProps, RadioState> {
static contextType: React.Context<RadioContextValue>;
static propTypes: {
autoFocus: PropTypes.Requireable<boolean>;
checked: PropTypes.Requireable<boolean>;
defaultChecked: PropTypes.Requireable<boolean>;
value: PropTypes.Requireable<any>;
style: PropTypes.Requireable<object>;
className: PropTypes.Requireable<string>;
disabled: PropTypes.Requireable<boolean>;
prefixCls: PropTypes.Requireable<string>;
displayMode: PropTypes.Requireable<RadioDisplayMode>;
onChange: PropTypes.Requireable<(...args: any[]) => any>;
onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
mode: PropTypes.Requireable<"" | "advanced">;
extra: PropTypes.Requireable<PropTypes.ReactNodeLike>;
addonStyle: PropTypes.Requireable<object>;
addonClassName: PropTypes.Requireable<string>;
type: PropTypes.Requireable<"default" | "button" | "card" | "pureCard">;
'aria-label': PropTypes.Requireable<string>;
preventScroll: PropTypes.Requireable<boolean>;
};
static defaultProps: Partial<RadioProps>;
static elementType: string;
radioEntity: RadioInner;
context: RadioContextValue;
foundation: RadioFoundation;
addonId: string;
extraId: string;
constructor(props: RadioProps);
componentDidUpdate(prevProps: RadioProps): void;
get adapter(): RadioAdapter;
isInGroup(): {
value?: string | number;
isButtonRadio?: any;
disabled?: boolean;
prefixCls?: string;
name?: string;
onChange?: (e: RadioChangeEvent) => void;
buttonSize?: "small" | "large" | "middle";
isCardRadio?: boolean;
isPureCardRadio?: boolean;
};
focus(): void;
blur(): void;
onChange: (e: RadioChangeEvent) => void;
handleMouseEnter: (e: React.MouseEvent<HTMLLabelElement>) => void;
handleMouseLeave: (e: React.MouseEvent<HTMLLabelElement>) => void;
handleFocusVisible: (event: React.FocusEvent) => void;
handleBlur: (event: React.FocusEvent) => void;
render(): React.JSX.Element;
}
export default Radio;