@cw-devops-fe/vue-tree-vue3 0.0.0-stage → 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;
@@ -0,0 +1,63 @@
1
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
+ node: {
3
+ type: ObjectConstructor;
4
+ required: true;
5
+ };
6
+ renderContent: FunctionConstructor;
7
+ renderAfterExpand: {
8
+ type: BooleanConstructor;
9
+ default: boolean;
10
+ };
11
+ showCheckbox: {
12
+ type: BooleanConstructor;
13
+ default: boolean;
14
+ };
15
+ }>, {
16
+ tree: any;
17
+ nodeRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
18
+ expanded: import('vue').Ref<boolean, boolean>;
19
+ childNodeRendered: import('vue').Ref<boolean, boolean>;
20
+ nodeContentComponent: import('vue').ComputedRef<{
21
+ props: {
22
+ node: {
23
+ type: ObjectConstructor;
24
+ required: boolean;
25
+ };
26
+ };
27
+ setup(innerProps: any): () => any;
28
+ }>;
29
+ getNodeKey: (node: any) => any;
30
+ handleClick: () => void;
31
+ handleContextMenu: (event: MouseEvent) => void;
32
+ handleExpandIconClick: () => void;
33
+ handleCheckChange: (ev: Event) => void;
34
+ handleChildNodeExpand: (nodeData: any, node: any, instance: any) => void;
35
+ handleDragStart: (event: DragEvent) => void;
36
+ handleDragOver: (event: DragEvent) => void;
37
+ handleDrop: (event: DragEvent) => void;
38
+ handleDragEnd: (event: DragEvent) => void;
39
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, "node-expand"[], "node-expand", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
40
+ node: {
41
+ type: ObjectConstructor;
42
+ required: true;
43
+ };
44
+ renderContent: FunctionConstructor;
45
+ renderAfterExpand: {
46
+ type: BooleanConstructor;
47
+ default: boolean;
48
+ };
49
+ showCheckbox: {
50
+ type: BooleanConstructor;
51
+ default: boolean;
52
+ };
53
+ }>> & Readonly<{
54
+ "onNode-expand"?: ((...args: any[]) => any) | undefined;
55
+ }>, {
56
+ renderAfterExpand: boolean;
57
+ showCheckbox: boolean;
58
+ }, {}, {
59
+ TreeCollapseTransition: import('vue').DefineComponent<{}, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
60
+ [key: string]: any;
61
+ }>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
62
+ }, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
63
+ export default _default;
@@ -0,0 +1,4 @@
1
+ export declare function objectAssign(target: Record<string, unknown>, ...sources: Record<string, unknown>[]): Record<string, unknown>;
2
+ export declare function arrayFindIndex<T>(arr: T[], pred: (item: T) => boolean): number;
3
+ export declare function addClass(el: HTMLElement, cls: string): void;
4
+ export declare function removeClass(el: HTMLElement, cls: string): void;
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
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;
@@ -0,0 +1,3 @@
1
+ import { default as VueTree } from './VueTree.vue';
2
+ export { VueTree };
3
+ export default VueTree;