@zhama/a2ui-core 0.6.1 → 0.9.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.
- package/README.md +11 -11
- package/dist/builders/index.cjs +3 -3
- package/dist/builders/index.d.cts +72 -445
- package/dist/builders/index.d.ts +72 -445
- package/dist/builders/index.js +3 -3
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +3 -3
- package/dist/primitives-DRaAeo-1.d.cts +148 -0
- package/dist/primitives-DRaAeo-1.d.ts +148 -0
- package/dist/surface/index.cjs +2 -2
- package/dist/surface/index.d.cts +29 -16
- package/dist/surface/index.d.ts +29 -16
- package/dist/surface/index.js +2 -2
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.d.cts +380 -395
- package/dist/types/index.d.ts +380 -395
- package/dist/types/index.js +2 -2
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +8 -16
- package/dist/utils/index.d.ts +8 -16
- package/dist/utils/index.js +1 -1
- package/dist/validators/index.cjs +1 -1
- package/dist/validators/index.d.cts +6 -39
- package/dist/validators/index.d.ts +6 -39
- package/dist/validators/index.js +1 -1
- package/package.json +1 -1
- package/dist/primitives-DLbBDhLq.d.cts +0 -46
- package/dist/primitives-DLbBDhLq.d.ts +0 -46
package/dist/builders/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { A as AccessibilityAttributes, C as CheckRule, b as DynamicString, f as DynamicValue, d as DynamicBoolean, e as DynamicStringList, c as DynamicNumber } from '../primitives-DRaAeo-1.js';
|
|
2
|
+
import { TextVariant, ImageComponent, ImageVariant, AlignItems, JustifyContent, ListComponent, DividerComponent, ButtonVariant, TextFieldVariant, ChoicePickerVariant, ChartAxisConfig, Action, ComponentInstance, ChildList, ChoiceOption, ChartType, ChartSeries, Theme, CreateSurfaceMessage, UpdateComponentsMessage, UpdateDataModelMessage, DeleteSurfaceMessage, DataObject, ServerToClientMessage, DataValue } from '../types/index.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* ID Generator
|
|
@@ -30,132 +30,70 @@ declare function getIdCounter(): number;
|
|
|
30
30
|
/**
|
|
31
31
|
* Component Builder
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
* 用于创建符合 A2UI v0.9 协议的组件结构
|
|
33
|
+
* A2UI v0.9 组件构建器
|
|
35
34
|
*/
|
|
36
35
|
|
|
37
|
-
/**
|
|
38
|
-
* 组件构建选项基类
|
|
39
|
-
*/
|
|
40
36
|
interface ComponentOptions {
|
|
41
|
-
/** 组件 ID(可选,自动生成) */
|
|
42
37
|
id?: string;
|
|
43
|
-
/** 在 Row/Column 中的权重 */
|
|
44
38
|
weight?: number;
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
accessibility?: AccessibilityAttributes;
|
|
40
|
+
}
|
|
41
|
+
interface CheckableOptions {
|
|
42
|
+
checks?: CheckRule[];
|
|
47
43
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Text 组件选项
|
|
50
|
-
*/
|
|
51
44
|
interface TextOptions extends ComponentOptions {
|
|
52
|
-
|
|
45
|
+
variant?: TextVariant;
|
|
53
46
|
}
|
|
54
|
-
/**
|
|
55
|
-
* Image 组件选项
|
|
56
|
-
*/
|
|
57
47
|
interface ImageOptions extends ComponentOptions {
|
|
58
48
|
fit?: ImageComponent['fit'];
|
|
59
|
-
|
|
49
|
+
variant?: ImageVariant;
|
|
60
50
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Icon 组件选项
|
|
63
|
-
*/
|
|
64
51
|
type IconOptions = ComponentOptions;
|
|
65
|
-
/**
|
|
66
|
-
* Video 组件选项
|
|
67
|
-
*/
|
|
68
52
|
type VideoOptions = ComponentOptions;
|
|
69
|
-
/**
|
|
70
|
-
* AudioPlayer 组件选项
|
|
71
|
-
*/
|
|
72
53
|
interface AudioPlayerOptions extends ComponentOptions {
|
|
73
|
-
description?:
|
|
54
|
+
description?: DynamicString;
|
|
74
55
|
}
|
|
75
|
-
/**
|
|
76
|
-
* 布局组件选项
|
|
77
|
-
*/
|
|
78
56
|
interface LayoutOptions extends ComponentOptions {
|
|
79
|
-
|
|
80
|
-
|
|
57
|
+
align?: AlignItems;
|
|
58
|
+
justify?: JustifyContent;
|
|
81
59
|
}
|
|
82
|
-
/**
|
|
83
|
-
* List 组件选项
|
|
84
|
-
*/
|
|
85
60
|
interface ListOptions extends ComponentOptions {
|
|
86
61
|
direction?: ListComponent['direction'];
|
|
87
|
-
|
|
62
|
+
align?: AlignItems;
|
|
88
63
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Card 组件选项
|
|
91
|
-
*/
|
|
92
64
|
type CardOptions = ComponentOptions;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
*/
|
|
96
|
-
type TabsOptions = ComponentOptions;
|
|
97
|
-
/**
|
|
98
|
-
* Tab 项目
|
|
99
|
-
*/
|
|
100
|
-
interface TabItem {
|
|
101
|
-
title: string;
|
|
65
|
+
interface TabInput {
|
|
66
|
+
title: DynamicString;
|
|
102
67
|
childId: string;
|
|
103
68
|
}
|
|
104
|
-
|
|
105
|
-
* Divider 组件选项
|
|
106
|
-
*/
|
|
69
|
+
type TabsOptions = ComponentOptions;
|
|
107
70
|
interface DividerOptions extends ComponentOptions {
|
|
108
71
|
axis?: DividerComponent['axis'];
|
|
109
72
|
}
|
|
110
|
-
/**
|
|
111
|
-
* Modal 组件选项
|
|
112
|
-
*/
|
|
113
73
|
type ModalOptions = ComponentOptions;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
*/
|
|
117
|
-
interface ButtonOptions extends ComponentOptions {
|
|
118
|
-
primary?: boolean;
|
|
74
|
+
interface ButtonOptions extends ComponentOptions, CheckableOptions {
|
|
75
|
+
variant?: ButtonVariant;
|
|
119
76
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
type CheckBoxOptions = ComponentOptions;
|
|
124
|
-
/**
|
|
125
|
-
* TextField 组件选项
|
|
126
|
-
*/
|
|
127
|
-
interface TextFieldOptions extends ComponentOptions {
|
|
128
|
-
usageHint?: TextFieldComponent['usageHint'];
|
|
129
|
-
validationRegexp?: string;
|
|
77
|
+
type CheckBoxOptions = ComponentOptions & CheckableOptions;
|
|
78
|
+
interface TextFieldOptions extends ComponentOptions, CheckableOptions {
|
|
79
|
+
variant?: TextFieldVariant;
|
|
130
80
|
}
|
|
131
|
-
|
|
132
|
-
* DateTimeInput 组件选项
|
|
133
|
-
*/
|
|
134
|
-
interface DateTimeInputOptions extends ComponentOptions {
|
|
81
|
+
interface DateTimeInputOptions extends ComponentOptions, CheckableOptions {
|
|
135
82
|
enableDate?: boolean;
|
|
136
83
|
enableTime?: boolean;
|
|
137
|
-
|
|
138
|
-
|
|
84
|
+
min?: DynamicString;
|
|
85
|
+
max?: DynamicString;
|
|
86
|
+
label?: DynamicString;
|
|
139
87
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
interface ChoicePickerOptions extends ComponentOptions {
|
|
144
|
-
label?: StringOrPath;
|
|
88
|
+
interface ChoicePickerOptions extends ComponentOptions, CheckableOptions {
|
|
89
|
+
label?: DynamicString;
|
|
90
|
+
variant?: ChoicePickerVariant;
|
|
145
91
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
*/
|
|
149
|
-
interface SliderOptions extends ComponentOptions {
|
|
150
|
-
label?: StringOrPath;
|
|
151
|
-
min?: number;
|
|
152
|
-
max?: number;
|
|
92
|
+
interface SliderOptions extends ComponentOptions, CheckableOptions {
|
|
93
|
+
label?: DynamicString;
|
|
153
94
|
}
|
|
154
|
-
/**
|
|
155
|
-
* Chart 组件选项
|
|
156
|
-
*/
|
|
157
95
|
interface ChartOptions extends ComponentOptions {
|
|
158
|
-
title?:
|
|
96
|
+
title?: DynamicString;
|
|
159
97
|
xAxis?: ChartAxisConfig;
|
|
160
98
|
yAxis?: ChartAxisConfig;
|
|
161
99
|
legend?: boolean;
|
|
@@ -167,351 +105,83 @@ interface ChartOptions extends ComponentOptions {
|
|
|
167
105
|
};
|
|
168
106
|
}
|
|
169
107
|
/**
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* @param text - 文本内容或数据路径
|
|
173
|
-
* @param options - 组件选项
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* // 静态文本
|
|
177
|
-
* text('Hello World', { usageHint: 'h1' });
|
|
178
|
-
*
|
|
179
|
-
* // 数据绑定
|
|
180
|
-
* text({ path: '/user/name' });
|
|
181
|
-
*/
|
|
182
|
-
declare function text(content: StringOrPath, options?: TextOptions): ComponentInstance;
|
|
183
|
-
/**
|
|
184
|
-
* 创建 Image 组件
|
|
185
|
-
*
|
|
186
|
-
* @param url - 图片 URL 或数据路径
|
|
187
|
-
* @param options - 组件选项
|
|
188
|
-
*/
|
|
189
|
-
declare function image(url: StringOrPath, options?: ImageOptions): ComponentInstance;
|
|
190
|
-
/**
|
|
191
|
-
* 创建 Icon 组件
|
|
192
|
-
*
|
|
193
|
-
* @param name - 图标名称或数据路径
|
|
194
|
-
* @param options - 组件选项
|
|
195
|
-
*/
|
|
196
|
-
declare function icon(name: StringOrPath, options?: IconOptions): ComponentInstance;
|
|
197
|
-
/**
|
|
198
|
-
* 创建 Video 组件
|
|
199
|
-
*
|
|
200
|
-
* @param url - 视频 URL 或数据路径
|
|
201
|
-
* @param options - 组件选项
|
|
202
|
-
*/
|
|
203
|
-
declare function video(url: StringOrPath, options?: VideoOptions): ComponentInstance;
|
|
204
|
-
/**
|
|
205
|
-
* 创建 AudioPlayer 组件
|
|
206
|
-
*
|
|
207
|
-
* @param url - 音频 URL 或数据路径
|
|
208
|
-
* @param options - 组件选项
|
|
209
|
-
*/
|
|
210
|
-
declare function audioPlayer(url: StringOrPath, options?: AudioPlayerOptions): ComponentInstance;
|
|
211
|
-
/**
|
|
212
|
-
* 创建 Row 组件(水平布局)
|
|
213
|
-
*
|
|
214
|
-
* @param children - 子组件 ID 列表或动态模板
|
|
215
|
-
* @param options - 布局选项
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* // 静态子组件
|
|
219
|
-
* row(['text1', 'text2', 'button1']);
|
|
220
|
-
*
|
|
221
|
-
* // 动态模板
|
|
222
|
-
* row({ componentId: 'itemTemplate', path: '/items' });
|
|
223
|
-
*/
|
|
224
|
-
declare function row(children: ChildrenProperty, options?: LayoutOptions): ComponentInstance;
|
|
225
|
-
/**
|
|
226
|
-
* 创建 Column 组件(垂直布局)
|
|
227
|
-
*
|
|
228
|
-
* @param children - 子组件 ID 列表或动态模板
|
|
229
|
-
* @param options - 布局选项
|
|
230
|
-
*/
|
|
231
|
-
declare function column(children: ChildrenProperty, options?: LayoutOptions): ComponentInstance;
|
|
232
|
-
/**
|
|
233
|
-
* 创建 List 组件
|
|
234
|
-
*
|
|
235
|
-
* @param children - 子组件 ID 列表或动态模板
|
|
236
|
-
* @param options - 列表选项
|
|
237
|
-
*/
|
|
238
|
-
declare function list(children: ChildrenProperty, options?: ListOptions): ComponentInstance;
|
|
239
|
-
/**
|
|
240
|
-
* 创建 Card 组件
|
|
241
|
-
*
|
|
242
|
-
* @param childId - 子组件 ID
|
|
243
|
-
* @param options - 卡片选项
|
|
108
|
+
* 创建服务器端事件 Action
|
|
244
109
|
*/
|
|
110
|
+
declare function eventAction(name: string, context?: Record<string, DynamicValue>): Action;
|
|
111
|
+
declare function text(content: DynamicString, options?: TextOptions): ComponentInstance;
|
|
112
|
+
declare function image(url: DynamicString, options?: ImageOptions): ComponentInstance;
|
|
113
|
+
declare function icon(name: DynamicString, options?: IconOptions): ComponentInstance;
|
|
114
|
+
declare function video(url: DynamicString, options?: VideoOptions): ComponentInstance;
|
|
115
|
+
declare function audioPlayer(url: DynamicString, options?: AudioPlayerOptions): ComponentInstance;
|
|
116
|
+
declare function row(children: ChildList, options?: LayoutOptions): ComponentInstance;
|
|
117
|
+
declare function column(children: ChildList, options?: LayoutOptions): ComponentInstance;
|
|
118
|
+
declare function list(children: ChildList, options?: ListOptions): ComponentInstance;
|
|
245
119
|
declare function card(childId: string, options?: CardOptions): ComponentInstance;
|
|
246
|
-
|
|
247
|
-
* 创建 Tabs 组件
|
|
248
|
-
*
|
|
249
|
-
* @param items - 标签项列表
|
|
250
|
-
* @param options - Tabs 选项
|
|
251
|
-
*/
|
|
252
|
-
declare function tabs(items: TabItem[], options?: TabsOptions): ComponentInstance;
|
|
253
|
-
/**
|
|
254
|
-
* 创建 Divider 组件
|
|
255
|
-
*
|
|
256
|
-
* @param options - 分割线选项
|
|
257
|
-
*/
|
|
120
|
+
declare function tabs(items: TabInput[], options?: TabsOptions): ComponentInstance;
|
|
258
121
|
declare function divider(options?: DividerOptions): ComponentInstance;
|
|
259
|
-
|
|
260
|
-
* 创建 Modal 组件
|
|
261
|
-
*
|
|
262
|
-
* @param entryPointChildId - 触发模态框的组件 ID
|
|
263
|
-
* @param contentChildId - 模态框内容组件 ID
|
|
264
|
-
* @param options - Modal 选项
|
|
265
|
-
*/
|
|
266
|
-
declare function modal(entryPointChildId: string, contentChildId: string, options?: ModalOptions): ComponentInstance;
|
|
267
|
-
/**
|
|
268
|
-
* 创建 Button 组件
|
|
269
|
-
*
|
|
270
|
-
* @param childId - 按钮内容组件 ID(通常是 Text)
|
|
271
|
-
* @param action - 点击时触发的操作
|
|
272
|
-
* @param options - 按钮选项
|
|
273
|
-
*/
|
|
122
|
+
declare function modal(triggerId: string, contentId: string, options?: ModalOptions): ComponentInstance;
|
|
274
123
|
declare function button(childId: string, action: Action, options?: ButtonOptions): ComponentInstance;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
* @param options - 选项
|
|
281
|
-
*/
|
|
282
|
-
declare function checkbox(label: StringOrPath, value: BooleanOrPath, options?: CheckBoxOptions): ComponentInstance;
|
|
283
|
-
/**
|
|
284
|
-
* 创建 TextField 组件
|
|
285
|
-
*
|
|
286
|
-
* @param label - 标签
|
|
287
|
-
* @param textValue - 值(可选)
|
|
288
|
-
* @param options - 选项
|
|
289
|
-
*/
|
|
290
|
-
declare function textField(label: StringOrPath, textValue?: StringOrPath, options?: TextFieldOptions): ComponentInstance;
|
|
291
|
-
/**
|
|
292
|
-
* 创建 DateTimeInput 组件
|
|
293
|
-
*
|
|
294
|
-
* @param value - 值(ISO 8601 格式字符串或数据路径)
|
|
295
|
-
* @param options - 选项
|
|
296
|
-
*/
|
|
297
|
-
declare function dateTimeInput(value: StringOrPath, options?: DateTimeInputOptions): ComponentInstance;
|
|
298
|
-
/**
|
|
299
|
-
* 创建 ChoicePicker 组件
|
|
300
|
-
*
|
|
301
|
-
* @param optionsList - 选项列表
|
|
302
|
-
* @param value - 当前选中值
|
|
303
|
-
* @param usageHint - 使用提示
|
|
304
|
-
* @param options - 组件选项
|
|
305
|
-
*/
|
|
306
|
-
declare function choicePicker(optionsList: Array<{
|
|
307
|
-
label: StringOrPath;
|
|
308
|
-
value: string;
|
|
309
|
-
}>, value: StringArrayOrPath, usageHint: ChoicePickerComponent['usageHint'], options?: ChoicePickerOptions): ComponentInstance;
|
|
310
|
-
/**
|
|
311
|
-
* 创建 Slider 组件
|
|
312
|
-
*
|
|
313
|
-
* @param value - 当前值
|
|
314
|
-
* @param options - 选项
|
|
315
|
-
*/
|
|
316
|
-
declare function slider(value: NumberOrPath, options?: SliderOptions): ComponentInstance;
|
|
317
|
-
/**
|
|
318
|
-
* 创建 Chart 组件
|
|
319
|
-
*
|
|
320
|
-
* @param chartType - 图表类型
|
|
321
|
-
* @param series - 数据系列
|
|
322
|
-
* @param options - 组件选项
|
|
323
|
-
*
|
|
324
|
-
* @example
|
|
325
|
-
* // 简单折线图
|
|
326
|
-
* chart('line', [
|
|
327
|
-
* { name: '销售额', data: [120, 200, 150, 80, 70, 110, 130] }
|
|
328
|
-
* ], {
|
|
329
|
-
* title: '月度销售趋势',
|
|
330
|
-
* xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }
|
|
331
|
-
* });
|
|
332
|
-
*
|
|
333
|
-
* // 数据绑定
|
|
334
|
-
* chart('bar', { path: '/chart/series' }, {
|
|
335
|
-
* title: { path: '/chart/title' },
|
|
336
|
-
* xAxis: { type: 'category', data: { path: '/chart/categories' } }
|
|
337
|
-
* });
|
|
338
|
-
*/
|
|
124
|
+
declare function checkbox(label: DynamicString, value: DynamicBoolean, options?: CheckBoxOptions): ComponentInstance;
|
|
125
|
+
declare function textField(label: DynamicString, value?: DynamicString, options?: TextFieldOptions): ComponentInstance;
|
|
126
|
+
declare function dateTimeInput(value: DynamicString, options?: DateTimeInputOptions): ComponentInstance;
|
|
127
|
+
declare function choicePicker(optionsList: ChoiceOption[], value: DynamicStringList, options?: ChoicePickerOptions): ComponentInstance;
|
|
128
|
+
declare function slider(value: DynamicNumber, min: number, max: number, options?: SliderOptions): ComponentInstance;
|
|
339
129
|
declare function chart(chartType: ChartType, series: ChartSeries[] | {
|
|
340
130
|
path: string;
|
|
341
131
|
}, options?: ChartOptions): ComponentInstance;
|
|
342
|
-
/**
|
|
343
|
-
* 创建折线图组件(便捷函数)
|
|
344
|
-
*/
|
|
345
132
|
declare function lineChart(series: ChartSeries[] | {
|
|
346
133
|
path: string;
|
|
347
134
|
}, options?: ChartOptions): ComponentInstance;
|
|
348
|
-
/**
|
|
349
|
-
* 创建柱状图组件(便捷函数)
|
|
350
|
-
*/
|
|
351
135
|
declare function barChart(series: ChartSeries[] | {
|
|
352
136
|
path: string;
|
|
353
137
|
}, options?: ChartOptions): ComponentInstance;
|
|
354
|
-
/**
|
|
355
|
-
* 创建饼图组件(便捷函数)
|
|
356
|
-
*/
|
|
357
138
|
declare function pieChart(series: ChartSeries[] | {
|
|
358
139
|
path: string;
|
|
359
140
|
}, options?: ChartOptions): ComponentInstance;
|
|
360
|
-
/**
|
|
361
|
-
* 创建带文本的按钮(返回按钮和文本组件)
|
|
362
|
-
*
|
|
363
|
-
* @param buttonText - 按钮文本
|
|
364
|
-
* @param action - 点击操作
|
|
365
|
-
* @param options - 按钮选项
|
|
366
|
-
* @returns 包含按钮和文本组件的数组
|
|
367
|
-
*/
|
|
368
141
|
declare function textButton(buttonText: string, action: Action, options?: ButtonOptions & {
|
|
369
142
|
textId?: string;
|
|
370
143
|
}): [ComponentInstance, ComponentInstance];
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
declare function
|
|
375
|
-
declare function
|
|
376
|
-
declare function
|
|
377
|
-
declare function
|
|
378
|
-
declare function h5(content: StringOrPath, options?: Omit<TextOptions, 'usageHint'>): ComponentInstance;
|
|
379
|
-
declare function caption(content: StringOrPath, options?: Omit<TextOptions, 'usageHint'>): ComponentInstance;
|
|
380
|
-
declare function body(content: StringOrPath, options?: Omit<TextOptions, 'usageHint'>): ComponentInstance;
|
|
144
|
+
declare function h1(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
|
|
145
|
+
declare function h2(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
|
|
146
|
+
declare function h3(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
|
|
147
|
+
declare function h4(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
|
|
148
|
+
declare function h5(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
|
|
149
|
+
declare function caption(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
|
|
150
|
+
declare function body(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
|
|
381
151
|
|
|
382
152
|
/**
|
|
383
153
|
* Message Builder
|
|
384
154
|
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
* v0.9 消息类型:
|
|
388
|
-
* - createSurface: 创建新的 UI Surface
|
|
389
|
-
* - updateComponents: 更新组件
|
|
390
|
-
* - updateDataModel: 更新数据模型 (JSON Patch 风格)
|
|
391
|
-
* - deleteSurface: 删除 Surface
|
|
392
|
-
*
|
|
393
|
-
* 参考: https://a2ui.org/
|
|
155
|
+
* A2UI v0.9 消息构建器
|
|
394
156
|
*/
|
|
395
157
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
* @example
|
|
403
|
-
* ```typescript
|
|
404
|
-
* const msg = createSurface('my-surface');
|
|
405
|
-
* // { createSurface: { surfaceId: 'my-surface', catalogId: '...' } }
|
|
406
|
-
* ```
|
|
407
|
-
*/
|
|
408
|
-
declare function createSurface(surfaceId: string, catalogId?: string): CreateSurfaceMessage;
|
|
409
|
-
/**
|
|
410
|
-
* 创建 UpdateComponents 消息
|
|
411
|
-
*
|
|
412
|
-
* @param surfaceId - Surface ID
|
|
413
|
-
* @param components - 组件列表
|
|
414
|
-
*
|
|
415
|
-
* @example
|
|
416
|
-
* ```typescript
|
|
417
|
-
* const title = text('Hello', { id: 'title' });
|
|
418
|
-
* const msg = updateComponents('my-surface', [title]);
|
|
419
|
-
* ```
|
|
420
|
-
*/
|
|
158
|
+
interface CreateSurfaceOptions {
|
|
159
|
+
catalogId?: string;
|
|
160
|
+
theme?: Theme;
|
|
161
|
+
sendDataModel?: boolean;
|
|
162
|
+
}
|
|
163
|
+
declare function createSurface(surfaceId: string, options?: CreateSurfaceOptions): CreateSurfaceMessage;
|
|
421
164
|
declare function updateComponents(surfaceId: string, components: ComponentInstance[]): UpdateComponentsMessage;
|
|
422
|
-
|
|
423
|
-
* 创建 UpdateDataModel 消息
|
|
424
|
-
*
|
|
425
|
-
* @param surfaceId - Surface ID
|
|
426
|
-
* @param value - 数据值
|
|
427
|
-
* @param path - 数据路径(可选,默认为根路径)
|
|
428
|
-
* @param op - 操作类型(默认为 replace)
|
|
429
|
-
*
|
|
430
|
-
* @example
|
|
431
|
-
* ```typescript
|
|
432
|
-
* // 替换整个数据模型
|
|
433
|
-
* updateDataModel('my-surface', { user: { name: 'John' } });
|
|
434
|
-
*
|
|
435
|
-
* // 更新特定路径
|
|
436
|
-
* updateDataModel('my-surface', 'Jane', '/user/name', 'replace');
|
|
437
|
-
*
|
|
438
|
-
* // 添加数据
|
|
439
|
-
* updateDataModel('my-surface', 'new-item', '/items/-', 'add');
|
|
440
|
-
* ```
|
|
441
|
-
*/
|
|
442
|
-
declare function updateDataModel(surfaceId: string, value: unknown, path?: string, op?: 'add' | 'replace' | 'remove'): UpdateDataModelMessage;
|
|
443
|
-
/**
|
|
444
|
-
* 创建 DeleteSurface 消息
|
|
445
|
-
*
|
|
446
|
-
* @param surfaceId - 要删除的 Surface ID
|
|
447
|
-
*/
|
|
165
|
+
declare function updateDataModel(surfaceId: string, value?: unknown, path?: string): UpdateDataModelMessage;
|
|
448
166
|
declare function deleteSurface(surfaceId: string): DeleteSurfaceMessage;
|
|
449
|
-
|
|
450
|
-
* 创建完整的 v0.9 消息序列
|
|
451
|
-
*
|
|
452
|
-
* @param options - 选项
|
|
453
|
-
* @returns 消息数组(可直接作为 JSONL 流发送)
|
|
454
|
-
*
|
|
455
|
-
* @example
|
|
456
|
-
* ```typescript
|
|
457
|
-
* const title = h1('Welcome', { id: 'title' });
|
|
458
|
-
* const root = column(['title'], { id: 'root' });
|
|
459
|
-
*
|
|
460
|
-
* const messages = createV09Messages({
|
|
461
|
-
* surfaceId: '@chat',
|
|
462
|
-
* components: [title, root],
|
|
463
|
-
* dataModel: { user: { name: 'John' } }
|
|
464
|
-
* });
|
|
465
|
-
*
|
|
466
|
-
* // 发送为 JSONL 流
|
|
467
|
-
* const jsonl = messagesToJsonl(messages);
|
|
468
|
-
* ```
|
|
469
|
-
*/
|
|
470
|
-
declare function createV09Messages(options: {
|
|
167
|
+
declare function createMessages(options: {
|
|
471
168
|
surfaceId: string;
|
|
472
169
|
catalogId?: string;
|
|
170
|
+
theme?: Theme;
|
|
171
|
+
sendDataModel?: boolean;
|
|
473
172
|
components: ComponentInstance[];
|
|
474
173
|
dataModel?: DataObject;
|
|
475
|
-
}):
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
*
|
|
479
|
-
* @param messages - 消息数组
|
|
480
|
-
* @returns JSONL 格式字符串
|
|
481
|
-
*
|
|
482
|
-
* @example
|
|
483
|
-
* ```typescript
|
|
484
|
-
* const jsonl = messagesToJsonl(messages);
|
|
485
|
-
* // 每行一个 JSON 对象
|
|
486
|
-
* ```
|
|
487
|
-
*/
|
|
488
|
-
declare function messagesToJsonl(messages: ServerToClientMessageV09[]): string;
|
|
489
|
-
/**
|
|
490
|
-
* 从 JSONL 格式字符串解析消息数组
|
|
491
|
-
*
|
|
492
|
-
* @param jsonl - JSONL 格式字符串
|
|
493
|
-
* @returns 消息数组
|
|
494
|
-
*/
|
|
495
|
-
declare function jsonlToMessages(jsonl: string): ServerToClientMessageV09[];
|
|
174
|
+
}): ServerToClientMessage[];
|
|
175
|
+
declare function messagesToJsonl(messages: ServerToClientMessage[]): string;
|
|
176
|
+
declare function jsonlToMessages(jsonl: string): ServerToClientMessage[];
|
|
496
177
|
|
|
497
178
|
/**
|
|
498
179
|
* Data Model Builder
|
|
499
180
|
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
181
|
+
* A2UI v0.9 数据模型工具函数
|
|
182
|
+
* v0.9 直接使用 JSON 值,不需要 ValueMap 包装格式
|
|
502
183
|
*/
|
|
503
184
|
|
|
504
|
-
/**
|
|
505
|
-
* ValueMap 格式 - 用于 v0.8 兼容和内部数据转换
|
|
506
|
-
* @internal
|
|
507
|
-
*/
|
|
508
|
-
interface ValueMap {
|
|
509
|
-
key: string;
|
|
510
|
-
valueString?: string;
|
|
511
|
-
valueNumber?: number;
|
|
512
|
-
valueBoolean?: boolean;
|
|
513
|
-
valueMap?: ValueMap[];
|
|
514
|
-
}
|
|
515
185
|
/**
|
|
516
186
|
* 路径映射表类型
|
|
517
187
|
*/
|
|
@@ -520,27 +190,6 @@ type PathMappings = Record<string, string>;
|
|
|
520
190
|
* 默认路径映射
|
|
521
191
|
*/
|
|
522
192
|
declare const DEFAULT_PATH_MAPPINGS: PathMappings;
|
|
523
|
-
/**
|
|
524
|
-
* 将 JavaScript 对象转换为 A2UI ValueMap 格式
|
|
525
|
-
*
|
|
526
|
-
* @param obj - JavaScript 对象
|
|
527
|
-
* @param prefix - 路径前缀(用于嵌套对象的 key 生成)
|
|
528
|
-
*
|
|
529
|
-
* @example
|
|
530
|
-
* objectToValueMap({ name: 'John', age: 30 });
|
|
531
|
-
* // Returns: [
|
|
532
|
-
* // { key: '/name', valueString: 'John' },
|
|
533
|
-
* // { key: '/age', valueNumber: 30 }
|
|
534
|
-
* // ]
|
|
535
|
-
*/
|
|
536
|
-
declare function objectToValueMap(obj: DataObject, prefix?: string): ValueMap[];
|
|
537
|
-
/**
|
|
538
|
-
* 将单个值转换为 A2UI ValueMap 格式
|
|
539
|
-
*
|
|
540
|
-
* @param key - 数据路径/键
|
|
541
|
-
* @param value - JavaScript 值
|
|
542
|
-
*/
|
|
543
|
-
declare function valueToValueMap(key: string, value: DataValue): ValueMap;
|
|
544
193
|
/**
|
|
545
194
|
* 规范化路径格式
|
|
546
195
|
* - 将 . 分隔符转换为 /
|
|
@@ -569,27 +218,5 @@ interface UpdateDataItem {
|
|
|
569
218
|
/** 操作类型(可选,用于增量更新) */
|
|
570
219
|
operation?: 'set' | 'increment' | 'decrement' | 'append' | 'remove';
|
|
571
220
|
}
|
|
572
|
-
/**
|
|
573
|
-
* 将更新数据项数组转换为 ValueMap
|
|
574
|
-
*
|
|
575
|
-
* @param updates - 更新数据项
|
|
576
|
-
* @param basePath - 基础路径
|
|
577
|
-
* @param pathMappings - 可选路径映射表
|
|
578
|
-
*/
|
|
579
|
-
declare function updatesToValueMap(updates: UpdateDataItem[], basePath?: string, pathMappings?: PathMappings): ValueMap[];
|
|
580
|
-
/**
|
|
581
|
-
* 将嵌套对象扁平化为 ValueMap 条目
|
|
582
|
-
*
|
|
583
|
-
* @param obj - 要扁平化的对象
|
|
584
|
-
* @param basePath - 基础路径
|
|
585
|
-
*/
|
|
586
|
-
declare function flattenObjectToValueMap(obj: DataObject, basePath: string): ValueMap[];
|
|
587
|
-
/**
|
|
588
|
-
* 从 ValueMap 数组中提取普通 JavaScript 对象
|
|
589
|
-
*
|
|
590
|
-
* @param valueMaps - ValueMap 数组
|
|
591
|
-
* @returns JavaScript 对象
|
|
592
|
-
*/
|
|
593
|
-
declare function valueMapToObject(valueMaps: ValueMap[]): DataObject;
|
|
594
221
|
|
|
595
|
-
export { type AudioPlayerOptions, type ButtonOptions, type CardOptions, type ChartOptions, type CheckBoxOptions, type ChoicePickerOptions, type ComponentOptions, DEFAULT_PATH_MAPPINGS, type DateTimeInputOptions, type DividerOptions, type IconOptions, type ImageOptions, type LayoutOptions, type ListOptions, type ModalOptions, type PathMappings, type SliderOptions, type
|
|
222
|
+
export { type AudioPlayerOptions, type ButtonOptions, type CardOptions, type ChartOptions, type CheckBoxOptions, type CheckableOptions, type ChoicePickerOptions, type ComponentOptions, type CreateSurfaceOptions, DEFAULT_PATH_MAPPINGS, type DateTimeInputOptions, type DividerOptions, type IconOptions, type ImageOptions, type LayoutOptions, type ListOptions, type ModalOptions, type PathMappings, type SliderOptions, type TabInput, type TabsOptions, type TextFieldOptions, type TextOptions, type UpdateDataItem, type VideoOptions, audioPlayer, barChart, body, button, caption, card, chart, checkbox, choicePicker, column, createMessages, createSurface, dateTimeInput, deleteSurface, divider, eventAction, generateId, getIdCounter, h1, h2, h3, h4, h5, icon, image, jsonlToMessages, lineChart, list, messagesToJsonl, modal, normalizePath, pieChart, resetIdCounter, row, slider, tabs, text, textButton, textField, updateComponents, updateDataModel, video };
|
package/dist/builders/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}function
|
|
3
|
-
`).filter(e=>e.trim()).map(e=>JSON.parse(e))}var
|
|
1
|
+
var g=0;function p(t="comp"){return `${t}_${Date.now()}_${g++}`}function b(){g=0;}function S(){return g}function M(t,e){let o={name:t};return e&&(o.context=e),{event:o}}function d(t,e={}){let{id:o=p("text"),weight:i,variant:n,accessibility:a}=e;return {id:o,component:"Text",text:t,...i!==void 0&&{weight:i},...n&&{variant:n},...a&&{accessibility:a}}}function T(t,e={}){let{id:o=p("image"),weight:i,fit:n,variant:a,accessibility:r}=e;return {id:o,component:"Image",url:t,...i!==void 0&&{weight:i},...n&&{fit:n},...a&&{variant:a},...r&&{accessibility:r}}}function v(t,e={}){let{id:o=p("icon"),weight:i,accessibility:n}=e;return {id:o,component:"Icon",name:t,...i!==void 0&&{weight:i},...n&&{accessibility:n}}}function A(t,e={}){let{id:o=p("video"),weight:i,accessibility:n}=e;return {id:o,component:"Video",url:t,...i!==void 0&&{weight:i},...n&&{accessibility:n}}}function k(t,e={}){let{id:o=p("audio"),weight:i,description:n,accessibility:a}=e;return {id:o,component:"AudioPlayer",url:t,...i!==void 0&&{weight:i},...n&&{description:n},...a&&{accessibility:a}}}function w(t,e={}){let{id:o=p("row"),weight:i,align:n,justify:a,accessibility:r}=e;return {id:o,component:"Row",children:t,...i!==void 0&&{weight:i},...n&&{align:n},...a&&{justify:a},...r&&{accessibility:r}}}function V(t,e={}){let{id:o=p("column"),weight:i,align:n,justify:a,accessibility:r}=e;return {id:o,component:"Column",children:t,...i!==void 0&&{weight:i},...n&&{align:n},...a&&{justify:a},...r&&{accessibility:r}}}function P(t,e={}){let{id:o=p("list"),weight:i,direction:n,align:a,accessibility:r}=e;return {id:o,component:"List",children:t,...i!==void 0&&{weight:i},...n&&{direction:n},...a&&{align:a},...r&&{accessibility:r}}}function L(t,e={}){let{id:o=p("card"),weight:i,accessibility:n}=e;return {id:o,component:"Card",child:t,...i!==void 0&&{weight:i},...n&&{accessibility:n}}}function R(t,e={}){let{id:o=p("tabs"),weight:i,accessibility:n}=e;return {id:o,component:"Tabs",tabs:t.map(a=>({title:a.title,child:a.childId})),...i!==void 0&&{weight:i},...n&&{accessibility:n}}}function F(t={}){let{id:e=p("divider"),weight:o,axis:i,accessibility:n}=t;return {id:e,component:"Divider",...o!==void 0&&{weight:o},...i&&{axis:i},...n&&{accessibility:n}}}function U(t,e,o={}){let{id:i=p("modal"),weight:n,accessibility:a}=o;return {id:i,component:"Modal",trigger:t,content:e,...n!==void 0&&{weight:n},...a&&{accessibility:a}}}function y(t,e,o={}){let{id:i=p("button"),weight:n,variant:a,checks:r,accessibility:s}=o;return {id:i,component:"Button",child:t,action:e,...n!==void 0&&{weight:n},...a&&{variant:a},...r&&r.length>0&&{checks:r},...s&&{accessibility:s}}}function B(t,e,o={}){let{id:i=p("checkbox"),weight:n,checks:a,accessibility:r}=o;return {id:i,component:"CheckBox",label:t,value:e,...n!==void 0&&{weight:n},...a&&a.length>0&&{checks:a},...r&&{accessibility:r}}}function E(t,e,o={}){let{id:i=p("textfield"),weight:n,variant:a,checks:r,accessibility:s}=o;return {id:i,component:"TextField",label:t,...e!==void 0&&{value:e},...n!==void 0&&{weight:n},...a&&{variant:a},...r&&r.length>0&&{checks:r},...s&&{accessibility:s}}}function _(t,e={}){let{id:o=p("datetime"),weight:i,enableDate:n,enableTime:a,min:r,max:s,label:c,checks:m,accessibility:u}=e;return {id:o,component:"DateTimeInput",value:t,...i!==void 0&&{weight:i},...n!==void 0&&{enableDate:n},...a!==void 0&&{enableTime:a},...r&&{min:r},...s&&{max:s},...c&&{label:c},...m&&m.length>0&&{checks:m},...u&&{accessibility:u}}}function j(t,e,o={}){let{id:i=p("choice"),weight:n,label:a,variant:r,checks:s,accessibility:c}=o;return {id:i,component:"ChoicePicker",options:t,value:e,...n!==void 0&&{weight:n},...a&&{label:a},...r&&{variant:r},...s&&s.length>0&&{checks:s},...c&&{accessibility:c}}}function N(t,e,o,i={}){let{id:n=p("slider"),weight:a,label:r,checks:s,accessibility:c}=i;return {id:n,component:"Slider",value:t,min:e,max:o,...a!==void 0&&{weight:a},...r&&{label:r},...s&&s.length>0&&{checks:s},...c&&{accessibility:c}}}function l(t,e,o={}){let{id:i=p("chart"),weight:n,title:a,xAxis:r,yAxis:s,legend:c,tooltip:m,height:u,width:f,echartsOption:x,accessibility:h}=o;return {id:i,component:"Chart",chartType:t,series:e,...n!==void 0&&{weight:n},...a&&{title:a},...r&&{xAxis:r},...s&&{yAxis:s},...c!==void 0&&{legend:c},...m!==void 0&&{tooltip:m},...u!==void 0&&{height:u},...f!==void 0&&{width:f},...x&&{echartsOption:x},...h&&{accessibility:h}}}function G(t,e={}){return l("line",t,e)}function $(t,e={}){return l("bar",t,e)}function J(t,e={}){return l("pie",t,e)}function z(t,e,o={}){let i=o.textId??p("btn_text"),n=d(t,{id:i}),a=y(i,e,o);return [n,a]}function H(t,e={}){return d(t,{...e,variant:"h1"})}function W(t,e={}){return d(t,{...e,variant:"h2"})}function q(t,e={}){return d(t,{...e,variant:"h3"})}function K(t,e={}){return d(t,{...e,variant:"h4"})}function Q(t,e={}){return d(t,{...e,variant:"h5"})}function X(t,e={}){return d(t,{...e,variant:"caption"})}function Y(t,e={}){return d(t,{...e,variant:"body"})}var C="https://a2ui.dev/specification/v0_9/standard_catalog.json";function O(t,e={}){let{catalogId:o=C,theme:i,sendDataModel:n}=e;return {createSurface:{surfaceId:t,catalogId:o,...i&&{theme:i},...n!==void 0&&{sendDataModel:n}}}}function D(t,e){return {updateComponents:{surfaceId:t,components:e}}}function I(t,e,o){return {updateDataModel:{surfaceId:t,...o&&{path:o},...e!==void 0&&{value:e}}}}function Z(t){return {deleteSurface:{surfaceId:t}}}function ee(t){let{surfaceId:e,catalogId:o,theme:i,sendDataModel:n,components:a,dataModel:r}=t,s=[O(e,{catalogId:o,theme:i,sendDataModel:n}),D(e,a)];return r&&s.push(I(e,r)),s}function te(t){return t.map(e=>JSON.stringify(e)).join(`
|
|
2
|
+
`)}function ne(t){return t.split(`
|
|
3
|
+
`).filter(e=>e.trim()).map(e=>JSON.parse(e))}var oe={};function ie(t,e={}){let o=t.replace(/\./g,"/");o.startsWith("/")||(o=`/${o}`);for(let[i,n]of Object.entries(e)){let a=new RegExp(`^/${i}(/|$)`);a.test(o)&&(o=o.replace(a,`/${n}$1`));}return o}export{oe as DEFAULT_PATH_MAPPINGS,k as audioPlayer,$ as barChart,Y as body,y as button,X as caption,L as card,l as chart,B as checkbox,j as choicePicker,V as column,ee as createMessages,O as createSurface,_ as dateTimeInput,Z as deleteSurface,F as divider,M as eventAction,p as generateId,S as getIdCounter,H as h1,W as h2,q as h3,K as h4,Q as h5,v as icon,T as image,ne as jsonlToMessages,G as lineChart,P as list,te as messagesToJsonl,U as modal,ie as normalizePath,J as pieChart,b as resetIdCounter,w as row,N as slider,R as tabs,d as text,z as textButton,E as textField,D as updateComponents,I as updateDataModel,A as video};
|