{"version":3,"file":"primeng-button.umd.js","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})\nexport class ButtonDirective implements AfterViewInit, OnDestroy {\n\n @Input() iconPos: 'left' | 'right' | 'top' | 'bottom' = 'left';\n \n public _label: string;\n \n public _icon: string;\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) {\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 if (iconPosClass) {\n DomHandler.addClass(iconElement, iconPosClass);\n }\n DomHandler.addMultipleClasses(iconElement, this.icon);\n this.el.nativeElement.appendChild(iconElement);\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 labelElement.appendChild(document.createTextNode(this.label||' '));\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 return styleClass;\n }\n\n setStyleClass() {\n let styleClass = this.getStyleClass();\n this.el.nativeElement.className = styleClass + ' ' + this._initialStyleClass;\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 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 if (this.iconPos)\n DomHandler.findSingle(this.el.nativeElement, '.p-button-icon').className = 'p-button-icon p-button-icon-' + this.iconPos + ' ' + this._icon;\n else\n DomHandler.findSingle(this.el.nativeElement, '.p-button-icon').className = 'p-button-icon ' + this._icon;\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 \n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None\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() style: any;\n\n @Input() styleClass: string;\n\n @Input() badgeClass: string;\n\n contentTemplate: TemplateRef;\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n\n @Output() onClick: EventEmitter = new EventEmitter();\n\n @Output() onFocus: EventEmitter = new EventEmitter();\n\n @Output() onBlur: EventEmitter = 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\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":["DomHandler","Directive","ElementRef","Input","EventEmitter","Component","ChangeDetectionStrategy","ViewEncapsulation","ContentChildren","PrimeTemplate","Output","NgModule","CommonModule","RippleModule"],"mappings":";;;;;;;QAqBI,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