bhd-components 0.10.3 → 0.10.5

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # bhd-components
2
2
 
3
- **当前版本:** 0.9.26
3
+ **当前版本:** 0.10.4
4
4
 
5
5
  ## Install
6
6
 
@@ -13640,7 +13640,7 @@ var sendingSvg = /*#__PURE__*/ jsx("svg", {
13640
13640
  })
13641
13641
  });
13642
13642
  var SendBtn$1 = function(props) {
13643
- var prefix = props.prefix, canSendMsg = props.canSendMsg, sending = props.sending, stopMessage = props.stopMessage;
13643
+ var prefix = props.prefix, canSendMsg = props.canSendMsg, sending = props.sending, stopMessage = props.stopMessage, _props_clickFn = props.clickFn, clickFn = _props_clickFn === void 0 ? function() {} : _props_clickFn;
13644
13644
  var getCls = function(clsName) {
13645
13645
  return modules_63b47c51$3[clsName] + " " + prefix + "-" + clsName;
13646
13646
  };
@@ -13659,6 +13659,11 @@ var SendBtn$1 = function(props) {
13659
13659
  }
13660
13660
  return /*#__PURE__*/ jsx("i", {
13661
13661
  className: "".concat(getCls("sendBtnIcon"), " ").concat(canSendMsg ? "" : getCls("disabled")),
13662
+ onClick: function() {
13663
+ if (canSendMsg) {
13664
+ clickFn();
13665
+ }
13666
+ },
13662
13667
  children: sendBtnSvg
13663
13668
  });
13664
13669
  };
@@ -15165,7 +15170,11 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
15165
15170
  prefix: prefix,
15166
15171
  canSendMsg: canSendMsg,
15167
15172
  sending: sending,
15168
- stopMessage: stopMessage
15173
+ stopMessage: stopMessage,
15174
+ clickFn: function() {
15175
+ if (textValue.trim().length === 0) return;
15176
+ sendMsg(textValue);
15177
+ }
15169
15178
  });
15170
15179
  if (fileUpload) {
15171
15180
  var fileNode = /*#__PURE__*/ jsx(UploadFileBtn, {
@@ -15239,7 +15248,9 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
15239
15248
  return "";
15240
15249
  } : _sendMsgAjaxParams_params, _sendMsgAjaxParams_onOpen = sendMsgAjaxParams.onOpen, onOpen = _sendMsgAjaxParams_onOpen === void 0 ? function() {} : _sendMsgAjaxParams_onOpen, _sendMsgAjaxParams_onMessage = sendMsgAjaxParams.onMessage, onMessage = _sendMsgAjaxParams_onMessage === void 0 ? function(ev) {
15241
15250
  return ev;
15242
- } : _sendMsgAjaxParams_onMessage, _sendMsgAjaxParams_onClose = sendMsgAjaxParams.onClose, onClose = _sendMsgAjaxParams_onClose === void 0 ? function() {} : _sendMsgAjaxParams_onClose, _sendMsgAjaxParams_onError = sendMsgAjaxParams.onError, onError = _sendMsgAjaxParams_onError === void 0 ? function() {} : _sendMsgAjaxParams_onError, _sendMsgAjaxParams_coverProps = sendMsgAjaxParams.coverProps, coverProps = _sendMsgAjaxParams_coverProps === void 0 ? {} : _sendMsgAjaxParams_coverProps;
15251
+ } : _sendMsgAjaxParams_onMessage, _sendMsgAjaxParams_onClose = sendMsgAjaxParams.onClose, onClose = _sendMsgAjaxParams_onClose === void 0 ? function() {} : _sendMsgAjaxParams_onClose, _sendMsgAjaxParams_onError = sendMsgAjaxParams.onError, onError = _sendMsgAjaxParams_onError === void 0 ? function() {} : _sendMsgAjaxParams_onError, _sendMsgAjaxParams_coverProps = sendMsgAjaxParams.coverProps, coverProps = _sendMsgAjaxParams_coverProps === void 0 ? {} : _sendMsgAjaxParams_coverProps, _sendMsgAjaxParams_beforeSendMsg = sendMsgAjaxParams.beforeSendMsg, beforeSendMsg = _sendMsgAjaxParams_beforeSendMsg === void 0 ? function() {
15252
+ return Promise.resolve();
15253
+ } : _sendMsgAjaxParams_beforeSendMsg;
15243
15254
  ctrl.current = new AbortController();
15244
15255
  // apiRef
15245
15256
  console.log("apiRef", apiRef);
@@ -15263,52 +15274,58 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
15263
15274
  recordRef.current.referencesSource,
15264
15275
  fileListRef.current ? fileListRef.current.getFileList() : []
15265
15276
  ];
