@ai-group/chat-sdk 3.0.3 → 3.0.5

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 (42) hide show
  1. package/dist/cjs/components/FileGallery/FileGallery.stories.d.ts +6 -0
  2. package/dist/cjs/components/FileGallery/FileGallery.stories.js +143 -0
  3. package/dist/cjs/components/FileGallery/FileGallery.stories.js.map +7 -0
  4. package/dist/cjs/components/FileGallery/index.d.ts +13 -12
  5. package/dist/cjs/components/FileGallery/index.js +165 -159
  6. package/dist/cjs/components/FileGallery/index.js.map +2 -2
  7. package/dist/cjs/components/FileGallery/styles.js +5 -0
  8. package/dist/cjs/components/FileGallery/styles.js.map +2 -2
  9. package/dist/cjs/components/XAdkChatbot/XAdkChatbot.stories.js +18 -9
  10. package/dist/cjs/components/XAdkChatbot/XAdkChatbot.stories.js.map +2 -2
  11. package/dist/cjs/components/XAdkChatbot/index.js +11 -3
  12. package/dist/cjs/components/XAdkChatbot/index.js.map +2 -2
  13. package/dist/cjs/components/XAdkChatbot/styles.d.ts +1 -0
  14. package/dist/cjs/components/XAdkChatbot/styles.js +7 -0
  15. package/dist/cjs/components/XAdkChatbot/styles.js.map +2 -2
  16. package/dist/cjs/components/XAdkSender/index.js +24 -13
  17. package/dist/cjs/components/XAdkSender/index.js.map +2 -2
  18. package/dist/cjs/types/FileGallery.d.ts +1 -21
  19. package/dist/cjs/types/FileGallery.js.map +1 -1
  20. package/dist/cjs/types/XAdkSender.js.map +1 -1
  21. package/dist/esm/components/FileGallery/FileGallery.stories.d.ts +6 -0
  22. package/dist/esm/components/FileGallery/FileGallery.stories.js +48 -0
  23. package/dist/esm/components/FileGallery/FileGallery.stories.js.map +1 -0
  24. package/dist/esm/components/FileGallery/index.d.ts +13 -12
  25. package/dist/esm/components/FileGallery/index.js +48 -69
  26. package/dist/esm/components/FileGallery/index.js.map +1 -1
  27. package/dist/esm/components/FileGallery/styles.js +1 -1
  28. package/dist/esm/components/FileGallery/styles.js.map +1 -1
  29. package/dist/esm/components/XAdkChatbot/XAdkChatbot.stories.js +17 -13
  30. package/dist/esm/components/XAdkChatbot/XAdkChatbot.stories.js.map +1 -1
  31. package/dist/esm/components/XAdkChatbot/index.js +23 -6
  32. package/dist/esm/components/XAdkChatbot/index.js.map +1 -1
  33. package/dist/esm/components/XAdkChatbot/styles.d.ts +1 -0
  34. package/dist/esm/components/XAdkChatbot/styles.js +21 -20
  35. package/dist/esm/components/XAdkChatbot/styles.js.map +1 -1
  36. package/dist/esm/components/XAdkSender/index.js +30 -17
  37. package/dist/esm/components/XAdkSender/index.js.map +1 -1
  38. package/dist/esm/types/FileGallery.d.ts +1 -21
  39. package/dist/esm/types/FileGallery.js.map +1 -1
  40. package/dist/esm/types/XAdkSender.js.map +1 -1
  41. package/dist/umd/chat-sdk.min.js +1 -1
  42. package/package.json +1 -1
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import FileGallery from "./index";
3
+ declare const meta: Meta<typeof FileGallery>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const 基础用法: Story;
@@ -0,0 +1,143 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/FileGallery/FileGallery.stories.tsx
30
+ var FileGallery_stories_exports = {};
31
+ __export(FileGallery_stories_exports, {
32
+ default: () => FileGallery_stories_default,
33
+ 基础用法: () => 基础用法
34
+ });
35
+ module.exports = __toCommonJS(FileGallery_stories_exports);
36
+ var import_index = __toESM(require("./index"));
37
+ var import_jsx_runtime = require("react/jsx-runtime");
38
+ var meta = {
39
+ title: "AI组件/FileGallery 附件卡片",
40
+ component: import_index.default,
41
+ parameters: {
42
+ layout: "padded",
43
+ docs: {
44
+ description: {
45
+ component: `
46
+
47
+ 一个通用的单文件展示组件,类似 antd-design-x 的设计风格,支持多种文件类型的展示和交互。
48
+
49
+ ## ✨ 特性
50
+
51
+ - 📁 支持多种文件类型展示 (图片、音频、视频、文档等)
52
+ - 🖼️ 图片支持预览和缩略图
53
+ - 🎵 音频文件支持内联播放
54
+ - 🎬 视频文件支持内联播放
55
+ - 📊 显示文件大小、类型图标
56
+ - 🗑️ 支持删除操作
57
+ - 📤 支持上传进度显示
58
+ - 🎯 单文件设计,布局灵活可控
59
+ - 🎨 支持卡片内部布局控制(图标在左/右)
60
+
61
+ ## 🎨 支持的文件类型
62
+
63
+ ### 图片 (带预览)
64
+
65
+ - jpg, jpeg, png, gif, webp, bmp, svg
66
+
67
+ ### 音频 (内联播放)
68
+
69
+ - mp3, wav, m4a, aac, ogg, flac
70
+
71
+ ### 视频 (内联播放)
72
+
73
+ - mp4, mov, webm, mkv, avi
74
+
75
+ ### 文档 (图标展示)
76
+
77
+ - PDF: pdf
78
+ - Word: doc, docx
79
+ - Excel: xls, xlsx, csv
80
+ - PowerPoint: ppt, pptx
81
+ - 其他: 通用文件图标
82
+
83
+ ## 📝 Props 说明
84
+
85
+ | 属性 | 类型 | 默认值 | 说明 |
86
+ | --------- | --------------------- | ------ | ------------------------------------------ |
87
+ | file | FileItem | - | 文件对象(必需) |
88
+ | align | "left" | "right" | "left" | 卡片内部布局:图标在左(left)或右(right) |
89
+ | removable | boolean | false | 是否显示删除按钮 |
90
+ | onRemove | (id: string) => void | - | 删除文件回调 |
91
+ | className | string | - | 自定义样式类名 |
92
+ | style | React.CSSProperties | - | 自定义样式 |
93
+
94
+
95
+ ## 💡 设计理念
96
+
97
+ ### 为什么是单文件设计?
98
+
99
+ 1. **布局灵活性**:上层组件可以自由控制文件列表的布局方式(flex、grid、水平、垂直等)
100
+ 2. **对齐控制**:通过容器的 CSS 控制整个列表的对齐方式,而非组件内部控制
101
+ 3. **责任单一**:组件专注于单个文件的展示,不关心列表布局
102
+ 4. **易于扩展**:可以轻松插入其他元素(如分隔符、标签等)
103
+ `
104
+ }
105
+ }
106
+ },
107
+ tags: ["autodocs"],
108
+ argTypes: {}
109
+ };
110
+ var FileGallery_stories_default = meta;
111
+ var 基础用法 = {
112
+ render: () => {
113
+ const remoteFiles = [
114
+ {
115
+ displayName: "report.xlsx",
116
+ mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
117
+ fileUri: "https://example.com/report.xlsx"
118
+ },
119
+ {
120
+ displayName: "photo.png",
121
+ mimeType: "image/png",
122
+ fileUri: "https://example.com/photo.png"
123
+ }
124
+ ];
125
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
126
+ "div",
127
+ {
128
+ style: {
129
+ display: "flex",
130
+ flexWrap: "wrap",
131
+ gap: "8px",
132
+ justifyContent: "flex-start"
133
+ },
134
+ children: remoteFiles.map((file, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_index.default, { file, align: "left" }, index))
135
+ }
136
+ );
137
+ }
138
+ };
139
+ // Annotate the CommonJS export names for ESM import in node:
140
+ 0 && (module.exports = {
141
+ 基础用法
142
+ });
143
+ //# sourceMappingURL=FileGallery.stories.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/components/FileGallery/FileGallery.stories.tsx"],
4
+ "sourcesContent": ["import type { Meta, StoryObj } from \"@storybook/react-vite\";\nimport FileGallery from \"./index\";\n\nconst meta: Meta<typeof FileGallery> = {\n title: \"AI组件/FileGallery 附件卡片\",\n component: FileGallery,\n parameters: {\n layout: \"padded\",\n docs: {\n description: {\n component: `\n\n一个通用的单文件展示组件,类似 antd-design-x 的设计风格,支持多种文件类型的展示和交互。\n\n## ✨ 特性\n\n- 📁 支持多种文件类型展示 (图片、音频、视频、文档等)\n- 🖼️ 图片支持预览和缩略图\n- 🎵 音频文件支持内联播放\n- 🎬 视频文件支持内联播放\n- 📊 显示文件大小、类型图标\n- 🗑️ 支持删除操作\n- 📤 支持上传进度显示\n- 🎯 单文件设计,布局灵活可控\n- 🎨 支持卡片内部布局控制(图标在左/右)\n\n## 🎨 支持的文件类型\n\n### 图片 (带预览)\n\n- jpg, jpeg, png, gif, webp, bmp, svg\n\n### 音频 (内联播放)\n\n- mp3, wav, m4a, aac, ogg, flac\n\n### 视频 (内联播放)\n\n- mp4, mov, webm, mkv, avi\n\n### 文档 (图标展示)\n\n- PDF: pdf\n- Word: doc, docx\n- Excel: xls, xlsx, csv\n- PowerPoint: ppt, pptx\n- 其他: 通用文件图标\n\n## 📝 Props 说明\n\n| 属性 | 类型 | 默认值 | 说明 |\n| --------- | --------------------- | ------ | ------------------------------------------ |\n| file | FileItem | - | 文件对象(必需) |\n| align | \"left\" \\| \"right\" | \"left\" | 卡片内部布局:图标在左(left)或右(right) |\n| removable | boolean | false | 是否显示删除按钮 |\n| onRemove | (id: string) => void | - | 删除文件回调 |\n| className | string | - | 自定义样式类名 |\n| style | React.CSSProperties | - | 自定义样式 |\n\n\n## 💡 设计理念\n\n### 为什么是单文件设计?\n\n1. **布局灵活性**:上层组件可以自由控制文件列表的布局方式(flex、grid、水平、垂直等)\n2. **对齐控制**:通过容器的 CSS 控制整个列表的对齐方式,而非组件内部控制\n3. **责任单一**:组件专注于单个文件的展示,不关心列表布局\n4. **易于扩展**:可以轻松插入其他元素(如分隔符、标签等)\n `,\n },\n },\n },\n tags: [\"autodocs\"],\n argTypes: {},\n};\n\nexport default meta;\ntype Story = StoryObj<typeof meta>;\n\n// ============================================\n// 示例 1: 基础用法\n// ============================================\nexport const 基础用法: Story = {\n render: () => {\n const remoteFiles = [\n {\n displayName: \"report.xlsx\",\n mimeType:\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n fileUri: \"https://example.com/report.xlsx\",\n },\n {\n displayName: \"photo.png\",\n mimeType: \"image/png\",\n fileUri: \"https://example.com/photo.png\",\n },\n ];\n\n return (\n <div\n style={{\n display: \"flex\",\n flexWrap: \"wrap\",\n gap: \"8px\",\n justifyContent: \"flex-start\",\n }}\n >\n {remoteFiles.map((file, index) => (\n <FileGallery key={index} file={file} align=\"left\" />\n ))}\n </div>\n );\n },\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAwB;AA2Gd;AAzGV,IAAM,OAAiC;AAAA,EACrC,OAAO;AAAA,EACP,WAAW,aAAAA;AAAA,EACX,YAAY;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,aAAa;AAAA,QACX,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MA2Db;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM,CAAC,UAAU;AAAA,EACjB,UAAU,CAAC;AACb;AAEA,IAAO,8BAAQ;AAMR,IAAM,OAAc;AAAA,EACzB,QAAQ,MAAM;AACZ,UAAM,cAAc;AAAA,MAClB;AAAA,QACE,aAAa;AAAA,QACb,UACE;AAAA,QACF,SAAS;AAAA,MACX;AAAA,MACA;AAAA,QACE,aAAa;AAAA,QACb,UAAU;AAAA,QACV,SAAS;AAAA,MACX;AAAA,IACF;AAEA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,UACL,SAAS;AAAA,UACT,UAAU;AAAA,UACV,KAAK;AAAA,UACL,gBAAgB;AAAA,QAClB;AAAA,QAEC,sBAAY,IAAI,CAAC,MAAM,UACtB,4CAAC,aAAAA,SAAA,EAAwB,MAAY,OAAM,UAAzB,KAAgC,CACnD;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;",
6
+ "names": ["FileGallery"]
7
+ }
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { FileGalleryProps } from "../../types";
3
3
  /**
4
- * FileGallery - 通用文件展示组件
4
+ * FileGallery - 单文件展示组件
5
5
  *
6
6
  * 功能特性:
7
7
  * - 📁 支持多种文件类型展示 (图片、音频、视频、文档等)
@@ -11,23 +11,24 @@ import { FileGalleryProps } from "../../types";
11
11
  * - 📊 显示文件大小、类型图标
12
12
  * - 🗑️ 支持删除操作
13
13
  * - 📤 支持上传进度显示
14
- * - 🎨 支持左右对齐
14
+ * - 🎨 支持卡片内部布局控制(align:图标和信息的排列方式)
15
15
  *
16
16
  * @example
17
17
  * // XAdkSender 场景 - 可删除的本地文件
18
- * <FileGallery
19
- * files={localFiles}
20
- * removable
21
- * onRemove={handleRemove}
22
- * align="left"
23
- * />
18
+ * {files.map(file => (
19
+ * <FileGallery
20
+ * key={file.id}
21
+ * file={file}
22
+ * removable
23
+ * onRemove={handleRemove}
24
+ * />
25
+ * ))}
24
26
  *
25
27
  * @example
26
28
  * // XadkChatbot 场景 - 只读的远程文件
27
- * <FileGallery
28
- * files={remoteFiles}
29
- * align="right"
30
- * />
29
+ * {files.map(file => (
30
+ * <FileGallery key={file.id} file={file} />
31
+ * ))}
31
32
  */
