igniteui-angular-inputs
Version:
Ignite UI Angular input components for building rich data visualizations for modern web apps.
377 lines (376 loc) • 15.7 kB
JavaScript
import { Output, TemplateRef, EventEmitter, Component, ViewContainerRef, ViewChild, Input, ChangeDetectionStrategy } from '@angular/core';
import { ColorEditorPanel } from "./ColorEditorPanel";
import { ensureEnum, brushToString, stringToBrush, 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 * as i0 from "@angular/core";
export let IgxColorEditorPanelComponent = /*@__PURE__*/ (() => {
class IgxColorEditorPanelComponent {
constructor(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._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 colorEditorPanel = this.i;
this._colorEditorPanel = colorEditorPanel;
if (renderer) {
this._portalManager = new PortalManager("colorEditorPanelContent", componentFactoryResolver);
var ren = new AngularRenderer(root, this.renderer, window.document, this.ngZone, true, {}, this._portalManager);
this._wrapper = ren;
colorEditorPanel.provideContainer(ren);
}
}
// supports angular themes or custom properties set in CSS
updateStyle() {
this._styling(this._root, this);
}
ngOnDestroy() {
this._colorEditorPanel.destroy();
this._wrapper.destroy();
}
ngAfterViewInit() {
this._portalManager.dynamicContent = this._dynamicContent;
this._portalManager.onChildContentChanged(this._childTemplateRef);
this._styling(this._root, this);
this.updateStyle();
}
createImplementation() {
return new ColorEditorPanel();
}
/**
* @hidden
*/
get i() {
return this._implementation;
} /**
* @hidden
*/
static _createFromInternal(internal) {
if (!internal) {
return null;
}
if (!internal.$type) {
return null;
}
let name = internal.$type.name;
let externalName = "Igx" + name + "Component";
if (!TypeRegistrar.isRegistered(externalName)) {
return null;
}
return TypeRegistrar.create(externalName);
}
/**
* Gets or Sets the value for the color editor panel.
*/
get value() {
return brushToString(this.i.value);
}
set value(v) {
this.i.value = stringToBrush(v);
}
/**
* Gets or sets the display density to use for the ColorEditorPanel.
*/
get density() {
return this.i.h;
}
set density(v) {
this.i.h = ensureEnum(ControlDisplayDensity_$type, v);
}
/**
* Gets or sets the base built in theme to use for the ColorEditorPanel.
*/
get baseTheme() {
return this.i.f;
}
set baseTheme(v) {
this.i.f = ensureEnum(BaseControlTheme_$type, v);
}
/**
* Gets or Sets the selected color background color
*/
get backgroundColor() {
return brushToString(this.i.by);
}
set backgroundColor(v) {
this.i.by = stringToBrush(v);
}
/**
* Gets or Sets the selected color boreder color
*/
get selectedColorBorderColor() {
return brushToString(this.i.b1);
}
set selectedColorBorderColor(v) {
this.i.b1 = stringToBrush(v);
}
/**
* Gets or Sets the selected color border color
*/
get selectedFocusDateBackgroundColor() {
return brushToString(this.i.b2);
}
set selectedFocusDateBackgroundColor(v) {
this.i.b2 = stringToBrush(v);
}
/**
* Gets or Sets the focus color border color
*/
get focusColorBorderColor() {
return brushToString(this.i.bz);
}
set focusColorBorderColor(v) {
this.i.bz = stringToBrush(v);
}
/**
* Gets or Sets the focus date background color
*/
get hoverBackgroundColor() {
return brushToString(this.i.b0);
}
set hoverBackgroundColor(v) {
this.i.b0 = stringToBrush(v);
}
/**
* Gets or Sets the selected date text color
*/
get textColor() {
return brushToString(this.i.b3);
}
set textColor(v) {
this.i.b3 = stringToBrush(v);
}
/**
* Gets or sets the font to use for the combobox.
*/
get textStyle() {
if (this.i.j == null) {
return null;
}
return this.i.j.fontString;
}
set textStyle(v) {
let fi = new FontInfo();
fi.fontString = v;
this.i.j = fi;
}
/**
* Gets or sets the scaling value used to affect the pixel density of the control.
* A higher scaling ratio will produce crisper visuals at the expense of memory. Lower values will cause the control
* to appear blurry.
*/
get pixelScalingRatio() {
return this.i.ae;
}
set pixelScalingRatio(v) {
this.i.ae = +v;
}
get actualPixelScalingRatio() {
return this.i.ab;
}
set actualPixelScalingRatio(v) {
this.i.ab = +v;
}
findByName(name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
return null;
}
get hasUserValues() {
return this._hasUserValues;
}
__m(propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
}
_styling(container, component, parent) {
if (this._inStyling) {
return;
}
this._inStyling = true;
this._stylingContainer = container;
this._stylingParent = component;
let genericPrefix = "";
let typeName = this.i.$type.name;
if (typeName.indexOf("Xam") === 0) {
typeName = typeName.substring(3);
}
genericPrefix = toSpinal("ColorEditorPanelComponent");
let additionalPrefixes = [];
let prefix = toSpinal(typeName);
additionalPrefixes.push(prefix + "-");
let 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);
}
let basePrefix = toSpinal(typeName);
additionalPrefixes.push(basePrefix + "-");
b = b.baseType;
}
if (parent) {
let parentTypeName = parent.i.$type.name;
if (parentTypeName.indexOf("Xam") === 0) {
parentTypeName = parentTypeName.substring(3);
}
let 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;
}
/**
* Called when date is selected.
*/
get valueChanged() {
if (this._valueChanged == null) {
this._valueChanged = new EventEmitter();
this.i.valueChanged = delegateCombine(this.i.valueChanged, (o, e) => {
this._runInZone(() => {
let outerArgs = new IgxColorEditorPanelSelectedValueChangedEventArgs();
outerArgs._provideImplementation(e);
if (this.beforeValueChanged) {
this.beforeValueChanged(this, outerArgs);
}
this._valueChanged.emit({
sender: this,
args: outerArgs
});
});
});
}
return this._valueChanged;
}
/**
* Called when date is selected.
*/
get valueChanging() {
if (this._valueChanging == null) {
this._valueChanging = new EventEmitter();
this.i.valueChanging = delegateCombine(this.i.valueChanging, (o, e) => {
let outerArgs = new IgxColorEditorPanelSelectedValueChangedEventArgs();
outerArgs._provideImplementation(e);
if (this.beforeValueChanging) {
this.beforeValueChanging(this, outerArgs);
}
this._valueChanging.emit({
sender: this,
args: outerArgs
});
});
}
return this._valueChanging;
}
_runInZone(act) {
if (this._zoneRunner != null) {
this._zoneRunner(act);
}
else {
act();
}
}
}
IgxColorEditorPanelComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxColorEditorPanelComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i0.NgZone }, { token: i0.Injector }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component });
IgxColorEditorPanelComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: IgxColorEditorPanelComponent, selector: "igx-color-editor-panel", inputs: { value: "value", density: "density", baseTheme: "baseTheme", backgroundColor: "backgroundColor", selectedColorBorderColor: "selectedColorBorderColor", selectedFocusDateBackgroundColor: "selectedFocusDateBackgroundColor", focusColorBorderColor: "focusColorBorderColor", hoverBackgroundColor: "hoverBackgroundColor", textColor: "textColor", textStyle: "textStyle", pixelScalingRatio: "pixelScalingRatio", actualPixelScalingRatio: "actualPixelScalingRatio" }, outputs: { valueChanged: "valueChanged", valueChanging: "valueChanging" }, host: { classAttribute: "ig-color-editor-panel igx-color-editor-panel" }, 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>
<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 IgxColorEditorPanelComponent;
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxColorEditorPanelComponent, decorators: [{
type: Component,
args: [{
selector: 'igx-color-editor-panel',
template: `<ng-template #childContent><ng-content></ng-content></ng-template>
<ng-container #dynamicContent></ng-container>`,
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [],
host: { 'class': 'ig-color-editor-panel igx-color-editor-panel' },
styles: [`
:host {
display: block;
}
`]
}]
}], 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
}], density: [{
type: Input
}], baseTheme: [{
type: Input
}], backgroundColor: [{
type: Input
}], selectedColorBorderColor: [{
type: Input
}], selectedFocusDateBackgroundColor: [{
type: Input
}], focusColorBorderColor: [{
type: Input
}], hoverBackgroundColor: [{
type: Input
}], textColor: [{
type: Input
}], textStyle: [{
type: Input
}], pixelScalingRatio: [{
type: Input
}], actualPixelScalingRatio: [{
type: Input
}], valueChanged: [{
type: Output
}], valueChanging: [{
type: Output
}] } });