forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetting-prop-entry.ts
More file actions
231 lines (200 loc) · 4.4 KB
/
setting-prop-entry.ts
File metadata and controls
231 lines (200 loc) · 4.4 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import { SettingField, ISetValueOptions } from '@alilc/lowcode-designer';
import { CompositeValue, FieldConfig } from '@alilc/lowcode-types';
import { settingPropEntrySymbol } from './symbols';
import Node from './node';
import SettingTopEntry from './setting-top-entry';
export default class SettingPropEntry {
private readonly [settingPropEntrySymbol]: SettingField;
constructor(prop: SettingField) {
this[settingPropEntrySymbol] = prop;
}
static create(prop: SettingField) {
return new SettingPropEntry(prop);
}
/**
* 获取设置属性的 id
*/
get id() {
return this[settingPropEntrySymbol].id;
}
/**
* 获取设置属性的 name
*/
get name() {
return this[settingPropEntrySymbol].name;
}
/**
* 获取设置属性的 key
*/
get key() {
return this[settingPropEntrySymbol].getKey();
}
/**
* 获取设置属性的 path
*/
get path() {
return this[settingPropEntrySymbol].path;
}
/**
* 获取设置属性的 title
*/
get title() {
return this[settingPropEntrySymbol].title;
}
/**
* 获取设置属性的 setter
*/
get setter() {
return this[settingPropEntrySymbol].setter;
}
/**
* 获取设置属性的 extraProps
*/
get extraProps() {
return this[settingPropEntrySymbol].extraProps;
}
/**
* 获取设置属性对应的节点实例
*/
get node(): Node | null {
return Node.create(this[settingPropEntrySymbol].getNode());
}
/**
* 获取设置属性的父设置属性
*/
get parent(): SettingPropEntry {
return SettingPropEntry.create(this[settingPropEntrySymbol].parent as any);
}
/**
* 是否是 SettingField 实例
*/
get isSettingField(): boolean {
return this[settingPropEntrySymbol].isSettingField;
}
/**
* 设置 key 值
* @param key
*/
setKey(key: string | number) {
this[settingPropEntrySymbol].setKey(key);
}
/**
* @deprecated use .node instead
*/
getNode() {
return this.node;
}
/**
* @deprecated use .parent instead
*/
getParent() {
return this.parent;
}
/**
* 设置值
* @param val 值
*/
setValue(val: CompositeValue, extraOptions?: ISetValueOptions) {
this[settingPropEntrySymbol].setValue(val, false, false, extraOptions);
}
/**
* 设置子级属性值
* @param propName 子属性名
* @param value 值
*/
setPropValue(propName: string | number, value: any) {
this[settingPropEntrySymbol].setPropValue(propName, value);
}
/**
* 清空指定属性值
* @param propName
*/
clearPropValue(propName: string | number) {
this[settingPropEntrySymbol].clearPropValue(propName);
}
/**
* 获取配置的默认值
* @returns
*/
getDefaultValue() {
return this[settingPropEntrySymbol].getDefaultValue();
}
/**
* 获取值
* @returns
*/
getValue() {
return this[settingPropEntrySymbol].getValue();
}
/**
* 获取子级属性值
* @param propName 子属性名
* @returns
*/
getPropValue(propName: string | number) {
return this[settingPropEntrySymbol].getPropValue(propName);
}
/**
* 获取设置属性集
* @returns
*/
getProps() {
return SettingTopEntry.create(this[settingPropEntrySymbol].getProps() as SettingEntry) as any;
}
/**
* 是否绑定了变量
* @returns
*/
isUseVariable() {
return this[settingPropEntrySymbol].isUseVariable();
}
/**
* 设置绑定变量
* @param flag
*/
setUseVariable(flag: boolean) {
this[settingPropEntrySymbol].setUseVariable(flag);
}
/**
* 创建一个设置 field 实例
* @param config
* @returns
*/
createField(config: FieldConfig) {
return SettingPropEntry.create(this[settingPropEntrySymbol].createField(config));
}
/**
* 获取值,当为变量时,返回 mock
* @returns
*/
getMockOrValue() {
return this[settingPropEntrySymbol].getMockOrValue();
}
/**
* 销毁当前 field 实例
*/
purge() {
this[settingPropEntrySymbol].purge();
}
/**
* 移除当前 field 实例
*/
remove() {
this[settingPropEntrySymbol].remove();
}
/**
* 设置 autorun
* @param action
* @returns
*/
onEffect(action: () => void) {
return this[settingPropEntrySymbol].onEffect(action);
}
/**
* 返回 shell 模型,兼容某些场景下 field 已经是 shell field 了
* @returns
*/
internalToShellPropEntry() {
return this;
}
}