@cw-devops-fe/vue-tree-vue3 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,59 @@
1
+ import { PropType } from 'vue';
2
+ type ScheduleContent = (mount: () => void, getIndex: () => number) => () => void;
3
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
4
+ node: {
5
+ type: ObjectConstructor;
6
+ required: true;
7
+ };
8
+ index: {
9
+ type: NumberConstructor;
10
+ required: true;
11
+ };
12
+ scheduleContent: PropType<ScheduleContent>;
13
+ renderContent: FunctionConstructor;
14
+ showCheckbox: {
15
+ type: BooleanConstructor;
16
+ default: boolean;
17
+ };
18
+ }>, {
19
+ tree: any;
20
+ nodeRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
21
+ expanded: import('vue').ComputedRef<any>;
22
+ loading: import('vue').ComputedRef<any>;
23
+ contentReady: import('vue').Ref<boolean, boolean>;
24
+ nodeContentComponent: import('vue').ComputedRef<{
25
+ props: {
26
+ node: {
27
+ type: ObjectConstructor;
28
+ required: boolean;
29
+ };
30
+ };
31
+ setup(innerProps: any): () => any;
32
+ }>;
33
+ handleClick: () => void;
34
+ handleContextMenu: (event: MouseEvent) => void;
35
+ handleExpandIconClick: () => void;
36
+ handleCheckChange: (event: Event) => void;
37
+ handleDragStart: (event: DragEvent) => void;
38
+ handleDragOver: (event: DragEvent) => void;
39
+ handleDrop: (event: DragEvent) => void;
40
+ handleDragEnd: (event: DragEvent) => void;
41
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
42
+ node: {
43
+ type: ObjectConstructor;
44
+ required: true;
45
+ };
46
+ index: {
47
+ type: NumberConstructor;
48
+ required: true;
49
+ };
50
+ scheduleContent: PropType<ScheduleContent>;
51
+ renderContent: FunctionConstructor;
52
+ showCheckbox: {
53
+ type: BooleanConstructor;
54
+ default: boolean;
55
+ };
56
+ }>> & Readonly<{}>, {
57
+ showCheckbox: boolean;
58
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
59
+ export default _default;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("vue"),we=require("@cw-devops-fe/virtual-list-vue3"),T="$treeNodeId",Z=function(t,e){!e||e[T]||Object.defineProperty(e,T,{value:t.id,enumerable:!1,configurable:!1,writable:!1})},W=function(t,e){return t?e[t]:e[T]},$=t=>{let e=!0,n=!0,o=!0;for(let i=0,s=t.length;i<s;i++){const c=t[i];(c.checked!==!0||c.indeterminate)&&(e=!1,c.disabled||(o=!1)),(c.checked!==!1||c.indeterminate)&&(n=!1)}return{all:e,none:n,allWithoutDisable:o,half:!e&&!n}},M=function(t){if(t.childNodes.length===0||t.loading)return;const{all:e,half:n,none:o}=$(t.childNodes);e?(t.checked=!0,t.indeterminate=!1):n?(t.checked=!1,t.indeterminate=!0):o&&(t.checked=!1,t.indeterminate=!1);const i=t.parent;!i||i.level===0||t.store.checkStrictly||M(i)},A=function(t,e){const n=t.store.props,o=t.data||{},i=n[e];if(typeof i=="function")return i(o,t);if(typeof i=="string")return o[i];if(typeof i>"u"){const s=o[e];return s===void 0?"":s}};let be=0;class S{constructor(e){this.id=be++,this.text=null,this.checked=!1,this.indeterminate=!1,this.data=null,this.expanded=!1,this.parent=null,this.visible=!0,this.isCurrent=!1,this.isLeaf=!1;for(const c in e)Object.prototype.hasOwnProperty.call(e,c)&&(this[c]=e[c]);this.level=0,this.loaded=!1,this.childNodes=[],this.loading=!1,this.parent&&(this.level=this.parent.level+1);const n=this.store;if(!n)throw new Error("[Node]store is required!");n.registerNode(this);const o=n.props;if(o&&typeof o.isLeaf<"u"){const c=A(this,"isLeaf");typeof c=="boolean"&&(this.isLeafByUser=c)}if(n.lazy!==!0&&this.data?(this.setData(this.data),n.defaultExpandAll&&(this.expanded=!0)):this.level>0&&n.lazy&&n.defaultExpandAll&&this.expand(),Array.isArray(this.data)||Z(this,this.data),!this.data)return;const i=n.defaultExpandedKeys,s=n.key;s&&i&&i.indexOf(this.key)!==-1&&this.expand(null,n.autoExpandParent),s&&n.currentNodeKey!==void 0&&this.key===n.currentNodeKey&&(n.currentNode=this,n.currentNode.isCurrent=!0),n.lazy&&n._initDefaultCheckedNode(this),this.updateLeafState()}setData(e){Array.isArray(e)||Z(this,e),this.data=e,this.childNodes=[];let n;this.level===0&&this.data instanceof Array?n=this.data:n=A(this,"children")||[];for(let o=0,i=n.length;o<i;o++)this.insertChild({data:n[o]})}get label(){return A(this,"label")}get key(){const e=this.store.key;return this.data?this.data[e]:null}get disabled(){return A(this,"disabled")}get nextSibling(){const e=this.parent;if(e){const n=e.childNodes.indexOf(this);if(n>-1)return e.childNodes[n+1]}return null}get previousSibling(){const e=this.parent;if(e){const n=e.childNodes.indexOf(this);if(n>-1)return n>0?e.childNodes[n-1]:null}return null}contains(e,n=!0){const o=function(i){const s=i.childNodes||[];let c=!1;for(let h=0,y=s.length;h<y;h++){const f=s[h];if(f===e||n&&o(f)){c=!0;break}}return c};return o(this)}remove(){const e=this.parent;e&&e.removeChild(this)}insertChild(e,n,o){if(!e)throw new Error("insertChild error: child is required.");if(!(e instanceof S)){if(!o){const i=this.getChildren(!0)||[];i.indexOf(e.data)===-1&&(typeof n>"u"||n<0?i.push(e.data):i.splice(n,0,e.data))}Object.assign(e,{parent:this,store:this.store}),e=new S(e)}e.level=this.level+1,typeof n>"u"||n<0?this.childNodes.push(e):this.childNodes.splice(n,0,e),this.updateLeafState()}insertBefore(e,n){let o;n&&(o=this.childNodes.indexOf(n)),this.insertChild(e,o)}insertAfter(e,n){let o;n&&(o=this.childNodes.indexOf(n),o!==-1&&(o+=1)),this.insertChild(e,o)}removeChild(e){const n=this.getChildren()||[],o=n.indexOf(e.data);o>-1&&n.splice(o,1);const i=this.childNodes.indexOf(e);i>-1&&(this.store&&this.store.deregisterNode(e),e.parent=null,this.childNodes.splice(i,1)),this.updateLeafState()}removeChildByData(e){let n=null;for(let o=0;o<this.childNodes.length;o++)if(this.childNodes[o].data===e){n=this.childNodes[o];break}n&&this.removeChild(n)}expand(e,n){const o=()=>{if(n){let i=this.parent;for(;i.level>0;)i.expanded=!0,i=i.parent}this.expanded=!0,e&&e()};this.shouldLoadData()?this.loadData(i=>{i instanceof Array&&(this.checked?this.setChecked(!0,!0):this.store.checkStrictly||M(this),o())}):o()}doCreateChildren(e,n={}){e.forEach(o=>{this.insertChild(Object.assign({data:o},n),void 0,!0)})}collapse(){this.expanded=!1}shouldLoadData(){return this.store.lazy===!0&&this.store.load&&!this.loaded}updateLeafState(){if(this.store.lazy===!0&&this.loaded!==!0&&typeof this.isLeafByUser<"u"){this.isLeaf=this.isLeafByUser;return}const e=this.childNodes;if(!this.store.lazy||this.store.lazy===!0&&this.loaded===!0){this.isLeaf=!e||e.length===0;return}this.isLeaf=!1}setChecked(e,n,o,i){if(this.indeterminate=e==="half",this.checked=e===!0,this.store.checkStrictly)return;if(!(this.shouldLoadData()&&!this.store.checkDescendants)){const{allWithoutDisable:c}=$(this.childNodes);!this.isLeaf&&!$(this.childNodes).all&&c&&(this.checked=!1,e=!1);const h=()=>{if(n){const y=this.childNodes;for(let k=0,v=y.length;k<v;k++){const E=y[k];i=i||e!==!1;const D=E.disabled?E.checked:i;E.setChecked(D,n,!0,i)}const{half:f,all:C}=$(y);C||(this.checked=C,this.indeterminate=f)}};if(this.shouldLoadData()){this.loadData(()=>{h(),M(this)},{checked:e!==!1});return}else h()}const s=this.parent;!s||s.level===0||o||M(s)}getChildren(e=!1){if(this.level===0)return this.data;const n=this.data;if(!n)return null;const o=this.store.props;let i="children";return o&&(i=o.children||"children"),n[i]===void 0&&(n[i]=null),e&&!n[i]&&(n[i]=[]),n[i]}updateChildren(){const e=this.getChildren()||[],n=this.childNodes.map(s=>s.data),o={},i=[];e.forEach((s,c)=>{const h=s[T];!!h&&n.findIndex(f=>f[T]===h)>=0?o[h]={index:c,data:s}:i.push({index:c,data:s})}),this.store.lazy||n.forEach(s=>{o[s[T]]||this.removeChildByData(s)}),i.forEach(({index:s,data:c})=>{this.insertChild({data:c},s)}),this.updateLeafState()}loadData(e,n={}){if(this.store.lazy===!0&&this.store.load&&!this.loaded&&(!this.loading||Object.keys(n).length)){this.loading=!0;const o=i=>{this.childNodes=[],this.doCreateChildren(i,n),this.loaded=!0,this.loading=!1,this.updateLeafState(),e&&e.call(this,i)};this.store.load(this,o)}else e&&e.call(this)}}class De{constructor(e){this.currentNode=null,this.currentNodeKey=null,this.key="",this.data=null,this.lazy=!1,this.load=null,this.props={},this.checkStrictly=!1,this.checkDescendants=!1,this.defaultCheckedKeys=[],this.defaultExpandedKeys=[],this.autoExpandParent=!0,this.defaultExpandAll=!1,this.filterNodeMethod=null;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(this[n]=e[n]);if(this.nodesMap={},this.root=new S({data:this.data,store:this}),this.lazy&&this.load){const n=this.load;n(this.root,o=>{this.root.doCreateChildren(o),this._initDefaultCheckedNodes()})}else this._initDefaultCheckedNodes()}filter(e){const n=this.filterNodeMethod,o=this.lazy,i=function(s){const c=s.root?s.root.childNodes:s.childNodes;if(c.forEach(h=>{h.visible=n.call(h,e,h.data,h),i(h)}),!s.visible&&c.length){let h=!0;h=!c.some(y=>y.visible),s.root?s.root.visible=h===!1:s.visible=h===!1}e&&s.visible&&!s.isLeaf&&!o&&s.expand()};i(this)}setData(e){e!==this.root.data?(this.root.setData(e),this._initDefaultCheckedNodes()):this.root.updateChildren()}getNode(e){if(e instanceof S)return e;const n=typeof e!="object"?e:W(this.key,e);return this.nodesMap[n]||null}insertBefore(e,n){const o=this.getNode(n);o.parent.insertBefore({data:e},o)}insertAfter(e,n){const o=this.getNode(n);o.parent.insertAfter({data:e},o)}remove(e){const n=this.getNode(e);n&&n.parent&&(n===this.currentNode&&(this.currentNode=null),n.parent.removeChild(n))}append(e,n){const o=n?this.getNode(n):this.root;o&&o.insertChild({data:e})}_initDefaultCheckedNodes(){const e=this.defaultCheckedKeys||[],n=this.nodesMap;e.forEach(o=>{const i=n[o];i&&i.setChecked(!0,!this.checkStrictly)})}_initDefaultCheckedNode(e){(this.defaultCheckedKeys||[]).indexOf(e.key)!==-1&&e.setChecked(!0,!this.checkStrictly)}setDefaultCheckedKey(e){e!==this.defaultCheckedKeys&&(this.defaultCheckedKeys=e,this._initDefaultCheckedNodes())}registerNode(e){if(!this.key||!e||!e.data)return;e.key!==void 0&&(this.nodesMap[e.key]=e)}deregisterNode(e){!this.key||!e||!e.data||(e.childNodes.forEach(o=>{this.deregisterNode(o)}),delete this.nodesMap[e.key])}getCheckedNodes(e=!1,n=!1){const o=[],i=function(s){(s.root?s.root.childNodes:s.childNodes).forEach(h=>{(h.checked||n&&h.indeterminate)&&(!e||e&&h.isLeaf)&&o.push(h.data),i(h)})};return i(this),o}getCheckedKeys(e=!1){return this.getCheckedNodes(e).map(n=>(n||{})[this.key])}getHalfCheckedNodes(){const e=[],n=function(o){(o.root?o.root.childNodes:o.childNodes).forEach(s=>{s.indeterminate&&e.push(s.data),n(s)})};return n(this),e}getHalfCheckedKeys(){return this.getHalfCheckedNodes().map(e=>(e||{})[this.key])}_getAllNodes(){const e=[],n=this.nodesMap;for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&e.push(n[o]);return e}updateChildren(e,n){const o=this.nodesMap[e];if(!o)return;const i=o.childNodes;for(let s=i.length-1;s>=0;s--){const c=i[s];this.remove(c.data)}for(let s=0,c=n.length;s<c;s++){const h=n[s];this.append(h,o.data)}}_setCheckedKeys(e,n=!1,o){const i=this._getAllNodes().sort((h,y)=>y.level-h.level),s=Object.create(null),c=Object.keys(o);i.forEach(h=>h.setChecked(!1,!1));for(let h=0,y=i.length;h<y;h++){const f=i[h],C=f.data[e].toString();if(!(c.indexOf(C)>-1)){f.checked&&!s[C]&&f.setChecked(!1,!1);continue}let v=f.parent;for(;v&&v.level>0;)s[v.data[e]]=!0,v=v.parent;if(f.isLeaf||this.checkStrictly){f.setChecked(!0,!1);continue}if(f.setChecked(!0,!0),n){f.setChecked(!1,!1);const E=function(D){D.childNodes.forEach(x=>{x.isLeaf||x.setChecked(!1,!1),E(x)})};E(f)}}}setCheckedNodes(e,n=!1){const o=this.key,i={};e.forEach(s=>{i[(s||{})[o]]=!0}),this._setCheckedKeys(o,n,i)}setCheckedKeys(e,n=!1){this.defaultCheckedKeys=e;const o=this.key,i={};e.forEach(s=>{i[s]=!0}),this._setCheckedKeys(o,n,i)}setDefaultExpandedKeys(e){e=e||[],this.defaultExpandedKeys=e,e.forEach(n=>{const o=this.getNode(n);o&&o.expand(null,this.autoExpandParent)})}setChecked(e,n,o){const i=this.getNode(e);i&&i.setChecked(!!n,o)}getCurrentNode(){return this.currentNode}setCurrentNode(e){const n=this.currentNode;n&&(n.isCurrent=!1),this.currentNode=e,this.currentNode.isCurrent=!0}setUserCurrentNode(e){const n=e[this.key],o=this.nodesMap[n];this.setCurrentNode(o)}setCurrentNodeKey(e){if(e==null){this.currentNode&&(this.currentNode.isCurrent=!1),this.currentNode=null;return}const n=this.getNode(e);n&&this.setCurrentNode(n)}}const _=(t,e)=>t.classList.add(e),ee=(t,e)=>t.classList.remove(e),xe=d.defineComponent({name:"TreeCollapseTransition",setup(t,{slots:e}){return()=>d.h(d.Transition,{onBeforeEnter(n){const o=n;_(o,"collapse-transition"),o.dataset.oldPaddingTop=o.style.paddingTop,o.dataset.oldPaddingBottom=o.style.paddingBottom,o.style.height="0",o.style.paddingTop="0",o.style.paddingBottom="0"},onEnter(n){const o=n;o.dataset.oldOverflow=o.style.overflow,o.scrollHeight!==0?(o.style.height=o.scrollHeight+"px",o.style.paddingTop=o.dataset.oldPaddingTop||"",o.style.paddingBottom=o.dataset.oldPaddingBottom||""):(o.style.height="",o.style.paddingTop=o.dataset.oldPaddingTop||"",o.style.paddingBottom=o.dataset.oldPaddingBottom||""),o.style.overflow="hidden"},onAfterEnter(n){const o=n;ee(o,"collapse-transition"),o.style.height="",o.style.overflow=o.dataset.oldOverflow||""},onBeforeLeave(n){const o=n;o.dataset.oldPaddingTop=o.style.paddingTop,o.dataset.oldPaddingBottom=o.style.paddingBottom,o.dataset.oldOverflow=o.style.overflow,o.style.height=o.scrollHeight+"px",o.style.overflow="hidden"},onLeave(n){const o=n;o.scrollHeight!==0&&(_(o,"collapse-transition"),o.style.height="0",o.style.paddingTop="0",o.style.paddingBottom="0")},onAfterLeave(n){const o=n;ee(o,"collapse-transition"),o.style.height="",o.style.overflow=o.dataset.oldOverflow||"",o.style.paddingTop=o.dataset.oldPaddingTop||"",o.style.paddingBottom=o.dataset.oldPaddingBottom||""}},e.default)}}),Be=d.defineComponent({name:"VueTreeNode",components:{TreeCollapseTransition:xe},props:{node:{type:Object,required:!0},renderContent:Function,renderAfterExpand:{type:Boolean,default:!0},showCheckbox:{type:Boolean,default:!1}},emits:["node-expand"],setup(t,{emit:e}){const n=d.inject("vueTree"),o=d.ref(),i=d.ref(!1),s=d.ref(!1),c=d.ref(null),h=d.ref(null),y=d.computed(()=>({props:{node:{type:Object,required:!0}},setup(u){return()=>{var N;return t.renderContent?t.renderContent(d.h,{_self:n,node:u.node,data:u.node.data,store:u.node.store}):(N=n==null?void 0:n.slots)!=null&&N.default?n.slots.default({node:u.node,data:u.node.data}):d.h("span",{class:"vue-tree-node__label"},u.node.label)}}}));d.watch(()=>t.node.indeterminate,u=>{C(t.node.checked,u)}),d.watch(()=>t.node.checked,u=>{C(u,t.node.indeterminate)}),d.watch(()=>t.node.expanded,u=>{d.nextTick(()=>i.value=u),u&&(s.value=!0)});function f(u){return W(n.nodeKey,u.data)}function C(u,N){(c.value!==u||h.value!==N)&&n.emitEvent("check-change",t.node.data,u,N),c.value=u,h.value=N}function k(){const u=n.store;u.setCurrentNode(t.node),n.emitEvent("current-change",u.currentNode?u.currentNode.data:null,u.currentNode),n.currentNode=o.value,n.expandOnClickNode&&E(),n.checkOnClickNode&&!t.node.disabled&&D({target:{checked:!t.node.checked}}),n.emitEvent("node-click",t.node.data,t.node,{$el:o.value})}function v(u){n.emitEvent("node-contextmenu",u,t.node.data,t.node,{$el:o.value})}function E(){t.node.isLeaf||(i.value?(n.emitEvent("node-collapse",t.node.data,t.node,{$el:o.value}),t.node.collapse()):(t.node.expand(),e("node-expand",t.node.data,t.node,{$el:o.value})))}function D(u){const N=u.target;t.node.setChecked(N.checked,!n.checkStrictly),d.nextTick(()=>{const B=n.store;n.emitEvent("check",t.node.data,{checkedNodes:B.getCheckedNodes(),checkedKeys:B.getCheckedKeys(),halfCheckedNodes:B.getHalfCheckedNodes(),halfCheckedKeys:B.getHalfCheckedKeys()})})}function O(u,N,B){n.broadcastTreeNodeExpand(N),n.emitEvent("node-expand",u,N,B)}function x(u){n.draggable&&n.handleTreeNodeDragStart(u,{node:t.node,$el:o.value})}function I(u){n.draggable&&(n.handleTreeNodeDragOver(u,{node:t.node,$el:o.value}),u.preventDefault())}function P(u){u.preventDefault()}function z(u){n.draggable&&n.handleTreeNodeDragEnd(u,{node:t.node,$el:o.value})}const j=u=>{t.node!==u&&t.node.collapse()};d.onMounted(()=>{n.accordion&&n.onAccordionExpand(j)});const L=(n.props||{}).children||"children";return d.watch(()=>{var u;return(u=t.node.data)==null?void 0:u[L]},()=>{t.node.updateChildren()}),t.node.expanded&&(i.value=!0,s.value=!0),{tree:n,nodeRef:o,expanded:i,childNodeRendered:s,nodeContentComponent:y,getNodeKey:f,handleClick:k,handleContextMenu:v,handleExpandIconClick:E,handleCheckChange:D,handleChildNodeExpand:O,handleDragStart:x,handleDragOver:I,handleDrop:P,handleDragEnd:z}}}),te=(t,e)=>{const n=t.__vccOpts||t;for(const[o,i]of e)n[o]=i;return n},Te=["aria-expanded","aria-disabled","aria-checked","draggable"],Se=["checked","disabled"],Oe={key:1,class:"vue-tree-node__loading-icon vue-icon-loading"},Le=["aria-expanded"];function Ae(t,e,n,o,i,s){var y;const c=d.resolveComponent("vue-tree-node",!0),h=d.resolveComponent("tree-collapse-transition");return d.withDirectives((d.openBlock(),d.createElementBlock("div",{class:d.normalizeClass(["vue-tree-node",{"is-expanded":t.expanded,"is-current":t.node.isCurrent,"is-hidden":!t.node.visible,"is-focusable":!t.node.disabled,"is-checked":!t.node.disabled&&t.node.checked}]),onClick:e[3]||(e[3]=d.withModifiers((...f)=>t.handleClick&&t.handleClick(...f),["stop"])),onContextmenu:e[4]||(e[4]=(...f)=>t.handleContextMenu&&t.handleContextMenu(...f)),role:"treeitem",tabindex:"-1","aria-expanded":t.expanded,"aria-disabled":t.node.disabled,"aria-checked":t.node.checked,draggable:(y=t.tree)==null?void 0:y.draggable,onDragstart:e[5]||(e[5]=d.withModifiers((...f)=>t.handleDragStart&&t.handleDragStart(...f),["stop"])),onDragover:e[6]||(e[6]=d.withModifiers((...f)=>t.handleDragOver&&t.handleDragOver(...f),["stop"])),onDragend:e[7]||(e[7]=d.withModifiers((...f)=>t.handleDragEnd&&t.handleDragEnd(...f),["stop"])),onDrop:e[8]||(e[8]=d.withModifiers((...f)=>t.handleDrop&&t.handleDrop(...f),["stop"])),ref:"nodeRef"},[d.createElementVNode("div",{class:"vue-tree-node__content",style:d.normalizeStyle({"padding-left":(t.node.level-1)*t.tree.indent+"px"})},[d.createElementVNode("span",{onClick:e[0]||(e[0]=d.withModifiers((...f)=>t.handleExpandIconClick&&t.handleExpandIconClick(...f),["stop"])),class:d.normalizeClass([{"is-leaf":t.node.isLeaf,expanded:!t.node.isLeaf&&t.expanded},"vue-tree-node__expand-icon",t.tree.iconClass?t.tree.iconClass:"vue-icon-caret-right"])},null,2),t.showCheckbox?(d.openBlock(),d.createElementBlock("label",{key:0,class:d.normalizeClass(["vue-checkbox",{"is-checked":t.node.checked,"is-indeterminate":t.node.indeterminate,"is-disabled":!!t.node.disabled}]),onClick:e[2]||(e[2]=d.withModifiers(()=>{},["stop"]))},[d.createElementVNode("span",{class:d.normalizeClass(["vue-checkbox__input",{"is-checked":t.node.checked,"is-indeterminate":t.node.indeterminate,"is-disabled":!!t.node.disabled}])},[e[9]||(e[9]=d.createElementVNode("span",{class:"vue-checkbox__inner"},null,-1)),d.createElementVNode("input",{type:"checkbox",class:"vue-checkbox__original",checked:t.node.checked,disabled:!!t.node.disabled,onChange:e[1]||(e[1]=(...f)=>t.handleCheckChange&&t.handleCheckChange(...f))},null,40,Se)],2)],2)):d.createCommentVNode("",!0),t.node.loading?(d.openBlock(),d.createElementBlock("span",Oe)):d.createCommentVNode("",!0),(d.openBlock(),d.createBlock(d.resolveDynamicComponent(t.nodeContentComponent),{node:t.node},null,8,["node"]))],4),d.createVNode(h,null,{default:d.withCtx(()=>[!t.renderAfterExpand||t.childNodeRendered?d.withDirectives((d.openBlock(),d.createElementBlock("div",{key:0,class:"vue-tree-node__children",role:"group","aria-expanded":t.expanded},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(t.node.childNodes,f=>(d.openBlock(),d.createBlock(c,{key:t.getNodeKey(f),"render-content":t.renderContent,"render-after-expand":t.renderAfterExpand,"show-checkbox":t.showCheckbox,node:f,onNodeExpand:t.handleChildNodeExpand},null,8,["render-content","render-after-expand","show-checkbox","node","onNodeExpand"]))),128))],8,Le)),[[d.vShow,t.expanded]]):d.createCommentVNode("",!0)]),_:1})],42,Te)),[[d.vShow,t.node.visible]])}const $e=te(Be,[["render",Ae]]);function Me(t,e){if(!t||!e)return;const n=e.split(" ");for(const o of n)o&&t.classList.add(o)}function U(t,e){if(!t||!e)return;const n=e.split(" ");for(const o of n)o&&t.classList.remove(o)}const Ie=d.defineComponent({name:"VueTree",components:{VueTreeNode:$e,VirtualList:we},props:{data:{type:Array,default:()=>[]},emptyText:{type:String,default:"暂无数据"},renderAfterExpand:{type:Boolean,default:!0},nodeKey:String,checkStrictly:Boolean,defaultExpandAll:Boolean,expandOnClickNode:{type:Boolean,default:!0},checkOnClickNode:Boolean,checkDescendants:{type:Boolean,default:!1},autoExpandParent:{type:Boolean,default:!0},defaultCheckedKeys:Array,defaultExpandedKeys:Array,currentNodeKey:[String,Number],renderContent:Function,showCheckbox:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},allowDrag:Function,allowDrop:Function,props:{default(){return{children:"children",label:"label",disabled:"disabled"}}},lazy:{type:Boolean,default:!1},highlightCurrent:Boolean,load:Function,filterNodeMethod:Function,accordion:Boolean,indent:{type:Number,default:18},iconClass:String,virtual:{type:Boolean,default:!1}},emits:["node-expand","current-change","check-change","check","node-click","node-contextmenu","node-collapse","node-drag-start","node-drag-enter","node-drag-leave","node-drag-over","node-drag-end","node-drop"],setup(t,{emit:e,expose:n}){const o=d.useSlots(),i=d.getCurrentInstance(),s=d.ref(null),c=d.ref(null),h=d.ref(null),y=d.ref(),f=d.ref(),C=d.ref(),k=d.reactive({showDropIndicator:!1,draggingNode:null,dropNode:null,allowDrop:!0,dropType:""}),v=[];function E(r){v.push(r)}function D(r){v.forEach(a=>a(r))}function O(r,...a){e(r,...a)}d.provide("vueTree",{get store(){return s.value},get nodeKey(){return t.nodeKey},get props(){return t.props},get expandOnClickNode(){return t.expandOnClickNode},get checkOnClickNode(){return t.checkOnClickNode},get checkStrictly(){return t.checkStrictly},get draggable(){return t.draggable},get accordion(){return t.accordion},get indent(){return t.indent},get iconClass(){return t.iconClass},get currentNode(){return h.value},set currentNode(r){h.value=r},slots:o,emitEvent:O,broadcastTreeNodeExpand:D,onAccordionExpand:E,handleTreeNodeDragStart:Ne,handleTreeNodeDragOver:Ce,handleTreeNodeDragEnd:ve}),s.value=new De({key:t.nodeKey,data:t.data,lazy:t.lazy,props:t.props,load:t.load,currentNodeKey:t.currentNodeKey,checkStrictly:t.checkStrictly,checkDescendants:t.checkDescendants,defaultCheckedKeys:t.defaultCheckedKeys,defaultExpandedKeys:t.defaultExpandedKeys,autoExpandParent:t.autoExpandParent,defaultExpandAll:t.defaultExpandAll,filterNodeMethod:t.filterNodeMethod}),c.value=s.value.root;function x(r){return W(t.nodeKey,r.data)}const I=d.computed(()=>{const r=c.value.childNodes;return!r||r.length===0||r.every(({visible:a})=>!a)});d.watch(()=>t.defaultCheckedKeys,r=>{s.value.setDefaultCheckedKey(r)}),d.watch(()=>t.defaultExpandedKeys,r=>{s.value.defaultExpandedKeys=r,s.value.setDefaultExpandedKeys(r)}),d.watch(()=>t.data,r=>{s.value.setData(r),t.currentNodeKey&&s.value.setCurrentNodeKey(t.currentNodeKey)}),d.watch(()=>t.currentNodeKey,r=>{r&&s.value.setCurrentNodeKey(r)}),d.watch(()=>t.checkStrictly,r=>{s.value.checkStrictly=!!r});function P(r){if(!t.filterNodeMethod)throw new Error("[Tree] filterNodeMethod is required when filter");s.value.filter(r)}function z(r){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in getNodePath");const a=s.value.getNode(r);if(!a)return[];const l=[a.data];let p=a.parent;for(;p&&p!==c.value;)l.push(p.data),p=p.parent;return l.reverse()}function j(r,a){return s.value.getCheckedNodes(r,a)}function Y(r){return s.value.getCheckedKeys(r)}function L(){const r=s.value.getCurrentNode();return r?r.data:null}function u(){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in getCurrentKey");const r=L();return r?r[t.nodeKey]:null}function N(r,a){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in setCheckedNodes");s.value.setCheckedNodes(r,a)}function B(r,a){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in setCheckedKeys");s.value.setCheckedKeys(r,a)}function oe(r,a,l){s.value.setChecked(r,a,l)}function de(){return s.value.getHalfCheckedNodes()}function re(){return s.value.getHalfCheckedKeys()}function ie(r){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in setCurrentNode");s.value.setUserCurrentNode(r)}function se(r){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in setCurrentKey");s.value.setCurrentNodeKey(r)}function G(r){return!t.nodeKey||!t.virtual?-1:c.value.childNodes.findIndex(a=>String(x(a))===String(r))}function ae(r){var l,p;const a=G(r);return a<0?!1:!!((p=(l=C.value)==null?void 0:l.isIndexVisible)!=null&&p.call(l,a))}async function le(r){var l,p;const a=G(r);a<0||await((p=(l=C.value)==null?void 0:l.scrollToIndex)==null?void 0:p.call(l,a))}function ce(r){return s.value.getNode(r)}function he(r){s.value.remove(r)}function ue(r,a){s.value.append(r,a)}function fe(r,a){s.value.insertBefore(r,a)}function pe(r,a){s.value.insertAfter(r,a)}function ye(r,a,l){D(a),e("node-expand",r,a,l)}function ge(r,a,l){e("node-collapse",r,a,l)}function ke(r,a){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in updateKeyChild");s.value.updateChildren(r,a)}function Ne(r,a){if(typeof t.allowDrag=="function"&&!t.allowDrag(a.node))return r.preventDefault(),!1;r.dataTransfer.effectAllowed="move";try{r.dataTransfer.setData("text/plain","")}catch{}k.draggingNode=a,e("node-drag-start",a.node,r)}function Ce(r,a){var X;const l=a,p=k.dropNode;p&&p!==l&&U(p.$el,"is-drop-inner");const g=k.draggingNode;if(!g||!l)return;let K=!0,m=!0,w=!0,J=!0;typeof t.allowDrop=="function"&&(K=t.allowDrop(g.node,l.node,"prev"),J=m=t.allowDrop(g.node,l.node,"inner"),w=t.allowDrop(g.node,l.node,"next")),r.dataTransfer.dropEffect=m?"move":"none",(K||m||w)&&p!==l&&(p&&e("node-drag-leave",g.node,p.node,r),e("node-drag-enter",g.node,l.node,r)),(K||m||w)&&(k.dropNode=l),l.node.nextSibling===g.node&&(w=!1),l.node.previousSibling===g.node&&(K=!1),l.node.contains(g.node,!1)&&(m=!1),(g.node===l.node||g.node.contains(l.node))&&(K=!1,m=!1,w=!1);const q=l.$el.getBoundingClientRect(),V=((X=i==null?void 0:i.proxy)==null?void 0:X.$el).getBoundingClientRect();let b;const Ee=K?m?.25:w?.45:1:-1,Ke=w?m?.75:K?.55:0:1;let F=-9999;const Q=r.clientY-q.top;Q<q.height*Ee?b="before":Q>q.height*Ke?b="after":m?b="inner":b="none";const H=l.$el.querySelector(".vue-tree-node__expand-icon").getBoundingClientRect(),R=y.value;b==="before"?F=H.top-V.top:b==="after"&&(F=H.bottom-V.top),R&&(R.style.top=F+"px",R.style.left=H.right-V.left+"px"),b==="inner"?Me(l.$el,"is-drop-inner"):U(l.$el,"is-drop-inner"),k.showDropIndicator=b==="before"||b==="after",k.allowDrop=k.showDropIndicator||J,k.dropType=b,e("node-drag-over",g.node,l.node,r)}function ve(r){const{draggingNode:a,dropType:l,dropNode:p}=k;if(r.preventDefault(),r.dataTransfer.dropEffect="move",a&&p){const g={data:a.node.data};l!=="none"&&a.node.remove(),l==="before"?p.node.parent.insertBefore(g,p.node):l==="after"?p.node.parent.insertAfter(g,p.node):l==="inner"&&p.node.insertChild(g),l!=="none"&&s.value.registerNode(g),U(p.$el,"is-drop-inner"),e("node-drag-end",a.node,p.node,l,r),l!=="none"&&e("node-drop",a.node,p.node,l,r)}a&&!p&&e("node-drag-end",a.node,null,l,r),k.showDropIndicator=!1,k.draggingNode=null,k.dropNode=null,k.allowDrop=!0}function me(r){var w;const a=r.target;if(a.className.indexOf("vue-tree-node")===-1)return;const l=(w=i==null?void 0:i.proxy)==null?void 0:w.$el,p=Array.from(l.querySelectorAll(".is-focusable[role=treeitem]")),g=p.indexOf(a);let K;[38,40].indexOf(r.keyCode)>-1&&(r.preventDefault(),r.keyCode===38?K=g!==0?g-1:0:K=g<p.length-1?g+1:0,p[K].focus()),[37,39].indexOf(r.keyCode)>-1&&(r.preventDefault(),a.click());const m=a.querySelector('[type="checkbox"]');[13,32].indexOf(r.keyCode)>-1&&m&&(r.preventDefault(),m.click())}return d.onMounted(()=>{var a;((a=i==null?void 0:i.proxy)==null?void 0:a.$el).addEventListener("keydown",me)}),n({filter:P,getNodePath:z,getCheckedNodes:j,getCheckedKeys:Y,getCurrentNode:L,getCurrentKey:u,setCheckedNodes:N,setCheckedKeys:B,setChecked:oe,getHalfCheckedNodes:de,getHalfCheckedKeys:re,setCurrentNode:ie,setCurrentKey:se,isKeyVisible:ae,scrollToKey:le,getNode:ce,remove:he,append:ue,insertBefore:fe,insertAfter:pe,updateKeyChildren:ke,store:s}),{store:s,root:c,currentNode:h,dragState:k,dropIndicator:y,treeContainerRef:f,virtualListRef:C,isEmpty:I,getNodeKeyFn:x,handleNodeExpand:ye,handleNodeCollapse:ge}}}),Pe={key:2,class:"vue-tree__empty-block"},ze={class:"vue-tree__empty-text"},je={class:"vue-tree__drop-indicator",ref:"dropIndicator"};function qe(t,e,n,o,i,s){const c=d.resolveComponent("vue-tree-node"),h=d.resolveComponent("virtual-list");return d.openBlock(),d.createElementBlock("div",{ref:"treeContainerRef",class:d.normalizeClass(["vue-tree",{"vue-tree--highlight-current":t.highlightCurrent,"vue-tree--virtual":t.virtual,"is-dragging":!!t.dragState.draggingNode,"is-drop-not-allow":!t.dragState.allowDrop,"is-drop-inner":t.dragState.dropType==="inner"}]),role:"tree"},[t.virtual&&!t.isEmpty?(d.openBlock(),d.createBlock(h,{key:0,ref:"virtualListRef","list-data":t.root.childNodes,"estimated-item-size":28,height:"100%"},{default:d.withCtx(({item:y})=>[d.createVNode(c,{node:y.item,props:t.props,"render-after-expand":t.renderAfterExpand,"show-checkbox":t.showCheckbox,"render-content":t.renderContent,onNodeExpand:t.handleNodeExpand,onNodeCollapse:t.handleNodeCollapse},null,8,["node","props","render-after-expand","show-checkbox","render-content","onNodeExpand","onNodeCollapse"])]),_:1},8,["list-data"])):d.createCommentVNode("",!0),!t.virtual&&!t.isEmpty?(d.openBlock(!0),d.createElementBlock(d.Fragment,{key:1},d.renderList(t.root.childNodes,y=>(d.openBlock(),d.createBlock(c,{key:t.getNodeKeyFn(y),node:y,props:t.props,"render-after-expand":t.renderAfterExpand,"show-checkbox":t.showCheckbox,"render-content":t.renderContent,onNodeExpand:t.handleNodeExpand,onNodeCollapse:t.handleNodeCollapse},null,8,["node","props","render-after-expand","show-checkbox","render-content","onNodeExpand","onNodeCollapse"]))),128)):d.createCommentVNode("",!0),t.isEmpty?(d.openBlock(),d.createElementBlock("div",Pe,[d.renderSlot(t.$slots,"empty",{},()=>[d.createElementVNode("span",ze,d.toDisplayString(t.emptyText),1)])])):d.createCommentVNode("",!0),d.withDirectives(d.createElementVNode("div",je,null,512),[[d.vShow,t.dragState.showDropIndicator]])],2)}const ne=te(Ie,[["render",qe]]);exports.VueTree=ne;exports.default=ne;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("vue"),Oe=require("@cw-devops-fe/virtual-list-vue3"),M="$treeNodeId",ee=function(e,t){!t||t[M]||Object.defineProperty(t,M,{value:e.id,enumerable:!1,configurable:!1,writable:!1})},Z=function(e,t){return e?t[e]:t[M]},q=e=>{let t=!0,n=!0,o=!0;for(let i=0,s=e.length;i<s;i++){const a=e[i];(a.checked!==!0||a.indeterminate)&&(t=!1,a.disabled||(o=!1)),(a.checked!==!1||a.indeterminate)&&(n=!1)}return{all:t,none:n,allWithoutDisable:o,half:!t&&!n}};function oe(e){const{all:t,half:n,none:o}=q(e.childNodes);t?(e.checked=!0,e.indeterminate=!1):n?(e.checked=!1,e.indeterminate=!0):o&&(e.checked=!1,e.indeterminate=!1)}const L=function(e){if(e.childNodes.length===0||e.loading)return;oe(e);const t=e.parent;!t||t.level===0||e.store.checkStrictly||L(t)},R=function(e,t){const n=e.store.props,o=e.data||{},i=n[t];if(typeof i=="function")return i(o,e);if(typeof i=="string")return o[i];if(typeof i>"u"){const s=o[t];return s===void 0?"":s}};let $e=0;class A{constructor(t){var a;this.id=$e++,this.text=null,this.checked=!1,this.indeterminate=!1,this.data=null,this.expanded=!1,this.parent=null,this.visible=!0,this.isCurrent=!1,this.isLeaf=!1;for(const l in t)Object.prototype.hasOwnProperty.call(t,l)&&(this[l]=t[l]);this.level=0,this.loaded=!1,this.childNodes=[],this.loading=!1,this.parent&&(this.level=this.parent.level+1);const n=this.store;if(!n)throw new Error("[Node]store is required!");n.registerNode(this);const o=n.props;if(o&&typeof o.isLeaf<"u"){const l=R(this,"isLeaf");typeof l=="boolean"&&(this.isLeafByUser=l)}if(n.lazy!==!0&&this.data?(this.setData(this.data),n.defaultExpandAll&&(this.expanded=!0)):this.level>0&&n.lazy&&n.defaultExpandAll&&this.expand(),Array.isArray(this.data)||ee(this,this.data),!this.data)return;const i=n.defaultExpandedKeys,s=n.key;s&&i&&i.indexOf(this.key)!==-1&&this.expand(null,n.autoExpandParent),(a=n.isVirtual)!=null&&a.call(n)?s&&n.currentNodeKey!=null&&this.key===n.currentNodeKey&&n.setCurrentNode(this):s&&n.currentNodeKey!==void 0&&this.key===n.currentNodeKey&&(n.currentNode=this,n.currentNode.isCurrent=!0),n.lazy&&n._initDefaultCheckedNode(this),this.updateLeafState()}setData(t){var o,i;Array.isArray(t)||ee(this,t),this.data=t,this.childNodes=[];let n;this.level===0&&((i=(o=this.store).isVirtual)!=null&&i.call(o)?Array.isArray(this.data):this.data instanceof Array)?n=this.data:n=R(this,"children")||[];for(let s=0,a=n.length;s<a;s++)this.insertChild({data:n[s]})}get label(){return R(this,"label")}get key(){const t=this.store.key;return this.data?this.data[t]:null}get disabled(){return R(this,"disabled")}get nextSibling(){const t=this.parent;if(t){const n=t.childNodes.indexOf(this);if(n>-1)return t.childNodes[n+1]}return null}get previousSibling(){const t=this.parent;if(t){const n=t.childNodes.indexOf(this);if(n>-1)return n>0?t.childNodes[n-1]:null}return null}contains(t,n=!0){const o=function(i){const s=i.childNodes||[];let a=!1;for(let l=0,f=s.length;l<f;l++){const c=s[l];if(c===t||n&&o(c)){a=!0;break}}return a};return o(this)}remove(){const t=this.parent;t&&t.removeChild(this)}insertChild(t,n,o){if(!t)throw new Error("insertChild error: child is required.");if(!(t instanceof A)){if(!o){const i=this.getChildren(!0)||[];i.indexOf(t.data)===-1&&(typeof n>"u"||n<0?i.push(t.data):i.splice(n,0,t.data))}Object.assign(t,{parent:this,store:this.store}),t=new A(t)}t.level=this.level+1,typeof n>"u"||n<0?this.childNodes.push(t):this.childNodes.splice(n,0,t),this.updateLeafState()}insertBefore(t,n){let o;n&&(o=this.childNodes.indexOf(n)),this.insertChild(t,o)}insertAfter(t,n){let o;n&&(o=this.childNodes.indexOf(n),o!==-1&&(o+=1)),this.insertChild(t,o)}removeChild(t){const n=this.getChildren()||[],o=n.indexOf(t.data);o>-1&&n.splice(o,1);const i=this.childNodes.indexOf(t);i>-1&&(this.store&&this.store.deregisterNode(t),t.parent=null,this.childNodes.splice(i,1)),this.updateLeafState()}removeChildByData(t){let n=null;for(let o=0;o<this.childNodes.length;o++)if(this.childNodes[o].data===t){n=this.childNodes[o];break}n&&this.removeChild(n)}expand(t,n){var i,s;if((s=(i=this.store).isVirtual)!=null&&s.call(i)){this.expandVirtual(t,n);return}const o=()=>{if(n){let a=this.parent;for(;a.level>0;)a.expanded=!0,a=a.parent}this.expanded=!0,t&&t()};this.shouldLoadData()?this.loadData(a=>{a instanceof Array&&(this.checked?this.setChecked(!0,!0):this.store.checkStrictly||L(this),o())}):o()}expandVirtual(t,n){if(n){let o=this.parent;for(;o&&o.level>0;)o.expanded=!0,o=o.parent}if(this.expanded=!0,this.shouldLoadData()){const o=d.reactive(this);o.loadData(i=>{Array.isArray(i)&&(o.checked?o.setChecked(!0,!0):o.store.checkStrictly||L(o),t==null||t())})}else t==null||t()}doCreateChildren(t,n={}){t.forEach(o=>{this.insertChild(Object.assign({data:o},n),void 0,!0)})}collapse(){this.expanded=!1}shouldLoadData(){return this.store.lazy===!0&&this.store.load&&!this.loaded}updateLeafState(){if(this.store.lazy===!0&&this.loaded!==!0&&typeof this.isLeafByUser<"u"){this.isLeaf=this.isLeafByUser;return}const t=this.childNodes;if(!this.store.lazy||this.store.lazy===!0&&this.loaded===!0){this.isLeaf=!t||t.length===0;return}this.isLeaf=!1}setChecked(t,n,o,i){if(this.indeterminate=t==="half",this.checked=t===!0,this.store.checkStrictly)return;if(!(this.shouldLoadData()&&!this.store.checkDescendants)){const{allWithoutDisable:a}=q(this.childNodes);!this.isLeaf&&!q(this.childNodes).all&&a&&(this.checked=!1,t=!1);const l=()=>{if(n){const f=this.childNodes;for(let y=0,C=f.length;y<C;y++){const N=f[y];i=i||t!==!1;const m=N.disabled?N.checked:i;N.setChecked(m,n,!0,i)}const{half:c,all:k}=q(f);k||(this.checked=k,this.indeterminate=c)}};if(this.shouldLoadData()){this.loadData(()=>{l(),L(this)},{checked:t!==!1});return}else l()}const s=this.parent;!s||s.level===0||o||L(s)}getChildren(t=!1){var s,a;if(this.level===0)return this.data;const n=this.data;if(!n)return null;const o=this.store.props;let i="children";return o&&(i=o.children||"children"),!((a=(s=this.store).isVirtual)!=null&&a.call(s))&&n[i]===void 0&&(n[i]=null),t&&!n[i]&&(n[i]=[]),n[i]}updateChildren(){var s,a;if((a=(s=this.store).isVirtual)!=null&&a.call(s)&&!this.store.lazy){this.updateVirtualChildren();return}const t=this.getChildren()||[],n=this.childNodes.map(l=>l.data),o={},i=[];t.forEach((l,f)=>{const c=l[M];!!c&&n.findIndex(y=>y[M]===c)>=0?o[c]={index:f,data:l}:i.push({index:f,data:l})}),this.store.lazy||n.forEach(l=>{o[l[M]]||this.removeChildByData(l)}),i.forEach(({index:l,data:f})=>{this.insertChild({data:f},l)}),this.updateLeafState()}updateVirtualChildren(){const t=this.getChildren()||[],n=new Map(this.childNodes.map(i=>[i.data,i])),o=[];t.forEach(i=>{const s=n.get(i);s?(o.push(s),n.delete(i)):o.push(new A({data:i,parent:this,store:this.store}))}),n.forEach(i=>{this.store.deregisterNode(i),i.parent=null}),this.childNodes=o,this.updateLeafState()}loadData(t,n={}){if(this.store.lazy===!0&&this.store.load&&!this.loaded&&(!this.loading||Object.keys(n).length)){this.loading=!0;const o=i=>{this.childNodes=[],this.doCreateChildren(i,n),this.loaded=!0,this.loading=!1,this.updateLeafState(),t&&t.call(this,i)};this.store.load(this,o)}else t&&t.call(this)}}class Ve{constructor(t){var n;this.currentNode=null,this.currentNodeKey=null,this.key="",this.data=null,this.lazy=!1,this.load=null,this.props={},this.checkStrictly=!1,this.checkDescendants=!1,this.defaultCheckedKeys=[],this.defaultExpandedKeys=[],this.autoExpandParent=!0,this.defaultExpandAll=!1,this.filterNodeMethod=null;for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(this[o]=t[o]);this.nodesMap={},this.root=new A({data:this.data,store:this}),!((n=this.isVirtual)!=null&&n.call(this))&&this.initializeRoot()}initializeRoot(){const t=this.load;if(this.lazy&&t){t(this.root,n=>{this.root.doCreateChildren(n),this._initDefaultCheckedNodes()});return}this._initDefaultCheckedNodes()}collapseOtherBranches(t){const n=new Set;for(let i=t;i!==this.root;i=i.parent)n.add(i);const o=i=>{i.childNodes.forEach(s=>{n.has(s)||s.collapse(),o(s)})};o(this.root)}filter(t){const n=this.filterNodeMethod,o=this.lazy,i=function(s){const a=s.root?s.root.childNodes:s.childNodes;if(a.forEach(l=>{l.visible=n.call(l,t,l.data,l),i(l)}),!s.visible&&a.length){let l=!0;l=!a.some(f=>f.visible),s.root?s.root.visible=l===!1:s.visible=l===!1}t&&s.visible&&!s.isLeaf&&!o&&s.expand()};i(this)}setData(t){var o;t!==this.root.data?((o=this.isVirtual)!=null&&o.call(this)&&(this.root.childNodes.forEach(i=>this.deregisterVirtualNode(i)),this.data=t),this.root.setData(t),this._initDefaultCheckedNodes()):this.root.updateChildren()}getNode(t){if(t instanceof A)return t;const n=typeof t!="object"?t:Z(this.key,t);return this.nodesMap[n]||null}insertBefore(t,n){const o=this.getNode(n);o.parent.insertBefore({data:t},o)}insertAfter(t,n){const o=this.getNode(n);o.parent.insertAfter({data:t},o)}remove(t){var o;const n=this.getNode(t);if(n&&n.parent){const i=(o=this.isVirtual)==null?void 0:o.call(this);!i&&n===this.currentNode&&(this.currentNode=null),n.parent.removeChild(n),i&&!this.currentNode&&(this.currentNodeKey=null)}}append(t,n){const o=n?this.getNode(n):this.root;o&&o.insertChild({data:t})}_initDefaultCheckedNodes(){const t=this.defaultCheckedKeys||[],n=this.nodesMap;t.forEach(o=>{const i=n[o];i&&i.setChecked(!0,!this.checkStrictly)})}_initDefaultCheckedNode(t){(this.defaultCheckedKeys||[]).indexOf(t.key)!==-1&&t.setChecked(!0,!this.checkStrictly)}setDefaultCheckedKey(t){t!==this.defaultCheckedKeys&&(this.defaultCheckedKeys=t,this._initDefaultCheckedNodes())}registerNode(t){if(!this.key||!t||!t.data)return;t.key!==void 0&&(this.nodesMap[t.key]=t)}deregisterNode(t){var o;if((o=this.isVirtual)!=null&&o.call(this)){this.deregisterVirtualNode(t);return}!this.key||!t||!t.data||(t.childNodes.forEach(i=>{this.deregisterNode(i)}),delete this.nodesMap[t.key])}deregisterVirtualNode(t){t.childNodes.forEach(n=>this.deregisterVirtualNode(n)),this.currentNode===t&&(this.currentNode=null,t.isCurrent=!1),this.key&&this.nodesMap[t.key]===t&&delete this.nodesMap[t.key]}getCheckedNodes(t=!1,n=!1){const o=[],i=function(s){(s.root?s.root.childNodes:s.childNodes).forEach(l=>{(l.checked||n&&l.indeterminate)&&(!t||t&&l.isLeaf)&&o.push(l.data),i(l)})};return i(this),o}getCheckedKeys(t=!1){return this.getCheckedNodes(t).map(n=>(n||{})[this.key])}getHalfCheckedNodes(){const t=[],n=function(o){(o.root?o.root.childNodes:o.childNodes).forEach(s=>{s.indeterminate&&t.push(s.data),n(s)})};return n(this),t}getHalfCheckedKeys(){return this.getHalfCheckedNodes().map(t=>(t||{})[this.key])}_getAllNodes(){const t=[],n=this.nodesMap;for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&t.push(n[o]);return t}updateChildren(t,n){const o=this.nodesMap[t];if(!o)return;const i=o.childNodes;for(let s=i.length-1;s>=0;s--){const a=i[s];this.remove(a.data)}for(let s=0,a=n.length;s<a;s++){const l=n[s];this.append(l,o.data)}}_setCheckedKeys(t,n=!1,o){var f;const i=Object.keys(o),s=(f=this.isVirtual)!=null&&f.call(this)&&!this.lazy?new Set(i):void 0,a=this._getAllNodes();if(s&&(!i.length||this.checkStrictly||i.every(c=>{var k;return((k=this.nodesMap[c])==null?void 0:k.isLeaf)??!0}))){const c=i.length>0&&!this.checkStrictly;c&&a.sort((k,y)=>y.level-k.level),a.forEach(k=>{c&&!k.isLeaf?oe(k):(k.checked=s.has(String(k.key)),k.indeterminate=!1)});return}a.sort((c,k)=>k.level-c.level);const l=Object.create(null);a.forEach(c=>{s?(c.checked=!1,c.indeterminate=!1):c.setChecked(!1,!1)});for(let c=0,k=a.length;c<k;c++){const y=a[c],C=y.data[t].toString();if(!(s?s.has(C):i.indexOf(C)>-1)){y.checked&&!l[C]&&y.setChecked(!1,!1);continue}let m=y.parent;for(;m&&m.level>0;)l[m.data[t]]=!0,m=m.parent;if(y.isLeaf||this.checkStrictly){y.setChecked(!0,!1);continue}if(y.setChecked(!0,!0),n){y.setChecked(!1,!1);const K=function(p){p.childNodes.forEach(T=>{T.isLeaf||T.setChecked(!1,!1),K(T)})};K(y)}}}setCheckedNodes(t,n=!1){const o=this.key,i={};t.forEach(s=>{i[(s||{})[o]]=!0}),this._setCheckedKeys(o,n,i)}setCheckedKeys(t,n=!1){this.defaultCheckedKeys=t;const o=this.key,i={};t.forEach(s=>{i[s]=!0}),this._setCheckedKeys(o,n,i)}setDefaultExpandedKeys(t){t=t||[],this.defaultExpandedKeys=t,t.forEach(n=>{const o=this.getNode(n);o&&o.expand(null,this.autoExpandParent)})}setChecked(t,n,o){const i=this.getNode(t);i&&i.setChecked(!!n,o)}getCurrentNode(){return this.currentNode}setCurrentNode(t){var o;const n=this.currentNode;n&&(n.isCurrent=!1),this.currentNode=t,(o=this.isVirtual)!=null&&o.call(this)&&(this.currentNodeKey=t.key),this.currentNode.isCurrent=!0}setUserCurrentNode(t){const n=t[this.key],o=this.nodesMap[n];this.setCurrentNode(o)}setCurrentNodeKey(t){var o;if(t==null){this.currentNode&&(this.currentNode.isCurrent=!1),this.currentNode=null,(o=this.isVirtual)!=null&&o.call(this)&&(this.currentNodeKey=null);return}const n=this.getNode(t);n&&this.setCurrentNode(n)}}function Me(e){const t=[],n=o=>{o.visible&&(t.push(o),o.expanded&&o.childNodes.forEach(n))};return e.childNodes.forEach(n),t}function Ae(e,t,n,o){const i=d.computed(()=>{if(!t())return;const a=new Map,l=n(),f=c=>{var y;const k=l?c===e?void 0:c.getChildren():(y=c.getChildren())==null?void 0:y.slice();a.set(c,k),c.childNodes.forEach(f)};return f(e),a}),s=d.computed(()=>{if(!t())return;const a=new Map,l=f=>{f!==e&&a.set(f,{checked:f.checked,indeterminate:f.indeterminate}),f.childNodes.forEach(l)};return l(e),a});d.watch([i,s],([a,l],[f,c])=>{if(!a||!l)return;const k=(N,m)=>{const K=c==null?void 0:c.get(N);K&&(K.checked!==m.checked||K.indeterminate!==m.indeterminate)&&o(N)};if(a===f){l.forEach((N,m)=>k(m,N));return}const y=n(),C=N=>{if(!a.has(N))return;const m=a.get(N);y?N!==e&&(f!=null&&f.has(N))&&m!==f.get(N)&&N.updateChildren():(((m==null?void 0:m.length)??0)!==N.childNodes.length||m!=null&&m.some((w,T)=>w!==N.childNodes[T].data))&&N.updateChildren();const K=l.get(N);K&&k(N,K),N.childNodes.forEach(C)};C(e)},{immediate:!0})}const te=(e,t)=>e.classList.add(t),ne=(e,t)=>e.classList.remove(t),Le=d.defineComponent({name:"TreeCollapseTransition",setup(e,{slots:t}){return()=>d.h(d.Transition,{onBeforeEnter(n){const o=n;te(o,"collapse-transition"),o.dataset.oldPaddingTop=o.style.paddingTop,o.dataset.oldPaddingBottom=o.style.paddingBottom,o.style.height="0",o.style.paddingTop="0",o.style.paddingBottom="0"},onEnter(n){const o=n;o.dataset.oldOverflow=o.style.overflow,o.scrollHeight!==0?(o.style.height=o.scrollHeight+"px",o.style.paddingTop=o.dataset.oldPaddingTop||"",o.style.paddingBottom=o.dataset.oldPaddingBottom||""):(o.style.height="",o.style.paddingTop=o.dataset.oldPaddingTop||"",o.style.paddingBottom=o.dataset.oldPaddingBottom||""),o.style.overflow="hidden"},onAfterEnter(n){const o=n;ne(o,"collapse-transition"),o.style.height="",o.style.overflow=o.dataset.oldOverflow||""},onBeforeLeave(n){const o=n;o.dataset.oldPaddingTop=o.style.paddingTop,o.dataset.oldPaddingBottom=o.style.paddingBottom,o.dataset.oldOverflow=o.style.overflow,o.style.height=o.scrollHeight+"px",o.style.overflow="hidden"},onLeave(n){const o=n;o.scrollHeight!==0&&(te(o,"collapse-transition"),o.style.height="0",o.style.paddingTop="0",o.style.paddingBottom="0")},onAfterLeave(n){const o=n;ne(o,"collapse-transition"),o.style.height="",o.style.overflow=o.dataset.oldOverflow||"",o.style.paddingTop=o.dataset.oldPaddingTop||"",o.style.paddingBottom=o.dataset.oldPaddingBottom||""}},t.default)}}),Ie=d.defineComponent({name:"VueTreeNode",components:{TreeCollapseTransition:Le},props:{node:{type:Object,required:!0},renderContent:Function,renderAfterExpand:{type:Boolean,default:!0},showCheckbox:{type:Boolean,default:!1}},emits:["node-expand"],setup(e,{emit:t}){const n=d.inject("vueTree"),o=d.ref(),i=d.ref(!1),s=d.ref(!1),a=d.ref(null),l=d.ref(null),f=d.computed(()=>({props:{node:{type:Object,required:!0}},setup(g){return()=>{var B;return e.renderContent?e.renderContent(d.h,{_self:n,node:g.node,data:g.node.data,store:g.node.store}):(B=n==null?void 0:n.slots)!=null&&B.default?n.slots.default({node:g.node,data:g.node.data}):d.h("span",{class:"vue-tree-node__label"},g.node.label)}}}));d.watch(()=>e.node.indeterminate,g=>{k(e.node.checked,g)}),d.watch(()=>e.node.checked,g=>{k(g,e.node.indeterminate)}),d.watch(()=>e.node.expanded,g=>{d.nextTick(()=>i.value=g),g&&(s.value=!0)});function c(g){return Z(n.nodeKey,g.data)}function k(g,B){(a.value!==g||l.value!==B)&&n.emitEvent("check-change",e.node.data,g,B),a.value=g,l.value=B}function y(){const g=n.store;g.setCurrentNode(e.node),n.emitEvent("current-change",g.currentNode?g.currentNode.data:null,g.currentNode),n.currentNode=o.value,n.expandOnClickNode&&N(),n.checkOnClickNode&&!e.node.disabled&&m({target:{checked:!e.node.checked}}),n.emitEvent("node-click",e.node.data,e.node,{$el:o.value})}function C(g){n.emitEvent("node-contextmenu",g,e.node.data,e.node,{$el:o.value})}function N(){e.node.isLeaf||(i.value?(n.emitEvent("node-collapse",e.node.data,e.node,{$el:o.value}),e.node.collapse()):(e.node.expand(),t("node-expand",e.node.data,e.node,{$el:o.value})))}function m(g){const B=g.target;e.node.setChecked(B.checked,!n.checkStrictly),d.nextTick(()=>{const $=n.store;n.emitEvent("check",e.node.data,{checkedNodes:$.getCheckedNodes(),checkedKeys:$.getCheckedKeys(),halfCheckedNodes:$.getHalfCheckedNodes(),halfCheckedKeys:$.getHalfCheckedKeys()})})}function K(g,B,$){n.broadcastTreeNodeExpand(B),n.emitEvent("node-expand",g,B,$)}function p(g){n.draggable&&n.handleTreeNodeDragStart(g,{node:e.node,$el:o.value})}function w(g){n.draggable&&(n.handleTreeNodeDragOver(g,{node:e.node,$el:o.value}),g.preventDefault())}function T(g){g.preventDefault()}function I(g){n.draggable&&n.handleTreeNodeDragEnd(g,{node:e.node,$el:o.value})}const j=g=>{e.node!==g&&e.node.collapse()};d.onMounted(()=>{n.accordion&&n.onAccordionExpand(j)});const F=(n.props||{}).children||"children";return d.watch(()=>{var g;return(g=e.node.data)==null?void 0:g[F]},()=>{e.node.updateChildren()}),e.node.expanded&&(i.value=!0,s.value=!0),{tree:n,nodeRef:o,expanded:i,childNodeRendered:s,nodeContentComponent:f,getNodeKey:c,handleClick:y,handleContextMenu:C,handleExpandIconClick:N,handleCheckChange:m,handleChildNodeExpand:K,handleDragStart:p,handleDragOver:w,handleDrop:T,handleDragEnd:I}}}),G=(e,t)=>{const n=e.__vccOpts||e;for(const[o,i]of t)n[o]=i;return n},ze=["aria-expanded","aria-disabled","aria-checked","draggable"],Re=["checked","disabled"],qe={key:1,class:"vue-tree-node__loading-icon vue-icon-loading"},je=["aria-expanded"];function Fe(e,t,n,o,i,s){var f;const a=d.resolveComponent("vue-tree-node",!0),l=d.resolveComponent("tree-collapse-transition");return d.withDirectives((d.openBlock(),d.createElementBlock("div",{class:d.normalizeClass(["vue-tree-node",{"is-expanded":e.expanded,"is-current":e.node.isCurrent,"is-hidden":!e.node.visible,"is-focusable":!e.node.disabled,"is-checked":!e.node.disabled&&e.node.checked}]),onClick:t[3]||(t[3]=d.withModifiers((...c)=>e.handleClick&&e.handleClick(...c),["stop"])),onContextmenu:t[4]||(t[4]=(...c)=>e.handleContextMenu&&e.handleContextMenu(...c)),role:"treeitem",tabindex:"-1","aria-expanded":e.expanded,"aria-disabled":e.node.disabled,"aria-checked":e.node.checked,draggable:(f=e.tree)==null?void 0:f.draggable,onDragstart:t[5]||(t[5]=d.withModifiers((...c)=>e.handleDragStart&&e.handleDragStart(...c),["stop"])),onDragover:t[6]||(t[6]=d.withModifiers((...c)=>e.handleDragOver&&e.handleDragOver(...c),["stop"])),onDragend:t[7]||(t[7]=d.withModifiers((...c)=>e.handleDragEnd&&e.handleDragEnd(...c),["stop"])),onDrop:t[8]||(t[8]=d.withModifiers((...c)=>e.handleDrop&&e.handleDrop(...c),["stop"])),ref:"nodeRef"},[d.createElementVNode("div",{class:"vue-tree-node__content",style:d.normalizeStyle({"padding-left":(e.node.level-1)*e.tree.indent+"px"})},[d.createElementVNode("span",{onClick:t[0]||(t[0]=d.withModifiers((...c)=>e.handleExpandIconClick&&e.handleExpandIconClick(...c),["stop"])),class:d.normalizeClass([{"is-leaf":e.node.isLeaf,expanded:!e.node.isLeaf&&e.expanded},"vue-tree-node__expand-icon",e.tree.iconClass?e.tree.iconClass:"vue-icon-caret-right"])},null,2),e.showCheckbox?(d.openBlock(),d.createElementBlock("label",{key:0,class:d.normalizeClass(["vue-checkbox",{"is-checked":e.node.checked,"is-indeterminate":e.node.indeterminate,"is-disabled":!!e.node.disabled}]),onClick:t[2]||(t[2]=d.withModifiers(()=>{},["stop"]))},[d.createElementVNode("span",{class:d.normalizeClass(["vue-checkbox__input",{"is-checked":e.node.checked,"is-indeterminate":e.node.indeterminate,"is-disabled":!!e.node.disabled}])},[t[9]||(t[9]=d.createElementVNode("span",{class:"vue-checkbox__inner"},null,-1)),d.createElementVNode("input",{type:"checkbox",class:"vue-checkbox__original",checked:e.node.checked,disabled:!!e.node.disabled,onChange:t[1]||(t[1]=(...c)=>e.handleCheckChange&&e.handleCheckChange(...c))},null,40,Re)],2)],2)):d.createCommentVNode("",!0),e.node.loading?(d.openBlock(),d.createElementBlock("span",qe)):d.createCommentVNode("",!0),(d.openBlock(),d.createBlock(d.resolveDynamicComponent(e.nodeContentComponent),{node:e.node},null,8,["node"]))],4),d.createVNode(l,null,{default:d.withCtx(()=>[!e.renderAfterExpand||e.childNodeRendered?d.withDirectives((d.openBlock(),d.createElementBlock("div",{key:0,class:"vue-tree-node__children",role:"group","aria-expanded":e.expanded},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(e.node.childNodes,c=>(d.openBlock(),d.createBlock(a,{key:e.getNodeKey(c),"render-content":e.renderContent,"render-after-expand":e.renderAfterExpand,"show-checkbox":e.showCheckbox,node:c,onNodeExpand:e.handleChildNodeExpand},null,8,["render-content","render-after-expand","show-checkbox","node","onNodeExpand"]))),128))],8,je)),[[d.vShow,e.expanded]]):d.createCommentVNode("",!0)]),_:1})],42,ze)),[[d.vShow,e.node.visible]])}const Pe=G(Ie,[["render",Fe]]),He=d.defineComponent({name:"VueTreeItem",props:{node:{type:Object,required:!0},index:{type:Number,required:!0},scheduleContent:Function,renderContent:Function,showCheckbox:{type:Boolean,default:!1}},setup(e){const t=d.inject("vueTree"),n=d.ref(),o=d.computed(()=>e.node.expanded),i=d.computed(()=>{var w;const p=t.loadingKey;return e.node.loading||!!(p&&((w=e.node.data)!=null&&w[p]))}),s=d.ref(!1);d.watch(()=>e.scheduleContent,(p,w,T)=>{s.value||(p?T(p(()=>{s.value=!0},()=>e.index)):s.value=!0)},{immediate:!0});const a=d.computed(()=>({props:{node:{type:Object,required:!0}},setup(p){return()=>{var w;return e.renderContent?e.renderContent(d.h,{_self:t,node:p.node,data:p.node.data,store:p.node.store}):(w=t==null?void 0:t.slots)!=null&&w.default?t.slots.default({node:p.node,data:p.node.data}):d.h("span",{class:"vue-tree-node__label"},p.node.label)}}}));function l(){const p=t.store;p.setCurrentNode(e.node),t.emitEvent("current-change",p.currentNode?p.currentNode.data:null,p.currentNode),t.expandOnClickNode&&c(),t.checkOnClickNode&&!e.node.disabled&&y(!e.node.checked),t.emitEvent("node-click",e.node.data,e.node,{$el:n.value})}function f(p){t.emitEvent("node-contextmenu",p,e.node.data,e.node,{$el:n.value})}function c(){e.node.isLeaf||(o.value?(t.emitEvent("node-collapse",e.node.data,e.node,{$el:n.value}),e.node.collapse()):(e.node.expand(),t.handleVirtualNodeExpand(e.node.data,e.node,{$el:n.value})))}function k(p){y(p.target.checked)}function y(p){e.node.setChecked(p,!t.checkStrictly),d.nextTick(()=>{const w=t.store;t.emitEvent("check",e.node.data,{checkedNodes:w.getCheckedNodes(),checkedKeys:w.getCheckedKeys(),halfCheckedNodes:w.getHalfCheckedNodes(),halfCheckedKeys:w.getHalfCheckedKeys()})})}function C(p){t.draggable&&t.handleTreeNodeDragStart(p,{node:e.node,$el:n.value})}function N(p){t.draggable&&(t.handleTreeNodeDragOver(p,{node:e.node,$el:n.value}),p.preventDefault())}function m(p){p.preventDefault()}function K(p){t.draggable&&t.handleTreeNodeDragEnd(p,{node:e.node,$el:n.value})}return{tree:t,nodeRef:n,expanded:o,loading:i,contentReady:s,nodeContentComponent:a,handleClick:l,handleContextMenu:f,handleExpandIconClick:c,handleCheckChange:k,handleDragStart:C,handleDragOver:N,handleDrop:m,handleDragEnd:K}}}),Ue=["aria-level","data-tree-node-id","aria-expanded","aria-disabled","aria-checked","aria-busy","draggable"],We=["checked","disabled"],Ye={key:4,class:"vue-tree-node__label"};function Ze(e,t,n,o,i,s){var a;return d.withDirectives((d.openBlock(),d.createElementBlock("div",{class:d.normalizeClass(["vue-tree-node",{"is-expanded":e.expanded,"is-current":e.node.isCurrent,"is-hidden":!e.node.visible,"is-focusable":!e.node.disabled,"is-checked":!e.node.disabled&&e.node.checked}]),onClick:t[4]||(t[4]=d.withModifiers((...l)=>e.handleClick&&e.handleClick(...l),["stop"])),onContextmenu:t[5]||(t[5]=(...l)=>e.handleContextMenu&&e.handleContextMenu(...l)),role:"treeitem","aria-level":e.node.level,"data-tree-node-id":e.node.id,tabindex:"-1","aria-expanded":e.expanded,"aria-disabled":e.node.disabled,"aria-checked":e.node.checked,"aria-busy":e.loading||void 0,draggable:(a=e.tree)==null?void 0:a.draggable,onDragstart:t[6]||(t[6]=d.withModifiers((...l)=>e.handleDragStart&&e.handleDragStart(...l),["stop"])),onDragover:t[7]||(t[7]=d.withModifiers((...l)=>e.handleDragOver&&e.handleDragOver(...l),["stop"])),onDragend:t[8]||(t[8]=d.withModifiers((...l)=>e.handleDragEnd&&e.handleDragEnd(...l),["stop"])),onDrop:t[9]||(t[9]=d.withModifiers((...l)=>e.handleDrop&&e.handleDrop(...l),["stop"])),ref:"nodeRef"},[d.createElementVNode("div",{class:"vue-tree-node__content",style:d.normalizeStyle({"padding-left":(e.node.level-1)*e.tree.indent+"px"})},[e.loading?(d.openBlock(),d.createElementBlock("div",{key:0,class:"vue-tree-node__expand-icon is-loading",onClick:t[0]||(t[0]=d.withModifiers((...l)=>e.handleExpandIconClick&&e.handleExpandIconClick(...l),["stop"]))},[d.renderSlot(e.$slots,"node-loading",{},()=>[t[10]||(t[10]=d.createElementVNode("span",{class:"vue-tree-node__loading-icon vue-icon-loading","aria-hidden":"true"},null,-1))])])):(d.openBlock(),d.createElementBlock("span",{key:1,onClick:t[1]||(t[1]=d.withModifiers((...l)=>e.handleExpandIconClick&&e.handleExpandIconClick(...l),["stop"])),class:d.normalizeClass([{"is-leaf":e.node.isLeaf,expanded:!e.node.isLeaf&&e.expanded},"vue-tree-node__expand-icon",e.tree.iconClass?e.tree.iconClass:"vue-icon-caret-right"])},null,2)),e.showCheckbox?(d.openBlock(),d.createElementBlock("label",{key:2,class:d.normalizeClass(["vue-checkbox",{"is-checked":e.node.checked,"is-indeterminate":e.node.indeterminate,"is-disabled":!!e.node.disabled}]),onClick:t[3]||(t[3]=d.withModifiers(()=>{},["stop"]))},[d.createElementVNode("span",{class:d.normalizeClass(["vue-checkbox__input",{"is-checked":e.node.checked,"is-indeterminate":e.node.indeterminate,"is-disabled":!!e.node.disabled}])},[t[11]||(t[11]=d.createElementVNode("span",{class:"vue-checkbox__inner"},null,-1)),d.createElementVNode("input",{type:"checkbox",class:"vue-checkbox__original",checked:e.node.checked,disabled:!!e.node.disabled,onChange:t[2]||(t[2]=(...l)=>e.handleCheckChange&&e.handleCheckChange(...l))},null,40,We)],2)],2)):d.createCommentVNode("",!0),e.contentReady?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(e.nodeContentComponent),{key:3,node:e.node},null,8,["node"])):(d.openBlock(),d.createElementBlock("span",Ye,d.toDisplayString(e.node.label),1))],4)],42,Ue)),[[d.vShow,e.node.visible]])}const Ge=G(He,[["render",Ze]]),Je=8,Qe=d.defineComponent({__name:"VirtualTreeRows",props:{rows:{},getRowKey:{type:Function},showCheckbox:{type:Boolean},renderContent:{type:Function},deferContent:{type:Boolean}},setup(e,{expose:t}){const n=e,o=d.ref(),i=c=>n.getRowKey(c),s=new Map;let a=null;function l(c,k){return s.set(c,k),a===null&&(a=requestAnimationFrame(f)),()=>s.delete(c)}function f(){a=null;const c=y=>{var C;return Number(((C=o.value)==null?void 0:C.isIndexVisible(y))??!1)},k=[...s].map(([y,C])=>({mount:y,index:C()})).sort((y,C)=>c(C.index)-c(y.index)||y.index-C.index).slice(0,Je);for(const{mount:y}of k)s.delete(y),y();s.size&&(a=requestAnimationFrame(f))}return d.onBeforeUnmount(()=>{a!==null&&cancelAnimationFrame(a),s.clear()}),t({isIndexVisible:c=>{var k;return((k=o.value)==null?void 0:k.isIndexVisible(c))??!1},scrollToIndex:c=>{var k;return(k=o.value)==null?void 0:k.scrollToIndex(c)}}),(c,k)=>(d.openBlock(),d.createBlock(d.unref(Oe),{ref_key:"list",ref:o,"list-data":e.rows,"item-key":i,"immediate-scroll-update":"","estimated-item-size":28,height:"100%"},{default:d.withCtx(({item:{item:y,index:C}})=>[d.createVNode(Ge,{node:y,index:Number(C.slice(1)),"show-checkbox":e.showCheckbox,"render-content":e.renderContent,"schedule-content":e.deferContent?l:void 0},d.createSlots({_:2},[c.$slots["node-loading"]?{name:"node-loading",fn:d.withCtx(()=>[d.renderSlot(c.$slots,"node-loading")]),key:"0"}:void 0]),1032,["node","index","show-checkbox","render-content","schedule-content"])]),_:3},8,["list-data"]))}});function Xe(e,t){if(!e||!t)return;const n=t.split(" ");for(const o of n)o&&e.classList.add(o)}function Y(e,t){if(!e||!t)return;const n=t.split(" ");for(const o of n)o&&e.classList.remove(o)}const _e=d.defineComponent({name:"VueTree",components:{VueTreeNode:Pe,VirtualTreeRows:Qe},props:{data:{type:Array,default:()=>[]},emptyText:{type:String,default:"暂无数据"},renderAfterExpand:{type:Boolean,default:!0},nodeKey:String,checkStrictly:Boolean,defaultExpandAll:Boolean,expandOnClickNode:{type:Boolean,default:!0},checkOnClickNode:Boolean,checkDescendants:{type:Boolean,default:!1},autoExpandParent:{type:Boolean,default:!0},defaultCheckedKeys:Array,defaultExpandedKeys:Array,currentNodeKey:[String,Number],renderContent:Function,showCheckbox:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},allowDrag:Function,allowDrop:Function,props:{default(){return{children:"children",label:"label",disabled:"disabled"}}},lazy:{type:Boolean,default:!1},highlightCurrent:Boolean,load:Function,filterNodeMethod:Function,accordion:Boolean,indent:{type:Number,default:18},iconClass:String,virtual:{type:Boolean,default:!1},deferContent:Boolean,loadingKey:String},emits:["node-expand","current-change","check-change","check","node-click","node-contextmenu","node-collapse","node-drag-start","node-drag-enter","node-drag-leave","node-drag-over","node-drag-end","node-drop"],setup(e,{emit:t,expose:n}){const o=d.useSlots(),i=d.getCurrentInstance();function s(){return e.deferContent&&!!(e.renderContent||o.default)}const a=d.ref(null),l=d.ref(null),f=d.ref(null),c=d.ref(),k=d.ref(),y=d.ref(),C=d.reactive({showDropIndicator:!1,draggingNode:null,dropNode:null,allowDrop:!0,dropType:""}),N=[];function m(r){N.push(r)}function K(r){N.forEach(h=>h(r))}function p(r,...h){t(r,...h)}d.provide("vueTree",{get store(){return a.value},get nodeKey(){return e.nodeKey},get props(){return e.props},get expandOnClickNode(){return e.expandOnClickNode},get checkOnClickNode(){return e.checkOnClickNode},get checkStrictly(){return e.checkStrictly},get draggable(){return e.draggable},get accordion(){return e.accordion},get indent(){return e.indent},get loadingKey(){return e.loadingKey},get iconClass(){return e.iconClass},get currentNode(){return f.value},set currentNode(r){f.value=r},slots:o,emitEvent:p,broadcastTreeNodeExpand:K,onAccordionExpand:m,handleVirtualNodeExpand:me,handleTreeNodeDragStart:be,handleTreeNodeDragOver:De,handleTreeNodeDragEnd:Ke}),a.value=new Ve({key:e.nodeKey,isVirtual:()=>e.virtual,data:e.data,lazy:e.lazy,props:e.props,load:e.load,currentNodeKey:e.currentNodeKey,checkStrictly:e.checkStrictly,checkDescendants:e.checkDescendants,defaultCheckedKeys:e.defaultCheckedKeys,defaultExpandedKeys:e.defaultExpandedKeys,autoExpandParent:e.autoExpandParent,defaultExpandAll:e.defaultExpandAll,filterNodeMethod:e.filterNodeMethod}),l.value=a.value.root,e.virtual&&a.value.initializeRoot();const w=d.computed(()=>e.virtual?Me(l.value):[]),T=r=>I(r)??r.id;Ae(l.value,()=>e.virtual,()=>e.lazy,r=>{t("check-change",r.data,r.checked,r.indeterminate)});function I(r){return Z(e.nodeKey,r.data)}const j=d.computed(()=>{const r=l.value.childNodes;return!r||r.length===0||r.every(({visible:h})=>!h)});d.watch(()=>e.defaultCheckedKeys,r=>{a.value.setDefaultCheckedKey(r)}),d.watch(()=>e.defaultExpandedKeys,r=>{a.value.defaultExpandedKeys=r,a.value.setDefaultExpandedKeys(r)}),d.watch(()=>e.data,r=>{a.value.setData(r),e.currentNodeKey&&a.value.setCurrentNodeKey(e.currentNodeKey)}),d.watch(()=>e.currentNodeKey,r=>{r&&a.value.setCurrentNodeKey(r)}),d.watch(()=>e.checkStrictly,r=>{a.value.checkStrictly=!!r});function J(r){if(!e.filterNodeMethod)throw new Error("[Tree] filterNodeMethod is required when filter");a.value.filter(r)}function F(r){if(!e.nodeKey)throw new Error("[Tree] nodeKey is required in getNodePath");const h=a.value.getNode(r);if(!h)return[];const u=[h.data];let v=h.parent;for(;v&&v!==l.value;)u.push(v.data),v=v.parent;return u.reverse()}function g(r,h){return a.value.getCheckedNodes(r,h)}function B(r){return a.value.getCheckedKeys(r)}function $(){const r=a.value.getCurrentNode();return r?r.data:null}function ie(){if(!e.nodeKey)throw new Error("[Tree] nodeKey is required in getCurrentKey");const r=$();return r?r[e.nodeKey]:null}function re(r,h){if(!e.nodeKey)throw new Error("[Tree] nodeKey is required in setCheckedNodes");a.value.setCheckedNodes(r,h)}function ae(r,h){if(!e.nodeKey)throw new Error("[Tree] nodeKey is required in setCheckedKeys");a.value.setCheckedKeys(r,h)}function se(r,h,u){a.value.setChecked(r,h,u)}function le(){return a.value.getHalfCheckedNodes()}function ce(){return a.value.getHalfCheckedKeys()}function he(r){if(!e.nodeKey)throw new Error("[Tree] nodeKey is required in setCurrentNode");a.value.setUserCurrentNode(r)}function ue(r){if(!e.nodeKey)throw new Error("[Tree] nodeKey is required in setCurrentKey");a.value.setCurrentNodeKey(r)}function Q(r){if(!e.virtual||!e.nodeKey)return-1;const h=a.value.getNode(r);return h?w.value.indexOf(h):-1}function fe(r){var u;const h=Q(r);return h>=0&&!!((u=y.value)!=null&&u.isIndexVisible(h))}async function ge(r){var u;if(!e.virtual)return;await d.nextTick();const h=Q(r);h>=0&&await((u=y.value)==null?void 0:u.scrollToIndex(h))}function ye(r){return a.value.getNode(r)}function ke(r){a.value.remove(r)}function pe(r,h){a.value.append(r,h)}function Ce(r,h){a.value.insertBefore(r,h)}function Ne(r,h){a.value.insertAfter(r,h)}function ve(r,h,u){K(h),t("node-expand",r,h,u)}function me(r,h,u){e.accordion&&a.value.collapseOtherBranches(h),t("node-expand",r,h,u)}function Ee(r,h,u){t("node-collapse",r,h,u)}function we(r,h){if(!e.nodeKey)throw new Error("[Tree] nodeKey is required in updateKeyChild");a.value.updateChildren(r,h)}function be(r,h){if(typeof e.allowDrag=="function"&&!e.allowDrag(h.node))return r.preventDefault(),!1;r.dataTransfer.effectAllowed="move";try{r.dataTransfer.setData("text/plain","")}catch{}C.draggingNode=h,t("node-drag-start",h.node,r)}function De(r,h){var _;const u=h,v=C.dropNode;v&&v!==u&&Y(v.$el,"is-drop-inner");const E=C.draggingNode;if(!E||!u)return;let x=!0,b=!0,D=!0,S=!0;typeof e.allowDrop=="function"&&(x=e.allowDrop(E.node,u.node,"prev"),S=b=e.allowDrop(E.node,u.node,"inner"),D=e.allowDrop(E.node,u.node,"next")),r.dataTransfer.dropEffect=b?"move":"none",(x||b||D)&&v!==u&&(v&&t("node-drag-leave",E.node,v.node,r),t("node-drag-enter",E.node,u.node,r)),(x||b||D)&&(C.dropNode=u),u.node.nextSibling===E.node&&(D=!1),u.node.previousSibling===E.node&&(x=!1),u.node.contains(E.node,!1)&&(b=!1),(E.node===u.node||E.node.contains(u.node))&&(x=!1,b=!1,D=!1);const V=u.$el.getBoundingClientRect(),P=((_=i==null?void 0:i.proxy)==null?void 0:_.$el).getBoundingClientRect();let O;const Se=x?b?.25:D?.45:1:-1,Te=D?b?.75:x?.55:0:1;let H=-9999;const X=r.clientY-V.top;X<V.height*Se?O="before":X>V.height*Te?O="after":b?O="inner":O="none";const U=u.$el.querySelector(".vue-tree-node__expand-icon").getBoundingClientRect(),W=c.value;O==="before"?H=U.top-P.top:O==="after"&&(H=U.bottom-P.top),W&&(W.style.top=H+"px",W.style.left=U.right-P.left+"px"),O==="inner"?Xe(u.$el,"is-drop-inner"):Y(u.$el,"is-drop-inner"),C.showDropIndicator=O==="before"||O==="after",C.allowDrop=C.showDropIndicator||S,C.dropType=O,t("node-drag-over",E.node,u.node,r)}function Ke(r){const{draggingNode:h,dropType:u,dropNode:v}=C;if(r.preventDefault(),r.dataTransfer.dropEffect="move",h&&v){const E={data:h.node.data};u!=="none"&&h.node.remove(),u==="before"?v.node.parent.insertBefore(E,v.node):u==="after"?v.node.parent.insertAfter(E,v.node):u==="inner"&&v.node.insertChild(E),u!=="none"&&a.value.registerNode(E),Y(v.$el,"is-drop-inner"),t("node-drag-end",h.node,v.node,u,r),u!=="none"&&t("node-drop",h.node,v.node,u,r)}h&&!v&&t("node-drag-end",h.node,null,u,r),C.showDropIndicator=!1,C.draggingNode=null,C.dropNode=null,C.allowDrop=!0}function xe(r){var D;const h=r.target;if(h.className.indexOf("vue-tree-node")===-1)return;const u=(D=i==null?void 0:i.proxy)==null?void 0:D.$el,v=Array.from(u.querySelectorAll(".is-focusable[role=treeitem]")),E=v.indexOf(h);let x;[38,40].indexOf(r.keyCode)>-1&&(r.preventDefault(),r.keyCode===38?x=E!==0?E-1:0:x=E<v.length-1?E+1:0,v[x].focus()),[37,39].indexOf(r.keyCode)>-1&&(r.preventDefault(),h.click());const b=h.querySelector('[type="checkbox"]');[13,32].indexOf(r.keyCode)>-1&&b&&(r.preventDefault(),b.click())}async function Be(r){var u,v,E,x;const h=r.target;if(h.matches('.vue-tree-node[role="treeitem"]')){if(r.key==="ArrowUp"||r.key==="ArrowDown"){r.preventDefault();const b=r.key==="ArrowDown"?1:-1,D=w.value;let S=D.findIndex(z=>String(z.id)===h.dataset.treeNodeId);if(S<0)return;do S+=b;while(S>=0&&S<D.length&&D[S].disabled);b===1&&S===D.length&&(S=D.findIndex(z=>!z.disabled));const V=D[S];if(!V)return;(u=y.value)!=null&&u.isIndexVisible(S)||await((v=y.value)==null?void 0:v.scrollToIndex(S)),(x=(E=k.value)==null?void 0:E.querySelector(`[data-tree-node-id="${V.id}"]`))==null||x.focus()}else if(r.key==="ArrowLeft"||r.key==="ArrowRight")r.preventDefault(),h.click();else if(r.key==="Enter"||r.key===" "){const b=h.querySelector('[type="checkbox"]');b&&(r.preventDefault(),b.click())}}}return d.onMounted(()=>{var h;((h=i==null?void 0:i.proxy)==null?void 0:h.$el).addEventListener("keydown",u=>{e.virtual?Be(u):xe(u)})}),n({filter:J,getNodePath:F,getCheckedNodes:g,getCheckedKeys:B,getCurrentNode:$,getCurrentKey:ie,setCheckedNodes:re,setCheckedKeys:ae,setChecked:se,getHalfCheckedNodes:le,getHalfCheckedKeys:ce,setCurrentNode:he,setCurrentKey:ue,isKeyVisible:fe,scrollToKey:ge,getNode:ye,remove:ke,append:pe,insertBefore:Ce,insertAfter:Ne,updateKeyChildren:we,store:a}),{store:a,root:l,currentNode:f,dragState:C,dropIndicator:c,treeContainerRef:k,virtualListRef:y,expandedRows:w,shouldDeferContent:s,getRowKey:T,isEmpty:j,getNodeKeyFn:I,handleNodeExpand:ve,handleNodeCollapse:Ee}}}),et={key:2,class:"vue-tree__empty-block"},tt={class:"vue-tree__empty-text"},nt={class:"vue-tree__drop-indicator",ref:"dropIndicator"};function ot(e,t,n,o,i,s){const a=d.resolveComponent("VirtualTreeRows"),l=d.resolveComponent("vue-tree-node");return d.openBlock(),d.createElementBlock("div",{ref:"treeContainerRef",class:d.normalizeClass(["vue-tree",{"vue-tree--highlight-current":e.highlightCurrent,"vue-tree--virtual":e.virtual,"is-dragging":!!e.dragState.draggingNode,"is-drop-not-allow":!e.dragState.allowDrop,"is-drop-inner":e.dragState.dropType==="inner"}]),role:"tree"},[e.virtual&&!e.isEmpty?(d.openBlock(),d.createBlock(a,{key:0,ref:"virtualListRef",rows:e.expandedRows,"get-row-key":e.getRowKey,"show-checkbox":e.showCheckbox,"render-content":e.renderContent,"defer-content":e.shouldDeferContent()},d.createSlots({_:2},[e.$slots["node-loading"]?{name:"node-loading",fn:d.withCtx(()=>[d.renderSlot(e.$slots,"node-loading")]),key:"0"}:void 0]),1032,["rows","get-row-key","show-checkbox","render-content","defer-content"])):d.createCommentVNode("",!0),!e.virtual&&!e.isEmpty?(d.openBlock(!0),d.createElementBlock(d.Fragment,{key:1},d.renderList(e.root.childNodes,f=>(d.openBlock(),d.createBlock(l,{key:e.getNodeKeyFn(f),node:f,props:e.props,"render-after-expand":e.renderAfterExpand,"show-checkbox":e.showCheckbox,"render-content":e.renderContent,onNodeExpand:e.handleNodeExpand,onNodeCollapse:e.handleNodeCollapse},null,8,["node","props","render-after-expand","show-checkbox","render-content","onNodeExpand","onNodeCollapse"]))),128)):d.createCommentVNode("",!0),e.isEmpty?(d.openBlock(),d.createElementBlock("div",et,[d.renderSlot(e.$slots,"empty",{},()=>[d.createElementVNode("span",tt,d.toDisplayString(e.emptyText),1)])])):d.createCommentVNode("",!0),d.withDirectives(d.createElementVNode("div",nt,null,512),[[d.vShow,e.dragState.showDropIndicator]])],2)}const de=G(_e,[["render",ot]]);exports.VueTree=de;exports.default=de;