32
33
  declare const FileGallery: React.FC<FileGalleryProps>;
33
34
  export default FileGallery;
@@ -106,10 +106,14 @@ var formatFileSize = (bytes) => {
106
106
  return (bytes / (1024 * 1024)).toFixed(1) + " MB";
107
107
  };
108
108
  var styles = (0, import_styles.useStyles)();
109
- var FileItemComponent = ({
109
+ var FileGallery = ({
110
110
  file,
111
- removable,
112
- onRemove
111
+ align = "left",
112
+ removable = false,
113
+ onRemove = () => {
114
+ },
115
+ className,
116
+ style
113
117
  }) => {
114
118
  const [objectUrl, setObjectUrl] = (0, import_react.useState)("");
115
119
  (0, import_react.useEffect)(() => {
@@ -119,6 +123,8 @@ var FileItemComponent = ({
119
123
  setObjectUrl(url2);
120
124
  return () => URL.revokeObjectURL(url2);
121
125
  }, [file.file]);
126
+ if (!file)
127
+ return null;
122
128
  const isImage = isImageFile(file);
123
129
  const isAudio = isAudioFile(file);
124
130
  const isVideo = isVideoFile(file);
@@ -127,173 +133,173 @@ var FileItemComponent = ({
127
133
  const fileId = getFileId(file);
128
134
  const url = getFileUrl(file) || objectUrl;
129
135
  if (isImage) {
130
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileCard, children: [
131
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.imageThumbnail, children: [
132
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
133
- import_antd.Image,
134
- {
135
- src: url,
136
- alt: fileName,
137
- fallback: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==",
138
- preview: {
139
- src: url
136
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
137
+ "div",
138
+ {
139
+ className: `${styles.fileCard} ${align === "right" ? "align-right" : ""} ${className || ""}`,
140
+ style,
141
+ children: [
142
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.imageThumbnail, children: [
143
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
144
+ import_antd.Image,
145
+ {
146
+ src: url,
147
+ alt: fileName,
148
+ fallback: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==",
149
+ preview: {
150
+ src: url
151
+ }
152
+ }
153
+ ),
154
+ file.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.imageOverlay, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
155
+ import_antd.Progress,
156
+ {
157
+ type: "circle",
158
+ percent: file.progress,
159
+ size: 30,
160
+ strokeColor: "#1677ff"
161
+ }
162
+ ) })
163
+ ] }),
164
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileInfo, children: [
165
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileName, children: fileName.length > 15 ? `${fileName.substring(0, 15)}...` : fileName }) }),
166
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileSize, children: formatFileSize(fileSize) })
167
+ ] }),
168
+ removable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
169
+ "button",
170
+ {
171
+ className: styles.fileRemoveBtn,
172
+ onClick: () => onRemove(fileId),
173
+ disabled: file.status === "uploading",
174
+ "aria-label": "删除文件",
175
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseOutlined, {})
140
176
  }
