1 | {"version":3,"file":"primeng-button.mjs","sources":["../../src/app/components/button/button.ts","../../src/app/components/button/primeng-button.ts"],"sourcesContent":["import {NgModule,Directive,Component,ElementRef,EventEmitter,AfterViewInit,Output,OnDestroy,Input,ChangeDetectionStrategy, ViewEncapsulation, ContentChildren, AfterContentInit, TemplateRef, QueryList} from '@angular/core';\nimport {DomHandler} from 'primeng/dom';\nimport {CommonModule} from '@angular/common';\nimport {RippleModule} from 'primeng/ripple';\nimport {PrimeTemplate} from 'primeng/api';\n\n@Directive({\n selector: '[pButton]',\n host: {\n 'class': 'p-element'\n }\n})\nexport class ButtonDirective implements AfterViewInit, OnDestroy {\n\n @Input() iconPos: 'left' | 'right' | 'top' | 'bottom' = 'left';\n\n @Input() loadingIcon: string = \"pi pi-spinner pi-spin\";\n\n public _label: string;\n\n public _icon: string;\n\n public _loading: boolean = false;\n\n public initialized: boolean;\n\n public _initialStyleClass: string;\n\n constructor(public el: ElementRef) {}\n\n ngAfterViewInit() {\n this._initialStyleClass = this.el.nativeElement.className;\n DomHandler.addMultipleClasses(this.el.nativeElement, this.getStyleClass());\n\n if (this.icon || this.loading) {\n this.createIconEl();\n }\n\n let labelElement = document.createElement(\"span\");\n if (this.icon && !this.label) {\n labelElement.setAttribute('aria-hidden', 'true');\n }\n labelElement.className = 'p-button-label';\n\n if (this.label)\n labelElement.appendChild(document.createTextNode(this.label));\n else\n labelElement.innerHTML = ' ';\n\n this.el.nativeElement.appendChild(labelElement);\n this.initialized = true;\n }\n\n getStyleClass(): string {\n let styleClass = 'p-button p-component';\n if (this.icon && !this.label) {\n styleClass = styleClass + ' p-button-icon-only';\n }\n\n if (this.loading) {\n styleClass = styleClass + ' p-disabled p-button-loading';\n if (!this.icon && this.label)\n styleClass = styleClass + ' p-button-loading-label-only';\n }\n\n return styleClass;\n }\n\n setStyleClass() {\n let styleClass = this.getStyleClass();\n this.el.nativeElement.className = styleClass + ' ' + this._initialStyleClass;\n }\n\n createIconEl() {\n let iconElement = document.createElement(\"span\");\n iconElement.className = 'p-button-icon';\n iconElement.setAttribute(\"aria-hidden\", \"true\");\n let iconPosClass = this.label ? 'p-button-icon-' + this.iconPos : null;\n\n if (iconPosClass) {\n DomHandler.addClass(iconElement, iconPosClass);\n }\n\n let iconClass = this.getIconClass();\n\n if(iconClass) {\n DomHandler.addMultipleClasses(iconElement, iconClass);\n }\n\n let labelEl = DomHandler.findSingle(this.el.nativeElement, '.p-button-label')\n\n if (labelEl)\n this.el.nativeElement.insertBefore(iconElement, labelEl);\n else\n this.el.nativeElement.appendChild(iconElement)\n }\n\n getIconClass() {\n return this.loading ? 'p-button-loading-icon ' + this.loadingIcon : this._icon;\n }\n\n setIconClass() {\n let iconElement = DomHandler.findSingle(this.el.nativeElement, '.p-button-icon');\n if (iconElement) {\n if (this.iconPos)\n iconElement.className = 'p-button-icon p-button-icon-' + this.iconPos + ' ' + this.getIconClass();\n else\n iconElement.className = 'p-button-icon ' + this.getIconClass();\n }\n else {\n this.createIconEl();\n }\n }\n\n removeIconElement() {\n let iconElement = DomHandler.findSingle(this.el.nativeElement, '.p-button-icon');\n this.el.nativeElement.removeChild(iconElement);\n }\n\n @Input() get label(): string {\n return this._label;\n }\n\n set label(val: string) {\n this._label = val;\n\n if (this.initialized) {\n DomHandler.findSingle(this.el.nativeElement, '.p-button-label').textContent = this._label || ' ';\n\n if (this.loading || this.icon) {\n this.setIconClass();\n }\n this.setStyleClass();\n }\n }\n\n @Input() get icon(): string {\n return this._icon;\n }\n\n set icon(val: string) {\n this._icon = val;\n\n if (this.initialized) {\n this.setIconClass();\n this.setStyleClass();\n }\n }\n\n @Input() get loading(): boolean {\n return this._loading;\n }\n\n set loading(val: boolean) {\n this._loading = val;\n\n if (this.initialized) {\n if (this.loading || this.icon)\n this.setIconClass();\n else\n this.removeIconElement();\n\n this.setStyleClass();\n }\n }\n\n ngOnDestroy() {\n this.initialized = false;\n }\n}\n\n@Component({\n selector: 'p-button',\n template: `\n <button [attr.type]=\"type\" [class]=\"styleClass\" [ngStyle]=\"style\" [disabled]=\"disabled || loading\"\n [ngClass]=\"{'p-button p-component':true,\n 'p-button-icon-only': (icon && !label),\n 'p-button-vertical': (iconPos === 'top' || iconPos === 'bottom') && label,\n 'p-disabled': this.disabled || this.loading,\n 'p-button-loading': this.loading,\n 'p-button-loading-label-only': this.loading && !this.icon && this.label}\"\n (click)=\"onClick.emit($event)\" (focus)=\"onFocus.emit($event)\" (blur)=\"onBlur.emit($event)\" pRipple>\n <ng-content></ng-content>\n <ng-container *ngTemplateOutlet=\"contentTemplate\"></ng-container>\n <span [ngClass]=\"{'p-button-icon': true,\n 'p-button-icon-left': iconPos === 'left' && label,\n 'p-button-icon-right': iconPos === 'right' && label,\n 'p-button-icon-top': iconPos === 'top' && label,\n 'p-button-icon-bottom': iconPos === 'bottom' && label}\"\n [class]=\"loading ? 'p-button-loading-icon ' + loadingIcon : icon\" *ngIf=\"!contentTemplate && (icon||loading)\" [attr.aria-hidden]=\"true\"></span>\n <span class=\"p-button-label\" [attr.aria-hidden]=\"icon && !label\" *ngIf=\"!contentTemplate\">{{label||' '}}</span>\n <span [ngClass]=\"badgeStyleClass()\" [class]=\"badgeClass\" *ngIf=\"!contentTemplate && badge\">{{badge}}</span>\n </button>\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n 'class': 'p-element'\n }\n})\nexport class Button implements AfterContentInit {\n\n @Input() type: string = \"button\";\n\n @Input() iconPos: string = 'left';\n\n @Input() icon: string;\n\n @Input() badge: string;\n\n @Input() label: string;\n\n @Input() disabled: boolean;\n\n @Input() loading: boolean = false;\n\n @Input() loadingIcon: string = \"pi pi-spinner pi-spin\";\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() badgeClass: string;\n\n contentTemplate: TemplateRef<any>;\n\n @ContentChildren(PrimeTemplate) templates: QueryList<any>;\n\n @Output() onClick: EventEmitter<any> = new EventEmitter();\n\n @Output() onFocus: EventEmitter<any> = new EventEmitter();\n\n @Output() onBlur: EventEmitter<any> = new EventEmitter();\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'content':\n this.contentTemplate = item.template;\n break;\n\n default:\n this.contentTemplate = item.template;\n break;\n }\n });\n }\n\n badgeStyleClass() {\n return {\n 'p-badge p-component': true,\n 'p-badge-no-gutter': this.badge && String(this.badge).length === 1\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule,RippleModule],\n exports: [ButtonDirective,Button],\n declarations: [ButtonDirective,Button]\n})\nexport class ButtonModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;MAYa,eAAe;IAgBxB,YAAmB,EAAc;QAAd,OAAE,GAAF,EAAE,CAAY;QAdxB,YAAO,GAAwC,MAAM,CAAC;QAEtD,gBAAW,GAAW,uBAAuB,CAAC;QAMhD,aAAQ,GAAY,KAAK,CAAC;KAMI;IAErC,eAAe;QACX,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC;QAC1D,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;QAE3E,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;YAC3B,IAAI,CAAC,YAAY,EAAE,CAAC;SACvB;QAED,IAAI,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YAC1B,YAAY,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;SACpD;QACD,YAAY,CAAC,SAAS,GAAG,gBAAgB,CAAC;QAE1C,IAAI,IAAI,CAAC,KAAK;YACV,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,KA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