2 lines
8.7 KiB
JavaScript
2 lines
8.7 KiB
JavaScript
import{x as w,e as C,E as z,a0 as te,Q as de,G as ae,r as g,c as b,P as ce,ah as re,m as K,V as Z,D as O,B as le,X as M,_ as q,H as Q,ae as ue,Y as se,$ as fe,cL as ve,cZ as ye,c_ as he}from"./index.ab0d47a4.js";import{r as pe,T as xe,t as Ke,f as ee,g as ke,c as me,h as be,V as Ne,i as Ee}from"./iconUtil.60568eec.js";import{w as _e}from"./useFlexGapSupport.f5eec5c4.js";var ne=4;function ge(t){var e,u=t.dropPosition,l=t.dropLevelOffset,o=t.prefixCls,d=t.indent,h=t.direction,p=h===void 0?"ltr":h,c=p==="ltr"?"left":"right",N=p==="ltr"?"right":"left",s=(e={},w(e,c,"".concat(-l*d+ne,"px")),w(e,N,0),e);switch(u){case-1:s.top="".concat(-3,"px");break;case 1:s.bottom="".concat(-3,"px");break;default:s.bottom="".concat(-3,"px"),s[c]="".concat(d+ne,"px");break}return C("div",{style:s,class:"".concat(o,"-drop-indicator")},null)}var oe=function(){var e=Ke();return K(K({},e),{showLine:{type:[Boolean,Object],default:void 0},multiple:{type:Boolean,default:void 0},autoExpandParent:{type:Boolean,default:void 0},checkStrictly:{type:Boolean,default:void 0},checkable:{type:Boolean,default:void 0},disabled:{type:Boolean,default:void 0},defaultExpandAll:{type:Boolean,default:void 0},defaultExpandParent:{type:Boolean,default:void 0},defaultExpandedKeys:{type:Array},expandedKeys:{type:Array},checkedKeys:{type:[Array,Object]},defaultCheckedKeys:{type:Array},selectedKeys:{type:Array},defaultSelectedKeys:{type:Array},selectable:{type:Boolean,default:void 0},loadedKeys:{type:Array},draggable:{type:Boolean,default:void 0},showIcon:{type:Boolean,default:void 0},icon:{type:Function},switcherIcon:M.any,prefixCls:String,replaceFields:{type:Object},blockNode:{type:Boolean,default:void 0},openAnimation:M.any,onDoubleclick:e.onDblclick,"onUpdate:selectedKeys":Function,"onUpdate:checkedKeys":Function,"onUpdate:expandedKeys":Function})};const j=z({name:"ATree",inheritAttrs:!1,props:te(oe(),{checkable:!1,selectable:!0,showIcon:!1,blockNode:!1}),slots:["icon","title","switcherIcon","titleRender"],setup:function(e,u){var l=u.attrs,o=u.expose,d=u.emit,h=u.slots;de(!(e.treeData===void 0&&h.default));var p=ae("tree",e),c=p.prefixCls,N=p.direction,s=p.virtual,f=g(),U=function(x){var y;(y=f.value)===null||y===void 0||y.scrollTo(x)};o({treeRef:f,onNodeExpand:function(){var x,y;(y=f.value)===null||y===void 0||(x=y).onNodeExpand.apply(x,arguments)},scrollTo:U,selectedKeys:b(function(){var a;return(a=f.value)===null||a===void 0?void 0:a.selectedKeys}),checkedKeys:b(function(){var a;return(a=f.value)===null||a===void 0?void 0:a.checkedKeys}),halfCheckedKeys:b(function(){var a;return(a=f.value)===null||a===void 0?void 0:a.halfCheckedKeys}),loadedKeys:b(function(){var a;return(a=f.value)===null||a===void 0?void 0:a.loadedKeys}),loadingKeys:b(function(){var a;return(a=f.value)===null||a===void 0?void 0:a.loadingKeys}),expandedKeys:b(function(){var a;return(a=f.value)===null||a===void 0?void 0:a.expandedKeys})}),ce(function(){re(e.replaceFields===void 0,"Tree","`replaceFields` is deprecated, please use fieldNames instead")});var I=function(x,y){d("update:checkedKeys",x),d("check",x,y)},D=function(x,y){d("update:expandedKeys",x),d("expand",x,y)},H=function(x,y){d("update:selectedKeys",x),d("select",x,y)};return function(){var a,x=e.showIcon,y=e.showLine,B=e.switcherIcon,_=B===void 0?h.switcherIcon:B,F=e.icon,R=F===void 0?h.icon:F,$=e.blockNode,S=e.checkable,L=e.selectable,n=e.fieldNames,i=n===void 0?e.replaceFields:n,r=e.motion,v=r===void 0?e.openAnimation:r,T=e.itemHeight,k=T===void 0?28:T,P=e.onDoubleclick,A=e.onDblclick,V=K(K(K({},l),_e(e,["onUpdate:checkedKeys","onUpdate:expandedKeys","onUpdate:selectedKeys","onDoubleclick"])),{showLine:Boolean(y),dropIndicatorRender:ge,fieldNames:i,icon:R,itemHeight:k}),G=h.default?Z(h.default()):void 0;return C(xe,O(O({},V),{},{virtual:s.value,motion:v,ref:f,prefixCls:c.value,class:le((a={},w(a,"".concat(c.value,"-icon-hide"),!x),w(a,"".concat(c.value,"-block-node"),$),w(a,"".concat(c.value,"-unselectable"),!L),w(a,"".concat(c.value,"-rtl"),N.value==="rtl"),a),l.class),direction:N.value,checkable:S,selectable:L,switcherIcon:function(ie){return pe(c.value,_,y,ie)},onCheck:I,onExpand:D,onSelect:H,onDblclick:A||P,children:G}),K(K({},h),{checkable:function(){return C("span",{class:"".concat(c.value,"-checkbox-inner")},null)}}))}}});var E;(function(t){t[t.None=0]="None",t[t.Start=1]="Start",t[t.End=2]="End"})(E||(E={}));function J(t,e,u){function l(o){var d=o[e.key],h=o[e.children];u(d,o)!==!1&&J(h||[],e,u)}t.forEach(l)}function we(t){var e=t.treeData,u=t.expandedKeys,l=t.startKey,o=t.endKey,d=t.fieldNames,h=d===void 0?{title:"title",key:"key",children:"children"}:d,p=[],c=E.None;if(l&&l===o)return[l];if(!l||!o)return[];function N(s){return s===l||s===o}return J(e,h,function(s){if(c===E.End)return!1;if(N(s)){if(p.push(s),c===E.None)c=E.Start;else if(c===E.Start)return c=E.End,!1}else c===E.Start&&p.push(s);return u.indexOf(s)!==-1}),p}function W(t,e,u){var l=q(e),o=[];return J(t,u,function(d,h){var p=l.indexOf(d);return p!==-1&&(o.push(h),l.splice(p,1)),!!l.length}),o}var Ce=globalThis&&globalThis.__rest||function(t,e){var u={};for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&e.indexOf(l)<0&&(u[l]=t[l]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,l=Object.getOwnPropertySymbols(t);o<l.length;o++)e.indexOf(l[o])<0&&Object.prototype.propertyIsEnumerable.call(t,l[o])&&(u[l[o]]=t[l[o]]);return u},De=function(){return K(K({},oe()),{expandAction:{type:[Boolean,String]}})};function Te(t){var e=t.isLeaf,u=t.expanded;return e?C(ve,null,null):u?C(ye,null,null):C(he,null,null)}const X=z({name:"ADirectoryTree",inheritAttrs:!1,props:te(De(),{showIcon:!0,expandAction:"click"}),slots:["icon","title","switcherIcon","titleRender"],setup:function(e,u){var l=u.attrs,o=u.slots,d=u.emit,h=u.expose,p,c=g(e.treeData||ee(Z((p=o.default)===null||p===void 0?void 0:p.call(o))));Q(function(){return e.treeData},function(){c.value=e.treeData}),ue(function(){se(function(){var n;e.treeData===void 0&&o.default&&(c.value=ee(Z((n=o.default)===null||n===void 0?void 0:n.call(o))))})});var N=g(),s=g(),f=g();h({selectedKeys:b(function(){var n;return(n=f.value)===null||n===void 0?void 0:n.selectedKeys}),checkedKeys:b(function(){var n;return(n=f.value)===null||n===void 0?void 0:n.checkedKeys}),halfCheckedKeys:b(function(){var n;return(n=f.value)===null||n===void 0?void 0:n.halfCheckedKeys}),loadedKeys:b(function(){var n;return(n=f.value)===null||n===void 0?void 0:n.loadedKeys}),loadingKeys:b(function(){var n;return(n=f.value)===null||n===void 0?void 0:n.loadingKeys}),expandedKeys:b(function(){var n;return(n=f.value)===null||n===void 0?void 0:n.expandedKeys})});var U=function(){var i=me(c.value),r=i.keyEntities,v;return e.defaultExpandAll?v=Object.keys(r):e.defaultExpandParent?v=be(e.expandedKeys||e.defaultExpandedKeys||[],r):v=e.expandedKeys||e.defaultExpandedKeys,v},I=g(e.selectedKeys||e.defaultSelectedKeys||[]),D=g(U());Q(function(){return e.selectedKeys},function(){e.selectedKeys!==void 0&&(I.value=e.selectedKeys)},{immediate:!0}),Q(function(){return e.expandedKeys},function(){e.expandedKeys!==void 0&&(D.value=e.expandedKeys)},{immediate:!0});var H=function(i,r){var v=r.isLeaf;v||i.shiftKey||i.metaKey||i.ctrlKey||f.value.onNodeExpand(i,r)},a=fe(H,200,{leading:!0}),x=function(i,r){e.expandedKeys===void 0&&(D.value=i),d("update:expandedKeys",i),d("expand",i,r)},y=function(i,r){var v=e.expandAction;v==="click"&&a(i,r),d("click",i,r)},B=function(i,r){var v=e.expandAction;(v==="dblclick"||v==="doubleclick")&&a(i,r),d("doubleclick",i,r),d("dblclick",i,r)},_=b(function(){return ke(e.fieldNames)}),F=function(i,r){var v=e.multiple,T=r.node,k=r.nativeEvent,P=T[_.value.key],A=K(K({},r),{selected:!0}),V=(k==null?void 0:k.ctrlKey)||(k==null?void 0:k.metaKey),G=k==null?void 0:k.shiftKey,m;v&&V?(m=i,N.value=P,s.value=m,A.selectedNodes=W(c.value,m,_.value)):v&&G?(m=Array.from(new Set([].concat(q(s.value||[]),q(we({treeData:c.value,expandedKeys:D.value,startKey:P,endKey:N.value,fieldNames:_.value}))))),A.selectedNodes=W(c.value,m,_.value)):(m=[P],N.value=P,s.value=m,A.selectedNodes=W(c.value,m,_.value)),d("update:selectedKeys",m),d("select",m,A),e.selectedKeys===void 0&&(I.value=m)},R=function(i,r){d("update:checkedKeys",i),d("check",i,r)},$=ae("tree",e),S=$.prefixCls,L=$.direction;return function(){var n=le("".concat(S.value,"-directory"),w({},"".concat(S.value,"-directory-rtl"),L.value==="rtl"),l.class),i=e.icon,r=i===void 0?o.icon:i,v=e.blockNode,T=v===void 0?!0:v,k=Ce(e,["icon","blockNode"]);return C(j,O(O(O({},l),{},{icon:r||Te,ref:f,blockNode:T},k),{},{prefixCls:S.value,class:n,expandedKeys:D.value,selectedKeys:I.value,onSelect:F,onClick:y,onDblclick:B,onExpand:x,onCheck:R}),o)}}});var Y=z(K(K({},Ne),{name:"ATreeNode",props:Ee}));const Se=K(j,{DirectoryTree:X,TreeNode:Y,install:function(e){return e.component(j.name,j),e.component(Y.name,Y),e.component(X.name,X),e}});export{Se as _};
|