igniteui-webcomponents-inputs
Version:
Ignite UI Web Components inputs components.
434 lines (433 loc) • 17 kB
JavaScript
import { ColorEditorPanel } from "./ColorEditorPanel";
import { ensureEnum, brushToString, stringToBrush, initializePropertiesFromCss, NamePatcher, toSpinal, enumToString, getAllPropertyNames, fromSpinal } from "igniteui-webcomponents-core";
import { FontInfo } from "igniteui-webcomponents-core";
import { WebComponentRenderer, PortalManager } from "igniteui-webcomponents-core";
import { delegateCombine, delegateRemove } from "igniteui-webcomponents-core";
import { TypeRegistrar } from "igniteui-webcomponents-core";
import { RegisterElementHelper } from "igniteui-webcomponents-core";
import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core";
import { BaseControlTheme_$type } from "igniteui-webcomponents-core";
import { IgcHTMLElement } from "igniteui-webcomponents-core";
import { IgcColorEditorPanelSelectedValueChangedEventArgs } from "./igc-color-editor-panel-selected-value-changed-event-args";
export let IgcColorEditorPanelComponent = /*@__PURE__*/ (() => {
class IgcColorEditorPanelComponent extends IgcHTMLElement {
constructor() {
super();
this._disconnected = false;
this._settingAttributes = false;
this._attached = false;
this._queuedSetAttributes = [];
this._updatingFromAttribute = false;
this.__p = null;
this._hasUserValues = new Set();
this._stylingContainer = null;
this._stylingParent = null;
this._inStyling = false;
this._valueChanged = null;
this._valueChanged_wrapped = null;
this._valueChanging = null;
this._valueChanging_wrapped = null;
if (this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this));
}
this._portalManager = new PortalManager("colorEditorPanelContent");
this._renderer = new WebComponentRenderer(this, document, true, {}, this._portalManager);
this._container = this._renderer.createElement("div");
this._renderer.updateRoot(this._container);
this._implementation = this.createImplementation();
this._implementation.externalObject = this;
//this._container.setStyleProperty("width", "100%");
//this._container.setStyleProperty("height", "100%");
var root;
root = this._container;
if (this._container.getNativeElement() != null) {
root = this._container.getNativeElement();
}
this._wrapper = this._renderer;
var colorEditorPanel = this.i;
this._colorEditorPanel = colorEditorPanel;
colorEditorPanel.provideContainer(this._renderer);
this._onChildrenChanged();
//Checkbox.notifySizeChanged();
let mut = new MutationObserver((list) => {
for (var mutation of list) {
if (mutation.type == 'childList') {
this._onChildrenChanged();
}
}
});
mut.observe(this, {
childList: true
});
//this._renderer.addSizeWatcher(() => {
// this._checkbox.notifySizeChanged();
//});
}
_onChildrenChanged() {
var children = [];
for (var i = 0; i < this.childNodes.length; i++) {
var child = this.childNodes[i];
if (child !== this._container.getNativeElement()) {
children.push(child);
}
}
this._portalManager.onChildrenChanged(children);
}
// supports angular themes or custom properties set in CSS
updateStyle() {
this._styling(this, this);
}
destroy() {
this._colorEditorPanel.destroy();
this._wrapper.destroy();
}
createImplementation() {
return new ColorEditorPanel();
}
disconnectedCallback() {
this._disconnected = true;
if (this.i) {
this.i.onDetachedFromUI();
}
}
connectedCallback() {
if (this._disconnected) {
this._disconnected = false;
if (this.i) {
this.i.onAttachedToUI();
}
return;
}
this.classList.add("ig-color-editor-panel");
this.classList.add("igc-color-editor-panel");
this.appendChild(this._container.getNativeElement());
this._attached = true;
this.style.display = "block";
//this.style.height = this._height;
//this.style.width = this._width;
this._flushQueuedAttributes();
// supports themes or custom properties set in CSS
this._styling(this, this);
this.afterContentInit();
}
afterContentInit() {
//this.i.notifySizeChanged();
}
/**
* @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 = "Igc" + name + "Component";
if (!TypeRegistrar.isRegistered(externalName)) {
return null;
}
return TypeRegistrar.create(externalName);
}
_enqueueSetAttribute(attrName, attrValue) {
this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue });
}
_flushQueuedAttributes() {
this._settingAttributes = true;
for (let i = 0; i < this._queuedSetAttributes.length; i++) {
this.setAttribute(this._queuedSetAttributes[i].attrName, this._queuedSetAttributes[i].attrValue);
}
this._settingAttributes = false;
this._queuedSetAttributes.length = 0;
}
_a(attrName, attrValue) {
if (this._updatingFromAttribute) {
return;
}
if (attrValue) {
attrValue = attrValue.toString();
}
this._settingAttributes = true;
attrName = toSpinal(attrName);
if (this._attached) {
this.setAttribute(attrName, attrValue);
}
else {
this._enqueueSetAttribute(attrName, attrValue);
}
this._settingAttributes = false;
}
static get observedAttributes() {
if (IgcColorEditorPanelComponent._observedAttributesIgcColorEditorPanelComponent == null) {
let names = getAllPropertyNames(IgcColorEditorPanelComponent);
for (let i = 0; i < names.length; i++) {
names[i] = toSpinal(names[i]);
}
IgcColorEditorPanelComponent._observedAttributesIgcColorEditorPanelComponent = names;
}
return IgcColorEditorPanelComponent._observedAttributesIgcColorEditorPanelComponent;
}
attributeChangedCallback(name, oldValue, newValue) {
if (this._settingAttributes) {
return;
}
let setName = fromSpinal(name);
this._updatingFromAttribute = true;
this[setName] = newValue;
this._updatingFromAttribute = false;
}
static register() {
if (!IgcColorEditorPanelComponent._isElementRegistered) {
IgcColorEditorPanelComponent._isElementRegistered = true;
RegisterElementHelper.registerElement(IgcColorEditorPanelComponent.htmlTagName, IgcColorEditorPanelComponent);
}
}
/**
* 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);
this._a("value", brushToString(this.i.value));
}
/**
* 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);
this._a("density", enumToString(ControlDisplayDensity_$type, this.i.h));
}
/**
* 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);
this._a("baseTheme", enumToString(BaseControlTheme_$type, this.i.f));
}
/**
* Gets or Sets the selected color background color
*/
get backgroundColor() {
return brushToString(this.i.by);
}
set backgroundColor(v) {
this.i.by = stringToBrush(v);
this._a("backgroundColor", brushToString(this.i.by));
}
/**
* Gets or Sets the selected color boreder color
*/
get selectedColorBorderColor() {
return brushToString(this.i.b1);
}
set selectedColorBorderColor(v) {
this.i.b1 = stringToBrush(v);
this._a("selectedColorBorderColor", brushToString(this.i.b1));
}
/**
* Gets or Sets the selected color border color
*/
get selectedFocusDateBackgroundColor() {
return brushToString(this.i.b2);
}
set selectedFocusDateBackgroundColor(v) {
this.i.b2 = stringToBrush(v);
this._a("selectedFocusDateBackgroundColor", brushToString(this.i.b2));
}
/**
* Gets or Sets the focus color border color
*/
get focusColorBorderColor() {
return brushToString(this.i.bz);
}
set focusColorBorderColor(v) {
this.i.bz = stringToBrush(v);
this._a("focusColorBorderColor", brushToString(this.i.bz));
}
/**
* Gets or Sets the focus date background color
*/
get hoverBackgroundColor() {
return brushToString(this.i.b0);
}
set hoverBackgroundColor(v) {
this.i.b0 = stringToBrush(v);
this._a("hoverBackgroundColor", brushToString(this.i.b0));
}
/**
* Gets or Sets the selected date text color
*/
get textColor() {
return brushToString(this.i.b3);
}
set textColor(v) {
this.i.b3 = stringToBrush(v);
this._a("textColor", brushToString(this.i.b3));
}
/**
* 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;
this._a("textStyle", this.i.j != null ? this.i.j.fontString : "");
}
/**
* 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;
this._a("pixelScalingRatio", this.i.ae);
}
get actualPixelScalingRatio() {
return this.i.ab;
}
set actualPixelScalingRatio(v) {
this.i.ab = +v;
this._a("actualPixelScalingRatio", this.i.ab);
}
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() {
return this._valueChanged;
}
set valueChanged(ev) {
if (this._valueChanged_wrapped !== null) {
this.i.valueChanged = delegateRemove(this.i.valueChanged, this._valueChanged_wrapped);
this._valueChanged_wrapped = null;
this._valueChanged = null;
}
this._valueChanged = ev;
this._valueChanged_wrapped = (o, e) => {
let outerArgs = new IgcColorEditorPanelSelectedValueChangedEventArgs();
outerArgs._provideImplementation(e);
if (this.beforeValueChanged) {
this.beforeValueChanged(this, outerArgs);
}
if (this._valueChanged) {
this._valueChanged(this, outerArgs);
}
};
this.i.valueChanged = delegateCombine(this.i.valueChanged, this._valueChanged_wrapped);
;
}
/**
* Called when date is selected.
*/
get valueChanging() {
return this._valueChanging;
}
set valueChanging(ev) {
if (this._valueChanging_wrapped !== null) {
this.i.valueChanging = delegateRemove(this.i.valueChanging, this._valueChanging_wrapped);
this._valueChanging_wrapped = null;
this._valueChanging = null;
}
this._valueChanging = ev;
this._valueChanging_wrapped = (o, e) => {
let outerArgs = new IgcColorEditorPanelSelectedValueChangedEventArgs();
outerArgs._provideImplementation(e);
if (this.beforeValueChanging) {
this.beforeValueChanging(this, outerArgs);
}
if (this._valueChanging) {
this._valueChanging(this, outerArgs);
}
};
this.i.valueChanging = delegateCombine(this.i.valueChanging, this._valueChanging_wrapped);
;
}
}
IgcColorEditorPanelComponent._observedAttributesIgcColorEditorPanelComponent = null;
IgcColorEditorPanelComponent.htmlTagName = "igc-color-editor-panel";
IgcColorEditorPanelComponent._isElementRegistered = false;
return IgcColorEditorPanelComponent;
})();