🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

wang-tree

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wang-tree - npm Package Compare versions

Comparing version
3.0.4
to
3.0.5
+1
-1
dist/wang-tree.umd.js

@@ -1,1 +0,1 @@

(function(F,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(F=typeof globalThis<"u"?globalThis:F||self,t(F.Vtree={},F.Vue))})(this,function(F,t){"use strict";var wt=Object.defineProperty;var Dt=(F,t,Q)=>t in F?wt(F,t,{enumerable:!0,configurable:!0,writable:!0,value:Q}):F[t]=Q;var E=(F,t,Q)=>(Dt(F,typeof t!="symbol"?t+"":t,Q),Q);const Q=["_level","_filterVisible","_parent","_loading","_loaded","_remote","_keyField","children","setChildren"];class W{constructor(l,n=null,a="id",s=!1){E(this,"_level",0);E(this,"checked",!1);E(this,"selected",!1);E(this,"indeterminate",!1);E(this,"disabled",!1);E(this,"expand",!1);E(this,"visible",!0);E(this,"_filterVisible",!0);E(this,"_parent",null);E(this,"children",[]);E(this,"isLeaf",!1);E(this,"_loading",!1);E(this,"_loaded",!1);this._keyField=a,this._remote=s;for(let i in l)Q.indexOf(i)===-1&&(this[i]=l[i]);this[a]==null&&(this[a]=Math.random().toString(36).substring(2)),this._parent=n,this._parent&&(this._level=this._parent._level+1),this.visible=this._parent===null||this._parent.expand&&this._parent.visible,Array.isArray(l.children)&&this.setChildren(l.children),this.children.length&&(this._loaded=!0),this._remote||(this.isLeaf=!this.children.length)}setChildren(l){this.children=l.map(n=>new W(Object.assign({},n),this,this._keyField,this._remote))}}var se=(e=>(e.none="none",e.parents="parents",e.children="children",e))(se||{});const nt=["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"];var Ne=(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",e))(Ne||{}),ie=(e=>(e.top="top",e.center="center",e.bottom="bottom",e))(ie||{}),P=(e=>(e.before="before",e.body="body",e.after="after",e))(P||{});const he=["expand","check","click","select","node-dblclick","node-right-click","node-dragstart","node-dragenter","node-dragover","node-dragleave","node-drop"];class we{constructor(l){E(this,"data",[]);E(this,"flatData",[]);E(this,"mapData",Object.create(null));E(this,"unloadCheckedKeys",[]);E(this,"unloadSelectedKey",null);E(this,"currentSelectedKey",null);E(this,"listenersMap",{});this.options=l}setData(l,n=null,a=null){this.data=l.map(s=>new W(s,null,this.options.keyField,!!this.options.load));for(let s in this.mapData)delete this.mapData[s];this.currentSelectedKey=null,this.flatData=this.flattenData(this.data),this.setUnloadCheckedKeys(a||[]),n&&(this.currentSelectedKey=null,this.setUnloadSelectedKey(n)),this.emit("visible-data-change"),this.emit("set-data")}setChecked(l,n,a=!0,s=!0,i=!1){const o=this.mapData[l];if(!o)return this.setUnloadChecked(l,n,a,s);o.disabled||o.checked&&n||!o.checked&&!o.indeterminate&&!n||(this.options.cascade?(this.checkNodeDownward(o,n,i),this.checkNodeUpward(o)):o.checked=n,a&&(o.checked?this.emit("check",o):this.emit("uncheck",o)),this.triggerCheckedChange(a,s))}setUnloadChecked(l,n,a=!0,s=!0){const i=this.findIndex(l,this.unloadCheckedKeys);n?i===-1&&this.unloadCheckedKeys.push(l):i!==-1&&this.unloadCheckedKeys.splice(i,1),this.triggerCheckedChange(a,s)}setCheckedKeys(l,n,a=!0,s=!0){l.forEach(i=>{this.setChecked(i,n,!1,!1)}),this.triggerCheckedChange(a,s)}checkAll(l=!0,n=!0){if(this.options.cascade){const a=s=>{s.forEach(i=>{i.disabled?a(i.children):this.setChecked(i[this.options.keyField],!0,!1,!1)})};a(this.data)}else{const a=this.flatData.length;for(let s=0;s<a;s++){const i=this.flatData[s];this.setChecked(i[this.options.keyField],!0,!1,!1)}}this.triggerCheckedChange(l,n)}clearChecked(l=!0,n=!0){this.getCheckedNodes().forEach(s=>{this.setChecked(s[this.options.keyField],!1,!1,!1)}),this.unloadCheckedKeys=[],this.triggerCheckedChange(l,n)}triggerCheckedChange(l=!0,n=!0){l&&this.emit("checked-change",this.getCheckedNodes(),this.getCheckedKeys()),n&&this.emit("render-data-change")}setSelected(l,n,a=!0,s=!0){const i=this.mapData[l];if(!i)return this.setUnloadSelected(l,n,a,s);i.disabled||i.selected!==n&&(l===this.currentSelectedKey?n||(i.selected=n,this.currentSelectedKey=null):n&&(this.currentSelectedKey===null?(i.selected=n,this.currentSelectedKey=i[this.options.keyField]):(this.mapData[this.currentSelectedKey]&&(this.mapData[this.currentSelectedKey].selected=!1),i.selected=n,this.currentSelectedKey=i[this.options.keyField])),a&&(i.selected?this.emit("select",i):this.emit("unselect",i),this.emit("selected-change",this.getSelectedNode(),this.getSelectedKey())),s&&this.emit("render-data-change"))}setUnloadSelected(l,n,a=!0,s=!0){n?(this.currentSelectedKey&&this.setSelected(this.currentSelectedKey,!1,!1,!1),this.unloadSelectedKey=l):this.unloadSelectedKey===l&&(this.unloadSelectedKey=null),a&&this.emit("selected-change",this.getSelectedNode(),this.getSelectedKey()),s&&this.emit("render-data-change")}clearSelected(l=!0,n=!0){this.currentSelectedKey&&this.mapData[this.currentSelectedKey]?this.setSelected(this.currentSelectedKey,!1,l,n):this.unloadSelectedKey!==null&&(this.unloadSelectedKey=null,l&&this.emit("selected-change",this.getSelectedNode(),this.getSelectedKey()),n&&this.emit("render-data-change"))}setExpand(l,n,a=!1,s=!0,i=!0){const o=this.mapData[l];if(!(!o||!a&&o.isLeaf)&&o.expand!==n){if(!o.isLeaf){if(typeof this.options.load=="function"){if(!o._loaded&&!o._loading&&n){o._loading=!0,i&&this.emit("visible-data-change"),new Promise((f,p)=>{const w=this.options.load;w(o,f,p)}).then(f=>{if(Array.isArray(f)){const p=this.findIndex(o);if(p===-1)return;o._loaded=!0,o.expand=n,o.setChildren(f);const w=this.getCheckedKeys(),b=this.flattenData(o.children,this.getSelectedKey===null);this.flatData.splice(p+1,0,...b),this.setUnloadCheckedKeys(w),this.unloadSelectedKey!==null&&this.setUnloadSelectedKey(this.unloadSelectedKey),this.emit("set-data")}}).catch(f=>{}).then(()=>{o._loading=!1,s&&this.emit("expand",o),i&&this.emit("visible-data-change")});return}else if(o._loading)return}o.expand=n;const d=[...o.children];for(;d.length;)d[0].expand&&d[0].children.length&&d.push(...d[0].children),d[0]._filterVisible===!1?d[0].visible=!1:d[0].visible=d[0]._parent===null||d[0]._parent.expand&&d[0]._parent.visible,d.shift();s&&this.emit("expand",o),i&&this.emit("visible-data-change")}a&&o._parent&&n&&this.setExpand(o._parent[this.options.keyField],n,a,!1,i)}}setExpandKeys(l,n,a=!0){l.forEach(s=>{this.setExpand(s,n,!1,!1,!1)}),a&&this.emit("visible-data-change")}setExpandAll(l,n=!0){this.flatData.forEach(a=>{(!this.options.load||a._loaded)&&this.setExpand(a[this.options.keyField],l,!1,!1,!1)}),n&&this.emit("visible-data-change")}getCheckedNodes(l=this.options.ignoreMode){if(l===se.children){const n=[],a=s=>{s.forEach(i=>{i.checked?n.push(i):!i.isLeaf&&i.indeterminate&&a(i.children)})};return a(this.data),n}else return this.flatData.filter(n=>l===se.parents?n.checked&&n.isLeaf:n.checked)}getCheckedKeys(l=this.options.ignoreMode){return this.getCheckedNodes(l).map(n=>n[this.options.keyField]).concat(this.unloadCheckedKeys)}getIndeterminateNodes(){return this.flatData.filter(l=>l.indeterminate)}getSelectedNode(){return this.currentSelectedKey===null?null:this.mapData[this.currentSelectedKey]||null}getSelectedKey(){return this.currentSelectedKey||this.unloadSelectedKey||null}getUnloadCheckedKeys(){return this.unloadCheckedKeys}getExpandNodes(){return this.flatData.filter(l=>!l.isLeaf&&l.expand)}getExpandKeys(){return this.getExpandNodes().map(l=>l[this.options.keyField])}getNode(l){return this.mapData[l]||null}insertBefore(l,n){const a=this.getInsertedNode(l,n);if(!a)return null;this.remove(a[this.options.keyField],!1);const i=this.mapData[n]._parent,o=this.findIndex(n,i&&i.children),d=this.findIndex(n),f=i&&-1||this.findIndex(n,this.data);return this.insertIntoStore(a,i,o,d,f),this.emit("visible-data-change"),a}insertAfter(l,n){const a=this.getInsertedNode(l,n);if(!a)return null;this.remove(a[this.options.keyField],!1);const s=this.mapData[n],i=s._parent,o=this.findIndex(n,i&&i.children)+1,d=this.flatData.length,f=this.findIndex(n);let p=f+1;for(let b=f+1;b<=d;b++){if(b===d){p=b;break}if(this.flatData[b]._level<=s._level){p=b;break}}const w=i&&-1||this.findIndex(n,this.data)+1;return this.insertIntoStore(a,i,o,p,w),this.emit("visible-data-change"),a}append(l,n){const a=this.mapData[n];if(!a.isLeaf){const o=a.children.length;return this.insertAfter(l,a.children[o-1][this.options.keyField])}const s=this.getInsertedNode(l,n,!0);if(!s)return null;this.remove(s[this.options.keyField],!1);const i=this.findIndex(n)+1;return this.insertIntoStore(s,a,0,i),this.emit("visible-data-change"),s}prepend(l,n){const a=this.mapData[n];if(!a.isLeaf)return this.insertBefore(l,a.children[0][this.options.keyField]);const s=this.getInsertedNode(l,n,!0);if(!s)return null;this.remove(s[this.options.keyField],!1);const i=this.findIndex(n)+1;return this.insertIntoStore(s,a,0,i),this.emit("visible-data-change"),s}remove(l,n=!0){const a=this.mapData[l];if(!a)return null;const s=this.findIndex(a);if(s===-1)return null;let i=1;const o=this.flatData.length;for(let f=s+1;f<o&&this.flatData[f]._level>a._level;f++)i++;this.flatData.splice(s,i);const d=f=>{const p=this.mapData[f];delete this.mapData[f],p.children.forEach(w=>d(w[this.options.keyField]))};if(d(l),!a._parent){const f=this.findIndex(a,this.data);f>-1&&this.data.splice(f,1)}if(a._parent){const f=this.findIndex(a,a._parent.children);f!==-1&&a._parent.children.splice(f,1),a._parent.isLeaf=!a._parent.children.length,a._parent.isLeaf&&(a._parent.expand=!1,a._parent.indeterminate=!1),this.updateMovingNodeStatus(a)}return n&&this.emit("visible-data-change"),a}getInsertedNode(l,n,a=!1){const s=this.mapData[n];if(!s)return null;const i=a?s:s._parent;if(l instanceof W)return l[this.options.keyField]===n?null:l;if(typeof l=="object"){if(l[this.options.keyField]===n)return null;const o=this.mapData[l[this.options.keyField]];return o||new W(l,i,this.options.keyField,!!this.options.load)}else return!this.mapData[l]||l===n?null:this.mapData[l]}insertIntoStore(l,n,a,s,i){if(s===-1)return;a!==-1&&n&&n.children.splice(a,0,l),l._parent=n,n?(n.isLeaf=!1,this.setExpand(n[this.options.keyField],!0,!1,!1,!1)):typeof i=="number"&&i>-1&&this.data.splice(i,0,l);const o=this.flattenData([l]);l._level=n?n._level+1:0,o.forEach(d=>d._level=d._parent?d._parent._level+1:0),this.flatData.splice(s,0,...o),this.updateMovingNodeStatus(l)}updateMovingNodeStatus(l){this.checkNodeUpward(l),this.triggerCheckedChange(),l.selected&&this.setSelected(l[this.options.keyField],!0)}filter(l,n){const a=[];this.flatData.forEach(s=>{s._filterVisible=s._parent&&s._parent._filterVisible||n(l,s),s.visible=s._filterVisible,s._filterVisible&&a.push(s)}),a.forEach(s=>{const i=[];let o=s._parent;for(;o;)i.unshift(o),o=o._parent;i.forEach(d=>{d._filterVisible=!0,d.visible=(d._parent===null||d._parent.expand&&d._parent.visible)&&d._filterVisible,this.options.expandOnFilter&&this.setExpand(d[this.options.keyField],!0,!1,!1,!1)}),s.visible=s._parent===null||s._parent.expand&&s._parent.visible}),this.emit("visible-data-change")}setUnloadCheckedKeys(l){this.unloadCheckedKeys=l;const n=l.concat(),a=this.unloadCheckedKeys.length;for(let i=a-1;i>=0;i--){const o=this.unloadCheckedKeys[i];this.mapData[o]&&(this.setChecked(o,!0,!1,!1),this.unloadCheckedKeys.splice(i,1))}const s=this.getCheckedKeys();s.length===n.length&&s.every(i=>n.some(o=>o===i))||this.emit("checked-change",this.getCheckedNodes(),s)}setUnloadSelectedKey(l){const n=this.getSelectedKey();this.mapData[l]?(this.setSelected(l,!0,!1),this.unloadSelectedKey=null):(this.currentSelectedKey&&this.setSelected(this.currentSelectedKey,!1,!1),this.unloadSelectedKey=l);const a=this.getSelectedKey();a!==n&&this.emit("selected-change",this.getSelectedNode(),a)}flattenData(l,n=!0,a=[]){const s=l.length;for(let i=0;i<s;i++){const o=l[i],d=o[this.options.keyField];if(a.push(o),this.mapData[d])throw new Error("[CTree] Duplicate tree node key.");this.mapData[d]=o,o.checked&&this.options.cascade&&(this.checkNodeDownward(o,!0),this.checkNodeUpward(o)),o.selected&&n&&(this.clearSelected(!1,!1),this.currentSelectedKey=o[this.options.keyField],this.emit("selected-change",o,this.currentSelectedKey)),(this.options.defaultExpandAll||o.expand)&&!this.options.load&&!o.isLeaf&&(o.expand=!1,this.setExpand(o[this.options.keyField],!0,!1,!1,!1)),o.children.length&&this.flattenData(o.children,n,a)}return a}checkNodeDownward(l,n,a=!1){if(l.children.forEach(s=>{this.checkNodeDownward(s,n,a)}),l.isLeaf||this.options.load&&!l.children.length){if(!l.disabled){if(a&&!this.options.filteredNodeCheckable&&!l._filterVisible)return;l.checked=n,l.indeterminate=!1}}else this.checkParentNode(l)}checkNodeUpward(l){let n=l._parent;for(;n;)this.checkParentNode(n),n=n._parent}checkParentNode(l){const n=l.children.length;if(!n)return;let a=!1,s=!1,i=!1;for(let o=0;o<n;o++){const d=l.children[o];if(d.checked?a=!0:s=!0,a&&s||d.indeterminate){i=!0,l.checked=!1,l.indeterminate=!0;break}}i||(l.checked=a,l.indeterminate=!1)}findIndex(l,n=this.flatData){if(n!==null){let a=l instanceof W?l[this.options.keyField]:l;const s=n.length;for(let i=0;i<s;i++)if(n[0]instanceof W){if(a===n[i][this.options.keyField])return i}else if(a===n[i])return i}return-1}on(l,n){this.listenersMap[l]||(this.listenersMap[l]=[]);let a=[];Array.isArray(n)?a=n:a=[n],a.forEach(s=>{this.listenersMap[l].indexOf(s)===-1&&this.listenersMap[l].push(s)})}off(l,n){if(this.listenersMap[l])if(!n)this.listenersMap[l]=[];else{const a=this.listenersMap[l].indexOf(n);a>-1&&this.listenersMap[l].splice(a,1)}}emit(l,...n){if(!this.listenersMap[l])return;const a=this.listenersMap[l].length;for(let s=0;s<a;s++)this.listenersMap[l][s](...n)}disposeListeners(){for(const l in this.listenersMap)this.listenersMap[l]=[]}}const at=t.defineComponent({name:"CLoadingIcon"}),ne=(e,l)=>{const n=e.__vccOpts||e;for(const[a,s]of l)n[a]=s;return n},st={viewBox:"0 0 50 50"},it=[t.createElementVNode("circle",{class:"ctree-loading-icon__circle",cx:"25",cy:"25",r:"20",fill:"none","stroke-width":"5","stroke-miterlimit":"10"},null,-1)];function rt(e,l,n,a,s,i){return t.openBlock(),t.createElementBlock("svg",st,it)}const De=ne(at,[["render",rt]]),K="ctree-tree-node",ot=t.defineComponent({name:"CTreeNode",components:{LoadingIcon:De},props:{data:Object,titleField:String,keyField:String,render:Function,checkable:Boolean,selectable:Boolean,unselectOnClick:Boolean,disableAll:Boolean,draggable:Boolean,droppable:Boolean,getNode:Function},emits:[...he],setup(e,{emit:l}){var D;const n=t.ref(!1),a=t.ref(!1),s=t.ref(!1),i=e.keyField,o=e.getNode,d=e.titleField,f=t.computed(()=>{var u,g,y;return[`${K}__wrapper`,{[`${K}__wrapper_is-leaf`]:(u=e.data)==null?void 0:u.isLeaf},{[`${K}__title_selected`]:(g=e.data)==null?void 0:g.selected,[`${K}__title_disabled`]:e.disableAll||((y=e.data)==null?void 0:y.disabled)}]}),p=t.computed(()=>[`${K}__node-body`,{[`${K}__drop_active`]:n.value}]),w=t.computed(()=>[`${K}__drop`,{[`${K}__drop_active`]:a.value}]),b=t.computed(()=>[`${K}__drop`,{[`${K}__drop_active`]:s.value}]),B=t.computed(()=>[`${K}__square`]),j=t.computed(()=>{var u;return[`${K}__expand`,{[`${K}__expand_active`]:(u=e.data)==null?void 0:u.expand}]}),X=t.computed(()=>[`${K}__loading-icon`]),R=t.computed(()=>{var u,g,y;return[`${K}__checkbox`,{[`${K}__checkbox_checked`]:(u=e.data)==null?void 0:u.checked,[`${K}__checkbox_indeterminate`]:(g=e.data)==null?void 0:g.indeterminate,[`${K}__checkbox_disabled`]:e.disableAll||((y=e.data)==null?void 0:y.disabled)}]}),x=t.computed(()=>[`${K}__title`]),S=t.computed(()=>o(e.data?e.data[i]:"")||e.data||{}),I=t.computed(()=>e.checkable),T=((D=e.data)==null?void 0:D.render)||e.render||null,Z=t.computed(()=>t.defineComponent({name:"Render",functional:!0,render(){return typeof T!="function"?t.h("div"):T(S.value)}})),v=t.computed(()=>{var g;let u={};return e.draggable&&!e.disableAll&&!((g=e.data)!=null&&g.disabled)&&(u={dragstart:A}),u}),Y=t.computed(()=>{let u={};return e.droppable&&(u={dragenter:h.bind(t.getCurrentInstance()),dragover:M.bind(t.getCurrentInstance()),dragleave:U.bind(t.getCurrentInstance()),drop:N.bind(t.getCurrentInstance())}),u});function O(){var u;(u=e.data)!=null&&u.isLeaf||l("expand",S.value)}function q(){var u;e.disableAll||(u=e.data)!=null&&u.disabled||!e.checkable||l("check",S.value)}function J(){var u,g;if(l("click",S.value),e.selectable){if(e.disableAll||(u=e.data)!=null&&u.disabled||(g=e.data)!=null&&g.selected&&!e.unselectOnClick)return;l("select",S.value),O()}else e.checkable?q():O()}function ee(){l("node-dblclick",S.value)}function te(){l("node-right-click",S.value)}const G=t.ref();function m(u){const g=G.value.getBoundingClientRect(),y=g.height,_=u.clientY-g.top;return _<=y*.3?P.before:_<=y*(.3+.4)?P.body:P.after}function k(u,g=!1){a.value=!1,n.value=!1,s.value=!1,g||(u===P.before?a.value=!0:u===P.body?n.value=!0:u===P.after&&(s.value=!0))}function A(u){var g;u.dataTransfer&&u.dataTransfer.setData("node",JSON.stringify(e.data)),(g=e.data)!=null&&g.expand&&O(),l("node-dragstart",S.value,u)}function h(u){u.preventDefault();const g=m(u);k(g),l("node-dragenter",S.value,u,g)}function M(u){u.preventDefault();const g=m(u);k(g),l("node-dragover",S.value,u,g)}function U(u){const g=m(u);k(g,!0),l("node-dragleave",S.value,u,g)}function N(u){const g=m(u);k(g,!0),l("node-drop",S.value,u,g)}return{dragoverBody:n,dragoverBefore:a,dragoverAfter:s,wrapperCls:f,nodeBodyCls:p,dropBeforeCls:w,dropAfterCls:b,squareCls:B,expandCls:j,loadingIconCls:X,checkboxCls:R,titleCls:x,fullData:S,showCheckbox:I,renderFunction:T,renderComponent:Z,dragListeners:v,dropListeners:Y,titleField:d,handleExpand:O,handleCheck:q,handleSelect:J,handleDblclick:ee,handleRightClick:te,nodeBody:G}}}),dt=["draggable"];function ct(e,l,n,a,s,i){var d,f,p,w;const o=t.resolveComponent("LoadingIcon");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.wrapperCls)},[t.createElementVNode("div",{class:t.normalizeClass(e.dropBeforeCls)},null,2),t.createElementVNode("div",t.mergeProps({ref:"nodeBody",class:e.nodeBodyCls},t.toHandlers(e.dropListeners,!0)),[t.createElementVNode("div",{class:t.normalizeClass(e.squareCls)},[t.withDirectives(t.createElementVNode("i",{class:t.normalizeClass(e.expandCls),onClick:l[0]||(l[0]=(...b)=>e.handleExpand&&e.handleExpand(...b))},null,2),[[t.vShow,!((d=e.data)!=null&&d.isLeaf)&&!((f=e.data)!=null&&f._loading)]]),(p=e.data)!=null&&p._loading?(t.openBlock(),t.createBlock(o,{key:0,class:t.normalizeClass(e.loadingIconCls)},null,8,["class"])):t.createCommentVNode("",!0)],2),e.showCheckbox?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(e.squareCls)},[t.createElementVNode("div",{class:t.normalizeClass(e.checkboxCls),onClick:l[1]||(l[1]=(...b)=>e.handleCheck&&e.handleCheck(...b))},null,2)],2)):t.createCommentVNode("",!0),t.createElementVNode("div",t.mergeProps({class:e.titleCls,onClick:l[2]||(l[2]=(...b)=>e.handleSelect&&e.handleSelect(...b)),onDblclick:l[3]||(l[3]=(...b)=>e.handleDblclick&&e.handleDblclick(...b)),onContextmenu:l[4]||(l[4]=(...b)=>e.handleRightClick&&e.handleRightClick(...b))},t.toHandlers(e.dragListeners,!0),{draggable:e.draggable&&!e.disableAll&&!((w=e.data)!=null&&w.disabled)}),[e.renderFunction?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.renderComponent),{key:0})):t.renderSlot(e.$slots,"node-item-final",{key:1},()=>[t.createTextVNode(t.toDisplayString(e.data?e.data[e.titleField]:""),1)])],16,dt)],16),t.createElementVNode("div",{class:t.normalizeClass(e.dropAfterCls)},null,2)],2)}const _e=ne(ot,[["render",ct]]),$e=["expand","select","unselect","selected-change","check","uncheck","checked-change","set-data"],ht=["node-drop","check","select","expand"],ft=t.defineComponent({name:"CTree",components:{CTreeNode:_e,LoadingIcon:De},emits:["update:modelValue",...he,...$e],props:{modelValue:[String,Number,Array],data:{type:Array,default:()=>[]},unloadDataList:{type:Array,default:()=>[]},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:()=>[]},expandedKeys:{type:Array,default:()=>[]},draggable:{type:Boolean,default:!1},droppable:{type:Boolean,default:!1},beforeDropMethod:{type:Function,default:()=>()=>!0},ignoreMode:{type:String,default:se.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}},setup(e,l){const n="ctree-tree",a=(r,c)=>{if(Array.isArray(r)&&Array.isArray(c)){if(r.length===c.length&&r.every(C=>c.some(L=>L===C)))return!0}else if(r===c)return!0;return!1};let s=t.reactive([]),i=t.ref([]);const o=t.ref(0),d=t.ref(0),f=t.ref(0),p=t.ref(0),w=t.ref(0),b=t.ref(0),B=t.ref(0),j=t.ref(0),X=t.ref(!1),R=t.ref(Array.isArray(e.modelValue)?e.modelValue.concat():e.modelValue),x=t.ref(void 0),S=t.ref(),I=t.ref(),T=t.computed(()=>({height:`${f.value}px`})),Z=t.computed(()=>({height:`${p.value}px`})),v=t.computed(()=>[`${n}__wrapper`]),Y=t.computed(()=>[`${n}__scroll-area`]),O=t.computed(()=>[`${n}__block-area`]),q=t.computed(()=>[`${n}__empty`]),J=t.computed(()=>[`${n}__empty-text_default`]),ee=t.computed(()=>[`${n}__loading`]),te=t.computed(()=>[`${n}__loading-wrapper`]),G=t.computed(()=>[`${n}__loading-icon`]),m=t.computed(()=>[`${n}__iframe`]),k=he.reduce((r,c)=>(ht.indexOf(c)<0&&(r[c]=(...C)=>{l.emit.apply(l,[c,...C])}),r),{}),A=()=>({store:new we({keyField:e.keyField,ignoreMode:e.ignoreMode,filteredNodeCheckable:e.filteredNodeCheckable,cascade:e.cascade,defaultExpandAll:e.defaultExpandAll,load:e.load,expandOnFilter:e.expandOnFilter}),blockNodes:[]});let h=A();t.watch(()=>e.modelValue,r=>{if(e.checkable){if(a(r,R.value))return;let c=[];Array.isArray(r)?c=r.concat():typeof r=="string"&&(c=r===""?[]:r.split(e.separator)),h.store.clearChecked(!1,!1),h.store.setCheckedKeys(c,!0)}else if(e.selectable){if(r===R.value)return;const c=h.store.getSelectedKey();r!==""&&r!=null?h.store.setSelected(r,!0):(r===""||r==null)&&c&&h.store.setSelected(c,!1)}}),t.watch(()=>e.data,r=>{M(r)}),t.watch(()=>e.expandedKeys,()=>{oe()});function M(r){ke();let c=null,C=null;e.checkable?Array.isArray(e.modelValue)?c=e.modelValue.concat():typeof e.modelValue=="string"&&(c=e.modelValue===""?[]:e.modelValue.split(e.separator)):e.selectable&&!Array.isArray(e.modelValue)&&(C=e.modelValue),h.store.setData(r,C,c),oe()}function U(r,c){h.store.setChecked(r,c)}function N(r,c){h.store.setCheckedKeys(r,c)}function D(){h.store.checkAll()}function u(){h.store.clearChecked()}function g(r,c){h.store.setSelected(r,c)}function y(){h.store.clearSelected()}function _(r,c,C=!0){h.store.setExpand(r,c,C)}function ae(r,c){h.store.setExpandKeys(r,c)}function Fe(r){h.store.setExpandAll(r)}function Be(r){return r=r||e.ignoreMode,h.store.getCheckedNodes(r)}function Ie(r){return r=r||e.ignoreMode,h.store.getCheckedKeys(r)}function Te(){return h.store.getIndeterminateNodes()}function Le(){return h.store.getSelectedNode()}function Me(){return h.store.getSelectedKey()}function ze(){return h.store.getExpandNodes()}function Re(){return h.store.getExpandKeys()}function Oe(){return h.store.flatData.filter(r=>r._filterVisible)}function fe(r){return h.store.getNode(r)}function Pe(){return h.store.data}function He(){return h.store.flatData}function xe(){return h.store.flatData.length}function Ue(r,c){return h.store.insertBefore(r,c)}function We(r,c){return h.store.insertAfter(r,c)}function je(r,c){return h.store.append(r,c)}function Xe(r,c){return h.store.prepend(r,c)}function Ye(r){return h.store.remove(r)}function qe(r,c){const C=(L,$)=>{const V=$[e.titleField];return V==null||!V.toString?!1:V.toString().toLowerCase().indexOf(L.toLowerCase())>-1};c=c||e.filterMethod||C,h.store.filter(r,c)}function Je(r){if(!e.checkable)return;r=r??e.showUnloadCheckedNodes;const c=h.store.getCheckedNodes();if(h.store.filter("",(L,$)=>$.checked),!r)return;const C=h.store.getUnloadCheckedKeys();if(C.length){const L=C.map($=>{const V=e.unloadDataList.concat(c);let be=$;return V.some(Se=>Se[e.keyField]===$&&Se[e.titleField]!=null?(be=Se[e.titleField],!0):!1),new W({[e.keyField]:$,[e.titleField]:be,checked:!0,isLeaf:!0},null,e.keyField,!!e.load)});s=L,h.blockNodes.push(...L),de(),le()}}function ue(){return X.value=!0,new Promise((r,c)=>{e.load&&e.load(null,r,c)}).then(r=>{Array.isArray(r)&&M(r)}).catch(()=>{}).then(()=>{X.value=!1})}function Ge(r,c=ie.top){const C=h.store.mapData[r];if(!C||!C.visible)return;let L=-1;for(let V=0;V<o.value;V++)if(h.blockNodes[V][e.keyField]===r){L=V;break}if(L===-1)return;let $=L*e.nodeMinHeight;if(c===ie.center){const V=S.value.clientHeight;$=$-(V-e.nodeMinHeight)/2}else if(c===ie.bottom){const V=S.value.clientHeight;$=$-(V-e.nodeMinHeight)}else typeof c=="number"&&($=$-c);S.value&&(S.value.scrollTop=$)}function oe(){e.expandedKeys.length&&(h.store.setExpandAll(!1,!1),h.store.setExpandKeys(e.expandedKeys,!0))}function pe(){if(s.length){const r=h.store.getUnloadCheckedKeys();s.forEach(c=>{c.checked=r.indexOf(c[e.keyField])>-1})}}function Qe(r){l.emit("check",r),!(!e.cascade&&e.enableLeafOnly&&!r.isLeaf)&&h.store.setChecked(r[e.keyField],r.indeterminate?!1:!r.checked,!0,!0,!0)}function Ze(r){l.emit("select",r),!(e.enableLeafOnly&&!r.isLeaf)&&h.store.setSelected(r[e.keyField],!r.selected)}function ve(r){l.emit("expand",r),h.store.setExpand(r[e.keyField],!r.expand)}function et(r,c,C){if(e.droppable&&c.dataTransfer)try{const $=JSON.parse(c.dataTransfer.getData("node"))[e.keyField],V=r[e.keyField];if(e.beforeDropMethod($,V,C)){if($===V)return;C===P.before?h.store.insertBefore($,V):C===P.body||!r.isLeaf&&r.expand?h.store.prepend($,V):C===P.after&&h.store.insertAfter($,V),l.emit("node-drop",r,c,C,fe($))}}catch(L){throw new Error(L)}}function me(r,c){if(e.checkable){let C=c;Array.isArray(e.modelValue)||(C=C.join(e.separator)),Array.isArray(C)?R.value=C.concat():R.value=C,l.emit("update:modelValue",C)}}function ge(r,c){if(e.selectable&&!e.checkable){const C=c||"";R.value=C,l.emit("update:modelValue",C)}}function tt(){$e.forEach(r=>{h.store.on(r,(...c)=>{l.emit.apply(l,[r,...c])})})}function ke(){f.value=0,p.value=0,S.value&&(S.value.scrollTop=0)}function Ce(){h.blockNodes=h.store.flatData.filter(r=>r.visible),de(),le()}function de(){o.value=h.blockNodes.length,d.value=e.nodeMinHeight*o.value}function le(){ye(),ce()}function ye(){const r=S.value.clientHeight;w.value=Math.max(e.renderNodeAmount,Math.ceil(r/e.nodeMinHeight)+e.bufferNodeAmount)}function ce(r=!1){if(o.value>w.value){const c=S.value.scrollTop,C=Math.floor(c/e.nodeMinHeight);B.value=Math.floor(C/e.bufferNodeAmount)*e.bufferNodeAmount}else B.value=0;r&&b.value===w.value&&j.value===B.value||(i.value=h.blockNodes.slice(B.value,B.value+w.value).map(c=>Object.assign({},c,{_parent:null,children:[]})),f.value=B.value*e.nodeMinHeight,p.value=d.value-(f.value+i.value.length*e.nodeMinHeight))}function lt(){x.value&&window.cancelAnimationFrame(x.value),b.value=w.value,j.value=B.value,x.value=window.requestAnimationFrame(ce.bind(null,!0))}const Nt={setData:M,setChecked:U,setCheckedKeys:N,checkAll:D,clearChecked:u,setSelected:g,clearSelected:y,setExpand:_,setExpandKeys:ae,setExpandAll:Fe,getCheckedNodes:Be,getCheckedKeys:Ie,getIndeterminateNodes:Te,getSelectedNode:Le,getSelectedKey:Me,getExpandNodes:ze,getExpandKeys:Re,getCurrentVisibleNodes:Oe,getTreeData:Pe,getFlatData:He,getNodesCount:xe,insertBefore:Ue,insertAfter:We,append:je,prepend:Xe,remove:Ye,filter:qe,showCheckedNodes:Je,loadRootNodes:ue,scrollTo:Ge,updateExpandedKeys:oe,updateUnloadStatus:pe,handleTreeScroll:lt,handleNodeCheck:Qe,handleNodeSelect:Ze,handleNodeExpand:ve,handleNodeDrop:et,emitCheckableInput:me,emitSelectableInput:ge,resetSpaceHeights:ke,updateBlockNodes:Ce,updateBlockData:de,updateRender:le,updateRenderAmount:ye,updateRenderNodes:ce,getNode:fe};return t.onMounted(()=>{h.store.on("visible-data-change",Ce),h.store.on("render-data-change",le),h.store.on("checked-change",(c,C)=>{me(c,C),pe()}),h.store.on("selected-change",ge),e.data.length?(M(e.data),e.defaultExpandedKeys.length&&h.store.setExpandKeys(e.defaultExpandedKeys,!0)):typeof e.load=="function"&&e.autoLoad&&((e.modelValue||e.unloadDataList)&&M([]),ue());const r=I.value;r!=null&&r.contentWindow&&r.contentWindow.addEventListener("resize",le)}),t.onBeforeUnmount(()=>{const r=I.value;r!=null&&r.contentWindow&&r.contentWindow.removeEventListener("resize",le),h.store.disposeListeners();const c=A();h.store=c.store,h.blockNodes=c.blockNodes}),tt(),{nonReactive:h,unloadCheckedNodes:s,blockLength:o,blockAreaHeight:d,topSpaceHeight:f,bottomSpaceHeight:p,renderAmount:w,renderAmountCache:b,renderNodes:i,renderStart:B,renderStartCache:j,isRootLoading:X,valueCache:R,debounceTimer:x,topSpaceStyles:T,bottomSpaceStyles:Z,wrapperCls:v,scrollAreaCls:Y,blockAreaCls:O,emptyCls:q,emptyTextDefaultCls:J,loadingCls:ee,loadingWrapperCls:te,loadingIconCls:G,iframeCls:m,treeNodeListeners:k,setData:M,setChecked:U,setCheckedKeys:N,checkAll:D,clearChecked:u,setSelected:g,clearSelected:y,setExpand:_,setExpandKeys:ae,setExpandAll:Fe,getCheckedNodes:Be,getCheckedKeys:Ie,getIndeterminateNodes:Te,getSelectedNode:Le,getSelectedKey:Me,getExpandNodes:ze,getExpandKeys:Re,getCurrentVisibleNodes:Oe,getTreeData:Pe,getFlatData:He,getNodesCount:xe,insertBefore:Ue,insertAfter:We,append:je,prepend:Xe,remove:Ye,filter:qe,showCheckedNodes:Je,loadRootNodes:ue,scrollTo:Ge,updateExpandedKeys:oe,updateUnloadStatus:pe,handleTreeScroll:lt,handleNodeCheck:Qe,handleNodeSelect:Ze,handleNodeExpand:ve,handleNodeDrop:et,emitCheckableInput:me,emitSelectableInput:ge,attachStoreEvents:tt,resetSpaceHeights:ke,updateBlockNodes:Ce,updateBlockData:de,updateRender:le,updateRenderAmount:ye,updateRenderNodes:ce,getNode:fe,scrollArea:S,iframe:I,methods:Nt}}}),ut={slot:"node-item-final"};function pt(e,l,n,a,s,i){const o=t.resolveComponent("CTreeNode"),d=t.resolveComponent("LoadingIcon");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.wrapperCls)},[t.createElementVNode("div",{ref:"scrollArea",class:t.normalizeClass(e.scrollAreaCls),onScrollPassive:l[0]||(l[0]=t.withModifiers((...f)=>e.handleTreeScroll&&e.handleTreeScroll(...f),["stop"]))},[t.createElementVNode("div",{class:t.normalizeClass(e.blockAreaCls)},[t.createElementVNode("div",{style:t.normalizeStyle(e.topSpaceStyles)},null,4),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.renderNodes,f=>(t.openBlock(),t.createBlock(o,t.mergeProps(e.$props,{key:f[e.keyField],data:f,getNode:e.getNode},t.toHandlers(e.treeNodeListeners),{class:typeof e.nodeClassName=="function"?e.nodeClassName(f):e.nodeClassName,style:{minHeight:`${e.nodeMinHeight}px`,marginLeft:e.usePadding?null:`${f._level*e.nodeIndent}px`,paddingLeft:e.usePadding?`${f._level*e.nodeIndent}px`:null},onCheck:e.handleNodeCheck,onSelect:e.handleNodeSelect,onExpand:e.handleNodeExpand,onNodeDrop:e.handleNodeDrop}),{default:t.withCtx(()=>[t.createElementVNode("template",ut,[t.renderSlot(e.$slots,"node-item",{node:f})])]),_:2},1040,["data","getNode","class","style","onCheck","onSelect","onExpand","onNodeDrop"]))),128)),t.createElementVNode("div",{style:t.normalizeStyle(e.bottomSpaceStyles)},null,4)],2)],34),t.withDirectives(t.createElementVNode("div",{class:t.normalizeClass(e.emptyCls)},[t.createElementVNode("span",{class:t.normalizeClass(e.emptyTextDefaultCls)},[t.renderSlot(e.$slots,"empty",{},()=>[t.createTextVNode(t.toDisplayString(e.emptyText),1)])],2)],2),[[t.vShow,!e.blockLength]]),t.withDirectives(t.createElementVNode("div",{class:t.normalizeClass(e.loadingCls)},[t.createElementVNode("div",{class:t.normalizeClass(e.loadingWrapperCls)},[t.renderSlot(e.$slots,"loading",{},()=>[t.createVNode(d,{class:t.normalizeClass(e.loadingIconCls)},null,8,["class"])])],2)],2),[[t.vShow,e.loading||e.isRootLoading]]),t.createElementVNode("iframe",{ref:"iframe",class:t.normalizeClass(e.iframeCls)},null,2)],2)}const Ee=ne(ft,[["render",pt]]);function Ve(e){return nt.reduce((l,n)=>(l[n]=function(...a){return e.value[n].apply(e.value,a)},l),{})}const z="ctree-tree-search",re="ctree-tree-node",mt=t.defineComponent({name:"CTreeSearch",inheritAttrs:!1,emits:["checked-change","search","set-data","update:modelValue"],components:{CTree:Ee},props:{modelValue:[String,Number,Array],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}},setup(e,{emit:l,attrs:n,expose:a}){const s=t.reactive({checked:!1,indeterminate:!1,disabled:!1}),i=t.ref(!1),o=t.ref(""),d=t.ref(void 0),f=t.ref(0),p=t.ref();let w=Ve(p);const b=t.computed({get:()=>e.modelValue,set:N=>{A(),l("update:modelValue",N)}}),B=t.computed(()=>[`${z}__wrapper`]),j=t.computed(()=>[`${z}__search`]),X=t.computed(()=>[`${z}__check-all-wrapper`]),R=t.computed(()=>[`${z}__check-all`,`${re}__checkbox`,{[`${re}__checkbox_checked`]:s.checked,[`${re}__checkbox_indeterminate`]:s.indeterminate,[`${re}__checkbox_disabled`]:e.searchDisabled||s.disabled}]),x=t.computed(()=>[`${z}__input-wrapper`]),S=t.computed(()=>[`${z}__input`,{[`${z}__input_disabled`]:e.searchDisabled}]),I=t.computed(()=>[`${z}__action-wrapper`]),T=t.computed(()=>[`${z}__checked-button`,{[`${z}__checked-button_active`]:i.value}]),Z=t.computed(()=>[`${z}__tree-wrapper`]),v=t.computed(()=>[`${z}__footer`]),Y=t.computed(()=>"checkable"in n&&n.checkable!==!1);function O(){o.value=""}function q(){return o.value}function J(N){let D=N;return typeof N!="string"&&(D=o.value),new Promise((u,g)=>{clearTimeout(d.value),d.value=setTimeout(()=>{if(!(D.length>0&&D.length<e.searchLength))if(i.value=!1,l("search",D),typeof e.searchMethod=="function"){const y=e.searchMethod(D);Promise.resolve(y).then(()=>{k(),u()})}else e.searchRemote?p.value.loadRootNodes().then(()=>{k(),u()}):(p.value.filter(D),k(),u())},e.searchDebounceTime)})}function ee(){if(e.searchDisabled||s.disabled)return;const N=p.value.getCurrentVisibleNodes().map(D=>D[p.value.keyField]);s.checked||s.indeterminate?p.value.setCheckedKeys(N,!1):p.value.setCheckedKeys(N,!0),k()}function te(){J()}function G(){const N=()=>{i.value=!i.value,i.value?p.value.showCheckedNodes():p.value.filter(o.value,()=>!0),k()};o.value?(O(),J().then(()=>{N()})):N()}function m(){A(),k()}function k(){const N=p.value.getCurrentVisibleNodes(),D=N.length;let u=!1,g=!1,y=!1;for(let _=0;_<D;_++){const ae=N[_];if(ae.checked?u=!0:g=!0,u&&g||ae.indeterminate){y=!0,s.checked=!1,s.indeterminate=!0;break}}y||(s.checked=u,s.indeterminate=!1)}function A(){f.value=p.value.getCheckedKeys().length}function h(N,D){k(),l("checked-change",N,D)}function M(){l("set-data"),m()}return t.onMounted(()=>{Y.value&&!f.value&&m()}),{...w,treeModelValue:b,setChecked:(N,D)=>{p.value.setChecked(N,D)},checkAllStatus:s,isShowingChecked:i,keyword:o,debounceTimer:d,checkedCount:f,wrapperCls:B,searchCls:j,checkAllWrapperCls:X,checkboxCls:R,inputWrapperCls:x,inputCls:S,actionWrapperCls:I,checkedButtonCls:T,treeWrapperCls:Z,footerCls:v,checkable:Y,treeRef:p,handleCheckAll:ee,handleSearch:te,handleShowChecked:G,updateCheckedCount:A,handleSetData:m,updateCheckAllStatus:k,getKeyword:q,checkedChange:h,onSetData:M,clearKeyword:O,search:J}}}),gt=["placeholder","disabled"],kt={style:{float:"right"}};function Ct(e,l,n,a,s,i){const o=t.resolveComponent("CTree");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.wrapperCls)},[t.createElementVNode("div",{class:t.normalizeClass(e.searchCls)},[e.showCheckAll&&e.checkable?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(e.checkAllWrapperCls)},[t.createElementVNode("div",{class:t.normalizeClass(e.checkboxCls),onClick:l[0]||(l[0]=(...d)=>e.handleCheckAll&&e.handleCheckAll(...d))},null,2)],2)):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(e.inputWrapperCls)},[t.renderSlot(e.$slots,"search-input",{},()=>[t.withDirectives(t.createElementVNode("input",{"onUpdate:modelValue":l[1]||(l[1]=d=>e.keyword=d),type:"text",class:t.normalizeClass(e.inputCls),placeholder:e.searchPlaceholder,disabled:e.searchDisabled,onInput:l[2]||(l[2]=(...d)=>e.handleSearch&&e.handleSearch(...d))},null,42,gt),[[t.vModelText,e.keyword]])])],2),t.createElementVNode("div",{class:t.normalizeClass(e.actionWrapperCls)},[e.showCheckedButton&&e.checkable?(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(e.checkedButtonCls),onClick:l[3]||(l[3]=(...d)=>e.handleShowChecked&&e.handleShowChecked(...d))},t.toDisplayString(e.checkedButtonText),3)):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"actions")],2)],2),t.createElementVNode("div",{class:t.normalizeClass(e.treeWrapperCls)},[t.createVNode(o,t.mergeProps({ref:"treeRef"},e.$attrs,{modelValue:e.treeModelValue,"onUpdate:modelValue":l[4]||(l[4]=d=>e.treeModelValue=d),onSetData:e.onSetData,onCheckedChange:e.checkedChange}),t.createSlots({_:2},[t.renderList(e.$slots,(d,f)=>({name:"default",fn:t.withCtx(p=>[t.renderSlot(e.$slots,f,t.normalizeProps(t.guardReactiveProps(p)))])}))]),1040,["modelValue","onSetData","onCheckedChange"])],2),e.showFooter&&e.checkable?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(e.footerCls)},[t.renderSlot(e.$slots,"footer",{},()=>[t.createElementVNode("span",kt,"已选 "+t.toDisplayString(e.checkedCount)+" 个",1)])],2)):t.createCommentVNode("",!0)],2)}const Ke=ne(mt,[["render",Ct]]),H="ctree-tree-drop",Ae="ctree-tree-search",yt=t.defineComponent({name:"CTreeDrop",inheritAttrs:!1,emits:["clear","checked-change","dropdown-visible-change","update:modelValue"],components:{CTreeSearch:Ke},props:{modelValue:[String,Number,Array],dropHeight:{type:Number,default:300},dropPlaceholder:{type:String},dropDisabled:{type:Boolean,default:!1},clearable:{type:Boolean,default:!1},placement:{type:String,default:Ne["bottom-start"]},transfer:{type:Boolean,default:!1},dropdownClassName:[String,Array],dropdownMinWidth:{type:Number},dropdownWidthFixed:{type:Boolean,default:!1}},setup(e,{attrs:l,emit:n}){const a=t.ref(!1),s=t.ref(0),i=t.ref(""),o=t.ref(),d=t.ref(),f=t.ref(),p=t.reactive({checkedNodes:[],checkedKeys:[],selectedNode:void 0,selectedKey:void 0}),w=t.computed({get:()=>e.modelValue,set:m=>{n("update:modelValue",m)}}),b=t.computed(()=>[`${H}__wrapper`]),B=t.computed(()=>[`${H}__reference`]),j=t.computed(()=>[`${Ae}__input`,`${H}__display-input`,{[`${H}__display-input_focus`]:a.value,[`${Ae}__input_disabled`]:e.dropDisabled}]),X=t.computed(()=>{let m=!1;return typeof e.dropPlaceholder=="string"&&(I.value?m=s.value===0:T.value&&(m=i.value==="")),[`${H}__display-input-text`,{[`${H}__display-input-placeholder`]:m}]}),R=t.computed(()=>[`${H}__display-icon-drop`,{[`${H}__display-icon-drop_active`]:a.value}]),x=t.computed(()=>[`${H}__display-icon-clear`]),S=t.computed(()=>{const m=Array.isArray(e.dropdownClassName)?e.dropdownClassName:[e.dropdownClassName];return[`${H}__dropdown`,...m]}),I=t.computed(()=>"checkable"in l&&l.checkable!==!1),T=t.computed(()=>"selectable"in l&&l.selectable!==!1),Z=t.computed(()=>I.value?s.value===0&&typeof e.dropPlaceholder=="string"?e.dropPlaceholder:`已选 ${s.value} 个`:T.value?i.value===""&&typeof e.dropPlaceholder=="string"?e.dropPlaceholder:i.value:e.dropPlaceholder||""),v=t.computed(()=>I.value?s.value!==0:T.value?i.value!=="":!1);function Y(){const m=o.value.getBoundingClientRect(),k=m.width,A=m.height,h=`${typeof e.dropdownMinWidth=="number"?e.dropdownMinWidth:k}px`;d.value.style.minWidth=h,d.value.style.width=e.dropdownWidthFixed?h:"auto";const M=d.value.getBoundingClientRect(),U=window.getComputedStyle(d.value),N=parseFloat(U.marginLeft)+parseFloat(U.marginRight),D=parseFloat(U.marginTop)+parseFloat(U.marginBottom),u=M.width+N,g=M.height/.8+D;let y=0,_=0;switch(e.transfer&&(y=-999,_=-999),e.placement){case"bottom-start":e.transfer?(y=window.pageYOffset+m.bottom,_=window.pageXOffset+m.left):y=A;break;case"bottom-end":e.transfer?(y=window.pageYOffset+m.bottom,_=window.pageXOffset+m.right-u):(y=A,_=k-u);break;case"bottom":e.transfer?(y=window.pageYOffset+m.bottom,_=window.pageXOffset+m.left+(k-u)/2):(y=A,_=(k-u)/2);break;case"top-start":e.transfer?(y=window.pageYOffset+m.top-g,_=window.pageXOffset+m.left):y=-g;break;case"top-end":e.transfer?(y=window.pageYOffset+m.top-g,_=window.pageXOffset+m.right-u):(y=-g,_=k-u);break;case"top":e.transfer?(y=window.pageYOffset+m.top-g,_=window.pageXOffset+m.left+(k-u)/2):(y=-g,_=(k-u)/2);break}d.value.style.top=`${y}px`,d.value.style.left=`${_}px`}function O(){e.dropDisabled||(a.value=!a.value)}function q(m){var k,A;!((k=o.value)!=null&&k.contains(m.target))&&!((A=d.value)!=null&&A.contains(m.target))&&(a.value=!1)}function J(){n("clear"),I.value?f.value.clearChecked():T.value&&f.value.clearSelected()}function ee(m,k){p.checkedNodes=m,p.checkedKeys=k,s.value=k.length,n("checked-change",m,k)}function te(m,k){if(p.selectedNode=m,p.selectedKey=k,m){const A=f.value.$refs.treeRef.titleField;i.value=m[A]}else k?i.value=k:i.value="";a.value=!1}function G(){const m=f.value.$refs.treeRef;if(p.checkedNodes=f.value.getCheckedNodes(),p.checkedKeys=f.value.getCheckedKeys(),p.selectedNode=f.value.getSelectedNode(),p.selectedKey=f.value.getSelectedKey(),I.value&&(s.value=p.checkedKeys.length),T.value&&e.modelValue!=null){const k=f.value.getNode(e.modelValue);if(k){const A=m.titleField;i.value=k[A]}else i.value=e.modelValue}}return t.onMounted(()=>{document.addEventListener("click",q),e.transfer&&document.body.appendChild(d.value),G()}),t.watch(()=>a.value,m=>{n("dropdown-visible-change",m),m?t.nextTick(()=>{Y()}):f.value.getKeyword()&&(f.value.clearKeyword(),f.value.search())}),{...Ve(f),treeSearchValue:w,dropdownVisible:a,checkedCount:s,selectedTitle:i,slotProps:p,wrapperCls:b,referenceCls:B,displayInputCls:j,displayInputTextCls:X,dropIconCls:R,clearIconCls:x,dropdownCls:S,checkable:I,selectable:T,displayValue:Z,showClearIcon:v,referenceRef:o,dropdownRef:d,treeSearchRef:f,locateDropdown:Y,handleRefClick:O,handleDocumentClick:q,handleClear:J,handleCheckedChange:ee,handleSelectedChange:te,handleSetData:G}}});function bt(e,l,n,a,s,i){const o=t.resolveComponent("CTreeSearch");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.wrapperCls)},[t.createElementVNode("div",{ref:"referenceRef",class:t.normalizeClass(e.referenceCls),onClick:l[1]||(l[1]=(...d)=>e.handleRefClick&&e.handleRefClick(...d))},[t.renderSlot(e.$slots,"default",t.normalizeProps(t.guardReactiveProps(e.slotProps)),()=>[t.createElementVNode("div",{class:t.normalizeClass(e.displayInputCls)},[t.createElementVNode("span",{class:t.normalizeClass(e.displayInputTextCls)},[t.renderSlot(e.$slots,"display",t.normalizeProps(t.guardReactiveProps(e.slotProps)),()=>[t.createTextVNode(t.toDisplayString(e.displayValue),1)])],2),e.dropDisabled?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("i",{class:t.normalizeClass(e.dropIconCls)},null,2),e.clearable&&e.showClearIcon?t.renderSlot(e.$slots,"clear",{key:0},()=>[t.createElementVNode("i",{class:t.normalizeClass(e.clearIconCls),onClick:l[0]||(l[0]=t.withModifiers((...d)=>e.handleClear&&e.handleClear(...d),["stop"]))},null,2)]):t.createCommentVNode("",!0)],64))],2)])],2),t.createVNode(t.Transition,{name:"ctree-dropdown"},{default:t.withCtx(()=>[t.withDirectives(t.createElementVNode("div",{ref:"dropdownRef",class:t.normalizeClass(e.dropdownCls),style:t.normalizeStyle({height:`${e.dropHeight}px`})},[t.createVNode(o,t.mergeProps({ref:"treeSearchRef",modelValue:e.treeSearchValue,"onUpdate:modelValue":l[2]||(l[2]=d=>e.treeSearchValue=d)},e.$attrs,{onSetData:e.handleSetData,onCheckedChange:e.handleCheckedChange,onSelectedChange:e.handleSelectedChange}),t.createSlots({_:2},[t.renderList(e.$slots,(d,f)=>({name:f,fn:t.withCtx(p=>[t.renderSlot(e.$slots,f,t.normalizeProps(t.guardReactiveProps(p)))])}))]),1040,["modelValue","onSetData","onCheckedChange","onSelectedChange"])],6),[[t.vShow,e.dropdownVisible]])]),_:3})],2)}const St=ne(yt,[["render",bt]]),$t="";F.TreeNode=W,F.TreeStore=we,F.VTreeDrop=St,F.VTreeNode=_e,F.VTreeSearch=Ke,F.default=Ee,Object.defineProperties(F,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
(function(F,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(F=typeof globalThis<"u"?globalThis:F||self,t(F.Vtree={},F.Vue))})(this,function(F,t){"use strict";var Nt=Object.defineProperty;var wt=(F,t,Q)=>t in F?Nt(F,t,{enumerable:!0,configurable:!0,writable:!0,value:Q}):F[t]=Q;var E=(F,t,Q)=>(wt(F,typeof t!="symbol"?t+"":t,Q),Q);const Q=["_level","_filterVisible","_parent","_loading","_loaded","_remote","_keyField","children","setChildren"];class W{constructor(l,n=null,a="id",s=!1){E(this,"_level",0);E(this,"checked",!1);E(this,"selected",!1);E(this,"indeterminate",!1);E(this,"disabled",!1);E(this,"expand",!1);E(this,"visible",!0);E(this,"_filterVisible",!0);E(this,"_parent",null);E(this,"children",[]);E(this,"isLeaf",!1);E(this,"_loading",!1);E(this,"_loaded",!1);this._keyField=a,this._remote=s;for(let i in l)Q.indexOf(i)===-1&&(this[i]=l[i]);this[a]==null&&(this[a]=Math.random().toString(36).substring(2)),this._parent=n,this._parent&&(this._level=this._parent._level+1),this.visible=this._parent===null||this._parent.expand&&this._parent.visible,Array.isArray(l.children)&&this.setChildren(l.children),this.children.length&&(this._loaded=!0),this._remote||(this.isLeaf=!this.children.length)}setChildren(l){this.children=l.map(n=>new W(Object.assign({},n),this,this._keyField,this._remote))}}var se=(e=>(e.none="none",e.parents="parents",e.children="children",e))(se||{});const nt=["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"];var Ne=(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",e))(Ne||{}),ie=(e=>(e.top="top",e.center="center",e.bottom="bottom",e))(ie||{}),P=(e=>(e.before="before",e.body="body",e.after="after",e))(P||{});const he=["expand","check","click","select","node-dblclick","node-right-click","node-dragstart","node-dragenter","node-dragover","node-dragleave","node-drop"];class we{constructor(l){E(this,"data",[]);E(this,"flatData",[]);E(this,"mapData",Object.create(null));E(this,"unloadCheckedKeys",[]);E(this,"unloadSelectedKey",null);E(this,"currentSelectedKey",null);E(this,"listenersMap",{});this.options=l}setData(l,n=null,a=null){this.data=l.map(s=>new W(s,null,this.options.keyField,!!this.options.load));for(let s in this.mapData)delete this.mapData[s];this.currentSelectedKey=null,this.flatData=this.flattenData(this.data),this.setUnloadCheckedKeys(a||[]),n&&(this.currentSelectedKey=null,this.setUnloadSelectedKey(n)),this.emit("visible-data-change"),this.emit("set-data")}setChecked(l,n,a=!0,s=!0,i=!1){const o=this.mapData[l];if(!o)return this.setUnloadChecked(l,n,a,s);o.disabled||o.checked&&n||!o.checked&&!o.indeterminate&&!n||(this.options.cascade?(this.checkNodeDownward(o,n,i),this.checkNodeUpward(o)):o.checked=n,a&&(o.checked?this.emit("check",o):this.emit("uncheck",o)),this.triggerCheckedChange(a,s))}setUnloadChecked(l,n,a=!0,s=!0){const i=this.findIndex(l,this.unloadCheckedKeys);n?i===-1&&this.unloadCheckedKeys.push(l):i!==-1&&this.unloadCheckedKeys.splice(i,1),this.triggerCheckedChange(a,s)}setCheckedKeys(l,n,a=!0,s=!0){l.forEach(i=>{this.setChecked(i,n,!1,!1)}),this.triggerCheckedChange(a,s)}checkAll(l=!0,n=!0){if(this.options.cascade){const a=s=>{s.forEach(i=>{i.disabled?a(i.children):this.setChecked(i[this.options.keyField],!0,!1,!1)})};a(this.data)}else{const a=this.flatData.length;for(let s=0;s<a;s++){const i=this.flatData[s];this.setChecked(i[this.options.keyField],!0,!1,!1)}}this.triggerCheckedChange(l,n)}clearChecked(l=!0,n=!0){this.getCheckedNodes().forEach(s=>{this.setChecked(s[this.options.keyField],!1,!1,!1)}),this.unloadCheckedKeys=[],this.triggerCheckedChange(l,n)}triggerCheckedChange(l=!0,n=!0){l&&this.emit("checked-change",this.getCheckedNodes(),this.getCheckedKeys()),n&&this.emit("render-data-change")}setSelected(l,n,a=!0,s=!0){const i=this.mapData[l];if(!i)return this.setUnloadSelected(l,n,a,s);i.disabled||i.selected!==n&&(l===this.currentSelectedKey?n||(i.selected=n,this.currentSelectedKey=null):n&&(this.currentSelectedKey===null?(i.selected=n,this.currentSelectedKey=i[this.options.keyField]):(this.mapData[this.currentSelectedKey]&&(this.mapData[this.currentSelectedKey].selected=!1),i.selected=n,this.currentSelectedKey=i[this.options.keyField])),a&&(i.selected?this.emit("select",i):this.emit("unselect",i),this.emit("selected-change",this.getSelectedNode(),this.getSelectedKey())),s&&this.emit("render-data-change"))}setUnloadSelected(l,n,a=!0,s=!0){n?(this.currentSelectedKey&&this.setSelected(this.currentSelectedKey,!1,!1,!1),this.unloadSelectedKey=l):this.unloadSelectedKey===l&&(this.unloadSelectedKey=null),a&&this.emit("selected-change",this.getSelectedNode(),this.getSelectedKey()),s&&this.emit("render-data-change")}clearSelected(l=!0,n=!0){this.currentSelectedKey&&this.mapData[this.currentSelectedKey]?this.setSelected(this.currentSelectedKey,!1,l,n):this.unloadSelectedKey!==null&&(this.unloadSelectedKey=null,l&&this.emit("selected-change",this.getSelectedNode(),this.getSelectedKey()),n&&this.emit("render-data-change"))}setExpand(l,n,a=!1,s=!0,i=!0){const o=this.mapData[l];if(!(!o||!a&&o.isLeaf)&&o.expand!==n){if(!o.isLeaf){if(typeof this.options.load=="function"){if(!o._loaded&&!o._loading&&n){o._loading=!0,i&&this.emit("visible-data-change"),new Promise((f,p)=>{const w=this.options.load;w(o,f,p)}).then(f=>{if(Array.isArray(f)){const p=this.findIndex(o);if(p===-1)return;o._loaded=!0,o.expand=n,o.setChildren(f);const w=this.getCheckedKeys(),b=this.flattenData(o.children,this.getSelectedKey===null);this.flatData.splice(p+1,0,...b),this.setUnloadCheckedKeys(w),this.unloadSelectedKey!==null&&this.setUnloadSelectedKey(this.unloadSelectedKey),this.emit("set-data")}}).catch(f=>{}).then(()=>{o._loading=!1,s&&this.emit("expand",o),i&&this.emit("visible-data-change")});return}else if(o._loading)return}o.expand=n;const d=[...o.children];for(;d.length;)d[0].expand&&d[0].children.length&&d.push(...d[0].children),d[0]._filterVisible===!1?d[0].visible=!1:d[0].visible=d[0]._parent===null||d[0]._parent.expand&&d[0]._parent.visible,d.shift();s&&this.emit("expand",o),i&&this.emit("visible-data-change")}a&&o._parent&&n&&this.setExpand(o._parent[this.options.keyField],n,a,!1,i)}}setExpandKeys(l,n,a=!0){l.forEach(s=>{this.setExpand(s,n,!1,!1,!1)}),a&&this.emit("visible-data-change")}setExpandAll(l,n=!0){this.flatData.forEach(a=>{(!this.options.load||a._loaded)&&this.setExpand(a[this.options.keyField],l,!1,!1,!1)}),n&&this.emit("visible-data-change")}getCheckedNodes(l=this.options.ignoreMode){if(l===se.children){const n=[],a=s=>{s.forEach(i=>{i.checked?n.push(i):!i.isLeaf&&i.indeterminate&&a(i.children)})};return a(this.data),n}else return this.flatData.filter(n=>l===se.parents?n.checked&&n.isLeaf:n.checked)}getCheckedKeys(l=this.options.ignoreMode){return this.getCheckedNodes(l).map(n=>n[this.options.keyField]).concat(this.unloadCheckedKeys)}getIndeterminateNodes(){return this.flatData.filter(l=>l.indeterminate)}getSelectedNode(){return this.currentSelectedKey===null?null:this.mapData[this.currentSelectedKey]||null}getSelectedKey(){return this.currentSelectedKey||this.unloadSelectedKey||null}getUnloadCheckedKeys(){return this.unloadCheckedKeys}getExpandNodes(){return this.flatData.filter(l=>!l.isLeaf&&l.expand)}getExpandKeys(){return this.getExpandNodes().map(l=>l[this.options.keyField])}getNode(l){return this.mapData[l]||null}insertBefore(l,n){const a=this.getInsertedNode(l,n);if(!a)return null;this.remove(a[this.options.keyField],!1);const i=this.mapData[n]._parent,o=this.findIndex(n,i&&i.children),d=this.findIndex(n),f=i&&-1||this.findIndex(n,this.data);return this.insertIntoStore(a,i,o,d,f),this.emit("visible-data-change"),a}insertAfter(l,n){const a=this.getInsertedNode(l,n);if(!a)return null;this.remove(a[this.options.keyField],!1);const s=this.mapData[n],i=s._parent,o=this.findIndex(n,i&&i.children)+1,d=this.flatData.length,f=this.findIndex(n);let p=f+1;for(let b=f+1;b<=d;b++){if(b===d){p=b;break}if(this.flatData[b]._level<=s._level){p=b;break}}const w=i&&-1||this.findIndex(n,this.data)+1;return this.insertIntoStore(a,i,o,p,w),this.emit("visible-data-change"),a}append(l,n){const a=this.mapData[n];if(!a.isLeaf){const o=a.children.length;return this.insertAfter(l,a.children[o-1][this.options.keyField])}const s=this.getInsertedNode(l,n,!0);if(!s)return null;this.remove(s[this.options.keyField],!1);const i=this.findIndex(n)+1;return this.insertIntoStore(s,a,0,i),this.emit("visible-data-change"),s}prepend(l,n){const a=this.mapData[n];if(!a.isLeaf)return this.insertBefore(l,a.children[0][this.options.keyField]);const s=this.getInsertedNode(l,n,!0);if(!s)return null;this.remove(s[this.options.keyField],!1);const i=this.findIndex(n)+1;return this.insertIntoStore(s,a,0,i),this.emit("visible-data-change"),s}remove(l,n=!0){const a=this.mapData[l];if(!a)return null;const s=this.findIndex(a);if(s===-1)return null;let i=1;const o=this.flatData.length;for(let f=s+1;f<o&&this.flatData[f]._level>a._level;f++)i++;this.flatData.splice(s,i);const d=f=>{const p=this.mapData[f];delete this.mapData[f],p.children.forEach(w=>d(w[this.options.keyField]))};if(d(l),!a._parent){const f=this.findIndex(a,this.data);f>-1&&this.data.splice(f,1)}if(a._parent){const f=this.findIndex(a,a._parent.children);f!==-1&&a._parent.children.splice(f,1),a._parent.isLeaf=!a._parent.children.length,a._parent.isLeaf&&(a._parent.expand=!1,a._parent.indeterminate=!1),this.updateMovingNodeStatus(a)}return n&&this.emit("visible-data-change"),a}getInsertedNode(l,n,a=!1){const s=this.mapData[n];if(!s)return null;const i=a?s:s._parent;if(l instanceof W)return l[this.options.keyField]===n?null:l;if(typeof l=="object"){if(l[this.options.keyField]===n)return null;const o=this.mapData[l[this.options.keyField]];return o||new W(l,i,this.options.keyField,!!this.options.load)}else return!this.mapData[l]||l===n?null:this.mapData[l]}insertIntoStore(l,n,a,s,i){if(s===-1)return;a!==-1&&n&&n.children.splice(a,0,l),l._parent=n,n?(n.isLeaf=!1,this.setExpand(n[this.options.keyField],!0,!1,!1,!1)):typeof i=="number"&&i>-1&&this.data.splice(i,0,l);const o=this.flattenData([l]);l._level=n?n._level+1:0,o.forEach(d=>d._level=d._parent?d._parent._level+1:0),this.flatData.splice(s,0,...o),this.updateMovingNodeStatus(l)}updateMovingNodeStatus(l){this.checkNodeUpward(l),this.triggerCheckedChange(),l.selected&&this.setSelected(l[this.options.keyField],!0)}filter(l,n){const a=[];this.flatData.forEach(s=>{s._filterVisible=s._parent&&s._parent._filterVisible||n(l,s),s.visible=s._filterVisible,s._filterVisible&&a.push(s)}),a.forEach(s=>{const i=[];let o=s._parent;for(;o;)i.unshift(o),o=o._parent;i.forEach(d=>{d._filterVisible=!0,d.visible=(d._parent===null||d._parent.expand&&d._parent.visible)&&d._filterVisible,this.options.expandOnFilter&&this.setExpand(d[this.options.keyField],!0,!1,!1,!1)}),s.visible=s._parent===null||s._parent.expand&&s._parent.visible}),this.emit("visible-data-change")}setUnloadCheckedKeys(l){this.unloadCheckedKeys=l;const n=l.concat(),a=this.unloadCheckedKeys.length;for(let i=a-1;i>=0;i--){const o=this.unloadCheckedKeys[i];this.mapData[o]&&(this.setChecked(o,!0,!1,!1),this.unloadCheckedKeys.splice(i,1))}const s=this.getCheckedKeys();s.length===n.length&&s.every(i=>n.some(o=>o===i))||this.emit("checked-change",this.getCheckedNodes(),s)}setUnloadSelectedKey(l){const n=this.getSelectedKey();this.mapData[l]?(this.setSelected(l,!0,!1),this.unloadSelectedKey=null):(this.currentSelectedKey&&this.setSelected(this.currentSelectedKey,!1,!1),this.unloadSelectedKey=l);const a=this.getSelectedKey();a!==n&&this.emit("selected-change",this.getSelectedNode(),a)}flattenData(l,n=!0,a=[]){const s=l.length;for(let i=0;i<s;i++){const o=l[i],d=o[this.options.keyField];if(a.push(o),this.mapData[d])throw new Error("[CTree] Duplicate tree node key.");this.mapData[d]=o,o.checked&&this.options.cascade&&(this.checkNodeDownward(o,!0),this.checkNodeUpward(o)),o.selected&&n&&(this.clearSelected(!1,!1),this.currentSelectedKey=o[this.options.keyField],this.emit("selected-change",o,this.currentSelectedKey)),(this.options.defaultExpandAll||o.expand)&&!this.options.load&&!o.isLeaf&&(o.expand=!1,this.setExpand(o[this.options.keyField],!0,!1,!1,!1)),o.children.length&&this.flattenData(o.children,n,a)}return a}checkNodeDownward(l,n,a=!1){if(l.children.forEach(s=>{this.checkNodeDownward(s,n,a)}),l.isLeaf||this.options.load&&!l.children.length){if(!l.disabled){if(a&&!this.options.filteredNodeCheckable&&!l._filterVisible)return;l.checked=n,l.indeterminate=!1}}else this.checkParentNode(l)}checkNodeUpward(l){let n=l._parent;for(;n;)this.checkParentNode(n),n=n._parent}checkParentNode(l){const n=l.children.length;if(!n)return;let a=!1,s=!1,i=!1;for(let o=0;o<n;o++){const d=l.children[o];if(d.checked?a=!0:s=!0,a&&s||d.indeterminate){i=!0,l.checked=!1,l.indeterminate=!0;break}}i||(l.checked=a,l.indeterminate=!1)}findIndex(l,n=this.flatData){if(n!==null){let a=l instanceof W?l[this.options.keyField]:l;const s=n.length;for(let i=0;i<s;i++)if(n[0]instanceof W){if(a===n[i][this.options.keyField])return i}else if(a===n[i])return i}return-1}on(l,n){this.listenersMap[l]||(this.listenersMap[l]=[]);let a=[];Array.isArray(n)?a=n:a=[n],a.forEach(s=>{this.listenersMap[l].indexOf(s)===-1&&this.listenersMap[l].push(s)})}off(l,n){if(this.listenersMap[l])if(!n)this.listenersMap[l]=[];else{const a=this.listenersMap[l].indexOf(n);a>-1&&this.listenersMap[l].splice(a,1)}}emit(l,...n){if(!this.listenersMap[l])return;const a=this.listenersMap[l].length;for(let s=0;s<a;s++)this.listenersMap[l][s](...n)}disposeListeners(){for(const l in this.listenersMap)this.listenersMap[l]=[]}}const at=t.defineComponent({name:"CLoadingIcon"}),ne=(e,l)=>{const n=e.__vccOpts||e;for(const[a,s]of l)n[a]=s;return n},st={viewBox:"0 0 50 50"},it=[t.createElementVNode("circle",{class:"ctree-loading-icon__circle",cx:"25",cy:"25",r:"20",fill:"none","stroke-width":"5","stroke-miterlimit":"10"},null,-1)];function rt(e,l,n,a,s,i){return t.openBlock(),t.createElementBlock("svg",st,it)}const De=ne(at,[["render",rt]]),V="ctree-tree-node",ot=t.defineComponent({name:"CTreeNode",components:{LoadingIcon:De},props:{data:Object,titleField:String,keyField:String,render:Function,checkable:Boolean,selectable:Boolean,unselectOnClick:Boolean,disableAll:Boolean,draggable:Boolean,droppable:Boolean,getNode:Function},emits:[...he],setup(e,{emit:l}){var D;const n=t.ref(!1),a=t.ref(!1),s=t.ref(!1),i=e.keyField,o=e.getNode,d=e.titleField,f=t.computed(()=>{var u,g,y;return[`${V}__wrapper`,{[`${V}__wrapper_is-leaf`]:(u=e.data)==null?void 0:u.isLeaf},{[`${V}__title_selected`]:(g=e.data)==null?void 0:g.selected,[`${V}__title_disabled`]:e.disableAll||((y=e.data)==null?void 0:y.disabled)}]}),p=t.computed(()=>[`${V}__node-body`,{[`${V}__drop_active`]:n.value}]),w=t.computed(()=>[`${V}__drop`,{[`${V}__drop_active`]:a.value}]),b=t.computed(()=>[`${V}__drop`,{[`${V}__drop_active`]:s.value}]),B=t.computed(()=>[`${V}__square`]),j=t.computed(()=>{var u;return[`${V}__expand`,{[`${V}__expand_active`]:(u=e.data)==null?void 0:u.expand}]}),X=t.computed(()=>[`${V}__loading-icon`]),R=t.computed(()=>{var u,g,y;return[`${V}__checkbox`,{[`${V}__checkbox_checked`]:(u=e.data)==null?void 0:u.checked,[`${V}__checkbox_indeterminate`]:(g=e.data)==null?void 0:g.indeterminate,[`${V}__checkbox_disabled`]:e.disableAll||((y=e.data)==null?void 0:y.disabled)}]}),x=t.computed(()=>[`${V}__title`]),S=t.computed(()=>o(e.data?e.data[i]:"")||e.data||{}),I=t.computed(()=>e.checkable),T=((D=e.data)==null?void 0:D.render)||e.render||null,Z=t.computed(()=>t.defineComponent({name:"Render",functional:!0,render(){return typeof T!="function"?t.h("div"):T(S.value)}})),v=t.computed(()=>{var g;let u={};return e.draggable&&!e.disableAll&&!((g=e.data)!=null&&g.disabled)&&(u={dragstart:A}),u}),Y=t.computed(()=>{let u={};return e.droppable&&(u={dragenter:h.bind(t.getCurrentInstance()),dragover:M.bind(t.getCurrentInstance()),dragleave:U.bind(t.getCurrentInstance()),drop:N.bind(t.getCurrentInstance())}),u});function O(){var u;(u=e.data)!=null&&u.isLeaf||l("expand",S.value)}function q(){var u;e.disableAll||(u=e.data)!=null&&u.disabled||!e.checkable||l("check",S.value)}function J(){var u,g;if(l("click",S.value),e.selectable){if(e.disableAll||(u=e.data)!=null&&u.disabled||(g=e.data)!=null&&g.selected&&!e.unselectOnClick)return;l("select",S.value),O()}else e.checkable?q():O()}function ee(){l("node-dblclick",S.value)}function te(){l("node-right-click",S.value)}const G=t.ref();function m(u){const g=G.value.getBoundingClientRect(),y=g.height,_=u.clientY-g.top;return _<=y*.3?P.before:_<=y*(.3+.4)?P.body:P.after}function k(u,g=!1){a.value=!1,n.value=!1,s.value=!1,g||(u===P.before?a.value=!0:u===P.body?n.value=!0:u===P.after&&(s.value=!0))}function A(u){var g;u.dataTransfer&&u.dataTransfer.setData("node",JSON.stringify(e.data)),(g=e.data)!=null&&g.expand&&O(),l("node-dragstart",S.value,u)}function h(u){u.preventDefault();const g=m(u);k(g),l("node-dragenter",S.value,u,g)}function M(u){u.preventDefault();const g=m(u);k(g),l("node-dragover",S.value,u,g)}function U(u){const g=m(u);k(g,!0),l("node-dragleave",S.value,u,g)}function N(u){const g=m(u);k(g,!0),l("node-drop",S.value,u,g)}return{dragoverBody:n,dragoverBefore:a,dragoverAfter:s,wrapperCls:f,nodeBodyCls:p,dropBeforeCls:w,dropAfterCls:b,squareCls:B,expandCls:j,loadingIconCls:X,checkboxCls:R,titleCls:x,fullData:S,showCheckbox:I,renderFunction:T,renderComponent:Z,dragListeners:v,dropListeners:Y,titleField:d,handleExpand:O,handleCheck:q,handleSelect:J,handleDblclick:ee,handleRightClick:te,nodeBody:G}}}),dt=["draggable"];function ct(e,l,n,a,s,i){var d,f,p,w;const o=t.resolveComponent("LoadingIcon");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.wrapperCls)},[t.createElementVNode("div",{class:t.normalizeClass(e.dropBeforeCls)},null,2),t.createElementVNode("div",t.mergeProps({ref:"nodeBody",class:e.nodeBodyCls},t.toHandlers(e.dropListeners,!0)),[t.createElementVNode("div",{class:t.normalizeClass(e.squareCls)},[t.withDirectives(t.createElementVNode("i",{class:t.normalizeClass(e.expandCls),onClick:l[0]||(l[0]=(...b)=>e.handleExpand&&e.handleExpand(...b))},null,2),[[t.vShow,!((d=e.data)!=null&&d.isLeaf)&&!((f=e.data)!=null&&f._loading)]]),(p=e.data)!=null&&p._loading?(t.openBlock(),t.createBlock(o,{key:0,class:t.normalizeClass(e.loadingIconCls)},null,8,["class"])):t.createCommentVNode("",!0)],2),e.showCheckbox?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(e.squareCls)},[t.createElementVNode("div",{class:t.normalizeClass(e.checkboxCls),onClick:l[1]||(l[1]=(...b)=>e.handleCheck&&e.handleCheck(...b))},null,2)],2)):t.createCommentVNode("",!0),t.createElementVNode("div",t.mergeProps({class:e.titleCls,onClick:l[2]||(l[2]=(...b)=>e.handleSelect&&e.handleSelect(...b)),onDblclick:l[3]||(l[3]=(...b)=>e.handleDblclick&&e.handleDblclick(...b)),onContextmenu:l[4]||(l[4]=(...b)=>e.handleRightClick&&e.handleRightClick(...b))},t.toHandlers(e.dragListeners,!0),{draggable:e.draggable&&!e.disableAll&&!((w=e.data)!=null&&w.disabled)}),[t.renderSlot(e.$slots,"node-item-final",{},()=>[t.createTextVNode(t.toDisplayString(e.data?e.data[e.titleField]:""),1)])],16,dt)],16),t.createElementVNode("div",{class:t.normalizeClass(e.dropAfterCls)},null,2)],2)}const _e=ne(ot,[["render",ct]]),$e=["expand","select","unselect","selected-change","check","uncheck","checked-change","set-data"],ht=["node-drop","check","select","expand"],ft=t.defineComponent({name:"CTree",components:{CTreeNode:_e,LoadingIcon:De},emits:["update:modelValue",...he,...$e],props:{modelValue:[String,Number,Array],data:{type:Array,default:()=>[]},unloadDataList:{type:Array,default:()=>[]},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:()=>[]},expandedKeys:{type:Array,default:()=>[]},draggable:{type:Boolean,default:!1},droppable:{type:Boolean,default:!1},beforeDropMethod:{type:Function,default:()=>()=>!0},ignoreMode:{type:String,default:se.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}},setup(e,l){const n="ctree-tree",a=(r,c)=>{if(Array.isArray(r)&&Array.isArray(c)){if(r.length===c.length&&r.every(C=>c.some(L=>L===C)))return!0}else if(r===c)return!0;return!1};let s=t.reactive([]),i=t.ref([]);const o=t.ref(0),d=t.ref(0),f=t.ref(0),p=t.ref(0),w=t.ref(0),b=t.ref(0),B=t.ref(0),j=t.ref(0),X=t.ref(!1),R=t.ref(Array.isArray(e.modelValue)?e.modelValue.concat():e.modelValue),x=t.ref(void 0),S=t.ref(),I=t.ref(),T=t.computed(()=>({height:`${f.value}px`})),Z=t.computed(()=>({height:`${p.value}px`})),v=t.computed(()=>[`${n}__wrapper`]),Y=t.computed(()=>[`${n}__scroll-area`]),O=t.computed(()=>[`${n}__block-area`]),q=t.computed(()=>[`${n}__empty`]),J=t.computed(()=>[`${n}__empty-text_default`]),ee=t.computed(()=>[`${n}__loading`]),te=t.computed(()=>[`${n}__loading-wrapper`]),G=t.computed(()=>[`${n}__loading-icon`]),m=t.computed(()=>[`${n}__iframe`]),k=he.reduce((r,c)=>(ht.indexOf(c)<0&&(r[c]=(...C)=>{l.emit.apply(l,[c,...C])}),r),{}),A=()=>({store:new we({keyField:e.keyField,ignoreMode:e.ignoreMode,filteredNodeCheckable:e.filteredNodeCheckable,cascade:e.cascade,defaultExpandAll:e.defaultExpandAll,load:e.load,expandOnFilter:e.expandOnFilter}),blockNodes:[]});let h=A();t.watch(()=>e.modelValue,r=>{if(e.checkable){if(a(r,R.value))return;let c=[];Array.isArray(r)?c=r.concat():typeof r=="string"&&(c=r===""?[]:r.split(e.separator)),h.store.clearChecked(!1,!1),h.store.setCheckedKeys(c,!0)}else if(e.selectable){if(r===R.value)return;const c=h.store.getSelectedKey();r!==""&&r!=null?h.store.setSelected(r,!0):(r===""||r==null)&&c&&h.store.setSelected(c,!1)}}),t.watch(()=>e.data,r=>{M(r)}),t.watch(()=>e.expandedKeys,()=>{oe()});function M(r){ke();let c=null,C=null;e.checkable?Array.isArray(e.modelValue)?c=e.modelValue.concat():typeof e.modelValue=="string"&&(c=e.modelValue===""?[]:e.modelValue.split(e.separator)):e.selectable&&!Array.isArray(e.modelValue)&&(C=e.modelValue),h.store.setData(r,C,c),oe()}function U(r,c){h.store.setChecked(r,c)}function N(r,c){h.store.setCheckedKeys(r,c)}function D(){h.store.checkAll()}function u(){h.store.clearChecked()}function g(r,c){h.store.setSelected(r,c)}function y(){h.store.clearSelected()}function _(r,c,C=!0){h.store.setExpand(r,c,C)}function ae(r,c){h.store.setExpandKeys(r,c)}function Fe(r){h.store.setExpandAll(r)}function Be(r){return r=r||e.ignoreMode,h.store.getCheckedNodes(r)}function Ie(r){return r=r||e.ignoreMode,h.store.getCheckedKeys(r)}function Te(){return h.store.getIndeterminateNodes()}function Le(){return h.store.getSelectedNode()}function Me(){return h.store.getSelectedKey()}function ze(){return h.store.getExpandNodes()}function Re(){return h.store.getExpandKeys()}function Oe(){return h.store.flatData.filter(r=>r._filterVisible)}function fe(r){return h.store.getNode(r)}function Pe(){return h.store.data}function He(){return h.store.flatData}function xe(){return h.store.flatData.length}function Ue(r,c){return h.store.insertBefore(r,c)}function We(r,c){return h.store.insertAfter(r,c)}function je(r,c){return h.store.append(r,c)}function Xe(r,c){return h.store.prepend(r,c)}function Ye(r){return h.store.remove(r)}function qe(r,c){const C=(L,$)=>{const K=$[e.titleField];return K==null||!K.toString?!1:K.toString().toLowerCase().indexOf(L.toLowerCase())>-1};c=c||e.filterMethod||C,h.store.filter(r,c)}function Je(r){if(!e.checkable)return;r=r??e.showUnloadCheckedNodes;const c=h.store.getCheckedNodes();if(h.store.filter("",(L,$)=>$.checked),!r)return;const C=h.store.getUnloadCheckedKeys();if(C.length){const L=C.map($=>{const K=e.unloadDataList.concat(c);let be=$;return K.some(Se=>Se[e.keyField]===$&&Se[e.titleField]!=null?(be=Se[e.titleField],!0):!1),new W({[e.keyField]:$,[e.titleField]:be,checked:!0,isLeaf:!0},null,e.keyField,!!e.load)});s=L,h.blockNodes.push(...L),de(),le()}}function ue(){return X.value=!0,new Promise((r,c)=>{e.load&&e.load(null,r,c)}).then(r=>{Array.isArray(r)&&M(r)}).catch(()=>{}).then(()=>{X.value=!1})}function Ge(r,c=ie.top){const C=h.store.mapData[r];if(!C||!C.visible)return;let L=-1;for(let K=0;K<o.value;K++)if(h.blockNodes[K][e.keyField]===r){L=K;break}if(L===-1)return;let $=L*e.nodeMinHeight;if(c===ie.center){const K=S.value.clientHeight;$=$-(K-e.nodeMinHeight)/2}else if(c===ie.bottom){const K=S.value.clientHeight;$=$-(K-e.nodeMinHeight)}else typeof c=="number"&&($=$-c);S.value&&(S.value.scrollTop=$)}function oe(){e.expandedKeys.length&&(h.store.setExpandAll(!1,!1),h.store.setExpandKeys(e.expandedKeys,!0))}function pe(){if(s.length){const r=h.store.getUnloadCheckedKeys();s.forEach(c=>{c.checked=r.indexOf(c[e.keyField])>-1})}}function Qe(r){l.emit("check",r),!(!e.cascade&&e.enableLeafOnly&&!r.isLeaf)&&h.store.setChecked(r[e.keyField],r.indeterminate?!1:!r.checked,!0,!0,!0)}function Ze(r){l.emit("select",r),!(e.enableLeafOnly&&!r.isLeaf)&&h.store.setSelected(r[e.keyField],!r.selected)}function ve(r){l.emit("expand",r),h.store.setExpand(r[e.keyField],!r.expand)}function et(r,c,C){if(e.droppable&&c.dataTransfer)try{const $=JSON.parse(c.dataTransfer.getData("node"))[e.keyField],K=r[e.keyField];if(e.beforeDropMethod($,K,C)){if($===K)return;C===P.before?h.store.insertBefore($,K):C===P.body||!r.isLeaf&&r.expand?h.store.prepend($,K):C===P.after&&h.store.insertAfter($,K),l.emit("node-drop",r,c,C,fe($))}}catch(L){throw new Error(L)}}function me(r,c){if(e.checkable){let C=c;Array.isArray(e.modelValue)||(C=C.join(e.separator)),Array.isArray(C)?R.value=C.concat():R.value=C,l.emit("update:modelValue",C)}}function ge(r,c){if(e.selectable&&!e.checkable){const C=c||"";R.value=C,l.emit("update:modelValue",C)}}function tt(){$e.forEach(r=>{h.store.on(r,(...c)=>{l.emit.apply(l,[r,...c])})})}function ke(){f.value=0,p.value=0,S.value&&(S.value.scrollTop=0)}function Ce(){h.blockNodes=h.store.flatData.filter(r=>r.visible),de(),le()}function de(){o.value=h.blockNodes.length,d.value=e.nodeMinHeight*o.value}function le(){ye(),ce()}function ye(){const r=S.value.clientHeight;w.value=Math.max(e.renderNodeAmount,Math.ceil(r/e.nodeMinHeight)+e.bufferNodeAmount)}function ce(r=!1){if(o.value>w.value){const c=S.value.scrollTop,C=Math.floor(c/e.nodeMinHeight);B.value=Math.floor(C/e.bufferNodeAmount)*e.bufferNodeAmount}else B.value=0;r&&b.value===w.value&&j.value===B.value||(i.value=h.blockNodes.slice(B.value,B.value+w.value).map(c=>Object.assign({},c,{_parent:null,children:[]})),f.value=B.value*e.nodeMinHeight,p.value=d.value-(f.value+i.value.length*e.nodeMinHeight))}function lt(){x.value&&window.cancelAnimationFrame(x.value),b.value=w.value,j.value=B.value,x.value=window.requestAnimationFrame(ce.bind(null,!0))}const St={setData:M,setChecked:U,setCheckedKeys:N,checkAll:D,clearChecked:u,setSelected:g,clearSelected:y,setExpand:_,setExpandKeys:ae,setExpandAll:Fe,getCheckedNodes:Be,getCheckedKeys:Ie,getIndeterminateNodes:Te,getSelectedNode:Le,getSelectedKey:Me,getExpandNodes:ze,getExpandKeys:Re,getCurrentVisibleNodes:Oe,getTreeData:Pe,getFlatData:He,getNodesCount:xe,insertBefore:Ue,insertAfter:We,append:je,prepend:Xe,remove:Ye,filter:qe,showCheckedNodes:Je,loadRootNodes:ue,scrollTo:Ge,updateExpandedKeys:oe,updateUnloadStatus:pe,handleTreeScroll:lt,handleNodeCheck:Qe,handleNodeSelect:Ze,handleNodeExpand:ve,handleNodeDrop:et,emitCheckableInput:me,emitSelectableInput:ge,resetSpaceHeights:ke,updateBlockNodes:Ce,updateBlockData:de,updateRender:le,updateRenderAmount:ye,updateRenderNodes:ce,getNode:fe};return t.onMounted(()=>{h.store.on("visible-data-change",Ce),h.store.on("render-data-change",le),h.store.on("checked-change",(c,C)=>{me(c,C),pe()}),h.store.on("selected-change",ge),e.data.length?(M(e.data),e.defaultExpandedKeys.length&&h.store.setExpandKeys(e.defaultExpandedKeys,!0)):typeof e.load=="function"&&e.autoLoad&&((e.modelValue||e.unloadDataList)&&M([]),ue());const r=I.value;r!=null&&r.contentWindow&&r.contentWindow.addEventListener("resize",le)}),t.onBeforeUnmount(()=>{const r=I.value;r!=null&&r.contentWindow&&r.contentWindow.removeEventListener("resize",le),h.store.disposeListeners();const c=A();h.store=c.store,h.blockNodes=c.blockNodes}),tt(),{nonReactive:h,unloadCheckedNodes:s,blockLength:o,blockAreaHeight:d,topSpaceHeight:f,bottomSpaceHeight:p,renderAmount:w,renderAmountCache:b,renderNodes:i,renderStart:B,renderStartCache:j,isRootLoading:X,valueCache:R,debounceTimer:x,topSpaceStyles:T,bottomSpaceStyles:Z,wrapperCls:v,scrollAreaCls:Y,blockAreaCls:O,emptyCls:q,emptyTextDefaultCls:J,loadingCls:ee,loadingWrapperCls:te,loadingIconCls:G,iframeCls:m,treeNodeListeners:k,setData:M,setChecked:U,setCheckedKeys:N,checkAll:D,clearChecked:u,setSelected:g,clearSelected:y,setExpand:_,setExpandKeys:ae,setExpandAll:Fe,getCheckedNodes:Be,getCheckedKeys:Ie,getIndeterminateNodes:Te,getSelectedNode:Le,getSelectedKey:Me,getExpandNodes:ze,getExpandKeys:Re,getCurrentVisibleNodes:Oe,getTreeData:Pe,getFlatData:He,getNodesCount:xe,insertBefore:Ue,insertAfter:We,append:je,prepend:Xe,remove:Ye,filter:qe,showCheckedNodes:Je,loadRootNodes:ue,scrollTo:Ge,updateExpandedKeys:oe,updateUnloadStatus:pe,handleTreeScroll:lt,handleNodeCheck:Qe,handleNodeSelect:Ze,handleNodeExpand:ve,handleNodeDrop:et,emitCheckableInput:me,emitSelectableInput:ge,attachStoreEvents:tt,resetSpaceHeights:ke,updateBlockNodes:Ce,updateBlockData:de,updateRender:le,updateRenderAmount:ye,updateRenderNodes:ce,getNode:fe,scrollArea:S,iframe:I,methods:St}}});function ut(e,l,n,a,s,i){const o=t.resolveComponent("CTreeNode"),d=t.resolveComponent("LoadingIcon");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.wrapperCls)},[t.createElementVNode("div",{ref:"scrollArea",class:t.normalizeClass(e.scrollAreaCls),onScrollPassive:l[0]||(l[0]=t.withModifiers((...f)=>e.handleTreeScroll&&e.handleTreeScroll(...f),["stop"]))},[t.createElementVNode("div",{class:t.normalizeClass(e.blockAreaCls)},[t.createElementVNode("div",{style:t.normalizeStyle(e.topSpaceStyles)},null,4),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.renderNodes,f=>(t.openBlock(),t.createBlock(o,t.mergeProps(e.$props,{key:f[e.keyField],data:f,getNode:e.getNode},t.toHandlers(e.treeNodeListeners),{class:typeof e.nodeClassName=="function"?e.nodeClassName(f):e.nodeClassName,style:{minHeight:`${e.nodeMinHeight}px`,marginLeft:e.usePadding?null:`${f._level*e.nodeIndent}px`,paddingLeft:e.usePadding?`${f._level*e.nodeIndent}px`:null},onCheck:e.handleNodeCheck,onSelect:e.handleNodeSelect,onExpand:e.handleNodeExpand,onNodeDrop:e.handleNodeDrop}),{"node-item-final":t.withCtx(()=>[t.renderSlot(e.$slots,"node-item",{node:f})]),_:2},1040,["data","getNode","class","style","onCheck","onSelect","onExpand","onNodeDrop"]))),128)),t.createElementVNode("div",{style:t.normalizeStyle(e.bottomSpaceStyles)},null,4)],2)],34),t.withDirectives(t.createElementVNode("div",{class:t.normalizeClass(e.emptyCls)},[t.createElementVNode("span",{class:t.normalizeClass(e.emptyTextDefaultCls)},[t.renderSlot(e.$slots,"empty",{},()=>[t.createTextVNode(t.toDisplayString(e.emptyText),1)])],2)],2),[[t.vShow,!e.blockLength]]),t.withDirectives(t.createElementVNode("div",{class:t.normalizeClass(e.loadingCls)},[t.createElementVNode("div",{class:t.normalizeClass(e.loadingWrapperCls)},[t.renderSlot(e.$slots,"loading",{},()=>[t.createVNode(d,{class:t.normalizeClass(e.loadingIconCls)},null,8,["class"])])],2)],2),[[t.vShow,e.loading||e.isRootLoading]]),t.createElementVNode("iframe",{ref:"iframe",class:t.normalizeClass(e.iframeCls)},null,2)],2)}const Ee=ne(ft,[["render",ut]]);function Ke(e){return nt.reduce((l,n)=>(l[n]=function(...a){return e.value[n].apply(e.value,a)},l),{})}const z="ctree-tree-search",re="ctree-tree-node",pt=t.defineComponent({name:"CTreeSearch",inheritAttrs:!1,emits:["checked-change","search","set-data","update:modelValue"],components:{CTree:Ee},props:{modelValue:[String,Number,Array],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}},setup(e,{emit:l,attrs:n,expose:a}){const s=t.reactive({checked:!1,indeterminate:!1,disabled:!1}),i=t.ref(!1),o=t.ref(""),d=t.ref(void 0),f=t.ref(0),p=t.ref();let w=Ke(p);const b=t.computed({get:()=>e.modelValue,set:N=>{A(),l("update:modelValue",N)}}),B=t.computed(()=>[`${z}__wrapper`]),j=t.computed(()=>[`${z}__search`]),X=t.computed(()=>[`${z}__check-all-wrapper`]),R=t.computed(()=>[`${z}__check-all`,`${re}__checkbox`,{[`${re}__checkbox_checked`]:s.checked,[`${re}__checkbox_indeterminate`]:s.indeterminate,[`${re}__checkbox_disabled`]:e.searchDisabled||s.disabled}]),x=t.computed(()=>[`${z}__input-wrapper`]),S=t.computed(()=>[`${z}__input`,{[`${z}__input_disabled`]:e.searchDisabled}]),I=t.computed(()=>[`${z}__action-wrapper`]),T=t.computed(()=>[`${z}__checked-button`,{[`${z}__checked-button_active`]:i.value}]),Z=t.computed(()=>[`${z}__tree-wrapper`]),v=t.computed(()=>[`${z}__footer`]),Y=t.computed(()=>"checkable"in n&&n.checkable!==!1);function O(){o.value=""}function q(){return o.value}function J(N){let D=N;return typeof N!="string"&&(D=o.value),new Promise((u,g)=>{clearTimeout(d.value),d.value=setTimeout(()=>{if(!(D.length>0&&D.length<e.searchLength))if(i.value=!1,l("search",D),typeof e.searchMethod=="function"){const y=e.searchMethod(D);Promise.resolve(y).then(()=>{k(),u()})}else e.searchRemote?p.value.loadRootNodes().then(()=>{k(),u()}):(p.value.filter(D),k(),u())},e.searchDebounceTime)})}function ee(){if(e.searchDisabled||s.disabled)return;const N=p.value.getCurrentVisibleNodes().map(D=>D[p.value.keyField]);s.checked||s.indeterminate?p.value.setCheckedKeys(N,!1):p.value.setCheckedKeys(N,!0),k()}function te(){J()}function G(){const N=()=>{i.value=!i.value,i.value?p.value.showCheckedNodes():p.value.filter(o.value,()=>!0),k()};o.value?(O(),J().then(()=>{N()})):N()}function m(){A(),k()}function k(){const N=p.value.getCurrentVisibleNodes(),D=N.length;let u=!1,g=!1,y=!1;for(let _=0;_<D;_++){const ae=N[_];if(ae.checked?u=!0:g=!0,u&&g||ae.indeterminate){y=!0,s.checked=!1,s.indeterminate=!0;break}}y||(s.checked=u,s.indeterminate=!1)}function A(){f.value=p.value.getCheckedKeys().length}function h(N,D){k(),l("checked-change",N,D)}function M(){l("set-data"),m()}return t.onMounted(()=>{Y.value&&!f.value&&m()}),{...w,treeModelValue:b,setChecked:(N,D)=>{p.value.setChecked(N,D)},checkAllStatus:s,isShowingChecked:i,keyword:o,debounceTimer:d,checkedCount:f,wrapperCls:B,searchCls:j,checkAllWrapperCls:X,checkboxCls:R,inputWrapperCls:x,inputCls:S,actionWrapperCls:I,checkedButtonCls:T,treeWrapperCls:Z,footerCls:v,checkable:Y,treeRef:p,handleCheckAll:ee,handleSearch:te,handleShowChecked:G,updateCheckedCount:A,handleSetData:m,updateCheckAllStatus:k,getKeyword:q,checkedChange:h,onSetData:M,clearKeyword:O,search:J}}}),mt=["placeholder","disabled"],gt={style:{float:"right"}};function kt(e,l,n,a,s,i){const o=t.resolveComponent("CTree");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.wrapperCls)},[t.createElementVNode("div",{class:t.normalizeClass(e.searchCls)},[e.showCheckAll&&e.checkable?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(e.checkAllWrapperCls)},[t.createElementVNode("div",{class:t.normalizeClass(e.checkboxCls),onClick:l[0]||(l[0]=(...d)=>e.handleCheckAll&&e.handleCheckAll(...d))},null,2)],2)):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(e.inputWrapperCls)},[t.renderSlot(e.$slots,"search-input",{},()=>[t.withDirectives(t.createElementVNode("input",{"onUpdate:modelValue":l[1]||(l[1]=d=>e.keyword=d),type:"text",class:t.normalizeClass(e.inputCls),placeholder:e.searchPlaceholder,disabled:e.searchDisabled,onInput:l[2]||(l[2]=(...d)=>e.handleSearch&&e.handleSearch(...d))},null,42,mt),[[t.vModelText,e.keyword]])])],2),t.createElementVNode("div",{class:t.normalizeClass(e.actionWrapperCls)},[e.showCheckedButton&&e.checkable?(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(e.checkedButtonCls),onClick:l[3]||(l[3]=(...d)=>e.handleShowChecked&&e.handleShowChecked(...d))},t.toDisplayString(e.checkedButtonText),3)):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"actions")],2)],2),t.createElementVNode("div",{class:t.normalizeClass(e.treeWrapperCls)},[t.createVNode(o,t.mergeProps({ref:"treeRef"},e.$attrs,{modelValue:e.treeModelValue,"onUpdate:modelValue":l[4]||(l[4]=d=>e.treeModelValue=d),onSetData:e.onSetData,onCheckedChange:e.checkedChange}),t.createSlots({_:2},[t.renderList(e.$slots,(d,f)=>({name:"default",fn:t.withCtx(p=>[t.renderSlot(e.$slots,f,t.normalizeProps(t.guardReactiveProps(p)))])}))]),1040,["modelValue","onSetData","onCheckedChange"])],2),e.showFooter&&e.checkable?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(e.footerCls)},[t.renderSlot(e.$slots,"footer",{},()=>[t.createElementVNode("span",gt,"已选 "+t.toDisplayString(e.checkedCount)+" 个",1)])],2)):t.createCommentVNode("",!0)],2)}const Ve=ne(pt,[["render",kt]]),H="ctree-tree-drop",Ae="ctree-tree-search",Ct=t.defineComponent({name:"CTreeDrop",inheritAttrs:!1,emits:["clear","checked-change","dropdown-visible-change","update:modelValue"],components:{CTreeSearch:Ve},props:{modelValue:[String,Number,Array],dropHeight:{type:Number,default:300},dropPlaceholder:{type:String},dropDisabled:{type:Boolean,default:!1},clearable:{type:Boolean,default:!1},placement:{type:String,default:Ne["bottom-start"]},transfer:{type:Boolean,default:!1},dropdownClassName:[String,Array],dropdownMinWidth:{type:Number},dropdownWidthFixed:{type:Boolean,default:!1}},setup(e,{attrs:l,emit:n}){const a=t.ref(!1),s=t.ref(0),i=t.ref(""),o=t.ref(),d=t.ref(),f=t.ref(),p=t.reactive({checkedNodes:[],checkedKeys:[],selectedNode:void 0,selectedKey:void 0}),w=t.computed({get:()=>e.modelValue,set:m=>{n("update:modelValue",m)}}),b=t.computed(()=>[`${H}__wrapper`]),B=t.computed(()=>[`${H}__reference`]),j=t.computed(()=>[`${Ae}__input`,`${H}__display-input`,{[`${H}__display-input_focus`]:a.value,[`${Ae}__input_disabled`]:e.dropDisabled}]),X=t.computed(()=>{let m=!1;return typeof e.dropPlaceholder=="string"&&(I.value?m=s.value===0:T.value&&(m=i.value==="")),[`${H}__display-input-text`,{[`${H}__display-input-placeholder`]:m}]}),R=t.computed(()=>[`${H}__display-icon-drop`,{[`${H}__display-icon-drop_active`]:a.value}]),x=t.computed(()=>[`${H}__display-icon-clear`]),S=t.computed(()=>{const m=Array.isArray(e.dropdownClassName)?e.dropdownClassName:[e.dropdownClassName];return[`${H}__dropdown`,...m]}),I=t.computed(()=>"checkable"in l&&l.checkable!==!1),T=t.computed(()=>"selectable"in l&&l.selectable!==!1),Z=t.computed(()=>I.value?s.value===0&&typeof e.dropPlaceholder=="string"?e.dropPlaceholder:`已选 ${s.value} 个`:T.value?i.value===""&&typeof e.dropPlaceholder=="string"?e.dropPlaceholder:i.value:e.dropPlaceholder||""),v=t.computed(()=>I.value?s.value!==0:T.value?i.value!=="":!1);function Y(){const m=o.value.getBoundingClientRect(),k=m.width,A=m.height,h=`${typeof e.dropdownMinWidth=="number"?e.dropdownMinWidth:k}px`;d.value.style.minWidth=h,d.value.style.width=e.dropdownWidthFixed?h:"auto";const M=d.value.getBoundingClientRect(),U=window.getComputedStyle(d.value),N=parseFloat(U.marginLeft)+parseFloat(U.marginRight),D=parseFloat(U.marginTop)+parseFloat(U.marginBottom),u=M.width+N,g=M.height/.8+D;let y=0,_=0;switch(e.transfer&&(y=-999,_=-999),e.placement){case"bottom-start":e.transfer?(y=window.pageYOffset+m.bottom,_=window.pageXOffset+m.left):y=A;break;case"bottom-end":e.transfer?(y=window.pageYOffset+m.bottom,_=window.pageXOffset+m.right-u):(y=A,_=k-u);break;case"bottom":e.transfer?(y=window.pageYOffset+m.bottom,_=window.pageXOffset+m.left+(k-u)/2):(y=A,_=(k-u)/2);break;case"top-start":e.transfer?(y=window.pageYOffset+m.top-g,_=window.pageXOffset+m.left):y=-g;break;case"top-end":e.transfer?(y=window.pageYOffset+m.top-g,_=window.pageXOffset+m.right-u):(y=-g,_=k-u);break;case"top":e.transfer?(y=window.pageYOffset+m.top-g,_=window.pageXOffset+m.left+(k-u)/2):(y=-g,_=(k-u)/2);break}d.value.style.top=`${y}px`,d.value.style.left=`${_}px`}function O(){e.dropDisabled||(a.value=!a.value)}function q(m){var k,A;!((k=o.value)!=null&&k.contains(m.target))&&!((A=d.value)!=null&&A.contains(m.target))&&(a.value=!1)}function J(){n("clear"),I.value?f.value.clearChecked():T.value&&f.value.clearSelected()}function ee(m,k){p.checkedNodes=m,p.checkedKeys=k,s.value=k.length,n("checked-change",m,k)}function te(m,k){if(p.selectedNode=m,p.selectedKey=k,m){const A=f.value.$refs.treeRef.titleField;i.value=m[A]}else k?i.value=k:i.value="";a.value=!1}function G(){const m=f.value.$refs.treeRef;if(p.checkedNodes=f.value.getCheckedNodes(),p.checkedKeys=f.value.getCheckedKeys(),p.selectedNode=f.value.getSelectedNode(),p.selectedKey=f.value.getSelectedKey(),I.value&&(s.value=p.checkedKeys.length),T.value&&e.modelValue!=null){const k=f.value.getNode(e.modelValue);if(k){const A=m.titleField;i.value=k[A]}else i.value=e.modelValue}}return t.onMounted(()=>{document.addEventListener("click",q),e.transfer&&document.body.appendChild(d.value),G()}),t.watch(()=>a.value,m=>{n("dropdown-visible-change",m),m?t.nextTick(()=>{Y()}):f.value.getKeyword()&&(f.value.clearKeyword(),f.value.search())}),{...Ke(f),treeSearchValue:w,dropdownVisible:a,checkedCount:s,selectedTitle:i,slotProps:p,wrapperCls:b,referenceCls:B,displayInputCls:j,displayInputTextCls:X,dropIconCls:R,clearIconCls:x,dropdownCls:S,checkable:I,selectable:T,displayValue:Z,showClearIcon:v,referenceRef:o,dropdownRef:d,treeSearchRef:f,locateDropdown:Y,handleRefClick:O,handleDocumentClick:q,handleClear:J,handleCheckedChange:ee,handleSelectedChange:te,handleSetData:G}}});function yt(e,l,n,a,s,i){const o=t.resolveComponent("CTreeSearch");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.wrapperCls)},[t.createElementVNode("div",{ref:"referenceRef",class:t.normalizeClass(e.referenceCls),onClick:l[1]||(l[1]=(...d)=>e.handleRefClick&&e.handleRefClick(...d))},[t.renderSlot(e.$slots,"default",t.normalizeProps(t.guardReactiveProps(e.slotProps)),()=>[t.createElementVNode("div",{class:t.normalizeClass(e.displayInputCls)},[t.createElementVNode("span",{class:t.normalizeClass(e.displayInputTextCls)},[t.renderSlot(e.$slots,"display",t.normalizeProps(t.guardReactiveProps(e.slotProps)),()=>[t.createTextVNode(t.toDisplayString(e.displayValue),1)])],2),e.dropDisabled?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("i",{class:t.normalizeClass(e.dropIconCls)},null,2),e.clearable&&e.showClearIcon?t.renderSlot(e.$slots,"clear",{key:0},()=>[t.createElementVNode("i",{class:t.normalizeClass(e.clearIconCls),onClick:l[0]||(l[0]=t.withModifiers((...d)=>e.handleClear&&e.handleClear(...d),["stop"]))},null,2)]):t.createCommentVNode("",!0)],64))],2)])],2),t.createVNode(t.Transition,{name:"ctree-dropdown"},{default:t.withCtx(()=>[t.withDirectives(t.createElementVNode("div",{ref:"dropdownRef",class:t.normalizeClass(e.dropdownCls),style:t.normalizeStyle({height:`${e.dropHeight}px`})},[t.createVNode(o,t.mergeProps({ref:"treeSearchRef",modelValue:e.treeSearchValue,"onUpdate:modelValue":l[2]||(l[2]=d=>e.treeSearchValue=d)},e.$attrs,{onSetData:e.handleSetData,onCheckedChange:e.handleCheckedChange,onSelectedChange:e.handleSelectedChange}),t.createSlots({_:2},[t.renderList(e.$slots,(d,f)=>({name:f,fn:t.withCtx(p=>[t.renderSlot(e.$slots,f,t.normalizeProps(t.guardReactiveProps(p)))])}))]),1040,["modelValue","onSetData","onCheckedChange","onSelectedChange"])],6),[[t.vShow,e.dropdownVisible]])]),_:3})],2)}const bt=ne(Ct,[["render",yt]]),_t="";F.TreeNode=W,F.TreeStore=we,F.VTreeDrop=bt,F.VTreeNode=_e,F.VTreeSearch=Ve,F.default=Ee,Object.defineProperties(F,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
{
"name": "wang-tree",
"version": "3.0.4",
"version": "3.0.5",
"types": "./types",

@@ -5,0 +5,0 @@ "description": "A vue tree component using virtual list.",

@@ -34,3 +34,3 @@ <template>

>
<template slot="node-item-final">
<template #node-item-final>
<slot name="node-item" :node="node"></slot>

@@ -37,0 +37,0 @@ </template>

@@ -30,4 +30,3 @@ <template>

>
<component v-if="renderFunction" :is="renderComponent"></component>
<slot v-else name="node-item-final">{{ data ? data[titleField] : '' }}</slot>
<slot name="node-item-final">{{ data ? data[titleField] : '' }}</slot>
</div>

@@ -34,0 +33,0 @@ </div>

Sorry, the diff of this file is too big to display