File tree Expand file tree Collapse file tree 5 files changed +28
-2
lines changed
td-contents/c-td-truncate Expand file tree Collapse file tree 5 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 5252 < c-nav-horizontal-item
5353 position ="right "
5454 href ="https://github.com/bindable-ui/bindable "
55- title ="v1.11.6 "
55+ title ="v1.11.7 "
5656 > </ c-nav-horizontal-item >
5757 </ c-nav-horizontal >
5858 </ l-box >
Original file line number Diff line number Diff line change 11{
22 "name" : " @bindable-ui/bindable" ,
33 "description" : " An Aurelia component library" ,
4- "version" : " 1.11.6 " ,
4+ "version" : " 1.11.7 " ,
55 "repository" : {
66 "type" : " git" ,
77 "url" : " https://github.com/bindable-ui/bindable"
Original file line number Diff line number Diff line change @@ -71,6 +71,11 @@ export interface CTableCol {
7171 * If you need to highlight a search string in the table (currently only supported on c-td-truncate)
7272 */
7373 getSearchVal ?( ) : string ;
74+
75+ /**
76+ * For custom search queries, pass in the words and phrases in an array that you would like to highlight
77+ */
78+ getSearchPhrases ?( ) : string [ ] ;
7479}
7580
7681export interface CTableActions {
Original file line number Diff line number Diff line change 33Licensed under the terms of the MIT license. See the LICENSE file in the project root for license terms.
44*/
55
6+ import { highlightSearchPhrases } from '../../../../helpers/highlight-phrases' ;
67import { highlightSearchText } from '../../../../helpers/highlight-text' ;
78
89import * as styles from './c-td-truncate.css.json' ;
@@ -23,5 +24,12 @@ export class CTdTruncate {
2324 this . searchHighlight = highlightSearchText ( searchVal , this . value ) ;
2425 }
2526 }
27+
28+ if ( model . col && _ . isFunction ( model . col . getSearchPhrases ) ) {
29+ const searchPhrases = model . col . getSearchPhrases ( ) ;
30+ if ( searchPhrases . length > 0 ) {
31+ this . searchHighlight = highlightSearchPhrases ( searchPhrases , this . value ) ;
32+ }
33+ }
2634 }
2735}
Original file line number Diff line number Diff line change 1+ export const highlightSearchPhrases = ( searchPhrases : string [ ] , matchAgainst ?: string ) : string => {
2+ let title = matchAgainst || '' ;
3+ title = title
4+ . replace ( '&' , '&' )
5+ . replace ( '<' , '<' )
6+ . replace ( '>' , '>' ) ;
7+ if ( searchPhrases && searchPhrases . length > 0 ) {
8+ searchPhrases . forEach ( orig => {
9+ title = title . replace ( orig , `<span style="background-color: #226684;">${ orig } </span>` ) ;
10+ } ) ;
11+ }
12+ return title ;
13+ } ;
You can’t perform that action at this time.
0 commit comments