@@ -4,21 +4,16 @@ import { toArray } from 'lodash';
4
4
import { classNames , cloneElement , Component , OmiProps , tag } from 'omi' ;
5
5
6
6
import { getClassPrefix } from '../_util/classname' ;
7
+ import { convertToLightDomNode } from '../_util/lightDom' ;
7
8
import parseTNode from '../_util/parseTNode' ;
8
9
import { StyledProps } from '../common' ;
9
- import { styleSheet } from './style/index.ts' ;
10
10
import { TdAvatarGroupProps } from './type' ;
11
11
12
- import borderCss from './style/border.less' ;
13
- import offsetLeftCss from './style/offset_left.less' ;
14
- import offsetLeftZIndexCss from './style/offset_left_zIndex.less' ;
15
- import offsetRightCss from './style/offset_right.less' ;
16
-
17
12
export interface AvatarGroupProps extends TdAvatarGroupProps , StyledProps { }
18
13
19
14
@tag ( 't-avatar-group' )
20
15
export default class AvatarGroup extends Component < AvatarGroupProps > {
21
- static css = styleSheet ;
16
+ static css = [ ] ;
22
17
23
18
static defaultProps = { cascading : 'right-up' } ;
24
19
@@ -32,8 +27,6 @@ export default class AvatarGroup extends Component<AvatarGroupProps> {
32
27
33
28
preClass = `${ getClassPrefix ( ) } -avatar` ;
34
29
35
- allChildrenList : any ;
36
-
37
30
provide = { groupSize : undefined as any } ;
38
31
39
32
install ( ) {
@@ -44,21 +37,13 @@ export default class AvatarGroup extends Component<AvatarGroupProps> {
44
37
const { preClass } = this ;
45
38
const { children, max, cascading, collapseAvatar } = props ;
46
39
const childrenList = toArray ( children ) ;
40
+ let allChildrenList = [ ] ;
47
41
if ( childrenList . length > 0 ) {
48
- this . allChildrenList = childrenList . map ( ( child , index ) => {
49
- let childrenCss = borderCss ;
50
- if ( cascading === 'right-up' && index !== childrenList . length - 1 ) {
51
- childrenCss += offsetRightCss ;
52
- } else if ( cascading === 'left-up' && index !== 0 ) {
53
- childrenCss += offsetLeftCss + offsetLeftZIndexCss ;
54
- } else if ( cascading === 'left-up' ) {
55
- childrenCss += offsetLeftZIndexCss ;
56
- }
57
-
58
- return cloneElement ( child , {
42
+ allChildrenList = childrenList . map ( ( child , index ) => {
43
+ const childNode = cloneElement ( child , {
59
44
key : `avatar-group-item-${ index } ` ,
60
- css : childrenCss ,
61
45
} ) ;
46
+ return convertToLightDomNode ( childNode ) ;
62
47
} ) ;
63
48
}
64
49
const groupClass = classNames ( `${ preClass } -group` , this . className , {
@@ -68,17 +53,16 @@ export default class AvatarGroup extends Component<AvatarGroupProps> {
68
53
69
54
const childrenCount = childrenList . length ;
70
55
if ( props . max && childrenCount > max ) {
71
- const showList = this . allChildrenList . slice ( 0 , max ) ;
72
- let childrenCss = borderCss ;
73
- if ( cascading === 'left-up' ) {
74
- childrenCss += offsetLeftCss + offsetLeftZIndexCss ;
75
- }
56
+ const showList = allChildrenList . slice ( 0 , max ) ;
76
57
const ellipsisAvatar = (
77
- < t-avatar css = { childrenCss } > { parseTNode ( collapseAvatar ) || `+${ childrenCount - max } ` } </ t-avatar >
58
+ < t-avatar
59
+ key = { `${ preClass } __collapse` }
60
+ content = { parseTNode ( collapseAvatar ) || `+${ childrenCount - max } ` }
61
+ > </ t-avatar >
78
62
) ;
79
- showList . push ( < div key = "t-avatar__collapse" > { ellipsisAvatar } </ div > ) ;
63
+ showList . push ( convertToLightDomNode ( ellipsisAvatar ) ) ;
80
64
return < div class = { groupClass } > { showList } </ div > ;
81
65
}
82
- return < div class = { groupClass } > { this . allChildrenList } </ div > ;
66
+ return < div class = { groupClass } > { allChildrenList } </ div > ;
83
67
}
84
68
}
0 commit comments