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
package/packages/lcap-frontend-library/references/lcap-extension-component/nasl-view-component.md
ADDED
|
@@ -0,0 +1,895 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# View Component API 书写指南和规范
|
|
6
|
+
|
|
7
|
+
## 1. 介绍
|
|
8
|
+
|
|
9
|
+
### 1.1 背景
|
|
10
|
+
|
|
11
|
+
CodeWave 智能开发平台可以集成多种不同的前端技术栈(包括 Vue2、React 等),配置 api.ts 主要能让 IDE 识别多种技术栈的组件,在 IDE 的右侧属性、样式、事件面板中、在设计器的插槽下拉菜单中、在逻辑设计器的可访问属性列表、事件对象参数、current 参数等能够有友好的编辑体验,并且能够支持精确的类型检查和智能自然语言生成 UI 等高级体验。
|
|
12
|
+
|
|
13
|
+
### 1.2 定义
|
|
14
|
+
|
|
15
|
+
**用于描述一组页面组件的 API 的书写规范,目前要求使用 TypeScript 的 class 和 decorator 方式书写。**
|
|
16
|
+
|
|
17
|
+
<div class="yellowBlock">
|
|
18
|
+
|
|
19
|
+
说明:目前用 TypeScript 书写,而不用 JSON/YAML,主要有以下几点原因:
|
|
20
|
+
- 类型推导(特别是泛型相关)在不用 TypeScript 的情况下书写困难
|
|
21
|
+
- 配置参数在不用 TypeScript 的情况下检查粒度较粗,在 IDE 中容易出问题
|
|
22
|
+
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
参考 [vue-facing-decorator](https://github.com/facing-dev/vue-facing-decorator)、[vue-property-decorator](https://github.com/kaorun343/vue-property-decorator) 以及 React class component 的书写方式。
|
|
26
|
+
|
|
27
|
+
### 1.3 适合范围
|
|
28
|
+
|
|
29
|
+
适用于基础组件库,和扩展依赖库 lcap 脚手架工具的页面组件部分。
|
|
30
|
+
|
|
31
|
+
## 2. 指南
|
|
32
|
+
|
|
33
|
+
### 2.1 准备
|
|
34
|
+
|
|
35
|
+
- **文件名统一为\`api.ts\`**
|
|
36
|
+
|
|
37
|
+
> 注意:decorator 无法在 d.ts 声明文件中使用。
|
|
38
|
+
|
|
39
|
+
- **安装 npm 包:@nasl/types**
|
|
40
|
+
|
|
41
|
+
### 2.2 基本概念
|
|
42
|
+
|
|
43
|
+
在书写 API 之前,需要先了解以下概念:
|
|
44
|
+
|
|
45
|
+
- **组件声明(ViewComponent)**:在 CodeWave平台中,CodeWave的组件可通过引用访问属性和方法(这部分的作用域与属性和事件绑定不完全一样,因此分成了两个类)
|
|
46
|
+
- **可访问属性**:在 IDE 中类似这样的方式`$refs.tableView.data`来访问
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
- **方法**:在 IDE 中类似这样的方式`$refs.tableView.exportExcel(page, size, ...)`来使用
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
- **组件选项(ViewComponentOptions)**:
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
- **属性**:在 IDE 中的右侧属性面板绑定表达式来使用
|
|
59
|
+
|
|
60
|
+
- **静态绑定**:在属性面板中的默认交互形态,比如开关、输入框等
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
- **动态绑定**:点击“动态绑定”图标后切换到的形态,可以绑定一个 NASL 表达式
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
- **双向绑定**:语法糖,同 Vue 的双向绑定
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
- **事件**:在 IDE 中的右侧事件面板添加事件逻辑来使用
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
- **event 事件对象**:要求有且只有一个事件对象,不需要传参时类型可设置为 null
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
- **插槽**:在 IDE 中的页面设计器中可插入子组件或其他组件
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
- **current 插槽参数对象**:要求**没有或者只有一个**插槽参数对象,不需要传参时不设置参数
|
|
85
|
+
|
|
86
|
+
<div class="highlight">
|
|
87
|
+
|
|
88
|
+
current 对象就是 Vue 的作用域插槽 scope 对象,只是在CodeWave平台中主要用于循环组件每一项展示的自定义,因此起名为“当前项”的含义。current 是 Current 类型,一般包含的字段有 { item: 列表循环的当前项, index: 循环索引, value: 根据“值字段属性”计算出的 value, rowIndex 和 columnIndex 仅在表格中使用 }</br>
|
|
89
|
+
|
|
90
|
+
多层循环组件嵌套时,为了不出现变量名遮盖的问题,current 会依次命名为 current, current1, current2, ...
|
|
91
|
+
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
- **snippets 代码片段**:插槽代码片段列表。如下图,一般用于在主组件的插槽中添加子组件。
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
- **主组件与子组件**:一般默认配置的都是主组件。有些组件是主组件与子组件结合在一起使用的,这里的主组件也被定义为父组件,如侧边栏+侧边栏项、多选组+多选框、选项卡+标签页等。子组件主要用于配合主组件使用,在 IDE 的组件面板中不直接显示,一般通过代码片段添加。它的声明内容与主组件基本相似。
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
### 2.3 大致结构
|
|
105
|
+
|
|
106
|
+
文件大致结构如下(中文部分需要替换成真实内容):
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
/// <reference types="@nasl/types" />
|
|
110
|
+
|
|
111
|
+
namespace nasl.ui {
|
|
112
|
+
@Component({
|
|
113
|
+
title: '组件标题',
|
|
114
|
+
description: '组件描述',
|
|
115
|
+
...
|
|
116
|
+
})
|
|
117
|
+
export class 组件名<泛型参数,可选> extends ViewComponent {
|
|
118
|
+
@Prop({
|
|
119
|
+
title: '可访问属性标题',
|
|
120
|
+
})
|
|
121
|
+
可访问属性名: 类型;
|
|
122
|
+
|
|
123
|
+
@Method({
|
|
124
|
+
title: '方法标题',
|
|
125
|
+
description: '方法描述',
|
|
126
|
+
})
|
|
127
|
+
方法名(参数1, 参数2, ...): 返回类型 { /* 不用实现 */ }
|
|
128
|
+
|
|
129
|
+
constructor(options?: Partial<组件名Options<泛型参数,可选>>) { super(); }
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export class 组件名Options<泛型参数,可选> extends ViewComponentOptions {
|
|
133
|
+
@Prop({
|
|
134
|
+
title: '属性标题',
|
|
135
|
+
...
|
|
136
|
+
})
|
|
137
|
+
属性名: 类型 = 默认值;
|
|
138
|
+
|
|
139
|
+
@Prop({
|
|
140
|
+
title: '属性标题',
|
|
141
|
+
...
|
|
142
|
+
})
|
|
143
|
+
private 属性名: 类型; /* private 表示暂时不对用户开放 */
|
|
144
|
+
|
|
145
|
+
@Event({
|
|
146
|
+
title: '事件标题',
|
|
147
|
+
description: '事件描述',
|
|
148
|
+
})
|
|
149
|
+
on事件名: (event: 事件对象类型) => void; /* 一般以 on 开头,固定一个 event 对象参数;须为合法属性名,禁止 'onUpdate:modelValue',双向绑定场景用 onUpdateModelValue */
|
|
150
|
+
|
|
151
|
+
@Slot({
|
|
152
|
+
title: '插槽标题',
|
|
153
|
+
description: '插槽描述',
|
|
154
|
+
snippets: [ // 快捷添加代码片段
|
|
155
|
+
{
|
|
156
|
+
title: '代码片段标题',
|
|
157
|
+
code: '代码片段内容',
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
})
|
|
161
|
+
slot插槽名: (插槽参数, 可选) => Array<可插入的组件1 | 可插入的组件2 | 可插入的组件3>; /* 插槽返回类型规定了可插入哪些子组件或其他组件 */
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@Component({
|
|
165
|
+
title: '子组件标题',
|
|
166
|
+
description: '子组件描述',
|
|
167
|
+
...
|
|
168
|
+
})
|
|
169
|
+
export class 子组件名<泛型参数,可选> extends ViewComponent { ... }
|
|
170
|
+
|
|
171
|
+
export class 子组件名Options<泛型参数,可选> extends ViewComponentOptions { ... }
|
|
172
|
+
|
|
173
|
+
...
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
基础配置参数可查阅下文中的规范部分,这里不再详述。
|
|
178
|
+
|
|
179
|
+
### 2.4 NASL 类型
|
|
180
|
+
|
|
181
|
+
为了能够顺利集成到 NASL 的类型系统中,\`@nasl/types\`包给 TypeScript 的传统类型起了别名。类型声明请使用以下写法:
|
|
182
|
+
|
|
183
|
+
#### a. 基础类型
|
|
184
|
+
|
|
185
|
+
```javascript
|
|
186
|
+
nasl.core.Boolean // 相当于 boolean
|
|
187
|
+
nasl.core.Integer // 相当于 number
|
|
188
|
+
nasl.core.Decimal // 相当于 number
|
|
189
|
+
nasl.core.String // 相当于 string
|
|
190
|
+
nasl.core.Date // 相当于 Date
|
|
191
|
+
nasl.core.DateTime // 相当于 Date
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
#### b. 集合类型
|
|
195
|
+
|
|
196
|
+
```javascript
|
|
197
|
+
nasl.collection.List<T> // 相当于 Array<T>
|
|
198
|
+
nasl.collection.Map<K, V> // 相当于 Record<K, V>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### c. 匿名数据结构(对应 TS 的 object 类型)
|
|
202
|
+
|
|
203
|
+
```javascript
|
|
204
|
+
{ list: nasl.collection.List<T>, total: nasl.core.Integer }
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
#### d. Union 类型
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
nasl.core.Boolean | nasl.core.String
|
|
211
|
+
nasl.collection.List<T> | { list: nasl.collection.List<T>, total: nasl.core.Integer }
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### e. 其他
|
|
215
|
+
|
|
216
|
+
在属性、方法和事件的类型声明处不要使用 any,在 decorator 中可以使用 any。
|
|
217
|
+
|
|
218
|
+
### 2.5 组件属性和可访问属性的配置要点
|
|
219
|
+
|
|
220
|
+
#### a. 默认值
|
|
221
|
+
|
|
222
|
+
组件属性在标注类型后,可以用赋值\`=\`设置默认值。可访问属性设置默认值没有意义。
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
prop1: nasl.core.Integer = 0;
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### b. 字符串枚举
|
|
229
|
+
|
|
230
|
+
某些属性在静态绑定时,想要快速的选择效果,这时可以用 TS 的字符串枚举表示选项值,并配合枚举型 Setter 使用。但对应的 NASL 类型仍为\`nasl.core.String\`。
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
@Prop({
|
|
234
|
+
title: '样式类型'
|
|
235
|
+
setter: {
|
|
236
|
+
concept: 'EnumSelectSetter',
|
|
237
|
+
options: [{ title: '默认' }, { title: '浅色' }, { title: '成功色' }, { title: '警告色' }, { title: '危险色' }],
|
|
238
|
+
},
|
|
239
|
+
...
|
|
240
|
+
})
|
|
241
|
+
color: 'default' | 'light' | 'success' | 'warning' | 'danger' = 'default';
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
目前枚举型的 Setter 主要有两种:**EnumSelectSetter**、**CapsulesSetter**,详见下表。
|
|
245
|
+
|
|
246
|
+
#### c. 设置器
|
|
247
|
+
|
|
248
|
+
| 设置器名称 | 说明 | 支持类型 | 效果图 |
|
|
249
|
+
| :------- | :-------------- | :------- | :------ |
|
|
250
|
+
| **InputSetter** | 输入框设置器(默认) | any | |
|
|
251
|
+
| **SwitchSetter** | 开关设置器 | nasl.core.Boolean | |
|
|
252
|
+
| **EnumSelectSetter** | 枚举选择设置器 | nasl.core.String(字符串枚举形式)| |
|
|
253
|
+
| **CapsulesSetter** | 胶囊设置器 | nasl.core.String(字符串枚举形式)| |
|
|
254
|
+
| **NumberInputSetter** | 数字输入设置器 | nasl.core.Integer \| nasl.core.Decimal | |
|
|
255
|
+
| **IconSetter** | 图标设置器 | nasl.core.String | |
|
|
256
|
+
| **ImageSetter** | 图片设置器 | nasl.core.String | |
|
|
257
|
+
| **PropertySelectSetter** | 属性选择设置器 | nasl.core.String | |
|
|
258
|
+
| **AnonymousFunctionSetter** | 匿名函数设置器 | (...args) => any | |
|
|
259
|
+
|
|
260
|
+
具体参数可以见后文“规范 References - 各种 Setter 的参数”一节。
|
|
261
|
+
|
|
262
|
+
#### d. 联动显隐和禁用
|
|
263
|
+
|
|
264
|
+
属性联动显隐使用\`if\`进行配置。该选项接收一个箭头函数,表示该属性在什么情况下显示。\`\_\`参数表示 IDE 中所有属性的当前状态。
|
|
265
|
+
|
|
266
|
+
比如下面的例子表示“默认每页条数”这个属性选项在“分页”选项开启时才展示。
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
@Prop({
|
|
270
|
+
title: '分页',
|
|
271
|
+
...
|
|
272
|
+
})
|
|
273
|
+
pagination: nasl.core.Boolean;
|
|
274
|
+
@Prop<UTableViewOptions<T, V, P, M>, 'pageSize'>({
|
|
275
|
+
title: '默认每页条数',
|
|
276
|
+
if: _ => _.pagination === true
|
|
277
|
+
...
|
|
278
|
+
})
|
|
279
|
+
pageSize: nasl.core.Integer = 20;
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
在 IDE 中的效果如下:
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
联动禁用同理,配置\`disabledIf\`即可。
|
|
287
|
+
|
|
288
|
+
#### e. 联动更新和清除
|
|
289
|
+
|
|
290
|
+
属性联动修改用\`onChange\`进行配置。该选项接收一个复杂的数组类型。
|
|
291
|
+
|
|
292
|
+
下面的示例表示"全选控制"属性改变时,清除“最小选中数”和“最大选中数”属性值;并且仅在"全选控制"属性关闭时展示“最小选中数”和“最大选中数”属性。
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
@Prop<UCheckboxesOptions<T, V, C>, 'min'>({
|
|
296
|
+
title: '最小选中数',
|
|
297
|
+
if: _ => _.checkAll === false
|
|
298
|
+
...
|
|
299
|
+
})
|
|
300
|
+
min: nasl.core.Integer = 0;
|
|
301
|
+
@Prop<UCheckboxesOptions<T, V, C>, 'max'>({
|
|
302
|
+
title: '最大选中数',
|
|
303
|
+
if: _ => _.checkAll === false
|
|
304
|
+
...
|
|
305
|
+
})
|
|
306
|
+
max: nasl.core.Integer;
|
|
307
|
+
@Prop<UCheckboxesOptions<T, V, C>, 'checkAll'>({
|
|
308
|
+
title: '全选控制',
|
|
309
|
+
...
|
|
310
|
+
onChange: [
|
|
311
|
+
{ clear: ['min', 'max'] }
|
|
312
|
+
],
|
|
313
|
+
})
|
|
314
|
+
checkAll: nasl.core.Boolean = false;
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
在 IDE 中的效果如下:
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
下面是一个复杂的联动更新的例子,表示当“图片裁剪形状”改变时,根据不同情况,修改“裁剪框的高度”值和显隐。
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
@Prop<UUploaderOptions, 'cropperPreviewShape'>({
|
|
325
|
+
title: '图片裁剪框预览形状',
|
|
326
|
+
onChange: [
|
|
327
|
+
{ update: { cropperBoxHeight: 200 }, if: _ => _ === 'rect' },
|
|
328
|
+
{ update: { cropperBoxHeight: 0 }, if: _ => _ === 'circle' },
|
|
329
|
+
{ update: { cropperBoxHeight: 0 }, if: _ => _ === 'square' },
|
|
330
|
+
],
|
|
331
|
+
if: _ => _.openCropper === true && _.multiple !== true,
|
|
332
|
+
...
|
|
333
|
+
})
|
|
334
|
+
cropperPreviewShape: 'rect' | 'square' | 'circle' = 'circle';
|
|
335
|
+
@Prop<UUploaderOptions, 'cropperBoxHeight'>({
|
|
336
|
+
title: '图片裁剪框高度',
|
|
337
|
+
if: _ => _.cropperPreviewShape === 'rect' && _.openCropper === true && _.multiple !== true
|
|
338
|
+
...
|
|
339
|
+
})
|
|
340
|
+
cropperBoxHeight: nasl.core.Decimal | nasl.core.Integer = 0;
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
在 IDE 中的效果如下:
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
### 2.6 事件配置要点
|
|
348
|
+
|
|
349
|
+
目前事件的\`event\`参数必须有,推荐以匿名数据结构为主。
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
@Event({
|
|
353
|
+
title: '改变后',
|
|
354
|
+
description: '单选或多选值改变后触发',
|
|
355
|
+
})
|
|
356
|
+
onChange: (event: {
|
|
357
|
+
value: V;
|
|
358
|
+
oldValue: V;
|
|
359
|
+
item: T;
|
|
360
|
+
oldItem: T;
|
|
361
|
+
values: nasl.collection.List<V>;
|
|
362
|
+
oldValues: nasl.collection.List<V>;
|
|
363
|
+
items: nasl.collection.List<T>;
|
|
364
|
+
}) => void;
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### 2.7 插槽配置要点
|
|
368
|
+
|
|
369
|
+
插槽为一个箭头函数类型,入参为插槽参数,返回为支持的组件类型数组。
|
|
370
|
+
|
|
371
|
+
下面的例子表示该默认插槽只支持侧边栏的几个子组件,并且在\`snippets\`中添加了对应的片段。
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
@Slot({
|
|
375
|
+
title: '默认',
|
|
376
|
+
snippets: [
|
|
377
|
+
{
|
|
378
|
+
title: '侧边栏分组',
|
|
379
|
+
code: '<u-sidebar-group><template #title><u-text text="分组"></u-text></template><u-sidebar-item><u-text text="侧边栏项"></u-text></u-sidebar-item></u-sidebar-group>',
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
title: '侧边栏项',
|
|
383
|
+
code: '<u-sidebar-item><u-text text="侧边栏项"></u-text></u-sidebar-item>',
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
title: '分隔线',
|
|
387
|
+
code: '<u-sidebar-divider></u-sidebar-divider>',
|
|
388
|
+
},
|
|
389
|
+
],
|
|
390
|
+
})
|
|
391
|
+
slotDefault: () => Array<USidebarGroup | USidebarItem | USidebarDivider>;
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
在 IDE 中的效果如下:
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
循环类组件的插槽请使用`current: Current<T>`类型传递循环项\`item\`。
|
|
399
|
+
|
|
400
|
+
```typescript
|
|
401
|
+
@Slot({
|
|
402
|
+
title: '循环项的插槽',
|
|
403
|
+
description: '自定义选项的结构和样式',
|
|
404
|
+
})
|
|
405
|
+
slotItem: (current: Current<T>) => Array<nasl.ui.ViewComponent>;
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### 2.8 泛型组件和类型推导
|
|
409
|
+
|
|
410
|
+
为了更精确的类型检查,一般循环类组件会用泛型表示:\`T\`表示\`item\`的类型。
|
|
411
|
+
|
|
412
|
+
```typescript
|
|
413
|
+
export class MySelect<T> extends ViewComponent {
|
|
414
|
+
value: nasl.core.String;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export class MySelectOptions<T> extends ViewComponentOptions {
|
|
418
|
+
dataSource: nasl.collection.List<T>;
|
|
419
|
+
value: nasl.core.String;
|
|
420
|
+
}
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
如果组件设计得更灵活一些,能让用户自行选择值字段。这时值字段的类型会随着用户选择而变化。
|
|
424
|
+
|
|
425
|
+
在设计时,一般用\`V\`表示选择值的类型,再设置\`valueField\`的属性类型进行类型推导。
|
|
426
|
+
|
|
427
|
+
```typescript
|
|
428
|
+
export class MySelect<T, V, M extends nasl.core.Boolean> extends ViewComponent {
|
|
429
|
+
value: M extends true ? nasl.collection.List<V> : V;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export class MySelectOptions<T, V, M extends nasl.core.Boolean> extends ViewComponentOptions {
|
|
433
|
+
dataSource: nasl.collection.List<T>;
|
|
434
|
+
valueField: (item: T) => V; // 通过函数类型进行推导
|
|
435
|
+
multiple: M;
|
|
436
|
+
value: M extends true ? nasl.collection.List<V> : V;
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
这时可以看到一条属性的**类型推导链**:\`dataSource -> valueField -> value\`(反过来可以看成属性的**类型依赖链**)
|
|
441
|
+
|
|
442
|
+
更复杂的组件可能会有复杂的类型推导关系。假设这个选择器能够同时支持单/多选,那么它的\`value\`类型会依赖\`multiple\`这个选项属性的值。这时可以用 TS 的条件类型\`A extends ? B : C\`来表示。同时需要再引入一个泛型参数。
|
|
443
|
+
|
|
444
|
+
```typescript
|
|
445
|
+
export class MySelect<T, V, M extends nasl.core.Boolean> extends ViewComponent {
|
|
446
|
+
value: M extends true ? nasl.collection.List<V> : V;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export class MySelectOptions<T, V, M extends nasl.core.Boolean> extends ViewComponentOptions {
|
|
450
|
+
dataSource: nasl.collection.List<T>;
|
|
451
|
+
valueField: (item: T) => V; // 通过函数类型进行推导
|
|
452
|
+
multiple: M;
|
|
453
|
+
value: M extends true ? nasl.collection.List<V> : V;
|
|
454
|
+
}
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
这时的**类型推导链**为:\`(dataSource -> valueField, multiple) -> value\`,\`value\`的类型由前面的几个属性类型共同决定。
|
|
458
|
+
|
|
459
|
+
### 2.9 综合示例
|
|
460
|
+
|
|
461
|
+
综合前面的教程,下面完成一个完整的支持单/多选的“我的选择框”组件的 API 定义。
|
|
462
|
+
|
|
463
|
+
> 样例模板,不建议直接复制使用。
|
|
464
|
+
|
|
465
|
+
```typescript
|
|
466
|
+
@Component({
|
|
467
|
+
title: '我的选择框',
|
|
468
|
+
description: 'api.ts 示例组件',
|
|
469
|
+
})
|
|
470
|
+
export class MySelect<T, V, M extends nasl.core.Boolean> extends ViewComponent {
|
|
471
|
+
@Prop({
|
|
472
|
+
title: '选中值',
|
|
473
|
+
})
|
|
474
|
+
value: MySelect<T, V, M>['value']; // 这里为了和 MySelectOptions 保持一致
|
|
475
|
+
|
|
476
|
+
@Method({
|
|
477
|
+
title: '添加选项',
|
|
478
|
+
})
|
|
479
|
+
addItem(
|
|
480
|
+
@Param({
|
|
481
|
+
title: '要添加的选项',
|
|
482
|
+
})
|
|
483
|
+
item: T,
|
|
484
|
+
): void {}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
export class MySelectOptions<T, V, M extends nasl.core.Boolean> extends ViewComponentOptions {
|
|
488
|
+
@Prop({
|
|
489
|
+
group: '数据属性',
|
|
490
|
+
title: '数据源',
|
|
491
|
+
description: '展示数据的输入源,可设置为集合类型变量(List<T>)或输出参数为集合类型的逻辑。',
|
|
492
|
+
})
|
|
493
|
+
dataSource: { list: nasl.collection.List<T>; total: nasl.core.Integer } | nasl.collection.List<T>;
|
|
494
|
+
|
|
495
|
+
@Prop<USelectOptions<T, V, M>, 'valueField'>({
|
|
496
|
+
group: '数据属性',
|
|
497
|
+
title: '值字段',
|
|
498
|
+
description: '集合的元素类型中,用于标识选中值的属性',
|
|
499
|
+
setter: { concept: 'PropertySelectSetter' }, // 用属性选择器进行选择
|
|
500
|
+
})
|
|
501
|
+
valueField: (item: T) => V; // 通过函数类型进行推导'
|
|
502
|
+
|
|
503
|
+
@Prop({
|
|
504
|
+
group: '交互属性',
|
|
505
|
+
title: '可多选',
|
|
506
|
+
description: '设置是否可以多选行',
|
|
507
|
+
setter: { concept: 'SwitchSetter' },
|
|
508
|
+
})
|
|
509
|
+
multiple: M;
|
|
510
|
+
|
|
511
|
+
@Prop({
|
|
512
|
+
group: '数据属性',
|
|
513
|
+
title: '选中值',
|
|
514
|
+
description: '当前选中的值',
|
|
515
|
+
sync: true,
|
|
516
|
+
})
|
|
517
|
+
value: M extends true ? nasl.collection.List<V> : V;
|
|
518
|
+
|
|
519
|
+
@Event({
|
|
520
|
+
title: '改变后',
|
|
521
|
+
description: '选择值改变时触发',
|
|
522
|
+
})
|
|
523
|
+
onChange: (event: {
|
|
524
|
+
value: V;
|
|
525
|
+
values: nasl.collection.List<V>;
|
|
526
|
+
}) => void;
|
|
527
|
+
|
|
528
|
+
@Slot({
|
|
529
|
+
title: '默认',
|
|
530
|
+
description: '插入子组件',
|
|
531
|
+
snippets: [
|
|
532
|
+
{
|
|
533
|
+
title: '选项',
|
|
534
|
+
code: '<my-select-item><u-text text="选项"></u-text></my-select-item>',
|
|
535
|
+
},
|
|
536
|
+
],
|
|
537
|
+
})
|
|
538
|
+
slotDefault: () => Array<MySelectItem<T, V>>;
|
|
539
|
+
}
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
## 3. 规范 References
|
|
543
|
+
|
|
544
|
+
### 3.1 @Component 的参数
|
|
545
|
+
|
|
546
|
+
```typescript
|
|
547
|
+
export interface ViewComponentOpts {
|
|
548
|
+
/**
|
|
549
|
+
- 组件标题
|
|
550
|
+
*/
|
|
551
|
+
title: string;
|
|
552
|
+
/**
|
|
553
|
+
- 组件分组
|
|
554
|
+
*/
|
|
555
|
+
group?: string;
|
|
556
|
+
/**
|
|
557
|
+
- 组件图标
|
|
558
|
+
*/
|
|
559
|
+
icon?: string;
|
|
560
|
+
/**
|
|
561
|
+
- 组件描述
|
|
562
|
+
*/
|
|
563
|
+
description?: string;
|
|
564
|
+
}
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
### 3.2 @Prop 的参数
|
|
568
|
+
|
|
569
|
+
```typescript
|
|
570
|
+
export interface PropOpts<T extends object, K extends keyof T> {
|
|
571
|
+
/**
|
|
572
|
+
- 属性标题
|
|
573
|
+
*/
|
|
574
|
+
title: string;
|
|
575
|
+
/**
|
|
576
|
+
- 属性分组
|
|
577
|
+
*/
|
|
578
|
+
group?: '基础信息' | '数据属性' | '主要属性' | '交互属性' | '状态属性' | '样式属性' | '工具属性';
|
|
579
|
+
/**
|
|
580
|
+
- 属性图标
|
|
581
|
+
*/
|
|
582
|
+
icon?: string;
|
|
583
|
+
/**
|
|
584
|
+
- 属性描述
|
|
585
|
+
*/
|
|
586
|
+
description?: string;
|
|
587
|
+
/**
|
|
588
|
+
- 属性是否具备双向绑定的功能
|
|
589
|
+
*/
|
|
590
|
+
sync?: boolean;
|
|
591
|
+
/**
|
|
592
|
+
- 属性在 IDE 中的工具提示
|
|
593
|
+
*/
|
|
594
|
+
tooltipLink?: string;
|
|
595
|
+
/**
|
|
596
|
+
- 属性文档描述
|
|
597
|
+
*/
|
|
598
|
+
docDescription?: string;
|
|
599
|
+
/**
|
|
600
|
+
- 该属性的动态绑定功能是否隐藏
|
|
601
|
+
- 对于某些属性可能不想支持动态绑定功能
|
|
602
|
+
*/
|
|
603
|
+
bindHide?: boolean;
|
|
604
|
+
/**
|
|
605
|
+
- 切换该属性到动态绑定时,是否直接打开表达式编辑区
|
|
606
|
+
*/
|
|
607
|
+
bindOpen?: boolean;
|
|
608
|
+
/**
|
|
609
|
+
- 该属性在属性面板配置还是在样式面板配置
|
|
610
|
+
*/
|
|
611
|
+
tabKind?: 'property' | 'style';
|
|
612
|
+
/**
|
|
613
|
+
- 配置静态绑定时的设置器,比如开关、输入框、选择框等
|
|
614
|
+
*/
|
|
615
|
+
setter?: BaseSetter<T, K>;
|
|
616
|
+
/**
|
|
617
|
+
- 在设计器中的默认填充数据,比如表格默认需要3列
|
|
618
|
+
*/
|
|
619
|
+
designerValue?: any;
|
|
620
|
+
/**
|
|
621
|
+
- 用于控制属性联动,表示在什么情况下显示
|
|
622
|
+
- @param target 配置时的属性对象
|
|
623
|
+
*/
|
|
624
|
+
if?: (target: T) => boolean;
|
|
625
|
+
/**
|
|
626
|
+
- 用于控制属性联动,表示在什么情况下禁用
|
|
627
|
+
- @param target 配置时的属性对象
|
|
628
|
+
*/
|
|
629
|
+
disabledIf?: (target: T) => boolean;
|
|
630
|
+
/**
|
|
631
|
+
- 该属性在修改值时,触发其他哪些属性的更新
|
|
632
|
+
*/
|
|
633
|
+
onChange?: Array<{ update: Array<string>; if?: (value: T[K]) => boolean } | { clear: Array<string>; if?: (value: T[K]) => boolean }>;
|
|
634
|
+
}
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
### 3.3 @Event 的参数
|
|
638
|
+
|
|
639
|
+
```typescript
|
|
640
|
+
export interface EventOpts {
|
|
641
|
+
/**
|
|
642
|
+
- 事件标题
|
|
643
|
+
*/
|
|
644
|
+
title: string;
|
|
645
|
+
/**
|
|
646
|
+
- 事件描述
|
|
647
|
+
*/
|
|
648
|
+
description?: string;
|
|
649
|
+
}
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
### 3.4 @Method 的参数
|
|
653
|
+
|
|
654
|
+
```typescript
|
|
655
|
+
export interface MethodOpts {
|
|
656
|
+
/**
|
|
657
|
+
- 方法标题
|
|
658
|
+
*/
|
|
659
|
+
title: string;
|
|
660
|
+
/**
|
|
661
|
+
- 方法描述
|
|
662
|
+
*/
|
|
663
|
+
description: string;
|
|
664
|
+
}
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
### 3.5 @Slot 的参数
|
|
668
|
+
|
|
669
|
+
```typescript
|
|
670
|
+
export interface SlotOpts {
|
|
671
|
+
/**
|
|
672
|
+
- 插槽标题
|
|
673
|
+
*/
|
|
674
|
+
title: string;
|
|
675
|
+
/**
|
|
676
|
+
- 插槽描述
|
|
677
|
+
*/
|
|
678
|
+
description?: string;
|
|
679
|
+
/**
|
|
680
|
+
- 空态图,比如表格没有设置数据源时的背景效果
|
|
681
|
+
*/
|
|
682
|
+
emptyBackground?: string;
|
|
683
|
+
/**
|
|
684
|
+
- 代码片段
|
|
685
|
+
*/
|
|
686
|
+
snippets?: Array<ViewBlock>;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
export interface ViewBlock {
|
|
690
|
+
/**
|
|
691
|
+
- 代码片段标题
|
|
692
|
+
*/
|
|
693
|
+
title: string;
|
|
694
|
+
/**
|
|
695
|
+
- 代码内容
|
|
696
|
+
*/
|
|
697
|
+
code: string;
|
|
698
|
+
/**
|
|
699
|
+
- 代码片段描述
|
|
700
|
+
*/
|
|
701
|
+
description?: string;
|
|
702
|
+
}
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
### 3.6 各种 Setter 的参数
|
|
706
|
+
|
|
707
|
+
```typescript
|
|
708
|
+
/**
|
|
709
|
+
* 输入框设置器
|
|
710
|
+
*/
|
|
711
|
+
export interface InputSetter {
|
|
712
|
+
concept: 'InputSetter';
|
|
713
|
+
/**
|
|
714
|
+
- 占位文本
|
|
715
|
+
*/
|
|
716
|
+
placeholder?: string;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* 切换设置器
|
|
721
|
+
*/
|
|
722
|
+
export interface SwitchSetter {
|
|
723
|
+
concept: 'SwitchSetter';
|
|
724
|
+
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* 枚举选择设置器
|
|
729
|
+
*/
|
|
730
|
+
export interface EnumSelectSetter {
|
|
731
|
+
concept: 'EnumSelectSetter';
|
|
732
|
+
/**
|
|
733
|
+
* 节点变更时间
|
|
734
|
+
*/
|
|
735
|
+
changedTime?: number;
|
|
736
|
+
/**
|
|
737
|
+
* 枚举选项列表
|
|
738
|
+
*/
|
|
739
|
+
options: Array<SetterOption>;
|
|
740
|
+
/**
|
|
741
|
+
* 是否多选
|
|
742
|
+
*/
|
|
743
|
+
multiple?: boolean;
|
|
744
|
+
/**
|
|
745
|
+
* 是否可清空
|
|
746
|
+
*/
|
|
747
|
+
clearable?: boolean;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* 设置器枚举选项
|
|
752
|
+
*/
|
|
753
|
+
export interface SetterOption {
|
|
754
|
+
concept: 'SetterOption';
|
|
755
|
+
/**
|
|
756
|
+
* 节点变更时间
|
|
757
|
+
*/
|
|
758
|
+
changedTime?: number;
|
|
759
|
+
/**
|
|
760
|
+
* 选项值
|
|
761
|
+
*/
|
|
762
|
+
value: string;
|
|
763
|
+
/**
|
|
764
|
+
* 选项标题
|
|
765
|
+
*/
|
|
766
|
+
title: string;
|
|
767
|
+
/**
|
|
768
|
+
* 选项图标
|
|
769
|
+
*/
|
|
770
|
+
icon?: string;
|
|
771
|
+
/**
|
|
772
|
+
* 选项工具提示
|
|
773
|
+
*/
|
|
774
|
+
tooltip?: string;
|
|
775
|
+
/**
|
|
776
|
+
* 是否显隐
|
|
777
|
+
*
|
|
778
|
+
* 用 TS 写表达式,在 IDE 中直接 eval
|
|
779
|
+
*/
|
|
780
|
+
tsIf?: string;
|
|
781
|
+
/**
|
|
782
|
+
* 是否禁用
|
|
783
|
+
*
|
|
784
|
+
* 用 TS 写表达式,在 IDE 中直接 eval
|
|
785
|
+
*/
|
|
786
|
+
tsDisabledIf?: string;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* 胶囊设置器
|
|
791
|
+
*/
|
|
792
|
+
export interface CapsulesSetter {
|
|
793
|
+
concept: 'CapsulesSetter';
|
|
794
|
+
/**
|
|
795
|
+
* 节点变更时间
|
|
796
|
+
*/
|
|
797
|
+
changedTime?: number;
|
|
798
|
+
/**
|
|
799
|
+
* 枚举选项列表
|
|
800
|
+
*/
|
|
801
|
+
options: Array<SetterOption>;
|
|
802
|
+
/**
|
|
803
|
+
* 是否多选
|
|
804
|
+
*/
|
|
805
|
+
multiple?: boolean;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* 数字输入设置器
|
|
810
|
+
*/
|
|
811
|
+
export interface NumberInputSetter {
|
|
812
|
+
concept: 'NumberInputSetter';
|
|
813
|
+
/**
|
|
814
|
+
- 按钮位置
|
|
815
|
+
*/
|
|
816
|
+
placement?: string;
|
|
817
|
+
/**
|
|
818
|
+
- 最小值
|
|
819
|
+
*/
|
|
820
|
+
min?: number;
|
|
821
|
+
/**
|
|
822
|
+
- 最大值
|
|
823
|
+
*/
|
|
824
|
+
max?: number;
|
|
825
|
+
/**
|
|
826
|
+
- 精度
|
|
827
|
+
*/
|
|
828
|
+
precision?: number;
|
|
829
|
+
/**
|
|
830
|
+
- 占位文本
|
|
831
|
+
*/
|
|
832
|
+
placeholder?: string;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* 图标设置器
|
|
837
|
+
*/
|
|
838
|
+
export interface IconSetter {
|
|
839
|
+
concept: 'IconSetter';
|
|
840
|
+
/**
|
|
841
|
+
- 图标标题
|
|
842
|
+
*/
|
|
843
|
+
title?: string;
|
|
844
|
+
/**
|
|
845
|
+
- 使用自定义 iconfont 库
|
|
846
|
+
*/
|
|
847
|
+
customIconFont?: string;
|
|
848
|
+
/**
|
|
849
|
+
- 隐藏上传图标功能
|
|
850
|
+
*/
|
|
851
|
+
hideUploadIcon?: boolean;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* 图片设置器
|
|
856
|
+
*/
|
|
857
|
+
export interface ImageSetter {
|
|
858
|
+
concept: 'ImageSetter';
|
|
859
|
+
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* 属性选择设置器
|
|
864
|
+
*/
|
|
865
|
+
export interface PropertySelectSetter {
|
|
866
|
+
concept: 'PropertySelectSetter';
|
|
867
|
+
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* 匿名函数设置器
|
|
872
|
+
*/
|
|
873
|
+
export interface AnonymousFunctionSetter {
|
|
874
|
+
concept: 'AnonymousFunctionSetter';
|
|
875
|
+
|
|
876
|
+
}
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
## 4. 发布相关
|
|
880
|
+
|
|
881
|
+
- 在发布组件时,该\`api.ts\`会结合截图、i18n 配置等功能,转换成\`nasl.ui.json\`,遵循 NASL [ViewComponentDeclaration](https://nasl.codewave.163.com/docs/current/ast/view/ViewComponentDeclaration__) AST 的定义。
|
|
882
|
+
- 在发布组件时,该\`api.ts\`会编译成\`nasl.ui.d.ts\`,与 NASL Language Server 无缝衔接。
|
|
883
|
+
|
|
884
|
+
## 5. 规范生态
|
|
885
|
+
|
|
886
|
+
目前以下设施使用了该规范:
|
|
887
|
+
|
|
888
|
+
- CodeWave Vue2/React 基础组件库
|
|
889
|
+
- CodeWave IDE
|
|
890
|
+
- NASL Language Server
|
|
891
|
+
- NL2NASL 服务
|
|
892
|
+
- ...
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|