portal-directives-Bw5woq8I.mjs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. import * as i0 from '@angular/core';
  2. import { ElementRef, NgModuleRef, EnvironmentInjector, createComponent, Injector, inject, TemplateRef, ViewContainerRef, Directive, EventEmitter, Input, Output, NgModule } from '@angular/core';
  3. import { DOCUMENT } from '@angular/common';
  4. /**
  5. * Throws an exception when attempting to attach a null portal to a host.
  6. * @docs-private
  7. */
  8. function throwNullPortalError() {
  9. throw Error('Must provide a portal to attach');
  10. }
  11. /**
  12. * Throws an exception when attempting to attach a portal to a host that is already attached.
  13. * @docs-private
  14. */
  15. function throwPortalAlreadyAttachedError() {
  16. throw Error('Host already has a portal attached');
  17. }
  18. /**
  19. * Throws an exception when attempting to attach a portal to an already-disposed host.
  20. * @docs-private
  21. */
  22. function throwPortalOutletAlreadyDisposedError() {
  23. throw Error('This PortalOutlet has already been disposed');
  24. }
  25. /**
  26. * Throws an exception when attempting to attach an unknown portal type.
  27. * @docs-private
  28. */
  29. function throwUnknownPortalTypeError() {
  30. throw Error('Attempting to attach an unknown Portal type. BasePortalOutlet accepts either ' +
  31. 'a ComponentPortal or a TemplatePortal.');
  32. }
  33. /**
  34. * Throws an exception when attempting to attach a portal to a null host.
  35. * @docs-private
  36. */
  37. function throwNullPortalOutletError() {
  38. throw Error('Attempting to attach a portal to a null PortalOutlet');
  39. }
  40. /**
  41. * Throws an exception when attempting to detach a portal that is not attached.
  42. * @docs-private
  43. */
  44. function throwNoPortalAttachedError() {
  45. throw Error('Attempting to detach a portal that is not attached to a host');
  46. }
  47. /**
  48. * A `Portal` is something that you want to render somewhere else.
  49. * It can be attach to / detached from a `PortalOutlet`.
  50. */
  51. class Portal {
  52. _attachedHost;
  53. /** Attach this portal to a host. */
  54. attach(host) {
  55. if (typeof ngDevMode === 'undefined' || ngDevMode) {
  56. if (host == null) {
  57. throwNullPortalOutletError();
  58. }
  59. if (host.hasAttached()) {
  60. throwPortalAlreadyAttachedError();
  61. }
  62. }
  63. this._attachedHost = host;
  64. return host.attach(this);
  65. }
  66. /** Detach this portal from its host */
  67. detach() {
  68. let host = this._attachedHost;
  69. if (host != null) {
  70. this._attachedHost = null;
  71. host.detach();
  72. }
  73. else if (typeof ngDevMode === 'undefined' || ngDevMode) {
  74. throwNoPortalAttachedError();
  75. }
  76. }
  77. /** Whether this portal is attached to a host. */
  78. get isAttached() {
  79. return this._attachedHost != null;
  80. }
  81. /**
  82. * Sets the PortalOutlet reference without performing `attach()`. This is used directly by
  83. * the PortalOutlet when it is performing an `attach()` or `detach()`.
  84. */
  85. setAttachedHost(host) {
  86. this._attachedHost = host;
  87. }
  88. }
  89. /**
  90. * A `ComponentPortal` is a portal that instantiates some Component upon attachment.
  91. */
  92. class ComponentPortal extends Portal {
  93. /** The type of the component that will be instantiated for attachment. */
  94. component;
  95. /**
  96. * Where the attached component should live in Angular's *logical* component tree.
  97. * This is different from where the component *renders*, which is determined by the PortalOutlet.
  98. * The origin is necessary when the host is outside of the Angular application context.
  99. */
  100. viewContainerRef;
  101. /** Injector used for the instantiation of the component. */
  102. injector;
  103. /**
  104. * @deprecated No longer in use. To be removed.
  105. * @breaking-change 18.0.0
  106. */
  107. componentFactoryResolver;
  108. /**
  109. * List of DOM nodes that should be projected through `<ng-content>` of the attached component.
  110. */
  111. projectableNodes;
  112. constructor(component, viewContainerRef, injector,
  113. /**
  114. * @deprecated No longer in use. To be removed.
  115. * @breaking-change 18.0.0
  116. */
  117. _componentFactoryResolver, projectableNodes) {
  118. super();
  119. this.component = component;
  120. this.viewContainerRef = viewContainerRef;
  121. this.injector = injector;
  122. this.projectableNodes = projectableNodes;
  123. }
  124. }
  125. /**
  126. * A `TemplatePortal` is a portal that represents some embedded template (TemplateRef).
  127. */
  128. class TemplatePortal extends Portal {
  129. templateRef;
  130. viewContainerRef;
  131. context;
  132. injector;
  133. constructor(
  134. /** The embedded template that will be used to instantiate an embedded View in the host. */
  135. templateRef,
  136. /** Reference to the ViewContainer into which the template will be stamped out. */
  137. viewContainerRef,
  138. /** Contextual data to be passed in to the embedded view. */
  139. context,
  140. /** The injector to use for the embedded view. */
  141. injector) {
  142. super();
  143. this.templateRef = templateRef;
  144. this.viewContainerRef = viewContainerRef;
  145. this.context = context;
  146. this.injector = injector;
  147. }
  148. get origin() {
  149. return this.templateRef.elementRef;
  150. }
  151. /**
  152. * Attach the portal to the provided `PortalOutlet`.
  153. * When a context is provided it will override the `context` property of the `TemplatePortal`
  154. * instance.
  155. */
  156. attach(host, context = this.context) {
  157. this.context = context;
  158. return super.attach(host);
  159. }
  160. detach() {
  161. this.context = undefined;
  162. return super.detach();
  163. }
  164. }
  165. /**
  166. * A `DomPortal` is a portal whose DOM element will be taken from its current position
  167. * in the DOM and moved into a portal outlet, when it is attached. On detach, the content
  168. * will be restored to its original position.
  169. */
  170. class DomPortal extends Portal {
  171. /** DOM node hosting the portal's content. */
  172. element;
  173. constructor(element) {
  174. super();
  175. this.element = element instanceof ElementRef ? element.nativeElement : element;
  176. }
  177. }
  178. /**
  179. * Partial implementation of PortalOutlet that handles attaching
  180. * ComponentPortal and TemplatePortal.
  181. */
  182. class BasePortalOutlet {
  183. /** The portal currently attached to the host. */
  184. _attachedPortal;
  185. /** A function that will permanently dispose this host. */
  186. _disposeFn;
  187. /** Whether this host has already been permanently disposed. */
  188. _isDisposed = false;
  189. /** Whether this host has an attached portal. */
  190. hasAttached() {
  191. return !!this._attachedPortal;
  192. }
  193. /** Attaches a portal. */
  194. attach(portal) {
  195. if (typeof ngDevMode === 'undefined' || ngDevMode) {
  196. if (!portal) {
  197. throwNullPortalError();
  198. }
  199. if (this.hasAttached()) {
  200. throwPortalAlreadyAttachedError();
  201. }
  202. if (this._isDisposed) {
  203. throwPortalOutletAlreadyDisposedError();
  204. }
  205. }
  206. if (portal instanceof ComponentPortal) {
  207. this._attachedPortal = portal;
  208. return this.attachComponentPortal(portal);
  209. }
  210. else if (portal instanceof TemplatePortal) {
  211. this._attachedPortal = portal;
  212. return this.attachTemplatePortal(portal);
  213. // @breaking-change 10.0.0 remove null check for `this.attachDomPortal`.
  214. }
  215. else if (this.attachDomPortal && portal instanceof DomPortal) {
  216. this._attachedPortal = portal;
  217. return this.attachDomPortal(portal);
  218. }
  219. if (typeof ngDevMode === 'undefined' || ngDevMode) {
  220. throwUnknownPortalTypeError();
  221. }
  222. }
  223. // @breaking-change 10.0.0 `attachDomPortal` to become a required abstract method.
  224. attachDomPortal = null;
  225. /** Detaches a previously attached portal. */
  226. detach() {
  227. if (this._attachedPortal) {
  228. this._attachedPortal.setAttachedHost(null);
  229. this._attachedPortal = null;
  230. }
  231. this._invokeDisposeFn();
  232. }
  233. /** Permanently dispose of this portal host. */
  234. dispose() {
  235. if (this.hasAttached()) {
  236. this.detach();
  237. }
  238. this._invokeDisposeFn();
  239. this._isDisposed = true;
  240. }
  241. /** @docs-private */
  242. setDisposeFn(fn) {
  243. this._disposeFn = fn;
  244. }
  245. _invokeDisposeFn() {
  246. if (this._disposeFn) {
  247. this._disposeFn();
  248. this._disposeFn = null;
  249. }
  250. }
  251. }
  252. /**
  253. * @deprecated Use `BasePortalOutlet` instead.
  254. * @breaking-change 9.0.0
  255. */
  256. class BasePortalHost extends BasePortalOutlet {
  257. }
  258. /**
  259. * A PortalOutlet for attaching portals to an arbitrary DOM element outside of the Angular
  260. * application context.
  261. */
  262. class DomPortalOutlet extends BasePortalOutlet {
  263. outletElement;
  264. _appRef;
  265. _defaultInjector;
  266. _document;
  267. /**
  268. * @param outletElement Element into which the content is projected.
  269. * @param _unusedComponentFactoryResolver Used to resolve the component factory.
  270. * Only required when attaching component portals.
  271. * @param _appRef Reference to the application. Only used in component portals when there
  272. * is no `ViewContainerRef` available.
  273. * @param _defaultInjector Injector to use as a fallback when the portal being attached doesn't
  274. * have one. Only used for component portals.
  275. * @param _document Reference to the document. Used when attaching a DOM portal. Will eventually
  276. * become a required parameter.
  277. */
  278. constructor(
  279. /** Element into which the content is projected. */
  280. outletElement,
  281. /**
  282. * @deprecated No longer in use. To be removed.
  283. * @breaking-change 18.0.0
  284. */
  285. _unusedComponentFactoryResolver, _appRef, _defaultInjector,
  286. /**
  287. * @deprecated `_document` Parameter to be made required.
  288. * @breaking-change 10.0.0
  289. */
  290. _document) {
  291. super();
  292. this.outletElement = outletElement;
  293. this._appRef = _appRef;
  294. this._defaultInjector = _defaultInjector;
  295. this._document = _document;
  296. }
  297. /**
  298. * Attach the given ComponentPortal to DOM element.
  299. * @param portal Portal to be attached
  300. * @returns Reference to the created component.
  301. */
  302. attachComponentPortal(portal) {
  303. let componentRef;
  304. // If the portal specifies a ViewContainerRef, we will use that as the attachment point
  305. // for the component (in terms of Angular's component tree, not rendering).
  306. // When the ViewContainerRef is missing, we use the factory to create the component directly
  307. // and then manually attach the view to the application.
  308. if (portal.viewContainerRef) {
  309. const injector = portal.injector || portal.viewContainerRef.injector;
  310. const ngModuleRef = injector.get(NgModuleRef, null, { optional: true }) || undefined;
  311. componentRef = portal.viewContainerRef.createComponent(portal.component, {
  312. index: portal.viewContainerRef.length,
  313. injector,
  314. ngModuleRef,
  315. projectableNodes: portal.projectableNodes || undefined,
  316. });
  317. this.setDisposeFn(() => componentRef.destroy());
  318. }
  319. else {
  320. if ((typeof ngDevMode === 'undefined' || ngDevMode) && !this._appRef) {
  321. throw Error('Cannot attach component portal to outlet without an ApplicationRef.');
  322. }
  323. const appRef = this._appRef;
  324. const elementInjector = portal.injector || this._defaultInjector || Injector.NULL;
  325. const environmentInjector = elementInjector.get(EnvironmentInjector, appRef.injector);
  326. componentRef = createComponent(portal.component, {
  327. elementInjector,
  328. environmentInjector,
  329. projectableNodes: portal.projectableNodes || undefined,
  330. });
  331. appRef.attachView(componentRef.hostView);
  332. this.setDisposeFn(() => {
  333. // Verify that the ApplicationRef has registered views before trying to detach a host view.
  334. // This check also protects the `detachView` from being called on a destroyed ApplicationRef.
  335. if (appRef.viewCount > 0) {
  336. appRef.detachView(componentRef.hostView);
  337. }
  338. componentRef.destroy();
  339. });
  340. }
  341. // At this point the component has been instantiated, so we move it to the location in the DOM
  342. // where we want it to be rendered.
  343. this.outletElement.appendChild(this._getComponentRootNode(componentRef));
  344. this._attachedPortal = portal;
  345. return componentRef;
  346. }
  347. /**
  348. * Attaches a template portal to the DOM as an embedded view.
  349. * @param portal Portal to be attached.
  350. * @returns Reference to the created embedded view.
  351. */
  352. attachTemplatePortal(portal) {
  353. let viewContainer = portal.viewContainerRef;
  354. let viewRef = viewContainer.createEmbeddedView(portal.templateRef, portal.context, {
  355. injector: portal.injector,
  356. });
  357. // The method `createEmbeddedView` will add the view as a child of the viewContainer.
  358. // But for the DomPortalOutlet the view can be added everywhere in the DOM
  359. // (e.g Overlay Container) To move the view to the specified host element. We just
  360. // re-append the existing root nodes.
  361. viewRef.rootNodes.forEach(rootNode => this.outletElement.appendChild(rootNode));
  362. // Note that we want to detect changes after the nodes have been moved so that
  363. // any directives inside the portal that are looking at the DOM inside a lifecycle
  364. // hook won't be invoked too early.
  365. viewRef.detectChanges();
  366. this.setDisposeFn(() => {
  367. let index = viewContainer.indexOf(viewRef);
  368. if (index !== -1) {
  369. viewContainer.remove(index);
  370. }
  371. });
  372. this._attachedPortal = portal;
  373. // TODO(jelbourn): Return locals from view.
  374. return viewRef;
  375. }
  376. /**
  377. * Attaches a DOM portal by transferring its content into the outlet.
  378. * @param portal Portal to be attached.
  379. * @deprecated To be turned into a method.
  380. * @breaking-change 10.0.0
  381. */
  382. attachDomPortal = (portal) => {
  383. const element = portal.element;
  384. if (!element.parentNode && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  385. throw Error('DOM portal content must be attached to a parent node.');
  386. }
  387. // Anchor used to save the element's previous position so
  388. // that we can restore it when the portal is detached.
  389. const anchorNode = this._document.createComment('dom-portal');
  390. element.parentNode.insertBefore(anchorNode, element);
  391. this.outletElement.appendChild(element);
  392. this._attachedPortal = portal;
  393. super.setDisposeFn(() => {
  394. // We can't use `replaceWith` here because IE doesn't support it.
  395. if (anchorNode.parentNode) {
  396. anchorNode.parentNode.replaceChild(element, anchorNode);
  397. }
  398. });
  399. };
  400. /**
  401. * Clears out a portal from the DOM.
  402. */
  403. dispose() {
  404. super.dispose();
  405. this.outletElement.remove();
  406. }
  407. /** Gets the root HTMLElement for an instantiated component. */
  408. _getComponentRootNode(componentRef) {
  409. return componentRef.hostView.rootNodes[0];
  410. }
  411. }
  412. /**
  413. * @deprecated Use `DomPortalOutlet` instead.
  414. * @breaking-change 9.0.0
  415. */
  416. class DomPortalHost extends DomPortalOutlet {
  417. }
  418. /**
  419. * Directive version of a `TemplatePortal`. Because the directive *is* a TemplatePortal,
  420. * the directive instance itself can be attached to a host, enabling declarative use of portals.
  421. */
  422. class CdkPortal extends TemplatePortal {
  423. constructor() {
  424. const templateRef = inject(TemplateRef);
  425. const viewContainerRef = inject(ViewContainerRef);
  426. super(templateRef, viewContainerRef);
  427. }
  428. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: CdkPortal, deps: [], target: i0.ɵɵFactoryTarget.Directive });
  429. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: CdkPortal, isStandalone: true, selector: "[cdkPortal]", exportAs: ["cdkPortal"], usesInheritance: true, ngImport: i0 });
  430. }
  431. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: CdkPortal, decorators: [{
  432. type: Directive,
  433. args: [{
  434. selector: '[cdkPortal]',
  435. exportAs: 'cdkPortal',
  436. }]
  437. }], ctorParameters: () => [] });
  438. /**
  439. * @deprecated Use `CdkPortal` instead.
  440. * @breaking-change 9.0.0
  441. */
  442. class TemplatePortalDirective extends CdkPortal {
  443. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TemplatePortalDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
  444. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: TemplatePortalDirective, isStandalone: true, selector: "[cdk-portal], [portal]", providers: [
  445. {
  446. provide: CdkPortal,
  447. useExisting: TemplatePortalDirective,
  448. },
  449. ], exportAs: ["cdkPortal"], usesInheritance: true, ngImport: i0 });
  450. }
  451. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TemplatePortalDirective, decorators: [{
  452. type: Directive,
  453. args: [{
  454. selector: '[cdk-portal], [portal]',
  455. exportAs: 'cdkPortal',
  456. providers: [
  457. {
  458. provide: CdkPortal,
  459. useExisting: TemplatePortalDirective,
  460. },
  461. ],
  462. }]
  463. }] });
  464. /**
  465. * Directive version of a PortalOutlet. Because the directive *is* a PortalOutlet, portals can be
  466. * directly attached to it, enabling declarative use.
  467. *
  468. * Usage:
  469. * `<ng-template [cdkPortalOutlet]="greeting"></ng-template>`
  470. */
  471. class CdkPortalOutlet extends BasePortalOutlet {
  472. _moduleRef = inject(NgModuleRef, { optional: true });
  473. _document = inject(DOCUMENT);
  474. _viewContainerRef = inject(ViewContainerRef);
  475. /** Whether the portal component is initialized. */
  476. _isInitialized = false;
  477. /** Reference to the currently-attached component/view ref. */
  478. _attachedRef;
  479. constructor() {
  480. super();
  481. }
  482. /** Portal associated with the Portal outlet. */
  483. get portal() {
  484. return this._attachedPortal;
  485. }
  486. set portal(portal) {
  487. // Ignore the cases where the `portal` is set to a falsy value before the lifecycle hooks have
  488. // run. This handles the cases where the user might do something like `<div cdkPortalOutlet>`
  489. // and attach a portal programmatically in the parent component. When Angular does the first CD
  490. // round, it will fire the setter with empty string, causing the user's content to be cleared.
  491. if (this.hasAttached() && !portal && !this._isInitialized) {
  492. return;
  493. }
  494. if (this.hasAttached()) {
  495. super.detach();
  496. }
  497. if (portal) {
  498. super.attach(portal);
  499. }
  500. this._attachedPortal = portal || null;
  501. }
  502. /** Emits when a portal is attached to the outlet. */
  503. attached = new EventEmitter();
  504. /** Component or view reference that is attached to the portal. */
  505. get attachedRef() {
  506. return this._attachedRef;
  507. }
  508. ngOnInit() {
  509. this._isInitialized = true;
  510. }
  511. ngOnDestroy() {
  512. super.dispose();
  513. this._attachedRef = this._attachedPortal = null;
  514. }
  515. /**
  516. * Attach the given ComponentPortal to this PortalOutlet.
  517. *
  518. * @param portal Portal to be attached to the portal outlet.
  519. * @returns Reference to the created component.
  520. */
  521. attachComponentPortal(portal) {
  522. portal.setAttachedHost(this);
  523. // If the portal specifies an origin, use that as the logical location of the component
  524. // in the application tree. Otherwise use the location of this PortalOutlet.
  525. const viewContainerRef = portal.viewContainerRef != null ? portal.viewContainerRef : this._viewContainerRef;
  526. const ref = viewContainerRef.createComponent(portal.component, {
  527. index: viewContainerRef.length,
  528. injector: portal.injector || viewContainerRef.injector,
  529. projectableNodes: portal.projectableNodes || undefined,
  530. ngModuleRef: this._moduleRef || undefined,
  531. });
  532. // If we're using a view container that's different from the injected one (e.g. when the portal
  533. // specifies its own) we need to move the component into the outlet, otherwise it'll be rendered
  534. // inside of the alternate view container.
  535. if (viewContainerRef !== this._viewContainerRef) {
  536. this._getRootNode().appendChild(ref.hostView.rootNodes[0]);
  537. }
  538. super.setDisposeFn(() => ref.destroy());
  539. this._attachedPortal = portal;
  540. this._attachedRef = ref;
  541. this.attached.emit(ref);
  542. return ref;
  543. }
  544. /**
  545. * Attach the given TemplatePortal to this PortalHost as an embedded View.
  546. * @param portal Portal to be attached.
  547. * @returns Reference to the created embedded view.
  548. */
  549. attachTemplatePortal(portal) {
  550. portal.setAttachedHost(this);
  551. const viewRef = this._viewContainerRef.createEmbeddedView(portal.templateRef, portal.context, {
  552. injector: portal.injector,
  553. });
  554. super.setDisposeFn(() => this._viewContainerRef.clear());
  555. this._attachedPortal = portal;
  556. this._attachedRef = viewRef;
  557. this.attached.emit(viewRef);
  558. return viewRef;
  559. }
  560. /**
  561. * Attaches the given DomPortal to this PortalHost by moving all of the portal content into it.
  562. * @param portal Portal to be attached.
  563. * @deprecated To be turned into a method.
  564. * @breaking-change 10.0.0
  565. */
  566. attachDomPortal = (portal) => {
  567. const element = portal.element;
  568. if (!element.parentNode && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  569. throw Error('DOM portal content must be attached to a parent node.');
  570. }
  571. // Anchor used to save the element's previous position so
  572. // that we can restore it when the portal is detached.
  573. const anchorNode = this._document.createComment('dom-portal');
  574. portal.setAttachedHost(this);
  575. element.parentNode.insertBefore(anchorNode, element);
  576. this._getRootNode().appendChild(element);
  577. this._attachedPortal = portal;
  578. super.setDisposeFn(() => {
  579. if (anchorNode.parentNode) {
  580. anchorNode.parentNode.replaceChild(element, anchorNode);
  581. }
  582. });
  583. };
  584. /** Gets the root node of the portal outlet. */
  585. _getRootNode() {
  586. const nativeElement = this._viewContainerRef.element.nativeElement;
  587. // The directive could be set on a template which will result in a comment
  588. // node being the root. Use the comment's parent node if that is the case.
  589. return (nativeElement.nodeType === nativeElement.ELEMENT_NODE
  590. ? nativeElement
  591. : nativeElement.parentNode);
  592. }
  593. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: CdkPortalOutlet, deps: [], target: i0.ɵɵFactoryTarget.Directive });
  594. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: CdkPortalOutlet, isStandalone: true, selector: "[cdkPortalOutlet]", inputs: { portal: ["cdkPortalOutlet", "portal"] }, outputs: { attached: "attached" }, exportAs: ["cdkPortalOutlet"], usesInheritance: true, ngImport: i0 });
  595. }
  596. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: CdkPortalOutlet, decorators: [{
  597. type: Directive,
  598. args: [{
  599. selector: '[cdkPortalOutlet]',
  600. exportAs: 'cdkPortalOutlet',
  601. }]
  602. }], ctorParameters: () => [], propDecorators: { portal: [{
  603. type: Input,
  604. args: ['cdkPortalOutlet']
  605. }], attached: [{
  606. type: Output
  607. }] } });
  608. /**
  609. * @deprecated Use `CdkPortalOutlet` instead.
  610. * @breaking-change 9.0.0
  611. */
  612. class PortalHostDirective extends CdkPortalOutlet {
  613. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: PortalHostDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
  614. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: PortalHostDirective, isStandalone: true, selector: "[cdkPortalHost], [portalHost]", inputs: { portal: ["cdkPortalHost", "portal"] }, providers: [
  615. {
  616. provide: CdkPortalOutlet,
  617. useExisting: PortalHostDirective,
  618. },
  619. ], exportAs: ["cdkPortalHost"], usesInheritance: true, ngImport: i0 });
  620. }
  621. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: PortalHostDirective, decorators: [{
  622. type: Directive,
  623. args: [{
  624. selector: '[cdkPortalHost], [portalHost]',
  625. exportAs: 'cdkPortalHost',
  626. inputs: [{ name: 'portal', alias: 'cdkPortalHost' }],
  627. providers: [
  628. {
  629. provide: CdkPortalOutlet,
  630. useExisting: PortalHostDirective,
  631. },
  632. ],
  633. }]
  634. }] });
  635. class PortalModule {
  636. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: PortalModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  637. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: PortalModule, imports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective], exports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective] });
  638. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: PortalModule });
  639. }
  640. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: PortalModule, decorators: [{
  641. type: NgModule,
  642. args: [{
  643. imports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective],
  644. exports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective],
  645. }]
  646. }] });
  647. export { BasePortalOutlet as B, ComponentPortal as C, DomPortal as D, Portal as P, TemplatePortal as T, BasePortalHost as a, DomPortalOutlet as b, DomPortalHost as c, CdkPortal as d, TemplatePortalDirective as e, CdkPortalOutlet as f, PortalHostDirective as g, PortalModule as h };
  648. //# sourceMappingURL=portal-directives-Bw5woq8I.mjs.map