{"version":3,"file":"primeng-rating.mjs","sources":["../../src/app/components/rating/rating.ts","../../src/app/components/rating/primeng-rating.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, EventEmitter, forwardRef, Input, NgModule, OnInit, Output, QueryList, TemplateRef, ViewEncapsulation } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { LicenseManager, PrimeTemplate, SharedModule } from 'primeng/api';\nimport { BanIcon } from 'primeng/icons/ban';\nimport { StarIcon } from 'primeng/icons/star';\nimport { StarFillIcon } from 'primeng/icons/starfill';\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 \n \n \n \n \n = value\">\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n `,\n providers: [RATING_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./rating.css'],\n host: {\n class: 'p-element'\n }\n})\nexport class Rating implements OnInit, ControlValueAccessor, AfterViewInit {\n @ContentChildren(PrimeTemplate) templates: QueryList;\n\n onIconTemplate: TemplateRef;\n\n offIconTemplate: TemplateRef;\n\n cancelIconTemplate: TemplateRef;\n\n @Input() isCustomCancelIcon: boolean = true;\n\n @Input() index: number;\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;\n\n @Input() iconOnStyle: any;\n\n @Input() iconOffClass: string;\n\n @Input() iconOffStyle: any;\n\n @Input() iconCancelClass: string;\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 ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch (item.getType()) {\n case 'onicon':\n this.onIconTemplate = item.template;\n break;\n\n case 'officon':\n this.offIconTemplate = item.template;\n break;\n\n case 'cancelicon':\n this.cancelIconTemplate = item.template;\n break;\n }\n });\n }\n\n ngAfterViewInit() {\n LicenseManager.check();\n }\n\n getIconTemplate(i: number): TemplateRef {\n return !this.value || i >= this.value ? this.offIconTemplate : this.onIconTemplate;\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 get isCustomIcon(): boolean {\n return this.templates && this.templates.length > 0;\n }\n}\n\n@NgModule({\n imports: [CommonModule, StarFillIcon, StarIcon, BanIcon],\n exports: [Rating, SharedModule],\n declarations: [Rating]\n})\nexport class RatingModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;;AAQa,MAAA,qBAAqB,GAAQ;AACtC,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,MAAM,CAAC;AACrC,IAAA,KAAK,EAAE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