1
1
import * as React from 'react' ;
2
+ import classNames from 'classnames' ;
2
3
import Filler from './Filler' ;
3
4
import {
4
5
getElementScrollPercentage ,
@@ -39,6 +40,7 @@ export interface ScrollInfo {
39
40
}
40
41
41
42
export interface ListProps < T > extends React . HTMLAttributes < any > {
43
+ prefixCls ?: string ;
42
44
children : RenderFunc < T > ;
43
45
data : T [ ] ;
44
46
height ?: number ;
@@ -548,7 +550,9 @@ class List<T> extends React.Component<ListProps<T>, ListState<T>> {
548
550
public render ( ) {
549
551
const { isVirtual, itemCount } = this . state ;
550
552
const {
553
+ prefixCls,
551
554
style,
555
+ className,
552
556
component : Component = 'div' ,
553
557
height,
554
558
itemHeight,
@@ -559,16 +563,21 @@ class List<T> extends React.Component<ListProps<T>, ListState<T>> {
559
563
...restProps
560
564
} = this . props ;
561
565
566
+ const mergedClassName = classNames ( prefixCls , className ) ;
567
+
562
568
// Render pure list if not set height or height is enough for all items
563
569
if ( ! isVirtual ) {
564
570
return (
565
571
< Component
566
572
style = { height ? { ...style , height, ...ScrollStyle } : style }
573
+ className = { mergedClassName }
567
574
{ ...restProps }
568
575
onScroll = { this . onRawScroll }
569
576
ref = { this . listRef }
570
577
>
571
- < Filler height = { height } > { this . renderChildren ( data , 0 , children ) } </ Filler >
578
+ < Filler prefixCls = { prefixCls } height = { height } >
579
+ { this . renderChildren ( data , 0 , children ) }
580
+ </ Filler >
572
581
</ Component >
573
582
) ;
574
583
}
@@ -584,8 +593,18 @@ class List<T> extends React.Component<ListProps<T>, ListState<T>> {
584
593
const contentHeight = itemCount * itemHeight * ITEM_SCALE_RATE ;
585
594
586
595
return (
587
- < Component style = { mergedStyle } { ...restProps } onScroll = { this . onScroll } ref = { this . listRef } >
588
- < Filler height = { contentHeight } offset = { status === 'MEASURE_DONE' ? startItemTop : 0 } >
596
+ < Component
597
+ style = { mergedStyle }
598
+ className = { mergedClassName }
599
+ { ...restProps }
600
+ onScroll = { this . onScroll }
601
+ ref = { this . listRef }
602
+ >
603
+ < Filler
604
+ prefixCls = { prefixCls }
605
+ height = { contentHeight }
606
+ offset = { status === 'MEASURE_DONE' ? startItemTop : 0 }
607
+ >
589
608
{ this . renderChildren ( data . slice ( startIndex , endIndex + 1 ) , startIndex , children ) }
590
609
</ Filler >
591
610
</ Component >
0 commit comments