@react-aria/virtualizer
Version:
Spectrum UI components in React
340 lines (338 loc) • 21.4 kB
TypeScript
import { Direction, Key, RefObject, Collection } from "@react-types/shared";
import { LayoutInfo, Size, Rect, Layout, ReusableView } from "@react-stately/virtualizer";
import React, { CSSProperties, HTMLAttributes, ReactNode, RefObject as _RefObject1, ReactElement } from "react";
export type RTLOffsetType = 'negative' | 'positive-descending' | 'positive-ascending';
export function getRTLOffsetType(recalculate?: boolean): RTLOffsetType;
export function getScrollLeft(node: Element, direction: Direction): number;
export function setScrollLeft(node: Element, direction: Direction, scrollLeft: number): void;
interface IVirtualizer {
updateItemSize(key: Key, size: Size): void;
}
export interface VirtualizerItemOptions {
layoutInfo: LayoutInfo | null;
virtualizer: IVirtualizer;
ref: RefObject<HTMLElement | null>;
}
export function useVirtualizerItem(options: VirtualizerItemOptions): {
updateSize: () => void;
};
interface ScrollViewProps extends HTMLAttributes<HTMLElement> {
contentSize: Size;
onVisibleRectChange: (rect: Rect) => void;
children?: ReactNode;
innerStyle?: CSSProperties;
onScrollStart?: () => void;
onScrollEnd?: () => void;
scrollDirection?: 'horizontal' | 'vertical' | 'both';
}
export const ScrollView: React.ForwardRefExoticComponent<ScrollViewProps & React.RefAttributes<HTMLDivElement | null>>;
export function useScrollView(props: ScrollViewProps, ref: _RefObject1<HTMLElement | null>): {
scrollViewProps: {
style: React.CSSProperties;
children?: ReactNode;
defaultChecked?: boolean | undefined;
defaultValue?: string | number | readonly string[] | undefined;
suppressContentEditableWarning?: boolean | undefined;
suppressHydrationWarning?: boolean | undefined;
accessKey?: string | undefined;
autoFocus?: boolean | undefined;
className?: string | undefined;
contentEditable?: (boolean | "false" | "true") | "inherit" | "plaintext-only" | undefined;
contextMenu?: string | undefined;
dir?: string | undefined;
draggable?: (boolean | "false" | "true") | undefined;
hidden?: boolean | undefined;
id?: string | undefined;
lang?: string | undefined;
nonce?: string | undefined;
slot?: string | undefined;
spellCheck?: (boolean | "false" | "true") | undefined;
tabIndex?: number | undefined;
title?: string | undefined;
translate?: "yes" | "no" | undefined;
radioGroup?: string | undefined;
role?: React.AriaRole | undefined;
about?: string | undefined;
content?: string | undefined;
datatype?: string | undefined;
inlist?: any;
prefix?: string | undefined;
property?: string | undefined;
rel?: string | undefined;
resource?: string | undefined;
rev?: string | undefined;
typeof?: string | undefined;
vocab?: string | undefined;
autoCapitalize?: string | undefined;
autoCorrect?: string | undefined;
autoSave?: string | undefined;
color?: string | undefined;
itemProp?: string | undefined;
itemScope?: boolean | undefined;
itemType?: string | undefined;
itemID?: string | undefined;
itemRef?: string | undefined;
results?: number | undefined;
security?: string | undefined;
unselectable?: "on" | "off" | undefined;
popover?: "" | "auto" | "manual" | undefined;
popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
popoverTarget?: string | undefined;
inert?: boolean | undefined;
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
is?: string | undefined;
"aria-activedescendant"?: string | undefined;
"aria-atomic"?: (boolean | "false" | "true") | undefined;
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
"aria-braillelabel"?: string | undefined;
"aria-brailleroledescription"?: string | undefined;
"aria-busy"?: (boolean | "false" | "true") | undefined;
"aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
"aria-colcount"?: number | undefined;
"aria-colindex"?: number | undefined;
"aria-colindextext"?: string | undefined;
"aria-colspan"?: number | undefined;
"aria-controls"?: string | undefined;
"aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
"aria-describedby"?: string | undefined;
"aria-description"?: string | undefined;
"aria-details"?: string | undefined;
"aria-disabled"?: (boolean | "false" | "true") | undefined;
"aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
"aria-errormessage"?: string | undefined;
"aria-expanded"?: (boolean | "false" | "true") | undefined;
"aria-flowto"?: string | undefined;
"aria-grabbed"?: (boolean | "false" | "true") | undefined;
"aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
"aria-hidden"?: (boolean | "false" | "true") | undefined;
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
"aria-keyshortcuts"?: string | undefined;
"aria-label"?: string | undefined;
"aria-labelledby"?: string | undefined;
"aria-level"?: number | undefined;
"aria-live"?: "off" | "assertive" | "polite" | undefined;
"aria-modal"?: (boolean | "false" | "true") | undefined;
"aria-multiline"?: (boolean | "false" | "true") | undefined;
"aria-multiselectable"?: (boolean | "false" | "true") | undefined;
"aria-orientation"?: "horizontal" | "vertical" | undefined;
"aria-owns"?: string | undefined;
"aria-placeholder"?: string | undefined;
"aria-posinset"?: number | undefined;
"aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
"aria-readonly"?: (boolean | "false" | "true") | undefined;
"aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined;
"aria-required"?: (boolean | "false" | "true") | undefined;
"aria-roledescription"?: string | undefined;
"aria-rowcount"?: number | undefined;
"aria-rowindex"?: number | undefined;
"aria-rowindextext"?: string | undefined;
"aria-rowspan"?: number | undefined;
"aria-selected"?: (boolean | "false" | "true") | undefined;
"aria-setsize"?: number | undefined;
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
"aria-valuemax"?: number | undefined;
"aria-valuemin"?: number | undefined;
"aria-valuenow"?: number | undefined;
"aria-valuetext"?: string | undefined;
dangerouslySetInnerHTML?: {
__html: string | TrustedHTML;
} | undefined;
onCopy?: React.ClipboardEventHandler<HTMLElement> | undefined;
onCopyCapture?: React.ClipboardEventHandler<HTMLElement> | undefined;
onCut?: React.ClipboardEventHandler<HTMLElement> | undefined;
onCutCapture?: React.ClipboardEventHandler<HTMLElement> | undefined;
onPaste?: React.ClipboardEventHandler<HTMLElement> | undefined;
onPasteCapture?: React.ClipboardEventHandler<HTMLElement> | undefined;
onCompositionEnd?: React.CompositionEventHandler<HTMLElement> | undefined;
onCompositionEndCapture?: React.CompositionEventHandler<HTMLElement> | undefined;
onCompositionStart?: React.CompositionEventHandler<HTMLElement> | undefined;
onCompositionStartCapture?: React.CompositionEventHandler<HTMLElement> | undefined;
onCompositionUpdate?: React.CompositionEventHandler<HTMLElement> | undefined;
onCompositionUpdateCapture?: React.CompositionEventHandler<HTMLElement> | undefined;
onFocus?: React.FocusEventHandler<HTMLElement> | undefined;
onFocusCapture?: React.FocusEventHandler<HTMLElement> | undefined;
onBlur?: React.FocusEventHandler<HTMLElement> | undefined;
onBlurCapture?: React.FocusEventHandler<HTMLElement> | undefined;
onChange?: React.FormEventHandler<HTMLElement> | undefined;
onChangeCapture?: React.FormEventHandler<HTMLElement> | undefined;
onBeforeInput?: React.FormEventHandler<HTMLElement> | undefined;
onBeforeInputCapture?: React.FormEventHandler<HTMLElement> | undefined;
onInput?: React.FormEventHandler<HTMLElement> | undefined;
onInputCapture?: React.FormEventHandler<HTMLElement> | undefined;
onReset?: React.FormEventHandler<HTMLElement> | undefined;
onResetCapture?: React.FormEventHandler<HTMLElement> | undefined;
onSubmit?: React.FormEventHandler<HTMLElement> | undefined;
onSubmitCapture?: React.FormEventHandler<HTMLElement> | undefined;
onInvalid?: React.FormEventHandler<HTMLElement> | undefined;
onInvalidCapture?: React.FormEventHandler<HTMLElement> | undefined;
onLoad?: React.ReactEventHandler<HTMLElement> | undefined;
onLoadCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onError?: React.ReactEventHandler<HTMLElement> | undefined;
onErrorCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onKeyDown?: React.KeyboardEventHandler<HTMLElement> | undefined;
onKeyDownCapture?: React.KeyboardEventHandler<HTMLElement> | undefined;
onKeyPress?: React.KeyboardEventHandler<HTMLElement> | undefined;
onKeyPressCapture?: React.KeyboardEventHandler<HTMLElement> | undefined;
onKeyUp?: React.KeyboardEventHandler<HTMLElement> | undefined;
onKeyUpCapture?: React.KeyboardEventHandler<HTMLElement> | undefined;
onAbort?: React.ReactEventHandler<HTMLElement> | undefined;
onAbortCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onCanPlay?: React.ReactEventHandler<HTMLElement> | undefined;
onCanPlayCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onCanPlayThrough?: React.ReactEventHandler<HTMLElement> | undefined;
onCanPlayThroughCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onDurationChange?: React.ReactEventHandler<HTMLElement> | undefined;
onDurationChangeCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onEmptied?: React.ReactEventHandler<HTMLElement> | undefined;
onEmptiedCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onEncrypted?: React.ReactEventHandler<HTMLElement> | undefined;
onEncryptedCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onEnded?: React.ReactEventHandler<HTMLElement> | undefined;
onEndedCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onLoadedData?: React.ReactEventHandler<HTMLElement> | undefined;
onLoadedDataCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onLoadedMetadata?: React.ReactEventHandler<HTMLElement> | undefined;
onLoadedMetadataCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onLoadStart?: React.ReactEventHandler<HTMLElement> | undefined;
onLoadStartCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onPause?: React.ReactEventHandler<HTMLElement> | undefined;
onPauseCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onPlay?: React.ReactEventHandler<HTMLElement> | undefined;
onPlayCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onPlaying?: React.ReactEventHandler<HTMLElement> | undefined;
onPlayingCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onProgress?: React.ReactEventHandler<HTMLElement> | undefined;
onProgressCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onRateChange?: React.ReactEventHandler<HTMLElement> | undefined;
onRateChangeCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onResize?: React.ReactEventHandler<HTMLElement> | undefined;
onResizeCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onSeeked?: React.ReactEventHandler<HTMLElement> | undefined;
onSeekedCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onSeeking?: React.ReactEventHandler<HTMLElement> | undefined;
onSeekingCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onStalled?: React.ReactEventHandler<HTMLElement> | undefined;
onStalledCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onSuspend?: React.ReactEventHandler<HTMLElement> | undefined;
onSuspendCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onTimeUpdate?: React.ReactEventHandler<HTMLElement> | undefined;
onTimeUpdateCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onVolumeChange?: React.ReactEventHandler<HTMLElement> | undefined;
onVolumeChangeCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onWaiting?: React.ReactEventHandler<HTMLElement> | undefined;
onWaitingCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onAuxClick?: React.MouseEventHandler<HTMLElement> | undefined;
onAuxClickCapture?: React.MouseEventHandler<HTMLElement> | undefined;
onClick?: React.MouseEventHandler<HTMLElement> | undefined;
onClickCapture?: React.MouseEventHandler<HTMLElement> | undefined;
onContextMenu?: React.MouseEventHandler<HTMLElement> | undefined;
onContextMenuCapture?: React.MouseEventHandler<HTMLElement> | undefined;
onDoubleClick?: React.MouseEventHandler<HTMLElement> | undefined;
onDoubleClickCapture?: React.MouseEventHandler<HTMLElement> | undefined;
onDrag?: React.DragEventHandler<HTMLElement> | undefined;
onDragCapture?: React.DragEventHandler<HTMLElement> | undefined;
onDragEnd?: React.DragEventHandler<HTMLElement> | undefined;
onDragEndCapture?: React.DragEventHandler<HTMLElement> | undefined;
onDragEnter?: React.DragEventHandler<HTMLElement> | undefined;
onDragEnterCapture?: React.DragEventHandler<HTMLElement> | undefined;
onDragExit?: React.DragEventHandler<HTMLElement> | undefined;
onDragExitCapture?: React.DragEventHandler<HTMLElement> | undefined;
onDragLeave?: React.DragEventHandler<HTMLElement> | undefined;
onDragLeaveCapture?: React.DragEventHandler<HTMLElement> | undefined;
onDragOver?: React.DragEventHandler<HTMLElement> | undefined;
onDragOverCapture?: React.DragEventHandler<HTMLElement> | undefined;
onDragStart?: React.DragEventHandler<HTMLElement> | undefined;
onDragStartCapture?: React.DragEventHandler<HTMLElement> | undefined;
onDrop?: React.DragEventHandler<HTMLElement> | undefined;
onDropCapture?: React.DragEventHandler<HTMLElement> | undefined;
onMouseDown?: React.MouseEventHandler<HTMLElement> | undefined;
onMouseDownCapture?: React.MouseEventHandler<HTMLElement> | undefined;
onMouseEnter?: React.MouseEventHandler<HTMLElement> | undefined;
onMouseLeave?: React.MouseEventHandler<HTMLElement> | undefined;
onMouseMove?: React.MouseEventHandler<HTMLElement> | undefined;
onMouseMoveCapture?: React.MouseEventHandler<HTMLElement> | undefined;
onMouseOut?: React.MouseEventHandler<HTMLElement> | undefined;
onMouseOutCapture?: React.MouseEventHandler<HTMLElement> | undefined;
onMouseOver?: React.MouseEventHandler<HTMLElement> | undefined;
onMouseOverCapture?: React.MouseEventHandler<HTMLElement> | undefined;
onMouseUp?: React.MouseEventHandler<HTMLElement> | undefined;
onMouseUpCapture?: React.MouseEventHandler<HTMLElement> | undefined;
onSelect?: React.ReactEventHandler<HTMLElement> | undefined;
onSelectCapture?: React.ReactEventHandler<HTMLElement> | undefined;
onTouchCancel?: React.TouchEventHandler<HTMLElement> | undefined;
onTouchCancelCapture?: React.TouchEventHandler<HTMLElement> | undefined;
onTouchEnd?: React.TouchEventHandler<HTMLElement> | undefined;
onTouchEndCapture?: React.TouchEventHandler<HTMLElement> | undefined;
onTouchMove?: React.TouchEventHandler<HTMLElement> | undefined;
onTouchMoveCapture?: React.TouchEventHandler<HTMLElement> | undefined;
onTouchStart?: React.TouchEventHandler<HTMLElement> | undefined;
onTouchStartCapture?: React.TouchEventHandler<HTMLElement> | undefined;
onPointerDown?: React.PointerEventHandler<HTMLElement> | undefined;
onPointerDownCapture?: React.PointerEventHandler<HTMLElement> | undefined;
onPointerMove?: React.PointerEventHandler<HTMLElement> | undefined;
onPointerMoveCapture?: React.PointerEventHandler<HTMLElement> | undefined;
onPointerUp?: React.PointerEventHandler<HTMLElement> | undefined;
onPointerUpCapture?: React.PointerEventHandler<HTMLElement> | undefined;
onPointerCancel?: React.PointerEventHandler<HTMLElement> | undefined;
onPointerCancelCapture?: React.PointerEventHandler<HTMLElement> | undefined;
onPointerEnter?: React.PointerEventHandler<HTMLElement> | undefined;
onPointerLeave?: React.PointerEventHandler<HTMLElement> | undefined;
onPointerOver?: React.PointerEventHandler<HTMLElement> | undefined;
onPointerOverCapture?: React.PointerEventHandler<HTMLElement> | undefined;
onPointerOut?: React.PointerEventHandler<HTMLElement> | undefined;
onPointerOutCapture?: React.PointerEventHandler<HTMLElement> | undefined;
onGotPointerCapture?: React.PointerEventHandler<HTMLElement> | undefined;
onGotPointerCaptureCapture?: React.PointerEventHandler<HTMLElement> | undefined;
onLostPointerCapture?: React.PointerEventHandler<HTMLElement> | undefined;
onLostPointerCaptureCapture?: React.PointerEventHandler<HTMLElement> | undefined;
onScroll?: React.UIEventHandler<HTMLElement> | undefined;
onScrollCapture?: React.UIEventHandler<HTMLElement> | undefined;
onWheel?: React.WheelEventHandler<HTMLElement> | undefined;
onWheelCapture?: React.WheelEventHandler<HTMLElement> | undefined;
onAnimationStart?: React.AnimationEventHandler<HTMLElement> | undefined;
onAnimationStartCapture?: React.AnimationEventHandler<HTMLElement> | undefined;
onAnimationEnd?: React.AnimationEventHandler<HTMLElement> | undefined;
onAnimationEndCapture?: React.AnimationEventHandler<HTMLElement> | undefined;
onAnimationIteration?: React.AnimationEventHandler<HTMLElement> | undefined;
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLElement> | undefined;
onToggle?: React.ToggleEventHandler<HTMLElement> | undefined;
onBeforeToggle?: React.ToggleEventHandler<HTMLElement> | undefined;
onTransitionCancel?: React.TransitionEventHandler<HTMLElement> | undefined;
onTransitionCancelCapture?: React.TransitionEventHandler<HTMLElement> | undefined;
onTransitionEnd?: React.TransitionEventHandler<HTMLElement> | undefined;
onTransitionEndCapture?: React.TransitionEventHandler<HTMLElement> | undefined;
onTransitionRun?: React.TransitionEventHandler<HTMLElement> | undefined;
onTransitionRunCapture?: React.TransitionEventHandler<HTMLElement> | undefined;
onTransitionStart?: React.TransitionEventHandler<HTMLElement> | undefined;
onTransitionStartCapture?: React.TransitionEventHandler<HTMLElement> | undefined;
};
contentProps: {
role: string;
style: React.CSSProperties;
};
};
interface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {
layoutInfo: LayoutInfo;
parent?: LayoutInfo | null;
style?: CSSProperties;
className?: string;
children: ReactNode;
}
export function VirtualizerItem(props: VirtualizerItemProps): React.JSX.Element;
export function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent?: LayoutInfo | null): CSSProperties;
type RenderWrapper<T extends object, V> = (parent: ReusableView<T, V> | null, reusableView: ReusableView<T, V>, children: ReusableView<T, V>[], renderChildren: (views: ReusableView<T, V>[]) => ReactElement[]) => ReactElement | null;
interface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
children: (type: string, content: T) => V;
renderWrapper?: RenderWrapper<T, V>;
layout: Layout<T, O>;
collection: Collection<T>;
persistedKeys?: Set<Key> | null;
scrollDirection?: 'horizontal' | 'vertical' | 'both';
isLoading?: boolean;
onLoadMore?: () => void;
layoutOptions?: O;
}
export const Virtualizer: <T extends object, V, O>(props: VirtualizerProps<T, V, O> & {
ref?: RefObject<HTMLDivElement | null>;
}) => ReactElement;
//# sourceMappingURL=types.d.ts.map