{"version":3,"file":"primeng-badge.mjs","sources":["../../src/app/components/badge/badge.ts","../../src/app/components/badge/primeng-badge.ts"],"sourcesContent":["import { CommonModule, DOCUMENT } from '@angular/common';\nimport { AfterViewInit, ChangeDetectionStrategy, Component, Directive, ElementRef, Inject, Input, NgModule, OnDestroy, Renderer2, ViewEncapsulation } from '@angular/core';\nimport { LicenseManager, SharedModule } from 'primeng/api';\nimport { DomHandler } from 'primeng/dom';\nimport { UniqueComponentId } from 'primeng/utils';\n\ntype BadgeDirectiveIconPosition = 'left' | 'right' | 'top' | 'bottom';\ntype BadgeSize = 'large' | 'xlarge';\n\n@Directive({\n selector: '[pBadge]',\n host: {\n class: 'p-element'\n }\n})\nexport class BadgeDirective implements AfterViewInit, OnDestroy {\n @Input() iconPos: BadgeDirectiveIconPosition = 'left';\n\n @Input('badgeDisabled') get disabled(): boolean {\n return this._disabled;\n }\n set disabled(val: boolean) {\n this._disabled = val;\n }\n\n @Input() public get size(): BadgeSize {\n return this._size;\n }\n set size(val: BadgeSize) {\n this._size = val;\n\n if (this.initialized) {\n this.setSizeClasses();\n }\n }\n\n public _value: string;\n\n public initialized: boolean;\n\n private id: string;\n\n private _disabled: boolean = false;\n\n private _size: BadgeSize;\n\n constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, private renderer: Renderer2) {}\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 if (this._disabled) {\n return null;\n }\n\n let badge = this.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 this.setSizeClasses(badge);\n\n if (this.value != null) {\n this.renderer.appendChild(badge, this.document.createTextNode(this.value));\n\n if (String(this.value).length === 1) {\n DomHandler.addClass(badge, 'p-badge-no-gutter');\n }\n } else {\n DomHandler.addClass(badge, 'p-badge-dot');\n }\n\n DomHandler.addClass(el, 'p-overlay-badge');\n this.renderer.appendChild(el, badge);\n\n this.initialized = true;\n\n LicenseManager.check();\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')) DomHandler.removeClass(badge, 'p-badge-dot');\n\n if (String(this._value).length === 1) {\n DomHandler.addClass(badge, 'p-badge-no-gutter');\n } else {\n DomHandler.removeClass(badge, 'p-badge-no-gutter');\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 this.renderer.appendChild(badge, document.createTextNode(this._value));\n }\n }\n }\n\n @Input() severity: string;\n\n private setSizeClasses(element?: HTMLElement): void {\n const badge = element ?? this.document.getElementById(this.id);\n\n if (!badge) {\n return;\n }\n\n if (this._size) {\n if (this._size === 'large') {\n DomHandler.addClass(badge, 'p-badge-lg');\n DomHandler.removeClass(badge, 'p-badge-xl');\n }\n\n if (this._size === 'xlarge') {\n DomHandler.addClass(badge, 'p-badge-xl');\n DomHandler.removeClass(badge, 'p-badge-lg');\n }\n } else {\n DomHandler.removeClass(badge, 'p-badge-lg');\n DomHandler.removeClass(badge, 'p-badge-xl');\n }\n }\n\n ngOnDestroy() {\n this.initialized = false;\n }\n}\n\n@Component({\n selector: 'p-badge',\n template: ` {{ value }} `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./badge.css'],\n host: {\n class: 'p-element'\n }\n})\nexport class Badge {\n @Input() styleClass: string;\n\n @Input() style: any;\n\n @Input() size: BadgeSize;\n\n @Input() severity: string;\n\n @Input() value: string;\n\n @Input() badgeDisabled: boolean = false;\n\n containerClass() {\n return {\n 'p-badge p-component': true,\n 'p-badge-no-gutter': this.value != undefined && 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":";;;;;;;;MAea,cAAc,CAAA;AA+BvB,IAAA,WAAA,CAAsC,QAAkB,EAAS,EAAc,EAAU,QAAmB,EAAA;AAAtE,QAAA,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;AAAS,QAAA,IAAE,CAAA,EAAA,GAAF,EAAE,CAAY;AAAU,QAAA,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAW;AA9BnG,QAAA,IAAO,CAAA,OAAA,GAA+B,MAAM,CAAC;AA0B9C,QAAA,IAAS,CAAA,SAAA,GAAY,KAAK,CAAC;KAI6E;AA5BhH,IAAA,IAA4B,QAAQ,GAAA;QAChC,OAAO,IAAI,CAAC,SAAS,CAAC;KACzB;IACD,IAAI,QAAQ,CAAC,GAAY,EAAA;AACrB,QAAA,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;KACxB;AAED,IAAA,IAAoB,IAAI,GAAA;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC;KACrB;IACD,IAAI,IAAI,CAAC,GAAc,EAAA;AACnB,QAAA,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;QAEjB,IAAI,IAAI,CAAC,WAAW,EAAE;YAClB,IAAI,CAAC,cAAc,EAAE,CAAC;AACzB,SAAA;KACJ;IAcD,eAAe,GAAA;AACX,QAAA,IAAI,CAAC,EAAE,GAAG,iBAAiB,EAAE,GAAG,QAAQ,CAAC;AACzC,QAAA,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC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