@leafer-ui/data 1.0.0-alpha.23 → 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.23",
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.23"
22
+ "@leafer/core": "1.0.0-alpha.30"
23
23
  },
24
24
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-alpha.23",
26
- "@leafer-ui/interface": "1.0.0-alpha.23"
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,27 +19,25 @@ export class UIData extends LeafData implements IUIData {
16
19
  protected _innerShadow?: __Value
17
20
 
18
21
  protected setFill(value: __Value) {
19
- this._fill = value
20
22
  if (typeof value === 'string' || !value) {
21
- if (this.__isFills) this.__isFills = false
22
- } else if (value instanceof Array) {
23
- this.__setInput('fill', value)
24
- this.__isFills = true
23
+ this._fill = value
24
+ if (this.__input) this.__removeInput('fill')
25
+ this.__isFills && (this.__isFills = false)
25
26
  } else if (typeof value === 'object') {
26
- this.__setInput('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
30
  }
29
31
  }
30
32
 
31
33
  protected setStroke(value: __Value) {
32
- this._stroke = value
33
34
  if (typeof value === 'string' || !value) {
34
- if (this.__isStrokes) this.__isStrokes = false
35
- } else if (value instanceof Array) {
36
- this.__setInput('stroke', value)
37
- this.__isStrokes = true
35
+ this._stroke = value
36
+ if (this.__input) this.__removeInput('stroke')
37
+ this.__isStrokes && (this.__isStrokes = false)
38
38
  } else if (typeof value === 'object') {
39
- this.__setInput('stroke', [value])
39
+ this.__setInput('stroke', value)
40
+ this.__leaf.__layout.boxBoundsChanged ? this._stroke = value : Paint.computeStroke(this.__leaf)
40
41
  this.__isStrokes = true
41
42
  }
42
43
  }
@@ -44,17 +45,33 @@ export class UIData extends LeafData implements IUIData {
44
45
  protected setShadow(value: __Value) {
45
46
  if (value instanceof Array) {
46
47
  this._shadow = value
47
- } else {
48
+ } else if (value) {
48
49
  this._shadow = [value]
50
+ } else {
51
+ this._shadow = value
49
52
  }
50
53
  }
51
54
 
52
55
  protected setInnerShadow(value: __Value) {
53
56
  if (value instanceof Array) {
54
57
  this._innerShadow = value
55
- } else {
58
+ } else if (value) {
56
59
  this._innerShadow = [value]
60
+ } else {
61
+ this._shadow = value
57
62
  }
58
63
  }
59
64
 
60
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
+