amazing-tree 1.3.0 → 1.3.4

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.
package/README.md CHANGED
@@ -62,27 +62,34 @@ function onDrop(drag: NodeItem, target: NodeItem, type: 'prev' | 'next' | 'inner
62
62
 
63
63
  **Props**
64
64
 
65
- | 属性名 | 说明 | 类型 | 默认值 | 是否可选 |
66
- | --------------------- | --------------------------- | -------------------------------------------------------------- | ------------------------------------------------------- | -------- |
67
- | `data` | 树数据源 | `T[]` | | |
68
- | `props` | 字段映射 | `{ value: string; label: string; children: string }` | `{ value:'value', label:'label', children:'children' }` | 是 |
69
- | `allowDrag` | 是否允许拖拽某节点 | `(node: T) => boolean` | — | |
70
- | `allowDrop` | 是否允许目标位置 | `(drag: T, drop: T, type: 'prev'\|'next'\|'inner') => boolean` | — | 是 |
71
- | `height` | 容器高度 | `number \| string` | `'100%'` | 是 |
72
- | `highlightColor` | 选中行高亮色 | `string` | `'#1e71ff'` | 是 |
73
- | `backgroundColor` | 背景色 | `string` | `'#1d1d24'` | 是 |
74
- | `textColor` | 文本色 | `string` | `'#c8d3de'` | 是 |
75
- | `hoverColor` | 悬浮色 | `string` | `'#5d90e5'` | 是 |
76
- | `currentNodeKey` | 当前行的 `value` | `Key` | — | 是 |
77
- | `defaultExpandedKeys` | 默认展开的节点 `value` 列表 | `Key[]` | — | 是 |
78
- | `defaultExpandAll` | 是否默认全部展开 | `boolean` | | 是 |
79
- | `draggable` | 是否允许拖拽 | `boolean` | `false` | 是 |
80
- | `emptyText` | 空状态文案 | `string` | `'暂无数据'` | 是 |
81
- | `showCheckbox` | 是否显示复选框 | `boolean` | `false` | 是 |
82
- | `checkStrictly` | 选择严格模式,父子不联动 | `boolean` | `false` | 是 |
83
- | `defaultCheckedKeys` | 默认勾选的 `value` 列表 | `Key[]` | `[]` | 是 |
84
- | `disabledChecked` | 是否禁用当前节点复选框 | `(node: T) => boolean` | — | 是 |
85
- | `filterNodeMethod` | 过滤方法(返回 false 隐藏) | `(value: unknown, node: T) => boolean` | | 是 |
65
+ > 类型别名:Key = `string | number`
66
+
67
+ | 属性名 | 说明 | 类型 | 默认值 | 是否可选 |
68
+ | --------------------- | ----------------------------------- | -------------------------------------------------------------- | ------------------------------------------------------- | -------- |
69
+ | `data` | 树数据源 | `T[]` | — | |
70
+ | `props` | 字段映射 | `{ value: string; label: string; children: string }` | `{ value:'value', label:'label', children:'children' }` | 是 |
71
+ | `allowDrag` | 是否允许拖拽某节点 | `(node: T) => boolean` | | 是 |
72
+ | `allowDrop` | 是否允许目标位置 | `(drag: T, drop: T, type: 'prev'\|'next'\|'inner') => boolean` | — | 是 |
73
+ | `height` | 容器高度(未传时样式回退为`100%`) | `number \| string` | | 是 |
74
+ | `rowHeight` | 行高(用于虚拟滚动估计) | `number \| string` | `32` | 是 |
75
+ | `dropLineColor` | 拖拽前后置指示线颜色 | `string` | `'#ffd400'` | 是 |
76
+ | `innerDashColor` | 拖拽内部放置虚线颜色 | `string` | `'#ffd400'` | 是 |
77
+ | `siblingZoneRatio` | 行内前后置判定区域比例(0.05–0.49) | `number` | `0.35` | 是 |
78
+ | `dragStartThreshold` | 触发拖拽的最小鼠标位移阈值 | `number` | `4` | 是 |
79
+ | `highlightColor` | 选中行高亮色 | `string` | `'#1e71ff'` | 是 |
80
+ | `backgroundColor` | 背景色 | `string` | `'#1d1d24'` | 是 |
81
+ | `textColor` | 文本色 | `string` | `'#c8d3de'` | 是 |
82
+ | `hoverColor` | 悬浮色 | `string` | `'#5d90e5'` | 是 |
83
+ | `currentNodeKey` | 当前行的 `value` | `Key` | | 是 |
84
+ | `defaultExpandedKeys` | 默认展开的节点 `value` 列表 | `Key[]` | — | 是 |
85
+ | `defaultExpandAll` | 是否默认全部展开 | `boolean` | `false` | 是 |
86
+ | `draggable` | 是否允许拖拽 | `boolean` | `false` | 是 |
87
+ | `emptyText` | 空状态文案 | `string` | `'暂无数据'` | 是 |
88
+ | `showCheckbox` | 是否显示复选框 | `boolean` | `false` | 是 |
89
+ | `checkStrictly` | 选择严格模式(父子不联动) | `boolean` | `false` | 是 |
90
+ | `defaultCheckedKeys` | 默认勾选的 `value` 列表 | `Key[]` | `[]` | 是 |
91
+ | `disabledChecked` | 是否禁用当前节点复选框 | `(node: T) => boolean` | — | 是 |
92
+ | `filterNodeMethod` | 过滤方法(返回 false 隐藏该节点) | `(value: unknown, node: T) => boolean` | — | 是 |
86
93
 
87
94
  **Events**
88
95
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),Ae=["onMousedown","onClick","onContextmenu"],Ke=["onClick"],Ne=["checked","indeterminate","disabled","onClick"],Ie={class:"amazing-tree-label"},Le={key:1,class:"amazing-tree-empty"},Re={class:"amazing-tree-empty-inner"},_=28,Ve=t.defineComponent({__name:"AmazingTree",props:{data:{},props:{default:()=>({value:"value",label:"label",children:"children"})},allowDrag:{},allowDrop:{},height:{default:void 0},highlightColor:{default:"#1e71ff"},backgroundColor:{default:"#1d1d24"},textColor:{default:"#c8d3de"},hoverColor:{default:"#5d90e5"},currentNodeKey:{},defaultExpandedKeys:{},defaultExpandAll:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},emptyText:{default:"暂无数据"},showCheckbox:{type:Boolean,default:!1},checkStrictly:{type:Boolean,default:!1},defaultCheckedKeys:{default:()=>[]},disabledChecked:{},filterNodeMethod:{}},emits:["node-click","node-contextmenu","node-drop","current-change","check-change"],setup(p,{expose:j,emit:O}){const a=p,B=O,fe=t.computed(()=>a.props.value||"value"),ve=t.computed(()=>a.props.label||"label"),P=t.computed(()=>a.props.children||"children"),he=t.computed(()=>Array.isArray(a.data)?a.data.length===0:!0),k=t.ref(new Set),m=t.ref(new Set),x=t.ref(new Set),Q=t.ref(null);function te(e){return k.value.has(e)}function me(e){k.value.has(e)?k.value.delete(e):k.value.add(e),i.value=C(a.data||[]),t.nextTick(()=>{T(),g()})}function y(e){return e[fe.value]}function b(e){const l=e[P.value];return Array.isArray(l)?l:[]}function pe(e){return m.value.has(e)}function ge(e){return x.value.has(e)}function G(e,l){if(l?m.value.add(e):m.value.delete(e),x.value.delete(e),!a.checkStrictly){const n=ee(e,a.data||[]);if(n){const o=[n];for(;o.length;){const r=o.pop(),c=y(r);l?m.value.add(c):m.value.delete(c),x.value.delete(c);const f=b(r);for(const d of f)o.push(d)}const u=$(e,a.data||[])||[];for(const r of u){const c=y(r),f=b(r);let d=!0,s=!1;for(const h of f){const R=y(h),ie=m.value.has(R),se=x.value.has(R);(ie||se)&&(s=!0),(!ie||se)&&(d=!1)}f.length===0?(m.value.has(c),x.value.delete(c)):d?(m.value.add(c),x.value.delete(c)):s?(m.value.delete(c),x.value.add(c)):(m.value.delete(c),x.value.delete(c))}}}}function le(e){m.value=new Set,x.value=new Set;for(const l of e||[])G(l,!0)}function ke(e,l){const n=l.target;a.disabledChecked&&a.disabledChecked(e.node)||(B("check-change",e.node,!!n.checked),G(e.id,!!n.checked))}function C(e){const l=[];function n(o,u,r){for(let c=0;c<o.length;c++){const f=o[c],d=y(f),s=b(f),h=s.length===0;l.push({id:d,node:f,parent:u,level:r,index:c,isLeaf:h}),!h&&k.value.has(d)&&n(s,f,r+1)}}if(n(e,null,0),a.filterNodeMethod&&Q.value!=null){let o=function(c){const f=y(c),d=b(c);let s=!1;for(const R of d)s=o(R)||s;const h=!!a.filterNodeMethod(Q.value,c);return h&&u.add(f),s&&r.add(f),h||s};const u=new Set,r=new Set;for(const c of e)o(c);return l.filter(c=>u.has(c.id)||r.has(c.id))}return l}const v=t.ref(null),M=t.ref(0),V=t.ref(0),i=t.ref([]),A=t.reactive(new Map),w=t.computed(()=>{let e=0;const l=[];for(const n of i.value){const o=A.get(n.id)||_;e+=o,l.push(e)}return l}),ne=t.computed(()=>{const e=w.value;return e.length?e[e.length-1]:0});function ae(e){let l=0,n=w.value.length-1,o=0;for(;l<=n;){const u=l+n>>1;w.value[u]!==void 0&&w.value[u]>=e?(o=u,n=u-1):l=u+1}return o}const K=t.ref(0),S=t.ref(0),N=t.ref(0),J=t.ref(0);function g(){if(V.value=v.value?.clientHeight||0,w.value.length===0||i.value.length===0){K.value=0,S.value=0,N.value=0,J.value=0;return}const e=ae(M.value);K.value=Math.max(0,e-3);const l=i.value[K.value],n=l?A.get(l.id)||_:0,u=(w.value[K.value]??0)-n;N.value=Math.max(0,u);let r=K.value;const c=M.value+V.value+3*_;for(;r<i.value.length&&(w.value[r]??0)<c;)r++;S.value=Math.min(i.value.length,r+1);const d=(w.value[S.value-1]??0)-N.value;if(d<V.value&&S.value<i.value.length){let s=S.value,h=d;for(;h<V.value&&s<i.value.length;)s++,h=(w.value[s-1]??0)-N.value;S.value=s}J.value=Math.max(0,ne.value-N.value-((w.value[S.value-1]??0)-N.value))}t.watch([M,()=>a.data,k],()=>{i.value=C(a.data||[]),t.nextTick(T),g()}),t.onMounted(()=>{i.value=C(a.data||[]),t.nextTick(T),g(),a.defaultCheckedKeys&&a.defaultCheckedKeys.length&&le(a.defaultCheckedKeys),v.value&&(D=new ResizeObserver(()=>{V.value=v.value?.clientHeight||0,g()}),D.observe(v.value))});let D=null;t.onUnmounted(()=>{D&&(D.disconnect(),D=null)});const W=t.reactive(new Map);function xe(e,l){l?W.set(e,l):W.delete(e)}function T(){let e=!1;for(const l of i.value.slice(K.value,S.value)){const n=W.get(l.id);if(n){const o=n.offsetHeight;(!A.has(l.id)||A.get(l.id)!==o)&&(A.set(l.id,o),e=!0)}}e&&g()}function ye(){M.value=v.value?.scrollTop||0,g()}const z=t.ref(!1),X=t.ref(null),H=t.ref(null),E=t.ref(null),Z=t.ref(0),I=t.ref(null),F=t.ref(0);let L=null;function q(){L!=null&&(cancelAnimationFrame(L),L=null)}function oe(){if(!z.value||F.value===0){q();return}const e=v.value;if(!e){q();return}const l=e.scrollHeight-e.clientHeight,n=12;e.scrollTop=Math.max(0,Math.min(l,e.scrollTop+F.value*n)),M.value=e.scrollTop,g(),L=requestAnimationFrame(oe)}function we(){F.value!==0&&L==null&&(L=requestAnimationFrame(oe)),F.value===0&&q()}function U(e){if(e==null)return null;for(const l of i.value)if(l.id===e)return l;return null}function Ce(e){const l=v.value.getBoundingClientRect(),n=e-l.top+M.value;return ae(n)}function be(e,l){!a.draggable||l.button!==0||!(!a.allowDrag||a.allowDrag(e.node))||(z.value=!0,X.value=e.id,Z.value=l.clientY,l.preventDefault(),window.addEventListener("mousemove",ce),window.addEventListener("mouseup",ue))}function ce(e){if(!z.value)return;Z.value=e.clientY;const l=Ce(e.clientY),n=i.value[Math.min(Math.max(l,0),i.value.length-1)];if(H.value=n?.id??null,!n){E.value=null;return}const o=w.value[l]??0,u=A.get(n.id)??_,r=o-u,c=v.value.getBoundingClientRect(),d=(e.clientY-c.top+M.value-r)/u;let s="inner";d<.25?s="prev":d>.75&&(s="next");const h=U(X.value),R=a.allowDrop?!!(h&&a.allowDrop(h.node,n.node,s)):!0;E.value=R?s:null,F.value=e.clientY>c.bottom?1:e.clientY<c.top?-1:0,we()}function $(e,l,n=[]){for(const o of l){if(y(o)===e)return n;const u=b(o);if(u.length){const r=$(e,u,[...n,o]);if(r)return r}}return null}function ee(e,l){if(e==null)return null;for(const n of l){if(y(n)===e)return n;const o=b(n),u=ee(e,o);if(u)return u}return null}function Y(e){const l=[];for(const n of e){l.push(y(n));const o=b(n);o.length&&l.push(...Y(o))}return l}function Se(e){const l=e.parent;if(l)b(l).splice(e.index,1);else{const n=a.data.findIndex(o=>y(o)===e.id);n>=0&&a.data.splice(n,1)}}function Te(e,l,n){if(n==="inner"){Array.isArray(l.node[P.value])||(l.node[P.value]=[]),l.node[P.value].push(e),k.value.add(l.id);return}const o=l.parent;if(o){const u=b(o),r=l.index+(n==="next"?1:0);u.splice(r,0,e)}else{const u=l.index+(n==="next"?1:0);a.data.splice(u,0,e)}}function ue(){if(window.removeEventListener("mousemove",ce),window.removeEventListener("mouseup",ue),q(),!z.value)return;const e=U(X.value),l=U(H.value),n=E.value;if(z.value=!1,E.value=null,H.value=null,!e||!l||!n||a.allowDrop&&!a.allowDrop(e.node,l.node,n)||e.id===l.id)return;const o=n==="inner"?l.node:l.parent||null;if(o){const f=$(y(o),a.data||[])||[];for(const d of f)if(y(d)===e.id)return}const u=e.node;Se(e);const r=C(a.data||[]);i.value=r;const c=U(l.id)||l;Te(u,c,n),i.value=C(a.data||[]),t.nextTick(()=>{T(),g()}),B("node-drop",u,c.node,n)}function ze(e,l){I.value=e.id,B("node-click",e.node,l)}function Ee(e,l){B("node-contextmenu",e.node,l)}t.watchEffect(()=>{t.nextTick(T)}),t.watch(()=>a.currentNodeKey,e=>{I.value=e??null},{immediate:!0}),t.watch(()=>a.defaultExpandedKeys,e=>{k.value=new Set(e||[]),i.value=C(a.data||[]),t.nextTick(()=>{T(),g()})},{immediate:!0}),t.watch(()=>a.defaultExpandAll,e=>{e&&(k.value=new Set(Y(a.data||[])),i.value=C(a.data||[]),t.nextTick(()=>{T(),g()}))},{immediate:!0}),t.watch(()=>a.data,()=>{a.defaultExpandAll&&(k.value=new Set(Y(a.data||[]))),i.value=C(a.data||[]),t.nextTick(()=>{T(),g()});const e=new Set(Y(a.data||[]));m.value=new Set([...m.value].filter(l=>e.has(l))),x.value=new Set([...x.value].filter(l=>e.has(l)))},{deep:!0});function Me(e){const l=$(e,a.data||[])||[];for(const n of l)k.value.add(y(n));i.value=C(a.data||[])}function re(e){e!=null&&(Me(e),t.nextTick(()=>{const l=i.value.findIndex(c=>c.id===e);if(l<0||!v.value)return;const n=A.get(e)||_,o=(w.value[l]??0)-n,u=v.value.clientHeight,r=Math.max(0,o-Math.max(0,(u-n)/2));v.value.scrollTop=r,M.value=r,g(),t.nextTick(()=>{const c=W.get(e);if(!c||!v.value)return;const f=c.offsetLeft,d=c.offsetWidth,s=v.value.clientWidth,h=Math.max(0,f+Math.max(0,d/2)-Math.max(0,s/2));v.value.scrollLeft=h})}))}function Be(e){I.value=e??null,re(I.value)}return j({getCurrentKey:()=>I.value,setCurrentKey:Be,scrollTo:re,getCheckedKeys:()=>Array.from(m.value),setCheckedKeys:le,setChecked:(e,l)=>G(e,l),filter:e=>{Q.value=e,k.value=new Set(Y(a.data||[])),i.value=C(a.data||[]),t.nextTick(()=>{T(),g()})}}),t.watch(I,e=>{const l=ee(e,a.data||[]);l&&B("current-change",l)}),(e,l)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"containerRef",ref:v,class:t.normalizeClass(["amazing-tree",{"is-dragging":z.value}]),style:t.normalizeStyle({height:typeof p.height=="number"?p.height+"px":p.height||"100%","--vtree-bg":p.backgroundColor,"--vtree-text":p.textColor,"--vtree-hover":p.hoverColor}),onScroll:ye},[he.value?(t.openBlock(),t.createElementBlock("div",Le,[t.renderSlot(e.$slots,"empty",{},()=>[t.createElementVNode("div",Re,t.toDisplayString(p.emptyText),1)],!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("div",{style:t.normalizeStyle({height:ne.value+"px",position:"relative",minWidth:"100%",width:"max-content"})},[t.createElementVNode("div",{style:t.normalizeStyle({height:N.value+"px"})},null,4),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.value.slice(K.value,S.value),n=>(t.openBlock(),t.createElementBlock("div",{key:n.id,class:"amazing-tree-row-wrapper"},[t.createElementVNode("div",{class:t.normalizeClass(["amazing-tree-row",{"is-target-inner":z.value&&H.value===n.id&&E.value==="inner","is-active":I.value===n.id}]),style:t.normalizeStyle({paddingLeft:n.level*16+"px","--active-color":p.highlightColor}),onMousedown:o=>be(n,o),onClick:o=>ze(n,o),onContextmenu:t.withModifiers(o=>Ee(n,o),["prevent"]),ref_for:!0,ref:o=>xe(n.id,o)},[t.createElementVNode("span",{class:t.normalizeClass(["amazing-tree-caret-box",{"is-leaf":n.isLeaf}]),onClick:t.withModifiers(o=>!n.isLeaf&&me(n.id),["stop"])},[n.isLeaf?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["amazing-tree-caret",{expanded:te(n.id)}])},null,2))],10,Ke),p.showCheckbox?(t.openBlock(),t.createElementBlock("input",{key:0,class:"amazing-tree-checkbox",type:"checkbox",checked:pe(n.id),indeterminate:ge(n.id),disabled:a.disabledChecked?a.disabledChecked(n.node):!1,onClick:t.withModifiers(o=>ke(n,o),["stop"])},null,8,Ne)):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"default",{node:n.node,data:n.node,level:n.level,expanded:te(n.id),isLeaf:n.isLeaf},()=>[t.createElementVNode("span",Ie,t.toDisplayString(n.node[ve.value]),1)],!0)],46,Ae),z.value&&H.value===n.id&&(E.value==="prev"||E.value==="next")?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["amazing-tree-drop-line",{"is-prev":E.value==="prev","is-next":E.value==="next"}])},null,2)):t.createCommentVNode("",!0)]))),128)),t.createElementVNode("div",{style:t.normalizeStyle({height:J.value+"px"})},null,4)],4),z.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"amazing-tree-ghost",style:t.normalizeStyle({top:Z.value+"px"})},null,4)):t.createCommentVNode("",!0)],64))],38))}}),De=(p,j)=>{const O=p.__vccOpts||p;for(const[a,B]of j)O[a]=B;return O},de=De(Ve,[["__scopeId","data-v-e0a4c022"]]);exports.AmazingTree=de;exports.default=de;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),Ye=["onMousedown","onClick","onContextmenu"],Fe=["onClick"],$e=["checked","indeterminate","disabled","onClick"],Oe={class:"amazing-tree-label"},Pe={key:1,class:"amazing-tree-empty"},We={class:"amazing-tree-empty-inner"},qe=l.defineComponent({__name:"AmazingTree",props:{data:{},props:{default:()=>({value:"value",label:"label",children:"children"})},allowDrag:{},allowDrop:{},height:{default:void 0},rowHeight:{default:32},dropLineColor:{default:"#ffd400"},innerDashColor:{default:"#ffd400"},siblingZoneRatio:{default:.35},dragStartThreshold:{default:4},highlightColor:{default:"#1e71ff"},backgroundColor:{default:"#1d1d24"},textColor:{default:"#c8d3de"},hoverColor:{default:"#5d90e5"},currentNodeKey:{},defaultExpandedKeys:{},defaultExpandAll:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},emptyText:{default:"暂无数据"},showCheckbox:{type:Boolean,default:!1},checkStrictly:{type:Boolean,default:!1},defaultCheckedKeys:{default:()=>[]},disabledChecked:{},filterNodeMethod:{}},emits:["node-click","node-contextmenu","node-drop","current-change","check-change"],setup(v,{expose:ee,emit:X}){const a=v,R=X,xe=l.computed(()=>a.props.value||"value"),we=l.computed(()=>a.props.label||"label"),Z=l.computed(()=>a.props.children||"children"),ye=l.computed(()=>Array.isArray(a.data)?a.data.length===0:!0),N=l.ref(new Set),x=l.ref(new Set),p=l.ref(new Set),y=l.ref(new Set),j=l.ref(null);function re(e){return N.value.has(e.rid)||x.value.has(e.id)}function ke(e){const t=J(e);if(!t)return;const n=t.id;N.value.has(e)||x.value.has(n)?(N.value.delete(e),x.value.delete(n)):N.value.add(e),c.value=S(a.data||[]),l.nextTick(()=>{z(),w()})}function k(e){return e[xe.value]}function E(e){const t=e[Z.value];return Array.isArray(t)?t:[]}function Ce(e){return p.value.has(e)}function be(e){return y.value.has(e)}function te(e,t){if(t?p.value.add(e):p.value.delete(e),y.value.delete(e),!a.checkStrictly){const n=ae(e,a.data||[]);if(n){const o=[n];for(;o.length;){const i=o.pop(),r=k(i);t?p.value.add(r):p.value.delete(r),y.value.delete(r);const s=E(i);for(const d of s)o.push(d)}const u=_(e,a.data||[])||[];for(const i of u){const r=k(i),s=E(i);let d=!0,f=!1;for(const m of s){const g=k(m),b=p.value.has(g),F=y.value.has(g);(b||F)&&(f=!0),(!b||F)&&(d=!1)}s.length===0?(p.value.has(r),y.value.delete(r)):d?(p.value.add(r),y.value.delete(r)):f?(p.value.delete(r),y.value.add(r)):(p.value.delete(r),y.value.delete(r))}}}}function ue(e){p.value=new Set,y.value=new Set;for(const t of e||[])te(t,!0)}function Se(e,t){const n=t.target;a.disabledChecked&&a.disabledChecked(e.node)||(R("check-change",e.node,!!n.checked),te(e.id,!!n.checked))}function S(e){const t=[];function n(o,u,i,r){for(let s=0;s<o.length;s++){const d=o[s],f=k(d),m=E(d),g=m.length===0,b=r?`${r}/${s}`:`${s}`,F={rid:b,id:f,node:d,parent:u,level:i,index:s,isLeaf:g};t.push(F);const oe=N.value.has(b)||x.value.has(f);!g&&oe&&n(m,d,i+1,b)}}if(n(e,null,0,""),a.filterNodeMethod&&j.value!=null){let o=function(r){const s=k(r),d=E(r);let f=!1;for(const g of d)f=o(g)||f;const m=!!a.filterNodeMethod(j.value,r);return m&&u.add(s),f&&i.add(s),m||f};const u=new Set,i=new Set;for(const r of e)o(r);return t.filter(r=>u.has(r.id)||i.has(r.id))}return t}const h=l.ref(null),B=l.ref(0),$=l.ref(0),c=l.ref([]),H=l.reactive(new Map);function Me(e){if(typeof e=="number")return e;if(typeof e=="string"){const t=e.match(/(\d+(\.\d+)?)/);return t?Number(t[1]):32}return 32}const O=Me(a.rowHeight),C=l.computed(()=>{let e=0;const t=[];for(const n of c.value){const o=H.get(n.rid)||O;e+=o,t.push(e)}return t}),ie=l.computed(()=>{const e=C.value;return e.length?e[e.length-1]:0});function ce(e){let t=0,n=C.value.length-1,o=0;for(;t<=n;){const u=t+n>>1;C.value[u]!==void 0&&C.value[u]>=e?(o=u,n=u-1):t=u+1}return o}const L=l.ref(0),T=l.ref(0),I=l.ref(0),le=l.ref(0);function w(){if($.value=h.value?.clientHeight||0,C.value.length===0||c.value.length===0){L.value=0,T.value=0,I.value=0,le.value=0;return}const e=ce(B.value);L.value=Math.max(0,e-3);const t=c.value[L.value],n=t?H.get(t.rid)||O:0,u=(C.value[L.value]??0)-n;I.value=Math.max(0,u);let i=L.value;const r=B.value+$.value+3*O;for(;i<c.value.length&&(C.value[i]??0)<r;)i++;T.value=Math.min(c.value.length,i+1);const d=(C.value[T.value-1]??0)-I.value;if(d<$.value&&T.value<c.value.length){let f=T.value,m=d;for(;m<$.value&&f<c.value.length;)f++,m=(C.value[f-1]??0)-I.value;T.value=f}le.value=Math.max(0,ie.value-I.value-((C.value[T.value-1]??0)-I.value))}l.watch([B,()=>a.data,N,x],()=>{c.value=S(a.data||[]),l.nextTick(z),w()}),l.onMounted(()=>{c.value=S(a.data||[]),l.nextTick(z),w(),a.defaultCheckedKeys&&a.defaultCheckedKeys.length&&ue(a.defaultCheckedKeys),h.value&&(P=new ResizeObserver(()=>{$.value=h.value?.clientHeight||0,w()}),P.observe(h.value))});let P=null;l.onUnmounted(()=>{P&&(P.disconnect(),P=null)});const Q=l.reactive(new Map);function Ee(e,t){t?Q.set(e,t):Q.delete(e)}function z(){let e=!1;for(const t of c.value.slice(L.value,T.value)){const n=Q.get(t.rid);if(n){const o=n.offsetHeight;(!H.has(t.rid)||H.get(t.rid)!==o)&&(H.set(t.rid,o),e=!0)}}e&&w()}function Te(){B.value=h.value?.scrollTop||0,w()}const A=l.ref(!1),W=l.ref(null),D=l.ref(null),M=l.ref(null),ne=l.ref(0),q=l.ref(!1),se=l.ref(0),de=l.ref(0),K=l.ref(null),U=l.ref(0);let V=null;function G(){V!=null&&(cancelAnimationFrame(V),V=null)}function fe(){if(!A.value||U.value===0){G();return}const e=h.value;if(!e){G();return}const t=e.scrollHeight-e.clientHeight,n=12;e.scrollTop=Math.max(0,Math.min(t,e.scrollTop+U.value*n)),B.value=e.scrollTop,w(),V=requestAnimationFrame(fe)}function ze(){U.value!==0&&V==null&&(V=requestAnimationFrame(fe)),U.value===0&&G()}function Be(e){if(e==null)return null;for(const t of c.value)if(t.id===e)return t;return null}function J(e){if(e==null)return null;for(const t of c.value)if(t.rid===e)return t;return null}function Ae(e){const t=h.value.getBoundingClientRect(),n=e-t.top+B.value;return ce(n)}function Ke(e,t){!a.draggable||t.button!==0||!(!a.allowDrag||a.allowDrag(e.node))||(W.value=e.rid,ne.value=t.clientY,se.value=t.clientX,de.value=t.clientY,q.value=!1,t.preventDefault(),window.addEventListener("mousemove",ve),window.addEventListener("mouseup",he))}function ve(e){if(W.value==null)return;if(!q.value){const oe=Math.abs(e.clientX-se.value),Ve=Math.abs(e.clientY-de.value),pe=Math.max(1,a.dragStartThreshold??4);if(oe<pe&&Ve<pe)return;q.value=!0,A.value=!0}ne.value=e.clientY;const t=Ae(e.clientY),n=c.value[Math.min(Math.max(t,0),c.value.length-1)];if(D.value=n?.rid??null,!n){M.value=null;return}const o=C.value[t]??0,u=H.get(n.rid)??O,i=o-u,r=h.value.getBoundingClientRect(),d=(e.clientY-r.top+B.value-i)/u,f=a.siblingZoneRatio??.35,m=Math.max(.05,Math.min(.49,f));let g="inner";d<m?g="prev":d>1-m&&(g="next");const b=J(W.value),F=a.allowDrop?!!(b&&a.allowDrop(b.node,n.node,g)):!0;M.value=F?g:null,U.value=e.clientY>r.bottom?1:e.clientY<r.top?-1:0,ze()}function _(e,t,n=[]){for(const o of t){if(k(o)===e)return n;const u=E(o);if(u.length){const i=_(e,u,[...n,o]);if(i)return i}}return null}function ae(e,t){if(e==null)return null;for(const n of t){if(k(n)===e)return n;const o=E(n),u=ae(e,o);if(u)return u}return null}function Y(e){const t=[];for(const n of e){t.push(k(n));const o=E(n);o.length&&t.push(...Y(o))}return t}function Re(e){const t=e.parent;if(t)E(t).splice(e.index,1);else{const n=a.data.findIndex(o=>k(o)===e.id);n>=0&&a.data.splice(n,1)}}function Ne(e,t,n){if(n==="inner"){Array.isArray(t.node[Z.value])||(t.node[Z.value]=[]),t.node[Z.value].push(e),N.value.add(t.rid);return}const o=t.parent;if(o){const u=E(o),i=t.index+(n==="next"?1:0);u.splice(i,0,e)}else{const u=t.index+(n==="next"?1:0);a.data.splice(u,0,e)}}function he(){if(window.removeEventListener("mousemove",ve),window.removeEventListener("mouseup",he),G(),!A.value){W.value=null,M.value=null,D.value=null,q.value=!1;return}const e=J(W.value),t=J(D.value),n=M.value;if(A.value=!1,q.value=!1,M.value=null,D.value=null,!e||!t||!n||a.allowDrop&&!a.allowDrop(e.node,t.node,n)||e.id===t.id)return;const o=n==="inner"?t.node:t.parent||null;if(o){const s=_(k(o),a.data||[])||[];for(const d of s)if(k(d)===e.id)return}const u=e.node;Re(e);const i=S(a.data||[]);c.value=i;const r=Be(t.id)||t;Ne(u,r,n),c.value=S(a.data||[]),l.nextTick(()=>{z(),w()}),R("node-drop",u,r.node,n)}function He(e,t){K.value=e.id,R("node-click",e.node,t)}function Le(e,t){K.value=e.id,R("node-contextmenu",e.node,t)}l.watchEffect(()=>{l.nextTick(z)}),l.watch(()=>a.currentNodeKey,e=>{K.value=e??null},{immediate:!0}),l.watch(()=>a.defaultExpandedKeys,e=>{x.value=new Set(e||[]),c.value=S(a.data||[]),l.nextTick(()=>{z(),w()})},{immediate:!0}),l.watch(()=>a.defaultExpandAll,e=>{e&&(x.value=new Set(Y(a.data||[])),c.value=S(a.data||[]),l.nextTick(()=>{z(),w()}))},{immediate:!0}),l.watch(()=>a.data,()=>{a.defaultExpandAll&&(x.value=new Set(Y(a.data||[]))),c.value=S(a.data||[]),l.nextTick(()=>{z(),w()});const e=new Set(Y(a.data||[]));p.value=new Set([...p.value].filter(t=>e.has(t))),y.value=new Set([...y.value].filter(t=>e.has(t)))},{deep:!0});function Ie(e){const t=_(e,a.data||[])||[];for(const n of t)x.value.add(k(n));c.value=S(a.data||[])}function me(e){e!=null&&(Ie(e),l.nextTick(()=>{const t=c.value.findIndex(s=>s.id===e);if(t<0||!h.value)return;const n=c.value[t]?.rid,o=(n?H.get(n):void 0)||O,u=(C.value[t]??0)-o,i=h.value.clientHeight,r=Math.max(0,u-Math.max(0,(i-o)/2));h.value.scrollTop=r,B.value=r,w(),l.nextTick(()=>{const s=n||null,d=s?Q.get(s):null;if(!d||!h.value)return;const f=d.offsetLeft,m=d.offsetWidth,g=h.value.clientWidth,b=Math.max(0,f+Math.max(0,m/2)-Math.max(0,g/2));h.value.scrollLeft=b})}))}function De(e){K.value=e??null,me(K.value)}return ee({getCurrentKey:()=>K.value,setCurrentKey:De,scrollTo:me,getCheckedKeys:()=>Array.from(p.value),setCheckedKeys:ue,setChecked:(e,t)=>te(e,t),filter:e=>{!(e==null||typeof e=="string"&&e.trim()==="")&&a.filterNodeMethod?(j.value=e,x.value=new Set(Y(a.data||[]))):(j.value=null,a.defaultExpandAll?x.value=new Set(Y(a.data||[])):a.defaultExpandedKeys&&a.defaultExpandedKeys.length?x.value=new Set(a.defaultExpandedKeys):x.value=new Set),c.value=S(a.data||[]),l.nextTick(()=>{z(),w()})}}),l.watch(K,e=>{const t=ae(e,a.data||[]);t&&R("current-change",t)}),(e,t)=>(l.openBlock(),l.createElementBlock("div",{ref_key:"containerRef",ref:h,class:l.normalizeClass(["amazing-tree",{"is-dragging":A.value}]),style:l.normalizeStyle({height:typeof v.height=="number"?v.height+"px":v.height||"100%","--vtree-bg":v.backgroundColor,"--vtree-text":v.textColor,"--vtree-hover":v.hoverColor,"--vtree-row-height":typeof v.rowHeight=="number"?v.rowHeight+"px":v.rowHeight||"32px","--vtree-drop-line":v.dropLineColor,"--vtree-drop-inner":v.innerDashColor}),onScroll:Te},[ye.value?(l.openBlock(),l.createElementBlock("div",Pe,[l.renderSlot(e.$slots,"empty",{},()=>[l.createElementVNode("div",We,l.toDisplayString(v.emptyText),1)],!0)])):(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[l.createElementVNode("div",{style:l.normalizeStyle({height:ie.value+"px",position:"relative",minWidth:"100%",width:"max-content"})},[l.createElementVNode("div",{style:l.normalizeStyle({height:I.value+"px"})},null,4),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(c.value.slice(L.value,T.value),n=>(l.openBlock(),l.createElementBlock("div",{key:n.rid,class:"amazing-tree-row-wrapper"},[l.createElementVNode("div",{class:l.normalizeClass(["amazing-tree-row",{"is-target-inner":A.value&&D.value===n.rid&&M.value==="inner","is-active":K.value===n.id}]),style:l.normalizeStyle({paddingLeft:n.level*16+"px","--active-color":v.highlightColor}),onMousedown:o=>Ke(n,o),onClick:o=>He(n,o),onContextmenu:l.withModifiers(o=>Le(n,o),["prevent"]),ref_for:!0,ref:o=>Ee(n.rid,o)},[l.createElementVNode("span",{class:l.normalizeClass(["amazing-tree-caret-box",{"is-leaf":n.isLeaf}]),onMousedown:t[0]||(t[0]=l.withModifiers(()=>{},["stop"])),onClick:l.withModifiers(o=>!n.isLeaf&&ke(n.rid),["stop"])},[n.isLeaf?l.createCommentVNode("",!0):(l.openBlock(),l.createElementBlock("span",{key:0,class:l.normalizeClass(["amazing-tree-caret",{expanded:re(n)}])},null,2))],42,Fe),v.showCheckbox?(l.openBlock(),l.createElementBlock("input",{key:0,class:"amazing-tree-checkbox",type:"checkbox",checked:Ce(n.id),onMousedown:t[1]||(t[1]=l.withModifiers(()=>{},["stop"])),indeterminate:be(n.id),disabled:a.disabledChecked?a.disabledChecked(n.node):!1,onClick:l.withModifiers(o=>Se(n,o),["stop"])},null,40,$e)):l.createCommentVNode("",!0),l.renderSlot(e.$slots,"default",{node:n.node,data:n.node,level:n.level,expanded:re(n),isLeaf:n.isLeaf},()=>[l.createElementVNode("span",Oe,l.toDisplayString(n.node[we.value]),1)],!0)],46,Ye),A.value&&D.value===n.rid&&(M.value==="prev"||M.value==="next")?(l.openBlock(),l.createElementBlock("div",{key:0,class:l.normalizeClass(["amazing-tree-drop-line",{"is-prev":M.value==="prev","is-next":M.value==="next"}])},null,2)):l.createCommentVNode("",!0)]))),128)),l.createElementVNode("div",{style:l.normalizeStyle({height:le.value+"px"})},null,4)],4),A.value?(l.openBlock(),l.createElementBlock("div",{key:0,class:"amazing-tree-ghost",style:l.normalizeStyle({top:ne.value+"px"})},null,4)):l.createCommentVNode("",!0)],64))],38))}}),Ue=(v,ee)=>{const X=v.__vccOpts||v;for(const[a,R]of ee)X[a]=R;return X},ge=Ue(qe,[["__scopeId","data-v-602b5fc5"]]);exports.AmazingTree=ge;exports.default=ge;
@@ -1 +1 @@
1
- .amazing-tree[data-v-e0a4c022]{width:100%;overflow:auto;position:relative;background:var(--vtree-bg);color:var(--vtree-text);scrollbar-width:thin;scrollbar-color:rgba(144,147,153,.3) transparent;cursor:pointer;--vtree-primary: #409eff;--vtree-checkbox-bg: #1d1d24;--vtree-checkbox-border: #4c4d4f;--vtree-checkbox-hover-border: #8d8e91;--vtree-checkbox-disabled-bg: #2c2f33;--vtree-checkbox-disabled-border: #5c5f63;--vtree-checkbox-check: #ffffff;--vtree-checkbox-check-disabled: #cfd3dc}.amazing-tree.is-dragging[data-v-e0a4c022],.amazing-tree.is-dragging[data-v-e0a4c022] *{-webkit-user-select:none;user-select:none}.amazing-tree[data-v-e0a4c022] *{cursor:pointer}.amazing-tree input[type=checkbox][data-v-e0a4c022]:disabled{cursor:not-allowed}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]{-webkit-appearance:none;appearance:none;position:relative;width:14px;height:14px;border:1px solid var(--vtree-checkbox-border);background:var(--vtree-checkbox-bg);border-radius:2px;outline:none;transition:border-color .12s ease,background-color .12s ease,box-shadow .12s ease;vertical-align:middle;margin-right:6px}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:not(:disabled):hover{border-color:var(--vtree-checkbox-hover-border)}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:focus-visible{box-shadow:0 0 0 2px #409eff33}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:checked{background:var(--vtree-primary);border-color:var(--vtree-primary)}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:checked:after{content:"";position:absolute;left:3px;top:0;width:4px;height:8px;border:2px solid var(--vtree-checkbox-check);border-top:0;border-left:0;transform:rotate(45deg)}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:indeterminate{background:var(--vtree-primary);border-color:var(--vtree-primary)}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:indeterminate:after{content:"";position:absolute;left:2px;top:5px;width:10px;height:2px;background:var(--vtree-checkbox-check);border-radius:1px}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:disabled{background:var(--vtree-checkbox-disabled-bg);border-color:var(--vtree-checkbox-disabled-border)}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:disabled:checked:after{border-color:var(--vtree-checkbox-check-disabled)}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:disabled:indeterminate:after{background:var(--vtree-checkbox-check-disabled)}.amazing-tree .amazing-tree-row-wrapper[data-v-e0a4c022]{position:relative}.amazing-tree .amazing-tree-row-wrapper .amazing-tree-drop-line[data-v-e0a4c022]{position:absolute;left:0;right:0;height:0;border-top:2px solid #409eff}.amazing-tree .amazing-tree-row-wrapper .amazing-tree-drop-line.is-prev[data-v-e0a4c022]{top:0}.amazing-tree .amazing-tree-row-wrapper .amazing-tree-drop-line.is-next[data-v-e0a4c022]{bottom:0}.amazing-tree .amazing-tree-row[data-v-e0a4c022]{display:flex;align-items:center;gap:4px;box-sizing:border-box;min-height:24px;padding:0 8px;white-space:nowrap}.amazing-tree .amazing-tree-row[data-v-e0a4c022]:hover{background:var(--vtree-hover)}.amazing-tree .amazing-tree-row.is-active[data-v-e0a4c022],.amazing-tree .amazing-tree-row.is-active[data-v-e0a4c022]:hover{background:var(--active-color)}.amazing-tree .amazing-tree-row.is-target-inner[data-v-e0a4c022]{outline:2px dashed #409eff}.amazing-tree .amazing-tree-row .amazing-tree-caret-box[data-v-e0a4c022]{display:inline-flex;align-items:center;justify-content:center;height:100%;aspect-ratio:1/1;min-width:16px;margin-right:4px;cursor:pointer}.amazing-tree .amazing-tree-row .amazing-tree-caret-box.is-leaf[data-v-e0a4c022]{pointer-events:none}.amazing-tree .amazing-tree-row .amazing-tree-caret[data-v-e0a4c022]{display:block;width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:6px solid #909399;transform:rotate(-90deg);transition:transform .1s linear}.amazing-tree .amazing-tree-row .amazing-tree-caret.expanded[data-v-e0a4c022]{transform:rotate(0)}.amazing-tree .amazing-tree-row .amazing-tree-label[data-v-e0a4c022]{color:inherit}.amazing-tree .amazing-tree-ghost[data-v-e0a4c022]{position:fixed;left:16px;width:120px;height:24px;background:#409eff33;border:1px solid #409eff;pointer-events:none}.amazing-tree .amazing-tree-empty[data-v-e0a4c022]{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.amazing-tree .amazing-tree-empty[data-v-e0a4c022]>*{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.amazing-tree .amazing-tree-empty .amazing-tree-empty-inner[data-v-e0a4c022]{color:var(--vtree-text)}[data-v-e0a4c022] .amazing-tree::-webkit-scrollbar{width:8px;height:8px}[data-v-e0a4c022] .amazing-tree::-webkit-scrollbar-track{background:transparent}[data-v-e0a4c022] .amazing-tree::-webkit-scrollbar-thumb{background-color:#9093994d;border-radius:4px}[data-v-e0a4c022] .amazing-tree::-webkit-scrollbar-thumb:hover{background-color:#90939980}
1
+ .amazing-tree[data-v-602b5fc5]{width:100%;overflow:auto;position:relative;background:var(--vtree-bg);color:var(--vtree-text);scrollbar-width:thin;scrollbar-color:rgba(144,147,153,.3) transparent;cursor:pointer;--vtree-primary: #409eff;--vtree-checkbox-bg: #1d1d24;--vtree-checkbox-border: #4c4d4f;--vtree-checkbox-hover-border: #8d8e91;--vtree-checkbox-disabled-bg: #2c2f33;--vtree-checkbox-disabled-border: #5c5f63;--vtree-checkbox-check: #ffffff;--vtree-checkbox-check-disabled: #cfd3dc}.amazing-tree.is-dragging[data-v-602b5fc5],.amazing-tree.is-dragging[data-v-602b5fc5] *{-webkit-user-select:none;user-select:none}.amazing-tree[data-v-602b5fc5] *{cursor:pointer}.amazing-tree input[type=checkbox][data-v-602b5fc5]:disabled{cursor:not-allowed}.amazing-tree .amazing-tree-checkbox[data-v-602b5fc5]{-webkit-appearance:none;appearance:none;position:relative;width:14px;height:14px;border:1px solid var(--vtree-checkbox-border);background:var(--vtree-checkbox-bg);border-radius:2px;outline:none;transition:border-color .12s ease,background-color .12s ease,box-shadow .12s ease;vertical-align:middle;margin-right:6px}.amazing-tree .amazing-tree-checkbox[data-v-602b5fc5]:not(:disabled):hover{border-color:var(--vtree-checkbox-hover-border)}.amazing-tree .amazing-tree-checkbox[data-v-602b5fc5]:focus-visible{box-shadow:0 0 0 2px #409eff33}.amazing-tree .amazing-tree-checkbox[data-v-602b5fc5]:checked{background:var(--vtree-primary);border-color:var(--vtree-primary)}.amazing-tree .amazing-tree-checkbox[data-v-602b5fc5]:checked:after{content:"";position:absolute;left:3px;top:0;width:4px;height:8px;border:2px solid var(--vtree-checkbox-check);border-top:0;border-left:0;transform:rotate(45deg)}.amazing-tree .amazing-tree-checkbox[data-v-602b5fc5]:indeterminate{background:var(--vtree-primary);border-color:var(--vtree-primary)}.amazing-tree .amazing-tree-checkbox[data-v-602b5fc5]:indeterminate:after{content:"";position:absolute;left:2px;top:5px;width:10px;height:2px;background:var(--vtree-checkbox-check);border-radius:1px}.amazing-tree .amazing-tree-checkbox[data-v-602b5fc5]:disabled{background:var(--vtree-checkbox-disabled-bg);border-color:var(--vtree-checkbox-disabled-border)}.amazing-tree .amazing-tree-checkbox[data-v-602b5fc5]:disabled:checked:after{border-color:var(--vtree-checkbox-check-disabled)}.amazing-tree .amazing-tree-checkbox[data-v-602b5fc5]:disabled:indeterminate:after{background:var(--vtree-checkbox-check-disabled)}.amazing-tree .amazing-tree-row-wrapper[data-v-602b5fc5]{position:relative}.amazing-tree .amazing-tree-row-wrapper .amazing-tree-drop-line[data-v-602b5fc5]{position:absolute;left:0;right:0;height:0;border-top:2px solid var(--vtree-drop-line, #ffd400)}.amazing-tree .amazing-tree-row-wrapper .amazing-tree-drop-line.is-prev[data-v-602b5fc5]{top:0}.amazing-tree .amazing-tree-row-wrapper .amazing-tree-drop-line.is-next[data-v-602b5fc5]{bottom:0}.amazing-tree .amazing-tree-row[data-v-602b5fc5]{display:flex;align-items:center;gap:4px;box-sizing:border-box;position:relative;min-height:var(--vtree-row-height, 32px);line-height:var(--vtree-row-height, 32px);padding:0 8px;white-space:nowrap}.amazing-tree .amazing-tree-row[data-v-602b5fc5]:hover{background:var(--vtree-hover)}.amazing-tree .amazing-tree-row.is-active[data-v-602b5fc5],.amazing-tree .amazing-tree-row.is-active[data-v-602b5fc5]:hover{background:var(--active-color)}.amazing-tree .amazing-tree-row.is-target-inner[data-v-602b5fc5]:before,.amazing-tree .amazing-tree-row.is-target-inner[data-v-602b5fc5]:after{content:"";position:absolute;left:0;right:0;pointer-events:none}.amazing-tree .amazing-tree-row.is-target-inner[data-v-602b5fc5]:before{top:0;border-top:2px dashed var(--vtree-drop-inner, #ffd400)}.amazing-tree .amazing-tree-row.is-target-inner[data-v-602b5fc5]:after{bottom:0;border-bottom:2px dashed var(--vtree-drop-inner, #ffd400)}.amazing-tree .amazing-tree-row .amazing-tree-caret-box[data-v-602b5fc5]{display:inline-flex;align-items:center;justify-content:center;height:100%;aspect-ratio:1/1;min-width:16px;margin-right:4px;cursor:pointer}.amazing-tree .amazing-tree-row .amazing-tree-caret-box.is-leaf[data-v-602b5fc5]{pointer-events:none}.amazing-tree .amazing-tree-row .amazing-tree-caret[data-v-602b5fc5]{display:block;width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:6px solid #909399;transform:rotate(-90deg);transition:transform .1s linear}.amazing-tree .amazing-tree-row .amazing-tree-caret.expanded[data-v-602b5fc5]{transform:rotate(0)}.amazing-tree .amazing-tree-row .amazing-tree-label[data-v-602b5fc5]{color:inherit}.amazing-tree .amazing-tree-ghost[data-v-602b5fc5]{position:fixed;left:16px;width:120px;height:var(--vtree-row-height, 32px);background:#409eff33;border:1px solid #409eff;pointer-events:none}.amazing-tree .amazing-tree-empty[data-v-602b5fc5]{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.amazing-tree .amazing-tree-empty[data-v-602b5fc5]>*{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.amazing-tree .amazing-tree-empty .amazing-tree-empty-inner[data-v-602b5fc5]{color:var(--vtree-text)}[data-v-602b5fc5] .amazing-tree::-webkit-scrollbar{width:8px;height:8px}[data-v-602b5fc5] .amazing-tree::-webkit-scrollbar-track{background:transparent}[data-v-602b5fc5] .amazing-tree::-webkit-scrollbar-thumb{background-color:#9093994d;border-radius:4px}[data-v-602b5fc5] .amazing-tree::-webkit-scrollbar-thumb:hover{background-color:#90939980}
@@ -1,8 +1,8 @@
1
- import { defineComponent as Pe, computed as _, ref as d, reactive as ke, watch as W, nextTick as C, onMounted as Ve, onUnmounted as Ue, watchEffect as $e, createElementBlock as K, openBlock as E, normalizeStyle as O, normalizeClass as Q, Fragment as Ce, createElementVNode as Y, createCommentVNode as ne, renderList as qe, withModifiers as re, renderSlot as be, toDisplayString as Se } from "vue";
2
- const Qe = ["onMousedown", "onClick", "onContextmenu"], je = ["onClick"], Ge = ["checked", "indeterminate", "disabled", "onClick"], Je = { class: "amazing-tree-label" }, Xe = {
1
+ import { defineComponent as Je, computed as U, ref as d, reactive as Ke, watch as X, nextTick as S, onMounted as _e, onUnmounted as et, watchEffect as tt, createElementBlock as R, openBlock as T, normalizeStyle as q, normalizeClass as ee, Fragment as ze, createElementVNode as $, createCommentVNode as se, renderList as nt, withModifiers as te, renderSlot as Ee, toDisplayString as Re } from "vue";
2
+ const lt = ["onMousedown", "onClick", "onContextmenu"], at = ["onClick"], ot = ["checked", "indeterminate", "disabled", "onClick"], ut = { class: "amazing-tree-label" }, it = {
3
3
  key: 1,
4
4
  class: "amazing-tree-empty"
5
- }, Ze = { class: "amazing-tree-empty-inner" }, j = 28, et = /* @__PURE__ */ Pe({
5
+ }, rt = { class: "amazing-tree-empty-inner" }, st = /* @__PURE__ */ Je({
6
6
  __name: "AmazingTree",
7
7
  props: {
8
8
  data: {},
@@ -10,6 +10,11 @@ const Qe = ["onMousedown", "onClick", "onContextmenu"], je = ["onClick"], Ge = [
10
10
  allowDrag: {},
11
11
  allowDrop: {},
12
12
  height: { default: void 0 },
13
+ rowHeight: { default: 32 },
14
+ dropLineColor: { default: "#ffd400" },
15
+ innerDashColor: { default: "#ffd400" },
16
+ siblingZoneRatio: { default: 0.35 },
17
+ dragStartThreshold: { default: 4 },
13
18
  highlightColor: { default: "#1e71ff" },
14
19
  backgroundColor: { default: "#1d1d24" },
15
20
  textColor: { default: "#c8d3de" },
@@ -26,432 +31,463 @@ const Qe = ["onMousedown", "onClick", "onContextmenu"], je = ["onClick"], Ge = [
26
31
  filterNodeMethod: {}
27
32
  },
28
33
  emits: ["node-click", "node-contextmenu", "node-drop", "current-change", "check-change"],
29
- setup(g, { expose: le, emit: G }) {
30
- const l = g, L = G, Me = _(() => l.props.value || "value"), Ae = _(() => l.props.label || "label"), J = _(() => l.props.children || "children"), ze = _(() => Array.isArray(l.data) ? l.data.length === 0 : !0), x = d(/* @__PURE__ */ new Set()), p = d(/* @__PURE__ */ new Set()), y = d(/* @__PURE__ */ new Set()), ae = d(null);
31
- function de(e) {
32
- return x.value.has(e);
33
- }
34
- function Te(e) {
35
- x.value.has(e) ? x.value.delete(e) : x.value.add(e), i.value = b(l.data || []), C(() => {
36
- A(), m();
34
+ setup(v, { expose: ce, emit: ne }) {
35
+ const l = v, B = ne, Te = U(() => l.props.value || "value"), He = U(() => l.props.label || "label"), le = U(() => l.props.children || "children"), Le = U(() => Array.isArray(l.data) ? l.data.length === 0 : !0), D = d(/* @__PURE__ */ new Set()), x = d(/* @__PURE__ */ new Set()), p = d(/* @__PURE__ */ new Set()), y = d(/* @__PURE__ */ new Set()), ae = d(null);
36
+ function pe(e) {
37
+ return D.value.has(e.rid) || x.value.has(e.id);
38
+ }
39
+ function Ie(e) {
40
+ const t = ie(e);
41
+ if (!t) return;
42
+ const n = t.id;
43
+ D.value.has(e) || x.value.has(n) ? (D.value.delete(e), x.value.delete(n)) : D.value.add(e), r.value = M(l.data || []), S(() => {
44
+ E(), w();
37
45
  });
38
46
  }
39
- function w(e) {
40
- return e[Me.value];
47
+ function k(e) {
48
+ return e[Te.value];
41
49
  }
42
- function S(e) {
43
- const t = e[J.value];
50
+ function K(e) {
51
+ const t = e[le.value];
44
52
  return Array.isArray(t) ? t : [];
45
53
  }
46
- function Ke(e) {
54
+ function Be(e) {
47
55
  return p.value.has(e);
48
56
  }
49
- function Ee(e) {
57
+ function De(e) {
50
58
  return y.value.has(e);
51
59
  }
52
- function oe(e, t) {
60
+ function de(e, t) {
53
61
  if (t ? p.value.add(e) : p.value.delete(e), y.value.delete(e), !l.checkStrictly) {
54
- const n = se(e, l.data || []);
62
+ const n = he(e, l.data || []);
55
63
  if (n) {
56
64
  const a = [n];
57
65
  for (; a.length; ) {
58
- const c = a.pop(), o = w(c);
66
+ const i = a.pop(), o = k(i);
59
67
  t ? p.value.add(o) : p.value.delete(o), y.value.delete(o);
60
- const v = S(c);
61
- for (const r of v) a.push(r);
68
+ const s = K(i);
69
+ for (const c of s) a.push(c);
62
70
  }
63
- const u = te(e, l.data || []) || [];
64
- for (const c of u) {
65
- const o = w(c), v = S(c);
66
- let r = !0, s = !1;
67
- for (const h of v) {
68
- const N = w(h), ye = p.value.has(N), we = y.value.has(N);
69
- (ye || we) && (s = !0), (!ye || we) && (r = !1);
71
+ const u = re(e, l.data || []) || [];
72
+ for (const i of u) {
73
+ const o = k(i), s = K(i);
74
+ let c = !0, f = !1;
75
+ for (const g of s) {
76
+ const m = k(g), b = p.value.has(m), V = y.value.has(m);
77
+ (b || V) && (f = !0), (!b || V) && (c = !1);
70
78
  }
71
- v.length === 0 ? (p.value.has(o), y.value.delete(o)) : r ? (p.value.add(o), y.value.delete(o)) : s ? (p.value.delete(o), y.value.add(o)) : (p.value.delete(o), y.value.delete(o));
79
+ s.length === 0 ? (p.value.has(o), y.value.delete(o)) : c ? (p.value.add(o), y.value.delete(o)) : f ? (p.value.delete(o), y.value.add(o)) : (p.value.delete(o), y.value.delete(o));
72
80
  }
73
81
  }
74
82
  }
75
83
  }
76
- function ve(e) {
84
+ function me(e) {
77
85
  p.value = /* @__PURE__ */ new Set(), y.value = /* @__PURE__ */ new Set();
78
- for (const t of e || []) oe(t, !0);
86
+ for (const t of e || []) de(t, !0);
79
87
  }
80
- function Ie(e, t) {
88
+ function Ye(e, t) {
81
89
  const n = t.target;
82
- l.disabledChecked && l.disabledChecked(e.node) || (L("check-change", e.node, !!n.checked), oe(e.id, !!n.checked));
90
+ l.disabledChecked && l.disabledChecked(e.node) || (B("check-change", e.node, !!n.checked), de(e.id, !!n.checked));
83
91
  }
84
- function b(e) {
92
+ function M(e) {
85
93
  const t = [];
86
- function n(a, u, c) {
87
- for (let o = 0; o < a.length; o++) {
88
- const v = a[o], r = w(v), s = S(v), h = s.length === 0;
89
- t.push({ id: r, node: v, parent: u, level: c, index: o, isLeaf: h }), !h && x.value.has(r) && n(s, v, c + 1);
94
+ function n(a, u, i, o) {
95
+ for (let s = 0; s < a.length; s++) {
96
+ const c = a[s], f = k(c), g = K(c), m = g.length === 0, b = o ? `${o}/${s}` : `${s}`, V = { rid: b, id: f, node: c, parent: u, level: i, index: s, isLeaf: m };
97
+ t.push(V);
98
+ const ge = D.value.has(b) || x.value.has(f);
99
+ !m && ge && n(g, c, i + 1, b);
90
100
  }
91
101
  }
92
- if (n(e, null, 0), l.filterNodeMethod && ae.value != null) {
102
+ if (n(e, null, 0, ""), l.filterNodeMethod && ae.value != null) {
93
103
  let a = function(o) {
94
- const v = w(o), r = S(o);
95
- let s = !1;
96
- for (const N of r) s = a(N) || s;
97
- const h = !!l.filterNodeMethod(ae.value, o);
98
- return h && u.add(v), s && c.add(v), h || s;
104
+ const s = k(o), c = K(o);
105
+ let f = !1;
106
+ for (const m of c) f = a(m) || f;
107
+ const g = !!l.filterNodeMethod(ae.value, o);
108
+ return g && u.add(s), f && i.add(s), g || f;
99
109
  };
100
- const u = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set();
110
+ const u = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
101
111
  for (const o of e) a(o);
102
- return t.filter((o) => u.has(o.id) || c.has(o.id));
112
+ return t.filter((o) => u.has(o.id) || i.has(o.id));
103
113
  }
104
114
  return t;
105
115
  }
106
- const f = d(null), I = d(0), P = d(0), i = d([]), R = ke(/* @__PURE__ */ new Map()), k = _(() => {
116
+ const h = d(null), H = d(0), Z = d(0), r = d([]), Y = Ke(/* @__PURE__ */ new Map());
117
+ function Ne(e) {
118
+ if (typeof e == "number") return e;
119
+ if (typeof e == "string") {
120
+ const t = e.match(/(\d+(\.\d+)?)/);
121
+ return t ? Number(t[1]) : 32;
122
+ }
123
+ return 32;
124
+ }
125
+ const Q = Ne(l.rowHeight), C = U(() => {
107
126
  let e = 0;
108
127
  const t = [];
109
- for (const n of i.value) {
110
- const a = R.get(n.id) || j;
128
+ for (const n of r.value) {
129
+ const a = Y.get(n.rid) || Q;
111
130
  e += a, t.push(e);
112
131
  }
113
132
  return t;
114
- }), fe = _(() => {
115
- const e = k.value;
133
+ }), xe = U(() => {
134
+ const e = C.value;
116
135
  return e.length ? e[e.length - 1] : 0;
117
136
  });
118
- function he(e) {
119
- let t = 0, n = k.value.length - 1, a = 0;
137
+ function we(e) {
138
+ let t = 0, n = C.value.length - 1, a = 0;
120
139
  for (; t <= n; ) {
121
140
  const u = t + n >> 1;
122
- k.value[u] !== void 0 && k.value[u] >= e ? (a = u, n = u - 1) : t = u + 1;
141
+ C.value[u] !== void 0 && C.value[u] >= e ? (a = u, n = u - 1) : t = u + 1;
123
142
  }
124
143
  return a;
125
144
  }
126
- const B = d(0), M = d(0), H = d(0), ue = d(0);
127
- function m() {
128
- if (P.value = f.value?.clientHeight || 0, k.value.length === 0 || i.value.length === 0) {
129
- B.value = 0, M.value = 0, H.value = 0, ue.value = 0;
145
+ const N = d(0), z = d(0), F = d(0), fe = d(0);
146
+ function w() {
147
+ if (Z.value = h.value?.clientHeight || 0, C.value.length === 0 || r.value.length === 0) {
148
+ N.value = 0, z.value = 0, F.value = 0, fe.value = 0;
130
149
  return;
131
150
  }
132
- const e = he(I.value);
133
- B.value = Math.max(0, e - 3);
134
- const t = i.value[B.value], n = t ? R.get(t.id) || j : 0, u = (k.value[B.value] ?? 0) - n;
135
- H.value = Math.max(0, u);
136
- let c = B.value;
137
- const o = I.value + P.value + 3 * j;
138
- for (; c < i.value.length && (k.value[c] ?? 0) < o; ) c++;
139
- M.value = Math.min(i.value.length, c + 1);
140
- const r = (k.value[M.value - 1] ?? 0) - H.value;
141
- if (r < P.value && M.value < i.value.length) {
142
- let s = M.value, h = r;
143
- for (; h < P.value && s < i.value.length; )
144
- s++, h = (k.value[s - 1] ?? 0) - H.value;
145
- M.value = s;
151
+ const e = we(H.value);
152
+ N.value = Math.max(0, e - 3);
153
+ const t = r.value[N.value], n = t ? Y.get(t.rid) || Q : 0, u = (C.value[N.value] ?? 0) - n;
154
+ F.value = Math.max(0, u);
155
+ let i = N.value;
156
+ const o = H.value + Z.value + 3 * Q;
157
+ for (; i < r.value.length && (C.value[i] ?? 0) < o; ) i++;
158
+ z.value = Math.min(r.value.length, i + 1);
159
+ const c = (C.value[z.value - 1] ?? 0) - F.value;
160
+ if (c < Z.value && z.value < r.value.length) {
161
+ let f = z.value, g = c;
162
+ for (; g < Z.value && f < r.value.length; )
163
+ f++, g = (C.value[f - 1] ?? 0) - F.value;
164
+ z.value = f;
146
165
  }
147
- ue.value = Math.max(0, fe.value - H.value - ((k.value[M.value - 1] ?? 0) - H.value));
148
- }
149
- W([I, () => l.data, x], () => {
150
- i.value = b(l.data || []), C(A), m();
151
- }), Ve(() => {
152
- i.value = b(l.data || []), C(A), m(), l.defaultCheckedKeys && l.defaultCheckedKeys.length && ve(l.defaultCheckedKeys), f.value && (V = new ResizeObserver(() => {
153
- P.value = f.value?.clientHeight || 0, m();
154
- }), V.observe(f.value));
166
+ fe.value = Math.max(0, xe.value - F.value - ((C.value[z.value - 1] ?? 0) - F.value));
167
+ }
168
+ X([H, () => l.data, D, x], () => {
169
+ r.value = M(l.data || []), S(E), w();
170
+ }), _e(() => {
171
+ r.value = M(l.data || []), S(E), w(), l.defaultCheckedKeys && l.defaultCheckedKeys.length && me(l.defaultCheckedKeys), h.value && (j = new ResizeObserver(() => {
172
+ Z.value = h.value?.clientHeight || 0, w();
173
+ }), j.observe(h.value));
155
174
  });
156
- let V = null;
157
- Ue(() => {
158
- V && (V.disconnect(), V = null);
175
+ let j = null;
176
+ et(() => {
177
+ j && (j.disconnect(), j = null);
159
178
  });
160
- const X = ke(/* @__PURE__ */ new Map());
161
- function Le(e, t) {
162
- t ? X.set(e, t) : X.delete(e);
179
+ const oe = Ke(/* @__PURE__ */ new Map());
180
+ function Fe(e, t) {
181
+ t ? oe.set(e, t) : oe.delete(e);
163
182
  }
164
- function A() {
183
+ function E() {
165
184
  let e = !1;
166
- for (const t of i.value.slice(B.value, M.value)) {
167
- const n = X.get(t.id);
185
+ for (const t of r.value.slice(N.value, z.value)) {
186
+ const n = oe.get(t.rid);
168
187
  if (n) {
169
188
  const a = n.offsetHeight;
170
- (!R.has(t.id) || R.get(t.id) !== a) && (R.set(t.id, a), e = !0);
189
+ (!Y.has(t.rid) || Y.get(t.rid) !== a) && (Y.set(t.rid, a), e = !0);
171
190
  }
172
191
  }
173
- e && m();
192
+ e && w();
174
193
  }
175
- function Re() {
176
- I.value = f.value?.scrollTop || 0, m();
194
+ function $e() {
195
+ H.value = h.value?.scrollTop || 0, w();
177
196
  }
178
- const z = d(!1), ce = d(null), U = d(null), T = d(null), ie = d(0), D = d(null), $ = d(0);
179
- let F = null;
180
- function Z() {
181
- F != null && (cancelAnimationFrame(F), F = null);
197
+ const L = d(!1), G = d(null), W = d(null), A = d(null), ve = d(0), J = d(!1), ye = d(0), ke = d(0), I = d(null), _ = d(0);
198
+ let O = null;
199
+ function ue() {
200
+ O != null && (cancelAnimationFrame(O), O = null);
182
201
  }
183
- function pe() {
184
- if (!z.value || $.value === 0) {
185
- Z();
202
+ function Ce() {
203
+ if (!L.value || _.value === 0) {
204
+ ue();
186
205
  return;
187
206
  }
188
- const e = f.value;
207
+ const e = h.value;
189
208
  if (!e) {
190
- Z();
209
+ ue();
191
210
  return;
192
211
  }
193
212
  const t = e.scrollHeight - e.clientHeight, n = 12;
194
- e.scrollTop = Math.max(0, Math.min(t, e.scrollTop + $.value * n)), I.value = e.scrollTop, m(), F = requestAnimationFrame(pe);
213
+ e.scrollTop = Math.max(0, Math.min(t, e.scrollTop + _.value * n)), H.value = e.scrollTop, w(), O = requestAnimationFrame(Ce);
214
+ }
215
+ function We() {
216
+ _.value !== 0 && O == null && (O = requestAnimationFrame(Ce)), _.value === 0 && ue();
195
217
  }
196
- function Be() {
197
- $.value !== 0 && F == null && (F = requestAnimationFrame(pe)), $.value === 0 && Z();
218
+ function Oe(e) {
219
+ if (e == null) return null;
220
+ for (const t of r.value) if (t.id === e) return t;
221
+ return null;
198
222
  }
199
- function ee(e) {
223
+ function ie(e) {
200
224
  if (e == null) return null;
201
- for (const t of i.value) if (t.id === e) return t;
225
+ for (const t of r.value) if (t.rid === e) return t;
202
226
  return null;
203
227
  }
204
- function He(e) {
205
- const t = f.value.getBoundingClientRect(), n = e - t.top + I.value;
206
- return he(n);
228
+ function Pe(e) {
229
+ const t = h.value.getBoundingClientRect(), n = e - t.top + H.value;
230
+ return we(n);
207
231
  }
208
- function De(e, t) {
209
- !l.draggable || t.button !== 0 || !(!l.allowDrag || l.allowDrag(e.node)) || (z.value = !0, ce.value = e.id, ie.value = t.clientY, t.preventDefault(), window.addEventListener("mousemove", ge), window.addEventListener("mouseup", me));
232
+ function Ve(e, t) {
233
+ !l.draggable || t.button !== 0 || !(!l.allowDrag || l.allowDrag(e.node)) || (G.value = e.rid, ve.value = t.clientY, ye.value = t.clientX, ke.value = t.clientY, J.value = !1, t.preventDefault(), window.addEventListener("mousemove", be), window.addEventListener("mouseup", Se));
210
234
  }
211
- function ge(e) {
212
- if (!z.value) return;
213
- ie.value = e.clientY;
214
- const t = He(e.clientY), n = i.value[Math.min(Math.max(t, 0), i.value.length - 1)];
215
- if (U.value = n?.id ?? null, !n) {
216
- T.value = null;
235
+ function be(e) {
236
+ if (G.value == null) return;
237
+ if (!J.value) {
238
+ const ge = Math.abs(e.clientX - ye.value), Ge = Math.abs(e.clientY - ke.value), Ae = Math.max(1, l.dragStartThreshold ?? 4);
239
+ if (ge < Ae && Ge < Ae) return;
240
+ J.value = !0, L.value = !0;
241
+ }
242
+ ve.value = e.clientY;
243
+ const t = Pe(e.clientY), n = r.value[Math.min(Math.max(t, 0), r.value.length - 1)];
244
+ if (W.value = n?.rid ?? null, !n) {
245
+ A.value = null;
217
246
  return;
218
247
  }
219
- const a = k.value[t] ?? 0, u = R.get(n.id) ?? j, c = a - u, o = f.value.getBoundingClientRect(), r = (e.clientY - o.top + I.value - c) / u;
220
- let s = "inner";
221
- r < 0.25 ? s = "prev" : r > 0.75 && (s = "next");
222
- const h = ee(ce.value), N = l.allowDrop ? !!(h && l.allowDrop(h.node, n.node, s)) : !0;
223
- T.value = N ? s : null, $.value = e.clientY > o.bottom ? 1 : e.clientY < o.top ? -1 : 0, Be();
248
+ const a = C.value[t] ?? 0, u = Y.get(n.rid) ?? Q, i = a - u, o = h.value.getBoundingClientRect(), c = (e.clientY - o.top + H.value - i) / u, f = l.siblingZoneRatio ?? 0.35, g = Math.max(0.05, Math.min(0.49, f));
249
+ let m = "inner";
250
+ c < g ? m = "prev" : c > 1 - g && (m = "next");
251
+ const b = ie(G.value), V = l.allowDrop ? !!(b && l.allowDrop(b.node, n.node, m)) : !0;
252
+ A.value = V ? m : null, _.value = e.clientY > o.bottom ? 1 : e.clientY < o.top ? -1 : 0, We();
224
253
  }
225
- function te(e, t, n = []) {
254
+ function re(e, t, n = []) {
226
255
  for (const a of t) {
227
- if (w(a) === e) return n;
228
- const u = S(a);
256
+ if (k(a) === e) return n;
257
+ const u = K(a);
229
258
  if (u.length) {
230
- const c = te(e, u, [...n, a]);
231
- if (c) return c;
259
+ const i = re(e, u, [...n, a]);
260
+ if (i) return i;
232
261
  }
233
262
  }
234
263
  return null;
235
264
  }
236
- function se(e, t) {
265
+ function he(e, t) {
237
266
  if (e == null) return null;
238
267
  for (const n of t) {
239
- if (w(n) === e) return n;
240
- const a = S(n), u = se(e, a);
268
+ if (k(n) === e) return n;
269
+ const a = K(n), u = he(e, a);
241
270
  if (u) return u;
242
271
  }
243
272
  return null;
244
273
  }
245
- function q(e) {
274
+ function P(e) {
246
275
  const t = [];
247
276
  for (const n of e) {
248
- t.push(w(n));
249
- const a = S(n);
250
- a.length && t.push(...q(a));
277
+ t.push(k(n));
278
+ const a = K(n);
279
+ a.length && t.push(...P(a));
251
280
  }
252
281
  return t;
253
282
  }
254
- function Ye(e) {
283
+ function Ue(e) {
255
284
  const t = e.parent;
256
285
  if (t)
257
- S(t).splice(e.index, 1);
286
+ K(t).splice(e.index, 1);
258
287
  else {
259
- const n = l.data.findIndex((a) => w(a) === e.id);
288
+ const n = l.data.findIndex((a) => k(a) === e.id);
260
289
  n >= 0 && l.data.splice(n, 1);
261
290
  }
262
291
  }
263
- function Fe(e, t, n) {
292
+ function Xe(e, t, n) {
264
293
  if (n === "inner") {
265
- Array.isArray(t.node[J.value]) || (t.node[J.value] = []), t.node[J.value].push(e), x.value.add(t.id);
294
+ Array.isArray(t.node[le.value]) || (t.node[le.value] = []), t.node[le.value].push(e), D.value.add(t.rid);
266
295
  return;
267
296
  }
268
297
  const a = t.parent;
269
298
  if (a) {
270
- const u = S(a), c = t.index + (n === "next" ? 1 : 0);
271
- u.splice(c, 0, e);
299
+ const u = K(a), i = t.index + (n === "next" ? 1 : 0);
300
+ u.splice(i, 0, e);
272
301
  } else {
273
302
  const u = t.index + (n === "next" ? 1 : 0);
274
303
  l.data.splice(u, 0, e);
275
304
  }
276
305
  }
277
- function me() {
278
- if (window.removeEventListener("mousemove", ge), window.removeEventListener("mouseup", me), Z(), !z.value) return;
279
- const e = ee(ce.value), t = ee(U.value), n = T.value;
280
- if (z.value = !1, T.value = null, U.value = null, !e || !t || !n || l.allowDrop && !l.allowDrop(e.node, t.node, n) || e.id === t.id) return;
306
+ function Se() {
307
+ if (window.removeEventListener("mousemove", be), window.removeEventListener("mouseup", Se), ue(), !L.value) {
308
+ G.value = null, A.value = null, W.value = null, J.value = !1;
309
+ return;
310
+ }
311
+ const e = ie(G.value), t = ie(W.value), n = A.value;
312
+ if (L.value = !1, J.value = !1, A.value = null, W.value = null, !e || !t || !n || l.allowDrop && !l.allowDrop(e.node, t.node, n) || e.id === t.id) return;
281
313
  const a = n === "inner" ? t.node : t.parent || null;
282
314
  if (a) {
283
- const v = te(w(a), l.data || []) || [];
284
- for (const r of v) if (w(r) === e.id) return;
315
+ const s = re(k(a), l.data || []) || [];
316
+ for (const c of s) if (k(c) === e.id) return;
285
317
  }
286
318
  const u = e.node;
287
- Ye(e);
288
- const c = b(l.data || []);
289
- i.value = c;
290
- const o = ee(t.id) || t;
291
- Fe(u, o, n), i.value = b(l.data || []), C(() => {
292
- A(), m();
293
- }), L("node-drop", u, o.node, n);
294
- }
295
- function Ne(e, t) {
296
- D.value = e.id, L("node-click", e.node, t);
297
- }
298
- function _e(e, t) {
299
- L("node-contextmenu", e.node, t);
300
- }
301
- $e(() => {
302
- C(A);
303
- }), W(
319
+ Ue(e);
320
+ const i = M(l.data || []);
321
+ r.value = i;
322
+ const o = Oe(t.id) || t;
323
+ Xe(u, o, n), r.value = M(l.data || []), S(() => {
324
+ E(), w();
325
+ }), B("node-drop", u, o.node, n);
326
+ }
327
+ function qe(e, t) {
328
+ I.value = e.id, B("node-click", e.node, t);
329
+ }
330
+ function Ze(e, t) {
331
+ I.value = e.id, B("node-contextmenu", e.node, t);
332
+ }
333
+ tt(() => {
334
+ S(E);
335
+ }), X(
304
336
  () => l.currentNodeKey,
305
337
  (e) => {
306
- D.value = e ?? null;
338
+ I.value = e ?? null;
307
339
  },
308
340
  { immediate: !0 }
309
- ), W(
341
+ ), X(
310
342
  () => l.defaultExpandedKeys,
311
343
  (e) => {
312
- x.value = new Set(e || []), i.value = b(l.data || []), C(() => {
313
- A(), m();
344
+ x.value = new Set(e || []), r.value = M(l.data || []), S(() => {
345
+ E(), w();
314
346
  });
315
347
  },
316
348
  { immediate: !0 }
317
- ), W(
349
+ ), X(
318
350
  () => l.defaultExpandAll,
319
351
  (e) => {
320
- e && (x.value = new Set(q(l.data || [])), i.value = b(l.data || []), C(() => {
321
- A(), m();
352
+ e && (x.value = new Set(P(l.data || [])), r.value = M(l.data || []), S(() => {
353
+ E(), w();
322
354
  }));
323
355
  },
324
356
  { immediate: !0 }
325
- ), W(
357
+ ), X(
326
358
  () => l.data,
327
359
  () => {
328
- l.defaultExpandAll && (x.value = new Set(q(l.data || []))), i.value = b(l.data || []), C(() => {
329
- A(), m();
360
+ l.defaultExpandAll && (x.value = new Set(P(l.data || []))), r.value = M(l.data || []), S(() => {
361
+ E(), w();
330
362
  });
331
- const e = new Set(q(l.data || []));
363
+ const e = new Set(P(l.data || []));
332
364
  p.value = new Set([...p.value].filter((t) => e.has(t))), y.value = new Set([...y.value].filter((t) => e.has(t)));
333
365
  },
334
366
  { deep: !0 }
335
367
  );
336
- function We(e) {
337
- const t = te(e, l.data || []) || [];
338
- for (const n of t) x.value.add(w(n));
339
- i.value = b(l.data || []);
340
- }
341
- function xe(e) {
342
- e != null && (We(e), C(() => {
343
- const t = i.value.findIndex((o) => o.id === e);
344
- if (t < 0 || !f.value) return;
345
- const n = R.get(e) || j, a = (k.value[t] ?? 0) - n, u = f.value.clientHeight, c = Math.max(0, a - Math.max(0, (u - n) / 2));
346
- f.value.scrollTop = c, I.value = c, m(), C(() => {
347
- const o = X.get(e);
348
- if (!o || !f.value) return;
349
- const v = o.offsetLeft, r = o.offsetWidth, s = f.value.clientWidth, h = Math.max(0, v + Math.max(0, r / 2) - Math.max(0, s / 2));
350
- f.value.scrollLeft = h;
368
+ function Qe(e) {
369
+ const t = re(e, l.data || []) || [];
370
+ for (const n of t) x.value.add(k(n));
371
+ r.value = M(l.data || []);
372
+ }
373
+ function Me(e) {
374
+ e != null && (Qe(e), S(() => {
375
+ const t = r.value.findIndex((s) => s.id === e);
376
+ if (t < 0 || !h.value) return;
377
+ const n = r.value[t]?.rid, a = (n ? Y.get(n) : void 0) || Q, u = (C.value[t] ?? 0) - a, i = h.value.clientHeight, o = Math.max(0, u - Math.max(0, (i - a) / 2));
378
+ h.value.scrollTop = o, H.value = o, w(), S(() => {
379
+ const s = n || null, c = s ? oe.get(s) : null;
380
+ if (!c || !h.value) return;
381
+ const f = c.offsetLeft, g = c.offsetWidth, m = h.value.clientWidth, b = Math.max(0, f + Math.max(0, g / 2) - Math.max(0, m / 2));
382
+ h.value.scrollLeft = b;
351
383
  });
352
384
  }));
353
385
  }
354
- function Oe(e) {
355
- D.value = e ?? null, xe(D.value);
386
+ function je(e) {
387
+ I.value = e ?? null, Me(I.value);
356
388
  }
357
- return le({
358
- getCurrentKey: () => D.value,
359
- setCurrentKey: Oe,
360
- scrollTo: xe,
389
+ return ce({
390
+ getCurrentKey: () => I.value,
391
+ setCurrentKey: je,
392
+ scrollTo: Me,
361
393
  getCheckedKeys: () => Array.from(p.value),
362
- setCheckedKeys: ve,
363
- setChecked: (e, t) => oe(e, t),
394
+ setCheckedKeys: me,
395
+ setChecked: (e, t) => de(e, t),
364
396
  filter: (e) => {
365
- ae.value = e, x.value = new Set(q(l.data || [])), i.value = b(l.data || []), C(() => {
366
- A(), m();
397
+ !(e == null || typeof e == "string" && e.trim() === "") && l.filterNodeMethod ? (ae.value = e, x.value = new Set(P(l.data || []))) : (ae.value = null, l.defaultExpandAll ? x.value = new Set(P(l.data || [])) : l.defaultExpandedKeys && l.defaultExpandedKeys.length ? x.value = new Set(l.defaultExpandedKeys) : x.value = /* @__PURE__ */ new Set()), r.value = M(l.data || []), S(() => {
398
+ E(), w();
367
399
  });
368
400
  }
369
- }), W(D, (e) => {
370
- const t = se(e, l.data || []);
371
- t && L("current-change", t);
372
- }), (e, t) => (E(), K("div", {
401
+ }), X(I, (e) => {
402
+ const t = he(e, l.data || []);
403
+ t && B("current-change", t);
404
+ }), (e, t) => (T(), R("div", {
373
405
  ref_key: "containerRef",
374
- ref: f,
375
- class: Q(["amazing-tree", { "is-dragging": z.value }]),
376
- style: O({ height: typeof g.height == "number" ? g.height + "px" : g.height || "100%", "--vtree-bg": g.backgroundColor, "--vtree-text": g.textColor, "--vtree-hover": g.hoverColor }),
377
- onScroll: Re
406
+ ref: h,
407
+ class: ee(["amazing-tree", { "is-dragging": L.value }]),
408
+ style: q({ height: typeof v.height == "number" ? v.height + "px" : v.height || "100%", "--vtree-bg": v.backgroundColor, "--vtree-text": v.textColor, "--vtree-hover": v.hoverColor, "--vtree-row-height": typeof v.rowHeight == "number" ? v.rowHeight + "px" : v.rowHeight || "32px", "--vtree-drop-line": v.dropLineColor, "--vtree-drop-inner": v.innerDashColor }),
409
+ onScroll: $e
378
410
  }, [
379
- ze.value ? (E(), K("div", Xe, [
380
- be(e.$slots, "empty", {}, () => [
381
- Y("div", Ze, Se(g.emptyText), 1)
411
+ Le.value ? (T(), R("div", it, [
412
+ Ee(e.$slots, "empty", {}, () => [
413
+ $("div", rt, Re(v.emptyText), 1)
382
414
  ], !0)
383
- ])) : (E(), K(Ce, { key: 0 }, [
384
- Y("div", {
385
- style: O({ height: fe.value + "px", position: "relative", minWidth: "100%", width: "max-content" })
415
+ ])) : (T(), R(ze, { key: 0 }, [
416
+ $("div", {
417
+ style: q({ height: xe.value + "px", position: "relative", minWidth: "100%", width: "max-content" })
386
418
  }, [
387
- Y("div", {
388
- style: O({ height: H.value + "px" })
419
+ $("div", {
420
+ style: q({ height: F.value + "px" })
389
421
  }, null, 4),
390
- (E(!0), K(Ce, null, qe(i.value.slice(B.value, M.value), (n) => (E(), K("div", {
391
- key: n.id,
422
+ (T(!0), R(ze, null, nt(r.value.slice(N.value, z.value), (n) => (T(), R("div", {
423
+ key: n.rid,
392
424
  class: "amazing-tree-row-wrapper"
393
425
  }, [
394
- Y("div", {
395
- class: Q(["amazing-tree-row", { "is-target-inner": z.value && U.value === n.id && T.value === "inner", "is-active": D.value === n.id }]),
396
- style: O({ paddingLeft: n.level * 16 + "px", "--active-color": g.highlightColor }),
397
- onMousedown: (a) => De(n, a),
398
- onClick: (a) => Ne(n, a),
399
- onContextmenu: re((a) => _e(n, a), ["prevent"]),
426
+ $("div", {
427
+ class: ee(["amazing-tree-row", { "is-target-inner": L.value && W.value === n.rid && A.value === "inner", "is-active": I.value === n.id }]),
428
+ style: q({ paddingLeft: n.level * 16 + "px", "--active-color": v.highlightColor }),
429
+ onMousedown: (a) => Ve(n, a),
430
+ onClick: (a) => qe(n, a),
431
+ onContextmenu: te((a) => Ze(n, a), ["prevent"]),
400
432
  ref_for: !0,
401
- ref: (a) => Le(n.id, a)
433
+ ref: (a) => Fe(n.rid, a)
402
434
  }, [
403
- Y("span", {
404
- class: Q(["amazing-tree-caret-box", { "is-leaf": n.isLeaf }]),
405
- onClick: re((a) => !n.isLeaf && Te(n.id), ["stop"])
435
+ $("span", {
436
+ class: ee(["amazing-tree-caret-box", { "is-leaf": n.isLeaf }]),
437
+ onMousedown: t[0] || (t[0] = te(() => {
438
+ }, ["stop"])),
439
+ onClick: te((a) => !n.isLeaf && Ie(n.rid), ["stop"])
406
440
  }, [
407
- n.isLeaf ? ne("", !0) : (E(), K("span", {
441
+ n.isLeaf ? se("", !0) : (T(), R("span", {
408
442
  key: 0,
409
- class: Q(["amazing-tree-caret", { expanded: de(n.id) }])
443
+ class: ee(["amazing-tree-caret", { expanded: pe(n) }])
410
444
  }, null, 2))
411
- ], 10, je),
412
- g.showCheckbox ? (E(), K("input", {
445
+ ], 42, at),
446
+ v.showCheckbox ? (T(), R("input", {
413
447
  key: 0,
414
448
  class: "amazing-tree-checkbox",
415
449
  type: "checkbox",
416
- checked: Ke(n.id),
417
- indeterminate: Ee(n.id),
450
+ checked: Be(n.id),
451
+ onMousedown: t[1] || (t[1] = te(() => {
452
+ }, ["stop"])),
453
+ indeterminate: De(n.id),
418
454
  disabled: l.disabledChecked ? l.disabledChecked(n.node) : !1,
419
- onClick: re((a) => Ie(n, a), ["stop"])
420
- }, null, 8, Ge)) : ne("", !0),
421
- be(e.$slots, "default", {
455
+ onClick: te((a) => Ye(n, a), ["stop"])
456
+ }, null, 40, ot)) : se("", !0),
457
+ Ee(e.$slots, "default", {
422
458
  node: n.node,
423
459
  data: n.node,
424
460
  level: n.level,
425
- expanded: de(n.id),
461
+ expanded: pe(n),
426
462
  isLeaf: n.isLeaf
427
463
  }, () => [
428
- Y("span", Je, Se(n.node[Ae.value]), 1)
464
+ $("span", ut, Re(n.node[He.value]), 1)
429
465
  ], !0)
430
- ], 46, Qe),
431
- z.value && U.value === n.id && (T.value === "prev" || T.value === "next") ? (E(), K("div", {
466
+ ], 46, lt),
467
+ L.value && W.value === n.rid && (A.value === "prev" || A.value === "next") ? (T(), R("div", {
432
468
  key: 0,
433
- class: Q(["amazing-tree-drop-line", { "is-prev": T.value === "prev", "is-next": T.value === "next" }])
434
- }, null, 2)) : ne("", !0)
469
+ class: ee(["amazing-tree-drop-line", { "is-prev": A.value === "prev", "is-next": A.value === "next" }])
470
+ }, null, 2)) : se("", !0)
435
471
  ]))), 128)),
436
- Y("div", {
437
- style: O({ height: ue.value + "px" })
472
+ $("div", {
473
+ style: q({ height: fe.value + "px" })
438
474
  }, null, 4)
439
475
  ], 4),
440
- z.value ? (E(), K("div", {
476
+ L.value ? (T(), R("div", {
441
477
  key: 0,
442
478
  class: "amazing-tree-ghost",
443
- style: O({ top: ie.value + "px" })
444
- }, null, 4)) : ne("", !0)
479
+ style: q({ top: ve.value + "px" })
480
+ }, null, 4)) : se("", !0)
445
481
  ], 64))
446
482
  ], 38));
447
483
  }
448
- }), tt = (g, le) => {
449
- const G = g.__vccOpts || g;
450
- for (const [l, L] of le)
451
- G[l] = L;
452
- return G;
453
- }, lt = /* @__PURE__ */ tt(et, [["__scopeId", "data-v-e0a4c022"]]);
484
+ }), ct = (v, ce) => {
485
+ const ne = v.__vccOpts || v;
486
+ for (const [l, B] of ce)
487
+ ne[l] = B;
488
+ return ne;
489
+ }, ft = /* @__PURE__ */ ct(st, [["__scopeId", "data-v-602b5fc5"]]);
454
490
  export {
455
- lt as AmazingTree,
456
- lt as default
491
+ ft as AmazingTree,
492
+ ft as default
457
493
  };
@@ -1 +1 @@
1
- (function(M,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(M=typeof globalThis<"u"?globalThis:M||self,t(M.AmazingTree={},M.Vue))})(this,(function(M,t){"use strict";const he=["onMousedown","onClick","onContextmenu"],ve=["onClick"],me=["checked","indeterminate","disabled","onClick"],pe={class:"amazing-tree-label"},ge={key:1,class:"amazing-tree-empty"},ke={class:"amazing-tree-empty-inner"},D=28,ne=((p,Q)=>{const P=p.__vccOpts||p;for(const[a,A]of Q)P[a]=A;return P})(t.defineComponent({__name:"AmazingTree",props:{data:{},props:{default:()=>({value:"value",label:"label",children:"children"})},allowDrag:{},allowDrop:{},height:{default:void 0},highlightColor:{default:"#1e71ff"},backgroundColor:{default:"#1d1d24"},textColor:{default:"#c8d3de"},hoverColor:{default:"#5d90e5"},currentNodeKey:{},defaultExpandedKeys:{},defaultExpandAll:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},emptyText:{default:"暂无数据"},showCheckbox:{type:Boolean,default:!1},checkStrictly:{type:Boolean,default:!1},defaultCheckedKeys:{default:()=>[]},disabledChecked:{},filterNodeMethod:{}},emits:["node-click","node-contextmenu","node-drop","current-change","check-change"],setup(p,{expose:Q,emit:P}){const a=p,A=P,xe=t.computed(()=>a.props.value||"value"),ye=t.computed(()=>a.props.label||"label"),W=t.computed(()=>a.props.children||"children"),we=t.computed(()=>Array.isArray(a.data)?a.data.length===0:!0),k=t.ref(new Set),m=t.ref(new Set),x=t.ref(new Set),G=t.ref(null);function le(e){return k.value.has(e)}function Ce(e){k.value.has(e)?k.value.delete(e):k.value.add(e),s.value=C(a.data||[]),t.nextTick(()=>{T(),g()})}function y(e){return e[xe.value]}function b(e){const n=e[W.value];return Array.isArray(n)?n:[]}function be(e){return m.value.has(e)}function Se(e){return x.value.has(e)}function J(e,n){if(n?m.value.add(e):m.value.delete(e),x.value.delete(e),!a.checkStrictly){const l=te(e,a.data||[]);if(l){const o=[l];for(;o.length;){const r=o.pop(),c=y(r);n?m.value.add(c):m.value.delete(c),x.value.delete(c);const f=b(r);for(const u of f)o.push(u)}const i=j(e,a.data||[])||[];for(const r of i){const c=y(r),f=b(r);let u=!0,d=!1;for(const v of f){const V=y(v),ue=m.value.has(V),fe=x.value.has(V);(ue||fe)&&(d=!0),(!ue||fe)&&(u=!1)}f.length===0?(m.value.has(c),x.value.delete(c)):u?(m.value.add(c),x.value.delete(c)):d?(m.value.delete(c),x.value.add(c)):(m.value.delete(c),x.value.delete(c))}}}}function ae(e){m.value=new Set,x.value=new Set;for(const n of e||[])J(n,!0)}function Te(e,n){const l=n.target;a.disabledChecked&&a.disabledChecked(e.node)||(A("check-change",e.node,!!l.checked),J(e.id,!!l.checked))}function C(e){const n=[];function l(o,i,r){for(let c=0;c<o.length;c++){const f=o[c],u=y(f),d=b(f),v=d.length===0;n.push({id:u,node:f,parent:i,level:r,index:c,isLeaf:v}),!v&&k.value.has(u)&&l(d,f,r+1)}}if(l(e,null,0),a.filterNodeMethod&&G.value!=null){let o=function(c){const f=y(c),u=b(c);let d=!1;for(const V of u)d=o(V)||d;const v=!!a.filterNodeMethod(G.value,c);return v&&i.add(f),d&&r.add(f),v||d};const i=new Set,r=new Set;for(const c of e)o(c);return n.filter(c=>i.has(c.id)||r.has(c.id))}return n}const h=t.ref(null),B=t.ref(0),H=t.ref(0),s=t.ref([]),K=t.reactive(new Map),w=t.computed(()=>{let e=0;const n=[];for(const l of s.value){const o=K.get(l.id)||D;e+=o,n.push(e)}return n}),oe=t.computed(()=>{const e=w.value;return e.length?e[e.length-1]:0});function ce(e){let n=0,l=w.value.length-1,o=0;for(;n<=l;){const i=n+l>>1;w.value[i]!==void 0&&w.value[i]>=e?(o=i,l=i-1):n=i+1}return o}const N=t.ref(0),S=t.ref(0),I=t.ref(0),X=t.ref(0);function g(){if(H.value=h.value?.clientHeight||0,w.value.length===0||s.value.length===0){N.value=0,S.value=0,I.value=0,X.value=0;return}const e=ce(B.value);N.value=Math.max(0,e-3);const n=s.value[N.value],l=n?K.get(n.id)||D:0,i=(w.value[N.value]??0)-l;I.value=Math.max(0,i);let r=N.value;const c=B.value+H.value+3*D;for(;r<s.value.length&&(w.value[r]??0)<c;)r++;S.value=Math.min(s.value.length,r+1);const u=(w.value[S.value-1]??0)-I.value;if(u<H.value&&S.value<s.value.length){let d=S.value,v=u;for(;v<H.value&&d<s.value.length;)d++,v=(w.value[d-1]??0)-I.value;S.value=d}X.value=Math.max(0,oe.value-I.value-((w.value[S.value-1]??0)-I.value))}t.watch([B,()=>a.data,k],()=>{s.value=C(a.data||[]),t.nextTick(T),g()}),t.onMounted(()=>{s.value=C(a.data||[]),t.nextTick(T),g(),a.defaultCheckedKeys&&a.defaultCheckedKeys.length&&ae(a.defaultCheckedKeys),h.value&&(_=new ResizeObserver(()=>{H.value=h.value?.clientHeight||0,g()}),_.observe(h.value))});let _=null;t.onUnmounted(()=>{_&&(_.disconnect(),_=null)});const q=t.reactive(new Map);function ze(e,n){n?q.set(e,n):q.delete(e)}function T(){let e=!1;for(const n of s.value.slice(N.value,S.value)){const l=q.get(n.id);if(l){const o=l.offsetHeight;(!K.has(n.id)||K.get(n.id)!==o)&&(K.set(n.id,o),e=!0)}}e&&g()}function Ee(){B.value=h.value?.scrollTop||0,g()}const z=t.ref(!1),Z=t.ref(null),F=t.ref(null),E=t.ref(null),ee=t.ref(0),L=t.ref(null),Y=t.ref(0);let R=null;function U(){R!=null&&(cancelAnimationFrame(R),R=null)}function ie(){if(!z.value||Y.value===0){U();return}const e=h.value;if(!e){U();return}const n=e.scrollHeight-e.clientHeight,l=12;e.scrollTop=Math.max(0,Math.min(n,e.scrollTop+Y.value*l)),B.value=e.scrollTop,g(),R=requestAnimationFrame(ie)}function Me(){Y.value!==0&&R==null&&(R=requestAnimationFrame(ie)),Y.value===0&&U()}function $(e){if(e==null)return null;for(const n of s.value)if(n.id===e)return n;return null}function Be(e){const n=h.value.getBoundingClientRect(),l=e-n.top+B.value;return ce(l)}function Ae(e,n){!a.draggable||n.button!==0||!(!a.allowDrag||a.allowDrag(e.node))||(z.value=!0,Z.value=e.id,ee.value=n.clientY,n.preventDefault(),window.addEventListener("mousemove",re),window.addEventListener("mouseup",se))}function re(e){if(!z.value)return;ee.value=e.clientY;const n=Be(e.clientY),l=s.value[Math.min(Math.max(n,0),s.value.length-1)];if(F.value=l?.id??null,!l){E.value=null;return}const o=w.value[n]??0,i=K.get(l.id)??D,r=o-i,c=h.value.getBoundingClientRect(),u=(e.clientY-c.top+B.value-r)/i;let d="inner";u<.25?d="prev":u>.75&&(d="next");const v=$(Z.value),V=a.allowDrop?!!(v&&a.allowDrop(v.node,l.node,d)):!0;E.value=V?d:null,Y.value=e.clientY>c.bottom?1:e.clientY<c.top?-1:0,Me()}function j(e,n,l=[]){for(const o of n){if(y(o)===e)return l;const i=b(o);if(i.length){const r=j(e,i,[...l,o]);if(r)return r}}return null}function te(e,n){if(e==null)return null;for(const l of n){if(y(l)===e)return l;const o=b(l),i=te(e,o);if(i)return i}return null}function O(e){const n=[];for(const l of e){n.push(y(l));const o=b(l);o.length&&n.push(...O(o))}return n}function Ke(e){const n=e.parent;if(n)b(n).splice(e.index,1);else{const l=a.data.findIndex(o=>y(o)===e.id);l>=0&&a.data.splice(l,1)}}function Ne(e,n,l){if(l==="inner"){Array.isArray(n.node[W.value])||(n.node[W.value]=[]),n.node[W.value].push(e),k.value.add(n.id);return}const o=n.parent;if(o){const i=b(o),r=n.index+(l==="next"?1:0);i.splice(r,0,e)}else{const i=n.index+(l==="next"?1:0);a.data.splice(i,0,e)}}function se(){if(window.removeEventListener("mousemove",re),window.removeEventListener("mouseup",se),U(),!z.value)return;const e=$(Z.value),n=$(F.value),l=E.value;if(z.value=!1,E.value=null,F.value=null,!e||!n||!l||a.allowDrop&&!a.allowDrop(e.node,n.node,l)||e.id===n.id)return;const o=l==="inner"?n.node:n.parent||null;if(o){const f=j(y(o),a.data||[])||[];for(const u of f)if(y(u)===e.id)return}const i=e.node;Ke(e);const r=C(a.data||[]);s.value=r;const c=$(n.id)||n;Ne(i,c,l),s.value=C(a.data||[]),t.nextTick(()=>{T(),g()}),A("node-drop",i,c.node,l)}function Ie(e,n){L.value=e.id,A("node-click",e.node,n)}function Le(e,n){A("node-contextmenu",e.node,n)}t.watchEffect(()=>{t.nextTick(T)}),t.watch(()=>a.currentNodeKey,e=>{L.value=e??null},{immediate:!0}),t.watch(()=>a.defaultExpandedKeys,e=>{k.value=new Set(e||[]),s.value=C(a.data||[]),t.nextTick(()=>{T(),g()})},{immediate:!0}),t.watch(()=>a.defaultExpandAll,e=>{e&&(k.value=new Set(O(a.data||[])),s.value=C(a.data||[]),t.nextTick(()=>{T(),g()}))},{immediate:!0}),t.watch(()=>a.data,()=>{a.defaultExpandAll&&(k.value=new Set(O(a.data||[]))),s.value=C(a.data||[]),t.nextTick(()=>{T(),g()});const e=new Set(O(a.data||[]));m.value=new Set([...m.value].filter(n=>e.has(n))),x.value=new Set([...x.value].filter(n=>e.has(n)))},{deep:!0});function Re(e){const n=j(e,a.data||[])||[];for(const l of n)k.value.add(y(l));s.value=C(a.data||[])}function de(e){e!=null&&(Re(e),t.nextTick(()=>{const n=s.value.findIndex(c=>c.id===e);if(n<0||!h.value)return;const l=K.get(e)||D,o=(w.value[n]??0)-l,i=h.value.clientHeight,r=Math.max(0,o-Math.max(0,(i-l)/2));h.value.scrollTop=r,B.value=r,g(),t.nextTick(()=>{const c=q.get(e);if(!c||!h.value)return;const f=c.offsetLeft,u=c.offsetWidth,d=h.value.clientWidth,v=Math.max(0,f+Math.max(0,u/2)-Math.max(0,d/2));h.value.scrollLeft=v})}))}function Ve(e){L.value=e??null,de(L.value)}return Q({getCurrentKey:()=>L.value,setCurrentKey:Ve,scrollTo:de,getCheckedKeys:()=>Array.from(m.value),setCheckedKeys:ae,setChecked:(e,n)=>J(e,n),filter:e=>{G.value=e,k.value=new Set(O(a.data||[])),s.value=C(a.data||[]),t.nextTick(()=>{T(),g()})}}),t.watch(L,e=>{const n=te(e,a.data||[]);n&&A("current-change",n)}),(e,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"containerRef",ref:h,class:t.normalizeClass(["amazing-tree",{"is-dragging":z.value}]),style:t.normalizeStyle({height:typeof p.height=="number"?p.height+"px":p.height||"100%","--vtree-bg":p.backgroundColor,"--vtree-text":p.textColor,"--vtree-hover":p.hoverColor}),onScroll:Ee},[we.value?(t.openBlock(),t.createElementBlock("div",ge,[t.renderSlot(e.$slots,"empty",{},()=>[t.createElementVNode("div",ke,t.toDisplayString(p.emptyText),1)],!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("div",{style:t.normalizeStyle({height:oe.value+"px",position:"relative",minWidth:"100%",width:"max-content"})},[t.createElementVNode("div",{style:t.normalizeStyle({height:I.value+"px"})},null,4),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.value.slice(N.value,S.value),l=>(t.openBlock(),t.createElementBlock("div",{key:l.id,class:"amazing-tree-row-wrapper"},[t.createElementVNode("div",{class:t.normalizeClass(["amazing-tree-row",{"is-target-inner":z.value&&F.value===l.id&&E.value==="inner","is-active":L.value===l.id}]),style:t.normalizeStyle({paddingLeft:l.level*16+"px","--active-color":p.highlightColor}),onMousedown:o=>Ae(l,o),onClick:o=>Ie(l,o),onContextmenu:t.withModifiers(o=>Le(l,o),["prevent"]),ref_for:!0,ref:o=>ze(l.id,o)},[t.createElementVNode("span",{class:t.normalizeClass(["amazing-tree-caret-box",{"is-leaf":l.isLeaf}]),onClick:t.withModifiers(o=>!l.isLeaf&&Ce(l.id),["stop"])},[l.isLeaf?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["amazing-tree-caret",{expanded:le(l.id)}])},null,2))],10,ve),p.showCheckbox?(t.openBlock(),t.createElementBlock("input",{key:0,class:"amazing-tree-checkbox",type:"checkbox",checked:be(l.id),indeterminate:Se(l.id),disabled:a.disabledChecked?a.disabledChecked(l.node):!1,onClick:t.withModifiers(o=>Te(l,o),["stop"])},null,8,me)):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"default",{node:l.node,data:l.node,level:l.level,expanded:le(l.id),isLeaf:l.isLeaf},()=>[t.createElementVNode("span",pe,t.toDisplayString(l.node[ye.value]),1)],!0)],46,he),z.value&&F.value===l.id&&(E.value==="prev"||E.value==="next")?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["amazing-tree-drop-line",{"is-prev":E.value==="prev","is-next":E.value==="next"}])},null,2)):t.createCommentVNode("",!0)]))),128)),t.createElementVNode("div",{style:t.normalizeStyle({height:X.value+"px"})},null,4)],4),z.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"amazing-tree-ghost",style:t.normalizeStyle({top:ee.value+"px"})},null,4)):t.createCommentVNode("",!0)],64))],38))}}),[["__scopeId","data-v-e0a4c022"]]);M.AmazingTree=ne,M.default=ne,Object.defineProperties(M,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(B,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(B=typeof globalThis<"u"?globalThis:B||self,t(B.AmazingTree={},B.Vue))})(this,(function(B,t){"use strict";const we=["onMousedown","onClick","onContextmenu"],ye=["onClick"],ke=["checked","indeterminate","disabled","onClick"],Ce={class:"amazing-tree-label"},be={key:1,class:"amazing-tree-empty"},Se={class:"amazing-tree-empty-inner"},ie=((h,te)=>{const j=h.__vccOpts||h;for(const[a,N]of te)j[a]=N;return j})(t.defineComponent({__name:"AmazingTree",props:{data:{},props:{default:()=>({value:"value",label:"label",children:"children"})},allowDrag:{},allowDrop:{},height:{default:void 0},rowHeight:{default:32},dropLineColor:{default:"#ffd400"},innerDashColor:{default:"#ffd400"},siblingZoneRatio:{default:.35},dragStartThreshold:{default:4},highlightColor:{default:"#1e71ff"},backgroundColor:{default:"#1d1d24"},textColor:{default:"#c8d3de"},hoverColor:{default:"#5d90e5"},currentNodeKey:{},defaultExpandedKeys:{},defaultExpandAll:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},emptyText:{default:"暂无数据"},showCheckbox:{type:Boolean,default:!1},checkStrictly:{type:Boolean,default:!1},defaultCheckedKeys:{default:()=>[]},disabledChecked:{},filterNodeMethod:{}},emits:["node-click","node-contextmenu","node-drop","current-change","check-change"],setup(h,{expose:te,emit:j}){const a=h,N=j,Me=t.computed(()=>a.props.value||"value"),Te=t.computed(()=>a.props.label||"label"),Z=t.computed(()=>a.props.children||"children"),Ee=t.computed(()=>Array.isArray(a.data)?a.data.length===0:!0),H=t.ref(new Set),x=t.ref(new Set),p=t.ref(new Set),y=t.ref(new Set),Q=t.ref(null);function ce(e){return H.value.has(e.rid)||x.value.has(e.id)}function ze(e){const n=_(e);if(!n)return;const l=n.id;H.value.has(e)||x.value.has(l)?(H.value.delete(e),x.value.delete(l)):H.value.add(e),s.value=S(a.data||[]),t.nextTick(()=>{z(),w()})}function k(e){return e[Me.value]}function T(e){const n=e[Z.value];return Array.isArray(n)?n:[]}function Be(e){return p.value.has(e)}function Ae(e){return y.value.has(e)}function ne(e,n){if(n?p.value.add(e):p.value.delete(e),y.value.delete(e),!a.checkStrictly){const l=oe(e,a.data||[]);if(l){const o=[l];for(;o.length;){const c=o.pop(),r=k(c);n?p.value.add(r):p.value.delete(r),y.value.delete(r);const d=T(c);for(const u of d)o.push(u)}const i=ee(e,a.data||[])||[];for(const c of i){const r=k(c),d=T(c);let u=!0,f=!1;for(const m of d){const g=k(m),b=p.value.has(g),$=y.value.has(g);(b||$)&&(f=!0),(!b||$)&&(u=!1)}d.length===0?(p.value.has(r),y.value.delete(r)):u?(p.value.add(r),y.value.delete(r)):f?(p.value.delete(r),y.value.add(r)):(p.value.delete(r),y.value.delete(r))}}}}function se(e){p.value=new Set,y.value=new Set;for(const n of e||[])ne(n,!0)}function Ke(e,n){const l=n.target;a.disabledChecked&&a.disabledChecked(e.node)||(N("check-change",e.node,!!l.checked),ne(e.id,!!l.checked))}function S(e){const n=[];function l(o,i,c,r){for(let d=0;d<o.length;d++){const u=o[d],f=k(u),m=T(u),g=m.length===0,b=r?`${r}/${d}`:`${d}`,$={rid:b,id:f,node:u,parent:i,level:c,index:d,isLeaf:g};n.push($);const re=H.value.has(b)||x.value.has(f);!g&&re&&l(m,u,c+1,b)}}if(l(e,null,0,""),a.filterNodeMethod&&Q.value!=null){let o=function(r){const d=k(r),u=T(r);let f=!1;for(const g of u)f=o(g)||f;const m=!!a.filterNodeMethod(Q.value,r);return m&&i.add(d),f&&c.add(d),m||f};const i=new Set,c=new Set;for(const r of e)o(r);return n.filter(r=>i.has(r.id)||c.has(r.id))}return n}const v=t.ref(null),A=t.ref(0),O=t.ref(0),s=t.ref([]),L=t.reactive(new Map);function Re(e){if(typeof e=="number")return e;if(typeof e=="string"){const n=e.match(/(\d+(\.\d+)?)/);return n?Number(n[1]):32}return 32}const P=Re(a.rowHeight),C=t.computed(()=>{let e=0;const n=[];for(const l of s.value){const o=L.get(l.rid)||P;e+=o,n.push(e)}return n}),de=t.computed(()=>{const e=C.value;return e.length?e[e.length-1]:0});function ue(e){let n=0,l=C.value.length-1,o=0;for(;n<=l;){const i=n+l>>1;C.value[i]!==void 0&&C.value[i]>=e?(o=i,l=i-1):n=i+1}return o}const I=t.ref(0),E=t.ref(0),D=t.ref(0),le=t.ref(0);function w(){if(O.value=v.value?.clientHeight||0,C.value.length===0||s.value.length===0){I.value=0,E.value=0,D.value=0,le.value=0;return}const e=ue(A.value);I.value=Math.max(0,e-3);const n=s.value[I.value],l=n?L.get(n.rid)||P:0,i=(C.value[I.value]??0)-l;D.value=Math.max(0,i);let c=I.value;const r=A.value+O.value+3*P;for(;c<s.value.length&&(C.value[c]??0)<r;)c++;E.value=Math.min(s.value.length,c+1);const u=(C.value[E.value-1]??0)-D.value;if(u<O.value&&E.value<s.value.length){let f=E.value,m=u;for(;m<O.value&&f<s.value.length;)f++,m=(C.value[f-1]??0)-D.value;E.value=f}le.value=Math.max(0,de.value-D.value-((C.value[E.value-1]??0)-D.value))}t.watch([A,()=>a.data,H,x],()=>{s.value=S(a.data||[]),t.nextTick(z),w()}),t.onMounted(()=>{s.value=S(a.data||[]),t.nextTick(z),w(),a.defaultCheckedKeys&&a.defaultCheckedKeys.length&&se(a.defaultCheckedKeys),v.value&&(W=new ResizeObserver(()=>{O.value=v.value?.clientHeight||0,w()}),W.observe(v.value))});let W=null;t.onUnmounted(()=>{W&&(W.disconnect(),W=null)});const G=t.reactive(new Map);function Ne(e,n){n?G.set(e,n):G.delete(e)}function z(){let e=!1;for(const n of s.value.slice(I.value,E.value)){const l=G.get(n.rid);if(l){const o=l.offsetHeight;(!L.has(n.rid)||L.get(n.rid)!==o)&&(L.set(n.rid,o),e=!0)}}e&&w()}function He(){A.value=v.value?.scrollTop||0,w()}const K=t.ref(!1),q=t.ref(null),V=t.ref(null),M=t.ref(null),ae=t.ref(0),U=t.ref(!1),fe=t.ref(0),he=t.ref(0),R=t.ref(null),X=t.ref(0);let Y=null;function J(){Y!=null&&(cancelAnimationFrame(Y),Y=null)}function ve(){if(!K.value||X.value===0){J();return}const e=v.value;if(!e){J();return}const n=e.scrollHeight-e.clientHeight,l=12;e.scrollTop=Math.max(0,Math.min(n,e.scrollTop+X.value*l)),A.value=e.scrollTop,w(),Y=requestAnimationFrame(ve)}function Le(){X.value!==0&&Y==null&&(Y=requestAnimationFrame(ve)),X.value===0&&J()}function Ie(e){if(e==null)return null;for(const n of s.value)if(n.id===e)return n;return null}function _(e){if(e==null)return null;for(const n of s.value)if(n.rid===e)return n;return null}function De(e){const n=v.value.getBoundingClientRect(),l=e-n.top+A.value;return ue(l)}function Ve(e,n){!a.draggable||n.button!==0||!(!a.allowDrag||a.allowDrag(e.node))||(q.value=e.rid,ae.value=n.clientY,fe.value=n.clientX,he.value=n.clientY,U.value=!1,n.preventDefault(),window.addEventListener("mousemove",me),window.addEventListener("mouseup",pe))}function me(e){if(q.value==null)return;if(!U.value){const re=Math.abs(e.clientX-fe.value),qe=Math.abs(e.clientY-he.value),xe=Math.max(1,a.dragStartThreshold??4);if(re<xe&&qe<xe)return;U.value=!0,K.value=!0}ae.value=e.clientY;const n=De(e.clientY),l=s.value[Math.min(Math.max(n,0),s.value.length-1)];if(V.value=l?.rid??null,!l){M.value=null;return}const o=C.value[n]??0,i=L.get(l.rid)??P,c=o-i,r=v.value.getBoundingClientRect(),u=(e.clientY-r.top+A.value-c)/i,f=a.siblingZoneRatio??.35,m=Math.max(.05,Math.min(.49,f));let g="inner";u<m?g="prev":u>1-m&&(g="next");const b=_(q.value),$=a.allowDrop?!!(b&&a.allowDrop(b.node,l.node,g)):!0;M.value=$?g:null,X.value=e.clientY>r.bottom?1:e.clientY<r.top?-1:0,Le()}function ee(e,n,l=[]){for(const o of n){if(k(o)===e)return l;const i=T(o);if(i.length){const c=ee(e,i,[...l,o]);if(c)return c}}return null}function oe(e,n){if(e==null)return null;for(const l of n){if(k(l)===e)return l;const o=T(l),i=oe(e,o);if(i)return i}return null}function F(e){const n=[];for(const l of e){n.push(k(l));const o=T(l);o.length&&n.push(...F(o))}return n}function Ye(e){const n=e.parent;if(n)T(n).splice(e.index,1);else{const l=a.data.findIndex(o=>k(o)===e.id);l>=0&&a.data.splice(l,1)}}function Fe(e,n,l){if(l==="inner"){Array.isArray(n.node[Z.value])||(n.node[Z.value]=[]),n.node[Z.value].push(e),H.value.add(n.rid);return}const o=n.parent;if(o){const i=T(o),c=n.index+(l==="next"?1:0);i.splice(c,0,e)}else{const i=n.index+(l==="next"?1:0);a.data.splice(i,0,e)}}function pe(){if(window.removeEventListener("mousemove",me),window.removeEventListener("mouseup",pe),J(),!K.value){q.value=null,M.value=null,V.value=null,U.value=!1;return}const e=_(q.value),n=_(V.value),l=M.value;if(K.value=!1,U.value=!1,M.value=null,V.value=null,!e||!n||!l||a.allowDrop&&!a.allowDrop(e.node,n.node,l)||e.id===n.id)return;const o=l==="inner"?n.node:n.parent||null;if(o){const d=ee(k(o),a.data||[])||[];for(const u of d)if(k(u)===e.id)return}const i=e.node;Ye(e);const c=S(a.data||[]);s.value=c;const r=Ie(n.id)||n;Fe(i,r,l),s.value=S(a.data||[]),t.nextTick(()=>{z(),w()}),N("node-drop",i,r.node,l)}function $e(e,n){R.value=e.id,N("node-click",e.node,n)}function Oe(e,n){R.value=e.id,N("node-contextmenu",e.node,n)}t.watchEffect(()=>{t.nextTick(z)}),t.watch(()=>a.currentNodeKey,e=>{R.value=e??null},{immediate:!0}),t.watch(()=>a.defaultExpandedKeys,e=>{x.value=new Set(e||[]),s.value=S(a.data||[]),t.nextTick(()=>{z(),w()})},{immediate:!0}),t.watch(()=>a.defaultExpandAll,e=>{e&&(x.value=new Set(F(a.data||[])),s.value=S(a.data||[]),t.nextTick(()=>{z(),w()}))},{immediate:!0}),t.watch(()=>a.data,()=>{a.defaultExpandAll&&(x.value=new Set(F(a.data||[]))),s.value=S(a.data||[]),t.nextTick(()=>{z(),w()});const e=new Set(F(a.data||[]));p.value=new Set([...p.value].filter(n=>e.has(n))),y.value=new Set([...y.value].filter(n=>e.has(n)))},{deep:!0});function Pe(e){const n=ee(e,a.data||[])||[];for(const l of n)x.value.add(k(l));s.value=S(a.data||[])}function ge(e){e!=null&&(Pe(e),t.nextTick(()=>{const n=s.value.findIndex(d=>d.id===e);if(n<0||!v.value)return;const l=s.value[n]?.rid,o=(l?L.get(l):void 0)||P,i=(C.value[n]??0)-o,c=v.value.clientHeight,r=Math.max(0,i-Math.max(0,(c-o)/2));v.value.scrollTop=r,A.value=r,w(),t.nextTick(()=>{const d=l||null,u=d?G.get(d):null;if(!u||!v.value)return;const f=u.offsetLeft,m=u.offsetWidth,g=v.value.clientWidth,b=Math.max(0,f+Math.max(0,m/2)-Math.max(0,g/2));v.value.scrollLeft=b})}))}function We(e){R.value=e??null,ge(R.value)}return te({getCurrentKey:()=>R.value,setCurrentKey:We,scrollTo:ge,getCheckedKeys:()=>Array.from(p.value),setCheckedKeys:se,setChecked:(e,n)=>ne(e,n),filter:e=>{!(e==null||typeof e=="string"&&e.trim()==="")&&a.filterNodeMethod?(Q.value=e,x.value=new Set(F(a.data||[]))):(Q.value=null,a.defaultExpandAll?x.value=new Set(F(a.data||[])):a.defaultExpandedKeys&&a.defaultExpandedKeys.length?x.value=new Set(a.defaultExpandedKeys):x.value=new Set),s.value=S(a.data||[]),t.nextTick(()=>{z(),w()})}}),t.watch(R,e=>{const n=oe(e,a.data||[]);n&&N("current-change",n)}),(e,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"containerRef",ref:v,class:t.normalizeClass(["amazing-tree",{"is-dragging":K.value}]),style:t.normalizeStyle({height:typeof h.height=="number"?h.height+"px":h.height||"100%","--vtree-bg":h.backgroundColor,"--vtree-text":h.textColor,"--vtree-hover":h.hoverColor,"--vtree-row-height":typeof h.rowHeight=="number"?h.rowHeight+"px":h.rowHeight||"32px","--vtree-drop-line":h.dropLineColor,"--vtree-drop-inner":h.innerDashColor}),onScroll:He},[Ee.value?(t.openBlock(),t.createElementBlock("div",be,[t.renderSlot(e.$slots,"empty",{},()=>[t.createElementVNode("div",Se,t.toDisplayString(h.emptyText),1)],!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("div",{style:t.normalizeStyle({height:de.value+"px",position:"relative",minWidth:"100%",width:"max-content"})},[t.createElementVNode("div",{style:t.normalizeStyle({height:D.value+"px"})},null,4),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.value.slice(I.value,E.value),l=>(t.openBlock(),t.createElementBlock("div",{key:l.rid,class:"amazing-tree-row-wrapper"},[t.createElementVNode("div",{class:t.normalizeClass(["amazing-tree-row",{"is-target-inner":K.value&&V.value===l.rid&&M.value==="inner","is-active":R.value===l.id}]),style:t.normalizeStyle({paddingLeft:l.level*16+"px","--active-color":h.highlightColor}),onMousedown:o=>Ve(l,o),onClick:o=>$e(l,o),onContextmenu:t.withModifiers(o=>Oe(l,o),["prevent"]),ref_for:!0,ref:o=>Ne(l.rid,o)},[t.createElementVNode("span",{class:t.normalizeClass(["amazing-tree-caret-box",{"is-leaf":l.isLeaf}]),onMousedown:n[0]||(n[0]=t.withModifiers(()=>{},["stop"])),onClick:t.withModifiers(o=>!l.isLeaf&&ze(l.rid),["stop"])},[l.isLeaf?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["amazing-tree-caret",{expanded:ce(l)}])},null,2))],42,ye),h.showCheckbox?(t.openBlock(),t.createElementBlock("input",{key:0,class:"amazing-tree-checkbox",type:"checkbox",checked:Be(l.id),onMousedown:n[1]||(n[1]=t.withModifiers(()=>{},["stop"])),indeterminate:Ae(l.id),disabled:a.disabledChecked?a.disabledChecked(l.node):!1,onClick:t.withModifiers(o=>Ke(l,o),["stop"])},null,40,ke)):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"default",{node:l.node,data:l.node,level:l.level,expanded:ce(l),isLeaf:l.isLeaf},()=>[t.createElementVNode("span",Ce,t.toDisplayString(l.node[Te.value]),1)],!0)],46,we),K.value&&V.value===l.rid&&(M.value==="prev"||M.value==="next")?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["amazing-tree-drop-line",{"is-prev":M.value==="prev","is-next":M.value==="next"}])},null,2)):t.createCommentVNode("",!0)]))),128)),t.createElementVNode("div",{style:t.normalizeStyle({height:le.value+"px"})},null,4)],4),K.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"amazing-tree-ghost",style:t.normalizeStyle({top:ae.value+"px"})},null,4)):t.createCommentVNode("",!0)],64))],38))}}),[["__scopeId","data-v-602b5fc5"]]);B.AmazingTree=ie,B.default=ie,Object.defineProperties(B,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "amazing-tree",
3
- "version": "1.3.0",
3
+ "version": "1.3.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": "^20.19.0 || >=22.12.0"
8
8
  },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/FE-kang/amazingTree"
12
+ },
9
13
  "scripts": {
10
14
  "dev": "vite",
11
15
  "build": "run-p type-check \"build-only {@}\" --",