@ant-design/agentic-ui 2.29.3 → 2.29.4

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.
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- export type RobotStatus = 'default' | 'thinking' | 'dazing' | 'pause';
3
- export interface RobotProps {
2
+ type RobotStatus = 'default' | 'thinking' | 'dazing' | 'pause';
3
+ interface RobotProps {
4
4
  /** 机器人状态 */
5
5
  status?: RobotStatus;
6
6
  /** 机器人大小 */
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ export * from './Robot';
2
3
  /**
3
4
  * 任务状态枚举
4
5
  * @enum {string}
@@ -20,6 +20,7 @@ import { I18nContext } from "../I18n";
20
20
  import { PauseIcon, PlayIcon, SimplePauseIcon, SimplePlayIcon, SimpleStopIcon, StopIcon } from "./icons";
21
21
  import Robot from "./Robot";
22
22
  import { useStyle } from "./style";
23
+ export * from "./Robot";
23
24
  /**
24
25
  * 任务状态枚举
25
26
  * @enum {string}
@@ -111,7 +111,8 @@ function _unsupported_iterable_to_array(o, minLen) {
111
111
  import { Editor, Node, Path, Range, Transforms } from "slate";
112
112
  import { ReactEditor } from "slate-react";
113
113
  export var inlineNode = new Set([
114
- 'break'
114
+ 'break',
115
+ 'inline-katex'
115
116
  ]);
116
117
  var voidNode = new Set([
117
118
  'hr',
@@ -139,8 +139,17 @@ var genStyle = function(token) {
139
139
  '[data-hidden]': {
140
140
  display: 'none'
141
141
  },
142
- // KaTeX容器样式
142
+ // KaTeX容器样式和公式样式修复
143
+ // 确保 white-space: nowrap 不被父元素的 pre-wrap 覆盖
144
+ // KaTeX 库生成的元素需要 nowrap 来防止公式堆叠
145
+ '.katex': {
146
+ whiteSpace: 'nowrap !important'
147
+ },
143
148
  '.katex-container': {
149
+ whiteSpace: 'nowrap !important',
150
+ '& *': {
151
+ whiteSpace: 'nowrap !important'
152
+ },
144
153
  '.newline': {
145
154
  margin: '4px 0'
146
155
  }
@@ -195,7 +195,7 @@ import { useVoiceInputManager } from "./VoiceInputManager";
195
195
  var _props_style, _props_attachment, _props_enlargeable, _props_refinePrompt, _props_enlargeable1, _props_enlargeable2;
196
196
  var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
197
197
  var baseCls = getPrefixCls('agentic-md-input-field');
198
- var _useStyle = useStyle(baseCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
198
+ var _useStyle = useStyle(baseCls, props.disableHoverAnimation), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
199
199
  // 状态管理
200
200
  var _useMarkdownInputFieldState = useMarkdownInputFieldState({
201
201
  value: props.value,
@@ -175,6 +175,7 @@ function _ts_generator(thisArg, body) {
175
175
  }
176
176
  }
177
177
  import React from "react";
178
+ import { Editor, Transforms } from "slate";
178
179
  import { useRefFunction } from "../../Hooks/useRefFunction";
179
180
  import { upLoadFileToServer } from "../AttachmentButton";
180
181
  import { isMobileDevice } from "../AttachmentButton/utils";
@@ -323,11 +324,38 @@ import { getFileListFromDataTransferItems } from "../FilePaste";
323
324
  }());
324
325
  // 键盘事件:早返回减少嵌套
325
326
  var handleKeyDown = useRefFunction(function(e) {
326
- var _markdownEditorRef_current;
327
+ var _markdownEditorRef_current, _markdownEditorRef_current_markdownEditorRef, _markdownEditorRef_current1;
327
328
  if (markdownEditorRef === null || markdownEditorRef === void 0 ? void 0 : (_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.store.inputComposition) return;
329
+ var editor = markdownEditorRef === null || markdownEditorRef === void 0 ? void 0 : (_markdownEditorRef_current1 = markdownEditorRef.current) === null || _markdownEditorRef_current1 === void 0 ? void 0 : (_markdownEditorRef_current_markdownEditorRef = _markdownEditorRef_current1.markdownEditorRef) === null || _markdownEditorRef_current_markdownEditorRef === void 0 ? void 0 : _markdownEditorRef_current_markdownEditorRef.current;
328
330
  var isEnter = e.key === 'Enter';
329
331
  var isMod = e.ctrlKey || e.metaKey;
330
332
  var isShift = e.shiftKey;
333
+ // 处理 Home 键:移动到文档开头
334
+ if (e.key === 'Home' && !isMod && editor) {
335
+ e.preventDefault();
336
+ e.stopPropagation();
337
+ var start = Editor.start(editor, []);
338
+ Transforms.select(editor, start);
339
+ return;
340
+ }
341
+ // 处理 End 键:移动到文档末尾
342
+ if (e.key === 'End' && !isMod && editor) {
343
+ e.preventDefault();
344
+ e.stopPropagation();
345
+ var end = Editor.end(editor, []);
346
+ Transforms.select(editor, end);
347
+ return;
348
+ }
349
+ // 处理 Ctrl+A / Cmd+A:全选
350
+ if ((e.key === 'a' || e.key === 'A') && isMod && !isShift && editor) {
351
+ e.preventDefault();
352
+ e.stopPropagation();
353
+ Transforms.select(editor, {
354
+ anchor: Editor.start(editor, []),
355
+ focus: Editor.end(editor, [])
356
+ });
357
+ return;
358
+ }
331
359
  // 手机端禁用 Enter 键发送
332
360
  if (isEnter && !isMod && !isShift && isMobileDevice()) {
333
361
  return; // 让编辑器正常处理换行
@@ -3,9 +3,10 @@ export declare const addGlowBorderOffset: (size: string | number) => string;
3
3
  /**
4
4
  * Probubble
5
5
  * @param prefixCls
6
+ * @param disableHoverAnimation 是否禁用 hover 动画
6
7
  * @returns
7
8
  */
8
- export declare function useStyle(prefixCls?: string): {
9
+ export declare function useStyle(prefixCls?: string, disableHoverAnimation?: boolean): {
9
10
  wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
10
11
  hashId: string;
11
12
  };
@@ -104,8 +104,13 @@ var stopIconRotate = new Keyframes('stopIconRotate', {
104
104
  }
105
105
  });
106
106
  var genStyle = function(token) {
107
+ var hoverStyle = token.disableHoverAnimation ? {} : {
108
+ '&:hover': {
109
+ boxShadow: '0px 0px 1px 0px rgba(10, 48, 104, 0.25), 0px 2px 7px 0px rgba(10, 48, 104, 0.05), 0px 2px 5px -2px rgba(10, 48, 104, 0.06)'
110
+ }
111
+ };
107
112
  var _obj, _obj1;
108
- return _obj1 = {}, _define_property(_obj1, token.componentCls, {
113
+ return _obj1 = {}, _define_property(_obj1, token.componentCls, _object_spread_props(_object_spread({
109
114
  width: '100%',
110
115
  height: '100%',
111
116
  display: 'flex',
@@ -125,10 +130,8 @@ var genStyle = function(token) {
125
130
  outline: '1px solid transparent',
126
131
  outlineColor: 'var(--mif-active-outline-color, transparent)'
127
132
  },
128
- boxShadow: '0px 0px 1px 0px rgba(10, 48, 104, 0.15), 0px 1.5px 4px -1px rgba(10, 48, 104, 0.04)',
129
- '&:hover': {
130
- boxShadow: '0px 0px 1px 0px rgba(10, 48, 104, 0.25), 0px 2px 7px 0px rgba(10, 48, 104, 0.05), 0px 2px 5px -2px rgba(10, 48, 104, 0.06)'
131
- },
133
+ boxShadow: '0px 0px 1px 0px rgba(10, 48, 104, 0.15), 0px 1.5px 4px -1px rgba(10, 48, 104, 0.04)'
134
+ }, hoverStyle), {
132
135
  '&-focused': {
133
136
  boxShadow: '0px 0px 1px 0px rgba(10, 48, 104, 0.25), 0px 2px 7px 0px rgba(10, 48, 104, 0.05), 0px 2px 5px -2px rgba(10, 48, 104, 0.06)'
134
137
  },
@@ -281,7 +284,7 @@ var genStyle = function(token) {
281
284
  animationTimingFunction: 'linear',
282
285
  animationIterationCount: 'infinite'
283
286
  }
284
- }), _define_property(_obj1, "".concat(token.componentCls, "-before-tools"), {
287
+ })), _define_property(_obj1, "".concat(token.componentCls, "-before-tools"), {
285
288
  display: 'flex',
286
289
  gap: 8,
287
290
  width: '100%',
@@ -304,11 +307,13 @@ var genStyle = function(token) {
304
307
  /**
305
308
  * Probubble
306
309
  * @param prefixCls
310
+ * @param disableHoverAnimation 是否禁用 hover 动画
307
311
  * @returns
308
- */ export function useStyle(prefixCls) {
312
+ */ export function useStyle(prefixCls, disableHoverAnimation) {
309
313
  return useEditorStyleRegister('MarkdownInputField', function(token) {
310
314
  var proChatToken = _object_spread_props(_object_spread({}, token), {
311
- componentCls: ".".concat(prefixCls)
315
+ componentCls: ".".concat(prefixCls),
316
+ disableHoverAnimation: disableHoverAnimation
312
317
  });
313
318
  return [
314
319
  resetComponent(proChatToken),
@@ -421,4 +421,14 @@ export type MarkdownInputFieldProps = {
421
421
  * @description 自定义发送按钮的样式和行为
422
422
  */
423
423
  sendButtonProps?: SendButtonCustomizationProps;
424
+ /**
425
+ * 是否禁用 hover 动画
426
+ * @description 控制是否在鼠标悬停时显示阴影动画效果
427
+ * @default false
428
+ * @example
429
+ * ```tsx
430
+ * <MarkdownInputField disableHoverAnimation={true} />
431
+ * ```
432
+ */
433
+ disableHoverAnimation?: boolean;
424
434
  };
@@ -82,7 +82,7 @@ import { Line } from "react-chartjs-2";
82
82
  import { ChartContainer, ChartFilter, ChartStatistic, ChartToolBar, downloadChart } from "../components";
83
83
  import { defaultColorList } from "../const";
84
84
  import { useChartDataFilter, useChartStatistics, useChartTheme, useResponsiveSize } from "../hooks";
85
- import { extractAndSortXValues, findDataPointByXValue, hexToRgba, registerLineChartComponents } from "../utils";
85
+ import { extractAndSortXValues, findDataPointByXValue, hexToRgba, registerLineChartComponents, resolveCssVariable } from "../utils";
86
86
  import { useStyle } from "./style";
87
87
  /**
88
88
  * 面积图组件
@@ -166,6 +166,8 @@ import { useStyle } from "./style";
166
166
  var datasets = types.map(function(type, index) {
167
167
  var provided = color;
168
168
  var baseColor = Array.isArray(provided) ? provided[index % provided.length] || defaultColorList[index % defaultColorList.length] : provided || defaultColorList[index % defaultColorList.length];
169
+ // 解析 CSS 变量为实际颜色值(Canvas 需要实际颜色值)
170
+ var resolvedColor = resolveCssVariable(baseColor);
169
171
  // 为每个类型收集数据点
170
172
  var typeData = xValues.map(function(x) {
171
173
  var dataPoint = findDataPointByXValue(filteredData, x, type);
@@ -176,19 +178,20 @@ import { useStyle } from "./style";
176
178
  return {
177
179
  label: type || '默认',
178
180
  data: typeData,
179
- borderColor: baseColor,
181
+ borderColor: resolvedColor,
180
182
  backgroundColor: function(ctx) {
181
183
  var chart = ctx.chart;
182
184
  var chartArea = chart.chartArea;
183
- if (!chartArea) return hexToRgba(baseColor, 0.2);
185
+ // 对于所有颜色(包括解析后的 CSS 变量),使用渐变效果
186
+ if (!chartArea) return hexToRgba(resolvedColor, 0.2);
184
187
  var top = chartArea.top, bottom = chartArea.bottom;
185
188
  var gradient = chart.ctx.createLinearGradient(0, top, 0, bottom);
186
189
  // 顶部颜色更实,向下逐渐透明,形成柔和的面积过渡
187
- gradient.addColorStop(0, hexToRgba(baseColor, 0.28));
188
- gradient.addColorStop(1, hexToRgba(baseColor, 0.05));
190
+ gradient.addColorStop(0, hexToRgba(resolvedColor, 0.28));
191
+ gradient.addColorStop(1, hexToRgba(resolvedColor, 0.05));
189
192
  return gradient;
190
193
  },
191
- pointBackgroundColor: baseColor,
194
+ pointBackgroundColor: resolvedColor,
192
195
  pointBorderColor: '#fff',
193
196
  pointBorderWidth: 1,
194
197
  borderWidth: 3,
@@ -203,7 +206,8 @@ import { useStyle } from "./style";
203
206
  }, [
204
207
  filteredData,
205
208
  types,
206
- xValues
209
+ xValues,
210
+ color
207
211
  ]);
208
212
  var options = {
209
213
  responsive: true,
@@ -120,7 +120,7 @@ import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
120
120
  import { Bar } from "react-chartjs-2";
121
121
  import { ChartContainer, ChartFilter, ChartStatistic, ChartToolBar, downloadChart } from "../components";
122
122
  import { defaultColorList } from "../const";
123
- import { extractAndSortXValues, findDataPointByXValue, hexToRgba } from "../utils";
123
+ import { extractAndSortXValues, findDataPointByXValue, hexToRgba, resolveCssVariable } from "../utils";
124
124
  import { useStyle } from "./style";
125
125
  /**
126
126
  * @fileoverview 柱状图组件文件
@@ -183,7 +183,7 @@ var BarChart = function(param) {
183
183
  // 从数据中提取唯一的类别作为筛选选项
184
184
  var categories = useMemo(function() {
185
185
  var uniqueCategories = _to_consumable_array(new Set(safeData.map(function(item) {
186
- return item.category;
186
+ return item === null || item === void 0 ? void 0 : item.category;
187
187
  }))).filter(Boolean);
188
188
  return uniqueCategories;
189
189
  }, [
@@ -192,7 +192,7 @@ var BarChart = function(param) {
192
192
  // 从数据中提取 filterLabel,过滤掉 undefined 值
193
193
  var validFilterLabels = useMemo(function() {
194
194
  return safeData.map(function(item) {
195
- return item.filterLabel;
195
+ return item === null || item === void 0 ? void 0 : item.filterLabel;
196
196
  }).filter(function(filterLabel) {
197
197
  return filterLabel !== undefined;
198
198
  });
@@ -225,9 +225,9 @@ var BarChart = function(param) {
225
225
  var withFilterLabel = !filterLabels || !selectedFilterLabel ? base : base.filter(function(item) {
226
226
  return item.filterLabel === selectedFilterLabel;
227
227
  });
228
- // 最终统一过滤掉 x 为空(null/undefined)的数据,避免后续 toString 报错
228
+ // 最终统一过滤掉 x 为空(null/undefined/空字符串)的数据,避免后续 toString 报错
229
229
  return withFilterLabel.filter(function(item) {
230
- return item.x !== null && item.x !== undefined;
230
+ return item.x !== null && item.x !== undefined && item.x !== '' && String(item.x).trim() !== '';
231
231
  });
232
232
  }, [
233
233
  safeData,
@@ -250,7 +250,7 @@ var BarChart = function(param) {
250
250
  var uniqueValues = _to_consumable_array(new Set(filteredData.map(function(item) {
251
251
  return item.x;
252
252
  }).filter(function(x) {
253
- return x !== null && x !== undefined;
253
+ return x !== null && x !== undefined && x !== '' && String(x).trim() !== '';
254
254
  })));
255
255
  return uniqueValues;
256
256
  }
@@ -305,6 +305,13 @@ var BarChart = function(param) {
305
305
  return Array.isArray(provided) ? provided[i] || provided[0] || defaultColorList[i % defaultColorList.length] : provided || defaultColorList[i % defaultColorList.length];
306
306
  };
307
307
  var baseColor = pickByIndex(index);
308
+ // 解析 CSS 变量为实际颜色值(Canvas 需要实际颜色值)
309
+ var resolvedBaseColor = resolveCssVariable(baseColor);
310
+ var resolvedProvidedColors = Array.isArray(provided) ? provided.map(function(c) {
311
+ return resolveCssVariable(c);
312
+ }) : provided ? [
313
+ resolveCssVariable(provided)
314
+ ] : null;
308
315
  // 为每个类型收集数据点
309
316
  var typeData = xValues.map(function(x) {
310
317
  var dataPoint = findDataPointByXValue(filteredData, x, type);
@@ -318,12 +325,12 @@ var BarChart = function(param) {
318
325
  borderColor: function(ctx) {
319
326
  var parsed = ctx.parsed;
320
327
  var value = indexAxis === 'y' ? typeof (parsed === null || parsed === void 0 ? void 0 : parsed.x) === 'number' ? parsed.x : 0 : typeof (parsed === null || parsed === void 0 ? void 0 : parsed.y) === 'number' ? parsed.y : 0;
321
- var base = baseColor;
328
+ var base = resolvedBaseColor;
322
329
  if (!color && isDiverging) {
323
330
  base = value >= 0 ? POSITIVE_COLOR_HEX : NEGATIVE_COLOR_HEX;
324
- } else if (Array.isArray(color) && isDiverging) {
325
- var pos = color[0] || baseColor;
326
- var neg = color[1] || color[0] || baseColor;
331
+ } else if (resolvedProvidedColors && isDiverging) {
332
+ var pos = resolvedProvidedColors[0] || resolvedBaseColor;
333
+ var neg = resolvedProvidedColors[1] || resolvedProvidedColors[0] || resolvedBaseColor;
327
334
  base = value >= 0 ? pos : neg;
328
335
  }
329
336
  return hexToRgba(base, 0.95);
@@ -332,23 +339,23 @@ var BarChart = function(param) {
332
339
  var chart = ctx.chart;
333
340
  var chartArea = chart.chartArea;
334
341
  var parsed = ctx.parsed;
335
- if (!chartArea) return hexToRgba(baseColor, 0.6);
342
+ if (!chartArea) return hexToRgba(resolvedBaseColor, 0.6);
336
343
  var xScale = chart.scales['x'];
337
344
  var yScale = chart.scales['y'];
338
345
  var startAlpha = 0.65;
339
346
  var endAlpha = 0.95;
340
347
  // 安全检查:确保坐标轴已正确初始化
341
348
  if (!xScale || !yScale || typeof xScale.getPixelForValue !== 'function' || typeof yScale.getPixelForValue !== 'function') {
342
- return hexToRgba(baseColor, 0.6);
349
+ return hexToRgba(resolvedBaseColor, 0.6);
343
350
  }
344
351
  if (indexAxis === 'y') {
345
352
  var value = typeof (parsed === null || parsed === void 0 ? void 0 : parsed.x) === 'number' ? parsed.x : 0;
346
- var base = baseColor;
353
+ var base = resolvedBaseColor;
347
354
  if (!color && isDiverging) {
348
355
  base = value >= 0 ? POSITIVE_COLOR_HEX : NEGATIVE_COLOR_HEX;
349
- } else if (Array.isArray(color) && isDiverging) {
350
- var pos = color[0] || baseColor;
351
- var neg = color[1] || color[0] || baseColor;
356
+ } else if (resolvedProvidedColors && isDiverging) {
357
+ var pos = resolvedProvidedColors[0] || resolvedBaseColor;
358
+ var neg = resolvedProvidedColors[1] || resolvedProvidedColors[0] || resolvedBaseColor;
352
359
  base = value >= 0 ? pos : neg;
353
360
  }
354
361
  // 当值为 0 时,直接返回纯色,避免渐变范围为 0 导致的显示问题
@@ -369,12 +376,12 @@ var BarChart = function(param) {
369
376
  return gradient;
370
377
  }
371
378
  var value1 = typeof (parsed === null || parsed === void 0 ? void 0 : parsed.y) === 'number' ? parsed.y : 0;
372
- var base1 = baseColor;
379
+ var base1 = resolvedBaseColor;
373
380
  if (!color && isDiverging) {
374
381
  base1 = value1 >= 0 ? POSITIVE_COLOR_HEX : NEGATIVE_COLOR_HEX;
375
- } else if (Array.isArray(color) && isDiverging) {
376
- var pos1 = color[0] || baseColor;
377
- var neg1 = color[1] || color[0] || baseColor;
382
+ } else if (resolvedProvidedColors && isDiverging) {
383
+ var pos1 = resolvedProvidedColors[0] || resolvedBaseColor;
384
+ var neg1 = resolvedProvidedColors[1] || resolvedProvidedColors[0] || resolvedBaseColor;
378
385
  base1 = value1 >= 0 ? pos1 : neg1;
379
386
  }
380
387
  // 当值为 0 时,直接返回纯色,避免渐变范围为 0 导致的显示问题
@@ -511,12 +518,17 @@ var BarChart = function(param) {
511
518
  var calculateLabelWidth = function(text) {
512
519
  var fontSize = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 11;
513
520
  // 创建临时canvas来测量文本宽度
514
- var canvas = document.createElement('canvas');
515
- var context = canvas.getContext('2d');
516
- if (!context) return text.length * fontSize * 0.6; // 备用估算
517
- context.font = "".concat(fontSize, "px Arial, sans-serif");
518
- var metrics = context.measureText(text);
519
- return metrics.width;
521
+ try {
522
+ var canvas = document.createElement('canvas');
523
+ var context = canvas.getContext('2d');
524
+ if (!context) return text.length * fontSize * 0.6; // 备用估算
525
+ context.font = "".concat(fontSize, "px Arial, sans-serif");
526
+ var metrics = context.measureText(text);
527
+ return metrics.width;
528
+ } catch (e) {
529
+ // 在测试环境或无法使用 canvas 时使用备用估算
530
+ return text.length * fontSize * 0.6;
531
+ }
520
532
  };
521
533
  // 计算所需的最大标签宽度
522
534
  var calculateMaxLabelWidth = useMemo(function() {
@@ -142,6 +142,7 @@ import React, { useContext, useMemo, useRef, useState } from "react";
142
142
  import { Doughnut } from "react-chartjs-2";
143
143
  import { ChartContainer, ChartFilter, ChartStatistic, ChartToolBar, downloadChart } from "../components";
144
144
  import { defaultColorList } from "../const";
145
+ import { resolveCssVariable } from "../utils";
145
146
  import { SINGLE_MODE_DESKTOP_CUTOUT, SINGLE_MODE_MOBILE_CUTOUT } from "./constants";
146
147
  import { useAutoCategory, useFilterLabels, useMobile, useResponsiveDimensions } from "./hooks";
147
148
  import LegendView from "./Legend";
@@ -471,25 +472,30 @@ import { useStyle } from "./style";
471
472
  return sum + (Number.isFinite(v) ? v : 0);
472
473
  }, 0);
473
474
  var backgroundColors = cfg.backgroundColor || defaultColorList;
475
+ // 解析 CSS 变量为实际颜色值(Canvas 需要实际颜色值)
476
+ var resolvedBackgroundColors = backgroundColors.map(function(color) {
477
+ return resolveCssVariable(color);
478
+ });
474
479
  var _cfg_backgroundColor_;
475
480
  var mainColor = (_cfg_backgroundColor_ = (_cfg_backgroundColor = cfg.backgroundColor) === null || _cfg_backgroundColor === void 0 ? void 0 : _cfg_backgroundColor[0]) !== null && _cfg_backgroundColor_ !== void 0 ? _cfg_backgroundColor_ : defaultColorList[idx % defaultColorList.length];
481
+ var resolvedMainColor = resolveCssVariable(mainColor);
476
482
  var chartJsData = {
477
483
  labels: labels,
478
484
  datasets: [
479
485
  {
480
486
  data: safeValues,
481
487
  backgroundColor: isSingleValueMode ? [
482
- mainColor,
488
+ resolvedMainColor,
483
489
  'transparent'
484
- ] : backgroundColors.slice(0, values.length),
490
+ ] : resolvedBackgroundColors.slice(0, values.length),
485
491
  borderColor: isSingleValueMode ? [
486
492
  cfg.borderColor || '#fff',
487
493
  'transparent'
488
494
  ] : cfg.borderColor || '#fff',
489
495
  hoverBackgroundColor: isSingleValueMode ? [
490
- mainColor,
496
+ resolvedMainColor,
491
497
  'transparent'
492
- ] : backgroundColors.slice(0, values.length),
498
+ ] : resolvedBackgroundColors.slice(0, values.length),
493
499
  hoverBorderColor: isSingleValueMode ? [
494
500
  cfg.borderColor || '#fff',
495
501
  'transparent'
@@ -143,7 +143,7 @@ import { Bar } from "react-chartjs-2";
143
143
  import ChartStatistic from "../ChartStatistic";
144
144
  import { ChartContainer, ChartFilter, ChartToolBar, downloadChart } from "../components";
145
145
  import { defaultColorList } from "../const";
146
- import { findDataPointByXValue, isXValueEqual, toNumber } from "../utils";
146
+ import { findDataPointByXValue, isXValueEqual, resolveCssVariable, toNumber } from "../utils";
147
147
  import { useStyle } from "./style";
148
148
  var funnelChartComponentsRegistered = false;
149
149
  var FunnelChart = function(_param) {
@@ -329,6 +329,8 @@ var FunnelChart = function(_param) {
329
329
  // 计算数据:使用浮动条 [-w/2, w/2] 居中呈现,形成对称“漏斗条”
330
330
  var processedData = useMemo(function() {
331
331
  var baseColor = color || defaultColorList[0];
332
+ // 解析 CSS 变量为实际颜色值(Canvas 需要实际颜色值)
333
+ var resolvedBaseColor = resolveCssVariable(baseColor);
332
334
  var labels = stages.map(function(x) {
333
335
  return x.toString();
334
336
  });
@@ -397,7 +399,7 @@ var FunnelChart = function(_param) {
397
399
  var count = Math.max(1, stages.length - 1);
398
400
  var colorList = stages.map(function(_, i) {
399
401
  var t = i / count * 0.6; // 限制变浅上限,避免变白
400
- return lighten(baseColor, t);
402
+ return lighten(resolvedBaseColor, t);
401
403
  });
402
404
  return {
403
405
  labels: labels,
@@ -109,7 +109,7 @@ import { Line } from "react-chartjs-2";
109
109
  import { ChartContainer, ChartFilter, ChartStatistic, ChartToolBar, downloadChart } from "../components";
110
110
  import { defaultColorList } from "../const";
111
111
  import { useChartDataFilter, useChartStatistics, useChartTheme, useResponsiveSize } from "../hooks";
112
- import { extractAndSortXValues, findDataPointByXValue, registerLineChartComponents } from "../utils";
112
+ import { extractAndSortXValues, findDataPointByXValue, hexToRgba, registerLineChartComponents, resolveCssVariable } from "../utils";
113
113
  import { useStyle } from "./style";
114
114
  var LineChart = function(_param) {
115
115
  var title = _param.title, data = _param.data, _param_width = _param.width, width = _param_width === void 0 ? 600 : _param_width, _param_height = _param.height, height = _param_height === void 0 ? 400 : _param_height, className = _param.className, classNamesProp = _param.classNames, dataTime = _param.dataTime, _param_theme = _param.theme, theme = _param_theme === void 0 ? 'light' : _param_theme, color = _param.color, _param_showLegend = _param.showLegend, showLegend = _param_showLegend === void 0 ? true : _param_showLegend, _param_legendPosition = _param.legendPosition, legendPosition = _param_legendPosition === void 0 ? 'bottom' : _param_legendPosition, _param_legendAlign = _param.legendAlign, legendAlign = _param_legendAlign === void 0 ? 'start' : _param_legendAlign, _param_showGrid = _param.showGrid, showGrid = _param_showGrid === void 0 ? true : _param_showGrid, _param_xPosition = _param.xPosition, xPosition = _param_xPosition === void 0 ? 'bottom' : _param_xPosition, _param_yPosition = _param.yPosition, yPosition = _param_yPosition === void 0 ? 'left' : _param_yPosition, _param_hiddenX = _param.hiddenX, hiddenX = _param_hiddenX === void 0 ? false : _param_hiddenX, _param_hiddenY = _param.hiddenY, hiddenY = _param_hiddenY === void 0 ? false : _param_hiddenY, toolbarExtra = _param.toolbarExtra, _param_renderFilterInToolbar = _param.renderFilterInToolbar, renderFilterInToolbar = _param_renderFilterInToolbar === void 0 ? false : _param_renderFilterInToolbar, statisticConfig = _param.statistic, _param_loading = _param.loading, loading = _param_loading === void 0 ? false : _param_loading, props = _object_without_properties(_param, [
@@ -190,6 +190,8 @@ var LineChart = function(_param) {
190
190
  var datasets = types.map(function(type, index) {
191
191
  var provided = color;
192
192
  var baseColor = Array.isArray(provided) ? provided[index % provided.length] || defaultColorList[index % defaultColorList.length] : provided || defaultColorList[index % defaultColorList.length];
193
+ // 解析 CSS 变量为实际颜色值(Canvas 需要实际颜色值)
194
+ var resolvedColor = resolveCssVariable(baseColor);
193
195
  // 为每个类型收集数据点
194
196
  var typeData = xValues.map(function(x) {
195
197
  var dataPoint = findDataPointByXValue(filteredData, x, type);
@@ -200,9 +202,9 @@ var LineChart = function(_param) {
200
202
  return {
201
203
  label: type || '默认',
202
204
  data: typeData,
203
- borderColor: baseColor,
204
- backgroundColor: "".concat(baseColor, "33"),
205
- pointBackgroundColor: baseColor,
205
+ borderColor: resolvedColor,
206
+ backgroundColor: hexToRgba(resolvedColor, 0.2),
207
+ pointBackgroundColor: resolvedColor,
206
208
  pointBorderColor: '#fff',
207
209
  pointBorderWidth: 1,
208
210
  borderWidth: 3,
@@ -217,7 +219,8 @@ var LineChart = function(_param) {
217
219
  }, [
218
220
  filteredData,
219
221
  types,
220
- xValues
222
+ xValues,
223
+ color
221
224
  ]);
222
225
  var options = {
223
226
  responsive: true,
@@ -386,7 +389,7 @@ var LineChart = function(_param) {
386
389
  }, config), {
387
390
  theme: theme
388
391
  }));
389
- })), /*#__PURE__*/ React.createElement(ChartFilter, _object_spread_props(_object_spread({
392
+ })), !renderFilterInToolbar && filterOptions && filterOptions.length > 1 && /*#__PURE__*/ React.createElement(ChartFilter, _object_spread_props(_object_spread({
390
393
  filterOptions: filterOptions,
391
394
  selectedFilter: selectedFilter,
392
395
  onFilterChange: setSelectedFilter
@@ -135,6 +135,7 @@ import { Radar } from "react-chartjs-2";
135
135
  import ChartStatistic from "../ChartStatistic";
136
136
  import { ChartContainer, ChartFilter, ChartToolBar, downloadChart } from "../components";
137
137
  import { defaultColorList } from "../const";
138
+ import { hexToRgba, resolveCssVariable } from "../utils";
138
139
  import { useStyle } from "./style";
139
140
  var radarChartComponentsRegistered = false;
140
141
  var RadarChart = function(_param) {
@@ -319,13 +320,15 @@ var RadarChart = function(_param) {
319
320
  var safeIndex = Math.max(0, index % defaultColorList.length);
320
321
  var safeDefaultColor = defaultColorList[safeIndex] || '#1677ff';
321
322
  var finalColor = baseColor || safeDefaultColor;
323
+ // 解析 CSS 变量为实际颜色值(Canvas 需要实际颜色值)
324
+ var resolvedColor = resolveCssVariable(finalColor);
322
325
  return {
323
326
  label: type || '默认',
324
327
  data: scores,
325
- borderColor: finalColor,
326
- backgroundColor: "".concat(finalColor, "20"),
328
+ borderColor: resolvedColor,
329
+ backgroundColor: hexToRgba(resolvedColor, 0.125),
327
330
  borderWidth: isMobile ? 1.5 : 2,
328
- pointBackgroundColor: finalColor,
331
+ pointBackgroundColor: resolvedColor,
329
332
  pointBorderColor: '#fff',
330
333
  pointBorderWidth: isMobile ? 1 : 2,
331
334
  pointRadius: isMobile ? 3 : 4,
@@ -135,6 +135,7 @@ import { Scatter } from "react-chartjs-2";
135
135
  import ChartStatistic from "../ChartStatistic";
136
136
  import { ChartContainer, ChartFilter, ChartToolBar, downloadChart } from "../components";
137
137
  import { defaultColorList } from "../const";
138
+ import { hexToRgba, resolveCssVariable } from "../utils";
138
139
  import { useStyle } from "./style";
139
140
  var scatterChartComponentsRegistered = false;
140
141
  var ScatterChart = function(_param) {
@@ -337,11 +338,13 @@ var ScatterChart = function(_param) {
337
338
  var safeIndex = Math.max(0, index % defaultColorList.length);
338
339
  var safeDefaultColor = defaultColorList[safeIndex] || '#1677ff';
339
340
  var finalColor = baseColor || safeDefaultColor;
341
+ // 解析 CSS 变量为实际颜色值(Canvas 需要实际颜色值)
342
+ var resolvedColor = resolveCssVariable(finalColor);
340
343
  return {
341
344
  label: type || '默认',
342
345
  data: coordinates,
343
- backgroundColor: "".concat(finalColor, "99"),
344
- borderColor: finalColor,
346
+ backgroundColor: hexToRgba(resolvedColor, 0.6),
347
+ borderColor: resolvedColor,
345
348
  pointRadius: isMobile ? 4 : 6,
346
349
  pointHoverRadius: isMobile ? 6 : 8
347
350
  };
@@ -287,11 +287,26 @@ export declare const getDataHash: (data: any[]) => string;
287
287
  */
288
288
  export declare const isConfigEqual: (config1: any, config2: any) => boolean;
289
289
  /**
290
- * 将十六进制颜色转换为带透明度的 RGBA 字符串
290
+ * 从浏览器 DOM 中解析 CSS 变量的实际颜色值
291
291
  *
292
- * 支持3位和6位十六进制颜色格式,并添加透明度。
292
+ * @param {string} cssVar - CSS 变量表达式(如 'var(--color-blue)')
293
+ * @returns {string} 解析后的颜色值(如 '#1d7afc')或原值
293
294
  *
294
- * @param {string} hex - 十六进制颜色值(如 '#ff0000' 或 '#f00')
295
+ * @example
296
+ * ```typescript
297
+ * resolveCssVariable('var(--color-blue-control-fill-primary)'); // '#1d7afc'
298
+ * resolveCssVariable('#ff0000'); // '#ff0000'
299
+ * ```
300
+ *
301
+ * @since 1.0.0
302
+ */
303
+ export declare const resolveCssVariable: (cssVar: string) => string;
304
+ /**
305
+ * 将十六进制颜色或CSS变量转换为带透明度的 RGBA 字符串
306
+ *
307
+ * 支持3位和6位十六进制颜色格式、CSS变量(如 var(--color-name)),并添加透明度。
308
+ *
309
+ * @param {string} color - 颜色值(如 '#ff0000'、'#f00' 或 'var(--color-blue)')
295
310
  * @param {number} alpha - 透明度值(0-1之间)
296
311
  * @returns {string} RGBA 颜色字符串
297
312
  *
@@ -299,9 +314,10 @@ export declare const isConfigEqual: (config1: any, config2: any) => boolean;
299
314
  * ```typescript
300
315
  * hexToRgba('#ff0000', 0.5); // 'rgba(255, 0, 0, 0.5)'
301
316
  * hexToRgba('#f00', 0.8); // 'rgba(255, 0, 0, 0.8)'
317
+ * hexToRgba('var(--color-blue)', 0.5); // 'rgba(29, 122, 252, 0.5)'
302
318
  * ```
303
319
  *
304
320
  * @since 1.0.0
305
321
  */
306
- export declare const hexToRgba: (hex: string, alpha: number) => string;
322
+ export declare const hexToRgba: (color: string, alpha: number) => string;
307
323
  export { registerBarChartComponents, registerChartComponents, registerLineChartComponents, } from './utils/registerChart';
@@ -231,9 +231,13 @@ var intl = new Intl.NumberFormat('en-US', {
231
231
  *
232
232
  * @since 1.0.0
233
233
  */ export var extractAndSortXValues = function(data) {
234
- // 提取所有 x 值并归一化
234
+ // 提取所有 x 值并归一化,同时过滤掉空值(null/undefined/空字符串)
235
235
  var normalizedValues = data.map(function(item) {
236
- return normalizeXValue(item.x);
236
+ return item.x;
237
+ }).filter(function(x) {
238
+ return x !== null && x !== undefined && x !== '' && String(x).trim() !== '';
239
+ }).map(function(x) {
240
+ return normalizeXValue(x);
237
241
  });
238
242
  // 去重并排序
239
243
  var uniqueValues = _to_consumable_array(new Set(normalizedValues));
@@ -437,11 +441,78 @@ var intl = new Intl.NumberFormat('en-US', {
437
441
  return true;
438
442
  };
439
443
  /**
440
- * 将十六进制颜色转换为带透明度的 RGBA 字符串
444
+ * RGB/RGBA 颜色字符串转换为十六进制格式
441
445
  *
442
- * 支持3位和6位十六进制颜色格式,并添加透明度。
446
+ * @param {string} rgb - RGB/RGBA 颜色字符串(如 'rgb(29, 122, 252)' 或 'rgba(29, 122, 252, 0.5)')
447
+ * @returns {string} 十六进制颜色值(如 '#1d7afc')
443
448
  *
444
- * @param {string} hex - 十六进制颜色值(如 '#ff0000' 或 '#f00')
449
+ * @since 1.0.0
450
+ */ var rgbToHex = function(rgb) {
451
+ var match = rgb.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
452
+ if (!match) return rgb;
453
+ var r = parseInt(match[1], 10);
454
+ var g = parseInt(match[2], 10);
455
+ var b = parseInt(match[3], 10);
456
+ return "#".concat(((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1));
457
+ };
458
+ /**
459
+ * 从浏览器 DOM 中解析 CSS 变量的实际颜色值
460
+ *
461
+ * @param {string} cssVar - CSS 变量表达式(如 'var(--color-blue)')
462
+ * @returns {string} 解析后的颜色值(如 '#1d7afc')或原值
463
+ *
464
+ * @example
465
+ * ```typescript
466
+ * resolveCssVariable('var(--color-blue-control-fill-primary)'); // '#1d7afc'
467
+ * resolveCssVariable('#ff0000'); // '#ff0000'
468
+ * ```
469
+ *
470
+ * @since 1.0.0
471
+ */ export var resolveCssVariable = function() {
472
+ var cssVariableCache = new Map();
473
+ return function(cssVar) {
474
+ // 如果不是 CSS 变量,直接返回
475
+ if (!cssVar.trim().startsWith('var(')) {
476
+ return cssVar;
477
+ }
478
+ if (cssVariableCache.has(cssVar)) {
479
+ return cssVariableCache.get(cssVar);
480
+ }
481
+ // 提取变量名,如 'var(--color-blue)' => '--color-blue'
482
+ var match = cssVar.match(/var\((--[^)]+)\)/);
483
+ if (!match) {
484
+ // 无法匹配也缓存,避免重复解析
485
+ cssVariableCache.set(cssVar, cssVar);
486
+ return cssVar;
487
+ }
488
+ var resolvedColor = cssVar;
489
+ // 从 DOM 中获取计算后的样式值
490
+ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
491
+ try {
492
+ // 创建临时元素来获取计算后的颜色值
493
+ var tempEl = document.createElement('div');
494
+ tempEl.style.color = cssVar;
495
+ document.body.appendChild(tempEl);
496
+ var computedColor = window.getComputedStyle(tempEl).color;
497
+ document.body.removeChild(tempEl);
498
+ // 如果解析成功,将 rgb/rgba 转换为十六进制
499
+ if (computedColor && computedColor !== cssVar) {
500
+ resolvedColor = rgbToHex(computedColor);
501
+ }
502
+ } catch (e) {
503
+ console.warn("Failed to resolve CSS variable: ".concat(cssVar), e);
504
+ }
505
+ }
506
+ cssVariableCache.set(cssVar, resolvedColor);
507
+ return resolvedColor;
508
+ };
509
+ }();
510
+ /**
511
+ * 将十六进制颜色或CSS变量转换为带透明度的 RGBA 字符串
512
+ *
513
+ * 支持3位和6位十六进制颜色格式、CSS变量(如 var(--color-name)),并添加透明度。
514
+ *
515
+ * @param {string} color - 颜色值(如 '#ff0000'、'#f00' 或 'var(--color-blue)')
445
516
  * @param {number} alpha - 透明度值(0-1之间)
446
517
  * @returns {string} RGBA 颜色字符串
447
518
  *
@@ -449,11 +520,15 @@ var intl = new Intl.NumberFormat('en-US', {
449
520
  * ```typescript
450
521
  * hexToRgba('#ff0000', 0.5); // 'rgba(255, 0, 0, 0.5)'
451
522
  * hexToRgba('#f00', 0.8); // 'rgba(255, 0, 0, 0.8)'
523
+ * hexToRgba('var(--color-blue)', 0.5); // 'rgba(29, 122, 252, 0.5)'
452
524
  * ```
453
525
  *
454
526
  * @since 1.0.0
455
- */ export var hexToRgba = function(hex, alpha) {
456
- var sanitized = hex.replace('#', '');
527
+ */ export var hexToRgba = function(color, alpha) {
528
+ // 解析 CSS 变量为实际颜色值
529
+ var resolvedColor = resolveCssVariable(color);
530
+ // 处理十六进制颜色
531
+ var sanitized = resolvedColor.replace('#', '');
457
532
  var isShort = sanitized.length === 3;
458
533
  var r = parseInt(isShort ? sanitized[0] + sanitized[0] : sanitized.slice(0, 2), 16);
459
534
  var g = parseInt(isShort ? sanitized[1] + sanitized[1] : sanitized.slice(2, 4), 16);
@@ -57,7 +57,7 @@ var genStyle = function(token) {
57
57
  return _define_property({}, token.componentCls, {
58
58
  position: 'relative',
59
59
  cursor: 'pointer',
60
- borderRadius: '24px',
60
+ borderRadius: 'var(--radius-card-base)',
61
61
  boxSizing: 'border-box',
62
62
  border: 'var(--color-gray-border-light)',
63
63
  boxShadow: 'var(--shadow-border-base)',
@@ -128,16 +128,17 @@ var genStyle = function(token) {
128
128
  width: '100%',
129
129
  display: 'flex',
130
130
  alignItems: 'center',
131
- gap: '8px',
131
+ gap: '4px',
132
132
  zIndex: 1
133
133
  },
134
134
  '&-header': {
135
135
  height: 24,
136
136
  display: 'flex',
137
137
  alignItems: 'center',
138
- gap: 8,
138
+ gap: 4,
139
139
  flex: 1,
140
140
  justifyContent: 'space-between',
141
+ paddingRight: 4,
141
142
  '&-light': {
142
143
  gap: 4
143
144
  }
package/dist/typing.d.ts CHANGED
@@ -1,5 +1,32 @@
1
- declare module '*.svg';
2
- declare module '*.webp';
1
+ declare module '*.svg' {
2
+ const content: string;
3
+ export default content;
4
+ }
5
+
6
+ declare module '*.png' {
7
+ const content: string;
8
+ export default content;
9
+ }
10
+
11
+ declare module '*.jpg' {
12
+ const content: string;
13
+ export default content;
14
+ }
15
+
16
+ declare module '*.jpeg' {
17
+ const content: string;
18
+ export default content;
19
+ }
20
+
21
+ declare module '*.gif' {
22
+ const content: string;
23
+ export default content;
24
+ }
25
+
26
+ declare module '*.webp' {
27
+ const content: string;
28
+ export default content;
29
+ }
3
30
  declare module 'direction' {
4
31
  function direction(text: string): 'neutral' | 'ltr' | 'rtl';
5
32
  export default direction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.29.3",
3
+ "version": "2.29.4",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",
@@ -24,11 +24,15 @@
24
24
  "prepare": "husky install && dumi setup",
25
25
  "prepublishOnly": "father doctor && pnpm run test && pnpm run build",
26
26
  "prettier": "prettier --write \"{src,docs,test}/**/*.{js,jsx,ts,tsx,css,less,json,md}\"",
27
+ "preview": "pnpm dumi preview",
27
28
  "report:demo": "node scripts/generateDemoReport.js",
28
29
  "start": "pnpm run dev",
29
30
  "test": "vitest --run --exclude \"**/e2e/**\"",
30
31
  "test:coverage": "vitest --run --exclude \"**/e2e/**\" --coverage",
31
- "test:e2e": "vitest run e2e",
32
+ "test:e2e": "playwright test",
33
+ "test:e2e:debug": "playwright test --debug",
34
+ "test:e2e:skip-server": "cross-env SKIP_WEBSERVER=1 playwright test",
35
+ "test:e2e:ui": "playwright test --ui",
32
36
  "tsc": "tsc --noEmit"
33
37
  },
34
38
  "lint-staged": {
@@ -57,8 +61,10 @@
57
61
  "@better-scroll/scroll-bar": "^2.5.1",
58
62
  "@galacean/effects": "^2.6.5",
59
63
  "@juggle/resize-observer": "^3.4.0",
64
+ "@react-three/fiber": "^8.18.0",
60
65
  "@schema-element-editor/host-sdk": "^2.1.1",
61
66
  "@sofa-design/icons": "^1.6.1",
67
+ "@types/three": "^0.182.0",
62
68
  "ace-builds": "^1.43.4",
63
69
  "ajv": "^8.17.1",
64
70
  "ajv-formats": "^3.0.1",
@@ -67,7 +73,9 @@
67
73
  "chart.js": "^4.5.1",
68
74
  "chartjs-plugin-datalabels": "^2.2.0",
69
75
  "classnames": "^2.5.1",
76
+ "clsx": "^2.1.1",
70
77
  "copy-to-clipboard": "^3.3.3",
78
+ "cross-env": "^7.0.3",
71
79
  "dayjs": "^1.11.19",
72
80
  "diacritics": "^1.3.0",
73
81
  "direction": "^1.0.4",
@@ -111,10 +119,14 @@
111
119
  "slate-hyperscript": "0.100.0",
112
120
  "slate-react": "0.120.0",
113
121
  "string-width": "^7.2.0",
122
+ "styled-components": "^6.1.19",
123
+ "tailwind-merge": "^3.4.0",
124
+ "three": "^0.182.0",
114
125
  "unified": "^11.0.5",
115
126
  "unist-util-visit": "^5.0.0"
116
127
  },
117
128
  "devDependencies": {
129
+ "@playwright/test": "^1.44.0",
118
130
  "@swc/core": "^1.3.53",
119
131
  "@testing-library/jest-dom": "^6.9.1",
120
132
  "@testing-library/react": "^16.3.0",
@@ -134,6 +146,7 @@
134
146
  "@types/react-dom": "^18.3.7",
135
147
  "@types/react-resizable": "^3.0.8",
136
148
  "@types/reveal.js": "^5.2.1",
149
+ "@types/styled-components": "^5.1.36",
137
150
  "@types/uuid": "^10.0.0",
138
151
  "@umijs/lint": "^4.5.3",
139
152
  "@vitejs/plugin-react": "^4.7.0",