import type { UseFormOptions, UseFormReturns } from "../use-form/index.cjs"; import type { UseMultiSelectReturnsActions, UseMultiSelectReturnsState } from "../use-multi-select/index.cjs"; import type { UsePaginationOptions, UsePaginationReturnsActions, UsePaginationReturnsState } from "../use-pagination/index.cjs"; import type { UseQueryOptions, UseQueryReturns } from "../use-query/index.cjs"; import type { ReactSetState } from "../use-safe-state/index.cjs"; export interface UsePagingListOptions { /** * fetcher function that will be called when the query is triggered */ fetcher?: UsePagingListFetcher; /** * options for `useForm`, see `useForm` for more details * * @defaultValue undefined */ form?: UseFormOptions; /** * options for `useQuery`, see `useQuery` for more details * * @defaultValue undefined */ query?: Omit>, 'initialParams' | 'initialData' | 'cacheKey' | 'cacheExpirationTime' | 'provider'>; /** * options for `usePagination`, see `usePagination` for more details * * @defaultValue undefined */ pagination?: UsePaginationOptions; /** * keys of form state that will trigger a new query when changed * * @defaultValue [] */ immediateQueryKeys?: (keyof FormState)[]; /** * strategy to handle page number when page size changes * * - 'reset' - reset to page 1 * - 'preserve' - preserve the current position by keeping the first item visible on the new page * * @since 1.14.0 * * @defaultValue 'reset' */ pageStrategy?: 'reset' | 'preserve'; } export interface UsePagingListFetcherParams { /** * previous data */ previousData: Item[] | undefined; /** * current page */ page: number; /** * page size */ pageSize: number; /** * form state */ form: FormState; /** * set total count */ setTotal: ReactSetState; } export type UsePagingListFetcher = (params: UsePagingListFetcherParams) => Promise; export interface UsePagingListReturns extends Pick, 'loading' | 'params' | 'error' | 'initializing' | 'refreshing' | 'loadingSlow'> { /** * list data */ list: Item[]; /** * form state */ form: UseFormReturns; /** * refresh query */ refresh: () => void; /** * selection state */ selection: UseMultiSelectReturnsState & UseMultiSelectReturnsActions; /** * pagination state */ pagination: UsePaginationReturnsState & UsePaginationReturnsActions; } /** * A hook for handling paging lists that integrates the functionalities of `useQuery`, `useForm`, `useMultiSelect`, and `usePagination`. * * @since 1.7.0 */ export declare function usePagingList(options?: UsePagingListOptions): UsePagingListReturns;