import './style.scss';
import Switch from '../../../switch';
import BaseFormControl from '../../baseFormControl';
class JDSwitch extends BaseFormControl {
    constructor(config) {
        super();
        this.name = 'JDSwitch';
        this.config = $.extend(true, {
            domData: {},
            onStateChange: () => {
            },
        }, config);
        this.render();
    }
    render() {
        this.appendFormControl('<div class="J-jdSwitch"></div>');
        this.node = this.element.find('.J-jdSwitch');
        this.config.node = this.node[0];
        this.switch = new Switch(this.config);
        this.switch.setState(this.config.moduleData === 1);
    }
    getData() {
        const data = {};
        const key = this.config.domData.name;
        data[key] = this.switch.getState() ? 1 : 0;
        return data;
    }
}
export default JDSwitch;