forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprop.ts
More file actions
94 lines (81 loc) · 1.81 KB
/
prop.ts
File metadata and controls
94 lines (81 loc) · 1.81 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { IProp as InnerProp } from '@alilc/lowcode-designer';
import { IPublicTypeCompositeValue, IPublicEnumTransformStage, IPublicModelProp, IPublicModelNode } from '@alilc/lowcode-types';
import { propSymbol } from '../symbols';
import { Node as ShellNode } from './node';
export class Prop implements IPublicModelProp {
private readonly [propSymbol]: InnerProp;
constructor(prop: InnerProp) {
this[propSymbol] = prop;
}
static create(prop: InnerProp | undefined | null): IPublicModelProp | null {
if (!prop) {
return null;
}
return new Prop(prop);
}
/**
* id
*/
get id(): string {
return this[propSymbol].id;
}
/**
* key 值
* get key of prop
*/
get key(): string | number | undefined {
return this[propSymbol].key;
}
/**
* 返回当前 prop 的路径
*/
get path(): string[] {
return this[propSymbol].path;
}
/**
* 返回所属的节点实例
*/
get node(): IPublicModelNode | null {
return ShellNode.create(this[propSymbol].getNode());
}
/**
* return the slot node (only if the current prop represents a slot)
*/
get slotNode(): IPublicModelNode | null {
return ShellNode.create(this[propSymbol].slotNode);
}
/**
* judge if it is a prop or not
*/
get isProp(): boolean {
return true;
}
/**
* 设置值
* @param val
*/
setValue(val: IPublicTypeCompositeValue): void {
this[propSymbol].setValue(val);
}
/**
* 获取值
* @returns
*/
getValue(): any {
return this[propSymbol].getValue();
}
/**
* 移除值
*/
remove(): void {
this[propSymbol].remove();
}
/**
* 导出值
* @param stage
* @returns
*/
exportSchema(stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Render) {
return this[propSymbol].export(stage);
}
}