{"version":3,"file":"primeng-focustrap.umd.js","sources":["../../src/app/components/focustrap/focustrap.ts","../../src/app/components/focustrap/primeng-focustrap.ts"],"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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["DomHandler","Directive","ElementRef","Input","HostListener","NgModule","CommonModule"],"mappings":";;;;;;;QAWI,mBAAmB,EAAc;YAAd,OAAE,GAAF,EAAE,CAAY;SAAI;QAIrC,6BAAS,GAAT,UAAU,CAAC;YACP,IAAI,IAAI,CAAC,kBAAkB,KAAK,IAAI,EAAE;gBAClC,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,IAAI,iBAAiB,GAAGA,cAAU,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CA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