{"version":3,"sources":["../../src/app/components/togglebutton/togglebutton.ts"],"names":["TOGGLEBUTTON_VALUE_ACCESSOR","provide","NG_VALUE_ACCESSOR","useExisting","forwardRef","ToggleButton","multi","cd","this","iconPos","onChange","EventEmitter","checked","onModelChange","onModelTouched","prototype","toggle","event","disabled","emit","originalEvent","markForCheck","onBlur","writeValue","value","registerOnChange","fn","registerOnTouched","setDisabledState","val","Object","defineProperty","onLabel","length","Component","args","selector","template","providers","changeDetection","ChangeDetectionStrategy","OnPush","ChangeDetectorRef","Input","Output","NgModule","imports","CommonModule","RippleModule","exports","declarations"],"mappings":"uhBAKaA,EAAmC,CAC9CC,QAASC,EAAAA,kBACTC,YAAaC,EAAAA,YAAW,WAAM,OAAAC,KAC9BC,OAAO,gBAkDL,SAAAD,EAAmBE,GAAAC,KAAAD,GAAAA,EAVVC,KAAAC,QAAkB,OAEjBD,KAAAE,SAA8B,IAAIC,EAAAA,aAE5CH,KAAAI,SAAmB,EAEnBJ,KAAAK,cAA0B,aAE1BL,KAAAM,eAA2B,oBAI3BT,EAAAU,UAAAC,OAAA,SAAOC,GACET,KAAKU,WACNV,KAAKI,SAAWJ,KAAKI,QACrBJ,KAAKK,cAAcL,KAAKI,SACxBJ,KAAKM,iBACLN,KAAKE,SAASS,KAAK,CACfC,cAAeH,EACfL,QAASJ,KAAKI,UAGlBJ,KAAKD,GAAGc,iBAIhBhB,EAAAU,UAAAO,OAAA,WACId,KAAKM,kBAGTT,EAAAU,UAAAQ,WAAA,SAAWC,GACPhB,KAAKI,QAAUY,EACfhB,KAAKD,GAAGc,gBAGZhB,EAAAU,UAAAU,iBAAA,SAAiBC,GACblB,KAAKK,cAAgBa,GAGzBrB,EAAAU,UAAAY,kBAAA,SAAkBD,GACdlB,KAAKM,eAAiBY,GAG1BrB,EAAAU,UAAAa,iBAAA,SAAiBC,GACbrB,KAAKU,SAAWW,EAChBrB,KAAKD,GAAGc,gBAGZS,OAAAC,eAAI1B,EAAAU,UAAA,aAAU,KAAd,WACI,OAAOP,KAAKwB,SAAWxB,KAAKwB,QAAQC,OAAS,mCAGjDH,OAAAC,eAAI1B,EAAAU,UAAA,cAAW,KAAf,WACI,OAAOP,KAAKwB,SAAWxB,KAAKwB,QAAQC,OAAS,4DA1FpDC,EAAAA,UAASC,KAAA,CAAC,CACPC,SAAU,iBACVC,SAAU,40BASVC,UAAW,CAACtC,GACZuC,gBAAiBC,EAAAA,wBAAwBC,g8BAvB2CC,EAAAA,sDA4BnFC,EAAAA,wBAEAA,EAAAA,sBAEAA,EAAAA,uBAEAA,EAAAA,8BAEAA,EAAAA,wBAEAA,EAAAA,qBAEAA,EAAAA,0BAEAA,EAAAA,uBAEAA,EAAAA,wBAEAA,EAAAA,uBAEAA,EAAAA,wBAEAC,EAAAA,gBA4DL,iCALCC,EAAAA,SAAQV,KAAA,CAAC,CACNW,QAAS,CAACC,EAAAA,aAAaC,EAAAA,cACvBC,QAAS,CAAC5C,GACV6C,aAAc,CAAC7C","sourcesContent":["import {NgModule,Component,Input,Output,EventEmitter,forwardRef,ChangeDetectionStrategy,ChangeDetectorRef} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {RippleModule} from 'primeng/ripple';\nimport {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';\n\nexport const TOGGLEBUTTON_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => ToggleButton),\n multi: true\n};\n\n@Component({\n selector: 'p-toggleButton',\n template: `\n
\n \n {{checked ? hasOnLabel ? onLabel : '' : hasOffLabel ? offLabel : ''}}\n
\n `,\n providers: [TOGGLEBUTTON_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n styleUrls: ['../button/button.css']\n})\nexport class ToggleButton implements ControlValueAccessor {\n\n @Input() onLabel: string;\n\n @Input() offLabel: string;\n\n @Input() onIcon: string;\n\n @Input() offIcon: string;\n\n @Input() ariaLabelledBy: string;\n\n @Input() disabled: boolean;\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() inputId: string;\n\n @Input() tabindex: number;\n\n @Input() iconPos: string = 'left';\n\n @Output() onChange: EventEmitter = new EventEmitter();\n \n checked: boolean = false;\n \n onModelChange: Function = () => {};\n \n onModelTouched: Function = () => {};\n \n constructor(public cd: ChangeDetectorRef) { }\n \n toggle(event: Event) {\n if (!this.disabled) {\n this.checked = !this.checked;\n this.onModelChange(this.checked);\n this.onModelTouched();\n this.onChange.emit({\n originalEvent: event,\n checked: this.checked\n });\n\n this.cd.markForCheck();\n }\n }\n \n onBlur() {\n this.onModelTouched();\n }\n \n writeValue(value: any) : void {\n this.checked = value;\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 get hasOnLabel():boolean {\n return this.onLabel && this.onLabel.length > 0;\n }\n \n get hasOffLabel():boolean {\n return this.onLabel && this.onLabel.length > 0;\n }\n}\n\n@NgModule({\n imports: [CommonModule,RippleModule],\n exports: [ToggleButton],\n declarations: [ToggleButton]\n})\nexport class ToggleButtonModule { }\n"]}