{"version":3,"sources":["../../src/app/components/button/button.ts"],"names":["ButtonDirective","el","this","iconPos","prototype","ngAfterViewInit","_initialStyleClass","nativeElement","className","DomHandler","addMultipleClasses","getStyleClass","icon","iconElement","document","createElement","setAttribute","iconPosClass","label","addClass","appendChild","labelElement","createTextNode","initialized","styleClass","setStyleClass","Object","defineProperty","_label","val","findSingle","textContent","_icon","ngOnDestroy","Directive","args","selector","ElementRef","Input","Button","type","onClick","EventEmitter","onFocus","onBlur","ngAfterContentInit","_this","templates","forEach","item","getType","contentTemplate","template","Component","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ContentChildren","PrimeTemplate","Output","NgModule","imports","CommonModule","RippleModule","exports","declarations"],"mappings":"0kBAqBI,SAAAA,EAAmBC,GAAAC,KAAAD,GAAAA,EAVVC,KAAAC,QAA+C,cAYxDH,EAAAI,UAAAC,gBAAA,WAII,GAHAH,KAAKI,mBAAqBJ,KAAKD,GAAGM,cAAcC,UAChDC,EAAAA,WAAWC,mBAAmBR,KAAKD,GAAGM,cAAeL,KAAKS,iBAEtDT,KAAKU,KAAM,CACX,IAAIC,EAAcC,SAASC,cAAc,QACzCF,EAAYL,UAAY,gBACxBK,EAAYG,aAAa,cAAe,QACxC,IAAIC,EAAef,KAAKgB,MAAQ,iBAAmBhB,KAAKC,QAAU,KAC9Dc,GACAR,EAAAA,WAAWU,SAASN,EAAaI,GAErCR,EAAAA,WAAWC,mBAAmBG,EAAaX,KAAKU,MAChDV,KAAKD,GAAGM,cAAca,YAAYP,GAGtC,IAAIQ,EAAeP,SAASC,cAAc,QACtCb,KAAKU,OAASV,KAAKgB,OACnBG,EAAaL,aAAa,cAAe,QAE7CK,EAAab,UAAY,iBACzBa,EAAaD,YAAYN,SAASQ,eAAepB,KAAKgB,OAAO,WAC7DhB,KAAKD,GAAGM,cAAca,YAAYC,GAClCnB,KAAKqB,aAAc,GAGvBvB,EAAAI,UAAAO,cAAA,WACI,IAAIa,EAAa,uBAKjB,OA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AAkBF,EAAKG,uCA7D/CC,EAAAA,UAASlB,KAAA,CAAC,CACPC,SAAU,WACVgB,SAAU,ovCAkBVE,gBAAiBC,EAAAA,wBAAwBC,OACzCC,cAAeC,EAAAA,kBAAkBC,uCAIhCrB,EAAAA,uBAEAA,EAAAA,oBAEAA,EAAAA,qBAEAA,EAAAA,qBAEAA,EAAAA,wBAEAA,EAAAA,qBAEAA,EAAAA,0BAEAA,EAAAA,0BAEAA,EAAAA,yBAIAsB,EAAAA,gBAAezB,KAAA,CAAC0B,EAAAA,gCAEhBC,EAAAA,wBAEAA,EAAAA,uBAEAA,EAAAA,gBAsBL,iCALCC,EAAAA,SAAQ5B,KAAA,CAAC,CACN6B,QAAS,CAACC,EAAAA,aAAaC,EAAAA,cACvBC,QAAS,CAACnE,EAAgBuC,GAC1B6B,aAAc,CAACpE,EAAgBuC","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"]}