@nepwork/dashboards
Version:
Dashboards for emergencies and monitoring
53 lines • 2.25 kB
JavaScript
import { __decorate, __extends, __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.
* */
var NbFocusTrap = /** @class */ (function (_super) {
__extends(NbFocusTrap, _super);
function NbFocusTrap(element, checker, ngZone, document, deferAnchors) {
var _this = _super.call(this, element, checker, ngZone, document, deferAnchors) || this;
_this.element = element;
_this.checker = checker;
_this.ngZone = ngZone;
_this.document = document;
_this.savePreviouslyFocusedElement();
return _this;
}
NbFocusTrap.prototype.restoreFocus = function () {
this.previouslyFocusedElement.focus();
this.destroy();
};
NbFocusTrap.prototype.blurPreviouslyFocusedElement = function () {
this.previouslyFocusedElement.blur();
};
NbFocusTrap.prototype.savePreviouslyFocusedElement = function () {
this.previouslyFocusedElement = this.document.activeElement;
};
return NbFocusTrap;
}(FocusTrap));
export { NbFocusTrap };
var NbFocusTrapFactoryService = /** @class */ (function (_super) {
__extends(NbFocusTrapFactoryService, _super);
function NbFocusTrapFactoryService(checker, ngZone, document) {
var _this = _super.call(this, checker, ngZone, document) || this;
_this.checker = checker;
_this.ngZone = ngZone;
_this.document = document;
return _this;
}
NbFocusTrapFactoryService.prototype.create = function (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);
return NbFocusTrapFactoryService;
}(FocusTrapFactory));
export { NbFocusTrapFactoryService };
//# sourceMappingURL=focus-trap.js.map