You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.0 KiB
37 lines
1.0 KiB
import React, { 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',
|
|
};
|
|
|
|
static propTypes = {
|
|
prefixCls: PropTypes.string,
|
|
// HACK: https://github.com/ant-design/ant-design/issues/5368
|
|
// size=default and size=large are the same
|
|
size: PropTypes.oneOf(['small', 'default', 'large']),
|
|
className: PropTypes.string,
|
|
};
|
|
|
|
render() {
|
|
const { prefixCls, size, className = '' } = this.props;
|
|
const classes = classNames(className, {
|
|
[`${prefixCls}-small`]: size === 'small',
|
|
});
|
|
return <RcSwitch {...this.props} className={classes} />;
|
|
}
|
|
}
|
|
|