141
- }
142
- ),
143
- file.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.imageOverlay, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
144
- import_antd.Progress,
145
- {
146
- type: "circle",
147
- percent: file.progress,
148
- size: 30,
149
- strokeColor: "#1677ff"
150
- }
151
- ) })
152
- ] }),
153
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileInfo, children: [
154
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileName, children: fileName.length > 15 ? `${fileName.substring(0, 15)}...` : fileName }) }),
155
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileSize, children: formatFileSize(fileSize) })
156
- ] }),
157
- removable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
158
- "button",
159
- {
160
- className: styles.fileRemoveBtn,
161
- onClick: () => onRemove(fileId),
162
- disabled: file.status === "uploading",
163
- "aria-label": "删除文件",
164
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseOutlined, {})
165
- }
166
- )
167
- ] });
177
+ )
178
+ ]
179
+ }
180
+ );
168
181
  }
169
182
  if (isAudio) {
170
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileCard, children: [
171
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileIcon, style: { color: "#722ed1" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.AudioOutlined, {}) }),
172
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileInfo, children: [
173
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileName, children: fileName }) }),
174
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
175
- "audio",
176
- {
177
- src: url,
178
- controls: true,
179
- className: styles.mediaWrapper,
180
- style: { width: "100%", height: 28 }
181
- }
182
- )
183
- ] }),
184
- removable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
185
- "button",
186
- {
187
- className: styles.fileRemoveBtn,
188
- onClick: () => onRemove(fileId),
189
- disabled: file.status === "uploading",
190
- "aria-label": "删除文件",
191
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseOutlined, {})
192
- }
193
- )
194
- ] });
183
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
184
+ "div",
185
+ {
186
+ className: `${styles.fileCard} ${align === "right" ? "align-right" : ""} ${className || ""}`,
187
+ style,
188
+ children: [
189
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileIcon, style: { color: "#722ed1" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.AudioOutlined, {}) }),
190
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileInfo, children: [
191
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileName, children: fileName }) }),
192
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
193
+ "audio",
194
+ {
195
+ src: url,
196
+ controls: true,
197
+ className: styles.mediaWrapper,
198
+ style: { width: "100%", height: 28 }
199
+ }
200
+ )
201
+ ] }),
202
+ removable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
203
+ "button",
204
+ {
205
+ className: styles.fileRemoveBtn,
206
+ onClick: () => onRemove(fileId),
207
+ disabled: file.status === "uploading",
208
+ "aria-label": "删除文件",
209
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseOutlined, {})
210
+ }
211
+ )
212
+ ]
213
+ }
214
+ );
195
215
  }
