@copilotz/chat-ui 0.6.7 → 0.7.0
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.cjs +28 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -15
- package/dist/index.js.map +1 -1
- package/dist/styles.css +18 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -786,8 +786,7 @@ var StreamingText = (0, import_react2.memo)(function StreamingText2({
|
|
|
786
786
|
className = "",
|
|
787
787
|
renderMarkdown = true,
|
|
788
788
|
markdown,
|
|
789
|
-
plainTextChunkChars = 12e3
|
|
790
|
-
contentStyle
|
|
789
|
+
plainTextChunkChars = 12e3
|
|
791
790
|
}) {
|
|
792
791
|
const hasContent = content.trim().length > 0;
|
|
793
792
|
const enableSyntaxHighlight = renderMarkdown && !isStreaming && hasCodeBlocks(content);
|
|
@@ -817,7 +816,6 @@ var StreamingText = (0, import_react2.memo)(function StreamingText2({
|
|
|
817
816
|
LongContentShell,
|
|
818
817
|
{
|
|
819
818
|
className: `prose prose-sm max-w-none dark:prose-invert break-words ${className}`.trim(),
|
|
820
|
-
style: contentStyle,
|
|
821
819
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
822
820
|
import_react_markdown.default,
|
|
823
821
|
{
|
|
@@ -833,8 +831,7 @@ var StreamingText = (0, import_react2.memo)(function StreamingText2({
|
|
|
833
831
|
{
|
|
834
832
|
content,
|
|
835
833
|
className,
|
|
836
|
-
chunkSize: plainTextChunkChars
|
|
837
|
-
style: contentStyle
|
|
834
|
+
chunkSize: plainTextChunkChars
|
|
838
835
|
}
|
|
839
836
|
) : null,
|
|
840
837
|
isStreaming && hasContent && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "inline-block w-2 h-4 bg-primary animate-pulse ml-1" })
|
|
@@ -984,11 +981,6 @@ var Message = (0, import_react2.memo)(({
|
|
|
984
981
|
const isCollapsed = canCollapseMessage && !isExpanded;
|
|
985
982
|
const contentToRender = isCollapsed ? getCollapsedPreview(message.content, normalizedPreviewChars, previewOverride) : message.content;
|
|
986
983
|
const shouldRenderMarkdown = !isCollapsed && (!messageIsUser || renderUserMarkdown);
|
|
987
|
-
const shouldApplyLargeContentContainment = !isCollapsed && message.content.length > normalizedChunkChars;
|
|
988
|
-
const contentStyle = shouldApplyLargeContentContainment ? {
|
|
989
|
-
contentVisibility: "auto",
|
|
990
|
-
containIntrinsicSize: "1px 400px"
|
|
991
|
-
} : void 0;
|
|
992
984
|
const horizontalOffsetClass = showAvatar ? messageIsUser ? compactMode ? "mr-9" : "mr-11" : compactMode ? "ml-9" : "ml-11" : "";
|
|
993
985
|
const handleCopy = async () => {
|
|
994
986
|
try {
|
|
@@ -1099,8 +1091,7 @@ var Message = (0, import_react2.memo)(({
|
|
|
1099
1091
|
isStreaming: message.isStreaming,
|
|
1100
1092
|
renderMarkdown: shouldRenderMarkdown,
|
|
1101
1093
|
markdown,
|
|
1102
|
-
plainTextChunkChars: normalizedChunkChars
|
|
1103
|
-
contentStyle
|
|
1094
|
+
plainTextChunkChars: normalizedChunkChars
|
|
1104
1095
|
}
|
|
1105
1096
|
),
|
|
1106
1097
|
canCollapseMessage && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
@@ -5304,6 +5295,7 @@ var ChatUI = ({
|
|
|
5304
5295
|
const virtualizer = (0, import_react_virtual.useVirtualizer)({
|
|
5305
5296
|
count: groupedMessages.length,
|
|
5306
5297
|
getScrollElement: () => scrollAreaRef.current,
|
|
5298
|
+
getItemKey: (index) => groupedMessages[index]?.id ?? index,
|
|
5307
5299
|
estimateSize: () => 100,
|
|
5308
5300
|
overscan: 5
|
|
5309
5301
|
});
|
|
@@ -5372,8 +5364,29 @@ var ChatUI = ({
|
|
|
5372
5364
|
});
|
|
5373
5365
|
}, [groupedMessages, state.isAtBottom, virtualizer]);
|
|
5374
5366
|
(0, import_react10.useEffect)(() => {
|
|
5375
|
-
|
|
5376
|
-
|
|
5367
|
+
const viewport = scrollAreaRef.current;
|
|
5368
|
+
if (!viewport) return;
|
|
5369
|
+
let rafId;
|
|
5370
|
+
const ro = new ResizeObserver(() => {
|
|
5371
|
+
cancelAnimationFrame(rafId);
|
|
5372
|
+
rafId = requestAnimationFrame(() => {
|
|
5373
|
+
const elements = virtualizer.elementsCache;
|
|
5374
|
+
if (elements) {
|
|
5375
|
+
elements.forEach((node) => {
|
|
5376
|
+
if (node.isConnected) {
|
|
5377
|
+
virtualizer.observer?.unobserve(node);
|
|
5378
|
+
virtualizer.observer?.observe(node);
|
|
5379
|
+
}
|
|
5380
|
+
});
|
|
5381
|
+
}
|
|
5382
|
+
});
|
|
5383
|
+
});
|
|
5384
|
+
ro.observe(viewport);
|
|
5385
|
+
return () => {
|
|
5386
|
+
cancelAnimationFrame(rafId);
|
|
5387
|
+
ro.disconnect();
|
|
5388
|
+
};
|
|
5389
|
+
}, [virtualizer]);
|
|
5377
5390
|
(0, import_react10.useEffect)(() => {
|
|
5378
5391
|
prependSnapshotRef.current = null;
|
|
5379
5392
|
}, [currentThreadId]);
|
|
@@ -5730,7 +5743,7 @@ var ChatUI = ({
|
|
|
5730
5743
|
className: "flex-1 min-h-0",
|
|
5731
5744
|
viewportClassName: "p-4 overscroll-contain",
|
|
5732
5745
|
onScrollCapture: handleScroll,
|
|
5733
|
-
style: { contain: "
|
|
5746
|
+
style: { contain: "content" },
|
|
5734
5747
|
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "max-w-4xl mx-auto pb-4", children: [
|
|
5735
5748
|
groupedMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex justify-center py-2", children: isLoadingOlderMessages ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-xs text-muted-foreground", children: config.labels.loadingOlderMessages }) : hasMoreMessagesBefore ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5736
5749
|
"button",
|