mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
a307a7acf7
* remove unnecessary computed props for classNames * rollback autocomplete optimization for possible css style order issue * update snapshots * remove more unnecessary computed props at Input
38 lines
967 B
TypeScript
Executable File
38 lines
967 B
TypeScript
Executable File
import React from 'react';
|
|
import { PropTypes } from 'react';
|
|
import RcSwitch from 'rc-switch';
|
|
import classNames from 'classnames';
|
|
|
|
export interface SwitchProps {
|
|
prefixCls?: string;
|
|
size?: 'small' | 'default';
|
|
className?: string;
|
|
checked?: boolean;
|
|
defaultChecked?: boolean;
|
|
onChange?: (checked: boolean) => any;
|
|
checkedChildren?: React.ReactNode;
|
|
unCheckedChildren?: React.ReactNode;
|
|
disabled?: boolean;
|
|
}
|
|
|
|
export default class Switch extends React.Component<SwitchProps, any> {
|
|
static defaultProps = {
|
|
prefixCls: 'ant-switch',
|
|
size: 'default',
|
|
};
|
|
|
|
static propTypes = {
|
|
prefixCls: PropTypes.string,
|
|
size: PropTypes.oneOf(['small', 'default']),
|
|
className: PropTypes.string,
|
|
};
|
|
|
|
render() {
|
|
const { prefixCls, size, className = '' } = this.props;
|
|
const classes = classNames(className, {
|
|
[`${prefixCls}-small`]: size === 'small',
|
|
});
|
|
return <RcSwitch {...this.props} className={classes} />;
|
|
}
|
|
}
|