196
216
  if (isVideo) {
197
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileCard, children: [
198
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileIcon, style: { color: "#fa8c16" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.VideoCameraOutlined, {}) }),
199
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileInfo, children: [
200
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileName, children: fileName }) }),
201
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
202
- "video",
203
- {
204
- src: url,
205
- controls: true,
206
- className: styles.mediaWrapper,
207
- style: { width: "100%", height: 40 }
208
- }
209
- )
210
- ] }),
211
- removable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
212
- "button",
213
- {
214
- className: styles.fileRemoveBtn,
215
- onClick: () => onRemove(fileId),
216
- disabled: file.status === "uploading",
217
- "aria-label": "删除文件",
218
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseOutlined, {})
219
- }
220
- )
221
- ] });
217
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
218
+ "div",
219
+ {
220
+ className: `${styles.fileCard} ${align === "right" ? "align-right" : ""} ${className || ""}`,
221
+ style,
222
+ children: [
223
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileIcon, style: { color: "#fa8c16" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.VideoCameraOutlined, {}) }),
224
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileInfo, children: [
225
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileName, children: fileName }) }),
226
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
227
+ "video",
228
+ {
229
+ src: url,
230
+ controls: true,
231
+ className: styles.mediaWrapper,
232
+ style: { width: "100%", height: 40 }
233
+ }
234
+ )
235
+ ] }),
236
+ removable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
237
+ "button",
238
+ {
239
+ className: styles.fileRemoveBtn,
240
+ onClick: () => onRemove(fileId),
241
+ disabled: file.status === "uploading",
242
+ "aria-label": "删除文件",
243
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseOutlined, {})
244
+ }
245
+ )
246
+ ]
247
+ }
248
+ );
222
249
  }
