import { Awaitable, DeepMaybeObservable, ReadonlyObservable } from '@usels/core'; import { ConfigurableWindow } from '../../shared/configurable.mjs'; import { MaybeEventTarget } from '../../types.mjs'; import { UseScrollOptions } from '../useScroll/core.mjs'; import '@legendapp/state'; type UseInfiniteScrollDirection = "top" | "bottom" | "left" | "right"; interface UseInfiniteScrollOptions extends ConfigurableWindow { /** Load trigger direction. Default: "bottom" */ direction?: UseInfiniteScrollDirection; /** arrivedState offset in px. Default: 0 */ distance?: number; /** Whether to auto-load on mount if content is already at boundary. Default: true */ immediate?: boolean; /** Minimum ms between consecutive load triggers. Default: 100 */ interval?: number; /** Gate function — return false to block loading. Evaluated before each load. */ canLoadMore?: (el: HTMLElement) => boolean; /** Additional options passed to useScroll */ scrollOptions?: UseScrollOptions; } interface UseInfiniteScrollReturn { /** Currently loading */ isLoading$: ReadonlyObservable; /** Manually trigger a load */ load: () => Promise; /** Re-check scroll position and trigger load if needed */ reset: () => void; } /** * Framework-agnostic infinite scroll core. * * Triggers `onLoadMore` whenever the scroll position reaches the configured * boundary of a scrollable element. Composes `createScroll` and * `createElementVisibility`. Must be called inside a `useScope` factory. */ declare function createInfiniteScroll(element: MaybeEventTarget, onLoadMore: (direction: UseInfiniteScrollDirection) => Awaitable, options?: DeepMaybeObservable): UseInfiniteScrollReturn; export { type UseInfiniteScrollDirection, type UseInfiniteScrollOptions, type UseInfiniteScrollReturn, createInfiniteScroll };