@leafer-ui/display 1.0.0-beta.9 → 1.0.0-rc.10

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,12 +1,15 @@
1
1
  {
2
2
  "name": "@leafer-ui/display",
3
- "version": "1.0.0-beta.9",
3
+ "version": "1.0.0-rc.10",
4
4
  "description": "@leafer-ui/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
+ "types": "types/index.d.ts",
8
9
  "files": [
9
- "src"
10
+ "src",
11
+ "types",
12
+ "dist"
10
13
  ],
11
14
  "repository": {
12
15
  "type": "git",
@@ -19,14 +22,14 @@
19
22
  "leaferjs"
20
23
  ],
21
24
  "dependencies": {
22
- "@leafer/core": "1.0.0-beta.9",
23
- "@leafer-ui/data": "1.0.0-beta.9",
24
- "@leafer-ui/text": "1.0.0-beta.9",
25
- "@leafer-ui/display-module": "1.0.0-beta.9",
26
- "@leafer-ui/decorator": "1.0.0-beta.9"
25
+ "@leafer/core": "1.0.0-rc.10",
26
+ "@leafer-ui/data": "1.0.0-rc.10",
27
+ "@leafer-ui/display-module": "1.0.0-rc.10",
28
+ "@leafer-ui/decorator": "1.0.0-rc.10",
29
+ "@leafer-ui/external": "1.0.0-rc.10"
27
30
  },
28
31
  "devDependencies": {
29
- "@leafer/interface": "1.0.0-beta.9",
30
- "@leafer-ui/interface": "1.0.0-beta.9"
32
+ "@leafer/interface": "1.0.0-rc.10",
33
+ "@leafer-ui/interface": "1.0.0-rc.10"
31
34
  }
32
35
  }
