{"version":3,"file":"primeng-inputswitch.mjs","sources":["../../src/app/components/inputswitch/inputswitch.ts","../../src/app/components/inputswitch/primeng-inputswitch.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, NgModule, Output, ViewEncapsulation, forwardRef } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { LicenseManager } from 'primeng/api';\n\nexport const INPUTSWITCH_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => InputSwitch),\n multi: true\n};\n\nexport interface InputSwitchOnChangeEvent {\n originalEvent: Event;\n checked: boolean;\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 host: {\n class: 'p-element'\n }\n})\nexport class InputSwitch implements ControlValueAccessor, AfterViewInit {\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() trueValue: any = true;\n\n @Input() falseValue: any = false;\n\n @Input() ariaLabel: string;\n\n @Input() ariaLabelledBy: string;\n\n @Output() onChange: EventEmitter = new EventEmitter();\n\n modelValue: any = false;\n\n focused: boolean = false;\n\n onModelChange: Function = () => {};\n\n onModelTouched: Function = () => {};\n\n constructor(private cd: ChangeDetectorRef) {}\n\n ngAfterViewInit() {\n LicenseManager.check();\n }\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.modelValue = value ? this.trueValue : this.falseValue;\n this.onModelChange(this.modelValue);\n this.onChange.emit({\n originalEvent: event,\n checked: this.modelValue\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(value: any): void {\n this.modelValue = 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 checked() {\n return this.modelValue === this.trueValue;\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":[],"mappings":";;;;;;;AAKa,MAAA,0BAA0B,GAAQ;AAC3C,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,WAAW,CAAC;AAC1C,IAAA,KAAK,EAAE,IAAI;EACb;MAwCW,WAAW,CAAA;AAiCpB,IAAA,WAAA,CAAoB,EAAqB,EAAA;AAArB,QAAA,IAAE,CAAA,EAAA,GAAF,EAAE,CAAmB;AAlBhC,QAAA,IAAS,CAAA,SAAA,GAAQ,IAAI,CAAC;AAEtB,QAAA,IAAU,CAAA,UAAA,GAAQ,KAAK,CAAC;AAMvB,QAAA,IAAA,CAAA,QAAQ,GAA2C,IAAI,YAAY,EAAE,CAAC;AAEhF,QAAA,IAAU,CAAA,UAAA,GAAQ,KAAK,CAAC;AAExB,QAAA,IAAO,CAAA,OAAA,GAAY,KAAK,CAAC;AAEzB,QAAA,IAAA,CAAA,aAAa,GAAa,MAAK,GAAG,CAAC;AAEnC,QAAA,IAAA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