var Checkbox; import React from 'react'; import autoBind from 'react-autobind'; export default Checkbox = class Checkbox extends React.Component { constructor(props) { var ref; super(props); this.state = { checked: props.checked != null ? props.checked : props.checked = false, disabled: (ref = props.disabled) != null ? ref : false }; //this.toggle = this.toggle.bind(this) autoBind(this); } componentWillReceiveProps(props) { return this.setState({ checked: props.checked }); } shouldComponentUpdate(nextProps, nextState) { var res; res = nextState.checked !== this.state.checked; return res; } setValue(x) { return this.setState({ checked: x }); } aToggle(checked) { var base; return typeof (base = this.props).onChange === "function" ? base.onChange(checked) : void 0; } toggle(e = null) { var checked, disabled; ({ disabled } = this.state); if (e != null) { e.stopPropagation(); } if (!disabled) { checked = !this.state.checked; return this.setState({ checked: checked }, this.aToggle.bind(this, checked)); } } render() { var checked, disabled; ({ checked, disabled } = this.state); return /*#__PURE__*/React.createElement("div", { class: "checkbox " + (checked ? "checked" : "") + (disabled ? " disabled" : ""), onClick: this.toggle }, /*#__PURE__*/React.createElement("input", { type: "checkbox", defaultChecked: this.state.checked, checked: checked })); } }; //# sourceMappingURL=checkbox.js.map