15266
- fetchEventSource(url, _object_spread({
15267
- method: method,
15268
- headers: _object_spread({
15269
- "Content-Type": "application/json",
15270
- Accept: "text/event-stream,application/json"
15271
- }, headers),
15272
- body: params.apply(void 0, _to_consumable_array(arg)),
15273
- openWhenHidden: true,
15274
- signal: ctrl.current.signal,
15275
- onopen: function(res) {
15276
- onOpen(res);
15277
- if (res.status === 200) ;
15278
- return null;
15279
- },
15280
- onmessage: function(ev) {
15281
- var data = onMessage(ev);
15282
- msgContent += data.content;
15283
- delete data.content;
15284
- recordMsgObj = _object_spread({
15285
- createTime: createTime,
15286
- content: msgContent,
15287
- location: "left",
15288
- reference: null,
15289
- source: null
15290
- }, data);
15291
- updateMsgRef.current = setTimeout(function() {
15292
- apiRef.contentApi.updateMsg(msgId, recordMsgObj);
15293
- msgId = data.id;
15294
- }, 100);
15295
- },
15296
- onclose: function() {
15297
- onClose();
15298
- setSending(false);
15299
- if (recordMsgObj.id) {
15300
- apiRef.contentApi.recordMsg(recordMsgObj);
15301
- }
15302
- console.log("onclose: ", recordMsgObj);
15303
- },
15304
- onerror: function(err) {
15305
- onError(err);
15306
- if (recordMsgObj.id) {
15307
- apiRef.contentApi.recordMsg(recordMsgObj);
15277
+ beforeSendMsg.apply(void 0, _to_consumable_array(arg)).then(function(beforeInfo) {
15278
+ fetchEventSource(url, _object_spread({
15279
+ method: method,
15280
+ headers: _object_spread({
15281
+ "Content-Type": "application/json",
15282
+ Accept: "text/event-stream,application/json"
15283
+ }, headers),
15284
+ body: params.apply(void 0, _to_consumable_array(arg).concat([
15285
+ beforeInfo
15286
+ ])),
15287
+ openWhenHidden: true,
15288
+ signal: ctrl.current.signal,
15289
+ onopen: function(res) {
15290
+ onOpen(res);
15291
+ if (res.status === 200) ;
15292
+ return null;
15293
+ },
15294
+ onmessage: function(ev) {
15295
+ var data = onMessage(ev);
15296
+ msgContent += data.content;
15297
+ delete data.content;
15298
+ recordMsgObj = _object_spread({
15299
+ createTime: createTime,
15300
+ content: msgContent,
15301
+ location: "left",
15302
+ reference: null,
15303
+ source: null
15304
+ }, data);
15305
+ updateMsgRef.current = setTimeout(function() {
15306
+ apiRef.contentApi.updateMsg(msgId, recordMsgObj);
15307
+ msgId = data.id;
15308
+ }, 100);
15309
+ },
15310
+ onclose: function() {
15311
+ onClose();
15312
+ setSending(false);
15313
+ if (recordMsgObj.id) {
15314
+ apiRef.contentApi.recordMsg(recordMsgObj);
15315
+ }
15316
+ console.log("onclose: ", recordMsgObj);
15317
+ },
15318
+ onerror: function(err) {
15319
+ onError(err);
15320
+ if (recordMsgObj.id) {
15321
+ apiRef.contentApi.recordMsg(recordMsgObj);
15322
+ }
15323
+ console.log("onerror: ", err);
15308
15324
  }
15309
- console.log("onerror: ", err);
15310
- }
15311
- }, coverProps));
15325
+ }, coverProps));
15326
+ }).catch(function() {
15327
+ stopMessage();
15328
+ });
15312
15329
  };
15313
15330
  // 判断是否超出最大字数
15314
15331
  var judegTextLengthWarn = function() {