@leafer-ui/data 1.0.0-rc.6 → 1.0.0-rc.8

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-rc.6",
3
+ "version": "1.0.0-rc.8",
4
4
  "description": "@leafer-ui/data",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,11 +22,11 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.0.0-rc.6",
26
- "@leafer-ui/external": "1.0.0-rc.6"
25
+ "@leafer/core": "1.0.0-rc.8",
26
+ "@leafer-ui/external": "1.0.0-rc.8"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.0.0-rc.6",
30
- "@leafer-ui/interface": "1.0.0-rc.6"
29
+ "@leafer/interface": "1.0.0-rc.8",
30
+ "@leafer-ui/interface": "1.0.0-rc.8"
31
31
  }
32
32
  }
package/src/UIData.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { __Number, __Value, __Boolean } from '@leafer/interface'
1
+ import { INumber, IValue, IBoolean } from '@leafer/interface'
2
2
  import { LeafData, Debug } from '@leafer/core'
3
3
 
4
4
  import { IShadowEffect, IUI, IUIData, IUnitData, ILeafPaint } from '@leafer-ui/interface'
@@ -11,7 +11,7 @@ export class UIData extends LeafData implements IUIData {
11
11
 
12
12
  declare public __leaf: IUI
13
13
 
14
- public __blendLayer?: boolean
14
+ public __blendLayer?: boolean // 非元素属性必须以两个下划线开头
15
15
 
16
16
  public __isFills?: boolean
17
17
  public __isStrokes?: boolean
@@ -19,24 +19,28 @@ export class UIData extends LeafData implements IUIData {
19
19
  public __pixelFill?: boolean // png / svg / webp
20
20
  public __pixelStroke?: boolean
21
21
 
22
- protected _visible?: __Boolean
22
+ protected _visible?: IBoolean
23
23
 
24
- protected _width?: __Number
25
- protected _height?: __Number
24
+ protected _width?: INumber
25
+ protected _height?: INumber
26
26
 
27
- protected _fill?: __Value
28
- protected _stroke?: __Value
27
+ protected _fill?: IValue
28
+ protected _stroke?: IValue
29
29
 
30
- protected _shadow?: __Value
31
- protected _innerShadow?: __Value
30
+ protected _shadow?: IValue
31
+ protected _innerShadow?: IValue
32
32
 
33
+ public get __autoWidth() { return !this._width }
34
+ public get __autoHeight() { return !this._height }
35
+ public get __autoBounds() { return !this._width && !this._height }
33
36
 
34
- protected setVisible(value: __Boolean) {
37
+
38
+ protected setVisible(value: IBoolean) {
35
39
  if (this.__leaf.leafer) this.__leaf.leafer.watcher.hasVisible = true
36
40
  this._visible = value
37
41
  }
38
42
 
39
- protected setWidth(value: __Number) {
43
+ protected setWidth(value: INumber) {
40
44
  if (value < 0) {
41
45
  this._width = -value
42
46
  this.__leaf.scaleX *= -1
@@ -46,7 +50,7 @@ export class UIData extends LeafData implements IUIData {
46
50
  }
47
51
  }
48
52
 
49
- protected setHeight(value: __Number) {
53
+ protected setHeight(value: INumber) {
50
54
  if (value < 0) {
51
55
  this._height = -value
52
56
  this.__leaf.scaleY *= -1
@@ -57,7 +61,7 @@ export class UIData extends LeafData implements IUIData {
57
61
  }
58
62
 
59
63
 
60
- protected setFill(value: __Value) {
64
+ protected setFill(value: IValue) {
61
65
  if (this.__naturalWidth) this.__naturalWidth = this.__naturalHeight = undefined
62
66
  if (typeof value === 'string' || !value) {
63
67
  if (this.__isFills) {
@@ -75,7 +79,7 @@ export class UIData extends LeafData implements IUIData {
75
79
  }
76
80
  }
77
81
 
78
- protected setStroke(value: __Value) {
82
+ protected setStroke(value: IValue) {
79
83
  if (typeof value === 'string' || !value) {
80
84
  if (this.__isStrokes) {
81
85
  this.__removeInput('stroke')
@@ -93,7 +97,7 @@ export class UIData extends LeafData implements IUIData {
93
97
  }
94
98
 
95
99
 
96
- protected setShadow(value: __Value) {
100
+ protected setShadow(value: IValue) {
97
101
  this.__setInput('shadow', value)
98
102
  if (value instanceof Array) {
99
103
  if (value.some((item: IShadowEffect) => item.visible === false)) value = value.filter((item: IShadowEffect) => item.visible !== false)
@@ -105,7 +109,7 @@ export class UIData extends LeafData implements IUIData {
105
109
  }
106
110
  }
107
111
 
108
- protected setInnerShadow(value: __Value) {
112
+ protected setInnerShadow(value: IValue) {
109
113
  this.__setInput('innerShadow', value)
110
114
  if (value instanceof Array) {
111
115
  if (value.some((item: IShadowEffect) => item.visible === false)) value = value.filter((item: IShadowEffect) => item.visible !== false)
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { __Boolean, __Number, __Value, IPathCommandData } from '@leafer/interface';
1
+ import { IBoolean, INumber, IValue, IPathCommandData } from '@leafer/interface';
2
2
  import { LeafData } from '@leafer/core';
3
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
4
 
@@ -9,20 +9,23 @@ declare class UIData extends LeafData implements IUIData {
9
9
  __isStrokes?: boolean;
10
10
  __pixelFill?: boolean;
11
11
  __pixelStroke?: boolean;
12
- protected _visible?: __Boolean;
13
- protected _width?: __Number;
14
- protected _height?: __Number;
15
- protected _fill?: __Value;
16
- protected _stroke?: __Value;
17
- protected _shadow?: __Value;
18
- protected _innerShadow?: __Value;
19
- protected setVisible(value: __Boolean): void;
20
- protected setWidth(value: __Number): void;
21
- protected setHeight(value: __Number): void;
22
- protected setFill(value: __Value): void;
23
- protected setStroke(value: __Value): void;
24
- protected setShadow(value: __Value): void;
25
- protected setInnerShadow(value: __Value): void;
12
+ protected _visible?: IBoolean;
13
+ protected _width?: INumber;
14
+ protected _height?: INumber;
15
+ protected _fill?: IValue;
16
+ protected _stroke?: IValue;
17
+ protected _shadow?: IValue;
18
+ protected _innerShadow?: IValue;
19
+ get __autoWidth(): boolean;
20
+ get __autoHeight(): boolean;
21
+ get __autoBounds(): boolean;
22
+ protected setVisible(value: IBoolean): void;
23
+ protected setWidth(value: INumber): void;
24
+ protected setHeight(value: INumber): void;
25
+ protected setFill(value: IValue): void;
26
+ protected setStroke(value: IValue): void;
27
+ protected setShadow(value: IValue): void;
28
+ protected setInnerShadow(value: IValue): void;
26
29
  }
27
30
  declare const UnitConvert: {
28
31
  number(value: number | IUnitData, percentRefer?: number): number;