igniteui-webcomponents-grids
Version:
Ignite UI Web Components grid components.
414 lines (413 loc) • 16.8 kB
JavaScript
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";
export let IgcGridConditionalStyleComponent = /*@__PURE__*/ (() => {
class IgcGridConditionalStyleComponent extends IgcHTMLElement {
createImplementation() {
return new GridConditionalStyle();
}
/**
* @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);
}
onImplementationCreated() {
}
_initializeAdapters() {
if (!this.__observingChildren) {
this.__observingChildren = true;
let mut = new MutationObserver((list) => {
for (var mutation of list) {
if (mutation.type == 'childList') {
if (this.updateContentChildren) {
this.updateContentChildren();
}
else if (this._initializeAdapters) {
this.initializeAdapters();
}
}
}
});
mut.observe(this, {
childList: true
});
}
this._propertiesAdapter = new CollectionAdapter(this.contentProperties, this.i.properties, this.actualProperties, (c) => c.i, (i) => {
if (this._initializeElement) {
this._initializeElement(i);
}
}, (i) => {
if (this._destroyElement) {
this._destroyElement(i);
}
});
if (super["_initializeAdapters"]) {
super["_initializeAdapters"]();
}
}
_updateAdapters() {
if (super["_updateAdapters"]) {
super["_updateAdapters"]();
}
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();
}
}
constructor() {
super();
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();
}
}
_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;
}
connectedCallback() {
if (super["connectedCallback"]) {
super["connectedCallback"]();
}
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();
}
}
disconnectedCallback() {
if (super["disconnectedCallback"]) {
super["disconnectedCallback"]();
}
if (this.i.disconnectedCallback) {
this.i.disconnectedCallback();
}
if (this._attached) {
this._attached = false;
}
}
static get observedAttributes() {
if (IgcGridConditionalStyleComponent._observedAttributesIgcGridConditionalStyleComponent == null) {
let names = getAllPropertyNames(IgcGridConditionalStyleComponent);
for (let i = 0; i < names.length; i++) {
names[i] = toSpinal(names[i]);
}
IgcGridConditionalStyleComponent._observedAttributesIgcGridConditionalStyleComponent = names;
}
return IgcGridConditionalStyleComponent._observedAttributesIgcGridConditionalStyleComponent;
}
attributeChangedCallback(name, oldValue, newValue) {
if (this._settingAttributes) {
return;
}
let setName = fromSpinal(name);
this._updatingFromAttribute = true;
this[setName] = newValue;
this._updatingFromAttribute = false;
}
static register() {
if (!IgcGridConditionalStyleComponent._isElementRegistered) {
IgcGridConditionalStyleComponent._isElementRegistered = true;
RegisterElementHelper.registerElement(IgcGridConditionalStyleComponent.htmlTagName, IgcGridConditionalStyleComponent);
}
}
get isCompound() {
return this.i.s;
}
get styleKey() {
return this.i.ak;
}
set styleKey(v) {
this.i.ak = v;
}
get isTransitionInEnabled() {
return this.i.w;
}
set isTransitionInEnabled(v) {
this.i.w = ensureBool(v);
this._a("isTransitionInEnabled", this.i.w);
}
get actualProperties() {
if (!this._actualProperties) {
this._actualProperties = [];
}
return this._actualProperties;
}
get contentProperties() {
if (!this._contentProperties) {
this._contentProperties = [];
}
return this._contentProperties;
}
get properties() {
if (this._properties === null) {
let coll = new IgcGridConditionalStylePropertyCollection();
let inner = coll._innerColl;
this._properties = coll;
inner.addListener((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;
}
get conditionString() {
return this.i.ae;
}
set conditionString(v) {
this.i.ae = v;
}
get condition() {
return this.i.e;
}
set condition(v) {
this.i.e = v;
}
get isFieldMinimumNeeded() {
return this.i.u;
}
set isFieldMinimumNeeded(v) {
this.i.u = ensureBool(v);
this._a("isFieldMinimumNeeded", this.i.u);
}
get isFieldMaximumNeeded() {
return this.i.t;
}
set isFieldMaximumNeeded(v) {
this.i.t = ensureBool(v);
this._a("isFieldMaximumNeeded", this.i.t);
}
get isFieldSumNeeded() {
return this.i.v;
}
set isFieldSumNeeded(v) {
this.i.v = ensureBool(v);
this._a("isFieldSumNeeded", this.i.v);
}
findByName(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;
}
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("GridConditionalStyleComponent");
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;
}
requiresGlobalValues() {
let iv = this.i.x();
return (iv);
}
actualNeedsFieldMinimum() {
let iv = this.i.q();
return (iv);
}
actualNeedsFieldMaximum() {
let iv = this.i.p();
return (iv);
}
actualNeedsFieldSum() {
let iv = this.i.r();
return (iv);
}
get propertyUpdated() {
return this._propertyUpdated;
}
set propertyUpdated(ev) {
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 = (o, e) => {
let 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);
;
}
get filterStringErrorsParsing() {
return this._filterStringErrorsParsing;
}
set filterStringErrorsParsing(ev) {
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 = (o, e) => {
let 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);
;
}
}
IgcGridConditionalStyleComponent._observedAttributesIgcGridConditionalStyleComponent = null;
IgcGridConditionalStyleComponent.htmlTagName = "igc-grid-conditional-style";
IgcGridConditionalStyleComponent._isElementRegistered = false;
return IgcGridConditionalStyleComponent;
})();