{"version":3,"file":"primeng-inputswitch.umd.js","sources":["../../src/app/components/inputswitch/inputswitch.ts","../../src/app/components/inputswitch/primeng-inputswitch.ts"],"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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["NG_VALUE_ACCESSOR","forwardRef","EventEmitter","Component","ChangeDetectionStrategy","ViewEncapsulation","ChangeDetectorRef","Input","Output","NgModule","CommonModule"],"mappings":";;;;;;QAIa,0BAA0B,GAAQ;QAC7C,OAAO,EAAEA,uBAAiB;QAC1B,WAAW,EAAEC,eAAU,CAAC,cAAM,OAAA,WAAW,GAAA,CAAC;QAC1C,KAAK,EAAE,IAAI;MACX;;QA+CE,qBAAoB,EAAqB;YAArB,OAAE,GAAF,EAAE,CAAmB;YAV/B,aAAQ,GAAsB,IAAIC,iBAAY,EAAE,CAAC;YAE3D,YAAO,GAAY,KAAK,CAAC;YAEzB,YAAO,GAAY,KAAK,CAAC;YAEzB,kBAAa,GAAa,eAAQ,CAAC;YAEnC,mBAAc,GAAa,eAAQ,CAAC;SAES;QAE7C,6BAAO,GAAP,UAAQ,KAAY,EAAE,EAAoB;YACtC,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAClC,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACnB,EAAE,CAAC,KAAK,EAAE,CAAC;aACd;SACJ;QAED,mCAAa,GAAb,UAAc,KAAY;YACtB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAChB,IAAM,YAAY,GAAuB,KAAK,CAAC,MAAO,CAAC,OAAO,CAAC;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