UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

400 lines (397 loc) 13.2 kB
import { __extends, __values } from "tslib"; import * as React from 'react'; import { delegateCombine, delegateRemove } from "igniteui-react-core"; import { toSpinal, brushToString, stringToBrush, initializePropertiesFromCss, NamePatcher, isValidProp, getModifiedProps } from "igniteui-react-core"; import { ReactRenderer } from "igniteui-react-core"; import { FontInfo } from "igniteui-react-core"; import { BrowserExecutionContext } from "./BrowserExecutionContext"; import { Pager } from "./Pager"; import { IgrPageChangedEventArgs } from "./igr-page-changed-event-args"; var PagerStylingDefaults = {}; var IgrDataGridPager = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgrDataGridPager, _super); function IgrDataGridPager(props) { var _this = _super.call(this, props) || this; _this._renderer = null; _this._dataSource = null; _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._getMainRef = _this._getMainRef.bind(_this); var root; root = _this._container; _this.requestRender = _this.requestRender.bind(_this); _this._implementation = new Pager(); _this._implementation.executionContext = new BrowserExecutionContext(null); _this._implementation.externalObject = _this; _this.initializeProperties(); return _this; } IgrDataGridPager.prototype._getMainRef = function (ref) { this._elRef = ref; if (this._elRef) { this._renderer = new ReactRenderer(this._elRef, document, true, PagerStylingDefaults, null); this.i.provideContainer(this._renderer); this._styling(this._elRef, this); } else { this.i.provideContainer(null); } }; IgrDataGridPager.prototype.render = function () { var div = React.createElement("div", { className: "ig-data-grid-pager igr-data-grid-pager", ref: this._getMainRef, }); return div; }; IgrDataGridPager.prototype.createImplementation = function () { return new Pager(); }; Object.defineProperty(IgrDataGridPager.prototype, "i", { get: function () { return this._implementation; }, enumerable: false, configurable: true }); IgrDataGridPager.prototype.onImplementationCreated = function () { }; IgrDataGridPager.prototype.requestRender = function () { this.setState({}); }; IgrDataGridPager.prototype.initializeContent = function () { if (this._dataSource) { this.i.itemsSource = this._dataSource; } }; IgrDataGridPager.prototype.destroy = function () { this._renderer.destroy(); }; IgrDataGridPager.prototype.componentWillUnmount = function () { }; IgrDataGridPager.prototype.componentDidMount = function () { this.initializeContent(); }; IgrDataGridPager.prototype.initializeProperties = function () { var e_1, _a; try { for (var _b = __values(Object.keys(this.props)), _c = _b.next(); !_c.done; _c = _b.next()) { var p = _c.value; if (isValidProp(this, p)) { this[p] = this.props[p]; } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } }; IgrDataGridPager.prototype.shouldComponentUpdate = function (nextProps, nextState) { var e_2, _a; var mod = getModifiedProps(this.props, nextProps); try { for (var _b = __values(Object.keys(mod)), _c = _b.next(); !_c.done; _c = _b.next()) { var p = _c.value; if (isValidProp(this, p)) { this[p] = mod[p]; } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_2) throw e_2.error; } } return true; }; IgrDataGridPager.prototype.containerResized = function () { //var width = this._container.clientWidth; //var height = this._container.clientHeight; }; ; Object.defineProperty(IgrDataGridPager.prototype, "actualDataSource", { get: function () { return this.i.actualDataSource; }, enumerable: false, configurable: true }); Object.defineProperty(IgrDataGridPager.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(IgrDataGridPager.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 }); Object.defineProperty(IgrDataGridPager.prototype, "pagerText", { get: function () { return this.i.a9; }, set: function (v) { this.i.a9 = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrDataGridPager.prototype, "pageSize", { /** * Gets or sets the page size. */ get: function () { return this.i.ao; }, set: function (v) { this.i.ao = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrDataGridPager.prototype, "pageCount", { /** * Gets the page count. */ get: function () { return this.i.an; }, set: function (v) { this.i.an = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrDataGridPager.prototype, "currentPage", { /** * Gets or sets the current page for the pager. */ get: function () { return this.i.ak; }, set: function (v) { this.i.ak = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrDataGridPager.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; }, enumerable: false, configurable: true }); Object.defineProperty(IgrDataGridPager.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); }, enumerable: false, configurable: true }); Object.defineProperty(IgrDataGridPager.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); }, enumerable: false, configurable: true }); IgrDataGridPager.prototype.findByName = function (name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } return null; }; Object.defineProperty(IgrDataGridPager.prototype, "hasUserValues", { get: function () { return this._hasUserValues; }, enumerable: false, configurable: true }); IgrDataGridPager.prototype.__m = function (propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } }; IgrDataGridPager.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("DataGridPager"); 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; }; IgrDataGridPager.prototype.nextPage = function () { this.i.bn(); }; IgrDataGridPager.prototype.previousPage = function () { this.i.by(); }; IgrDataGridPager.prototype.firstPage = function () { this.i.bk(); }; IgrDataGridPager.prototype.lastPage = function () { this.i.bm(); }; IgrDataGridPager.prototype.provideContainer = function (container) { this.i.provideContainer(container); }; /** * Exports visual information about the current state of the grid. */ IgrDataGridPager.prototype.exportVisualModel = function () { var iv = this.i.as(); return (iv); }; /** * Returns a serialized copy of the exported visual model */ IgrDataGridPager.prototype.exportSerializedVisualModel = function () { var iv = this.i.az(); return (iv); }; Object.defineProperty(IgrDataGridPager.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 IgrPageChangedEventArgs(); 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 }); return IgrDataGridPager; }(React.Component)); export { IgrDataGridPager };