igniteui-react-grids
Version:
Ignite UI React grid components.
577 lines (576 loc) • 19.4 kB
JavaScript
/*
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 } from "igniteui-react-core";
import { ICellRenderingEngine_$type } from "./ICellRenderingEngine";
import { CurrentRendererSettings } from "./CurrentRendererSettings";
import { RenderingContext } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { CanvasViewRenderer } from "igniteui-react-core";
import { intDivide } from "igniteui-react-core";
import { stringFormat1 } from "igniteui-react-core";
/**
* @hidden
*/
var DataGridCellLayoutPanel = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(DataGridCellLayoutPanel, _super);
function DataGridCellLayoutPanel(a, b, c) {
var _this = _super.call(this) || this;
_this.f = null;
_this.l = false;
_this.r = null;
_this._element = null;
_this.e = null;
_this.j = false;
_this._rootElement = null;
_this.n = false;
_this.h = null;
_this.m = false;
_this._requestAnimationFrame = null;
_this.v = 0;
_this.p = -1;
_this.o = -1;
_this.k = false;
_this.q = 0;
_this.c = null;
_this.a = null;
_this.d = null;
_this.b = null;
_this.q = c;
_this.r = a;
_this.requestAnimationFrame = _this.r.getRequestAnimationFrame();
_this.element = _this.r.createElement("div");
_this.element.setRawStyleProperty("position", "relative");
_this.element.setRawStyleProperty("box-sizing", "border-box");
_this.refresh(_this.f, false);
_this.e = b;
_this.j = false;
return _this;
}
Object.defineProperty(DataGridCellLayoutPanel.prototype, "element", {
get: function () {
return this._element;
},
set: function (a) {
this._element = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataGridCellLayoutPanel.prototype, "s", {
get: function () {
return this.r;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataGridCellLayoutPanel.prototype, "g", {
get: function () {
return this.f;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DataGridCellLayoutPanel.prototype, "rootElement", {
get: function () {
return this._rootElement;
},
set: function (a) {
this._rootElement = a;
},
enumerable: false,
configurable: true
});
DataGridCellLayoutPanel.prototype.refresh = function (a, b) {
this.f = a;
this.as(b);
};
DataGridCellLayoutPanel.prototype.viewportChanged = function () {
this.as(true);
};
DataGridCellLayoutPanel.prototype.invalidateVisibility = function (a) {
this.h = a;
this.n = true;
};
Object.defineProperty(DataGridCellLayoutPanel.prototype, "initialRefreshFinished", {
get: function () {
return this.j;
},
enumerable: false,
configurable: true
});
DataGridCellLayoutPanel.prototype.ag = function (a, b, c, d) {
this.as(true);
};
DataGridCellLayoutPanel.prototype.ar = function (a) {
var b = this.e.b(this.r, a);
if (b.isCanvasBased) {
var c = b.nativeCell.ah = false;
}
else {
var d = b.nativeCell.ah;
d.setRawStyleProperty("top", "-1000px");
d.setRawStyleProperty("left", "-1000px");
if (a.l.d != 0) {
d.setRawStyleProperty("clip", "auto");
}
b.nativeCell.isRemoved = true;
this.aj(a, d);
}
};
DataGridCellLayoutPanel.prototype.as = function (a) {
if (a) {
this.l = true;
this.z();
return;
}
if (this.m) {
return;
}
if (this.l) {
return;
}
this.l = true;
this.ac(runOn(this, this.z));
};
Object.defineProperty(DataGridCellLayoutPanel.prototype, "requestAnimationFrame", {
get: function () {
return this._requestAnimationFrame;
},
set: function (a) {
this._requestAnimationFrame = a;
},
enumerable: false,
configurable: true
});
DataGridCellLayoutPanel.prototype.ac = function (a) {
this.requestAnimationFrame(a);
};
DataGridCellLayoutPanel.prototype.z = function () {
if (!this.l) {
return;
}
this.l = false;
if (this.n) {
this.n = false;
this.h();
}
if (this.f == null) {
return;
}
if (Rect.l_op_Equality(this.f.actualVisibleRegion, null) || this.f.actualVisibleRegion.isEmpty) {
return;
}
this.j = true;
if (this.p != this.f.absoluteWidth) {
this.element.setRawStyleProperty("width", this.f.absoluteWidth + "px");
}
if (this.o != this.f.absoluteHeight) {
this.element.setRawStyleProperty("height", this.f.absoluteHeight + "px");
}
this.p = this.f.absoluteWidth;
this.o = this.f.absoluteHeight;
var a = this.f.actualVisibleRegion.top;
var b = this.f.actualVisibleRegion.left;
var c = this.f.cc;
var d = c.count;
var e = this.f.bz;
var f = this.f.bz.o;
var g = f.count;
var h = this.f.bz.p;
for (var i = 0; i < g; i++) {
if (h._inner[i]) {
continue;
}
var j = e.item(f._inner[i]);
for (var k = 0; k < j.count; k++) {
var l = j._inner[k];
this.ar(l);
}
}
e.u();
var m = false;
var n = this.v;
var o = true;
var p = false;
for (var q = 0; q < d; q++) {
var r = c._inner[q].q;
var s = c._inner[q].q.count;
var t = c._inner[q].p;
for (var u = 0; u < s; u++) {
if (t._inner[u]) {
continue;
}
var v = r._inner[u];
var w = this.e.b(this.r, v);
if (!w.isCanvasBased) {
o = false;
}
else {
p = true;
}
if (v.bh) {
m = true;
}
if (v.u == 1 && v.hh != n) {
m = true;
}
}
}
if (p) {
this.ab();
}
if (m) {
if (this.v == 0x7FFFFFFFFFFFFFFF - 1) {
this.v = 0;
}
else {
this.v++;
}
n = this.v;
}
var x = 0;
var y = new CurrentRendererSettings();
var z = this.q;
this.m = true;
for (var aa = 0; aa < d; aa++) {
var ab = c._inner[aa].q;
var ac = c._inner[aa].q.count;
var ad = c._inner[aa].p;
for (var ae = 0; ae < ac; ae++) {
if (ad._inner[ae]) {
continue;
}
var af = ab._inner[ae];
var ag = this.e.b(this.r, af);
if (ag.isCanvasBased) {
var ah = y.a;
this.aw(y, aa, af, this.f, x, m, o);
if (y.a != ah && m) {
x++;
}
}
var ai = ag.isCanvasBased;
var aj = null;
if (!ai) {
aj = ag.nativeCell.ah;
if (af.u == 0) {
this.element.append(aj);
ag.nativeCell.isRemoved = false;
this.ah(af, aj);
}
}
if (af.u == 1) {
if (ai) {
var ak = af.s.nativeCell;
ak.ah = true;
}
ag.nativeCell.isRemoved = false;
}
af.u = 2;
var al = (af.g0 + intDivide(af.hd, 2));
var am = (af.g2 + intDivide(af.fu, 2));
var an = (al - b) / this.f.actualVisibleRegion.width;
var ao = (am - a) / this.f.actualVisibleRegion.height;
if (af.bj) {
if (!ai) {
aj.setRawPosition(af.cu, af.cv);
}
}
if (!ai) {
if (af.l.d != 0) {
if (this.f.b2) {
aj.setRawStyleProperty("clip", this.w(af.l.d, af.cu, af.cv));
}
else {
aj.setRawStyleProperty("clip", "auto");
}
}
else if (af.l.ao) {
aj.setRawStyleProperty("clip", this.y(af));
}
else {
if (Rect.l_op_Inequality(af.me, Rect.empty)) {
aj.setRawStyleProperty("clip", this.x(af.me));
}
else {
aj.setRawStyleProperty("clip", "auto");
}
}
}
af.ku();
if (ai) {
var ap = af.s.nativeCell;
ap.co(z);
}
af.s.modelUpdated(af);
if (ai && y.b) {
var aq = y.a;
aq.aa();
if (af.l.d != 0 && this.f.b2) {
aq.af(this.ax(af.l.d));
}
var ar = af.s.nativeCell;
ar.b6(aq, y.c, y.d, af.cu, af.cv, z);
aq.z();
}
af.kn();
if (m) {
af.hh = n;
if (!ai) {
aj.setRawStyleProperty("z-index", x.toString());
}
x++;
}
this.ai(af, aj);
}
}
this.m = false;
if (y.a != null && this.q != 1) {
y.a.z();
}
this.an();
};
DataGridCellLayoutPanel.prototype.an = function () {
};
DataGridCellLayoutPanel.prototype.ab = function () {
if (!this.k) {
this.k = true;
var a = this.r.rootWrapper;
var b = (window.navigator.msPointerEnabled && window.MSGesture !== undefined);
var c = (window.PointerEvent !== undefined);
var d = (window.TouchEvent);
if ((b || c)) {
a.listen("pointerdown", runOn(this, this.ao));
a.listen("pointerup", runOn(this, this.aq));
a.listen("pointermove", runOn(this, this.ap));
}
else {
a.listen("mousedown", runOn(this, this.ad));
a.listen("mouseup", runOn(this, this.af));
a.listen("mousemove", runOn(this, this.ae));
a.listen("touchstart", runOn(this, this.at));
a.listen("touchend", runOn(this, this.av));
a.listen("touchmove", runOn(this, this.au));
}
a.listen("dblclick", runOn(this, this.aa));
}
};
DataGridCellLayoutPanel.prototype.ad = function (a) {
this.am(a, false);
};
DataGridCellLayoutPanel.prototype.af = function (a) {
this.ak(a, false);
};
DataGridCellLayoutPanel.prototype.ae = function (a) {
this.al(a, false);
};
DataGridCellLayoutPanel.prototype.aa = function (a) {
if (this.f == null) {
return;
}
var b = this.r.rootWrapper.getOffset();
var c = this.f.f(a.pageX - b.left, a.pageY - b.top);
if (c == null) {
return;
}
if (c.s != null) {
if (c.s.isCanvasBased && c.s.nativeCell != null) {
c.s.nativeCell.onDoubleClick(a);
}
}
};
DataGridCellLayoutPanel.prototype.ao = function (e_) {
var a = (e_.originalEvent.pointerType);
if (a == "touch") {
this.at(e_);
}
else {
this.ad(e_);
}
};
DataGridCellLayoutPanel.prototype.ap = function (e_) {
var a = (e_.originalEvent.pointerType);
if (a == "touch") {
this.au(e_);
}
else {
this.ae(e_);
}
};
DataGridCellLayoutPanel.prototype.aq = function (e_) {
var a = (e_.originalEvent.pointerType);
if (a == "touch") {
this.av(e_);
}
else {
this.af(e_);
}
};
DataGridCellLayoutPanel.prototype.at = function (a) {
this.am(a, true);
};
DataGridCellLayoutPanel.prototype.am = function (a, b) {
if (this.f == null) {
return;
}
var c = this.r.rootWrapper.getOffset();
var d = this.f.f(a.pageX - c.left, a.pageY - c.top);
if (d == null) {
return;
}
if (d.s != null) {
if (d.s.isCanvasBased && d.s.nativeCell != null) {
d.s.nativeCell.onContactStarted(a, b);
}
}
};
DataGridCellLayoutPanel.prototype.au = function (a) {
this.al(a, true);
};
DataGridCellLayoutPanel.prototype.al = function (a, b) {
if (this.f == null) {
return;
}
var c = this.r.rootWrapper.getOffset();
var d = this.f.f(a.pageX - c.left, a.pageY - c.top);
if (d == null) {
return;
}
if (d.s != null) {
if (d.s.isCanvasBased && d.s.nativeCell != null) {
d.s.nativeCell.onContactMoved(a, b);
}
}
};
DataGridCellLayoutPanel.prototype.av = function (a) {
this.ak(a, true);
};
DataGridCellLayoutPanel.prototype.ak = function (a, b) {
if (this.f == null) {
return;
}
var c = this.r.rootWrapper.getOffset();
var d = this.f.f(a.pageX - c.left, a.pageY - c.top);
if (d == null) {
return;
}
if (d.s != null) {
if (d.s.isCanvasBased && d.s.nativeCell != null) {
d.s.nativeCell.onContactCompleted(a, b);
}
}
};
DataGridCellLayoutPanel.prototype.aw = function (a, b, c, d, e, f, g) {
if (g) {
b = 0;
}
if (this.c == null) {
this.c = new Array(d.cc.count);
this.a = new Array(d.cc.count);
this.d = new Array(d.cc.count);
this.b = new Array(d.cc.count);
for (var h = 0; h < d.cc.count; h++) {
this.c[h] = null;
this.a[h] = null;
this.d[h] = -1;
this.b[h] = -1;
}
}
if (this.c[b] == null) {
var i = this.r.createElement("canvas");
this.a[b] = i;
i.setRawStyleProperty("position", "absolute");
i.setRawStyleProperty("z-index", e.toString());
this.element.append(i);
var j_1 = this.r.get2DCanvasContext(i);
var k = ((function () {
var $ret = new CanvasViewRenderer();
$ret.h$d = j_1;
return $ret;
})());
this.c[b] = new RenderingContext(k, j_1);
}
if (a.a != this.c[b]) {
a.a = this.c[b];
a.b = true;
a.c = d.actualVisibleRegion.left;
a.d = d.actualVisibleRegion.top;
var l = d.actualVisibleRegion.width * this.q;
var m = d.actualVisibleRegion.height * this.q;
if (l != this.d[b] || m != this.b[b]) {
this.a[b].setRawSize(d.actualVisibleRegion.width, d.actualVisibleRegion.height);
this.a[b].setAttribute("width", l + "px");
this.a[b].setAttribute("height", m + "px");
this.d[b] = l;
this.b[b] = m;
}
if (f) {
this.a[b].setRawStyleProperty("z-index", e.toString());
}
a.a.l(0, 0, d.actualVisibleRegion.width, d.actualVisibleRegion.height);
this.a[b].setRawPosition(a.c, a.d);
}
};
DataGridCellLayoutPanel.prototype.ax = function (a) {
var b = this.f.cr;
var c = this.f.cm + this.f.cj;
var d = this.f.cz;
var e = this.f.ch;
if (a == 2) {
c = Math.min(this.f.c4, this.f.cp) - this.f.c0 - this.f.ck;
d = this.f.c0;
}
return new Rect(0, c, b, d, e);
};
DataGridCellLayoutPanel.prototype.w = function (a, b, c) {
if (a != 0) {
var d = this.ax(a);
var e = d.x - b;
var f = d.y - c;
var g = e + d.width;
var h = f + d.height;
return "rect(" + f + "px," + g + "px," + h + "px," + e + "px)";
}
return "auto";
};
DataGridCellLayoutPanel.prototype.x = function (a) {
return stringFormat1("rect({0}px, {1}px, {2}px, {3}px)", a.top, a.right, a.bottom, a.left);
};
DataGridCellLayoutPanel.prototype.y = function (a) {
var b = a.cu < this.g.cn ? this.g.cn - a.cu : 0;
var c = 0;
var d = this.g.cy == -1 ? a.hd : (a.cu + a.hd > this.g.co) ? a.hd - (a.cu + a.hd - this.g.co) : a.hd;
var e = a.fu;
return this.x(new Rect(0, b, c, d, e));
};
DataGridCellLayoutPanel.prototype.ah = function (a, b) {
};
DataGridCellLayoutPanel.prototype.aj = function (a, b) {
};
DataGridCellLayoutPanel.prototype.ai = function (a, b) {
};
DataGridCellLayoutPanel.prototype.detach = function () {
if (this.f == null) {
return;
}
for (var a = 0; a < this.f.cc.count; a++) {
var b = this.f.cc._inner[a].q;
for (var c = 0; c < b.count; c++) {
var d = b._inner[c];
if (d.s != null && d.s.nativeCell != null) {
d.s.nativeCell.detach();
}
}
}
};
DataGridCellLayoutPanel.prototype.attach = function () {
};
DataGridCellLayoutPanel.$t = markType(DataGridCellLayoutPanel, 'DataGridCellLayoutPanel', Base.$, [ICellRenderingEngine_$type]);
return DataGridCellLayoutPanel;
}(Base));
export { DataGridCellLayoutPanel };