import { Component , HostBinding , Input , ContentChild , TemplateRef , ElementRef , ViewEncapsulation } from '@angular/core' ; import { ThyTranslate , UpdateHostClassService } from 'ngx-tethys/core' ; export type InputGroupSize = 'sm' | 'lg' | '' ; const inputGroupSizeMap = { sm : [ 'input-group-sm' ] , lg : [ 'input-group-lg' ] } ; @ Component ( { selector : 'thy-input-group' , templateUrl : './input-group.component.html' , providers : [ UpdateHostClassService ] , encapsulation : ViewEncapsulation . None } ) export class ThyInputGroupComponent { public appendText : string ; public prependText : string ; @ HostBinding ( 'class.thy-input-group' ) _isInputGroup = true ; @ Input ( ) set thyAppendText ( value ) { this . appendText = value ; } @ Input ( ) set thyAppendTextTranslateKey ( value ) { if ( value ) { this . appendText = this . thyTranslate . instant ( value ) ; } } @ Input ( ) set thyPrependText ( value ) { this . prependText = value ; } @ Input ( ) set thyPrependTextTranslateKey ( value ) { if ( value ) { this . prependText = this . thyTranslate . instant ( value ) ; } } @ Input ( ) set thySize ( size ) { if ( size && inputGroupSizeMap [ size ] ) { this . updateHostClassService . updateClass ( inputGroupSizeMap [ size ] ) ; } else { this . updateHostClassService . updateClass ( [ ] ) ; } } @ ContentChild ( 'append' ) appendTemplate : TemplateRef < any > ; @ ContentChild ( 'prepend' ) prependTemplate : TemplateRef < any > ; constructor ( private thyTranslate , private updateHostClassService , private elementRef ) { this . updateHostClassService . initializeElement ( elementRef . nativeElement ) ; } }