@ai-group/chat-sdk 3.0.1-alpha.4 → 3.0.2

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 (62) hide show
  1. package/dist/cjs/components/FileGallery/index.d.ts +33 -0
  2. package/dist/cjs/components/FileGallery/index.js +301 -0
  3. package/dist/cjs/components/FileGallery/index.js.map +7 -0
  4. package/dist/{esm/components/XAdkChatbot → cjs}/components/FileGallery/styles.d.ts +11 -6
  5. package/dist/cjs/components/FileGallery/styles.js +188 -0
  6. package/dist/cjs/components/FileGallery/styles.js.map +7 -0
  7. package/dist/cjs/components/XAdkChatbot/index.js +1 -1
  8. package/dist/cjs/components/XAdkChatbot/index.js.map +1 -1
  9. package/dist/cjs/components/XAdkProvider/XAdkProvider.stories.js +1 -1
  10. package/dist/cjs/components/XAdkProvider/XAdkProvider.stories.js.map +1 -1
  11. package/dist/cjs/components/XAdkSender/index.d.ts +2 -2
  12. package/dist/cjs/components/XAdkSender/index.js +127 -95
  13. package/dist/cjs/components/XAdkSender/index.js.map +2 -2
  14. package/dist/cjs/index.d.ts +2 -2
  15. package/dist/cjs/index.js +1 -1
  16. package/dist/cjs/index.js.map +3 -3
  17. package/dist/cjs/types/FileGallery.d.ts +54 -0
  18. package/dist/cjs/types/FileGallery.js +18 -0
  19. package/dist/cjs/types/FileGallery.js.map +7 -0
  20. package/dist/cjs/types/index.d.ts +1 -0
  21. package/dist/cjs/types/index.js +2 -0
  22. package/dist/cjs/types/index.js.map +2 -2
  23. package/dist/esm/components/FileGallery/index.d.ts +33 -0
  24. package/dist/esm/components/FileGallery/index.js +439 -0
  25. package/dist/esm/components/FileGallery/index.js.map +1 -0
  26. package/dist/{cjs/components/XAdkChatbot → esm}/components/FileGallery/styles.d.ts +11 -6
  27. package/dist/esm/components/FileGallery/styles.js +23 -0
  28. package/dist/esm/components/FileGallery/styles.js.map +1 -0
  29. package/dist/esm/components/XAdkChatbot/index.js +1 -1
  30. package/dist/esm/components/XAdkChatbot/index.js.map +1 -1
  31. package/dist/esm/components/XAdkProvider/XAdkProvider.stories.js +1 -1
  32. package/dist/esm/components/XAdkProvider/XAdkProvider.stories.js.map +1 -1
  33. package/dist/esm/components/XAdkSender/index.d.ts +2 -2
  34. package/dist/esm/components/XAdkSender/index.js +46 -45
  35. package/dist/esm/components/XAdkSender/index.js.map +1 -1
  36. package/dist/esm/index.d.ts +2 -2
  37. package/dist/esm/index.js +2 -2
  38. package/dist/esm/index.js.map +1 -1
  39. package/dist/esm/types/FileGallery.d.ts +54 -0
  40. package/dist/esm/types/FileGallery.js +2 -0
  41. package/dist/esm/types/FileGallery.js.map +1 -0
  42. package/dist/esm/types/index.d.ts +1 -0
  43. package/dist/esm/types/index.js +1 -0
  44. package/dist/esm/types/index.js.map +1 -1
  45. package/dist/umd/chat-sdk.min.js +1 -1
  46. package/package.json +1 -1
  47. package/dist/cjs/components/XAdkChatbot/components/FileGallery/index.d.ts +0 -12
  48. package/dist/cjs/components/XAdkChatbot/components/FileGallery/index.js +0 -92
  49. package/dist/cjs/components/XAdkChatbot/components/FileGallery/index.js.map +0 -7
  50. package/dist/cjs/components/XAdkChatbot/components/FileGallery/styles.js +0 -137
  51. package/dist/cjs/components/XAdkChatbot/components/FileGallery/styles.js.map +0 -7
  52. package/dist/cjs/components/XAdkSender/FileGallery.d.ts +0 -8
  53. package/dist/cjs/components/XAdkSender/FileGallery.js +0 -381
  54. package/dist/cjs/components/XAdkSender/FileGallery.js.map +0 -7
  55. package/dist/esm/components/XAdkChatbot/components/FileGallery/index.d.ts +0 -12
  56. package/dist/esm/components/XAdkChatbot/components/FileGallery/index.js +0 -104
  57. package/dist/esm/components/XAdkChatbot/components/FileGallery/index.js.map +0 -1
  58. package/dist/esm/components/XAdkChatbot/components/FileGallery/styles.js +0 -20
  59. package/dist/esm/components/XAdkChatbot/components/FileGallery/styles.js.map +0 -1
  60. package/dist/esm/components/XAdkSender/FileGallery.d.ts +0 -8
  61. package/dist/esm/components/XAdkSender/FileGallery.js +0 -236
  62. package/dist/esm/components/XAdkSender/FileGallery.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-group/chat-sdk",
