/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { FocusTrap } from './focus-trap'; /** * Class that allows for trapping focus within a DOM element. * * This class uses a strategy pattern that determines how it traps focus. * See FocusTrapInertStrategy. */ export class ConfigurableFocusTrap extends FocusTrap { /** Whether the FocusTrap is enabled. */ get enabled() { return this._enabled; } set enabled(value) { this._enabled = value; if (this._enabled) { this._focusTrapManager.register(this); } else { this._focusTrapManager.deregister(this); } } constructor(_element, _checker, _ngZone, _document, _focusTrapManager, _inertStrategy, config) { super(_element, _checker, _ngZone, _document, config.defer); this._focusTrapManager = _focusTrapManager; this._inertStrategy = _inertStrategy; this._focusTrapManager.register(this); } /** Notifies the FocusTrapManager that this FocusTrap will be destroyed. */ destroy() { this._focusTrapManager.deregister(this); super.destroy(); } /** @docs-private Implemented as part of ManagedFocusTrap. */ _enable() { this._inertStrategy.preventFocus(this); this.toggleAnchors(true); } /** @docs-private Implemented as part of ManagedFocusTrap. */ _disable() { this._inertStrategy.allowFocus(this); this.toggleAnchors(false); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlndXJhYmxlLWZvY3VzLXRyYXAuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL2ExMXkvZm9jdXMtdHJhcC9jb25maWd1cmFibGUtZm9jdXMtdHJhcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFJSCxPQUFPLEVBQUMsU0FBUyxFQUFDLE1BQU0sY0FBYyxDQUFDO0FBS3ZDOzs7OztHQUtHO0FBQ0gsTUFBTSxPQUFPLHFCQUFzQixTQUFRLFNBQVM7SUFDbEQsd0NBQXdDO0lBQ3hDLElBQWEsT0FBTztRQUNsQixPQUFPLElBQUksQ0FBQyxRQUFRLENBQUM7SUFDdkIsQ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