import type { UseAsyncFnOptions } from "../use-async-fn/index.js"; import type { UseFormOptions, UseFormReturns } from "../use-form/index.js"; import type { UseInfiniteScrollOptions, UseInfiniteScrollReturns } from "../use-infinite-scroll/index.js"; import type { UseMultiSelectReturnsActions, UseMultiSelectReturnsState } from "../use-multi-select/index.js"; import type { UsePaginationOptions, UsePaginationReturnsState } from "../use-pagination/index.js"; import type { ElementTarget } from "../use-target-element/index.js"; import type { AnyFunc } from "../utils/basic.js"; export interface UseInfiniteListOptions { /** * The container element */ target?: ElementTarget; /** * The fetcher function, should return a object with data item list. */ fetcher?: Fetcher; /** * The map function to map each data to item list */ mapFullList?: (data: Data) => Item[]; /** * The form options * * see `useForm` for more details */ form?: UseFormOptions; /** * The async function options * * see `useAsyncFn` for more details */ asyncFn?: Omit, 'initialParams'>; /** * The pagination options * * see `usePagination` for more details */ pagination?: UsePaginationOptions; /** * Whether can load more */ canLoadMore?: (previousData: Data | undefined, dataList: Data[], fullList: Item[]) => boolean; /** * The infinite scroll options * * see `useInfiniteScroll` for more details */ infiniteScroll?: Omit, 'canLoadMore'>; /** * The keys of form state that will trigger a new query when changed */ immediateQueryKeys?: (keyof FormState)[]; } export interface UseInfiniteListFetcherParams { /** * previous data */ previousData: Data | undefined; /** * current page */ page: number; /** * page size */ pageSize: number; /** * form state */ form: FormState; } export type UseInfiniteListFetcher = (params: UseInfiniteListFetcherParams) => Promise; export interface UseInfiniteListReturns extends Omit { /** * reset the list, form, pagination, selection, and refetch the data */ reset: () => void; /** * The form state */ form: UseFormReturns; /** * The list data */ list: Data[]; /** * The full list data */ fullList: Item[]; /** * The selection state and action */ selection: UseMultiSelectReturnsState & UseMultiSelectReturnsActions; /** * The pagination state */ paginationState: UsePaginationReturnsState; } /** * * @since 1.7.0 */ export declare function useInfiniteList = UseInfiniteListFetcher, Container extends HTMLElement = HTMLElement>(options?: UseInfiniteListOptions): UseInfiniteListReturns;