@leafer-in/flow 2.2.10 → 2.3.0
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 +42 -7
- package/dist/flow.esm.js +43 -8
- package/dist/flow.esm.min.js +1 -1
- package/dist/flow.esm.min.js.map +1 -1
- package/dist/flow.js +37 -7
- package/dist/flow.min.cjs +1 -1
- package/dist/flow.min.cjs.map +1 -1
- package/dist/flow.min.js +1 -1
- package/dist/flow.min.js.map +1 -1
- package/package.json +5 -5
- package/src/decorate.ts +9 -3
- package/src/index.ts +24 -5
- package/src/layout/flowX.ts +5 -1
- package/src/layout/flowY.ts +5 -1
- package/src/layout/x/grow.ts +1 -0
- package/src/layout/y/grow.ts +1 -0
package/dist/flow.cjs
CHANGED
|
@@ -234,6 +234,7 @@ function assignRemainSpace$1(list, totalSpace, countGrow) {
|
|
|
234
234
|
function resizeWidth(child, local, size) {
|
|
235
235
|
const {widthRange: widthRange, lockRatio: lockRatio} = child.__;
|
|
236
236
|
const realSize = widthRange ? within$1(size, widthRange) : size;
|
|
237
|
+
if (!local.width) child.__.width = local.width = 1;
|
|
237
238
|
const scale = realSize / local.width;
|
|
238
239
|
child.scaleResize(scale, lockRatio ? scale : 1);
|
|
239
240
|
local.width = realSize;
|
|
@@ -280,6 +281,7 @@ function assignRemainSpace(list, totalSpace, countGrow) {
|
|
|
280
281
|
function resizeHeight(child, local, size) {
|
|
281
282
|
const {heightRange: heightRange, lockRatio: lockRatio} = child.__;
|
|
282
283
|
const realSize = heightRange ? within(size, heightRange) : size;
|
|
284
|
+
if (!local.height) child.__.height = local.height = 1;
|
|
283
285
|
const scale = realSize / local.height;
|
|
284
286
|
child.scaleResize(lockRatio ? scale : 1, scale);
|
|
285
287
|
local.height = realSize;
|
|
@@ -298,6 +300,8 @@ function flowX(box, reverse) {
|
|
|
298
300
|
child = children[index = reverse ? len - 1 - i : i];
|
|
299
301
|
if (child.__.inFlow && child.__.visible !== 0) {
|
|
300
302
|
local = getItemBounds(child, itemBox);
|
|
303
|
+
if (child.__.autoWidth && draw.isObject(child.__.autoWidth)) resizeWidth(child, local, draw.UnitConvertHelper.number(child.__.autoWidth, width));
|
|
304
|
+
if (child.__.autoHeight && draw.isObject(child.__.autoHeight)) resizeHeight(child, local, draw.UnitConvertHelper.number(child.__.autoHeight, height));
|
|
301
305
|
if (complex) {
|
|
302
306
|
child.__flowBounds = local;
|
|
303
307
|
if (!data) data = getDrawData(index, xGapTempNum);
|
|
@@ -395,6 +399,8 @@ function flowY(box, reverse) {
|
|
|
395
399
|
child = children[index = reverse ? len - 1 - i : i];
|
|
396
400
|
if (child.__.inFlow && child.__.visible !== 0) {
|
|
397
401
|
local = getItemBounds(child, itemBox);
|
|
402
|
+
if (child.__.autoWidth && draw.isObject(child.__.autoWidth)) resizeWidth(child, local, draw.UnitConvertHelper.number(child.__.autoWidth, width));
|
|
403
|
+
if (child.__.autoHeight && draw.isObject(child.__.autoHeight)) resizeHeight(child, local, draw.UnitConvertHelper.number(child.__.autoHeight, height));
|
|
398
404
|
if (complex) {
|
|
399
405
|
child.__flowBounds = local;
|
|
400
406
|
if (!data) data = getDrawData(index, yGapTempNum);
|
|
@@ -437,22 +443,26 @@ function flowY(box, reverse) {
|
|
|
437
443
|
}
|
|
438
444
|
}
|
|
439
445
|
|
|
446
|
+
function autoBoundsParentChange(parent) {
|
|
447
|
+
parent.__hasGrow = true;
|
|
448
|
+
}
|
|
449
|
+
|
|
440
450
|
function autoBoundsType(defaultValue) {
|
|
441
451
|
return draw.decorateLeafAttr(defaultValue, key => draw.attr({
|
|
442
452
|
set(value) {
|
|
443
453
|
const grow = draw.isNumber(value) ? value : 0;
|
|
444
454
|
key === "autoWidth" ? this.__widthGrow = grow : this.__heightGrow = grow;
|
|
445
|
-
if (
|
|
446
|
-
this.
|
|
447
|
-
|
|
448
|
-
|
|
455
|
+
if (this.__setAttr(key, value)) {
|
|
456
|
+
if (grow) this.waitParentChange(autoBoundsParentChange);
|
|
457
|
+
draw.doBoundsType(this);
|
|
458
|
+
}
|
|
449
459
|
}
|
|
450
460
|
}));
|
|
451
461
|
}
|
|
452
462
|
|
|
453
463
|
draw.Plugin.add("flow", "resize");
|
|
454
464
|
|
|
455
|
-
const box = draw.Box.prototype, {__updateBoxBounds: __updateBoxBounds} = draw.Group.prototype;
|
|
465
|
+
const box = draw.Box.prototype, uiData = draw.UIData.prototype, {__updateBoxBounds: __updateBoxBounds} = draw.Group.prototype;
|
|
456
466
|
|
|
457
467
|
draw.UI.addAttr("flow", false, draw.autoLayoutType);
|
|
458
468
|
|
|
@@ -472,7 +482,7 @@ draw.UI.addAttr("autoHeight", undefined, autoBoundsType);
|
|
|
472
482
|
|
|
473
483
|
draw.UI.addAttr("autoBox", undefined, draw.boundsType);
|
|
474
484
|
|
|
475
|
-
const {copyAndSpread: copyAndSpread} = draw.BoundsHelper;
|
|
485
|
+
const {copyAndSpread: copyAndSpread, unsign: unsign} = draw.BoundsHelper;
|
|
476
486
|
|
|
477
487
|
box.__updateFlowLayout = function() {
|
|
478
488
|
const {leaferIsCreated: leaferIsCreated, flow: flow} = this;
|
|
@@ -505,13 +515,14 @@ box.__updateContentBounds = function() {
|
|
|
505
515
|
if (padding) {
|
|
506
516
|
if (same) layout.shrinkContent();
|
|
507
517
|
copyAndSpread(layout.contentBounds, layout.boxBounds, padding, true);
|
|
518
|
+
unsign(layout.contentBounds);
|
|
508
519
|
} else {
|
|
509
520
|
if (!same) layout.shrinkContentCancel();
|
|
510
521
|
}
|
|
511
522
|
};
|
|
512
523
|
|
|
513
524
|
box.__updateBoxBounds = function(secondLayout) {
|
|
514
|
-
if (this.children.length && !this.
|
|
525
|
+
if (this.children.length && !this.__useSelfBox) {
|
|
515
526
|
const data = this.__, {flow: flow} = data;
|
|
516
527
|
if (data.__autoSide) {
|
|
517
528
|
if (data.__hasSurface) this.__extraUpdate();
|
|
@@ -536,3 +547,27 @@ box.__updateBoxBounds = function(secondLayout) {
|
|
|
536
547
|
this.__updateRectBoxBounds();
|
|
537
548
|
}
|
|
538
549
|
};
|
|
550
|
+
|
|
551
|
+
Object.defineProperty(uiData, "__autoWidth", {
|
|
552
|
+
get() {
|
|
553
|
+
return this._width == null && this._autoWidth == null;
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
Object.defineProperty(uiData, "__autoHeight", {
|
|
558
|
+
get() {
|
|
559
|
+
return this._height == null && this._autoHeight == null;
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
Object.defineProperty(uiData, "__autoSide", {
|
|
564
|
+
get() {
|
|
565
|
+
return this.__autoWidth || this.__autoHeight;
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
Object.defineProperty(uiData, "__autoSize", {
|
|
570
|
+
get() {
|
|
571
|
+
return this.__autoWidth && this.__autoHeight;
|
|
572
|
+
}
|
|
573
|
+
});
|
package/dist/flow.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BoxData, dataProcessor, autoLayoutType, registerUI, Box, AlignHelper, PointHelper, isObject, tryToNumber, isString, MathHelper, decorateLeafAttr, attr, isNumber, doBoundsType, Plugin, Group, UI, boundsType, BoundsHelper } from "@leafer-ui/draw";
|
|
1
|
+
import { BoxData, dataProcessor, autoLayoutType, registerUI, Box, AlignHelper, PointHelper, isObject, tryToNumber, isString, MathHelper, UnitConvertHelper, decorateLeafAttr, attr, isNumber, doBoundsType, Plugin, UIData, Group, UI, boundsType, BoundsHelper } from "@leafer-ui/draw";
|
|
2
2
|
|
|
3
3
|
import "@leafer-in/resize";
|
|
4
4
|
|
|
@@ -232,6 +232,7 @@ function assignRemainSpace$1(list, totalSpace, countGrow) {
|
|
|
232
232
|
function resizeWidth(child, local, size) {
|
|
233
233
|
const {widthRange: widthRange, lockRatio: lockRatio} = child.__;
|
|
234
234
|
const realSize = widthRange ? within$1(size, widthRange) : size;
|
|
235
|
+
if (!local.width) child.__.width = local.width = 1;
|
|
235
236
|
const scale = realSize / local.width;
|
|
236
237
|
child.scaleResize(scale, lockRatio ? scale : 1);
|
|
237
238
|
local.width = realSize;
|
|
@@ -278,6 +279,7 @@ function assignRemainSpace(list, totalSpace, countGrow) {
|
|
|
278
279
|
function resizeHeight(child, local, size) {
|
|
279
280
|
const {heightRange: heightRange, lockRatio: lockRatio} = child.__;
|
|
280
281
|
const realSize = heightRange ? within(size, heightRange) : size;
|
|
282
|
+
if (!local.height) child.__.height = local.height = 1;
|
|
281
283
|
const scale = realSize / local.height;
|
|
282
284
|
child.scaleResize(lockRatio ? scale : 1, scale);
|
|
283
285
|
local.height = realSize;
|
|
@@ -296,6 +298,8 @@ function flowX(box, reverse) {
|
|
|
296
298
|
child = children[index = reverse ? len - 1 - i : i];
|
|
297
299
|
if (child.__.inFlow && child.__.visible !== 0) {
|
|
298
300
|
local = getItemBounds(child, itemBox);
|
|
301
|
+
if (child.__.autoWidth && isObject(child.__.autoWidth)) resizeWidth(child, local, UnitConvertHelper.number(child.__.autoWidth, width));
|
|
302
|
+
if (child.__.autoHeight && isObject(child.__.autoHeight)) resizeHeight(child, local, UnitConvertHelper.number(child.__.autoHeight, height));
|
|
299
303
|
if (complex) {
|
|
300
304
|
child.__flowBounds = local;
|
|
301
305
|
if (!data) data = getDrawData(index, xGapTempNum);
|
|
@@ -393,6 +397,8 @@ function flowY(box, reverse) {
|
|
|
393
397
|
child = children[index = reverse ? len - 1 - i : i];
|
|
394
398
|
if (child.__.inFlow && child.__.visible !== 0) {
|
|
395
399
|
local = getItemBounds(child, itemBox);
|
|
400
|
+
if (child.__.autoWidth && isObject(child.__.autoWidth)) resizeWidth(child, local, UnitConvertHelper.number(child.__.autoWidth, width));
|
|
401
|
+
if (child.__.autoHeight && isObject(child.__.autoHeight)) resizeHeight(child, local, UnitConvertHelper.number(child.__.autoHeight, height));
|
|
396
402
|
if (complex) {
|
|
397
403
|
child.__flowBounds = local;
|
|
398
404
|
if (!data) data = getDrawData(index, yGapTempNum);
|
|
@@ -435,22 +441,26 @@ function flowY(box, reverse) {
|
|
|
435
441
|
}
|
|
436
442
|
}
|
|
437
443
|
|
|
444
|
+
function autoBoundsParentChange(parent) {
|
|
445
|
+
parent.__hasGrow = true;
|
|
446
|
+
}
|
|
447
|
+
|
|
438
448
|
function autoBoundsType(defaultValue) {
|
|
439
449
|
return decorateLeafAttr(defaultValue, key => attr({
|
|
440
450
|
set(value) {
|
|
441
451
|
const grow = isNumber(value) ? value : 0;
|
|
442
452
|
key === "autoWidth" ? this.__widthGrow = grow : this.__heightGrow = grow;
|
|
443
|
-
if (
|
|
444
|
-
this.
|
|
445
|
-
|
|
446
|
-
|
|
453
|
+
if (this.__setAttr(key, value)) {
|
|
454
|
+
if (grow) this.waitParentChange(autoBoundsParentChange);
|
|
455
|
+
doBoundsType(this);
|
|
456
|
+
}
|
|
447
457
|
}
|
|
448
458
|
}));
|
|
449
459
|
}
|
|
450
460
|
|
|
451
461
|
Plugin.add("flow", "resize");
|
|
452
462
|
|
|
453
|
-
const box = Box.prototype, {__updateBoxBounds: __updateBoxBounds} = Group.prototype;
|
|
463
|
+
const box = Box.prototype, uiData = UIData.prototype, {__updateBoxBounds: __updateBoxBounds} = Group.prototype;
|
|
454
464
|
|
|
455
465
|
UI.addAttr("flow", false, autoLayoutType);
|
|
456
466
|
|
|
@@ -470,7 +480,7 @@ UI.addAttr("autoHeight", undefined, autoBoundsType);
|
|
|
470
480
|
|
|
471
481
|
UI.addAttr("autoBox", undefined, boundsType);
|
|
472
482
|
|
|
473
|
-
const {copyAndSpread: copyAndSpread} = BoundsHelper;
|
|
483
|
+
const {copyAndSpread: copyAndSpread, unsign: unsign} = BoundsHelper;
|
|
474
484
|
|
|
475
485
|
box.__updateFlowLayout = function() {
|
|
476
486
|
const {leaferIsCreated: leaferIsCreated, flow: flow} = this;
|
|
@@ -503,13 +513,14 @@ box.__updateContentBounds = function() {
|
|
|
503
513
|
if (padding) {
|
|
504
514
|
if (same) layout.shrinkContent();
|
|
505
515
|
copyAndSpread(layout.contentBounds, layout.boxBounds, padding, true);
|
|
516
|
+
unsign(layout.contentBounds);
|
|
506
517
|
} else {
|
|
507
518
|
if (!same) layout.shrinkContentCancel();
|
|
508
519
|
}
|
|
509
520
|
};
|
|
510
521
|
|
|
511
522
|
box.__updateBoxBounds = function(secondLayout) {
|
|
512
|
-
if (this.children.length && !this.
|
|
523
|
+
if (this.children.length && !this.__useSelfBox) {
|
|
513
524
|
const data = this.__, {flow: flow} = data;
|
|
514
525
|
if (data.__autoSide) {
|
|
515
526
|
if (data.__hasSurface) this.__extraUpdate();
|
|
@@ -535,4 +546,28 @@ box.__updateBoxBounds = function(secondLayout) {
|
|
|
535
546
|
}
|
|
536
547
|
};
|
|
537
548
|
|
|
549
|
+
Object.defineProperty(uiData, "__autoWidth", {
|
|
550
|
+
get() {
|
|
551
|
+
return this._width == null && this._autoWidth == null;
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
Object.defineProperty(uiData, "__autoHeight", {
|
|
556
|
+
get() {
|
|
557
|
+
return this._height == null && this._autoHeight == null;
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
Object.defineProperty(uiData, "__autoSide", {
|
|
562
|
+
get() {
|
|
563
|
+
return this.__autoWidth || this.__autoHeight;
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
Object.defineProperty(uiData, "__autoSize", {
|
|
568
|
+
get() {
|
|
569
|
+
return this.__autoWidth && this.__autoHeight;
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
|
|
538
573
|
export { Flow };
|
package/dist/flow.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{BoxData as t,dataProcessor as
|
|
1
|
+
import{BoxData as t,dataProcessor as e,autoLayoutType as o,registerUI as i,Box as n,AlignHelper as h,PointHelper as r,isObject as _,tryToNumber as a,isString as s,MathHelper as u,UnitConvertHelper as l,decorateLeafAttr as c,attr as d,isNumber as g,doBoundsType as f,Plugin as w,UIData as p,Group as x,UI as y,boundsType as m,BoundsHelper as G}from"@leafer-ui/draw";import"@leafer-in/resize";function b(t,e,o,i){var n,h=arguments.length,r=h<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,o,i);else for(var _=t.length-1;_>=0;_--)(n=t[_])&&(r=(h<3?n(r):h>3?n(e,o,r):n(e,o))||r);return h>3&&r&&Object.defineProperty(e,o,r),r}"function"==typeof SuppressedError&&SuppressedError;let B=class extends n{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}};b([e(class extends t{})],B.prototype,"__",void 0),b([o("x")],B.prototype,"flow",void 0),B=b([i()],B);const A={},v={"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 W(t,e,o){const i=t.__,{contentBounds:n}=t.__layout;h.toPoint(o,e,n,A),e.x=i.__autoWidth?n.x:A.x,e.y=i.__autoHeight?n.y:A.y}const{move:S}=r;function F(t,e,o,i,n,h){const{children:r}=t;let _,a,{x:s,start:u}=e,l=i;s+=o;for(let t=0,o=e.count;t<o;t++)_=r[h?u-t:u+t],_.__.inFlow&&0!==_.__.visible?(a=_.__flowBounds,"from"!==n&&(l=i+(e.height-a.height)/("center"===n?2:1)),S(_,s-a.x,l-a.y),s+=a.width+e.gap):o++}function H(t,e,o){const i="width"===o?"height":"width";t[o]=Math.max(t[o],e[o]),t[i]+=t.count?e[i]+t.gap:e[i],t.list.push(e),t.count++}const z={};function X(t,e){const{gap:o,flowAlign:i,flowWrap:n,__autoWidth:h,__autoHeight:r}=t.__,u=n&&(e?!h:!r);return _(o)?(z.xGap=o.x||0,z.yGap=o.y||0):z.xGap=z.yGap=a(o),z.isAutoXGap=s(z.xGap)&&!h,z.isAutoYGap=s(z.yGap)&&!r,z.complex=u||"top-left"!==i||t.__hasGrow||z.isAutoXGap||z.isAutoYGap,z.wrap=u,z.complex&&(z.isFitXGap="fit"===z.xGap&&!h,z.isFitYGap="fit"===z.yGap&&!r,_(i)?(z.contentAlign=i.content||"top-left",z.rowXAlign=i.x||"from",z.rowYAlign=i.y||"from"):(z.contentAlign=i,z.rowXAlign=v[i],z.rowYAlign=R[i])),z}function Y(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function k(t,e,o,i){const{count:n}=t;n>1&&(o>t[e]||i)&&(t.gap=(o-t[e])/(n-1),t[e]=o)}function P(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:j}=u;function C(t,e,o,i){let n,h,r,_=0,a=e.hasRangeSize&&[],{grow:s,start:u}=e;const l=(o-e.width)/s,{children:c}=t;if(!(l<=0)){e.width=o;for(let t=0,o=e.count;t<o;t++)n=c[i?u-t:u+t],n.__.inFlow&&0!==n.__.visible?(h=n.__widthGrow)&&(r=O(n,n.__flowBounds,l*h),r?(_+=r,s-=h):a&&(n.__.widthRange?a.unshift(n):a.push(n))):o++;_&&function(t,e,o){let i,n,h,r;t.forEach(t=>{i=t.__widthGrow,n=e/o*i,r=O(t,h=t.__flowBounds,h.width+n),e-=n-r,o-=i})}(a,_,s)}}function O(t,e,o){const{widthRange:i,lockRatio:n}=t.__,h=i?j(o,i):o;e.width||(t.__.width=e.width=1);const r=h/e.width;return t.scaleResize(r,n?r:1),e.width=h,o-h}const{within:E}=u;function M(t,e,o,i){let n,h,r,_=0,a=e.hasRangeSize&&[],{grow:s,start:u}=e;const l=(o-e.height)/s,{children:c}=t;if(!(l<=0)){e.height=o;for(let t=0,o=e.count;t<o;t++)n=c[i?u-t:u+t],n.__.inFlow&&0!==n.__.visible?(h=n.__heightGrow)&&(r=L(n,n.__flowBounds,l*h),r?(_+=r,s-=h):a&&(n.__.heightRange?a.unshift(n):a.push(n))):o++;_&&function(t,e,o){let i,n,h,r;t.forEach(t=>{i=t.__heightGrow,n=e/o*i,r=L(t,h=t.__flowBounds,h.height+n),e-=n-r,o-=i})}(a,_,s)}}function L(t,e,o){const{heightRange:i,lockRatio:n}=t.__,h=i?E(o,i):o;e.height||(t.__.height=e.height=1);const r=h/e.height;return t.scaleResize(n?r:1,r),e.height=h,o-h}const{move:D}=r;function I(t,e){const o="width",{children:i,itemBox:n}=t,h=X(t,!0),{complex:r,wrap:a,xGap:s,yGap:u,isAutoXGap:c,isFitXGap:d}=h;if(!i.length)return;const g=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},f=c?0:s;let w,p,x,y,m,{x:G,y:b,width:B,height:A}=t.__layout.contentBounds;for(let h=0,s=i.length;h<s;h++)w=i[y=e?s-1-h:h],w.__.inFlow&&0!==w.__.visible&&(p=P(w,n),w.__.autoWidth&&_(w.__.autoWidth)&&O(w,p,l.number(w.__.autoWidth,B)),w.__.autoHeight&&_(w.__.autoHeight)&&L(w,p,l.number(w.__.autoHeight,A)),r?(w.__flowBounds=p,m||(m=Y(y,f)),a&&m.count&&m.width+p.width>B&&(m.grow?C(t,m,B,e):c&&k(m,o,B,d),H(g,m,o),m=Y(y,f)),x=p.width,w.__widthGrow&&(m.grow+=w.__widthGrow,x=0,w.__.widthRange&&(m.hasRangeSize=!0)),w.__heightGrow&&L(w,p,A),m.width+=m.count?x+f:x,m.height=Math.max(m.height,p.height),m.count++):(D(w,G-p.x,b-p.y),G+=p.width+f));if(r&&m){const{isAutoYGap:i,isFitYGap:n,contentAlign:r,rowXAlign:_,rowYAlign:s}=h;m.count&&(m.grow?C(t,m,B,e):c&&k(m,o,B,d),a&&H(g,m,o)),a?(i?k(g,"height",A,n):g.height+=(g.gap=u)*(g.list.length-1),function(t,e,o,i){W(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=v[o]),"from"!==i)){let t;for(let o=0,h=n.length;o<h;o++)t=n[o],t.x=e.width-t.width,"center"===i&&(t.x/=2)}}(t,g,r,_),function(t,e,o,i){const{list:n}=e,h="reverse"===t.__.flowWrap;let r,{x:_,y:a}=e;for(let s=0,u=n.length;s<u;s++)r=n[h?u-1-s:s],F(t,r,_,a,o,i),a+=r.height+e.gap}(t,g,s,e)):(W(t,m,r),F(t,m,0,m.y,s,e))}}const{move:N}=r;function U(t,e,o,i,n,h){const{children:r}=t;let _,a,{y:s,start:u}=e,l=o;s+=i;for(let t=0,i=e.count;t<i;t++)_=r[h?u-t:u+t],_.__.inFlow&&0!==_.__.visible?(a=_.__flowBounds,"from"!==n&&(l=o+(e.width-a.width)/("center"===n?2:1)),N(_,l-a.x,s-a.y),s+=a.height+e.gap):i++}const{move:q}=r;function J(t,e){const o="height",{children:i,itemBox:n}=t,h=X(t,!1),{complex:r,wrap:a,xGap:s,yGap:u,isAutoYGap:c,isFitYGap:d}=h;if(!i.length)return;const g=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},f=c?0:u;let w,p,x,y,m,{x:G,y:b,width:B,height:A}=t.__layout.contentBounds;for(let h=0,s=i.length;h<s;h++)w=i[y=e?s-1-h:h],w.__.inFlow&&0!==w.__.visible&&(p=P(w,n),w.__.autoWidth&&_(w.__.autoWidth)&&O(w,p,l.number(w.__.autoWidth,B)),w.__.autoHeight&&_(w.__.autoHeight)&&L(w,p,l.number(w.__.autoHeight,A)),r?(w.__flowBounds=p,m||(m=Y(y,f)),a&&m.count&&m.height+p.height>A&&(m.grow&&M(t,m,A,e),c&&k(m,o,A,d),H(g,m,o),m=Y(y,f)),x=p.height,w.__heightGrow&&(m.grow+=w.__heightGrow,x=0,w.__.heightRange&&(m.hasRangeSize=!0)),w.__widthGrow&&O(w,p,B),m.height+=m.count?x+f:x,m.width=Math.max(m.width,p.width),m.count++):(q(w,G-p.x,b-p.y),b+=p.height+f));if(r&&m){const{isAutoXGap:i,isFitXGap:n,contentAlign:r,rowXAlign:_,rowYAlign:u}=h;m.count&&(m.grow&&M(t,m,A,e),c&&k(m,o,A,d),a&&H(g,m,o)),a?(i?k(g,"width",B,n):g.width+=(g.gap=s)*(g.list.length-1),function(t,e,o,i){W(t,e,o);const{list:n}=e;if(n.length>1&&(i||(i=R[o]),"from"!==i)){let t;for(let o=0,h=n.length;o<h;o++)t=n[o],t.y=e.height-t.height,"center"===i&&(t.y/=2)}}(t,g,r,u),function(t,e,o,i){const{list:n}=e,h="reverse"===t.__.flowWrap;let r,{x:_,y:a}=e;for(let s=0,u=n.length;s<u;s++)r=n[h?u-1-s:s],U(t,r,_,a,o,i),_+=r.width+e.gap}(t,g,_,e)):(W(t,m,r),U(t,m,m.x,0,_,e))}}function K(t){t.__hasGrow=!0}function Q(t){return c(t,t=>d({set(e){const o=g(e)?e:0;"autoWidth"===t?this.__widthGrow=o:this.__heightGrow=o,this.__setAttr(t,e)&&(o&&this.waitParentChange(K),f(this))}}))}w.add("flow","resize");const T=n.prototype,V=p.prototype,{__updateBoxBounds:Z}=x.prototype;y.addAttr("flow",!1,o),y.addAttr("gap",0,m),y.addAttr("flowAlign","top-left",m),y.addAttr("flowWrap",!1,m),y.addAttr("itemBox","box",m),y.addAttr("inFlow",!0,m),y.addAttr("autoWidth",void 0,Q),y.addAttr("autoHeight",void 0,Q),y.addAttr("autoBox",void 0,m);const{copyAndSpread:$,unsign:tt}=G;T.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:e}=this;switch(t&&(this.leafer.created=!1),e){case"x":case!0:I(this);break;case"y":J(this);break;case"x-reverse":I(this,!0);break;case"y-reverse":J(this,!0)}t&&(this.leafer.created=!0)},T.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,o=e.contentBounds===e.boxBounds;t?(o&&e.shrinkContent(),$(e.contentBounds,e.boxBounds,t,!0),tt(e.contentBounds)):o||e.shrinkContentCancel()},T.__updateBoxBounds=function(t){if(this.children.length&&!this.__useSelfBox){const e=this.__,{flow:o}=e;if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),o&&!t?this.__updateRectBoxBounds():Z.call(this);const{boxBounds:i}=this.__layout;e.__autoSize||(e.__autoWidth?(o||(i.width+=i.x,i.x=0),i.height=e.height,i.y=0):(o||(i.height+=i.y,i.y=0),i.width=e.width,i.x=0)),o&&t&&e.padding&&$(i,i,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();o&&this.__updateContentBounds()}else this.__updateRectBoxBounds()},Object.defineProperty(V,"__autoWidth",{get(){return null==this._width&&null==this._autoWidth}}),Object.defineProperty(V,"__autoHeight",{get(){return null==this._height&&null==this._autoHeight}}),Object.defineProperty(V,"__autoSide",{get(){return this.__autoWidth||this.__autoHeight}}),Object.defineProperty(V,"__autoSize",{get(){return this.__autoWidth&&this.__autoHeight}});export{B as Flow};
|
|
2
2
|
//# sourceMappingURL=flow.esm.min.js.map
|