forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
138 lines (120 loc) · 3.83 KB
/
types.ts
File metadata and controls
138 lines (120 loc) · 3.83 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
import { ReactElement, ComponentType } from 'react';
import { TitleContent, IconType, I18nData, TipContent } from '@alilc/lowcode-types';
import { IWidget } from './widget/widget';
/**
* 所有可能的停靠位置
*/
export type IWidgetConfigArea =
| 'leftArea' | 'left' | 'rightArea'
| 'right' | 'topArea' | 'top'
| 'toolbar' | 'mainArea' | 'main'
| 'center' | 'centerArea' | 'bottomArea'
| 'bottom' | 'leftFixedArea'
| 'leftFloatArea' | 'stages';
export interface IWidgetBaseConfig {
type: string;
name: string;
/**
* 停靠位置:
* - 当 type 为 'Panel' 时自动为 'leftFloatArea';
* - 当 type 为 'Widget' 时自动为 'mainArea';
* - 其他时候自动为 'leftArea';
*/
area?: IWidgetConfigArea;
props?: Record<string, any>;
content?: any;
contentProps?: Record<string, any>;
// index?: number;
[extra: string]: any;
}
export interface WidgetConfig extends IWidgetBaseConfig {
type: 'Widget';
props?: {
align?: 'left' | 'right' | 'bottom' | 'center' | 'top';
onInit?: (widget: IWidget) => void;
title?: TitleContent;
};
content?: string | ReactElement | ComponentType<any>; // children
}
export function isWidgetConfig(obj: any): obj is WidgetConfig {
return obj && obj.type === 'Widget';
}
export interface DockProps {
title?: TitleContent;
icon?: IconType;
size?: 'small' | 'medium' | 'large';
className?: string;
description?: TipContent;
onClick?: () => void;
}
export interface DividerConfig extends IWidgetBaseConfig {
type: 'Divider';
props?: {
align?: 'left' | 'right' | 'center';
};
}
export function isDividerConfig(obj: any): obj is DividerConfig {
return obj && obj.type === 'Divider';
}
export interface IDockBaseConfig extends IWidgetBaseConfig {
props?: DockProps & {
align?: 'left' | 'right' | 'bottom' | 'center' | 'top';
onInit?: (widget: IWidget) => void;
};
}
export interface DockConfig extends IDockBaseConfig {
type: 'Dock';
content?: string | ReactElement | ComponentType<any>;
}
export function isDockConfig(obj: any): obj is DockConfig {
return obj && /Dock$/.test(obj.type);
}
// 按钮弹窗扩展
export interface DialogDockConfig extends IDockBaseConfig {
type: 'DialogDock';
dialogProps?: {
title?: TitleContent;
[key: string]: any;
};
}
export function isDialogDockConfig(obj: any): obj is DialogDockConfig {
return obj && obj.type === 'DialogDock';
}
// 窗格扩展
export interface PanelConfig extends IWidgetBaseConfig {
type: 'Panel';
content?: string | ReactElement | ComponentType<any> | PanelConfig[]; // as children
props?: PanelProps;
}
export function isPanelConfig(obj: any): obj is PanelConfig {
return obj && obj.type === 'Panel';
}
export type HelpTipConfig = string | { url?: string; content?: string | ReactElement };
export interface PanelProps {
title?: TitleContent;
icon?: any; // 冗余字段
description?: string | I18nData;
hideTitleBar?: boolean; // panel.props 兼容,不暴露
help?: HelpTipConfig; // 显示问号帮助
width?: number; // panel.props
height?: number; // panel.props
maxWidth?: number; // panel.props
maxHeight?: number; // panel.props
condition?: (widget: IWidget) => any;
onInit?: (widget: IWidget) => any;
onDestroy?: () => any;
shortcut?: string; // 只有在特定位置,可触发 toggle show
enableDrag?: boolean; // 是否开启通过 drag 调整 宽度
keepVisibleWhileDragging?: boolean; // 是否在该 panel 范围内拖拽时保持 visible 状态
}
export interface PanelDockConfig extends IDockBaseConfig {
type: 'PanelDock';
panelName?: string;
panelProps?: PanelProps & {
area?: IWidgetConfigArea;
};
content?: string | ReactElement | ComponentType<any> | PanelConfig[]; // content for pane
}
export function isPanelDockConfig(obj: any): obj is PanelDockConfig {
return obj && obj.type === 'PanelDock';
}