{"version":3,"sources":["../../src/app/components/focustrap/focustrap.ts"],"names":["FocusTrap","el","this","prototype","onkeydown","e","pFocusTrapDisabled","preventDefault","focusableElements","DomHandler","getFocusableElements","nativeElement","length","ownerDocument","activeElement","focusedIndex","indexOf","shiftKey","focus","Directive","args","selector","ElementRef","Input","HostListener","type","NgModule","imports","CommonModule","exports","declarations"],"mappings":"6dAWI,SAAAA,EAAmBC,GAAAC,KAAAD,GAAAA,SAInBD,EAAAG,UAAAC,UAAA,SAAUC,GACN,IAAgC,IAA5BH,KAAKI,mBAA6B,CAClCD,EAAEE,iBACF,IAAIC,EAAoBC,EAAAA,WAAWC,qBAAqBR,KAAKD,GAAGU,eAChE,GAAIH,GAAqBA,EAAkBI,OAAS,EAChD,GAAKJ,EAAkB,GAAGK,cAAcC,cAGnC,CACD,IAAIC,EAAeP,EAAkBQ,QAAQR,EAAkB,GAAGK,cAAcC,eAE5ET,EAAEY,UACmB,GAAjBF,GAAuC,IAAjBA,EACtBP,EAAkBA,EAAkBI,OAAS,GAAGM,QAEhDV,EAAkBO,EAAe,GAAGG,SAGnB,GAAjBH,GAAsBA,IAAkBP,EAAkBI,OAAS,EACnEJ,EAAkB,GAAGU,QAErBV,EAAkBO,EAAe,GAAGG,aAf5CV,EAAkB,GAAGU,mCAjBxCC,EAAAA,UAASC,KAAA,CAAC,CACPC,SAAU,4DALaC,EAAAA,0DAStBC,EAAAA,yBAIAC,EAAAA,aAAYJ,KAAA,CAAC,cAAe,CAAC,YAAS,CAAAK,KACtCD,EAAAA,aAAYJ,KAAA,CAAC,oBAAqB,CAAC,oBAmCxC,iCALCM,EAAAA,SAAQN,KAAA,CAAC,CACNO,QAAS,CAACC,EAAAA,cACVC,QAAS,CAAC7B,GACV8B,aAAc,CAAC9B","sourcesContent":["import {NgModule,Directive,ElementRef,HostListener, Input} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {DomHandler} from 'primeng/dom';\n\n@Directive({\n selector: '[pFocusTrap]',\n})\nexport class FocusTrap {\n\n @Input() pFocusTrapDisabled: boolean;\n\n constructor(public el: ElementRef) {}\n\n @HostListener('keydown.tab', ['$event'])\n @HostListener('keydown.shift.tab', ['$event'])\n onkeydown(e) {\n if (this.pFocusTrapDisabled !== true) {\n e.preventDefault();\n let focusableElements = DomHandler.getFocusableElements(this.el.nativeElement);\n if (focusableElements && focusableElements.length > 0) {\n if (!focusableElements[0].ownerDocument.activeElement) {\n focusableElements[0].focus();\n }\n else {\n let focusedIndex = focusableElements.indexOf(focusableElements[0].ownerDocument.activeElement);\n\n if (e.shiftKey) {\n if (focusedIndex == -1 || focusedIndex === 0)\n focusableElements[focusableElements.length - 1].focus();\n else\n focusableElements[focusedIndex - 1].focus();\n }\n else {\n if (focusedIndex == -1 || focusedIndex === (focusableElements.length - 1))\n focusableElements[0].focus();\n else\n focusableElements[focusedIndex + 1].focus();\n }\n }\n }\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [FocusTrap],\n declarations: [FocusTrap]\n})\nexport class FocusTrapModule { }\n"]}