"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames3=_interopRequireDefault(require("../helpers/libs/classNames")),_fieldNamesBehavior=require("../helpers/mixins/fieldNamesBehavior");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,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}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.")}(0,_baseComponent.default)({externalClasses:["wux-scroll-view-class"],properties:_objectSpread({prefixCls:{type:String,value:"wux-cascader"},defaultValue:{type:Array,value:[]},value:{type:Array,value:[],observer:function(e){this.data.controlled&&(this.setActiveValue(e),this.setInnerValue(e))}},controlled:{type:Boolean,value:!1},title:{type:String,value:""},cancelText:{type:String,value:"取消"},confirmText:{type:String,value:"确定"},options:{type:Array,value:[]},full:{type:Boolean,value:!1},height:{type:[String,Number],value:"auto"},chooseTitle:{type:String,value:"请选择"},visible:{type:Boolean,value:!1,observer:function(e){e&&this.setShouldRender(!0)}},skipAnimation:{type:Boolean,value:!1}},_fieldNamesBehavior.fieldNamesProps),data:{shouldRender:!1,innerValue:[],activeValue:[]},computed:{classes:["prefixCls",function(e){return{wrap:(0,_classNames3.default)(e),hd:"".concat(e,"__hd"),bd:"".concat(e,"__bd"),toolbar:"".concat(e,"__toolbar"),inner:"".concat(e,"__inner"),cancel:(0,_classNames3.default)("".concat(e,"__button"),_defineProperty({},"".concat(e,"__button--cancel"),!0)),confirm:(0,_classNames3.default)("".concat(e,"__button"),_defineProperty({},"".concat(e,"__button--confirm"),!0)),hover:"".concat(e,"__button--hover"),title:"".concat(e,"__title")}}]},methods:{setShouldRender:function(e){this.data.shouldRender!==e&&this.setData({shouldRender:e})},setActiveValue:function(e,t){this.data.activeValue===e&&!t||this.setData({activeValue:e})},setInnerValue:function(e){this.data.innerValue!==e&&this.setData({innerValue:e})},getValue:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.data.activeValue;return this.cascaderView=this.cascaderView||this.querySelector("#wux-cascader-view"),this.cascaderView&&this.cascaderView.getValue(e)},onTabsChange:function(e){this.triggerEvent("tabsChange",e.detail)},onLoadOptions:function(e){this.triggerEvent("load",e.detail)},onChange:function(e){var t=this.data.visible,e=e.detail,n=e.value;this.setInnerValue(n),t&&this.triggerEvent("change",e)},close:function(){this.triggerEvent("close")},onClosed:function(){var e=this.data.activeValue;this.setInnerValue(e),this.setShouldRender(!1)},onConfirm:function(){var e=this.data.innerValue;this.data.controlled||this.setActiveValue(e,!0),this.triggerEvent("confirm",_objectSpread({},this.getValue(e))),this.close()},onCancel:function(){this.triggerEvent("cancel",_objectSpread({},this.getValue())),this.close()},noop:function(){}},attached:function(){var e=this.data,t=e.defaultValue,n=e.value,r=e.controlled,e=e.visible,r=r?n:t;this.setActiveValue(r),this.setInnerValue(r),this.setShouldRender(e)}});