UNPKG

2.91 kBSource Map (JSON)View Raw
1{"version":3,"file":"focus-trap-manager.js","sourceRoot":"","sources":["../../../../src/focus-trap/focus-trap-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oBAAoB;AAEpB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAY3C,kFAAkF;AAElF,MAAM,OAAO,gBAAgB;IAD7B;QAEE,mEAAmE;QACnE,8BAA8B;QACtB,oBAAe,GAAuB,EAAE,CAAC;KAqClD;IAnCC;;;OAGG;IACH,QAAQ,CAAC,SAA2B;QAClC,kDAAkD;QAClD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;QAE7E,IAAI,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC;QAEjC,IAAI,KAAK,CAAC,MAAM,EAAE;YAChB,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;SACpC;QAED,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtB,SAAS,CAAC,OAAO,EAAE,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,SAA2B;QACpC,SAAS,CAAC,QAAQ,EAAE,CAAC;QAErB,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC;QAEnC,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;YACZ,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACnB,IAAI,KAAK,CAAC,MAAM,EAAE;gBAChB,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;aACnC;SACF;IACH,CAAC;;;;YAxCF,UAAU,SAAC,EAAC,UAAU,EAAE,MAAM,EAAC","sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n/* eslint-disable */\n\nimport { Injectable } from '@angular/core';\n\n/**\n * A FocusTrap managed by FocusTrapManager.\n * Implemented by ConfigurableFocusTrap to avoid circular dependency.\n */\nexport interface ManagedFocusTrap {\n _enable(): void;\n _disable(): void;\n focusInitialElementWhenReady(): Promise<boolean>;\n}\n\n/** Injectable that ensures only the most recently enabled FocusTrap is active. */\n@Injectable({providedIn: 'root'})\nexport class FocusTrapManager {\n // A stack of the FocusTraps on the page. Only the FocusTrap at the\n // top of the stack is active.\n private _focusTrapStack: ManagedFocusTrap[] = [];\n\n /**\n * Disables the FocusTrap at the top of the stack, and then pushes\n * the new FocusTrap onto the stack.\n */\n register(focusTrap: ManagedFocusTrap): void {\n // Dedupe focusTraps that register multiple times.\n this._focusTrapStack = this._focusTrapStack.filter((ft) => ft !== focusTrap);\n\n let stack = this._focusTrapStack;\n\n if (stack.length) {\n stack[stack.length - 1]._disable();\n }\n\n stack.push(focusTrap);\n focusTrap._enable();\n }\n\n /**\n * Removes the FocusTrap from the stack, and activates the\n * FocusTrap that is the new top of the stack.\n */\n deregister(focusTrap: ManagedFocusTrap): void {\n focusTrap._disable();\n\n const stack = this._focusTrapStack;\n\n const i = stack.indexOf(focusTrap);\n if (i !== -1) {\n stack.splice(i, 1);\n if (stack.length) {\n stack[stack.length - 1]._enable();\n }\n }\n }\n}\n"]}
\No newline at end of file