{"version":3,"file":"primeng-focustrap.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":[],"mappings":";;;;;MAOa,SAAS;IAIlB,YAAmB,EAAc;QAAd,OAAE,GAAF,EAAE,CAAY;KAAI;IAIrC,SAAS,CAAC,CAAC;QACP,IAAI,IAAI,CAAC,kBAAkB,KAAK,IAAI,EAAE;YAClC,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,IAAI,iBAAiB,GAAG,UAAU,CAAC,oBAAoB,CAAC,IAAI,CAA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