UNPKG

@cossistant/next

Version:

Next.js-ready SDK for building AI-powered support/chat widgets. Hooks + primitives, WS-driven, TypeScript-first. Next.js-ready, Tailwind optional.

84 lines 2.44 kB
//#region ../react/src/hooks/use-conversation-history-page.d.ts type UseConversationHistoryPageOptions = { /** * Initial number of conversations to display. * Default: 4 */ initialVisibleCount?: number; /** * Whether to enable conversations fetching. * Default: true */ enabled?: boolean; /** * Callback when user wants to open a conversation. */ onOpenConversation?: (conversationId: string) => void; /** * Callback when user wants to start a new conversation. */ onStartConversation?: (initialMessage?: string) => void; }; type UseConversationHistoryPageReturn = { conversations: Conversation[]; isLoading: boolean; error: Error | null; visibleConversations: Conversation[]; visibleCount: number; hasMore: boolean; remainingCount: number; showMore: () => void; showAll: () => void; openConversation: (conversationId: string) => void; startConversation: (initialMessage?: string) => void; }; /** * Main hook for the conversation history page. * * This hook: * - Fetches all conversations * - Manages pagination/visible count * - Provides navigation actions * * It encapsulates all conversation history logic, making the component * purely presentational. * * @example * ```tsx * export function ConversationHistoryPage() { * const history = useConversationHistoryPage({ * initialVisibleCount: 4, * onOpenConversation: (id) => { * navigate('conversation', { conversationId: id }); * }, * onStartConversation: (msg) => { * navigate('conversation', { conversationId: PENDING_CONVERSATION_ID, initialMessage: msg }); * }, * }); * * return ( * <> * <h1>Conversation History</h1> * * {history.hasMore && ( * <button onClick={history.showAll}> * +{history.remainingCount} more * </button> * )} * * <ul> * {history.visibleConversations.map(conv => ( * <li key={conv.id} onClick={() => history.openConversation(conv.id)}> * {conv.title} * </li> * ))} * </ul> * </> * ); * } * ``` */ declare function useConversationHistoryPage(options?: UseConversationHistoryPageOptions): UseConversationHistoryPageReturn; //#endregion export { UseConversationHistoryPageOptions, UseConversationHistoryPageReturn, useConversationHistoryPage }; //# sourceMappingURL=use-conversation-history-page.d.ts.map