import { location, record } from '@synnaxlabs/x'; import { PropsWithChildren, ReactElement, RefCallback } from 'react'; /** Function interface for getting items from a list by key(s). */ export interface GetItem | undefined> extends GetSingleItem, GetMultipleItems { } /** Reads one item by key. */ export interface GetSingleItem | undefined> { (key: K): E | undefined; } /** Reads many items at once, dropping any key with no item. */ export interface GetMultipleItems | undefined> { (keys: K[]): E[]; } /** Joins a single-key and a multi-key reader into one {@link GetItem}. */ export declare const createGetItem: | undefined>(first: GetSingleItem, second: GetMultipleItems) => GetItem; /** One item the enclosing frame asks its children to render. */ export interface ItemSpec { key: K; index: number; /** Pixel offset from the top of the list, set only when virtualized. */ translate?: number; } export interface DataContextValue { data: K[]; getItems: () => ItemSpec[]; getTotalSize: () => number | undefined; sentinelRef?: RefCallback; } export interface UtilContextValue | undefined = record.Keyed | undefined> { ref: RefCallback; getItem?: GetItem; subscribe?: (callback: () => void, key: K) => () => void; scrollToIndex: (index: number, direction?: location.Y) => void; itemHeight?: number; } export declare const useUtilContext: | undefined = record.Keyed | undefined>() => UtilContextValue; /** Props for {@link Frame}. A data hook such as `useStaticData` supplies most of them. */ export interface FrameProps | undefined = record.Keyed | undefined> extends PropsWithChildren, Pick, "getItem" | "subscribe"> { /** The keys to render, in order. */ data: K[]; /** Whether to render only the visible window. Needed above a few hundred items. */ virtual?: boolean; /** Extra items to render past each edge of the visible window. */ overscan?: number; /** Row height in pixels. Virtualization estimates from it. */ itemHeight?: number; /** Called when the list scrolls near its end. */ onFetchMore?: () => void; } /** @returns a scroller for the enclosing {@link Frame}, stable as the list scrolls. */ export declare const useScroller: () => Pick, "scrollToIndex">; /** * useItemHeight returns the row height the enclosing Frame was given. It reads the * util context, which does not change as the list scrolls. */ export declare const useItemHeight: () => number | undefined; /** * Reads the item for a key from the enclosing {@link Frame} and re-renders the caller * when that one item changes. Use it inside a list item, so the list does not re-render * on every entry update. */ export declare const useItem: | undefined = record.Keyed | undefined>(key: K) => E | undefined; /** * Reads the full state of the enclosing {@link Frame}: the keys, the visible window, * and the item readers. It re-renders on every scroll, so prefer {@link useItem} inside * an item. */ export declare const useData: | undefined = record.Keyed | undefined>() => DataContextValue & UtilContextValue; /** {@link Frame} before memoization. Prefer `Frame`. */ export declare const BaseFrame: | undefined = record.Keyed | undefined>({ virtual, ...rest }: FrameProps) => ReactElement; /** * Holds the data for a list and hands it to its children through context. It renders no * element of its own: pair it with {@link Items} for the scroll container. * * @example * * {(p) => } * */ export declare const Frame: | undefined = record.Keyed | undefined>({ virtual, ...rest }: FrameProps) => ReactElement; //# sourceMappingURL=Frame.d.ts.map