{"version":3,"sources":["../../src/app/components/rating/rating.ts"],"names":["RATING_VALUE_ACCESSOR","provide","NG_VALUE_ACCESSOR","useExisting","forwardRef","Rating","multi","cd","this","stars","cancel","iconOnClass","iconOffClass","iconCancelClass","onRate","EventEmitter","onCancel","onModelChange","onModelTouched","prototype","ngOnInit","starsArray","i","rate","event","readonly","disabled","value","emit","originalEvent","preventDefault","clear","writeValue","detectChanges","registerOnChange","fn","registerOnTouched","setDisabledState","val","markForCheck","Component","args","selector","template","providers","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ChangeDetectorRef","Input","Output","NgModule","imports","CommonModule","exports","declarations"],"mappings":"6cAIaA,EAA6B,CACxCC,QAASC,EAAAA,kBACTC,YAAaC,EAAAA,YAAW,WAAM,OAAAC,KAC9BC,OAAO,gBA4CL,SAAAD,EAAoBE,GAAAC,KAAAD,GAAAA,EApBXC,KAAAC,MAAgB,EAEhBD,KAAAE,QAAkB,EAElBF,KAAAG,YAAsB,aAItBH,KAAAI,aAAuB,eAIvBJ,KAAAK,gBAA0B,YAIzBL,KAAAM,OAA4B,IAAIC,EAAAA,aAEhCP,KAAAQ,SAA8B,IAAID,EAAAA,aAM5CP,KAAAS,cAA0B,aAE1BT,KAAAU,eAA2B,oBAI3Bb,EAAAc,UAAAC,SAAA,WACIZ,KAAKa,WAAa,GAClB,IAAI,IAAIC,EAAI,EAAGA,EAAId,KAAKC,MAAOa,IAC3Bd,KAAKa,WAAWC,GAAKA,GAI7BjB,EAAAc,UAAAI,KAAA,SAAKC,EAAOF,GACHd,KAAKiB,UAAWjB,KAAKkB,WACtBlB,KAAKmB,MAASL,EAAI,EAClBd,KAAKS,cAAcT,KAAKmB,OACxBnB,KAAKU,iBACLV,KAAKM,OAAOc,KAAK,CACbC,cAAeL,EACfG,MAAQL,EAAE,KAGlBE,EAAMM,kBAGVzB,EAAAc,UAAAY,MAAA,SAAMP,GACGhB,KAAKiB,UAAWjB,KAAKkB,WACtBlB,KAAKmB,MAAQ,KACbnB,KAAKS,cAAcT,KAAKmB,OACxBnB,KAAKU,iBACLV,KAAKQ,SAASY,KAAKJ,IAEvBA,EAAMM,kBAGVzB,EAAAc,UAAAa,WAAA,SAAWL,GACPnB,KAAKmB,MAAQA,EACbnB,KAAKD,GAAG0B,iBAGZ5B,EAAAc,UAAAe,iBAAA,SAAiBC,GACb3B,KAAKS,cAAgBkB,GAGzB9B,EAAAc,UAAAiB,kBAAA,SAAkBD,GACd3B,KAAKU,eAAiBiB,GAG1B9B,EAAAc,UAAAkB,iBAAA,SAAiBC,GACb9B,KAAKkB,SAAWY,EAChB9B,KAAKD,GAAGgC,yCAhGfC,EAAAA,UAASC,KAAA,CAAC,CACPC,SAAU,WACVC,SAAU,ouBAQVC,UAAW,CAAC5C,GACZ6C,gBAAiBC,EAAAA,wBAAwBC,OACzCC,cAAeC,EAAAA,kBAAkBC,sJAtBkCC,EAAAA,uDA2BlEC,EAAAA,wBAEAA,EAAAA,qBAEAA,EAAAA,sBAEAA,EAAAA,2BAEAA,EAAAA,2BAEAA,EAAAA,4BAEAA,EAAAA,4BAEAA,EAAAA,+BAEAA,EAAAA,+BAEAA,EAAAA,sBAEAC,EAAAA,yBAEAA,EAAAA,gBAkEL,iCALCC,EAAAA,SAAQb,KAAA,CAAC,CACNc,QAAS,CAACC,EAAAA,cACVC,QAAS,CAACpD,GACVqD,aAAc,CAACrD","sourcesContent":["import {NgModule,Component,OnInit,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 RATING_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => Rating),\n multi: true\n};\n\n@Component({\n selector: 'p-rating',\n template: `\n
\n \n = value) ? iconOffClass : iconOnClass\"\n [ngStyle]=\"(!value || i >= value) ? iconOffStyle : iconOnStyle\">\n
\n `,\n providers: [RATING_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./rating.css']\n})\nexport class Rating implements OnInit,ControlValueAccessor {\n\n @Input() disabled: boolean;\n\n @Input() readonly: boolean;\n\n @Input() stars: number = 5;\n\n @Input() cancel: boolean = true;\n\n @Input() iconOnClass: string = 'pi pi-star';\n\n @Input() iconOnStyle: any;\n\n @Input() iconOffClass: string = 'pi pi-star-o';\n\n @Input() iconOffStyle: any;\n\n @Input() iconCancelClass: string = 'pi pi-ban';\n\n @Input() iconCancelStyle: any;\n\n @Output() onRate: EventEmitter = new EventEmitter();\n\n @Output() onCancel: EventEmitter = new EventEmitter();\n\n constructor(private cd: ChangeDetectorRef) {} \n \n value: number;\n \n onModelChange: Function = () => {};\n \n onModelTouched: Function = () => {};\n \n public starsArray: number[];\n \n ngOnInit() {\n this.starsArray = [];\n for(let i = 0; i < this.stars; i++) {\n this.starsArray[i] = i;\n }\n }\n \n rate(event, i: number): void {\n if (!this.readonly&&!this.disabled) {\n this.value = (i + 1);\n this.onModelChange(this.value);\n this.onModelTouched();\n this.onRate.emit({\n originalEvent: event,\n value: (i+1)\n });\n }\n event.preventDefault(); \n }\n \n clear(event): void {\n if (!this.readonly&&!this.disabled) {\n this.value = null;\n this.onModelChange(this.value);\n this.onModelTouched();\n this.onCancel.emit(event);\n }\n event.preventDefault();\n }\n \n writeValue(value: any) : void {\n this.value = value;\n this.cd.detectChanges();\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: [Rating],\n declarations: [Rating]\n})\nexport class RatingModule { }"]}