@chatbi-v/xcml 2.0.1 → 2.1.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/dist/index.d.cts CHANGED
@@ -397,6 +397,58 @@ declare function toXCMLNodeFromElement(name: string, attrs: Record<string, any>,
397
397
  */
398
398
  declare function preprocessXCML(md: string, knownTags?: string[]): string;
399
399
 
400
+ interface XTagPluginOptions {
401
+ /**
402
+ * 允许的标签名称列表,不包含前缀 'x-'
403
+ * @default ['chart', 'table', 'metric', 'list', 'card', 'toc']
404
+ */
405
+ tags?: string[];
406
+ }
407
+ /**
408
+ * 插件工厂:返回 marked 扩展/引擎插件(兼容 @ant-design/x-markdown)
409
+ */
410
+ declare function xTagPlugin(options?: XTagPluginOptions): {
411
+ level: string;
412
+ name: string;
413
+ start(src: string): number;
414
+ /**
415
+ * tokenizer:将 <x-*> 片段转为自定义 Token
416
+ */
417
+ tokenizer(src: string): {
418
+ type: string;
419
+ raw: string;
420
+ name: string;
421
+ attrs: Record<string, any>;
422
+ body: string;
423
+ } | undefined;
424
+ /**
425
+ * renderer:不返回原始 HTML,转为受控节点
426
+ */
427
+ renderer(token: any): {
428
+ type: string;
429
+ props: any;
430
+ body: any;
431
+ };
432
+ };
433
+
434
+ interface XCMLLayoutContextValue {
435
+ /**
436
+ * 容器宽度(像素)
437
+ */
438
+ containerWidth: number;
439
+ }
440
+ /**
441
+ * XCML 布局上下文 Provider
442
+ * 负责监听容器尺寸变化并下发给子组件
443
+ */
444
+ declare const XCMLLayoutProvider: React$1.FC<{
445
+ children: React$1.ReactNode;
446
+ }>;
447
+ /**
448
+ * 获取 XCML 布局信息的 Hook
449
+ */
450
+ declare const useXCMLLayout: () => XCMLLayoutContextValue;
451
+
400
452
  interface XCMLProps {
401
453
  content?: string;
402
454
  stream?: AsyncIterable<string>;
@@ -414,6 +466,14 @@ interface XCMLProps {
414
466
  * 主题配置,用于 Mermaid 等图表
415
467
  */
416
468
  theme?: string;
469
+ /**
470
+ * 内容变更回调
471
+ */
472
+ onContentChange?: (content: string) => void;
473
+ /**
474
+ * 组件渲染状态变更回调
475
+ */
476
+ onComponentRender?: (tag: string, status: 'loading' | 'success' | 'error') => void;
417
477
  }
418
478
  /**
419
479
  * XCML 核心渲染组件 (XCMLMarkdown)
@@ -999,8 +1059,8 @@ type ThemeProviderState = {
999
1059
  theme: Theme;
1000
1060
  setTheme: (theme: Theme) => void;
1001
1061
  };
1002
- declare function ThemeProvider({ children, defaultTheme, theme: controlledTheme, primaryColor, // Indigo 500 default
1062
+ declare function ThemeProvider({ children, defaultTheme, theme: controlledTheme, primaryColor, // Orange 600 (Sunset)
1003
1063
  storageKey, scoped, className, style, ...props }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
1004
1064
  declare const useTheme: () => ThemeProviderState;
1005
1065
 
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 };
1066
+ 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, XCMLLayoutProvider, XCMLMarkdown, type XCMLPlugin, type XCMLPropertyCategory, type XCMLPropertyDefinition, type XCMLPropertyType, type XCMLProps, type XCMLRenderer, XCML_SCHEMAS, type XTagPluginOptions, 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, useXCMLLayout, useXCMLNode, validateDataSchema, validateXCMLNode, withXCMLCard, xTagPlugin, xcmlBus };
package/dist/index.d.ts CHANGED
@@ -397,6 +397,58 @@ declare function toXCMLNodeFromElement(name: string, attrs: Record<string, any>,
397
397
  */
398
398
  declare function preprocessXCML(md: string, knownTags?: string[]): string;
399
399
 
400
+ interface XTagPluginOptions {
401
+ /**
402
+ * 允许的标签名称列表,不包含前缀 'x-'
403
+ * @default ['chart', 'table', 'metric', 'list', 'card', 'toc']
404
+ */
405
+ tags?: string[];
406
+ }
407
+ /**
408
+ * 插件工厂:返回 marked 扩展/引擎插件(兼容 @ant-design/x-markdown)
409
+ */
410
+ declare function xTagPlugin(options?: XTagPluginOptions): {
411
+ level: string;
412
+ name: string;
413
+ start(src: string): number;
414
+ /**
415
+ * tokenizer:将 <x-*> 片段转为自定义 Token
416
+ */
417
+ tokenizer(src: string): {
418
+ type: string;
419
+ raw: string;
420
+ name: string;
421
+ attrs: Record<string, any>;
422
+ body: string;
423
+ } | undefined;
424
+ /**
425
+ * renderer:不返回原始 HTML,转为受控节点
426
+ */
427
+ renderer(token: any): {
428
+ type: string;
429
+ props: any;
430
+ body: any;
431
+ };
432
+ };
433
+
434
+ interface XCMLLayoutContextValue {
435
+ /**
436
+ * 容器宽度(像素)
437
+ */
438
+ containerWidth: number;
439
+ }
440
+ /**
441
+ * XCML 布局上下文 Provider
442
+ * 负责监听容器尺寸变化并下发给子组件
443
+ */
444
+ declare const XCMLLayoutProvider: React$1.FC<{
445
+ children: React$1.ReactNode;
446
+ }>;
447
+ /**
448
+ * 获取 XCML 布局信息的 Hook
449
+ */
450
+ declare const useXCMLLayout: () => XCMLLayoutContextValue;
451
+
400
452
  interface XCMLProps {
401
453
  content?: string;
402
454
  stream?: AsyncIterable<string>;
@@ -414,6 +466,14 @@ interface XCMLProps {
414
466
  * 主题配置,用于 Mermaid 等图表
415
467
  */
416
468
  theme?: string;
469
+ /**
470
+ * 内容变更回调
471
+ */
472
+ onContentChange?: (content: string) => void;
473
+ /**
474
+ * 组件渲染状态变更回调
475
+ */
476
+ onComponentRender?: (tag: string, status: 'loading' | 'success' | 'error') => void;
417
477
  }
418
478
  /**
419
479
  * XCML 核心渲染组件 (XCMLMarkdown)
@@ -999,8 +1059,8 @@ type ThemeProviderState = {
999
1059
  theme: Theme;
1000
1060
  setTheme: (theme: Theme) => void;
1001
1061
  };
1002
- declare function ThemeProvider({ children, defaultTheme, theme: controlledTheme, primaryColor, // Indigo 500 default
1062
+ declare function ThemeProvider({ children, defaultTheme, theme: controlledTheme, primaryColor, // Orange 600 (Sunset)
1003
1063
  storageKey, scoped, className, style, ...props }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
1004
1064
  declare const useTheme: () => ThemeProviderState;
1005
1065
 
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 };
1066
+ 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, XCMLLayoutProvider, XCMLMarkdown, type XCMLPlugin, type XCMLPropertyCategory, type XCMLPropertyDefinition, type XCMLPropertyType, type XCMLProps, type XCMLRenderer, XCML_SCHEMAS, type XTagPluginOptions, 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, useXCMLLayout, useXCMLNode, validateDataSchema, validateXCMLNode, withXCMLCard, xTagPlugin, xcmlBus };