source: trip-planner-front/node_modules/@angular/material/esm2015/menu/menu-content.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: 11.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 { DomPortalOutlet, TemplatePortal } from '@angular/cdk/portal';
9import { DOCUMENT } from '@angular/common';
10import { ApplicationRef, ChangeDetectorRef, ComponentFactoryResolver, Directive, Inject, InjectionToken, Injector, TemplateRef, ViewContainerRef, } from '@angular/core';
11import { Subject } from 'rxjs';
12/**
13 * Injection token that can be used to reference instances of `MatMenuContent`. It serves
14 * as alternative token to the actual `MatMenuContent` class which could cause unnecessary
15 * retention of the class and its directive metadata.
16 */
17export const MAT_MENU_CONTENT = new InjectionToken('MatMenuContent');
18export class _MatMenuContentBase {
19 constructor(_template, _componentFactoryResolver, _appRef, _injector, _viewContainerRef, _document, _changeDetectorRef) {
20 this._template = _template;
21 this._componentFactoryResolver = _componentFactoryResolver;
22 this._appRef = _appRef;
23 this._injector = _injector;
24 this._viewContainerRef = _viewContainerRef;
25 this._document = _document;
26 this._changeDetectorRef = _changeDetectorRef;
27 /** Emits when the menu content has been attached. */
28 this._attached = new Subject();
29 }
30 /**
31 * Attaches the content with a particular context.
32 * @docs-private
33 */
34 attach(context = {}) {
35 if (!this._portal) {
36 this._portal = new TemplatePortal(this._template, this._viewContainerRef);
37 }
38 this.detach();
39 if (!this._outlet) {
40 this._outlet = new DomPortalOutlet(this._document.createElement('div'), this._componentFactoryResolver, this._appRef, this._injector);
41 }
42 const element = this._template.elementRef.nativeElement;
43 // Because we support opening the same menu from different triggers (which in turn have their
44 // own `OverlayRef` panel), we have to re-insert the host element every time, otherwise we
45 // risk it staying attached to a pane that's no longer in the DOM.
46 element.parentNode.insertBefore(this._outlet.outletElement, element);
47 // When `MatMenuContent` is used in an `OnPush` component, the insertion of the menu
48 // content via `createEmbeddedView` does not cause the content to be seen as "dirty"
49 // by Angular. This causes the `@ContentChildren` for menu items within the menu to
50 // not be updated by Angular. By explicitly marking for check here, we tell Angular that
51 // it needs to check for new menu items and update the `@ContentChild` in `MatMenu`.
52 // @breaking-change 9.0.0 Make change detector ref required
53 if (this._changeDetectorRef) {
54 this._changeDetectorRef.markForCheck();
55 }
56 this._portal.attach(this._outlet, context);
57 this._attached.next();
58 }
59 /**
60 * Detaches the content.
61 * @docs-private
62 */
63 detach() {
64 if (this._portal.isAttached) {
65 this._portal.detach();
66 }
67 }
68 ngOnDestroy() {
69 if (this._outlet) {
70 this._outlet.dispose();
71 }
72 }
73}
74_MatMenuContentBase.decorators = [
75 { type: Directive }
76];
77_MatMenuContentBase.ctorParameters = () => [
78 { type: TemplateRef },
79 { type: ComponentFactoryResolver },
80 { type: ApplicationRef },
81 { type: Injector },
82 { type: ViewContainerRef },
83 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
84 { type: ChangeDetectorRef }
85];
86/**
87 * Menu content that will be rendered lazily once the menu is opened.
88 */
89export class MatMenuContent extends _MatMenuContentBase {
90}
91MatMenuContent.decorators = [
92 { type: Directive, args: [{
93 selector: 'ng-template[matMenuContent]',
94 providers: [{ provide: MAT_MENU_CONTENT, useExisting: MatMenuContent }],
95 },] }
96];
97//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVudS1jb250ZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21hdGVyaWFsL21lbnUvbWVudS1jb250ZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBQyxlQUFlLEVBQUUsY0FBYyxFQUFDLE1BQU0scUJBQXFCLENBQUM7QUFDcEUsT0FBTyxFQUFDLFFBQVEsRUFBQyxNQUFNLGlCQU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NvbnRlbnRCYXNlIHt9XG4iXX0=
Note: See TracBrowser for help on using the repository browser.