forked from HoikanChan/openui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdsl.py
More file actions
218 lines (200 loc) · 4.01 KB
/
Copy pathdsl.py
File metadata and controls
218 lines (200 loc) · 4.01 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
# TextDSL
TEXT_DSL = """
interface TextDSL {
type: 'text';
properties: {
type?: 'default' | 'markdown' | 'html';
content: string;
};
style?: CSSProperties;
}
"""
# 基础组件DSL定义
BASIC_COMPONENT_DSL = """
{TEXT_DSL}
interface ButtonDSL {
type: 'button';
style?: CSSProperties;
properties?: {
status?: 'default' | 'primary' | 'risk';
disabled?: boolean;
text?: string;
type?: 'default' | 'text';
};
actions?: Action[];
}
interface SelectDSL {
type: 'select';
properties: {
allowClear?: boolean;
options: {
label: string;
value: number | string;
}[];
defaultValue?: number | string;
};
style?: CSSProperties;
}
interface ImageDSL {
type: 'image';
properties: {
type: 'url' | 'base64' | 'svg';
content: string;
};
style?: CSSProperties;
}
interface LinkDSL {
type: 'link';
properties: {
target?: '_self' | '_blank';
href: string;
text?: string;
disabled?: boolean;
download?: string;
};
style?: CSSProperties;
}
interface CardDSL {
type: 'card';
properties: {
tag?: string;
header?: string;
headerAlign?: 'left' | 'center' | 'right';
};
children: DSL[];
style?: CSSProperties;
}
interface ListDSL {
type: 'list';
properties: {
header?: string;
isOrder?: boolean;
};
children: DSL[];
style?: CSSProperties;
}
"""
# 布局组件DSL定义
LAYOUT_COMPONENT_DSL = """
// 水平布局组件
interface HLayoutDSL {
type: 'hLayout';
properties: {
gap?: number;
wrap?: boolean;
};
children: DSL[];
style?: CSSProperties;
}
// 垂直布局组件
interface VLayoutDSL {
type: 'vLayout';
properties?: {
gap?: number;
};
children?: DSL[];
style?: CSSProperties;
actions?: Action[];
}
"""
# 表单组件DSL定义
FORM_COMPONENT_DSL = """
interface FormDSL {
type: 'form';
properties: {
layout?: 'vertical' | 'inline' | 'horizontal';
labelAlign?: 'left' | 'right';
initialValues?: Record<string, unknown>;
fields: {
label: string;
name: string;
rules?: { required: boolean }[];
component: DSL;
}[];
};
}
"""
# 表格组件DSL定义
TABLE_COMPONENT_DSL = """
interface TableDSL {
type: 'table';
properties: {
columns: {
title: string;
field: string;
sortable?: boolean; // 考虑给数值列添加排序功能,但不要给所有列都添加排序功能
filterable?: boolean;
filterOptions?: string[];
customized?: DSL;
format?: 'data' | 'dateTime' | 'time';
tooltip?: boolean;
}[];
};
style?: CSSProperties;
}
"""
# 图表组件DSL定义
PIE_CHART_DSL = """
interface PieChartProperties extends Omit<echarts.EChartsOption, 'title'> {
title?: string;
series?: Array<PieSeriesOption>;
}
interface PieChartDSL {
type: 'pieChart';
properties: PieChartProperties;
data?: { source: number[][] };
style?: CSSProperties;
}
"""
LINE_CHART_DSL = """
interface LineChartProperties extends Omit<echarts.EChartsOption, 'title'> {
title?: string;
series?: Array<LineSeriesOption>;
}
interface LineChartDSL {
type: 'lineChart';
properties: LineChartProperties;
data?: { source: number[][] };
style?: CSSProperties;
}
"""
BAR_CHART_DSL = """
interface BarChartProperties extends Omit<echarts.EChartsOption, 'title'> {
title?: string;
series?: Array<BarSeriesOption>;
}
interface BarChartDSL {
type: 'barChart';
properties: BarChartProperties;
style?: CSSProperties;
}
"""
GAUGE_CHART_DSL = """
interface GaugeChartProperties extends Omit<echarts.EChartsOption, 'title'> {
title?: string;
series?: Array<GaugeSeriesOption>;
}
interface GaugeChartDSL {
type: 'gaugeChart';
properties: GaugeChartProperties;
data?: { source: number[][] };
style?: CSSProperties;
}
"""
# 时间线组件DSL定义
TIMELINE_COMPONENT_DSL = """
interface TimeLineDSL {
type: 'timeLine';
properties: {
title?: string;
id?: string;
};
data: {
content: {
title: string;
children: DSL[];
};
iconType: 'success' | 'error' | 'default';
}[];
}
"""