@leafer-ui/decorator 1.0.0-rc.8 → 1.0.0
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/data.ts +49 -17
- package/src/index.ts +1 -1
- package/types/index.d.ts +7 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/decorator",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "@leafer-ui/decorator",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.0.0
|
|
25
|
+
"@leafer/core": "1.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@leafer/interface": "1.0.0
|
|
29
|
-
"@leafer-ui/interface": "1.0.0
|
|
28
|
+
"@leafer/interface": "1.0.0",
|
|
29
|
+
"@leafer-ui/interface": "1.0.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/data.ts
CHANGED
|
@@ -1,28 +1,60 @@
|
|
|
1
|
-
import { IValue } from '@leafer/interface'
|
|
2
|
-
import {
|
|
1
|
+
import { IStateStyleType, IValue, IObject } from '@leafer/interface'
|
|
2
|
+
import { defineKey, decorateLeafAttr, attr, doStrokeType } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { ICanvas, IUI } from '@leafer-ui/interface'
|
|
4
|
+
import { ICanvas, IUI, IApp } from '@leafer-ui/interface'
|
|
5
|
+
import { State } from '@leafer-ui/external'
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
export function
|
|
8
|
-
return (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
export function stateType(defaultValue?: IValue) {
|
|
9
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
10
|
+
set(value: IValue) {
|
|
11
|
+
this.__setAttr(key, value)
|
|
12
|
+
this.waitLeafer(() => { if (State.setStyle) State.setStyle(this, key + 'Style' as IStateStyleType, value as boolean) })
|
|
13
|
+
}
|
|
14
|
+
}))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function arrowType(defaultValue?: IValue) {
|
|
18
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
19
|
+
set(value: IValue) {
|
|
20
|
+
if (this.__setAttr(key, value)) {
|
|
21
|
+
const data = (this as IUI).__
|
|
22
|
+
data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none'
|
|
23
|
+
doStrokeType(this)
|
|
14
24
|
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
25
|
+
}
|
|
26
|
+
}))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function effectType(defaultValue?: IValue) {
|
|
30
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
31
|
+
set(value: IValue) {
|
|
32
|
+
this.__setAttr(key, value)
|
|
33
|
+
if (value) (this as IUI).__.__useEffect = true
|
|
34
|
+
this.__layout.renderChanged || this.__layout.renderChange()
|
|
35
|
+
}
|
|
36
|
+
}))
|
|
17
37
|
}
|
|
18
38
|
|
|
19
39
|
export function resizeType(defaultValue?: IValue) {
|
|
40
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
41
|
+
set(value: IValue) {
|
|
42
|
+
this.__setAttr(key, value)
|
|
43
|
+
this.__layout.boxChanged || this.__layout.boxChange();
|
|
44
|
+
(this as ICanvas).__updateSize()
|
|
45
|
+
}
|
|
46
|
+
}))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function zoomLayerType() {
|
|
20
50
|
return (target: IUI, key: string) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
51
|
+
const privateKey = '_' + key
|
|
52
|
+
defineKey(target, key, {
|
|
53
|
+
set(value: IUI) { if (this.isLeafer) (this as IObject)[privateKey] = value },
|
|
54
|
+
get() {
|
|
55
|
+
return this.isApp
|
|
56
|
+
? (this as IApp).tree.zoomLayer
|
|
57
|
+
: (this.isLeafer ? ((this as IObject)[privateKey] || this) : this.leafer && this.leafer.zoomLayer)
|
|
26
58
|
}
|
|
27
59
|
})
|
|
28
60
|
}
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { effectType, resizeType } from './data'
|
|
1
|
+
export { stateType, arrowType, effectType, resizeType, zoomLayerType } from './data'
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import * as _leafer_interface from '@leafer/interface';
|
|
1
2
|
import { IValue } from '@leafer/interface';
|
|
2
3
|
import { IUI } from '@leafer-ui/interface';
|
|
3
4
|
|
|
4
|
-
declare function
|
|
5
|
-
declare function
|
|
5
|
+
declare function stateType(defaultValue?: IValue): (target: _leafer_interface.ILeaf, key: string) => void;
|
|
6
|
+
declare function arrowType(defaultValue?: IValue): (target: _leafer_interface.ILeaf, key: string) => void;
|
|
7
|
+
declare function effectType(defaultValue?: IValue): (target: _leafer_interface.ILeaf, key: string) => void;
|
|
8
|
+
declare function resizeType(defaultValue?: IValue): (target: _leafer_interface.ILeaf, key: string) => void;
|
|
9
|
+
declare function zoomLayerType(): (target: IUI, key: string) => void;
|
|
6
10
|
|
|
7
|
-
export { effectType, resizeType };
|
|
11
|
+
export { arrowType, effectType, resizeType, stateType, zoomLayerType };
|