{"version":3,"file":"primeng-checkbox.js","sources":["../../src/app/components/checkbox/checkbox.ts","../../src/app/components/checkbox/primeng-checkbox.ts"],"sourcesContent":["import {NgModule,Component,Input,Output,EventEmitter,forwardRef,ChangeDetectorRef,ViewChild,ElementRef,ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {NG_VALUE_ACCESSOR, ControlValueAccessor, FormControl} from '@angular/forms';\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 providers: [CHECKBOX_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./checkbox.css']\n})\nexport class Checkbox implements ControlValueAccessor {\n\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() 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 = 'pi pi-check';\n \n @Input() readonly: boolean;\n\n @Input() required: boolean;\n\n @ViewChild('cb') inputViewChild: ElementRef;\n\n @Output() onChange: EventEmitter = new EventEmitter();\n \n model: any;\n \n onModelChange: Function = () => {};\n \n onModelTouched: Function = () => {};\n \n focused: boolean = false;\n \n checked: boolean = false;\n\n constructor(private cd: ChangeDetectorRef) {}\n\n onClick(event,checkbox,focus:boolean) {\n event.preventDefault();\n \n if (this.disabled || this.readonly) {\n return;\n }\n \n this.checked = !this.checked;\n this.updateModel(event);\n \n if (focus) {\n checkbox.focus();\n }\n }\n \n updateModel(event) {\n if (!this.binary) {\n if (this.checked)\n this.addValue();\n else\n this.removeValue();\n\n this.onModelChange(this.model);\n \n if (this.formControl) {\n this.formControl.setValue(this.model);\n }\n }\n else {\n this.onModelChange(this.checked);\n }\n \n this.onChange.emit({checked:this.checked, originalEvent: event});\n }\n \n handleChange(event) {\n if (!this.readonly) {\n this.checked = event.target.checked;\n this.updateModel(event);\n }\n }\n\n isChecked(): boolean {\n if (this.binary)\n return this.model;\n else\n return this.model && this.model.indexOf(this.value) > -1;\n }\n\n removeValue() {\n this.model = this.model.filter(val => val !== this.value);\n }\n\n addValue() {\n if (this.model)\n this.model = [...this.model, this.value];\n else\n this.model = [this.value];\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.checked = this.isChecked();\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: [Checkbox],\n declarations: [Checkbox]\n})\nexport class CheckboxModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;MAIa,uBAAuB,GAAQ;IAC1C,OAAO,EAAE,iBAAiB;IAC1B,WAAW,EAAE,UAAU,CAAC,MAAM,QAAQ,CAAC;IACvC,KAAK,EAAE,IAAI;EACX;MAwBW,QAAQ;IA8CjB,YAAoB,EAAqB;QAArB,OAAE,GAAF,EAAE,CAAmB;QApBhC,iBAAY,GAAW,aAAa,CAAC;QAQpC,aAAQ,GAAsB,IAAI,YAAY,EAAE,CAAC;QAI3D,kBAAa,GAAa,SAAQ,CAAC;QAEnC,mBAAc,GAAa,SAAQ,CAAC;QAEpC,YAAO,GAAY,KAAK,CAAC;QAEzB,YAAO,GAAY,KAAK,CAAC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