UNPKG

igniteui-webcomponents-grids

Version:

Ignite UI Web Components grid components.

555 lines (552 loc) 20.6 kB
import { __extends } from "tslib"; import { ensureEnum, brushToString, stringToBrush, ensureBool, 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 { DataGridToolbar } from './DataGridToolbar'; import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core"; import { BaseControlTheme_$type } from "igniteui-webcomponents-core"; import { IgcHTMLElement } from "igniteui-webcomponents-core"; import { Thickness } from "igniteui-webcomponents-core"; var IgcDataGridToolbarComponent = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgcDataGridToolbarComponent, _super); function IgcDataGridToolbarComponent() { 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("width", "100%"); //this._container.setStyleProperty("height", "100%"); var toolbar = _this.i; _this._toolbar = toolbar; _this._renderer.addSizeWatcher(function () { _this._toolbar.notifySizeChanged(); }); return _this; } Object.defineProperty(IgcDataGridToolbarComponent.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(IgcDataGridToolbarComponent.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 IgcDataGridToolbarComponent.prototype.updateStyle = function () { this._styling(this, this); }; IgcDataGridToolbarComponent.prototype.destroy = function () { this._toolbar.destroy(); }; IgcDataGridToolbarComponent.prototype.createImplementation = function () { return new DataGridToolbar(); }; IgcDataGridToolbarComponent.prototype.disconnectedCallback = function () { this._disconnected = true; }; IgcDataGridToolbarComponent.prototype.connectedCallback = function () { if (this._disconnected) { this._disconnected = false; return; } this.classList.add("ig-data-grid-toolbar"); this.classList.add("igc-data-grid-toolbar"); 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 title = this._renderer.createElement("span"); this._container.append(title); var buttonsContainer = this._renderer.createElement("div"); this._container.append(buttonsContainer); var hideBtnContainer = this._renderer.createElement("div"); buttonsContainer.append(hideBtnContainer); var pinBtnContainer = this._renderer.createElement("div"); buttonsContainer.append(pinBtnContainer); var chooserDialog = this._renderer.createElement("div"); this._container.append(chooserDialog); var columnChooser = this._renderer.createElement("igc-column-chooser"); chooserDialog.append(columnChooser); var pinningDialog = this._renderer.createElement("div"); this._container.append(pinningDialog); var columnPinning = this._renderer.createElement("igc-column-pinning"); pinningDialog.append(columnPinning); this._toolbar.provideContainer(this._renderer, columnChooser.getNativeElement().i, columnPinning.getNativeElement().i); this._toolbar.notifySizeChanged(); this._flushQueuedAttributes(); // supports themes or custom properties set in CSS this._styling(this, this); this.afterContentInit(); }; IgcDataGridToolbarComponent.prototype.afterContentInit = function () { this.i.notifySizeChanged(); }; Object.defineProperty(IgcDataGridToolbarComponent.prototype, "i", { /** * @hidden */ get: function () { return this._implementation; } /** * @hidden */, enumerable: false, configurable: true }); IgcDataGridToolbarComponent._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); }; IgcDataGridToolbarComponent.prototype._enqueueSetAttribute = function (attrName, attrValue) { this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue }); }; IgcDataGridToolbarComponent.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; }; IgcDataGridToolbarComponent.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(IgcDataGridToolbarComponent, "observedAttributes", { get: function () { if (IgcDataGridToolbarComponent._observedAttributesIgcDataGridToolbarComponent == null) { var names = getAllPropertyNames(IgcDataGridToolbarComponent); for (var i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcDataGridToolbarComponent._observedAttributesIgcDataGridToolbarComponent = names; } return IgcDataGridToolbarComponent._observedAttributesIgcDataGridToolbarComponent; }, enumerable: false, configurable: true }); IgcDataGridToolbarComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) { if (this._settingAttributes) { return; } var setName = fromSpinal(name); this._updatingFromAttribute = true; this[setName] = newValue; this._updatingFromAttribute = false; }; IgcDataGridToolbarComponent.register = function () { if (!IgcDataGridToolbarComponent._isElementRegistered) { IgcDataGridToolbarComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcDataGridToolbarComponent.htmlTagName, IgcDataGridToolbarComponent); } }; Object.defineProperty(IgcDataGridToolbarComponent.prototype, "targetGrid", { /** * Gets or Sets the property name that contains the values. */ get: function () { var r = this.i.e; 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.e = null : this.i.e = v.i; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "toolbarTitle", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.ar; }, set: function (v) { this.i.ar = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "toolbarTitleStyle", { /** * Gets or Sets the property name that contains the values. */ get: function () { if (this.i.n == null) { return null; } return this.i.n.fontString; }, set: function (v) { var fi = new FontInfo(); fi.fontString = v; this.i.n = fi; this._a("toolbarTitleStyle", this.i.n != null ? this.i.n.fontString : ""); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "toolbarTitleColor", { /** * Gets or Sets the property name that contains the values. */ get: function () { return brushToString(this.i.bg); }, set: function (v) { this.i.bg = stringToBrush(v); this._a("toolbarTitleColor", brushToString(this.i.bg)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "backgroundColor", { /** * Gets or Sets the property name that contains the values. */ get: function () { return brushToString(this.i.be); }, set: function (v) { this.i.be = stringToBrush(v); this._a("backgroundColor", brushToString(this.i.be)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "dialogBackgroundColor", { /** * Gets or Sets the property name that contains the values. */ get: function () { return brushToString(this.i.bf); }, set: function (v) { this.i.bf = stringToBrush(v); this._a("dialogBackgroundColor", brushToString(this.i.bf)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "columnChooser", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.q; }, set: function (v) { this.i.q = ensureBool(v); this._a("columnChooser", this.i.q); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "columnChooserText", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.ad; }, set: function (v) { this.i.ad = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "columnChooserTitle", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.af; }, set: function (v) { this.i.af = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "columnPinning", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.r; }, set: function (v) { this.i.r = ensureBool(v); this._a("columnPinning", this.i.r); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "columnPinningText", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.ai; }, set: function (v) { this.i.ai = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "columnPinningTitle", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.ak; }, set: function (v) { this.i.ak = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "borderWidthBottom", { get: function () { return this.i.bi ? this.i.bi.bottom : NaN; }, set: function (v) { this.ensureBorderWidth(); this.i.bi.bottom = +v; this._a("borderWidthBottom", this.i.bi.bottom); this.i.bi = this.i.bi; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "borderWidthLeft", { get: function () { return this.i.bi ? this.i.bi.left : NaN; }, set: function (v) { this.ensureBorderWidth(); this.i.bi.left = +v; this._a("borderWidthLeft", this.i.bi.left); this.i.bi = this.i.bi; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "borderWidthRight", { get: function () { return this.i.bi ? this.i.bi.right : NaN; }, set: function (v) { this.ensureBorderWidth(); this.i.bi.right = +v; this._a("borderWidthRight", this.i.bi.right); this.i.bi = this.i.bi; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "borderWidthTop", { get: function () { return this.i.bi ? this.i.bi.top : NaN; }, set: function (v) { this.ensureBorderWidth(); this.i.bi.top = +v; this._a("borderWidthTop", this.i.bi.top); this.i.bi = this.i.bi; }, enumerable: false, configurable: true }); IgcDataGridToolbarComponent.prototype.ensureBorderWidth = function () { if (this.i.bi) { return; } this.i.bi = new Thickness(2); }; Object.defineProperty(IgcDataGridToolbarComponent.prototype, "density", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.l; }, set: function (v) { this.i.l = ensureEnum(ControlDisplayDensity_$type, v); this._a("density", enumToString(ControlDisplayDensity_$type, this.i.l)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridToolbarComponent.prototype, "baseTheme", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.j; }, set: function (v) { this.i.j = ensureEnum(BaseControlTheme_$type, v); this._a("baseTheme", enumToString(BaseControlTheme_$type, this.i.j)); }, enumerable: false, configurable: true }); IgcDataGridToolbarComponent.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(IgcDataGridToolbarComponent.prototype, "hasUserValues", { get: function () { return this._hasUserValues; }, enumerable: false, configurable: true }); IgcDataGridToolbarComponent.prototype.__m = function (propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } }; IgcDataGridToolbarComponent.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("DataGridToolbarComponent"); 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 toolbar. */ IgcDataGridToolbarComponent.prototype.exportVisualModel = function () { var iv = this.i.exportVisualModel(); return (iv); }; /** * Returns a serialized copy of the exported visual model */ IgcDataGridToolbarComponent.prototype.exportSerializedVisualModel = function () { var iv = this.i.exportSerializedVisualModel(); return (iv); }; IgcDataGridToolbarComponent._observedAttributesIgcDataGridToolbarComponent = null; IgcDataGridToolbarComponent.htmlTagName = "igc-data-grid-toolbar"; IgcDataGridToolbarComponent._isElementRegistered = false; return IgcDataGridToolbarComponent; }(IgcHTMLElement)); export { IgcDataGridToolbarComponent };