3
- "version": "3.0.1-alpha.4",
3
+ "version": "3.0.2",
4
4
  "private": false,
5
5
  "description": "面向 AI 中台平台的前端集成 SDK,支持 OAuth2 安全认证、聊天机器人、智能编辑器、多模态对话,适配 SaaS / 私有化双场景。",
6
6
  "main": "dist/cjs/index.js",
@@ -1,12 +0,0 @@
1
- import React from "react";
2
- import type { FileData } from "../../../../types";
3
- export interface FileGalleryProps {
4
- files?: FileData[];
5
- align?: "left" | "right";
6
- }
7
- /**
8
- * 文件展示画廊组件
9
- * 支持图片九宫格 + 文件列表双模式
10
- */
11
- declare const FileGallery: React.FC<FileGalleryProps>;
12
- export default FileGallery;
@@ -1,92 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/components/XAdkChatbot/components/FileGallery/index.tsx
20
- var FileGallery_exports = {};
21
- __export(FileGallery_exports, {
22
- default: () => FileGallery_default
23
- });
24
- module.exports = __toCommonJS(FileGallery_exports);
25
- var import_antd = require("antd");
26
- var import_styles = require("./styles");
27
- var import_jsx_runtime = require("react/jsx-runtime");
28
- var getFileName = (file) => {
29
- return file.displayName || "";
30
- };
31
- var getFileUrl = (file) => {
32
- return file.fileUri || "";
33
- };
34
- var isImage = (file) => {
35
- if (!file)
36
- return false;
37
- const mimeType = file.mimeType;
38
- const name = getFileName(file);
39
- const url = getFileUrl(file);
40
- if (mimeType == null ? void 0 : mimeType.startsWith("image/"))
41
- return true;
42
- if (name == null ? void 0 : name.match(/\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i))
43
- return true;
44
- if (url == null ? void 0 : url.match(/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?.*)?$/i))
45
- return true;
46
- return false;
47
- };
48
- var FileGallery = ({ files, align = "left" }) => {
49
- const styles = (0, import_styles.useStyles)();
50
- if (!files || files.length === 0)
51
- return null;
52
- const imageFiles = files.filter(isImage);
53
- const otherFiles = files.filter((f) => !isImage(f));
54
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
55
- "div",
56
- {
57
- className: `${styles.fileGalleryWrapper} ${align === "right" ? "alignRight" : ""}`,
58
- children: [
59
- imageFiles.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.imageGrid, "data-count": imageFiles.length, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Image.PreviewGroup, { children: imageFiles.map((file, index) => {
60
- const src = getFileUrl(file);
61
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.imageItem, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
62
- import_antd.Image,
63
- {
64
- src,
65
- className: styles.img,
66
- width: "100%",
67
- height: "100%",
68
- alt: getFileName(file),
69
- fallback: "https://via.placeholder.com/150?text=Load+Error",
70
- style: { objectFit: "cover" }
71
- }
72
- ) }, index);
73
- }) }) }),
74
- otherFiles.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileList, children: otherFiles.map((file, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileItem, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
75
- "a",
76
- {
77
- href: getFileUrl(file),
78
- target: "_blank",
79
- rel: "noopener noreferrer",
80
- className: styles.fileLink,
81
- children: [
82
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: styles.fileIcon, children: "📄" }),
83
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: styles.fileName, children: getFileName(file) })
84
- ]
85
- }
86
- ) }, i)) })
87
- ]
88
- }
89
- );
90
- };
91
- var FileGallery_default = FileGallery;
92
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../src/components/XAdkChatbot/components/FileGallery/index.tsx"],
4
- "sourcesContent": ["import React from \"react\";\nimport { Image } from \"antd\";\nimport { useStyles } from \"./styles\";\nimport type { FileData } from \"@/types\";\n\nexport interface FileGalleryProps {\n files?: FileData[];\n align?: \"left\" | \"right\";\n}\n\n/**\n * 获取文件名\n */\nconst getFileName = (file: FileData): string => {\n return file.displayName || \"\";\n};\n\n/**\n * 获取文件 URL\n */\nconst getFileUrl = (file: FileData): string => {\n return file.fileUri || \"\";\n};\n\n/**\n * 判断是否为图片\n */\nconst isImage = (file: FileData): boolean => {\n if (!file) return false;\n\n const mimeType = file.mimeType;\n const name = getFileName(file);\n const url = getFileUrl(file);\n\n // 1. 根据 MIME 类型判断\n if (mimeType?.startsWith(\"image/\")) return true;\n\n // 2. 根据后缀名判断\n if (name?.match(/\\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i)) return true;\n\n // 3. 根据 URL 后缀判断 (兜底)\n if (url?.match(/\\.(jpg|jpeg|png|gif|webp|bmp|svg)(\\?.*)?$/i)) return true;\n\n return false;\n};\n\n/**\n * 文件展示画廊组件\n * 支持图片九宫格 + 文件列表双模式\n */\nconst FileGallery: React.FC<FileGalleryProps> = ({ files, align = \"left\" }) => {\n const styles = useStyles();\n\n if (!files || files.length === 0) return null;\n\n // 分类:图片 vs 其他文件\n const imageFiles = files.filter(isImage);\n const otherFiles = files.filter((f) => !isImage(f));\n\n return (\n <div\n className={`${styles.fileGalleryWrapper} ${align === \"right\" ? \"alignRight\" : \"\"}`}\n >\n {/* 1. 图片区域:九宫格 */}\n {imageFiles.length > 0 && (\n <div className={styles.imageGrid} data-count={imageFiles.length}>\n <Image.PreviewGroup>\n {imageFiles.map((file, index) => {\n const src = getFileUrl(file);\n return (\n <div key={index} className={styles.imageItem}>\n <Image\n src={src}\n className={styles.img}\n width=\"100%\"\n height=\"100%\"\n alt={getFileName(file)}\n fallback=\"https://via.placeholder.com/150?text=Load+Error\"\n style={{ objectFit: \"cover\" }}\n />\n </div>\n );\n })}\n </Image.PreviewGroup>\n </div>\n )}\n\n {/* 2. 非图片文件:列表展示 */}\n {otherFiles.length > 0 && (\n <div className={styles.fileList}>\n {otherFiles.map((file, i) => (\n <div key={i} className={styles.fileItem}>\n <a\n href={getFileUrl(file)}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={styles.fileLink}\n >\n <span className={styles.fileIcon}>📄</span>\n <span className={styles.fileName}>{getFileName(file)}</span>\n </a>\n </div>\n ))}\n </div>\n )}\n </div>\n );\n};\n\nexport default FileGallery;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAsB;AACtB,oBAA0B;AAqER;AA1DlB,IAAM,cAAc,CAAC,SAA2B;AAC9C,SAAO,KAAK,eAAe;AAC7B;AAKA,IAAM,aAAa,CAAC,SAA2B;AAC7C,SAAO,KAAK,WAAW;AACzB;AAKA,IAAM,UAAU,CAAC,SAA4B;AAC3C,MAAI,CAAC;AAAM,WAAO;AAElB,QAAM,WAAW,KAAK;AACtB,QAAM,OAAO,YAAY,IAAI;AAC7B,QAAM,MAAM,WAAW,IAAI;AAG3B,MAAI,qCAAU,WAAW;AAAW,WAAO;AAG3C,MAAI,6BAAM,MAAM;AAAwC,WAAO;AAG/D,MAAI,2BAAK,MAAM;AAA+C,WAAO;AAErE,SAAO;AACT;AAMA,IAAM,cAA0C,CAAC,EAAE,OAAO,QAAQ,OAAO,MAAM;AAC7E,QAAM,aAAS,yBAAU;AAEzB,MAAI,CAAC,SAAS,MAAM,WAAW;AAAG,WAAO;AAGzC,QAAM,aAAa,MAAM,OAAO,OAAO;AACvC,QAAM,aAAa,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAElD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,OAAO,sBAAsB,UAAU,UAAU,eAAe;AAAA,MAG7E;AAAA,mBAAW,SAAS,KACnB,4CAAC,SAAI,WAAW,OAAO,WAAW,cAAY,WAAW,QACvD,sDAAC,kBAAM,cAAN,EACE,qBAAW,IAAI,CAAC,MAAM,UAAU;AAC/B,gBAAM,MAAM,WAAW,IAAI;AAC3B,iBACE,4CAAC,SAAgB,WAAW,OAAO,WACjC;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,WAAW,OAAO;AAAA,cAClB,OAAM;AAAA,cACN,QAAO;AAAA,cACP,KAAK,YAAY,IAAI;AAAA,cACrB,UAAS;AAAA,cACT,OAAO,EAAE,WAAW,QAAQ;AAAA;AAAA,UAC9B,KATQ,KAUV;AAAA,QAEJ,CAAC,GACH,GACF;AAAA,QAID,WAAW,SAAS,KACnB,4CAAC,SAAI,WAAW,OAAO,UACpB,qBAAW,IAAI,CAAC,MAAM,MACrB,4CAAC,SAAY,WAAW,OAAO,UAC7B;AAAA,UAAC;AAAA;AAAA,YACC,MAAM,WAAW,IAAI;AAAA,YACrB,QAAO;AAAA,YACP,KAAI;AAAA,YACJ,WAAW,OAAO;AAAA,YAElB;AAAA,0DAAC,UAAK,WAAW,OAAO,UAAU,gBAAE;AAAA,cACpC,4CAAC,UAAK,WAAW,OAAO,UAAW,sBAAY,IAAI,GAAE;AAAA;AAAA;AAAA,QACvD,KATQ,CAUV,CACD,GACH;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,sBAAQ;",
6
- "names": []
7
- }
@@ -1,137 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/components/XAdkChatbot/components/FileGallery/styles.tsx
20
- var styles_exports = {};
21
- __export(styles_exports, {
22
- useStyles: () => useStyles
23
- });
24
- module.exports = __toCommonJS(styles_exports);
25
- var import_css = require("@emotion/css");
26
- var import_common = require("../../../../styles/common");
27
- var useStyles = (0, import_common.withBasicStyles)(() => ({
28
- fileGalleryWrapper: import_css.css`
29
- margin: 8px 0;
30
-
31
- &.alignRight {
32
- display: flex;
33
- flex-direction: column;
34
- align-items: flex-end;
35
- }
36
- `,
37
- // 九宫格布局
38
- imageGrid: import_css.css`
39
- display: grid;
40
- gap: 8px;
41
- max-width: 400px;
42
- margin-bottom: 8px;
43
-
44
- /* 1张图片:单列 */
45
- &[data-count="1"] {
46
- grid-template-columns: 1fr;
47
- max-width: 300px;
48
- }
49
-
50
- /* 2-4张图片:两列 */
51
- &[data-count="2"],
52
- &[data-count="3"],
53
- &[data-count="4"] {
54
- grid-template-columns: repeat(2, 1fr);
55
- }
56
-
57
- /* 5-9张图片:三列 */
58
- &[data-count="5"],
59
- &[data-count="6"],
60
- &[data-count="7"],
61
- &[data-count="8"],
62
- &[data-count="9"] {
63
- grid-template-columns: repeat(3, 1fr);
64
- max-width: 400px;
65
- }
66
- `,
67
- imageItem: import_css.css`
68
- position: relative;
69
- width: 100%;
70
- padding-top: 100%; /* 1:1 比例 */
71
- overflow: hidden;
72
- border-radius: 8px;
73
- background: #ffffff;
74
- border: 1px solid #d9d9d9;
75
-
76
- .ant-image {
77
- position: absolute;
78
- top: 0;
79
- left: 0;
80
- width: 100%;
81
- height: 100%;
82
- }
83
- `,
84
- img: import_css.css`
85
- object-fit: cover;
86
- cursor: pointer;
87
- transition: transform 0.2s;
88
-
89
- &:hover {
90
- transform: scale(1.05);
91
- }
92
- `,
93
- // 文件列表
94
- fileList: import_css.css`
95
- display: flex;
96
- flex-direction: column;
97
- gap: 8px;
98
- max-width: 400px;
99
- `,
100
- fileItem: import_css.css`
101
- background: #ffffff;
102
- border: 1px solid #d9d9d9;
103
- border-radius: 8px;
104
- padding: 12px;
105
- transition: all 0.2s;
106
-
107
- &:hover {
108
- border-color: #1890ff;
109
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
110
- }
111
- `,
112
- fileLink: import_css.css`
113
- display: flex;
114
- align-items: center;
115
- gap: 8px;
116
- color: rgba(0, 0, 0, 0.85);
117
- text-decoration: none;
118
-
119
- &:hover {
120
- color: #1890ff;
121
- }
122
- `,
123
- fileIcon: import_css.css`
124
- font-size: 20px;
125
- `,
126
- fileName: import_css.css`
127
- flex: 1;
128
- overflow: hidden;
129
- text-overflow: ellipsis;
130
- white-space: nowrap;
131
- `
132
- }));
133
- // Annotate the CommonJS export names for ESM import in node:
134
- 0 && (module.exports = {
135
- useStyles
136
- });
137
- //# sourceMappingURL=styles.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../src/components/XAdkChatbot/components/FileGallery/styles.tsx"],
4
- "sourcesContent": ["import { css } from \"@emotion/css\";\nimport { withBasicStyles } from \"@/styles/common\";\n\nexport const useStyles = withBasicStyles(() => ({\n fileGalleryWrapper: css`\n margin: 8px 0;\n\n &.alignRight {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n }\n `,\n\n // 九宫格布局\n imageGrid: css`\n display: grid;\n gap: 8px;\n max-width: 400px;\n margin-bottom: 8px;\n\n /* 1张图片:单列 */\n &[data-count=\"1\"] {\n grid-template-columns: 1fr;\n max-width: 300px;\n }\n\n /* 2-4张图片:两列 */\n &[data-count=\"2\"],\n &[data-count=\"3\"],\n &[data-count=\"4\"] {\n grid-template-columns: repeat(2, 1fr);\n }\n\n /* 5-9张图片:三列 */\n &[data-count=\"5\"],\n &[data-count=\"6\"],\n &[data-count=\"7\"],\n &[data-count=\"8\"],\n &[data-count=\"9\"] {\n grid-template-columns: repeat(3, 1fr);\n max-width: 400px;\n }\n `,\n\n imageItem: css`\n position: relative;\n width: 100%;\n padding-top: 100%; /* 1:1 比例 */\n overflow: hidden;\n border-radius: 8px;\n background: #ffffff;\n border: 1px solid #d9d9d9;\n\n .ant-image {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n }\n `,\n\n img: css`\n object-fit: cover;\n cursor: pointer;\n transition: transform 0.2s;\n\n &:hover {\n transform: scale(1.05);\n }\n `,\n\n // 文件列表\n fileList: css`\n display: flex;\n flex-direction: column;\n gap: 8px;\n max-width: 400px;\n `,\n\n fileItem: css`\n background: #ffffff;\n border: 1px solid #d9d9d9;\n border-radius: 8px;\n padding: 12px;\n transition: all 0.2s;\n\n &:hover {\n border-color: #1890ff;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);\n }\n `,\n\n fileLink: css`\n display: flex;\n align-items: center;\n gap: 8px;\n color: rgba(0, 0, 0, 0.85);\n text-decoration: none;\n\n &:hover {\n color: #1890ff;\n }\n `,\n\n fileIcon: css`\n font-size: 20px;\n `,\n\n fileName: css`\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n `,\n}));\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoB;AACpB,oBAAgC;AAEzB,IAAM,gBAAY,+BAAgB,OAAO;AAAA,EAC9C,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWpB,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,EA8BX,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBX,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWL,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOV,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaV,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYV,UAAU;AAAA;AAAA;AAAA,EAIV,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAMZ,EAAE;",
6
- "names": []
7
- }
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- import { LocalFile } from "../../types/XAdkSender";
3
- interface FileGalleryProps {
4
- files: LocalFile[];
5
- onRemove: (id: string) => void;
6
- }
7
- declare const FileGallery: React.FC<FileGalleryProps>;
8
- export default FileGallery;
@@ -1,381 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/components/XAdkSender/FileGallery.tsx
20
- var FileGallery_exports = {};
21
- __export(FileGallery_exports, {
22
- default: () => FileGallery_default
23
- });
24
- module.exports = __toCommonJS(FileGallery_exports);
25
- var import_antd = require("antd");
26
- var import_icons = require("@ant-design/icons");
27
- var import_css = require("@emotion/css");
28
- var import_jsx_runtime = require("react/jsx-runtime");
29
- var isImageFile = (file) => {
30
- if (!file.type)
31
- return false;
32
- return file.type.startsWith("image/");
33
- };
34
- var getFileExtension = (filename) => {
35
- const ext = filename.split(".").pop();
36
- return ext ? ext.toLowerCase() : "";
37
- };
38
- var getFileIcon = (file) => {
39
- const ext = getFileExtension(file.name);
40
- if (ext === "pdf") {
41
- return { icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.FilePdfOutlined, {}), color: "#ff4d4f" };
42
- }
43
- if (["doc", "docx"].includes(ext)) {
44
- return { icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.FileWordOutlined, {}), color: "#1677ff" };
45
- }
46
- if (["xls", "xlsx", "csv"].includes(ext)) {
47
- return { icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.FileExcelOutlined, {}), color: "#22b35e" };
48
- }
49
- if (["ppt", "pptx"].includes(ext)) {
50
- return { icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.FilePptOutlined, {}), color: "#ff6e31" };
51
- }
52
- if (isImageFile(file)) {
53
- return { icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.FileImageOutlined, {}), color: "#8c8c8c" };
54
- }
55
- return { icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.FileOutlined, {}), color: "#8c8c8c" };
56
- };
57
- var formatFileSize = (bytes) => {
58
- if (bytes < 1024)
59
- return bytes + " B";
60
- if (bytes < 1024 * 1024)
61
- return (bytes / 1024).toFixed(1) + " KB";
62
- return (bytes / (1024 * 1024)).toFixed(1) + " MB";
63
- };
64
- var styles = {
65
- container: import_css.css`
66
- padding: 12px 0;
67
- display: flex;
68
- flex-direction: column;
69
- gap: 12px;
70
- `,
71
- // 图片九宫格容器
72
- imageGrid: import_css.css`
73
- display: grid;
74
- gap: 8px;
75
- width: fit-content;
76
- min-width: 80px;
77
- max-width: 100%;
78
- /* 默认3列布局 */
79
- grid-template-columns: repeat(3, 1fr);
80
-
81
- /* 单张图 */
82
- &[data-count="1"] {
83
- grid-template-columns: 1fr;
84
- min-width: 100px;
85
- max-width: 200px;
86
- }
87
-
88
- /* 2张、4张 -> 2列 */
89
- &[data-count="2"],
90
- &[data-count="4"] {
91
- grid-template-columns: repeat(2, 1fr);
92
- min-width: 180px;
93
- max-width: 240px;
94
- }
95
-
96
- /* 3张、5-9张 -> 3列 */
97
- &[data-count="3"],
98
- &[data-count="5"],
99
- &[data-count="6"],
100
- &[data-count="7"],
101
- &[data-count="8"],
102
- &[data-count="9"] {
103
- grid-template-columns: repeat(3, 1fr);
104
- min-width: 260px;
105
- max-width: 320px;
106
- }
107
- `,
108
- imageItem: import_css.css`
109
- position: relative;
110
- width: 100%;
111
- min-width: 80px;
112
- padding-top: 100%; /* 1:1 正方形 */
113
- height: 0;
114
- overflow: hidden;
115
- border-radius: 8px;
116
- background-color: #f5f5f5;
117
- border: 1px solid rgba(0, 0, 0, 0.06);
118
-
119
- .ant-image {
120
- position: absolute !important;
121
- top: 0;
122
- left: 0;
123
- width: 100% !important;
124
- height: 100% !important;
125
- display: flex !important;
126
- justify-content: center;
127
- align-items: center;
128
- }
129
-
130
- img {
131
- width: 100% !important;
132
- height: 100% !important;
133
- object-fit: cover !important;
134
- display: block !important;
135
- }
136
- `,
137
- imageOverlay: import_css.css`
138
- position: absolute;
139
- top: 0;
140
- left: 0;
141
- right: 0;
142
- bottom: 0;
143
- background: rgba(0, 0, 0, 0.05);
144
- display: flex;
145
- align-items: center;
146
- justify-content: center;
147
- z-index: 10;
148
- `,
149
- removeBtn: import_css.css`
150
- position: absolute;
151
- top: 4px;
152
- right: 4px;
153
- width: 20px;
154
- height: 20px;
155
- border-radius: 50%;
156
- background: rgba(0, 0, 0, 0.6);
157
- color: #fff;
158
- border: none;
159
- display: flex;
160
- align-items: center;
161
- justify-content: center;
162
- cursor: pointer;
163
- z-index: 20;
164
- padding: 0;
165
- font-size: 10px;
166
- transition: all 0.2s ease;
167
-
168
- &:hover {
169
- background: rgba(0, 0, 0, 0.8);
170
- transform: scale(1.1);
171
- }
172
- `,
173
- // 文件列表
174
- fileList: import_css.css`
175
- display: flex;
176
- flex-wrap: wrap;
177
- gap: 8px;
178
- `,
179
- fileCard: import_css.css`
180
- position: relative;
181
- display: flex;
182
- align-items: center;
183
- gap: 10px;
184
- padding: 10px 12px;
185
- background: #fafafa;
186
- border: 1px solid #f0f0f0;
187
- border-radius: 8px;
188
- min-width: 200px;
189
- max-width: 280px;
190
- min-height: 64px;
191
- transition: all 0.2s ease;
192
-
193
- &:hover {
194
- background: #f5f5f5;
195
- border-color: #e0e0e0;
196
- }
197
- `,
198
- // 图片缩略图容器
199
- imageThumbnail: import_css.css`
200
- position: relative;
201
- width: 44px;
202
- height: 44px;
203
- flex-shrink: 0;
204
- border-radius: 4px;
205
- overflow: hidden;
206
- background-color: #f5f5f5;
207
- border: 1px solid rgba(0, 0, 0, 0.06);
208
-
209
- .ant-image {
210
- width: 100% !important;
211
- height: 100% !important;
212
- display: flex !important;
213
- justify-content: center;
214
- align-items: center;
215
- }
216
-
217
- img {
218
- width: 100% !important;
219
- height: 100% !important;
220
- object-fit: cover !important;
221
- display: block !important;
222
- }
223
- `,
224
- fileIcon: import_css.css`
225
- font-size: 24px;
226
- flex-shrink: 0;
227
- width: 44px;
228
- height: 44px;
229
- display: flex;
230
- align-items: center;
231
- justify-content: center;
232
- `,
233
- fileInfo: import_css.css`
234
- flex: 1;
235
- min-width: 0;
236
- overflow: hidden;
237
- `,
238
- fileName: import_css.css`
239
- font-size: 13px;
240
- font-weight: 500;
241
- color: #262626;
242
- margin-bottom: 4px;
243
- overflow: hidden;
244
- text-overflow: ellipsis;
245
- white-space: nowrap;
246
- `,
247
- fileSize: import_css.css`
248
- font-size: 11px;
249
- color: #8c8c8c;
250
- `,
251
- progress: import_css.css`
252
- margin-top: 4px;
253
-
254
- .ant-progress-inner {
255
- height: 4px !important;
256
- }
257
-
258
- .ant-progress-bg {
259
- height: 4px !important;
260
- }
261
- `,
262
- fileRemoveBtn: import_css.css`
263
- position: absolute;
264
- top: -6px;
265
- right: -6px;
266
- width: 18px;
267
- height: 18px;
268
- border-radius: 50%;
269
- background: rgba(0, 0, 0, 0.75);
270
- color: #fff;
271
- border: none;
272
- display: flex;
273
- align-items: center;
274
- justify-content: center;
275
- cursor: pointer;
276
- z-index: 1;
277
- padding: 0;
278
- font-size: 10px;
279
- transition: all 0.2s ease;
280
-
281
- &:hover {
282
- background: rgba(0, 0, 0, 0.9);
283
- transform: scale(1.1);
284
- }
285
-
286
- &:disabled {
287
- opacity: 0.5;
288
- cursor: not-allowed;
289
- }
290
- `
291
- };
292
- var FileGallery = ({ files, onRemove }) => {
293
- if (files.length === 0)
294
- return null;
295
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.container, 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) => {
296
- var _a, _b;
297
- const isImage = isImageFile(file);
298
- if (isImage) {
299
- const url = ((_a = file.response) == null ? void 0 : _a.fileUrl) || ((_b = file.response) == null ? void 0 : _b.tempUrl) || file.tempUrl || (file.file ? URL.createObjectURL(file.file) : "");
300
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileCard, children: [
301
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.imageThumbnail, children: [
302
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
303
- import_antd.Image,
304
- {
305
- src: url,
306
- alt: file.name,
307
- fallback: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==",
308
- preview: {
309
- src: url
310
- }
311
- }
312
- ),
313
- file.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.imageOverlay, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
314
- import_antd.Progress,
315
- {
316
- type: "circle",
317
- percent: file.progress,
318
- size: 30,
319
- strokeColor: "#1677ff"
320
- }
321
- ) })
322
- ] }),
323
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileInfo, children: [
324
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: file.name, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileName, children: file.name.length > 15 ? `${file.name.substring(0, 15)}...` : file.name }) }),
325
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileSize, children: formatFileSize(file.size) })
326
- ] }),
327
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
328
- "button",
329
- {
330
- className: styles.fileRemoveBtn,
331
- onClick: () => onRemove(file.id),
332
- disabled: file.status === "uploading",
333
- "aria-label": "删除文件",
334
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseOutlined, {})
335
- }
336
- )
337
- ] }, file.id);
338
- } else {
339
- const { icon, color } = getFileIcon(file);
340
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileCard, children: [
341
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileIcon, style: { color }, children: icon }),
342
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.fileInfo, children: [
343
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: file.name, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileName, children: file.name.length > 15 ? `${file.name.substring(0, 15)}...` : file.name }) }),
344
- file.status === "uploading" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
345
- import_antd.Progress,
346
- {
347
- percent: file.progress,
348
- size: "small",
349
- showInfo: false,
350
- strokeColor: "#1677ff",
351
- className: styles.progress
352
- }
353
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.fileSize, children: formatFileSize(file.size) }),
354
- file.status === "error" && file.errorMessage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
355
- "div",
356
- {
357
- style: {
358
- fontSize: "11px",
359
- color: "#ff4d4f",
360
- marginTop: "2px"
361
- },
362
- children: file.errorMessage
363
- }
364
- )
365
- ] }),
366
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
367
- "button",
368
- {
369
- className: styles.fileRemoveBtn,
370
- onClick: () => onRemove(file.id),
371
- disabled: file.status === "uploading",
372
- "aria-label": "删除文件",
373
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseOutlined, {})
374
- }
375
- )
376
- ] }, file.id);
377
- }
378
- }) }) }) });
379
- };
380
- var FileGallery_default = FileGallery;
381
- //# sourceMappingURL=FileGallery.js.map