@ant-design/agentic-ui 2.30.14 → 2.30.17

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.
Files changed (32) hide show
  1. package/dist/Bubble/AIBubble.js +3 -2
  2. package/dist/Bubble/ContentFilemapView.d.ts +2 -0
  3. package/dist/Bubble/ContentFilemapView.js +9 -6
  4. package/dist/Bubble/MessagesContent/index.js +7 -7
  5. package/dist/Bubble/UserBubble.js +2 -1
  6. package/dist/Hooks/useLanguage.d.ts +3 -1
  7. package/dist/I18n/locales.d.ts +3 -1
  8. package/dist/I18n/locales.js +8 -4
  9. package/dist/MarkdownEditor/editor/elements/Code/ReadonlyCode.js +1 -1
  10. package/dist/MarkdownEditor/editor/elements/Code/index.js +1 -1
  11. package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.d.ts +1 -6
  12. package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.js +2 -13
  13. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +2 -1
  14. package/dist/MarkdownInputField/AttachmentButton/index.d.ts +30 -0
  15. package/dist/MarkdownInputField/AttachmentButton/index.js +22 -6
  16. package/dist/MarkdownInputField/AttachmentButton/utils.d.ts +3 -6
  17. package/dist/MarkdownInputField/FileMapView/index.js +1 -7
  18. package/dist/MarkdownInputField/FileMapView/style.js +1 -2
  19. package/dist/MarkdownInputField/FileUploadManager/index.js +36 -21
  20. package/dist/MarkdownInputField/MarkdownInputField.js +18 -6
  21. package/dist/MarkdownInputField/SendActions/index.js +2 -2
  22. package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.d.ts +1 -0
  23. package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.js +21 -0
  24. package/dist/MarkdownInputField/style.js +26 -2
  25. package/dist/MarkdownInputField/types/MarkdownInputFieldProps.d.ts +4 -4
  26. package/dist/MarkdownInputField/types/MarkdownInputFieldProps.js +1 -1
  27. package/dist/Plugins/chart/ChartRender.js +3 -1
  28. package/dist/Plugins/chart/DonutChart/index.js +1 -1
  29. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.d.ts +6 -2
  30. package/dist/Workspace/File/FileComponent.js +178 -103
  31. package/dist/Workspace/File/style.js +20 -0
  32. package/package.json +1 -1
@@ -241,13 +241,16 @@ import { Empty } from "antd";
241
241
  import classNames from "clsx";
242
242
  import { AnimatePresence, motion } from "framer-motion";
243
243
  import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
244
+ import { useRefFunction } from "../../Hooks/useRefFunction";
244
245
  import { ActionIconBox } from "../../Components/ActionIconBox";
245
- import { I18nContext } from "../../I18n";
246
+ import { I18nContext, compileTemplate } from "../../I18n";
246
247
  import { formatFileSize, formatLastModified } from "../utils";
247
248
  import { fileTypeProcessor, isImageFile } from "./FileTypeProcessor";
248
249
  import { PreviewComponent } from "./PreviewComponent";
249
250
  import { useFileStyle } from "./style";
250
251
  import { generateUniqueId, getFileTypeIcon, getGroupIcon } from "./utils";
252
+ /** Initial number of files shown per group before "show more" */ var GROUP_INITIAL_PAGE_SIZE = 50;
253
+ /** Number of additional files revealed per "show more" click */ var GROUP_PAGE_SIZE_INCREMENT = 100;
251
254
  // 通用的键盘事件处理函数