package/src/Arrow.ts ADDED
@@ -0,0 +1,27 @@
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('none')
18
+ declare public startArrow: IArrowType
19
+
20
+ @strokeType('lines')
21
+ declare public endArrow: IArrowType
22
+
23
+ constructor(data?: IArrowInputData) {
24
+ super(data)
25
+ }
26
+
27
+ }
package/src/Box.ts CHANGED
@@ -1,12 +1,11 @@
1
- import { ILeaferCanvas, IRenderOptions, IPathDrawer, IBoundsData, IPathCommandData, __Boolean } from '@leafer/interface'
1
+ import { ILeaferCanvas, IRenderOptions, IPathDrawer, IBoundsData, IPathCommandData } from '@leafer/interface'
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
@@ -20,10 +19,10 @@ export class Box extends Group implements IBox {
20
19
  public get __tag() { return 'Box' }
21
20
 
22
21
  @dataProcessor(BoxData)
23
- public __: IBoxData
22
+ declare public __: IBoxData
24
23
 
25
24
  @affectRenderBoundsType('show')
26
- public overflow: IOverflow
25
+ declare public overflow: IOverflow
27
26
 
28
27
  constructor(data?: IBoxInputData) {
29
28
  super(data)
@@ -46,7 +45,15 @@ export class Box extends Group implements IBox {
46
45
 
47
46
 
48
47
  @rewrite(rect.__updateBoxBounds)
49
- public __updateBoxBounds(): void { }
48
+ public __updateRectBoxBounds(): void { }
49
+
50
+ public __updateBoxBounds(): void {
51
+ if (this.__.__autoBounds && this.children.length) {
52
+ super.__updateBoxBounds()
53
+ } else {
54
+ this.__updateRectBoxBounds()
55
+ }
56
+ }
50
57
 
51
58
  @rewrite(rect.__updateStrokeBounds)
52
59
  public __updateStrokeBounds(): void { }
package/src/Canvas.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeaferCanvas, ILeaferCanvasConfig, __String, __Number, IRenderOptions, IPointData, ICanvasContext2D, IScreenSizeData, ISizeData, IHitType } from '@leafer/interface'
1
+ import { ILeaferCanvas, ILeaferCanvasConfig, INumber, IRenderOptions, IPointData, ICanvasContext2D, IScreenSizeData, ISizeData, IHitType } from '@leafer/interface'
2
2
  import { Creator, Matrix, Platform, dataProcessor, registerUI, hitType } from '@leafer/core'
3
3
 
4
4
  import { ICanvas, ICanvasData, ICanvasInputData, IUI } from '@leafer-ui/interface'
@@ -14,22 +14,22 @@ export class Canvas extends Rect implements ICanvas {
14
14
  public get __tag() { return 'Canvas' }
15
15
 
16
16
  @dataProcessor(ImageData)
17
- public __: ICanvasData
17
+ declare public __: ICanvasData
18
18
 
19
19
  @resizeType(100)
20
- public width: __Number
20
+ declare public width: INumber
21
21
 
22
22
  @resizeType(100)
23
- public height: __Number
23
+ declare public height: INumber
24
24
 
25
25
  @resizeType(Platform.devicePixelRatio)
26
- public pixelRatio: __Number
26
+ public pixelRatio: INumber
27
27
 
28
28
  @resizeType(true)
29
29
  public smooth: boolean
30
30
 
31
31
  @hitType('all')
32
- public hitFill: IHitType
32
+ declare public hitFill: IHitType
33
33
 
34
34
  public canvas: ILeaferCanvas
35
35
 
@@ -43,18 +43,17 @@ export class Canvas extends Rect implements ICanvas {
43
43
  }
44
44
 
45
45
  public draw(ui: IUI, offset?: IPointData, scale?: number | IPointData, rotation?: number): void {
46
- ui.__layout.checkUpdate()
46
+ ui.__layout.update()
47
47
 
48
- const matrix = new Matrix(ui.__world)
49
- matrix.invert()
48
+ const matrix = new Matrix(ui.__world).invert()
50
49
 
51
50
  const m = new Matrix()
52
51
  if (offset) m.translate(offset.x, offset.y)
53
52
  if (scale) typeof scale === 'number' ? m.scale(scale) : m.scale(scale.x, scale.y)
54
53
  if (rotation) m.rotate(rotation)
55
- matrix.preMultiply(m)
54
+ matrix.multiplyParent(m)
56
55
 
57
- ui.__render(this.canvas, { matrix })
56
+ ui.__render(this.canvas, { matrix: matrix.withScale() })
58
57
  this.paint()
59
58
  }
60
59
 
package/src/Ellipse.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { __Number } from '@leafer/interface'
2
- import { PathCommandDataHelper, dataProcessor, pathType, registerUI } from '@leafer/core'
1
+ import { INumber } from '@leafer/interface'
2
+ import { PathCommandDataHelper, Platform, dataProcessor, pathType, registerUI } from '@leafer/core'
3
3
 
4
4
  import { IEllipse, IEllipseInputData, IEllipseData } from '@leafer-ui/interface'
5
5
  import { EllipseData } from '@leafer-ui/data'
@@ -15,16 +15,16 @@ export class Ellipse extends UI implements IEllipse {
15
15
  public get __tag() { return 'Ellipse' }
16
16
 
17
17
  @dataProcessor(EllipseData)
18
- public __: IEllipseData
18
+ declare public __: IEllipseData
19
19
 
20
20
  @pathType(0)
21
- public innerRadius: __Number
21
+ public innerRadius: INumber
22
22
 
23
23
  @pathType(0)
24
- public startAngle: __Number
24
+ public startAngle: INumber
25
25
 
26
26
  @pathType(0)
27
- public endAngle: __Number
27
+ public endAngle: INumber
28
28
 
29
29
  constructor(data?: IEllipseInputData) {
30
30
  super(data)
@@ -48,9 +48,12 @@ export class Ellipse extends UI implements IEllipse {
48
48
  ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius)
49
49
  moveTo(path, width, ry)
50
50
  }
51
- ellipse(path, rx, ry, rx, ry, 0, 0, 360, true)
51
+ ellipse(path, rx, ry, rx, ry, 0, 360, 0, true)
52
52
  }
53
53
 
54
+ // fix node
55
+ if (Platform.ellipseToCurve) this.__.path = this.getPath(true)
56
+
54
57
  } else {
55
58
 
56
59
  if (startAngle || endAngle) {
package/src/Frame.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { __Boolean } from '@leafer/interface'
2
- import { dataProcessor, registerUI, affectRenderBoundsType } from '@leafer/core'
1
+ import { dataProcessor, registerUI, affectRenderBoundsType, surfaceType } from '@leafer/core'
3
2
 
4
- import { IFrame, IFrameData, IFrameInputData, IOverflow } from '@leafer-ui/interface'
3
+ import { IFrame, IFrameData, IFrameInputData, IFill, IOverflow } from '@leafer-ui/interface'
5
4
  import { FrameData } from '@leafer-ui/data'
6
5
 
7
6
  import { Box } from './Box'
@@ -13,13 +12,16 @@ export class Frame extends Box implements IFrame {
13
12
  public get __tag() { return 'Frame' }
14
13
 
15
14
  @dataProcessor(FrameData)
16
- public __: IFrameData
15
+ declare public __: IFrameData
16
+
17
+ @surfaceType('#FFFFFF')
18
+ declare public fill: IFill
17
19
 
18
20
  @affectRenderBoundsType('hide')
19
- public overflow: IOverflow
21
+ declare public overflow: IOverflow
20
22
 
21
23
  constructor(data?: IFrameInputData) {
22
24
  super(data)
23
- if (!this.__.fill) this.__.fill = '#FFFFFF'
25
+ this.isFrame = true
24
26
  }
25
27
  }
package/src/Group.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Branch, useModule, dataProcessor, registerUI } from '@leafer/core'
1
+ import { IPickOptions, IPickResult, IPointData } from '@leafer/interface'
2
+ import { Branch, useModule, dataProcessor, registerUI, UICreator } from '@leafer/core'
2
3
 
3
- import { IGroup, IGroupData, IGroupInputData, IUI } from '@leafer-ui/interface'
4
+ import { IGroup, IGroupData, IGroupInputData, IUI, IUIInputData } from '@leafer-ui/interface'
4
5
  import { GroupData } from '@leafer-ui/data'
5
6
 
6
7
  import { UI } from './UI'
@@ -13,27 +14,62 @@ export class Group extends UI implements IGroup {
13
14
  public get __tag() { return 'Group' }
14
15
 
15
16
  @dataProcessor(GroupData)
16
- public __: IGroupData
17
+ declare public __: IGroupData
17
18
 
18
- public children: IUI[]
19
-
20
- public set mask(child: IUI) {
21
- if (this.__hasMask) this.__removeMask()
22
- if (child) {
23
- child.isMask = true
24
- this.addAt(child, 0)
25
- }
26
- }
27
- public get mask(): IUI {
28
- return this.children.find(item => item.isMask)
29
- }
19
+ declare public children: IUI[]
30
20
 
31
21
  constructor(data?: IGroupInputData) {
32
22
  super(data)
23
+ this.__setBranch()
24
+ }
25
+
26
+ public __setBranch(): void {
33
27
  this.isBranch = true
34
- this.children = []
28
+ if (!this.children) this.children = []
29
+ }
30
+
31
+ // data
32
+
33
+ public set(data: IUIInputData): void {
34
+ if (data.children) {
35
+ const { children } = data
36
+ delete data.children
37
+
38
+ if (!this.children) {
39
+ this.__setBranch()
40
+ } else {
41
+ this.removeAll(true)
42
+ }
43
+
44
+ super.set(data)
45
+
46
+ let child: IUI
47
+ children.forEach(childData => {
48
+ child = UICreator.get(childData.tag, childData) as IUI
49
+ this.add(child)
50
+ })
51
+
52
+ data.children = children
53
+
54
+ } else {
55
+ super.set(data)
56
+ }
35
57
  }
36
58
 
59
+ public toJSON(): IUIInputData {
60
+ const data = super.toJSON()
61
+ data.children = this.children.map(child => child.toJSON())
62
+ return data
63
+ }
64
+
65
+
66
+ // hit rewrite
67
+
68
+ public pick(_hitPoint: IPointData, _options?: IPickOptions): IPickResult { return undefined }
69
+
70
+
71
+ // add
72
+
37
73
  public addAt(child: IUI, index: number): void {
38
74
  this.add(child, index)
39
75
  }
@@ -50,8 +86,12 @@ export class Group extends UI implements IGroup {
50
86
 
51
87
  public add(_child: IUI, _index?: number): void { }
52
88
 
53
- public remove(_child?: IUI): void { }
89
+ public addMany(..._children: IUI[]): void { }
90
+
91
+ public remove(_child?: IUI, _destroy?: boolean): void { }
92
+
93
+ public removeAll(_destroy?: boolean): void { }
54
94
 
55
- public removeAll(): void { }
95
+ public clear(): void { }
56
96
 
57
97
  }
package/src/Image.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ILeaferImage, __String } from '@leafer/interface'
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'
@@ -13,10 +13,10 @@ export class Image extends Rect implements IImage {
13
13
  public get __tag() { return 'Image' }
14
14
 
15
15
  @dataProcessor(ImageData)
16
- public __: IImageData
16
+ declare public __: IImageData
17
17
 
18
18
  @boundsType('')
19
- public url: __String
19
+ public url: IString
20
20
 
21
21
  public get ready(): boolean { return this.image ? this.image.ready : false }
22
22
 
@@ -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 = { type: 'image', mode: 'strench', url }
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 {