{"version":3,"file":"primeng-button.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 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":";;;;;;MASa,eAAe;IAYxB,YAAmB,EAAc;QAA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