bhd-components 0.10.17 → 0.10.19

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.
@@ -13085,7 +13085,6 @@ var CopyIcon = function(props) {
13085
13085
  setCopySuccess(true);
13086
13086
  clearTimeout(timer.current);
13087
13087
  timer.current = setTimeout(function() {
13088
- console.log("定时器定时器");
13089
13088
  setCopySuccess(false);
13090
13089
  }, 2000);
13091
13090
  };
@@ -13129,9 +13128,7 @@ var ReferencesIcon = function(props) {
13129
13128
  return modules_63b47c51$7[clsName] + " " + prefix + "-" + clsName;
13130
13129
  };
13131
13130
  var clickFn = function() {
13132
- console.log("apiRef", apiRef);
13133
13131
  if (apiRef && apiRef.footerApi) {
13134
- console.log("itemitem", item);
13135
13132
  if (item.type === "file") {
13136
13133
  apiRef.footerApi.setReferences({
13137
13134
  type: "file",
@@ -13141,7 +13138,8 @@ var ReferencesIcon = function(props) {
13141
13138
  fileId: item.id,
13142
13139
  url: "",
13143
13140
  status: "success",
13144
- source: null
13141
+ source: null,
13142
+ size: 0
13145
13143
  },
13146
13144
  source: item
13147
13145
  });
@@ -14384,7 +14382,6 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
14384
14382
  }
14385
14383
  var list = [];
14386
14384
  if (msg.location === "right" && msg.fileList && msg.fileList.length > 0) {
14387
- console.log("fileList", msg, msg.fileList);
14388
14385
  msg.fileList.map(function(item) {
14389
14386
  list.push({
14390
14387
  type: "file",
@@ -14419,7 +14416,6 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
14419
14416
  setLoading(true);
14420
14417
  return getList(page, pageSize).then(function(listObj) {
14421
14418
  setLoading(false);
14422
- console.log("listObjlistObj", listObj);
14423
14419
  setDataSource(function(data) {
14424
14420
  return _to_consumable_array(data).concat(_to_consumable_array(listObj.dataSource));
14425
14421
  });
@@ -14559,7 +14555,6 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
14559
14555
  var topDom = dom.querySelector("." + modules_63b47c51$9["msgItem-action-popover-floatTop"]);
14560
14556
  var bottomDom = dom.querySelector("." + modules_63b47c51$9["msgItem-action-popover-floatBottom"]);
14561
14557
  if (!topDom || !bottomDom) return;
14562
- console.log("itemitem", dom, container);
14563
14558
  var con_obj = container.getBoundingClientRect(); // 外层盒子
14564
14559
  var dom_obj = dom.getBoundingClientRect(); // 鼠标滑过元素
14565
14560
  var y = dom_obj.y - con_obj.y;
@@ -14575,7 +14570,6 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
14575
14570
  topDom.style.cssText = "display:flex";
14576
14571
  }
14577
14572
  } else {
14578
- console.log("yyyy", y, dom_obj, con_obj, y + dom_obj.height < con_obj.height);
14579
14573
  // 元素top不在可视区域内
14580
14574
  if (y + dom_obj.height < con_obj.height) {
14581
14575
  // 底部在可视区域内
@@ -15005,11 +14999,11 @@ var getSuffix = function(fileName) {
15005
14999
  return fileName.split(".").pop().toLowerCase();
15006
15000
  };
15007
15001
  var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
15008
- var prefix = props.prefix, fileUpload = props.fileUpload, errorCallback = props.errorCallback, changeFileCanSending = props.changeFileCanSending;
15009
- console.log("fileUpload", fileUpload);
15002
+ var prefix = props.prefix, fileUpload = props.fileUpload, errorCallback = props.errorCallback, changeFileCanSending = props.changeFileCanSending, onChange = props.onChange;
15010
15003
  var _useState = _sliced_to_array(useState([]), 2), fileList = _useState[0], setFileList = _useState[1];
15011
15004
  var _useState1 = _sliced_to_array(useState(1), 2), page = _useState1[0], setPage = _useState1[1];
15012
15005
  var _useState2 = _sliced_to_array(useState(5), 2), pageSize = _useState2[0], setPageSize = _useState2[1];
15006
+ var recordListLength = useRef(0);
15013
15007
  var recordObj = useRef({
15014
15008
  page: page,
15015
15009
  pageSize: pageSize,
@@ -15019,6 +15013,11 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
15019
15013
  recordObj.current.page = page;
15020
15014
  recordObj.current.pageSize = pageSize;
15021
15015
  recordObj.current.fileList = fileList;
15016
+ onChange && onChange({
15017
+ page: page,
15018
+ pageSize: pageSize,
15019
+ fileList: fileList
15020
+ });
15022
15021
  }, [
15023
15022
  page,
15024
15023
  pageSize,
@@ -15057,10 +15056,11 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
15057
15056
  return modules_63b47c51$1[clsName] + " " + prefix + "-" + clsName;
15058
15057
  };
15059
15058
  var clearFileList = function() {
15059
+ recordListLength.current = 0;
15060
15060
  setFileList([]);
15061
15061
  };
15062
15062
  var vaildFile = function(file, fileId) {
15063
- if (fileUpload.maxCount > 0 && recordObj.current.fileList.length > fileUpload.maxCount) {
15063
+ if (fileUpload.maxCount > 0 && recordListLength.current + 1 > fileUpload.maxCount) {
15064
15064
  errorCallback({
15065
15065
  type: "fileCountOver",
15066
15066
  message: "上传失败,文件数量超过限制"
@@ -15111,8 +15111,8 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
15111
15111
  return true;
15112
15112
  };
15113
15113
  var addFile = function(file, fileId) {
15114
- console.log("addFileaddFile", file, fileUpload);
15115
15114
  if (vaildFile(file, fileId)) {
15115
+ recordListLength.current += 1;
15116
15116
  // 等待上传
15117
15117
  // 判断是否存在等待上传的文件
15118
15118
  setFileList(function(fileList) {
@@ -15200,13 +15200,14 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
15200
15200
  // 删除文件
15201
15201
  var deleteFile = function(fileId) {
15202
15202
  var fileObj = null;
15203
+ recordListLength.current -= 0;
15203
15204
  setFileList(function(fileList) {
15204
15205
  return fileList.filter(function(item) {
15205
15206
  if (item.fileId === fileId) {
15206
15207
  fileObj = item;
15207
- return true;
15208
+ return false;
15208
15209
  }
15209
- return false;
15210
+ return true;
15210
15211
  });
15211
15212
  });
15212
15213
  // 删除文件时如果删除的是最后一条 则page-1
@@ -15250,6 +15251,24 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
15250
15251
  setPage(page);
15251
15252
  setPageSize(pageSize);
15252
15253
  };
15254
+ var retryUploadFile = function(fileItem) {
15255
+ setFileList(function(fileList) {
15256
+ var uploadingList = fileList.filter(function(item) {
15257
+ return item.status === "uploading";
15258
+ });
15259
+ return fileList.map(function(item) {
15260
+ if (fileItem.fileId === item.fileId) {
15261
+ if (uploadingList.length >= fileUpload.mapUploadCount) {
15262
+ item.status = "waiting";
15263
+ } else {
15264
+ item.status = "uploading";
15265
+ uploadFile(item.source);
15266
+ }
15267
+ }
15268
+ return item;
15269
+ });
15270
+ });
15271
+ };
15253
15272
  var list = fileList.slice((page - 1) * pageSize, page * pageSize);
15254
15273
  if (list.length === 0) return null;
15255
15274
  return /*#__PURE__*/ jsxs("div", {
@@ -15260,10 +15279,7 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
15260
15279
  onClick: function() {
15261
15280
  return changePage(page - 1);
15262
15281
  },
15263
- children: /*#__PURE__*/ jsx(DoubleRightOutlined, {
15264
- onPointerEnterCapture: undefined,
15265
- onPointerLeaveCapture: undefined
15266
- })
15282
+ children: /*#__PURE__*/ jsx(DoubleRightOutlined, {})
15267
15283
  }),
15268
15284
  /*#__PURE__*/ jsx("div", {
15269
15285
  className: "".concat(getCls("footer-fileList-list")),
@@ -15280,20 +15296,30 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
15280
15296
  title: item.name,
15281
15297
  children: item.name
15282
15298
  }),
15283
- item.status === "uploadError" ? /*#__PURE__*/ jsx(Upload, {
15284
- fileList: [],
15285
- accept: fileUpload.accept,
15286
- customRequest: function(options) {
15287
- return addFile(options.file, item.fileId);
15299
+ item.status === "uploadError" ? // <Upload
15300
+ // fileList={[]}
15301
+ // accept={fileUpload.accept}
15302
+ // customRequest={(options: any) =>
15303
+ // addFile(options.file, item.fileId)
15304
+ // }
15305
+ // multiple={false}
15306
+ // >
15307
+ // <div
15308
+ // className={`${getCls("footer-fileList-listItem-status")}`}
15309
+ // style={{ cursor: "pointer" }}
15310
+ // >
15311
+ // {statusRender(item.status, fileUpload.statusText)}
15312
+ // </div>
15313
+ // </Upload>
15314
+ /*#__PURE__*/ jsx("div", {
15315
+ className: "".concat(getCls("footer-fileList-listItem-status")),
15316
+ style: {
15317
+ cursor: "pointer"
15288
15318
  },
15289
- multiple: false,
15290
- children: /*#__PURE__*/ jsx("div", {
15291
- className: "".concat(getCls("footer-fileList-listItem-status")),
15292
- style: {
15293
- cursor: "pointer"
15294
- },
15295
- children: statusRender(item.status, fileUpload.statusText)
15296
- })
15319
+ onClick: function() {
15320
+ return retryUploadFile(item);
15321
+ },
15322
+ children: statusRender(item.status, fileUpload.statusText)
15297
15323
  }) : /*#__PURE__*/ jsx("div", {
15298
15324
  className: "".concat(getCls("footer-fileList-listItem-status")),
15299
15325
  children: statusRender(item.status, fileUpload.statusText)
@@ -15301,8 +15327,6 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
15301
15327
  /*#__PURE__*/ jsx("div", {
15302
15328
  className: "".concat(getCls("footer-fileList-listItem-delete")),
15303
15329
  children: /*#__PURE__*/ jsx(CloseCircleFilled, {
15304
- onPointerEnterCapture: undefined,
15305
- onPointerLeaveCapture: undefined,
15306
15330
  onClick: function() {
15307
15331
  return deleteFile(item.fileId);
15308
15332
  }
@@ -15317,10 +15341,7 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
15317
15341
  onClick: function() {
15318
15342
  return changePage(page + 1);
15319
15343
  },
15320
- children: /*#__PURE__*/ jsx(DoubleRightOutlined, {
15321
- onPointerEnterCapture: undefined,
15322
- onPointerLeaveCapture: undefined
15323
- })
15344
+ children: /*#__PURE__*/ jsx(DoubleRightOutlined, {})
15324
15345
  })
15325
15346
  ]
15326
15347
  });
@@ -15349,8 +15370,6 @@ var References = function(props) {
15349
15370
  /*#__PURE__*/ jsx("div", {
15350
15371
  className: "".concat(getCls("footerReferences_right")),
15351
15372
  children: /*#__PURE__*/ jsx(CloseCircleFilled, {
15352
- onPointerEnterCapture: undefined,
15353
- onPointerLeaveCapture: undefined,
15354
15373
  onClick: function() {
15355
15374
  return deleteReferences();
15356
15375
  }
@@ -15383,8 +15402,6 @@ var References = function(props) {
15383
15402
  /*#__PURE__*/ jsx("div", {
15384
15403
  className: "".concat(getCls("footerReferences_right")),
15385
15404
  children: /*#__PURE__*/ jsx(CloseCircleFilled, {
15386
- onPointerEnterCapture: undefined,
15387
- onPointerLeaveCapture: undefined,
15388
15405
  onClick: function() {
15389
15406
  return deleteReferences();
15390
15407
  }
@@ -15427,6 +15444,11 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
15427
15444
  var _useState1 = _sliced_to_array(useState(false), 2), sending = _useState1[0], setSending = _useState1[1];
15428
15445
  var _useState2 = _sliced_to_array(useState(true), 2), fileCanSending = _useState2[0], setFileCanSending = _useState2[1]; // 是否允许发送 关联文件
15429
15446
  var updateMsgRef = useRef(null);
15447
+ var recordFileList = useRef({
15448
+ page: 1,
15449
+ pageSize: 5,
15450
+ fileList: []
15451
+ });
15430
15452
  // const [referencesSource, setReferencesSource] = useState<referenceType>({
15431
15453
  // type: "file",
15432
15454
  // value: {
@@ -15535,7 +15557,6 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
15535
15557
  fileUpload: fileUpload,
15536
15558
  customRequest: function(options) {
15537
15559
  var _fileListRef_current;
15538
- console.log("customRequestcustomRequest", options);
15539
15560
  (_fileListRef_current = fileListRef.current) === null || _fileListRef_current === void 0 ? void 0 : _fileListRef_current.addFile(options.file);
15540
15561
  }
15541
15562
  });
@@ -15584,10 +15605,10 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
15584
15605
  };
15585
15606
  // 发现消息
15586
15607
  var sendMsg = function(value) {
15587
- console.log("发送消息:", value);
15588
15608
  if (value.trim().length === 0) {
15589
15609
  throw new Error("消息不能为空");
15590
15610
  }
15611
+ recordRef.current.value = value;
15591
15612
  apiRef.contentApi.addMsg({
15592
15613
  id: guidGenerator(),
15593
15614
  createTime: new Date().getTime(),
@@ -15628,7 +15649,6 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
15628
15649
  } : _sendMsgAjaxParams_beforeSendMsg;
15629
15650
  ctrl.current = new AbortController();
15630
15651
  // apiRef
15631
- console.log("apiRef", apiRef);
15632
15652
  var msgId = "inputing";
15633
15653
  var createTime = new Date().getTime();
15634
15654
  if (recordObj) {
@@ -15677,6 +15697,9 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
15677
15697
  ];
15678
15698
  }
15679
15699
  beforeSendMsg.apply(void 0, _to_consumable_array(arg)).then(function(beforeInfo) {
15700
+ var bodyParams = params.apply(void 0, _to_consumable_array(arg).concat([
15701
+ beforeInfo
15702
+ ]));
15680
15703
  var callback = function() {
15681
15704
  var isClose = false;
15682
15705
  var closeCallback = function() {
@@ -15688,7 +15711,6 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
15688
15711
  apiRef.contentApi.recordMsg(recordMsgObj);
15689
15712
  }
15690
15713
  apiRef.contentApi.setSendingId("");
15691
- console.log("onclose: ", recordMsgObj);
15692
15714
  };
15693
15715
  fetchEventSource(url, _object_spread({
15694
15716
  method: method,
@@ -15696,9 +15718,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
15696
15718
  "Content-Type": "application/json",
15697
15719
  Accept: "text/event-stream,application/json"
15698
15720
  }, headers()),
15699
- body: params.apply(void 0, _to_consumable_array(arg).concat([
15700
- beforeInfo
15701
- ])),
15721
+ body: bodyParams,
15702
15722
  openWhenHidden: true,
15703
15723
  signal: ctrl.current.signal,
15704
15724
  onopen: function(res) {
@@ -15712,7 +15732,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
15712
15732
  return null;
15713
15733
  },
15714
15734
  onmessage: function(ev) {
15715
- var data = onMessage(ev, closeCallback);
15735
+ var data = onMessage(ev, closeCallback, bodyParams, msgId);
15716
15736
  if (recordObj) {
15717
15737
  data.id = recordObj.id;
15718
15738
  }
@@ -15742,7 +15762,6 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
15742
15762
  if (recordMsgObj.id) {
15743
15763
  apiRef.contentApi.recordMsg(recordMsgObj);
15744
15764
  }
15745
- console.log("onerror: ", err);
15746
15765
  }
15747
15766
  }, coverProps));
15748
15767
  };
@@ -15772,7 +15791,13 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
15772
15791
  fileUpload: fileUpload,
15773
15792
  ref: fileListRef,
15774
15793
  errorCallback: errorCallback,
15775
- changeFileCanSending: setFileCanSending
15794
+ changeFileCanSending: setFileCanSending,
15795
+ onChange: function(param) {
15796
+ var page = param.page, pageSize = param.pageSize, fileList = param.fileList;
15797
+ recordFileList.current.fileList = fileList;
15798
+ recordFileList.current.page = page;
15799
+ recordFileList.current.pageSize = pageSize;
15800
+ }
15776
15801
  })
15777
15802
  }),
15778
15803
  /*#__PURE__*/ jsxs("div", {