igniteui-webcomponents-grids
Version:
Ignite UI Web Components grid components.
379 lines (376 loc) • 14.3 kB
JavaScript
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";
export let IgcColumnGroupingComponent = /*@__PURE__*/ (() => {
class IgcColumnGroupingComponent extends IgcHTMLElement {
set height(value) {
this._height = value;
this.style.height = value;
this.i.notifySizeChanged();
}
get height() {
return this._height;
}
set width(value) {
this._width = value;
this.style.width = value;
this.i.notifySizeChanged();
}
get width() {
return this._width;
}
constructor() {
super();
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(() => {
this._columnGrouping.notifySizeChanged();
});
}
// supports angular themes or custom properties set in CSS
updateStyle() {
this._styling(this, this);
}
destroy() {
this._columnGrouping.destroy();
}
createImplementation() {
return new ColumnGrouping();
}
disconnectedCallback() {
this._disconnected = true;
}
connectedCallback() {
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;
let 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();
}
afterContentInit() {
this.i.notifySizeChanged();
}
/**
* @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);
}
_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;
}
static get observedAttributes() {
if (IgcColumnGroupingComponent._observedAttributesIgcColumnGroupingComponent == null) {
let names = getAllPropertyNames(IgcColumnGroupingComponent);
for (let i = 0; i < names.length; i++) {
names[i] = toSpinal(names[i]);
}
IgcColumnGroupingComponent._observedAttributesIgcColumnGroupingComponent = names;
}
return IgcColumnGroupingComponent._observedAttributesIgcColumnGroupingComponent;
}
attributeChangedCallback(name, oldValue, newValue) {
if (this._settingAttributes) {
return;
}
let setName = fromSpinal(name);
this._updatingFromAttribute = true;
this[setName] = newValue;
this._updatingFromAttribute = false;
}
static register() {
if (!IgcColumnGroupingComponent._isElementRegistered) {
IgcColumnGroupingComponent._isElementRegistered = true;
RegisterElementHelper.registerElement(IgcColumnGroupingComponent.htmlTagName, IgcColumnGroupingComponent);
}
}
/**
* Gets or Sets the property name that contains the values.
*/
get targetGrid() {
const r = this.i.targetGrid;
if (r == null) {
return null;
}
return r.externalObject;
}
set targetGrid(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;
}
/**
* Gets or Sets the property name that contains the values.
*/
get baseTheme() {
return this.i.g;
}
set baseTheme(v) {
this.i.g = ensureEnum(BaseControlTheme_$type, v);
this._a("baseTheme", enumToString(BaseControlTheme_$type, this.i.g));
}
/**
* Gets or Sets the property name that contains the values.
*/
get density() {
return this.i.i;
}
set density(v) {
this.i.i = ensureEnum(ControlDisplayDensity_$type, v);
this._a("density", enumToString(ControlDisplayDensity_$type, this.i.i));
}
/**
* Gets or Sets the property name that contains the values.
*/
get title() {
return this.i.al;
}
set title(v) {
this.i.al = v;
}
/**
* Gets or Sets the property name that contains the values.
*/
get titleColor() {
return brushToString(this.i.bm);
}
set titleColor(v) {
this.i.bm = stringToBrush(v);
this._a("titleColor", brushToString(this.i.bm));
}
/**
* Gets or Sets the property name that contains the values.
*/
get textStyle() {
if (this.i.k == null) {
return null;
}
return this.i.k.fontString;
}
set textStyle(v) {
let fi = new FontInfo();
fi.fontString = v;
this.i.k = fi;
this._a("textStyle", this.i.k != null ? this.i.k.fontString : "");
}
/**
* Gets or Sets the property name that contains the values.
*/
get textColor() {
return brushToString(this.i.bl);
}
set textColor(v) {
this.i.bl = stringToBrush(v);
this._a("textColor", brushToString(this.i.bl));
}
/**
* Gets or Sets the property name that contains the values.
*/
get iconColor() {
return brushToString(this.i.bi);
}
set iconColor(v) {
this.i.bi = stringToBrush(v);
this._a("iconColor", brushToString(this.i.bi));
}
/**
* Gets or sets the background color of the column items in the group area.
*/
get itemBackgroundColor() {
return brushToString(this.i.bj);
}
set itemBackgroundColor(v) {
this.i.bj = stringToBrush(v);
this._a("itemBackgroundColor", brushToString(this.i.bj));
}
/**
* Gets or sets the background color of the column items when hovered by the mouse.
*/
get itemHoverBackgroundColor() {
return brushToString(this.i.bk);
}
set itemHoverBackgroundColor(v) {
this.i.bk = stringToBrush(v);
this._a("itemHoverBackgroundColor", brushToString(this.i.bk));
}
/**
* Gets or sets the background of the group by area.
*/
get backgroundColor() {
return brushToString(this.i.bh);
}
set backgroundColor(v) {
this.i.bh = stringToBrush(v);
this._a("backgroundColor", brushToString(this.i.bh));
}
findByName(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;
}
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("ColumnGroupingComponent");
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.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.
*/
exportVisualModel() {
let iv = this.i.exportVisualModel();
return (iv);
}
/**
* Returns a serialized copy of the exported visual model
*/
exportSerializedVisualModel() {
let iv = this.i.exportSerializedVisualModel();
return (iv);
}
}
IgcColumnGroupingComponent._observedAttributesIgcColumnGroupingComponent = null;
IgcColumnGroupingComponent.htmlTagName = "igc-column-grouping";
IgcColumnGroupingComponent._isElementRegistered = false;
return IgcColumnGroupingComponent;
})();