UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

357 lines (353 loc) 10.9 kB
import { IgrColumn } from "./igr-column"; import { IgrRowType } from "./igr-row-type"; import { IgrGridCellIdentifier } from "./igr-grid-cell-identifier"; import { CellType as CellType_internal } from "./CellType"; import { ensureBool, interfaceToInternal } from "igniteui-react-core"; import { GridValidationState } from "./GridValidationState"; /** * Interface representing a cell in the grid. It is essentially the blueprint to a cell object. * Contains definitions of properties and methods, relevant to a cell */ var IgrCellType = /** @class */ /*@__PURE__*/ (function () { function IgrCellType() { this.mounted = false; this._implementation = this.createImplementation(); this._implementation.externalObject = this; this.onImplementationCreated(); if (this._initializeAdapters) { this._initializeAdapters(); } } IgrCellType.prototype.createImplementation = function () { return new CellType_internal(); }; Object.defineProperty(IgrCellType.prototype, "nativeElement", { get: function () { return this._implementation.nativeElement; }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "i", { /** * @hidden */ get: function () { return this._implementation; }, enumerable: false, configurable: true }); IgrCellType.prototype.onImplementationCreated = function () { }; IgrCellType.prototype._provideImplementation = function (i) { this._implementation = i; this._implementation.externalObject = this; this.onImplementationCreated(); if (this._initializeAdapters) { this._initializeAdapters(); } }; Object.defineProperty(IgrCellType.prototype, "value", { /** * The current value of the cell. */ get: function () { return this.i.u; }, set: function (v) { this.i.u = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "editValue", { /** * The value to display when the cell is in edit mode. */ get: function () { return this.i.r; }, set: function (v) { this.i.r = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "selected", { /** * Indicates whether the cell is currently selected. It is false, if the sell is not selected, and true, if it is. */ get: function () { return this.i.m; }, set: function (v) { this.i.m = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "active", { /** * Indicates whether the cell is currently active (focused). */ get: function () { return this.i.i; }, set: function (v) { this.i.i = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "editable", { /** * Indicates whether the cell can be edited. */ get: function () { return this.i.j; }, set: function (v) { this.i.j = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "editMode", { /** * Indicates whether the cell is currently in edit mode. */ get: function () { return this.i.k; }, set: function (v) { this.i.k = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "column", { /** * Represents the column that the cell belongs to. */ get: function () { var r = this.i.b; if (r == null) { return null; } if (!r.externalObject) { var e = IgrColumn._createFromInternal(r); if (e) { e._implementation = r; } r.externalObject = e; } return r.externalObject; }, set: function (v) { v == null ? this.i.b = null : this.i.b = v.i; }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "row", { /** * Represents the row that the cell belongs to */ 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(IgrCellType.prototype, "grid", { /** * Represents the grid instance containing the cell */ 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(IgrCellType.prototype, "id", { /** * Optional; An object identifying the cell. It contains rowID, columnID, and rowIndex of the cell. */ get: function () { var r = this.i.d; if (r == null) { return null; } if (!r.externalObject) { var e = new IgrGridCellIdentifier(); 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.d = null : this.i.d = v.i; }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "cellID", { /** * Optional; The `cellID` is the unique key, used to identify the cell */ get: function () { return this.i.q; }, set: function (v) { this.i.q = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "validation", { /** * Optional; An object representing the validation state of the cell. * Whether it's valid or invalid, and if it has errors */ get: function () { return this.i.e.nativeElement; }, set: function (v) { this.i.e = interfaceToInternal(v, function () { return new GridValidationState(); }); }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "readonly", { get: function () { return this.i.l; }, set: function (v) { this.i.l = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "title", { /** * An optional title to display for the cell */ get: function () { return this.i.t; }, set: function (v) { this.i.t = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "width", { /** * The CSS width of the cell as a string. */ get: function () { return this.i.v; }, set: function (v) { this.i.v = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrCellType.prototype, "visibleColumnIndex", { /** * The index of the column that the cell belongs to. It counts only the visible (not hidden) columns */ get: function () { return this.i.o; }, set: function (v) { this.i.o = +v; }, enumerable: false, configurable: true }); IgrCellType.prototype.findByName = function (name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } if (this.column && this.column.name && this.column.name == name) { return this.column; } if (this.row && this.row.name && this.row.name == name) { return this.row; } if (this.grid && this.grid.name && this.grid.name == name) { return this.grid; } if (this.id && this.id.name && this.id.name == name) { return this.id; } if (this.validation && this.validation.name && this.validation.name == name) { return this.validation; } return null; }; IgrCellType.prototype.setNativeElement = function (element) { this.i.setNativeElement(element); }; /** * A method definition to update the value of the cell. */ IgrCellType.prototype.update = function (value) { this.i.y(value); }; /** * A method definition to start or end the edit mode of the cell. It takes a boolean value as an argument */ IgrCellType.prototype.setEditMode = function (value) { this.i.w(value); }; /** * Optional; * A method definition to calculate the size of the cell to fit the content * The method can be used to calculate the size of the cell with the longest content and resize all cells to that size */ IgrCellType.prototype.calculateSizeToFit = function (range) { var iv = this.i.n(range); return (iv); }; return IgrCellType; }()); export { IgrCellType };