UNPKG

infogo-tree

Version:

A vue tree component using virtual list.

1 lines 62.4 kB
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("vue")):"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["ctree"]=t(require("vue")):e["ctree"]=t(e["Vue"])})("undefined"!==typeof self?self:this,(function(e){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(i,a,function(t){return e[t]}.bind(null,a));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="fb15")}({"7f4f":function(e,t,n){},"8bbf":function(t,n){t.exports=e},a4b1:function(e,t,n){},eced:function(e,t,n){"use strict";var i=n("7f4f"),a=n.n(i);a.a},f6fd:function(e,t){(function(e){var t="currentScript",n=e.getElementsByTagName("script");t in e||Object.defineProperty(e,t,{get:function(){try{throw new Error}catch(i){var e,t=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(i.stack)||[!1])[1];for(e in n)if(n[e].src==t||"interactive"==n[e].readyState)return n[e];return null}}})})(document)},fb15:function(e,t,n){"use strict";var i;(n.r(t),"undefined"!==typeof window)&&(n("f6fd"),(i=window.document.currentScript)&&(i=i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(n.p=i[1]));var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{class:e.wrapperCls},[n("div",{ref:"scrollArea",class:e.scrollAreaCls,on:{"&scroll":function(t){return t.stopPropagation(),e.handleTreeScroll(t)}}},[n("div",{class:e.blockAreaCls},[n("div",{style:e.topSpaceStyles}),e._l(e.renderNodes,(function(t){return n("CTreeNode",e._g(e._b({key:t[e.keyField],class:["function"===typeof e.nodeClassName?e.nodeClassName(t):e.nodeClassName,"function"===typeof e.defaultClassName?e.defaultClassName(t):""],style:{minHeight:e.nodeMinHeight+"px",marginLeft:e.usePadding?null:t._level*e.nodeIndent+"px",paddingLeft:e.usePadding?t._level*e.nodeIndent+"px":null,width:e.usePadding?null:"calc(100% - "+t._level*e.nodeIndent+"px)"},attrs:{data:t,itemSize:e.itemSize},on:{check:e.handleNodeCheck,select:e.handleNodeSelect,expand:e.handleNodeExpand,"node-drop":e.handleNodeDrop},scopedSlots:e._u([{key:"titleAddition",fn:function(t){return[e._t("titleAddition",null,{data:t.data})]}}],null,!0)},"CTreeNode",e.$props,!1),e.treeNodeListeners))})),n("div",{style:e.bottomSpaceStyles})],2)]),n("div",{directives:[{name:"show",rawName:"v-show",value:!e.blockLength,expression:"!blockLength"}],class:e.emptyCls},[n("span",{class:e.emptyTextDefaultCls},[e._t("empty",[e._v("\n "+e._s(e.emptyText)+"\n ")])],2)]),n("div",{directives:[{name:"show",rawName:"v-show",value:e.loading||e.isRootLoading,expression:"loading || isRootLoading"}],class:e.loadingCls},[n("div",{class:e.loadingWrapperCls},[e._t("loading",[n("LoadingIcon",{class:e.loadingIconCls})])],2)]),n("iframe",{ref:"iframe",class:e.iframeCls})])},r=[],s=n("8bbf"),o=n.n(s);function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function d(e,t,n){return t&&c(e.prototype,t),n&&c(e,n),e}var h,u=function(e,t){var n=e[t];if("function"===typeof n)return n(e);if("string"===typeof n)return e[n];if("undefined"===typeof n){var i=e[t];return void 0===i?e.disabled:i}},f=["_level","_filterVisible","_parent","_loading","_loaded","_remote","_keyField","children","setChildren"],p=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"id",a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",s=arguments.length>5?arguments[5]:void 0;for(var o in l(this,e),this._keyField=i,this._remote=a,this._level=0,this.checked=!1,this.selected=!1,this.indeterminate=!1,this.expand=!1,this.visible=!0,this._filterVisible=!0,this._parent=null,this.children=[],this.isLeaf=!1,this._loading=!1,this._loaded=!1,this.disabledFn=s,t)-1===f.indexOf(o)&&o!==r&&(this[o]=t[o]);null==this[i]&&(this[i]=Math.random().toString(36).substring(2)),this._parent=n,this._parent&&(this._level=this._parent._level+1),this.visible=null===this._parent||this._parent.expand&&this._parent.visible,Array.isArray(t[r])&&this.setChildren(t[r],r,s),this.children.length&&(this._loaded=!0),this._remote||(this.isLeaf=!this.children.length),this.disabled=u(this,"disabledFn")}return d(e,[{key:"setChildren",value:function(t,n,i){var a=this;this.children=t.map((function(t){return new e(Object.assign({},t),a,a._keyField,a._remote,n,i)}))}}]),e}();(function(e){e["none"]="none",e["parents"]="parents",e["children"]="children"})(h||(h={}));var v,g,y,k=["setData","setChecked","setCheckedKeys","checkAll","clearChecked","setSelected","clearSelected","setExpand","setExpandKeys","setExpandAll","getCheckedNodes","getCheckedKeys","getIndeterminateNodes","getSelectedNode","getSelectedKey","getExpandNodes","getExpandKeys","getCurrentVisibleNodes","getNode","getTreeData","getFlatData","getNodesCount","insertBefore","insertAfter","append","prepend","remove","filter","showCheckedNodes","loadRootNodes","scrollTo"],m=["clearKeyword","getKeyword","search"];function b(e){return b="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},b(e)}function C(e){return w(e)||S(e)||_()}function _(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function S(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function w(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}function x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function N(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function D(e,t,n){return t&&N(e.prototype,t),n&&N(e,n),e}(function(e){e["bottom-start"]="bottom-start",e["bottom-end"]="bottom-end",e["bottom"]="bottom",e["top-start"]="top-start",e["top-end"]="top-end",e["top"]="top"})(v||(v={})),function(e){e["top"]="top",e["center"]="center",e["bottom"]="bottom"}(g||(g={})),function(e){e["before"]="before",e["body"]="body",e["after"]="after"}(y||(y={}));var A=function(){function e(t){x(this,e),this.options=t,this.data=[],this.childStr="",this.flatData=[],this.mapData=Object.create(null),this.unloadCheckedKeys=[],this.unloadSelectedKey=null,this.currentSelectedKey=null,this.listenersMap={}}return D(e,[{key:"setData",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0;for(var o in this.childStr=a,this.disabledFn=r,this.data=e.map((function(e){return new p(e,null,t.options.keyField,!!t.options.load,a,r)})),this.mapData)delete this.mapData[o];this.currentSelectedKey=null,this.flatData=this.flattenData(this.data),this.setUnloadCheckedKeys(i||[],s),(n||0===n)&&(this.currentSelectedKey=null,this.setUnloadSelectedKey(n)),this.emit("visible-data-change"),this.emit("set-data")}},{key:"setChecked",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=this.mapData[e];if(!s)return this.setUnloadChecked(e,t,n,i);s.disabled&&r||s.checked&&t||(s.checked||s.indeterminate||t)&&(this.options.cascade?(this.checkNodeDownward(s,t,a,r),this.checkNodeUpward(s)):s.checked=t,n&&(s.checked?this.emit("check",s):this.emit("uncheck",s)),this.triggerCheckedChange(n,i))}},{key:"setUnloadChecked",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=this.findIndex(e,this.unloadCheckedKeys);t?-1===a&&this.unloadCheckedKeys.push(e):-1!==a&&this.unloadCheckedKeys.splice(a,1),this.triggerCheckedChange(n,i)}},{key:"setCheckedKeys",value:function(e,t){var n=this,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];e.forEach((function(e){n.setChecked(e,t,!1,!1,!1,r)})),this.triggerCheckedChange(i,a)}},{key:"checkAll",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.options.cascade){var i=function t(n){n.forEach((function(n){n.disabled?t(n.children):e.setChecked(n[e.options.keyField],!0,!1,!1)}))};i(this.data)}else for(var a=this.flatData.length,r=0;r<a;r++){var s=this.flatData[r];this.setChecked(s[this.options.keyField],!0,!1,!1)}this.triggerCheckedChange(t,n)}},{key:"clearChecked",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.getCheckedNodes();i.forEach((function(t){e.setChecked(t[e.options.keyField],!1,!1,!1)})),this.unloadCheckedKeys=[],this.triggerCheckedChange(t,n)}},{key:"triggerCheckedChange",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&this.emit("checked-change",this.getCheckedNodes(),this.getCheckedKeys()),t&&this.emit("render-data-change")}},{key:"setSelected",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=this.mapData[e];if(!a)return this.setUnloadSelected(e,t,n,i);a.disabled||a.selected!==t&&(e===this.currentSelectedKey?t||(a.selected=t,this.currentSelectedKey=null):t&&(null===this.currentSelectedKey?(a.selected=t,this.currentSelectedKey=a[this.options.keyField]):(this.mapData[this.currentSelectedKey]&&(this.mapData[this.currentSelectedKey].selected=!1),a.selected=t,this.currentSelectedKey=a[this.options.keyField])),n&&(a.selected?this.emit("select",a):this.emit("unselect",a),this.emit("selected-change",this.getSelectedNode(),this.getSelectedKey())),i&&this.emit("render-data-change"))}},{key:"setUnloadSelected",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];t?(this.currentSelectedKey&&this.setSelected(this.currentSelectedKey,!1,!1,!1),this.unloadSelectedKey=e):this.unloadSelectedKey===e&&(this.unloadSelectedKey=null),n&&this.emit("selected-change",this.getSelectedNode(),this.getSelectedKey()),i&&this.emit("render-data-change")}},{key:"clearSelected",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.currentSelectedKey&&this.mapData[this.currentSelectedKey]?this.setSelected(this.currentSelectedKey,!1,e,t):null!==this.unloadSelectedKey&&(this.unloadSelectedKey=null,e&&this.emit("selected-change",this.getSelectedNode(),this.getSelectedKey()),t&&this.emit("render-data-change"))}},{key:"setExpand",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=this.mapData[e];if(s&&(i||!s.isLeaf)&&s.expand!==t){if(!s.isLeaf){if("function"===typeof this.options.load){if(!s._loaded&&!s._loading&&t)return s._loading=!0,r&&this.emit("visible-data-change"),void new Promise((function(e,t){var i=n.options.load;i(s,e,t)})).then((function(e){if(Array.isArray(e)&&e.length>0){var i,a=n.findIndex(s);if(-1===a)return;s._loaded=!0,s.expand=t,s.setChildren(e,n.childStr,n.disabledFn);var r=n.getCheckedKeys(),o=n.flattenData(s.children,null===n.getSelectedKey);(i=n.flatData).splice.apply(i,[a+1,0].concat(C(o))),n.setUnloadCheckedKeys(r),null!==n.unloadSelectedKey&&n.setUnloadSelectedKey(n.unloadSelectedKey),n.emit("set-data")}else s&&(s.isLeaf=!0)})).catch((function(e){var t=e;e instanceof Error||(t=new Error(e)),console.error(t)})).then((function(){s._loading=!1,a&&n.emit("expand",s),r&&n.emit("visible-data-change")}));if(s._loading)return}s.expand=t;var o=C(s.children);while(o.length)o[0].expand&&o[0].children.length&&o.push.apply(o,C(o[0].children)),!1===o[0]._filterVisible?o[0].visible=!1:o[0].visible=null===o[0]._parent||o[0]._parent.expand&&o[0]._parent.visible,o.shift();a&&this.emit("expand",s),r&&this.emit("visible-data-change")}i&&s._parent&&t&&this.setExpand(s._parent[this.options.keyField],t,i,!1,r)}}},{key:"setExpandKeys",value:function(e,t){var n=this,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e.forEach((function(e){n.setExpand(e,t,!0,!1,!1)})),i&&this.emit("visible-data-change")}},{key:"setExpandAll",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.flatData.forEach((function(n){t.options.load&&!n._loaded||t.setExpand(n[t.options.keyField],e,!1,!1,!1)})),n&&this.emit("visible-data-change")}},{key:"getCheckedNodes",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.ignoreMode;if(t===h.children){var n=[],i=function t(i){i.forEach((function(i){i.checked?n.push(i):!i.isLeaf&&(i.indeterminate||e.options.cascadeLoose&&!i.indeterminate)&&t(i.children)}))};return i(this.data),n}return this.flatData.filter((function(e){return t===h.parents?e.checked&&e.isLeaf:e.checked}))}},{key:"getCheckedKeys",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.ignoreMode;return this.getCheckedNodes(t).map((function(t){return t[e.options.keyField]})).concat(this.unloadCheckedKeys)}},{key:"getIndeterminateNodes",value:function(){return this.flatData.filter((function(e){return e.indeterminate}))}},{key:"getSelectedNode",value:function(){return null===this.currentSelectedKey?null:this.mapData[this.currentSelectedKey]||null}},{key:"getSelectedKey",value:function(){return 0===this.currentSelectedKey||this.currentSelectedKey?this.currentSelectedKey:this.unloadSelectedKey||null}},{key:"getUnloadCheckedKeys",value:function(){return this.unloadCheckedKeys}},{key:"getExpandNodes",value:function(){return this.flatData.filter((function(e){return!e.isLeaf&&e.expand}))}},{key:"getExpandKeys",value:function(){var e=this;return this.getExpandNodes().map((function(t){return t[e.options.keyField]}))}},{key:"getNode",value:function(e){return this.mapData[e]||null}},{key:"insertBefore",value:function(e,t){var n=this.getInsertedNode(e,t);if(!n)return null;this.remove(n[this.options.keyField],!1);var i=this.mapData[t],a=i._parent,r=this.findIndex(t,a&&a.children),s=this.findIndex(t),o=a?-1:this.findIndex(t,this.data);return this.insertIntoStore(n,a,r,s,o),this.emit("visible-data-change"),n}},{key:"insertAfter",value:function(e,t){var n=this.getInsertedNode(e,t);if(!n)return null;this.remove(n[this.options.keyField],!1);for(var i=this.mapData[t],a=i._parent,r=this.findIndex(t,a&&a.children)+1,s=this.flatData.length,o=this.findIndex(t),l=o+1,c=o+1;c<=s;c++){if(c===s){l=c;break}if(this.flatData[c]._level<=i._level){l=c;break}}var d=a?-1:this.findIndex(t,this.data)+1;return this.insertIntoStore(n,a,r,l,d),this.emit("visible-data-change"),n}},{key:"append",value:function(e,t){var n=this.mapData[t];if(!n.isLeaf){var i=n.children.length;return this.insertAfter(e,n.children[i-1][this.options.keyField])}var a=this.getInsertedNode(e,t,!0);if(!a)return null;this.remove(a[this.options.keyField],!1);var r=this.findIndex(t)+1;return this.insertIntoStore(a,n,0,r),this.emit("visible-data-change"),a}},{key:"prepend",value:function(e,t){var n=this.mapData[t];if(!n.isLeaf)return this.insertBefore(e,n.children[0][this.options.keyField]);var i=this.getInsertedNode(e,t,!0);if(!i)return null;this.remove(i[this.options.keyField],!1);var a=this.findIndex(t)+1;return this.insertIntoStore(i,n,0,a),this.emit("visible-data-change"),i}},{key:"remove",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.mapData[e];if(!i)return null;var a=this.findIndex(i);if(-1===a)return null;for(var r=1,s=this.flatData.length,o=a+1;o<s;o++){if(!(this.flatData[o]._level>i._level))break;r++}this.flatData.splice(a,r);var l=function e(n){var i=t.mapData[n];delete t.mapData[n],i.children.forEach((function(n){return e(n[t.options.keyField])}))};if(l(e),!i._parent){var c=this.findIndex(i,this.data);c>-1&&this.data.splice(c,1)}if(i._parent){var d=this.findIndex(i,i._parent.children);-1!==d&&i._parent.children.splice(d,1),i._parent.isLeaf=!i._parent.children.length,i._parent.isLeaf&&(i._parent.expand=!1,i._parent.indeterminate=!1),this.updateMovingNodeStatus(i)}return n&&this.emit("visible-data-change"),i}},{key:"getInsertedNode",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=this.mapData[t];if(!i)return null;var a=n?i:i._parent;if(e instanceof p)return e[this.options.keyField]===t?null:e;if("object"===b(e)){if(e[this.options.keyField]===t)return null;var r=this.mapData[e[this.options.keyField]];return r||new p(e,a,this.options.keyField,!!this.options.load,this.childStr,this.disabledFn)}return this.mapData[e]&&e!==t?this.mapData[e]:null}},{key:"insertIntoStore",value:function(e,t,n,i,a){var r;if(-1!==i){-1!==n&&t&&t.children.splice(n,0,e),e._parent=t,t?(t.isLeaf=!1,this.setExpand(t[this.options.keyField],!0,!0,!1,!1)):"number"===typeof a&&a>-1&&this.data.splice(a,0,e);var s=this.flattenData([e]);e._level=t?t._level+1:0,s.forEach((function(e){return e._level=e._parent?e._parent._level+1:0})),(r=this.flatData).splice.apply(r,[i,0].concat(C(s))),this.updateMovingNodeStatus(e)}}},{key:"updateMovingNodeStatus",value:function(e){this.checkNodeUpward(e),this.triggerCheckedChange(),e.selected&&this.setSelected(e[this.options.keyField],!0)}},{key:"filter",value:function(e,t){var n=this,i=[];this.flatData.forEach((function(n){n._filterVisible=n._parent&&n._parent._filterVisible||t(e,n),n.visible=n._filterVisible,n._filterVisible&&i.push(n)})),i.forEach((function(e){var t=[],i=e._parent;while(i)t.unshift(i),i=i._parent;t.forEach((function(e){e._filterVisible=!0,e.visible=(null===e._parent||e._parent.expand&&e._parent.visible)&&e._filterVisible,n.options.expandOnFilter&&n.setExpand(e[n.options.keyField],!0,!0,!1,!1)})),e.visible=null===e._parent||e._parent.expand&&e._parent.visible})),this.emit("visible-data-change")}},{key:"setUnloadCheckedKeys",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.unloadCheckedKeys=e;for(var n=e.concat(),i=this.unloadCheckedKeys.length,a=i-1;a>=0;a--){var r=this.unloadCheckedKeys[a];this.mapData[r]&&(this.setChecked(r,!0,!1,!1),this.unloadCheckedKeys.splice(a,1))}var s=this.getCheckedKeys();s.length===n.length&&s.every((function(e){return n.some((function(t){return t===e}))}))||t&&this.emit("checked-change",this.getCheckedNodes(),s)}},{key:"setUnloadSelectedKey",value:function(e){var t=this.getSelectedKey();this.mapData[e]?(this.setSelected(e,!0,!1),this.unloadSelectedKey=null):(this.currentSelectedKey&&this.setSelected(this.currentSelectedKey,!1,!1),this.unloadSelectedKey=e);var n=this.getSelectedKey();n!==t&&this.emit("selected-change",this.getSelectedNode(),n)}},{key:"flattenData",value:function(e){for(var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=e.length,a=0;a<i;a++){var r=e[a],s=r[this.options.keyField];if(n.push(r),this.mapData[s])throw new Error("[CTree] Duplicate tree node key.");this.mapData[s]=r,r.checked&&this.options.cascade&&(this.checkNodeDownward(r,!0),this.checkNodeUpward(r)),r.selected&&t&&(this.clearSelected(!1,!1),this.currentSelectedKey=r[this.options.keyField],this.emit("selected-change",r,this.currentSelectedKey)),!this.options.defaultExpandAll&&!r.expand||this.options.load||r.isLeaf||(r.expand=!1,this.setExpand(r[this.options.keyField],!0,!1,!1,!1)),r.children.length&&this.flattenData(r.children,t,n)}return n}},{key:"checkNodeDownward",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(e.children.forEach((function(e){n.checkNodeDownward(e,t,i,a)})),e.isLeaf||this.options.load&&!e.children.length){if(!e.disabled||e.disabled&&!a){if(i&&!this.options.filteredNodeCheckable&&!e._filterVisible)return;e.checked=t,e.indeterminate=!1}}else this.checkParentNode(e,"down")}},{key:"checkNodeUpward",value:function(e){var t=e._parent;while(t)this.checkParentNode(t,"up"),t=t._parent}},{key:"checkParentNode",value:function(e,t){var n=e.children.length;if(n){for(var i=!1,a=!1,r=!1,s=0;s<n;s++){var o=e.children[s];if(o.disabled||(o.checked?i=!0:a=!0),i&&a||o.indeterminate){this.options.cascadeLoose||(e.indeterminate=!0),r=!0,e.checked=!1;break}}r||("up"===t&&this.options.cascadeLoose?e.checked=!1:(e.checked=i,e.indeterminate=!1))}}},{key:"findIndex",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.flatData;if(null!==t)for(var n=e instanceof p?e[this.options.keyField]:e,i=t.length,a=0;a<i;a++)if(t[0]instanceof p){if(n===t[a][this.options.keyField])return a}else if(n===t[a])return a;return-1}},{key:"on",value:function(e,t){var n=this;this.listenersMap[e]||(this.listenersMap[e]=[]);var i=[];i=Array.isArray(t)?t:[t],i.forEach((function(t){-1===n.listenersMap[e].indexOf(t)&&n.listenersMap[e].push(t)}))}},{key:"off",value:function(e,t){if(this.listenersMap[e])if(t){var n=this.listenersMap[e].indexOf(t);n>-1&&this.listenersMap[e].splice(n,1)}else this.listenersMap[e]=[]}},{key:"emit",value:function(e){if(this.listenersMap[e]){for(var t=this.listenersMap[e].length,n=arguments.length,i=new Array(n>1?n-1:0),a=1;a<n;a++)i[a-1]=arguments[a];for(var r=0;r<t;r++){var s;(s=this.listenersMap[e])[r].apply(s,i)}}}}]),e}(),K=A,F=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{class:e.wrapperCls},[n("div",{class:e.dropBeforeCls}),n("div",e._g({ref:"nodeBody",class:e.nodeBodyCls},e.dropListeners),[n("div",{class:e.squareCls},[n("i",{directives:[{name:"show",rawName:"v-show",value:!e.data.isLeaf&&!e.data._loading,expression:"!data.isLeaf && !data._loading"}],class:e.expandCls,on:{click:e.handleExpand}}),e.data._loading?n("LoadingIcon",{class:e.loadingIconCls}):e._e()],1),e.showCheckbox?n("div",{class:e.squareCls},[n("div",{class:e.checkboxCls,on:{click:e.handleCheck}})]):e._e(),n("div",e._g({class:e.titleCls,style:{height:e.itemSize+"px",lineHeight:e.itemSize+"px"},attrs:{draggable:e.draggable&&!e.disableAll&&!e.data.disabled&&e.allowDrag(e.data)},on:{click:e.handleSelect,dblclick:e.handleDblclick,contextmenu:e.handleRightClick}},e.dragListeners),[e.renderFunction?n(e.renderComponent,{tag:"component"}):[n("p",{staticClass:"custom-tree-node"},[n("span",{staticClass:"tree-label over-hidden",attrs:{title:e.data[e.titleField]}},[e._v(e._s(e.data[e.titleField]))]),e._t("titleAddition",null,{data:e.data})],2)]],2)]),n("div",{class:e.dropAfterCls})])},T=[],$=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("svg",{attrs:{viewBox:"0 0 50 50"}},[n("circle",{staticClass:"ctree-loading-icon__circle",attrs:{cx:"25",cy:"25",r:"20",fill:"none","stroke-width":"5","stroke-miterlimit":"10"}})])},R=[],E=o.a.extend({name:"CLoadingIcon"}),O=E;function L(e,t,n,i,a,r,s,o){var l,c="function"===typeof e?e.options:e;if(t&&(c.render=t,c.staticRenderFns=n,c._compiled=!0),i&&(c.functional=!0),r&&(c._scopeId="data-v-"+r),s?(l=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"===typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),a&&a.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},c._ssrRegister=l):a&&(l=o?function(){a.call(this,this.$root.$options.shadowRoot)}:a),l)if(c.functional){c._injectStyles=l;var d=c.render;c.render=function(e,t){return l.call(t),d(e,t)}}else{var h=c.beforeCreate;c.beforeCreate=h?[].concat(h,l):[l]}return{exports:e,options:c}}var B=L(O,$,R,!1,null,null,null),P=B.exports;function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var j="ctree-tree-node",M=o.a.extend({name:"CTreeNode",inheritAttrs:!1,components:{LoadingIcon:P},props:{data:Object,titleField:String,selectShowField:String,keyField:String,render:Function,checkable:Boolean,selectable:Boolean,unselectOnClick:Boolean,disableAll:Boolean,draggable:Boolean,allowDrag:{type:Function,default:function(){return function(){return!0}}},droppable:Boolean,itemSize:{type:Number,default:34}},data:function(){return{dragoverBody:!1,dragoverBefore:!1,dragoverAfter:!1}},computed:{wrapperCls:function(){return["".concat(j,"__wrapper"),I({},"".concat(j,"__wrapper_is-leaf"),this.data.isLeaf)]},nodeBodyCls:function(){var e;return["".concat(j,"__node-body"),(e={},I(e,"".concat(j,"__drop_active"),this.dragoverBody),I(e,"".concat(j,"__body_selected"),this.data.selected),e)]},dropBeforeCls:function(){return["".concat(j,"__drop"),I({},"".concat(j,"__drop_active"),this.dragoverBefore)]},dropAfterCls:function(){return["".concat(j,"__drop"),I({},"".concat(j,"__drop_active"),this.dragoverAfter)]},squareCls:function(){return["".concat(j,"__square")]},expandCls:function(){return["".concat(j,"__expand"),I({},"".concat(j,"__expand_active"),this.data.expand)]},loadingIconCls:function(){return["".concat(j,"__loading-icon")]},checkboxCls:function(){var e;return["".concat(j,"__checkbox"),(e={},I(e,"".concat(j,"__checkbox_checked"),this.data.checked),I(e,"".concat(j,"__checkbox_indeterminate"),this.data.indeterminate),I(e,"".concat(j,"__checkbox_disabled"),this.disableAll||this.data.disabled),e)]},titleCls:function(){var e;return["".concat(j,"__title"),(e={},I(e,"".concat(j,"__title_selected"),this.data.selected),I(e,"".concat(j,"__selected"),this.selectable&&!this.checkable),I(e,"".concat(j,"__title_disabled"),this.disableAll||this.data.disabled),e)]},fullData:function(){return this.$parent.getNode(this.data[this.keyField])||{}},showCheckbox:function(){return this.checkable},renderFunction:function(){return this.data.render||this.render||null},renderComponent:function(){var e=this;return o.a.extend({name:"Render",functional:!0,render:function(t){return"function"!==typeof e.renderFunction?t("div"):e.renderFunction(t,e.fullData)}})},dragListeners:function(){var e={};return this.draggable&&!this.disableAll&&!this.data.disabled&&this.allowDrag(this.data)&&(e={dragstart:this.handleDragStart}),e},dropListeners:function(){var e={};return this.droppable&&(e={dragenter:this.handleDragEnter.bind(this),dragover:this.handleDragOver.bind(this),dragleave:this.handleDragLeave.bind(this),drop:this.handleDrop.bind(this)}),e}},methods:{handleExpand:function(){this.data.isLeaf||this.$emit("expand",this.fullData)},handleCheck:function(){this.disableAll||this.data.disabled||!this.checkable||this.$emit("check",this.fullData)},handleSelect:function(){if(this.$emit("click",this.fullData),this.selectable){if(this.disableAll||this.data.disabled)return;if(this.data.selected&&!this.unselectOnClick)return;this.$emit("select",this.fullData)}else this.checkable?this.handleCheck():this.handleExpand()},handleDblclick:function(){this.$emit("node-dblclick",this.fullData)},handleRightClick:function(){this.$emit("node-right-click",this.fullData)},getHoverPart:function(e){var t=this.$refs.nodeBody.getBoundingClientRect(),n=t.height,i=e.clientY-t.top;return i<=.3*n?y.before:i<=.7*n?y.body:y.after},resetDragoverFlags:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.dragoverBefore=!1,this.dragoverBody=!1,this.dragoverAfter=!1,t||(e===y.before?this.dragoverBefore=!0:e===y.body?this.dragoverBody=!0:e===y.after&&(this.dragoverAfter=!0))},handleDragStart:function(e){e.dataTransfer&&e.dataTransfer.setData("node",JSON.stringify(this.data)),this.data.expand&&this.handleExpand(),this.$emit("node-dragstart",this.fullData,e)},handleDragEnter:function(e){e.preventDefault();var t=this.getHoverPart(e);this.resetDragoverFlags(t),this.$emit("node-dragenter",this.fullData,e,t)},handleDragOver:function(e){e.preventDefault();var t=this.getHoverPart(e);this.resetDragoverFlags(t),this.$emit("node-dragover",this.fullData,e,t)},handleDragLeave:function(e){var t=this.getHoverPart(e);this.resetDragoverFlags(t,!0),this.$emit("node-dragleave",this.fullData,e,t)},handleDrop:function(e){var t=this.getHoverPart(e);this.resetDragoverFlags(t,!0),this.$emit("node-drop",this.fullData,e,t)}}}),H=M,V=L(H,F,T,!1,null,null,null),W=V.exports;function U(e){return X(e)||q(e)||z()}function z(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function q(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function X(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}function Y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var J="ctree-tree",G=["expand","select","unselect","selected-change","check","uncheck","checked-change","set-data"],Q=["node-drop"],Z=function(e,t){if(Array.isArray(e)&&Array.isArray(t)){if(e.length===t.length&&e.every((function(e){return t.some((function(t){return t===e}))})))return!0}else if(e===t)return!0;return!1},ee=o.a.extend({name:"CTree",components:{CTreeNode:W,LoadingIcon:P},props:{value:[String,Number,Array],data:{type:Array,default:function(){return[]}},unloadDataList:{type:Array,default:function(){return[]}},showUnloadCheckedNodes:{type:Boolean,default:!0},emptyText:{type:String,default:"暂无数据"},titleField:{type:String,default:"title"},selectShowField:{type:String,default:""},keyField:{type:String,default:"id"},childStr:{type:String,default:"children"},replenishSelect:{type:Boolean,default:!1},disabledFn:{type:Function},separator:{type:String,default:","},checkable:{type:Boolean,default:!1},selectable:{type:Boolean,default:!1},filteredNodeCheckable:{type:Boolean,default:!1},cascade:{type:Boolean,default:!0},cascadeLoose:{type:Boolean,default:!1},enableLeafOnly:{type:Boolean,default:!1},disableAll:{type:Boolean,default:!1},defaultExpandAll:{type:Boolean,default:!1},defaultExpandedKeys:{type:Array,default:function(){return[]}},expandedKeys:{type:Array,default:function(){return[]}},draggable:{type:Boolean,default:!1},droppable:{type:Boolean,default:!1},beforeDropMethod:{type:Function,default:function(){return function(){return!0}}},allowDrag:{type:Function,default:function(){return function(){return!0}}},ignoreMode:{type:String,default:h.none},autoLoad:{type:Boolean,default:!0},load:Function,render:Function,filterMethod:Function,expandOnFilter:{type:Boolean,default:!0},unselectOnClick:{type:Boolean,default:!0},loading:{type:Boolean,default:!1},nodeMinHeight:{type:Number,default:30},nodeIndent:{type:Number,default:20},renderNodeAmount:{type:Number,default:55},bufferNodeAmount:{type:Number,default:20},nodeClassName:{type:[String,Object,Array,Function]},usePadding:{type:Boolean,default:!1},itemSize:{type:Number,default:34}},data:function(){var e=Array.isArray(this.value)?this.value.concat():this.value;return{unloadCheckedNodes:[],blockLength:0,blockAreaHeight:0,topSpaceHeight:0,bottomSpaceHeight:0,renderAmount:0,renderAmountCache:0,renderNodes:[],renderStart:0,renderStartCache:0,isRootLoading:!1,valueCache:e,debounceTimer:void 0}},computed:{topSpaceStyles:function(){return{height:"".concat(this.topSpaceHeight,"px")}},bottomSpaceStyles:function(){return{height:"".concat(this.bottomSpaceHeight,"px")}},wrapperCls:function(){return["".concat(J,"__wrapper")]},scrollAreaCls:function(){return["".concat(J,"__scroll-area")]},blockAreaCls:function(){return["".concat(J,"__block-area")]},emptyCls:function(){return["".concat(J,"__empty")]},emptyTextDefaultCls:function(){return["".concat(J,"__empty-text_default")]},loadingCls:function(){return["".concat(J,"__loading")]},loadingWrapperCls:function(){return["".concat(J,"__loading-wrapper")]},loadingIconCls:function(){return["".concat(J,"__loading-icon")]},iframeCls:function(){return["".concat(J,"__iframe")]},treeNodeListeners:function(){var e={};for(var t in this.$listeners)-1===G.indexOf(t)&&-1===Q.indexOf(t)&&(e[t]=this.$listeners[t]);return e}},methods:{setData:function(e){this.resetSpaceHeights();var t=null,n=null;this.checkable?Array.isArray(this.value)?t=this.value.concat():"string"===typeof this.value&&(t=""===this.value?[]:this.value.split(this.separator)):this.selectable&&!Array.isArray(this.value)&&(n=this.value),this.nonReactive.store.setData(e,n,t,this.childStr,this.disabledFn,this.replenishSelect),this.updateExpandedKeys()},setChecked:function(e,t){this.nonReactive.store.setChecked(e,t)},setCheckedKeys:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];this.nonReactive.store.setCheckedKeys(e,t,n,i,a)},checkAll:function(){this.nonReactive.store.checkAll()},clearChecked:function(){this.nonReactive.store.clearChecked()},setSelected:function(e,t){this.nonReactive.store.setSelected(e,t)},clearSelected:function(){this.nonReactive.store.clearSelected()},setExpand:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.nonReactive.store.setExpand(e,t,n)},setExpandKeys:function(e,t){this.nonReactive.store.setExpandKeys(e,t)},setExpandAll:function(e){this.nonReactive.store.setExpandAll(e)},getCheckedNodes:function(e){return e=e||this.ignoreMode,this.nonReactive.store.getCheckedNodes(e)},getCheckedKeys:function(e){return e=e||this.ignoreMode,this.nonReactive.store.getCheckedKeys(e)},getIndeterminateNodes:function(){return this.nonReactive.store.getIndeterminateNodes()},getSelectedNode:function(){return this.nonReactive.store.getSelectedNode()},getSelectedKey:function(){return this.nonReactive.store.getSelectedKey()},getExpandNodes:function(){return this.nonReactive.store.getExpandNodes()},getExpandKeys:function(){return this.nonReactive.store.getExpandKeys()},getCurrentVisibleNodes:function(){return this.nonReactive.store.flatData.filter((function(e){return e._filterVisible}))},getNode:function(e){return this.nonReactive.store.getNode(e)},getTreeData:function(){return this.nonReactive.store.data},getFlatData:function(){return this.nonReactive.store.flatData},getNodesCount:function(){return this.nonReactive.store.flatData.length},insertBefore:function(e,t){return this.nonReactive.store.insertBefore(e,t)},insertAfter:function(e,t){return this.nonReactive.store.insertAfter(e,t)},append:function(e,t){return this.nonReactive.store.append(e,t)},prepend:function(e,t){return this.nonReactive.store.prepend(e,t)},remove:function(e){return this.nonReactive.store.remove(e)},filter:function(e,t){var n=this,i=function(e,t){var i=t[n.titleField];return!(null==i||!i.toString)&&i.toString().toLowerCase().indexOf(e.toLowerCase())>-1};t=t||this.filterMethod||i,this.nonReactive.store.filter(e,t)},showCheckedNodes:function(e){var t=this;if(this.checkable){e=null==e?this.showUnloadCheckedNodes:e;var n=this.nonReactive.store.getCheckedNodes();if(this.nonReactive.store.filter("",(function(e,t){return t.checked})),e){var i=this.nonReactive.store.getUnloadCheckedKeys();if(i.length){var a,r=i.map((function(e){var i,a=t.unloadDataList.concat(n),r=e,s="";return a.some((function(n){return n[t.keyField]===e&&null!=n[t.titleField]&&(r=n[t.titleField],t.selectShowField&&(s=n[t.selectShowField]),!0)})),new p((i={},Y(i,t.keyField,e),Y(i,t.titleField,r),Y(i,t.selectShowField,s),Y(i,"checked",!0),Y(i,"isLeaf",!0),i),null,t.keyField,!!t.load,t.childStr,t.disabledFn)}));this.unloadCheckedNodes=r,(a=this.nonReactive.blockNodes).push.apply(a,U(r)),this.updateBlockData(),this.updateRender()}}}},loadRootNodes:function(){var e=this;return this.isRootLoading=!0,new Promise((function(t,n){e.load(null,t,n)})).then((function(t){Array.isArray(t)&&e.setData(t)})).catch((function(){})).then((function(){e.isRootLoading=!1}))},scrollTo:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:g.top,n=this.nonReactive.store.mapData[e];if(n&&n.visible){for(var i=-1,a=0;a<this.blockLength;a++)if(this.nonReactive.blockNodes[a][this.keyField]===e){i=a;break}if(-1!==i){var r=i*this.nodeMinHeight;if(t===g.center){var s=this.$refs.scrollArea.clientHeight;r-=(s-this.nodeMinHeight)/2}else if(t===g.bottom){var o=this.$refs.scrollArea.clientHeight;r-=o-this.nodeMinHeight}else"number"===typeof t&&(r-=t);this.$refs.scrollArea.scrollTop=r}}},updateExpandedKeys:function(){this.expandedKeys.length&&(this.nonReactive.store.setExpandAll(!1,!1),this.nonReactive.store.setExpandKeys(this.expandedKeys,!0))},updateUnloadStatus:function(){var e=this;if(this.unloadCheckedNodes.length){var t=this.nonReactive.store.getUnloadCheckedKeys();this.unloadCheckedNodes.forEach((function(n){n.checked=t.indexOf(n[e.keyField])>-1}))}},handleNodeCheck:function(e){(this.cascade||!this.enableLeafOnly||e.isLeaf)&&this.nonReactive.store.setChecked(e[this.keyField],!e.indeterminate&&!e.checked,!0,!0,!0,!0)},handleNodeSelect:function(e){this.enableLeafOnly&&!e.isLeaf||this.nonReactive.store.setSelected(e[this.keyField],!e.selected)},handleNodeExpand:function(e){this.nonReactive.store.setExpand(e[this.keyField],!e.expand)},handleNodeDrop:function(e,t,n){if(this.droppable&&t.dataTransfer)try{var i=JSON.parse(t.dataTransfer.getData("node")),a=i[this.keyField],r=e[this.keyField],s=this.beforeDropMethod(a,r,n);if(s){if(a===r)return;n===y.before?this.nonReactive.store.insertBefore(a,r):n===y.body||!e.isLeaf&&e.expand?this.nonReactive.store.prepend(a,r):n===y.after&&this.nonReactive.store.insertAfter(a,r),this.$emit("node-drop",e,t,n,this.getNode(a))}}catch(o){throw new Error(o)}},emitCheckableInput:function(e,t){if(this.checkable){var n=t;Array.isArray(this.value)||(n=n.join(this.separator)),Array.isArray(n)?this.valueCache=n.concat():this.valueCache=n,this.$emit("input",n)}},emitSelectableInput:function(e,t){if(this.selectable&&!this.checkable){var n=t||0===t?t:"";this.valueCache=n,this.$emit("input",n)}},attachStoreEvents:function(){for(var e in this.$listeners)if(G.indexOf(e)>-1){var t=e;this.nonReactive.store.on(t,this.$listeners[e])}},resetSpaceHeights:function(){this.topSpaceHeight=0,this.bottomSpaceHeight=0,this.$refs.scrollArea.scrollTop=0},updateBlockNodes:function(){this.nonReactive.blockNodes=this.nonReactive.store.flatData.filter((function(e){return e.visible})),this.updateBlockData(),this.updateRender()},updateBlockData:function(){this.blockLength=this.nonReactive.blockNodes.length,this.blockAreaHeight=this.nodeMinHeight*this.blockLength},updateRender:function(){this.updateRenderAmount(),this.updateRenderNodes()},updateRenderAmount:function(){var e=this.$refs.scrollArea.clientHeight;this.renderAmount=Math.max(this.renderNodeAmount,Math.ceil(e/this.nodeMinHeight)+this.bufferNodeAmount)},updateRenderNodes:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.blockLength>this.renderAmount){var t=this.$refs.scrollArea.scrollTop,n=Math.floor(t/this.nodeMinHeight);this.renderStart=Math.floor(n/this.bufferNodeAmount)*this.bufferNodeAmount}else this.renderStart=0;e&&this.renderAmountCache===this.renderAmount&&this.renderStartCache===this.renderStart||(this.renderNodes=this.nonReactive.blockNodes.slice(this.renderStart,this.renderStart+this.renderAmount).map((function(e){return Object.assign({},e,{_parent:null,children:[]})})),this.topSpaceHeight=this.renderStart*this.nodeMinHeight,this.bottomSpaceHeight=this.blockAreaHeight-(this.topSpaceHeight+this.renderNodes.length*this.nodeMinHeight))},handleTreeScroll:function(){this.debounceTimer&&window.cancelAnimationFrame(this.debounceTimer),this.renderAmountCache=this.renderAmount,this.renderStartCache=this.renderStart,this.debounceTimer=window.requestAnimationFrame(this.updateRenderNodes.bind(this,!0))},initializeNonReactiveData:function(){var e=this.keyField,t=this.ignoreMode,n=this.filteredNodeCheckable,i=this.cascade,a=this.cascadeLoose,r=this.defaultExpandAll,s=this.load,o=this.expandOnFilter;this.nonReactive={store:new K({keyField:e,ignoreMode:t,filteredNodeCheckable:n,cascade:i,cascadeLoose:a,defaultExpandAll:r,load:s,expandOnFilter:o}),blockNodes:[]}},defaultClassName:function(e){var t="";return e.isLeaf||e._loading||(t="isNode"),e._level||(t="firstLevelNode"),t}},created:function(){var e=this;this.initializeNonReactiveData(),this.nonReactive.store.on("visible-data-change",this.updateBlockNodes),this.nonReactive.store.on("render-data-change",this.updateRender),this.nonReactive.store.on("checked-change",(function(t,n){e.emitCheckableInput(t,n),e.updateUnloadStatus()})),this.nonReactive.store.on("selected-change",this.emitSelectableInput),this.attachStoreEvents()},mounted:function(){this.data.length?(this.setData(this.data),this.defaultExpandedKeys.length&&this.nonReactive.store.setExpandKeys(this.defaultExpandedKeys,!0)):"function"===typeof this.load&&this.autoLoad&&this.loadRootNodes();var e=this.$refs.iframe;e.contentWindow&&e.contentWindow.addEventListener("resize",this.updateRender)},beforeDestroy:function(){var e=this.$refs.iframe;e.contentWindow&&e.contentWindow.removeEventListener("resize",this.updateRender),this.initializeNonReactiveData(),this.nonReactive.store.off("visible-data-change"),this.nonReactive.store.off("render-data-change"),this.nonReactive.store.off("checked-change"),this.nonReactive.store.off("selected-change")},watch:{value:function(e){if(this.checkable){if(Z(e,this.valueCache))return;var t=[];Array.isArray(e)?t=e.concat():"string"===typeof e&&(t=""===e?[]:e.split(this.separator)),this.nonReactive.store.clearChecked(!1,!1),this.nonReactive.store.setCheckedKeys(t,!0,this.replenishSelect)}else if(this.selectable){if(e===this.valueCache)return;var n=this.nonReactive.store.getSelectedKey();""!==e&&null!=e?this.nonReactive.store.setSelected(e,!0):""!==e&&null!=e||!n||this.nonReactive.store.setSelected(n,!1)}},data:{deep:!0,handler:function(e){this.setData(e)}},expandedKeys:function(){this.updateExpandedKeys()},$listeners:function(){this.attachStoreEvents()}}}),te=ee,ne=L(te,a,r,!1,null,null,null),ie=ne.exports,ae=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{class:e.wrapperCls},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.isShowSearch,expression:"isShowSearch"}],class:e.searchCls},[n("div",{class:e.inputWrapperCls},[e._t("search-input",[n("input",{directives:[{name:"model",rawName:"v-model",value:e.keyword,expression:"keyword"}],class:e.inputCls,attrs:{type:"text",placeholder:e.searchPlaceholder,disabled:e.searchDisabled},domProps:{value:e.keyword},on:{input:[function(t){t.target.composing||(e.keyword=t.target.value)},e.handleSearch]}})])],2),n("div",{class:e.actionWrapperCls},[e.showCheckedButton&&e.checkable?n("span",{class:e.checkedButtonCls,on:{click:e.handleShowChecked}},[e._v("\n "+e._s(e.checkedButtonText)+"\n ")]):e._e(),e._t("actions")],2)]),n("div",{class:e.treeWrapperCls},[e.showCheckAll&&e.checkable?n("div",{staticClass:"search-tree-all-check"},[n("div",{class:e.checkAllWrapperCls},[n("div",{class:e.checkboxCls,on:{click:e.handleCheckAll}})]),n("span",{staticClass:"select-all-info"},[e._v(e._s(e.diyText.selectAll))])]):e._e(),n("CTree",e._g(e._b({ref:"tree",class:{noChild:e.checkable&&!e.isTree},attrs:{value:e.value,childStr:e.childStr,replenishSelect:e.replenishSelect,itemSize:e.itemSize,separator:e.separator},on:{input:e.updateCheckedCount,"set-data":e.handleSetData,"checked-change":e.updateCheckAllStatus},scopedSlots:e._u([e._l(e.$scopedSlots,(function(t,n){return{key:n,fn:function(t){return[e._t(n,null,null,t)]}}}))],null,!0)},"CTree",e.$attrs,!1),e.$listeners))],1),e.showFooter&&e.checkable?n("div",{class:e.footerCls},[e._t("footer",[n("span",{staticStyle:{float:"right"}},[e._v(e._s(e.diyText.selected)+" "),n("span",{staticClass:"num"},[e._v(e._s(e.checkedCount)+" ")]),e._v(e._s(e.diyText.num))])])],2):e._e()])},re=[];function se(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function oe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?se(n,!0).forEach((function(t){le(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):se(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function le(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ce="ctree-tree-search",de="ctree-tree-node",he={},ue=ie.options.methods,fe=function(e){var t=e;if(k.indexOf(t)>-1){var n=he;n[t]=function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return ue[t].apply(this.$refs.tree,n)}}};for(var pe in ue)fe(pe);var ve=o.a.extend({name:"CTreeSearch",inheritAttrs:!1,components:{CTree:ie},props:{value:{},searchPlaceholder:{type:String,default:"搜索关键字"},diyText:{type:Object,default:function(){return{selectAll:"全选",selected:"已选",num:"个"}}},isTree:{type:Boolean,default:!0},showCheckAll:{type:Boolean,default:!0},isShowSearch:{type:Boolean,default:!0},showCheckedButton:{type:Boolean,default:!0},replenishSelect:{type:Boolean,default:!0},checkedButtonText:{type:String,default:"已选"},showFooter:{type:Boolean,default:!0},searchMethod:Function,searchLength:{type:Number,default:1},searchDisabled:{type:Boolean,default:!1},searchRemote:{type:Boolean,default:!1},childStr:{type:String,default:"children"},separator:{type:String,default:","},searchDebounceTime:{type:Number,default:300},itemSize:{type:Number,default:34}},data:function(){return{checkAllStatus:{checked:!1,indeterminate:!1,disabled:!1},isShowingChecked:!1,keyword:"",debounceTimer:void 0,checkedCount:0}},computed:{wrapperCls:function(){return["".concat(ce,"__wrapper")]},searchCls:function(){return["".concat(ce,"__search")]},checkAllWrapperCls:function(){return["".concat(ce,"__check-all-wrapper")]},checkboxCls:function(){var e;return["".concat(ce,"__check-all"),"".concat(de,"__checkbox"),(e={},le(e,"".concat(de,"__checkbox_checked"),this.checkAllStatus.checked),le(e,"".concat(de,"__checkbox_indeterminate"),this.checkAllStatus.indeterminate),le(e,"".concat(de,"__checkbox_disabled"),this.searchDisabled||this.checkAllStatus.disabled),e)]},inputWrapperCls:function(){return["".concat(ce,"__input-wrapper")]},inputCls:function(){return["".concat(ce,"__input"),le({},"".concat(ce,"__input_disabled"),this.searchDisabled)]},actionWrapperCls:function(){return["".concat(ce,"__action-wrapper"),le({},"".concat(ce,"__action-wrapper-noBtn"),!this.showCheckedButton||!this.checkable)]},checkedButtonCls:function(){return["".concat(ce,"__checked-button"),le({},"".concat(ce,"__checked-button_active"),this.isShowingChecked)]},treeWrapperCls:function(){return["".concat(ce,"__tree-wrapper"),le({},"".concat(ce,"__tree-wrapper-checkAll"),this.showCheckAll)]},footerCls:function(){return["".concat(ce,"__footer")]},checkable:function(){return"checkable"in this.$attrs&&!1!==this.$attrs.checkable}},methods:oe({},he,{clearKeyword:function(){this.keyword=""},getKeyword:function(){return this.keyword},search:function(e){var t=this,n=e;return"string"!==typeof e&&(n=this.keyword),new Promise((function(e,i){clearTimeout(t.debounceTimer),t.debounceTimer=setTimeout((function(){if(!(n.length>0&&n.length<t.searchLength))if(t.isShowingChecked=!1,t.$emit("search",n),"function"===typeof t.searchMethod){var i=t.searchMethod(n);Promise.resolve(i).then((function(){t.updateCheckAllStatus(),e()}))}else t.searchRemote?t.$refs.tree.loadRootNodes().then((function(){t.updateCheckAllStatus(),e()})):(t.$refs.tree.filter(n),t.updateCheckAllStatus(),e())}),t.searchDebounceTime)}))},handleCheckAll:function(){var e=this;if(!this.searchDisabled&&!this.checkAllStatus.disabled){var t=this.$refs.tree.getCurrentVisibleNodes().map((function(t){return t[e.$refs.tree.keyField]}));this.checkAllStatus.checked||this.checkAllStatus.indeterminate?this.$refs.tree.setCheckedKeys(t,!1,!0,!0,!0):this.$refs.tree.setCheckedKeys(t,!0,!0,!0,!0),this.updateCheckAllStatus()}},handleSearch:function(){this.search()},handleShowChecked:function(){var e=this,t=function(){e.isShowingChecked=!e.isShowingChecked,e.isShowingChecked?e.$refs.tree.showCheckedNodes():e.$refs.tree.filter(e.keyword,(function(){return!0})),e.updateCheckAllStatus()};this.keyword?(this.clearKeyword(),this.search().then((function(){t()}))):t()},handleSetData:function(){this.updateCheckedCount(),this.updateCheckAllStatus()},updateCheckAllStatus:function(){for(var e=this.$refs.tree.getCurrentVisibleNodes(),t=e.length,n=!1,i=!1,a=!1,r=0;r<t;r++){var s=e[r];if(s.checked&&!s.disabled?n=!0:i=!0,n&&i||s.indeterminate){a=!0,this.checkAllStatus.checked=!1,this.checkAllStatus.indeterminate=!0;br