223
250
  const { icon, color } = getFileIcon(file);
224
251
  const isExternalUrl = url && url.startsWith("http");
225
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileCard, children: [
226
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileIcon, style: { color }, children: icon }),
227
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileInfo, children: [
228
- isExternalUrl ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
229
- "a",
230
- {
231
- href: url,
232
- target: "_blank",
233
- rel: "noopener noreferrer",
234
- className: styles.fileLink,
235
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileName, children: fileName.length > 15 ? `${fileName.substring(0, 15)}...` : fileName }) })
236
- }
237
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileName, children: fileName.length > 15 ? `${fileName.substring(0, 15)}...` : fileName }) }),
238
- file.status === "uploading" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
239
- import_antd.Progress,
240
- {
241
- percent: file.progress,
242
- size: "small",
243
- showInfo: false,
244
- strokeColor: "#1677ff",
245
- className: styles.progress
246
- }
247
- ) : fileSize > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileSize, children: formatFileSize(fileSize) }),
248
- file.status === "error" && file.errorMessage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
249
- "div",
250
- {
251
- style: {
252
- fontSize: "11px",
253
- color: "#ff4d4f",
254
- marginTop: "2px"
255
- },
256
- children: file.errorMessage
257
- }
258
- )
259
- ] }),
260
- removable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
261
- "button",
262
- {
263
- className: styles.fileRemoveBtn,
264
- onClick: () => onRemove(fileId),
265
- disabled: file.status === "uploading",
266
- "aria-label": "删除文件",
267
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseOutlined, {})
268
- }
269
- )
270
- ] });
271
- };
272
- var FileGallery = ({
273
- files,
274
- align = "left",
275
- removable = false,
276
- onRemove = () => {
277
- },
278
- className,
279
- style
280
- }) => {
281
- if (!files || files.length === 0)
282
- return null;
283
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
252
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
284
253
  "div",
285
254
  {
286
- className: `${styles.container} ${align === "right" ? "align-right" : ""} ${className || ""}`,
255
+ className: `${styles.fileCard} ${align === "right" ? "align-right" : ""} ${className || ""}`,
287
256
  style,
288
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileList, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Image.PreviewGroup, { children: files.map((file, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
289
- FileItemComponent,
290
- {
291
- file,
292
- removable,
293
- onRemove
294
- },
295
- getFileId(file) || index
296
- )) }) })
257
+ children: [
258
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileIcon, style: { color }, children: icon }),
259
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileInfo, children: [
260
+ isExternalUrl ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
261
+ "a",
262
+ {
263
+ href: url,
264
+ target: "_blank",
265
+ rel: "noopener noreferrer",
266
+ className: styles.fileLink,
267
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileName, children: fileName.length > 15 ? `${fileName.substring(0, 15)}...` : fileName }) })
268
+ }
269
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileName, children: fileName.length > 15 ? `${fileName.substring(0, 15)}...` : fileName }) }),
270
+ file.status === "uploading" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
271
+ import_antd.Progress,
272
+ {
273
+ percent: file.progress,
274
+ size: "small",
275
+ showInfo: false,
276
+ strokeColor: "#1677ff",
277
+ className: styles.progress
278
+ }
279
+ ) : fileSize > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileSize, children: formatFileSize(fileSize) }),
280
+ file.status === "error" && file.errorMessage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
281
+ "div",
282
+ {
283
+ style: {
284
+ fontSize: "11px",
285
+ color: "#ff4d4f",
286
+ marginTop: "2px"
287
+ },
288
+ children: file.errorMessage
289
+ }
290
+ )
291
+ ] }),
292
+ removable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
293
+ "button",
294
+ {
295
+ className: styles.fileRemoveBtn,
296
+ onClick: () => onRemove(fileId),
297
+ disabled: file.status === "uploading",
298
+ "aria-label": "删除文件",
299
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseOutlined, {})
300
+ }
301
+ )
302
+ ]
297
303
  }
298
304
  );
299
305
  };