UNPKG

igniteui-webcomponents-grids

Version:

Ignite UI Web Components grid components.

501 lines (500 loc) 20.4 kB
import { __extends, __values } from "tslib"; import { IgcHTMLElement } from "igniteui-webcomponents-core"; import { delegateCombine, delegateRemove } from "igniteui-webcomponents-core"; import { IgcGridConditionalStylePropertyCollection } from "./igc-grid-conditional-style-property-collection"; import { IgcPropertyUpdatedEventArgs } from "igniteui-webcomponents-core"; import { IgcGridConditionFilterStringErrorsParsingEventArgs } from "./igc-grid-condition-filter-string-errors-parsing-event-args"; import { GridConditionalStyle } from "./GridConditionalStyle"; import { TypeRegistrar } from "igniteui-webcomponents-core"; import { CollectionAdapter, NamePatcher, getAllPropertyNames, fromSpinal, toSpinal, ensureBool, initializePropertiesFromCss } from "igniteui-webcomponents-core"; import { RegisterElementHelper } from "igniteui-webcomponents-core"; import { IgcGridConditionalStylePropertyComponent } from "./igc-grid-conditional-style-property-component"; import { NotifyCollectionChangedAction } from "igniteui-webcomponents-core"; var IgcGridConditionalStyleComponent = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgcGridConditionalStyleComponent, _super); function IgcGridConditionalStyleComponent() { var _this = _super.call(this) || this; _this._settingAttributes = false; _this._attached = false; _this._queuedSetAttributes = []; _this._updatingFromAttribute = false; _this._properties = null; _this.__p = null; _this._hasUserValues = new Set(); _this._stylingContainer = null; _this._stylingParent = null; _this._inStyling = false; _this._propertyUpdated = null; _this._propertyUpdated_wrapped = null; _this._filterStringErrorsParsing = null; _this._filterStringErrorsParsing_wrapped = null; if (_this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this)); } _this._implementation = _this.createImplementation(); _this._implementation.externalObject = _this; _this.onImplementationCreated(); if (_this._initializeAdapters) { _this._initializeAdapters(); } return _this; } IgcGridConditionalStyleComponent.prototype.createImplementation = function () { return new GridConditionalStyle(); }; Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "i", { /** * @hidden */ get: function () { return this._implementation; } /** * @hidden */, enumerable: false, configurable: true }); IgcGridConditionalStyleComponent._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); }; IgcGridConditionalStyleComponent.prototype.onImplementationCreated = function () { }; IgcGridConditionalStyleComponent.prototype._initializeAdapters = function () { var _this = this; if (!this.__observingChildren) { this.__observingChildren = true; 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') { if (_this.updateContentChildren) { _this.updateContentChildren(); } else if (_this._initializeAdapters) { _this.initializeAdapters(); } } } } 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 }); } this._propertiesAdapter = new CollectionAdapter(this.contentProperties, this.i.properties, this.actualProperties, function (c) { return c.i; }, function (i) { if (_this._initializeElement) { _this._initializeElement(i); } }, function (i) { if (_this._destroyElement) { _this._destroyElement(i); } }); if (_super.prototype["_initializeAdapters"]) { _super.prototype["_initializeAdapters"].call(this); } }; IgcGridConditionalStyleComponent.prototype._updateAdapters = function () { if (_super.prototype["_updateAdapters"]) { _super.prototype["_updateAdapters"].call(this); } this.contentProperties.length = 0; for (var i = 0; i < this.children.length; i++) { if (this.children[i] instanceof IgcGridConditionalStylePropertyComponent) { this.contentProperties.push(this.children[i]); } } if (this._propertiesAdapter != null) { this._propertiesAdapter.notifyContentChanged(); } }; IgcGridConditionalStyleComponent.prototype._enqueueSetAttribute = function (attrName, attrValue) { this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue }); }; IgcGridConditionalStyleComponent.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; }; IgcGridConditionalStyleComponent.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; }; IgcGridConditionalStyleComponent.prototype.connectedCallback = function () { if (_super.prototype["connectedCallback"]) { _super.prototype["connectedCallback"].call(this); } if (this.i.connectedCallback) { this.i.connectedCallback(); } if (this.updateContentChildren) { this.updateContentChildren(); } else if (this._updateAdapters) { this._updateAdapters(); } if (!this._attached) { this._attached = true; this._flushQueuedAttributes(); } }; IgcGridConditionalStyleComponent.prototype.disconnectedCallback = function () { if (_super.prototype["disconnectedCallback"]) { _super.prototype["disconnectedCallback"].call(this); } if (this.i.disconnectedCallback) { this.i.disconnectedCallback(); } if (this._attached) { this._attached = false; } }; Object.defineProperty(IgcGridConditionalStyleComponent, "observedAttributes", { get: function () { if (IgcGridConditionalStyleComponent._observedAttributesIgcGridConditionalStyleComponent == null) { var names = getAllPropertyNames(IgcGridConditionalStyleComponent); for (var i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcGridConditionalStyleComponent._observedAttributesIgcGridConditionalStyleComponent = names; } return IgcGridConditionalStyleComponent._observedAttributesIgcGridConditionalStyleComponent; }, enumerable: false, configurable: true }); IgcGridConditionalStyleComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) { if (this._settingAttributes) { return; } var setName = fromSpinal(name); this._updatingFromAttribute = true; this[setName] = newValue; this._updatingFromAttribute = false; }; IgcGridConditionalStyleComponent.register = function () { if (!IgcGridConditionalStyleComponent._isElementRegistered) { IgcGridConditionalStyleComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcGridConditionalStyleComponent.htmlTagName, IgcGridConditionalStyleComponent); } }; Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "isCompound", { get: function () { return this.i.s; }, enumerable: false, configurable: true }); Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "styleKey", { get: function () { return this.i.ak; }, set: function (v) { this.i.ak = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "isTransitionInEnabled", { get: function () { return this.i.w; }, set: function (v) { this.i.w = ensureBool(v); this._a("isTransitionInEnabled", this.i.w); }, enumerable: false, configurable: true }); Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "actualProperties", { get: function () { if (!this._actualProperties) { this._actualProperties = []; } return this._actualProperties; }, enumerable: false, configurable: true }); Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "contentProperties", { get: function () { if (!this._contentProperties) { this._contentProperties = []; } return this._contentProperties; }, enumerable: false, configurable: true }); Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "properties", { get: function () { var _this = this; if (this._properties === null) { var coll = new IgcGridConditionalStylePropertyCollection(); var inner = coll._innerColl; this._properties = coll; inner.addListener(function (sender, e) { switch (e.action) { case NotifyCollectionChangedAction.Add: _this._propertiesAdapter.insertManualItem(e.newStartingIndex, e.newItems.item(0)); break; case NotifyCollectionChangedAction.Remove: _this._propertiesAdapter.removeManualItemAt(e.oldStartingIndex); break; case NotifyCollectionChangedAction.Replace: _this._propertiesAdapter.removeManualItemAt(e.oldStartingIndex); _this._propertiesAdapter.insertManualItem(e.newStartingIndex, e.newItems.item(0)); break; case NotifyCollectionChangedAction.Reset: _this._propertiesAdapter.clearManualItems(); break; } }); ; } return this._properties; }, enumerable: false, configurable: true }); Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "conditionString", { get: function () { return this.i.ae; }, set: function (v) { this.i.ae = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "condition", { get: function () { return this.i.e; }, set: function (v) { this.i.e = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "isFieldMinimumNeeded", { get: function () { return this.i.u; }, set: function (v) { this.i.u = ensureBool(v); this._a("isFieldMinimumNeeded", this.i.u); }, enumerable: false, configurable: true }); Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "isFieldMaximumNeeded", { get: function () { return this.i.t; }, set: function (v) { this.i.t = ensureBool(v); this._a("isFieldMaximumNeeded", this.i.t); }, enumerable: false, configurable: true }); Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "isFieldSumNeeded", { get: function () { return this.i.v; }, set: function (v) { this.i.v = ensureBool(v); this._a("isFieldSumNeeded", this.i.v); }, enumerable: false, configurable: true }); IgcGridConditionalStyleComponent.prototype.findByName = function (name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } if (this.properties != null && this.properties.findByName && this.properties.findByName(name)) { return this.properties.findByName(name); } return null; }; Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "hasUserValues", { get: function () { return this._hasUserValues; }, enumerable: false, configurable: true }); IgcGridConditionalStyleComponent.prototype.__m = function (propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } }; IgcGridConditionalStyleComponent.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("GridConditionalStyleComponent"); 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; }; IgcGridConditionalStyleComponent.prototype.requiresGlobalValues = function () { var iv = this.i.x(); return (iv); }; IgcGridConditionalStyleComponent.prototype.actualNeedsFieldMinimum = function () { var iv = this.i.q(); return (iv); }; IgcGridConditionalStyleComponent.prototype.actualNeedsFieldMaximum = function () { var iv = this.i.p(); return (iv); }; IgcGridConditionalStyleComponent.prototype.actualNeedsFieldSum = function () { var iv = this.i.r(); return (iv); }; Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "propertyUpdated", { get: function () { return this._propertyUpdated; }, set: function (ev) { var _this = this; if (this._propertyUpdated_wrapped !== null) { this.i.propertyUpdated = delegateRemove(this.i.propertyUpdated, this._propertyUpdated_wrapped); this._propertyUpdated_wrapped = null; this._propertyUpdated = null; } this._propertyUpdated = ev; this._propertyUpdated_wrapped = function (o, e) { var outerArgs = new IgcPropertyUpdatedEventArgs(); outerArgs._provideImplementation(e); if (_this.beforePropertyUpdated) { _this.beforePropertyUpdated(_this, outerArgs); } if (_this._propertyUpdated) { _this._propertyUpdated(_this, outerArgs); } }; this.i.propertyUpdated = delegateCombine(this.i.propertyUpdated, this._propertyUpdated_wrapped); ; }, enumerable: false, configurable: true }); Object.defineProperty(IgcGridConditionalStyleComponent.prototype, "filterStringErrorsParsing", { get: function () { return this._filterStringErrorsParsing; }, set: function (ev) { var _this = this; if (this._filterStringErrorsParsing_wrapped !== null) { this.i.filterStringErrorsParsing = delegateRemove(this.i.filterStringErrorsParsing, this._filterStringErrorsParsing_wrapped); this._filterStringErrorsParsing_wrapped = null; this._filterStringErrorsParsing = null; } this._filterStringErrorsParsing = ev; this._filterStringErrorsParsing_wrapped = function (o, e) { var outerArgs = new IgcGridConditionFilterStringErrorsParsingEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeFilterStringErrorsParsing) { _this.beforeFilterStringErrorsParsing(_this, outerArgs); } if (_this._filterStringErrorsParsing) { _this._filterStringErrorsParsing(_this, outerArgs); } }; this.i.filterStringErrorsParsing = delegateCombine(this.i.filterStringErrorsParsing, this._filterStringErrorsParsing_wrapped); ; }, enumerable: false, configurable: true }); IgcGridConditionalStyleComponent._observedAttributesIgcGridConditionalStyleComponent = null; IgcGridConditionalStyleComponent.htmlTagName = "igc-grid-conditional-style"; IgcGridConditionalStyleComponent._isElementRegistered = false; return IgcGridConditionalStyleComponent; }(IgcHTMLElement)); export { IgcGridConditionalStyleComponent };