{"version":3,"file":"primeng-togglebutton.umd.js","sources":["../../src/app/components/togglebutton/togglebutton.ts","../../src/app/components/togglebutton/primeng-togglebutton.ts"],"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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["NG_VALUE_ACCESSOR","forwardRef","EventEmitter","Component","ChangeDetectionStrategy","ChangeDetectorRef","Input","Output","NgModule","CommonModule","RippleModule"],"mappings":";;;;;;QAKa,2BAA2B,GAAQ;QAC9C,OAAO,EAAEA,uBAAiB;QAC1B,WAAW,EAAEC,eAAU,CAAC,cAAM,OAAA,YAAY,GAAA,CAAC;QAC3C,KAAK,EAAE,IAAI;MACX;;QAiDE,sBAAmB,EAAqB;YAArB,OAAE,GAAF,EAAE,CAAmB;YAV/B,YAAO,GAAW,MAAM,CAAC;YAExB,aAAQ,GAAsB,IAAIC,iBAAY,EAAE,CAAC;YAE3D,YAAO,GAAY,KAAK,CAAC;YAEzB,kBAAa,GAAa,eAAQ,CAAC;YAEnC,mBAAc,GAAa,eAAQ,CAAC;SAES;QAE7C,6BAAM,GAAN,UAAO,KAAY;YACf,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAChB,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;gBAC7B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACjC,IAAI,CAAC,cAAc,EAAE,CAAC;gBACtB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;oBACf,aAAa,EAAE,KAAK;oBACpB,OAAO,EAAE,IAAI,CAAC,OAAO;iBACxB,CAAC,CAAC;gBAEH,IAAI,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC;aAC1B;SACJ;QAED,6BAAM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