igniteui-webcomponents-inputs
Version:
Ignite UI Web Components inputs components.
646 lines (645 loc) • 24.1 kB
JavaScript
import { __extends, __values } from "tslib";
import { ColorEditor } from "./ColorEditor";
import { ensureEnum, brushToString, stringToBrush, ensureBool, 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";
import { IgcColorEditorLostFocusEventArgs } from "./igc-color-editor-lost-focus-event-args";
import { IgcColorEditorGotFocusEventArgs } from "./igc-color-editor-got-focus-event-args";
var IgcColorEditorComponent = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgcColorEditorComponent, _super);
function IgcColorEditorComponent() {
var _this = _super.call(this) || this;
_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;
_this._gotFocus = null;
_this._gotFocus_wrapped = null;
_this._lostFocus = null;
_this._lostFocus_wrapped = null;
if (_this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this));
}
_this._portalManager = new PortalManager("colorEditorContent");
_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 colorEditor = _this.i;
_this._colorEditor = colorEditor;
colorEditor.provideContainer(_this._renderer);
_this._onChildrenChanged();
//Checkbox.notifySizeChanged();
var mut = new MutationObserver(function (list) {
var e_1, _b;
try {
for (var list_1 = __values(list), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) {
var mutation = list_1_1.value;
if (mutation.type == 'childList') {
_this._onChildrenChanged();
}
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (list_1_1 && !list_1_1.done && (_b = list_1.return))
_b.call(list_1);
}
finally {
if (e_1)
throw e_1.error;
}
}
});
mut.observe(_this, {
childList: true
});
return _this;
//this._renderer.addSizeWatcher(() => {
// this._checkbox.notifySizeChanged();
//});
}
IgcColorEditorComponent.prototype._onChildrenChanged = function () {
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
IgcColorEditorComponent.prototype.updateStyle = function () {
this._styling(this, this);
};
IgcColorEditorComponent.prototype.destroy = function () {
this._colorEditor.destroy();
this._wrapper.destroy();
};
IgcColorEditorComponent.prototype.createImplementation = function () {
return new ColorEditor();
};
IgcColorEditorComponent.prototype.disconnectedCallback = function () {
this._disconnected = true;
if (this.i) {
this.i.onDetachedFromUI();
}
};
IgcColorEditorComponent.prototype.connectedCallback = function () {
if (this._disconnected) {
this._disconnected = false;
if (this.i) {
this.i.onAttachedToUI();
}
return;
}
this.classList.add("ig-color-editor");
this.classList.add("igc-color-editor");
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();
};
IgcColorEditorComponent.prototype.afterContentInit = function () {
//this.i.notifySizeChanged();
};
Object.defineProperty(IgcColorEditorComponent.prototype, "i", {
/**
* @hidden
*/
get: function () {
return this._implementation;
} /**
* @hidden
*/,
enumerable: false,
configurable: true
});
IgcColorEditorComponent._createFromInternal = function (internal) {
if (!internal) {
return null;
}
if (!internal.$type) {
return null;
}
var name = internal.$type.name;
var externalName = "Igc" + name + "Component";
if (!TypeRegistrar.isRegistered(externalName)) {
return null;
}
return TypeRegistrar.create(externalName);
};
IgcColorEditorComponent.prototype._enqueueSetAttribute = function (attrName, attrValue) {
this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue });
};
IgcColorEditorComponent.prototype._flushQueuedAttributes = function () {
this._settingAttributes = true;
for (var i = 0; i < this._queuedSetAttributes.length; i++) {
this.setAttribute(this._queuedSetAttributes[i].attrName, this._queuedSetAttributes[i].attrValue);
}
this._settingAttributes = false;
this._queuedSetAttributes.length = 0;
};
IgcColorEditorComponent.prototype._a = function (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;
};
Object.defineProperty(IgcColorEditorComponent, "observedAttributes", {
get: function () {
if (IgcColorEditorComponent._observedAttributesIgcColorEditorComponent == null) {
var names = getAllPropertyNames(IgcColorEditorComponent);
for (var i = 0; i < names.length; i++) {
names[i] = toSpinal(names[i]);
}
IgcColorEditorComponent._observedAttributesIgcColorEditorComponent = names;
}
return IgcColorEditorComponent._observedAttributesIgcColorEditorComponent;
},
enumerable: false,
configurable: true
});
IgcColorEditorComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) {
if (this._settingAttributes) {
return;
}
var setName = fromSpinal(name);
this._updatingFromAttribute = true;
this[setName] = newValue;
this._updatingFromAttribute = false;
};
IgcColorEditorComponent.register = function () {
if (!IgcColorEditorComponent._isElementRegistered) {
IgcColorEditorComponent._isElementRegistered = true;
RegisterElementHelper.registerElement(IgcColorEditorComponent.htmlTagName, IgcColorEditorComponent);
}
};
Object.defineProperty(IgcColorEditorComponent.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);
this._a("value", brushToString(this.i.value));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.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(IgcColorEditorComponent.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);
this._a("labelTextColor", brushToString(this.i.cn));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.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;
this._a("labelTextStyle", this.i.o != null ? this.i.o.fontString : "");
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.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);
this._a("density", enumToString(ControlDisplayDensity_$type, this.i.k));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.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);
this._a("baseTheme", enumToString(BaseControlTheme_$type, this.i.i));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.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;
this._a("textStyle", this.i.p != null ? this.i.p.fontString : "");
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.prototype, "textColor", {
/**
* Gets or Sets the text color
*/
get: function () {
return brushToString(this.i.co);
},
set: function (v) {
this.i.co = stringToBrush(v);
this._a("textColor", brushToString(this.i.co));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.prototype, "iconColor", {
/**
* Gets or Sets the text color
*/
get: function () {
return brushToString(this.i.cm);
},
set: function (v) {
this.i.cm = stringToBrush(v);
this._a("iconColor", brushToString(this.i.cm));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.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);
this._a("showClearButton", this.i.am);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.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);
this._a("allowTextInput", this.i.ag);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.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);
this._a("openOnFocus", this.i.ak);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.prototype, "isDisabled", {
get: function () {
return this.i.ah;
},
set: function (v) {
this.i.ah = ensureBool(v);
this._a("isDisabled", this.i.ah);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.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);
this._a("isFixed", this.i.ai);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.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);
this._a("openAsChild", this.i.aj);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.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);
this._a("useTopLayer", this.i.an);
},
enumerable: false,
configurable: true
});
IgcColorEditorComponent.prototype.findByName = function (name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
return null;
};
Object.defineProperty(IgcColorEditorComponent.prototype, "hasUserValues", {
get: function () {
return this._hasUserValues;
},
enumerable: false,
configurable: true
});
IgcColorEditorComponent.prototype.__m = function (propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
};
IgcColorEditorComponent.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;
};
IgcColorEditorComponent.prototype.select = function () {
this.i.b8();
};
Object.defineProperty(IgcColorEditorComponent.prototype, "valueChanged", {
/**
* Called when color is selected.
*/
get: function () {
return this._valueChanged;
},
set: function (ev) {
var _this = this;
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 = function (o, e) {
var 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);
;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.prototype, "valueChanging", {
/**
* Called when color is selected.
*/
get: function () {
return this._valueChanging;
},
set: function (ev) {
var _this = this;
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 = function (o, e) {
var 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);
;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.prototype, "gotFocus", {
get: function () {
return this._gotFocus;
},
set: function (ev) {
var _this = this;
if (this._gotFocus_wrapped !== null) {
this.i.gotFocus = delegateRemove(this.i.gotFocus, this._gotFocus_wrapped);
this._gotFocus_wrapped = null;
this._gotFocus = null;
}
this._gotFocus = ev;
this._gotFocus_wrapped = function (o, e) {
var outerArgs = new IgcColorEditorGotFocusEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeGotFocus) {
_this.beforeGotFocus(_this, outerArgs);
}
if (_this._gotFocus) {
_this._gotFocus(_this, outerArgs);
}
};
this.i.gotFocus = delegateCombine(this.i.gotFocus, this._gotFocus_wrapped);
;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColorEditorComponent.prototype, "lostFocus", {
get: function () {
return this._lostFocus;
},
set: function (ev) {
var _this = this;
if (this._lostFocus_wrapped !== null) {
this.i.lostFocus = delegateRemove(this.i.lostFocus, this._lostFocus_wrapped);
this._lostFocus_wrapped = null;
this._lostFocus = null;
}
this._lostFocus = ev;
this._lostFocus_wrapped = function (o, e) {
var outerArgs = new IgcColorEditorLostFocusEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeLostFocus) {
_this.beforeLostFocus(_this, outerArgs);
}
if (_this._lostFocus) {
_this._lostFocus(_this, outerArgs);
}
};
this.i.lostFocus = delegateCombine(this.i.lostFocus, this._lostFocus_wrapped);
;
},
enumerable: false,
configurable: true
});
IgcColorEditorComponent._observedAttributesIgcColorEditorComponent = null;
IgcColorEditorComponent.htmlTagName = "igc-color-editor";
IgcColorEditorComponent._isElementRegistered = false;
return IgcColorEditorComponent;
}(IgcHTMLElement));
export { IgcColorEditorComponent };