@ant-design/agentic-ui 2.0.5 → 2.0.8

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.
@@ -598,7 +598,7 @@ var SlateMarkdownEditor = (props) => {
598
598
  };
599
599
  const elementRenderElement = useCallback(
600
600
  (eleProps) => {
601
- var _a2, _b2, _c2, _d2;
601
+ var _a2, _b2, _c2, _d2, _e;
602
602
  const defaultDom = /* @__PURE__ */ React.createElement(
603
603
  ErrorBoundary,
604
604
  {
@@ -638,7 +638,8 @@ var SlateMarkdownEditor = (props) => {
638
638
  LazyElement,
639
639
  {
640
640
  placeholderHeight: (_c2 = props.lazy) == null ? void 0 : _c2.placeholderHeight,
641
- rootMargin: (_d2 = props.lazy) == null ? void 0 : _d2.rootMargin
641
+ rootMargin: (_d2 = props.lazy) == null ? void 0 : _d2.rootMargin,
642
+ renderPlaceholder: (_e = props.lazy) == null ? void 0 : _e.renderPlaceholder
642
643
  },
643
644
  renderedDom
644
645
  );
@@ -11,6 +11,24 @@ export interface LazyElementProps {
11
11
  rootMargin?: string;
12
12
  /** 占位符样式 */
13
13
  placeholderStyle?: React.CSSProperties;
14
+ /** 自定义占位符渲染函数 */
15
+ renderPlaceholder?: (props: {
16
+ /** 占位符高度 */
17
+ height: number;
18
+ /** 占位符样式 */
19
+ style: React.CSSProperties;
20
+ /** 元素是否即将进入视口 */
21
+ isIntersecting: boolean;
22
+ /** 元素在文档中的位置信息 */
23
+ elementInfo?: {
24
+ /** 元素类型 */
25
+ type: string;
26
+ /** 元素在文档中的索引 */
27
+ index: number;
28
+ /** 元素总数量 */
29
+ total: number;
30
+ };
31
+ }) => React.ReactNode;
14
32
  }
15
33
  /**
16
34
  * LazyElement 组件 - 懒加载元素包裹器
@@ -26,12 +44,26 @@ export interface LazyElementProps {
26
44
  * @param {number} [props.placeholderHeight=100] - 占位符高度
27
45
  * @param {string} [props.rootMargin='200px'] - 提前加载的距离
28
46
  * @param {React.CSSProperties} [props.placeholderStyle] - 自定义占位符样式
47
+ * @param {Function} [props.renderPlaceholder] - 自定义占位符渲染函数
29
48
  *
30
49
  * @example
31
50
  * ```tsx
51
+ * // 基本使用
32
52
  * <LazyElement placeholderHeight={150} rootMargin="300px">
33
53
  * <div>这是需要懒加载的内容</div>
34
54
  * </LazyElement>
55
+ *
56
+ * // 自定义占位符渲染
57
+ * <LazyElement
58
+ * placeholderHeight={150}
59
+ * renderPlaceholder={({ height, style, isIntersecting }) => (
60
+ * <div style={style}>
61
+ * <div>加载中... {isIntersecting ? '(即将显示)' : ''}</div>
62
+ * </div>
63
+ * )}
64
+ * >
65
+ * <div>这是需要懒加载的内容</div>
66
+ * </LazyElement>
35
67
  * ```
36
68
  *
37
69
  * @returns {React.ReactElement} 渲染的懒加载元素
@@ -21,11 +21,13 @@ var LazyElement = ({
21
21
  children,
22
22
  placeholderHeight = 25,
23
23
  rootMargin = "200px",
24
- placeholderStyle
24
+ placeholderStyle,
25
+ renderPlaceholder
25
26
  }) => {
26
27
  const containerRef = useRef(null);
27
28
  const [isVisible, setIsVisible] = useState(false);
28
29
  const [hasRendered, setHasRendered] = useState(false);
30
+ const [isIntersecting, setIsIntersecting] = useState(false);
29
31
  useEffect(() => {
30
32
  const container = containerRef.current;
31
33
  if (!container)
@@ -33,6 +35,7 @@ var LazyElement = ({
33
35
  const observer = new IntersectionObserver(
34
36
  (entries) => {
35
37
  entries.forEach((entry) => {
38
+ setIsIntersecting(entry.isIntersecting);
36
39
  if (entry.isIntersecting) {
37
40
  setIsVisible(true);
38
41
  setHasRendered(true);
@@ -53,13 +56,21 @@ var LazyElement = ({
53
56
  if (hasRendered || isVisible) {
54
57
  return /* @__PURE__ */ React.createElement("div", { ref: containerRef }, children);
55
58
  }
59
+ const computedPlaceholderStyle = __spreadValues({
60
+ minHeight: placeholderHeight
61
+ }, placeholderStyle);
62
+ if (renderPlaceholder) {
63
+ return /* @__PURE__ */ React.createElement("div", { ref: containerRef, "aria-hidden": "true" }, renderPlaceholder({
64
+ height: placeholderHeight,
65
+ style: computedPlaceholderStyle,
66
+ isIntersecting
67
+ }));
68
+ }
56
69
  return /* @__PURE__ */ React.createElement(
57
70
  "div",
58
71
  {
59
72
  ref: containerRef,
60
- style: __spreadValues({
61
- minHeight: placeholderHeight
62
- }, placeholderStyle),
73
+ style: computedPlaceholderStyle,
63
74
  "aria-hidden": "true"
64
75
  }
65
76
  );
@@ -147,11 +147,24 @@ export type MarkdownEditorProps = {
147
147
  *
148
148
  * @example
149
149
  * ```tsx
150
+ * // 基本懒加载配置
150
151
  * lazy={{
151
152
  * enable: true,
152
153
  * placeholderHeight: 100,
153
154
  * rootMargin: '200px'
154
155
  * }}
156
+ *
157
+ * // 自定义占位符渲染
158
+ * lazy={{
159
+ * enable: true,
160
+ * placeholderHeight: 120,
161
+ * rootMargin: '300px',
162
+ * renderPlaceholder: ({ height, style, isIntersecting }) => (
163
+ * <div style={style}>
164
+ * <div>加载中... {isIntersecting ? '(即将显示)' : ''}</div>
165
+ * </div>
166
+ * )
167
+ * }}
155
168
  * ```
156
169
  */
157
170
  lazy?: {
@@ -168,6 +181,27 @@ export type MarkdownEditorProps = {
168
181
  * 支持所有 IntersectionObserver rootMargin 的值
169
182
  */
170
183
  rootMargin?: string;
184
+ /**
185
+ * 自定义占位符渲染函数
186
+ * 允许开发者自定义懒加载时的占位符显示内容
187
+ */
188
+ renderPlaceholder?: (props: {
189
+ /** 占位符高度 */
190
+ height: number;
191
+ /** 占位符样式 */
192
+ style: React.CSSProperties;
193
+ /** 元素是否即将进入视口 */
194
+ isIntersecting: boolean;
195
+ /** 元素在文档中的位置信息 */
196
+ elementInfo?: {
197
+ /** 元素类型 */
198
+ type: string;
199
+ /** 元素在文档中的索引 */
200
+ index: number;
201
+ /** 元素总数量 */
202
+ total: number;
203
+ };
204
+ }) => React.ReactNode;
171
205
  };
172
206
  /**
173
207
  * 样式
@@ -285,7 +285,11 @@ var MarkdownInputField = (_a) => {
285
285
  onMouseEnter: () => setHover(true),
286
286
  onMouseLeave: () => setHover(false),
287
287
  onKeyDown: (e) => {
288
+ var _a3;
288
289
  const { triggerSendKey = "Enter" } = props;
290
+ if ((_a3 = markdownEditorRef == null ? void 0 : markdownEditorRef.current) == null ? void 0 : _a3.store.inputComposition) {
291
+ return;
292
+ }
289
293
  if (triggerSendKey === "Enter" && e.key === "Enter" && !(e.ctrlKey || e.metaKey)) {
290
294
  e.stopPropagation();
291
295
  e.preventDefault();
@@ -72,7 +72,7 @@ var SendActions = ({
72
72
  var _a;
73
73
  (_a = attachment == null ? void 0 : attachment.onFileMapChange) == null ? void 0 : _a.call(attachment, fileMap2);
74
74
  },
75
- disabled: !fileUploadDone
75
+ disabled: !fileUploadDone || (attachment == null ? void 0 : attachment.disabled)
76
76
  })
77
77
  ) : null,
78
78
  voiceRecognizer ? /* @__PURE__ */ React.createElement(
@@ -2,26 +2,94 @@ import React from 'react';
2
2
  import { ChartContainerProps } from '../components';
3
3
  import { StatisticConfigType } from '../hooks/useChartStatistic';
4
4
  import { ChartDataItem } from '../utils';
5
+ /**
6
+ * 面积图数据项类型
7
+ *
8
+ * 继承自 ChartDataItem,用于面积图的数据表示。
9
+ *
10
+ * @typedef {ChartDataItem} AreaChartDataItem
11
+ * @since 1.0.0
12
+ */
5
13
  export type AreaChartDataItem = ChartDataItem;
14
+ /**
15
+ * 面积图配置项接口
16
+ *
17
+ * 定义了面积图的配置选项,包括数据集、主题、图例、网格等设置。
18
+ *
19
+ * @interface AreaChartConfigItem
20
+ * @since 1.0.0
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const config: AreaChartConfigItem = {
25
+ * datasets: [data1, data2],
26
+ * theme: 'light',
27
+ * showLegend: true,
28
+ * legendPosition: 'top',
29
+ * showGrid: true,
30
+ * xAxisLabel: '时间',
31
+ * yAxisLabel: '数值'
32
+ * };
33
+ * ```
34
+ */
6
35
  export interface AreaChartConfigItem {
36
+ /** 数据集数组 */
7
37
  datasets: Array<(string | {
8
38
  x: number;
9
39
  y: number;
10
40
  })[]>;
41
+ /** 图表主题 */
11
42
  theme?: 'light' | 'dark';
43
+ /** 是否显示图例 */
12
44
  showLegend?: boolean;
45
+ /** 图例位置 */
13
46
  legendPosition?: 'top' | 'left' | 'bottom' | 'right';
47
+ /** 图例水平对齐方式 */
14
48
  legendAlign?: 'start' | 'center' | 'end';
49
+ /** 是否显示网格线 */
15
50
  showGrid?: boolean;
51
+ /** X轴标签 */
16
52
  xAxisLabel?: string;
53
+ /** Y轴标签 */
17
54
  yAxisLabel?: string;
55
+ /** X轴最小值 */
18
56
  xAxisMin?: number;
57
+ /** X轴最大值 */
19
58
  xAxisMax?: number;
59
+ /** Y轴最小值 */
20
60
  yAxisMin?: number;
61
+ /** Y轴最大值 */
21
62
  yAxisMax?: number;
63
+ /** X轴步长 */
22
64
  xAxisStep?: number;
65
+ /** Y轴步长 */
23
66
  yAxisStep?: number;
24
67
  }
68
+ /**
69
+ * 面积图组件属性接口
70
+ *
71
+ * 定义了面积图组件的所有属性,继承自 ChartContainerProps。
72
+ * 支持数据配置、样式设置、交互功能等。
73
+ *
74
+ * @interface AreaChartProps
75
+ * @extends ChartContainerProps
76
+ * @since 1.0.0
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const props: AreaChartProps = {
81
+ * title: '销售趋势',
82
+ * data: [
83
+ * { x: '2024-01', y: 100, type: '产品A' },
84
+ * { x: '2024-02', y: 150, type: '产品A' }
85
+ * ],
86
+ * width: 800,
87
+ * height: 400,
88
+ * showLegend: true,
89
+ * showGrid: true
90
+ * };
91
+ * ```
92
+ */
25
93
  export interface AreaChartProps extends ChartContainerProps {
26
94
  /** 图表标题 */
27
95
  title?: string;
@@ -62,5 +130,32 @@ export interface AreaChartProps extends ChartContainerProps {
62
130
  /** ChartStatistic组件配置:object表示单个配置,array表示多个配置 */
63
131
  statistic?: StatisticConfigType;
64
132
  }
133
+ /**
134
+ * 面积图组件
135
+ *
136
+ * 基于 Chart.js 和 react-chartjs-2 实现的面积图组件。
137
+ * 支持数据可视化、交互、配置、统计等功能。
138
+ *
139
+ * @component
140
+ * @param {AreaChartProps} props - 组件属性
141
+ * @returns {React.ReactElement} 面积图组件
142
+ *
143
+ * @example
144
+ * ```tsx
145
+ * <AreaChart
146
+ * title="销售趋势"
147
+ * data={[
148
+ * { x: '2024-01', y: 100, type: '产品A' },
149
+ * { x: '2024-02', y: 150, type: '产品A' }
150
+ * ]}
151
+ * width={800}
152
+ * height={400}
153
+ * showLegend={true}
154
+ * showGrid={true}
155
+ * />
156
+ * ```
157
+ *
158
+ * @since 1.0.0
159
+ */
65
160
  declare const AreaChart: React.FC<AreaChartProps>;
66
161
  export default AreaChart;
@@ -57,15 +57,25 @@ ChartJS.register(
57
57
  );
58
58
  var defaultColors = [
59
59
  "#1677ff",
60
+ // 蓝色
60
61
  "#8954FC",
62
+ // 紫色
61
63
  "#15e7e4",
64
+ // 青色
62
65
  "#F45BB5",
66
+ // 粉色
63
67
  "#00A6FF",
68
+ // 天蓝色
64
69
  "#33E59B",
70
+ // 绿色
65
71
  "#D666E4",
72
+ // 紫红色
66
73
  "#6151FF",
74
+ // 靛蓝色
67
75
  "#BF3C93",
76
+ // 深粉色
68
77
  "#005EE0"
78
+ // 深蓝色
69
79
  ];
70
80
  var hexToRgba = (hex, alpha) => {
71
81
  const sanitized = hex.replace("#", "");
@@ -3,26 +3,73 @@ import React from 'react';
3
3
  import { ChartContainerProps } from '../components';
4
4
  import { StatisticConfigType } from '../hooks/useChartStatistic';
5
5
  import { ChartDataItem } from '../utils';
6
+ /**
7
+ * 柱状图数据项类型
8
+ *
9
+ * 继承自 ChartDataItem,用于柱状图的数据表示。
10
+ *
11
+ * @typedef {ChartDataItem} BarChartDataItem
12
+ * @since 1.0.0
13
+ */
6
14
  export type BarChartDataItem = ChartDataItem;
15
+ /**
16
+ * 柱状图配置项接口
17
+ *
18
+ * 定义了柱状图的配置选项,包括数据集、主题、图例、网格等设置。
19
+ *
20
+ * @interface BarChartConfigItem
21
+ * @since 1.0.0
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const config: BarChartConfigItem = {
26
+ * datasets: [data1, data2],
27
+ * theme: 'light',
28
+ * showLegend: true,
29
+ * legendPosition: 'top',
30
+ * showGrid: true,
31
+ * xAxisLabel: '类别',
32
+ * yAxisLabel: '数值',
33
+ * stacked: false,
34
+ * indexAxis: 'x'
35
+ * };
36
+ * ```
37
+ */
7
38
  export interface BarChartConfigItem {
39
+ /** 数据集数组 */
8
40
  datasets: Array<(string | {
9
41
  x: number;
10
42
  y: number;
11
43
  })[]>;
44
+ /** 图表主题 */
12
45
  theme?: 'light' | 'dark';
46
+ /** 是否显示图例 */
13
47
  showLegend?: boolean;
48
+ /** 图例位置 */
14
49
  legendPosition?: 'top' | 'left' | 'bottom' | 'right';
50
+ /** 图例水平对齐方式 */
15
51
  legendAlign?: 'start' | 'center' | 'end';
52
+ /** 是否显示网格线 */
16
53
  showGrid?: boolean;
54
+ /** X轴标签 */
17
55
  xAxisLabel?: string;
56
+ /** Y轴标签 */
18
57
  yAxisLabel?: string;
58
+ /** X轴最小值 */
19
59
  xAxisMin?: number;
60
+ /** X轴最大值 */
20
61
  xAxisMax?: number;
62
+ /** Y轴最小值 */
21
63
  yAxisMin?: number;
64
+ /** Y轴最大值 */
22
65
  yAxisMax?: number;
66
+ /** X轴步长 */
23
67
  xAxisStep?: number;
68
+ /** Y轴步长 */
24
69
  yAxisStep?: number;
70
+ /** 是否堆叠显示 */
25
71
  stacked?: boolean;
72
+ /** 索引轴方向 */
26
73
  indexAxis?: 'x' | 'y';
27
74
  }
28
75
  export interface BarChartProps extends ChartContainerProps {
@@ -1,5 +1,33 @@
1
1
  import React from 'react';
2
2
  import type { DonutChartProps } from './types';
3
3
  export type { DonutChartConfig, DonutChartData, DonutChartProps, } from './types';
4
+ /**
5
+ * 环形图组件
6
+ *
7
+ * 基于 Chart.js 和 react-chartjs-2 实现的环形图(甜甜圈图)组件。
8
+ * 支持饼图和环形图两种样式,提供数据可视化、交互、配置、统计等功能。
9
+ *
10
+ * @component
11
+ * @param {DonutChartProps} props - 组件属性
12
+ * @returns {React.ReactElement} 环形图组件
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * <DonutChart
17
+ * title="销售占比"
18
+ * data={[
19
+ * { label: '产品A', value: 30 },
20
+ * { label: '产品B', value: 50 },
21
+ * { label: '产品C', value: 20 }
22
+ * ]}
23
+ * configs={[{ chartStyle: 'donut', showLegend: true }]}
24
+ * width={400}
25
+ * height={400}
26
+ * showToolbar={true}
27
+ * />
28
+ * ```
29
+ *
30
+ * @since 1.0.0
31
+ */
4
32
  declare const DonutChart: React.FC<DonutChartProps>;
5
33
  export default DonutChart;
@@ -1,12 +1,70 @@
1
1
  import { default as React } from 'react';
2
+ /**
3
+ * @fileoverview 图表工具栏组件文件
4
+ *
5
+ * 该文件提供了图表工具栏组件的实现,用于显示图表标题、数据时间、下载按钮等。
6
+ *
7
+ * @author md-editor
8
+ * @version 1.0.0
9
+ * @since 2024
10
+ */
11
+ /**
12
+ * 图表工具栏属性接口
13
+ *
14
+ * 定义了图表工具栏组件的所有属性。
15
+ *
16
+ * @interface ChartToolBarProps
17
+ * @since 1.0.0
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const props: ChartToolBarProps = {
22
+ * title: '销售数据',
23
+ * dataTime: '2024-01-01 00:00:00',
24
+ * theme: 'light',
25
+ * onDownload: () => console.log('下载图表'),
26
+ * extra: <Button>自定义按钮</Button>
27
+ * };
28
+ * ```
29
+ */
2
30
  export interface ChartToolBarProps {
31
+ /** 图表标题 */
3
32
  title?: string;
33
+ /** 数据时间 */
4
34
  dataTime?: string;
35
+ /** 自定义CSS类名 */
5
36
  className?: string;
37
+ /** 图表主题 */
6
38
  theme?: 'light' | 'dark';
39
+ /** 下载回调函数 */
7
40
  onDownload?: () => void;
41
+ /** 额外内容 */
8
42
  extra?: React.ReactNode;
43
+ /** 过滤器内容 */
9
44
  filter?: React.ReactNode;
10
45
  }
46
+ /**
47
+ * 图表工具栏组件
48
+ *
49
+ * 用于显示图表标题、数据时间、下载按钮等工具栏内容。
50
+ * 支持主题切换、自定义内容、下载功能等。
51
+ *
52
+ * @component
53
+ * @param {ChartToolBarProps} props - 组件属性
54
+ * @returns {React.ReactElement | null} 图表工具栏组件,当没有标题和额外内容时返回 null
55
+ *
56
+ * @example
57
+ * ```tsx
58
+ * <ChartToolBar
59
+ * title="销售数据"
60
+ * dataTime="2024-01-01 00:00:00"
61
+ * theme="light"
62
+ * onDownload={() => console.log('下载图表')}
63
+ * extra={<Button>自定义按钮</Button>}
64
+ * />
65
+ * ```
66
+ *
67
+ * @since 1.0.0
68
+ */
11
69
  declare const ChartToolBar: React.FC<ChartToolBarProps>;
12
70
  export default ChartToolBar;
@@ -1 +1,26 @@
1
+ /**
2
+ * @fileoverview 图表插件常量定义文件
3
+ *
4
+ * 该文件定义了图表插件中使用的各种常量,包括默认颜色列表等。
5
+ *
6
+ * @author md-editor
7
+ * @version 1.0.0
8
+ * @since 2024
9
+ */
10
+ /**
11
+ * 默认颜色列表
12
+ *
13
+ * 用于图表数据系列的颜色配置,提供10种预定义的颜色。
14
+ * 这些颜色经过精心挑选,确保在图表中具有良好的视觉效果和对比度。
15
+ *
16
+ * @constant
17
+ * @type {string[]}
18
+ * @default
19
+ * @example
20
+ * // 使用默认颜色列表
21
+ * const colors = defaultColorList;
22
+ * console.log(colors[0]); // '#1677ff'
23
+ *
24
+ * @since 1.0.0
25
+ */
1
26
  export declare const defaultColorList: string[];
@@ -1,15 +1,25 @@
1
1
  // src/plugins/chart/const.ts
2
2
  var defaultColorList = [
3
3
  "#1677ff",
4
+ // 蓝色
4
5
  "#15e7e4",
6
+ // 青色
5
7
  "#8954FC",
8
+ // 紫色
6
9
  "#F45BB5",
10
+ // 粉色
7
11
  "#00A6FF",
12
+ // 天蓝色
8
13
  "#33E59B",
14
+ // 绿色
9
15
  "#D666E4",
16
+ // 紫红色
10
17
  "#6151FF",
18
+ // 靛蓝色
11
19
  "#BF3C93",
20
+ // 深粉色
12
21
  "#005EE0"
22
+ // 深蓝色
13
23
  ];
14
24
  export {
15
25
  defaultColorList
@@ -1,5 +1,19 @@
1
1
  import React from 'react';
2
2
  import { RenderElementProps } from 'slate-react';
3
+ /**
4
+ * @fileoverview 图表插件主入口文件
5
+ *
6
+ * 该文件提供了完整的图表功能,包括:
7
+ * - 多种图表类型的组件(饼图、柱状图、折线图、面积图等)
8
+ * - 图表渲染和配置功能
9
+ * - 数据处理和格式化工具
10
+ * - 图表属性工具栏
11
+ * - 图表标记和容器组件
12
+ *
13
+ * @author md-editor
14
+ * @version 1.0.0
15
+ * @since 2024
16
+ */
3
17
  export { ChartAttrToolBar } from './ChartAttrToolBar';
4
18
  export * from './ChartMark';
5
19
  export { ChartRender } from './ChartRender';
@@ -7,6 +7,38 @@
7
7
  * 如果输入值为空或格式化过程中发生错误,则返回原始值。
8
8
  */
9
9
  export declare const stringFormatNumber: (value: string | number) => string | number;
10
+ /**
11
+ * 防抖函数
12
+ *
13
+ * 创建一个防抖函数,该函数会在调用后等待指定的延迟时间,
14
+ * 如果在延迟时间内再次调用,则重新开始计时。
15
+ * 常用于限制函数调用频率,如搜索输入、窗口调整等场景。
16
+ *
17
+ * @param {Function} func - 要防抖的函数
18
+ * @param {number} delay - 延迟时间(毫秒)
19
+ * @returns {Function} 防抖后的函数,包含以下方法:
20
+ * - `flush()`: 立即执行函数并清除定时器
21
+ * - `cancel()`: 取消延迟执行
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const debouncedSearch = debounce((query: string) => {
26
+ * console.log('搜索:', query);
27
+ * }, 300);
28
+ *
29
+ * // 调用防抖函数
30
+ * debouncedSearch('hello');
31
+ * debouncedSearch('world'); // 只有这个会执行
32
+ *
33
+ * // 立即执行
34
+ * debouncedSearch.flush();
35
+ *
36
+ * // 取消执行
37
+ * debouncedSearch.cancel();
38
+ * ```
39
+ *
40
+ * @since 1.0.0
41
+ */
10
42
  export declare function debounce(func: {
11
43
  (): void;
12
44
  apply?: any;
@@ -16,68 +48,201 @@ export declare function debounce(func: {
16
48
  cancel(): void;
17
49
  };
18
50
  /**
19
- * 数据项接口,用于图表数据处理
51
+ * 图表数据项接口
52
+ *
53
+ * 定义了图表中单个数据项的结构,用于统一各种图表类型的数据格式。
54
+ * 支持多种图表类型的数据表示,包括分类、类型、坐标等信息。
55
+ *
56
+ * @interface ChartDataItem
57
+ * @since 1.0.0
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const dataItem: ChartDataItem = {
62
+ * x: '2024-01',
63
+ * y: 100,
64
+ * category: '销售',
65
+ * type: '产品A',
66
+ * xtitle: '月份',
67
+ * ytitle: '销售额',
68
+ * filterLabel: 'Q1'
69
+ * };
70
+ * ```
20
71
  */
21
72
  export interface ChartDataItem {
22
- /** 数据类别 */
73
+ /** 数据类别,用于数据分组和筛选 */
23
74
  category?: string;
24
- /** 数据类型 */
75
+ /** 数据类型,用于区分不同的数据系列 */
25
76
  type?: string;
26
- /** X轴值 */
77
+ /** X轴值,可以是数字或字符串 */
27
78
  x: number | string;
28
- /** Y轴值 */
79
+ /** Y轴值,可以是数字或字符串 */
29
80
  y: number | string;
30
- /** X轴标题 */
81
+ /** X轴标题,用于显示轴标签 */
31
82
  xtitle?: string;
32
- /** Y轴标题 */
83
+ /** Y轴标题,用于显示轴标签 */
33
84
  ytitle?: string;
34
- /** 筛选标签 */
85
+ /** 筛选标签,用于数据筛选和过滤 */
35
86
  filterLabel?: string;
36
87
  }
37
88
  /**
38
- * 归一化 x 轴值,将字符串数字转换为数字,避免重复标签
39
- * @param value - 原始 x 轴值
40
- * @returns 归一化后的值
89
+ * 归一化 X 轴值
90
+ *
91
+ * 将字符串数字转换为数字类型,避免重复标签问题。
92
+ * 如果输入已经是数字,直接返回;如果是字符串,尝试转换为数字。
93
+ * 转换失败时返回原始值。
94
+ *
95
+ * @param {number | string} value - 原始 X 轴值
96
+ * @returns {number | string} 归一化后的值
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * normalizeXValue(123); // 123
101
+ * normalizeXValue('456'); // 456
102
+ * normalizeXValue('abc'); // 'abc'
103
+ * normalizeXValue(''); // ''
104
+ * ```
105
+ *
106
+ * @since 1.0.0
41
107
  */
42
108
  export declare const normalizeXValue: (value: number | string) => number | string;
43
109
  /**
44
- * 比较两个 x 轴值的大小,用于排序
45
- * @param a - 第一个值
46
- * @param b - 第二个值
47
- * @returns 比较结果
110
+ * 比较两个 X 轴值的大小
111
+ *
112
+ * 用于对 X 轴值进行排序,支持数字和字符串的混合比较。
113
+ * 比较规则:
114
+ * 1. 数字优先于字符串
115
+ * 2. 数字按数值大小比较
116
+ * 3. 字符串按字典序比较
117
+ *
118
+ * @param {number | string} a - 第一个值
119
+ * @param {number | string} b - 第二个值
120
+ * @returns {number} 比较结果:负数表示 a < b,0 表示 a = b,正数表示 a > b
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * compareXValues(1, 2); // -1
125
+ * compareXValues('a', 'b'); // -1
126
+ * compareXValues(1, 'a'); // -1 (数字优先)
127
+ * compareXValues('a', 1); // 1 (数字优先)
128
+ * ```
129
+ *
130
+ * @since 1.0.0
48
131
  */
49
132
  export declare const compareXValues: (a: number | string, b: number | string) => number;
50
133
  /**
51
- * 检查两个 x 轴值是否相等
52
- * @param a - 第一个值
53
- * @param b - 第二个值
54
- * @returns 是否相等
134
+ * 检查两个 X 轴值是否相等
135
+ *
136
+ * 比较两个 X 轴值是否相等,支持数字和字符串的混合比较。
137
+ * 先对值进行归一化处理,然后进行比较。
138
+ *
139
+ * @param {number | string} a - 第一个值
140
+ * @param {number | string} b - 第二个值
141
+ * @returns {boolean} 是否相等
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * isXValueEqual(1, 1); // true
146
+ * isXValueEqual('1', 1); // true
147
+ * isXValueEqual('a', 'a'); // true
148
+ * isXValueEqual(1, 2); // false
149
+ * ```
150
+ *
151
+ * @since 1.0.0
55
152
  */
56
153
  export declare const isXValueEqual: (a: number | string, b: number | string) => boolean;
57
154
  /**
58
- * 从数据中提取并排序 x 轴值
59
- * @param data - 图表数据数组
60
- * @returns 排序后的唯一 x 轴值数组
155
+ * 从数据中提取并排序 X 轴值
156
+ *
157
+ * 从图表数据数组中提取所有唯一的 X 轴值,并进行排序。
158
+ * 先对值进行归一化处理,然后去重并排序。
159
+ *
160
+ * @param {ChartDataItem[]} data - 图表数据数组
161
+ * @returns {Array<number | string>} 排序后的唯一 X 轴值数组
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * const data = [
166
+ * { x: '2024-01', y: 100 },
167
+ * { x: '2024-02', y: 200 },
168
+ * { x: '2024-01', y: 150 }, // 重复值
169
+ * { x: 3, y: 300 }
170
+ * ];
171
+ * const sortedValues = extractAndSortXValues(data);
172
+ * // ['2024-01', '2024-02', 3]
173
+ * ```
174
+ *
175
+ * @since 1.0.0
61
176
  */
62
177
  export declare const extractAndSortXValues: (data: ChartDataItem[]) => Array<number | string>;
63
178
  /**
64
- * 根据 x 轴值查找对应的数据点
65
- * @param data - 数据数组
66
- * @param type - 数据类型
67
- * @param xValue - x 轴值
68
- * @returns 匹配的数据点,如果未找到返回 undefined
179
+ * 根据 X 轴值查找对应的数据点
180
+ *
181
+ * 在数据数组中查找指定 X 轴值对应的数据点。
182
+ * 可以指定数据类型进行精确匹配。
183
+ *
184
+ * @param {ChartDataItem[]} data - 数据数组
185
+ * @param {number | string} xValue - X 轴值
186
+ * @param {string} [type] - 数据类型,可选
187
+ * @returns {ChartDataItem | undefined} 匹配的数据点,如果未找到返回 undefined
188
+ *
189
+ * @example
190
+ * ```typescript
191
+ * const data = [
192
+ * { x: '2024-01', y: 100, type: 'A' },
193
+ * { x: '2024-01', y: 200, type: 'B' },
194
+ * { x: '2024-02', y: 300, type: 'A' }
195
+ * ];
196
+ *
197
+ * // 查找所有类型
198
+ * findDataPointByXValue(data, '2024-01'); // 第一个匹配项
199
+ *
200
+ * // 查找指定类型
201
+ * findDataPointByXValue(data, '2024-01', 'B'); // { x: '2024-01', y: 200, type: 'B' }
202
+ * ```
203
+ *
204
+ * @since 1.0.0
69
205
  */
70
206
  export declare const findDataPointByXValue: (data: ChartDataItem[], xValue: number | string, type?: string) => ChartDataItem | undefined;
71
207
  /**
72
208
  * 将值转换为数字
73
- * @param val - 要转换的值
74
- * @param fallback - 转换失败时的默认值
75
- * @returns 转换后的数字
209
+ *
210
+ * 安全地将任意值转换为数字类型,转换失败时返回默认值。
211
+ * 如果输入已经是有效的数字,直接返回;否则尝试转换。
212
+ *
213
+ * @param {any} val - 要转换的值
214
+ * @param {number} fallback - 转换失败时的默认值
215
+ * @returns {number} 转换后的数字
216
+ *
217
+ * @example
218
+ * ```typescript
219
+ * toNumber('123', 0); // 123
220
+ * toNumber(456, 0); // 456
221
+ * toNumber('abc', 0); // 0
222
+ * toNumber(null, 100); // 100
223
+ * ```
224
+ *
225
+ * @since 1.0.0
76
226
  */
77
227
  export declare const toNumber: (val: any, fallback: number) => number;
78
228
  /**
79
229
  * 检查值是否不为空
80
- * @param val - 要检查的值
81
- * @returns 是否不为空
230
+ *
231
+ * 检查值是否不为 null 和 undefined。
232
+ * 用于数据验证和条件判断。
233
+ *
234
+ * @param {any} val - 要检查的值
235
+ * @returns {boolean} 是否不为空
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * isNotEmpty('hello'); // true
240
+ * isNotEmpty(0); // true
241
+ * isNotEmpty(''); // true
242
+ * isNotEmpty(null); // false
243
+ * isNotEmpty(undefined); // false
244
+ * ```
245
+ *
246
+ * @since 1.0.0
82
247
  */
83
248
  export declare const isNotEmpty: (val: any) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.0.5",
3
+ "version": "2.0.8",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",