igniteui-react-grids
Version:
Ignite UI React grid components.
551 lines (550 loc) • 18.8 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 { 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
*/
export let DataGridCellLayoutPanel = /*@__PURE__*/ (() => {
class DataGridCellLayoutPanel extends Base {
get element() {
return this._element;
}
set element(a) {
this._element = a;
}
get s() {
return this.r;
}
get g() {
return this.f;
}
get rootElement() {
return this._rootElement;
}
set rootElement(a) {
this._rootElement = a;
}
constructor(a, b, c) {
super();
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;
}
refresh(a, b) {
this.f = a;
this.as(b);
}
viewportChanged() {
this.as(true);
}
invalidateVisibility(a) {
this.h = a;
this.n = true;
}
get initialRefreshFinished() {
return this.j;
}
ag(a, b, c, d) {
this.as(true);
}
ar(a) {
let b = this.e.b(this.r, a);
if (b.isCanvasBased) {
let c = b.nativeCell.ah = false;
}
else {
let 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);
}
}
as(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));
}
get requestAnimationFrame() {
return this._requestAnimationFrame;
}
set requestAnimationFrame(a) {
this._requestAnimationFrame = a;
}
ac(a) {
this.requestAnimationFrame(a);
}
z() {
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;
let a = this.f.actualVisibleRegion.top;
let b = this.f.actualVisibleRegion.left;
let c = this.f.cc;
let d = c.count;
let e = this.f.bz;
let f = this.f.bz.o;
let g = f.count;
let h = this.f.bz.p;
for (let i = 0; i < g; i++) {
if (h._inner[i]) {
continue;
}
let j = e.item(f._inner[i]);
for (let k = 0; k < j.count; k++) {
let l = j._inner[k];
this.ar(l);
}
}
e.u();
let m = false;
let n = this.v;
let o = true;
let p = false;
for (let q = 0; q < d; q++) {
let r = c._inner[q].q;
let s = c._inner[q].q.count;
let t = c._inner[q].p;
for (let u = 0; u < s; u++) {
if (t._inner[u]) {
continue;
}
let v = r._inner[u];
let 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;
}
let x = 0;
let y = new CurrentRendererSettings();
let z = this.q;
this.m = true;
for (let aa = 0; aa < d; aa++) {
let ab = c._inner[aa].q;
let ac = c._inner[aa].q.count;
let ad = c._inner[aa].p;
for (let ae = 0; ae < ac; ae++) {
if (ad._inner[ae]) {
continue;
}
let af = ab._inner[ae];
let ag = this.e.b(this.r, af);
if (ag.isCanvasBased) {
let ah = y.a;
this.aw(y, aa, af, this.f, x, m, o);
if (y.a != ah && m) {
x++;
}
}
let ai = ag.isCanvasBased;
let 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) {
let ak = af.s.nativeCell;
ak.ah = true;
}
ag.nativeCell.isRemoved = false;
}
af.u = 2;
let al = (af.g0 + intDivide(af.hd, 2));
let am = (af.g2 + intDivide(af.fu, 2));
let an = (al - b) / this.f.actualVisibleRegion.width;
let 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) {
let ap = af.s.nativeCell;
ap.co(z);
}
af.s.modelUpdated(af);
if (ai && y.b) {
let aq = y.a;
aq.aa();
if (af.l.d != 0 && this.f.b2) {
aq.af(this.ax(af.l.d));
}
let 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();
}
an() {
}
ab() {
if (!this.k) {
this.k = true;
let a = this.r.rootWrapper;
let b = (window.navigator.msPointerEnabled && window.MSGesture !== undefined);
let c = (window.PointerEvent !== undefined);
let 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));
}
}
ad(a) {
this.am(a, false);
}
af(a) {
this.ak(a, false);
}
ae(a) {
this.al(a, false);
}
aa(a) {
if (this.f == null) {
return;
}
let b = this.r.rootWrapper.getOffset();
let 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);
}
}
}
ao(e_) {
let a = (e_.originalEvent.pointerType);
if (a == "touch") {
this.at(e_);
}
else {
this.ad(e_);
}
}
ap(e_) {
let a = (e_.originalEvent.pointerType);
if (a == "touch") {
this.au(e_);
}
else {
this.ae(e_);
}
}
aq(e_) {
let a = (e_.originalEvent.pointerType);
if (a == "touch") {
this.av(e_);
}
else {
this.af(e_);
}
}
at(a) {
this.am(a, true);
}
am(a, b) {
if (this.f == null) {
return;
}
let c = this.r.rootWrapper.getOffset();
let 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);
}
}
}
au(a) {
this.al(a, true);
}
al(a, b) {
if (this.f == null) {
return;
}
let c = this.r.rootWrapper.getOffset();
let 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);
}
}
}
av(a) {
this.ak(a, true);
}
ak(a, b) {
if (this.f == null) {
return;
}
let c = this.r.rootWrapper.getOffset();
let 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);
}
}
}
aw(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 (let 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) {
let i = this.r.createElement("canvas");
this.a[b] = i;
i.setRawStyleProperty("position", "absolute");
i.setRawStyleProperty("z-index", e.toString());
this.element.append(i);
let j = this.r.get2DCanvasContext(i);
let k = ((() => {
let $ret = new CanvasViewRenderer();
$ret.h$d = j;
return $ret;
})());
this.c[b] = new RenderingContext(k, j);
}
if (a.a != this.c[b]) {
a.a = this.c[b];
a.b = true;
a.c = d.actualVisibleRegion.left;
a.d = d.actualVisibleRegion.top;
let l = d.actualVisibleRegion.width * this.q;
let 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);
}
}
ax(a) {
let b = this.f.cr;
let c = this.f.cm + this.f.cj;
let d = this.f.cz;
let 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);
}
w(a, b, c) {
if (a != 0) {
let d = this.ax(a);
let e = d.x - b;
let f = d.y - c;
let g = e + d.width;
let h = f + d.height;
return "rect(" + f + "px," + g + "px," + h + "px," + e + "px)";
}
return "auto";
}
x(a) {
return stringFormat1("rect({0}px, {1}px, {2}px, {3}px)", a.top, a.right, a.bottom, a.left);
}
y(a) {
let b = a.cu < this.g.cn ? this.g.cn - a.cu : 0;
let c = 0;
let 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;
let e = a.fu;
return this.x(new Rect(0, b, c, d, e));
}
ah(a, b) {
}
aj(a, b) {
}
ai(a, b) {
}
detach() {
if (this.f == null) {
return;
}
for (let a = 0; a < this.f.cc.count; a++) {
let b = this.f.cc._inner[a].q;
for (let c = 0; c < b.count; c++) {
let d = b._inner[c];
if (d.s != null && d.s.nativeCell != null) {
d.s.nativeCell.detach();
}
}
}
}
attach() {
}
}
DataGridCellLayoutPanel.$t = /*@__PURE__*/ markType(DataGridCellLayoutPanel, 'DataGridCellLayoutPanel', Base.$, [ICellRenderingEngine_$type]);
return DataGridCellLayoutPanel;
})();