@leafer-ui/data 1.0.0-beta.9 → 1.0.0-rc.2
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 +9 -5
- package/src/UIData.ts +53 -11
- package/types/index.d.ts +78 -0
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/data",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
4
|
"description": "@leafer-ui/data",
|
|
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,10 +22,11 @@
|
|
|
19
22
|
"leaferjs"
|
|
20
23
|
],
|
|
21
24
|
"dependencies": {
|
|
22
|
-
"@leafer/core": "1.0.0-
|
|
25
|
+
"@leafer/core": "1.0.0-rc.2",
|
|
26
|
+
"@leafer-ui/external": "1.0.0-rc.2"
|
|
23
27
|
},
|
|
24
28
|
"devDependencies": {
|
|
25
|
-
"@leafer/interface": "1.0.0-
|
|
26
|
-
"@leafer-ui/interface": "1.0.0-
|
|
29
|
+
"@leafer/interface": "1.0.0-rc.2",
|
|
30
|
+
"@leafer-ui/interface": "1.0.0-rc.2"
|
|
27
31
|
}
|
|
28
32
|
}
|
package/src/UIData.ts
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import { __Value } from '@leafer/interface'
|
|
2
|
-
import { LeafData } from '@leafer/core'
|
|
1
|
+
import { __Number, __Value, __Boolean } from '@leafer/interface'
|
|
2
|
+
import { LeafData, Debug } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { IShadowEffect, IUI, IUIData, IUnitData } from '@leafer-ui/interface'
|
|
4
|
+
import { IShadowEffect, IUI, IUIData, IUnitData, ILeafPaint } from '@leafer-ui/interface'
|
|
5
5
|
import { Paint } from '@leafer-ui/external'
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
const emptyPaint: ILeafPaint = {}
|
|
9
|
+
const debug = Debug.get('UIData')
|
|
8
10
|
export class UIData extends LeafData implements IUIData {
|
|
9
11
|
|
|
10
|
-
public __leaf: IUI
|
|
12
|
+
declare public __leaf: IUI
|
|
11
13
|
|
|
12
14
|
public __blendLayer?: boolean
|
|
13
15
|
|
|
14
16
|
public __isFills?: boolean
|
|
15
17
|
public __isStrokes?: boolean
|
|
16
18
|
|
|
19
|
+
protected _visible?: __Boolean
|
|
20
|
+
|
|
21
|
+
protected _width?: __Number
|
|
22
|
+
protected _height?: __Number
|
|
23
|
+
|
|
17
24
|
protected _fill?: __Value
|
|
18
25
|
protected _stroke?: __Value
|
|
19
26
|
|
|
@@ -21,31 +28,66 @@ export class UIData extends LeafData implements IUIData {
|
|
|
21
28
|
protected _innerShadow?: __Value
|
|
22
29
|
|
|
23
30
|
|
|
31
|
+
protected setVisible(value: __Boolean) {
|
|
32
|
+
if (this.__leaf.leafer) this.__leaf.leafer.watcher.hasVisible = true
|
|
33
|
+
this._visible = value
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected setWidth(value: __Number) {
|
|
37
|
+
if (value < 0) {
|
|
38
|
+
this._width = -value
|
|
39
|
+
this.__leaf.scaleX *= -1
|
|
40
|
+
debug.warn('width < 0, instead -scaleX ', this)
|
|
41
|
+
} else {
|
|
42
|
+
this._width = value
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
protected setHeight(value: __Number) {
|
|
47
|
+
if (value < 0) {
|
|
48
|
+
this._height = -value
|
|
49
|
+
this.__leaf.scaleY *= -1
|
|
50
|
+
debug.warn('height < 0, instead -scaleY', this)
|
|
51
|
+
} else {
|
|
52
|
+
this._height = value
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
24
57
|
protected setFill(value: __Value) {
|
|
58
|
+
if (this.__naturalWidth) this.__naturalWidth = this.__naturalHeight = undefined
|
|
25
59
|
if (typeof value === 'string' || !value) {
|
|
60
|
+
if (this.__isFills) {
|
|
61
|
+
this.__removeInput('fill')
|
|
62
|
+
Paint.recycleImage(this, 'fill')
|
|
63
|
+
this.__isFills = false
|
|
64
|
+
}
|
|
26
65
|
this._fill = value
|
|
27
|
-
if (this.__input) this.__removeInput('fill')
|
|
28
|
-
this.__isFills && (this.__isFills = false)
|
|
29
66
|
} else if (typeof value === 'object') {
|
|
30
67
|
this.__setInput('fill', value)
|
|
31
|
-
this.__leaf.__layout.boxChanged
|
|
68
|
+
this.__leaf.__layout.boxChanged || this.__leaf.__layout.boxChange()
|
|
32
69
|
this.__isFills = true
|
|
70
|
+
this._fill || (this._fill = emptyPaint)
|
|
33
71
|
}
|
|
34
|
-
if (this.__naturalWidth) this.__naturalWidth = this.__naturalHeight = undefined
|
|
35
72
|
}
|
|
36
73
|
|
|
37
74
|
protected setStroke(value: __Value) {
|
|
38
75
|
if (typeof value === 'string' || !value) {
|
|
76
|
+
if (this.__isStrokes) {
|
|
77
|
+
this.__removeInput('stroke')
|
|
78
|
+
Paint.recycleImage(this, 'stroke')
|
|
79
|
+
this.__isStrokes = false
|
|
80
|
+
}
|
|
39
81
|
this._stroke = value
|
|
40
|
-
if (this.__input) this.__removeInput('stroke')
|
|
41
|
-
this.__isStrokes && (this.__isStrokes = false)
|
|
42
82
|
} else if (typeof value === 'object') {
|
|
43
83
|
this.__setInput('stroke', value)
|
|
44
|
-
this.__leaf.__layout.boxChanged
|
|
84
|
+
this.__leaf.__layout.boxChanged || this.__leaf.__layout.boxChange()
|
|
45
85
|
this.__isStrokes = true
|
|
86
|
+
this._stroke || (this._stroke = emptyPaint)
|
|
46
87
|
}
|
|
47
88
|
}
|
|
48
89
|
|
|
90
|
+
|
|
49
91
|
protected setShadow(value: __Value) {
|
|
50
92
|
this.__setInput('shadow', value)
|
|
51
93
|
if (value instanceof Array) {
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { __Boolean, __Number, __Value, IPathCommandData } from '@leafer/interface';
|
|
2
|
+
import { LeafData } from '@leafer/core';
|
|
3
|
+
import { IUIData, IUI, IUnitData, IGroupData, IBoxData, ILeaferData, IFrameData, ILineData, IRectData, IEllipseData, IPolygonData, IStarData, IPathString, IPenData, ITextData, IFontWeight, IImageData, ICanvasData } from '@leafer-ui/interface';
|
|
4
|
+
|
|
5
|
+
declare class UIData extends LeafData implements IUIData {
|
|
6
|
+
__leaf: IUI;
|
|
7
|
+
__blendLayer?: boolean;
|
|
8
|
+
__isFills?: boolean;
|
|
9
|
+
__isStrokes?: boolean;
|
|
10
|
+
protected _visible?: __Boolean;
|
|
11
|
+
protected _width?: __Number;
|
|
12
|
+
protected _height?: __Number;
|
|
13
|
+
protected _fill?: __Value;
|
|
14
|
+
protected _stroke?: __Value;
|
|
15
|
+
protected _shadow?: __Value;
|
|
16
|
+
protected _innerShadow?: __Value;
|
|
17
|
+
protected setVisible(value: __Boolean): void;
|
|
18
|
+
protected setWidth(value: __Number): void;
|
|
19
|
+
protected setHeight(value: __Number): void;
|
|
20
|
+
protected setFill(value: __Value): void;
|
|
21
|
+
protected setStroke(value: __Value): void;
|
|
22
|
+
protected setShadow(value: __Value): void;
|
|
23
|
+
protected setInnerShadow(value: __Value): void;
|
|
24
|
+
}
|
|
25
|
+
declare const UnitConvert: {
|
|
26
|
+
number(value: number | IUnitData, percentRefer?: number): number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
declare class GroupData extends UIData implements IGroupData {
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare class BoxData extends GroupData implements IBoxData {
|
|
33
|
+
get __boxStroke(): boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare class LeaferData extends GroupData implements ILeaferData {
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare class FrameData extends BoxData implements IFrameData {
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
declare class LineData extends UIData implements ILineData {
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare class RectData extends UIData implements IRectData {
|
|
46
|
+
get __boxStroke(): boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare class EllipseData extends UIData implements IEllipseData {
|
|
50
|
+
get __boxStroke(): boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare class PolygonData extends UIData implements IPolygonData {
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare class StarData extends UIData implements IStarData {
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare class PathData extends UIData {
|
|
60
|
+
protected _path: IPathCommandData;
|
|
61
|
+
protected setPath(value: IPathCommandData | IPathString): void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare class PenData extends GroupData implements IPenData {
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare class TextData extends UIData implements ITextData {
|
|
68
|
+
protected _fontWeight?: number;
|
|
69
|
+
setFontWeight(value: IFontWeight): void;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare class ImageData extends RectData implements IImageData {
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
declare class CanvasData extends RectData implements ICanvasData {
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { BoxData, CanvasData, EllipseData, FrameData, GroupData, ImageData, LeaferData, LineData, PathData, PenData, PolygonData, RectData, StarData, TextData, UIData, UnitConvert };
|