@leafer-ui/data 1.0.0-alpha.21 → 1.0.0-alpha.30

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/data",
3
- "version": "1.0.0-alpha.21",
3
+ "version": "1.0.0-alpha.30",
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-alpha.21"
22
+ "@leafer/core": "1.0.0-alpha.30"
23
23
  },
24
24
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-alpha.21",
26
- "@leafer-ui/interface": "1.0.0-alpha.21"
25
+ "@leafer/interface": "1.0.0-alpha.30",
26
+ "@leafer-ui/interface": "1.0.0-alpha.30"
27
27
  }
28
28
  }
package/src/BoxData.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { IBoxData } from '@leafer-ui/interface'
2
+
3
+ import { GroupData } from "./GroupData"
4
+
5
+
6
+ export class BoxData extends GroupData implements IBoxData {
7
+
8
+ }
package/src/FrameData.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { IFrameData } from '@leafer-ui/interface'
2
2
 
3
- import { GroupData } from "./GroupData"
3
+ import { BoxData } from './BoxData'
4
4
 
5
5
 
6
- export class FrameData extends GroupData implements IFrameData {
6
+ export class FrameData extends BoxData implements IFrameData {
7
7
 
8
8
  }
@@ -0,0 +1,8 @@
1
+ import { ILeaferData } from '@leafer-ui/interface'
2
+
3
+ import { GroupData } from './GroupData'
4
+
5
+
6
+ export class LeaferData extends GroupData implements ILeaferData {
7
+
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
- this._path = (typeof value === 'string') ? parse(value) : value
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
@@ -0,0 +1,8 @@
1
+ import { IPenData } from '@leafer-ui/interface'
2
+
3
+ import { GroupData } from './GroupData'
4
+
5
+
6
+ export class PenData extends GroupData implements IPenData {
7
+
8
+ }
package/src/TextData.ts CHANGED
@@ -1,8 +1,30 @@
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._fontWeight = fontWeightMap[value] || 400
25
+ } else {
26
+ this._fontWeight = value
27
+ }
28
+ }
29
+
8
30
  }
package/src/UIData.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  import { __Value } from '@leafer/interface'
2
2
  import { LeafData } from '@leafer/core'
3
3
 
4
- import { IUIData } from '@leafer-ui/interface'
4
+ import { 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
+
9
12
  public __isFills?: boolean
10
13
  public __isStrokes?: boolean
11
14
 
@@ -16,51 +19,59 @@ export class UIData extends LeafData implements IUIData {
16
19
  protected _innerShadow?: __Value
17
20
 
18
21
  protected setFill(value: __Value) {
19
- if (typeof value === 'string') {
20
- this._fill = value
21
- if (this.__isFills) this.__isFills = false
22
- } else if (value instanceof Array) {
22
+ if (typeof value === 'string' || !value) {
23
23
  this._fill = value
24
- this.__isFills = true
24
+ if (this.__input) this.__removeInput('fill')
25
+ this.__isFills && (this.__isFills = false)
25
26
  } else if (typeof value === 'object') {
26
- this._fill = [value]
27
+ this.__setInput('fill', value)
28
+ this.__leaf.__layout.boxBoundsChanged ? this._fill = value : Paint.computeFill(this.__leaf)
27
29
  this.__isFills = true
28
- } else {
29
- this._fill = value
30
- if (this.__isFills) this.__isFills = false
31
30
  }
32
31
  }
33
32
 
34
33
  protected setStroke(value: __Value) {
35
- if (typeof value === 'string') {
36
- this._stroke = value
37
- if (this.__isStrokes) this.__isStrokes = false
38
- } else if (value instanceof Array) {
34
+ if (typeof value === 'string' || !value) {
39
35
  this._stroke = value
40
- this.__isStrokes = true
36
+ if (this.__input) this.__removeInput('stroke')
37
+ this.__isStrokes && (this.__isStrokes = false)
41
38
  } else if (typeof value === 'object') {
42
- this._stroke = [value]
39
+ this.__setInput('stroke', value)
40
+ this.__leaf.__layout.boxBoundsChanged ? this._stroke = value : Paint.computeStroke(this.__leaf)
43
41
  this.__isStrokes = true
44
- } else {
45
- this._stroke = value
46
- if (this.__isStrokes) this.__isStrokes = false
47
42
  }
48
43
  }
49
44
 
50
45
  protected setShadow(value: __Value) {
51
46
  if (value instanceof Array) {
52
47
  this._shadow = value
53
- } else {
48
+ } else if (value) {
54
49
  this._shadow = [value]
50
+ } else {
51
+ this._shadow = value
55
52
  }
56
53
  }
57
54
 
58
55
  protected setInnerShadow(value: __Value) {
59
56
  if (value instanceof Array) {
60
57
  this._innerShadow = value
61
- } else {
58
+ } else if (value) {
62
59
  this._innerShadow = [value]
60
+ } else {
61
+ this._shadow = value
63
62
  }
64
63
  }
65
64
 
66
65
  }
66
+
67
+
68
+
69
+
70
+ export const UnitConvert = {
71
+
72
+ number(value: number | IUnitData, percentRefer?: number): number {
73
+ if (typeof value === 'object') return value.type === 'percent' ? value.value / 100 * percentRefer : value.value
74
+ return value
75
+ }
76
+
77
+ }
package/src/index.ts CHANGED
@@ -1,7 +1,9 @@
1
1
 
2
- export { UIData } from './UIData'
2
+ export { UIData, UnitConvert } from './UIData'
3
3
  export { GroupData } from './GroupData'
4
+ export { BoxData } from './BoxData'
4
5
 
6
+ export { LeaferData } from './LeaferData'
5
7
  export { FrameData } from './FrameData'
6
8
 
7
9
  export { LineData } from './LineData'
@@ -10,8 +12,10 @@ export { EllipseData } from './EllipseData'
10
12
  export { PolygonData } from './PolygonData'
11
13
  export { StarData } from './StarData'
12
14
  export { PathData } from './PathData'
15
+ export { PenData } from './PenData'
13
16
  export { VectorData } from './VectorData'
14
17
  export { TextData } from './TextData'
15
18
  export { ImageData } from './ImageData'
16
19
 
17
20
 
21
+