UNPKG

1.69 kBTypeScriptView Raw
1/// <reference types="react" />
2
3import { ReactNode, Component, ComponentType } from 'react';
4import { LoadingProps } from '../loading';
5import CommonProps from '../util';
6
7interface HTMLAttributesWeak extends React.HTMLAttributes<HTMLElement> {
8 title?: any
9}
10
11export interface ListProps extends React.HTMLAttributes<HTMLElement>, CommonProps {
12 /**
13 * 列表头部
14 */
15 header?: ReactNode,
16 /**
17 * 列表尾部
18 */
19 footer?: ReactNode,
20 /**
21 * 列表尺寸
22 */
23 size?: 'medium' | 'small',
24 /**
25 * 是否显示分割线
26 */
27 divider?: boolean,
28 /**
29 * children
30 */
31 children?: ReactNode;
32 dataSource?: any[];
33 /**
34 * 当使用 dataSource 时,可以用 renderItem 自定义渲染列表项
35 * @param {Any} current 当前遍历的项
36 * @param {Number} index 当前遍历的项的索引
37 */
38 renderItem?: (current: any, index: number) => any;
39 loading?: boolean;
40 /**
41 * 自定义 Loading 组件
42 * 请务必透传 props, 使用方式: loadingComponent={props => <Loading {...props}/>}
43 */
44 loadingComponent?: (props: LoadingProps) => ReactNode;
45 emptyContent?: ReactNode;
46}
47
48export interface ListItemProps extends HTMLAttributesWeak, CommonProps {
49 /**
50 * 列表元素的标题
51 */
52 title?: ReactNode,
53 /**
54 * 列表元素的描述内容
55 */
56 description?: ReactNode,
57 /**
58 * 列表元素的头像 / 图标 / 图片内容
59 */
60 media?: ReactNode,
61 /**
62 * 额外内容
63 */
64 extra?: ReactNode,
65}
66
67export default class List extends Component<ListProps, any> {
68 static Item: ComponentType<ListItemProps>;
69}