UNPKG

igniteui-webcomponents-grids

Version:

Ignite UI Web Components grid components.

442 lines (439 loc) 16.3 kB
import { __extends } from "tslib"; import { delegateCombine, delegateRemove } from "igniteui-webcomponents-core"; import { getAllPropertyNames, fromSpinal, toSpinal, brushToString, stringToBrush, initializePropertiesFromCss, NamePatcher } from "igniteui-webcomponents-core"; import { WebComponentRenderer } from "igniteui-webcomponents-core"; import { RegisterElementHelper } from "igniteui-webcomponents-core"; import { FontInfo } from "igniteui-webcomponents-core"; import { BrowserExecutionContext } from "./BrowserExecutionContext"; import { Pager } from "./Pager"; import { IgcHTMLElement } from "igniteui-webcomponents-core"; import { IgcPageChangedEventArgs } from "./igc-page-changed-event-args"; var PagerStylingDefaults = {}; var IgcDataGridPagerComponent = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgcDataGridPagerComponent, _super); function IgcDataGridPagerComponent() { var _this = _super.call(this) || this; _this._contentInitialized = false; _this._renderer = null; _this._disconnected = false; _this.containerResized = function () { //var width = this._container.getNativeElement().clientWidth; //var height = this._container.getNativeElement().clientHeight; }; _this._dataSource = null; _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; _this._pageChanged = null; _this._pageChanged_wrapped = null; if (_this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this)); } _this._renderer = new WebComponentRenderer(_this, document, true, PagerStylingDefaults, null); _this._implementation = new Pager(); _this._implementation.executionContext = new BrowserExecutionContext(null); _this._implementation.externalObject = _this; _this._renderer.addSizeWatcher(function () { _this.containerResized(); }); return _this; } Object.defineProperty(IgcDataGridPagerComponent.prototype, "height", { get: function () { return this._height; }, set: function (value) { this._height = value; this.style.height = value; this.containerResized(); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridPagerComponent.prototype, "width", { get: function () { return this._width; }, set: function (value) { this._width = value; this.style.width = value; this.containerResized(); }, enumerable: false, configurable: true }); IgcDataGridPagerComponent.prototype.createImplementation = function () { return new Pager(); }; Object.defineProperty(IgcDataGridPagerComponent.prototype, "i", { get: function () { return this._implementation; }, enumerable: false, configurable: true }); IgcDataGridPagerComponent.prototype.onImplementationCreated = function () { }; IgcDataGridPagerComponent.prototype.disconnectedCallback = function () { this._disconnected = true; this._attached = false; }; IgcDataGridPagerComponent.prototype.connectedCallback = function () { if (this._disconnected) { this._disconnected = false; return; } // Apparently if you read or write the DOM in the constructor of the WebComponent the browser will error. We're supposed to do that // stuff in the connectedCallback. if (!this._contentInitialized) { this._implementation.provideContainer(this._renderer); this._contentInitialized = true; } this.classList.add("ig-data-grid-pager"); this.classList.add("igc-data-grid-pager"); this._attached = true; this.style.height = this._height; this.style.width = this._width; this._flushQueuedAttributes(); // supports themes or custom properties set in CSS this._styling(this, this); this.afterContentInit(); }; IgcDataGridPagerComponent.prototype.afterContentInit = function () { this.i.targetGrid = this.targetGrid.i; if (!this.targetGrid) { this.i.itemsSource = this._dataSource; } }; Object.defineProperty(IgcDataGridPagerComponent.prototype, "actualDataSource", { get: function () { return this.i.actualDataSource; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridPagerComponent.prototype, "dataSource", { get: function () { return this._dataSource; }, /** * Gets or sets the data used by the pager. * */ set: function (value) { this._dataSource = value; if (this.i != null) { this.i.itemsSource = this._dataSource; } }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridPagerComponent.prototype, "targetGrid", { get: function () { if (this.i.targetGrid == null) { return null; } return this.i.targetGrid.externalObject; }, /** * Gets or sets the target grid for the pager. * */ set: function (value) { value == null ? this.i.targetGrid = null : this.i.targetGrid = value.i; }, enumerable: false, configurable: true }); IgcDataGridPagerComponent.prototype._enqueueSetAttribute = function (attrName, attrValue) { this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue }); }; IgcDataGridPagerComponent.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; }; IgcDataGridPagerComponent.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(IgcDataGridPagerComponent, "observedAttributes", { get: function () { if (IgcDataGridPagerComponent._observedAttributesIgcDataGridPagerComponent == null) { var names = getAllPropertyNames(IgcDataGridPagerComponent); for (var i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcDataGridPagerComponent._observedAttributesIgcDataGridPagerComponent = names; } return IgcDataGridPagerComponent._observedAttributesIgcDataGridPagerComponent; }, enumerable: false, configurable: true }); IgcDataGridPagerComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) { if (this._settingAttributes) { return; } var setName = fromSpinal(name); this._updatingFromAttribute = true; this[setName] = newValue; this._updatingFromAttribute = false; }; IgcDataGridPagerComponent.register = function () { if (!IgcDataGridPagerComponent._isElementRegistered) { IgcDataGridPagerComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcDataGridPagerComponent.htmlTagName, IgcDataGridPagerComponent); } }; Object.defineProperty(IgcDataGridPagerComponent.prototype, "pagerText", { get: function () { return this.i.a9; }, set: function (v) { this.i.a9 = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridPagerComponent.prototype, "pageSize", { /** * Gets or sets the page size. */ get: function () { return this.i.ao; }, set: function (v) { this.i.ao = +v; this._a("pageSize", this.i.ao); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridPagerComponent.prototype, "pageCount", { /** * Gets the page count. */ get: function () { return this.i.an; }, set: function (v) { this.i.an = +v; this._a("pageCount", this.i.an); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridPagerComponent.prototype, "currentPage", { /** * Gets or sets the current page for the pager. */ get: function () { return this.i.ak; }, set: function (v) { this.i.ak = +v; this._a("currentPage", this.i.ak); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridPagerComponent.prototype, "textStyle", { /** * Gets or sets the font to use for content cells */ get: function () { if (this.i.s == null) { return null; } return this.i.s.fontString; }, set: function (v) { var fi = new FontInfo(); fi.fontString = v; this.i.s = fi; this._a("textStyle", this.i.s != null ? this.i.s.fontString : ""); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridPagerComponent.prototype, "background", { /** * Gets or sets the background color to use. */ get: function () { return brushToString(this.i.ca); }, set: function (v) { this.i.ca = stringToBrush(v); this._a("background", brushToString(this.i.ca)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridPagerComponent.prototype, "border", { /** * Gets or sets the border color around the grid. */ get: function () { return brushToString(this.i.border); }, set: function (v) { this.i.border = stringToBrush(v); this._a("border", brushToString(this.i.border)); }, enumerable: false, configurable: true }); IgcDataGridPagerComponent.prototype.findByName = function (name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } return null; }; Object.defineProperty(IgcDataGridPagerComponent.prototype, "hasUserValues", { get: function () { return this._hasUserValues; }, enumerable: false, configurable: true }); IgcDataGridPagerComponent.prototype.__m = function (propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } }; IgcDataGridPagerComponent.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("DataGridPagerComponent"); 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._otherStyling) { this._otherStyling(container, component, parent); } this._inStyling = false; }; IgcDataGridPagerComponent.prototype.nextPage = function () { this.i.bn(); }; IgcDataGridPagerComponent.prototype.previousPage = function () { this.i.by(); }; IgcDataGridPagerComponent.prototype.firstPage = function () { this.i.bk(); }; IgcDataGridPagerComponent.prototype.lastPage = function () { this.i.bm(); }; IgcDataGridPagerComponent.prototype.provideContainer = function (container) { this.i.provideContainer(container); }; /** * Exports visual information about the current state of the grid. */ IgcDataGridPagerComponent.prototype.exportVisualModel = function () { var iv = this.i.as(); return (iv); }; /** * Returns a serialized copy of the exported visual model */ IgcDataGridPagerComponent.prototype.exportSerializedVisualModel = function () { var iv = this.i.az(); return (iv); }; Object.defineProperty(IgcDataGridPagerComponent.prototype, "pageChanged", { /** * Event called when the page has changed. */ get: function () { return this._pageChanged; }, set: function (ev) { var _this = this; if (this._pageChanged_wrapped !== null) { this.i.pageChanged = delegateRemove(this.i.pageChanged, this._pageChanged_wrapped); this._pageChanged_wrapped = null; this._pageChanged = null; } this._pageChanged = ev; this._pageChanged_wrapped = function (o, e) { var outerArgs = new IgcPageChangedEventArgs(); outerArgs._provideImplementation(e); if (_this.beforePageChanged) { _this.beforePageChanged(_this, outerArgs); } if (_this._pageChanged) { _this._pageChanged(_this, outerArgs); } }; this.i.pageChanged = delegateCombine(this.i.pageChanged, this._pageChanged_wrapped); ; }, enumerable: false, configurable: true }); IgcDataGridPagerComponent._observedAttributesIgcDataGridPagerComponent = null; IgcDataGridPagerComponent.htmlTagName = "igc-data-grid-pager"; IgcDataGridPagerComponent._isElementRegistered = false; return IgcDataGridPagerComponent; }(IgcHTMLElement)); export { IgcDataGridPagerComponent };