import type { Accessor } from './signals.js'; import type { Component } from './component.js'; import type { JSX, Ref } from '../jsx-runtime.js'; type Child = JSX.Element; type WhenValue = unknown; export interface ShowProps { when: T | Accessor; keyed?: boolean; fallback?: Child; children?: Child | ((item: NonNullable) => Child); } export declare function Show(props: ShowProps): Child; export interface ForProps { each: T[] | Accessor; fallback?: Child; children: (item: T, index: Accessor) => Child; } export declare function For(props: ForProps): Child; export interface VirtualListScrollOptions { /** Item alignment within the viewport. Default `"start"`. */ align?: 'start' | 'center' | 'end' | 'auto'; /** Native scroll behavior. Default `"auto"`. */ behavior?: ScrollBehavior; } export interface VirtualListOffsetOptions { /** Native scroll behavior. Default `"auto"`. */ behavior?: ScrollBehavior; } export type VirtualListScrollEvent = Event & { readonly currentTarget: HTMLDivElement; readonly target: HTMLDivElement; }; export interface VirtualListApi { /** Scroll to an item index. Out-of-range indices are clamped. */ scrollToIndex: (index: number, options?: VirtualListScrollOptions) => boolean; /** Scroll to the current array item by identity. Returns false when absent. */ scrollToItem: (item: T, options?: VirtualListScrollOptions) => boolean; /** Scroll to a main-axis pixel offset. Out-of-range offsets are clamped. */ scrollToOffset: (offset: number, options?: VirtualListOffsetOptions) => boolean; /** Read the current half-open rendered range. */ getVisibleRange: () => { start: number; end: number }; /** Read the outer scroller element after mount. */ getElement: () => HTMLDivElement | null; } export interface VirtualListProps { /** Additional outer `
` attributes and event handlers are forwarded. */ [key: string]: unknown; each: T[] | Accessor; /** Scroll axis. Default `"vertical"`. */ orientation?: 'vertical' | 'horizontal' | Accessor<'vertical' | 'horizontal'>; /** Fixed row height in px (vertical). Also accepted as main-axis fallback for horizontal. */ itemHeight?: number | Accessor; /** Fixed item width in px (horizontal). Also accepted as main-axis fallback for vertical. */ itemWidth?: number | Accessor; /** Vertical viewport height in px (and optional cross-axis size when horizontal). */ height?: number | string | Accessor; /** Horizontal viewport width in px (and optional cross-axis size when vertical). */ width?: number | string | Accessor; /** Extra items before/after the viewport. Default 5. */ overscan?: number | Accessor; /** * Min ms between scroll-driven window updates (leading + trailing). * `0` (default) applies on every scroll event that changes the index window. */ debounceTime?: number | Accessor; /** Called once when scroll crosses near the trailing edge (infinite scroll). */ onEndReached?: () => void; /** * Fraction of viewport size from the end that triggers `onEndReached`. * Default `0.2`. */ endReachedThreshold?: number | Accessor; /** When true, `onEndReached` will not fire (block while a fetch is in flight). */ endReachedLoading?: boolean | Accessor; keyed?: boolean | ((item: T, index: number) => string | number); fallback?: Child; class?: string; className?: string; style?: string | Record; /** Receives the outer scroller element and `null` when it unmounts. */ ref?: Ref; /** Receives a stable imperative API and `null` when the scroller unmounts. */ apiRef?: (api: VirtualListApi | null) => void; onScroll?: (event: VirtualListScrollEvent) => void; onscroll?: (event: VirtualListScrollEvent) => void; children: (item: T, index: number) => Child; } export declare function VirtualList(props: VirtualListProps): Child; export interface SwitchProps { fallback?: Child; children?: Child; } export declare function Switch(props: SwitchProps): Child; export interface MatchProps { when: T | Accessor; children?: Child | ((item: NonNullable) => Child); } export declare function Match(props: MatchProps): Child; export interface SuspenseProps { fallback?: Child; children?: Child; } export declare function Suspense(props: SuspenseProps): Child; export interface ErrorBoundaryProps { fallback?: Child | ((error: Error, reset: () => void) => Child); children?: Child; } export declare function ErrorBoundary(props: ErrorBoundaryProps): Child; export interface PortalProps { mount?: Node | Accessor; isSVG?: boolean | Accessor; children?: Child; } export declare function Portal(props: PortalProps): Child; export interface Context { id: symbol; defaultValue: T; Provider: Component<{ value: T; children?: Child }>; } export declare function createContext(): Context; export declare function createContext(defaultValue: T): Context; export declare function useContext(context: Context): T; export type ResourceState = 'pending' | 'ready' | 'refreshing' | 'errored'; export interface Resource extends Accessor { state: Accessor; error: Accessor; loading: Accessor; latest: Accessor; promise: () => Promise | null; refetch: () => void; } export declare function createResource( fetcher: ( source: S, info: { value: T | undefined; refetching: boolean } ) => T | Promise ): [Resource]; export declare function createResource( source: S | Accessor, fetcher: ( source: S, info: { value: T | undefined; refetching: boolean } ) => T | Promise ): [Resource]; /** * Lazy-load a component. Wrap in ``. Works with `renderToStringAsync`. */ export declare function lazy( loader: () => Promise<{ default: T } | T> ): T;