Icard/angular-clarity-master(work.../node_modules/primeng/fesm2022/primeng-focustrap.mjs

68 lines
3.1 KiB
JavaScript
Raw Permalink Normal View History

2024-07-16 15:23:22 +00:00
import { DomHandler } from 'primeng/dom';
import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { inject, ElementRef, booleanAttribute, Directive, Input, HostListener, NgModule } from '@angular/core';
/**
* Focus Trap keeps focus within a certain DOM element while tabbing.
* @group Components
*/
class FocusTrap {
/**
* When set as true, focus wouldn't be managed.
* @group Props
*/
pFocusTrapDisabled = false;
host = inject(ElementRef);
onkeydown(e) {
if (this.pFocusTrapDisabled !== true) {
e.preventDefault();
const focusableElement = DomHandler.getNextFocusableElement(this.host.nativeElement, e.shiftKey);
if (focusableElement) {
focusableElement.focus();
focusableElement.select?.();
}
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: FocusTrap, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "17.3.7", type: FocusTrap, selector: "[pFocusTrap]", inputs: { pFocusTrapDisabled: ["pFocusTrapDisabled", "pFocusTrapDisabled", booleanAttribute] }, host: { listeners: { "keydown.tab": "onkeydown($event)", "keydown.shift.tab": "onkeydown($event)" }, classAttribute: "p-element" }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: FocusTrap, decorators: [{
type: Directive,
args: [{
selector: '[pFocusTrap]',
host: {
class: 'p-element'
}
}]
}], propDecorators: { pFocusTrapDisabled: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], onkeydown: [{
type: HostListener,
args: ['keydown.tab', ['$event']]
}, {
type: HostListener,
args: ['keydown.shift.tab', ['$event']]
}] } });
class FocusTrapModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: FocusTrapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: FocusTrapModule, declarations: [FocusTrap], imports: [CommonModule], exports: [FocusTrap] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: FocusTrapModule, imports: [CommonModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: FocusTrapModule, decorators: [{
type: NgModule,
args: [{
imports: [CommonModule],
exports: [FocusTrap],
declarations: [FocusTrap]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { FocusTrap, FocusTrapModule };
//# sourceMappingURL=primeng-focustrap.mjs.map