@promptbook/vercel
Version:
Promptbook: Turn your company's scattered knowledge into AI ready books
42 lines (41 loc) • 1.27 kB
TypeScript
/**
* Configuration for the auto-scroll behavior
*/
export type ChatAutoScrollConfig = {
/**
* Threshold in pixels from bottom to consider as "at bottom"
* @default 100
*/
bottomThreshold?: number;
/**
* Whether to use smooth scrolling
* @default true
*/
smoothScroll?: boolean;
/**
* Delay before checking scroll position after new messages (in milliseconds)
* @default 100
*/
scrollCheckDelay?: number;
};
/**
* Hook for managing auto-scroll behavior in chat components
*
* This hook provides:
* - Automatic scrolling to bottom when new messages arrive (if user is already at bottom)
* - Detection of when user scrolls away from bottom
* - Scroll-to-bottom functionality with smooth animation
* - Mobile-optimized scrolling behavior
*
* @public exported from `@promptbook/components`
*/
export declare function useChatAutoScroll(config?: ChatAutoScrollConfig): {
isAutoScrolling: boolean;
chatMessagesRef: (element: HTMLDivElement | null) => void;
handleScroll: (event: React.UIEvent<HTMLDivElement>) => void;
handleMessagesChange: () => void;
scrollToBottom: () => void;
enableAutoScroll: () => void;
disableAutoScroll: () => void;
isMobile: boolean;
};