@leafer-ui/display 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/display",
3
- "version": "1.0.0-rc.8",
3
+ "version": "1.0.0-rc.9",
4
4
  "description": "@leafer-ui/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,14 +22,14 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.0.0-rc.8",
26
- "@leafer-ui/data": "1.0.0-rc.8",
27
- "@leafer-ui/display-module": "1.0.0-rc.8",
28
- "@leafer-ui/decorator": "1.0.0-rc.8",
29
- "@leafer-ui/external": "1.0.0-rc.8"
25
+ "@leafer/core": "1.0.0-rc.9",
26
+ "@leafer-ui/data": "1.0.0-rc.9",
27
+ "@leafer-ui/display-module": "1.0.0-rc.9",
28
+ "@leafer-ui/decorator": "1.0.0-rc.9",
29
+ "@leafer-ui/external": "1.0.0-rc.9"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "1.0.0-rc.8",
33
- "@leafer-ui/interface": "1.0.0-rc.8"
32
+ "@leafer/interface": "1.0.0-rc.9",
33
+ "@leafer-ui/interface": "1.0.0-rc.9"
34
34
  }
35
35
  }
package/src/Arrow.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { registerUI, strokeType, dataProcessor } from '@leafer/core'
2
+
3
+ import { IArrow, IArrowData, IArrowInputData, IArrowType } from '@leafer-ui/interface'
4
+ import { ArrowData } from '@leafer-ui/data'
5
+
6
+ import { Line } from './Line'
7
+
8
+
9
+ @registerUI()
10
+ export class Arrow extends Line implements IArrow {
11
+
12
+ public get __tag() { return 'Arrow' }
13
+
14
+ @dataProcessor(ArrowData)
15
+ declare public __: IArrowData
16
+
17
+ @strokeType('lines')
18
+ declare public endArrow: IArrowType
19
+
20
+ constructor(data?: IArrowInputData) {
21
+ super(data)
22
+ }
23
+
24
+ }
package/src/Box.ts CHANGED
@@ -2,11 +2,10 @@ import { ILeaferCanvas, IRenderOptions, IPathDrawer, IBoundsData, IPathCommandDa
2
2
  import { rewrite, rewriteAble, registerUI, BoundsHelper, dataProcessor, affectRenderBoundsType } from '@leafer/core'
3
3
 
4
4
  import { IBox, IBoxData, IBoxInputData, IOverflow } from '@leafer-ui/interface'
5
+ import { BoxData } from '@leafer-ui/data'
5
6
 
6
7
  import { Group } from './Group'
7
8
  import { Rect } from './Rect'
8
- import { BoxData } from '@leafer-ui/data'
9
-
10
9
 
11
10
  const rect = Rect.prototype
12
11
  const group = Group.prototype
package/src/Image.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ILeaferImage, IString } from '@leafer/interface'
2
2
  import { ImageEvent, boundsType, dataProcessor, registerUI } from '@leafer/core'
3
3
 
4
- import { IImage, IImageInputData, IImageData, IImagePaint } from '@leafer-ui/interface'
4
+ import { IImage, IImageInputData, IImageData } from '@leafer-ui/interface'
5
5
  import { ImageData } from '@leafer-ui/data'
6
6
 
7
7
  import { Rect } from './Rect'
@@ -24,29 +24,9 @@ export class Image extends Rect implements IImage {
24
24
 
25
25
  constructor(data?: IImageInputData) {
26
26
  super(data)
27
- }
28
-
29
- public __updateBoxBounds(): void {
30
-
31
- let update: boolean
32
-
33
- const { url } = this
34
- const fill = this.fill as IImagePaint
35
-
36
- if (fill) {
37
- if (fill.url !== url) update = true
38
- } else {
39
- if (url) update = true
40
- }
41
-
42
- if (update) {
43
- if (this.image) this.image = null
44
- this.fill = url ? { type: 'image', mode: 'strench', url } : undefined
45
- this.once(ImageEvent.LOADED, (e) => this.image = e.image)
46
- }
47
-
48
- super.__updateBoxBounds()
49
-
27
+ this.on(ImageEvent.LOADED, (e: ImageEvent) => {
28
+ if (e.attrName === 'fill' && e.attrValue.url === this.url) this.image = e.image
29
+ })
50
30
  }
51
31
 
52
32
  public destroy(): void {
package/src/UI.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IAround, IFindMethod } from '@leafer/interface'
2
- import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, sortType, maskType, dataProcessor, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType } from '@leafer/core'
2
+ import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, sortType, maskType, dataProcessor, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType, PathCreator } from '@leafer/core'
3
3
 
4
- import { IUI, IShadowEffect, IBlurEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult, IFill, IStroke, IFindUIMethod, IEditSize, ILeafer } from '@leafer-ui/interface'
4
+ import { IUI, IShadowEffect, IBlurEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult, IFill, IStroke, IArrowType, IFindUIMethod, IEditSize, ILeafer } from '@leafer-ui/interface'
5
5
  import { effectType } from '@leafer-ui/decorator'
6
6
 
7
7
  import { UIData } from '@leafer-ui/data'
