11 lines
2.9 KiB
JavaScript
11 lines
2.9 KiB
JavaScript
import{t as f,c as x,a as C,v as B,g as T,b as y,_ as s,I as u,l as k,N as V,f as N,G as _,K as S,C as D}from"./index-BsqrNJOy.js";import{p as I}from"./chunk-4BX2VUAB-BtKd7YSa.js";import{I as $}from"./chunk-QZHKN3VN-BpjlORTp.js";import{p as A}from"./wardley-RL74JXVD-DCcnpaQH.js";import"./semi-ui-C-ZN869V.js";import"./react-core-C8o2IdY8.js";import"./i18n-DJWjvQyM.js";import"./tools-qobPTha0.js";import"./react-components-KaTRN41W.js";import"./min-GZB7r5Ok.js";import"./_baseUniq-pyr2ZJQu.js";var d=new $(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",children:[]}]})),X=s(()=>{d.reset(),D()},"clear"),z=s(()=>d.records.stack[0],"getRoot"),H=s(()=>d.records.cnt,"getCount"),L=S.treeView,R=s(()=>u(L,_().treeView),"getConfig"),W=s((e,t)=>{for(;e<=d.records.stack[d.records.stack.length-1].level;)d.records.stack.pop();const r={id:d.records.cnt++,level:e,name:t,children:[]};d.records.stack[d.records.stack.length-1].children.push(r),d.records.stack.push(r)},"addNode"),E={clear:X,addNode:W,getRoot:z,getCount:H,getConfig:R,getAccTitle:y,getAccDescription:T,getDiagramTitle:B,setAccDescription:C,setAccTitle:x,setDiagramTitle:f},w=E,M=s(e=>{I(e,w),e.nodes.map(t=>w.addNode(t.indent?parseInt(t.indent):0,t.name))},"populate"),F={parse:s(async e=>{const t=await A("treeView",e);k.debug(t),M(t)},"parse")},Y=s((e,t,r,i,n)=>{const c=i.append("text").text(r.name).attr("dominant-baseline","middle").attr("class","treeView-node-label"),{height:p,width:a}=c.node().getBBox(),l=p+n.paddingY*2,o=a+n.paddingX*2;c.attr("x",e+n.paddingX),c.attr("y",t+l/2),r.BBox={x:e,y:t,width:o,height:l}},"positionLabel"),b=s((e,t,r,i,n,c)=>e.append("line").attr("x1",t).attr("y1",r).attr("x2",i).attr("y2",n).attr("stroke-width",c).attr("class","treeView-node-line"),"positionLine"),G=s((e,t,r)=>{let i=0,n=0;const c=s((a,l,o,h)=>{const m=h*(o.rowIndent+o.paddingX);Y(m,i,l,a,o);const{height:g,width:v}=l.BBox;b(a,m-o.rowIndent,i+g/2,m,i+g/2,o.lineThickness),n=Math.max(n,m+v),i+=g},"drawNode"),p=s((a,l=0)=>{c(e,a,r,l),a.children.forEach(g=>{p(g,l+1)});const{x:o,y:h,height:m}=a.BBox;if(a.children.length){const{y:g,height:v}=a.children[a.children.length-1].BBox;b(e,o+r.paddingX,h+m,o+r.paddingX,g+v/2+r.lineThickness/2,r.lineThickness)}},"processNode");return p(t),{totalHeight:i,totalWidth:n}},"drawTree"),K=s((e,t,r,i)=>{k.debug(`Rendering treeView diagram
|
|
`+e);const n=i.db,c=n.getRoot(),p=n.getConfig(),a=V(t),l=a.append("g");l.attr("class","tree-view");const{totalHeight:o,totalWidth:h}=G(l,c,p);a.attr("viewBox",`-${p.lineThickness/2} 0 ${h} ${o}`),N(a,o,h,p.useMaxWidth)},"draw"),j={draw:K},q=j,J={labelFontSize:"16px",labelColor:"black",lineColor:"black"},O=s(({treeView:e})=>{const{labelFontSize:t,labelColor:r,lineColor:i}=u(J,e);return`
|
|
.treeView-node-label {
|
|
font-size: ${t};
|
|
fill: ${r};
|
|
}
|
|
.treeView-node-line {
|
|
stroke: ${i};
|
|
}
|
|
`},"styles"),P=O,le={db:w,renderer:q,parser:F,styles:P};export{le as diagram};
|