igniteui-angular-core
Version:
Ignite UI Angular Core logic used in multiple UI components.
681 lines (677 loc) • 26.5 kB
JavaScript
import { Output, TemplateRef, EventEmitter, Component, ViewContainerRef, ViewChild, ElementRef, Input, ChangeDetectionStrategy } from '@angular/core';
import { toRect, ensureEnum, brushToString, stringToBrush, ensureBool, toSpinal, initializePropertiesFromCss, NamePatcher } from "./componentUtil";
import { AngularRenderer, PortalManager } from "./angular-renderer";
import { delegateCombine } from "./type";
import { Popup } from './Popup';
import { IgxOnPopupEventArgs } from './igx-on-popup-event-args';
import { IgxOnClosedEventArgs } from './igx-on-closed-event-args';
import { IgxFocusEventArgs } from './igx-focus-event-args';
import { PopupAnimationType_$type } from "./PopupAnimationType";
import { PopupPointerPosition_$type } from "./PopupPointerPosition";
import { IgxPopupMeasuringContentSizeEventArgs } from './igx-popup-measuring-content-size-event-args';
import * as i0 from "@angular/core";
var IgxPopupComponent = /** @class */ /*@__PURE__*/ (function () {
function IgxPopupComponent(renderer, _elRef, ngZone, injector, componentFactoryResolver) {
this.renderer = renderer;
this._elRef = _elRef;
this.ngZone = ngZone;
this.injector = injector;
this.componentFactoryResolver = componentFactoryResolver;
this._angularRenderer = null;
this._implementation = null;
this._componentFactoryResolver = null;
this._portalManager = null;
this.__p = null;
this._hasUserValues = new Set();
this._stylingContainer = null;
this._stylingParent = null;
this._inStyling = false;
this._onClosed = null;
this._onPopup = null;
this._popupGotFocus = null;
this._popupLostFocus = null;
this._measuringContentSize = null;
this._zoneRunner = null;
this._componentFactoryResolver = componentFactoryResolver;
this._implementation = this.createImplementation();
if (this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this));
}
}
Object.defineProperty(IgxPopupComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = value;
this.i.notifySizeChanged();
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "width", {
get: function () {
return this._width;
},
set: function (value) {
this._width = value;
this.renderer.setStyle(this._elRef.element.nativeElement, "width", value);
this.i.notifySizeChanged();
},
enumerable: false,
configurable: true
});
// supports angular themes or custom properties set in CSS
IgxPopupComponent.prototype.updateStyle = function () {
this._styling(this._mainDiv, this);
};
IgxPopupComponent.prototype.ngOnDestroy = function () {
this.i.destroy();
this._angularRenderer.destroy();
};
IgxPopupComponent.prototype.ngAfterViewInit = function () {
this._mainDiv = this._mainDivRef.nativeElement;
if (this.renderer) {
this._portalManager = new PortalManager("popupContent", this._componentFactoryResolver);
this._angularRenderer = new AngularRenderer(this._mainDiv, this.renderer, window.document, this.ngZone, true, {}, this._portalManager);
this.i.provideRenderer(this._angularRenderer);
this._portalManager.dynamicContent = this._dynamicContent;
this._portalManager.onChildContentChanged(this._childTemplateRef);
}
this.updateStyle();
};
IgxPopupComponent.prototype.ngAfterContentInit = function () {
};
IgxPopupComponent.prototype.createImplementation = function () {
return new Popup();
};
Object.defineProperty(IgxPopupComponent.prototype, "i", {
get: function () {
return this._implementation;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "isFocusable", {
get: function () {
return this.i.as;
},
set: function (v) {
this.i.as = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "animationDuration", {
/**
* Gets or sets the duration of the Popup and Closeup animations in milliseconds.
*/
get: function () {
return this.i.a9;
},
set: function (v) {
this.i.a9 = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "animationEnabled", {
/**
* Gets or sets whether the popup and closeup animations are animated.
*/
get: function () {
return this.i.am;
},
set: function (v) {
this.i.am = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "animationType", {
/**
* Gets or sets the type of animation to use when the popup opens and closes.
*/
get: function () {
return this.i.p;
},
set: function (v) {
this.i.p = ensureEnum(PopupAnimationType_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "elevation", {
/**
* Gets or sets the elevation to use for the button regardless of type.
*/
get: function () {
return this.i.bb;
},
set: function (v) {
this.i.bb = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "actualElevation", {
/**
* Gets or sets the elevation of the border shadow
*/
get: function () {
return this.i.a7;
},
set: function (v) {
this.i.a7 = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "isShown", {
/**
* Gets / sets the isShown state of the panel.
*/
get: function () {
return this.i.ax;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "actualUmbraShadowColor", {
/**
* Gets or sets the color to use for the check mark when the checkbox is checked.
*/
get: function () {
return brushToString(this.i.cz);
},
set: function (v) {
this.i.cz = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "actualPenumbraShadowColor", {
/**
* Gets or sets the color to use for the check mark when the checkbox is checked.
*/
get: function () {
return brushToString(this.i.cy);
},
set: function (v) {
this.i.cy = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "actualAmbientShadowColor", {
/**
* Gets or sets the color to use for the check mark when the checkbox is checked.
*/
get: function () {
return brushToString(this.i.cx);
},
set: function (v) {
this.i.cx = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "background", {
/**
* Gets or sets the background color of the popup.
*/
get: function () {
return brushToString(this.i.c0);
},
set: function (v) {
this.i.c0 = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "cornerRadius", {
get: function () {
return this.i.a1;
},
set: function (v) {
this.i.a1 = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "isHitTestVisible", {
/**
* Gets or sets whether to disable hit testing on the popup.
*/
get: function () {
return this.i.at;
},
set: function (v) {
this.i.at = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "disableHitTestDuringAnimation", {
/**
* Gets or sets whether to disable hit testing during the open and close animations.
*/
get: function () {
return this.i.ao;
},
set: function (v) {
this.i.ao = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "isPointerEnabled", {
/**
* Gets or sets whether to show a pointer off the side of the popup towards the popup target.
*/
get: function () {
return this.i.au;
},
set: function (v) {
this.i.au = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "pointerPosition", {
/**
* Gets or sets the pointer position.
*/
get: function () {
return this.i.v;
},
set: function (v) {
this.i.v = ensureEnum(PopupPointerPosition_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "pointerBackground", {
/**
* Gets or sets the pointer background color.
*/
get: function () {
return brushToString(this.i.c4);
},
set: function (v) {
this.i.c4 = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "pointerSize", {
/**
* Gets or sets the pointer size.
*/
get: function () {
return this.i.a4;
},
set: function (v) {
this.i.a4 = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "isShowing", {
/**
* Gets whether the popup is in the middle of opening or not.
*/
get: function () {
return this.i.av;
},
set: function (v) {
this.i.av = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "isClosing", {
/**
* Gets whether the popup is in the middle of closing or not.
*/
get: function () {
return this.i.aq;
},
set: function (v) {
this.i.aq = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "isFixed", {
/**
* Indicates that the popup will position itself relative to the window instead of the document.
*/
get: function () {
return this.i.ar;
},
set: function (v) {
this.i.ar = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "useTopLayer", {
/**
* Indicates that the popup will place itself into the browser top layer.
*/
get: function () {
return this.i.ay;
},
set: function (v) {
this.i.ay = ensureBool(v);
},
enumerable: false,
configurable: true
});
IgxPopupComponent.prototype.findByName = function (name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
return null;
};
Object.defineProperty(IgxPopupComponent.prototype, "hasUserValues", {
get: function () {
return this._hasUserValues;
},
enumerable: false,
configurable: true
});
IgxPopupComponent.prototype.__m = function (propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
};
IgxPopupComponent.prototype._styling = function (container, component, parent) {
if (this._inStyling) {
return;
}
this._inStyling = true;
this._stylingContainer = container;
this._stylingParent = component;
var genericPrefix = "";
var typeName = this.i.$type.name;
if (typeName.indexOf("Xam") === 0) {
typeName = typeName.substring(3);
}
genericPrefix = toSpinal("PopupComponent");
var additionalPrefixes = [];
var prefix = toSpinal(typeName);
additionalPrefixes.push(prefix + "-");
var b = this.i.$type.baseType;
while (b && b.name != "Object" &&
b.name != "Base" &&
b.name != "Control" &&
b.Name != "DependencyObject" &&
b.Name != "FrameworkElement") {
typeName = b.name;
if (typeName.indexOf("Xam") === 0) {
typeName = typeName.substring(3);
}
var basePrefix = toSpinal(typeName);
additionalPrefixes.push(basePrefix + "-");
b = b.baseType;
}
if (parent) {
var parentTypeName = parent.i.$type.name;
if (parentTypeName.indexOf("Xam") === 0) {
parentTypeName = parentTypeName.substring(3);
}
var parentPrefix = toSpinal(parentTypeName);
additionalPrefixes.push(parentPrefix + "-" + genericPrefix + "-");
additionalPrefixes.push(parentPrefix + "-" + prefix + "-");
}
initializePropertiesFromCss(container, this, genericPrefix + "-", this.hasUserValues, false, additionalPrefixes);
if (this._otherStyling) {
this._otherStyling(container, component, parent);
}
this._inStyling = false;
};
/**
* Closes the popup.
*/
IgxPopupComponent.prototype.close = function () {
this.i.b6();
};
IgxPopupComponent.prototype.showRelativeToExclusionRect = function (exclusionRect, popupDirection, popupAlignment) {
this.i.showRelativeToExclusionRect(toRect(exclusionRect), (popupDirection == null ? null : popupDirection), (popupAlignment == null ? null : popupAlignment));
};
/**
* Exports visual information about the current state of the grid.
*/
IgxPopupComponent.prototype.exportVisualModel = function () {
var iv = this.i.bd();
return (iv);
};
/**
* Returns a serialized copy of the exported visual model
*/
IgxPopupComponent.prototype.exportSerializedVisualModel = function () {
var iv = this.i.bq();
return (iv);
};
Object.defineProperty(IgxPopupComponent.prototype, "onClosed", {
get: function () {
var _this = this;
if (this._onClosed == null) {
this._onClosed = new EventEmitter();
this.i.onClosed = delegateCombine(this.i.onClosed, function (o, e) {
_this._runInZone(function () {
var outerArgs = new IgxOnClosedEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeOnClosed) {
_this.beforeOnClosed(_this, outerArgs);
}
_this._onClosed.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._onClosed;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "onPopup", {
/**
* Fires when the popup is shown
*/
get: function () {
var _this = this;
if (this._onPopup == null) {
this._onPopup = new EventEmitter();
this.i.onPopup = delegateCombine(this.i.onPopup, function (o, e) {
_this._runInZone(function () {
var outerArgs = new IgxOnPopupEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeOnPopup) {
_this.beforeOnPopup(_this, outerArgs);
}
_this._onPopup.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._onPopup;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "popupGotFocus", {
/**
* Fired when the open popup gains focus.
*/
get: function () {
var _this = this;
if (this._popupGotFocus == null) {
this._popupGotFocus = new EventEmitter();
this.i.popupGotFocus = delegateCombine(this.i.popupGotFocus, function (o, e) {
_this._runInZone(function () {
var outerArgs = new IgxFocusEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforePopupGotFocus) {
_this.beforePopupGotFocus(_this, outerArgs);
}
_this._popupGotFocus.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._popupGotFocus;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "popupLostFocus", {
/**
* Fired when the open popup loses focus.
*/
get: function () {
var _this = this;
if (this._popupLostFocus == null) {
this._popupLostFocus = new EventEmitter();
this.i.popupLostFocus = delegateCombine(this.i.popupLostFocus, function (o, e) {
_this._runInZone(function () {
var outerArgs = new IgxFocusEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforePopupLostFocus) {
_this.beforePopupLostFocus(_this, outerArgs);
}
_this._popupLostFocus.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._popupLostFocus;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxPopupComponent.prototype, "measuringContentSize", {
get: function () {
var _this = this;
if (this._measuringContentSize == null) {
this._measuringContentSize = new EventEmitter();
this.i.measuringContentSize = delegateCombine(this.i.measuringContentSize, function (o, e) {
_this._runInZone(function () {
var outerArgs = new IgxPopupMeasuringContentSizeEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeMeasuringContentSize) {
_this.beforeMeasuringContentSize(_this, outerArgs);
}
_this._measuringContentSize.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._measuringContentSize;
},
enumerable: false,
configurable: true
});
IgxPopupComponent.prototype._runInZone = function (act) {
if (this._zoneRunner != null) {
this._zoneRunner(act);
}
else {
act();
}
};
IgxPopupComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxPopupComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i0.NgZone }, { token: i0.Injector }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component });
IgxPopupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: IgxPopupComponent, selector: "igx-popup", inputs: { height: "height", width: "width", isFocusable: "isFocusable", animationDuration: "animationDuration", animationEnabled: "animationEnabled", animationType: "animationType", elevation: "elevation", actualElevation: "actualElevation", actualUmbraShadowColor: "actualUmbraShadowColor", actualPenumbraShadowColor: "actualPenumbraShadowColor", actualAmbientShadowColor: "actualAmbientShadowColor", background: "background", cornerRadius: "cornerRadius", isHitTestVisible: "isHitTestVisible", disableHitTestDuringAnimation: "disableHitTestDuringAnimation", isPointerEnabled: "isPointerEnabled", pointerPosition: "pointerPosition", pointerBackground: "pointerBackground", pointerSize: "pointerSize", isShowing: "isShowing", isClosing: "isClosing", isFixed: "isFixed", useTopLayer: "useTopLayer" }, outputs: { onClosed: "onClosed", onPopup: "onPopup", popupGotFocus: "popupGotFocus", popupLostFocus: "popupLostFocus", measuringContentSize: "measuringContentSize" }, host: { classAttribute: "ig-popup igx-popup" }, providers: [], viewQueries: [{ propertyName: "_mainDivRef", first: true, predicate: ["mainDivRef"], descendants: true, read: ElementRef, static: true }, { propertyName: "_dynamicContent", first: true, predicate: ["dynamicContent"], descendants: true, read: ViewContainerRef, static: true }, { propertyName: "_childTemplateRef", first: true, predicate: ["childContent"], descendants: true, read: TemplateRef }], ngImport: i0, template: "\n <ng-template #childContent>\n <ng-content></ng-content>\n </ng-template>\n <ng-container #dynamicContent></ng-container>\n <div #mainDivRef> \n\t</div> \n ", isInline: true, styles: ["\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\t"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
return IgxPopupComponent;
}());
export { IgxPopupComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxPopupComponent, decorators: [{
type: Component,
args: [{
selector: 'igx-popup',
template: "\n <ng-template #childContent>\n <ng-content></ng-content>\n </ng-template>\n <ng-container #dynamicContent></ng-container>\n <div #mainDivRef> \n\t</div> \n ",
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [],
host: { 'class': 'ig-popup igx-popup' },
styles: ["\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\t"]
}]
}], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ViewContainerRef }, { type: i0.NgZone }, { type: i0.Injector }, { type: i0.ComponentFactoryResolver }]; }, propDecorators: { _mainDivRef: [{
type: ViewChild,
args: ['mainDivRef', { read: ElementRef, static: true }]
}], _dynamicContent: [{
type: ViewChild,
args: ["dynamicContent", { read: ViewContainerRef, static: true }]
}], _childTemplateRef: [{
type: ViewChild,
args: ["childContent", { read: TemplateRef, static: false }]
}], height: [{
type: Input
}], width: [{
type: Input
}], isFocusable: [{
type: Input
}], animationDuration: [{
type: Input
}], animationEnabled: [{
type: Input
}], animationType: [{
type: Input
}], elevation: [{
type: Input
}], actualElevation: [{
type: Input
}], actualUmbraShadowColor: [{
type: Input
}], actualPenumbraShadowColor: [{
type: Input
}], actualAmbientShadowColor: [{
type: Input
}], background: [{
type: Input
}], cornerRadius: [{
type: Input
}], isHitTestVisible: [{
type: Input
}], disableHitTestDuringAnimation: [{
type: Input
}], isPointerEnabled: [{
type: Input
}], pointerPosition: [{
type: Input
}], pointerBackground: [{
type: Input
}], pointerSize: [{
type: Input
}], isShowing: [{
type: Input
}], isClosing: [{
type: Input
}], isFixed: [{
type: Input
}], useTopLayer: [{
type: Input
}], onClosed: [{
type: Output
}], onPopup: [{
type: Output
}], popupGotFocus: [{
type: Output
}], popupLostFocus: [{
type: Output
}], measuringContentSize: [{
type: Output
}] } });