{"version":3,"file":"primeng-togglebutton.mjs","sources":["../../src/app/components/togglebutton/togglebutton.ts","../../src/app/components/togglebutton/primeng-togglebutton.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, forwardRef, Input, NgModule, Output } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { LicenseManager } from 'primeng/api';\nimport { RippleModule } from 'primeng/ripple';\n\ntype ToggleButtonIconPosition = 'left' | 'right';\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 host: {\n class: 'p-element'\n }\n})\nexport class ToggleButton implements ControlValueAccessor, AfterViewInit {\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 ngAfterViewInit() {\n LicenseManager.check();\n }\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":[],"mappings":";;;;;;;;;AAQa,MAAA,2BAA2B,GAAQ;AAC5C,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,YAAY,CAAC;AAC3C,IAAA,KAAK,EAAE,IAAI;EACb;MA2BW,YAAY,CAAA;AA+BrB,IAAA,WAAA,CAAmB,EAAqB,EAAA;AAArB,QAAA,IAAE,CAAA,EAAA,GAAF,EAAE,CAAmB;AAV/B,QAAA,IAAO,CAAA,OAAA,GAAW,MAAM,CAAC;AAExB,QAAA,IAAA,CAAA,QAAQ,GAAsB,IAAI,YAAY,EAAE,CAAC;AAE3D,QAAA,IAAO,CAAA,OAAA,GAAY,KAAK,CAAC;AAEzB,QAAA,IAAA,CAAA,aAAa,GAAa,MAAK,GAAG,CAAC;AAEnC,QAAA,IAAA,CAAA,cAAc,GAAa,MAAK,GAAG,CAAC;KAEQ;IAE5C,eAAe,GAAA;QACX,cAAc,CAAC,KAAK,EAAE,CAAC;KAC1B;AAED,IAAA,MAAM,CAAC,KAAY,EAAA;AACf,QAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;AAChB,YAAA,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;AAC7B,YAAA,IAAI,C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