blob: f576857be79bca187cb23a4e91872209bf5d2755 [file] [log] [blame]
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define("@angular/cdk/portal",["exports","@angular/core","@angular/common"],e):e(((t=t||self).ng=t.ng||{},t.ng.cdk=t.ng.cdk||{},t.ng.cdk.portal={}),t.ng.core,t.ng.common)}(this,(function(t,e,o){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var a=function(){function t(){}return t.prototype.attach=function(t){return this._attachedHost=t,t.attach(this)},t.prototype.detach=function(){var t=this._attachedHost;null!=t&&(this._attachedHost=null,t.detach())},Object.defineProperty(t.prototype,"isAttached",{get:function(){return null!=this._attachedHost},enumerable:!1,configurable:!0}),t.prototype.setAttachedHost=function(t){this._attachedHost=t},t}(),i=function(t){function e(e,o,n,r){var a=t.call(this)||this;return a.component=e,a.viewContainerRef=o,a.injector=n,a.componentFactoryResolver=r,a}return r(e,t),e}(a),c=function(t){function e(e,o,n){var r=t.call(this)||this;return r.templateRef=e,r.viewContainerRef=o,r.context=n,r}return r(e,t),Object.defineProperty(e.prototype,"origin",{get:function(){return this.templateRef.elementRef},enumerable:!1,configurable:!0}),e.prototype.attach=function(e,o){return void 0===o&&(o=this.context),this.context=o,t.prototype.attach.call(this,e)},e.prototype.detach=function(){return this.context=void 0,t.prototype.detach.call(this)},e}(a),s=function(t){function o(o){var n=t.call(this)||this;return n.element=o instanceof e.ElementRef?o.nativeElement:o,n}return r(o,t),o}(a),l=function(){function t(){this._isDisposed=!1,this.attachDomPortal=null}return t.prototype.hasAttached=function(){return!!this._attachedPortal},t.prototype.attach=function(t){return t instanceof i?(this._attachedPortal=t,this.attachComponentPortal(t)):t instanceof c?(this._attachedPortal=t,this.attachTemplatePortal(t)):this.attachDomPortal&&t instanceof s?(this._attachedPortal=t,this.attachDomPortal(t)):void 0},t.prototype.detach=function(){this._attachedPortal&&(this._attachedPortal.setAttachedHost(null),this._attachedPortal=null),this._invokeDisposeFn()},t.prototype.dispose=function(){this.hasAttached()&&this.detach(),this._invokeDisposeFn(),this._isDisposed=!0},t.prototype.setDisposeFn=function(t){this._disposeFn=t},t.prototype._invokeDisposeFn=function(){this._disposeFn&&(this._disposeFn(),this._disposeFn=null)},t}(),p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(l),h=function(t){function e(e,o,n,r,a){var i=t.call(this)||this;return i.outletElement=e,i._componentFactoryResolver=o,i._appRef=n,i._defaultInjector=r,i.attachDomPortal=function(e){var o=e.element,n=i._document.createComment("dom-portal");o.parentNode.insertBefore(n,o),i.outletElement.appendChild(o),i._attachedPortal=e,t.prototype.setDisposeFn.call(i,(function(){n.parentNode&&n.parentNode.replaceChild(o,n)}))},i._document=a,i}return r(e,t),e.prototype.attachComponentPortal=function(t){var e,o=this,n=(t.componentFactoryResolver||this._componentFactoryResolver).resolveComponentFactory(t.component);return t.viewContainerRef?(e=t.viewContainerRef.createComponent(n,t.viewContainerRef.length,t.injector||t.viewContainerRef.injector),this.setDisposeFn((function(){return e.destroy()}))):(e=n.create(t.injector||this._defaultInjector),this._appRef.attachView(e.hostView),this.setDisposeFn((function(){o._appRef.detachView(e.hostView),e.destroy()}))),this.outletElement.appendChild(this._getComponentRootNode(e)),this._attachedPortal=t,e},e.prototype.attachTemplatePortal=function(t){var e=this,o=t.viewContainerRef,n=o.createEmbeddedView(t.templateRef,t.context);return n.rootNodes.forEach((function(t){return e.outletElement.appendChild(t)})),n.detectChanges(),this.setDisposeFn((function(){var t=o.indexOf(n);-1!==t&&o.remove(t)})),this._attachedPortal=t,n},e.prototype.dispose=function(){t.prototype.dispose.call(this),null!=this.outletElement.parentNode&&this.outletElement.parentNode.removeChild(this.outletElement)},e.prototype._getComponentRootNode=function(t){return t.hostView.rootNodes[0]},e}(l),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(h),d=function(t){function e(e,o){return t.call(this,e,o)||this}return r(e,t),e}(c);d.decorators=[{type:e.Directive,args:[{selector:"[cdkPortal]",exportAs:"cdkPortal"}]}],d.ctorParameters=function(){return[{type:e.TemplateRef},{type:e.ViewContainerRef}]};var f=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(d);f.decorators=[{type:e.Directive,args:[{selector:"[cdk-portal], [portal]",exportAs:"cdkPortal",providers:[{provide:d,useExisting:f}]}]}];var m=function(t){function o(o,n,r){var a=t.call(this)||this;return a._componentFactoryResolver=o,a._viewContainerRef=n,a._isInitialized=!1,a.attached=new e.EventEmitter,a.attachDomPortal=function(e){var o=e.element,n=a._document.createComment("dom-portal");e.setAttachedHost(a),o.parentNode.insertBefore(n,o),a._getRootNode().appendChild(o),a._attachedPortal=e,t.prototype.setDisposeFn.call(a,(function(){n.parentNode&&n.parentNode.replaceChild(o,n)}))},a._document=r,a}return r(o,t),Object.defineProperty(o.prototype,"portal",{get:function(){return this._attachedPortal},set:function(e){(!this.hasAttached()||e||this._isInitialized)&&(this.hasAttached()&&t.prototype.detach.call(this),e&&t.prototype.attach.call(this,e),this._attachedPortal=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"attachedRef",{get:function(){return this._attachedRef},enumerable:!1,configurable:!0}),o.prototype.ngOnInit=function(){this._isInitialized=!0},o.prototype.ngOnDestroy=function(){t.prototype.dispose.call(this),this._attachedPortal=null,this._attachedRef=null},o.prototype.attachComponentPortal=function(e){e.setAttachedHost(this);var o=null!=e.viewContainerRef?e.viewContainerRef:this._viewContainerRef,n=(e.componentFactoryResolver||this._componentFactoryResolver).resolveComponentFactory(e.component),r=o.createComponent(n,o.length,e.injector||o.injector);return o!==this._viewContainerRef&&this._getRootNode().appendChild(r.hostView.rootNodes[0]),t.prototype.setDisposeFn.call(this,(function(){return r.destroy()})),this._attachedPortal=e,this._attachedRef=r,this.attached.emit(r),r},o.prototype.attachTemplatePortal=function(e){var o=this;e.setAttachedHost(this);var n=this._viewContainerRef.createEmbeddedView(e.templateRef,e.context);return t.prototype.setDisposeFn.call(this,(function(){return o._viewContainerRef.clear()})),this._attachedPortal=e,this._attachedRef=n,this.attached.emit(n),n},o.prototype._getRootNode=function(){var t=this._viewContainerRef.element.nativeElement;return t.nodeType===t.ELEMENT_NODE?t:t.parentNode},o}(l);m.decorators=[{type:e.Directive,args:[{selector:"[cdkPortalOutlet]",exportAs:"cdkPortalOutlet",inputs:["portal: cdkPortalOutlet"]}]}],m.ctorParameters=function(){return[{type:e.ComponentFactoryResolver},{type:e.ViewContainerRef},{type:void 0,decorators:[{type:e.Inject,args:[o.DOCUMENT]}]}]},m.propDecorators={attached:[{type:e.Output}]};var y,_=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(m);_.decorators=[{type:e.Directive,args:[{selector:"[cdkPortalHost], [portalHost]",exportAs:"cdkPortalHost",inputs:["portal: cdkPortalHost"],providers:[{provide:m,useExisting:_}]}]}],(y=function y(){}).decorators=[{type:e.NgModule,args:[{exports:[d,m,f,_],declarations:[d,m,f,_]}]}];
/**
* @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
*/
var v=function(){function t(t,e){this._parentInjector=t,this._customTokens=e}return t.prototype.get=function(t,e){var o=this._customTokens.get(t);return void 0!==o?o:this._parentInjector.get(t,e)},t}();
/**
* @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
*/t.BasePortalHost=p,t.BasePortalOutlet=l,t.CdkPortal=d,t.CdkPortalOutlet=m,t.ComponentPortal=i,t.DomPortal=s,t.DomPortalHost=u,t.DomPortalOutlet=h,t.Portal=a,t.PortalHostDirective=_,t.PortalInjector=v,t.PortalModule=y,t.TemplatePortal=c,t.TemplatePortalDirective=f,Object.defineProperty(t,"__esModule",{value:!0})}));