@leafer-in/flow 1.0.0-rc.25 → 1.0.0-rc.26

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
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer-ui/draw");function e(t,e,o,n){var i,r=arguments.length,h=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(h=(r<3?i(h):r>3?i(e,o,h):i(e,o))||h);return r>3&&h&&Object.defineProperty(e,o,h),h}"function"==typeof SuppressedError&&SuppressedError;class o extends t.BoxData{}exports.Flow=class extends t.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},e([t.dataProcessor(o)],exports.Flow.prototype,"__",void 0),e([t.autoLayoutType("x")],exports.Flow.prototype,"flow",void 0),exports.Flow=e([t.registerUI()],exports.Flow);const n={},i={"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"},r={"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 h(e,o,i){t.AlignHelper.toPoint(i,o,e.__layout.contentBounds,n);const r=e.__;o.x=r.__autoWidth?0:n.x,o.y=r.__autoHeight?0:n.y}const{move:s}=t.PointHelper;function c(t,e,o,n,i,r){const{children:h}=t;let c,l,{x:a,start:_}=e,u=n;a+=o;for(let t=0,o=e.count;t<o;t++)c=h[r?_-t:_+t],c.__.inFlow&&0!==c.__.visible?(l=c.__flowBounds,"from"!==i&&(u=n+(e.height-l.height)/("center"===i?2:1)),s(c,a-l.x,u-l.y),a+=l.width+e.gap):o++}function l(t,e,o){const n="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[n]+=t.count?e[n]+t.gap:e[n],t.list.push(e),t.count++}const a={};function _(t,e){const{gap:o,flowAlign:n,flowWrap:h,__autoWidth:s,__autoHeight:c}=t.__,l=h&&(e?!s:!c);return"object"==typeof o?(a.xGap=o.x||0,a.yGap=o.y||0):a.xGap=a.yGap=o,a.isAutoXGap="string"==typeof a.xGap&&!s,a.isAutoYGap="string"==typeof a.yGap&&!c,a.complex=l||"top-left"!==n||t.__hasGrow||a.isAutoXGap||a.isAutoYGap,a.wrap=l,a.complex&&(a.isFitXGap="fit"===a.xGap&&!s,a.isFitYGap="fit"===a.yGap&&!c,"object"==typeof n?(a.contentAlign=n.content||"top-left",a.rowXAlign=n.x||"from",a.rowYAlign=n.y||"from"):(a.contentAlign=n,a.rowXAlign=i[n],a.rowYAlign=r[n])),a}function u(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function g(t,e,o,n){const{count:i}=t;i>1&&(o>t[e]||n)&&(t.gap=(o-t[e])/(i-1),t[e]=o)}function p(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:w}=t.MathHelper;function f(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:l,start:a}=e;const _=e.width<o?(o-e.width)/l:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)i=u[n?a-t:a+t],i.__.inFlow&&0!==i.__.visible?(r=i.__widthGrow)&&(h=d(i,i.__flowBounds,_*r),h?(s+=h,l-=r):c&&(i.__.widthRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__widthGrow,i=e/o*n,h=d(t,r=t.__flowBounds,r.width+i),e-=i-h,o-=n}))}(c,s,l)}function d(t,e,o){const{widthRange:n}=t.__,i=n?w(o,n.min,n.max):o;return t.scaleResize(i/e.width,1),e.width=i,o-i}const{within:x}=t.MathHelper;function y(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:l,start:a}=e;const _=e.height<o?(o-e.height)/l:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)i=u[n?a-t:a+t],i.__.inFlow&&0!==i.__.visible?(r=i.__heightGrow)&&(h=G(i,i.__flowBounds,_*r),h?(s+=h,l-=r):c&&(i.__.heightRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__heightGrow,i=e/o*n,h=G(t,r=t.__flowBounds,r.height+i),e-=i-h,o-=n}))}(c,s,l)}function G(t,e,o){const{heightRange:n}=t.__,i=n?x(o,n.min,n.max):o;return t.scaleResize(1,i/e.height),e.height=i,o-i}const{move:m}=t.PointHelper;const{move:b}=t.PointHelper;function A(t,e,o,n,i,r){const{children:h}=t;let s,c,{y:l,start:a}=e,_=o;l+=n;for(let t=0,n=e.count;t<n;t++)s=h[r?a-t:a+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=o+(e.width-c.width)/("center"===i?2:1)),b(s,_-c.x,l-c.y),l+=c.height+e.gap):n++}const{move:B}=t.PointHelper;const v=t.inviteCode;function F(e){return t.decorateLeafAttr(e,(e=>t.attr({set(o){const n="number"==typeof o?o:0;"autoWidth"===e?this.__widthGrow=n:this.__heightGrow=n,!n||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(e,o)&&t.doBoundsType(this)}})))}function R(t){return t.length>6&&"e"===t[6]}const{copyAndSpread:H}=t.BoundsHelper;let X=function(t,e){const o="width",{children:n,itemBox:r}=t,s=_(t,!0),{complex:a,wrap:w,xGap:d,yGap:x,isAutoXGap:y,isFitXGap:b}=s;if(!n.length)return;const A=w&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},B=y?0:d;let v,F,R,H,X,{x:Y,y:P,width:S,height:W}=t.__layout.contentBounds;for(let i=0,h=n.length;i<h;i++)v=n[H=e?h-1-i:i],v.__.inFlow&&0!==v.__.visible&&(F=p(v,r),a?(v.__flowBounds=F,X||(X=u(H,B)),w&&X.count&&X.width+F.width>S&&(X.grow?f(t,X,S,e):y&&g(X,o,S,b),l(A,X,o),X=u(H,B)),R=F.width,v.__widthGrow&&(X.grow+=v.__widthGrow,R=0,v.__.widthRange&&(X.hasRangeSize=!0)),v.__heightGrow&&G(v,F,W),X.width+=X.count?R+B:R,X.height=Math.max(X.height,F.height),X.count++):(m(v,Y-F.x,P-F.y),Y+=F.width+B));if(a){const{isAutoYGap:n,isFitYGap:r,contentAlign:a,rowXAlign:_,rowYAlign:u}=s;X.count&&(X.grow?f(t,X,S,e):y&&g(X,o,S,b),w&&l(A,X,o)),w?(n?g(A,"height",W,r):A.gap=x,function(t,e,o,n){h(t,e,o);const{list:r}=e;if(r.length>1&&(n||(n=i[o]),"from"!==n)){let t;for(let o=0,i=r.length;o<i;o++)t=r[o],t.x=e.width-t.width,"center"===n&&(t.x/=2)}}(t,A,a,_),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:l}=e;for(let a=0,_=i.length;a<_;a++)h=i[r?_-1-a:a],c(t,h,s,l,o,n),l+=h.height+e.gap}(t,A,u,e)):(h(t,X,a),c(t,X,0,X.y,u,e))}},Y=function(t,e){const o="height",{children:n,itemBox:i}=t,s=_(t,!1),{complex:c,wrap:a,xGap:w,yGap:f,isAutoYGap:x,isFitYGap:G}=s;if(!n.length)return;const m=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},b=x?0:f;let v,F,R,H,X,{x:Y,y:P,width:S,height:W}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)v=n[H=e?h-1-r:r],v.__.inFlow&&0!==v.__.visible&&(F=p(v,i),c?(v.__flowBounds=F,X||(X=u(H,b)),a&&X.count&&X.height+F.height>W&&(X.grow&&y(t,X,W,e),x&&g(X,o,W,G),l(m,X,o),X=u(H,b)),R=F.height,v.__heightGrow&&(X.grow+=v.__heightGrow,R=0,v.__.heightRange&&(X.hasRangeSize=!0)),v.__widthGrow&&d(v,F,S),X.height+=X.count?R+b:R,X.width=Math.max(X.width,F.width),X.count++):(B(v,Y-F.x,P-F.y),P+=F.height+b));if(c){const{isAutoXGap:n,isFitXGap:i,contentAlign:c,rowXAlign:_,rowYAlign:u}=s;X.count&&(X.grow&&y(t,X,W,e),x&&g(X,o,W,G),a&&l(m,X,o)),a?(n?g(m,"width",S,i):m.gap=w,function(t,e,o,n){h(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=r[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.y=e.height-t.height,"center"===n&&(t.y/=2)}}(t,m,c,u),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let l=0,a=i.length;l<a;l++)h=i[r?a-1-l:l],A(t,h,s,c,o,n),s+=h.width+e.gap}(t,m,_,e)):(h(t,X,c),A(t,X,X.x,0,_,e))}};t.UI.changeAttr("autoWidth",void 0,F),t.UI.changeAttr("autoHeight",void 0,F),t.Box.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:X(this);break;case"y":Y(this);break;case"x-reverse":X(this,!0);break;case"y-reverse":Y(this,!0)}this.leafer.created=!0},setTimeout((function(){Object.values(v).some(R)||(X=()=>{Y=X})})),t.Box.prototype.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),H(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()};
1
+ "use strict";var t=require("@leafer-in/resize"),e=require("@leafer-ui/draw");function o(t,e,o,n){var i,r=arguments.length,h=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(h=(r<3?i(h):r>3?i(e,o,h):i(e,o))||h);return r>3&&h&&Object.defineProperty(e,o,h),h}"function"==typeof SuppressedError&&SuppressedError;class n extends e.BoxData{}exports.Flow=class extends e.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},o([e.dataProcessor(n)],exports.Flow.prototype,"__",void 0),o([e.autoLayoutType("x")],exports.Flow.prototype,"flow",void 0),exports.Flow=o([e.registerUI()],exports.Flow);const i={},r={"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"},h={"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 s(t,o,n){e.AlignHelper.toPoint(n,o,t.__layout.contentBounds,i);const r=t.__;o.x=r.__autoWidth?0:i.x,o.y=r.__autoHeight?0:i.y}const{move:c}=e.PointHelper;function a(t,e,o,n,i,r){const{children:h}=t;let s,a,{x:l,start:_}=e,u=n;l+=o;for(let t=0,o=e.count;t<o;t++)s=h[r?_-t:_+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==i&&(u=n+(e.height-a.height)/("center"===i?2:1)),c(s,l-a.x,u-a.y),l+=a.width+e.gap):o++}function l(t,e,o){const n="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[n]+=t.count?e[n]+t.gap:e[n],t.list.push(e),t.count++}const _={};function u(t,e){const{gap:o,flowAlign:n,flowWrap:i,__autoWidth:s,__autoHeight:c}=t.__,a=i&&(e?!s:!c);return"object"==typeof o?(_.xGap=o.x||0,_.yGap=o.y||0):_.xGap=_.yGap=o,_.isAutoXGap="string"==typeof _.xGap&&!s,_.isAutoYGap="string"==typeof _.yGap&&!c,_.complex=a||"top-left"!==n||t.__hasGrow||_.isAutoXGap||_.isAutoYGap,_.wrap=a,_.complex&&(_.isFitXGap="fit"===_.xGap&&!s,_.isFitYGap="fit"===_.yGap&&!c,"object"==typeof n?(_.contentAlign=n.content||"top-left",_.rowXAlign=n.x||"from",_.rowYAlign=n.y||"from"):(_.contentAlign=n,_.rowXAlign=r[n],_.rowYAlign=h[n])),_}function g(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function p(t,e,o,n){const{count:i}=t;i>1&&(o>t[e]||n)&&(t.gap=(o-t[e])/(i-1),t[e]=o)}function f(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:w}=e.MathHelper;function d(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:a,start:l}=e;const _=e.width<o?(o-e.width)/a:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)i=u[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(r=i.__widthGrow)&&(h=y(i,i.__flowBounds,_*r),h?(s+=h,a-=r):c&&(i.__.widthRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__widthGrow,i=e/o*n,h=y(t,r=t.__flowBounds,r.width+i),e-=i-h,o-=n}))}(c,s,a)}function y(t,e,o){const{widthRange:n,lockRatio:i}=t.__,r=n?w(o,n.min,n.max):o,h=r/e.width;return t.scaleResize(h,i?h:1),e.width=r,o-r}const{within:x}=e.MathHelper;function G(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:a,start:l}=e;const _=e.height<o?(o-e.height)/a:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)i=u[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(r=i.__heightGrow)&&(h=m(i,i.__flowBounds,_*r),h?(s+=h,a-=r):c&&(i.__.heightRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__heightGrow,i=e/o*n,h=m(t,r=t.__flowBounds,r.height+i),e-=i-h,o-=n}))}(c,s,a)}function m(t,e,o){const{heightRange:n,lockRatio:i}=t.__,r=n?x(o,n.min,n.max):o,h=r/e.height;return t.scaleResize(i?h:1,h),e.height=r,o-r}const{move:b}=e.PointHelper;const{move:A}=e.PointHelper;function B(t,e,o,n,i,r){const{children:h}=t;let s,c,{y:a,start:l}=e,_=o;a+=n;for(let t=0,n=e.count;t<n;t++)s=h[r?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=o+(e.width-c.width)/("center"===i?2:1)),A(s,_-c.x,a-c.y),a+=c.height+e.gap):n++}const{move:v}=e.PointHelper;const F=e.inviteCode;function R(t){return e.decorateLeafAttr(t,(t=>e.attr({set(o){const n="number"==typeof o?o:0;"autoWidth"===t?this.__widthGrow=n:this.__heightGrow=n,!n||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,o)&&e.doBoundsType(this)}})))}function H(t){return t.length>6&&"e"===t[6]}const{copyAndSpread:P}=e.BoundsHelper;let X=function(t,e){const o="width",{children:n,itemBox:i}=t,h=u(t,!0),{complex:c,wrap:_,xGap:w,yGap:y,isAutoXGap:x,isFitXGap:G}=h;if(!n.length)return;const A=_&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},B=x?0:w;let v,F,R,H,P,{x:X,y:Y,width:j,height:k}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)v=n[H=e?h-1-r:r],v.__.inFlow&&0!==v.__.visible&&(F=f(v,i),c?(v.__flowBounds=F,P||(P=g(H,B)),_&&P.count&&P.width+F.width>j&&(P.grow?d(t,P,j,e):x&&p(P,o,j,G),l(A,P,o),P=g(H,B)),R=F.width,v.__widthGrow&&(P.grow+=v.__widthGrow,R=0,v.__.widthRange&&(P.hasRangeSize=!0)),v.__heightGrow&&m(v,F,k),P.width+=P.count?R+B:R,P.height=Math.max(P.height,F.height),P.count++):(b(v,X-F.x,Y-F.y),X+=F.width+B));if(c){const{isAutoYGap:n,isFitYGap:i,contentAlign:c,rowXAlign:u,rowYAlign:g}=h;P.count&&(P.grow?d(t,P,j,e):x&&p(P,o,j,G),_&&l(A,P,o)),_?(n?p(A,"height",k,i):A.gap=y,function(t,e,o,n){s(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=r[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.x=e.width-t.width,"center"===n&&(t.x/=2)}}(t,A,c,u),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let l=0,_=i.length;l<_;l++)h=i[r?_-1-l:l],a(t,h,s,c,o,n),c+=h.height+e.gap}(t,A,g,e)):(s(t,P,c),a(t,P,0,P.y,g,e))}},Y=function(t,e){const o="height",{children:n,itemBox:i}=t,r=u(t,!1),{complex:c,wrap:a,xGap:_,yGap:w,isAutoYGap:d,isFitYGap:x}=r;if(!n.length)return;const m=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},b=d?0:w;let A,F,R,H,P,{x:X,y:Y,width:j,height:k}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)A=n[H=e?h-1-r:r],A.__.inFlow&&0!==A.__.visible&&(F=f(A,i),c?(A.__flowBounds=F,P||(P=g(H,b)),a&&P.count&&P.height+F.height>k&&(P.grow&&G(t,P,k,e),d&&p(P,o,k,x),l(m,P,o),P=g(H,b)),R=F.height,A.__heightGrow&&(P.grow+=A.__heightGrow,R=0,A.__.heightRange&&(P.hasRangeSize=!0)),A.__widthGrow&&y(A,F,j),P.height+=P.count?R+b:R,P.width=Math.max(P.width,F.width),P.count++):(v(A,X-F.x,Y-F.y),Y+=F.height+b));if(c){const{isAutoXGap:n,isFitXGap:i,contentAlign:c,rowXAlign:u,rowYAlign:g}=r;P.count&&(P.grow&&G(t,P,k,e),d&&p(P,o,k,x),a&&l(m,P,o)),a?(n?p(m,"width",j,i):m.gap=_,function(t,e,o,n){s(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=h[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.y=e.height-t.height,"center"===n&&(t.y/=2)}}(t,m,c,g),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let a=0,l=i.length;a<l;a++)h=i[r?l-1-a:a],B(t,h,s,c,o,n),s+=h.width+e.gap}(t,m,u,e)):(s(t,P,c),B(t,P,P.x,0,u,e))}};e.UI.changeAttr("autoWidth",void 0,R),e.UI.changeAttr("autoHeight",void 0,R),e.Box.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:X(this);break;case"y":Y(this);break;case"x-reverse":X(this,!0);break;case"y-reverse":Y(this,!0)}this.leafer.created=!0},setTimeout((function(){Object.values(F).some(H)||(X=()=>{Y=X})})),e.Box.prototype.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),P(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
package/dist/flow.esm.js CHANGED
@@ -1 +1 @@
1
- import{BoxData as t,dataProcessor as o,autoLayoutType as e,registerUI as n,Box as i,AlignHelper as h,PointHelper as r,MathHelper as s,decorateLeafAttr as c,attr as a,doBoundsType as l,inviteCode as _,UI as g,BoundsHelper as u}from"@leafer-ui/draw";function f(t,o,e,n){var i,h=arguments.length,r=h<3?o:null===n?n=Object.getOwnPropertyDescriptor(o,e):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,o,e,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(r=(h<3?i(r):h>3?i(o,e,r):i(o,e))||r);return h>3&&r&&Object.defineProperty(o,e,r),r}"function"==typeof SuppressedError&&SuppressedError;let w=class extends i{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}};f([o(class extends t{})],w.prototype,"__",void 0),f([e("x")],w.prototype,"flow",void 0),w=f([n()],w);const p={},d={"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"},y={"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 x(t,o,e){h.toPoint(e,o,t.__layout.contentBounds,p);const n=t.__;o.x=n.__autoWidth?0:p.x,o.y=n.__autoHeight?0:p.y}const{move:m}=r;function G(t,o,e,n,i,h){const{children:r}=t;let s,c,{x:a,start:l}=o,_=n;a+=e;for(let t=0,e=o.count;t<e;t++)s=r[h?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=n+(o.height-c.height)/("center"===i?2:1)),m(s,a-c.x,_-c.y),a+=c.width+o.gap):e++}function b(t,o,e){const n="width"===e?"height":"width";t[e]=Math.max(t[e],o[e]),t[n]+=t.count?o[n]+t.gap:o[n],t.list.push(o),t.count++}const A={};function v(t,o){const{gap:e,flowAlign:n,flowWrap:i,__autoWidth:h,__autoHeight:r}=t.__,s=i&&(o?!h:!r);return"object"==typeof e?(A.xGap=e.x||0,A.yGap=e.y||0):A.xGap=A.yGap=e,A.isAutoXGap="string"==typeof A.xGap&&!h,A.isAutoYGap="string"==typeof A.yGap&&!r,A.complex=s||"top-left"!==n||t.__hasGrow||A.isAutoXGap||A.isAutoYGap,A.wrap=s,A.complex&&(A.isFitXGap="fit"===A.xGap&&!h,A.isFitYGap="fit"===A.yGap&&!r,"object"==typeof n?(A.contentAlign=n.content||"top-left",A.rowXAlign=n.x||"from",A.rowYAlign=n.y||"from"):(A.contentAlign=n,A.rowXAlign=d[n],A.rowYAlign=y[n])),A}function B(t,o){return{x:0,y:0,width:0,height:0,gap:o,start:t,count:0,grow:0}}function R(t,o,e,n){const{count:i}=t;i>1&&(e>t[o]||n)&&(t.gap=(e-t[o])/(i-1),t[o]=e)}function F(t,o){return"box"===o?t.__local:t.__layout.localStrokeBounds}const{within:X}=s;function Y(t,o,e,n){let i,h,r,s=0,c=o.hasRangeSize&&[],{grow:a,start:l}=o;const _=o.width<e?(e-o.width)/a:0,{children:g}=t;_&&(o.width=e);for(let t=0,e=o.count;t<e;t++)i=g[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(h=i.__widthGrow)&&(r=S(i,i.__flowBounds,_*h),r?(s+=r,a-=h):c&&(i.__.widthRange?c.unshift(i):c.push(i))):e++;s&&function(t,o,e){let n,i,h,r;t.forEach((t=>{n=t.__widthGrow,i=o/e*n,r=S(t,h=t.__flowBounds,h.width+i),o-=i-r,e-=n}))}(c,s,a)}function S(t,o,e){const{widthRange:n}=t.__,i=n?X(e,n.min,n.max):e;return t.scaleResize(i/o.width,1),o.width=i,e-i}const{within:W}=s;function j(t,o,e,n){let i,h,r,s=0,c=o.hasRangeSize&&[],{grow:a,start:l}=o;const _=o.height<e?(e-o.height)/a:0,{children:g}=t;_&&(o.height=e);for(let t=0,e=o.count;t<e;t++)i=g[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(h=i.__heightGrow)&&(r=k(i,i.__flowBounds,_*h),r?(s+=r,a-=h):c&&(i.__.heightRange?c.unshift(i):c.push(i))):e++;s&&function(t,o,e){let n,i,h,r;t.forEach((t=>{n=t.__heightGrow,i=o/e*n,r=k(t,h=t.__flowBounds,h.height+i),o-=i-r,e-=n}))}(c,s,a)}function k(t,o,e){const{heightRange:n}=t.__,i=n?W(e,n.min,n.max):e;return t.scaleResize(1,i/o.height),o.height=i,e-i}const{move:z}=r;const{move:C}=r;function E(t,o,e,n,i,h){const{children:r}=t;let s,c,{y:a,start:l}=o,_=e;a+=n;for(let t=0,n=o.count;t<n;t++)s=r[h?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=e+(o.width-c.width)/("center"===i?2:1)),C(s,_-c.x,a-c.y),a+=c.height+o.gap):n++}const{move:O}=r;const P=_;function H(t){return c(t,(t=>a({set(o){const e="number"==typeof o?o:0;"autoWidth"===t?this.__widthGrow=e:this.__heightGrow=e,!e||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,o)&&l(this)}})))}function M(t){return t.length>6&&"e"===t[6]}const{copyAndSpread:L}=u;let D=function(t,o){const e="width",{children:n,itemBox:i}=t,h=v(t,!0),{complex:r,wrap:s,xGap:c,yGap:a,isAutoXGap:l,isFitXGap:_}=h;if(!n.length)return;const g=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},u=l?0:c;let f,w,p,y,m,{x:A,y:X,width:S,height:W}=t.__layout.contentBounds;for(let h=0,c=n.length;h<c;h++)f=n[y=o?c-1-h:h],f.__.inFlow&&0!==f.__.visible&&(w=F(f,i),r?(f.__flowBounds=w,m||(m=B(y,u)),s&&m.count&&m.width+w.width>S&&(m.grow?Y(t,m,S,o):l&&R(m,e,S,_),b(g,m,e),m=B(y,u)),p=w.width,f.__widthGrow&&(m.grow+=f.__widthGrow,p=0,f.__.widthRange&&(m.hasRangeSize=!0)),f.__heightGrow&&k(f,w,W),m.width+=m.count?p+u:p,m.height=Math.max(m.height,w.height),m.count++):(z(f,A-w.x,X-w.y),A+=w.width+u));if(r){const{isAutoYGap:n,isFitYGap:i,contentAlign:r,rowXAlign:c,rowYAlign:u}=h;m.count&&(m.grow?Y(t,m,S,o):l&&R(m,e,S,_),s&&b(g,m,e)),s?(n?R(g,"height",W,i):g.gap=a,function(t,o,e,n){x(t,o,e);const{list:i}=o;if(i.length>1&&(n||(n=d[e]),"from"!==n)){let t;for(let e=0,h=i.length;e<h;e++)t=i[e],t.x=o.width-t.width,"center"===n&&(t.x/=2)}}(t,g,r,c),function(t,o,e,n){const{list:i}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:c}=o;for(let a=0,l=i.length;a<l;a++)r=i[h?l-1-a:a],G(t,r,s,c,e,n),c+=r.height+o.gap}(t,g,u,o)):(x(t,m,r),G(t,m,0,m.y,u,o))}},T=function(t,o){const e="height",{children:n,itemBox:i}=t,h=v(t,!1),{complex:r,wrap:s,xGap:c,yGap:a,isAutoYGap:l,isFitYGap:_}=h;if(!n.length)return;const g=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},u=l?0:a;let f,w,p,d,m,{x:G,y:A,width:X,height:Y}=t.__layout.contentBounds;for(let h=0,c=n.length;h<c;h++)f=n[d=o?c-1-h:h],f.__.inFlow&&0!==f.__.visible&&(w=F(f,i),r?(f.__flowBounds=w,m||(m=B(d,u)),s&&m.count&&m.height+w.height>Y&&(m.grow&&j(t,m,Y,o),l&&R(m,e,Y,_),b(g,m,e),m=B(d,u)),p=w.height,f.__heightGrow&&(m.grow+=f.__heightGrow,p=0,f.__.heightRange&&(m.hasRangeSize=!0)),f.__widthGrow&&S(f,w,X),m.height+=m.count?p+u:p,m.width=Math.max(m.width,w.width),m.count++):(O(f,G-w.x,A-w.y),A+=w.height+u));if(r){const{isAutoXGap:n,isFitXGap:i,contentAlign:r,rowXAlign:a,rowYAlign:u}=h;m.count&&(m.grow&&j(t,m,Y,o),l&&R(m,e,Y,_),s&&b(g,m,e)),s?(n?R(g,"width",X,i):g.gap=c,function(t,o,e,n){x(t,o,e);const{list:i}=o;if(i.length>1&&(n||(n=y[e]),"from"!==n)){let t;for(let e=0,h=i.length;e<h;e++)t=i[e],t.y=o.height-t.height,"center"===n&&(t.y/=2)}}(t,g,r,u),function(t,o,e,n){const{list:i}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:c}=o;for(let a=0,l=i.length;a<l;a++)r=i[h?l-1-a:a],E(t,r,s,c,e,n),s+=r.width+o.gap}(t,g,a,o)):(x(t,m,r),E(t,m,m.x,0,a,o))}};g.changeAttr("autoWidth",void 0,H),g.changeAttr("autoHeight",void 0,H),i.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:D(this);break;case"y":T(this);break;case"x-reverse":D(this,!0);break;case"y-reverse":T(this,!0)}this.leafer.created=!0},setTimeout((function(){Object.values(P).some(M)||(D=()=>{T=D})})),i.prototype.__updateContentBounds=function(){const{padding:t}=this.__,o=this.__layout,e=o.contentBounds===o.boxBounds;t?(e&&o.shrinkContent(),L(o.contentBounds,o.boxBounds,t,!0)):e||o.shrinkContentCancel()};export{w as Flow};
1
+ export*from"@leafer-in/resize";import{BoxData as t,dataProcessor as o,autoLayoutType as e,registerUI as n,Box as i,AlignHelper as h,PointHelper as r,MathHelper as s,decorateLeafAttr as c,attr as a,doBoundsType as l,inviteCode as _,UI as g,BoundsHelper as u}from"@leafer-ui/draw";function f(t,o,e,n){var i,h=arguments.length,r=h<3?o:null===n?n=Object.getOwnPropertyDescriptor(o,e):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,o,e,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(r=(h<3?i(r):h>3?i(o,e,r):i(o,e))||r);return h>3&&r&&Object.defineProperty(o,e,r),r}"function"==typeof SuppressedError&&SuppressedError;let w=class extends i{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}};f([o(class extends t{})],w.prototype,"__",void 0),f([e("x")],w.prototype,"flow",void 0),w=f([n()],w);const p={},d={"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"},y={"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 x(t,o,e){h.toPoint(e,o,t.__layout.contentBounds,p);const n=t.__;o.x=n.__autoWidth?0:p.x,o.y=n.__autoHeight?0:p.y}const{move:m}=r;function G(t,o,e,n,i,h){const{children:r}=t;let s,c,{x:a,start:l}=o,_=n;a+=e;for(let t=0,e=o.count;t<e;t++)s=r[h?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=n+(o.height-c.height)/("center"===i?2:1)),m(s,a-c.x,_-c.y),a+=c.width+o.gap):e++}function b(t,o,e){const n="width"===e?"height":"width";t[e]=Math.max(t[e],o[e]),t[n]+=t.count?o[n]+t.gap:o[n],t.list.push(o),t.count++}const A={};function v(t,o){const{gap:e,flowAlign:n,flowWrap:i,__autoWidth:h,__autoHeight:r}=t.__,s=i&&(o?!h:!r);return"object"==typeof e?(A.xGap=e.x||0,A.yGap=e.y||0):A.xGap=A.yGap=e,A.isAutoXGap="string"==typeof A.xGap&&!h,A.isAutoYGap="string"==typeof A.yGap&&!r,A.complex=s||"top-left"!==n||t.__hasGrow||A.isAutoXGap||A.isAutoYGap,A.wrap=s,A.complex&&(A.isFitXGap="fit"===A.xGap&&!h,A.isFitYGap="fit"===A.yGap&&!r,"object"==typeof n?(A.contentAlign=n.content||"top-left",A.rowXAlign=n.x||"from",A.rowYAlign=n.y||"from"):(A.contentAlign=n,A.rowXAlign=d[n],A.rowYAlign=y[n])),A}function B(t,o){return{x:0,y:0,width:0,height:0,gap:o,start:t,count:0,grow:0}}function R(t,o,e,n){const{count:i}=t;i>1&&(e>t[o]||n)&&(t.gap=(e-t[o])/(i-1),t[o]=e)}function F(t,o){return"box"===o?t.__local:t.__layout.localStrokeBounds}const{within:X}=s;function Y(t,o,e,n){let i,h,r,s=0,c=o.hasRangeSize&&[],{grow:a,start:l}=o;const _=o.width<e?(e-o.width)/a:0,{children:g}=t;_&&(o.width=e);for(let t=0,e=o.count;t<e;t++)i=g[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(h=i.__widthGrow)&&(r=k(i,i.__flowBounds,_*h),r?(s+=r,a-=h):c&&(i.__.widthRange?c.unshift(i):c.push(i))):e++;s&&function(t,o,e){let n,i,h,r;t.forEach((t=>{n=t.__widthGrow,i=o/e*n,r=k(t,h=t.__flowBounds,h.width+i),o-=i-r,e-=n}))}(c,s,a)}function k(t,o,e){const{widthRange:n,lockRatio:i}=t.__,h=n?X(e,n.min,n.max):e,r=h/o.width;return t.scaleResize(r,i?r:1),o.width=h,e-h}const{within:S}=s;function z(t,o,e,n){let i,h,r,s=0,c=o.hasRangeSize&&[],{grow:a,start:l}=o;const _=o.height<e?(e-o.height)/a:0,{children:g}=t;_&&(o.height=e);for(let t=0,e=o.count;t<e;t++)i=g[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(h=i.__heightGrow)&&(r=W(i,i.__flowBounds,_*h),r?(s+=r,a-=h):c&&(i.__.heightRange?c.unshift(i):c.push(i))):e++;s&&function(t,o,e){let n,i,h,r;t.forEach((t=>{n=t.__heightGrow,i=o/e*n,r=W(t,h=t.__flowBounds,h.height+i),o-=i-r,e-=n}))}(c,s,a)}function W(t,o,e){const{heightRange:n,lockRatio:i}=t.__,h=n?S(e,n.min,n.max):e,r=h/o.height;return t.scaleResize(i?r:1,r),o.height=h,e-h}const{move:j}=r;const{move:C}=r;function E(t,o,e,n,i,h){const{children:r}=t;let s,c,{y:a,start:l}=o,_=e;a+=n;for(let t=0,n=o.count;t<n;t++)s=r[h?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=e+(o.width-c.width)/("center"===i?2:1)),C(s,_-c.x,a-c.y),a+=c.height+o.gap):n++}const{move:O}=r;const P=_;function H(t){return c(t,(t=>a({set(o){const e="number"==typeof o?o:0;"autoWidth"===t?this.__widthGrow=e:this.__heightGrow=e,!e||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,o)&&l(this)}})))}function M(t){return t.length>6&&"e"===t[6]}const{copyAndSpread:L}=u;let D=function(t,o){const e="width",{children:n,itemBox:i}=t,h=v(t,!0),{complex:r,wrap:s,xGap:c,yGap:a,isAutoXGap:l,isFitXGap:_}=h;if(!n.length)return;const g=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},u=l?0:c;let f,w,p,y,m,{x:A,y:X,width:k,height:S}=t.__layout.contentBounds;for(let h=0,c=n.length;h<c;h++)f=n[y=o?c-1-h:h],f.__.inFlow&&0!==f.__.visible&&(w=F(f,i),r?(f.__flowBounds=w,m||(m=B(y,u)),s&&m.count&&m.width+w.width>k&&(m.grow?Y(t,m,k,o):l&&R(m,e,k,_),b(g,m,e),m=B(y,u)),p=w.width,f.__widthGrow&&(m.grow+=f.__widthGrow,p=0,f.__.widthRange&&(m.hasRangeSize=!0)),f.__heightGrow&&W(f,w,S),m.width+=m.count?p+u:p,m.height=Math.max(m.height,w.height),m.count++):(j(f,A-w.x,X-w.y),A+=w.width+u));if(r){const{isAutoYGap:n,isFitYGap:i,contentAlign:r,rowXAlign:c,rowYAlign:u}=h;m.count&&(m.grow?Y(t,m,k,o):l&&R(m,e,k,_),s&&b(g,m,e)),s?(n?R(g,"height",S,i):g.gap=a,function(t,o,e,n){x(t,o,e);const{list:i}=o;if(i.length>1&&(n||(n=d[e]),"from"!==n)){let t;for(let e=0,h=i.length;e<h;e++)t=i[e],t.x=o.width-t.width,"center"===n&&(t.x/=2)}}(t,g,r,c),function(t,o,e,n){const{list:i}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:c}=o;for(let a=0,l=i.length;a<l;a++)r=i[h?l-1-a:a],G(t,r,s,c,e,n),c+=r.height+o.gap}(t,g,u,o)):(x(t,m,r),G(t,m,0,m.y,u,o))}},T=function(t,o){const e="height",{children:n,itemBox:i}=t,h=v(t,!1),{complex:r,wrap:s,xGap:c,yGap:a,isAutoYGap:l,isFitYGap:_}=h;if(!n.length)return;const g=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},u=l?0:a;let f,w,p,d,m,{x:G,y:A,width:X,height:Y}=t.__layout.contentBounds;for(let h=0,c=n.length;h<c;h++)f=n[d=o?c-1-h:h],f.__.inFlow&&0!==f.__.visible&&(w=F(f,i),r?(f.__flowBounds=w,m||(m=B(d,u)),s&&m.count&&m.height+w.height>Y&&(m.grow&&z(t,m,Y,o),l&&R(m,e,Y,_),b(g,m,e),m=B(d,u)),p=w.height,f.__heightGrow&&(m.grow+=f.__heightGrow,p=0,f.__.heightRange&&(m.hasRangeSize=!0)),f.__widthGrow&&k(f,w,X),m.height+=m.count?p+u:p,m.width=Math.max(m.width,w.width),m.count++):(O(f,G-w.x,A-w.y),A+=w.height+u));if(r){const{isAutoXGap:n,isFitXGap:i,contentAlign:r,rowXAlign:a,rowYAlign:u}=h;m.count&&(m.grow&&z(t,m,Y,o),l&&R(m,e,Y,_),s&&b(g,m,e)),s?(n?R(g,"width",X,i):g.gap=c,function(t,o,e,n){x(t,o,e);const{list:i}=o;if(i.length>1&&(n||(n=y[e]),"from"!==n)){let t;for(let e=0,h=i.length;e<h;e++)t=i[e],t.y=o.height-t.height,"center"===n&&(t.y/=2)}}(t,g,r,u),function(t,o,e,n){const{list:i}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:c}=o;for(let a=0,l=i.length;a<l;a++)r=i[h?l-1-a:a],E(t,r,s,c,e,n),s+=r.width+o.gap}(t,g,a,o)):(x(t,m,r),E(t,m,m.x,0,a,o))}};g.changeAttr("autoWidth",void 0,H),g.changeAttr("autoHeight",void 0,H),i.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:D(this);break;case"y":T(this);break;case"x-reverse":D(this,!0);break;case"y-reverse":T(this,!0)}this.leafer.created=!0},setTimeout((function(){Object.values(P).some(M)||(D=()=>{T=D})})),i.prototype.__updateContentBounds=function(){const{padding:t}=this.__,o=this.__layout,e=o.contentBounds===o.boxBounds;t?(e&&o.shrinkContent(),L(o.contentBounds,o.boxBounds,t,!0)):e||o.shrinkContentCancel()};export{w as Flow};
@@ -1 +1 @@
1
- import{BoxData as t,dataProcessor as o,autoLayoutType as e,registerUI as n,Box as i,AlignHelper as h,PointHelper as r,MathHelper as s,decorateLeafAttr as c,attr as a,doBoundsType as l,inviteCode as _,UI as g,BoundsHelper as u}from"@leafer-ui/draw";function f(t,o,e,n){var i,h=arguments.length,r=h<3?o:null===n?n=Object.getOwnPropertyDescriptor(o,e):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,o,e,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(r=(h<3?i(r):h>3?i(o,e,r):i(o,e))||r);return h>3&&r&&Object.defineProperty(o,e,r),r}"function"==typeof SuppressedError&&SuppressedError;let w=class extends i{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}};f([o(class extends t{})],w.prototype,"__",void 0),f([e("x")],w.prototype,"flow",void 0),w=f([n()],w);const p={},d={"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"},y={"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 x(t,o,e){h.toPoint(e,o,t.__layout.contentBounds,p);const n=t.__;o.x=n.__autoWidth?0:p.x,o.y=n.__autoHeight?0:p.y}const{move:m}=r;function G(t,o,e,n,i,h){const{children:r}=t;let s,c,{x:a,start:l}=o,_=n;a+=e;for(let t=0,e=o.count;t<e;t++)s=r[h?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=n+(o.height-c.height)/("center"===i?2:1)),m(s,a-c.x,_-c.y),a+=c.width+o.gap):e++}function b(t,o,e){const n="width"===e?"height":"width";t[e]=Math.max(t[e],o[e]),t[n]+=t.count?o[n]+t.gap:o[n],t.list.push(o),t.count++}const A={};function v(t,o){const{gap:e,flowAlign:n,flowWrap:i,__autoWidth:h,__autoHeight:r}=t.__,s=i&&(o?!h:!r);return"object"==typeof e?(A.xGap=e.x||0,A.yGap=e.y||0):A.xGap=A.yGap=e,A.isAutoXGap="string"==typeof A.xGap&&!h,A.isAutoYGap="string"==typeof A.yGap&&!r,A.complex=s||"top-left"!==n||t.__hasGrow||A.isAutoXGap||A.isAutoYGap,A.wrap=s,A.complex&&(A.isFitXGap="fit"===A.xGap&&!h,A.isFitYGap="fit"===A.yGap&&!r,"object"==typeof n?(A.contentAlign=n.content||"top-left",A.rowXAlign=n.x||"from",A.rowYAlign=n.y||"from"):(A.contentAlign=n,A.rowXAlign=d[n],A.rowYAlign=y[n])),A}function B(t,o){return{x:0,y:0,width:0,height:0,gap:o,start:t,count:0,grow:0}}function R(t,o,e,n){const{count:i}=t;i>1&&(e>t[o]||n)&&(t.gap=(e-t[o])/(i-1),t[o]=e)}function F(t,o){return"box"===o?t.__local:t.__layout.localStrokeBounds}const{within:X}=s;function Y(t,o,e,n){let i,h,r,s=0,c=o.hasRangeSize&&[],{grow:a,start:l}=o;const _=o.width<e?(e-o.width)/a:0,{children:g}=t;_&&(o.width=e);for(let t=0,e=o.count;t<e;t++)i=g[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(h=i.__widthGrow)&&(r=S(i,i.__flowBounds,_*h),r?(s+=r,a-=h):c&&(i.__.widthRange?c.unshift(i):c.push(i))):e++;s&&function(t,o,e){let n,i,h,r;t.forEach((t=>{n=t.__widthGrow,i=o/e*n,r=S(t,h=t.__flowBounds,h.width+i),o-=i-r,e-=n}))}(c,s,a)}function S(t,o,e){const{widthRange:n}=t.__,i=n?X(e,n.min,n.max):e;return t.scaleResize(i/o.width,1),o.width=i,e-i}const{within:W}=s;function j(t,o,e,n){let i,h,r,s=0,c=o.hasRangeSize&&[],{grow:a,start:l}=o;const _=o.height<e?(e-o.height)/a:0,{children:g}=t;_&&(o.height=e);for(let t=0,e=o.count;t<e;t++)i=g[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(h=i.__heightGrow)&&(r=k(i,i.__flowBounds,_*h),r?(s+=r,a-=h):c&&(i.__.heightRange?c.unshift(i):c.push(i))):e++;s&&function(t,o,e){let n,i,h,r;t.forEach((t=>{n=t.__heightGrow,i=o/e*n,r=k(t,h=t.__flowBounds,h.height+i),o-=i-r,e-=n}))}(c,s,a)}function k(t,o,e){const{heightRange:n}=t.__,i=n?W(e,n.min,n.max):e;return t.scaleResize(1,i/o.height),o.height=i,e-i}const{move:z}=r;const{move:C}=r;function E(t,o,e,n,i,h){const{children:r}=t;let s,c,{y:a,start:l}=o,_=e;a+=n;for(let t=0,n=o.count;t<n;t++)s=r[h?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=e+(o.width-c.width)/("center"===i?2:1)),C(s,_-c.x,a-c.y),a+=c.height+o.gap):n++}const{move:O}=r;const P=_;function H(t){return c(t,(t=>a({set(o){const e="number"==typeof o?o:0;"autoWidth"===t?this.__widthGrow=e:this.__heightGrow=e,!e||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,o)&&l(this)}})))}function M(t){return t.length>6&&"e"===t[6]}const{copyAndSpread:L}=u;let D=function(t,o){const e="width",{children:n,itemBox:i}=t,h=v(t,!0),{complex:r,wrap:s,xGap:c,yGap:a,isAutoXGap:l,isFitXGap:_}=h;if(!n.length)return;const g=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},u=l?0:c;let f,w,p,y,m,{x:A,y:X,width:S,height:W}=t.__layout.contentBounds;for(let h=0,c=n.length;h<c;h++)f=n[y=o?c-1-h:h],f.__.inFlow&&0!==f.__.visible&&(w=F(f,i),r?(f.__flowBounds=w,m||(m=B(y,u)),s&&m.count&&m.width+w.width>S&&(m.grow?Y(t,m,S,o):l&&R(m,e,S,_),b(g,m,e),m=B(y,u)),p=w.width,f.__widthGrow&&(m.grow+=f.__widthGrow,p=0,f.__.widthRange&&(m.hasRangeSize=!0)),f.__heightGrow&&k(f,w,W),m.width+=m.count?p+u:p,m.height=Math.max(m.height,w.height),m.count++):(z(f,A-w.x,X-w.y),A+=w.width+u));if(r){const{isAutoYGap:n,isFitYGap:i,contentAlign:r,rowXAlign:c,rowYAlign:u}=h;m.count&&(m.grow?Y(t,m,S,o):l&&R(m,e,S,_),s&&b(g,m,e)),s?(n?R(g,"height",W,i):g.gap=a,function(t,o,e,n){x(t,o,e);const{list:i}=o;if(i.length>1&&(n||(n=d[e]),"from"!==n)){let t;for(let e=0,h=i.length;e<h;e++)t=i[e],t.x=o.width-t.width,"center"===n&&(t.x/=2)}}(t,g,r,c),function(t,o,e,n){const{list:i}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:c}=o;for(let a=0,l=i.length;a<l;a++)r=i[h?l-1-a:a],G(t,r,s,c,e,n),c+=r.height+o.gap}(t,g,u,o)):(x(t,m,r),G(t,m,0,m.y,u,o))}},T=function(t,o){const e="height",{children:n,itemBox:i}=t,h=v(t,!1),{complex:r,wrap:s,xGap:c,yGap:a,isAutoYGap:l,isFitYGap:_}=h;if(!n.length)return;const g=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},u=l?0:a;let f,w,p,d,m,{x:G,y:A,width:X,height:Y}=t.__layout.contentBounds;for(let h=0,c=n.length;h<c;h++)f=n[d=o?c-1-h:h],f.__.inFlow&&0!==f.__.visible&&(w=F(f,i),r?(f.__flowBounds=w,m||(m=B(d,u)),s&&m.count&&m.height+w.height>Y&&(m.grow&&j(t,m,Y,o),l&&R(m,e,Y,_),b(g,m,e),m=B(d,u)),p=w.height,f.__heightGrow&&(m.grow+=f.__heightGrow,p=0,f.__.heightRange&&(m.hasRangeSize=!0)),f.__widthGrow&&S(f,w,X),m.height+=m.count?p+u:p,m.width=Math.max(m.width,w.width),m.count++):(O(f,G-w.x,A-w.y),A+=w.height+u));if(r){const{isAutoXGap:n,isFitXGap:i,contentAlign:r,rowXAlign:a,rowYAlign:u}=h;m.count&&(m.grow&&j(t,m,Y,o),l&&R(m,e,Y,_),s&&b(g,m,e)),s?(n?R(g,"width",X,i):g.gap=c,function(t,o,e,n){x(t,o,e);const{list:i}=o;if(i.length>1&&(n||(n=y[e]),"from"!==n)){let t;for(let e=0,h=i.length;e<h;e++)t=i[e],t.y=o.height-t.height,"center"===n&&(t.y/=2)}}(t,g,r,u),function(t,o,e,n){const{list:i}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:c}=o;for(let a=0,l=i.length;a<l;a++)r=i[h?l-1-a:a],E(t,r,s,c,e,n),s+=r.width+o.gap}(t,g,a,o)):(x(t,m,r),E(t,m,m.x,0,a,o))}};g.changeAttr("autoWidth",void 0,H),g.changeAttr("autoHeight",void 0,H),i.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:D(this);break;case"y":T(this);break;case"x-reverse":D(this,!0);break;case"y-reverse":T(this,!0)}this.leafer.created=!0},setTimeout((function(){Object.values(P).some(M)||(D=()=>{T=D})})),i.prototype.__updateContentBounds=function(){const{padding:t}=this.__,o=this.__layout,e=o.contentBounds===o.boxBounds;t?(e&&o.shrinkContent(),L(o.contentBounds,o.boxBounds,t,!0)):e||o.shrinkContentCancel()};export{w as Flow};
1
+ export*from"@leafer-in/resize";import{BoxData as t,dataProcessor as o,autoLayoutType as e,registerUI as n,Box as i,AlignHelper as h,PointHelper as r,MathHelper as s,decorateLeafAttr as c,attr as a,doBoundsType as l,inviteCode as _,UI as g,BoundsHelper as u}from"@leafer-ui/draw";function f(t,o,e,n){var i,h=arguments.length,r=h<3?o:null===n?n=Object.getOwnPropertyDescriptor(o,e):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,o,e,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(r=(h<3?i(r):h>3?i(o,e,r):i(o,e))||r);return h>3&&r&&Object.defineProperty(o,e,r),r}"function"==typeof SuppressedError&&SuppressedError;let w=class extends i{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}};f([o(class extends t{})],w.prototype,"__",void 0),f([e("x")],w.prototype,"flow",void 0),w=f([n()],w);const p={},d={"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"},y={"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 x(t,o,e){h.toPoint(e,o,t.__layout.contentBounds,p);const n=t.__;o.x=n.__autoWidth?0:p.x,o.y=n.__autoHeight?0:p.y}const{move:m}=r;function G(t,o,e,n,i,h){const{children:r}=t;let s,c,{x:a,start:l}=o,_=n;a+=e;for(let t=0,e=o.count;t<e;t++)s=r[h?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=n+(o.height-c.height)/("center"===i?2:1)),m(s,a-c.x,_-c.y),a+=c.width+o.gap):e++}function b(t,o,e){const n="width"===e?"height":"width";t[e]=Math.max(t[e],o[e]),t[n]+=t.count?o[n]+t.gap:o[n],t.list.push(o),t.count++}const A={};function v(t,o){const{gap:e,flowAlign:n,flowWrap:i,__autoWidth:h,__autoHeight:r}=t.__,s=i&&(o?!h:!r);return"object"==typeof e?(A.xGap=e.x||0,A.yGap=e.y||0):A.xGap=A.yGap=e,A.isAutoXGap="string"==typeof A.xGap&&!h,A.isAutoYGap="string"==typeof A.yGap&&!r,A.complex=s||"top-left"!==n||t.__hasGrow||A.isAutoXGap||A.isAutoYGap,A.wrap=s,A.complex&&(A.isFitXGap="fit"===A.xGap&&!h,A.isFitYGap="fit"===A.yGap&&!r,"object"==typeof n?(A.contentAlign=n.content||"top-left",A.rowXAlign=n.x||"from",A.rowYAlign=n.y||"from"):(A.contentAlign=n,A.rowXAlign=d[n],A.rowYAlign=y[n])),A}function B(t,o){return{x:0,y:0,width:0,height:0,gap:o,start:t,count:0,grow:0}}function R(t,o,e,n){const{count:i}=t;i>1&&(e>t[o]||n)&&(t.gap=(e-t[o])/(i-1),t[o]=e)}function F(t,o){return"box"===o?t.__local:t.__layout.localStrokeBounds}const{within:X}=s;function Y(t,o,e,n){let i,h,r,s=0,c=o.hasRangeSize&&[],{grow:a,start:l}=o;const _=o.width<e?(e-o.width)/a:0,{children:g}=t;_&&(o.width=e);for(let t=0,e=o.count;t<e;t++)i=g[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(h=i.__widthGrow)&&(r=k(i,i.__flowBounds,_*h),r?(s+=r,a-=h):c&&(i.__.widthRange?c.unshift(i):c.push(i))):e++;s&&function(t,o,e){let n,i,h,r;t.forEach((t=>{n=t.__widthGrow,i=o/e*n,r=k(t,h=t.__flowBounds,h.width+i),o-=i-r,e-=n}))}(c,s,a)}function k(t,o,e){const{widthRange:n,lockRatio:i}=t.__,h=n?X(e,n.min,n.max):e,r=h/o.width;return t.scaleResize(r,i?r:1),o.width=h,e-h}const{within:S}=s;function z(t,o,e,n){let i,h,r,s=0,c=o.hasRangeSize&&[],{grow:a,start:l}=o;const _=o.height<e?(e-o.height)/a:0,{children:g}=t;_&&(o.height=e);for(let t=0,e=o.count;t<e;t++)i=g[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(h=i.__heightGrow)&&(r=W(i,i.__flowBounds,_*h),r?(s+=r,a-=h):c&&(i.__.heightRange?c.unshift(i):c.push(i))):e++;s&&function(t,o,e){let n,i,h,r;t.forEach((t=>{n=t.__heightGrow,i=o/e*n,r=W(t,h=t.__flowBounds,h.height+i),o-=i-r,e-=n}))}(c,s,a)}function W(t,o,e){const{heightRange:n,lockRatio:i}=t.__,h=n?S(e,n.min,n.max):e,r=h/o.height;return t.scaleResize(i?r:1,r),o.height=h,e-h}const{move:j}=r;const{move:C}=r;function E(t,o,e,n,i,h){const{children:r}=t;let s,c,{y:a,start:l}=o,_=e;a+=n;for(let t=0,n=o.count;t<n;t++)s=r[h?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=e+(o.width-c.width)/("center"===i?2:1)),C(s,_-c.x,a-c.y),a+=c.height+o.gap):n++}const{move:O}=r;const P=_;function H(t){return c(t,(t=>a({set(o){const e="number"==typeof o?o:0;"autoWidth"===t?this.__widthGrow=e:this.__heightGrow=e,!e||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,o)&&l(this)}})))}function M(t){return t.length>6&&"e"===t[6]}const{copyAndSpread:L}=u;let D=function(t,o){const e="width",{children:n,itemBox:i}=t,h=v(t,!0),{complex:r,wrap:s,xGap:c,yGap:a,isAutoXGap:l,isFitXGap:_}=h;if(!n.length)return;const g=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},u=l?0:c;let f,w,p,y,m,{x:A,y:X,width:k,height:S}=t.__layout.contentBounds;for(let h=0,c=n.length;h<c;h++)f=n[y=o?c-1-h:h],f.__.inFlow&&0!==f.__.visible&&(w=F(f,i),r?(f.__flowBounds=w,m||(m=B(y,u)),s&&m.count&&m.width+w.width>k&&(m.grow?Y(t,m,k,o):l&&R(m,e,k,_),b(g,m,e),m=B(y,u)),p=w.width,f.__widthGrow&&(m.grow+=f.__widthGrow,p=0,f.__.widthRange&&(m.hasRangeSize=!0)),f.__heightGrow&&W(f,w,S),m.width+=m.count?p+u:p,m.height=Math.max(m.height,w.height),m.count++):(j(f,A-w.x,X-w.y),A+=w.width+u));if(r){const{isAutoYGap:n,isFitYGap:i,contentAlign:r,rowXAlign:c,rowYAlign:u}=h;m.count&&(m.grow?Y(t,m,k,o):l&&R(m,e,k,_),s&&b(g,m,e)),s?(n?R(g,"height",S,i):g.gap=a,function(t,o,e,n){x(t,o,e);const{list:i}=o;if(i.length>1&&(n||(n=d[e]),"from"!==n)){let t;for(let e=0,h=i.length;e<h;e++)t=i[e],t.x=o.width-t.width,"center"===n&&(t.x/=2)}}(t,g,r,c),function(t,o,e,n){const{list:i}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:c}=o;for(let a=0,l=i.length;a<l;a++)r=i[h?l-1-a:a],G(t,r,s,c,e,n),c+=r.height+o.gap}(t,g,u,o)):(x(t,m,r),G(t,m,0,m.y,u,o))}},T=function(t,o){const e="height",{children:n,itemBox:i}=t,h=v(t,!1),{complex:r,wrap:s,xGap:c,yGap:a,isAutoYGap:l,isFitYGap:_}=h;if(!n.length)return;const g=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},u=l?0:a;let f,w,p,d,m,{x:G,y:A,width:X,height:Y}=t.__layout.contentBounds;for(let h=0,c=n.length;h<c;h++)f=n[d=o?c-1-h:h],f.__.inFlow&&0!==f.__.visible&&(w=F(f,i),r?(f.__flowBounds=w,m||(m=B(d,u)),s&&m.count&&m.height+w.height>Y&&(m.grow&&z(t,m,Y,o),l&&R(m,e,Y,_),b(g,m,e),m=B(d,u)),p=w.height,f.__heightGrow&&(m.grow+=f.__heightGrow,p=0,f.__.heightRange&&(m.hasRangeSize=!0)),f.__widthGrow&&k(f,w,X),m.height+=m.count?p+u:p,m.width=Math.max(m.width,w.width),m.count++):(O(f,G-w.x,A-w.y),A+=w.height+u));if(r){const{isAutoXGap:n,isFitXGap:i,contentAlign:r,rowXAlign:a,rowYAlign:u}=h;m.count&&(m.grow&&z(t,m,Y,o),l&&R(m,e,Y,_),s&&b(g,m,e)),s?(n?R(g,"width",X,i):g.gap=c,function(t,o,e,n){x(t,o,e);const{list:i}=o;if(i.length>1&&(n||(n=y[e]),"from"!==n)){let t;for(let e=0,h=i.length;e<h;e++)t=i[e],t.y=o.height-t.height,"center"===n&&(t.y/=2)}}(t,g,r,u),function(t,o,e,n){const{list:i}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:c}=o;for(let a=0,l=i.length;a<l;a++)r=i[h?l-1-a:a],E(t,r,s,c,e,n),s+=r.width+o.gap}(t,g,a,o)):(x(t,m,r),E(t,m,m.x,0,a,o))}};g.changeAttr("autoWidth",void 0,H),g.changeAttr("autoHeight",void 0,H),i.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:D(this);break;case"y":T(this);break;case"x-reverse":D(this,!0);break;case"y-reverse":T(this,!0)}this.leafer.created=!0},setTimeout((function(){Object.values(P).some(M)||(D=()=>{T=D})})),i.prototype.__updateContentBounds=function(){const{padding:t}=this.__,o=this.__layout,e=o.contentBounds===o.boxBounds;t?(e&&o.shrinkContent(),L(o.contentBounds,o.boxBounds,t,!0)):e||o.shrinkContentCancel()};export{w as Flow};
package/dist/flow.js CHANGED
@@ -1 +1 @@
1
- this.LeaferIN=this.LeaferIN||{},this.LeaferIN.flow=function(t,e){"use strict";function o(t,e,o,n){var i,r=arguments.length,h=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(h=(r<3?i(h):r>3?i(e,o,h):i(e,o))||h);return r>3&&h&&Object.defineProperty(e,o,h),h}"function"==typeof SuppressedError&&SuppressedError;class n extends e.BoxData{}t.Flow=class extends e.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},o([e.dataProcessor(n)],t.Flow.prototype,"__",void 0),o([e.autoLayoutType("x")],t.Flow.prototype,"flow",void 0),t.Flow=o([e.registerUI()],t.Flow);const i={},r={"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"},h={"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 s(t,o,n){e.AlignHelper.toPoint(n,o,t.__layout.contentBounds,i);const r=t.__;o.x=r.__autoWidth?0:i.x,o.y=r.__autoHeight?0:i.y}const{move:c}=e.PointHelper;function a(t,e,o,n,i,r){const{children:h}=t;let s,a,{x:l,start:_}=e,u=n;l+=o;for(let t=0,o=e.count;t<o;t++)s=h[r?_-t:_+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==i&&(u=n+(e.height-a.height)/("center"===i?2:1)),c(s,l-a.x,u-a.y),l+=a.width+e.gap):o++}function l(t,e,o){const n="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[n]+=t.count?e[n]+t.gap:e[n],t.list.push(e),t.count++}const _={};function u(t,e){const{gap:o,flowAlign:n,flowWrap:i,__autoWidth:s,__autoHeight:c}=t.__,a=i&&(e?!s:!c);return"object"==typeof o?(_.xGap=o.x||0,_.yGap=o.y||0):_.xGap=_.yGap=o,_.isAutoXGap="string"==typeof _.xGap&&!s,_.isAutoYGap="string"==typeof _.yGap&&!c,_.complex=a||"top-left"!==n||t.__hasGrow||_.isAutoXGap||_.isAutoYGap,_.wrap=a,_.complex&&(_.isFitXGap="fit"===_.xGap&&!s,_.isFitYGap="fit"===_.yGap&&!c,"object"==typeof n?(_.contentAlign=n.content||"top-left",_.rowXAlign=n.x||"from",_.rowYAlign=n.y||"from"):(_.contentAlign=n,_.rowXAlign=r[n],_.rowYAlign=h[n])),_}function g(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function f(t,e,o,n){const{count:i}=t;i>1&&(o>t[e]||n)&&(t.gap=(o-t[e])/(i-1),t[e]=o)}function w(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:p}=e.MathHelper;function d(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:a,start:l}=e;const _=e.width<o?(o-e.width)/a:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)i=u[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(r=i.__widthGrow)&&(h=y(i,i.__flowBounds,_*r),h?(s+=h,a-=r):c&&(i.__.widthRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__widthGrow,i=e/o*n,h=y(t,r=t.__flowBounds,r.width+i),e-=i-h,o-=n}))}(c,s,a)}function y(t,e,o){const{widthRange:n}=t.__,i=n?p(o,n.min,n.max):o;return t.scaleResize(i/e.width,1),e.width=i,o-i}const{within:x}=e.MathHelper;function G(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:a,start:l}=e;const _=e.height<o?(o-e.height)/a:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)i=u[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(r=i.__heightGrow)&&(h=m(i,i.__flowBounds,_*r),h?(s+=h,a-=r):c&&(i.__.heightRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__heightGrow,i=e/o*n,h=m(t,r=t.__flowBounds,r.height+i),e-=i-h,o-=n}))}(c,s,a)}function m(t,e,o){const{heightRange:n}=t.__,i=n?x(o,n.min,n.max):o;return t.scaleResize(1,i/e.height),e.height=i,o-i}const{move:b}=e.PointHelper;const{move:A}=e.PointHelper;function B(t,e,o,n,i,r){const{children:h}=t;let s,c,{y:a,start:l}=e,_=o;a+=n;for(let t=0,n=e.count;t<n;t++)s=h[r?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=o+(e.width-c.width)/("center"===i?2:1)),A(s,_-c.x,a-c.y),a+=c.height+e.gap):n++}const{move:v}=e.PointHelper;const F=e.inviteCode;function R(t){return e.decorateLeafAttr(t,(t=>e.attr({set(o){const n="number"==typeof o?o:0;"autoWidth"===t?this.__widthGrow=n:this.__heightGrow=n,!n||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,o)&&e.doBoundsType(this)}})))}function H(t){return t.length>6&&"e"===t[6]}const{copyAndSpread:X}=e.BoundsHelper;let Y=function(t,e){const o="width",{children:n,itemBox:i}=t,h=u(t,!0),{complex:c,wrap:_,xGap:p,yGap:y,isAutoXGap:x,isFitXGap:G}=h;if(!n.length)return;const A=_&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},B=x?0:p;let v,F,R,H,X,{x:Y,y:P,width:L,height:S}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)v=n[H=e?h-1-r:r],v.__.inFlow&&0!==v.__.visible&&(F=w(v,i),c?(v.__flowBounds=F,X||(X=g(H,B)),_&&X.count&&X.width+F.width>L&&(X.grow?d(t,X,L,e):x&&f(X,o,L,G),l(A,X,o),X=g(H,B)),R=F.width,v.__widthGrow&&(X.grow+=v.__widthGrow,R=0,v.__.widthRange&&(X.hasRangeSize=!0)),v.__heightGrow&&m(v,F,S),X.width+=X.count?R+B:R,X.height=Math.max(X.height,F.height),X.count++):(b(v,Y-F.x,P-F.y),Y+=F.width+B));if(c){const{isAutoYGap:n,isFitYGap:i,contentAlign:c,rowXAlign:u,rowYAlign:g}=h;X.count&&(X.grow?d(t,X,L,e):x&&f(X,o,L,G),_&&l(A,X,o)),_?(n?f(A,"height",S,i):A.gap=y,function(t,e,o,n){s(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=r[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.x=e.width-t.width,"center"===n&&(t.x/=2)}}(t,A,c,u),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let l=0,_=i.length;l<_;l++)h=i[r?_-1-l:l],a(t,h,s,c,o,n),c+=h.height+e.gap}(t,A,g,e)):(s(t,X,c),a(t,X,0,X.y,g,e))}},P=function(t,e){const o="height",{children:n,itemBox:i}=t,r=u(t,!1),{complex:c,wrap:a,xGap:_,yGap:p,isAutoYGap:d,isFitYGap:x}=r;if(!n.length)return;const m=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},b=d?0:p;let A,F,R,H,X,{x:Y,y:P,width:L,height:S}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)A=n[H=e?h-1-r:r],A.__.inFlow&&0!==A.__.visible&&(F=w(A,i),c?(A.__flowBounds=F,X||(X=g(H,b)),a&&X.count&&X.height+F.height>S&&(X.grow&&G(t,X,S,e),d&&f(X,o,S,x),l(m,X,o),X=g(H,b)),R=F.height,A.__heightGrow&&(X.grow+=A.__heightGrow,R=0,A.__.heightRange&&(X.hasRangeSize=!0)),A.__widthGrow&&y(A,F,L),X.height+=X.count?R+b:R,X.width=Math.max(X.width,F.width),X.count++):(v(A,Y-F.x,P-F.y),P+=F.height+b));if(c){const{isAutoXGap:n,isFitXGap:i,contentAlign:c,rowXAlign:u,rowYAlign:g}=r;X.count&&(X.grow&&G(t,X,S,e),d&&f(X,o,S,x),a&&l(m,X,o)),a?(n?f(m,"width",L,i):m.gap=_,function(t,e,o,n){s(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=h[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.y=e.height-t.height,"center"===n&&(t.y/=2)}}(t,m,c,g),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let a=0,l=i.length;a<l;a++)h=i[r?l-1-a:a],B(t,h,s,c,o,n),s+=h.width+e.gap}(t,m,u,e)):(s(t,X,c),B(t,X,X.x,0,u,e))}};return e.UI.changeAttr("autoWidth",void 0,R),e.UI.changeAttr("autoHeight",void 0,R),e.Box.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:Y(this);break;case"y":P(this);break;case"x-reverse":Y(this,!0);break;case"y-reverse":P(this,!0)}this.leafer.created=!0},setTimeout((function(){Object.values(F).some(H)||(Y=()=>{P=Y})})),e.Box.prototype.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),X(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},t}({},LeaferUI);
1
+ this.LeaferIN=this.LeaferIN||{},this.LeaferIN.flow=function(t,e,o){"use strict";function n(t,e,o,n){var i,r=arguments.length,h=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(h=(r<3?i(h):r>3?i(e,o,h):i(e,o))||h);return r>3&&h&&Object.defineProperty(e,o,h),h}"function"==typeof SuppressedError&&SuppressedError;class i extends o.BoxData{}t.Flow=class extends o.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},n([o.dataProcessor(i)],t.Flow.prototype,"__",void 0),n([o.autoLayoutType("x")],t.Flow.prototype,"flow",void 0),t.Flow=n([o.registerUI()],t.Flow);const r={},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"},s={"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(t,e,n){o.AlignHelper.toPoint(n,e,t.__layout.contentBounds,r);const i=t.__;e.x=i.__autoWidth?0:r.x,e.y=i.__autoHeight?0:r.y}const{move:a}=o.PointHelper;function l(t,e,o,n,i,r){const{children:h}=t;let s,c,{x:l,start:_}=e,u=n;l+=o;for(let t=0,o=e.count;t<o;t++)s=h[r?_-t:_+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(u=n+(e.height-c.height)/("center"===i?2:1)),a(s,l-c.x,u-c.y),l+=c.width+e.gap):o++}function _(t,e,o){const n="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[n]+=t.count?e[n]+t.gap:e[n],t.list.push(e),t.count++}const u={};function f(t,e){const{gap:o,flowAlign:n,flowWrap:i,__autoWidth:r,__autoHeight:c}=t.__,a=i&&(e?!r:!c);return"object"==typeof o?(u.xGap=o.x||0,u.yGap=o.y||0):u.xGap=u.yGap=o,u.isAutoXGap="string"==typeof u.xGap&&!r,u.isAutoYGap="string"==typeof u.yGap&&!c,u.complex=a||"top-left"!==n||t.__hasGrow||u.isAutoXGap||u.isAutoYGap,u.wrap=a,u.complex&&(u.isFitXGap="fit"===u.xGap&&!r,u.isFitYGap="fit"===u.yGap&&!c,"object"==typeof n?(u.contentAlign=n.content||"top-left",u.rowXAlign=n.x||"from",u.rowYAlign=n.y||"from"):(u.contentAlign=n,u.rowXAlign=h[n],u.rowYAlign=s[n])),u}function g(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function w(t,e,o,n){const{count:i}=t;i>1&&(o>t[e]||n)&&(t.gap=(o-t[e])/(i-1),t[e]=o)}function p(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:d}=o.MathHelper;function y(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:a,start:l}=e;const _=e.width<o?(o-e.width)/a:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)i=u[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(r=i.__widthGrow)&&(h=x(i,i.__flowBounds,_*r),h?(s+=h,a-=r):c&&(i.__.widthRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__widthGrow,i=e/o*n,h=x(t,r=t.__flowBounds,r.width+i),e-=i-h,o-=n}))}(c,s,a)}function x(t,e,o){const{widthRange:n,lockRatio:i}=t.__,r=n?d(o,n.min,n.max):o,h=r/e.width;return t.scaleResize(h,i?h:1),e.width=r,o-r}const{within:G}=o.MathHelper;function m(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:a,start:l}=e;const _=e.height<o?(o-e.height)/a:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)i=u[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(r=i.__heightGrow)&&(h=b(i,i.__flowBounds,_*r),h?(s+=h,a-=r):c&&(i.__.heightRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__heightGrow,i=e/o*n,h=b(t,r=t.__flowBounds,r.height+i),e-=i-h,o-=n}))}(c,s,a)}function b(t,e,o){const{heightRange:n,lockRatio:i}=t.__,r=n?G(o,n.min,n.max):o,h=r/e.height;return t.scaleResize(i?h:1,h),e.height=r,o-r}const{move:A}=o.PointHelper;const{move:B}=o.PointHelper;function v(t,e,o,n,i,r){const{children:h}=t;let s,c,{y:a,start:l}=e,_=o;a+=n;for(let t=0,n=e.count;t<n;t++)s=h[r?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=o+(e.width-c.width)/("center"===i?2:1)),B(s,_-c.x,a-c.y),a+=c.height+e.gap):n++}const{move:F}=o.PointHelper;const R=o.inviteCode;function H(t){return o.decorateLeafAttr(t,(t=>o.attr({set(e){const n="number"==typeof e?e:0;"autoWidth"===t?this.__widthGrow=n:this.__heightGrow=n,!n||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,e)&&o.doBoundsType(this)}})))}function P(t){return t.length>6&&"e"===t[6]}const{copyAndSpread:X}=o.BoundsHelper;let Y=function(t,e){const o="width",{children:n,itemBox:i}=t,r=f(t,!0),{complex:s,wrap:a,xGap:u,yGap:d,isAutoXGap:x,isFitXGap:G}=r;if(!n.length)return;const m=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},B=x?0:u;let v,F,R,H,P,{x:X,y:Y,width:j,height:k}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)v=n[H=e?h-1-r:r],v.__.inFlow&&0!==v.__.visible&&(F=p(v,i),s?(v.__flowBounds=F,P||(P=g(H,B)),a&&P.count&&P.width+F.width>j&&(P.grow?y(t,P,j,e):x&&w(P,o,j,G),_(m,P,o),P=g(H,B)),R=F.width,v.__widthGrow&&(P.grow+=v.__widthGrow,R=0,v.__.widthRange&&(P.hasRangeSize=!0)),v.__heightGrow&&b(v,F,k),P.width+=P.count?R+B:R,P.height=Math.max(P.height,F.height),P.count++):(A(v,X-F.x,Y-F.y),X+=F.width+B));if(s){const{isAutoYGap:n,isFitYGap:i,contentAlign:s,rowXAlign:u,rowYAlign:f}=r;P.count&&(P.grow?y(t,P,j,e):x&&w(P,o,j,G),a&&_(m,P,o)),a?(n?w(m,"height",k,i):m.gap=d,function(t,e,o,n){c(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=h[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.x=e.width-t.width,"center"===n&&(t.x/=2)}}(t,m,s,u),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let a=0,_=i.length;a<_;a++)h=i[r?_-1-a:a],l(t,h,s,c,o,n),c+=h.height+e.gap}(t,m,f,e)):(c(t,P,s),l(t,P,0,P.y,f,e))}},j=function(t,e){const o="height",{children:n,itemBox:i}=t,r=f(t,!1),{complex:h,wrap:a,xGap:l,yGap:u,isAutoYGap:d,isFitYGap:y}=r;if(!n.length)return;const G=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},b=d?0:u;let A,B,R,H,P,{x:X,y:Y,width:j,height:k}=t.__layout.contentBounds;for(let r=0,s=n.length;r<s;r++)A=n[H=e?s-1-r:r],A.__.inFlow&&0!==A.__.visible&&(B=p(A,i),h?(A.__flowBounds=B,P||(P=g(H,b)),a&&P.count&&P.height+B.height>k&&(P.grow&&m(t,P,k,e),d&&w(P,o,k,y),_(G,P,o),P=g(H,b)),R=B.height,A.__heightGrow&&(P.grow+=A.__heightGrow,R=0,A.__.heightRange&&(P.hasRangeSize=!0)),A.__widthGrow&&x(A,B,j),P.height+=P.count?R+b:R,P.width=Math.max(P.width,B.width),P.count++):(F(A,X-B.x,Y-B.y),Y+=B.height+b));if(h){const{isAutoXGap:n,isFitXGap:i,contentAlign:h,rowXAlign:u,rowYAlign:f}=r;P.count&&(P.grow&&m(t,P,k,e),d&&w(P,o,k,y),a&&_(G,P,o)),a?(n?w(G,"width",j,i):G.gap=l,function(t,e,o,n){c(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=s[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.y=e.height-t.height,"center"===n&&(t.y/=2)}}(t,G,h,f),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let a=0,l=i.length;a<l;a++)h=i[r?l-1-a:a],v(t,h,s,c,o,n),s+=h.width+e.gap}(t,G,u,e)):(c(t,P,h),v(t,P,P.x,0,u,e))}};return o.UI.changeAttr("autoWidth",void 0,H),o.UI.changeAttr("autoHeight",void 0,H),o.Box.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:Y(this);break;case"y":j(this);break;case"x-reverse":Y(this,!0);break;case"y-reverse":j(this,!0)}this.leafer.created=!0},setTimeout((function(){Object.values(R).some(P)||(Y=()=>{j=Y})})),o.Box.prototype.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),X(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},Object.keys(e).forEach((function(o){"default"===o||Object.prototype.hasOwnProperty.call(t,o)||Object.defineProperty(t,o,{enumerable:!0,get:function(){return e[o]}})})),t}({},LeaferIN.resize,LeaferUI);
package/dist/flow.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer-ui/draw");function e(t,e,o,n){var i,r=arguments.length,h=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(h=(r<3?i(h):r>3?i(e,o,h):i(e,o))||h);return r>3&&h&&Object.defineProperty(e,o,h),h}"function"==typeof SuppressedError&&SuppressedError;class o extends t.BoxData{}exports.Flow=class extends t.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},e([t.dataProcessor(o)],exports.Flow.prototype,"__",void 0),e([t.autoLayoutType("x")],exports.Flow.prototype,"flow",void 0),exports.Flow=e([t.registerUI()],exports.Flow);const n={},i={"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"},r={"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 h(e,o,i){t.AlignHelper.toPoint(i,o,e.__layout.contentBounds,n);const r=e.__;o.x=r.__autoWidth?0:n.x,o.y=r.__autoHeight?0:n.y}const{move:s}=t.PointHelper;function c(t,e,o,n,i,r){const{children:h}=t;let c,l,{x:a,start:_}=e,u=n;a+=o;for(let t=0,o=e.count;t<o;t++)c=h[r?_-t:_+t],c.__.inFlow&&0!==c.__.visible?(l=c.__flowBounds,"from"!==i&&(u=n+(e.height-l.height)/("center"===i?2:1)),s(c,a-l.x,u-l.y),a+=l.width+e.gap):o++}function l(t,e,o){const n="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[n]+=t.count?e[n]+t.gap:e[n],t.list.push(e),t.count++}const a={};function _(t,e){const{gap:o,flowAlign:n,flowWrap:h,__autoWidth:s,__autoHeight:c}=t.__,l=h&&(e?!s:!c);return"object"==typeof o?(a.xGap=o.x||0,a.yGap=o.y||0):a.xGap=a.yGap=o,a.isAutoXGap="string"==typeof a.xGap&&!s,a.isAutoYGap="string"==typeof a.yGap&&!c,a.complex=l||"top-left"!==n||t.__hasGrow||a.isAutoXGap||a.isAutoYGap,a.wrap=l,a.complex&&(a.isFitXGap="fit"===a.xGap&&!s,a.isFitYGap="fit"===a.yGap&&!c,"object"==typeof n?(a.contentAlign=n.content||"top-left",a.rowXAlign=n.x||"from",a.rowYAlign=n.y||"from"):(a.contentAlign=n,a.rowXAlign=i[n],a.rowYAlign=r[n])),a}function u(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function g(t,e,o,n){const{count:i}=t;i>1&&(o>t[e]||n)&&(t.gap=(o-t[e])/(i-1),t[e]=o)}function p(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:w}=t.MathHelper;function f(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:l,start:a}=e;const _=e.width<o?(o-e.width)/l:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)i=u[n?a-t:a+t],i.__.inFlow&&0!==i.__.visible?(r=i.__widthGrow)&&(h=d(i,i.__flowBounds,_*r),h?(s+=h,l-=r):c&&(i.__.widthRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__widthGrow,i=e/o*n,h=d(t,r=t.__flowBounds,r.width+i),e-=i-h,o-=n}))}(c,s,l)}function d(t,e,o){const{widthRange:n}=t.__,i=n?w(o,n.min,n.max):o;return t.scaleResize(i/e.width,1),e.width=i,o-i}const{within:x}=t.MathHelper;function y(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:l,start:a}=e;const _=e.height<o?(o-e.height)/l:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)i=u[n?a-t:a+t],i.__.inFlow&&0!==i.__.visible?(r=i.__heightGrow)&&(h=G(i,i.__flowBounds,_*r),h?(s+=h,l-=r):c&&(i.__.heightRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__heightGrow,i=e/o*n,h=G(t,r=t.__flowBounds,r.height+i),e-=i-h,o-=n}))}(c,s,l)}function G(t,e,o){const{heightRange:n}=t.__,i=n?x(o,n.min,n.max):o;return t.scaleResize(1,i/e.height),e.height=i,o-i}const{move:m}=t.PointHelper;const{move:b}=t.PointHelper;function A(t,e,o,n,i,r){const{children:h}=t;let s,c,{y:l,start:a}=e,_=o;l+=n;for(let t=0,n=e.count;t<n;t++)s=h[r?a-t:a+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=o+(e.width-c.width)/("center"===i?2:1)),b(s,_-c.x,l-c.y),l+=c.height+e.gap):n++}const{move:B}=t.PointHelper;const v=t.inviteCode;function F(e){return t.decorateLeafAttr(e,(e=>t.attr({set(o){const n="number"==typeof o?o:0;"autoWidth"===e?this.__widthGrow=n:this.__heightGrow=n,!n||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(e,o)&&t.doBoundsType(this)}})))}function R(t){return t.length>6&&"e"===t[6]}const{copyAndSpread:H}=t.BoundsHelper;let X=function(t,e){const o="width",{children:n,itemBox:r}=t,s=_(t,!0),{complex:a,wrap:w,xGap:d,yGap:x,isAutoXGap:y,isFitXGap:b}=s;if(!n.length)return;const A=w&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},B=y?0:d;let v,F,R,H,X,{x:Y,y:P,width:S,height:W}=t.__layout.contentBounds;for(let i=0,h=n.length;i<h;i++)v=n[H=e?h-1-i:i],v.__.inFlow&&0!==v.__.visible&&(F=p(v,r),a?(v.__flowBounds=F,X||(X=u(H,B)),w&&X.count&&X.width+F.width>S&&(X.grow?f(t,X,S,e):y&&g(X,o,S,b),l(A,X,o),X=u(H,B)),R=F.width,v.__widthGrow&&(X.grow+=v.__widthGrow,R=0,v.__.widthRange&&(X.hasRangeSize=!0)),v.__heightGrow&&G(v,F,W),X.width+=X.count?R+B:R,X.height=Math.max(X.height,F.height),X.count++):(m(v,Y-F.x,P-F.y),Y+=F.width+B));if(a){const{isAutoYGap:n,isFitYGap:r,contentAlign:a,rowXAlign:_,rowYAlign:u}=s;X.count&&(X.grow?f(t,X,S,e):y&&g(X,o,S,b),w&&l(A,X,o)),w?(n?g(A,"height",W,r):A.gap=x,function(t,e,o,n){h(t,e,o);const{list:r}=e;if(r.length>1&&(n||(n=i[o]),"from"!==n)){let t;for(let o=0,i=r.length;o<i;o++)t=r[o],t.x=e.width-t.width,"center"===n&&(t.x/=2)}}(t,A,a,_),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:l}=e;for(let a=0,_=i.length;a<_;a++)h=i[r?_-1-a:a],c(t,h,s,l,o,n),l+=h.height+e.gap}(t,A,u,e)):(h(t,X,a),c(t,X,0,X.y,u,e))}},Y=function(t,e){const o="height",{children:n,itemBox:i}=t,s=_(t,!1),{complex:c,wrap:a,xGap:w,yGap:f,isAutoYGap:x,isFitYGap:G}=s;if(!n.length)return;const m=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},b=x?0:f;let v,F,R,H,X,{x:Y,y:P,width:S,height:W}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)v=n[H=e?h-1-r:r],v.__.inFlow&&0!==v.__.visible&&(F=p(v,i),c?(v.__flowBounds=F,X||(X=u(H,b)),a&&X.count&&X.height+F.height>W&&(X.grow&&y(t,X,W,e),x&&g(X,o,W,G),l(m,X,o),X=u(H,b)),R=F.height,v.__heightGrow&&(X.grow+=v.__heightGrow,R=0,v.__.heightRange&&(X.hasRangeSize=!0)),v.__widthGrow&&d(v,F,S),X.height+=X.count?R+b:R,X.width=Math.max(X.width,F.width),X.count++):(B(v,Y-F.x,P-F.y),P+=F.height+b));if(c){const{isAutoXGap:n,isFitXGap:i,contentAlign:c,rowXAlign:_,rowYAlign:u}=s;X.count&&(X.grow&&y(t,X,W,e),x&&g(X,o,W,G),a&&l(m,X,o)),a?(n?g(m,"width",S,i):m.gap=w,function(t,e,o,n){h(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=r[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.y=e.height-t.height,"center"===n&&(t.y/=2)}}(t,m,c,u),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let l=0,a=i.length;l<a;l++)h=i[r?a-1-l:l],A(t,h,s,c,o,n),s+=h.width+e.gap}(t,m,_,e)):(h(t,X,c),A(t,X,X.x,0,_,e))}};t.UI.changeAttr("autoWidth",void 0,F),t.UI.changeAttr("autoHeight",void 0,F),t.Box.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:X(this);break;case"y":Y(this);break;case"x-reverse":X(this,!0);break;case"y-reverse":Y(this,!0)}this.leafer.created=!0},setTimeout((function(){Object.values(v).some(R)||(X=()=>{Y=X})})),t.Box.prototype.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),H(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()};
1
+ "use strict";var t=require("@leafer-in/resize"),e=require("@leafer-ui/draw");function o(t,e,o,n){var i,r=arguments.length,h=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(h=(r<3?i(h):r>3?i(e,o,h):i(e,o))||h);return r>3&&h&&Object.defineProperty(e,o,h),h}"function"==typeof SuppressedError&&SuppressedError;class n extends e.BoxData{}exports.Flow=class extends e.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},o([e.dataProcessor(n)],exports.Flow.prototype,"__",void 0),o([e.autoLayoutType("x")],exports.Flow.prototype,"flow",void 0),exports.Flow=o([e.registerUI()],exports.Flow);const i={},r={"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"},h={"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 s(t,o,n){e.AlignHelper.toPoint(n,o,t.__layout.contentBounds,i);const r=t.__;o.x=r.__autoWidth?0:i.x,o.y=r.__autoHeight?0:i.y}const{move:c}=e.PointHelper;function a(t,e,o,n,i,r){const{children:h}=t;let s,a,{x:l,start:_}=e,u=n;l+=o;for(let t=0,o=e.count;t<o;t++)s=h[r?_-t:_+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==i&&(u=n+(e.height-a.height)/("center"===i?2:1)),c(s,l-a.x,u-a.y),l+=a.width+e.gap):o++}function l(t,e,o){const n="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[n]+=t.count?e[n]+t.gap:e[n],t.list.push(e),t.count++}const _={};function u(t,e){const{gap:o,flowAlign:n,flowWrap:i,__autoWidth:s,__autoHeight:c}=t.__,a=i&&(e?!s:!c);return"object"==typeof o?(_.xGap=o.x||0,_.yGap=o.y||0):_.xGap=_.yGap=o,_.isAutoXGap="string"==typeof _.xGap&&!s,_.isAutoYGap="string"==typeof _.yGap&&!c,_.complex=a||"top-left"!==n||t.__hasGrow||_.isAutoXGap||_.isAutoYGap,_.wrap=a,_.complex&&(_.isFitXGap="fit"===_.xGap&&!s,_.isFitYGap="fit"===_.yGap&&!c,"object"==typeof n?(_.contentAlign=n.content||"top-left",_.rowXAlign=n.x||"from",_.rowYAlign=n.y||"from"):(_.contentAlign=n,_.rowXAlign=r[n],_.rowYAlign=h[n])),_}function g(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function p(t,e,o,n){const{count:i}=t;i>1&&(o>t[e]||n)&&(t.gap=(o-t[e])/(i-1),t[e]=o)}function f(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:w}=e.MathHelper;function d(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:a,start:l}=e;const _=e.width<o?(o-e.width)/a:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)i=u[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(r=i.__widthGrow)&&(h=y(i,i.__flowBounds,_*r),h?(s+=h,a-=r):c&&(i.__.widthRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__widthGrow,i=e/o*n,h=y(t,r=t.__flowBounds,r.width+i),e-=i-h,o-=n}))}(c,s,a)}function y(t,e,o){const{widthRange:n,lockRatio:i}=t.__,r=n?w(o,n.min,n.max):o,h=r/e.width;return t.scaleResize(h,i?h:1),e.width=r,o-r}const{within:x}=e.MathHelper;function G(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:a,start:l}=e;const _=e.height<o?(o-e.height)/a:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)i=u[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(r=i.__heightGrow)&&(h=m(i,i.__flowBounds,_*r),h?(s+=h,a-=r):c&&(i.__.heightRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__heightGrow,i=e/o*n,h=m(t,r=t.__flowBounds,r.height+i),e-=i-h,o-=n}))}(c,s,a)}function m(t,e,o){const{heightRange:n,lockRatio:i}=t.__,r=n?x(o,n.min,n.max):o,h=r/e.height;return t.scaleResize(i?h:1,h),e.height=r,o-r}const{move:b}=e.PointHelper;const{move:A}=e.PointHelper;function B(t,e,o,n,i,r){const{children:h}=t;let s,c,{y:a,start:l}=e,_=o;a+=n;for(let t=0,n=e.count;t<n;t++)s=h[r?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=o+(e.width-c.width)/("center"===i?2:1)),A(s,_-c.x,a-c.y),a+=c.height+e.gap):n++}const{move:v}=e.PointHelper;const F=e.inviteCode;function R(t){return e.decorateLeafAttr(t,(t=>e.attr({set(o){const n="number"==typeof o?o:0;"autoWidth"===t?this.__widthGrow=n:this.__heightGrow=n,!n||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,o)&&e.doBoundsType(this)}})))}function H(t){return t.length>6&&"e"===t[6]}const{copyAndSpread:P}=e.BoundsHelper;let X=function(t,e){const o="width",{children:n,itemBox:i}=t,h=u(t,!0),{complex:c,wrap:_,xGap:w,yGap:y,isAutoXGap:x,isFitXGap:G}=h;if(!n.length)return;const A=_&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},B=x?0:w;let v,F,R,H,P,{x:X,y:Y,width:j,height:k}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)v=n[H=e?h-1-r:r],v.__.inFlow&&0!==v.__.visible&&(F=f(v,i),c?(v.__flowBounds=F,P||(P=g(H,B)),_&&P.count&&P.width+F.width>j&&(P.grow?d(t,P,j,e):x&&p(P,o,j,G),l(A,P,o),P=g(H,B)),R=F.width,v.__widthGrow&&(P.grow+=v.__widthGrow,R=0,v.__.widthRange&&(P.hasRangeSize=!0)),v.__heightGrow&&m(v,F,k),P.width+=P.count?R+B:R,P.height=Math.max(P.height,F.height),P.count++):(b(v,X-F.x,Y-F.y),X+=F.width+B));if(c){const{isAutoYGap:n,isFitYGap:i,contentAlign:c,rowXAlign:u,rowYAlign:g}=h;P.count&&(P.grow?d(t,P,j,e):x&&p(P,o,j,G),_&&l(A,P,o)),_?(n?p(A,"height",k,i):A.gap=y,function(t,e,o,n){s(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=r[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.x=e.width-t.width,"center"===n&&(t.x/=2)}}(t,A,c,u),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let l=0,_=i.length;l<_;l++)h=i[r?_-1-l:l],a(t,h,s,c,o,n),c+=h.height+e.gap}(t,A,g,e)):(s(t,P,c),a(t,P,0,P.y,g,e))}},Y=function(t,e){const o="height",{children:n,itemBox:i}=t,r=u(t,!1),{complex:c,wrap:a,xGap:_,yGap:w,isAutoYGap:d,isFitYGap:x}=r;if(!n.length)return;const m=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},b=d?0:w;let A,F,R,H,P,{x:X,y:Y,width:j,height:k}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)A=n[H=e?h-1-r:r],A.__.inFlow&&0!==A.__.visible&&(F=f(A,i),c?(A.__flowBounds=F,P||(P=g(H,b)),a&&P.count&&P.height+F.height>k&&(P.grow&&G(t,P,k,e),d&&p(P,o,k,x),l(m,P,o),P=g(H,b)),R=F.height,A.__heightGrow&&(P.grow+=A.__heightGrow,R=0,A.__.heightRange&&(P.hasRangeSize=!0)),A.__widthGrow&&y(A,F,j),P.height+=P.count?R+b:R,P.width=Math.max(P.width,F.width),P.count++):(v(A,X-F.x,Y-F.y),Y+=F.height+b));if(c){const{isAutoXGap:n,isFitXGap:i,contentAlign:c,rowXAlign:u,rowYAlign:g}=r;P.count&&(P.grow&&G(t,P,k,e),d&&p(P,o,k,x),a&&l(m,P,o)),a?(n?p(m,"width",j,i):m.gap=_,function(t,e,o,n){s(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=h[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.y=e.height-t.height,"center"===n&&(t.y/=2)}}(t,m,c,g),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let a=0,l=i.length;a<l;a++)h=i[r?l-1-a:a],B(t,h,s,c,o,n),s+=h.width+e.gap}(t,m,u,e)):(s(t,P,c),B(t,P,P.x,0,u,e))}};e.UI.changeAttr("autoWidth",void 0,R),e.UI.changeAttr("autoHeight",void 0,R),e.Box.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:X(this);break;case"y":Y(this);break;case"x-reverse":X(this,!0);break;case"y-reverse":Y(this,!0)}this.leafer.created=!0},setTimeout((function(){Object.values(F).some(H)||(X=()=>{Y=X})})),e.Box.prototype.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),P(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
package/dist/flow.min.js CHANGED
@@ -1 +1 @@
1
- this.LeaferIN=this.LeaferIN||{},this.LeaferIN.flow=function(t,e){"use strict";function o(t,e,o,n){var i,r=arguments.length,h=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(h=(r<3?i(h):r>3?i(e,o,h):i(e,o))||h);return r>3&&h&&Object.defineProperty(e,o,h),h}"function"==typeof SuppressedError&&SuppressedError;class n extends e.BoxData{}t.Flow=class extends e.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},o([e.dataProcessor(n)],t.Flow.prototype,"__",void 0),o([e.autoLayoutType("x")],t.Flow.prototype,"flow",void 0),t.Flow=o([e.registerUI()],t.Flow);const i={},r={"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"},h={"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 s(t,o,n){e.AlignHelper.toPoint(n,o,t.__layout.contentBounds,i);const r=t.__;o.x=r.__autoWidth?0:i.x,o.y=r.__autoHeight?0:i.y}const{move:c}=e.PointHelper;function a(t,e,o,n,i,r){const{children:h}=t;let s,a,{x:l,start:_}=e,u=n;l+=o;for(let t=0,o=e.count;t<o;t++)s=h[r?_-t:_+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==i&&(u=n+(e.height-a.height)/("center"===i?2:1)),c(s,l-a.x,u-a.y),l+=a.width+e.gap):o++}function l(t,e,o){const n="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[n]+=t.count?e[n]+t.gap:e[n],t.list.push(e),t.count++}const _={};function u(t,e){const{gap:o,flowAlign:n,flowWrap:i,__autoWidth:s,__autoHeight:c}=t.__,a=i&&(e?!s:!c);return"object"==typeof o?(_.xGap=o.x||0,_.yGap=o.y||0):_.xGap=_.yGap=o,_.isAutoXGap="string"==typeof _.xGap&&!s,_.isAutoYGap="string"==typeof _.yGap&&!c,_.complex=a||"top-left"!==n||t.__hasGrow||_.isAutoXGap||_.isAutoYGap,_.wrap=a,_.complex&&(_.isFitXGap="fit"===_.xGap&&!s,_.isFitYGap="fit"===_.yGap&&!c,"object"==typeof n?(_.contentAlign=n.content||"top-left",_.rowXAlign=n.x||"from",_.rowYAlign=n.y||"from"):(_.contentAlign=n,_.rowXAlign=r[n],_.rowYAlign=h[n])),_}function g(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function f(t,e,o,n){const{count:i}=t;i>1&&(o>t[e]||n)&&(t.gap=(o-t[e])/(i-1),t[e]=o)}function w(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:p}=e.MathHelper;function d(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:a,start:l}=e;const _=e.width<o?(o-e.width)/a:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)i=u[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(r=i.__widthGrow)&&(h=y(i,i.__flowBounds,_*r),h?(s+=h,a-=r):c&&(i.__.widthRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__widthGrow,i=e/o*n,h=y(t,r=t.__flowBounds,r.width+i),e-=i-h,o-=n}))}(c,s,a)}function y(t,e,o){const{widthRange:n}=t.__,i=n?p(o,n.min,n.max):o;return t.scaleResize(i/e.width,1),e.width=i,o-i}const{within:x}=e.MathHelper;function G(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:a,start:l}=e;const _=e.height<o?(o-e.height)/a:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)i=u[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(r=i.__heightGrow)&&(h=m(i,i.__flowBounds,_*r),h?(s+=h,a-=r):c&&(i.__.heightRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__heightGrow,i=e/o*n,h=m(t,r=t.__flowBounds,r.height+i),e-=i-h,o-=n}))}(c,s,a)}function m(t,e,o){const{heightRange:n}=t.__,i=n?x(o,n.min,n.max):o;return t.scaleResize(1,i/e.height),e.height=i,o-i}const{move:b}=e.PointHelper;const{move:A}=e.PointHelper;function B(t,e,o,n,i,r){const{children:h}=t;let s,c,{y:a,start:l}=e,_=o;a+=n;for(let t=0,n=e.count;t<n;t++)s=h[r?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=o+(e.width-c.width)/("center"===i?2:1)),A(s,_-c.x,a-c.y),a+=c.height+e.gap):n++}const{move:v}=e.PointHelper;const F=e.inviteCode;function R(t){return e.decorateLeafAttr(t,(t=>e.attr({set(o){const n="number"==typeof o?o:0;"autoWidth"===t?this.__widthGrow=n:this.__heightGrow=n,!n||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,o)&&e.doBoundsType(this)}})))}function H(t){return t.length>6&&"e"===t[6]}const{copyAndSpread:X}=e.BoundsHelper;let Y=function(t,e){const o="width",{children:n,itemBox:i}=t,h=u(t,!0),{complex:c,wrap:_,xGap:p,yGap:y,isAutoXGap:x,isFitXGap:G}=h;if(!n.length)return;const A=_&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},B=x?0:p;let v,F,R,H,X,{x:Y,y:P,width:L,height:S}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)v=n[H=e?h-1-r:r],v.__.inFlow&&0!==v.__.visible&&(F=w(v,i),c?(v.__flowBounds=F,X||(X=g(H,B)),_&&X.count&&X.width+F.width>L&&(X.grow?d(t,X,L,e):x&&f(X,o,L,G),l(A,X,o),X=g(H,B)),R=F.width,v.__widthGrow&&(X.grow+=v.__widthGrow,R=0,v.__.widthRange&&(X.hasRangeSize=!0)),v.__heightGrow&&m(v,F,S),X.width+=X.count?R+B:R,X.height=Math.max(X.height,F.height),X.count++):(b(v,Y-F.x,P-F.y),Y+=F.width+B));if(c){const{isAutoYGap:n,isFitYGap:i,contentAlign:c,rowXAlign:u,rowYAlign:g}=h;X.count&&(X.grow?d(t,X,L,e):x&&f(X,o,L,G),_&&l(A,X,o)),_?(n?f(A,"height",S,i):A.gap=y,function(t,e,o,n){s(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=r[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.x=e.width-t.width,"center"===n&&(t.x/=2)}}(t,A,c,u),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let l=0,_=i.length;l<_;l++)h=i[r?_-1-l:l],a(t,h,s,c,o,n),c+=h.height+e.gap}(t,A,g,e)):(s(t,X,c),a(t,X,0,X.y,g,e))}},P=function(t,e){const o="height",{children:n,itemBox:i}=t,r=u(t,!1),{complex:c,wrap:a,xGap:_,yGap:p,isAutoYGap:d,isFitYGap:x}=r;if(!n.length)return;const m=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},b=d?0:p;let A,F,R,H,X,{x:Y,y:P,width:L,height:S}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)A=n[H=e?h-1-r:r],A.__.inFlow&&0!==A.__.visible&&(F=w(A,i),c?(A.__flowBounds=F,X||(X=g(H,b)),a&&X.count&&X.height+F.height>S&&(X.grow&&G(t,X,S,e),d&&f(X,o,S,x),l(m,X,o),X=g(H,b)),R=F.height,A.__heightGrow&&(X.grow+=A.__heightGrow,R=0,A.__.heightRange&&(X.hasRangeSize=!0)),A.__widthGrow&&y(A,F,L),X.height+=X.count?R+b:R,X.width=Math.max(X.width,F.width),X.count++):(v(A,Y-F.x,P-F.y),P+=F.height+b));if(c){const{isAutoXGap:n,isFitXGap:i,contentAlign:c,rowXAlign:u,rowYAlign:g}=r;X.count&&(X.grow&&G(t,X,S,e),d&&f(X,o,S,x),a&&l(m,X,o)),a?(n?f(m,"width",L,i):m.gap=_,function(t,e,o,n){s(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=h[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.y=e.height-t.height,"center"===n&&(t.y/=2)}}(t,m,c,g),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let a=0,l=i.length;a<l;a++)h=i[r?l-1-a:a],B(t,h,s,c,o,n),s+=h.width+e.gap}(t,m,u,e)):(s(t,X,c),B(t,X,X.x,0,u,e))}};return e.UI.changeAttr("autoWidth",void 0,R),e.UI.changeAttr("autoHeight",void 0,R),e.Box.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:Y(this);break;case"y":P(this);break;case"x-reverse":Y(this,!0);break;case"y-reverse":P(this,!0)}this.leafer.created=!0},setTimeout((function(){Object.values(F).some(H)||(Y=()=>{P=Y})})),e.Box.prototype.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),X(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},t}({},LeaferUI);
1
+ this.LeaferIN=this.LeaferIN||{},this.LeaferIN.flow=function(t,e,o){"use strict";function n(t,e,o,n){var i,r=arguments.length,h=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(h=(r<3?i(h):r>3?i(e,o,h):i(e,o))||h);return r>3&&h&&Object.defineProperty(e,o,h),h}"function"==typeof SuppressedError&&SuppressedError;class i extends o.BoxData{}t.Flow=class extends o.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},n([o.dataProcessor(i)],t.Flow.prototype,"__",void 0),n([o.autoLayoutType("x")],t.Flow.prototype,"flow",void 0),t.Flow=n([o.registerUI()],t.Flow);const r={},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"},s={"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(t,e,n){o.AlignHelper.toPoint(n,e,t.__layout.contentBounds,r);const i=t.__;e.x=i.__autoWidth?0:r.x,e.y=i.__autoHeight?0:r.y}const{move:a}=o.PointHelper;function l(t,e,o,n,i,r){const{children:h}=t;let s,c,{x:l,start:_}=e,u=n;l+=o;for(let t=0,o=e.count;t<o;t++)s=h[r?_-t:_+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(u=n+(e.height-c.height)/("center"===i?2:1)),a(s,l-c.x,u-c.y),l+=c.width+e.gap):o++}function _(t,e,o){const n="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[n]+=t.count?e[n]+t.gap:e[n],t.list.push(e),t.count++}const u={};function f(t,e){const{gap:o,flowAlign:n,flowWrap:i,__autoWidth:r,__autoHeight:c}=t.__,a=i&&(e?!r:!c);return"object"==typeof o?(u.xGap=o.x||0,u.yGap=o.y||0):u.xGap=u.yGap=o,u.isAutoXGap="string"==typeof u.xGap&&!r,u.isAutoYGap="string"==typeof u.yGap&&!c,u.complex=a||"top-left"!==n||t.__hasGrow||u.isAutoXGap||u.isAutoYGap,u.wrap=a,u.complex&&(u.isFitXGap="fit"===u.xGap&&!r,u.isFitYGap="fit"===u.yGap&&!c,"object"==typeof n?(u.contentAlign=n.content||"top-left",u.rowXAlign=n.x||"from",u.rowYAlign=n.y||"from"):(u.contentAlign=n,u.rowXAlign=h[n],u.rowYAlign=s[n])),u}function g(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function w(t,e,o,n){const{count:i}=t;i>1&&(o>t[e]||n)&&(t.gap=(o-t[e])/(i-1),t[e]=o)}function p(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:d}=o.MathHelper;function y(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:a,start:l}=e;const _=e.width<o?(o-e.width)/a:0,{children:u}=t;_&&(e.width=o);for(let t=0,o=e.count;t<o;t++)i=u[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(r=i.__widthGrow)&&(h=x(i,i.__flowBounds,_*r),h?(s+=h,a-=r):c&&(i.__.widthRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__widthGrow,i=e/o*n,h=x(t,r=t.__flowBounds,r.width+i),e-=i-h,o-=n}))}(c,s,a)}function x(t,e,o){const{widthRange:n,lockRatio:i}=t.__,r=n?d(o,n.min,n.max):o,h=r/e.width;return t.scaleResize(h,i?h:1),e.width=r,o-r}const{within:G}=o.MathHelper;function m(t,e,o,n){let i,r,h,s=0,c=e.hasRangeSize&&[],{grow:a,start:l}=e;const _=e.height<o?(o-e.height)/a:0,{children:u}=t;_&&(e.height=o);for(let t=0,o=e.count;t<o;t++)i=u[n?l-t:l+t],i.__.inFlow&&0!==i.__.visible?(r=i.__heightGrow)&&(h=b(i,i.__flowBounds,_*r),h?(s+=h,a-=r):c&&(i.__.heightRange?c.unshift(i):c.push(i))):o++;s&&function(t,e,o){let n,i,r,h;t.forEach((t=>{n=t.__heightGrow,i=e/o*n,h=b(t,r=t.__flowBounds,r.height+i),e-=i-h,o-=n}))}(c,s,a)}function b(t,e,o){const{heightRange:n,lockRatio:i}=t.__,r=n?G(o,n.min,n.max):o,h=r/e.height;return t.scaleResize(i?h:1,h),e.height=r,o-r}const{move:A}=o.PointHelper;const{move:B}=o.PointHelper;function v(t,e,o,n,i,r){const{children:h}=t;let s,c,{y:a,start:l}=e,_=o;a+=n;for(let t=0,n=e.count;t<n;t++)s=h[r?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(c=s.__flowBounds,"from"!==i&&(_=o+(e.width-c.width)/("center"===i?2:1)),B(s,_-c.x,a-c.y),a+=c.height+e.gap):n++}const{move:F}=o.PointHelper;const R=o.inviteCode;function H(t){return o.decorateLeafAttr(t,(t=>o.attr({set(e){const n="number"==typeof e?e:0;"autoWidth"===t?this.__widthGrow=n:this.__heightGrow=n,!n||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,e)&&o.doBoundsType(this)}})))}function P(t){return t.length>6&&"e"===t[6]}const{copyAndSpread:X}=o.BoundsHelper;let Y=function(t,e){const o="width",{children:n,itemBox:i}=t,r=f(t,!0),{complex:s,wrap:a,xGap:u,yGap:d,isAutoXGap:x,isFitXGap:G}=r;if(!n.length)return;const m=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},B=x?0:u;let v,F,R,H,P,{x:X,y:Y,width:j,height:k}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)v=n[H=e?h-1-r:r],v.__.inFlow&&0!==v.__.visible&&(F=p(v,i),s?(v.__flowBounds=F,P||(P=g(H,B)),a&&P.count&&P.width+F.width>j&&(P.grow?y(t,P,j,e):x&&w(P,o,j,G),_(m,P,o),P=g(H,B)),R=F.width,v.__widthGrow&&(P.grow+=v.__widthGrow,R=0,v.__.widthRange&&(P.hasRangeSize=!0)),v.__heightGrow&&b(v,F,k),P.width+=P.count?R+B:R,P.height=Math.max(P.height,F.height),P.count++):(A(v,X-F.x,Y-F.y),X+=F.width+B));if(s){const{isAutoYGap:n,isFitYGap:i,contentAlign:s,rowXAlign:u,rowYAlign:f}=r;P.count&&(P.grow?y(t,P,j,e):x&&w(P,o,j,G),a&&_(m,P,o)),a?(n?w(m,"height",k,i):m.gap=d,function(t,e,o,n){c(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=h[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.x=e.width-t.width,"center"===n&&(t.x/=2)}}(t,m,s,u),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let a=0,_=i.length;a<_;a++)h=i[r?_-1-a:a],l(t,h,s,c,o,n),c+=h.height+e.gap}(t,m,f,e)):(c(t,P,s),l(t,P,0,P.y,f,e))}},j=function(t,e){const o="height",{children:n,itemBox:i}=t,r=f(t,!1),{complex:h,wrap:a,xGap:l,yGap:u,isAutoYGap:d,isFitYGap:y}=r;if(!n.length)return;const G=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},b=d?0:u;let A,B,R,H,P,{x:X,y:Y,width:j,height:k}=t.__layout.contentBounds;for(let r=0,s=n.length;r<s;r++)A=n[H=e?s-1-r:r],A.__.inFlow&&0!==A.__.visible&&(B=p(A,i),h?(A.__flowBounds=B,P||(P=g(H,b)),a&&P.count&&P.height+B.height>k&&(P.grow&&m(t,P,k,e),d&&w(P,o,k,y),_(G,P,o),P=g(H,b)),R=B.height,A.__heightGrow&&(P.grow+=A.__heightGrow,R=0,A.__.heightRange&&(P.hasRangeSize=!0)),A.__widthGrow&&x(A,B,j),P.height+=P.count?R+b:R,P.width=Math.max(P.width,B.width),P.count++):(F(A,X-B.x,Y-B.y),Y+=B.height+b));if(h){const{isAutoXGap:n,isFitXGap:i,contentAlign:h,rowXAlign:u,rowYAlign:f}=r;P.count&&(P.grow&&m(t,P,k,e),d&&w(P,o,k,y),a&&_(G,P,o)),a?(n?w(G,"width",j,i):G.gap=l,function(t,e,o,n){c(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=s[o]),"from"!==n)){let t;for(let o=0,r=i.length;o<r;o++)t=i[o],t.y=e.height-t.height,"center"===n&&(t.y/=2)}}(t,G,h,f),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:c}=e;for(let a=0,l=i.length;a<l;a++)h=i[r?l-1-a:a],v(t,h,s,c,o,n),s+=h.width+e.gap}(t,G,u,e)):(c(t,P,h),v(t,P,P.x,0,u,e))}};return o.UI.changeAttr("autoWidth",void 0,H),o.UI.changeAttr("autoHeight",void 0,H),o.Box.prototype.__updateFlowLayout=function(){this.leafer.created=!1;const{flow:t}=this.__;switch(t){case"x":case!0:Y(this);break;case"y":j(this);break;case"x-reverse":Y(this,!0);break;case"y-reverse":j(this,!0)}this.leafer.created=!0},setTimeout((function(){Object.values(R).some(P)||(Y=()=>{j=Y})})),o.Box.prototype.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),X(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},Object.keys(e).forEach((function(o){"default"===o||Object.prototype.hasOwnProperty.call(t,o)||Object.defineProperty(t,o,{enumerable:!0,get:function(){return e[o]}})})),t}({},LeaferIN.resize,LeaferUI);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/flow",
3
- "version": "1.0.0-rc.25",
3
+ "version": "1.0.0-rc.26",
4
4
  "description": "@leafer-in/flow",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -24,8 +24,9 @@
24
24
  "leaferjs"
25
25
  ],
26
26
  "dependencies": {
27
- "@leafer-ui/draw": "1.0.0-rc.25",
28
- "@leafer-ui/interface": "1.0.0-rc.25",
29
- "@leafer-in/interface": "1.0.0-rc.25"
27
+ "@leafer-ui/draw": "1.0.0-rc.26",
28
+ "@leafer-ui/interface": "1.0.0-rc.26",
29
+ "@leafer-in/resize": "1.0.0-rc.26",
30
+ "@leafer-in/interface": "1.0.0-rc.26"
30
31
  }
31
32
  }
package/types/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from '@leafer-in/resize';
1
2
  import { IFlow, IFlowData, IFlowType, IFlowInputData } from '@leafer-ui/interface';
2
3
  import { Box } from '@leafer-ui/draw';
3
4