@leafer-in/flow 1.1.1 → 1.1.2

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,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var resize = require('@leafer-in/resize');
4
3
  var draw = require('@leafer-ui/draw');
4
+ require('@leafer-in/resize');
5
5
 
6
6
  /******************************************************************************
7
7
  Copyright (c) Microsoft Corporation.
@@ -558,10 +558,3 @@ box.__updateBoxBounds = function (secondLayout) {
558
558
  this.__updateRectBoxBounds();
559
559
  }
560
560
  };
561
-
562
- Object.keys(resize).forEach(function (k) {
563
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
564
- enumerable: true,
565
- get: function () { return resize[k]; }
566
- });
567
- });
package/dist/flow.esm.js CHANGED
@@ -1,5 +1,5 @@
1
- export * from '@leafer-in/resize';
2
1
  import { BoxData, dataProcessor, autoLayoutType, registerUI, Box, AlignHelper, PointHelper, MathHelper, decorateLeafAttr, attr, doBoundsType, UI, Group, boundsType, BoundsHelper } from '@leafer-ui/draw';
2
+ import '@leafer-in/resize';
3
3
 
4
4
  /******************************************************************************
5
5
  Copyright (c) Microsoft Corporation.
@@ -1 +1 @@
1
- export*from"@leafer-in/resize";import{BoxData as t,dataProcessor as o,autoLayoutType as e,registerUI as i,Box as n,AlignHelper as h,PointHelper as r,MathHelper as s,decorateLeafAttr as a,attr as c,doBoundsType as l,UI as _,Group as u,boundsType as g,BoundsHelper as f}from"@leafer-ui/draw";function d(t,o,e,i){var n,h=arguments.length,r=h<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,o,e,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(r=(h<3?n(r):h>3?n(o,e,r):n(o,e))||r);return h>3&&r&&Object.defineProperty(o,e,r),r}"function"==typeof SuppressedError&&SuppressedError;let w=class extends n{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}};d([o(class extends t{})],w.prototype,"__",void 0),d([e("x")],w.prototype,"flow",void 0),w=d([i()],w);const p={},x={"top-left":"from",top:"center","top-right":"to",right:"to","bottom-right":"to",bottom:"center","bottom-left":"from",left:"from",center:"center","baseline-left":"from","baseline-center":"center","baseline-right":"to"},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 G(t,o,e){const i=t.__,{contentBounds:n}=t.__layout;h.toPoint(e,o,n,p),o.x=i.__autoWidth?n.x:p.x,o.y=i.__autoHeight?n.y:p.y}const{move:m}=r;function B(t,o,e,i,n,h){const{children:r}=t;let s,a,{x:c,start:l}=o,_=i;c+=e;for(let t=0,e=o.count;t<e;t++)s=r[h?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==n&&(_=i+(o.height-a.height)/("center"===n?2:1)),m(s,c-a.x,_-a.y),c+=a.width+o.gap):e++}function b(t,o,e){const i="width"===e?"height":"width";t[e]=Math.max(t[e],o[e]),t[i]+=t.count?o[i]+t.gap:o[i],t.list.push(o),t.count++}const A={};function R(t,o){const{gap:e,flowAlign:i,flowWrap:n,__autoWidth:h,__autoHeight:r}=t.__,s=n&&(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"!==i||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 i?(A.contentAlign=i.content||"top-left",A.rowXAlign=i.x||"from",A.rowYAlign=i.y||"from"):(A.contentAlign=i,A.rowXAlign=x[i],A.rowYAlign=y[i])),A}function v(t,o){return{x:0,y:0,width:0,height:0,gap:o,start:t,count:0,grow:0}}function F(t,o,e,i){const{count:n}=t;n>1&&(e>t[o]||i)&&(t.gap=(e-t[o])/(n-1),t[o]=e)}function S(t,o){return"box"===o?t.__local:t.__layout.localStrokeBounds}const{within:X}=s;function Y(t,o,e,i){let n,h,r,s=0,a=o.hasRangeSize&&[],{grow:c,start:l}=o;const _=o.width<e?(e-o.width)/c:0,{children:u}=t;_&&(o.width=e);for(let t=0,e=o.count;t<e;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(h=n.__widthGrow)&&(r=z(n,n.__flowBounds,_*h),r?(s+=r,c-=h):a&&(n.__.widthRange?a.unshift(n):a.push(n))):e++;s&&function(t,o,e){let i,n,h,r;t.forEach((t=>{i=t.__widthGrow,n=o/e*i,r=z(t,h=t.__flowBounds,h.width+n),o-=n-r,e-=i}))}(a,s,c)}function z(t,o,e){const{widthRange:i,lockRatio:n}=t.__,h=i?X(e,i):e,r=h/o.width;return t.scaleResize(r,n?r:1),o.width=h,e-h}const{within:W}=s;function k(t,o,e,i){let n,h,r,s=0,a=o.hasRangeSize&&[],{grow:c,start:l}=o;const _=o.height<e?(e-o.height)/c:0,{children:u}=t;_&&(o.height=e);for(let t=0,e=o.count;t<e;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(h=n.__heightGrow)&&(r=C(n,n.__flowBounds,_*h),r?(s+=r,c-=h):a&&(n.__.heightRange?a.unshift(n):a.push(n))):e++;s&&function(t,o,e){let i,n,h,r;t.forEach((t=>{i=t.__heightGrow,n=o/e*i,r=C(t,h=t.__flowBounds,h.height+n),o-=n-r,e-=i}))}(a,s,c)}function C(t,o,e){const{heightRange:i,lockRatio:n}=t.__,h=i?W(e,i):e,r=h/o.height;return t.scaleResize(n?r:1,r),o.height=h,e-h}const{move:j}=r;function E(t,o){const e="width",{children:i,itemBox:n}=t,h=R(t,!0),{complex:r,wrap:s,xGap:a,yGap:c,isAutoXGap:l,isFitXGap:_}=h;if(!i.length)return;const u=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},g=l?0:a;let f,d,w,p,y,{x:m,y:A,width:X,height:z}=t.__layout.contentBounds;for(let h=0,a=i.length;h<a;h++)f=i[p=o?a-1-h:h],f.__.inFlow&&0!==f.__.visible&&(d=S(f,n),r?(f.__flowBounds=d,y||(y=v(p,g)),s&&y.count&&y.width+d.width>X&&(y.grow?Y(t,y,X,o):l&&F(y,e,X,_),b(u,y,e),y=v(p,g)),w=d.width,f.__widthGrow&&(y.grow+=f.__widthGrow,w=0,f.__.widthRange&&(y.hasRangeSize=!0)),f.__heightGrow&&C(f,d,z),y.width+=y.count?w+g:w,y.height=Math.max(y.height,d.height),y.count++):(j(f,m-d.x,A-d.y),m+=d.width+g));if(r&&y){const{isAutoYGap:i,isFitYGap:n,contentAlign:r,rowXAlign:a,rowYAlign:g}=h;y.count&&(y.grow?Y(t,y,X,o):l&&F(y,e,X,_),s&&b(u,y,e)),s?(i?F(u,"height",z,n):u.gap=c,function(t,o,e,i){G(t,o,e);const{list:n}=o;if(n.length>1&&(i||(i=x[e]),"from"!==i)){let t;for(let e=0,h=n.length;e<h;e++)t=n[e],t.x=o.width-t.width,"center"===i&&(t.x/=2)}}(t,u,r,a),function(t,o,e,i){const{list:n}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:a}=o;for(let c=0,l=n.length;c<l;c++)r=n[h?l-1-c:c],B(t,r,s,a,e,i),a+=r.height+o.gap}(t,u,g,o)):(G(t,y,r),B(t,y,0,y.y,g,o))}}const{move:P}=r;function H(t,o,e,i,n,h){const{children:r}=t;let s,a,{y:c,start:l}=o,_=e;c+=i;for(let t=0,i=o.count;t<i;t++)s=r[h?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==n&&(_=e+(o.width-a.width)/("center"===n?2:1)),P(s,_-a.x,c-a.y),c+=a.height+o.gap):i++}const{move:M}=r;function O(t,o){const e="height",{children:i,itemBox:n}=t,h=R(t,!1),{complex:r,wrap:s,xGap:a,yGap:c,isAutoYGap:l,isFitYGap:_}=h;if(!i.length)return;const u=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},g=l?0:c;let f,d,w,p,x,{x:m,y:B,width:A,height:X}=t.__layout.contentBounds;for(let h=0,a=i.length;h<a;h++)f=i[p=o?a-1-h:h],f.__.inFlow&&0!==f.__.visible&&(d=S(f,n),r?(f.__flowBounds=d,x||(x=v(p,g)),s&&x.count&&x.height+d.height>X&&(x.grow&&k(t,x,X,o),l&&F(x,e,X,_),b(u,x,e),x=v(p,g)),w=d.height,f.__heightGrow&&(x.grow+=f.__heightGrow,w=0,f.__.heightRange&&(x.hasRangeSize=!0)),f.__widthGrow&&z(f,d,A),x.height+=x.count?w+g:w,x.width=Math.max(x.width,d.width),x.count++):(M(f,m-d.x,B-d.y),B+=d.height+g));if(r&&x){const{isAutoXGap:i,isFitXGap:n,contentAlign:r,rowXAlign:c,rowYAlign:g}=h;x.count&&(x.grow&&k(t,x,X,o),l&&F(x,e,X,_),s&&b(u,x,e)),s?(i?F(u,"width",A,n):u.gap=a,function(t,o,e,i){G(t,o,e);const{list:n}=o;if(n.length>1&&(i||(i=y[e]),"from"!==i)){let t;for(let e=0,h=n.length;e<h;e++)t=n[e],t.y=o.height-t.height,"center"===i&&(t.y/=2)}}(t,u,r,g),function(t,o,e,i){const{list:n}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:a}=o;for(let c=0,l=n.length;c<l;c++)r=n[h?l-1-c:c],H(t,r,s,a,e,i),s+=r.width+o.gap}(t,u,c,o)):(G(t,x,r),H(t,x,x.x,0,c,o))}}function L(t){return a(t,(t=>c({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)}})))}const D=_.prototype,I=n.prototype,{__updateBoxBounds:N}=u.prototype;e(!1)(D,"flow"),g(0)(D,"gap"),g("top-left")(D,"flowAlign"),g(!1)(D,"flowWrap"),g("box")(D,"itemBox"),g(!0)(D,"inFlow"),L()(D,"autoWidth"),L()(D,"autoHeight"),g()(D,"autoBox");const{copyAndSpread:q}=f;I.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:o}=this;switch(t&&(this.leafer.created=!1),o){case"x":case!0:E(this);break;case"y":O(this);break;case"x-reverse":E(this,!0);break;case"y-reverse":O(this,!0)}t&&(this.leafer.created=!0)},I.__updateContentBounds=function(){const{padding:t}=this.__,o=this.__layout,e=o.contentBounds===o.boxBounds;t?(e&&o.shrinkContent(),q(o.contentBounds,o.boxBounds,t,!0)):e||o.shrinkContentCancel()},I.__updateBoxBounds=function(t){const o=this.__;if(this.children.length){const{flow:e}=o;if(o.__autoSide){e&&!t?this.__updateRectBoxBounds():N.call(this);const{boxBounds:i}=this.__layout;o.__autoSize||(o.__autoWidth?(e||(i.width+=i.x,i.x=0),i.height=o.height,i.y=0):(e||(i.height+=i.y,i.y=0),i.width=o.width,i.x=0)),e&&t&&o.padding&&q(i,i,o.padding,!1,o.__autoSize?null:o.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();e&&this.__updateContentBounds()}else this.__updateRectBoxBounds()};export{w as Flow};
1
+ import{BoxData as t,dataProcessor as o,autoLayoutType as e,registerUI as i,Box as n,AlignHelper as h,PointHelper as r,MathHelper as s,decorateLeafAttr as a,attr as c,doBoundsType as l,UI as _,Group as u,boundsType as g,BoundsHelper as f}from"@leafer-ui/draw";import"@leafer-in/resize";function d(t,o,e,i){var n,h=arguments.length,r=h<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,o,e,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(r=(h<3?n(r):h>3?n(o,e,r):n(o,e))||r);return h>3&&r&&Object.defineProperty(o,e,r),r}"function"==typeof SuppressedError&&SuppressedError;let w=class extends n{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}};d([o(class extends t{})],w.prototype,"__",void 0),d([e("x")],w.prototype,"flow",void 0),w=d([i()],w);const p={},x={"top-left":"from",top:"center","top-right":"to",right:"to","bottom-right":"to",bottom:"center","bottom-left":"from",left:"from",center:"center","baseline-left":"from","baseline-center":"center","baseline-right":"to"},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 G(t,o,e){const i=t.__,{contentBounds:n}=t.__layout;h.toPoint(e,o,n,p),o.x=i.__autoWidth?n.x:p.x,o.y=i.__autoHeight?n.y:p.y}const{move:m}=r;function B(t,o,e,i,n,h){const{children:r}=t;let s,a,{x:c,start:l}=o,_=i;c+=e;for(let t=0,e=o.count;t<e;t++)s=r[h?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==n&&(_=i+(o.height-a.height)/("center"===n?2:1)),m(s,c-a.x,_-a.y),c+=a.width+o.gap):e++}function b(t,o,e){const i="width"===e?"height":"width";t[e]=Math.max(t[e],o[e]),t[i]+=t.count?o[i]+t.gap:o[i],t.list.push(o),t.count++}const A={};function R(t,o){const{gap:e,flowAlign:i,flowWrap:n,__autoWidth:h,__autoHeight:r}=t.__,s=n&&(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"!==i||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 i?(A.contentAlign=i.content||"top-left",A.rowXAlign=i.x||"from",A.rowYAlign=i.y||"from"):(A.contentAlign=i,A.rowXAlign=x[i],A.rowYAlign=y[i])),A}function v(t,o){return{x:0,y:0,width:0,height:0,gap:o,start:t,count:0,grow:0}}function F(t,o,e,i){const{count:n}=t;n>1&&(e>t[o]||i)&&(t.gap=(e-t[o])/(n-1),t[o]=e)}function S(t,o){return"box"===o?t.__local:t.__layout.localStrokeBounds}const{within:X}=s;function Y(t,o,e,i){let n,h,r,s=0,a=o.hasRangeSize&&[],{grow:c,start:l}=o;const _=o.width<e?(e-o.width)/c:0,{children:u}=t;_&&(o.width=e);for(let t=0,e=o.count;t<e;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(h=n.__widthGrow)&&(r=z(n,n.__flowBounds,_*h),r?(s+=r,c-=h):a&&(n.__.widthRange?a.unshift(n):a.push(n))):e++;s&&function(t,o,e){let i,n,h,r;t.forEach((t=>{i=t.__widthGrow,n=o/e*i,r=z(t,h=t.__flowBounds,h.width+n),o-=n-r,e-=i}))}(a,s,c)}function z(t,o,e){const{widthRange:i,lockRatio:n}=t.__,h=i?X(e,i):e,r=h/o.width;return t.scaleResize(r,n?r:1),o.width=h,e-h}const{within:W}=s;function k(t,o,e,i){let n,h,r,s=0,a=o.hasRangeSize&&[],{grow:c,start:l}=o;const _=o.height<e?(e-o.height)/c:0,{children:u}=t;_&&(o.height=e);for(let t=0,e=o.count;t<e;t++)n=u[i?l-t:l+t],n.__.inFlow&&0!==n.__.visible?(h=n.__heightGrow)&&(r=C(n,n.__flowBounds,_*h),r?(s+=r,c-=h):a&&(n.__.heightRange?a.unshift(n):a.push(n))):e++;s&&function(t,o,e){let i,n,h,r;t.forEach((t=>{i=t.__heightGrow,n=o/e*i,r=C(t,h=t.__flowBounds,h.height+n),o-=n-r,e-=i}))}(a,s,c)}function C(t,o,e){const{heightRange:i,lockRatio:n}=t.__,h=i?W(e,i):e,r=h/o.height;return t.scaleResize(n?r:1,r),o.height=h,e-h}const{move:j}=r;function E(t,o){const e="width",{children:i,itemBox:n}=t,h=R(t,!0),{complex:r,wrap:s,xGap:a,yGap:c,isAutoXGap:l,isFitXGap:_}=h;if(!i.length)return;const u=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},g=l?0:a;let f,d,w,p,y,{x:m,y:A,width:X,height:z}=t.__layout.contentBounds;for(let h=0,a=i.length;h<a;h++)f=i[p=o?a-1-h:h],f.__.inFlow&&0!==f.__.visible&&(d=S(f,n),r?(f.__flowBounds=d,y||(y=v(p,g)),s&&y.count&&y.width+d.width>X&&(y.grow?Y(t,y,X,o):l&&F(y,e,X,_),b(u,y,e),y=v(p,g)),w=d.width,f.__widthGrow&&(y.grow+=f.__widthGrow,w=0,f.__.widthRange&&(y.hasRangeSize=!0)),f.__heightGrow&&C(f,d,z),y.width+=y.count?w+g:w,y.height=Math.max(y.height,d.height),y.count++):(j(f,m-d.x,A-d.y),m+=d.width+g));if(r&&y){const{isAutoYGap:i,isFitYGap:n,contentAlign:r,rowXAlign:a,rowYAlign:g}=h;y.count&&(y.grow?Y(t,y,X,o):l&&F(y,e,X,_),s&&b(u,y,e)),s?(i?F(u,"height",z,n):u.gap=c,function(t,o,e,i){G(t,o,e);const{list:n}=o;if(n.length>1&&(i||(i=x[e]),"from"!==i)){let t;for(let e=0,h=n.length;e<h;e++)t=n[e],t.x=o.width-t.width,"center"===i&&(t.x/=2)}}(t,u,r,a),function(t,o,e,i){const{list:n}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:a}=o;for(let c=0,l=n.length;c<l;c++)r=n[h?l-1-c:c],B(t,r,s,a,e,i),a+=r.height+o.gap}(t,u,g,o)):(G(t,y,r),B(t,y,0,y.y,g,o))}}const{move:P}=r;function H(t,o,e,i,n,h){const{children:r}=t;let s,a,{y:c,start:l}=o,_=e;c+=i;for(let t=0,i=o.count;t<i;t++)s=r[h?l-t:l+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==n&&(_=e+(o.width-a.width)/("center"===n?2:1)),P(s,_-a.x,c-a.y),c+=a.height+o.gap):i++}const{move:M}=r;function O(t,o){const e="height",{children:i,itemBox:n}=t,h=R(t,!1),{complex:r,wrap:s,xGap:a,yGap:c,isAutoYGap:l,isFitYGap:_}=h;if(!i.length)return;const u=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},g=l?0:c;let f,d,w,p,x,{x:m,y:B,width:A,height:X}=t.__layout.contentBounds;for(let h=0,a=i.length;h<a;h++)f=i[p=o?a-1-h:h],f.__.inFlow&&0!==f.__.visible&&(d=S(f,n),r?(f.__flowBounds=d,x||(x=v(p,g)),s&&x.count&&x.height+d.height>X&&(x.grow&&k(t,x,X,o),l&&F(x,e,X,_),b(u,x,e),x=v(p,g)),w=d.height,f.__heightGrow&&(x.grow+=f.__heightGrow,w=0,f.__.heightRange&&(x.hasRangeSize=!0)),f.__widthGrow&&z(f,d,A),x.height+=x.count?w+g:w,x.width=Math.max(x.width,d.width),x.count++):(M(f,m-d.x,B-d.y),B+=d.height+g));if(r&&x){const{isAutoXGap:i,isFitXGap:n,contentAlign:r,rowXAlign:c,rowYAlign:g}=h;x.count&&(x.grow&&k(t,x,X,o),l&&F(x,e,X,_),s&&b(u,x,e)),s?(i?F(u,"width",A,n):u.gap=a,function(t,o,e,i){G(t,o,e);const{list:n}=o;if(n.length>1&&(i||(i=y[e]),"from"!==i)){let t;for(let e=0,h=n.length;e<h;e++)t=n[e],t.y=o.height-t.height,"center"===i&&(t.y/=2)}}(t,u,r,g),function(t,o,e,i){const{list:n}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:a}=o;for(let c=0,l=n.length;c<l;c++)r=n[h?l-1-c:c],H(t,r,s,a,e,i),s+=r.width+o.gap}(t,u,c,o)):(G(t,x,r),H(t,x,x.x,0,c,o))}}function L(t){return a(t,(t=>c({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)}})))}const D=_.prototype,I=n.prototype,{__updateBoxBounds:N}=u.prototype;e(!1)(D,"flow"),g(0)(D,"gap"),g("top-left")(D,"flowAlign"),g(!1)(D,"flowWrap"),g("box")(D,"itemBox"),g(!0)(D,"inFlow"),L()(D,"autoWidth"),L()(D,"autoHeight"),g()(D,"autoBox");const{copyAndSpread:q}=f;I.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:o}=this;switch(t&&(this.leafer.created=!1),o){case"x":case!0:E(this);break;case"y":O(this);break;case"x-reverse":E(this,!0);break;case"y-reverse":O(this,!0)}t&&(this.leafer.created=!0)},I.__updateContentBounds=function(){const{padding:t}=this.__,o=this.__layout,e=o.contentBounds===o.boxBounds;t?(e&&o.shrinkContent(),q(o.contentBounds,o.boxBounds,t,!0)):e||o.shrinkContentCancel()},I.__updateBoxBounds=function(t){const o=this.__;if(this.children.length){const{flow:e}=o;if(o.__autoSide){e&&!t?this.__updateRectBoxBounds():N.call(this);const{boxBounds:i}=this.__layout;o.__autoSize||(o.__autoWidth?(e||(i.width+=i.x,i.x=0),i.height=o.height,i.y=0):(e||(i.height+=i.y,i.y=0),i.width=o.width,i.x=0)),e&&t&&o.padding&&q(i,i,o.padding,!1,o.__autoSize?null:o.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();e&&this.__updateContentBounds()}else this.__updateRectBoxBounds()};export{w as Flow};
package/dist/flow.js CHANGED
@@ -1,5 +1,5 @@
1
1
  this.LeaferIN = this.LeaferIN || {};
2
- this.LeaferIN.flow = (function (exports, resize, draw) {
2
+ this.LeaferIN.flow = (function (exports, draw) {
3
3
  'use strict';
4
4
 
5
5
  /******************************************************************************
@@ -558,13 +558,6 @@ this.LeaferIN.flow = (function (exports, resize, draw) {
558
558
  }
559
559
  };
560
560
 
561
- Object.keys(resize).forEach(function (k) {
562
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
563
- enumerable: true,
564
- get: function () { return resize[k]; }
565
- });
566
- });
567
-
568
561
  return exports;
569
562
 
570
- })({}, LeaferIN.resize, LeaferUI);
563
+ })({}, LeaferUI);
package/dist/flow.min.cjs CHANGED
@@ -1 +1 @@
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){const r=t.__,{contentBounds:h}=t.__layout;e.AlignHelper.toPoint(n,o,h,i),o.x=r.__autoWidth?h.x:i.x,o.y=r.__autoHeight?h.y:i.y}const{move:a}=e.PointHelper;function l(t,e,o,n,i,r){const{children:h}=t;let s,l,{x:c,start:u}=e,_=n;c+=o;for(let t=0,o=e.count;t<o;t++)s=h[r?u-t:u+t],s.__.inFlow&&0!==s.__.visible?(l=s.__flowBounds,"from"!==i&&(_=n+(e.height-l.height)/("center"===i?2:1)),a(s,c-l.x,_-l.y),c+=l.width+e.gap):o++}function c(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 _(t,e){const{gap:o,flowAlign:n,flowWrap:i,__autoWidth:s,__autoHeight:a}=t.__,l=i&&(e?!s:!a);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&&!s,u.isAutoYGap="string"==typeof u.yGap&&!a,u.complex=l||"top-left"!==n||t.__hasGrow||u.isAutoXGap||u.isAutoYGap,u.wrap=l,u.complex&&(u.isFitXGap="fit"===u.xGap&&!s,u.isFitYGap="fit"===u.yGap&&!a,"object"==typeof n?(u.contentAlign=n.content||"top-left",u.rowXAlign=n.x||"from",u.rowYAlign=n.y||"from"):(u.contentAlign=n,u.rowXAlign=r[n],u.rowYAlign=h[n])),u}function p(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function d(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 g(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:f}=e.MathHelper;function w(t,e,o,n){let i,r,h,s=0,a=e.hasRangeSize&&[],{grow:l,start:c}=e;const u=e.width<o?(o-e.width)/l:0,{children:_}=t;u&&(e.width=o);for(let t=0,o=e.count;t<o;t++)i=_[n?c-t:c+t],i.__.inFlow&&0!==i.__.visible?(r=i.__widthGrow)&&(h=y(i,i.__flowBounds,u*r),h?(s+=h,l-=r):a&&(i.__.widthRange?a.unshift(i):a.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}))}(a,s,l)}function y(t,e,o){const{widthRange:n,lockRatio:i}=t.__,r=n?f(o,n):o,h=r/e.width;return t.scaleResize(h,i?h:1),e.width=r,o-r}const{within:x}=e.MathHelper;function b(t,e,o,n){let i,r,h,s=0,a=e.hasRangeSize&&[],{grow:l,start:c}=e;const u=e.height<o?(o-e.height)/l:0,{children:_}=t;u&&(e.height=o);for(let t=0,o=e.count;t<o;t++)i=_[n?c-t:c+t],i.__.inFlow&&0!==i.__.visible?(r=i.__heightGrow)&&(h=G(i,i.__flowBounds,u*r),h?(s+=h,l-=r):a&&(i.__.heightRange?a.unshift(i):a.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}))}(a,s,l)}function G(t,e,o){const{heightRange:n,lockRatio:i}=t.__,r=n?x(o,n):o,h=r/e.height;return t.scaleResize(i?h:1,h),e.height=r,o-r}const{move:B}=e.PointHelper;function m(t,e){const o="width",{children:n,itemBox:i}=t,h=_(t,!0),{complex:a,wrap:u,xGap:f,yGap:y,isAutoXGap:x,isFitXGap:b}=h;if(!n.length)return;const m=u&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},A=x?0:f;let F,R,v,S,H,{x:P,y:X,width:Y,height:z}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)F=n[S=e?h-1-r:r],F.__.inFlow&&0!==F.__.visible&&(R=g(F,i),a?(F.__flowBounds=R,H||(H=p(S,A)),u&&H.count&&H.width+R.width>Y&&(H.grow?w(t,H,Y,e):x&&d(H,o,Y,b),c(m,H,o),H=p(S,A)),v=R.width,F.__widthGrow&&(H.grow+=F.__widthGrow,v=0,F.__.widthRange&&(H.hasRangeSize=!0)),F.__heightGrow&&G(F,R,z),H.width+=H.count?v+A:v,H.height=Math.max(H.height,R.height),H.count++):(B(F,P-R.x,X-R.y),P+=R.width+A));if(a&&H){const{isAutoYGap:n,isFitYGap:i,contentAlign:a,rowXAlign:_,rowYAlign:p}=h;H.count&&(H.grow?w(t,H,Y,e):x&&d(H,o,Y,b),u&&c(m,H,o)),u?(n?d(m,"height",z,i):m.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,m,a,_),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:a}=e;for(let c=0,u=i.length;c<u;c++)h=i[r?u-1-c:c],l(t,h,s,a,o,n),a+=h.height+e.gap}(t,m,p,e)):(s(t,H,a),l(t,H,0,H.y,p,e))}}const{move:A}=e.PointHelper;function F(t,e,o,n,i,r){const{children:h}=t;let s,a,{y:l,start:c}=e,u=o;l+=n;for(let t=0,n=e.count;t<n;t++)s=h[r?c-t:c+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==i&&(u=o+(e.width-a.width)/("center"===i?2:1)),A(s,u-a.x,l-a.y),l+=a.height+e.gap):n++}const{move:R}=e.PointHelper;function v(t,e){const o="height",{children:n,itemBox:i}=t,r=_(t,!1),{complex:a,wrap:l,xGap:u,yGap:f,isAutoYGap:w,isFitYGap:x}=r;if(!n.length)return;const G=l&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},B=w?0:f;let m,A,v,S,H,{x:P,y:X,width:Y,height:z}=t.__layout.contentBounds;for(let r=0,h=n.length;r<h;r++)m=n[S=e?h-1-r:r],m.__.inFlow&&0!==m.__.visible&&(A=g(m,i),a?(m.__flowBounds=A,H||(H=p(S,B)),l&&H.count&&H.height+A.height>z&&(H.grow&&b(t,H,z,e),w&&d(H,o,z,x),c(G,H,o),H=p(S,B)),v=A.height,m.__heightGrow&&(H.grow+=m.__heightGrow,v=0,m.__.heightRange&&(H.hasRangeSize=!0)),m.__widthGrow&&y(m,A,Y),H.height+=H.count?v+B:v,H.width=Math.max(H.width,A.width),H.count++):(R(m,P-A.x,X-A.y),X+=A.height+B));if(a&&H){const{isAutoXGap:n,isFitXGap:i,contentAlign:a,rowXAlign:_,rowYAlign:p}=r;H.count&&(H.grow&&b(t,H,z,e),w&&d(H,o,z,x),l&&c(G,H,o)),l?(n?d(G,"width",Y,i):G.gap=u,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,G,a,p),function(t,e,o,n){const{list:i}=e,r="reverse"===t.__.flowWrap;let h,{x:s,y:a}=e;for(let l=0,c=i.length;l<c;l++)h=i[r?c-1-l:l],F(t,h,s,a,o,n),s+=h.width+e.gap}(t,G,_,e)):(s(t,H,a),F(t,H,H.x,0,_,e))}}function S(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)}})))}const H=e.UI.prototype,P=e.Box.prototype,{__updateBoxBounds:X}=e.Group.prototype;e.autoLayoutType(!1)(H,"flow"),e.boundsType(0)(H,"gap"),e.boundsType("top-left")(H,"flowAlign"),e.boundsType(!1)(H,"flowWrap"),e.boundsType("box")(H,"itemBox"),e.boundsType(!0)(H,"inFlow"),S()(H,"autoWidth"),S()(H,"autoHeight"),e.boundsType()(H,"autoBox");const{copyAndSpread:Y}=e.BoundsHelper;P.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:e}=this;switch(t&&(this.leafer.created=!1),e){case"x":case!0:m(this);break;case"y":v(this);break;case"x-reverse":m(this,!0);break;case"y-reverse":v(this,!0)}t&&(this.leafer.created=!0)},P.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),Y(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},P.__updateBoxBounds=function(t){const e=this.__;if(this.children.length){const{flow:o}=e;if(e.__autoSide){o&&!t?this.__updateRectBoxBounds():X.call(this);const{boxBounds:n}=this.__layout;e.__autoSize||(e.__autoWidth?(o||(n.width+=n.x,n.x=0),n.height=e.height,n.y=0):(o||(n.height+=n.y,n.y=0),n.width=e.width,n.x=0)),o&&t&&e.padding&&Y(n,n,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();o&&this.__updateContentBounds()}else this.__updateRectBoxBounds()},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]}})}));
1
+ "use strict";var t=require("@leafer-ui/draw");function o(t,o,e,i){var n,h=arguments.length,r=h<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,o,e,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(r=(h<3?n(r):h>3?n(o,e,r):n(o,e))||r);return h>3&&r&&Object.defineProperty(o,e,r),r}require("@leafer-in/resize"),"function"==typeof SuppressedError&&SuppressedError;class e extends t.BoxData{}exports.Flow=class extends t.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},o([t.dataProcessor(e)],exports.Flow.prototype,"__",void 0),o([t.autoLayoutType("x")],exports.Flow.prototype,"flow",void 0),exports.Flow=o([t.registerUI()],exports.Flow);const i={},n={"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 r(o,e,n){const h=o.__,{contentBounds:r}=o.__layout;t.AlignHelper.toPoint(n,e,r,i),e.x=h.__autoWidth?r.x:i.x,e.y=h.__autoHeight?r.y:i.y}const{move:s}=t.PointHelper;function a(t,o,e,i,n,h){const{children:r}=t;let a,l,{x:c,start:_}=o,u=i;c+=e;for(let t=0,e=o.count;t<e;t++)a=r[h?_-t:_+t],a.__.inFlow&&0!==a.__.visible?(l=a.__flowBounds,"from"!==n&&(u=i+(o.height-l.height)/("center"===n?2:1)),s(a,c-l.x,u-l.y),c+=l.width+o.gap):e++}function l(t,o,e){const i="width"===e?"height":"width";t[e]=Math.max(t[e],o[e]),t[i]+=t.count?o[i]+t.gap:o[i],t.list.push(o),t.count++}const c={};function _(t,o){const{gap:e,flowAlign:i,flowWrap:r,__autoWidth:s,__autoHeight:a}=t.__,l=r&&(o?!s:!a);return"object"==typeof e?(c.xGap=e.x||0,c.yGap=e.y||0):c.xGap=c.yGap=e,c.isAutoXGap="string"==typeof c.xGap&&!s,c.isAutoYGap="string"==typeof c.yGap&&!a,c.complex=l||"top-left"!==i||t.__hasGrow||c.isAutoXGap||c.isAutoYGap,c.wrap=l,c.complex&&(c.isFitXGap="fit"===c.xGap&&!s,c.isFitYGap="fit"===c.yGap&&!a,"object"==typeof i?(c.contentAlign=i.content||"top-left",c.rowXAlign=i.x||"from",c.rowYAlign=i.y||"from"):(c.contentAlign=i,c.rowXAlign=n[i],c.rowYAlign=h[i])),c}function u(t,o){return{x:0,y:0,width:0,height:0,gap:o,start:t,count:0,grow:0}}function p(t,o,e,i){const{count:n}=t;n>1&&(e>t[o]||i)&&(t.gap=(e-t[o])/(n-1),t[o]=e)}function d(t,o){return"box"===o?t.__local:t.__layout.localStrokeBounds}const{within:g}=t.MathHelper;function w(t,o,e,i){let n,h,r,s=0,a=o.hasRangeSize&&[],{grow:l,start:c}=o;const _=o.width<e?(e-o.width)/l:0,{children:u}=t;_&&(o.width=e);for(let t=0,e=o.count;t<e;t++)n=u[i?c-t:c+t],n.__.inFlow&&0!==n.__.visible?(h=n.__widthGrow)&&(r=f(n,n.__flowBounds,_*h),r?(s+=r,l-=h):a&&(n.__.widthRange?a.unshift(n):a.push(n))):e++;s&&function(t,o,e){let i,n,h,r;t.forEach((t=>{i=t.__widthGrow,n=o/e*i,r=f(t,h=t.__flowBounds,h.width+n),o-=n-r,e-=i}))}(a,s,l)}function f(t,o,e){const{widthRange:i,lockRatio:n}=t.__,h=i?g(e,i):e,r=h/o.width;return t.scaleResize(r,n?r:1),o.width=h,e-h}const{within:y}=t.MathHelper;function x(t,o,e,i){let n,h,r,s=0,a=o.hasRangeSize&&[],{grow:l,start:c}=o;const _=o.height<e?(e-o.height)/l:0,{children:u}=t;_&&(o.height=e);for(let t=0,e=o.count;t<e;t++)n=u[i?c-t:c+t],n.__.inFlow&&0!==n.__.visible?(h=n.__heightGrow)&&(r=G(n,n.__flowBounds,_*h),r?(s+=r,l-=h):a&&(n.__.heightRange?a.unshift(n):a.push(n))):e++;s&&function(t,o,e){let i,n,h,r;t.forEach((t=>{i=t.__heightGrow,n=o/e*i,r=G(t,h=t.__flowBounds,h.height+n),o-=n-r,e-=i}))}(a,s,l)}function G(t,o,e){const{heightRange:i,lockRatio:n}=t.__,h=i?y(e,i):e,r=h/o.height;return t.scaleResize(n?r:1,r),o.height=h,e-h}const{move:b}=t.PointHelper;function B(t,o){const e="width",{children:i,itemBox:h}=t,s=_(t,!0),{complex:c,wrap:g,xGap:f,yGap:y,isAutoXGap:x,isFitXGap:B}=s;if(!i.length)return;const m=g&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},A=x?0:f;let F,R,v,S,H,{x:X,y:Y,width:z,height:W}=t.__layout.contentBounds;for(let n=0,r=i.length;n<r;n++)F=i[S=o?r-1-n:n],F.__.inFlow&&0!==F.__.visible&&(R=d(F,h),c?(F.__flowBounds=R,H||(H=u(S,A)),g&&H.count&&H.width+R.width>z&&(H.grow?w(t,H,z,o):x&&p(H,e,z,B),l(m,H,e),H=u(S,A)),v=R.width,F.__widthGrow&&(H.grow+=F.__widthGrow,v=0,F.__.widthRange&&(H.hasRangeSize=!0)),F.__heightGrow&&G(F,R,W),H.width+=H.count?v+A:v,H.height=Math.max(H.height,R.height),H.count++):(b(F,X-R.x,Y-R.y),X+=R.width+A));if(c&&H){const{isAutoYGap:i,isFitYGap:h,contentAlign:c,rowXAlign:_,rowYAlign:u}=s;H.count&&(H.grow?w(t,H,z,o):x&&p(H,e,z,B),g&&l(m,H,e)),g?(i?p(m,"height",W,h):m.gap=y,function(t,o,e,i){r(t,o,e);const{list:h}=o;if(h.length>1&&(i||(i=n[e]),"from"!==i)){let t;for(let e=0,n=h.length;e<n;e++)t=h[e],t.x=o.width-t.width,"center"===i&&(t.x/=2)}}(t,m,c,_),function(t,o,e,i){const{list:n}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:l}=o;for(let c=0,_=n.length;c<_;c++)r=n[h?_-1-c:c],a(t,r,s,l,e,i),l+=r.height+o.gap}(t,m,u,o)):(r(t,H,c),a(t,H,0,H.y,u,o))}}const{move:m}=t.PointHelper;function A(t,o,e,i,n,h){const{children:r}=t;let s,a,{y:l,start:c}=o,_=e;l+=i;for(let t=0,i=o.count;t<i;t++)s=r[h?c-t:c+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==n&&(_=e+(o.width-a.width)/("center"===n?2:1)),m(s,_-a.x,l-a.y),l+=a.height+o.gap):i++}const{move:F}=t.PointHelper;function R(t,o){const e="height",{children:i,itemBox:n}=t,s=_(t,!1),{complex:a,wrap:c,xGap:g,yGap:w,isAutoYGap:y,isFitYGap:G}=s;if(!i.length)return;const b=c&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},B=y?0:w;let m,R,v,S,H,{x:X,y:Y,width:z,height:W}=t.__layout.contentBounds;for(let h=0,r=i.length;h<r;h++)m=i[S=o?r-1-h:h],m.__.inFlow&&0!==m.__.visible&&(R=d(m,n),a?(m.__flowBounds=R,H||(H=u(S,B)),c&&H.count&&H.height+R.height>W&&(H.grow&&x(t,H,W,o),y&&p(H,e,W,G),l(b,H,e),H=u(S,B)),v=R.height,m.__heightGrow&&(H.grow+=m.__heightGrow,v=0,m.__.heightRange&&(H.hasRangeSize=!0)),m.__widthGrow&&f(m,R,z),H.height+=H.count?v+B:v,H.width=Math.max(H.width,R.width),H.count++):(F(m,X-R.x,Y-R.y),Y+=R.height+B));if(a&&H){const{isAutoXGap:i,isFitXGap:n,contentAlign:a,rowXAlign:_,rowYAlign:u}=s;H.count&&(H.grow&&x(t,H,W,o),y&&p(H,e,W,G),c&&l(b,H,e)),c?(i?p(b,"width",z,n):b.gap=g,function(t,o,e,i){r(t,o,e);const{list:n}=o;if(n.length>1&&(i||(i=h[e]),"from"!==i)){let t;for(let e=0,h=n.length;e<h;e++)t=n[e],t.y=o.height-t.height,"center"===i&&(t.y/=2)}}(t,b,a,u),function(t,o,e,i){const{list:n}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:a}=o;for(let l=0,c=n.length;l<c;l++)r=n[h?c-1-l:l],A(t,r,s,a,e,i),s+=r.width+o.gap}(t,b,_,o)):(r(t,H,a),A(t,H,H.x,0,_,o))}}function v(o){return t.decorateLeafAttr(o,(o=>t.attr({set(e){const i="number"==typeof e?e:0;"autoWidth"===o?this.__widthGrow=i:this.__heightGrow=i,!i||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(o,e)&&t.doBoundsType(this)}})))}const S=t.UI.prototype,H=t.Box.prototype,{__updateBoxBounds:X}=t.Group.prototype;t.autoLayoutType(!1)(S,"flow"),t.boundsType(0)(S,"gap"),t.boundsType("top-left")(S,"flowAlign"),t.boundsType(!1)(S,"flowWrap"),t.boundsType("box")(S,"itemBox"),t.boundsType(!0)(S,"inFlow"),v()(S,"autoWidth"),v()(S,"autoHeight"),t.boundsType()(S,"autoBox");const{copyAndSpread:Y}=t.BoundsHelper;H.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:o}=this;switch(t&&(this.leafer.created=!1),o){case"x":case!0:B(this);break;case"y":R(this);break;case"x-reverse":B(this,!0);break;case"y-reverse":R(this,!0)}t&&(this.leafer.created=!0)},H.__updateContentBounds=function(){const{padding:t}=this.__,o=this.__layout,e=o.contentBounds===o.boxBounds;t?(e&&o.shrinkContent(),Y(o.contentBounds,o.boxBounds,t,!0)):e||o.shrinkContentCancel()},H.__updateBoxBounds=function(t){const o=this.__;if(this.children.length){const{flow:e}=o;if(o.__autoSide){e&&!t?this.__updateRectBoxBounds():X.call(this);const{boxBounds:i}=this.__layout;o.__autoSize||(o.__autoWidth?(e||(i.width+=i.x,i.x=0),i.height=o.height,i.y=0):(e||(i.height+=i.y,i.y=0),i.width=o.width,i.x=0)),e&&t&&o.padding&&Y(i,i,o.padding,!1,o.__autoSize?null:o.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();e&&this.__updateContentBounds()}else this.__updateRectBoxBounds()};
package/dist/flow.min.js CHANGED
@@ -1 +1 @@
1
- this.LeaferIN=this.LeaferIN||{},this.LeaferIN.flow=function(t,e,o){"use strict";function n(t,e,o,n){var i,h=arguments.length,r=h<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,o,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(r=(h<3?i(r):h>3?i(e,o,r):i(e,o))||r);return h>3&&r&&Object.defineProperty(e,o,r),r}"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 h={},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"},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 a(t,e,n){const i=t.__,{contentBounds:r}=t.__layout;o.AlignHelper.toPoint(n,e,r,h),e.x=i.__autoWidth?r.x:h.x,e.y=i.__autoHeight?r.y:h.y}const{move:l}=o.PointHelper;function c(t,e,o,n,i,h){const{children:r}=t;let s,a,{x:c,start:u}=e,_=n;c+=o;for(let t=0,o=e.count;t<o;t++)s=r[h?u-t:u+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==i&&(_=n+(e.height-a.height)/("center"===i?2:1)),l(s,c-a.x,_-a.y),c+=a.width+e.gap):o++}function u(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 p(t,e){const{gap:o,flowAlign:n,flowWrap:i,__autoWidth:h,__autoHeight:a}=t.__,l=i&&(e?!h:!a);return"object"==typeof o?(_.xGap=o.x||0,_.yGap=o.y||0):_.xGap=_.yGap=o,_.isAutoXGap="string"==typeof _.xGap&&!h,_.isAutoYGap="string"==typeof _.yGap&&!a,_.complex=l||"top-left"!==n||t.__hasGrow||_.isAutoXGap||_.isAutoYGap,_.wrap=l,_.complex&&(_.isFitXGap="fit"===_.xGap&&!h,_.isFitYGap="fit"===_.yGap&&!a,"object"==typeof n?(_.contentAlign=n.content||"top-left",_.rowXAlign=n.x||"from",_.rowYAlign=n.y||"from"):(_.contentAlign=n,_.rowXAlign=r[n],_.rowYAlign=s[n])),_}function f(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function d(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 g(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:w}=o.MathHelper;function y(t,e,o,n){let i,h,r,s=0,a=e.hasRangeSize&&[],{grow:l,start:c}=e;const u=e.width<o?(o-e.width)/l:0,{children:_}=t;u&&(e.width=o);for(let t=0,o=e.count;t<o;t++)i=_[n?c-t:c+t],i.__.inFlow&&0!==i.__.visible?(h=i.__widthGrow)&&(r=x(i,i.__flowBounds,u*h),r?(s+=r,l-=h):a&&(i.__.widthRange?a.unshift(i):a.push(i))):o++;s&&function(t,e,o){let n,i,h,r;t.forEach((t=>{n=t.__widthGrow,i=e/o*n,r=x(t,h=t.__flowBounds,h.width+i),e-=i-r,o-=n}))}(a,s,l)}function x(t,e,o){const{widthRange:n,lockRatio:i}=t.__,h=n?w(o,n):o,r=h/e.width;return t.scaleResize(r,i?r:1),e.width=h,o-h}const{within:b}=o.MathHelper;function G(t,e,o,n){let i,h,r,s=0,a=e.hasRangeSize&&[],{grow:l,start:c}=e;const u=e.height<o?(o-e.height)/l:0,{children:_}=t;u&&(e.height=o);for(let t=0,o=e.count;t<o;t++)i=_[n?c-t:c+t],i.__.inFlow&&0!==i.__.visible?(h=i.__heightGrow)&&(r=B(i,i.__flowBounds,u*h),r?(s+=r,l-=h):a&&(i.__.heightRange?a.unshift(i):a.push(i))):o++;s&&function(t,e,o){let n,i,h,r;t.forEach((t=>{n=t.__heightGrow,i=e/o*n,r=B(t,h=t.__flowBounds,h.height+i),e-=i-r,o-=n}))}(a,s,l)}function B(t,e,o){const{heightRange:n,lockRatio:i}=t.__,h=n?b(o,n):o,r=h/e.height;return t.scaleResize(i?r:1,r),e.height=h,o-h}const{move:m}=o.PointHelper;function A(t,e){const o="width",{children:n,itemBox:i}=t,h=p(t,!0),{complex:s,wrap:l,xGap:_,yGap:w,isAutoXGap:x,isFitXGap:b}=h;if(!n.length)return;const G=l&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},A=x?0:_;let F,R,v,S,H,{x:P,y:X,width:Y,height:z}=t.__layout.contentBounds;for(let h=0,r=n.length;h<r;h++)F=n[S=e?r-1-h:h],F.__.inFlow&&0!==F.__.visible&&(R=g(F,i),s?(F.__flowBounds=R,H||(H=f(S,A)),l&&H.count&&H.width+R.width>Y&&(H.grow?y(t,H,Y,e):x&&d(H,o,Y,b),u(G,H,o),H=f(S,A)),v=R.width,F.__widthGrow&&(H.grow+=F.__widthGrow,v=0,F.__.widthRange&&(H.hasRangeSize=!0)),F.__heightGrow&&B(F,R,z),H.width+=H.count?v+A:v,H.height=Math.max(H.height,R.height),H.count++):(m(F,P-R.x,X-R.y),P+=R.width+A));if(s&&H){const{isAutoYGap:n,isFitYGap:i,contentAlign:s,rowXAlign:_,rowYAlign:p}=h;H.count&&(H.grow?y(t,H,Y,e):x&&d(H,o,Y,b),l&&u(G,H,o)),l?(n?d(G,"height",z,i):G.gap=w,function(t,e,o,n){a(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=r[o]),"from"!==n)){let t;for(let o=0,h=i.length;o<h;o++)t=i[o],t.x=e.width-t.width,"center"===n&&(t.x/=2)}}(t,G,s,_),function(t,e,o,n){const{list:i}=e,h="reverse"===t.__.flowWrap;let r,{x:s,y:a}=e;for(let l=0,u=i.length;l<u;l++)r=i[h?u-1-l:l],c(t,r,s,a,o,n),a+=r.height+e.gap}(t,G,p,e)):(a(t,H,s),c(t,H,0,H.y,p,e))}}const{move:F}=o.PointHelper;function R(t,e,o,n,i,h){const{children:r}=t;let s,a,{y:l,start:c}=e,u=o;l+=n;for(let t=0,n=e.count;t<n;t++)s=r[h?c-t:c+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==i&&(u=o+(e.width-a.width)/("center"===i?2:1)),F(s,u-a.x,l-a.y),l+=a.height+e.gap):n++}const{move:v}=o.PointHelper;function S(t,e){const o="height",{children:n,itemBox:i}=t,h=p(t,!1),{complex:r,wrap:l,xGap:c,yGap:_,isAutoYGap:w,isFitYGap:y}=h;if(!n.length)return;const b=l&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},B=w?0:_;let m,A,F,S,H,{x:P,y:X,width:Y,height:z}=t.__layout.contentBounds;for(let h=0,s=n.length;h<s;h++)m=n[S=e?s-1-h:h],m.__.inFlow&&0!==m.__.visible&&(A=g(m,i),r?(m.__flowBounds=A,H||(H=f(S,B)),l&&H.count&&H.height+A.height>z&&(H.grow&&G(t,H,z,e),w&&d(H,o,z,y),u(b,H,o),H=f(S,B)),F=A.height,m.__heightGrow&&(H.grow+=m.__heightGrow,F=0,m.__.heightRange&&(H.hasRangeSize=!0)),m.__widthGrow&&x(m,A,Y),H.height+=H.count?F+B:F,H.width=Math.max(H.width,A.width),H.count++):(v(m,P-A.x,X-A.y),X+=A.height+B));if(r&&H){const{isAutoXGap:n,isFitXGap:i,contentAlign:r,rowXAlign:_,rowYAlign:p}=h;H.count&&(H.grow&&G(t,H,z,e),w&&d(H,o,z,y),l&&u(b,H,o)),l?(n?d(b,"width",Y,i):b.gap=c,function(t,e,o,n){a(t,e,o);const{list:i}=e;if(i.length>1&&(n||(n=s[o]),"from"!==n)){let t;for(let o=0,h=i.length;o<h;o++)t=i[o],t.y=e.height-t.height,"center"===n&&(t.y/=2)}}(t,b,r,p),function(t,e,o,n){const{list:i}=e,h="reverse"===t.__.flowWrap;let r,{x:s,y:a}=e;for(let l=0,c=i.length;l<c;l++)r=i[h?c-1-l:l],R(t,r,s,a,o,n),s+=r.width+e.gap}(t,b,_,e)):(a(t,H,r),R(t,H,H.x,0,_,e))}}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)}})))}const P=o.UI.prototype,X=o.Box.prototype,{__updateBoxBounds:Y}=o.Group.prototype;o.autoLayoutType(!1)(P,"flow"),o.boundsType(0)(P,"gap"),o.boundsType("top-left")(P,"flowAlign"),o.boundsType(!1)(P,"flowWrap"),o.boundsType("box")(P,"itemBox"),o.boundsType(!0)(P,"inFlow"),H()(P,"autoWidth"),H()(P,"autoHeight"),o.boundsType()(P,"autoBox");const{copyAndSpread:z}=o.BoundsHelper;return X.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:e}=this;switch(t&&(this.leafer.created=!1),e){case"x":case!0:A(this);break;case"y":S(this);break;case"x-reverse":A(this,!0);break;case"y-reverse":S(this,!0)}t&&(this.leafer.created=!0)},X.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),z(e.contentBounds,e.boxBounds,t,!0)):o||e.shrinkContentCancel()},X.__updateBoxBounds=function(t){const e=this.__;if(this.children.length){const{flow:o}=e;if(e.__autoSide){o&&!t?this.__updateRectBoxBounds():Y.call(this);const{boxBounds:n}=this.__layout;e.__autoSize||(e.__autoWidth?(o||(n.width+=n.x,n.x=0),n.height=e.height,n.y=0):(o||(n.height+=n.y,n.y=0),n.width=e.width,n.x=0)),o&&t&&e.padding&&z(n,n,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();o&&this.__updateContentBounds()}else this.__updateRectBoxBounds()},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);
1
+ this.LeaferIN=this.LeaferIN||{},this.LeaferIN.flow=function(t,o){"use strict";function e(t,o,e,i){var n,h=arguments.length,r=h<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,o,e,i);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(r=(h<3?n(r):h>3?n(o,e,r):n(o,e))||r);return h>3&&r&&Object.defineProperty(o,e,r),r}"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}},e([o.dataProcessor(i)],t.Flow.prototype,"__",void 0),e([o.autoLayoutType("x")],t.Flow.prototype,"flow",void 0),t.Flow=e([o.registerUI()],t.Flow);const n={},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"},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 s(t,e,i){const h=t.__,{contentBounds:r}=t.__layout;o.AlignHelper.toPoint(i,e,r,n),e.x=h.__autoWidth?r.x:n.x,e.y=h.__autoHeight?r.y:n.y}const{move:a}=o.PointHelper;function l(t,o,e,i,n,h){const{children:r}=t;let s,l,{x:c,start:_}=o,u=i;c+=e;for(let t=0,e=o.count;t<e;t++)s=r[h?_-t:_+t],s.__.inFlow&&0!==s.__.visible?(l=s.__flowBounds,"from"!==n&&(u=i+(o.height-l.height)/("center"===n?2:1)),a(s,c-l.x,u-l.y),c+=l.width+o.gap):e++}function c(t,o,e){const i="width"===e?"height":"width";t[e]=Math.max(t[e],o[e]),t[i]+=t.count?o[i]+t.gap:o[i],t.list.push(o),t.count++}const _={};function u(t,o){const{gap:e,flowAlign:i,flowWrap:n,__autoWidth:s,__autoHeight:a}=t.__,l=n&&(o?!s:!a);return"object"==typeof e?(_.xGap=e.x||0,_.yGap=e.y||0):_.xGap=_.yGap=e,_.isAutoXGap="string"==typeof _.xGap&&!s,_.isAutoYGap="string"==typeof _.yGap&&!a,_.complex=l||"top-left"!==i||t.__hasGrow||_.isAutoXGap||_.isAutoYGap,_.wrap=l,_.complex&&(_.isFitXGap="fit"===_.xGap&&!s,_.isFitYGap="fit"===_.yGap&&!a,"object"==typeof i?(_.contentAlign=i.content||"top-left",_.rowXAlign=i.x||"from",_.rowYAlign=i.y||"from"):(_.contentAlign=i,_.rowXAlign=h[i],_.rowYAlign=r[i])),_}function p(t,o){return{x:0,y:0,width:0,height:0,gap:o,start:t,count:0,grow:0}}function g(t,o,e,i){const{count:n}=t;n>1&&(e>t[o]||i)&&(t.gap=(e-t[o])/(n-1),t[o]=e)}function d(t,o){return"box"===o?t.__local:t.__layout.localStrokeBounds}const{within:f}=o.MathHelper;function w(t,o,e,i){let n,h,r,s=0,a=o.hasRangeSize&&[],{grow:l,start:c}=o;const _=o.width<e?(e-o.width)/l:0,{children:u}=t;_&&(o.width=e);for(let t=0,e=o.count;t<e;t++)n=u[i?c-t:c+t],n.__.inFlow&&0!==n.__.visible?(h=n.__widthGrow)&&(r=y(n,n.__flowBounds,_*h),r?(s+=r,l-=h):a&&(n.__.widthRange?a.unshift(n):a.push(n))):e++;s&&function(t,o,e){let i,n,h,r;t.forEach((t=>{i=t.__widthGrow,n=o/e*i,r=y(t,h=t.__flowBounds,h.width+n),o-=n-r,e-=i}))}(a,s,l)}function y(t,o,e){const{widthRange:i,lockRatio:n}=t.__,h=i?f(e,i):e,r=h/o.width;return t.scaleResize(r,n?r:1),o.width=h,e-h}const{within:x}=o.MathHelper;function G(t,o,e,i){let n,h,r,s=0,a=o.hasRangeSize&&[],{grow:l,start:c}=o;const _=o.height<e?(e-o.height)/l:0,{children:u}=t;_&&(o.height=e);for(let t=0,e=o.count;t<e;t++)n=u[i?c-t:c+t],n.__.inFlow&&0!==n.__.visible?(h=n.__heightGrow)&&(r=b(n,n.__flowBounds,_*h),r?(s+=r,l-=h):a&&(n.__.heightRange?a.unshift(n):a.push(n))):e++;s&&function(t,o,e){let i,n,h,r;t.forEach((t=>{i=t.__heightGrow,n=o/e*i,r=b(t,h=t.__flowBounds,h.height+n),o-=n-r,e-=i}))}(a,s,l)}function b(t,o,e){const{heightRange:i,lockRatio:n}=t.__,h=i?x(e,i):e,r=h/o.height;return t.scaleResize(n?r:1,r),o.height=h,e-h}const{move:B}=o.PointHelper;function m(t,o){const e="width",{children:i,itemBox:n}=t,r=u(t,!0),{complex:a,wrap:_,xGap:f,yGap:y,isAutoXGap:x,isFitXGap:G}=r;if(!i.length)return;const m=_&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},A=x?0:f;let F,R,v,S,H,{x:X,y:Y,width:W,height:z}=t.__layout.contentBounds;for(let h=0,r=i.length;h<r;h++)F=i[S=o?r-1-h:h],F.__.inFlow&&0!==F.__.visible&&(R=d(F,n),a?(F.__flowBounds=R,H||(H=p(S,A)),_&&H.count&&H.width+R.width>W&&(H.grow?w(t,H,W,o):x&&g(H,e,W,G),c(m,H,e),H=p(S,A)),v=R.width,F.__widthGrow&&(H.grow+=F.__widthGrow,v=0,F.__.widthRange&&(H.hasRangeSize=!0)),F.__heightGrow&&b(F,R,z),H.width+=H.count?v+A:v,H.height=Math.max(H.height,R.height),H.count++):(B(F,X-R.x,Y-R.y),X+=R.width+A));if(a&&H){const{isAutoYGap:i,isFitYGap:n,contentAlign:a,rowXAlign:u,rowYAlign:p}=r;H.count&&(H.grow?w(t,H,W,o):x&&g(H,e,W,G),_&&c(m,H,e)),_?(i?g(m,"height",z,n):m.gap=y,function(t,o,e,i){s(t,o,e);const{list:n}=o;if(n.length>1&&(i||(i=h[e]),"from"!==i)){let t;for(let e=0,h=n.length;e<h;e++)t=n[e],t.x=o.width-t.width,"center"===i&&(t.x/=2)}}(t,m,a,u),function(t,o,e,i){const{list:n}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:a}=o;for(let c=0,_=n.length;c<_;c++)r=n[h?_-1-c:c],l(t,r,s,a,e,i),a+=r.height+o.gap}(t,m,p,o)):(s(t,H,a),l(t,H,0,H.y,p,o))}}const{move:A}=o.PointHelper;function F(t,o,e,i,n,h){const{children:r}=t;let s,a,{y:l,start:c}=o,_=e;l+=i;for(let t=0,i=o.count;t<i;t++)s=r[h?c-t:c+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==n&&(_=e+(o.width-a.width)/("center"===n?2:1)),A(s,_-a.x,l-a.y),l+=a.height+o.gap):i++}const{move:R}=o.PointHelper;function v(t,o){const e="height",{children:i,itemBox:n}=t,h=u(t,!1),{complex:a,wrap:l,xGap:_,yGap:f,isAutoYGap:w,isFitYGap:x}=h;if(!i.length)return;const b=l&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},B=w?0:f;let m,A,v,S,H,{x:X,y:Y,width:W,height:z}=t.__layout.contentBounds;for(let h=0,r=i.length;h<r;h++)m=i[S=o?r-1-h:h],m.__.inFlow&&0!==m.__.visible&&(A=d(m,n),a?(m.__flowBounds=A,H||(H=p(S,B)),l&&H.count&&H.height+A.height>z&&(H.grow&&G(t,H,z,o),w&&g(H,e,z,x),c(b,H,e),H=p(S,B)),v=A.height,m.__heightGrow&&(H.grow+=m.__heightGrow,v=0,m.__.heightRange&&(H.hasRangeSize=!0)),m.__widthGrow&&y(m,A,W),H.height+=H.count?v+B:v,H.width=Math.max(H.width,A.width),H.count++):(R(m,X-A.x,Y-A.y),Y+=A.height+B));if(a&&H){const{isAutoXGap:i,isFitXGap:n,contentAlign:a,rowXAlign:u,rowYAlign:p}=h;H.count&&(H.grow&&G(t,H,z,o),w&&g(H,e,z,x),l&&c(b,H,e)),l?(i?g(b,"width",W,n):b.gap=_,function(t,o,e,i){s(t,o,e);const{list:n}=o;if(n.length>1&&(i||(i=r[e]),"from"!==i)){let t;for(let e=0,h=n.length;e<h;e++)t=n[e],t.y=o.height-t.height,"center"===i&&(t.y/=2)}}(t,b,a,p),function(t,o,e,i){const{list:n}=o,h="reverse"===t.__.flowWrap;let r,{x:s,y:a}=o;for(let l=0,c=n.length;l<c;l++)r=n[h?c-1-l:l],F(t,r,s,a,e,i),s+=r.width+o.gap}(t,b,u,o)):(s(t,H,a),F(t,H,H.x,0,u,o))}}function S(t){return o.decorateLeafAttr(t,(t=>o.attr({set(e){const i="number"==typeof e?e:0;"autoWidth"===t?this.__widthGrow=i:this.__heightGrow=i,!i||this.parent&&this.parent.__hasGrow||this.waitParent((()=>{this.parent.__hasGrow=!0})),this.__setAttr(t,e)&&o.doBoundsType(this)}})))}const H=o.UI.prototype,X=o.Box.prototype,{__updateBoxBounds:Y}=o.Group.prototype;o.autoLayoutType(!1)(H,"flow"),o.boundsType(0)(H,"gap"),o.boundsType("top-left")(H,"flowAlign"),o.boundsType(!1)(H,"flowWrap"),o.boundsType("box")(H,"itemBox"),o.boundsType(!0)(H,"inFlow"),S()(H,"autoWidth"),S()(H,"autoHeight"),o.boundsType()(H,"autoBox");const{copyAndSpread:W}=o.BoundsHelper;return X.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:o}=this;switch(t&&(this.leafer.created=!1),o){case"x":case!0:m(this);break;case"y":v(this);break;case"x-reverse":m(this,!0);break;case"y-reverse":v(this,!0)}t&&(this.leafer.created=!0)},X.__updateContentBounds=function(){const{padding:t}=this.__,o=this.__layout,e=o.contentBounds===o.boxBounds;t?(e&&o.shrinkContent(),W(o.contentBounds,o.boxBounds,t,!0)):e||o.shrinkContentCancel()},X.__updateBoxBounds=function(t){const o=this.__;if(this.children.length){const{flow:e}=o;if(o.__autoSide){e&&!t?this.__updateRectBoxBounds():Y.call(this);const{boxBounds:i}=this.__layout;o.__autoSize||(o.__autoWidth?(e||(i.width+=i.x,i.x=0),i.height=o.height,i.y=0):(e||(i.height+=i.y,i.y=0),i.width=o.width,i.x=0)),e&&t&&o.padding&&W(i,i,o.padding,!1,o.__autoSize?null:o.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();e&&this.__updateContentBounds()}else this.__updateRectBoxBounds()},t}({},LeaferUI);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/flow",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "@leafer-in/flow",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -34,9 +34,9 @@
34
34
  "leaferjs"
35
35
  ],
36
36
  "peerDependencies": {
37
- "@leafer-ui/draw": "^1.1.1",
38
- "@leafer-in/resize": "^1.1.1",
39
- "@leafer-ui/interface": "^1.1.1",
40
- "@leafer-in/interface": "^1.1.1"
37
+ "@leafer-ui/draw": "^1.1.2",
38
+ "@leafer-in/resize": "^1.1.2",
39
+ "@leafer-ui/interface": "^1.1.2",
40
+ "@leafer-in/interface": "^1.1.2"
41
41
  }
42
42
  }
package/src/index.ts CHANGED
@@ -1,9 +1,10 @@
1
- export * from '@leafer-in/resize'
2
-
3
1
  export { Flow } from './Flow'
4
2
 
3
+
5
4
  import { BoundsHelper, Box, Group, UI, autoLayoutType, boundsType } from '@leafer-ui/draw'
6
5
 
6
+ import '@leafer-in/resize'
7
+
7
8
  import { flowX } from './layout/flowX'
8
9
  import { flowY } from './layout/flowY'
9
10
  import { autoBoundsType } from './decorate'