import { __decorate, __extends } from "tslib";
import { createFocusTrap } from 'focus-trap';
import Component from 'vue-class-component';
import { ModulVue } from '../../utils/vue/vue';
var MFocusTrap = /** @class */ (function (_super) {
    __extends(MFocusTrap, _super);
    function MFocusTrap() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MFocusTrap.prototype.setFocusTrap = function (el, options) {
        if (options === void 0) { options = {}; }
        this.focusTrap = createFocusTrap(el, {
            escapeDeactivates: true,
            allowOutsideClick: true,
            initialFocus: options.initialFocus || el,
            returnFocusOnDeactivate: options.returnFocusOnDeactivate === undefined ? true : options.returnFocusOnDeactivate,
            preventScroll: true
        });
        this.focusTrap.activate();
    };
    MFocusTrap.prototype.removeFocusTrap = function () {
        if (!this.focusTrap) {
            return;
        }
        this.focusTrap.deactivate();
    };
    MFocusTrap.prototype.beforeDestroy = function () {
        if (!this.focusTrap) {
            return;
        }
        this.focusTrap.deactivate();
    };
    MFocusTrap = __decorate([
        Component
    ], MFocusTrap);
    return MFocusTrap;
}(ModulVue));
export { MFocusTrap };
//# sourceMappingURL=window-focus-trap.js.map