1+ import _ from 'lodash'
12import cx from 'classnames'
23import React , { Component , PropTypes } from 'react'
34
@@ -107,10 +108,7 @@ export default class Label extends Component {
107108 onRemove : PropTypes . func ,
108109
109110 /** Shorthand for Icon to appear as the last child and trigger onRemove. */
110- removeIcon : customPropTypes . every ( [
111- customPropTypes . demand ( [ 'onRemove' ] ) ,
112- customPropTypes . itemShorthand ,
113- ] ) ,
111+ removeIcon : customPropTypes . itemShorthand ,
114112
115113 /** A label can appear as a ribbon attaching itself to an element. */
116114 ribbon : PropTypes . oneOfType ( [
@@ -125,10 +123,6 @@ export default class Label extends Component {
125123 tag : PropTypes . bool ,
126124 }
127125
128- static defaultProps = {
129- removeIcon : 'delete' ,
130- }
131-
132126 static _meta = _meta
133127
134128 static Detail = LabelDetail
@@ -201,13 +195,15 @@ export default class Label extends Component {
201195 return < ElementType { ...rest } className = { classes } onClick = { this . handleClick } > { children } </ ElementType >
202196 }
203197
198+ const removeIconShorthand = _ . isUndefined ( removeIcon ) ? 'delete' : removeIcon
199+
204200 return (
205201 < ElementType className = { classes } onClick = { this . handleClick } { ...rest } >
206202 { Icon . create ( icon ) }
207203 { typeof image !== 'boolean' && Image . create ( image ) }
208204 { content }
209205 { createShorthand ( LabelDetail , val => ( { content : val } ) , detail ) }
210- { onRemove && Icon . create ( removeIcon , { onClick : this . handleRemove } ) }
206+ { onRemove && Icon . create ( removeIconShorthand , { onClick : this . handleRemove } ) }
211207 </ ElementType >
212208 )
213209 }
0 commit comments