UNPKG

igniteui-webcomponents-grids

Version:

Ignite UI Web Components grid components.

334 lines (333 loc) 12.9 kB
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 { ColumnChooser } from './ColumnChooser'; import { BaseControlTheme_$type } from "igniteui-webcomponents-core"; import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core"; import { IgcHTMLElement } from "igniteui-webcomponents-core"; export let IgcColumnChooserComponent = /*@__PURE__*/ (() => { class IgcColumnChooserComponent 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 columnChooser = this.i; this._columnChooser = columnChooser; this._renderer.addSizeWatcher(() => { this._columnChooser.notifySizeChanged(); }); } // supports angular themes or custom properties set in CSS updateStyle() { this._styling(this, this); } destroy() { this._columnChooser.destroy(); } createImplementation() { return new ColumnChooser(); } disconnectedCallback() { this._disconnected = true; } connectedCallback() { if (this._disconnected) { this._disconnected = false; return; } this.classList.add("ig-column-chooser"); this.classList.add("igc-column-chooser"); 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 title = this._renderer.createElement("span"); this._container.append(title); var checkboxList = this._renderer.createElement("igc-checkbox-list"); this._container.append(checkboxList); this._columnChooser.provideContainer(this._renderer, checkboxList.getNativeElement().i); this._columnChooser.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 (IgcColumnChooserComponent._observedAttributesIgcColumnChooserComponent == null) { let names = getAllPropertyNames(IgcColumnChooserComponent); for (let i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcColumnChooserComponent._observedAttributesIgcColumnChooserComponent = names; } return IgcColumnChooserComponent._observedAttributesIgcColumnChooserComponent; } attributeChangedCallback(name, oldValue, newValue) { if (this._settingAttributes) { return; } let setName = fromSpinal(name); this._updatingFromAttribute = true; this[setName] = newValue; this._updatingFromAttribute = false; } static register() { if (!IgcColumnChooserComponent._isElementRegistered) { IgcColumnChooserComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcColumnChooserComponent.htmlTagName, IgcColumnChooserComponent); } } /** * Gets or Sets the property name that contains the values. */ get targetGrid() { const r = this.i.c; 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.c = null : this.i.c = v.i; } /** * Gets or Sets the property name that contains the values. */ get title() { return this.i.v; } set title(v) { this.i.v = v; } /** * Gets or Sets the property name that contains the values. */ get titleStyle() { if (this.i.j == null) { return null; } return this.i.j.fontString; } set titleStyle(v) { let fi = new FontInfo(); fi.fontString = v; this.i.j = fi; this._a("titleStyle", this.i.j != null ? this.i.j.fontString : ""); } /** * Gets or Sets the property name that contains the values. */ get titleColor() { return brushToString(this.i.ar); } set titleColor(v) { this.i.ar = stringToBrush(v); this._a("titleColor", brushToString(this.i.ar)); } /** * Gets or Sets the property name that contains the values. */ get filterPlaceholderText() { return this.i.s; } set filterPlaceholderText(v) { this.i.s = v; } /** * Gets or Sets the property name that contains the values. */ get baseTheme() { return this.i.f; } set baseTheme(v) { this.i.f = ensureEnum(BaseControlTheme_$type, v); this._a("baseTheme", enumToString(BaseControlTheme_$type, this.i.f)); } /** * Gets or Sets the property name that contains the values. */ get density() { return this.i.h; } set density(v) { this.i.h = ensureEnum(ControlDisplayDensity_$type, v); this._a("density", enumToString(ControlDisplayDensity_$type, this.i.h)); } /** * Gets or Sets the property name that contains the values. */ get backgroundColor() { return brushToString(this.i.aq); } set backgroundColor(v) { this.i.aq = stringToBrush(v); this._a("backgroundColor", brushToString(this.i.aq)); } 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("ColumnChooserComponent"); 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; } } IgcColumnChooserComponent._observedAttributesIgcColumnChooserComponent = null; IgcColumnChooserComponent.htmlTagName = "igc-column-chooser"; IgcColumnChooserComponent._isElementRegistered = false; return IgcColumnChooserComponent; })();