UNPKG

@nepwork/dashboards

Version:

Dashboards for emergencies and monitoring

46 lines 1.73 kB
import { __decorate, __metadata, __param } from "tslib"; import { Inject, Injectable, NgZone } from '@angular/core'; import { FocusTrap, FocusTrapFactory, InteractivityChecker } from '@angular/cdk/a11y'; import { NB_DOCUMENT } from '../../../theme.options'; /** * Overrides angular cdk focus trap to keep restore functionality inside trap. * */ export class NbFocusTrap extends FocusTrap { constructor(element, checker, ngZone, document, deferAnchors) { super(element, checker, ngZone, document, deferAnchors); this.element = element; this.checker = checker; this.ngZone = ngZone; this.document = document; this.savePreviouslyFocusedElement(); } restoreFocus() { this.previouslyFocusedElement.focus(); this.destroy(); } blurPreviouslyFocusedElement() { this.previouslyFocusedElement.blur(); } savePreviouslyFocusedElement() { this.previouslyFocusedElement = this.document.activeElement; } } let NbFocusTrapFactoryService = class NbFocusTrapFactoryService extends FocusTrapFactory { constructor(checker, ngZone, document) { super(checker, ngZone, document); this.checker = checker; this.ngZone = ngZone; this.document = document; } create(element, deferCaptureElements) { return new NbFocusTrap(element, this.checker, this.ngZone, this.document, deferCaptureElements); } }; NbFocusTrapFactoryService = __decorate([ Injectable(), __param(2, Inject(NB_DOCUMENT)), __metadata("design:paramtypes", [InteractivityChecker, NgZone, Object]) ], NbFocusTrapFactoryService); export { NbFocusTrapFactoryService }; //# sourceMappingURL=focus-trap.js.map