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

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

initial commit

  • Property mode set to 100644
File size: 6.0 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 { FocusTrap } from './focus-trap';
9/**
10 * Class that allows for trapping focus within a DOM element.
11 *
12 * This class uses a strategy pattern that determines how it traps focus.
13 * See FocusTrapInertStrategy.
14 */
15export class ConfigurableFocusTrap extends FocusTrap {
16 constructor(_element, _checker, _ngZone, _document, _focusTrapManager, _inertStrategy, config) {
17 super(_element, _checker, _ngZone, _document, config.defer);
18 this._focusTrapManager = _focusTrapManager;
19 this._inertStrategy = _inertStrategy;
20 this._focusTrapManager.register(this);
21 }
22 /** Whether the FocusTrap is enabled. */
23 get enabled() { return this._enabled; }
24 set enabled(value) {
25 this._enabled = value;
26 if (this._enabled) {
27 this._focusTrapManager.register(this);
28 }
29 else {
30 this._focusTrapManager.deregister(this);
31 }
32 }
33 /** Notifies the FocusTrapManager that this FocusTrap will be destroyed. */
34 destroy() {
35 this._focusTrapManager.deregister(this);
36 super.destroy();
37 }
38 /** @docs-private Implemented as part of ManagedFocusTrap. */
39 _enable() {
40 this._inertStrategy.preventFocus(this);
41 this.toggleAnchors(true);
42 }
43 /** @docs-private Implemented as part of ManagedFocusTrap. */
44 _disable() {
45 this._inertStrategy.allowFocus(this);
46 this.toggleAnchors(false);
47 }
48}
49//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlndXJhYmxlLWZvY3VzLXRyYXAuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL2ExMXkvZm9jdXMtdHJhcC9jb25maWd1cmFibGUtZm9jdXMtdHJhcC50cyJd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