meraproject/lib/js/bws/react/form/switchios.js

58 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

var SwitchIOS;
export default window.SwitchIOS = SwitchIOS = class SwitchIOS extends React.Component {
constructor(props) {
var ref, ref1;
super(props);
this.state = {
checked: (ref = props.checked) != null ? ref : false,
label: (ref1 = props.label) != null ? ref1 : ''
};
this.toggle = this.toggle.bind(this);
}
getValue() {
if (this.state.checked) {
return 1;
} else {
return 0;
}
}
aToggle() {
var base;
return typeof (base = this.props).onChange === "function" ? base.onChange(this.state.checked) : void 0;
}
toggle() {
return this.setState({
checked: !this.state.checked
}, this.aToggle);
}
setValueSilence(x) {
return this.setState({
checked: x
});
}
componentWillReceiveProps(props) {} //this.setState {checked:props.checked}
render() {
var checked;
({
checked
} = this.state);
return /*#__PURE__*/React.createElement("div", {
class: " f fvcenter",
onClick: this.toggle
}, /*#__PURE__*/React.createElement("div", {
class: ["switch mr-10", checked ? 'selected' : ''].join(" ")
}), /*#__PURE__*/React.createElement("span", {
class: ""
}, this.state.label));
}
};
//# sourceMappingURL=switchios.js.map