@@ -36,59 +36,7 @@ export class SearchChange {
3636 */
3737@Component ( {
3838 selector : "ibm-search" ,
39- template : `
40- <div
41- class="bx--search"
42- [ngClass]="{
43- 'bx--search--sm': size === 'sm',
44- 'bx--search--xl': size === 'xl',
45- 'bx--search--light': theme === 'light',
46- 'bx--skeleton': skeleton,
47- 'bx--toolbar-search': toolbar,
48- 'bx--toolbar-search--active': toolbar && active
49- }"
50- role="search">
51- <label class="bx--label" [for]="id">{{label}}</label>
52-
53- <div *ngIf="skeleton; else enableInput" class="bx--search-input"></div>
54- <ng-template #enableInput>
55- <input
56- #input
57- *ngIf="!toolbar || active"
58- class="bx--search-input"
59- type="text"
60- role="search"
61- [id]="id"
62- [value]="value"
63- [placeholder]="placeholder"
64- [disabled]="disabled"
65- [required]="required"
66- (input)="onSearch($event.target.value)"/>
67- <button
68- *ngIf="toolbar; else svg"
69- class="bx--toolbar-search__btn"
70- [attr.aria-label]="i18n.get('SEARCH.TOOLBAR_SEARCH') | async"
71- tabindex="0"
72- (click)="openSearch($event)">
73- <ng-template [ngTemplateOutlet]="svg"></ng-template>
74- </button>
75- <ng-template #svg>
76- <ibm-icon-search16 class="bx--search-magnifier"></ibm-icon-search16>
77- </ng-template>
78- </ng-template>
79-
80- <button
81- class="bx--search-close"
82- [ngClass]="{
83- 'bx--search-close--hidden': !value || value.length === 0
84- }"
85- [title]="clearButtonTitle"
86- [attr.aria-label]="clearButtonTitle"
87- (click)="clearSearch()">
88- <ibm-icon-close16></ibm-icon-close16>
89- </button>
90- </div>
91- ` ,
39+ templateUrl : "search.component.html" ,
9240 providers : [
9341 {
9442 provide : NG_VALUE_ACCESSOR ,
@@ -103,7 +51,7 @@ export class Search implements ControlValueAccessor {
10351 */
10452 static searchCount = 0 ;
10553
106- @HostBinding ( "class.bx--form-item" ) containerClass = true ;
54+ @HostBinding ( "class.bx--form-item" ) get containerClass ( ) { return ! this . toolbar ; }
10755
10856 /**
10957 * `light` or `dark` search theme.
@@ -139,6 +87,10 @@ export class Search implements ControlValueAccessor {
13987 * Set to `true` to expand the toolbar search component.
14088 */
14189 @Input ( ) active = false ;
90+ /**
91+ * Specifies whether the search component is used in the table toolbar.
92+ */
93+ @Input ( ) tableSearch = false ;
14294 /**
14395 * Sets the name attribute on the `input` element.
14496 */
@@ -263,7 +215,9 @@ export class Search implements ControlValueAccessor {
263215
264216 @HostListener ( "focusout" , [ "$event" ] )
265217 focusOut ( event ) {
266- if ( this . toolbar && event . relatedTarget === null ) {
218+ if ( this . toolbar &&
219+ this . inputRef . nativeElement . value === "" &&
220+ event . relatedTarget === null ) {
267221 this . active = false ;
268222 }
269223 }
0 commit comments