leafer-ui 1.0.0-rc.8 → 1.0.0-rc.9

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.
@@ -5935,7 +5935,7 @@ const LeafRender = {
5935
5935
  canvas.setWorld(this.__world, options.matrix);
5936
5936
  canvas.opacity = this.__worldOpacity;
5937
5937
  if (this.__.__single) {
5938
- const tempCanvas = canvas.getSameCanvas(true);
5938
+ const tempCanvas = canvas.getSameCanvas(true, true);
5939
5939
  this.__draw(tempCanvas, options);
5940
5940
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5941
5941
  if (this.__worldFlipped || options.matrix) {
@@ -6012,7 +6012,7 @@ const BranchRender = {
6012
6012
  if (this.__worldOpacity) {
6013
6013
  if (this.__.__single) {
6014
6014
  canvas.resetTransform();
6015
- const tempCanvas = canvas.getSameCanvas();
6015
+ const tempCanvas = canvas.getSameCanvas(false, true);
6016
6016
  this.__renderBranch(tempCanvas, options);
6017
6017
  canvas.opacity = this.__worldOpacity;
6018
6018
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
@@ -7357,8 +7357,9 @@ class LeaferCanvas extends LeaferCanvasBase {
7357
7357
  view ? this.__createViewFrom(view) : this.__createView();
7358
7358
  const { style } = this.view;
7359
7359
  style.display || (style.display = 'block');
7360
- style.userSelect = 'none';
7361
7360
  this.parentView = this.view.parentElement;
7361
+ if (this.parentView)
7362
+ this.parentView.style.userSelect = 'none';
7362
7363
  if (Platform.syncDomFont && !this.parentView) {
7363
7364
  this.view.style.display = 'none';
7364
7365
  document.body.appendChild(this.view);
@@ -8084,6 +8085,9 @@ class FrameData extends BoxData {
8084
8085
  class LineData extends UIData {
8085
8086
  }
8086
8087
 
8088
+ class ArrowData extends LineData {
8089
+ }
8090
+
8087
8091
  class RectData extends UIData {
8088
8092
  get __boxStroke() { return true; }
8089
8093
  }
@@ -8142,6 +8146,25 @@ class TextData extends UIData {
8142
8146
  }
8143
8147
 
8144
8148
  class ImageData extends RectData {
8149
+ setUrl(value) {
8150
+ this.__setImageFill(value);
8151
+ this._url = value;
8152
+ }
8153
+ __setImageFill(value) {
8154
+ if (this.__leaf.image)
8155
+ this.__leaf.image = null;
8156
+ this.fill = value ? { type: 'image', mode: 'strench', url: value } : undefined;
8157
+ }
8158
+ __getData() {
8159
+ const data = super.__getData();
8160
+ delete data.fill;
8161
+ return data;
8162
+ }
8163
+ __getInputData() {
8164
+ const data = super.__getInputData();
8165
+ delete data.fill;
8166
+ return data;
8167
+ }
8145
8168
  }
8146
8169
 
8147
8170
  class CanvasData extends RectData {
@@ -8388,14 +8411,15 @@ let UI = UI_1 = class UI extends Leaf {
8388
8411
  findOne(condition, options) {
8389
8412
  return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
8390
8413
  }
8391
- getPath(curve) {
8392
- const { path } = this.__;
8414
+ getPath(curve, pathForRender) {
8415
+ this.__layout.update();
8416
+ let path = pathForRender ? this.__.__pathForRender : this.__.path;
8393
8417
  if (!path)
8394
- return [];
8418
+ this.__drawPathByBox(new PathCreator(path = []));
8395
8419
  return curve ? PathConvert.toCanvasData(path, true) : path;
8396
8420
  }
8397
- getPathString(curve) {
8398
- return PathConvert.stringify(this.getPath(curve));
8421
+ getPathString(curve, pathForRender) {
8422
+ return PathConvert.stringify(this.getPath(curve, pathForRender));
8399
8423
  }
8400
8424
  __onUpdateSize() {
8401
8425
  if (this.__.__input) {
@@ -8567,6 +8591,12 @@ __decorate([
8567
8591
  __decorate([
8568
8592
  strokeType(10)
8569
8593
  ], UI.prototype, "miterLimit", void 0);
8594
+ __decorate([
8595
+ strokeType('none')
8596
+ ], UI.prototype, "startArrow", void 0);
8597
+ __decorate([
8598
+ strokeType('none')
8599
+ ], UI.prototype, "endArrow", void 0);
8570
8600
  __decorate([
8571
8601
  pathType(0)
8572
8602
  ], UI.prototype, "cornerRadius", void 0);
@@ -9063,26 +9093,10 @@ let Image$1 = class Image extends Rect {
9063
9093
  get ready() { return this.image ? this.image.ready : false; }
9064
9094
  constructor(data) {
9065
9095
  super(data);
9066
- }
9067
- __updateBoxBounds() {
9068
- let update;
9069
- const { url } = this;
9070
- const fill = this.fill;
9071
- if (fill) {
9072
- if (fill.url !== url)
9073
- update = true;
9074
- }
9075
- else {
9076
- if (url)
9077
- update = true;
9078
- }
9079
- if (update) {
9080
- if (this.image)
9081
- this.image = null;
9082
- this.fill = url ? { type: 'image', mode: 'strench', url } : undefined;
9083
- this.once(ImageEvent.LOADED, (e) => this.image = e.image);
9084
- }
9085
- super.__updateBoxBounds();
9096
+ this.on(ImageEvent.LOADED, (e) => {
9097
+ if (e.attrName === 'fill' && e.attrValue.url === this.url)
9098
+ this.image = e.image;
9099
+ });
9086
9100
  }
9087
9101
  destroy() {
9088
9102
  this.image = null;
@@ -9842,6 +9856,7 @@ App = __decorate([
9842
9856
  registerUI()
9843
9857
  ], App);
9844
9858
 
9859
+ let origin = {};
9845
9860
  const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
9846
9861
  function fillOrFitMode(data, mode, box, width, height, rotation) {
9847
9862
  const transform = get$4();
@@ -9858,13 +9873,13 @@ function fillOrFitMode(data, mode, box, width, height, rotation) {
9858
9873
  data.scaleX = data.scaleY = scale;
9859
9874
  data.transform = transform;
9860
9875
  }
9861
- function clipMode(data, box, offset, scale, rotation) {
9876
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
9862
9877
  const transform = get$4();
9863
9878
  translate$1(transform, box.x, box.y);
9864
- if (offset)
9865
- translate$1(transform, offset.x, offset.y);
9866
- if (scale) {
9867
- typeof scale === 'number' ? scaleHelper(transform, scale) : scaleHelper(transform, scale.x, scale.y);
9879
+ if (x || y)
9880
+ translate$1(transform, x, y);
9881
+ if (scaleX) {
9882
+ scaleHelper(transform, scaleX, scaleY);
9868
9883
  data.scaleX = transform.a;
9869
9884
  data.scaleY = transform.d;
9870
9885
  }
@@ -9872,7 +9887,7 @@ function clipMode(data, box, offset, scale, rotation) {
9872
9887
  rotate(transform, rotation);
9873
9888
  data.transform = transform;
9874
9889
  }
9875
- function repeatMode(data, box, width, height, scale, rotation) {
9890
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
9876
9891
  const transform = get$4();
9877
9892
  if (rotation) {
9878
9893
  rotate(transform, rotation);
@@ -9888,10 +9903,15 @@ function repeatMode(data, box, width, height, scale, rotation) {
9888
9903
  break;
9889
9904
  }
9890
9905
  }
9891
- translate$1(transform, box.x, box.y);
9892
- if (scale) {
9893
- scaleOfOuter$2(transform, box, scale);
9894
- data.scaleX = data.scaleY = scale;
9906
+ origin.x = box.x;
9907
+ origin.y = box.y;
9908
+ if (x || y)
9909
+ origin.x += x, origin.y += y;
9910
+ translate$1(transform, origin.x, origin.y);
9911
+ if (scaleX) {
9912
+ scaleOfOuter$2(transform, origin, scaleX, scaleY);
9913
+ data.scaleX = scaleX;
9914
+ data.scaleY = scaleY;
9895
9915
  }
9896
9916
  data.transform = transform;
9897
9917
  }
@@ -9899,11 +9919,22 @@ function repeatMode(data, box, width, height, scale, rotation) {
9899
9919
  const { get: get$3, translate } = MatrixHelper;
9900
9920
  function createData(leafPaint, image, paint, box) {
9901
9921
  let { width, height } = image;
9902
- const { opacity, mode, offset, scale, rotation, blendMode, repeat } = paint;
9922
+ const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
9903
9923
  const sameBox = box.width === width && box.height === height;
9904
9924
  if (blendMode)
9905
9925
  leafPaint.blendMode = blendMode;
9906
9926
  const data = leafPaint.data = { mode };
9927
+ let x, y, scaleX, scaleY;
9928
+ if (offset)
9929
+ x = offset.x, y = offset.y;
9930
+ if (size) {
9931
+ scaleX = (typeof size === 'number' ? size : size.width) / width;
9932
+ scaleY = (typeof size === 'number' ? size : size.height) / height;
9933
+ }
9934
+ else if (scale) {
9935
+ scaleX = typeof scale === 'number' ? scale : scale.x;
9936
+ scaleY = typeof scale === 'number' ? scale : scale.y;
9937
+ }
9907
9938
  switch (mode) {
9908
9939
  case 'strench':
9909
9940
  if (!sameBox)
@@ -9914,12 +9945,12 @@ function createData(leafPaint, image, paint, box) {
9914
9945
  }
9915
9946
  break;
9916
9947
  case 'clip':
9917
- if (offset || scale || rotation)
9918
- clipMode(data, box, offset, scale, rotation);
9948
+ if (offset || scaleX || rotation)
9949
+ clipMode(data, box, x, y, scaleX, scaleY, rotation);
9919
9950
  break;
9920
9951
  case 'repeat':
9921
- if (!sameBox || scale || rotation)
9922
- repeatMode(data, box, width, height, scale, rotation);
9952
+ if (!sameBox || scaleX || rotation)
9953
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
9923
9954
  if (!repeat)
9924
9955
  data.repeat = 'repeat';
9925
9956
  break;
@@ -11221,4 +11252,4 @@ Object.assign(Export$1, Export);
11221
11252
 
11222
11253
  useCanvas();
11223
11254
 
11224
- export { Animate, AnimateEvent, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert$1 as ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export$1 as Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafHit, LeafLayout, LeafLevelList, LeafList, LeafMask, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, Path, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Platform, PluginManager, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert$1 as TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIHit, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, effectType, eraserType, getDescriptor, hitType, layoutProcessor, maskType, opacityType, pathType, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, useCanvas, useModule, usePlugin };
11255
+ export { Animate, AnimateEvent, App, AroundHelper, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert$1 as ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export$1 as Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafHit, LeafLayout, LeafLevelList, LeafList, LeafMask, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, Path, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Platform, PluginManager, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert$1 as TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIHit, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, effectType, eraserType, getDescriptor, hitType, layoutProcessor, maskType, opacityType, pathType, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, useCanvas, useModule, usePlugin };