import React from 'react'; import { type ColumnsOption, type LayoutInfo, type LayoutMode } from '../core'; /** * Anything the component accepts as the scrolling viewport, including a React * ref so the common `useRef(null)` case works directly. */ export type ReactScrollTarget = Window | HTMLElement | 'window' | null | React.RefObject | (() => Window | HTMLElement | null); /** * Public component props */ export interface MasonrySnapGridProps { /** Data items to render */ items: T[]; /** * Layout engine strategy * - 'auto' (default) -> use CSS masonry if supported * - 'js' -> always use JS masonry */ layoutMode?: LayoutMode; /** Space between items (px) */ gutter?: number; /** Minimum column width (px) */ minColWidth?: number; /** * Fixed column count, or a mobile-first breakpoint map of * `minContainerWidth -> columns`, e.g. `{ 0: 1, 640: 2, 1024: 3 }`. * Overrides `minColWidth` when provided. */ columns?: ColumnsOption; /** Enable transform transition animations */ animate?: boolean; /** Transition duration in milliseconds */ transitionDuration?: number; /** Item renderer. Receives the item and its index. */ renderItem: (item: T, index: number) => React.ReactNode; /** * Stable React key for an item. Strongly recommended when items can be * reordered, filtered, or prepended — the index-based fallback will otherwise * reuse a node (and its cached height) for whatever item now sits at that * position. */ getItemKey?: (item: T, index: number) => React.Key; /** Optional container class */ className?: string; /** Optional container styles */ style?: React.CSSProperties; /** Enable scroll virtualization */ virtualize?: boolean; /** Extra viewport buffer when virtualizing */ overscan?: number; /** * The scrolling viewport used for virtualization. Defaults to the page. * Pass an element or a ref to virtualize inside an `overflow: auto` * container. Inline functions should be memoized, as a new identity * resubscribes the scroll listeners. */ scrollContainer?: ReactScrollTarget; /** * Assumed item height in pixels before measurement. * * Without it, virtualization must mount every item once to learn its height, * which defeats the purpose for very large lists. With it, positions are * estimated up front and refined as real heights arrive. */ estimatedItemHeight?: number; /** * Watch each item for size changes so the layout self-heals when content * settles after first measurement — images decoding, fonts swapping, embeds * resizing. Default: true */ observeItemResize?: boolean; /** Also listen for image `load`/`error` inside items. Default: true */ watchImages?: boolean; /** Called after every layout pass. */ onLayout?: (info: LayoutInfo) => void; } /** * MasonrySnapGrid * * SSR friendly masonry grid that: * - renders SEO friendly markup on the server * - upgrades to CSS masonry when supported * - falls back to JS masonry positioning * - supports optional virtualization, in the page or in a scroll container * * Placement, visibility, scroll tracking, and measurement all come from the * framework-agnostic core in `src/core`, so behaviour matches the Vanilla and * Vue builds exactly. */ declare function MasonrySnapGrid({ items, layoutMode, gutter, minColWidth, columns, animate, transitionDuration, renderItem, getItemKey, className, style, virtualize, overscan, scrollContainer, estimatedItemHeight, observeItemResize, watchImages, onLayout, }: MasonrySnapGridProps): React.JSX.Element; export default MasonrySnapGrid;