@copilotkit/react-core 1.56.4-canary.1777538870 → 1.56.4-canary.1777659843
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/{copilotkit-tb4zqaMK.cjs → copilotkit-Bn7CCpNA.cjs} +12 -36
- package/dist/{copilotkit-tb4zqaMK.cjs.map → copilotkit-Bn7CCpNA.cjs.map} +1 -1
- package/dist/copilotkit-DFaI4j2r.d.mts.map +1 -1
- package/dist/{copilotkit-Bd0m5HFp.mjs → copilotkit-DHEUlli6.mjs} +12 -36
- package/dist/{copilotkit-Bd0m5HFp.mjs.map → copilotkit-DHEUlli6.mjs.map} +1 -1
- package/dist/copilotkit-Dg4r4Gi_.d.cts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +11 -35
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/v2/components/chat/CopilotChatView.tsx +1 -9
- package/src/v2/components/chat/__tests__/CopilotChatView.pinToSend.test.tsx +23 -13
- package/src/v2/hooks/__tests__/use-pin-to-send.test.tsx +48 -53
- package/src/v2/hooks/use-pin-to-send.ts +23 -32
|
@@ -6218,55 +6218,40 @@ const LastUserMessageContext = react.default.createContext({
|
|
|
6218
6218
|
|
|
6219
6219
|
//#endregion
|
|
6220
6220
|
//#region src/v2/hooks/use-pin-to-send.ts
|
|
6221
|
-
function usePinToSend({ scrollRef, contentRef,
|
|
6221
|
+
function usePinToSend({ scrollRef, contentRef, topOffset = 16 }) {
|
|
6222
6222
|
const { id, sendNonce } = (0, react.useContext)(LastUserMessageContext);
|
|
6223
6223
|
const lastNonceRef = (0, react.useRef)(-1);
|
|
6224
|
-
const currentSpacerHeightRef = (0, react.useRef)(0);
|
|
6225
6224
|
(0, react.useEffect)(() => {
|
|
6226
6225
|
if (sendNonce === lastNonceRef.current) return;
|
|
6227
6226
|
lastNonceRef.current = sendNonce;
|
|
6228
6227
|
if (!id) return;
|
|
6229
6228
|
const scrollEl = scrollRef.current;
|
|
6230
6229
|
const contentEl = contentRef.current;
|
|
6231
|
-
|
|
6232
|
-
if (!scrollEl || !contentEl || !spacerEl) return;
|
|
6230
|
+
if (!scrollEl || !contentEl) return;
|
|
6233
6231
|
const escaped = typeof CSS !== "undefined" && CSS.escape ? CSS.escape(id) : id.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
|
|
6234
6232
|
const targetEl = contentEl.querySelector(`[data-message-id="${escaped}"]`);
|
|
6235
6233
|
if (!targetEl) return;
|
|
6236
6234
|
const viewportHeight = scrollEl.clientHeight;
|
|
6237
|
-
const userMessageHeight = targetEl.getBoundingClientRect().height;
|
|
6238
6235
|
const paddingTop = parseFloat(getComputedStyle(targetEl).paddingTop) || 0;
|
|
6239
|
-
const
|
|
6240
|
-
const
|
|
6241
|
-
|
|
6242
|
-
currentSpacerHeightRef.current = spacerHeight;
|
|
6236
|
+
const userMsgOffsetInScroll = computeOffsetTop(targetEl, scrollEl);
|
|
6237
|
+
const requiredScrollHeight = userMsgOffsetInScroll + paddingTop + viewportHeight - topOffset;
|
|
6238
|
+
contentEl.style.minHeight = `${Math.max(0, requiredScrollHeight)}px`;
|
|
6243
6239
|
const raf = requestAnimationFrame(() => {
|
|
6244
|
-
const targetTop =
|
|
6240
|
+
const targetTop = userMsgOffsetInScroll + paddingTop - topOffset;
|
|
6245
6241
|
scrollEl.scrollTo({
|
|
6246
6242
|
top: Math.max(0, targetTop),
|
|
6247
6243
|
behavior: "smooth"
|
|
6248
6244
|
});
|
|
6249
6245
|
});
|
|
6250
|
-
const ro = new ResizeObserver(() => {
|
|
6251
|
-
if (!contentEl || !spacerEl || !scrollEl) return;
|
|
6252
|
-
const consumedBelow = contentEl.getBoundingClientRect().height - computeOffsetTop(targetEl, contentEl) - userMessageHeight;
|
|
6253
|
-
const remaining = Math.max(0, spacerHeight - consumedBelow);
|
|
6254
|
-
if (remaining < currentSpacerHeightRef.current) {
|
|
6255
|
-
spacerEl.style.height = `${remaining}px`;
|
|
6256
|
-
currentSpacerHeightRef.current = remaining;
|
|
6257
|
-
}
|
|
6258
|
-
});
|
|
6259
|
-
ro.observe(contentEl);
|
|
6260
6246
|
return () => {
|
|
6261
6247
|
cancelAnimationFrame(raf);
|
|
6262
|
-
|
|
6248
|
+
contentEl.style.minHeight = "";
|
|
6263
6249
|
};
|
|
6264
6250
|
}, [
|
|
6265
6251
|
id,
|
|
6266
6252
|
sendNonce,
|
|
6267
6253
|
scrollRef,
|
|
6268
6254
|
contentRef,
|
|
6269
|
-
spacerRef,
|
|
6270
6255
|
topOffset
|
|
6271
6256
|
]);
|
|
6272
6257
|
}
|
|
@@ -6480,11 +6465,9 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
6480
6465
|
});
|
|
6481
6466
|
};
|
|
6482
6467
|
const PinToSendScrollContainer = ({ children, scrollRef, contentRef, scrollToBottom, scrollToBottomButton, feather, inputContainerHeight, isResizing, nonAutoScrollEl, nonAutoScrollRefCallback, showScrollButton, className, ...props }) => {
|
|
6483
|
-
const spacerRef = (0, react.useRef)(null);
|
|
6484
6468
|
usePinToSend({
|
|
6485
6469
|
scrollRef,
|
|
6486
6470
|
contentRef,
|
|
6487
|
-
spacerRef,
|
|
6488
6471
|
topOffset: 16
|
|
6489
6472
|
});
|
|
6490
6473
|
const BoundFeather = renderSlot(feather, CopilotChatView.Feather, {});
|
|
@@ -6493,23 +6476,16 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
6493
6476
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6494
6477
|
className: cn("cpk:h-full cpk:max-h-full cpk:flex cpk:flex-col cpk:min-h-0 cpk:relative", className),
|
|
6495
6478
|
children: [
|
|
6496
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
6479
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6497
6480
|
ref: nonAutoScrollRefCallback,
|
|
6498
6481
|
className: "cpk:flex-1 cpk:min-h-0 cpk:overflow-y-auto cpk:overflow-x-hidden",
|
|
6499
6482
|
...props,
|
|
6500
|
-
children:
|
|
6483
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6501
6484
|
ref: contentRef,
|
|
6485
|
+
"data-pin-to-send-content": true,
|
|
6502
6486
|
className: "cpk:px-4 cpk:sm:px-0 cpk:[div[data-sidebar-chat]_&]:px-8 cpk:[div[data-popup-chat]_&]:px-6",
|
|
6503
6487
|
children
|
|
6504
|
-
})
|
|
6505
|
-
ref: spacerRef,
|
|
6506
|
-
"data-pin-to-send-spacer": true,
|
|
6507
|
-
"aria-hidden": "true",
|
|
6508
|
-
style: {
|
|
6509
|
-
height: 0,
|
|
6510
|
-
flex: "0 0 auto"
|
|
6511
|
-
}
|
|
6512
|
-
})]
|
|
6488
|
+
})
|
|
6513
6489
|
}),
|
|
6514
6490
|
BoundFeather,
|
|
6515
6491
|
showScrollButton && !isResizing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -10202,4 +10178,4 @@ Object.defineProperty(exports, 'useToast', {
|
|
|
10202
10178
|
return useToast;
|
|
10203
10179
|
}
|
|
10204
10180
|
});
|
|
10205
|
-
//# sourceMappingURL=copilotkit-
|
|
10181
|
+
//# sourceMappingURL=copilotkit-Bn7CCpNA.cjs.map
|