{"version":3,"file":"primeng-checkbox.mjs","sources":["../../src/app/components/checkbox/checkbox.ts","../../src/app/components/checkbox/primeng-checkbox.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, ElementRef, EventEmitter, forwardRef, Input, NgModule, Output, QueryList, TemplateRef, ViewChild, ViewEncapsulation } from '@angular/core';\nimport { ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { LicenseManager, PrimeTemplate, SharedModule } from 'primeng/api';\nimport { CheckIcon } from 'primeng/icons/check';\nimport { ObjectUtils } from 'primeng/utils';\n\nexport const CHECKBOX_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => Checkbox),\n multi: true\n};\n\n@Component({\n selector: 'p-checkbox',\n template: `\n
\n
\n \n
\n
\n \n \n \n \n \n \n \n \n \n
\n
\n {{ label }}\n `,\n providers: [CHECKBOX_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./checkbox.css'],\n host: {\n class: 'p-element'\n }\n})\nexport class Checkbox implements ControlValueAccessor {\n @Input() value: any;\n\n @Input() name: string;\n\n @Input() disabled: boolean;\n\n @Input() binary: boolean;\n\n @Input() label: string;\n\n @Input() ariaLabelledBy: string;\n\n @Input() ariaLabel: string;\n\n @Input() tabindex: number;\n\n @Input() inputId: string;\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() labelStyleClass: string;\n\n @Input() formControl: FormControl;\n\n @Input() checkboxIcon: string;\n\n @Input() readonly: boolean;\n\n @Input() required: boolean;\n\n @Input() trueValue: any = true;\n\n @Input() falseValue: any = false;\n\n @ViewChild('cb') inputViewChild: ElementRef;\n\n @Output() onChange: EventEmitter = new EventEmitter();\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n\n checkboxIconTemplate: TemplateRef;\n\n model: any;\n\n onModelChange: Function = () => {};\n\n onModelTouched: Function = () => {};\n\n focused: boolean = false;\n\n constructor(public cd: ChangeDetectorRef) {}\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch (item.getType()) {\n case 'icon':\n this.checkboxIconTemplate = item.template;\n break;\n }\n });\n }\n\n ngAfterViewInit() {\n LicenseManager.check();\n }\n\n onClick(event, checkbox, focus: boolean) {\n event.preventDefault();\n\n if (this.disabled || this.readonly) {\n return;\n }\n\n this.updateModel(event);\n\n if (focus) {\n checkbox.focus();\n }\n }\n\n updateModel(event) {\n let newModelValue;\n\n if (!this.binary) {\n if (this.checked()) newModelValue = this.model.filter((val) => !ObjectUtils.equals(val, this.value));\n else newModelValue = this.model ? [...this.model, this.value] : [this.value];\n\n this.onModelChange(newModelValue);\n this.model = newModelValue;\n\n if (this.formControl) {\n this.formControl.setValue(newModelValue);\n }\n } else {\n newModelValue = this.checked() ? this.falseValue : this.trueValue;\n this.model = newModelValue;\n this.onModelChange(newModelValue);\n }\n\n this.onChange.emit({ checked: newModelValue, originalEvent: event });\n }\n\n handleChange(event) {\n if (!this.readonly) {\n this.updateModel(event);\n }\n }\n\n onFocus() {\n this.focused = true;\n }\n\n onBlur() {\n this.focused = false;\n this.onModelTouched();\n }\n\n focus() {\n this.inputViewChild.nativeElement.focus();\n }\n\n writeValue(model: any): void {\n this.model = model;\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.binary ? this.model === this.trueValue : ObjectUtils.contains(this.value, this.model);\n }\n}\n\n@NgModule({\n imports: [CommonModule, CheckIcon],\n exports: [Checkbox, SharedModule],\n declarations: [Checkbox]\n})\nexport class CheckboxModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;AAOa,MA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