vue-tree-polyfill
Version:
A vue tree component using virtual list.
1 lines • 55.1 kB
JavaScript
(function(U,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(U=typeof globalThis<"u"?globalThis:U||self,e(U.Vtree={},U.Vue))})(this,function(U,e){"use strict";var Lt=Object.defineProperty;var Mt=(U,e,ce)=>e in U?Lt(U,e,{enumerable:!0,configurable:!0,writable:!0,value:ce}):U[e]=ce;var I=(U,e,ce)=>(Mt(U,typeof e!="symbol"?e+"":e,ce),ce);const ce=["_level","_filterVisible","_parent","_loading","_loaded","_remote","_keyField","children","setChildren"];class oe{constructor(c,n=null,t="id",s=!1){I(this,"_level",0);I(this,"checked",!1);I(this,"selected",!1);I(this,"indeterminate",!1);I(this,"disabled",!1);I(this,"expand",!1);I(this,"visible",!0);I(this,"_filterVisible",!0);I(this,"_parent",null);I(this,"children",[]);I(this,"isLeaf",!1);I(this,"_loading",!1);I(this,"_loaded",!1);this._keyField=t,this._remote=s;for(let l in c)ce.indexOf(l)===-1&&(this[l]=c[l]);this[t]==null&&(this[t]=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(c.children)&&this.setChildren(c.children),this.children.length&&(this._loaded=!0),this._remote||(this.isLeaf=!this.children.length)}setChildren(c){this.children=c.map(n=>new oe(Object.assign({},n),this,this._keyField,this._remote))}}var ue=(r=>(r.none="none",r.parents="parents",r.children="children",r))(ue||{});const Ae=["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","updateNode","updateNodes","scrollTo"],Re=[...Ae,"clearKeyword","getKeyword","search"];var Ke=(r=>(r["bottom-start"]="bottom-start",r["bottom-end"]="bottom-end",r.bottom="bottom",r["top-start"]="top-start",r["top-end"]="top-end",r.top="top",r))(Ke||{}),me=(r=>(r.top="top",r.center="center",r.bottom="bottom",r))(me||{}),te=(r=>(r.before="before",r.body="body",r.after="after",r))(te||{}),ye=(r=>(r.dashed="dashed",r.solid="solid",r))(ye||{});class je{constructor(){I(this,"listenersMap",{})}on(c,n){this.listenersMap[c]||(this.listenersMap[c]=[]);let t=[];Array.isArray(n)?t=n:t=[n],t.forEach(s=>{this.listenersMap[c].indexOf(s)===-1&&this.listenersMap[c].push(s)})}off(c,n){if(this.listenersMap[c])if(!n)this.listenersMap[c]=[];else{const t=this.listenersMap[c].indexOf(n);t>-1&&this.listenersMap[c].splice(t,1)}}emit(c,...n){if(!this.listenersMap[c])return;const t=this.listenersMap[c].length;for(let s=0;s<t;s++)this.listenersMap[c][s](...n)}disposeListeners(){for(const c in this.listenersMap)this.listenersMap[c]=[]}}class Ve extends je{constructor(n){super();I(this,"data",[]);I(this,"flatData",[]);I(this,"mapData",Object.create(null));I(this,"unloadCheckedKeys",[]);I(this,"unloadSelectedKey",null);I(this,"currentSelectedKey",null);this.options=n}insertIntoFlatData(n,t){this.flatData=this.flatData.slice(0,n).concat(t,this.flatData.slice(n))}setData(n,t=null,s=null){this.data=n.map(l=>new oe(l,null,this.options.keyField,!!this.options.load));for(let l in this.mapData)delete this.mapData[l];this.currentSelectedKey=null,this.flatData=this.flattenData(this.data),this.setUnloadCheckedKeys(s||[]),t&&(this.currentSelectedKey=null,this.setUnloadSelectedKey(t)),this.emit("visible-data-change"),this.emit("set-data")}setChecked(n,t,s=!0,l=!0,o=!1){const a=this.mapData[n];if(!a)return this.setUnloadChecked(n,t,s,l);a.disabled||a.checked&&t||!a.checked&&!a.indeterminate&&!t||(this.options.cascade?(this.checkNodeDownward(a,t,o),this.checkNodeUpward(a)):a.checked=t,s&&(a.checked?this.emit("check",a):this.emit("uncheck",a)),this.triggerCheckedChange(s,l))}setUnloadChecked(n,t,s=!0,l=!0){const o=this.findIndex(n,this.unloadCheckedKeys);t?o===-1&&this.unloadCheckedKeys.push(n):o!==-1&&this.unloadCheckedKeys.splice(o,1),this.triggerCheckedChange(s,l)}setCheckedKeys(n,t,s=!0,l=!0){n.forEach(o=>{this.setChecked(o,t,!1,!1)}),this.triggerCheckedChange(s,l)}checkAll(n=!0,t=!0){if(this.options.cascade){const s=l=>{l.forEach(o=>{o.disabled?s(o.children):this.setChecked(o[this.options.keyField],!0,!1,!1)})};s(this.data)}else{const s=this.flatData.length;for(let l=0;l<s;l++){const o=this.flatData[l];this.setChecked(o[this.options.keyField],!0,!1,!1)}}this.triggerCheckedChange(n,t)}clearChecked(n=!0,t=!0){this.getCheckedNodes().forEach(l=>{this.setChecked(l[this.options.keyField],!1,!1,!1)}),this.unloadCheckedKeys=[],this.triggerCheckedChange(n,t)}triggerCheckedChange(n=!0,t=!0){n&&this.emit("checked-change",this.getCheckedNodes(),this.getCheckedKeys()),t&&this.emit("render-data-change")}triggerSelectedChange(n=!0,t=!0){n&&this.emit("selected-change",this.getSelectedNode(),this.getSelectedKey()),t&&this.emit("render-data-change")}setSelected(n,t,s=!0,l=!0){const o=this.mapData[n];if(!o)return this.setUnloadSelected(n,t,s,l);o.disabled||o.selected!==t&&(n===this.currentSelectedKey?t||(o.selected=t,this.currentSelectedKey=null):t&&(this.currentSelectedKey!==null&&this.mapData[this.currentSelectedKey]&&(this.mapData[this.currentSelectedKey].selected=!1),o.selected=t,this.currentSelectedKey=o[this.options.keyField],this.unloadSelectedKey=null),s&&(o.selected?this.emit("select",o):this.emit("unselect",o)),this.triggerSelectedChange(s,l))}setUnloadSelected(n,t,s=!0,l=!0){t?(this.currentSelectedKey=null,this.unloadSelectedKey=n):this.unloadSelectedKey===n&&(this.unloadSelectedKey=null),this.triggerSelectedChange(s,l)}clearSelected(n=!0,t=!0){this.currentSelectedKey&&this.mapData[this.currentSelectedKey]?this.setSelected(this.currentSelectedKey,!1,n,t):this.unloadSelectedKey!==null&&(this.unloadSelectedKey=null,this.triggerSelectedChange(n,t))}setExpand(n,t,s=!1,l=!0,o=!0){const a=this.mapData[n];if(!(!a||!s&&a.isLeaf)&&a.expand!==t){if(!a.isLeaf){if(typeof this.options.load=="function"){if(!a._loaded&&!a._loading&&t){a._loading=!0,o&&this.emit("visible-data-change"),new Promise((h,u)=>{const b=this.options.load;b(a,h,u)}).then(h=>{Array.isArray(h)&&(this.loadChildren(a,h,t),this.emit("set-data"))}).catch(h=>{let u=h;h instanceof Error||(u=new Error(h)),console.error("[VTree] load tree nodes error.",u)}).then(()=>{a._loading=!1,l&&this.emit("expand",a),o&&this.emit("visible-data-change")});return}else if(a._loading)return}a.expand=t;let d=a.children.concat();for(;d.length;){const h=d.pop();h&&(h.expand&&h.children.length&&(d=h.children.concat(d)),h._filterVisible===!1?h.visible=!1:h.visible=h._parent===null||h._parent.expand&&h._parent.visible)}l&&this.emit("expand",a),o&&this.emit("visible-data-change")}s&&a._parent&&t&&this.setExpand(a._parent[this.options.keyField],t,s,!1,o)}}setExpandKeys(n,t,s=!0){n.forEach(l=>{this.setExpand(l,t,!1,!1,!1)}),s&&this.emit("visible-data-change")}setExpandAll(n,t=!0){this.flatData.forEach(s=>{(!this.options.load||s._loaded)&&this.setExpand(s[this.options.keyField],n,!1,!1,!1)}),t&&this.emit("visible-data-change")}isChildrenChanged(n,t){var s;return"children"in t&&(!!n.children.length||!!((s=t.children)!=null&&s.length))}updateNode(n,t,s=!0,l=!0){var K;const o=this.mapData[n];if(!o)return;const a={},d=[this.options.keyField,"indeterminate","visible","isLeaf"];Object.keys(t).forEach(E=>{!E.startsWith("_")&&!d.includes(E)&&(a[E]=t[E])});const h=this.getCheckedKeys(),u=this.getSelectedKey();let b=this.isChildrenChanged(o,a);"children"in a&&(o.children.length||(K=a.children)!=null&&K.length)&&(this.removeChildren(n,!1,!1),Array.isArray(a.children)&&this.loadChildren(o,a.children,o.expand),delete a.children),"checked"in a&&(this.setChecked(n,a.checked,!1,!1),delete a.checked),"selected"in a&&(this.setSelected(n,a.selected,!1,!1),delete a.selected),"expand"in a&&(this.setExpand(n,a.expand,!1,!1,!1),delete a.expand),Object.keys(a).forEach(E=>{o[E]=a[E]});const g=this.getCheckedKeys(),L=this.getSelectedKey();s&&(JSON.stringify(g.sort())!==JSON.stringify(h.sort())&&this.triggerCheckedChange(!0,!1),L!==u&&this.triggerSelectedChange(!0,!1)),l&&(b&&this.emit("set-data"),this.emit("visible-data-change"))}updateNodes(n){const t=n.filter(h=>h[this.options.keyField]!=null);if(!t.length)return;const s=this.getCheckedKeys(),l=this.getSelectedKey();let o=!1;t.forEach(h=>{const u=h[this.options.keyField],b=this.mapData[u];b&&(o=o||this.isChildrenChanged(b,h),this.updateNode(u,h,!1,!1))});const a=this.getCheckedKeys(),d=this.getSelectedKey();JSON.stringify(a.sort())!==JSON.stringify(s.sort())&&this.triggerCheckedChange(!0,!1),d!==l&&this.triggerSelectedChange(!0,!1),o&&this.emit("set-data"),this.emit("visible-data-change")}getCheckedNodes(n=this.options.ignoreMode){if(n===ue.children){const t=[],s=l=>{l.forEach(o=>{o.checked?t.push(o):!o.isLeaf&&o.indeterminate&&s(o.children)})};return s(this.data),t}else return this.flatData.filter(t=>n===ue.parents?t.checked&&t.isLeaf:t.checked)}getCheckedKeys(n=this.options.ignoreMode){return this.getCheckedNodes(n).map(t=>t[this.options.keyField]).concat(this.unloadCheckedKeys)}getIndeterminateNodes(){return this.flatData.filter(n=>n.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(n=>!n.isLeaf&&n.expand)}getExpandKeys(){return this.getExpandNodes().map(n=>n[this.options.keyField])}getNode(n){return this.mapData[n]||null}insertBefore(n,t,s=!0,l=!0){const o=this.getInsertedNode(n,t);if(!o)return null;this.remove(o[this.options.keyField],!1,!1);const d=this.mapData[t]._parent,h=this.findIndex(t,d&&d.children),u=this.findIndex(t),b=d&&-1||this.findIndex(t,this.data);return this.insertIntoStore(o,d,h,u,b,s,l),l&&this.emit("visible-data-change"),o}insertAfter(n,t,s=!0,l=!0){const o=this.getInsertedNode(n,t);if(!o)return null;this.remove(o[this.options.keyField],!1,!1);const a=this.mapData[t],d=a._parent,h=this.findIndex(t,d&&d.children)+1,u=this.flatData.length,b=this.findIndex(t);let g=b+1;for(let K=b+1;K<=u;K++){if(K===u){g=K;break}if(this.flatData[K]._level<=a._level){g=K;break}}const L=d&&-1||this.findIndex(t,this.data)+1;return this.insertIntoStore(o,d,h,g,L,s,l),l&&this.emit("visible-data-change"),o}append(n,t,s=!0,l=!0){const o=this.mapData[t];if(!o.isLeaf){const h=o.children.length;return this.insertAfter(n,o.children[h-1][this.options.keyField],s,l)}const a=this.getInsertedNode(n,t,!0);if(!a)return null;this.remove(a[this.options.keyField],!1,!1);const d=this.findIndex(t)+1;return this.insertIntoStore(a,o,0,d,void 0,s,l),l&&this.emit("visible-data-change"),a}prepend(n,t,s=!0,l=!0){const o=this.mapData[t];if(!o.isLeaf)return this.insertBefore(n,o.children[0][this.options.keyField],s,l);const a=this.getInsertedNode(n,t,!0);if(!a)return null;this.remove(a[this.options.keyField],!1,!1);const d=this.findIndex(t)+1;return this.insertIntoStore(a,o,0,d,void 0,s,l),l&&this.emit("visible-data-change"),a}remove(n,t=!0,s=!0){const l=this.mapData[n];if(!l)return null;const o=this.findIndex(l);if(o===-1)return null;let a=1;const d=this.flatData.length;for(let u=o+1;u<d&&this.flatData[u]._level>l._level;u++)a++;this.flatData.splice(o,a);const h=u=>{const b=this.mapData[u];delete this.mapData[u],b.children.forEach(g=>h(g[this.options.keyField]))};if(h(n),!l._parent){const u=this.findIndex(l,this.data);u>-1&&this.data.splice(u,1)}if(l._parent){const u=this.findIndex(l,l._parent.children);u!==-1&&l._parent.children.splice(u,1),l._parent.isLeaf=!l._parent.children.length,l._parent.isLeaf&&(l._parent.expand=!1,l._parent.indeterminate=!1),this.updateMovingNodeStatus(l,t,s)}return s&&this.emit("visible-data-change"),l}removeChildren(n,t=!0,s=!0){const l=this.mapData[n];if(!l||!l.children.length)return null;let a=l.children[0];const d=this.findIndex(l);if(d===-1)return null;let h=0;const u=this.flatData.length;for(let b=d+1;b<u&&this.flatData[b]._level>l._level;b++)delete this.mapData[this.flatData[b][this.options.keyField]],h++,this.flatData[b].selected&&(a=this.flatData[b]);return this.flatData.splice(d+1,h),l.children.splice(0,l.children.length),l.isLeaf=!0,l.indeterminate=!1,this.updateMovingNodeStatus(a,t,s),s&&this.emit("visible-data-change"),l}loadChildren(n,t,s){const l=this.findIndex(n);if(l===-1)return;n._loaded=!0,n.expand=s,n.setChildren(t),n.isLeaf=!n.children.length;const o=this.getCheckedKeys(),a=this.flattenData(n.children,this.getSelectedKey()===null);this.insertIntoFlatData(l+1,a),this.setUnloadCheckedKeys(o),this.unloadSelectedKey!==null&&this.setUnloadSelectedKey(this.unloadSelectedKey),this.checkNodeUpward(n,!0)}getInsertedNode(n,t,s=!1){const l=this.mapData[t];if(!l)return null;const o=s?l:l._parent;if(n instanceof oe)return n[this.options.keyField]===t?null:n;if(typeof n=="object"){if(n[this.options.keyField]===t)return null;const a=this.mapData[n[this.options.keyField]];return a||new oe(n,o,this.options.keyField,!!this.options.load)}else return!this.mapData[n]||n===t?null:this.mapData[n]}insertIntoStore(n,t,s,l,o,a=!0,d=!0){if(l===-1)return;s!==-1&&t&&t.children.splice(s,0,n),n._parent=t,t?(t.isLeaf=!1,this.setExpand(t[this.options.keyField],!0,!1,!1,!1)):typeof o=="number"&&o>-1&&this.data.splice(o,0,n);const h=this.flattenData([n]);n._level=t?t._level+1:0,h.forEach(u=>u._level=u._parent?u._parent._level+1:0),this.insertIntoFlatData(l,h),this.updateMovingNodeStatus(n,a,d)}updateMovingNodeStatus(n,t=!0,s=!0){this.checkNodeUpward(n),this.triggerCheckedChange(t,s),n.selected&&this.setSelected(n[this.options.keyField],!0,t,s)}filter(n,t){const s=[];this.flatData.forEach(l=>{l._filterVisible=l._parent&&l._parent._filterVisible||t(n,l),l.visible=l._filterVisible,l._filterVisible&&s.push(l)}),s.forEach(l=>{const o=[];let a=l._parent;for(;a;)o.unshift(a),a=a._parent;o.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)}),l.visible=l._parent===null||l._parent.expand&&l._parent.visible}),this.emit("visible-data-change")}setUnloadCheckedKeys(n){this.unloadCheckedKeys=n;const t=n.concat(),s=this.unloadCheckedKeys.length;for(let o=s-1;o>=0;o--){const a=this.unloadCheckedKeys[o];this.mapData[a]&&(this.setChecked(a,!0,!1,!1),this.unloadCheckedKeys.splice(o,1))}const l=this.getCheckedKeys();l.length===t.length&&l.every(o=>t.some(a=>a===o))||this.emit("checked-change",this.getCheckedNodes(),l)}setUnloadSelectedKey(n){const t=this.getSelectedKey();this.mapData[n]?(this.setSelected(n,!0,!1),this.unloadSelectedKey=null):(this.currentSelectedKey&&this.setSelected(this.currentSelectedKey,!1,!1),this.unloadSelectedKey=n);const s=this.getSelectedKey();s!==t&&this.emit("selected-change",this.getSelectedNode(),s)}flattenData(n,t=!0,s=[]){const l=n.length;for(let o=0;o<l;o++){const a=n[o],d=a[this.options.keyField];if(s.push(a),this.mapData[d])throw new Error("[VTree] Duplicate tree node key.");this.mapData[d]=a,a.checked&&this.options.cascade&&this.checkNodeDownward(a,!0),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,s)}return this.options.cascade&&l&&this.checkNodeUpward(n[0]),s}checkNodeDownward(n,t,s=!1){if(n.children.forEach(l=>{this.checkNodeDownward(l,t,s)}),n.isLeaf||this.options.load&&!n.children.length){if(!n.disabled){if(s&&!this.options.filteredNodeCheckable&&!n._filterVisible)return;n.checked=t,n.indeterminate=!1}}else this.checkParentNode(n)}checkNodeUpward(n,t=!1){let s=t?n:n._parent;for(;s;)this.checkParentNode(s),s=s._parent}checkParentNode(n){const t=n.children.length;if(!t)return;let s=!1,l=!1,o=!1;for(let a=0;a<t;a++){const d=n.children[a];if(d.checked?s=!0:l=!0,s&&l||d.indeterminate){o=!0,n.checked=!1,n.indeterminate=!0;break}}o||(n.checked=s,n.indeterminate=!1)}findIndex(n,t=this.flatData){if(t!==null){let s=n instanceof oe?n[this.options.keyField]:n;const l=t.length;for(let o=0;o<l;o++)if(t[0]instanceof oe){if(s===t[o][this.options.keyField])return o}else if(s===t[o])return o}return-1}}const Xe=e.defineComponent({name:"CLoadingIcon"}),Ye=(r,c)=>{const n=r.__vccOpts||r;for(const[t,s]of c)n[t]=s;return n},Je={viewBox:"0 0 50 50"},qe=[e.createElementVNode("circle",{class:"vtree-loading-icon__circle",cx:"25",cy:"25",r:"20",fill:"none","stroke-width":"5","stroke-miterlimit":"10"},null,-1)];function Qe(r,c,n,t,s,l){return e.openBlock(),e.createElementBlock("svg",Je,qe)}const Te=Ye(Xe,[["render",Qe]]),ge=["expand","check","click","select","node-dblclick","node-right-click","node-dragstart","node-dragenter","node-dragover","node-dragleave","node-drop"],$e=["expand","select","unselect","selected-change","check","uncheck","checked-change","set-data"],Ce=[...ge,...$e],be=["search",...Ce],Ge=["clear","dropdown-visible-change",...be],D="vtree-tree-node",Ze=(r,c)=>{const{dragoverBody:n,dragoverBefore:t,dragoverAfter:s}=c,l=e.computed(()=>[`${D}__indent-wrapper`]),o=e.computed(()=>{var E,M,H,w,F;return[`${D}__wrapper`,{[`${D}__wrapper_is-leaf`]:(E=r.data)==null?void 0:E.isLeaf,[`${D}_disabled`]:r.disableAll||((M=r.data)==null?void 0:M.disabled)},{[`${D}_checked`]:r.checkable&&((H=r.data)==null?void 0:H.checked),[`${D}_indeterminate`]:r.checkable&&((w=r.data)==null?void 0:w.indeterminate)},{[`${D}_selected`]:(F=r.data)==null?void 0:F.selected}]}),a=e.computed(()=>[`${D}__node-body`,{[`${D}__drop_active`]:n.value}]),d=e.computed(()=>[`${D}__drop`,{[`${D}__drop_active`]:t.value}]),h=e.computed(()=>[`${D}__drop`,{[`${D}__drop_active`]:s.value}]),u=e.computed(()=>[`${D}__square`,`${D}__checkbox_wrapper`]),b=e.computed(()=>{var E;return[`${D}__square`,`${D}__expand`,{[`${D}__expand_active`]:(E=r.data)==null?void 0:E.expand}]}),g=e.computed(()=>[`${D}__loading-icon`]),L=e.computed(()=>{var E,M,H;return[`${D}__checkbox`,{[`${D}__checkbox_checked`]:(E=r.data)==null?void 0:E.checked,[`${D}__checkbox_indeterminate`]:(M=r.data)==null?void 0:M.indeterminate,[`${D}__checkbox_disabled`]:r.disableAll||((H=r.data)==null?void 0:H.disabled)}]}),K=e.computed(()=>{var E,M;return[`${D}__title`,{[`${D}__title_selected`]:(E=r.data)==null?void 0:E.selected,[`${D}__title_disabled`]:r.disableAll||((M=r.data)==null?void 0:M.disabled)}]});return{indentWrapperCls:l,wrapperCls:o,nodeBodyCls:a,dropBeforeCls:d,dropAfterCls:h,checkboxWrapperCls:u,expandCls:b,loadingIconCls:g,checkboxCls:L,titleCls:K}},ve=["d","stroke-width","stroke","stroke-dasharray"],et=["draggable"],ke=e.defineComponent({name:"VTreeNode",__name:"TreeNode",props:{titleField:{},keyField:{},checkable:{type:Boolean},selectable:{type:Boolean},unselectOnClick:{type:Boolean},disableAll:{type:Boolean},draggable:{type:Boolean},droppable:{type:Boolean},nodeIndent:{},expandOnClickNode:{type:Boolean},render:{type:Function},showLine:{type:[Boolean,Object]},data:{},getNode:{type:Function},noSiblingNodeMap:{}},emits:[...ge],setup(r,{emit:c}){var f;const n=r,t=c,s=e.ref(!1),l=e.ref(!1),o=e.ref(!1),a=e.computed(()=>{const i={width:1,type:ye.solid,color:"#D3D3D3",polyline:!1,dashDensity:3};let C=i;if(typeof n.showLine=="object"){let T=i.dashDensity;typeof n.showLine.dashDensity=="number"&&n.showLine.dashDensity>=1&&n.showLine.dashDensity<=10&&(T=n.showLine.dashDensity),C={width:n.showLine.width??i.width,type:n.showLine.type??i.type,color:n.showLine.color??i.color,polyline:n.showLine.polyline??i.polyline,dashDensity:T}}return C}),d=e.computed(()=>a.value.width*100/n.nodeIndent),h=e.computed(()=>{switch(a.value.type){case ye.dashed:return 100/(a.value.dashDensity*2)}return"none"}),u=i=>{var T;if(!a.value.polyline||!i)return"M50,0 L50,100";const C=(T=n.getNode(n.data[n.keyField]))==null?void 0:T._parent;return C&&n.noSiblingNodeMap[C[n.keyField]]&&n.noSiblingNodeMap[n.data[n.keyField]]?"M50,0 L50,50 M100,50 L50,50":"M50,0 L50,100 M100,50 L50,50"},{indentWrapperCls:b,wrapperCls:g,nodeBodyCls:L,dropBeforeCls:K,dropAfterCls:E,checkboxWrapperCls:M,expandCls:H,loadingIconCls:w,checkboxCls:F,titleCls:V}=Ze(n,{dragoverBody:s,dragoverBefore:l,dragoverAfter:o}),S=e.computed(()=>n.getNode(n.data?n.data[n.keyField]:"")||n.data||{}),$=e.computed(()=>n.checkable),W=((f=n.data)==null?void 0:f.render)||n.render||null,J=e.computed(()=>e.defineComponent({name:"Render",functional:!0,render(){return typeof W!="function"?e.h("div"):W(S.value)}})),R=e.computed(()=>{var C;let i={};return n.draggable&&!n.disableAll&&!((C=n.data)!=null&&C.disabled)&&(i={dragstart:_}),i}),P=e.computed(()=>{let i={};return n.droppable&&(i={dragenter:B.bind(e.getCurrentInstance()),dragover:q.bind(e.getCurrentInstance()),dragleave:O.bind(e.getCurrentInstance()),drop:X.bind(e.getCurrentInstance())}),i});function G(){var i;(i=n.data)!=null&&i.isLeaf||t("expand",S.value)}function le(){var i;n.disableAll||(i=n.data)!=null&&i.disabled||!n.checkable||t("check",S.value)}const ae=j(i=>{var C,T;if(t("click",S.value,i),n.selectable){if(n.disableAll||(C=n.data)!=null&&C.disabled||(T=n.data)!=null&&T.selected&&!n.unselectOnClick)return;t("select",S.value)}else n.checkable?le():n.expandOnClickNode&&G()});function v(i){t("node-dblclick",S.value,i)}function m(i){t("node-right-click",S.value,i)}const y=e.ref();function A(i){const C=y.value.getBoundingClientRect(),T=C.height,z=i.clientY-C.top;return z<=T*.3?te.before:z<=T*(.3+.4)?te.body:te.after}function j(i,C=200){let T,z=0;return(...se)=>{z++,clearTimeout(T),T=setTimeout(()=>{z===1&&i(...se),z=0},C)}}function k(i,C=!1){l.value=!1,s.value=!1,o.value=!1,C||(i===te.before?l.value=!0:i===te.body?s.value=!0:i===te.after&&(o.value=!0))}function _(i){var C;i.dataTransfer&&i.dataTransfer.setData("node",JSON.stringify(n.data)),(C=n.data)!=null&&C.expand&&G(),t("node-dragstart",S.value,i)}function B(i){i.preventDefault();const C=A(i);k(C),t("node-dragenter",S.value,i,C)}function q(i){i.preventDefault();const C=A(i);k(C),t("node-dragover",S.value,i,C)}function O(i){const C=A(i);k(C,!0),t("node-dragleave",S.value,i,C)}function X(i){const C=A(i);k(C,!0),t("node-drop",S.value,i,C)}return(i,C)=>{var T,z,se,ee;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(b))},[i.showLine?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(i.data._level,(ie,_e)=>(e.openBlock(),e.createElementBlock("svg",{key:ie,viewBox:"0 0 100 100",preserveAspectRatio:"none",style:e.normalizeStyle({alignSelf:"stretch",width:`${i.nodeIndent}px`})},[e.createElementVNode("path",{fill:"none",d:u(_e===i.data._level-1),"stroke-width":d.value,stroke:a.value.color,"stroke-dasharray":h.value},null,8,ve)],4))),128)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(e.unref(g)),style:e.normalizeStyle({paddingLeft:i.showLine?"none":`${i.data._level*i.nodeIndent}px`})},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(K))},null,2),e.createElementVNode("div",e.mergeProps({ref_key:"nodeBody",ref:y,class:e.unref(L)},e.toHandlers(P.value,!0)),[e.createElementVNode("div",{class:e.normalizeClass(e.unref(H))},[e.withDirectives(e.createElementVNode("i",{onClick:G},null,512),[[e.vShow,!((T=i.data)!=null&&T.isLeaf)&&!((z=i.data)!=null&&z._loading)]]),(se=i.data)!=null&&se._loading?(e.openBlock(),e.createBlock(Te,{key:0,class:e.normalizeClass(e.unref(w))},null,8,["class"])):e.createCommentVNode("",!0)],2),$.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(M))},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(F)),onClick:le},null,2)],2)):e.createCommentVNode("",!0),e.createElementVNode("div",e.mergeProps({class:e.unref(V),onClick:C[0]||(C[0]=(...ie)=>e.unref(ae)&&e.unref(ae)(...ie)),onDblclick:v,onContextmenu:m},e.toHandlers(R.value,!0),{draggable:i.draggable&&!i.disableAll&&!((ee=i.data)!=null&&ee.disabled)}),[e.renderSlot(i.$slots,"default",{node:S.value},()=>[e.unref(W)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(J.value),{key:0})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(i.data?i.data[i.titleField]:""),1)],64))])],16,et)],16),e.createElementVNode("div",{class:e.normalizeClass(e.unref(E))},null,2)],6)],2)}}}),re="vtree-tree",tt=()=>{const r=e.computed(()=>[`${re}__wrapper`]),c=e.computed(()=>[`${re}__scroll-area`]),n=e.computed(()=>[`${re}__block-area`]),t=e.computed(()=>[`${re}__empty`]),s=e.computed(()=>[`${re}__empty-text_default`]),l=e.computed(()=>[`${re}__loading`]),o=e.computed(()=>[`${re}__loading-wrapper`]),a=e.computed(()=>[`${re}__loading-icon`]),d=e.computed(()=>[`${re}__iframe`]);return{wrapperCls:r,scrollAreaCls:c,blockAreaCls:n,emptyCls:t,emptyTextDefaultCls:s,loadingCls:l,loadingWrapperCls:o,loadingIconCls:a,iframeCls:d}},nt=(r,c)=>{const n=e.ref(),t=e.ref([]),s=e.ref(0),l=e.ref(0),o=e.ref(0),a=e.ref(0),d=e.ref(0),h=e.ref(0),u=e.ref(0),b=e.ref(0),g=e.ref(void 0),L=()=>{o.value=0,a.value=0,n.value&&(n.value.scrollTop=0)},K=()=>{const S=n.value.clientHeight;d.value=Math.max(c.renderNodeAmount,Math.ceil(S/c.nodeMinHeight)+c.bufferNodeAmount)},E=(S=!1)=>{if(s.value>d.value){const $=Math.max(n.value.scrollTop,0),W=Math.floor($/c.nodeMinHeight);u.value=Math.floor(W/c.bufferNodeAmount)*c.bufferNodeAmount}else u.value=0;S&&h.value===d.value&&b.value===u.value||(t.value=r.blockNodes.slice(u.value,u.value+d.value).map($=>Object.assign({},$,{_parent:null,children:[]})),o.value=u.value*c.nodeMinHeight,a.value=l.value-(o.value+t.value.length*c.nodeMinHeight))},M=()=>{K(),E()},H=()=>{r.blockNodes=r.store.flatData.filter(S=>S.visible),w(),M()},w=()=>{s.value=r.blockNodes.length,l.value=c.nodeMinHeight*s.value};return{scrollArea:n,renderNodes:t,blockLength:s,blockAreaHeight:l,topSpaceHeight:o,bottomSpaceHeight:a,renderAmount:d,renderAmountCache:h,renderStart:u,renderStartCache:b,resetSpaceHeights:L,updateRenderAmount:K,updateRenderNodes:E,updateRender:M,updateBlockNodes:H,updateBlockData:w,handleTreeScroll:()=>{g.value&&window.cancelAnimationFrame(g.value),h.value=d.value,b.value=u.value,g.value=window.requestAnimationFrame(E.bind(null,!0))},scrollTo:(S,$=me.top)=>{const W=r.store.mapData[S];if(!W||!W.visible)return;let J=-1;for(let P=0;P<s.value;P++)if(r.blockNodes[P][c.keyField]===S){J=P;break}if(J===-1)return;let R=J*c.nodeMinHeight;if($===me.center){const P=n.value.clientHeight;R=R-(P-c.nodeMinHeight)/2}else if($===me.bottom){const P=n.value.clientHeight;R=R-(P-c.nodeMinHeight)}else typeof $=="number"&&(R=R-$);n.value&&(n.value.scrollTop=R)}}},lt=r=>{const c=e.ref();e.onMounted(()=>{const n=c.value;n!=null&&n.contentWindow&&n.contentWindow.addEventListener("resize",r)}),e.onBeforeUnmount(()=>{const n=c.value;n!=null&&n.contentWindow&&n.contentWindow.removeEventListener("resize",r)})},at=(r,c,n)=>{const{resetSpaceHeights:t,updateExpandedKeys:s,updateBlockData:l,updateRender:o}=n,a=e.ref([]),d=e.ref(!1);function h(f){t();let i=null,C=null;c.checkable?Array.isArray(c.modelValue)?i=c.modelValue.concat():typeof c.modelValue=="string"&&(i=c.modelValue===""?[]:c.modelValue.split(c.separator)):c.selectable&&!Array.isArray(c.modelValue)&&(C=c.modelValue),r.store.setData(f,C,i),s()}function u(f,i){r.store.setChecked(f,i)}function b(f,i){r.store.setCheckedKeys(f,i)}function g(){r.store.checkAll()}function L(){r.store.clearChecked()}function K(f,i){r.store.setSelected(f,i)}function E(){r.store.clearSelected()}function M(f,i,C=!0){r.store.setExpand(f,i,C)}function H(f,i){r.store.setExpandKeys(f,i)}function w(f){r.store.setExpandAll(f)}function F(f){return f=f||c.ignoreMode,r.store.getCheckedNodes(f)}function V(f){return f=f||c.ignoreMode,r.store.getCheckedKeys(f)}function S(){return r.store.getIndeterminateNodes()}function $(){return r.store.getSelectedNode()}function W(){return r.store.getSelectedKey()}function J(){return r.store.getExpandNodes()}function R(){return r.store.getExpandKeys()}function P(){return r.store.flatData.filter(f=>f._filterVisible)}function G(f){return r.store.getNode(f)}function le(){return r.store.data}function ae(){return r.store.flatData}function v(){return r.store.flatData.length}function m(f,i){return r.store.insertBefore(f,i)}function y(f,i){return r.store.insertAfter(f,i)}function A(f,i){return r.store.append(f,i)}function j(f,i){return r.store.prepend(f,i)}function k(f){return r.store.remove(f)}function _(f,i){const C=(z,se)=>{const ee=se[c.titleField];return ee==null||!ee.toString?!1:ee.toString().toLowerCase().indexOf(z.toLowerCase())>-1},T=i||c.filterMethod||C;r.store.filter(f,T)}function B(f){if(!c.checkable)return;f=f??c.showUnloadCheckedNodes;const i=r.store.getCheckedNodes();if(r.store.filter("",(T,z)=>z.checked),!f)return;const C=r.store.getUnloadCheckedKeys();if(C.length){const T=C.map(z=>{const se=c.unloadDataList.concat(i);let ee=z;return se.some(ie=>ie[c.keyField]===z&&ie[c.titleField]!=null?(ee=ie[c.titleField],!0):!1),new oe({[c.keyField]:z,[c.titleField]:ee,checked:!0,isLeaf:!0},null,c.keyField,!!c.load)});a.value=T,r.blockNodes=r.blockNodes.concat(T),l(),o()}}function q(){return d.value=!0,new Promise((f,i)=>{c.load&&c.load(null,f,i)}).then(f=>{Array.isArray(f)&&h(f)}).catch(()=>{}).then(()=>{d.value=!1})}function O(f,i){return r.store.updateNode(f,i)}function X(f){return r.store.updateNodes(f)}return{unloadCheckedNodes:a,isRootLoading:d,setData:h,setChecked:u,setCheckedKeys:b,checkAll:g,clearChecked:L,setSelected:K,clearSelected:E,setExpand:M,setExpandKeys:H,setExpandAll:w,getCheckedNodes:F,getCheckedKeys:V,getIndeterminateNodes:S,getSelectedNode:$,getSelectedKey:W,getExpandNodes:J,getExpandKeys:R,getCurrentVisibleNodes:P,getNode:G,getTreeData:le,getFlatData:ae,getNodesCount:v,insertBefore:m,insertAfter:y,append:A,prepend:j,remove:k,filter:_,showCheckedNodes:B,loadRootNodes:q,updateNode:O,updateNodes:X}},Le=(r,c)=>r.reduce((n,t)=>{const s=(...l)=>{var a;const o=(a=c.value)==null?void 0:a[t];if(typeof o=="function")return o(...l)};return n[t]=s,n},{}),st=(r,...c)=>{const n={};return c.forEach(t=>{r.hasOwnProperty(t)&&(n[t]=r[t])}),n},ot=(r,c,n)=>{const t=e.ref(!1),s=e.ref(!1),l=e.ref(-1),o=e.ref(-1),a=e.ref(!1),d=e.ref(!1),h=e.ref(0),u=e.ref([]),b=e.ref([]),g=e.ref([]),L=()=>{t.value=!1,s.value=!1,l.value=-1,o.value=-1,h.value=0,u.value=[],b.value=[],g.value=[]},K=()=>{const w=o.value,F=[],V=r.value.length,S=c.value-h.value;for(let $=l.value-S+1;$<V&&r.value[$]._level>w;$++)F.push(r.value[$]);b.value=F};return{ready:s,currentExpandState:a,topNodes:u,middleNodes:b,bottomNodes:g,updateBeforeExpand:w=>{if(!n.animation)return;L();const F=w[n.keyField],V=r.value.findIndex(S=>S[n.keyField]===F);V>-1&&(l.value=V,o.value=w._level,t.value=!0,a.value=w.expand,d.value=!w.expand,h.value=c.value,d.value?g.value=r.value.slice(l.value+1):K())},updateAfterExpand:()=>{if(n.animation){if(!t.value){t.value=!1;return}l.value!==-1&&e.nextTick(()=>{const w=c.value-h.value;u.value=r.value.slice(0,l.value-w+1),d.value?K():g.value=r.value.slice(l.value-w+1),s.value=!0,e.nextTick(()=>{a.value=!a.value})})}},onExpandAnimationFinish:()=>{L()}}},rt={style:{display:"grid"}},it={style:{overflow:"hidden"}},Me={data:()=>[],unloadDataList:()=>[],showUnloadCheckedNodes:!0,emptyText:"暂无数据",titleField:"title",keyField:"id",separator:",",checkable:!1,selectable:!1,filteredNodeCheckable:!1,cascade:!0,enableLeafOnly:!1,disableAll:!1,defaultExpandAll:!1,defaultExpandedKeys:()=>[],expandedKeys:()=>[],draggable:!1,droppable:!1,beforeDropMethod:()=>()=>!0,ignoreMode:ue.none,autoLoad:!0,expandOnFilter:!0,unselectOnClick:!0,loading:!1,nodeMinHeight:30,nodeIndent:20,renderNodeAmount:100,bufferNodeAmount:20,expandOnClickNode:!0},Oe=e.defineComponent({name:"VTree",inheritAttrs:!1,__name:"Tree",props:e.mergeDefaults({data:{},emptyText:{},modelValue:{},selectable:{type:Boolean},checkable:{type:Boolean},separator:{},ignoreMode:{},titleField:{},keyField:{},filterMethod:{type:Function},showUnloadCheckedNodes:{type:Boolean},unloadDataList:{},load:{type:Function},filteredNodeCheckable:{type:Boolean},cascade:{type:Boolean},enableLeafOnly:{type:Boolean},disableAll:{type:Boolean},defaultExpandAll:{type:Boolean},defaultExpandedKeys:{},expandedKeys:{},draggable:{type:Boolean},droppable:{type:Boolean},beforeDropMethod:{type:Function},autoLoad:{type:Boolean},render:{type:Function},expandOnFilter:{type:Boolean},unselectOnClick:{type:Boolean},loading:{type:Boolean},nodeClassName:{type:[String,Object,Array,Function]},showLine:{type:[Boolean,Object]},animation:{type:Boolean},nodeIndent:{},renderNodeAmount:{},nodeMinHeight:{},bufferNodeAmount:{},expandOnClickNode:{type:Boolean}},Me),emits:["update:modelValue",...Ce],setup(r,{expose:c,emit:n}){const t=r,s=n,l=["node-drop","check","select","expand"],o=ge.reduce((p,N)=>(l.indexOf(N)<0&&(p[N]=(...x)=>{s(N,...x)}),p),{}),a=()=>({store:new Ve({keyField:t.keyField,ignoreMode:t.ignoreMode,filteredNodeCheckable:t.filteredNodeCheckable,cascade:t.cascade,defaultExpandAll:t.defaultExpandAll,load:t.load,expandOnFilter:t.expandOnFilter}),blockNodes:[]});let d=a();(()=>{$e.forEach(p=>{d.store.on(p,(...N)=>{s(p,...N)})})})();const u=()=>{t.expandedKeys.length&&(d.store.setExpandAll(!1,!1),d.store.setExpandKeys(t.expandedKeys,!0))},{wrapperCls:b,scrollAreaCls:g,blockAreaCls:L,emptyCls:K,emptyTextDefaultCls:E,loadingCls:M,loadingWrapperCls:H,loadingIconCls:w,iframeCls:F}=tt(),{scrollArea:V,renderNodes:S,blockLength:$,topSpaceHeight:W,bottomSpaceHeight:J,renderStart:R,resetSpaceHeights:P,updateRender:G,updateBlockNodes:le,updateBlockData:ae,handleTreeScroll:v,scrollTo:m}=nt(d,t),y=ot(S,R,t),{unloadCheckedNodes:A,isRootLoading:j,setData:k,setChecked:_,setCheckedKeys:B,checkAll:q,clearChecked:O,setSelected:X,clearSelected:f,setExpand:i,setExpandKeys:C,setExpandAll:T,getCheckedNodes:z,getCheckedKeys:se,getIndeterminateNodes:ee,getSelectedNode:ie,getSelectedKey:_e,getExpandNodes:mt,getExpandKeys:kt,getCurrentVisibleNodes:yt,getNode:he,getTreeData:gt,getFlatData:Ct,getNodesCount:bt,insertBefore:_t,insertAfter:Nt,append:St,prepend:xt,remove:Et,filter:wt,showCheckedNodes:Dt,loadRootNodes:Pe,updateNode:Bt,updateNodes:Ft}=at(d,t,{resetSpaceHeights:P,updateExpandedKeys:u,updateBlockData:ae,updateRender:G}),Ne=p=>typeof t.nodeClassName=="function"?t.nodeClassName(p):t.nodeClassName,Se=e.computed(()=>{var de;const p=[];let N=(de=S.value[0])==null?void 0:de._parent;for(;N;)p.push(N),N=N._parent;const x=p.concat(S.value),Q={},Z=[];return x.forEach(pe=>{const ze=pe._level;let Fe=Z.length;for(;Fe;){const Ue=Z[Fe-1],We=Ue._level;if(We>ze)Q[Ue[t.keyField]]=!0,Z.pop();else if(We===ze){Z.pop();break}else break;Fe--}Z.push(pe)}),Z.forEach(pe=>{Q[pe[t.keyField]]=!0}),Q}),At=(p,N)=>{if(Array.isArray(p)&&Array.isArray(N)){if(p.length===N.length&&p.every(x=>N.some(Q=>Q===x)))return!0}else if(p===N)return!0;return!1},fe=e.ref(Array.isArray(t.modelValue)?t.modelValue.concat():t.modelValue),xe=p=>{!t.cascade&&t.enableLeafOnly&&!p.isLeaf||d.store.setChecked(p[t.keyField],p.indeterminate?!0:!p.checked,!0,!0,!0)},Ee=p=>{t.enableLeafOnly&&!p.isLeaf||d.store.setSelected(p[t.keyField],!p.selected)},we=p=>{y.updateBeforeExpand(p),d.store.setExpand(p[t.keyField],!p.expand)},De=(p,N,x)=>{if(t.droppable&&N.dataTransfer)try{const Z=JSON.parse(N.dataTransfer.getData("node"))[t.keyField],de=p[t.keyField];if(t.beforeDropMethod(Z,de,x)){if(Z===de)return;x===te.before?d.store.insertBefore(Z,de):x===te.body||!p.isLeaf&&p.expand?d.store.prepend(Z,de):x===te.after&&d.store.insertAfter(Z,de),s("node-drop",p,N,x,he(Z))}}catch(Q){throw new Error(Q)}};e.watch(()=>t.modelValue,p=>{if(t.checkable){if(At(p,fe.value))return;let N=[];Array.isArray(p)?N=p.concat():typeof p=="string"&&(N=p===""?[]:p.split(t.separator)),d.store.clearChecked(!1,!1),d.store.setCheckedKeys(N,!0)}else if(t.selectable){if(p===fe.value)return;const N=d.store.getSelectedKey();p!==""&&p!=null?d.store.setSelected(p,!0):(p===""||p==null)&&N&&d.store.setSelected(N,!1)}}),e.watch(()=>t.data,p=>{k(p)}),e.watch(()=>t.expandedKeys,()=>{u()});const Kt=()=>{if(A.value.length){const p=d.store.getUnloadCheckedKeys();A.value.forEach(N=>{N.checked=p.indexOf(N[t.keyField])>-1})}},Vt=(p,N)=>{if(t.checkable){let x=N;Array.isArray(t.modelValue)||(x=x.join(t.separator)),Array.isArray(x)?fe.value=x.concat():fe.value=x,s("update:modelValue",x)}},Tt=(p,N)=>{if(t.selectable&&!t.checkable){const x=N||"";fe.value=x,s("update:modelValue",x)}};e.onMounted(()=>{d.store.on("expand",y.updateAfterExpand),d.store.on("visible-data-change",le),d.store.on("render-data-change",G),d.store.on("checked-change",(p,N)=>{Vt(p,N),Kt()}),d.store.on("selected-change",Tt),t.data.length?(k(t.data),t.defaultExpandedKeys.length&&d.store.setExpandKeys(t.defaultExpandedKeys,!0)):typeof t.load=="function"&&t.autoLoad&&((t.modelValue||t.unloadDataList)&&k([]),Pe())}),e.onBeforeUnmount(()=>{d.store.disposeListeners();const p=a();d.store=p.store,d.blockNodes=p.blockNodes}),lt(G);const $t=["titleField","keyField","checkable","selectable","unselectOnClick","disableAll","draggable","droppable","render","nodeIndent","showLine"],Be=e.reactive(st(e.toRefs(t),...$t));return c({setData:k,setChecked:_,setCheckedKeys:B,checkAll:q,clearChecked:O,setSelected:X,clearSelected:f,setExpand:i,setExpandKeys:C,setExpandAll:T,getCheckedNodes:z,getCheckedKeys:se,getIndeterminateNodes:ee,getSelectedNode:ie,getSelectedKey:_e,getExpandNodes:mt,getExpandKeys:kt,getCurrentVisibleNodes:yt,getNode:he,getTreeData:gt,getFlatData:Ct,getNodesCount:bt,insertBefore:_t,insertAfter:Nt,append:St,prepend:xt,remove:Et,filter:wt,showCheckedNodes:Dt,loadRootNodes:Pe,updateNode:Bt,updateNodes:Ft,scrollTo:m}),(p,N)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(b))},[e.createElementVNode("div",{ref_key:"scrollArea",ref:V,class:e.normalizeClass(e.unref(g)),onScrollPassive:N[0]||(N[0]=e.withModifiers((...x)=>e.unref(v)&&e.unref(v)(...x),["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(L))},[e.createElementVNode("div",{style:e.normalizeStyle({height:`${e.unref(W)}px`})},null,4),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y).ready.value?e.unref(y).topNodes.value:e.unref(S),x=>(e.openBlock(),e.createBlock(ke,e.mergeProps({ref_for:!0},Be,{key:x[p.keyField],data:x,getNode:e.unref(he),noSiblingNodeMap:Se.value,expandOnClickNode:p.expandOnClickNode},e.toHandlers(e.unref(o)),{class:Ne(x),style:{minHeight:`${p.nodeMinHeight}px`},onCheck:xe,onSelect:Ee,onExpand:we,onNodeDrop:De}),{default:e.withCtx(Q=>[e.renderSlot(p.$slots,"node",e.mergeProps({ref_for:!0},Q))]),_:2},1040,["data","getNode","noSiblingNodeMap","expandOnClickNode","class","style"]))),128)),e.unref(y).ready.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(e.Transition,{name:"vtree-expand-animation",onAfterEnter:e.unref(y).onExpandAnimationFinish,onAfterLeave:e.unref(y).onExpandAnimationFinish},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",rt,[e.createElementVNode("div",it,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y).middleNodes.value,x=>(e.openBlock(),e.createBlock(ke,e.mergeProps({ref_for:!0},Be,{key:x[p.keyField],data:x,getNode:e.unref(he),noSiblingNodeMap:Se.value,expandOnClickNode:p.expandOnClickNode},e.toHandlers(e.unref(o)),{class:Ne(x),style:{minHeight:`${p.nodeMinHeight}px`},onCheck:xe,onSelect:Ee,onExpand:we,onNodeDrop:De}),{default:e.withCtx(Q=>[e.renderSlot(p.$slots,"node",e.mergeProps({ref_for:!0},Q))]),_:2},1040,["data","getNode","noSiblingNodeMap","expandOnClickNode","class","style"]))),128))])],512),[[e.vShow,e.unref(y).currentExpandState.value]])]),_:3},8,["onAfterEnter","onAfterLeave"]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y).bottomNodes.value,x=>(e.openBlock(),e.createBlock(ke,e.mergeProps({ref_for:!0},Be,{key:x[p.keyField],data:x,getNode:e.unref(he),noSiblingNodeMap:Se.value,expandOnClickNode:p.expandOnClickNode},e.toHandlers(e.unref(o)),{class:Ne(x),style:{minHeight:`${p.nodeMinHeight}px`},onCheck:xe,onSelect:Ee,onExpand:we,onNodeDrop:De}),{default:e.withCtx(Q=>[e.renderSlot(p.$slots,"node",e.mergeProps({ref_for:!0},Q))]),_:2},1040,["data","getNode","noSiblingNodeMap","expandOnClickNode","class","style"]))),128))],64)):e.createCommentVNode("",!0),e.createElementVNode("div",{style:e.normalizeStyle({height:`${e.unref(J)}px`})},null,4)],2)],34),e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(e.unref(K))},[e.createElementVNode("span",{class:e.normalizeClass(e.unref(E))},[e.renderSlot(p.$slots,"empty",{},()=>[e.createTextVNode(e.toDisplayString(p.emptyText),1)])],2)],2),[[e.vShow,!e.unref($)]]),e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(e.unref(M))},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(H))},[e.renderSlot(p.$slots,"loading",{},()=>[e.createVNode(Te,{class:e.normalizeClass(e.unref(w))},null,8,["class"])])],2)],2),[[e.vShow,p.loading||e.unref(j)]]),e.createElementVNode("iframe",{ref:"iframe",class:e.normalizeClass(e.unref(F))},null,2)],2))}}),Y="vtree-tree-search",dt=(r,c)=>{const{checkAllStatus:n,isShowingChecked:t}=c,s=e.computed(()=>[`${Y}__wrapper`]),l=e.computed(()=>[`${Y}__search`]),o=e.computed(()=>[`${Y}__check-all-wrapper`]),a=e.computed(()=>[`${Y}__check-all`,`${D}__checkbox`,{[`${D}__checkbox_checked`]:n.checked,[`${D}__checkbox_indeterminate`]:n.indeterminate,[`${D}__checkbox_disabled`]:r.searchDisabled||n.disabled}]),d=e.computed(()=>[`${Y}__input-wrapper`]),h=e.computed(()=>[`${Y}__input`,{[`${Y}__input_disabled`]:r.searchDisabled}]),u=e.computed(()=>[`${Y}__action-wrapper`]),b=e.computed(()=>[`${Y}__checked-button`,{[`${Y}__checked-button_active`]:t.value}]),g=e.computed(()=>[`${Y}__tree-wrapper`]),L=e.computed(()=>[`${Y}__footer`]);return{wrapperCls:s,searchCls:l,checkAllWrapperCls:o,checkboxCls:a,inputWrapperCls:d,inputCls:h,actionWrapperCls:u,checkedButtonCls:b,treeWrapperCls:g,footerCls:L}},ct=["placeholder","disabled"],ht={style:{float:"right"}},Ie={...Me,searchPlaceholder:"搜索关键字",showCheckAll:!0,showCheckedButton:!0,checkedButtonText:"已选",showFooter:!0,searchLength:1,searchDisabled:!1,searchRemote:!1,searchDebounceTime:300},He=e.defineComponent({name:"VTreeSearch",inheritAttrs:!1,__name:"TreeSearch",props:e.mergeDefaults({data:{},emptyText:{},modelValue:{},selectable:{type:Boolean},checkable:{type:Boolean},separator:{},ignoreMode:{},titleField:{},keyField:{},filterMethod:{type:Function},showUnloadCheckedNodes:{type:Boolean},unloadDataList:{},load:{type:Function},filteredNodeCheckable:{type:Boolean},cascade:{type:Boolean},enableLeafOnly:{type:Boolean},disableAll:{type:Boolean},defaultExpandAll:{type:Boolean},defaultExpandedKeys:{},expandedKeys:{},draggable:{type:Boolean},droppable:{type:Boolean},beforeDropMethod:{type:Function},autoLoad:{type:Boolean},render:{type:Function},expandOnFilter:{type:Boolean},unselectOnClick:{type:Boolean},loading:{type:Boolean},nodeClassName:{type:[String,Object,Array,Function]},showLine:{type:[Boolean,Object]},animation:{type:Boolean},nodeIndent:{},renderNodeAmount:{},nodeMinHeight:{},bufferNodeAmount:{},expandOnClickNode:{type:Boolean},searchPlaceholder:{},showCheckAll:{type:Boolean},showCheckedButton:{type:Boolean},checkedButtonText:{},showFooter:{type:Boolean},searchMethod:{type:Function},searchLength:{},searchDisabled:{type:Boolean},searchRemote:{type:Boolean},searchDebounceTime:{}},Ie),emits:["update:modelValue",...be],setup(r,{expose:c,emit:n}){const t=r,s=n,l=["set-data","checked-change"],o=Ce.reduce((k,_)=>(l.indexOf(_)<0&&(k[_]=(...B)=>{s(_,...B)}),k),{}),a=e.reactive({checked:!1,indeterminate:!1,disabled:!1}),d=e.ref(!1),h=e.ref(""),u=e.ref(void 0),b=e.ref(0),g=e.ref(null),{wrapperCls:L,searchCls:K,checkAllWrapperCls:E,checkboxCls:M,inputWrapperCls:H,inputCls:w,actionWrapperCls:F,checkedButtonCls:V,treeWrapperCls:S,footerCls:$}=dt(t,{checkAllStatus:a,isShowingChecked:d}),W=e.computed({get:()=>t.modelValue,set:k=>{y(),s("update:modelValue",k)}});function J(){h.value=""}function R(){return h.value}function P(k){let _=k;return typeof k!="string"&&(_=h.value),new Promise((B,q)=>{clearTimeout(u.value),u.value=setTimeout(()=>{if(!(_.length>0&&_.length<t.searchLength))if(d.value=!1,s("search",_),typeof t.searchMethod=="function"){const O=t.searchMethod(_);Promise.resolve(O).then(()=>{m(),B()})}else{if(!g.value)return;t.searchRemote?g.value.loadRootNodes().then(()=>{m(),B()}):(g.value.filter(_),m(),B())}},t.searchDebounceTime)})}function G(){const k=t.keyField;if(t.searchDisabled||a.disabled||!g.value||!k)return;const _=g.value.getCurrentVisibleNodes().map(B=>B[k]);a.checked?g.value.setCheckedKeys(_,!1):g.value.setCheckedKeys(_,!0),m()}function le(){P()}function ae(){const k=()=>{var _,B;d.value=!d.value,d.value?(_=g.value)==null||_.showCheckedNodes():(B=g.value)==null||B.filter(h.value,()=>!0),m()};h.value?(J(),P().then(()=>{k()})):k()}function v(){y(),m()}function m(){var X;const k=((X=g.value)==null?void 0:X.getCurrentVisibleNodes())||[],_=k.length;let B=!1,q=!1,O=!1;for(let f=0;f<_;f++){const i=k[f];if(i.checked?B=!0:q=!0,B&&q||i.indeterminate){O=!0,a.checked=!1,a.indeterminate=!0;break}}O||(a.checked=B,a.indeterminate=!1)}function y(){var k;b.value=((k=g.value)==null?void 0:k.getCheckedKeys().length)||0}function A(k,_){m(),s("checked-change",k,_)}function j(){s("set-data"),v()}return e.onMounted(()=>{t.checkable&&!b.value&&v()}),c({...Le(Ae,g),clearKeyword:J,getKeyword:R,search:P}),(k,_)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(L))},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(K))},[k.showCheckAll&&k.checkable?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(E))},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(M)),onClick:G},null,2)],2)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(e.unref(H))},[e.renderSlot(k.$slots,"search-input",{},()=>[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":_[0]||(_[0]=B=>h.value=B),type:"text",class:e.normalizeClass(e.unref(w)),placeholder:k.searchPlaceholder,disabled:k.searchDisabled,onInput:le},null,42,ct),[[e.vModelText,h.value]])])],2),e.createElementVNode("div",{class:e.normalizeClass(e.unref(F))},[k.showCheckedButton&&k.checkable?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(V)),onClick:ae},e.toDisplayString(k.checkedButtonText),3)):e.createCommentVNode("",!0),e.renderSlot(k.$slots,"actions")],2)],2),e.createElementVNode("div",{class:e.normalizeClass(e.unref(S))},[e.createVNode(Oe,e.mergeProps({ref_key:"treeRef",ref:g},t,{modelValue:W.value,"onUpdate:modelValue":_[1]||(_[1]=B=>W.value=B)},e.toHandlers(e.unref(o)),{onSetData:j,onCheckedChange:A}),e.createSlots({_:2},[e.renderList(k.$slots,(B,q)=>({name:q,fn:e.withCtx(O=>[e.renderSlot(k.$slots,q,e.normalizeProps(e.guardReactiveProps(O)))])}))]),1040,["modelValue"])],2),k.showFooter&&k.checkable?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref($))},[e.renderSlot(k.$slots,"footer",{},()=>[e.createElementVNode("span",ht,"已选 "+e.toDisplayString(b.value)+" 个",1)])],2)):e.createCommentVNode("",!0)],2))}}),ne="vtree-tree-drop",ft=(r,c)=>{const{dropdownVisible:n,checkedCount:t,selectedTitle:s}=c,l=e.computed(()=>[`${ne}__wrapper`]),o=e.computed(()=>[`${ne}__reference`]),a=e.computed(()=>[`${Y}__input`,`${ne}__display-input`,{[`${ne}__display-input_focus`]:n.value,[`${Y}__input_disabled`]:r.dropDisabled}]),d=e.computed(()=>{let g=!1;return typeof r.dropPlaceholder=="string"&&(r.checkable?g=t.value===0:r.selectable&&(g=s.value==="")),[`${ne}__display-input-text`,{[`${ne}__display-input-placeholder`]:g}]}),h=e.computed(()=>[`${ne}__display-icon-drop`,{[`${ne}__display-icon-drop_active`]:n.value}]),u=e.computed(()=>[`${ne}__display-icon-clear`]),b=e.computed(()=>{const g=Array.isArray(r.dropdownClassName)?r.dropdownClassName:[r.dropdownClassName];return[`${ne}__dropdown`,...g]});return{wrapperCls:l,referenceCls:o,displayInputCls:a,displayInputTextCls:d,dropIconCls:h,clearIconCls:u,dropdownCls:b}},pt={...Ie,dropHeight:300,dropDisabled:!1,clearable:!1,placement:Ke["bottom-start"],transfer:!1,dropdownWidthFixed:!1},ut=e.defineComponent({name:"VTreeDrop",inheritAttrs:!1,__name:"TreeDrop",props:e.mergeDefaults({data:{},emptyText:{},modelValue:{},selectable:{type:Boolean},checkable:{type:Boolean},separator:{},ignoreMode:{},titleField:{},keyField:{},filterMethod:{type:Function},showUnloadCheckedNodes:{type:Boolean},unloadDataList:{},load:{type:Function},filteredNodeCheckable:{type:Boolean},cascade:{type:Boolean},enableLeafOnly:{type:Boolean},disableAll:{type:Boolean},defaultExpandAll:{type:Boolean},defaultExpandedKeys:{},expandedKeys:{},draggable:{type:Boolean},droppable:{type:Boolean},beforeDropMethod:{type:Function},autoLoad:{type:Boolean},render:{type:Function},expandOnFilter:{type:Boolean},unselectOnClick:{type:Boolean},loading:{type:Boolean},nodeClassName:{type:[String,Object,Array,Function]},showLine:{type:[Boolean,Object]},animation:{type:Boolean},nodeIndent:{},renderNodeAmount:{},nodeMinHeight:{},bufferNodeAmount:{},expandOnClickNode:{type:Boolean},searchPlaceholder:{},showCheckAll:{type:Boolean},showCheckedButton:{type:Boolean},checkedButtonText:{},showFooter:{type:Boolean},searchMethod:{type:Function},searchLength:{},searchDisabled:{type:Boolean},searchRemote:{type:Boolean},searchDebounceTime:{},dropHeight:{},dropPlaceholder:{},dropDisabled:{type:Boolean},clearable:{type:Boolean},placement:{},transfer:{type:Boolean},dropdownClassName:{},dropdownMinWidth:{},dropdownWidthFixed:{type:Boolean}},pt),emits:["update:modelValue",...Ge],setup(r,{expose:c,emit:n}){const t=r,s=n,l=["set-data","checked-change","selected-change"],o=be.red