@@ -174,6 +174,13 @@ export class UI extends Leaf implements IUI {
174
174
  @strokeType(10)
175
175
  public miterLimit: INumber
176
176
 
177
+ // arrow
178
+
179
+ @strokeType('none')
180
+ public startArrow: IArrowType
181
+
182
+ @strokeType('none')
183
+ public endArrow: IArrowType
177
184
 
178
185
  // corner
179
186
 
@@ -251,14 +258,15 @@ export class UI extends Leaf implements IUI {
251
258
 
252
259
  // path
253
260
 
254
- public getPath(curve?: boolean): IPathCommandData {
255
- const { path } = this.__
256
- if (!path) return []
261
+ public getPath(curve?: boolean, pathForRender?: boolean): IPathCommandData {
262
+ this.__layout.update()
263
+ let path = pathForRender ? this.__.__pathForRender : this.__.path
264
+ if (!path) this.__drawPathByBox(new PathCreator(path = []))
257
265
  return curve ? PathConvert.toCanvasData(path, true) : path
258
266
  }
259
267
 
260
- public getPathString(curve?: boolean): IPathString {
261
- return PathConvert.stringify(this.getPath(curve))
268
+ public getPathString(curve?: boolean, pathForRender?: boolean): IPathString {
269
+ return PathConvert.stringify(this.getPath(curve, pathForRender))
262
270
  }
263
271
 
264
272
 
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { IString, INumber, IBoolean, IAround, IHitType, ICursorType, IPointData, IPathCommandData, IPathString, ILeaferCanvas, IPathDrawer, IExportFileType, IRenderOptions, ILeaferImage, ICanvasContext2D, IWindingRule } from '@leafer/interface';
2
2
  import { Leaf } from '@leafer/core';
3
- import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode, IEditSize, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IFindUIMethod, IExportOptions, IExportResult, IGroupData, IGroupInputData, IBox, IBoxData, IOverflow, IBoxInputData, IFrame, IFrameData, IFrameInputData, IRect, IRectData, IRectInputData, IEllipse, IEllipseData, IEllipseInputData, IPolygon, IPolygonData, IPolygonInputData, IStar, IStarData, IStarInputData, ILine, ILineData, ILineInputData, IImage, IImageData, IImageInputData, ICanvas, ICanvasData, ICanvasInputData, IText, ITextData, IHitType as IHitType$1, IFontWeight, ITextCase, ITextDecoration, IUnitData, ITextAlign, IVerticalAlign, ITextWrap, ITextDrawData, ITextInputData, IPath, IPathData, IPathString as IPathString$1, IPathInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPenInputData } from '@leafer-ui/interface';
3
+ import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode, IEditSize, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowType, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IFindUIMethod, IExportOptions, IExportResult, IGroupData, IGroupInputData, IBox, IBoxData, IOverflow, IBoxInputData, IFrame, IFrameData, IFrameInputData, IRect, IRectData, IRectInputData, IEllipse, IEllipseData, IEllipseInputData, IPolygon, IPolygonData, IPolygonInputData, IStar, IStarData, IStarInputData, ILine, ILineData, ILineInputData, IImage, IImageData, IImageInputData, ICanvas, ICanvasData, ICanvasInputData, IText, ITextData, IHitType as IHitType$1, IFontWeight, ITextCase, ITextDecoration, IUnitData, ITextAlign, IVerticalAlign, ITextWrap, ITextDrawData, ITextInputData, IPath, IPathData, IPathString as IPathString$1, IPathInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPenInputData } from '@leafer-ui/interface';
4
4
 
5
5
  declare class UI extends Leaf implements IUI {
6
6
  __: IUIData;
@@ -51,6 +51,8 @@ declare class UI extends Leaf implements IUI {
51
51
  dashPattern: INumber[] | IDashPatternString;
52
52
  dashOffset: INumber;
53
53
  miterLimit: INumber;
54
+ startArrow: IArrowType;
55
+ endArrow: IArrowType;
54
56
  cornerRadius: number | number[] | ICornerRadiusString;
55
57
  cornerSmoothing: INumber;
56
58
  shadow: IShadowEffect | IShadowEffect[] | IShadowString;
@@ -67,8 +69,8 @@ declare class UI extends Leaf implements IUI {
67
69
  createProxyData(): IUIInputData;
68
70
  find(condition: number | string | IFindUIMethod, options?: any): IUI[];
69
71
  findOne(condition: number | string | IFindUIMethod, options?: any): IUI;
70
- getPath(curve?: boolean): IPathCommandData;
71
- getPathString(curve?: boolean): IPathString;
72
+ getPath(curve?: boolean, pathForRender?: boolean): IPathCommandData;
73
+ getPathString(curve?: boolean, pathForRender?: boolean): IPathString;
72
74
  __onUpdateSize(): void;
73
75
  __updateRenderPath(): void;
74
76
  __drawRenderPath(canvas: ILeaferCanvas): void;
@@ -193,7 +195,6 @@ declare class Image extends Rect implements IImage {
193
195
  get ready(): boolean;
194
196
  image: ILeaferImage;
195
197
  constructor(data?: IImageInputData);
196
- __updateBoxBounds(): void;
197
198
  destroy(): void;
198
199
  }
199
200