lcap-frontend-library 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +271 -0
- package/bin/lcap-frontend-library.mjs +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +27 -0
- package/dist/init.d.ts +6 -0
- package/dist/init.js +79 -0
- package/dist/sync.d.ts +4 -0
- package/dist/sync.js +70 -0
- package/dist/utils.d.ts +19 -0
- package/dist/utils.js +101 -0
- package/package.json +34 -0
- package/packages/lcap-frontend-library/LEARNINGS.md +11 -0
- package/packages/lcap-frontend-library/SKILL.md +86 -0
- package/packages/lcap-frontend-library/commands/migrate.check.md +287 -0
- package/packages/lcap-frontend-library/commands/migrate.green.md +190 -0
- package/packages/lcap-frontend-library/commands/migrate.plan.md +169 -0
- package/packages/lcap-frontend-library/commands/migrate.red.md +160 -0
- package/packages/lcap-frontend-library/commands/migrate.scan.md +151 -0
- package/packages/lcap-frontend-library/commands/migrate.spec.md +144 -0
- package/packages/lcap-frontend-library/commands/migrate.tasks.md +179 -0
- package/packages/lcap-frontend-library/commands/speckit.create.md +201 -0
- package/packages/lcap-frontend-library/commands/speckit.implement.md +88 -0
- package/packages/lcap-frontend-library/commands/speckit.plan.md +79 -0
- package/packages/lcap-frontend-library/commands/speckit.self-check.md +177 -0
- package/packages/lcap-frontend-library/commands/speckit.specify.md +91 -0
- package/packages/lcap-frontend-library/commands/speckit.tasks.md +61 -0
- package/packages/lcap-frontend-library/references/frontend-design/LICENSE.txt +177 -0
- package/packages/lcap-frontend-library/references/frontend-design/SKILL.md +42 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/SKILL.md +360 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/api.md +331 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/block.md +160 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/i18n.md +95 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/icon.md +27 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/ide/container.md +728 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/ide/element.md +312 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/ide/expression.md +154 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/ide/index.md +113 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/ide/modal.md +189 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/ide/popover.md +171 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/ide.md +799 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/implementation-rules.md +242 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/index.md +27 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/nasl-view-component.md +895 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/platform/accessibility.md +185 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/platform/child.md +82 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/platform/data-source.md +261 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/platform/event.md +171 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/platform/form.md +266 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/platform/function.md +80 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/platform/link.md +137 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/platform/slot.md +128 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/platform/theme-variables-ant-design.md +1470 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/platform/theme-variables-cloud-ui.md +259 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/platform/theme-variables-element-plus.md +580 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/platform/theme-variables-element-ui.md +1007 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/platform/theme-variables-mobile-ui.md +85 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/theme.md +234 -0
- package/packages/lcap-frontend-library/references/lcap-extension-component/workflow-guardrails.md +328 -0
- package/packages/lcap-frontend-library/references/nasl-logic-authoring/SKILL.md +201 -0
- package/packages/lcap-frontend-library/scripts/bash/create-component-files.sh +95 -0
- package/packages/lcap-frontend-library/scripts/bash/create-extension-project.sh +109 -0
- package/packages/lcap-frontend-library/scripts/bash/create-logic-files.sh +149 -0
- package/packages/lcap-frontend-library/scripts/bash/create-spec.sh +109 -0
- package/packages/lcap-frontend-library/scripts/bash/get-available-port.sh +35 -0
- package/packages/lcap-frontend-library/scripts/bash/list-specs.sh +19 -0
- package/packages/lcap-frontend-library/scripts/node/setup-extension-project.mjs +166 -0
- package/packages/lcap-frontend-library/templates/component-self-check.md +31 -0
- package/packages/lcap-frontend-library/templates/component-template.md +96 -0
- package/packages/lcap-frontend-library/templates/library-report-template.md +52 -0
- package/packages/lcap-frontend-library/templates/logic-template.md +44 -0
- package/packages/lcap-frontend-library/templates/migration-manifest-template.md +84 -0
- package/packages/lcap-frontend-library/templates/migration-plan-template.md +138 -0
- package/packages/lcap-frontend-library/templates/migration-report-template.md +227 -0
- package/packages/lcap-frontend-library/templates/migration-spec-template.md +135 -0
- package/packages/lcap-frontend-library/templates/migration-tasks-template.md +129 -0
- package/packages/lcap-frontend-library/templates/plan-template.md +299 -0
- package/packages/lcap-frontend-library/templates/self-check-report-template.md +148 -0
- package/packages/lcap-frontend-library/templates/tasks-template.md +81 -0
- package/packages/lcap-frontend-library/workflows/create/flow.md +199 -0
- package/packages/lcap-frontend-library/workflows/evolve/flow.md +249 -0
- package/packages/lcap-frontend-library/workflows/generate/flow.md +10 -0
- package/packages/lcap-frontend-library/workflows/harness/flow.md +82 -0
- package/packages/lcap-frontend-library/workflows/migrate/flow.md +302 -0
- package/packages/lcap-frontend-library/workflows/migrate/knowledge-base.md +564 -0
|
@@ -0,0 +1,799 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# IDE页面设计器适配说明
|
|
6
|
+
开发者通过在 api.ts 配置 ideusage 将组件接入设计器,从而定制设计器内置的翻译器行为。
|
|
7
|
+
|
|
8
|
+
{data-zoomable}
|
|
9
|
+
|
|
10
|
+
设计器内部的翻译结果可以通过在控制台打印预览:
|
|
11
|
+
|
|
12
|
+
通过在浏览器控制台输入 `window.__$dev_runtime__ = true` 来开启当前设计器内的代码输出,以便组件配置与目标代码进行比对。
|
|
13
|
+
|
|
14
|
+
下文以 vue 模板为例,展示配置和翻译器生层代码的匹配关系。React 相似。
|
|
15
|
+
|
|
16
|
+
## 1. 前提条件
|
|
17
|
+
* PC端 - IDE `3.10` 以上版本
|
|
18
|
+
* H5端 - IDE `3.11` 以上版本
|
|
19
|
+
* React 应用
|
|
20
|
+
|
|
21
|
+
## 2. 组件配置说明
|
|
22
|
+
|
|
23
|
+
接入的组件分为以下几种类型:
|
|
24
|
+
|
|
25
|
+
* element (默认) :无法再插入子节点的原子组件
|
|
26
|
+
* container :可以插入子节点的容器组件
|
|
27
|
+
* modal :弹窗类组件
|
|
28
|
+
* drawer :抽屉类组件
|
|
29
|
+
* messager :消息弹出类组件
|
|
30
|
+
* popover :一些弹出框类组件
|
|
31
|
+
* router :路由组件
|
|
32
|
+
* board : 自由布局组件
|
|
33
|
+
|
|
34
|
+
开发者可以通过配置 `idetype` 来指定组件的类型,以element类型为例:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
@ExtensionComponent({
|
|
38
|
+
ideusage: {
|
|
39
|
+
idetype: "element"
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 公用配置
|
|
45
|
+
开发者可以为组件指定的公用配置如下:
|
|
46
|
+
|
|
47
|
+
* (选配)forceRefresh: “self” | “parent” ,组件在画布内移动后,强制刷新自己或者父组件
|
|
48
|
+
* (选配)forceUpdateWhenAttributeChange: boolean ,组件改变属性后,强制刷新自己
|
|
49
|
+
* (选配)ignoreProperty: Array[string],不需要翻译的属性名
|
|
50
|
+
|
|
51
|
+
### element 配置
|
|
52
|
+
|
|
53
|
+
类型为 `element` 的组件无法插入子组件,是不可再分的原子组件。
|
|
54
|
+
|
|
55
|
+
#### 示例-文本组件
|
|
56
|
+
以 CloudUI 的文本组件 `u-text` 为例:`u-text` 具有 props 属性,其具体形式为 `{ text: string }` 。
|
|
57
|
+
|
|
58
|
+
参考配置要求:
|
|
59
|
+
|
|
60
|
+
* 将该组件归类为 element 类型的组件;
|
|
61
|
+
* 可以通过双击编辑 text 字段;
|
|
62
|
+
* text 字段支持在示例文本和表达式之间切换。
|
|
63
|
+
|
|
64
|
+
参考配置书写:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
@ExtensionComponent({
|
|
68
|
+
"ideusage": {
|
|
69
|
+
"idetype": "element",
|
|
70
|
+
"editable": "text",
|
|
71
|
+
"textholder": "text",
|
|
72
|
+
"useFxOrEg":{"property": "text"}
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
这段配置会生成的vue模板如下:
|
|
78
|
+
|
|
79
|
+
```html
|
|
80
|
+
<u-text data-nodepath="6ac1466240c84a3cbf0f45b5da7c93a4"
|
|
81
|
+
text="普通文本"
|
|
82
|
+
key="component-6ac1466240c84a3cbf0f45b5da7c93a4"
|
|
83
|
+
data-editable="true" >
|
|
84
|
+
</u-text>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
通过该模板生成html节点如下:
|
|
88
|
+
|
|
89
|
+
```html
|
|
90
|
+
<span vusion-slot-name-edit="text"
|
|
91
|
+
class="u-text__yjhV4gf0"
|
|
92
|
+
data-nodepath="6ac1466240c84a3cbf0f45b5da7c93a4"
|
|
93
|
+
data-editable="true">
|
|
94
|
+
普通文本
|
|
95
|
+
</span>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
> 需要注意的点:
|
|
99
|
+
>
|
|
100
|
+
> * 组件内需要将 data-* 的属性透传到生成的DOM节点上
|
|
101
|
+
> * 组件插槽需要支持设计器内置的 `EmptySlot` 组件和普通html dom元素
|
|
102
|
+
|
|
103
|
+
#### 配置项说明
|
|
104
|
+
|
|
105
|
+
* (选配)editable: 可被编辑的属性名
|
|
106
|
+
* (选配)textholder:显示文本的属性名
|
|
107
|
+
* (选配)`translateBindingProperty: Array[string]`,可以显示绑定变量的属性名
|
|
108
|
+
|
|
109
|
+
以 CloudUI 的 u-select 组件组件为例:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
@ExtensionComponent({
|
|
113
|
+
ideusage: {
|
|
114
|
+
"idetype": "container",
|
|
115
|
+
"structured": true,
|
|
116
|
+
"childAccept": "['u-select-item', 'u-select-group', 'u-select-divider'].includes(target.tag)",
|
|
117
|
+
"events": {
|
|
118
|
+
"click": true
|
|
119
|
+
},
|
|
120
|
+
"translateBindingProperty": ["value", "placeholder"]
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
在IDE中用户在 placeholder 上绑定了变量
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
生成的组件代码如下:
|
|
129
|
+
|
|
130
|
+
```html
|
|
131
|
+
<u-select data-nodepath="29d12b2924dc4217ae60dceb991e38a6"
|
|
132
|
+
data-enable-events="click"
|
|
133
|
+
:clearable="true"
|
|
134
|
+
:placeholder="'{{ variable1 }}'"
|
|
135
|
+
:pageSize="50"
|
|
136
|
+
:emptyValueIsNull="true"
|
|
137
|
+
textField="text"
|
|
138
|
+
valueField="value"
|
|
139
|
+
class="" key="component-29d12b2924dc4217ae60dceb991e38a6">
|
|
140
|
+
|
|
141
|
+
</u-select>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
`translateBindingProperty` 指定的属性,在绑定变量时,可以传入平台内置的、转为字符串的属性字符串。
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
* (选配)`iconEditor:boolean`, 支持双击打开icon面板并设置icon
|
|
149
|
+
|
|
150
|
+
* (选配)`parentAccept`: 可以放入的父组件判断表达式
|
|
151
|
+
|
|
152
|
+
* (选配)`additionalAttribute`:设计器内组件展示时额外传入的属性, 为 ``{ key: value }`` 形式。需要注意,这里传入的键值对将直接放入模板翻译结果,需要对 " 等特殊符号做转义。
|
|
153
|
+
|
|
154
|
+
* (选配)`useFxOrEg: { property: string, displayAsAttr?: boolean }` 支持表达式和示例切换,property是支持的属性名,displayAsAttr 表示组件是否支持内部插入子元素
|
|
155
|
+
|
|
156
|
+
* (选配)`events`: 设计器内支持的事件,为 ``{ key: value }`` 形式。
|
|
157
|
+
|
|
158
|
+
* `key`: 事件名称,目前支持 `click` 或 `mousedown`
|
|
159
|
+
|
|
160
|
+
* `value`: 生效条件,支持 `true`, `false`, 及表达式
|
|
161
|
+
|
|
162
|
+
* (选配)`elementSutando`: 设计器中的替代组件
|
|
163
|
+
|
|
164
|
+
* `component`: 组件名
|
|
165
|
+
* (选配)`condition`: 使用替代组件的条件表达式
|
|
166
|
+
* (选配)`selector`: `{ slot: string, cssSelector: string }`
|
|
167
|
+
|
|
168
|
+
### container 配置
|
|
169
|
+
类型为 `container` 的组件可以插入子节点。
|
|
170
|
+
|
|
171
|
+
#### 示例-卡片组件
|
|
172
|
+
以 CloudUI 的卡片组件 `u-card` 为例。
|
|
173
|
+
|
|
174
|
+
参考配置要求:
|
|
175
|
+
|
|
176
|
+
* 组件包含三个插槽;
|
|
177
|
+
* 禁止自动插入插槽。
|
|
178
|
+
|
|
179
|
+
参考配置书写:
|
|
180
|
+
|
|
181
|
+
由于 `disableSlotAutoFill` 配置了不自动插入槽位的插槽名,所以设计器只会自动在 `default` 和 `title` 插槽下插入可置入组件的槽位。
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
@ExtensionComponent({
|
|
185
|
+
ideusage: {
|
|
186
|
+
idetype: "container",
|
|
187
|
+
"disableSlotAutoFill": ["cover"]
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
export class UCardOptions extends ViewComponentOptions {
|
|
191
|
+
// ...
|
|
192
|
+
@Slot({
|
|
193
|
+
title: 'undefined',
|
|
194
|
+
description: '插入默认的元素',
|
|
195
|
+
})
|
|
196
|
+
slotDefault: () => Array<ViewComponent>;
|
|
197
|
+
|
|
198
|
+
@Slot({
|
|
199
|
+
title: '图片',
|
|
200
|
+
description: '插入图片',
|
|
201
|
+
})
|
|
202
|
+
slotCover: () => Array<ViewComponent>;
|
|
203
|
+
|
|
204
|
+
@Slot({
|
|
205
|
+
title: '标题',
|
|
206
|
+
description: '插入文本或 HTML。',
|
|
207
|
+
})
|
|
208
|
+
slotTitle: () => Array<ViewComponent>;
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
这段配置生成的vue模板如下:
|
|
213
|
+
|
|
214
|
+
```html
|
|
215
|
+
<u-card data-nodepath="c3f682566bb94d12ad71144c80d858d8" key="component-c3f682566bb94d12ad71144c80d858d8">
|
|
216
|
+
<EmptySlot data-emptyslot-nodepath="c3f682566bb94d12ad71144c80d858d8"></EmptySlot>
|
|
217
|
+
<template slot="title">
|
|
218
|
+
<div data-nodepath="22e902143270453796cd6d94ee2f0e91">
|
|
219
|
+
<EmptySlot data-emptyslot-nodepath="22e902143270453796cd6d94ee2f0e91"></EmptySlot>
|
|
220
|
+
</div>
|
|
221
|
+
</template>
|
|
222
|
+
</u-card>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
> 需要注意的点:
|
|
226
|
+
> * 组件内需要将 data-* 的属性透传到生成的DOM节点上
|
|
227
|
+
> * 组件插槽需要支持设计器内置的 EmptySlot 组件和普通html dom元素
|
|
228
|
+
|
|
229
|
+
#### 示例-数据表格组件
|
|
230
|
+
|
|
231
|
+
在一些特殊情况中,container类型的组件无法将 `data-*` 的属性透传到生成的DOM节点上。以 CloudUI 的 表格列 `u-tableview-column` 为例。
|
|
232
|
+
|
|
233
|
+
参考配置要求:
|
|
234
|
+
|
|
235
|
+
* 在IDE中可以完整的选中表格列。
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
参考配置书写:
|
|
240
|
+
|
|
241
|
+
组件分为表头和表格内容,为了能够同时选中表格头个表格内容,设计器提供了 selector 配置项,配置项通过向指定的插槽注入内置组件 HoistNodePath ,从而将 data-*的属性复制到上层 cssSelector 可以匹配的 dom 元素。
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
@ExtensionComponent({
|
|
247
|
+
"ideusage": {
|
|
248
|
+
"idetype": "container",
|
|
249
|
+
"selector": [
|
|
250
|
+
{
|
|
251
|
+
"expression": "this.getElement(el => el.slotTarget === 'title')",
|
|
252
|
+
"cssSelector": "th"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"expression": "this.getElement(el => el.slotTarget === 'cell')",
|
|
256
|
+
"cssSelector": "td"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"expression": "this.getElement(el => el.slotTarget === 'expand-content')",
|
|
260
|
+
"cssSelector": "tr[class^='u-table-view_expand-content']"
|
|
261
|
+
}
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
})
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
这段配置生成的vue模板如下:
|
|
268
|
+
|
|
269
|
+
```html
|
|
270
|
+
<u-table-view-column field="entity1.updatedTime" key="component-613a75d05eb04790969d9fd1532eb5ab">
|
|
271
|
+
<template #cell={...argus}>
|
|
272
|
+
<HoistNodePath nodePath="613a75d05eb04790969d9fd1532eb5ab" topSelector="td" data-nodepath-multiple="true">
|
|
273
|
+
</HoistNodePath>
|
|
274
|
+
<div data-nodepath="55b20ff830b84a2bb1e4640a2c51496c">
|
|
275
|
+
<EmptySlot data-emptyslot-nodepath="55b20ff830b84a2bb1e4640a2c51496c"></EmptySlot>
|
|
276
|
+
</div>
|
|
277
|
+
</template>
|
|
278
|
+
<template #editcell={...argus}>
|
|
279
|
+
<div data-nodepath="530ebd475ab742d5a7967376ae5132d7">
|
|
280
|
+
<EmptySlot data-emptyslot-nodepath="530ebd475ab742d5a7967376ae5132d7"></EmptySlot>
|
|
281
|
+
</div>
|
|
282
|
+
</template>
|
|
283
|
+
<template slot="title">
|
|
284
|
+
<HoistNodePath nodePath="613a75d05eb04790969d9fd1532eb5ab" topSelector="th" data-nodepath-multiple="true">
|
|
285
|
+
</HoistNodePath>
|
|
286
|
+
<div data-nodepath="a556e6e3851b40578d12022f4d4e1ca3">
|
|
287
|
+
<EmptySlot data-emptyslot-nodepath="a556e6e3851b40578d12022f4d4e1ca3"></EmptySlot>
|
|
288
|
+
</div>
|
|
289
|
+
</template>
|
|
290
|
+
<template #expand-content={...argus}>
|
|
291
|
+
<HoistNodePath nodePath="613a75d05eb04790969d9fd1532eb5ab"
|
|
292
|
+
topSelector="tr[class^='u-table-view_expand-content']" data-nodepath-multiple="true"></HoistNodePath>
|
|
293
|
+
<div data-nodepath="f5b3b0b27b6f43d7806d82ccd97660e2">
|
|
294
|
+
<EmptySlot data-emptyslot-nodepath="f5b3b0b27b6f43d7806d82ccd97660e2"></EmptySlot>
|
|
295
|
+
</div>
|
|
296
|
+
</template>
|
|
297
|
+
<template #expander={...argus}>
|
|
298
|
+
<div data-nodepath="67149ae2ebd6428d89646a6fdc0c6905"><u-table-view-expander
|
|
299
|
+
data-nodepath="cdd6d65d372149e994debc85c0969b85" data-enable-events="click"
|
|
300
|
+
key="component-cdd6d65d372149e994debc85c0969b85" :item="argus.item"></u-table-view-expander></div>
|
|
301
|
+
</template>
|
|
302
|
+
</u-table-view-column>
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
#### 示例-表单组件
|
|
306
|
+
|
|
307
|
+
设计器还提供了通过 `+` 来添加子组件的功能。以 CloudUI 的表单组件 `u-form` 为例。
|
|
308
|
+
|
|
309
|
+
参考配置要求:
|
|
310
|
+
|
|
311
|
+
* 在IDE中可以选中表单添加表单分组和表单项。
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
参考配置书写:
|
|
315
|
+
|
|
316
|
+
通过配置 `structured` 属性,配合 `slot` 配置中的 `snippets` 来配置子组件添加模板。
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
@ExtensionComponent({
|
|
320
|
+
"ideusage": {
|
|
321
|
+
"idetype": "container",
|
|
322
|
+
"structured": true
|
|
323
|
+
}
|
|
324
|
+
})
|
|
325
|
+
export class UFormGroupOptions extends ViewComponentOptions {
|
|
326
|
+
...
|
|
327
|
+
@Slot({
|
|
328
|
+
title: 'undefined',
|
|
329
|
+
description: '插入`<u-form-item>`子组件。',
|
|
330
|
+
emptyBackground: 'add-sub-large',
|
|
331
|
+
snippets: [
|
|
332
|
+
{
|
|
333
|
+
title: '表单分组',
|
|
334
|
+
code: '<u-form-group><template #title><u-text text="分组"></u-text></template><u-form-item><template #label><u-text text="表单项"></u-text></template></u-form-item></u-form-group>',
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
title: '表单项',
|
|
338
|
+
code: '<u-form-item><template #label><u-text text="表单项"></u-text></template></u-form-item>',
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
})
|
|
342
|
+
slotDefault: () => Array<ViewComponent>;
|
|
343
|
+
...
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
> `structure`: `true` 表示 `snippet` 插入到 `default` 插槽内;
|
|
348
|
+
>
|
|
349
|
+
> `structure`: `slotname` 表示 `snippet` 插入到 `slotname` 插槽内;
|
|
350
|
+
>
|
|
351
|
+
> `structure`: `{ slot: “slotname”, empty: true }` 表示即使空态也有槽位展示。
|
|
352
|
+
|
|
353
|
+
#### 示例-单选组组件
|
|
354
|
+
|
|
355
|
+
当具有 `dataSource` 属性的组件接入时,需要配置 `dataSource` 的展示形式。以 CloudUI 的单选组组件 `u-radios` 为例。
|
|
356
|
+
|
|
357
|
+
参考配置要求:
|
|
358
|
+
|
|
359
|
+
* 支持设置数据源。
|
|
360
|
+
* 支持在绑定数据源后拖拽插入子组件,使子组件动态展示。
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
参考配置书写:
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
@ExtensionComponent({
|
|
368
|
+
"ideusage": {
|
|
369
|
+
"idetype": "container",
|
|
370
|
+
"structured": true,
|
|
371
|
+
"dataSource": {
|
|
372
|
+
"dismiss": "!this.getAttribute('dataSource') && this.getDefaultElements().length > 0",
|
|
373
|
+
"display": 3,
|
|
374
|
+
"loopRule": "nth-child(n+2)",
|
|
375
|
+
"loopElem": "> label[class^='u-radios_radio']:not([data-nodepath])"
|
|
376
|
+
},
|
|
377
|
+
// ...
|
|
378
|
+
}
|
|
379
|
+
})
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
这段配置生成的vue模板,及相关css样式如下:
|
|
383
|
+
|
|
384
|
+
```html
|
|
385
|
+
<u-radios data-nodepath="e19ce4d016414bada1b05a96b7157963"
|
|
386
|
+
key="component-e19ce4d016414bada1b05a96b7157963"
|
|
387
|
+
:dataSource="[{},{},{}]"
|
|
388
|
+
class="ide-style1">
|
|
389
|
+
<template #item={...argus}>
|
|
390
|
+
<div data-nodepath="9474b8caced5485da6f788e1745d02ee">
|
|
391
|
+
<EmptySlot data-emptyslot-nodepath="9474b8caced5485da6f788e1745d02ee"></EmptySlot>
|
|
392
|
+
</div>
|
|
393
|
+
</template>
|
|
394
|
+
</u-radios>
|
|
395
|
+
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
> 需要注意的是:
|
|
399
|
+
>
|
|
400
|
+
> 组件的 `dataSource` 需要支持传入 `[{}, {}, {}]` 形态的数据,`display: 3` 表示展示3个 `{}`
|
|
401
|
+
> loopRule 和 loopElem 用于拼接生成的 css 选择器,用于给后面几项的展示增加样式。
|
|
402
|
+
> dismiss 是当指定条件下,忽略dataSource的设置,即不传入 [{}, {}, {}],也不增加css样式。
|
|
403
|
+
>
|
|
404
|
+
> 空态可由slot的配置emptyBackground生效,目前支持 `add-sub` 与 `add-sub-large`。
|
|
405
|
+
>
|
|
406
|
+
|
|
407
|
+
#### 配置项说明
|
|
408
|
+
|
|
409
|
+
* (选配)`containerDirection`: 容器内部排列方向表达式
|
|
410
|
+
|
|
411
|
+
* (选配)`translateBindingProperty`:`Array[string]`,可以显示绑定变量的属性名
|
|
412
|
+
|
|
413
|
+
* (选配)`elementSutando`: 设计器中的替代组件
|
|
414
|
+
|
|
415
|
+
* `component`: 组件名
|
|
416
|
+
* (选配)`condition`: 使用替代组件的条件表达式
|
|
417
|
+
* (选配)`dataSource`:具有数据源的组件可设置。具体示例请参考上文示例-单选组组件。
|
|
418
|
+
|
|
419
|
+
* (选配)`dismiss`:忽略 `datasource` 的条件表达式
|
|
420
|
+
|
|
421
|
+
* `display`:在设计器中展示的条数
|
|
422
|
+
|
|
423
|
+
* `displayData`: 设计器中该组件传入的 `datasource` 的值,如果设置了,`display`就不生效了。
|
|
424
|
+
|
|
425
|
+
* `loopElem`:该组件循环的具体DOM节点的css选择器
|
|
426
|
+
|
|
427
|
+
* `emptySlot`: 没有绑定数据源时的占位设置
|
|
428
|
+
|
|
429
|
+
* `condition`:使用占位组件的条件
|
|
430
|
+
* (选配)`component`: 占位的组件名称
|
|
431
|
+
* `accept`:可置入的目标表达式
|
|
432
|
+
* (选配)`display`: 如果使用了默认的占位组件的样式,可能的值为:`inline`,`block`,默认 `block`
|
|
433
|
+
* (选配)`parentAccept`: 可以放入的父组件判断表达式
|
|
434
|
+
* (选配)`childAccept`,表达式或者对象形式。
|
|
435
|
+
|
|
436
|
+
* 表达式形式:
|
|
437
|
+
```json
|
|
438
|
+
"childAccept": "target.tag === 'Radio'",
|
|
439
|
+
```
|
|
440
|
+
* 对象形式,key为slot中配置的名字,value是表达式
|
|
441
|
+
```json
|
|
442
|
+
"childAccept": {
|
|
443
|
+
"default": "this.getDefaultElements().length < 1",
|
|
444
|
+
"menuItem": "target.tag === 'MenuItem'"
|
|
445
|
+
}
|
|
446
|
+
```
|
|
447
|
+
* (选配)`selector`:若存在无法将 `data-nodepath` 传入顶层DOM节点,则可以通过设置此项绕行,绕行是通过向具体组件内部放入一个能够根据css选择器向上查找DOM节点的组件X。为对象或者数组形式。具体示例请参考上文示例-数据表格组件。
|
|
448
|
+
* `expression`: 从当前节点查找塞入组件X的位置
|
|
449
|
+
* `cssSelector`: X组件所使用的css选择器
|
|
450
|
+
|
|
451
|
+
* (选配)`structured`: `true / false | { slot: string, empty?: boolean }`,当前组件的子组件的插入方式,`true`表示通过设计器内菜单中"+"插入,`false`表示通过拖拽插入,`empty`可以配置是否为此节点插入插槽。如果在 `slotDefinitions` 中配置了 `emptyBackground`,则优先展示 `emptyBackground`。具体示例请参考上文示例-表单组件。
|
|
452
|
+
|
|
453
|
+
* (选配)`events`: 设计器内支持的事件,为 `{ key: value }` 形式。
|
|
454
|
+
|
|
455
|
+
* `key`: 事件名称,目前支持 `click` 或 `mousedown`
|
|
456
|
+
* `value`: 生效条件,支持 `true`, `false`, 及表达式
|
|
457
|
+
|
|
458
|
+
* (选配)`additionalAttribute`:设计器内组件展示时额外传入的属性, 为 `{ key: value }` 形式。
|
|
459
|
+
|
|
460
|
+
* (选配)`displaySlotConditions`:左侧结构树上条件展示插槽节点,为 `{ key: value }` 形式。不配置的插槽名称默认都展示,即为 `true`
|
|
461
|
+
* `key`: 插槽名称,同 `slots` 配置下的 `name` 属性
|
|
462
|
+
* `value`: 插槽展示条件,支持 `true`, `false`, 及表达式
|
|
463
|
+
|
|
464
|
+
以 react antd 的组件 menuitem 为例:该配置描述了当 lableIsSlot 这个属性值为 true 的时候,labelSlot 这个槽位才会展示在结构树上。
|
|
465
|
+
|
|
466
|
+
```json
|
|
467
|
+
"displaySlotConditions": {
|
|
468
|
+
"labelSlot": "this.getAttribute('labelIsSlot').value === true"
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
* (选配)`namedSlotOmitWrapper`:`boolean`,插槽不翻译DIV外包裹。
|
|
473
|
+
|
|
474
|
+
* (选配)`slotWrapperInlineStyle`:传入插槽外包裹的样式,例如:
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
其中 `file-list` 是 `slot` 的名字。
|
|
478
|
+
```json
|
|
479
|
+
"slotWrapperInlineStyle": {
|
|
480
|
+
"file-list": "display:flex"
|
|
481
|
+
}
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
* (选配)`slotInlineStyle`:插槽的样式,为 `{ key: value }` 形式。例如:分栏布局组件的布局栏高度。
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
其中 `default` 是 `slot`的名字。
|
|
488
|
+
|
|
489
|
+
```json
|
|
490
|
+
"slotInlineStyle": {
|
|
491
|
+
"default": "height:100%;"
|
|
492
|
+
}
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
* (选配)`displaySlotInline`:插槽外包裹使用行内样式的条件,`{ key: value }` 形式。例如:单选组的选项。
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
```json
|
|
500
|
+
"displaySlotInline": {
|
|
501
|
+
"item": true
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
* (选配)`disableSlotAutoFill`:`string | { slot: string, expression?: expression, fill?: expression }`,禁止自动插入插槽,可配置插槽名称,生效条件,替换的内容,例如:
|
|
506
|
+
|
|
507
|
+
```json
|
|
508
|
+
"disableSlotAutoFill": [{
|
|
509
|
+
"slot": "title",
|
|
510
|
+
"expression": "this.getAttribute('title')",
|
|
511
|
+
"fill": "this.getAttribute('title').value"
|
|
512
|
+
}],
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
* (选配)`useTemplateInDefaultSlot`:`boolean`,标识可以支持名为 `default` 的插槽为单个NASL节点
|
|
516
|
+
|
|
517
|
+
* (选配)`expandWhenHesitate`:`boolean`,悬停可撑开
|
|
518
|
+
|
|
519
|
+
* (选配)`iconEditor`:`boolean`, 支持双击打开icon面板并设置icon
|
|
520
|
+
|
|
521
|
+
* (选配)`operator`: `{ copy?:expression, cut?: expression, duplicate?: expression, d2c?: expression }` 支持的操作配置,不配默认全支持,`expression` 为生效的条件
|
|
522
|
+
|
|
523
|
+
* (选配)`useFxOrEg`: `{ property: string, displayAsAttr?: boolean }` 支持表达式和示例切换,`property`是支持的属性名,`displayAsAttr` 表示组件支不支持内部插入子元素
|
|
524
|
+
|
|
525
|
+
### modal | drawer | messager 配置
|
|
526
|
+
|
|
527
|
+
类型为 `modal`、 `drawer`、 `messager` 的组件分别对应了弹窗、抽屉、弹出消息三种组件:
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
#### 示例-弹窗组件
|
|
532
|
+
|
|
533
|
+
以 CloudUI 的弹窗为例:
|
|
534
|
+
|
|
535
|
+
```typescript
|
|
536
|
+
@ExtensionComponent({
|
|
537
|
+
"ideusage": {
|
|
538
|
+
"idetype": "modal",
|
|
539
|
+
"selector": {
|
|
540
|
+
"expression": "this.getElement(el => el.slotTarget === 'body')",
|
|
541
|
+
"cssSelector": "div[class^='u-modal_dialog']"
|
|
542
|
+
},
|
|
543
|
+
"cacheOpenKey": "visible",
|
|
544
|
+
...
|
|
545
|
+
}
|
|
546
|
+
})
|
|
547
|
+
```
|
|
548
|
+
这段配置会生成如下模板代码:
|
|
549
|
+
|
|
550
|
+
```html
|
|
551
|
+
<u-modal key="component-0318bd77736b4ec48ac739ec78ff55ba" :visible="true">
|
|
552
|
+
<template slot="title">
|
|
553
|
+
<div data-nodepath="734cd0e5ed8943f8b24493a2b04cd7f6">
|
|
554
|
+
<EmptySlot data-emptyslot-nodepath="734cd0e5ed8943f8b24493a2b04cd7f6"></EmptySlot>
|
|
555
|
+
</div>
|
|
556
|
+
</template>
|
|
557
|
+
<template slot="body">
|
|
558
|
+
<HoistNodePath nodePath="0318bd77736b4ec48ac739ec78ff55ba" topSelector="div[class^='u-modal_dialog']">
|
|
559
|
+
</HoistNodePath>
|
|
560
|
+
<div data-nodepath="ec5a186379744599a5d5ecfcf5322fb4">
|
|
561
|
+
<EmptySlot data-emptyslot-nodepath="ec5a186379744599a5d5ecfcf5322fb4"></EmptySlot>
|
|
562
|
+
</div>
|
|
563
|
+
</template>
|
|
564
|
+
<template slot="foot">
|
|
565
|
+
<div data-nodepath="c3b7f6018e9746db9c6bd4dfef063a71">
|
|
566
|
+
<EmptySlot data-emptyslot-nodepath="c3b7f6018e9746db9c6bd4dfef063a71"></EmptySlot>
|
|
567
|
+
</div>
|
|
568
|
+
</template>
|
|
569
|
+
<template slot="heading">
|
|
570
|
+
<div data-nodepath="b08d6c6b2552461eac38cfdf037e49a0">
|
|
571
|
+
<EmptySlot data-emptyslot-nodepath="b08d6c6b2552461eac38cfdf037e49a0"></EmptySlot>
|
|
572
|
+
</div>
|
|
573
|
+
</template>
|
|
574
|
+
<EmptySlot data-emptyslot-nodepath="0318bd77736b4ec48ac739ec78ff55ba"></EmptySlot>
|
|
575
|
+
</u-modal>
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
> `HoistNodePath` 从 body slot 内,向上注入 `data-*` 属性到能匹配 `div[class^=‘u-modal_dialog’]` 的dom元素上。
|
|
579
|
+
|
|
580
|
+
#### 配置项说明
|
|
581
|
+
|
|
582
|
+
* (选配)`parentAccept`: 可以放入的父组件判断表达式
|
|
583
|
+
* (选配)`childAccept`,表达式或者对象形式。
|
|
584
|
+
* `selector`:若存在无法将 `data-nodepath` 传入顶层DOM节点,则可以通过设置此项绕行,绕行是通过向具体组件内部op一个能够根据css选择器向上查找DOM节点的组件X。
|
|
585
|
+
* `expression`: 从当前节点查找塞入组件X的位置
|
|
586
|
+
* `cssSelector`: X组件所使用的css选择器
|
|
587
|
+
* (选配)`modalSutando`:设计器中的占位组件
|
|
588
|
+
* `additionalAttribute`:设计器内组件展示时额外传入的属性, 为 { key: value } 形式。
|
|
589
|
+
* `cacheOpenKey`: 控制弹窗显隐的字段
|
|
590
|
+
* `useFeedbackWrapper`:渲染时,使用额外的div包裹组件
|
|
591
|
+
* `feedbackAliaName`:出现在反馈框内的名称
|
|
592
|
+
|
|
593
|
+
> 可以在设计器内,通过双击打开组件弹窗,通过关闭按钮关闭当前弹窗。
|
|
594
|
+
>
|
|
595
|
+
> 弹窗类组件必须配置 `selector`,用于选中弹窗组件本身,否则将出现无法拖入组件,关闭按钮出不来的问题。
|
|
596
|
+
>
|
|
597
|
+
> 另外还需要设置 `cacheOpenKey`,用于向弹窗组件传递开关状态,值为属性名称。
|
|
598
|
+
|
|
599
|
+
### popover 配置
|
|
600
|
+
类型为 `popover` 的组件为弹出框类的组件,这类组件一般分为两部分,触发弹出框和框体本身,触发部分一般不带本身的dom元素,以子组件的dom元素为触发事件来源。
|
|
601
|
+
|
|
602
|
+
#### 示例-下拉菜单组件
|
|
603
|
+
|
|
604
|
+
以 react 的下拉菜单组件 Dropdown 为例:
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
```typescript
|
|
609
|
+
@ExtensionComponent({
|
|
610
|
+
"ideusage": {
|
|
611
|
+
"idetype": "popover",
|
|
612
|
+
"structured": true,
|
|
613
|
+
"namedSlotOmitWrapper": ["menuItem"],
|
|
614
|
+
"childAccept": {
|
|
615
|
+
"default": "this.getDefaultElements().length < 1",
|
|
616
|
+
"menuItem": "target.tag === 'MenuItem'"
|
|
617
|
+
},
|
|
618
|
+
"additionalAttribute": {
|
|
619
|
+
"menu": "{{ triggerSubMenuAction: 'click' }}",
|
|
620
|
+
"trigger": "{['click']}"
|
|
621
|
+
},
|
|
622
|
+
}
|
|
623
|
+
})
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
翻译后的模板为:
|
|
627
|
+
|
|
628
|
+
```jsx
|
|
629
|
+
<Dropdown key="component-7ce766fcfbea49b2a4e05497bda00fc5"
|
|
630
|
+
menu={{ triggerSubMenuAction: 'click' }}
|
|
631
|
+
trigger={['click']}
|
|
632
|
+
menuItem={(()=> (<>
|
|
633
|
+
<MenuItem data-nodepath="905aaedc246942ab960e37dac8c04456"
|
|
634
|
+
data-anonymous-nodepath="de07f9185b2b4143b8df73699f7a8214" label="导航项目" path="https://www.baidu.com"
|
|
635
|
+
key="component-905aaedc246942ab960e37dac8c04456" labelSlot={(()=> (<>
|
|
636
|
+
<div data-nodepath="bb28a4999c1748e08c4f2c67dbd1316e">
|
|
637
|
+
<EmptySlot data-emptyslot-nodepath="bb28a4999c1748e08c4f2c67dbd1316e"></EmptySlot>
|
|
638
|
+
</div>
|
|
639
|
+
</>))()} ></MenuItem>
|
|
640
|
+
<MenuItem data-nodepath="f63421583fac4df78ecd8aa45a35488a"
|
|
641
|
+
data-anonymous-nodepath="de07f9185b2b4143b8df73699f7a8214" label="导航项目2"
|
|
642
|
+
key="component-f63421583fac4df78ecd8aa45a35488a" labelSlot={(()=> (<>
|
|
643
|
+
<div data-nodepath="3a69cfcc46124eb299b760f70d29f807">
|
|
644
|
+
<EmptySlot data-emptyslot-nodepath="3a69cfcc46124eb299b760f70d29f807"></EmptySlot>
|
|
645
|
+
</div>
|
|
646
|
+
</>))()} ></MenuItem>
|
|
647
|
+
</>))()} >
|
|
648
|
+
<Link data-nodepath="9cc435699e93484e80bfaa584e637567"
|
|
649
|
+
data-anonymous-nodepath="7ce766fcfbea49b2a4e05497bda00fc5"
|
|
650
|
+
data-enable-interaction={bindref}
|
|
651
|
+
data-enable-events="click"
|
|
652
|
+
icon="RiArrowDownSLine"
|
|
653
|
+
children="按钮"
|
|
654
|
+
key="component-9cc435699e93484e80bfaa584e637567"
|
|
655
|
+
data-editable="true">
|
|
656
|
+
</Link>
|
|
657
|
+
</Dropdown>
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
> 由于Dropdown没有自己对应的dom元素,所以通过 `data-anonymous-nodepath` 附着在了内部的Link上,Dropdown的 menuItem 只接受 MenuItem 组件,所以通过 `namedSlotOmitWrapper` 去除了原本会注入的外层div元素。
|
|
661
|
+
|
|
662
|
+
#### 配置项说明
|
|
663
|
+
* (选配)`parentAccept`: 可以放入的父组件判断表达式
|
|
664
|
+
* (选配)`childAccept`,表达式或者对象形式。
|
|
665
|
+
* (选配)`selector`:若存在无法将 `data-nodepath` 传入顶层DOM节点,则可以通过设置此项绕行,绕行是通过向具体组件内部放入一个能够根据css选择器向上查找DOM节点的组件X。为对象或者数组形式。
|
|
666
|
+
* `expression`: 从当前节点查找塞入组件X的位置
|
|
667
|
+
* `cssSelector`: X组件所使用的css选择器
|
|
668
|
+
* (选配)`placement`: `‘head’ | ‘tail’`,插入组件X的位置,默认是’head’
|
|
669
|
+
* (选配)`structured`: `true / false`,当前组件的子组件的插入方式,`true`时只能通过设置的`snippet`增加子元素,`false`为通过拖拽插入
|
|
670
|
+
* (选配)`additionalAttribute`:设计器内组件展示时额外传入的属性, 为 `{ key: value }` 形式。
|
|
671
|
+
|
|
672
|
+
## 3. 表达式API说明
|
|
673
|
+
表达式分为两种:
|
|
674
|
+
|
|
675
|
+
1. 带`target`参数:`parentAccept`、`childAccept`、`accept`配置项
|
|
676
|
+
2. 不带`target`参数:其他的表达式
|
|
677
|
+
|
|
678
|
+
表示内部通过 `this` 来指向自己,`this`上定义了一系列的属性和API:
|
|
679
|
+
|
|
680
|
+
```typescript
|
|
681
|
+
type Attribute {
|
|
682
|
+
name: string,
|
|
683
|
+
value: any
|
|
684
|
+
}
|
|
685
|
+
class Element {
|
|
686
|
+
// 处于的slot名称
|
|
687
|
+
slotTarget: string
|
|
688
|
+
|
|
689
|
+
// 获取当前的参数
|
|
690
|
+
getAttribute: (attrname: string) => Attribute
|
|
691
|
+
|
|
692
|
+
// 根据条件获取子元素
|
|
693
|
+
getElement: (filter: (el: Element) => boolean) => ?Element
|
|
694
|
+
// 根据条件过滤子元素
|
|
695
|
+
filterElement: (filter: (el: Element) => boolean) => Element[]
|
|
696
|
+
// 获得父节点
|
|
697
|
+
getParent: () => Element
|
|
698
|
+
// 子节点个数
|
|
699
|
+
elementsLength: () => number
|
|
700
|
+
|
|
701
|
+
// 获取祖先节点
|
|
702
|
+
getAncestor: (tag: string) => ?Element
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
class Target {
|
|
706
|
+
// 对应到nasl节点的concept
|
|
707
|
+
concept: string;
|
|
708
|
+
// 目标的 tag 属性
|
|
709
|
+
tag: string;
|
|
710
|
+
}
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
### 示例一
|
|
714
|
+
这段表达了Flex是一个container,他的containerDirecion由当前设计器内设置的direction属性值决定。
|
|
715
|
+
|
|
716
|
+
```json
|
|
717
|
+
{
|
|
718
|
+
"name": "Flex",
|
|
719
|
+
"ideusage": {
|
|
720
|
+
"idetype": "container",
|
|
721
|
+
"containerDirection": "this.getAttribute('direction')?.value === 'true' ? 'column' : 'row' "
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
### 示例二
|
|
727
|
+
|
|
728
|
+
这段表达了Table是一个container,他的内部只允许放入TableColumn,只能通过snippet增加子节点,他具有数据源的特性,默认展示3条假记录,根据’table > tbody > tr’这个选择器来禁用除了第一条以外的假数据,在当前没有设置dataSource属性或者当前子节点数量为0时,展示占位。
|
|
729
|
+
|
|
730
|
+
TableColumn也是一个container,不支持放入子元素,只允许放入Table中,由于组件实现问题,只能通过向其title的slot内部放入一个能够根据css选择器,向上查找DOM节点的组件,
|
|
731
|
+
|
|
732
|
+
```json
|
|
733
|
+
{
|
|
734
|
+
"name": "Table",
|
|
735
|
+
"ideusage": {
|
|
736
|
+
"idetype": "container",
|
|
737
|
+
"containerDirection": "row",
|
|
738
|
+
"structured": true,
|
|
739
|
+
"dataSource": {
|
|
740
|
+
"display": 3,
|
|
741
|
+
"loopElem": "table > tbody > tr",
|
|
742
|
+
"emptySlot": {
|
|
743
|
+
"condition": "!this.getAttribute('dataSource') || this.elementsLength() === 0",
|
|
744
|
+
"accept": "target.concept === 'Entity'"
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
"childAccept": "target.tag === 'TableColumn'"
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
{
|
|
751
|
+
"name": "TableColumn",
|
|
752
|
+
"ideusage": {
|
|
753
|
+
"idetype": "container",
|
|
754
|
+
"childAccept": false,
|
|
755
|
+
"parentAccept": "target.tag === 'Table'",
|
|
756
|
+
"containerDirection": "row",
|
|
757
|
+
"selector": {
|
|
758
|
+
"expression": "this.getElement(el => el.slotTarget === 'title')",
|
|
759
|
+
"cssSelector": "th"
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
### 示例三
|
|
766
|
+
这段表达了Modal是一个modal类型的组件,由于组件实现问题,只能通过向其内部放入一个能够根据css选择器:“div[class=‘ant-modal-content’]”,向上查找DOM节点的组件。为了去除弹窗编辑时的闪动,需要额外增加设计器专门的配置 additionalAttribute。
|
|
767
|
+
|
|
768
|
+
```json
|
|
769
|
+
{
|
|
770
|
+
"name": "Modal",
|
|
771
|
+
"ideusage": {
|
|
772
|
+
"idetype": "modal",
|
|
773
|
+
"selector": {
|
|
774
|
+
"expression": "this",
|
|
775
|
+
"cssSelector": "div[class='ant-modal-content']"
|
|
776
|
+
},
|
|
777
|
+
"additionalAttribute": {
|
|
778
|
+
"transitionName": "''",
|
|
779
|
+
"maskStyle": "{{opacity: 1,animationDuration: '0s'}}"
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
### 示例四
|
|
786
|
+
这段表达了Popover是一个popover类型的组件,由于组件实现问题,只能通过向其content的slot内部放入一个能够根据css选择器:“div[class=‘ant-popover-content’]”,向上查找DOM节点的组件。通过设置actions,用户能在设计器内部通过点击,修改组件的临时状态,通过open或close方法,打开关闭下拉框编辑。
|
|
787
|
+
|
|
788
|
+
```json
|
|
789
|
+
{
|
|
790
|
+
"name": "Popover",
|
|
791
|
+
"ideusage": {
|
|
792
|
+
"idetype": "popover",
|
|
793
|
+
"selector": {
|
|
794
|
+
"expression": "this.getElement(el => el.slotTarget === 'content')",
|
|
795
|
+
"cssSelector": "div[class='ant-popover-content']"
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
```
|