@copilotkit/react-ui 1.4.0-pre-1-4-0.12 → 1.4.0-pre-1-4-0.13
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/CHANGELOG.md +13 -0
- package/dist/{chunk-QK6XA3PL.mjs → chunk-H5CXJBR5.mjs} +3 -3
- package/dist/{chunk-TEZWY2BL.mjs → chunk-M2NVAJQA.mjs} +2 -2
- package/dist/{chunk-C5KOJ3IH.mjs → chunk-ORHE7FYT.mjs} +2 -2
- package/dist/{chunk-OJ5NVSTU.mjs → chunk-PY7YBFPA.mjs} +2 -2
- package/dist/{chunk-CPMIEVKK.mjs → chunk-RKPANT3F.mjs} +65 -15
- package/dist/chunk-RKPANT3F.mjs.map +1 -0
- package/dist/components/chat/Chat.js +62 -13
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +2 -2
- package/dist/components/chat/Messages.d.ts +6 -1
- package/dist/components/chat/Messages.js +66 -15
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +5 -3
- package/dist/components/chat/Modal.js +62 -13
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +3 -3
- package/dist/components/chat/Popup.js +62 -13
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +4 -4
- package/dist/components/chat/Sidebar.js +62 -13
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +4 -4
- package/dist/components/chat/index.js +62 -13
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +5 -5
- package/dist/components/index.js +62 -13
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +5 -5
- package/dist/index.js +62 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/package.json +7 -7
- package/src/components/chat/Messages.tsx +72 -15
- package/dist/chunk-CPMIEVKK.mjs.map +0 -1
- /package/dist/{chunk-QK6XA3PL.mjs.map → chunk-H5CXJBR5.mjs.map} +0 -0
- /package/dist/{chunk-TEZWY2BL.mjs.map → chunk-M2NVAJQA.mjs.map} +0 -0
- /package/dist/{chunk-C5KOJ3IH.mjs.map → chunk-ORHE7FYT.mjs.map} +0 -0
- /package/dist/{chunk-OJ5NVSTU.mjs.map → chunk-PY7YBFPA.mjs.map} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotSidebar
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-M2NVAJQA.mjs";
|
|
4
|
+
import "../../chunk-H5CXJBR5.mjs";
|
|
5
5
|
import "../../chunk-YAGE7RCE.mjs";
|
|
6
6
|
import "../../chunk-VEC45H6Q.mjs";
|
|
7
7
|
import "../../chunk-RQNJNK2W.mjs";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-ORHE7FYT.mjs";
|
|
9
9
|
import "../../chunk-V7W6IM2V.mjs";
|
|
10
10
|
import "../../chunk-OMTPWC7T.mjs";
|
|
11
11
|
import "../../chunk-ZABXREBH.mjs";
|
|
@@ -18,7 +18,7 @@ import "../../chunk-OTPAZXVR.mjs";
|
|
|
18
18
|
import "../../chunk-4LUMV4YO.mjs";
|
|
19
19
|
import "../../chunk-YQFVRDNC.mjs";
|
|
20
20
|
import "../../chunk-YQ3D5IQV.mjs";
|
|
21
|
-
import "../../chunk-
|
|
21
|
+
import "../../chunk-RKPANT3F.mjs";
|
|
22
22
|
import "../../chunk-3XAXY2Z3.mjs";
|
|
23
23
|
import "../../chunk-CBBFRI3Q.mjs";
|
|
24
24
|
import "../../chunk-UPTB2MVO.mjs";
|
|
@@ -529,7 +529,7 @@ var Header = ({}) => {
|
|
|
529
529
|
};
|
|
530
530
|
|
|
531
531
|
// src/components/chat/Messages.tsx
|
|
532
|
-
var import_react3 =
|
|
532
|
+
var import_react3 = require("react");
|
|
533
533
|
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
534
534
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
535
535
|
var Messages = ({
|
|
@@ -559,18 +559,8 @@ var Messages = ({
|
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
}
|
|
562
|
-
const messagesEndRef =
|
|
563
|
-
|
|
564
|
-
if (messagesEndRef.current) {
|
|
565
|
-
messagesEndRef.current.scrollIntoView({
|
|
566
|
-
behavior: "auto"
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
(0, import_react3.useEffect)(() => {
|
|
571
|
-
scrollToBottom();
|
|
572
|
-
}, [messages]);
|
|
573
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitMessages", children: [
|
|
562
|
+
const { messagesEndRef, messagesContainerRef } = useScrollToBottom(messages);
|
|
563
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitMessages", ref: messagesContainerRef, children: [
|
|
574
564
|
messages.map((message, index) => {
|
|
575
565
|
const isCurrentMessage = index === messages.length - 1;
|
|
576
566
|
if (message.isTextMessage()) {
|
|
@@ -639,6 +629,65 @@ function makeInitialMessages(initial) {
|
|
|
639
629
|
})
|
|
640
630
|
);
|
|
641
631
|
}
|
|
632
|
+
function useScrollToBottom(messages) {
|
|
633
|
+
const messagesEndRef = (0, import_react3.useRef)(null);
|
|
634
|
+
const messagesContainerRef = (0, import_react3.useRef)(null);
|
|
635
|
+
const isProgrammaticScrollRef = (0, import_react3.useRef)(false);
|
|
636
|
+
const isUserScrollUpRef = (0, import_react3.useRef)(false);
|
|
637
|
+
const scrollToBottom = () => {
|
|
638
|
+
if (messagesEndRef.current) {
|
|
639
|
+
isProgrammaticScrollRef.current = true;
|
|
640
|
+
messagesEndRef.current.scrollIntoView({
|
|
641
|
+
behavior: "auto"
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
const handleScroll = () => {
|
|
646
|
+
if (isProgrammaticScrollRef.current) {
|
|
647
|
+
isProgrammaticScrollRef.current = false;
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
if (messagesContainerRef.current) {
|
|
651
|
+
const { scrollTop, scrollHeight, clientHeight } = messagesContainerRef.current;
|
|
652
|
+
isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
(0, import_react3.useEffect)(() => {
|
|
656
|
+
const container = messagesContainerRef.current;
|
|
657
|
+
if (container) {
|
|
658
|
+
container.addEventListener("scroll", handleScroll);
|
|
659
|
+
}
|
|
660
|
+
return () => {
|
|
661
|
+
if (container) {
|
|
662
|
+
container.removeEventListener("scroll", handleScroll);
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
}, []);
|
|
666
|
+
(0, import_react3.useEffect)(() => {
|
|
667
|
+
const container = messagesContainerRef.current;
|
|
668
|
+
if (!container) {
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
const mutationObserver = new MutationObserver(() => {
|
|
672
|
+
if (!isUserScrollUpRef.current) {
|
|
673
|
+
scrollToBottom();
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
mutationObserver.observe(container, {
|
|
677
|
+
childList: true,
|
|
678
|
+
subtree: true,
|
|
679
|
+
characterData: true
|
|
680
|
+
});
|
|
681
|
+
return () => {
|
|
682
|
+
mutationObserver.disconnect();
|
|
683
|
+
};
|
|
684
|
+
}, []);
|
|
685
|
+
(0, import_react3.useEffect)(() => {
|
|
686
|
+
isUserScrollUpRef.current = false;
|
|
687
|
+
scrollToBottom();
|
|
688
|
+
}, [messages.filter((m) => m.isTextMessage() && m.role === import_runtime_client_gql.Role.User).length]);
|
|
689
|
+
return { messagesEndRef, messagesContainerRef };
|
|
690
|
+
}
|
|
642
691
|
|
|
643
692
|
// src/components/chat/Input.tsx
|
|
644
693
|
var import_react6 = require("react");
|