igniteui-react-grids
Version:
Ignite UI React grid components.
987 lines (981 loc) • 23.9 kB
JavaScript
import { CellContentHorizontalAlignment, CellContentHorizontalAlignment_$type } from "./CellContentHorizontalAlignment";
import { CellContentVerticalAlignment_$type } from "./CellContentVerticalAlignment";
import { TextCellLineBreakMode_$type } from "./TextCellLineBreakMode";
import { ColumnSortDirection_$type } from "./ColumnSortDirection";
import { ensureBool, ensureEnum, brushToString, stringToBrush } from "igniteui-react-core";
import { FontInfo } from "igniteui-react-core";
import { delegateCombine, delegateRemove, runOn } from "igniteui-react-core";
import { PinnedPositions_$type } from './PinnedPositions';
/**
* Represents info about the current cell.
*/
export class IgrCellInfo {
createImplementation() {
return null;
}
get i() {
return this._implementation;
}
constructor() {
this._onChanged = [];
this._changed = false;
this._implementation = this.createImplementation();
this._implementation.externalObject = this;
this.onImplementationCreated();
}
_provideImplementation(i) {
this._implementation = i;
this._implementation.externalObject = this;
this.onImplementationCreated();
}
onImplementationCreated() {
}
addOnChangedListener(listener) {
if (this._onChanged.length == 0) {
this.i.propertyChanged = delegateCombine(this.i.propertyChanged, runOn(this, this._implementation_propertyChanged));
this.i.cellReconciling = delegateCombine(this.i.cellReconciling, runOn(this, this._implementation_cellReconciling));
}
this._onChanged.push(listener);
}
removeOnChangedListener(listener) {
let ind = this._onChanged.indexOf(listener);
if (ind < 0) {
return;
}
this._onChanged.splice(ind, 1);
if (this._onChanged.length == 0) {
this.i.propertyChanged = delegateRemove(this.i.propertyChanged, runOn(this, this._implementation_propertyChanged));
this.i.cellReconciling = delegateRemove(this.i.cellReconciling, runOn(this, this._implementation_cellReconciling));
}
}
_implementation_propertyChanged(sender, args) {
this._changed = true;
}
_implementation_cellReconciling(model) {
if (this._changed && this._onChanged !== null && this._onChanged.length > 0) {
this._changed = false;
for (let i = 0; i < this._onChanged.length; i++) {
this._onChanged[i]();
}
}
this._changed = false;
}
get resolvedTextAlign() {
switch (this.horizontalAlignment) {
case CellContentHorizontalAlignment.Center:
return "center";
case CellContentHorizontalAlignment.Left:
return "left";
case CellContentHorizontalAlignment.Right:
return "right";
case CellContentHorizontalAlignment.Stretch:
return "center";
}
return "left";
}
get resolvedContentOpacity() {
let virtualPercent = Math.min(1.0, Math.max(0.0, this.virtualizationPercentage));
let opacity = this.contentOpacity * (1.0 - virtualPercent);
return opacity;
}
/**
* Gets the style key of the current cell, used for recycling.
*/
get styleKey() {
return this.i.kc;
}
set styleKey(v) {
this.i.kc = v;
}
/**
* Gets the absolute data row for the current cell.
*/
get dataRow() {
return this.i.fb;
}
set dataRow(v) {
this.i.fb = +v;
}
/**
* Gets if the position of the cell is dirty.
*/
get isPositionDirty() {
return this.i.bj;
}
set isPositionDirty(v) {
this.i.bj = ensureBool(v);
}
/**
* Gets if the size of the cell is dirty.
*/
get isSizeDirty() {
return this.i.bo;
}
set isSizeDirty(v) {
this.i.bo = ensureBool(v);
}
/**
* Gets if the content of the cell is dirty.
*/
get isContentDirty() {
return this.i.a3;
}
set isContentDirty(v) {
this.i.a3 = ensureBool(v);
}
/**
* Gets if the content of the cell is dirty.
*/
get isBorderDirty() {
return this.i.a1;
}
set isBorderDirty(v) {
this.i.a1 = ensureBool(v);
}
/**
* Gets if the layer of the cell is dirty.
*/
get isLayerDirty() {
return this.i.bh;
}
set isLayerDirty(v) {
this.i.bh = ensureBool(v);
}
/**
* Gets if the layer of the cell is dirty.
*/
get isStateDirty() {
return this.i.bp;
}
set isStateDirty(v) {
this.i.bp = ensureBool(v);
}
/**
* Gets if the data of the cell is dirty.
*/
get isDataDirty() {
return this.i.a5;
}
set isDataDirty(v) {
this.i.a5 = ensureBool(v);
}
/**
* Gets if placeholder content is needed when virtualized.
*/
get isPlaceholdContentNeeded() {
return this.i.bi;
}
set isPlaceholdContentNeeded(v) {
this.i.bi = ensureBool(v);
}
/**
* Gets the action manager to propagate actions back to the grid.
*/
get actionManager() {
return this.i.c;
}
set actionManager(v) {
this.i.c = v;
}
/**
* Gets or sets whether the cell is hit test visible.
*/
get isHitTestVisible() {
return this.i.bd;
}
set isHitTestVisible(v) {
this.i.bd = ensureBool(v);
}
/**
* Gets if this cell belongs to a row that has been marked as pinned.
*/
get isRowPinned() {
return this.i.bk;
}
set isRowPinned(v) {
this.i.bk = ensureBool(v);
}
/**
* Gets if this cell belongs to a row that will stick to the top of the grid.
*/
get isRowSticky() {
return this.i.bl;
}
set isRowSticky(v) {
this.i.bl = ensureBool(v);
}
/**
* Gets if this cell is the last row that can stick to the top of the grid.
*/
get isLastStickyRow() {
return this.i.bg;
}
set isLastStickyRow(v) {
this.i.bg = ensureBool(v);
}
/**
* Gets if this cell is in the filter row.
*/
get isFilterRow() {
return this.i.bb;
}
set isFilterRow(v) {
this.i.bb = ensureBool(v);
}
/**
* Gets the indent level of the cell.
*/
get indent() {
return this.i.f0;
}
set indent(v) {
this.i.f0 = +v;
}
get rowItem() {
return this.i.hn;
}
set rowItem(v) {
this.i.hn = v;
}
/**
* Gets the X position of the cell within the content.
*/
get x() {
return this.i.cu;
}
set x(v) {
this.i.cu = +v;
}
/**
* Gets the Y position of the cell within the content.
*/
get y() {
return this.i.cv;
}
set y(v) {
this.i.cv = +v;
}
/**
* Gets the pixel snapped X position of the cell within the content.
*/
get snappedX() {
return this.i.g0;
}
set snappedX(v) {
this.i.g0 = +v;
}
/**
* Gets the snapped Y position of the cell within the content.
*/
get snappedY() {
return this.i.g2;
}
set snappedY(v) {
this.i.g2 = +v;
}
/**
* Gets or sets the opacity for cells that have unsaved edits.
*/
get editOpacity() {
return this.i.ck;
}
set editOpacity(v) {
this.i.ck = +v;
}
/**
* Gets or sets the opacity of the content of the cell.
*/
get contentOpacity() {
return this.i.cj;
}
set contentOpacity(v) {
this.i.cj = +v;
}
/**
* Gets the actual content opacity of the cell.
*/
get actualContentOpacity() {
return this.i.cg;
}
set actualContentOpacity(v) {
this.i.cg = +v;
}
/**
* Gets or sets the opacity of the cell.
*/
get opacity() {
return this.i.co;
}
set opacity(v) {
this.i.co = +v;
}
/**
* Gets the actual opacity of the cell.
*/
get actualOpacity() {
return this.i.ch;
}
set actualOpacity(v) {
this.i.ch = +v;
}
/**
* Gets the height of the cell.
*/
get height() {
return this.i.fu;
}
set height(v) {
this.i.fu = +v;
}
/**
* Gets the width of the cell.
*/
get width() {
return this.i.hd;
}
set width(v) {
this.i.hd = +v;
}
/**
* Gets if the cell is selected.
*/
get isSelected() {
return this.i.bn;
}
set isSelected(v) {
this.i.bn = ensureBool(v);
}
/**
* Gets the amount that the cell is selected. This is a value between 0 and 1.
*/
get selectedStatus() {
return this.i.cq;
}
set selectedStatus(v) {
this.i.cq = +v;
}
/**
* Gets the amount that the cell is activated. This is a value between 0 and 1.
*/
get activationStatus() {
return this.i.cf;
}
set activationStatus(v) {
this.i.cf = +v;
}
/**
* Gets the amount that the cell is hovered. This is a value between 0 and 1.
*/
get hoverStatus() {
return this.i.cl;
}
set hoverStatus(v) {
this.i.cl = +v;
}
/**
* Gets whether the cell is hoverable or not.
*/
get isHoverable() {
return this.i.be;
}
set isHoverable(v) {
this.i.be = ensureBool(v);
}
/**
* Gets or sets the horiztonal alignment of the cell content.
*/
get horizontalAlignment() {
return this.i.g;
}
set horizontalAlignment(v) {
this.i.g = ensureEnum(CellContentHorizontalAlignment_$type, v);
}
/**
* Gets or sets the vertical alignment of the cell content.
*/
get verticalAlignment() {
return this.i.i;
}
set verticalAlignment(v) {
this.i.i = ensureEnum(CellContentVerticalAlignment_$type, v);
}
/**
* Gets or sets the background color of the cell.
*/
get background() {
return brushToString(this.i.lx);
}
set background(v) {
this.i.lx = stringToBrush(v);
}
/**
* Gets or sets the border color of the cell.
*/
get border() {
return brushToString(this.i.l0);
}
set border(v) {
this.i.l0 = stringToBrush(v);
}
/**
* Gets the actual background color of the cell
*/
get actualBackground() {
return brushToString(this.i.lu);
}
set actualBackground(v) {
this.i.lu = stringToBrush(v);
}
/**
* Gets the actual background color of the cell
*/
get actualBorder() {
return brushToString(this.i.lv);
}
set actualBorder(v) {
this.i.lv = stringToBrush(v);
}
/**
* Gets the actual background color of the cell
*/
get activationBorder() {
return brushToString(this.i.lt);
}
set activationBorder(v) {
this.i.lt = stringToBrush(v);
}
/**
* Gets or sets the error border color of the cell.
*/
get errorBorder() {
return brushToString(this.i.l2);
}
set errorBorder(v) {
this.i.l2 = stringToBrush(v);
}
/**
* Gets or sets the selected background color of the cell.
*/
get selectedBackground() {
return brushToString(this.i.l9);
}
set selectedBackground(v) {
this.i.l9 = stringToBrush(v);
}
/**
* Gets or sets the hover background color of the cell.
*/
get hoverBackground() {
return brushToString(this.i.l5);
}
set hoverBackground(v) {
this.i.l5 = stringToBrush(v);
}
/**
* Gets or sets the hover text color of the cell.
*/
get hoverTextColor() {
return brushToString(this.i.l6);
}
set hoverTextColor(v) {
this.i.l6 = stringToBrush(v);
}
/**
* Gets or sets the color for the sort indicator icon.
*/
get sortIndicatorColor() {
return brushToString(this.i.ma);
}
set sortIndicatorColor(v) {
this.i.ma = stringToBrush(v);
}
/**
* Gets or sets the background color for the cell when it is stuck to the top of the grid as a pinned row.
*/
get stickyRowBackground() {
return brushToString(this.i.mb);
}
set stickyRowBackground(v) {
this.i.mb = stringToBrush(v);
}
/**
* Gets or sets the background color for the cell that has been marked as pinned.
*/
get pinnedRowBackground() {
return brushToString(this.i.l8);
}
set pinnedRowBackground(v) {
this.i.l8 = stringToBrush(v);
}
/**
* Gets or sets the color for the last row in the sticky row area.
*/
get lastStickyRowBackground() {
return brushToString(this.i.l7);
}
set lastStickyRowBackground(v) {
this.i.l7 = stringToBrush(v);
}
/**
* Gets or sets the background color for filter row.
*/
get filterRowBackground() {
return brushToString(this.i.l3);
}
set filterRowBackground(v) {
this.i.l3 = stringToBrush(v);
}
/**
* Gets or sets the color to use for displaying text.
*/
get pinnedRowOpacity() {
return this.i.cp;
}
set pinnedRowOpacity(v) {
this.i.cp = +v;
}
/**
* Gets or sets the original value for the cell, before processing.
*/
get originalValue() {
return this.i.hm;
}
set originalValue(v) {
this.i.hm = v;
}
/**
* Gets or sets the text value, if any, which was rendered by a text cell.
*/
get renderValue() {
return this.i.j1;
}
set renderValue(v) {
this.i.j1 = v;
}
/**
* Gets or sets the color of the text for the cell, if any.
*/
get textColor() {
return brushToString(this.i.mc);
}
set textColor(v) {
this.i.mc = stringToBrush(v);
}
/**
* Gets the actual color of the text for the cell, if any.
*/
get actualTextColor() {
return brushToString(this.i.lw);
}
set actualTextColor(v) {
this.i.lw = stringToBrush(v);
}
/**
* Gets or sets the text color for cells in deleted rows.
*/
get deletedTextColor() {
return brushToString(this.i.l1);
}
set deletedTextColor(v) {
this.i.l1 = stringToBrush(v);
}
get font() {
if (this.i.ag == null) {
return null;
}
return this.i.ag.fontString;
}
set font(v) {
let fi = new FontInfo();
fi.fontString = v;
this.i.ag = fi;
}
get actualFont() {
if (this.i.ae == null) {
return null;
}
return this.i.ae.fontString;
}
set actualFont(v) {
let fi = new FontInfo();
fi.fontString = v;
this.i.ae = fi;
}
/**
* Gets or sets the line break mode to use if text is present in the cell.
*/
get lineBreakMode() {
return this.i.aa;
}
set lineBreakMode(v) {
this.i.aa = ensureEnum(TextCellLineBreakMode_$type, v);
}
/**
* Gets or sets the virtualization percentage value. This is between 0 an 1, and indicates how virtual the content is at present.
*/
get virtualizationPercentage() {
return this.i.ct;
}
set virtualizationPercentage(v) {
this.i.ct = +v;
}
/**
* Gets or sets the left padding to use for the content.
*/
get paddingLeft() {
return this.i.gm;
}
set paddingLeft(v) {
this.i.gm = +v;
}
/**
* Gets or sets the top padding to use for the content.
*/
get paddingTop() {
return this.i.gq;
}
set paddingTop(v) {
this.i.gq = +v;
}
/**
* Gets or sets the right padding to use for the content.
*/
get paddingRight() {
return this.i.go;
}
set paddingRight(v) {
this.i.go = +v;
}
/**
* Gets or sets the bottom padding to use for the content.
*/
get paddingBottom() {
return this.i.gk;
}
set paddingBottom(v) {
this.i.gk = +v;
}
/**
* Gets or sets the left padding to use for the content.
*/
get actualPaddingLeft() {
return this.i.el;
}
set actualPaddingLeft(v) {
this.i.el = +v;
}
/**
* Gets or sets the top padding to use for the content.
*/
get actualPaddingTop() {
return this.i.ep;
}
set actualPaddingTop(v) {
this.i.ep = +v;
}
/**
* Gets or sets the right padding to use for the content.
*/
get actualPaddingRight() {
return this.i.en;
}
set actualPaddingRight(v) {
this.i.en = +v;
}
/**
* Gets or sets the bottom padding to use for the content.
*/
get actualPaddingBottom() {
return this.i.ej;
}
set actualPaddingBottom(v) {
this.i.ej = +v;
}
/**
* Gets or sets the left border to use for the content.
*/
get borderLeftWidth() {
return this.i.e2;
}
set borderLeftWidth(v) {
this.i.e2 = +v;
}
/**
* Gets or sets the top border to use for the content.
*/
get borderTopWidth() {
return this.i.e7;
}
set borderTopWidth(v) {
this.i.e7 = +v;
}
/**
* Gets or sets the right border to use for the content.
*/
get borderRightWidth() {
return this.i.e5;
}
set borderRightWidth(v) {
this.i.e5 = +v;
}
/**
* Gets or sets the bottom border to use for the content.
*/
get borderBottomWidth() {
return this.i.e0;
}
set borderBottomWidth(v) {
this.i.e0 = +v;
}
/**
* Gets or sets the left activation border to use for the content.
*/
get activationBorderLeftWidth() {
return this.i.dy;
}
set activationBorderLeftWidth(v) {
this.i.dy = +v;
}
/**
* Gets or sets the top activation border to use for the content.
*/
get activationBorderTopWidth() {
return this.i.d3;
}
set activationBorderTopWidth(v) {
this.i.d3 = +v;
}
/**
* Gets or sets the right activation border to use for the content.
*/
get activationBorderRightWidth() {
return this.i.d1;
}
set activationBorderRightWidth(v) {
this.i.d1 = +v;
}
/**
* Gets or sets the bottom activation border to use for the content.
*/
get activationBorderBottomWidth() {
return this.i.dw;
}
set activationBorderBottomWidth(v) {
this.i.dw = +v;
}
/**
* Gets or sets the left error border to use for the content.
*/
get errorBorderLeftWidth() {
return this.i.fk;
}
set errorBorderLeftWidth(v) {
this.i.fk = +v;
}
/**
* Gets or sets the top error border to use for the content.
*/
get errorBorderTopWidth() {
return this.i.fp;
}
set errorBorderTopWidth(v) {
this.i.fp = +v;
}
/**
* Gets or sets the right error border to use for the content.
*/
get errorBorderRightWidth() {
return this.i.fn;
}
set errorBorderRightWidth(v) {
this.i.fn = +v;
}
/**
* Gets or sets the bottom error border to use for the content.
*/
get errorBorderBottomWidth() {
return this.i.fi;
}
set errorBorderBottomWidth(v) {
this.i.fi = +v;
}
/**
* Gets or sets the actual left border to use for the content.
*/
get actualBorderLeftWidth() {
return this.i.d9;
}
set actualBorderLeftWidth(v) {
this.i.d9 = +v;
}
/**
* Gets or sets the actual top border to use for the content.
*/
get actualBorderTopWidth() {
return this.i.ee;
}
set actualBorderTopWidth(v) {
this.i.ee = +v;
}
/**
* Gets or sets the actual right border to use for the content.
*/
get actualBorderRightWidth() {
return this.i.ec;
}
set actualBorderRightWidth(v) {
this.i.ec = +v;
}
/**
* Gets or sets the actual bottom border to use for the content.
*/
get actualBorderBottomWidth() {
return this.i.d7;
}
set actualBorderBottomWidth(v) {
this.i.d7 = +v;
}
/**
* Gets the current sort direction for the column containing the cell.
*/
get sortDirection() {
return this.i.n;
}
set sortDirection(v) {
this.i.n = ensureEnum(ColumnSortDirection_$type, v);
}
/**
* Gets the expansion state of the cell.
*/
get isExpanded() {
return this.i.ba;
}
set isExpanded(v) {
this.i.ba = ensureBool(v);
}
/**
* Gets if the cell needs to display an expansion indicator.
*/
get isCollapsable() {
return this.i.a2;
}
set isCollapsable(v) {
this.i.a2 = ensureBool(v);
}
/**
* Gets the fixed column position of this cell.
*/
get pinned() {
return this.i.y;
}
set pinned(v) {
this.i.y = ensureEnum(PinnedPositions_$type, v);
}
get editFont() {
if (this.i.af == null) {
return null;
}
return this.i.af.fontString;
}
set editFont(v) {
let fi = new FontInfo();
fi.fontString = v;
this.i.af = fi;
}
/**
* Gets whether the cell has been edited.
*/
get isEdited() {
return this.i.a9;
}
set isEdited(v) {
this.i.a9 = ensureBool(v);
}
/**
* Gets whether the cell is part of a deleted row.
*/
get isDeleted() {
return this.i.a6;
}
set isDeleted(v) {
this.i.a6 = ensureBool(v);
}
/**
* Gets or sets the error message for the cell.
*/
get editError() {
return this.i.it;
}
set editError(v) {
this.i.it = v;
}
/**
* Gets whether the cell is in edit mode.
*/
get isInEditMode() {
return this.i.bf;
}
set isInEditMode(v) {
this.i.bf = ensureBool(v);
}
get editID() {
return this.i.fg;
}
set editID(v) {
this.i.fg = +v;
}
findByName(name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
return null;
}
isCustomFieldDirty(propertyName) {
let iv = this.i.a4(propertyName);
return (iv);
}
/**
* Gets if a named property is dirty.
* @param propertyId * The property id to check.
*/
isDirtyById(propertyId_) {
let iv = this.i.a8(propertyId_);
return (iv);
}
/**
* Gets if a named property is dirty.
* @param propertyName * The property name to check.
*/
isDirty(propertyName) {
let iv = this.i.a7(propertyName);
return (iv);
}
setNamedValue(valueName, value) {
this.i.k8(valueName, value);
}
/**
* Returns if there is a named value stored for the cell.
* @param valueName * The name of the value to check.
*/
hasNamedValue(valueName) {
let iv = this.i.az(valueName);
return (iv);
}
/**
* Removes a named value from the cell.
* @param valueName * The name of the value to remove.
*/
removeNamedValue(valueName) {
this.i.k4(valueName);
}
/**
* Gets a named value from the cell.
* @param valueName * The name of the value to get.
*/
getNamedValue(valueName) {
let iv = this.i.hk(valueName);
return (iv);
}
}