import React, { Component } from 'react';
import { Switch } from 'antd';
import PropTypes from 'prop-types';
export default class index extends Component {
static propTypes = {
value: PropTypes.bool,
className: PropTypes.string,
checkedText: PropTypes.string,
uncheckedText: PropTypes.string,
disabled: PropTypes.bool,
onChange: PropTypes.func,
};
static defaultProps = {
value: false,
checkedText: t('On'),
uncheckedText: t('Off'),
disabled: false,
};
onChange = (checked) => {
const { onChange } = this.props;
onChange && onChange(checked);
};
render() {
const { value, className, checkedText, uncheckedText, disabled } =
this.props;
const conf = {
checked: value,
className,
checkedChildren: checkedText,
unCheckedChildren: uncheckedText,
disabled,
onChange: this.onChange,
};
return <Switch {...conf} />;
}
}