/** * @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 { Directive, EventEmitter, inject, InjectionToken, Injector, ViewContainerRef, } from '@angular/core'; import { MENU_STACK } from './menu-stack'; import { TemplatePortal } from '@angular/cdk/portal'; import { merge, Subject } from 'rxjs'; import * as i0 from "@angular/core"; /** Injection token used for an implementation of MenuStack. */ export const MENU_TRIGGER = new InjectionToken('cdk-menu-trigger'); /** * Abstract directive that implements shared logic common to all menu triggers. * This class can be extended to create custom menu trigger types. */ export class CdkMenuTriggerBase { constructor() { /** The DI injector for this component. */ this.injector = inject(Injector); /** The view container ref for this component */ this.viewContainerRef = inject(ViewContainerRef); /** The menu stack in which this menu resides. */ this.menuStack = inject(MENU_STACK); /** Emits when the attached menu is requested to open */ this.opened = new EventEmitter(); /** Emits when the attached menu is requested to close */ this.closed = new EventEmitter(); /** A reference to the overlay which manages the triggered menu */ this.overlayRef = null; /** Emits when this trigger is destroyed. */ this.destroyed = new Subject(); /** Emits when the outside pointer events listener on the overlay should be stopped. */ this.stopOutsideClicksListener = merge(this.closed, this.destroyed); } ngOnDestroy() { this._destroyOverlay(); this.destroyed.next(); this.destroyed.complete(); } /** Whether the attached menu is open. */ isOpen() { return !!this.overlayRef?.hasAttached(); } /** Registers a child menu as having been opened by this trigger. */ registerChildMenu(child) { this.childMenu = child; } /** * Get the portal to be attached to the overlay which contains the menu. Allows for the menu * content to change dynamically and be reflected in the application. */ getMenuContentPortal() { const hasMenuContentChanged = this.menuTemplateRef !== this._menuPortal?.templateRef; if (this.menuTemplateRef && (!this._menuPortal || hasMenuContentChanged)) { this._menuPortal = new TemplatePortal(this.menuTemplateRef, this.viewContainerRef, this.menuData, this._getChildMenuInjector()); } return this._menuPortal; } /** * Whether the given element is inside the scope of this trigger's menu stack. * @param element The element to check. * @return Whether the element is inside the scope of this trigger's menu stack. */ isElementInsideMenuStack(element) { for (let el = element; el; el = el?.parentElement ?? null) { if (el.getAttribute('data-cdk-menu-stack-id') === this.menuStack.id) { return true; } } return false; } /** Destroy and unset the overlay reference it if exists */ _destroyOverlay() { if (this.overlayRef) { this.overlayRef.dispose(); this.overlayRef = null; } } /** Gets the injector to use when creating a child menu. */ _getChildMenuInjector() { this._childMenuInjector = this._childMenuInjector || Injector.create({ providers: [ { provide: MENU_TRIGGER, useValue: this }, { provide: MENU_STACK, useValue: this.menuStack }, ], parent: this.injector, }); return this._childMenuInjector; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: CdkMenuTriggerBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: CdkMenuTriggerBase, host: { properties: { "attr.aria-controls": "childMenu?.id", "attr.data-cdk-menu-stack-id": "menuStack.id" } }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: CdkMenuTriggerBase, decorators: [{ type: Directive, args: [{ host: { '[attr.aria-controls]': 'childMenu?.id', '[attr.data-cdk-menu-stack-id]': 'menuStack.id', }, }] }] }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVudS10cmlnZ2VyLWJhc2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL21lbnUvbWVudS10cmlnZ2VyLWJhc2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUNMLFNBQVMsRUFDVCxZQUFZLEVBQ1osTUFBTSxFQUNOLGNBQWMsRUFDZCxRQUFRLEVBR1IsZ0JBQWdCLEdBQ2pCLE1BQU0sZUFBZSxDQUFDO0FBRXZCLE9BQU8sRUFBQyxVQUFVLEVBQVksTUFBTSxjQUFjLENBQUM7QUFFb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