bhd-components 0.10.12 → 0.10.14

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 (116) hide show
  1. package/README.md +1 -1
  2. package/dist/index.esm.es5.development.css +768 -0
  3. package/dist/index.esm.es5.development.js +3133 -159
  4. package/dist/index.esm.es5.production.css +1 -1
  5. package/dist/index.esm.es5.production.js +1 -1
  6. package/dist/vendor.esm.es5.development.js +2515 -1100
  7. package/dist/vendor.esm.es5.production.js +136 -136
  8. package/es2017/AIMessageList/components/content/index.d.ts +4 -0
  9. package/es2017/AIMessageList/components/content/index.js +29 -0
  10. package/es2017/AIMessageList/components/content/index.module.less +8 -0
  11. package/es2017/AIMessageList/components/copyIcon/index.d.ts +7 -0
  12. package/es2017/AIMessageList/components/copyIcon/index.js +73 -0
  13. package/es2017/AIMessageList/components/copyIcon/index.module.less +23 -0
  14. package/es2017/AIMessageList/components/errorCallback/index.d.ts +3 -0
  15. package/es2017/AIMessageList/components/errorCallback/index.js +6 -0
  16. package/es2017/AIMessageList/components/fileList/fileIcon.d.ts +3 -0
  17. package/es2017/AIMessageList/components/fileList/fileIcon.js +970 -0
  18. package/es2017/AIMessageList/components/fileList/index.d.ts +4 -0
  19. package/es2017/AIMessageList/components/fileList/index.js +315 -0
  20. package/es2017/AIMessageList/components/fileList/index.module.less +95 -0
  21. package/es2017/AIMessageList/components/footer/index.d.ts +10 -0
  22. package/es2017/AIMessageList/components/footer/index.js +402 -0
  23. package/es2017/AIMessageList/components/footer/index.module.less +51 -0
  24. package/es2017/AIMessageList/components/header/index.d.ts +9 -0
  25. package/es2017/AIMessageList/components/header/index.js +94 -0
  26. package/es2017/AIMessageList/components/header/index.module.less +31 -0
  27. package/es2017/AIMessageList/components/referencesIcon/index.d.ts +9 -0
  28. package/es2017/AIMessageList/components/referencesIcon/index.js +63 -0
  29. package/es2017/AIMessageList/components/referencesIcon/index.module.less +14 -0
  30. package/es2017/AIMessageList/components/refreshBtn/index.d.ts +4 -0
  31. package/es2017/AIMessageList/components/refreshBtn/index.js +29 -0
  32. package/es2017/AIMessageList/components/refreshBtn/index.module.less +12 -0
  33. package/es2017/AIMessageList/components/remarkBtn/index.d.ts +4 -0
  34. package/es2017/AIMessageList/components/remarkBtn/index.js +51 -0
  35. package/es2017/AIMessageList/components/remarkBtn/index.module.less +13 -0
  36. package/es2017/AIMessageList/components/renderReferrnce/index.d.ts +10 -0
  37. package/es2017/AIMessageList/components/renderReferrnce/index.js +68 -0
  38. package/es2017/AIMessageList/components/renderReferrnce/index.module.less +64 -0
  39. package/es2017/AIMessageList/components/sendBtn/index.d.ts +4 -0
  40. package/es2017/AIMessageList/components/sendBtn/index.js +51 -0
  41. package/es2017/AIMessageList/components/sendBtn/index.module.less +25 -0
  42. package/es2017/AIMessageList/components/uplodaFileBtn/index.d.ts +4 -0
  43. package/es2017/AIMessageList/components/uplodaFileBtn/index.js +33 -0
  44. package/es2017/AIMessageList/components/uplodaFileBtn/index.module.less +5 -0
  45. package/es2017/AIMessageList/components/virtuosoList/index.d.ts +5 -0
  46. package/es2017/AIMessageList/components/virtuosoList/index.js +696 -0
  47. package/es2017/AIMessageList/components/virtuosoList/index.module.less +467 -0
  48. package/es2017/AIMessageList/index.d.ts +4 -0
  49. package/es2017/AIMessageList/index.js +58 -0
  50. package/es2017/AIMessageList/index.module.less +20 -0
  51. package/es2017/AIMessageList/type.d.ts +307 -0
  52. package/es2017/customerService/index.js +1 -0
  53. package/es2017/images/loading2.js +2 -0
  54. package/es2017/index.d.ts +1 -0
  55. package/es2017/index.js +1 -0
  56. package/es2017/utils/Date.d.ts +2 -1
  57. package/es2017/utils/Date.js +2 -1
  58. package/es2017/utils/dom.d.ts +4 -1
  59. package/es2017/utils/dom.js +44 -1
  60. package/es2017/utils/number.d.ts +1 -0
  61. package/es2017/utils/number.js +9 -0
  62. package/esm/AIMessageList/components/content/index.d.ts +4 -0
  63. package/esm/AIMessageList/components/content/index.js +29 -0
  64. package/esm/AIMessageList/components/content/index.module.less +8 -0
  65. package/esm/AIMessageList/components/copyIcon/index.d.ts +7 -0
  66. package/esm/AIMessageList/components/copyIcon/index.js +76 -0
  67. package/esm/AIMessageList/components/copyIcon/index.module.less +23 -0
  68. package/esm/AIMessageList/components/errorCallback/index.d.ts +3 -0
  69. package/esm/AIMessageList/components/errorCallback/index.js +6 -0
  70. package/esm/AIMessageList/components/fileList/fileIcon.d.ts +3 -0
  71. package/esm/AIMessageList/components/fileList/fileIcon.js +970 -0
  72. package/esm/AIMessageList/components/fileList/index.d.ts +4 -0
  73. package/esm/AIMessageList/components/fileList/index.js +337 -0
  74. package/esm/AIMessageList/components/fileList/index.module.less +95 -0
  75. package/esm/AIMessageList/components/footer/index.d.ts +10 -0
  76. package/esm/AIMessageList/components/footer/index.js +418 -0
  77. package/esm/AIMessageList/components/footer/index.module.less +51 -0
  78. package/esm/AIMessageList/components/header/index.d.ts +9 -0
  79. package/esm/AIMessageList/components/header/index.js +96 -0
  80. package/esm/AIMessageList/components/header/index.module.less +31 -0
  81. package/esm/AIMessageList/components/referencesIcon/index.d.ts +9 -0
  82. package/esm/AIMessageList/components/referencesIcon/index.js +65 -0
  83. package/esm/AIMessageList/components/referencesIcon/index.module.less +14 -0
  84. package/esm/AIMessageList/components/refreshBtn/index.d.ts +4 -0
  85. package/esm/AIMessageList/components/refreshBtn/index.js +31 -0
  86. package/esm/AIMessageList/components/refreshBtn/index.module.less +12 -0
  87. package/esm/AIMessageList/components/remarkBtn/index.d.ts +4 -0
  88. package/esm/AIMessageList/components/remarkBtn/index.js +51 -0
  89. package/esm/AIMessageList/components/remarkBtn/index.module.less +13 -0
  90. package/esm/AIMessageList/components/renderReferrnce/index.d.ts +10 -0
  91. package/esm/AIMessageList/components/renderReferrnce/index.js +72 -0
  92. package/esm/AIMessageList/components/renderReferrnce/index.module.less +64 -0
  93. package/esm/AIMessageList/components/sendBtn/index.d.ts +4 -0
  94. package/esm/AIMessageList/components/sendBtn/index.js +53 -0
  95. package/esm/AIMessageList/components/sendBtn/index.module.less +25 -0
  96. package/esm/AIMessageList/components/uplodaFileBtn/index.d.ts +4 -0
  97. package/esm/AIMessageList/components/uplodaFileBtn/index.js +33 -0
  98. package/esm/AIMessageList/components/uplodaFileBtn/index.module.less +5 -0
  99. package/esm/AIMessageList/components/virtuosoList/index.d.ts +5 -0
  100. package/esm/AIMessageList/components/virtuosoList/index.js +673 -0
  101. package/esm/AIMessageList/components/virtuosoList/index.module.less +467 -0
  102. package/esm/AIMessageList/index.d.ts +4 -0
  103. package/esm/AIMessageList/index.js +58 -0
  104. package/esm/AIMessageList/index.module.less +20 -0
  105. package/esm/AIMessageList/type.d.ts +307 -0
  106. package/esm/customerService/index.js +1 -0
  107. package/esm/images/loading2.js +2 -0
  108. package/esm/index.d.ts +1 -0
  109. package/esm/index.js +1 -0
  110. package/esm/utils/Date.d.ts +2 -1
  111. package/esm/utils/Date.js +2 -1
  112. package/esm/utils/dom.d.ts +4 -1
  113. package/esm/utils/dom.js +45 -1
  114. package/esm/utils/number.d.ts +1 -0
  115. package/esm/utils/number.js +9 -0
  116. 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,315 @@
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
+ clearFileList
57
+ };
58
+ });
59
+ const getCls = (clsName)=>{
60
+ return styles[clsName] + " " + prefix + "-" + clsName;
61
+ };
62
+ const clearFileList = ()=>{
63
+ setFileList([]);
64
+ };
65
+ const vaildFile = (file, fileId)=>{
66
+ if (fileUpload.maxCount > 0 && recordObj.current.fileList.length > fileUpload.maxCount) {
67
+ errorCallback({
68
+ type: "fileCountOver",
69
+ message: "上传失败,文件数量超过限制"
70
+ });
71
+ return false;
72
+ }
73
+ // fileUpload
74
+ let acceptList = fileUpload.accept.split(/[.,]/).filter((item)=>!!item);
75
+ let suffix = getSuffix(file.name);
76
+ if (!acceptList.includes(suffix)) {
77
+ errorCallback({
78
+ type: "fileAcceptError",
79
+ message: "上传失败,文件格式错误"
80
+ });
81
+ return false;
82
+ }
83
+ if (file.size <= 0) {
84
+ errorCallback({
85
+ type: "fileSizeEmpty",
86
+ message: "上传失败,不支持上传空内容文件"
87
+ });
88
+ return false;
89
+ }
90
+ if (file.size > fileUpload.maxSize) {
91
+ errorCallback({
92
+ type: "fileSizeOver",
93
+ message: "上传失败,文件大小超过限制"
94
+ });
95
+ return false;
96
+ }
97
+ let flag = recordObj.current.fileList.some((item)=>{
98
+ if (fileId) {
99
+ return item.name === file.name && item.fileId !== fileId;
100
+ } else {
101
+ return item.name === file.name;
102
+ }
103
+ });
104
+ // 判断是否有同名文件
105
+ if (flag) {
106
+ errorCallback({
107
+ type: "fileNameExist",
108
+ message: "上传失败,文件已存在"
109
+ });
110
+ return false;
111
+ }
112
+ return true;
113
+ };
114
+ const addFile = (file, fileId)=>{
115
+ console.log("addFileaddFile", file, fileUpload);
116
+ if (vaildFile(file, fileId)) {
117
+ // 等待上传
118
+ // 判断是否存在等待上传的文件
119
+ setFileList((fileList)=>{
120
+ let uploadingList = fileList.filter((item)=>item.status === "uploading");
121
+ if (uploadingList.length >= fileUpload.mapUploadCount) {
122
+ if (fileId) {
123
+ return fileList.map((item)=>{
124
+ if (item.fileId === fileId) {
125
+ let obj = fileToCustomFile(file, {});
126
+ return {
127
+ name: obj.name,
128
+ suffix: obj.suffix,
129
+ fileId: fileId,
130
+ url: "",
131
+ status: "waiting",
132
+ source: file,
133
+ size: file.size
134
+ };
135
+ }
136
+ return item;
137
+ });
138
+ } else {
139
+ return [
140
+ ...fileList,
141
+ fileToCustomFile(file, {})
142
+ ];
143
+ }
144
+ } else {
145
+ uploadFile(file);
146
+ if (fileId) {
147
+ return fileList.map((item)=>{
148
+ if (item.fileId === fileId) {
149
+ let obj = fileToCustomFile(file, {});
150
+ return {
151
+ name: obj.name,
152
+ suffix: obj.suffix,
153
+ fileId: fileId,
154
+ url: "",
155
+ status: "uploading",
156
+ source: file,
157
+ size: file.size
158
+ };
159
+ }
160
+ return item;
161
+ });
162
+ } else {
163
+ return [
164
+ ...fileList,
165
+ fileToCustomFile(file, {
166
+ status: "uploading"
167
+ })
168
+ ];
169
+ }
170
+ }
171
+ });
172
+ }
173
+ };
174
+ const uploadFile = (file)=>{
175
+ fileUpload.customRequest(file).then((res)=>{
176
+ setFileList((fileList)=>{
177
+ let list = fileList.map((item)=>{
178
+ if (item.source === file) {
179
+ return _object_spread({}, item, res);
180
+ }
181
+ return item;
182
+ });
183
+ let waitList = list.filter((item)=>item.status === "waiting");
184
+ if (waitList.length > 0) {
185
+ list = list.map((item)=>{
186
+ if (item.fileId === waitList[0].fileId) {
187
+ return _object_spread_props(_object_spread({}, item), {
188
+ status: "uploading"
189
+ });
190
+ }
191
+ return item;
192
+ });
193
+ uploadFile(waitList[0].source);
194
+ }
195
+ return list;
196
+ });
197
+ });
198
+ };
199
+ // 删除文件
200
+ const deleteFile = (fileId)=>{
201
+ let fileObj = null;
202
+ setFileList((fileList)=>{
203
+ return fileList.filter((item)=>{
204
+ if (item.fileId === fileId) {
205
+ fileObj = item;
206
+ return true;
207
+ }
208
+ return false;
209
+ });
210
+ });
211
+ // 删除文件时如果删除的是最后一条 则page-1
212
+ const { fileList, page, pageSize } = recordObj.current;
213
+ let list = fileList.slice((page - 1) * pageSize, page * pageSize);
214
+ list = list.filter((item)=>item.fileId !== fileId);
215
+ if (list.length === 0 && page > 1) {
216
+ changePage(page - 1);
217
+ }
218
+ fileUpload.deleteFileAjax && fileUpload.deleteFileAjax(fileId, fileObj);
219
+ };
220
+ // 更新文件状态
221
+ const updateFile = (fileId, status)=>{
222
+ setFileList((fileList)=>fileList.map((item)=>{
223
+ if (item.fileId === fileId) {
224
+ return _object_spread_props(_object_spread({}, item), {
225
+ status: status
226
+ });
227
+ }
228
+ return item;
229
+ }));
230
+ };
231
+ // file to customFile
232
+ const fileToCustomFile = (file, params)=>{
233
+ let customFile = {
234
+ name: file.name,
235
+ suffix: getSuffix(file.name),
236
+ fileId: params.fileId || guidGenerator(),
237
+ url: params.url || "",
238
+ status: params.status || "waiting",
239
+ source: file,
240
+ size: file.size
241
+ };
242
+ return customFile;
243
+ };
244
+ const changePage = (page)=>{
245
+ setPage(page);
246
+ setPageSize(pageSize);
247
+ };
248
+ const list = fileList.slice((page - 1) * pageSize, page * pageSize);
249
+ if (list.length === 0) return null;
250
+ return /*#__PURE__*/ _jsxs("div", {
251
+ className: `${getCls("footer-fileList-wrapper")}`,
252
+ children: [
253
+ page !== 1 && /*#__PURE__*/ _jsx("div", {
254
+ className: `${getCls("footer-fileList-pre")}`,
255
+ onClick: ()=>changePage(page - 1),
256
+ children: /*#__PURE__*/ _jsx(DoubleRightOutlined, {
257
+ onPointerEnterCapture: undefined,
258
+ onPointerLeaveCapture: undefined
259
+ })
260
+ }),
261
+ /*#__PURE__*/ _jsx("div", {
262
+ className: `${getCls("footer-fileList-list")}`,
263
+ children: list.map((item)=>{
264
+ return /*#__PURE__*/ _jsxs("div", {
265
+ className: `${getCls("footer-fileList-listItem")}`,
266
+ children: [
267
+ /*#__PURE__*/ _jsx("div", {
268
+ className: `${getCls("footer-fileList-listItem-icon")}`,
269
+ children: fileIconRender(item.suffix, fileUpload.iconFileRender)
270
+ }),
271
+ /*#__PURE__*/ _jsx("div", {
272
+ className: `${getCls("footer-fileList-listItem-text")}`,
273
+ title: item.name,
274
+ children: item.name
275
+ }),
276
+ item.status === "uploadError" ? /*#__PURE__*/ _jsx(Upload, {
277
+ fileList: [],
278
+ accept: fileUpload.accept,
279
+ customRequest: (options)=>addFile(options.file, item.fileId),
280
+ multiple: false,
281
+ children: /*#__PURE__*/ _jsx("div", {
282
+ className: `${getCls("footer-fileList-listItem-status")}`,
283
+ style: {
284
+ cursor: "pointer"
285
+ },
286
+ children: statusRender(item.status, fileUpload.statusText)
287
+ })
288
+ }) : /*#__PURE__*/ _jsx("div", {
289
+ className: `${getCls("footer-fileList-listItem-status")}`,
290
+ children: statusRender(item.status, fileUpload.statusText)
291
+ }),
292
+ /*#__PURE__*/ _jsx("div", {
293
+ className: `${getCls("footer-fileList-listItem-delete")}`,
294
+ children: /*#__PURE__*/ _jsx(CloseCircleFilled, {
295
+ onPointerEnterCapture: undefined,
296
+ onPointerLeaveCapture: undefined,
297
+ onClick: ()=>deleteFile(item.fileId)
298
+ })
299
+ })
300
+ ]
301
+ }, item.fileId);
302
+ })
303
+ }),
304
+ page * pageSize < fileList.length && /*#__PURE__*/ _jsx("div", {
305
+ className: `${getCls("footer-fileList-next")}`,
306
+ onClick: ()=>changePage(page + 1),
307
+ children: /*#__PURE__*/ _jsx(DoubleRightOutlined, {
308
+ onPointerEnterCapture: undefined,
309
+ onPointerLeaveCapture: undefined
310
+ })
311
+ })
312
+ ]
313
+ });
314
+ });
315
+ 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;