66 HostBinding
77} from "@angular/core" ;
88import { NG_VALUE_ACCESSOR , ControlValueAccessor } from "@angular/forms" ;
9+ import { I18n } from "src/i18n/i18n.module" ;
910
1011/**
1112 * Used to emit changes performed on search components.
@@ -43,7 +44,7 @@ export class SearchChange {
4344 'bx--search--light': theme === 'light'
4445 }"
4546 role="search">
46- <label class="bx--label" [for]="id">Search </label>
47+ <label class="bx--label" [for]="id">{{label}} </label>
4748 <input
4849 class="bx--search-input"
4950 type="text"
@@ -68,8 +69,8 @@ export class SearchChange {
6869 [ngClass]="{
6970 'bx--search-close--hidden': !value || value === 0
7071 }"
71- title="Clear search input "
72- [attr.aria-label]="ariaLabel "
72+ [ title]="clearButtonTitle "
73+ [attr.aria-label]="clearButtonTitle "
7374 (click)="clearSearch()">
7475 <svg
7576 width="16"
@@ -129,28 +130,35 @@ export class Search implements ControlValueAccessor {
129130 */
130131 @Input ( ) value = "" ;
131132 /**
132- * Sets the placeholder attribute on the `input` element .
133+ * Sets the text inside the `label` tag .
133134 */
134- @Input ( ) placeholder = "Search" ;
135+ @Input ( ) label = this . i18n . get ( ) . SEARCH . LABEL ;
135136 /**
136- * Used to set the `aria-label` attribute on the input element.
137+ * Sets the placeholder attribute on the ` input` element.
137138 */
138- // tslint:disable-next-line:no-input-rename
139- @Input ( "aria-label" ) ariaLabel = "Clear search input" ;
139+ @Input ( ) placeholder = this . i18n . get ( ) . SEARCH . PLACEHOLDER ;
140+ /**
141+ * Used to set the `title` attribute of the clear button.
142+ */
143+ @Input ( ) clearButtonTitle = this . i18n . get ( ) . SEARCH . CLEAR_BUTTON ;
140144 /**
141145 * Emits event notifying other classes when a change in state occurs in the input.
142146 */
143147 @Output ( ) change = new EventEmitter < SearchChange > ( ) ;
144148
145149 /**
146150 * Creates an instance of `Search`.
151+ * @param i18n The i18n translations.
147152 * @memberof Search
148153 */
149- constructor ( ) {
154+ constructor ( protected i18n : I18n ) {
150155 Search . searchCount ++ ;
151156 }
152157
153- // this is the initial value set to the component
158+ /**
159+ * This is the initial value set to the component
160+ * @param value The input value.
161+ */
154162 public writeValue ( value : any ) {
155163 this . value = value ;
156164 }
0 commit comments