UNPKG

react-photo-album

Version:

Responsive photo gallery component for React

40 lines (37 loc) 2.04 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import React from 'react'; import { Photo, ClickHandlerProps, CommonPhotoAlbumProps } from '../types.js'; /** InfiniteScroll component props. */ type InfiniteScrollProps<TPhoto extends Photo = Photo> = { /** Photo fetcher. Resolve promise with `null` to indicate end of stream. The promise must always settle; * implement timeouts and cancellation inside the callback as needed. */ fetch: (index: number) => Promise<readonly TPhoto[] | null>; /** Initial photos (optional). */ photos?: readonly TPhoto[]; /** Click handler */ onClick?: ({ photos, photo, index, event }: ClickHandlerProps<TPhoto> & { photos: readonly TPhoto[]; }) => void; /** Retry attempts. */ retries?: number; /** Use a single photo album component (masonry layout). */ singleton?: boolean; /** Markup to display when an error occurred. */ error?: React.ReactNode; /** Markup to display while fetching additional photos. */ loading?: React.ReactNode; /** Markup to display when no more photos are available. */ finished?: React.ReactNode; /** The nearest scrollable ancestor other than the viewport. */ scrollContainer?: () => HTMLElement | null; /** Fetcher `IntersectionObserver` root margin setting. Default: `800px` */ fetchRootMargin?: string; /** Offscreen `IntersectionObserver` root margin setting. Default: `2000px` */ offscreenRootMargin?: string; /** Photo album component. Must be the only child. */ children: React.ReactElement<Pick<CommonPhotoAlbumProps<TPhoto>, "photos" | "render" | "onClick">>; }; /** InfiniteScroll component. */ declare function InfiniteScroll<TPhoto extends Photo>({ photos: initialPhotos, onClick, fetch, retries, singleton, error, loading, finished, children, scrollContainer, fetchRootMargin, offscreenRootMargin, }: InfiniteScrollProps<TPhoto>): react_jsx_runtime.JSX.Element; export { InfiniteScroll as default }; export type { InfiniteScrollProps };