UNPKG

igniteui-angular-core

Version:

Ignite UI Angular Core logic used in multiple UI components.

153 lines (152 loc) 7.86 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { EventEmitter, ApplicationRef, Component, ViewChild, Input, ChangeDetectionStrategy, ViewContainerRef } from '@angular/core'; import { TypeRegistrar } from './type'; import * as i0 from "@angular/core"; export let IgxComponentRendererContainerComponent = /*@__PURE__*/ (() => { class IgxComponentRendererContainerComponent { constructor(_renderer, _elRef, _ngZone, changeDetector, _componentFactoryResolver, _injector) { this._renderer = _renderer; this._elRef = _elRef; this._ngZone = _ngZone; this.changeDetector = changeDetector; this._componentFactoryResolver = _componentFactoryResolver; this._injector = _injector; this.isAngularHost = true; this.listeners = []; this._currentRoot = null; this._currentRootRef = null; } set height(value) { this._height = value; this._renderer.setStyle(this._elRef.element.nativeElement, "height", value); } get height() { return this._height; } set width(value) { this._width = value; this._renderer.setStyle(this._elRef.element.nativeElement, "width", value); } get width() { return this._width; } static isEvent(ev) { return ev instanceof EventEmitter; } determineInjector(origName, typeName, type) { return this._currentRootRef.injector; } getSpecificAnchor(origName, typeName, type, context) { var _a; var meta = context.getMetadata(origName, "__mustUseNGParentAnchor"); if (meta) { return (_a = this._currentRootRef.instance.anchor) !== null && _a !== void 0 ? _a : this._currentRootRef.instance.___viewContainerRef; } return null; } createObject(type, container, context, portalChildren, nameContext) { var origName = type; var meta = context.getMetadata(type, "__qualifiedNameTS"); if (meta) { type = meta.specificExternalType; } var meta = context.getMetadata(origName, "__qualifiedNameNG"); if (meta) { type = meta.specificExternalType; } let typeName = "Igx" + type + "Component"; if (TypeRegistrar.isRegistered(typeName)) { let C = TypeRegistrar.get(typeName); let cf = this._componentFactoryResolver.resolveComponentFactory(C); let injector = this.determineInjector(origName, typeName, C); let parentViewRef = injector.get(ViewContainerRef); let cr = cf.create(parentViewRef.injector); cr.instance.___owningRef = cr; cr.instance.___parentViewRef = parentViewRef; cr.instance.___hostView = cr.hostView; let specificAnchor = this.getSpecificAnchor(origName, typeName, C, context); if (!specificAnchor) { let appRef = parentViewRef.injector.get(ApplicationRef); appRef.attachView(cr.hostView); this._currentRootRef.changeDetectorRef.detectChanges(); cr.changeDetectorRef.detectChanges(); } else { const domParent = cr.location.nativeElement.parentElement; if (domParent) { const nextSibling = cr.location.nativeElement.nextSibling; specificAnchor.insert(cr.hostView); domParent.insertBefore(cr.hostView, nextSibling); } else { specificAnchor.insert(cr.hostView); } this._currentRootRef.changeDetectorRef.detectChanges(); } return cr.instance; } return null; } replaceRootItem(t, deferAttach, continueActions) { if (this._currentRoot != null) { if (this._currentRootRef) { this._currentRootRef.destroy(); this._currentRootRef = null; this._currentRoot = null; } } let cf = this._componentFactoryResolver.resolveComponentFactory(t); let cr = this._dynamicContent.createComponent(cf); this._currentRootRef = cr; this._currentRoot = cr.instance; this.changeDetector.detectChanges(); cr.instance.___owningRef = cr; cr.instance.___viewContainerRef = cr.injector.get(ViewContainerRef); this._currentRoot.width = "100%"; this._currentRoot.height = "100%"; continueActions(false); } clearContainer(continueActions) { if (this._currentRootRef) { this._currentRootRef.destroy(); this._currentRootRef = null; this._currentRoot = null; } continueActions(false); } getRootObject() { return this._currentRoot; } } IgxComponentRendererContainerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxComponentRendererContainerComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }, { token: i0.ComponentFactoryResolver }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component }); IgxComponentRendererContainerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: IgxComponentRendererContainerComponent, selector: "igx-component-renderer-container", inputs: { height: "height", width: "width" }, viewQueries: [{ propertyName: "_dynamicContent", first: true, predicate: ["dynamicContent"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: ` <ng-container #dynamicContent></ng-container> `, isInline: true, styles: ["\n :host {\n display: block;\n }"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); return IgxComponentRendererContainerComponent; })(); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxComponentRendererContainerComponent, decorators: [{ type: Component, args: [{ selector: 'igx-component-renderer-container', changeDetection: ChangeDetectionStrategy.OnPush, template: ` <ng-container #dynamicContent></ng-container> `, styles: [` :host { display: block; }`] }] }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ViewContainerRef }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }, { type: i0.ComponentFactoryResolver }, { type: i0.Injector }]; }, propDecorators: { height: [{ type: Input }], width: [{ type: Input }], _dynamicContent: [{ type: ViewChild, args: ["dynamicContent", { read: ViewContainerRef, static: true }] }] } });