@leafer-ui/data 1.0.0-alpha.7 → 1.0.0-bate
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 +4 -4
- package/src/BoxData.ts +8 -0
- package/src/CanvasData.ts +8 -0
- package/src/FrameData.ts +2 -2
- package/src/LeaferData.ts +8 -0
- package/src/PathData.ts +7 -1
- package/src/PenData.ts +8 -0
- package/src/TextData.ts +25 -1
- package/src/UIData.ts +47 -30
- package/src/index.ts +5 -5
- package/src/VectorData.ts +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/data",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-bate",
|
|
4
4
|
"description": "@leafer-ui/data",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/core": "1.0.0-
|
|
22
|
+
"@leafer/core": "1.0.0-bate"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@leafer/interface": "1.0.0-
|
|
26
|
-
"@leafer-ui/interface": "1.0.0-
|
|
25
|
+
"@leafer/interface": "1.0.0-bate",
|
|
26
|
+
"@leafer-ui/interface": "1.0.0-bate"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/src/BoxData.ts
ADDED
package/src/FrameData.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IFrameData } from '@leafer-ui/interface'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { BoxData } from './BoxData'
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
export class FrameData extends
|
|
6
|
+
export class FrameData extends BoxData implements IFrameData {
|
|
7
7
|
|
|
8
8
|
}
|
package/src/PathData.ts
CHANGED
|
@@ -12,7 +12,13 @@ export class PathData extends UIData {
|
|
|
12
12
|
protected _path: IPathCommandData
|
|
13
13
|
|
|
14
14
|
protected setPath(value: IPathCommandData | IPathString) {
|
|
15
|
-
|
|
15
|
+
if (typeof value === 'string') {
|
|
16
|
+
this.__setInput('path', value)
|
|
17
|
+
this._path = parse(value)
|
|
18
|
+
} else {
|
|
19
|
+
if (this.__input) this.__removeInput('path')
|
|
20
|
+
this._path = value
|
|
21
|
+
}
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
}
|
package/src/PenData.ts
ADDED
package/src/TextData.ts
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
|
-
import { ITextData } from '@leafer-ui/interface'
|
|
1
|
+
import { IFontWeight, ITextData } from '@leafer-ui/interface'
|
|
2
2
|
|
|
3
3
|
import { UIData } from "./UIData"
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
const fontWeightMap = {
|
|
7
|
+
'thin': 100,
|
|
8
|
+
'extra-light': 200,
|
|
9
|
+
'light': 300,
|
|
10
|
+
'normal': 400,
|
|
11
|
+
'medium': 500,
|
|
12
|
+
'semi-bold': 600,
|
|
13
|
+
'bold': 700,
|
|
14
|
+
'extra-bold': 800,
|
|
15
|
+
'black': 900
|
|
16
|
+
}
|
|
17
|
+
|
|
6
18
|
export class TextData extends UIData implements ITextData {
|
|
7
19
|
|
|
20
|
+
protected _fontWeight?: number
|
|
21
|
+
|
|
22
|
+
setFontWeight(value: IFontWeight): void {
|
|
23
|
+
if (typeof value === 'string') {
|
|
24
|
+
this.__setInput('fontWeight', value)
|
|
25
|
+
this._fontWeight = fontWeightMap[value] || 400
|
|
26
|
+
} else {
|
|
27
|
+
if (this.__input) this.__removeInput('fontWeight')
|
|
28
|
+
this._fontWeight = value
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
8
32
|
}
|
package/src/UIData.ts
CHANGED
|
@@ -1,74 +1,91 @@
|
|
|
1
|
-
import { __Value } from '@leafer/interface'
|
|
1
|
+
import { IBlendMode, __Value } from '@leafer/interface'
|
|
2
2
|
import { LeafData } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { IUIData } from '@leafer-ui/interface'
|
|
4
|
+
import { IShadowEffect, IUI, IUIData, IUnitData } from '@leafer-ui/interface'
|
|
5
|
+
import { Paint } from '@leafer-ui/external'
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
export class UIData extends LeafData implements IUIData {
|
|
8
9
|
|
|
10
|
+
public __leaf: IUI
|
|
11
|
+
|
|
12
|
+
public __blendLayer?: boolean
|
|
13
|
+
public _blendMode: string
|
|
14
|
+
|
|
9
15
|
public __isFills?: boolean
|
|
10
16
|
public __isStrokes?: boolean
|
|
11
17
|
|
|
12
18
|
protected _fill?: __Value
|
|
13
19
|
protected _stroke?: __Value
|
|
14
20
|
|
|
15
|
-
protected _borderWidth?: __Value
|
|
16
|
-
protected _strokeWidth?: number
|
|
17
|
-
|
|
18
21
|
protected _shadow?: __Value
|
|
19
22
|
protected _innerShadow?: __Value
|
|
20
23
|
|
|
21
|
-
protected
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
protected setBlendMode(value: IBlendMode) {
|
|
25
|
+
this._blendMode = value
|
|
26
|
+
if (value === 'pass-through' || !value) {
|
|
27
|
+
if (this.__blendLayer) this.__blendLayer = false
|
|
28
|
+
} else {
|
|
29
|
+
this.__blendLayer = true
|
|
30
|
+
}
|
|
24
31
|
}
|
|
25
32
|
|
|
26
33
|
protected setFill(value: __Value) {
|
|
27
|
-
if (typeof value === 'string') {
|
|
34
|
+
if (typeof value === 'string' || !value) {
|
|
28
35
|
this._fill = value
|
|
29
|
-
if (this.
|
|
30
|
-
|
|
31
|
-
this._fill = value
|
|
32
|
-
this.__isFills = true
|
|
36
|
+
if (this.__input) this.__removeInput('fill')
|
|
37
|
+
this.__isFills && (this.__isFills = false)
|
|
33
38
|
} else if (typeof value === 'object') {
|
|
34
|
-
this.
|
|
39
|
+
this.__setInput('fill', value)
|
|
40
|
+
this.__leaf.__layout.boxChanged ? this._fill = value : Paint.computeFill(this.__leaf)
|
|
35
41
|
this.__isFills = true
|
|
36
|
-
} else {
|
|
37
|
-
this._fill = value
|
|
38
|
-
if (this.__isFills) this.__isFills = false
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
protected setStroke(value: __Value) {
|
|
43
|
-
if (typeof value === 'string') {
|
|
46
|
+
if (typeof value === 'string' || !value) {
|
|
44
47
|
this._stroke = value
|
|
45
|
-
if (this.
|
|
46
|
-
|
|
47
|
-
this._stroke = value
|
|
48
|
-
this.__isStrokes = true
|
|
48
|
+
if (this.__input) this.__removeInput('stroke')
|
|
49
|
+
this.__isStrokes && (this.__isStrokes = false)
|
|
49
50
|
} else if (typeof value === 'object') {
|
|
50
|
-
this.
|
|
51
|
+
this.__setInput('stroke', value)
|
|
52
|
+
this.__leaf.__layout.boxChanged ? this._stroke = value : Paint.computeStroke(this.__leaf)
|
|
51
53
|
this.__isStrokes = true
|
|
52
|
-
} else {
|
|
53
|
-
this._stroke = value
|
|
54
|
-
if (this.__isStrokes) this.__isStrokes = false
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
protected setShadow(value: __Value) {
|
|
58
|
+
this.__setInput('shadow', value)
|
|
59
59
|
if (value instanceof Array) {
|
|
60
|
-
|
|
60
|
+
if (value.some((item: IShadowEffect) => item.visible === false)) value = value.filter((item: IShadowEffect) => item.visible !== false)
|
|
61
|
+
this._shadow = value.length ? value : null
|
|
62
|
+
} else if (value) {
|
|
63
|
+
this._shadow = (value as IShadowEffect).visible === false ? null : [value]
|
|
61
64
|
} else {
|
|
62
|
-
this._shadow =
|
|
65
|
+
this._shadow = null
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
protected setInnerShadow(value: __Value) {
|
|
70
|
+
this.__setInput('innerShadow', value)
|
|
67
71
|
if (value instanceof Array) {
|
|
68
|
-
|
|
72
|
+
if (value.some((item: IShadowEffect) => item.visible === false)) value = value.filter((item: IShadowEffect) => item.visible !== false)
|
|
73
|
+
this._innerShadow = value.length ? value : null
|
|
74
|
+
} else if (value) {
|
|
75
|
+
this._innerShadow = (value as IShadowEffect).visible === false ? null : [value]
|
|
69
76
|
} else {
|
|
70
|
-
this._innerShadow =
|
|
77
|
+
this._innerShadow = null
|
|
71
78
|
}
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
export const UnitConvert = {
|
|
85
|
+
|
|
86
|
+
number(value: number | IUnitData, percentRefer?: number): number {
|
|
87
|
+
if (typeof value === 'object') return value.type === 'percent' ? value.value / 100 * percentRefer : value.value
|
|
88
|
+
return value
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export { UIData } from './UIData'
|
|
1
|
+
export { UIData, UnitConvert } from './UIData'
|
|
3
2
|
export { GroupData } from './GroupData'
|
|
3
|
+
export { BoxData } from './BoxData'
|
|
4
4
|
|
|
5
|
+
export { LeaferData } from './LeaferData'
|
|
5
6
|
export { FrameData } from './FrameData'
|
|
6
7
|
|
|
7
8
|
export { LineData } from './LineData'
|
|
@@ -10,8 +11,7 @@ export { EllipseData } from './EllipseData'
|
|
|
10
11
|
export { PolygonData } from './PolygonData'
|
|
11
12
|
export { StarData } from './StarData'
|
|
12
13
|
export { PathData } from './PathData'
|
|
13
|
-
export {
|
|
14
|
+
export { PenData } from './PenData'
|
|
14
15
|
export { TextData } from './TextData'
|
|
15
16
|
export { ImageData } from './ImageData'
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
export { CanvasData } from './CanvasData'
|