"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/libs/classNames")),_styleToCssString=_interopRequireDefault(require("../helpers/libs/styleToCssString")),_colors=require("../helpers/colors"),_eventsMixin=_interopRequireDefault(require("../helpers/mixins/eventsMixin"));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 _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.")}(0,_baseComponent.default)({useField:!0,externalClasses:["wux-input-class"],behaviors:[(0,_eventsMixin.default)()],relations:{"../field/index":{type:"ancestor"}},properties:{prefixCls:{type:String,value:"wux-selectable"},type:{type:String,value:"checkbox"},value:{type:String,value:""},defaultChecked:{type:Boolean,value:!1},checked:{type:Boolean,value:!1,observer:function(e){this.data.controlled&&this.updated(e)}},disabled:{type:Boolean,value:!1},readOnly:{type:Boolean,value:!1},color:{type:String,value:"balanced",observer:function(e){this.setData({inputColor:(0,_colors.isPresetColor)(e)})}},controlled:{type:Boolean,value:!1},wrapStyle:{type:[String,Object],value:"",observer:function(e){this.setData({extStyle:(0,_styleToCssString.default)(e)})}},iconSize:{type:String,value:""},iconOn:{type:String,value:""},iconOff:{type:String,value:""}},data:{inputChecked:!1,inputColor:"",extStyle:"",innerIconSize:"23",innerIconOn:"success",innerIconOff:"circle"},observers:_defineProperty({},"type, iconSize, iconOn, iconOff",function(e,t,n,r){var o=""===t,i=""===n&&""===r;"checkbox"===e?this.setData({innerIconSize:o?23:parseInt(t),innerIconOn:i?"success":n,innerIconOff:i?"circle":r}):"radio"===e&&this.setData({innerIconSize:o?16:parseInt(t),innerIconOn:i?"success_no_circle":n,innerIconOff:i?"":r})}),computed:{classes:["prefixCls, inputChecked, disabled, readOnly",function(e,t,n,r){return{wrap:(0,_classNames2.default)(e,_defineProperty(_defineProperty(_defineProperty({},"".concat(e,"--checked"),t),"".concat(e,"--disabled"),n),"".concat(e,"--readonly"),r)),input:"".concat(e,"__input"),icon:"".concat(e,"__icon")}}]},methods:{updated:function(e){this.hasFieldDecorator||this.data.inputChecked!==e&&this.setData({inputChecked:e})},onChange:function(){var e=this.data,t=e.value,n=e.inputChecked,r=e.disabled,o=e.readOnly,e=e.controlled,t={checked:!n,value:t,type:"checkbox"};r||o||(e||this.updated(!n),this.triggerEvent("change",t))}},attached:function(){var e=this.data,t=e.defaultChecked,n=e.checked,e=e.controlled?n:t,n=(0,_colors.isPresetColor)(this.data.color);this.setData({inputChecked:e,inputColor:n})}});