bhd-components 0.9.29 → 0.10.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 (103) hide show
  1. package/dist/index.esm.es5.development.css +662 -0
  2. package/dist/index.esm.es5.development.js +2694 -159
  3. package/dist/index.esm.es5.production.css +1 -1
  4. package/dist/index.esm.es5.production.js +1 -1
  5. package/dist/vendor.esm.es5.development.js +2515 -1100
  6. package/dist/vendor.esm.es5.production.js +136 -136
  7. package/es2017/AIMessageList/components/content/index.d.ts +4 -0
  8. package/es2017/AIMessageList/components/content/index.js +29 -0
  9. package/es2017/AIMessageList/components/content/index.module.less +8 -0
  10. package/es2017/AIMessageList/components/copyIcon/index.d.ts +7 -0
  11. package/es2017/AIMessageList/components/copyIcon/index.js +58 -0
  12. package/es2017/AIMessageList/components/copyIcon/index.module.less +22 -0
  13. package/es2017/AIMessageList/components/errorCallback/index.d.ts +3 -0
  14. package/es2017/AIMessageList/components/errorCallback/index.js +6 -0
  15. package/es2017/AIMessageList/components/fileList/fileIcon.d.ts +3 -0
  16. package/es2017/AIMessageList/components/fileList/fileIcon.js +970 -0
  17. package/es2017/AIMessageList/components/fileList/index.d.ts +4 -0
  18. package/es2017/AIMessageList/components/fileList/index.js +299 -0
  19. package/es2017/AIMessageList/components/fileList/index.module.less +95 -0
  20. package/es2017/AIMessageList/components/footer/index.d.ts +10 -0
  21. package/es2017/AIMessageList/components/footer/index.js +296 -0
  22. package/es2017/AIMessageList/components/footer/index.module.less +51 -0
  23. package/es2017/AIMessageList/components/header/index.d.ts +9 -0
  24. package/es2017/AIMessageList/components/header/index.js +94 -0
  25. package/es2017/AIMessageList/components/header/index.module.less +31 -0
  26. package/es2017/AIMessageList/components/referencesIcon/index.d.ts +9 -0
  27. package/es2017/AIMessageList/components/referencesIcon/index.js +37 -0
  28. package/es2017/AIMessageList/components/referencesIcon/index.module.less +13 -0
  29. package/es2017/AIMessageList/components/renderReferrnce/index.d.ts +10 -0
  30. package/es2017/AIMessageList/components/renderReferrnce/index.js +68 -0
  31. package/es2017/AIMessageList/components/renderReferrnce/index.module.less +64 -0
  32. package/es2017/AIMessageList/components/sendBtn/index.d.ts +4 -0
  33. package/es2017/AIMessageList/components/sendBtn/index.js +46 -0
  34. package/es2017/AIMessageList/components/sendBtn/index.module.less +25 -0
  35. package/es2017/AIMessageList/components/uplodaFileBtn/index.d.ts +4 -0
  36. package/es2017/AIMessageList/components/uplodaFileBtn/index.js +33 -0
  37. package/es2017/AIMessageList/components/uplodaFileBtn/index.module.less +5 -0
  38. package/es2017/AIMessageList/components/virtuosoList/index.d.ts +5 -0
  39. package/es2017/AIMessageList/components/virtuosoList/index.js +507 -0
  40. package/es2017/AIMessageList/components/virtuosoList/index.module.less +381 -0
  41. package/es2017/AIMessageList/index.d.ts +4 -0
  42. package/es2017/AIMessageList/index.js +58 -0
  43. package/es2017/AIMessageList/index.module.less +20 -0
  44. package/es2017/AIMessageList/type.d.ts +242 -0
  45. package/es2017/customerService/index.js +1 -0
  46. package/es2017/images/loading2.js +2 -0
  47. package/es2017/index.d.ts +1 -0
  48. package/es2017/index.js +1 -0
  49. package/es2017/utils/Date.d.ts +2 -1
  50. package/es2017/utils/Date.js +2 -1
  51. package/es2017/utils/dom.d.ts +4 -1
  52. package/es2017/utils/dom.js +44 -1
  53. package/es2017/utils/number.d.ts +1 -0
  54. package/es2017/utils/number.js +9 -0
  55. package/esm/AIMessageList/components/content/index.d.ts +4 -0
  56. package/esm/AIMessageList/components/content/index.js +29 -0
  57. package/esm/AIMessageList/components/content/index.module.less +8 -0
  58. package/esm/AIMessageList/components/copyIcon/index.d.ts +7 -0
  59. package/esm/AIMessageList/components/copyIcon/index.js +61 -0
  60. package/esm/AIMessageList/components/copyIcon/index.module.less +22 -0
  61. package/esm/AIMessageList/components/errorCallback/index.d.ts +3 -0
  62. package/esm/AIMessageList/components/errorCallback/index.js +6 -0
  63. package/esm/AIMessageList/components/fileList/fileIcon.d.ts +3 -0
  64. package/esm/AIMessageList/components/fileList/fileIcon.js +970 -0
  65. package/esm/AIMessageList/components/fileList/index.d.ts +4 -0
  66. package/esm/AIMessageList/components/fileList/index.js +325 -0
  67. package/esm/AIMessageList/components/fileList/index.module.less +95 -0
  68. package/esm/AIMessageList/components/footer/index.d.ts +10 -0
  69. package/esm/AIMessageList/components/footer/index.js +304 -0
  70. package/esm/AIMessageList/components/footer/index.module.less +51 -0
  71. package/esm/AIMessageList/components/header/index.d.ts +9 -0
  72. package/esm/AIMessageList/components/header/index.js +96 -0
  73. package/esm/AIMessageList/components/header/index.module.less +31 -0
  74. package/esm/AIMessageList/components/referencesIcon/index.d.ts +9 -0
  75. package/esm/AIMessageList/components/referencesIcon/index.js +39 -0
  76. package/esm/AIMessageList/components/referencesIcon/index.module.less +13 -0
  77. package/esm/AIMessageList/components/renderReferrnce/index.d.ts +10 -0
  78. package/esm/AIMessageList/components/renderReferrnce/index.js +72 -0
  79. package/esm/AIMessageList/components/renderReferrnce/index.module.less +64 -0
  80. package/esm/AIMessageList/components/sendBtn/index.d.ts +4 -0
  81. package/esm/AIMessageList/components/sendBtn/index.js +48 -0
  82. package/esm/AIMessageList/components/sendBtn/index.module.less +25 -0
  83. package/esm/AIMessageList/components/uplodaFileBtn/index.d.ts +4 -0
  84. package/esm/AIMessageList/components/uplodaFileBtn/index.js +33 -0
  85. package/esm/AIMessageList/components/uplodaFileBtn/index.module.less +5 -0
  86. package/esm/AIMessageList/components/virtuosoList/index.d.ts +5 -0
  87. package/esm/AIMessageList/components/virtuosoList/index.js +484 -0
  88. package/esm/AIMessageList/components/virtuosoList/index.module.less +381 -0
  89. package/esm/AIMessageList/index.d.ts +4 -0
  90. package/esm/AIMessageList/index.js +58 -0
  91. package/esm/AIMessageList/index.module.less +20 -0
  92. package/esm/AIMessageList/type.d.ts +242 -0
  93. package/esm/customerService/index.js +1 -0
  94. package/esm/images/loading2.js +2 -0
  95. package/esm/index.d.ts +1 -0
  96. package/esm/index.js +1 -0
  97. package/esm/utils/Date.d.ts +2 -1
  98. package/esm/utils/Date.js +2 -1
  99. package/esm/utils/dom.d.ts +4 -1
  100. package/esm/utils/dom.js +45 -1
  101. package/esm/utils/number.d.ts +1 -0
  102. package/esm/utils/number.js +9 -0
  103. package/package.json +2 -1
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { fileListProps, FileListRefProps } from "../../type";
3
+ declare const FileList: React.ForwardRefExoticComponent<fileListProps & React.RefAttributes<FileListRefProps>>;
4
+ export default FileList;
@@ -0,0 +1,299 @@
1
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
+ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
3
+ import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
4
+ import React, { useState, useEffect, useImperativeHandle, forwardRef, useRef } from "react";
5
+ import styles from "./index.module.less";
6
+ import { fileIconRender, statusRender } from "./fileIcon";
7
+ import { CloseCircleFilled, DoubleRightOutlined } from "../../../icons";
8
+ import { guidGenerator } from "../../../utils/number";
9
+ import { Upload } from "antd";
10
+ // 通过文件名 获取文件后缀
11
+ const getSuffix = (fileName)=>{
12
+ return fileName.split(".").pop().toLowerCase();
13
+ };
14
+ const FileList = /*#__PURE__*/ forwardRef((props, ref)=>{
15
+ const { prefix, fileUpload, errorCallback, changeFileCanSending } = props;
16
+ console.log("fileUpload", fileUpload);
17
+ const [fileList, setFileList] = useState([]);
18
+ const [page, setPage] = useState(1);
19
+ const [pageSize, setPageSize] = useState(5);
20
+ const recordObj = useRef({
21
+ page: page,
22
+ pageSize: pageSize,
23
+ fileList: fileList
24
+ });
25
+ useEffect(()=>{
26
+ recordObj.current.page = page;
27
+ recordObj.current.pageSize = pageSize;
28
+ recordObj.current.fileList = fileList;
29
+ }, [
30
+ page,
31
+ pageSize,
32
+ fileList
33
+ ]);
34
+ useEffect(()=>{
35
+ let flag = fileList.some((item)=>[
36
+ "waiting",
37
+ "uploading",
38
+ "uploadError",
39
+ "waitParse",
40
+ "parsing",
41
+ "parsingError"
42
+ ].includes(item.status));
43
+ changeFileCanSending(!flag);
44
+ }, [
45
+ fileList
46
+ ]);
47
+ useImperativeHandle(ref, ()=>{
48
+ return {
49
+ addFile,
50
+ changePage,
51
+ deleteFile,
52
+ updateFile,
53
+ getFileList: ()=>recordObj.current.fileList,
54
+ vaildFile,
55
+ fileToCustomFile
56
+ };
57
+ });
58
+ const getCls = (clsName)=>{
59
+ return styles[clsName] + " " + prefix + "-" + clsName;
60
+ };
61
+ const vaildFile = (file, fileId)=>{
62
+ if (fileUpload.maxCount > 0 && recordObj.current.fileList.length > fileUpload.maxCount) {
63
+ errorCallback({
64
+ type: "fileCountOver",
65
+ message: "上传失败,文件数量超过限制"
66
+ });
67
+ return false;
68
+ }
69
+ // fileUpload
70
+ let acceptList = fileUpload.accept.split(/[.,]/).filter((item)=>!!item);
71
+ let suffix = getSuffix(file.name);
72
+ if (!acceptList.includes(suffix)) {
73
+ errorCallback({
74
+ type: "fileAcceptError",
75
+ message: "上传失败,文件格式错误"
76
+ });
77
+ return false;
78
+ }
79
+ if (file.size <= 0) {
80
+ errorCallback({
81
+ type: "fileSizeEmpty",
82
+ message: "上传失败,不支持上传空内容文件"
83
+ });
84
+ return false;
85
+ }
86
+ if (file.size > fileUpload.maxSize) {
87
+ errorCallback({
88
+ type: "fileSizeOver",
89
+ message: "上传失败,文件大小超过限制"
90
+ });
91
+ return false;
92
+ }
93
+ let flag = recordObj.current.fileList.some((item)=>{
94
+ if (fileId) {
95
+ return item.name === file.name && item.fileId !== fileId;
96
+ } else {
97
+ return item.name === file.name;
98
+ }
99
+ });
100
+ // 判断是否有同名文件
101
+ if (flag) {
102
+ errorCallback({
103
+ type: "fileNameExist",
104
+ message: "上传失败,文件已存在"
105
+ });
106
+ return false;
107
+ }
108
+ return true;
109
+ };
110
+ const addFile = (file, fileId)=>{
111
+ console.log("addFileaddFile", file, fileUpload);
112
+ if (vaildFile(file, fileId)) {
113
+ // 等待上传
114
+ // 判断是否存在等待上传的文件
115
+ setFileList((fileList)=>{
116
+ let uploadingList = fileList.filter((item)=>item.status === "uploading");
117
+ if (uploadingList.length >= fileUpload.mapUploadCount) {
118
+ if (fileId) {
119
+ return fileList.map((item)=>{
120
+ if (item.fileId === fileId) {
121
+ let obj = fileToCustomFile(file, {});
122
+ return {
123
+ name: obj.name,
124
+ suffix: obj.suffix,
125
+ fileId: fileId,
126
+ url: "",
127
+ status: "waiting",
128
+ source: file
129
+ };
130
+ }
131
+ return item;
132
+ });
133
+ } else {
134
+ return [
135
+ ...fileList,
136
+ fileToCustomFile(file, {})
137
+ ];
138
+ }
139
+ } else {
140
+ uploadFile(file);
141
+ if (fileId) {
142
+ return fileList.map((item)=>{
143
+ if (item.fileId === fileId) {
144
+ let obj = fileToCustomFile(file, {});
145
+ return {
146
+ name: obj.name,
147
+ suffix: obj.suffix,
148
+ fileId: fileId,
149
+ url: "",
150
+ status: "uploading",
151
+ source: file
152
+ };
153
+ }
154
+ return item;
155
+ });
156
+ } else {
157
+ return [
158
+ ...fileList,
159
+ fileToCustomFile(file, {
160
+ status: "uploading"
161
+ })
162
+ ];
163
+ }
164
+ }
165
+ });
166
+ }
167
+ };
168
+ const uploadFile = (file)=>{
169
+ fileUpload.customRequest(file).then((res)=>{
170
+ setFileList((fileList)=>{
171
+ let list = fileList.map((item)=>{
172
+ if (item.source === file) {
173
+ return _object_spread({}, item, res);
174
+ }
175
+ return item;
176
+ });
177
+ let waitList = list.filter((item)=>item.status === "waiting");
178
+ if (waitList.length > 0) {
179
+ list = list.map((item)=>{
180
+ if (item.fileId === waitList[0].fileId) {
181
+ return _object_spread_props(_object_spread({}, item), {
182
+ status: "uploading"
183
+ });
184
+ }
185
+ return item;
186
+ });
187
+ uploadFile(waitList[0].source);
188
+ }
189
+ return list;
190
+ });
191
+ });
192
+ };
193
+ // 删除文件
194
+ const deleteFile = (fileId)=>{
195
+ setFileList((fileList)=>fileList.filter((item)=>item.fileId !== fileId));
196
+ // 删除文件时如果删除的是最后一条 则page-1
197
+ const { fileList, page, pageSize } = recordObj.current;
198
+ let list = fileList.slice((page - 1) * pageSize, page * pageSize);
199
+ list = list.filter((item)=>item.fileId !== fileId);
200
+ if (list.length === 0 && page > 1) {
201
+ changePage(page - 1);
202
+ }
203
+ fileUpload.deleteFileAjax && fileUpload.deleteFileAjax(fileId);
204
+ };
205
+ // 更新文件状态
206
+ const updateFile = (fileId, status)=>{
207
+ setFileList((fileList)=>fileList.map((item)=>{
208
+ if (item.fileId === fileId) {
209
+ return _object_spread_props(_object_spread({}, item), {
210
+ status: status
211
+ });
212
+ }
213
+ return item;
214
+ }));
215
+ };
216
+ // file to customFile
217
+ const fileToCustomFile = (file, params)=>{
218
+ let customFile = {
219
+ name: file.name,
220
+ suffix: getSuffix(file.name),
221
+ fileId: params.fileId || guidGenerator(),
222
+ url: params.url || "",
223
+ status: params.status || "waiting",
224
+ source: file
225
+ };
226
+ return customFile;
227
+ };
228
+ const changePage = (page)=>{
229
+ setPage(page);
230
+ setPageSize(pageSize);
231
+ };
232
+ const list = fileList.slice((page - 1) * pageSize, page * pageSize);
233
+ if (list.length === 0) return null;
234
+ return /*#__PURE__*/ _jsxs("div", {
235
+ className: `${getCls("footer-fileList-wrapper")}`,
236
+ children: [
237
+ page !== 1 && /*#__PURE__*/ _jsx("div", {
238
+ className: `${getCls("footer-fileList-pre")}`,
239
+ onClick: ()=>changePage(page - 1),
240
+ children: /*#__PURE__*/ _jsx(DoubleRightOutlined, {
241
+ onPointerEnterCapture: undefined,
242
+ onPointerLeaveCapture: undefined
243
+ })
244
+ }),
245
+ /*#__PURE__*/ _jsx("div", {
246
+ className: `${getCls("footer-fileList-list")}`,
247
+ children: list.map((item)=>{
248
+ return /*#__PURE__*/ _jsxs("div", {
249
+ className: `${getCls("footer-fileList-listItem")}`,
250
+ children: [
251
+ /*#__PURE__*/ _jsx("div", {
252
+ className: `${getCls("footer-fileList-listItem-icon")}`,
253
+ children: fileIconRender(item.suffix, fileUpload.iconFileRender)
254
+ }),
255
+ /*#__PURE__*/ _jsx("div", {
256
+ className: `${getCls("footer-fileList-listItem-text")}`,
257
+ title: item.name,
258
+ children: item.name
259
+ }),
260
+ item.status === "uploadError" ? /*#__PURE__*/ _jsx(Upload, {
261
+ fileList: [],
262
+ accept: fileUpload.accept,
263
+ customRequest: (options)=>addFile(options.file, item.fileId),
264
+ multiple: false,
265
+ children: /*#__PURE__*/ _jsx("div", {
266
+ className: `${getCls("footer-fileList-listItem-status")}`,
267
+ style: {
268
+ cursor: "pointer"
269
+ },
270
+ children: statusRender(item.status, fileUpload.statusText)
271
+ })
272
+ }) : /*#__PURE__*/ _jsx("div", {
273
+ className: `${getCls("footer-fileList-listItem-status")}`,
274
+ children: statusRender(item.status, fileUpload.statusText)
275
+ }),
276
+ /*#__PURE__*/ _jsx("div", {
277
+ className: `${getCls("footer-fileList-listItem-delete")}`,
278
+ children: /*#__PURE__*/ _jsx(CloseCircleFilled, {
279
+ onPointerEnterCapture: undefined,
280
+ onPointerLeaveCapture: undefined,
281
+ onClick: ()=>deleteFile(item.fileId)
282
+ })
283
+ })
284
+ ]
285
+ }, item.fileId);
286
+ })
287
+ }),
288
+ page * pageSize < fileList.length && /*#__PURE__*/ _jsx("div", {
289
+ className: `${getCls("footer-fileList-next")}`,
290
+ onClick: ()=>changePage(page + 1),
291
+ children: /*#__PURE__*/ _jsx(DoubleRightOutlined, {
292
+ onPointerEnterCapture: undefined,
293
+ onPointerLeaveCapture: undefined
294
+ })
295
+ })
296
+ ]
297
+ });
298
+ });
299
+ export default FileList;
@@ -0,0 +1,95 @@
1
+ .footer-fileList-wrapper {
2
+ width: 100%;
3
+ position: relative;
4
+ padding: 12px 16px;
5
+ box-sizing: border-box;
6
+ .footer-fileList-list {
7
+ width: 100%;
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: 8px;
11
+ .footer-fileList-listItem {
12
+ width: 100%;
13
+ position: relative;
14
+ display: flex;
15
+ overflow: hidden;
16
+ padding: 8px 12px;
17
+ box-sizing: border-box;
18
+ gap: 12px;
19
+ border-radius: 8px;
20
+ border: 1px solid #ebebeb;
21
+ background: rgba(0, 0, 0, 0.02);
22
+ align-items: center;
23
+ .footer-fileList-listItem-icon {
24
+ flex-shrink: 0;
25
+ & > i {
26
+ font-size: 24px;
27
+ display: flex;
28
+ }
29
+ }
30
+ .footer-fileList-listItem-text {
31
+ flex: 1;
32
+ overflow: hidden;
33
+ width: 100%;
34
+ overflow: hidden;
35
+ text-overflow: ellipsis;
36
+ color: rgba(0, 0, 0, 0.65);
37
+ font-size: 14px;
38
+ font-weight: 400;
39
+ white-space: nowrap;
40
+ }
41
+ .footer-fileList-listItem-status {
42
+ flex-shrink: 0;
43
+ }
44
+ .footer-fileList-listItem-delete {
45
+ position: absolute;
46
+ right: 0;
47
+ top: 0;
48
+ display: none;
49
+ cursor: pointer;
50
+ }
51
+
52
+ &:hover {
53
+ background: rgba(0, 0, 0, 0.06);
54
+ .footer-fileList-listItem-delete {
55
+ display: flex;
56
+ }
57
+ }
58
+ }
59
+ }
60
+ .footer-fileList-pre {
61
+ display: flex;
62
+ justify-content: center;
63
+ position: absolute;
64
+ left: 50%;
65
+ transform: translateX(-50%);
66
+ top: -8px;
67
+ z-index: 2;
68
+ :global {
69
+ .anticon-double-right {
70
+ font-size: 16px;
71
+ transform: rotate(-90deg);
72
+ color: #595959;
73
+ cursor: pointer;
74
+ }
75
+ }
76
+ }
77
+
78
+ .footer-fileList-next {
79
+ display: flex;
80
+ justify-content: center;
81
+ position: absolute;
82
+ left: 50%;
83
+ transform: translateX(-50%);
84
+ bottom: -8px;
85
+ z-index: 2;
86
+ :global {
87
+ .anticon-double-right {
88
+ font-size: 16px;
89
+ transform: rotate(90deg);
90
+ color: #595959;
91
+ cursor: pointer;
92
+ }
93
+ }
94
+ }
95
+ }
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import type { footerConfigProps, footerRefProps, errorMessageProps, AIMessageListRefProps } from "../../type";
3
+ interface IProps {
4
+ footerConfig: footerConfigProps;
5
+ prefix: string;
6
+ errorCallback: (error: errorMessageProps) => void;
7
+ apiRef: AIMessageListRefProps;
8
+ }
9
+ declare const Footer: React.ForwardRefExoticComponent<IProps & React.RefAttributes<footerRefProps>>;
10
+ export default Footer;