UNPKG

epic-designer-gold

Version:

基于vue3的设计器,可视化开发页面表单

71 lines (59 loc) 18 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./mermaid.core-amipJqhv.cjs");var tt=function(){var i=e.__name(function(M,t,s,n){for(s=s||{},n=M.length;n--;s[M[n]]=t);return s},"o"),h=[1,4],l=[1,14],r=[1,12],o=[1,13],y=[6,7,8],f=[1,20],d=[1,18],m=[1,19],c=[6,7,11],g=[1,6,13,14],_=[1,23],w=[1,24],x=[1,6,7,11,13,14],N={trace:e.__name(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"ISHIKAWA",11:"EOF",13:"SPACELIST",14:"TEXT"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:e.__name(function(t,s,n,u,p,a,v){var k=a.length-1;switch(p){case 6:case 7:return u;case 15:u.addNode(a[k-1].length,a[k].trim());break;case 16:u.addNode(0,a[k].trim());break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:h},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:h},{6:l,7:[1,10],9:9,12:11,13:r,14:o},i(y,[2,3]),{1:[2,2]},i(y,[2,4]),i(y,[2,5]),{1:[2,6],6:l,12:15,13:r,14:o},{6:l,9:16,12:11,13:r,14:o},{6:f,7:d,10:17,11:m},i(c,[2,18],{14:[1,21]}),i(c,[2,16]),i(c,[2,17]),{6:f,7:d,10:22,11:m},{1:[2,7],6:l,12:15,13:r,14:o},i(g,[2,14],{7:_,11:w}),i(x,[2,8]),i(x,[2,9]),i(x,[2,10]),i(c,[2,15]),i(g,[2,13],{7:_,11:w}),i(x,[2,11]),i(x,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:e.__name(function(t,s){if(s.recoverable)this.trace(t);else{var n=new Error(t);throw n.hash=s,n}},"parseError"),parse:e.__name(function(t){var s=this,n=[0],u=[],p=[null],a=[],v=this.table,k="",I=0,S=0,L=2,E=1,R=a.slice.call(arguments,1),b=Object.create(this.lexer),C={yy:{}};for(var j in this.yy)Object.prototype.hasOwnProperty.call(this.yy,j)&&(C.yy[j]=this.yy[j]);b.setInput(t,C.yy),C.yy.lexer=b,C.yy.parser=this,typeof b.yylloc>"u"&&(b.yylloc={});var T=b.yylloc;a.push(T);var D=b.options&&b.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function F(P){n.length=n.length-2*P,p.length=p.length-P,a.length=a.length-P}e.__name(F,"popStack");function z(){var P;return P=u.pop()||b.lex()||E,typeof P!="number"&&(P instanceof Array&&(u=P,P=u.pop()),P=s.symbols_[P]||P),P}e.__name(z,"lex");for(var A,W,B,K,H={},X,V,et,Y;;){if(W=n[n.length-1],this.defaultActions[W]?B=this.defaultActions[W]:((A===null||typeof A>"u")&&(A=z()),B=v[W]&&v[W][A]),typeof B>"u"||!B.length||!B[0]){var Q="";Y=[];for(X in v[W])this.terminals_[X]&&X>L&&Y.push("'"+this.terminals_[X]+"'");b.showPosition?Q="Parse error on line "+(I+1)+`: `+b.showPosition()+` Expecting `+Y.join(", ")+", got '"+(this.terminals_[A]||A)+"'":Q="Parse error on line "+(I+1)+": Unexpected "+(A==E?"end of input":"'"+(this.terminals_[A]||A)+"'"),this.parseError(Q,{text:b.match,token:this.terminals_[A]||A,line:b.yylineno,loc:T,expected:Y})}if(B[0]instanceof Array&&B.length>1)throw new Error("Parse Error: multiple actions possible at state: "+W+", token: "+A);switch(B[0]){case 1:n.push(A),p.push(b.yytext),a.push(b.yylloc),n.push(B[1]),A=null,S=b.yyleng,k=b.yytext,I=b.yylineno,T=b.yylloc;break;case 2:if(V=this.productions_[B[1]][1],H.$=p[p.length-V],H._$={first_line:a[a.length-(V||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(V||1)].first_column,last_column:a[a.length-1].last_column},D&&(H._$.range=[a[a.length-(V||1)].range[0],a[a.length-1].range[1]]),K=this.performAction.apply(H,[k,S,I,C.yy,B[1],p,a].concat(R)),typeof K<"u")return K;V&&(n=n.slice(0,-1*V*2),p=p.slice(0,-1*V),a=a.slice(0,-1*V)),n.push(this.productions_[B[1]][0]),p.push(H.$),a.push(H._$),et=v[n[n.length-2]][n[n.length-1]],n.push(et);break;case 3:return!0}}return!0},"parse")},O=function(){var M={EOF:1,parseError:e.__name(function(s,n){if(this.yy.parser)this.yy.parser.parseError(s,n);else throw new Error(s)},"parseError"),setInput:e.__name(function(t,s){return this.yy=s||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:e.__name(function(){var t=this._input[0];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;var s=t.match(/(?:\r\n?|\n).*/g);return s?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},"input"),unput:e.__name(function(t){var s=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-s),this.offset-=s;var u=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var p=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===u.length?this.yylloc.first_column:0)+u[u.length-n.length].length-n[0].length:this.yylloc.first_column-s},this.options.ranges&&(this.yylloc.range=[p[0],p[0]+this.yyleng-s]),this.yyleng=this.yytext.length,this},"unput"),more:e.__name(function(){return this._more=!0,this},"more"),reject:e.__name(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true). `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:e.__name(function(t){this.unput(this.match.slice(t))},"less"),pastInput:e.__name(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:e.__name(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:e.__name(function(){var t=this.pastInput(),s=new Array(t.length+1).join("-");return t+this.upcomingInput()+` `+s+"^"},"showPosition"),test_match:e.__name(function(t,s){var n,u,p;if(this.options.backtrack_lexer&&(p={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(p.yylloc.range=this.yylloc.range.slice(0))),u=t[0].match(/(?:\r\n?|\n).*/g),u&&(this.yylineno+=u.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:u?u[u.length-1].length-u[u.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,s,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in p)this[a]=p[a];return!1}return!1},"test_match"),next:e.__name(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,s,n,u;this._more||(this.yytext="",this.match="");for(var p=this._currentRules(),a=0;a<p.length;a++)if(n=this._input.match(this.rules[p[a]]),n&&(!s||n[0].length>s[0].length)){if(s=n,u=a,this.options.backtrack_lexer){if(t=this.test_match(n,p[a]),t!==!1)return t;if(this._backtrack){s=!1;continue}else return!1}else if(!this.options.flex)break}return s?(t=this.test_match(s,p[u]),t!==!1?t:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text. `+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:e.__name(function(){var s=this.next();return s||this.lex()},"lex"),begin:e.__name(function(s){this.conditionStack.push(s)},"begin"),popState:e.__name(function(){var s=this.conditionStack.length-1;return s>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:e.__name(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:e.__name(function(s){return s=this.conditionStack.length-1-Math.abs(s||0),s>=0?this.conditionStack[s]:"INITIAL"},"topState"),pushState:e.__name(function(s){this.begin(s)},"pushState"),stateStackSize:e.__name(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:e.__name(function(s,n,u,p){switch(u){case 0:return 6;case 1:return 8;case 2:return 8;case 3:return 6;case 4:return 7;case 5:return 13;case 6:return 14;case 7:return 11}},"anonymous"),rules:[/^(?:\s*%%.*)/i,/^(?:ishikawa-beta\b)/i,/^(?:ishikawa\b)/i,/^(?:[\s]+[\n])/i,/^(?:[\n]+)/i,/^(?:[\s]+)/i,/^(?:[^\n]+)/i,/^(?:$)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:!0}}};return M}();N.lexer=O;function $(){this.yy={}}return e.__name($,"Parser"),$.prototype=N,N.Parser=$,new $}();tt.parser=tt;var ht=tt,Z,ct=(Z=class{constructor(){this.stack=[],this.clear=this.clear.bind(this),this.addNode=this.addNode.bind(this),this.getRoot=this.getRoot.bind(this)}clear(){this.root=void 0,this.stack=[],this.baseLevel=void 0,e.clear()}getRoot(){return this.root}addNode(h,l){const r=e.common_default.sanitizeText(l,e.getConfig2());if(!this.root){this.baseLevel=h,this.root={text:r,children:[]},this.stack=[{level:0,node:this.root}],e.setDiagramTitle(r);return}let o=h-(this.baseLevel??0);for(o<=0&&(o=1);this.stack.length>1&&this.stack[this.stack.length-1].level>=o;)this.stack.pop();const y=this.stack[this.stack.length-1].node,f={text:r,children:[]};y.children.push(f),this.stack.push({level:o,node:f})}getAccTitle(){return e.getAccTitle()}setAccTitle(h){e.setAccTitle(h)}getAccDescription(){return e.getAccDescription()}setAccDescription(h){e.setAccDescription(h)}getDiagramTitle(){return e.getDiagramTitle()}setDiagramTitle(h){e.setDiagramTitle(h)}},e.__name(Z,"IshikawaDB"),Z),ut=14,G=250,dt=30,yt=60,ft=5,lt=82*Math.PI/180,it=Math.cos(lt),nt=Math.sin(lt),st=e.__name((i,h,l)=>{const r=i.node().getBBox(),o=r.width+h*2,y=r.height+h*2;e.configureSvgSize(i,y,o,l),i.attr("viewBox",`${r.x-h} ${r.y-h} ${o} ${y}`)},"applyPaddedViewBox"),pt=e.__name((i,h,l,r)=>{var C,j;const y=r.db.getRoot();if(!y)return;const f=e.getConfig2(),{look:d,handDrawnSeed:m,themeVariables:c}=f,g=e.parseFontSize(f.fontSize)[0]??ut,_=d==="handDrawn",w=y.children??[],x=((C=f.ishikawa)==null?void 0:C.diagramPadding)??20,N=((j=f.ishikawa)==null?void 0:j.useMaxWidth)??!1,O=e.selectSvgElement(h),$=O.append("g").attr("class","ishikawa"),M=_?e.at.svg(O.node()):void 0,t=M?{roughSvg:M,seed:m??0,lineColor:(c==null?void 0:c.lineColor)??"#333",fillColor:(c==null?void 0:c.mainBkg)??"#fff"}:void 0,s=`ishikawa-arrow-${h}`;_||$.append("defs").append("marker").attr("id",s).attr("viewBox","0 0 10 10").attr("refX",0).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 Z").attr("class","ishikawa-arrow");let n=0,u=G;const p=_?void 0:U($,n,u,n,u,"ishikawa-spine");if(_t($,n,u,y.text,g,t),!w.length){_&&U($,n,u,n,u,"ishikawa-spine",t),st(O,x,N);return}n-=20;const a=w.filter((T,D)=>D%2===0),v=w.filter((T,D)=>D%2===1),k=at(a),I=at(v),S=k.total+I.total;let L=G,E=G;if(S>0){const T=G*2,D=G*.3;L=Math.max(D,T*(k.total/S)),E=Math.max(D,T*(I.total/S))}const R=g*2;L=Math.max(L,k.max*R),E=Math.max(E,I.max*R),u=Math.max(L,G),p&&p.attr("y1",u).attr("y2",u),$.select(".ishikawa-head-group").attr("transform",`translate(0,${u})`);const b=Math.ceil(w.length/2);for(let T=0;T<b;T++){const D=$.append("g").attr("class","ishikawa-pair");for(const[F,z,A]of[[w[T*2],-1,L],[w[T*2+1],1,E]])F&&kt(D,F,n,u,z,A,g,t);n=D.selectAll("text").nodes().reduce((F,z)=>Math.min(F,z.getBBox().x),1/0)}if(_)U($,n,u,0,u,"ishikawa-spine",t);else{p.attr("x1",n);const T=`url(#${s})`;$.selectAll("line.ishikawa-branch, line.ishikawa-sub-branch").attr("marker-start",T)}st(O,x,N)},"draw"),at=e.__name(i=>{const h=e.__name(l=>l.children.reduce((r,o)=>r+1+h(o),0),"countDescendants");return i.reduce((l,r)=>{const o=h(r);return l.total+=o,l.max=Math.max(l.max,o),l},{total:0,max:0})},"sideStats"),_t=e.__name((i,h,l,r,o,y)=>{const f=Math.max(6,Math.floor(110/(o*.6))),d=i.append("g").attr("class","ishikawa-head-group").attr("transform",`translate(${h},${l})`),m=q(d,ot(r,f),0,0,"ishikawa-head-label","start",o),c=m.node().getBBox(),g=Math.max(60,c.width+6),_=Math.max(40,c.height*2+40),w=`M 0 ${-_/2} L 0 ${_/2} Q ${g*2.4} 0 0 ${-_/2} Z`;if(y){const x=y.roughSvg.path(w,{roughness:1.5,seed:y.seed,fill:y.fillColor,fillStyle:"hachure",fillWeight:2.5,hachureGap:5,stroke:y.lineColor,strokeWidth:2});d.insert(()=>x,":first-child").attr("class","ishikawa-head")}else d.insert("path",":first-child").attr("class","ishikawa-head").attr("d",w);m.attr("transform",`translate(${(g-c.width)/2-c.x+3},${-c.y-c.height/2})`)},"drawHead"),gt=e.__name((i,h)=>{const l=[],r=[],o=e.__name((y,f,d)=>{const m=h===-1?[...y].reverse():y;for(const c of m){const g=l.length,_=c.children??[];l.push({depth:d,text:ot(c.text,15),parentIndex:f,childCount:_.length}),d%2===0?(r.push(g),_.length&&o(_,g,d+1)):(_.length&&o(_,g,d+1),r.push(g))}},"walk");return o(i,-1,2),{entries:l,yOrder:r}},"flattenTree"),mt=e.__name((i,h,l,r,o,y,f)=>{const d=i.append("g").attr("class","ishikawa-label-group"),c=q(d,h,l,r+11*o,"ishikawa-label cause","middle",y).node().getBBox();if(f){const g=f.roughSvg.rectangle(c.x-20,c.y-2,c.width+40,c.height+4,{roughness:1.5,seed:f.seed,fill:f.fillColor,fillStyle:"hachure",fillWeight:2.5,hachureGap:5,stroke:f.lineColor,strokeWidth:2});d.insert(()=>g,":first-child").attr("class","ishikawa-label-box")}else d.insert("rect",":first-child").attr("class","ishikawa-label-box").attr("x",c.x-20).attr("y",c.y-2).attr("width",c.width+40).attr("height",c.height+4)},"drawCauseLabel"),J=e.__name((i,h,l,r,o,y)=>{const f=Math.sqrt(r*r+o*o);if(f===0)return;const d=r/f,m=o/f,c=6,g=-m*c,_=d*c,w=h,x=l,N=`M ${w} ${x} L ${w-d*c*2+g} ${x-m*c*2+_} L ${w-d*c*2-g} ${x-m*c*2-_} Z`,O=y.roughSvg.path(N,{roughness:1,seed:y.seed,fill:y.lineColor,fillStyle:"solid",stroke:y.lineColor,strokeWidth:1});i.append(()=>O)},"drawArrowMarker"),kt=e.__name((i,h,l,r,o,y,f,d)=>{const m=h.children??[],c=y*(m.length?1:.2),g=-it*c,_=nt*c*o,w=l+g,x=r+_;if(U(i,l,r,w,x,"ishikawa-branch",d),d&&J(i,l,r,l-w,r-x,d),mt(i,h.text,w,x,o,f,d),!m.length)return;const{entries:N,yOrder:O}=gt(m,o),$=N.length,M=new Array($);for(const[p,a]of O.entries())M[a]=r+_*((p+1)/($+1));const t=new Map;t.set(-1,{x0:l,y0:r,x1:w,y1:x,childCount:m.length,childrenDrawn:0});const s=-it,n=nt*o,u=o<0?"ishikawa-label up":"ishikawa-label down";for(const[p,a]of N.entries()){const v=M[p],k=t.get(a.parentIndex),I=i.append("g").attr("class","ishikawa-sub-group");let S=0,L=0,E=0;if(a.depth%2===0){const R=k.y1-k.y0;S=rt(k.x0,k.x1,R?(v-k.y0)/R:.5),L=v,E=S-(a.childCount>0?yt+a.childCount*ft:dt),U(I,S,v,E,v,"ishikawa-sub-branch",d),d&&J(I,S,v,1,0,d),q(I,a.text,E,v,"ishikawa-label align","end",f)}else{const R=k.childrenDrawn++;S=rt(k.x0,k.x1,(k.childCount-R)/(k.childCount+1)),L=k.y0,E=S+s*((v-L)/n),U(I,S,L,E,v,"ishikawa-sub-branch",d),d&&J(I,S,L,S-E,L-v,d),q(I,a.text,E,v,u,"end",f)}a.childCount>0&&t.set(p,{x0:S,y0:L,x1:E,y1:v,childCount:a.childCount,childrenDrawn:0})}},"drawBranch"),wt=e.__name(i=>i.split(/<br\s*\/?>|\n/),"splitLines"),ot=e.__name((i,h)=>{if(i.length<=h)return i;const l=[];for(const r of i.split(/\s+/)){const o=l.length-1;o>=0&&l[o].length+1+r.length<=h?l[o]+=" "+r:l.push(r)}return l.join(` `)},"wrapText"),q=e.__name((i,h,l,r,o,y,f)=>{const d=wt(h),m=f*1.05,c=i.append("text").attr("class",o).attr("text-anchor",y).attr("x",l).attr("y",r-(d.length-1)*m/2);for(const[g,_]of d.entries())c.append("tspan").attr("x",l).attr("dy",g===0?0:m).text(_);return c},"drawMultilineText"),rt=e.__name((i,h,l)=>i+(h-i)*l,"lerp"),U=e.__name((i,h,l,r,o,y,f)=>{if(f){const d=f.roughSvg.line(h,l,r,o,{roughness:1.5,seed:f.seed,stroke:f.lineColor,strokeWidth:2});i.append(()=>d).attr("class",y);return}return i.append("line").attr("class",y).attr("x1",h).attr("y1",l).attr("x2",r).attr("y2",o)},"drawLine"),bt={draw:pt},xt=e.__name(i=>` .ishikawa .ishikawa-spine, .ishikawa .ishikawa-branch, .ishikawa .ishikawa-sub-branch { stroke: ${i.lineColor}; stroke-width: 2; fill: none; } .ishikawa .ishikawa-sub-branch { stroke-width: 1; } .ishikawa .ishikawa-arrow { fill: ${i.lineColor}; } .ishikawa .ishikawa-head { fill: ${i.mainBkg}; stroke: ${i.lineColor}; stroke-width: 2; } .ishikawa .ishikawa-label-box { fill: ${i.mainBkg}; stroke: ${i.lineColor}; stroke-width: 2; } .ishikawa text { font-family: ${i.fontFamily}; font-size: ${i.fontSize}; fill: ${i.textColor}; } .ishikawa .ishikawa-head-label { font-weight: 600; text-anchor: middle; dominant-baseline: middle; font-size: 14px; } .ishikawa .ishikawa-label { text-anchor: end; } .ishikawa .ishikawa-label.cause { text-anchor: middle; dominant-baseline: middle; } .ishikawa .ishikawa-label.align { text-anchor: end; dominant-baseline: middle; } .ishikawa .ishikawa-label.up { dominant-baseline: baseline; } .ishikawa .ishikawa-label.down { dominant-baseline: hanging; } `,"getStyles"),vt=xt,St={parser:ht,get db(){return new ct},renderer:bt,styles:vt};exports.diagram=St;