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