leafer-ui 1.0.0-rc.26 → 1.0.0-rc.27

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.
@@ -5189,6 +5189,9 @@ let Leaf = class Leaf {
5189
5189
  }
5190
5190
  set(_data) { }
5191
5191
  get(_name) { return undefined; }
5192
+ setAttr(name, value) { this[name] = value; }
5193
+ getAttr(name) { return this[name]; }
5194
+ getComputedAttr(name) { return this.__[name]; }
5192
5195
  toJSON() {
5193
5196
  return this.__.__getInputData();
5194
5197
  }
@@ -5749,7 +5752,7 @@ class LeafLevelList {
5749
5752
  }
5750
5753
  }
5751
5754
 
5752
- const version = "1.0.0-rc.26";
5755
+ const version = "1.0.0-rc.27";
5753
5756
  const inviteCode = {};
5754
5757
 
5755
5758
  const debug$7 = Debug.get('LeaferCanvas');
@@ -7224,6 +7227,8 @@ const UIRender = {
7224
7227
  this.__drawRenderPath(canvas);
7225
7228
  if (fill && !ignoreFill)
7226
7229
  this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7230
+ if (this.__.__isCanvas)
7231
+ this.__drawAfterFill(canvas, options);
7227
7232
  if (stroke && !ignoreStroke)
7228
7233
  this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7229
7234
  }
