import * as React from 'react'; import SvgChevron from '../../assets/icons/Chevron'; import type { usePagination } from '../../hooks'; import { createInteractingObservable } from '@livekit/components-core'; export interface PaginationControlProps extends Pick< ReturnType, 'totalPageCount' | 'nextPage' | 'prevPage' | 'currentPage' > { /** Reference to an HTML element that holds the pages, while interacting (`mouseover`) * with it, the pagination controls will appear for a while. */ pagesContainer?: React.RefObject; } export function PaginationControl({ totalPageCount, nextPage, prevPage, currentPage, pagesContainer: connectedElement, }: PaginationControlProps) { const [interactive, setInteractive] = React.useState(false); React.useEffect(() => { let subscription: | ReturnType['subscribe']> | undefined; if (connectedElement) { subscription = createInteractingObservable(connectedElement.current, 2000).subscribe( setInteractive, ); } return () => { if (subscription) { subscription.unsubscribe(); } }; }, [connectedElement]); return (
{`${currentPage} of ${totalPageCount}`}
); }