import type { PaginatedResponse } from "@polymedia/suitcase-core"; import { type RefObject } from "react"; export type UseFetchResult = ReturnType>; export type UseFetchAndLoadMoreResult = ReturnType>; export type UseFetchAndPaginateResult = ReturnType>; /** * A hook that detects when a click or touch event occurs outside a DOM element. * * @param domElementRef A React ref object pointing to the target DOM element. * @param onClickOutside Function to call when a click or touch is detected outside the target element. */ export declare function useClickOutside(domElementRef: RefObject, onClickOutside: () => void): void; /** * A hook to handle data fetching. * * @template T The type of data returned by the fetch function * @param fetchFunction An async function that returns a `Promise` * @param dependencies An array of dependencies that trigger a re-fetch when changed * @returns An object containing: * - data: The fetched data * - err: Any error that occurred * - isLoading: Whether data is currently being fetched */ export declare function useFetch(fetchFunction: () => Promise, dependencies?: unknown[]): { data: T | undefined; err: string | null; isLoading: boolean; refetch: () => Promise; }; /** /** * A hook to handle data fetching and loading more data. * * @template T The type of data returned by the fetch function * @template C The type of cursor used to paginate through the data * @param fetchFunction An async function that returns a `Promise>` * @param dependencies An array of dependencies that trigger a re-fetch when changed * @returns An object containing: * - data: The fetched data * - err: Any error that occurred * - isLoading: Whether data is currently being fetched * - hasNextPage: Whether there is a next page available to fetch * - loadMore: A function to load more data */ export declare function useFetchAndLoadMore(fetchFunction: (cursor: C | undefined) => Promise>, dependencies?: unknown[]): { data: T[]; err: string | null; isLoading: boolean; hasNextPage: boolean; loadMore: () => Promise; }; /** * A hook to handle data fetching and paginating through the results. * * @template T The type of data returned by the fetch function * @template C The type of cursor used to paginate through the data * @param fetchFunction An async function that returns a `Promise>` * @param dependencies An array of dependencies that trigger a re-fetch when changed * @returns An object containing the following properties: * - page: The current page of data * - err: Any error that occurred during fetching * - isLoading: Whether data is currently being fetched * - hasMultiplePages: Whether there are multiple pages of data * - isFirstPage: Whether the current page is the first page * - isLastPage: Whether the current page is the last fetched page * - hasNextPage: Whether there is a next page available to fetch * - goToNextPage: Function to navigate to the next page * - goToPreviousPage: Function to navigate to the previous page */ export declare function useFetchAndPaginate(fetchFunction: (cursor: C | undefined) => Promise>, dependencies?: unknown[]): { page: T[]; err: string | null; isLoading: boolean; hasMultiplePages: boolean; isFirstPage: boolean; isLastPage: boolean; hasNextPage: boolean; goToNextPage: () => Promise; goToPreviousPage: () => void; };