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,312 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# element 配置说明
|
|
6
|
+
|
|
7
|
+
类型为 "element" 的组件无法插入子组件,是不可再分的原子组件。
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
@ExtensionComponent({
|
|
11
|
+
ideusage: {
|
|
12
|
+
"idetype": "element"
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
下文以 vue 模板为例,展示配置和翻译器生层代码的匹配关系。React 相似。
|
|
18
|
+
|
|
19
|
+
## 示例
|
|
20
|
+
|
|
21
|
+
以 CloudUI 的**文本组**件 [u-text](https://github.com/netease-lcap/ui-libraries/blob/test-v3.10.x/libraries/pc-ui/src/components/u-text.vue/index.js) 为例:u-text 具有 props 属性,其具体形式为 { text: string } 。
|
|
22
|
+
|
|
23
|
+
参考配置要求:
|
|
24
|
+
|
|
25
|
+
- 将该组件归类为 element 类型的组件;
|
|
26
|
+
- 可以通过双击编辑 text 字段;
|
|
27
|
+
- text 字段支持在示例文本和表达式之间切换。
|
|
28
|
+
|
|
29
|
+
参考配置书写:
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
@ExtensionComponent({
|
|
33
|
+
ideusage: {
|
|
34
|
+
"idetype": "element",
|
|
35
|
+
"editable": "text",
|
|
36
|
+
"textholder": "text",
|
|
37
|
+
"useFxOrEg":{"property": "text"}
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
这段配置会生成的vue模板如下:
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<u-text data-nodepath="6ac1466240c84a3cbf0f45b5da7c93a4"
|
|
46
|
+
text="普通文本"
|
|
47
|
+
key="component-6ac1466240c84a3cbf0f45b5da7c93a4"
|
|
48
|
+
data-editable="true" >
|
|
49
|
+
</u-text>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
通过该模板生成html节点如下:
|
|
53
|
+
|
|
54
|
+
```html
|
|
55
|
+
<span vusion-slot-name-edit="text"
|
|
56
|
+
class="u-text__yjhV4gf0"
|
|
57
|
+
data-nodepath="6ac1466240c84a3cbf0f45b5da7c93a4"
|
|
58
|
+
data-editable="true">普通文本</span>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
需要注意的点:
|
|
62
|
+
|
|
63
|
+
- 组件内需要将 data-\* 的属性透传到生成的DOM节点上
|
|
64
|
+
- 组件插槽需要支持设计器内置的 EmptySlot 组件和普通html dom元素
|
|
65
|
+
|
|
66
|
+
## 配置项说明
|
|
67
|
+
|
|
68
|
+
### editable
|
|
69
|
+
|
|
70
|
+
选配,定义可被编辑的属性。书写格式为`"editable": "可被编辑的属性名"`,例如:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
"editable": "text"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
> 示例中的 text 属性来源于 api.ts 中的属性描述,实现属性描述请参考[组件配置编写说明](../api.md)。
|
|
77
|
+
|
|
78
|
+
### textholder
|
|
79
|
+
|
|
80
|
+
选配,定义显示文本的属性。书写格式为`"textholder": "显示文本的属性名"`,例如:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
"textholder": "text"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
> 示例中的 text 属性来源于 api.ts 中的属性描述,实现属性描述请参考[组件配置编写说明](../api.md)。
|
|
87
|
+
|
|
88
|
+
### translateBindingProperty
|
|
89
|
+
|
|
90
|
+
选配,定义可以显示绑定变量的属性。书写格式为 `"translateBindingProperty": Array[String]`,Array\[String]即属性名的数组。
|
|
91
|
+
|
|
92
|
+
**示例**
|
|
93
|
+
|
|
94
|
+
以 CloudUI 的**选择器**组件 [u-select](https://github.com/netease-lcap/ui-libraries/blob/test-v3.10.x/libraries/pc-ui/src/components/u-select.vue/index.js) 为例。
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
@ExtensionComponent({
|
|
98
|
+
ideusage: {
|
|
99
|
+
"idetype": "container",
|
|
100
|
+
"structured": true,
|
|
101
|
+
"childAccept": "['u-select-item', 'u-select-group', 'u-select-divider'].includes(target.tag)",
|
|
102
|
+
"events": {
|
|
103
|
+
"click": true
|
|
104
|
+
},
|
|
105
|
+
"translateBindingProperty": ["value", "placeholder"]
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
此处 translateBindingProperty 定义的分别为选择器的“选中值”和“占位符”属性,属性描述如下:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
@Prop({
|
|
114
|
+
title: '选中值'
|
|
115
|
+
})
|
|
116
|
+
value: USelectOptions<T, V, P, M, C>['value'];
|
|
117
|
+
@Prop({
|
|
118
|
+
group: '主要属性',
|
|
119
|
+
title: '自动获取焦点',
|
|
120
|
+
description: '设置是否自动获取焦点',
|
|
121
|
+
docDescription: '控制是否在进入页面时聚焦到该组件',
|
|
122
|
+
designerValue: false,
|
|
123
|
+
setter: {
|
|
124
|
+
concept: 'SwitchSetter'
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
placeholder: nasl.core.String = '请选择';
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**IDE 中的效果**
|
|
131
|
+
|
|
132
|
+
在IDE中,若为“占位符”属性 placeholder 绑定变量,则该属性允许传入平台内置的相关属性字符串。
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
拖拽生成组件后,在页面设计器中生成的代码如下:
|
|
139
|
+
|
|
140
|
+
```html
|
|
141
|
+
<u-select data-nodepath="29d12b2924dc4217ae60dceb991e38a6"
|
|
142
|
+
data-enable-events="click"
|
|
143
|
+
:clearable="true"
|
|
144
|
+
:placeholder="'{{ variable1 }}'"
|
|
145
|
+
:pageSize="50"
|
|
146
|
+
:emptyValueIsNull="true"
|
|
147
|
+
textField="text"
|
|
148
|
+
valueField="value"
|
|
149
|
+
class="" key="component-29d12b2924dc4217ae60dceb991e38a6">
|
|
150
|
+
|
|
151
|
+
</u-select>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### iconEditor
|
|
155
|
+
|
|
156
|
+
选配,定义是否支持双击组件打开icon面板并设置icon。书写格式为`"iconEditor":Boolean`,例如:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
"iconEditor":true
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
### parentAccept
|
|
165
|
+
|
|
166
|
+
选配,定义可以放入当前组件的父组件。书写格式为`"parentAccept":"判断表达式"`,例如要求组件只能置入到面包屑组件 u-crumb 中:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
"parentAccept": "target.tag === 'u-crumb'"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### additionalAttribute
|
|
173
|
+
|
|
174
|
+
选配,定义设计器内组件展示时额外传入的属性。书写格式为`”additionalAttribute“: { key: value }` 。
|
|
175
|
+
|
|
176
|
+
**示例**
|
|
177
|
+
|
|
178
|
+
要求取消 react modal 在设计器里的弹出动画:
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
@ExtensionComponent({
|
|
182
|
+
"ideusage": {
|
|
183
|
+
"idetype": "modal",
|
|
184
|
+
...
|
|
185
|
+
"additionalAttribute": {
|
|
186
|
+
"transitionName": "''",
|
|
187
|
+
"maskStyle": "{{opacity: 1,animationDuration: '0s'}}"
|
|
188
|
+
},
|
|
189
|
+
"cacheOpenKey": "open"
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
> 需要注意,传入的键值对将直接放入模板翻译结果,需要对 " 等特殊符号做转义。
|
|
195
|
+
|
|
196
|
+
**IDE 中的效果**
|
|
197
|
+
|
|
198
|
+
拖拽生成组件后,在页面设计器中生成的代码如下:
|
|
199
|
+
|
|
200
|
+
```html
|
|
201
|
+
<Modal okText="确定" cancelText="取消"
|
|
202
|
+
key="component-24445f4bd7be4acdb923d4e53c06fe58"
|
|
203
|
+
open={true}
|
|
204
|
+
transitionName=''
|
|
205
|
+
maskStyle={{opacity: 1,animationDuration: '0s'}}
|
|
206
|
+
title={...}
|
|
207
|
+
footer={...}>
|
|
208
|
+
...
|
|
209
|
+
</Modal>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### useFxOrEg
|
|
213
|
+
|
|
214
|
+
选配,定义支持表达式和示例切换的属性。书写格式为`useFxOrEg: { property: String, displayAsAttr?: Boolean }` 。
|
|
215
|
+
|
|
216
|
+
- property:表示支持的属性名;
|
|
217
|
+
- displayAsAttr: 表示组件是否支持内部插入子元素。
|
|
218
|
+
|
|
219
|
+
例如:
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
"useFxOrEg":{"property": "text"}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
示例中的 text 属性来源于 api.ts 中的属性描述,实现属性描述请参考[组件配置编写说明](../api.md)。
|
|
226
|
+
|
|
227
|
+
在IDE中,若为文本属性 text 绑定变量,支持[切换显示表达式和示例数据](https://community.codewave.163.com/CommunityParent/fileIndex?filePath=20.%E5%BA%94%E7%94%A8%E5%BC%80%E5%8F%91%2F10.%E9%A1%B5%E9%9D%A2%E8%AE%BE%E8%AE%A1%2F16.%E7%A4%BA%E4%BE%8B%E6%95%B0%E6%8D%AE%EF%BC%88%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%8D%A0%E4%BD%8D%E7%AC%A6%EF%BC%89.md&version=3.13)。
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
### events
|
|
232
|
+
|
|
233
|
+
选配,定义页面设计器内支持的事件。书写格式为`"events": { key: value }` 。
|
|
234
|
+
|
|
235
|
+
- key:表示事件名称,目前支持 click 或 mousedown;
|
|
236
|
+
- value:表示生效条件,支持 true、false以及表达式。
|
|
237
|
+
|
|
238
|
+
例如为折叠面板组件定义点击事件,支持点击后在设计器中打开和关闭折叠面板项:
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
"events": {"click": true}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
### elementSutando
|
|
247
|
+
|
|
248
|
+
选配,定义页面设计器中的替代组件,如果设计器中要展示的组件无法与原组件相同,则可以使用为设计器定制的组件作为替代。书写格式为:
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
"elementSutando": { "condition": true,
|
|
252
|
+
"component": "组件名",
|
|
253
|
+
"condition": "使用替代组件的条件判断表达式", //选配
|
|
254
|
+
"selector": { //选配
|
|
255
|
+
"slot": String,
|
|
256
|
+
"cssSelector": String,
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**示例**
|
|
261
|
+
|
|
262
|
+
以 ElementUI 的弹框组件 [MessageBox](https://element.eleme.cn/#/zh-CN/component/message-box) 为例:只能通过element的API唤起,不是一个组件,如果要在设计器里编排,则需要写一个类似的组件作为替身。
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
@ExtensionComponent({
|
|
266
|
+
ideusage: {
|
|
267
|
+
"idetype": "messager",
|
|
268
|
+
"elementSutando": {
|
|
269
|
+
"condition": true,
|
|
270
|
+
"component": "ElMessageBoxDesigner",
|
|
271
|
+
"selector": {
|
|
272
|
+
"slot": "default",
|
|
273
|
+
"cssSelector": ".el-message-box",
|
|
274
|
+
},
|
|
275
|
+
"useSlot": true,
|
|
276
|
+
},
|
|
277
|
+
"cacheOpenKey": "visible"
|
|
278
|
+
}
|
|
279
|
+
})
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**IDE 中的效果**
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
### style
|
|
287
|
+
|
|
288
|
+
选配,针对IDE内显示的组件内部元素定义样式。书写格式为style:`Array<Object>`,Array\<Object>即样式键值对的数组。
|
|
289
|
+
|
|
290
|
+
例如,想要覆盖 van button 组件中,被IDE禁用的动画效果,可以在style中重新定义样式表:
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
@ExtensionComponent({
|
|
294
|
+
"ideusage": {
|
|
295
|
+
"idetype": "element",
|
|
296
|
+
"useFxOrEg": {
|
|
297
|
+
"property": "text"
|
|
298
|
+
},
|
|
299
|
+
"translateBindingProperty": ["icon", "text"],
|
|
300
|
+
"style": [
|
|
301
|
+
{
|
|
302
|
+
"selector": ".van-loading__spinner",
|
|
303
|
+
"declaration": "animation-duration: 2s!important"
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"selector": ".van-loading__spinner *",
|
|
307
|
+
"declaration": "animation-duration: 2s!important"
|
|
308
|
+
}
|
|
309
|
+
]
|
|
310
|
+
}
|
|
311
|
+
})
|
|
312
|
+
```
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# 表达式API说明与示例
|
|
6
|
+
|
|
7
|
+
## 表达式API说明
|
|
8
|
+
|
|
9
|
+
在组件的配置项使用表达式时,可以将表达式分为两种:
|
|
10
|
+
|
|
11
|
+
1. 带target参数:例如parentAccept、childAccept、accept配置项
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
"parentAccept": "target.tag === 'u-crumb'"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
1. 不带target参数:其他的表达式
|
|
18
|
+
|
|
19
|
+
表达式内部通过 ‘this‘ 来指向自己,this上定义了一系列的属性和API:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
type Attribute {
|
|
23
|
+
name: string,
|
|
24
|
+
value: any
|
|
25
|
+
}
|
|
26
|
+
class Element {
|
|
27
|
+
// 处于的slot名称
|
|
28
|
+
slotTarget: string
|
|
29
|
+
|
|
30
|
+
// 获取当前的参数
|
|
31
|
+
getAttribute: (attrname: string) => Attribute
|
|
32
|
+
|
|
33
|
+
// 根据条件获取子元素
|
|
34
|
+
getElement: (filter: (el: Element) => boolean) => ?Element
|
|
35
|
+
// 根据条件过滤子元素
|
|
36
|
+
filterElement: (filter: (el: Element) => boolean) => Element[]
|
|
37
|
+
// 获得父节点
|
|
38
|
+
getParent: () => Element
|
|
39
|
+
// 子节点个数
|
|
40
|
+
elementsLength: () => number
|
|
41
|
+
|
|
42
|
+
// 设计器缓存状态(deprecated)
|
|
43
|
+
// setCacheStatus: (cachename: string, initialStatus: any) => void
|
|
44
|
+
// 获取设计器缓存状态(deprecated)
|
|
45
|
+
// getCacheStatus: (cachename: string) => any
|
|
46
|
+
// 调用组件方法 (废弃)
|
|
47
|
+
// callComponentMethod: (funcName: string, ...args: any[]) => void
|
|
48
|
+
|
|
49
|
+
// 获取祖先节点
|
|
50
|
+
getAncestor: (tag: string) => ?Element
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
class Target {
|
|
54
|
+
// 对应到nasl节点的concept
|
|
55
|
+
concept: string;
|
|
56
|
+
// 目标的 tag 属性
|
|
57
|
+
tag: string;
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 表达式API示例
|
|
62
|
+
|
|
63
|
+
### 示例一
|
|
64
|
+
|
|
65
|
+
这段表达了Flex是一个container,他的containerDirecion由当前设计器内设置的direction属性值决定。
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
{
|
|
69
|
+
"name": "Flex",
|
|
70
|
+
"ideusage": {
|
|
71
|
+
"idetype": "container",
|
|
72
|
+
"containerDirection": "this.getAttribute('direction')?.value === 'true' ? 'column' : 'row' "
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 示例二
|
|
78
|
+
|
|
79
|
+
这段表达了Table是一个container,他的内部只允许放入TableColumn,只能通过snippet增加子节点,他具有数据源的特性,默认展示3条假记录,根据'table > tbody > tr'这个选择器来禁用除了第一条以外的假数据,在当前没有设置dataSource属性或者当前子节点数量为0时,展示占位。
|
|
80
|
+
|
|
81
|
+
TableColumn也是一个container,不支持放入子元素,只允许放入Table中,由于组件实现问题,只能通过向其title的slot内部放入一个能够根据css选择器,向上查找DOM节点的组件,
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
{
|
|
85
|
+
"name": "Table",
|
|
86
|
+
"ideusage": {
|
|
87
|
+
"idetype": "container",
|
|
88
|
+
"containerDirection": "row",
|
|
89
|
+
"structured": true,
|
|
90
|
+
"dataSource": {
|
|
91
|
+
"display": 3,
|
|
92
|
+
"loopElem": "table > tbody > tr",
|
|
93
|
+
"emptySlot": {
|
|
94
|
+
"condition": "!this.getAttribute('dataSource') || this.elementsLength() === 0",
|
|
95
|
+
"accept": "target.concept === 'Entity'"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"childAccept": "target.tag === 'TableColumn'"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
{
|
|
102
|
+
"name": "TableColumn",
|
|
103
|
+
"ideusage": {
|
|
104
|
+
"idetype": "container",
|
|
105
|
+
"childAccept": false,
|
|
106
|
+
"parentAccept": "target.tag === 'Table'",
|
|
107
|
+
"containerDirection": "row",
|
|
108
|
+
"selector": {
|
|
109
|
+
"expression": "this.getElement(el => el.slotTarget === 'title')",
|
|
110
|
+
"cssSelector": "th"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 示例三
|
|
117
|
+
|
|
118
|
+
这段表达了Modal是一个modal类型的组件,由于组件实现问题,只能通过向其内部放入一个能够根据css选择器:"div\[class='ant-modal-content']",向上查找DOM节点的组件。为了去除弹窗编辑时的闪动,需要额外增加设计器专门的配置 additionalAttribute。
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
{
|
|
122
|
+
"name": "Modal",
|
|
123
|
+
"ideusage": {
|
|
124
|
+
"idetype": "modal",
|
|
125
|
+
"selector": {
|
|
126
|
+
"expression": "this",
|
|
127
|
+
"cssSelector": "div[class='ant-modal-content']"
|
|
128
|
+
},
|
|
129
|
+
"additionalAttribute": {
|
|
130
|
+
"transitionName": "''",
|
|
131
|
+
"maskStyle": "{{opacity: 1,animationDuration: '0s'}}"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 示例四
|
|
138
|
+
|
|
139
|
+
这段表达了Popover是一个popover类型的组件,由于组件实现问题,只能通过向其content的slot内部放入一个能够根据css选择器:"div\[class='ant-popover-content']",向上查找DOM节点的组件。通过设置actions,用户能在设计器内部通过点击,修改组件的临时状态,通过open或close方法,打开关闭下拉框编辑。
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
{
|
|
143
|
+
"name": "Popover",
|
|
144
|
+
"ideusage": {
|
|
145
|
+
"idetype": "popover",
|
|
146
|
+
"selector": {
|
|
147
|
+
"expression": "this.getElement(el => el.slotTarget === 'content')",
|
|
148
|
+
"cssSelector": "div[class='ant-popover-content']"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# 页面设计器适配说明
|
|
6
|
+
|
|
7
|
+
在IDE中,页面设计器是实现可视化拖拽与布局、配置属性、数据绑定、交互设计等的工具。
|
|
8
|
+
|
|
9
|
+
在依赖库项目中,开发者可以通过在 api.ts 文件中配置 ideusage ,从而定制页面设计器接入组件后内置的翻译器行为。
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
设计器内部的翻译结果可以通过在控制台打印预览:
|
|
14
|
+
|
|
15
|
+
通过在浏览器控制台输入 window.\_\_\$dev\_runtime\_\_ = true 来开启当前设计器内的代码输出,以便组件配置与目标代码进行比对。
|
|
16
|
+
|
|
17
|
+
## 1. 前提条件
|
|
18
|
+
|
|
19
|
+
- PC端 - IDE3.10以上版本
|
|
20
|
+
- H5端 - IDE3.11以上版本
|
|
21
|
+
- React 应用
|
|
22
|
+
|
|
23
|
+
## 2. 组件配置说明
|
|
24
|
+
|
|
25
|
+
接入的组件分为以下几种类型:
|
|
26
|
+
|
|
27
|
+
- element (默认) :无法再插入子节点的原子组件
|
|
28
|
+
- container :可以插入子节点的容器组件
|
|
29
|
+
- modal :弹窗类组件
|
|
30
|
+
- drawer :抽屉类组件
|
|
31
|
+
- messager :消息弹出类组件
|
|
32
|
+
- popover :一些弹出框类组件
|
|
33
|
+
- router :路由组件
|
|
34
|
+
- board : 自由布局组件
|
|
35
|
+
|
|
36
|
+
开发者可以通过配置 `idetype` 来指定组件的类型,以 element 类型为例:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
@ExtensionComponent({
|
|
40
|
+
ideusage: {
|
|
41
|
+
idetype: "element"
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 公用配置
|
|
47
|
+
|
|
48
|
+
开发者可以为组件指定的公用配置如下:
|
|
49
|
+
|
|
50
|
+
#### forceRefresh
|
|
51
|
+
|
|
52
|
+
选配,定义组件在画布内移动后,强制刷新自己或者父组件。书写格式为:`"forceRefresh: "self"` 或 `"forceRefresh:"parent"` 。
|
|
53
|
+
|
|
54
|
+
forceRefresh 是通过key值变化强制刷新页面上的组件,比如在数据表格 table-view 中,表格列 table-view-column 的顺序需要通过强制刷新 table-view 来改变。
|
|
55
|
+
|
|
56
|
+
table-view-column的配置为:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
"ideusage": {
|
|
60
|
+
"idetype": "container",
|
|
61
|
+
"forceRefresh": "parent",
|
|
62
|
+
...
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### forceUpdateWhenAttributeChange
|
|
67
|
+
|
|
68
|
+
选配,定义组件改变属性后是否强制刷新自己。书写格式为`"forceUpdateWhenAttributeChange": Boolean` 。
|
|
69
|
+
|
|
70
|
+
forceUpdateWhenAttributeChange 同样是通过key值变化强制刷新页面上的组件。
|
|
71
|
+
|
|
72
|
+
#### ignoreProperty
|
|
73
|
+
|
|
74
|
+
选配,定义不需要翻译的属性。书写格式为`"ignoreProperty": Array[String]`,Array\[String]即属性名的数组。
|
|
75
|
+
|
|
76
|
+
例如在表单组件的表单项上,为了避免在设计器里使用到验证规则导致报错,所以屏蔽了验证规则属性 rules 的翻译:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
"ignoreProperty": ["rules"]
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### useWrapperInBoard
|
|
83
|
+
|
|
84
|
+
选配,定义自由布局内是否使用div包裹。书写格式为`"useWrapperInBoard":Boolean`。
|
|
85
|
+
|
|
86
|
+
#### defaultStyleInBoard
|
|
87
|
+
|
|
88
|
+
选配,定义组件首次置入自由布局的样式。书写格式为`"defaultStyleInBoard":Object`,Object为样式的键值对。
|
|
89
|
+
|
|
90
|
+
例如图片组件首次拖入自由布局时的宽度为300px。
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
defaultStyleInBoard: {
|
|
94
|
+
width: "300px"
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
### 组件配置
|
|
101
|
+
|
|
102
|
+
具体组件配置说明请前往相应的文档查看:
|
|
103
|
+
|
|
104
|
+
- [element 配置](../ide/element.md)
|
|
105
|
+
- [container 配置说明](../ide/container.md)
|
|
106
|
+
- [modal | drawer | messager 配置说明](../ide/modal.md)
|
|
107
|
+
- [popover 配置说明](../ide/popover.md)
|
|
108
|
+
|
|
109
|
+
### API表达式说明
|
|
110
|
+
|
|
111
|
+
配置项中使用表达式说明请参考[表达式API说明与示例](../ide/expression.md)。
|
|
112
|
+
|
|
113
|
+
|