{"version":3,"file":"primeng-radiobutton.mjs","sources":["../../src/app/components/radiobutton/radiobutton.ts","../../src/app/components/radiobutton/primeng-radiobutton.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, Injectable, Injector, Input, NgModule, OnDestroy, OnInit, Output, ViewChild, forwardRef } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';\nimport { LicenseManager } from 'primeng/api';\n\nexport const RADIO_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => RadioButton),\n multi: true\n};\n\n@Injectable({\n providedIn: 'root'\n})\nexport class RadioControlRegistry {\n private accessors: any[] = [];\n\n add(control: NgControl, accessor: RadioButton) {\n this.accessors.push([control, accessor]);\n }\n\n remove(accessor: RadioButton) {\n this.accessors = this.accessors.filter((c) => {\n return c[1] !== accessor;\n });\n }\n\n select(accessor: RadioButton) {\n this.accessors.forEach((c) => {\n if (this.isSameGroup(c, accessor) && c[1] !== accessor) {\n c[1].writeValue(accessor.value);\n }\n });\n }\n\n private isSameGroup(controlPair: [NgControl, RadioButton], accessor: RadioButton): boolean {\n if (!controlPair[0].control) {\n return false;\n }\n\n return controlPair[0].control.root === accessor.control.control.root && controlPair[1].name === accessor.name;\n }\n}\n\n@Component({\n selector: 'p-radioButton',\n template: `\n
\n
\n \n
\n
\n \n
\n
\n {{ label }}\n `,\n providers: [RADIO_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'p-element'\n }\n})\nexport class RadioButton implements ControlValueAccessor, OnInit, OnDestroy, AfterViewInit {\n @Input() value: any;\n\n @Input() formControlName: string;\n\n @Input() name: string;\n\n @Input() disabled: boolean;\n\n @Input() label: string;\n\n @Input() tabindex: number;\n\n @Input() inputId: string;\n\n @Input() ariaLabelledBy: string;\n\n @Input() ariaLabel: string;\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() labelStyleClass: string;\n\n @Output() onClick: EventEmitter = new EventEmitter();\n\n @Output() onFocus: EventEmitter = new EventEmitter();\n\n @Output() onBlur: EventEmitter = new EventEmitter();\n\n @ViewChild('rb') inputViewChild: ElementRef;\n\n public onModelChange: Function = () => {};\n\n public onModelTouched: Function = () => {};\n\n public checked: boolean;\n\n public focused: boolean;\n\n control: NgControl;\n\n constructor(public cd: ChangeDetectorRef, private injector: Injector, private registry: RadioControlRegistry) {}\n\n ngOnInit() {\n this.control = this.injector.get(NgControl);\n this.checkName();\n this.registry.add(this.control, this);\n }\n\n ngAfterViewInit() {\n LicenseManager.check();\n }\n\n handleClick(event, radioButton, focus) {\n event.preventDefault();\n\n if (this.disabled) {\n return;\n }\n\n this.select(event);\n\n if (focus) {\n radioButton.focus();\n }\n }\n\n select(event) {\n if (!this.disabled) {\n this.inputViewChild.nativeElement.checked = true;\n this.checked = true;\n this.onModelChange(this.value);\n this.registry.select(this);\n this.onClick.emit({ originalEvent: event, value: this.value });\n }\n }\n\n writeValue(value: any): void {\n this.checked = value == this.value;\n\n if (this.inputViewChild && this.inputViewChild.nativeElement) {\n this.inputViewChild.nativeElement.checked = this.checked;\n }\n\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 onInputFocus(event) {\n this.focused = true;\n this.onFocus.emit(event);\n }\n\n onInputBlur(event) {\n this.focused = false;\n this.onModelTouched();\n this.onBlur.emit(event);\n }\n\n onChange(event) {\n this.select(event);\n }\n\n focus() {\n this.inputViewChild.nativeElement.focus();\n }\n\n ngOnDestroy() {\n this.registry.remove(this);\n }\n\n private checkName() {\n if (this.name && this.formControlName && this.name !== this.formControlName) {\n this.throwNameError();\n }\n if (!this.name && this.formControlName) {\n this.name = this.formControlName;\n }\n }\n\n private throwNameError() {\n throw new Error(`\n If you define both a name and a formControlName attribute on your radio button, their values\n must match. Ex: \n `);\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [RadioButton],\n declarations: [RadioButton]\n})\nexport class RadioButtonModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;AAKa,MAAA,oBAAoB,GAAQ;AACrC,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,WAAW,CAAC;AAC1C,IAAA,KAAK,EAAE,IAAI;EACb;MAKW,oBAAoB,CAAA;AAHjC,IAAA,WAAA,GAAA;AAIY,QAAA,IAAS,CAAA,SAAA,GAAU,EAAE,CAAC;KA2BjC;IAzBG,GAAG,CAAC,OAAkB,EAAE,QAAqB,EAAA;QACzC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;KAC5C;AAED,IAAA,MAAM,CAAC,QAAqB,EAAA;AACxB,QAAA,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,KAAI;AACzC,YAAA,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;AAC7B,SAAC,CAAC,CAAC;KACN;AAED,IAAA,MAAM,CAAC,QAAqB,EAAA;QACxB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,KAAI;AACzB,YAAA,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;gBACpD,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACnC,aAAA;AACL,SAAC,CAAC,CAAC;KACN;IAEO,WAAW,CAAC,WAAqC,EAAE,QAAqB,EAAA;AAC5E,QAAA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