Create task(创建任务)
简短的任务表单收集标题、说明和截止日期,再提交创建动作。
loading
安装
bash
npm install @assistant-ui/generative-ui zod1
用法
将下方规格传给渲染器。提供 dispatch 可接收按钮或表单的动作载荷。演示只在本地显示操作反馈。
tsx
import { defaultGenerativeUILibrary, renderGenerativeUI } from "@assistant-ui/generative-ui/react";
renderGenerativeUI(spec, defaultGenerativeUILibrary, {
status: "done",
dispatch: (action) => {
// 将用户操作交给应用。
console.log(action);
},
});1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
规格
tsx
const spec = {
"$type": "Form",
"$action": {
"type": "create_task"
},
"children": [
{
"$type": "Input",
"$key": "title",
"name": "title",
"label": "标题",
"placeholder": "输入任务标题"
},
{
"$type": "Input",
"$key": "description",
"name": "description",
"label": "说明",
"multiline": true,
"placeholder": "补充任务细节…"
},
{
"$type": "DatePicker",
"$key": "due",
"name": "dueDate",
"label": "截止日期"
},
{
"$type": "Button",
"$key": "create",
"label": "创建任务",
"buttonStyle": "primary",
"block": true,
"submit": true
}
]
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37