@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.
64 lines (63 loc) • 2.81 kB
TypeScript
import React from 'react';
import PropTypes from 'prop-types';
import { SwitchAdapter } from '@douyinfe/semi-foundation/lib/cjs/switch/foundation';
import BaseComponent from '../_base/baseComponent';
import '@douyinfe/semi-foundation/lib/cjs/switch/switch.css';
export interface SwitchProps {
'aria-label'?: React.AriaAttributes['aria-label'];
'aria-describedby'?: React.AriaAttributes['aria-describedby'];
'aria-errormessage'?: React.AriaAttributes['aria-errormessage'];
'aria-invalid'?: React.AriaAttributes['aria-invalid'];
'aria-labelledby'?: React.AriaAttributes['aria-labelledby'];
defaultChecked?: boolean;
checked?: boolean;
disabled?: boolean;
onChange?: (checked: boolean, e: React.ChangeEvent<HTMLInputElement>) => void;
loading?: boolean;
className?: string;
style?: React.CSSProperties;
onMouseEnter?: (e: React.MouseEvent) => any;
onMouseLeave?: (e: React.MouseEvent) => any;
size?: 'large' | 'default' | 'small';
checkedText?: React.ReactNode;
uncheckedText?: React.ReactNode;
id?: string;
}
export interface SwitchState {
nativeControlChecked: boolean;
nativeControlDisabled: boolean;
focusVisible: boolean;
}
declare class Switch extends BaseComponent<SwitchProps, SwitchState> {
static propTypes: {
'aria-label': PropTypes.Requireable<string>;
'aria-labelledby': PropTypes.Requireable<string>;
'aria-invalid': PropTypes.Requireable<boolean>;
'aria-errormessage': PropTypes.Requireable<string>;
'aria-describedby': PropTypes.Requireable<string>;
className: PropTypes.Requireable<string>;
checked: PropTypes.Requireable<boolean>;
checkedText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
defaultChecked: PropTypes.Requireable<boolean>;
disabled: PropTypes.Requireable<boolean>;
loading: PropTypes.Requireable<boolean>;
onChange: PropTypes.Requireable<(...args: any[]) => any>;
onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
style: PropTypes.Requireable<object>;
size: PropTypes.Requireable<"default" | "small" | "large">;
uncheckedText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
id: PropTypes.Requireable<string>;
};
static defaultProps: Partial<SwitchProps>;
private switchRef;
constructor(props: SwitchProps);
componentDidMount(): void;
componentDidUpdate(prevProps: SwitchProps): void;
componentWillUnmount(): void;
get adapter(): SwitchAdapter<SwitchProps, SwitchState>;
handleFocusVisible: (event: React.FocusEvent) => void;
handleBlur: (event: React.FocusEvent) => void;
render(): React.JSX.Element;
}
export default Switch;