@@ -12,6 +12,7 @@ const {FormControl, FormGroup, Glyphicon, Tooltip} = require('react-bootstrap');
1212const OverlayTrigger = require ( '../../misc/OverlayTrigger' ) ;
1313const LocaleUtils = require ( '../../../utils/LocaleUtils' ) ;
1414const Spinner = require ( 'react-spinkit' ) ;
15+ const assign = require ( 'object-assign' ) ;
1516
1617
1718const delay = (
@@ -36,6 +37,8 @@ require('./searchbar.css');
3637 * @prop {function } onCancelSelectedItem triggered when the user deletes the selected item (by hitting backspace) when text is empty
3738 * @prop {string } placeholder string to use as placeholder when text is empty
3839 * @prop {string } placeholderMsgId msgId for the placeholder. Used if placeholder is not defined
40+ * @prop {string } removeIcon glyphicon used for reset button, default 1-close
41+ * @prop {string } searchIcon glyphicon used for search button, default search
3942 * @prop {number } delay milliseconds after trigger onSearch if typeAhead is true
4043 * @prop {boolean } hideOnBlur if true, it triggers onPurgeResults on blur
4144 * @prop {boolean } typeAhead if true, onSearch is triggered when users change the search text, after `delay` milliseconds
@@ -65,6 +68,8 @@ class SearchBar extends React.Component {
6568 blurResetDelay : PropTypes . number ,
6669 typeAhead : PropTypes . bool ,
6770 searchText : PropTypes . string ,
71+ removeIcon : PropTypes . string ,
72+ searchIcon : PropTypes . string ,
6873 selectedItems : PropTypes . array ,
6974 autoFocusOnSelect : PropTypes . bool ,
7075 splitTools : PropTypes . bool ,
@@ -86,6 +91,8 @@ class SearchBar extends React.Component {
8691 onCancelSelectedItem : ( ) => { } ,
8792 selectedItems : [ ] ,
8893 placeholderMsgId : "search.placeholder" ,
94+ removeIcon : "1-close" ,
95+ searchIcon : "search" ,
8996 delay : 1000 ,
9097 blurResetDelay : 300 ,
9198 autoFocusOnSelect : true ,
@@ -141,23 +148,30 @@ class SearchBar extends React.Component {
141148 }
142149 } ;
143150
151+ getSpinnerStyle = ( ) => {
152+ const nonSplittedStyle = {
153+ right : "19px" ,
154+ top : "7px"
155+ } ;
156+ const splittedStyle = {
157+ right : "16px" ,
158+ top : "12px"
159+ } ;
160+ return assign ( { } , { position : "absolute" } , this . props . splitTools ? { ...splittedStyle } : { ...nonSplittedStyle } ) ;
161+ }
144162 renderAddonBefore = ( ) => {
145163 return this . props . selectedItems && this . props . selectedItems . map ( ( item , index ) =>
146164 < span key = { "selected-item" + index } className = "input-group-addon" > < div className = "selectedItem-text" > { item . text } </ div > </ span >
147165 ) ;
148166 } ;
149167
150168 renderAddonAfter = ( ) => {
151- const remove = < Glyphicon className = "searchclear" glyph = "1-close" onClick = { this . clearSearch } key = "searchbar_remove_glyphicon" /> ;
152- const search = < Glyphicon className = "magnifying-glass" glyph = "search" key = "searchbar_search_glyphicon" onClick = { this . search } /> ;
169+ const remove = < Glyphicon className = "searchclear" glyph = { this . props . removeIcon } onClick = { this . clearSearch } key = "searchbar_remove_glyphicon" /> ;
170+ const search = < Glyphicon className = "magnifying-glass" glyph = { this . props . searchIcon } key = "searchbar_search_glyphicon" onClick = { this . search } /> ;
153171 const showRemove = this . props . searchText !== "" || this . props . selectedItems && this . props . selectedItems . length > 0 ;
154172 let addonAfter = showRemove ? ( this . props . splitTools ? [ remove ] : [ remove , search ] ) : [ search ] ;
155173 if ( this . props . loading ) {
156- addonAfter = [ < Spinner style = { {
157- position : "absolute" ,
158- right : "19px" ,
159- top : "7px"
160- } } spinnerName = "pulse" noFadeIn /> , addonAfter ] ;
174+ addonAfter = [ < Spinner style = { this . getSpinnerStyle ( ) } spinnerName = "pulse" noFadeIn /> , addonAfter ] ;
161175 }
162176 if ( this . props . error ) {
163177 let tooltip = < Tooltip id = "tooltip" > { this . props . error && this . props . error . message || null } </ Tooltip > ;
0 commit comments