{"version":3,"file":"primeng-badge.js","sources":["../../src/app/components/badge/badge.ts","../../src/app/components/badge/primeng-badge.ts"],"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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;MASa,cAAc;IAUvB,YAAmB,EAAc;QAAd,OAAE,GAAF,EAAE,CAAY;QARxB,YAAO,GAAwC,MAAM,CAAC;KAQ1B;IAErC,eAAe;QACX,IAAI,CAAC,EAAE,GAAG,iBAAiB,EAAE,GAAG,QAAQ,CAAC;QACzC,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC;QAEtH,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC3C,KAAK,CAAC,EAAE,GA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