@@ -7646,6 +7651,9 @@ __decorate([
7646
7651
  __decorate([
7647
7652
  dataType()
7648
7653
  ], UI.prototype, "disabledStyle", void 0);
7654
+ __decorate([
7655
+ dataType({})
7656
+ ], UI.prototype, "data", void 0);
7649
7657
  __decorate([
7650
7658
  rewrite(Leaf.prototype.reset)
7651
7659
  ], UI.prototype, "reset", null);
@@ -8488,7 +8496,7 @@ let Canvas = class Canvas extends Rect {
8488
8496
  super(data);
8489
8497
  this.canvas = Creator.canvas(this.__);
8490
8498
  this.context = this.canvas.context;
8491
- this.__.__drawAfterFill = true;
8499
+ this.__.__isCanvas = this.__.__drawAfterFill = true;
8492
8500
  }
8493
8501
  draw(ui, offset, scale, rotation) {
8494
8502
  ui.__layout.update();
@@ -8556,9 +8564,6 @@ __decorate([
8556
8564
  __decorate([
8557
8565
  resizeType()
8558
8566
  ], Canvas.prototype, "contextSettings", void 0);
8559
- __decorate([
8560
- hitType('all')
8561
- ], Canvas.prototype, "hitFill", void 0);
8562
8567
  Canvas = __decorate([
8563
8568
  registerUI()
8564
8569
  ], Canvas);
@@ -9025,20 +9030,32 @@ let DragEvent = class DragEvent extends PointerEvent {
9025
9030
  move.x = 0;
9026
9031
  return move;
9027
9032
  }
9028
- static getMoveInDragBounds(box, dragBounds, move, change) {
9029
- const x = box.x + move.x, y = box.y + move.y;
9030
- const right = x + box.width, bottom = y + box.height;
9033
+ static getMoveInDragBounds(childBox, dragBounds, move, change) {
9034
+ const x = childBox.x + move.x, y = childBox.y + move.y;
9035
+ const right = x + childBox.width, bottom = y + childBox.height;
9031
9036
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
9032
9037
  if (!change)
9033
9038
  move = Object.assign({}, move);
9034
- if (x < dragBounds.x)
9035
- move.x += dragBounds.x - x;
9036
- else if (right > boundsRight)
9037
- move.x += boundsRight - right;
9038
- if (y < dragBounds.y)
9039
- move.y += dragBounds.y - y;
9040
- else if (bottom > boundsBottom)
9041
- move.y += boundsBottom - bottom;
9039
+ if (BoundsHelper.includes(childBox, dragBounds)) {
9040
+ if (x > dragBounds.x)
9041
+ move.x += dragBounds.x - x;
9042
+ else if (right < boundsRight)
9043
+ move.x += boundsRight - right;
9044
+ if (y > dragBounds.y)
9045
+ move.y += dragBounds.y - y;
9046
+ else if (bottom < boundsBottom)
9047
+ move.y += boundsBottom - bottom;
9048
+ }
9049
+ else {
9050
+ if (x < dragBounds.x)
9051
+ move.x += dragBounds.x - x;
9052
+ else if (right > boundsRight)
9053
+ move.x += boundsRight - right;
9054
+ if (y < dragBounds.y)
9055
+ move.y += dragBounds.y - y;
9056
+ else if (bottom > boundsBottom)
9057
+ move.y += boundsBottom - bottom;
9058
+ }
9042
9059
  return move;
9043
9060
  }
9044
9061
  getPageMove(total) {
@@ -10158,27 +10175,6 @@ class HitCanvasManager extends CanvasManager {
10158
10175
  }
10159
10176
  }
10160
10177
 
10161
- const canvas$1 = LeaferCanvasBase.prototype;
10162
- canvas$1.hitFill = function (point, fillRule) {
10163
- return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
10164
- };
10165
- canvas$1.hitStroke = function (point, strokeWidth) {
10166
- this.strokeWidth = strokeWidth;
10167
- return this.context.isPointInStroke(point.x, point.y);
10168
- };
10169
- canvas$1.hitPixel = function (radiusPoint, offset, scale = 1) {
10170
- let { x, y, radiusX, radiusY } = radiusPoint;
10171
- if (offset)
10172
- x -= offset.x, y -= offset.y;
10173
- tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
10174
- const { data } = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
10175
- for (let i = 0, len = data.length; i < len; i += 4) {
10176
- if (data[i + 3] > 0)
10177
- return true;
10178
- }
10179
- return data[3] > 0;
10180
- };
10181
-
10182
10178
  const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
10183
10179
  const inner = {};
10184
10180
  const leaf = Leaf.prototype;
@@ -10215,7 +10211,7 @@ const matrix = new Matrix();
10215
10211
  const ui$2 = UI.prototype;
10216
10212
  ui$2.__updateHitCanvas = function () {
10217
10213
  const data = this.__, { hitCanvasManager } = this.leafer;
10218
- const isHitPixelFill = data.__pixelFill && data.hitFill === 'pixel';
10214
+ const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10219
10215
  const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
10220
10216
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
10221
10217
  if (!this.__hitCanvas)
@@ -10247,11 +10243,11 @@ ui$2.__hit = function (inner) {
10247
10243
  if (data.__isHitPixel && this.__hitPixel(inner))
10248
10244
  return true;
10249
10245
  const { hitFill } = data;
10250
- const needHitFillPath = (data.fill && hitFill && hitFill !== 'none') || hitFill === 'all';
10246
+ const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__pixelFill || data.__isCanvas)))) || hitFill === 'all';
10251
10247
  if (needHitFillPath && this.__hitFill(inner))
10252
10248
  return true;
10253
10249
  const { hitStroke, __strokeWidth } = data;
10254
- const needHitStrokePath = (data.stroke && hitFill && hitStroke !== 'none') || hitStroke === 'all';
10250
+ const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__pixelStroke))) || hitStroke === 'all';
10255
10251
  if (!needHitFillPath && !needHitStrokePath)
10256
10252
  return false;
10257
10253
  const radiusWidth = inner.radiusX * 2;
@@ -10283,7 +10279,7 @@ ui$2.__hit = function (inner) {
10283
10279
  const ui$1 = new UI();
10284
10280
  const rect = Rect.prototype;
10285
10281
  rect.__updateHitCanvas = function () {
10286
- if (this.stroke || this.cornerRadius || (this.fill && this.hitFill === 'pixel') || this.hitStroke === 'all')
10282
+ if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
10287
10283
  ui$1.__updateHitCanvas.call(this);
10288
10284
  else if (this.__hitCanvas)
10289
10285
  this.__hitCanvas = null;
@@ -10306,6 +10302,27 @@ group.pick = function (hitPoint, options) {
10306
10302
  return this.leafer ? this.leafer.selector.getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this })) : null;
10307
10303
  };
10308
10304
 
10305
+ const canvas$1 = LeaferCanvasBase.prototype;
10306
+ canvas$1.hitFill = function (point, fillRule) {
10307
+ return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
10308
+ };
10309
+ canvas$1.hitStroke = function (point, strokeWidth) {
10310
+ this.strokeWidth = strokeWidth;
10311
+ return this.context.isPointInStroke(point.x, point.y);
10312
+ };
10313
+ canvas$1.hitPixel = function (radiusPoint, offset, scale = 1) {
10314
+ let { x, y, radiusX, radiusY } = radiusPoint;
10315
+ if (offset)
10316
+ x -= offset.x, y -= offset.y;
10317
+ tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
10318
+ const { data } = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width || 1, tempBounds$1.height || 1);
10319
+ for (let i = 0, len = data.length; i < len; i += 4) {
10320
+ if (data[i + 3] > 0)
10321
+ return true;
10322
+ }
10323
+ return data[3] > 0;
10324
+ };
10325
+
10309
10326
  const PointerEventHelper = {
10310
10327
  convert(e, local) {
10311
10328
  const base = InteractionHelper.getBase(e);