252
255
  var handleKeyboardEvent = function handleKeyboardEvent(e, callback) {
253
256
  if (e.key === 'Enter' || e.key === ' ') {
@@ -373,11 +376,8 @@ var SearchInput = /*#__PURE__*/ React.memo(function(param) {
373
376
  });
374
377
  SearchInput.displayName = 'SearchInput';
375
378
  // 文件项组件
376
- var FileItemComponent = function FileItemComponent(param) {
377
- var file = param.file, onClick = param.onClick, onDownload = param.onDownload, onPreview = param.onPreview, onShare = param.onShare, onLocate = param.onLocate, prefixCls = param.prefixCls, hashId = param.hashId, _param_bindDomId = param.bindDomId, bindDomId = _param_bindDomId === void 0 ? false : _param_bindDomId;
378
- var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
379
- var locale = useContext(I18nContext).locale;
380
- var finalPrefixCls = prefixCls || getPrefixCls('workspace-file');
379
+ var FileItemComponent = /*#__PURE__*/ React.memo(function(param) {
380
+ var file = param.file, onClick = param.onClick, onDownload = param.onDownload, onPreview = param.onPreview, onShare = param.onShare, onLocate = param.onLocate, prefixCls = param.prefixCls, hashId = param.hashId, locale = param.locale, _param_bindDomId = param.bindDomId, bindDomId = _param_bindDomId === void 0 ? false : _param_bindDomId;
381
381
  // 确保文件有唯一ID
382
382
  var fileWithId = ensureNodeWithId(file);
383
383
  var fileTypeInfo = fileTypeProcessor.inferFileType(fileWithId);
@@ -447,7 +447,7 @@ var FileItemComponent = function FileItemComponent(param) {
447
447
  onLocate === null || onLocate === void 0 ? void 0 : onLocate(fileWithId);
448
448
  };
449
449
  // 内置操作按钮
450
- var actionBtnClass = classNames("".concat(finalPrefixCls, "-item-action-btn"), hashId);
450
+ var actionBtnClass = classNames("".concat(prefixCls, "-item-action-btn"), hashId);
451
451
  var builtinActions = {
452
452
  preview: showPreviewButton ? /*#__PURE__*/ React.createElement(ActionIconBox, {
453
453
  key: "preview",
@@ -489,55 +489,52 @@ var FileItemComponent = function FileItemComponent(param) {
489
489
  // 自定义渲染上下文
490
490
  var renderContext = {
491
491
  file: fileWithId,
492
- prefixCls: finalPrefixCls,
493
- hashId: hashId || '',
492
+ prefixCls: prefixCls,
493
+ hashId: hashId,
494
494
  disabled: isDisabled,
495
495
  actions: builtinActions
496
496
  };
497
497
  return /*#__PURE__*/ React.createElement(AccessibleButton, {
498
498
  icon: /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
499
- className: classNames("".concat(finalPrefixCls, "-item-icon"), hashId)
499
+ className: classNames("".concat(prefixCls, "-item-icon"), hashId)
500
500
  }, getFileTypeIcon(fileTypeInfo.fileType, fileWithId.icon, fileWithId.name)), /*#__PURE__*/ React.createElement("div", {
501
- className: classNames("".concat(finalPrefixCls, "-item-info"), hashId)
501
+ className: classNames("".concat(prefixCls, "-item-info"), hashId)
502
502
  }, /*#__PURE__*/ React.createElement("div", {
503
- className: classNames("".concat(finalPrefixCls, "-item-name"), hashId)
503
+ className: classNames("".concat(prefixCls, "-item-name"), hashId)
504
504
  }, fileWithId.renderName ? fileWithId.renderName(renderContext) : /*#__PURE__*/ React.createElement(Typography.Text, {
505
505
  ellipsis: {
506
506
  tooltip: fileWithId.name
507
507
  }
508
508
  }, fileWithId.name)), (fileWithId.renderDetails || fileTypeInfo.displayType || fileWithId.size || fileWithId.lastModified) && /*#__PURE__*/ React.createElement("div", {
509
- className: classNames("".concat(finalPrefixCls, "-item-details"), hashId)
509
+ className: classNames("".concat(prefixCls, "-item-details"), hashId)
510
510
  }, fileWithId.renderDetails ? fileWithId.renderDetails(renderContext) : /*#__PURE__*/ React.createElement(Typography.Text, {
511
511
  type: "secondary",
512
512
  ellipsis: true
513
513
  }, fileTypeInfo.displayType && /*#__PURE__*/ React.createElement("span", {
514
- className: classNames("".concat(finalPrefixCls, "-item-type"), hashId)
514
+ className: classNames("".concat(prefixCls, "-item-type"), hashId)
515
515
  }, fileTypeInfo.displayType), fileWithId.size && /*#__PURE__*/ React.createElement(React.Fragment, null, fileTypeInfo.displayType && /*#__PURE__*/ React.createElement("span", {
516
- className: classNames("".concat(finalPrefixCls, "-item-separator"), hashId)
516
+ className: classNames("".concat(prefixCls, "-item-separator"), hashId)
517
517
  }, "|"), /*#__PURE__*/ React.createElement("span", {
518
- className: classNames("".concat(finalPrefixCls, "-item-size"), hashId)
518
+ className: classNames("".concat(prefixCls, "-item-size"), hashId)
519
519
  }, formatFileSize(fileWithId.size))), fileWithId.lastModified && /*#__PURE__*/ React.createElement(React.Fragment, null, (fileTypeInfo.displayType || fileWithId.size) && /*#__PURE__*/ React.createElement("span", {
520
- className: classNames("".concat(finalPrefixCls, "-item-separator"), hashId)
520
+ className: classNames("".concat(prefixCls, "-item-separator"), hashId)
521
521
  }, "|"), /*#__PURE__*/ React.createElement("span", {
522
- className: classNames("".concat(finalPrefixCls, "-item-time"), hashId)
522
+ className: classNames("".concat(prefixCls, "-item-time"), hashId)
523
523
  }, formatLastModified(fileWithId.lastModified)))))), /*#__PURE__*/ React.createElement("div", {
524
- className: classNames("".concat(finalPrefixCls, "-item-actions"), hashId),
524
+ className: classNames("".concat(prefixCls, "-item-actions"), hashId),
525
525
  onClick: function onClick(e) {
526
526
  return e.stopPropagation();
527
527
  }
528
528
  }, fileWithId.renderActions ? fileWithId.renderActions(renderContext) : !isDisabled ? /*#__PURE__*/ React.createElement(React.Fragment, null, builtinActions.preview, builtinActions.locate, builtinActions.share, builtinActions.download) : null)),
529
529
  onClick: handleClick,
530
- className: classNames("".concat(finalPrefixCls, "-item"), _define_property({}, "".concat(finalPrefixCls, "-item-disabled"), isDisabled), hashId),
530
+ className: classNames("".concat(prefixCls, "-item"), _define_property({}, "".concat(prefixCls, "-item-disabled"), isDisabled), hashId),
531
531
  ariaLabel: "".concat((locale === null || locale === void 0 ? void 0 : locale['workspace.file']) || '文件', ":").concat(fileWithId.name),
532
532
  id: bindDomId ? fileWithId.id : undefined
533
533
  });
534
- };
534
+ });
535
535
  // 分组标题栏组件
536
- var GroupHeader = function GroupHeader(param) {
537
- var group = param.group, onToggle = param.onToggle, onGroupDownload = param.onGroupDownload, prefixCls = param.prefixCls, hashId = param.hashId;
538
- var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
539
- var locale = useContext(I18nContext).locale;
540
- var finalPrefixCls = prefixCls || getPrefixCls('workspace-file');
536
+ var GroupHeader = /*#__PURE__*/ React.memo(function(param) {
537
+ var group = param.group, onToggle = param.onToggle, onGroupDownload = param.onGroupDownload, prefixCls = param.prefixCls, hashId = param.hashId, locale = param.locale;
541
538
  var groupTypeInfo = fileTypeProcessor.inferFileType(group);
542
539
  var groupType = group.type || groupTypeInfo.fileType;
543
540
  var handleToggle = function handleToggle() {
@@ -565,35 +562,60 @@ var GroupHeader = function GroupHeader(param) {
565
562
  }();
566
563
  return /*#__PURE__*/ React.createElement(AccessibleButton, {
567
564
  icon: /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
568
- className: classNames("".concat(finalPrefixCls, "-group-header-left"), hashId)
565
+ className: classNames("".concat(prefixCls, "-group-header-left"), hashId)
569
566
  }, /*#__PURE__*/ React.createElement(CollapseIcon, {
570
- className: classNames("".concat(finalPrefixCls, "-group-toggle-icon"), hashId)
567
+ className: classNames("".concat(prefixCls, "-group-toggle-icon"), hashId)
571
568
  }), /*#__PURE__*/ React.createElement("div", {
572
- className: classNames("".concat(finalPrefixCls, "-group-type-icon"), hashId)
569
+ className: classNames("".concat(prefixCls, "-group-type-icon"), hashId)
573
570
  }, groupIcon), /*#__PURE__*/ React.createElement("span", {
574
- className: classNames("".concat(finalPrefixCls, "-group-type-name"), hashId)
571
+ className: classNames("".concat(prefixCls, "-group-type-name"), hashId)
575
572
  }, group.name)), /*#__PURE__*/ React.createElement("div", {
576
- className: classNames("".concat(finalPrefixCls, "-group-header-right"), hashId)
573
+ className: classNames("".concat(prefixCls, "-group-header-right"), hashId)
577
574
  }, /*#__PURE__*/ React.createElement("span", {
578
- className: classNames("".concat(finalPrefixCls, "-group-count"), hashId)
575
+ className: classNames("".concat(prefixCls, "-group-count"), hashId)
579
576
  }, group.children.length), showDownloadButton && /*#__PURE__*/ React.createElement(ActionIconBox, {
580
577
  title: (locale === null || locale === void 0 ? void 0 : locale['workspace.file.download']) || '下载',
581
578
  onClick: handleDownload,
582
579
  tooltipProps: {
583
580
  mouseEnterDelay: 0.3
584
581
  },
585
- className: classNames("".concat(finalPrefixCls, "-group-action-btn"), hashId)
582
+ className: classNames("".concat(prefixCls, "-group-action-btn"), hashId)
586
583
  }, /*#__PURE__*/ React.createElement(DownloadIcon, null)))),
587
584
  onClick: handleToggle,
588
- className: classNames("".concat(finalPrefixCls, "-group-header"), hashId),
585
+ className: classNames("".concat(prefixCls, "-group-header"), hashId),
589
586
  ariaLabel: "".concat(group.collapsed ? (locale === null || locale === void 0 ? void 0 : locale['workspace.expand']) || '展开' : (locale === null || locale === void 0 ? void 0 : locale['workspace.collapse']) || '收起').concat(group.name).concat((locale === null || locale === void 0 ? void 0 : locale['workspace.group']) || '分组')
590
587
  });
591
- };
588
+ });
592
589
  // 文件分组组件
593
- var FileGroupComponent = function FileGroupComponent(param) {
594
- var group = param.group, onToggle = param.onToggle, onGroupDownload = param.onGroupDownload, onDownload = param.onDownload, onFileClick = param.onFileClick, onPreview = param.onPreview, onShare = param.onShare, onLocate = param.onLocate, prefixCls = param.prefixCls, hashId = param.hashId, bindDomId = param.bindDomId;
595
- var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
596
- var finalPrefixCls = prefixCls || getPrefixCls('workspace-file');
590
+ var FileGroupComponent = /*#__PURE__*/ React.memo(function(param) {
591
+ var group = param.group, onToggle = param.onToggle, onGroupDownload = param.onGroupDownload, onDownload = param.onDownload, onFileClick = param.onFileClick, onPreview = param.onPreview, onShare = param.onShare, onLocate = param.onLocate, prefixCls = param.prefixCls, hashId = param.hashId, locale = param.locale, bindDomId = param.bindDomId;
592
+ var _useState = _sliced_to_array(useState(GROUP_INITIAL_PAGE_SIZE), 2), visibleCount = _useState[0], setVisibleCount = _useState[1];
593
+ // 分组数据变化时重置分页,避免切换数据源后一次性展示过多节点
594
+ useEffect(function() {
595
+ setVisibleCount(GROUP_INITIAL_PAGE_SIZE);
596
+ }, [
597
+ group.id,
598
+ group.children.length
599
+ ]);
600
+ var totalCount = group.children.length;
601
+ var visibleFiles = group.children.slice(0, visibleCount);
602
+ var remainingCount = totalCount - visibleCount;
603
+ var hasMore = remainingCount > 0;
604
+ var handleShowMore = useRefFunction(function(e) {
605
+ e.stopPropagation();
606
+ setVisibleCount(function(prev) {
607
+ return prev + GROUP_PAGE_SIZE_INCREMENT;
608
+ });
609
+ });
610
+ var handleShowMoreKeyDown = useRefFunction(function(e) {
611
+ if (e.key === 'Enter' || e.key === ' ') {
612
+ e.preventDefault();
613
+ e.stopPropagation();
614
+ setVisibleCount(function(prev) {
615
+ return prev + GROUP_PAGE_SIZE_INCREMENT;
616
+ });
617
+ }
618
+ });
597
619
  var contentVariants = useMemo(function() {
598
620
  return {
599
621
  expanded: {
@@ -623,14 +645,18 @@ var FileGroupComponent = function FileGroupComponent(param) {
623
645
  }
624
646
  };
625
647
  }, []);
648
+ var showMoreLabel = hasMore ? compileTemplate((locale === null || locale === void 0 ? void 0 : locale['workspace.file.showMore']) || '查看更多(还有 ${count} 个)', {
649
+ count: String(remainingCount)
650
+ }) : (locale === null || locale === void 0 ? void 0 : locale['workspace.file.showMoreFiles']) || '查看更多文件';
626
651
  return /*#__PURE__*/ React.createElement("div", {
627
- className: classNames("".concat(finalPrefixCls, "-container--group"), hashId)
652
+ className: classNames("".concat(prefixCls, "-container--group"), hashId)
628
653
  }, /*#__PURE__*/ React.createElement(GroupHeader, {
629
654
  group: group,
630
655
  onToggle: onToggle,
631
656
  onGroupDownload: onGroupDownload,
632
- prefixCls: finalPrefixCls,
633
- hashId: hashId
657
+ prefixCls: prefixCls,
658
+ hashId: hashId,
659
+ locale: locale
634
660
  }), /*#__PURE__*/ React.createElement(AnimatePresence, {
635
661
  initial: false
636
662
  }, !group.collapsed && /*#__PURE__*/ React.createElement(motion.div, {
@@ -640,8 +666,8 @@ var FileGroupComponent = function FileGroupComponent(param) {
640
666
  animate: "expanded",
641
667
  exit: "collapsed",
642
668
  transition: contentTransition,
643
- className: classNames("".concat(finalPrefixCls, "-group-content"), hashId)
644
- }, group.children.map(function(file) {
669
+ className: classNames("".concat(prefixCls, "-group-content"), hashId)
670
+ }, visibleFiles.map(function(file) {
645
671
  return /*#__PURE__*/ React.createElement(FileItemComponent, {
646
672
  key: file.id,
647
673
  file: file,
@@ -650,12 +676,20 @@ var FileGroupComponent = function FileGroupComponent(param) {
650
676
  onPreview: onPreview,
651
677
  onShare: onShare,
652
678
  onLocate: onLocate,
653
- prefixCls: finalPrefixCls,
679
+ prefixCls: prefixCls,
654
680
  hashId: hashId,
681
+ locale: locale,
655
682
  bindDomId: !!bindDomId
656
683
  });
657
- }))));
658
- };
684
+ }), hasMore && /*#__PURE__*/ React.createElement("div", {
685
+ role: "button",
686
+ tabIndex: 0,
687
+ className: classNames("".concat(prefixCls, "-show-more"), hashId),
688
+ onClick: handleShowMore,
689
+ onKeyDown: handleShowMoreKeyDown,
690
+ "aria-label": showMoreLabel
691
+ }, showMoreLabel))));
692
+ });
659
693
  export var FileComponent = function FileComponent(param) {
660
694
  var nodes = param.nodes, onGroupDownload = param.onGroupDownload, onDownload = param.onDownload, onShare = param.onShare, onFileClick = param.onFileClick, onLocate = param.onLocate, onToggleGroup = param.onToggleGroup, onGroupToggle = param.onGroupToggle, onPreview = param.onPreview, onBack = param.onBack, resetKey = param.resetKey, markdownEditorProps = param.markdownEditorProps, customActions = param.customActions, actionRef = param.actionRef, loading = param.loading, loadingRender = param.loadingRender, emptyRender = param.emptyRender, keyword = param.keyword, onChange = param.onChange, _param_showSearch = param.showSearch, showSearch = _param_showSearch === void 0 ? false : _param_showSearch, searchPlaceholder = param.searchPlaceholder, _param_bindDomId = param.bindDomId, bindDomId = _param_bindDomId === void 0 ? false : _param_bindDomId;
661
695
  var _useState = _sliced_to_array(useState(null), 2), previewFile = _useState[0], setPreviewFile = _useState[1];
@@ -669,6 +703,15 @@ export var FileComponent = function FileComponent(param) {
669
703
  }), 2), imagePreview = _useState4[0], setImagePreview = _useState4[1];
