source: trip-planner-front/node_modules/@angular/cdk/esm2015/a11y/focus-trap/focus-trap-manager.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.6 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Injectable } from '@angular/core';
9import * as i0 from "@angular/core";
10/** Injectable that ensures only the most recently enabled FocusTrap is active. */
11export class FocusTrapManager {
12 constructor() {
13 // A stack of the FocusTraps on the page. Only the FocusTrap at the
14 // top of the stack is active.
15 this._focusTrapStack = [];
16 }
17 /**
18 * Disables the FocusTrap at the top of the stack, and then pushes
19 * the new FocusTrap onto the stack.
20 */
21 register(focusTrap) {
22 // Dedupe focusTraps that register multiple times.
23 this._focusTrapStack = this._focusTrapStack.filter((ft) => ft !== focusTrap);
24 let stack = this._focusTrapStack;
25 if (stack.length) {
26 stack[stack.length - 1]._disable();
27 }
28 stack.push(focusTrap);
29 focusTrap._enable();
30 }
31 /**
32 * Removes the FocusTrap from the stack, and activates the
33 * FocusTrap that is the new top of the stack.
34 */
35 deregister(focusTrap) {
36 focusTrap._disable();
37 const stack = this._focusTrapStack;
38 const i = stack.indexOf(focusTrap);
39 if (i !== -1) {
40 stack.splice(i, 1);
41 if (stack.length) {
42 stack[stack.length - 1]._enable();
43 }
44 }
45 }
46}
47FocusTrapManager.ɵprov = i0.ɵɵdefineInjectable({ factory: function FocusTrapManager_Factory() { return new FocusTrapManager(); }, token: FocusTrapManager, providedIn: "root" });
48FocusTrapManager.decorators = [
49 { type: Injectable, args: [{ providedIn: 'root' },] }
50];
51//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9jdXMtdHJhcC1tYW5hZ2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vL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