import _createClass from "@babel/runtime-corejs2/helpers/createClass";
import _inheritsLoose from "../../inheritsLoose";
import _defineProperty from "@babel/runtime-corejs2/helpers/defineProperty";
import Intact from 'intact-angular';
import template from './index.vdt';
import '../../styles/kpc.css';
import './index.css';
var isArray = Intact.Vdt.utils.isArray;

var Checkbox =
/*#__PURE__*/
function (_Intact) {
  _inheritsLoose(Checkbox, _Intact);

  function Checkbox() {
    return _Intact.apply(this, arguments) || this;
  }

  var _proto = Checkbox.prototype;

  _proto.defaults = function defaults() {
    return {
      disabled: false,
      value: false,
      trueValue: true,
      falseValue: false,
      indeterminate: false
    };
  };

  _proto._destroy = function _destroy() {// we should not change data in _destroy
    // we must use _context to get value, because it maybe has changed
    // const model = this.get('v-model');
    // if (!model) return;
    // let value = this.get('_context').data.get(model);
    // if (!value) return;
    // const trueValue = this.get('trueValue');
    // if (this.isChecked()) {
    // if (isArray(value)) {
    // value = value.slice(0);
    // const index = value.indexOf(trueValue);
    // value.splice(index, 1);
    // this.set('value', value);
    // } else {
    // this.set('value', this.get('falseValue'));
    // }
    // }
  };

  _proto.isChecked = function isChecked() {
    var value = this.get('value');
    var trueValue = this.get('trueValue');
    return isArray(value) ? value.indexOf(trueValue) > -1 : value === trueValue;
  };

  _proto._onKeypress = function _onKeypress(e) {
    if (e.keyCode === 13) {
      this.refs.input.click();
    }
  };

  _createClass(Checkbox, [{
    key: "template",
    get: function get() {
      return template;
    }
  }]);

  return Checkbox;
}(Intact);

_defineProperty(Checkbox, "propTypes", {
  disabled: Boolean,
  indeterminate: Boolean,
  // declare for camelizing in Vue dom template
  trueValue: undefined,
  falseValue: undefined // set value to falseValue when destroy

});

export { Checkbox as default };
export { Checkbox };