UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

732 lines (731 loc) 24.2 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { __extends } from "tslib"; import { Base, runOn, markType, PointUtil } from "igniteui-react-core"; import { INativeCell_$type } from "./INativeCell"; import { GridExpansionIndicator } from "./GridExpansionIndicator"; import { PlaceholderView } from "./PlaceholderView"; import { Color } from "igniteui-react-core"; import { TestRandomness } from "igniteui-react-core"; import { Random } from "igniteui-react-core"; import { DefaultRandomnessSource } from "igniteui-react-core"; import { DeviceUtils } from "igniteui-react-core"; import { intDivide, truncate, isNaN_ } from "igniteui-react-core"; /** * @hidden */ var GridCellBase = /** @class */ /*@__PURE__*/ (function (_super) { __extends(GridCellBase, _super); function GridCellBase(a) { var _this = _super.call(this) || this; _this.a = null; _this.e = null; _this.c = null; _this.ad = null; _this.af = null; _this.s = false; _this.ag = null; _this.i = null; _this.as = 0; _this.ap = 24; _this.ar = 0; _this.aq = 0; _this.av = 0; _this.p = false; _this.q = false; _this.r = true; _this.n = false; _this.ax = 0; _this.az = 0; _this.ay = 0; _this.aw = 0; _this.ak = 0; _this.am = 0; _this.al = 0; _this.aj = 0; _this.cj = null; _this.at = 0; _this.a2 = 0; _this.au = 0; _this.j = null; _this.g = 0; _this.h = 0; _this.ac = 0; _this.ab = 0; _this.t = false; _this.a8 = 0; _this.a9 = 0; _this.ai = 0; _this.a1 = -1; _this.an = 0; _this.o = false; _this.ad = a; _this.af = _this.ad.createElement("div"); _this.af.setAttribute("tabindex", "-1"); _this.af.setRawStyleProperty("position", "absolute"); _this.af.setRawStyleProperty("overflow", "hidden"); _this.af.setRawStyleProperty("box-sizing", "border-box"); _this.af.setRawStyleProperty("outline", "none"); var b = (window.navigator.msPointerEnabled && window.MSGesture !== undefined); var c = (window.PointerEvent !== undefined); var d = (window.TouchEvent); if ((b || c)) { _this.af.listen("pointerdown", runOn(_this, _this.bt)); _this.af.listen("pointerup", runOn(_this, _this.bx)); _this.af.listen("pointermove", runOn(_this, _this.bw)); _this.af.listen("pointerleave", runOn(_this, _this.bv)); _this.af.listen("pointerenter", runOn(_this, _this.bu)); } else { _this.af.listen("mousedown", runOn(_this, _this.bj)); _this.af.listen("mouseup", runOn(_this, _this.bn)); _this.af.listen("mousemove", runOn(_this, _this.bm)); _this.af.listen("mouseleave", runOn(_this, _this.bl)); _this.af.listen("touchstart", runOn(_this, _this.cb)); _this.af.listen("touchend", runOn(_this, _this.cd)); _this.af.listen("touchmove", runOn(_this, _this.cc)); } return _this; } Object.defineProperty(GridCellBase.prototype, "b", { get: function () { return this.a; }, enumerable: false, configurable: true }); Object.defineProperty(GridCellBase.prototype, "f", { get: function () { return this.e; }, enumerable: false, configurable: true }); Object.defineProperty(GridCellBase.prototype, "d", { get: function () { return this.c; }, enumerable: false, configurable: true }); Object.defineProperty(GridCellBase.prototype, "ae", { get: function () { return this.ad; }, enumerable: false, configurable: true }); Object.defineProperty(GridCellBase.prototype, "ah", { get: function () { return this.af; }, enumerable: false, configurable: true }); Object.defineProperty(GridCellBase.prototype, "isRemoved", { get: function () { return this.s; }, set: function (a) { var b = this.s; this.s = a; if (b != this.s) { this.bs("IsRemoved", b, this.s); } }, enumerable: false, configurable: true }); Object.defineProperty(GridCellBase.prototype, "a5", { get: function () { return this.as; }, enumerable: false, configurable: true }); Object.defineProperty(GridCellBase.prototype, "a3", { get: function () { return this.aq; }, enumerable: false, configurable: true }); Object.defineProperty(GridCellBase.prototype, "a4", { get: function () { return this.ar; }, enumerable: false, configurable: true }); Object.defineProperty(GridCellBase.prototype, "a6", { get: function () { return this.av; }, set: function (a) { var b = this.av; this.av = a; if (b != this.av) { this.bs("Indent", b, this.av); } }, enumerable: false, configurable: true }); Object.defineProperty(GridCellBase.prototype, "v", { get: function () { return this.p; }, set: function (a) { var b = this.p; this.p = a; if (b != this.p) { this.bs("IsCollapsable", b, this.p); } }, enumerable: false, configurable: true }); Object.defineProperty(GridCellBase.prototype, "w", { get: function () { return this.q; }, set: function (a) { var b = this.q; this.q = a; if (b != this.q) { this.bs("IsExpanded", b, this.q); } }, enumerable: false, configurable: true }); Object.defineProperty(GridCellBase.prototype, "y", { get: function () { return this.r; }, set: function (a) { var b = this.r; this.r = a; if (b != this.r) { this.bs("IsHitTestVisible", b, this.r); } }, enumerable: false, configurable: true }); GridCellBase.prototype.bi = function () { this.ar = 10; this.aq = this.a6 * 24; this.as = 24; if (this.ag == null) { this.ag = this.ad.createElement("div"); this.ag.setRawStyleProperty("display", "inline-block"); this.ag.setRawStyleProperty("vertical-align", "middle"); this.ag.setRawStyleProperty("width", this.as + "px"); this.ag.setRawStyleProperty("height", this.as + "px"); this.ag.setRawStyleProperty("cursor", "pointer"); this.ag.setRawStyleProperty("position", "absolute"); this.ag.setRawXPosition(this.ax + this.aq); this.ag.setRawYPosition(intDivide(this.at, 2) - intDivide(this.ap, 2)); } if (this.i == null) { var a = this.ad.getSubRenderer(this.ag); this.i = new GridExpansionIndicator(); this.i.ab(a); this.i.y(24, 24); } if (this.ag.parent() == null) { this.af.append(this.ag); } }; GridCellBase.prototype.by = function () { this.as = 0; this.ar = 0; if (this.ag != null) { if (this.ag.parent() != null) { this.ag.remove(); } } }; Object.defineProperty(GridCellBase.prototype, "u", { get: function () { return this.n; }, set: function (a) { this.n = a; }, enumerable: false, configurable: true }); GridCellBase.prototype.get_z = function () { return false; }; Object.defineProperty(GridCellBase.prototype, "z", { get: function () { return this.get_z(); }, enumerable: false, configurable: true }); GridCellBase.prototype.b7 = function (a, b, c, d) { this.ax = a; this.az = b; this.ay = c; this.aw = d; this.af.setRawStyleProperty("padding-left", a.toString() + "px"); this.af.setRawStyleProperty("padding-top", b.toString() + "px"); this.af.setRawStyleProperty("padding-right", c.toString() + "px"); this.af.setRawStyleProperty("padding-bottom", d.toString() + "px"); }; GridCellBase.prototype.b1 = function (a, b, c, d, e) { this.ak = b; this.am = c; this.al = d; this.aj = e; this.cj = a; if (a == null) { this.af.setRawStyleProperty("border", ""); } else { this.af.setRawStyleProperty("border-color", a._fill); this.af.setRawStyleProperty("border-left-width", b.toString() + "px"); this.af.setRawStyleProperty("border-top-width", c.toString() + "px"); this.af.setRawStyleProperty("border-right-width", d.toString() + "px"); this.af.setRawStyleProperty("border-bottom-width", e.toString() + "px"); this.af.setRawStyleProperty("border-style", "solid"); } }; GridCellBase.prototype.get_x = function () { return false; }; Object.defineProperty(GridCellBase.prototype, "x", { get: function () { return this.get_x(); }, enumerable: false, configurable: true }); GridCellBase.prototype.b3 = function (a, b) { if (this.at != a || this.au != b) { var c = this.at; this.at = a; this.au = b; var d = Math.max(0, this.at - this.au); this.af.setRawStyleProperty("height", a.toString() + "px"); this.af.setRawStyleProperty("line-height", d.toString() + "px"); if (this.ag != null) { this.ag.setRawYPosition(intDivide(this.at, 2) - intDivide(this.as, 2)); } this.ca(this.a2, this.at, this.a2, c); } }; GridCellBase.prototype.b9 = function (a, b) { if (this.a2 != a) { var c = this.a2; this.a2 = a; this.af.setRawStyleProperty("width", a.toString() + "px"); this.ca(this.a2, this.at, c, this.at); } }; GridCellBase.prototype.ca = function (a, b, c, d) { }; GridCellBase.prototype.bg = function () { if (!this.z) { return; } this.n = true; this.j = new PlaceholderView(this.ad); this.g = 0; this.h = 1; this.j.l = Color.u(120, 120, 120, 120); this.j.i = 0; this.af.append(this.j.g); }; GridCellBase.prototype.b0 = function (a) { this.af.setRawStyleProperty("background-color", a.colorString); }; GridCellBase.prototype.b6 = function (a) { this.af.setRawStyleProperty("opacity", a.toString()); }; GridCellBase.prototype.m = function () { if (TestRandomness.instance.testRandomnessSource != null) { return TestRandomness.instance.testRandomnessSource; } return new DefaultRandomnessSource(1, GridCellBase.a7); }; GridCellBase.prototype.l = function () { var a = this.m(); return a.getGenerator("PlaceholderWidths"); }; GridCellBase.prototype.ci = function (a) { if (!this.z) { return; } this.j.i = (a * 0.20000000298023224); }; GridCellBase.prototype.cg = function (a, b, c, d) { if (this.j != null) { var e = this.ac; var f = this.ab; if (this.h == 1) { b = truncate((b + (d / 2) - (f / 2))); } else if (this.h == 2) { b = truncate((b + (d) - (f))); } if (this.g == 1) { a = truncate((a + (c / 2) - (e / 2))); } else if (this.g == 2) { a = truncate((a + (c) - (e))); } this.j.g.setRawXPosition(a); this.j.g.setRawYPosition(b); } }; GridCellBase.prototype.bq = function (a, b, c) { }; GridCellBase.prototype.ch = function (a) { if (!this.z) { return; } var b = DeviceUtils.f(12); if (a.ag != null && !isNaN_(a.ag.f)) { b = a.ag.f; } if (this.ab != b) { this.ab = b; this.j.d = (b); } var c = a.hd * 0.2; var d = a.fu * 0.6; if (this.ac >= c && this.ac <= d && !this.t) { return; } this.t = false; if (GridCellBase.k == null) { GridCellBase.k = this.l(); } var e = (GridCellBase.k.nextDouble() * (d - c) + c); if (this.ac != e) { this.ac = e; this.j.e = e; } this.cg(this.ax + this.aq + this.as, this.az, this.a2 - (this.ax + this.ay), this.at - (this.az + this.aw)); }; GridCellBase.prototype.ce = function (a, b) { if (!this.z) { return; } this.g = a; this.h = b; this.t = true; }; GridCellBase.prototype.cf = function (a) { if (!this.z) { return; } if (a != null) { this.j.l = a.color; } }; GridCellBase.prototype.bz = function (a) { this.a = a; }; GridCellBase.prototype.b5 = function (a) { this.e = a; }; GridCellBase.prototype.b2 = function (a) { this.c = a; }; GridCellBase.prototype.b4 = function (a, b) { switch (b) { case 0: this.ah.setRawStyleProperty("text-align", "left"); break; case 1: this.ah.setRawStyleProperty("text-align", "center"); break; case 2: this.ah.setRawStyleProperty("text-align", "right"); break; case 3: this.ah.setRawStyleProperty("text-align", "center"); break; } }; GridCellBase.prototype.b8 = function (a, b) { switch (b) { case 0: a.setRawStyleProperty("vertical-align", "top"); break; case 1: a.setRawStyleProperty("vertical-align", "center"); break; case 2: a.setRawStyleProperty("vertical-align", "bottom"); break; case 3: a.setRawStyleProperty("vertical-align", "center"); break; } }; GridCellBase.prototype.aa = function (a) { return a.isClickActionDesired; }; GridCellBase.prototype.bj = function (a) { this.onContactStarted(a, false); }; GridCellBase.prototype.bn = function (a) { this.onContactCompleted(a, false); }; GridCellBase.prototype.bm = function (a) { this.onContactMoved(a, false); }; GridCellBase.prototype.bl = function (a) { this.bp(a, false); }; GridCellBase.prototype.bk = function (a) { this.bo(a, false); }; GridCellBase.prototype.bt = function (e_) { var a = (e_.originalEvent.pointerType); if (a == "touch") { this.cb(e_); } else { this.bj(e_); } }; GridCellBase.prototype.bw = function (e_) { var a = (e_.originalEvent.pointerType); if (a == "touch") { this.cc(e_); } else { this.bm(e_); } }; GridCellBase.prototype.bx = function (e_) { var a = (e_.originalEvent.pointerType); if (a == "touch") { this.cd(e_); } else { this.bn(e_); } }; GridCellBase.prototype.bv = function (e_) { var a = (e_.originalEvent.pointerType); if (a != "touch") { this.bl(e_); } }; GridCellBase.prototype.bu = function (e_) { var a = (e_.originalEvent.pointerType); if (a != "touch") { this.bk(e_); } }; GridCellBase.prototype.cb = function (a) { this.onContactStarted(a, true); }; GridCellBase.prototype.cc = function (a) { this.onContactMoved(a, true); }; GridCellBase.prototype.cd = function (a) { this.onContactCompleted(a, true); }; GridCellBase.prototype.onContactStarted = function (e_, a) { var b = false; if (this.v) { var indicator_ = this.i.q(); b = (e_.originalEvent.srcElement === indicator_ || e_.originalEvent.target === indicator_); } this.o = false; if (b) { this.o = true; } else { if (this.a != null && this.aa(this.a)) { this.a8 = e_.pageX; this.a9 = e_.pageY; if (this.a1 != e_.which) { this.an = 0; } this.a1 = e_.which; this.a.mouseDownCell(this.a8, this.a9); } } }; GridCellBase.prototype.onContactMoved = function (a, b) { if (this.a != null) { var c = a.pageX; var d = a.pageY; if (this.aa(this.a)) { if (this.a.isMouseDown) { if (b) { if (PointUtil.equals(this.a.mousePosition, null) || Math.abs(c - this.a.mousePosition.x) > GridCellBase.a0 || Math.abs(d - this.a.mousePosition.y) > GridCellBase.a0) { this.a.mouseUpCell(c, d); } else { a.stopPropagation(); } } else { if (PointUtil.equals(this.a.mousePosition, null)) { this.a.mouseUpCell(c, d); } else if (this.a1 == 1) { if (Math.abs(c - this.a.mousePosition.x) > GridCellBase.ao || Math.abs(d - this.a.mousePosition.y) > GridCellBase.ao) { this.a.isControlPressed = a.ctrlKey; this.a.dragStarted(); } } } } } if (this.a.isHoverActionDesired) { this.a.mouseIsOver(c, d); } } }; GridCellBase.prototype.onContactCompleted = function (e_, a) { var _this = this; this.an++; window.setTimeout(function () { return _this.an = 0; }, 250); var b = false; if (this.v) { var indicator_ = this.i.q(); b = (e_.originalEvent.srcElement === indicator_ || e_.originalEvent.target === indicator_); } if (this.o && b) { this.b.clickExpansionIndicator(); } else { if (this.a != null && this.aa(this.a)) { var c = e_.pageX; var d = e_.pageY; if (PointUtil.equals(this.a.mousePosition, null) || Math.abs(c - this.a.mousePosition.x) > GridCellBase.a0 || Math.abs(d - this.a.mousePosition.y) > GridCellBase.a0 || this.a.isDrag) { this.a.mouseUpCell(c, d); } if (this.a.isCellDown()) { this.a.isControlPressed = e_.ctrlKey; this.a.isShiftPressed = e_.shiftKey; if (this.an > 1) { switch (this.a1) { case 1: this.a.doubleClicked(0); break; case 2: this.a.doubleClicked(1); break; case 3: this.a.doubleClicked(2); break; default: this.a.doubleClicked(3); break; } } else { switch (e_.which) { case 1: this.a.clickCell(0); break; case 2: this.a.clickCell(1); break; case 3: this.a.clickCell(2); break; default: this.a.clickCell(3); break; } } this.a.mouseUpCell(e_.pageX, e_.pageY); } } } this.o = false; }; GridCellBase.prototype.bp = function (a, b) { if (this.a != null) { if (this.aa(this.a)) { if (this.a.isMouseDown) { if (!b && PointUtil.notEquals(this.a.mousePosition, null)) { this.a.isControlPressed = a.ctrlKey; this.a.dragStarted(); } } } if (this.a.isLeaveActionDesired) { var c = a.pageX; var d = a.pageY; this.a.mouseLeaveCell(c, d); } } }; GridCellBase.prototype.bo = function (a, b) { if (this.a != null && this.a.isEnterActionDesired) { var c = a.pageX; var d = a.pageY; this.a.mouseEnterCell(c, d); } }; GridCellBase.prototype.onDoubleClick = function (a) { }; GridCellBase.prototype.bs = function (a, b, c) { switch (a) { case "Indent": this.aq = this.a6 * 24; this.ar = this.a6 > 0 ? 10 : 0; if (this.ag != null) { this.ag.setRawXPosition(this.ax + this.aq); this.ag.setRawYPosition(intDivide(this.at, 2) - intDivide(this.ap, 2)); } break; case "IsCollapsable": if (this.v) { this.bi(); } else { this.by(); } break; case "IsExpanded": if (this.i != null) { this.i.g = this.w; } break; case "IsHitTestVisible": this.ah.setRawStyleProperty("pointer-events", this.y ? "auto" : "none"); break; } }; GridCellBase.prototype.br = function () { }; GridCellBase.prototype.bh = function () { this.af.focus(true); }; GridCellBase.prototype.bf = function () { if (this.a != null) { var a = this.af.clone(); this.a.passCellClone(a); } }; GridCellBase.prototype.detach = function () { }; GridCellBase.$t = markType(GridCellBase, 'GridCellBase', Base.$, [INativeCell_$type]); GridCellBase.k = null; GridCellBase.a7 = new Random(0); GridCellBase.a0 = 10; GridCellBase.ao = 3; return GridCellBase; }(Base)); export { GridCellBase };