@leafer-ui/miniapp 1.0.4 → 1.0.6

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.
@@ -552,6 +552,12 @@ const PointHelper = {
552
552
  to.y = t.y + sin$4(r) * distance;
553
553
  return to;
554
554
  },
555
+ toNumberPoints(originPoints) {
556
+ let points = originPoints;
557
+ if (typeof originPoints[0] === 'object')
558
+ points = [], originPoints.forEach(p => points.push(p.x, p.y));
559
+ return points;
560
+ },
555
561
  reset(t) {
556
562
  P$5.reset(t);
557
563
  }
@@ -1542,7 +1548,10 @@ const { assign } = DataHelper;
1542
1548
 
1543
1549
  class LeafData {
1544
1550
  get __useNaturalRatio() { return true; }
1545
- get __isLinePath() { return this.path && this.path.length === 6; }
1551
+ get __isLinePath() {
1552
+ const { path } = this;
1553
+ return path && path.length === 6 && path[0] === 1;
1554
+ }
1546
1555
  get __blendMode() {
1547
1556
  if (this.eraser && this.eraser !== 'path')
1548
1557
  return 'destination-out';
@@ -2305,11 +2314,12 @@ const RectHelper = {
2305
2314
 
2306
2315
  const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2307
2316
  const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2308
- const { set } = PointHelper;
2317
+ const { set, toNumberPoints } = PointHelper;
2309
2318
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
2310
2319
  const tempPoint$2 = {};
2311
2320
  const BezierHelper = {
2312
- points(data, points, curve, close) {
2321
+ points(data, originPoints, curve, close) {
2322
+ let points = toNumberPoints(originPoints);
2313
2323
  data.push(M$5, points[0], points[1]);
2314
2324
  if (curve && points.length > 5) {
2315
2325
  let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
@@ -2818,6 +2828,27 @@ const PathConvert = {
2818
2828
  }
2819
2829
  return data;
2820
2830
  },
2831
+ objectToCanvasData(list) {
2832
+ const data = [];
2833
+ list.forEach(item => {
2834
+ switch (item.name) {
2835
+ case 'M':
2836
+ data.push(M$4, item.x, item.y);
2837
+ break;
2838
+ case 'L':
2839
+ data.push(L$5, item.x, item.y);
2840
+ break;
2841
+ case 'C':
2842
+ data.push(C$4, item.x1, item.y1, item.x2, item.y2, item.x, item.y);
2843
+ break;
2844
+ case 'Q':
2845
+ data.push(Q$3, item.x1, item.y1, item.x, item.y);
2846
+ break;
2847
+ case 'Z': data.push(Z$4);
2848
+ }
2849
+ });
2850
+ return data;
2851
+ },
2821
2852
  copyData(data, old, index, count) {
2822
2853
  for (let i = index, end = index + count; i < end; i++) {
2823
2854
  data.push(old[i]);
@@ -4755,6 +4786,7 @@ class RenderEvent extends Event {
4755
4786
  }
4756
4787
  }
4757
4788
  RenderEvent.REQUEST = 'render.request';
4789
+ RenderEvent.CHILD_START = 'render.child_start';
4758
4790
  RenderEvent.START = 'render.start';
4759
4791
  RenderEvent.BEFORE = 'render.before';
4760
4792
  RenderEvent.RENDER = 'render';
@@ -4930,7 +4962,7 @@ const { isFinite } = Number;
4930
4962
  const debug$7 = Debug.get('setAttr');
4931
4963
  const LeafDataProxy = {
4932
4964
  __setAttr(name, newValue, checkFiniteNumber) {
4933
- if (this.leafer && this.leafer.created) {
4965
+ if (this.leaferIsCreated) {
4934
4966
  const oldValue = this.__.__getInput(name);
4935
4967
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4936
4968
  debug$7.warn(this.innerName, name, newValue);
@@ -5002,7 +5034,7 @@ const LeafMatrix = {
5002
5034
 
5003
5035
  const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
5004
5036
  const { updateBounds: updateBounds$1 } = BranchHelper;
5005
- const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$5 } = BoundsHelper;
5037
+ const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
5006
5038
  const { toBounds: toBounds$2 } = PathBounds;
5007
5039
  const LeafBounds = {
5008
5040
  __updateWorldBounds() {
@@ -5085,7 +5117,7 @@ const LeafBounds = {
5085
5117
  const b = this.__layout.boxBounds;
5086
5118
  const data = this.__;
5087
5119
  if (data.__pathInputed) {
5088
- toBounds$2(data.__pathForRender, b);
5120
+ toBounds$2(data.path, b);
5089
5121
  }
5090
5122
  else {
5091
5123
  b.x = 0;
@@ -5097,7 +5129,7 @@ const LeafBounds = {
5097
5129
  __updateAutoLayout() {
5098
5130
  this.__layout.matrixChanged = true;
5099
5131
  if (this.isBranch) {
5100
- if (this.leafer && this.leafer.ready)
5132
+ if (this.leaferIsReady)
5101
5133
  this.leafer.layouter.addExtra(this);
5102
5134
  if (this.__.flow) {
5103
5135
  if (this.__layout.boxChanged)
@@ -5123,11 +5155,11 @@ const LeafBounds = {
5123
5155
  },
5124
5156
  __updateStrokeBounds() {
5125
5157
  const layout = this.__layout;
5126
- copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5158
+ copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5127
5159
  },
5128
5160
  __updateRenderBounds() {
5129
5161
  const layout = this.__layout;
5130
- layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
5162
+ layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
5131
5163
  }
5132
5164
  };
5133
5165
 
@@ -5158,7 +5190,7 @@ const LeafRender = {
5158
5190
  if (this.__worldOpacity) {
5159
5191
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5160
5192
  this.__drawRenderPath(canvas);
5161
- this.__.windingRule ? canvas.clip(this.__.windingRule) : canvas.clip();
5193
+ this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
5162
5194
  }
5163
5195
  },
5164
5196
  __updateWorldOpacity() {
@@ -5232,6 +5264,8 @@ let Leaf = class Leaf {
5232
5264
  get innerName() { return this.__.name || this.tag + this.innerId; }
5233
5265
  get __DataProcessor() { return LeafData; }
5234
5266
  get __LayoutProcessor() { return LeafLayout; }
5267
+ get leaferIsCreated() { return this.leafer && this.leafer.created; }
5268
+ get leaferIsReady() { return this.leafer && this.leafer.ready; }
5235
5269
  get isLeafer() { return false; }
5236
5270
  get isBranch() { return false; }
5237
5271
  get isBranchLeaf() { return false; }
@@ -5673,10 +5707,17 @@ let Branch = class Branch extends Leaf {
5673
5707
  add(child, index) {
5674
5708
  if (child === this)
5675
5709
  return;
5710
+ const noIndex = index === undefined;
5711
+ if (!child.__) {
5712
+ if (child instanceof Array)
5713
+ return child.forEach(item => { this.add(item, index); noIndex || index++; });
5714
+ else
5715
+ child = UICreator.get(child.tag, child);
5716
+ }
5676
5717
  if (child.parent)
5677
5718
  child.parent.remove(child);
5678
5719
  child.parent = this;
5679
- index === undefined ? this.children.push(child) : this.children.splice(index, 0, child);
5720
+ noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
5680
5721
  if (child.isBranch)
5681
5722
  this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
5682
5723
  child.__layout.boxChanged || child.__layout.boxChange();
@@ -5690,15 +5731,17 @@ let Branch = class Branch extends Leaf {
5690
5731
  }
5691
5732
  this.__layout.affectChildrenSort && this.__layout.childrenSortChange();
5692
5733
  }
5693
- addMany(...children) {
5694
- children.forEach(child => this.add(child));
5695
- }
5734
+ addMany(...children) { this.add(children); }
5696
5735
  remove(child, destroy) {
5697
5736
  if (child) {
5698
- if (child.animationOut)
5699
- child.__runAnimation('out', () => this.__remove(child, destroy));
5737
+ if (child.__) {
5738
+ if (child.animationOut)
5739
+ child.__runAnimation('out', () => this.__remove(child, destroy));
5740
+ else
5741
+ this.__remove(child, destroy);
5742
+ }
5700
5743
  else
5701
- this.__remove(child, destroy);
5744
+ this.find(child).forEach(item => this.remove(item, destroy));
5702
5745
  }
5703
5746
  else if (child === undefined) {
5704
5747
  super.remove(null, destroy);
@@ -5916,7 +5959,7 @@ class LeafLevelList {
5916
5959
  }
5917
5960
  }
5918
5961
 
5919
- const version = "1.0.4";
5962
+ const version = "1.0.6";
5920
5963
 
5921
5964
  class LeaferCanvas extends LeaferCanvasBase {
5922
5965
  get allowBackgroundColor() { return false; }
@@ -6522,6 +6565,7 @@ class Renderer {
6522
6565
  this.totalBounds = new Bounds();
6523
6566
  debug$5.log(target.innerName, '--->');
6524
6567
  try {
6568
+ target.app.emit(RenderEvent.CHILD_START, target);
6525
6569
  this.emitRender(RenderEvent.START);
6526
6570
  this.renderOnce(callback);
6527
6571
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -6819,7 +6863,7 @@ class Picker {
6819
6863
  if (child.isBranch) {
6820
6864
  if (hit || child.__ignoreHitWorld) {
6821
6865
  this.eachFind(child.children, child.__onlyHitMask);
6822
- if (child.isBranchLeaf && !this.findList.length)
6866
+ if (child.isBranchLeaf)
6823
6867
  this.hitChild(child, point);
6824
6868
  }
6825
6869
  }
@@ -7032,6 +7076,13 @@ function zoomLayerType() {
7032
7076
 
7033
7077
  const TextConvert = {};
7034
7078
  const ColorConvert = {};
7079
+ const UnitConvert = {
7080
+ number(value, percentRefer) {
7081
+ if (typeof value === 'object')
7082
+ return value.type === 'percent' ? value.value * percentRefer : value.value;
7083
+ return value;
7084
+ }
7085
+ };
7035
7086
  const PathArrow = {};
7036
7087
  const Paint = {};
7037
7088
  const PaintImage = {};
@@ -7052,7 +7103,7 @@ const Transition = {
7052
7103
  }
7053
7104
  };
7054
7105
 
7055
- const { parse } = PathConvert;
7106
+ const { parse, objectToCanvasData } = PathConvert;
7056
7107
  const emptyPaint = {};
7057
7108
  const debug$4 = Debug.get('UIData');
7058
7109
  class UIData extends LeafData {
@@ -7066,10 +7117,11 @@ class UIData extends LeafData {
7066
7117
  scaleX = -scaleX;
7067
7118
  return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
7068
7119
  }
7069
- else {
7120
+ else
7070
7121
  return strokeWidth;
7071
- }
7072
7122
  }
7123
+ get __hasStroke() { return this.stroke && this.strokeWidth; }
7124
+ get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
7073
7125
  get __autoWidth() { return !this._width; }
7074
7126
  get __autoHeight() { return !this._height; }
7075
7127
  get __autoSide() { return !this._width || !this._height; }
@@ -7086,9 +7138,8 @@ class UIData extends LeafData {
7086
7138
  this.__leaf.scaleX *= -1;
7087
7139
  debug$4.warn('width < 0, instead -scaleX ', this);
7088
7140
  }
7089
- else {
7141
+ else
7090
7142
  this._width = value;
7091
- }
7092
7143
  }
7093
7144
  setHeight(value) {
7094
7145
  if (value < 0) {
@@ -7096,9 +7147,8 @@ class UIData extends LeafData {
7096
7147
  this.__leaf.scaleY *= -1;
7097
7148
  debug$4.warn('height < 0, instead -scaleY', this);
7098
7149
  }
7099
- else {
7150
+ else
7100
7151
  this._height = value;
7101
- }
7102
7152
  }
7103
7153
  setFill(value) {
7104
7154
  if (this.__naturalWidth)
@@ -7139,9 +7189,10 @@ class UIData extends LeafData {
7139
7189
  }
7140
7190
  }
7141
7191
  setPath(value) {
7142
- if (typeof value === 'string') {
7192
+ const isString = typeof value === 'string';
7193
+ if (isString || (value && typeof value[0] === 'object')) {
7143
7194
  this.__setInput('path', value);
7144
- this._path = parse(value);
7195
+ this._path = isString ? parse(value) : objectToCanvasData(value);
7145
7196
  }
7146
7197
  else {
7147
7198
  if (this.__input)
@@ -7156,12 +7207,8 @@ class UIData extends LeafData {
7156
7207
  value = value.filter((item) => item.visible !== false);
7157
7208
  this._shadow = value.length ? value : null;
7158
7209
  }
7159
- else if (value) {
7160
- this._shadow = value.visible === false ? null : [value];
7161
- }
7162
- else {
7163
- this._shadow = null;
7164
- }
7210
+ else
7211
+ this._shadow = value && value.visible !== false ? [value] : null;
7165
7212
  }
7166
7213
  setInnerShadow(value) {
7167
7214
  this.__setInput('innerShadow', value);
@@ -7170,12 +7217,8 @@ class UIData extends LeafData {
7170
7217
  value = value.filter((item) => item.visible !== false);
7171
7218
  this._innerShadow = value.length ? value : null;
7172
7219
  }
7173
- else if (value) {
7174
- this._innerShadow = value.visible === false ? null : [value];
7175
- }
7176
- else {
7177
- this._innerShadow = null;
7178
- }
7220
+ else
7221
+ this._innerShadow = value && value.visible !== false ? [value] : null;
7179
7222
  }
7180
7223
  __computePaint() {
7181
7224
  const { fill, stroke } = this.__input;
@@ -7186,24 +7229,19 @@ class UIData extends LeafData {
7186
7229
  this.__needComputePaint = false;
7187
7230
  }
7188
7231
  }
7189
- const UnitConvert = {
7190
- number(value, percentRefer) {
7191
- if (typeof value === 'object')
7192
- return value.type === 'percent' ? value.value * percentRefer : value.value;
7193
- return value;
7194
- }
7195
- };
7196
7232
 
7197
7233
  class GroupData extends UIData {
7198
7234
  }
7199
7235
 
7200
7236
  class BoxData extends GroupData {
7201
7237
  get __boxStroke() { return !this.__pathInputed; }
7238
+ get __drawAfterFill() { return this.overflow === 'hide' && this.__clipAfterFill && this.__leaf.children.length; }
7239
+ get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
7202
7240
  }
7203
7241
 
7204
7242
  class LeaferData extends GroupData {
7205
- __getInputData() {
7206
- const data = super.__getInputData();
7243
+ __getInputData(names, options) {
7244
+ const data = super.__getInputData(names, options);
7207
7245
  canvasSizeAttrs.forEach(key => delete data[key]);
7208
7246
  return data;
7209
7247
  }
@@ -7230,6 +7268,7 @@ class StarData extends UIData {
7230
7268
  }
7231
7269
 
7232
7270
  class PathData extends UIData {
7271
+ get __pathInputed() { return 2; }
7233
7272
  }
7234
7273
 
7235
7274
  class PenData extends GroupData {
@@ -7276,16 +7315,18 @@ class ImageData extends RectData {
7276
7315
  delete data.fill;
7277
7316
  return data;
7278
7317
  }
7279
- __getInputData() {
7280
- const data = super.__getInputData();
7318
+ __getInputData(names, options) {
7319
+ const data = super.__getInputData(names, options);
7281
7320
  delete data.fill;
7282
7321
  return data;
7283
7322
  }
7284
7323
  }
7285
7324
 
7286
7325
  class CanvasData extends RectData {
7287
- __getInputData() {
7288
- const data = super.__getInputData();
7326
+ get __isCanvas() { return true; }
7327
+ get __drawAfterFill() { return true; }
7328
+ __getInputData(names, options) {
7329
+ const data = super.__getInputData(names, options);
7289
7330
  data.url = this.__leaf.canvas.toDataURL('image/png');
7290
7331
  return data;
7291
7332
  }
@@ -7312,16 +7353,12 @@ const UIBounds = {
7312
7353
  let width = 0;
7313
7354
  const { shadow, innerShadow, blur, backgroundBlur } = this.__;
7314
7355
  if (shadow)
7315
- shadow.forEach(item => {
7316
- width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5);
7317
- });
7356
+ shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
7318
7357
  if (blur)
7319
7358
  width = Math.max(width, blur);
7320
7359
  let shapeWidth = width = Math.ceil(width);
7321
7360
  if (innerShadow)
7322
- innerShadow.forEach(item => {
7323
- shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5);
7324
- });
7361
+ innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
7325
7362
  if (backgroundBlur)
7326
7363
  shapeWidth = Math.max(shapeWidth, backgroundBlur);
7327
7364
  this.__layout.renderShapeSpread = shapeWidth;
@@ -7403,6 +7440,16 @@ const UIRender = {
7403
7440
  if (stroke && !ignoreStroke)
7404
7441
  this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7405
7442
  }
7443
+ },
7444
+ __drawAfterFill(canvas, options) {
7445
+ if (this.__.__clipAfterFill) {
7446
+ canvas.save();
7447
+ this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
7448
+ this.__drawContent(canvas, options);
7449
+ canvas.restore();
7450
+ }
7451
+ else
7452
+ this.__drawContent(canvas, options);
7406
7453
  }
7407
7454
  };
7408
7455
  function drawFast(ui, canvas, options) {
@@ -7469,8 +7516,8 @@ let UI = UI_1 = class UI extends Leaf {
7469
7516
  return pen;
7470
7517
  }
7471
7518
  get editConfig() { return undefined; }
7472
- get editOuter() { return this.__.__isLinePath ? 'LineEditTool' : 'EditTool'; }
7473
- get editInner() { return 'PathEditor'; }
7519
+ get editOuter() { return ''; }
7520
+ get editInner() { return ''; }
7474
7521
  constructor(data) {
7475
7522
  super(data);
7476
7523
  }
@@ -7481,9 +7528,8 @@ let UI = UI_1 = class UI extends Leaf {
7481
7528
  Object.assign(this, data);
7482
7529
  this.lockNormalStyle = false;
7483
7530
  }
7484
- else {
7531
+ else
7485
7532
  Object.assign(this, data);
7486
- }
7487
7533
  }
7488
7534
  get(name) {
7489
7535
  return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -7529,12 +7575,7 @@ let UI = UI_1 = class UI extends Leaf {
7529
7575
  this.__drawPathByData(canvas, this.__.path);
7530
7576
  }
7531
7577
  __drawPathByData(drawer, data) {
7532
- if (data) {
7533
- PathDrawer.drawPathByData(drawer, data);
7534
- }
7535
- else {
7536
- this.__drawPathByBox(drawer);
7537
- }
7578
+ data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
7538
7579
  }
7539
7580
  __drawPathByBox(drawer) {
7540
7581
  const { x, y, width, height } = this.__layout.boxBounds;
@@ -7542,9 +7583,8 @@ let UI = UI_1 = class UI extends Leaf {
7542
7583
  const { cornerRadius } = this.__;
7543
7584
  drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7544
7585
  }
7545
- else {
7586
+ else
7546
7587
  drawer.rect(x, y, width, height);
7547
- }
7548
7588
  }
7549
7589
  animate(_keyframe, _options, _type, _isTemp) {
7550
7590
  return needPlugin('animate');
@@ -7791,23 +7831,13 @@ let Group = class Group extends UI {
7791
7831
  if (data.children) {
7792
7832
  const { children } = data;
7793
7833
  delete data.children;
7794
- if (!this.children) {
7795
- this.__setBranch();
7796
- }
7797
- else {
7798
- this.clear();
7799
- }
7834
+ this.children ? this.clear() : this.__setBranch();
7800
7835
  super.set(data, isTemp);
7801
- let child;
7802
- children.forEach(childData => {
7803
- child = childData.__ ? childData : UICreator.get(childData.tag, childData);
7804
- this.add(child);
7805
- });
7836
+ children.forEach(child => this.add(child));
7806
7837
  data.children = children;
7807
7838
  }
7808
- else {
7839
+ else
7809
7840
  super.set(data, isTemp);
7810
- }
7811
7841
  }
7812
7842
  toJSON(options) {
7813
7843
  const data = super.toJSON(options);
@@ -8227,10 +8257,9 @@ Rect = __decorate([
8227
8257
  registerUI()
8228
8258
  ], Rect);
8229
8259
 
8230
- const rect$1 = Rect.prototype;
8231
- const group$1 = Group.prototype;
8260
+ const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
8261
+ const rect$1 = Rect.prototype, group$1 = Group.prototype;
8232
8262
  const childrenRenderBounds = {};
8233
- const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
8234
8263
  let Box = class Box extends Group {
8235
8264
  get __tag() { return 'Box'; }
8236
8265
  get isBranchLeaf() { return true; }
@@ -8240,37 +8269,31 @@ let Box = class Box extends Group {
8240
8269
  }
8241
8270
  __updateStrokeSpread() { return 0; }
8242
8271
  __updateRectRenderSpread() { return 0; }
8243
- __updateRenderSpread() {
8244
- return this.__updateRectRenderSpread() || -1;
8245
- }
8272
+ __updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
8246
8273
  __updateRectBoxBounds() { }
8247
- __updateBoxBounds(secondLayout) {
8274
+ __updateBoxBounds(_secondLayout) {
8248
8275
  const data = this.__;
8249
8276
  if (this.children.length) {
8250
8277
  if (data.__autoSide) {
8251
- if (this.leafer && this.leafer.ready)
8252
- this.leafer.layouter.addExtra(this);
8253
8278
  super.__updateBoxBounds();
8254
8279
  const { boxBounds } = this.__layout;
8255
8280
  if (!data.__autoSize) {
8256
- if (data.__autoWidth)
8257
- boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
8258
- else
8259
- boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
8281
+ if (data.__autoWidth) {
8282
+ boxBounds.width += boxBounds.x, boxBounds.x = 0;
8283
+ boxBounds.height = data.height, boxBounds.y = 0;
8284
+ }
8285
+ else {
8286
+ boxBounds.height += boxBounds.y, boxBounds.y = 0;
8287
+ boxBounds.width = data.width, boxBounds.x = 0;
8288
+ }
8260
8289
  }
8261
- if (secondLayout && data.flow && data.padding)
8262
- copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
8263
8290
  this.__updateNaturalSize();
8264
8291
  }
8265
- else {
8292
+ else
8266
8293
  this.__updateRectBoxBounds();
8267
- }
8268
- if (data.flow)
8269
- this.__updateContentBounds();
8270
8294
  }
8271
- else {
8295
+ else
8272
8296
  this.__updateRectBoxBounds();
8273
- }
8274
8297
  }
8275
8298
  __updateStrokeBounds() { }
8276
8299
  __updateRenderBounds() {
@@ -8280,14 +8303,13 @@ let Box = class Box extends Group {
8280
8303
  super.__updateRenderBounds();
8281
8304
  copy$3(childrenRenderBounds, renderBounds);
8282
8305
  this.__updateRectRenderBounds();
8283
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
8306
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8307
+ if (isOverflow && this.__.overflow !== 'hide')
8308
+ add(renderBounds, childrenRenderBounds);
8284
8309
  }
8285
- else {
8310
+ else
8286
8311
  this.__updateRectRenderBounds();
8287
- }
8288
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8289
- if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
8290
- add(renderBounds, childrenRenderBounds);
8312
+ !this.isOverflow !== !isOverflow && (this.isOverflow = isOverflow);
8291
8313
  }
8292
8314
  __updateRectRenderBounds() { }
8293
8315
  __updateRectChange() { }
@@ -8307,20 +8329,9 @@ let Box = class Box extends Group {
8307
8329
  this.__renderGroup(canvas, options);
8308
8330
  }
8309
8331
  }
8310
- __drawAfterFill(canvas, options) {
8311
- const { length } = this.children;
8312
- if (this.isOverflow) {
8313
- canvas.save();
8314
- canvas.clip();
8315
- if (length)
8316
- this.__renderGroup(canvas, options);
8317
- canvas.restore();
8318
- }
8319
- else {
8320
- if (length)
8321
- this.__renderGroup(canvas, options);
8322
- }
8323
- if (this.__.stroke && length) {
8332
+ __drawContent(canvas, options) {
8333
+ this.__renderGroup(canvas, options);
8334
+ if (this.__.__hasStroke) {
8324
8335
  canvas.setWorld(this.__nowWorld);
8325
8336
  this.__drawRenderPath(canvas);
8326
8337
  }
@@ -8332,6 +8343,9 @@ __decorate([
8332
8343
  __decorate([
8333
8344
  dataType(false)
8334
8345
  ], Box.prototype, "resizeChildren", void 0);
8346
+ __decorate([
8347
+ dataType(false)
8348
+ ], Box.prototype, "textBox", void 0);
8335
8349
  __decorate([
8336
8350
  affectRenderBoundsType('show')
8337
8351
  ], Box.prototype, "overflow", void 0);
@@ -8481,17 +8495,15 @@ let Line = class Line extends UI {
8481
8495
  if (data.__useArrow)
8482
8496
  PathArrow.addArrows(this, false);
8483
8497
  }
8484
- else {
8498
+ else
8485
8499
  super.__updateRenderPath();
8486
- }
8487
8500
  }
8488
8501
  __updateBoxBounds() {
8489
8502
  if (this.points) {
8490
8503
  toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
8491
8504
  }
8492
- else {
8505
+ else
8493
8506
  super.__updateBoxBounds();
8494
- }
8495
8507
  }
8496
8508
  };
8497
8509
  __decorate([
@@ -8629,7 +8641,6 @@ let Canvas = class Canvas extends Rect {
8629
8641
  super(data);
8630
8642
  this.canvas = Creator.canvas(this.__);
8631
8643
  this.context = this.canvas.context;
8632
- this.__.__isCanvas = this.__.__drawAfterFill = true;
8633
8644
  if (data && data.url)
8634
8645
  this.drawImage(data.url);
8635
8646
  }
@@ -8642,8 +8653,7 @@ let Canvas = class Canvas extends Rect {
8642
8653
  });
8643
8654
  }
8644
8655
  draw(ui, offset, scale, rotation) {
8645
- ui.__layout.update();
8646
- const matrix = new Matrix(ui.__world).invert();
8656
+ const matrix = new Matrix(ui.worldTransform).invert();
8647
8657
  const m = new Matrix();
8648
8658
  if (offset)
8649
8659
  m.translate(offset.x, offset.y);
@@ -8658,17 +8668,9 @@ let Canvas = class Canvas extends Rect {
8658
8668
  paint() {
8659
8669
  this.forceRender();
8660
8670
  }
8661
- __drawAfterFill(canvas, _options) {
8662
- const { width, height, cornerRadius } = this.__, { view } = this.canvas;
8663
- if (cornerRadius || this.pathInputed) {
8664
- canvas.save();
8665
- canvas.clip();
8666
- canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
8667
- canvas.restore();
8668
- }
8669
- else {
8670
- canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
8671
- }
8671
+ __drawContent(canvas, _options) {
8672
+ const { width, height } = this.__, { view } = this.canvas;
8673
+ canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
8672
8674
  }
8673
8675
  __updateSize() {
8674
8676
  const { canvas } = this;
@@ -8712,7 +8714,6 @@ Canvas = __decorate([
8712
8714
  const { copyAndSpread, includes, isSame: isSame$1, spread, setList } = BoundsHelper;
8713
8715
  let Text = class Text extends UI {
8714
8716
  get __tag() { return 'Text'; }
8715
- get editInner() { return 'TextEditor'; }
8716
8717
  get textDrawData() {
8717
8718
  this.__layout.update();
8718
8719
  return this.__.__textDrawData;
@@ -8861,6 +8862,9 @@ __decorate([
8861
8862
  __decorate([
8862
8863
  boundsType('top')
8863
8864
  ], Text.prototype, "verticalAlign", void 0);
8865
+ __decorate([
8866
+ boundsType(true)
8867
+ ], Text.prototype, "autoSizeAlign", void 0);
8864
8868
  __decorate([
8865
8869
  boundsType('normal')
8866
8870
  ], Text.prototype, "textWrap", void 0);
@@ -8875,7 +8879,6 @@ let Path = class Path extends UI {
8875
8879
  get __tag() { return 'Path'; }
8876
8880
  constructor(data) {
8877
8881
  super(data);
8878
- this.__.__pathInputed = 2;
8879
8882
  }
8880
8883
  };
8881
8884
  __decorate([
@@ -8958,21 +8961,17 @@ let App = class App extends Leafer {
8958
8961
  this.tree = this.addLeafer(tree);
8959
8962
  if (sky || editor)
8960
8963
  this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
8961
- if (editor) {
8962
- this.editor = Creator.editor(editor);
8963
- this.sky.add(this.editor);
8964
- }
8964
+ if (editor)
8965
+ this.sky.add(this.editor = Creator.editor(editor));
8965
8966
  }
8966
8967
  }
8967
8968
  __setApp() {
8968
8969
  const { canvas } = this;
8969
8970
  const { realCanvas, view } = this.config;
8970
- if (realCanvas || view === this.canvas.view || !canvas.parentView) {
8971
+ if (realCanvas || view === this.canvas.view || !canvas.parentView)
8971
8972
  this.realCanvas = true;
8972
- }
8973
- else {
8973
+ else
8974
8974
  canvas.unrealCanvas();
8975
- }
8976
8975
  this.leafer = this;
8977
8976
  this.watcher.disable();
8978
8977
  this.layouter.disable();
@@ -9378,10 +9377,7 @@ leafer.initType = function (type) {
9378
9377
  leafer.getValidMove = function (moveX, moveY) {
9379
9378
  const { scroll, disabled } = this.app.config.move;
9380
9379
  if (scroll) {
9381
- if (Math.abs(moveX) > Math.abs(moveY))
9382
- moveY = 0;
9383
- else
9384
- moveX = 0;
9380
+ Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0;
9385
9381
  if (scroll === 'limit') {
9386
9382
  const { x, y, width, height } = new Bounds(this.__world).addPoint(this.zoomLayer);
9387
9383
  const right = x + width - this.width, bottom = y + height - this.height;
@@ -9581,9 +9577,10 @@ class Dragger {
9581
9577
  this.dragData = getDragEventData(data, data, data);
9582
9578
  this.canAnimate = this.canDragOut = true;
9583
9579
  }
9584
- getList() {
9580
+ getList(realDraggable, hover) {
9585
9581
  const { proxy } = this.interaction.selector;
9586
- return this.dragging && (!proxy || !proxy.list.length) ? (DragEvent.list || this.dragableList || emptyList) : emptyList;
9582
+ const hasProxyList = proxy && proxy.list.length, dragList = DragEvent.list || this.draggableList || emptyList;
9583
+ return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList);
9587
9584
  }
9588
9585
  checkDrag(data, canDrag) {
9589
9586
  const { interaction } = this;
@@ -9608,8 +9605,8 @@ class Dragger {
9608
9605
  this.dragging = canDrag && PointerButton.left(data);
9609
9606
  if (this.dragging) {
9610
9607
  this.interaction.emit(DragEvent.START, this.dragData);
9611
- this.getDragableList(this.dragData.path);
9612
- this.setDragStartPoints(this.realDragableList = this.getList());
9608
+ this.getDraggableList(this.dragData.path);
9609
+ this.setDragStartPoints(this.realDraggableList = this.getList(true));
9613
9610
  }
9614
9611
  }
9615
9612
  }
@@ -9617,12 +9614,12 @@ class Dragger {
9617
9614
  this.dragStartPoints = {};
9618
9615
  list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9619
9616
  }
9620
- getDragableList(path) {
9617
+ getDraggableList(path) {
9621
9618
  let leaf;
9622
9619
  for (let i = 0, len = path.length; i < len; i++) {
9623
9620
  leaf = path.list[i];
9624
- if ((leaf.__.draggable || leaf.__.editable) && leaf.__.hitSelf && !leaf.__.locked) {
9625
- this.dragableList = new LeafList(leaf);
9621
+ if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
9622
+ this.draggableList = new LeafList(leaf);
9626
9623
  break;
9627
9624
  }
9628
9625
  }
@@ -9647,7 +9644,7 @@ class Dragger {
9647
9644
  }
9648
9645
  dragReal() {
9649
9646
  const { running } = this.interaction;
9650
- const list = this.realDragableList;
9647
+ const list = this.realDraggableList;
9651
9648
  if (list.length && running) {
9652
9649
  const { totalX, totalY } = this.dragData;
9653
9650
  list.forEach(leaf => leaf.draggable && leaf.move(DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
@@ -9736,7 +9733,7 @@ class Dragger {
9736
9733
  this.interaction.emit(DragEvent.LEAVE, data, dragEnterPath);
9737
9734
  }
9738
9735
  dragReset() {
9739
- DragEvent.list = DragEvent.data = this.dragableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9736
+ DragEvent.list = DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9740
9737
  }
9741
9738
  checkDragOut(data) {
9742
9739
  const { interaction } = this;
@@ -9877,6 +9874,7 @@ const config = {
9877
9874
  touch: {
9878
9875
  preventDefault: true
9879
9876
  },
9877
+ multiTouch: {},
9880
9878
  cursor: true,
9881
9879
  keyEvent: true
9882
9880
  };
@@ -10003,6 +10001,8 @@ class InteractionBase {
10003
10001
  this.pointerUp(data);
10004
10002
  }
10005
10003
  multiTouch(data, list) {
10004
+ if (this.config.multiTouch.disabled)
10005
+ return;
10006
10006
  const { move, angle, scale, center } = MultiTouchHelper.getData(list);
10007
10007
  this.rotate(getRotateEventData(center, angle, data));
10008
10008
  this.zoom(getZoomEventData(center, scale, data));
@@ -10192,7 +10192,7 @@ class InteractionBase {
10192
10192
  data = this.hoverData;
10193
10193
  if (!data)
10194
10194
  return;
10195
- this.findPath(data, { exclude: this.dragger.getList(), name: PointerEvent.MOVE });
10195
+ this.findPath(data, { exclude: this.dragger.getList(false, true), name: PointerEvent.MOVE });
10196
10196
  this.hoverData = data;
10197
10197
  }
10198
10198
  updateCursor(data) {
@@ -10214,7 +10214,7 @@ class InteractionBase {
10214
10214
  const { path } = data;
10215
10215
  for (let i = 0, len = path.length; i < len; i++) {
10216
10216
  leaf = path.list[i];
10217
- cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
10217
+ cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor;
10218
10218
  if (cursor)
10219
10219
  break;
10220
10220
  }
@@ -10396,7 +10396,7 @@ ui$2.__updateHitCanvas = function () {
10396
10396
  if (isHitPixel) {
10397
10397
  const { renderBounds } = this.__layout;
10398
10398
  const size = Platform.image.hitCanvasSize;
10399
- const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds, 0.5).a;
10399
+ const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10400
10400
  const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
10401
10401
  h.resize({ width, height, pixelRatio: 1 });
10402
10402
  h.clear();
@@ -10452,15 +10452,14 @@ ui$2.__hit = function (inner) {
10452
10452
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
10453
10453
  };
10454
10454
 
10455
- const ui$1 = new UI();
10456
- const rect = Rect.prototype;
10457
- rect.__updateHitCanvas = function () {
10455
+ const ui$1 = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
10456
+ rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
10458
10457
  if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
10459
10458
  ui$1.__updateHitCanvas.call(this);
10460
10459
  else if (this.__hitCanvas)
10461
10460
  this.__hitCanvas = null;
10462
10461
  };
10463
- rect.__hitFill = function (inner) {
10462
+ rect.__hitFill = box$1.__hitFill = function (inner) {
10464
10463
  return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10465
10464
  };
10466
10465
 
@@ -11064,9 +11063,10 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11064
11063
  onLoadError(ui, event, image.error);
11065
11064
  }
11066
11065
  else {
11067
- ignoreRender(ui, true);
11068
- if (firstUse)
11066
+ if (firstUse) {
11067
+ ignoreRender(ui, true);
11069
11068
  onLoad(ui, event);
11069
+ }
11070
11070
  leafPaint.loadId = image.load(() => {
11071
11071
  ignoreRender(ui, false);
11072
11072
  if (!ui.destroyed) {
@@ -11214,7 +11214,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
11214
11214
  }
11215
11215
  if (allowPaint) {
11216
11216
  canvas.save();
11217
- canvas.clip();
11217
+ ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
11218
11218
  if (paint.blendMode)
11219
11219
  canvas.blendMode = paint.blendMode;
11220
11220
  if (data.opacity)
@@ -11678,11 +11678,12 @@ const { trimRight } = TextRowHelper;
11678
11678
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
11679
11679
  let word, row, wordWidth, rowWidth, realWidth;
11680
11680
  let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
11681
- let textDrawData, rows = [], bounds;
11681
+ let textDrawData, rows = [], bounds, findMaxWidth;
11682
11682
  function createRows(drawData, content, style) {
11683
11683
  textDrawData = drawData;
11684
11684
  rows = drawData.rows;
11685
11685
  bounds = drawData.bounds;
11686
+ findMaxWidth = !bounds.width && !style.autoSizeAlign;
11686
11687
  const { __letterSpacing, paraIndent, textCase } = style;
11687
11688
  const { canvas } = Platform;
11688
11689
  const { width, height } = bounds;
@@ -11767,7 +11768,10 @@ function createRows(drawData, content, style) {
11767
11768
  else {
11768
11769
  content.split('\n').forEach(content => {
11769
11770
  textDrawData.paraNumber++;
11770
- rows.push({ x: paraIndent || 0, text: content, width: canvas.measureText(content).width, paraStart: true });
11771
+ rowWidth = canvas.measureText(content).width;
11772
+ rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
11773
+ if (findMaxWidth)
11774
+ setMaxWidth();
11771
11775
  });
11772
11776
  }
11773
11777
  }
@@ -11798,10 +11802,16 @@ function addRow() {
11798
11802
  row.width = rowWidth;
11799
11803
  if (bounds.width)
11800
11804
  trimRight(row);
11805
+ else if (findMaxWidth)
11806
+ setMaxWidth();
11801
11807
  rows.push(row);
11802
11808
  row = { words: [] };
11803
11809
  rowWidth = 0;
11804
11810
  }
11811
+ function setMaxWidth() {
11812
+ if (rowWidth > (textDrawData.maxWidth || 0))
11813
+ textDrawData.maxWidth = rowWidth;
11814
+ }
11805
11815
 
11806
11816
  const CharMode = 0;
11807
11817
  const WordMode = 1;
@@ -11873,34 +11883,32 @@ function toChar(data, charX, rowData, isOverflow) {
11873
11883
 
11874
11884
  function layoutText(drawData, style) {
11875
11885
  const { rows, bounds } = drawData;
11876
- const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
11886
+ const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
11877
11887
  let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11878
11888
  let starY = __baseLine;
11879
11889
  if (__clipText && realHeight > height) {
11880
11890
  realHeight = Math.max(height, __lineHeight);
11881
11891
  drawData.overflow = rows.length;
11882
11892
  }
11883
- else {
11893
+ else if (height || autoSizeAlign) {
11884
11894
  switch (verticalAlign) {
11885
11895
  case 'middle':
11886
11896
  y += (height - realHeight) / 2;
11887
11897
  break;
11888
- case 'bottom':
11889
- y += (height - realHeight);
11898
+ case 'bottom': y += (height - realHeight);
11890
11899
  }
11891
11900
  }
11892
11901
  starY += y;
11893
- let row, rowX, rowWidth;
11902
+ let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
11894
11903
  for (let i = 0, len = rows.length; i < len; i++) {
11895
11904
  row = rows[i];
11896
11905
  row.x = x;
11897
11906
  if (row.width < width || (row.width > width && !__clipText)) {
11898
11907
  switch (textAlign) {
11899
11908
  case 'center':
11900
- row.x += (width - row.width) / 2;
11909
+ row.x += (layoutWidth - row.width) / 2;
11901
11910
  break;
11902
- case 'right':
11903
- row.x += width - row.width;
11911
+ case 'right': row.x += layoutWidth - row.width;
11904
11912
  }
11905
11913
  }
11906
11914
  if (row.paraStart && paraSpacing && i > 0)
@@ -12005,14 +12013,14 @@ function getDrawData(content, style) {
12005
12013
  let height = style.__getInput('height') || 0;
12006
12014
  const { textDecoration, __font, __padding: padding } = style;
12007
12015
  if (padding) {
12008
- if (width) {
12016
+ if (width)
12017
+ x = padding[left], width -= (padding[right] + padding[left]);
12018
+ else if (!style.autoSizeAlign)
12009
12019
  x = padding[left];
12010
- width -= (padding[right] + padding[left]);
12011
- }
12012
- if (height) {
12020
+ if (height)
12021
+ y = padding[top], height -= (padding[top] + padding[bottom]);
12022
+ else if (!style.autoSizeAlign)
12013
12023
  y = padding[top];
12014
- height -= (padding[top] + padding[bottom]);
12015
- }
12016
12024
  }
12017
12025
  const drawData = {
12018
12026
  bounds: { x, y, width, height },
@@ -12032,22 +12040,20 @@ function getDrawData(content, style) {
12032
12040
  return drawData;
12033
12041
  }
12034
12042
  function padAutoText(padding, drawData, style, width, height) {
12035
- if (!width) {
12043
+ if (!width && style.autoSizeAlign) {
12036
12044
  switch (style.textAlign) {
12037
12045
  case 'left':
12038
12046
  offsetText(drawData, 'x', padding[left]);
12039
12047
  break;
12040
- case 'right':
12041
- offsetText(drawData, 'x', -padding[right]);
12048
+ case 'right': offsetText(drawData, 'x', -padding[right]);
12042
12049
  }
12043
12050
  }
12044
- if (!height) {
12051
+ if (!height && style.autoSizeAlign) {
12045
12052
  switch (style.verticalAlign) {
12046
12053
  case 'top':
12047
12054
  offsetText(drawData, 'y', padding[top]);
12048
12055
  break;
12049
- case 'bottom':
12050
- offsetText(drawData, 'y', -padding[bottom]);
12056
+ case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
12051
12057
  }
12052
12058
  }
12053
12059
  }