xiaohao-components 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,540 @@
1
+ const n = JSON.stringify(
2
+ {
3
+ messages: [
4
+ {
5
+ version: "v0.9",
6
+ createSurface: {
7
+ surfaceId: "cloud-console",
8
+ catalogId: "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json"
9
+ }
10
+ },
11
+ {
12
+ version: "v0.9",
13
+ updateComponents: {
14
+ surfaceId: "cloud-console",
15
+ components: [
16
+ {
17
+ id: "root",
18
+ component: "Column",
19
+ children: ["title", "summary", "svcList", "message", "divider", "footer"]
20
+ },
21
+ { id: "title", component: "Text", text: "云端部署控制台", variant: "h3" },
22
+ { id: "summary", component: "Text", text: { path: "/summary" }, variant: "caption" },
23
+ {
24
+ id: "svcList",
25
+ component: "List",
26
+ direction: "vertical",
27
+ children: { componentId: "svcRow", path: "/services" }
28
+ },
29
+ {
30
+ id: "svcRow",
31
+ component: "Row",
32
+ children: ["svcName", "svcStatus", "svcReplicas", "svcActions"]
33
+ },
34
+ { id: "svcName", component: "Text", text: { path: "name" } },
35
+ { id: "svcStatus", component: "Text", text: { path: "status" }, variant: "caption" },
36
+ {
37
+ id: "svcReplicas",
38
+ component: "Text",
39
+ text: { path: "replicas" },
40
+ variant: "caption"
41
+ },
42
+ {
43
+ id: "svcActions",
44
+ component: "Row",
45
+ children: ["scaleBtn", "restartBtn"]
46
+ },
47
+ {
48
+ id: "scaleBtn",
49
+ component: "Button",
50
+ variant: "primary",
51
+ child: "scaleBtnText",
52
+ action: {
53
+ event: { name: "scale_up_service", context: { service: { path: "name" } } }
54
+ }
55
+ },
56
+ { id: "scaleBtnText", component: "Text", text: "扩容" },
57
+ {
58
+ id: "restartBtn",
59
+ component: "Button",
60
+ variant: "default",
61
+ child: "restartBtnText",
62
+ action: {
63
+ event: { name: "restart_service", context: { service: { path: "name" } } }
64
+ }
65
+ },
66
+ { id: "restartBtnText", component: "Text", text: "重启" },
67
+ { id: "message", component: "Text", text: { path: "/message" }, variant: "caption" },
68
+ { id: "divider", component: "Divider" },
69
+ {
70
+ id: "footer",
71
+ component: "Text",
72
+ text: "点任一按钮都会真实调用工具,结果写回这张卡",
73
+ variant: "caption"
74
+ }
75
+ ]
76
+ }
77
+ }
78
+ ]
79
+ },
80
+ null,
81
+ 2
82
+ ), i = {
83
+ "/services": [
84
+ { name: "gateway-api", status: "running", replicas: 3 },
85
+ { name: "order-service", status: "running", replicas: 2 },
86
+ { name: "report-job", status: "degraded", replicas: 1 }
87
+ ],
88
+ "/summary": "共 3 个服务 · 2 个运行中 · 1 个异常",
89
+ "/message": "控制台已打开"
90
+ }, c = JSON.stringify(
91
+ {
92
+ messages: [
93
+ {
94
+ version: "v0.9",
95
+ createSurface: {
96
+ surfaceId: "waybill-form",
97
+ catalogId: "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json"
98
+ }
99
+ },
100
+ {
101
+ version: "v0.9",
102
+ updateComponents: {
103
+ surfaceId: "waybill-form",
104
+ components: [
105
+ {
106
+ id: "root",
107
+ component: "Column",
108
+ children: [
109
+ "title",
110
+ "shipperField",
111
+ "consigneeField",
112
+ "goodsField",
113
+ "quantityField",
114
+ "status",
115
+ "submit"
116
+ ]
117
+ },
118
+ { id: "title", component: "Text", text: "运单录入", variant: "h3" },
119
+ {
120
+ id: "shipperField",
121
+ component: "TextField",
122
+ label: "发货人",
123
+ variant: "shortText",
124
+ value: { path: "/shipper" }
125
+ },
126
+ {
127
+ id: "consigneeField",
128
+ component: "TextField",
129
+ label: "收货人",
130
+ variant: "shortText",
131
+ value: { path: "/consignee" }
132
+ },
133
+ {
134
+ id: "goodsField",
135
+ component: "TextField",
136
+ label: "货物名称",
137
+ variant: "shortText",
138
+ value: { path: "/goods" }
139
+ },
140
+ {
141
+ id: "quantityField",
142
+ component: "TextField",
143
+ label: "数量",
144
+ variant: "number",
145
+ value: { path: "/quantity" }
146
+ },
147
+ { id: "status", component: "Text", text: { path: "/status" }, variant: "caption" },
148
+ {
149
+ id: "submit",
150
+ component: "Button",
151
+ variant: "primary",
152
+ child: "submitText",
153
+ action: {
154
+ event: {
155
+ name: "submit_waybill",
156
+ context: {
157
+ shipper: { path: "/shipper" },
158
+ consignee: { path: "/consignee" },
159
+ goods: { path: "/goods" },
160
+ quantity: { path: "/quantity" }
161
+ }
162
+ }
163
+ }
164
+ // 刻意不写 `checks`:`/formValid` 没有任何一方会置真,加上的效果是
165
+ // 按钮永远禁用(引擎把 checks 编译成 isValid)。提交后的冻结由
166
+ // 客户端 shouldFreeze 按回包的 `/submitted === true` 负责。
167
+ },
168
+ { id: "submitText", component: "Text", text: "创建运单" }
169
+ ]
170
+ }
171
+ }
172
+ ]
173
+ },
174
+ null,
175
+ 2
176
+ ), s = {
177
+ "/status": "待提交",
178
+ "/message": "请填写运单信息",
179
+ "/shipper": "深圳小好科技有限公司",
180
+ "/consignee": "上海云之梦科技有限公司",
181
+ "/goods": "文件",
182
+ "/quantity": 2
183
+ }, t = "deploy-console", r = JSON.stringify(
184
+ {
185
+ messages: [
186
+ {
187
+ version: "v0.9",
188
+ createSurface: {
189
+ surfaceId: t,
190
+ catalogId: "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json"
191
+ }
192
+ },
193
+ {
194
+ version: "v0.9",
195
+ updateComponents: {
196
+ surfaceId: t,
197
+ components: [
198
+ {
199
+ id: "root",
200
+ component: "Column",
201
+ children: ["title", "keyword", "serviceSelect", "versionSelect", "status", "actions"]
202
+ },
203
+ { id: "title", component: "Text", text: "部署控制台", variant: "h3" },
204
+ {
205
+ id: "keyword",
206
+ component: "TextField",
207
+ label: "关键字",
208
+ variant: "shortText",
209
+ value: { path: "/keyword" }
210
+ },
211
+ {
212
+ id: "serviceSelect",
213
+ component: "ChoicePicker",
214
+ label: "服务",
215
+ options: { source: "/services", label: "name", value: "id" },
216
+ value: { path: "/selectedService" },
217
+ variant: "mutuallyExclusive"
218
+ },
219
+ {
220
+ id: "versionSelect",
221
+ component: "ChoicePicker",
222
+ label: "版本",
223
+ options: { source: "/versions", label: "name", value: "id" },
224
+ value: { path: "/selectedVersion" },
225
+ variant: "mutuallyExclusive"
226
+ },
227
+ { id: "status", component: "Text", text: { path: "/status" }, variant: "caption" },
228
+ {
229
+ id: "actions",
230
+ component: "Row",
231
+ children: ["action_0", "action_1", "action_2"]
232
+ },
233
+ {
234
+ id: "action_0",
235
+ component: "Button",
236
+ variant: "default",
237
+ child: "action_0_text",
238
+ action: {
239
+ event: { name: "search_services", context: { keyword: { path: "/keyword" } } }
240
+ }
241
+ },
242
+ { id: "action_0_text", component: "Text", text: "搜索" },
243
+ {
244
+ id: "action_1",
245
+ component: "Button",
246
+ variant: "default",
247
+ child: "action_1_text",
248
+ action: {
249
+ event: {
250
+ name: "list_versions",
251
+ context: { selectedService: { path: "/selectedService" } }
252
+ }
253
+ }
254
+ },
255
+ { id: "action_1_text", component: "Text", text: "加载版本" },
256
+ {
257
+ id: "action_2",
258
+ component: "Button",
259
+ variant: "primary",
260
+ child: "action_2_text",
261
+ action: {
262
+ event: {
263
+ name: "submit_deployment",
264
+ context: {
265
+ selectedService: { path: "/selectedService" },
266
+ selectedVersion: { path: "/selectedVersion" }
267
+ }
268
+ }
269
+ }
270
+ },
271
+ { id: "action_2_text", component: "Text", text: "提交部署" }
272
+ ]
273
+ }
274
+ }
275
+ ]
276
+ },
277
+ null,
278
+ 2
279
+ ), e = "waybill-track", l = JSON.stringify(
280
+ {
281
+ messages: [
282
+ {
283
+ version: "v0.9",
284
+ createSurface: {
285
+ surfaceId: e,
286
+ catalogId: "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json"
287
+ }
288
+ },
289
+ {
290
+ version: "v0.9",
291
+ updateComponents: {
292
+ surfaceId: e,
293
+ components: [
294
+ {
295
+ id: "root",
296
+ component: "Column",
297
+ children: [
298
+ "title",
299
+ "subtitle",
300
+ "queryRow",
301
+ "status",
302
+ "dividerTop",
303
+ "tableCard",
304
+ "dividerBottom",
305
+ "formTitle",
306
+ "operatorField",
307
+ "prioritySelect",
308
+ "carrierSelect",
309
+ "remarkField",
310
+ "submitRow"
311
+ ]
312
+ },
313
+ { id: "title", component: "Text", text: "运单轨迹", variant: "h3" },
314
+ {
315
+ id: "subtitle",
316
+ component: "Text",
317
+ text: "输入运单号点「查询」,轨迹按时间列出",
318
+ variant: "caption"
319
+ },
320
+ { id: "queryRow", component: "Row", children: ["waybillField", "queryBtn"] },
321
+ {
322
+ id: "waybillField",
323
+ component: "TextField",
324
+ label: "运单号",
325
+ variant: "shortText",
326
+ value: { path: "/waybillNo" }
327
+ },
328
+ {
329
+ id: "queryBtn",
330
+ component: "Button",
331
+ variant: "default",
332
+ child: "queryBtnText",
333
+ action: {
334
+ event: { name: "search_tracks", context: { waybillNo: { path: "/waybillNo" } } }
335
+ }
336
+ },
337
+ { id: "queryBtnText", component: "Text", text: "查询" },
338
+ { id: "status", component: "Text", text: { path: "/status" }, variant: "caption" },
339
+ { id: "dividerTop", component: "Divider" },
340
+ { id: "tableCard", component: "Card", child: "tableInner" },
341
+ { id: "tableInner", component: "Column", children: ["summary", "trackTable"] },
342
+ { id: "summary", component: "Text", text: { path: "/summary" }, variant: "body" },
343
+ {
344
+ id: "trackTable",
345
+ component: "Table",
346
+ columns: [
347
+ { label: "时间", key: "trackTime", width: 150 },
348
+ { label: "轨迹", key: "trackInfo" },
349
+ { label: "站点", key: "stationId", width: 90 }
350
+ ],
351
+ // 必须 `{path}`:协同端发布校验只从这种形状里收集路径(详见 shadcn-catalog)
352
+ rows: { path: "/doTrackList" },
353
+ emptyText: "请先输入运单号并点「查询」"
354
+ },
355
+ { id: "dividerBottom", component: "Divider" },
356
+ { id: "formTitle", component: "Text", text: "回单登记", variant: "h4" },
357
+ {
358
+ id: "operatorField",
359
+ component: "TextField",
360
+ label: "操作人",
361
+ variant: "shortText",
362
+ value: { path: "/operator" }
363
+ },
364
+ {
365
+ id: "prioritySelect",
366
+ component: "ChoicePicker",
367
+ label: "优先级",
368
+ options: [
369
+ { label: "普通", value: "normal" },
370
+ { label: "加急", value: "urgent" },
371
+ { label: "特急", value: "critical" }
372
+ ],
373
+ value: { path: "/priority" },
374
+ variant: "mutuallyExclusive"
375
+ },
376
+ {
377
+ id: "carrierSelect",
378
+ component: "ChoicePicker",
379
+ label: "承运商(远程选项)",
380
+ // 扩展写法:工具只回纯数据,选项由渲染层按声明解析(见 remote-options.ts)
381
+ options: { source: "/carriers", label: "name", value: "id" },
382
+ value: { path: "/carrier" },
383
+ variant: "mutuallyExclusive"
384
+ },
385
+ {
386
+ id: "remarkField",
387
+ component: "TextField",
388
+ label: "备注",
389
+ variant: "longText",
390
+ value: { path: "/remark" }
391
+ },
392
+ { id: "submitRow", component: "Row", children: ["submitBtn"] },
393
+ {
394
+ id: "submitBtn",
395
+ component: "Button",
396
+ variant: "primary",
397
+ child: "submitBtnText",
398
+ action: {
399
+ event: {
400
+ name: "submit_receipt",
401
+ context: {
402
+ waybillNo: { path: "/waybillNo" },
403
+ operator: { path: "/operator" },
404
+ priority: { path: "/priority" },
405
+ carrier: { path: "/carrier" },
406
+ remark: { path: "/remark" }
407
+ }
408
+ }
409
+ }
410
+ },
411
+ { id: "submitBtnText", component: "Text", text: "提交回单" }
412
+ ]
413
+ }
414
+ }
415
+ ]
416
+ },
417
+ null,
418
+ 2
419
+ ), d = {
420
+ "/waybillNo": "YD20260924001",
421
+ "/status": "输入运单号后点「查询」加载轨迹",
422
+ "/summary": "运单 YD20260924001 · 尚未查询",
423
+ // 查询前是空数组:Table 走空态文案,下拉走「暂无选项」
424
+ "/doTrackList": [],
425
+ "/carriers": [],
426
+ "/priority": [],
427
+ "/carrier": [],
428
+ "/operator": "",
429
+ "/remark": ""
430
+ }, o = "goods-editable", a = [
431
+ { code: "kg", name: "千克" },
432
+ { code: "t", name: "吨" },
433
+ { code: "pcs", name: "件" },
434
+ { code: "box", name: "箱" }
435
+ ], p = JSON.stringify(
436
+ {
437
+ messages: [
438
+ {
439
+ version: "v0.9",
440
+ createSurface: {
441
+ surfaceId: o,
442
+ catalogId: "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json"
443
+ }
444
+ },
445
+ {
446
+ version: "v0.9",
447
+ updateComponents: {
448
+ surfaceId: o,
449
+ components: [
450
+ {
451
+ id: "root",
452
+ component: "Column",
453
+ children: ["title", "hint", "goodsTable", "submitRow"]
454
+ },
455
+ { id: "title", component: "Text", text: "货物明细", variant: "h3" },
456
+ {
457
+ id: "hint",
458
+ component: "Text",
459
+ text: "点「添加一行」录入,行数不限",
460
+ variant: "caption"
461
+ },
462
+ {
463
+ id: "goodsTable",
464
+ component: "EditableTable",
465
+ columns: [
466
+ { label: "货物名称", key: "name" },
467
+ { label: "重量(kg)", key: "weight", type: "number", width: 90 },
468
+ {
469
+ label: "单位",
470
+ key: "unit",
471
+ type: "select",
472
+ width: 100,
473
+ // 远程选项:数据由工具回包写进 /units(见 remote-options.ts)
474
+ options: { source: "/units", label: "name", value: "code" }
475
+ },
476
+ {
477
+ label: "状态",
478
+ key: "status",
479
+ type: "select",
480
+ width: 100,
481
+ options: [
482
+ { label: "完好", value: "ok" },
483
+ { label: "破损", value: "damaged" }
484
+ ]
485
+ }
486
+ ],
487
+ // 必须 `{path}`,与 `Table` 同一条约束
488
+ rows: { path: "/goods" },
489
+ addLabel: "添加一行",
490
+ removeLabel: "删除这一行",
491
+ emptyHint: "还没有货物,点「添加一行」开始"
492
+ },
493
+ { id: "submitRow", component: "Row", children: ["submitBtn"] },
494
+ {
495
+ id: "submitBtn",
496
+ component: "Button",
497
+ variant: "primary",
498
+ child: "submitBtnText",
499
+ action: {
500
+ event: { name: "submit_goods", context: { goods: { path: "/goods" } } }
501
+ }
502
+ },
503
+ { id: "submitBtnText", component: "Text", text: "提交明细" }
504
+ ]
505
+ }
506
+ }
507
+ ]
508
+ },
509
+ null,
510
+ 2
511
+ ), m = {
512
+ // 预置一行,打开就能看到两种下拉的实际样子;删掉它即回到「还没有货物」空态
513
+ "/goods": [{ name: "螺丝", weight: 12.5, unit: "kg", status: "ok" }],
514
+ "/units": a,
515
+ "/submitted": !1
516
+ }, u = {
517
+ "/keyword": "",
518
+ "/selectedService": [],
519
+ "/selectedVersion": [],
520
+ // 两个下拉的数据源:工具回包会把它们填上(`options.source` 指的就是这两个路径)
521
+ "/services": [],
522
+ "/versions": [],
523
+ "/status": "输入关键字后点「搜索」"
524
+ };
525
+ export {
526
+ i as DISPLAY_SAMPLE_DATA,
527
+ n as DISPLAY_SAMPLE_JSON,
528
+ m as EDITABLE_SAMPLE_DATA,
529
+ p as EDITABLE_SAMPLE_JSON,
530
+ o as EDITABLE_SURFACE_ID,
531
+ a as EDITABLE_UNIT_OPTIONS,
532
+ s as FORM_SAMPLE_DATA,
533
+ c as FORM_SAMPLE_JSON,
534
+ u as MULTI_ACTION_SAMPLE_DATA,
535
+ r as MULTI_ACTION_SAMPLE_JSON,
536
+ t as MULTI_ACTION_SURFACE_ID,
537
+ d as TRACK_SAMPLE_DATA,
538
+ l as TRACK_SAMPLE_JSON,
539
+ e as TRACK_SURFACE_ID
540
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @xiaohao/a2ui-renderer 公开 API。
3
+ *
4
+ * 定位:A2UI 卡片的 **Web 渲染层**——任何 React 18/19 页面要显示 A2UI 卡,
5
+ * 一律安装这个包,不再各自实现一份。宿主无关:这里不 import 任何桌面/协同端
6
+ * 的业务模块(网络、toast、日志全部由 props 注入)。
7
+ */
8
+ export { A2uiRenderer } from './a2ui-renderer';
9
+ export type { A2uiActionOutcome, A2uiActionRequest, A2uiCardInput, A2uiRendererProps, } from './types';
10
+ export { A2UI_AUX_KEY, A2UI_VERSION, auxMessagesOf, buildDataModelMessages, parseA2uiCard, shouldFreeze, toDataEntries, } from './messages/a2ui-messages';
11
+ export type { A2uiCardMessages, A2uiDataModelMessage } from './messages/a2ui-messages';
12
+ export { DEFAULT_LABEL_KEY, DEFAULT_VALUE_KEY, isRemoteOptions, resolveRemoteOptions, } from './messages/remote-options';
13
+ export type { ChoiceOption, RemoteOptionsDescriptor } from './messages/remote-options';
14
+ export { collectMissingPaths } from './messages/missing-paths';
15
+ export { deriveToolPrefix, resolveToolName } from './actions/tool-name';
16
+ export { extractToolResultText } from './text';
17
+ export { shadcnCatalog, shadcnCatalogId } from './catalog/shadcn-catalog';
18
+ export { A2uiFallback } from './fallback';
19
+ export { A2uiPortalProvider, useA2uiPortalContainer } from './lib/portal-context';
20
+ /** 包版本(宿主可断言 `RENDERER_VERSION === 依赖里声明的版本`,防两仓漂移) */
21
+ export declare const RENDERER_VERSION: string;