UNPKG

ruru

Version:

Grafast-flavoured GraphiQL distribution

2 lines • 12.4 kB
export const __webpack_esm_id__=4310;export const __webpack_esm_ids__=[4310];export const __webpack_esm_modules__={26637(e,t,a){function l(e,t){e.accDescr&&t.setAccDescription?.(e.accDescr),e.accTitle&&t.setAccTitle?.(e.accTitle),e.title&&t.setDiagramTitle?.(e.title)}a.r(t),a.d(t,{populateCommonDb:()=>l}),(0,a(79456).__name)(l,"populateCommonDb")},2667(e,t,a){a.r(t),a.d(t,{setupViewPortForSVG:()=>n});var l=a(39989),s=a(27166),r=a(79456),n=(0,r.__name)((e,t,a,r)=>{e.attr("class",a);const{width:n,height:c,x:d,y:p}=i(e,t);(0,l.configureSvgSize)(e,c,n,r);const h=o(d,p,n,c,t);e.attr("viewBox",h),s.log.debug(`viewBox configured: ${h} with padding: ${t}`)},"setupViewPortForSVG"),i=(0,r.__name)((e,t)=>{const a=e.node()?.getBBox()||{width:0,height:0,x:0,y:0};return{width:a.width+2*t,height:a.height+2*t,x:a.x,y:a.y}},"calculateDimensionsWithPadding"),o=(0,r.__name)((e,t,a,l,s)=>`${e-s} ${t-s} ${a} ${l}`,"createViewBox")},4310(e,t,a){a.r(t),a.d(t,{diagram:()=>C});var l=a(26637),s=a(64342),r=a(2667),n=a(48550),i=a(70848),o=a(39989),c=a(27166),d=a(79456),p=a(73744),h=a(79806),m=class{constructor(){this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.setAccTitle=o.setAccTitle,this.getAccTitle=o.getAccTitle,this.setDiagramTitle=o.setDiagramTitle,this.getDiagramTitle=o.getDiagramTitle,this.getAccDescription=o.getAccDescription,this.setAccDescription=o.setAccDescription}static{(0,d.__name)(this,"TreeMapDB")}getNodes(){return this.nodes}getConfig(){const e=o.defaultConfig_default,t=(0,o.getConfig)();return(0,i.cleanAndMerge)({...e.treemap,...t.treemap??{}})}addNode(e,t){this.nodes.push(e),this.levels.set(e,t),0===t&&(this.outerNodes.push(e),this.root??=e)}getRoot(){return{name:"",children:this.outerNodes}}addClass(e,t){const a=this.classes.get(e)??{id:e,styles:[],textStyles:[]},l=t.replace(/\\,/g,"§§§").replace(/,/g,";").replace(/§§§/g,",").split(";");l&&l.forEach(e=>{(0,n.isLabelStyle)(e)&&(a?.textStyles?a.textStyles.push(e):a.textStyles=[e]),a?.styles?a.styles.push(e):a.styles=[e]}),this.classes.set(e,a)}getClasses(){return this.classes}getStylesForClass(e){return this.classes.get(e)?.styles??[]}clear(){(0,o.clear)(),this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.root=void 0}};function g(e){if(!e.length)return[];const t=[],a=[];return e.forEach(e=>{const l={name:e.name,children:"Leaf"===e.type?void 0:[]};for(l.classSelector=e?.classSelector,e?.cssCompiledStyles&&(l.cssCompiledStyles=e.cssCompiledStyles),"Leaf"===e.type&&void 0!==e.value&&(l.value=e.value);a.length>0&&a[a.length-1].level>=e.level;)a.pop();if(0===a.length)t.push(l);else{const e=a[a.length-1].node;e.children?e.children.push(l):e.children=[l]}"Leaf"!==e.type&&a.push({node:l,level:e.level})}),t}(0,d.__name)(g,"buildHierarchy");var y=(0,d.__name)((e,t)=>{(0,l.populateCommonDb)(e,t);const a=[];for(const a of e.TreemapRows??[])"ClassDefStatement"===a.$type&&t.addClass(a.className??"",a.styleText??"");for(const l of e.TreemapRows??[]){const e=l.item;if(!e)continue;const s=l.indent?parseInt(l.indent):0,r=f(e),n=e.classSelector?t.getStylesForClass(e.classSelector):[],i=n.length>0?n:void 0,o={level:s,name:r,type:e.$type,value:e.value,classSelector:e.classSelector,cssCompiledStyles:i};a.push(o)}const s=g(a),r=(0,d.__name)((e,a)=>{for(const l of e)t.addNode(l,a),l.children&&l.children.length>0&&r(l.children,a+1)},"addNodesRecursively");r(s,0)},"populate"),f=(0,d.__name)(e=>e.name?String(e.name):"","getItemName"),u={parser:{yy:void 0},parse:(0,d.__name)(async e=>{try{const t=p.parse,a=await t("treemap",e);c.log.debug("Treemap AST:",a);const l=u.parser?.yy;if(!(l instanceof m))throw new Error("parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");y(a,l)}catch(e){throw c.log.error("Error parsing treemap:",e),e}},"parse")},S={draw:(0,d.__name)((e,t,a,l)=>{const i=l.db,p=i.getConfig(),m=p.padding??10,g=i.getDiagramTitle(),y=i.getRoot(),{themeVariables:f}=(0,o.getConfig)();if(!y)return;const u=g?30:0,S=(0,s.selectSvgElement)(t),x=p.nodeWidth?10*p.nodeWidth:960,b=p.nodeHeight?10*p.nodeHeight:500,C=x,w=b+u;let $;S.attr("viewBox",`0 0 ${C} ${w}`),(0,o.configureSvgSize)(S,w,C,p.useMaxWidth);try{const e=p.valueFormat||",";if("$0,0"===e)$=(0,d.__name)(e=>"$"+(0,h.format)(",")(e),"valueFormat");else if(e.startsWith("$")&&e.includes(",")){const t=/\.\d+/.exec(e),a=t?t[0]:"";$=(0,d.__name)(e=>"$"+(0,h.format)(","+a)(e),"valueFormat")}else if(e.startsWith("$")){const t=e.substring(1);$=(0,d.__name)(e=>"$"+(0,h.format)(t||"")(e),"valueFormat")}else $=(0,h.format)(e)}catch(e){c.log.error("Error creating format function:",e),$=(0,h.format)(",")}const v=(0,h.scaleOrdinal)().range(["transparent",f.cScale0,f.cScale1,f.cScale2,f.cScale3,f.cScale4,f.cScale5,f.cScale6,f.cScale7,f.cScale8,f.cScale9,f.cScale10,f.cScale11]),_=(0,h.scaleOrdinal)().range(["transparent",f.cScalePeer0,f.cScalePeer1,f.cScalePeer2,f.cScalePeer3,f.cScalePeer4,f.cScalePeer5,f.cScalePeer6,f.cScalePeer7,f.cScalePeer8,f.cScalePeer9,f.cScalePeer10,f.cScalePeer11]),T=(0,h.scaleOrdinal)().range([f.cScaleLabel0,f.cScaleLabel1,f.cScaleLabel2,f.cScaleLabel3,f.cScaleLabel4,f.cScaleLabel5,f.cScaleLabel6,f.cScaleLabel7,f.cScaleLabel8,f.cScaleLabel9,f.cScaleLabel10,f.cScaleLabel11]);g&&S.append("text").attr("x",C/2).attr("y",u/2).attr("class","treemapTitle").attr("text-anchor","middle").attr("dominant-baseline","middle").text(g);const L=S.append("g").attr("transform",`translate(0, ${u})`).attr("class","treemapContainer"),k=(0,h.hierarchy)(y).sum(e=>e.value??0).sort((e,t)=>(t.value??0)-(e.value??0)),M=(0,h.treemap)().size([x,b]).paddingTop(e=>e.children&&e.children.length>0?35:0).paddingInner(m).paddingLeft(e=>e.children&&e.children.length>0?10:0).paddingRight(e=>e.children&&e.children.length>0?10:0).paddingBottom(e=>e.children&&e.children.length>0?10:0).round(!0)(k),z=M.descendants().filter(e=>e.children&&e.children.length>0),D=L.selectAll(".treemapSection").data(z).enter().append("g").attr("class","treemapSection").attr("transform",e=>`translate(${e.x0},${e.y0})`);D.append("rect").attr("width",e=>e.x1-e.x0).attr("height",25).attr("class","treemapSectionHeader").attr("fill","none").attr("fill-opacity",.6).attr("stroke-width",.6).attr("style",e=>0===e.depth?"display: none;":""),D.append("clipPath").attr("id",(e,a)=>`clip-section-${t}-${a}`).append("rect").attr("width",e=>Math.max(0,e.x1-e.x0-12)).attr("height",25),D.append("rect").attr("width",e=>e.x1-e.x0).attr("height",e=>e.y1-e.y0).attr("class",(e,t)=>`treemapSection section${t}`).attr("fill",e=>v(e.data.name)).attr("fill-opacity",.6).attr("stroke",e=>_(e.data.name)).attr("stroke-width",2).attr("stroke-opacity",.4).attr("style",e=>{if(0===e.depth)return"display: none;";const t=(0,n.styles2String)({cssCompiledStyles:e.data.cssCompiledStyles});return t.nodeStyles+";"+t.borderStyles.join(";")}),D.append("text").attr("class","treemapSectionLabel").attr("x",6).attr("y",12.5).attr("dominant-baseline","middle").text(e=>0===e.depth?"":e.data.name).attr("font-weight","bold").attr("clip-path",(e,a)=>`url(#clip-section-${t}-${a})`).attr("style",e=>0===e.depth?"display: none;":"dominant-baseline: middle; font-size: 12px; fill:"+T(e.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"+(0,n.styles2String)({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace("color:","fill:")).each(function(e){if(0===e.depth)return;const t=(0,h.select)(this),a=e.data.name;t.text(a);const l=e.x1-e.x0;let s;s=!1!==p.showValues&&e.value?l-10-30-10-6:l-6-6;const r=Math.max(15,s),n=t.node();if(n.getComputedTextLength()>r){const e="...";let l=a;for(;l.length>0;){if(l=a.substring(0,l.length-1),0===l.length){t.text(e),n.getComputedTextLength()>r&&t.text("");break}if(t.text(l+e),n.getComputedTextLength()<=r)break}}}),!1!==p.showValues&&D.append("text").attr("class","treemapSectionValue").attr("x",e=>e.x1-e.x0-10).attr("y",12.5).attr("text-anchor","end").attr("dominant-baseline","middle").text(e=>e.value?$(e.value):"").attr("font-style","italic").attr("style",e=>0===e.depth?"display: none;":"text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:"+T(e.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"+(0,n.styles2String)({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace("color:","fill:"));const F=M.leaves(),P=F.length>20,A=P?16:38,V=P?14:28,N=P?4:8,W=P?4:6,B=P?2:4,E=P?8:10,R=P?1:2,G=L.selectAll(".treemapLeafGroup").data(F).enter().append("g").attr("class",(e,t)=>`treemapNode treemapLeafGroup leaf${t}${e.data.classSelector?` ${e.data.classSelector}`:""}x`).attr("transform",e=>`translate(${e.x0},${e.y0})`);G.append("rect").attr("width",e=>e.x1-e.x0).attr("height",e=>e.y1-e.y0).attr("class","treemapLeaf").attr("fill",e=>e.parent?v(e.parent.data.name):v(e.data.name)).attr("style",e=>(0,n.styles2String)({cssCompiledStyles:e.data.cssCompiledStyles}).nodeStyles).attr("fill-opacity",.3).attr("stroke",e=>e.parent?v(e.parent.data.name):v(e.data.name)).attr("stroke-width",3),G.append("clipPath").attr("id",(e,a)=>`clip-${t}-${a}`).append("rect").attr("width",e=>Math.max(0,e.x1-e.x0-4)).attr("height",e=>Math.max(0,e.y1-e.y0-4)),G.append("text").attr("class","treemapLabel").attr("x",e=>(e.x1-e.x0)/2).attr("y",e=>(e.y1-e.y0)/2).attr("style",e=>`text-anchor: middle; dominant-baseline: middle; font-size: ${A}px;fill:`+T(e.data.name)+";"+(0,n.styles2String)({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace("color:","fill:")).attr("clip-path",(e,a)=>`url(#clip-${t}-${a})`).text(e=>e.data.name).each(function(e){const t=(0,h.select)(this),a=e.x1-e.x0,l=e.y1-e.y0,s=t.node(),r=a-2*B,n=l-2*B;if(r<E||n<E)return void t.style("display","none");let i=parseInt(t.style("font-size"),10);for(;s.getComputedTextLength()>r&&i>N;)i--,t.style("font-size",`${i}px`);let o=Math.max(W,Math.min(V,Math.round(.6*i))),c=i+R+o;for(;c>n&&i>N&&(i--,o=Math.max(W,Math.min(V,Math.round(.6*i))),!(o<W&&i===N));)t.style("font-size",`${i}px`),c=i+R+o;t.style("font-size",`${i}px`),P?(i<N||n<N)&&t.style("display","none"):(s.getComputedTextLength()>r||i<N||n<i)&&t.style("display","none")}),!1!==p.showValues&&G.append("text").attr("class","treemapValue").attr("x",e=>(e.x1-e.x0)/2).attr("y",function(e){return(e.y1-e.y0)/2}).attr("style",e=>`text-anchor: middle; dominant-baseline: hanging; font-size: ${V}px;fill:`+T(e.data.name)+";"+(0,n.styles2String)({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace("color:","fill:")).attr("clip-path",(e,a)=>`url(#clip-${t}-${a})`).text(e=>e.value?$(e.value):"").each(function(e){const t=(0,h.select)(this),a=this.parentNode;if(!a)return void t.style("display","none");const l=(0,h.select)(a).select(".treemapLabel");if(l.empty()||"none"===l.style("display"))return void t.style("display","none");const s=parseFloat(l.style("font-size")),r=Math.max(W,Math.min(V,Math.round(.6*s)));t.style("font-size",`${r}px`);const n=(e.y1-e.y0)/2+s/2+R;t.attr("y",n);const i=e.x1-e.x0,o=e.y1-e.y0-4,c=i-2*B;t.node().getComputedTextLength()>c||n+r>o||r<W?t.style("display","none"):t.style("display",null)});const H=p.diagramPadding??8;(0,r.setupViewPortForSVG)(S,H,"flowchart",p?.useMaxWidth||!1)},"draw"),getClasses:(0,d.__name)(function(e,t){return t.db.getClasses()},"getClasses")},x={sectionStrokeColor:"black",sectionStrokeWidth:"1",sectionFillColor:"#efefef",leafStrokeColor:"black",leafStrokeWidth:"1",leafFillColor:"#efefef",labelFontSize:"12px",valueFontSize:"10px",titleFontSize:"14px"},b=(0,d.__name)(({treemap:e}={})=>{const t=(0,o.getThemeVariables)(),a=(0,o.getConfig)(),l=(0,i.cleanAndMerge)(t,a.themeVariables),s=(0,i.cleanAndMerge)(x,e),r=s.titleColor??l.titleColor,n=s.labelColor??l.textColor,c=s.valueColor??l.textColor;return`\n .treemapNode.section {\n stroke: ${s.sectionStrokeColor};\n stroke-width: ${s.sectionStrokeWidth};\n fill: ${s.sectionFillColor};\n }\n .treemapNode.leaf {\n stroke: ${s.leafStrokeColor};\n stroke-width: ${s.leafStrokeWidth};\n fill: ${s.leafFillColor};\n }\n .treemapLabel {\n fill: ${n};\n font-size: ${s.labelFontSize};\n }\n .treemapValue {\n fill: ${c};\n font-size: ${s.valueFontSize};\n }\n .treemapTitle {\n fill: ${r};\n font-size: ${s.titleFontSize};\n }\n `},"getStyles"),C={parser:u,get db(){return new m},renderer:S,styles:b}}}; //# sourceMappingURL=4310.js.map