forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.ts
More file actions
55 lines (47 loc) · 1.09 KB
/
node.ts
File metadata and controls
55 lines (47 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { PropChangeOptions } from "@ali/lowcode-designer";
import EventEmitter from "events";
export default class Node {
private emitter: EventEmitter;
schema: any = {
props: {},
};
hasLoop = false;
constructor(schema: any) {
this.emitter = new EventEmitter();
this.schema = schema;
}
mockLoop() {
this.hasLoop = true;
}
onChildrenChange(fn: any) {
this.emitter.on('onChildrenChange', fn);
return () => {
this.emitter.off('onChildrenChange', fn);
}
}
onPropChange(fn: any) {
this.emitter.on('onPropChange', fn);
return () => {
this.emitter.off('onPropChange', fn);
}
}
emitPropChange(val: PropChangeOptions) {
this.schema.props = {
...this.schema.props,
[val.key + '']: val.newValue,
}
this.emitter?.emit('onPropChange', val);
}
onVisibleChange(fn: any) {
this.emitter.on('onVisibleChange', fn);
return () => {
this.emitter.off('onVisibleChange', fn);
}
}
emitVisibleChange(val: boolean) {
this.emitter?.emit('onVisibleChange', val);
}
export() {
return this.schema;
}
}