{"version":3,"sources":["../../src/app/components/badge/badge.ts"],"names":["BadgeDirective","el","this","iconPos","prototype","ngAfterViewInit","id","UniqueComponentId","nativeElement","nodeName","indexOf","firstChild","badge","document","createElement","className","severity","DomHandler","addClass","value","appendChild","createTextNode","String","length","initialized","Object","defineProperty","_value","val","getElementById","hasClass","removeClass","innerHTML","ngOnDestroy","Directive","args","selector","ElementRef","Input","Badge","containerClass","p-badge p-component","p-badge-no-gutter","p-badge-lg","size","p-badge-xl","p-badge-info","p-badge-success","p-badge-warning","p-badge-danger","Component","template","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","NgModule","imports","CommonModule","exports","SharedModule","declarations"],"mappings":"qkBAmBI,SAAAA,EAAmBC,GAAAC,KAAAD,GAAAA,EARVC,KAAAC,QAA+C,cAUxDH,EAAAI,UAAAC,gBAAA,WACIH,KAAKI,GAAKC,EAAAA,oBAAsB,SAChC,IAAIN,GAAqD,GAAhDC,KAAKD,GAAGO,cAAcC,SAASC,QAAQ,KAAaR,KAAKD,GAAGO,cAAcG,WAAaT,KAAKD,GAAGO,cAEpGI,EAAQC,SAASC,cAAc,QACnCF,EAAMN,GAAKJ,KAAKI,GAChBM,EAAMG,UAAY,sBAEdb,KAAKc,UACLC,EAAAA,WAAWC,SAASN,EAAO,WAAaV,KAAKc,UAG/B,MAAdd,KAAKiB,OACLP,EAAMQ,YAAYP,SAASQ,eAAenB,KAAKiB,QAEb,IAA9BG,OAAOpB,KAAKiB,OAAOI,QACnBN,EAAAA,WAAWC,SAASN,EAAO,sBAI/BK,EAAAA,WAAWC,SAASN,EAAO,eAG/BK,EAAAA,WAAWC,SAASjB,EAAI,mBACxBA,EAAGmB,YAAYR,GAEfV,KAAKsB,aAAc,GAGvBC,OAAAC,eAAa1B,EAAAI,UAAA,QAAK,KAAlB,WACI,OAAOF,KAAKyB,YAGhB,SAAUC,GACN,GAAIA,IAAQ1B,KAAKyB,SACbzB,KAAKyB,OAASC,EAEV1B,KAAKsB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AA,cACjCC,aAAc,CAACxB,EAAOvC","sourcesContent":["import { NgModule, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, QueryList, ContentChildren, TemplateRef, Directive, OnDestroy, AfterViewInit, ElementRef } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { SharedModule } from 'primeng/api';\nimport { DomHandler } from 'primeng/dom';\nimport { UniqueComponentId } from 'primeng/utils';\n\n@Directive({\n selector: '[pBadge]'\n})\nexport class BadgeDirective implements AfterViewInit, OnDestroy {\n\n @Input() iconPos: 'left' | 'right' | 'top' | 'bottom' = 'left';\n \n public _value: string;\n \n public initialized: boolean;\n\n private id: string;\n \n constructor(public el: ElementRef) {}\n \n ngAfterViewInit() {\n this.id = UniqueComponentId() + '_badge';\n let el = this.el.nativeElement.nodeName.indexOf(\"-\") != -1 ? this.el.nativeElement.firstChild : this.el.nativeElement; \n\n let badge = document.createElement('span');\n badge.id = this.id ;\n badge.className = 'p-badge p-component';\n\n if (this.severity) {\n DomHandler.addClass(badge, 'p-badge-' + this.severity);\n }\n \n if (this.value != null) {\n badge.appendChild(document.createTextNode(this.value));\n \n if (String(this.value).length === 1) {\n DomHandler.addClass(badge, 'p-badge-no-gutter');\n }\n }\n else {\n DomHandler.addClass(badge, 'p-badge-dot');\n }\n\n DomHandler.addClass(el, 'p-overlay-badge');\n el.appendChild(badge);\n\n this.initialized = true;\n }\n\n @Input() get value(): string {\n return this._value;\n }\n\n set value(val: string) {\n if (val !== this._value) {\n this._value = val;\n\n if (this.initialized) {\n let badge = document.getElementById(this.id);\n\n if (this._value) {\n if (DomHandler.hasClass(badge, 'p-badge-dot'))\n DomHandler.removeClass(badge, 'p-badge-dot');\n\n if (String(this._value).length === 1) {\n DomHandler.addClass(badge, 'p-badge-no-gutter');\n }\n else {\n DomHandler.removeClass(badge, 'p-badge-no-gutter');\n }\n }\n else if (!this._value && !DomHandler.hasClass(badge, 'p-badge-dot')) {\n DomHandler.addClass(badge, 'p-badge-dot');\n }\n\n badge.innerHTML = '';\n badge.appendChild(document.createTextNode(this._value));\n }\n }\n }\n\n @Input() severity: string;\n \n ngOnDestroy() {\n this.initialized = false;\n }\n}\n\n@Component({\n selector: 'p-badge',\n template: `\n \n {{value}}\n \n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./badge.css']\n})\nexport class Badge {\n\n @Input() styleClass: string;\n\n @Input() style: any;\n\n @Input() size: string;\n \n @Input() severity: string;\n \n @Input() value: string;\n \n containerClass() {\n return {\n 'p-badge p-component': true,\n 'p-badge-no-gutter': this.value && String(this.value).length === 1,\n 'p-badge-lg': this.size === 'large',\n 'p-badge-xl': this.size === 'xlarge',\n 'p-badge-info': this.severity === 'info',\n 'p-badge-success': this.severity === 'success',\n 'p-badge-warning': this.severity === 'warning',\n 'p-badge-danger': this.severity === 'danger'\n };\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Badge, BadgeDirective, SharedModule],\n declarations: [Badge, BadgeDirective]\n})\nexport class BadgeModule { }\n"]}