@leafer/decorator 1.0.0-rc.19 → 1.0.0-rc.20
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 +120 -147
- package/src/index.ts +1 -1
- package/types/index.d.ts +9 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/decorator",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.20",
|
|
4
4
|
"description": "@leafer/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/platform": "1.0.0-rc.
|
|
26
|
-
"@leafer/debug": "1.0.0-rc.
|
|
25
|
+
"@leafer/platform": "1.0.0-rc.20",
|
|
26
|
+
"@leafer/debug": "1.0.0-rc.20"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@leafer/interface": "1.0.0-rc.
|
|
29
|
+
"@leafer/interface": "1.0.0-rc.20"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/data.ts
CHANGED
|
@@ -1,96 +1,90 @@
|
|
|
1
|
-
import { ILeafData, ILeaf, IObject, IValue } from '@leafer/interface'
|
|
1
|
+
import { ILeafData, ILeaf, IObject, IValue, ILeafAttrDescriptor, ILeafAttrDescriptorFn } from '@leafer/interface'
|
|
2
2
|
import { defineKey, getDescriptor } from './object'
|
|
3
3
|
import { Debug } from '@leafer/debug'
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
// name
|
|
7
7
|
|
|
8
|
-
export function
|
|
9
|
-
|
|
8
|
+
export function decorateLeafAttr(defaultValue?: IValue, descriptorFn?: ILeafAttrDescriptorFn) {
|
|
9
|
+
return (target: ILeaf, key: string) => defineLeafAttr(target, key, defaultValue, descriptorFn && descriptorFn(key))
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function attr(partDescriptor?: ILeafAttrDescriptor): ILeafAttrDescriptor {
|
|
13
|
+
return partDescriptor
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export function defineLeafAttr(target: ILeaf, key: string, defaultValue?: IValue, partDescriptor?: ILeafAttrDescriptor): void {
|
|
18
|
+
const defaultDescriptor: ILeafAttrDescriptor = {
|
|
10
19
|
get() { return this.__getAttr(key) },
|
|
11
20
|
set(value: IValue) { this.__setAttr(key, value) },
|
|
12
21
|
configurable: true,
|
|
13
22
|
enumerable: true
|
|
14
23
|
}
|
|
15
|
-
defineKey(target, key, Object.assign(defaultDescriptor,
|
|
24
|
+
defineKey(target, key, Object.assign(defaultDescriptor, partDescriptor || {}))
|
|
16
25
|
defineDataProcessor(target, key, defaultValue)
|
|
17
26
|
}
|
|
18
27
|
|
|
28
|
+
|
|
19
29
|
export function dataType(defaultValue?: IValue) {
|
|
20
|
-
return (
|
|
21
|
-
defineLeafAttr(target, key, defaultValue)
|
|
22
|
-
}
|
|
30
|
+
return decorateLeafAttr(defaultValue)
|
|
23
31
|
}
|
|
24
32
|
|
|
25
|
-
export function positionType(defaultValue?: IValue) {
|
|
26
|
-
return (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
}
|
|
33
|
+
export function positionType(defaultValue?: IValue, checkFiniteNumber?: boolean) {
|
|
34
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
35
|
+
set(value: IValue) {
|
|
36
|
+
this.__setAttr(key, value, checkFiniteNumber)
|
|
37
|
+
this.__layout.matrixChanged || this.__layout.matrixChange()
|
|
38
|
+
}
|
|
39
|
+
}))
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
export function autoLayoutType(defaultValue?: IValue) {
|
|
37
|
-
return (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})
|
|
46
|
-
}
|
|
43
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
44
|
+
set(value: IValue) {
|
|
45
|
+
this.__setAttr(key, value)
|
|
46
|
+
this.__layout.matrixChanged || this.__layout.matrixChange()
|
|
47
|
+
this.__hasAutoLayout = !!value
|
|
48
|
+
if (!this.__local) this.__layout.createLocal()
|
|
49
|
+
}
|
|
50
|
+
}))
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
export function scaleType(defaultValue?: IValue) {
|
|
50
|
-
return (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
57
|
-
}
|
|
53
|
+
export function scaleType(defaultValue?: IValue, checkFiniteNumber?: boolean) {
|
|
54
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
55
|
+
set(value: IValue) {
|
|
56
|
+
this.__setAttr(key, value, checkFiniteNumber)
|
|
57
|
+
this.__layout.scaleChanged || this.__layout.scaleChange()
|
|
58
|
+
}
|
|
59
|
+
}))
|
|
58
60
|
}
|
|
59
61
|
|
|
62
|
+
export function rotationType(defaultValue?: IValue, checkFiniteNumber?: boolean) {
|
|
63
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
64
|
+
set(value: IValue) {
|
|
65
|
+
this.__setAttr(key, value, checkFiniteNumber)
|
|
66
|
+
this.__layout.rotationChanged || this.__layout.rotationChange()
|
|
67
|
+
}
|
|
60
68
|
|
|
61
|
-
|
|
62
|
-
return (target: ILeaf, key: string) => {
|
|
63
|
-
defineLeafAttr(target, key, defaultValue, {
|
|
64
|
-
set(value: IValue) {
|
|
65
|
-
this.__setAttr(key, value)
|
|
66
|
-
this.__layout.rotationChanged || this.__layout.rotationChange()
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
}
|
|
69
|
+
}))
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
export function boundsType(defaultValue?: IValue) {
|
|
74
|
-
return (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
}
|
|
72
|
+
export function boundsType(defaultValue?: IValue, checkFiniteNumber?: boolean) {
|
|
73
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
74
|
+
set(value: IValue) {
|
|
75
|
+
this.__setAttr(key, value, checkFiniteNumber) && doBoundsType(this)
|
|
76
|
+
}
|
|
77
|
+
}))
|
|
82
78
|
}
|
|
83
79
|
|
|
84
80
|
export function naturalBoundsType(defaultValue?: IValue) {
|
|
85
|
-
return (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
})
|
|
93
|
-
}
|
|
81
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
82
|
+
set(value: IValue) {
|
|
83
|
+
this.__setAttr(key, value)
|
|
84
|
+
doBoundsType(this)
|
|
85
|
+
this.__.__removeNaturalSize()
|
|
86
|
+
}
|
|
87
|
+
}))
|
|
94
88
|
}
|
|
95
89
|
|
|
96
90
|
export function doBoundsType(leaf: ILeaf): void {
|
|
@@ -99,29 +93,24 @@ export function doBoundsType(leaf: ILeaf): void {
|
|
|
99
93
|
}
|
|
100
94
|
|
|
101
95
|
export function pathInputType(defaultValue?: IValue) {
|
|
102
|
-
return (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
})
|
|
110
|
-
}
|
|
96
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
97
|
+
set(value: IValue) {
|
|
98
|
+
if (this.__.__pathInputed !== 2) this.__.__pathInputed = value ? 1 : 0
|
|
99
|
+
this.__setAttr(key, value)
|
|
100
|
+
doBoundsType(this)
|
|
101
|
+
}
|
|
102
|
+
}))
|
|
111
103
|
}
|
|
112
104
|
|
|
113
105
|
export const pathType = boundsType
|
|
114
106
|
|
|
115
107
|
|
|
116
108
|
export function affectStrokeBoundsType(defaultValue?: IValue) {
|
|
117
|
-
return (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
})
|
|
124
|
-
}
|
|
109
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
110
|
+
set(value: IValue) {
|
|
111
|
+
this.__setAttr(key, value) && doStrokeType(this)
|
|
112
|
+
}
|
|
113
|
+
}))
|
|
125
114
|
}
|
|
126
115
|
|
|
127
116
|
export function doStrokeType(leaf: ILeaf): void {
|
|
@@ -132,94 +121,78 @@ export function doStrokeType(leaf: ILeaf): void {
|
|
|
132
121
|
export const strokeType = affectStrokeBoundsType
|
|
133
122
|
|
|
134
123
|
export function affectRenderBoundsType(defaultValue?: IValue) {
|
|
135
|
-
return (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
})
|
|
142
|
-
}
|
|
124
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
125
|
+
set(value: IValue) {
|
|
126
|
+
this.__setAttr(key, value)
|
|
127
|
+
this.__layout.renderChanged || this.__layout.renderChange()
|
|
128
|
+
}
|
|
129
|
+
}))
|
|
143
130
|
}
|
|
144
131
|
|
|
145
132
|
export function surfaceType(defaultValue?: IValue) {
|
|
146
|
-
return (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
})
|
|
153
|
-
}
|
|
133
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
134
|
+
set(value: IValue) {
|
|
135
|
+
this.__setAttr(key, value)
|
|
136
|
+
this.__layout.surfaceChanged || this.__layout.surfaceChange()
|
|
137
|
+
}
|
|
138
|
+
}))
|
|
154
139
|
}
|
|
155
140
|
|
|
156
141
|
export function opacityType(defaultValue?: IValue) {
|
|
157
|
-
return (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
})
|
|
164
|
-
}
|
|
142
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
143
|
+
set(value: IValue) {
|
|
144
|
+
this.__setAttr(key, value)
|
|
145
|
+
this.__layout.opacityChanged || this.__layout.opacityChange()
|
|
146
|
+
}
|
|
147
|
+
}))
|
|
165
148
|
}
|
|
166
149
|
|
|
167
150
|
export function sortType(defaultValue?: IValue) {
|
|
168
|
-
return (
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
})
|
|
176
|
-
}
|
|
151
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
152
|
+
set(value: IValue) {
|
|
153
|
+
this.__setAttr(key, value)
|
|
154
|
+
this.__layout.surfaceChanged || this.__layout.surfaceChange()
|
|
155
|
+
this.waitParent(() => { this.parent.__layout.childrenSortChange() })
|
|
156
|
+
}
|
|
157
|
+
}))
|
|
177
158
|
}
|
|
178
159
|
|
|
179
160
|
export function maskType(defaultValue?: IValue) {
|
|
180
|
-
return (
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
})
|
|
188
|
-
}
|
|
161
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
162
|
+
set(value: boolean) {
|
|
163
|
+
this.__setAttr(key, value)
|
|
164
|
+
this.__layout.boxChanged || this.__layout.boxChange()
|
|
165
|
+
this.waitParent(() => { this.parent.__updateMask(value) })
|
|
166
|
+
}
|
|
167
|
+
}))
|
|
189
168
|
}
|
|
190
169
|
|
|
191
170
|
export function eraserType(defaultValue?: IValue) {
|
|
192
|
-
return (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
})
|
|
199
|
-
}
|
|
171
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
172
|
+
set(value: boolean) {
|
|
173
|
+
this.__setAttr(key, value)
|
|
174
|
+
this.waitParent(() => { this.parent.__updateEraser(value) })
|
|
175
|
+
}
|
|
176
|
+
}))
|
|
200
177
|
}
|
|
201
178
|
|
|
202
179
|
export function hitType(defaultValue?: IValue) {
|
|
203
|
-
return (
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
})
|
|
211
|
-
}
|
|
180
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
181
|
+
set(value: IValue) {
|
|
182
|
+
this.__setAttr(key, value)
|
|
183
|
+
if (Debug.showHitView) { this.__layout.surfaceChanged || this.__layout.surfaceChange() }
|
|
184
|
+
if (this.leafer) this.leafer.updateCursor()
|
|
185
|
+
}
|
|
186
|
+
}))
|
|
212
187
|
}
|
|
213
188
|
|
|
214
189
|
export function cursorType(defaultValue?: IValue) {
|
|
215
|
-
return (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
})
|
|
222
|
-
}
|
|
190
|
+
return decorateLeafAttr(defaultValue, (key: string) => attr({
|
|
191
|
+
set(value: IValue) {
|
|
192
|
+
this.__setAttr(key, value)
|
|
193
|
+
if (this.leafer) this.leafer.updateCursor()
|
|
194
|
+
}
|
|
195
|
+
}))
|
|
223
196
|
}
|
|
224
197
|
|
|
225
198
|
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { defineLeafAttr, dataType, positionType, autoLayoutType, boundsType, doBoundsType, naturalBoundsType, affectStrokeBoundsType, doStrokeType, strokeType, affectRenderBoundsType, scaleType, rotationType, surfaceType, opacityType, sortType, maskType, eraserType, hitType, pathType, pathInputType, cursorType, dataProcessor, layoutProcessor, defineDataProcessor } from './data'
|
|
1
|
+
export { defineLeafAttr, decorateLeafAttr, attr, dataType, positionType, autoLayoutType, boundsType, doBoundsType, naturalBoundsType, affectStrokeBoundsType, doStrokeType, strokeType, affectRenderBoundsType, scaleType, rotationType, surfaceType, opacityType, sortType, maskType, eraserType, hitType, pathType, pathInputType, cursorType, dataProcessor, layoutProcessor, defineDataProcessor } from './data'
|
|
2
2
|
export { useModule, rewrite, rewriteAble } from './rewrite'
|
|
3
3
|
export { defineKey, getDescriptor } from './object'
|
|
4
4
|
export { registerUI, registerUIEvent } from './class'
|
package/types/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { ILeaf,
|
|
1
|
+
import { IValue, ILeafAttrDescriptorFn, ILeaf, ILeafAttrDescriptor, IObject, IFunction } from '@leafer/interface';
|
|
2
2
|
|
|
3
|
-
declare function
|
|
3
|
+
declare function decorateLeafAttr(defaultValue?: IValue, descriptorFn?: ILeafAttrDescriptorFn): (target: ILeaf, key: string) => void;
|
|
4
|
+
declare function attr(partDescriptor?: ILeafAttrDescriptor): ILeafAttrDescriptor;
|
|
5
|
+
declare function defineLeafAttr(target: ILeaf, key: string, defaultValue?: IValue, partDescriptor?: ILeafAttrDescriptor): void;
|
|
4
6
|
declare function dataType(defaultValue?: IValue): (target: ILeaf, key: string) => void;
|
|
5
|
-
declare function positionType(defaultValue?: IValue): (target: ILeaf, key: string) => void;
|
|
7
|
+
declare function positionType(defaultValue?: IValue, checkFiniteNumber?: boolean): (target: ILeaf, key: string) => void;
|
|
6
8
|
declare function autoLayoutType(defaultValue?: IValue): (target: ILeaf, key: string) => void;
|
|
7
|
-
declare function scaleType(defaultValue?: IValue): (target: ILeaf, key: string) => void;
|
|
8
|
-
declare function rotationType(defaultValue?: IValue): (target: ILeaf, key: string) => void;
|
|
9
|
-
declare function boundsType(defaultValue?: IValue): (target: ILeaf, key: string) => void;
|
|
9
|
+
declare function scaleType(defaultValue?: IValue, checkFiniteNumber?: boolean): (target: ILeaf, key: string) => void;
|
|
10
|
+
declare function rotationType(defaultValue?: IValue, checkFiniteNumber?: boolean): (target: ILeaf, key: string) => void;
|
|
11
|
+
declare function boundsType(defaultValue?: IValue, checkFiniteNumber?: boolean): (target: ILeaf, key: string) => void;
|
|
10
12
|
declare function naturalBoundsType(defaultValue?: IValue): (target: ILeaf, key: string) => void;
|
|
11
13
|
declare function doBoundsType(leaf: ILeaf): void;
|
|
12
14
|
declare function pathInputType(defaultValue?: IValue): (target: ILeaf, key: string) => void;
|
|
@@ -36,4 +38,4 @@ declare function getDescriptor(object: IObject, name: string): PropertyDescripto
|
|
|
36
38
|
declare function registerUI(): (target: IObject) => void;
|
|
37
39
|
declare function registerUIEvent(): (target: IObject) => void;
|
|
38
40
|
|
|
39
|
-
export { affectRenderBoundsType, affectStrokeBoundsType, autoLayoutType, boundsType, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, eraserType, getDescriptor, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, useModule };
|
|
41
|
+
export { affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, eraserType, getDescriptor, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, useModule };
|