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,728 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# container 配置说明
|
|
6
|
+
|
|
7
|
+
类型为 "container" 的组件搭配 [Slot ](../platform/slot.md)可以插入子节点。
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
@ExtensionComponent({
|
|
11
|
+
ideusage: {
|
|
12
|
+
"idetype": "container"
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
下文以 vue 模板为例,展示配置和翻译器生层代码的匹配关系。React 相似。
|
|
18
|
+
|
|
19
|
+
## 示例
|
|
20
|
+
|
|
21
|
+
### 卡片组件
|
|
22
|
+
|
|
23
|
+
以 CloudUI 的卡片组件 [u-card](https://github.com/netease-lcap/ui-libraries/blob/test-v3.10.x/libraries/pc-ui/src/components/u-card.vue/index.js) 为例。
|
|
24
|
+
|
|
25
|
+
参考配置要求:
|
|
26
|
+
|
|
27
|
+
- 组件包含三个插槽;
|
|
28
|
+
- 禁止自动插入插槽。
|
|
29
|
+
|
|
30
|
+
参考配置书写:
|
|
31
|
+
|
|
32
|
+
由于disableSlotAutoFill配置了不自动插入槽位的插槽名,所以设计器只会自动在 default 和 title 插槽下插入可置入组件的槽位。
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
@ExtensionComponent({
|
|
36
|
+
ideusage: {
|
|
37
|
+
idetype: "container",
|
|
38
|
+
"disableSlotAutoFill": ["cover"]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export class UCardOptions extends ViewComponentOptions {
|
|
42
|
+
// ...
|
|
43
|
+
@Slot({
|
|
44
|
+
title: 'undefined',
|
|
45
|
+
description: '插入默认的元素',
|
|
46
|
+
})
|
|
47
|
+
slotDefault: () => Array<nasl.ui.ViewComponent>;
|
|
48
|
+
|
|
49
|
+
@Slot({
|
|
50
|
+
title: '图片',
|
|
51
|
+
description: '插入图片',
|
|
52
|
+
})
|
|
53
|
+
slotCover: () => Array<nasl.ui.ViewComponent>;
|
|
54
|
+
|
|
55
|
+
@Slot({
|
|
56
|
+
title: '标题',
|
|
57
|
+
description: '插入文本或 HTML。',
|
|
58
|
+
})
|
|
59
|
+
slotTitle: () => Array<nasl.ui.ViewComponent>;
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
这段配置生成的vue模板如下:
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<u-card data-nodepath="c3f682566bb94d12ad71144c80d858d8" key="component-c3f682566bb94d12ad71144c80d858d8">
|
|
67
|
+
<EmptySlot data-emptyslot-nodepath="c3f682566bb94d12ad71144c80d858d8"></EmptySlot>
|
|
68
|
+
<template slot="title">
|
|
69
|
+
<div data-nodepath="22e902143270453796cd6d94ee2f0e91">
|
|
70
|
+
<EmptySlot data-emptyslot-nodepath="22e902143270453796cd6d94ee2f0e91"></EmptySlot>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
</u-card>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
需要注意的点:
|
|
77
|
+
|
|
78
|
+
- 组件内需要将 data-\* 的属性透传到生成的DOM节点上
|
|
79
|
+
- 组件插槽需要支持设计器内置的 EmptySlot 组件和普通html dom元素
|
|
80
|
+
|
|
81
|
+
### 数据表格组件
|
|
82
|
+
|
|
83
|
+
在一些特殊情况中,container类型的组件无法将 data-\* 的属性透传到生成的DOM节点上。以 CloudUI 的 表格列[u-tableview-column](https://github.com/netease-lcap/ui-libraries/blob/2e9708d13891015ae6b9ac33507fb77bb8b253b3/libraries/pc-ui/src/components/u-table-view.vue/api.ts#L1116)为例。
|
|
84
|
+
|
|
85
|
+
参考配置要求:
|
|
86
|
+
|
|
87
|
+
- 在IDE中可以完整的选中表格列。
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
参考配置书写:
|
|
92
|
+
|
|
93
|
+
组件分为表头和表格内容,为了能够同时选中表格头个表格内容,设计器提供了 selector 配置项,配置项通过向指定的插槽注入内置组件 HoistNodePath ,从而将 data-\*的属性复制到上层 cssSelector 可以匹配的 dom 元素。
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
@ExtensionComponent({
|
|
101
|
+
"ideusage": {
|
|
102
|
+
"idetype": "container",
|
|
103
|
+
"selector": [
|
|
104
|
+
{
|
|
105
|
+
"expression": "this.getElement(el => el.slotTarget === 'title')",
|
|
106
|
+
"cssSelector": "th"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"expression": "this.getElement(el => el.slotTarget === 'cell')",
|
|
110
|
+
"cssSelector": "td"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"expression": "this.getElement(el => el.slotTarget === 'expand-content')",
|
|
114
|
+
"cssSelector": "tr[class^='u-table-view_expand-content']"
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
这段配置生成的vue模板如下:
|
|
122
|
+
|
|
123
|
+
```html
|
|
124
|
+
<u-table-view-column field="entity1.updatedTime" key="component-613a75d05eb04790969d9fd1532eb5ab">
|
|
125
|
+
<template #cell={...argus}>
|
|
126
|
+
<HoistNodePath nodePath="613a75d05eb04790969d9fd1532eb5ab" topSelector="td" data-nodepath-multiple="true">
|
|
127
|
+
</HoistNodePath>
|
|
128
|
+
<div data-nodepath="55b20ff830b84a2bb1e4640a2c51496c">
|
|
129
|
+
<EmptySlot data-emptyslot-nodepath="55b20ff830b84a2bb1e4640a2c51496c"></EmptySlot>
|
|
130
|
+
</div>
|
|
131
|
+
</template>
|
|
132
|
+
<template #editcell={...argus}>
|
|
133
|
+
<div data-nodepath="530ebd475ab742d5a7967376ae5132d7">
|
|
134
|
+
<EmptySlot data-emptyslot-nodepath="530ebd475ab742d5a7967376ae5132d7"></EmptySlot>
|
|
135
|
+
</div>
|
|
136
|
+
</template>
|
|
137
|
+
<template slot="title">
|
|
138
|
+
<HoistNodePath nodePath="613a75d05eb04790969d9fd1532eb5ab" topSelector="th" data-nodepath-multiple="true">
|
|
139
|
+
</HoistNodePath>
|
|
140
|
+
<div data-nodepath="a556e6e3851b40578d12022f4d4e1ca3">
|
|
141
|
+
<EmptySlot data-emptyslot-nodepath="a556e6e3851b40578d12022f4d4e1ca3"></EmptySlot>
|
|
142
|
+
</div>
|
|
143
|
+
</template>
|
|
144
|
+
<template #expand-content={...argus}>
|
|
145
|
+
<HoistNodePath nodePath="613a75d05eb04790969d9fd1532eb5ab"
|
|
146
|
+
topSelector="tr[class^='u-table-view_expand-content']" data-nodepath-multiple="true"></HoistNodePath>
|
|
147
|
+
<div data-nodepath="f5b3b0b27b6f43d7806d82ccd97660e2">
|
|
148
|
+
<EmptySlot data-emptyslot-nodepath="f5b3b0b27b6f43d7806d82ccd97660e2"></EmptySlot>
|
|
149
|
+
</div>
|
|
150
|
+
</template>
|
|
151
|
+
<template #expander={...argus}>
|
|
152
|
+
<div data-nodepath="67149ae2ebd6428d89646a6fdc0c6905"><u-table-view-expander
|
|
153
|
+
data-nodepath="cdd6d65d372149e994debc85c0969b85" data-enable-events="click"
|
|
154
|
+
key="component-cdd6d65d372149e994debc85c0969b85" :item="argus.item"></u-table-view-expander></div>
|
|
155
|
+
</template>
|
|
156
|
+
</u-table-view-column>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 表单组件
|
|
160
|
+
|
|
161
|
+
设计器还提供了通过 “+” 来添加子组件的功能。以 CloudUI 的表单组件 [u-form](https://github.com/netease-lcap/ui-libraries/tree/test-v3.10.x/libraries/pc-ui/src/components/u-form.vue) 为例。
|
|
162
|
+
|
|
163
|
+
参考配置要求:
|
|
164
|
+
|
|
165
|
+
- 在IDE中可以选中表单添加表单分组和表单项。
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
参考配置书写:
|
|
170
|
+
|
|
171
|
+
通过配置 structured 属性,配合slot配置中的 snippets 来配置子组件添加模板。
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
@ExtensionComponent({
|
|
175
|
+
"ideusage": {
|
|
176
|
+
"idetype": "container",
|
|
177
|
+
"structured": true
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
export class UFormGroupOptions extends ViewComponentOptions {
|
|
181
|
+
...
|
|
182
|
+
@Slot({
|
|
183
|
+
title: 'undefined',
|
|
184
|
+
description: '插入`<u-form-item>`子组件。',
|
|
185
|
+
emptyBackground: 'add-sub-large',
|
|
186
|
+
snippets: [
|
|
187
|
+
{
|
|
188
|
+
title: '表单分组',
|
|
189
|
+
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>',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
title: '表单项',
|
|
193
|
+
code: '<u-form-item><template #label><u-text text="表单项"></u-text></template></u-form-item>',
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
})
|
|
197
|
+
slotDefault: () => Array<nasl.ui.ViewComponent>;
|
|
198
|
+
...
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
- structure: true 表示 snippet 插入到 "default" 插槽内;
|
|
203
|
+
- structure: "slotname" 表示 snippet 插入到 "slotname" 插槽内;
|
|
204
|
+
- structure: { slot: "slotname", empty: true } 表示即使空态也有槽位展示。
|
|
205
|
+
|
|
206
|
+
### 单选组组件
|
|
207
|
+
|
|
208
|
+
当具有 dataSource 属性的组件接入时,需要配置 dataSource 的展示形式。以 CloudUI 的单选组组件 [u-radios](https://github.com/netease-lcap/ui-libraries/tree/test-v3.10.x/libraries/pc-ui/src/components/u-radios.vue) 为例。
|
|
209
|
+
|
|
210
|
+
参考配置要求:
|
|
211
|
+
|
|
212
|
+
- 支持设置数据源。
|
|
213
|
+
- 支持在绑定数据源后拖拽插入子组件,使子组件动态展示。
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
参考配置书写:
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
@ExtensionComponent({
|
|
221
|
+
"ideusage": {
|
|
222
|
+
"idetype": "container",
|
|
223
|
+
"structured": true,
|
|
224
|
+
"dataSource": {
|
|
225
|
+
"dismiss": "!this.getAttribute('dataSource') && this.getDefaultElements().length > 0",
|
|
226
|
+
"display": 3,
|
|
227
|
+
"loopRule": "nth-child(n+2)",
|
|
228
|
+
"loopElem": "> label[class^='u-radios_radio']:not([data-nodepath])"
|
|
229
|
+
},
|
|
230
|
+
// ...
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
这段配置生成的vue模板,及相关css样式如下:
|
|
236
|
+
|
|
237
|
+
```html
|
|
238
|
+
<u-radios data-nodepath="e19ce4d016414bada1b05a96b7157963"
|
|
239
|
+
key="component-e19ce4d016414bada1b05a96b7157963"
|
|
240
|
+
:dataSource="[{},{},{}]"
|
|
241
|
+
class="ide-style1">
|
|
242
|
+
<template #item={...argus}>
|
|
243
|
+
<div data-nodepath="9474b8caced5485da6f788e1745d02ee">
|
|
244
|
+
<EmptySlot data-emptyslot-nodepath="9474b8caced5485da6f788e1745d02ee"></EmptySlot>
|
|
245
|
+
</div>
|
|
246
|
+
</template>
|
|
247
|
+
</u-radios>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
```css
|
|
251
|
+
.ide-style1>label[class^='u-radios_radio']:not([data-nodepath]):nth-child(n+2) {
|
|
252
|
+
opacity: 0.2;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.ide-style1>label[class^='u-radios_radio']:not([data-nodepath]):nth-child(n+2),
|
|
256
|
+
.ide-style1>label[class^='u-radios_radio']:not([data-nodepath]):nth-child(n+2) * {
|
|
257
|
+
pointer-events: none;
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
需要注意的是:
|
|
262
|
+
|
|
263
|
+
- 组件的dataSource 需要支持传入 \[{}, {}, {}] 形态的数据,display: 3 表示展示3个 '{}'
|
|
264
|
+
- loopRule 和 loopElem 用于拼接生成的 css 选择器,用于给后面几项的展示增加样式。
|
|
265
|
+
- dismiss 是当指定条件下,忽略dataSource的设置,即不传入 \[{}, {}, {}],也不增加css样式。
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
空态可由slot的配置emptyBackground生效,目前支持 'add-sub' 与 'add-sub-large'。
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
## 配置项说明
|
|
274
|
+
|
|
275
|
+
### containerDirection
|
|
276
|
+
|
|
277
|
+
选配,定义容器内部排列方向的表达式,与置入的指示线有关。
|
|
278
|
+
|
|
279
|
+
**示例**
|
|
280
|
+
|
|
281
|
+
以 CloudUI 的栅格布局组件的**栅格行** grid-layout和**栅格列** grid-layout-row 为例。
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
@ExtensionComponent({
|
|
285
|
+
"ideusage": {
|
|
286
|
+
"idetype": "container",
|
|
287
|
+
"structured": true,
|
|
288
|
+
"dataSource": {
|
|
289
|
+
"dismiss": "!this.getAttribute('dataSource') && this.getDefaultElements().length > 0",
|
|
290
|
+
"display": 3,
|
|
291
|
+
"loopRule": "nth-child(n+2)",
|
|
292
|
+
"loopElem": "> label[class^='u-radios_radio']:not([data-nodepath])"
|
|
293
|
+
},
|
|
294
|
+
// ...
|
|
295
|
+
}
|
|
296
|
+
})
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
**IDE 中的效果**
|
|
300
|
+
|
|
301
|
+
栅格行垂直方向依次排列,栅格列水平方向依次排列。
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
### translateBindingProperty
|
|
306
|
+
|
|
307
|
+
选配,定义可以显示绑定变量的属性。书写格式为 `"translateBindingProperty": Array[String]`,Array\[String]即属性名的数组。
|
|
308
|
+
|
|
309
|
+
**示例**
|
|
310
|
+
|
|
311
|
+
以 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) 为例。
|
|
312
|
+
|
|
313
|
+
```typescript
|
|
314
|
+
@ExtensionComponent({
|
|
315
|
+
ideusage: {
|
|
316
|
+
"idetype": "container",
|
|
317
|
+
"structured": true,
|
|
318
|
+
"childAccept": "['u-select-item', 'u-select-group', 'u-select-divider'].includes(target.tag)",
|
|
319
|
+
"events": {
|
|
320
|
+
"click": true
|
|
321
|
+
},
|
|
322
|
+
"translateBindingProperty": ["value", "placeholder"]
|
|
323
|
+
}
|
|
324
|
+
})
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
此处 translateBindingProperty 定义的分别为选择器的“选中值”和“占位符”属性,属性描述如下:
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
@Prop({
|
|
331
|
+
title: '选中值'
|
|
332
|
+
})
|
|
333
|
+
value: USelectOptions<T, V, P, M, C>['value'];
|
|
334
|
+
@Prop({
|
|
335
|
+
group: '主要属性',
|
|
336
|
+
title: '自动获取焦点',
|
|
337
|
+
description: '设置是否自动获取焦点',
|
|
338
|
+
docDescription: '控制是否在进入页面时聚焦到该组件',
|
|
339
|
+
designerValue: false,
|
|
340
|
+
setter: {
|
|
341
|
+
concept: 'SwitchSetter'
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
placeholder: nasl.core.String = '请选择';
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
**IDE 中的效果**
|
|
348
|
+
|
|
349
|
+
在IDE中,若为“占位符”属性 placeholder 绑定变量,则该属性允许传入平台内置的相关属性字符串。
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
拖拽生成组件后,在页面设计器中生成的代码如下:
|
|
356
|
+
|
|
357
|
+
```html
|
|
358
|
+
<u-select data-nodepath="29d12b2924dc4217ae60dceb991e38a6"
|
|
359
|
+
data-enable-events="click"
|
|
360
|
+
:clearable="true"
|
|
361
|
+
:placeholder="'{{ variable1 }}'"
|
|
362
|
+
:pageSize="50"
|
|
363
|
+
:emptyValueIsNull="true"
|
|
364
|
+
textField="text"
|
|
365
|
+
valueField="value"
|
|
366
|
+
class="" key="component-29d12b2924dc4217ae60dceb991e38a6">
|
|
367
|
+
|
|
368
|
+
</u-select>
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### elementSutando
|
|
372
|
+
|
|
373
|
+
选配,定义页面设计器中的替代组件,如果设计器中要展示的组件无法与原组件相同,则可以使用为设计器定制的组件作为替代。书写格式为:
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
"elementSutando": {
|
|
377
|
+
"component": "组件名",
|
|
378
|
+
"condition": "使用替代组件的条件判断表达式",
|
|
379
|
+
"selector": {
|
|
380
|
+
"slot": String,
|
|
381
|
+
"cssSelector": String,
|
|
382
|
+
}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
**示例**
|
|
386
|
+
|
|
387
|
+
以 ElementUI 的弹框组件 [MessageBox](https://element.eleme.cn/#/zh-CN/component/message-box) 为例:只能通过element的API唤起,不是一个组件,如果要在设计器里编排,则需要写一个类似的组件作为替身。
|
|
388
|
+
|
|
389
|
+
```typescript
|
|
390
|
+
@ExtensionComponent({
|
|
391
|
+
ideusage: {
|
|
392
|
+
"idetype": "messager",
|
|
393
|
+
"elementSutando": {
|
|
394
|
+
"condition": true,
|
|
395
|
+
"component": "ElMessageBoxDesigner",
|
|
396
|
+
"selector": {
|
|
397
|
+
"slot": "default",
|
|
398
|
+
"cssSelector": ".el-message-box",
|
|
399
|
+
},
|
|
400
|
+
"useSlot": true,
|
|
401
|
+
},
|
|
402
|
+
"cacheOpenKey": "visible"
|
|
403
|
+
}
|
|
404
|
+
})
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
**IDE 中的效果**
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
### dataSource
|
|
412
|
+
|
|
413
|
+
选配,定义具有数据源的组件。书写格式为:
|
|
414
|
+
|
|
415
|
+
```typescript
|
|
416
|
+
"dataSource": {
|
|
417
|
+
"dismiss": String,
|
|
418
|
+
""display": Integer,
|
|
419
|
+
"loopElem": String
|
|
420
|
+
"emptySlot": {
|
|
421
|
+
"display": String,
|
|
422
|
+
"condition": String,
|
|
423
|
+
"component":String,
|
|
424
|
+
"accept": Boolean
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
- dismiss(选配):忽略datasource的条件表达式。
|
|
430
|
+
- display:在设计器中展示的条数。例如`"display": 3`表示传入的是 "\[{}, {}, {}]"
|
|
431
|
+
- displayData:设计器中该组件传入的datasource的值。如果设置则display不生效,`"display": 3`等同于`"displayData": "[{}, {}, {}]"`。
|
|
432
|
+
- loopElem:该组件循环的具体DOM节点的css选择器
|
|
433
|
+
- emptySlot:没有绑定数据源时的占位设置
|
|
434
|
+
|
|
435
|
+
- condition:使用占位组件的条件
|
|
436
|
+
- component(选配):占位的组件名称
|
|
437
|
+
- accept:可置入的目标表达式
|
|
438
|
+
- display(选配): 如果使用了默认的占位组件的样式,可能的值为:'inline','block',默认'block'。
|
|
439
|
+
|
|
440
|
+
具体示例请参考上文:[示例-单选组组件]()。
|
|
441
|
+
|
|
442
|
+
### parentAccept
|
|
443
|
+
|
|
444
|
+
选配,定义可以放入当前组件的父组件。书写格式为`"parentAccept":"判断表达式"`,例如要求组件只能置入到面包屑组件 u-crumb 中:
|
|
445
|
+
|
|
446
|
+
```typescript
|
|
447
|
+
"parentAccept": "target.tag === 'u-crumb'"
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
### childAccept
|
|
451
|
+
|
|
452
|
+
选配,定义可以放入子组件的组件。书写格式为`"parentAccept":"判断表达式"`或`"parentAccept":Object`。
|
|
453
|
+
|
|
454
|
+
- 表达式形式:
|
|
455
|
+
|
|
456
|
+
```typescript
|
|
457
|
+
"childAccept": "target.tag === 'Radio'",
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
- 对象形式:key为slot中配置的名字,value是表达式
|
|
461
|
+
|
|
462
|
+
```typescript
|
|
463
|
+
"childAccept": {
|
|
464
|
+
"default": "this.getDefaultElements().length < 1",
|
|
465
|
+
"menuItem": "target.tag === 'MenuItem'"
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
### selector
|
|
470
|
+
|
|
471
|
+
选配,若存在无法将data-nodepath 传入顶层DOM节点,可以通过设置此项绕行,绕行是通过向具体组件内部放入一个能够根据css选择器向上查找DOM节点的组件X。书写格式为:
|
|
472
|
+
|
|
473
|
+
```typescript
|
|
474
|
+
"selector": [
|
|
475
|
+
{
|
|
476
|
+
"expression": String,
|
|
477
|
+
"cssSelector": String
|
|
478
|
+
},
|
|
479
|
+
]
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
selector 中可以为包含 expression 和 cssSelector 的对象或对象的数组。
|
|
483
|
+
|
|
484
|
+
- expression: 从当前节点查找塞入组件X的位置;
|
|
485
|
+
- cssSelector: X组件所使用的css选择器。
|
|
486
|
+
|
|
487
|
+
具体示例请参考上文:[示例-数据表格组件]()。
|
|
488
|
+
|
|
489
|
+
### structured
|
|
490
|
+
|
|
491
|
+
选配,定义当前组件的子组件的插入方式。书写格式为`"structured":true`或`"structured": false`或`"structured": { slot: String, empty?: Boolean }`。
|
|
492
|
+
|
|
493
|
+
- true表示通过设计器内菜单中"+"插入;
|
|
494
|
+
- false表示通过拖拽插入;
|
|
495
|
+
- empty可以配置是否为此节点插入插槽。
|
|
496
|
+
|
|
497
|
+
如果在slotDefinitions 中配置了emptyBackground,则优先展示emptyBackground。具体示例请参考上文:[示例-表单组件]()。
|
|
498
|
+
|
|
499
|
+
### events
|
|
500
|
+
|
|
501
|
+
选配,定义页面设计器内支持的事件。书写格式为`"event": { key: value }` 。
|
|
502
|
+
|
|
503
|
+
- key:表示事件名称,目前支持 click 或 mousedown;
|
|
504
|
+
- value:表示生效条件,支持 true、false以及表达式。
|
|
505
|
+
|
|
506
|
+
例如为折叠面板组件定义点击事件,支持点击后在设计器中打开和关闭折叠面板项:
|
|
507
|
+
|
|
508
|
+
```typescript
|
|
509
|
+
"events": {"click": true}
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
### additionalAttribute
|
|
515
|
+
|
|
516
|
+
选配,定义设计器内组件展示时额外传入的属性。书写格式为`”additionalAttribute“: { key: value }` 。
|
|
517
|
+
|
|
518
|
+
**示例**
|
|
519
|
+
|
|
520
|
+
要求取消 react modal 在设计器里的弹出动画:
|
|
521
|
+
|
|
522
|
+
```typescript
|
|
523
|
+
@ExtensionComponent({
|
|
524
|
+
"ideusage": {
|
|
525
|
+
"idetype": "modal",
|
|
526
|
+
...
|
|
527
|
+
"additionalAttribute": {
|
|
528
|
+
"transitionName": "''",
|
|
529
|
+
"maskStyle": "{{opacity: 1,animationDuration: '0s'}}"
|
|
530
|
+
},
|
|
531
|
+
"cacheOpenKey": "open"
|
|
532
|
+
}
|
|
533
|
+
})
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
> 需要注意,传入的键值对将直接放入模板翻译结果,需要对 " 等特殊符号做转义。
|
|
537
|
+
|
|
538
|
+
**IDE 中的效果**
|
|
539
|
+
|
|
540
|
+
拖拽生成组件后,在页面设计器中生成的代码如下:
|
|
541
|
+
|
|
542
|
+
```html
|
|
543
|
+
<Modal okText="确定" cancelText="取消"
|
|
544
|
+
key="component-24445f4bd7be4acdb923d4e53c06fe58"
|
|
545
|
+
open={true}
|
|
546
|
+
transitionName=''
|
|
547
|
+
maskStyle={{opacity: 1,animationDuration: '0s'}}
|
|
548
|
+
title={...}
|
|
549
|
+
footer={...}>
|
|
550
|
+
...
|
|
551
|
+
</Modal>
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
### displaySlotConditions
|
|
555
|
+
|
|
556
|
+
选配,定义结构树上插槽节点的展示条件。书写格式为`”displaySlotConditions“: { key: value }` 。不配置的插槽名称默认都展示,即为 true。
|
|
557
|
+
|
|
558
|
+
- key:插槽名称,同slots配置下的name属性
|
|
559
|
+
- value:插槽展示条件,支持 true, false, 及表达式
|
|
560
|
+
|
|
561
|
+
**示例**
|
|
562
|
+
|
|
563
|
+
比如 react form input组件,在 labelIsSlot 生效的情况的才在结构树上展示label插槽。注意插槽的显示隐藏需要通过组件本身来控制。
|
|
564
|
+
|
|
565
|
+
```typescript
|
|
566
|
+
ideusage: {
|
|
567
|
+
"idetype": "container",
|
|
568
|
+
"textholder": "value",
|
|
569
|
+
"displaySlotConditions": {
|
|
570
|
+
"default": false,
|
|
571
|
+
"label": "this.getAttribute('labelIsSlot').value === true",
|
|
572
|
+
"description": false,
|
|
573
|
+
"extra": false
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
**IDE 中的效果**
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
### namedSlotOmitWrapper
|
|
585
|
+
|
|
586
|
+
选配,定义插槽是否不翻译idv外包裹。设计器会给每个具名插槽上加一个div包裹,用于标识具名插槽的DOM节点,但有时因为样式,可能不需要这层包裹的div。书写格式为`"namedSlotOmitWrapper":Boolean`。
|
|
587
|
+
|
|
588
|
+
### slotWrapperInlineStyle
|
|
589
|
+
|
|
590
|
+
选配,定义传入插槽外包裹的样式。书写格式为`"slotWrapperInlineStyle": { key: value }` 。
|
|
591
|
+
|
|
592
|
+
- key:插槽的名称;
|
|
593
|
+
- value:插槽外包裹的样式。
|
|
594
|
+
|
|
595
|
+
例如:上传组件放置文件信息的插槽为弹性布局容器。
|
|
596
|
+
|
|
597
|
+
```typescript
|
|
598
|
+
"slotWrapperInlineStyle": {
|
|
599
|
+
"file-list": "display:flex"
|
|
600
|
+
}
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
### slotInlineStyle
|
|
606
|
+
|
|
607
|
+
选配,定义插槽的样式,书写格式为`"slotInlineStyle": { key: value }` 。
|
|
608
|
+
|
|
609
|
+
- key:插槽的名称;
|
|
610
|
+
- value:插槽的样式。
|
|
611
|
+
|
|
612
|
+
例如:分栏布局组件的布局栏高度。
|
|
613
|
+
|
|
614
|
+
```typescript
|
|
615
|
+
"slotInlineStyle": {
|
|
616
|
+
"default": "height:100%;"
|
|
617
|
+
}
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
### displaySlotInline
|
|
623
|
+
|
|
624
|
+
选配,定义插槽外包裹使用行内样式的条件,书写格式为`"displaySlotInline":{ key: value }` 。
|
|
625
|
+
|
|
626
|
+
- key:插槽的名称;
|
|
627
|
+
- value:使用行内样式的条件,支持 true、false以及表达式。
|
|
628
|
+
|
|
629
|
+
例如:单选组的选项。
|
|
630
|
+
|
|
631
|
+
```typescript
|
|
632
|
+
"displaySlotInline": {
|
|
633
|
+
"item": true
|
|
634
|
+
}
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
### disableSlotAutoFill
|
|
640
|
+
|
|
641
|
+
选配,定义禁止自动插入插槽。书写格式为:`"disableSlotAutoFill":String | { slot: String, expression?: expression, fill?: expression }`。
|
|
642
|
+
|
|
643
|
+
- slot:插槽的名称;
|
|
644
|
+
- expression:生效条件;
|
|
645
|
+
- fill:替换的内容。
|
|
646
|
+
|
|
647
|
+
例如:
|
|
648
|
+
|
|
649
|
+
```typescript
|
|
650
|
+
"disableSlotAutoFill": [{
|
|
651
|
+
"slot": "title",
|
|
652
|
+
"expression": "this.getAttribute('title')",
|
|
653
|
+
"fill": "this.getAttribute('title').value"
|
|
654
|
+
}],
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
### useTemplateInDefaultSlot
|
|
658
|
+
|
|
659
|
+
选配,定义是否支持名为 default 的插槽为单个NASL节点。书写格式为`"useTemplateInDefaultSlot":Boolean`。
|
|
660
|
+
|
|
661
|
+
例如组件列表中,明确需要名为default的NASL插槽节点。
|
|
662
|
+
|
|
663
|
+
```typescript
|
|
664
|
+
"useTemplateInDefaultSlot":true
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
### expandWhenHesitate
|
|
670
|
+
|
|
671
|
+
选配,boolean,定义是否在悬停时撑开。书写格式为`"expandWhenHesitate":Boolean`。
|
|
672
|
+
|
|
673
|
+
例如线性布局组件,悬停时撑开边缘,方便在边缘重合的情况下插入组件。
|
|
674
|
+
|
|
675
|
+
```typescript
|
|
676
|
+
"expandWhenHesitate":true
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
### iconEditor
|
|
682
|
+
|
|
683
|
+
选配,定义是否支持双击组件打开icon面板并设置icon。书写格式为`"iconEditor":Boolean`,例如:
|
|
684
|
+
|
|
685
|
+
```typescript
|
|
686
|
+
"iconEditor":true
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
### operator
|
|
692
|
+
|
|
693
|
+
选配,定义支持的操作配置,不配置时默认全支持。书写格式为:`“operator”: { copy?:expression, cut?: expression, duplicate?: expression, d2c?: expression }` ,expression 为生效的条件。
|
|
694
|
+
|
|
695
|
+
例如 vant 的单选组组件,其删除操作在radio-group设置了数据源的情况下禁止,但是不禁止直接子节点的删除。
|
|
696
|
+
|
|
697
|
+
```typescript
|
|
698
|
+
ideusage: {
|
|
699
|
+
"idetype": "container",
|
|
700
|
+
"operator": {
|
|
701
|
+
"delete": "!this.getParent().getParent().getAttribute('dataSource')"
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
### useFxOrEg
|
|
711
|
+
|
|
712
|
+
选配,定义支持表达式和示例切换的属性。书写格式为`useFxOrEg: { property: String, displayAsAttr?: Boolean }` 。
|
|
713
|
+
|
|
714
|
+
- property:表示支持的属性名;
|
|
715
|
+
- displayAsAttr: 表示组件是否支持内部插入子元素。
|
|
716
|
+
|
|
717
|
+
例如:
|
|
718
|
+
|
|
719
|
+
```typescript
|
|
720
|
+
"useFxOrEg":{"property": "text"}
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
> 示例中的 text 属性来源于 api.ts 中的属性描述,实现属性描述请参考[组件配置编写说明](../api.md)。
|
|
724
|
+
|
|
725
|
+
在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)。
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
|