{"version":3,"file":"primeng-rating.umd.js","sources":["../../src/app/components/rating/rating.ts","../../src/app/components/rating/primeng-rating.ts"],"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 { }","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["NG_VALUE_ACCESSOR","forwardRef","EventEmitter","Component","ChangeDetectionStrategy","ViewEncapsulation","ChangeDetectorRef","Input","Output","NgModule","CommonModule"],"mappings":";;;;;;QAIa,qBAAqB,GAAQ;QACxC,OAAO,EAAEA,uBAAiB;QAC1B,WAAW,EAAEC,eAAU,CAAC,cAAM,OAAA,MAAM,GAAA,CAAC;QACrC,KAAK,EAAE,IAAI;MACX;;QA2CE,gBAAoB,EAAqB;YAArB,OAAE,GAAF,EAAE,CAAmB;YApBhC,UAAK,GAAW,CAAC,CAAC;YAElB,WAAM,GAAY,IAAI,CAAC;YAEvB,gBAAW,GAAW,YAAY,CAAC;YAInC,iBAAY,GAAW,cAAc,CAAC;YAItC,oBAAe,GAAW,WAAW,CAAC;YAIrC,WAAM,GAAsB,IAAIC,iBAAY,EAAE,CAAC;YAE/C,aAAQ,GAAsB,IAAIA,iBAAY,EAAE,CAAC;YAM3D,kBAAa,GAAa,eAAQ,CAAC;YAEnC,mBAAc,GAAa,eAAQ,CAAC;SANS;QAU7C,yBAAQ,GAAR;YACI,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;YACrB,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;gBAChC,IAAI,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