"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames=_interopRequireDefault(require("../helpers/libs/classNames")),_getDefaultContext=require("../helpers/shared/getDefaultContext"),_props=require("../checkbox-group/props");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ownKeys(t,e){var n,o=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)),o}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}var defaultContext=_objectSpread(_objectSpread({},(0,_getDefaultContext.getDefaultContext)(_props.props,["disabled","readOnly","hasLine","hasFieldDecorator","withListComponent","iconPosition","iconSize","iconOn","iconOff"])),{},{withListComponent:!1});(0,_baseComponent.default)({useExport:!0,relations:{"../checkbox-group/index":{type:"ancestor"}},properties:{prefixCls:{type:String,value:"wux-checkbox"},cellPrefixCls:{type:String,value:"wux-cell"},selectablePrefixCls:{type:String,value:"wux-selectable"},title:{type:String,value:""},label:{type:String,value:""},extra:{type:String,value:""},value:{type:String,value:""},checked:{type:Boolean,value:!1,observer:function(e){this.setData({inputChecked:e})}},disabled:{type:Boolean,value:!1},readOnly:{type:Boolean,value:!1},color:{type:String,value:"balanced"},wrapStyle:{type:[String,Object],value:""},hasLine:{type:Boolean,value:!0}},data:{inputChecked:!1,index:0,isLast:!1,context:defaultContext},computed:{classes:["prefixCls",function(e){return{cell:(0,_classNames.default)(e),extra:"".concat(e,"__extra"),iconPosition:"".concat(e,"__icon-position"),iconSelectable:"".concat(e,"__icon-selectable"),selectable:"".concat(e,"__selectable"),selectableH:"".concat(e,"__selectable-horizontal")}}]},methods:{checkboxChange:function(e){var t=this.data,n=t.disabled,o=t.readOnly,t=t.context,e=e.detail.checked;n||t.disabled||o||t.readOnly||this.onChange(e)},changeValue:function(){this.setData({inputChecked:0<arguments.length&&void 0!==arguments[0]&&arguments[0],index:1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,isLast:2<arguments.length&&void 0!==arguments[2]&&arguments[2],context:3<arguments.length&&void 0!==arguments[3]?arguments[3]:defaultContext})},onChange:function(e){var t=this.data,e={checked:e,value:t.value,index:t.index},t=this.getRelationsByName("../checkbox-group/index")[0];t?t.onChange(e):this.triggerEvent("change",e)},setChecked:function(e){this.data.inputChecked!==e&&this.setData({inputChecked:e}),this.onChange(e)},check:function(){this.setChecked(!0)},uncheck:function(){this.setChecked(!1)},toggle:function(){this.setChecked(!this.data.inputChecked)}}});