UNPKG

ctree-virtualtree

Version:

A vue tree component using virtual list.fork from @wsfe/ctree

1 lines 54.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 r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.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 r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));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")}({"8bbf":function(t,n){t.exports=e},a4b1:function(e,t,n){},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 r=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,i){return n("CTreeNode",e._g(e._b({key:t[e.keyField],class:"function"===typeof e.nodeClassName?e.nodeClassName(t):e.nodeClassName,style:{minHeight:e.nodeMinHeight+"px",marginLeft:e.usePadding?null:t._level*e.nodeIndent+"px",paddingLeft:e.usePadding?t._level*e.nodeIndent+"px":null},attrs:{data:t},on:{check:e.handleNodeCheck,select:e.handleNodeSelect,expand:e.handleNodeExpand,"node-drop":e.handleNodeDrop}},"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})])},a=[],o=n("8bbf"),s=n.n(o);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=["_level","_filterVisible","_parent","_loading","_loaded","_remote","_keyField","children","setChildren"],f=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",r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];for(var a in l(this,e),this._keyField=i,this._remote=r,this._level=0,this.checked=!1,this.selected=!1,this.indeterminate=!1,this.disabled=!1,this.expand=!1,this.visible=!0,this._filterVisible=!0,this._parent=null,this.children=[],this.isLeaf=!1,this._loading=!1,this._loaded=!1,t)-1===u.indexOf(a)&&(this[a]=t[a]);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.children)&&this.setChildren(t.children),this.children.length&&(this._loaded=!0),this._remote||(this.isLeaf=!this.children.length)}return d(e,[{key:"setChildren",value:function(t){var n=this;this.children=t.map((function(t){return new e(Object.assign({},t),n,n._keyField,n._remote)}))}}]),e}();(function(e){e["none"]="none",e["parents"]="parents",e["children"]="children"})(h||(h={}));var p,v,g,y=["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"],k=["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 m(e){return S(e)||_(e)||C()}function C(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function S(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 w(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function x(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&&x(e.prototype,t),n&&x(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"})(p||(p={})),function(e){e["top"]="top",e["center"]="center",e["bottom"]="bottom"}(v||(v={})),function(e){e["before"]="before",e["body"]="body",e["after"]="after"}(g||(g={}));var N=function(){function e(t){w(this,e),this.options=t,this.data=[],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;for(var r in this.data=e.map((function(e){return new f(e,null,t.options.keyField,!!t.options.load)})),this.mapData)delete this.mapData[r];this.currentSelectedKey=null,this.flatData=this.flattenData(this.data),this.setUnloadCheckedKeys(i||[]),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],r=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=this.mapData[e];if(!a)return this.setUnloadChecked(e,t,n,i);a.disabled||a.checked&&t||(a.checked||a.indeterminate||t)&&(this.options.cascade?(this.checkNodeDownward(a,t,r),this.checkNodeUpward(a)):a.checked=t,n&&(a.checked?this.emit("check",a):this.emit("uncheck",a)),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],r=this.findIndex(e,this.unloadCheckedKeys);t?-1===r&&this.unloadCheckedKeys.push(e):-1!==r&&this.unloadCheckedKeys.splice(r,1),this.triggerCheckedChange(n,i)}},{key:"setCheckedKeys",value:function(e,t){var n=this,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];e.forEach((function(e){n.setChecked(e,t,!1,!1)})),this.triggerCheckedChange(i,r)}},{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 r=this.flatData.length,a=0;a<r;a++){var o=this.flatData[a];this.setChecked(o[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],r=this.mapData[e];if(!r)return this.setUnloadSelected(e,t,n,i);r.disabled||r.selected!==t&&(e===this.currentSelectedKey?t||(r.selected=t,this.currentSelectedKey=null):t&&(null===this.currentSelectedKey?(r.selected=t,this.currentSelectedKey=r[this.options.keyField]):(this.mapData[this.currentSelectedKey]&&(this.mapData[this.currentSelectedKey].selected=!1),r.selected=t,this.currentSelectedKey=r[this.options.keyField])),n&&(r.selected?this.emit("select",r):this.emit("unselect",r),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],r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=this.mapData[e];if(o&&(i||!o.isLeaf)&&o.expand!==t){if(!o.isLeaf){if("function"===typeof this.options.load){if(!o._loaded&&!o._loading&&t)return o._loading=!0,a&&this.emit("visible-data-change"),void new Promise((function(e,t){var i=n.options.load;i(o,e,t)})).then((function(e){if(Array.isArray(e)){var i,r=n.findIndex(o);if(-1===r)return;o._loaded=!0,o.expand=t,o.setChildren(e);var a=n.getCheckedKeys(),s=n.flattenData(o.children,null===n.getSelectedKey);(i=n.flatData).splice.apply(i,[r+1,0].concat(m(s))),n.setUnloadCheckedKeys(a),null!==n.unloadSelectedKey&&n.setUnloadSelectedKey(n.unloadSelectedKey),n.emit("set-data")}})).catch((function(e){var t=e;e instanceof Error||(t=new Error(e)),console.error(t)})).then((function(){o._loading=!1,r&&n.emit("expand",o),a&&n.emit("visible-data-change")}));if(o._loading)return}o.expand=t;var s=m(o.children);while(s.length)s[0].expand&&s[0].children.length&&s.push.apply(s,m(s[0].children)),!1===s[0]._filterVisible?s[0].visible=!1:s[0].visible=null===s[0]._parent||s[0]._parent.expand&&s[0]._parent.visible,s.shift();r&&this.emit("expand",o),a&&this.emit("visible-data-change")}i&&o._parent&&t&&this.setExpand(o._parent[this.options.keyField],t,i,!1,a)}}},{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,!1,!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=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.ignoreMode;if(e===h.children){var t=[],n=function e(n){n.forEach((function(n){n.checked?t.push(n):!n.isLeaf&&n.indeterminate&&e(n.children)}))};return n(this.data),t}return this.flatData.filter((function(t){return e===h.parents?t.checked&&t.isLeaf:t.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 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],r=i._parent,a=this.findIndex(t,r&&r.children),o=this.findIndex(t),s=r?-1:this.findIndex(t,this.data);return this.insertIntoStore(n,r,a,o,s),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],r=i._parent,a=this.findIndex(t,r&&r.children)+1,o=this.flatData.length,s=this.findIndex(t),l=s+1,c=s+1;c<=o;c++){if(c===o){l=c;break}if(this.flatData[c]._level<=i._level){l=c;break}}var d=r?-1:this.findIndex(t,this.data)+1;return this.insertIntoStore(n,r,a,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 r=this.getInsertedNode(e,t,!0);if(!r)return null;this.remove(r[this.options.keyField],!1);var a=this.findIndex(t)+1;return this.insertIntoStore(r,n,0,a),this.emit("visible-data-change"),r}},{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 r=this.findIndex(t)+1;return this.insertIntoStore(i,n,0,r),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 r=this.findIndex(i);if(-1===r)return null;for(var a=1,o=this.flatData.length,s=r+1;s<o;s++){if(!(this.flatData[s]._level>i._level))break;a++}this.flatData.splice(r,a);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 r=n?i:i._parent;if(e instanceof f)return e[this.options.keyField]===t?null:e;if("object"===b(e)){if(e[this.options.keyField]===t)return null;var a=this.mapData[e[this.options.keyField]];return a||new f(e,r,this.options.keyField,!!this.options.load)}return this.mapData[e]&&e!==t?this.mapData[e]:null}},{key:"insertIntoStore",value:function(e,t,n,i,r){var a;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,!1,!1,!1)):"number"===typeof r&&r>-1&&this.data.splice(r,0,e);var o=this.flattenData([e]);e._level=t?t._level+1:0,o.forEach((function(e){return e._level=e._parent?e._parent._level+1:0})),(a=this.flatData).splice.apply(a,[i,0].concat(m(o))),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,!1,!1,!1)})),e.visible=null===e._parent||e._parent.expand&&e._parent.visible})),this.emit("visible-data-change")}},{key:"setUnloadCheckedKeys",value:function(e){this.unloadCheckedKeys=e;for(var t=e.concat(),n=this.unloadCheckedKeys.length,i=n-1;i>=0;i--){var r=this.unloadCheckedKeys[i];this.mapData[r]&&(this.setChecked(r,!0,!1,!1),this.unloadCheckedKeys.splice(i,1))}var a=this.getCheckedKeys();a.length===t.length&&a.every((function(e){return t.some((function(t){return t===e}))}))||this.emit("checked-change",this.getCheckedNodes(),a)}},{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,r=0;r<i;r++){var a=e[r],o=a[this.options.keyField];if(n.push(a),this.mapData[o])throw new Error("[CTree] Duplicate tree node key.");this.mapData[o]=a,a.checked&&this.options.cascade&&(this.checkNodeDownward(a,!0),this.checkNodeUpward(a)),a.selected&&t&&(this.clearSelected(!1,!1),this.currentSelectedKey=a[this.options.keyField],this.emit("selected-change",a,this.currentSelectedKey)),!this.options.defaultExpandAll&&!a.expand||this.options.load||a.isLeaf||(a.expand=!1,this.setExpand(a[this.options.keyField],!0,!1,!1,!1)),a.children.length&&this.flattenData(a.children,t,n)}return n}},{key:"checkNodeDownward",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e.children.forEach((function(e){n.checkNodeDownward(e,t,i)})),e.isLeaf||this.options.load&&!e.children.length){if(!e.disabled){if(i&&!this.options.filteredNodeCheckable&&!e._filterVisible)return;e.checked=t,e.indeterminate=!1}}else this.checkParentNode(e)}},{key:"checkNodeUpward",value:function(e){var t=e._parent;while(t)this.checkParentNode(t),t=t._parent}},{key:"checkParentNode",value:function(e){var t=e.children.length;if(t){for(var n=!1,i=!1,r=!1,a=0;a<t;a++){var o=e.children[a];if(o.checked?n=!0:i=!0,n&&i||o.indeterminate){r=!0,e.checked=!1,e.indeterminate=!0;break}}r||(e.checked=n,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 f?e[this.options.keyField]:e,i=t.length,r=0;r<i;r++)if(t[0]instanceof f){if(n===t[r][this.options.keyField])return r}else if(n===t[r])return r;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),r=1;r<n;r++)i[r-1]=arguments[r];for(var a=0;a<t;a++){var o;(o=this.listenersMap[e])[a].apply(o,i)}}}}]),e}(),A=N,K=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,attrs:{draggable:e.draggable&&!e.disableAll&&!e.data.disabled},on:{click:e.handleSelect,dblclick:e.handleDblclick,contextmenu:e.handleRightClick}},e.dragListeners),[e.renderFunction?n(e.renderComponent,{tag:"component"}):[e._v(e._s(e.data[e.titleField]))]],2)]),n("div",{class:e.dropAfterCls})])},R=[],E=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"}})])},O=[],F=s.a.extend({name:"CLoadingIcon"}),$=F;function T(e,t,n,i,r,a,o,s){var l,c="function"===typeof e?e.options:e;if(t&&(c.render=t,c.staticRenderFns=n,c._compiled=!0),i&&(c.functional=!0),a&&(c._scopeId="data-v-"+a),o?(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__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(o)},c._ssrRegister=l):r&&(l=s?function(){r.call(this,this.$root.$options.shadowRoot)}:r),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=T($,E,O,!1,null,null,null),P=B.exports;function L(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var I="ctree-tree-node",j=s.a.extend({name:"CTreeNode",inheritAttrs:!1,components:{LoadingIcon:P},props:{data:Object,titleField:String,keyField:String,render:Function,checkable:Boolean,selectable:Boolean,unselectOnClick:Boolean,disableAll:Boolean,draggable:Boolean,droppable:Boolean},data:function(){return{dragoverBody:!1,dragoverBefore:!1,dragoverAfter:!1}},computed:{wrapperCls:function(){return["".concat(I,"__wrapper"),L({},"".concat(I,"__wrapper_is-leaf"),this.data.isLeaf)]},nodeBodyCls:function(){return["".concat(I,"__node-body"),L({},"".concat(I,"__drop_active"),this.dragoverBody)]},dropBeforeCls:function(){return["".concat(I,"__drop"),L({},"".concat(I,"__drop_active"),this.dragoverBefore)]},dropAfterCls:function(){return["".concat(I,"__drop"),L({},"".concat(I,"__drop_active"),this.dragoverAfter)]},squareCls:function(){return["".concat(I,"__square")]},expandCls:function(){return["".concat(I,"__expand"),L({},"".concat(I,"__expand_active"),this.data.expand)]},loadingIconCls:function(){return["".concat(I,"__loading-icon")]},checkboxCls:function(){var e;return["".concat(I,"__checkbox"),(e={},L(e,"".concat(I,"__checkbox_checked"),this.data.checked),L(e,"".concat(I,"__checkbox_indeterminate"),this.data.indeterminate),L(e,"".concat(I,"__checkbox_disabled"),this.disableAll||this.data.disabled),e)]},titleCls:function(){var e;return["".concat(I,"__title"),(e={},L(e,"".concat(I,"__title_selected"),this.data.selected),L(e,"".concat(I,"__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 s.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||(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?g.before:i<=.7*n?g.body:g.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===g.before?this.dragoverBefore=!0:e===g.body?this.dragoverBody=!0:e===g.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)}}}),M=j,H=T(M,K,R,!1,null,null,null),V=H.exports;function U(e){return q(e)||X(e)||W()}function W(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function X(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function q(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 z="ctree-tree",J=["expand","select","unselect","selected-change","check","uncheck","checked-change","set-data"],G=["node-drop"],Q=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},Z=s.a.extend({name:"CTree",components:{CTreeNode:V,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"},keyField:{type:String,default:"id"},separator:{type:String,default:","},checkable:{type:Boolean,default:!1},selectable:{type:Boolean,default:!1},filteredNodeCheckable:{type:Boolean,default:!1},cascade:{type:Boolean,default:!0},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}}},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:100},bufferNodeAmount:{type:Number,default:20},nodeClassName:{type:[String,Object,Array,Function]},usePadding:{type:Boolean,default:!1}},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(z,"__wrapper")]},scrollAreaCls:function(){return["".concat(z,"__scroll-area")]},blockAreaCls:function(){return["".concat(z,"__block-area")]},emptyCls:function(){return["".concat(z,"__empty")]},emptyTextDefaultCls:function(){return["".concat(z,"__empty-text_default")]},loadingCls:function(){return["".concat(z,"__loading")]},loadingWrapperCls:function(){return["".concat(z,"__loading-wrapper")]},loadingIconCls:function(){return["".concat(z,"__loading-icon")]},iframeCls:function(){return["".concat(z,"__iframe")]},treeNodeListeners:function(){var e={};for(var t in this.$listeners)-1===J.indexOf(t)&&-1===G.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.updateExpandedKeys()},setChecked:function(e,t){this.nonReactive.store.setChecked(e,t)},setCheckedKeys:function(e,t){this.nonReactive.store.setCheckedKeys(e,t)},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 r,a=i.map((function(e){var i,r=t.unloadDataList.concat(n),a=e;return r.some((function(n){return n[t.keyField]===e&&null!=n[t.titleField]&&(a=n[t.titleField],!0)})),new f((i={},Y(i,t.keyField,e),Y(i,t.titleField,a),Y(i,"checked",!0),Y(i,"isLeaf",!0),i),null,t.keyField,!!t.load)}));this.unloadCheckedNodes=a,(r=this.nonReactive.blockNodes).push.apply(r,U(a)),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]:v.top,n=this.nonReactive.store.mapData[e];if(n&&n.visible){for(var i=-1,r=0;r<this.blockLength;r++)if(this.nonReactive.blockNodes[r][this.keyField]===e){i=r;break}if(-1!==i){var a=i*this.nodeMinHeight;if(t===v.center){var o=this.$refs.scrollArea.clientHeight;a-=(o-this.nodeMinHeight)/2}else if(t===v.bottom){var s=this.$refs.scrollArea.clientHeight;a-=s-this.nodeMinHeight}else"number"===typeof t&&(a-=t);this.$refs.scrollArea.scrollTop=a}}},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)},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")),r=i[this.keyField],a=e[this.keyField],o=this.beforeDropMethod(r,a,n);if(o){if(r===a)return;n===g.before?this.nonReactive.store.insertBefore(r,a):n===g.body||!e.isLeaf&&e.expand?this.nonReactive.store.prepend(r,a):n===g.after&&this.nonReactive.store.insertAfter(r,a),this.$emit("node-drop",e,t,n,this.getNode(r))}}catch(s){throw new Error(s)}},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||"";this.valueCache=n,this.$emit("input",n)}},attachStoreEvents:function(){for(var e in this.$listeners)if(J.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,r=this.defaultExpandAll,a=this.load,o=this.expandOnFilter;this.nonReactive={store:new A({keyField:e,ignoreMode:t,filteredNodeCheckable:n,cascade:i,defaultExpandAll:r,load:a,expandOnFilter:o}),blockNodes:[]}}},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()},watch:{value:function(e){if(this.checkable){if(Q(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)}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()}}}),ee=Z,te=T(ee,r,a,!1,null,null,null),ne=te.exports,ie=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{class:e.wrapperCls},[n("div",{class:e.searchCls},[e.showCheckAll&&e.checkable?n("div",{class:e.checkAllWrapperCls},[n("div",{class:e.checkboxCls,on:{click:e.handleCheckAll}})]):e._e(),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},[n("CTree",e._g(e._b({ref:"tree",attrs:{value:e.value},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.checkedCount)+" 个")])])],2):e._e()])},re=[];function ae(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?ae(n,!0).forEach((function(t){se(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ae(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function se(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var le="ctree-tree-search",ce="ctree-tree-node",de={},he=ne.options.methods,ue=function(e){var t=e;if(y.indexOf(t)>-1){var n=de;n[t]=function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return he[t].apply(this.$refs.tree,n)}}};for(var fe in he)ue(fe);var pe=s.a.extend({name:"CTreeSearch",inheritAttrs:!1,components:{CTree:ne},props:{value:{},searchPlaceholder:{type:String,default:"搜索关键字"},showCheckAll:{type:Boolean,default:!0},showCheckedButton:{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},searchDebounceTime:{type:Number,default:300}},data:function(){return{checkAllStatus:{checked:!1,indeterminate:!1,disabled:!1},isShowingChecked:!1,keyword:"",debounceTimer:void 0,checkedCount:0}},computed:{wrapperCls:function(){return["".concat(le,"__wrapper")]},searchCls:function(){return["".concat(le,"__search")]},checkAllWrapperCls:function(){return["".concat(le,"__check-all-wrapper")]},checkboxCls:function(){var e;return["".concat(le,"__check-all"),"".concat(ce,"__checkbox"),(e={},se(e,"".concat(ce,"__checkbox_checked"),this.checkAllStatus.checked),se(e,"".concat(ce,"__checkbox_indeterminate"),this.checkAllStatus.indeterminate),se(e,"".concat(ce,"__checkbox_disabled"),this.searchDisabled||this.checkAllStatus.disabled),e)]},inputWrapperCls:function(){return["".concat(le,"__input-wrapper")]},inputCls:function(){return["".concat(le,"__input"),se({},"".concat(le,"__input_disabled"),this.searchDisabled)]},actionWrapperCls:function(){return["".concat(le,"__action-wrapper")]},checkedButtonCls:function(){return["".concat(le,"__checked-button"),se({},"".concat(le,"__checked-button_active"),this.isShowingChecked)]},treeWrapperCls:function(){return["".concat(le,"__tree-wrapper")]},footerCls:function(){return["".concat(le,"__footer")]},checkable:function(){return"checkable"in this.$attrs&&!1!==this.$attrs.checkable}},methods:oe({},de,{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):this.$refs.tree.setCheckedKeys(t,!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,r=!1,a=0;a<t;a++){var o=e[a];if(o.checked?n=!0:i=!0,n&&i||o.indeterminate){r=!0,this.checkAllStatus.checked=!1,this.checkAllStatus.indeterminate=!0;break}}r||(this.checkAllStatus.checked=n,this.checkAllStatus.indeterminate=!1)},updateCheckedCount:function(){this.checkedCount=this.$refs.tree.getCheckedKeys().length}}),mounted:function(){this.checkable&&!this.checkedCount&&this.handleSetData()}}),ve=pe,ge=T(ve,ie,re,!1,null,null,null),ye=ge.exports,ke=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{class:e.wrapperCls},[n("div",{ref:"reference",class:e.referenceCls,on:{click:e.handleRefClick}},[e._t("default",[n("div",{class:e.displayInputCls},[n("span",{class:e.displayInputTextCls},[e._t("display",[e._v("\n "+e._s(e.displayValue)+"\n ")],null,e.slotProps)],2),e.dropDisabled?e._e():[n("i",{class:e.dropIconCls}),e.clearable&&e.showClearIcon?e._t("clear",[n("i",{class:e.clearIconCls,on:{click:function(t){return t.stopPropagation(),e.handleClear(t)}}})]):e._e()]],2)],null,e.slotProps)],2),n("transition",{attrs:{name:"ctree-dropdown"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.dropdownVisible,expression:"dropdownVisible"}],ref:"dropdown",class:e.dropdownCls,style:{height:e.dropHeight+"px"}},[n("CTreeSearch",e._g(e._b({ref:"treeSearch",attrs:{value:e.value},on:{"set-data":e.handleSetData,"checked-change":e.handleCheckedChange,"selected-change":e.handleSelectedChange},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)},"CTreeSearch",e.$attrs,!1),e.$listeners))],1)])],1)},be=[];function me(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 Ce(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?me(n,!0).forEach((function(t){De(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):me(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function _e(e){return xe(e)||we(e)||Se()}function Se(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function we(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function xe(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 De(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ne="ctree-tree-drop",Ae="ctree-tree-search",Ke={},Re=y.concat(k),Ee=ye.options.methods,Oe=function(e){var t=e;if(Re.indexOf(t)>-1){var n=Ke;n[t]=function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return Ee[t].apply(this.$refs.treeSearch,n)}}};for(var Fe in Ee)Oe(Fe);var $e=s.a.extend({name:"CTreeDrop",inheritAttrs:!1,components:{CTreeSearch:ye},props:{value:{},dropHeight:{type:Number,default:300},dropPlaceholder:{type:String},dropDisabled:{type:Boolean,default:!1},clearable:{type:Boolean,default:!1},placement:{type:String,default:p["bottom-start"]},transfer:{type:Boolean,default:!1},dropdownClassName:{type:[String,Array]},dropdownMinWidth:{type:Number},dropdownWidthFixed:{type:Boolean,default:!1}},data:function(){return{dropdownVisible:!1,checkedCount:0,selectedTitle:"",slotProps:{checkedNodes:[],checkedKeys:[],selectedNode:null,selectedKey:null}}},computed:{wrapperCls:function(){return["".concat(Ne,"__wrapper")]},referenceCls:function(){return["".concat(Ne,"__reference")]},displayInputCls:function(){var e;return["".concat(Ae,"__input"),"".concat(Ne,"__display-input"),(e={},De(e,"".concat(Ne,"__display-input_focus"),this.dropdownVisible),De(e,"".concat(Ae,"__input_disabled"),this.dropDisabled),e)]},displayInputTextCls:function(){var e=!1;return"string"===typeof this.dropPlaceholder&&(this.checkable?e=0===this.checkedCount:this.select