@leafer-ui/miniapp 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.
@@ -4483,15 +4483,16 @@ class LeafLayout {
4483
4483
  }
4484
4484
  getLayoutBounds(type, relative = 'world', unscale) {
4485
4485
  const { leaf } = this;
4486
- let point, matrix, bounds = this.getInnerBounds(type);
4486
+ let point, matrix, layoutBounds, bounds = this.getInnerBounds(type);
4487
4487
  switch (relative) {
4488
4488
  case 'world':
4489
4489
  point = leaf.getWorldPoint(bounds);
4490
4490
  matrix = leaf.__world;
4491
4491
  break;
4492
4492
  case 'local':
4493
+ const { scaleX, scaleY, rotation, skewX, skewY } = leaf.__;
4494
+ layoutBounds = { scaleX, scaleY, rotation, skewX, skewY };
4493
4495
  point = leaf.getLocalPointByInner(bounds);
4494
- matrix = leaf.__localMatrix;
4495
4496
  break;
4496
4497
  case 'inner':
4497
4498
  point = bounds;
@@ -4503,7 +4504,8 @@ class LeafLayout {
4503
4504
  point = leaf.getWorldPoint(bounds, relative);
4504
4505
  matrix = getRelativeWorld$1(leaf, relative, true);
4505
4506
  }
4506
- const layoutBounds = MatrixHelper.getLayout(matrix);
4507
+ if (!layoutBounds)
4508
+ layoutBounds = MatrixHelper.getLayout(matrix);
4507
4509
  copy$6(layoutBounds, bounds);
4508
4510
  PointHelper.copy(layoutBounds, point);
4509
4511
  if (unscale) {
@@ -4753,6 +4755,7 @@ class RenderEvent extends Event {
4753
4755
  }
4754
4756
  }
4755
4757
  RenderEvent.REQUEST = 'render.request';
4758
+ RenderEvent.CHILD_START = 'render.child_start';
4756
4759
  RenderEvent.START = 'render.start';
4757
4760
  RenderEvent.BEFORE = 'render.before';
4758
4761
  RenderEvent.RENDER = 'render';
@@ -4928,7 +4931,7 @@ const { isFinite } = Number;
4928
4931
  const debug$7 = Debug.get('setAttr');
4929
4932
  const LeafDataProxy = {
4930
4933
  __setAttr(name, newValue, checkFiniteNumber) {
4931
- if (this.leafer && this.leafer.created) {
4934
+ if (this.leaferIsCreated) {
4932
4935
  const oldValue = this.__.__getInput(name);
4933
4936
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4934
4937
  debug$7.warn(this.innerName, name, newValue);
@@ -5000,7 +5003,7 @@ const LeafMatrix = {
5000
5003
 
5001
5004
  const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
5002
5005
  const { updateBounds: updateBounds$1 } = BranchHelper;
5003
- const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$5 } = BoundsHelper;
5006
+ const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
5004
5007
  const { toBounds: toBounds$2 } = PathBounds;
5005
5008
  const LeafBounds = {
5006
5009
  __updateWorldBounds() {
@@ -5083,7 +5086,7 @@ const LeafBounds = {
5083
5086
  const b = this.__layout.boxBounds;
5084
5087
  const data = this.__;
5085
5088
  if (data.__pathInputed) {
5086
- toBounds$2(data.__pathForRender, b);
5089
+ toBounds$2(data.path, b);
5087
5090
  }
5088
5091
  else {
5089
5092
  b.x = 0;
@@ -5095,7 +5098,7 @@ const LeafBounds = {
5095
5098
  __updateAutoLayout() {
5096
5099
  this.__layout.matrixChanged = true;
5097
5100
  if (this.isBranch) {
5098
- if (this.leafer && this.leafer.ready)
5101
+ if (this.leaferIsReady)
5099
5102
  this.leafer.layouter.addExtra(this);
5100
5103
  if (this.__.flow) {
5101
5104
  if (this.__layout.boxChanged)
@@ -5121,11 +5124,11 @@ const LeafBounds = {
5121
5124
  },
5122
5125
  __updateStrokeBounds() {
5123
5126
  const layout = this.__layout;
5124
- copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5127
+ copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5125
5128
  },
5126
5129
  __updateRenderBounds() {
5127
5130
  const layout = this.__layout;
5128
- layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
5131
+ layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
5129
5132
  }
5130
5133
  };
5131
5134
 
@@ -5230,6 +5233,8 @@ let Leaf = class Leaf {
5230
5233
  get innerName() { return this.__.name || this.tag + this.innerId; }
5231
5234
  get __DataProcessor() { return LeafData; }
5232
5235
  get __LayoutProcessor() { return LeafLayout; }
5236
+ get leaferIsCreated() { return this.leafer && this.leafer.created; }
5237
+ get leaferIsReady() { return this.leafer && this.leafer.ready; }
5233
5238
  get isLeafer() { return false; }
5234
5239
  get isBranch() { return false; }
5235
5240
  get isBranchLeaf() { return false; }
@@ -5671,6 +5676,7 @@ let Branch = class Branch extends Leaf {
5671
5676
  add(child, index) {
5672
5677
  if (child === this)
5673
5678
  return;
5679
+ child.__ || (child = UICreator.get(child.tag, child));
5674
5680
  if (child.parent)
5675
5681
  child.parent.remove(child);
5676
5682
  child.parent = this;
@@ -5693,10 +5699,14 @@ let Branch = class Branch extends Leaf {
5693
5699
  }
5694
5700
  remove(child, destroy) {
5695
5701
  if (child) {
5696
- if (child.animationOut)
5697
- child.__runAnimation('out', () => this.__remove(child, destroy));
5702
+ if (child.__) {
5703
+ if (child.animationOut)
5704
+ child.__runAnimation('out', () => this.__remove(child, destroy));
5705
+ else
5706
+ this.__remove(child, destroy);
5707
+ }
5698
5708
  else
5699
- this.__remove(child, destroy);
5709
+ this.find(child).forEach(item => this.remove(item, destroy));
5700
5710
  }
5701
5711
  else if (child === undefined) {
5702
5712
  super.remove(null, destroy);
@@ -5914,7 +5924,7 @@ class LeafLevelList {
5914
5924
  }
5915
5925
  }
5916
5926
 
5917
- const version = "1.0.3";
5927
+ const version = "1.0.5";
5918
5928
 
5919
5929
  class LeaferCanvas extends LeaferCanvasBase {
5920
5930
  get allowBackgroundColor() { return false; }
@@ -6520,6 +6530,7 @@ class Renderer {
6520
6530
  this.totalBounds = new Bounds();
6521
6531
  debug$5.log(target.innerName, '--->');
6522
6532
  try {
6533
+ target.app.emit(RenderEvent.CHILD_START, target);
6523
6534
  this.emitRender(RenderEvent.START);
6524
6535
  this.renderOnce(callback);
6525
6536
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -6817,7 +6828,7 @@ class Picker {
6817
6828
  if (child.isBranch) {
6818
6829
  if (hit || child.__ignoreHitWorld) {
6819
6830
  this.eachFind(child.children, child.__onlyHitMask);
6820
- if (child.isBranchLeaf && !this.findList.length)
6831
+ if (child.isBranchLeaf)
6821
6832
  this.hitChild(child, point);
6822
6833
  }
6823
6834
  }
@@ -7527,12 +7538,7 @@ let UI = UI_1 = class UI extends Leaf {
7527
7538
  this.__drawPathByData(canvas, this.__.path);
7528
7539
  }
7529
7540
  __drawPathByData(drawer, data) {
7530
- if (data) {
7531
- PathDrawer.drawPathByData(drawer, data);
7532
- }
7533
- else {
7534
- this.__drawPathByBox(drawer);
7535
- }
7541
+ data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
7536
7542
  }
7537
7543
  __drawPathByBox(drawer) {
7538
7544
  const { x, y, width, height } = this.__layout.boxBounds;
@@ -7540,9 +7546,8 @@ let UI = UI_1 = class UI extends Leaf {
7540
7546
  const { cornerRadius } = this.__;
7541
7547
  drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7542
7548
  }
7543
- else {
7549
+ else
7544
7550
  drawer.rect(x, y, width, height);
7545
- }
7546
7551
  }
7547
7552
  animate(_keyframe, _options, _type, _isTemp) {
7548
7553
  return needPlugin('animate');
@@ -7551,10 +7556,10 @@ let UI = UI_1 = class UI extends Leaf {
7551
7556
  export(filename, options) {
7552
7557
  return Export.export(this, filename, options);
7553
7558
  }
7554
- clone(newData) {
7559
+ clone(data) {
7555
7560
  const json = this.toJSON();
7556
- if (newData)
7557
- Object.assign(json, newData);
7561
+ if (data)
7562
+ Object.assign(json, data);
7558
7563
  return UI_1.one(json);
7559
7564
  }
7560
7565
  static one(data, x, y, width, height) {
@@ -8225,10 +8230,9 @@ Rect = __decorate([
8225
8230
  registerUI()
8226
8231
  ], Rect);
8227
8232
 
8228
- const rect$1 = Rect.prototype;
8229
- const group$1 = Group.prototype;
8233
+ const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
8234
+ const rect$1 = Rect.prototype, group$1 = Group.prototype;
8230
8235
  const childrenRenderBounds = {};
8231
- const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
8232
8236
  let Box = class Box extends Group {
8233
8237
  get __tag() { return 'Box'; }
8234
8238
  get isBranchLeaf() { return true; }
@@ -8242,29 +8246,27 @@ let Box = class Box extends Group {
8242
8246
  return this.__updateRectRenderSpread() || -1;
8243
8247
  }
8244
8248
  __updateRectBoxBounds() { }
8245
- __updateBoxBounds(secondLayout) {
8249
+ __updateBoxBounds(_secondLayout) {
8246
8250
  const data = this.__;
8247
8251
  if (this.children.length) {
8248
8252
  if (data.__autoSide) {
8249
- if (this.leafer && this.leafer.ready)
8250
- this.leafer.layouter.addExtra(this);
8251
8253
  super.__updateBoxBounds();
8252
8254
  const { boxBounds } = this.__layout;
8253
8255
  if (!data.__autoSize) {
8254
- if (data.__autoWidth)
8255
- boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
8256
- else
8257
- boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
8256
+ if (data.__autoWidth) {
8257
+ boxBounds.width += boxBounds.x, boxBounds.x = 0;
8258
+ boxBounds.height = data.height, boxBounds.y = 0;
8259
+ }
8260
+ else {
8261
+ boxBounds.height += boxBounds.y, boxBounds.y = 0;
8262
+ boxBounds.width = data.width, boxBounds.x = 0;
8263
+ }
8258
8264
  }
8259
- if (secondLayout && data.flow && data.padding)
8260
- copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
8261
8265
  this.__updateNaturalSize();
8262
8266
  }
8263
8267
  else {
8264
8268
  this.__updateRectBoxBounds();
8265
8269
  }
8266
- if (data.flow)
8267
- this.__updateContentBounds();
8268
8270
  }
8269
8271
  else {
8270
8272
  this.__updateRectBoxBounds();
@@ -8330,6 +8332,9 @@ __decorate([
8330
8332
  __decorate([
8331
8333
  dataType(false)
8332
8334
  ], Box.prototype, "resizeChildren", void 0);
8335
+ __decorate([
8336
+ dataType(false)
8337
+ ], Box.prototype, "textBox", void 0);
8333
8338
  __decorate([
8334
8339
  affectRenderBoundsType('show')
8335
8340
  ], Box.prototype, "overflow", void 0);
@@ -8859,6 +8864,9 @@ __decorate([
8859
8864
  __decorate([
8860
8865
  boundsType('top')
8861
8866
  ], Text.prototype, "verticalAlign", void 0);
8867
+ __decorate([
8868
+ boundsType(true)
8869
+ ], Text.prototype, "autoSizeAlign", void 0);
8862
8870
  __decorate([
8863
8871
  boundsType('normal')
8864
8872
  ], Text.prototype, "textWrap", void 0);
@@ -9579,9 +9587,10 @@ class Dragger {
9579
9587
  this.dragData = getDragEventData(data, data, data);
9580
9588
  this.canAnimate = this.canDragOut = true;
9581
9589
  }
9582
- getList() {
9590
+ getList(realDraggable, hover) {
9583
9591
  const { proxy } = this.interaction.selector;
9584
- return this.dragging && (!proxy || !proxy.list.length) ? (DragEvent.list || this.dragableList || emptyList) : emptyList;
9592
+ const hasProxyList = proxy && proxy.list.length, dragList = DragEvent.list || this.draggableList || emptyList;
9593
+ return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList);
9585
9594
  }
9586
9595
  checkDrag(data, canDrag) {
9587
9596
  const { interaction } = this;
@@ -9606,8 +9615,8 @@ class Dragger {
9606
9615
  this.dragging = canDrag && PointerButton.left(data);
9607
9616
  if (this.dragging) {
9608
9617
  this.interaction.emit(DragEvent.START, this.dragData);
9609
- this.getDragableList(this.dragData.path);
9610
- this.setDragStartPoints(this.realDragableList = this.getList());
9618
+ this.getDraggableList(this.dragData.path);
9619
+ this.setDragStartPoints(this.realDraggableList = this.getList(true));
9611
9620
  }
9612
9621
  }
9613
9622
  }
@@ -9615,12 +9624,12 @@ class Dragger {
9615
9624
  this.dragStartPoints = {};
9616
9625
  list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9617
9626
  }
9618
- getDragableList(path) {
9627
+ getDraggableList(path) {
9619
9628
  let leaf;
9620
9629
  for (let i = 0, len = path.length; i < len; i++) {
9621
9630
  leaf = path.list[i];
9622
- if ((leaf.__.draggable || leaf.__.editable) && leaf.__.hitSelf && !leaf.__.locked) {
9623
- this.dragableList = new LeafList(leaf);
9631
+ if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
9632
+ this.draggableList = new LeafList(leaf);
9624
9633
  break;
9625
9634
  }
9626
9635
  }
@@ -9645,7 +9654,7 @@ class Dragger {
9645
9654
  }
9646
9655
  dragReal() {
9647
9656
  const { running } = this.interaction;
9648
- const list = this.realDragableList;
9657
+ const list = this.realDraggableList;
9649
9658
  if (list.length && running) {
9650
9659
  const { totalX, totalY } = this.dragData;
9651
9660
  list.forEach(leaf => leaf.draggable && leaf.move(DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
@@ -9734,7 +9743,7 @@ class Dragger {
9734
9743
  this.interaction.emit(DragEvent.LEAVE, data, dragEnterPath);
9735
9744
  }
9736
9745
  dragReset() {
9737
- DragEvent.list = DragEvent.data = this.dragableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9746
+ DragEvent.list = DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9738
9747
  }
9739
9748
  checkDragOut(data) {
9740
9749
  const { interaction } = this;
@@ -9875,6 +9884,7 @@ const config = {
9875
9884
  touch: {
9876
9885
  preventDefault: true
9877
9886
  },
9887
+ multiTouch: {},
9878
9888
  cursor: true,
9879
9889
  keyEvent: true
9880
9890
  };
@@ -10001,6 +10011,8 @@ class InteractionBase {
10001
10011
  this.pointerUp(data);
10002
10012
  }
10003
10013
  multiTouch(data, list) {
10014
+ if (this.config.multiTouch.disabled)
10015
+ return;
10004
10016
  const { move, angle, scale, center } = MultiTouchHelper.getData(list);
10005
10017
  this.rotate(getRotateEventData(center, angle, data));
10006
10018
  this.zoom(getZoomEventData(center, scale, data));
@@ -10190,7 +10202,7 @@ class InteractionBase {
10190
10202
  data = this.hoverData;
10191
10203
  if (!data)
10192
10204
  return;
10193
- this.findPath(data, { exclude: this.dragger.getList(), name: PointerEvent.MOVE });
10205
+ this.findPath(data, { exclude: this.dragger.getList(false, true), name: PointerEvent.MOVE });
10194
10206
  this.hoverData = data;
10195
10207
  }
10196
10208
  updateCursor(data) {
@@ -10212,7 +10224,7 @@ class InteractionBase {
10212
10224
  const { path } = data;
10213
10225
  for (let i = 0, len = path.length; i < len; i++) {
10214
10226
  leaf = path.list[i];
10215
- cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
10227
+ cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor;
10216
10228
  if (cursor)
10217
10229
  break;
10218
10230
  }
@@ -10394,7 +10406,7 @@ ui$2.__updateHitCanvas = function () {
10394
10406
  if (isHitPixel) {
10395
10407
  const { renderBounds } = this.__layout;
10396
10408
  const size = Platform.image.hitCanvasSize;
10397
- const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds, 0.5).a;
10409
+ const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10398
10410
  const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
10399
10411
  h.resize({ width, height, pixelRatio: 1 });
10400
10412
  h.clear();
@@ -10450,15 +10462,14 @@ ui$2.__hit = function (inner) {
10450
10462
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
10451
10463
  };
10452
10464
 
10453
- const ui$1 = new UI();
10454
- const rect = Rect.prototype;
10455
- rect.__updateHitCanvas = function () {
10465
+ const ui$1 = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
10466
+ rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
10456
10467
  if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
10457
10468
  ui$1.__updateHitCanvas.call(this);
10458
10469
  else if (this.__hitCanvas)
10459
10470
  this.__hitCanvas = null;
10460
10471
  };
10461
- rect.__hitFill = function (inner) {
10472
+ rect.__hitFill = box$1.__hitFill = function (inner) {
10462
10473
  return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10463
10474
  };
10464
10475
 
@@ -11062,9 +11073,10 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11062
11073
  onLoadError(ui, event, image.error);
11063
11074
  }
11064
11075
  else {
11065
- ignoreRender(ui, true);
11066
- if (firstUse)
11076
+ if (firstUse) {
11077
+ ignoreRender(ui, true);
11067
11078
  onLoad(ui, event);
11079
+ }
11068
11080
  leafPaint.loadId = image.load(() => {
11069
11081
  ignoreRender(ui, false);
11070
11082
  if (!ui.destroyed) {
@@ -11676,11 +11688,12 @@ const { trimRight } = TextRowHelper;
11676
11688
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
11677
11689
  let word, row, wordWidth, rowWidth, realWidth;
11678
11690
  let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
11679
- let textDrawData, rows = [], bounds;
11691
+ let textDrawData, rows = [], bounds, findMaxWidth;
11680
11692
  function createRows(drawData, content, style) {
11681
11693
  textDrawData = drawData;
11682
11694
  rows = drawData.rows;
11683
11695
  bounds = drawData.bounds;
11696
+ findMaxWidth = !bounds.width && !style.autoSizeAlign;
11684
11697
  const { __letterSpacing, paraIndent, textCase } = style;
11685
11698
  const { canvas } = Platform;
11686
11699
  const { width, height } = bounds;
@@ -11765,7 +11778,10 @@ function createRows(drawData, content, style) {
11765
11778
  else {
11766
11779
  content.split('\n').forEach(content => {
11767
11780
  textDrawData.paraNumber++;
11768
- rows.push({ x: paraIndent || 0, text: content, width: canvas.measureText(content).width, paraStart: true });
11781
+ rowWidth = canvas.measureText(content).width;
11782
+ rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
11783
+ if (findMaxWidth)
11784
+ setMaxWidth();
11769
11785
  });
11770
11786
  }
11771
11787
  }
@@ -11796,10 +11812,16 @@ function addRow() {
11796
11812
  row.width = rowWidth;
11797
11813
  if (bounds.width)
11798
11814
  trimRight(row);
11815
+ else if (findMaxWidth)
11816
+ setMaxWidth();
11799
11817
  rows.push(row);
11800
11818
  row = { words: [] };
11801
11819
  rowWidth = 0;
11802
11820
  }
11821
+ function setMaxWidth() {
11822
+ if (rowWidth > (textDrawData.maxWidth || 0))
11823
+ textDrawData.maxWidth = rowWidth;
11824
+ }
11803
11825
 
11804
11826
  const CharMode = 0;
11805
11827
  const WordMode = 1;
@@ -11871,34 +11893,32 @@ function toChar(data, charX, rowData, isOverflow) {
11871
11893
 
11872
11894
  function layoutText(drawData, style) {
11873
11895
  const { rows, bounds } = drawData;
11874
- const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
11896
+ const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
11875
11897
  let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11876
11898
  let starY = __baseLine;
11877
11899
  if (__clipText && realHeight > height) {
11878
11900
  realHeight = Math.max(height, __lineHeight);
11879
11901
  drawData.overflow = rows.length;
11880
11902
  }
11881
- else {
11903
+ else if (height || autoSizeAlign) {
11882
11904
  switch (verticalAlign) {
11883
11905
  case 'middle':
11884
11906
  y += (height - realHeight) / 2;
11885
11907
  break;
11886
- case 'bottom':
11887
- y += (height - realHeight);
11908
+ case 'bottom': y += (height - realHeight);
11888
11909
  }
11889
11910
  }
11890
11911
  starY += y;
11891
- let row, rowX, rowWidth;
11912
+ let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
11892
11913
  for (let i = 0, len = rows.length; i < len; i++) {
11893
11914
  row = rows[i];
11894
11915
  row.x = x;
11895
11916
  if (row.width < width || (row.width > width && !__clipText)) {
11896
11917
  switch (textAlign) {
11897
11918
  case 'center':
11898
- row.x += (width - row.width) / 2;
11919
+ row.x += (layoutWidth - row.width) / 2;
11899
11920
  break;
11900
- case 'right':
11901
- row.x += width - row.width;
11921
+ case 'right': row.x += layoutWidth - row.width;
11902
11922
  }
11903
11923
  }
11904
11924
  if (row.paraStart && paraSpacing && i > 0)
@@ -12003,14 +12023,14 @@ function getDrawData(content, style) {
12003
12023
  let height = style.__getInput('height') || 0;
12004
12024
  const { textDecoration, __font, __padding: padding } = style;
12005
12025
  if (padding) {
12006
- if (width) {
12026
+ if (width)
12027
+ x = padding[left], width -= (padding[right] + padding[left]);
12028
+ else if (!style.autoSizeAlign)
12007
12029
  x = padding[left];
12008
- width -= (padding[right] + padding[left]);
12009
- }
12010
- if (height) {
12030
+ if (height)
12031
+ y = padding[top], height -= (padding[top] + padding[bottom]);
12032
+ else if (!style.autoSizeAlign)
12011
12033
  y = padding[top];
12012
- height -= (padding[top] + padding[bottom]);
12013
- }
12014
12034
  }
12015
12035
  const drawData = {
12016
12036
  bounds: { x, y, width, height },
@@ -12030,22 +12050,20 @@ function getDrawData(content, style) {
12030
12050
  return drawData;
12031
12051
  }
12032
12052
  function padAutoText(padding, drawData, style, width, height) {
12033
- if (!width) {
12053
+ if (!width && style.autoSizeAlign) {
12034
12054
  switch (style.textAlign) {
12035
12055
  case 'left':
12036
12056
  offsetText(drawData, 'x', padding[left]);
12037
12057
  break;
12038
- case 'right':
12039
- offsetText(drawData, 'x', -padding[right]);
12058
+ case 'right': offsetText(drawData, 'x', -padding[right]);
12040
12059
  }
12041
12060
  }
12042
- if (!height) {
12061
+ if (!height && style.autoSizeAlign) {
12043
12062
  switch (style.verticalAlign) {
12044
12063
  case 'top':
12045
12064
  offsetText(drawData, 'y', padding[top]);
12046
12065
  break;
12047
- case 'bottom':
12048
- offsetText(drawData, 'y', -padding[bottom]);
12066
+ case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
12049
12067
  }
12050
12068
  }
12051
12069
  }