/** * Unified Cursor Pagination State Hook * * Manages all common cursor-based pagination state logic: * - URL state management with useApiParams * - Debounced search input * - hasLoadedBeyondFirst tracking * - Initial load detection * - Search change detection * - Pagination handlers (next, reset) * * This eliminates ~60-80 lines of boilerplate from each paginated component. * * @example * const { * searchInput, setSearchInput, * hasLoadedBeyondFirst, * handleNextPage, handleResetToFirstPage * } = useCursorPaginationState({ * onInitialLoad: (search, cursor) => fetchDialogs(false, search, true, cursor), * onSearchChange: (search) => fetchDialogs(false, search) * }) */ import { type UseApiParamsReturn } from './use-api-params'; export interface UseCursorPaginationStateOptions { /** * Debounce delay for search input (default: 300ms) */ debounceMs?: number; /** * Callback for initial page load * Called once on mount with current search and cursor from URL */ onInitialLoad: (search: string, cursor: string | null) => void | Promise; /** * Callback when search term changes (after debounce) * Called after URL is updated, cursor is already reset */ onSearchChange: (search: string) => void | Promise; } declare const urlSchema: { search: { type: "string"; default: string; }; cursor: { type: "string"; default: string; }; }; type ApiParamsReturn = UseApiParamsReturn; /** Pagination params managed by this hook */ export type PaginationParams = ApiParamsReturn['params']; export interface CursorPaginationStateReturn { searchInput: string; setSearchInput: (value: string) => void; hasLoadedBeyondFirst: boolean; setHasLoadedBeyondFirst: (value: boolean) => void; handleNextPage: (endCursor: string, fetchFn: () => Promise) => Promise; handleResetToFirstPage: (fetchFn: () => Promise) => Promise; params: PaginationParams; setParam: ApiParamsReturn['setParam']; setParams: ApiParamsReturn['setParams']; } export declare function useCursorPaginationState(options: UseCursorPaginationStateOptions): CursorPaginationStateReturn; export {}; //# sourceMappingURL=use-cursor-pagination-state.d.ts.map