UNPKG

@assistant-ui/react

Version:

Typescript/React library for AI Chat

28 lines (27 loc) 855 B
"use client"; // src/primitives/thread/ThreadScrollToBottom.tsx import { createActionButton } from "../../utils/createActionButton.mjs"; import { useCallback } from "react"; import { useThreadViewport, useThreadViewportStore } from "../../context/react/ThreadViewportContext.mjs"; var useThreadScrollToBottom = () => { const isAtBottom = useThreadViewport((s) => s.isAtBottom); const threadViewportStore = useThreadViewportStore(); const handleScrollToBottom = useCallback(() => { threadViewportStore.getState().scrollToBottom(); }, [threadViewportStore]); if (isAtBottom) return null; return handleScrollToBottom; }; var ThreadPrimitiveScrollToBottom = createActionButton( "ThreadPrimitive.ScrollToBottom", useThreadScrollToBottom ); export { ThreadPrimitiveScrollToBottom }; //# sourceMappingURL=ThreadScrollToBottom.mjs.map