UNPKG

basb-cli

Version:
2 lines (1 loc) 2.35 kB
import{_ as t,bV as e,U as i,a9 as o,a0 as n,bq as l,g,ap as r,R as a,bU as d}from"./index.js";var s=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=i.type,t.layoutMode={type:"box",ignoreSize:!0},t}return t(i,e),i.type="title",i.defaultOption={z:6,show:!0,text:"",target:"blank",subtext:"",subtarget:"blank",left:0,top:0,backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",borderWidth:0,padding:5,itemGap:10,textStyle:{fontSize:18,fontWeight:"bold",color:"#464646"},subtextStyle:{fontSize:12,color:"#6E7079"}},i}(e),h=function(e){function d(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=d.type,t}return t(d,e),d.prototype.render=function(t,e,d){if(this.group.removeAll(),t.get("show")){var s=this.group,h=t.getModel("textStyle"),p=t.getModel("subtextStyle"),u=t.get("textAlign"),c=i(t.get("textBaseline"),t.get("textVerticalAlign")),y=new o({style:n(h,{text:t.get("text"),fill:h.getTextColor()},{disableBox:!0}),z2:10}),x=y.getBoundingRect(),b=t.get("subtext"),m=new o({style:n(p,{text:b,fill:p.getTextColor(),y:x.height+t.get("itemGap"),verticalAlign:"top"},{disableBox:!0}),z2:10}),f=t.get("link"),v=t.get("sublink"),w=t.get("triggerEvent",!0);y.silent=!f&&!w,m.silent=!v&&!w,f&&y.on("click",(function(){l(f,"_"+t.get("target"))})),v&&m.on("click",(function(){l(v,"_"+t.get("subtarget"))})),g(y).eventData=g(m).eventData=w?{componentType:"title",componentIndex:t.componentIndex}:null,s.add(y),b&&s.add(m);var S=s.getBoundingRect(),k=t.getBoxLayoutParams();k.width=S.width,k.height=S.height;var z=r(k,{width:d.getWidth(),height:d.getHeight()},t.get("padding"));u||("middle"===(u=t.get("left")||t.get("right"))&&(u="center"),"right"===u?z.x+=z.width:"center"===u&&(z.x+=z.width/2)),c||("center"===(c=t.get("top")||t.get("bottom"))&&(c="middle"),"bottom"===c?z.y+=z.height:"middle"===c&&(z.y+=z.height/2),c=c||"top"),s.x=z.x,s.y=z.y,s.markRedraw();var B={align:u,verticalAlign:c};y.setStyle(B),m.setStyle(B),S=s.getBoundingRect();var C=z.margin,R=t.getItemStyle(["color","opacity"]);R.fill=t.get("backgroundColor");var A=new a({shape:{x:S.x-C[3],y:S.y-C[0],width:S.width+C[1]+C[3],height:S.height+C[0]+C[2],r:t.get("borderRadius")},style:R,subPixelOptimize:!0,silent:!0});s.add(A)}},d.type="title",d}(d);function p(t){t.registerComponentModel(s),t.registerComponentView(h)}export{p as install};