UNPKG

md2

Version:

Angular2 based Material Design components, directives and services are Accordion, Autocomplete, Chips(Tags), Collapse, Colorpicker, Data Table, Datepicker, Dialog(Modal), Menu, Multiselect, Select, Tabs, Tags(Chips), Toast and Tooltip.

148 lines 6.34 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { NgModule, Directive, TemplateRef, ComponentFactoryResolver, ViewContainerRef, Input, } from '@angular/core'; import { TemplatePortal, BasePortalHost } from './portal'; /** * Directive version of a `TemplatePortal`. Because the directive *is* a TemplatePortal, * the directive instance itself can be attached to a host, enabling declarative use of portals. * * Usage: * <ng-template portal #greeting> * <p> Hello {{name}} </p> * </ng-template> */ var TemplatePortalDirective = (function (_super) { __extends(TemplatePortalDirective, _super); function TemplatePortalDirective(templateRef, viewContainerRef) { return _super.call(this, templateRef, viewContainerRef) || this; } return TemplatePortalDirective; }(TemplatePortal)); TemplatePortalDirective = __decorate([ Directive({ selector: '[cdk-portal], [cdkPortal], [portal]', exportAs: 'cdkPortal', }), __metadata("design:paramtypes", [TemplateRef, ViewContainerRef]) ], TemplatePortalDirective); export { TemplatePortalDirective }; /** * Directive version of a PortalHost. Because the directive *is* a PortalHost, portals can be * directly attached to it, enabling declarative use. * * Usage: * <ng-template [cdkPortalHost]="greeting"></ng-template> */ var PortalHostDirective = (function (_super) { __extends(PortalHostDirective, _super); function PortalHostDirective(_componentFactoryResolver, _viewContainerRef) { var _this = _super.call(this) || this; _this._componentFactoryResolver = _componentFactoryResolver; _this._viewContainerRef = _viewContainerRef; return _this; } Object.defineProperty(PortalHostDirective.prototype, "_deprecatedPortal", { /** @deprecated */ get: function () { return this.portal; }, set: function (v) { this.portal = v; }, enumerable: true, configurable: true }); Object.defineProperty(PortalHostDirective.prototype, "portal", { /** Portal associated with the Portal host. */ get: function () { return this._portal; }, set: function (portal) { if (this.hasAttached()) { _super.prototype.detach.call(this); } if (portal) { _super.prototype.attach.call(this, portal); } this._portal = portal; }, enumerable: true, configurable: true }); PortalHostDirective.prototype.ngOnDestroy = function () { _super.prototype.dispose.call(this); this._portal = null; }; /** * Attach the given ComponentPortal to this PortalHost using the ComponentFactoryResolver. * * @param portal Portal to be attached to the portal host. */ PortalHostDirective.prototype.attachComponentPortal = function (portal) { portal.setAttachedHost(this); // If the portal specifies an origin, use that as the logical location of the component // in the application tree. Otherwise use the location of this PortalHost. var viewContainerRef = portal.viewContainerRef != null ? portal.viewContainerRef : this._viewContainerRef; var componentFactory = this._componentFactoryResolver.resolveComponentFactory(portal.component); var ref = viewContainerRef.createComponent(componentFactory, viewContainerRef.length, portal.injector || viewContainerRef.parentInjector); _super.prototype.setDisposeFn.call(this, function () { return ref.destroy(); }); this._portal = portal; return ref; }; /** * Attach the given TemplatePortal to this PortlHost as an embedded View. * @param portal Portal to be attached. */ PortalHostDirective.prototype.attachTemplatePortal = function (portal) { var _this = this; portal.setAttachedHost(this); this._viewContainerRef.createEmbeddedView(portal.templateRef); _super.prototype.setDisposeFn.call(this, function () { return _this._viewContainerRef.clear(); }); this._portal = portal; // TODO(jelbourn): return locals from view return new Map(); }; return PortalHostDirective; }(BasePortalHost)); __decorate([ Input('portalHost'), __metadata("design:type", Object), __metadata("design:paramtypes", [Object]) ], PortalHostDirective.prototype, "_deprecatedPortal", null); PortalHostDirective = __decorate([ Directive({ selector: '[cdkPortalHost], [portalHost]', inputs: ['portal: cdkPortalHost'] }), __metadata("design:paramtypes", [ComponentFactoryResolver, ViewContainerRef]) ], PortalHostDirective); export { PortalHostDirective }; var PortalModule = (function () { function PortalModule() { } return PortalModule; }()); PortalModule = __decorate([ NgModule({ exports: [TemplatePortalDirective, PortalHostDirective], declarations: [TemplatePortalDirective, PortalHostDirective], }) ], PortalModule); export { PortalModule }; //# sourceMappingURL=portal-directives.js.map