@leafer-in/flow 1.0.0-rc.30 → 1.0.1
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 +716 -1
- package/dist/flow.esm.js +709 -1
- package/dist/flow.esm.min.js +1 -1
- package/dist/flow.js +720 -1
- package/dist/flow.min.cjs +1 -1
- package/dist/flow.min.js +1 -1
- package/package.json +5 -5
package/dist/flow.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer-
|
|
1
|
+
"use strict";var t=require("@leafer-ui/draw");const{M:e,L:o,C:i,Q:n,Z:s,N:h,D:r,X:a,G:c,F:l,O:_,P:p,U:u}=t.PathCommandMap,f={scale(t,f,d){if(!t)return;let w,x=0,y=t.length;for(;x<y;)switch(w=t[x],w){case e:case o:g(t,f,d,x,1),x+=3;break;case i:g(t,f,d,x,3),x+=7;break;case n:g(t,f,d,x,2),x+=5;break;case s:x+=1;break;case h:g(t,f,d,x,2),x+=5;break;case r:g(t,f,d,x,2),x+=9;break;case a:g(t,f,d,x,2),x+=6;break;case c:g(t,f,d,x,2),x+=9;break;case l:g(t,f,d,x,2),x+=5;break;case _:t[x]=c,t.splice(x+4,0,t[x+3],0),g(t,f,d,x,2),x+=9,y+=2;break;case p:t[x]=l,t.splice(x+4,0,t[x+3]),g(t,f,d,x,2),x+=5,y+=1;break;case u:g(t,f,d,x,2),x+=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}=f,d=t.MatrixHelper.get();function w(t,e,o){t.pathInputed?y(t,e,o):(1!==e&&(t.width*=e),1!==o&&(t.height*=o))}function x(t,e,o){const{width:i,height:n}=t.__localBoxBounds;1!==e?(t.fontSize*=e,t.y-=n*(e-o)/2):1!==o&&(t.fontSize*=o,t.x-=i*(o-e)/2)}function y(t,e,o){f.scale(t.__.path,e,o),t.path=t.__.path}function b(t,e,o){f.scalePoints(t.__.points,e,o),t.points=t.__.points}function G(t,e,o){const{children:i}=t;for(let t=0;t<i.length;t++)d.a=e,d.d=o,i[t].transform(d,!0)}const m=t.Leaf.prototype;function z(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 r=t.length-1;r>=0;r--)(n=t[r])&&(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}m.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))},m.__scaleResize=function(t,e){w(this,t,e)},m.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},m.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.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?x(this,t,e):w(this,t,e)},t.Path.prototype.__scaleResize=function(t,e){y(this,t,e)},t.Line.prototype.__scaleResize=function(t,e){this.pathInputed?y(this,t,e):this.points?b(this,t,e):this.width*=t},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?y(this,t,e):this.points?b(this,t,e):w(this,t,e)},t.Group.prototype.__scaleResize=function(t,e){G(this,t,e)},t.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?G(this,t,e):(w(this,t,e),this.__.resizeChildren&&G(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class R extends t.BoxData{}exports.Flow=class extends t.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},z([t.dataProcessor(R)],exports.Flow.prototype,"__",void 0),z([t.autoLayoutType("x")],exports.Flow.prototype,"flow",void 0),exports.Flow=z([t.registerUI()],exports.Flow);const B={},A={"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"},F={"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 k(e,o,i){t.AlignHelper.toPoint(i,o,e.__layout.contentBounds,B);const n=e.__;o.x=n.__autoWidth?0:B.x,o.y=n.__autoHeight?0:B.y}const{move:v}=t.PointHelper;function P(t,e,o,i,n,s){const{children:h}=t;let r,a,{x:c,start:l}=e,_=i;c+=o;for(let t=0,o=e.count;t<o;t++)r=h[s?l-t:l+t],r.__.inFlow&&0!==r.__.visible?(a=r.__flowBounds,"from"!==n&&(_=i+(e.height-a.height)/("center"===n?2:1)),v(r,c-a.x,_-a.y),c+=a.width+e.gap):o++}function S(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 X={};function H(t,e){const{gap:o,flowAlign:i,flowWrap:n,__autoWidth:s,__autoHeight:h}=t.__,r=n&&(e?!s:!h);return"object"==typeof o?(X.xGap=o.x||0,X.yGap=o.y||0):X.xGap=X.yGap=o,X.isAutoXGap="string"==typeof X.xGap&&!s,X.isAutoYGap="string"==typeof X.yGap&&!h,X.complex=r||"top-left"!==i||t.__hasGrow||X.isAutoXGap||X.isAutoYGap,X.wrap=r,X.complex&&(X.isFitXGap="fit"===X.xGap&&!s,X.isFitYGap="fit"===X.yGap&&!h,"object"==typeof i?(X.contentAlign=i.content||"top-left",X.rowXAlign=i.x||"from",X.rowYAlign=i.y||"from"):(X.contentAlign=i,X.rowXAlign=A[i],X.rowYAlign=F[i])),X}function Y(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function C(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 M(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:W}=t.MathHelper;function L(t,e,o,i){let n,s,h,r=0,a=e.hasRangeSize&&[],{grow:c,start:l}=e;const _=e.width<o?(o-e.width)/c:0,{children:p}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)n=p[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__widthGrow)&&(h=I(n,n.__flowBounds,_*s),h?(r+=h,c-=s):a&&(n.__.widthRange?a.unshift(n):a.push(n))):o++;r&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__widthGrow,n=e/o*i,h=I(t,s=t.__flowBounds,s.width+n),e-=n-h,o-=i}))}(a,r,c)}function I(t,e,o){const{widthRange:i,lockRatio:n}=t.__,s=i?W(o,i):o,h=s/e.width;return t.scaleResize(h,n?h:1),e.width=s,o-s}const{within:O}=t.MathHelper;function j(t,e,o,i){let n,s,h,r=0,a=e.hasRangeSize&&[],{grow:c,start:l}=e;const _=e.height<o?(o-e.height)/c:0,{children:p}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)n=p[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(s=n.__heightGrow)&&(h=E(n,n.__flowBounds,_*s),h?(r+=h,c-=s):a&&(n.__.heightRange?a.unshift(n):a.push(n))):o++;r&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__heightGrow,n=e/o*i,h=E(t,s=t.__flowBounds,s.height+n),e-=n-h,o-=i}))}(a,r,c)}function E(t,e,o){const{heightRange:i,lockRatio:n}=t.__,s=i?O(o,i):o,h=s/e.height;return t.scaleResize(n?h:1,h),e.height=s,o-s}const{move:U}=t.PointHelper;const{move:D}=t.PointHelper;function T(t,e,o,i,n,s){const{children:h}=t;let r,a,{y:c,start:l}=e,_=o;c+=i;for(let t=0,i=e.count;t<i;t++)r=h[s?l-t:l+t],r.__.inFlow&&0!==r.__.visible?(a=r.__flowBounds,"from"!==n&&(_=o+(e.width-a.width)/("center"===n?2:1)),D(r,_-a.x,c-a.y),c+=a.height+e.gap):i++}const{move:q}=t.PointHelper;function N(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{copyAndSpread:Q}=t.BoundsHelper;let Z=function(t,e){const o="width",{children:i,itemBox:n}=t,s=H(t,!0),{complex:h,wrap:r,xGap:a,yGap:c,isAutoXGap:l,isFitXGap:_}=s;if(!i.length)return;const p=r&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},u=l?0:a;let f,g,d,w,x,{x:y,y:b,width:G,height:m}=t.__layout.contentBounds;for(let s=0,a=i.length;s<a;s++)f=i[w=e?a-1-s:s],f.__.inFlow&&0!==f.__.visible&&(g=M(f,n),h?(f.__flowBounds=g,x||(x=Y(w,u)),r&&x.count&&x.width+g.width>G&&(x.grow?L(t,x,G,e):l&&C(x,o,G,_),S(p,x,o),x=Y(w,u)),d=g.width,f.__widthGrow&&(x.grow+=f.__widthGrow,d=0,f.__.widthRange&&(x.hasRangeSize=!0)),f.__heightGrow&&E(f,g,m),x.width+=x.count?d+u:d,x.height=Math.max(x.height,g.height),x.count++):(U(f,y-g.x,b-g.y),y+=g.width+u));if(h){const{isAutoYGap:i,isFitYGap:n,contentAlign:h,rowXAlign:a,rowYAlign:u}=s;x.count&&(x.grow?L(t,x,G,e):l&&C(x,o,G,_),r&&S(p,x,o)),r?(i?C(p,"height",m,n):p.gap=c,function(t,e,o,i){k(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=A[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,p,h,a),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:r,y:a}=e;for(let c=0,l=n.length;c<l;c++)h=n[s?l-1-c:c],P(t,h,r,a,o,i),a+=h.height+e.gap}(t,p,u,e)):(k(t,x,h),P(t,x,0,x.y,u,e))}},J=function(t,e){const o="height",{children:i,itemBox:n}=t,s=H(t,!1),{complex:h,wrap:r,xGap:a,yGap:c,isAutoYGap:l,isFitYGap:_}=s;if(!i.length)return;const p=r&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},u=l?0:c;let f,g,d,w,x,{x:y,y:b,width:G,height:m}=t.__layout.contentBounds;for(let s=0,a=i.length;s<a;s++)f=i[w=e?a-1-s:s],f.__.inFlow&&0!==f.__.visible&&(g=M(f,n),h?(f.__flowBounds=g,x||(x=Y(w,u)),r&&x.count&&x.height+g.height>m&&(x.grow&&j(t,x,m,e),l&&C(x,o,m,_),S(p,x,o),x=Y(w,u)),d=g.height,f.__heightGrow&&(x.grow+=f.__heightGrow,d=0,f.__.heightRange&&(x.hasRangeSize=!0)),f.__widthGrow&&I(f,g,G),x.height+=x.count?d+u:d,x.width=Math.max(x.width,g.width),x.count++):(q(f,y-g.x,b-g.y),b+=g.height+u));if(h){const{isAutoXGap:i,isFitXGap:n,contentAlign:h,rowXAlign:c,rowYAlign:u}=s;x.count&&(x.grow&&j(t,x,m,e),l&&C(x,o,m,_),r&&S(p,x,o)),r?(i?C(p,"width",G,n):p.gap=a,function(t,e,o,i){k(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=F[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,p,h,u),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:r,y:a}=e;for(let c=0,l=n.length;c<l;c++)h=n[s?l-1-c:c],T(t,h,r,a,o,i),r+=h.width+e.gap}(t,p,c,e)):(k(t,x,h),T(t,x,x.x,0,c,e))}};t.UI.changeAttr("autoWidth",void 0,N),t.UI.changeAttr("autoHeight",void 0,N),t.Box.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:Z(this);break;case"y":J(this);break;case"x-reverse":Z(this,!0);break;case"y-reverse":J(this,!0)}this.leafer.created=!0},t.Box.prototype.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),Q(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},exports.PathScaler=f,exports.scaleResize=w,exports.scaleResizeFontSize=x,exports.scaleResizeGroup=G,exports.scaleResizePath=y,exports.scaleResizePoints=b;
|
package/dist/flow.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.flow=function(t,e
|
|
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:r,D:a,X:c,G:l,F:_,O:u,P:f,U:p}=e.PathCommandMap,g={scale(t,e,g){if(!t)return;let w,y=0,x=t.length;for(;y<x;)switch(w=t[y],w){case o:case i:d(t,e,g,y,1),y+=3;break;case n:d(t,e,g,y,3),y+=7;break;case s:d(t,e,g,y,2),y+=5;break;case h:y+=1;break;case r:d(t,e,g,y,2),y+=5;break;case a:d(t,e,g,y,2),y+=9;break;case c:d(t,e,g,y,2),y+=6;break;case l:d(t,e,g,y,2),y+=9;break;case _:d(t,e,g,y,2),y+=5;break;case u:t[y]=l,t.splice(y+4,0,t[y+3],0),d(t,e,g,y,2),y+=9,x+=2;break;case f:t[y]=_,t.splice(y+4,0,t[y+3]),d(t,e,g,y,2),y+=5,x+=1;break;case p:d(t,e,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:d}=g,w=e.MatrixHelper.get();function y(t,e,o){t.pathInputed?b(t,e,o):(1!==e&&(t.width*=e),1!==o&&(t.height*=o))}function x(t,e,o){const{width:i,height:n}=t.__localBoxBounds;1!==e?(t.fontSize*=e,t.y-=n*(e-o)/2):1!==o&&(t.fontSize*=o,t.x-=i*(o-e)/2)}function b(t,e,o){g.scale(t.__.path,e,o),t.path=t.__.path}function G(t,e,o){g.scalePoints(t.__.points,e,o),t.points=t.__.points}function m(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 z=e.Leaf.prototype;function R(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 r=t.length-1;r>=0;r--)(n=t[r])&&(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}z.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))},z.__scaleResize=function(t,e){y(this,t,e)},z.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},z.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.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?x(this,t,e):y(this,t,e)},e.Path.prototype.__scaleResize=function(t,e){b(this,t,e)},e.Line.prototype.__scaleResize=function(t,e){this.pathInputed?b(this,t,e):this.points?G(this,t,e):this.width*=t},e.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?b(this,t,e):this.points?G(this,t,e):y(this,t,e)},e.Group.prototype.__scaleResize=function(t,e){m(this,t,e)},e.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?m(this,t,e):(y(this,t,e),this.__.resizeChildren&&m(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class B extends e.BoxData{}t.Flow=class extends e.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},R([e.dataProcessor(B)],t.Flow.prototype,"__",void 0),R([e.autoLayoutType("x")],t.Flow.prototype,"flow",void 0),t.Flow=R([e.registerUI()],t.Flow);const A={},F={"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"},k={"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 v(t,o,i){e.AlignHelper.toPoint(i,o,t.__layout.contentBounds,A);const n=t.__;o.x=n.__autoWidth?0:A.x,o.y=n.__autoHeight?0:A.y}const{move:P}=e.PointHelper;function S(t,e,o,i,n,s){const{children:h}=t;let r,a,{x:c,start:l}=e,_=i;c+=o;for(let t=0,o=e.count;t<o;t++)r=h[s?l-t:l+t],r.__.inFlow&&0!==r.__.visible?(a=r.__flowBounds,"from"!==n&&(_=i+(e.height-a.height)/("center"===n?2:1)),P(r,c-a.x,_-a.y),c+=a.width+e.gap):o++}function X(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 H={};function Y(t,e){const{gap:o,flowAlign:i,flowWrap:n,__autoWidth:s,__autoHeight:h}=t.__,r=n&&(e?!s:!h);return"object"==typeof o?(H.xGap=o.x||0,H.yGap=o.y||0):H.xGap=H.yGap=o,H.isAutoXGap="string"==typeof H.xGap&&!s,H.isAutoYGap="string"==typeof H.yGap&&!h,H.complex=r||"top-left"!==i||t.__hasGrow||H.isAutoXGap||H.isAutoYGap,H.wrap=r,H.complex&&(H.isFitXGap="fit"===H.xGap&&!s,H.isFitYGap="fit"===H.yGap&&!h,"object"==typeof i?(H.contentAlign=i.content||"top-left",H.rowXAlign=i.x||"from",H.rowYAlign=i.y||"from"):(H.contentAlign=i,H.rowXAlign=F[i],H.rowYAlign=k[i])),H}function C(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function L(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 I(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:M}=e.MathHelper;function W(t,e,o,i){let n,s,h,r=0,a=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=O(n,n.__flowBounds,_*s),h?(r+=h,c-=s):a&&(n.__.widthRange?a.unshift(n):a.push(n))):o++;r&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__widthGrow,n=e/o*i,h=O(t,s=t.__flowBounds,s.width+n),e-=n-h,o-=i}))}(a,r,c)}function O(t,e,o){const{widthRange:i,lockRatio:n}=t.__,s=i?M(o,i):o,h=s/e.width;return t.scaleResize(h,n?h:1),e.width=s,o-s}const{within:j}=e.MathHelper;function U(t,e,o,i){let n,s,h,r=0,a=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=E(n,n.__flowBounds,_*s),h?(r+=h,c-=s):a&&(n.__.heightRange?a.unshift(n):a.push(n))):o++;r&&function(t,e,o){let i,n,s,h;t.forEach((t=>{i=t.__heightGrow,n=e/o*i,h=E(t,s=t.__flowBounds,s.height+n),e-=n-h,o-=i}))}(a,r,c)}function E(t,e,o){const{heightRange:i,lockRatio:n}=t.__,s=i?j(o,i):o,h=s/e.height;return t.scaleResize(n?h:1,h),e.height=s,o-s}const{move:N}=e.PointHelper;const{move:D}=e.PointHelper;function T(t,e,o,i,n,s){const{children:h}=t;let r,a,{y:c,start:l}=e,_=o;c+=i;for(let t=0,i=e.count;t<i;t++)r=h[s?l-t:l+t],r.__.inFlow&&0!==r.__.visible?(a=r.__flowBounds,"from"!==n&&(_=o+(e.width-a.width)/("center"===n?2:1)),D(r,_-a.x,c-a.y),c+=a.height+e.gap):i++}const{move:Q}=e.PointHelper;function Z(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{copyAndSpread:q}=e.BoundsHelper;let J=function(t,e){const o="width",{children:i,itemBox:n}=t,s=Y(t,!0),{complex:h,wrap:r,xGap:a,yGap:c,isAutoXGap:l,isFitXGap:_}=s;if(!i.length)return;const u=r&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},f=l?0:a;let p,g,d,w,y,{x:x,y:b,width:G,height:m}=t.__layout.contentBounds;for(let s=0,a=i.length;s<a;s++)p=i[w=e?a-1-s:s],p.__.inFlow&&0!==p.__.visible&&(g=I(p,n),h?(p.__flowBounds=g,y||(y=C(w,f)),r&&y.count&&y.width+g.width>G&&(y.grow?W(t,y,G,e):l&&L(y,o,G,_),X(u,y,o),y=C(w,f)),d=g.width,p.__widthGrow&&(y.grow+=p.__widthGrow,d=0,p.__.widthRange&&(y.hasRangeSize=!0)),p.__heightGrow&&E(p,g,m),y.width+=y.count?d+f:d,y.height=Math.max(y.height,g.height),y.count++):(N(p,x-g.x,b-g.y),x+=g.width+f));if(h){const{isAutoYGap:i,isFitYGap:n,contentAlign:h,rowXAlign:a,rowYAlign:f}=s;y.count&&(y.grow?W(t,y,G,e):l&&L(y,o,G,_),r&&X(u,y,o)),r?(i?L(u,"height",m,n):u.gap=c,function(t,e,o,i){v(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=F[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,a),function(t,e,o,i){const{list:n}=e,s="reverse"===t.__.flowWrap;let h,{x:r,y:a}=e;for(let c=0,l=n.length;c<l;c++)h=n[s?l-1-c:c],S(t,h,r,a,o,i),a+=h.height+e.gap}(t,u,f,e)):(v(t,y,h),S(t,y,0,y.y,f,e))}},K=function(t,e){const o="height",{children:i,itemBox:n}=t,s=Y(t,!1),{complex:h,wrap:r,xGap:a,yGap:c,isAutoYGap:l,isFitYGap:_}=s;if(!i.length)return;const u=r&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},f=l?0:c;let p,g,d,w,y,{x:x,y:b,width:G,height:m}=t.__layout.contentBounds;for(let s=0,a=i.length;s<a;s++)p=i[w=e?a-1-s:s],p.__.inFlow&&0!==p.__.visible&&(g=I(p,n),h?(p.__flowBounds=g,y||(y=C(w,f)),r&&y.count&&y.height+g.height>m&&(y.grow&&U(t,y,m,e),l&&L(y,o,m,_),X(u,y,o),y=C(w,f)),d=g.height,p.__heightGrow&&(y.grow+=p.__heightGrow,d=0,p.__.heightRange&&(y.hasRangeSize=!0)),p.__widthGrow&&O(p,g,G),y.height+=y.count?d+f:d,y.width=Math.max(y.width,g.width),y.count++):(Q(p,x-g.x,b-g.y),b+=g.height+f));if(h){const{isAutoXGap:i,isFitXGap:n,contentAlign:h,rowXAlign:c,rowYAlign:f}=s;y.count&&(y.grow&&U(t,y,m,e),l&&L(y,o,m,_),r&&X(u,y,o)),r?(i?L(u,"width",G,n):u.gap=a,function(t,e,o,i){v(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=k[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:r,y:a}=e;for(let c=0,l=n.length;c<l;c++)h=n[s?l-1-c:c],T(t,h,r,a,o,i),r+=h.width+e.gap}(t,u,c,e)):(v(t,y,h),T(t,y,y.x,0,c,e))}};return e.UI.changeAttr("autoWidth",void 0,Z),e.UI.changeAttr("autoHeight",void 0,Z),e.Box.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:J(this);break;case"y":K(this);break;case"x-reverse":J(this,!0);break;case"y-reverse":K(this,!0)}this.leafer.created=!0},e.Box.prototype.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),q(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},t.PathScaler=g,t.scaleResize=y,t.scaleResizeFontSize=x,t.scaleResizeGroup=m,t.scaleResizePath=b,t.scaleResizePoints=G,t}({},LeaferUI);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/flow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "@leafer-in/flow",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"leaferjs"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@leafer-ui/draw": "1.0.
|
|
31
|
-
"@leafer-ui/interface": "1.0.
|
|
32
|
-
"@leafer-in/resize": "1.0.
|
|
33
|
-
"@leafer-in/interface": "1.0.
|
|
30
|
+
"@leafer-ui/draw": "1.0.1",
|
|
31
|
+
"@leafer-ui/interface": "1.0.1",
|
|
32
|
+
"@leafer-in/resize": "1.0.1",
|
|
33
|
+
"@leafer-in/interface": "1.0.1"
|
|
34
34
|
}
|
|
35
35
|
}
|