UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

495 lines (490 loc) 14.6 kB
import { IgrGroupByRecord } from "./igr-group-by-record"; import { IgrTreeGridRecord } from "./igr-tree-grid-record"; import { RowType as RowType_internal } from "./RowType"; import { ensureBool, interfaceToInternal } from "igniteui-react-core"; import { GridValidationState } from "./GridValidationState"; import { IgrCellType } from "./igr-cell-type"; /** * Interface representing a row in the grid. It is essentially the blueprint to a row object. * Contains definitions of properties and methods, relevant to a row */ var IgrRowType = /** @class */ /*@__PURE__*/ (function () { function IgrRowType() { this.mounted = false; this._implementation = this.createImplementation(); this._implementation.externalObject = this; this.onImplementationCreated(); if (this._initializeAdapters) { this._initializeAdapters(); } } IgrRowType.prototype.createImplementation = function () { return new RowType_internal(); }; Object.defineProperty(IgrRowType.prototype, "nativeElement", { get: function () { return this._implementation.nativeElement; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "i", { /** * @hidden */ get: function () { return this._implementation; }, enumerable: false, configurable: true }); IgrRowType.prototype.onImplementationCreated = function () { }; IgrRowType.prototype._provideImplementation = function (i) { this._implementation = i; this._implementation.externalObject = this; this.onImplementationCreated(); if (this._initializeAdapters) { this._initializeAdapters(); } }; Object.defineProperty(IgrRowType.prototype, "index", { /** * The index of the row within the grid */ get: function () { return this.i.u; }, set: function (v) { this.i.u = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "viewIndex", { get: function () { return this.i.v; }, set: function (v) { this.i.v = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "isGroupByRow", { /** * Indicates whether the row is grouped. */ get: function () { return this.i.q; }, set: function (v) { this.i.q = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "isSummaryRow", { get: function () { return this.i.r; }, set: function (v) { this.i.r = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "groupRow", { get: function () { var r = this.i.e; if (r == null) { return null; } if (!r.externalObject) { var e = new IgrGroupByRecord(); if (r.$type) { e._implementation = r; } else { if (e.i.setNativeElement) { e.i.setNativeElement(r); } } r.externalObject = e; } return r.externalObject; }, set: function (v) { v == null ? this.i.e = null : this.i.e = v.i; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "key", { get: function () { return this.i.z; }, set: function (v) { this.i.z = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "validation", { get: function () { return this.i.d.nativeElement; }, set: function (v) { this.i.d = interfaceToInternal(v, function () { return new GridValidationState(); }); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "data", { get: function () { return this.i.x; }, set: function (v) { this.i.x = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "cells", { /** * Optional * A list or an array of cells, that belong to the row */ get: function () { if (!this.i.a) { return undefined; } var ret = []; for (var i = 0; i < this.i.a.length; i++) { var impl = this.i.a[i]; if (!impl.externalObject) { if (impl instanceof IgrCellType) { ret.push(impl); continue; } var e = new IgrCellType(); e._implementation = impl; impl.externalObject = e; } ret.push(impl.externalObject); } return ret; }, set: function (v) { var arr = []; for (var i = 0; i < v.length; i++) { arr.push(v[i].i); } this.i.a = arr; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "disabled", { /** * Optional * Indicates whether the current row is disabled */ get: function () { return this.i.l; }, set: function (v) { this.i.l = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "pinned", { /** * Optional * Indicates whether the current row is pinned. */ get: function () { return this.i.s; }, set: function (v) { this.i.s = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "selected", { /** * Optional * Indicates whether the current row is selected */ get: function () { return this.i.t; }, set: function (v) { this.i.t = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "expanded", { /** * Optional * Indicates whether the current row is expanded. * The value is true, if the row is expanded and false, if it is collapsed */ get: function () { return this.i.m; }, set: function (v) { this.i.m = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "deleted", { /** * Optional * Indicates whether the row is marked for deletion. */ get: function () { return this.i.k; }, set: function (v) { this.i.k = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "inEditMode", { /** * Optional * Indicates whether the row is currently being edited. */ get: function () { return this.i.p; }, set: function (v) { this.i.p = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "children", { /** * Optional * Contains the child rows of the current row, if there are any. */ get: function () { if (!this.i.b) { return undefined; } var ret = []; for (var i = 0; i < this.i.b.length; i++) { var impl = this.i.b[i]; if (!impl.externalObject) { if (impl instanceof IgrRowType) { ret.push(impl); continue; } var e = new IgrRowType(); e._implementation = impl; impl.externalObject = e; } ret.push(impl.externalObject); } return ret; }, set: function (v) { var arr = []; for (var i = 0; i < v.length; i++) { arr.push(v[i].i); } this.i.b = arr; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "parent", { /** * Optional * Contains the parent row of the current row, if it has one. * If the parent row exist, it means that the current row is a child row */ get: function () { var r = this.i.f; if (r == null) { return null; } if (!r.externalObject) { var e = new IgrRowType(); if (r.$type) { e._implementation = r; } else { if (e.i.setNativeElement) { e.i.setNativeElement(r); } } r.externalObject = e; } return r.externalObject; }, set: function (v) { v == null ? this.i.f = null : this.i.f = v.i; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "hasChildren", { /** * Optional * Indicates whether the current row has any child rows */ get: function () { return this.i.o; }, set: function (v) { this.i.o = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "treeRow", { /** * Optional * Represents the hierarchical record associated with the row (for tree grids). * It is of type ITreeGridRecord, which contains the data, children, the hierarchical level, etc. */ get: function () { var r = this.i.g; if (r == null) { return null; } if (!r.externalObject) { var e = new IgrTreeGridRecord(); if (r.$type) { e._implementation = r; } else { if (e.i.setNativeElement) { e.i.setNativeElement(r); } } r.externalObject = e; } return r.externalObject; }, set: function (v) { v == null ? this.i.g = null : this.i.g = v.i; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "addRowUI", { get: function () { return this.i.j; }, set: function (v) { this.i.j = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "focused", { /** * Optional * Indicates whether the row is currently focused. */ get: function () { return this.i.n; }, set: function (v) { this.i.n = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "grid", { /** * Represent the grid instance, the row belongs to */ get: function () { var r = this.i.c; if (r == null) { return null; } return r.externalObject; }, set: function (v) { v == null ? this.i.c = null : this.i.c = v.i; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRowType.prototype, "ephemeralKey", { get: function () { return this.i.ab; }, enumerable: false, configurable: true }); IgrRowType.prototype.findByName = function (name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } if (this.groupRow && this.groupRow.name && this.groupRow.name == name) { return this.groupRow; } if (this.validation && this.validation.name && this.validation.name == name) { return this.validation; } if (this.parent && this.parent.name && this.parent.name == name) { return this.parent; } if (this.treeRow && this.treeRow.name && this.treeRow.name == name) { return this.treeRow; } if (this.grid && this.grid.name && this.grid.name == name) { return this.grid; } return null; }; IgrRowType.prototype.setNativeElement = function (element) { this.i.setNativeElement(element); }; /** * Optional * A method to handle changing the value of elements of the row * It takes the new value as an argument */ IgrRowType.prototype.update = function (value) { this.i.af(value); }; /** * Optional * A method to handle deleting rows */ IgrRowType.prototype.del = function () { var iv = this.i.y(); return (iv); }; /** * Optional * A method to handle pinning a row */ IgrRowType.prototype.pin = function () { this.i.ac(); }; /** * Optional * A method to handle unpinning a row, that has been pinned */ IgrRowType.prototype.unpin = function () { this.i.ae(); }; return IgrRowType; }()); export { IgrRowType };