leafer-ui 1.0.3 → 1.0.5

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/web.js CHANGED
@@ -4486,15 +4486,16 @@ var LeaferUI = (function (exports) {
4486
4486
  }
4487
4487
  getLayoutBounds(type, relative = 'world', unscale) {
4488
4488
  const { leaf } = this;
4489
- let point, matrix, bounds = this.getInnerBounds(type);
4489
+ let point, matrix, layoutBounds, bounds = this.getInnerBounds(type);
4490
4490
  switch (relative) {
4491
4491
  case 'world':
4492
4492
  point = leaf.getWorldPoint(bounds);
4493
4493
  matrix = leaf.__world;
4494
4494
  break;
4495
4495
  case 'local':
4496
+ const { scaleX, scaleY, rotation, skewX, skewY } = leaf.__;
4497
+ layoutBounds = { scaleX, scaleY, rotation, skewX, skewY };
4496
4498
  point = leaf.getLocalPointByInner(bounds);
4497
- matrix = leaf.__localMatrix;
4498
4499
  break;
4499
4500
  case 'inner':
4500
4501
  point = bounds;
@@ -4506,7 +4507,8 @@ var LeaferUI = (function (exports) {
4506
4507
  point = leaf.getWorldPoint(bounds, relative);
4507
4508
  matrix = getRelativeWorld$1(leaf, relative, true);
4508
4509
  }
4509
- const layoutBounds = MatrixHelper.getLayout(matrix);
4510
+ if (!layoutBounds)
4511
+ layoutBounds = MatrixHelper.getLayout(matrix);
4510
4512
  copy$6(layoutBounds, bounds);
4511
4513
  PointHelper.copy(layoutBounds, point);
4512
4514
  if (unscale) {
@@ -4756,6 +4758,7 @@ var LeaferUI = (function (exports) {
4756
4758
  }
4757
4759
  }
4758
4760
  RenderEvent.REQUEST = 'render.request';
4761
+ RenderEvent.CHILD_START = 'render.child_start';
4759
4762
  RenderEvent.START = 'render.start';
4760
4763
  RenderEvent.BEFORE = 'render.before';
4761
4764
  RenderEvent.RENDER = 'render';
@@ -4931,7 +4934,7 @@ var LeaferUI = (function (exports) {
4931
4934
  const debug$8 = Debug.get('setAttr');
4932
4935
  const LeafDataProxy = {
4933
4936
  __setAttr(name, newValue, checkFiniteNumber) {
4934
- if (this.leafer && this.leafer.created) {
4937
+ if (this.leaferIsCreated) {
4935
4938
  const oldValue = this.__.__getInput(name);
4936
4939
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4937
4940
  debug$8.warn(this.innerName, name, newValue);
@@ -5003,7 +5006,7 @@ var LeaferUI = (function (exports) {
5003
5006
 
5004
5007
  const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
5005
5008
  const { updateBounds: updateBounds$1 } = BranchHelper;
5006
- const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$5 } = BoundsHelper;
5009
+ const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
5007
5010
  const { toBounds: toBounds$2 } = PathBounds;
5008
5011
  const LeafBounds = {
5009
5012
  __updateWorldBounds() {
@@ -5086,7 +5089,7 @@ var LeaferUI = (function (exports) {
5086
5089
  const b = this.__layout.boxBounds;
5087
5090
  const data = this.__;
5088
5091
  if (data.__pathInputed) {
5089
- toBounds$2(data.__pathForRender, b);
5092
+ toBounds$2(data.path, b);
5090
5093
  }
5091
5094
  else {
5092
5095
  b.x = 0;
@@ -5098,7 +5101,7 @@ var LeaferUI = (function (exports) {
5098
5101
  __updateAutoLayout() {
5099
5102
  this.__layout.matrixChanged = true;
5100
5103
  if (this.isBranch) {
5101
- if (this.leafer && this.leafer.ready)
5104
+ if (this.leaferIsReady)
5102
5105
  this.leafer.layouter.addExtra(this);
5103
5106
  if (this.__.flow) {
5104
5107
  if (this.__layout.boxChanged)
@@ -5124,11 +5127,11 @@ var LeaferUI = (function (exports) {
5124
5127
  },
5125
5128
  __updateStrokeBounds() {
5126
5129
  const layout = this.__layout;
5127
- copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5130
+ copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5128
5131
  },
5129
5132
  __updateRenderBounds() {
5130
5133
  const layout = this.__layout;
5131
- layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
5134
+ layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
5132
5135
  }
5133
5136
  };
5134
5137
 
@@ -5233,6 +5236,8 @@ var LeaferUI = (function (exports) {
5233
5236
  get innerName() { return this.__.name || this.tag + this.innerId; }
5234
5237
  get __DataProcessor() { return LeafData; }
5235
5238
  get __LayoutProcessor() { return LeafLayout; }
5239
+ get leaferIsCreated() { return this.leafer && this.leafer.created; }
5240
+ get leaferIsReady() { return this.leafer && this.leafer.ready; }
5236
5241
  get isLeafer() { return false; }
5237
5242
  get isBranch() { return false; }
5238
5243
  get isBranchLeaf() { return false; }
@@ -5674,6 +5679,7 @@ var LeaferUI = (function (exports) {
5674
5679
  add(child, index) {
5675
5680
  if (child === this)
5676
5681
  return;
5682
+ child.__ || (child = UICreator.get(child.tag, child));
5677
5683
  if (child.parent)
5678
5684
  child.parent.remove(child);
5679
5685
  child.parent = this;
@@ -5696,10 +5702,14 @@ var LeaferUI = (function (exports) {
5696
5702
  }
5697
5703
  remove(child, destroy) {
5698
5704
  if (child) {
5699
- if (child.animationOut)
5700
- child.__runAnimation('out', () => this.__remove(child, destroy));
5705
+ if (child.__) {
5706
+ if (child.animationOut)
5707
+ child.__runAnimation('out', () => this.__remove(child, destroy));
5708
+ else
5709
+ this.__remove(child, destroy);
5710
+ }
5701
5711
  else
5702
- this.__remove(child, destroy);
5712
+ this.find(child).forEach(item => this.remove(item, destroy));
5703
5713
  }
5704
5714
  else if (child === undefined) {
5705
5715
  super.remove(null, destroy);
@@ -5917,7 +5927,7 @@ var LeaferUI = (function (exports) {
5917
5927
  }
5918
5928
  }
5919
5929
 
5920
- const version = "1.0.3";
5930
+ const version = "1.0.5";
5921
5931
 
5922
5932
  const debug$7 = Debug.get('LeaferCanvas');
5923
5933
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6559,6 +6569,7 @@ var LeaferUI = (function (exports) {
6559
6569
  this.totalBounds = new Bounds();
6560
6570
  debug$5.log(target.innerName, '--->');
6561
6571
  try {
6572
+ target.app.emit(RenderEvent.CHILD_START, target);
6562
6573
  this.emitRender(RenderEvent.START);
6563
6574
  this.renderOnce(callback);
6564
6575
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -6856,7 +6867,7 @@ var LeaferUI = (function (exports) {
6856
6867
  if (child.isBranch) {
6857
6868
  if (hit || child.__ignoreHitWorld) {
6858
6869
  this.eachFind(child.children, child.__onlyHitMask);
6859
- if (child.isBranchLeaf && !this.findList.length)
6870
+ if (child.isBranchLeaf)
6860
6871
  this.hitChild(child, point);
6861
6872
  }
6862
6873
  }
@@ -7566,12 +7577,7 @@ var LeaferUI = (function (exports) {
7566
7577
  this.__drawPathByData(canvas, this.__.path);
7567
7578
  }
7568
7579
  __drawPathByData(drawer, data) {
7569
- if (data) {
7570
- PathDrawer.drawPathByData(drawer, data);
7571
- }
7572
- else {
7573
- this.__drawPathByBox(drawer);
7574
- }
7580
+ data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
7575
7581
  }
7576
7582
  __drawPathByBox(drawer) {
7577
7583
  const { x, y, width, height } = this.__layout.boxBounds;
@@ -7579,9 +7585,8 @@ var LeaferUI = (function (exports) {
7579
7585
  const { cornerRadius } = this.__;
7580
7586
  drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7581
7587
  }
7582
- else {
7588
+ else
7583
7589
  drawer.rect(x, y, width, height);
7584
- }
7585
7590
  }
7586
7591
  animate(_keyframe, _options, _type, _isTemp) {
7587
7592
  return needPlugin('animate');
@@ -7590,10 +7595,10 @@ var LeaferUI = (function (exports) {
7590
7595
  export(filename, options) {
7591
7596
  return Export.export(this, filename, options);
7592
7597
  }
7593
- clone(newData) {
7598
+ clone(data) {
7594
7599
  const json = this.toJSON();
7595
- if (newData)
7596
- Object.assign(json, newData);
7600
+ if (data)
7601
+ Object.assign(json, data);
7597
7602
  return UI_1.one(json);
7598
7603
  }
7599
7604
  static one(data, x, y, width, height) {
@@ -8264,10 +8269,9 @@ var LeaferUI = (function (exports) {
8264
8269
  registerUI()
8265
8270
  ], exports.Rect);
8266
8271
 
8267
- const rect$1 = exports.Rect.prototype;
8268
- const group$1 = exports.Group.prototype;
8272
+ const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
8273
+ const rect$1 = exports.Rect.prototype, group$1 = exports.Group.prototype;
8269
8274
  const childrenRenderBounds = {};
8270
- const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
8271
8275
  exports.Box = class Box extends exports.Group {
8272
8276
  get __tag() { return 'Box'; }
8273
8277
  get isBranchLeaf() { return true; }
@@ -8281,29 +8285,27 @@ var LeaferUI = (function (exports) {
8281
8285
  return this.__updateRectRenderSpread() || -1;
8282
8286
  }
8283
8287
  __updateRectBoxBounds() { }
8284
- __updateBoxBounds(secondLayout) {
8288
+ __updateBoxBounds(_secondLayout) {
8285
8289
  const data = this.__;
8286
8290
  if (this.children.length) {
8287
8291
  if (data.__autoSide) {
8288
- if (this.leafer && this.leafer.ready)
8289
- this.leafer.layouter.addExtra(this);
8290
8292
  super.__updateBoxBounds();
8291
8293
  const { boxBounds } = this.__layout;
8292
8294
  if (!data.__autoSize) {
8293
- if (data.__autoWidth)
8294
- boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
8295
- else
8296
- boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
8295
+ if (data.__autoWidth) {
8296
+ boxBounds.width += boxBounds.x, boxBounds.x = 0;
8297
+ boxBounds.height = data.height, boxBounds.y = 0;
8298
+ }
8299
+ else {
8300
+ boxBounds.height += boxBounds.y, boxBounds.y = 0;
8301
+ boxBounds.width = data.width, boxBounds.x = 0;
8302
+ }
8297
8303
  }
8298
- if (secondLayout && data.flow && data.padding)
8299
- copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
8300
8304
  this.__updateNaturalSize();
8301
8305
  }
8302
8306
  else {
8303
8307
  this.__updateRectBoxBounds();
8304
8308
  }
8305
- if (data.flow)
8306
- this.__updateContentBounds();
8307
8309
  }
8308
8310
  else {
8309
8311
  this.__updateRectBoxBounds();
@@ -8369,6 +8371,9 @@ var LeaferUI = (function (exports) {
8369
8371
  __decorate([
8370
8372
  dataType(false)
8371
8373
  ], exports.Box.prototype, "resizeChildren", void 0);
8374
+ __decorate([
8375
+ dataType(false)
8376
+ ], exports.Box.prototype, "textBox", void 0);
8372
8377
  __decorate([
8373
8378
  affectRenderBoundsType('show')
8374
8379
  ], exports.Box.prototype, "overflow", void 0);
@@ -8898,6 +8903,9 @@ var LeaferUI = (function (exports) {
8898
8903
  __decorate([
8899
8904
  boundsType('top')
8900
8905
  ], exports.Text.prototype, "verticalAlign", void 0);
8906
+ __decorate([
8907
+ boundsType(true)
8908
+ ], exports.Text.prototype, "autoSizeAlign", void 0);
8901
8909
  __decorate([
8902
8910
  boundsType('normal')
8903
8911
  ], exports.Text.prototype, "textWrap", void 0);
@@ -9618,9 +9626,10 @@ var LeaferUI = (function (exports) {
9618
9626
  this.dragData = getDragEventData(data, data, data);
9619
9627
  this.canAnimate = this.canDragOut = true;
9620
9628
  }
9621
- getList() {
9629
+ getList(realDraggable, hover) {
9622
9630
  const { proxy } = this.interaction.selector;
9623
- return this.dragging && (!proxy || !proxy.list.length) ? (exports.DragEvent.list || this.dragableList || emptyList) : emptyList;
9631
+ const hasProxyList = proxy && proxy.list.length, dragList = exports.DragEvent.list || this.draggableList || emptyList;
9632
+ return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList);
9624
9633
  }
9625
9634
  checkDrag(data, canDrag) {
9626
9635
  const { interaction } = this;
@@ -9645,8 +9654,8 @@ var LeaferUI = (function (exports) {
9645
9654
  this.dragging = canDrag && PointerButton.left(data);
9646
9655
  if (this.dragging) {
9647
9656
  this.interaction.emit(exports.DragEvent.START, this.dragData);
9648
- this.getDragableList(this.dragData.path);
9649
- this.setDragStartPoints(this.realDragableList = this.getList());
9657
+ this.getDraggableList(this.dragData.path);
9658
+ this.setDragStartPoints(this.realDraggableList = this.getList(true));
9650
9659
  }
9651
9660
  }
9652
9661
  }
@@ -9654,12 +9663,12 @@ var LeaferUI = (function (exports) {
9654
9663
  this.dragStartPoints = {};
9655
9664
  list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9656
9665
  }
9657
- getDragableList(path) {
9666
+ getDraggableList(path) {
9658
9667
  let leaf;
9659
9668
  for (let i = 0, len = path.length; i < len; i++) {
9660
9669
  leaf = path.list[i];
9661
- if ((leaf.__.draggable || leaf.__.editable) && leaf.__.hitSelf && !leaf.__.locked) {
9662
- this.dragableList = new LeafList(leaf);
9670
+ if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
9671
+ this.draggableList = new LeafList(leaf);
9663
9672
  break;
9664
9673
  }
9665
9674
  }
@@ -9684,7 +9693,7 @@ var LeaferUI = (function (exports) {
9684
9693
  }
9685
9694
  dragReal() {
9686
9695
  const { running } = this.interaction;
9687
- const list = this.realDragableList;
9696
+ const list = this.realDraggableList;
9688
9697
  if (list.length && running) {
9689
9698
  const { totalX, totalY } = this.dragData;
9690
9699
  list.forEach(leaf => leaf.draggable && leaf.move(exports.DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
@@ -9773,7 +9782,7 @@ var LeaferUI = (function (exports) {
9773
9782
  this.interaction.emit(exports.DragEvent.LEAVE, data, dragEnterPath);
9774
9783
  }
9775
9784
  dragReset() {
9776
- exports.DragEvent.list = exports.DragEvent.data = this.dragableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9785
+ exports.DragEvent.list = exports.DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9777
9786
  }
9778
9787
  checkDragOut(data) {
9779
9788
  const { interaction } = this;
@@ -9914,6 +9923,7 @@ var LeaferUI = (function (exports) {
9914
9923
  touch: {
9915
9924
  preventDefault: true
9916
9925
  },
9926
+ multiTouch: {},
9917
9927
  cursor: true,
9918
9928
  keyEvent: true
9919
9929
  };
@@ -10040,6 +10050,8 @@ var LeaferUI = (function (exports) {
10040
10050
  this.pointerUp(data);
10041
10051
  }
10042
10052
  multiTouch(data, list) {
10053
+ if (this.config.multiTouch.disabled)
10054
+ return;
10043
10055
  const { move, angle, scale, center } = MultiTouchHelper.getData(list);
10044
10056
  this.rotate(getRotateEventData$1(center, angle, data));
10045
10057
  this.zoom(getZoomEventData$1(center, scale, data));
@@ -10229,7 +10241,7 @@ var LeaferUI = (function (exports) {
10229
10241
  data = this.hoverData;
10230
10242
  if (!data)
10231
10243
  return;
10232
- this.findPath(data, { exclude: this.dragger.getList(), name: exports.PointerEvent.MOVE });
10244
+ this.findPath(data, { exclude: this.dragger.getList(false, true), name: exports.PointerEvent.MOVE });
10233
10245
  this.hoverData = data;
10234
10246
  }
10235
10247
  updateCursor(data) {
@@ -10251,7 +10263,7 @@ var LeaferUI = (function (exports) {
10251
10263
  const { path } = data;
10252
10264
  for (let i = 0, len = path.length; i < len; i++) {
10253
10265
  leaf = path.list[i];
10254
- cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
10266
+ cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor;
10255
10267
  if (cursor)
10256
10268
  break;
10257
10269
  }
@@ -10433,7 +10445,7 @@ var LeaferUI = (function (exports) {
10433
10445
  if (isHitPixel) {
10434
10446
  const { renderBounds } = this.__layout;
10435
10447
  const size = Platform.image.hitCanvasSize;
10436
- const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds, 0.5).a;
10448
+ const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10437
10449
  const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
10438
10450
  h.resize({ width, height, pixelRatio: 1 });
10439
10451
  h.clear();
@@ -10489,15 +10501,14 @@ var LeaferUI = (function (exports) {
10489
10501
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
10490
10502
  };
10491
10503
 
10492
- const ui$1 = new exports.UI();
10493
- const rect = exports.Rect.prototype;
10494
- rect.__updateHitCanvas = function () {
10504
+ const ui$1 = exports.UI.prototype, rect = exports.Rect.prototype, box$1 = exports.Box.prototype;
10505
+ rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
10495
10506
  if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
10496
10507
  ui$1.__updateHitCanvas.call(this);
10497
10508
  else if (this.__hitCanvas)
10498
10509
  this.__hitCanvas = null;
10499
10510
  };
10500
- rect.__hitFill = function (inner) {
10511
+ rect.__hitFill = box$1.__hitFill = function (inner) {
10501
10512
  return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10502
10513
  };
10503
10514
 
@@ -11348,9 +11359,10 @@ var LeaferUI = (function (exports) {
11348
11359
  onLoadError(ui, event, image.error);
11349
11360
  }
11350
11361
  else {
11351
- ignoreRender(ui, true);
11352
- if (firstUse)
11362
+ if (firstUse) {
11363
+ ignoreRender(ui, true);
11353
11364
  onLoad(ui, event);
11365
+ }
11354
11366
  leafPaint.loadId = image.load(() => {
11355
11367
  ignoreRender(ui, false);
11356
11368
  if (!ui.destroyed) {
@@ -11962,11 +11974,12 @@ var LeaferUI = (function (exports) {
11962
11974
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
11963
11975
  let word, row, wordWidth, rowWidth, realWidth;
11964
11976
  let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
11965
- let textDrawData, rows = [], bounds;
11977
+ let textDrawData, rows = [], bounds, findMaxWidth;
11966
11978
  function createRows(drawData, content, style) {
11967
11979
  textDrawData = drawData;
11968
11980
  rows = drawData.rows;
11969
11981
  bounds = drawData.bounds;
11982
+ findMaxWidth = !bounds.width && !style.autoSizeAlign;
11970
11983
  const { __letterSpacing, paraIndent, textCase } = style;
11971
11984
  const { canvas } = Platform;
11972
11985
  const { width, height } = bounds;
@@ -12051,7 +12064,10 @@ var LeaferUI = (function (exports) {
12051
12064
  else {
12052
12065
  content.split('\n').forEach(content => {
12053
12066
  textDrawData.paraNumber++;
12054
- rows.push({ x: paraIndent || 0, text: content, width: canvas.measureText(content).width, paraStart: true });
12067
+ rowWidth = canvas.measureText(content).width;
12068
+ rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
12069
+ if (findMaxWidth)
12070
+ setMaxWidth();
12055
12071
  });
12056
12072
  }
12057
12073
  }
@@ -12082,10 +12098,16 @@ var LeaferUI = (function (exports) {
12082
12098
  row.width = rowWidth;
12083
12099
  if (bounds.width)
12084
12100
  trimRight(row);
12101
+ else if (findMaxWidth)
12102
+ setMaxWidth();
12085
12103
  rows.push(row);
12086
12104
  row = { words: [] };
12087
12105
  rowWidth = 0;
12088
12106
  }
12107
+ function setMaxWidth() {
12108
+ if (rowWidth > (textDrawData.maxWidth || 0))
12109
+ textDrawData.maxWidth = rowWidth;
12110
+ }
12089
12111
 
12090
12112
  const CharMode = 0;
12091
12113
  const WordMode = 1;
@@ -12157,34 +12179,32 @@ var LeaferUI = (function (exports) {
12157
12179
 
12158
12180
  function layoutText(drawData, style) {
12159
12181
  const { rows, bounds } = drawData;
12160
- const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
12182
+ const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
12161
12183
  let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
12162
12184
  let starY = __baseLine;
12163
12185
  if (__clipText && realHeight > height) {
12164
12186
  realHeight = Math.max(height, __lineHeight);
12165
12187
  drawData.overflow = rows.length;
12166
12188
  }
12167
- else {
12189
+ else if (height || autoSizeAlign) {
12168
12190
  switch (verticalAlign) {
12169
12191
  case 'middle':
12170
12192
  y += (height - realHeight) / 2;
12171
12193
  break;
12172
- case 'bottom':
12173
- y += (height - realHeight);
12194
+ case 'bottom': y += (height - realHeight);
12174
12195
  }
12175
12196
  }
12176
12197
  starY += y;
12177
- let row, rowX, rowWidth;
12198
+ let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
12178
12199
  for (let i = 0, len = rows.length; i < len; i++) {
12179
12200
  row = rows[i];
12180
12201
  row.x = x;
12181
12202
  if (row.width < width || (row.width > width && !__clipText)) {
12182
12203
  switch (textAlign) {
12183
12204
  case 'center':
12184
- row.x += (width - row.width) / 2;
12205
+ row.x += (layoutWidth - row.width) / 2;
12185
12206
  break;
12186
- case 'right':
12187
- row.x += width - row.width;
12207
+ case 'right': row.x += layoutWidth - row.width;
12188
12208
  }
12189
12209
  }
12190
12210
  if (row.paraStart && paraSpacing && i > 0)
@@ -12289,14 +12309,14 @@ var LeaferUI = (function (exports) {
12289
12309
  let height = style.__getInput('height') || 0;
12290
12310
  const { textDecoration, __font, __padding: padding } = style;
12291
12311
  if (padding) {
12292
- if (width) {
12312
+ if (width)
12313
+ x = padding[left], width -= (padding[right] + padding[left]);
12314
+ else if (!style.autoSizeAlign)
12293
12315
  x = padding[left];
12294
- width -= (padding[right] + padding[left]);
12295
- }
12296
- if (height) {
12316
+ if (height)
12317
+ y = padding[top], height -= (padding[top] + padding[bottom]);
12318
+ else if (!style.autoSizeAlign)
12297
12319
  y = padding[top];
12298
- height -= (padding[top] + padding[bottom]);
12299
- }
12300
12320
  }
12301
12321
  const drawData = {
12302
12322
  bounds: { x, y, width, height },
@@ -12316,22 +12336,20 @@ var LeaferUI = (function (exports) {
12316
12336
  return drawData;
12317
12337
  }
12318
12338
  function padAutoText(padding, drawData, style, width, height) {
12319
- if (!width) {
12339
+ if (!width && style.autoSizeAlign) {
12320
12340
  switch (style.textAlign) {
12321
12341
  case 'left':
12322
12342
  offsetText(drawData, 'x', padding[left]);
12323
12343
  break;
12324
- case 'right':
12325
- offsetText(drawData, 'x', -padding[right]);
12344
+ case 'right': offsetText(drawData, 'x', -padding[right]);
12326
12345
  }
12327
12346
  }
12328
- if (!height) {
12347
+ if (!height && style.autoSizeAlign) {
12329
12348
  switch (style.verticalAlign) {
12330
12349
  case 'top':
12331
12350
  offsetText(drawData, 'y', padding[top]);
12332
12351
  break;
12333
- case 'bottom':
12334
- offsetText(drawData, 'y', -padding[bottom]);
12352
+ case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
12335
12353
  }
12336
12354
  }
12337
12355
  }