forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskeleton.ts
More file actions
98 lines (89 loc) · 1.98 KB
/
skeleton.ts
File metadata and controls
98 lines (89 loc) · 1.98 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
import {
Skeleton as InnerSkeleton,
IWidgetBaseConfig,
IWidgetConfigArea,
} from '@alilc/lowcode-editor-skeleton';
import { skeletonSymbol } from './symbols';
export default class Skeleton {
private readonly [skeletonSymbol]: InnerSkeleton;
constructor(skeleton: InnerSkeleton) {
this[skeletonSymbol] = skeleton;
}
/**
* 增加一个面板实例
* @param config
* @param extraConfig
* @returns
*/
add(config: IWidgetBaseConfig, extraConfig?: Record<string, any>) {
return this[skeletonSymbol].add(config, extraConfig);
}
/**
* 移除一个面板实例
* @param config
* @returns
*/
remove(config: IWidgetBaseConfig) {
const { area, name } = config;
const skeleton = this[skeletonSymbol];
if (!normalizeArea(area)) return;
skeleton[normalizeArea(area)!].container.remove(name);
}
/**
* 显示面板
* @param name
*/
showPanel(name: string) {
this[skeletonSymbol].getPanel(name)?.show();
}
/**
* 隐藏面板
* @param name
*/
hidePanel(name: string) {
this[skeletonSymbol].getPanel(name)?.hide();
}
/**
* 显示 widget
* @param name
*/
showWidget(name: string) {
this[skeletonSymbol].getWidget(name)?.show();
}
/**
* 隐藏 widget
* @param name
*/
hideWidget(name: string) {
this[skeletonSymbol].getWidget(name)?.hide();
}
}
function normalizeArea(area: IWidgetConfigArea | undefined) {
switch (area) {
case 'leftArea':
case 'left':
return 'leftArea';
case 'rightArea':
case 'right':
return 'rightArea';
case 'topArea':
case 'top':
return 'topArea';
case 'toolbar':
return 'toolbar';
case 'mainArea':
case 'main':
case 'center':
case 'centerArea':
return 'mainArea';
case 'bottomArea':
case 'bottom':
return 'bottomArea';
case 'leftFixedArea':
return 'leftFixedArea';
case 'leftFloatArea':
return 'leftFloatArea';
case 'stages':
return 'stages';
}
}