/** * Internal dependencies */ import type { View } from '../types'; type PaginationInfo = { totalItems: number; totalPages: number; }; interface UseDataParams { view: View; data: Item[]; getItemId: (item: Item) => string; isLoading?: boolean; paginationInfo: PaginationInfo; selection?: string[]; } interface UseDataResult { data: (Item & { position?: number; })[]; paginationInfo: PaginationInfo; hasInitiallyLoaded: boolean; setVisibleEntries?: React.Dispatch>; } /** * Hook to manage data for DataViews. * * When infinite scroll is enabled, this hook handles: * - Loading more data when scrolling up or down * - Maintaining stable positions for items * - Unloading items that are no longer visible (with a buffer) * * When infinite scroll is disabled, it preserves the previous data and * pagination info while loading, so the UI doesn't flash empty. * * In both cases, it tracks whether data has initially loaded. * * @param params - Configuration parameters * @param params.view - Current view configuration * @param params.data - Current page of data * @param params.getItemId - Function to extract item ID * @param params.isLoading - Whether data is currently loading * @param params.paginationInfo - Pagination info (totalItems, totalPages) * @param params.selection - Currently selected item IDs * @return Object containing data, paginationInfo, hasInitiallyLoaded, * and optional setVisibleEntries callback */ export default function useData({ view, data: shownData, getItemId, isLoading, paginationInfo, selection, }: UseDataParams): UseDataResult; export {}; //# sourceMappingURL=use-data.d.ts.map