UNPKG

2.42 kBTypeScriptView Raw
1import * as React from 'react';
2import type { InnerProps } from './Filler';
3import type { ScrollBarDirectionType } from './ScrollBar';
4import type { RenderFunc, ExtraRenderInfo } from './interface';
5import type { ScrollPos, ScrollTarget } from './hooks/useScrollTo';
6export interface ScrollInfo {
7 x: number;
8 y: number;
9}
10export type ScrollConfig = ScrollTarget | ScrollPos;
11export type ScrollTo = (arg: number | ScrollConfig) => void;
12export type ListRef = {
13 scrollTo: ScrollTo;
14 getScrollInfo: () => ScrollInfo;
15};
16export interface ListProps<T> extends Omit<React.HTMLAttributes<any>, 'children'> {
17 prefixCls?: string;
18 children: RenderFunc<T>;
19 data: T[];
20 height?: number;
21 itemHeight?: number;
22 /** If not match virtual scroll condition, Set List still use height of container. */
23 fullHeight?: boolean;
24 itemKey: React.Key | ((item: T) => React.Key);
25 component?: string | React.FC<any> | React.ComponentClass<any>;
26 /** Set `false` will always use real scroll instead of virtual one */
27 virtual?: boolean;
28 direction?: ScrollBarDirectionType;
29 /**
30 * By default `scrollWidth` is same as container.
31 * When set this, it will show the horizontal scrollbar and
32 * `scrollWidth` will be used as the real width instead of container width.
33 * When set, `virtual` will always be enabled.
34 */
35 scrollWidth?: number;
36 styles?: {
37 horizontalScrollBar?: React.CSSProperties;
38 horizontalScrollBarThumb?: React.CSSProperties;
39 verticalScrollBar?: React.CSSProperties;
40 verticalScrollBarThumb?: React.CSSProperties;
41 };
42 onScroll?: React.UIEventHandler<HTMLElement>;
43 /**
44 * Given the virtual offset value.
45 * It's the logic offset from start position.
46 */
47 onVirtualScroll?: (info: ScrollInfo) => void;
48 /** Trigger when render list item changed */
49 onVisibleChange?: (visibleList: T[], fullList: T[]) => void;
50 /** Inject to inner container props. Only use when you need pass aria related data */
51 innerProps?: InnerProps;
52 /** Render extra content into Filler */
53 extraRender?: (info: ExtraRenderInfo) => React.ReactNode;
54}
55export declare function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>): React.JSX.Element;
56declare const _default: <Item = any>(props: ListProps<Item> & {
57 ref?: React.Ref<ListRef>;
58}) => React.ReactElement;
59export default _default;