@connectif/ui-components 2.0.3 → 2.0.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.
|
@@ -16,6 +16,10 @@ export type ChatProps = React.PropsWithChildren<{
|
|
|
16
16
|
* Scrollbar color
|
|
17
17
|
*/
|
|
18
18
|
scrollbarColor?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Number that change to trigger scroll to class in scrollToLastClassName
|
|
21
|
+
*/
|
|
22
|
+
triggerScroll?: number;
|
|
19
23
|
}>;
|
|
20
|
-
declare const Chat: ({ children, header, backgroundColor, scrollToLastClassName, scrollbarColor }: ChatProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
declare const Chat: ({ children, header, backgroundColor, scrollToLastClassName, scrollbarColor, triggerScroll }: ChatProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
25
|
export default Chat;
|
package/dist/index.js
CHANGED
|
@@ -13901,14 +13901,17 @@ var ChatMessage_default = ChatMessage;
|
|
|
13901
13901
|
import Stack5 from "@mui/material/Stack";
|
|
13902
13902
|
import * as React36 from "react";
|
|
13903
13903
|
import { jsx as jsx80, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
13904
|
+
var PADDING_BOTTOM = 8;
|
|
13904
13905
|
var Chat = ({
|
|
13905
13906
|
children,
|
|
13906
13907
|
header,
|
|
13907
13908
|
backgroundColor: backgroundColor2,
|
|
13908
13909
|
scrollToLastClassName,
|
|
13909
|
-
scrollbarColor
|
|
13910
|
+
scrollbarColor,
|
|
13911
|
+
triggerScroll
|
|
13910
13912
|
}) => {
|
|
13911
13913
|
const ref = React36.useRef(null);
|
|
13914
|
+
const innerRef = React36.useRef(null);
|
|
13912
13915
|
const [isInitialize, setIsInitialize] = React36.useState(false);
|
|
13913
13916
|
const [hasVerticalScroll, setHasVerticalScroll] = React36.useState(false);
|
|
13914
13917
|
React36.useEffect(() => {
|
|
@@ -13931,20 +13934,31 @@ var Chat = ({
|
|
|
13931
13934
|
if (!container) {
|
|
13932
13935
|
return;
|
|
13933
13936
|
}
|
|
13934
|
-
if (
|
|
13935
|
-
const
|
|
13936
|
-
|
|
13937
|
+
if (innerRef.current && innerRef.current.style.paddingBottom !== "0px" && innerRef.current.style.paddingBottom !== `${PADDING_BOTTOM}px` && innerRef.current.style.paddingBottom !== "") {
|
|
13938
|
+
const paddingBottom = parseInt(
|
|
13939
|
+
innerRef.current.style.paddingBottom || "0",
|
|
13940
|
+
10
|
|
13937
13941
|
);
|
|
13938
|
-
const
|
|
13939
|
-
|
|
13940
|
-
|
|
13941
|
-
|
|
13942
|
-
|
|
13943
|
-
|
|
13944
|
-
|
|
13945
|
-
|
|
13942
|
+
const childrenHeight = innerRef.current.scrollHeight - paddingBottom;
|
|
13943
|
+
const childrenHeightVisible = childrenHeight - container.scrollTop;
|
|
13944
|
+
innerRef.current.style.paddingBottom = childrenHeightVisible > container.clientHeight ? "0px" : `${container.clientHeight - childrenHeightVisible}px`;
|
|
13945
|
+
}
|
|
13946
|
+
}, [children]);
|
|
13947
|
+
React36.useEffect(() => {
|
|
13948
|
+
const container = ref.current;
|
|
13949
|
+
if (!container || !scrollToLastClassName || !triggerScroll) {
|
|
13950
|
+
return;
|
|
13946
13951
|
}
|
|
13947
|
-
|
|
13952
|
+
const elements = container.querySelectorAll(
|
|
13953
|
+
`.${scrollToLastClassName}`
|
|
13954
|
+
);
|
|
13955
|
+
const last = elements[elements.length - 1];
|
|
13956
|
+
if (last && innerRef.current) {
|
|
13957
|
+
const paddingBottom = container.clientHeight - last.offsetHeight;
|
|
13958
|
+
innerRef.current.style.paddingBottom = `${paddingBottom}px`;
|
|
13959
|
+
last.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
13960
|
+
}
|
|
13961
|
+
}, [scrollToLastClassName, triggerScroll]);
|
|
13948
13962
|
return /* @__PURE__ */ jsxs36(
|
|
13949
13963
|
Stack5,
|
|
13950
13964
|
{
|
|
@@ -13956,7 +13970,7 @@ var Chat = ({
|
|
|
13956
13970
|
height: "calc(100% - 8px)",
|
|
13957
13971
|
visibility: !isInitialize ? "hidden" : "visible",
|
|
13958
13972
|
width: `calc(100% - ${hasVerticalScroll ? "4px" : "8px"})`,
|
|
13959
|
-
paddingBottom:
|
|
13973
|
+
paddingBottom: `${PADDING_BOTTOM}px`,
|
|
13960
13974
|
...backgroundColor2 && { backgroundColor: backgroundColor2 },
|
|
13961
13975
|
paddingRight: hasVerticalScroll ? "4px" : "8px",
|
|
13962
13976
|
"::-webkit-scrollbar": {
|
|
@@ -13979,10 +13993,10 @@ var Chat = ({
|
|
|
13979
13993
|
/* @__PURE__ */ jsx80(
|
|
13980
13994
|
Stack5,
|
|
13981
13995
|
{
|
|
13982
|
-
|
|
13996
|
+
ref: innerRef,
|
|
13997
|
+
justifyContent: "start",
|
|
13983
13998
|
...!header && {
|
|
13984
|
-
minHeight: "100%"
|
|
13985
|
-
justifyContent: "end"
|
|
13999
|
+
minHeight: "100%"
|
|
13986
14000
|
},
|
|
13987
14001
|
sx: {
|
|
13988
14002
|
"> *": { marginTop: "12px" },
|
|
@@ -22643,11 +22657,9 @@ var TextEditor = function TextEditor2({
|
|
|
22643
22657
|
);
|
|
22644
22658
|
const onTextChange = React67.useCallback(() => {
|
|
22645
22659
|
if (editorRef.current) {
|
|
22646
|
-
onChange(
|
|
22647
|
-
!isCodeEditorDirty ? contentValue : editorRef.current?.getContent()
|
|
22648
|
-
);
|
|
22660
|
+
onChange(editorRef.current?.getContent());
|
|
22649
22661
|
}
|
|
22650
|
-
}, [
|
|
22662
|
+
}, [onChange]);
|
|
22651
22663
|
const onTextEditorDirty = React67.useCallback(
|
|
22652
22664
|
(textEditorDirty) => {
|
|
22653
22665
|
editorRef.current?.setDirty(textEditorDirty);
|