{"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","Input","HostListener","CommonModule","NgModule"],"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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