@@ -11,10 +11,18 @@ type State = {
1111 expanded : boolean ,
1212} ;
1313
14+ type DefaultProps = {
15+ renderCount : ( count : number ) => string ,
16+ } ;
17+
1418export default class FilterGroup extends Component {
1519 props : FilterGroupProps ;
1620 state : State = { expanded : this . props . initiallyExpanded } ;
1721
22+ static defaultProps : DefaultProps = {
23+ renderCount : ( count : number ) : string => `(${ count } )` ,
24+ }
25+
1826 selectedCount = ( ) => {
1927 const { values = [ ] } = this . props ;
2028 return values . reduce ( ( acc , val ) => {
@@ -26,20 +34,21 @@ export default class FilterGroup extends Component {
2634 toggleExpansion = ( ) => this . setState ( { expanded : ! this . state . expanded } ) ;
2735
2836 render ( ) {
29- const { children, label, term, values } = this . props ;
37+ const { children, label, term, values, renderCount } = this . props ;
3038 const {
3139 onClearFacet = ( ) => { } ,
3240 onSelectFacet = ( ) => { } ,
3341 } = this . props ;
3442 const { expanded } = this . state ;
3543
3644 const updatedChildren = React . Children . map ( children , ( child ) => {
37- return React . cloneElement ( child , { onSelectFacet, term, values } ) ;
45+ return React . cloneElement ( child , { onSelectFacet, term, values, renderCount } ) ;
3846 } ) ;
3947
4048 return (
4149 < div styleName = "group" >
4250 < FilterHeader
51+ renderCount = { renderCount }
4352 count = { this . selectedCount ( ) }
4453 expanded = { expanded }
4554 onClear = { onClearFacet }
0 commit comments