@@ -15,6 +15,7 @@ import {
15
15
prefixClaName ,
16
16
} from 'mo/common/className' ;
17
17
import TabExtra from './tabExtra' ;
18
+ import { Icon } from '../icon' ;
18
19
19
20
export interface ITabEvent {
20
21
onMoveTab ?: ( dragIndex : number , hoverIndex : number ) => void ;
@@ -29,6 +30,7 @@ export interface ITabProps<T = any, P = any> extends ITabEvent {
29
30
active ?: boolean ;
30
31
closable ?: boolean ;
31
32
editable ?: boolean ;
33
+ icon ?: string | JSX . Element ;
32
34
index ?: number ;
33
35
id ?: string ;
34
36
name ?: string ;
@@ -42,6 +44,7 @@ export const tabItemActiveClassName = getBEMModifier(
42
44
tabItemClassName ,
43
45
'active'
44
46
) ;
47
+ export const tabItemLabelClassName = getBEMElement ( tabItemClassName , 'label' ) ;
45
48
46
49
export function Tab < T > ( props : ITabProps ) {
47
50
const {
@@ -52,6 +55,7 @@ export function Tab<T>(props: ITabProps) {
52
55
data,
53
56
id,
54
57
index,
58
+ icon,
55
59
onCloseTab,
56
60
onMoveTab,
57
61
onSelectTab,
@@ -118,6 +122,11 @@ export function Tab<T>(props: ITabProps) {
118
122
} ) ;
119
123
120
124
drag ( drop ( ref ) ) ;
125
+
126
+ const renderIcon = ( icon : string | JSX . Element ) => {
127
+ return typeof icon === 'string' ? < Icon type = { icon } /> : icon ;
128
+ } ;
129
+
121
130
return (
122
131
< div
123
132
ref = { ref }
@@ -129,6 +138,11 @@ export function Tab<T>(props: ITabProps) {
129
138
onMouseOut = { handleMouseOut }
130
139
onContextMenu = { handleOnContextMenu }
131
140
>
141
+ { icon && (
142
+ < span className = { tabItemLabelClassName } >
143
+ { renderIcon ( icon ) }
144
+ </ span >
145
+ ) }
132
146
{ name }
133
147
{ editable && (
134
148
< TabExtra
0 commit comments