UNPKG

@cn-ui/core

Version:

The @cn-ui/core is a collection of UI components and utilities for building modern web applications with SolidJS.

64 lines (63 loc) 1.75 kB
import { type Atom, type JSXSlot } from "@cn-ui/reactive"; import { type Accessor, type JSXElement, type Setter } from "solid-js"; import { type CNVirtualizer } from "../table/virtual/createVirtualizer"; export interface VirtualListExpose { virtualizer: CNVirtualizer<HTMLDivElement, Element>; } export interface VirtualListProps<T> { /** * 需要渲染的数组 * @tested */ each: T[]; /** * 翻转渲染方向。比如原来从上至下,现在从下至上渲染。 * @tested */ reverse?: boolean; /** * 当没有数据时的渲染 */ fallback?: JSXSlot; /** * 预估每一项的高度 * @tested */ estimateSize?: number; /** * 覆盖自动计算的容器高度 */ containerHeight?: number; /** * 是否是横向滚动 * @tested */ horizontal?: boolean; /** 标识其 Key 值的属性,为了保证渲染的高效 */ getItemKey?: (index: number) => number | string; /** * 每一项的渲染组件 * @tested */ children: (item: T, index: Accessor<number>, context: { itemClass: Atom<string>; itemRef: Atom<HTMLDivElement | null>; }) => JSXElement; /** transition 动画需要的样式 */ transitionName?: string; /** * 视图之外预先渲染的数据量 * @tested */ overscan?: number; /** * 暴露一些内部方法 * @tested */ expose?: Setter<VirtualListExpose>; /** * @dev */ onVirtualScrollEnd?: () => void; } export declare const VirtualList: <T>(props: import("@cn-ui/reactive").OriginComponentOutputType<VirtualListProps<T>, HTMLDivElement, unknown>) => import("solid-js").JSX.Element;