igniteui-webcomponents-grids
Version:
Ignite UI Web Components grid components.
445 lines (442 loc) • 16.8 kB
JavaScript
import { __extends } from "tslib";
import { ensureEnum, brushToString, stringToBrush, initializePropertiesFromCss, NamePatcher, toSpinal, enumToString, getAllPropertyNames, fromSpinal } from "igniteui-webcomponents-core";
import { FontInfo } from "igniteui-webcomponents-core";
import { WebComponentRenderer } from "igniteui-webcomponents-core";
import { TypeRegistrar } from "igniteui-webcomponents-core";
import { RegisterElementHelper } from "igniteui-webcomponents-core";
import { ColumnGrouping } from './ColumnGrouping';
import { BaseControlTheme_$type } from "igniteui-webcomponents-core";
import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core";
import { IgcHTMLElement } from "igniteui-webcomponents-core";
var IgcColumnGroupingComponent = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgcColumnGroupingComponent, _super);
function IgcColumnGroupingComponent() {
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._renderer = new WebComponentRenderer(_this, document, true, null);
_this._implementation = _this.createImplementation();
_this._container = _this._renderer.createElement("div");
_this._renderer.updateRoot(_this._container);
//this._renderer.rootWrapper.append(this._container);
_this._container.setStyleProperty("display", "block");
_this._container.setStyleProperty("width", "100%");
_this._container.setStyleProperty("height", "100%");
var columnGrouping = _this.i;
_this._columnGrouping = columnGrouping;
_this._renderer.addSizeWatcher(function () {
_this._columnGrouping.notifySizeChanged();
});
return _this;
}
Object.defineProperty(IgcColumnGroupingComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = value;
this.style.height = value;
this.i.notifySizeChanged();
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColumnGroupingComponent.prototype, "width", {
get: function () {
return this._width;
},
set: function (value) {
this._width = value;
this.style.width = value;
this.i.notifySizeChanged();
},
enumerable: false,
configurable: true
});
// supports angular themes or custom properties set in CSS
IgcColumnGroupingComponent.prototype.updateStyle = function () {
this._styling(this, this);
};
IgcColumnGroupingComponent.prototype.destroy = function () {
this._columnGrouping.destroy();
};
IgcColumnGroupingComponent.prototype.createImplementation = function () {
return new ColumnGrouping();
};
IgcColumnGroupingComponent.prototype.disconnectedCallback = function () {
this._disconnected = true;
};
IgcColumnGroupingComponent.prototype.connectedCallback = function () {
if (this._disconnected) {
this._disconnected = false;
return;
}
this.classList.add("ig-column-grouping");
this.classList.add("igc-column-grouping");
var rootWrapper = this._renderer.rootWrapper;
var rootElement = rootWrapper.getNativeElement();
this.appendChild(rootElement);
this._attached = true;
this.style.display = "block";
this.style.height = this._height;
this.style.width = this._width;
var groupAreaContainer = this._renderer.createElement("div");
this._container.append(groupAreaContainer);
this._columnGrouping.provideContainer(this._renderer);
this._columnGrouping.notifySizeChanged();
this._flushQueuedAttributes();
// supports themes or custom properties set in CSS
this._styling(this, this);
this.afterContentInit();
};
IgcColumnGroupingComponent.prototype.afterContentInit = function () {
this.i.notifySizeChanged();
};
Object.defineProperty(IgcColumnGroupingComponent.prototype, "i", {
/**
* @hidden
*/
get: function () {
return this._implementation;
} /**
* @hidden
*/,
enumerable: false,
configurable: true
});
IgcColumnGroupingComponent._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);
};
IgcColumnGroupingComponent.prototype._enqueueSetAttribute = function (attrName, attrValue) {
this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue });
};
IgcColumnGroupingComponent.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;
};
IgcColumnGroupingComponent.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(IgcColumnGroupingComponent, "observedAttributes", {
get: function () {
if (IgcColumnGroupingComponent._observedAttributesIgcColumnGroupingComponent == null) {
var names = getAllPropertyNames(IgcColumnGroupingComponent);
for (var i = 0; i < names.length; i++) {
names[i] = toSpinal(names[i]);
}
IgcColumnGroupingComponent._observedAttributesIgcColumnGroupingComponent = names;
}
return IgcColumnGroupingComponent._observedAttributesIgcColumnGroupingComponent;
},
enumerable: false,
configurable: true
});
IgcColumnGroupingComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) {
if (this._settingAttributes) {
return;
}
var setName = fromSpinal(name);
this._updatingFromAttribute = true;
this[setName] = newValue;
this._updatingFromAttribute = false;
};
IgcColumnGroupingComponent.register = function () {
if (!IgcColumnGroupingComponent._isElementRegistered) {
IgcColumnGroupingComponent._isElementRegistered = true;
RegisterElementHelper.registerElement(IgcColumnGroupingComponent.htmlTagName, IgcColumnGroupingComponent);
}
};
Object.defineProperty(IgcColumnGroupingComponent.prototype, "targetGrid", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
var r = this.i.targetGrid;
if (r == null) {
return null;
}
return r.externalObject;
},
set: function (v) {
if (v != null && this._stylingContainer && v._styling)
v._styling(this._stylingContainer, this, this);
v == null ? this.i.targetGrid = null : this.i.targetGrid = v.i;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColumnGroupingComponent.prototype, "baseTheme", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
return this.i.g;
},
set: function (v) {
this.i.g = ensureEnum(BaseControlTheme_$type, v);
this._a("baseTheme", enumToString(BaseControlTheme_$type, this.i.g));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColumnGroupingComponent.prototype, "density", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
return this.i.i;
},
set: function (v) {
this.i.i = ensureEnum(ControlDisplayDensity_$type, v);
this._a("density", enumToString(ControlDisplayDensity_$type, this.i.i));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColumnGroupingComponent.prototype, "title", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
return this.i.al;
},
set: function (v) {
this.i.al = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColumnGroupingComponent.prototype, "titleColor", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
return brushToString(this.i.bm);
},
set: function (v) {
this.i.bm = stringToBrush(v);
this._a("titleColor", brushToString(this.i.bm));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColumnGroupingComponent.prototype, "textStyle", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
if (this.i.k == null) {
return null;
}
return this.i.k.fontString;
},
set: function (v) {
var fi = new FontInfo();
fi.fontString = v;
this.i.k = fi;
this._a("textStyle", this.i.k != null ? this.i.k.fontString : "");
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColumnGroupingComponent.prototype, "textColor", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
return brushToString(this.i.bl);
},
set: function (v) {
this.i.bl = stringToBrush(v);
this._a("textColor", brushToString(this.i.bl));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColumnGroupingComponent.prototype, "iconColor", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
return brushToString(this.i.bi);
},
set: function (v) {
this.i.bi = stringToBrush(v);
this._a("iconColor", brushToString(this.i.bi));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColumnGroupingComponent.prototype, "itemBackgroundColor", {
/**
* Gets or sets the background color of the column items in the group area.
*/
get: function () {
return brushToString(this.i.bj);
},
set: function (v) {
this.i.bj = stringToBrush(v);
this._a("itemBackgroundColor", brushToString(this.i.bj));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColumnGroupingComponent.prototype, "itemHoverBackgroundColor", {
/**
* Gets or sets the background color of the column items when hovered by the mouse.
*/
get: function () {
return brushToString(this.i.bk);
},
set: function (v) {
this.i.bk = stringToBrush(v);
this._a("itemHoverBackgroundColor", brushToString(this.i.bk));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcColumnGroupingComponent.prototype, "backgroundColor", {
/**
* Gets or sets the background of the group by area.
*/
get: function () {
return brushToString(this.i.bh);
},
set: function (v) {
this.i.bh = stringToBrush(v);
this._a("backgroundColor", brushToString(this.i.bh));
},
enumerable: false,
configurable: true
});
IgcColumnGroupingComponent.prototype.findByName = function (name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
if (this.targetGrid && this.targetGrid.name && this.targetGrid.name == name) {
return this.targetGrid;
}
return null;
};
Object.defineProperty(IgcColumnGroupingComponent.prototype, "hasUserValues", {
get: function () {
return this._hasUserValues;
},
enumerable: false,
configurable: true
});
IgcColumnGroupingComponent.prototype.__m = function (propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
};
IgcColumnGroupingComponent.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("ColumnGroupingComponent");
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.targetGrid && this.targetGrid._styling) {
this.targetGrid._styling(container, component, this);
}
if (this._otherStyling) {
this._otherStyling(container, component, parent);
}
this._inStyling = false;
};
/**
* Exports visual information about the current state of the grid.
*/
IgcColumnGroupingComponent.prototype.exportVisualModel = function () {
var iv = this.i.exportVisualModel();
return (iv);
};
/**
* Returns a serialized copy of the exported visual model
*/
IgcColumnGroupingComponent.prototype.exportSerializedVisualModel = function () {
var iv = this.i.exportSerializedVisualModel();
return (iv);
};
IgcColumnGroupingComponent._observedAttributesIgcColumnGroupingComponent = null;
IgcColumnGroupingComponent.htmlTagName = "igc-column-grouping";
IgcColumnGroupingComponent._isElementRegistered = false;
return IgcColumnGroupingComponent;
}(IgcHTMLElement));
export { IgcColumnGroupingComponent };