{"version":3,"file":"primeng-badge.umd.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":["UniqueComponentId","DomHandler","Directive","ElementRef","Input","Component","ChangeDetectionStrategy","ViewEncapsulation","NgModule","CommonModule","SharedModule"],"mappings":";;;;;;;QAmBI,wBAAmB,EAAc;YAAd,OAAE,GAAF,EAAE,CAAY;YARxB,YAAO,GAAwC,MAAM,CAAC;SAQ1B;QAErC,wCAAe,GAAf;YACI,IAAI,CAAC,EAAE,GAAGA,uBAAiB,EAAE,GAAG,QAAQ,CAAC;YACzC,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;YAEtH,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