bhd-components 0.11.14 → 0.11.16
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/dist/index.esm.es5.development.css +155 -153
- package/dist/index.esm.es5.development.js +28 -14
- package/dist/index.esm.es5.production.css +1 -1
- package/dist/index.esm.es5.production.js +1 -1
- package/dist/vendor.esm.es5.development.js +1 -1
- package/dist/vendor.esm.es5.production.js +1 -1
- package/es2017/AIMessageList/components/footer/index.js +12 -4
- package/es2017/AIMessageList/components/footer/index.module.less +3 -0
- package/es2017/AIMessageList/components/virtuosoList/index.js +11 -7
- package/es2017/AIMessageList/components/virtuosoList/index.module.less +2 -0
- package/es2017/AIMessageList/type.d.ts +13 -1
- package/esm/AIMessageList/components/footer/index.js +15 -7
- package/esm/AIMessageList/components/footer/index.module.less +3 -0
- package/esm/AIMessageList/components/virtuosoList/index.js +12 -6
- package/esm/AIMessageList/components/virtuosoList/index.module.less +2 -0
- package/esm/AIMessageList/type.d.ts +13 -1
- package/package.json +1 -1
|
@@ -41,6 +41,7 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
41
41
|
const ctrl = useRef(); //停止生成ai回答时使用
|
|
42
42
|
const [textValue, setTextValue] = useState("");
|
|
43
43
|
const [sending, setSending] = useState(false);
|
|
44
|
+
const [isFocus, setIsFocus] = useState(false);
|
|
44
45
|
const [isDisabled, setIsDisabled] = useState(false);
|
|
45
46
|
const [fileCanSending, setFileCanSending] = useState(true); // 是否允许发送 关联文件
|
|
46
47
|
const updateMsgRef = useRef(null);
|
|
@@ -100,7 +101,8 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
100
101
|
},
|
|
101
102
|
setDisabled: (flag)=>{
|
|
102
103
|
setIsDisabled(flag);
|
|
103
|
-
}
|
|
104
|
+
},
|
|
105
|
+
setIsFocus
|
|
104
106
|
}, fileListRef.current || {});
|
|
105
107
|
});
|
|
106
108
|
useEffect(()=>{
|
|
@@ -462,12 +464,12 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
462
464
|
}
|
|
463
465
|
};
|
|
464
466
|
return /*#__PURE__*/ _jsxs("div", {
|
|
465
|
-
className: `${getCls("footer")} ${className}`,
|
|
467
|
+
className: `${getCls("footer")} ${className} `,
|
|
466
468
|
ref: footerDomRef,
|
|
467
469
|
children: [
|
|
468
470
|
renderTopContent && renderTopContent(),
|
|
469
471
|
/*#__PURE__*/ _jsxs("div", {
|
|
470
|
-
className: `${getCls("footerBody")} ${judegTextLengthWarn() ? getCls("footerBodyWarn") : ""}`,
|
|
472
|
+
className: `${getCls("footerBody")} ${judegTextLengthWarn() ? getCls("footerBodyWarn") : ""} ${isFocus ? getCls("footerBodyFocus") : ""}`,
|
|
471
473
|
children: [
|
|
472
474
|
fileUpload && /*#__PURE__*/ _jsx("div", {
|
|
473
475
|
className: getCls("footerFile"),
|
|
@@ -497,7 +499,13 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
497
499
|
minRows: 2,
|
|
498
500
|
maxRows: 6
|
|
499
501
|
},
|
|
500
|
-
onPressEnter: onPressEnter
|
|
502
|
+
onPressEnter: onPressEnter,
|
|
503
|
+
onFocus: ()=>{
|
|
504
|
+
setIsFocus(true);
|
|
505
|
+
},
|
|
506
|
+
onBlur: ()=>{
|
|
507
|
+
setIsFocus(false);
|
|
508
|
+
}
|
|
501
509
|
}, textAreaProps)),
|
|
502
510
|
/*#__PURE__*/ _jsx(References, {
|
|
503
511
|
prefix: prefix,
|
|
@@ -69,13 +69,13 @@ const Header = ({ context })=>{
|
|
|
69
69
|
});
|
|
70
70
|
if (isInitLoad) {
|
|
71
71
|
if (renderLoading) {
|
|
72
|
-
let node = renderLoading("init");
|
|
72
|
+
let node = renderLoading("init", initLoadNode, loadMoreNode);
|
|
73
73
|
if (node) return node;
|
|
74
74
|
}
|
|
75
75
|
return initLoadNode;
|
|
76
76
|
}
|
|
77
77
|
if (renderLoading) {
|
|
78
|
-
let node = renderLoading("loadMore");
|
|
78
|
+
let node = renderLoading("loadMore", initLoadNode, loadMoreNode);
|
|
79
79
|
if (node) return node;
|
|
80
80
|
}
|
|
81
81
|
return loadMoreNode;
|
|
@@ -100,7 +100,7 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
100
100
|
"copy",
|
|
101
101
|
"reference"
|
|
102
102
|
], coverRenderReferences, onRecordMessage = ()=>{}, onVoteChange = ()=>{}, onRefresh = ()=>{}, helloMsg, showTime = true, fileCustomRender = {}, // onSendedHelloMsg = () => {},
|
|
103
|
-
onInit = ()=>{}, renderLoading, renderItemBottom, renderItemTop, htmlStyle = "richText" } = contentConfig;
|
|
103
|
+
onInit = ()=>{}, renderLoading, renderItemBottom, renderItemTop, htmlStyle = "richText", scrollOffset = 0, renderVirtuosoFooter = ()=>null } = contentConfig;
|
|
104
104
|
const loadMoreProps = contentConfig.loadMore || true;
|
|
105
105
|
const virtuosoRef = useRef(null);
|
|
106
106
|
const [loading, setLoading] = useState(false); // 是否加载中
|
|
@@ -279,7 +279,8 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
279
279
|
virtuosoRef.current.scrollToIndex({
|
|
280
280
|
index: "LAST",
|
|
281
281
|
align: "end",
|
|
282
|
-
behavior: "auto"
|
|
282
|
+
behavior: "auto",
|
|
283
|
+
offset: scrollOffset
|
|
283
284
|
});
|
|
284
285
|
}, 100);
|
|
285
286
|
}
|
|
@@ -629,7 +630,7 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
629
630
|
const markToHtml = (markStr, id)=>{
|
|
630
631
|
let html = remarkable.render(markStr);
|
|
631
632
|
if (htmlStyle === "ai_body") {
|
|
632
|
-
html = html.replace(/<table/g, '<div class="ai-table-wrap"><table').replace(/<\/table>/g,
|
|
633
|
+
html = html.replace(/<table/g, '<div class="ai-table-wrap"><table').replace(/<\/table>/g, "</table></div>");
|
|
633
634
|
}
|
|
634
635
|
let position = 0;
|
|
635
636
|
html = html.replace(new RegExp(`<pre`, "ig"), ()=>{
|
|
@@ -804,11 +805,14 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
804
805
|
loading,
|
|
805
806
|
prefix,
|
|
806
807
|
isInitLoad,
|
|
807
|
-
renderLoading
|
|
808
|
+
renderLoading,
|
|
809
|
+
isSending,
|
|
810
|
+
dataSource
|
|
808
811
|
},
|
|
809
812
|
itemContent: itemContent,
|
|
810
813
|
components: {
|
|
811
|
-
Header: Header
|
|
814
|
+
Header: Header,
|
|
815
|
+
Footer: renderVirtuosoFooter
|
|
812
816
|
},
|
|
813
817
|
increaseViewportBy: 200,
|
|
814
818
|
overscan: 10,
|
|
@@ -538,6 +538,7 @@
|
|
|
538
538
|
/* 表格 */
|
|
539
539
|
.ai-table-wrap {
|
|
540
540
|
margin-top: 12px;
|
|
541
|
+
margin-bottom: 12px;
|
|
541
542
|
overflow-x: auto;
|
|
542
543
|
border: 1px solid rgba(120, 161, 138, 0.12);
|
|
543
544
|
border-radius: 10px;
|
|
@@ -579,6 +580,7 @@
|
|
|
579
580
|
border-radius: 10px;
|
|
580
581
|
padding: 14px 16px;
|
|
581
582
|
margin-top: 10px;
|
|
583
|
+
margin-bottom: 10px;
|
|
582
584
|
overflow-x: auto;
|
|
583
585
|
}
|
|
584
586
|
pre code {
|
|
@@ -55,7 +55,7 @@ export interface contentConfigProps {
|
|
|
55
55
|
dataSource: dataItemType[];
|
|
56
56
|
}>; // 列表数据
|
|
57
57
|
loadMore?: boolean; // 是否开启加载更多 // 默认为true
|
|
58
|
-
showTime
|
|
58
|
+
showTime?:boolean;// 是否显示时间 默认为true
|
|
59
59
|
helloMsg?: string; //欢迎语
|
|
60
60
|
pageSize?: number; //每页数量 默认为30
|
|
61
61
|
coverRenderText?: (
|
|
@@ -81,9 +81,20 @@ export interface contentConfigProps {
|
|
|
81
81
|
renderLoading?: (type:"init"|"loadMore",initLoadNode:React.ReactNode,loadMoreNode:React.ReactNode) => React.ReactNode;
|
|
82
82
|
renderItemBottom?: (item: dataItemType) => React.ReactNode;
|
|
83
83
|
renderItemTop?: (item: dataItemType) => React.ReactNode;
|
|
84
|
+
scrollOffset?: number;
|
|
85
|
+
renderVirtuosoFooter?: (props:{context:ContextProps} ) => React.ReactNode;
|
|
84
86
|
|
|
85
87
|
}
|
|
86
88
|
|
|
89
|
+
export interface ContextProps{
|
|
90
|
+
loading: boolean;
|
|
91
|
+
prefix: string;
|
|
92
|
+
isInitLoad: boolean;
|
|
93
|
+
renderLoading: (type: "init" | "loadMore",initLoadNode:React.ReactNode,loadMoreNode:React.ReactNode) => React.ReactNode;
|
|
94
|
+
isSending:boolean;
|
|
95
|
+
dataSource:dataItemType[]
|
|
96
|
+
}
|
|
97
|
+
|
|
87
98
|
// content props
|
|
88
99
|
|
|
89
100
|
export interface contentProps {
|
|
@@ -207,6 +218,7 @@ export interface footerRefProps {
|
|
|
207
218
|
stopMessage: () => void; //停止发送消息
|
|
208
219
|
setReferences: (reference: referenceType) => void; // 添加引用
|
|
209
220
|
setDisabled: (flag: boolean) => void;// 设置是否禁用发送按钮
|
|
221
|
+
setIsFocus: (flag: boolean) => void;//设置是否聚焦
|
|
210
222
|
}
|
|
211
223
|
|
|
212
224
|
// sendBtn Props
|
|
@@ -45,8 +45,9 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
45
45
|
var ctrl = useRef(); //停止生成ai回答时使用
|
|
46
46
|
var _useState = _sliced_to_array(useState(""), 2), textValue = _useState[0], setTextValue = _useState[1];
|
|
47
47
|
var _useState1 = _sliced_to_array(useState(false), 2), sending = _useState1[0], setSending = _useState1[1];
|
|
48
|
-
var _useState2 = _sliced_to_array(useState(false), 2),
|
|
49
|
-
var _useState3 = _sliced_to_array(useState(
|
|
48
|
+
var _useState2 = _sliced_to_array(useState(false), 2), isFocus = _useState2[0], setIsFocus = _useState2[1];
|
|
49
|
+
var _useState3 = _sliced_to_array(useState(false), 2), isDisabled = _useState3[0], setIsDisabled = _useState3[1];
|
|
50
|
+
var _useState4 = _sliced_to_array(useState(true), 2), fileCanSending = _useState4[0], setFileCanSending = _useState4[1]; // 是否允许发送 关联文件
|
|
50
51
|
var updateMsgRef = useRef(null);
|
|
51
52
|
var canSendMsgRef = useRef(false);
|
|
52
53
|
var recordFileList = useRef({
|
|
@@ -65,7 +66,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
65
66
|
// source: undefined,
|
|
66
67
|
// },
|
|
67
68
|
// });
|
|
68
|
-
var
|
|
69
|
+
var _useState5 = _sliced_to_array(useState(null), 2), referencesSource = _useState5[0], setReferencesSource = _useState5[1];
|
|
69
70
|
var recordRef = useRef({
|
|
70
71
|
value: textValue,
|
|
71
72
|
referencesSource: referencesSource,
|
|
@@ -104,7 +105,8 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
104
105
|
},
|
|
105
106
|
setDisabled: function(flag) {
|
|
106
107
|
setIsDisabled(flag);
|
|
107
|
-
}
|
|
108
|
+
},
|
|
109
|
+
setIsFocus: setIsFocus
|
|
108
110
|
}, fileListRef.current || {});
|
|
109
111
|
});
|
|
110
112
|
useEffect(function() {
|
|
@@ -477,12 +479,12 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
477
479
|
}
|
|
478
480
|
};
|
|
479
481
|
return /*#__PURE__*/ _jsxs("div", {
|
|
480
|
-
className: "".concat(getCls("footer"), " ").concat(className),
|
|
482
|
+
className: "".concat(getCls("footer"), " ").concat(className, " "),
|
|
481
483
|
ref: footerDomRef,
|
|
482
484
|
children: [
|
|
483
485
|
renderTopContent && renderTopContent(),
|
|
484
486
|
/*#__PURE__*/ _jsxs("div", {
|
|
485
|
-
className: "".concat(getCls("footerBody"), " ").concat(judegTextLengthWarn() ? getCls("footerBodyWarn") : ""),
|
|
487
|
+
className: "".concat(getCls("footerBody"), " ").concat(judegTextLengthWarn() ? getCls("footerBodyWarn") : "", " ").concat(isFocus ? getCls("footerBodyFocus") : ""),
|
|
486
488
|
children: [
|
|
487
489
|
fileUpload && /*#__PURE__*/ _jsx("div", {
|
|
488
490
|
className: getCls("footerFile"),
|
|
@@ -513,7 +515,13 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
513
515
|
minRows: 2,
|
|
514
516
|
maxRows: 6
|
|
515
517
|
},
|
|
516
|
-
onPressEnter: onPressEnter
|
|
518
|
+
onPressEnter: onPressEnter,
|
|
519
|
+
onFocus: function() {
|
|
520
|
+
setIsFocus(true);
|
|
521
|
+
},
|
|
522
|
+
onBlur: function() {
|
|
523
|
+
setIsFocus(false);
|
|
524
|
+
}
|
|
517
525
|
}, textAreaProps)),
|
|
518
526
|
/*#__PURE__*/ _jsx(References, {
|
|
519
527
|
prefix: prefix,
|
|
@@ -73,13 +73,13 @@ var Header = function(param) {
|
|
|
73
73
|
});
|
|
74
74
|
if (isInitLoad) {
|
|
75
75
|
if (renderLoading) {
|
|
76
|
-
var node = renderLoading("init");
|
|
76
|
+
var node = renderLoading("init", initLoadNode, loadMoreNode);
|
|
77
77
|
if (node) return node;
|
|
78
78
|
}
|
|
79
79
|
return initLoadNode;
|
|
80
80
|
}
|
|
81
81
|
if (renderLoading) {
|
|
82
|
-
var node1 = renderLoading("loadMore");
|
|
82
|
+
var node1 = renderLoading("loadMore", initLoadNode, loadMoreNode);
|
|
83
83
|
if (node1) return node1;
|
|
84
84
|
}
|
|
85
85
|
return loadMoreNode;
|
|
@@ -104,7 +104,9 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
104
104
|
"copy",
|
|
105
105
|
"reference"
|
|
106
106
|
] : _contentConfig_msgAction, coverRenderReferences = contentConfig.coverRenderReferences, _contentConfig_onRecordMessage = contentConfig.onRecordMessage, onRecordMessage = _contentConfig_onRecordMessage === void 0 ? function() {} : _contentConfig_onRecordMessage, _contentConfig_onVoteChange = contentConfig.onVoteChange, onVoteChange = _contentConfig_onVoteChange === void 0 ? function() {} : _contentConfig_onVoteChange, _contentConfig_onRefresh = contentConfig.onRefresh, onRefresh = _contentConfig_onRefresh === void 0 ? function() {} : _contentConfig_onRefresh, helloMsg = contentConfig.helloMsg, _contentConfig_showTime = contentConfig.showTime, showTime = _contentConfig_showTime === void 0 ? true : _contentConfig_showTime, _contentConfig_fileCustomRender = contentConfig.fileCustomRender, fileCustomRender = _contentConfig_fileCustomRender === void 0 ? {} : _contentConfig_fileCustomRender, _contentConfig_onInit = contentConfig.// onSendedHelloMsg = () => {},
|
|
107
|
-
onInit, onInit = _contentConfig_onInit === void 0 ? function() {} : _contentConfig_onInit, renderLoading = contentConfig.renderLoading, renderItemBottom = contentConfig.renderItemBottom, renderItemTop = contentConfig.renderItemTop, _contentConfig_htmlStyle = contentConfig.htmlStyle, htmlStyle = _contentConfig_htmlStyle === void 0 ? "richText" : _contentConfig_htmlStyle
|
|
107
|
+
onInit, onInit = _contentConfig_onInit === void 0 ? function() {} : _contentConfig_onInit, renderLoading = contentConfig.renderLoading, renderItemBottom = contentConfig.renderItemBottom, renderItemTop = contentConfig.renderItemTop, _contentConfig_htmlStyle = contentConfig.htmlStyle, htmlStyle = _contentConfig_htmlStyle === void 0 ? "richText" : _contentConfig_htmlStyle, _contentConfig_scrollOffset = contentConfig.scrollOffset, scrollOffset = _contentConfig_scrollOffset === void 0 ? 0 : _contentConfig_scrollOffset, _contentConfig_renderVirtuosoFooter = contentConfig.renderVirtuosoFooter, renderVirtuosoFooter = _contentConfig_renderVirtuosoFooter === void 0 ? function() {
|
|
108
|
+
return null;
|
|
109
|
+
} : _contentConfig_renderVirtuosoFooter;
|
|
108
110
|
var loadMoreProps = contentConfig.loadMore || true;
|
|
109
111
|
var virtuosoRef = useRef(null);
|
|
110
112
|
var _useState = _sliced_to_array(useState(false), 2), loading = _useState[0], setLoading = _useState[1]; // 是否加载中
|
|
@@ -282,7 +284,8 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
282
284
|
virtuosoRef.current.scrollToIndex({
|
|
283
285
|
index: "LAST",
|
|
284
286
|
align: "end",
|
|
285
|
-
behavior: "auto"
|
|
287
|
+
behavior: "auto",
|
|
288
|
+
offset: scrollOffset
|
|
286
289
|
});
|
|
287
290
|
}, 100);
|
|
288
291
|
}
|
|
@@ -785,11 +788,14 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
785
788
|
loading: loading,
|
|
786
789
|
prefix: prefix,
|
|
787
790
|
isInitLoad: isInitLoad,
|
|
788
|
-
renderLoading: renderLoading
|
|
791
|
+
renderLoading: renderLoading,
|
|
792
|
+
isSending: isSending,
|
|
793
|
+
dataSource: dataSource
|
|
789
794
|
},
|
|
790
795
|
itemContent: itemContent,
|
|
791
796
|
components: {
|
|
792
|
-
Header: Header
|
|
797
|
+
Header: Header,
|
|
798
|
+
Footer: renderVirtuosoFooter
|
|
793
799
|
},
|
|
794
800
|
increaseViewportBy: 200,
|
|
795
801
|
overscan: 10,
|
|
@@ -538,6 +538,7 @@
|
|
|
538
538
|
/* 表格 */
|
|
539
539
|
.ai-table-wrap {
|
|
540
540
|
margin-top: 12px;
|
|
541
|
+
margin-bottom: 12px;
|
|
541
542
|
overflow-x: auto;
|
|
542
543
|
border: 1px solid rgba(120, 161, 138, 0.12);
|
|
543
544
|
border-radius: 10px;
|
|
@@ -579,6 +580,7 @@
|
|
|
579
580
|
border-radius: 10px;
|
|
580
581
|
padding: 14px 16px;
|
|
581
582
|
margin-top: 10px;
|
|
583
|
+
margin-bottom: 10px;
|
|
582
584
|
overflow-x: auto;
|
|
583
585
|
}
|
|
584
586
|
pre code {
|
|
@@ -55,7 +55,7 @@ export interface contentConfigProps {
|
|
|
55
55
|
dataSource: dataItemType[];
|
|
56
56
|
}>; // 列表数据
|
|
57
57
|
loadMore?: boolean; // 是否开启加载更多 // 默认为true
|
|
58
|
-
showTime
|
|
58
|
+
showTime?:boolean;// 是否显示时间 默认为true
|
|
59
59
|
helloMsg?: string; //欢迎语
|
|
60
60
|
pageSize?: number; //每页数量 默认为30
|
|
61
61
|
coverRenderText?: (
|
|
@@ -81,9 +81,20 @@ export interface contentConfigProps {
|
|
|
81
81
|
renderLoading?: (type:"init"|"loadMore",initLoadNode:React.ReactNode,loadMoreNode:React.ReactNode) => React.ReactNode;
|
|
82
82
|
renderItemBottom?: (item: dataItemType) => React.ReactNode;
|
|
83
83
|
renderItemTop?: (item: dataItemType) => React.ReactNode;
|
|
84
|
+
scrollOffset?: number;
|
|
85
|
+
renderVirtuosoFooter?: (props:{context:ContextProps} ) => React.ReactNode;
|
|
84
86
|
|
|
85
87
|
}
|
|
86
88
|
|
|
89
|
+
export interface ContextProps{
|
|
90
|
+
loading: boolean;
|
|
91
|
+
prefix: string;
|
|
92
|
+
isInitLoad: boolean;
|
|
93
|
+
renderLoading: (type: "init" | "loadMore",initLoadNode:React.ReactNode,loadMoreNode:React.ReactNode) => React.ReactNode;
|
|
94
|
+
isSending:boolean;
|
|
95
|
+
dataSource:dataItemType[]
|
|
96
|
+
}
|
|
97
|
+
|
|
87
98
|
// content props
|
|
88
99
|
|
|
89
100
|
export interface contentProps {
|
|
@@ -207,6 +218,7 @@ export interface footerRefProps {
|
|
|
207
218
|
stopMessage: () => void; //停止发送消息
|
|
208
219
|
setReferences: (reference: referenceType) => void; // 添加引用
|
|
209
220
|
setDisabled: (flag: boolean) => void;// 设置是否禁用发送按钮
|
|
221
|
+
setIsFocus: (flag: boolean) => void;//设置是否聚焦
|
|
210
222
|
}
|
|
211
223
|
|
|
212
224
|
// sendBtn Props
|