@leafer-in/flow 1.3.1 → 1.3.3
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 +5 -3
- package/dist/flow.esm.js +5 -3
- package/dist/flow.esm.min.js +1 -1
- package/dist/flow.js +5 -3
- package/dist/flow.min.cjs +1 -1
- package/dist/flow.min.js +1 -1
- package/package.json +5 -5
- package/src/index.ts +1 -1
package/dist/flow.cjs
CHANGED
|
@@ -17,7 +17,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
17
17
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
18
|
PERFORMANCE OF THIS SOFTWARE.
|
|
19
19
|
***************************************************************************** */
|
|
20
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
20
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
function __decorate(decorators, target, key, desc) {
|
|
@@ -44,10 +44,10 @@ exports.Flow = class Flow extends draw.Box {
|
|
|
44
44
|
};
|
|
45
45
|
__decorate([
|
|
46
46
|
draw.dataProcessor(FlowData)
|
|
47
|
-
], exports.Flow.prototype, "__",
|
|
47
|
+
], exports.Flow.prototype, "__", undefined);
|
|
48
48
|
__decorate([
|
|
49
49
|
draw.autoLayoutType('x')
|
|
50
|
-
], exports.Flow.prototype, "flow",
|
|
50
|
+
], exports.Flow.prototype, "flow", undefined);
|
|
51
51
|
exports.Flow = __decorate([
|
|
52
52
|
draw.registerUI()
|
|
53
53
|
], exports.Flow);
|
|
@@ -532,6 +532,8 @@ box.__updateBoxBounds = function (secondLayout) {
|
|
|
532
532
|
if (this.children.length) {
|
|
533
533
|
const { flow } = data;
|
|
534
534
|
if (data.__autoSide) {
|
|
535
|
+
if (data.__hasSurface)
|
|
536
|
+
this.__extraUpdate();
|
|
535
537
|
flow && !secondLayout ? this.__updateRectBoxBounds() : __updateBoxBounds.call(this);
|
|
536
538
|
const { boxBounds } = this.__layout;
|
|
537
539
|
if (!data.__autoSize) {
|
package/dist/flow.esm.js
CHANGED
|
@@ -15,7 +15,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
15
15
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
16
16
|
PERFORMANCE OF THIS SOFTWARE.
|
|
17
17
|
***************************************************************************** */
|
|
18
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
18
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
function __decorate(decorators, target, key, desc) {
|
|
@@ -42,10 +42,10 @@ let Flow = class Flow extends Box {
|
|
|
42
42
|
};
|
|
43
43
|
__decorate([
|
|
44
44
|
dataProcessor(FlowData)
|
|
45
|
-
], Flow.prototype, "__",
|
|
45
|
+
], Flow.prototype, "__", undefined);
|
|
46
46
|
__decorate([
|
|
47
47
|
autoLayoutType('x')
|
|
48
|
-
], Flow.prototype, "flow",
|
|
48
|
+
], Flow.prototype, "flow", undefined);
|
|
49
49
|
Flow = __decorate([
|
|
50
50
|
registerUI()
|
|
51
51
|
], Flow);
|
|
@@ -530,6 +530,8 @@ box.__updateBoxBounds = function (secondLayout) {
|
|
|
530
530
|
if (this.children.length) {
|
|
531
531
|
const { flow } = data;
|
|
532
532
|
if (data.__autoSide) {
|
|
533
|
+
if (data.__hasSurface)
|
|
534
|
+
this.__extraUpdate();
|
|
533
535
|
flow && !secondLayout ? this.__updateRectBoxBounds() : __updateBoxBounds.call(this);
|
|
534
536
|
const { boxBounds } = this.__layout;
|
|
535
537
|
if (!data.__autoSize) {
|
package/dist/flow.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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 _,doBoundsType as c,Plugin as l,UI as u,Group as g,boundsType as f,BoundsHelper as d}from"@leafer-ui/draw";import"@leafer-in/resize";function w(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 p=class extends n{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}};w([o(class extends t{})],p.prototype,"__",void 0),w([e("x")],p.prototype,"flow",void 0),p=w([i()],p);const x={},y={"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"},G={"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 m(t,o,e){const i=t.__,{contentBounds:n}=t.__layout;h.toPoint(e,o,n,x),o.x=i.__autoWidth?n.x:x.x,o.y=i.__autoHeight?n.y:x.y}const{move:B}=r;function b(t,o,e,i,n,h){const{children:r}=t;let s,a,{x:_,start:c}=o,l=i;_+=e;for(let t=0,e=o.count;t<e;t++)s=r[h?c-t:c+t],s.__.inFlow&&0!==s.__.visible?(a=s.__flowBounds,"from"!==n&&(l=i+(o.height-a.height)/("center"===n?2:1)),B(s,_-a.x,l-a.y),_+=a.width+o.gap):e++}function A(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 R={};function v(t,o){const{gap:e,flowAlign:i,flowWrap:n,__autoWidth:h,__autoHeight:r}=t.__,s=n&&(o?!h:!r);return"object"==typeof e?(R.xGap=e.x||0,R.yGap=e.y||0):R.xGap=R.yGap=e,R.isAutoXGap="string"==typeof R.xGap&&!h,R.isAutoYGap="string"==typeof R.yGap&&!r,R.complex=s||"top-left"!==i||t.__hasGrow||R.isAutoXGap||R.isAutoYGap,R.wrap=s,R.complex&&(R.isFitXGap="fit"===R.xGap&&!h,R.isFitYGap="fit"===R.yGap&&!r,"object"==typeof i?(R.contentAlign=i.content||"top-left",R.rowXAlign=i.x||"from",R.rowYAlign=i.y||"from"):(R.contentAlign=i,R.rowXAlign=y[i],R.rowYAlign=G[i])),R}function F(t,o){return{x:0,y:0,width:0,height:0,gap:o,start:t,count:0,grow:0}}function S(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 z(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:_,start:c}=o;const l=o.width<e?(e-o.width)/_:0,{children:u}=t;l&&(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=W(n,n.__flowBounds,l*h),r?(s+=r,_-=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=W(t,h=t.__flowBounds,h.width+n),o-=n-r,e-=i}))}(a,s,_)}function W(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:k}=s;function C(t,o,e,i){let n,h,r,s=0,a=o.hasRangeSize&&[],{grow:_,start:c}=o;const l=o.height<e?(e-o.height)/_:0,{children:u}=t;l&&(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=j(n,n.__flowBounds,l*h),r?(s+=r,_-=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=j(t,h=t.__flowBounds,h.height+n),o-=n-r,e-=i}))}(a,s,_)}function j(t,o,e){const{heightRange:i,lockRatio:n}=t.__,h=i?k(e,i):e,r=h/o.height;return t.scaleResize(n?r:1,r),o.height=h,e-h}const{move:E}=r;function P(t,o){const e="width",{children:i,itemBox:n}=t,h=v(t,!0),{complex:r,wrap:s,xGap:a,yGap:_,isAutoXGap:c,isFitXGap:l}=h;if(!i.length)return;const u=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},g=c?0:a;let f,d,w,p,x,{x:G,y:B,width:R,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=z(f,n),r?(f.__flowBounds=d,x||(x=F(p,g)),s&&x.count&&x.width+d.width>R&&(x.grow?Y(t,x,R,o):c&&S(x,e,R,l),A(u,x,e),x=F(p,g)),w=d.width,f.__widthGrow&&(x.grow+=f.__widthGrow,w=0,f.__.widthRange&&(x.hasRangeSize=!0)),f.__heightGrow&&j(f,d,X),x.width+=x.count?w+g:w,x.height=Math.max(x.height,d.height),x.count++):(E(f,G-d.x,B-d.y),G+=d.width+g));if(r&&x){const{isAutoYGap:i,isFitYGap:n,contentAlign:r,rowXAlign:a,rowYAlign:g}=h;x.count&&(x.grow?Y(t,x,R,o):c&&S(x,e,R,l),s&&A(u,x,e)),s?(i?S(u,"height",X,n):u.gap=_,function(t,o,e,i){m(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.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 _=0,c=n.length;_<c;_++)r=n[h?c-1-_:_],b(t,r,s,a,e,i),a+=r.height+o.gap}(t,u,g,o)):(m(t,x,r),b(t,x,0,x.y,g,o))}}const{move:H}=r;function M(t,o,e,i,n,h){const{children:r}=t;let s,a,{y:_,start:c}=o,l=e;_+=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&&(l=e+(o.width-a.width)/("center"===n?2:1)),H(s,l-a.x,_-a.y),_+=a.height+o.gap):i++}const{move:O}=r;function L(t,o){const e="height",{children:i,itemBox:n}=t,h=v(t,!1),{complex:r,wrap:s,xGap:a,yGap:_,isAutoYGap:c,isFitYGap:l}=h;if(!i.length)return;const u=s&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},g=c?0:_;let f,d,w,p,x,{x:y,y:B,width:b,height:R}=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=z(f,n),r?(f.__flowBounds=d,x||(x=F(p,g)),s&&x.count&&x.height+d.height>R&&(x.grow&&C(t,x,R,o),c&&S(x,e,R,l),A(u,x,e),x=F(p,g)),w=d.height,f.__heightGrow&&(x.grow+=f.__heightGrow,w=0,f.__.heightRange&&(x.hasRangeSize=!0)),f.__widthGrow&&W(f,d,b),x.height+=x.count?w+g:w,x.width=Math.max(x.width,d.width),x.count++):(O(f,y-d.x,B-d.y),B+=d.height+g));if(r&&x){const{isAutoXGap:i,isFitXGap:n,contentAlign:r,rowXAlign:_,rowYAlign:g}=h;x.count&&(x.grow&&C(t,x,R,o),c&&S(x,e,R,l),s&&A(u,x,e)),s?(i?S(u,"width",b,n):u.gap=a,function(t,o,e,i){m(t,o,e);const{list:n}=o;if(n.length>1&&(i||(i=G[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 _=0,c=n.length;_<c;_++)r=n[h?c-1-_:_],M(t,r,s,a,e,i),s+=r.width+o.gap}(t,u,_,o)):(m(t,x,r),M(t,x,x.x,0,_,o))}}function D(t){return a(t,(t=>_({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)&&c(this)}})))}l.add("flow","resize");const I=u.prototype,N=n.prototype,{__updateBoxBounds:U}=g.prototype;e(!1)(I,"flow"),f(0)(I,"gap"),f("top-left")(I,"flowAlign"),f(!1)(I,"flowWrap"),f("box")(I,"itemBox"),f(!0)(I,"inFlow"),D()(I,"autoWidth"),D()(I,"autoHeight"),f()(I,"autoBox");const{copyAndSpread:q}=d;N.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:o}=this;switch(t&&(this.leafer.created=!1),o){case"x":case!0:P(this);break;case"y":L(this);break;case"x-reverse":P(this,!0);break;case"y-reverse":L(this,!0)}t&&(this.leafer.created=!0)},N.__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()},N.__updateBoxBounds=function(t){const o=this.__;if(this.children.length){const{flow:e}=o;if(o.__autoSide){o.__hasSurface&&this.__extraUpdate(),e&&!t?this.__updateRectBoxBounds():U.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{p as Flow};
|
package/dist/flow.js
CHANGED
|
@@ -16,7 +16,7 @@ this.LeaferIN.flow = (function (exports, draw) {
|
|
|
16
16
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
17
|
PERFORMANCE OF THIS SOFTWARE.
|
|
18
18
|
***************************************************************************** */
|
|
19
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
19
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
function __decorate(decorators, target, key, desc) {
|
|
@@ -43,10 +43,10 @@ this.LeaferIN.flow = (function (exports, draw) {
|
|
|
43
43
|
};
|
|
44
44
|
__decorate([
|
|
45
45
|
draw.dataProcessor(FlowData)
|
|
46
|
-
], exports.Flow.prototype, "__",
|
|
46
|
+
], exports.Flow.prototype, "__", undefined);
|
|
47
47
|
__decorate([
|
|
48
48
|
draw.autoLayoutType('x')
|
|
49
|
-
], exports.Flow.prototype, "flow",
|
|
49
|
+
], exports.Flow.prototype, "flow", undefined);
|
|
50
50
|
exports.Flow = __decorate([
|
|
51
51
|
draw.registerUI()
|
|
52
52
|
], exports.Flow);
|
|
@@ -531,6 +531,8 @@ this.LeaferIN.flow = (function (exports, draw) {
|
|
|
531
531
|
if (this.children.length) {
|
|
532
532
|
const { flow } = data;
|
|
533
533
|
if (data.__autoSide) {
|
|
534
|
+
if (data.__hasSurface)
|
|
535
|
+
this.__extraUpdate();
|
|
534
536
|
flow && !secondLayout ? this.__updateRectBoxBounds() : __updateBoxBounds.call(this);
|
|
535
537
|
const { boxBounds } = this.__layout;
|
|
536
538
|
if (!data.__autoSize) {
|
package/dist/flow.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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,z,{x:H,y:X,width:Y,height:P}=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,z||(z=u(S,A)),g&&z.count&&z.width+R.width>Y&&(z.grow?w(t,z,Y,o):x&&p(z,e,Y,B),l(m,z,e),z=u(S,A)),v=R.width,F.__widthGrow&&(z.grow+=F.__widthGrow,v=0,F.__.widthRange&&(z.hasRangeSize=!0)),F.__heightGrow&&G(F,R,P),z.width+=z.count?v+A:v,z.height=Math.max(z.height,R.height),z.count++):(b(F,H-R.x,X-R.y),H+=R.width+A));if(c&&z){const{isAutoYGap:i,isFitYGap:h,contentAlign:c,rowXAlign:_,rowYAlign:u}=s;z.count&&(z.grow?w(t,z,Y,o):x&&p(z,e,Y,B),g&&l(m,z,e)),g?(i?p(m,"height",P,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,z,c),a(t,z,0,z.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,z,{x:H,y:X,width:Y,height:P}=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,z||(z=u(S,B)),c&&z.count&&z.height+R.height>P&&(z.grow&&x(t,z,P,o),y&&p(z,e,P,G),l(b,z,e),z=u(S,B)),v=R.height,m.__heightGrow&&(z.grow+=m.__heightGrow,v=0,m.__.heightRange&&(z.hasRangeSize=!0)),m.__widthGrow&&f(m,R,Y),z.height+=z.count?v+B:v,z.width=Math.max(z.width,R.width),z.count++):(F(m,H-R.x,X-R.y),X+=R.height+B));if(a&&z){const{isAutoXGap:i,isFitXGap:n,contentAlign:a,rowXAlign:_,rowYAlign:u}=s;z.count&&(z.grow&&x(t,z,P,o),y&&p(z,e,P,G),c&&l(b,z,e)),c?(i?p(b,"width",Y,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,z,a),A(t,z,z.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)}})))}t.Plugin.add("flow","resize");const S=t.UI.prototype,z=t.Box.prototype,{__updateBoxBounds:H}=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:X}=t.BoundsHelper;z.__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)},z.__updateContentBounds=function(){const{padding:t}=this.__,o=this.__layout,e=o.contentBounds===o.boxBounds;t?(e&&o.shrinkContent(),X(o.contentBounds,o.boxBounds,t,!0)):e||o.shrinkContentCancel()},z.__updateBoxBounds=function(t){const o=this.__;if(this.children.length){const{flow:e}=o;if(o.__autoSide){e&&!t?this.__updateRectBoxBounds():H.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&&X(i,i,o.padding,!1,o.__autoSize?null:o.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();e&&this.__updateContentBounds()}else this.__updateRectBoxBounds()};
|
|
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,z,{x:H,y:X,width:Y,height:P}=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,z||(z=u(S,A)),g&&z.count&&z.width+R.width>Y&&(z.grow?w(t,z,Y,o):x&&p(z,e,Y,B),l(m,z,e),z=u(S,A)),v=R.width,F.__widthGrow&&(z.grow+=F.__widthGrow,v=0,F.__.widthRange&&(z.hasRangeSize=!0)),F.__heightGrow&&G(F,R,P),z.width+=z.count?v+A:v,z.height=Math.max(z.height,R.height),z.count++):(b(F,H-R.x,X-R.y),H+=R.width+A));if(c&&z){const{isAutoYGap:i,isFitYGap:h,contentAlign:c,rowXAlign:_,rowYAlign:u}=s;z.count&&(z.grow?w(t,z,Y,o):x&&p(z,e,Y,B),g&&l(m,z,e)),g?(i?p(m,"height",P,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,z,c),a(t,z,0,z.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,z,{x:H,y:X,width:Y,height:P}=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,z||(z=u(S,B)),c&&z.count&&z.height+R.height>P&&(z.grow&&x(t,z,P,o),y&&p(z,e,P,G),l(b,z,e),z=u(S,B)),v=R.height,m.__heightGrow&&(z.grow+=m.__heightGrow,v=0,m.__.heightRange&&(z.hasRangeSize=!0)),m.__widthGrow&&f(m,R,Y),z.height+=z.count?v+B:v,z.width=Math.max(z.width,R.width),z.count++):(F(m,H-R.x,X-R.y),X+=R.height+B));if(a&&z){const{isAutoXGap:i,isFitXGap:n,contentAlign:a,rowXAlign:_,rowYAlign:u}=s;z.count&&(z.grow&&x(t,z,P,o),y&&p(z,e,P,G),c&&l(b,z,e)),c?(i?p(b,"width",Y,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,z,a),A(t,z,z.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)}})))}t.Plugin.add("flow","resize");const S=t.UI.prototype,z=t.Box.prototype,{__updateBoxBounds:H}=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:X}=t.BoundsHelper;z.__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)},z.__updateContentBounds=function(){const{padding:t}=this.__,o=this.__layout,e=o.contentBounds===o.boxBounds;t?(e&&o.shrinkContent(),X(o.contentBounds,o.boxBounds,t,!0)):e||o.shrinkContentCancel()},z.__updateBoxBounds=function(t){const o=this.__;if(this.children.length){const{flow:e}=o;if(o.__autoSide){o.__hasSurface&&this.__extraUpdate(),e&&!t?this.__updateRectBoxBounds():H.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&&X(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,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 d(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 g(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:z,height:P}=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=g(F,n),a?(F.__flowBounds=R,H||(H=p(S,A)),_&&H.count&&H.width+R.width>z&&(H.grow?w(t,H,z,o):x&&d(H,e,z,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,P),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,z,o):x&&d(H,e,z,G),_&&c(m,H,e)),_?(i?d(m,"height",P,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:z,height:P}=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=g(m,n),a?(m.__flowBounds=A,H||(H=p(S,B)),l&&H.count&&H.height+A.height>P&&(H.grow&&G(t,H,P,o),w&&d(H,e,P,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,z),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,P,o),w&&d(H,e,P,x),l&&c(b,H,e)),l?(i?d(b,"width",z,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)}})))}o.Plugin.add("flow","resize");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:z}=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(),z(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&&z(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);
|
|
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 d(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 g(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:z,height:P}=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=g(F,n),a?(F.__flowBounds=R,H||(H=p(S,A)),_&&H.count&&H.width+R.width>z&&(H.grow?w(t,H,z,o):x&&d(H,e,z,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,P),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,z,o):x&&d(H,e,z,G),_&&c(m,H,e)),_?(i?d(m,"height",P,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:z,height:P}=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=g(m,n),a?(m.__flowBounds=A,H||(H=p(S,B)),l&&H.count&&H.height+A.height>P&&(H.grow&&G(t,H,P,o),w&&d(H,e,P,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,z),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,P,o),w&&d(H,e,P,x),l&&c(b,H,e)),l?(i?d(b,"width",z,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)}})))}o.Plugin.add("flow","resize");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:z}=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(),z(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){o.__hasSurface&&this.__extraUpdate(),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&&z(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.3.
|
|
3
|
+
"version": "1.3.3",
|
|
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.3.
|
|
38
|
-
"@leafer-in/resize": "^1.3.
|
|
39
|
-
"@leafer-ui/interface": "^1.3.
|
|
40
|
-
"@leafer-in/interface": "^1.3.
|
|
37
|
+
"@leafer-ui/draw": "^1.3.3",
|
|
38
|
+
"@leafer-in/resize": "^1.3.3",
|
|
39
|
+
"@leafer-ui/interface": "^1.3.3",
|
|
40
|
+
"@leafer-in/interface": "^1.3.3"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/index.ts
CHANGED
|
@@ -77,7 +77,7 @@ box.__updateBoxBounds = function (secondLayout?: boolean): void { // autoSide且
|
|
|
77
77
|
|
|
78
78
|
if (data.__autoSide) {
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
if (data.__hasSurface) this.__extraUpdate() // Box自身存在样式,需要额外更新
|
|
81
81
|
|
|
82
82
|
flow && !secondLayout ? this.__updateRectBoxBounds() : __updateBoxBounds.call(this)
|
|
83
83
|
|