import { UseQueryOptions } from '@tanstack/react-query'; import { FilterPayload, RaRecord, SortPayload } from '../types'; /** * A hook used to fetch the previous and next record identifiers for a given record and resource. * * It fetches the list of records according to the filters * and the sort order configured in the list, and merges * the filters and the sorting order passed as props. * * usePrevNextController can be used anywhere a record context is provided * (often inside a `` or `` component). * * @example Simple usage * * import { usePrevNextControllerProps } from 'ra-core'; * const { * hasPrev, * hasNext, * prevPath, * nextPath, * index, * total, * error, * isPending, * } = usePrevNextController(props); * * @example Custom PrevNextButton * * import { UsePrevNextControllerProps, useTranslate } from 'ra-core'; * import NavigateBefore from '@mui/icons-material/NavigateBefore'; * import NavigateNext from '@mui/icons-material/NavigateNext'; * import ErrorIcon from '@mui/icons-material/Error'; * import { Link } from 'react-router-dom'; * import { CircularProgress, IconButton } from '@mui/material'; * * const MyPrevNextButtons = props => { * const { * hasPrev, * hasNext, * nextPath, * prevPath, * index, * total, * error, * isPending, * } = usePrevNextController(props); * * const translate = useTranslate(); * * if (isPending) { * return ; * } * * if (error) { * return ( * * ); * } * * return ( *
    *
  • * * * *
  • * {typeof index === 'number' && ( *
  • * {index + 1} / {total} *
  • * )} *
  • * * * *
  • *
* ); * }; */ export declare const usePrevNextController: (props: UsePrevNextControllerProps) => UsePrevNextControllerResult; export interface UsePrevNextControllerProps { linkType?: 'edit' | 'show'; storeKey?: string | false; limit?: number; filter?: FilterPayload; filterDefaultValues?: FilterPayload; sort?: SortPayload; resource?: string; queryOptions?: Omit, 'queryFn' | 'queryKey'> & { meta?: any; }; } export type UsePrevNextControllerResult = { isFetching: boolean; isLoading: boolean; isPending: boolean; hasPrev: boolean; hasNext: boolean; prevPath: string | undefined; nextPath: string | undefined; index: number | undefined; total: number | undefined; error?: any; }; //# sourceMappingURL=usePrevNextController.d.ts.map