{"version":3,"sources":["../../src/app/components/inputswitch/inputswitch.ts"],"names":["INPUTSWITCH_VALUE_ACCESSOR","provide","NG_VALUE_ACCESSOR","useExisting","forwardRef","InputSwitch","multi","cd","this","onChange","EventEmitter","checked","focused","onModelChange","onModelTouched","prototype","onClick","event","cb","disabled","readonly","preventDefault","toggle","focus","onInputChange","inputChecked","target","updateModel","value","emit","originalEvent","onFocus","onBlur","writeValue","markForCheck","registerOnChange","fn","registerOnTouched","setDisabledState","val","Component","args","selector","template","providers","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ChangeDetectorRef","Input","Output","NgModule","imports","CommonModule","exports","declarations"],"mappings":"udAIaA,EAAkC,CAC7CC,QAASC,EAAAA,kBACTC,YAAaC,EAAAA,YAAW,WAAM,OAAAC,KAC9BC,OAAO,gBAgDL,SAAAD,EAAoBE,GAAAC,KAAAD,GAAAA,EAVVC,KAAAC,SAA8B,IAAIC,EAAAA,aAE5CF,KAAAG,SAAmB,EAEnBH,KAAAI,SAAmB,EAEnBJ,KAAAK,cAA0B,aAE1BL,KAAAM,eAA2B,oBAI3BT,EAAAU,UAAAC,QAAA,SAAQC,EAAcC,GACbV,KAAKW,UAAaX,KAAKY,WACxBH,EAAMI,iBACNb,KAAKc,OAAOL,GACZC,EAAGK,UAIXlB,EAAAU,UAAAS,cAAA,SAAcP,GACV,IAAKT,KAAKY,SAAU,CAChB,IAAMK,EAAmCR,EAAMS,OAAQf,QACvDH,KAAKmB,YAAYV,EAAOQ,KAIhCpB,EAAAU,UAAAO,OAAA,SAAOL,GACHT,KAAKmB,YAAYV,GAAQT,KAAKG,UAGlCN,EAAAU,UAAAY,YAAA,SAAYV,EAAcW,GACtBpB,KAAKG,QAAUiB,EACfpB,KAAKK,cAAcL,KAAKG,SACxBH,KAAKC,SAASoB,KAAK,CACfC,cAAeb,EACfN,QAASH,KAAKG,WAItBN,EAAAU,UAAAgB,QAAA,SAAQd,GACJT,KAAKI,SAAU,GAGnBP,EAAAU,UAAAiB,OAAA,SAAOf,GACHT,KAAKI,SAAU,EACfJ,KAAKM,kBAGTT,EAAAU,UAAAkB,WAAA,SAAWtB,GACPH,KAAKG,QAAUA,EACfH,KAAKD,GAAG2B,gBAGZ7B,EAAAU,UAAAoB,iBAAA,SAAiBC,GACb5B,KAAKK,cAAgBuB,GAGzB/B,EAAAU,UAAAsB,kBAAA,SAAkBD,GACd5B,KAAKM,eAAiBsB,GAG1B/B,EAAAU,UAAAuB,iBAAA,SAAiBC,GACb/B,KAAKW,SAAWoB,EAChB/B,KAAKD,GAAG2B,yCAnGfM,EAAAA,UAASC,KAAA,CAAC,CACPC,SAAU,gBACVC,SAAU,ktBAUVC,UAAW,CAAC5C,GACZ6C,gBAAiBC,EAAAA,wBAAwBC,OACzCC,cAAeC,EAAAA,kBAAkBC,0UAxB2BC,EAAAA,oDA6B3DC,EAAAA,0BAEAA,EAAAA,wBAEAA,EAAAA,uBAEAA,EAAAA,oBAEAA,EAAAA,wBAEAA,EAAAA,wBAEAA,EAAAA,8BAEAA,EAAAA,wBAEAC,EAAAA,gBAyEL,iCALCC,EAAAA,SAAQb,KAAA,CAAC,CACNc,QAAS,CAACC,EAAAA,cACVC,QAAS,CAACpD,GACVqD,aAAc,CAACrD","sourcesContent":["import {NgModule,Component,Input,forwardRef,EventEmitter,Output,ChangeDetectorRef,ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {NG_VALUE_ACCESSOR,ControlValueAccessor} from '@angular/forms';\n\nexport const INPUTSWITCH_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => InputSwitch),\n multi: true\n};\n\n@Component({\n selector: 'p-inputSwitch',\n template: `\n
\n
\n \n
\n \n
\n `,\n providers: [INPUTSWITCH_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./inputswitch.css']\n})\nexport class InputSwitch implements ControlValueAccessor {\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() tabindex: number;\n\n @Input() inputId: string;\n\n @Input() name: string;\n\n @Input() disabled: boolean;\n\n @Input() readonly: boolean;\n\n @Input() ariaLabelledBy: string;\n \n @Output() onChange: EventEmitter = new EventEmitter();\n\n checked: boolean = false;\n\n focused: boolean = false;\n\n onModelChange: Function = () => {};\n\n onModelTouched: Function = () => {};\n\n constructor(private cd: ChangeDetectorRef) {}\n\n onClick(event: Event, cb: HTMLInputElement) {\n if (!this.disabled && !this.readonly) {\n event.preventDefault();\n this.toggle(event);\n cb.focus();\n }\n }\n\n onInputChange(event: Event) {\n if (!this.readonly) {\n const inputChecked = ( event.target).checked;\n this.updateModel(event, inputChecked);\n }\n }\n\n toggle(event: Event) {\n this.updateModel(event, !this.checked);\n }\n\n updateModel(event: Event, value: boolean) {\n this.checked = value;\n this.onModelChange(this.checked);\n this.onChange.emit({\n originalEvent: event,\n checked: this.checked\n });\n }\n\n onFocus(event: Event) {\n this.focused = true;\n }\n\n onBlur(event: Event) {\n this.focused = false;\n this.onModelTouched();\n }\n\n writeValue(checked: any) : void {\n this.checked = checked;\n this.cd.markForCheck();\n }\n\n registerOnChange(fn: Function): void {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: Function): void {\n this.onModelTouched = fn;\n }\n \n setDisabledState(val: boolean): void {\n this.disabled = val;\n this.cd.markForCheck();\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [InputSwitch],\n declarations: [InputSwitch]\n})\nexport class InputSwitchModule { }\n"]}