@chatbi-v/xcml 1.0.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,1006 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React$1, { ReactNode } from 'react';
3
+ export { parse, stringify } from 'yaml';
4
+
5
+ /**
6
+ * XCML 组件规范定义 (Metadata Registry)
7
+ * 职责:显式标注所有组件的可选属性,支持自动化表单生成、校验及 AI 意图映射。
8
+ */
9
+ /** 属性数据类型 */
10
+ type XCMLPropertyType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'enum' | 'any';
11
+ /** 属性功能分类 */
12
+ type XCMLPropertyCategory = 'required' | 'optional' | 'layout' | 'interaction' | 'style';
13
+ /**
14
+ * 单个属性的详细定义
15
+ */
16
+ interface XCMLPropertyDefinition {
17
+ /** 属性名 */
18
+ name: string;
19
+ /** 数据类型 */
20
+ type: XCMLPropertyType;
21
+ /** 属性描述(用于文档或 Tooltip) */
22
+ description: string;
23
+ /** 功能分类 */
24
+ category?: XCMLPropertyCategory;
25
+ /** 是否必填 */
26
+ required?: boolean;
27
+ /** 默认值 */
28
+ default?: any;
29
+ /** 属性转换器:在渲染前对属性值进行最后一次加工(如字符串转数字) */
30
+ transform?: (value: any, context: any) => any;
31
+ /** 枚举类型的可选值列表 */
32
+ options?: string[];
33
+ /** 动态可见性判断:根据其他属性值决定当前属性是否显示 */
34
+ visibleIf?: (props: Record<string, any>) => boolean;
35
+ /** 对象的子属性定义 (仅当 type 为 'object' 时有效) */
36
+ properties?: XCMLPropertyDefinition[];
37
+ /** 数组项的属性定义 (仅当 type 为 'array' 且项为对象时有效) */
38
+ items?: XCMLPropertyDefinition[];
39
+ /** 数组项的基本类型 (仅当 type 为 'array' 且项为基本类型时有效) */
40
+ itemType?: XCMLPropertyType;
41
+ }
42
+ /**
43
+ * 组件完整 Schema 定义
44
+ */
45
+ interface XCMLComponentSchema {
46
+ /** 组件标签名 (如 xcml:metric) */
47
+ tag: string;
48
+ /** 组件中文标题 */
49
+ title: string;
50
+ /** 组件功能描述 */
51
+ description: string;
52
+ /** 标签属性定义 (Attributes) */
53
+ props: XCMLPropertyDefinition[];
54
+ /** 标签体数据定义 (Body Data) */
55
+ body?: XCMLPropertyDefinition[];
56
+ /** 示例配置,用于编辑器快速生成代码 */
57
+ example?: {
58
+ /** 示例属性 */
59
+ props?: Record<string, any>;
60
+ /** 示例 Body 数据 */
61
+ body?: Record<string, any>;
62
+ /** 当 Body 为纯字符串时,默认映射到的属性名(如 'content') */
63
+ contentProp?: string;
64
+ };
65
+ }
66
+ /**
67
+ * 通用组件属性定义
68
+ * 所有 XCML 组件都会自动继承这些属性,无需在每个组件中重复定义
69
+ */
70
+ declare const COMMON_PROPS: XCMLPropertyDefinition[];
71
+ declare const XCML_SCHEMAS: Record<string, XCMLComponentSchema>;
72
+
73
+ /**
74
+ * XCML 基础组件属性定义
75
+ * 所有 XCML 组件都应继承此接口,以确保通用样式的统一透传
76
+ */
77
+ interface XCMLBaseProps {
78
+ /** 唯一标识符,用于事件总线(xcmlBus)定位组件 */
79
+ id?: string;
80
+ /** 视觉主题,可选值如 'light', 'dark', 'ocean' 等 */
81
+ theme?: string;
82
+ /** 变体样式,用于区分同组件的不同视觉呈现 */
83
+ variant?: string;
84
+ /** 组件尺寸 */
85
+ size?: 'small' | 'middle' | 'large';
86
+ /** 自定义 Tailwind 类名 */
87
+ className?: string;
88
+ /** 自定义内联样式 */
89
+ style?: React$1.CSSProperties;
90
+ /** 手动指定加载状态 */
91
+ loading?: boolean;
92
+ /**
93
+ * 数据流状态
94
+ * - loading: 初始加载中
95
+ * - streaming: 正在接收流式数据
96
+ * - done: 加载完成
97
+ * - error: 发生错误
98
+ */
99
+ streamStatus?: 'loading' | 'streaming' | 'done' | 'error';
100
+ /** 错误信息对象 */
101
+ error?: Error | null;
102
+ /** 原始 XCML AST 节点引用 */
103
+ node?: any;
104
+ }
105
+ /**
106
+ * XCML 基础组件接口
107
+ * 定义了组件应实现的通用方法与元数据
108
+ *
109
+ * @example
110
+ * ```tsx
111
+ * const MyComponent: XCMLBaseComponent<Props> = (props) => { ... }
112
+ * MyComponent.schema = mySchema;
113
+ * ```
114
+ */
115
+ interface XCMLBaseComponent<P = {}> extends React$1.FC<P & XCMLBaseProps> {
116
+ /**
117
+ * 组件元数据定义 (Schema)
118
+ * 用于自动化的属性提取、文档生成及工作台交互
119
+ */
120
+ schema: XCMLComponentSchema;
121
+ }
122
+ /**
123
+ * 通用样式提取工具
124
+ * 从组件 Props 中提取出 XCMLBaseProps 定义的通用样式属性,便于透传给 Wrapper
125
+ *
126
+ * @param props - 组件接收到的所有属性
127
+ * @returns 仅包含基础样式的属性对象
128
+ */
129
+ declare function extractBaseStyles(props: Record<string, any>): Partial<XCMLBaseProps>;
130
+
131
+ /**
132
+ * XCML 内部通用工具函数
133
+ */
134
+ /**
135
+ * 核心 Hook:从 XCML 节点中提取并合并属性与数据
136
+ *
137
+ * 治理原则:
138
+ * 1. 优先级:显式标签属性 (Props) > 标签体数据 (Body Data) > Schema 默认值 (Defaults)。
139
+ * 2. 智能解析:自动识别 Body 中的 JSON 字符串并解析。
140
+ * 3. 结构适配:根据 Schema 将 Body 中的数组或原始值映射到正确的属性名上。
141
+ *
142
+ * @param node - XCML AST 节点模型
143
+ * @param schema - 组件的规范定义
144
+ * @returns 合并后的全量属性对象
145
+ *
146
+ * @template T - 组件特有的属性类型
147
+ */
148
+ declare function useXCMLNode<T = Record<string, any>>(node: any, schema?: XCMLComponentSchema): T & XCMLBaseProps;
149
+ /**
150
+ * 增强型数组解析工具
151
+ *
152
+ * 支持以下格式:
153
+ * 1. 标准 JSON 数组: `["a", "b"]`
154
+ * 2. 非标单引号数组: `['a', 'b']`
155
+ * 3. 逗号分隔字符串: `a, b, c` 或 `a,b,c`
156
+ *
157
+ * @param val - 待解析的原始值
158
+ * @returns 归一化后的字符串数组
159
+ */
160
+ declare const parseArrayProp: (val: any) => string[];
161
+ /**
162
+ * 渲染器别名生成工具
163
+ *
164
+ * 职责:
165
+ * 为组件创建标准 `xcml:` 前缀的映射,并根据别名表生成冗余映射。
166
+ * 注意:`x-` 前缀的兼容性由 Markdown 渲染引擎在运行时通过 `normalizeTagName` 自动处理。
167
+ *
168
+ * @param baseMap - 基础渲染器映射表 { tagName: Renderer }
169
+ * @param aliases - 别名映射表 { tagName: [alias1, alias2] }
170
+ * @returns 补全后的渲染器映射表
171
+ */
172
+ declare function createRenderersWithAliases(baseMap: Record<string, (node: any, key: string | number) => any>, aliases?: Record<string, string[]>): Record<string, (node: any, key: string | number) => any>;
173
+ /**
174
+ * XCML 独立渲染函数
175
+ * 职责:接收 XCML 节点数据,返回对应的 React 组件
176
+ */
177
+ declare const renderXCML: (node: any, key?: string | number) => any;
178
+ /**
179
+ * 结构化数据校验工具
180
+ *
181
+ * 职责:
182
+ * 根据 Schema 定义,对 XCML 节点的 Props 和 Body 进行合规性检查。
183
+ * 用于编辑器实时报错提示或数据入库前的安全检查。
184
+ *
185
+ * @param node - 待校验的 XCML 节点
186
+ * @param schema - 该组件对应的规范定义
187
+ * @returns 校验结果对象,包含是否合法及详细错误列表
188
+ */
189
+ declare function validateXCMLNode(node: any, schema: XCMLComponentSchema): {
190
+ valid: boolean;
191
+ errors: string[];
192
+ };
193
+
194
+ /**
195
+ * XCML 组件通用业务逻辑 Hook
196
+ *
197
+ * 职责:
198
+ * 1. 自动调用 `useXCMLNode` 进行属性 (Props) 与数据 (Body) 的智能合并。
199
+ * 2. 统一计算 `loading` 状态,支持多种标记方式(外部注入、节点状态、data-属性)。
200
+ * 3. 统一提取基础样式属性,确保所有组件在不同主题下的视觉一致性。
201
+ *
202
+ * @param props - 组件接收到的原始属性
203
+ * @param schema - 组件的 Schema 定义,用于指导属性合并与默认值注入
204
+ * @returns 包含合并后的数据 `merged`、基础样式 `baseProps` 及加载状态 `isLoading`
205
+ *
206
+ * @example
207
+ * ```tsx
208
+ * const { merged, baseProps, isLoading } = useXCMLComponent(props, cardSchema);
209
+ * ```
210
+ */
211
+ declare function useXCMLComponent<P extends object>(props: P & XCMLBaseProps, schema?: XCMLComponentSchema): {
212
+ merged: P & XCMLBaseProps;
213
+ baseProps: XCMLBaseProps;
214
+ isLoading: boolean | undefined;
215
+ streamStatus: any;
216
+ };
217
+
218
+ /**
219
+ * XCML 架构说明 (Architecture Guide)
220
+ *
221
+ * 1. Schema 定义 (./schemas/):
222
+ * 定义组件的 tag、props、example 等元数据。
223
+ * 每个组件拥有独立的 schema 文件,便于维护 and 扩展。
224
+ * 这是组件的“身份证”,用于工作台展示 and 数据校验。
225
+ *
226
+ * 2. 核心逻辑 (./index.ts):
227
+ * 处理 XCML 标签的预处理、解析、数据转换及事件通信 (xcmlBus)。
228
+ *
229
+ * 3. 渲染层 (../renderers/):
230
+ * - basic: 基础组件 (Metric, Table, List)
231
+ * - antv: 图表组件 (基于 @ant-design/plots)
232
+ * - cards: 复合业务组件 (InsightCard, ThoughtChain)
233
+ *
234
+ * 如何扩展新组件:
235
+ * 1. 在 core/schemas/ 目录下创建新的 schema 文件并导出。
236
+ * 2. 在 core/schema.ts 的 XCML_SCHEMAS 注册表中引入并注册该 schema。
237
+ * 3. 在对应的 renderers 目录下创建 React 组件实现。
238
+ * 4. 在 renderers 的工厂方法中导出该组件的渲染函数。
239
+ */
240
+ /**
241
+ * XCML 核心类型与事件总线
242
+ */
243
+ /**
244
+ * 标签归一化:将任意格式的标签名统一转换为不带前缀的纯名称
245
+ * @param tag - 原始标签名 (如 xcml:metric, x-metric)
246
+ * @returns 归一化后的名称 (如 metric)
247
+ */
248
+ declare function normalizeTagName(tag: string): string;
249
+ /**
250
+ * 转换为 x- 前缀格式(用于 HTML 渲染)
251
+ */
252
+ declare function toXTag(tag: string): string;
253
+ /**
254
+ * 转换为 xcml: 前缀格式(用于 Schema 匹配)
255
+ */
256
+ declare function toXCMLTag(tag: string): string;
257
+ type XCMLRenderer = (node: any, key: string | number) => any;
258
+ interface XCMLContext {
259
+ theme: string;
260
+ whitelist?: {
261
+ link?: string[];
262
+ image?: string[];
263
+ };
264
+ }
265
+ type XCMLPlugin = (ast: any, ctx: XCMLContext) => any;
266
+ /**
267
+ * XCML 事件总线
268
+ * 职责:实现渲染层组件与宿主页面之间的双向通信。
269
+ *
270
+ * 支持的内置事件:
271
+ * - refresh: 请求组件重新加载数据
272
+ * - update: 外部向组件注入新数据
273
+ * - resize: 通知组件重绘图表尺寸
274
+ * - export: 触发组件导出操作 (图片/CSV)
275
+ */
276
+ declare class XCMLEventBus {
277
+ /** 监听器映射:事件名到监听函数数组 */
278
+ private listeners;
279
+ /** 注册事件监听器 */
280
+ on(event: string, handler: (payload?: any) => void): void;
281
+ /** 触发事件 */
282
+ emit(event: string, payload?: any): void;
283
+ /** 刷新方法:按 id 或全部刷新 */
284
+ refresh(id?: string): void;
285
+ /** 更新方法:按 id 注入数据 */
286
+ update(id: string, payload: any): void;
287
+ /** 重绘尺寸 */
288
+ resize(id?: string): void;
289
+ /** 导出方法:导出指定类型 */
290
+ export(id: string, type: string): void;
291
+ }
292
+ /**
293
+ * 事件总线单例:供渲染器与页面交互使用
294
+ */
295
+ declare const xcmlBus: XCMLEventBus;
296
+ /**
297
+ * 智能数据解析引擎
298
+ *
299
+ * 职责:
300
+ * 根据 `data-format` 属性将文本块解析为 JavaScript 对象/数组。
301
+ *
302
+ * 特性:
303
+ * 1. 支持 JSON / JSONC (带注释的 JSON)。
304
+ * 2. 支持 YAML (由于 YAML 格式更宽容,常作为 JSON 解析失败后的 Fallback)。
305
+ * 3. 支持 CSV / TSV 自动转换(含简单的类型识别)。
306
+ * 4. 支持 NDJSON (每行一个 JSON 对象)。
307
+ *
308
+ * @param text - 待解析的文本内容
309
+ * @param format - 指定的数据格式
310
+ * @returns 解析后的对象或数组
311
+ */
312
+ declare function parseInlineData(text: string, format?: 'json' | 'jsonc' | 'yaml' | 'csv' | 'tsv' | 'ndjson'): any;
313
+ /**
314
+ * 安全校验占位:后续接入 Ajv Schema 校验与白名单过滤
315
+ */
316
+ declare function validateDataSchema(_component: string, data: any): boolean;
317
+
318
+ /**
319
+ * 规范化数据对象:根据 Schema 定义,将属性中可能的 JSON 字符串解析为对象/数组
320
+ * 解决双重序列化问题 (Double Serialization)
321
+ */
322
+ declare function normalizeNodeData(tag: string, data: any): any;
323
+ /**
324
+ * 核心逻辑:属性与数据智能合并
325
+ *
326
+ * 职责:
327
+ * 将解析出的标签属性 (attrs) 与标签体数据 (bodyData) 根据 Schema 定义进行智能分流。
328
+ *
329
+ * 核心策略:
330
+ * 1. 结构化匹配:如果 bodyData 是对象,将其字段分流到 Props 或 Body 属性中。
331
+ * 2. 类型适配:如果 bodyData 是数组,根据 Schema 查找对应的数组字段(默认为 `data`)。
332
+ * 3. preferBody 模式:为了生成更简洁的 XCML 标签,支持将所有业务属性强制压缩到 Body 的 JSON 中。
333
+ *
334
+ * @param tagName - 标签名
335
+ * @param attrs - 标签上的属性集合
336
+ * @param bodyData - 标签体内的解析后数据
337
+ * @param options - 合并配置
338
+ * @returns 分流后的 { props, body } 对象
339
+ */
340
+ declare function mergePropsAndBody(tagName: string, attrs: Record<string, any>, bodyData: any, options?: {
341
+ preferBody?: boolean;
342
+ }): {
343
+ props: any;
344
+ body: any;
345
+ };
346
+ /**
347
+ * 序列化引擎:将内存中的节点模型转换为 XCML 标签字符串
348
+ *
349
+ * 治理要求:
350
+ * 遵循“全量 Body 化”协定,除了技术性属性(id, className)外,
351
+ * 所有业务属性一律序列化为 Body 中的 JSON,以提高 Markdown 的可读性和容错率。
352
+ *
353
+ * @param node - 待转换的节点模型
354
+ * @returns 格式化后的 XCML 字符串
355
+ */
356
+ declare function stringifyToXCML(node: {
357
+ tag?: string;
358
+ type?: string;
359
+ props?: Record<string, any>;
360
+ body?: any;
361
+ }): string;
362
+ /**
363
+ * 简单的 XCML 解析器,用于工作台同步
364
+ * 仅处理单个根节点
365
+ */
366
+ declare function parseXCML(xcml: string): {
367
+ tag: string;
368
+ props: Record<string, any>;
369
+ body: any;
370
+ } | null;
371
+
372
+ /**
373
+ * 统一节点模型转换器
374
+ *
375
+ * 职责:
376
+ * 接收原始的 DOM 元素信息(标签名、属性、文本内容),将其转换为 XCML AST 节点。
377
+ * 这是连接 Markdown 解析层与 XCML 渲染层的关键桥梁。
378
+ *
379
+ * @param name - 标签名
380
+ * @param attrs - DOM 属性集合
381
+ * @param bodyText - 标签体内的原始文本
382
+ * @returns 标准化的 XCML AST 节点对象
383
+ */
384
+ declare function toXCMLNodeFromElement(name: string, attrs: Record<string, any>, bodyText: string): {
385
+ type: string;
386
+ props: any;
387
+ body: any;
388
+ __source: string;
389
+ };
390
+ /**
391
+ * 预处理 XCML 内容:
392
+ * 0. 流式优化与归一化
393
+ * 1. 忽略代码块中的标签
394
+ * 2. 转义未闭合的标签
395
+ * 3. 修复属性格式
396
+ * 4. 剔除未识别的 x- 标签 (如果提供了 knownTags)
397
+ */
398
+ declare function preprocessXCML(md: string, knownTags?: string[]): string;
399
+
400
+ interface XCMLProps {
401
+ content?: string;
402
+ stream?: AsyncIterable<string>;
403
+ renderers?: Record<string, (node: any, key: string | number) => React$1.ReactNode>;
404
+ className?: string;
405
+ style?: React$1.CSSProperties;
406
+ openLinksInNewTab?: boolean;
407
+ dompurifyConfig?: Record<string, any>;
408
+ /**
409
+ * 是否启用悬停查看组件源码功能
410
+ * @default false
411
+ */
412
+ enableHoverSource?: boolean;
413
+ /**
414
+ * 主题配置,用于 Mermaid 等图表
415
+ */
416
+ theme?: string;
417
+ }
418
+ /**
419
+ * XCML 核心渲染组件 (XCMLMarkdown)
420
+ *
421
+ * 职责:
422
+ * 1. 内容预处理:利用 `preprocessXCML` 处理不规范标签,并支持通过 `data-xcml-raw` 保护原始 Markdown 内容。
423
+ * 2. 动态组件映射:将 `x-*` 标签自动关联到 `renderers` 中定义的业务渲染器。
424
+ * 3. 增强 Markdown 功能:集成 Mermaid 图表、自动生成目录 (TOC) 锚点、处理 DOM 嵌套合法性(如 P 标签内嵌 Div)。
425
+ * 4. 交互体验:支持流式输出中间态显示、源码悬浮查看、链接新窗口打开等。
426
+ *
427
+ * @example
428
+ * ```tsx
429
+ * <XCMLMarkdown
430
+ * content="<x-card>Hello</x-card>"
431
+ * renderers={{ 'x-card': CardRenderer }}
432
+ * />
433
+ * ```
434
+ */
435
+ declare function XCMLMarkdown(props: XCMLProps): react_jsx_runtime.JSX.Element;
436
+
437
+ /**
438
+ * AntV 渲染器全局配置选项
439
+ */
440
+ interface AntVRendererOptions {
441
+ /** 主题名称,如 'light', 'dark' */
442
+ theme?: string;
443
+ }
444
+ /**
445
+ * AntV 图表组件属性定义
446
+ *
447
+ * @description 所有的属性(除了 type 和 data)都将直接透传给 @ant-design/plots 的对应组件。
448
+ */
449
+ interface ChartProps {
450
+ /**
451
+ * 图表类型,对应 @ant-design/plots 的组件名(如 'line', 'pie', 'column' 等)。
452
+ * 系统会自动进行 PascalCase 转换(如 'word-cloud' -> 'WordCloud')。
453
+ */
454
+ type: string;
455
+ /**
456
+ * 图表数据。
457
+ * - 如果是 Array: 映射为 AntV 的 data 属性。
458
+ * - 如果是 Object: 视为完整的 AntV 配置对象,将与其它属性合并。
459
+ * - 如果是 Number: 针对进度类图表,自动映射为 percent 属性。
460
+ */
461
+ data?: any;
462
+ /**
463
+ * 其他 AntV 配置项,如 xField, yField, seriesField, color, legend 等。
464
+ */
465
+ [key: string]: any;
466
+ }
467
+ /**
468
+ * 动态加载的图表组件类型定义
469
+ */
470
+ type ChartComponent = React.ComponentType<any>;
471
+
472
+ /**
473
+ * 图表策略接口
474
+ */
475
+ interface ChartStrategy {
476
+ /** 策略对应的图表类型 (如 'line', 'column') */
477
+ type: string;
478
+ /** 该图表类型的独立 Schema 定义 */
479
+ schema: XCMLComponentSchema;
480
+ /** 获取 AntV 组件 */
481
+ getComponent: () => React$1.ComponentType<Record<string, any>>;
482
+ /** 属性转换/规范化 */
483
+ transformProps?: (props: Record<string, any>) => Record<string, any>;
484
+ }
485
+ /**
486
+ * 坐标轴配置
487
+ */
488
+ interface ChartAxisConfig {
489
+ title?: string | {
490
+ text?: string;
491
+ style?: Record<string, string | number>;
492
+ };
493
+ label?: {
494
+ autoHide?: boolean;
495
+ autoRotate?: boolean;
496
+ style?: Record<string, string | number>;
497
+ };
498
+ grid?: {
499
+ line?: {
500
+ style?: Record<string, string | number>;
501
+ };
502
+ };
503
+ line?: {
504
+ style?: Record<string, string | number>;
505
+ };
506
+ tickLine?: {
507
+ style?: Record<string, string | number>;
508
+ };
509
+ }
510
+ /**
511
+ * 标签配置
512
+ */
513
+ interface ChartLabelConfig {
514
+ text?: string;
515
+ position?: 'top' | 'bottom' | 'left' | 'right' | 'inside' | 'outside' | 'center';
516
+ offset?: number;
517
+ content?: string | ((data: Record<string, any>) => string);
518
+ formatter?: (val: string | number) => string;
519
+ style?: Record<string, string | number>;
520
+ [key: string]: string | number | boolean | undefined | Record<string, any> | ((...args: unknown[]) => unknown);
521
+ }
522
+ /**
523
+ * 图例配置
524
+ */
525
+ interface ChartLegendConfig {
526
+ position?: 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
527
+ layout?: 'horizontal' | 'vertical';
528
+ title?: {
529
+ text?: string;
530
+ style?: Record<string, string | number>;
531
+ };
532
+ marker?: {
533
+ symbol?: string;
534
+ style?: Record<string, string | number>;
535
+ };
536
+ }
537
+ /**
538
+ * 基础图表属性定义
539
+ */
540
+ interface BaseChartProps {
541
+ /** 图表类型 */
542
+ type: string;
543
+ /** 图表数据 */
544
+ data: Record<string, any>[];
545
+ /** 宽度 */
546
+ width?: number;
547
+ /** 高度 */
548
+ height?: number;
549
+ /** 是否自适应 */
550
+ autoFit?: boolean;
551
+ /** 主题 */
552
+ theme?: string;
553
+ /** 标题配置 */
554
+ title?: string | {
555
+ text?: string;
556
+ style?: Record<string, string | number>;
557
+ };
558
+ /** 标签配置 (支持单标签对象或多标签数组) */
559
+ label?: boolean | ChartLabelConfig | ChartLabelConfig[];
560
+ /** 标签配置别名 (支持多标签数组) */
561
+ labels?: ChartLabelConfig[];
562
+ /** 坐标轴配置 */
563
+ axis?: boolean | {
564
+ x?: ChartAxisConfig;
565
+ y?: ChartAxisConfig;
566
+ };
567
+ /** 图例配置 */
568
+ legend?: boolean | ChartLegendConfig;
569
+ /** 交互配置 */
570
+ interaction?: Record<string, any>;
571
+ /** 动画配置 */
572
+ animation?: Record<string, any>;
573
+ /** 原生 AntV 配置透传 (最高优先级) */
574
+ __native__?: Record<string, any>;
575
+ /** 空态占位 */
576
+ emptyPlaceholder?: ReactNode;
577
+ /** 错误态占位 */
578
+ errorPlaceholder?: (err: Error, reset: () => void) => ReactNode;
579
+ /** 其他透传属性 */
580
+ [key: string]: string | number | boolean | undefined | Record<string, any> | string[] | number[] | Record<string, any>[] | ReactNode | ((...args: unknown[]) => unknown);
581
+ }
582
+
583
+ /**
584
+ * 折线图 XCML Schema 定义
585
+ */
586
+ declare const lineChartSchema: XCMLComponentSchema;
587
+
588
+ /**
589
+ * 折线图属性定义
590
+ */
591
+ interface LineChartProps extends BaseChartProps {
592
+ type: 'line';
593
+ xField: string;
594
+ yField: string;
595
+ colorField?: string;
596
+ seriesField?: string;
597
+ }
598
+ /**
599
+ * 折线图策略实现
600
+ */
601
+ declare const lineStrategy: ChartStrategy;
602
+
603
+ /**
604
+ * 柱状图 XCML Schema 定义
605
+ */
606
+ declare const columnChartSchema: XCMLComponentSchema;
607
+
608
+ /**
609
+ * 柱状图属性定义
610
+ */
611
+ interface ColumnChartProps extends BaseChartProps {
612
+ type: 'column';
613
+ xField: string;
614
+ yField: string;
615
+ colorField?: string;
616
+ seriesField?: string;
617
+ group?: boolean | Record<string, string | number | boolean>;
618
+ isRange?: boolean;
619
+ }
620
+ /**
621
+ * 柱状图策略实现
622
+ */
623
+ declare const columnStrategy: ChartStrategy;
624
+
625
+ /**
626
+ * 饼图 XCML Schema 定义
627
+ */
628
+ declare const pieChartSchema: XCMLComponentSchema;
629
+
630
+ /**
631
+ * 饼图属性定义
632
+ */
633
+ interface PieChartProps extends BaseChartProps {
634
+ type: 'pie';
635
+ angleField: string;
636
+ colorField: string;
637
+ }
638
+ /**
639
+ * 饼图策略实现
640
+ */
641
+ declare const pieStrategy: ChartStrategy;
642
+
643
+ /**
644
+ * 双轴图 XCML Schema 定义
645
+ */
646
+ declare const dualAxesChartSchema: XCMLComponentSchema;
647
+
648
+ /**
649
+ * 双轴图子图层配置
650
+ */
651
+ interface DualAxesChildConfig {
652
+ type: 'interval' | 'line' | 'area' | 'point';
653
+ yField: string;
654
+ colorField?: string;
655
+ seriesField?: string;
656
+ shapeField?: string;
657
+ group?: boolean;
658
+ style?: Record<string, any>;
659
+ interaction?: Record<string, any>;
660
+ data?: Record<string, any>[];
661
+ axis?: Record<string, any>;
662
+ label?: boolean | ChartLabelConfig;
663
+ [key: string]: string | number | boolean | undefined | Record<string, any> | string[] | number[] | Record<string, any>[] | ((...args: unknown[]) => unknown);
664
+ }
665
+ /**
666
+ * 双轴图属性定义
667
+ */
668
+ interface DualAxesChartProps extends BaseChartProps {
669
+ type: 'dual-axes';
670
+ xField: string;
671
+ children: DualAxesChildConfig[];
672
+ }
673
+ /**
674
+ * 双轴图策略实现
675
+ */
676
+ declare const dualAxesStrategy: ChartStrategy;
677
+
678
+ /**
679
+ * 漏斗图 XCML Schema 定义
680
+ */
681
+ declare const funnelChartSchema: XCMLComponentSchema;
682
+
683
+ /**
684
+ * 漏斗图属性定义
685
+ */
686
+ interface FunnelChartProps extends BaseChartProps {
687
+ type: 'funnel';
688
+ xField: string;
689
+ yField: string;
690
+ }
691
+ /**
692
+ * 漏斗图策略实现
693
+ */
694
+ declare const funnelStrategy: ChartStrategy;
695
+
696
+ declare const strategies: Record<string, ChartStrategy>;
697
+ /**
698
+ * 根据类型获取图表策略
699
+ */
700
+ declare function getChartStrategy(type: string): ChartStrategy | null;
701
+
702
+ /**
703
+ * AntV 通用图表 XCML Schema 定义
704
+ * 职责:作为图表组件的通用容器入口,聚合各子图表的属性定义,支持在工作台中根据 type 动态切换。
705
+ */
706
+ declare const chartSchema: XCMLComponentSchema;
707
+
708
+ /**
709
+ * 深度合并工具函数
710
+ */
711
+ declare function deepMerge<T extends Record<string, any>>(target: T, source: Record<string, any>): T;
712
+ /**
713
+ * Schema 驱动的属性清洗器
714
+ * 根据 Schema 定义的规则 (visibleIf, default, transform) 处理属性
715
+ *
716
+ * @param props 原始属性
717
+ * @param schema 组件 Schema
718
+ * @returns 清洗后的属性
719
+ */
720
+ declare function cleanPropsBySchema(props: Record<string, any>, schema?: XCMLComponentSchema): Record<string, any>;
721
+ /**
722
+ * 构建最终图表配置
723
+ */
724
+ declare function buildConfig(props: BaseChartProps): Record<string, any>;
725
+ /**
726
+ * 空态占位组件
727
+ */
728
+ declare const DefaultEmptyPlaceholder: () => react_jsx_runtime.JSX.Element;
729
+ /**
730
+ * 错误态占位组件
731
+ */
732
+ declare const DefaultErrorPlaceholder: ({ error, reset }: {
733
+ error: Error;
734
+ reset: () => void;
735
+ }) => react_jsx_runtime.JSX.Element;
736
+
737
+ /**
738
+ * AntV 图表加载器 (基于 withXCMLCard 重构)
739
+ */
740
+ declare const AntVChartLoader: React$1.ForwardRefExoticComponent<Omit<any, "ref"> & React$1.RefAttributes<any>>;
741
+
742
+ /**
743
+ * XCML 图表组件 (对外导出,供编排使用)
744
+ */
745
+ declare const XCMLChart: React$1.FC<BaseChartProps & {
746
+ node?: any;
747
+ }>;
748
+
749
+ declare const themeLight: {
750
+ defaultColor: string;
751
+ colors10: string[];
752
+ styleSheet: {
753
+ backgroundColor: string;
754
+ };
755
+ components: {
756
+ axis: {
757
+ common: {
758
+ label: {
759
+ style: {
760
+ fillOpacity: number;
761
+ fontSize: number;
762
+ };
763
+ };
764
+ title: {
765
+ style: {
766
+ fontSize: number;
767
+ fillOpacity: number;
768
+ };
769
+ };
770
+ grid: {
771
+ line: {
772
+ style: {
773
+ stroke: string;
774
+ lineWidth: number;
775
+ lineDash: number[];
776
+ strokeOpacity: number;
777
+ };
778
+ };
779
+ };
780
+ };
781
+ };
782
+ tooltip: {
783
+ style: {
784
+ backgroundColor: string;
785
+ boxShadow: string;
786
+ color: string;
787
+ borderRadius: string;
788
+ padding: string;
789
+ border: string;
790
+ backdropFilter: string;
791
+ };
792
+ };
793
+ legend: {
794
+ common: {
795
+ itemStates: {
796
+ active: {
797
+ labelStyle: {
798
+ fontWeight: number;
799
+ fill: string;
800
+ };
801
+ };
802
+ };
803
+ };
804
+ };
805
+ };
806
+ };
807
+ declare const themeDark: {
808
+ defaultColor: string;
809
+ colors10: string[];
810
+ styleSheet: {
811
+ backgroundColor: string;
812
+ };
813
+ components: {
814
+ axis: {
815
+ common: {
816
+ label: {
817
+ style: {
818
+ fill: string;
819
+ fontSize: number;
820
+ };
821
+ };
822
+ title: {
823
+ style: {
824
+ fill: string;
825
+ fontSize: number;
826
+ };
827
+ };
828
+ grid: {
829
+ line: {
830
+ style: {
831
+ stroke: string;
832
+ lineWidth: number;
833
+ lineDash: number[];
834
+ };
835
+ };
836
+ };
837
+ };
838
+ };
839
+ tooltip: {
840
+ style: {
841
+ backgroundColor: string;
842
+ boxShadow: string;
843
+ color: string;
844
+ borderRadius: string;
845
+ padding: string;
846
+ border: string;
847
+ backdropFilter: string;
848
+ };
849
+ };
850
+ legend: {
851
+ common: {
852
+ labelStyle: {
853
+ fill: string;
854
+ };
855
+ };
856
+ };
857
+ };
858
+ };
859
+ declare const themeMap: Record<string, any>;
860
+ declare function getTheme(themeName?: string): any;
861
+
862
+ /**
863
+ * 图表渲染器:将 xcml:chart 数据映射到 AntV Plots
864
+ */
865
+ declare function createAntVRenderers(options?: AntVRendererOptions): Record<string, (node: any, key: string | number) => any>;
866
+
867
+ /**
868
+ * XCML 通用卡片包装器属性定义
869
+ */
870
+ interface XCMLCardWrapperProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>, 'title'> {
871
+ /** 卡片标题 */
872
+ title?: React$1.ReactNode;
873
+ /** 卡片左上角图标 */
874
+ icon?: React$1.ReactNode;
875
+ /** 卡片主体内容 */
876
+ children?: React$1.ReactNode;
877
+ /** 数据来源(透传属性) */
878
+ source?: string;
879
+ /** 摘要内容(透传属性) */
880
+ summary?: React$1.ReactNode;
881
+ /** 容器变体: 'card' (默认带边框阴影) | 'plain' (纯文字,无边框) */
882
+ variant?: string;
883
+ /** 视觉主题 */
884
+ theme?: string;
885
+ /** 是否支持悬停时的浮起阴影效果 */
886
+ hoverable?: boolean;
887
+ /** 原始 XCML 节点数据 */
888
+ node?: Record<string, any>;
889
+ /** 关联的 DOM 节点引用 */
890
+ domNode?: HTMLElement | null;
891
+ /** 数据流式加载状态 */
892
+ streamStatus?: string;
893
+ }
894
+ /**
895
+ * XCML 通用卡片包装器 (Themed Container)
896
+ *
897
+ * 职责:
898
+ * 1. 提供全局一致的容器样式:圆角、边框、阴影、外边距。
899
+ * 2. 渲染统一的标题栏布局,支持图标与悬停装饰条。
900
+ * 3. 拦截并清理内部业务属性,防止非法的 XCML 属性透传到原生 DOM 节点引起 React 警告。
901
+ *
902
+ * 设计风格:
903
+ * 参考现代 AI 助手 UI 规范,强调微阴影(shadow-card)与圆润度(rounded-xl)。
904
+ */
905
+ declare const XCMLCardWrapper: React$1.FC<XCMLCardWrapperProps>;
906
+
907
+ /**
908
+ * withXCMLCard 高阶组件配置项
909
+ */
910
+ interface WithXCMLCardOptions<P> {
911
+ /**
912
+ * 组件 Schema 定义
913
+ * 用于 `useXCMLComponent` 自动进行属性映射与默认值注入
914
+ */
915
+ schema?: XCMLComponentSchema;
916
+ /**
917
+ * 自定义获取标题逻辑
918
+ * @default merged.label || merged.title
919
+ */
920
+ getTitle?: (mergedProps: P) => string | undefined;
921
+ /**
922
+ * 自定义获取图标逻辑
923
+ * @default merged.icon
924
+ */
925
+ getIcon?: (mergedProps: P) => React$1.ReactNode;
926
+ /**
927
+ * 自定义获取变体逻辑 (card | plain)
928
+ * @default merged.variant || 'card'
929
+ */
930
+ getVariant?: (mergedProps: P) => string;
931
+ /**
932
+ * 自定义加载态渲染内容
933
+ * 如果提供此函数,则忽略骨架屏配置
934
+ */
935
+ renderLoading?: (mergedProps: P) => React$1.ReactNode;
936
+ /**
937
+ * 是否支持骨架屏渲染
938
+ * @default true
939
+ */
940
+ skeleton?: boolean | {
941
+ rows?: number;
942
+ };
943
+ }
944
+ /**
945
+ * XCML 渲染器增强高阶组件 (HOC)
946
+ *
947
+ * 职责:
948
+ * 1. 状态集成:利用 `useXCMLComponent` 统一管理 Props 合并、数据流状态及加载判断。
949
+ * 2. 视觉规范:自动包裹 `XCMLCardWrapper`,确保所有组件拥有统一的容器样式、标题栏和主题表现。
950
+ * 3. 容错治理:处理标题防御(如 LLM 生成了数组或对象形式的标题)及旧版属性兼容。
951
+ * 4. 体验优化:内置 Ant Design 骨架屏加载态。
952
+ *
953
+ * @param Component - 业务渲染器组件
954
+ * @param options - 配置参数
955
+ *
956
+ * @example
957
+ * ```tsx
958
+ * export default withXCMLCard(MyTable, { schema: tableSchema });
959
+ * ```
960
+ */
961
+ declare function withXCMLCard<P extends object>(Component: React$1.ComponentType<P>, options?: WithXCMLCardOptions<P & XCMLBaseProps>): React$1.ForwardRefExoticComponent<Omit<any, "ref"> & React$1.RefAttributes<any>>;
962
+
963
+ /**
964
+ * 基础渲染器集合:metric/table/card/list/toc
965
+ * 说明:UI 基于 @ant-design/x,若组件名存在差异,将以简化实现占位
966
+ */
967
+ interface BasicRenderersOptions {
968
+ theme?: string;
969
+ }
970
+ declare function createBasicRenderers(options?: BasicRenderersOptions): Record<string, (node: any, key: string | number) => any>;
971
+
972
+ interface ExtendedRenderersOptions {
973
+ theme?: string;
974
+ }
975
+ declare function createExtendedRenderers(options?: ExtendedRenderersOptions): Record<string, (node: any, key: string | number) => any>;
976
+
977
+ type Theme = "dark" | "light" | "system" | "ocean" | "sunset" | "lavender" | "rose" | "amber" | "midnight" | "forest" | "slate" | "crimson" | "cyan";
978
+ type ThemeProviderProps = {
979
+ children: React.ReactNode;
980
+ defaultTheme?: Theme;
981
+ /**
982
+ * Explicitly set the theme (Controlled mode).
983
+ */
984
+ theme?: Theme;
985
+ /**
986
+ * Primary color for the theme (e.g., #6366f1)
987
+ */
988
+ primaryColor?: string;
989
+ storageKey?: string;
990
+ /**
991
+ * Whether to apply the theme only to the container instead of the document root
992
+ * @default true
993
+ */
994
+ scoped?: boolean;
995
+ className?: string;
996
+ style?: React.CSSProperties;
997
+ };
998
+ type ThemeProviderState = {
999
+ theme: Theme;
1000
+ setTheme: (theme: Theme) => void;
1001
+ };
1002
+ declare function ThemeProvider({ children, defaultTheme, theme: controlledTheme, primaryColor, // Indigo 500 default
1003
+ storageKey, scoped, className, style, ...props }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
1004
+ declare const useTheme: () => ThemeProviderState;
1005
+
1006
+ export { AntVChartLoader, type AntVRendererOptions, type BaseChartProps, type BasicRenderersOptions, COMMON_PROPS, type ChartAxisConfig, type ChartComponent, type ChartLabelConfig, type ChartLegendConfig, type ChartProps, type ChartStrategy, type ColumnChartProps, DefaultEmptyPlaceholder, DefaultErrorPlaceholder, type DualAxesChartProps, type DualAxesChildConfig, type ExtendedRenderersOptions, type FunnelChartProps, type LineChartProps, type PieChartProps, type Theme, ThemeProvider, type XCMLBaseComponent, type XCMLBaseProps, XCMLCardWrapper, XCMLChart, type XCMLComponentSchema, type XCMLContext, XCMLEventBus, XCMLMarkdown, type XCMLPlugin, type XCMLPropertyCategory, type XCMLPropertyDefinition, type XCMLPropertyType, type XCMLProps, type XCMLRenderer, XCML_SCHEMAS, buildConfig, chartSchema, cleanPropsBySchema, columnChartSchema, columnStrategy, createAntVRenderers, createBasicRenderers, createExtendedRenderers, createRenderersWithAliases, deepMerge, dualAxesChartSchema, dualAxesStrategy, extractBaseStyles, funnelChartSchema, funnelStrategy, getChartStrategy, getTheme, lineChartSchema, lineStrategy, mergePropsAndBody, normalizeNodeData, normalizeTagName, parseArrayProp, parseInlineData, parseXCML, pieChartSchema, pieStrategy, preprocessXCML, renderXCML, strategies, stringifyToXCML, themeDark, themeLight, themeMap, toXCMLNodeFromElement, toXCMLTag, toXTag, useTheme, useXCMLComponent, useXCMLNode, validateDataSchema, validateXCMLNode, withXCMLCard, xcmlBus };