@leafer-in/flow 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/flow.cjs CHANGED
@@ -128,8 +128,9 @@ function scaleResizePath(leaf, scaleX, scaleY) {
128
128
  leaf.path = leaf.__.path;
129
129
  }
130
130
  function scaleResizePoints(leaf, scaleX, scaleY) {
131
- PathScaler.scalePoints(leaf.__.points, scaleX, scaleY);
132
- leaf.points = leaf.__.points;
131
+ const { points } = leaf;
132
+ typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
133
+ leaf.points = points;
133
134
  }
134
135
  function scaleResizeGroup(group, scaleX, scaleY) {
135
136
  const { children } = group;
package/dist/flow.esm.js CHANGED
@@ -126,8 +126,9 @@ function scaleResizePath(leaf, scaleX, scaleY) {
126
126
  leaf.path = leaf.__.path;
127
127
  }
128
128
  function scaleResizePoints(leaf, scaleX, scaleY) {
129
- PathScaler.scalePoints(leaf.__.points, scaleX, scaleY);
130
- leaf.points = leaf.__.points;
129
+ const { points } = leaf;
130
+ typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
131
+ leaf.points = points;
131
132
  }
132
133
  function scaleResizeGroup(group, scaleX, scaleY) {
133
134
  const { children } = group;
@@ -1 +1 @@
1
- import{PathCommandMap as t,MatrixHelper as e,Direction9 as o,Leaf as i,Text as n,Path as s,Line as h,Polygon as a,Group as c,Box as r,BoxData as l,dataProcessor as _,autoLayoutType as u,registerUI as f,AlignHelper as g,PointHelper as p,MathHelper as d,decorateLeafAttr as w,attr as y,doBoundsType as x,UI as b,boundsType as G,BoundsHelper as m}from"@leafer-ui/draw";const{M:B,L:R,C:z,Q:A,Z:k,N:v,D:S,X:F,G:X,F:Y,O:C,P:W,U:O}=t,P={scale(t,e,o){if(!t)return;let i,n=0,s=t.length;for(;n<s;)switch(i=t[n],i){case B:case R:I(t,e,o,n,1),n+=3;break;case z:I(t,e,o,n,3),n+=7;break;case A:I(t,e,o,n,2),n+=5;break;case k:n+=1;break;case v:I(t,e,o,n,2),n+=5;break;case S:I(t,e,o,n,2),n+=9;break;case F:I(t,e,o,n,2),n+=6;break;case X:I(t,e,o,n,2),n+=9;break;case Y:I(t,e,o,n,2),n+=5;break;case C:t[n]=X,t.splice(n+4,0,t[n+3],0),I(t,e,o,n,2),n+=9,s+=2;break;case W:t[n]=Y,t.splice(n+4,0,t[n+3]),I(t,e,o,n,2),n+=5,s+=1;break;case O:I(t,e,o,n,2),n+=6}},scalePoints(t,e,o,i,n){for(let s=n?i+1:0,h=n?s+2*n:t.length;s<h;s+=2)t[s]*=e,t[s+1]*=o}},{scalePoints:I}=P,j=e.get(),{topLeft:H,top:E,topRight:L,right:M,bottom:D,left:N}=o;function Q(t,e,o){t.pathInputed?Z(t,e,o):(1!==e&&(t.width*=e),1!==o&&(t.height*=o))}function U(t,e,o){const{app:i}=t,n=i&&i.editor;let s=e;if(n.editing){const i=t.__layout;let{width:h,height:a}=i.boxBounds;switch(h*=o-e,a*=e-o,n.resizeDirection){case E:case D:s=o,i.affectScaleOrRotation?t.moveInner(-h/2,0):t.x-=h/2;break;case N:case M:i.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case H:case L:i.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=s;const h=t.__;h.__autoWidth||(t.width*=s),h.__autoHeight||(t.height*=s)}function Z(t,e,o){P.scale(t.__.path,e,o),t.path=t.__.path}function q(t,e,o){P.scalePoints(t.__.points,e,o),t.points=t.__.points}function J(t,e,o){const{children:i}=t;for(let t=0;t<i.length;t++)j.a=e,j.d=o,i[t].transform(j,!0)}const K=i.prototype;function T(t,e,o,i){var n,s=arguments.length,h=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(h=(s<3?n(h):s>3?n(e,o,h):n(e,o))||h);return s>3&&h&&Object.defineProperty(e,o,h),h}K.scaleResize=function(t,e=t,o){const i=this;o||i.editConfig&&"scale"===i.editConfig.editSize?(i.scaleX*=t,i.scaleY*=e):(t<0&&(i.scaleX*=-1,t=-t),e<0&&(i.scaleY*=-1,e=-e),this.__scaleResize(t,e))},K.__scaleResize=function(t,e){Q(this,t,e)},K.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},K.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},n.prototype.__scaleResize=function(t,e){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?U(this,t,e):Q(this,t,e)},s.prototype.__scaleResize=function(t,e){Z(this,t,e)},h.prototype.__scaleResize=function(t,e){this.pathInputed?Z(this,t,e):this.points?q(this,t,e):this.width*=t},a.prototype.__scaleResize=function(t,e){this.pathInputed?Z(this,t,e):this.points?q(this,t,e):Q(this,t,e)},c.prototype.__scaleResize=function(t,e){J(this,t,e)},r.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?J(this,t,e):(Q(this,t,e),this.__.resizeChildren&&J(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;let V=class extends r{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}};T([_(class extends l{})],V.prototype,"__",void 0),T([u("x")],V.prototype,"flow",void 0),V=T([f()],V);const $={},tt={"top-left":"from",top:"center","top-right":"to",right:"to","bottom-right":"to",bottom:"center","bottom-left":"from",left:"from",center:"center","baseline-left":"from","baseline-center":"center","baseline-right":"to"},et={"top-left":"from",top:"from","top-right":"from",right:"center","bottom-right":"to",bottom:"to","bottom-left":"to",left:"center",center:"center","baseline-left":"to","baseline-center":"to","baseline-right":"to"};function ot(t,e,o){const i=t.__,{contentBounds:n}=t.__layout;g.toPoint(o,e,n,$),e.x=i.__autoWidth?n.x:$.x,e.y=i.__autoHeight?n.y:$.y}const{move:it}=p;function nt(t,e,o,i,n,s){const{children:h}=t;let a,c,{x:r,start:l}=e,_=i;r+=o;for(let t=0,o=e.count;t<o;t++)a=h[s?l-t:l+t],a.__.inFlow&&0!==a.__.visible?(c=a.__flowBounds,"from"!==n&&(_=i+(e.height-c.height)/("center"===n?2:1)),it(a,r-c.x,_-c.y),r+=c.width+e.gap):o++}function st(t,e,o){const i="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[i]+=t.count?e[i]+t.gap:e[i],t.list.push(e),t.count++}const ht={};function at(t,e){const{gap:o,flowAlign:i,flowWrap:n,__autoWidth:s,__autoHeight:h}=t.__,a=n&&(e?!s:!h);return"object"==typeof o?(ht.xGap=o.x||0,ht.yGap=o.y||0):ht.xGap=ht.yGap=o,ht.isAutoXGap="string"==typeof ht.xGap&&!s,ht.isAutoYGap="string"==typeof ht.yGap&&!h,ht.complex=a||"top-left"!==i||t.__hasGrow||ht.isAutoXGap||ht.isAutoYGap,ht.wrap=a,ht.complex&&(ht.isFitXGap="fit"===ht.xGap&&!s,ht.isFitYGap="fit"===ht.yGap&&!h,"object"==typeof i?(ht.contentAlign=i.content||"top-left",ht.rowXAlign=i.x||"from",ht.rowYAlign=i.y||"from"):(ht.contentAlign=i,ht.rowXAlign=tt[i],ht.rowYAlign=et[i])),ht}function ct(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function rt(t,e,o,i){const{count:n}=t;n>1&&(o>t[e]||i)&&(t.gap=(o-t[e])/(n-1),t[e]=o)}function lt(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:_t}=d;function ut(t,e,o,i){let n,s,h,a=0,c=e.hasRangeSize&&[],{grow:r,start:l}=e;const _=e.width<o?(o-e.width)/r:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__widthGrow)&&(h=ft(n,n.__flowBounds,_*s),h?(a+=h,r-=s):c&&(n.__.widthRange?c.unshift(n):c.push(n))):o++;a&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__widthGrow,n=e/o*i,h=ft(t,s=t.__flowBounds,s.width+n),e-=n-h,o-=i}))}(c,a,r)}function ft(t,e,o){const{widthRange:i,lockRatio:n}=t.__,s=i?_t(o,i):o,h=s/e.width;return t.scaleResize(h,n?h:1),e.width=s,o-s}const{within:gt}=d;function pt(t,e,o,i){let n,s,h,a=0,c=e.hasRangeSize&&[],{grow:r,start:l}=e;const _=e.height<o?(o-e.height)/r:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__heightGrow)&&(h=dt(n,n.__flowBounds,_*s),h?(a+=h,r-=s):c&&(n.__.heightRange?c.unshift(n):c.push(n))):o++;a&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__heightGrow,n=e/o*i,h=dt(t,s=t.__flowBounds,s.height+n),e-=n-h,o-=i}))}(c,a,r)}function dt(t,e,o){const{heightRange:i,lockRatio:n}=t.__,s=i?gt(o,i):o,h=s/e.height;return t.scaleResize(n?h:1,h),e.height=s,o-s}const{move:wt}=p;function yt(t,e){const o="width",{children:i,itemBox:n}=t,s=at(t,!0),{complex:h,wrap:a,xGap:c,yGap:r,isAutoXGap:l,isFitXGap:_}=s;if(!i.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},f=l?0:c;let g,p,d,w,y,{x:x,y:b,width:G,height:m}=t.__layout.contentBounds;for(let s=0,c=i.length;s<c;s++)g=i[w=e?c-1-s:s],g.__.inFlow&&0!==g.__.visible&&(p=lt(g,n),h?(g.__flowBounds=p,y||(y=ct(w,f)),a&&y.count&&y.width+p.width>G&&(y.grow?ut(t,y,G,e):l&&rt(y,o,G,_),st(u,y,o),y=ct(w,f)),d=p.width,g.__widthGrow&&(y.grow+=g.__widthGrow,d=0,g.__.widthRange&&(y.hasRangeSize=!0)),g.__heightGrow&&dt(g,p,m),y.width+=y.count?d+f:d,y.height=Math.max(y.height,p.height),y.count++):(wt(g,x-p.x,b-p.y),x+=p.width+f));if(h){const{isAutoYGap:i,isFitYGap:n,contentAlign:h,rowXAlign:c,rowYAlign:f}=s;y.count&&(y.grow?ut(t,y,G,e):l&&rt(y,o,G,_),a&&st(u,y,o)),a?(i?rt(u,"height",m,n):u.gap=r,function(t,e,o,i){ot(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=tt[o]),"from"!==i)){let t;for(let o=0,s=n.length;o<s;o++)t=n[o],t.x=e.width-t.width,"center"===i&&(t.x/=2)}}(t,u,h,c),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:a,y:c}=e;for(let r=0,l=n.length;r<l;r++)h=n[s?l-1-r:r],nt(t,h,a,c,o,i),c+=h.height+e.gap}(t,u,f,e)):(ot(t,y,h),nt(t,y,0,y.y,f,e))}}const{move:xt}=p;function bt(t,e,o,i,n,s){const{children:h}=t;let a,c,{y:r,start:l}=e,_=o;r+=i;for(let t=0,i=e.count;t<i;t++)a=h[s?l-t:l+t],a.__.inFlow&&0!==a.__.visible?(c=a.__flowBounds,"from"!==n&&(_=o+(e.width-c.width)/("center"===n?2:1)),xt(a,_-c.x,r-c.y),r+=c.height+e.gap):i++}const{move:Gt}=p;function mt(t,e){const o="height",{children:i,itemBox:n}=t,s=at(t,!1),{complex:h,wrap:a,xGap:c,yGap:r,isAutoYGap:l,isFitYGap:_}=s;if(!i.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},f=l?0:r;let g,p,d,w,y,{x:x,y:b,width:G,height:m}=t.__layout.contentBounds;for(let s=0,c=i.length;s<c;s++)g=i[w=e?c-1-s:s],g.__.inFlow&&0!==g.__.visible&&(p=lt(g,n),h?(g.__flowBounds=p,y||(y=ct(w,f)),a&&y.count&&y.height+p.height>m&&(y.grow&&pt(t,y,m,e),l&&rt(y,o,m,_),st(u,y,o),y=ct(w,f)),d=p.height,g.__heightGrow&&(y.grow+=g.__heightGrow,d=0,g.__.heightRange&&(y.hasRangeSize=!0)),g.__widthGrow&&ft(g,p,G),y.height+=y.count?d+f:d,y.width=Math.max(y.width,p.width),y.count++):(Gt(g,x-p.x,b-p.y),b+=p.height+f));if(h){const{isAutoXGap:i,isFitXGap:n,contentAlign:h,rowXAlign:r,rowYAlign:f}=s;y.count&&(y.grow&&pt(t,y,m,e),l&&rt(y,o,m,_),a&&st(u,y,o)),a?(i?rt(u,"width",G,n):u.gap=c,function(t,e,o,i){ot(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=et[o]),"from"!==i)){let t;for(let o=0,s=n.length;o<s;o++)t=n[o],t.y=e.height-t.height,"center"===i&&(t.y/=2)}}(t,u,h,f),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:a,y:c}=e;for(let r=0,l=n.length;r<l;r++)h=n[s?l-1-r:r],bt(t,h,a,c,o,i),a+=h.width+e.gap}(t,u,r,e)):(ot(t,y,h),bt(t,y,y.x,0,r,e))}}function Bt(t){return w(t,(t=>y({set(e){const o="number"==typeof e?e:0;"autoWidth"===t?this.__widthGrow=o:this.__heightGrow=o,!o||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,e)&&x(this)}})))}const Rt=b.prototype,zt=r.prototype,{__updateBoxBounds:At}=c.prototype;u(!1)(Rt,"flow"),G(0)(Rt,"gap"),G("top-left")(Rt,"flowAlign"),G(!1)(Rt,"flowWrap"),G("box")(Rt,"itemBox"),G(!0)(Rt,"inFlow"),Bt()(Rt,"autoWidth"),Bt()(Rt,"autoHeight"),G()(Rt,"lockRatio"),G()(Rt,"autoBox"),G()(Rt,"widthRange"),G()(Rt,"heightRange");const{copyAndSpread:kt}=m;zt.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:e}=this;switch(t&&(this.leafer.created=!1),e){case"x":case!0:yt(this);break;case"y":mt(this);break;case"x-reverse":yt(this,!0);break;case"y-reverse":mt(this,!0)}t&&(this.leafer.created=!0)},zt.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),kt(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},zt.__updateBoxBounds=function(t){const e=this.__;if(this.children.length){const{flow:o}=e;if(e.__autoSide){o&&!t?this.__updateRectBoxBounds():At.call(this);const{boxBounds:i}=this.__layout;e.__autoSize||(e.__autoWidth?(o||(i.width+=i.x,i.x=0),i.height=e.height,i.y=0):(o||(i.height+=i.y,i.y=0),i.width=e.width,i.x=0)),o&&t&&e.padding&&kt(i,i,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();o&&this.__updateContentBounds()}else this.__updateRectBoxBounds()};export{V as Flow,P as PathScaler,Q as scaleResize,U as scaleResizeFontSize,J as scaleResizeGroup,Z as scaleResizePath,q as scaleResizePoints};
1
+ import{PathCommandMap as t,MatrixHelper as e,Direction9 as o,Leaf as i,Text as n,Path as s,Line as h,Polygon as a,Group as c,Box as r,BoxData as l,dataProcessor as _,autoLayoutType as u,registerUI as f,AlignHelper as g,PointHelper as p,MathHelper as d,decorateLeafAttr as w,attr as y,doBoundsType as x,UI as b,boundsType as G,BoundsHelper as m}from"@leafer-ui/draw";const{M:B,L:R,C:z,Q:A,Z:k,N:v,D:S,X:F,G:X,F:Y,O:C,P:W,U:O}=t,P={scale(t,e,o){if(!t)return;let i,n=0,s=t.length;for(;n<s;)switch(i=t[n],i){case B:case R:I(t,e,o,n,1),n+=3;break;case z:I(t,e,o,n,3),n+=7;break;case A:I(t,e,o,n,2),n+=5;break;case k:n+=1;break;case v:I(t,e,o,n,2),n+=5;break;case S:I(t,e,o,n,2),n+=9;break;case F:I(t,e,o,n,2),n+=6;break;case X:I(t,e,o,n,2),n+=9;break;case Y:I(t,e,o,n,2),n+=5;break;case C:t[n]=X,t.splice(n+4,0,t[n+3],0),I(t,e,o,n,2),n+=9,s+=2;break;case W:t[n]=Y,t.splice(n+4,0,t[n+3]),I(t,e,o,n,2),n+=5,s+=1;break;case O:I(t,e,o,n,2),n+=6}},scalePoints(t,e,o,i,n){for(let s=n?i+1:0,h=n?s+2*n:t.length;s<h;s+=2)t[s]*=e,t[s+1]*=o}},{scalePoints:I}=P,j=e.get(),{topLeft:E,top:H,topRight:L,right:M,bottom:D,left:N}=o;function Q(t,e,o){t.pathInputed?Z(t,e,o):(1!==e&&(t.width*=e),1!==o&&(t.height*=o))}function U(t,e,o){const{app:i}=t,n=i&&i.editor;let s=e;if(n.editing){const i=t.__layout;let{width:h,height:a}=i.boxBounds;switch(h*=o-e,a*=e-o,n.resizeDirection){case H:case D:s=o,i.affectScaleOrRotation?t.moveInner(-h/2,0):t.x-=h/2;break;case N:case M:i.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case E:case L:i.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=s;const h=t.__;h.__autoWidth||(t.width*=s),h.__autoHeight||(t.height*=s)}function Z(t,e,o){P.scale(t.__.path,e,o),t.path=t.__.path}function q(t,e,o){const{points:i}=t;"object"==typeof i[0]?i.forEach((t=>{t.x*=e,t.y*=o})):P.scalePoints(i,e,o),t.points=i}function J(t,e,o){const{children:i}=t;for(let t=0;t<i.length;t++)j.a=e,j.d=o,i[t].transform(j,!0)}const K=i.prototype;function T(t,e,o,i){var n,s=arguments.length,h=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(h=(s<3?n(h):s>3?n(e,o,h):n(e,o))||h);return s>3&&h&&Object.defineProperty(e,o,h),h}K.scaleResize=function(t,e=t,o){const i=this;o||i.editConfig&&"scale"===i.editConfig.editSize?(i.scaleX*=t,i.scaleY*=e):(t<0&&(i.scaleX*=-1,t=-t),e<0&&(i.scaleY*=-1,e=-e),this.__scaleResize(t,e))},K.__scaleResize=function(t,e){Q(this,t,e)},K.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},K.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},n.prototype.__scaleResize=function(t,e){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?U(this,t,e):Q(this,t,e)},s.prototype.__scaleResize=function(t,e){Z(this,t,e)},h.prototype.__scaleResize=function(t,e){this.pathInputed?Z(this,t,e):this.points?q(this,t,e):this.width*=t},a.prototype.__scaleResize=function(t,e){this.pathInputed?Z(this,t,e):this.points?q(this,t,e):Q(this,t,e)},c.prototype.__scaleResize=function(t,e){J(this,t,e)},r.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?J(this,t,e):(Q(this,t,e),this.__.resizeChildren&&J(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;let V=class extends r{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}};T([_(class extends l{})],V.prototype,"__",void 0),T([u("x")],V.prototype,"flow",void 0),V=T([f()],V);const $={},tt={"top-left":"from",top:"center","top-right":"to",right:"to","bottom-right":"to",bottom:"center","bottom-left":"from",left:"from",center:"center","baseline-left":"from","baseline-center":"center","baseline-right":"to"},et={"top-left":"from",top:"from","top-right":"from",right:"center","bottom-right":"to",bottom:"to","bottom-left":"to",left:"center",center:"center","baseline-left":"to","baseline-center":"to","baseline-right":"to"};function ot(t,e,o){const i=t.__,{contentBounds:n}=t.__layout;g.toPoint(o,e,n,$),e.x=i.__autoWidth?n.x:$.x,e.y=i.__autoHeight?n.y:$.y}const{move:it}=p;function nt(t,e,o,i,n,s){const{children:h}=t;let a,c,{x:r,start:l}=e,_=i;r+=o;for(let t=0,o=e.count;t<o;t++)a=h[s?l-t:l+t],a.__.inFlow&&0!==a.__.visible?(c=a.__flowBounds,"from"!==n&&(_=i+(e.height-c.height)/("center"===n?2:1)),it(a,r-c.x,_-c.y),r+=c.width+e.gap):o++}function st(t,e,o){const i="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[i]+=t.count?e[i]+t.gap:e[i],t.list.push(e),t.count++}const ht={};function at(t,e){const{gap:o,flowAlign:i,flowWrap:n,__autoWidth:s,__autoHeight:h}=t.__,a=n&&(e?!s:!h);return"object"==typeof o?(ht.xGap=o.x||0,ht.yGap=o.y||0):ht.xGap=ht.yGap=o,ht.isAutoXGap="string"==typeof ht.xGap&&!s,ht.isAutoYGap="string"==typeof ht.yGap&&!h,ht.complex=a||"top-left"!==i||t.__hasGrow||ht.isAutoXGap||ht.isAutoYGap,ht.wrap=a,ht.complex&&(ht.isFitXGap="fit"===ht.xGap&&!s,ht.isFitYGap="fit"===ht.yGap&&!h,"object"==typeof i?(ht.contentAlign=i.content||"top-left",ht.rowXAlign=i.x||"from",ht.rowYAlign=i.y||"from"):(ht.contentAlign=i,ht.rowXAlign=tt[i],ht.rowYAlign=et[i])),ht}function ct(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function rt(t,e,o,i){const{count:n}=t;n>1&&(o>t[e]||i)&&(t.gap=(o-t[e])/(n-1),t[e]=o)}function lt(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:_t}=d;function ut(t,e,o,i){let n,s,h,a=0,c=e.hasRangeSize&&[],{grow:r,start:l}=e;const _=e.width<o?(o-e.width)/r:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__widthGrow)&&(h=ft(n,n.__flowBounds,_*s),h?(a+=h,r-=s):c&&(n.__.widthRange?c.unshift(n):c.push(n))):o++;a&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__widthGrow,n=e/o*i,h=ft(t,s=t.__flowBounds,s.width+n),e-=n-h,o-=i}))}(c,a,r)}function ft(t,e,o){const{widthRange:i,lockRatio:n}=t.__,s=i?_t(o,i):o,h=s/e.width;return t.scaleResize(h,n?h:1),e.width=s,o-s}const{within:gt}=d;function pt(t,e,o,i){let n,s,h,a=0,c=e.hasRangeSize&&[],{grow:r,start:l}=e;const _=e.height<o?(o-e.height)/r:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__heightGrow)&&(h=dt(n,n.__flowBounds,_*s),h?(a+=h,r-=s):c&&(n.__.heightRange?c.unshift(n):c.push(n))):o++;a&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__heightGrow,n=e/o*i,h=dt(t,s=t.__flowBounds,s.height+n),e-=n-h,o-=i}))}(c,a,r)}function dt(t,e,o){const{heightRange:i,lockRatio:n}=t.__,s=i?gt(o,i):o,h=s/e.height;return t.scaleResize(n?h:1,h),e.height=s,o-s}const{move:wt}=p;function yt(t,e){const o="width",{children:i,itemBox:n}=t,s=at(t,!0),{complex:h,wrap:a,xGap:c,yGap:r,isAutoXGap:l,isFitXGap:_}=s;if(!i.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},f=l?0:c;let g,p,d,w,y,{x:x,y:b,width:G,height:m}=t.__layout.contentBounds;for(let s=0,c=i.length;s<c;s++)g=i[w=e?c-1-s:s],g.__.inFlow&&0!==g.__.visible&&(p=lt(g,n),h?(g.__flowBounds=p,y||(y=ct(w,f)),a&&y.count&&y.width+p.width>G&&(y.grow?ut(t,y,G,e):l&&rt(y,o,G,_),st(u,y,o),y=ct(w,f)),d=p.width,g.__widthGrow&&(y.grow+=g.__widthGrow,d=0,g.__.widthRange&&(y.hasRangeSize=!0)),g.__heightGrow&&dt(g,p,m),y.width+=y.count?d+f:d,y.height=Math.max(y.height,p.height),y.count++):(wt(g,x-p.x,b-p.y),x+=p.width+f));if(h){const{isAutoYGap:i,isFitYGap:n,contentAlign:h,rowXAlign:c,rowYAlign:f}=s;y.count&&(y.grow?ut(t,y,G,e):l&&rt(y,o,G,_),a&&st(u,y,o)),a?(i?rt(u,"height",m,n):u.gap=r,function(t,e,o,i){ot(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=tt[o]),"from"!==i)){let t;for(let o=0,s=n.length;o<s;o++)t=n[o],t.x=e.width-t.width,"center"===i&&(t.x/=2)}}(t,u,h,c),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:a,y:c}=e;for(let r=0,l=n.length;r<l;r++)h=n[s?l-1-r:r],nt(t,h,a,c,o,i),c+=h.height+e.gap}(t,u,f,e)):(ot(t,y,h),nt(t,y,0,y.y,f,e))}}const{move:xt}=p;function bt(t,e,o,i,n,s){const{children:h}=t;let a,c,{y:r,start:l}=e,_=o;r+=i;for(let t=0,i=e.count;t<i;t++)a=h[s?l-t:l+t],a.__.inFlow&&0!==a.__.visible?(c=a.__flowBounds,"from"!==n&&(_=o+(e.width-c.width)/("center"===n?2:1)),xt(a,_-c.x,r-c.y),r+=c.height+e.gap):i++}const{move:Gt}=p;function mt(t,e){const o="height",{children:i,itemBox:n}=t,s=at(t,!1),{complex:h,wrap:a,xGap:c,yGap:r,isAutoYGap:l,isFitYGap:_}=s;if(!i.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},f=l?0:r;let g,p,d,w,y,{x:x,y:b,width:G,height:m}=t.__layout.contentBounds;for(let s=0,c=i.length;s<c;s++)g=i[w=e?c-1-s:s],g.__.inFlow&&0!==g.__.visible&&(p=lt(g,n),h?(g.__flowBounds=p,y||(y=ct(w,f)),a&&y.count&&y.height+p.height>m&&(y.grow&&pt(t,y,m,e),l&&rt(y,o,m,_),st(u,y,o),y=ct(w,f)),d=p.height,g.__heightGrow&&(y.grow+=g.__heightGrow,d=0,g.__.heightRange&&(y.hasRangeSize=!0)),g.__widthGrow&&ft(g,p,G),y.height+=y.count?d+f:d,y.width=Math.max(y.width,p.width),y.count++):(Gt(g,x-p.x,b-p.y),b+=p.height+f));if(h){const{isAutoXGap:i,isFitXGap:n,contentAlign:h,rowXAlign:r,rowYAlign:f}=s;y.count&&(y.grow&&pt(t,y,m,e),l&&rt(y,o,m,_),a&&st(u,y,o)),a?(i?rt(u,"width",G,n):u.gap=c,function(t,e,o,i){ot(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=et[o]),"from"!==i)){let t;for(let o=0,s=n.length;o<s;o++)t=n[o],t.y=e.height-t.height,"center"===i&&(t.y/=2)}}(t,u,h,f),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:a,y:c}=e;for(let r=0,l=n.length;r<l;r++)h=n[s?l-1-r:r],bt(t,h,a,c,o,i),a+=h.width+e.gap}(t,u,r,e)):(ot(t,y,h),bt(t,y,y.x,0,r,e))}}function Bt(t){return w(t,(t=>y({set(e){const o="number"==typeof e?e:0;"autoWidth"===t?this.__widthGrow=o:this.__heightGrow=o,!o||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,e)&&x(this)}})))}const Rt=b.prototype,zt=r.prototype,{__updateBoxBounds:At}=c.prototype;u(!1)(Rt,"flow"),G(0)(Rt,"gap"),G("top-left")(Rt,"flowAlign"),G(!1)(Rt,"flowWrap"),G("box")(Rt,"itemBox"),G(!0)(Rt,"inFlow"),Bt()(Rt,"autoWidth"),Bt()(Rt,"autoHeight"),G()(Rt,"lockRatio"),G()(Rt,"autoBox"),G()(Rt,"widthRange"),G()(Rt,"heightRange");const{copyAndSpread:kt}=m;zt.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:e}=this;switch(t&&(this.leafer.created=!1),e){case"x":case!0:yt(this);break;case"y":mt(this);break;case"x-reverse":yt(this,!0);break;case"y-reverse":mt(this,!0)}t&&(this.leafer.created=!0)},zt.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),kt(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},zt.__updateBoxBounds=function(t){const e=this.__;if(this.children.length){const{flow:o}=e;if(e.__autoSide){o&&!t?this.__updateRectBoxBounds():At.call(this);const{boxBounds:i}=this.__layout;e.__autoSize||(e.__autoWidth?(o||(i.width+=i.x,i.x=0),i.height=e.height,i.y=0):(o||(i.height+=i.y,i.y=0),i.width=e.width,i.x=0)),o&&t&&e.padding&&kt(i,i,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();o&&this.__updateContentBounds()}else this.__updateRectBoxBounds()};export{V as Flow,P as PathScaler,Q as scaleResize,U as scaleResizeFontSize,J as scaleResizeGroup,Z as scaleResizePath,q as scaleResizePoints};
package/dist/flow.js CHANGED
@@ -128,8 +128,9 @@ this.LeaferIN.flow = (function (exports, draw) {
128
128
  leaf.path = leaf.__.path;
129
129
  }
130
130
  function scaleResizePoints(leaf, scaleX, scaleY) {
131
- PathScaler.scalePoints(leaf.__.points, scaleX, scaleY);
132
- leaf.points = leaf.__.points;
131
+ const { points } = leaf;
132
+ typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
133
+ leaf.points = points;
133
134
  }
134
135
  function scaleResizeGroup(group, scaleX, scaleY) {
135
136
  const { children } = group;
package/dist/flow.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer-ui/draw");const{M:e,L:o,C:i,Q:n,Z:s,N:h,D:a,X:r,G:c,F:l,O:_,P:u,U:p}=t.PathCommandMap,d={scale(t,d,g){if(!t)return;let w,y=0,x=t.length;for(;y<x;)switch(w=t[y],w){case e:case o:f(t,d,g,y,1),y+=3;break;case i:f(t,d,g,y,3),y+=7;break;case n:f(t,d,g,y,2),y+=5;break;case s:y+=1;break;case h:f(t,d,g,y,2),y+=5;break;case a:f(t,d,g,y,2),y+=9;break;case r:f(t,d,g,y,2),y+=6;break;case c:f(t,d,g,y,2),y+=9;break;case l:f(t,d,g,y,2),y+=5;break;case _:t[y]=c,t.splice(y+4,0,t[y+3],0),f(t,d,g,y,2),y+=9,x+=2;break;case u:t[y]=l,t.splice(y+4,0,t[y+3]),f(t,d,g,y,2),y+=5,x+=1;break;case p:f(t,d,g,y,2),y+=6}},scalePoints(t,e,o,i,n){for(let s=n?i+1:0,h=n?s+2*n:t.length;s<h;s+=2)t[s]*=e,t[s+1]*=o}},{scalePoints:f}=d,g=t.MatrixHelper.get(),{topLeft:w,top:y,topRight:x,right:b,bottom:G,left:B}=t.Direction9;function R(t,e,o){t.pathInputed?z(t,e,o):(1!==e&&(t.width*=e),1!==o&&(t.height*=o))}function m(t,e,o){const{app:i}=t,n=i&&i.editor;let s=e;if(n.editing){const i=t.__layout;let{width:h,height:a}=i.boxBounds;switch(h*=o-e,a*=e-o,n.resizeDirection){case y:case G:s=o,i.affectScaleOrRotation?t.moveInner(-h/2,0):t.x-=h/2;break;case B:case b:i.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case w:case x:i.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=s;const h=t.__;h.__autoWidth||(t.width*=s),h.__autoHeight||(t.height*=s)}function z(t,e,o){d.scale(t.__.path,e,o),t.path=t.__.path}function A(t,e,o){d.scalePoints(t.__.points,e,o),t.points=t.__.points}function k(t,e,o){const{children:i}=t;for(let t=0;t<i.length;t++)g.a=e,g.d=o,i[t].transform(g,!0)}const F=t.Leaf.prototype;function v(t,e,o,i){var n,s=arguments.length,h=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(h=(s<3?n(h):s>3?n(e,o,h):n(e,o))||h);return s>3&&h&&Object.defineProperty(e,o,h),h}F.scaleResize=function(t,e=t,o){const i=this;o||i.editConfig&&"scale"===i.editConfig.editSize?(i.scaleX*=t,i.scaleY*=e):(t<0&&(i.scaleX*=-1,t=-t),e<0&&(i.scaleY*=-1,e=-e),this.__scaleResize(t,e))},F.__scaleResize=function(t,e){R(this,t,e)},F.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},F.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},t.Text.prototype.__scaleResize=function(t,e){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?m(this,t,e):R(this,t,e)},t.Path.prototype.__scaleResize=function(t,e){z(this,t,e)},t.Line.prototype.__scaleResize=function(t,e){this.pathInputed?z(this,t,e):this.points?A(this,t,e):this.width*=t},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?z(this,t,e):this.points?A(this,t,e):R(this,t,e)},t.Group.prototype.__scaleResize=function(t,e){k(this,t,e)},t.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?k(this,t,e):(R(this,t,e),this.__.resizeChildren&&k(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class S extends t.BoxData{}exports.Flow=class extends t.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},v([t.dataProcessor(S)],exports.Flow.prototype,"__",void 0),v([t.autoLayoutType("x")],exports.Flow.prototype,"flow",void 0),exports.Flow=v([t.registerUI()],exports.Flow);const P={},H={"top-left":"from",top:"center","top-right":"to",right:"to","bottom-right":"to",bottom:"center","bottom-left":"from",left:"from",center:"center","baseline-left":"from","baseline-center":"center","baseline-right":"to"},X={"top-left":"from",top:"from","top-right":"from",right:"center","bottom-right":"to",bottom:"to","bottom-left":"to",left:"center",center:"center","baseline-left":"to","baseline-center":"to","baseline-right":"to"};function C(e,o,i){const n=e.__,{contentBounds:s}=e.__layout;t.AlignHelper.toPoint(i,o,s,P),o.x=n.__autoWidth?s.x:P.x,o.y=n.__autoHeight?s.y:P.y}const{move:T}=t.PointHelper;function Y(t,e,o,i,n,s){const{children:h}=t;let a,r,{x:c,start:l}=e,_=i;c+=o;for(let t=0,o=e.count;t<o;t++)a=h[s?l-t:l+t],a.__.inFlow&&0!==a.__.visible?(r=a.__flowBounds,"from"!==n&&(_=i+(e.height-r.height)/("center"===n?2:1)),T(a,c-r.x,_-r.y),c+=r.width+e.gap):o++}function W(t,e,o){const i="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[i]+=t.count?e[i]+t.gap:e[i],t.list.push(e),t.count++}const I={};function L(t,e){const{gap:o,flowAlign:i,flowWrap:n,__autoWidth:s,__autoHeight:h}=t.__,a=n&&(e?!s:!h);return"object"==typeof o?(I.xGap=o.x||0,I.yGap=o.y||0):I.xGap=I.yGap=o,I.isAutoXGap="string"==typeof I.xGap&&!s,I.isAutoYGap="string"==typeof I.yGap&&!h,I.complex=a||"top-left"!==i||t.__hasGrow||I.isAutoXGap||I.isAutoYGap,I.wrap=a,I.complex&&(I.isFitXGap="fit"===I.xGap&&!s,I.isFitYGap="fit"===I.yGap&&!h,"object"==typeof i?(I.contentAlign=i.content||"top-left",I.rowXAlign=i.x||"from",I.rowYAlign=i.y||"from"):(I.contentAlign=i,I.rowXAlign=H[i],I.rowYAlign=X[i])),I}function O(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function M(t,e,o,i){const{count:n}=t;n>1&&(o>t[e]||i)&&(t.gap=(o-t[e])/(n-1),t[e]=o)}function j(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:D}=t.MathHelper;function E(t,e,o,i){let n,s,h,a=0,r=e.hasRangeSize&&[],{grow:c,start:l}=e;const _=e.width<o?(o-e.width)/c:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__widthGrow)&&(h=U(n,n.__flowBounds,_*s),h?(a+=h,c-=s):r&&(n.__.widthRange?r.unshift(n):r.push(n))):o++;a&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__widthGrow,n=e/o*i,h=U(t,s=t.__flowBounds,s.width+n),e-=n-h,o-=i}))}(r,a,c)}function U(t,e,o){const{widthRange:i,lockRatio:n}=t.__,s=i?D(o,i):o,h=s/e.width;return t.scaleResize(h,n?h:1),e.width=s,o-s}const{within:N}=t.MathHelper;function q(t,e,o,i){let n,s,h,a=0,r=e.hasRangeSize&&[],{grow:c,start:l}=e;const _=e.height<o?(o-e.height)/c:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__heightGrow)&&(h=Q(n,n.__flowBounds,_*s),h?(a+=h,c-=s):r&&(n.__.heightRange?r.unshift(n):r.push(n))):o++;a&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__heightGrow,n=e/o*i,h=Q(t,s=t.__flowBounds,s.height+n),e-=n-h,o-=i}))}(r,a,c)}function Q(t,e,o){const{heightRange:i,lockRatio:n}=t.__,s=i?N(o,i):o,h=s/e.height;return t.scaleResize(n?h:1,h),e.height=s,o-s}const{move:Z}=t.PointHelper;function J(t,e){const o="width",{children:i,itemBox:n}=t,s=L(t,!0),{complex:h,wrap:a,xGap:r,yGap:c,isAutoXGap:l,isFitXGap:_}=s;if(!i.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},p=l?0:r;let d,f,g,w,y,{x:x,y:b,width:G,height:B}=t.__layout.contentBounds;for(let s=0,r=i.length;s<r;s++)d=i[w=e?r-1-s:s],d.__.inFlow&&0!==d.__.visible&&(f=j(d,n),h?(d.__flowBounds=f,y||(y=O(w,p)),a&&y.count&&y.width+f.width>G&&(y.grow?E(t,y,G,e):l&&M(y,o,G,_),W(u,y,o),y=O(w,p)),g=f.width,d.__widthGrow&&(y.grow+=d.__widthGrow,g=0,d.__.widthRange&&(y.hasRangeSize=!0)),d.__heightGrow&&Q(d,f,B),y.width+=y.count?g+p:g,y.height=Math.max(y.height,f.height),y.count++):(Z(d,x-f.x,b-f.y),x+=f.width+p));if(h){const{isAutoYGap:i,isFitYGap:n,contentAlign:h,rowXAlign:r,rowYAlign:p}=s;y.count&&(y.grow?E(t,y,G,e):l&&M(y,o,G,_),a&&W(u,y,o)),a?(i?M(u,"height",B,n):u.gap=c,function(t,e,o,i){C(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=H[o]),"from"!==i)){let t;for(let o=0,s=n.length;o<s;o++)t=n[o],t.x=e.width-t.width,"center"===i&&(t.x/=2)}}(t,u,h,r),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:a,y:r}=e;for(let c=0,l=n.length;c<l;c++)h=n[s?l-1-c:c],Y(t,h,a,r,o,i),r+=h.height+e.gap}(t,u,p,e)):(C(t,y,h),Y(t,y,0,y.y,p,e))}}const{move:K}=t.PointHelper;function V(t,e,o,i,n,s){const{children:h}=t;let a,r,{y:c,start:l}=e,_=o;c+=i;for(let t=0,i=e.count;t<i;t++)a=h[s?l-t:l+t],a.__.inFlow&&0!==a.__.visible?(r=a.__flowBounds,"from"!==n&&(_=o+(e.width-r.width)/("center"===n?2:1)),K(a,_-r.x,c-r.y),c+=r.height+e.gap):i++}const{move:$}=t.PointHelper;function tt(t,e){const o="height",{children:i,itemBox:n}=t,s=L(t,!1),{complex:h,wrap:a,xGap:r,yGap:c,isAutoYGap:l,isFitYGap:_}=s;if(!i.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},p=l?0:c;let d,f,g,w,y,{x:x,y:b,width:G,height:B}=t.__layout.contentBounds;for(let s=0,r=i.length;s<r;s++)d=i[w=e?r-1-s:s],d.__.inFlow&&0!==d.__.visible&&(f=j(d,n),h?(d.__flowBounds=f,y||(y=O(w,p)),a&&y.count&&y.height+f.height>B&&(y.grow&&q(t,y,B,e),l&&M(y,o,B,_),W(u,y,o),y=O(w,p)),g=f.height,d.__heightGrow&&(y.grow+=d.__heightGrow,g=0,d.__.heightRange&&(y.hasRangeSize=!0)),d.__widthGrow&&U(d,f,G),y.height+=y.count?g+p:g,y.width=Math.max(y.width,f.width),y.count++):($(d,x-f.x,b-f.y),b+=f.height+p));if(h){const{isAutoXGap:i,isFitXGap:n,contentAlign:h,rowXAlign:c,rowYAlign:p}=s;y.count&&(y.grow&&q(t,y,B,e),l&&M(y,o,B,_),a&&W(u,y,o)),a?(i?M(u,"width",G,n):u.gap=r,function(t,e,o,i){C(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=X[o]),"from"!==i)){let t;for(let o=0,s=n.length;o<s;o++)t=n[o],t.y=e.height-t.height,"center"===i&&(t.y/=2)}}(t,u,h,p),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:a,y:r}=e;for(let c=0,l=n.length;c<l;c++)h=n[s?l-1-c:c],V(t,h,a,r,o,i),a+=h.width+e.gap}(t,u,c,e)):(C(t,y,h),V(t,y,y.x,0,c,e))}}function et(e){return t.decorateLeafAttr(e,(e=>t.attr({set(o){const i="number"==typeof o?o:0;"autoWidth"===e?this.__widthGrow=i:this.__heightGrow=i,!i||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(e,o)&&t.doBoundsType(this)}})))}const ot=t.UI.prototype,it=t.Box.prototype,{__updateBoxBounds:nt}=t.Group.prototype;t.autoLayoutType(!1)(ot,"flow"),t.boundsType(0)(ot,"gap"),t.boundsType("top-left")(ot,"flowAlign"),t.boundsType(!1)(ot,"flowWrap"),t.boundsType("box")(ot,"itemBox"),t.boundsType(!0)(ot,"inFlow"),et()(ot,"autoWidth"),et()(ot,"autoHeight"),t.boundsType()(ot,"lockRatio"),t.boundsType()(ot,"autoBox"),t.boundsType()(ot,"widthRange"),t.boundsType()(ot,"heightRange");const{copyAndSpread:st}=t.BoundsHelper;it.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:e}=this;switch(t&&(this.leafer.created=!1),e){case"x":case!0:J(this);break;case"y":tt(this);break;case"x-reverse":J(this,!0);break;case"y-reverse":tt(this,!0)}t&&(this.leafer.created=!0)},it.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),st(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},it.__updateBoxBounds=function(t){const e=this.__;if(this.children.length){const{flow:o}=e;if(e.__autoSide){o&&!t?this.__updateRectBoxBounds():nt.call(this);const{boxBounds:i}=this.__layout;e.__autoSize||(e.__autoWidth?(o||(i.width+=i.x,i.x=0),i.height=e.height,i.y=0):(o||(i.height+=i.y,i.y=0),i.width=e.width,i.x=0)),o&&t&&e.padding&&st(i,i,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();o&&this.__updateContentBounds()}else this.__updateRectBoxBounds()},exports.PathScaler=d,exports.scaleResize=R,exports.scaleResizeFontSize=m,exports.scaleResizeGroup=k,exports.scaleResizePath=z,exports.scaleResizePoints=A;
1
+ "use strict";var t=require("@leafer-ui/draw");const{M:e,L:o,C:i,Q:n,Z:s,N:h,D:a,X:r,G:c,F:l,O:_,P:u,U:p}=t.PathCommandMap,d={scale(t,d,g){if(!t)return;let w,y=0,x=t.length;for(;y<x;)switch(w=t[y],w){case e:case o:f(t,d,g,y,1),y+=3;break;case i:f(t,d,g,y,3),y+=7;break;case n:f(t,d,g,y,2),y+=5;break;case s:y+=1;break;case h:f(t,d,g,y,2),y+=5;break;case a:f(t,d,g,y,2),y+=9;break;case r:f(t,d,g,y,2),y+=6;break;case c:f(t,d,g,y,2),y+=9;break;case l:f(t,d,g,y,2),y+=5;break;case _:t[y]=c,t.splice(y+4,0,t[y+3],0),f(t,d,g,y,2),y+=9,x+=2;break;case u:t[y]=l,t.splice(y+4,0,t[y+3]),f(t,d,g,y,2),y+=5,x+=1;break;case p:f(t,d,g,y,2),y+=6}},scalePoints(t,e,o,i,n){for(let s=n?i+1:0,h=n?s+2*n:t.length;s<h;s+=2)t[s]*=e,t[s+1]*=o}},{scalePoints:f}=d,g=t.MatrixHelper.get(),{topLeft:w,top:y,topRight:x,right:b,bottom:G,left:B}=t.Direction9;function R(t,e,o){t.pathInputed?z(t,e,o):(1!==e&&(t.width*=e),1!==o&&(t.height*=o))}function m(t,e,o){const{app:i}=t,n=i&&i.editor;let s=e;if(n.editing){const i=t.__layout;let{width:h,height:a}=i.boxBounds;switch(h*=o-e,a*=e-o,n.resizeDirection){case y:case G:s=o,i.affectScaleOrRotation?t.moveInner(-h/2,0):t.x-=h/2;break;case B:case b:i.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case w:case x:i.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=s;const h=t.__;h.__autoWidth||(t.width*=s),h.__autoHeight||(t.height*=s)}function z(t,e,o){d.scale(t.__.path,e,o),t.path=t.__.path}function A(t,e,o){const{points:i}=t;"object"==typeof i[0]?i.forEach((t=>{t.x*=e,t.y*=o})):d.scalePoints(i,e,o),t.points=i}function k(t,e,o){const{children:i}=t;for(let t=0;t<i.length;t++)g.a=e,g.d=o,i[t].transform(g,!0)}const F=t.Leaf.prototype;function v(t,e,o,i){var n,s=arguments.length,h=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(h=(s<3?n(h):s>3?n(e,o,h):n(e,o))||h);return s>3&&h&&Object.defineProperty(e,o,h),h}F.scaleResize=function(t,e=t,o){const i=this;o||i.editConfig&&"scale"===i.editConfig.editSize?(i.scaleX*=t,i.scaleY*=e):(t<0&&(i.scaleX*=-1,t=-t),e<0&&(i.scaleY*=-1,e=-e),this.__scaleResize(t,e))},F.__scaleResize=function(t,e){R(this,t,e)},F.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},F.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},t.Text.prototype.__scaleResize=function(t,e){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?m(this,t,e):R(this,t,e)},t.Path.prototype.__scaleResize=function(t,e){z(this,t,e)},t.Line.prototype.__scaleResize=function(t,e){this.pathInputed?z(this,t,e):this.points?A(this,t,e):this.width*=t},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?z(this,t,e):this.points?A(this,t,e):R(this,t,e)},t.Group.prototype.__scaleResize=function(t,e){k(this,t,e)},t.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?k(this,t,e):(R(this,t,e),this.__.resizeChildren&&k(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class S extends t.BoxData{}exports.Flow=class extends t.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},v([t.dataProcessor(S)],exports.Flow.prototype,"__",void 0),v([t.autoLayoutType("x")],exports.Flow.prototype,"flow",void 0),exports.Flow=v([t.registerUI()],exports.Flow);const P={},H={"top-left":"from",top:"center","top-right":"to",right:"to","bottom-right":"to",bottom:"center","bottom-left":"from",left:"from",center:"center","baseline-left":"from","baseline-center":"center","baseline-right":"to"},X={"top-left":"from",top:"from","top-right":"from",right:"center","bottom-right":"to",bottom:"to","bottom-left":"to",left:"center",center:"center","baseline-left":"to","baseline-center":"to","baseline-right":"to"};function C(e,o,i){const n=e.__,{contentBounds:s}=e.__layout;t.AlignHelper.toPoint(i,o,s,P),o.x=n.__autoWidth?s.x:P.x,o.y=n.__autoHeight?s.y:P.y}const{move:T}=t.PointHelper;function Y(t,e,o,i,n,s){const{children:h}=t;let a,r,{x:c,start:l}=e,_=i;c+=o;for(let t=0,o=e.count;t<o;t++)a=h[s?l-t:l+t],a.__.inFlow&&0!==a.__.visible?(r=a.__flowBounds,"from"!==n&&(_=i+(e.height-r.height)/("center"===n?2:1)),T(a,c-r.x,_-r.y),c+=r.width+e.gap):o++}function W(t,e,o){const i="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[i]+=t.count?e[i]+t.gap:e[i],t.list.push(e),t.count++}const I={};function L(t,e){const{gap:o,flowAlign:i,flowWrap:n,__autoWidth:s,__autoHeight:h}=t.__,a=n&&(e?!s:!h);return"object"==typeof o?(I.xGap=o.x||0,I.yGap=o.y||0):I.xGap=I.yGap=o,I.isAutoXGap="string"==typeof I.xGap&&!s,I.isAutoYGap="string"==typeof I.yGap&&!h,I.complex=a||"top-left"!==i||t.__hasGrow||I.isAutoXGap||I.isAutoYGap,I.wrap=a,I.complex&&(I.isFitXGap="fit"===I.xGap&&!s,I.isFitYGap="fit"===I.yGap&&!h,"object"==typeof i?(I.contentAlign=i.content||"top-left",I.rowXAlign=i.x||"from",I.rowYAlign=i.y||"from"):(I.contentAlign=i,I.rowXAlign=H[i],I.rowYAlign=X[i])),I}function O(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function M(t,e,o,i){const{count:n}=t;n>1&&(o>t[e]||i)&&(t.gap=(o-t[e])/(n-1),t[e]=o)}function j(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:D}=t.MathHelper;function E(t,e,o,i){let n,s,h,a=0,r=e.hasRangeSize&&[],{grow:c,start:l}=e;const _=e.width<o?(o-e.width)/c:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__widthGrow)&&(h=U(n,n.__flowBounds,_*s),h?(a+=h,c-=s):r&&(n.__.widthRange?r.unshift(n):r.push(n))):o++;a&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__widthGrow,n=e/o*i,h=U(t,s=t.__flowBounds,s.width+n),e-=n-h,o-=i}))}(r,a,c)}function U(t,e,o){const{widthRange:i,lockRatio:n}=t.__,s=i?D(o,i):o,h=s/e.width;return t.scaleResize(h,n?h:1),e.width=s,o-s}const{within:N}=t.MathHelper;function q(t,e,o,i){let n,s,h,a=0,r=e.hasRangeSize&&[],{grow:c,start:l}=e;const _=e.height<o?(o-e.height)/c:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__heightGrow)&&(h=Q(n,n.__flowBounds,_*s),h?(a+=h,c-=s):r&&(n.__.heightRange?r.unshift(n):r.push(n))):o++;a&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__heightGrow,n=e/o*i,h=Q(t,s=t.__flowBounds,s.height+n),e-=n-h,o-=i}))}(r,a,c)}function Q(t,e,o){const{heightRange:i,lockRatio:n}=t.__,s=i?N(o,i):o,h=s/e.height;return t.scaleResize(n?h:1,h),e.height=s,o-s}const{move:Z}=t.PointHelper;function J(t,e){const o="width",{children:i,itemBox:n}=t,s=L(t,!0),{complex:h,wrap:a,xGap:r,yGap:c,isAutoXGap:l,isFitXGap:_}=s;if(!i.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},p=l?0:r;let d,f,g,w,y,{x:x,y:b,width:G,height:B}=t.__layout.contentBounds;for(let s=0,r=i.length;s<r;s++)d=i[w=e?r-1-s:s],d.__.inFlow&&0!==d.__.visible&&(f=j(d,n),h?(d.__flowBounds=f,y||(y=O(w,p)),a&&y.count&&y.width+f.width>G&&(y.grow?E(t,y,G,e):l&&M(y,o,G,_),W(u,y,o),y=O(w,p)),g=f.width,d.__widthGrow&&(y.grow+=d.__widthGrow,g=0,d.__.widthRange&&(y.hasRangeSize=!0)),d.__heightGrow&&Q(d,f,B),y.width+=y.count?g+p:g,y.height=Math.max(y.height,f.height),y.count++):(Z(d,x-f.x,b-f.y),x+=f.width+p));if(h){const{isAutoYGap:i,isFitYGap:n,contentAlign:h,rowXAlign:r,rowYAlign:p}=s;y.count&&(y.grow?E(t,y,G,e):l&&M(y,o,G,_),a&&W(u,y,o)),a?(i?M(u,"height",B,n):u.gap=c,function(t,e,o,i){C(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=H[o]),"from"!==i)){let t;for(let o=0,s=n.length;o<s;o++)t=n[o],t.x=e.width-t.width,"center"===i&&(t.x/=2)}}(t,u,h,r),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:a,y:r}=e;for(let c=0,l=n.length;c<l;c++)h=n[s?l-1-c:c],Y(t,h,a,r,o,i),r+=h.height+e.gap}(t,u,p,e)):(C(t,y,h),Y(t,y,0,y.y,p,e))}}const{move:K}=t.PointHelper;function V(t,e,o,i,n,s){const{children:h}=t;let a,r,{y:c,start:l}=e,_=o;c+=i;for(let t=0,i=e.count;t<i;t++)a=h[s?l-t:l+t],a.__.inFlow&&0!==a.__.visible?(r=a.__flowBounds,"from"!==n&&(_=o+(e.width-r.width)/("center"===n?2:1)),K(a,_-r.x,c-r.y),c+=r.height+e.gap):i++}const{move:$}=t.PointHelper;function tt(t,e){const o="height",{children:i,itemBox:n}=t,s=L(t,!1),{complex:h,wrap:a,xGap:r,yGap:c,isAutoYGap:l,isFitYGap:_}=s;if(!i.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},p=l?0:c;let d,f,g,w,y,{x:x,y:b,width:G,height:B}=t.__layout.contentBounds;for(let s=0,r=i.length;s<r;s++)d=i[w=e?r-1-s:s],d.__.inFlow&&0!==d.__.visible&&(f=j(d,n),h?(d.__flowBounds=f,y||(y=O(w,p)),a&&y.count&&y.height+f.height>B&&(y.grow&&q(t,y,B,e),l&&M(y,o,B,_),W(u,y,o),y=O(w,p)),g=f.height,d.__heightGrow&&(y.grow+=d.__heightGrow,g=0,d.__.heightRange&&(y.hasRangeSize=!0)),d.__widthGrow&&U(d,f,G),y.height+=y.count?g+p:g,y.width=Math.max(y.width,f.width),y.count++):($(d,x-f.x,b-f.y),b+=f.height+p));if(h){const{isAutoXGap:i,isFitXGap:n,contentAlign:h,rowXAlign:c,rowYAlign:p}=s;y.count&&(y.grow&&q(t,y,B,e),l&&M(y,o,B,_),a&&W(u,y,o)),a?(i?M(u,"width",G,n):u.gap=r,function(t,e,o,i){C(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=X[o]),"from"!==i)){let t;for(let o=0,s=n.length;o<s;o++)t=n[o],t.y=e.height-t.height,"center"===i&&(t.y/=2)}}(t,u,h,p),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:a,y:r}=e;for(let c=0,l=n.length;c<l;c++)h=n[s?l-1-c:c],V(t,h,a,r,o,i),a+=h.width+e.gap}(t,u,c,e)):(C(t,y,h),V(t,y,y.x,0,c,e))}}function et(e){return t.decorateLeafAttr(e,(e=>t.attr({set(o){const i="number"==typeof o?o:0;"autoWidth"===e?this.__widthGrow=i:this.__heightGrow=i,!i||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(e,o)&&t.doBoundsType(this)}})))}const ot=t.UI.prototype,it=t.Box.prototype,{__updateBoxBounds:nt}=t.Group.prototype;t.autoLayoutType(!1)(ot,"flow"),t.boundsType(0)(ot,"gap"),t.boundsType("top-left")(ot,"flowAlign"),t.boundsType(!1)(ot,"flowWrap"),t.boundsType("box")(ot,"itemBox"),t.boundsType(!0)(ot,"inFlow"),et()(ot,"autoWidth"),et()(ot,"autoHeight"),t.boundsType()(ot,"lockRatio"),t.boundsType()(ot,"autoBox"),t.boundsType()(ot,"widthRange"),t.boundsType()(ot,"heightRange");const{copyAndSpread:st}=t.BoundsHelper;it.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:e}=this;switch(t&&(this.leafer.created=!1),e){case"x":case!0:J(this);break;case"y":tt(this);break;case"x-reverse":J(this,!0);break;case"y-reverse":tt(this,!0)}t&&(this.leafer.created=!0)},it.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),st(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},it.__updateBoxBounds=function(t){const e=this.__;if(this.children.length){const{flow:o}=e;if(e.__autoSide){o&&!t?this.__updateRectBoxBounds():nt.call(this);const{boxBounds:i}=this.__layout;e.__autoSize||(e.__autoWidth?(o||(i.width+=i.x,i.x=0),i.height=e.height,i.y=0):(o||(i.height+=i.y,i.y=0),i.width=e.width,i.x=0)),o&&t&&e.padding&&st(i,i,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();o&&this.__updateContentBounds()}else this.__updateRectBoxBounds()},exports.PathScaler=d,exports.scaleResize=R,exports.scaleResizeFontSize=m,exports.scaleResizeGroup=k,exports.scaleResizePath=z,exports.scaleResizePoints=A;
package/dist/flow.min.js CHANGED
@@ -1 +1 @@
1
- this.LeaferIN=this.LeaferIN||{},this.LeaferIN.flow=function(t,e){"use strict";const{M:o,L:i,C:n,Q:s,Z:h,N:a,D:r,X:c,G:l,F:_,O:u,P:p,U:f}=e.PathCommandMap,d={scale(t,e,d){if(!t)return;let w,y=0,x=t.length;for(;y<x;)switch(w=t[y],w){case o:case i:g(t,e,d,y,1),y+=3;break;case n:g(t,e,d,y,3),y+=7;break;case s:g(t,e,d,y,2),y+=5;break;case h:y+=1;break;case a:g(t,e,d,y,2),y+=5;break;case r:g(t,e,d,y,2),y+=9;break;case c:g(t,e,d,y,2),y+=6;break;case l:g(t,e,d,y,2),y+=9;break;case _:g(t,e,d,y,2),y+=5;break;case u:t[y]=l,t.splice(y+4,0,t[y+3],0),g(t,e,d,y,2),y+=9,x+=2;break;case p:t[y]=_,t.splice(y+4,0,t[y+3]),g(t,e,d,y,2),y+=5,x+=1;break;case f:g(t,e,d,y,2),y+=6}},scalePoints(t,e,o,i,n){for(let s=n?i+1:0,h=n?s+2*n:t.length;s<h;s+=2)t[s]*=e,t[s+1]*=o}},{scalePoints:g}=d,w=e.MatrixHelper.get(),{topLeft:y,top:x,topRight:b,right:G,bottom:B,left:R}=e.Direction9;function m(t,e,o){t.pathInputed?A(t,e,o):(1!==e&&(t.width*=e),1!==o&&(t.height*=o))}function z(t,e,o){const{app:i}=t,n=i&&i.editor;let s=e;if(n.editing){const i=t.__layout;let{width:h,height:a}=i.boxBounds;switch(h*=o-e,a*=e-o,n.resizeDirection){case x:case B:s=o,i.affectScaleOrRotation?t.moveInner(-h/2,0):t.x-=h/2;break;case R:case G:i.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case y:case b:i.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=s;const h=t.__;h.__autoWidth||(t.width*=s),h.__autoHeight||(t.height*=s)}function A(t,e,o){d.scale(t.__.path,e,o),t.path=t.__.path}function k(t,e,o){d.scalePoints(t.__.points,e,o),t.points=t.__.points}function F(t,e,o){const{children:i}=t;for(let t=0;t<i.length;t++)w.a=e,w.d=o,i[t].transform(w,!0)}const S=e.Leaf.prototype;function v(t,e,o,i){var n,s=arguments.length,h=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(h=(s<3?n(h):s>3?n(e,o,h):n(e,o))||h);return s>3&&h&&Object.defineProperty(e,o,h),h}S.scaleResize=function(t,e=t,o){const i=this;o||i.editConfig&&"scale"===i.editConfig.editSize?(i.scaleX*=t,i.scaleY*=e):(t<0&&(i.scaleX*=-1,t=-t),e<0&&(i.scaleY*=-1,e=-e),this.__scaleResize(t,e))},S.__scaleResize=function(t,e){m(this,t,e)},S.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},S.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},e.Text.prototype.__scaleResize=function(t,e){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?z(this,t,e):m(this,t,e)},e.Path.prototype.__scaleResize=function(t,e){A(this,t,e)},e.Line.prototype.__scaleResize=function(t,e){this.pathInputed?A(this,t,e):this.points?k(this,t,e):this.width*=t},e.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?A(this,t,e):this.points?k(this,t,e):m(this,t,e)},e.Group.prototype.__scaleResize=function(t,e){F(this,t,e)},e.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?F(this,t,e):(m(this,t,e),this.__.resizeChildren&&F(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class P extends e.BoxData{}t.Flow=class extends e.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},v([e.dataProcessor(P)],t.Flow.prototype,"__",void 0),v([e.autoLayoutType("x")],t.Flow.prototype,"flow",void 0),t.Flow=v([e.registerUI()],t.Flow);const H={},X={"top-left":"from",top:"center","top-right":"to",right:"to","bottom-right":"to",bottom:"center","bottom-left":"from",left:"from",center:"center","baseline-left":"from","baseline-center":"center","baseline-right":"to"},C={"top-left":"from",top:"from","top-right":"from",right:"center","bottom-right":"to",bottom:"to","bottom-left":"to",left:"center",center:"center","baseline-left":"to","baseline-center":"to","baseline-right":"to"};function I(t,o,i){const n=t.__,{contentBounds:s}=t.__layout;e.AlignHelper.toPoint(i,o,s,H),o.x=n.__autoWidth?s.x:H.x,o.y=n.__autoHeight?s.y:H.y}const{move:L}=e.PointHelper;function T(t,e,o,i,n,s){const{children:h}=t;let a,r,{x:c,start:l}=e,_=i;c+=o;for(let t=0,o=e.count;t<o;t++)a=h[s?l-t:l+t],a.__.inFlow&&0!==a.__.visible?(r=a.__flowBounds,"from"!==n&&(_=i+(e.height-r.height)/("center"===n?2:1)),L(a,c-r.x,_-r.y),c+=r.width+e.gap):o++}function Y(t,e,o){const i="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[i]+=t.count?e[i]+t.gap:e[i],t.list.push(e),t.count++}const W={};function O(t,e){const{gap:o,flowAlign:i,flowWrap:n,__autoWidth:s,__autoHeight:h}=t.__,a=n&&(e?!s:!h);return"object"==typeof o?(W.xGap=o.x||0,W.yGap=o.y||0):W.xGap=W.yGap=o,W.isAutoXGap="string"==typeof W.xGap&&!s,W.isAutoYGap="string"==typeof W.yGap&&!h,W.complex=a||"top-left"!==i||t.__hasGrow||W.isAutoXGap||W.isAutoYGap,W.wrap=a,W.complex&&(W.isFitXGap="fit"===W.xGap&&!s,W.isFitYGap="fit"===W.yGap&&!h,"object"==typeof i?(W.contentAlign=i.content||"top-left",W.rowXAlign=i.x||"from",W.rowYAlign=i.y||"from"):(W.contentAlign=i,W.rowXAlign=X[i],W.rowYAlign=C[i])),W}function M(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function j(t,e,o,i){const{count:n}=t;n>1&&(o>t[e]||i)&&(t.gap=(o-t[e])/(n-1),t[e]=o)}function D(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:N}=e.MathHelper;function E(t,e,o,i){let n,s,h,a=0,r=e.hasRangeSize&&[],{grow:c,start:l}=e;const _=e.width<o?(o-e.width)/c:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__widthGrow)&&(h=U(n,n.__flowBounds,_*s),h?(a+=h,c-=s):r&&(n.__.widthRange?r.unshift(n):r.push(n))):o++;a&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__widthGrow,n=e/o*i,h=U(t,s=t.__flowBounds,s.width+n),e-=n-h,o-=i}))}(r,a,c)}function U(t,e,o){const{widthRange:i,lockRatio:n}=t.__,s=i?N(o,i):o,h=s/e.width;return t.scaleResize(h,n?h:1),e.width=s,o-s}const{within:Q}=e.MathHelper;function Z(t,e,o,i){let n,s,h,a=0,r=e.hasRangeSize&&[],{grow:c,start:l}=e;const _=e.height<o?(o-e.height)/c:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__heightGrow)&&(h=q(n,n.__flowBounds,_*s),h?(a+=h,c-=s):r&&(n.__.heightRange?r.unshift(n):r.push(n))):o++;a&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__heightGrow,n=e/o*i,h=q(t,s=t.__flowBounds,s.height+n),e-=n-h,o-=i}))}(r,a,c)}function q(t,e,o){const{heightRange:i,lockRatio:n}=t.__,s=i?Q(o,i):o,h=s/e.height;return t.scaleResize(n?h:1,h),e.height=s,o-s}const{move:J}=e.PointHelper;function K(t,e){const o="width",{children:i,itemBox:n}=t,s=O(t,!0),{complex:h,wrap:a,xGap:r,yGap:c,isAutoXGap:l,isFitXGap:_}=s;if(!i.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},p=l?0:r;let f,d,g,w,y,{x:x,y:b,width:G,height:B}=t.__layout.contentBounds;for(let s=0,r=i.length;s<r;s++)f=i[w=e?r-1-s:s],f.__.inFlow&&0!==f.__.visible&&(d=D(f,n),h?(f.__flowBounds=d,y||(y=M(w,p)),a&&y.count&&y.width+d.width>G&&(y.grow?E(t,y,G,e):l&&j(y,o,G,_),Y(u,y,o),y=M(w,p)),g=d.width,f.__widthGrow&&(y.grow+=f.__widthGrow,g=0,f.__.widthRange&&(y.hasRangeSize=!0)),f.__heightGrow&&q(f,d,B),y.width+=y.count?g+p:g,y.height=Math.max(y.height,d.height),y.count++):(J(f,x-d.x,b-d.y),x+=d.width+p));if(h){const{isAutoYGap:i,isFitYGap:n,contentAlign:h,rowXAlign:r,rowYAlign:p}=s;y.count&&(y.grow?E(t,y,G,e):l&&j(y,o,G,_),a&&Y(u,y,o)),a?(i?j(u,"height",B,n):u.gap=c,function(t,e,o,i){I(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=X[o]),"from"!==i)){let t;for(let o=0,s=n.length;o<s;o++)t=n[o],t.x=e.width-t.width,"center"===i&&(t.x/=2)}}(t,u,h,r),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:a,y:r}=e;for(let c=0,l=n.length;c<l;c++)h=n[s?l-1-c:c],T(t,h,a,r,o,i),r+=h.height+e.gap}(t,u,p,e)):(I(t,y,h),T(t,y,0,y.y,p,e))}}const{move:V}=e.PointHelper;function $(t,e,o,i,n,s){const{children:h}=t;let a,r,{y:c,start:l}=e,_=o;c+=i;for(let t=0,i=e.count;t<i;t++)a=h[s?l-t:l+t],a.__.inFlow&&0!==a.__.visible?(r=a.__flowBounds,"from"!==n&&(_=o+(e.width-r.width)/("center"===n?2:1)),V(a,_-r.x,c-r.y),c+=r.height+e.gap):i++}const{move:tt}=e.PointHelper;function et(t,e){const o="height",{children:i,itemBox:n}=t,s=O(t,!1),{complex:h,wrap:a,xGap:r,yGap:c,isAutoYGap:l,isFitYGap:_}=s;if(!i.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},p=l?0:c;let f,d,g,w,y,{x:x,y:b,width:G,height:B}=t.__layout.contentBounds;for(let s=0,r=i.length;s<r;s++)f=i[w=e?r-1-s:s],f.__.inFlow&&0!==f.__.visible&&(d=D(f,n),h?(f.__flowBounds=d,y||(y=M(w,p)),a&&y.count&&y.height+d.height>B&&(y.grow&&Z(t,y,B,e),l&&j(y,o,B,_),Y(u,y,o),y=M(w,p)),g=d.height,f.__heightGrow&&(y.grow+=f.__heightGrow,g=0,f.__.heightRange&&(y.hasRangeSize=!0)),f.__widthGrow&&U(f,d,G),y.height+=y.count?g+p:g,y.width=Math.max(y.width,d.width),y.count++):(tt(f,x-d.x,b-d.y),b+=d.height+p));if(h){const{isAutoXGap:i,isFitXGap:n,contentAlign:h,rowXAlign:c,rowYAlign:p}=s;y.count&&(y.grow&&Z(t,y,B,e),l&&j(y,o,B,_),a&&Y(u,y,o)),a?(i?j(u,"width",G,n):u.gap=r,function(t,e,o,i){I(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=C[o]),"from"!==i)){let t;for(let o=0,s=n.length;o<s;o++)t=n[o],t.y=e.height-t.height,"center"===i&&(t.y/=2)}}(t,u,h,p),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:a,y:r}=e;for(let c=0,l=n.length;c<l;c++)h=n[s?l-1-c:c],$(t,h,a,r,o,i),a+=h.width+e.gap}(t,u,c,e)):(I(t,y,h),$(t,y,y.x,0,c,e))}}function ot(t){return e.decorateLeafAttr(t,(t=>e.attr({set(o){const i="number"==typeof o?o:0;"autoWidth"===t?this.__widthGrow=i:this.__heightGrow=i,!i||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,o)&&e.doBoundsType(this)}})))}const it=e.UI.prototype,nt=e.Box.prototype,{__updateBoxBounds:st}=e.Group.prototype;e.autoLayoutType(!1)(it,"flow"),e.boundsType(0)(it,"gap"),e.boundsType("top-left")(it,"flowAlign"),e.boundsType(!1)(it,"flowWrap"),e.boundsType("box")(it,"itemBox"),e.boundsType(!0)(it,"inFlow"),ot()(it,"autoWidth"),ot()(it,"autoHeight"),e.boundsType()(it,"lockRatio"),e.boundsType()(it,"autoBox"),e.boundsType()(it,"widthRange"),e.boundsType()(it,"heightRange");const{copyAndSpread:ht}=e.BoundsHelper;return nt.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:e}=this;switch(t&&(this.leafer.created=!1),e){case"x":case!0:K(this);break;case"y":et(this);break;case"x-reverse":K(this,!0);break;case"y-reverse":et(this,!0)}t&&(this.leafer.created=!0)},nt.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),ht(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},nt.__updateBoxBounds=function(t){const e=this.__;if(this.children.length){const{flow:o}=e;if(e.__autoSide){o&&!t?this.__updateRectBoxBounds():st.call(this);const{boxBounds:i}=this.__layout;e.__autoSize||(e.__autoWidth?(o||(i.width+=i.x,i.x=0),i.height=e.height,i.y=0):(o||(i.height+=i.y,i.y=0),i.width=e.width,i.x=0)),o&&t&&e.padding&&ht(i,i,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();o&&this.__updateContentBounds()}else this.__updateRectBoxBounds()},t.PathScaler=d,t.scaleResize=m,t.scaleResizeFontSize=z,t.scaleResizeGroup=F,t.scaleResizePath=A,t.scaleResizePoints=k,t}({},LeaferUI);
1
+ this.LeaferIN=this.LeaferIN||{},this.LeaferIN.flow=function(t,e){"use strict";const{M:o,L:i,C:n,Q:s,Z:h,N:a,D:c,X:r,G:l,F:_,O:u,P:p,U:f}=e.PathCommandMap,d={scale(t,e,d){if(!t)return;let w,y=0,x=t.length;for(;y<x;)switch(w=t[y],w){case o:case i:g(t,e,d,y,1),y+=3;break;case n:g(t,e,d,y,3),y+=7;break;case s:g(t,e,d,y,2),y+=5;break;case h:y+=1;break;case a:g(t,e,d,y,2),y+=5;break;case c:g(t,e,d,y,2),y+=9;break;case r:g(t,e,d,y,2),y+=6;break;case l:g(t,e,d,y,2),y+=9;break;case _:g(t,e,d,y,2),y+=5;break;case u:t[y]=l,t.splice(y+4,0,t[y+3],0),g(t,e,d,y,2),y+=9,x+=2;break;case p:t[y]=_,t.splice(y+4,0,t[y+3]),g(t,e,d,y,2),y+=5,x+=1;break;case f:g(t,e,d,y,2),y+=6}},scalePoints(t,e,o,i,n){for(let s=n?i+1:0,h=n?s+2*n:t.length;s<h;s+=2)t[s]*=e,t[s+1]*=o}},{scalePoints:g}=d,w=e.MatrixHelper.get(),{topLeft:y,top:x,topRight:b,right:G,bottom:B,left:R}=e.Direction9;function m(t,e,o){t.pathInputed?A(t,e,o):(1!==e&&(t.width*=e),1!==o&&(t.height*=o))}function z(t,e,o){const{app:i}=t,n=i&&i.editor;let s=e;if(n.editing){const i=t.__layout;let{width:h,height:a}=i.boxBounds;switch(h*=o-e,a*=e-o,n.resizeDirection){case x:case B:s=o,i.affectScaleOrRotation?t.moveInner(-h/2,0):t.x-=h/2;break;case R:case G:i.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case y:case b:i.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=s;const h=t.__;h.__autoWidth||(t.width*=s),h.__autoHeight||(t.height*=s)}function A(t,e,o){d.scale(t.__.path,e,o),t.path=t.__.path}function k(t,e,o){const{points:i}=t;"object"==typeof i[0]?i.forEach((t=>{t.x*=e,t.y*=o})):d.scalePoints(i,e,o),t.points=i}function F(t,e,o){const{children:i}=t;for(let t=0;t<i.length;t++)w.a=e,w.d=o,i[t].transform(w,!0)}const S=e.Leaf.prototype;function v(t,e,o,i){var n,s=arguments.length,h=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(h=(s<3?n(h):s>3?n(e,o,h):n(e,o))||h);return s>3&&h&&Object.defineProperty(e,o,h),h}S.scaleResize=function(t,e=t,o){const i=this;o||i.editConfig&&"scale"===i.editConfig.editSize?(i.scaleX*=t,i.scaleY*=e):(t<0&&(i.scaleX*=-1,t=-t),e<0&&(i.scaleY*=-1,e=-e),this.__scaleResize(t,e))},S.__scaleResize=function(t,e){m(this,t,e)},S.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},S.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},e.Text.prototype.__scaleResize=function(t,e){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?z(this,t,e):m(this,t,e)},e.Path.prototype.__scaleResize=function(t,e){A(this,t,e)},e.Line.prototype.__scaleResize=function(t,e){this.pathInputed?A(this,t,e):this.points?k(this,t,e):this.width*=t},e.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?A(this,t,e):this.points?k(this,t,e):m(this,t,e)},e.Group.prototype.__scaleResize=function(t,e){F(this,t,e)},e.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?F(this,t,e):(m(this,t,e),this.__.resizeChildren&&F(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class P extends e.BoxData{}t.Flow=class extends e.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},v([e.dataProcessor(P)],t.Flow.prototype,"__",void 0),v([e.autoLayoutType("x")],t.Flow.prototype,"flow",void 0),t.Flow=v([e.registerUI()],t.Flow);const H={},X={"top-left":"from",top:"center","top-right":"to",right:"to","bottom-right":"to",bottom:"center","bottom-left":"from",left:"from",center:"center","baseline-left":"from","baseline-center":"center","baseline-right":"to"},C={"top-left":"from",top:"from","top-right":"from",right:"center","bottom-right":"to",bottom:"to","bottom-left":"to",left:"center",center:"center","baseline-left":"to","baseline-center":"to","baseline-right":"to"};function I(t,o,i){const n=t.__,{contentBounds:s}=t.__layout;e.AlignHelper.toPoint(i,o,s,H),o.x=n.__autoWidth?s.x:H.x,o.y=n.__autoHeight?s.y:H.y}const{move:L}=e.PointHelper;function T(t,e,o,i,n,s){const{children:h}=t;let a,c,{x:r,start:l}=e,_=i;r+=o;for(let t=0,o=e.count;t<o;t++)a=h[s?l-t:l+t],a.__.inFlow&&0!==a.__.visible?(c=a.__flowBounds,"from"!==n&&(_=i+(e.height-c.height)/("center"===n?2:1)),L(a,r-c.x,_-c.y),r+=c.width+e.gap):o++}function Y(t,e,o){const i="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[i]+=t.count?e[i]+t.gap:e[i],t.list.push(e),t.count++}const W={};function O(t,e){const{gap:o,flowAlign:i,flowWrap:n,__autoWidth:s,__autoHeight:h}=t.__,a=n&&(e?!s:!h);return"object"==typeof o?(W.xGap=o.x||0,W.yGap=o.y||0):W.xGap=W.yGap=o,W.isAutoXGap="string"==typeof W.xGap&&!s,W.isAutoYGap="string"==typeof W.yGap&&!h,W.complex=a||"top-left"!==i||t.__hasGrow||W.isAutoXGap||W.isAutoYGap,W.wrap=a,W.complex&&(W.isFitXGap="fit"===W.xGap&&!s,W.isFitYGap="fit"===W.yGap&&!h,"object"==typeof i?(W.contentAlign=i.content||"top-left",W.rowXAlign=i.x||"from",W.rowYAlign=i.y||"from"):(W.contentAlign=i,W.rowXAlign=X[i],W.rowYAlign=C[i])),W}function M(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function j(t,e,o,i){const{count:n}=t;n>1&&(o>t[e]||i)&&(t.gap=(o-t[e])/(n-1),t[e]=o)}function D(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:E}=e.MathHelper;function N(t,e,o,i){let n,s,h,a=0,c=e.hasRangeSize&&[],{grow:r,start:l}=e;const _=e.width<o?(o-e.width)/r:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__widthGrow)&&(h=U(n,n.__flowBounds,_*s),h?(a+=h,r-=s):c&&(n.__.widthRange?c.unshift(n):c.push(n))):o++;a&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__widthGrow,n=e/o*i,h=U(t,s=t.__flowBounds,s.width+n),e-=n-h,o-=i}))}(c,a,r)}function U(t,e,o){const{widthRange:i,lockRatio:n}=t.__,s=i?E(o,i):o,h=s/e.width;return t.scaleResize(h,n?h:1),e.width=s,o-s}const{within:Q}=e.MathHelper;function Z(t,e,o,i){let n,s,h,a=0,c=e.hasRangeSize&&[],{grow:r,start:l}=e;const _=e.height<o?(o-e.height)/r:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__heightGrow)&&(h=q(n,n.__flowBounds,_*s),h?(a+=h,r-=s):c&&(n.__.heightRange?c.unshift(n):c.push(n))):o++;a&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__heightGrow,n=e/o*i,h=q(t,s=t.__flowBounds,s.height+n),e-=n-h,o-=i}))}(c,a,r)}function q(t,e,o){const{heightRange:i,lockRatio:n}=t.__,s=i?Q(o,i):o,h=s/e.height;return t.scaleResize(n?h:1,h),e.height=s,o-s}const{move:J}=e.PointHelper;function K(t,e){const o="width",{children:i,itemBox:n}=t,s=O(t,!0),{complex:h,wrap:a,xGap:c,yGap:r,isAutoXGap:l,isFitXGap:_}=s;if(!i.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},p=l?0:c;let f,d,g,w,y,{x:x,y:b,width:G,height:B}=t.__layout.contentBounds;for(let s=0,c=i.length;s<c;s++)f=i[w=e?c-1-s:s],f.__.inFlow&&0!==f.__.visible&&(d=D(f,n),h?(f.__flowBounds=d,y||(y=M(w,p)),a&&y.count&&y.width+d.width>G&&(y.grow?N(t,y,G,e):l&&j(y,o,G,_),Y(u,y,o),y=M(w,p)),g=d.width,f.__widthGrow&&(y.grow+=f.__widthGrow,g=0,f.__.widthRange&&(y.hasRangeSize=!0)),f.__heightGrow&&q(f,d,B),y.width+=y.count?g+p:g,y.height=Math.max(y.height,d.height),y.count++):(J(f,x-d.x,b-d.y),x+=d.width+p));if(h){const{isAutoYGap:i,isFitYGap:n,contentAlign:h,rowXAlign:c,rowYAlign:p}=s;y.count&&(y.grow?N(t,y,G,e):l&&j(y,o,G,_),a&&Y(u,y,o)),a?(i?j(u,"height",B,n):u.gap=r,function(t,e,o,i){I(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=X[o]),"from"!==i)){let t;for(let o=0,s=n.length;o<s;o++)t=n[o],t.x=e.width-t.width,"center"===i&&(t.x/=2)}}(t,u,h,c),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:a,y:c}=e;for(let r=0,l=n.length;r<l;r++)h=n[s?l-1-r:r],T(t,h,a,c,o,i),c+=h.height+e.gap}(t,u,p,e)):(I(t,y,h),T(t,y,0,y.y,p,e))}}const{move:V}=e.PointHelper;function $(t,e,o,i,n,s){const{children:h}=t;let a,c,{y:r,start:l}=e,_=o;r+=i;for(let t=0,i=e.count;t<i;t++)a=h[s?l-t:l+t],a.__.inFlow&&0!==a.__.visible?(c=a.__flowBounds,"from"!==n&&(_=o+(e.width-c.width)/("center"===n?2:1)),V(a,_-c.x,r-c.y),r+=c.height+e.gap):i++}const{move:tt}=e.PointHelper;function et(t,e){const o="height",{children:i,itemBox:n}=t,s=O(t,!1),{complex:h,wrap:a,xGap:c,yGap:r,isAutoYGap:l,isFitYGap:_}=s;if(!i.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},p=l?0:r;let f,d,g,w,y,{x:x,y:b,width:G,height:B}=t.__layout.contentBounds;for(let s=0,c=i.length;s<c;s++)f=i[w=e?c-1-s:s],f.__.inFlow&&0!==f.__.visible&&(d=D(f,n),h?(f.__flowBounds=d,y||(y=M(w,p)),a&&y.count&&y.height+d.height>B&&(y.grow&&Z(t,y,B,e),l&&j(y,o,B,_),Y(u,y,o),y=M(w,p)),g=d.height,f.__heightGrow&&(y.grow+=f.__heightGrow,g=0,f.__.heightRange&&(y.hasRangeSize=!0)),f.__widthGrow&&U(f,d,G),y.height+=y.count?g+p:g,y.width=Math.max(y.width,d.width),y.count++):(tt(f,x-d.x,b-d.y),b+=d.height+p));if(h){const{isAutoXGap:i,isFitXGap:n,contentAlign:h,rowXAlign:r,rowYAlign:p}=s;y.count&&(y.grow&&Z(t,y,B,e),l&&j(y,o,B,_),a&&Y(u,y,o)),a?(i?j(u,"width",G,n):u.gap=c,function(t,e,o,i){I(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=C[o]),"from"!==i)){let t;for(let o=0,s=n.length;o<s;o++)t=n[o],t.y=e.height-t.height,"center"===i&&(t.y/=2)}}(t,u,h,p),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:a,y:c}=e;for(let r=0,l=n.length;r<l;r++)h=n[s?l-1-r:r],$(t,h,a,c,o,i),a+=h.width+e.gap}(t,u,r,e)):(I(t,y,h),$(t,y,y.x,0,r,e))}}function ot(t){return e.decorateLeafAttr(t,(t=>e.attr({set(o){const i="number"==typeof o?o:0;"autoWidth"===t?this.__widthGrow=i:this.__heightGrow=i,!i||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,o)&&e.doBoundsType(this)}})))}const it=e.UI.prototype,nt=e.Box.prototype,{__updateBoxBounds:st}=e.Group.prototype;e.autoLayoutType(!1)(it,"flow"),e.boundsType(0)(it,"gap"),e.boundsType("top-left")(it,"flowAlign"),e.boundsType(!1)(it,"flowWrap"),e.boundsType("box")(it,"itemBox"),e.boundsType(!0)(it,"inFlow"),ot()(it,"autoWidth"),ot()(it,"autoHeight"),e.boundsType()(it,"lockRatio"),e.boundsType()(it,"autoBox"),e.boundsType()(it,"widthRange"),e.boundsType()(it,"heightRange");const{copyAndSpread:ht}=e.BoundsHelper;return nt.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:e}=this;switch(t&&(this.leafer.created=!1),e){case"x":case!0:K(this);break;case"y":et(this);break;case"x-reverse":K(this,!0);break;case"y-reverse":et(this,!0)}t&&(this.leafer.created=!0)},nt.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),ht(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},nt.__updateBoxBounds=function(t){const e=this.__;if(this.children.length){const{flow:o}=e;if(e.__autoSide){o&&!t?this.__updateRectBoxBounds():st.call(this);const{boxBounds:i}=this.__layout;e.__autoSize||(e.__autoWidth?(o||(i.width+=i.x,i.x=0),i.height=e.height,i.y=0):(o||(i.height+=i.y,i.y=0),i.width=e.width,i.x=0)),o&&t&&e.padding&&ht(i,i,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();o&&this.__updateContentBounds()}else this.__updateRectBoxBounds()},t.PathScaler=d,t.scaleResize=m,t.scaleResizeFontSize=z,t.scaleResizeGroup=F,t.scaleResizePath=A,t.scaleResizePoints=k,t}({},LeaferUI);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/flow",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "@leafer-in/flow",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -34,9 +34,9 @@
34
34
  "leaferjs"
35
35
  ],
36
36
  "dependencies": {
37
- "@leafer-ui/draw": "^1.0.5",
38
- "@leafer-ui/interface": "^1.0.5",
39
- "@leafer-in/resize": "^1.0.5",
40
- "@leafer-in/interface": "^1.0.5"
37
+ "@leafer-ui/draw": "^1.0.6",
38
+ "@leafer-ui/interface": "^1.0.6",
39
+ "@leafer-in/resize": "^1.0.6",
40
+ "@leafer-in/interface": "^1.0.6"
41
41
  }
42
42
  }