Icard/angular-clarity-master(work.../node_modules/primeng/fesm2022/primeng-badge.mjs.map

1 line
17 KiB
Plaintext
Raw Permalink Normal View History

2024-07-16 14:55:36 +00:00
{"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, Renderer2, OnChanges, SimpleChanges, ViewEncapsulation, booleanAttribute } from '@angular/core';\nimport { SharedModule } from 'primeng/api';\nimport { DomHandler } from 'primeng/dom';\nimport { UniqueComponentId } from 'primeng/utils';\n/**\n * Badge Directive is directive usage of badge component.\n * @group Components\n */\n@Directive({\n selector: '[pBadge]',\n host: {\n class: 'p-element'\n }\n})\nexport class BadgeDirective implements OnChanges, AfterViewInit {\n /**\n * When specified, disables the component.\n * @group Props\n */\n @Input('badgeDisabled') public disabled: boolean;\n /**\n * Size of the badge, valid options are \"large\" and \"xlarge\".\n * @group Props\n */\n @Input() public badgeSize: 'large' | 'xlarge';\n /**\n * Size of the badge, valid options are \"large\" and \"xlarge\".\n * @group Props\n * @deprecated use badgeSize instead.\n */\n @Input() public set size(value: 'large' | 'xlarge') {\n this._size = value;\n console.warn('size property is deprecated and will removed in v18, use badgeSize instead.');\n }\n get size() {\n return this._size;\n }\n _size: 'large' | 'xlarge';\n /**\n * Severity type of the badge.\n * @group Props\n */\n @Input() public severity: 'success' | 'info' | 'warning' | 'danger' | null | undefined;\n /**\n * Value to display inside the badge.\n * @group Props\n */\n @Input() public value: string | number;\n\n private id!: string;\n\n private get activeElement(): HTMLElement {\n return this.el.nativeElement.nodeName.indexOf('-') != -1 ? this.el.nativeElement.firstChild : this.el.nativeElement;\n }\n\n private get canUpdateBadge(): boolean {\n return this.id && !this.disabled;\n }\n\n constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, private renderer: Renderer2) {}\n\n public ngOnChanges({ value, size, severity, disabled }: SimpleChanges): void {\n if (disabled) {\n this.toggleDisableState();\n }\n\n if (!this.canUpdateBadge) {\n return;\n }\n\n if (severity) {\n this.setSeverity(severity.previousValue);\n }\n\n if (size) {\n this.setSizeClasses();\n }\n\n if (value) {\n this.setValue();\n }\n }\n\n public ngAfterViewInit(): void {\n this.id = UniqueComponentId() + '_badge';\n this.renderBadgeContent();\n }\n\n private setValue(element?: HTMLElement): void {\n const badge = element ?? this.document.getElementById(this.id);\n\n if (!badge) {\n return;\n }\n\n if (this.value != null) {\n if (DomHandler.hasClass(badge, 'p-badge-dot')) {\n DomHandler.removeClass(badge, 'p-badge-dot');\n }\n\n if (this.value && 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 {\n if (!DomHandler.hasClass(badge, 'p-badge-dot')) {\n DomHandler.addClass(badge, 'p-badge-dot');\n }\n\n DomHandler.removeClass(badge, 'p-badge-no-gutter');\n }\n\n badge.innerHTML = '';\n const badgeValue = this.value != null ? String(this.value) : '';\n this.renderer.appendChild(badge, this.document.createTextNode(badgeValue));\n }\n\n private setSizeClasses(element?: HTMLElement): void {\n const badge = element ?? this.document.getElementById(this.id);\n\n if (!badge) {\n return