{"version":3,"sources":["../../src/app/components/tristatecheckbox/tristatecheckbox.ts"],"names":["TRISTATECHECKBOX_VALUE_ACCESSOR","provide","NG_VALUE_ACCESSOR","useExisting","forwardRef","TriStateCheckbox","multi","cd","this","onChange","EventEmitter","onModelChange","onModelTouched","prototype","onClick","event","input","disabled","readonly","toggle","focused","focus","onKeydown","keyCode","preventDefault","onKeyup","value","undefined","emit","originalEvent","onFocus","onBlur","registerOnChange","fn","registerOnTouched","writeValue","markForCheck","setDisabledState","Component","args","selector","template","providers","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ChangeDetectorRef","Input","Output","NgModule","imports","CommonModule","exports","declarations"],"mappings":"ieAIaA,EAAuC,CAClDC,QAASC,EAAAA,kBACTC,YAAaC,EAAAA,YAAW,WAAM,OAAAC,KAC9BC,OAAO,gBAyBL,SAAAD,EAAoBE,GAAAC,KAAAD,GAAAA,EAoBVC,KAAAC,SAA8B,IAAIC,EAAAA,aAM5CF,KAAAG,cAA0B,aAE1BH,KAAAI,eAA2B,oBAE3BP,EAAAQ,UAAAC,QAAA,SAAQC,EAAcC,GACbR,KAAKS,UAAaT,KAAKU,WACxBV,KAAKW,OAAOJ,GACZP,KAAKY,SAAU,EACfJ,EAAMK,UAIdhB,EAAAQ,UAAAS,UAAA,SAAUP,GACe,IAAjBA,EAAMQ,SACNR,EAAMS,kBAIdnB,EAAAQ,UAAAY,QAAA,SAAQV,GACiB,IAAjBA,EAAMQ,SAAkBf,KAAKU,WAC7BV,KAAKW,OAAOJ,GACZA,EAAMS,mBAIdnB,EAAAQ,UAAAM,OAAA,SAAOJ,GACe,MAAdP,KAAKkB,OAA+BC,MAAdnB,KAAKkB,MAC3BlB,KAAKkB,OAAQ,EACM,GAAdlB,KAAKkB,MACVlB,KAAKkB,OAAQ,EACM,GAAdlB,KAAKkB,QACVlB,KAAKkB,MAAQ,MAEjBlB,KAAKG,cAAcH,KAAKkB,OACxBlB,KAAKC,SAASmB,KAAK,CACfC,cAAed,EACfW,MAAOlB,KAAKkB,SAIpBrB,EAAAQ,UAAAiB,QAAA,WACItB,KAAKY,SAAU,GAGnBf,EAAAQ,UAAAkB,OAAA,WACIvB,KAAKY,SAAU,EACfZ,KAAKI,kBAGTP,EAAAQ,UAAAmB,iBAAA,SAAiBC,GACbzB,KAAKG,cAAgBsB,GAGzB5B,EAAAQ,UAAAqB,kBAAA,SAAkBD,GACdzB,KAAKI,eAAiBqB,GAG1B5B,EAAAQ,UAAAsB,WAAA,SAAWT,GACPlB,KAAKkB,MAAQA,EACblB,KAAKD,GAAG6B,gBAGZ/B,EAAAQ,UAAAwB,iBAAA,SAAiBpB,GACbT,KAAKS,SAAWA,EAChBT,KAAKD,GAAG6B,yCAhHfE,EAAAA,UAASC,KAAA,CAAC,CACPC,SAAU,qBACVC,SAAU,urCAcVC,UAAW,CAAC1C,GACZ2C,gBAAiBC,EAAAA,wBAAwBC,OACzCC,cAAeC,EAAAA,kBAAkBC,kDA5B2BC,EAAAA,uDAkC3DC,EAAAA,oBAEAA,EAAAA,8BAEAA,EAAAA,wBAEAA,EAAAA,uBAEAA,EAAAA,qBAEAA,EAAAA,0BAEAA,EAAAA,qBAEAA,EAAAA,wBAEAA,EAAAA,wBAEAC,EAAAA,gBA+EL,iCALCC,EAAAA,SAAQb,KAAA,CAAC,CACNc,QAAS,CAACC,EAAAA,cACVC,QAAS,CAAClD,GACVmD,aAAc,CAACnD","sourcesContent":["import {NgModule,Component,Input,Output,EventEmitter,forwardRef,ChangeDetectorRef,ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';\n\nexport const TRISTATECHECKBOX_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => TriStateCheckbox),\n multi: true\n};\n\n@Component({\n selector: 'p-triStateCheckbox',\n template: `\n
\n
\n \n
\n
\n \n
\n
\n \n `,\n providers: [TRISTATECHECKBOX_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None\n})\nexport class TriStateCheckbox implements ControlValueAccessor {\n\n constructor(private cd: ChangeDetectorRef) {}\n\n @Input() disabled: boolean;\n\n @Input() name: 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() label: string;\n\n @Input() readonly: boolean;\n\n @Output() onChange: EventEmitter = new EventEmitter();\n\n focused: boolean;\n\n value: any;\n\n onModelChange: Function = () => {};\n\n onModelTouched: Function = () => {};\n\n onClick(event: Event, input: HTMLInputElement) {\n if (!this.disabled && !this.readonly) {\n this.toggle(event);\n this.focused = true;\n input.focus();\n }\n }\n\n onKeydown(event: KeyboardEvent) {\n if (event.keyCode == 32) {\n event.preventDefault();\n }\n }\n\n onKeyup(event: KeyboardEvent) {\n if (event.keyCode == 32 && !this.readonly) {\n this.toggle(event);\n event.preventDefault();\n }\n }\n\n toggle(event: Event) {\n if (this.value == null || this.value == undefined)\n this.value = true;\n else if (this.value == true)\n this.value = false;\n else if (this.value == false)\n this.value = null;\n\n this.onModelChange(this.value);\n this.onChange.emit({\n originalEvent: event,\n value: this.value\n })\n }\n\n onFocus() {\n this.focused = true;\n }\n\n onBlur() {\n this.focused = false;\n this.onModelTouched();\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 writeValue(value: any) : void {\n this.value = value;\n this.cd.markForCheck();\n }\n\n setDisabledState(disabled: boolean): void {\n this.disabled = disabled;\n this.cd.markForCheck();\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [TriStateCheckbox],\n declarations: [TriStateCheckbox]\n})\nexport class TriStateCheckboxModule { }\n"]}