igniteui-angular-inputs
Version:
Ignite UI Angular input components for building rich data visualizations for modern web apps.
556 lines (555 loc) • 21.8 kB
JavaScript
import { Output, TemplateRef, EventEmitter, Component, ViewContainerRef, ViewChild, Input, ChangeDetectionStrategy } from '@angular/core';
import { ColorEditor } from "./ColorEditor";
import { ensureEnum, brushToString, stringToBrush, ensureBool, toSpinal, initializePropertiesFromCss, NamePatcher } from "igniteui-angular-core";
import { FontInfo } from "igniteui-angular-core";
import { AngularRenderer, PortalManager } from "igniteui-angular-core";
import { delegateCombine } from "igniteui-angular-core";
import { TypeRegistrar } from "igniteui-angular-core";
import { ControlDisplayDensity_$type } from "igniteui-angular-core";
import { BaseControlTheme_$type } from "igniteui-angular-core";
import { IgxColorEditorPanelSelectedValueChangedEventArgs } from "./igx-color-editor-panel-selected-value-changed-event-args";
import { IgxColorEditorLostFocusEventArgs } from "./igx-color-editor-lost-focus-event-args";
import { IgxColorEditorGotFocusEventArgs } from "./igx-color-editor-got-focus-event-args";
import * as i0 from "@angular/core";
var IgxColorEditorComponent = /** @class */ /*@__PURE__*/ (function () {
function IgxColorEditorComponent(renderer, _elRef, ngZone, injector, componentFactoryResolver) {
this.renderer = renderer;
this._elRef = _elRef;
this.ngZone = ngZone;
this.injector = injector;
this.componentFactoryResolver = componentFactoryResolver;
this._wrapper = null;
this._portalManager = null;
this._root = null;
this.__p = null;
this._hasUserValues = new Set();
this._stylingContainer = null;
this._stylingParent = null;
this._inStyling = false;
this._valueChanged = null;
this._valueChanging = null;
this._gotFocus = null;
this._lostFocus = null;
this._zoneRunner = null;
if (this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this));
}
this._implementation = this.createImplementation();
this._implementation.externalObject = this;
if (renderer) {
this.container = renderer.createElement("div");
renderer.appendChild(_elRef.element.nativeElement, this.container);
renderer.setStyle(this.container, "display", "block");
}
var root;
root = this.container;
if (this.container != null) {
root = this.container;
}
if (root && root.nativeElement) {
root = root.nativeElement;
}
this._root = root;
var colorEditor = this.i;
this._colorEditor = colorEditor;
if (renderer) {
this._portalManager = new PortalManager("colorEditorContent", componentFactoryResolver);
var ren = new AngularRenderer(root, this.renderer, window.document, this.ngZone, true, {}, this._portalManager);
this._wrapper = ren;
colorEditor.provideContainer(ren);
}
}
// supports angular themes or custom properties set in CSS
IgxColorEditorComponent.prototype.updateStyle = function () {
this._styling(this._root, this);
};
IgxColorEditorComponent.prototype.ngOnDestroy = function () {
this._colorEditor.destroy();
this._wrapper.destroy();
};
IgxColorEditorComponent.prototype.ngAfterViewInit = function () {
this._portalManager.dynamicContent = this._dynamicContent;
this._portalManager.onChildContentChanged(this._childTemplateRef);
this._styling(this._root, this);
this.updateStyle();
};
IgxColorEditorComponent.prototype.createImplementation = function () {
return new ColorEditor();
};
Object.defineProperty(IgxColorEditorComponent.prototype, "i", {
/**
* @hidden
*/
get: function () {
return this._implementation;
} /**
* @hidden
*/,
enumerable: false,
configurable: true
});
IgxColorEditorComponent._createFromInternal = function (internal) {
if (!internal) {
return null;
}
if (!internal.$type) {
return null;
}
var name = internal.$type.name;
var externalName = "Igx" + name + "Component";
if (!TypeRegistrar.isRegistered(externalName)) {
return null;
}
return TypeRegistrar.create(externalName);
};
Object.defineProperty(IgxColorEditorComponent.prototype, "value", {
/**
* Gets or Sets color value of the editor.
*/
get: function () {
return brushToString(this.i.value);
},
set: function (v) {
this.i.value = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "label", {
/**
* Gets or Sets the property name that contains the label.
*/
get: function () {
return this.i.az;
},
set: function (v) {
this.i.az = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "labelTextColor", {
/**
* Gets or sets the color to use for the text.
*/
get: function () {
return brushToString(this.i.cn);
},
set: function (v) {
this.i.cn = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "labelTextStyle", {
/**
* Gets or sets the font to use for the input.
*/
get: function () {
if (this.i.o == null) {
return null;
}
return this.i.o.fontString;
},
set: function (v) {
var fi = new FontInfo();
fi.fontString = v;
this.i.o = fi;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "density", {
/**
* Gets or sets the display density to use for the date pcicker.
*/
get: function () {
return this.i.k;
},
set: function (v) {
this.i.k = ensureEnum(ControlDisplayDensity_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "baseTheme", {
/**
* Gets or sets the base built in theme to use for the date picker.
*/
get: function () {
return this.i.i;
},
set: function (v) {
this.i.i = ensureEnum(BaseControlTheme_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "textStyle", {
/**
* Gets or sets the font to use for the combobox.
*/
get: function () {
if (this.i.p == null) {
return null;
}
return this.i.p.fontString;
},
set: function (v) {
var fi = new FontInfo();
fi.fontString = v;
this.i.p = fi;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "textColor", {
/**
* Gets or Sets the text color
*/
get: function () {
return brushToString(this.i.co);
},
set: function (v) {
this.i.co = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "iconColor", {
/**
* Gets or Sets the text color
*/
get: function () {
return brushToString(this.i.cm);
},
set: function (v) {
this.i.cm = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "showClearButton", {
/**
* Gets or sets the ShowClearButton property to detirmine if the clear button is shown
*/
get: function () {
return this.i.am;
},
set: function (v) {
this.i.am = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "allowTextInput", {
/**
* Gets or sets the AllowTextInput property to detirmine if entering text into the input is allowed
*/
get: function () {
return this.i.ag;
},
set: function (v) {
this.i.ag = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "openOnFocus", {
/**
* Gets or sets the AllowTextInput property to detirmine if entering text into the input is allowed
*/
get: function () {
return this.i.ak;
},
set: function (v) {
this.i.ak = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "isDisabled", {
get: function () {
return this.i.ah;
},
set: function (v) {
this.i.ah = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "isFixed", {
/**
* Indicates that the editor dropdown will position itself relative to the window instead of the document.
*/
get: function () {
return this.i.ai;
},
set: function (v) {
this.i.ai = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "openAsChild", {
/**
* Indicates that the dropdown should open as a child of the color editor.
*/
get: function () {
return this.i.aj;
},
set: function (v) {
this.i.aj = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "useTopLayer", {
/**
* Indicates that the dropdown will place itself into the browser top layer.
*/
get: function () {
return this.i.an;
},
set: function (v) {
this.i.an = ensureBool(v);
},
enumerable: false,
configurable: true
});
IgxColorEditorComponent.prototype.findByName = function (name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
return null;
};
Object.defineProperty(IgxColorEditorComponent.prototype, "hasUserValues", {
get: function () {
return this._hasUserValues;
},
enumerable: false,
configurable: true
});
IgxColorEditorComponent.prototype.__m = function (propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
};
IgxColorEditorComponent.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("ColorEditorComponent");
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;
};
IgxColorEditorComponent.prototype.select = function () {
this.i.b8();
};
Object.defineProperty(IgxColorEditorComponent.prototype, "valueChanged", {
/**
* Called when color is selected.
*/
get: function () {
var _this = this;
if (this._valueChanged == null) {
this._valueChanged = new EventEmitter();
this.i.valueChanged = delegateCombine(this.i.valueChanged, function (o, e) {
var outerArgs = new IgxColorEditorPanelSelectedValueChangedEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeValueChanged) {
_this.beforeValueChanged(_this, outerArgs);
}
_this._valueChanged.emit({
sender: _this,
args: outerArgs
});
});
}
return this._valueChanged;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "valueChanging", {
/**
* Called when color is selected.
*/
get: function () {
var _this = this;
if (this._valueChanging == null) {
this._valueChanging = new EventEmitter();
this.i.valueChanging = delegateCombine(this.i.valueChanging, function (o, e) {
var outerArgs = new IgxColorEditorPanelSelectedValueChangedEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeValueChanging) {
_this.beforeValueChanging(_this, outerArgs);
}
_this._valueChanging.emit({
sender: _this,
args: outerArgs
});
});
}
return this._valueChanging;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "gotFocus", {
get: function () {
var _this = this;
if (this._gotFocus == null) {
this._gotFocus = new EventEmitter();
this.i.gotFocus = delegateCombine(this.i.gotFocus, function (o, e) {
_this._runInZone(function () {
var outerArgs = new IgxColorEditorGotFocusEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeGotFocus) {
_this.beforeGotFocus(_this, outerArgs);
}
_this._gotFocus.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._gotFocus;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxColorEditorComponent.prototype, "lostFocus", {
get: function () {
var _this = this;
if (this._lostFocus == null) {
this._lostFocus = new EventEmitter();
this.i.lostFocus = delegateCombine(this.i.lostFocus, function (o, e) {
_this._runInZone(function () {
var outerArgs = new IgxColorEditorLostFocusEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeLostFocus) {
_this.beforeLostFocus(_this, outerArgs);
}
_this._lostFocus.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._lostFocus;
},
enumerable: false,
configurable: true
});
IgxColorEditorComponent.prototype._runInZone = function (act) {
if (this._zoneRunner != null) {
this._zoneRunner(act);
}
else {
act();
}
};
IgxColorEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxColorEditorComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i0.NgZone }, { token: i0.Injector }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component });
IgxColorEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: IgxColorEditorComponent, selector: "igx-color-editor", inputs: { value: "value", label: "label", labelTextColor: "labelTextColor", labelTextStyle: "labelTextStyle", density: "density", baseTheme: "baseTheme", textStyle: "textStyle", textColor: "textColor", iconColor: "iconColor", showClearButton: "showClearButton", allowTextInput: "allowTextInput", openOnFocus: "openOnFocus", isDisabled: "isDisabled", isFixed: "isFixed", openAsChild: "openAsChild", useTopLayer: "useTopLayer" }, outputs: { valueChanged: "valueChanged", valueChanging: "valueChanging", gotFocus: "gotFocus", lostFocus: "lostFocus" }, host: { classAttribute: "ig-color-editor igx-color-editor" }, providers: [], viewQueries: [{ 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: "<ng-template #childContent><ng-content></ng-content></ng-template>\n<ng-container #dynamicContent></ng-container>", isInline: true, styles: ["\n\t\t:host {\n\t\t\tdisplay: block; \n\t\t}\n\t"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
return IgxColorEditorComponent;
}());
export { IgxColorEditorComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxColorEditorComponent, decorators: [{
type: Component,
args: [{
selector: 'igx-color-editor',
template: "<ng-template #childContent><ng-content></ng-content></ng-template>\n<ng-container #dynamicContent></ng-container>",
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [],
host: { 'class': 'ig-color-editor igx-color-editor' },
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: { _dynamicContent: [{
type: ViewChild,
args: ["dynamicContent", { read: ViewContainerRef, static: true }]
}], _childTemplateRef: [{
type: ViewChild,
args: ["childContent", { read: TemplateRef, static: false }]
}], value: [{
type: Input
}], label: [{
type: Input
}], labelTextColor: [{
type: Input
}], labelTextStyle: [{
type: Input
}], density: [{
type: Input
}], baseTheme: [{
type: Input
}], textStyle: [{
type: Input
}], textColor: [{
type: Input
}], iconColor: [{
type: Input
}], showClearButton: [{
type: Input
}], allowTextInput: [{
type: Input
}], openOnFocus: [{
type: Input
}], isDisabled: [{
type: Input
}], isFixed: [{
type: Input
}], openAsChild: [{
type: Input
}], useTopLayer: [{
type: Input
}], valueChanged: [{
type: Output
}], valueChanging: [{
type: Output
}], gotFocus: [{
type: Output
}], lostFocus: [{
type: Output
}] } });