@leafer-ui/display 1.0.0-alpha.2 → 1.0.0-alpha.21

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,11 +1,13 @@
1
1
  {
2
2
  "name": "@leafer-ui/display",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.21",
4
4
  "description": "@leafer-ui/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
- "files": ["src"],
8
+ "files": [
9
+ "src"
10
+ ],
9
11
  "repository": {
10
12
  "type": "git",
11
13
  "url": "https://github.com/leaferjs/ui.git"
@@ -13,18 +15,17 @@
13
15
  "homepage": "https://github.com/leaferjs/ui/tree/main/packages/display",
14
16
  "bugs": "https://github.com/leaferjs/ui/issues",
15
17
  "keywords": [
16
- "leaferui",
17
18
  "leafer-ui",
18
19
  "leaferjs"
19
20
  ],
20
21
  "dependencies": {
21
- "@leafer/core": "1.0.0-alpha.1",
22
- "@leafer-ui/data": "1.0.0-alpha.1",
23
- "@leafer-ui/display-module": "1.0.0-alpha.1",
24
- "@leafer-ui/decorator": "1.0.0-alpha.1"
22
+ "@leafer/core": "1.0.0-alpha.21",
23
+ "@leafer-ui/data": "1.0.0-alpha.21",
24
+ "@leafer-ui/display-module": "1.0.0-alpha.21",
25
+ "@leafer-ui/decorator": "1.0.0-alpha.21"
25
26
  },
26
27
  "devDependencies": {
27
- "@leafer/interface": "1.0.0-alpha.1",
28
- "@leafer-ui/interface": "1.0.0-alpha.1"
28
+ "@leafer/interface": "1.0.0-alpha.21",
29
+ "@leafer-ui/interface": "1.0.0-alpha.21"
29
30
  }
30
31
  }
package/src/Ellipse.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { __Number } from '@leafer/interface'
1
2
  import { PathCreator, OneRadian, dataProcessor, pathType, registerUI } from '@leafer/core'
2
3
 
3
4
  import { IEllipse, IEllipseInputData, IEllipseData } from '@leafer-ui/interface'
@@ -6,6 +7,7 @@ import { EllipseData } from '@leafer-ui/data'
6
7
  import { UI } from './UI'
7
8
 
8
9
 
10
+
9
11
  const { PI } = Math
10
12
  const { begin, moveTo, close, ellipse } = PathCreator
11
13
 
@@ -17,13 +19,13 @@ export class Ellipse extends UI implements IEllipse {
17
19
  public __: IEllipseData
18
20
 
19
21
  @pathType(0)
20
- public innerRadius: number
22
+ public innerRadius: __Number
21
23
 
22
24
  @pathType(0)
23
- public startAngle: number
25
+ public startAngle: __Number
24
26
 
25
27
  @pathType(0)
26
- public endAngle: number
28
+ public endAngle: __Number
27
29
 
28
30
  constructor(data?: IEllipseInputData) {
29
31
  super(data)
package/src/Frame.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeaferCanvas, IRenderOptions, ICanvasDrawPath, IBoundsData, IPathCommandData } from '@leafer/interface'
1
+ import { ILeaferCanvas, IRenderOptions, IPathDrawer, IBoundsData, IPathCommandData, __Boolean } from '@leafer/interface'
2
2
  import { BoundsHelper, dataProcessor, boundsType, rewrite, useModule, rewriteAble, registerUI } from '@leafer/core'
3
3
 
4
4
  import { IFrame, IFrameData, IFrameInputData } from '@leafer-ui/interface'
@@ -24,7 +24,7 @@ export class Frame extends Group implements IFrame {
24
24
  public __: IFrameData
25
25
 
26
26
  @boundsType(true)
27
- public clip: boolean
27
+ public clip: __Boolean
28
28
 
29
29
  constructor(data?: IFrameInputData) {
30
30
  super(data)
@@ -33,7 +33,7 @@ export class Frame extends Group implements IFrame {
33
33
  }
34
34
 
35
35
  @rewrite(rect.__drawPathByData)
36
- public __drawPathByData(drawer: ICanvasDrawPath, data: IPathCommandData): void { }
36
+ public __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void { }
37
37
 
38
38
  public __updateBoxBounds(): void {
39
39
  this.__updateRectBoxBounds()
@@ -76,9 +76,9 @@ export class Frame extends Group implements IFrame {
76
76
 
77
77
 
78
78
  @rewrite(rect.__render)
79
- public __renderRect(canvas: ILeaferCanvas, options: IRenderOptions): void { }
79
+ public __renderRect(_canvas: ILeaferCanvas, _options: IRenderOptions): void { }
80
80
 
81
81
  @rewrite(group.__render)
82
- public __renderGroup(canvas: ILeaferCanvas, options: IRenderOptions): void { }
82
+ public __renderGroup(_canvas: ILeaferCanvas, _options: IRenderOptions): void { }
83
83
 
84
84
  }
package/src/Group.ts CHANGED
@@ -21,12 +21,6 @@ export class Group extends UI implements IGroup {
21
21
  this.children = []
22
22
  }
23
23
 
24
- public __updatePath(): void {
25
-
26
- }
27
-
28
- public add(child: IUI, index?: number): void { } // Branch rewrite
29
-
30
24
  public addAt(child: IUI, index: number): void {
31
25
  this.add(child, index)
32
26
  }
@@ -39,6 +33,10 @@ export class Group extends UI implements IGroup {
39
33
  this.add(child, this.children.indexOf(before))
40
34
  }
41
35
 
42
- public remove(child?: IUI): void { } // Branch rewrite
36
+ // Branch rewrite
37
+
38
+ public add(_child: IUI, _index?: number): void { }
39
+
40
+ public remove(_child?: IUI): void { }
43
41
 
44
42
  }
package/src/Image.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { boundsType, dataProcessor, registerUI } from '@leafer/core'
1
+ import { ILeaferImage, __String } from '@leafer/interface'
2
+ import { boundsType, dataProcessor, registerUI, Creator } from '@leafer/core'
2
3
 
3
4
  import { IImage, IImageInputData, IImageData } from '@leafer-ui/interface'
4
5
  import { ImageData } from '@leafer-ui/data'
@@ -13,13 +14,24 @@ export class Image extends Rect implements IImage {
13
14
  public __: IImageData
14
15
 
15
16
  @boundsType('')
16
- public url: string
17
+ public url: __String
17
18
 
18
19
  @boundsType('')
19
- public thumb: string
20
+ public thumb: __String
21
+
22
+ public __image: ILeaferImage
20
23
 
21
24
  constructor(data?: IImageInputData) {
22
25
  super(data)
23
26
  }
24
27
 
28
+ public __updateBoxBounds(): void {
29
+ this.__image = Creator.image(this)
30
+ }
31
+
32
+
33
+ public drawFill(): void {
34
+
35
+ }
36
+
25
37
  }
package/src/Line.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { __Number, IPointData, ITwoPointBoundsData } from '@leafer/interface'
1
+ import { IPointData, ITwoPointBoundsData, __Number } from '@leafer/interface'
2
2
  import { PathCreator, PointHelper, TwoPointBoundsHelper, boundsType, dataProcessor, registerUI } from '@leafer/core'
3
3
 
4
4
  import { ILine, ILineData, ILineInputData } from '@leafer-ui/interface'
@@ -23,20 +23,17 @@ export class Line extends UI implements ILine {
23
23
  @boundsType()
24
24
  public rotation: __Number
25
25
 
26
-
27
- protected __to: IPointData
26
+ protected __toPoint: IPointData
28
27
 
29
28
  public get toPoint(): IPointData {
30
- if (this.__to && !this.__layout.boxBoundsChanged) return this.__to
29
+ if (this.__toPoint && !this.__layout.boxBoundsChanged) return this.__toPoint
31
30
 
32
- const { width, height, rotation } = this.__
31
+ const { width, rotation } = this.__
33
32
  const to: IPointData = { x: 0, y: 0 }
34
33
 
35
34
  if (width) to.x = width
36
- if (height) to.y = height
37
-
38
35
  if (rotation) rotate(to, rotation)
39
- this.__to = to
36
+ this.__toPoint = to
40
37
 
41
38
  return to
42
39
  }
@@ -64,7 +61,7 @@ export class Line extends UI implements ILine {
64
61
 
65
62
  public __updateBoxBounds(): void {
66
63
  setPoint(pointBounds, 0, 0)
67
- addPoint(pointBounds, this.__to.x, this.__to.y)
64
+ addPoint(pointBounds, this.__toPoint.x, this.__toPoint.y)
68
65
  toBounds(pointBounds, this.__layout.boxBounds)
69
66
  }
70
67
 
package/src/Path.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ITwoPointBoundsData, ILeaferCanvas, IPathCommandData } from '@leafer/interface'
1
+ import { ITwoPointBoundsData, ILeaferCanvas, IPathCommandData, IWindingRule } from '@leafer/interface'
2
2
  import { PathHelper, TwoPointBoundsHelper, dataProcessor, pathType, registerUI } from '@leafer/core'
3
3
 
4
- import { IPath, IPathData, IPathInputData, IWindingRule, IPathString } from '@leafer-ui/interface'
4
+ import { IPath, IPathData, IPathInputData, IPathString } from '@leafer-ui/interface'
5
5
  import { PathData } from '@leafer-ui/data'
6
6
 
7
7
  import { UI } from './UI'
package/src/Polygon.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { __Number } from '@leafer/interface'
1
2
  import { PathCreator, dataProcessor, pathType, registerUI } from '@leafer/core'
2
3
 
3
4
  import { IPolygon, IPolygonData, IPolygonInputData } from '@leafer-ui/interface'
package/src/Rect.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICanvasDrawPath, IPathCommandData } from '@leafer/interface'
1
+ import { IPathDrawer, IPathCommandData, __Number } from '@leafer/interface'
2
2
  import { dataProcessor, registerUI, useModule } from '@leafer/core'
3
3
 
4
4
  import { IRect, IRectInputData, IRectData } from '@leafer-ui/interface'
@@ -19,12 +19,10 @@ export class Rect extends UI implements IRect {
19
19
  super(data)
20
20
  }
21
21
 
22
- public __updatePath(): void { }
23
-
24
- public __drawPathByData(drawer: ICanvasDrawPath, data: IPathCommandData): void {
25
- const { width, height, borderRadius } = this.__
26
- if (borderRadius) {
27
- drawer.roundRect(0, 0, width, height, borderRadius)
22
+ public __drawPathByData(drawer: IPathDrawer, _data: IPathCommandData): void {
23
+ const { width, height, cornerRadius } = this.__
24
+ if (cornerRadius) {
25
+ drawer.roundRect(0, 0, width, height, cornerRadius)
28
26
  } else {
29
27
  drawer.rect(0, 0, width, height)
30
28
  }
package/src/Star.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { __Number } from '@leafer/interface'
1
2
  import { PathCreator, dataProcessor, pathType, registerUI } from '@leafer/core'
2
3
 
3
4
  import { IStar, IStarData, IStarInputData } from '@leafer-ui/interface'
@@ -17,10 +18,10 @@ export class Star extends UI implements IStar {
17
18
  public __: IStarData
18
19
 
19
20
  @pathType(5)
20
- public points: number
21
+ public points: __Number
21
22
 
22
23
  @pathType(0.38)
23
- public innerRadius: number
24
+ public innerRadius: __Number
24
25
 
25
26
  constructor(data?: IStarInputData) {
26
27
  super(data)
package/src/Text.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICanvasDrawPath, IPathCommandData } from '@leafer/interface'
1
+ import { IPathDrawer, IPathCommandData, __Boolean, __Number, __String } from '@leafer/interface'
2
2
  import { Platform, boundsType, dataProcessor, registerUI, useModule } from '@leafer/core'
3
3
 
4
4
  import { IText, IFontWeight, ITextCase, ITextDecoration, IPercent, ITextData, ITextInputData } from '@leafer-ui/interface'
@@ -16,19 +16,19 @@ export class Text extends UI implements IText {
16
16
  public __: ITextData
17
17
 
18
18
  @boundsType('')
19
- public content: string
19
+ public content: __String
20
20
 
21
21
  @boundsType('arial')
22
- public fontFamily: string
22
+ public fontFamily: __String
23
23
 
24
24
  @boundsType(12)
25
- public fontSize: number
25
+ public fontSize: __Number
26
26
 
27
27
  @boundsType('normal')
28
28
  public fontWeight: IFontWeight
29
29
 
30
30
  @boundsType(false)
31
- public italic: boolean
31
+ public italic: __Boolean
32
32
 
33
33
  @boundsType('normal')
34
34
  public textCase: ITextCase
@@ -37,26 +37,22 @@ export class Text extends UI implements IText {
37
37
  public textDecoration: ITextDecoration
38
38
 
39
39
  @boundsType()
40
- public letterSpacing: number | IPercent
40
+ public letterSpacing: __Number | IPercent
41
41
 
42
42
  @boundsType()
43
- public lineHeight: number | IPercent
43
+ public lineHeight: __Number | IPercent
44
44
 
45
45
  @boundsType()
46
- public paragraphIndent: number
46
+ public paragraphIndent: __Number
47
47
 
48
48
  @boundsType()
49
- public paragraphSpacing: number
49
+ public paragraphSpacing: __Number
50
50
 
51
51
  constructor(data?: ITextInputData) {
52
52
  super(data)
53
53
  }
54
54
 
55
- public __updatePath(): void {
56
-
57
- }
58
-
59
- public __drawPathByData(drawer: ICanvasDrawPath, data: IPathCommandData): void {
55
+ public __drawPathByData(drawer: IPathDrawer, _data: IPathCommandData): void {
60
56
  const { width, height } = this.__
61
57
  drawer.rect(0, 0, width, height)
62
58
  }
package/src/UI.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ILeaferCanvas, ICanvasDrawPath, IPathCommandData, __Number, __Boolean, __String, IMatrixData, IBoundsData } from '@leafer/interface'
1
+ import { ILeaferCanvas, IPathDrawer, IPathCommandData, IMatrixData, IBoundsData, IHitType, __Number, __Boolean, __String } from '@leafer/interface'
2
2
  import { Leaf, PathHelper, affectEventBoundsType, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, sortType, dataProcessor, useModule, rewrite, rewriteAble } from '@leafer/core'
3
3
 
4
- import { IUI, IShadowEffect, IBlurEffect, IPaint, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IPaintString, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IBorderWidthString, IBorderRadiusString } from '@leafer-ui/interface'
4
+ import { IUI, IShadowEffect, IBlurEffect, IPaint, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IPaintString, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString } from '@leafer-ui/interface'
5
5
  import { effectType } from '@leafer-ui/decorator'
6
6
 
7
7
  import { UIData } from '@leafer-ui/data'
@@ -79,8 +79,20 @@ export class UI extends Leaf implements IUI {
79
79
  @rotationType(0)
80
80
  public skewY: __Number
81
81
 
82
+
83
+ @dataType(false)
82
84
  public draggable: __Boolean
83
85
 
86
+ // hit
87
+ @dataType(true)
88
+ public hittable: __Boolean
89
+
90
+ @dataType('visible')
91
+ public hitType: IHitType
92
+
93
+ @dataType(true)
94
+ public hitChildren: __Boolean
95
+
84
96
  // ---
85
97
 
86
98
 
@@ -100,15 +112,6 @@ export class UI extends Leaf implements IUI {
100
112
  @surfaceType()
101
113
  public fill: IPaint | IPaint[] | IPaintString
102
114
 
103
- // border
104
-
105
- @pathType()
106
- public borderRadius: __Number | __Number[] | IBorderRadiusString
107
-
108
- @affectEventBoundsType(1)
109
- public borderWidth: __Number | __Number[] | IBorderWidthString
110
-
111
-
112
115
  // stroke
113
116
 
114
117
  @affectEventBoundsType()
@@ -118,7 +121,7 @@ export class UI extends Leaf implements IUI {
118
121
  public strokeAlign: IStrokeAlign
119
122
 
120
123
  @affectEventBoundsType(1)
121
- public strokeWidth: __Number
124
+ public strokeWidth: number | number[] | IStrokeWidthString
122
125
 
123
126
  @surfaceType('none')
124
127
  public strokeCap: IStrokeCap
@@ -139,7 +142,7 @@ export class UI extends Leaf implements IUI {
139
142
  // corner
140
143
 
141
144
  @pathType()
142
- public cornerRadius: __Number
145
+ public cornerRadius: number | number[] | ICornerRadiusString
143
146
 
144
147
  @pathType()
145
148
  public cornerSmoothing: __Number
@@ -176,14 +179,15 @@ export class UI extends Leaf implements IUI {
176
179
 
177
180
 
178
181
  public __updateRenderPath(): void {
179
- const { __: data } = this
180
- const { cornerRadius, path } = data
181
- data.__renderPath = cornerRadius && path ? PathHelper.applyCorner(path, cornerRadius, data.cornerSmoothing) : path
182
+ if (this.__.path) {
183
+ const { __: data } = this
184
+ data.__pathForRender = data.cornerRadius ? PathHelper.smoothCorner(data.path, data.cornerRadius, data.cornerSmoothing) : data.path
185
+ }
182
186
  }
183
187
 
184
188
  public __drawRenderPath(canvas: ILeaferCanvas): void {
185
189
  canvas.beginPath()
186
- this.__drawPathByData(canvas, this.__.__renderPath)
190
+ this.__drawPathByData(canvas, this.__.__pathForRender)
187
191
  }
188
192
 
189
193
  public __drawPath(canvas: ILeaferCanvas): void {
@@ -192,6 +196,6 @@ export class UI extends Leaf implements IUI {
192
196
  }
193
197
 
194
198
  @rewrite(PathHelper.drawData)
195
- public __drawPathByData(drawer: ICanvasDrawPath, data: IPathCommandData): void { }
199
+ public __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void { }
196
200
 
197
201
  }