leafer-ui 1.0.0-rc.5 → 1.0.0-rc.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.
package/dist/web.js CHANGED
@@ -129,13 +129,13 @@ var LeaferUI = (function (exports) {
129
129
  t.d *= y;
130
130
  },
131
131
  scaleOfOuter(t, origin, x, y = x) {
132
- M$5.toInnerPoint(t, origin, tempPoint$1);
133
- M$5.scaleOfInner(t, tempPoint$1, x, y);
132
+ M$6.toInnerPoint(t, origin, tempPoint$1);
133
+ M$6.scaleOfInner(t, tempPoint$1, x, y);
134
134
  },
135
135
  scaleOfInner(t, origin, x, y = x) {
136
- M$5.translateInner(t, origin.x, origin.y);
137
- M$5.scale(t, x, y);
138
- M$5.translateInner(t, -origin.x, -origin.y);
136
+ M$6.translateInner(t, origin.x, origin.y);
137
+ M$6.scale(t, x, y);
138
+ M$6.translateInner(t, -origin.x, -origin.y);
139
139
  },
140
140
  rotate(t, angle) {
141
141
  angle *= OneRadian;
@@ -148,13 +148,13 @@ var LeaferUI = (function (exports) {
148
148
  t.d = (c * sinR) + (d * cosR);
149
149
  },
150
150
  rotateOfOuter(t, origin, angle) {
151
- M$5.toInnerPoint(t, origin, tempPoint$1);
152
- M$5.rotateOfInner(t, tempPoint$1, angle);
151
+ M$6.toInnerPoint(t, origin, tempPoint$1);
152
+ M$6.rotateOfInner(t, tempPoint$1, angle);
153
153
  },
154
154
  rotateOfInner(t, origin, angle) {
155
- M$5.translateInner(t, origin.x, origin.y);
156
- M$5.rotate(t, angle);
157
- M$5.translateInner(t, -origin.x, -origin.y);
155
+ M$6.translateInner(t, origin.x, origin.y);
156
+ M$6.rotate(t, angle);
157
+ M$6.translateInner(t, -origin.x, -origin.y);
158
158
  },
159
159
  skew(t, x, y) {
160
160
  const { a, b, c, d } = t;
@@ -170,13 +170,13 @@ var LeaferUI = (function (exports) {
170
170
  }
171
171
  },
172
172
  skewOfOuter(t, origin, x, y) {
173
- M$5.toInnerPoint(t, origin, tempPoint$1);
174
- M$5.skewOfInner(t, tempPoint$1, x, y);
173
+ M$6.toInnerPoint(t, origin, tempPoint$1);
174
+ M$6.skewOfInner(t, tempPoint$1, x, y);
175
175
  },
176
176
  skewOfInner(t, origin, x, y) {
177
- M$5.translateInner(t, origin.x, origin.y);
178
- M$5.skew(t, x, y);
179
- M$5.translateInner(t, -origin.x, -origin.y);
177
+ M$6.translateInner(t, origin.x, origin.y);
178
+ M$6.skew(t, x, y);
179
+ M$6.translateInner(t, -origin.x, -origin.y);
180
180
  },
181
181
  multiply(t, matrix) {
182
182
  const { a, b, c, d, e, f } = t;
@@ -199,12 +199,12 @@ var LeaferUI = (function (exports) {
199
199
  t.f = (e * matrix.b) + (f * matrix.d) + matrix.f;
200
200
  },
201
201
  divide(t, matrix) {
202
- M$5.preMultiply(t, M$5.tempInvert(matrix));
202
+ M$6.preMultiply(t, M$6.tempInvert(matrix));
203
203
  },
204
204
  tempInvert(t) {
205
- const { tempMatrix: temp } = M$5;
206
- M$5.copy(temp, t);
207
- M$5.invert(temp);
205
+ const { tempMatrix: temp } = M$6;
206
+ M$6.copy(temp, t);
207
+ M$6.invert(temp);
208
208
  return temp;
209
209
  },
210
210
  invert(t) {
@@ -267,10 +267,10 @@ var LeaferUI = (function (exports) {
267
267
  return { x: t.e, y: t.f, scaleX, scaleY, rotation, skewX, skewY };
268
268
  },
269
269
  reset(t) {
270
- M$5.set(t);
270
+ M$6.set(t);
271
271
  }
272
272
  };
273
- const M$5 = MatrixHelper;
273
+ const M$6 = MatrixHelper;
274
274
 
275
275
  const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$2 } = MatrixHelper;
276
276
  const { sin: sin$5, cos: cos$5, abs: abs$1, sqrt: sqrt$2, atan2: atan2$2 } = Math;
@@ -590,9 +590,7 @@ var LeaferUI = (function (exports) {
590
590
  }
591
591
  B.move(to, -to.offsetX, -to.offsetY);
592
592
  },
593
- scale(t, scaleX, scaleY) {
594
- if (!scaleY)
595
- scaleY = scaleX;
593
+ scale(t, scaleX, scaleY = scaleX) {
596
594
  if (t.x)
597
595
  t.x *= scaleX;
598
596
  if (t.y)
@@ -600,6 +598,12 @@ var LeaferUI = (function (exports) {
600
598
  t.width *= scaleX;
601
599
  t.height *= scaleY;
602
600
  },
601
+ scaleOf(t, origin, scaleX, scaleY) {
602
+ t.x += (t.x - origin.x) * (scaleX - 1);
603
+ t.y += (t.y - origin.y) * (scaleY - 1);
604
+ t.width *= scaleX;
605
+ t.height *= scaleY;
606
+ },
603
607
  tempToOuterOf(t, matrix) {
604
608
  B.copy(B.tempBounds, t);
605
609
  B.toOuterOf(B.tempBounds, matrix);
@@ -791,6 +795,10 @@ var LeaferUI = (function (exports) {
791
795
  BoundsHelper.scale(this, scaleX, scaleY);
792
796
  return this;
793
797
  }
798
+ scaleOf(origin, scaleX, scaleY) {
799
+ BoundsHelper.scaleOf(this, origin, scaleX, scaleY);
800
+ return this;
801
+ }
794
802
  toOuterOf(matrix, to) {
795
803
  BoundsHelper.toOuterOf(this, matrix, to);
796
804
  return this;
@@ -1343,14 +1351,22 @@ var LeaferUI = (function (exports) {
1343
1351
  if (this.__input && this.__input[name] !== undefined)
1344
1352
  this.__input[name] = undefined;
1345
1353
  }
1346
- __getInputData() {
1354
+ __getInputData(options) {
1347
1355
  const data = { tag: this.__leaf.tag }, { __input } = this;
1348
- let realKey, value;
1349
- for (let key in this) {
1350
- realKey = key.substring(1);
1351
- if (this[realKey] !== undefined) {
1352
- value = __input ? __input[realKey] : undefined;
1353
- data[realKey] = value === undefined ? this[key] : value;
1356
+ if (options) {
1357
+ for (let key in this) {
1358
+ if (key[0] !== '_')
1359
+ data[key] = this[key];
1360
+ }
1361
+ }
1362
+ else {
1363
+ let realKey, value;
1364
+ for (let key in this) {
1365
+ realKey = key.substring(1);
1366
+ if (this[realKey] !== undefined) {
1367
+ value = __input ? __input[realKey] : undefined;
1368
+ data[realKey] = value === undefined ? this[key] : value;
1369
+ }
1354
1370
  }
1355
1371
  }
1356
1372
  return data;
@@ -2089,11 +2105,11 @@ var LeaferUI = (function (exports) {
2089
2105
  const { sin: sin$4, cos: cos$4, atan2: atan2$1, ceil, abs, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2090
2106
  const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
2091
2107
  const { set: set$2 } = PointHelper;
2092
- const { M: M$4, L: L$5, C: C$4, Q: Q$4, Z: Z$4 } = PathCommandMap;
2108
+ const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
2093
2109
  const tempPoint = {};
2094
2110
  const BezierHelper = {
2095
2111
  points(data, points, curve, close) {
2096
- data.push(M$4, points[0], points[1]);
2112
+ data.push(M$5, points[0], points[1]);
2097
2113
  if (curve && points.length > 5) {
2098
2114
  let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
2099
2115
  let ba, cb, d, len = points.length;
@@ -2123,7 +2139,7 @@ var LeaferUI = (function (exports) {
2123
2139
  data.push(Q$4, c1X, c1Y, bX, bY);
2124
2140
  }
2125
2141
  else {
2126
- data.push(C$4, c2X, c2Y, c1X, c1Y, bX, bY);
2142
+ data.push(C$5, c2X, c2Y, c1X, c1Y, bX, bY);
2127
2143
  }
2128
2144
  c2X = bX + cb * cX;
2129
2145
  c2Y = bY + cb * cY;
@@ -2133,11 +2149,11 @@ var LeaferUI = (function (exports) {
2133
2149
  }
2134
2150
  else {
2135
2151
  for (let i = 2, len = points.length; i < len; i += 2) {
2136
- data.push(L$5, points[i], points[i + 1]);
2152
+ data.push(L$6, points[i], points[i + 1]);
2137
2153
  }
2138
2154
  }
2139
2155
  if (close)
2140
- data.push(Z$4);
2156
+ data.push(Z$5);
2141
2157
  },
2142
2158
  rect(data, x, y, width, height) {
2143
2159
  PathHelper.creator.path = data;
@@ -2160,7 +2176,7 @@ var LeaferUI = (function (exports) {
2160
2176
  totalRadian += PI2;
2161
2177
  if (totalRadian === PI$2 || (abs(BAx + BAy) < 1.e-12) || (abs(CBx + CBy) < 1.e-12)) {
2162
2178
  if (data)
2163
- data.push(L$5, x1, y1);
2179
+ data.push(L$6, x1, y1);
2164
2180
  if (setPointBounds) {
2165
2181
  setPoint$1(setPointBounds, fromX, fromY);
2166
2182
  addPoint$1(setPointBounds, x1, y1);
@@ -2213,7 +2229,7 @@ var LeaferUI = (function (exports) {
2213
2229
  let startY = y = rotationSin * radiusX * startCos + rotationCos * radiusY * startSin;
2214
2230
  let fromX = cx + x, fromY = cy + y;
2215
2231
  if (data)
2216
- data.push(L$5, fromX, fromY);
2232
+ data.push(L$6, fromX, fromY);
2217
2233
  if (setPointBounds)
2218
2234
  setPoint$1(setPointBounds, fromX, fromY);
2219
2235
  if (setStartPoint)
@@ -2228,7 +2244,7 @@ var LeaferUI = (function (exports) {
2228
2244
  x2 = cx + x + control * (rotationCos * radiusX * endSin + rotationSin * radiusY * endCos);
2229
2245
  y2 = cy + y + control * (rotationSin * radiusX * endSin - rotationCos * radiusY * endCos);
2230
2246
  if (data)
2231
- data.push(C$4, x1, y1, x2, y2, cx + x, cy + y);
2247
+ data.push(C$5, x1, y1, x2, y2, cx + x, cy + y);
2232
2248
  if (setPointBounds)
2233
2249
  toTwoPointBounds$1(cx + startX, cy + startY, x1, y1, x2, y2, cx + x, cy + y, setPointBounds, true);
2234
2250
  startX = x;
@@ -2242,7 +2258,7 @@ var LeaferUI = (function (exports) {
2242
2258
  set$2(setEndPoint, cx + x, cy + y);
2243
2259
  },
2244
2260
  quadraticCurveTo(data, fromX, fromY, x1, y1, toX, toY) {
2245
- data.push(C$4, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
2261
+ data.push(C$5, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
2246
2262
  },
2247
2263
  toTwoPointBoundsByQuadraticCurve(fromX, fromY, x1, y1, toX, toY, pointBounds, addMode) {
2248
2264
  toTwoPointBounds$1(fromX, fromY, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY, pointBounds, addMode);
@@ -2336,7 +2352,7 @@ var LeaferUI = (function (exports) {
2336
2352
  const centerX = fromX + halfX + rotationCos * cx - rotationSin * cy;
2337
2353
  const centerY = fromY + halfY + rotationSin * cx + rotationCos * cy;
2338
2354
  const anticlockwise = totalRadian < 0 ? 1 : 0;
2339
- if (curveMode || Platform.name === 'node') {
2355
+ if (curveMode || Platform.ellipseToCurve) {
2340
2356
  ellipse$5(data, centerX, centerY, radiusX, radiusY, rotation, startRadian / OneRadian, endRadian / OneRadian, anticlockwise);
2341
2357
  }
2342
2358
  else {
@@ -2350,7 +2366,7 @@ var LeaferUI = (function (exports) {
2350
2366
  }
2351
2367
  };
2352
2368
 
2353
- const { M: M$3, m, L: L$4, l, H, h, V, v, C: C$3, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$3, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$3, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
2369
+ const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$3, O: O$3, P: P$3, U: U$4 } = PathCommandMap;
2354
2370
  const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$2, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2355
2371
  const { ellipticalArc } = EllipseHelper;
2356
2372
  const debug$b = Debug.get('PathConvert');
@@ -2438,33 +2454,33 @@ var LeaferUI = (function (exports) {
2438
2454
  case m:
2439
2455
  old[i + 1] += x;
2440
2456
  old[i + 2] += y;
2441
- case M$3:
2457
+ case M$4:
2442
2458
  x = old[i + 1];
2443
2459
  y = old[i + 2];
2444
- data.push(M$3, x, y);
2460
+ data.push(M$4, x, y);
2445
2461
  i += 3;
2446
2462
  break;
2447
2463
  case h:
2448
2464
  old[i + 1] += x;
2449
2465
  case H:
2450
2466
  x = old[i + 1];
2451
- data.push(L$4, x, y);
2467
+ data.push(L$5, x, y);
2452
2468
  i += 2;
2453
2469
  break;
2454
2470
  case v:
2455
2471
  old[i + 1] += y;
2456
2472
  case V:
2457
2473
  y = old[i + 1];
2458
- data.push(L$4, x, y);
2474
+ data.push(L$5, x, y);
2459
2475
  i += 2;
2460
2476
  break;
2461
2477
  case l:
2462
2478
  old[i + 1] += x;
2463
2479
  old[i + 2] += y;
2464
- case L$4:
2480
+ case L$5:
2465
2481
  x = old[i + 1];
2466
2482
  y = old[i + 2];
2467
- data.push(L$4, x, y);
2483
+ data.push(L$5, x, y);
2468
2484
  i += 3;
2469
2485
  break;
2470
2486
  case s:
@@ -2474,14 +2490,14 @@ var LeaferUI = (function (exports) {
2474
2490
  old[i + 4] += y;
2475
2491
  command = S;
2476
2492
  case S:
2477
- smooth = (lastCommand === C$3) || (lastCommand === S);
2493
+ smooth = (lastCommand === C$4) || (lastCommand === S);
2478
2494
  x1 = smooth ? (x * 2 - controlX) : old[i + 1];
2479
2495
  y1 = smooth ? (y * 2 - controlY) : old[i + 2];
2480
2496
  controlX = old[i + 1];
2481
2497
  controlY = old[i + 2];
2482
2498
  x = old[i + 3];
2483
2499
  y = old[i + 4];
2484
- data.push(C$3, x1, y1, controlX, controlY, x, y);
2500
+ data.push(C$4, x1, y1, controlX, controlY, x, y);
2485
2501
  i += 5;
2486
2502
  break;
2487
2503
  case c:
@@ -2491,13 +2507,13 @@ var LeaferUI = (function (exports) {
2491
2507
  old[i + 4] += y;
2492
2508
  old[i + 5] += x;
2493
2509
  old[i + 6] += y;
2494
- command = C$3;
2495
- case C$3:
2510
+ command = C$4;
2511
+ case C$4:
2496
2512
  controlX = old[i + 3];
2497
2513
  controlY = old[i + 4];
2498
2514
  x = old[i + 5];
2499
2515
  y = old[i + 6];
2500
- data.push(C$3, old[i + 1], old[i + 2], controlX, controlY, x, y);
2516
+ data.push(C$4, old[i + 1], old[i + 2], controlX, controlY, x, y);
2501
2517
  i += 7;
2502
2518
  break;
2503
2519
  case t:
@@ -2537,8 +2553,8 @@ var LeaferUI = (function (exports) {
2537
2553
  i += 8;
2538
2554
  break;
2539
2555
  case z:
2540
- case Z$3:
2541
- data.push(Z$3);
2556
+ case Z$4:
2557
+ data.push(Z$4);
2542
2558
  i++;
2543
2559
  break;
2544
2560
  case N$3:
@@ -2583,7 +2599,7 @@ var LeaferUI = (function (exports) {
2583
2599
  y = old[i + 2];
2584
2600
  i += 4;
2585
2601
  break;
2586
- case U$3:
2602
+ case U$4:
2587
2603
  arcTo$2(curveMode ? data : copyData(data, old, i, 6), x, y, old[i + 1], old[i + 2], old[i + 3], old[i + 4], old[i + 5], null, setEndPoint$1);
2588
2604
  x = setEndPoint$1.x;
2589
2605
  y = setEndPoint$1.y;
@@ -2614,26 +2630,26 @@ var LeaferUI = (function (exports) {
2614
2630
  };
2615
2631
  const { current, pushData, copyData } = PathConvert;
2616
2632
 
2617
- const { M: M$2, L: L$3, C: C$2, Q: Q$2, Z: Z$2, N: N$2, D: D$2, X: X$2, G: G$2, F: F$2, O: O$2, P: P$2, U: U$2 } = PathCommandMap;
2633
+ const { M: M$3, L: L$4, C: C$3, Q: Q$2, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$2, O: O$2, P: P$2, U: U$3 } = PathCommandMap;
2618
2634
  const startPoint = {};
2619
2635
  const PathCommandDataHelper = {
2620
2636
  beginPath(data) {
2621
2637
  data.length = 0;
2622
2638
  },
2623
2639
  moveTo(data, x, y) {
2624
- data.push(M$2, x, y);
2640
+ data.push(M$3, x, y);
2625
2641
  },
2626
2642
  lineTo(data, x, y) {
2627
- data.push(L$3, x, y);
2643
+ data.push(L$4, x, y);
2628
2644
  },
2629
2645
  bezierCurveTo(data, x1, y1, x2, y2, x, y) {
2630
- data.push(C$2, x1, y1, x2, y2, x, y);
2646
+ data.push(C$3, x1, y1, x2, y2, x, y);
2631
2647
  },
2632
2648
  quadraticCurveTo(data, x1, y1, x, y) {
2633
2649
  data.push(Q$2, x1, y1, x, y);
2634
2650
  },
2635
2651
  closePath(data) {
2636
- data.push(Z$2);
2652
+ data.push(Z$3);
2637
2653
  },
2638
2654
  rect(data, x, y, width, height) {
2639
2655
  data.push(N$2, x, y, width, height);
@@ -2675,7 +2691,7 @@ var LeaferUI = (function (exports) {
2675
2691
  }
2676
2692
  },
2677
2693
  arcTo(data, x1, y1, x2, y2, radius) {
2678
- data.push(U$2, x1, y1, x2, y2, radius);
2694
+ data.push(U$3, x1, y1, x2, y2, radius);
2679
2695
  },
2680
2696
  drawEllipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2681
2697
  if (rotation === undefined)
@@ -2685,7 +2701,7 @@ var LeaferUI = (function (exports) {
2685
2701
  if (endAngle === undefined)
2686
2702
  endAngle = 360;
2687
2703
  BezierHelper.ellipse(null, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise, null, null, startPoint);
2688
- data.push(M$2, startPoint.x, startPoint.y);
2704
+ data.push(M$3, startPoint.x, startPoint.y);
2689
2705
  ellipse$3(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2690
2706
  },
2691
2707
  drawArc(data, x, y, radius, startAngle, endAngle, anticlockwise) {
@@ -2694,7 +2710,7 @@ var LeaferUI = (function (exports) {
2694
2710
  if (endAngle === undefined)
2695
2711
  endAngle = 360;
2696
2712
  BezierHelper.arc(null, x, y, radius, startAngle, endAngle, anticlockwise, null, null, startPoint);
2697
- data.push(M$2, startPoint.x, startPoint.y);
2713
+ data.push(M$3, startPoint.x, startPoint.y);
2698
2714
  arc$2(data, x, y, radius, startAngle, endAngle, anticlockwise);
2699
2715
  },
2700
2716
  drawPoints(data, points, curve, close) {
@@ -2771,7 +2787,7 @@ var LeaferUI = (function (exports) {
2771
2787
  }
2772
2788
  }
2773
2789
 
2774
- const { M: M$1, L: L$2, C: C$1, Q: Q$1, Z: Z$1, N: N$1, D: D$1, X: X$1, G: G$1, F: F$1, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
2790
+ const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$1, O: O$1, P: P$1, U: U$2 } = PathCommandMap;
2775
2791
  const debug$a = Debug.get('PathDrawer');
2776
2792
  const PathDrawer = {
2777
2793
  drawPathByData(drawer, data) {
@@ -2782,15 +2798,15 @@ var LeaferUI = (function (exports) {
2782
2798
  while (i < len) {
2783
2799
  command = data[i];
2784
2800
  switch (command) {
2785
- case M$1:
2801
+ case M$2:
2786
2802
  drawer.moveTo(data[i + 1], data[i + 2]);
2787
2803
  i += 3;
2788
2804
  break;
2789
- case L$2:
2805
+ case L$3:
2790
2806
  drawer.lineTo(data[i + 1], data[i + 2]);
2791
2807
  i += 3;
2792
2808
  break;
2793
- case C$1:
2809
+ case C$2:
2794
2810
  drawer.bezierCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
2795
2811
  i += 7;
2796
2812
  break;
@@ -2798,7 +2814,7 @@ var LeaferUI = (function (exports) {
2798
2814
  drawer.quadraticCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4]);
2799
2815
  i += 5;
2800
2816
  break;
2801
- case Z$1:
2817
+ case Z$2:
2802
2818
  drawer.closePath();
2803
2819
  i += 1;
2804
2820
  break;
@@ -2830,7 +2846,7 @@ var LeaferUI = (function (exports) {
2830
2846
  drawer.arc(data[i + 1], data[i + 2], data[i + 3], 0, PI2, false);
2831
2847
  i += 4;
2832
2848
  break;
2833
- case U$1:
2849
+ case U$2:
2834
2850
  drawer.arcTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5]);
2835
2851
  i += 6;
2836
2852
  break;
@@ -2842,7 +2858,7 @@ var LeaferUI = (function (exports) {
2842
2858
  }
2843
2859
  };
2844
2860
 
2845
- const { M, L: L$1, C, Q, Z, N, D, X, G, F, O, P, U } = PathCommandMap;
2861
+ const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F, O, P, U: U$1 } = PathCommandMap;
2846
2862
  const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo, arc, ellipse: ellipse$1 } = BezierHelper;
2847
2863
  const { add: add$1, copy: copy$6, addPoint, setPoint, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
2848
2864
  const debug$9 = Debug.get('PathBounds');
@@ -2864,7 +2880,7 @@ var LeaferUI = (function (exports) {
2864
2880
  while (i < len) {
2865
2881
  command = data[i];
2866
2882
  if (i === 0) {
2867
- if (command === Z || command === C || command === Q) {
2883
+ if (command === Z$1 || command === C$1 || command === Q) {
2868
2884
  setPoint(setPointBounds, x, y);
2869
2885
  }
2870
2886
  else {
@@ -2872,14 +2888,14 @@ var LeaferUI = (function (exports) {
2872
2888
  }
2873
2889
  }
2874
2890
  switch (command) {
2875
- case M:
2876
- case L$1:
2891
+ case M$1:
2892
+ case L$2:
2877
2893
  x = data[i + 1];
2878
2894
  y = data[i + 2];
2879
2895
  addPoint(setPointBounds, x, y);
2880
2896
  i += 3;
2881
2897
  break;
2882
- case C:
2898
+ case C$1:
2883
2899
  toX = data[i + 5];
2884
2900
  toY = data[i + 6];
2885
2901
  toTwoPointBounds(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY, tempPointBounds);
@@ -2899,7 +2915,7 @@ var LeaferUI = (function (exports) {
2899
2915
  y = toY;
2900
2916
  i += 5;
2901
2917
  break;
2902
- case Z:
2918
+ case Z$1:
2903
2919
  i += 1;
2904
2920
  break;
2905
2921
  case N:
@@ -2946,7 +2962,7 @@ var LeaferUI = (function (exports) {
2946
2962
  x += radius;
2947
2963
  i += 4;
2948
2964
  break;
2949
- case U:
2965
+ case U$1:
2950
2966
  arcTo(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
2951
2967
  i === 0 ? copy$6(setPointBounds, tempPointBounds) : add$1(setPointBounds, tempPointBounds);
2952
2968
  x = setEndPoint.x;
@@ -2961,9 +2977,60 @@ var LeaferUI = (function (exports) {
2961
2977
  }
2962
2978
  };
2963
2979
 
2980
+ const { M, L: L$1, C, Z, U } = PathCommandMap;
2964
2981
  const PathCorner = {
2965
- smooth(data, _cornerRadius, _cornerSmoothing) {
2966
- return data;
2982
+ smooth(data, cornerRadius, _cornerSmoothing) {
2983
+ let command;
2984
+ let i = 0, x = 0, y = 0, startX, startY = 0, centerX = 0, centerY = 0;
2985
+ const len = data.length;
2986
+ const smooth = [];
2987
+ while (i < len) {
2988
+ command = data[i];
2989
+ switch (command) {
2990
+ case M:
2991
+ startX = data[i + 1];
2992
+ startY = data[i + 2];
2993
+ i += 3;
2994
+ if (data[i] === L$1) {
2995
+ centerX = startX + (data[i + 1] - startX) / 2;
2996
+ centerY = startY + (data[i + 2] - startY) / 2;
2997
+ smooth.push(M, centerX, centerY);
2998
+ }
2999
+ else {
3000
+ smooth.push(M, startX, startY);
3001
+ }
3002
+ break;
3003
+ case L$1:
3004
+ x = data[i + 1];
3005
+ y = data[i + 2];
3006
+ i += 3;
3007
+ switch (data[i]) {
3008
+ case L$1:
3009
+ smooth.push(U, x, y, data[i + 1], data[i + 2], cornerRadius);
3010
+ break;
3011
+ case Z:
3012
+ smooth.push(U, x, y, startX, startY, cornerRadius);
3013
+ break;
3014
+ default:
3015
+ smooth.push(L$1, x, y);
3016
+ }
3017
+ break;
3018
+ case C:
3019
+ smooth.push(C, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
3020
+ i += 7;
3021
+ break;
3022
+ case Z:
3023
+ smooth.push(U, startX, startY, centerX, centerY, cornerRadius);
3024
+ smooth.push(Z);
3025
+ i += 1;
3026
+ break;
3027
+ }
3028
+ }
3029
+ if (command !== Z) {
3030
+ smooth[1] = startX;
3031
+ smooth[2] = startY;
3032
+ }
3033
+ return smooth;
2967
3034
  }
2968
3035
  };
2969
3036
 
@@ -3015,9 +3082,7 @@ var LeaferUI = (function (exports) {
3015
3082
  }
3016
3083
 
3017
3084
  class TaskProcessor {
3018
- get total() {
3019
- return this.list.length + this.delayNumber;
3020
- }
3085
+ get total() { return this.list.length + this.delayNumber; }
3021
3086
  get finishedIndex() {
3022
3087
  return this.isComplete ? 0 : this.index + this.parallelSuccessNumber;
3023
3088
  }
@@ -3073,8 +3138,10 @@ var LeaferUI = (function (exports) {
3073
3138
  else {
3074
3139
  this.delayNumber++;
3075
3140
  setTimeout(() => {
3076
- this.delayNumber--;
3077
- this.push(task, start);
3141
+ if (this.delayNumber) {
3142
+ this.delayNumber--;
3143
+ this.push(task, start);
3144
+ }
3078
3145
  }, delay);
3079
3146
  }
3080
3147
  this.isComplete = false;
@@ -3091,6 +3158,7 @@ var LeaferUI = (function (exports) {
3091
3158
  this.parallelSuccessNumber = 0;
3092
3159
  this.list = [];
3093
3160
  this.parallelList = [];
3161
+ this.delayNumber = 0;
3094
3162
  }
3095
3163
  start() {
3096
3164
  if (!this.running) {
@@ -4140,6 +4208,17 @@ var LeaferUI = (function (exports) {
4140
4208
  parent.worldToInner(position);
4141
4209
  t.set(position);
4142
4210
  parent.add(t);
4211
+ },
4212
+ hasParent(t, parent) {
4213
+ if (!parent)
4214
+ return false;
4215
+ let p = t;
4216
+ while (p) {
4217
+ if (parent === p)
4218
+ return true;
4219
+ p = p.parent;
4220
+ }
4221
+ return false;
4143
4222
  }
4144
4223
  };
4145
4224
  const L = LeafHelper;
@@ -5216,6 +5295,8 @@ var LeaferUI = (function (exports) {
5216
5295
  const oldValue = this.__.__getInput(name);
5217
5296
  if (typeof newValue === 'object' || oldValue !== newValue) {
5218
5297
  this.__[name] = newValue;
5298
+ if (this.proxyData)
5299
+ this.setProxyAttr(name, newValue);
5219
5300
  const { CHANGE } = PropertyEvent;
5220
5301
  const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
5221
5302
  if (this.hasEvent(CHANGE) && !this.isLeafer)
@@ -5225,10 +5306,21 @@ var LeaferUI = (function (exports) {
5225
5306
  }
5226
5307
  else {
5227
5308
  this.__[name] = newValue;
5309
+ if (this.proxyData)
5310
+ this.setProxyAttr(name, newValue);
5228
5311
  }
5229
5312
  },
5230
5313
  __getAttr(name) {
5314
+ if (this.proxyData)
5315
+ return this.getProxyAttr(name);
5231
5316
  return this.__.__get(name);
5317
+ },
5318
+ setProxyAttr(name, newValue) {
5319
+ if (this.proxyData[name] !== newValue)
5320
+ this.proxyData[name] = newValue;
5321
+ },
5322
+ getProxyAttr(name) {
5323
+ return this.proxyData[name];
5232
5324
  }
5233
5325
  };
5234
5326
 
@@ -5438,6 +5530,10 @@ var LeaferUI = (function (exports) {
5438
5530
  setRadius(point, this.__.hitRadius);
5439
5531
  }
5440
5532
  toInnerRadiusPointOf(point, this.__world, inner);
5533
+ if (this.__.hitBox) {
5534
+ if (BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner))
5535
+ return true;
5536
+ }
5441
5537
  return this.__hit(inner);
5442
5538
  },
5443
5539
  __drawHitPath(canvas) {
@@ -5481,12 +5577,21 @@ var LeaferUI = (function (exports) {
5481
5577
  __updateMask(value) {
5482
5578
  this.__hasMask = value ? true : this.children.some(item => item.__.isMask);
5483
5579
  },
5484
- __renderMask(canvas, content, mask) {
5580
+ __renderMask(canvas, content, mask, recycle) {
5581
+ content.opacity = 1;
5485
5582
  content.resetTransform();
5486
5583
  content.useMask(mask);
5487
- canvas.resetTransform();
5488
5584
  canvas.opacity = this.__worldOpacity;
5585
+ canvas.resetTransform();
5489
5586
  canvas.copyWorld(content);
5587
+ if (recycle) {
5588
+ content.recycle();
5589
+ mask.recycle();
5590
+ }
5591
+ else {
5592
+ content.clear();
5593
+ mask.clear();
5594
+ }
5490
5595
  },
5491
5596
  __removeMask(child) {
5492
5597
  if (child) {
@@ -5541,15 +5646,13 @@ var LeaferUI = (function (exports) {
5541
5646
  const { children } = this;
5542
5647
  if (this.__hasMask && children.length > 1) {
5543
5648
  let mask;
5544
- let maskCanvas = canvas.getSameCanvas();
5545
- let contentCanvas = canvas.getSameCanvas();
5649
+ const maskCanvas = canvas.getSameCanvas();
5650
+ const contentCanvas = canvas.getSameCanvas();
5546
5651
  for (let i = 0, len = children.length; i < len; i++) {
5547
5652
  child = children[i];
5548
5653
  if (child.isMask) {
5549
5654
  if (mask) {
5550
5655
  this.__renderMask(canvas, contentCanvas, maskCanvas);
5551
- maskCanvas.clear();
5552
- contentCanvas.clear();
5553
5656
  }
5554
5657
  else {
5555
5658
  mask = true;
@@ -5557,11 +5660,9 @@ var LeaferUI = (function (exports) {
5557
5660
  child.__render(maskCanvas, options);
5558
5661
  continue;
5559
5662
  }
5560
- child.__render(contentCanvas, options);
5663
+ child.__render(mask ? contentCanvas : canvas, options);
5561
5664
  }
5562
- this.__renderMask(canvas, contentCanvas, maskCanvas);
5563
- maskCanvas.recycle();
5564
- contentCanvas.recycle();
5665
+ this.__renderMask(canvas, contentCanvas, maskCanvas, true);
5565
5666
  }
5566
5667
  else {
5567
5668
  const { bounds, hideBounds } = options;
@@ -5655,6 +5756,7 @@ var LeaferUI = (function (exports) {
5655
5756
  }
5656
5757
  }
5657
5758
  set(_data) { }
5759
+ get(_options) { return undefined; }
5658
5760
  toJSON() {
5659
5761
  return this.__.__getInputData();
5660
5762
  }
@@ -5663,6 +5765,10 @@ var LeaferUI = (function (exports) {
5663
5765
  }
5664
5766
  __setAttr(_attrName, _newValue) { }
5665
5767
  __getAttr(_attrName) { return undefined; }
5768
+ setProxyAttr(_attrName, _newValue) { }
5769
+ getProxyAttr(_attrName) { return undefined; }
5770
+ find(_condition) { return undefined; }
5771
+ findOne(_condition) { return undefined; }
5666
5772
  forceUpdate(attrName) {
5667
5773
  if (attrName === undefined)
5668
5774
  attrName = 'width';
@@ -5687,7 +5793,7 @@ var LeaferUI = (function (exports) {
5687
5793
  __onUpdateSize() { }
5688
5794
  __updateEraser(_value) { }
5689
5795
  __updateMask(_value) { }
5690
- __renderMask(_canvas, _content, _mask) { }
5796
+ __renderMask(_canvas, _content, _mask, _recycle) { }
5691
5797
  __removeMask(_child) { }
5692
5798
  getWorld(attrName) {
5693
5799
  this.__layout.checkUpdate();
@@ -6544,7 +6650,7 @@ var LeaferUI = (function (exports) {
6544
6650
  }
6545
6651
 
6546
6652
  const { hitRadiusPoint } = BoundsHelper;
6547
- class FindPath {
6653
+ class Pather {
6548
6654
  constructor(target, selector) {
6549
6655
  this.target = target;
6550
6656
  this.selector = selector;
@@ -6664,117 +6770,108 @@ var LeaferUI = (function (exports) {
6664
6770
  class Selector {
6665
6771
  constructor(target, userConfig) {
6666
6772
  this.config = {};
6667
- this.innerIdList = {};
6668
- this.idList = {};
6669
- this.classNameList = {};
6670
- this.tagNameList = {};
6773
+ this.innerIdMap = {};
6774
+ this.idMap = {};
6775
+ this.methods = {
6776
+ id: (leaf, name) => leaf.id === name ? this.idMap[name] = leaf : 0,
6777
+ innerId: (leaf, innerId) => leaf.innerId === innerId ? this.innerIdMap[innerId] = leaf : 0,
6778
+ className: (leaf, name) => leaf.className === name ? 1 : 0,
6779
+ tag: (leaf, name) => leaf.__tag === name ? 1 : 0
6780
+ };
6671
6781
  this.target = target;
6672
6782
  if (userConfig)
6673
6783
  this.config = DataHelper.default(userConfig, this.config);
6674
- this.findPath = new FindPath(target, this);
6784
+ this.pather = new Pather(target, this);
6675
6785
  this.__listenEvents();
6676
6786
  }
6677
6787
  getByPoint(hitPoint, hitRadius, options) {
6678
6788
  if (Platform.name === 'node')
6679
6789
  this.target.emit(LayoutEvent.CHECK_UPDATE);
6680
- return this.findPath.getByPoint(hitPoint, hitRadius, options);
6681
- }
6682
- find(name, branch) {
6683
- if (typeof name === 'number') {
6684
- return this.getByInnerId(name, branch);
6685
- }
6686
- else if (name.startsWith('#')) {
6687
- return this.getById(name.substring(1), branch);
6688
- }
6689
- else if (name.startsWith('.')) {
6690
- return this.getByClassName(name.substring(1), branch);
6691
- }
6692
- else {
6693
- return this.getByTagName(name, branch);
6790
+ return this.pather.getByPoint(hitPoint, hitRadius, options);
6791
+ }
6792
+ getBy(condition, branch, one, options) {
6793
+ switch (typeof condition) {
6794
+ case 'number':
6795
+ const leaf = this.getByInnerId(condition, branch);
6796
+ return one ? leaf : (leaf ? [leaf] : []);
6797
+ case 'string':
6798
+ switch (condition[0]) {
6799
+ case '#':
6800
+ const leaf = this.getById(condition.substring(1), branch);
6801
+ return one ? leaf : (leaf ? [leaf] : []);
6802
+ case '.':
6803
+ return this.getByMethod(this.methods.className, branch, one, condition.substring(1));
6804
+ default:
6805
+ return this.getByMethod(this.methods.tag, branch, one, condition);
6806
+ }
6807
+ case 'function':
6808
+ return this.getByMethod(condition, branch, one, options);
6694
6809
  }
6695
6810
  }
6696
- getByInnerId(name, branch) {
6697
- let cache = this.innerIdList[name];
6811
+ getByInnerId(innerId, branch) {
6812
+ const cache = this.innerIdMap[innerId];
6698
6813
  if (cache)
6699
6814
  return cache;
6700
- if (!branch)
6701
- branch = this.target;
6702
- let find;
6703
- this.loopFind(branch, (leaf) => {
6704
- if (leaf.innerId === name) {
6705
- find = leaf;
6706
- this.innerIdList[name] = find;
6707
- return true;
6708
- }
6709
- else {
6710
- return false;
6711
- }
6712
- });
6713
- return find;
6815
+ this.eachFind(this.toChildren(branch), this.methods.innerId, null, innerId);
6816
+ return this.findLeaf;
6714
6817
  }
6715
- getById(name, branch) {
6716
- let cache = this.idList[name];
6717
- if (cache)
6818
+ getById(id, branch) {
6819
+ const cache = this.idMap[id];
6820
+ if (cache && LeafHelper.hasParent(cache, branch || this.target))
6718
6821
  return cache;
6719
- if (!branch)
6720
- branch = this.target;
6721
- let find;
6722
- this.loopFind(branch, (leaf) => {
6723
- if (leaf.id === name) {
6724
- find = leaf;
6725
- this.idList[name] = find;
6726
- return true;
6727
- }
6728
- else {
6729
- return false;
6730
- }
6731
- });
6732
- return find;
6822
+ this.eachFind(this.toChildren(branch), this.methods.id, null, id);
6823
+ return this.findLeaf;
6733
6824
  }
6734
- getByClassName(name, branch) {
6735
- if (!branch)
6736
- branch = this.target;
6737
- let find = [];
6738
- this.loopFind(branch, (leaf) => {
6739
- if (leaf.className === name)
6740
- find.push(leaf);
6741
- return false;
6742
- });
6743
- return find;
6825
+ getByClassName(className, branch) {
6826
+ return this.getByMethod(this.methods.className, branch, false, className);
6744
6827
  }
6745
- getByTagName(name, branch) {
6746
- if (!branch)
6747
- branch = this.target;
6748
- let find = [];
6749
- this.loopFind(branch, (leaf) => {
6750
- if (leaf.__tag === name)
6751
- find.push(leaf);
6752
- return false;
6753
- });
6754
- return find;
6828
+ getByTag(tag, branch) {
6829
+ return this.getByMethod(this.methods.tag, branch, false, tag);
6755
6830
  }
6756
- loopFind(branch, find) {
6757
- if (find(branch))
6758
- return;
6759
- const { children } = branch;
6831
+ getByMethod(method, branch, one, options) {
6832
+ const list = one ? null : [];
6833
+ this.eachFind(this.toChildren(branch), method, list, options);
6834
+ return list || this.findLeaf;
6835
+ }
6836
+ eachFind(children, method, list, options) {
6837
+ let child;
6760
6838
  for (let i = 0, len = children.length; i < len; i++) {
6761
- branch = children[i];
6762
- if (find(branch))
6763
- return;
6764
- if (branch.isBranch)
6765
- this.loopFind(branch, find);
6839
+ child = children[i];
6840
+ if (method(child, options)) {
6841
+ if (list) {
6842
+ list.push(child);
6843
+ }
6844
+ else {
6845
+ this.findLeaf = child;
6846
+ return;
6847
+ }
6848
+ }
6849
+ if (child.isBranch)
6850
+ this.eachFind(child.children, method, list, options);
6766
6851
  }
6767
6852
  }
6853
+ toChildren(branch) {
6854
+ this.findLeaf = null;
6855
+ return [branch || this.target];
6856
+ }
6768
6857
  __onRemoveChild(event) {
6769
- const target = event.target;
6770
- if (this.idList[target.id])
6771
- this.idList[target.id] = null;
6772
- if (this.innerIdList[target.id])
6773
- this.innerIdList[target.innerId] = null;
6858
+ const { id, innerId } = event.child;
6859
+ if (this.idMap[id])
6860
+ delete this.idMap[id];
6861
+ if (this.innerIdMap[innerId])
6862
+ delete this.innerIdMap[innerId];
6863
+ }
6864
+ __checkIdChange(event) {
6865
+ if (event.attrName === 'id') {
6866
+ const id = event.oldValue;
6867
+ if (this.idMap[id])
6868
+ delete this.idMap[id];
6869
+ }
6774
6870
  }
6775
6871
  __listenEvents() {
6776
6872
  this.__eventIds = [
6777
- this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this)
6873
+ this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this),
6874
+ this.target.on_(PropertyEvent.CHANGE, this.__checkIdChange, this)
6778
6875
  ];
6779
6876
  }
6780
6877
  __removeListenEvents() {
@@ -6784,11 +6881,10 @@ var LeaferUI = (function (exports) {
6784
6881
  destroy() {
6785
6882
  if (this.__eventIds.length) {
6786
6883
  this.__removeListenEvents();
6787
- this.findPath.destroy();
6788
- this.innerIdList = {};
6789
- this.idList = {};
6790
- this.classNameList = {};
6791
- this.tagNameList = {};
6884
+ this.pather.destroy();
6885
+ this.findLeaf = null;
6886
+ this.innerIdMap = {};
6887
+ this.idMap = {};
6792
6888
  }
6793
6889
  }
6794
6890
  }
@@ -7010,7 +7106,7 @@ var LeaferUI = (function (exports) {
7010
7106
  let { zoomMode, zoomSpeed } = config;
7011
7107
  const delta = e.deltaY || e.deltaX;
7012
7108
  if (zoomMode) {
7013
- zoom = !e.deltaX && (Platform.intWheelDeltaY ? Math.abs(delta) > 17 : Math.ceil(delta) !== delta);
7109
+ zoom = (zoomMode === 'mouse') ? true : (!e.deltaX && (Platform.intWheelDeltaY ? Math.abs(delta) > 17 : Math.ceil(delta) !== delta));
7014
7110
  if (e.shiftKey || e.metaKey || e.ctrlKey)
7015
7111
  zoom = true;
7016
7112
  }
@@ -7819,8 +7915,15 @@ var LeaferUI = (function (exports) {
7819
7915
  set(data) {
7820
7916
  Object.assign(this, data);
7821
7917
  }
7822
- get() {
7823
- return this.__.__getInputData();
7918
+ get(options) {
7919
+ return this.__.__getInputData(options);
7920
+ }
7921
+ getProxyData() { return undefined; }
7922
+ find(condition) {
7923
+ return this.leafer ? this.leafer.selector.getBy(condition, this) : [];
7924
+ }
7925
+ findOne(condition) {
7926
+ return this.leafer ? this.leafer.selector.getBy(condition, this, true) : null;
7824
7927
  }
7825
7928
  getPath(curve) {
7826
7929
  const path = this.__.path;
@@ -7944,6 +8047,9 @@ var LeaferUI = (function (exports) {
7944
8047
  __decorate([
7945
8048
  strokeType('path')
7946
8049
  ], exports.UI.prototype, "hitStroke", void 0);
8050
+ __decorate([
8051
+ hitType(false)
8052
+ ], exports.UI.prototype, "hitBox", void 0);
7947
8053
  __decorate([
7948
8054
  hitType(true)
7949
8055
  ], exports.UI.prototype, "hitChildren", void 0);
@@ -8252,7 +8358,7 @@ var LeaferUI = (function (exports) {
8252
8358
  }
8253
8359
  ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
8254
8360
  }
8255
- if (Platform.name === 'node')
8361
+ if (Platform.ellipseToCurve)
8256
8362
  this.__.path = PathConvert.toCanvasData(path, true);
8257
8363
  }
8258
8364
  else {
@@ -8563,7 +8669,7 @@ var LeaferUI = (function (exports) {
8563
8669
  registerUI()
8564
8670
  ], exports.Canvas);
8565
8671
 
8566
- const { copyAndSpread, includes, spread } = BoundsHelper;
8672
+ const { copyAndSpread, includes, spread, setByList } = BoundsHelper;
8567
8673
  exports.Text = class Text extends exports.UI {
8568
8674
  get __tag() { return 'Text'; }
8569
8675
  get textDrawData() {
@@ -8597,18 +8703,19 @@ var LeaferUI = (function (exports) {
8597
8703
  __updateBoxBounds() {
8598
8704
  const data = this.__;
8599
8705
  const layout = this.__layout;
8600
- const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase } = data;
8706
+ const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
8707
+ const width = data.__getInput('width');
8708
+ const height = data.__getInput('height');
8601
8709
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
8602
8710
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
8603
8711
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
8604
8712
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
8713
+ data.__clipText = textOverflow !== 'show' && (width || height);
8605
8714
  this.__updateTextDrawData();
8606
8715
  const { bounds } = data.__textDrawData;
8607
8716
  const b = layout.boxBounds;
8608
8717
  if (data.__lineHeight < fontSize)
8609
8718
  spread(bounds, fontSize / 2);
8610
- const width = data.__getInput('width');
8611
- const height = data.__getInput('height');
8612
8719
  if (width && height) {
8613
8720
  super.__updateBoxBounds();
8614
8721
  }
@@ -8623,6 +8730,10 @@ var LeaferUI = (function (exports) {
8623
8730
  if (contentBounds !== layout.contentBounds) {
8624
8731
  layout.contentBounds = contentBounds;
8625
8732
  layout.renderChanged = true;
8733
+ setByList(data.__textBoxBounds = {}, [b, bounds]);
8734
+ }
8735
+ else {
8736
+ data.__textBoxBounds = contentBounds;
8626
8737
  }
8627
8738
  }
8628
8739
  __updateRenderSpread() {
@@ -8632,7 +8743,7 @@ var LeaferUI = (function (exports) {
8632
8743
  return width;
8633
8744
  }
8634
8745
  __updateRenderBounds() {
8635
- copyAndSpread(this.__layout.renderBounds, this.__layout.contentBounds, this.__layout.renderSpread);
8746
+ copyAndSpread(this.__layout.renderBounds, this.__.__textBoxBounds, this.__layout.renderSpread);
8636
8747
  }
8637
8748
  };
8638
8749
  __decorate([
@@ -8650,6 +8761,9 @@ var LeaferUI = (function (exports) {
8650
8761
  __decorate([
8651
8762
  affectStrokeBoundsType('outside')
8652
8763
  ], exports.Text.prototype, "strokeAlign", void 0);
8764
+ __decorate([
8765
+ hitType('all')
8766
+ ], exports.Text.prototype, "hitFill", void 0);
8653
8767
  __decorate([
8654
8768
  boundsType('')
8655
8769
  ], exports.Text.prototype, "text", void 0);
@@ -8689,6 +8803,9 @@ var LeaferUI = (function (exports) {
8689
8803
  __decorate([
8690
8804
  boundsType('top')
8691
8805
  ], exports.Text.prototype, "verticalAlign", void 0);
8806
+ __decorate([
8807
+ boundsType('normal')
8808
+ ], exports.Text.prototype, "textWrap", void 0);
8692
8809
  __decorate([
8693
8810
  boundsType('show')
8694
8811
  ], exports.Text.prototype, "textOverflow", void 0);
@@ -9419,8 +9536,9 @@ var LeaferUI = (function (exports) {
9419
9536
  if (!paint.patternTask) {
9420
9537
  paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
9421
9538
  paint.patternTask = null;
9422
- if (canvas.bounds.hit(ui.__world) && createPattern(ui, paint, canvas.pixelRatio))
9423
- ui.forceUpdate('surface');
9539
+ if (canvas.bounds.hit(ui.__world))
9540
+ createPattern(ui, paint, canvas.pixelRatio);
9541
+ ui.forceUpdate('surface');
9424
9542
  }), 300);
9425
9543
  }
9426
9544
  }
@@ -10084,6 +10202,8 @@ var LeaferUI = (function (exports) {
10084
10202
  const { width, height } = bounds;
10085
10203
  const charMode = width || height || __letterSpacing || (textCase !== 'none');
10086
10204
  if (charMode) {
10205
+ const wrap = style.textWrap !== 'none';
10206
+ const breakAll = style.textWrap === 'break';
10087
10207
  paraStart = true;
10088
10208
  lastCharType = null;
10089
10209
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
@@ -10110,16 +10230,23 @@ var LeaferUI = (function (exports) {
10110
10230
  langBreak = (charType === Single && (lastCharType === Single || lastCharType === Letter)) || (lastCharType === Single && charType !== After);
10111
10231
  afterBreak = ((charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After));
10112
10232
  realWidth = paraStart && paraIndent ? width - paraIndent : width;
10113
- if (width && rowWidth + wordWidth + charWidth > realWidth) {
10114
- if (!afterBreak)
10115
- afterBreak = charType === Letter && lastCharType == After;
10116
- if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
10233
+ if (wrap && (width && rowWidth + wordWidth + charWidth > realWidth)) {
10234
+ if (breakAll) {
10117
10235
  if (wordWidth)
10118
10236
  addWord();
10119
10237
  addRow();
10120
10238
  }
10121
10239
  else {
10122
- addRow();
10240
+ if (!afterBreak)
10241
+ afterBreak = charType === Letter && lastCharType == After;
10242
+ if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
10243
+ if (wordWidth)
10244
+ addWord();
10245
+ addRow();
10246
+ }
10247
+ else {
10248
+ addRow();
10249
+ }
10123
10250
  }
10124
10251
  }
10125
10252
  if (char === ' ' && paraStart !== true && (rowWidth + wordWidth) === 0) ;
@@ -10189,7 +10316,7 @@ var LeaferUI = (function (exports) {
10189
10316
 
10190
10317
  const CharMode = 0;
10191
10318
  const WordMode = 1;
10192
- const RowMode = 2;
10319
+ const TextMode = 2;
10193
10320
  function layoutChar(drawData, style, width, _height) {
10194
10321
  const { rows } = drawData;
10195
10322
  const { textAlign, paraIndent, letterSpacing } = style;
@@ -10198,15 +10325,12 @@ var LeaferUI = (function (exports) {
10198
10325
  if (row.words) {
10199
10326
  indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
10200
10327
  addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
10201
- mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : RowMode);
10202
- if (mode === RowMode) {
10203
- row.text = '';
10328
+ mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
10329
+ if (row.isOverflow && !letterSpacing)
10330
+ row.textMode = true;
10331
+ if (mode === TextMode) {
10204
10332
  row.x += indentWidth;
10205
- row.words.forEach(word => {
10206
- word.data.forEach(char => {
10207
- row.text += char.char;
10208
- });
10209
- });
10333
+ toTextChar$1(row);
10210
10334
  }
10211
10335
  else {
10212
10336
  row.x += indentWidth;
@@ -10232,6 +10356,14 @@ var LeaferUI = (function (exports) {
10232
10356
  }
10233
10357
  });
10234
10358
  }
10359
+ function toTextChar$1(row) {
10360
+ row.text = '';
10361
+ row.words.forEach(word => {
10362
+ word.data.forEach(char => {
10363
+ row.text += char.char;
10364
+ });
10365
+ });
10366
+ }
10235
10367
  function toWordChar(data, charX, wordChar) {
10236
10368
  data.forEach(char => {
10237
10369
  wordChar.char += char.char;
@@ -10252,10 +10384,10 @@ var LeaferUI = (function (exports) {
10252
10384
 
10253
10385
  function layoutText(drawData, style) {
10254
10386
  const { rows, bounds } = drawData;
10255
- const { __lineHeight, __baseLine, __letterSpacing, textAlign, verticalAlign, paraSpacing, textOverflow } = style;
10387
+ const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
10256
10388
  let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
10257
10389
  let starY = __baseLine;
10258
- if (textOverflow !== 'show' && realHeight > height) {
10390
+ if (__clipText && realHeight > height) {
10259
10391
  realHeight = Math.max(height, __lineHeight);
10260
10392
  drawData.overflow = rows.length;
10261
10393
  }
@@ -10304,39 +10436,58 @@ var LeaferUI = (function (exports) {
10304
10436
  bounds.x = rowX;
10305
10437
  if (rowWidth > bounds.width)
10306
10438
  bounds.width = rowWidth;
10439
+ if (__clipText && width && width < rowWidth) {
10440
+ row.isOverflow = true;
10441
+ if (!drawData.overflow)
10442
+ drawData.overflow = rows.length;
10443
+ }
10307
10444
  }
10308
10445
  bounds.y = y;
10309
10446
  bounds.height = realHeight;
10310
10447
  }
10311
10448
 
10312
- function clipText(drawData, textOverflow) {
10449
+ function clipText(drawData, style) {
10313
10450
  const { rows, overflow } = drawData;
10451
+ let { textOverflow } = style;
10314
10452
  rows.splice(overflow);
10315
10453
  if (textOverflow !== 'hide') {
10316
10454
  if (textOverflow === 'ellipsis')
10317
10455
  textOverflow = '...';
10456
+ let char, charRight;
10318
10457
  const ellipsisWidth = Platform.canvas.measureText(textOverflow).width;
10319
- const row = rows[overflow - 1];
10320
- let char, end = row.data.length - 1, charRight;
10321
- const { x, width } = drawData.bounds;
10322
- const right = x + width - ellipsisWidth;
10323
- for (let i = end; i > -1; i--) {
10324
- char = row.data[i];
10325
- charRight = char.x + char.width;
10326
- if (i === end && charRight < right) {
10327
- break;
10328
- }
10329
- else if (charRight < right && char.char !== ' ') {
10330
- row.data.splice(i + 1);
10331
- row.width -= char.width;
10332
- break;
10458
+ const right = style.x + style.width - ellipsisWidth;
10459
+ const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
10460
+ list.forEach(row => {
10461
+ if (row.isOverflow && row.data) {
10462
+ let end = row.data.length - 1;
10463
+ for (let i = end; i > -1; i--) {
10464
+ char = row.data[i];
10465
+ charRight = char.x + char.width;
10466
+ if (i === end && charRight < right) {
10467
+ break;
10468
+ }
10469
+ else if (charRight < right && char.char !== ' ') {
10470
+ row.data.splice(i + 1);
10471
+ row.width -= char.width;
10472
+ break;
10473
+ }
10474
+ row.width -= char.width;
10475
+ }
10476
+ row.width += ellipsisWidth;
10477
+ row.data.push({ char: textOverflow, x: charRight });
10478
+ if (row.textMode)
10479
+ toTextChar(row);
10333
10480
  }
10334
- row.width -= char.width;
10335
- }
10336
- row.width += ellipsisWidth;
10337
- row.data.push({ char: textOverflow, x: charRight });
10481
+ });
10338
10482
  }
10339
10483
  }
10484
+ function toTextChar(row) {
10485
+ row.text = '';
10486
+ row.data.forEach(char => {
10487
+ row.text += char.char;
10488
+ });
10489
+ row.data = null;
10490
+ }
10340
10491
 
10341
10492
  function decorationText(drawData, style) {
10342
10493
  const { fontSize } = style;
@@ -10357,7 +10508,7 @@ var LeaferUI = (function (exports) {
10357
10508
  let x = 0, y = 0;
10358
10509
  let width = style.__getInput('width') || 0;
10359
10510
  let height = style.__getInput('height') || 0;
10360
- const { textDecoration, textOverflow, __font, padding } = style;
10511
+ const { textDecoration, __font, padding } = style;
10361
10512
  if (padding) {
10362
10513
  const [top, right, bottom, left] = MathHelper.fourNumber(padding);
10363
10514
  if (width) {
@@ -10379,7 +10530,7 @@ var LeaferUI = (function (exports) {
10379
10530
  layoutText(drawData, style);
10380
10531
  layoutChar(drawData, style, width);
10381
10532
  if (drawData.overflow)
10382
- clipText(drawData, textOverflow);
10533
+ clipText(drawData, style);
10383
10534
  if (textDecoration !== 'none')
10384
10535
  decorationText(drawData, style);
10385
10536
  return drawData;