UNPKG

igniteui-webcomponents-inputs

Version:

Ignite UI Web Components inputs components.

899 lines (896 loc) 29.8 kB
import { __extends, __values } from "tslib"; import { XIcon } from "./XIcon"; import { ensureEnum, brushToString, stringToBrush, ensureBool, initializePropertiesFromCss, NamePatcher, toSpinal, fromBrushCollection, toBrushCollection, brushCollectionToString, enumToString, getAllPropertyNames, fromSpinal } from "igniteui-webcomponents-core"; import { FontInfo } from "igniteui-webcomponents-core"; import { WebComponentRenderer, PortalManager } from "igniteui-webcomponents-core"; import { TypeRegistrar } from "igniteui-webcomponents-core"; import { RegisterElementHelper } from "igniteui-webcomponents-core"; import { IgcHTMLElement } from "igniteui-webcomponents-core"; import { BaseControlTheme_$type } from "igniteui-webcomponents-core"; export var IgcXIconComponent = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgcXIconComponent, _super); function IgcXIconComponent() { 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; if (_this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this)); } _this._portalManager = new PortalManager("iconContent"); _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 icon = _this.i; _this._icon = icon; icon.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(); //}); } IgcXIconComponent.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 IgcXIconComponent.prototype.updateStyle = function () { this._styling(this, this); }; IgcXIconComponent.prototype.destroy = function () { this._icon.destroy(); this._wrapper.destroy(); }; IgcXIconComponent.prototype.createImplementation = function () { return new XIcon(); }; IgcXIconComponent.prototype.disconnectedCallback = function () { this._disconnected = true; if (this.i) { this.i.onDetachedFromUI(); } }; IgcXIconComponent.prototype.connectedCallback = function () { if (this._disconnected) { this._disconnected = false; if (this.i) { this.i.onAttachedToUI(); } return; } this.classList.add("ig-x-icon"); this.classList.add("igc-x-icon"); this.appendChild(this._container.getNativeElement()); this._attached = true; this.style.display = "inline-block"; this.style.verticalAlign = "middle"; //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(); }; IgcXIconComponent.prototype.afterContentInit = function () { //this.i.notifySizeChanged(); }; Object.defineProperty(IgcXIconComponent.prototype, "i", { /** * @hidden */ get: function () { return this._implementation; } /** * @hidden */, enumerable: false, configurable: true }); IgcXIconComponent._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); }; IgcXIconComponent.prototype._enqueueSetAttribute = function (attrName, attrValue) { this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue }); }; IgcXIconComponent.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; }; IgcXIconComponent.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(IgcXIconComponent, "observedAttributes", { get: function () { if (IgcXIconComponent._observedAttributesIgcXIconComponent == null) { var names = getAllPropertyNames(IgcXIconComponent); for (var i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcXIconComponent._observedAttributesIgcXIconComponent = names; } return IgcXIconComponent._observedAttributesIgcXIconComponent; }, enumerable: false, configurable: true }); IgcXIconComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) { if (this._settingAttributes) { return; } var setName = fromSpinal(name); this._updatingFromAttribute = true; this[setName] = newValue; this._updatingFromAttribute = false; }; IgcXIconComponent.register = function () { if (!IgcXIconComponent._isElementRegistered) { IgcXIconComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcXIconComponent.htmlTagName, IgcXIconComponent); } }; Object.defineProperty(IgcXIconComponent.prototype, "baseTheme", { /** * Gets or sets the base built in theme to use for the button. */ get: function () { return this.i.m; }, set: function (v) { this.i.m = ensureEnum(BaseControlTheme_$type, v); this._a("baseTheme", enumToString(BaseControlTheme_$type, this.i.m)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "actualFill", { /** * Gets the fill color currently used by the icon. */ get: function () { return brushToString(this.i.du); }, set: function (v) { this.i.du = stringToBrush(v); this._a("actualFill", brushToString(this.i.du)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "actualStroke", { /** * Gets the stroke color currently used by the icon. */ get: function () { return brushToString(this.i.dv); }, set: function (v) { this.i.dv = stringToBrush(v); this._a("actualStroke", brushToString(this.i.dv)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "actualTextColor", { /** * Gets the text color currently used by the icon. */ get: function () { return brushToString(this.i.dw); }, set: function (v) { this.i.dw = stringToBrush(v); this._a("actualTextColor", brushToString(this.i.dw)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "actualStrokeWidth", { /** * Gets the stroke width currently used by the icon. */ get: function () { return this.i.aq; }, set: function (v) { this.i.aq = +v; this._a("actualStrokeWidth", this.i.aq); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "fill", { /** * Gets or sets the fill color to use for the icon. */ get: function () { return brushToString(this.i.fill); }, set: function (v) { this.i.fill = stringToBrush(v); this._a("fill", brushToString(this.i.fill)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "stroke", { /** * Gets or sets the stroke color to use for the icon. */ get: function () { return brushToString(this.i.ea); }, set: function (v) { this.i.ea = stringToBrush(v); this._a("stroke", brushToString(this.i.ea)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "strokeWidth", { /** * Gets or sets the stroke thickness to use for the icon. */ get: function () { return this.i.a4; }, set: function (v) { this.i.a4 = +v; this._a("strokeWidth", this.i.a4); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "textColor", { /** * Gets or sets the text color to use for the icon. */ get: function () { return brushToString(this.i.eb); }, set: function (v) { this.i.eb = stringToBrush(v); this._a("textColor", brushToString(this.i.eb)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "hoverFill", { /** * Gets or sets the fill color to use when the icon is hovered. */ get: function () { return brushToString(this.i.d3); }, set: function (v) { this.i.d3 = stringToBrush(v); this._a("hoverFill", brushToString(this.i.d3)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "hoverStroke", { /** * Gets or sets the stroke color to use when the icon is hovered. */ get: function () { return brushToString(this.i.d4); }, set: function (v) { this.i.d4 = stringToBrush(v); this._a("hoverStroke", brushToString(this.i.d4)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "hoverStrokeThickness", { /** * Gets or sets the stroke thickness to use when the icon is hovered. */ get: function () { return this.i.a2; }, set: function (v) { this.i.a2 = +v; this._a("hoverStrokeThickness", this.i.a2); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "hoverTextColor", { /** * Gets or sets the text color to use when the icon is hovered. */ get: function () { return brushToString(this.i.d5); }, set: function (v) { this.i.d5 = stringToBrush(v); this._a("hoverTextColor", brushToString(this.i.d5)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "fillColors", { /** * Gets or sets a collection of fill colors to use in the icon. * These colors can be used by SVG elements that have been marked with the * ig-icon-fill-# * class where # is a number from 0 to count - 1. */ get: function () { return fromBrushCollection(this.i.e); }, set: function (v) { this.i.e = toBrushCollection(v); this._a("fillColors", brushCollectionToString(this.i.e)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "strokeColors", { /** * Gets or sets a collection of stroke colors to use in the icon. * These colors can be used by SVG elements that have been marked with the * ig-icon-stroke-# * class where # is a number from 0 to count - 1. */ get: function () { return fromBrushCollection(this.i.f); }, set: function (v) { this.i.f = toBrushCollection(v); this._a("strokeColors", brushCollectionToString(this.i.f)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "primaryFillColor", { /** * Gets or sets a primary fill color for the icon. * This color is used by SVG elements that have been marked * with the * ig-icon-primary-fill * class. */ get: function () { return brushToString(this.i.d6); }, set: function (v) { this.i.d6 = stringToBrush(v); this._a("primaryFillColor", brushToString(this.i.d6)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "primaryStrokeColor", { /** * Gets or sets a primary stroke color for the icon. * This color is used by SVG elements that have been marked * with the * ig-icon-primary-stroke * class. */ get: function () { return brushToString(this.i.d7); }, set: function (v) { this.i.d7 = stringToBrush(v); this._a("primaryStrokeColor", brushToString(this.i.d7)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "secondaryFillColor", { /** * Gets or sets a secondary fill color for the icon. * This color is used by SVG elements that have been marked * with the * ig-icon-secondary-fill * class. */ get: function () { return brushToString(this.i.d8); }, set: function (v) { this.i.d8 = stringToBrush(v); this._a("secondaryFillColor", brushToString(this.i.d8)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "secondaryStrokeColor", { /** * Gets or sets a secondary stroke color for the icon. * This color is used by SVG elements that have been marked * with the * ig-icon-secondary-stroke * class. */ get: function () { return brushToString(this.i.d9); }, set: function (v) { this.i.d9 = stringToBrush(v); this._a("secondaryStrokeColor", brushToString(this.i.d9)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "source", { /** * Gets or sets the image source for the icon. Used if none of the other icon types are not used. */ get: function () { return this.i.bh; }, set: function (v) { this.i.bh = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "dataURL", { /** * Gets or sets data url for the icon to use. */ get: function () { return this.i.b0; }, set: function (v) { this.i.b0 = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "svgPath", { /** * Gets or sets path data for the icon to use. */ get: function () { return this.i.svgPath; }, set: function (v) { this.i.svgPath = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "svg", { /** * Gets or sets svg text for the icon to use. */ get: function () { return this.i.svg; }, set: function (v) { this.i.svg = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "sVGPaths", { /** * Gets or sets an array of path data for the icon to use. */ get: function () { return this.i.b; }, set: function (v) { if (v && !Array.isArray(v) && typeof (v) == "string") { var re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.b = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "textStyle", { /** * Gets or sets the use for the button. */ 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("textStyle", this.i.o != null ? this.i.o.fontString : ""); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "id", { /** * Gets or sets the id to use for the checkbox. */ get: function () { return this.i.ca; }, set: function (v) { this.i.ca = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "tabIndex", { /** * Gets or sets TabIndex to use for the checkbox. */ get: function () { return this.i.bb; }, set: function (v) { this.i.bb = +v; this._a("tabIndex", this.i.bb); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "ariaLabel", { /** * Gets or sets the value of the aria-label attribute. */ get: function () { return this.i.bv; }, set: function (v) { this.i.bv = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "isHover", { /** * Gets or sets whether the icon is hovered. */ get: function () { return this.i.v; }, set: function (v) { this.i.v = ensureBool(v); this._a("isHover", this.i.v); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "disabled", { /** * Gets or sets whether the checkbox is disabled. */ get: function () { return this.i.disabled; }, set: function (v) { this.i.disabled = ensureBool(v); this._a("disabled", this.i.disabled); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "opacity", { get: function () { return this.i.a3; }, set: function (v) { this.i.a3 = +v; this._a("opacity", this.i.a3); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "actualViewBoxLeft", { /** * Gets the actual viewbox left for the svg icon. */ get: function () { return this.i.as; }, set: function (v) { this.i.as = +v; this._a("actualViewBoxLeft", this.i.as); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "viewBoxLeft", { /** * Gets or sets the viewbox left for the svg icon. */ get: function () { return this.i.a6; }, set: function (v) { this.i.a6 = +v; this._a("viewBoxLeft", this.i.a6); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "actualViewBoxTop", { /** * Gets the actual viewbox top for the svg icon. */ get: function () { return this.i.at; }, set: function (v) { this.i.at = +v; this._a("actualViewBoxTop", this.i.at); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "viewBoxTop", { /** * Gets or sets the viewbox top for the svg icon. */ get: function () { return this.i.a7; }, set: function (v) { this.i.a7 = +v; this._a("viewBoxTop", this.i.a7); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "actualViewBoxWidth", { /** * Gets the actual viewbox width for the svg icon. */ get: function () { return this.i.au; }, set: function (v) { this.i.au = +v; this._a("actualViewBoxWidth", this.i.au); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "viewBoxWidth", { /** * Gets or sets the viewbox width for the svg icon. */ get: function () { return this.i.a8; }, set: function (v) { this.i.a8 = +v; this._a("viewBoxWidth", this.i.a8); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "actualViewBoxHeight", { /** * Gets the actual viewbox height for the svg icon. */ get: function () { return this.i.ar; }, set: function (v) { this.i.ar = +v; this._a("actualViewBoxHeight", this.i.ar); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "viewBoxHeight", { /** * Gets or sets the viewbox height for the svg icon. */ get: function () { return this.i.a5; }, set: function (v) { this.i.a5 = +v; this._a("viewBoxHeight", this.i.a5); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "width", { /** * Gets or sets the width of the icon. */ get: function () { return this.i.a9; }, set: function (v) { this.i.a9 = +v; this._a("width", this.i.a9); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXIconComponent.prototype, "height", { /** * Gets or sets the height of the icon. */ get: function () { return this.i.a1; }, set: function (v) { this.i.a1 = +v; this._a("height", this.i.a1); }, enumerable: false, configurable: true }); IgcXIconComponent.prototype.findByName = function (name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } return null; }; Object.defineProperty(IgcXIconComponent.prototype, "hasUserValues", { get: function () { return this._hasUserValues; }, enumerable: false, configurable: true }); IgcXIconComponent.prototype.__m = function (propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } }; IgcXIconComponent.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("XIconComponent"); 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; }; IgcXIconComponent.prototype.onDetachedFromUI = function () { this.i.onDetachedFromUI(); }; IgcXIconComponent.prototype.onAttachedToUI = function () { this.i.onAttachedToUI(); }; /** * Exports visual information about the current state of the grid. */ IgcXIconComponent.prototype.exportVisualModel = function () { var iv = this.i.bg(); return (iv); }; /** * Returns a serialized copy of the exported visual model */ IgcXIconComponent.prototype.exportSerializedVisualModel = function () { var iv = this.i.b2(); return (iv); }; IgcXIconComponent._observedAttributesIgcXIconComponent = null; IgcXIconComponent.htmlTagName = "igc-x-icon"; IgcXIconComponent._isElementRegistered = false; return IgcXIconComponent; }(IgcHTMLElement));