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 | */
|
8 | import { ElementRef, } from '@angular/core';
|
9 | import { throwNullPortalOutletError, throwPortalAlreadyAttachedError, throwNoPortalAttachedError, throwNullPortalError, throwPortalOutletAlreadyDisposedError, throwUnknownPortalTypeError, } from './portal-errors';
|
10 | /**
|
11 | * A `Portal` is something that you want to render somewhere else.
|
12 | * It can be attach to / detached from a `PortalOutlet`.
|
13 | */
|
14 | export class Portal {
|
15 | /** Attach this portal to a host. */
|
16 | attach(host) {
|
17 | if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
18 | if (host == null) {
|
19 | throwNullPortalOutletError();
|
20 | }
|
21 | if (host.hasAttached()) {
|
22 | throwPortalAlreadyAttachedError();
|
23 | }
|
24 | }
|
25 | this._attachedHost = host;
|
26 | return host.attach(this);
|
27 | }
|
28 | /** Detach this portal from its host */
|
29 | detach() {
|
30 | let host = this._attachedHost;
|
31 | if (host != null) {
|
32 | this._attachedHost = null;
|
33 | host.detach();
|
34 | }
|
35 | else if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
36 | throwNoPortalAttachedError();
|
37 | }
|
38 | }
|
39 | /** Whether this portal is attached to a host. */
|
40 | get isAttached() {
|
41 | return this._attachedHost != null;
|
42 | }
|
43 | /**
|
44 | * Sets the PortalOutlet reference without performing `attach()`. This is used directly by
|
45 | * the PortalOutlet when it is performing an `attach()` or `detach()`.
|
46 | */
|
47 | setAttachedHost(host) {
|
48 | this._attachedHost = host;
|
49 | }
|
50 | }
|
51 | /**
|
52 | * A `ComponentPortal` is a portal that instantiates some Component upon attachment.
|
53 | */
|
54 | export class ComponentPortal extends Portal {
|
55 | constructor(component, viewContainerRef, injector, componentFactoryResolver, projectableNodes) {
|
56 | super();
|
57 | this.component = component;
|
58 | this.viewContainerRef = viewContainerRef;
|
59 | this.injector = injector;
|
60 | this.componentFactoryResolver = componentFactoryResolver;
|
61 | this.projectableNodes = projectableNodes;
|
62 | }
|
63 | }
|
64 | /**
|
65 | * A `TemplatePortal` is a portal that represents some embedded template (TemplateRef).
|
66 | */
|
67 | export class TemplatePortal extends Portal {
|
68 | constructor(
|
69 | /** The embedded template that will be used to instantiate an embedded View in the host. */
|
70 | templateRef,
|
71 | /** Reference to the ViewContainer into which the template will be stamped out. */
|
72 | viewContainerRef,
|
73 | /** Contextual data to be passed in to the embedded view. */
|
74 | context,
|
75 | /** The injector to use for the embedded view. */
|
76 | injector) {
|
77 | super();
|
78 | this.templateRef = templateRef;
|
79 | this.viewContainerRef = viewContainerRef;
|
80 | this.context = context;
|
81 | this.injector = injector;
|
82 | }
|
83 | get origin() {
|
84 | return this.templateRef.elementRef;
|
85 | }
|
86 | /**
|
87 | * Attach the portal to the provided `PortalOutlet`.
|
88 | * When a context is provided it will override the `context` property of the `TemplatePortal`
|
89 | * instance.
|
90 | */
|
91 | attach(host, context = this.context) {
|
92 | this.context = context;
|
93 | return super.attach(host);
|
94 | }
|
95 | detach() {
|
96 | this.context = undefined;
|
97 | return super.detach();
|
98 | }
|
99 | }
|
100 | /**
|
101 | * A `DomPortal` is a portal whose DOM element will be taken from its current position
|
102 | * in the DOM and moved into a portal outlet, when it is attached. On detach, the content
|
103 | * will be restored to its original position.
|
104 | */
|
105 | export class DomPortal extends Portal {
|
106 | constructor(element) {
|
107 | super();
|
108 | this.element = element instanceof ElementRef ? element.nativeElement : element;
|
109 | }
|
110 | }
|
111 | /**
|
112 | * Partial implementation of PortalOutlet that handles attaching
|
113 | * ComponentPortal and TemplatePortal.
|
114 | */
|
115 | export class BasePortalOutlet {
|
116 | constructor() {
|
117 | /** Whether this host has already been permanently disposed. */
|
118 | this._isDisposed = false;
|
119 | // @breaking-change 10.0.0 `attachDomPortal` to become a required abstract method.
|
120 | this.attachDomPortal = null;
|
121 | }
|
122 | /** Whether this host has an attached portal. */
|
123 | hasAttached() {
|
124 | return !!this._attachedPortal;
|
125 | }
|
126 | /** Attaches a portal. */
|
127 | attach(portal) {
|
128 | if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
129 | if (!portal) {
|
130 | throwNullPortalError();
|
131 | }
|
132 | if (this.hasAttached()) {
|
133 | throwPortalAlreadyAttachedError();
|
134 | }
|
135 | if (this._isDisposed) {
|
136 | throwPortalOutletAlreadyDisposedError();
|
137 | }
|
138 | }
|
139 | if (portal instanceof ComponentPortal) {
|
140 | this._attachedPortal = portal;
|
141 | return this.attachComponentPortal(portal);
|
142 | }
|
143 | else if (portal instanceof TemplatePortal) {
|
144 | this._attachedPortal = portal;
|
145 | return this.attachTemplatePortal(portal);
|
146 | // @breaking-change 10.0.0 remove null check for `this.attachDomPortal`.
|
147 | }
|
148 | else if (this.attachDomPortal && portal instanceof DomPortal) {
|
149 | this._attachedPortal = portal;
|
150 | return this.attachDomPortal(portal);
|
151 | }
|
152 | if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
153 | throwUnknownPortalTypeError();
|
154 | }
|
155 | }
|
156 | /** Detaches a previously attached portal. */
|
157 | detach() {
|
158 | if (this._attachedPortal) {
|
159 | this._attachedPortal.setAttachedHost(null);
|
160 | this._attachedPortal = null;
|
161 | }
|
162 | this._invokeDisposeFn();
|
163 | }
|
164 | /** Permanently dispose of this portal host. */
|
165 | dispose() {
|
166 | if (this.hasAttached()) {
|
167 | this.detach();
|
168 | }
|
169 | this._invokeDisposeFn();
|
170 | this._isDisposed = true;
|
171 | }
|
172 | /** @docs-private */
|
173 | setDisposeFn(fn) {
|
174 | this._disposeFn = fn;
|
175 | }
|
176 | _invokeDisposeFn() {
|
177 | if (this._disposeFn) {
|
178 | this._disposeFn();
|
179 | this._disposeFn = null;
|
180 | }
|
181 | }
|
182 | }
|
183 | /**
|
184 | * @deprecated Use `BasePortalOutlet` instead.
|
185 | * @breaking-change 9.0.0
|
186 | */
|
187 | export class BasePortalHost extends BasePortalOutlet {
|
188 | }
|
189 | //# sourceMapp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