@@ -36,9 +36,10 @@ import {
36
36
import { ErrorStateMatcher , _ErrorStateTracker } from '@angular/material/core' ;
37
37
import { MAT_FORM_FIELD , MatFormField , MatFormFieldControl } from '@angular/material/form-field' ;
38
38
import { NgSelectComponent , NgSelectModule } from '@ng-select/ng-select' ;
39
- import { Subject , merge } from 'rxjs' ;
39
+ import { Subject , Subscription , merge } from 'rxjs' ;
40
40
import { startWith , takeUntil } from 'rxjs/operators' ;
41
41
import { MtxOption } from './option' ;
42
+ import { MtxSelectIntl } from './select-intl' ;
42
43
import {
43
44
MtxSelectFooterTemplate ,
44
45
MtxSelectHeaderTemplate ,
@@ -159,13 +160,13 @@ export class MtxSelect
159
160
mtxOptions ! : QueryList < MtxOption > ;
160
161
161
162
@Input ( ) addTag : boolean | AddTagFn = false ;
162
- @Input ( ) addTagText = this . _defaultOptions ?. addTagText ?? 'Add item' ;
163
+ @Input ( ) addTagText ?: string ;
163
164
@Input ( ) appearance = 'underline' ;
164
165
@Input ( ) appendTo = this . _defaultOptions ?. appendTo ?? 'body' ;
165
166
@Input ( ) bindLabel = this . _defaultOptions ?. bindLabel ;
166
167
@Input ( ) bindValue = this . _defaultOptions ?. bindValue ;
167
168
@Input ( { transform : booleanAttribute } ) closeOnSelect = true ;
168
- @Input ( ) clearAllText = this . _defaultOptions ?. clearAllText ?? 'Clear all' ;
169
+ @Input ( ) clearAllText ?: string ;
169
170
@Input ( { transform : booleanAttribute } ) clearable = true ;
170
171
@Input ( { transform : booleanAttribute } ) clearOnBackspace = true ;
171
172
@Input ( ) compareWith ! : CompareWithFn ;
@@ -177,12 +178,12 @@ export class MtxSelect
177
178
@Input ( { transform : booleanAttribute } ) selectableGroupAsModel = true ;
178
179
@Input ( { transform : booleanAttribute } ) hideSelected = false ;
179
180
@Input ( { transform : booleanAttribute } ) loading = false ;
180
- @Input ( ) loadingText = this . _defaultOptions ?. loadingText ?? 'Loading...' ;
181
+ @Input ( ) loadingText ?: string ;
181
182
@Input ( ) labelForId : string | null = null ;
182
183
@Input ( { transform : booleanAttribute } ) markFirst = true ;
183
184
@Input ( ) maxSelectedItems ! : number ;
184
185
@Input ( { transform : booleanAttribute } ) multiple = false ;
185
- @Input ( ) notFoundText = this . _defaultOptions ?. notFoundText ?? 'No items found' ;
186
+ @Input ( ) notFoundText ?: string ;
186
187
@Input ( { transform : booleanAttribute } ) searchable = true ;
187
188
@Input ( { transform : booleanAttribute } ) readonly = false ;
188
189
@Input ( ) searchFn : SearchFn | null = null ;
@@ -196,7 +197,7 @@ export class MtxSelect
196
197
@Input ( { transform : booleanAttribute } ) editableSearchTerm = false ;
197
198
@Input ( ) keyDownFn = ( _ : KeyboardEvent ) => true ;
198
199
@Input ( { transform : booleanAttribute } ) virtualScroll = false ;
199
- @Input ( ) typeToSearchText = this . _defaultOptions ?. typeToSearchText ?? 'Type to search' ;
200
+ @Input ( ) typeToSearchText ?: string ;
200
201
@Input ( ) typeahead ! : Subject < string > ;
201
202
@Input ( ) isOpen ?: boolean ;
202
203
@@ -275,7 +276,7 @@ export class MtxSelect
275
276
this . _placeholder = value ;
276
277
this . stateChanges . next ( ) ;
277
278
}
278
- private _placeholder = this . _defaultOptions ?. placeholder ;
279
+ private _placeholder ! : string ;
279
280
280
281
/** Whether the select is focused. */
281
282
get focused ( ) : boolean {
@@ -363,7 +364,10 @@ export class MtxSelect
363
364
this . _errorStateTracker . errorState = value ;
364
365
}
365
366
367
+ private _intlChangesSubscription = Subscription . EMPTY ;
368
+
366
369
constructor (
370
+ protected _intl : MtxSelectIntl ,
367
371
protected _changeDetectorRef : ChangeDetectorRef ,
368
372
protected _elementRef : ElementRef ,
369
373
protected _focusMonitor : FocusMonitor ,
@@ -376,6 +380,10 @@ export class MtxSelect
376
380
@Inject ( MTX_SELECT_DEFAULT_OPTIONS )
377
381
protected _defaultOptions ?: MtxSelectDefaultOptions
378
382
) {
383
+ this . _intlChangesSubscription = this . _intl . changes . subscribe ( ( ) => {
384
+ this . _changeDetectorRef . detectChanges ( ) ;
385
+ } ) ;
386
+
379
387
_focusMonitor . monitor ( this . _elementRef , true ) . subscribe ( origin => {
380
388
if ( this . _focused && ! origin ) {
381
389
this . _onTouched ( ) ;
@@ -443,6 +451,7 @@ export class MtxSelect
443
451
this . _destroy$ . complete ( ) ;
444
452
this . stateChanges . complete ( ) ;
445
453
this . _focusMonitor . stopMonitoring ( this . _elementRef ) ;
454
+ this . _intlChangesSubscription . unsubscribe ( ) ;
446
455
}
447
456
448
457
/** Gets the value for the `aria-labelledby` attribute of the inputs. */
0 commit comments