@ant-design/agentic-ui 2.30.17 → 2.30.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Bubble/MessagesContent/MarkdownPreview.js +11 -10
- package/dist/Hooks/useLanguage.d.ts +25 -0
- package/dist/I18n/locales.d.ts +25 -0
- package/dist/I18n/locales.js +58 -2
- package/dist/MarkdownEditor/editor/elements/Code/index.js +12 -0
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/enter.js +5 -0
- package/dist/MarkdownInputField/AttachmentButton/index.js +55 -5
- package/dist/MarkdownInputField/style.js +1 -2
- package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.d.ts +50 -0
- package/dist/Plugins/code/components/CodeToolbar.js +1 -1
- package/dist/Schema/SchemaForm/index.js +18 -9
- package/dist/TaskList/TaskList.js +6 -2
- package/dist/ThoughtChainList/ThoughtChainListItem.js +28 -3
- package/dist/ThoughtChainList/index.js +19 -3
- package/dist/ThoughtChainList/style.js +4 -2
- package/dist/ToolUseBar/BarItem/Content.js +26 -49
- package/dist/ToolUseBar/style.js +13 -4
- package/dist/Workspace/Browser/index.js +1 -2
- package/dist/Workspace/File/FileTypeProcessor.js +1 -4
- package/dist/Workspace/File/PreviewComponent.js +6 -6
- package/dist/Workspace/File/index.d.ts +1 -0
- package/dist/Workspace/File/index.js +1 -0
- package/dist/Workspace/File/utils.js +4 -2
- package/dist/Workspace/types.d.ts +8 -1
- package/dist/Workspace/types.js +74 -35
- package/package.json +1 -1
|
@@ -161,7 +161,8 @@ var genStyle = function genStyle(token) {
|
|
|
161
161
|
borderRadius: '0px 0px 12px 12px',
|
|
162
162
|
maxHeight: '566px',
|
|
163
163
|
padding: '12px 12px',
|
|
164
|
-
|
|
164
|
+
opacity: 1,
|
|
165
|
+
transition: 'max-height 0.16s cubic-bezier(0.4, 0, 0.2, 1), padding 0.16s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.12s linear',
|
|
165
166
|
overflow: 'auto',
|
|
166
167
|
'&&-compact': {
|
|
167
168
|
padding: 8
|
|
@@ -169,7 +170,8 @@ var genStyle = function genStyle(token) {
|
|
|
169
170
|
'&&-collapse': {
|
|
170
171
|
maxHeight: '0px',
|
|
171
172
|
padding: '0',
|
|
172
|
-
opacity: 0
|
|
173
|
+
opacity: 0,
|
|
174
|
+
overflow: 'hidden'
|
|
173
175
|
},
|
|
174
176
|
'&-list': {
|
|
175
177
|
display: 'flex',
|
|
@@ -98,10 +98,11 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
98
98
|
}
|
|
99
99
|
import { Api, ChevronUp, ChevronsDownUp, ChevronsUpDown, X } from "@sofa-design/icons";
|
|
100
100
|
import classNames from "clsx";
|
|
101
|
-
import {
|
|
101
|
+
import { motion } from "framer-motion";
|
|
102
102
|
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
103
103
|
import { useRefFunction } from "../../Hooks/useRefFunction";
|
|
104
104
|
/** 内容超出此高度时自动收起 */ var CONTENT_COLLAPSE_THRESHOLD = 200;
|
|
105
|
+
/** 工具详情收起动画时长(毫秒) */ var TOOL_CONTENT_COLLAPSE_DURATION_MS = 160;
|
|
105
106
|
var ToolImageComponent = function ToolImageComponent(param) {
|
|
106
107
|
var tool = param.tool, prefixCls = param.prefixCls, hashId = param.hashId, _param_disableAnimation = param.disableAnimation, disableAnimation = _param_disableAnimation === void 0 ? false : _param_disableAnimation;
|
|
107
108
|
var toolImageWrapperClassName = useMemo(function() {
|
|
@@ -325,6 +326,7 @@ var ToolContentComponent = function ToolContentComponent(param) {
|
|
|
325
326
|
var contentInnerRef = useRef(null);
|
|
326
327
|
var _useState = _sliced_to_array(useState(false), 2), isContentOverflowing = _useState[0], setIsContentOverflowing = _useState[1];
|
|
327
328
|
var _useState1 = _sliced_to_array(useState(false), 2), contentExpanded = _useState1[0], setContentExpanded = _useState1[1];
|
|
329
|
+
var _useState2 = _sliced_to_array(useState(expanded), 2), shouldRenderContent = _useState2[0], setShouldRenderContent = _useState2[1];
|
|
328
330
|
var toolContainerClassName = useMemo(function() {
|
|
329
331
|
return classNames("".concat(prefixCls, "-tool-container"), hashId, _define_property({}, "".concat(prefixCls, "-tool-container-light"), light));
|
|
330
332
|
}, [
|
|
@@ -409,6 +411,25 @@ var ToolContentComponent = function ToolContentComponent(param) {
|
|
|
409
411
|
tool.errorMessage,
|
|
410
412
|
checkOverflow
|
|
411
413
|
]);
|
|
414
|
+
useEffect(function() {
|
|
415
|
+
if (!showContent) {
|
|
416
|
+
setShouldRenderContent(false);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
if (expanded) {
|
|
420
|
+
setShouldRenderContent(true);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
var timer = window.setTimeout(function() {
|
|
424
|
+
setShouldRenderContent(false);
|
|
425
|
+
}, TOOL_CONTENT_COLLAPSE_DURATION_MS);
|
|
426
|
+
return function() {
|
|
427
|
+
window.clearTimeout(timer);
|
|
428
|
+
};
|
|
429
|
+
}, [
|
|
430
|
+
expanded,
|
|
431
|
+
showContent
|
|
432
|
+
]);
|
|
412
433
|
var handleContentExpandToggle = useRefFunction(function() {
|
|
413
434
|
setContentExpanded(function(prev) {
|
|
414
435
|
return !prev;
|
|
@@ -449,41 +470,6 @@ var ToolContentComponent = function ToolContentComponent(param) {
|
|
|
449
470
|
contentExpandClassName,
|
|
450
471
|
handleContentExpandToggle
|
|
451
472
|
]);
|
|
452
|
-
var contentVariants = useMemo(function() {
|
|
453
|
-
return {
|
|
454
|
-
expanded: {
|
|
455
|
-
height: 'auto',
|
|
456
|
-
opacity: 1
|
|
457
|
-
},
|
|
458
|
-
collapsed: {
|
|
459
|
-
height: 0,
|
|
460
|
-
opacity: 0
|
|
461
|
-
}
|
|
462
|
-
};
|
|
463
|
-
}, []);
|
|
464
|
-
var contentTransition = useMemo(function() {
|
|
465
|
-
return {
|
|
466
|
-
height: {
|
|
467
|
-
duration: 0.26,
|
|
468
|
-
ease: [
|
|
469
|
-
0.4,
|
|
470
|
-
0,
|
|
471
|
-
0.2,
|
|
472
|
-
1
|
|
473
|
-
]
|
|
474
|
-
},
|
|
475
|
-
opacity: {
|
|
476
|
-
duration: 0.2,
|
|
477
|
-
ease: 'linear'
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
}, []);
|
|
481
|
-
var containerStyle = useMemo(function() {
|
|
482
|
-
return {
|
|
483
|
-
overflow: 'hidden',
|
|
484
|
-
willChange: 'height, opacity'
|
|
485
|
-
};
|
|
486
|
-
}, []);
|
|
487
473
|
var innerContent = /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
|
|
488
474
|
ref: contentInnerRef,
|
|
489
475
|
style: contentInnerStyle
|
|
@@ -491,26 +477,17 @@ var ToolContentComponent = function ToolContentComponent(param) {
|
|
|
491
477
|
// 禁用动画时使用简单的显示/隐藏
|
|
492
478
|
if (disableAnimation) {
|
|
493
479
|
return showContent && expanded ? /*#__PURE__*/ React.createElement("div", {
|
|
494
|
-
className: toolContainerClassName,
|
|
480
|
+
className: classNames(toolContainerClassName, _define_property({}, "".concat(prefixCls, "-tool-container-expanded"), true)),
|
|
495
481
|
"data-testid": "tool-user-item-tool-container",
|
|
496
482
|
style: {
|
|
497
483
|
overflow: 'hidden'
|
|
498
484
|
}
|
|
499
485
|
}, innerContent) : null;
|
|
500
486
|
}
|
|
501
|
-
return /*#__PURE__*/ React.createElement(
|
|
502
|
-
|
|
503
|
-
mode: "sync"
|
|
504
|
-
}, expanded ? /*#__PURE__*/ React.createElement(motion.div, {
|
|
505
|
-
key: "tool-content",
|
|
506
|
-
className: toolContainerClassName,
|
|
487
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, showContent && shouldRenderContent ? /*#__PURE__*/ React.createElement("div", {
|
|
488
|
+
className: classNames(toolContainerClassName, _define_property({}, "".concat(prefixCls, "-tool-container-expanded"), expanded)),
|
|
507
489
|
"data-testid": "tool-user-item-tool-container",
|
|
508
|
-
|
|
509
|
-
initial: "collapsed",
|
|
510
|
-
animate: "expanded",
|
|
511
|
-
exit: "collapsed",
|
|
512
|
-
transition: contentTransition,
|
|
513
|
-
style: containerStyle
|
|
490
|
+
"aria-hidden": !expanded
|
|
514
491
|
}, innerContent) : null, !showContent ? /*#__PURE__*/ React.createElement("div", {
|
|
515
492
|
style: {
|
|
516
493
|
overflow: 'hidden',
|
package/dist/ToolUseBar/style.js
CHANGED
|
@@ -76,7 +76,7 @@ var genStyle = function genStyle(token) {
|
|
|
76
76
|
minHeight: '20px',
|
|
77
77
|
backdropFilter: 'blur(8px)',
|
|
78
78
|
width: 'max-content',
|
|
79
|
-
transition: 'border-radius 0.
|
|
79
|
+
transition: 'border-radius 0.16s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
80
80
|
display: 'flex',
|
|
81
81
|
alignItems: 'center',
|
|
82
82
|
flexDirection: 'column',
|
|
@@ -307,12 +307,21 @@ var genStyle = function genStyle(token) {
|
|
|
307
307
|
display: 'flex',
|
|
308
308
|
flexDirection: 'column',
|
|
309
309
|
width: '100%',
|
|
310
|
-
maxHeight:
|
|
310
|
+
maxHeight: 0,
|
|
311
311
|
overflow: 'hidden',
|
|
312
|
-
|
|
312
|
+
opacity: 0,
|
|
313
|
+
pointerEvents: 'none',
|
|
314
|
+
transition: 'max-height 0.16s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.12s linear',
|
|
313
315
|
position: 'relative',
|
|
314
316
|
paddingInline: 4,
|
|
315
|
-
paddingBottom:
|
|
317
|
+
paddingBottom: 0,
|
|
318
|
+
'&-expanded': {
|
|
319
|
+
maxHeight: 700,
|
|
320
|
+
opacity: 1,
|
|
321
|
+
pointerEvents: 'auto',
|
|
322
|
+
overflowY: 'auto',
|
|
323
|
+
paddingBottom: 4
|
|
324
|
+
},
|
|
316
325
|
'&-light': {
|
|
317
326
|
borderLeft: '1px solid var(--color-gray-border-light)',
|
|
318
327
|
paddingLeft: 12,
|
|
@@ -197,8 +197,7 @@ export var BrowserItemComponent = function BrowserItemComponent(param) {
|
|
|
197
197
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
198
198
|
className: classNames("".concat(prefixCls, "-result-item-title"), hashId)
|
|
199
199
|
}, item.title)))), /*#__PURE__*/ React.createElement("div", {
|
|
200
|
-
className: classNames("".concat(prefixCls, "-result-item-site"), hashId)
|
|
201
|
-
onClick: handleOpen
|
|
200
|
+
className: classNames("".concat(prefixCls, "-result-item-site"), hashId)
|
|
202
201
|
}, renderSiteAvatar(item.site, item.icon), /*#__PURE__*/ React.createElement(Tooltip, {
|
|
203
202
|
title: item.site,
|
|
204
203
|
mouseEnterDelay: 1
|
|
@@ -284,8 +284,7 @@ import { PreviewCapability, dataSourceManager } from "./DataSourceStrategy";
|
|
|
284
284
|
FileCategory.Image,
|
|
285
285
|
FileCategory.Video,
|
|
286
286
|
FileCategory.Audio,
|
|
287
|
-
FileCategory.PDF
|
|
288
|
-
FileCategory.Archive
|
|
287
|
+
FileCategory.PDF
|
|
289
288
|
].includes(typeInference.category);
|
|
290
289
|
}
|
|
291
290
|
},
|
|
@@ -309,8 +308,6 @@ import { PreviewCapability, dataSourceManager } from "./DataSourceStrategy";
|
|
|
309
308
|
return 'inline';
|
|
310
309
|
case FileCategory.PDF:
|
|
311
310
|
return 'inline';
|
|
312
|
-
case FileCategory.Archive:
|
|
313
|
-
return 'modal';
|
|
314
311
|
default:
|
|
315
312
|
return 'external';
|
|
316
313
|
}
|
|
@@ -209,7 +209,7 @@ var PlaceholderContent = function PlaceholderContent(param) {
|
|
|
209
209
|
}
|
|
210
210
|
return response.text();
|
|
211
211
|
}).then(setReadyContent).catch(function(err) {
|
|
212
|
-
var errorMessage = _instanceof(err, Error) ? err.message : '加载文本内容失败';
|
|
212
|
+
var errorMessage = _instanceof(err, Error) ? err.message : (locale === null || locale === void 0 ? void 0 : locale['common.loadTextFailed']) || '加载文本内容失败';
|
|
213
213
|
setContentState({
|
|
214
214
|
status: 'error',
|
|
215
215
|
error: errorMessage
|
|
@@ -326,13 +326,13 @@ var PlaceholderContent = function PlaceholderContent(param) {
|
|
|
326
326
|
className: classNames("".concat(filePrefixCls, "-item-time"), hashId)
|
|
327
327
|
}, formatLastModified(file.lastModified))))))), canDownload && onDownload && /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
|
|
328
328
|
className: classNames("".concat(prefixCls, "-unsupported-text"), hashId)
|
|
329
|
-
},
|
|
329
|
+
}, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.unsupportedPreview']) || '此文件无法预览,请下载查看。'), /*#__PURE__*/ React.createElement(Button, {
|
|
330
330
|
color: "default",
|
|
331
331
|
variant: "solid",
|
|
332
332
|
icon: /*#__PURE__*/ React.createElement(DownloadIcon, null),
|
|
333
333
|
onClick: handleDownload,
|
|
334
334
|
"aria-label": (locale === null || locale === void 0 ? void 0 : locale['workspace.file.download']) || '下载'
|
|
335
|
-
},
|
|
335
|
+
}, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.downloadButton']) || '下载'))));
|
|
336
336
|
}
|
|
337
337
|
var renderTextOrCode = function renderTextOrCode() {
|
|
338
338
|
if (isCurrentFileHtml) {
|
|
@@ -402,14 +402,14 @@ var PlaceholderContent = function PlaceholderContent(param) {
|
|
|
402
402
|
preload: "metadata"
|
|
403
403
|
}, /*#__PURE__*/ React.createElement("track", {
|
|
404
404
|
kind: "captions"
|
|
405
|
-
}),
|
|
405
|
+
}), (locale === null || locale === void 0 ? void 0 : locale['workspace.file.videoNotSupported']) || '您的浏览器不支持视频播放'),
|
|
406
406
|
audio: /*#__PURE__*/ React.createElement("audio", {
|
|
407
407
|
className: classNames("".concat(prefixCls, "-audio"), hashId),
|
|
408
408
|
src: dataSource.previewUrl,
|
|
409
409
|
controls: true,
|
|
410
410
|
controlsList: "nodownload",
|
|
411
411
|
preload: "metadata"
|
|
412
|
-
},
|
|
412
|
+
}, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.audioNotSupported']) || '您的浏览器不支持音频播放'),
|
|
413
413
|
pdf: /*#__PURE__*/ React.createElement("embed", {
|
|
414
414
|
className: classNames("".concat(prefixCls, "-pdf"), hashId),
|
|
415
415
|
src: dataSource.previewUrl,
|
|
@@ -437,7 +437,7 @@ var PlaceholderContent = function PlaceholderContent(param) {
|
|
|
437
437
|
locale: locale,
|
|
438
438
|
prefixCls: prefixCls,
|
|
439
439
|
hashId: hashId
|
|
440
|
-
}, /*#__PURE__*/ React.createElement("p", null, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.unknownFileType']) || '未知的文件类型'), /*#__PURE__*/ React.createElement("p", null,
|
|
440
|
+
}, /*#__PURE__*/ React.createElement("p", null, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.unknownFileType']) || '未知的文件类型'), /*#__PURE__*/ React.createElement("p", null, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.fileType']) || '文件类型:', typeInference.fileType));
|
|
441
441
|
}
|
|
442
442
|
};
|
|
443
443
|
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
@@ -3,3 +3,4 @@ export { PreviewComponent } from './PreviewComponent';
|
|
|
3
3
|
export type { PreviewComponentProps } from './PreviewComponent';
|
|
4
4
|
export type { FileActionRef, FileBuiltinActions, FileNode, FileProps, FileRenderContext, FileType, GroupNode, } from '../types';
|
|
5
5
|
export { getFileTypeIcon, getGroupIcon } from './utils';
|
|
6
|
+
export { getFileTypeName } from '../types';
|
|
@@ -57,7 +57,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
57
57
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
58
58
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
59
59
|
}
|
|
60
|
-
import { FileOther as DefaultFileIcon, FileAudio, FileCsv, FileDoc, FileFolders, FileMarkdown, FileOther, FilePdf, FilePic, FileVideo, FileXlsx, FileXml, FileZip } from "@sofa-design/icons";
|
|
60
|
+
import { FileOther as DefaultFileIcon, FileAudio, FileCsv, FileDoc, FileFolders, FileMarkdown, FileOther, FilePdf, FilePic, FilePpt, FileVideo, FileXlsx, FileXml, FileZip } from "@sofa-design/icons";
|
|
61
61
|
import React from "react";
|
|
62
62
|
import { FILE_TYPES, FileCategory, getFileCategory } from "../types";
|
|
63
63
|
// 文件扩展名到图标的映射
|
|
@@ -73,6 +73,8 @@ var EXTENSION_ICON_MAP = {
|
|
|
73
73
|
html: /*#__PURE__*/ React.createElement(FileXml, null),
|
|
74
74
|
md: /*#__PURE__*/ React.createElement(FileMarkdown, null),
|
|
75
75
|
markdown: /*#__PURE__*/ React.createElement(FileMarkdown, null),
|
|
76
|
+
ppt: /*#__PURE__*/ React.createElement(FilePpt, null),
|
|
77
|
+
pptx: /*#__PURE__*/ React.createElement(FilePpt, null),
|
|
76
78
|
zip: /*#__PURE__*/ React.createElement(FileZip, null),
|
|
77
79
|
rar: /*#__PURE__*/ React.createElement(FileZip, null),
|
|
78
80
|
'7z': /*#__PURE__*/ React.createElement(FileZip, null),
|
|
@@ -82,7 +84,7 @@ var EXTENSION_ICON_MAP = {
|
|
|
82
84
|
};
|
|
83
85
|
var _obj;
|
|
84
86
|
// 文件类型到默认图标的映射
|
|
85
|
-
var TYPE_ICON_MAP = (_obj = {}, _define_property(_obj, FileCategory.Text, /*#__PURE__*/ React.createElement(FileMarkdown, null)), _define_property(_obj, FileCategory.Code, /*#__PURE__*/ React.createElement(FileXml, null)), _define_property(_obj, FileCategory.PDF, /*#__PURE__*/ React.createElement(FilePdf, null)), _define_property(_obj, FileCategory.Word, /*#__PURE__*/ React.createElement(FileDoc, null)), _define_property(_obj, FileCategory.Excel, /*#__PURE__*/ React.createElement(FileXlsx, null)), _define_property(_obj, FileCategory.Image, /*#__PURE__*/ React.createElement(FilePic, null)), _define_property(_obj, FileCategory.Video, /*#__PURE__*/ React.createElement(FileVideo, null)), _define_property(_obj, FileCategory.Audio, /*#__PURE__*/ React.createElement(FileAudio, null)), _define_property(_obj, FileCategory.Archive, /*#__PURE__*/ React.createElement(FileZip, null)), _define_property(_obj, FileCategory.Other, /*#__PURE__*/ React.createElement(FileOther, null)), _obj);
|
|
87
|
+
var TYPE_ICON_MAP = (_obj = {}, _define_property(_obj, FileCategory.Text, /*#__PURE__*/ React.createElement(FileMarkdown, null)), _define_property(_obj, FileCategory.Code, /*#__PURE__*/ React.createElement(FileXml, null)), _define_property(_obj, FileCategory.PDF, /*#__PURE__*/ React.createElement(FilePdf, null)), _define_property(_obj, FileCategory.Word, /*#__PURE__*/ React.createElement(FileDoc, null)), _define_property(_obj, FileCategory.Excel, /*#__PURE__*/ React.createElement(FileXlsx, null)), _define_property(_obj, FileCategory.Presentation, /*#__PURE__*/ React.createElement(FilePpt, null)), _define_property(_obj, FileCategory.Image, /*#__PURE__*/ React.createElement(FilePic, null)), _define_property(_obj, FileCategory.Video, /*#__PURE__*/ React.createElement(FileVideo, null)), _define_property(_obj, FileCategory.Audio, /*#__PURE__*/ React.createElement(FileAudio, null)), _define_property(_obj, FileCategory.Archive, /*#__PURE__*/ React.createElement(FileZip, null)), _define_property(_obj, FileCategory.Other, /*#__PURE__*/ React.createElement(FileOther, null)), _obj);
|
|
86
88
|
/**
|
|
87
89
|
* 获取文件类型图标
|
|
88
90
|
*/ export var getFileTypeIcon = function getFileTypeIcon(type, customIcon, fileName) {
|
|
@@ -53,6 +53,7 @@ export declare enum FileCategory {
|
|
|
53
53
|
PDF = "pdf",
|
|
54
54
|
Word = "word",
|
|
55
55
|
Excel = "excel",
|
|
56
|
+
Presentation = "presentation",
|
|
56
57
|
Archive = "archive",
|
|
57
58
|
Other = "other"
|
|
58
59
|
}
|
|
@@ -60,7 +61,8 @@ export interface FileTypeDefinition {
|
|
|
60
61
|
category: FileCategory;
|
|
61
62
|
extensions: string[];
|
|
62
63
|
mimeTypes: string[];
|
|
63
|
-
name
|
|
64
|
+
/** Locale key for the file type display name (e.g. 'fileType.plainText') */
|
|
65
|
+
nameKey: string;
|
|
64
66
|
}
|
|
65
67
|
export declare const FILE_TYPES: Record<string, FileTypeDefinition>;
|
|
66
68
|
export type FileType = keyof typeof FILE_TYPES;
|
|
@@ -238,3 +240,8 @@ export interface CustomProps extends BaseChildProps {
|
|
|
238
240
|
export declare const getFileType: (filename: string) => FileType;
|
|
239
241
|
export declare const getMimeType: (fileType: FileType) => string;
|
|
240
242
|
export declare const getFileCategory: (fileType: FileType) => FileCategory;
|
|
243
|
+
/**
|
|
244
|
+
* Get the localized display name for a file type.
|
|
245
|
+
* Falls back to the nameKey itself when no locale is provided.
|
|
246
|
+
*/
|
|
247
|
+
export declare const getFileTypeName: (fileType: FileType, locale?: Record<string, string>) => string;
|
package/dist/Workspace/types.js
CHANGED
|
@@ -44,7 +44,6 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
44
44
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
45
45
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
46
46
|
}
|
|
47
|
-
// ... (rest of the file content unchanged)
|
|
48
47
|
// 文件类型分类
|
|
49
48
|
export var FileCategory = /*#__PURE__*/ function(FileCategory) {
|
|
50
49
|
FileCategory["Text"] = "text";
|
|
@@ -55,6 +54,7 @@ export var FileCategory = /*#__PURE__*/ function(FileCategory) {
|
|
|
55
54
|
FileCategory["PDF"] = "pdf";
|
|
56
55
|
FileCategory["Word"] = "word";
|
|
57
56
|
FileCategory["Excel"] = "excel";
|
|
57
|
+
FileCategory["Presentation"] = "presentation";
|
|
58
58
|
FileCategory["Archive"] = "archive";
|
|
59
59
|
FileCategory["Other"] = "other";
|
|
60
60
|
return FileCategory;
|
|
@@ -69,7 +69,7 @@ export var FILE_TYPES = {
|
|
|
69
69
|
mimeTypes: [
|
|
70
70
|
'text/plain'
|
|
71
71
|
],
|
|
72
|
-
|
|
72
|
+
nameKey: 'fileType.plainText'
|
|
73
73
|
},
|
|
74
74
|
markdown: {
|
|
75
75
|
category: "text",
|
|
@@ -80,7 +80,7 @@ export var FILE_TYPES = {
|
|
|
80
80
|
mimeTypes: [
|
|
81
81
|
'text/markdown'
|
|
82
82
|
],
|
|
83
|
-
|
|
83
|
+
nameKey: 'markdown'
|
|
84
84
|
},
|
|
85
85
|
image: {
|
|
86
86
|
category: "image",
|
|
@@ -101,21 +101,33 @@ export var FILE_TYPES = {
|
|
|
101
101
|
'image/webp',
|
|
102
102
|
'image/svg+xml'
|
|
103
103
|
],
|
|
104
|
-
|
|
104
|
+
nameKey: 'fileType.image'
|
|
105
105
|
},
|
|
106
106
|
video: {
|
|
107
107
|
category: "video",
|
|
108
108
|
extensions: [
|
|
109
109
|
'mp4',
|
|
110
110
|
'webm',
|
|
111
|
-
'
|
|
111
|
+
'ogv',
|
|
112
|
+
'mov',
|
|
113
|
+
'avi',
|
|
114
|
+
'mkv',
|
|
115
|
+
'flv',
|
|
116
|
+
'3gp',
|
|
117
|
+
'm4v'
|
|
112
118
|
],
|
|
113
119
|
mimeTypes: [
|
|
114
120
|
'video/mp4',
|
|
115
121
|
'video/webm',
|
|
116
|
-
'video/ogg'
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
'video/ogg',
|
|
123
|
+
'video/quicktime',
|
|
124
|
+
'video/x-msvideo',
|
|
125
|
+
'video/x-matroska',
|
|
126
|
+
'video/x-flv',
|
|
127
|
+
'video/3gpp',
|
|
128
|
+
'video/x-m4v'
|
|
129
|
+
],
|
|
130
|
+
nameKey: 'fileType.video'
|
|
119
131
|
},
|
|
120
132
|
audio: {
|
|
121
133
|
category: "audio",
|
|
@@ -124,16 +136,22 @@ export var FILE_TYPES = {
|
|
|
124
136
|
'wav',
|
|
125
137
|
'ogg',
|
|
126
138
|
'aac',
|
|
127
|
-
'm4a'
|
|
139
|
+
'm4a',
|
|
140
|
+
'flac',
|
|
141
|
+
'wma',
|
|
142
|
+
'opus'
|
|
128
143
|
],
|
|
129
144
|
mimeTypes: [
|
|
130
145
|
'audio/mpeg',
|
|
131
146
|
'audio/wav',
|
|
132
147
|
'audio/ogg',
|
|
133
148
|
'audio/aac',
|
|
134
|
-
'audio/mp4'
|
|
149
|
+
'audio/mp4',
|
|
150
|
+
'audio/flac',
|
|
151
|
+
'audio/x-ms-wma',
|
|
152
|
+
'audio/opus'
|
|
135
153
|
],
|
|
136
|
-
|
|
154
|
+
nameKey: 'fileType.audio'
|
|
137
155
|
},
|
|
138
156
|
pdf: {
|
|
139
157
|
category: "pdf",
|
|
@@ -143,7 +161,7 @@ export var FILE_TYPES = {
|
|
|
143
161
|
mimeTypes: [
|
|
144
162
|
'application/pdf'
|
|
145
163
|
],
|
|
146
|
-
|
|
164
|
+
nameKey: 'fileType.pdf'
|
|
147
165
|
},
|
|
148
166
|
word: {
|
|
149
167
|
category: "word",
|
|
@@ -155,7 +173,7 @@ export var FILE_TYPES = {
|
|
|
155
173
|
'application/msword',
|
|
156
174
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
|
157
175
|
],
|
|
158
|
-
|
|
176
|
+
nameKey: 'fileType.word'
|
|
159
177
|
},
|
|
160
178
|
excel: {
|
|
161
179
|
category: "excel",
|
|
@@ -167,7 +185,7 @@ export var FILE_TYPES = {
|
|
|
167
185
|
'application/vnd.ms-excel',
|
|
168
186
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
169
187
|
],
|
|
170
|
-
|
|
188
|
+
nameKey: 'fileType.excel'
|
|
171
189
|
},
|
|
172
190
|
csv: {
|
|
173
191
|
category: "excel",
|
|
@@ -179,7 +197,19 @@ export var FILE_TYPES = {
|
|
|
179
197
|
'application/csv',
|
|
180
198
|
'application/vnd.ms-excel'
|
|
181
199
|
],
|
|
182
|
-
|
|
200
|
+
nameKey: 'fileType.csv'
|
|
201
|
+
},
|
|
202
|
+
powerpoint: {
|
|
203
|
+
category: "presentation",
|
|
204
|
+
extensions: [
|
|
205
|
+
'ppt',
|
|
206
|
+
'pptx'
|
|
207
|
+
],
|
|
208
|
+
mimeTypes: [
|
|
209
|
+
'application/vnd.ms-powerpoint',
|
|
210
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
|
|
211
|
+
],
|
|
212
|
+
nameKey: 'fileType.powerpoint'
|
|
183
213
|
},
|
|
184
214
|
archive: {
|
|
185
215
|
category: "archive",
|
|
@@ -199,7 +229,7 @@ export var FILE_TYPES = {
|
|
|
199
229
|
'application/gzip',
|
|
200
230
|
'application/x-bzip2'
|
|
201
231
|
],
|
|
202
|
-
|
|
232
|
+
nameKey: 'fileType.archive'
|
|
203
233
|
},
|
|
204
234
|
// 代码文件类型
|
|
205
235
|
javascript: {
|
|
@@ -213,7 +243,7 @@ export var FILE_TYPES = {
|
|
|
213
243
|
'text/javascript',
|
|
214
244
|
'application/javascript'
|
|
215
245
|
],
|
|
216
|
-
|
|
246
|
+
nameKey: 'javascript'
|
|
217
247
|
},
|
|
218
248
|
typescript: {
|
|
219
249
|
category: "code",
|
|
@@ -224,7 +254,7 @@ export var FILE_TYPES = {
|
|
|
224
254
|
'text/typescript',
|
|
225
255
|
'application/typescript'
|
|
226
256
|
],
|
|
227
|
-
|
|
257
|
+
nameKey: 'typescript'
|
|
228
258
|
},
|
|
229
259
|
react: {
|
|
230
260
|
category: "code",
|
|
@@ -236,7 +266,7 @@ export var FILE_TYPES = {
|
|
|
236
266
|
'text/jsx',
|
|
237
267
|
'text/tsx'
|
|
238
268
|
],
|
|
239
|
-
|
|
269
|
+
nameKey: 'react'
|
|
240
270
|
},
|
|
241
271
|
python: {
|
|
242
272
|
category: "code",
|
|
@@ -249,7 +279,7 @@ export var FILE_TYPES = {
|
|
|
249
279
|
'text/x-python',
|
|
250
280
|
'application/x-python-code'
|
|
251
281
|
],
|
|
252
|
-
|
|
282
|
+
nameKey: 'python'
|
|
253
283
|
},
|
|
254
284
|
java: {
|
|
255
285
|
category: "code",
|
|
@@ -259,7 +289,7 @@ export var FILE_TYPES = {
|
|
|
259
289
|
mimeTypes: [
|
|
260
290
|
'text/x-java-source'
|
|
261
291
|
],
|
|
262
|
-
|
|
292
|
+
nameKey: 'java'
|
|
263
293
|
},
|
|
264
294
|
cpp: {
|
|
265
295
|
category: "code",
|
|
@@ -276,7 +306,7 @@ export var FILE_TYPES = {
|
|
|
276
306
|
'text/x-c++src',
|
|
277
307
|
'text/x-c++hdr'
|
|
278
308
|
],
|
|
279
|
-
|
|
309
|
+
nameKey: 'c++'
|
|
280
310
|
},
|
|
281
311
|
c: {
|
|
282
312
|
category: "code",
|
|
@@ -288,7 +318,7 @@ export var FILE_TYPES = {
|
|
|
288
318
|
'text/x-csrc',
|
|
289
319
|
'text/x-chdr'
|
|
290
320
|
],
|
|
291
|
-
|
|
321
|
+
nameKey: 'c'
|
|
292
322
|
},
|
|
293
323
|
csharp: {
|
|
294
324
|
category: "code",
|
|
@@ -298,7 +328,7 @@ export var FILE_TYPES = {
|
|
|
298
328
|
mimeTypes: [
|
|
299
329
|
'text/x-csharp'
|
|
300
330
|
],
|
|
301
|
-
|
|
331
|
+
nameKey: 'c#'
|
|
302
332
|
},
|
|
303
333
|
go: {
|
|
304
334
|
category: "code",
|
|
@@ -308,7 +338,7 @@ export var FILE_TYPES = {
|
|
|
308
338
|
mimeTypes: [
|
|
309
339
|
'text/x-go'
|
|
310
340
|
],
|
|
311
|
-
|
|
341
|
+
nameKey: 'go'
|
|
312
342
|
},
|
|
313
343
|
rust: {
|
|
314
344
|
category: "code",
|
|
@@ -318,7 +348,7 @@ export var FILE_TYPES = {
|
|
|
318
348
|
mimeTypes: [
|
|
319
349
|
'text/x-rust'
|
|
320
350
|
],
|
|
321
|
-
|
|
351
|
+
nameKey: 'rust'
|
|
322
352
|
},
|
|
323
353
|
php: {
|
|
324
354
|
category: "code",
|
|
@@ -333,7 +363,7 @@ export var FILE_TYPES = {
|
|
|
333
363
|
'text/x-php',
|
|
334
364
|
'application/x-httpd-php'
|
|
335
365
|
],
|
|
336
|
-
|
|
366
|
+
nameKey: 'php'
|
|
337
367
|
},
|
|
338
368
|
ruby: {
|
|
339
369
|
category: "code",
|
|
@@ -344,7 +374,7 @@ export var FILE_TYPES = {
|
|
|
344
374
|
mimeTypes: [
|
|
345
375
|
'text/x-ruby'
|
|
346
376
|
],
|
|
347
|
-
|
|
377
|
+
nameKey: 'ruby'
|
|
348
378
|
},
|
|
349
379
|
shell: {
|
|
350
380
|
category: "code",
|
|
@@ -358,7 +388,7 @@ export var FILE_TYPES = {
|
|
|
358
388
|
'text/x-shellscript',
|
|
359
389
|
'application/x-sh'
|
|
360
390
|
],
|
|
361
|
-
|
|
391
|
+
nameKey: 'fileType.shell'
|
|
362
392
|
},
|
|
363
393
|
powershell: {
|
|
364
394
|
category: "code",
|
|
@@ -370,7 +400,7 @@ export var FILE_TYPES = {
|
|
|
370
400
|
mimeTypes: [
|
|
371
401
|
'text/x-powershell'
|
|
372
402
|
],
|
|
373
|
-
|
|
403
|
+
nameKey: 'powershell'
|
|
374
404
|
},
|
|
375
405
|
sql: {
|
|
376
406
|
category: "code",
|
|
@@ -381,7 +411,7 @@ export var FILE_TYPES = {
|
|
|
381
411
|
'text/x-sql',
|
|
382
412
|
'application/sql'
|
|
383
413
|
],
|
|
384
|
-
|
|
414
|
+
nameKey: 'sql'
|
|
385
415
|
},
|
|
386
416
|
lua: {
|
|
387
417
|
category: "code",
|
|
@@ -391,7 +421,7 @@ export var FILE_TYPES = {
|
|
|
391
421
|
mimeTypes: [
|
|
392
422
|
'text/x-lua'
|
|
393
423
|
],
|
|
394
|
-
|
|
424
|
+
nameKey: 'lua'
|
|
395
425
|
},
|
|
396
426
|
perl: {
|
|
397
427
|
category: "code",
|
|
@@ -403,7 +433,7 @@ export var FILE_TYPES = {
|
|
|
403
433
|
mimeTypes: [
|
|
404
434
|
'text/x-perl'
|
|
405
435
|
],
|
|
406
|
-
|
|
436
|
+
nameKey: 'perl'
|
|
407
437
|
},
|
|
408
438
|
scala: {
|
|
409
439
|
category: "code",
|
|
@@ -414,7 +444,7 @@ export var FILE_TYPES = {
|
|
|
414
444
|
mimeTypes: [
|
|
415
445
|
'text/x-scala'
|
|
416
446
|
],
|
|
417
|
-
|
|
447
|
+
nameKey: 'scala'
|
|
418
448
|
},
|
|
419
449
|
config: {
|
|
420
450
|
category: "code",
|
|
@@ -436,7 +466,7 @@ export var FILE_TYPES = {
|
|
|
436
466
|
'text/plain',
|
|
437
467
|
'application/x-wine-extension-ini'
|
|
438
468
|
],
|
|
439
|
-
|
|
469
|
+
nameKey: 'fileType.config'
|
|
440
470
|
}
|
|
441
471
|
};
|
|
442
472
|
// 工具函数
|
|
@@ -474,3 +504,12 @@ export var getFileCategory = function getFileCategory(fileType) {
|
|
|
474
504
|
var _FILE_TYPES_fileType;
|
|
475
505
|
return FILE_TYPES === null || FILE_TYPES === void 0 ? void 0 : (_FILE_TYPES_fileType = FILE_TYPES[fileType]) === null || _FILE_TYPES_fileType === void 0 ? void 0 : _FILE_TYPES_fileType.category;
|
|
476
506
|
};
|
|
507
|
+
/**
|
|
508
|
+
* Get the localized display name for a file type.
|
|
509
|
+
* Falls back to the nameKey itself when no locale is provided.
|
|
510
|
+
*/ export var getFileTypeName = function getFileTypeName(fileType, locale) {
|
|
511
|
+
var _ref;
|
|
512
|
+
var definition = FILE_TYPES[fileType];
|
|
513
|
+
if (!definition) return fileType;
|
|
514
|
+
return (_ref = locale === null || locale === void 0 ? void 0 : locale[definition.nameKey]) !== null && _ref !== void 0 ? _ref : definition.nameKey;
|
|
515
|
+
};
|