670
704
  // 添加内部状态来管理分组的折叠状态
671
705
  var _useState5 = _sliced_to_array(useState({}), 2), collapsedGroups = _useState5[0], setCollapsedGroups = _useState5[1];
706
+ // 扁平文件列表(非分组模式)分页状态
707
+ var _useState6 = _sliced_to_array(useState(GROUP_INITIAL_PAGE_SIZE), 2), flatVisibleCount = _useState6[0], setFlatVisibleCount = _useState6[1];
708
+ // nodes 或 keyword 变化时重置扁平列表分页,避免切换数据源后一次性渲染过多节点
709
+ useEffect(function() {
710
+ setFlatVisibleCount(GROUP_INITIAL_PAGE_SIZE);
711
+ }, [
712
+ nodes,
713
+ keyword
714
+ ]);
672
715
  // 追踪预览请求的序号,避免异步竞态
673
716
  var previewRequestIdRef = useRef(0);
674
717
  // 缓存节点 ID,避免每次渲染重新生成(使用 WeakMap 自动清理不再使用的节点)
@@ -680,7 +723,7 @@ export var FileComponent = function FileComponent(param) {
680
723
  var prefixCls = getPrefixCls('workspace-file');
681
724
  var _useFileStyle = useFileStyle(prefixCls), wrapSSR = _useFileStyle.wrapSSR, hashId = _useFileStyle.hashId;
682
725
  // 确保节点有稳定的唯一 ID(使用缓存)
683
- var ensureNodeWithStableId = function ensureNodeWithStableId(node) {
726
+ var ensureNodeWithStableId = useRefFunction(function(node) {
684
727
  if (node.id) return _object_spread({}, node);
685
728
  // 尝试从缓存获取 ID
686
729
  var cachedId = nodeIdCacheRef.current.get(node);
@@ -692,16 +735,16 @@ export var FileComponent = function FileComponent(param) {
692
735
  return _object_spread_props(_object_spread({}, node), {
693
736
  id: cachedId
694
737
  });
695
- };
738
+ });
696
739
  // 返回列表(供预览页调用)
697
- var handleBackToList = function handleBackToList() {
740
+ var handleBackToList = useRefFunction(function() {
698
741
  // 使进行中的预览请求失效
699
742
  previewRequestIdRef.current++;
700
743
  setPreviewFile(null);
701
744
  setCustomPreviewContent(null);
702
745
  setCustomPreviewHeader(null);
703
746
  setHeaderFileOverride(null);
704
- };
747
+ });
705
748
  // 监听 resetKey 变化,重置预览状态
706
749
  useEffect(function() {
707
750
  if (resetKey !== undefined && previewFile) {
@@ -756,7 +799,7 @@ export var FileComponent = function FileComponent(param) {
756
799
  nodes
757
800
  ]);
758
801
  // 处理分组折叠/展开
759
- var handleToggleGroup = function handleToggleGroup(groupId, type, collapsed) {
802
+ var handleToggleGroup = useRefFunction(function(groupId, type, collapsed) {
760
803
  // 更新内部状态,使用 groupId 作为 key
761
804
  setCollapsedGroups(function(prev) {
762
805
  return _object_spread_props(_object_spread({}, prev), _define_property({}, groupId, collapsed));
@@ -767,9 +810,9 @@ export var FileComponent = function FileComponent(param) {
767
810
  } else if (onToggleGroup) {
768
811
  onToggleGroup(type, collapsed);
769
812
  }
770
- };
813
+ });
771
814
  // 包装后的返回逻辑,允许外部拦截
772
- var handleBack = function handleBack() {
815
+ var handleBack = useRefFunction(function() {
773
816
  return _async_to_generator(function() {
774
817
  var result, _;
775
818
  return _ts_generator(this, function(_state) {
@@ -814,18 +857,18 @@ export var FileComponent = function FileComponent(param) {
814
857
  }
815
858
  });
816
859
  })();
817
- };
860
+ });
818
861
  // 预览页面的下载(供预览页调用)
819
- var handleDownloadInPreview = function handleDownloadInPreview(file) {
862
+ var handleDownloadInPreview = useRefFunction(function(file) {
820
863
  // 优先使用用户传入的下载方法
821
864
  if (onDownload) {
822
865
  onDownload(file);
823
866
  return;
824
867
  }
825
868
  handleFileDownload(file);
826
- };
869
+ });
827
870
  // 预览文件处理
828
- var handlePreview = function handlePreview(file) {
871
+ var handlePreview = useRefFunction(function(file) {
829
872
  return _async_to_generator(function() {
830
873
  var currentCallId, previewData, content, err, previewSrc;
831
874
  return _ts_generator(this, function(_state) {
@@ -935,7 +978,7 @@ export var FileComponent = function FileComponent(param) {
935
978
  }
936
979
  });
937
980
  })();
938
- };
981
+ });
939
982
  // 通过 actionRef 暴露可编程接口
940
983
  React.useEffect(function() {
941
984
  if (!actionRef) return;
@@ -963,7 +1006,7 @@ export var FileComponent = function FileComponent(param) {
963
1006
  ]);
964
1007
  var hasKeyword = Boolean((keyword !== null && keyword !== void 0 ? keyword : '').trim());
965
1008
  // 渲染搜索框组件 - 确保在所有情况下都保持一致
966
- var renderSearchInput = function renderSearchInput() {
1009
+ var renderSearchInput = useRefFunction(function() {
967
1010
  if (!showSearch) return null;
968
1011
  return /*#__PURE__*/ React.createElement(SearchInput, {
969
1012
  keyword: keyword,
@@ -973,9 +1016,9 @@ export var FileComponent = function FileComponent(param) {
973
1016
  hashId: hashId,
974
1017
  locale: locale
975
1018
  });
976
- };
1019
+ });
977
1020
  // 渲染空状态内容
978
- var renderEmptyContent = function renderEmptyContent() {
1021
+ var renderEmptyContent = useRefFunction(function() {
979
1022
  if (hasKeyword) {
980
1023
  return /*#__PURE__*/ React.createElement(Typography.Text, {
981
1024
  type: "secondary"
@@ -987,48 +1030,20 @@ export var FileComponent = function FileComponent(param) {
987
1030
  return emptyRender !== null && emptyRender !== void 0 ? emptyRender : /*#__PURE__*/ React.createElement(Empty, {
988
1031
  description: (locale === null || locale === void 0 ? void 0 : locale['workspace.empty']) || 'No data'
989
1032
  });
990
- };
991
- // 图片预览组件
992
- var ImagePreviewComponent = /*#__PURE__*/ React.createElement(Image, {
993
- className: classNames("".concat(prefixCls, "-hidden-image"), hashId),
994
- src: imagePreview.src,
995
- preview: {
996
- visible: imagePreview.visible,
997
- onVisibleChange: function onVisibleChange(visible) {
998
- setImagePreview(function(prev) {
999
- return _object_spread_props(_object_spread({}, prev), {
1000
- visible: visible
1001
- });
1002
- });
1003
- }
1033
+ });
1034
+ var handleFlatShowMore = useRefFunction(function() {
1035
+ setFlatVisibleCount(function(prev) {
1036
+ return prev + GROUP_PAGE_SIZE_INCREMENT;
1037
+ });
1038
+ });
1039
+ var handleFlatShowMoreKeyDown = useRefFunction(function(e) {
1040
+ if (e.key === 'Enter' || e.key === ' ') {
1041
+ e.preventDefault();
1042
+ handleFlatShowMore();
1004
1043
  }
1005
1044
  });
1006
- // 如果正在预览文件,显示预览组件
1007
- if (previewFile) {
1008
- return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(PreviewComponent, {
1009
- file: previewFile,
1010
- onBack: handleBack,
1011
- onDownload: handleDownloadInPreview,
1012
- onShare: function onShare1(file, options) {
1013
- if (onShare) {
1014
- onShare(file, {
1015
- anchorEl: options === null || options === void 0 ? void 0 : options.anchorEl,
1016
- origin: 'preview'
1017
- });
1018
- } else {
1019
- handleDefaultShare(file);
1020
- }
1021
- },
1022
- onLocate: onLocate,
1023
- customContent: customPreviewContent || undefined,
1024
- customHeader: customPreviewHeader || undefined,
1025
- customActions: typeof customActions === 'function' ? customActions(previewFile) : customActions,
1026
- headerFileOverride: headerFileOverride || undefined,
1027
- markdownEditorProps: markdownEditorProps
1028
- }), ImagePreviewComponent);
1029
- }
1030
1045
  // 渲染文件内容
1031
- var renderFileContent = function renderFileContent() {
1046
+ var renderFileContent = useRefFunction(function() {
1032
1047
  if ((!nodes || nodes.length === 0) && !loading) {
1033
1048
  return /*#__PURE__*/ React.createElement("div", {
1034
1049
  className: classNames("".concat(prefixCls, "-empty"), hashId)
@@ -1039,7 +1054,14 @@ export var FileComponent = function FileComponent(param) {
1039
1054
  className: classNames("".concat(prefixCls, "-empty"), hashId)
1040
1055
  }, renderEmptyContent());
1041
1056
  }
1042
- return safeNodes.map(function(node) {
1057
+ // Determine whether this is a purely flat list (no groups) so we can paginate
1058
+ var isFlat = safeNodes.every(function(n) {
1059
+ return !('children' in n);
1060
+ });
1061
+ var nodesToRender = isFlat ? safeNodes.slice(0, flatVisibleCount) : safeNodes;
1062
+ var flatRemaining = isFlat ? safeNodes.length - flatVisibleCount : 0;
1063
+ var flatHasMore = flatRemaining > 0;
1064
+ var items = nodesToRender.map(function(node) {
1043
1065
  var nodeWithId = ensureNodeWithStableId(node);
1044
1066
  if ('children' in nodeWithId) {
1045
1067
  var _collapsedGroups_nodeWithId_id;
@@ -1061,6 +1083,7 @@ export var FileComponent = function FileComponent(param) {
1061
1083
  onLocate: onLocate,
1062
1084
  prefixCls: prefixCls,
1063
1085
  hashId: hashId,
1086
+ locale: locale,
1064
1087
  bindDomId: bindDomId
1065
1088
  });
1066
1089
  }
@@ -1075,10 +1098,62 @@ export var FileComponent = function FileComponent(param) {
1075
1098
  onLocate: onLocate,
1076
1099
  prefixCls: prefixCls,
1077
1100
  hashId: hashId,
1101
+ locale: locale,
1078
1102
  bindDomId: bindDomId
1079
1103
  });
1080
1104
  });
1081
- };
1105
+ if (!flatHasMore) return items;
1106
+ var flatShowMoreLabel = compileTemplate((locale === null || locale === void 0 ? void 0 : locale['workspace.file.showMore']) || '查看更多(还有 ${count} 个)', {
1107
+ count: String(flatRemaining)
1108
+ });
1109
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, items, /*#__PURE__*/ React.createElement("div", {
1110
+ role: "button",
1111
+ tabIndex: 0,
1112
+ className: classNames("".concat(prefixCls, "-show-more"), hashId),
1113
+ onClick: handleFlatShowMore,
1114
+ onKeyDown: handleFlatShowMoreKeyDown,
1115
+ "aria-label": flatShowMoreLabel
1116
+ }, flatShowMoreLabel));
1117
+ });
1118
+ // 图片预览组件
1119
+ var ImagePreviewComponent = /*#__PURE__*/ React.createElement(Image, {
1120
+ className: classNames("".concat(prefixCls, "-hidden-image"), hashId),
1121
+ src: imagePreview.src,
1122
+ preview: {
1123
+ visible: imagePreview.visible,
1124
+ onVisibleChange: function onVisibleChange(visible) {
1125
+ setImagePreview(function(prev) {
1126
+ return _object_spread_props(_object_spread({}, prev), {
1127
+ visible: visible
1128
+ });
1129
+ });
1130
+ }
1131
+ }
1132
+ });
1133
+ // 如果正在预览文件,显示预览组件
1134
+ if (previewFile) {
1135
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(PreviewComponent, {
1136
+ file: previewFile,
1137
+ onBack: handleBack,
1138
+ onDownload: handleDownloadInPreview,
1139
+ onShare: function onShare1(file, options) {
1140
+ if (onShare) {
1141
+ onShare(file, {
1142
+ anchorEl: options === null || options === void 0 ? void 0 : options.anchorEl,
1143
+ origin: 'preview'
1144
+ });
1145
+ } else {
1146
+ handleDefaultShare(file);
1147
+ }
1148
+ },
1149
+ onLocate: onLocate,
1150
+ customContent: customPreviewContent || undefined,
1151
+ customHeader: customPreviewHeader || undefined,
1152
+ customActions: typeof customActions === 'function' ? customActions(previewFile) : customActions,
1153
+ headerFileOverride: headerFileOverride || undefined,
1154
+ markdownEditorProps: markdownEditorProps
1155
+ }), ImagePreviewComponent);
1156
+ }
1082
1157
  // 统一的渲染逻辑 - 确保搜索框位置稳定
1083
1158
  return wrapSSR(/*#__PURE__*/ React.createElement(React.Fragment, null, loading && loadingRender ? // 使用自定义loading渲染函数
1084
1159
  /*#__PURE__*/ React.createElement("div", {
@@ -446,6 +446,26 @@ var genStyle = function genStyle(token) {
446
446
  }), // 隐藏的图片预览组件
447
447
  _define_property(_obj7, "".concat(token.componentCls, "-hidden-image"), {
448
448
  display: 'none'
449
+ }), // 查看更多按钮
450
+ _define_property(_obj7, "".concat(token.componentCls, "-show-more"), {
451
+ display: 'flex',
452
+ alignItems: 'center',
453
+ justifyContent: 'center',
454
+ padding: '6px 0',
455
+ cursor: 'pointer',
456
+ color: 'var(--color-gray-text-secondary)',
457
+ font: 'var(--font-text-body-sm)',
458
+ letterSpacing: 'var(--letter-spacing-body-sm, normal)',
459
+ transition: 'color 0.2s ease',
460
+ userSelect: 'none',
461
+ '&:hover': {
462
+ color: 'var(--color-primary-control-fill-primary-active)'
463
+ },
464
+ svg: {
465
+ marginLeft: '4px',
466
+ width: '12px',
467
+ height: '12px'
468
+ }
449
469
  }), _obj7;
450
470
  };
451
471
  export function useFileStyle(prefixCls) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.30.14",
3
+ "version": "2.30.17",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",