2 lines
5.0 KiB
Java
2 lines
5.0 KiB
Java
import{e as Ne,a4 as ke,c as l,r as B,h as A,K as Ce,C as h,z as f,F as z,D as J,y as D,A as K,f as L,Q as O,H as Me,G as Se,R as _,T as Be,J as ze,u as De,b as U,n as w}from"./vue-vendor-DNhG1Cve.js";import{o as I,n as _e}from"./index-Crt100Db-CDbHzweT.js";import Ie from"./NodeIcon-BiVm3xLp-DYMLCJV5.js";import{bo as Te,T as Ve,aE as Ge,b9 as He}from"./index-X7Y8jykP.js";import Ee from"./index-saD4h7VJ.js";import"./emoji-mart-vue-fast-R0uJEDq-.js";var T=(N,k,u)=>new Promise((C,y)=>{var p=r=>{try{s(u.next(r))}catch(m){y(m)}},v=r=>{try{s(u.throw(r))}catch(m){y(m)}},s=r=>r.done?C(r.value):Promise.resolve(r.value).then(p,v);s((u=u.apply(N,k)).next())});const Pe={class:"airag-node-label"},Re=["href"],X=2,Fe=12,Y=10,Qe=9,Ue=Ne({__name:"AddNodeDrawer",props:{visible:{type:Boolean,default:!1},payload:Object,triggerNodeId:String,isShow:Function,columnSize:{type:Number,default:8},columnGap:{type:Number,default:12},columnWidth:{type:Number,default:160},nodeItemHeight:{type:Number,default:38},nodeMarginTop:{type:Number,default:6},nodePadding:{type:Number,default:8}},emits:["add"],setup(N,{emit:k}){ke(e=>({v40b92f9d:re.value,v86c46ba0:se.value,v117e8991:de.value,v429a2c30:pe.value,v77322428:ce.value,v4868c4e4:ye.value,v2abd7af4:ge.value,v3af8838c:be.value,v0ea33c5c:xe.value,v02f5e750:fe.value,ac5b06fe:ve.value,v3093bbf7:he.value,f10649a6:me.value}));const u=N,C=k,{prefixCls:y}=Te("airag-add-node-drawer"),p=B(u.visible),v=B(!0),s=B([]),r=l(()=>Math.max(1,Number(u.columnSize)||10)),m=l(()=>Math.max(4,Number(u.columnGap)||12)),V=l(()=>Math.max(120,Number(u.columnWidth)||150)),G=l(()=>Math.max(28,Number(u.nodeItemHeight)||38)),H=l(()=>Math.max(2,Number(u.nodeMarginTop)||6)),Z=l(()=>Math.max(4,Number(u.nodePadding)||8)),$=typeof u.isShow=="function"?u.isShow:I.isShow;A(()=>u.visible,e=>e?q():ee()),A(()=>u.triggerNodeId,te);function q(){return T(this,null,function*(){var e,t;F(),yield w(),v.value=!1,P(),yield w(),(e=u.payload)!=null&&e.isDragend||(v.value=!0),E(),yield w(),(t=u.payload)!=null&&t.isDragend&&(yield He(50),v.value=!0),p.value=!0})}function ee(){return T(this,null,function*(){p.value=!1})}function te(e,t){!p.value||!e||e!==t&&ae()}function ae(){return T(this,null,function*(){F(),yield w(),E(),P()})}const g=U({top:0,left:0});function E(e){if(e=R(e),!e)return;const{top:t,left:a,width:i,height:o}=e,n={top:t+o/2-x.value/2,left:a+i+6};n.top=Math.max(n.top,80);const c=window.innerHeight-x.value-40;n.top=Math.min(n.top,c),g.top=n.top,g.left=n.left}const b=U({top:0,left:0});function P(e){if(e=R(e),!e)return;const{top:t,left:a,width:i,height:o}=e,n={top:t+o/2-x.value/2,left:a+i-Q.value/2};b.top=n.top,b.left=n.left}function R(e){return e||oe()}function oe(){const{payload:e={}}=u,{event:t}=e;if(!t)return;const a=t.target;if(a&&typeof a.getBoundingClientRect=="function")return a.getBoundingClientRect()}function F(){s.value=[];for(const e of I)if(I.isDivider(e))s.value.push({divider:!0});else if($(e)){const t=_e.get(e),a=t?t.label:"未知";s.value.push({type:e,label:a,docs:t==null?void 0:t.docs})}}function ne(e,t){const a=[];let i=[],o=0;for(const n of e){if(n.divider){o>=t&&i.length>0&&(a.push(M(i)),i=[],o=0),i.push(n);continue}o>=t&&(a.push(M(i)),i=[],o=0),i.push(n),o++}return i.length>0&&a.push(M(i)),a.filter(n=>n.length>0)}function M(e){let t=0,a=e.length-1;for(;t<=a&&e[t].divider;)t++;for(;a>=t&&e[a].divider;)a--;return e.slice(t,a+1)}function le(e,t,a,i){let o=0,n=!1;for(const c of e){if(c.divider){o=o+a,n=!1;continue}n&&(o=o+i),o=o+t,n=!0}return o}function ue(e,t,a,i){if(!e.length)return 0;let o=0;for(const n of e){const c=le(n,t,a,i);c>o&&(o=c)}return o+X+Y}function ie(e,t,a){return e<=0?t:e*t+(e-1)*a}const S=l(()=>ne(s.value,r.value)),x=l(()=>ue(S.value,G.value,Qe,H.value)),Q=l(()=>ie(S.value.length,V.value,m.value)),re=l(()=>Q.value+"px"),se=l(()=>x.value+"px"),ce=l(()=>`${Fe/2}px ${Y/2}px`),de=l(()=>`${X/2}px`),fe=l(()=>V.value+"px"),pe=l(()=>m.value+"px"),ve=l(()=>G.value+"px"),me=l(()=>H.value+"px"),he=l(()=>Z.value+"px"),ye=l(()=>b.top+"px"),ge=l(()=>b.left+"px"),be=l(()=>g.top+"px"),xe=l(()=>g.left+"px");function we(e){C("add",e)}return(e,t)=>{const a=Ee,i=Ce("Icon"),o=Ve,n=Ge;return f(),h("div",{class:ze([De(y),{show:p.value}]),style:Be({transition:v.value?"box-shadow 0.15s, opacity 0.3s, top 0.3s, left 0.3s, height 0.3s, transform 0.3s":void 0}),onClick:t[1]||(t[1]=_(()=>{},["stop"]))},[(f(!0),h(z,null,J(S.value,(c,W)=>(f(),h("div",{key:W,class:"add-node-column"},[(f(!0),h(z,null,J(c,(d,j)=>(f(),h(z,{key:d.type?`${d.type}-${j}`:`divider-${W}-${j}`},[d.divider?(f(),D(a,{key:0,class:"add-node-divider"})):(f(),D(n,{key:1,class:"add-node-item",onClick:_(We=>we(d.type),["stop"])},{default:K(()=>[L(Ie,{type:d.type},null,8,["type"]),O("span",Pe,Se(d.label),1),d.docs?(f(),D(o,{key:0,title:"查看文档"},{default:K(()=>[O("a",{class:"airag-node-docs-btn",href:d.docs,target:"_blank",onClick:t[0]||(t[0]=_(()=>{},["stop"]))},[L(i,{icon:"material-symbols:menu-book-outline-rounded",color:"#666"})],8,Re)]),_:2},1024)):Me("",!0)]),_:2},1032,["onClick"]))],64))),128))]))),128))],6)}}});export{Ue as default};
|